@tangle-network/agent-runtime 0.52.0 → 0.53.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/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/{chunk-7SP2OVYZ.js → chunk-5M2WDWBI.js} +3 -3
- package/dist/{chunk-4JI4BCBI.js → chunk-AYRQZRDV.js} +2 -2
- package/dist/{chunk-BERLUBAP.js → chunk-FO4DCM7R.js} +2 -2
- package/dist/{chunk-7JITYN6T.js → chunk-JFIYKDXF.js} +17 -2
- package/dist/chunk-JFIYKDXF.js.map +1 -0
- package/dist/{chunk-COAVO6QB.js → chunk-K5M3SHEU.js} +3 -3
- package/dist/{chunk-2OU7ZQPD.js → chunk-K6WP7PYW.js} +42 -57
- package/dist/chunk-K6WP7PYW.js.map +1 -0
- package/dist/{chunk-V2K35HF2.js → chunk-P4QNEXFC.js} +2 -2
- package/dist/{coder-_YCf3BAK.d.ts → coder-LKm3Mczw.d.ts} +1 -1
- package/dist/{delegation-profile-1GbW5yA3.d.ts → delegation-profile-Bvfro2m1.d.ts} +28 -2
- package/dist/{driver-DLI1io57.d.ts → driver-B2RKkVJW.d.ts} +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +475 -5
- package/dist/intelligence.js +547 -3
- package/dist/intelligence.js.map +1 -1
- package/dist/{kb-gate-CHAyt4aI.d.ts → kb-gate-CKfykcYQ.d.ts} +2 -2
- package/dist/{loop-runner-bin-DFUNgpeK.d.ts → loop-runner-bin-D4Ir7b00.d.ts} +4 -4
- package/dist/loop-runner-bin.d.ts +5 -5
- package/dist/loop-runner-bin.js +3 -3
- package/dist/loops.d.ts +6 -5
- package/dist/loops.js +1 -1
- package/dist/mcp/bin.js +4 -4
- package/dist/mcp/index.d.ts +7 -7
- package/dist/mcp/index.js +6 -6
- package/dist/{openai-tools-D4HLDWgw.d.ts → openai-tools-CKfR3EMh.d.ts} +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/router-client-B0Qi1NiN.d.ts +120 -0
- package/dist/{run-loop-BIineL1T.d.ts → run-loop-DgVhucoR.d.ts} +1 -1
- package/dist/runtime.d.ts +16 -119
- package/dist/runtime.js +1 -1
- package/dist/{types-5MGt5KTY.d.ts → types-CNDJCL_0.d.ts} +1 -1
- package/dist/{types-BEQsBhOE.d.ts → types-CklkW4Eh.d.ts} +2 -1
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2OU7ZQPD.js.map +0 -1
- package/dist/chunk-7JITYN6T.js.map +0 -1
- /package/dist/{chunk-7SP2OVYZ.js.map → chunk-5M2WDWBI.js.map} +0 -0
- /package/dist/{chunk-4JI4BCBI.js.map → chunk-AYRQZRDV.js.map} +0 -0
- /package/dist/{chunk-BERLUBAP.js.map → chunk-FO4DCM7R.js.map} +0 -0
- /package/dist/{chunk-COAVO6QB.js.map → chunk-K5M3SHEU.js.map} +0 -0
- /package/dist/{chunk-V2K35HF2.js.map → chunk-P4QNEXFC.js.map} +0 -0
package/dist/agent.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as _tangle_network_agent_eval from '@tangle-network/agent-eval';
|
|
2
2
|
import { TraceAnalystKindSpec, AnalystFinding } from '@tangle-network/agent-eval';
|
|
3
|
-
import { R as RuntimeStreamEvent, S as SandboxClient, O as OutputAdapter, A as AgentRunSpec } from './types-
|
|
3
|
+
import { R as RuntimeStreamEvent, S as SandboxClient, O as OutputAdapter, A as AgentRunSpec } from './types-CklkW4Eh.js';
|
|
4
4
|
import { A as AgentSurfaces } from './improvement-adapter-BC4HhuAR.js';
|
|
5
5
|
export { C as CreateSurfaceImprovementAdapterOpts, D as DraftPatchInput, a as DraftPatchOutput, R as ResolvedSurface, S as SurfaceImprovementEdit, b as SurfaceValidationIssue, c as createSurfaceImprovementAdapter, r as renderSurfaceIssues, d as resolveSubjectPath, v as validateSurfaces } from './improvement-adapter-BC4HhuAR.js';
|
|
6
6
|
import { K as KnowledgeAdapter, a as RunAnalystLoopResult } from './types-p8dWBIXL.js';
|
|
7
7
|
import { AgentProfile, SandboxEvent } from '@tangle-network/sandbox';
|
|
8
|
-
import { C as ComposeProductionAgentProfileOptions } from './delegation-profile-
|
|
8
|
+
import { C as ComposeProductionAgentProfileOptions } from './delegation-profile-Bvfro2m1.js';
|
|
9
9
|
import './runtime-hooks-C7JwKb9E.js';
|
|
10
10
|
|
|
11
11
|
/**
|
package/dist/agent.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
composeProductionAgentProfile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JFIYKDXF.js";
|
|
4
4
|
import {
|
|
5
5
|
createSandboxForSpec
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-K6WP7PYW.js";
|
|
7
7
|
import {
|
|
8
8
|
mapSandboxEvent
|
|
9
9
|
} from "./chunk-GSUO5QS6.js";
|
package/dist/analyst-loop.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TraceAnalystByteBudgets, TraceAnalysisStore } from '@tangle-network/agent-eval';
|
|
2
|
-
import { I as Iteration } from './types-
|
|
2
|
+
import { I as Iteration } from './types-CklkW4Eh.js';
|
|
3
3
|
import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-p8dWBIXL.js';
|
|
4
4
|
export { A as AnalystLoopEvent, b as AnalystRegistryLike, c as AnalystRegistryStreamingLike, d as AutoApplyPolicy, F as FindingsStoreLike, I as ImprovementAdapter, e as ImprovementEditBatch, f as ImprovementReport, K as KnowledgeAdapter, g as KnowledgeProposalBatch, h as KnowledgeReport } from './types-p8dWBIXL.js';
|
|
5
5
|
import '@tangle-network/sandbox';
|
|
@@ -25,11 +25,11 @@ import {
|
|
|
25
25
|
createDelegationHistoryHandler,
|
|
26
26
|
createDelegationStatusHandler,
|
|
27
27
|
hashIdempotencyInput
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-FO4DCM7R.js";
|
|
29
29
|
import {
|
|
30
30
|
createFleetWorkspaceExecutor,
|
|
31
31
|
createSiblingSandboxExecutor
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-AYRQZRDV.js";
|
|
33
33
|
import {
|
|
34
34
|
runLocalHarness
|
|
35
35
|
} from "./chunk-GLR25NG7.js";
|
|
@@ -905,4 +905,4 @@ export {
|
|
|
905
905
|
createPropagatingTraceEmitter,
|
|
906
906
|
traceContextToEnv
|
|
907
907
|
};
|
|
908
|
-
//# sourceMappingURL=chunk-
|
|
908
|
+
//# sourceMappingURL=chunk-5M2WDWBI.js.map
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
sleep,
|
|
13
13
|
throwAbort,
|
|
14
14
|
throwIfAborted
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-K6WP7PYW.js";
|
|
16
16
|
import {
|
|
17
17
|
ValidationError
|
|
18
18
|
} from "./chunk-GSUO5QS6.js";
|
|
@@ -620,4 +620,4 @@ export {
|
|
|
620
620
|
coderTaskFromArgs,
|
|
621
621
|
settleDetachedCoderTurn
|
|
622
622
|
};
|
|
623
|
-
//# sourceMappingURL=chunk-
|
|
623
|
+
//# sourceMappingURL=chunk-AYRQZRDV.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createDelegationTraceCollector,
|
|
4
4
|
formatDetachedSessionRef,
|
|
5
5
|
generateDelegationSpanId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AYRQZRDV.js";
|
|
7
7
|
import {
|
|
8
8
|
AgentEvalError,
|
|
9
9
|
NotFoundError,
|
|
@@ -1353,4 +1353,4 @@ export {
|
|
|
1353
1353
|
validateDelegationStatusArgs,
|
|
1354
1354
|
createDelegationStatusHandler
|
|
1355
1355
|
};
|
|
1356
|
-
//# sourceMappingURL=chunk-
|
|
1356
|
+
//# sourceMappingURL=chunk-FO4DCM7R.js.map
|
|
@@ -48,14 +48,21 @@ function composeProductionAgentProfile(baseProfile, options = {}) {
|
|
|
48
48
|
env: options.env
|
|
49
49
|
});
|
|
50
50
|
const baseMcp = baseProfile.mcp ?? {};
|
|
51
|
-
const
|
|
51
|
+
const withInjected = options.mcpConnections ? { ...baseMcp, ...options.mcpConnections } : { ...baseMcp };
|
|
52
|
+
const mergedMcp = delegationMcp ? { ...withInjected, ...delegationMcp } : withInjected;
|
|
52
53
|
const baseFiles = baseProfile.resources?.files ?? [];
|
|
53
54
|
const mergedFiles = options.extraFiles?.length ? [...baseFiles, ...options.extraFiles] : [...baseFiles];
|
|
54
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;
|
|
55
59
|
return {
|
|
56
60
|
...baseProfile,
|
|
57
61
|
name: options.name ?? baseProfile.name,
|
|
58
62
|
prompt,
|
|
63
|
+
...mergedTools ? { tools: mergedTools } : {},
|
|
64
|
+
...mergedHooks ? { hooks: mergedHooks } : {},
|
|
65
|
+
...mergedSubagents ? { subagents: mergedSubagents } : {},
|
|
59
66
|
mcp: mergedMcp,
|
|
60
67
|
resources: {
|
|
61
68
|
...baseProfile.resources,
|
|
@@ -63,10 +70,18 @@ function composeProductionAgentProfile(baseProfile, options = {}) {
|
|
|
63
70
|
}
|
|
64
71
|
};
|
|
65
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
|
+
}
|
|
66
81
|
|
|
67
82
|
export {
|
|
68
83
|
DELEGATION_MCP_SERVER_KEY,
|
|
69
84
|
buildDelegationMcpServer,
|
|
70
85
|
composeProductionAgentProfile
|
|
71
86
|
};
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-JFIYKDXF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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\nconst 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,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,2BAA2B;AAqB1B,SAAS,yBACd,UAA2C,CAAC,GACO;AACnD,QAAM,MAAM,QAAQ,OAAO,QAAQ;AACnC,QAAM,gBAAgB,QAAQ,iBAAiB,IAAI;AACnD,MAAI,CAAC,cAAe,QAAO;AAC3B,QAAM,UACJ,QAAQ,kBACR,IAAI,oBACJ,IAAI,mBACJ;AAEF,QAAM,UAAkC,CAAC;AACzC,aAAW,OAAO,mBAAmB;AACnC,UAAM,QAAQ,IAAI,GAAG;AACrB,QAAI,MAAO,SAAQ,GAAG,IAAI;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL,CAAC,yBAAyB,GAAG;AAAA,MAC3B,WAAW;AAAA,MACX,SAAS;AAAA,MACT,MAAM,CAAC,MAAM,iCAAiC,KAAK;AAAA,MACnD,KAAK;AAAA,QACH,gBAAgB;AAAA,QAChB,kBAAkB;AAAA,QAClB,GAAG;AAAA,MACL;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,QACR,SAAS;AAAA,QACT,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAsDO,SAAS,8BACd,aACA,UAAgD,CAAC,GACnC;AACd,QAAM,gBAAgB,yBAAyB;AAAA,IAC7C,eAAe,QAAQ;AAAA,IACvB,gBAAgB,QAAQ;AAAA,IACxB,KAAK,QAAQ;AAAA,EACf,CAAC;AAED,QAAM,UAAU,YAAY,OAAO,CAAC;AACpC,QAAM,eAAsD,QAAQ,iBAChE,EAAE,GAAG,SAAS,GAAG,QAAQ,eAAe,IACxC,EAAE,GAAG,QAAQ;AACjB,QAAM,YAAmD,gBACrD,EAAE,GAAG,cAAc,GAAG,cAAc,IACpC;AAEJ,QAAM,YAAY,YAAY,WAAW,SAAS,CAAC;AACnD,QAAM,cAAuC,QAAQ,YAAY,SAC7D,CAAC,GAAG,WAAW,GAAG,QAAQ,UAAU,IACpC,CAAC,GAAG,SAAS;AAEjB,QAAM,SAAS,QAAQ,eACnB,EAAE,GAAG,YAAY,QAAQ,cAAc,QAAQ,aAAa,IAC5D,YAAY;AAEhB,QAAM,cAAc,QAAQ,QACxB,EAAE,GAAI,YAAY,SAAS,CAAC,GAAI,GAAG,QAAQ,MAAM,IACjD,YAAY;AAEhB,QAAM,cAAc,WAAW,YAAY,OAAO,QAAQ,KAAK;AAE/D,QAAM,kBAAkB,QAAQ,YAC5B,EAAE,GAAI,YAAY,aAAa,CAAC,GAAI,GAAG,QAAQ,UAAU,IACzD,YAAY;AAEhB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM,QAAQ,QAAQ,YAAY;AAAA,IAClC;AAAA,IACA,GAAI,cAAc,EAAE,OAAO,YAAY,IAAI,CAAC;AAAA,IAC5C,GAAI,cAAc,EAAE,OAAO,YAAY,IAAI,CAAC;AAAA,IAC5C,GAAI,kBAAkB,EAAE,WAAW,gBAAgB,IAAI,CAAC;AAAA,IACxD,KAAK;AAAA,IACL,WAAW;AAAA,MACT,GAAG,YAAY;AAAA,MACf,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAIA,SAAS,WACP,MACA,SACuD;AACvD,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,SAAoD,EAAE,GAAI,QAAQ,CAAC,EAAG;AAC5E,aAAW,CAAC,OAAO,QAAQ,KAAK,OAAO,QAAQ,OAAO,GAAG;AACvD,WAAO,KAAK,IAAI,CAAC,GAAI,OAAO,KAAK,KAAK,CAAC,GAAI,GAAG,QAAQ;AAAA,EACxD;AACA,SAAO;AACT;","names":[]}
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
} from "./chunk-FNMGYYSS.js";
|
|
4
4
|
import {
|
|
5
5
|
createDefaultCoderDelegate
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AYRQZRDV.js";
|
|
7
7
|
import {
|
|
8
8
|
runAnalystLoop
|
|
9
9
|
} from "./chunk-HNUXAZIJ.js";
|
|
10
10
|
import {
|
|
11
11
|
createDriver,
|
|
12
12
|
runLoop
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-K6WP7PYW.js";
|
|
14
14
|
import {
|
|
15
15
|
ConfigError
|
|
16
16
|
} from "./chunk-GSUO5QS6.js";
|
|
@@ -200,4 +200,4 @@ export {
|
|
|
200
200
|
runLoopRunnerCli,
|
|
201
201
|
parseLoopRunnerArgv
|
|
202
202
|
};
|
|
203
|
-
//# sourceMappingURL=chunk-
|
|
203
|
+
//# sourceMappingURL=chunk-K5M3SHEU.js.map
|
|
@@ -3194,7 +3194,8 @@ async function routerChatWithTools(cfg, messages, tools, opts) {
|
|
|
3194
3194
|
messages,
|
|
3195
3195
|
tools,
|
|
3196
3196
|
tool_choice: opts?.toolChoice ?? "auto",
|
|
3197
|
-
temperature: opts?.temperature ?? 0.3
|
|
3197
|
+
temperature: opts?.temperature ?? 0.3,
|
|
3198
|
+
...opts?.maxTokens ? { max_tokens: opts.maxTokens } : {}
|
|
3198
3199
|
}),
|
|
3199
3200
|
...opts?.signal ? { signal: opts.signal } : {}
|
|
3200
3201
|
});
|
|
@@ -3218,7 +3219,7 @@ async function routerChatWithTools(cfg, messages, tools, opts) {
|
|
|
3218
3219
|
}
|
|
3219
3220
|
async function routerToolLoop(cfg, system, user, tools, execute, opts) {
|
|
3220
3221
|
const maxTurns = opts?.maxTurns ?? 4;
|
|
3221
|
-
const messages = [
|
|
3222
|
+
const messages = opts?.initialMessages ? [...opts.initialMessages] : [
|
|
3222
3223
|
{ role: "system", content: system },
|
|
3223
3224
|
{ role: "user", content: user }
|
|
3224
3225
|
];
|
|
@@ -3229,6 +3230,7 @@ async function routerToolLoop(cfg, system, user, tools, execute, opts) {
|
|
|
3229
3230
|
for (let turn = 1; turn <= maxTurns; turn += 1) {
|
|
3230
3231
|
const r = await routerChatWithTools(cfg, messages, tools, {
|
|
3231
3232
|
...opts?.temperature !== void 0 ? { temperature: opts.temperature } : {},
|
|
3233
|
+
...opts?.maxTokens ? { maxTokens: opts.maxTokens } : {},
|
|
3232
3234
|
...opts?.signal ? { signal: opts.signal } : {}
|
|
3233
3235
|
});
|
|
3234
3236
|
if (r.usage) {
|
|
@@ -3237,7 +3239,7 @@ async function routerToolLoop(cfg, system, user, tools, execute, opts) {
|
|
|
3237
3239
|
}
|
|
3238
3240
|
if (r.content) lastText = r.content;
|
|
3239
3241
|
if (r.toolCalls.length === 0)
|
|
3240
|
-
return { final: lastText, turns: turn, toolCalls, toolTrace, usage };
|
|
3242
|
+
return { final: lastText, turns: turn, toolCalls, toolTrace, usage, messages };
|
|
3241
3243
|
messages.push({
|
|
3242
3244
|
role: "assistant",
|
|
3243
3245
|
content: r.content ?? "",
|
|
@@ -3265,7 +3267,7 @@ async function routerToolLoop(cfg, system, user, tools, execute, opts) {
|
|
|
3265
3267
|
toolTrace.push({ name: tc.name, args: tc.arguments, result: out });
|
|
3266
3268
|
}
|
|
3267
3269
|
}
|
|
3268
|
-
return { final: lastText, turns: maxTurns, toolCalls, toolTrace, usage };
|
|
3270
|
+
return { final: lastText, turns: maxTurns, toolCalls, toolTrace, usage, messages };
|
|
3269
3271
|
}
|
|
3270
3272
|
|
|
3271
3273
|
// src/runtime/supervise/runtime.ts
|
|
@@ -4279,7 +4281,8 @@ async function runPersonified(options) {
|
|
|
4279
4281
|
...options.maxRestarts !== void 0 ? { maxRestarts: options.maxRestarts } : {},
|
|
4280
4282
|
...options.withinMs !== void 0 ? { withinMs: options.withinMs } : {},
|
|
4281
4283
|
...options.now ? { now: options.now } : {},
|
|
4282
|
-
...options.signal ? { signal: options.signal } : {}
|
|
4284
|
+
...options.signal ? { signal: options.signal } : {},
|
|
4285
|
+
...options.hooks ? { hooks: options.hooks } : {}
|
|
4283
4286
|
};
|
|
4284
4287
|
return supervisor.run(rootAgent, options.task, supervisorOpts);
|
|
4285
4288
|
}
|
|
@@ -4682,59 +4685,41 @@ import { pairedBootstrap, paretoFrontier } from "@tangle-network/agent-eval";
|
|
|
4682
4685
|
import { createChatClient, estimateCost as estimateCost3, isModelPriced as isModelPriced3 } from "@tangle-network/agent-eval";
|
|
4683
4686
|
var taskNudge = "Use the available tools to bring the artifact to the required final state. Address EVERY distinct change the request implies. After each tool result, check what remains and continue. Re-read the values you set to confirm they took. Reply DONE only once every required change is made and verified.";
|
|
4684
4687
|
async function runShot(surface, _task, handle, tools, messages, opts, modelOverride) {
|
|
4685
|
-
const innerTurns = opts.innerTurns ?? 4;
|
|
4686
|
-
let completions = 0;
|
|
4687
|
-
let toolCalls = 0;
|
|
4688
4688
|
let toolErrors = 0;
|
|
4689
|
-
const
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
tools,
|
|
4698
|
-
tool_choice: "auto",
|
|
4699
|
-
temperature: opts.temperature ?? 0.7,
|
|
4700
|
-
...opts.maxTokens ? { max_tokens: opts.maxTokens } : {}
|
|
4701
|
-
})
|
|
4702
|
-
});
|
|
4703
|
-
if (!res.ok) throw new Error(`router ${res.status}: ${(await res.text()).slice(0, 200)}`);
|
|
4704
|
-
completions += 1;
|
|
4705
|
-
const data = await res.json();
|
|
4706
|
-
if (typeof data.usage?.prompt_tokens === "number") tokens.input += data.usage.prompt_tokens;
|
|
4707
|
-
if (typeof data.usage?.completion_tokens === "number")
|
|
4708
|
-
tokens.output += data.usage.completion_tokens;
|
|
4709
|
-
const msg = data.choices?.[0]?.message;
|
|
4710
|
-
if (!msg) break;
|
|
4711
|
-
const calls = msg.tool_calls ?? [];
|
|
4712
|
-
messages.push({
|
|
4713
|
-
role: "assistant",
|
|
4714
|
-
content: msg.content ?? "",
|
|
4715
|
-
...calls.length ? { tool_calls: calls } : {}
|
|
4716
|
-
});
|
|
4717
|
-
if (calls.length === 0) break;
|
|
4718
|
-
for (const call of calls) {
|
|
4719
|
-
toolCalls += 1;
|
|
4720
|
-
let args = {};
|
|
4721
|
-
try {
|
|
4722
|
-
args = JSON.parse(call.function.arguments || "{}");
|
|
4723
|
-
} catch {
|
|
4724
|
-
toolErrors += 1;
|
|
4725
|
-
}
|
|
4726
|
-
let out;
|
|
4727
|
-
try {
|
|
4728
|
-
out = await surface.call(handle, call.function.name, args);
|
|
4729
|
-
if (out.startsWith("ERROR:")) toolErrors += 1;
|
|
4730
|
-
} catch (e) {
|
|
4731
|
-
toolErrors += 1;
|
|
4732
|
-
out = `ERROR: ${e instanceof Error ? e.message : String(e)}`;
|
|
4733
|
-
}
|
|
4734
|
-
messages.push({ role: "tool", tool_call_id: call.id, content: out });
|
|
4689
|
+
const execute = async (name, args) => {
|
|
4690
|
+
try {
|
|
4691
|
+
const out = await surface.call(handle, name, args);
|
|
4692
|
+
if (out.startsWith("ERROR:")) toolErrors += 1;
|
|
4693
|
+
return out;
|
|
4694
|
+
} catch (e) {
|
|
4695
|
+
toolErrors += 1;
|
|
4696
|
+
return `ERROR: ${e instanceof Error ? e.message : String(e)}`;
|
|
4735
4697
|
}
|
|
4736
|
-
}
|
|
4737
|
-
|
|
4698
|
+
};
|
|
4699
|
+
const r = await routerToolLoop(
|
|
4700
|
+
{
|
|
4701
|
+
routerBaseUrl: opts.routerBaseUrl,
|
|
4702
|
+
routerKey: opts.routerKey,
|
|
4703
|
+
model: modelOverride ?? opts.model
|
|
4704
|
+
},
|
|
4705
|
+
"",
|
|
4706
|
+
"",
|
|
4707
|
+
tools,
|
|
4708
|
+
execute,
|
|
4709
|
+
{
|
|
4710
|
+
maxTurns: opts.innerTurns ?? 4,
|
|
4711
|
+
temperature: opts.temperature ?? 0.7,
|
|
4712
|
+
initialMessages: messages,
|
|
4713
|
+
...opts.maxTokens ? { maxTokens: opts.maxTokens } : {}
|
|
4714
|
+
}
|
|
4715
|
+
);
|
|
4716
|
+
return {
|
|
4717
|
+
messages: r.messages,
|
|
4718
|
+
completions: r.turns,
|
|
4719
|
+
toolCalls: r.toolCalls,
|
|
4720
|
+
toolErrors,
|
|
4721
|
+
tokens: r.usage
|
|
4722
|
+
};
|
|
4738
4723
|
}
|
|
4739
4724
|
function compactTrajectory(messages) {
|
|
4740
4725
|
return messages.filter((m) => m.role === "assistant" || m.role === "tool").map((m) => {
|
|
@@ -6549,4 +6534,4 @@ export {
|
|
|
6549
6534
|
gitWorkspace,
|
|
6550
6535
|
jjWorkspace
|
|
6551
6536
|
};
|
|
6552
|
-
//# sourceMappingURL=chunk-
|
|
6537
|
+
//# sourceMappingURL=chunk-K6WP7PYW.js.map
|