@animalabs/agent-framework 0.26.1 → 0.27.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/README.md +57 -7
- package/dist/src/agent.d.ts +263 -22
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +531 -54
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +1 -2
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/auto-continue.d.ts +33 -0
- package/dist/src/auto-continue.d.ts.map +1 -0
- package/dist/src/auto-continue.js +35 -0
- package/dist/src/auto-continue.js.map +1 -0
- package/dist/src/code-execution/isolate/scripts.d.ts +11 -0
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/scripts.js +5 -1
- package/dist/src/code-execution/isolate/scripts.js.map +1 -1
- package/dist/src/framework.d.ts +829 -156
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +3906 -1008
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +309 -46
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +2117 -395
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/gate/index.d.ts +2 -2
- package/dist/src/gate/index.d.ts.map +1 -1
- package/dist/src/gate/index.js +1 -1
- package/dist/src/gate/index.js.map +1 -1
- package/dist/src/gate/recipe-reconcile.d.ts +103 -0
- package/dist/src/gate/recipe-reconcile.d.ts.map +1 -0
- package/dist/src/gate/recipe-reconcile.js +325 -0
- package/dist/src/gate/recipe-reconcile.js.map +1 -0
- package/dist/src/gate/types.d.ts +68 -8
- package/dist/src/gate/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +6 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts +433 -113
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +1152 -434
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/conversation-router.d.ts +16 -8
- package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
- package/dist/src/mcpl/conversation-router.js +29 -15
- package/dist/src/mcpl/conversation-router.js.map +1 -1
- package/dist/src/mcpl/convert-block.d.ts.map +1 -1
- package/dist/src/mcpl/convert-block.js +14 -2
- package/dist/src/mcpl/convert-block.js.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts +7 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.js +32 -7
- package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
- package/dist/src/mcpl/index.d.ts +5 -1
- package/dist/src/mcpl/index.d.ts.map +1 -1
- package/dist/src/mcpl/index.js +4 -0
- package/dist/src/mcpl/index.js.map +1 -1
- package/dist/src/mcpl/inference-router.d.ts +14 -2
- package/dist/src/mcpl/inference-router.d.ts.map +1 -1
- package/dist/src/mcpl/inference-router.js +73 -28
- package/dist/src/mcpl/inference-router.js.map +1 -1
- package/dist/src/mcpl/prose-grammar.d.ts +4 -0
- package/dist/src/mcpl/prose-grammar.d.ts.map +1 -1
- package/dist/src/mcpl/prose-grammar.js +6 -0
- package/dist/src/mcpl/prose-grammar.js.map +1 -1
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
- package/dist/src/mcpl/protocol-family.js +3 -0
- package/dist/src/mcpl/protocol-family.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +20 -2
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +33 -11
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts +63 -42
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
- package/dist/src/mcpl/reference-fetcher.js +177 -145
- package/dist/src/mcpl/reference-fetcher.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +380 -46
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +737 -78
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +82 -3
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +132 -7
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.d.ts +11 -0
- package/dist/src/mcpl/tool-lifecycle.d.ts.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.js +21 -0
- package/dist/src/mcpl/tool-lifecycle.js.map +1 -1
- package/dist/src/mcpl/tool-presence.d.ts +259 -0
- package/dist/src/mcpl/tool-presence.d.ts.map +1 -0
- package/dist/src/mcpl/tool-presence.js +628 -0
- package/dist/src/mcpl/tool-presence.js.map +1 -0
- package/dist/src/mcpl/tool-result-normalize.d.ts +9 -3
- package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -1
- package/dist/src/mcpl/tool-result-normalize.js +14 -6
- package/dist/src/mcpl/tool-result-normalize.js.map +1 -1
- package/dist/src/mcpl/tool-signature.d.ts +39 -0
- package/dist/src/mcpl/tool-signature.d.ts.map +1 -0
- package/dist/src/mcpl/tool-signature.js +292 -0
- package/dist/src/mcpl/tool-signature.js.map +1 -0
- package/dist/src/mcpl/toolset-host.d.ts +200 -0
- package/dist/src/mcpl/toolset-host.d.ts.map +1 -0
- package/dist/src/mcpl/toolset-host.js +621 -0
- package/dist/src/mcpl/toolset-host.js.map +1 -0
- package/dist/src/mcpl/toolsets-module.d.ts +80 -0
- package/dist/src/mcpl/toolsets-module.d.ts.map +1 -0
- package/dist/src/mcpl/toolsets-module.js +431 -0
- package/dist/src/mcpl/toolsets-module.js.map +1 -0
- package/dist/src/mcpl/transport.d.ts +2 -2
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +3 -2
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +21 -1
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/mcpl/visible-content.d.ts +7 -9
- package/dist/src/mcpl/visible-content.d.ts.map +1 -1
- package/dist/src/mcpl/visible-content.js +21 -9
- package/dist/src/mcpl/visible-content.js.map +1 -1
- package/dist/src/module-registry.d.ts +23 -8
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +68 -15
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/discord/index.js +1 -1
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts +2 -1
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +51 -17
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/history/semantic.d.ts +108 -6
- package/dist/src/modules/history/semantic.d.ts.map +1 -1
- package/dist/src/modules/history/semantic.js +273 -57
- package/dist/src/modules/history/semantic.js.map +1 -1
- package/dist/src/modules/workspace/direct-write.d.ts +181 -0
- package/dist/src/modules/workspace/direct-write.d.ts.map +1 -0
- package/dist/src/modules/workspace/direct-write.js +384 -0
- package/dist/src/modules/workspace/direct-write.js.map +1 -0
- package/dist/src/modules/workspace/edit-text.d.ts +26 -12
- package/dist/src/modules/workspace/edit-text.d.ts.map +1 -1
- package/dist/src/modules/workspace/edit-text.js +58 -28
- package/dist/src/modules/workspace/edit-text.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts +10 -0
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +1 -1
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +246 -27
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +1216 -236
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/read-page.d.ts +41 -0
- package/dist/src/modules/workspace/read-page.d.ts.map +1 -0
- package/dist/src/modules/workspace/read-page.js +213 -0
- package/dist/src/modules/workspace/read-page.js.map +1 -0
- package/dist/src/modules/workspace/result-text.d.ts +67 -0
- package/dist/src/modules/workspace/result-text.d.ts.map +1 -0
- package/dist/src/modules/workspace/result-text.js +94 -0
- package/dist/src/modules/workspace/result-text.js.map +1 -0
- package/dist/src/modules/workspace/text.d.ts +29 -12
- package/dist/src/modules/workspace/text.d.ts.map +1 -1
- package/dist/src/modules/workspace/text.js +35 -33
- package/dist/src/modules/workspace/text.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +41 -17
- package/dist/src/modules/workspace/types.d.ts.map +1 -1
- package/dist/src/modules/workspace/types.js.map +1 -1
- package/dist/src/sent-rows.d.ts +59 -0
- package/dist/src/sent-rows.d.ts.map +1 -0
- package/dist/src/sent-rows.js +145 -0
- package/dist/src/sent-rows.js.map +1 -0
- package/dist/src/silent-heartbeat.d.ts +17 -10
- package/dist/src/silent-heartbeat.d.ts.map +1 -1
- package/dist/src/silent-heartbeat.js.map +1 -1
- package/dist/src/stable-hash.d.ts +3 -0
- package/dist/src/stable-hash.d.ts.map +1 -0
- package/dist/src/stable-hash.js +15 -0
- package/dist/src/stable-hash.js.map +1 -0
- package/dist/src/stored-injections.d.ts +99 -0
- package/dist/src/stored-injections.d.ts.map +1 -0
- package/dist/src/stored-injections.js +106 -0
- package/dist/src/stored-injections.js.map +1 -0
- package/dist/src/text-as-stored.d.ts +4 -3
- package/dist/src/text-as-stored.d.ts.map +1 -1
- package/dist/src/text-as-stored.js +4 -3
- package/dist/src/text-as-stored.js.map +1 -1
- package/dist/src/thinking-drops.d.ts +81 -0
- package/dist/src/thinking-drops.d.ts.map +1 -0
- package/dist/src/thinking-drops.js +103 -0
- package/dist/src/thinking-drops.js.map +1 -0
- package/dist/src/tool-image-ledger.d.ts +9 -8
- package/dist/src/tool-image-ledger.d.ts.map +1 -1
- package/dist/src/tool-image-ledger.js +9 -8
- package/dist/src/tool-image-ledger.js.map +1 -1
- package/dist/src/tool-presentation.d.ts.map +1 -1
- package/dist/src/tool-presentation.js +3 -1
- package/dist/src/tool-presentation.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +4 -2
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +21 -6
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tool-result-history.d.ts +186 -21
- package/dist/src/tool-result-history.d.ts.map +1 -1
- package/dist/src/tool-result-history.js +428 -89
- package/dist/src/tool-result-history.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +17 -9
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +84 -37
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/types/agent.d.ts +186 -7
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +19 -2
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +24 -3
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +90 -7
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +57 -2
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/agent.ts +593 -60
- package/src/api/server.ts +1 -2
- package/src/auto-continue.ts +42 -0
- package/src/code-execution/isolate/scripts.ts +11 -3
- package/src/framework.ts +4004 -1026
- package/src/gate/event-gate.ts +2315 -389
- package/src/gate/index.ts +2 -1
- package/src/gate/recipe-reconcile.ts +355 -0
- package/src/gate/types.ts +70 -8
- package/src/index.ts +7 -4
- package/src/mcpl/channel-registry.ts +1220 -467
- package/src/mcpl/conversation-router.ts +34 -16
- package/src/mcpl/convert-block.ts +14 -1
- package/src/mcpl/hook-orchestrator.ts +33 -6
- package/src/mcpl/index.ts +6 -1
- package/src/mcpl/inference-router.ts +79 -34
- package/src/mcpl/prose-grammar.ts +7 -0
- package/src/mcpl/protocol-family.ts +2 -0
- package/src/mcpl/push-coalescer.ts +51 -13
- package/src/mcpl/reference-fetcher.ts +201 -162
- package/src/mcpl/references.ts +852 -78
- package/src/mcpl/server-connection.ts +145 -7
- package/src/mcpl/tool-lifecycle.ts +21 -0
- package/src/mcpl/tool-presence.ts +650 -0
- package/src/mcpl/tool-result-normalize.ts +18 -6
- package/src/mcpl/tool-signature.ts +285 -0
- package/src/mcpl/toolset-host.ts +637 -0
- package/src/mcpl/toolsets-module.ts +451 -0
- package/src/mcpl/transport.ts +3 -2
- package/src/mcpl/types.ts +22 -1
- package/src/mcpl/visible-content.ts +22 -9
- package/src/module-registry.ts +77 -24
- package/src/modules/discord/index.ts +1 -1
- package/src/modules/history/index.ts +48 -18
- package/src/modules/history/semantic.ts +308 -54
- package/src/modules/workspace/direct-write.ts +425 -0
- package/src/modules/workspace/edit-text.ts +82 -35
- package/src/modules/workspace/effects.ts +1 -1
- package/src/modules/workspace/index.ts +1274 -241
- package/src/modules/workspace/read-page.ts +222 -0
- package/src/modules/workspace/result-text.ts +119 -0
- package/src/modules/workspace/text.ts +58 -32
- package/src/modules/workspace/types.ts +41 -17
- package/src/sent-rows.ts +162 -0
- package/src/silent-heartbeat.ts +17 -10
- package/src/stable-hash.ts +14 -0
- package/src/stored-injections.ts +131 -0
- package/src/text-as-stored.ts +4 -3
- package/src/thinking-drops.ts +141 -0
- package/src/tool-image-ledger.ts +9 -8
- package/src/tool-presentation.ts +3 -1
- package/src/tool-result-guard.ts +19 -6
- package/src/tool-result-history.ts +488 -88
- package/src/tune-out/coordinator.ts +80 -37
- package/src/types/agent.ts +189 -7
- package/src/types/events.ts +19 -2
- package/src/types/framework.ts +21 -3
- package/src/types/module.ts +86 -7
- package/src/types/trace.ts +58 -2
package/src/types/module.ts
CHANGED
|
@@ -25,6 +25,29 @@ export interface MessageQuery {
|
|
|
25
25
|
metadata?: Record<string, unknown>;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* A context injection a module gathers (Module.gatherContext).
|
|
30
|
+
*
|
|
31
|
+
* An `afterUser` one is stored in the agent's window, as the message
|
|
32
|
+
* `compile()` would have placed after the last user message, where it then
|
|
33
|
+
* stays: so the replies after it keep their thinking, and the cache keeps the
|
|
34
|
+
* turns before it. The same source's unchanged content isn't stored again
|
|
35
|
+
* while the copy the agent will read as current has it whole: the one its
|
|
36
|
+
* last request held, or a newer one a start stored whose compile then
|
|
37
|
+
* didn't record. Once a fold has summarized it or a strategy's window has
|
|
38
|
+
* scrolled past it, it's stored again, as one more row. (See
|
|
39
|
+
* stored-injections.ts.)
|
|
40
|
+
*
|
|
41
|
+
* `placedEachCompile: true` opts out: `compile()` places the injection after
|
|
42
|
+
* the last user message at each start, near the end, as before it was
|
|
43
|
+
* stored. That's for context meant to stay near the end, such as
|
|
44
|
+
* instructions moved off `system`. Its cost: it moves, and on a model that
|
|
45
|
+
* binds a reply's thinking to everything before it, every reply after its old
|
|
46
|
+
* place loses its thinking. It has no effect on a `system` or `beforeUser`
|
|
47
|
+
* injection, which `compile()` always places.
|
|
48
|
+
*/
|
|
49
|
+
export type ModuleContextInjection = ContextInjection & { placedEachCompile?: true };
|
|
50
|
+
|
|
28
51
|
/**
|
|
29
52
|
* A message as a module context's reads answer it: a stored row, or a row
|
|
30
53
|
* for a write the framework holds (`held`). Either is marked
|
|
@@ -159,9 +182,16 @@ export interface Module {
|
|
|
159
182
|
* Called before each inference to collect data (e.g., HUD overlays, game state)
|
|
160
183
|
* that should be injected into the compiled context.
|
|
161
184
|
* Complementary to MCPL push-based hooks — modules pull via gatherContext.
|
|
185
|
+
* An `afterUser` injection is appended to the agent's window, where it
|
|
186
|
+
* then stays, unless the copy the agent will read as current has the same
|
|
187
|
+
* content, every part of it (the one its last request held, or a newer
|
|
188
|
+
* one a start stored whose compile then didn't record), or it opts out
|
|
189
|
+
* (ModuleContextInjection.placedEachCompile). At a
|
|
190
|
+
* turn's start or a restart after tool results, that's where `compile()`
|
|
191
|
+
* would have placed it.
|
|
162
192
|
* Adapted from Anarchid/agent-framework@mcpl-module-proto.
|
|
163
193
|
*/
|
|
164
|
-
gatherContext?(agentName: string): Promise<
|
|
194
|
+
gatherContext?(agentName: string): Promise<ModuleContextInjection[]>;
|
|
165
195
|
|
|
166
196
|
/**
|
|
167
197
|
* Called once an agent's tool batch has completed — when the round's last
|
|
@@ -304,11 +334,43 @@ export interface ModuleContext {
|
|
|
304
334
|
* (ModuleMessage.held). The writes a process held, and keeps across a
|
|
305
335
|
* restart, show to the next process's modules once create() has restored
|
|
306
336
|
* them, which is after every module's start().
|
|
337
|
+
*
|
|
338
|
+
* With `opts.forAgent`, it's added to the named agent's window instead: a
|
|
339
|
+
* conversation fork's or a running sub-agent's own store, or, for an
|
|
340
|
+
* ordinary resident, the residents' shared slot. It's held while that
|
|
341
|
+
* agent's turn is alive, as a write for the primary is while the
|
|
342
|
+
* primary's is. A name that isn't a registered agent when the write is
|
|
343
|
+
* made, or the empty name, throws, naming the registered ones, so a write
|
|
344
|
+
* for a launcher that has gone is heard. For an ephemeral run (a
|
|
345
|
+
* sub-agent's run) or a conversation fork, whose window nothing reads
|
|
346
|
+
* after it's released, a write it never read goes to the primary at its
|
|
347
|
+
* release, as the write itself, through the primary's own delivery. It's
|
|
348
|
+
* read as the framework reads a notice: once it's below the target's
|
|
349
|
+
* consumed watermark, which a compile built to send moves when it
|
|
350
|
+
* commits (a row that compile's strategy left out counts as read too),
|
|
351
|
+
* and a tool round moves when it injects messages into a stream that
|
|
352
|
+
* declares it carries them. So one that waited for its target's end (a
|
|
353
|
+
* run's end, or a fork's last turn), one stored while it was idle and
|
|
354
|
+
* never sent, one stored at a tool round that ended the turn, and one
|
|
355
|
+
* injected into a stream that didn't declare it carries injections go to
|
|
356
|
+
* the primary. The framework's own
|
|
357
|
+
* writes for a run or a fork are unchanged: they stay in its store,
|
|
358
|
+
* unless they're notices the primary already takes in their place (a
|
|
359
|
+
* failed reply, or a channel notice its reader could act on). getMessage,
|
|
360
|
+
* editMessage and removeMessage read the delivery agent's window (the
|
|
361
|
+
* primary's, or the first agent's when none is primary): they don't take
|
|
362
|
+
* an id or handle for a row in a fork's or a sub-agent's window, and don't
|
|
363
|
+
* find it (read it with queryMessages and the same forAgent). The
|
|
364
|
+
* residents' shared slot is the primary's window too, for a primary
|
|
365
|
+
* that's an ordinary resident, so there they do.
|
|
366
|
+
* `metadata.external` with a target throws: its id map is read in the
|
|
367
|
+
* primary's window.
|
|
307
368
|
*/
|
|
308
369
|
addMessage(
|
|
309
370
|
participant: string,
|
|
310
371
|
content: ContentBlock[],
|
|
311
|
-
metadata?: MessageMetadata & { external?: ExternalIdRef }
|
|
372
|
+
metadata?: MessageMetadata & { external?: ExternalIdRef },
|
|
373
|
+
opts?: { forAgent?: string },
|
|
312
374
|
): MessageId;
|
|
313
375
|
|
|
314
376
|
/**
|
|
@@ -354,8 +416,17 @@ export interface ModuleContext {
|
|
|
354
416
|
* restored them, after every module's start() (addMessage). A message a
|
|
355
417
|
* tune-out holds from the residents is among the rows, marked
|
|
356
418
|
* `heldFromResidents` (ModuleMessage).
|
|
419
|
+
*
|
|
420
|
+
* It reads the primary's window (the first registered agent's when none
|
|
421
|
+
* is primary), or with `opts.forAgent`, the named agent's: a conversation
|
|
422
|
+
* fork's or a running sub-agent's own store, or, for an ordinary resident,
|
|
423
|
+
* the residents' shared slot. For the subconscious, it's the
|
|
424
|
+
* subconscious's own store, not the residents' slot its compile merges
|
|
425
|
+
* in. A name that isn't a registered agent, or the empty name, throws,
|
|
426
|
+
* naming the registered ones, so a typo is heard rather than read as an
|
|
427
|
+
* empty window.
|
|
357
428
|
*/
|
|
358
|
-
queryMessages(filter: MessageQuery): MessageQueryResult;
|
|
429
|
+
queryMessages(filter: MessageQuery, opts?: { forAgent?: string }): MessageQueryResult;
|
|
359
430
|
|
|
360
431
|
/**
|
|
361
432
|
* Get info about all agents.
|
|
@@ -512,7 +583,15 @@ export interface AgentInfo {
|
|
|
512
583
|
export type AgentStatus = 'idle' | 'inferring' | 'streaming' | 'waiting_for_tools' | 'ready';
|
|
513
584
|
|
|
514
585
|
/**
|
|
515
|
-
* Response from a module's event handler.
|
|
586
|
+
* Response from a module's event handler. The framework applies it in this
|
|
587
|
+
* order: its messages added, edited and removed, then its stateUpdate, then
|
|
588
|
+
* its inference request. When one of these throws, such as an edit of a
|
|
589
|
+
* message the store doesn't hold, what came before it stays applied, the
|
|
590
|
+
* operation that threw may have taken effect in part or whole (a store can
|
|
591
|
+
* throw after it wrote), the rest of the response isn't, and a line names
|
|
592
|
+
* the module and where it threw; the event's other responses, a tool call's dispatch and its trace
|
|
593
|
+
* go on. Content the framework finds malformed refuses the whole response
|
|
594
|
+
* before any of it applies.
|
|
516
595
|
*/
|
|
517
596
|
export interface EventResponse {
|
|
518
597
|
/**
|
|
@@ -546,9 +625,9 @@ export interface EventResponse {
|
|
|
546
625
|
toolsChanged?: boolean;
|
|
547
626
|
|
|
548
627
|
/**
|
|
549
|
-
* Module state update.
|
|
550
|
-
*
|
|
551
|
-
*
|
|
628
|
+
* Module state update. The framework calls setState() with this value
|
|
629
|
+
* after applying the response's message changes, and not when one of
|
|
630
|
+
* them threw.
|
|
552
631
|
*/
|
|
553
632
|
stateUpdate?: unknown;
|
|
554
633
|
}
|
package/src/types/trace.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ThinkingBindingEntry } from '@animalabs/membrane';
|
|
1
2
|
import type { ProcessEvent } from './events.js';
|
|
2
3
|
import type { ModuleProcessResponse } from './framework.js';
|
|
3
4
|
import type { SessionUsage } from '../usage/types.js';
|
|
@@ -66,6 +67,14 @@ export type TraceEvent =
|
|
|
66
67
|
* without re-deriving routing.
|
|
67
68
|
*/
|
|
68
69
|
channelId?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The server that registers `channelId`, given with it. Two MCPL
|
|
72
|
+
* servers may register one channel id, so a tap that posts back to the
|
|
73
|
+
* turn's channel, such as a host telling it the turn failed, passes this
|
|
74
|
+
* server with the id. The streaming traces, `inference:tokens` and
|
|
75
|
+
* `inference:content_block`, carry the id alone.
|
|
76
|
+
*/
|
|
77
|
+
serverId?: string;
|
|
69
78
|
/** True for a control-plane wake that must not surface typing/prose. */
|
|
70
79
|
silent?: boolean;
|
|
71
80
|
})
|
|
@@ -146,7 +155,9 @@ export type TraceEvent =
|
|
|
146
155
|
* content in it or its retry after a refusal, and a tool result the
|
|
147
156
|
* boundary reports carries the channel of the round it answers. In
|
|
148
157
|
* hybrid mode a `>>>` envelope can send the text itself elsewhere.
|
|
149
|
-
* Explicit mode: the channel the start's wake
|
|
158
|
+
* Explicit mode: the channel its typing shows, where the start's wake
|
|
159
|
+
* came from, or, at a start whose wake names none, such as a budget
|
|
160
|
+
* restart, the one the turn already shows. */
|
|
150
161
|
channelId?: string;
|
|
151
162
|
})
|
|
152
163
|
| (TraceEventBase & {
|
|
@@ -169,7 +180,9 @@ export type TraceEvent =
|
|
|
169
180
|
* content in it or its retry after a refusal, and a tool result the
|
|
170
181
|
* boundary reports carries the channel of the round it answers. In
|
|
171
182
|
* hybrid mode a `>>>` envelope can send the text itself elsewhere.
|
|
172
|
-
* Explicit mode: the channel the start's wake
|
|
183
|
+
* Explicit mode: the channel its typing shows, where the start's wake
|
|
184
|
+
* came from, or, at a start whose wake names none, such as a budget
|
|
185
|
+
* restart, the one the turn already shows. */
|
|
173
186
|
channelId?: string;
|
|
174
187
|
})
|
|
175
188
|
| (TraceEventBase & {
|
|
@@ -181,6 +194,20 @@ export type TraceEvent =
|
|
|
181
194
|
type: 'inference:usage';
|
|
182
195
|
agentName: string;
|
|
183
196
|
tokenUsage: { input: number; output: number; cacheCreation?: number; cacheRead?: number };
|
|
197
|
+
/**
|
|
198
|
+
* The provider's report on the signed thinking of the call this event
|
|
199
|
+
* closes (membrane's `RoundReport.thinking`): blocks it dropped before
|
|
200
|
+
* the model saw them, and blocks it showed the model anyway because the
|
|
201
|
+
* check isn't enforced. `tokenUsage` beside it is the stream's running
|
|
202
|
+
* total, not this call's. The provider reports them for a request that
|
|
203
|
+
* carried the binding control, whoever asked for it:
|
|
204
|
+
* `thinkingBinding.dropBlock`, or a thinking config the host sends
|
|
205
|
+
* itself. Present only when the report names any block.
|
|
206
|
+
*/
|
|
207
|
+
thinking?: {
|
|
208
|
+
dropped: ThinkingBindingEntry[];
|
|
209
|
+
mismatchAllowed: ThinkingBindingEntry[];
|
|
210
|
+
};
|
|
184
211
|
})
|
|
185
212
|
| (TraceEventBase & {
|
|
186
213
|
type: 'inference:stream_resumed';
|
|
@@ -445,6 +472,20 @@ export type TraceEvent =
|
|
|
445
472
|
policyName: string;
|
|
446
473
|
eventCount: number;
|
|
447
474
|
})
|
|
475
|
+
| (TraceEventBase & {
|
|
476
|
+
/** A batched wake's turn started without its `[Gate: …]` line (the
|
|
477
|
+
* gate hands the line to the wake when its message is the newest at
|
|
478
|
+
* the fire, EventGate isNewestEntry, and the turn's start decides).
|
|
479
|
+
* `reason`: `newest`, on the delivery agent's start the message was
|
|
480
|
+
* still the newest entry in the window; `held`, the host was quiesced
|
|
481
|
+
* or another reader of the residents' shared slot had a turn alive,
|
|
482
|
+
* so no line could be written then. */
|
|
483
|
+
type: 'gate:wake-line-omitted';
|
|
484
|
+
reason: 'newest' | 'held';
|
|
485
|
+
policyNames: string[];
|
|
486
|
+
eventType: string;
|
|
487
|
+
channelId?: string;
|
|
488
|
+
})
|
|
448
489
|
| (TraceEventBase & {
|
|
449
490
|
type: 'gate:config-reloaded';
|
|
450
491
|
configPath: string;
|
|
@@ -508,6 +549,8 @@ export type TraceEvent =
|
|
|
508
549
|
| (TraceEventBase & {
|
|
509
550
|
type: 'mcpl:conversation-spawned';
|
|
510
551
|
channelId: string;
|
|
552
|
+
/** The channel's server: a channel id is unique only within one server. */
|
|
553
|
+
serverId: string;
|
|
511
554
|
agentName: string;
|
|
512
555
|
generation: number;
|
|
513
556
|
template: string;
|
|
@@ -515,22 +558,30 @@ export type TraceEvent =
|
|
|
515
558
|
| (TraceEventBase & {
|
|
516
559
|
type: 'mcpl:conversation-spawn-failed';
|
|
517
560
|
channelId: string;
|
|
561
|
+
/** The channel's server: a channel id is unique only within one server. */
|
|
562
|
+
serverId: string;
|
|
518
563
|
agentName: string;
|
|
519
564
|
error: string;
|
|
520
565
|
})
|
|
521
566
|
| (TraceEventBase & {
|
|
522
567
|
type: 'mcpl:conversation-unrouted';
|
|
523
568
|
channelId: string;
|
|
569
|
+
/** The channel's server: a channel id is unique only within one server. */
|
|
570
|
+
serverId: string;
|
|
524
571
|
messageId: string;
|
|
525
572
|
})
|
|
526
573
|
| (TraceEventBase & {
|
|
527
574
|
type: 'mcpl:conversation-binding-orphaned';
|
|
528
575
|
channelId: string;
|
|
576
|
+
/** The channel's server: a channel id is unique only within one server. */
|
|
577
|
+
serverId: string;
|
|
529
578
|
agentName: string;
|
|
530
579
|
})
|
|
531
580
|
| (TraceEventBase & {
|
|
532
581
|
type: 'mcpl:conversation-closed';
|
|
533
582
|
channelId: string;
|
|
583
|
+
/** The channel's server: a channel id is unique only within one server. */
|
|
584
|
+
serverId: string;
|
|
534
585
|
agentName: string;
|
|
535
586
|
reason: 'idle-ttl';
|
|
536
587
|
})
|
|
@@ -538,6 +589,8 @@ export type TraceEvent =
|
|
|
538
589
|
type: 'mcpl:conversation-disposed';
|
|
539
590
|
agentName: string;
|
|
540
591
|
channelId?: string;
|
|
592
|
+
/** The home channel's server, beside its channelId. */
|
|
593
|
+
serverId?: string;
|
|
541
594
|
})
|
|
542
595
|
|
|
543
596
|
// Host-owned speech routing (ChannelRegistry.routeSpeech). One trace per
|
|
@@ -569,6 +622,9 @@ export type TraceEvent =
|
|
|
569
622
|
type: 'mcpl:speech-route-failed';
|
|
570
623
|
/** Agent / conversation whose speech failed to route. */
|
|
571
624
|
conversationId: string;
|
|
625
|
+
/** The channel's server, where the destination, or the caller, named
|
|
626
|
+
* one: a channel id is unique only within one server. */
|
|
627
|
+
serverId?: string;
|
|
572
628
|
/** Empty string when the failure was "no locus at all". */
|
|
573
629
|
channelId: string;
|
|
574
630
|
reason: string;
|