mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 23:01:37 +00:00
feat(factory): finish workbench milestone pass
This commit is contained in:
parent
bf282199b5
commit
49cba9e6c2
137 changed files with 819 additions and 338 deletions
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@openhandoff/frontend-errors",
|
||||
"name": "@sandbox-agent/factory-frontend-errors",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ interface FrontendErrorCollectorGlobal {
|
|||
|
||||
declare global {
|
||||
interface Window {
|
||||
__OPENHANDOFF_FRONTEND_ERROR_COLLECTOR__?: FrontendErrorCollectorGlobal;
|
||||
__OPENHANDOFF_FRONTEND_ERROR_CONTEXT__?: FrontendErrorContext;
|
||||
__FACTORY_FRONTEND_ERROR_COLLECTOR__?: FrontendErrorCollectorGlobal;
|
||||
__FACTORY_FRONTEND_ERROR_CONTEXT__?: FrontendErrorContext;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -17,11 +17,11 @@ export function setFrontendErrorContext(context: FrontendErrorContext): void {
|
|||
}
|
||||
|
||||
const nextContext = sanitizeContext(context);
|
||||
window.__OPENHANDOFF_FRONTEND_ERROR_CONTEXT__ = {
|
||||
...(window.__OPENHANDOFF_FRONTEND_ERROR_CONTEXT__ ?? {}),
|
||||
window.__FACTORY_FRONTEND_ERROR_CONTEXT__ = {
|
||||
...(window.__FACTORY_FRONTEND_ERROR_CONTEXT__ ?? {}),
|
||||
...nextContext,
|
||||
};
|
||||
window.__OPENHANDOFF_FRONTEND_ERROR_COLLECTOR__?.setContext(nextContext);
|
||||
window.__FACTORY_FRONTEND_ERROR_COLLECTOR__?.setContext(nextContext);
|
||||
}
|
||||
|
||||
function sanitizeContext(input: FrontendErrorContext): FrontendErrorContext {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import { dirname, join, resolve } from "node:path";
|
|||
import { Hono } from "hono";
|
||||
import type { FrontendErrorContext, FrontendErrorKind, FrontendErrorLogEvent } from "./types.js";
|
||||
|
||||
const DEFAULT_RELATIVE_LOG_PATH = ".openhandoff/logs/frontend-errors.ndjson";
|
||||
const DEFAULT_REPORTER = "openhandoff-frontend";
|
||||
const DEFAULT_RELATIVE_LOG_PATH = ".sandbox-agent-factory/logs/frontend-errors.ndjson";
|
||||
const DEFAULT_REPORTER = "sandbox-agent-factory";
|
||||
const MAX_FIELD_LENGTH = 12_000;
|
||||
|
||||
export interface FrontendErrorCollectorRouterOptions {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { FrontendErrorCollectorScriptOptions } from "./types.js";
|
||||
|
||||
const DEFAULT_REPORTER = "openhandoff-frontend";
|
||||
const DEFAULT_REPORTER = "sandbox-agent-factory";
|
||||
|
||||
export function createFrontendErrorCollectorScript(
|
||||
options: FrontendErrorCollectorScriptOptions
|
||||
|
|
@ -17,13 +17,13 @@ export function createFrontendErrorCollectorScript(
|
|||
return;
|
||||
}
|
||||
|
||||
if (window.__OPENHANDOFF_FRONTEND_ERROR_COLLECTOR__) {
|
||||
if (window.__FACTORY_FRONTEND_ERROR_COLLECTOR__) {
|
||||
return;
|
||||
}
|
||||
|
||||
var config = ${JSON.stringify(config)};
|
||||
var sharedContext = window.__OPENHANDOFF_FRONTEND_ERROR_CONTEXT__ || {};
|
||||
window.__OPENHANDOFF_FRONTEND_ERROR_CONTEXT__ = sharedContext;
|
||||
var sharedContext = window.__FACTORY_FRONTEND_ERROR_CONTEXT__ || {};
|
||||
window.__FACTORY_FRONTEND_ERROR_CONTEXT__ = sharedContext;
|
||||
|
||||
function now() {
|
||||
return Date.now();
|
||||
|
|
@ -124,7 +124,7 @@ export function createFrontendErrorCollectorScript(
|
|||
});
|
||||
}
|
||||
|
||||
window.__OPENHANDOFF_FRONTEND_ERROR_COLLECTOR__ = {
|
||||
window.__FACTORY_FRONTEND_ERROR_COLLECTOR__ = {
|
||||
setContext: function (nextContext) {
|
||||
if (!nextContext || typeof nextContext !== "object") {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import type { Plugin } from "vite";
|
|||
import { createFrontendErrorCollectorRouter, defaultFrontendErrorLogPath } from "./router.js";
|
||||
import { createFrontendErrorCollectorScript } from "./script.js";
|
||||
|
||||
const DEFAULT_MOUNT_PATH = "/__openhandoff/frontend-errors";
|
||||
const DEFAULT_MOUNT_PATH = "/__factory/frontend-errors";
|
||||
const DEFAULT_EVENT_PATH = "/events";
|
||||
|
||||
export interface FrontendErrorCollectorVitePluginOptions {
|
||||
|
|
@ -20,7 +20,7 @@ export function frontendErrorCollectorVitePlugin(
|
|||
): Plugin {
|
||||
const mountPath = normalizePath(options.mountPath ?? DEFAULT_MOUNT_PATH);
|
||||
const logFilePath = options.logFilePath ?? defaultFrontendErrorLogPath(process.cwd());
|
||||
const reporter = options.reporter ?? "openhandoff-vite";
|
||||
const reporter = options.reporter ?? "factory-vite";
|
||||
const endpoint = `${mountPath}${DEFAULT_EVENT_PATH}`;
|
||||
|
||||
const router = createFrontendErrorCollectorRouter({
|
||||
|
|
@ -31,7 +31,7 @@ export function frontendErrorCollectorVitePlugin(
|
|||
const listener = getRequestListener(mountApp.fetch);
|
||||
|
||||
return {
|
||||
name: "openhandoff:frontend-error-collector",
|
||||
name: "factory:frontend-error-collector",
|
||||
apply: "serve",
|
||||
transformIndexHtml(html) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ describe("frontend error collector router", () => {
|
|||
describe("frontend error collector script", () => {
|
||||
test("embeds configured endpoint", () => {
|
||||
const script = createFrontendErrorCollectorScript({
|
||||
endpoint: "/__openhandoff/frontend-errors/events",
|
||||
endpoint: "/__factory/frontend-errors/events",
|
||||
});
|
||||
expect(script).toContain("/__openhandoff/frontend-errors/events");
|
||||
expect(script).toContain("/__factory/frontend-errors/events");
|
||||
expect(script).toContain("window.addEventListener(\"error\"");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue