@tangle-network/agent-runtime 0.41.0 → 0.42.1

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 (32) hide show
  1. package/dist/agent.d.ts +57 -2
  2. package/dist/agent.js +54 -0
  3. package/dist/agent.js.map +1 -1
  4. package/dist/chunk-7JITYN6T.js +72 -0
  5. package/dist/chunk-7JITYN6T.js.map +1 -0
  6. package/dist/{chunk-WSJJGSD3.js → chunk-HCL2ZG5L.js} +2 -2
  7. package/dist/{chunk-OISRXLWI.js → chunk-IFG6GX6A.js} +64 -40
  8. package/dist/chunk-IFG6GX6A.js.map +1 -0
  9. package/dist/{chunk-4GI7C36B.js → chunk-PSGD6OIJ.js} +5 -4
  10. package/dist/{chunk-4GI7C36B.js.map → chunk-PSGD6OIJ.js.map} +1 -1
  11. package/dist/{chunk-FJ4GDNVN.js → chunk-WMBYQPYM.js} +2 -2
  12. package/dist/delegation-profile-1GbW5yA3.d.ts +73 -0
  13. package/dist/{dynamic-CazTl_Zp.d.ts → dynamic-B_7GgCwu.d.ts} +1 -1
  14. package/dist/index.d.ts +7 -8
  15. package/dist/index.js +3 -3
  16. package/dist/{kb-gate-NzOJSnOk.d.ts → kb-gate-DTBum3vH.d.ts} +1 -1
  17. package/dist/{loop-runner-bin-DYRzk2cT.d.ts → loop-runner-bin-CVoCBmYk.d.ts} +3 -3
  18. package/dist/loop-runner-bin.d.ts +4 -5
  19. package/dist/loop-runner-bin.js +3 -3
  20. package/dist/loops.d.ts +65 -7
  21. package/dist/loops.js +7 -1
  22. package/dist/mcp/bin.js +3 -3
  23. package/dist/mcp/index.d.ts +6 -6
  24. package/dist/mcp/index.js +11 -3
  25. package/dist/{otel-export-xgf4J6bo.d.ts → otel-export-BzvF1Ela.d.ts} +1 -1
  26. package/dist/profiles.d.ts +1 -2
  27. package/dist/{types-BrJKXXI8.d.ts → types-Bcp071Jg.d.ts} +488 -3
  28. package/package.json +11 -22
  29. package/dist/chunk-OISRXLWI.js.map +0 -1
  30. package/dist/types-CsCCryln.d.ts +0 -489
  31. /package/dist/{chunk-WSJJGSD3.js.map → chunk-HCL2ZG5L.js.map} +0 -0
  32. /package/dist/{chunk-FJ4GDNVN.js.map → chunk-WMBYQPYM.js.map} +0 -0
@@ -1,9 +1,9 @@
1
1
  import { Scenario } from '@tangle-network/agent-eval/campaign';
2
2
  import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-p8dWBIXL.js';
3
3
  import { O as OptimizePromptOptions, a as OptimizePromptResult } from './optimize-prompt-D-urF2wW.js';
4
- import { T as TopologyPlanner, D as DynamicDecision } from './dynamic-CazTl_Zp.js';
5
- import { L as LoopSandboxClient, O as OutputAdapter, V as Validator, A as AgentRunSpec, a as LoopResult } from './types-BrJKXXI8.js';
6
- import { D as DelegateCodeArgs, C as CoderReviewer, a as CoderWinnerSelection, F as FactCandidate, b as CreateKbGateOptions } from './kb-gate-NzOJSnOk.js';
4
+ import { T as TopologyPlanner, D as DynamicDecision } from './dynamic-B_7GgCwu.js';
5
+ import { L as LoopSandboxClient, a as OutputAdapter, V as Validator, A as AgentRunSpec, b as LoopResult } from './types-Bcp071Jg.js';
6
+ import { D as DelegateCodeArgs, C as CoderReviewer, a as CoderWinnerSelection, F as FactCandidate, b as CreateKbGateOptions } from './kb-gate-DTBum3vH.js';
7
7
  import { CoderOutput } from './profiles.js';
8
8
 
9
9
  /**
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env node
2
- export { L as LoopRunnerCliArgs, f as LoopRunnerCliResult, p as parseLoopRunnerArgv, o as runLoopRunnerCli } from './loop-runner-bin-DYRzk2cT.js';
2
+ export { L as LoopRunnerCliArgs, f as LoopRunnerCliResult, p as parseLoopRunnerArgv, o as runLoopRunnerCli } from './loop-runner-bin-CVoCBmYk.js';
3
3
  import '@tangle-network/agent-eval/campaign';
4
4
  import './types-p8dWBIXL.js';
5
5
  import '@tangle-network/agent-eval';
6
6
  import './optimize-prompt-D-urF2wW.js';
7
- import './dynamic-CazTl_Zp.js';
8
- import './types-BrJKXXI8.js';
7
+ import './dynamic-B_7GgCwu.js';
8
+ import './types-Bcp071Jg.js';
9
9
  import '@tangle-network/sandbox';
10
- import './types-CsCCryln.js';
11
- import './kb-gate-NzOJSnOk.js';
10
+ import './kb-gate-DTBum3vH.js';
12
11
  import './profiles.js';
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  parseLoopRunnerArgv,
4
4
  runLoopRunnerCli
5
- } from "./chunk-4GI7C36B.js";
5
+ } from "./chunk-PSGD6OIJ.js";
6
6
  import "./chunk-XBUG326M.js";
7
7
  import "./chunk-VOX6Z3II.js";
8
8
  import "./chunk-FNMGYYSS.js";
9
- import "./chunk-FJ4GDNVN.js";
10
- import "./chunk-OISRXLWI.js";
9
+ import "./chunk-WMBYQPYM.js";
10
+ import "./chunk-IFG6GX6A.js";
11
11
  import "./chunk-3HMHSN22.js";
12
12
  import "./chunk-PY6NMZYX.js";
13
13
  import "./chunk-SQSCRJ7U.js";
package/dist/loops.d.ts CHANGED
@@ -1,13 +1,12 @@
1
- import { AgentProfile, SandboxEvent } from '@tangle-network/sandbox';
1
+ import { AgentProfile, SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
2
2
  export { AgentProfile, CreateSandboxOptions, SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
3
- import { P as PlannerContext, T as TopologyPlanner } from './dynamic-CazTl_Zp.js';
4
- export { C as CreateDynamicDriverOptions, D as DynamicDecision, a as TopologyMove, c as createDynamicDriver, s as summarizeHistory } from './dynamic-CazTl_Zp.js';
5
- import { D as Driver, I as Iteration, L as LoopSandboxClient, A as AgentRunSpec, O as OutputAdapter, V as Validator, E as ExecCtx, c as LoopWinner, a as LoopResult } from './types-BrJKXXI8.js';
6
- export { d as LoopDecisionPayload, e as LoopEndedPayload, f as LoopIterationDispatchPayload, g as LoopIterationEndedPayload, h as LoopIterationStartedPayload, i as LoopPlanDescription, j as LoopPlanPayload, k as LoopSandboxPlacement, l as LoopStartedPayload, m as LoopTokenUsage, b as LoopTraceEmitter, n as LoopTraceEvent, o as ValidationCtx } from './types-BrJKXXI8.js';
3
+ import { P as PlannerContext, T as TopologyPlanner } from './dynamic-B_7GgCwu.js';
4
+ export { C as CreateDynamicDriverOptions, D as DynamicDecision, a as TopologyMove, c as createDynamicDriver, s as summarizeHistory } from './dynamic-B_7GgCwu.js';
5
+ import { D as Driver, I as Iteration, L as LoopSandboxClient, A as AgentRunSpec, a as OutputAdapter, V as Validator, E as ExecCtx, d as LoopWinner, b as LoopResult, R as RuntimeStreamEvent } from './types-Bcp071Jg.js';
6
+ export { e as LoopDecisionPayload, f as LoopEndedPayload, g as LoopIterationDispatchPayload, h as LoopIterationEndedPayload, i as LoopIterationStartedPayload, j as LoopPlanDescription, k as LoopPlanPayload, l as LoopSandboxPlacement, m as LoopStartedPayload, n as LoopTokenUsage, c as LoopTraceEmitter, o as LoopTraceEvent, p as ValidationCtx } from './types-Bcp071Jg.js';
7
7
  import { DefaultVerdict, AgentProfile as AgentProfile$1 } from '@tangle-network/agent-eval';
8
8
  export { DefaultVerdict } from '@tangle-network/agent-eval';
9
9
  import { Scenario, DispatchFn, ProfileDispatchFn } from '@tangle-network/agent-eval/campaign';
10
- import './types-CsCCryln.js';
11
10
 
12
11
  /**
13
12
  * @experimental
@@ -213,6 +212,13 @@ interface RunLoopOptions<Task, Output, Decision> {
213
212
  }
214
213
  /** @experimental */
215
214
  declare function runLoop<Task, Output, Decision>(options: RunLoopOptions<Task, Output, Decision>): Promise<LoopResult<Task, Output, Decision>>;
215
+ /**
216
+ * Instantiate a sandbox for an `AgentRunSpec`: sets `backend.profile` to the
217
+ * spec's profile (inferring the backend type when the spec doesn't override
218
+ * it) and merges `sandboxOverrides`. Shared by the loop kernel and the
219
+ * `AgentRuntime.act` sandbox bridge so both boot the sandbox identically.
220
+ */
221
+ declare function createSandboxForSpec<Task>(client: LoopSandboxClient, spec: AgentRunSpec<Task>, signal: AbortSignal): Promise<SandboxInstance>;
216
222
 
217
223
  /**
218
224
  * `loopDispatch` — turn `runLoop` into an agent-eval campaign dispatch.
@@ -312,4 +318,56 @@ interface UsageSink {
312
318
  */
313
319
  declare function reportLoopUsage<Task, Output, Decision>(cost: UsageSink, result: Pick<LoopResult<Task, Output, Decision>, 'costUsd' | 'tokenUsage'>, source?: string): void;
314
320
 
315
- export { AgentRunSpec, type CreateFanoutVoteDriverOptions, type CreateRefineDriverOptions, type CreateSandboxPlannerOptions, Driver, ExecCtx, type FanoutVoteDecision, type FanoutVoteScored, Iteration, type LoopDispatchOptions, type LoopOptionsForDispatch, LoopResult, LoopSandboxClient, LoopWinner, OutputAdapter, PlannerContext, type RefineDecision, type RunLoopOptions, type TopologyMoveEnvelope, TopologyPlanner, type UsageSink, Validator, createFanoutVoteDriver, createRefineDriver, createSandboxPlanner, loopCampaignDispatch, loopDispatch, refineWinnerIndex, reportLoopUsage, runLoop, scoreFanoutVoteIterations };
321
+ /**
322
+ * Sandbox-event → runtime-event mapping.
323
+ *
324
+ * The sandbox SDK emits a polymorphic `SandboxEvent = { type, data, id? }`
325
+ * whose `type` vocabulary is backend-determined (opencode, etc.) rather than
326
+ * enumerated by the SDK. Two consumers project it:
327
+ * - the loop kernel's cost ledger (`extractLlmCallEvent`) — sums usage off
328
+ * every cost-bearing event, regardless of stream shape;
329
+ * - the `AgentRuntime.act` streaming contract (`mapSandboxEvent`) — projects
330
+ * incremental events to the `RuntimeStreamEvent` chat-UX vocabulary.
331
+ *
332
+ * Both live here so the empirically-observed `type` vocabulary has one home.
333
+ */
334
+
335
+ /**
336
+ * Extract a `RuntimeStreamEvent`-shaped `llm_call` from a sandbox event when
337
+ * the event carries usage/cost data. Returns `undefined` for non-cost events
338
+ * so the kernel can iterate the full stream without branching.
339
+ *
340
+ * Canonical cost-carrying types observed in the wild:
341
+ * - `llm_call` — `data: { model, tokensIn, tokensOut, costUsd, ... }`
342
+ * - `message.completed` / `result` — `data: { usage: { inputTokens,
343
+ * outputTokens, totalCostUsd? } }`
344
+ * - `cost.usage` / `usage` — same shape under a dedicated type
345
+ *
346
+ * Numeric coercion is strict: `Number.isFinite` gates every accumulator write
347
+ * so a sentinel `NaN` from a misbehaving backend cannot poison the ledger.
348
+ */
349
+ declare function extractLlmCallEvent(event: SandboxEvent, agentRunName: string): (RuntimeStreamEvent & {
350
+ type: 'llm_call';
351
+ }) | undefined;
352
+ /**
353
+ * Project one `SandboxEvent` onto the `RuntimeStreamEvent` chat-UX vocabulary,
354
+ * for runtimes that bridge a sandbox `streamPrompt` into the
355
+ * `AgentRuntime.act` streaming contract. Returns `undefined` for events that
356
+ * have no faithful projection — the raw stream is preserved separately for the
357
+ * `OutputAdapter`, so an unmapped event never loses data.
358
+ *
359
+ * Mapped (the task-optional incremental variants — no synthesized task
360
+ * lifecycle, no guessed tool-part shapes):
361
+ * - `message.part.updated` text part → `text_delta`
362
+ * - `message.part.updated` reasoning/thinking part → `reasoning_delta`
363
+ * - cost-bearing events → `llm_call` (shared with the ledger extractor)
364
+ *
365
+ * The opencode backend emits incremental text as
366
+ * `{ type: 'message.part.updated', data: { part: { type, text }, delta } }`;
367
+ * `delta` is the increment, `part.text` the running accumulation.
368
+ */
369
+ declare function mapSandboxEvent(event: SandboxEvent, opts?: {
370
+ agentRunName?: string;
371
+ }): RuntimeStreamEvent | undefined;
372
+
373
+ export { AgentRunSpec, type CreateFanoutVoteDriverOptions, type CreateRefineDriverOptions, type CreateSandboxPlannerOptions, Driver, ExecCtx, type FanoutVoteDecision, type FanoutVoteScored, Iteration, type LoopDispatchOptions, type LoopOptionsForDispatch, LoopResult, LoopSandboxClient, LoopWinner, OutputAdapter, PlannerContext, type RefineDecision, type RunLoopOptions, type TopologyMoveEnvelope, TopologyPlanner, type UsageSink, Validator, createFanoutVoteDriver, createRefineDriver, createSandboxForSpec, createSandboxPlanner, extractLlmCallEvent, loopCampaignDispatch, loopDispatch, mapSandboxEvent, refineWinnerIndex, reportLoopUsage, runLoop, scoreFanoutVoteIterations };
package/dist/loops.js CHANGED
@@ -1,14 +1,17 @@
1
1
  import {
2
2
  createDynamicDriver,
3
3
  createRefineDriver,
4
+ createSandboxForSpec,
4
5
  createSandboxPlanner,
6
+ extractLlmCallEvent,
5
7
  loopCampaignDispatch,
6
8
  loopDispatch,
9
+ mapSandboxEvent,
7
10
  refineWinnerIndex,
8
11
  reportLoopUsage,
9
12
  runLoop,
10
13
  summarizeHistory
11
- } from "./chunk-OISRXLWI.js";
14
+ } from "./chunk-IFG6GX6A.js";
12
15
  import {
13
16
  createFanoutVoteDriver,
14
17
  scoreFanoutVoteIterations
@@ -19,9 +22,12 @@ export {
19
22
  createDynamicDriver,
20
23
  createFanoutVoteDriver,
21
24
  createRefineDriver,
25
+ createSandboxForSpec,
22
26
  createSandboxPlanner,
27
+ extractLlmCallEvent,
23
28
  loopCampaignDispatch,
24
29
  loopDispatch,
30
+ mapSandboxEvent,
25
31
  refineWinnerIndex,
26
32
  reportLoopUsage,
27
33
  runLoop,
package/dist/mcp/bin.js CHANGED
@@ -4,15 +4,15 @@ import {
4
4
  createPropagatingTraceEmitter,
5
5
  detectExecutor,
6
6
  readTraceContextFromEnv
7
- } from "../chunk-WSJJGSD3.js";
7
+ } from "../chunk-HCL2ZG5L.js";
8
8
  import "../chunk-HVYOHJHK.js";
9
9
  import {
10
10
  createDefaultCoderDelegate
11
- } from "../chunk-FJ4GDNVN.js";
11
+ } from "../chunk-WMBYQPYM.js";
12
12
  import "../chunk-GLR25NG7.js";
13
13
  import {
14
14
  runLoop
15
- } from "../chunk-OISRXLWI.js";
15
+ } from "../chunk-IFG6GX6A.js";
16
16
  import "../chunk-3HMHSN22.js";
17
17
  import "../chunk-PY6NMZYX.js";
18
18
  import "../chunk-SQSCRJ7U.js";
@@ -1,13 +1,13 @@
1
- import { L as LoopSandboxClient, k as LoopSandboxPlacement, b as LoopTraceEmitter } from '../types-BrJKXXI8.js';
2
- import { c as FleetHandle, d as DelegationExecutor, e as DelegateFeedbackArgs, f as DelegationFeedbackSnapshot, g as DelegationProfile, D as DelegateCodeArgs, h as DelegateResearchArgs, i as DelegationStatus, j as DelegationProgress, k as DelegationResultPayload, l as DelegationError, m as DelegationStatusResult, n as DelegationHistoryArgs, o as DelegationHistoryEntry, p as CoderDelegate, R as ResearcherDelegate, q as DelegateCodeResult, r as DelegateFeedbackResult, s as ResearchSource, t as DelegateResearchResult, u as DelegationHistoryResult, v as DelegationStatusArgs } from '../kb-gate-NzOJSnOk.js';
3
- export { w as CoderReview, C as CoderReviewer, a as CoderWinnerSelection, x as CreateDefaultCoderDelegateOptions, b as CreateKbGateOptions, y as DelegateCodeConfig, z as DelegateResearchConfig, A as DelegateRunCtx, F as FactCandidate, B as FactJudge, E as FactJudgeVerdict, G as FeedbackRating, H as FeedbackRefersTo, I as FleetWorkspaceExecutorOptions, K as KbGateResult, J as ResearchOutputShape, S as SiblingSandboxExecutorOptions, L as createDefaultCoderDelegate, M as createFleetWorkspaceExecutor, N as createKbGate, O as createSiblingSandboxExecutor } from '../kb-gate-NzOJSnOk.js';
1
+ import { L as LoopSandboxClient, l as LoopSandboxPlacement, c as LoopTraceEmitter } from '../types-Bcp071Jg.js';
2
+ import { c as FleetHandle, d as DelegationExecutor, e as DelegateFeedbackArgs, f as DelegationFeedbackSnapshot, g as DelegationProfile, D as DelegateCodeArgs, h as DelegateResearchArgs, i as DelegationStatus, j as DelegationProgress, k as DelegationResultPayload, l as DelegationError, m as DelegationStatusResult, n as DelegationHistoryArgs, o as DelegationHistoryEntry, p as CoderDelegate, R as ResearcherDelegate, q as DelegateCodeResult, r as DelegateFeedbackResult, s as ResearchSource, t as DelegateResearchResult, u as DelegationHistoryResult, v as DelegationStatusArgs } from '../kb-gate-DTBum3vH.js';
3
+ export { w as CoderReview, C as CoderReviewer, a as CoderWinnerSelection, x as CreateDefaultCoderDelegateOptions, b as CreateKbGateOptions, y as DelegateCodeConfig, z as DelegateResearchConfig, A as DelegateRunCtx, F as FactCandidate, B as FactJudge, E as FactJudgeVerdict, G as FeedbackRating, H as FeedbackRefersTo, I as FleetWorkspaceExecutorOptions, K as KbGateResult, J as ResearchOutputShape, S as SiblingSandboxExecutorOptions, L as createDefaultCoderDelegate, M as createFleetWorkspaceExecutor, N as createKbGate, O as createSiblingSandboxExecutor } from '../kb-gate-DTBum3vH.js';
4
+ export { B as BuildDelegationMcpServerOptions, C as ComposeProductionAgentProfileOptions, D as DELEGATION_MCP_SERVER_KEY, b as buildDelegationMcpServer, c as composeProductionAgentProfile } from '../delegation-profile-1GbW5yA3.js';
4
5
  import { L as LocalHarness, r as runLocalHarness } from '../local-harness-KrdFTY5R.js';
5
6
  export { a as LocalHarnessResult, R as RunLocalHarnessOptions } from '../local-harness-KrdFTY5R.js';
6
- import { O as OtelExporter } from '../otel-export-xgf4J6bo.js';
7
- export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from '../otel-export-xgf4J6bo.js';
7
+ import { O as OtelExporter } from '../otel-export-BzvF1Ela.js';
8
+ export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from '../otel-export-BzvF1Ela.js';
8
9
  import '@tangle-network/agent-eval';
9
10
  import '@tangle-network/sandbox';
10
- import '../types-CsCCryln.js';
11
11
  import '../profiles.js';
12
12
  import 'node:child_process';
13
13
 
package/dist/mcp/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  readTraceContextFromEnv,
10
10
  removeWorktree,
11
11
  traceContextToEnv
12
- } from "../chunk-WSJJGSD3.js";
12
+ } from "../chunk-HCL2ZG5L.js";
13
13
  import {
14
14
  mcpToolsForRuntimeMcp,
15
15
  mcpToolsForRuntimeMcpSubset
@@ -52,11 +52,16 @@ import {
52
52
  createDefaultCoderDelegate,
53
53
  createFleetWorkspaceExecutor,
54
54
  createSiblingSandboxExecutor
55
- } from "../chunk-FJ4GDNVN.js";
55
+ } from "../chunk-WMBYQPYM.js";
56
56
  import {
57
57
  runLocalHarness
58
58
  } from "../chunk-GLR25NG7.js";
59
- import "../chunk-OISRXLWI.js";
59
+ import {
60
+ DELEGATION_MCP_SERVER_KEY,
61
+ buildDelegationMcpServer,
62
+ composeProductionAgentProfile
63
+ } from "../chunk-7JITYN6T.js";
64
+ import "../chunk-IFG6GX6A.js";
60
65
  import "../chunk-3HMHSN22.js";
61
66
  import "../chunk-PY6NMZYX.js";
62
67
  import "../chunk-SQSCRJ7U.js";
@@ -74,12 +79,15 @@ export {
74
79
  DELEGATION_HISTORY_DESCRIPTION,
75
80
  DELEGATION_HISTORY_INPUT_SCHEMA,
76
81
  DELEGATION_HISTORY_TOOL_NAME,
82
+ DELEGATION_MCP_SERVER_KEY,
77
83
  DELEGATION_STATUS_DESCRIPTION,
78
84
  DELEGATION_STATUS_INPUT_SCHEMA,
79
85
  DELEGATION_STATUS_TOOL_NAME,
80
86
  DelegationTaskQueue,
81
87
  InMemoryFeedbackStore,
88
+ buildDelegationMcpServer,
82
89
  captureWorktreeDiff,
90
+ composeProductionAgentProfile,
83
91
  createDefaultCoderDelegate,
84
92
  createDelegateCodeHandler,
85
93
  createDelegateFeedbackHandler,
@@ -1,4 +1,4 @@
1
- import { O as OpenAIChatTool } from './types-CsCCryln.js';
1
+ import { O as OpenAIChatTool } from './types-Bcp071Jg.js';
2
2
 
3
3
  /**
4
4
  * @experimental
@@ -1,7 +1,6 @@
1
1
  import { AgentProfile } from '@tangle-network/sandbox';
2
- import { O as OutputAdapter, V as Validator, A as AgentRunSpec, D as Driver } from './types-BrJKXXI8.js';
2
+ import { a as OutputAdapter, V as Validator, A as AgentRunSpec, D as Driver } from './types-Bcp071Jg.js';
3
3
  import '@tangle-network/agent-eval';
4
- import './types-CsCCryln.js';
5
4
 
6
5
  /**
7
6
  * @experimental