@animalabs/agent-framework 0.23.3 → 0.24.1
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 +212 -42
- package/dist/src/agent.d.ts +65 -9
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +98 -12
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +14 -12
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/clock-rows.d.ts +115 -0
- package/dist/src/clock-rows.d.ts.map +1 -0
- package/dist/src/clock-rows.js +222 -0
- package/dist/src/clock-rows.js.map +1 -0
- package/dist/src/code-execution/engine.d.ts +177 -0
- package/dist/src/code-execution/engine.d.ts.map +1 -0
- package/dist/src/code-execution/engine.js +494 -0
- package/dist/src/code-execution/engine.js.map +1 -0
- package/dist/src/code-execution/index.d.ts +5 -10
- package/dist/src/code-execution/index.d.ts.map +1 -1
- package/dist/src/code-execution/index.js +5 -9
- package/dist/src/code-execution/index.js.map +1 -1
- package/dist/src/code-execution/isolate/calls.d.ts +114 -0
- package/dist/src/code-execution/isolate/calls.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/calls.js +145 -0
- package/dist/src/code-execution/isolate/calls.js.map +1 -0
- package/dist/src/code-execution/isolate/child-entry.d.ts +2 -0
- package/dist/src/code-execution/isolate/child-entry.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/child-entry.js +5 -0
- package/dist/src/code-execution/isolate/child-entry.js.map +1 -0
- package/dist/src/code-execution/isolate/child-main.d.ts +26 -0
- package/dist/src/code-execution/isolate/child-main.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/child-main.js +132 -0
- package/dist/src/code-execution/isolate/child-main.js.map +1 -0
- package/dist/src/code-execution/isolate/child.d.ts +44 -0
- package/dist/src/code-execution/isolate/child.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/child.js +315 -0
- package/dist/src/code-execution/isolate/child.js.map +1 -0
- package/dist/src/code-execution/isolate/frames.d.ts +80 -0
- package/dist/src/code-execution/isolate/frames.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/frames.js +210 -0
- package/dist/src/code-execution/isolate/frames.js.map +1 -0
- package/dist/src/code-execution/isolate/output.d.ts +68 -0
- package/dist/src/code-execution/isolate/output.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/output.js +143 -0
- package/dist/src/code-execution/isolate/output.js.map +1 -0
- package/dist/src/code-execution/isolate/prelude.d.ts +109 -0
- package/dist/src/code-execution/isolate/prelude.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/prelude.js +401 -0
- package/dist/src/code-execution/isolate/prelude.js.map +1 -0
- package/dist/src/code-execution/isolate/protocol.d.ts +151 -0
- package/dist/src/code-execution/isolate/protocol.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/protocol.js +150 -0
- package/dist/src/code-execution/isolate/protocol.js.map +1 -0
- package/dist/src/code-execution/isolate/render.d.ts +57 -0
- package/dist/src/code-execution/isolate/render.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/render.js +214 -0
- package/dist/src/code-execution/isolate/render.js.map +1 -0
- package/dist/src/code-execution/isolate/runner.d.ts +250 -0
- package/dist/src/code-execution/isolate/runner.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/runner.js +854 -0
- package/dist/src/code-execution/isolate/runner.js.map +1 -0
- package/dist/src/code-execution/isolate/scripts.d.ts +175 -0
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -0
- package/dist/src/code-execution/isolate/scripts.js +357 -0
- package/dist/src/code-execution/isolate/scripts.js.map +1 -0
- package/dist/src/code-execution/quickjs.wasm +0 -0
- package/dist/src/code-execution/tool-definition.d.ts +93 -43
- package/dist/src/code-execution/tool-definition.d.ts.map +1 -1
- package/dist/src/code-execution/tool-definition.js +176 -142
- package/dist/src/code-execution/tool-definition.js.map +1 -1
- package/dist/src/deadline-timer.d.ts +3 -0
- package/dist/src/deadline-timer.d.ts.map +1 -1
- package/dist/src/deadline-timer.js +1 -1
- package/dist/src/deadline-timer.js.map +1 -1
- package/dist/src/framework.d.ts +1120 -457
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +4635 -2505
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +28 -4
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +89 -13
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/held-writes.d.ts +16 -3
- package/dist/src/held-writes.d.ts.map +1 -1
- package/dist/src/held-writes.js +16 -3
- package/dist/src/held-writes.js.map +1 -1
- package/dist/src/index.d.ts +8 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts +483 -115
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +1735 -425
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/conversation-router.d.ts +19 -39
- package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
- package/dist/src/mcpl/conversation-router.js +27 -59
- 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 +9 -5
- package/dist/src/mcpl/convert-block.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +50 -0
- package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
- package/dist/src/mcpl/inbound-source.js +130 -0
- package/dist/src/mcpl/inbound-source.js.map +1 -1
- package/dist/src/mcpl/index.d.ts +2 -1
- package/dist/src/mcpl/index.d.ts.map +1 -1
- package/dist/src/mcpl/index.js +3 -2
- package/dist/src/mcpl/index.js.map +1 -1
- package/dist/src/mcpl/log-value.d.ts +6 -0
- package/dist/src/mcpl/log-value.d.ts.map +1 -1
- package/dist/src/mcpl/log-value.js +8 -0
- package/dist/src/mcpl/log-value.js.map +1 -1
- package/dist/src/mcpl/modern-connection.d.ts +15 -6
- package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
- package/dist/src/mcpl/modern-connection.js +168 -53
- package/dist/src/mcpl/modern-connection.js.map +1 -1
- package/dist/src/mcpl/prose-grammar.d.ts +4 -5
- package/dist/src/mcpl/prose-grammar.d.ts.map +1 -1
- package/dist/src/mcpl/prose-grammar.js +4 -5
- package/dist/src/mcpl/prose-grammar.js.map +1 -1
- package/dist/src/mcpl/protocol-family.d.ts +97 -10
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
- package/dist/src/mcpl/protocol-family.js +174 -17
- package/dist/src/mcpl/protocol-family.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +132 -14
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +227 -50
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/push-handler.d.ts +9 -20
- package/dist/src/mcpl/push-handler.d.ts.map +1 -1
- package/dist/src/mcpl/push-handler.js +7 -49
- package/dist/src/mcpl/push-handler.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts +2 -2
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
- package/dist/src/mcpl/reference-fetcher.js +4 -4
- package/dist/src/mcpl/reference-fetcher.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +50 -21
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +158 -74
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/tags.d.ts +24 -0
- package/dist/src/mcpl/tags.d.ts.map +1 -1
- package/dist/src/mcpl/tags.js +33 -0
- package/dist/src/mcpl/tags.js.map +1 -1
- package/dist/src/mcpl/tool-result-normalize.d.ts +2 -1
- package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -1
- package/dist/src/mcpl/tool-result-normalize.js.map +1 -1
- package/dist/src/mcpl/transport.d.ts +55 -7
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +163 -34
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +22 -6
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/module-registry.d.ts +4 -2
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +100 -13
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/discord/index.d.ts.map +1 -1
- package/dist/src/modules/discord/index.js +8 -13
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +27 -4
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/history/semantic.d.ts +15 -3
- package/dist/src/modules/history/semantic.d.ts.map +1 -1
- package/dist/src/modules/history/semantic.js +27 -5
- package/dist/src/modules/history/semantic.js.map +1 -1
- package/dist/src/modules/index.d.ts +1 -1
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js.map +1 -1
- package/dist/src/modules/unknown-tool.d.ts +4 -1
- package/dist/src/modules/unknown-tool.d.ts.map +1 -1
- package/dist/src/modules/unknown-tool.js +4 -1
- package/dist/src/modules/unknown-tool.js.map +1 -1
- package/dist/src/modules/workspace/branch-intent.d.ts +3 -1
- package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
- package/dist/src/modules/workspace/branch-intent.js +3 -1
- package/dist/src/modules/workspace/branch-intent.js.map +1 -1
- package/dist/src/modules/workspace/edit-plan.d.ts +265 -0
- package/dist/src/modules/workspace/edit-plan.d.ts.map +1 -0
- package/dist/src/modules/workspace/edit-plan.js +794 -0
- package/dist/src/modules/workspace/edit-plan.js.map +1 -0
- package/dist/src/modules/workspace/edit-text.d.ts +117 -0
- package/dist/src/modules/workspace/edit-text.d.ts.map +1 -0
- package/dist/src/modules/workspace/edit-text.js +584 -0
- package/dist/src/modules/workspace/edit-text.js.map +1 -0
- package/dist/src/modules/workspace/effects.d.ts +5 -4
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +78 -25
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +493 -62
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +2216 -652
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +213 -38
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +416 -36
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +15 -8
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/modules/workspace/text.d.ts +32 -0
- package/dist/src/modules/workspace/text.d.ts.map +1 -0
- package/dist/src/modules/workspace/text.js +67 -0
- package/dist/src/modules/workspace/text.js.map +1 -0
- package/dist/src/modules/workspace/types.d.ts +210 -6
- package/dist/src/modules/workspace/types.d.ts.map +1 -1
- package/dist/src/modules/workspace/types.js.map +1 -1
- package/dist/src/modules/workspace/watcher.d.ts +3 -2
- package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
- package/dist/src/modules/workspace/watcher.js.map +1 -1
- package/dist/src/operator-log.d.ts +52 -24
- package/dist/src/operator-log.d.ts.map +1 -1
- package/dist/src/operator-log.js.map +1 -1
- package/dist/src/recovery/discord-awareness-outbox.d.ts +496 -72
- package/dist/src/recovery/discord-awareness-outbox.d.ts.map +1 -1
- package/dist/src/recovery/discord-awareness-outbox.js +1196 -289
- package/dist/src/recovery/discord-awareness-outbox.js.map +1 -1
- package/dist/src/recovery/offline-branch.d.ts +26 -1
- package/dist/src/recovery/offline-branch.d.ts.map +1 -1
- package/dist/src/recovery/offline-branch.js +164 -39
- package/dist/src/recovery/offline-branch.js.map +1 -1
- package/dist/src/recovery/recover-cli.js +23 -4
- package/dist/src/recovery/recover-cli.js.map +1 -1
- package/dist/src/send-tools.d.ts +11 -0
- package/dist/src/send-tools.d.ts.map +1 -0
- package/dist/src/send-tools.js +11 -0
- package/dist/src/send-tools.js.map +1 -0
- package/dist/src/timezone.d.ts +4 -2
- package/dist/src/timezone.d.ts.map +1 -1
- package/dist/src/timezone.js +4 -2
- package/dist/src/timezone.js.map +1 -1
- package/dist/src/tool-image-ledger.d.ts +46 -7
- package/dist/src/tool-image-ledger.d.ts.map +1 -1
- package/dist/src/tool-image-ledger.js +60 -7
- package/dist/src/tool-image-ledger.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +14 -11
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +17 -14
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tool-result-history.d.ts +3 -2
- package/dist/src/tool-result-history.d.ts.map +1 -1
- package/dist/src/tool-result-history.js +3 -2
- package/dist/src/tool-result-history.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +21 -0
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +142 -40
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/types/agent.d.ts +31 -6
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +66 -9
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +69 -62
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +40 -8
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +111 -10
- package/dist/src/types/trace.d.ts.map +1 -1
- package/dist/src/usage/types.d.ts +16 -0
- package/dist/src/usage/types.d.ts.map +1 -1
- package/dist/src/usage/usage-tracker.d.ts +14 -1
- package/dist/src/usage/usage-tracker.d.ts.map +1 -1
- package/dist/src/usage/usage-tracker.js +81 -41
- package/dist/src/usage/usage-tracker.js.map +1 -1
- package/package.json +6 -8
- package/src/agent.ts +99 -12
- package/src/api/server.ts +14 -12
- package/src/clock-rows.ts +302 -0
- package/src/code-execution/engine.ts +595 -0
- package/src/code-execution/index.ts +5 -17
- package/src/code-execution/isolate/calls.ts +199 -0
- package/src/code-execution/isolate/child-entry.ts +5 -0
- package/src/code-execution/isolate/child-main.ts +132 -0
- package/src/code-execution/isolate/child.ts +327 -0
- package/src/code-execution/isolate/frames.ts +209 -0
- package/src/code-execution/isolate/output.ts +161 -0
- package/src/code-execution/isolate/prelude.ts +409 -0
- package/src/code-execution/isolate/protocol.ts +240 -0
- package/src/code-execution/isolate/render.ts +230 -0
- package/src/code-execution/isolate/runner.ts +911 -0
- package/src/code-execution/isolate/scripts.ts +479 -0
- package/src/code-execution/quickjs.wasm +0 -0
- package/src/code-execution/quickjs.wasm.LICENSES +149 -0
- package/src/code-execution/tool-definition.ts +236 -167
- package/src/deadline-timer.ts +1 -1
- package/src/framework.ts +4978 -2671
- package/src/gate/event-gate.ts +79 -17
- package/src/held-writes.ts +17 -3
- package/src/index.ts +32 -22
- package/src/mcpl/channel-registry.ts +1892 -471
- package/src/mcpl/conversation-router.ts +26 -72
- package/src/mcpl/convert-block.ts +9 -5
- package/src/mcpl/inbound-source.ts +131 -0
- package/src/mcpl/index.ts +4 -2
- package/src/mcpl/log-value.ts +9 -0
- package/src/mcpl/modern-connection.ts +162 -53
- package/src/mcpl/prose-grammar.ts +4 -5
- package/src/mcpl/protocol-family.ts +200 -22
- package/src/mcpl/push-coalescer.ts +306 -62
- package/src/mcpl/push-handler.ts +12 -54
- package/src/mcpl/reference-fetcher.ts +4 -4
- package/src/mcpl/server-connection.ts +180 -79
- package/src/mcpl/tags.ts +36 -0
- package/src/mcpl/tool-result-normalize.ts +2 -1
- package/src/mcpl/transport.ts +162 -33
- package/src/mcpl/types.ts +23 -6
- package/src/module-registry.ts +92 -13
- package/src/modules/discord/index.ts +8 -13
- package/src/modules/history/index.ts +25 -3
- package/src/modules/history/semantic.ts +29 -6
- package/src/modules/index.ts +1 -0
- package/src/modules/unknown-tool.ts +4 -1
- package/src/modules/workspace/branch-intent.ts +3 -1
- package/src/modules/workspace/edit-plan.ts +954 -0
- package/src/modules/workspace/edit-text.ts +618 -0
- package/src/modules/workspace/effects.ts +70 -19
- package/src/modules/workspace/index.ts +2293 -650
- package/src/modules/workspace/observe.ts +465 -56
- package/src/modules/workspace/reconcile.ts +14 -7
- package/src/modules/workspace/text.ts +68 -0
- package/src/modules/workspace/types.ts +211 -6
- package/src/modules/workspace/watcher.ts +3 -2
- package/src/operator-log.ts +47 -19
- package/src/recovery/discord-awareness-outbox.ts +1500 -356
- package/src/recovery/offline-branch.ts +189 -55
- package/src/recovery/recover-cli.ts +25 -4
- package/src/send-tools.ts +11 -0
- package/src/timezone.ts +4 -2
- package/src/tool-image-ledger.ts +62 -8
- package/src/tool-result-guard.ts +18 -15
- package/src/tool-result-history.ts +3 -2
- package/src/tune-out/coordinator.ts +166 -45
- package/src/types/agent.ts +32 -6
- package/src/types/events.ts +66 -9
- package/src/types/framework.ts +69 -62
- package/src/types/module.ts +40 -8
- package/src/types/trace.ts +121 -15
- package/src/usage/types.ts +16 -0
- package/src/usage/usage-tracker.ts +86 -43
- package/dist/src/code-execution/py-runner.d.ts +0 -191
- package/dist/src/code-execution/py-runner.d.ts.map +0 -1
- package/dist/src/code-execution/py-runner.js +0 -655
- package/dist/src/code-execution/py-runner.js.map +0 -1
- package/dist/src/code-execution/runtime-py.d.ts +0 -50
- package/dist/src/code-execution/runtime-py.d.ts.map +0 -1
- package/dist/src/code-execution/runtime-py.js +0 -677
- package/dist/src/code-execution/runtime-py.js.map +0 -1
- package/dist/src/mcpl/prose-stream-router.d.ts +0 -88
- package/dist/src/mcpl/prose-stream-router.d.ts.map +0 -1
- package/dist/src/mcpl/prose-stream-router.js +0 -291
- package/dist/src/mcpl/prose-stream-router.js.map +0 -1
- package/src/code-execution/py-runner.ts +0 -791
- package/src/code-execution/runtime-py.ts +0 -677
- package/src/mcpl/prose-stream-router.ts +0 -268
|
@@ -49,7 +49,7 @@ import type { ToolDefinition, ToolCall, ToolResult, ProcessEvent } from '../../t
|
|
|
49
49
|
import type { EventResponse, ProcessState } from '../../types/module.js';
|
|
50
50
|
import type { SearchWorkerMessage, SearchWorkerMatch } from './search-regex-worker.js';
|
|
51
51
|
import type { ChannelRegistry } from '../../mcpl/channel-registry.js';
|
|
52
|
-
import { EmbedServiceError, SemanticIndexClient, SemanticIndexer, messageIndexText, type SearchResponse, type SemanticIndexConfig, type SyncReport, type PendingChanges } from './semantic.js';
|
|
52
|
+
import { EmbedServiceError, SemanticIndexClient, SemanticIndexer, messageIndexText, summaryIndexText, type SearchResponse, type SemanticIndexConfig, type SyncReport, type PendingChanges } from './semantic.js';
|
|
53
53
|
import { unknownToolMessage } from '../unknown-tool.js';
|
|
54
54
|
import { safeSlice } from '../../safe-slice.js';
|
|
55
55
|
|
|
@@ -1614,6 +1614,9 @@ export class HistoryModule implements Module {
|
|
|
1614
1614
|
try { sync = await this.indexer.catchUp(this.semanticCfg.maxSyncBeforeSearch ?? 256); } catch { /* reported via indexer.lastError */ }
|
|
1615
1615
|
}
|
|
1616
1616
|
|
|
1617
|
+
// A message's or summary's snippet is built here, from the local text.
|
|
1618
|
+
// `snippet` still bounds what a service that keeps text sends with each
|
|
1619
|
+
// hit, since what it sends without one isn't specified here.
|
|
1617
1620
|
const runSearch = (k: number) => this.semanticClient!.search({
|
|
1618
1621
|
query: input.query, k,
|
|
1619
1622
|
ts_from: fromMs === undefined ? undefined : fromMs / 1000,
|
|
@@ -1667,7 +1670,10 @@ export class HistoryModule implements Module {
|
|
|
1667
1670
|
// /newtopic keeps its id (a new message gets a fresh one) and stays
|
|
1668
1671
|
// indexed. Check every hit against the CURRENT branch before it goes back
|
|
1669
1672
|
// to the model — getMessage/getSummary rebuild on branch switch, so an
|
|
1670
|
-
// undone message or a summary
|
|
1673
|
+
// undone message, or a summary this branch doesn't hold, answers null.
|
|
1674
|
+
// A branch made from an earlier point, as an undo makes one, can mint a
|
|
1675
|
+
// summary id another branch already used, so a summary hit's score,
|
|
1676
|
+
// timestamp and date filtering can still be that other summary's.
|
|
1671
1677
|
// k is small, so this is at most `limit` local lookups.
|
|
1672
1678
|
// A message hit whose current text has nothing left to index (edited
|
|
1673
1679
|
// blank, delete not yet applied) is dropped too, so its stale snippet is
|
|
@@ -1679,6 +1685,10 @@ export class HistoryModule implements Module {
|
|
|
1679
1685
|
// A message hit's snippet is rebuilt from the CURRENT local text, never
|
|
1680
1686
|
// the remote copy: an edit not yet synced (or one the index never got)
|
|
1681
1687
|
// must not leak a passage the edit removed. Only the ranking can be stale.
|
|
1688
|
+
// A summary hit's snippet is rebuilt from the local summary too: a
|
|
1689
|
+
// service that keeps only vectors and ids (no text) still yields one, and
|
|
1690
|
+
// a summary whose id another branch also minted shows this branch's text
|
|
1691
|
+
// in its snippet and chars.
|
|
1682
1692
|
const currentText = new Map<string, string>();
|
|
1683
1693
|
const keep = (h: { id: string }): 'ok' | 'offBranch' | 'stale' => {
|
|
1684
1694
|
const msgId = /^msg:(.+)$/.exec(h.id)?.[1];
|
|
@@ -1691,7 +1701,19 @@ export class HistoryModule implements Module {
|
|
|
1691
1701
|
currentText.set(h.id, text);
|
|
1692
1702
|
return 'ok';
|
|
1693
1703
|
}
|
|
1694
|
-
if (sumId !== undefined)
|
|
1704
|
+
if (sumId !== undefined) {
|
|
1705
|
+
const s = cm.getSummary(sumId);
|
|
1706
|
+
if (!s) return 'offBranch';
|
|
1707
|
+
const text = summaryIndexText(s, this.semanticCfg!);
|
|
1708
|
+
// An empty text here is mostly defensive: context-manager drops a
|
|
1709
|
+
// summary that's empty after trimming when it loads, and refuses to
|
|
1710
|
+
// store one. Short of that, only a maxChars that cuts the text to
|
|
1711
|
+
// nothing gives one. The hit is dropped rather than show the index's
|
|
1712
|
+
// text.
|
|
1713
|
+
if (!text) return 'stale';
|
|
1714
|
+
currentText.set(h.id, text);
|
|
1715
|
+
return 'ok';
|
|
1716
|
+
}
|
|
1695
1717
|
return 'ok';
|
|
1696
1718
|
};
|
|
1697
1719
|
let k = limit;
|
|
@@ -17,8 +17,12 @@
|
|
|
17
17
|
* What gets embedded per message: text blocks verbatim, plus the string
|
|
18
18
|
* arguments of the agent's private-prose tools (think / journal / skip_reply
|
|
19
19
|
* / private_note) labelled `[think] …` — that is the resident's own diary and
|
|
20
|
-
* is exactly what "what did I think about X" should find.
|
|
21
|
-
*
|
|
20
|
+
* is exactly what "what did I think about X" should find. The message
|
|
21
|
+
* argument of the send tools and edit_message, labelled by tool, such as
|
|
22
|
+
* `[send_message] …`, since with prose routing disabled the resident speaks
|
|
23
|
+
* through them.
|
|
24
|
+
* tool_result payloads, other tool arguments, thinking blocks and media are
|
|
25
|
+
* skipped.
|
|
22
26
|
*
|
|
23
27
|
* Failure posture: the service being down never breaks the module. Sync ticks
|
|
24
28
|
* log and back off; `semantic_search` returns a clean tool error.
|
|
@@ -27,6 +31,7 @@
|
|
|
27
31
|
import type { ContextManager, StoredMessage } from '@animalabs/context-manager';
|
|
28
32
|
import type { ContentBlock } from '@animalabs/membrane';
|
|
29
33
|
import { safeSlice } from '../../safe-slice.js';
|
|
34
|
+
import { SEND_TOOLS, bareToolName } from '../../send-tools.js';
|
|
30
35
|
|
|
31
36
|
export interface SemanticIndexConfig {
|
|
32
37
|
/** Base URL of the embed-service, e.g. `http://100.90.161.34:8804`. */
|
|
@@ -80,8 +85,10 @@ export interface SearchHit {
|
|
|
80
85
|
kind: string;
|
|
81
86
|
level: number | null;
|
|
82
87
|
meta: Record<string, unknown>;
|
|
88
|
+
/** The text the service sends for the hit, where it keeps text; a service that keeps none leaves it out. */
|
|
83
89
|
text?: string;
|
|
84
|
-
|
|
90
|
+
/** The length of the text the service holds for the hit; a service that keeps no text may leave it out too. */
|
|
91
|
+
chars?: number;
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
export interface SearchRequest {
|
|
@@ -104,6 +111,12 @@ export interface SearchResponse {
|
|
|
104
111
|
}
|
|
105
112
|
|
|
106
113
|
const PRIVATE_PROSE_TOOLS = new Set(['think', 'journal', 'skip_reply', 'private_note']);
|
|
114
|
+
/**
|
|
115
|
+
* Tools whose message argument is what the resident said: the send tools,
|
|
116
|
+
* and edit_message, whose argument is the new text of a message it sent.
|
|
117
|
+
* With prose routing disabled the resident speaks through these.
|
|
118
|
+
*/
|
|
119
|
+
const SPEECH_TOOLS = new Set([...SEND_TOOLS, 'edit_message']);
|
|
107
120
|
|
|
108
121
|
/**
|
|
109
122
|
* The semantic index service's failure, said of the service alone: it didn't
|
|
@@ -269,6 +282,12 @@ export function messageIndexText(msg: StoredMessage, includePrivateTools = true)
|
|
|
269
282
|
for (const v of Object.values(input)) {
|
|
270
283
|
if (typeof v === 'string' && v.trim().length > 0) parts.push(`[${block.name}] ${v}`);
|
|
271
284
|
}
|
|
285
|
+
} else if (block.type === 'tool_use' && SPEECH_TOOLS.has(bareToolName(block.name))) {
|
|
286
|
+
// Only the message: the other arguments are ids, topics and names.
|
|
287
|
+
// channel_publish still takes `text` from older callers.
|
|
288
|
+
const input = (block as { input?: { content?: unknown; text?: unknown } }).input ?? {};
|
|
289
|
+
const v = input.content ?? input.text;
|
|
290
|
+
if (typeof v === 'string' && v.trim().length > 0) parts.push(`[${bareToolName(block.name)}] ${v}`);
|
|
272
291
|
}
|
|
273
292
|
}
|
|
274
293
|
return parts.join('\n').trim();
|
|
@@ -315,12 +334,16 @@ export interface SummaryLike {
|
|
|
315
334
|
parentId?: string;
|
|
316
335
|
}
|
|
317
336
|
|
|
337
|
+
/** The text a summary is indexed by: its content trimmed, and cut at `maxChars` at a whole character. */
|
|
338
|
+
export function summaryIndexText(s: { content: string }, cfg: { maxChars?: number }): string {
|
|
339
|
+
return safeSlice(s.content.trim(), 0, cfg.maxChars ?? 32_000);
|
|
340
|
+
}
|
|
341
|
+
|
|
318
342
|
export function summaryToItem(s: SummaryLike, cfg: { maxChars?: number }): IndexItem | null {
|
|
319
|
-
|
|
320
|
-
if (!text) return null;
|
|
343
|
+
if (!s.content.trim()) return null;
|
|
321
344
|
return {
|
|
322
345
|
id: `sum:${s.id}`,
|
|
323
|
-
text:
|
|
346
|
+
text: summaryIndexText(s, cfg),
|
|
324
347
|
ts: s.startMs / 1000,
|
|
325
348
|
kind: 'summary',
|
|
326
349
|
level: s.level,
|
package/src/modules/index.ts
CHANGED
|
@@ -5,7 +5,10 @@ import type { ToolDefinition } from '../types/events.js';
|
|
|
5
5
|
* tool, so nothing ran, and which tools the module has, read from its own
|
|
6
6
|
* getTools() so the list can't drift. The registry hands every `module--name`
|
|
7
7
|
* to its module, even one the module doesn't declare, since some modules route
|
|
8
|
-
* undeclared names on purpose, so this answer is the module's to give.
|
|
8
|
+
* undeclared names on purpose, so this answer is the module's to give. On the
|
|
9
|
+
* dispatcher's path it comes after the call has opened (RFC-007), and an
|
|
10
|
+
* in-process route opens none, so either way its result is a failure whose
|
|
11
|
+
* text says nothing ran, not a refusal (ToolResult.refused).
|
|
9
12
|
*/
|
|
10
13
|
export function unknownToolMessage(module: string, name: string, tools: readonly Pick<ToolDefinition, 'name'>[]): string {
|
|
11
14
|
const missing = `There's no tool "${module}--${name}", so nothing ran.`;
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
* - tombstone: the workspace deleted the path while disk kept a copy (no
|
|
8
8
|
* autoMaterialize, or a refused unlink). The hash is the deleted entry's,
|
|
9
|
-
* so even a legacy entry with no disk evidence keeps a durable intent.
|
|
9
|
+
* so even a legacy entry with no disk evidence keeps a durable intent. A
|
|
10
|
+
* tombstone beside an entry that's still there, left by a change that
|
|
11
|
+
* stopped partway (commitToolChanges), is no deletion, and guards nothing.
|
|
10
12
|
* - origin 'store': the entry was created through workspace tools and disk
|
|
11
13
|
* has never agreed with it.
|
|
12
14
|
* - conflict: disk and workspace diverged in a way no rule may resolve
|