@tangle-network/agent-runtime 0.349.0 → 0.352.1
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-wBipBkCf.d.ts → activation-BidzGkUQ.d.ts} +2 -24
- package/dist/{activation-tNGW73Y9.js → activation-C6zNC2kx.js} +12 -14
- package/dist/{activation-tNGW73Y9.js.map → activation-C6zNC2kx.js.map} +1 -1
- package/dist/agent.d.ts +8 -12
- package/dist/agent.js +9 -12
- package/dist/agent.js.map +1 -1
- package/dist/{analyst-loop-DZw5QWT9.js → analyst-loop-BZvXCDKy.js} +2 -3
- package/dist/{analyst-loop-DZw5QWT9.js.map → analyst-loop-BZvXCDKy.js.map} +1 -1
- package/dist/analyst-loop.d.ts +3 -5
- package/dist/analyst-loop.js +1 -2
- package/dist/{bundle-1xaJEgjq.js → bundle-DeDkJbsr.js} +3 -4
- package/dist/{bundle-1xaJEgjq.js.map → bundle-DeDkJbsr.js.map} +1 -1
- package/dist/candidate-execution/index.d.ts +13 -33
- package/dist/candidate-execution/index.js +16 -18
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/chat-turn.d.ts +2 -0
- package/dist/chat-turn.js +1 -0
- package/dist/{coordination-manager-B2Z_MmL9.js → coordination-manager-B7QadgrI.js} +101 -132
- package/dist/{coordination-manager-B2Z_MmL9.js.map → coordination-manager-B7QadgrI.js.map} +1 -1
- package/dist/{delegate-Dr-63jFl.js → delegate-CoscoyEo.js} +19 -21
- package/dist/delegate-CoscoyEo.js.map +1 -0
- package/dist/durable.d.ts +16 -149
- package/dist/durable.js +57 -980
- package/dist/durable.js.map +1 -1
- package/dist/{errors-DodWX-cb.js → errors-AzSuGI23.js} +5 -3
- package/dist/errors-AzSuGI23.js.map +1 -0
- package/dist/execution-handle-Bd2_nUB6.js +167 -0
- package/dist/execution-handle-Bd2_nUB6.js.map +1 -0
- package/dist/execution-handle-CujvqgCn.d.ts +130 -0
- package/dist/{graph-DPejYB3C.js → graph-mojMML8e.js} +192 -14
- package/dist/graph-mojMML8e.js.map +1 -0
- package/dist/{improve-DwSahPi1.js → improve-Dm5ZE8mr.js} +36 -53
- package/dist/{improve-DwSahPi1.js.map → improve-Dm5ZE8mr.js.map} +1 -1
- package/dist/{improvement-adapter-sIthWkcN.d.ts → improvement-adapter-D5GRU1eY.d.ts} +2 -6
- package/dist/index.d.ts +41 -89
- package/dist/index.js +45 -61
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +39 -59
- package/dist/intelligence.js +24 -33
- package/dist/intelligence.js.map +1 -1
- package/dist/journal-store-BJPMUydp.js +3925 -0
- package/dist/journal-store-BJPMUydp.js.map +1 -0
- package/dist/kernel.d.ts +5 -5
- package/dist/kernel.js +12 -11
- package/dist/{loop-runner-CP6MfO1b.js → loop-runner-5cL_vZi0.js} +5 -6
- package/dist/{loop-runner-CP6MfO1b.js.map → loop-runner-5cL_vZi0.js.map} +1 -1
- package/dist/{loop-runner-C6pGq-2l.d.ts → loop-runner-DyLD-aNb.d.ts} +3 -5
- package/dist/loop-runner-bin.d.ts +5 -8
- package/dist/loop-runner-bin.js +2 -3
- package/dist/mcp/bin.js +6 -8
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +8 -18
- package/dist/mcp/index.js +17 -25
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.js +4 -6
- package/dist/mcp/memory-bin.js.map +1 -1
- package/dist/{model-policy-CyCUwHed.js → model-policy-C-RGAUW4.js} +11 -13
- package/dist/{model-policy-CyCUwHed.js.map → model-policy-C-RGAUW4.js.map} +1 -1
- package/dist/placement.d.ts +12 -14
- package/dist/placement.js +1 -2
- package/dist/platform.d.ts +7 -13
- package/dist/platform.js +3 -6
- package/dist/platform.js.map +1 -1
- package/dist/{prepare-B9wWffjO.js → prepare-XWwsOh8O.js} +50 -69
- package/dist/{prepare-B9wWffjO.js.map → prepare-XWwsOh8O.js.map} +1 -1
- package/dist/{profile-JLJd2wFG.js → profile-C01SQZKa.js} +58 -92
- package/dist/profile-C01SQZKa.js.map +1 -0
- package/dist/{profile-materialization-bPm0gGLO.d.ts → profile-materialization-BRY22Oh8.d.ts} +1 -3
- package/dist/profiles.d.ts +25 -12
- package/dist/profiles.js +52 -11
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-DVVh-hEk.d.ts → protected-model-port-IKqhTypD.d.ts} +2 -14
- package/dist/{protected-redaction-DFCeo4vg.js → protected-redaction-DilFZch5.js} +2 -3
- package/dist/{protected-redaction-DFCeo4vg.js.map → protected-redaction-DilFZch5.js.map} +1 -1
- package/dist/{provision-supervisor-C4v2vqDo.js → provision-supervisor-D9pO-iPl.js} +11 -15
- package/dist/{provision-supervisor-C4v2vqDo.js.map → provision-supervisor-D9pO-iPl.js.map} +1 -1
- package/dist/{run-cancellation-CzFhQGMa.js → run-cancellation-CoJRKvih.js} +6 -7
- package/dist/{run-cancellation-CzFhQGMa.js.map → run-cancellation-CoJRKvih.js.map} +1 -1
- package/dist/{runtime-CsvGCQpl.js → runtime-BJPXHWbc.js} +652 -215
- package/dist/runtime-BJPXHWbc.js.map +1 -0
- package/dist/{runtime-hooks-tXpAarhW.js → runtime-hooks-CsW2pfFk.js} +2 -3
- package/dist/{runtime-hooks-tXpAarhW.js.map → runtime-hooks-CsW2pfFk.js.map} +1 -1
- package/dist/{runtime-hooks-nsqxSUFL.d.ts → runtime-hooks-ZQqPw-0g.d.ts} +1 -3
- package/dist/{sandbox-profile-compat-DtuJWFrM.js → sandbox-profile-compat-CXjozdWL.js} +52 -653
- package/dist/sandbox-profile-compat-CXjozdWL.js.map +1 -0
- package/dist/{search-executor-CCb82Umc.js → search-executor-CQEHMXoT.js} +12 -15
- package/dist/{search-executor-CCb82Umc.js.map → search-executor-CQEHMXoT.js.map} +1 -1
- package/dist/{server-CKPwZU-I.js → server-U9NGgudQ.js} +19 -30
- package/dist/{server-CKPwZU-I.js.map → server-U9NGgudQ.js.map} +1 -1
- package/dist/{structural-rollout-DylC_fwU.js → structural-rollout-wMSxE7bn.js} +71 -70
- package/dist/structural-rollout-wMSxE7bn.js.map +1 -0
- package/dist/{substrate-CGDFTSRh.js → substrate-Db2pp6y3.js} +2 -3
- package/dist/{substrate-CGDFTSRh.js.map → substrate-Db2pp6y3.js.map} +1 -1
- package/dist/{supervise-BGfm2GlY.js → supervise-CNNhX0ab.js} +460 -195
- package/dist/supervise-CNNhX0ab.js.map +1 -0
- package/dist/supervision-discovery-CewADdEs.js +772 -0
- package/dist/supervision-discovery-CewADdEs.js.map +1 -0
- package/dist/{supervisor-wS9Ehz_x.js → supervisor-rK5Y8en6.js} +521 -4320
- package/dist/supervisor-rK5Y8en6.js.map +1 -0
- package/dist/{task-queue-0fKkoweu.d.ts → task-queue-kefGy79U.d.ts} +1 -3
- package/dist/task-queue.d.ts +1 -1
- package/dist/task-queue.js +1 -2
- package/dist/testing.d.ts +7 -15
- package/dist/testing.js +241 -244
- package/dist/testing.js.map +1 -1
- package/dist/tool-loop.d.ts +16 -19
- package/dist/tool-loop.js +2 -3
- package/dist/{tool-server-XV4aJwoQ.js → tool-server-CZWd_Opp.js} +3 -4
- package/dist/{tool-server-XV4aJwoQ.js.map → tool-server-CZWd_Opp.js.map} +1 -1
- package/dist/{top-snapshot-CflmaDgk.js → top-snapshot-DcV7VG4m.js} +179 -163
- package/dist/top-snapshot-DcV7VG4m.js.map +1 -0
- package/dist/tui/bin.js +50 -81
- package/dist/tui/bin.js.map +1 -1
- package/dist/tui/index.d.ts +27 -58
- package/dist/tui/index.js +2 -2
- package/dist/{types-C8BGOCBn.d.ts → types-0uzVKtFW.d.ts} +388 -484
- package/dist/{types-Cwrea-bU.d.ts → types-qsqfyQoY.d.ts} +1 -3
- package/dist/util-ebWMWzY0.js +624 -0
- package/dist/util-ebWMWzY0.js.map +1 -0
- package/dist/workspace-store/index.d.ts +12 -22
- package/dist/workspace-store/index.js +13 -10
- package/dist/workspace-store/index.js.map +1 -1
- package/dist/{workspace-streams-BiS4ABah.d.ts → workspace-streams-Dq2Fzk3c.d.ts} +1 -11
- package/package.json +31 -26
- package/skills/agent-graphs/SKILL.md +17 -4
- package/skills/be-ambitious/SKILL.md +46 -0
- package/skills/graph-designer/SKILL.md +9 -2
- package/dist/delegate-Dr-63jFl.js.map +0 -1
- package/dist/errors-DodWX-cb.js.map +0 -1
- package/dist/graph-DPejYB3C.js.map +0 -1
- package/dist/profile-JLJd2wFG.js.map +0 -1
- package/dist/record-events-D93DkpAx.js +0 -263
- package/dist/record-events-D93DkpAx.js.map +0 -1
- package/dist/runtime-CsvGCQpl.js.map +0 -1
- package/dist/sandbox-profile-compat-DtuJWFrM.js.map +0 -1
- package/dist/structural-rollout-DylC_fwU.js.map +0 -1
- package/dist/supervise-BGfm2GlY.js.map +0 -1
- package/dist/supervisor-wS9Ehz_x.js.map +0 -1
- package/dist/top-snapshot-CflmaDgk.js.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Bt as createSandboxUsageLedger, D as runtimeFailureCause, Dt as createSandboxToolPartState, Nt as terminalTextFromSandboxEvent, Ot as mapSandboxEvent, Pt as canonicalStreamEventFromSandboxEvent, kt as mapSandboxToolEvent } from "./journal-store-BJPMUydp.js";
|
|
2
|
+
import { Zr as authoredProfileDigest, _ as withDriverExecutor, _i as awaitAbortable, bi as providerMessageText, bt as captureReusableExecutorConfig, di as unknownExecutionBindingReceipt, ei as knownExecutionBindingReceipt, fi as unknownMaterializationReceipt, gi as readSandboxOutcome, gt as InMemorySpawnJournal, hi as projectSandboxOutcome, ht as InMemoryResultBlobStore, li as runtimeOwnedPendingExecutorMaterialization, n as createSupervisor, oi as runtimeOwnedExecutorExecutionBinding, pi as executableAgentProfileSnapshot, si as runtimeOwnedExecutorMaterialization, ti as knownMaterializationReceipt, vi as promptFromAgentTurnInput, vt as createExecutorRegistry, xt as createExecutor, yi as promptOptionsFromAgentTurnInput } from "./supervisor-rK5Y8en6.js";
|
|
3
|
+
import { m as ValidationError, p as SessionMismatchError, r as BackendTransportError } from "./errors-AzSuGI23.js";
|
|
4
|
+
import { F as armDeadlineTimer, c as errorMessage, f as isAsyncIterable } from "./util-ebWMWzY0.js";
|
|
5
|
+
import { c as profileModelExecutionSettings, g as observedModelMatchesDeclared, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-C-RGAUW4.js";
|
|
6
|
+
import { B as sha256Bytes$1 } from "./sandbox-profile-compat-CXjozdWL.js";
|
|
5
7
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, renderInputPartsAsText } from "@tangle-network/agent-interface";
|
|
6
8
|
import { costForTokenPricing, makeProposalFinding, scoreKnowledgeReadiness } from "@tangle-network/agent-eval";
|
|
7
9
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
@@ -10,7 +12,7 @@ import { existsSync, mkdirSync, renameSync, writeFileSync } from "node:fs";
|
|
|
10
12
|
import { join } from "node:path";
|
|
11
13
|
import { assertProposalFindings } from "@tangle-network/agent-eval/analyst";
|
|
12
14
|
import { pathToFileURL } from "node:url";
|
|
13
|
-
|
|
15
|
+
// src/sessions.ts
|
|
14
16
|
/**
|
|
15
17
|
*
|
|
16
18
|
* Session helpers + an in-memory `RuntimeSessionStore` implementation suitable
|
|
@@ -101,8 +103,7 @@ var InMemoryRuntimeSessionStore = class {
|
|
|
101
103
|
return [...this.events.get(sessionId) ?? []];
|
|
102
104
|
}
|
|
103
105
|
};
|
|
104
|
-
|
|
105
|
-
//#region src/backends.ts
|
|
106
|
+
// src/backends.ts
|
|
106
107
|
/**
|
|
107
108
|
* Provider-neutral backend adapters for `runAgentTaskStream`.
|
|
108
109
|
*
|
|
@@ -240,8 +241,7 @@ function mapCommonBackendEvent(event, context) {
|
|
|
240
241
|
function stringValue(value) {
|
|
241
242
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
242
243
|
}
|
|
243
|
-
|
|
244
|
-
//#region src/runtime/agent-turn-backend-events.ts
|
|
244
|
+
// src/runtime/agent-turn-backend-events.ts
|
|
245
245
|
function turnBackendInput(task, input) {
|
|
246
246
|
return {
|
|
247
247
|
task,
|
|
@@ -687,8 +687,10 @@ function deriveTurnSignal(callerSignal, timeoutMs) {
|
|
|
687
687
|
const controller = new AbortController();
|
|
688
688
|
const clearTimer = timeoutMs > 0 ? armDeadlineTimer(timeoutMs, () => controller.abort(/* @__PURE__ */ new Error(`agent turn timed out after ${timeoutMs}ms`))) : void 0;
|
|
689
689
|
const onCallerAbort = () => controller.abort(callerSignal?.reason ?? /* @__PURE__ */ new Error("agent turn aborted"));
|
|
690
|
-
if (callerSignal)
|
|
691
|
-
|
|
690
|
+
if (callerSignal) {
|
|
691
|
+
if (callerSignal.aborted) onCallerAbort();
|
|
692
|
+
else callerSignal.addEventListener("abort", onCallerAbort, { once: true });
|
|
693
|
+
}
|
|
692
694
|
return {
|
|
693
695
|
signal: controller.signal,
|
|
694
696
|
dispose: () => {
|
|
@@ -697,8 +699,7 @@ function deriveTurnSignal(callerSignal, timeoutMs) {
|
|
|
697
699
|
}
|
|
698
700
|
};
|
|
699
701
|
}
|
|
700
|
-
|
|
701
|
-
//#region src/runtime/stream-agent-turn.ts
|
|
702
|
+
// src/runtime/stream-agent-turn.ts
|
|
702
703
|
/**
|
|
703
704
|
* `streamAgentTurn` — the ONE run-a-turn event-stream contract over every
|
|
704
705
|
* execution substrate: a sandbox box (`SandboxInstance.streamPrompt`), a
|
|
@@ -1099,8 +1100,7 @@ function materializedModel(receipt, profile) {
|
|
|
1099
1100
|
const fallback = profile.model?.default;
|
|
1100
1101
|
return typeof fallback === "string" && fallback.length > 0 ? fallback : void 0;
|
|
1101
1102
|
}
|
|
1102
|
-
|
|
1103
|
-
//#region src/runtime/profile-chat-client.ts
|
|
1103
|
+
// src/runtime/profile-chat-client.ts
|
|
1104
1104
|
/** Profile-exact adapter for packages that consume agent-eval's ChatClient contract.
|
|
1105
1105
|
* Every call still enters Runtime through createExecutor -> streamAgentTurn, and every
|
|
1106
1106
|
* behavioral field is checked against the exact AgentProfile before any transport runs. */
|
|
@@ -1435,8 +1435,7 @@ function optimizerTokenCount(value, label) {
|
|
|
1435
1435
|
if (!Number.isSafeInteger(value) || value < 0) throw new Error(`profile optimizer ${label} must be a non-negative integer`);
|
|
1436
1436
|
return value;
|
|
1437
1437
|
}
|
|
1438
|
-
|
|
1439
|
-
//#region src/runtime/observe.ts
|
|
1438
|
+
// src/runtime/observe.ts
|
|
1440
1439
|
/**
|
|
1441
1440
|
* The third-person observer — the connective tissue that closes the loop.
|
|
1442
1441
|
*
|
|
@@ -1593,7 +1592,8 @@ async function analyzeWithProfile(input, opts) {
|
|
|
1593
1592
|
};
|
|
1594
1593
|
validateUsage(usage);
|
|
1595
1594
|
try {
|
|
1596
|
-
const
|
|
1595
|
+
const parsed = parseFindings(res.content);
|
|
1596
|
+
const findings = assertProposalFindings(parsed.map((f) => makeProposalFinding({
|
|
1597
1597
|
analyst_id: observerId,
|
|
1598
1598
|
area: f.area,
|
|
1599
1599
|
severity: f.severity,
|
|
@@ -1687,8 +1687,7 @@ function renderReport(findings) {
|
|
|
1687
1687
|
const block = (title, fs) => fs.length === 0 ? "" : `**${title}**\n${fs.map((f) => `- [${f.severity}] ${f.claim}\n → ${f.recommended_action ?? ""}`).join("\n")}\n`;
|
|
1688
1688
|
return [block("For the agent (fix skills / prompt / tools)", forAgent), block("For you (the operator)", forOperator)].filter(Boolean).join("\n");
|
|
1689
1689
|
}
|
|
1690
|
-
|
|
1691
|
-
//#region src/runtime/strategy.ts
|
|
1690
|
+
// src/runtime/strategy.ts
|
|
1692
1691
|
const taskNudge = "Use the available tools to bring the artifact to the required final state. Address EVERY distinct change the request implies. After each tool result, check what remains and continue. Re-read the values you set to confirm they took. Reply DONE only once every required change is made and verified.";
|
|
1693
1692
|
function exactAgenticProfile(profile, context) {
|
|
1694
1693
|
const parsed = agentProfileSchema.safeParse(profile);
|
|
@@ -1702,7 +1701,11 @@ function requiredProfileModel(profile, context) {
|
|
|
1702
1701
|
return model;
|
|
1703
1702
|
}
|
|
1704
1703
|
function profileSystemPrompt(profile) {
|
|
1705
|
-
const sections = [
|
|
1704
|
+
const sections = [
|
|
1705
|
+
profile.prompt?.systemPrompt,
|
|
1706
|
+
profile.prompt?.appendSystemPrompt,
|
|
1707
|
+
...profile.prompt?.instructions ?? []
|
|
1708
|
+
].filter((value) => typeof value === "string" && value.trim().length > 0);
|
|
1706
1709
|
const instructions = profile.resources?.instructions;
|
|
1707
1710
|
if (typeof instructions === "string" && instructions.trim()) sections.push(instructions);
|
|
1708
1711
|
else if (instructions && typeof instructions === "object" && instructions.kind === "inline" && instructions.content.trim()) sections.push(instructions.content);
|
|
@@ -2176,8 +2179,7 @@ async function runAgentic(opts) {
|
|
|
2176
2179
|
ms: Date.now() - started
|
|
2177
2180
|
};
|
|
2178
2181
|
}
|
|
2179
|
-
|
|
2180
|
-
//#region src/improvement/optimizer-prompt.ts
|
|
2182
|
+
// src/improvement/optimizer-prompt.ts
|
|
2181
2183
|
/**
|
|
2182
2184
|
* The senior scientific-method optimizer doctrine — the ONE substantial prompt
|
|
2183
2185
|
* core shared by every builder/author surface (tool build, MCP build, codebase
|
|
@@ -2252,8 +2254,7 @@ const strategyAuthorMethod = [
|
|
|
2252
2254
|
"6. PREDICT, THEN REFLECT: put the hypothesis, the mechanism, and the predicted lift in a",
|
|
2253
2255
|
" comment at the top of the module — the holdout verdict will be read against it."
|
|
2254
2256
|
].join("\n");
|
|
2255
|
-
|
|
2256
|
-
//#region src/runtime/authored-code.ts
|
|
2257
|
+
// src/runtime/authored-code.ts
|
|
2257
2258
|
/**
|
|
2258
2259
|
* The ONE lint over model-authored source.
|
|
2259
2260
|
*
|
|
@@ -2284,8 +2285,7 @@ function assertAuthoredCode(code, options = {}) {
|
|
|
2284
2285
|
[/child_process|node:fs|node:net|node:http|worker_threads/, "node builtin access"]
|
|
2285
2286
|
]) if (pattern.test(code)) throw new ValidationError(`${context} rejected: ${what}`);
|
|
2286
2287
|
}
|
|
2287
|
-
|
|
2288
|
-
//#region src/runtime/strategy-author.ts
|
|
2288
|
+
// src/runtime/strategy-author.ts
|
|
2289
2289
|
/**
|
|
2290
2290
|
* authorStrategy — the agent-authored layer as a package primitive (software-3.0): an
|
|
2291
2291
|
* LLM reads a benchmark's per-task LOSSES + the defineStrategy contract and writes a NEW
|
|
@@ -2313,10 +2313,10 @@ spend a compute budget to beat a task's deployable check. You compose exactly tw
|
|
|
2313
2313
|
- steer => a corrective instruction injected before the shot.
|
|
2314
2314
|
- profile => a complete AgentProfile — give THIS shot its own instructions,
|
|
2315
2315
|
model, skills, tools, hooks, and subagents. Include name, harness, and
|
|
2316
|
-
model: { provider, default }; put standing instructions in prompt.
|
|
2316
|
+
model: { provider, default }; put standing instructions in prompt.appendSystemPrompt.
|
|
2317
2317
|
For example: { ...opts.workerProfile, name: 'researcher',
|
|
2318
2318
|
prompt: { ...opts.workerProfile.prompt,
|
|
2319
|
-
|
|
2319
|
+
appendSystemPrompt: 'Inspect the evidence before proposing a change.' } }.
|
|
2320
2320
|
Choose an available model from the current execution setup. Omit profile to use
|
|
2321
2321
|
the worker's exact profile. Every shot spends from the same conserved budget.
|
|
2322
2322
|
- tools => string[] — restrict THIS shot to a subset of the task's tools by
|
|
@@ -2387,7 +2387,7 @@ async function requestStrategySource(opts) {
|
|
|
2387
2387
|
context: "strategy author"
|
|
2388
2388
|
}).chat({ messages: [{
|
|
2389
2389
|
role: "user",
|
|
2390
|
-
content: `${opts.contract ??
|
|
2390
|
+
content: `${opts.contract ?? "\nYou author an OPTIMIZATION STRATEGY for an agentic loop system. A strategy decides how to\nspend a compute budget to beat a task's deployable check. You compose exactly two steps:\n\n shot(spec?: { handle?, messages?, steer?, profile?, tools? }): Promise<ShotResult | null>\n Runs ONE worker attempt (a bounded tool loop) over an artifact.\n - omit handle => the shot opens its OWN fresh artifact and closes it after (a sample).\n - pass handle => the shot CONTINUES that artifact (state accumulates across shots).\n - messages => the carried conversation (pass the previous ShotResult.messages to continue).\n - steer => a corrective instruction injected before the shot.\n - profile => a complete AgentProfile — give THIS shot its own instructions,\n model, skills, tools, hooks, and subagents. Include name, harness, and\n model: { provider, default }; put standing instructions in prompt.appendSystemPrompt.\n For example: { ...opts.workerProfile, name: 'researcher',\n prompt: { ...opts.workerProfile.prompt,\n appendSystemPrompt: 'Inspect the evidence before proposing a change.' } }.\n Choose an available model from the current execution setup. Omit profile to use\n the worker's exact profile. Every shot spends from the same conserved budget.\n - tools => string[] — restrict THIS shot to a subset of the task's tools by\n name (focus an explore shot on read-only tools, an execute shot on write tools).\n Restriction-only; unknown names make the shot fail. ALWAYS select from\n await listTools(handle) — never hardcode. Omitted => the shot sees every tool.\n ShotResult = { messages, score (0..1 on the task's check), passes, total, completions, toolErrors }\n Returns null if the attempt failed infra-wise.\n\n critique(messages): Promise<string | null>\n A firewalled trace-analyst reads the attempt's trajectory and returns ONE corrective\n instruction (or null when it judges the work complete). Costs ~1 completion.\n\n consult(messages, instruction): Promise<string | null>\n The RAW analyst channel: the same firewalled critic answers YOUR instruction over the\n trajectory verbatim (no reformatting) — use it when you need a specific reply format\n (a decision, a prediction). Costs ~1 completion.\n\n surface.open(task) / surface.close(handle)\n Open a persistent artifact you manage yourself (remember to close in a finally).\n close is idempotent — closing an already-closed handle is a safe no-op.\n\n listTools(handle): Promise<Array<{ name, description? }>>\n The tools THIS task actually offers. TOOL SETS VARY PER TASK — if you restrict a\n shot with `tools`, you MUST pick names from await listTools(handle); hardcoding\n names from an example kills your shots on every task whose tools differ.\n\nRules:\n- ALWAYS await every shot/critique/surface call — a floating promise that rejects\n crashes the whole benchmark run.\n- Stay within ~budget total shots; every shot/critique spends from a conserved pool.\n- For a FRESH attempt OMIT `messages` entirely (never pass `[]` — an empty array is a\n fresh conversation too, but be explicit). To CONTINUE, pass the previous\n ShotResult.messages unchanged.\n- Return { score, resolved, completions, progression, shots } — score = the BEST checkpoint\n you reached (keep-best, never final-state), progression = score after each shot.\n- The module must be EXACTLY this shape (no other imports, no commentary outside code):\n\nimport { defineStrategy } from '@tangle-network/agent-runtime/kernel'\nexport default defineStrategy('your-strategy-name', async ({ surface, task, opts, budget, shot, critique, listTools }) => {\n // your composition (listTools comes from the destructured context — it is NOT a global)\n})\n"}\n\nBASELINE RESULTS on the "${opts.environmentName}" environment (budget=${opts.budget}) — the per-task losses are your gradient:\n${opts.lossesJson}\n\nAuthor ONE new strategy that you expect to beat the baselines on THIS environment at the same budget.\n${strategyAuthorMethod}\n\nOutput only the module code block.`
|
|
2391
2391
|
}] }, { ...opts.signal ? { signal: opts.signal } : {} });
|
|
2392
2392
|
turns.push({
|
|
2393
2393
|
content: res.content,
|
|
@@ -2418,7 +2418,8 @@ async function requestStrategySource(opts) {
|
|
|
2418
2418
|
* module breaks the contract or exports no Strategy. */
|
|
2419
2419
|
async function loadAuthoredStrategy(code, outDir) {
|
|
2420
2420
|
assertStrategyContract(code);
|
|
2421
|
-
const
|
|
2421
|
+
const digest = sha256Bytes$1(Buffer.from(code, "utf8")).slice(7);
|
|
2422
|
+
const file = join(outDir, `strategy-${digest}.mts`);
|
|
2422
2423
|
if (!existsSync(file)) {
|
|
2423
2424
|
mkdirSync(outDir, { recursive: true });
|
|
2424
2425
|
const partial = `${file}.${process.pid}.tmp`;
|
|
@@ -2663,8 +2664,7 @@ const sampleThenRefine = defineStrategy("sampleThenRefine", async ({ surface, ta
|
|
|
2663
2664
|
for (const h of open) await surface.close(h);
|
|
2664
2665
|
}
|
|
2665
2666
|
});
|
|
2666
|
-
|
|
2667
|
-
//#region src/runtime/structural-rollout.ts
|
|
2667
|
+
// src/runtime/structural-rollout.ts
|
|
2668
2668
|
/**
|
|
2669
2669
|
* structuralRollout — the measured structural lever as a fourth member of the
|
|
2670
2670
|
* sample/refine/sampleThenRefine strategy family: k independent samples, selection by
|
|
@@ -3011,41 +3011,43 @@ function structuralRollout(config = {}) {
|
|
|
3011
3011
|
});
|
|
3012
3012
|
let seq = candidates.length;
|
|
3013
3013
|
let repairStop = "already-passing";
|
|
3014
|
-
if (!passesAllChecks(best.outcome))
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3014
|
+
if (!passesAllChecks(best.outcome)) {
|
|
3015
|
+
if (best.outcome.crashed !== true && totalChecks(best.outcome) === 0) repairStop = "no-signal";
|
|
3016
|
+
else {
|
|
3017
|
+
repairStop = "rounds-exhausted";
|
|
3018
|
+
for (let r = 0; r < policy.repairRounds; r += 1) {
|
|
3019
|
+
const out = await shot({
|
|
3020
|
+
messages: best.messages,
|
|
3021
|
+
steer: repairSteer(best.outcome)
|
|
3022
|
+
});
|
|
3023
|
+
if (!out) break;
|
|
3024
|
+
shots += 1;
|
|
3025
|
+
completions += out.completions;
|
|
3026
|
+
progression.push(out.score);
|
|
3027
|
+
const artifact = extract(out.messages);
|
|
3028
|
+
const outcome = await checkRunner.run(artifact, checks, runCtx);
|
|
3029
|
+
const displaced = canDisplace(outcome, best.outcome);
|
|
3030
|
+
const label = displaced ? "repair (displaced the incumbent)" : outcome.crashed !== true && outcome.passedOfficial < best.outcome.passedOfficial ? "repair (held out: passes fewer official checks than the incumbent)" : "repair (held out: no improvement)";
|
|
3031
|
+
receipts.push({
|
|
3032
|
+
candidateIndex: seq,
|
|
3033
|
+
selected: false,
|
|
3034
|
+
score: visibleCheckScore(outcome),
|
|
3035
|
+
reason: describeOutcome(label, outcome),
|
|
3036
|
+
selector: "driver"
|
|
3037
|
+
});
|
|
3038
|
+
if (displaced) best = {
|
|
3039
|
+
index: seq,
|
|
3040
|
+
messages: out.messages,
|
|
3041
|
+
artifact,
|
|
3042
|
+
outcome,
|
|
3043
|
+
shotScore: out.score,
|
|
3044
|
+
shotResolved: out.total > 0 && out.passes === out.total
|
|
3045
|
+
};
|
|
3046
|
+
seq += 1;
|
|
3047
|
+
if (passesAllChecks(best.outcome)) {
|
|
3048
|
+
repairStop = "repaired-pass";
|
|
3049
|
+
break;
|
|
3050
|
+
}
|
|
3049
3051
|
}
|
|
3050
3052
|
}
|
|
3051
3053
|
}
|
|
@@ -3065,7 +3067,6 @@ function structuralRollout(config = {}) {
|
|
|
3065
3067
|
};
|
|
3066
3068
|
});
|
|
3067
3069
|
}
|
|
3068
|
-
//#endregion
|
|
3069
3070
|
export { defaultAnalystInstruction as A, InMemoryRuntimeSessionStore as B, optimizerMethod as C, runAgentic as D, refine as E, collectAgentTurn as F, nowIso as H, streamAgentTurn as I, createIterableBackend as L, renderReport as M, profileChatClient as N, sample as O, profileOptimizerModelCall as P, createSandboxPromptBackend as R, strategyAuthorSystemPrompt as S, depthStrategy as T, startOrResumeRuntimeSession as U, newRuntimeSession as V, touchSession as W, defineStrategy as _, defaultStructuralRolloutPolicy as a, sampleThenRefine as b, officialChecksFromMeta as c, selectBestIndex as d, structuralRollout as f, authorStrategy as g, assertStrategyContract as h, defaultExtractCandidate as i, observe as j, ObservationError as k, resolveEntrySymbol as l, adaptiveRefine as m, compareCheckOutcomes as n, filterAuthoredAsserts as o, visibleCheckScore as p, composeCheckSources as r, modelAuthoredChecks as s, canDisplace as t, sandboxCheckRunner as u, loadAuthoredStrategy as v, breadthStrategy as w, strategyAuthorContract as x, requestStrategySource as y, normalizeBackendStreamEvent as z };
|
|
3070
3071
|
|
|
3071
|
-
//# sourceMappingURL=structural-rollout-
|
|
3072
|
+
//# sourceMappingURL=structural-rollout-wMSxE7bn.js.map
|