@tangle-network/agent-runtime 0.86.0 → 0.87.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.
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  parseLoopRunnerArgv,
4
4
  runLoopRunnerCli
5
- } from "./chunk-EJ7MAQN4.js";
5
+ } from "./chunk-FLVVVBWV.js";
6
6
  import "./chunk-SGKPNBXE.js";
7
- import "./chunk-3TZOXS7B.js";
8
- import "./chunk-F7OO2SKB.js";
7
+ import "./chunk-VKVNDNG4.js";
8
+ import "./chunk-6XCW3M7W.js";
9
9
  import "./chunk-UD4BHQMI.js";
10
10
  import "./chunk-BZF3KQ6G.js";
11
- import "./chunk-YPA5MLVE.js";
12
- import "./chunk-4J6RBI3K.js";
11
+ import "./chunk-LCXXIL3U.js";
12
+ import "./chunk-QUXZBZCS.js";
13
13
  import "./chunk-7LO5GMAO.js";
14
14
  import "./chunk-YEJR7IXO.js";
15
15
  import "./chunk-DPEUKJRO.js";
package/dist/loops.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ChatClient, RunRecord, HarnessType, AgentProfile, AnalystFinding, AnalystRunInputs, ToolSpan, StreamingDetector, DetectorSignal, buildTrajectory } from '@tangle-network/agent-eval';
2
2
  export { AnalystFinding, DefaultVerdict, computeFindingId, makeFinding } from '@tangle-network/agent-eval';
3
- import { SandboxEvent, SandboxInstance, CreateSandboxOptions } from '@tangle-network/sandbox';
3
+ import { SandboxEvent, SandboxInstance, CreateSandboxOptions, PromptOptions, TaskOptions } from '@tangle-network/sandbox';
4
4
  export { AgentProfile, CreateSandboxOptions, SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
5
5
  import { d as ResultBlobStore, S as SpawnJournal, N as NodeId, j as SpawnEvent, E as ExecutorFactory, c as Agent, B as Budget, i as Scope, g as Settled, f as SupervisedResult, h as Spend, U as UsageEvent, b as ExecutorRegistry, k as Supervisor } from './types-Driepl87.js';
6
6
  export { A as AgentSpec, a as Executor, l as ExecutorContext, m as ExecutorResult, R as Runtime, n as SupervisorOpts, T as TreeView, W as WidenGate } from './types-Driepl87.js';
@@ -802,10 +802,11 @@ interface HarvestReport {
802
802
  /** Batch the firewalled `observe()` analyst over completed runs and accrete the trace-derived facts into the durable corpus — the production-traces→corpus write side of the flywheel. */
803
803
  declare function harvestCorpus(opts: HarvestCorpusOptions): Promise<HarvestReport>;
804
804
 
805
- /** Context handed to each `onPrompt` call. */
805
+ /** Context handed to each `onPrompt` / `onTask` call. */
806
806
  interface InProcessPromptCtx {
807
- /** 0-based round index — increments per `streamPrompt` on the SAME box (so a
808
- * refine driver's round N can differ from round N-1). Fresh boxes start at 0. */
807
+ /** 0-based round index — increments per `streamPrompt`/`streamTask` on the
808
+ * SAME box (so a refine driver's round N can differ from round N-1). Fresh
809
+ * boxes start at 0. */
809
810
  round: number;
810
811
  /** Absolute path of this box's workspace, when a `workdir` was configured.
811
812
  * Write the deliverable / fixtures here; `fs.read`/`fs.write`/`exec` operate
@@ -813,6 +814,13 @@ interface InProcessPromptCtx {
813
814
  workdir?: string;
814
815
  /** Cooperative cancellation channel for this turn. */
815
816
  signal: AbortSignal;
817
+ /** Which box verb produced this call: `prompt` = `streamPrompt`,
818
+ * `task` = `streamTask`. */
819
+ mode: 'prompt' | 'task';
820
+ /** The verbatim per-call options the caller passed to the box verb (minus
821
+ * `signal`, surfaced above) — lets an offline test assert an options
822
+ * passthrough (`model`, `sessionId`, `maxTurns`, …) actually arrived. */
823
+ options?: Record<string, unknown>;
816
824
  }
817
825
  /**
818
826
  * The user callback: given a prompt and its round, produce the box's event
@@ -825,6 +833,14 @@ type InProcessOnPrompt = (prompt: string, ctx: InProcessPromptCtx) => SandboxEve
825
833
  interface InProcessSandboxClientOptions {
826
834
  /** The per-turn behavior — see {@link InProcessOnPrompt}. */
827
835
  onPrompt: InProcessOnPrompt;
836
+ /**
837
+ * Task-mode behavior, driven by `box.streamTask` (the verb `streamAgentTurn`'s
838
+ * `box-task` backend calls). When omitted, `streamTask` drives `onPrompt` —
839
+ * the pseudo-box has ONE behavior callback and both verbs exercise it
840
+ * (`ctx.mode` tells them apart). Provide `onTask` when a test must
841
+ * discriminate the verbs or script different task-mode behavior.
842
+ */
843
+ onTask?: InProcessOnPrompt;
828
844
  /**
829
845
  * Opt in to a REAL filesystem-backed box. When set, each `create()` mints a
830
846
  * fresh temp directory (prefixed `<workdir>-`) and the box exposes
@@ -2087,6 +2103,51 @@ declare function sumSandboxUsage(events: readonly SandboxEvent[], agentRunName?:
2087
2103
  output: number;
2088
2104
  costUsd: number;
2089
2105
  };
2106
+ /**
2107
+ * Cross-event state for {@link mapSandboxToolEvent}. Sandbox backends emit a
2108
+ * tool invocation as MANY `message.part.updated` frames on the same call id
2109
+ * (pending → running → completed), so faithful projection needs per-call
2110
+ * status memory: one `tool_call` on first sighting, at most one `tool_result`
2111
+ * on the terminal transition, nothing on intermediate re-frames. Create one
2112
+ * state per turn via {@link createSandboxToolPartState}.
2113
+ *
2114
+ * @experimental
2115
+ */
2116
+ interface SandboxToolPartState {
2117
+ /** Last seen status per tool call id. A terminal status is sticky — later
2118
+ * frames on a settled call project to nothing. */
2119
+ statusByCall: Map<string, string>;
2120
+ /** Sequence for synthesized call ids when an event carries none. */
2121
+ seq: number;
2122
+ }
2123
+ /** @experimental */
2124
+ declare function createSandboxToolPartState(): SandboxToolPartState;
2125
+ /**
2126
+ * Project one `SandboxEvent` onto the `tool_call` / `tool_result` variants of
2127
+ * `RuntimeStreamEvent` — the tool-part projection `mapSandboxEvent`
2128
+ * deliberately does NOT perform. Opt-in and additive: `mapSandboxEvent`'s
2129
+ * default vocabulary (text/reasoning deltas + `llm_call`) is unchanged;
2130
+ * consumers that need the tool surface (chat UIs rendering tool activity)
2131
+ * compose this projector alongside it — `streamAgentTurn` does exactly that
2132
+ * under its `preserveToolParts` option.
2133
+ *
2134
+ * Handled shapes (observed on the opencode / claude-code sandbox backends):
2135
+ * - `message.part.updated` with `part.type === 'tool'` — stateful: a
2136
+ * `tool_call` on the call id's first frame (args from `state.input` or
2137
+ * `state.metadata.input`), a `tool_result` when the status transitions to
2138
+ * `completed` (result from `state.output` / `metadata.output`) or to a
2139
+ * terminal failure (result is `{ error, status, output? }` — the error
2140
+ * surfaced in-band, never dropped).
2141
+ * - bare `tool*` event types (`tool.call`, `tool_result`, …) — stateless:
2142
+ * `*result*` types project to `tool_result`, the rest to `tool_call`.
2143
+ *
2144
+ * Returns `[]` for every non-tool event.
2145
+ *
2146
+ * @experimental
2147
+ */
2148
+ declare function mapSandboxToolEvent(event: SandboxEvent, state: SandboxToolPartState): (RuntimeStreamEvent & {
2149
+ type: 'tool_call' | 'tool_result';
2150
+ })[];
2090
2151
  /**
2091
2152
  * Project one `SandboxEvent` onto the `RuntimeStreamEvent` chat-UX vocabulary,
2092
2153
  * for runtimes that bridge a sandbox `streamPrompt` into the
@@ -2100,6 +2161,9 @@ declare function sumSandboxUsage(events: readonly SandboxEvent[], agentRunName?:
2100
2161
  * - `message.part.updated` reasoning/thinking part → `reasoning_delta`
2101
2162
  * - cost-bearing events → `llm_call` (shared with the ledger extractor)
2102
2163
  *
2164
+ * Tool parts are deliberately NOT mapped here (unchanged default) — compose
2165
+ * {@link mapSandboxToolEvent} alongside when a consumer needs them.
2166
+ *
2103
2167
  * The opencode backend emits incremental text as
2104
2168
  * `{ type: 'message.part.updated', data: { part: { type, text }, delta } }`;
2105
2169
  * `delta` is the increment, `part.text` the running accumulation.
@@ -2782,7 +2846,8 @@ declare function runStrategyEvolution(cfg: StrategyEvolutionConfig): Promise<Evo
2782
2846
 
2783
2847
  /**
2784
2848
  * `streamAgentTurn` — the ONE run-a-turn event-stream contract over every
2785
- * execution substrate: a sandbox box (`SandboxInstance.streamPrompt`), a
2849
+ * execution substrate: a sandbox box (`SandboxInstance.streamPrompt`, or
2850
+ * `streamTask` via the `box-task` kind for autonomous-task semantics), a
2786
2851
  * one-shot `Executor` (cli-bridge / router / BYO, via `ExecutorFactory`), and
2787
2852
  * an in-process `AgentExecutionBackend` (the `resolveAgentBackend` output).
2788
2853
  *
@@ -2797,6 +2862,10 @@ declare function runStrategyEvolution(cfg: StrategyEvolutionConfig): Promise<Evo
2797
2862
  * adapter over code that already exists and is already hardened:
2798
2863
  * - `box` — `mapSandboxEvent` + `extractLlmCallEvent` (sandbox-events.ts)
2799
2864
  * project the sandbox event stream; nothing is re-mapped here.
2865
+ * - `box-task` — the same projection over `box.streamTask` (the sandbox
2866
+ * SDK's autonomous-task verb: the agent works to completion,
2867
+ * multi-turn, session state maintained) with per-task
2868
+ * `TaskOptions` passthrough.
2800
2869
  * - `executor` — `inlineSandboxClient` (the ONE executor→box adapter) turns
2801
2870
  * the factory into a box, then the box path drives it. The
2802
2871
  * executor's settle/teardown lifecycle stays in that adapter.
@@ -2816,6 +2885,15 @@ declare function runStrategyEvolution(cfg: StrategyEvolutionConfig): Promise<Evo
2816
2885
  * `final.status: 'failed'` — so cancellation stays distinguishable from a
2817
2886
  * blown deadline.
2818
2887
  *
2888
+ * Mid-stream lifecycle work needs NO extra API: the generator is pull-based,
2889
+ * so the producer is suspended between yields and resumes only when the caller
2890
+ * pulls again. A consumer can therefore run arbitrary async work between
2891
+ * events — sync state on each `tool_result`, decide a no-op retry after
2892
+ * draining, run a pre-`done` flush when it receives `final` and BEFORE it
2893
+ * forwards its own terminal event downstream. The interleaving is guaranteed
2894
+ * (and locked by test): nothing is produced past the event the caller is
2895
+ * holding.
2896
+ *
2819
2897
  * @experimental
2820
2898
  */
2821
2899
 
@@ -2829,6 +2907,34 @@ type AgentTurnBackend = {
2829
2907
  /** A live sandbox box: the turn is one `box.streamPrompt(prompt)` call. */
2830
2908
  kind: 'box';
2831
2909
  box: SandboxInstance;
2910
+ /**
2911
+ * Per-turn `PromptOptions` forwarded verbatim to `streamPrompt`
2912
+ * (`sessionId`, `turnId`, `model`, `backend` profile, `timeoutMs`, …).
2913
+ * The turn's derived abort signal (caller `signal` + `timeoutMs`
2914
+ * deadline) is always installed as `signal` — pass cancellation through
2915
+ * `StreamAgentTurnOptions`, not here.
2916
+ */
2917
+ options?: Omit<PromptOptions, 'signal'>;
2918
+ /** Model label stamped on cost-only `llm_call` events. Default `'agent'`. */
2919
+ agentRunName?: string;
2920
+ } | {
2921
+ /**
2922
+ * A live sandbox box in TASK mode: the turn is one
2923
+ * `box.streamTask(prompt)` call — the sandbox SDK's autonomous-task
2924
+ * verb. Unlike `streamPrompt` (one chat turn), the agent works until
2925
+ * the task completes or errors, session state is maintained for
2926
+ * continuity, and `options.maxTurns` bounds the agent's internal turns.
2927
+ * Event projection, usage folding, and the terminal `final` contract
2928
+ * are identical to the `box` kind.
2929
+ */
2930
+ kind: 'box-task';
2931
+ box: SandboxInstance;
2932
+ /**
2933
+ * Per-task `TaskOptions` forwarded verbatim to `streamTask`
2934
+ * (`maxTurns` plus every `PromptOptions` field). The turn's derived
2935
+ * abort signal is always installed as `signal`.
2936
+ */
2937
+ options?: Omit<TaskOptions, 'signal'>;
2832
2938
  /** Model label stamped on cost-only `llm_call` events. Default `'agent'`. */
2833
2939
  agentRunName?: string;
2834
2940
  } | {
@@ -2860,6 +2966,25 @@ interface StreamAgentTurnOptions {
2860
2966
  * (a blown deadline is a turn failure, not a caller cancellation).
2861
2967
  */
2862
2968
  timeoutMs?: number;
2969
+ /**
2970
+ * Opt-in tool-part projection for box-kind backends (`box`, `box-task`,
2971
+ * `executor`): sandbox tool parts additionally surface in-stream as
2972
+ * `tool_call` / `tool_result` events (`mapSandboxToolEvent`), so a consumer
2973
+ * rendering tool activity needs no bespoke sandbox-event parser. Default
2974
+ * off — the stream vocabulary existing consumers see is unchanged. No-op
2975
+ * for the `chat` kind (its backend emits `RuntimeStreamEvent`s directly,
2976
+ * tool events included when the backend produces them).
2977
+ */
2978
+ preserveToolParts?: boolean;
2979
+ /**
2980
+ * Raw-event tap for box-kind backends: called (and awaited) with every
2981
+ * unmapped `SandboxEvent` BEFORE it is projected, so a consumer can read
2982
+ * parts the chat-UX projection drops (part ids, step markers, custom
2983
+ * backend events) without forking the mapper. Purely observational — it
2984
+ * cannot alter the mapped stream. Never called for the `chat` kind, which
2985
+ * has no sandbox events.
2986
+ */
2987
+ onRawEvent?: (event: SandboxEvent) => void | Promise<void>;
2863
2988
  }
2864
2989
  /**
2865
2990
  * Metered usage of one turn, summed over every cost-bearing event the backend
@@ -3943,4 +4068,4 @@ declare function runInWorkspace<T>(ws: Workspace, body: (cwd: string) => Promise
3943
4068
  commitOnInvalid?: boolean;
3944
4069
  }): Promise<WorkspaceRun<T>>;
3945
4070
 
3946
- export { Agent, AgentRunSpec, type AgentTurnBackend, type AgentTurnUsage, type AgenticOptions, type AgenticRunResult, type AgenticSurface, type AgenticTask, type AgenticTool, AnalystRegistry, type AnytimeReport, type AnytimeStrategySummary, type AnytimeTaskCurve, type ApplyContinuation, type ArtifactHandle, AssertTraceDerivedFindings, type AuditIntentInput, type AuditIntentOptions, type AuthorStrategyOptions, type AuthoredProfile, type AuthoredStrategy, type BenchmarkCell, type BenchmarkConfig, type BenchmarkLift, type BenchmarkReport, type BenchmarkStrategySummary, type BenchmarkTaskRow, Budget, type BudgetPool, type BudgetReadout, type ChampionPick, type ChampionPolicy, type CheckpointCapableBox, type CollectedAgentTurn, CombinatorShape, type CompletionAnalyst, type CompletionEvidence, type CompletionPolicy, type CompletionVerdict, CoordinationEvent, type CoordinationMcpHandle, Corpus, CorpusFilter, CorpusRecord, type CreateScopeAnalystOptions, type CriuCapableClient, DefinePersonaInput, type DefinedLeaderboard, type DelegateOptions, type Deliverable, DeliverableSpec, type DriveHarness, Driver, type DriverAgentOptions, type DumbDriverOptions, type Environment, EqualKArm, EqualKOnCostOptions, EqualKVerdict, type EvolutionArchiveNode, type EvolutionAuthor, type EvolutionBandInfo, type EvolutionCandidate, type EvolutionGeneration, type EvolutionReport, ExecCtx, ExecutorConfig, ExecutorFactory, ExecutorRegistry, FanoutOptions, FanoutWinnerSelector, FileCorpus, type ForkCapableBox, type GitWorkspaceOptions, type HarvestCorpusOptions, type HarvestFailure, type HarvestReport, InMemoryCorpus, InMemoryResultBlobStore, type InMemoryRunContext, type InMemoryRunContextOptions, InMemorySpawnJournal, type InProcessOnPrompt, type InProcessPromptCtx, type InProcessSandboxClientOptions, type Inbox, type InboxMessage, type IntentAudit, type Interval, Iteration, type Leaderboard, type LeaderboardBenchScore, type LeaderboardBenchTask, type LeaderboardBenchmarkAdapter, type LeaderboardFlagSpec, type LeaderboardIterationInfo, type LeaderboardOptions, type LeaderboardRow, type LeaderboardRunContext, type LeaderboardScenario, type LeaderboardScore, type LeaderboardSpec, type LoopCampaignDispatchOptions, type LoopDispatchOptions, LoopLineageOptions, type LoopOptionsForDispatch, LoopResult, LoopShape, LoopTokenUsage, LoopUntilSpec, LoopWinner, MakeWorkerAgent, type McpEndpoint, type McpEnvironmentOptions, MountRecorder, type NaiveDriverOptions, type Observation, type ObserveInput, type ObserveOptions, type OpenSandboxRunOptions, Outcome, OutputAdapter, type PairwiseOptions, type PairwiseVerdict, PanelSpec, Persona, PipelineStage, type ProfileRichness, type ProfileRichnessThresholds, type PromotionGateOptions, type PromotionVerdict, type RegistryAnalyzeProjection, RenderCorpusToInstructionsOptions, type ReservationTicket, type ResolveSandboxClientOptions, ResultBlobStore, RouterConfig, type RunAgenticOptions, RunPersonifiedOptions, type SandboxCapabilities, SandboxClient, type SandboxLineage, type SandboxLineageHandle, type SandboxRun, SandboxRunAbortError, Scope, ScopeAnalyst, ScopeAnalyzeInput, ScopeWidenGate, type SessionCapableBox, type SessionTraceBox, Settled, ShapeRegistry, type Shell, type ShotPersona, type ShotSpec, Spend, SteerContext, type SteeringDecision, type Strategy, type StrategyCtx, type StrategyEvolutionConfig, type StrategyResult, type StreamAgentTurnOptions, type SuperviseOptions, type SuperviseSurfaceOptions, type SuperviseSurfaceResult, SupervisedResult, Supervisor, type SupervisorAgentDeps, type SupervisorProfile, type SurfaceScore, type SurfaceWorkerConfig, type SurfaceWorkerOut, ToolLoopChat, ToolLoopCompactionOptions, type TraceSource, type TrajectoryAnalysis, TrajectoryReport, TrajectoryReportOptions, type TurnResult, UsageEvent, type UsageSink, Validator, type VerifierEnvironmentOptions, VerifySpec, type WatchTraceOptions, type WaterfallCollector, type WaterfallReport, type WaterfallSpan, WidenSpec, WinnerStrategy, type Workspace, type WorkspaceCommit, type WorkspaceRun, acquireSandbox, adaptiveRefine, analyzeTrace, anytimeReport, asAuthoredProfile, assertModelAllowed, assertStrategyContract, assertTraceDerivedFindings, assessAuthoredProfile, auditIntent, authorStrategy, authoredWorker, breadthStrategy, buildSteerContext, builtinShapes, collectAgentTurn, completionAuthorizes, contentAddress, createBudgetPool, createInMemoryRunContext, createInbox, createMcpEnvironment, createPushTraceSource, createSandboxLineage, createScope, createScopeAnalyst, createShapeRegistry, createSupervisor, createVerifierEnvironment, createWaterfallCollector, decodeToolPart, defaultAnalystInstruction, defaultAuditorInstruction, defaultDelegateBudget, defaultProfileRichnessThresholds, defaultSelectWinner, defaultToolDetectors, defineLeaderboard, definePersona, defineStrategy, delegate, depthStrategy, deterministicCompletion, discriminatingMeans, driverAgent, dumbDriver, equalKOnCost, extractLlmCallEvent, failuresAnalyst, fanout, finalizeBestDelivered, flatWidenGate, gitWorkspace, harvestCorpus, inProcessSandboxClient, inlineSandboxClient, jjWorkspace, leaderboard, localShell, loopCampaignDispatch, loopDispatch, loopUntil, mapSandboxEvent, naiveDriver, observe, openSandboxRun, pairwiseSignificance, panel, pickChampion, pipeline, printBenchmarkReport, probeSandboxCapabilities, profileRichnessFinding, promotionGate, refine, registerShape, registryScopeAnalyst, renderAnytimeTable, renderCorpusToInstructions, renderLeaderboardHtml, renderLeaderboardMarkdown, renderLeaderboardSvg, renderPairwiseMarkdown, renderReport, reportLoopUsage, resolveSandboxClient, runAgentic, runBenchmark, runInWorkspace, runLoop, runPersonified, runStrategyEvolution, sample, sampleThenRefine, sandboxSessionTraceSource, selectChampion, selectValidWinner, sentinelCompletion, serveCoordinationMcp, settledToIteration, spendFromUsageEvents, stopSentinel, strategyAuthorContract, streamAgentTurn, sumSandboxUsage, supervise, superviseSurface, supervisorAgent, supervisorInstructions, trajectoryReport, verify, watchTrace, widen, workerFromBackend };
4071
+ export { Agent, AgentRunSpec, type AgentTurnBackend, type AgentTurnUsage, type AgenticOptions, type AgenticRunResult, type AgenticSurface, type AgenticTask, type AgenticTool, AnalystRegistry, type AnytimeReport, type AnytimeStrategySummary, type AnytimeTaskCurve, type ApplyContinuation, type ArtifactHandle, AssertTraceDerivedFindings, type AuditIntentInput, type AuditIntentOptions, type AuthorStrategyOptions, type AuthoredProfile, type AuthoredStrategy, type BenchmarkCell, type BenchmarkConfig, type BenchmarkLift, type BenchmarkReport, type BenchmarkStrategySummary, type BenchmarkTaskRow, Budget, type BudgetPool, type BudgetReadout, type ChampionPick, type ChampionPolicy, type CheckpointCapableBox, type CollectedAgentTurn, CombinatorShape, type CompletionAnalyst, type CompletionEvidence, type CompletionPolicy, type CompletionVerdict, CoordinationEvent, type CoordinationMcpHandle, Corpus, CorpusFilter, CorpusRecord, type CreateScopeAnalystOptions, type CriuCapableClient, DefinePersonaInput, type DefinedLeaderboard, type DelegateOptions, type Deliverable, DeliverableSpec, type DriveHarness, Driver, type DriverAgentOptions, type DumbDriverOptions, type Environment, EqualKArm, EqualKOnCostOptions, EqualKVerdict, type EvolutionArchiveNode, type EvolutionAuthor, type EvolutionBandInfo, type EvolutionCandidate, type EvolutionGeneration, type EvolutionReport, ExecCtx, ExecutorConfig, ExecutorFactory, ExecutorRegistry, FanoutOptions, FanoutWinnerSelector, FileCorpus, type ForkCapableBox, type GitWorkspaceOptions, type HarvestCorpusOptions, type HarvestFailure, type HarvestReport, InMemoryCorpus, InMemoryResultBlobStore, type InMemoryRunContext, type InMemoryRunContextOptions, InMemorySpawnJournal, type InProcessOnPrompt, type InProcessPromptCtx, type InProcessSandboxClientOptions, type Inbox, type InboxMessage, type IntentAudit, type Interval, Iteration, type Leaderboard, type LeaderboardBenchScore, type LeaderboardBenchTask, type LeaderboardBenchmarkAdapter, type LeaderboardFlagSpec, type LeaderboardIterationInfo, type LeaderboardOptions, type LeaderboardRow, type LeaderboardRunContext, type LeaderboardScenario, type LeaderboardScore, type LeaderboardSpec, type LoopCampaignDispatchOptions, type LoopDispatchOptions, LoopLineageOptions, type LoopOptionsForDispatch, LoopResult, LoopShape, LoopTokenUsage, LoopUntilSpec, LoopWinner, MakeWorkerAgent, type McpEndpoint, type McpEnvironmentOptions, MountRecorder, type NaiveDriverOptions, type Observation, type ObserveInput, type ObserveOptions, type OpenSandboxRunOptions, Outcome, OutputAdapter, type PairwiseOptions, type PairwiseVerdict, PanelSpec, Persona, PipelineStage, type ProfileRichness, type ProfileRichnessThresholds, type PromotionGateOptions, type PromotionVerdict, type RegistryAnalyzeProjection, RenderCorpusToInstructionsOptions, type ReservationTicket, type ResolveSandboxClientOptions, ResultBlobStore, RouterConfig, type RunAgenticOptions, RunPersonifiedOptions, type SandboxCapabilities, SandboxClient, type SandboxLineage, type SandboxLineageHandle, type SandboxRun, SandboxRunAbortError, type SandboxToolPartState, Scope, ScopeAnalyst, ScopeAnalyzeInput, ScopeWidenGate, type SessionCapableBox, type SessionTraceBox, Settled, ShapeRegistry, type Shell, type ShotPersona, type ShotSpec, Spend, SteerContext, type SteeringDecision, type Strategy, type StrategyCtx, type StrategyEvolutionConfig, type StrategyResult, type StreamAgentTurnOptions, type SuperviseOptions, type SuperviseSurfaceOptions, type SuperviseSurfaceResult, SupervisedResult, Supervisor, type SupervisorAgentDeps, type SupervisorProfile, type SurfaceScore, type SurfaceWorkerConfig, type SurfaceWorkerOut, ToolLoopChat, ToolLoopCompactionOptions, type TraceSource, type TrajectoryAnalysis, TrajectoryReport, TrajectoryReportOptions, type TurnResult, UsageEvent, type UsageSink, Validator, type VerifierEnvironmentOptions, VerifySpec, type WatchTraceOptions, type WaterfallCollector, type WaterfallReport, type WaterfallSpan, WidenSpec, WinnerStrategy, type Workspace, type WorkspaceCommit, type WorkspaceRun, acquireSandbox, adaptiveRefine, analyzeTrace, anytimeReport, asAuthoredProfile, assertModelAllowed, assertStrategyContract, assertTraceDerivedFindings, assessAuthoredProfile, auditIntent, authorStrategy, authoredWorker, breadthStrategy, buildSteerContext, builtinShapes, collectAgentTurn, completionAuthorizes, contentAddress, createBudgetPool, createInMemoryRunContext, createInbox, createMcpEnvironment, createPushTraceSource, createSandboxLineage, createSandboxToolPartState, createScope, createScopeAnalyst, createShapeRegistry, createSupervisor, createVerifierEnvironment, createWaterfallCollector, decodeToolPart, defaultAnalystInstruction, defaultAuditorInstruction, defaultDelegateBudget, defaultProfileRichnessThresholds, defaultSelectWinner, defaultToolDetectors, defineLeaderboard, definePersona, defineStrategy, delegate, depthStrategy, deterministicCompletion, discriminatingMeans, driverAgent, dumbDriver, equalKOnCost, extractLlmCallEvent, failuresAnalyst, fanout, finalizeBestDelivered, flatWidenGate, gitWorkspace, harvestCorpus, inProcessSandboxClient, inlineSandboxClient, jjWorkspace, leaderboard, localShell, loopCampaignDispatch, loopDispatch, loopUntil, mapSandboxEvent, mapSandboxToolEvent, naiveDriver, observe, openSandboxRun, pairwiseSignificance, panel, pickChampion, pipeline, printBenchmarkReport, probeSandboxCapabilities, profileRichnessFinding, promotionGate, refine, registerShape, registryScopeAnalyst, renderAnytimeTable, renderCorpusToInstructions, renderLeaderboardHtml, renderLeaderboardMarkdown, renderLeaderboardSvg, renderPairwiseMarkdown, renderReport, reportLoopUsage, resolveSandboxClient, runAgentic, runBenchmark, runInWorkspace, runLoop, runPersonified, runStrategyEvolution, sample, sampleThenRefine, sandboxSessionTraceSource, selectChampion, selectValidWinner, sentinelCompletion, serveCoordinationMcp, settledToIteration, spendFromUsageEvents, stopSentinel, strategyAuthorContract, streamAgentTurn, sumSandboxUsage, supervise, superviseSurface, supervisorAgent, supervisorInstructions, trajectoryReport, verify, watchTrace, widen, workerFromBackend };
package/dist/loops.js CHANGED
@@ -89,7 +89,7 @@ import {
89
89
  watchTrace,
90
90
  widen,
91
91
  worktreeFanout
92
- } from "./chunk-3TZOXS7B.js";
92
+ } from "./chunk-VKVNDNG4.js";
93
93
  import {
94
94
  InMemoryResultBlobStore,
95
95
  InMemorySpawnJournal,
@@ -131,7 +131,7 @@ import {
131
131
  supervisorAgent,
132
132
  supervisorInstructions,
133
133
  workerFromBackend
134
- } from "./chunk-F7OO2SKB.js";
134
+ } from "./chunk-6XCW3M7W.js";
135
135
  import "./chunk-UD4BHQMI.js";
136
136
  import {
137
137
  createAgentEnvironmentProviderRegistry,
@@ -141,10 +141,12 @@ import {
141
141
  sandboxClientAsProvider
142
142
  } from "./chunk-BZF3KQ6G.js";
143
143
  import {
144
+ createSandboxToolPartState,
144
145
  extractLlmCallEvent,
145
146
  mapSandboxEvent,
147
+ mapSandboxToolEvent,
146
148
  sumSandboxUsage
147
- } from "./chunk-4J6RBI3K.js";
149
+ } from "./chunk-QUXZBZCS.js";
148
150
  import "./chunk-7LO5GMAO.js";
149
151
  import "./chunk-YEJR7IXO.js";
150
152
  import "./chunk-DPEUKJRO.js";
@@ -185,6 +187,7 @@ export {
185
187
  createMcpEnvironment,
186
188
  createPushTraceSource,
187
189
  createSandboxLineage,
190
+ createSandboxToolPartState,
188
191
  createScope,
189
192
  createScopeAnalyst,
190
193
  createShapeRegistry,
@@ -227,6 +230,7 @@ export {
227
230
  loopUntil,
228
231
  makeFinding,
229
232
  mapSandboxEvent,
233
+ mapSandboxToolEvent,
230
234
  naiveDriver,
231
235
  observe,
232
236
  openSandboxRun,
package/dist/mcp/bin.js CHANGED
@@ -9,10 +9,10 @@ import {
9
9
  DelegationTaskQueue,
10
10
  FileDelegationStore,
11
11
  createMcpServer
12
- } from "../chunk-F7OO2SKB.js";
12
+ } from "../chunk-6XCW3M7W.js";
13
13
  import "../chunk-UD4BHQMI.js";
14
14
  import "../chunk-BZF3KQ6G.js";
15
- import "../chunk-4J6RBI3K.js";
15
+ import "../chunk-QUXZBZCS.js";
16
16
  import "../chunk-7LO5GMAO.js";
17
17
  import "../chunk-YEJR7IXO.js";
18
18
  import "../chunk-DPEUKJRO.js";
package/dist/mcp/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  mcpToolsForRuntimeMcp,
8
8
  mcpToolsForRuntimeMcpSubset
9
- } from "../chunk-U4TS65XZ.js";
9
+ } from "../chunk-MHYF2LIP.js";
10
10
  import {
11
11
  createKbGate
12
12
  } from "../chunk-SGKPNBXE.js";
@@ -14,7 +14,7 @@ import {
14
14
  assertTraceDerivedFindings,
15
15
  runCoderChecks,
16
16
  selectValidWinner
17
- } from "../chunk-3TZOXS7B.js";
17
+ } from "../chunk-VKVNDNG4.js";
18
18
  import {
19
19
  DELEGATE_DESCRIPTION,
20
20
  DELEGATE_FEEDBACK_DESCRIPTION,
@@ -64,7 +64,7 @@ import {
64
64
  validateDelegateUiAuditArgs,
65
65
  validateDelegationHistoryArgs,
66
66
  validateDelegationStatusArgs
67
- } from "../chunk-F7OO2SKB.js";
67
+ } from "../chunk-6XCW3M7W.js";
68
68
  import "../chunk-UD4BHQMI.js";
69
69
  import {
70
70
  deleteBoxSafe,
@@ -72,7 +72,7 @@ import {
72
72
  throwAbort,
73
73
  throwIfAborted
74
74
  } from "../chunk-BZF3KQ6G.js";
75
- import "../chunk-4J6RBI3K.js";
75
+ import "../chunk-QUXZBZCS.js";
76
76
  import {
77
77
  runLocalHarness
78
78
  } from "../chunk-7LO5GMAO.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-runtime",
3
- "version": "0.86.0",
3
+ "version": "0.87.0",
4
4
  "description": "Shared task-lifecycle skeleton for agents: a recursive loop kernel for chat turns, one-shot tasks, and multi-attempt loops, with trace capture and eval-gated self-improvement. Domain behavior lives in adapters; scoring and ship-gates in @tangle-network/agent-eval.",
5
5
  "homepage": "https://github.com/tangle-network/agent-runtime#readme",
6
6
  "repository": {
@@ -64,8 +64,9 @@ agent-runtime's `AgentSpec { profile, harness }`. To sweep it as an eval axis,
64
64
  don't hand-declare a harness list — expand one base profile across
65
65
  `CODING_HARNESSES` with `expandProfileAxes` (agent-eval), run with
66
66
  `runProfileMatrix`, and pivot results by the stamped `AgentProfileCell`
67
- (`groupRunsByAgentProfileCell`); incompatible `(harness, model)` pairs drop via
68
- `harnessSupportsModel`.
67
+ (`groupRunsByAgentProfileCell`); `harnessSupportsModel` filters per harness,
68
+ and a vendor-locked harness that supports none of the requested models SNAPS
69
+ to its native default (`HARNESS_NATIVE_MODEL`) — never silently dropped.
69
70
 
70
71
  | Altitude — I want to… | Use | Source |
71
72
  |---|---|---|
@@ -80,6 +81,10 @@ don't hand-declare a harness list — expand one base profile across
80
81
  | **Add a stateful tool-using domain** | implement `AgenticSurface` (5 hooks) — `/loops` | canonical-api §3.3 |
81
82
  | **Drive a team of agents over a graded `AgenticSurface` task** (workers settle on its check, driver self-improves from the failing tests) | `superviseSurface(profile, task, { surface, worker })` — `/loops` | canonical-api §2 |
82
83
  | **Benchmark: compare strategies + significance + Pareto on a domain** | `runBenchmark({ environment, tasks, worker, strategies })` — `/loops` | canonical-api §3.3 |
84
+ | **Author a PRODUCT eval leaderboard** (cases + prompt + grader → ranked board, standard flags, fresh run-dir, export, `toBenchmarkAdapter()`) | `defineLeaderboard({ name, cases, prompt, score, axis?, backends?, flags?, setup?/teardown?, onCellEvents?, resolveModel?, export?, dispatch?, judges?, matrix? })` — `/loops` — NOT a hand-assembled flag-parsing + `runProfileMatrix` frame; `runProfileMatrix` is the escape floor, the level-2 `dispatch` override is how in-process products plug in | `src/runtime/define-leaderboard.ts` (verify vs source) |
85
+ | **Resolve a harness-in-box backend** (box / local cli-bridge / router leaf, one `SandboxClient` shape) | `resolveSandboxClient({ backend: 'sandbox' \| 'bridge' \| 'router' })` — `/loops` — NOT a per-product backend factory or a hand-faked box (`inlineSandboxClient` / the bridge executor already exist) | `src/runtime/resolve-sandbox-client.ts` |
86
+ | **Resolve an in-process chat backend** (the one `--backend` branch for `runChatThroughRuntime` / `runAgentTaskStream`) | `resolveAgentBackend({ kind: 'router' \| 'tcloud' \| 'cli-bridge' \| 'sandbox' })` — root `.` | `src/resolve-agent-backend.ts` |
87
+ | **Run ONE agent turn as one normalized event stream** (box, executor, or chat backend; guaranteed terminal result+usage) | `streamAgentTurn(backend, prompt, { signal, timeoutMs })` + `collectAgentTurn(stream)` — `/loops` | canonical-api §2 |
83
88
  | **Benchmark report: multi-profile × multi-axis leaderboard** (ranked board + score matrix + SVG/HTML charts, any `RunRecord[]`) | `leaderboard(records)` + `renderLeaderboardMarkdown` / `renderLeaderboardSvg` / `renderLeaderboardHtml` — `/loops` | canonical-api §2 |
84
89
  | **Meter one `openSandboxRun` cell's token/cost usage** | `sumSandboxUsage(events)` — `/loops` | canonical-api §2 |
85
90
  | **Sweep harness × model as an eval axis** (turn one base profile into the full harness × model set) | `expandProfileAxes({ base, harnesses, models })` over `CODING_HARNESSES` → `runProfileMatrix(...)`, pivot with `groupRunsByAgentProfileCell` — `agent-eval` root — NOT a hand-declared `HARNESSES` list | agent-eval root (verify vs source) |
@@ -125,10 +130,24 @@ holds the load-bearing invariant the parallel breaks:
125
130
  (seeded, identical run-to-run; never report a point lift without `low/high/pairs`).
126
131
  - a per-product `HARNESSES` / `HarnessBackend` list + a metadata-harness reader
127
132
  **≈** `CODING_HARNESSES` + `expandProfileAxes` (the one canonical harness list;
128
- incompatible `(harness, model)` pairs drop via `harnessSupportsModel`) and the
133
+ vendor-locked harnesses SNAP to their native model via `HARNESS_NATIVE_MODEL`,
134
+ never dropped) and the
129
135
  `AgentProfileCell` stamped by `runProfileMatrix`, pivoted via
130
136
  `groupRunsByAgentProfileCell` — never bake the harness into the model id so the
131
137
  same model can run under multiple harnesses.
138
+ - a per-product leaderboard CLI (flag parsing + run-dir management + axis
139
+ expansion + a `runProfileMatrix` call + export/markdown) **≈**
140
+ `defineLeaderboard` (0.84+; it owns that whole frame — FRESH default run-dir,
141
+ standard `--backend`/`--harnesses`/`--models`/`--cases`/`--shots`/`--reps`
142
+ flags, `toBenchmarkAdapter()`; the product writes ~150-250 domain lines).
143
+ - a backend factory / `if (backend === 'router') ... else ...` branch or a
144
+ hand-faked box around a non-box executor **≈** `resolveSandboxClient`
145
+ (harness-in-box: `'sandbox' | 'bridge' | 'router'`) or `resolveAgentBackend`
146
+ (in-process: `'router' | 'tcloud' | 'cli-bridge' | 'sandbox'`) — grep the
147
+ substrate first; `inlineSandboxClient` and the bridge executor exist.
148
+ - a per-provider stream→event mapper for a single agent turn **≈**
149
+ `streamAgentTurn` + `collectAgentTurn` (0.85+; one `RuntimeStreamEvent`
150
+ contract over box / executor / chat, guaranteed terminal result+usage).
132
151
 
133
152
  ## End-to-end recipe
134
153