@tangle-network/agent-runtime 0.71.1 → 0.72.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/README.md +8 -8
- package/dist/agent.d.ts +27 -17
- package/dist/agent.js +19 -8
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/{chunk-5ISW5JUF.js → chunk-55WKGOGU.js} +1907 -6534
- package/dist/chunk-55WKGOGU.js.map +1 -0
- package/dist/{chunk-K3RM4MPM.js → chunk-HXVMLRYU.js} +5 -20
- package/dist/chunk-HXVMLRYU.js.map +1 -0
- package/dist/chunk-PBE35ULD.js +52 -0
- package/dist/chunk-PBE35ULD.js.map +1 -0
- package/dist/chunk-PHKNOAOU.js +4021 -0
- package/dist/chunk-PHKNOAOU.js.map +1 -0
- package/dist/chunk-UZ5SODU7.js +29 -0
- package/dist/chunk-UZ5SODU7.js.map +1 -0
- package/dist/{chunk-4KGQHS7U.js → chunk-VYXBFWHZ.js} +2 -18
- package/dist/chunk-VYXBFWHZ.js.map +1 -0
- package/dist/{delegates-CsXJPZDH.d.ts → coordination-CFVF0OzX.d.ts} +869 -1099
- package/dist/index.d.ts +7 -8
- package/dist/index.js +4 -7
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +1 -1
- package/dist/{loop-runner-bin-DLM_bVQO.d.ts → loop-runner-bin-B7biH0Gk.d.ts} +10 -27
- package/dist/loop-runner-bin.d.ts +5 -6
- package/dist/loop-runner-bin.js +3 -4
- package/dist/loops.d.ts +10 -9
- package/dist/loops.js +43 -41
- package/dist/mcp/bin.js +13 -326
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +10 -190
- package/dist/mcp/index.js +948 -47
- package/dist/mcp/index.js.map +1 -1
- package/dist/{openai-tools-kdCS-T12.d.ts → openai-tools-DOI5mKNw.d.ts} +11 -13
- package/dist/otel-export-BKmNwiCb.d.ts +180 -0
- package/dist/profiles.d.ts +3 -3
- package/dist/profiles.js +1 -5
- package/dist/profiles.js.map +1 -1
- package/dist/{substrate-BoRXgvka.d.ts → substrate-rNj6TDc3.d.ts} +7 -23
- package/dist/{types-CdnEAE3U.d.ts → types-K8-xkiw1.d.ts} +1 -1
- package/dist/worktree-JXGJ1MxQ.d.ts +702 -0
- package/dist/{worktree-fanout-CK2ypmEm.d.ts → worktree-fanout-DJHQy7Ux.d.ts} +2 -2
- package/package.json +1 -1
- package/dist/chunk-4KGQHS7U.js.map +0 -1
- package/dist/chunk-5ISW5JUF.js.map +0 -1
- package/dist/chunk-74UAWZXE.js +0 -278
- package/dist/chunk-74UAWZXE.js.map +0 -1
- package/dist/chunk-DVQGYDN5.js +0 -59
- package/dist/chunk-DVQGYDN5.js.map +0 -1
- package/dist/chunk-INXDNX2W.js +0 -475
- package/dist/chunk-INXDNX2W.js.map +0 -1
- package/dist/chunk-K3RM4MPM.js.map +0 -1
- package/dist/chunk-XRYEZPR6.js +0 -88
- package/dist/chunk-XRYEZPR6.js.map +0 -1
- package/dist/coordination-BPQmuwv8.d.ts +0 -666
- package/dist/delegation-profile-Bvfro2m1.d.ts +0 -99
package/dist/chunk-XRYEZPR6.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
// src/mcp/delegation-profile.ts
|
|
2
|
-
var DELEGATION_MCP_SERVER_KEY = "agent-runtime-delegation";
|
|
3
|
-
var OTEL_FORWARD_KEYS = [
|
|
4
|
-
"OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
5
|
-
"OTEL_EXPORTER_OTLP_HEADERS",
|
|
6
|
-
"TRACE_ID",
|
|
7
|
-
"PARENT_SPAN_ID"
|
|
8
|
-
];
|
|
9
|
-
var DEFAULT_SANDBOX_BASE_URL = "https://sandbox.tangle.tools";
|
|
10
|
-
function buildDelegationMcpServer(options = {}) {
|
|
11
|
-
const env = options.env ?? process.env;
|
|
12
|
-
const sandboxApiKey = options.sandboxApiKey ?? env.TANGLE_API_KEY;
|
|
13
|
-
if (!sandboxApiKey) return void 0;
|
|
14
|
-
const baseUrl = options.sandboxBaseUrl ?? env.SANDBOX_BASE_URL ?? env.SANDBOX_API_URL ?? DEFAULT_SANDBOX_BASE_URL;
|
|
15
|
-
const otelEnv = {};
|
|
16
|
-
for (const key of OTEL_FORWARD_KEYS) {
|
|
17
|
-
const value = env[key];
|
|
18
|
-
if (value) otelEnv[key] = value;
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
[DELEGATION_MCP_SERVER_KEY]: {
|
|
22
|
-
transport: "stdio",
|
|
23
|
-
command: "npx",
|
|
24
|
-
args: ["-y", "@tangle-network/agent-runtime", "mcp"],
|
|
25
|
-
env: {
|
|
26
|
-
TANGLE_API_KEY: sandboxApiKey,
|
|
27
|
-
SANDBOX_BASE_URL: baseUrl,
|
|
28
|
-
...otelEnv
|
|
29
|
-
},
|
|
30
|
-
enabled: true,
|
|
31
|
-
metadata: {
|
|
32
|
-
surface: "delegation:dispatch",
|
|
33
|
-
tools: [
|
|
34
|
-
"delegate_code",
|
|
35
|
-
"delegate_research",
|
|
36
|
-
"delegate_feedback",
|
|
37
|
-
"delegation_status",
|
|
38
|
-
"delegation_history"
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function composeProductionAgentProfile(baseProfile, options = {}) {
|
|
45
|
-
const delegationMcp = buildDelegationMcpServer({
|
|
46
|
-
sandboxApiKey: options.sandboxApiKey,
|
|
47
|
-
sandboxBaseUrl: options.sandboxBaseUrl,
|
|
48
|
-
env: options.env
|
|
49
|
-
});
|
|
50
|
-
const baseMcp = baseProfile.mcp ?? {};
|
|
51
|
-
const withInjected = options.mcpConnections ? { ...baseMcp, ...options.mcpConnections } : { ...baseMcp };
|
|
52
|
-
const mergedMcp = delegationMcp ? { ...withInjected, ...delegationMcp } : withInjected;
|
|
53
|
-
const baseFiles = baseProfile.resources?.files ?? [];
|
|
54
|
-
const mergedFiles = options.extraFiles?.length ? [...baseFiles, ...options.extraFiles] : [...baseFiles];
|
|
55
|
-
const prompt = options.systemPrompt ? { ...baseProfile.prompt, systemPrompt: options.systemPrompt } : baseProfile.prompt;
|
|
56
|
-
const mergedTools = options.tools ? { ...baseProfile.tools ?? {}, ...options.tools } : baseProfile.tools;
|
|
57
|
-
const mergedHooks = mergeHooks(baseProfile.hooks, options.hooks);
|
|
58
|
-
const mergedSubagents = options.subagents ? { ...baseProfile.subagents ?? {}, ...options.subagents } : baseProfile.subagents;
|
|
59
|
-
return {
|
|
60
|
-
...baseProfile,
|
|
61
|
-
name: options.name ?? baseProfile.name,
|
|
62
|
-
prompt,
|
|
63
|
-
...mergedTools ? { tools: mergedTools } : {},
|
|
64
|
-
...mergedHooks ? { hooks: mergedHooks } : {},
|
|
65
|
-
...mergedSubagents ? { subagents: mergedSubagents } : {},
|
|
66
|
-
mcp: mergedMcp,
|
|
67
|
-
resources: {
|
|
68
|
-
...baseProfile.resources,
|
|
69
|
-
files: mergedFiles
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function mergeHooks(base, overlay) {
|
|
74
|
-
if (!overlay) return base;
|
|
75
|
-
const merged = { ...base ?? {} };
|
|
76
|
-
for (const [event, commands] of Object.entries(overlay)) {
|
|
77
|
-
merged[event] = [...merged[event] ?? [], ...commands];
|
|
78
|
-
}
|
|
79
|
-
return merged;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export {
|
|
83
|
-
DELEGATION_MCP_SERVER_KEY,
|
|
84
|
-
DEFAULT_SANDBOX_BASE_URL,
|
|
85
|
-
buildDelegationMcpServer,
|
|
86
|
-
composeProductionAgentProfile
|
|
87
|
-
};
|
|
88
|
-
//# sourceMappingURL=chunk-XRYEZPR6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mcp/delegation-profile.ts"],"sourcesContent":["/**\n * Production-profile composition for the agent-runtime delegation MCP.\n *\n * A product agent's sandbox loads the delegation tools (`delegate_code`,\n * `delegate_research`, `delegate_feedback`, `delegation_status`,\n * `delegation_history`) by mounting the `agent-runtime-mcp` stdio server as\n * an MCP entry in its `AgentProfile`. This module is the single composer for\n * that wiring, so every consumer — the fleet agents and agent-builder's\n * generated agents — shares one implementation instead of copying it.\n *\n * The load-bearing invariant: the delegation MCP entry is only ever emitted\n * when a sandbox API key is present. Without the key the kernel's\n * coder/researcher delegate cannot construct an authenticated sandbox client,\n * so we omit the entry rather than ship an MCP child that fails to\n * authenticate on startup. No static profile entry, ever.\n */\n\nimport type {\n AgentProfile,\n AgentProfileFileMount,\n AgentProfileMcpServer,\n AgentSubagentProfile,\n} from '@tangle-network/sandbox'\n\n/** One hook command entry. The SDK declares `AgentProfile.hooks` as\n * `Record<string, AgentProfileHookCommand[]>` but does not re-export the element\n * type from the package entry, so derive it from `AgentProfile` by indexed\n * access — the single source of truth, no drift from the SDK shape. */\ntype AgentProfileHookCommand = NonNullable<AgentProfile['hooks']>[string][number]\n\n/** MCP server key under which the agent-runtime delegation tools mount. */\nexport const DELEGATION_MCP_SERVER_KEY = 'agent-runtime-delegation'\n\n/**\n * Env vars forwarded into the delegation MCP child so its delegated\n * build/research loops export topology spans to the configured OTLP /\n * Tangle Intelligence sink. Each is forwarded only when present, so the\n * child is a no-op exporter until `OTEL_EXPORTER_OTLP_ENDPOINT` is set in the\n * parent env — never a hardcoded endpoint.\n */\nconst OTEL_FORWARD_KEYS = [\n 'OTEL_EXPORTER_OTLP_ENDPOINT',\n 'OTEL_EXPORTER_OTLP_HEADERS',\n 'TRACE_ID',\n 'PARENT_SPAN_ID',\n] as const\n\nexport const DEFAULT_SANDBOX_BASE_URL = 'https://sandbox.tangle.tools'\n\nexport interface BuildDelegationMcpServerOptions {\n /** Sandbox API key forwarded as `TANGLE_API_KEY` to the MCP child. The\n * agent-runtime MCP bin reads `TANGLE_API_KEY` and passes it straight to\n * `new Sandbox({ apiKey })`. Defaults to `env.TANGLE_API_KEY`. */\n sandboxApiKey?: string\n /** Sandbox base URL forwarded as `SANDBOX_BASE_URL`. Defaults to\n * `env.SANDBOX_BASE_URL`, then `env.SANDBOX_API_URL`, then the public\n * sandbox endpoint. */\n sandboxBaseUrl?: string\n /** Environment source for key + OTEL resolution. Defaults to `process.env`;\n * injectable for tests and non-process callers. */\n env?: Record<string, string | undefined>\n}\n\n/**\n * Build the delegation MCP entry the sandbox-side agent loads on startup.\n * Returns `undefined` when no sandbox API key is resolvable — callers merge\n * the result into a profile's `mcp` map only when defined.\n */\nexport function buildDelegationMcpServer(\n options: BuildDelegationMcpServerOptions = {},\n): Record<string, AgentProfileMcpServer> | undefined {\n const env = options.env ?? process.env\n const sandboxApiKey = options.sandboxApiKey ?? env.TANGLE_API_KEY\n if (!sandboxApiKey) return undefined\n const baseUrl =\n options.sandboxBaseUrl ??\n env.SANDBOX_BASE_URL ??\n env.SANDBOX_API_URL ??\n DEFAULT_SANDBOX_BASE_URL\n\n const otelEnv: Record<string, string> = {}\n for (const key of OTEL_FORWARD_KEYS) {\n const value = env[key]\n if (value) otelEnv[key] = value\n }\n\n return {\n [DELEGATION_MCP_SERVER_KEY]: {\n transport: 'stdio',\n command: 'npx',\n args: ['-y', '@tangle-network/agent-runtime', 'mcp'],\n env: {\n TANGLE_API_KEY: sandboxApiKey,\n SANDBOX_BASE_URL: baseUrl,\n ...otelEnv,\n },\n enabled: true,\n metadata: {\n surface: 'delegation:dispatch',\n tools: [\n 'delegate_code',\n 'delegate_research',\n 'delegate_feedback',\n 'delegation_status',\n 'delegation_history',\n ],\n },\n },\n }\n}\n\nexport interface ComposeProductionAgentProfileOptions {\n /** Sandbox API key forwarded to the delegation MCP child. Defaults to\n * `env.TANGLE_API_KEY`. When unset, the delegation MCP entry is omitted. */\n sandboxApiKey?: string\n /** Sandbox base URL forwarded as `SANDBOX_BASE_URL` to the MCP child. */\n sandboxBaseUrl?: string\n /** Replace the base profile's system prompt. Used by per-turn calls that\n * swap in workspace-augmented prompts (board summary, learned style). */\n systemPrompt?: string\n /** Extra file mounts layered after the base profile's `resources.files`. */\n extraFiles?: AgentProfileFileMount[]\n /** Override the profile `name`. Defaults to the base profile's name. */\n name?: string\n /** Environment source for key + OTEL resolution. Defaults to `process.env`. */\n env?: Record<string, string | undefined>\n /** Box built-in tool ON/OFF flags merged over the base profile's `tools`\n * (overlay wins per key). The sandbox-seam mapping of a certified surface's\n * tool grants — `AgentProfile.tools` is `Record<string, boolean>` box flags,\n * so it carries grants, not arbitrary tool defs. */\n tools?: Record<string, boolean>\n /** Per-event hook commands merged over the base profile's `hooks`. An event\n * present in both has the extra commands appended after the base ones. */\n hooks?: Record<string, AgentProfileHookCommand[]>\n /** Subagent definitions merged over the base profile's `subagents` (overlay\n * wins per key). */\n subagents?: Record<string, AgentSubagentProfile>\n /** Resolved certified MCP connections injected into `AgentProfile.mcp` — the\n * sandbox-seam delivery of a `ResolvedSurface.mcpConnections`. Merged after\n * the base map and before the delegation entry, so a base/delegation key is\n * never silently shadowed by an injected one. */\n mcpConnections?: Record<string, AgentProfileMcpServer>\n}\n\n/**\n * Compose the production `AgentProfile`: the canonical base profile with the\n * delegation MCP merged into `mcp`. Used by every call site that boots a\n * sandbox or runs a chat turn through the sandbox path, and by eval wiring so\n * the scorecard profile hash reflects the actual production profile.\n *\n * Merge rules:\n * - `mcp`: base map preserved; `options.mcpConnections` (resolved certified\n * servers) merged over it; the delegation entry is appended last under\n * {@link DELEGATION_MCP_SERVER_KEY}, and omitted entirely when no sandbox\n * API key resolves.\n * - `tools`: base box-flags map preserved; `options.tools` overlaid per key.\n * - `hooks`: per event, base commands preserved; `options.hooks[event]`\n * appended after the base ones.\n * - `subagents`: base map preserved; `options.subagents` overlaid per key.\n * - `prompt.systemPrompt`: replaced when `options.systemPrompt` is set.\n * - `resources.files`: `options.extraFiles` concatenated after base files.\n * - `name`: replaced when `options.name` is set.\n */\nexport function composeProductionAgentProfile(\n baseProfile: AgentProfile,\n options: ComposeProductionAgentProfileOptions = {},\n): AgentProfile {\n const delegationMcp = buildDelegationMcpServer({\n sandboxApiKey: options.sandboxApiKey,\n sandboxBaseUrl: options.sandboxBaseUrl,\n env: options.env,\n })\n\n const baseMcp = baseProfile.mcp ?? {}\n const withInjected: Record<string, AgentProfileMcpServer> = options.mcpConnections\n ? { ...baseMcp, ...options.mcpConnections }\n : { ...baseMcp }\n const mergedMcp: Record<string, AgentProfileMcpServer> = delegationMcp\n ? { ...withInjected, ...delegationMcp }\n : withInjected\n\n const baseFiles = baseProfile.resources?.files ?? []\n const mergedFiles: AgentProfileFileMount[] = options.extraFiles?.length\n ? [...baseFiles, ...options.extraFiles]\n : [...baseFiles]\n\n const prompt = options.systemPrompt\n ? { ...baseProfile.prompt, systemPrompt: options.systemPrompt }\n : baseProfile.prompt\n\n const mergedTools = options.tools\n ? { ...(baseProfile.tools ?? {}), ...options.tools }\n : baseProfile.tools\n\n const mergedHooks = mergeHooks(baseProfile.hooks, options.hooks)\n\n const mergedSubagents = options.subagents\n ? { ...(baseProfile.subagents ?? {}), ...options.subagents }\n : baseProfile.subagents\n\n return {\n ...baseProfile,\n name: options.name ?? baseProfile.name,\n prompt,\n ...(mergedTools ? { tools: mergedTools } : {}),\n ...(mergedHooks ? { hooks: mergedHooks } : {}),\n ...(mergedSubagents ? { subagents: mergedSubagents } : {}),\n mcp: mergedMcp,\n resources: {\n ...baseProfile.resources,\n files: mergedFiles,\n },\n }\n}\n\n/** Merge per-event hook command lists: base commands first, overlay commands\n * appended after. Returns the base map unchanged when no overlay is given. */\nfunction mergeHooks(\n base: Record<string, AgentProfileHookCommand[]> | undefined,\n overlay: Record<string, AgentProfileHookCommand[]> | undefined,\n): Record<string, AgentProfileHookCommand[]> | undefined {\n if (!overlay) return base\n const merged: Record<string, AgentProfileHookCommand[]> = { ...(base ?? {}) }\n for (const [event, commands] of Object.entries(overlay)) {\n merged[event] = [...(merged[event] ?? []), ...commands]\n }\n return merged\n}\n"],"mappings":";AA+BO,IAAM,4BAA4B;AASzC,IAAM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