dev3000 0.0.189 → 0.0.192
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -12
- package/dist/cdp-monitor.d.ts +10 -0
- package/dist/cdp-monitor.d.ts.map +1 -1
- package/dist/cdp-monitor.js +28 -4
- package/dist/cdp-monitor.js.map +1 -1
- package/dist/runtime/bridge.d.ts +2 -0
- package/dist/runtime/bridge.d.ts.map +1 -1
- package/dist/runtime/bridge.js +74 -0
- package/dist/runtime/bridge.js.map +1 -1
- package/dist/runtime/browser-capture.d.ts +117 -0
- package/dist/runtime/browser-capture.d.ts.map +1 -0
- package/dist/runtime/browser-capture.js +274 -0
- package/dist/runtime/browser-capture.js.map +1 -0
- package/dist/runtime/browser-compare.d.ts +91 -0
- package/dist/runtime/browser-compare.d.ts.map +1 -0
- package/dist/runtime/browser-compare.js +129 -0
- package/dist/runtime/browser-compare.js.map +1 -0
- package/dist/runtime/browser-events.d.ts +3 -2
- package/dist/runtime/browser-events.d.ts.map +1 -1
- package/dist/runtime/browser-events.js +11 -53
- package/dist/runtime/browser-events.js.map +1 -1
- package/dist/runtime/browser-metrics.d.ts +148 -0
- package/dist/runtime/browser-metrics.d.ts.map +1 -0
- package/dist/runtime/browser-metrics.js +243 -0
- package/dist/runtime/browser-metrics.js.map +1 -0
- package/dist/runtime/chrome-isolation.d.ts +4 -2
- package/dist/runtime/chrome-isolation.d.ts.map +1 -1
- package/dist/runtime/chrome-isolation.js +24 -35
- package/dist/runtime/chrome-isolation.js.map +1 -1
- package/dist/runtime/cli.js +67 -2
- package/dist/runtime/cli.js.map +1 -1
- package/dist/runtime/desktop-mcp.d.ts +216 -0
- package/dist/runtime/desktop-mcp.d.ts.map +1 -0
- package/dist/runtime/desktop-mcp.js +258 -0
- package/dist/runtime/desktop-mcp.js.map +1 -0
- package/dist/runtime/git-identity.d.ts +17 -0
- package/dist/runtime/git-identity.d.ts.map +1 -0
- package/dist/runtime/git-identity.js +41 -0
- package/dist/runtime/git-identity.js.map +1 -0
- package/dist/runtime/github-publish.d.ts +31 -0
- package/dist/runtime/github-publish.d.ts.map +1 -0
- package/dist/runtime/github-publish.js +237 -0
- package/dist/runtime/github-publish.js.map +1 -0
- package/dist/runtime/harness.d.ts +14 -3
- package/dist/runtime/harness.d.ts.map +1 -1
- package/dist/runtime/harness.js +55 -7
- package/dist/runtime/harness.js.map +1 -1
- package/dist/runtime/managed-cdp.d.ts +10 -0
- package/dist/runtime/managed-cdp.d.ts.map +1 -0
- package/dist/runtime/managed-cdp.js +80 -0
- package/dist/runtime/managed-cdp.js.map +1 -0
- package/dist/runtime/mcp-stdio.d.ts +17 -0
- package/dist/runtime/mcp-stdio.d.ts.map +1 -0
- package/dist/runtime/mcp-stdio.js +99 -0
- package/dist/runtime/mcp-stdio.js.map +1 -0
- package/dist/runtime/network-evidence.d.ts +28 -0
- package/dist/runtime/network-evidence.d.ts.map +1 -0
- package/dist/runtime/network-evidence.js +291 -0
- package/dist/runtime/network-evidence.js.map +1 -0
- package/dist/runtime/package-manager.d.ts +13 -0
- package/dist/runtime/package-manager.d.ts.map +1 -0
- package/dist/runtime/package-manager.js +69 -0
- package/dist/runtime/package-manager.js.map +1 -0
- package/dist/runtime/runtime.d.ts +7 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +54 -30
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/sandbox-agent.d.ts +5 -0
- package/dist/runtime/sandbox-agent.d.ts.map +1 -1
- package/dist/runtime/sandbox-agent.js +32 -0
- package/dist/runtime/sandbox-agent.js.map +1 -1
- package/dist/runtime/sandbox-cleanup.d.ts +14 -0
- package/dist/runtime/sandbox-cleanup.d.ts.map +1 -0
- package/dist/runtime/sandbox-cleanup.js +77 -0
- package/dist/runtime/sandbox-cleanup.js.map +1 -0
- package/dist/runtime/sandbox-command.d.ts +1 -0
- package/dist/runtime/sandbox-command.d.ts.map +1 -1
- package/dist/runtime/sandbox-command.js +39 -9
- package/dist/runtime/sandbox-command.js.map +1 -1
- package/dist/runtime/sandbox-context.d.ts +5 -0
- package/dist/runtime/sandbox-context.d.ts.map +1 -0
- package/dist/runtime/sandbox-context.js +42 -0
- package/dist/runtime/sandbox-context.js.map +1 -0
- package/dist/runtime/sandbox-fx-resume.d.ts +11 -0
- package/dist/runtime/sandbox-fx-resume.d.ts.map +1 -0
- package/dist/runtime/sandbox-fx-resume.js +45 -0
- package/dist/runtime/sandbox-fx-resume.js.map +1 -0
- package/dist/runtime/sandbox-gateway.d.ts +17 -0
- package/dist/runtime/sandbox-gateway.d.ts.map +1 -0
- package/dist/runtime/sandbox-gateway.js +34 -0
- package/dist/runtime/sandbox-gateway.js.map +1 -0
- package/dist/runtime/sandbox-git.d.ts +19 -0
- package/dist/runtime/sandbox-git.d.ts.map +1 -0
- package/dist/runtime/sandbox-git.js +42 -0
- package/dist/runtime/sandbox-git.js.map +1 -0
- package/dist/runtime/sandbox-github.d.ts +10 -0
- package/dist/runtime/sandbox-github.d.ts.map +1 -0
- package/dist/runtime/sandbox-github.js +35 -0
- package/dist/runtime/sandbox-github.js.map +1 -0
- package/dist/runtime/sandbox-local-harness.d.ts +34 -0
- package/dist/runtime/sandbox-local-harness.d.ts.map +1 -0
- package/dist/runtime/sandbox-local-harness.js +151 -0
- package/dist/runtime/sandbox-local-harness.js.map +1 -0
- package/dist/runtime/sandbox-ports.d.ts +6 -0
- package/dist/runtime/sandbox-ports.d.ts.map +1 -0
- package/dist/runtime/sandbox-ports.js +11 -0
- package/dist/runtime/sandbox-ports.js.map +1 -0
- package/dist/runtime/sandbox-preview.d.ts +14 -0
- package/dist/runtime/sandbox-preview.d.ts.map +1 -0
- package/dist/runtime/sandbox-preview.js +96 -0
- package/dist/runtime/sandbox-preview.js.map +1 -0
- package/dist/runtime/sandbox-process.d.ts +11 -0
- package/dist/runtime/sandbox-process.d.ts.map +1 -0
- package/dist/runtime/sandbox-process.js +77 -0
- package/dist/runtime/sandbox-process.js.map +1 -0
- package/dist/runtime/sandbox-proxy.d.ts +2 -0
- package/dist/runtime/sandbox-proxy.d.ts.map +1 -1
- package/dist/runtime/sandbox-proxy.js +75 -20
- package/dist/runtime/sandbox-proxy.js.map +1 -1
- package/dist/runtime/sandbox-recovery.d.ts +4 -0
- package/dist/runtime/sandbox-recovery.d.ts.map +1 -0
- package/dist/runtime/sandbox-recovery.js +36 -0
- package/dist/runtime/sandbox-recovery.js.map +1 -0
- package/dist/runtime/sandbox-sessions.d.ts +8 -1
- package/dist/runtime/sandbox-sessions.d.ts.map +1 -1
- package/dist/runtime/sandbox-sessions.js +20 -2
- package/dist/runtime/sandbox-sessions.js.map +1 -1
- package/dist/runtime/sandbox-setup.d.ts +5 -0
- package/dist/runtime/sandbox-setup.d.ts.map +1 -0
- package/dist/runtime/sandbox-setup.js +62 -0
- package/dist/runtime/sandbox-setup.js.map +1 -0
- package/dist/runtime/sandbox-shell.d.ts +27 -0
- package/dist/runtime/sandbox-shell.d.ts.map +1 -0
- package/dist/runtime/sandbox-shell.js +169 -0
- package/dist/runtime/sandbox-shell.js.map +1 -0
- package/dist/runtime/sandbox-watch.d.ts +11 -0
- package/dist/runtime/sandbox-watch.d.ts.map +1 -0
- package/dist/runtime/sandbox-watch.js +30 -0
- package/dist/runtime/sandbox-watch.js.map +1 -0
- package/dist/runtime/sandbox-workspace.d.ts +125 -0
- package/dist/runtime/sandbox-workspace.d.ts.map +1 -0
- package/dist/runtime/sandbox-workspace.js +205 -0
- package/dist/runtime/sandbox-workspace.js.map +1 -0
- package/dist/runtime/sandbox.d.ts +21 -2
- package/dist/runtime/sandbox.d.ts.map +1 -1
- package/dist/runtime/sandbox.js +473 -207
- package/dist/runtime/sandbox.js.map +1 -1
- package/dist/runtime/session.d.ts +1 -1
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +3 -3
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/terminal.d.ts +19 -0
- package/dist/runtime/terminal.d.ts.map +1 -0
- package/dist/runtime/terminal.js +60 -0
- package/dist/runtime/terminal.js.map +1 -0
- package/dist/runtime/workspace-client.d.ts +2 -0
- package/dist/runtime/workspace-client.d.ts.map +1 -0
- package/dist/runtime/workspace-client.js +46 -0
- package/dist/runtime/workspace-client.js.map +1 -0
- package/package.json +2 -1
- package/scripts/eve/README.md +341 -0
- package/scripts/eve/agent/agent.ts +12 -0
- package/scripts/eve/agent/channels/eve.ts +23 -0
- package/scripts/eve/agent/instructions.md +53 -0
- package/scripts/eve/agent/sandbox.ts +34 -0
- package/scripts/eve/build-cache.mjs +18 -0
- package/scripts/eve/build-cache.test.mjs +32 -0
- package/scripts/eve/client.mjs +229 -0
- package/scripts/eve/connection.mjs +89 -0
- package/scripts/eve/conversation.mjs +91 -0
- package/scripts/eve/conversation.test.mjs +113 -0
- package/scripts/eve/fixture-agent.ts +101 -0
- package/scripts/eve/images.mjs +84 -0
- package/scripts/eve/launch.mjs +277 -0
- package/scripts/eve/model-command.mjs +21 -0
- package/scripts/eve/reconnect.mjs +22 -0
- package/scripts/eve/reconnect.test.mjs +41 -0
- package/scripts/eve/settings.mjs +33 -0
- package/scripts/eve/supervisor.mjs +41 -0
- package/scripts/eve/tui-client.mjs +234 -0
- package/scripts/eve/tui-input.mjs +114 -0
- package/scripts/eve/verify.mjs +575 -0
- package/skills/d3k/SKILL.md +60 -5
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { harnessStartupContext } from "./harness.js";
|
|
2
|
+
// fx loads ~/.fx/AGENTS.md at startup, whereas --add-dir exposes skills only
|
|
3
|
+
// for optional discovery. Preload the connected skill outside the project repo.
|
|
4
|
+
export const sandboxFxContextScript = `
|
|
5
|
+
const fs = require('node:fs'), path = require('node:path'), os = require('node:os');
|
|
6
|
+
const directory = path.join(os.homedir(), '.fx');
|
|
7
|
+
const file = path.join(directory, 'AGENTS.md');
|
|
8
|
+
const start = '\\n<!-- d3k-browser-context:start -->\\n';
|
|
9
|
+
const end = '\\n<!-- d3k-browser-context:end -->\\n';
|
|
10
|
+
const mode = process.argv[1];
|
|
11
|
+
let current = '';
|
|
12
|
+
try {
|
|
13
|
+
if (!fs.lstatSync(file).isFile()) throw new Error('Sandbox fx instructions must be a regular file');
|
|
14
|
+
current = fs.readFileSync(file, 'utf8');
|
|
15
|
+
} catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
16
|
+
let body = current;
|
|
17
|
+
const begin = body.indexOf(start);
|
|
18
|
+
if (begin !== -1) {
|
|
19
|
+
const finish = body.indexOf(end, begin + start.length);
|
|
20
|
+
if (finish === -1) throw new Error('Incomplete d3k browser context block');
|
|
21
|
+
body = body.slice(0, begin) + body.slice(finish + end.length);
|
|
22
|
+
}
|
|
23
|
+
if (mode === 'install') body += start + process.argv[2] + end;
|
|
24
|
+
else if (mode !== 'remove') throw new Error('Unknown browser context operation');
|
|
25
|
+
if (body !== current) {
|
|
26
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
27
|
+
if (body.length === 0) fs.unlinkSync(file);
|
|
28
|
+
else fs.writeFileSync(file, body, { mode: 0o600 });
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
export async function sandboxFxContext(sandbox, context, signal) {
|
|
32
|
+
const note = context ? harnessStartupContext(context) : undefined;
|
|
33
|
+
const result = await sandbox.runCommand({
|
|
34
|
+
cmd: "node",
|
|
35
|
+
args: ["-e", sandboxFxContextScript, note ? "install" : "remove", ...(note ? [note] : [])],
|
|
36
|
+
timeoutMs: 5000,
|
|
37
|
+
signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(6000)]) : AbortSignal.timeout(6000)
|
|
38
|
+
});
|
|
39
|
+
if (result.exitCode !== 0)
|
|
40
|
+
throw new Error("Could not update sandbox fx browser context");
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=sandbox-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-context.js","sourceRoot":"","sources":["../../src/runtime/sandbox-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAA8B,MAAM,cAAc,CAAA;AAEhF,6EAA6E;AAC7E,gFAAgF;AAChF,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BrC,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAgB,EAChB,OAA+B,EAC/B,MAAoB;IAEpB,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACjE,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC;QACtC,GAAG,EAAE,MAAM;QACX,IAAI,EAAE,CAAC,IAAI,EAAE,sBAAsB,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC1F,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;KAClG,CAAC,CAAA;IACF,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;AAC3F,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SandboxSession } from "./sandbox-sessions.js";
|
|
2
|
+
interface FxSession {
|
|
3
|
+
workspace_root: string;
|
|
4
|
+
created_at_ms: number;
|
|
5
|
+
updated_at_ms: number;
|
|
6
|
+
}
|
|
7
|
+
/** Recover old temporary workspace identities from fx metadata, never conversation contents. */
|
|
8
|
+
export declare function legacyFxWorkspace(record: SandboxSession, records: SandboxSession[], sessions: FxSession[]): string | undefined;
|
|
9
|
+
export declare function discoverLegacyFxWorkspace(record: SandboxSession, records: SandboxSession[], invoke: (args: string[]) => Promise<string>): Promise<string | undefined>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=sandbox-fx-resume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-fx-resume.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-fx-resume.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE3D,UAAU,SAAS;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,cAAc,EAAE,EACzB,QAAQ,EAAE,SAAS,EAAE,GACpB,MAAM,GAAG,SAAS,CA+BpB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,cAAc,EAAE,EACzB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,GAC1C,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAmB7B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { basename, dirname, resolve } from "node:path";
|
|
4
|
+
/** Recover old temporary workspace identities from fx metadata, never conversation contents. */
|
|
5
|
+
export function legacyFxWorkspace(record, records, sessions) {
|
|
6
|
+
const start = Date.parse(record.lastUsedAt);
|
|
7
|
+
const end = Date.parse(record.closedAt || "");
|
|
8
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || end < start)
|
|
9
|
+
return undefined;
|
|
10
|
+
// Concurrent launchers make a time-based association ambiguous. Do not guess.
|
|
11
|
+
if (records.some((other) => other.id !== record.id &&
|
|
12
|
+
other.harness === "fx" &&
|
|
13
|
+
other.harnessLocation !== "sandbox" &&
|
|
14
|
+
Date.parse(other.lastUsedAt) <= end &&
|
|
15
|
+
Date.parse(other.closedAt || "9999-01-01") >= start))
|
|
16
|
+
return undefined;
|
|
17
|
+
const roots = new Set(sessions
|
|
18
|
+
.filter((session) => typeof session.workspace_root === "string" &&
|
|
19
|
+
session.created_at_ms >= start &&
|
|
20
|
+
session.updated_at_ms >= session.created_at_ms &&
|
|
21
|
+
session.updated_at_ms <= end &&
|
|
22
|
+
basename(session.workspace_root) === "control" &&
|
|
23
|
+
basename(dirname(session.workspace_root)).startsWith("d3k-sandbox-") &&
|
|
24
|
+
dirname(dirname(resolve(session.workspace_root))) === realpathSync(tmpdir()))
|
|
25
|
+
.map((session) => session.workspace_root));
|
|
26
|
+
return roots.size === 1 ? [...roots][0] : undefined;
|
|
27
|
+
}
|
|
28
|
+
export async function discoverLegacyFxWorkspace(record, records, invoke) {
|
|
29
|
+
const sessions = [];
|
|
30
|
+
let cursor;
|
|
31
|
+
for (let page = 0; page < 10; page++) {
|
|
32
|
+
const response = JSON.parse(await invoke(["sessions", "--all", "--json", "--limit", "100", ...(cursor ? ["--cursor", cursor] : [])]));
|
|
33
|
+
if (!Array.isArray(response.sessions))
|
|
34
|
+
throw new Error("fx did not return saved-session metadata");
|
|
35
|
+
sessions.push(...response.sessions);
|
|
36
|
+
if (!response.has_more)
|
|
37
|
+
return legacyFxWorkspace(record, records, sessions);
|
|
38
|
+
if (!response.next_cursor || response.next_cursor === cursor)
|
|
39
|
+
break;
|
|
40
|
+
cursor = response.next_cursor;
|
|
41
|
+
}
|
|
42
|
+
// An incomplete listing cannot establish that the association is unique.
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=sandbox-fx-resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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C,IAAI,CAAC,QAAQ,CAAC,QAAQ;YAAE,OAAO,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC3E,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,KAAK,MAAM;YAAE,MAAK;QACnE,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAA;IAC/B,CAAC;IACD,yEAAyE;IACzE,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type Run = (binary: string, args: string[], options?: {
|
|
2
|
+
input?: string;
|
|
3
|
+
}) => Promise<string>;
|
|
4
|
+
/** The CLI authenticates locally. Only this purpose/project-restricted key goes into the VM. */
|
|
5
|
+
export declare function createSandboxGateway(run: Run, options: {
|
|
6
|
+
projectId: string;
|
|
7
|
+
teamId: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
minutes: number;
|
|
10
|
+
budget?: number;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
id: string;
|
|
13
|
+
key: string;
|
|
14
|
+
expiresAt: number;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=sandbox-gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-gateway.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-gateway.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAE5F,gGAAgG;AAChG,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;;GA0CpG"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** The CLI authenticates locally. Only this purpose/project-restricted key goes into the VM. */
|
|
2
|
+
export async function createSandboxGateway(run, options) {
|
|
3
|
+
if (options.budget !== undefined && (!Number.isFinite(options.budget) || options.budget < 1))
|
|
4
|
+
throw new Error("Gateway budget must be at least 1 USD");
|
|
5
|
+
const expiresAt = Date.now() + options.minutes * 60000;
|
|
6
|
+
const result = JSON.parse(await run("vercel", ["api", "/v1/api-keys", "--method", "POST", "--scope", options.teamId, "--input", "-", "--raw"], {
|
|
7
|
+
input: JSON.stringify({
|
|
8
|
+
purpose: "ai-gateway",
|
|
9
|
+
projectId: options.projectId,
|
|
10
|
+
name: `d3k ${options.sessionId}`,
|
|
11
|
+
expiresAt,
|
|
12
|
+
...(options.budget === undefined
|
|
13
|
+
? {}
|
|
14
|
+
: { aiGatewayQuota: { limitAmount: options.budget, refreshPeriod: "none", includeByokInQuota: true } })
|
|
15
|
+
})
|
|
16
|
+
}));
|
|
17
|
+
const id = result.apiKey?.id;
|
|
18
|
+
const revoke = async () => {
|
|
19
|
+
if (!id)
|
|
20
|
+
return;
|
|
21
|
+
await run("vercel", ["ai-gateway", "api-keys", "revoke", id, "--scope", options.teamId, "--yes"]);
|
|
22
|
+
};
|
|
23
|
+
if (!id ||
|
|
24
|
+
!result.apiKeyString ||
|
|
25
|
+
result.apiKey?.purpose !== "ai-gateway" ||
|
|
26
|
+
result.apiKey.projectId !== options.projectId ||
|
|
27
|
+
result.apiKey.teamId !== options.teamId ||
|
|
28
|
+
result.apiKey.expiresAt !== expiresAt) {
|
|
29
|
+
await revoke();
|
|
30
|
+
throw new Error("Vercel did not return a project-scoped, expiring Gateway key");
|
|
31
|
+
}
|
|
32
|
+
return { id, key: result.apiKeyString, expiresAt };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL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QACxB,IAAI,CAAC,EAAE;YAAE,OAAM;QACf,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACnG,CAAC,CAAA;IACD,IACE,CAAC,EAAE;QACH,CAAC,MAAM,CAAC,YAAY;QACpB,MAAM,CAAC,MAAM,EAAE,OAAO,KAAK,YAAY;QACvC,MAAM,CAAC,MAAM,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS;QAC7C,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;QACvC,MAAM,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,EACrC,CAAC;QACD,MAAM,MAAM,EAAE,CAAA;QACd,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAA;IACjF,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,YAAY,EAAE,SAAS,EAAE,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { runSandboxCli } from "./sandbox-process.js";
|
|
2
|
+
/** Discover existing broker authorization on the laptop; never provision or export GitHub secrets. */
|
|
3
|
+
export declare function sandboxGitCredentials(project: {
|
|
4
|
+
id: string;
|
|
5
|
+
accountId: string;
|
|
6
|
+
link?: {
|
|
7
|
+
repoId: number;
|
|
8
|
+
};
|
|
9
|
+
}, run?: typeof runSandboxCli, cwd?: string): Promise<{
|
|
10
|
+
__source_credentials?: true;
|
|
11
|
+
__commitAs?: {
|
|
12
|
+
name: string;
|
|
13
|
+
email: string;
|
|
14
|
+
};
|
|
15
|
+
resources?: {
|
|
16
|
+
vcpus: number;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=sandbox-git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-git.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-git.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAUpD,sGAAsG;AACtG,wBAAsB,qBAAqB,CACzC,OAAO,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACrE,GAAG,GAAE,OAAO,aAA6B,EACzC,GAAG,SAAgB,GAClB,OAAO,CAAC;IACT,oBAAoB,CAAC,EAAE,IAAI,CAAA;IAC3B,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9B,CAAC,CAoCD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { configuredGitIdentity } from "./git-identity.js";
|
|
2
|
+
import { runSandboxCli } from "./sandbox-process.js";
|
|
3
|
+
/** Discover existing broker authorization on the laptop; never provision or export GitHub secrets. */
|
|
4
|
+
export async function sandboxGitCredentials(project, run = runSandboxCli, cwd = process.cwd()) {
|
|
5
|
+
if (!project.link?.repoId)
|
|
6
|
+
return {};
|
|
7
|
+
let cursor;
|
|
8
|
+
const seen = new Set();
|
|
9
|
+
do {
|
|
10
|
+
const query = new URLSearchParams({ teamId: project.accountId });
|
|
11
|
+
if (cursor)
|
|
12
|
+
query.set("cursor", cursor);
|
|
13
|
+
const page = JSON.parse(await run("vercel", ["api", `/v1/git-credential-broker/bounds?${query}`, "--scope", project.accountId, "--raw"]));
|
|
14
|
+
if (!Array.isArray(page.bounds))
|
|
15
|
+
throw new Error("Vercel returned invalid Git credential Bounds");
|
|
16
|
+
const authorized = page.bounds.some((bound) => bound.projectId === project.id &&
|
|
17
|
+
bound.teamId === project.accountId &&
|
|
18
|
+
bound.repositoryIds.includes(String(project.link?.repoId)) &&
|
|
19
|
+
bound.actions.includes("git:write") &&
|
|
20
|
+
!bound.actAs?.length);
|
|
21
|
+
if (authorized) {
|
|
22
|
+
const identity = await configuredGitIdentity(run, cwd);
|
|
23
|
+
if (!identity)
|
|
24
|
+
throw new Error("Managed Sandbox Git requires your configured git user.name and user.email");
|
|
25
|
+
return {
|
|
26
|
+
// The installed SDK forwards __ parameters. These are the broker's supported legacy fields.
|
|
27
|
+
__source_credentials: true,
|
|
28
|
+
__commitAs: { name: identity.GIT_AUTHOR_NAME, email: identity.GIT_AUTHOR_EMAIL },
|
|
29
|
+
// Managed Git currently requires a cold allocation: 1/2/4/8-vCPU warm images omit its helper.
|
|
30
|
+
// Sandbox enforces the team's effective resource limits; never downgrade to a broken warm image.
|
|
31
|
+
resources: { vcpus: 6 }
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
cursor = page.pagination?.next || undefined;
|
|
35
|
+
if (cursor && seen.has(cursor))
|
|
36
|
+
throw new Error("Vercel repeated the Git credential Bounds cursor");
|
|
37
|
+
if (cursor)
|
|
38
|
+
seen.add(cursor);
|
|
39
|
+
} while (cursor);
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=sandbox-git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-git.js","sourceRoot":"","sources":["../../src/runtime/sandbox-git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAUpD,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAqE,EACrE,GAAG,GAAyB,aAAa,EACzC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;IAMnB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM;QAAE,OAAO,EAAE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E,IAAI,EAAE,QAAQ,CAAC,eAAe,EAAE,KAAK,EAAE,QAAQ,CAAC,gBAAgB,EAAE;gBAChF,8FAA8F;gBAC9F,iGAAiG;gBACjG,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;aACxB,CAAA;QACH,CAAC;QACD,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,IAAI,SAAS,CAAA;QAC3C,IAAI,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;QACnG,IAAI,MAAM;YAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC9B,CAAC,QAAQ,MAAM,EAAC;IAChB,OAAO,EAAE,CAAA;AACX,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function workspaceGithubRequest(repository: string, args: Record<string, unknown>): {
|
|
2
|
+
args: string[];
|
|
3
|
+
input: string | undefined;
|
|
4
|
+
};
|
|
5
|
+
/** Run only repository-scoped Git Data/PR operations; the credential stays local. */
|
|
6
|
+
export declare function callSandboxGithub(repository: string, args: Record<string, unknown>, options?: {
|
|
7
|
+
cwd?: string;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}): Promise<string>;
|
|
10
|
+
//# sourceMappingURL=sandbox-github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-github.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-github.ts"],"names":[],"mappings":"AAEA,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAgBpF,IAAI;IASJ,KAAK;EAER;AAED,qFAAqF;AACrF,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,mBAIrD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { runSandboxCli } from "./sandbox-process.js";
|
|
2
|
+
export function workspaceGithubRequest(repository, args) {
|
|
3
|
+
if (!/^[\w.-]+\/[\w.-]+$/.test(repository))
|
|
4
|
+
throw new Error("No linked GitHub repository");
|
|
5
|
+
const method = String(args.method);
|
|
6
|
+
const path = String(args.path);
|
|
7
|
+
if (!["GET", "POST", "PATCH"].includes(method) ||
|
|
8
|
+
!/^\/(git\/(blobs|trees|commits|refs?|matching-refs)|pulls)(\/|\?|$)[\w/?.=&%-]*$/.test(path) ||
|
|
9
|
+
path.includes("..") ||
|
|
10
|
+
path.includes("%") ||
|
|
11
|
+
path.includes("//"))
|
|
12
|
+
throw new Error("Use a supported repo-relative Git Data or pulls endpoint");
|
|
13
|
+
if (args.body && (typeof args.body !== "object" || Array.isArray(args.body)))
|
|
14
|
+
throw new Error("body must be an object");
|
|
15
|
+
if (args.body?.force)
|
|
16
|
+
throw new Error("Force pushes are not supported");
|
|
17
|
+
return {
|
|
18
|
+
args: [
|
|
19
|
+
"api",
|
|
20
|
+
"--hostname",
|
|
21
|
+
"github.com",
|
|
22
|
+
"--method",
|
|
23
|
+
method,
|
|
24
|
+
`repos/${repository}${path}`,
|
|
25
|
+
...(args.body ? ["--input", "-"] : [])
|
|
26
|
+
],
|
|
27
|
+
input: args.body ? JSON.stringify(args.body) : undefined
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Run only repository-scoped Git Data/PR operations; the credential stays local. */
|
|
31
|
+
export async function callSandboxGithub(repository, args, options = {}) {
|
|
32
|
+
const request = workspaceGithubRequest(repository, args);
|
|
33
|
+
return runSandboxCli("gh", request.args, { ...options, input: request.input, timeoutMs: 60000 });
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=sandbox-github.js.map
|
|
@@ -0,0 +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CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACvC;QACD,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KACzD,CAAA;AACH,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAkB,EAClB,IAA6B,EAC7B,OAAO,GAA2C,EAAE;IAEpD,MAAM,OAAO,GAAG,sBAAsB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IACxD,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;AAClG,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Sandbox } from "@vercel/sandbox";
|
|
2
|
+
import { type Harness } from "./harness.js";
|
|
3
|
+
export { workspaceGithubRequest } from "./sandbox-github.js";
|
|
4
|
+
export declare function localWorkspaceInstructions(workdir: string, appUrl: string, helper: string): string;
|
|
5
|
+
export declare function prepareLocalSandboxHarness(harness: Harness, directory: string, connection: {
|
|
6
|
+
url: string;
|
|
7
|
+
token: string;
|
|
8
|
+
}, workdir: string, appUrl: string, resume?: boolean): {
|
|
9
|
+
binary: "claude" | "codex" | "eve" | "fx";
|
|
10
|
+
args: string[];
|
|
11
|
+
};
|
|
12
|
+
export interface LocalSandboxWorkspaceOptions {
|
|
13
|
+
directory: string;
|
|
14
|
+
sandbox: Sandbox;
|
|
15
|
+
workdir: string;
|
|
16
|
+
appUrl: string;
|
|
17
|
+
signal: AbortSignal;
|
|
18
|
+
chromePort: number;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
repository?: string;
|
|
21
|
+
recover?: (args: Record<string, unknown>) => Promise<import("./sandbox-workspace.js").WorkspaceResult>;
|
|
22
|
+
}
|
|
23
|
+
/** Shared by terminal harnesses and desktop MCP; credentials stay in this process. */
|
|
24
|
+
export declare function createLocalSandboxWorkspace(options: LocalSandboxWorkspaceOptions): Promise<(name: string, args: Record<string, unknown>) => Promise<import("./sandbox-workspace.js").WorkspaceResult>>;
|
|
25
|
+
export declare function launchLocalSandboxHarness(options: LocalSandboxWorkspaceOptions & {
|
|
26
|
+
harness: Harness;
|
|
27
|
+
gateway?: {
|
|
28
|
+
key: string;
|
|
29
|
+
};
|
|
30
|
+
resume?: boolean;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
/** A stable fx workspace must never retain a live broker credential between launches. */
|
|
33
|
+
export declare function clearLocalHarnessConnection(directory: string): void;
|
|
34
|
+
//# sourceMappingURL=sandbox-local-harness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-local-harness.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-local-harness.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAM9C,OAAO,EAAE,KAAK,OAAO,EAA8C,MAAM,cAAc,CAAA;AAKvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAqClG;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC1C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,MAAM,UAAQ;;;EA8Bf;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,WAAW,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,wBAAwB,EAAE,eAAe,CAAC,CAAA;CACvG;AAED,sFAAsF;AACtF,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,4BAA4B,kBAIjE,MAAM,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,gEAqD1D;AAED,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,4BAA4B,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,iBA2B1G;AAED,yFAAyF;AACzF,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEnE"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { getAgentBrowserBinaryPath } from "../utils/agent-browser.js";
|
|
5
|
+
import { captureBrowserLoading } from "./browser-capture.js";
|
|
6
|
+
import { compareBrowserCaptures } from "./browser-compare.js";
|
|
7
|
+
import { captureBrowserMetrics } from "./browser-metrics.js";
|
|
8
|
+
import { configuredGitIdentity } from "./git-identity.js";
|
|
9
|
+
import { pullRequestInstructions, runHarnessProcess } from "./harness.js";
|
|
10
|
+
import { callSandboxGithub } from "./sandbox-github.js";
|
|
11
|
+
import { runSandboxCli } from "./sandbox-process.js";
|
|
12
|
+
import { startWorkspaceBroker, workspaceHandler } from "./sandbox-workspace.js";
|
|
13
|
+
export { workspaceGithubRequest } from "./sandbox-github.js";
|
|
14
|
+
export function localWorkspaceInstructions(workdir, appUrl, helper) {
|
|
15
|
+
return `# d3k remote workspace
|
|
16
|
+
|
|
17
|
+
You are running LOCALLY. The project code, dependencies, environment, Git checkout, and dev server are in a Vercel Sandbox at ${JSON.stringify(workdir)}. This local directory contains only d3k connection files. Do not clone, download, or recreate the project locally. Do not use native local file/edit tools for project files.
|
|
18
|
+
|
|
19
|
+
Connection details are refreshed on every launch. Use the helper and MCP connection below even when continuing a prior conversation; old broker addresses and credentials are invalid. Do not replay unfinished commands automatically.
|
|
20
|
+
|
|
21
|
+
The app is already running at ${JSON.stringify(appUrl)} in the user's local Chrome. Use the d3k workspace tools immediately; do not discover a CDP port, install browsers, or start another runtime. Your normal local image-paste capability works here.
|
|
22
|
+
|
|
23
|
+
After a user-visible UI change, inspect sandbox_runtime status, verify the changed page through sandbox_browser and read the relevant events before reporting completion. You do not need to start a dev server locally to verify the remote app. If verification fails, report the tool call and actual error; do not infer that the server is absent because you did not launch it yourself.
|
|
24
|
+
|
|
25
|
+
After responsive/device testing, use sandbox_browser with args ["set","viewport","0","0","0"] to restore window-sized rendering. Verify the page fills the headed window before handing it back. Do not restore to a guessed desktop size such as 1280x900, which leaves a fixed viewport when the user resizes the window.
|
|
26
|
+
|
|
27
|
+
Use the d3k MCP tools sandbox_exec, sandbox_read_file, sandbox_write_file, sandbox_runtime, sandbox_browser, and sandbox_github. If MCP tools are not available (including fx), use the following exact helper commands with your native shell tool. The helper forwards requests to the same remote workspace; it does not execute project commands locally:
|
|
28
|
+
|
|
29
|
+
\`\`\`sh
|
|
30
|
+
${helper} sandbox_exec '{"command":"pwd; git status --short; test ! -f AGENTS.md || cat AGENTS.md"}'
|
|
31
|
+
${helper} sandbox_read_file '{"path":"package.json"}'
|
|
32
|
+
${helper} sandbox_write_file '{"path":"example.txt","content":"new file content"}'
|
|
33
|
+
${helper} sandbox_runtime '{"args":["status"]}'
|
|
34
|
+
${helper} sandbox_recover '{"action":"start"}'
|
|
35
|
+
${helper} sandbox_recover '{"action":"status"}'
|
|
36
|
+
${helper} sandbox_browser '{"args":["snapshot","-i"]}'
|
|
37
|
+
${helper} sandbox_browser '{"args":["click","@e2"]}'
|
|
38
|
+
${helper} sandbox_browser '{"args":["metrics","https://example.com/","--new-tab"]}'
|
|
39
|
+
${helper} sandbox_runtime '{"args":["events","--limit","50"]}'
|
|
40
|
+
${helper} sandbox_github '{"method":"GET","path":"/git/ref/heads/main"}'
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
For loading metrics, prefer sandbox_browser args ["metrics","https://example.com/","--new-tab"] over custom eval scripts. It installs observers before navigation and returns Web Vitals, navigation timing, long tasks and resource summaries as JSON. Omit the URL for a current-page snapshot without reload; CLS and long tasks are then unavailable. Results use the existing cache and throttling; null means unavailable and paint/vitals values are provisional.
|
|
44
|
+
For user-requested page/UI changes and loading/jank investigations, capture BEFORE editing with sandbox_browser args ["capture",URL,"--output","/absolute/new-before-dir","--ready","#ready"], then repeat the identical scenario after edits into a new directory. Limit captures to affected pages; skip backend-only work or if the user asks to skip recording. Optional --actions JSON accepts CSS click, pixel scroll and CSS waitFor steps, e.g. [{"click":"#expand"},{"scroll":600}]. Use idempotent actions; d3k repeats them three times and does not reset app data. Compare with ["compare","/absolute/new-before-dir","/absolute/new-after-dir","--output","/absolute/report.html"]. Paths are on the LOCAL laptop companion, not the remote project. Inspect videos and median/range metrics before claiming an improvement. These are local lab measurements; interaction maxima are not INP and animation gaps are not compositor dropped-frame counts. Keep the tab visible. Capture each page separately.
|
|
45
|
+
|
|
46
|
+
For file contents, patches, or GitHub upload bodies, pipe JSON to the helper with a final \`-\` argument instead of putting large JSON in command-line arguments: \`producer | ${helper} sandbox_github -\`. Keep project contents in tool input/output memory rather than local files. sandbox_github accepts method (GET, POST, PATCH), repo-relative path, and optional body (JSON object). For example, POST /git/blobs takes body {"content":"BASE64","encoding":"base64"}; POST /pulls takes body {"title":"...","head":"feature-branch","base":"main","body":"...","draft":true}. Check isError in helper responses and exitCode in remote command results before continuing.
|
|
47
|
+
|
|
48
|
+
If sandbox_runtime reports running:false or the app returns 502 after the dev runtime stops, call sandbox_recover with action start, then poll action status until recovered or failed. Recovery preserves this agent, remote edits and local Chrome; it does not clone, reinstall or replay your commands. Reread runtime status and reproduce after recovery because old in-memory evidence is lost. If recovery fails, report the error and preserve edits.
|
|
49
|
+
|
|
50
|
+
${pullRequestInstructions()}\n\nRead the remote project's AGENTS.md and any narrower instructions before editing. Use remote shell searches and patch commands for focused edits; sandbox_write_file writes the entire file. Run tests, Git branches, and commits remotely. For publishing, run /tmp/d3k-tools/node_modules/.bin/d3k-runtime publish --base <actual-base> --title <title> --body-file <remote-description-file> through sandbox_exec in the remote project root after committing intended files. Write the description remotely first. The publisher owns Git object construction, SHA verification, safe retries, branch updates and draft PR creation using only the laptop's linked-repository authentication. Do not construct Git Data requests manually or copy credentials into the sandbox. Use sandbox_runtime status before a reproduction, then events --session ID --after CURSOR afterward; reset or dropped events mean an evidence gap. Use the existing browser autonomously for UI checks. Batch related remote commands to reduce network round trips. Shell calls have a 60-second deadline; a timeout does not prove the command stopped, so inspect remote state before retrying mutations. Report disconnected tools instead of falling back to a local checkout. Await the user's task before modifying project code.`;
|
|
51
|
+
}
|
|
52
|
+
export function prepareLocalSandboxHarness(harness, directory, connection, workdir, appUrl, resume = false) {
|
|
53
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
54
|
+
const configPath = join(directory, "connection.json");
|
|
55
|
+
writeFileSync(configPath, JSON.stringify(connection), { mode: 0o600 });
|
|
56
|
+
const client = fileURLToPath(new URL("./workspace-client.js", import.meta.url));
|
|
57
|
+
const node = process.execPath;
|
|
58
|
+
const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
59
|
+
const helper = [node, client, configPath].map(quote).join(" ");
|
|
60
|
+
const instructions = localWorkspaceInstructions(workdir, appUrl, helper);
|
|
61
|
+
writeFileSync(join(directory, "AGENTS.md"), instructions, { mode: 0o600 });
|
|
62
|
+
writeFileSync(join(directory, "CLAUDE.md"), instructions, { mode: 0o600 });
|
|
63
|
+
const mcp = { command: node, args: [client, configPath, "--stdio"] };
|
|
64
|
+
const mcpPath = join(directory, ".mcp.json");
|
|
65
|
+
writeFileSync(mcpPath, JSON.stringify({ mcpServers: { d3k: mcp } }), { mode: 0o600 });
|
|
66
|
+
const args = harness === "codex"
|
|
67
|
+
? [
|
|
68
|
+
"-c",
|
|
69
|
+
`mcp_servers.d3k.command=${JSON.stringify(mcp.command)}`,
|
|
70
|
+
"-c",
|
|
71
|
+
`mcp_servers.d3k.args=${JSON.stringify(mcp.args)}`,
|
|
72
|
+
instructions
|
|
73
|
+
]
|
|
74
|
+
: harness === "claude"
|
|
75
|
+
? ["--mcp-config", mcpPath, "--append-system-prompt", instructions]
|
|
76
|
+
: resume
|
|
77
|
+
? ["-c"]
|
|
78
|
+
: [];
|
|
79
|
+
return { binary: harness, args };
|
|
80
|
+
}
|
|
81
|
+
/** Shared by terminal harnesses and desktop MCP; credentials stay in this process. */
|
|
82
|
+
export async function createLocalSandboxWorkspace(options) {
|
|
83
|
+
mkdirSync(options.directory, { recursive: true, mode: 0o700 });
|
|
84
|
+
const gitIdentity = await configuredGitIdentity(runSandboxCli, options.directory, options.signal);
|
|
85
|
+
const remote = workspaceHandler(options.sandbox, options.workdir, gitIdentity);
|
|
86
|
+
return async (name, args) => {
|
|
87
|
+
if (name === "sandbox_recover") {
|
|
88
|
+
if (!options.recover)
|
|
89
|
+
throw new Error("Recovery is unavailable in this older companion; exit and resume it");
|
|
90
|
+
return options.recover(args);
|
|
91
|
+
}
|
|
92
|
+
let output;
|
|
93
|
+
if (name === "sandbox_github") {
|
|
94
|
+
output = await callSandboxGithub(options.repository || "", args, {
|
|
95
|
+
cwd: options.directory,
|
|
96
|
+
signal: options.signal
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else if (name === "sandbox_browser") {
|
|
100
|
+
if (!Array.isArray(args.args) ||
|
|
101
|
+
args.args.some((arg) => typeof arg !== "string" ||
|
|
102
|
+
/^(--(cdp|profile|profile-dir|session|session-name|auto-connect|provider|engine|executable-path|config)|connect|close)(=|$)/.test(arg)))
|
|
103
|
+
throw new Error("Use browser interaction arguments; the connection is managed by d3k");
|
|
104
|
+
if (args.args[0] === "compare") {
|
|
105
|
+
return {
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
type: "text",
|
|
109
|
+
text: JSON.stringify(await compareBrowserCaptures(args.args.slice(1)))
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (args.args[0] === "metrics" || args.args[0] === "capture") {
|
|
115
|
+
const metrics = await (args.args[0] === "capture" ? captureBrowserLoading : captureBrowserMetrics)(args.args.slice(1), (command) => runSandboxCli(getAgentBrowserBinaryPath(), ["--session", `d3k-local-${options.sessionId}`, "--cdp", String(options.chromePort), ...command], { cwd: options.directory, timeoutMs: 30000, signal: options.signal }));
|
|
116
|
+
return { content: [{ type: "text", text: JSON.stringify(metrics) }] };
|
|
117
|
+
}
|
|
118
|
+
output = await runSandboxCli(getAgentBrowserBinaryPath(), ["--session", `d3k-local-${options.sessionId}`, "--cdp", String(options.chromePort), ...args.args], { cwd: options.directory, timeoutMs: 60000, signal: options.signal });
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
return remote(name, args);
|
|
122
|
+
return { content: [{ type: "text", text: output }] };
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export async function launchLocalSandboxHarness(options) {
|
|
126
|
+
const broker = await startWorkspaceBroker(await createLocalSandboxWorkspace(options));
|
|
127
|
+
try {
|
|
128
|
+
const invocation = prepareLocalSandboxHarness(options.harness, options.directory, broker, options.workdir, options.appUrl, options.resume);
|
|
129
|
+
await runHarnessProcess(invocation.binary, invocation.args, {
|
|
130
|
+
cwd: options.directory,
|
|
131
|
+
signal: options.signal,
|
|
132
|
+
env: options.gateway && options.harness === "fx"
|
|
133
|
+
? { ...process.env, FX_PROVIDER: "gateway", AI_GATEWAY_API_KEY: options.gateway.key }
|
|
134
|
+
: undefined
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
try {
|
|
139
|
+
await broker.close();
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
clearLocalHarnessConnection(options.directory);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** A stable fx workspace must never retain a live broker credential between launches. */
|
|
147
|
+
export function clearLocalHarnessConnection(directory) {
|
|
148
|
+
for (const file of ["connection.json", ".mcp.json"])
|
|
149
|
+
rmSync(join(directory, file), { force: true });
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=sandbox-local-harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-local-harness.js","sourceRoot":"","sources":["../../src/runtime/sandbox-local-harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAgB,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD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QACtB,CAAC;gBAAS,CAAC;YACT,2BAA2B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;AACH,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,2BAA2B,CAAC,SAAiB;IAC3D,KAAK,MAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACrG,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const SANDBOX_APP_PORT = 3000;
|
|
2
|
+
export declare const SANDBOX_PROXY_PORT = 9224;
|
|
3
|
+
export declare const SANDBOX_BRIDGE_PORT = 9223;
|
|
4
|
+
/** Port 3000 must stay private: only the authenticated proxy is exposed by Sandbox. */
|
|
5
|
+
export declare function sandboxExposedPorts(existing?: number[]): number[];
|
|
6
|
+
//# sourceMappingURL=sandbox-ports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-ports.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-ports.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,OAAO,CAAA;AACpC,eAAO,MAAM,kBAAkB,OAAO,CAAA;AACtC,eAAO,MAAM,mBAAmB,OAAO,CAAA;AAEvC,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,QAAQ,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE,CAIrE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Keep infrastructure off the app's conventional port, including during startup checks.
|
|
2
|
+
export const SANDBOX_APP_PORT = 3000;
|
|
3
|
+
export const SANDBOX_PROXY_PORT = 9224;
|
|
4
|
+
export const SANDBOX_BRIDGE_PORT = 9223;
|
|
5
|
+
/** Port 3000 must stay private: only the authenticated proxy is exposed by Sandbox. */
|
|
6
|
+
export function sandboxExposedPorts(existing = []) {
|
|
7
|
+
return [
|
|
8
|
+
...new Set([...existing.filter((port) => port !== SANDBOX_APP_PORT), SANDBOX_PROXY_PORT, SANDBOX_BRIDGE_PORT])
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=sandbox-ports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-ports.js","sourceRoot":"","sources":["../../src/runtime/sandbox-ports.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAA;AACpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAA;AACtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEvC,uFAAuF;AACvF,MAAM,UAAU,mBAAmB,CAAC,QAAQ,GAAa,EAAE;IACzD,OAAO;QACL,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;KAC/G,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
export interface SandboxPreview {
|
|
3
|
+
origin: string;
|
|
4
|
+
token: string;
|
|
5
|
+
expiresAt: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function sandboxPreviewLink(preview: SandboxPreview): string;
|
|
8
|
+
/** A separate capability grants app access only; never reuse the CDP or companion credential. */
|
|
9
|
+
export declare function sandboxPreview(preview: SandboxPreview): {
|
|
10
|
+
authorized(request: IncomingMessage): boolean;
|
|
11
|
+
stripCookie(cookie: string | undefined): string | undefined;
|
|
12
|
+
handle(request: IncomingMessage, response: ServerResponse): boolean;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=sandbox-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-preview.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-preview.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAKhE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAUlE;AAMD,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,OAAO,EAAE,cAAc;IAMlD,UAAU,UAAU,eAAe,GAAG,OAAO;IAU7C,WAAW,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS;IAQ3D,MAAM,UAAU,eAAe,YAAY,cAAc,GAAG,OAAO;EAyDtE"}
|