@tangle-network/agent-runtime 0.170.0 → 0.172.0
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/dist/{activation-8RxHIo02.js → activation-DTleO7Fl.js} +2 -2
- package/dist/{activation-8RxHIo02.js.map → activation-DTleO7Fl.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{authored-code-C2TGxNtf.js → authored-code-DzYtiflw.js} +9 -16
- package/dist/authored-code-DzYtiflw.js.map +1 -0
- package/dist/{authoring-CUTgAxxE.js → authoring-c9yTIa3G.js} +2 -2
- package/dist/{authoring-CUTgAxxE.js.map → authoring-c9yTIa3G.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +1 -1
- package/dist/{graph-ZDMygFIo.js → graph-CtMnqYYC.js} +2 -2
- package/dist/{graph-ZDMygFIo.js.map → graph-CtMnqYYC.js.map} +1 -1
- package/dist/graph.d.ts +25 -85
- package/dist/graph.js +7 -162
- package/dist/graph.js.map +1 -1
- package/dist/{improvement-cycle-BYCnKZ_G.js → improvement-cycle-ipnDcl3P.js} +3 -3
- package/dist/{improvement-cycle-BYCnKZ_G.js.map → improvement-cycle-ipnDcl3P.js.map} +1 -1
- package/dist/{index-BgptUCKl.d.ts → index-DEEN055X.d.ts} +2 -2
- package/dist/{index-BGQtpQuJ.d.ts → index-cFm21prV.d.ts} +66 -10
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -7
- package/dist/intelligence.js +3 -3
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +7 -7
- package/dist/{knowledge-D3211Z_x.js → knowledge-BHfAAu6C.js} +3 -3
- package/dist/{knowledge-D3211Z_x.js.map → knowledge-BHfAAu6C.js.map} +1 -1
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-B_g5JOKA.js → loop-runner-bin-B3ju0qWS.js} +3 -3
- package/dist/{loop-runner-bin-B_g5JOKA.js.map → loop-runner-bin-B3ju0qWS.js.map} +1 -1
- package/dist/{loop-runner-bin-C2NXQK7J.d.ts → loop-runner-bin-BGcW6Gm7.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-UyXVO0kd.js → openai-tools-CfsSJ2sn.js} +2 -2
- package/dist/{openai-tools-UyXVO0kd.js.map → openai-tools-CfsSJ2sn.js.map} +1 -1
- package/dist/{runtime-C-7uhhFs.js → runtime-ckAefgVV.js} +248 -8
- package/dist/runtime-ckAefgVV.js.map +1 -0
- package/dist/{structural-rollout-C7nNNhri.js → structural-rollout-DjUoh2aA.js} +2 -2
- package/dist/{structural-rollout-C7nNNhri.js.map → structural-rollout-DjUoh2aA.js.map} +1 -1
- package/dist/{supervise-rEE46ruH.js → supervise-CnHd8x54.js} +12 -3
- package/dist/{supervise-rEE46ruH.js.map → supervise-CnHd8x54.js.map} +1 -1
- package/dist/{supervisor-B-mmmiOU.js → supervisor-Dw-5mGKr.js} +19 -22
- package/dist/{supervisor-B-mmmiOU.js.map → supervisor-Dw-5mGKr.js.map} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/package.json +1 -1
- package/skills/codemode/SKILL.md +5 -4
- package/dist/authored-code-C2TGxNtf.js.map +0 -1
- package/dist/runtime-C-7uhhFs.js.map +0 -1
|
@@ -9,14 +9,14 @@ import { i as redactProtectedValue, r as redactProtectedReason } from "./protect
|
|
|
9
9
|
import { c as notifySandboxEventObserver, m as parseCanonicalTransportEvent, p as extractTransportEventIdentity } from "./sandbox-events-BVjstFgb.js";
|
|
10
10
|
import { n as executableAgentSpecSnapshot, t as executableAgentProfileSnapshot } from "./executable-spec-CkGvdPds.js";
|
|
11
11
|
import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, t as assertExecutableAgentProfile } from "./model-policy-Sw4ywhtL.js";
|
|
12
|
-
import { $ as createPushTraceSource, Et as canonicalObservedModel, G as createWorktreeCliExecutor, H as createExecutor, St as probeSandboxCapabilities, Tt as runBrainLoop, U as createExecutorRegistry, bt as runAgentRounds, f as withDriverExecutor, k as rollingDispatch, n as createSupervisor, vt as defaultSelectWinner, wt as routerBrain, xt as createSandboxLineage, y as settledToIteration } from "./supervisor-
|
|
12
|
+
import { $ as createPushTraceSource, Et as canonicalObservedModel, G as createWorktreeCliExecutor, H as createExecutor, St as probeSandboxCapabilities, Tt as runBrainLoop, U as createExecutorRegistry, bt as runAgentRounds, f as withDriverExecutor, k as rollingDispatch, n as createSupervisor, vt as defaultSelectWinner, wt as routerBrain, xt as createSandboxLineage, y as settledToIteration } from "./supervisor-Dw-5mGKr.js";
|
|
13
13
|
import "./environment-provider-Bn3652YU.js";
|
|
14
14
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
|
|
15
|
-
import { C as observe, O as strategyAuthorMethod, T as profileChatClient, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-
|
|
16
|
-
import { At as gateOnDeliverable, jt as mapExecutorResult, n as supervise } from "./supervise-
|
|
17
|
-
import { t as assertAuthoredCode } from "./authored-code-
|
|
18
|
-
import "./authoring-
|
|
19
|
-
import "./graph-
|
|
15
|
+
import { C as observe, O as strategyAuthorMethod, T as profileChatClient, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-DjUoh2aA.js";
|
|
16
|
+
import { At as gateOnDeliverable, jt as mapExecutorResult, n as supervise } from "./supervise-CnHd8x54.js";
|
|
17
|
+
import { t as assertAuthoredCode } from "./authored-code-DzYtiflw.js";
|
|
18
|
+
import "./authoring-c9yTIa3G.js";
|
|
19
|
+
import "./graph-CtMnqYYC.js";
|
|
20
20
|
import { AgentEnvironmentCapabilitiesSchema, AgentExactRunControlRefSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentNativeContextContinuationResultSchema, AgentTurnResultSchema, InteractionAcknowledgementSchema, InteractionResponseCommandSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, RuntimeEventEnvelopeSchema, TerminalReplayWindowSchema, TerminalSessionRefSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentNativeContextContinuationResultMatchesRequest, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, exactAgentInteractiveSessionStart, nativeContextContinuationTurnDigest, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
21
21
|
import { CODING_HARNESSES, DEFAULT_TRACE_ANALYST_KINDS, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, expandProfileAxes, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
|
|
22
22
|
import { heldoutSignificance, runProfileMatrix } from "@tangle-network/agent-eval/campaign";
|
|
@@ -30,6 +30,7 @@ import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
|
30
30
|
import { collectAgentResponseText } from "@tangle-network/sandbox";
|
|
31
31
|
import { createInterface } from "node:readline";
|
|
32
32
|
import { gzipSync } from "node:zlib";
|
|
33
|
+
import { createContext, runInContext } from "node:vm";
|
|
33
34
|
import { stuckLoopView, toolWasteView } from "@tangle-network/agent-eval/pipelines";
|
|
34
35
|
//#region src/runtime/key-provider.ts
|
|
35
36
|
/** The env-backed provider: reads the (dotenvx-loaded) process env. Empty /
|
|
@@ -5752,6 +5753,245 @@ function chatWorkerSeam(opts) {
|
|
|
5752
5753
|
};
|
|
5753
5754
|
}
|
|
5754
5755
|
//#endregion
|
|
5756
|
+
//#region src/runtime/supervise/code-mode.ts
|
|
5757
|
+
/**
|
|
5758
|
+
* Code mode — the pattern Cloudflare ("Code Mode") and Anthropic ("code execution with MCP")
|
|
5759
|
+
* define, over this runtime's coordination verbs: generate a typed API from the tools' schemas,
|
|
5760
|
+
* expose exactly two tools (`search`, `execute`), and run model-written code whose only intended
|
|
5761
|
+
* capability is the API bindings. One model turn where the tool-calling loop pays one round trip
|
|
5762
|
+
* per call; intermediates live in the program, not the context window.
|
|
5763
|
+
*
|
|
5764
|
+
* WHAT THIS RUNTIME OWNS AND THE SOURCES' CENTRAL PROPERTY — read this before choosing a runner.
|
|
5765
|
+
* The sources isolate execution in a REAL boundary: Cloudflare runs the code in a V8 isolate with
|
|
5766
|
+
* a separate heap; Anthropic runs it out of process. That is not a detail — it is the whole reason
|
|
5767
|
+
* "let the model write code" is safe. This runtime does NOT ship an isolate, so `execute`'s
|
|
5768
|
+
* execution boundary is a SEAM you must fill: `codeModeSupervisorTools(runner)` REQUIRES a
|
|
5769
|
+
* `CodeModeRunner`, and there is no default. For untrusted model output, supply a jailed runner
|
|
5770
|
+
* (a sub-sandbox, a worker isolate). {@link unsafeInProcessRunner} is provided for TRUSTED output
|
|
5771
|
+
* only — your own eval harness, an offline test, a model you control — and is named for what it is:
|
|
5772
|
+
* `node:vm` shares the host realm, so host code is reachable from inside it and it is not a
|
|
5773
|
+
* security boundary. Choosing it for a hostile model is remote code execution, by construction.
|
|
5774
|
+
*
|
|
5775
|
+
* WHAT IS GENUINELY THIS RUNTIME'S CONTRIBUTION, and survives audit: every call the program makes
|
|
5776
|
+
* crosses the IDENTICAL kernel path an MCP verb crosses. Bindings dispatch through `context.verbs`
|
|
5777
|
+
* → the live coordination descriptor's own handler → authorization, the conserved pool, the
|
|
5778
|
+
* journal ("there is no second spawn path"). The model authors a workflow as code at runtime and
|
|
5779
|
+
* the kernel still meters and records every edge of it — a dynamic workflow system, not a bypass.
|
|
5780
|
+
* Verb RESULTS are detached (JSON round-trip) before they re-enter the program, so in-code calls
|
|
5781
|
+
* cannot mutate live coordination state the MCP transport would have copied.
|
|
5782
|
+
*
|
|
5783
|
+
* WHAT STAYS THE MODEL'S: `submit_result`, `stop`, `ask_parent` are never in the API — a program
|
|
5784
|
+
* that could settle the run would be a second brain. `search` names them and says why. Code does
|
|
5785
|
+
* the mechanics; the model keeps the judgment, the same split the sources draw.
|
|
5786
|
+
*
|
|
5787
|
+
* THE GRANT CANNOT DRIFT FROM THE DOCS: `search` renders from `context.coordinationTools()`, the
|
|
5788
|
+
* same descriptor objects the verbs are served from — never prose written beside them.
|
|
5789
|
+
*/
|
|
5790
|
+
/** The seven coordination verbs callable in code, and the `context.verbs` member each maps to. */
|
|
5791
|
+
const CODE_CALLABLE_VERBS = {
|
|
5792
|
+
spawn_agent: "spawnAgent",
|
|
5793
|
+
await_event: "awaitEvent",
|
|
5794
|
+
steer_agent: "steerAgent",
|
|
5795
|
+
observe_agent: "observeAgent",
|
|
5796
|
+
list_questions: "listQuestions",
|
|
5797
|
+
answer_question: "answerQuestion",
|
|
5798
|
+
run_analyst: "runAnalyst"
|
|
5799
|
+
};
|
|
5800
|
+
/** The manager's own lifecycle verbs — never callable from code; `search` names them and why. */
|
|
5801
|
+
const LIFECYCLE_VERBS = [
|
|
5802
|
+
"submit_result",
|
|
5803
|
+
"stop",
|
|
5804
|
+
"ask_parent"
|
|
5805
|
+
];
|
|
5806
|
+
/** Render a JSON Schema as TypeScript type text. Bounded and structural: enough for tool input
|
|
5807
|
+
* schemas (objects, enums, arrays, unions); anything unrecognized renders `unknown`, never a
|
|
5808
|
+
* guess. Module-level (not root) export: consumed by `renderCodeModeApi` and its tests only. */
|
|
5809
|
+
function renderJsonSchemaType(schema, depth = 0) {
|
|
5810
|
+
if (depth > 6 || typeof schema !== "object" || schema === null) return "unknown";
|
|
5811
|
+
const node = schema;
|
|
5812
|
+
if (node.const !== void 0) return JSON.stringify(node.const);
|
|
5813
|
+
if (Array.isArray(node.enum)) return node.enum.map((value) => JSON.stringify(value)).join(" | ");
|
|
5814
|
+
const variants = node.anyOf ?? node.oneOf;
|
|
5815
|
+
if (Array.isArray(variants)) return variants.map((variant) => renderJsonSchemaType(variant, depth + 1)).join(" | ");
|
|
5816
|
+
const type = Array.isArray(node.type) ? node.type : [node.type];
|
|
5817
|
+
if (type.includes("object") || node.type === void 0 && node.properties !== void 0) {
|
|
5818
|
+
const properties = node.properties ?? {};
|
|
5819
|
+
const required = new Set(Array.isArray(node.required) ? node.required : []);
|
|
5820
|
+
const fields = Object.entries(properties).map(([name, property]) => {
|
|
5821
|
+
const doc = describeSchema(property);
|
|
5822
|
+
const optional = required.has(name) ? "" : "?";
|
|
5823
|
+
return `${doc}${JSON.stringify(name).slice(1, -1)}${optional}: ${renderJsonSchemaType(property, depth + 1)}`;
|
|
5824
|
+
});
|
|
5825
|
+
if (fields.length === 0) return "Record<string, unknown>";
|
|
5826
|
+
const indent = " ".repeat(depth + 1);
|
|
5827
|
+
return `{\n${fields.map((field) => `${indent}${field}`).join("\n")}\n${" ".repeat(depth)}}`;
|
|
5828
|
+
}
|
|
5829
|
+
if (type.includes("array")) return `Array<${renderJsonSchemaType(node.items, depth + 1)}>`;
|
|
5830
|
+
const primitives = type.map((entry) => entry === "integer" ? "number" : typeof entry === "string" ? entry : void 0).filter((entry) => entry === "string" || entry === "number" || entry === "boolean" || entry === "null");
|
|
5831
|
+
return primitives.length > 0 ? primitives.join(" | ") : "unknown";
|
|
5832
|
+
}
|
|
5833
|
+
function describeSchema(schema) {
|
|
5834
|
+
const description = typeof schema === "object" && schema !== null ? schema.description : void 0;
|
|
5835
|
+
if (typeof description !== "string" || description.length === 0) return "";
|
|
5836
|
+
const first = description.split("\n")[0] ?? "";
|
|
5837
|
+
return `/** ${first.length > 140 ? `${first.slice(0, 140)}…` : first} */ `;
|
|
5838
|
+
}
|
|
5839
|
+
/** Render the callable API from tool faces — `declare function` per tool, doc from its own
|
|
5840
|
+
* description. This is the text `search` answers; generated, never hand-written. Module-level
|
|
5841
|
+
* export for tests. */
|
|
5842
|
+
function renderCodeModeApi(tools, query) {
|
|
5843
|
+
const needle = query?.trim().toLowerCase();
|
|
5844
|
+
const blocks = tools.filter((tool) => !needle || tool.name.toLowerCase().includes(needle) || (tool.description ?? "").toLowerCase().includes(needle)).map((tool) => {
|
|
5845
|
+
const doc = (tool.description ?? "").split("\n")[0] ?? "";
|
|
5846
|
+
const args = tool.inputSchema === void 0 ? "unknown" : renderJsonSchemaType(tool.inputSchema);
|
|
5847
|
+
return `/** ${doc} */\ndeclare function ${tool.name}(args: ${args}): Promise<unknown>`;
|
|
5848
|
+
});
|
|
5849
|
+
const header = [
|
|
5850
|
+
"// Call these as `api.<name>(args)` from code passed to `execute`.",
|
|
5851
|
+
"// Results are the same JSON the tools return. Intermediates stay in your program;",
|
|
5852
|
+
"// return only what the next decision needs.",
|
|
5853
|
+
`// NOT callable from code: ${LIFECYCLE_VERBS.join(", ")} — those are your own tools,`,
|
|
5854
|
+
"// because a program that could settle the run would be a second brain."
|
|
5855
|
+
].join("\n");
|
|
5856
|
+
if (blocks.length === 0) return `${header}\n\n// No API member matches ${JSON.stringify(query ?? "")}. Call search with no query for the full API.`;
|
|
5857
|
+
return `${header}\n\n${blocks.join("\n\n")}`;
|
|
5858
|
+
}
|
|
5859
|
+
/**
|
|
5860
|
+
* An in-process runner for TRUSTED model output ONLY. NOT a security boundary.
|
|
5861
|
+
*
|
|
5862
|
+
* It runs the program in a `node:vm` context whose globals are the bindings (`api`) and a
|
|
5863
|
+
* capturing `console`, with code generation disabled and inherited properties stripped. Those are
|
|
5864
|
+
* capability discipline, not containment: `node:vm` shares the host realm, and a host function's
|
|
5865
|
+
* `.constructor` is the host `Function`, so code that WANTS out can get out
|
|
5866
|
+
* (`api.<binding>.constructor('return process')()`). Use this for your own eval harness, offline
|
|
5867
|
+
* tests, or a model you trust; for untrusted output supply a jailed `CodeModeRunner` instead.
|
|
5868
|
+
*/
|
|
5869
|
+
function unsafeInProcessRunner() {
|
|
5870
|
+
return { async run({ code, bindings, signal }) {
|
|
5871
|
+
const logs = [];
|
|
5872
|
+
const capture = (level) => (...args) => {
|
|
5873
|
+
const line = args.map((value) => typeof value === "string" ? value : safeJson(value)).join(" ");
|
|
5874
|
+
if (logs.length < 200) logs.push(level === "log" ? line : `[${level}] ${line}`);
|
|
5875
|
+
};
|
|
5876
|
+
const target = Object.create(null);
|
|
5877
|
+
for (const [name, fn] of Object.entries(bindings)) target[name] = fn;
|
|
5878
|
+
const sandbox = Object.create(null);
|
|
5879
|
+
sandbox.api = new Proxy(Object.freeze(target), { get(owned, member) {
|
|
5880
|
+
if (typeof member !== "string") return void 0;
|
|
5881
|
+
if (Object.hasOwn(owned, member)) return owned[member];
|
|
5882
|
+
throw new ValidationError(LIFECYCLE_VERBS.includes(member) ? `code mode: api.${member} is not callable from code — it is the manager's own lifecycle verb; return from your program and call it as a tool` : `code mode: api.${member} is not in the granted API — call search to see what is`);
|
|
5883
|
+
} });
|
|
5884
|
+
sandbox.console = Object.freeze({
|
|
5885
|
+
log: capture("log"),
|
|
5886
|
+
warn: capture("warn"),
|
|
5887
|
+
error: capture("error")
|
|
5888
|
+
});
|
|
5889
|
+
const context = createContext(sandbox, { codeGeneration: {
|
|
5890
|
+
strings: false,
|
|
5891
|
+
wasm: false
|
|
5892
|
+
} });
|
|
5893
|
+
const program = runInContext(`(async () => {\n${code}\n})()`, context);
|
|
5894
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
5895
|
+
if (signal.aborted) reject(abortReason(signal));
|
|
5896
|
+
else signal.addEventListener("abort", () => reject(abortReason(signal)), { once: true });
|
|
5897
|
+
});
|
|
5898
|
+
return {
|
|
5899
|
+
result: await Promise.race([program, aborted]) ?? null,
|
|
5900
|
+
logs
|
|
5901
|
+
};
|
|
5902
|
+
} };
|
|
5903
|
+
}
|
|
5904
|
+
function abortReason(signal) {
|
|
5905
|
+
const reason = signal.reason;
|
|
5906
|
+
return reason instanceof Error ? reason : new ValidationError("code mode: program aborted");
|
|
5907
|
+
}
|
|
5908
|
+
function safeJson(value) {
|
|
5909
|
+
try {
|
|
5910
|
+
return JSON.stringify(value) ?? String(value);
|
|
5911
|
+
} catch {
|
|
5912
|
+
return String(value);
|
|
5913
|
+
}
|
|
5914
|
+
}
|
|
5915
|
+
/** Detach a verb result before it re-enters the program — the deep copy the MCP transport makes,
|
|
5916
|
+
* so in-code calls cannot mutate live coordination state. Matches the MCP path exactly (both
|
|
5917
|
+
* JSON round-trip); a non-serializable result degrades to a marker rather than leaking a live
|
|
5918
|
+
* reference. */
|
|
5919
|
+
function detach(value) {
|
|
5920
|
+
if (value === void 0) return void 0;
|
|
5921
|
+
try {
|
|
5922
|
+
return JSON.parse(JSON.stringify(value));
|
|
5923
|
+
} catch {
|
|
5924
|
+
return { nonSerializable: true };
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
/**
|
|
5928
|
+
* Put a supervisor in code mode: its product tool surface becomes exactly `search` and `execute`.
|
|
5929
|
+
*
|
|
5930
|
+
* `runner` is REQUIRED and has no default — this runtime ships no isolate, so the execution
|
|
5931
|
+
* boundary is the caller's explicit choice (see the module doc). Use {@link unsafeInProcessRunner}
|
|
5932
|
+
* for trusted output; a jailed runner for untrusted models.
|
|
5933
|
+
*
|
|
5934
|
+
* Pass the result as `SuperviseOptions.resolveSupervisorTools` (which `runGraph` forwards to its
|
|
5935
|
+
* root supervisor). The graph engine's `supervisorKind` does not accept it yet, so a graph
|
|
5936
|
+
* supervisor node cannot be put in code mode through node config today.
|
|
5937
|
+
*/
|
|
5938
|
+
function codeModeSupervisorTools(runner, options = {}) {
|
|
5939
|
+
if (runner === void 0 || typeof runner.run !== "function") throw new ValidationError("codeModeSupervisorTools: a CodeModeRunner is required (no default) — pass unsafeInProcessRunner() for trusted output, or a jailed runner for untrusted models");
|
|
5940
|
+
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
5941
|
+
const faces = (context) => context.coordinationTools().filter((tool) => CODE_CALLABLE_VERBS[tool.name] !== void 0);
|
|
5942
|
+
return () => [{
|
|
5943
|
+
name: "search",
|
|
5944
|
+
description: "Search the callable API. Returns TypeScript declarations for the operations your code may call, generated from the live grant. Optional `query` filters by name or description; omit it for the full API.",
|
|
5945
|
+
inputSchema: {
|
|
5946
|
+
type: "object",
|
|
5947
|
+
properties: { query: {
|
|
5948
|
+
type: "string",
|
|
5949
|
+
description: "Substring filter over names and descriptions."
|
|
5950
|
+
} }
|
|
5951
|
+
},
|
|
5952
|
+
handler: async (raw, context) => {
|
|
5953
|
+
const query = typeof raw === "object" && raw !== null ? raw.query : void 0;
|
|
5954
|
+
return renderCodeModeApi(faces(context), typeof query === "string" ? query : void 0);
|
|
5955
|
+
}
|
|
5956
|
+
}, {
|
|
5957
|
+
name: "execute",
|
|
5958
|
+
description: "Run JavaScript against the API from `search`. Write the BODY of an async function: call `api.<name>(args)` (await each call), use loops and Promise.all for fan-out, keep intermediates in variables, `return` only what the next decision needs. `console.log` lines come back beside the result. No imports, no network, no filesystem — the API is the intended capability.",
|
|
5959
|
+
inputSchema: {
|
|
5960
|
+
type: "object",
|
|
5961
|
+
properties: { code: {
|
|
5962
|
+
type: "string",
|
|
5963
|
+
description: "The async function body to run."
|
|
5964
|
+
} },
|
|
5965
|
+
required: ["code"]
|
|
5966
|
+
},
|
|
5967
|
+
handler: async (raw, context) => {
|
|
5968
|
+
const code = typeof raw === "object" && raw !== null ? raw.code : void 0;
|
|
5969
|
+
if (typeof code !== "string" || code.trim().length === 0) throw new ValidationError("code mode: execute needs { code: string }");
|
|
5970
|
+
assertAuthoredCode(code, { context: `code mode (${context.nodeId})` });
|
|
5971
|
+
const deadline = new AbortController();
|
|
5972
|
+
const onScopeAbort = () => deadline.abort(abortReason(context.signal));
|
|
5973
|
+
const timer = setTimeout(() => deadline.abort(new ValidationError(`code mode: program timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
5974
|
+
if (context.signal.aborted) deadline.abort(abortReason(context.signal));
|
|
5975
|
+
else context.signal.addEventListener("abort", onScopeAbort, { once: true });
|
|
5976
|
+
const bindings = {};
|
|
5977
|
+
for (const [wire, member] of Object.entries(CODE_CALLABLE_VERBS)) bindings[wire] = async (args) => {
|
|
5978
|
+
if (deadline.signal.aborted) throw new ValidationError(`code mode: the execute deadline passed; api.${wire} is refused so no work outlives the call`);
|
|
5979
|
+
return detach(await context.verbs[member](args));
|
|
5980
|
+
};
|
|
5981
|
+
try {
|
|
5982
|
+
return await runner.run({
|
|
5983
|
+
code,
|
|
5984
|
+
bindings,
|
|
5985
|
+
signal: deadline.signal
|
|
5986
|
+
});
|
|
5987
|
+
} finally {
|
|
5988
|
+
clearTimeout(timer);
|
|
5989
|
+
context.signal.removeEventListener("abort", onScopeAbort);
|
|
5990
|
+
}
|
|
5991
|
+
}
|
|
5992
|
+
}];
|
|
5993
|
+
}
|
|
5994
|
+
//#endregion
|
|
5755
5995
|
//#region src/runtime/supervise/patch-checks.ts
|
|
5756
5996
|
const DEFAULT_MAX_DIFF_LINES = 400;
|
|
5757
5997
|
/**
|
|
@@ -7118,6 +7358,6 @@ function tail(s) {
|
|
|
7118
7358
|
return s.slice(-400);
|
|
7119
7359
|
}
|
|
7120
7360
|
//#endregion
|
|
7121
|
-
export {
|
|
7361
|
+
export { equalKOnCost as $, chatWorkerSeam as A, completionAuthorizes as At, SandboxRunAbortError as B, auditIntent as Bt, withUntrackedArtifacts as C, defineLeaderboard as Ct, codeModeSupervisorTools as D, loopCampaignDispatch as Dt, runCoderChecks as E, inlineSandboxClient as Et, selectChampion as F, pairwiseSignificance as Ft, reconnectRetainedInteractiveRun as G, createMcpEnvironment as Gt, printBenchmarkReport as H, McpSpawnFault as Ht, assertStrategyContract as I, renderLeaderboardHtml as It, reconnectRetainedRun as J, mcpSecretEnvMetadataKey as Jt, recoverRetainedInteractiveRun as K, sanitizeMcpToolSchema as Kt, authorStrategy as L, renderLeaderboardMarkdown as Lt, discriminatingMeans as M, sentinelCompletion as Mt, pickChampion as N, stopSentinel as Nt, unsafeInProcessRunner as O, loopDispatch as Ot, runStrategyEvolution as P, leaderboard as Pt, promotionGate as Q, strategyAuthorContract as R, renderLeaderboardSvg as Rt, copyUntrackedIntoClone as S, harvestCorpus as St, patchDelivered as T, localSandboxClient as Tt, runBenchmark as U, connectStdioMcp as Ut, openSandboxRun as V, defaultAuditorInstruction as Vt, claimRetainedInteractiveControl as W, materializeLocalMcp as Wt, startRetainedRun as X, resolveSecretEnv as Xt, recoverRetainedRun as Y, resolveMcpServerLaunch as Yt, startRetainedRunInEnvironment as Z, secretEnvOfMcpServer as Zt, NOTE_MAX_CHARS as _, assertTraceDerivedFindings as _t, localShell as a, registerShape as at, composeWorkerEvidence as b, registryScopeAnalyst as bt, createVerifierEnvironment as c, renderCorpusToInstructions as ct, harvestSurfaceDiffs as d, loopUntil as dt, trajectoryReport as et, analystsFromRegistry as f, panel as ft, EVIDENCE_MAX_CHARS as g, widen as gt, worktreeFanout as h, verify as ht, jjWorkspace as i, createShapeRegistry as it, createChatSessionStore as j, deterministicCompletion as jt, chatTransportExecutor as k, superviseDispatch as kt, boxSurfaceReader as l, fanout as lt, superviseSurface as m, selectValidWinner as mt, makeFinding$1 as n, runPersonified as nt, runInWorkspace as o, FileCorpus as ot, failuresAnalyst as p, pipeline as pt, startRetainedInteractiveRun as q, envKeyProvider as qt, gitWorkspace as r, builtinShapes as rt, createWaterfallCollector as s, InMemoryCorpus as st, computeFindingId$1 as t, definePersona as tt, fsSurfaceReader as u, flatWidenGate as ut, VERIFY_TAIL_CHARS as v, buildSteerContext as vt, analyzeTrace as w, resolveSandboxClient as wt, settledWorkerOut as x, inProcessSandboxClient as xt, closingWorkerNote as y, createScopeAnalyst as yt, strategyAuthorSystemPrompt as z, renderPairwiseMarkdown as zt };
|
|
7122
7362
|
|
|
7123
|
-
//# sourceMappingURL=runtime-
|
|
7363
|
+
//# sourceMappingURL=runtime-ckAefgVV.js.map
|