@vellumai/assistant 0.8.8 → 0.8.9-staging.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/bun.lock +2 -2
- package/examples/plugins/echo/README.md +61 -60
- package/examples/plugins/echo/hooks/post-tool-use.ts +18 -0
- package/examples/plugins/echo/hooks/stop.ts +16 -0
- package/examples/plugins/echo/hooks/user-prompt-submit.ts +18 -0
- package/examples/plugins/echo/package.json +1 -2
- package/examples/plugins/echo/src/emit.ts +19 -0
- package/node_modules/@vellumai/skill-host-contracts/src/skill-host.ts +7 -6
- package/openapi.yaml +236 -6
- package/package.json +2 -2
- package/src/__tests__/agent-loop-callsite-precedence.test.ts +69 -14
- package/src/__tests__/agent-loop-exit-reason.test.ts +185 -140
- package/src/__tests__/agent-loop-mutable-latest-user-message.test.ts +50 -35
- package/src/__tests__/agent-loop-output-hooks.test.ts +357 -0
- package/src/__tests__/agent-loop-override-profile.test.ts +25 -6
- package/src/__tests__/agent-loop-provider-error-recording.test.ts +41 -21
- package/src/__tests__/agent-loop-thinking.test.ts +36 -20
- package/src/__tests__/agent-loop.test.ts +441 -96
- package/src/__tests__/agent-wake-disk-pressure-callsite.test.ts +14 -14
- package/src/__tests__/agent-wake-override-profile.test.ts +17 -21
- package/src/__tests__/anthropic-provider.test.ts +1 -1
- package/src/__tests__/app-control-flow.test.ts +1 -1
- package/src/__tests__/app-dir-path-guard.test.ts +1 -0
- package/src/__tests__/approval-cascade.test.ts +5 -4
- package/src/__tests__/approval-routes-http.test.ts +4 -1
- package/src/__tests__/background-workers-disk-pressure.test.ts +1 -1
- package/src/__tests__/channel-approval-routes.test.ts +1 -1
- package/src/__tests__/channel-approvals.test.ts +1 -1
- package/src/__tests__/compaction-circuit.test.ts +258 -0
- package/src/__tests__/compaction-direct.test.ts +132 -0
- package/src/__tests__/compaction-events.test.ts +5 -5
- package/src/__tests__/conversation-abort-tool-results.test.ts +6 -4
- package/src/__tests__/conversation-agent-loop-disk-pressure.test.ts +7 -10
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +59 -103
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +94 -189
- package/src/__tests__/conversation-agent-loop.test.ts +249 -490
- package/src/__tests__/conversation-clean-command.test.ts +5 -2
- package/src/__tests__/conversation-confirmation-signals.test.ts +5 -4
- package/src/__tests__/conversation-crud-inference-profile.test.ts +7 -9
- package/src/__tests__/conversation-process-app-control-preactivation.test.ts +4 -4
- package/src/__tests__/conversation-process-callsite.test.ts +14 -14
- package/src/__tests__/conversation-provider-retry-repair.test.ts +18 -16
- package/src/__tests__/conversation-queue.test.ts +9 -9
- package/src/__tests__/conversation-runtime-assembly.test.ts +923 -231
- package/src/__tests__/conversation-runtime-workspace.test.ts +115 -20
- package/src/__tests__/conversation-slash-queue.test.ts +6 -4
- package/src/__tests__/conversation-slash-unknown.test.ts +6 -4
- package/src/__tests__/conversation-speed-override.test.ts +10 -9
- package/src/__tests__/conversation-starter-routes.test.ts +14 -6
- package/src/__tests__/conversation-workspace-cache-state.test.ts +23 -20
- package/src/__tests__/conversation-workspace-injection.test.ts +68 -6
- package/src/__tests__/conversation-workspace-tool-tracking.test.ts +14 -11
- package/src/__tests__/conversations-import-system-filter.test.ts +101 -0
- package/src/__tests__/credential-security-invariants.test.ts +0 -1
- package/src/__tests__/db-acp-history.test.ts +101 -0
- package/src/__tests__/dynamic-page-surface.test.ts +31 -0
- package/src/__tests__/empty-response-hook.test.ts +1 -1
- package/src/__tests__/file-write-tool.test.ts +63 -0
- package/src/__tests__/gateway-only-guard.test.ts +12 -2
- package/src/__tests__/guardian-grant-minting.test.ts +1 -1
- package/src/__tests__/guardian-routing-invariants.test.ts +2 -4
- package/src/__tests__/handlers-user-message-approval-consumption.test.ts +1 -1
- package/src/__tests__/heartbeat-disk-pressure.test.ts +1 -0
- package/src/__tests__/heartbeat-service.test.ts +1 -0
- package/src/__tests__/history-repair-hook.test.ts +1 -1
- package/src/__tests__/host-app-control-routes.test.ts +1 -1
- package/src/__tests__/host-cu-routes-targeted.test.ts +3 -3
- package/src/__tests__/inference-profile-reaper.test.ts +62 -0
- package/src/__tests__/inference-profile-session-handler.test.ts +86 -0
- package/src/__tests__/injector-background-turn.test.ts +13 -23
- package/src/__tests__/injector-chain.test.ts +268 -44
- package/src/__tests__/injector-disk-pressure.test.ts +210 -52
- package/src/__tests__/injector-document-comments.test.ts +97 -114
- package/src/__tests__/injector-pkb-v2-silenced.test.ts +2 -2
- package/src/__tests__/injector-v3-suppression.test.ts +4 -4
- package/src/__tests__/list-messages-client-message-id.test.ts +91 -0
- package/src/__tests__/list-messages-hidden-metadata.test.ts +38 -0
- package/src/__tests__/memory-retrieval-hook.test.ts +73 -6
- package/src/__tests__/memory-v2-static-injector.test.ts +86 -8
- package/src/__tests__/parallel-tool.benchmark.test.ts +35 -8
- package/src/__tests__/plugin-api-shim.test.ts +6 -9
- package/src/__tests__/plugin-bootstrap.test.ts +12 -23
- package/src/__tests__/plugin-registry.test.ts +3 -49
- package/src/__tests__/plugin-types.test.ts +0 -70
- package/src/__tests__/reaction-persistence.test.ts +1 -1
- package/src/__tests__/send-endpoint-busy.test.ts +4 -1
- package/src/__tests__/skill-feature-flags-integration.test.ts +33 -0
- package/src/__tests__/steer-tool-repair.test.ts +1 -1
- package/src/__tests__/subagent-call-site-routing.test.ts +1 -1
- package/src/__tests__/subagent-detail.test.ts +25 -7
- package/src/__tests__/subagent-fork-notifications.test.ts +1 -3
- package/src/__tests__/subagent-fork-spawn.test.ts +1 -1
- package/src/__tests__/subagent-manager-notify.test.ts +1 -3
- package/src/__tests__/subagent-notify-parent.test.ts +1 -3
- package/src/__tests__/subagent-spawn-tool-fork.test.ts +1 -1
- package/src/__tests__/title-generate-hook.test.ts +1 -1
- package/src/__tests__/tool-error-hook.test.ts +1 -1
- package/src/__tests__/tool-result-truncate-hook.test.ts +1 -1
- package/src/__tests__/user-plugin-loader.test.ts +54 -286
- package/src/acp/__tests__/agent-process.test.ts +161 -0
- package/src/acp/__tests__/client-handler.test.ts +40 -0
- package/src/acp/__tests__/helpers/acp-history-db.ts +82 -0
- package/src/acp/__tests__/helpers/exec-file-stub.ts +101 -0
- package/src/acp/__tests__/prepare-agent-env.test.ts +137 -0
- package/src/acp/__tests__/session-manager-persistence.test.ts +95 -28
- package/src/acp/__tests__/session-manager-resume.test.ts +736 -0
- package/src/acp/agent-process.ts +61 -1
- package/src/acp/auto-install.test.ts +196 -0
- package/src/acp/auto-install.ts +177 -0
- package/src/acp/client-handler.ts +31 -0
- package/src/acp/feature-gate.test.ts +48 -0
- package/src/acp/feature-gate.ts +34 -0
- package/src/acp/prepare-agent-env.ts +83 -29
- package/src/acp/resolve-agent.test.ts +320 -7
- package/src/acp/resolve-agent.ts +182 -18
- package/src/acp/resume-hint.ts +25 -0
- package/src/acp/session-manager.ts +495 -73
- package/src/acp/types.ts +8 -0
- package/src/agent/compaction-circuit.ts +60 -102
- package/src/agent/loop.ts +390 -240
- package/src/api/responses/conversation-message.ts +14 -1
- package/src/approvals/guardian-request-resolvers.ts +1 -1
- package/src/background-wake/next-wake.ts +1 -0
- package/src/cli/commands/db/__tests__/repair.test.ts +3 -1
- package/src/cli/commands/plugins.ts +43 -37
- package/src/cli/lib/__tests__/install-from-github.test.ts +429 -111
- package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +196 -0
- package/src/cli/lib/__tests__/plugin-details.test.ts +372 -0
- package/src/cli/lib/__tests__/plugin-marketplace.test.ts +220 -0
- package/src/cli/lib/__tests__/search-plugins.test.ts +226 -32
- package/src/cli/lib/install-from-github.ts +464 -55
- package/src/cli/lib/plugin-catalog-cache.ts +84 -0
- package/src/cli/lib/plugin-details.ts +409 -0
- package/src/cli/lib/plugin-marketplace.ts +197 -0
- package/src/cli/lib/search-plugins.ts +195 -29
- package/src/config/__tests__/feature-flag-registry-guard.test.ts +2 -2
- package/src/config/acp-defaults.test.ts +10 -0
- package/src/config/acp-defaults.ts +6 -0
- package/src/config/bundled-skills/acp/SKILL.md +83 -31
- package/src/config/bundled-skills/acp/TOOLS.json +4 -4
- package/src/config/bundled-skills/app-builder/SKILL.md +224 -381
- package/src/config/bundled-skills/app-builder/TOOLS.json +29 -0
- package/src/config/bundled-skills/app-builder/references/DESIGN_SYSTEM.md +48 -0
- package/src/config/bundled-skills/app-builder/references/RESPONSIVE.md +57 -0
- package/src/config/bundled-skills/app-builder/references/SLIDES.md +38 -0
- package/src/config/bundled-skills/app-builder/tools/app-list.ts +62 -0
- package/src/config/bundled-skills/document-editor/SKILL.md +28 -23
- package/src/config/bundled-skills/document-editor/TOOLS.json +1 -1
- package/src/config/bundled-tool-registry.ts +2 -0
- package/src/config/feature-flag-registry.json +14 -5
- package/src/config/schemas/heartbeat.ts +9 -0
- package/src/context/strip-injections.ts +8 -2
- package/src/context/window-manager.ts +27 -13
- package/src/daemon/conversation-agent-loop-handlers.ts +10 -35
- package/src/daemon/conversation-agent-loop.ts +167 -1005
- package/src/daemon/conversation-lifecycle.ts +11 -255
- package/src/daemon/conversation-process.ts +8 -136
- package/src/daemon/conversation-registry.ts +159 -0
- package/src/daemon/conversation-runtime-assembly.ts +293 -392
- package/src/daemon/conversation-store.ts +9 -90
- package/src/daemon/conversation-surfaces.ts +24 -8
- package/src/daemon/conversation-workspace.ts +17 -0
- package/src/daemon/conversation.ts +383 -56
- package/src/daemon/external-plugins-bootstrap.ts +14 -19
- package/src/daemon/handlers/conversations.ts +3 -1
- package/src/daemon/handlers/skills.ts +4 -1
- package/src/daemon/host-proxy-preactivation.ts +1 -3
- package/src/daemon/lifecycle.ts +21 -0
- package/src/daemon/server.ts +2 -0
- package/src/daemon/wake-conversation-ops.ts +269 -0
- package/src/embedded/plugin-api.ts +2 -2
- package/src/export/__tests__/transcript-formatter.test.ts +5 -0
- package/src/heartbeat/__tests__/heartbeat-service.test.ts +3 -0
- package/src/heartbeat/heartbeat-run-store.ts +23 -1
- package/src/heartbeat/heartbeat-service.ts +26 -0
- package/src/ipc/__tests__/browser-ipc.test.ts +1 -1
- package/src/ipc/__tests__/ui-request-route.test.ts +3 -3
- package/src/ipc/skill-routes/__tests__/memory.test.ts +15 -0
- package/src/ipc/skill-routes/memory.ts +4 -2
- package/src/memory/__tests__/jobs-worker-v2-schedule.test.ts +87 -0
- package/src/memory/conversation-crud.ts +29 -19
- package/src/memory/conversation-starter-checkpoints.ts +1 -0
- package/src/memory/db-init.ts +2 -0
- package/src/memory/job-handlers/conversation-starters.ts +13 -2
- package/src/memory/jobs/__tests__/embed-concept-page.test.ts +5 -4
- package/src/memory/jobs-worker.ts +25 -1
- package/src/memory/migrations/272-acp-session-history-cwd.ts +36 -0
- package/src/memory/migrations/index.ts +1 -0
- package/src/memory/schema/acp.ts +4 -0
- package/src/memory/v2/__tests__/consolidation-job.test.ts +3 -3
- package/src/memory/v2/consolidation-job.ts +13 -4
- package/src/plugin-api/constants.ts +4 -0
- package/src/plugin-api/index.ts +6 -5
- package/src/plugin-api/types.ts +75 -0
- package/src/plugins/defaults/compaction/compact.ts +59 -0
- package/src/plugins/defaults/compaction/manager-store.ts +44 -0
- package/src/plugins/defaults/compaction/package.json +1 -2
- package/src/plugins/defaults/empty-response/package.json +0 -1
- package/src/plugins/defaults/history-repair/package.json +0 -1
- package/src/plugins/defaults/index.ts +135 -26
- package/src/plugins/defaults/memory-retrieval/hooks/post-compact.ts +103 -38
- package/src/plugins/defaults/memory-retrieval/hooks/user-prompt-submit-temp.ts +167 -56
- package/src/plugins/defaults/memory-retrieval/injector-chain.ts +2 -2
- package/src/plugins/defaults/{injectors/register.ts → memory-retrieval/injectors.ts} +148 -73
- package/src/plugins/defaults/memory-retrieval/unified-turn-context.ts +223 -0
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/assign.test.ts +4 -4
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/live-integration.test.ts +9 -6
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/maintain-job.test.ts +5 -5
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/orchestrate.test.ts +8 -5
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/reconcile.test.ts +2 -2
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/render-injection.test.ts +1 -1
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/router.test.ts +10 -5
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/selection-log-store.test.ts +8 -8
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/selector.test.ts +5 -5
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/shadow-plugin.test.ts +16 -17
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/types.test.ts +2 -2
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/assign.ts +9 -5
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/capabilities.ts +5 -2
- package/src/plugins/defaults/memory-v3-shadow/hooks/post-compact.ts +14 -0
- package/src/plugins/defaults/memory-v3-shadow/hooks/user-prompt-submit.ts +19 -0
- package/src/plugins/defaults/memory-v3-shadow/injector.ts +75 -0
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/maintain-job.ts +15 -8
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/orchestrate.ts +2 -2
- package/src/plugins/defaults/memory-v3-shadow/package.json +14 -0
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/page-content.ts +2 -2
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/provider-blocks.ts +1 -1
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/reconcile.ts +7 -3
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/render-injection.ts +1 -1
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/router.ts +5 -5
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/selection-log-store.ts +4 -4
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/selector.ts +7 -7
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/shadow-plugin.ts +32 -94
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/tree.ts +1 -1
- package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/types.ts +1 -1
- package/src/plugins/defaults/title-generate/package.json +0 -1
- package/src/plugins/defaults/tool-error/package.json +0 -1
- package/src/plugins/defaults/tool-result-truncate/package.json +0 -1
- package/src/plugins/pipeline.ts +6 -293
- package/src/plugins/registry.ts +9 -37
- package/src/plugins/types.ts +76 -381
- package/src/plugins/user-loader.ts +30 -127
- package/src/proactive-artifact/aux-message-injector.ts +1 -1
- package/src/proactive-artifact/job.test.ts +1 -1
- package/src/prompts/__tests__/system-prompt.test.ts +6 -0
- package/src/prompts/templates/BOOTSTRAP-ACTIVATION-RAIL.md +35 -3
- package/src/runtime/__tests__/agent-wake.test.ts +555 -691
- package/src/runtime/__tests__/interactive-ui.test.ts +1 -1
- package/src/runtime/agent-wake.ts +108 -209
- package/src/runtime/assistant-event-hub.ts +1 -1
- package/src/runtime/channel-approvals.ts +1 -1
- package/src/runtime/interactive-ui.ts +1 -1
- package/src/runtime/routes/__tests__/acp-routes.test.ts +283 -55
- package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +1 -1
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +398 -73
- package/src/runtime/routes/__tests__/surface-action-routes.test.ts +5 -4
- package/src/runtime/routes/__tests__/surface-content-routes.test.ts +4 -1
- package/src/runtime/routes/acp-routes.test.ts +89 -25
- package/src/runtime/routes/acp-routes.ts +81 -29
- package/src/runtime/routes/approval-routes.ts +1 -1
- package/src/runtime/routes/browser-routes.ts +1 -1
- package/src/runtime/routes/browser-tabs-routes.ts +6 -10
- package/src/runtime/routes/conversation-cli-routes.ts +1 -1
- package/src/runtime/routes/conversation-list-routes.ts +1 -1
- package/src/runtime/routes/conversation-query-routes.ts +1 -1
- package/src/runtime/routes/conversation-routes.ts +28 -2
- package/src/runtime/routes/conversation-starter-routes.ts +13 -7
- package/src/runtime/routes/conversations-import-routes.ts +24 -7
- package/src/runtime/routes/host-app-control-routes.ts +1 -1
- package/src/runtime/routes/host-cu-routes.ts +1 -1
- package/src/runtime/routes/identity-routes.ts +18 -3
- package/src/runtime/routes/inbound-message-handler.ts +1 -1
- package/src/runtime/routes/inference-profile-session-handler.ts +11 -0
- package/src/runtime/routes/inference-profile-session-reaper.ts +6 -0
- package/src/runtime/routes/memory-v3-routes.ts +16 -6
- package/src/runtime/routes/playground/helpers.ts +1 -1
- package/src/runtime/routes/plugins-routes.ts +336 -35
- package/src/runtime/routes/surface-conversation-resolver.ts +4 -3
- package/src/runtime/routes/work-items-routes.ts +2 -4
- package/src/runtime/services/conversation-serializer.ts +1 -1
- package/src/signals/cancel.ts +2 -4
- package/src/subagent/manager.ts +21 -5
- package/src/tools/acp/context.ts +20 -0
- package/src/tools/acp/list-agents.test.ts +7 -1
- package/src/tools/acp/spawn.test.ts +158 -55
- package/src/tools/acp/spawn.ts +47 -72
- package/src/tools/acp/steer.test.ts +105 -8
- package/src/tools/acp/steer.ts +48 -17
- package/src/tools/apps/executors.ts +13 -8
- package/src/tools/filesystem/write.ts +34 -0
- package/src/tools/subagent/spawn.ts +2 -4
- package/src/tools/ui-surface/definitions.ts +25 -5
- package/src/workspace/migrations/051-seed-conversation-summarization-callsite.ts +4 -5
- package/src/workspace/migrations/097-enable-adaptive-thinking-managed-profiles.ts +69 -45
- package/docs/plugins.md +0 -832
- package/examples/plugins/echo/register.ts +0 -143
- package/src/__tests__/circuit-breaker-pipeline.test.ts +0 -405
- package/src/__tests__/compaction-pipeline.test.ts +0 -210
- package/src/__tests__/compaction-timeout-recovery.test.ts +0 -251
- package/src/__tests__/overflow-reduce-pipeline.test.ts +0 -667
- package/src/__tests__/pipeline-runner.test.ts +0 -554
- package/src/__tests__/plugin-external-api.test.ts +0 -68
- package/src/daemon/wake-target-adapter.ts +0 -253
- package/src/plugins/defaults/circuit-breaker/middlewares/circuitBreaker.ts +0 -93
- package/src/plugins/defaults/circuit-breaker/package.json +0 -15
- package/src/plugins/defaults/circuit-breaker/register.ts +0 -39
- package/src/plugins/defaults/compaction/middlewares/compaction.ts +0 -25
- package/src/plugins/defaults/compaction/register.ts +0 -35
- package/src/plugins/defaults/compaction/terminal.ts +0 -73
- package/src/plugins/defaults/empty-response/register.ts +0 -23
- package/src/plugins/defaults/history-repair/register.ts +0 -24
- package/src/plugins/defaults/overflow-reduce/middlewares/overflowReduce.ts +0 -126
- package/src/plugins/defaults/overflow-reduce/package.json +0 -15
- package/src/plugins/defaults/overflow-reduce/register.ts +0 -42
- package/src/plugins/defaults/title-generate/register.ts +0 -35
- package/src/plugins/defaults/tool-error/register.ts +0 -23
- package/src/plugins/defaults/tool-result-truncate/register.ts +0 -24
- package/src/plugins/external-api.ts +0 -104
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/capabilities.test.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/core.test.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/fixtures/eval-turns.json +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/fixtures/live-turns.json +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/health.test.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/needle.test.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/provider-blocks.test.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/snapshot.test.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/tree.test.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/working-set-eviction.test.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/__tests__/working-set-skeleton.test.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/core.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/data/README.md +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/data/assignments.json +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/data/core.json +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/data/leaves/domain-a/topic-x.md +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/data/leaves/domain-a/topic-y.md +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/data/leaves/domain-b/topic-z.md +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/health.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/llm-retry.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/needle.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/snapshot.ts +0 -0
- /package/src/{memory/v3 → plugins/defaults/memory-v3-shadow}/working-set.ts +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default compaction implementation.
|
|
3
|
+
*
|
|
4
|
+
* Summarizes conversation history when the context window fills up by
|
|
5
|
+
* delegating to a {@link ContextWindowManager}. The agent loop calls
|
|
6
|
+
* {@link defaultCompact} directly with a {@link CompactionContext}; the request
|
|
7
|
+
* carries the conversational inputs while the manager performs the work.
|
|
8
|
+
*
|
|
9
|
+
* This module is side-effect free: importing it does not register any plugin.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
ContextWindowManager,
|
|
14
|
+
ContextWindowResult,
|
|
15
|
+
} from "../../../context/window-manager.js";
|
|
16
|
+
import type { Message } from "../../../providers/types.js";
|
|
17
|
+
import type { TrustClass } from "../../../runtime/actor-trust-resolver.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Name under which the default compaction plugin registers. Exposed so call
|
|
21
|
+
* sites can attribute compaction failures to the default plugin.
|
|
22
|
+
*/
|
|
23
|
+
export const DEFAULT_COMPACTION_PLUGIN_NAME = "default-compaction";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Self-describing compaction request handed to {@link defaultCompact}. Carries
|
|
27
|
+
* the conversational inputs plus the {@link ContextWindowManager} that runs the
|
|
28
|
+
* summary, so the request is the part that can grow toward a model-facing
|
|
29
|
+
* compaction-method shape without coupling callers to the manager's option bag.
|
|
30
|
+
*/
|
|
31
|
+
export interface CompactionContext {
|
|
32
|
+
/** Context window manager that performs the compaction. */
|
|
33
|
+
manager: ContextWindowManager;
|
|
34
|
+
/** Message history to consider for compaction. */
|
|
35
|
+
messages: Message[];
|
|
36
|
+
/** Abort signal forwarded to the compaction summary call. */
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
/** Skip the auto-threshold check (forced/overflow/emergency compaction). */
|
|
39
|
+
force?: boolean;
|
|
40
|
+
/** Per-conversation inference-profile override for the summary call. */
|
|
41
|
+
overrideProfile?: string | null;
|
|
42
|
+
/** Pre-computed token estimate from a prior `shouldCompact()` call. */
|
|
43
|
+
precomputedEstimate?: number;
|
|
44
|
+
/** Legacy keep-boundary hint forwarded to the compactor. */
|
|
45
|
+
minKeepRecentUserTurns?: number;
|
|
46
|
+
/** Trust class of the actor whose turn triggered compaction. */
|
|
47
|
+
actorTrustClass?: TrustClass;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Run compaction for the turn: delegates to the request's context window
|
|
52
|
+
* manager and returns the (possibly summarized) message history.
|
|
53
|
+
*/
|
|
54
|
+
export async function defaultCompact(
|
|
55
|
+
context: CompactionContext,
|
|
56
|
+
): Promise<ContextWindowResult> {
|
|
57
|
+
const { manager, messages, signal, ...options } = context;
|
|
58
|
+
return manager.maybeCompact(messages, signal, options);
|
|
59
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-conversation {@link ContextWindowManager} ownership for the default
|
|
3
|
+
* compaction module.
|
|
4
|
+
*
|
|
5
|
+
* Construction of the manager lives here rather than in the conversation so the
|
|
6
|
+
* compaction surface owns the manager's lifetime: {@link createContextWindowManager}
|
|
7
|
+
* builds the instance and records it in a per-conversation store, and
|
|
8
|
+
* {@link disposeContextWindowManager} drops it when the conversation is torn
|
|
9
|
+
* down so the store doesn't grow unbounded.
|
|
10
|
+
*
|
|
11
|
+
* This module is side-effect free: importing it only initializes an empty
|
|
12
|
+
* store and registers no plugin.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
ContextWindowManager,
|
|
17
|
+
type ContextWindowManagerOptions,
|
|
18
|
+
} from "../../../context/window-manager.js";
|
|
19
|
+
|
|
20
|
+
/** Live managers keyed by conversation id. */
|
|
21
|
+
const managersByConversation = new Map<string, ContextWindowManager>();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Build the conversation's {@link ContextWindowManager} and register it under
|
|
25
|
+
* its conversation id. Construction is owned by the compaction module; the
|
|
26
|
+
* conversation supplies the provider, prompt/tool resolvers, and initial
|
|
27
|
+
* config. Replaces any prior manager for the same conversation so each
|
|
28
|
+
* construction yields a fresh instance, matching a direct `new` call.
|
|
29
|
+
*/
|
|
30
|
+
export function createContextWindowManager(
|
|
31
|
+
options: ContextWindowManagerOptions & { conversationId: string },
|
|
32
|
+
): ContextWindowManager {
|
|
33
|
+
const manager = new ContextWindowManager(options);
|
|
34
|
+
managersByConversation.set(options.conversationId, manager);
|
|
35
|
+
return manager;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Release the manager registered for a conversation. Called from conversation
|
|
40
|
+
* teardown so the store releases the instance once the conversation is gone.
|
|
41
|
+
*/
|
|
42
|
+
export function disposeContextWindowManager(conversationId: string): void {
|
|
43
|
+
managersByConversation.delete(conversationId);
|
|
44
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "default-compaction",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"description": "First-party default plugin
|
|
4
|
+
"description": "First-party default plugin providing the assistant's built-in conversation-history compaction.",
|
|
5
5
|
"private": true,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "./register.ts",
|
|
9
8
|
"engines": {
|
|
10
9
|
"node": ">=20.12.0"
|
|
11
10
|
},
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* First-party default plugins — definitions and centralized registration.
|
|
3
3
|
*
|
|
4
|
-
* Each default
|
|
5
|
-
*
|
|
6
|
-
* and at test time, even when no
|
|
4
|
+
* Each default contributes the hooks for one of the assistant's built-in
|
|
5
|
+
* behaviors (history repair, title generation, tool-error coaching, …) so the
|
|
6
|
+
* lifecycle is always populated at boot and at test time, even when no
|
|
7
|
+
* third-party plugins are loaded. A `Plugin` is the manifest (name/version,
|
|
8
|
+
* sourced from the sibling `package.json`) plus its hook map; the hook
|
|
9
|
+
* implementations live in each `defaults/<name>/hooks/` directory.
|
|
7
10
|
*
|
|
8
11
|
* Consumers:
|
|
9
12
|
*
|
|
@@ -16,44 +19,150 @@
|
|
|
16
19
|
* production-parity state (e.g. `conversation-agent-loop.test.ts`); those
|
|
17
20
|
* call {@link resetPluginRegistryAndRegisterDefaults}.
|
|
18
21
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* every module has finished initializing, so importing this aggregator does no
|
|
23
|
-
* registration work.
|
|
22
|
+
* The plugin definitions below are plain `const`s, so importing this module
|
|
23
|
+
* does no registration work — registration is driven by
|
|
24
|
+
* {@link registerDefaultPlugins} at call time.
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
27
|
import { registerPlugin, resetPluginRegistryForTests } from "../registry.js";
|
|
27
28
|
import { type Plugin, PluginExecutionError } from "../types.js";
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
29
|
+
import compactionPkg from "./compaction/package.json" with { type: "json" };
|
|
30
|
+
import emptyResponseStop from "./empty-response/hooks/stop.js";
|
|
31
|
+
import emptyResponsePkg from "./empty-response/package.json" with { type: "json" };
|
|
32
|
+
import historyRepairUserPromptSubmit from "./history-repair/hooks/user-prompt-submit.js";
|
|
33
|
+
import historyRepairPkg from "./history-repair/package.json" with { type: "json" };
|
|
34
|
+
import memoryV3PostCompact from "./memory-v3-shadow/hooks/post-compact.js";
|
|
35
|
+
import memoryV3UserPromptSubmit from "./memory-v3-shadow/hooks/user-prompt-submit.js";
|
|
36
|
+
import memoryV3Pkg from "./memory-v3-shadow/package.json" with { type: "json" };
|
|
37
|
+
import titleGenerateStop from "./title-generate/hooks/stop.js";
|
|
38
|
+
import titleGenerateUserPromptSubmit from "./title-generate/hooks/user-prompt-submit.js";
|
|
39
|
+
import titleGeneratePkg from "./title-generate/package.json" with { type: "json" };
|
|
40
|
+
import toolErrorPostToolUse from "./tool-error/hooks/post-tool-use.js";
|
|
41
|
+
import toolErrorPkg from "./tool-error/package.json" with { type: "json" };
|
|
42
|
+
import toolResultTruncatePostToolUse from "./tool-result-truncate/hooks/post-tool-use.js";
|
|
43
|
+
import toolResultTruncatePkg from "./tool-result-truncate/package.json" with { type: "json" };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `compaction` — compaction is implemented in `compaction/compact.ts` as
|
|
47
|
+
* `defaultCompact`, which the agent loop calls directly. The plugin stays
|
|
48
|
+
* registered as a placeholder so it keeps a presence in the defaults list
|
|
49
|
+
* while we decide how plugins should surface compaction; it contributes no
|
|
50
|
+
* hooks today.
|
|
51
|
+
*/
|
|
52
|
+
export const defaultCompactionPlugin: Plugin = {
|
|
53
|
+
manifest: {
|
|
54
|
+
name: compactionPkg.name,
|
|
55
|
+
version: compactionPkg.version,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* `empty-response` — a `stop` hook that re-queries the model when a turn
|
|
61
|
+
* yields with no tool calls but came back empty (or as a provider refusal).
|
|
62
|
+
*/
|
|
63
|
+
export const defaultEmptyResponsePlugin: Plugin = {
|
|
64
|
+
manifest: {
|
|
65
|
+
name: emptyResponsePkg.name,
|
|
66
|
+
version: emptyResponsePkg.version,
|
|
67
|
+
},
|
|
68
|
+
hooks: {
|
|
69
|
+
stop: emptyResponseStop,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* `history-repair` — a `user-prompt-submit` hook that normalizes the working
|
|
75
|
+
* message history (tool-use/tool-result pairing, role alternation) before the
|
|
76
|
+
* agent loop hands it to the provider.
|
|
77
|
+
*/
|
|
78
|
+
export const defaultHistoryRepairPlugin: Plugin = {
|
|
79
|
+
manifest: {
|
|
80
|
+
name: historyRepairPkg.name,
|
|
81
|
+
version: historyRepairPkg.version,
|
|
82
|
+
},
|
|
83
|
+
hooks: {
|
|
84
|
+
"user-prompt-submit": historyRepairUserPromptSubmit,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* `memory-v3-shadow` — houses the memory-v3 shadow/live orchestration engine
|
|
90
|
+
* (`memory-v3-shadow/`) and its injector. The `user-prompt-submit` /
|
|
91
|
+
* `post-compact` hooks are no-op scaffolding for the eventual convergence,
|
|
92
|
+
* when v3 injection moves off the loop-driven chain and into these hooks.
|
|
93
|
+
*/
|
|
94
|
+
export const memoryV3ShadowPlugin: Plugin = {
|
|
95
|
+
manifest: {
|
|
96
|
+
name: memoryV3Pkg.name,
|
|
97
|
+
version: memoryV3Pkg.version,
|
|
98
|
+
},
|
|
99
|
+
hooks: {
|
|
100
|
+
"user-prompt-submit": memoryV3UserPromptSubmit,
|
|
101
|
+
"post-compact": memoryV3PostCompact,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* `title-generate` — two pure-trigger hooks that delegate the title work to
|
|
107
|
+
* the conversation-title service: `user-prompt-submit` (first-pass title) and
|
|
108
|
+
* `stop` (second-pass regeneration once the topic is established).
|
|
109
|
+
*/
|
|
110
|
+
export const defaultTitleGeneratePlugin: Plugin = {
|
|
111
|
+
manifest: {
|
|
112
|
+
name: titleGeneratePkg.name,
|
|
113
|
+
version: titleGeneratePkg.version,
|
|
114
|
+
},
|
|
115
|
+
hooks: {
|
|
116
|
+
"user-prompt-submit": titleGenerateUserPromptSubmit,
|
|
117
|
+
stop: titleGenerateStop,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* `tool-error` — a `post-tool-use` hook that coaches the model to retry or
|
|
123
|
+
* report a failed tool call, bounded per tool. The coaching is surfaced via
|
|
124
|
+
* `additionalContext`, leaving the tool result's own content untouched.
|
|
125
|
+
*/
|
|
126
|
+
export const defaultToolErrorPlugin: Plugin = {
|
|
127
|
+
manifest: {
|
|
128
|
+
name: toolErrorPkg.name,
|
|
129
|
+
version: toolErrorPkg.version,
|
|
130
|
+
},
|
|
131
|
+
hooks: {
|
|
132
|
+
"post-tool-use": toolErrorPostToolUse,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* `tool-result-truncate` — a `post-tool-use` hook that tail-drops an oversized
|
|
138
|
+
* tool result down to a character budget derived from the model's context
|
|
139
|
+
* window before the result is sent to the provider.
|
|
140
|
+
*/
|
|
141
|
+
export const defaultToolResultTruncatePlugin: Plugin = {
|
|
142
|
+
manifest: {
|
|
143
|
+
name: toolResultTruncatePkg.name,
|
|
144
|
+
version: toolResultTruncatePkg.version,
|
|
145
|
+
},
|
|
146
|
+
hooks: {
|
|
147
|
+
"post-tool-use": toolResultTruncatePostToolUse,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
36
150
|
|
|
37
151
|
/**
|
|
38
152
|
* Full set of first-party default plugins. Used by
|
|
39
153
|
* {@link registerDefaultPlugins} to drive the registration loop; the array
|
|
40
|
-
* order is the registration order, which
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* Returned by a function rather than a top-level `const` so the array
|
|
44
|
-
* contents are read at call time, after every imported plugin identifier is
|
|
45
|
-
* guaranteed initialized.
|
|
154
|
+
* order is the registration order, which fixes hook-chain order (defaults run
|
|
155
|
+
* ahead of any later-registered user plugins).
|
|
46
156
|
*/
|
|
47
157
|
function getAllDefaultPlugins(): readonly Plugin[] {
|
|
48
158
|
return [
|
|
49
159
|
defaultToolResultTruncatePlugin,
|
|
50
160
|
defaultEmptyResponsePlugin,
|
|
51
161
|
defaultToolErrorPlugin,
|
|
52
|
-
defaultOverflowReducePlugin,
|
|
53
162
|
defaultHistoryRepairPlugin,
|
|
54
163
|
defaultCompactionPlugin,
|
|
55
|
-
defaultCircuitBreakerPlugin,
|
|
56
164
|
defaultTitleGeneratePlugin,
|
|
165
|
+
memoryV3ShadowPlugin,
|
|
57
166
|
];
|
|
58
167
|
}
|
|
59
168
|
|
|
@@ -85,7 +194,7 @@ export function registerDefaultPlugins(): void {
|
|
|
85
194
|
* so integration tests that exercise the full agent loop have a
|
|
86
195
|
* production-parity plugin stack. Use this in `beforeEach` of tests that
|
|
87
196
|
* dispatch through pipelines with a terminal that assumes the default
|
|
88
|
-
* plugin handles every op (e.g.
|
|
197
|
+
* plugin handles every op (e.g. compaction).
|
|
89
198
|
*
|
|
90
199
|
* Tests that specifically need an empty registry (pipeline-unit tests, the
|
|
91
200
|
* plugin-registry tests themselves) should continue to call
|
|
@@ -21,69 +21,134 @@
|
|
|
21
21
|
* The memory graph handle is sourced internally from the plugin's own
|
|
22
22
|
* conversation-keyed registry ({@link getLiveGraphMemory}) rather than being
|
|
23
23
|
* threaded in by the loop — it is memory-retrieval-specific state, not
|
|
24
|
-
* something the generic loop
|
|
24
|
+
* something the generic loop should carry.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import {
|
|
28
28
|
applyRuntimeInjections,
|
|
29
|
-
type
|
|
29
|
+
type InboundActorContext,
|
|
30
|
+
type InjectionMode,
|
|
30
31
|
type RuntimeInjectionResult,
|
|
31
32
|
} from "../../../../daemon/conversation-runtime-assembly.js";
|
|
33
|
+
import {
|
|
34
|
+
resolveTrustClass,
|
|
35
|
+
type TrustContext,
|
|
36
|
+
} from "../../../../daemon/trust-context.js";
|
|
32
37
|
import { stripHistoricalWebSearchResults } from "../../../../daemon/web-search-history.js";
|
|
33
38
|
import { getLiveGraphMemory } from "../../../../memory/graph/conversation-graph-memory.js";
|
|
34
|
-
import type { PluginLogger } from "../../../../plugin-api/types.js";
|
|
35
39
|
import type { Message } from "../../../../providers/types.js";
|
|
36
|
-
import
|
|
40
|
+
import { getLogger } from "../../../../util/logger.js";
|
|
41
|
+
|
|
42
|
+
const log = getLogger("post-compact-reinject");
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
|
-
*
|
|
40
|
-
* state. Re-injection inputs migrate loop-ward by growing this
|
|
41
|
-
* hands the hook an object of this shape
|
|
42
|
-
* {@link
|
|
45
|
+
* Everything the post-compaction hook needs, supplied by the agent loop from
|
|
46
|
+
* its own working state. Re-injection inputs migrate loop-ward by growing this
|
|
47
|
+
* type; the loop hands the hook an object of this shape when it calls
|
|
48
|
+
* {@link postCompact} directly.
|
|
49
|
+
*
|
|
50
|
+
* The turn-identity fields are flat here: `conversationId` is the key the
|
|
51
|
+
* re-injection resolves the live conversation through (and the only one that,
|
|
52
|
+
* together with `requestId` and `trust`, cannot be recovered from that live
|
|
53
|
+
* conversation), while `turnIndex` and `callSite` are intentionally omitted so
|
|
54
|
+
* {@link applyRuntimeInjections} self-resolves them from the live conversation.
|
|
55
|
+
* The memory graph handle is likewise sourced internally via
|
|
56
|
+
* {@link getLiveGraphMemory} rather than threaded in.
|
|
43
57
|
*/
|
|
44
|
-
export interface
|
|
58
|
+
export interface PostCompactContext {
|
|
45
59
|
/** Compacted message history to re-inject onto. */
|
|
46
60
|
history: Message[];
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Stable ID for the current request, forwarded onto the injector turn
|
|
63
|
+
* context. The one turn-identity field that cannot be recovered from the
|
|
64
|
+
* live conversation, so the loop supplies it.
|
|
65
|
+
*/
|
|
66
|
+
requestId: string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Conversation the turn is scoped to. The key the re-injection resolves the
|
|
69
|
+
* live conversation (and its channel/trust/transcript state) through, so the
|
|
70
|
+
* loop always supplies it.
|
|
71
|
+
*/
|
|
72
|
+
conversationId: string;
|
|
73
|
+
/**
|
|
74
|
+
* Trust classification and channel identity for the inbound actor, forwarded
|
|
75
|
+
* onto the injector turn context and used to gate the memory-graph re-track.
|
|
76
|
+
* Supplied by the loop as the turn-start snapshot rather than re-resolved
|
|
77
|
+
* mid-turn.
|
|
78
|
+
*/
|
|
79
|
+
trust: TrustContext;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the in-flight turn has no human present to answer clarification
|
|
82
|
+
* questions. Resolved once by the agent loop at turn start (from its
|
|
83
|
+
* `isInteractive` option, which can fall back to mutable client/headless
|
|
84
|
+
* state that flips mid-turn on SSE reconnect) and handed to the hook here, so
|
|
85
|
+
* re-injection uses the loop's turn-start snapshot rather than re-reading
|
|
86
|
+
* live conversation state.
|
|
87
|
+
*/
|
|
88
|
+
isNonInteractive: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Injection volume for the re-applied blocks. Owned by the agent loop, which
|
|
91
|
+
* drops to `"minimal"` when overflow reduction trims the prompt; handed to
|
|
92
|
+
* the hook here so re-injection matches the loop's committed decision instead
|
|
93
|
+
* of re-deriving it.
|
|
94
|
+
*/
|
|
95
|
+
mode: InjectionMode;
|
|
96
|
+
/**
|
|
97
|
+
* The `model_profile:` turn-context label, or `null` when the active
|
|
98
|
+
* inference profile is unchanged since the last notified one. The agent loop
|
|
99
|
+
* resolves it once at turn start from config and the turn's profile override,
|
|
100
|
+
* and notifies the model only on change — a decision that flips mid-turn once
|
|
101
|
+
* the notification is persisted, so it cannot be re-derived. Handed to the
|
|
102
|
+
* hook here so re-injection re-emits the loop's turn-start value.
|
|
103
|
+
*/
|
|
104
|
+
modelProfile: string | null;
|
|
105
|
+
/**
|
|
106
|
+
* Inbound actor identity and trust fields for the unified `<turn_context>`
|
|
107
|
+
* block, or `null` on guardian turns (which suppress the actor section). The
|
|
108
|
+
* agent loop resolves it once at turn start via the actor-trust resolver,
|
|
109
|
+
* whose contact/member registry inputs can be mutated mid-turn by contact
|
|
110
|
+
* tools, so it cannot be re-derived. Handed to the hook here so re-injection
|
|
111
|
+
* re-emits the loop's turn-start value.
|
|
112
|
+
*/
|
|
113
|
+
actorContext: InboundActorContext | null;
|
|
65
114
|
}
|
|
66
115
|
|
|
67
|
-
export default async function
|
|
116
|
+
export default async function postCompact(
|
|
68
117
|
ctx: PostCompactContext,
|
|
69
118
|
): Promise<RuntimeInjectionResult> {
|
|
70
|
-
const { history,
|
|
71
|
-
|
|
119
|
+
const { history, requestId, conversationId, trust, ...options } = ctx;
|
|
120
|
+
// The remaining `options` carry the non-identity injection inputs
|
|
121
|
+
// (`isNonInteractive`, `mode`, `modelProfile`, `actorContext`). Forward the
|
|
122
|
+
// turn-identity fields the live conversation can't supply (`requestId`,
|
|
123
|
+
// `conversationId`, `trust`); `turnIndex` and `callSite` self-resolve from
|
|
124
|
+
// the live conversation so the re-injection matches the turn's initial
|
|
125
|
+
// assembly.
|
|
126
|
+
const result = await applyRuntimeInjections(history, {
|
|
127
|
+
...options,
|
|
128
|
+
requestId,
|
|
129
|
+
conversationId,
|
|
130
|
+
trust,
|
|
131
|
+
});
|
|
72
132
|
// Re-track the nodes the memory graph last injected so they survive against
|
|
73
133
|
// the re-injected history. Untrusted actors and minimal-mode turns never
|
|
74
134
|
// received a memory-graph injection, so there is nothing to re-track. The
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
135
|
+
// actor's trust class is derived from the turn's own trust context (the same
|
|
136
|
+
// value the injector chain resolves). The live graph handle is looked up
|
|
137
|
+
// from the plugin's own registry by the turn's conversation id — the same
|
|
138
|
+
// instance the turn's retrieval mutated, so re-tracking sees the real
|
|
139
|
+
// cached-node state.
|
|
140
|
+
const isTrustedActor = resolveTrustClass(trust) === "guardian";
|
|
78
141
|
if (isTrustedActor && options.mode !== "minimal") {
|
|
79
|
-
getLiveGraphMemory(
|
|
80
|
-
options.turnContext?.conversationId,
|
|
81
|
-
)?.retrackCachedNodes();
|
|
142
|
+
getLiveGraphMemory(conversationId)?.retrackCachedNodes();
|
|
82
143
|
}
|
|
83
144
|
const strip = stripHistoricalWebSearchResults(result.messages);
|
|
84
145
|
if (strip.stats.blocksStripped > 0) {
|
|
85
|
-
|
|
86
|
-
{
|
|
146
|
+
log.info(
|
|
147
|
+
{
|
|
148
|
+
phase: "mid-loop-compact",
|
|
149
|
+
conversationId,
|
|
150
|
+
...strip.stats,
|
|
151
|
+
},
|
|
87
152
|
"Converted historical web_search_tool_result blocks to text summaries",
|
|
88
153
|
);
|
|
89
154
|
}
|