@tangle-network/agent-runtime 0.338.0 → 0.339.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 (140) hide show
  1. package/dist/{activation-CsbNax2X.d.ts → activation-CJIIl_Ey.d.ts} +4 -24
  2. package/dist/{activation-kbkAuSmY.js → activation-CVSFxis9.js} +5 -18
  3. package/dist/{activation-kbkAuSmY.js.map → activation-CVSFxis9.js.map} +1 -1
  4. package/dist/agent.d.ts +4 -4
  5. package/dist/agent.js +3 -3
  6. package/dist/{bundle-DM60AI2B.js → bundle-DVOhBTic.js} +2 -2
  7. package/dist/{bundle-DM60AI2B.js.map → bundle-DVOhBTic.js.map} +1 -1
  8. package/dist/candidate-execution/index.d.ts +4 -63
  9. package/dist/candidate-execution/index.js +6 -145
  10. package/dist/candidate-execution/index.js.map +1 -1
  11. package/dist/{delegate-Se1YZKMb.js → delegate-CCWE_AkU.js} +2 -2
  12. package/dist/{delegate-Se1YZKMb.js.map → delegate-CCWE_AkU.js.map} +1 -1
  13. package/dist/{driver-control-acknowledgers-T2a1Ouay.js → driver-control-acknowledgers-C53ggdJ6.js} +12 -8
  14. package/dist/driver-control-acknowledgers-C53ggdJ6.js.map +1 -0
  15. package/dist/{durable-file-B_eJr6Mb.js → durable-file-gNI9ILAn.js} +1 -3
  16. package/dist/durable-file-gNI9ILAn.js.map +1 -0
  17. package/dist/durable.d.ts +3 -35
  18. package/dist/durable.js +10 -10
  19. package/dist/durable.js.map +1 -1
  20. package/dist/{graph-CY0wH838.js → graph-CI9JXKqO.js} +4 -4
  21. package/dist/graph-CI9JXKqO.js.map +1 -0
  22. package/dist/{graph-registry-By0tUj4S.js → graph-registry-BnO64cn8.js} +3 -3
  23. package/dist/{graph-registry-By0tUj4S.js.map → graph-registry-BnO64cn8.js.map} +1 -1
  24. package/dist/{improve-CWGBT13K.js → improve-BOXTLWJ3.js} +8 -35
  25. package/dist/improve-BOXTLWJ3.js.map +1 -0
  26. package/dist/{improvement-adapter-D5gwwoXQ.d.ts → improvement-adapter-HUt_-cWA.d.ts} +2 -20
  27. package/dist/index.d.ts +9 -206
  28. package/dist/index.js +91 -302
  29. package/dist/index.js.map +1 -1
  30. package/dist/intelligence.d.ts +10 -142
  31. package/dist/intelligence.js +7 -81
  32. package/dist/intelligence.js.map +1 -1
  33. package/dist/{jsonl-file-DBv31uPi.js → jsonl-file-C9Kde_0Z.js} +2 -2
  34. package/dist/{jsonl-file-DBv31uPi.js.map → jsonl-file-C9Kde_0Z.js.map} +1 -1
  35. package/dist/kernel.d.ts +4 -3
  36. package/dist/kernel.js +12 -14
  37. package/dist/loop-runner-CWzG1bH4.d.ts +32 -0
  38. package/dist/loop-runner-bin.d.ts +32 -2
  39. package/dist/loop-runner-bin.js +93 -1
  40. package/dist/loop-runner-bin.js.map +1 -0
  41. package/dist/loop-runner-pmPIHFVY.js +59 -0
  42. package/dist/loop-runner-pmPIHFVY.js.map +1 -0
  43. package/dist/mcp/bin.js +3 -3
  44. package/dist/mcp/index.d.ts +99 -418
  45. package/dist/mcp/index.js +121 -203
  46. package/dist/mcp/index.js.map +1 -1
  47. package/dist/mcp/memory-bin.js +231 -1
  48. package/dist/mcp/memory-bin.js.map +1 -1
  49. package/dist/model-policy-CyCUwHed.js.map +1 -1
  50. package/dist/placement.d.ts +2 -9
  51. package/dist/placement.js +1 -1
  52. package/dist/placement.js.map +1 -1
  53. package/dist/platform.d.ts +188 -1
  54. package/dist/platform.js +129 -1
  55. package/dist/platform.js.map +1 -1
  56. package/dist/{prepare-Bt0IouPq.js → prepare-bXkvPMJA.js} +8 -160
  57. package/dist/prepare-bXkvPMJA.js.map +1 -0
  58. package/dist/{profile-Do-5xO_D.js → profile-Dpei_Sq0.js} +2 -2
  59. package/dist/profile-Dpei_Sq0.js.map +1 -0
  60. package/dist/{profile-materialization-BnoEf1co.d.ts → profile-materialization-B1wm2SPT.d.ts} +3 -5
  61. package/dist/profiles.d.ts +2 -2
  62. package/dist/profiles.js +3 -40
  63. package/dist/profiles.js.map +1 -1
  64. package/dist/{protected-model-port-DGxQ8_YM.d.ts → protected-model-port-BGgpy2r9.d.ts} +3 -29
  65. package/dist/protected-redaction-DFCeo4vg.js.map +1 -1
  66. package/dist/{provision-supervisor-0jMufp4h.js → provision-supervisor-CJ6Zz6dz.js} +6 -6
  67. package/dist/{provision-supervisor-0jMufp4h.js.map → provision-supervisor-CJ6Zz6dz.js.map} +1 -1
  68. package/dist/{run-cancellation-BoW5Sg9Y.js → run-cancellation-C9oL62sW.js} +3 -7
  69. package/dist/{run-cancellation-BoW5Sg9Y.js.map → run-cancellation-C9oL62sW.js.map} +1 -1
  70. package/dist/{runtime-D37zRSs7.js → runtime-B2fjL9Oi.js} +2531 -2889
  71. package/dist/runtime-B2fjL9Oi.js.map +1 -0
  72. package/dist/{runtime-hooks-Bj6wJHlH.d.ts → runtime-hooks-nsqxSUFL.d.ts} +2 -6
  73. package/dist/{sandbox-profile-compat-xSoVtdWw.js → sandbox-profile-compat-BzVBFqrz.js} +2 -4
  74. package/dist/sandbox-profile-compat-BzVBFqrz.js.map +1 -0
  75. package/dist/{search-executor-DmgUm5p7.js → search-executor-zMumiak_.js} +3 -3
  76. package/dist/search-executor-zMumiak_.js.map +1 -0
  77. package/dist/{server-DQHJszfk.js → server-_4voDNrl.js} +362 -67
  78. package/dist/server-_4voDNrl.js.map +1 -0
  79. package/dist/{structural-rollout-DAvIE8mw.js → structural-rollout-DpLCXzaL.js} +80 -80
  80. package/dist/structural-rollout-DpLCXzaL.js.map +1 -0
  81. package/dist/{substrate-B0TYNrXn.js → substrate-CGDFTSRh.js} +2 -9
  82. package/dist/substrate-CGDFTSRh.js.map +1 -0
  83. package/dist/{supervise-WuPAwfPh.js → supervise-qAwXmPtD.js} +10 -57
  84. package/dist/supervise-qAwXmPtD.js.map +1 -0
  85. package/dist/{supervisor-CPG1I9UN.js → supervisor-DHrUJhEZ.js} +179 -236
  86. package/dist/supervisor-DHrUJhEZ.js.map +1 -0
  87. package/dist/testing.d.ts +2 -2
  88. package/dist/testing.js +13 -13
  89. package/dist/testing.js.map +1 -1
  90. package/dist/tool-loop.d.ts +1 -1
  91. package/dist/{tool-server-Dqer2M4_.js → tool-server-XV4aJwoQ.js} +2 -2
  92. package/dist/tool-server-XV4aJwoQ.js.map +1 -0
  93. package/dist/top-snapshot-CbZE1JsU.js +502 -0
  94. package/dist/top-snapshot-CbZE1JsU.js.map +1 -0
  95. package/dist/tui/bin.js +711 -1
  96. package/dist/tui/bin.js.map +1 -1
  97. package/dist/tui/index.d.ts +2 -70
  98. package/dist/tui/index.js +3 -3
  99. package/dist/{types-CrNWif8-.d.ts → types-CaOXqRTq.d.ts} +713 -2096
  100. package/dist/workspace-store/index.d.ts +2 -27
  101. package/dist/workspace-store/index.js +2 -2
  102. package/dist/workspace-store/index.js.map +1 -1
  103. package/dist/{workspace-streams-BZZds1Fw.d.ts → workspace-streams-BiS4ABah.d.ts} +3 -18
  104. package/package.json +1 -1
  105. package/skills/agent-graphs/references/authoring.md +3 -2
  106. package/dist/coder-yhVWbdWc.js +0 -40
  107. package/dist/coder-yhVWbdWc.js.map +0 -1
  108. package/dist/delegation-status-CF4D0NZ_.js +0 -358
  109. package/dist/delegation-status-CF4D0NZ_.js.map +0 -1
  110. package/dist/driver-control-acknowledgers-T2a1Ouay.js.map +0 -1
  111. package/dist/durable-file-B_eJr6Mb.js.map +0 -1
  112. package/dist/graph-CY0wH838.js.map +0 -1
  113. package/dist/improve-CWGBT13K.js.map +0 -1
  114. package/dist/integrations-6xttbPi9.d.ts +0 -190
  115. package/dist/integrations-dFi-ALk7.js +0 -132
  116. package/dist/integrations-dFi-ALk7.js.map +0 -1
  117. package/dist/kb-gate-C8z2juK8.d.ts +0 -80
  118. package/dist/kb-gate-DpaSwXVx.js +0 -80
  119. package/dist/kb-gate-DpaSwXVx.js.map +0 -1
  120. package/dist/loop-runner-bin-CFnrAHpl.d.ts +0 -164
  121. package/dist/loop-runner-bin-CdPlhy9g.js +0 -246
  122. package/dist/loop-runner-bin-CdPlhy9g.js.map +0 -1
  123. package/dist/memory-server-DXQ8IxGR.js +0 -234
  124. package/dist/memory-server-DXQ8IxGR.js.map +0 -1
  125. package/dist/openai-tools-DoQ32vpe.js +0 -44
  126. package/dist/openai-tools-DoQ32vpe.js.map +0 -1
  127. package/dist/openai-tools-zh2I_uD7.d.ts +0 -24
  128. package/dist/prepare-Bt0IouPq.js.map +0 -1
  129. package/dist/profile-Do-5xO_D.js.map +0 -1
  130. package/dist/runtime-D37zRSs7.js.map +0 -1
  131. package/dist/sandbox-profile-compat-xSoVtdWw.js.map +0 -1
  132. package/dist/search-executor-DmgUm5p7.js.map +0 -1
  133. package/dist/server-DQHJszfk.js.map +0 -1
  134. package/dist/structural-rollout-DAvIE8mw.js.map +0 -1
  135. package/dist/substrate-B0TYNrXn.js.map +0 -1
  136. package/dist/supervise-WuPAwfPh.js.map +0 -1
  137. package/dist/supervisor-CPG1I9UN.js.map +0 -1
  138. package/dist/tool-server-Dqer2M4_.js.map +0 -1
  139. package/dist/top-app-C55Wa7uy.js +0 -1214
  140. package/dist/top-app-C55Wa7uy.js.map +0 -1
package/dist/mcp/index.js CHANGED
@@ -1,20 +1,128 @@
1
- import { $r as parseCodexTokenUsage, Dt as createSandboxForSpec, Qr as removeWorktree, Tt as assertBoxlessPromptOptions, Xr as captureWorktreeDiff, Yr as runWorktreeHarness, Zr as createWorktree, ai as localHarnessExecutable, bn as readTraceContextFromEnv, ei as CodexExecutionDiagnosticError, ii as harnessSupportsReasoningEffort, ni as LOCAL_HARNESSES, ti as DEFAULT_LOCAL_HARNESS, vn as createPropagatingTraceEmitter, wt as runAgentRounds, xn as traceContextToEnv, yn as mergeTraceEnv } from "../supervisor-CPG1I9UN.js";
1
+ import { Tr as LOCAL_HARNESSES, _t as runAgentRounds, bt as createSandboxForSpec, nn as readTraceContextFromEnv, tn as createPropagatingTraceEmitter, vt as assertBoxlessPromptOptions, wr as runWorktreeHarness } from "../supervisor-DHrUJhEZ.js";
2
2
  import { i as ConfigError, m as ValidationError } from "../errors-DodWX-cb.js";
3
3
  import { t as isRecord } from "../record-value-B6bwJxLa.js";
4
- import { X as deleteBoxSafe, lt as throwAbort, st as sleep, ut as throwIfAborted } from "../sandbox-profile-compat-xSoVtdWw.js";
4
+ import { X as deleteBoxSafe, st as sleep, ut as throwIfAborted } from "../sandbox-profile-compat-BzVBFqrz.js";
5
5
  import { t as assertExecutableAgentProfile } from "../model-policy-CyCUwHed.js";
6
- import { C as SPAWN_RESOURCE_PATH_MAX_BYTES, E as resolveSpawnResourcePaths, T as hostDirectoryReader, c as downMessageRefusalReasons, d as ANALYST_DEFINITION_BOUNDS, f as analystToolGroupNames, h as parseAuthoredAnalystDefinition, r as createCoordinationTools, s as questionEscalationTargets, w as environmentReader } from "../driver-control-acknowledgers-T2a1Ouay.js";
7
- import { pt as selectValidWinner, z as runCoderChecks } from "../runtime-D37zRSs7.js";
8
- import { n as SUPPORTED_PROTOCOL_VERSIONS, r as createStdioToolServer } from "../tool-server-Dqer2M4_.js";
9
- import { t as createKbGate } from "../kb-gate-DpaSwXVx.js";
10
- import { _ as InMemoryFeedbackStore, a as validateDelegationStatusArgs, c as DELEGATION_HISTORY_TOOL_NAME, d as delegationProfiles, f as DELEGATE_FEEDBACK_DESCRIPTION, g as validateDelegateFeedbackArgs, h as createDelegateFeedbackHandler, i as createDelegationStatusHandler, l as createDelegationHistoryHandler, m as DELEGATE_FEEDBACK_TOOL_NAME, n as DELEGATION_STATUS_INPUT_SCHEMA, o as DELEGATION_HISTORY_DESCRIPTION, p as DELEGATE_FEEDBACK_INPUT_SCHEMA, r as DELEGATION_STATUS_TOOL_NAME, s as DELEGATION_HISTORY_INPUT_SCHEMA, t as DELEGATION_STATUS_DESCRIPTION, u as validateDelegationHistoryArgs, v as eventToSnapshot } from "../delegation-status-CF4D0NZ_.js";
11
- import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "../openai-tools-DoQ32vpe.js";
12
- import { t as coderTaskToPrompt } from "../coder-yhVWbdWc.js";
13
- import { n as PlatformHubError } from "../integrations-dFi-ALk7.js";
14
- import { C as composeLoopTraceEmitters, S as capDelegationTrace, _ as FileDelegationStore, a as DELEGATE_UI_AUDIT_TOOL_NAME, b as DELEGATION_TRACE_MAX_SPANS, c as DELEGATE_DESCRIPTION, d as createDelegateHandler, f as validateDelegateArgs, g as DelegationStateCorruptError, h as DelegationPersistenceError, i as DELEGATE_UI_AUDIT_INPUT_SCHEMA, l as DELEGATE_INPUT_SCHEMA, m as hashIdempotencyInput, n as createMcpServer, o as createDelegateUiAuditHandler, p as DelegationTaskQueue, r as DELEGATE_UI_AUDIT_DESCRIPTION, s as validateDelegateUiAuditArgs, t as createInProcessTransport, u as DELEGATE_TOOL_NAME, v as InMemoryDelegationStore, w as createDelegationTraceCollector, x as buildDelegationTraceSpans, y as DELEGATION_TRACE_MAX_BYTES } from "../server-DQHJszfk.js";
15
- import { a as createMemoryToolServer, c as resolveMemoryFromEnv, i as MEMORY_NAME_ENV, n as MEMORY_ITEMS_ENV, o as parseMemoryItems, r as MEMORY_LOG_ENV, s as readMemoryItemsFile, t as MEMORY_FILE_ENV } from "../memory-server-DXQ8IxGR.js";
6
+ import { _ as environmentReader, r as createCoordinationTools, v as resolveSpawnResourcePaths } from "../driver-control-acknowledgers-C53ggdJ6.js";
7
+ import { n as createStdioToolServer } from "../tool-server-XV4aJwoQ.js";
8
+ import { ct as selectValidWinner, h as runCoderChecks } from "../runtime-B2fjL9Oi.js";
9
+ import { a as composeLoopTraceEmitters, i as FileDelegationStore, n as createDelegateHandler, r as DelegationTaskQueue, t as createMcpServer } from "../server-_4voDNrl.js";
16
10
  import { agentProfileSchema } from "@tangle-network/agent-interface";
17
11
  import { randomUUID } from "node:crypto";
12
+ //#region src/mcp/kb-gate.ts
13
+ const norm = (s) => s.toLowerCase().replace(/\s+/g, " ").trim();
14
+ /** Does `value` appear in the (normalized) passage — literally, comma-grouped,
15
+ * or in billion/million shorthand (the forms a source actually writes). */
16
+ function valueAppears(value, passageNorm) {
17
+ if (passageNorm.includes(norm(String(value)))) return true;
18
+ if (typeof value !== "number" || !Number.isFinite(value)) return false;
19
+ const forms = [value.toLocaleString("en-US")];
20
+ if (Math.abs(value) >= 1e9) forms.push(`${trimZero(value / 1e9)} billion`);
21
+ if (Math.abs(value) >= 1e6) forms.push(`${trimZero(value / 1e6)} million`);
22
+ return forms.some((f) => passageNorm.includes(norm(f)));
23
+ }
24
+ function trimZero(n) {
25
+ return Number.isInteger(n) ? String(n) : String(Number(n.toFixed(2)));
26
+ }
27
+ /** The always-on floor judges. Order matters: cheapest / most-fundamental first. */
28
+ function builtinJudges(minPassageChars, selfArtifactKinds) {
29
+ const kinds = selfArtifactKinds.map((k) => k.toLowerCase());
30
+ return [
31
+ {
32
+ name: "passage-non-empty",
33
+ judge: (c) => c.verbatimPassage.trim().length >= minPassageChars ? { accept: true } : {
34
+ accept: false,
35
+ reason: `passage shorter than ${minPassageChars} chars`
36
+ }
37
+ },
38
+ {
39
+ name: "passage-present",
40
+ judge: (c) => norm(c.sourceText).includes(norm(c.verbatimPassage)) ? { accept: true } : {
41
+ accept: false,
42
+ reason: "verbatim passage not found in source (unbacked fact)"
43
+ }
44
+ },
45
+ {
46
+ name: "value-in-passage",
47
+ judge: (c) => c.value === void 0 || valueAppears(c.value, norm(c.verbatimPassage)) ? { accept: true } : {
48
+ accept: false,
49
+ reason: `value ${JSON.stringify(c.value)} not present in passage`
50
+ }
51
+ },
52
+ {
53
+ name: "no-circular-citation",
54
+ judge: (c) => {
55
+ if (!c.citation || kinds.length === 0) return { accept: true };
56
+ const cite = c.citation.toLowerCase();
57
+ const hit = kinds.find((k) => cite.includes(k));
58
+ return hit ? {
59
+ accept: false,
60
+ reason: `circular citation to self-generated artifact "${hit}"`
61
+ } : { accept: true };
62
+ }
63
+ }
64
+ ];
65
+ }
66
+ /**
67
+ *
68
+ * Build a fail-closed KB gate. The returned function runs the built-in floor
69
+ * (passage-non-empty → passage-present → value-in-passage → no-circular-citation)
70
+ * then any consumer judges, returning on the first veto.
71
+ *
72
+ * @experimental
73
+ */
74
+ function createKbGate(options = {}) {
75
+ const judges = [...builtinJudges(options.minPassageChars ?? 12, options.selfArtifactKinds ?? []), ...options.judges ?? []];
76
+ return async (candidate) => {
77
+ for (const j of judges) {
78
+ const verdict = await j.judge(candidate);
79
+ if (!verdict.accept) return {
80
+ accepted: false,
81
+ vetoedBy: j.name,
82
+ reason: verdict.reason
83
+ };
84
+ }
85
+ return { accepted: true };
86
+ };
87
+ }
88
+ //#endregion
89
+ //#region src/profiles/coder.ts
90
+ /**
91
+ *
92
+ * `CoderTask` + `coderTaskToPrompt` — the per-task DATA + pure formatter for code-modification tasks
93
+ * (§1.5: the system authors profiles; there is no hardcoded coder profile constant). A domain
94
+ * customizes the worker by authoring its own `AgentProfile` and handing it to a leaf executor
95
+ * (`createWorktreeCliExecutor`) or a fanout (`worktreeFanout`); "is it delivered" is a
96
+ * `DeliverableSpec` (`patchDelivered`), not a bundled validator. This formatter renders a `CoderTask`
97
+ * into the per-task instruction that profile receives.
98
+ *
99
+ * @experimental
100
+ */
101
+ const DEFAULT_MAX_DIFF_LINES$1 = 400;
102
+ /** Render a `CoderTask` into the per-task instruction handed to the coder profile. @experimental */
103
+ function coderTaskToPrompt(task) {
104
+ const base = task.baseBranch ?? "main";
105
+ const testCmd = task.testCmd ?? "pnpm test --run";
106
+ const typecheckCmd = task.typecheckCmd ?? "pnpm typecheck";
107
+ const maxDiff = task.maxDiffLines ?? DEFAULT_MAX_DIFF_LINES$1;
108
+ const forbidden = task.forbiddenPaths?.length ? task.forbiddenPaths.join(", ") : "(none)";
109
+ const context = task.contextFiles?.length ? task.contextFiles.map((f) => ` - ${f}`).join("\n") : " (none)";
110
+ return [
111
+ `Goal: ${task.goal}`,
112
+ `Repo: ${task.repoRoot}`,
113
+ `Base branch: ${base}`,
114
+ `Run tests with: ${testCmd}`,
115
+ `Run typecheck with: ${typecheckCmd}`,
116
+ `Forbidden paths: ${forbidden}`,
117
+ `Max diff lines: ${maxDiff}`,
118
+ "Context files:",
119
+ context,
120
+ "",
121
+ "Produce a minimal patch on a fresh branch. Run tests and typecheck before",
122
+ "returning. Emit the final JSON result block exactly as instructed."
123
+ ].join("\n");
124
+ }
125
+ //#endregion
18
126
  //#region src/mcp/detached-coder.ts
19
127
  /**
20
128
  *
@@ -478,74 +586,6 @@ function createDetachedTurnTrace(options) {
478
586
  function detachedRunningPhase(elapsedMs) {
479
587
  return elapsedMs === void 0 ? "detached-running" : `detached-running ${Math.round(elapsedMs / 1e3)}s`;
480
588
  }
481
- /**
482
- * Build the `driveTurn`-backed {@link DelegationResumeDriver}. Each `tick()`
483
- * is one settle/poll/dispatch pass:
484
- *
485
- * - ref without a sandbox binding → `failed` (`DetachedSessionUnboundError`):
486
- * the previous process died before a box existed; there is nothing to resume.
487
- * - `driveTurn` `completed` → `settleOutput` → `completed` tick.
488
- * - `running` → progress via `ctx.report`, `running` tick (queue re-ticks
489
- * after `intervalMs`).
490
- * - `failed` → `failed` tick (`DetachedTurnFailedError`) — terminal per the
491
- * SDK's deterministic-failure contract.
492
- *
493
- * Abort: the queue stops ticking once `cancel()` flips the record, so remote
494
- * cancellation is hooked onto `ctx.signal` (once per task) and fires
495
- * `_sessionCancel` when the SDK surface exposes it. The driver never deletes
496
- * boxes — it cannot know whether `sandboxId` is a disposable sibling or a
497
- * fleet machine, and destroying a fleet machine would be unrecoverable.
498
- *
499
- * @experimental
500
- */
501
- function createDetachedTurnResumeDriver(options) {
502
- const cancelHooked = /* @__PURE__ */ new Set();
503
- return {
504
- intervalMs: options.intervalMs ?? DEFAULT_TICK_INTERVAL_MS,
505
- async tick({ record, detachedSessionRef }, ctx) {
506
- const ref = parseDetachedSessionRef(detachedSessionRef);
507
- if (ref.sandboxId === void 0) return {
508
- state: "failed",
509
- error: {
510
- message: `detached session "${ref.sessionId}" was never bound to a sandbox — the previous process died before the box was acquired, so the turn was never dispatched and cannot be resumed`,
511
- kind: "DetachedSessionUnboundError"
512
- }
513
- };
514
- const box = await options.resolveSandbox(ref.sandboxId);
515
- if (!cancelHooked.has(record.taskId)) {
516
- cancelHooked.add(record.taskId);
517
- ctx.signal.addEventListener("abort", () => {
518
- box._sessionCancel?.(ref.sessionId).catch(() => {});
519
- }, { once: true });
520
- }
521
- if (ctx.signal.aborted) throwAbort();
522
- const tick = await box.driveTurn(options.buildMessage(record), {
523
- sessionId: ref.sessionId,
524
- turnId: ref.sessionId,
525
- ...options.wallCapMs !== void 0 ? { wallCapMs: options.wallCapMs } : {}
526
- });
527
- if (tick.state === "completed") return {
528
- state: "completed",
529
- output: await options.settleOutput({
530
- text: tick.text,
531
- result: tick.result
532
- }, record, { signal: ctx.signal })
533
- };
534
- if (tick.state === "failed") return {
535
- state: "failed",
536
- error: {
537
- message: `detached turn ${ref.sessionId} failed: ${tick.error}`,
538
- kind: "DetachedTurnFailedError"
539
- }
540
- };
541
- ctx.report({
542
- iteration: 0,
543
- phase: detachedRunningPhase(tick.elapsedMs)
544
- });
545
- return { state: "running" };
546
- }
547
- };
548
- }
549
589
  //#endregion
550
590
  //#region src/mcp/executor.ts
551
591
  /**
@@ -934,128 +974,6 @@ function collidesWithHarnessNativeTool(name) {
934
974
  return sourcedHarnesses.filter((harness) => harnessNativeTools[harness].some((native) => native.toLowerCase() === wanted));
935
975
  }
936
976
  //#endregion
937
- //#region src/mcp/hub-server.ts
938
- /**
939
- * Hub integration MCP server — the user's connected databases and vector
940
- * stores as agent tools, mid-turn.
941
- *
942
- * The Tangle Platform Hub (`PlatformHubClient`, platform/integrations.ts)
943
- * already turns a provider credential into a per-user, per-action-policy'd,
944
- * approved, audited access surface: the user connects Pinecone/Qdrant/
945
- * Weaviate/Neon/Supabase/… once, and every later call goes through
946
- * `POST /v1/hub/exec`. This module is the thin bridge from that surface to
947
- * the agent's tool loop: for every ACTIVE connection to a data provider it
948
- * serves ONE router tool (`hub_<provider>`) whose `action` + `input`
949
- * arguments are dispatched to the provider's Hub adapter.
950
- *
951
- * Why one router tool per connection instead of one tool per adapter action:
952
- * the Hub catalog publishes capability counts, not capability schemas, so a
953
- * per-action tool surface would have to bundle the whole adapter registry.
954
- * The router tool keeps the layer thin — the Hub adapter IS the tool, the
955
- * Hub exec endpoint IS the invocation, and the Hub policy IS the permission.
956
- * Every call is policy-gated server-side; a denial surfaces to the agent as
957
- * the Hub's own error message. When the platform grows a capabilities
958
- * endpoint, per-action tools can be generated from it without changing this
959
- * module's contract.
960
- *
961
- * Tool lists are resolved at construction (session-scoped, like the memory
962
- * server): connections the user adds later appear after the server restarts.
963
- *
964
- * @experimental
965
- */
966
- /** The substrate data providers whose Hub adapters become agent tools. */
967
- const HUB_DATA_PROVIDER_KINDS = [
968
- "pinecone",
969
- "qdrant",
970
- "weaviate",
971
- "neon",
972
- "supabase",
973
- "mongodb",
974
- "postgres",
975
- "mysql",
976
- "redis"
977
- ];
978
- /** An action name: dot-separated identifiers — `vectors.query`, `branches.list`. */
979
- const ACTION_NAME_PATTERN = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/;
980
- const MCP_TOOL_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
981
- function toolNameFor(providerId, connectionId, taken) {
982
- const base = `hub_${providerId}`.replace(/[^A-Za-z0-9_-]/g, "-");
983
- const candidates = [base, `${base}-${connectionId.replace(/[^A-Za-z0-9_-]/g, "-").slice(0, 64 - base.length - 1)}`];
984
- for (const candidate of candidates) if (MCP_TOOL_NAME_PATTERN.test(candidate) && !taken.has(candidate)) {
985
- taken.add(candidate);
986
- return candidate;
987
- }
988
- throw new ValidationError(`hubIntegrationTools: cannot derive a unique tool name for connection '${connectionId}' of provider '${providerId}'`);
989
- }
990
- function connectionLabel(connection) {
991
- const account = connection.accountDisplay ? ` (${connection.accountDisplay})` : "";
992
- return `${connection.displayName || connection.providerId}${account}`;
993
- }
994
- /**
995
- * One router tool per active Hub connection to a data provider. The tool
996
- * handler never holds provider credentials — it execs through the Hub, which
997
- * enforces the per-user action policy and writes the audit record.
998
- */
999
- async function hubIntegrationTools(options) {
1000
- const providers = new Set(options.providers ?? HUB_DATA_PROVIDER_KINDS);
1001
- const eligible = (await options.client.listConnections()).filter((connection) => providers.has(connection.providerId) && connection.status === "active" && (options.includeUnhealthy === true || connection.health !== "unhealthy"));
1002
- const taken = /* @__PURE__ */ new Set();
1003
- return eligible.map((connection) => {
1004
- const providerId = connection.providerId;
1005
- const name = toolNameFor(providerId, connection.id, taken);
1006
- return {
1007
- name,
1008
- description: `Execute a ${providerId} action on the user's Hub connection '${connectionLabel(connection)}' (connection ${connection.id}). Pass action (e.g. "vectors.query", "branches.list", "collections.list") and its input object. Every call is policy-gated and audited by the Tangle Hub; a denied action returns the Hub's error message. Read actions list data; mutations may require prior approval.`,
1009
- inputSchema: {
1010
- type: "object",
1011
- properties: {
1012
- action: {
1013
- type: "string",
1014
- description: `The ${providerId} adapter action name, e.g. "vectors.query".`
1015
- },
1016
- input: {
1017
- type: "object",
1018
- description: "Arguments object for the action.",
1019
- additionalProperties: true
1020
- }
1021
- },
1022
- required: ["action"],
1023
- additionalProperties: false
1024
- },
1025
- handler: async (raw) => {
1026
- const args = raw ?? {};
1027
- if (typeof args.action !== "string" || !ACTION_NAME_PATTERN.test(args.action)) throw new TypeError(`${name}: action must be a provider action name like "vectors.query" (dot-separated, no path or spaces)`);
1028
- if (args.input !== void 0 && (typeof args.input !== "object" || args.input === null || Array.isArray(args.input))) throw new TypeError(`${name}: input must be an object of action arguments`);
1029
- const path = `${providerId}.${args.action}`;
1030
- try {
1031
- return await options.client.exec({
1032
- path,
1033
- input: args.input ?? {},
1034
- connectionId: connection.id
1035
- });
1036
- } catch (error) {
1037
- if (error instanceof PlatformHubError) throw new Error(`${name}: hub exec '${path}' failed (${error.status}${error.code ? ` ${error.code}` : ""}): ${error.message}`);
1038
- throw error;
1039
- }
1040
- }
1041
- };
1042
- });
1043
- }
1044
- /**
1045
- * Build the hub integration MCP server on the shared stdio JSON-RPC core —
1046
- * the same wire protocol every in-repo MCP server speaks. Serves zero tools
1047
- * when the caller has no active data-provider connections (a session without
1048
- * connections simply gets no database tools, mirroring the memory server's
1049
- * "no artifact, no server" discipline).
1050
- */
1051
- async function createHubIntegrationToolServer(options) {
1052
- return createStdioToolServer({
1053
- serverName: options.serverName ?? "agent-hub-integrations",
1054
- serverVersion: options.serverVersion ?? "0",
1055
- tools: await hubIntegrationTools(options)
1056
- });
1057
- }
1058
- //#endregion
1059
977
  //#region src/mcp/in-process-executor.ts
1060
978
  /**
1061
979
  *
@@ -1237,6 +1155,6 @@ async function defaultRunPostCheck(cmd, cwd, signal) {
1237
1155
  });
1238
1156
  }
1239
1157
  //#endregion
1240
- export { ANALYST_DEFINITION_BOUNDS, CodexExecutionDiagnosticError, DEFAULT_LOCAL_HARNESS, DELEGATE_DESCRIPTION, DELEGATE_FEEDBACK_DESCRIPTION, DELEGATE_FEEDBACK_INPUT_SCHEMA, DELEGATE_FEEDBACK_TOOL_NAME, DELEGATE_INPUT_SCHEMA, DELEGATE_TOOL_NAME, DELEGATE_UI_AUDIT_DESCRIPTION, DELEGATE_UI_AUDIT_INPUT_SCHEMA, DELEGATE_UI_AUDIT_TOOL_NAME, DELEGATION_HISTORY_DESCRIPTION, DELEGATION_HISTORY_INPUT_SCHEMA, DELEGATION_HISTORY_TOOL_NAME, DELEGATION_STATUS_DESCRIPTION, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, DELEGATION_TRACE_MAX_BYTES, DELEGATION_TRACE_MAX_SPANS, DelegationPersistenceError, DelegationStateCorruptError, DelegationTaskQueue, FileDelegationStore, HUB_DATA_PROVIDER_KINDS, InMemoryDelegationStore, InMemoryFeedbackStore, LOCAL_HARNESSES, MEMORY_FILE_ENV, MEMORY_ITEMS_ENV, MEMORY_LOG_ENV, MEMORY_NAME_ENV, SPAWN_RESOURCE_PATH_MAX_BYTES, SUPPORTED_PROTOCOL_VERSIONS, analystToolGroupNames, buildDelegationTraceSpans, capDelegationTrace, captureWorktreeDiff, coderTaskFromArgs, collidesWithHarnessNativeTool, composeLoopTraceEmitters, createCoordinationTools, createDelegateFeedbackHandler, createDelegateHandler, createDelegateUiAuditHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createDelegationTraceCollector, createDetachedTurnResumeDriver, createFleetWorkspaceExecutor, createHubIntegrationToolServer, createInProcessExecutor, createInProcessTransport, createKbGate, createMcpServer, createMemoryToolServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, createStdioToolServer, createWorktree, delegationProfiles, detachedSessionDelegate, detachedTurnEvents, downMessageRefusalReasons, environmentReader, eventToSnapshot, formatDetachedSessionRef, harnessNativeToolNames, harnessNativeTools, harnessSupportsReasoningEffort, hashIdempotencyInput, hostDirectoryReader, hubIntegrationTools, localHarnessExecutable, mcpToolsForRuntimeMcp, mcpToolsForRuntimeMcpSubset, mergeTraceEnv, parseAuthoredAnalystDefinition, parseCodexTokenUsage, parseDetachedSessionRef, parseMemoryItems, questionEscalationTargets, readMemoryItemsFile, readTraceContextFromEnv, removeWorktree, resolveMemoryFromEnv, resolveSpawnResourcePaths, runDetachedTurn, settleDetachedCoderTurn, sourcedHarnesses, traceContextToEnv, validateDelegateArgs, validateDelegateFeedbackArgs, validateDelegateUiAuditArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
1158
+ export { DelegationTaskQueue, FileDelegationStore, LOCAL_HARNESSES, collidesWithHarnessNativeTool, composeLoopTraceEmitters, createCoordinationTools, createDelegateHandler, createFleetWorkspaceExecutor, createInProcessExecutor, createKbGate, createMcpServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, createStdioToolServer, detachedSessionDelegate, environmentReader, harnessNativeToolNames, readTraceContextFromEnv, resolveSpawnResourcePaths, runDetachedTurn };
1241
1159
 
1242
1160
  //# sourceMappingURL=index.js.map