@tangle-network/agent-runtime 0.102.0 → 0.102.2

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 (77) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.js +5 -3
  3. package/dist/agent.js.map +1 -1
  4. package/dist/analyst-loop.d.ts +1 -1
  5. package/dist/candidate-execution/index.js +5 -4
  6. package/dist/{chunk-SPCD4IQQ.js → chunk-377GOJHJ.js} +2 -2
  7. package/dist/{chunk-LKKIM5QD.js → chunk-3DW5DEKQ.js} +3 -3
  8. package/dist/{chunk-4AMAFNUD.js → chunk-7FJJUC73.js} +311 -40
  9. package/dist/chunk-7FJJUC73.js.map +1 -0
  10. package/dist/{chunk-DA7YL6I4.js → chunk-CK76OZPM.js} +3 -3
  11. package/dist/{chunk-KSBUSEUA.js → chunk-EKUMRQNR.js} +2 -2
  12. package/dist/{chunk-23Z7N5IG.js → chunk-J6V6DWWS.js} +5 -5
  13. package/dist/{chunk-AIBIRAJ6.js → chunk-KSM6GFHP.js} +2 -2
  14. package/dist/chunk-L5DST3QC.js +351 -0
  15. package/dist/chunk-L5DST3QC.js.map +1 -0
  16. package/dist/{chunk-TGDHHHH4.js → chunk-LJLG734E.js} +12 -253
  17. package/dist/chunk-LJLG734E.js.map +1 -0
  18. package/dist/{chunk-MAONWP4R.js → chunk-QCXD7NHM.js} +611 -1419
  19. package/dist/chunk-QCXD7NHM.js.map +1 -0
  20. package/dist/chunk-ROILMKDL.js +1338 -0
  21. package/dist/chunk-ROILMKDL.js.map +1 -0
  22. package/dist/{chunk-N2CEE5Q3.js → chunk-SCOHHMKU.js} +3 -3
  23. package/dist/chunk-SQ3ZJH3Y.js +3082 -0
  24. package/dist/chunk-SQ3ZJH3Y.js.map +1 -0
  25. package/dist/chunk-UPWGXKXB.js +254 -0
  26. package/dist/chunk-UPWGXKXB.js.map +1 -0
  27. package/dist/{chunk-KVJQV342.js → chunk-ZUCUAFVF.js} +26 -1778
  28. package/dist/chunk-ZUCUAFVF.js.map +1 -0
  29. package/dist/{completion-gate-C80jiRfN.d.ts → completion-gate-C6dhVN-N.d.ts} +2 -2
  30. package/dist/{coordination-BFE3Den7.d.ts → coordination-D9l_YmwW.d.ts} +6 -6
  31. package/dist/environment-provider.d.ts +2 -2
  32. package/dist/{improve-CIml6hT3.d.ts → improve-B40dRu0X.d.ts} +40 -19
  33. package/dist/index.d.ts +329 -21
  34. package/dist/index.js +541 -137
  35. package/dist/index.js.map +1 -1
  36. package/dist/intelligence.d.ts +5 -5
  37. package/dist/intelligence.js +7 -5
  38. package/dist/intelligence.js.map +1 -1
  39. package/dist/knowledge.d.ts +8 -8
  40. package/dist/knowledge.js +9 -7
  41. package/dist/{local-harness-ZqCx51u7.d.ts → local-harness-CtK9dSny.d.ts} +14 -2
  42. package/dist/{loop-runner-bin-Cn1N2rRo.d.ts → loop-runner-bin-PnWslIw4.d.ts} +2 -2
  43. package/dist/loop-runner-bin.d.ts +6 -6
  44. package/dist/loop-runner-bin.js +6 -4
  45. package/dist/loops.d.ts +231 -460
  46. package/dist/loops.js +58 -37
  47. package/dist/mcp/bin.js +2 -2
  48. package/dist/mcp/index.d.ts +184 -12
  49. package/dist/mcp/index.js +31 -9
  50. package/dist/mcp/index.js.map +1 -1
  51. package/dist/mcp/memory-bin.d.ts +1 -0
  52. package/dist/mcp/memory-bin.js +22 -0
  53. package/dist/mcp/memory-bin.js.map +1 -0
  54. package/dist/profiles.d.ts +3 -3
  55. package/dist/structural-rollout-D7xik9XR.d.ts +446 -0
  56. package/dist/{substrate-DO2GHNg2.d.ts → substrate-Dyiqmd3o.d.ts} +1 -1
  57. package/dist/{supervise-BLPI50-w.d.ts → supervise-BQdNAXtK.d.ts} +4 -4
  58. package/dist/testing.js +10 -8
  59. package/dist/testing.js.map +1 -1
  60. package/dist/{types-B3vAW0Oq.d.ts → types-CLat4bT9.d.ts} +1 -1
  61. package/dist/{types-CmnA2iL3.d.ts → types-D870JlH0.d.ts} +2 -2
  62. package/dist/{worktree-fanout-DCA3G4bO.d.ts → worktree-fanout-DsIR4d6w.d.ts} +234 -234
  63. package/package.json +4 -3
  64. package/dist/chunk-4AMAFNUD.js.map +0 -1
  65. package/dist/chunk-IKGCKPDX.js +0 -1115
  66. package/dist/chunk-IKGCKPDX.js.map +0 -1
  67. package/dist/chunk-KVJQV342.js.map +0 -1
  68. package/dist/chunk-MAONWP4R.js.map +0 -1
  69. package/dist/chunk-TGDHHHH4.js.map +0 -1
  70. package/dist/{chunk-SPCD4IQQ.js.map → chunk-377GOJHJ.js.map} +0 -0
  71. package/dist/{chunk-LKKIM5QD.js.map → chunk-3DW5DEKQ.js.map} +0 -0
  72. package/dist/{chunk-DA7YL6I4.js.map → chunk-CK76OZPM.js.map} +0 -0
  73. package/dist/{chunk-KSBUSEUA.js.map → chunk-EKUMRQNR.js.map} +0 -0
  74. package/dist/{chunk-23Z7N5IG.js.map → chunk-J6V6DWWS.js.map} +0 -0
  75. package/dist/{chunk-AIBIRAJ6.js.map → chunk-KSM6GFHP.js.map} +0 -0
  76. package/dist/{chunk-N2CEE5Q3.js.map → chunk-SCOHHMKU.js.map} +0 -0
  77. package/dist/{sanitize-BTSsdBXw.d.ts → sanitize-DEbPNtyI.d.ts} +58 -58
@@ -1,64 +1,6 @@
1
1
  import { ControlEvalResult, KnowledgeReadinessReport, KnowledgeRequirement } from '@tangle-network/agent-eval';
2
2
  import { e as AgentRuntimeEvent, R as RuntimeStreamEvent, f as AgentTaskStatus } from './types-BwoZWq-i.js';
3
3
 
4
- /**
5
- * THE canonical agentic tool-loop. One inference turn → run any requested tools → fold the
6
- * results back as `tool` messages → repeat, until the model answers without a tool call or the
7
- * turn budget is hit. One turn = one inference call (the equal-compute unit vs random@k).
8
- *
9
- * The inference is an INJECTABLE seam (`ToolLoopChat`): a router model, a sandboxed CLI
10
- * harness, or a scripted mock all satisfy it — so the loop is backend-agnostic. The metered /
11
- * steerable concerns the call sites add (a driver's conserved-pool + deadline bound; an inline
12
- * executor's inbox flush + abort) attach via optional `hooks`; the skeleton stays one copy.
13
- */
14
-
15
- type Msg = Record<string, unknown>;
16
- /** One inference turn over the running conversation + the tool specs → the model's text, any
17
- * tool calls, and token usage. The seam every brain satisfies. */
18
- type ToolLoopChat = (messages: ReadonlyArray<Msg>, tools: ReadonlyArray<ToolSpec>) => Promise<{
19
- content?: string | null;
20
- toolCalls: RouterToolCall[];
21
- usage?: {
22
- input: number;
23
- output: number;
24
- };
25
- /** The turn's inference cost (usd) when the provider priced it — for callers that meter usd
26
- * into a conserved pool (the supervisor brain). `runBrainLoop` itself ignores it. */
27
- costUsd?: number;
28
- }>;
29
- /** Self-compaction — bound the loop's OWN context window the way a fresh-respawn (dumb-Ralph) loop
30
- * does, but in place. A stateless chat API re-sends the WHOLE running conversation every turn, so an
31
- * agent that accumulates dozens of turns of tool results re-bills its entire transcript on every
32
- * inference — the context-overflow-one-level-up that the conserved budget pool cannot fix. With
33
- * compaction set, once the conversation exceeds `thresholdTokens` the accumulated middle (every prior
34
- * assistant turn + tool result) is distilled into ONE compact progress note and the conversation is
35
- * reset to `[...head, digest]`: the preserved head (system + the original task) survives, the stale
36
- * turn-by-turn history does not. The model keeps deciding; it stops re-billing the whole transcript.
37
- * Fires at a CLEAN turn boundary (after a turn's tool results are folded in, before the next
38
- * inference) so it never orphans an assistant `tool_calls` from its `tool` replies. */
39
- interface ToolLoopCompaction {
40
- /** Compact once the estimated token count of the conversation exceeds this. */
41
- readonly thresholdTokens: number;
42
- /** Distill the conversation into a compact progress note that REPLACES the middle. Receives the
43
- * full conversation (so it can summarize everything done so far); returns the digest string. */
44
- readonly distill: (messages: ReadonlyArray<Msg>) => Promise<string> | string;
45
- /** Leading messages preserved verbatim (system + the original task). Default 2. */
46
- readonly preserveHead?: number;
47
- /** Token estimator over the conversation. Default ≈ chars/4 (incl. tool-call arguments). */
48
- readonly estimateTokens?: (messages: ReadonlyArray<Msg>) => number;
49
- /** Notified each time a compaction fires — for observability/metering. */
50
- readonly onCompact?: (info: {
51
- turn: number;
52
- beforeTokens: number;
53
- afterTokens: number;
54
- }) => void;
55
- }
56
- /** Public supervisor-facing compaction config: same knobs as the primitive, but `distill` is optional
57
- * because the supervisor has a default digest that combines a brain note with live worker state. */
58
- type ToolLoopCompactionOptions = Omit<ToolLoopCompaction, 'distill'> & {
59
- readonly distill?: ToolLoopCompaction['distill'];
60
- };
61
-
62
4
  /**
63
5
  * The one router chat client: direct OpenAI-compatible completions through the
64
6
  * Tangle router — the cheapest dial, no sandbox. Three layers: `routerChatWithUsage`
@@ -216,6 +158,64 @@ declare function routerBrain(cfg: RouterConfig, opts?: {
216
158
  temperature?: number;
217
159
  }): ToolLoopChat;
218
160
 
161
+ /**
162
+ * THE canonical agentic tool-loop. One inference turn → run any requested tools → fold the
163
+ * results back as `tool` messages → repeat, until the model answers without a tool call or the
164
+ * turn budget is hit. One turn = one inference call (the equal-compute unit vs random@k).
165
+ *
166
+ * The inference is an INJECTABLE seam (`ToolLoopChat`): a router model, a sandboxed CLI
167
+ * harness, or a scripted mock all satisfy it — so the loop is backend-agnostic. The metered /
168
+ * steerable concerns the call sites add (a driver's conserved-pool + deadline bound; an inline
169
+ * executor's inbox flush + abort) attach via optional `hooks`; the skeleton stays one copy.
170
+ */
171
+
172
+ type Msg = Record<string, unknown>;
173
+ /** One inference turn over the running conversation + the tool specs → the model's text, any
174
+ * tool calls, and token usage. The seam every brain satisfies. */
175
+ type ToolLoopChat = (messages: ReadonlyArray<Msg>, tools: ReadonlyArray<ToolSpec>) => Promise<{
176
+ content?: string | null;
177
+ toolCalls: RouterToolCall[];
178
+ usage?: {
179
+ input: number;
180
+ output: number;
181
+ };
182
+ /** The turn's inference cost (usd) when the provider priced it — for callers that meter usd
183
+ * into a conserved pool (the supervisor brain). `runBrainLoop` itself ignores it. */
184
+ costUsd?: number;
185
+ }>;
186
+ /** Self-compaction — bound the loop's OWN context window the way a fresh-respawn (dumb-Ralph) loop
187
+ * does, but in place. A stateless chat API re-sends the WHOLE running conversation every turn, so an
188
+ * agent that accumulates dozens of turns of tool results re-bills its entire transcript on every
189
+ * inference — the context-overflow-one-level-up that the conserved budget pool cannot fix. With
190
+ * compaction set, once the conversation exceeds `thresholdTokens` the accumulated middle (every prior
191
+ * assistant turn + tool result) is distilled into ONE compact progress note and the conversation is
192
+ * reset to `[...head, digest]`: the preserved head (system + the original task) survives, the stale
193
+ * turn-by-turn history does not. The model keeps deciding; it stops re-billing the whole transcript.
194
+ * Fires at a CLEAN turn boundary (after a turn's tool results are folded in, before the next
195
+ * inference) so it never orphans an assistant `tool_calls` from its `tool` replies. */
196
+ interface ToolLoopCompaction {
197
+ /** Compact once the estimated token count of the conversation exceeds this. */
198
+ readonly thresholdTokens: number;
199
+ /** Distill the conversation into a compact progress note that REPLACES the middle. Receives the
200
+ * full conversation (so it can summarize everything done so far); returns the digest string. */
201
+ readonly distill: (messages: ReadonlyArray<Msg>) => Promise<string> | string;
202
+ /** Leading messages preserved verbatim (system + the original task). Default 2. */
203
+ readonly preserveHead?: number;
204
+ /** Token estimator over the conversation. Default ≈ chars/4 (incl. tool-call arguments). */
205
+ readonly estimateTokens?: (messages: ReadonlyArray<Msg>) => number;
206
+ /** Notified each time a compaction fires — for observability/metering. */
207
+ readonly onCompact?: (info: {
208
+ turn: number;
209
+ beforeTokens: number;
210
+ afterTokens: number;
211
+ }) => void;
212
+ }
213
+ /** Public supervisor-facing compaction config: same knobs as the primitive, but `distill` is optional
214
+ * because the supervisor has a default digest that combines a brain note with live worker state. */
215
+ type ToolLoopCompactionOptions = Omit<ToolLoopCompaction, 'distill'> & {
216
+ readonly distill?: ToolLoopCompaction['distill'];
217
+ };
218
+
219
219
  /**
220
220
  *
221
221
  * Sanitization for runtime telemetry. The rule: nothing user-controlled leaks