@tangle-network/agent-runtime 0.126.0 → 0.131.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/README.md +70 -20
- package/dist/{activation-DhWJ3p8N.js → activation-BCzMOTaV.js} +3 -3
- package/dist/{activation-DhWJ3p8N.js.map → activation-BCzMOTaV.js.map} +1 -1
- package/dist/agent.d.ts +2 -3
- package/dist/agent.js +4 -5
- package/dist/agent.js.map +1 -1
- package/dist/{analyst-loop-DvSciOfB.js → analyst-loop-BE8cDs5Q.js} +2 -2
- package/dist/{analyst-loop-DvSciOfB.js.map → analyst-loop-BE8cDs5Q.js.map} +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/analyst-loop.js +1 -1
- package/dist/authoring-CvHwo1oW.js +163 -0
- package/dist/authoring-CvHwo1oW.js.map +1 -0
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{candidate-execution-BFpq-Xi6.js → candidate-execution-BNxKr-Bu.js} +5 -5
- package/dist/{candidate-execution-BFpq-Xi6.js.map → candidate-execution-BNxKr-Bu.js.map} +1 -1
- package/dist/{conversation-BpLQZGPH.js → conversation-DNtxaJ1Z.js} +113 -31
- package/dist/conversation-DNtxaJ1Z.js.map +1 -0
- package/dist/conversation.d.ts +2 -2
- package/dist/conversation.js +2 -2
- package/dist/environment-provider-CxvSd1W6.d.ts +86 -0
- package/dist/{environment-provider-DqFS6FSZ.js → environment-provider-Dyg8DtLK.js} +8 -4
- package/dist/environment-provider-Dyg8DtLK.js.map +1 -0
- package/dist/environment-provider.d.ts +1 -1
- package/dist/environment-provider.js +1 -1
- package/dist/graph-BJTxGOFB.js +471 -0
- package/dist/graph-BJTxGOFB.js.map +1 -0
- package/dist/{improvement-cycle-IJgCbKWQ.js → improvement-cycle-Csp38cWg.js} +133 -224
- package/dist/improvement-cycle-Csp38cWg.js.map +1 -0
- package/dist/{index-EdjCQBV9.d.ts → index-CoO7atyo.d.ts} +640 -1184
- package/dist/{index-DIV33AF5.d.ts → index-DwGtu9nc.d.ts} +7 -9
- package/dist/{index-Efjb3nrQ.d.ts → index-qYHpsmG2.d.ts} +36 -18
- package/dist/index.d.ts +353 -11
- package/dist/index.js +111 -354
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +6 -6
- package/dist/intelligence.js +9 -8
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +7 -5
- package/dist/kernel.js +13 -9
- package/dist/{knowledge-EnuEqm_Y.js → knowledge-ce0_uKCl.js} +19 -17
- package/dist/knowledge-ce0_uKCl.js.map +1 -0
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-Bo29_fiD.d.ts → loop-runner-bin-BwgZ8m_7.d.ts} +6 -3
- package/dist/{loop-runner-bin-qwT_4F5I.js → loop-runner-bin-DSbuDDqM.js} +5 -27
- package/dist/loop-runner-bin-DSbuDDqM.js.map +1 -0
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/materialization-COJ1UYQ-.js +272 -0
- package/dist/materialization-COJ1UYQ-.js.map +1 -0
- package/dist/mcp/bin.js +39 -47
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +24 -30
- package/dist/mcp/index.js +66 -83
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/{memory-server-DL6cE2Ag.js → memory-server-5HEJH672.js} +2 -2
- package/dist/{memory-server-DL6cE2Ag.js.map → memory-server-5HEJH672.js.map} +1 -1
- package/dist/model-policy-CqziaqS1.js +232 -0
- package/dist/model-policy-CqziaqS1.js.map +1 -0
- package/dist/{openai-tools-B68JaOCx.d.ts → openai-tools-D3oMyVGl.d.ts} +2 -2
- package/dist/{openai-tools-Bp1KSkP6.js → openai-tools-ru75mLjq.js} +2 -2
- package/dist/openai-tools-ru75mLjq.js.map +1 -0
- package/dist/{prepare--8EvLqCr.js → prepare-DYWjVcPx.js} +169 -153
- package/dist/prepare-DYWjVcPx.js.map +1 -0
- package/dist/primeintellect/index.d.ts +7 -6
- package/dist/primeintellect/index.js +9 -11
- package/dist/primeintellect/index.js.map +1 -1
- package/dist/profiles.d.ts +21 -174
- package/dist/profiles.js +67 -276
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-CXVfOUu_.js → protected-model-port-48ALLGxT.js} +2 -2
- package/dist/{protected-model-port-CXVfOUu_.js.map → protected-model-port-48ALLGxT.js.map} +1 -1
- package/dist/{redact-PQzmE1Jn.d.ts → redact-9_Gf-8m3.d.ts} +58 -69
- package/dist/{researcher-CoVqNhfI.js → researcher-Skz5-Uc8.js} +50 -26
- package/dist/researcher-Skz5-Uc8.js.map +1 -0
- package/dist/{run-layout-C2FGmZ3v.js → run-layout-CeJsEAom.js} +2 -2
- package/dist/{run-layout-C2FGmZ3v.js.map → run-layout-CeJsEAom.js.map} +1 -1
- package/dist/runtime-D-QfLbSd.d.ts +893 -0
- package/dist/{runtime-BzXz7OjS.js → runtime-hiAABiTk.js} +329 -854
- package/dist/runtime-hiAABiTk.js.map +1 -0
- package/dist/{sandbox-events-Yhd1GYWl.js → sandbox-events-CRDwc5WN.js} +42 -5
- package/dist/sandbox-events-CRDwc5WN.js.map +1 -0
- package/dist/snapshot-CXiiuHhL.js +21 -0
- package/dist/snapshot-CXiiuHhL.js.map +1 -0
- package/dist/{spawn-journal-DsZKDqeh.js → spawn-journal-saHQzqYi.js} +15 -21
- package/dist/spawn-journal-saHQzqYi.js.map +1 -0
- package/dist/stream-agent-turn-C852AgMT.d.ts +128 -0
- package/dist/stream-agent-turn-rYgaOLO0.js +910 -0
- package/dist/stream-agent-turn-rYgaOLO0.js.map +1 -0
- package/dist/{structural-rollout-zY0oqQzO.js → structural-rollout-3uxVGcg2.js} +459 -235
- package/dist/structural-rollout-3uxVGcg2.js.map +1 -0
- package/dist/{supervise-Ds8FtyI9.js → supervise-iPN27pO0.js} +932 -4771
- package/dist/supervise-iPN27pO0.js.map +1 -0
- package/dist/{supervisor-DpjO0Gmy.js → supervisor-CV6Jh28D.js} +7439 -2897
- package/dist/supervisor-CV6Jh28D.js.map +1 -0
- package/dist/testing.d.ts +3 -1
- package/dist/testing.js +271 -221
- package/dist/testing.js.map +1 -1
- package/dist/{top-app-5unxqovu.js → top-app-G4M18b6i.js} +3 -3
- package/dist/{top-app-5unxqovu.js.map → top-app-G4M18b6i.js.map} +1 -1
- package/dist/tui/bin.js +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{environment-provider-PM9PeW_J.d.ts → types-C6Q-J0Dt.d.ts} +57 -114
- package/dist/{types-DnNGJ5Gz.d.ts → types-ebIY0dMG.d.ts} +556 -30
- package/dist/{util-MVgdwuIS.js → util-Bw6srryQ.js} +3 -2
- package/dist/{util-MVgdwuIS.js.map → util-Bw6srryQ.js.map} +1 -1
- package/dist/{workspace-archive-BQxvkypI.js → workspace-archive-aOfJ47ms.js} +3 -3
- package/dist/{workspace-archive-BQxvkypI.js.map → workspace-archive-aOfJ47ms.js.map} +1 -1
- package/package.json +12 -15
- package/skills/agent-graphs/IMPROVE.md +58 -0
- package/skills/agent-graphs/SKILL.md +139 -0
- package/skills/agent-graphs/cases/artifact-mission-release-notes.json +10 -0
- package/skills/agent-graphs/cases/audited-single-writer.json +9 -0
- package/skills/agent-graphs/cases/cap-as-stop-mistake.json +8 -0
- package/skills/agent-graphs/cases/mission-in-deliverable.json +8 -0
- package/skills/agent-graphs/cases/review-pipeline.json +13 -0
- package/skills/agent-graphs/cases/runtime-discovered-fanout.json +8 -0
- package/skills/agent-graphs/cases/single-agent-suffices.json +7 -0
- package/skills/agent-graphs/cases/steer-heavy-drafting.json +9 -0
- package/skills/agent-graphs/cases/unmeasured-harness.json +7 -0
- package/skills/agent-graphs/generations/gen1-baseline.json +248 -0
- package/skills/agent-graphs/generations/gen2.json +375 -0
- package/skills/agent-graphs/generations/gen3.json +702 -0
- package/skills/build-with-agent-runtime/SKILL.md +1 -0
- package/dist/backends-CiOCyRHb.js +0 -743
- package/dist/backends-CiOCyRHb.js.map +0 -1
- package/dist/conversation-BpLQZGPH.js.map +0 -1
- package/dist/environment-provider-DqFS6FSZ.js.map +0 -1
- package/dist/improvement-cycle-IJgCbKWQ.js.map +0 -1
- package/dist/index-D_M4d1_B.d.ts +0 -545
- package/dist/knowledge-EnuEqm_Y.js.map +0 -1
- package/dist/local-harness-BIajef4A.d.ts +0 -465
- package/dist/loop-runner-bin-qwT_4F5I.js.map +0 -1
- package/dist/model-resolution-Btd9iIKV.js +0 -98
- package/dist/model-resolution-Btd9iIKV.js.map +0 -1
- package/dist/openai-tools-Bp1KSkP6.js.map +0 -1
- package/dist/prepare--8EvLqCr.js.map +0 -1
- package/dist/researcher-CoVqNhfI.js.map +0 -1
- package/dist/runtime-BzXz7OjS.js.map +0 -1
- package/dist/sandbox-events-Yhd1GYWl.js.map +0 -1
- package/dist/spawn-journal-DsZKDqeh.js.map +0 -1
- package/dist/structural-rollout-zY0oqQzO.js.map +0 -1
- package/dist/supervise-Ds8FtyI9.js.map +0 -1
- package/dist/supervisor-DpjO0Gmy.js.map +0 -1
- package/dist/types-C9j4qg6l.d.ts +0 -500
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { x as contentAddress } from "./spawn-journal-
|
|
1
|
+
import { x as contentAddress } from "./spawn-journal-saHQzqYi.js";
|
|
2
2
|
import { i as redactProtectedValue, n as createProtectedRecordRedactor, r as redactProtectedReason, t as assertNoProtectedBytes } from "./protected-redaction--F3v1oo8.js";
|
|
3
3
|
import { REDACTION_VERSION, canonicalJson, isLlmSpan } from "@tangle-network/agent-eval";
|
|
4
4
|
import { agentCandidateArtifactRefSchema, agentCandidateBenchmarkResultEvidenceSchema, agentCandidateBenchmarkSuiteSchema, agentCandidateBenchmarkTaskSchema, agentCandidateBundleSchema, agentCandidateContainerSchema, agentCandidateExecutionLimitsSchema, agentCandidateExecutionPlanEvidenceSchema, agentCandidateExecutionPlanMaterialSchema, agentCandidateMaterializationReceiptSchema, agentCandidateModelAccessNetworkSchema, agentCandidateModelSettlementEvidenceSchema, agentCandidateProfileActivationSchema, agentCandidateProfilePlanEvidenceSchema, agentCandidateProfileSchema, agentCandidateResolvedModelSchema, agentCandidateRunCellSchema, agentCandidateRunReceiptSchema, agentCandidateTaskOutcomeEvidenceSchema, agentCandidateTaskOutcomeSpecSchema, agentCandidateTerminationSchema, agentCandidateWorkspaceManifestMaterialSchema, agentCandidateWorkspaceSnapshotEvidenceSchema, agentProfileDiffSchema, agentProfileSchema, applyAgentProfileDiff, sha256DigestSchema } from "@tangle-network/agent-interface";
|
|
5
5
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
6
|
+
import { isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
6
7
|
import { applyAgentCandidateWorkspacePlan, isMaterializerHarness, materializeCandidateProfile } from "@tangle-network/agent-profile-materialize";
|
|
7
8
|
import { lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rm, stat } from "node:fs/promises";
|
|
8
9
|
import { constants } from "node:fs";
|
|
9
|
-
import { isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
11
11
|
import { tmpdir } from "node:os";
|
|
12
12
|
import { hashKnowledgeBase } from "@tangle-network/agent-knowledge";
|
|
@@ -64,11 +64,166 @@ function deepFreezeCandidate(value, seen = /* @__PURE__ */ new Set()) {
|
|
|
64
64
|
return Object.freeze(value);
|
|
65
65
|
}
|
|
66
66
|
//#endregion
|
|
67
|
+
//#region src/candidate-execution/system-prompt.ts
|
|
68
|
+
const SYSTEM_PROMPT_FILE = ".tangle/system-prompt.md";
|
|
69
|
+
const APPEND_SYSTEM_PROMPT_FILE = ".tangle/append-system-prompt.md";
|
|
70
|
+
const SYSTEM_PROMPT_FLAGS = ["--system-prompt", "--system-prompt-file"];
|
|
71
|
+
const APPEND_SYSTEM_PROMPT_FLAGS = ["--append-system-prompt", "--append-system-prompt-file"];
|
|
72
|
+
function argsSetSystemPromptFlag(values) {
|
|
73
|
+
return values.some((value) => SYSTEM_PROMPT_FLAGS.some((flag) => value === flag || value.startsWith(`${flag}=`)));
|
|
74
|
+
}
|
|
75
|
+
function argsSetAppendSystemPromptFlag(values) {
|
|
76
|
+
return values.some((value) => APPEND_SYSTEM_PROMPT_FLAGS.some((flag) => value === flag || value.startsWith(`${flag}=`)));
|
|
77
|
+
}
|
|
78
|
+
/** Codex keys that can replace or contaminate the materializer's sealed instructions file. */
|
|
79
|
+
const CODEX_INSTRUCTION_KEYS = ["model_instructions_file", "developer_instructions"];
|
|
80
|
+
function argsSetCodexInstructionOverride(values) {
|
|
81
|
+
for (let index = 0; index < values.length; index++) {
|
|
82
|
+
const value = values[index];
|
|
83
|
+
const config = value === "-c" || value === "--config" ? values[index + 1] : value.startsWith("--config=") ? value.slice(9) : void 0;
|
|
84
|
+
if (config !== void 0 && CODEX_INSTRUCTION_KEYS.some((key) => config.trimStart().startsWith(`${key}=`))) return true;
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const HARNESS_SYSTEM_PROMPTS = {
|
|
89
|
+
"claude-code": {
|
|
90
|
+
executable: "claude",
|
|
91
|
+
project: (plan, systemPrompt, path) => appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), "--system-prompt-file", path),
|
|
92
|
+
projectAppend: (plan, appendSystemPrompt, path) => appendFlags(addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt), "--append-system-prompt-file", path),
|
|
93
|
+
conflictsWithArgs: argsSetSystemPromptFlag,
|
|
94
|
+
conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
|
|
95
|
+
},
|
|
96
|
+
/** OpenCode's bound primary agent is already selected by the materializer's --agent flag. */
|
|
97
|
+
opencode: {
|
|
98
|
+
executable: "opencode",
|
|
99
|
+
project: (plan) => plan,
|
|
100
|
+
retainsProjectedSystemPrompt: true,
|
|
101
|
+
conflictsWithArgs: (values) => values.some((value) => value === "--agent" || value.startsWith("--agent=")),
|
|
102
|
+
conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
|
|
103
|
+
},
|
|
104
|
+
pi: {
|
|
105
|
+
executable: "pi",
|
|
106
|
+
project: (plan, systemPrompt, path) => appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), "--system-prompt", path),
|
|
107
|
+
projectAppend: (plan, appendSystemPrompt, path) => appendFlags(addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt), "--append-system-prompt", path),
|
|
108
|
+
conflictsWithArgs: argsSetSystemPromptFlag,
|
|
109
|
+
conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
|
|
110
|
+
},
|
|
111
|
+
prime: {
|
|
112
|
+
executable: "prime-agent",
|
|
113
|
+
project: (plan, systemPrompt, path) => appendFlags(addPromptFile(plan, SYSTEM_PROMPT_FILE, systemPrompt), "--system-prompt", path),
|
|
114
|
+
projectAppend: (plan, appendSystemPrompt, path) => appendFlags(addPromptFile(plan, APPEND_SYSTEM_PROMPT_FILE, appendSystemPrompt), "--append-system-prompt", path),
|
|
115
|
+
conflictsWithArgs: argsSetSystemPromptFlag,
|
|
116
|
+
conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
|
|
117
|
+
},
|
|
118
|
+
/** Gemini's file and env lowering is materializer-owned; this row supplies the launch proof. */
|
|
119
|
+
gemini: {
|
|
120
|
+
executable: "gemini",
|
|
121
|
+
project: (plan) => plan,
|
|
122
|
+
conflictsWithArgs: argsSetSystemPromptFlag,
|
|
123
|
+
conflictsWithAppendArgs: argsSetAppendSystemPromptFlag
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* These controls are lowered by agent-profile-materialize into files plus launch inputs. The
|
|
128
|
+
* candidate adapter does not own the spawn, so it must reject an arbitrary entrypoint even when
|
|
129
|
+
* the plan has the right bytes: only the native binary can make those inputs effective.
|
|
130
|
+
*/
|
|
131
|
+
const MATERIALIZED_PROMPT_DELIVERIES = {
|
|
132
|
+
codex: {
|
|
133
|
+
executable: "codex",
|
|
134
|
+
delivered: (plan) => plan.files.some((file) => file.relPath === ".codex/system-prompt.md") && plan.flags.some((flag) => flag.value === "model_instructions_file=.codex/system-prompt.md"),
|
|
135
|
+
conflictsWithArgs: argsSetCodexInstructionOverride
|
|
136
|
+
},
|
|
137
|
+
gemini: {
|
|
138
|
+
executable: "gemini",
|
|
139
|
+
delivered: (plan) => plan.files.some((file) => file.relPath === ".gemini/system.md") && plan.env.GEMINI_SYSTEM_MD?.value === "1",
|
|
140
|
+
conflictsWithArgs: argsSetSystemPromptFlag
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
/** Project both prompt intents onto their distinct native process controls. */
|
|
144
|
+
function projectCandidatePromptIntents(plan, launch, systemPromptFilePath, requestedSystemPrompt = plan.systemPrompt?.value, requestedAppendSystemPrompt = plan.appendSystemPrompt?.value) {
|
|
145
|
+
const systemPrompt = plan.systemPrompt;
|
|
146
|
+
const appendSystemPrompt = plan.appendSystemPrompt;
|
|
147
|
+
const delivery = MATERIALIZED_PROMPT_DELIVERIES[plan.harness];
|
|
148
|
+
if (systemPrompt === void 0 && delivery?.delivered(plan)) {
|
|
149
|
+
assertProvableNativeLaunch(plan.harness, delivery.executable, launch, "replacement");
|
|
150
|
+
assertNoShadowingArgs(plan.harness, delivery.conflictsWithArgs, launch, "replacement");
|
|
151
|
+
if (requestedSystemPrompt === void 0) return plan;
|
|
152
|
+
return plan;
|
|
153
|
+
}
|
|
154
|
+
if (requestedSystemPrompt === void 0 && requestedAppendSystemPrompt === void 0) return plan;
|
|
155
|
+
const projection = HARNESS_SYSTEM_PROMPTS[plan.harness];
|
|
156
|
+
if (!projection) throw new Error(`candidate system prompt has no native launch projection for ${plan.harness}`);
|
|
157
|
+
const requestedReplacement = requestedSystemPrompt !== void 0;
|
|
158
|
+
if (requestedReplacement && systemPrompt === void 0) throw new Error(`profile materializer did not deliver the candidate system prompt for ${plan.harness}`);
|
|
159
|
+
if (systemPrompt !== void 0 && requestedSystemPrompt === void 0) throw new Error(`profile materializer added an unexpected candidate system prompt for ${plan.harness}`);
|
|
160
|
+
if (systemPrompt !== void 0 && systemPrompt.value !== requestedSystemPrompt) throw new Error("profile materializer changed the candidate system prompt");
|
|
161
|
+
if (appendSystemPrompt !== void 0 && appendSystemPrompt.value !== requestedAppendSystemPrompt) throw new Error("profile materializer changed the candidate append system prompt");
|
|
162
|
+
const intent = requestedReplacement ? "replacement" : "addition";
|
|
163
|
+
assertProvableNativeLaunch(plan.harness, projection.executable, launch, intent);
|
|
164
|
+
const launchArgs = (launch.args ?? []).map((value) => value.value);
|
|
165
|
+
if (requestedReplacement && projection.conflictsWithArgs(launchArgs)) throw new Error(`${plan.harness} launch arguments conflict with the candidate profile system prompt`);
|
|
166
|
+
if (requestedAppendSystemPrompt !== void 0 && projection.conflictsWithAppendArgs(launchArgs)) throw new Error(`${plan.harness} launch arguments conflict with the candidate profile append system prompt`);
|
|
167
|
+
let projected = plan;
|
|
168
|
+
if (systemPrompt !== void 0) projected = projection.project(projection.retainsProjectedSystemPrompt ? projected : omitPromptIntent(projected, "systemPrompt"), systemPrompt.value, systemPromptFilePath);
|
|
169
|
+
if (appendSystemPrompt !== void 0) {
|
|
170
|
+
if (!projection.projectAppend) throw new Error(`candidate append system prompt has no native launch projection for ${plan.harness}`);
|
|
171
|
+
projected = projection.projectAppend(omitPromptIntent(projected, "appendSystemPrompt"), appendSystemPrompt.value, posix.join(posix.dirname(systemPromptFilePath), "append-system-prompt.md"));
|
|
172
|
+
}
|
|
173
|
+
return projected;
|
|
174
|
+
}
|
|
175
|
+
function assertProvableNativeLaunch(harness, expectedExecutable, launch, intent) {
|
|
176
|
+
if (launch.kind !== "container-command") throw new Error(`candidate-entrypoint launch cannot prove ${harness} system-prompt ${intent}`);
|
|
177
|
+
if (launch.executable !== expectedExecutable && !(posix.isAbsolute(launch.executable) && posix.basename(launch.executable) === expectedExecutable)) throw new Error(`${harness} system-prompt ${intent} requires the native ${expectedExecutable} executable`);
|
|
178
|
+
}
|
|
179
|
+
function assertNoShadowingArgs(harness, conflictsWithArgs, launch, intent) {
|
|
180
|
+
if (conflictsWithArgs((launch.args ?? []).map((value) => value.value))) throw new Error(`${harness} launch arguments conflict with the candidate profile ${intent === "replacement" ? "system" : "append system"} prompt`);
|
|
181
|
+
}
|
|
182
|
+
function omitPromptIntent(plan, intent) {
|
|
183
|
+
const projected = { ...plan };
|
|
184
|
+
delete projected[intent];
|
|
185
|
+
return projected;
|
|
186
|
+
}
|
|
187
|
+
function appendFlags(plan, ...values) {
|
|
188
|
+
return {
|
|
189
|
+
...plan,
|
|
190
|
+
flags: [...plan.flags, ...values.map(publicValue$1)]
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function publicValue$1(value) {
|
|
194
|
+
return {
|
|
195
|
+
kind: "public",
|
|
196
|
+
value
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function addPromptFile(plan, relPath, prompt) {
|
|
200
|
+
if (plan.files.some((file) => file.relPath === relPath)) throw new Error(`candidate profile conflicts with reserved ${relPath}`);
|
|
201
|
+
return {
|
|
202
|
+
...plan,
|
|
203
|
+
files: [...plan.files, {
|
|
204
|
+
relPath,
|
|
205
|
+
content: prompt,
|
|
206
|
+
source: "generated"
|
|
207
|
+
}]
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
67
211
|
//#region src/candidate-execution/profile.ts
|
|
68
212
|
function candidateMaterializerHarness(harness) {
|
|
69
213
|
if (!isMaterializerHarness(harness)) throw new Error(`sealed candidate profile materialization is unsupported for harness ${harness}`);
|
|
70
214
|
return harness;
|
|
71
215
|
}
|
|
216
|
+
/** Runtime applies the materializer's launch flags to the candidate process. */
|
|
217
|
+
const CANDIDATE_PROFILE_MATERIALIZER_BINDS = ["systemPrompt"];
|
|
218
|
+
/** Derive the exact native profile plan used by preparation and later evidence checks. */
|
|
219
|
+
function materializeAgentCandidateProfilePlan(options) {
|
|
220
|
+
const root = options.workspace === "task" ? options.workspaces.taskRoot : options.workspaces.candidateRoot;
|
|
221
|
+
if (!root) throw new Error("candidate profile target is missing its execution workspace root");
|
|
222
|
+
return projectCandidatePromptIntents(materializeCandidateProfile(options.profile, candidateMaterializerHarness(options.harness), {
|
|
223
|
+
binds: CANDIDATE_PROFILE_MATERIALIZER_BINDS,
|
|
224
|
+
resolvedResources: options.resolvedResources
|
|
225
|
+
}), options.launch, posix.join(root, ".tangle/system-prompt.md"), options.profile.prompt?.systemPrompt, options.profile.prompt?.appendSystemPrompt);
|
|
226
|
+
}
|
|
72
227
|
/** Bind exact native profile text to the canonical plan captured during preparation. */
|
|
73
228
|
function createAgentCandidateProfileActivation(plan, profilePlan) {
|
|
74
229
|
const sourceByPath = new Map(plan.files.map((file) => [file.relPath, file]));
|
|
@@ -207,7 +362,7 @@ function agentCandidateProfileAsAgentProfile(candidate) {
|
|
|
207
362
|
if (candidate.modes) output.modes = cloneRecord(candidate.modes);
|
|
208
363
|
if (candidate.hooks) output.hooks = Object.fromEntries(Object.entries(candidate.hooks).map(([event, hooks]) => [event, hooks.map(({ executable, args, env, ...hook }) => ({
|
|
209
364
|
...hook,
|
|
210
|
-
command: [executable, ...(args ?? []).map(publicValue
|
|
365
|
+
command: [executable, ...(args ?? []).map(publicValue)].map(shellQuote).join(" "),
|
|
211
366
|
...env ? { env: cloneRecord(env) } : {}
|
|
212
367
|
}))]));
|
|
213
368
|
if (candidate.resources) {
|
|
@@ -309,7 +464,7 @@ function candidatePublicValue(value, path) {
|
|
|
309
464
|
function mapCandidatePublicValues(values, pathPrefix) {
|
|
310
465
|
return Object.fromEntries(Object.entries(values).map(([name, value]) => [name, candidatePublicValue(value, `${pathPrefix}.${name}`)]));
|
|
311
466
|
}
|
|
312
|
-
function publicValue
|
|
467
|
+
function publicValue(value) {
|
|
313
468
|
return value.value;
|
|
314
469
|
}
|
|
315
470
|
function cloneRecord(values) {
|
|
@@ -3735,146 +3890,6 @@ var CandidateExecutionDeadlineError = class extends Error {
|
|
|
3735
3890
|
}
|
|
3736
3891
|
};
|
|
3737
3892
|
//#endregion
|
|
3738
|
-
//#region src/candidate-execution/system-prompt.ts
|
|
3739
|
-
const SYSTEM_PROMPT_FILE = ".tangle/system-prompt.md";
|
|
3740
|
-
const SYSTEM_PROMPT_FLAGS = ["--system-prompt", "--system-prompt-file"];
|
|
3741
|
-
/** Shared by the harnesses whose native control IS a `--system-prompt*` flag. */
|
|
3742
|
-
function argsSetSystemPromptFlag(values) {
|
|
3743
|
-
return values.some((value) => SYSTEM_PROMPT_FLAGS.some((flag) => value === flag || value.startsWith(`${flag}=`)));
|
|
3744
|
-
}
|
|
3745
|
-
function argsSetCodexDeveloperInstructions(values) {
|
|
3746
|
-
for (let index = 0; index < values.length; index++) {
|
|
3747
|
-
const value = values[index];
|
|
3748
|
-
if ((value === "-c" || value === "--config" ? values[index + 1] : value.startsWith("--config=") ? value.slice(9) : void 0)?.trimStart().startsWith("developer_instructions=")) return true;
|
|
3749
|
-
}
|
|
3750
|
-
return false;
|
|
3751
|
-
}
|
|
3752
|
-
const HARNESS_SYSTEM_PROMPTS = {
|
|
3753
|
-
"claude-code": {
|
|
3754
|
-
executable: "claude",
|
|
3755
|
-
project: (plan, systemPrompt, path) => appendFlags(addSystemPromptFile(plan, systemPrompt), "--system-prompt-file", path),
|
|
3756
|
-
conflictsWithArgs: argsSetSystemPromptFlag
|
|
3757
|
-
},
|
|
3758
|
-
codex: {
|
|
3759
|
-
executable: "codex",
|
|
3760
|
-
project: (plan, systemPrompt) => appendFlags(plan, "-c", `developer_instructions=${tomlString(systemPrompt)}`),
|
|
3761
|
-
conflictsWithArgs: argsSetCodexDeveloperInstructions
|
|
3762
|
-
},
|
|
3763
|
-
opencode: {
|
|
3764
|
-
executable: "opencode",
|
|
3765
|
-
project: (plan, systemPrompt) => ({
|
|
3766
|
-
...plan,
|
|
3767
|
-
files: projectOpenCodeSystemPrompt(plan.files, systemPrompt)
|
|
3768
|
-
}),
|
|
3769
|
-
conflictsWithArgs: () => false
|
|
3770
|
-
},
|
|
3771
|
-
pi: {
|
|
3772
|
-
executable: "pi",
|
|
3773
|
-
project: (plan, systemPrompt, path) => appendFlags(addSystemPromptFile(plan, systemPrompt), "--system-prompt", path),
|
|
3774
|
-
conflictsWithArgs: argsSetSystemPromptFlag
|
|
3775
|
-
}
|
|
3776
|
-
};
|
|
3777
|
-
/** Project a replacement system prompt onto the exact native process control. */
|
|
3778
|
-
function projectCandidateSystemPrompt(plan, launch, systemPromptFilePath) {
|
|
3779
|
-
const systemPrompt = plan.systemPrompt;
|
|
3780
|
-
if (systemPrompt === void 0) return plan;
|
|
3781
|
-
const projection = HARNESS_SYSTEM_PROMPTS[plan.harness];
|
|
3782
|
-
if (!projection) throw new Error(`candidate system prompt has no native launch projection for ${plan.harness}`);
|
|
3783
|
-
const expectedExecutable = projection.executable;
|
|
3784
|
-
if (launch.kind !== "container-command") throw new Error(`candidate-entrypoint launch cannot prove ${plan.harness} system-prompt replacement`);
|
|
3785
|
-
if (launch.executable !== expectedExecutable && !(posix.isAbsolute(launch.executable) && posix.basename(launch.executable) === expectedExecutable)) throw new Error(`${plan.harness} system-prompt replacement requires the native ${expectedExecutable} executable`);
|
|
3786
|
-
if (projection.conflictsWithArgs((launch.args ?? []).map((value) => value.value))) throw new Error(`${plan.harness} launch arguments conflict with the candidate profile system prompt`);
|
|
3787
|
-
return projection.project(omitUnappliedSystemPrompt(plan), systemPrompt.value, systemPromptFilePath);
|
|
3788
|
-
}
|
|
3789
|
-
function omitUnappliedSystemPrompt(plan) {
|
|
3790
|
-
const { systemPrompt: _systemPrompt, ...projected } = plan;
|
|
3791
|
-
return projected;
|
|
3792
|
-
}
|
|
3793
|
-
function appendFlags(plan, ...values) {
|
|
3794
|
-
return {
|
|
3795
|
-
...plan,
|
|
3796
|
-
flags: [...plan.flags, ...values.map(publicValue)]
|
|
3797
|
-
};
|
|
3798
|
-
}
|
|
3799
|
-
function publicValue(value) {
|
|
3800
|
-
return {
|
|
3801
|
-
kind: "public",
|
|
3802
|
-
value
|
|
3803
|
-
};
|
|
3804
|
-
}
|
|
3805
|
-
function addSystemPromptFile(plan, systemPrompt) {
|
|
3806
|
-
if (plan.files.some((file) => file.relPath === SYSTEM_PROMPT_FILE)) throw new Error(`candidate profile conflicts with reserved ${SYSTEM_PROMPT_FILE}`);
|
|
3807
|
-
return {
|
|
3808
|
-
...plan,
|
|
3809
|
-
files: [...plan.files, {
|
|
3810
|
-
relPath: SYSTEM_PROMPT_FILE,
|
|
3811
|
-
content: systemPrompt,
|
|
3812
|
-
source: "generated"
|
|
3813
|
-
}]
|
|
3814
|
-
};
|
|
3815
|
-
}
|
|
3816
|
-
function projectOpenCodeSystemPrompt(files, prompt) {
|
|
3817
|
-
const configIndex = files.findIndex((file) => file.relPath === "opencode.json");
|
|
3818
|
-
if (configIndex === -1) return [...files, {
|
|
3819
|
-
relPath: "opencode.json",
|
|
3820
|
-
content: openCodeConfigWithPrompt({}, prompt),
|
|
3821
|
-
source: "generated"
|
|
3822
|
-
}];
|
|
3823
|
-
const configFile = files[configIndex];
|
|
3824
|
-
if (configFile.source !== "generated") throw new Error("opencode system-prompt replacement requires generated opencode.json");
|
|
3825
|
-
const config = parseJsonObject(configFile.content, "generated opencode.json");
|
|
3826
|
-
const output = [...files];
|
|
3827
|
-
output[configIndex] = {
|
|
3828
|
-
...configFile,
|
|
3829
|
-
content: openCodeConfigWithPrompt(config, prompt)
|
|
3830
|
-
};
|
|
3831
|
-
return output;
|
|
3832
|
-
}
|
|
3833
|
-
function openCodeConfigWithPrompt(config, prompt) {
|
|
3834
|
-
const agent = optionalJsonObject(config.agent, "generated opencode.json agent");
|
|
3835
|
-
const build = optionalJsonObject(agent.build, "generated opencode.json agent.build");
|
|
3836
|
-
const plan = optionalJsonObject(agent.plan, "generated opencode.json agent.plan");
|
|
3837
|
-
assertCompatiblePrompt(build.prompt, prompt, "build");
|
|
3838
|
-
assertCompatiblePrompt(plan.prompt, prompt, "plan");
|
|
3839
|
-
return JSON.stringify({
|
|
3840
|
-
$schema: "https://opencode.ai/config.json",
|
|
3841
|
-
...config,
|
|
3842
|
-
agent: {
|
|
3843
|
-
...agent,
|
|
3844
|
-
build: {
|
|
3845
|
-
...build,
|
|
3846
|
-
prompt
|
|
3847
|
-
},
|
|
3848
|
-
plan: {
|
|
3849
|
-
...plan,
|
|
3850
|
-
prompt
|
|
3851
|
-
}
|
|
3852
|
-
}
|
|
3853
|
-
}, null, 2);
|
|
3854
|
-
}
|
|
3855
|
-
function parseJsonObject(content, label) {
|
|
3856
|
-
let value;
|
|
3857
|
-
try {
|
|
3858
|
-
value = JSON.parse(content);
|
|
3859
|
-
} catch (cause) {
|
|
3860
|
-
throw new Error(`${label} must contain valid JSON`, { cause });
|
|
3861
|
-
}
|
|
3862
|
-
return jsonObject(value, label);
|
|
3863
|
-
}
|
|
3864
|
-
function optionalJsonObject(value, label) {
|
|
3865
|
-
return value === void 0 ? {} : jsonObject(value, label);
|
|
3866
|
-
}
|
|
3867
|
-
function jsonObject(value, label) {
|
|
3868
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be a JSON object`);
|
|
3869
|
-
return value;
|
|
3870
|
-
}
|
|
3871
|
-
function assertCompatiblePrompt(value, prompt, agent) {
|
|
3872
|
-
if (value !== void 0 && value !== prompt) throw new Error(`generated opencode.json agent.${agent}.prompt conflicts with the profile`);
|
|
3873
|
-
}
|
|
3874
|
-
function tomlString(value) {
|
|
3875
|
-
return `"${value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n", "\\n").replaceAll("\r", "\\r").replaceAll(" ", "\\t")}"`;
|
|
3876
|
-
}
|
|
3877
|
-
//#endregion
|
|
3878
3893
|
//#region src/candidate-execution/prepare.ts
|
|
3879
3894
|
const MIN_RESERVATION_TTL_MS = 15 * 6e4;
|
|
3880
3895
|
const PREPARED_HOLD_MARGIN_MS = 5 * 6e4;
|
|
@@ -3890,7 +3905,6 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
3890
3905
|
maxAttempts: benchmarkTask.attempt.maxAttempts,
|
|
3891
3906
|
retryPolicy: benchmarkTask.attempt.retryPolicy
|
|
3892
3907
|
};
|
|
3893
|
-
const harness = candidateMaterializerHarness(bundle.execution.harness);
|
|
3894
3908
|
assertTaskInput(task, bundle.execution.instructionDelivery);
|
|
3895
3909
|
const resultTimeoutMs = candidateResultTimeout(options.resultTimeoutMs, benchmarkTask.limits.timeoutMs);
|
|
3896
3910
|
const reservationWindowMs = candidateExecutionOwnerWindowMs(benchmarkTask.limits.timeoutMs, cleanupTimeoutMs, resultTimeoutMs) + PREPARED_HOLD_MARGIN_MS;
|
|
@@ -3922,7 +3936,14 @@ async function prepareAgentCandidateExecution(candidate, task, ports, options =
|
|
|
3922
3936
|
candidateExecutorFiles = await readMaterializedWorkspaceFiles(task.stagingRoots.candidateRoot, bundle.execution.workspace.material);
|
|
3923
3937
|
} else if (task.stagingRoots.candidateRoot || task.executionRoots.candidateRoot) throw new Error("disabled code cannot receive a candidate workspace root");
|
|
3924
3938
|
await assertEmptyDirectory(task.stagingRoots.profileRoot);
|
|
3925
|
-
const profileWorkspacePlan =
|
|
3939
|
+
const profileWorkspacePlan = materializeAgentCandidateProfilePlan({
|
|
3940
|
+
profile: bundle.profile,
|
|
3941
|
+
harness: bundle.execution.harness,
|
|
3942
|
+
launch: bundle.execution.launch,
|
|
3943
|
+
workspace: bundle.execution.cwd.workspace,
|
|
3944
|
+
workspaces: task.executionRoots,
|
|
3945
|
+
resolvedResources: verifiedResourceTextByDigest(candidate)
|
|
3946
|
+
});
|
|
3926
3947
|
const profileApplication = applyAgentCandidateWorkspacePlan(profileWorkspacePlan, task.stagingRoots.profileRoot, bundle.execution.cwd.workspace);
|
|
3927
3948
|
await verifyMaterializedProfileWorkspace(task.stagingRoots.profileRoot, profileApplication.profileActivation.profilePlan.material);
|
|
3928
3949
|
const profilePlanBytes = await readVerifiedArtifact(profileApplication.profileActivation.profilePlan.artifact, ports.artifacts);
|
|
@@ -4395,11 +4416,6 @@ function absoluteExecutionCwd(cwd, roots) {
|
|
|
4395
4416
|
if (absolute !== root && !absolute.startsWith(`${root}/`)) throw new Error("candidate cwd escapes its execution workspace");
|
|
4396
4417
|
return absolute;
|
|
4397
4418
|
}
|
|
4398
|
-
function profileSystemPromptExecutionPath(workspace, roots) {
|
|
4399
|
-
const root = workspace === "task" ? roots.taskRoot : roots.candidateRoot;
|
|
4400
|
-
if (!root) throw new Error("candidate profile target is missing its execution workspace root");
|
|
4401
|
-
return posix.join(root, ".tangle/system-prompt.md");
|
|
4402
|
-
}
|
|
4403
4419
|
function validateProtectedModelReservation(reservation, expectedLimits, preparationId, expiresAtMs) {
|
|
4404
4420
|
if (!/^sha256:[a-f0-9]{64}$/.test(reservation.digest)) throw new Error("protected model reservation has an invalid identity digest");
|
|
4405
4421
|
if (reservation.preparationId !== preparationId || reservation.expiresAtMs !== expiresAtMs) throw new Error("protected model reservation is not scoped to this preparation");
|
|
@@ -4453,6 +4469,6 @@ function errorMessage(error) {
|
|
|
4453
4469
|
return error instanceof Error ? error.message : String(error);
|
|
4454
4470
|
}
|
|
4455
4471
|
//#endregion
|
|
4456
|
-
export { parseExactAgentProfile as $, verifyMaterializedWorkspace as A, rejectedStage as B, assertNoGitIndirection as C, captureMaterializedWorkspace as D, candidateWorkspaceManifest as E, assertTerminalAllowedInPhase as F, agentCandidateProfileAsAgentProfile as G, sealTerminalDigest as H, assertTerminalMatchesClaim as I,
|
|
4472
|
+
export { parseExactAgentProfile as $, verifyMaterializedWorkspace as A, rejectedStage as B, assertNoGitIndirection as C, captureMaterializedWorkspace as D, candidateWorkspaceManifest as E, assertTerminalAllowedInPhase as F, agentCandidateProfileAsAgentProfile as G, sealTerminalDigest as H, assertTerminalMatchesClaim as I, createAgentCandidateProfileActivation as J, applyExactAgentProfileDiff as K, assertTerminalMatchesStaged as L, candidateCleanupTimeout as M, withinCandidateCleanupDeadline as N, readVerifiedArtifact as O, assertRecoveryMatchesStaged as P, parseAgentCandidateProfileActivation as Q, recoveredTerminalRecord as R, CANDIDATE_TRACE_TAGS as S, runCandidateGit as T, terminalRecord as U, requireStagedTerminal as V, assertExactObjectKeys as W, materializeAgentCandidateProfilePlan as X, freezeGenericAgentCandidateProfile as Y, omitUndefinedObjectFields as Z, candidateExecutionClaim as _, persistCandidateOutputArtifact as a, deepFreezeCandidate as at, consumePreparedCandidateExecution as b, CANDIDATE_KNOWLEDGE_ROOT_ENV as c, omitTopLevelDigest as ct, verifiedResourceTextByDigest as d, parseExactAgentProfileDiff as et, verifyAgentCandidateBundle as f, candidateClaimFileInternals as g, InMemoryAgentCandidateExecutionClaimStore as h, persistCandidateModelSettlementEvidence as i, canonicalCandidateDocument as it, candidateCleanupDeadline as j, verifyBytes as k, candidateKnowledgeExecutionPaths as l, sha256Bytes as lt, usdToNanos as m, executePreparedAgentCandidate as n, canonicalCandidateBytes as nt, sealAgentCandidateExecutorStopAcknowledgement as o, embeddedCandidateArtifact as ot, sealAgentCandidateModelSettlement as p, assertCandidateProfileBinding as q, RecoveryAgentCandidateTraceStore as r, canonicalCandidateDigest$1 as rt, CANDIDATE_KNOWLEDGE_RETRIEVAL_CONFIG_ENV as s, immutableCandidateValue as st, prepareAgentCandidateExecution as t, parseExactCandidateProfile as tt, AGENT_CANDIDATE_EXECUTION_SUPPORT as u, verifyCanonicalCandidateDocument as ut, assertPreparedCandidateIntegrity as v, readCandidateGitTreeFiles as w, CANDIDATE_TRACE_ENV as x, beginPreparedCandidateDisposal as y, rejectedFinish as z };
|
|
4457
4473
|
|
|
4458
|
-
//# sourceMappingURL=prepare
|
|
4474
|
+
//# sourceMappingURL=prepare-DYWjVcPx.js.map
|