@tangle-network/agent-runtime 0.193.1 → 0.195.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.
Files changed (131) hide show
  1. package/dist/{activation-BismttgN.js → activation-DtIbcFOX.js} +3 -3
  2. package/dist/{activation-BismttgN.js.map → activation-DtIbcFOX.js.map} +1 -1
  3. package/dist/agent.d.ts +1 -1
  4. package/dist/agent.js +2 -2
  5. package/dist/candidate-execution/index.js +4 -4
  6. package/dist/{candidate-execution-BSkZErxD.js → candidate-execution-nvqVIMyS.js} +5 -4
  7. package/dist/{candidate-execution-BSkZErxD.js.map → candidate-execution-nvqVIMyS.js.map} +1 -1
  8. package/dist/{conversation-DILnmy84.js → conversation-BXPWMOSd.js} +4 -5
  9. package/dist/{conversation-DILnmy84.js.map → conversation-BXPWMOSd.js.map} +1 -1
  10. package/dist/conversation.d.ts +1 -1
  11. package/dist/conversation.js +1 -1
  12. package/dist/{coordination-driver-DujHiIGa.js → coordination-driver-iSN-m3VX.js} +281 -244
  13. package/dist/coordination-driver-iSN-m3VX.js.map +1 -0
  14. package/dist/{authoring-DWiqKSDY.js → delegate-DCC2muUd.js} +56 -13
  15. package/dist/delegate-DCC2muUd.js.map +1 -0
  16. package/dist/delegation-status-BlsbSeOB.js +358 -0
  17. package/dist/delegation-status-BlsbSeOB.js.map +1 -0
  18. package/dist/durable.d.ts +2 -2
  19. package/dist/durable.js +3 -3
  20. package/dist/{environment-provider-DEwsolvi.js → environment-provider-Dr-wfnHg.js} +422 -8
  21. package/dist/environment-provider-Dr-wfnHg.js.map +1 -0
  22. package/dist/{environment-provider-DpPGJfK-.d.ts → environment-provider-adVa6X7a.d.ts} +2 -2
  23. package/dist/environment-provider.d.ts +1 -1
  24. package/dist/environment-provider.js +1 -1
  25. package/dist/{graph-DORfp9WX.js → graph-DghidDx5.js} +138 -5
  26. package/dist/graph-DghidDx5.js.map +1 -0
  27. package/dist/graph.d.ts +3 -3
  28. package/dist/graph.js +4 -5
  29. package/dist/graph.js.map +1 -1
  30. package/dist/{improve-Bn1zpWHF.d.ts → improve-7VTwse1c.d.ts} +6 -6
  31. package/dist/{improvement-cycle-BbsiYcpH.js → improvement-cycle-bTBySunH.js} +22 -8
  32. package/dist/{improvement-cycle-BbsiYcpH.js.map → improvement-cycle-bTBySunH.js.map} +1 -1
  33. package/dist/{index-Vz-13VZq.d.ts → index-CVD30soi.d.ts} +4 -4
  34. package/dist/{index-DV1lzp9p.d.ts → index-DNx0nWZH.d.ts} +57 -51
  35. package/dist/{index-RM2oRI9s.d.ts → index-DO6DHgRP.d.ts} +2 -2
  36. package/dist/index.d.ts +10 -9
  37. package/dist/index.js +75 -29
  38. package/dist/index.js.map +1 -1
  39. package/dist/intelligence.d.ts +5 -5
  40. package/dist/intelligence.js +7 -6
  41. package/dist/intelligence.js.map +1 -1
  42. package/dist/{executable-spec-DxuiDFAU.js → jsonl-file-Bh1Q9nt0.js} +59 -3
  43. package/dist/jsonl-file-Bh1Q9nt0.js.map +1 -0
  44. package/dist/kernel.d.ts +6 -6
  45. package/dist/kernel.js +11 -12
  46. package/dist/{knowledge-RW1pbZCH.js → knowledge-U8WJ5xCI.js} +7 -17
  47. package/dist/knowledge-U8WJ5xCI.js.map +1 -0
  48. package/dist/knowledge.d.ts +1 -1
  49. package/dist/knowledge.js +1 -1
  50. package/dist/{loop-runner-bin-sBwcyQTc.js → loop-runner-bin-BU2NACsF.js} +3 -3
  51. package/dist/{loop-runner-bin-sBwcyQTc.js.map → loop-runner-bin-BU2NACsF.js.map} +1 -1
  52. package/dist/{loop-runner-bin-CGraqNiA.d.ts → loop-runner-bin-b4585v9Z.d.ts} +3 -3
  53. package/dist/loop-runner-bin.d.ts +1 -1
  54. package/dist/loop-runner-bin.js +1 -1
  55. package/dist/{materialization-CekWK6OO.js → materialization-vZssF9Nx.js} +28 -3
  56. package/dist/materialization-vZssF9Nx.js.map +1 -0
  57. package/dist/mcp/bin.js +3 -3
  58. package/dist/mcp/index.d.ts +4 -4
  59. package/dist/mcp/index.js +8 -8
  60. package/dist/mcp/index.js.map +1 -1
  61. package/dist/{openai-tools-6jUqkGG7.js → openai-tools-DmvmaG0a.js} +2 -2
  62. package/dist/{openai-tools-6jUqkGG7.js.map → openai-tools-DmvmaG0a.js.map} +1 -1
  63. package/dist/{prepare-B5fJ7mLS.js → prepare-DDGp0-rW.js} +4 -59
  64. package/dist/prepare-DDGp0-rW.js.map +1 -0
  65. package/dist/primeintellect/index.d.ts +1 -1
  66. package/dist/profiles.js +454 -1
  67. package/dist/profiles.js.map +1 -1
  68. package/dist/{protected-model-port-B0xFSAjt.js → protected-model-port-DxFN8DLS.js} +3 -2
  69. package/dist/{protected-model-port-B0xFSAjt.js.map → protected-model-port-DxFN8DLS.js.map} +1 -1
  70. package/dist/{protected-redaction--F3v1oo8.js → protected-redaction-wGo44k2K.js} +54 -3
  71. package/dist/protected-redaction-wGo44k2K.js.map +1 -0
  72. package/dist/{provision-supervisor-CddfH9mg.js → provision-supervisor-CRPbnJiB.js} +6 -8
  73. package/dist/{provision-supervisor-CddfH9mg.js.map → provision-supervisor-CRPbnJiB.js.map} +1 -1
  74. package/dist/{redact-D0OzQsyt.js → redact-BOU77QfQ.js} +1013 -24
  75. package/dist/redact-BOU77QfQ.js.map +1 -0
  76. package/dist/{runtime-V91N6sPc.d.ts → runtime-B8x43nGP.d.ts} +5 -4
  77. package/dist/{runtime-ZM4i-jEF.js → runtime-CuNJ0opC.js} +153 -77
  78. package/dist/runtime-CuNJ0opC.js.map +1 -0
  79. package/dist/server-D6XmE1Du.js +1311 -0
  80. package/dist/server-D6XmE1Du.js.map +1 -0
  81. package/dist/{stream-agent-turn-1ahpdeIo.d.ts → stream-agent-turn-B-gtBlOy.d.ts} +2 -2
  82. package/dist/{stream-agent-turn-DWWe_7bh.js → stream-agent-turn-DOtEsvCV.js} +3 -3
  83. package/dist/{stream-agent-turn-DWWe_7bh.js.map → stream-agent-turn-DOtEsvCV.js.map} +1 -1
  84. package/dist/{structural-rollout-CktnUTCC.js → structural-rollout-DxEQ77H7.js} +37 -51
  85. package/dist/structural-rollout-DxEQ77H7.js.map +1 -0
  86. package/dist/{supervise-Dj6zd2C7.js → supervise-C0V3pZXK.js} +154 -1961
  87. package/dist/supervise-C0V3pZXK.js.map +1 -0
  88. package/dist/testing.d.ts +2 -2
  89. package/dist/testing.js +14 -13
  90. package/dist/testing.js.map +1 -1
  91. package/dist/tui/index.d.ts +1 -1
  92. package/dist/tui/index.js +1 -1
  93. package/dist/{types-CGez_ZHQ.d.ts → types-B_pNTBjK.d.ts} +5 -2
  94. package/dist/{workspace-archive-yAPDklLV.js → workspace-archive-Ybomp7AN.js} +3 -2
  95. package/dist/{workspace-archive-yAPDklLV.js.map → workspace-archive-Ybomp7AN.js.map} +1 -1
  96. package/package.json +4 -4
  97. package/skills/agent-graphs/SKILL.md +28 -123
  98. package/skills/agent-graphs/references/authoring.md +34 -0
  99. package/skills/agent-graphs/references/measurement.md +18 -0
  100. package/skills/build-with-agent-runtime/SKILL.md +31 -117
  101. package/skills/build-with-agent-runtime/references/improvement.md +32 -0
  102. package/skills/codemode/SKILL.md +22 -34
  103. package/skills/codemode/references/runtime-execution.md +14 -0
  104. package/skills/generate-eval/SKILL.md +2 -1
  105. package/skills/loop-writer/SKILL.md +30 -84
  106. package/skills/supervise/SKILL.md +43 -77
  107. package/skills/supervise/references/profile-authoring.md +19 -0
  108. package/dist/authoring-DWiqKSDY.js.map +0 -1
  109. package/dist/coordination-driver-DujHiIGa.js.map +0 -1
  110. package/dist/environment-provider-DEwsolvi.js.map +0 -1
  111. package/dist/executable-spec-DxuiDFAU.js.map +0 -1
  112. package/dist/graph-DORfp9WX.js.map +0 -1
  113. package/dist/jsonl-file-CDfsCI5s.js +0 -59
  114. package/dist/jsonl-file-CDfsCI5s.js.map +0 -1
  115. package/dist/knowledge-RW1pbZCH.js.map +0 -1
  116. package/dist/materialization-CekWK6OO.js.map +0 -1
  117. package/dist/prepare-B5fJ7mLS.js.map +0 -1
  118. package/dist/protected-redaction--F3v1oo8.js.map +0 -1
  119. package/dist/redact-D0OzQsyt.js.map +0 -1
  120. package/dist/researcher-hgPa5p9i.js +0 -457
  121. package/dist/researcher-hgPa5p9i.js.map +0 -1
  122. package/dist/runtime-ZM4i-jEF.js.map +0 -1
  123. package/dist/snapshot-CTAf4uuA.js +0 -26
  124. package/dist/snapshot-CTAf4uuA.js.map +0 -1
  125. package/dist/spawn-journal-B9eTmVAn.js +0 -999
  126. package/dist/spawn-journal-B9eTmVAn.js.map +0 -1
  127. package/dist/structural-rollout-CktnUTCC.js.map +0 -1
  128. package/dist/supervise-Dj6zd2C7.js.map +0 -1
  129. package/dist/util-mCNUeboW.js +0 -419
  130. package/dist/util-mCNUeboW.js.map +0 -1
  131. package/skills/agent-graphs/IMPROVE.md +0 -58
@@ -1,6 +1,6 @@
1
1
  import { E as SandboxClient, at as RuntimeStreamEvent, i as ExecCtx, k as Validator } from "./types-BdolQ6Zi.js";
2
- import { B as Scope, _ as ExecutorRegistry, _n as TraceSource, a as DefaultVerdict, b as ExecutorToolCall, g as ExecutorProgressEvent, it as UsageEvent, l as ExecutorCancellation, p as ExecutorFactory, q as Spend, u as ExecutorCancellationRequest, wn as ExecutorProgress } from "./types-CGez_ZHQ.js";
3
- import { i as AgentEnvironmentProvider, o as AgentEnvironmentProviderRegistry, w as ProviderExecutorOptions } from "./environment-provider-DpPGJfK-.js";
2
+ import { B as Scope, _ as ExecutorRegistry, _n as TraceSource, a as DefaultVerdict, b as ExecutorToolCall, g as ExecutorProgressEvent, it as UsageEvent, l as ExecutorCancellation, p as ExecutorFactory, q as Spend, u as ExecutorCancellationRequest, wn as ExecutorProgress } from "./types-B_pNTBjK.js";
3
+ import { i as AgentEnvironmentProvider, o as AgentEnvironmentProviderRegistry, w as ProviderExecutorOptions } from "./environment-provider-adVa6X7a.js";
4
4
  import { AgentProfile, AgentProfileMcpServer, HarnessType, ReasoningEffort, StreamEvent } from "@tangle-network/agent-interface";
5
5
  import { WorkspacePlanReceipt } from "@tangle-network/agent-profile-materialize";
6
6
  import { ChildProcess } from "node:child_process";
@@ -415,7 +415,8 @@ interface RunLocalHarnessOptions {
415
415
  /** Absolute host paths that reproducible Codex must not read. The normalized set is compiled
416
416
  * into the controlled permission profile and its digest is returned in execution evidence. */
417
417
  codexReadDeniedPaths?: ReadonlyArray<string>;
418
- /** Wall-clock kill deadline (ms). Default 5 min. Subprocess SIGTERMed on expiry. */
418
+ /** Optional wall-clock kill deadline (ms). Omit it for no timer. A positive value sends
419
+ * SIGTERM on expiry. */
419
420
  timeoutMs?: number;
420
421
  /** Newest stdout/stderr bytes retained per stream. Default 64 MiB. */
421
422
  maxOutputBytes?: number;
@@ -1692,4 +1693,4 @@ declare function createExecutor(config: ExecutorConfig): ExecutorFactory<unknown
1692
1693
  declare function createExecutorRegistry(): ExecutorRegistry;
1693
1694
  //#endregion
1694
1695
  export { CodexRolloutTurn as $, PeerMailboxOptions as $t, SandboxToolPartState as A, localHarnessExecutable as At, sumSandboxUsage as B, ToolLoopToolCall as Bt, Inbox as C, CodexTokenUsage as Ct, SandboxLeafOut as D, LocalHarnessResult as Dt, createInbox as E, LocalHarness as Et, extractLlmCallEvent as F, ToolLoopCallContext as Ft, resolveMcpServerLaunch as G, PeerMailEvent as Gt, ResolvedMcpServerLaunch as H, DEFAULT_PEER_MAIL_LIMITS as Ht, mapSandboxEvent as I, ToolLoopChat as It, CodexForkBoundary as J, PeerMailOutcome as Jt, resolveSecretEnv as K, PeerMailKind as Kt, mapSandboxToolEvent as L, ToolLoopCompaction as Lt, assertSandboxServedModel as M, runLocalHarness as Mt, createSandboxToolPartState as N, RouterTransportConfig as Nt, SandboxOutputMarker as O, RunLocalHarnessOptions as Ot, createSandboxUsageLedger as P, ToolSpec as Pt, CodexRolloutStoreRef as Q, PeerMailbox as Qt, sandboxEventServedBackend as R, ToolLoopCompactionOptions as Rt, AuthorityInboxMessage as S, CodexExecutionPolicy as St, PeerInboxMessage as T, LOCAL_HARNESSES as Tt, envKeyProvider as U, PEER_MAIL_WIRE_KEY as Ut, KeyProvider as V, AUTHORITY_MARKERS as Vt, mcpSecretEnvMetadataKey as W, PeerMailEnvelope as Wt, CodexRolloutSession as X, PeerMailRefusal as Xt, CodexRolloutIdentity as Y, PeerMailReadout as Yt, CodexRolloutStoreReader as Z, PeerMailSendInput as Zt, DEFAULT_SANDBOX_STEERING_MAX_TURNS as _, WorktreeHandle as _t, CliSeam as a, JsonRpcMessage as an, HarnessUsage as at, SteerableSandboxSession as b, removeWorktree as bt, ExecutorConfig as c, McpTransport as cn, WorktreeCheckRunner as ct, RouterToolsSeam as d, WorktreeProfileMaterializationReceipt as dt, claimsAuthority as en, CodexStoreDelta as et, SandboxSeam as f, CreateWorktreeOptions as ft, createExecutorRegistry as g, RemoveWorktreeOptions as gt, createExecutor as h, GitRunner as ht, CliInPlaceSeam as i, peerMailVerbNames as in, readCodexRolloutSession as it, SandboxUsageLedger as j, parseCodexTokenUsage as jt, SandboxServedBackend as k, harnessSupportsReasoningEffort as kt, ProviderSeam as l, WorktreeCommandResult as lt, cliWorktreeExecutor as m, DiffResult as mt, BridgeModelCredential as n, isPeerMailEnvelope as nn, createCodexRolloutStoreReader as nt, CliWorktreeBridgeSeam as o, JsonRpcResponse as on, decodeHarnessUsage as ot, cliInPlaceExecutor as p, DiffOptions as pt, secretEnvOfMcpServer as q, PeerMailLimits as qt, BridgeSeam as r, peerMailTools as rn, harnessUsageIsEmpty as rt, CliWorktreeSeam as s, McpToolDescriptor as sn, InPlaceHarnessResult as st, BridgeHarnessStore as t, createPeerMailbox as tn, addHarnessUsage as tt, RouterSeam as u, WorktreeHarnessResult as ut, SandboxSteeringOptions as v, captureWorktreeDiff as vt, InboxMessage as w, DEFAULT_LOCAL_HARNESS as wt, createSteerableSandboxSession as x, CodexExecutionEvidence as xt, SteerableSandboxArgs as y, createWorktree as yt, sandboxProgressEvents as z, ToolLoopMessageRecord as zt };
1695
- //# sourceMappingURL=runtime-V91N6sPc.d.ts.map
1696
+ //# sourceMappingURL=runtime-B8x43nGP.d.ts.map
@@ -1,23 +1,21 @@
1
+ import { E as detachedFrozen } from "./materialization-vZssF9Nx.js";
1
2
  import { m as ValidationError, n as AnalystError, s as PlannerError } from "./errors-CDZ8XsVj.js";
2
- import "./stream-agent-turn-DWWe_7bh.js";
3
- import { i as InMemorySpawnJournal, r as InMemoryResultBlobStore, s as insideCursorNamespace, v as isTraceAnalysisStore, x as contentAddress } from "./spawn-journal-B9eTmVAn.js";
4
- import { b as zeroSpend, c as isAbortError, d as randomSuffix, h as stringifySafe, i as cloneSpend, m as sleep, r as chargedTokens, s as hasCompleteCacheBreakdown, t as addSpend } from "./util-mCNUeboW.js";
5
- import { i as writeAllBytes, n as parseCommittedJsonLines, r as prepareJsonlAppend, t as isNoEntError } from "./jsonl-file-CDfsCI5s.js";
6
- import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction--F3v1oo8.js";
3
+ import "./stream-agent-turn-DOtEsvCV.js";
4
+ import { f as sha256Bytes, i as redactProtectedValue, o as canonicalCandidateDigest$1, r as redactProtectedReason, u as immutableCandidateValue } from "./protected-redaction-wGo44k2K.js";
7
5
  import { l as notifySandboxEventObserver } from "./sandbox-events-DWeQRWxg.js";
8
- import { n as executableAgentSpecSnapshot, t as executableAgentProfileSnapshot } from "./executable-spec-DxuiDFAU.js";
6
+ import { a as executableAgentProfileSnapshot, i as writeAllBytes, n as parseCommittedJsonLines, o as executableAgentSpecSnapshot, r as prepareJsonlAppend, t as isNoEntError } from "./jsonl-file-Bh1Q9nt0.js";
9
7
  import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, t as assertExecutableAgentProfile } from "./model-policy-Wf2MxXJ9.js";
10
- import { C as settledToIteration, Gt as probeSandboxCapabilities, Jt as readPromptOptions, Ut as runAgentRounds, Vt as defaultSelectWinner, Wt as createSandboxLineage, Xt as runBrainLoop, Y as rollingDispatch, Yt as routerBrain, Zt as canonicalObservedModelParts, a as createSupervisor, bt as createPushTraceSource, ft as createWorktreeCliExecutor, h as withDriverExecutor, lt as createExecutor, qt as assertBoxlessPromptOptions, ut as createExecutorRegistry } from "./redact-D0OzQsyt.js";
11
- import "./environment-provider-DEwsolvi.js";
8
+ import { C as settledToIteration, Ht as InMemorySpawnJournal, Vt as InMemoryResultBlobStore, Wt as insideCursorNamespace, Y as rollingDispatch, Zt as isTraceAnalysisStore, a as createSupervisor, an as runAgentRounds, bt as createPushTraceSource, dn as routerBrain, en as contentAddress, fn as runBrainLoop, ft as createWorktreeCliExecutor, h as withDriverExecutor, ln as assertBoxlessPromptOptions, lt as createExecutor, on as createSandboxLineage, pn as canonicalObservedModelParts, rn as defaultSelectWinner, sn as probeSandboxCapabilities, un as readPromptOptions, ut as createExecutorRegistry } from "./redact-BOU77QfQ.js";
9
+ import { E as zeroSpend, _ as randomSuffix, b as sleep, l as chargedTokens, m as isAbortError, p as hasCompleteCacheBreakdown, s as addSpend, u as cloneSpend, x as stringifySafe } from "./environment-provider-Dr-wfnHg.js";
12
10
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
13
- import { C as observe, O as strategyAuthorMethod, T as profileChatClient, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-CktnUTCC.js";
14
- import "./coordination-driver-DujHiIGa.js";
15
- import { n as supervise, vt as gateOnDeliverable, yt as mapExecutorResult } from "./supervise-Dj6zd2C7.js";
11
+ import { C as observe, O as strategyAuthorMethod, T as profileChatClient, b as sample, v as refine, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-DxEQ77H7.js";
12
+ import { b as mapExecutorResult, n as supervise, y as gateOnDeliverable } from "./supervise-C0V3pZXK.js";
13
+ import "./coordination-driver-iSN-m3VX.js";
16
14
  import "./run-layout-B8I_LXN-.js";
17
- import "./provision-supervisor-CddfH9mg.js";
15
+ import "./provision-supervisor-CRPbnJiB.js";
18
16
  import { t as assertAuthoredCode } from "./authored-code-DzYtiflw.js";
19
- import "./authoring-DWiqKSDY.js";
20
- import "./graph-DORfp9WX.js";
17
+ import "./delegate-DCC2muUd.js";
18
+ import "./graph-DghidDx5.js";
21
19
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
22
20
  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";
23
21
  import { createHash, randomUUID } from "node:crypto";
@@ -30,6 +28,7 @@ import { tmpdir } from "node:os";
30
28
  import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
31
29
  import { collectAgentResponseText } from "@tangle-network/sandbox";
32
30
  import { createInterface } from "node:readline";
31
+ import { pathToFileURL } from "node:url";
33
32
  import { gzipSync } from "node:zlib";
34
33
  import { createContext, runInContext } from "node:vm";
35
34
  import { stuckLoopView, toolWasteView } from "@tangle-network/agent-eval/pipelines";
@@ -2699,23 +2698,25 @@ function applyFilter(records, filter) {
2699
2698
  var InMemoryCorpus = class {
2700
2699
  byId = /* @__PURE__ */ new Map();
2701
2700
  async append(record) {
2701
+ let snapshot;
2702
2702
  try {
2703
2703
  assertCorpusRecord(record, "append: record");
2704
+ snapshot = detachedFrozen(record);
2704
2705
  } catch (err) {
2705
2706
  return {
2706
2707
  succeeded: false,
2707
2708
  error: err instanceof Error ? err.message : String(err)
2708
2709
  };
2709
2710
  }
2710
- const existing = this.byId.get(record.id);
2711
+ const existing = this.byId.get(snapshot.id);
2711
2712
  if (existing) {
2712
- if (recordsEqual(existing, record)) return { succeeded: true };
2713
+ if (recordsEqual(existing, snapshot)) return { succeeded: true };
2713
2714
  return {
2714
2715
  succeeded: false,
2715
2716
  error: `corpus conflict: id '${record.id}' is already stored with a different record; a learned fact is append-only — re-mint the id or reconcile before re-appending`
2716
2717
  };
2717
2718
  }
2718
- this.byId.set(record.id, freeze(record));
2719
+ this.byId.set(snapshot.id, snapshot);
2719
2720
  return { succeeded: true };
2720
2721
  }
2721
2722
  async query(filter) {
@@ -2740,40 +2741,51 @@ var FileCorpus = class {
2740
2741
  async append(record) {
2741
2742
  try {
2742
2743
  assertCorpusRecord(record, "append: record");
2744
+ const snapshot = detachedFrozen(record);
2745
+ const fs = await import("node:fs/promises");
2746
+ const { dirname } = await import("node:path");
2747
+ const { tryAcquireAtomicFileLock } = await import("@tangle-network/agent-eval/ledger-core");
2748
+ await fs.mkdir(dirname(this.path), { recursive: true });
2749
+ await (await fs.open(this.path, "a")).close();
2750
+ const canonicalPath = await fs.realpath(this.path);
2751
+ const deadline = Date.now() + 5e3;
2752
+ for (;;) {
2753
+ const acquisition = tryAcquireAtomicFileLock({ lockPath: `${canonicalPath}.lock` });
2754
+ if (!acquisition.acquired) {
2755
+ if (Date.now() >= deadline) throw new Error(`corpus append lock unavailable after 5000ms: ${canonicalPath}`);
2756
+ await new Promise((resolve) => setTimeout(resolve, 25));
2757
+ continue;
2758
+ }
2759
+ try {
2760
+ const existing = (await this.load(canonicalPath)).get(snapshot.id);
2761
+ if (existing) {
2762
+ if (recordsEqual(existing, snapshot)) return { succeeded: true };
2763
+ return {
2764
+ succeeded: false,
2765
+ error: `corpus conflict: id '${snapshot.id}' is already stored in ${canonicalPath} with a different record; a learned fact is append-only — re-mint the id or reconcile before re-appending`
2766
+ };
2767
+ }
2768
+ await this.appendLine(canonicalPath, snapshot);
2769
+ return { succeeded: true };
2770
+ } finally {
2771
+ acquisition.lock.release();
2772
+ }
2773
+ }
2743
2774
  } catch (err) {
2744
2775
  return {
2745
2776
  succeeded: false,
2746
2777
  error: err instanceof Error ? err.message : String(err)
2747
2778
  };
2748
2779
  }
2749
- let stored;
2750
- try {
2751
- stored = await this.load();
2752
- } catch (err) {
2753
- return {
2754
- succeeded: false,
2755
- error: err instanceof Error ? err.message : String(err)
2756
- };
2757
- }
2758
- const existing = stored.get(record.id);
2759
- if (existing) {
2760
- if (recordsEqual(existing, record)) return { succeeded: true };
2761
- return {
2762
- succeeded: false,
2763
- error: `corpus conflict: id '${record.id}' is already stored in ${this.path} with a different record; a learned fact is append-only — re-mint the id or reconcile before re-appending`
2764
- };
2765
- }
2766
- await this.appendLine(record);
2767
- return { succeeded: true };
2768
2780
  }
2769
2781
  async query(filter) {
2770
2782
  return applyFilter([...(await this.load()).values()], filter);
2771
2783
  }
2772
- async load() {
2784
+ async load(path = this.path) {
2773
2785
  const fs = await import("node:fs/promises");
2774
2786
  let text;
2775
2787
  try {
2776
- text = await fs.readFile(this.path, "utf8");
2788
+ text = await fs.readFile(path, "utf8");
2777
2789
  } catch (err) {
2778
2790
  if (isNoEntError(err)) return /* @__PURE__ */ new Map();
2779
2791
  throw err;
@@ -2785,16 +2797,14 @@ var FileCorpus = class {
2785
2797
  assertCorpusRecord(parsed, `corpus ${this.path} line ${i + 1}`);
2786
2798
  const existing = byId.get(parsed.id);
2787
2799
  if (existing && !recordsEqual(existing, parsed)) throw new Error(`corpus corrupted: ${this.path} has two different records for id '${parsed.id}'; an append-only corpus must never hold a conflicting re-append under one id`);
2788
- byId.set(parsed.id, freeze(parsed));
2800
+ byId.set(parsed.id, detachedFrozen(parsed));
2789
2801
  }
2790
2802
  return byId;
2791
2803
  }
2792
- async appendLine(record) {
2804
+ async appendLine(path, record) {
2793
2805
  const fs = await import("node:fs/promises");
2794
- const path = await import("node:path");
2795
- await fs.mkdir(path.dirname(this.path), { recursive: true });
2796
- const needsSeparator = await prepareJsonlAppend(this.path);
2797
- const fh = await fs.open(this.path, "a");
2806
+ const needsSeparator = await prepareJsonlAppend(path);
2807
+ const fh = await fs.open(path, "a");
2798
2808
  try {
2799
2809
  await writeAllBytes(fh, `${needsSeparator ? "\n" : ""}${JSON.stringify(record)}\n`);
2800
2810
  await fh.sync();
@@ -2846,9 +2856,6 @@ async function renderCorpusToInstructions(opts) {
2846
2856
  function renderLine(record) {
2847
2857
  return record.rationale ? `${record.claim} (${record.rationale})` : record.claim;
2848
2858
  }
2849
- function freeze(record) {
2850
- return Object.freeze({ ...record });
2851
- }
2852
2859
  //#endregion
2853
2860
  //#region src/runtime/personify/registry.ts
2854
2861
  /**
@@ -4032,9 +4039,10 @@ function errorMessage(error) {
4032
4039
  * optimization strategy as code; the caller gates it like any human-built candidate
4033
4040
  * (runBenchmark + a frozen holdout).
4034
4041
  *
4035
- * Structurally safe by construction: the authored body composes shot()/critique() and
4036
- * spends through the Supervisor's conserved pool it can be wrong, but it cannot
4037
- * Goodhart the check (it never sees the verifiers) and it cannot win by overspending.
4042
+ * Brokered shot()/critique() calls spend through the Supervisor's conserved pool.
4043
+ * Source validation checks obvious forbidden operations; it is not an execution sandbox.
4044
+ * Code that uses other execution paths can access state or spend outside that pool.
4045
+ * Callers must provide isolation when authored code requires an enforced boundary.
4038
4046
  *
4039
4047
  * The authored module is written to `outDir` and dynamically imported — run under a
4040
4048
  * TS-capable loader (tsx) since models often emit type annotations.
@@ -4044,16 +4052,20 @@ const strategyAuthorContract = `
4044
4052
  You author an OPTIMIZATION STRATEGY for an agentic loop system. A strategy decides how to
4045
4053
  spend a compute budget to beat a task's deployable check. You compose exactly two steps:
4046
4054
 
4047
- shot(spec?: { handle?, messages?, steer?, persona?, tools? }): Promise<ShotResult | null>
4055
+ shot(spec?: { handle?, messages?, steer?, profile?, tools? }): Promise<ShotResult | null>
4048
4056
  Runs ONE worker attempt (a bounded tool loop) over an artifact.
4049
4057
  - omit handle => the shot opens its OWN fresh artifact and closes it after (a sample).
4050
4058
  - pass handle => the shot CONTINUES that artifact (state accumulates across shots).
4051
4059
  - messages => the carried conversation (pass the previous ShotResult.messages to continue).
4052
4060
  - steer => a corrective instruction injected before the shot.
4053
- - persona => { systemPrompt?, model? } — give THIS shot its own role and/or model
4054
- (multi-agent strategies: a researcher shot then an engineer shot, a panel of k
4055
- personas over one budget). On a fresh shot the systemPrompt replaces the task's; on
4056
- a carried conversation it arrives as a hand-off message. Same conserved budget.
4061
+ - profile => a complete AgentProfile — give THIS shot its own instructions,
4062
+ model, skills, tools, hooks, and subagents. Include name, harness, and
4063
+ model: { provider, default }; put standing instructions in prompt.systemPrompt.
4064
+ For example: { ...opts.workerProfile, name: 'researcher',
4065
+ prompt: { ...opts.workerProfile.prompt,
4066
+ systemPrompt: 'Inspect the evidence before proposing a change.' } }.
4067
+ Choose an available model from the current execution setup. Omit profile to use
4068
+ the worker's exact profile. Every shot spends from the same conserved budget.
4057
4069
  - tools => string[] — restrict THIS shot to a subset of the task's tools by
4058
4070
  name (focus an explore shot on read-only tools, an execute shot on write tools).
4059
4071
  Restriction-only; unknown names make the shot fail. ALWAYS select from
@@ -4091,7 +4103,7 @@ Rules:
4091
4103
  - The module must be EXACTLY this shape (no other imports, no commentary outside code):
4092
4104
 
4093
4105
  import { defineStrategy } from '@tangle-network/agent-runtime/kernel'
4094
- export default defineStrategy('your-strategy-name', async ({ surface, task, budget, shot, critique, listTools }) => {
4106
+ export default defineStrategy('your-strategy-name', async ({ surface, task, opts, budget, shot, critique, listTools }) => {
4095
4107
  // your composition (listTools comes from the destructured context — it is NOT a global)
4096
4108
  })
4097
4109
  `;
@@ -4285,23 +4297,66 @@ async function runStrategyEvolution(cfg) {
4285
4297
  const epsilon = cfg.championEpsilon ?? (cfg.objective === "cost" ? cfg.scoreTolerance ?? .05 : .01);
4286
4298
  const byName = new Map(baselines.map((s) => [s.name, s]));
4287
4299
  const codeByName = /* @__PURE__ */ new Map();
4288
- const fingerprint = {
4300
+ for (const [label, count] of Object.entries({
4301
+ trainN: cfg.trainN,
4302
+ holdoutN: cfg.holdoutN
4303
+ })) if (!Number.isSafeInteger(count) || count < 1) throw new Error(`evolution: ${label} must be a positive integer`);
4304
+ const holdoutOffset = cfg.holdoutOffset ?? 0;
4305
+ if (!Number.isSafeInteger(holdoutOffset) || holdoutOffset < 0) throw new Error("evolution: holdoutOffset must be a non-negative integer");
4306
+ if (baselines.length === 0 || byName.size !== baselines.length) throw new Error("evolution: baselines must have non-empty, unique names");
4307
+ if (cfg.checkpoint && !/^sha256:[0-9a-f]{64}$/.test(cfg.checkpoint.executionRef)) throw new Error("evolution checkpoint: executionRef must be a lowercase sha256:<64 hex> digest");
4308
+ const fingerprint = cfg.checkpoint ? canonicalCandidateDigest$1({
4309
+ schemaVersion: 2,
4310
+ executionRef: cfg.checkpoint?.executionRef ?? null,
4311
+ environment: cfg.environment.name,
4289
4312
  trainN: cfg.trainN,
4290
4313
  holdoutN: cfg.holdoutN,
4314
+ holdoutOffset,
4291
4315
  budget,
4316
+ concurrency,
4292
4317
  generations,
4293
- populationSize
4294
- };
4318
+ populationSize,
4319
+ baselines: baselines.map((baseline) => baseline.name),
4320
+ objective: cfg.objective ?? "score",
4321
+ scoreTolerance: cfg.scoreTolerance ?? .05,
4322
+ champion: policy,
4323
+ championEpsilon: epsilon,
4324
+ minPairedTasks: cfg.minPairedTasks ?? null,
4325
+ band: cfg.band ?? null,
4326
+ lossesDetail: cfg.lossesDetail ?? "exact",
4327
+ reproducerCheck: cfg.reproducerCheck ?? null,
4328
+ modelPreflight: cfg.modelPreflight !== false,
4329
+ modelPreflightTimeoutMs: cfg.modelPreflightTimeoutMs ?? null,
4330
+ worker: {
4331
+ routerBaseUrl: cfg.worker.routerBaseUrl,
4332
+ profile: cfg.worker.workerProfile,
4333
+ analystProfile: cfg.worker.analystProfile ?? cfg.worker.workerProfile,
4334
+ corpusTags: cfg.worker.corpusTags ?? [],
4335
+ corpusReadback: cfg.worker.corpusReadback ?? null
4336
+ },
4337
+ author: {
4338
+ profile: cfg.author.profile,
4339
+ fallbackProfile: cfg.author.fallbackProfile ?? null,
4340
+ executorBackend: cfg.author.executor.backend
4341
+ },
4342
+ authorContract: strategyAuthorContract
4343
+ }) : void 0;
4295
4344
  let ckpt;
4296
4345
  if (cfg.checkpoint?.resume && existsSync(cfg.checkpoint.path)) {
4297
4346
  const raw = JSON.parse(readFileSync(cfg.checkpoint.path, "utf8"));
4298
- if (JSON.stringify(raw.fingerprint) !== JSON.stringify(fingerprint)) throw new Error(`evolution resume: checkpoint design mismatch checkpoint ${JSON.stringify(raw.fingerprint)} vs config ${JSON.stringify(fingerprint)}; delete ${cfg.checkpoint.path} or match the config`);
4347
+ if (raw.fingerprint !== fingerprint) throw new Error(`evolution resume: checkpoint design mismatch at ${cfg.checkpoint.path}; use a new checkpoint or restore the original execution dependencies`);
4299
4348
  ckpt = raw;
4300
4349
  }
4350
+ const train = checkedTaskSlice(await cfg.tasks(0, cfg.trainN), cfg.trainN, "train", !!cfg.checkpoint);
4351
+ const trainDigest = cfg.checkpoint ? canonicalCandidateDigest$1(train) : void 0;
4352
+ if (ckpt && ckpt.trainDigest !== trainDigest) throw new Error("evolution resume: train task payloads changed");
4353
+ let holdoutPoolDigest;
4301
4354
  const save = (state) => {
4302
4355
  if (cfg.checkpoint) writeFileSync(cfg.checkpoint.path, JSON.stringify({
4303
4356
  ...state,
4304
- fingerprint
4357
+ fingerprint,
4358
+ trainDigest,
4359
+ holdoutPoolDigest
4305
4360
  }, null, 1));
4306
4361
  };
4307
4362
  let modelsPreflighted = false;
@@ -4322,7 +4377,6 @@ async function runStrategyEvolution(cfg) {
4322
4377
  modelsPreflighted = true;
4323
4378
  return report;
4324
4379
  };
4325
- const train = await cfg.tasks(0, cfg.trainN);
4326
4380
  const probeTask = train[0];
4327
4381
  if (!probeTask) throw new Error("runStrategyEvolution: empty train slice");
4328
4382
  const probe = await cfg.environment.open(probeTask);
@@ -4349,11 +4403,16 @@ async function runStrategyEvolution(cfg) {
4349
4403
  usd: gen0Champion.usd
4350
4404
  }];
4351
4405
  for (const row of generationRows) for (const c of row.candidates) {
4352
- if (!c.file || c.error) continue;
4353
- const mod = await import(`file://${c.file}`);
4406
+ if (c.error) continue;
4407
+ if (!c.file || !c.sourceSha256) throw new Error(`evolution resume: missing source identity for '${c.name}'`);
4408
+ const bytes = readFileSync(c.file);
4409
+ if (sha256Bytes(bytes) !== c.sourceSha256) throw new Error(`evolution resume: authored source changed for '${c.name}' (${c.file})`);
4410
+ const sourceUrl = pathToFileURL(c.file);
4411
+ sourceUrl.searchParams.set("sha256", c.sourceSha256);
4412
+ const mod = await import(sourceUrl.href);
4354
4413
  if (!mod.default || typeof mod.default.driver !== "function") throw new Error(`evolution resume: ${c.file} no longer exports a Strategy — cannot restore "${c.name}"`);
4355
4414
  byName.set(c.name, renameStrategy(mod.default, c.name));
4356
- codeByName.set(c.name, readFileSync(c.file, "utf8"));
4415
+ codeByName.set(c.name, bytes.toString("utf8"));
4357
4416
  }
4358
4417
  let authoredOk = generationRows.reduce((n, row) => n + row.candidates.filter((c) => !c.error).length, 0);
4359
4418
  const lastRow = generationRows[generationRows.length - 1];
@@ -4401,6 +4460,7 @@ async function runStrategyEvolution(cfg) {
4401
4460
  candidates.push({
4402
4461
  name: unique,
4403
4462
  file: authored.file,
4463
+ sourceSha256: sha256Bytes(Buffer.from(authored.code)),
4404
4464
  gzipBits: gzipSync(Buffer.from(authored.code)).length * 8,
4405
4465
  codeChars: authored.code.length
4406
4466
  });
@@ -4448,13 +4508,17 @@ async function runStrategyEvolution(cfg) {
4448
4508
  });
4449
4509
  }
4450
4510
  if (authoredOk === 0) throw new Error("runStrategyEvolution: every author attempt failed across all generations — no search happened; see the candidates[].error entries");
4451
- const holdoutOffset = cfg.trainN + (cfg.holdoutOffset ?? 0);
4511
+ const poolN = cfg.band?.holdoutPoolN ?? cfg.holdoutN;
4512
+ const pool = checkedTaskSlice(await cfg.tasks(cfg.trainN + holdoutOffset, poolN), poolN, "holdout", !!cfg.checkpoint);
4513
+ const trainIds = new Set(train.map((task) => task.id));
4514
+ if (pool.some((task) => trainIds.has(task.id))) throw new Error("evolution: train and holdout task IDs must be disjoint");
4515
+ holdoutPoolDigest = cfg.checkpoint ? canonicalCandidateDigest$1(pool) : void 0;
4516
+ if (ckpt?.holdout && ckpt.holdoutPoolDigest !== holdoutPoolDigest) throw new Error("evolution resume: holdout task payloads changed");
4452
4517
  let holdoutTasks = [];
4453
4518
  let bandInfo;
4454
4519
  if (ckpt?.holdout && ckpt.verdict) {
4455
4520
  bandInfo = ckpt.band;
4456
4521
  if (cfg.reproducerCheck && codeByName.has(incumbent.name)) {
4457
- const pool = await cfg.tasks(holdoutOffset, cfg.band?.holdoutPoolN ?? cfg.holdoutN);
4458
4522
  const gateIds = new Set(ckpt.holdout.perTask.map((r) => r.taskId));
4459
4523
  holdoutTasks = pool.filter((t) => gateIds.has(t.id));
4460
4524
  }
@@ -4462,7 +4526,6 @@ async function runStrategyEvolution(cfg) {
4462
4526
  const maxRef = cfg.band.maxRefScore ?? .99;
4463
4527
  const reference = baselines[0];
4464
4528
  if (!reference) throw new Error("evolution band: baselines[0] required as the screening reference");
4465
- const pool = await cfg.tasks(holdoutOffset, cfg.band.holdoutPoolN);
4466
4529
  const refScores = (await bench("band-screen", pool, [reference])).perTask.filter((r) => r.cells?.[reference.name]).map((r) => ({
4467
4530
  taskId: r.taskId,
4468
4531
  score: r.cells?.[reference.name]?.score ?? 0
@@ -4476,7 +4539,7 @@ async function runStrategyEvolution(cfg) {
4476
4539
  inBand: kept.length,
4477
4540
  refScores
4478
4541
  };
4479
- } else holdoutTasks = await cfg.tasks(holdoutOffset, cfg.holdoutN);
4542
+ } else holdoutTasks = pool;
4480
4543
  let holdout;
4481
4544
  let verdict;
4482
4545
  if (ckpt?.holdout && ckpt.verdict) {
@@ -4576,6 +4639,15 @@ async function runStrategyEvolution(cfg) {
4576
4639
  trajectory
4577
4640
  };
4578
4641
  }
4642
+ function checkedTaskSlice(tasks, count, label, snapshot) {
4643
+ if (!Number.isSafeInteger(count) || count < 1 || tasks.length !== count) throw new Error(`evolution: ${label} must supply exactly ${count} tasks; received ${tasks.length}`);
4644
+ const ids = /* @__PURE__ */ new Set();
4645
+ for (const task of tasks) {
4646
+ if (typeof task.id !== "string" || !task.id.trim() || ids.has(task.id)) throw new Error(`evolution: ${label} task IDs must be non-empty and unique`);
4647
+ ids.add(task.id);
4648
+ }
4649
+ return snapshot ? immutableCandidateValue(tasks) : tasks;
4650
+ }
4579
4651
  //#endregion
4580
4652
  //#region src/runtime/supervise/chat-transport-executor.ts
4581
4653
  /**
@@ -4929,13 +5001,17 @@ function codeModeSupervisorTools(runner, options = {}) {
4929
5001
  if (context.signal.aborted) execution.abort(abortReason(context.signal));
4930
5002
  else context.signal.addEventListener("abort", onScopeAbort, { once: true });
4931
5003
  const bindings = {};
4932
- for (const [wire, member] of Object.entries(CODE_CALLABLE_VERBS)) bindings[wire] = async (args) => {
4933
- if (execution.signal.aborted) {
4934
- if (!timedOut) throw abortReason(execution.signal);
4935
- throw new ValidationError(`code mode: the execute deadline passed; api.${wire} is refused so no work outlives the call`);
4936
- }
4937
- return detach(await context.verbs[member](args));
4938
- };
5004
+ for (const face of faces(context)) {
5005
+ const member = CODE_CALLABLE_VERBS[face.name];
5006
+ if (member === void 0) continue;
5007
+ bindings[face.name] = async (args) => {
5008
+ if (execution.signal.aborted) {
5009
+ if (!timedOut) throw abortReason(execution.signal);
5010
+ throw new ValidationError(`code mode: the execute deadline passed; api.${face.name} is refused so no work outlives the call`);
5011
+ }
5012
+ return detach(await context.verbs[member](args));
5013
+ };
5014
+ }
4939
5015
  try {
4940
5016
  return await runner.run({
4941
5017
  code,
@@ -6360,4 +6436,4 @@ function tail(s) {
6360
6436
  //#endregion
6361
6437
  export { InMemoryCorpus as $, chatWorkerSeam as A, renderLeaderboardSvg as At, SandboxRunAbortError as B, mcpSecretEnvMetadataKey as Bt, withUntrackedArtifacts as C, deterministicCompletion as Ct, codeModeSupervisorTools as D, pairwiseSignificance as Dt, runCoderChecks as E, leaderboard as Et, selectChampion as F, connectStdioMcp as Ft, equalKOnCost as G, printBenchmarkReport as H, resolveSecretEnv as Ht, assertStrategyContract as I, materializeLocalMcp as It, runPersonified as J, trajectoryReport as K, authorStrategy as L, createMcpEnvironment as Lt, discriminatingMeans as M, auditIntent as Mt, pickChampion as N, defaultAuditorInstruction as Nt, unsafeInProcessRunner as O, renderLeaderboardHtml as Ot, runStrategyEvolution as P, McpSpawnFault as Pt, FileCorpus as Q, strategyAuthorContract as R, sanitizeMcpToolSchema as Rt, copyUntrackedIntoClone as S, completionAuthorizes as St, patchDelivered as T, stopSentinel as Tt, runBenchmark as U, secretEnvOfMcpServer as Ut, openSandboxRun as V, resolveMcpServerLaunch as Vt, promotionGate as W, createShapeRegistry as X, builtinShapes as Y, registerShape as Z, NOTE_MAX_CHARS as _, localSandboxClient as _t, localShell as a, pipeline as at, composeWorkerEvidence as b, loopDispatch as bt, createVerifierEnvironment as c, widen as ct, harvestSurfaceDiffs as d, createScopeAnalyst as dt, renderCorpusToInstructions as et, analystsFromRegistry as f, registryScopeAnalyst as ft, EVIDENCE_MAX_CHARS as g, resolveSandboxClient as gt, worktreeFanout as h, defineLeaderboard as ht, jjWorkspace as i, panel as it, createChatSessionStore as j, renderPairwiseMarkdown as jt, chatTransportExecutor as k, renderLeaderboardMarkdown as kt, boxSurfaceReader as l, assertTraceDerivedFindings as lt, superviseSurface as m, harvestCorpus as mt, makeFinding$1 as n, flatWidenGate as nt, runInWorkspace as o, selectValidWinner as ot, failuresAnalyst as p, inProcessSandboxClient as pt, definePersona as q, gitWorkspace as r, loopUntil as rt, createWaterfallCollector as s, verify as st, computeFindingId$1 as t, fanout as tt, fsSurfaceReader as u, buildSteerContext as ut, VERIFY_TAIL_CHARS as v, inlineSandboxClient as vt, analyzeTrace as w, sentinelCompletion as wt, settledWorkerOut as x, superviseDispatch as xt, closingWorkerNote as y, loopCampaignDispatch as yt, strategyAuthorSystemPrompt as z, envKeyProvider as zt };
6362
6438
 
6363
- //# sourceMappingURL=runtime-ZM4i-jEF.js.map
6439
+ //# sourceMappingURL=runtime-CuNJ0opC.js.map