@tangle-network/agent-runtime 0.88.0 → 0.89.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.js +2 -2
- package/dist/{chunk-JHULWWQD.js → chunk-5AVV7KAH.js} +2 -2
- package/dist/{chunk-HBE77SWV.js → chunk-BQPFZE2C.js} +3 -3
- package/dist/{chunk-LRNRPJAV.js → chunk-N7EJV7N3.js} +25 -269
- package/dist/chunk-N7EJV7N3.js.map +1 -0
- package/dist/{chunk-22HPUH77.js → chunk-PIPPLSOF.js} +139 -268
- package/dist/chunk-PIPPLSOF.js.map +1 -0
- package/dist/index.js +4 -4
- package/dist/loop-runner-bin.js +3 -3
- package/dist/loops.d.ts +2 -185
- package/dist/loops.js +2 -14
- package/dist/mcp/bin.js +1 -1
- package/dist/mcp/index.js +3 -3
- package/package.json +1 -1
- package/skills/build-with-agent-runtime/SKILL.md +0 -6
- package/skills/loop-writer/SKILL.md +0 -73
- package/dist/chunk-22HPUH77.js.map +0 -1
- package/dist/chunk-LRNRPJAV.js.map +0 -1
- /package/dist/{chunk-JHULWWQD.js.map → chunk-5AVV7KAH.js.map} +0 -0
- /package/dist/{chunk-HBE77SWV.js.map → chunk-BQPFZE2C.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mcpToolsForRuntimeMcp,
|
|
3
3
|
mcpToolsForRuntimeMcpSubset
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5AVV7KAH.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_ROUTER_BASE_URL,
|
|
7
7
|
cleanModelId,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
runLoopRunnerCli,
|
|
21
21
|
selfImproveLoopRunner,
|
|
22
22
|
worktreeLoopRunner
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-BQPFZE2C.js";
|
|
24
24
|
import "./chunk-SGKPNBXE.js";
|
|
25
25
|
import {
|
|
26
26
|
InMemoryRuntimeSessionStore,
|
|
@@ -31,14 +31,14 @@ import {
|
|
|
31
31
|
normalizeBackendStreamEvent,
|
|
32
32
|
nowIso,
|
|
33
33
|
touchSession
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-PIPPLSOF.js";
|
|
35
35
|
import {
|
|
36
36
|
assertModelAllowed,
|
|
37
37
|
composeRuntimeHooks,
|
|
38
38
|
defineRuntimeHooks,
|
|
39
39
|
notifyRuntimeDecisionPoint,
|
|
40
40
|
notifyRuntimeHookEvent
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-N7EJV7N3.js";
|
|
42
42
|
import {
|
|
43
43
|
INTELLIGENCE_WIRE_VERSION,
|
|
44
44
|
buildLoopOtelSpans,
|
package/dist/loop-runner-bin.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
parseLoopRunnerArgv,
|
|
4
4
|
runLoopRunnerCli
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BQPFZE2C.js";
|
|
6
6
|
import "./chunk-SGKPNBXE.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-PIPPLSOF.js";
|
|
8
|
+
import "./chunk-N7EJV7N3.js";
|
|
9
9
|
import "./chunk-UD4BHQMI.js";
|
|
10
10
|
import "./chunk-BZF3KQ6G.js";
|
|
11
11
|
import "./chunk-ZQZX77MM.js";
|
package/dist/loops.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ChatClient, RunRecord, HarnessType, AgentProfile, AnalystFinding, Analy
|
|
|
2
2
|
export { AnalystFinding, DefaultVerdict, computeFindingId, makeFinding } from '@tangle-network/agent-eval';
|
|
3
3
|
import { SandboxEvent, SandboxInstance, CreateSandboxOptions, PromptOptions, TaskOptions } from '@tangle-network/sandbox';
|
|
4
4
|
export { AgentProfile, CreateSandboxOptions, SandboxEvent, SandboxInstance } from '@tangle-network/sandbox';
|
|
5
|
-
import { d as ResultBlobStore, S as SpawnJournal, N as NodeId, j as SpawnEvent, E as ExecutorFactory,
|
|
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';
|
|
7
7
|
import { ak as MakeWorkerAgent, A as AnalystRegistry, o as CoordinationTools, n as CoordinationEvent, ar as QuestionPolicy, a$ as ExecutorConfig } from './coordination-CuDLO8wj.js';
|
|
8
8
|
export { b0 as BusEvent, b1 as BusRecord, b2 as BusStats, b3 as EventBus, b4 as ProviderSeam, b5 as PublishOptions, b6 as cliWorktreeExecutor, b7 as createEventBus, b8 as createExecutor, b9 as createExecutorRegistry } from './coordination-CuDLO8wj.js';
|
|
@@ -879,182 +879,6 @@ declare function inProcessSandboxClient(options: InProcessSandboxClientOptions):
|
|
|
879
879
|
*/
|
|
880
880
|
declare function inlineSandboxClient(factory: ExecutorFactory<unknown>): SandboxClient;
|
|
881
881
|
|
|
882
|
-
/**
|
|
883
|
-
*
|
|
884
|
-
* The loop-executor — a spawnable, budget-conserving, gated, STEERABLE multi-round loop
|
|
885
|
-
* as a first-class atom, the sibling of the recursive driver-executor.
|
|
886
|
-
*
|
|
887
|
-
* A leaf worker runs one turn and settles. A driver child (driver-executor.ts) runs an
|
|
888
|
-
* LLM brain that spawns children and reacts. A LOOP child is the third shape: a CODED loop
|
|
889
|
-
* whose control flow is written, not left to a model's judgment. On `execute` it mounts a
|
|
890
|
-
* NESTED `Scope` (via the same `nested-scope` seam the driver-executor uses) one `depth`
|
|
891
|
-
* deeper over the SAME conserved pool + shared journal/blobs + open registry, then runs the
|
|
892
|
-
* authored loop's `round(ctx)` up to `maxRounds` times. Each round may spawn children into
|
|
893
|
-
* that nested scope (conserved budget, depth-bounded), and the runtime — not the authored
|
|
894
|
-
* body — owns the three guarantees a "loop" must make:
|
|
895
|
-
*
|
|
896
|
-
* - BOUNDED: at most `maxRounds` rounds; the run-wide conserved pool still fails a spawn
|
|
897
|
-
* closed at any depth, so a loop can never overspend the root ceiling.
|
|
898
|
-
* - GATED: the loop settles `valid` iff its deployable `check(out)` passes (the completion
|
|
899
|
-
* oracle, same discipline as `gateOnDeliverable`). A loop that exhausts `maxRounds`
|
|
900
|
-
* without the check ever passing settles `valid: false` — ran, did not deliver.
|
|
901
|
-
* - STEERABLE: the executor owns an `Inbox` and exposes `deliver`, so a supervisor's
|
|
902
|
-
* `steer_agent` (→ `Scope.send` → this `deliver`) lands between rounds. Queued messages
|
|
903
|
-
* fold into the next round's `ctx.steer`; a forceful `interrupt` aborts the in-flight
|
|
904
|
-
* round's linked signal so the loop re-plans immediately with the message folded in.
|
|
905
|
-
*
|
|
906
|
-
* Why this preserves every keystone invariant: identical to the driver-executor — the SCOPE
|
|
907
|
-
* owns the sharing (nested scope over `args.pool`, one `SpawnJournal` tree per child), this
|
|
908
|
-
* executor only runs the coded loop over what the scope mounts and rolls the sub-tree's
|
|
909
|
-
* conserved spend up on settle. It builds NO new budget, journal, or selection logic.
|
|
910
|
-
*
|
|
911
|
-
* The authored loop body is `defineLoop(name, { maxRounds, round, check })`. `round` is
|
|
912
|
-
* ordinary code — arbitrary composition inside a round (spawn one child, fan out many,
|
|
913
|
-
* pipeline) — while the runtime owns iteration, the budget, the gate, and steer-folding.
|
|
914
|
-
* So a loop is "codemode" (the author writes control flow) yet structurally bounded.
|
|
915
|
-
*
|
|
916
|
-
* @experimental
|
|
917
|
-
*/
|
|
918
|
-
|
|
919
|
-
/** The runtime tag the registry maps a loop child to. */
|
|
920
|
-
declare const loopRuntime: "loop";
|
|
921
|
-
/** What one round of a loop receives. The scope is the NESTED scope — spawn conserved
|
|
922
|
-
* children here; budget/depth are enforced by the scope, not the body. */
|
|
923
|
-
interface LoopRoundCtx {
|
|
924
|
-
/** The spawn task, verbatim. */
|
|
925
|
-
readonly task: unknown;
|
|
926
|
-
/** The nested, conserved scope. Spawn children with `scope.spawn`, react with `scope.next`. */
|
|
927
|
-
readonly scope: Scope<unknown>;
|
|
928
|
-
/** 1-based round index. */
|
|
929
|
-
readonly round: number;
|
|
930
|
-
/** The declared ceiling on rounds. */
|
|
931
|
-
readonly maxRounds: number;
|
|
932
|
-
/** Supervisor `steer_agent` messages that arrived since the last round, folded to text. */
|
|
933
|
-
readonly steer: readonly string[];
|
|
934
|
-
/** Conserved-pool readouts (post-reservation) for in-body budget-awareness. */
|
|
935
|
-
readonly budget: Scope<unknown>['budget'];
|
|
936
|
-
/** Abort signal: the spawn signal + nested-scope signal + a fresh per-round interrupt.
|
|
937
|
-
* A forceful steer during the round aborts THIS signal so the body can break and re-plan. */
|
|
938
|
-
readonly signal: AbortSignal;
|
|
939
|
-
}
|
|
940
|
-
/** What a round returns. `out` is the running result; `done: true` stops the loop early
|
|
941
|
-
* (the author's own stop condition, distinct from the runtime's gate `check`). */
|
|
942
|
-
interface LoopRoundResult {
|
|
943
|
-
readonly out: unknown;
|
|
944
|
-
readonly done?: boolean;
|
|
945
|
-
}
|
|
946
|
-
/** An authored coded loop: a name, a round ceiling, the round body, and an optional
|
|
947
|
-
* deployable gate `check`. `check` decides DELIVERED — the loop settles `valid` iff it
|
|
948
|
-
* passes — and is polled after each round to stop as soon as the loop has delivered. */
|
|
949
|
-
interface LoopDef {
|
|
950
|
-
readonly name: string;
|
|
951
|
-
readonly maxRounds: number;
|
|
952
|
-
round(ctx: LoopRoundCtx): Promise<LoopRoundResult>;
|
|
953
|
-
/** The deployable completion oracle. `settled.valid ⟺ this resolves true`. A throwing
|
|
954
|
-
* check is fail-closed (not delivered). Omit for a loop whose only stop is `done`. */
|
|
955
|
-
check?(out: unknown): boolean | Promise<boolean>;
|
|
956
|
-
/** What the loop was supposed to produce — surfaced in traces. */
|
|
957
|
-
readonly describe?: string;
|
|
958
|
-
}
|
|
959
|
-
/** One named agent in a MULTI-AGENT loop (the `agents` form of `defineLoop`). `run` does the
|
|
960
|
-
* agent's work for a round; `prior` is the previous agent's output, or `ctx.task` for the first.
|
|
961
|
-
* The last agent's return is the round's `out`. So a proposer→verifier loop is just two agents. */
|
|
962
|
-
interface LoopAgent {
|
|
963
|
-
/** A short, human name for the agent this plays (proposer, verifier, engineer). */
|
|
964
|
-
readonly name: string;
|
|
965
|
-
run(ctx: LoopRoundCtx, prior: unknown): Promise<unknown>;
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
* Author a coded loop atom. The returned `LoopDef` is handed to `loopChild` to become a
|
|
969
|
-
* spawnable `Agent`. The runtime owns `maxRounds`, the conserved budget, the gate, and
|
|
970
|
-
* steer-folding; you supply ONE of two round shapes:
|
|
971
|
-
*
|
|
972
|
-
* - `round` — freeform: write the whole round yourself (arbitrary code, may spawn children).
|
|
973
|
-
* - `agents` — declarative MULTI-AGENT: an ordered list of named agents piped each round
|
|
974
|
-
* (`task → agents[0] → agents[1] → … → out`). "How many agents" is self-evident from the
|
|
975
|
-
* list, so a two-agent research loop is `agents: [proposer, verifier]` — no bespoke function.
|
|
976
|
-
*
|
|
977
|
-
* Provide EXACTLY one of `round` / `agents`.
|
|
978
|
-
*/
|
|
979
|
-
declare function defineLoop(name: string, spec: {
|
|
980
|
-
maxRounds: number;
|
|
981
|
-
round?: (ctx: LoopRoundCtx) => Promise<LoopRoundResult>;
|
|
982
|
-
agents?: readonly LoopAgent[];
|
|
983
|
-
check?: (out: unknown) => boolean | Promise<boolean>;
|
|
984
|
-
describe?: string;
|
|
985
|
-
}): LoopDef;
|
|
986
|
-
/**
|
|
987
|
-
* Mark + carry an authored loop so the recursive registry resolves it to the
|
|
988
|
-
* loop-executor. The returned agent is SPAWNED (never run directly): its `executorSpec` is
|
|
989
|
-
* marked `role: 'loop'` and carries the `LoopDef` + the shared journal. `act` fails loud if
|
|
990
|
-
* called directly — a loop child runs THROUGH its nested-scope executor, never as a root.
|
|
991
|
-
*/
|
|
992
|
-
declare function loopChild<Out>(loop: LoopDef, journal: SpawnJournal): Agent<unknown, Out>;
|
|
993
|
-
/**
|
|
994
|
-
* Register the loop-executor so a child marked `role: 'loop'` resolves to it. Mirrors
|
|
995
|
-
* `withDriverExecutor`: a loop-role spec → the loop-executor; everything else → the base
|
|
996
|
-
* registry's resolution. Compose it WITH `withDriverExecutor` so loops and drivers coexist:
|
|
997
|
-
* `withLoopExecutor(withDriverExecutor(base))`.
|
|
998
|
-
*/
|
|
999
|
-
declare function withLoopExecutor(base: ExecutorRegistry): ExecutorRegistry;
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* authorLoop — the codemode layer over the loop atom: an LLM reads a goal + the defineLoop
|
|
1003
|
-
* contract and WRITES a coded loop as a module; the caller spawns it as a first-class atom
|
|
1004
|
-
* (`loopChild` → the loop-executor) and it settles gated on its own `check`, budget-conserved
|
|
1005
|
-
* and depth-bounded like any spawned child.
|
|
1006
|
-
*
|
|
1007
|
-
* This is to `defineLoop` what `authorStrategy` is to `defineStrategy`: the "supervisor writes
|
|
1008
|
-
* the loop" seam. The authored body composes real code (spawns children on the nested scope,
|
|
1009
|
-
* fans out, pipelines) while the runtime owns iteration, the conserved budget, the gate, and
|
|
1010
|
-
* steer-between-rounds — so an authored loop can be WRONG but cannot overspend the pool or
|
|
1011
|
-
* skip the completion check.
|
|
1012
|
-
*
|
|
1013
|
-
* Safety is structural, not a sandbox (mirrors `authorStrategy`): the same `assertStrategyContract`
|
|
1014
|
-
* lint bounds the module to the loops import and bans out-of-band compute (require/eval/fetch/
|
|
1015
|
-
* process/node builtins), and the authored module is written to `outDir` and dynamically imported
|
|
1016
|
-
* under a TS-capable loader (tsx) since models emit type annotations.
|
|
1017
|
-
*/
|
|
1018
|
-
|
|
1019
|
-
/** The compressed consumable a skill carries: everything an author needs to emit a loop atom. */
|
|
1020
|
-
declare const loopAuthorContract = "\nYou author a LOOP ATOM for an agent supervisor. A loop runs a bounded, multi-round journey\ntoward a deployable check; a supervisor spawns / observes / steers it exactly like a worker.\nYou write ONE round; the runtime owns the round ceiling, the conserved budget, the gate, and\nfolding a supervisor's steer into the next round. So write real control flow inside a round,\nbut never write the loop's stop condition as \"hope the model stops\" \u2014 that is the runtime's job.\n\nYou export ONE module of EXACTLY this shape (no other imports, no commentary outside the code):\n\nimport { defineLoop } from '@tangle-network/agent-runtime/loops'\nexport default defineLoop('your-loop-name', {\n maxRounds: 3,\n round: async ({ task, scope, round, maxRounds, steer, budget, signal }) => {\n // arbitrary code for ONE round. Do real work by spawning children on the nested scope:\n // const w = scope.spawn(childAgent, subtask, { budget: perRound, label: `r${round}` })\n // if (!w.ok) throw new Error(w.reason) // fail loud: budget-exhausted | depth-exceeded\n // const settled = await scope.next() // conserved child work; settles gated\n // 'steer' is the supervisor's messages since the last round (fold them into what you do next).\n // 'signal' aborts if a forceful steer arrives mid-round \u2014 pass it to your awaited work.\n return { out: /* the running result */ undefined, done: false } // done:true stops early\n },\n check: (out) => /* the deployable completion oracle */ Boolean(out),\n})\n\nFor a MULTI-AGENT loop (a proposer then a verifier, a researcher then an engineer), do NOT\nhand-write the pipeline in 'round' \u2014 use 'agents' instead: an ordered list of named agents piped\neach round (task -> agents[0] -> agents[1] -> ... -> out). \"How many agents\" is then self-evident.\n\nimport { defineLoop } from '@tangle-network/agent-runtime/loops'\nexport default defineLoop('your-loop-name', {\n maxRounds: 3,\n agents: [\n { name: 'proposer', run: async (ctx, prior) => { /* spawn a worker, produce a draft */ return draft } },\n { name: 'verifier', run: async (ctx, prior) => { /* verify/refine the proposer's draft */ return checked } },\n ],\n check: (out) => Boolean(out),\n})\n\nProvide EXACTLY one of 'round' or 'agents'. The round context (for the 'round' form, and passed to\neach agent's run as its first arg):\n task the spawn task, verbatim.\n scope the NESTED conserved scope. scope.spawn(agent, task, { budget, label }) reserves\n budget and fails closed; scope.next() awaits one child settlement. Budget NESTS \u2014\n the pool reserves each spawn's full ceiling until it settles, so give children a\n per-round budget smaller than the loop's own.\n round 1-based round index. maxRounds is the declared ceiling.\n steer readonly string[] \u2014 supervisor steer_agent messages that arrived since last round.\n budget conserved-pool readouts (tokensLeft, usdLeft, deadlineMs) for in-body awareness.\n signal AbortSignal \u2014 the spawn signal + a fresh per-round interrupt; honor it in awaits.\n\nThe round result: { out: unknown; done?: boolean }. 'out' is the running result the gate reads;\n'done: true' is YOUR early stop (distinct from the runtime's gate 'check').\n\ncheck(out): boolean | Promise<boolean>. The DEPLOYABLE oracle \u2014 an executable test, a state\nverifier, a readiness score threshold \u2014 read off 'out', never the model judging itself. The loop\nsettles valid IFF check passes, and the runtime polls it after each round to stop the instant the\nloop has delivered. A loop that exhausts maxRounds without check passing settles valid:false.\n\nRules:\n- ALWAYS await every scope.spawn drain / async call \u2014 a floating rejection crashes the run.\n- Do real work by SPAWNING children; raw un-metered inference in the body is not budget-conserved.\n- Give 'check' a real oracle. A loop whose check is a self-judged score cannot be trusted.\n- The only import allowed is '@tangle-network/agent-runtime/loops'. No require/eval/fetch/process/\n node builtins \u2014 the runtime meters and gates you; out-of-band compute breaks that.\n";
|
|
1021
|
-
interface AuthorLoopOptions {
|
|
1022
|
-
/** The model-call seam (agent-eval `createChatClient`). */
|
|
1023
|
-
chat: ChatClient;
|
|
1024
|
-
model?: string;
|
|
1025
|
-
/** A NAMED fallback author tried once when the primary call fails or returns no code block
|
|
1026
|
-
* (thinking models can time out at the edge on long authoring prompts, or return empty
|
|
1027
|
-
* content without `maxTokens`). Opt-in — absent means the primary's failure propagates. */
|
|
1028
|
-
fallbackModel?: string;
|
|
1029
|
-
/** The contract text shown to the author. Default `loopAuthorContract`. A skill/GEPA loop can
|
|
1030
|
-
* evolve this text and gate each variant on the same check as any loop. */
|
|
1031
|
-
contract?: string;
|
|
1032
|
-
/** What the loop must accomplish — the objective, in plain language (the author's orientation). */
|
|
1033
|
-
goal: string;
|
|
1034
|
-
/** Optional orienting context: the check's shape, the child agents available, prior findings —
|
|
1035
|
-
* never the check's internals (the author stays blind to the oracle, like `authorStrategy`). */
|
|
1036
|
-
context?: string;
|
|
1037
|
-
/** The round ceiling the loop must respect. */
|
|
1038
|
-
maxRounds: number;
|
|
1039
|
-
/** Where the authored module file is written (created if missing). */
|
|
1040
|
-
outDir: string;
|
|
1041
|
-
temperature?: number;
|
|
1042
|
-
/** Completion cap — required by thinking-model authors that stream reasoning first. */
|
|
1043
|
-
maxTokens?: number;
|
|
1044
|
-
signal?: AbortSignal;
|
|
1045
|
-
}
|
|
1046
|
-
interface AuthoredLoop {
|
|
1047
|
-
loop: LoopDef;
|
|
1048
|
-
file: string;
|
|
1049
|
-
code: string;
|
|
1050
|
-
}
|
|
1051
|
-
/**
|
|
1052
|
-
* Author + load a coded loop from a goal. Throws when the author emits no loadable module; with
|
|
1053
|
-
* `fallbackModel` set, the named fallback gets one attempt first. The returned `loop` is handed
|
|
1054
|
-
* to `loopChild(loop, journal)` and spawned as a first-class atom.
|
|
1055
|
-
*/
|
|
1056
|
-
declare function authorLoop(opts: AuthorLoopOptions): Promise<AuthoredLoop>;
|
|
1057
|
-
|
|
1058
882
|
/**
|
|
1059
883
|
*
|
|
1060
884
|
* `runLoop` — the topology-agnostic kernel built atop the sandbox SDK.
|
|
@@ -3890,13 +3714,6 @@ interface InMemoryRunContextOptions {
|
|
|
3890
3714
|
* leaf workers. Default `false`.
|
|
3891
3715
|
*/
|
|
3892
3716
|
readonly withDriver?: boolean;
|
|
3893
|
-
/**
|
|
3894
|
-
* Wrap the executor registry with `withLoopExecutor` so a spawned child marked
|
|
3895
|
-
* `role: 'loop'` resolves to the loop-executor (a coded, budget-conserving, gated,
|
|
3896
|
-
* steerable multi-round loop over a nested `Scope` on the same pool). Composes with
|
|
3897
|
-
* `withDriver` so loops and drivers coexist. Default `false`.
|
|
3898
|
-
*/
|
|
3899
|
-
readonly withLoop?: boolean;
|
|
3900
3717
|
}
|
|
3901
3718
|
/**
|
|
3902
3719
|
* The bundle of stores a supervised run needs, shaped to spread into `SupervisorOpts`.
|
|
@@ -4272,4 +4089,4 @@ declare function runInWorkspace<T>(ws: Workspace, body: (cwd: string) => Promise
|
|
|
4272
4089
|
commitOnInvalid?: boolean;
|
|
4273
4090
|
}): Promise<WorkspaceRun<T>>;
|
|
4274
4091
|
|
|
4275
|
-
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
|
|
4092
|
+
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, type OpenSandboxRunPromptOptions, 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
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
assertStrategyContract,
|
|
9
9
|
assertTraceDerivedFindings,
|
|
10
10
|
auditIntent,
|
|
11
|
-
authorLoop,
|
|
12
11
|
authorStrategy,
|
|
13
12
|
breadthStrategy,
|
|
14
13
|
buildSteerContext,
|
|
@@ -44,7 +43,6 @@ import {
|
|
|
44
43
|
jjWorkspace,
|
|
45
44
|
leaderboard,
|
|
46
45
|
localShell,
|
|
47
|
-
loopAuthorContract,
|
|
48
46
|
loopCampaignDispatch,
|
|
49
47
|
loopDispatch,
|
|
50
48
|
loopUntil,
|
|
@@ -91,7 +89,7 @@ import {
|
|
|
91
89
|
watchTrace,
|
|
92
90
|
widen,
|
|
93
91
|
worktreeFanout
|
|
94
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-PIPPLSOF.js";
|
|
95
93
|
import {
|
|
96
94
|
InMemoryResultBlobStore,
|
|
97
95
|
InMemorySpawnJournal,
|
|
@@ -115,13 +113,10 @@ import {
|
|
|
115
113
|
defaultDelegateBudget,
|
|
116
114
|
defaultProfileRichnessThresholds,
|
|
117
115
|
defaultSelectWinner,
|
|
118
|
-
defineLoop,
|
|
119
116
|
delegate,
|
|
120
117
|
driverAgent,
|
|
121
118
|
finalizeBestDelivered,
|
|
122
119
|
gateOnDeliverable,
|
|
123
|
-
loopChild,
|
|
124
|
-
loopRuntime,
|
|
125
120
|
probeSandboxCapabilities,
|
|
126
121
|
profileRichnessFinding,
|
|
127
122
|
routerBrain,
|
|
@@ -135,9 +130,8 @@ import {
|
|
|
135
130
|
supervise,
|
|
136
131
|
supervisorAgent,
|
|
137
132
|
supervisorInstructions,
|
|
138
|
-
withLoopExecutor,
|
|
139
133
|
workerFromBackend
|
|
140
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-N7EJV7N3.js";
|
|
141
135
|
import "./chunk-UD4BHQMI.js";
|
|
142
136
|
import {
|
|
143
137
|
createAgentEnvironmentProviderRegistry,
|
|
@@ -173,7 +167,6 @@ export {
|
|
|
173
167
|
assertTraceDerivedFindings,
|
|
174
168
|
assessAuthoredProfile,
|
|
175
169
|
auditIntent,
|
|
176
|
-
authorLoop,
|
|
177
170
|
authorStrategy,
|
|
178
171
|
authoredWorker,
|
|
179
172
|
breadthStrategy,
|
|
@@ -210,7 +203,6 @@ export {
|
|
|
210
203
|
defaultSelectWinner,
|
|
211
204
|
defaultToolDetectors,
|
|
212
205
|
defineLeaderboard,
|
|
213
|
-
defineLoop,
|
|
214
206
|
definePersona,
|
|
215
207
|
defineStrategy,
|
|
216
208
|
delegate,
|
|
@@ -233,11 +225,8 @@ export {
|
|
|
233
225
|
jjWorkspace,
|
|
234
226
|
leaderboard,
|
|
235
227
|
localShell,
|
|
236
|
-
loopAuthorContract,
|
|
237
228
|
loopCampaignDispatch,
|
|
238
|
-
loopChild,
|
|
239
229
|
loopDispatch,
|
|
240
|
-
loopRuntime,
|
|
241
230
|
loopUntil,
|
|
242
231
|
makeFinding,
|
|
243
232
|
mapSandboxEvent,
|
|
@@ -301,7 +290,6 @@ export {
|
|
|
301
290
|
verify,
|
|
302
291
|
watchTrace,
|
|
303
292
|
widen,
|
|
304
|
-
withLoopExecutor,
|
|
305
293
|
workerFromBackend,
|
|
306
294
|
worktreeFanout
|
|
307
295
|
};
|
package/dist/mcp/bin.js
CHANGED
package/dist/mcp/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
mcpToolsForRuntimeMcp,
|
|
8
8
|
mcpToolsForRuntimeMcpSubset
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-5AVV7KAH.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-
|
|
17
|
+
} from "../chunk-PIPPLSOF.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-
|
|
67
|
+
} from "../chunk-N7EJV7N3.js";
|
|
68
68
|
import "../chunk-UD4BHQMI.js";
|
|
69
69
|
import {
|
|
70
70
|
deleteBoxSafe,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.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": {
|
|
@@ -78,8 +78,6 @@ to its native default (`HARNESS_NATIVE_MODEL`) — never silently dropped.
|
|
|
78
78
|
| **Produce-then-gate / multi-judge quorum / fixed chain** | `verify` / `panel` / `pipeline` — `/loops` | canonical-api §3.1 |
|
|
79
79
|
| **Run depth-vs-breadth (or a custom strategy) over a stateful tool domain** | `runAgentic({ surface, task, mode\|strategy, budget })` — `/loops` | canonical-api §3.3 |
|
|
80
80
|
| **Author a new topology/strategy compactly** | `defineStrategy(name, body)` w/ `ctx.shot()`+`ctx.critique()` — `/loops` | canonical-api §3.3 |
|
|
81
|
-
| **Spawn a coded loop as a first-class atom** (bounded/gated/steerable, spawned + steered like a worker — the 3rd shape beside leaf worker + driver child) | `defineLoop(name, { maxRounds, round | agents, check })` + `loopChild`, wired via `createInMemoryRunContext({ withLoop: true })` — `/loops` — multi-agent = `agents: [proposer, verifier]` (declarative chain, not a bespoke `runTwoAgent…` fn); NOT a hand-driver looping in the model's head; the loop-executor owns maxRounds + conserved budget + gate + steer-between-rounds | canonical-api decision table |
|
|
82
|
-
| **Have an LLM AUTHOR a loop at runtime** (codemode: the supervisor writes a `defineLoop` module for a novel goal) | `authorLoop({ chat, goal, maxRounds, outDir })` → a `LoopDef` for `loopChild` — `/loops` — NOT a per-product loop-code generator or a VM around authored code; the sibling of `authorStrategy`, safety is the conserved pool + gate + `assertStrategyContract` lint | `src/runtime/loop-author.ts` |
|
|
83
81
|
| **Add a stateful tool-using domain** | implement `AgenticSurface` (5 hooks) — `/loops` | canonical-api §3.3 |
|
|
84
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 |
|
|
85
83
|
| **Benchmark: compare strategies + significance + Pareto on a domain** | `runBenchmark({ environment, tasks, worker, strategies })` — `/loops` | canonical-api §3.3 |
|
|
@@ -150,10 +148,6 @@ holds the load-bearing invariant the parallel breaks:
|
|
|
150
148
|
- a per-provider stream→event mapper for a single agent turn **≈**
|
|
151
149
|
`streamAgentTurn` + `collectAgentTurn` (0.85+; one `RuntimeStreamEvent`
|
|
152
150
|
contract over box / executor / chat, guaranteed terminal result+usage).
|
|
153
|
-
- a supervisor `act` with a `for (round…)` loop that spawns + checks + continues
|
|
154
|
-
in the model's reasoning **≈** `defineLoop` + `loopChild` (the loop-executor
|
|
155
|
-
enforces the round ceiling, the conserved pool, the completion gate, and
|
|
156
|
-
steer-between-rounds; a hand-driver loop enforces none of them).
|
|
157
151
|
|
|
158
152
|
## End-to-end recipe
|
|
159
153
|
|
|
@@ -30,7 +30,6 @@ The driver owns strategy.
|
|
|
30
30
|
| Review from several lenses | `panel` |
|
|
31
31
|
| Simulated user/product eval | `defineConversation` + `runConversation` |
|
|
32
32
|
| Dynamic topology / drivers of drivers | `Scope` or sandbox driver + `createCoordinationTools` |
|
|
33
|
-
| **A coded multi-round loop spawned + steered like a worker** | `defineLoop` + `loopChild` (the loop atom) |
|
|
34
33
|
| Mutate a shared repo | git branch/clone loop with typed merge outcomes |
|
|
35
34
|
|
|
36
35
|
If a fixed combinator solves it, do not use a dynamic driver.
|
|
@@ -115,78 +114,6 @@ When the driver lives in a sandbox, expose the same verbs through
|
|
|
115
114
|
`steer_worker`, `list_questions`, `answer_question`, `ask_parent`, `stop`, and
|
|
116
115
|
optional analyst tools.
|
|
117
116
|
|
|
118
|
-
## The Loop Atom — a coded loop spawned like a worker
|
|
119
|
-
|
|
120
|
-
When the loop itself is the reusable unit (a research loop, a verify loop, an
|
|
121
|
-
evolve loop), make it a spawnable atom instead of a hand-driver. `defineLoop`
|
|
122
|
-
authors the body; the runtime owns the round ceiling, the conserved budget, the
|
|
123
|
-
gate, and steer-between-rounds. A supervisor spawns / observes / steers it with
|
|
124
|
-
the SAME coordination verbs as a worker.
|
|
125
|
-
|
|
126
|
-
Two ways to author the round. **`agents`** — a MULTI-AGENT loop as a declarative
|
|
127
|
-
CHAIN (the common case): an ordered list of named agents piped each round,
|
|
128
|
-
`task -> agents[0] -> agents[1] -> ... -> out`, each agent's return feeding the next
|
|
129
|
-
as `prior`. "Two agents" is self-evident from the list — no bespoke `runTwoAgent...`
|
|
130
|
-
function. **`round`** — freeform code for any other topology (fan-out, dynamic
|
|
131
|
-
routing). Provide exactly one.
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
// A two-agent research loop as a CHAIN: proposer drafts, verifier checks the draft.
|
|
135
|
-
const research = defineLoop('research', {
|
|
136
|
-
maxRounds: 3,
|
|
137
|
-
agents: [
|
|
138
|
-
{ name: 'proposer', run: async ({ scope, steer }, _prior) => {
|
|
139
|
-
const w = scope.spawn(researcher, { steer }, { budget: perRound, label: 'propose' })
|
|
140
|
-
if (!w.ok) throw new Error(w.reason)
|
|
141
|
-
return await scope.next() // the draft
|
|
142
|
-
} },
|
|
143
|
-
{ name: 'verifier', run: async ({ scope }, draft) => {
|
|
144
|
-
const w = scope.spawn(verifier, { draft }, { budget: perRound, label: 'verify' })
|
|
145
|
-
if (!w.ok) throw new Error(w.reason)
|
|
146
|
-
return await scope.next() // the verified result -> round out
|
|
147
|
-
} },
|
|
148
|
-
],
|
|
149
|
-
check: (out) => readinessPasses(out), // the deployable completion oracle
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
// Spawn it exactly like a worker (role:'loop' resolves to the loop-executor).
|
|
153
|
-
const r = scope.spawn(loopChild(research, journal), task, { budget, label: 'research-loop' })
|
|
154
|
-
// Wire once at the top: createInMemoryRunContext({ withDriver: true, withLoop: true }).
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
TOPOLOGY: `agents` is a sequential CHAIN only. It is NOT parallel and NOT a graph —
|
|
158
|
-
the loop's nested `scope.next()` is one shared queue, so parallel agents would steal
|
|
159
|
-
each other's settlements. For fan-out (a panel of critics, best-of-N), dynamic
|
|
160
|
-
routing, or any non-linear shape, use the freeform `round`: spawn every handle first,
|
|
161
|
-
then drain N times, or branch on the data yourself. `fanout`/`panel`/`pipeline` cover
|
|
162
|
-
the reactive-layer parallel case.
|
|
163
|
-
|
|
164
|
-
Rules: the loop is code, not the model's judgment — that is what makes maxRounds,
|
|
165
|
-
the budget, and the gate ENFORCED rather than hoped-for. Give the loop a real
|
|
166
|
-
`check` (an executable oracle, never a self-judged score). Budget nests: the pool
|
|
167
|
-
reserves each spawn's full ceiling until it settles, so pool > loop > per-round.
|
|
168
|
-
|
|
169
|
-
### Codemode — an LLM authors the loop at runtime
|
|
170
|
-
|
|
171
|
-
When the supervisor should WRITE the loop for a novel goal (not pick a hand-built
|
|
172
|
-
one), use `authorLoop` — the codemode seam over the atom, the sibling of
|
|
173
|
-
`authorStrategy`. It shows the model `loopAuthorContract` (the exact `defineLoop`
|
|
174
|
-
module shape, exported so a skill/GEPA pass can evolve it), extracts the fenced
|
|
175
|
-
module, lints it with `assertStrategyContract` (only the loops import; no
|
|
176
|
-
require/eval/fetch/process/node builtins), writes it, dynamic-imports it, and
|
|
177
|
-
validates the default export is a `LoopDef` — ready for `loopChild`.
|
|
178
|
-
|
|
179
|
-
```ts
|
|
180
|
-
const { loop } = await authorLoop({ chat, goal, maxRounds, outDir, fallbackModel })
|
|
181
|
-
const spawned = scope.spawn(loopChild(loop, journal), task, { budget, label: 'authored-loop' })
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Safety is structural, same as `authorStrategy`: the authored body can be WRONG
|
|
185
|
-
but cannot overspend (conserved pool), cannot skip the check (the runtime gates
|
|
186
|
-
it), and cannot reach outside the loops surface (the lint). Do not build a
|
|
187
|
-
per-product loop-code generator or a VM sandbox around authored loops — `authorLoop`
|
|
188
|
-
is that seam.
|
|
189
|
-
|
|
190
117
|
## Role Boundaries
|
|
191
118
|
|
|
192
119
|
- **Verifier**: executable shippability gate; controls accept/reject.
|