@tangle-network/agent-runtime 0.349.0 → 0.350.2

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 (126) hide show
  1. package/dist/{activation-tNGW73Y9.js → activation-CfJMyzEs.js} +12 -14
  2. package/dist/{activation-tNGW73Y9.js.map → activation-CfJMyzEs.js.map} +1 -1
  3. package/dist/{activation-wBipBkCf.d.ts → activation-DyiHrTlS.d.ts} +2 -24
  4. package/dist/agent.d.ts +8 -12
  5. package/dist/agent.js +9 -12
  6. package/dist/agent.js.map +1 -1
  7. package/dist/{analyst-loop-DZw5QWT9.js → analyst-loop-BZvXCDKy.js} +2 -3
  8. package/dist/{analyst-loop-DZw5QWT9.js.map → analyst-loop-BZvXCDKy.js.map} +1 -1
  9. package/dist/analyst-loop.d.ts +3 -5
  10. package/dist/analyst-loop.js +1 -2
  11. package/dist/{bundle-1xaJEgjq.js → bundle-Ze8pd07a.js} +3 -4
  12. package/dist/{bundle-1xaJEgjq.js.map → bundle-Ze8pd07a.js.map} +1 -1
  13. package/dist/candidate-execution/index.d.ts +13 -33
  14. package/dist/candidate-execution/index.js +16 -18
  15. package/dist/candidate-execution/index.js.map +1 -1
  16. package/dist/{coordination-manager-B2Z_MmL9.js → coordination-manager-BkVfWlMz.js} +101 -132
  17. package/dist/{coordination-manager-B2Z_MmL9.js.map → coordination-manager-BkVfWlMz.js.map} +1 -1
  18. package/dist/{delegate-Dr-63jFl.js → delegate-DgEie4ad.js} +19 -21
  19. package/dist/delegate-DgEie4ad.js.map +1 -0
  20. package/dist/durable.d.ts +13 -23
  21. package/dist/durable.js +48 -43
  22. package/dist/durable.js.map +1 -1
  23. package/dist/{errors-DodWX-cb.js → errors-wuhGvpE3.js} +2 -3
  24. package/dist/{errors-DodWX-cb.js.map → errors-wuhGvpE3.js.map} +1 -1
  25. package/dist/{graph-DPejYB3C.js → graph-Cx0FhKSE.js} +191 -14
  26. package/dist/graph-Cx0FhKSE.js.map +1 -0
  27. package/dist/{improve-DwSahPi1.js → improve-i0HU1-aa.js} +35 -53
  28. package/dist/{improve-DwSahPi1.js.map → improve-i0HU1-aa.js.map} +1 -1
  29. package/dist/{improvement-adapter-sIthWkcN.d.ts → improvement-adapter-D5GRU1eY.d.ts} +2 -6
  30. package/dist/index.d.ts +41 -89
  31. package/dist/index.js +43 -61
  32. package/dist/index.js.map +1 -1
  33. package/dist/intelligence.d.ts +39 -59
  34. package/dist/intelligence.js +23 -33
  35. package/dist/intelligence.js.map +1 -1
  36. package/dist/kernel.d.ts +5 -5
  37. package/dist/kernel.js +11 -11
  38. package/dist/{loop-runner-CP6MfO1b.js → loop-runner-BwN9MhdP.js} +5 -6
  39. package/dist/{loop-runner-CP6MfO1b.js.map → loop-runner-BwN9MhdP.js.map} +1 -1
  40. package/dist/{loop-runner-C6pGq-2l.d.ts → loop-runner-DvfOXVx9.d.ts} +3 -5
  41. package/dist/loop-runner-bin.d.ts +5 -8
  42. package/dist/loop-runner-bin.js +2 -3
  43. package/dist/mcp/bin.js +6 -8
  44. package/dist/mcp/bin.js.map +1 -1
  45. package/dist/mcp/index.d.ts +8 -18
  46. package/dist/mcp/index.js +17 -25
  47. package/dist/mcp/index.js.map +1 -1
  48. package/dist/mcp/memory-bin.js +4 -6
  49. package/dist/mcp/memory-bin.js.map +1 -1
  50. package/dist/{model-policy-CyCUwHed.js → model-policy-GSxWwP-b.js} +11 -13
  51. package/dist/{model-policy-CyCUwHed.js.map → model-policy-GSxWwP-b.js.map} +1 -1
  52. package/dist/placement.d.ts +12 -14
  53. package/dist/placement.js +1 -2
  54. package/dist/platform.d.ts +7 -13
  55. package/dist/platform.js +3 -6
  56. package/dist/platform.js.map +1 -1
  57. package/dist/{prepare-B9wWffjO.js → prepare-DE8TQnLu.js} +49 -69
  58. package/dist/{prepare-B9wWffjO.js.map → prepare-DE8TQnLu.js.map} +1 -1
  59. package/dist/{profile-JLJd2wFG.js → profile-CAhZDW2T.js} +58 -92
  60. package/dist/profile-CAhZDW2T.js.map +1 -0
  61. package/dist/{profile-materialization-bPm0gGLO.d.ts → profile-materialization-BRY22Oh8.d.ts} +1 -3
  62. package/dist/profiles.d.ts +25 -12
  63. package/dist/profiles.js +52 -11
  64. package/dist/profiles.js.map +1 -1
  65. package/dist/{protected-model-port-DVVh-hEk.d.ts → protected-model-port-IKqhTypD.d.ts} +2 -14
  66. package/dist/{protected-redaction-DFCeo4vg.js → protected-redaction-DilFZch5.js} +2 -3
  67. package/dist/{protected-redaction-DFCeo4vg.js.map → protected-redaction-DilFZch5.js.map} +1 -1
  68. package/dist/{provision-supervisor-C4v2vqDo.js → provision-supervisor-Bde_FF0R.js} +11 -15
  69. package/dist/{provision-supervisor-C4v2vqDo.js.map → provision-supervisor-Bde_FF0R.js.map} +1 -1
  70. package/dist/{record-events-D93DkpAx.js → record-events-B2GUgYdz.js} +12 -14
  71. package/dist/{record-events-D93DkpAx.js.map → record-events-B2GUgYdz.js.map} +1 -1
  72. package/dist/{run-cancellation-CzFhQGMa.js → run-cancellation-BLy_Zz-w.js} +6 -7
  73. package/dist/{run-cancellation-CzFhQGMa.js.map → run-cancellation-BLy_Zz-w.js.map} +1 -1
  74. package/dist/{runtime-CsvGCQpl.js → runtime-6Ec9sHRe.js} +648 -215
  75. package/dist/runtime-6Ec9sHRe.js.map +1 -0
  76. package/dist/{runtime-hooks-tXpAarhW.js → runtime-hooks-CsW2pfFk.js} +2 -3
  77. package/dist/{runtime-hooks-tXpAarhW.js.map → runtime-hooks-CsW2pfFk.js.map} +1 -1
  78. package/dist/{runtime-hooks-nsqxSUFL.d.ts → runtime-hooks-ZQqPw-0g.d.ts} +1 -3
  79. package/dist/{sandbox-profile-compat-DtuJWFrM.js → sandbox-profile-compat-BxMQ1VXv.js} +61 -43
  80. package/dist/sandbox-profile-compat-BxMQ1VXv.js.map +1 -0
  81. package/dist/{search-executor-CCb82Umc.js → search-executor-B7g_5Wjl.js} +10 -15
  82. package/dist/{search-executor-CCb82Umc.js.map → search-executor-B7g_5Wjl.js.map} +1 -1
  83. package/dist/{server-CKPwZU-I.js → server-fvEMwGMQ.js} +19 -30
  84. package/dist/{server-CKPwZU-I.js.map → server-fvEMwGMQ.js.map} +1 -1
  85. package/dist/{structural-rollout-DylC_fwU.js → structural-rollout-B86bSixU.js} +69 -70
  86. package/dist/structural-rollout-B86bSixU.js.map +1 -0
  87. package/dist/{substrate-CGDFTSRh.js → substrate-Db2pp6y3.js} +2 -3
  88. package/dist/{substrate-CGDFTSRh.js.map → substrate-Db2pp6y3.js.map} +1 -1
  89. package/dist/{supervise-BGfm2GlY.js → supervise-CaeZcgAW.js} +460 -195
  90. package/dist/supervise-CaeZcgAW.js.map +1 -0
  91. package/dist/{supervisor-wS9Ehz_x.js → supervisor-C1OePYE-.js} +511 -626
  92. package/dist/supervisor-C1OePYE-.js.map +1 -0
  93. package/dist/{task-queue-0fKkoweu.d.ts → task-queue-kefGy79U.d.ts} +1 -3
  94. package/dist/task-queue.d.ts +1 -1
  95. package/dist/task-queue.js +1 -2
  96. package/dist/testing.d.ts +7 -15
  97. package/dist/testing.js +241 -244
  98. package/dist/testing.js.map +1 -1
  99. package/dist/tool-loop.d.ts +16 -19
  100. package/dist/tool-loop.js +2 -3
  101. package/dist/{tool-server-XV4aJwoQ.js → tool-server-CwuYeW_Z.js} +3 -4
  102. package/dist/{tool-server-XV4aJwoQ.js.map → tool-server-CwuYeW_Z.js.map} +1 -1
  103. package/dist/{top-snapshot-CflmaDgk.js → top-snapshot-ChwpTr7A.js} +4 -5
  104. package/dist/{top-snapshot-CflmaDgk.js.map → top-snapshot-ChwpTr7A.js.map} +1 -1
  105. package/dist/tui/bin.js +7 -9
  106. package/dist/tui/bin.js.map +1 -1
  107. package/dist/tui/index.d.ts +3 -5
  108. package/dist/tui/index.js +2 -2
  109. package/dist/{types-C8BGOCBn.d.ts → types-Fowuwdz2.d.ts} +364 -483
  110. package/dist/{types-Cwrea-bU.d.ts → types-qsqfyQoY.d.ts} +1 -3
  111. package/dist/workspace-store/index.d.ts +12 -22
  112. package/dist/workspace-store/index.js +4 -7
  113. package/dist/workspace-store/index.js.map +1 -1
  114. package/dist/{workspace-streams-BiS4ABah.d.ts → workspace-streams-Dq2Fzk3c.d.ts} +1 -11
  115. package/package.json +25 -25
  116. package/skills/agent-graphs/SKILL.md +17 -4
  117. package/skills/be-ambitious/SKILL.md +46 -0
  118. package/skills/graph-designer/SKILL.md +9 -2
  119. package/dist/delegate-Dr-63jFl.js.map +0 -1
  120. package/dist/graph-DPejYB3C.js.map +0 -1
  121. package/dist/profile-JLJd2wFG.js.map +0 -1
  122. package/dist/runtime-CsvGCQpl.js.map +0 -1
  123. package/dist/sandbox-profile-compat-DtuJWFrM.js.map +0 -1
  124. package/dist/structural-rollout-DylC_fwU.js.map +0 -1
  125. package/dist/supervise-BGfm2GlY.js.map +0 -1
  126. package/dist/supervisor-wS9Ehz_x.js.map +0 -1
@@ -1,4 +1,4 @@
1
- //#region src/runtime-hooks.ts
1
+ // src/runtime-hooks.ts
2
2
  /** Identity helper that types a {@link RuntimeHooks} literal so the fields are inferred. */
3
3
  function defineRuntimeHooks(hooks) {
4
4
  return hooks;
@@ -119,7 +119,6 @@ function isThenable(value) {
119
119
  function toError(error) {
120
120
  return error instanceof Error ? error : new Error(String(error));
121
121
  }
122
- //#endregion
123
122
  export { withPursuitContext as a, notifyRuntimeHookEvent as i, defineRuntimeHooks as n, notifyRuntimeDecisionPoint as r, composeRuntimeHooks as t };
124
123
 
125
- //# sourceMappingURL=runtime-hooks-tXpAarhW.js.map
124
+ //# sourceMappingURL=runtime-hooks-CsW2pfFk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-hooks-tXpAarhW.js","names":[],"sources":["../src/runtime-hooks.ts"],"sourcesContent":["/**\n *\n * Runtime hook contracts. Hooks are execution-scoped observers, not part of an\n * `AgentProfile`: profiles stay portable agent recipes; hooks attach to the\n * loop or product harness that is running the profile.\n *\n * A `pursuitId` is deliberately orthogonal to `runId`: a pursuit can span many\n * resumed/retried/forked runs while every event remains attributable to the\n * durable objective that caused it. The observer plane is outside the agent\n * environment and must never be required for agent correctness.\n *\n * @experimental\n */\n\nexport type RuntimeHookPhase = 'before' | 'after' | 'error' | 'event'\n\nexport type RuntimeHookTarget =\n | 'agent.run'\n | 'agent.turn'\n | 'agent.tool_call'\n | 'agent.spawn'\n | 'agent.child'\n | 'agent.plan'\n | 'agent.decision'\n | (string & {})\n\nexport type RuntimeDecisionKind =\n | 'continue'\n | 'verify'\n | 'ask'\n | 'retry'\n | 'stop'\n | 'memory-write'\n | 'memory-read'\n | 'tool-select'\n | 'skill-select'\n | 'workflow-select'\n | 'surface-promote'\n | (string & {})\n\nexport interface RuntimeHookEvent<Payload = unknown> {\n id: string\n /** Stable identity for the long-lived objective. One pursuit may contain many runs. */\n pursuitId?: string\n runId: string\n scenarioId?: string\n target: RuntimeHookTarget\n phase: RuntimeHookPhase\n timestamp: number\n stepIndex?: number\n parentId?: string\n payload?: Payload\n metadata?: Record<string, unknown>\n}\n\nexport interface RuntimeHookContext {\n signal?: AbortSignal\n}\n\nexport interface RuntimeDecisionEvidenceRef {\n source: string\n id: string\n detail?: string\n metadata?: Record<string, unknown>\n}\n\nexport interface RuntimeDecisionPoint {\n id: string\n /** Stable identity for the long-lived objective. One pursuit may contain many runs. */\n pursuitId?: string\n runId: string\n scenarioId?: string\n stepIndex: number\n kind: RuntimeDecisionKind\n candidateActions: string[]\n context?: string\n evidence: RuntimeDecisionEvidenceRef[]\n metadata?: Record<string, unknown>\n}\n\nexport interface RuntimeHookErrorContext {\n hook: 'onEvent' | 'onDecisionPoint'\n eventId?: string\n target?: RuntimeHookTarget\n phase?: RuntimeHookPhase\n decisionId?: string\n decisionKind?: RuntimeDecisionKind\n}\n\n/**\n * The observation seam attached to a running loop (never to the portable genome).\n * Implement the optional hooks to receive lifecycle events, semantic decision points,\n * and hook errors. Author with {@link defineRuntimeHooks} for inference, and attach N\n * observers at once with {@link composeRuntimeHooks} — there is ONE event stream, not a\n * callback-prop zoo.\n */\nexport interface RuntimeHooks {\n /**\n * General before/after/event hook. Use this for telemetry, memory capture,\n * policy wrapping, child lifecycle observers, or product-specific extension\n * points.\n */\n onEvent?: (event: RuntimeHookEvent, context: RuntimeHookContext) => void | Promise<void>\n /**\n * Semantic decision hook. Belief-state evaluation consumes this, but runtime\n * code should keep emitting ordinary lifecycle events as the base layer.\n */\n onDecisionPoint?: (\n point: RuntimeDecisionPoint,\n context: RuntimeHookContext,\n ) => void | Promise<void>\n onHookError?: (error: Error, context: RuntimeHookErrorContext) => void | Promise<void>\n}\n\n/** Identity helper that types a {@link RuntimeHooks} literal so the fields are inferred. */\nexport function defineRuntimeHooks(hooks: RuntimeHooks): RuntimeHooks {\n return hooks\n}\n\n/**\n * Attach a stable pursuit identity to the entire observer stream without changing\n * agent code or teaching individual runtimes about pursuits. Because recursive Scope\n * execution already inherits one RuntimeHooks instance, this wrapper automatically\n * covers descendants, nested drivers, and resumed execution that reuses the wrapper.\n *\n * Existing matching pursuit ids are preserved. A conflicting id fails closed: silently\n * rewriting attribution would make the meta-observer untrustworthy.\n */\nexport function withPursuitContext(pursuitId: string, hooks: RuntimeHooks): RuntimeHooks {\n const stableId = pursuitId.trim()\n if (stableId.length === 0) throw new TypeError('withPursuitContext: pursuitId must be non-empty')\n\n const assertAndStamp = <T extends RuntimeHookEvent | RuntimeDecisionPoint>(value: T): T => {\n if (value.pursuitId !== undefined && value.pursuitId !== stableId) {\n throw new Error(\n `withPursuitContext: observer identity conflict (${value.pursuitId} !== ${stableId})`,\n )\n }\n if (value.pursuitId === stableId) return value\n return { ...value, pursuitId: stableId }\n }\n\n return {\n onEvent: hooks.onEvent\n ? (event, context) => hooks.onEvent?.(assertAndStamp(event), context)\n : undefined,\n onDecisionPoint: hooks.onDecisionPoint\n ? (point, context) => hooks.onDecisionPoint?.(assertAndStamp(point), context)\n : undefined,\n onHookError: hooks.onHookError,\n }\n}\n\n/**\n * Merge several {@link RuntimeHooks} into one. Falsy entries are dropped (so you can\n * pass `flag && hooks`), and every observer's `onEvent`/`onDecisionPoint` fires for each\n * event. Use this to attach N observers to a loop instead of a second event bus.\n */\nexport function composeRuntimeHooks(\n ...entries: Array<RuntimeHooks | undefined | null | false>\n): RuntimeHooks {\n const hooks = entries.filter((entry): entry is RuntimeHooks => !!entry)\n return {\n onEvent: hooks.some((hook) => hook.onEvent)\n ? (event, context) => {\n const pending: Promise<unknown>[] = []\n for (const hook of hooks) {\n const result = hook.onEvent?.(event, context)\n if (isThenable(result)) pending.push(Promise.resolve(result))\n }\n if (pending.length > 0) return Promise.all(pending).then(() => undefined)\n return undefined\n }\n : undefined,\n onDecisionPoint: hooks.some((hook) => hook.onDecisionPoint)\n ? (point, context) => {\n const pending: Promise<unknown>[] = []\n for (const hook of hooks) {\n const result = hook.onDecisionPoint?.(point, context)\n if (isThenable(result)) pending.push(Promise.resolve(result))\n }\n if (pending.length > 0) return Promise.all(pending).then(() => undefined)\n return undefined\n }\n : undefined,\n onHookError: hooks.some((hook) => hook.onHookError)\n ? (error, context) => {\n const pending: Promise<unknown>[] = []\n for (const hook of hooks) {\n const result = hook.onHookError?.(error, context)\n if (isThenable(result)) pending.push(Promise.resolve(result))\n }\n if (pending.length > 0) return Promise.all(pending).then(() => undefined)\n return undefined\n }\n : undefined,\n }\n}\n\n/** Fire `hooks.onEvent`, swallowing sync throws and surfacing async failures to `onError`. */\nexport function notifyRuntimeHookEvent(\n hooks: RuntimeHooks | undefined,\n event: RuntimeHookEvent,\n context: RuntimeHookContext = {},\n): void {\n const onEvent = hooks?.onEvent\n if (!onEvent) return\n\n try {\n const result = onEvent(event, context)\n if (isThenable(result)) {\n void result.catch((error) => {\n notifyRuntimeHookError(hooks, toError(error), {\n hook: 'onEvent',\n eventId: event.id,\n target: event.target,\n phase: event.phase,\n })\n })\n }\n } catch (error) {\n notifyRuntimeHookError(hooks, toError(error), {\n hook: 'onEvent',\n eventId: event.id,\n target: event.target,\n phase: event.phase,\n })\n }\n}\n\n/** Fire `hooks.onDecisionPoint`, swallowing sync throws and surfacing async failures to `onError`. */\nexport function notifyRuntimeDecisionPoint(\n hooks: RuntimeHooks | undefined,\n point: RuntimeDecisionPoint,\n context: RuntimeHookContext = {},\n): void {\n const onDecisionPoint = hooks?.onDecisionPoint\n if (!onDecisionPoint) return\n\n try {\n const result = onDecisionPoint(point, context)\n if (isThenable(result)) {\n void result.catch((error) => {\n notifyRuntimeHookError(hooks, toError(error), {\n hook: 'onDecisionPoint',\n decisionId: point.id,\n decisionKind: point.kind,\n })\n })\n }\n } catch (error) {\n notifyRuntimeHookError(hooks, toError(error), {\n hook: 'onDecisionPoint',\n decisionId: point.id,\n decisionKind: point.kind,\n })\n }\n}\n\nfunction notifyRuntimeHookError(\n hooks: RuntimeHooks | undefined,\n error: Error,\n context: RuntimeHookErrorContext,\n): void {\n try {\n const result = hooks?.onHookError?.(error, context)\n if (isThenable(result)) void result.catch(() => undefined)\n } catch {\n // Hook errors must never become agent-loop errors.\n }\n}\n\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'then' in value &&\n typeof (value as { then?: unknown }).then === 'function'\n )\n}\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error))\n}\n"],"mappings":";;AAmHA,SAAgB,mBAAmB,OAAmC;CACpE,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,mBAAmB,WAAmB,OAAmC;CACvF,MAAM,WAAW,UAAU,KAAK;CAChC,IAAI,SAAS,WAAW,GAAG,MAAM,IAAI,UAAU,iDAAiD;CAEhG,MAAM,kBAAqE,UAAgB;EACzF,IAAI,MAAM,cAAc,KAAA,KAAa,MAAM,cAAc,UACvD,MAAM,IAAI,MACR,mDAAmD,MAAM,UAAU,OAAO,SAAS,EACrF;EAEF,IAAI,MAAM,cAAc,UAAU,OAAO;EACzC,OAAO;GAAE,GAAG;GAAO,WAAW;EAAS;CACzC;CAEA,OAAO;EACL,SAAS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AU,SACV,OAAQ,MAA6B,SAAS;AAElD;AAEA,SAAS,QAAQ,OAAuB;CACtC,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE"}
1
+ {"version":3,"file":"runtime-hooks-CsW2pfFk.js","names":[],"sources":["../src/runtime-hooks.ts"],"sourcesContent":["/**\n *\n * Runtime hook contracts. Hooks are execution-scoped observers, not part of an\n * `AgentProfile`: profiles stay portable agent recipes; hooks attach to the\n * loop or product harness that is running the profile.\n *\n * A `pursuitId` is deliberately orthogonal to `runId`: a pursuit can span many\n * resumed/retried/forked runs while every event remains attributable to the\n * durable objective that caused it. The observer plane is outside the agent\n * environment and must never be required for agent correctness.\n *\n * @experimental\n */\n\nexport type RuntimeHookPhase = 'before' | 'after' | 'error' | 'event'\n\nexport type RuntimeHookTarget =\n | 'agent.run'\n | 'agent.turn'\n | 'agent.tool_call'\n | 'agent.spawn'\n | 'agent.child'\n | 'agent.plan'\n | 'agent.decision'\n | (string & {})\n\nexport type RuntimeDecisionKind =\n | 'continue'\n | 'verify'\n | 'ask'\n | 'retry'\n | 'stop'\n | 'memory-write'\n | 'memory-read'\n | 'tool-select'\n | 'skill-select'\n | 'workflow-select'\n | 'surface-promote'\n | (string & {})\n\nexport interface RuntimeHookEvent<Payload = unknown> {\n id: string\n /** Stable identity for the long-lived objective. One pursuit may contain many runs. */\n pursuitId?: string\n runId: string\n scenarioId?: string\n target: RuntimeHookTarget\n phase: RuntimeHookPhase\n timestamp: number\n stepIndex?: number\n parentId?: string\n payload?: Payload\n metadata?: Record<string, unknown>\n}\n\nexport interface RuntimeHookContext {\n signal?: AbortSignal\n}\n\nexport interface RuntimeDecisionEvidenceRef {\n source: string\n id: string\n detail?: string\n metadata?: Record<string, unknown>\n}\n\nexport interface RuntimeDecisionPoint {\n id: string\n /** Stable identity for the long-lived objective. One pursuit may contain many runs. */\n pursuitId?: string\n runId: string\n scenarioId?: string\n stepIndex: number\n kind: RuntimeDecisionKind\n candidateActions: string[]\n context?: string\n evidence: RuntimeDecisionEvidenceRef[]\n metadata?: Record<string, unknown>\n}\n\nexport interface RuntimeHookErrorContext {\n hook: 'onEvent' | 'onDecisionPoint'\n eventId?: string\n target?: RuntimeHookTarget\n phase?: RuntimeHookPhase\n decisionId?: string\n decisionKind?: RuntimeDecisionKind\n}\n\n/**\n * The observation seam attached to a running loop (never to the portable genome).\n * Implement the optional hooks to receive lifecycle events, semantic decision points,\n * and hook errors. Author with {@link defineRuntimeHooks} for inference, and attach N\n * observers at once with {@link composeRuntimeHooks} — there is ONE event stream, not a\n * callback-prop zoo.\n */\nexport interface RuntimeHooks {\n /**\n * General before/after/event hook. Use this for telemetry, memory capture,\n * policy wrapping, child lifecycle observers, or product-specific extension\n * points.\n */\n onEvent?: (event: RuntimeHookEvent, context: RuntimeHookContext) => void | Promise<void>\n /**\n * Semantic decision hook. Belief-state evaluation consumes this, but runtime\n * code should keep emitting ordinary lifecycle events as the base layer.\n */\n onDecisionPoint?: (\n point: RuntimeDecisionPoint,\n context: RuntimeHookContext,\n ) => void | Promise<void>\n onHookError?: (error: Error, context: RuntimeHookErrorContext) => void | Promise<void>\n}\n\n/** Identity helper that types a {@link RuntimeHooks} literal so the fields are inferred. */\nexport function defineRuntimeHooks(hooks: RuntimeHooks): RuntimeHooks {\n return hooks\n}\n\n/**\n * Attach a stable pursuit identity to the entire observer stream without changing\n * agent code or teaching individual runtimes about pursuits. Because recursive Scope\n * execution already inherits one RuntimeHooks instance, this wrapper automatically\n * covers descendants, nested drivers, and resumed execution that reuses the wrapper.\n *\n * Existing matching pursuit ids are preserved. A conflicting id fails closed: silently\n * rewriting attribution would make the meta-observer untrustworthy.\n */\nexport function withPursuitContext(pursuitId: string, hooks: RuntimeHooks): RuntimeHooks {\n const stableId = pursuitId.trim()\n if (stableId.length === 0) throw new TypeError('withPursuitContext: pursuitId must be non-empty')\n\n const assertAndStamp = <T extends RuntimeHookEvent | RuntimeDecisionPoint>(value: T): T => {\n if (value.pursuitId !== undefined && value.pursuitId !== stableId) {\n throw new Error(\n `withPursuitContext: observer identity conflict (${value.pursuitId} !== ${stableId})`,\n )\n }\n if (value.pursuitId === stableId) return value\n return { ...value, pursuitId: stableId }\n }\n\n return {\n onEvent: hooks.onEvent\n ? (event, context) => hooks.onEvent?.(assertAndStamp(event), context)\n : undefined,\n onDecisionPoint: hooks.onDecisionPoint\n ? (point, context) => hooks.onDecisionPoint?.(assertAndStamp(point), context)\n : undefined,\n onHookError: hooks.onHookError,\n }\n}\n\n/**\n * Merge several {@link RuntimeHooks} into one. Falsy entries are dropped (so you can\n * pass `flag && hooks`), and every observer's `onEvent`/`onDecisionPoint` fires for each\n * event. Use this to attach N observers to a loop instead of a second event bus.\n */\nexport function composeRuntimeHooks(\n ...entries: Array<RuntimeHooks | undefined | null | false>\n): RuntimeHooks {\n const hooks = entries.filter((entry): entry is RuntimeHooks => !!entry)\n return {\n onEvent: hooks.some((hook) => hook.onEvent)\n ? (event, context) => {\n const pending: Promise<unknown>[] = []\n for (const hook of hooks) {\n const result = hook.onEvent?.(event, context)\n if (isThenable(result)) pending.push(Promise.resolve(result))\n }\n if (pending.length > 0) return Promise.all(pending).then(() => undefined)\n return undefined\n }\n : undefined,\n onDecisionPoint: hooks.some((hook) => hook.onDecisionPoint)\n ? (point, context) => {\n const pending: Promise<unknown>[] = []\n for (const hook of hooks) {\n const result = hook.onDecisionPoint?.(point, context)\n if (isThenable(result)) pending.push(Promise.resolve(result))\n }\n if (pending.length > 0) return Promise.all(pending).then(() => undefined)\n return undefined\n }\n : undefined,\n onHookError: hooks.some((hook) => hook.onHookError)\n ? (error, context) => {\n const pending: Promise<unknown>[] = []\n for (const hook of hooks) {\n const result = hook.onHookError?.(error, context)\n if (isThenable(result)) pending.push(Promise.resolve(result))\n }\n if (pending.length > 0) return Promise.all(pending).then(() => undefined)\n return undefined\n }\n : undefined,\n }\n}\n\n/** Fire `hooks.onEvent`, swallowing sync throws and surfacing async failures to `onError`. */\nexport function notifyRuntimeHookEvent(\n hooks: RuntimeHooks | undefined,\n event: RuntimeHookEvent,\n context: RuntimeHookContext = {},\n): void {\n const onEvent = hooks?.onEvent\n if (!onEvent) return\n\n try {\n const result = onEvent(event, context)\n if (isThenable(result)) {\n void result.catch((error) => {\n notifyRuntimeHookError(hooks, toError(error), {\n hook: 'onEvent',\n eventId: event.id,\n target: event.target,\n phase: event.phase,\n })\n })\n }\n } catch (error) {\n notifyRuntimeHookError(hooks, toError(error), {\n hook: 'onEvent',\n eventId: event.id,\n target: event.target,\n phase: event.phase,\n })\n }\n}\n\n/** Fire `hooks.onDecisionPoint`, swallowing sync throws and surfacing async failures to `onError`. */\nexport function notifyRuntimeDecisionPoint(\n hooks: RuntimeHooks | undefined,\n point: RuntimeDecisionPoint,\n context: RuntimeHookContext = {},\n): void {\n const onDecisionPoint = hooks?.onDecisionPoint\n if (!onDecisionPoint) return\n\n try {\n const result = onDecisionPoint(point, context)\n if (isThenable(result)) {\n void result.catch((error) => {\n notifyRuntimeHookError(hooks, toError(error), {\n hook: 'onDecisionPoint',\n decisionId: point.id,\n decisionKind: point.kind,\n })\n })\n }\n } catch (error) {\n notifyRuntimeHookError(hooks, toError(error), {\n hook: 'onDecisionPoint',\n decisionId: point.id,\n decisionKind: point.kind,\n })\n }\n}\n\nfunction notifyRuntimeHookError(\n hooks: RuntimeHooks | undefined,\n error: Error,\n context: RuntimeHookErrorContext,\n): void {\n try {\n const result = hooks?.onHookError?.(error, context)\n if (isThenable(result)) void result.catch(() => undefined)\n } catch {\n // Hook errors must never become agent-loop errors.\n }\n}\n\nfunction isThenable(value: unknown): value is PromiseLike<unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'then' in value &&\n typeof (value as { then?: unknown }).then === 'function'\n )\n}\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error))\n}\n"],"mappings":";;AAmHA,SAAgB,mBAAmB,OAAmC;CACpE,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,mBA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SAAS,OAAO;EACd,uBAAuB,OAAO,QAAQ,KAAK,GAAG;GAC5C,MAAM;GACN,YAAY,MAAM;GAClB,cAAc,MAAM;EACtB,CAAC;CACH;AACF;AAEA,SAAS,uBACP,OACA,OACA,SACM;CACN,IAAI;EACF,MAAM,SAAS,OAAO,cAAc,OAAO,OAAO;EAClD,IAAI,WAAW,MAAM,GAAG,OAAY,YAAY,KAAA,CAAS;CAC3D,QAAQ,CAER;AACF;AAEA,SAAS,WAAW,OAA+C;CACjE,OACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,OAAQ,MAA6B,SAAS;AAElD;AAEA,SAAS,QAAQ,OAAuB;CACtC,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE"}
@@ -1,4 +1,3 @@
1
- //#region src/runtime-hooks.d.ts
2
1
  /**
3
2
  *
4
3
  * Runtime hook contracts. Hooks are execution-scoped observers, not part of an
@@ -88,6 +87,5 @@ declare function defineRuntimeHooks(hooks: RuntimeHooks): RuntimeHooks;
88
87
  * event. Use this to attach N observers to a loop instead of a second event bus.
89
88
  */
90
89
  declare function composeRuntimeHooks(...entries: Array<RuntimeHooks | undefined | null | false>): RuntimeHooks;
91
- //#endregion
92
90
  export { RuntimeHookErrorContext as a, RuntimeHookTarget as c, defineRuntimeHooks as d, RuntimeHookContext as i, RuntimeHooks as l, RuntimeDecisionKind as n, RuntimeHookEvent as o, RuntimeDecisionPoint as r, RuntimeHookPhase as s, RuntimeDecisionEvidenceRef as t, composeRuntimeHooks as u };
93
- //# sourceMappingURL=runtime-hooks-nsqxSUFL.d.ts.map
91
+ //# sourceMappingURL=runtime-hooks-ZQqPw-0g.d.ts.map
@@ -1,10 +1,10 @@
1
- import { m as ValidationError } from "./errors-DodWX-cb.js";
1
+ import { m as ValidationError } from "./errors-wuhGvpE3.js";
2
2
  import { runTaskQueue } from "./task-queue.js";
3
3
  import { agentCandidateArtifactRefSchema, canonicalCandidateBytes as canonicalCandidateBytes$1 } from "@tangle-network/agent-interface";
4
4
  import { isRecord } from "@tangle-network/agent-core";
5
5
  import { createHash, randomUUID } from "node:crypto";
6
6
  import { constants } from "node:fs";
7
- import { dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
7
+ import { dirname, isAbsolute, join, posix, relative, resolve, sep, win32 } from "node:path";
8
8
  import { spawn } from "node:child_process";
9
9
  import { lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
10
10
  import { homedir, tmpdir } from "node:os";
@@ -12,7 +12,7 @@ import { Readable } from "node:stream";
12
12
  import { isAnyArrayBuffer, isSharedArrayBuffer } from "node:util/types";
13
13
  import { extract, pack } from "tar-stream";
14
14
  import { pipeline } from "node:stream/promises";
15
- //#region src/runtime/supervise/deadline.ts
15
+ // src/runtime/supervise/deadline.ts
16
16
  const MAX_TIMER_DELAY_MS = 2147483647;
17
17
  const DEFAULT_SUCCESSFUL_SHUTDOWN_MS = 5e3;
18
18
  /** The abort reason a child's own deadline carries. */
@@ -34,7 +34,7 @@ function checkInIdleMs(policy) {
34
34
  * session copy (a bounded native capture), metering its usage and committing its result. Its
35
35
  * workspace capture is not part of it: the manager's owner runs that after the result.
36
36
  */
37
- const ACCEPTED_RESULT_GRACE_MS = 5 * 6e4;
37
+ const ACCEPTED_RESULT_GRACE_MS = 3e5;
38
38
  /** Whether an abort reason is a deadline: the child's own or the root budget's. */
39
39
  function isDeadlineAbortReason(reason) {
40
40
  return reason === "child deadline exceeded" || reason === "root budget deadline exceeded";
@@ -145,8 +145,7 @@ function singleFlightTeardown(executor, onRequest) {
145
145
  return request;
146
146
  };
147
147
  }
148
- //#endregion
149
- //#region src/runtime/supervise/resources.ts
148
+ // src/runtime/supervise/resources.ts
150
149
  /** Validate caller-owned names and units without assigning domain meaning to them. */
151
150
  function assertResources(resources, kind, label) {
152
151
  if (resources === void 0) return;
@@ -208,8 +207,7 @@ function resourceTelemetry(streamed, terminal) {
208
207
  }
209
208
  return addResourceSpend(Object.fromEntries(resources));
210
209
  }
211
- //#endregion
212
- //#region src/runtime/util.ts
210
+ // src/runtime/util.ts
213
211
  /**
214
212
  * Best-effort sandbox delete. Skips instances without a `delete` (test fakes);
215
213
  * swallows errors (the platform reaps on expiry). Returns `false` when delete
@@ -633,8 +631,36 @@ function fnv1a32Hex(text) {
633
631
  }
634
632
  return (h >>> 0).toString(16).padStart(8, "0");
635
633
  }
636
- //#endregion
637
- //#region src/path-control-characters.ts
634
+ // src/agent/native-system-prompt.ts
635
+ /** Native replace and append controls shared by local and sealed candidate execution. */
636
+ function nativeSystemPrompt(harness, prompt, systemPath = ".tangle/system-prompt.md") {
637
+ const files = [];
638
+ const flags = [];
639
+ for (const intent of ["systemPrompt", "appendSystemPrompt"]) {
640
+ const text = prompt?.[intent];
641
+ if (text === void 0) continue;
642
+ if (typeof text !== "string" || intent === "appendSystemPrompt" && !text.trim()) throw new Error(`profile.prompt.${intent} must be ${intent === "systemPrompt" ? "a string" : "non-empty text"}`);
643
+ const append = intent === "appendSystemPrompt";
644
+ const path = append ? posix.join(posix.dirname(systemPath), "append-system-prompt.md") : systemPath;
645
+ if (harness === "codex" && append) {
646
+ flags.push("-c", `developer_instructions=${JSON.stringify(text)}`);
647
+ continue;
648
+ }
649
+ const flag = harness === "claude-code" ? append ? "--append-system-prompt-file" : "--system-prompt-file" : harness === "pi" || harness === "prime" ? append ? "--append-system-prompt" : "--system-prompt" : harness === "codex" ? "-c" : void 0;
650
+ if (!flag) throw new Error(`${harness} has no native ${intent} launch projection`);
651
+ files.push({
652
+ relPath: append ? ".tangle/append-system-prompt.md" : ".tangle/system-prompt.md",
653
+ content: text,
654
+ source: "generated"
655
+ });
656
+ flags.push(flag, harness === "codex" ? `model_instructions_file=${JSON.stringify(path)}` : path);
657
+ }
658
+ return {
659
+ files,
660
+ flags
661
+ };
662
+ }
663
+ // src/path-control-characters.ts
638
664
  /** Whether a serialized field contains an ASCII control or delete character. */
639
665
  function hasControlCharacter(value) {
640
666
  for (let index = 0; index < value.length; index++) {
@@ -643,8 +669,7 @@ function hasControlCharacter(value) {
643
669
  }
644
670
  return false;
645
671
  }
646
- //#endregion
647
- //#region src/candidate-execution/digest.ts
672
+ // src/candidate-execution/digest.ts
648
673
  /** Use native hashing for workspace archives. */
649
674
  function sha256Bytes$1(bytes) {
650
675
  return `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
@@ -693,8 +718,7 @@ function deepFreezeCandidate(value, seen = /* @__PURE__ */ new Set()) {
693
718
  for (const child of Object.values(value)) deepFreezeCandidate(child, seen);
694
719
  return Object.freeze(value);
695
720
  }
696
- //#endregion
697
- //#region src/candidate-execution/artifacts.ts
721
+ // src/candidate-execution/artifacts.ts
698
722
  function artifactCacheKey(artifact) {
699
723
  return `${artifact.sha256}:${artifact.byteLength}`;
700
724
  }
@@ -926,7 +950,7 @@ function isWithin(root, path) {
926
950
  */
927
951
  async function readWorkspaceFile(descriptor, maxBytes, keepBytes, path, signal) {
928
952
  const hash = createHash("sha256");
929
- const buffer = Buffer.allocUnsafe(1024 * 1024);
953
+ const buffer = Buffer.allocUnsafe(1048576);
930
954
  const chunks = [];
931
955
  let total = 0;
932
956
  while (true) {
@@ -949,8 +973,7 @@ async function readWorkspaceFile(descriptor, maxBytes, keepBytes, path, signal)
949
973
  byteLength: total
950
974
  };
951
975
  }
952
- //#endregion
953
- //#region src/candidate-execution/exact-object.ts
976
+ // src/candidate-execution/exact-object.ts
954
977
  /** Reject unknown fields while requiring every declared non-optional field. */
955
978
  function assertExactObjectKeys(value, required, label, optional = []) {
956
979
  if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must be an object`);
@@ -975,8 +998,7 @@ function isWellFormedUnicode(value) {
975
998
  }
976
999
  return true;
977
1000
  }
978
- //#endregion
979
- //#region src/candidate-execution/output-artifacts.ts
1001
+ // src/candidate-execution/output-artifacts.ts
980
1002
  /** Persist evaluator evidence, read it back, and bind the returned locator to the exact bytes. */
981
1003
  async function persistCandidateOutputArtifact(port, input) {
982
1004
  input.signal?.throwIfAborted();
@@ -995,8 +1017,7 @@ async function persistCandidateOutputArtifact(port, input) {
995
1017
  verifyBytes(stored, expectedDigest, bytes.byteLength, "persisted candidate output");
996
1018
  return immutableCandidateValue(ref);
997
1019
  }
998
- //#endregion
999
- //#region src/candidate-execution/workspace-archive.ts
1020
+ // src/candidate-execution/workspace-archive.ts
1000
1021
  const archiveKind = "agent-candidate-workspace-archive";
1001
1022
  const workspaceEntryPrefix = "workspace/";
1002
1023
  const repositoryMetadataEntry = "metadata/repository.json";
@@ -1005,13 +1026,13 @@ const repositoryIndexEntry = "metadata/repository.index.json";
1005
1026
  const repositoryIndexPrefix = "index/";
1006
1027
  const fixedTarTime = /* @__PURE__ */ new Date(0);
1007
1028
  const defaultLimits = Object.freeze({
1008
- maxArchiveBytes: 512 * 1024 * 1024,
1009
- maxEmbeddedArtifactBytes: 1024 * 1024,
1029
+ maxArchiveBytes: 536870912,
1030
+ maxEmbeddedArtifactBytes: 1048576,
1010
1031
  maxFiles: 5e4,
1011
- maxFileBytes: 128 * 1024 * 1024,
1012
- maxTotalFileBytes: 256 * 1024 * 1024,
1032
+ maxFileBytes: 134217728,
1033
+ maxTotalFileBytes: 268435456,
1013
1034
  maxPathBytes: 4096,
1014
- maxRepositoryBundleBytes: 128 * 1024 * 1024
1035
+ maxRepositoryBundleBytes: 134217728
1015
1036
  });
1016
1037
  /** Capture detached files returned by a remote executor into the standard archive. */
1017
1038
  async function captureAgentCandidateWorkspaceFiles(input, options = {}) {
@@ -1414,8 +1435,7 @@ function workspaceTarHeader(name, mode, size) {
1414
1435
  gname: ""
1415
1436
  };
1416
1437
  }
1417
- //#endregion
1418
- //#region src/candidate-execution/artifact-streams.ts
1438
+ // src/candidate-execution/artifact-streams.ts
1419
1439
  /** Verify the complete stream, including its final digest, before accepting its consumer's result. */
1420
1440
  async function* verifiedArtifactChunks(artifact, port, signal) {
1421
1441
  signal?.throwIfAborted();
@@ -1482,8 +1502,7 @@ async function persistCandidateOutputArtifactStream(port, input) {
1482
1502
  await chunks.return(void 0);
1483
1503
  }
1484
1504
  }
1485
- //#endregion
1486
- //#region src/candidate-execution/git-materialize.ts
1505
+ // src/candidate-execution/git-materialize.ts
1487
1506
  async function verifyCandidateCode(code, repositories, patchBytes) {
1488
1507
  if (code.kind === "disabled") return void 0;
1489
1508
  const repositoryRoot = await verifiedRepositoryRoot(code.repository, repositories);
@@ -1617,7 +1636,8 @@ async function verifiedRepositoryRoot(repository, repositories) {
1617
1636
  ])).stdout.toString("utf8").trim();
1618
1637
  const actual = parseGitHubRemote(origin);
1619
1638
  if (!actual || actual.owner !== repository.owner || actual.repo !== repository.repo) throw new Error(`local repository origin ${origin || "<missing>"} does not match github.com/${repository.owner}/${repository.repo}`);
1620
- await assertNoGitIndirection(repositoryRoot, resolve((await runCandidateGit(repositoryRoot, ["rev-parse", "--absolute-git-dir"])).stdout.toString("utf8").trim()), "candidate repository");
1639
+ const gitDirText = (await runCandidateGit(repositoryRoot, ["rev-parse", "--absolute-git-dir"])).stdout.toString("utf8").trim();
1640
+ await assertNoGitIndirection(repositoryRoot, resolve(gitDirText), "candidate repository");
1621
1641
  return repositoryRoot;
1622
1642
  }
1623
1643
  async function assertNoGitIndirection(repositoryRoot, gitDir, label) {
@@ -1811,8 +1831,7 @@ async function runCandidateGit(repositoryRoot, args, input, extraEnv = {}, optio
1811
1831
  function isNoEntry(error) {
1812
1832
  return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
1813
1833
  }
1814
- //#endregion
1815
- //#region src/candidate-execution/workspace-archive-local.ts
1834
+ // src/candidate-execution/workspace-archive-local.ts
1816
1835
  /** Capture one exact regular-file workspace for immutable candidate execution. */
1817
1836
  async function captureAgentCandidateWorkspace(rootInput, options = {}) {
1818
1837
  const root = resolve(rootInput);
@@ -1872,7 +1891,8 @@ async function captureRepository(requestedRoot, limits, workingTree) {
1872
1891
  const root = await realpath(requestedRoot);
1873
1892
  const resolvedStats = await lstat(root);
1874
1893
  if (!resolvedStats.isDirectory() || resolvedStats.isSymbolicLink()) throw new Error("candidate repository root must resolve to a real directory");
1875
- if (await realpath(resolve((await runCandidateGit(root, ["rev-parse", "--show-toplevel"])).stdout.toString("utf8").trim())) !== root) throw new Error("candidate repository capture must start at the Git worktree root");
1894
+ const topLevel = (await runCandidateGit(root, ["rev-parse", "--show-toplevel"])).stdout.toString("utf8").trim();
1895
+ if (await realpath(resolve(topLevel)) !== root) throw new Error("candidate repository capture must start at the Git worktree root");
1876
1896
  const gitDir = resolve((await runCandidateGit(root, ["rev-parse", "--absolute-git-dir"])).stdout.toString("utf8").trim());
1877
1897
  if (await realpath(gitDir) !== gitDir || gitDir.includes(":")) throw new Error("candidate repository Git object store has an unsupported path");
1878
1898
  await assertNoGitIndirection(root, gitDir, "candidate repository");
@@ -2054,7 +2074,8 @@ async function prepareEmptyDestination(destination, options = {}) {
2054
2074
  throw error;
2055
2075
  }
2056
2076
  if (!stats.isDirectory() || stats.isSymbolicLink()) throw new Error("candidate workspace destination must be a real directory");
2057
- const resolvedStats = await lstat(await realpath(destination));
2077
+ const resolvedDestination = await realpath(destination);
2078
+ const resolvedStats = await lstat(resolvedDestination);
2058
2079
  if (!resolvedStats.isDirectory() || resolvedStats.isSymbolicLink()) throw new Error("candidate workspace destination must resolve to a real directory");
2059
2080
  if ((await readdir(destination)).length > 0) throw new Error("candidate workspace destination must be empty");
2060
2081
  }
@@ -2164,8 +2185,7 @@ function workspacePath(root, relativePath) {
2164
2185
  if (!path.startsWith(`${root}${sep}`)) throw new Error(`candidate workspace archive path escapes its destination: ${relativePath}`);
2165
2186
  return path;
2166
2187
  }
2167
- //#endregion
2168
- //#region src/candidate-execution/workspace-streams.ts
2188
+ // src/candidate-execution/workspace-streams.ts
2169
2189
  /**
2170
2190
  * Files a tree capture stores at once; each waits on a durable-store round trip of its own and on
2171
2191
  * four fsyncs. On drew-gtr-pro, with three 180 ms store requests per file, 64 at once
@@ -2443,7 +2463,7 @@ async function* workspaceFileChunks(root, expected, signal) {
2443
2463
  let byteLength = 0;
2444
2464
  for await (const chunk of file.createReadStream({
2445
2465
  autoClose: false,
2446
- highWaterMark: 64 * 1024
2466
+ highWaterMark: 65536
2447
2467
  })) {
2448
2468
  signal?.throwIfAborted();
2449
2469
  byteLength += chunk.byteLength;
@@ -2496,8 +2516,7 @@ async function* oneChunk(bytes) {
2496
2516
  function asError(error) {
2497
2517
  return error instanceof Error ? error : new Error(String(error));
2498
2518
  }
2499
- //#endregion
2500
- //#region src/runtime/sandbox-profile-compat.ts
2519
+ // src/runtime/sandbox-profile-compat.ts
2501
2520
  /**
2502
2521
  * Interface 5.3 admits proxy secrets and private config values, but the current Sandbox SDK
2503
2522
  * carries Interface 4.0. Refuse these fields before either candidate conversion or a direct
@@ -2527,7 +2546,6 @@ function refuseNonPublicConfigValues(values, path, context) {
2527
2546
  function refuseSandboxProfileField(field, context = "candidate profile") {
2528
2547
  throw new ValidationError(`${context} field ${field} is refused: Sandbox's Interface 4.0.0 cannot carry it yet, and Runtime does not drop it`);
2529
2548
  }
2530
- //#endregion
2531
- export { isAbortError as $, verifyMaterializedProfileWorkspace as A, sha256Bytes$1 as B, WorkspaceScanLimitError as C, armDeadlineTimer as Ct, readMaterializedWorkspaceFiles as D, singleFlightTeardown as Dt, captureMaterializedWorkspace as E, isDeadlineAbortReason as Et, canonicalCandidateDocument as F, addTokenUsage as G, hasControlCharacter as H, deepFreezeCandidate as I, cloneTokenUsage as J, chargedTokens as K, embeddedCandidateArtifact as L, verifyWorkspaceSnapshotArtifacts as M, canonicalCandidateBytes$1 as N, readVerifiedArtifact as O, teardownExecutor as Ot, canonicalCandidateDigest$1 as P, hasCompleteCacheBreakdown as Q, immutableCandidateValue as R, isWellFormedUnicode as S, ROOT_DEADLINE_REASON as St, candidateWorkspaceManifest as T, checkInIdleMs as Tt, abortError as U, verifyCanonicalCandidateDocument as V, addSpend as W, errorMessage as X, deleteBoxSafe as Y, fnv1a32Hex as Z, captureAgentCandidateWorkspaceFiles as _, withBudgetResources as _t, materializeAgentCandidateWorkspaceFromArtifacts as a, roundBoxMinutes as at, persistCandidateOutputArtifact as b, DEADLINE_CHECK_IN_MESSAGE as bt, verifyAgentCandidateWorkspaceTree as c, throwAbort as ct, readCandidateGitHubResource as d, withTimeout as dt, isAsyncIterable as et, verifyCandidateCode as f, zeroSpend as ft, verifiedArtifactChunks as g, resourceTelemetry as gt, markPutStreamVerified as h, assertResources as ht, captureAgentCandidateWorkspaceTreeToArtifacts as i, randomUuid as it, verifyMaterializedWorkspace as j, verifyBytes as k, teardownSurfaces as kt, captureAgentCandidateWorkspace as l, throwIfAborted as lt, verifyTaskOutcomePatch as m, addResourceSpend as mt, refuseSandboxProfileField as n, promptCacheTokenClasses as nt, readAgentCandidateWorkspaceArtifactFiles as o, sleep as ot, verifyTaskCheckout as p, zeroTokenUsage as pt, cloneSpend as q, captureAgentCandidateWorkspaceToArtifacts as r, randomSuffix as rt, verifyAgentCandidateWorkspaceArtifacts as s, stringifySafe as st, assertSandboxProfileCompatibility as t, mapWithConcurrency as tt, createAgentCandidateWorkspacePort as u, unmeteredSpend as ut, verifyAgentCandidateWorkspaceArchive as v, ACCEPTED_RESULT_GRACE_MS as vt, artifactCacheKey as w, boundedChildDeadlineAt as wt, assertExactObjectKeys as x, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as xt, workspaceLimits as y, CHILD_DEADLINE_REASON as yt, omitTopLevelDigest as z };
2549
+ export { hasCompleteCacheBreakdown as $, verifyMaterializedProfileWorkspace as A, teardownSurfaces as At, sha256Bytes$1 as B, WorkspaceScanLimitError as C, ROOT_DEADLINE_REASON as Ct, readMaterializedWorkspaceFiles as D, isDeadlineAbortReason as Dt, captureMaterializedWorkspace as E, checkInIdleMs as Et, canonicalCandidateDocument as F, addSpend as G, hasControlCharacter as H, deepFreezeCandidate as I, cloneSpend as J, addTokenUsage as K, embeddedCandidateArtifact as L, verifyWorkspaceSnapshotArtifacts as M, canonicalCandidateBytes$1 as N, readVerifiedArtifact as O, singleFlightTeardown as Ot, canonicalCandidateDigest$1 as P, fnv1a32Hex as Q, immutableCandidateValue as R, isWellFormedUnicode as S, DEFAULT_SUCCESSFUL_SHUTDOWN_MS as St, candidateWorkspaceManifest as T, boundedChildDeadlineAt as Tt, nativeSystemPrompt as U, verifyCanonicalCandidateDocument as V, abortError as W, deleteBoxSafe as X, cloneTokenUsage as Y, errorMessage as Z, captureAgentCandidateWorkspaceFiles as _, resourceTelemetry as _t, materializeAgentCandidateWorkspaceFromArtifacts as a, randomUuid as at, persistCandidateOutputArtifact as b, CHILD_DEADLINE_REASON as bt, verifyAgentCandidateWorkspaceTree as c, stringifySafe as ct, readCandidateGitHubResource as d, unmeteredSpend as dt, isAbortError as et, verifyCandidateCode as f, withTimeout as ft, verifiedArtifactChunks as g, assertResources as gt, markPutStreamVerified as h, addResourceSpend as ht, captureAgentCandidateWorkspaceTreeToArtifacts as i, randomSuffix as it, verifyMaterializedWorkspace as j, verifyBytes as k, teardownExecutor as kt, captureAgentCandidateWorkspace as l, throwAbort as lt, verifyTaskOutcomePatch as m, zeroTokenUsage as mt, refuseSandboxProfileField as n, mapWithConcurrency as nt, readAgentCandidateWorkspaceArtifactFiles as o, roundBoxMinutes as ot, verifyTaskCheckout as p, zeroSpend as pt, chargedTokens as q, captureAgentCandidateWorkspaceToArtifacts as r, promptCacheTokenClasses as rt, verifyAgentCandidateWorkspaceArtifacts as s, sleep as st, assertSandboxProfileCompatibility as t, isAsyncIterable as tt, createAgentCandidateWorkspacePort as u, throwIfAborted as ut, verifyAgentCandidateWorkspaceArchive as v, withBudgetResources as vt, artifactCacheKey as w, armDeadlineTimer as wt, assertExactObjectKeys as x, DEADLINE_CHECK_IN_MESSAGE as xt, workspaceLimits as y, ACCEPTED_RESULT_GRACE_MS as yt, omitTopLevelDigest as z };
2532
2550
 
2533
- //# sourceMappingURL=sandbox-profile-compat-DtuJWFrM.js.map
2551
+ //# sourceMappingURL=sandbox-profile-compat-BxMQ1VXv.js.map