@tangle-network/agent-runtime 0.338.0 → 0.340.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{activation-kbkAuSmY.js → activation-D2PVljaw.js} +5 -18
- package/dist/{activation-kbkAuSmY.js.map → activation-D2PVljaw.js.map} +1 -1
- package/dist/{activation-CsbNax2X.d.ts → activation-DGDl4wwI.d.ts} +4 -24
- package/dist/agent.d.ts +4 -18
- package/dist/agent.js +3 -21
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +2 -2
- package/dist/{bundle-DM60AI2B.js → bundle-DNUq-OPW.js} +2 -2
- package/dist/{bundle-DM60AI2B.js.map → bundle-DNUq-OPW.js.map} +1 -1
- package/dist/candidate-execution/index.d.ts +4 -101
- package/dist/candidate-execution/index.js +10 -395
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/{delegate-Se1YZKMb.js → delegate-CtJIS-tp.js} +2 -2
- package/dist/{delegate-Se1YZKMb.js.map → delegate-CtJIS-tp.js.map} +1 -1
- package/dist/{driver-control-acknowledgers-T2a1Ouay.js → driver-control-acknowledgers-MTrs8HAF.js} +15 -11
- package/dist/driver-control-acknowledgers-MTrs8HAF.js.map +1 -0
- package/dist/{durable-file-B_eJr6Mb.js → durable-file-gNI9ILAn.js} +1 -3
- package/dist/durable-file-gNI9ILAn.js.map +1 -0
- package/dist/durable.d.ts +3 -35
- package/dist/durable.js +10 -10
- package/dist/durable.js.map +1 -1
- package/dist/{graph-CY0wH838.js → graph-DfWqp_1e.js} +4 -4
- package/dist/graph-DfWqp_1e.js.map +1 -0
- package/dist/{graph-registry-By0tUj4S.js → graph-registry-BnO64cn8.js} +3 -3
- package/dist/{graph-registry-By0tUj4S.js.map → graph-registry-BnO64cn8.js.map} +1 -1
- package/dist/{improve-CWGBT13K.js → improve-CKRVQqzt.js} +8 -35
- package/dist/improve-CKRVQqzt.js.map +1 -0
- package/dist/{improvement-adapter-D5gwwoXQ.d.ts → improvement-adapter-sIthWkcN.d.ts} +3 -21
- package/dist/index.d.ts +10 -215
- package/dist/index.js +91 -302
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +11 -143
- package/dist/intelligence.js +7 -81
- package/dist/intelligence.js.map +1 -1
- package/dist/{jsonl-file-DBv31uPi.js → jsonl-file-C9Kde_0Z.js} +2 -2
- package/dist/{jsonl-file-DBv31uPi.js.map → jsonl-file-C9Kde_0Z.js.map} +1 -1
- package/dist/kernel.d.ts +4 -3
- package/dist/kernel.js +12 -14
- package/dist/loop-runner-C4EWEcXf.d.ts +32 -0
- package/dist/loop-runner-DNWbTcVm.js +59 -0
- package/dist/loop-runner-DNWbTcVm.js.map +1 -0
- package/dist/loop-runner-bin.d.ts +32 -2
- package/dist/loop-runner-bin.js +93 -1
- package/dist/loop-runner-bin.js.map +1 -0
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +99 -418
- package/dist/mcp/index.js +121 -203
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.js +231 -1
- package/dist/mcp/memory-bin.js.map +1 -1
- package/dist/model-policy-CyCUwHed.js.map +1 -1
- package/dist/placement.d.ts +2 -33
- package/dist/placement.js +1 -35
- package/dist/placement.js.map +1 -1
- package/dist/platform.d.ts +188 -1
- package/dist/platform.js +129 -1
- package/dist/platform.js.map +1 -1
- package/dist/{prepare-Bt0IouPq.js → prepare-FzJoS68l.js} +8 -160
- package/dist/prepare-FzJoS68l.js.map +1 -0
- package/dist/{profile-Do-5xO_D.js → profile-DToH0XEs.js} +2 -2
- package/dist/profile-DToH0XEs.js.map +1 -0
- package/dist/profile-materialization-bPm0gGLO.d.ts +49 -0
- package/dist/profiles.d.ts +2 -2
- package/dist/profiles.js +3 -40
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-DGxQ8_YM.d.ts → protected-model-port-DVVh-hEk.d.ts} +3 -33
- package/dist/protected-redaction-DFCeo4vg.js.map +1 -1
- package/dist/{provision-supervisor-0jMufp4h.js → provision-supervisor-DqvWXmAE.js} +6 -6
- package/dist/{provision-supervisor-0jMufp4h.js.map → provision-supervisor-DqvWXmAE.js.map} +1 -1
- package/dist/{run-cancellation-BoW5Sg9Y.js → run-cancellation-C9oL62sW.js} +3 -7
- package/dist/{run-cancellation-BoW5Sg9Y.js.map → run-cancellation-C9oL62sW.js.map} +1 -1
- package/dist/{runtime-D37zRSs7.js → runtime-C55Zgo1R.js} +2531 -2889
- package/dist/runtime-C55Zgo1R.js.map +1 -0
- package/dist/{runtime-hooks-Bj6wJHlH.d.ts → runtime-hooks-nsqxSUFL.d.ts} +2 -6
- package/dist/{sandbox-profile-compat-xSoVtdWw.js → sandbox-profile-compat-DRr3JwDx.js} +2 -4
- package/dist/sandbox-profile-compat-DRr3JwDx.js.map +1 -0
- package/dist/{search-executor-DmgUm5p7.js → search-executor-ChOlRBgg.js} +3 -3
- package/dist/search-executor-ChOlRBgg.js.map +1 -0
- package/dist/{server-DQHJszfk.js → server-DkVBSN_S.js} +362 -67
- package/dist/server-DkVBSN_S.js.map +1 -0
- package/dist/{structural-rollout-DAvIE8mw.js → structural-rollout-C1LEk_zq.js} +80 -80
- package/dist/structural-rollout-C1LEk_zq.js.map +1 -0
- package/dist/{substrate-B0TYNrXn.js → substrate-CGDFTSRh.js} +2 -9
- package/dist/substrate-CGDFTSRh.js.map +1 -0
- package/dist/{supervise-WuPAwfPh.js → supervise-CaUAxZZP.js} +92 -75
- package/dist/supervise-CaUAxZZP.js.map +1 -0
- package/dist/{supervisor-CPG1I9UN.js → supervisor-VXuN2OHT.js} +205 -319
- package/dist/supervisor-VXuN2OHT.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +13 -13
- package/dist/testing.js.map +1 -1
- package/dist/tool-loop.d.ts +1 -1
- package/dist/{tool-server-Dqer2M4_.js → tool-server-XV4aJwoQ.js} +2 -2
- package/dist/tool-server-XV4aJwoQ.js.map +1 -0
- package/dist/top-snapshot-CbZE1JsU.js +502 -0
- package/dist/top-snapshot-CbZE1JsU.js.map +1 -0
- package/dist/tui/bin.js +711 -1
- package/dist/tui/bin.js.map +1 -1
- package/dist/tui/index.d.ts +2 -70
- package/dist/tui/index.js +3 -3
- package/dist/{types-zWfqDjeL.d.ts → types-Cwrea-bU.d.ts} +2 -17
- package/dist/{types-CrNWif8-.d.ts → types-DZ6L0Bv3.d.ts} +765 -2152
- package/dist/workspace-store/index.d.ts +1 -107
- package/dist/workspace-store/index.js +1 -415
- package/dist/workspace-store/index.js.map +1 -1
- package/dist/{workspace-streams-BZZds1Fw.d.ts → workspace-streams-BiS4ABah.d.ts} +3 -18
- package/package.json +1 -1
- package/skills/agent-graphs/references/authoring.md +3 -2
- package/dist/coder-yhVWbdWc.js +0 -40
- package/dist/coder-yhVWbdWc.js.map +0 -1
- package/dist/delegation-status-CF4D0NZ_.js +0 -358
- package/dist/delegation-status-CF4D0NZ_.js.map +0 -1
- package/dist/driver-control-acknowledgers-T2a1Ouay.js.map +0 -1
- package/dist/durable-file-B_eJr6Mb.js.map +0 -1
- package/dist/graph-CY0wH838.js.map +0 -1
- package/dist/improve-CWGBT13K.js.map +0 -1
- package/dist/integrations-6xttbPi9.d.ts +0 -190
- package/dist/integrations-dFi-ALk7.js +0 -132
- package/dist/integrations-dFi-ALk7.js.map +0 -1
- package/dist/kb-gate-C8z2juK8.d.ts +0 -80
- package/dist/kb-gate-DpaSwXVx.js +0 -80
- package/dist/kb-gate-DpaSwXVx.js.map +0 -1
- package/dist/loop-runner-bin-CFnrAHpl.d.ts +0 -164
- package/dist/loop-runner-bin-CdPlhy9g.js +0 -246
- package/dist/loop-runner-bin-CdPlhy9g.js.map +0 -1
- package/dist/memory-server-DXQ8IxGR.js +0 -234
- package/dist/memory-server-DXQ8IxGR.js.map +0 -1
- package/dist/openai-tools-DoQ32vpe.js +0 -44
- package/dist/openai-tools-DoQ32vpe.js.map +0 -1
- package/dist/openai-tools-zh2I_uD7.d.ts +0 -24
- package/dist/prepare-Bt0IouPq.js.map +0 -1
- package/dist/profile-Do-5xO_D.js.map +0 -1
- package/dist/profile-materialization-BnoEf1co.d.ts +0 -96
- package/dist/runtime-D37zRSs7.js.map +0 -1
- package/dist/sandbox-profile-compat-xSoVtdWw.js.map +0 -1
- package/dist/search-executor-DmgUm5p7.js.map +0 -1
- package/dist/server-DQHJszfk.js.map +0 -1
- package/dist/structural-rollout-DAvIE8mw.js.map +0 -1
- package/dist/substrate-B0TYNrXn.js.map +0 -1
- package/dist/supervise-WuPAwfPh.js.map +0 -1
- package/dist/supervisor-CPG1I9UN.js.map +0 -1
- package/dist/tool-server-Dqer2M4_.js.map +0 -1
- package/dist/top-app-C55Wa7uy.js +0 -1214
- package/dist/top-app-C55Wa7uy.js.map +0 -1
package/dist/mcp/index.js
CHANGED
|
@@ -1,20 +1,128 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cr as LOCAL_HARNESSES, Sr as runWorktreeHarness, nn as createPropagatingTraceEmitter, rn as readTraceContextFromEnv, vt as runAgentRounds, xt as createSandboxForSpec, yt as assertBoxlessPromptOptions } from "../supervisor-VXuN2OHT.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 {
|
|
4
|
+
import { Y as deleteBoxSafe, lt as throwIfAborted, ot as sleep } from "../sandbox-profile-compat-DRr3JwDx.js";
|
|
5
5
|
import { t as assertExecutableAgentProfile } from "../model-policy-CyCUwHed.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
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-MTrs8HAF.js";
|
|
7
|
+
import { n as createStdioToolServer } from "../tool-server-XV4aJwoQ.js";
|
|
8
|
+
import { ct as selectValidWinner, h as runCoderChecks } from "../runtime-C55Zgo1R.js";
|
|
9
|
+
import { a as composeLoopTraceEmitters, i as FileDelegationStore, n as createDelegateHandler, r as DelegationTaskQueue, t as createMcpServer } from "../server-DkVBSN_S.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 {
|
|
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
|