@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../../src/modules/workspace/text.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA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MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACxC,OAAO,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,CAAS,EAAE,QAAQ,GAAG,cAAc,EAAE,MAAgC;IAC/G,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrC,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,GAAG,MAAM,KAAK,IAAI,EAAE,CAAC;IACzD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACpC,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,aAAa,GAAG,CAAC;AAC5G,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,QAAQ,CAAC,KAAe,EAAE,KAAa,EAAE,QAAQ,GAAG,cAAc;IAChF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpF,CAAC"}
|
|
@@ -15,24 +15,44 @@ export interface MountConfig {
|
|
|
15
15
|
* Where the mount's tools get what they read (default: 'chronicle').
|
|
16
16
|
* - 'chronicle': the workspace keeps the mount's files in its store, where
|
|
17
17
|
* writes and edits land first, and takes in disk's changes under the
|
|
18
|
-
* three-way rule as
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* and none of its files go into the store. No scan or watcher
|
|
18
|
+
* three-way rule as `read`, listings, searches, syncs and scans reach
|
|
19
|
+
* them. Its tools read the store's copy.
|
|
20
|
+
* - 'direct': for a checkout, such as a git one, whose history is its
|
|
21
|
+
* own. Every read, listing and search is disk's own copy as it is when
|
|
22
|
+
* it runs, and none of its files go into the store. No scan or watcher
|
|
24
23
|
* runs, so no call waits behind one, and `sync`, `materialize` and the
|
|
25
|
-
* watch settings have nothing to act on.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
24
|
+
* watch settings have nothing to act on. Not with `watch` other than
|
|
25
|
+
* 'never', `watchDebounceMs`, `watchRootPollMs`, a `wakeOnChange` that
|
|
26
|
+
* would wake (true, or a non-empty list) or `autoMaterialize: true`:
|
|
27
|
+
* each of those would never act, and the workspace refuses the mount.
|
|
28
|
+
* Writable, as any mount with no `mode` is, its `write`, `edit`,
|
|
29
|
+
* `edit_many` and `delete` land on disk when they answer, or don't
|
|
30
|
+
* happen: a file is staged beside itself in `.workspace-staged-<id>` and
|
|
31
|
+
* renamed over itself, keeping its mode, so no reader sees half of it;
|
|
32
|
+
* an edit is applied to disk's text as it is now, and again on top of a
|
|
33
|
+
* change another writer makes meanwhile; and `edit_many` checks every
|
|
34
|
+
* edit before writing its files one by one, naming each file's outcome
|
|
35
|
+
* if a write fails partway. A file with other hard links gets a file of
|
|
36
|
+
* its own at its path, and the others keep the old text; a file this
|
|
37
|
+
* process may not write is refused. Nothing is synced, so a power loss
|
|
38
|
+
* can lose a write its answer called landed. An undo or other move of
|
|
39
|
+
* the store's head leaves the files as they are, and at the agent's next
|
|
40
|
+
* start the framework tells it once that writes from turns its history
|
|
41
|
+
* no longer holds are still on disk. Where each agent's latest write
|
|
42
|
+
* lies is saved at a clean stop, in a record no branch switch rewinds,
|
|
43
|
+
* so a restart on another branch still tells it, and after a crash a
|
|
44
|
+
* move away from the writes since then isn't told. The framework's own
|
|
45
|
+
* files, its
|
|
46
|
+
* tool-result spills, saved payloads and fetched references, never go to
|
|
47
|
+
* a mount configured direct. Its `ignore`
|
|
30
48
|
* has a default (see there). Paths, links, its `include`, other mounts'
|
|
31
49
|
* directories, size limits and the walk cap hold as on a 'chronicle'
|
|
32
|
-
* mount. Its tools read beneath whatever directory is at its
|
|
33
|
-
* root, with no check against the one a
|
|
34
|
-
*
|
|
35
|
-
*
|
|
50
|
+
* mount. Its tools read and write beneath whatever directory is at its
|
|
51
|
+
* root when each call starts, with no check against the one a
|
|
52
|
+
* 'chronicle' run of it last agreed with, so a root repointed through a
|
|
53
|
+
* link is read and written where it leads now. Where that root now lies
|
|
54
|
+
* elsewhere than the last start placed it, each call nests in it, as a
|
|
55
|
+
* start would now, every mount
|
|
36
56
|
* configured beneath its path, where that path leads beneath its root,
|
|
37
57
|
* and every other mount whose root, as that start placed it, lies
|
|
38
58
|
* beneath where its root lies now, or whose configured path lies
|
|
@@ -47,7 +67,10 @@ export interface MountConfig {
|
|
|
47
67
|
* them pending, or an intent the workspace can't read, which may hold one
|
|
48
68
|
* of those. They stay in view, and the workspace says so on stderr and
|
|
49
69
|
* through the framework's ops alerts, naming them and the ways to start it
|
|
50
|
-
* direct.
|
|
70
|
+
* direct. Until a start finds none held, it takes no writes, edits or
|
|
71
|
+
* deletions, so what's held only shrinks: a `sync` of a held path takes
|
|
72
|
+
* disk's copy, and a `materialize` naming the mount writes the store's.
|
|
73
|
+
* It runs unwatched, and walks by the direct kind's default
|
|
51
74
|
* ignore list where its config names none; `ls` without a path, and
|
|
52
75
|
* `status`, give its `backend` as 'chronicle' and that list. A mount that
|
|
53
76
|
* ran direct and runs as 'chronicle' again takes in what disk changed
|
|
@@ -284,7 +307,8 @@ export interface MountConfig {
|
|
|
284
307
|
/**
|
|
285
308
|
* If true, writes/edits/deletes via the module's tools materialize to the
|
|
286
309
|
* filesystem immediately (not just into Chronicle tree state). Required for
|
|
287
|
-
* any mount shared across agents as a communication channel
|
|
310
|
+
* any store-backed mount shared across agents as a communication channel (a
|
|
311
|
+
* direct mount's writes reach disk without it, and it's refused there) — without it,
|
|
288
312
|
* another agent's watcher on the same directory sees nothing. The watcher
|
|
289
313
|
* suppresses its own echoes, so this doesn't cause self-wake loops.
|
|
290
314
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/modules/workspace/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,IAAI,EAAE,YAAY,GAAG,WAAW,CAAC;IACjC
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/modules/workspace/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,IAAI,EAAE,YAAY,GAAG,WAAW,CAAC;IACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiEG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IACjC;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,iBAAiB,GAAG,OAAO,CAAC;IAC/C,oEAAoE;IACpE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qFAAqF;IACrF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;;;;;;;;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C,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,cAAc,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,qBAAqB,GACrB,uBAAuB,CAAC;AAE5B,eAAO,MAAM,wBAAwB,YACnC,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,CACX,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,OAAO,wBAAwB,CAAC,MAAM,CAAC,CAAC;AAE3E,wBAAgB,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,oBAAoB,CAErE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/modules/workspace/types.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/modules/workspace/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6mBH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;CACX,CAAC;AAIX,MAAM,UAAU,aAAa,CAAC,EAAiB;IAC7C,OAAO,aAAa,EAAE,EAA0B,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ContentBlock, ToolResult as MembraneToolResult } from '@animalabs/membrane';
|
|
2
|
+
import type { MessageId } from '@animalabs/context-manager';
|
|
3
|
+
/**
|
|
4
|
+
* A row a stream's later round carried after its compiled messages, as a context manager that keeps a
|
|
5
|
+
* thinking-binding record is told of it (`noteRequestSent`): the id of a stored body the next request carries as
|
|
6
|
+
* the stream sent it, or the marker for one it doesn't, after which nothing keeps its thinking.
|
|
7
|
+
*/
|
|
8
|
+
export type SentRow = MessageId | {
|
|
9
|
+
unstored: true;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Whether a request carries a block: the sanitize pass leaves out an empty or whitespace text block, which the
|
|
13
|
+
* Anthropic API refuses (assembleActivationRequest). The `typeof` guard is runtime defense: history loaded from
|
|
14
|
+
* disk can carry a non-string `text` despite what the types claim.
|
|
15
|
+
*/
|
|
16
|
+
export declare function carriedBlock(block: ContentBlock): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* A stored body's content as the agent's next request carries it: what the sanitize pass leaves of it, without
|
|
19
|
+
* the framework's pricing stamp. Null when the pass leaves nothing, so the request carries no message there.
|
|
20
|
+
*/
|
|
21
|
+
export declare function asNextRequestCarries(content: readonly ContentBlock[]): ContentBlock[] | null;
|
|
22
|
+
/**
|
|
23
|
+
* Blocks equal as JSON data, as the store keeps them and a request sends them: equal where `JSON.stringify` writes
|
|
24
|
+
* them alike, key order aside. So a non-finite number is null; a field whose value is undefined, a function or a
|
|
25
|
+
* symbol is absent; such an array element, or a hole, is null; and anything else an object can be (a Date, a Buffer)
|
|
26
|
+
* is compared as JSON writes it. It walks plain objects and arrays rather than serializing them, since a note compares
|
|
27
|
+
* every row of the stream so far, base64 images and long tool results included, at each boundary.
|
|
28
|
+
*/
|
|
29
|
+
export declare function sameData(a: unknown, b: unknown): boolean;
|
|
30
|
+
/** One stored row of a round, beside what the stream sent in its place. */
|
|
31
|
+
export type RoundRow = {
|
|
32
|
+
kind: 'reply';
|
|
33
|
+
id: MessageId | undefined;
|
|
34
|
+
sent: readonly ContentBlock[];
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'results';
|
|
37
|
+
id: MessageId | undefined;
|
|
38
|
+
sent: readonly MembraneToolResult[];
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'injected';
|
|
41
|
+
id: MessageId | undefined;
|
|
42
|
+
participant: string;
|
|
43
|
+
sent: readonly ContentBlock[];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A round's rows as noted: each stored row's id where the next request carries it as the stream sent it, the
|
|
47
|
+
* marker where it doesn't. `carried` gives each id's stored body as the next compile renders it (participant and
|
|
48
|
+
* content, or null where no compile can send it), so the comparison is the one the context manager's record
|
|
49
|
+
* makes, after the agent's own request passes (asNextRequestCarries). A row the store doesn't hold (no id), a reply
|
|
50
|
+
* that differs from the round's content as membrane held it, results that differ from those submitted (as while the
|
|
51
|
+
* tool-result guard holds a batch, storing placeholders and submitting the originals), or an injected message sent
|
|
52
|
+
* otherwise than its stored body renders, is the marker. Called again over the same rows once the store has
|
|
53
|
+
* changed, as when the guard's batch settles to the originals, it gives each row's verdict as of then.
|
|
54
|
+
*/
|
|
55
|
+
export declare function roundRows(rows: readonly RoundRow[], carried: (id: MessageId) => {
|
|
56
|
+
participant: string;
|
|
57
|
+
content: ContentBlock[];
|
|
58
|
+
} | null): SentRow[];
|
|
59
|
+
//# sourceMappingURL=sent-rows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sent-rows.d.ts","sourceRoot":"","sources":["../../src/sent-rows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,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.freeze({ unstored: true });
|
|
4
|
+
/**
|
|
5
|
+
* Whether a request carries a block: the sanitize pass leaves out an empty or whitespace text block, which the
|
|
6
|
+
* Anthropic API refuses (assembleActivationRequest). The `typeof` guard is runtime defense: history loaded from
|
|
7
|
+
* disk can carry a non-string `text` despite what the types claim.
|
|
8
|
+
*/
|
|
9
|
+
export function carriedBlock(block) {
|
|
10
|
+
return !(block.type === 'text' && (typeof block.text !== 'string' || block.text.trim() === ''));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A stored body's content as the agent's next request carries it: what the sanitize pass leaves of it, without
|
|
14
|
+
* the framework's pricing stamp. Null when the pass leaves nothing, so the request carries no message there.
|
|
15
|
+
*/
|
|
16
|
+
export function asNextRequestCarries(content) {
|
|
17
|
+
const kept = content.filter(carriedBlock);
|
|
18
|
+
if (kept.length === 0)
|
|
19
|
+
return null;
|
|
20
|
+
return withoutTokenEstimates([{ content: kept }])[0].content;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether a block of what a stream sent counts in the comparison. membrane's native formatter leaves out an exactly
|
|
24
|
+
* empty text block, which the API refuses. An empty text block carrying a provider-native item (`rawItem`) it sends
|
|
25
|
+
* as that item where it's a server-tool block it knows, in an assistant turn, and leaves out otherwise; whitespace
|
|
26
|
+
* text it sends, behind the participant's name where a multiuser conversation shows names. The next request's
|
|
27
|
+
* sanitize pass leaves both out, so both count as differences. Where membrane, or the adapter's cleanup (whitespace in
|
|
28
|
+
* an assistant turn), leaves one out of both requests, that's a needless strip rather than a row named for bytes the
|
|
29
|
+
* provider didn't see.
|
|
30
|
+
*/
|
|
31
|
+
function sentBlock(block) {
|
|
32
|
+
if (block.type !== 'text' || block.text !== '')
|
|
33
|
+
return true;
|
|
34
|
+
const raw = block.rawItem;
|
|
35
|
+
return raw !== null && typeof raw === 'object';
|
|
36
|
+
}
|
|
37
|
+
/** A block's own cache marker left out: the provider's thinking binding doesn't count it, nor does the context
|
|
38
|
+
* manager's record, and stored history can carry a stale one. */
|
|
39
|
+
function withoutCacheMarker(block) {
|
|
40
|
+
if (!('cache_control' in block) && !('cacheControl' in block))
|
|
41
|
+
return block;
|
|
42
|
+
const { cache_control: _snake, cacheControl: _camel, ...rest } = block;
|
|
43
|
+
return rest;
|
|
44
|
+
}
|
|
45
|
+
/** A value as JSON writes it: a non-finite number as null, and undefined, a function or a symbol as nothing
|
|
46
|
+
* (undefined here), which an object leaves out and an array writes as null. */
|
|
47
|
+
function asJson(value) {
|
|
48
|
+
if (typeof value === 'number')
|
|
49
|
+
return Number.isFinite(value) ? value : null;
|
|
50
|
+
return value === undefined || typeof value === 'function' || typeof value === 'symbol' ? undefined : value;
|
|
51
|
+
}
|
|
52
|
+
/** Whether JSON writes an object by walking it: an array, or a plain object without its own `toJSON`. */
|
|
53
|
+
function walkable(value) {
|
|
54
|
+
if (Array.isArray(value))
|
|
55
|
+
return true;
|
|
56
|
+
const proto = Object.getPrototypeOf(value);
|
|
57
|
+
return (proto === Object.prototype || proto === null) && typeof value.toJSON !== 'function';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Blocks equal as JSON data, as the store keeps them and a request sends them: equal where `JSON.stringify` writes
|
|
61
|
+
* them alike, key order aside. So a non-finite number is null; a field whose value is undefined, a function or a
|
|
62
|
+
* symbol is absent; such an array element, or a hole, is null; and anything else an object can be (a Date, a Buffer)
|
|
63
|
+
* is compared as JSON writes it. It walks plain objects and arrays rather than serializing them, since a note compares
|
|
64
|
+
* every row of the stream so far, base64 images and long tool results included, at each boundary.
|
|
65
|
+
*/
|
|
66
|
+
export function sameData(a, b) {
|
|
67
|
+
const left = asJson(a);
|
|
68
|
+
const right = asJson(b);
|
|
69
|
+
if (left === right)
|
|
70
|
+
return true;
|
|
71
|
+
const unwalked = (value) => typeof value === 'object' && value !== null && !walkable(value);
|
|
72
|
+
if (unwalked(left) || unwalked(right)) {
|
|
73
|
+
return isDeepStrictEqual(JSON.parse(JSON.stringify(left) ?? 'null'), JSON.parse(JSON.stringify(right) ?? 'null'));
|
|
74
|
+
}
|
|
75
|
+
if (typeof left !== 'object' || typeof right !== 'object' || left === null || right === null)
|
|
76
|
+
return false;
|
|
77
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
78
|
+
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length)
|
|
79
|
+
return false;
|
|
80
|
+
for (let i = 0; i < left.length; i++) {
|
|
81
|
+
if (!sameData(asJson(left[i]) ?? null, asJson(right[i]) ?? null))
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
const l = left;
|
|
87
|
+
const r = right;
|
|
88
|
+
const keys = Object.keys(l).filter((key) => asJson(l[key]) !== undefined);
|
|
89
|
+
return keys.length === Object.keys(r).filter((key) => asJson(r[key]) !== undefined).length
|
|
90
|
+
&& keys.every((key) => Object.hasOwn(r, key) && asJson(r[key]) !== undefined && sameData(l[key], r[key]));
|
|
91
|
+
}
|
|
92
|
+
/** What membrane builds a round's results message from: each submitted result as a `tool_result` block. */
|
|
93
|
+
function submittedBlocks(results) {
|
|
94
|
+
return results.map((result) => ({
|
|
95
|
+
type: 'tool_result',
|
|
96
|
+
toolUseId: result.toolUseId,
|
|
97
|
+
content: result.content,
|
|
98
|
+
isError: result.isError === true,
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A round's rows as noted: each stored row's id where the next request carries it as the stream sent it, the
|
|
103
|
+
* marker where it doesn't. `carried` gives each id's stored body as the next compile renders it (participant and
|
|
104
|
+
* content, or null where no compile can send it), so the comparison is the one the context manager's record
|
|
105
|
+
* makes, after the agent's own request passes (asNextRequestCarries). A row the store doesn't hold (no id), a reply
|
|
106
|
+
* that differs from the round's content as membrane held it, results that differ from those submitted (as while the
|
|
107
|
+
* tool-result guard holds a batch, storing placeholders and submitting the originals), or an injected message sent
|
|
108
|
+
* otherwise than its stored body renders, is the marker. Called again over the same rows once the store has
|
|
109
|
+
* changed, as when the guard's batch settles to the originals, it gives each row's verdict as of then.
|
|
110
|
+
*/
|
|
111
|
+
export function roundRows(rows, carried) {
|
|
112
|
+
return rows.map((row) => {
|
|
113
|
+
if (row.id === undefined)
|
|
114
|
+
return UNSTORED;
|
|
115
|
+
const body = carried(row.id);
|
|
116
|
+
const content = body ? asNextRequestCarries(body.content) : null;
|
|
117
|
+
if (!body || !content)
|
|
118
|
+
return UNSTORED;
|
|
119
|
+
// What the stream sent, as membrane's native formatter sends it (sentBlock): an exactly empty text block is in
|
|
120
|
+
// neither request.
|
|
121
|
+
const sent = row.kind === 'results' ? submittedBlocks(row.sent) : row.sent.filter(sentBlock);
|
|
122
|
+
const sameParticipant = row.kind !== 'injected' || body.participant === row.participant;
|
|
123
|
+
const sameContent = row.kind === 'results'
|
|
124
|
+
? sameData(content.map(normalizedResult), sent.map(normalizedResult))
|
|
125
|
+
: sameData(content.map(withoutCacheMarker), sent.map(withoutCacheMarker));
|
|
126
|
+
return sameParticipant && sameContent ? row.id : UNSTORED;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A results block as compared: what a request sends of it, its id, content and error flag, with `isError` as a
|
|
131
|
+
* boolean, where a stored block may leave a false one out. A stream's envelope sends a submitted result's
|
|
132
|
+
* `is_error: false` and the next request, from the stored block, sends none; the provider's thinking binding takes
|
|
133
|
+
* the two alike (read from the provider on 2026-10-23: Haiku 5.5 with the drop control, on an enforcing API-key
|
|
134
|
+
* organization and on a subscription account, reported no drop for either, and dropped both replies' blocks when an
|
|
135
|
+
* earlier user message changed). The store's own fields beside them, such as
|
|
136
|
+
* `toolName`, don't reach the provider on membrane's native path, the only one noted (membrane 0.7.1's XML
|
|
137
|
+
* formatter reads `toolName`, and an XML stream is never noted).
|
|
138
|
+
*/
|
|
139
|
+
function normalizedResult(block) {
|
|
140
|
+
if (block.type !== 'tool_result')
|
|
141
|
+
return block;
|
|
142
|
+
const { toolUseId, content, isError } = block;
|
|
143
|
+
return { type: 'tool_result', toolUseId, content, isError: isError === true };
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=sent-rows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sent-rows.js","sourceRoot":"","sources":["../../src/sent-rows.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AASlE,MAAM,QAAQ,GAAY,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAa,EAAE,CAAC,CAAC;AAErE;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAmB;IAC9C,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AAClG,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgC;IACnE,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC;AAChE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,SAAS,CAAC,KAAmB;IACpC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC5D,MAAM,GAAG,GAAI,KAA+B,CAAC,OAAO,CAAC;IACrD,OAAO,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC;AACjD,CAAC;AAED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
|
@@ -7,19 +7,22 @@
|
|
|
7
7
|
* - A silent heartbeat tick stores no prompt row (#216): its reply is written
|
|
8
8
|
* straight after whatever the window held before it — often the previous
|
|
9
9
|
* assistant message, since a suppressed tick leaves no delivery receipt
|
|
10
|
-
* behind. Every row
|
|
11
|
-
* and a separator carrying the tick's
|
|
12
|
-
* first of
|
|
10
|
+
* behind. Every row the tick's reply writes is stamped with
|
|
11
|
+
* `metadata.silentHeartbeat`, and a separator carrying the tick's
|
|
12
|
+
* instruction is rendered before the first of those rows that survives
|
|
13
|
+
* compilation. A context injection its start stores (stored-injections.ts)
|
|
14
|
+
* is unstamped: it's history the agent saw, not the tick's speech, so a
|
|
15
|
+
* policy that drops a tick's rows leaves it.
|
|
13
16
|
* - A compile that ends on the agent's own message gets a trailing
|
|
14
17
|
* `[Continue]` turn (some models reject a trailing assistant message). The
|
|
15
18
|
* reply it prompts is stored straight after that message, so the reply's
|
|
16
19
|
* rows are stamped `metadata.promptedBy` (`RequestOnlyPrompt`), and the turn
|
|
17
20
|
* is rendered before the first of them that survives. A reply follows the
|
|
18
21
|
* prompt when what it was sent ends on that `[Continue]`, or on the tool
|
|
19
|
-
* results of a reply that followed it (`toolLoopPrompt`)
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* prompt.
|
|
22
|
+
* results of a reply that followed it (`toolLoopPrompt`), stored context
|
|
23
|
+
* injections after those results aside: a stream start and each round of
|
|
24
|
+
* a stream alike. A reply sent anything else after the results (a message
|
|
25
|
+
* that arrived meanwhile) follows that, and carries no prompt.
|
|
23
26
|
*
|
|
24
27
|
* Without the row, the wire formatter merges consecutive same-role messages:
|
|
25
28
|
* the reply would read as an unprompted continuation of the earlier response,
|
|
@@ -65,9 +68,13 @@ export interface SilentHeartbeatTick {
|
|
|
65
68
|
/** The MCPL server that sent it. */
|
|
66
69
|
serverId: string;
|
|
67
70
|
}
|
|
68
|
-
/** `metadata.silentHeartbeat` on
|
|
69
|
-
*
|
|
70
|
-
* (
|
|
71
|
+
/** `metadata.silentHeartbeat` on the rows of a tick's own turn (its reply,
|
|
72
|
+
* tool results and their wrappers). What the framework stores of its own
|
|
73
|
+
* accord is left unstamped, a clock row (at the turn's start or a tool
|
|
74
|
+
* boundary) or a context injection, so a retention policy that drops a
|
|
75
|
+
* tick's rows keeps it. Residents share one message
|
|
76
|
+
* slot, so the stamp names the agent whose turn wrote it (tool_result rows
|
|
77
|
+
* are stored as `user`). */
|
|
71
78
|
export interface SilentHeartbeatStamp extends SilentHeartbeatTick {
|
|
72
79
|
agentName: string;
|
|
73
80
|
/** The separator text the tick's request rendered, which later compiles
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"silent-heartbeat.d.ts","sourceRoot":"","sources":["../../src/silent-heartbeat.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"silent-heartbeat.d.ts","sourceRoot":"","sources":["../../src/silent-heartbeat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE3E;;;;;4DAK4D;AAC5D,eAAO,MAAM,0BAA0B,QAEiF,CAAC;AAMzH,6EAA6E;AAC7E,eAAO,MAAM,YAAY,eAAe,CAAC;AAEzC,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB;IAClC;oCACgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;4BAM4B;AAC5B,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB;;iDAE6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;6DAC6D;AAC7D,wBAAgB,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAEzD;AAED,yDAAyD;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c,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,KAAK,EAAE,mBAAmB,EAC1B,SAAS,EAAE,MAAM,GAChB,uBAAuB,CAsBzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"silent-heartbeat.js","sourceRoot":"","sources":["../../src/silent-heartbeat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"silent-heartbeat.js","sourceRoot":"","sources":["../../src/silent-heartbeat.ts"],"names":[],"mappings":"AAsDA;;;;;4DAK4D;AAC5D,MAAM,CAAC,MAAM,0BAA0B,GACrC,qFAAqF;IACrF,sHAAsH,CAAC;AAEzH;iEACiE;AACjE,MAAM,iCAAiC,GAAG,kBAAkB,CAAC;AAE7D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC;AA0BzC;6DAC6D;AAC7D,MAAM,UAAU,OAAO,CAAC,IAAyB;IAC/C,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,iBAAiB,CAAC,QAAiB;IACjD,MAAM,KAAK,GAAI,QAAsD,EAAE,eAAe,CAAC;IACvF,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC1D,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,KAAgC,CAAC;IACrF,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ;QACjG,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,OAAO,SAAS,K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":["../../src/stable-hash.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUjD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/** A SHA-256 of `value` that doesn't depend on its objects' key order. */
|
|
3
|
+
export function stableHash(value) {
|
|
4
|
+
const encode = (item) => {
|
|
5
|
+
if (Array.isArray(item))
|
|
6
|
+
return `[${item.map(encode).join(',')}]`;
|
|
7
|
+
if (item && typeof item === 'object') {
|
|
8
|
+
const record = item;
|
|
9
|
+
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${encode(record[key])}`).join(',')}}`;
|
|
10
|
+
}
|
|
11
|
+
return JSON.stringify(item) ?? 'null';
|
|
12
|
+
};
|
|
13
|
+
return createHash('sha256').update(encode(value)).digest('hex');
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=stable-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stable-hash.js","sourceRoot":"","sources":["../../src/stable-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,MAAM,MAAM,GAAG,CAAC,IAAa,EAAU,EAAE;QACvC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QAClE,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,IAA+B,CAAC;YAC/C,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QACnH,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC;IACxC,CAAC,CAAC;IACF,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context injections kept where they were placed (context-manager #155,
|
|
3
|
+
* part 5).
|
|
4
|
+
*
|
|
5
|
+
* `compile()` places an `afterUser` injection after the last user message
|
|
6
|
+
* each time it runs, and nothing stores it. So at the next start, a new turn
|
|
7
|
+
* or a restart after a tool result, it's gone from where the agent's replies
|
|
8
|
+
* saw it, and on a model that binds a reply's thinking to everything before
|
|
9
|
+
* it, every reply after the old place loses its thinking. A moved injection
|
|
10
|
+
* also rewrites the previous turn's cached prefix. So at each start that
|
|
11
|
+
* sends, the framework appends each `afterUser` injection to the agent's own
|
|
12
|
+
* window, as the message `compile()` would have placed, unless the copy the
|
|
13
|
+
* agent will read as current (the one its last request held, or a newer one
|
|
14
|
+
* a start stored whose compile then didn't record) has the same content,
|
|
15
|
+
* every part of it, and the compile
|
|
16
|
+
* then renders
|
|
17
|
+
* it from the store like any message, where it stays. While the window is
|
|
18
|
+
* held (AgentFramework's slotHeldFrom), `compile()` places it instead. Being a
|
|
19
|
+
* message, it's history to the strategy: capped by its per-message bound,
|
|
20
|
+
* sharded, selected by the budget and folded like any other.
|
|
21
|
+
*
|
|
22
|
+
* A stored injection's row carries `system: true`, `kind:
|
|
23
|
+
* 'context-injection'` and `contextInjection` in its metadata (the mark),
|
|
24
|
+
* naming the agent whose context it is and its source's namespace, so a
|
|
25
|
+
* reader can tell it from conversation, and so another agent reading the
|
|
26
|
+
* same slot leaves it out (AgentFramework's view filters). All three are
|
|
27
|
+
* keys only the host writes.
|
|
28
|
+
*/
|
|
29
|
+
import type { ContextInjection } from '@animalabs/context-manager';
|
|
30
|
+
/** The metadata key a stored injection's row is marked with. */
|
|
31
|
+
export declare const STORED_INJECTION_KEY = "contextInjection";
|
|
32
|
+
/** The `kind` a stored injection's row carries beside `system: true`, as the
|
|
33
|
+
* framework's other rows of its own do (a clock row, a notice). */
|
|
34
|
+
export declare const STORED_INJECTION_KIND = "context-injection";
|
|
35
|
+
/**
|
|
36
|
+
* The mark: whose context the row is, its source's namespace, a hash of the
|
|
37
|
+
* content its source gave at that start (the unit), in its stored form
|
|
38
|
+
* (unitHash), and which of the unit's `parts` injections the row holds
|
|
39
|
+
* (`part`, from 0). Every row of one injection, a sharded one's too, carries
|
|
40
|
+
* the same `part`.
|
|
41
|
+
*/
|
|
42
|
+
export interface StoredInjectionMark {
|
|
43
|
+
agent: string;
|
|
44
|
+
namespace: string;
|
|
45
|
+
contentHash: string;
|
|
46
|
+
part: number;
|
|
47
|
+
parts: number;
|
|
48
|
+
}
|
|
49
|
+
/** The participant `compile()` gives an injection it places, which a stored
|
|
50
|
+
* one keeps, so it renders as the placed one did. */
|
|
51
|
+
export declare function injectionParticipant(namespace: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* A stored injection's mark, read from a row's metadata, so a host's reader
|
|
54
|
+
* tells a stored injection from conversation by the rule the framework's own
|
|
55
|
+
* views use. Undefined for a row with no mark, and for one whose mark isn't
|
|
56
|
+
* whole (a string `agent`, `namespace` and `contentHash`, and integer
|
|
57
|
+
* `part` and `parts` with 0 <= part < parts): no view of the framework's
|
|
58
|
+
* treats such a row as a stored injection, so neither should a host's.
|
|
59
|
+
*/
|
|
60
|
+
export declare function storedInjectionMarkOf(metadata: unknown): StoredInjectionMark | undefined;
|
|
61
|
+
/** Whether a row is another agent's stored injection, which `agentName`'s
|
|
62
|
+
* view leaves out: it's that agent's context, not conversation. */
|
|
63
|
+
export declare function isAnotherAgentsInjection(metadata: unknown, agentName: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether an injection is stored, rather than placed by `compile()` each
|
|
66
|
+
* time: an `afterUser` one, unless it opts out
|
|
67
|
+
* (ModuleContextInjection.placedEachCompile). Only a module's can: an MCPL
|
|
68
|
+
* server's is built from four fields alone (convertMcplInjection), so it
|
|
69
|
+
* never carries the field.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isStoredKind(injection: ContextInjection): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether content leaves anything in a request: a block that isn't a text
|
|
74
|
+
* block, or a text block with non-blank text, as the request's sanitizer
|
|
75
|
+
* keeps (Agent's assembleActivationRequest drops blank text blocks, and a
|
|
76
|
+
* message left with none). An injection with none isn't stored: its row
|
|
77
|
+
* would vanish from every request, and the count of stored rows the
|
|
78
|
+
* request ends on, which keeps [Continue] last, would then be wrong.
|
|
79
|
+
* compile() places it, and the sanitizer drops it, as before.
|
|
80
|
+
*/
|
|
81
|
+
export declare function hasRenderedContent(content: ContextInjection['content']): boolean;
|
|
82
|
+
/** One injection as its row would store it: its namespace as text (as
|
|
83
|
+
* compile() writes it into the participant's name, so one that isn't a
|
|
84
|
+
* string, an MCPL server's number or none, is read so), that participant,
|
|
85
|
+
* and its content in the stored form (injectionsAsStored), as the compile
|
|
86
|
+
* would have taken it. The store's write would mend the content the same
|
|
87
|
+
* way; the namespace, which the mark carries too, it wouldn't. */
|
|
88
|
+
export declare function asStoredRow(injection: ContextInjection): {
|
|
89
|
+
namespace: string;
|
|
90
|
+
participant: string;
|
|
91
|
+
content: ContextInjection['content'];
|
|
92
|
+
};
|
|
93
|
+
/** The hash of a unit's content in its stored form, which the same-content
|
|
94
|
+
* skip compares: the mark's, from the gather that stored the unit, with
|
|
95
|
+
* this gather's. */
|
|
96
|
+
export declare function unitHash(rows: ReadonlyArray<{
|
|
97
|
+
content: ContextInjection['content'];
|
|
98
|
+
}>): string;
|
|
99
|
+
//# sourceMappingURL=stored-injections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-injections.d.ts","sourceRoot":"","sources":["../../src/stored-injections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAInE,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAEvD;oEACoE;AACpE,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;sDACsD;AACtD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,mBAAmB,GAAG,SAAS,CAQxF;AAED;oEACoE;AACpE,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAGtF;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAGjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,GAAG,OAAO,CAIhF;AAED;;;;;mEAKmE;AACnE,wBAAgB,WAAW,CAAC,SAAS,EAAE,gBAAgB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAA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