@tangle-network/agent-runtime 0.318.0 → 0.319.5
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-CRG-tjnR.js → activation-DPpb2I8z.js} +3 -3
- package/dist/{activation-CRG-tjnR.js.map → activation-DPpb2I8z.js.map} +1 -1
- package/dist/{activation-RExX9RDm.d.ts → activation-OColGsfd.d.ts} +2 -2
- package/dist/agent.d.ts +3 -3
- package/dist/agent.js +3 -3
- package/dist/{bundle-RgHpAFDY.js → bundle-Cw-QdGmH.js} +2 -2
- package/dist/{bundle-RgHpAFDY.js.map → bundle-Cw-QdGmH.js.map} +1 -1
- package/dist/candidate-execution/index.d.ts +40 -3
- package/dist/candidate-execution/index.js +86 -7
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/{coordination-driver-DK3pI_HB.js → coordination-driver-woTI2Vpr.js} +3 -3
- package/dist/{coordination-driver-DK3pI_HB.js.map → coordination-driver-woTI2Vpr.js.map} +1 -1
- package/dist/{delegate-Co9vJIgE.js → delegate-DrFainK0.js} +2 -2
- package/dist/{delegate-Co9vJIgE.js.map → delegate-DrFainK0.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +4 -4
- package/dist/{graph-DYBCYZjg.js → graph-joXNwtkE.js} +5 -5
- package/dist/{graph-DYBCYZjg.js.map → graph-joXNwtkE.js.map} +1 -1
- package/dist/graph-registry-BuJbzTzF.js +211 -0
- package/dist/graph-registry-BuJbzTzF.js.map +1 -0
- package/dist/{improvement-cycle-jp80l_ZQ.js → improvement-cycle-Dkrb5nVc.js} +7 -7
- package/dist/{improvement-cycle-jp80l_ZQ.js.map → improvement-cycle-Dkrb5nVc.js.map} +1 -1
- package/dist/{index-CHlWvoo5.d.ts → index-Da7w2H86.d.ts} +268 -82
- package/dist/index.d.ts +5 -5
- package/dist/index.js +10 -10
- package/dist/intelligence.d.ts +4 -4
- package/dist/intelligence.js +7 -7
- package/dist/kernel.d.ts +3 -2
- package/dist/kernel.js +12 -11
- package/dist/{loop-runner-bin-C-QaaVE2.d.ts → loop-runner-bin-CbBoLC9D.d.ts} +2 -2
- package/dist/{loop-runner-bin-C8jLr2gR.js → loop-runner-bin-OYVzvqiL.js} +3 -3
- package/dist/{loop-runner-bin-C8jLr2gR.js.map → loop-runner-bin-OYVzvqiL.js.map} +1 -1
- 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 +2 -2
- package/dist/mcp/index.js +6 -6
- package/dist/{model-policy-B-rOb8Nj.js → model-policy-CNe257pB.js} +4 -4
- package/dist/{model-policy-B-rOb8Nj.js.map → model-policy-CNe257pB.js.map} +1 -1
- package/dist/{openai-tools-BuJB3JQH.d.ts → openai-tools-Cu9E1Bda.d.ts} +2 -2
- package/dist/placement.d.ts +1 -1
- package/dist/{prepare-CD9kR0gS.js → prepare-DjCLEN-q.js} +3 -3
- package/dist/prepare-DjCLEN-q.js.map +1 -0
- package/dist/{profile-CHXYmpGd.js → profile-DmVM4Gxb.js} +9 -2
- package/dist/profile-DmVM4Gxb.js.map +1 -0
- package/dist/{profile-materialization-Cca615eu.d.ts → profile-materialization-C5-t3HJ7.d.ts} +14 -3
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +1 -1
- package/dist/{protected-model-port-C9QtEf3y.d.ts → protected-model-port-CQg2gstJ.d.ts} +3 -3
- package/dist/{protected-model-port-B0pHd65J.js → protected-model-port-D1fcnYdj.js} +4 -4
- package/dist/{protected-model-port-B0pHd65J.js.map → protected-model-port-D1fcnYdj.js.map} +1 -1
- package/dist/{provision-supervisor-CunKnayY.js → provision-supervisor-CN16EdkE.js} +5 -5
- package/dist/{provision-supervisor-CunKnayY.js.map → provision-supervisor-CN16EdkE.js.map} +1 -1
- package/dist/{runtime-UG5tV_yf.js → runtime-BE4GW_q1.js} +307 -13
- package/dist/runtime-BE4GW_q1.js.map +1 -0
- package/dist/{search-executor-DMX6tCY4.js → search-executor-DuHd_fws.js} +4 -4
- package/dist/{search-executor-DMX6tCY4.js.map → search-executor-DuHd_fws.js.map} +1 -1
- package/dist/{server-fSBvPPLH.js → server-CYdjyARj.js} +4 -4
- package/dist/{server-fSBvPPLH.js.map → server-CYdjyARj.js.map} +1 -1
- package/dist/{supervise-C41ywfFd.js → supervise-CvKx8rlw.js} +5 -5
- package/dist/{supervise-C41ywfFd.js.map → supervise-CvKx8rlw.js.map} +1 -1
- package/dist/{supervisor-BXEL_Fxe.js → supervisor--nmU6w86.js} +259 -36
- package/dist/supervisor--nmU6w86.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +14 -14
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/workspace-store/index.d.ts +171 -3
- package/dist/workspace-store/index.js +529 -8
- package/dist/workspace-store/index.js.map +1 -1
- package/dist/{workspace-streams-DkijayqX.js → workspace-streams-DFAhW7hF.js} +300 -42
- package/dist/workspace-streams-DFAhW7hF.js.map +1 -0
- package/dist/{workspace-streams-CpSmt3zx.d.ts → workspace-streams-U6_UfOXu.d.ts} +10 -2
- package/package.json +13 -10
- package/skills/codemode/references/runtime-execution.md +10 -3
- package/skills/graph-designer/SKILL.md +57 -0
- package/dist/prepare-CD9kR0gS.js.map +0 -1
- package/dist/profile-CHXYmpGd.js.map +0 -1
- package/dist/runtime-UG5tV_yf.js.map +0 -1
- package/dist/supervisor-BXEL_Fxe.js.map +0 -1
- package/dist/workspace-streams-DkijayqX.js.map +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as graphRunsFor, d as recordGraphRun, i as graphRegistry, l as lookupGraph, p as taskShapeDigest, r as graphFromStored, t as digestOfGraph } from "./graph-registry-BuJbzTzF.js";
|
|
2
|
+
import { Bn as InMemoryResultBlobStore, Cn as readPromptOptions, Hn as insideCursorNamespace, It as createWorktreeCliExecutor, Jn as readCommittedJsonLines, Mr as contentAddress, Nt as createExecutor, Ot as verdictFromJudgeScore, Pt as createExecutorRegistry, Qn as isTraceAnalysisStore, Sn as assertBoxlessPromptOptions, Tn as runBrainLoop, Vn as InMemorySpawnJournal, Yn as writeAllBytes, _n as runAgentRounds, aa as detachedSnapshot, ga as notifySandboxEventObserver, hn as defaultSelectWinner, ht as mapExecutorResult, ia as detachedFrozen, j as settledToIteration, mt as gateOnDeliverable, na as executableAgentProfileSnapshot, pt as rollingDispatch, qn as prepareJsonlAppend, r as createSupervisor, ra as executableAgentSpecSnapshot, v as withDriverExecutor, vn as createSandboxLineage, vt as CheckUnavailableError, wn as routerBrain } from "./supervisor--nmU6w86.js";
|
|
2
3
|
import { i as ConfigError, m as ValidationError, n as AnalystError, s as PlannerError } from "./errors-DodWX-cb.js";
|
|
3
|
-
import { B as runAgentic, G as observe, K as renderReport, U as ObservationError, V as sample, X as strategyAuthorMethod, a as reconcileInterruptedSearchCalls, c as searchExecutor, q as profileChatClient, r as dedicatedLane, x as runtimeShipDecision, z as refine } from "./search-executor-
|
|
4
|
-
import {
|
|
5
|
-
import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-
|
|
4
|
+
import { B as runAgentic, G as observe, K as renderReport, U as ObservationError, V as sample, X as strategyAuthorMethod, a as reconcileInterruptedSearchCalls, c as searchExecutor, q as profileChatClient, r as dedicatedLane, x as runtimeShipDecision, z as refine } from "./search-executor-DuHd_fws.js";
|
|
5
|
+
import { A as markPutStreamVerified, J as fnv1a32Hex, L as immutableCandidateValue, N as canonicalCandidateDigest$1, S as captureMaterializedWorkspace, U as chargedTokens, V as addSpend, W as cloneSpend, X as isAbortError, Y as hasCompleteCacheBreakdown, Z as isAsyncIterable, et as randomSuffix, it as stringifySafe, lt as zeroSpend, q as errorMessage, rt as sleep, xt as armDeadlineTimer, y as WorkspaceScanLimitError, z as sha256Bytes$1 } from "./workspace-streams-DFAhW7hF.js";
|
|
6
|
+
import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-CNe257pB.js";
|
|
6
7
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
|
|
7
8
|
import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction-DylCC_ot.js";
|
|
8
|
-
import { C as createInMemoryRunContext, E as foldCoordinationRecords } from "./coordination-driver-
|
|
9
|
-
import { r as supervise } from "./supervise-
|
|
9
|
+
import { C as createInMemoryRunContext, E as foldCoordinationRecords } from "./coordination-driver-woTI2Vpr.js";
|
|
10
|
+
import { r as supervise } from "./supervise-CvKx8rlw.js";
|
|
10
11
|
import "./run-layout-DSCWdbX2.js";
|
|
11
|
-
import "./provision-supervisor-
|
|
12
|
-
import "./delegate-
|
|
13
|
-
import "./graph-
|
|
12
|
+
import "./provision-supervisor-CN16EdkE.js";
|
|
13
|
+
import "./delegate-DrFainK0.js";
|
|
14
|
+
import "./graph-joXNwtkE.js";
|
|
14
15
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, sha256Bytes, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
15
16
|
import { CODING_HARNESSES, DEFAULT_TRACE_ANALYST_KINDS, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, createTraceAnalyst, expandProfileAxes, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
|
|
16
17
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
@@ -562,12 +563,23 @@ function envKeyProvider(env = process.env) {
|
|
|
562
563
|
}
|
|
563
564
|
/** The `AgentProfileMcpServer.metadata` key the declarative secret-env map
|
|
564
565
|
* rides under: `{ ENV_VAR_NAME: 'PROVIDER_KEY_NAME' }`. Names only — values
|
|
565
|
-
* are resolved at materialize time and never stored.
|
|
566
|
+
* are resolved at materialize time and never stored.
|
|
567
|
+
*
|
|
568
|
+
* DEPRECATED (2026-10-12): this is the interface <0.40 channel. Author
|
|
569
|
+
* `profile.mcp[key].env.ENV_VAR_NAME = { kind: 'secret-ref', key }` instead —
|
|
570
|
+
* the canonical form since 0.40. The legacy map keeps resolving (profiles
|
|
571
|
+
* are data in the wild and must not break at boot) but every use now warns
|
|
572
|
+
* once per server; removal lands at the next interface major. */
|
|
566
573
|
const mcpSecretEnvMetadataKey = "secretEnv";
|
|
574
|
+
const warnedSecretEnv = /* @__PURE__ */ new Set();
|
|
567
575
|
/** Read (and validate) a server entry's declared secret-env map, if any.
|
|
568
576
|
* Malformed metadata throws — a half-declared secret must never half-boot. */
|
|
569
|
-
function secretEnvOfMcpServer(server) {
|
|
577
|
+
function secretEnvOfMcpServer(server, label = "profile.mcp server") {
|
|
570
578
|
const raw = server.metadata?.[mcpSecretEnvMetadataKey];
|
|
579
|
+
if (raw !== void 0 && !warnedSecretEnv.has(label)) {
|
|
580
|
+
warnedSecretEnv.add(label);
|
|
581
|
+
console.warn(`${label}: metadata.${mcpSecretEnvMetadataKey} is deprecated — author env secret-refs (profile.mcp[key].env.ENV = { kind: 'secret-ref', key }) instead; support is removed at the next interface major`);
|
|
582
|
+
}
|
|
571
583
|
if (raw === void 0 || raw === null) return void 0;
|
|
572
584
|
if (typeof raw !== "object" || Array.isArray(raw)) throw new ValidationError(`secretEnvOfMcpServer: metadata.${mcpSecretEnvMetadataKey} must be an object mapping env var name -> key name`);
|
|
573
585
|
const entries = Object.entries(raw);
|
|
@@ -7116,6 +7128,185 @@ function chatWorkerSeam(opts) {
|
|
|
7116
7128
|
};
|
|
7117
7129
|
}
|
|
7118
7130
|
//#endregion
|
|
7131
|
+
//#region src/runtime/supervise/designer-tools.ts
|
|
7132
|
+
/**
|
|
7133
|
+
* `graphDesignerExtraTools` — the designer's toolset on the existing
|
|
7134
|
+
* `RunGraphOptions.extraTools` seam.
|
|
7135
|
+
*
|
|
7136
|
+
* A meta-graph designer is an ordinary supervisor ROOT whose ONLY tools are
|
|
7137
|
+
* these three: look up what this task shape has run, run a graph (authored or
|
|
7138
|
+
* replayed — every run recorded, terminal accounting included), and read the
|
|
7139
|
+
* history. The agent authors graphs as DATA (nodes, edges, budget, deliverable
|
|
7140
|
+
* description); execution is ENVIRONMENT-OWNED — the caller closes over how
|
|
7141
|
+
* graphs run (backend/brain/leaf seam) and how the deliverable's check is
|
|
7142
|
+
* re-bound, because oracles are environment, never agent-supplied.
|
|
7143
|
+
*
|
|
7144
|
+
* This is the `measure_rung` pattern from the graph contract generalized: the
|
|
7145
|
+
* root's profile declares the tools; the graph options supply them; nothing
|
|
7146
|
+
* new exists below this line but the registry calls themselves.
|
|
7147
|
+
*/
|
|
7148
|
+
const taskShapeSchema = {
|
|
7149
|
+
type: "object",
|
|
7150
|
+
description: "Stable descriptor of this class of work (kind, source, constraints) — the lookup key. Not the payload.",
|
|
7151
|
+
additionalProperties: true
|
|
7152
|
+
};
|
|
7153
|
+
const graphDataSchema = {
|
|
7154
|
+
type: "object",
|
|
7155
|
+
description: "A graph as data: { nodes: [{id, profile}], edges: [{kind, from, to, directive, ...}], budget, deliverable: {describe} }. No check function — the environment binds it.",
|
|
7156
|
+
additionalProperties: true
|
|
7157
|
+
};
|
|
7158
|
+
function asRecord(value, context) {
|
|
7159
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new ValidationError(`${context}: expected an object`);
|
|
7160
|
+
return value;
|
|
7161
|
+
}
|
|
7162
|
+
/** The designer's three tools over one registry. Record-every-run is enforced
|
|
7163
|
+
* by construction: running IS recording. */
|
|
7164
|
+
function graphDesignerExtraTools(env) {
|
|
7165
|
+
const registry = graphRegistry(env.registryDir);
|
|
7166
|
+
let runCounter = 0;
|
|
7167
|
+
const runId = env.nextRunId ?? (() => `designer-${++runCounter}`);
|
|
7168
|
+
const runAndRecord = async (taskShape, graph, mode) => {
|
|
7169
|
+
const digest = digestOfGraph(graph);
|
|
7170
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7171
|
+
const result = await env.runGraph(graph);
|
|
7172
|
+
const winner = result.result.kind === "winner";
|
|
7173
|
+
const spent = winner ? result.result.spentTotal : void 0;
|
|
7174
|
+
await recordGraphRun(registry, graph, {
|
|
7175
|
+
graphDigest: digest,
|
|
7176
|
+
taskDigest: taskShapeDigest(taskShape),
|
|
7177
|
+
startedAt,
|
|
7178
|
+
finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7179
|
+
outcome: winner ? { kind: "delivered" } : {
|
|
7180
|
+
kind: "no-winner",
|
|
7181
|
+
reason: `mode=${mode} result=${result.result.kind}`
|
|
7182
|
+
},
|
|
7183
|
+
cost: {
|
|
7184
|
+
...spent?.iterations !== void 0 ? { iterations: spent.iterations } : {},
|
|
7185
|
+
...spent?.tokens && typeof spent.tokens === "object" && "input" in spent.tokens ? { tokens: (spent.tokens.input ?? 0) + (spent.tokens.output ?? 0) } : {},
|
|
7186
|
+
...spent?.usd !== void 0 ? { usd: spent.usd } : {}
|
|
7187
|
+
},
|
|
7188
|
+
traversals: result.ledger.length,
|
|
7189
|
+
...result.exhaustedEdges.length > 0 ? { exhaustedEdges: result.exhaustedEdges } : {}
|
|
7190
|
+
});
|
|
7191
|
+
return {
|
|
7192
|
+
runId: runId(),
|
|
7193
|
+
outcome: winner ? "delivered" : `no-winner (${result.result.kind})`,
|
|
7194
|
+
graphDigest: digest,
|
|
7195
|
+
traversals: result.ledger.length,
|
|
7196
|
+
...spent?.iterations !== void 0 ? { iterations: spent.iterations } : {},
|
|
7197
|
+
...spent?.tokens && typeof spent.tokens === "object" && "input" in spent.tokens ? { tokens: (spent.tokens.input ?? 0) + (spent.tokens.output ?? 0) } : {}
|
|
7198
|
+
};
|
|
7199
|
+
};
|
|
7200
|
+
const summarize = (row) => ({
|
|
7201
|
+
graphDigest: row.graphDigest.slice(0, 12),
|
|
7202
|
+
outcome: row.outcome.kind,
|
|
7203
|
+
cost: row.cost,
|
|
7204
|
+
finishedAt: row.finishedAt
|
|
7205
|
+
});
|
|
7206
|
+
return {
|
|
7207
|
+
extraTools: [
|
|
7208
|
+
{
|
|
7209
|
+
name: "designer_lookup_graph",
|
|
7210
|
+
description: "Look up what this task shape has run before. Returns replay (a known-good graph — run it verbatim with designer_run_graph, near-zero inference) or author (with the reason), plus the recent history for context.",
|
|
7211
|
+
parameters: {
|
|
7212
|
+
type: "object",
|
|
7213
|
+
properties: { taskShape: taskShapeSchema },
|
|
7214
|
+
required: ["taskShape"],
|
|
7215
|
+
additionalProperties: false
|
|
7216
|
+
}
|
|
7217
|
+
},
|
|
7218
|
+
{
|
|
7219
|
+
name: "designer_run_graph",
|
|
7220
|
+
description: "Run a graph and record it. REPLAY mode: pass the graphDigest from lookup — the stored graph runs verbatim, check re-bound by the environment. AUTHOR mode: pass the graph as data (no check). Every run is recorded with its terminal accounting; the registry is the memory.",
|
|
7221
|
+
parameters: {
|
|
7222
|
+
type: "object",
|
|
7223
|
+
properties: {
|
|
7224
|
+
taskShape: taskShapeSchema,
|
|
7225
|
+
mode: {
|
|
7226
|
+
type: "string",
|
|
7227
|
+
enum: ["replay", "authored"]
|
|
7228
|
+
},
|
|
7229
|
+
graphDigest: {
|
|
7230
|
+
type: "string",
|
|
7231
|
+
description: "Replay mode: the digest lookup returned."
|
|
7232
|
+
},
|
|
7233
|
+
graph: graphDataSchema,
|
|
7234
|
+
mutationNote: {
|
|
7235
|
+
type: "string",
|
|
7236
|
+
description: "Author mode after a failed replay lineage: what the prior record says went wrong and the ONE axis this graph changes."
|
|
7237
|
+
}
|
|
7238
|
+
},
|
|
7239
|
+
required: ["taskShape", "mode"],
|
|
7240
|
+
additionalProperties: false
|
|
7241
|
+
}
|
|
7242
|
+
},
|
|
7243
|
+
{
|
|
7244
|
+
name: "designer_history",
|
|
7245
|
+
description: "Every recorded run for a task shape (or all shapes): graph digest, outcome, cost, finish time. The evidence for improvement decisions.",
|
|
7246
|
+
parameters: {
|
|
7247
|
+
type: "object",
|
|
7248
|
+
properties: { taskShape: taskShapeSchema },
|
|
7249
|
+
additionalProperties: false
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7252
|
+
],
|
|
7253
|
+
executeExtraTool: (name, raw) => {
|
|
7254
|
+
if (name === "designer_lookup_graph") return (async () => {
|
|
7255
|
+
return lookupGraphSyncish(asRecord(asRecord(raw, "designer_lookup_graph").taskShape, "designer_lookup_graph.taskShape"));
|
|
7256
|
+
})();
|
|
7257
|
+
if (name === "designer_history") return (async () => {
|
|
7258
|
+
const args = asRecord(raw ?? {}, "designer_history");
|
|
7259
|
+
const { listGraphRuns } = await import("./graph-registry-BuJbzTzF.js").then((n) => n.o);
|
|
7260
|
+
const all = await listGraphRuns(registry);
|
|
7261
|
+
return { runs: (args.taskShape === void 0 ? all : all.filter((row) => row.taskDigest === taskShapeDigest(asRecord(args.taskShape, "designer_history.taskShape")))).map(summarize) };
|
|
7262
|
+
})();
|
|
7263
|
+
if (name === "designer_run_graph") return (async () => {
|
|
7264
|
+
const args = asRecord(raw, "designer_run_graph");
|
|
7265
|
+
const taskShape = asRecord(args.taskShape, "designer_run_graph.taskShape");
|
|
7266
|
+
const mode = args.mode;
|
|
7267
|
+
if (mode === "replay") {
|
|
7268
|
+
const digest = args.graphDigest;
|
|
7269
|
+
if (typeof digest !== "string" || digest.length === 0) throw new ValidationError("designer_run_graph: replay mode requires graphDigest from lookup");
|
|
7270
|
+
const { loadGraph } = await import("./graph-registry-BuJbzTzF.js").then((n) => n.o);
|
|
7271
|
+
const stored = await loadGraph(registry, digest);
|
|
7272
|
+
if (!stored) throw new ValidationError(`designer_run_graph: no stored graph ${digest.slice(0, 12)} — re-lookup`);
|
|
7273
|
+
const graph = env.bindCheck(graphFromStored(stored, () => {
|
|
7274
|
+
throw new Error("designer: environment did not bind the deliverable check");
|
|
7275
|
+
}));
|
|
7276
|
+
return runAndRecord(taskShape, graph, "replay");
|
|
7277
|
+
}
|
|
7278
|
+
if (mode === "authored") {
|
|
7279
|
+
const graph = asRecord(args.graph, "designer_run_graph.graph");
|
|
7280
|
+
for (const axis of [
|
|
7281
|
+
"nodes",
|
|
7282
|
+
"edges",
|
|
7283
|
+
"budget",
|
|
7284
|
+
"deliverable"
|
|
7285
|
+
]) if (graph[axis] === void 0) throw new ValidationError(`designer_run_graph.graph: ${axis} is required`);
|
|
7286
|
+
return runAndRecord(taskShape, env.bindCheck(graph), "authored");
|
|
7287
|
+
}
|
|
7288
|
+
throw new ValidationError("designer_run_graph: mode must be 'replay' | 'authored'");
|
|
7289
|
+
})();
|
|
7290
|
+
return null;
|
|
7291
|
+
}
|
|
7292
|
+
};
|
|
7293
|
+
async function lookupGraphSyncish(taskShape) {
|
|
7294
|
+
const selection = await lookupGraph(registry, taskShapeDigest(taskShape));
|
|
7295
|
+
const history = (await graphRunsFor(registry, taskShapeDigest(taskShape))).map(summarize);
|
|
7296
|
+
if (selection.kind === "replay") return {
|
|
7297
|
+
decision: "replay",
|
|
7298
|
+
reason: `a delivered graph exists (${selection.record.cost.iterations ?? "?"} iterations, ${selection.record.cost.tokens ?? "?"} tokens)`,
|
|
7299
|
+
graphDigest: selection.graph.digest,
|
|
7300
|
+
history
|
|
7301
|
+
};
|
|
7302
|
+
return {
|
|
7303
|
+
decision: "author",
|
|
7304
|
+
reason: selection.reason,
|
|
7305
|
+
history
|
|
7306
|
+
};
|
|
7307
|
+
}
|
|
7308
|
+
}
|
|
7309
|
+
//#endregion
|
|
7119
7310
|
//#region src/runtime/supervise/patch-checks.ts
|
|
7120
7311
|
const DEFAULT_MAX_DIFF_LINES = 400;
|
|
7121
7312
|
/**
|
|
@@ -7245,6 +7436,109 @@ function signalPass(value, required) {
|
|
|
7245
7436
|
return !required;
|
|
7246
7437
|
}
|
|
7247
7438
|
//#endregion
|
|
7439
|
+
//#region src/runtime/supervise/profile-registry.ts
|
|
7440
|
+
/**
|
|
7441
|
+
* `profile-registry` — named AgentProfiles with run receipts: the missing
|
|
7442
|
+
* bottom layer of the designer's memory.
|
|
7443
|
+
*
|
|
7444
|
+
* The graph registry (#1719) answers "which GRAPH won for this task shape?"
|
|
7445
|
+
* but a profile is reused ACROSS graphs and across products — the same
|
|
7446
|
+
* summarizer, the same referee, the same driver — and "did the v2 prompt
|
|
7447
|
+
* actually improve?" was answerable only per-graph. This module gives named
|
|
7448
|
+
* profiles their own receipt loop in the exact same shape as the graph
|
|
7449
|
+
* registry: profiles content-addressed by the interface's canonical digest,
|
|
7450
|
+
* one JSONL record per run, pickBest by the same documented heuristic.
|
|
7451
|
+
*
|
|
7452
|
+
* A profile record answers the question a prompt change has to answer before
|
|
7453
|
+
* it deserves to exist: same name, new digest — what did each version cost,
|
|
7454
|
+
* and did it deliver? Versions never overwrite (immutability), so old-vs-new
|
|
7455
|
+
* is always a controlled diff, and a product mounting the registry can refuse
|
|
7456
|
+
* a profile revision with no runs behind it.
|
|
7457
|
+
*/
|
|
7458
|
+
const RECORDS_FILE = "profile-records.jsonl";
|
|
7459
|
+
const PROFILES_DIR = "profiles";
|
|
7460
|
+
function assertRecord(record) {
|
|
7461
|
+
if (typeof record.name !== "string" || record.name.trim().length === 0) throw new ValidationError("profile-registry: record.name is required");
|
|
7462
|
+
if (typeof record.profileDigest !== "string" || record.profileDigest.length === 0) throw new ValidationError("profile-registry: record.profileDigest is required");
|
|
7463
|
+
if (record.outcome.kind !== "delivered" && record.outcome.kind !== "failed") throw new ValidationError("profile-registry: record.outcome.kind must be 'delivered' | 'failed'");
|
|
7464
|
+
}
|
|
7465
|
+
/** Open (or lazily create) a profile registry rooted at a workspace directory. */
|
|
7466
|
+
function profileRegistry(root) {
|
|
7467
|
+
if (!root || root.trim().length === 0) throw new ValidationError("profileRegistry: root directory is required");
|
|
7468
|
+
return { root };
|
|
7469
|
+
}
|
|
7470
|
+
async function ensureLayout(reg) {
|
|
7471
|
+
await mkdir(join(reg.root, PROFILES_DIR), { recursive: true });
|
|
7472
|
+
}
|
|
7473
|
+
async function readRecords(reg) {
|
|
7474
|
+
try {
|
|
7475
|
+
return (await readFile(join(reg.root, RECORDS_FILE), "utf8")).split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
|
|
7476
|
+
} catch {
|
|
7477
|
+
return [];
|
|
7478
|
+
}
|
|
7479
|
+
}
|
|
7480
|
+
/** Record one run and persist the exact profile revision beside it. The
|
|
7481
|
+
* record's digest must match the supplied profile — a record always names
|
|
7482
|
+
* the revision that actually ran. The revision file is write-once: a
|
|
7483
|
+
* different profile under the same digest is refused. */
|
|
7484
|
+
async function recordProfileRun(reg, profile, record) {
|
|
7485
|
+
assertRecord(record);
|
|
7486
|
+
if (typeof profile?.name !== "string" || profile.name !== record.name) throw new ValidationError(`profile-registry: the supplied profile's name must equal record.name ('${record.name}')`);
|
|
7487
|
+
const digest = canonicalAgentProfileDigest(profile);
|
|
7488
|
+
if (digest !== record.profileDigest) throw new ValidationError(`profile-registry: record.profileDigest ${record.profileDigest.slice(0, 12)} does not match the supplied profile (${digest.slice(0, 12)}) — record the revision that actually ran`);
|
|
7489
|
+
await ensureLayout(reg);
|
|
7490
|
+
const file = join(reg.root, PROFILES_DIR, `${digest}.json`);
|
|
7491
|
+
try {
|
|
7492
|
+
if (canonicalAgentProfileDigest(JSON.parse(await readFile(file, "utf8"))) !== digest) throw new ValidationError(`profile-registry: revision ${digest.slice(0, 12)} is immutable but its stored copy differs — refusing to overwrite`);
|
|
7493
|
+
} catch (error) {
|
|
7494
|
+
if (!(error instanceof ValidationError)) await writeFile(file, JSON.stringify(profile), "utf8");
|
|
7495
|
+
else throw error;
|
|
7496
|
+
}
|
|
7497
|
+
const deduped = (await readRecords(reg)).filter((row) => !(row.name === record.name && row.profileDigest === record.profileDigest && row.startedAt === record.startedAt));
|
|
7498
|
+
deduped.push(record);
|
|
7499
|
+
await writeFile(join(reg.root, RECORDS_FILE), deduped.map((row) => JSON.stringify(row)).join("\n") + "\n", "utf8");
|
|
7500
|
+
}
|
|
7501
|
+
/** All records for one name, newest last. */
|
|
7502
|
+
async function profileRunsForName(reg, name) {
|
|
7503
|
+
return (await readRecords(reg)).filter((row) => row.name === name);
|
|
7504
|
+
}
|
|
7505
|
+
/** The best revision of a name by the same documented heuristic as the graph
|
|
7506
|
+
* registry: delivered beats failed, then cheaper (tokens, then iterations),
|
|
7507
|
+
* then most recent. This is the answer to "which prompt revision is winning?"
|
|
7508
|
+
* — and every alternative is a controlled diff away (versions never overwrite). */
|
|
7509
|
+
function pickBestProfile(records) {
|
|
7510
|
+
const delivered = records.filter((row) => row.outcome.kind === "delivered");
|
|
7511
|
+
if (delivered.length === 0) return void 0;
|
|
7512
|
+
const better = (a, b) => {
|
|
7513
|
+
const aTokens = a.cost.tokens ?? Number.POSITIVE_INFINITY;
|
|
7514
|
+
const bTokens = b.cost.tokens ?? Number.POSITIVE_INFINITY;
|
|
7515
|
+
if (aTokens !== bTokens) return aTokens < bTokens ? a : b;
|
|
7516
|
+
const aIter = a.cost.iterations ?? Number.POSITIVE_INFINITY;
|
|
7517
|
+
const bIter = b.cost.iterations ?? Number.POSITIVE_INFINITY;
|
|
7518
|
+
if (aIter !== bIter) return aIter < bIter ? a : b;
|
|
7519
|
+
return a.finishedAt >= b.finishedAt ? a : b;
|
|
7520
|
+
};
|
|
7521
|
+
return delivered.reduce((best, row) => better(best, row) === best ? best : row);
|
|
7522
|
+
}
|
|
7523
|
+
/** Load a stored profile revision by digest (for replaying the winning revision). */
|
|
7524
|
+
async function loadProfile(reg, digest) {
|
|
7525
|
+
try {
|
|
7526
|
+
return JSON.parse(await readFile(join(reg.root, PROFILES_DIR, `${digest}.json`), "utf8"));
|
|
7527
|
+
} catch {
|
|
7528
|
+
return;
|
|
7529
|
+
}
|
|
7530
|
+
}
|
|
7531
|
+
/** The winning revision of a name, ready to mount. */
|
|
7532
|
+
async function bestProfileFor(reg, name) {
|
|
7533
|
+
const best = pickBestProfile(await profileRunsForName(reg, name));
|
|
7534
|
+
if (!best) return void 0;
|
|
7535
|
+
const profile = await loadProfile(reg, best.profileDigest);
|
|
7536
|
+
return profile ? {
|
|
7537
|
+
profile,
|
|
7538
|
+
record: best
|
|
7539
|
+
} : void 0;
|
|
7540
|
+
}
|
|
7541
|
+
//#endregion
|
|
7248
7542
|
//#region src/runtime/supervise/sql-run-context.ts
|
|
7249
7543
|
/**
|
|
7250
7544
|
* A cross-machine run context on the existing autocommit SqlAdapter. Reuse the same database,
|
|
@@ -8530,6 +8824,6 @@ function tail(s) {
|
|
|
8530
8824
|
return s.slice(-400);
|
|
8531
8825
|
}
|
|
8532
8826
|
//#endregion
|
|
8533
|
-
export {
|
|
8827
|
+
export { builtinShapes as $, mcpSecretEnvMetadataKey as $t, recordProfileRun as A, declaredCheckDeliverable as At, authorStrategy as B, pairwiseSignificance as Bt, analyzeTrace as C, localSandboxClient as Ct, pickBestProfile as D, superviseDispatch as Dt, loadProfile as E, loopDispatch as Et, chatWorkerSeam as F, completionAuthorizes as Ft, createS3PrivateCasStore as G, SqlRunOwnershipError as Gt, strategyAuthorSystemPrompt as H, renderLeaderboardMarkdown as Ht, createChatSessionStore as I, deterministicCompletion as It, createPrivateCasArtifactPort as J, connectStdioMcp as Jt, printBenchmarkReport as K, openSqlRunStore as Kt, runStrategyEvolution as L, sentinelCompletion as Lt, runCoderChecks as M, declaredCheckJudge as Mt, graphDesignerExtraTools as N, readDeclaredCheck as Nt, profileRegistry as O, assertDeclaredCheck as Ot, chatTransportExecutor as P, runIsolatedCheck as Pt, runPersonified as Q, envKeyProvider as Qt, strategyTournament as R, stopSentinel as Rt, withUntrackedArtifacts as S, resolveSandboxClient as St, bestProfileFor as T, loopCampaignDispatch as Tt, SandboxRunAbortError as U, renderLeaderboardSvg as Ut, strategyAuthorContract as V, renderLeaderboardHtml as Vt, openSandboxRun as W, renderPairwiseMarkdown as Wt, trajectoryReport as X, createMcpEnvironment as Xt, equalKOnCost as Y, materializeLocalMcp as Yt, definePersona as Z, sanitizeMcpToolSchema as Zt, VERIFY_TAIL_CHARS as _, observationFromRegistry as _t, localShell as a, fanout as at, settledWorkerOut as b, harvestCorpus as bt, createVerifierEnvironment as c, panel as ct, harvestSurfaceDiffs as d, verify as dt, resolveMcpServerLaunch as en, createShapeRegistry as et, analystsFromRegistry as f, widen as ft, NOTE_MAX_CHARS as g, registryScopeAnalyst as gt, EVIDENCE_MAX_CHARS as h, createScopeAnalyst as ht, jjWorkspace as i, renderCorpusToInstructions as it, patchDelivered as j, declaredCheckDigest as jt, profileRunsForName as k, checkProgramDigest as kt, boxSurfaceReader as l, pipeline as lt, worktreeFanout as m, buildSteerContext as mt, makeFinding$1 as n, secretEnvOfMcpServer as nn, FileCorpus as nt, runInWorkspace as o, flatWidenGate as ot, failuresAnalyst as p, assertTraceDerivedFindings as pt, runBenchmark as q, McpSpawnFault as qt, gitWorkspace as r, createTangleSandboxExactProcessProvider as rn, InMemoryCorpus as rt, createWaterfallCollector as s, loopUntil as st, computeFindingId$1 as t, resolveSecretEnv as tn, registerShape as tt, fsSurfaceReader as u, selectValidWinner as ut, closingWorkerNote as v, inProcessSandboxClient as vt, createFencedSqlRunContext as w, inlineSandboxClient as wt, copyUntrackedIntoClone as x, defineLeaderboard as xt, composeWorkerEvidence as y, HarvestError as yt, assertStrategyContract as z, leaderboard as zt };
|
|
8534
8828
|
|
|
8535
|
-
//# sourceMappingURL=runtime-
|
|
8829
|
+
//# sourceMappingURL=runtime-BE4GW_q1.js.map
|