@vellumai/assistant 0.8.8 → 0.8.9-staging.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +6 -6
- 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 +235 -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 +204 -144
- 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-builder-tool-scripts.test.ts +21 -0
- package/src/__tests__/app-control-flow.test.ts +1 -1
- package/src/__tests__/app-dir-path-guard.test.ts +1 -0
- package/src/__tests__/app-executors.test.ts +132 -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__/compactor-web-search-strip.test.ts +213 -0
- package/src/__tests__/context-overflow-reducer.test.ts +1 -1
- 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 +78 -119
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +142 -218
- package/src/__tests__/conversation-agent-loop.test.ts +297 -586
- 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-history-web-search.test.ts +1 -1
- 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 +70 -65
- 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 +131 -26
- 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__/pre-model-call-sanitize.test.ts +109 -0
- 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 +106 -0
- package/src/acp/__tests__/prepare-agent-env.test.ts +97 -0
- package/src/acp/__tests__/session-manager-persistence.test.ts +95 -28
- package/src/acp/__tests__/session-manager-resume.test.ts +888 -0
- package/src/acp/agent-process.ts +61 -1
- package/src/acp/auto-install.test.ts +280 -0
- package/src/acp/auto-install.ts +232 -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 +80 -27
- package/src/acp/resolve-agent.test.ts +225 -9
- package/src/acp/resolve-agent.ts +122 -17
- package/src/acp/resume-hint.ts +23 -0
- package/src/acp/session-manager.ts +507 -73
- package/src/agent/compaction-circuit.ts +60 -102
- package/src/agent/loop.ts +414 -248
- 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 +85 -33
- 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 +72 -2
- 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/app-builder/tools/app-update.ts +18 -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 +4 -0
- package/src/config/call-site-defaults.ts +0 -2
- package/src/config/feature-flag-registry.json +15 -6
- package/src/config/schemas/call-site-catalog.ts +0 -14
- package/src/config/schemas/heartbeat.ts +9 -0
- package/src/config/schemas/llm.ts +0 -2
- package/src/context/compactor.ts +22 -4
- 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 +175 -1055
- 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 +404 -57
- package/src/daemon/disk-pressure-policy.ts +0 -1
- 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 -7
- 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/{daemon → plugins/defaults/compaction}/context-overflow-reducer.ts +7 -7
- package/src/plugins/defaults/compaction/manager-store.ts +57 -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 +100 -52
- package/src/plugins/defaults/memory-retrieval/hooks/user-prompt-submit-temp.ts +184 -74
- 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/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 +315 -55
- package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +1 -1
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +423 -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 +337 -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 +8 -2
- package/src/tools/acp/spawn.test.ts +176 -195
- package/src/tools/acp/spawn.ts +37 -172
- package/src/tools/acp/steer.test.ts +105 -8
- package/src/tools/acp/steer.ts +48 -17
- package/src/tools/apps/executors.ts +166 -50
- 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/proactive-artifact/aux-message-injector.ts +0 -97
- package/src/proactive-artifact/decision.test.ts +0 -226
- package/src/proactive-artifact/decision.ts +0 -165
- package/src/proactive-artifact/index.ts +0 -7
- package/src/proactive-artifact/job.test.ts +0 -962
- package/src/proactive-artifact/job.ts +0 -372
- package/src/proactive-artifact/message-copy.ts +0 -58
- package/src/proactive-artifact/trigger-state.test.ts +0 -286
- package/src/proactive-artifact/trigger-state.ts +0 -123
- /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
package/src/plugins/registry.ts
CHANGED
|
@@ -10,20 +10,16 @@
|
|
|
10
10
|
* late-arriving registrations.
|
|
11
11
|
*
|
|
12
12
|
* Registration is order-preserving: {@link getRegisteredPlugins} and
|
|
13
|
-
* {@link
|
|
14
|
-
*
|
|
15
|
-
* in the pipeline runner.
|
|
13
|
+
* {@link getHooksFor} reflect the order in which {@link registerPlugin} was
|
|
14
|
+
* called, which in turn determines the order plugin hooks run.
|
|
16
15
|
*
|
|
17
16
|
* This module does not call `Plugin.init()` — that is the job of the
|
|
18
|
-
* bootstrap
|
|
19
|
-
* later PRs introduce consumers.
|
|
17
|
+
* bootstrap. It also does not wire the registry into the daemon.
|
|
20
18
|
*
|
|
21
|
-
* Design doc: `.private/plans/agent-plugin-system.md
|
|
19
|
+
* Design doc: `.private/plans/agent-plugin-system.md`.
|
|
22
20
|
*/
|
|
23
21
|
|
|
24
22
|
import {
|
|
25
|
-
type PipelineMiddlewareMap,
|
|
26
|
-
type PipelineName,
|
|
27
23
|
type Plugin,
|
|
28
24
|
PluginExecutionError,
|
|
29
25
|
type PluginHookFn,
|
|
@@ -33,7 +29,7 @@ import {
|
|
|
33
29
|
|
|
34
30
|
/**
|
|
35
31
|
* Registered plugins keyed by `manifest.name`. A `Map` preserves insertion
|
|
36
|
-
* order, which the registry relies on for
|
|
32
|
+
* order, which the registry relies on for hook ordering and
|
|
37
33
|
* `getRegisteredPlugins()` output.
|
|
38
34
|
*/
|
|
39
35
|
const registeredPlugins = new Map<string, Plugin>();
|
|
@@ -46,8 +42,7 @@ const registeredPlugins = new Map<string, Plugin>();
|
|
|
46
42
|
* top-level `await` later resolves and still tries to call
|
|
47
43
|
* {@link registerPlugin}. Without the latch such a late arrival would land in
|
|
48
44
|
* the registry after `bootstrapPlugins()` has already walked it, leaving the
|
|
49
|
-
* plugin visible
|
|
50
|
-
* `init()` hook never invoked.
|
|
45
|
+
* plugin visible in the registry with its `init()` hook never invoked.
|
|
51
46
|
*/
|
|
52
47
|
let registrationClosed = false;
|
|
53
48
|
|
|
@@ -66,7 +61,7 @@ let registrationClosed = false;
|
|
|
66
61
|
*
|
|
67
62
|
* On success the plugin is appended to the registry in the order this
|
|
68
63
|
* function is called. This function does NOT invoke `plugin.init()` — that
|
|
69
|
-
* runs in the bootstrap sequence
|
|
64
|
+
* runs in the bootstrap sequence.
|
|
70
65
|
*/
|
|
71
66
|
export function registerPlugin(plugin: Plugin): void {
|
|
72
67
|
// Basic shape / required-field validation. The type system already enforces
|
|
@@ -143,27 +138,6 @@ export function getRegisteredPlugins(): Plugin[] {
|
|
|
143
138
|
return Array.from(registeredPlugins.values());
|
|
144
139
|
}
|
|
145
140
|
|
|
146
|
-
/**
|
|
147
|
-
* Collect the middleware each registered plugin contributes for the given
|
|
148
|
-
* pipeline, in registration order. Consumers feed the returned array into the
|
|
149
|
-
* pipeline runner's `composeMiddleware` helper (PR 12), which applies the
|
|
150
|
-
* outermost-first convention.
|
|
151
|
-
*
|
|
152
|
-
* Plugins that don't declare a middleware for `pipeline` are skipped.
|
|
153
|
-
*/
|
|
154
|
-
export function getMiddlewaresFor<P extends PipelineName>(
|
|
155
|
-
pipeline: P,
|
|
156
|
-
): PipelineMiddlewareMap[P][] {
|
|
157
|
-
const out: PipelineMiddlewareMap[P][] = [];
|
|
158
|
-
for (const plugin of registeredPlugins.values()) {
|
|
159
|
-
const middleware = plugin.middleware?.[pipeline];
|
|
160
|
-
if (middleware) {
|
|
161
|
-
out.push(middleware);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return out;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
141
|
/**
|
|
168
142
|
* Collect every registered plugin's hook for the given name, in
|
|
169
143
|
* registration order. Plugins that don't declare a hook for `name` are
|
|
@@ -208,10 +182,8 @@ export function closeRegistration(): void {
|
|
|
208
182
|
|
|
209
183
|
/**
|
|
210
184
|
* Remove a plugin from the registry. Invoked from the bootstrap's failure path
|
|
211
|
-
* after {@link Plugin.onShutdown} and contribution teardown have run, so
|
|
212
|
-
*
|
|
213
|
-
* mid-bootstrap. Without this, every subsequent pipeline invocation would
|
|
214
|
-
* re-enter the uninitialized plugin's middleware.
|
|
185
|
+
* after {@link Plugin.onShutdown} and contribution teardown have run, so the
|
|
186
|
+
* registry no longer exposes a plugin whose `init()` aborted mid-bootstrap.
|
|
215
187
|
* Safe to call on an already-absent name (no-op).
|
|
216
188
|
*/
|
|
217
189
|
export function unregisterPlugin(name: string): void {
|
package/src/plugins/types.ts
CHANGED
|
@@ -1,34 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Plugin core types.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* The assistant composes behavior around a small set of named pipelines
|
|
10
|
-
* (`compaction`, `overflowReduce`, ...). Each plugin may contribute one
|
|
11
|
-
* {@link Middleware} per pipeline; the registry composes them in onion
|
|
12
|
-
* order at runtime. Plugins may also contribute {@link Injector}s that emit
|
|
13
|
-
* system-prompt-time content, as well as model-visible capabilities
|
|
14
|
-
* (`tools`, `routes`, `skills`).
|
|
4
|
+
* A plugin may contribute lifecycle hooks ({@link PluginHooks}) that the
|
|
5
|
+
* runtime invokes at named events, and model-visible capabilities (`tools`,
|
|
6
|
+
* `routes`, `skills`). The registry tracks every registered plugin in
|
|
7
|
+
* registration order.
|
|
15
8
|
*
|
|
16
9
|
* Design doc: `.private/plans/agent-plugin-system.md`.
|
|
17
10
|
*/
|
|
18
11
|
|
|
19
12
|
import type { CompactionCircuitClosedEvent } from "../api/events/compaction-circuit-closed.js";
|
|
20
13
|
import type { CompactionCircuitOpenEvent } from "../api/events/compaction-circuit-open.js";
|
|
21
|
-
import type { ContextWindowConfig } from "../config/schemas/inference.js";
|
|
22
14
|
import type { LLMCallSite } from "../config/schemas/llm.js";
|
|
23
15
|
import type {
|
|
24
|
-
ContextWindowManager,
|
|
25
|
-
ContextWindowResult,
|
|
26
|
-
} from "../context/window-manager.js";
|
|
27
|
-
import type { ReducerState } from "../daemon/context-overflow-reducer.js";
|
|
28
|
-
import type {
|
|
29
|
-
ActiveSurfaceContext,
|
|
30
16
|
ChannelCapabilities,
|
|
31
|
-
|
|
17
|
+
InboundActorContext,
|
|
32
18
|
InjectionMode,
|
|
33
19
|
} from "../daemon/conversation-runtime-assembly.js";
|
|
34
20
|
import type { TrustContext } from "../daemon/trust-context.js";
|
|
@@ -88,32 +74,7 @@ export type {
|
|
|
88
74
|
PluginShutdownContext,
|
|
89
75
|
} from "../plugin-api/types.js";
|
|
90
76
|
|
|
91
|
-
// ───
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Generic onion-style middleware. Each middleware may observe/modify the
|
|
95
|
-
* arguments, decide whether to call `next` (short-circuit) or return a
|
|
96
|
-
* synthetic result, and observe/modify the downstream result. `ctx` is the
|
|
97
|
-
* immutable per-turn {@link TurnContext}.
|
|
98
|
-
*/
|
|
99
|
-
export type Middleware<A, R> = (
|
|
100
|
-
args: A,
|
|
101
|
-
next: (args: A) => Promise<R>,
|
|
102
|
-
ctx: TurnContext,
|
|
103
|
-
) => Promise<R>;
|
|
104
|
-
|
|
105
|
-
// ─── Pipeline names ──────────────────────────────────────────────────────────
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Exhaustive list of pipeline slot names. New pipelines must be added here
|
|
109
|
-
* and in `DEFAULT_TIMEOUTS` (PR 12). The registry only understands these.
|
|
110
|
-
*/
|
|
111
|
-
export type PipelineName = "compaction" | "overflowReduce" | "circuitBreaker";
|
|
112
|
-
|
|
113
|
-
// ─── Per-pipeline args / results (placeholder shapes) ────────────────────────
|
|
114
|
-
// Concrete field-level types land in M2/M3 PRs as each pipeline is wrapped.
|
|
115
|
-
// Until then we expose `unknown`-tagged aliases so downstream code can name
|
|
116
|
-
// the types without depending on unstable internal shapes.
|
|
77
|
+
// ─── Memory-graph result ─────────────────────────────────────────────────────
|
|
117
78
|
|
|
118
79
|
/**
|
|
119
80
|
* Full output of a single memory-graph retrieval — the object returned by
|
|
@@ -126,186 +87,7 @@ export type GraphMemoryResult = Awaited<
|
|
|
126
87
|
>;
|
|
127
88
|
|
|
128
89
|
/**
|
|
129
|
-
*
|
|
130
|
-
* would otherwise have passed to {@link ContextWindowManager.maybeCompact}.
|
|
131
|
-
*
|
|
132
|
-
* Typed via `unknown`-forwarded aliases to keep this module free of runtime
|
|
133
|
-
* imports from `context/window-manager.ts` (which would pull the full
|
|
134
|
-
* compaction machinery into anything that merely imports plugin types).
|
|
135
|
-
* The default compaction plugin re-casts back to the concrete types before
|
|
136
|
-
* delegating to the manager.
|
|
137
|
-
*/
|
|
138
|
-
export type CompactionArgs = {
|
|
139
|
-
/** The message history to consider for compaction. */
|
|
140
|
-
readonly messages: unknown;
|
|
141
|
-
/** Abort signal forwarded to the compaction summary call. */
|
|
142
|
-
readonly signal?: AbortSignal;
|
|
143
|
-
/** `ContextWindowCompactOptions` — options block forwarded verbatim. */
|
|
144
|
-
readonly options?: unknown;
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Pipeline result for the `compaction` slot — the full
|
|
148
|
-
* {@link import("../context/window-manager.js").ContextWindowResult}
|
|
149
|
-
* object returned by `maybeCompact()`. Kept as `unknown` here for the
|
|
150
|
-
* same decoupling reason as {@link CompactionArgs}; consumers in
|
|
151
|
-
* `daemon/conversation-agent-loop.ts` cast back to the concrete shape.
|
|
152
|
-
*/
|
|
153
|
-
export type CompactionResult = unknown;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Input to the `overflowReduce` pipeline. Captures everything the reducer
|
|
157
|
-
* tier loop needs, including the message history, reducer configuration,
|
|
158
|
-
* and side-effect callbacks that bridge the pipeline back to the orchestrator's
|
|
159
|
-
* mutable per-turn state (context-window manager, activity emitter, runtime
|
|
160
|
-
* injection reassembly, memory reinjection).
|
|
161
|
-
*
|
|
162
|
-
* The callbacks are supplied by the orchestrator because the reducer loop
|
|
163
|
-
* needs to coordinate with state that lives on the `AgentLoopConversationContext`
|
|
164
|
-
* (message mutation, compaction event emission, circuit breaker tracking,
|
|
165
|
-
* injection block reassembly). Keeping them as explicit callbacks — rather
|
|
166
|
-
* than pulling the whole context into the pipeline — preserves the rule that
|
|
167
|
-
* `TurnContext` stays minimal and pipeline-agnostic.
|
|
168
|
-
*/
|
|
169
|
-
export interface OverflowReduceArgs {
|
|
170
|
-
/** Bare persisted message history (mutable copy — the default middleware
|
|
171
|
-
* applies reducer results in-place via the `applyMessages` callback). */
|
|
172
|
-
readonly messages: Message[];
|
|
173
|
-
/** Current run-time message array with runtime injections applied. */
|
|
174
|
-
readonly runMessages: Message[];
|
|
175
|
-
/** System prompt used for post-step token estimation. */
|
|
176
|
-
readonly systemPrompt: string;
|
|
177
|
-
/** Provider name used for token estimation (calibration provider key). */
|
|
178
|
-
readonly providerName: string;
|
|
179
|
-
/** Context window config (drives compaction behavior). */
|
|
180
|
-
readonly contextWindow: ContextWindowConfig;
|
|
181
|
-
/** Token budget the reducer must get below (preflight budget). */
|
|
182
|
-
readonly preflightBudget: number;
|
|
183
|
-
/** Tool-token overhead included in every estimation call. */
|
|
184
|
-
readonly toolTokenBudget?: number;
|
|
185
|
-
/** Maximum reducer iterations before the loop exits unconditionally. */
|
|
186
|
-
readonly maxAttempts: number;
|
|
187
|
-
/** Abort signal threaded through compaction calls. */
|
|
188
|
-
readonly abortSignal?: AbortSignal;
|
|
189
|
-
/**
|
|
190
|
-
* Compaction callback — the reducer never owns the ContextWindowManager
|
|
191
|
-
* instance. The orchestrator supplies this closure so the default plugin
|
|
192
|
-
* can delegate the forced-compaction tier without crossing the
|
|
193
|
-
* pipeline/infra boundary on its own.
|
|
194
|
-
*/
|
|
195
|
-
readonly compactFn: (
|
|
196
|
-
messages: Message[],
|
|
197
|
-
signal: AbortSignal | undefined,
|
|
198
|
-
options: unknown,
|
|
199
|
-
) => Promise<ContextWindowResult>;
|
|
200
|
-
/**
|
|
201
|
-
* Invoked before each reducer iteration to emit the `context_compacting`
|
|
202
|
-
* activity state. The orchestrator owns activity emission because the
|
|
203
|
-
* signal is trust/channel aware.
|
|
204
|
-
*/
|
|
205
|
-
readonly emitActivityState: () => void;
|
|
206
|
-
/**
|
|
207
|
-
* Invoked after each reducer step that produced a successful compaction.
|
|
208
|
-
* Handles circuit-breaker tracking, event emission, and context mutation.
|
|
209
|
-
* The pipeline passes back `didCompact` so the orchestrator can flip its
|
|
210
|
-
* `reducerCompacted` / `shouldInjectWorkspace` flags and the next
|
|
211
|
-
* re-injection uses the fresh messages.
|
|
212
|
-
*/
|
|
213
|
-
readonly onCompactionResult: (
|
|
214
|
-
result: ContextWindowResult,
|
|
215
|
-
compactedBasis?: Message[],
|
|
216
|
-
) => void | Promise<void>;
|
|
217
|
-
/**
|
|
218
|
-
* Invoked after each step to rebuild `runMessages` from the step's
|
|
219
|
-
* reduced history with the requested injection mode. The orchestrator
|
|
220
|
-
* owns this helper so the full per-turn injection options object doesn't
|
|
221
|
-
* leak into the pipeline surface. The plugin passes the current reduced
|
|
222
|
-
* messages array explicitly so the orchestrator doesn't need to read
|
|
223
|
-
* mutable shared state. Returns the new `runMessages`.
|
|
224
|
-
*
|
|
225
|
-
* Two distinct "did compact" signals are passed so the orchestrator can
|
|
226
|
-
* apply the correct per-iteration vs sticky gating:
|
|
227
|
-
* - `stepCompacted` — whether THIS iteration's reducer step produced a
|
|
228
|
-
* fresh compaction. Gates PKB / NOW re-injection: compaction strips the
|
|
229
|
-
* existing blocks, so only iterations that just compacted need the
|
|
230
|
-
* content re-threaded. Iterations that only truncated tool results or
|
|
231
|
-
* downgraded injections must NOT force a re-injection or the token
|
|
232
|
-
* count grows each round.
|
|
233
|
-
* - `accumulatedCompacted` — whether ANY iteration in this pipeline
|
|
234
|
-
* invocation has compacted. Gates `slackChronologicalMessages`
|
|
235
|
-
* suppression: once compaction has run, the captured Slack transcript
|
|
236
|
-
* snapshot would overwrite the compacted history, so it must stay
|
|
237
|
-
* suppressed for every subsequent iteration even if that iteration
|
|
238
|
-
* didn't re-compact.
|
|
239
|
-
*/
|
|
240
|
-
readonly reinjectForMode: (
|
|
241
|
-
messages: Message[],
|
|
242
|
-
mode: InjectionMode,
|
|
243
|
-
stepCompacted: boolean,
|
|
244
|
-
accumulatedCompacted: boolean,
|
|
245
|
-
) => Promise<Message[]>;
|
|
246
|
-
/**
|
|
247
|
-
* Invoked after each step to post-estimate the rebuilt `runMessages`.
|
|
248
|
-
* Pulled out so the orchestrator controls how estimation is performed
|
|
249
|
-
* (and which fields feed it) without the pipeline reimplementing it.
|
|
250
|
-
*/
|
|
251
|
-
readonly estimatePostInjection: (runMessages: Message[]) => number;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** Output of the `overflowReduce` pipeline. */
|
|
255
|
-
export interface OverflowReduceResult {
|
|
256
|
-
/** Final reduced `ctx.messages` value (mutated in place by the reducer). */
|
|
257
|
-
readonly messages: Message[];
|
|
258
|
-
/** Final `runMessages` with re-applied runtime injections. */
|
|
259
|
-
readonly runMessages: Message[];
|
|
260
|
-
/** Final injection mode (may be `"minimal"` if the downgrade tier fired). */
|
|
261
|
-
readonly injectionMode: InjectionMode;
|
|
262
|
-
/** Accumulated reducer state at exit. */
|
|
263
|
-
readonly reducerState: ReducerState;
|
|
264
|
-
/** True if any step successfully compacted history. */
|
|
265
|
-
readonly reducerCompacted: boolean;
|
|
266
|
-
/** How many iterations of the tier loop executed. */
|
|
267
|
-
readonly attempts: number;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Arguments for the `circuitBreaker` pipeline.
|
|
272
|
-
*
|
|
273
|
-
* A single call pattern handles both querying and updating the breaker:
|
|
274
|
-
* - `{ key }` — query-only. Returns the current `{ open, cooldownRemainingMs? }`.
|
|
275
|
-
* - `{ key, outcome }` — update state, then return the post-update decision.
|
|
276
|
-
*
|
|
277
|
-
* `key` identifies the circuit bucket so independent circuits (e.g. per
|
|
278
|
-
* conversation, per provider) can coexist. The default compaction plugin
|
|
279
|
-
* uses `"compaction:<conversationId>"`.
|
|
280
|
-
*
|
|
281
|
-
* `state` is a pragmatic extension beyond the minimal `{ key, outcome? }`
|
|
282
|
-
* shape: the `Conversation` owns `consecutiveCompactionFailures` and
|
|
283
|
-
* `compactionCircuitOpenUntil` because dev-only playground routes read and
|
|
284
|
-
* mutate those fields directly. The default plugin reads/updates the same
|
|
285
|
-
* container so the pipeline stays a pure wrapper rather than forking state
|
|
286
|
-
* ownership.
|
|
287
|
-
*
|
|
288
|
-
* `onEvent` is optional — when provided, the default plugin emits
|
|
289
|
-
* `compaction_circuit_open` / `compaction_circuit_closed` transition events
|
|
290
|
-
* through it. Its parameter is narrowed to {@link CompactionCircuitEvent} (the
|
|
291
|
-
* only two messages this pipeline ever emits) rather than the full
|
|
292
|
-
* `ServerMessage` union, so a caller whose outbound channel can carry just
|
|
293
|
-
* these two events can satisfy it. Callers that only want to query without
|
|
294
|
-
* emitting can omit it.
|
|
295
|
-
*/
|
|
296
|
-
export type CircuitBreakerArgs = {
|
|
297
|
-
readonly key: string;
|
|
298
|
-
readonly outcome?: "success" | "failure";
|
|
299
|
-
readonly state: {
|
|
300
|
-
readonly conversationId: string;
|
|
301
|
-
consecutiveCompactionFailures: number;
|
|
302
|
-
compactionCircuitOpenUntil: number | null;
|
|
303
|
-
};
|
|
304
|
-
readonly onEvent?: (msg: CompactionCircuitEvent) => void;
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* The complete set of transition events the `circuitBreaker` pipeline emits:
|
|
90
|
+
* The complete set of compaction circuit-breaker transition events:
|
|
309
91
|
* `compaction_circuit_open` when the breaker trips and `compaction_circuit_closed`
|
|
310
92
|
* on the open→closed transition. Both are a subset of `ServerMessage`, so any
|
|
311
93
|
* existing `ServerMessage` sink remains assignable to a
|
|
@@ -315,49 +97,38 @@ export type CompactionCircuitEvent =
|
|
|
315
97
|
| CompactionCircuitOpenEvent
|
|
316
98
|
| CompactionCircuitClosedEvent;
|
|
317
99
|
|
|
318
|
-
/**
|
|
319
|
-
* Result of a `circuitBreaker` pipeline invocation.
|
|
320
|
-
*
|
|
321
|
-
* - `open` — `true` when the breaker is currently tripped (auto paths must
|
|
322
|
-
* skip). `false` when closed (auto paths may proceed).
|
|
323
|
-
* - `cooldownRemainingMs` — when `open` is `true`, the number of ms until
|
|
324
|
-
* the breaker auto-closes (for informational display). Omitted when the
|
|
325
|
-
* breaker is closed.
|
|
326
|
-
*/
|
|
327
|
-
export type CircuitBreakerResult = {
|
|
328
|
-
readonly open: boolean;
|
|
329
|
-
readonly cooldownRemainingMs?: number;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Mapping from {@link PipelineName} to the middleware signature the registry
|
|
334
|
-
* expects for that slot. Used both to shape `Plugin.middleware` and to drive
|
|
335
|
-
* `getMiddlewaresFor<P>()` type narrowing in PR 13.
|
|
336
|
-
*/
|
|
337
|
-
export interface PipelineMiddlewareMap {
|
|
338
|
-
compaction: Middleware<CompactionArgs, CompactionResult>;
|
|
339
|
-
overflowReduce: Middleware<OverflowReduceArgs, OverflowReduceResult>;
|
|
340
|
-
circuitBreaker: Middleware<CircuitBreakerArgs, CircuitBreakerResult>;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
100
|
// ─── TurnContext ─────────────────────────────────────────────────────────────
|
|
344
101
|
|
|
345
102
|
/**
|
|
346
|
-
* Per-turn
|
|
103
|
+
* Per-turn execution context threaded to the injector chain and to hook
|
|
104
|
+
* consumers that need turn-level identity.
|
|
347
105
|
*
|
|
348
|
-
*
|
|
349
|
-
* the
|
|
350
|
-
*
|
|
106
|
+
* Combines turn-level identifiers (`requestId`, `conversationId`,
|
|
107
|
+
* `turnIndex`) and the canonical {@link TrustContext} (trust class and
|
|
108
|
+
* channel identity for the inbound actor) with the per-turn injection inputs
|
|
109
|
+
* consumed by the default {@link Injector} chain — the text, gating state,
|
|
110
|
+
* and timezone/actor parameters that drive each injector's
|
|
111
|
+
* {@link InjectionBlock} output.
|
|
112
|
+
*
|
|
113
|
+
* `applyRuntimeInjections` resolves the injection fields once per turn and
|
|
114
|
+
* layers them onto the caller's context right before
|
|
115
|
+
* {@link collectInjectorBlocks}. Call sites that synthesize a context outside
|
|
116
|
+
* the agent loop (tests, overflow-reducer reinjection, etc.) may omit them —
|
|
117
|
+
* every injection field is optional and every default injector treats a
|
|
118
|
+
* missing input as "no injection on this turn".
|
|
351
119
|
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
* `conversation-agent-loop.ts` right before `applyRuntimeInjections`). Call
|
|
355
|
-
* sites that synthesize a {@link TurnContext} outside of the agent loop
|
|
356
|
-
* (tests, overflow-reducer reinjection, etc.) may omit the bag entirely —
|
|
357
|
-
* every field is optional and every default injector treats a missing input
|
|
358
|
-
* as "no injection on this turn".
|
|
120
|
+
* `TrustContext` is re-exposed here (rather than redefined) so the plugin
|
|
121
|
+
* surface always stays in sync with the assistant's trust model.
|
|
359
122
|
*/
|
|
360
|
-
export interface
|
|
123
|
+
export interface TurnContext {
|
|
124
|
+
/** Stable ID for the current request (one per inbound message). */
|
|
125
|
+
requestId: string;
|
|
126
|
+
/** Conversation ID the turn is scoped to. */
|
|
127
|
+
conversationId: string;
|
|
128
|
+
/** 0-based turn index within the conversation. */
|
|
129
|
+
turnIndex: number;
|
|
130
|
+
/** Trust classification and channel identity for the inbound actor. */
|
|
131
|
+
trust: TrustContext;
|
|
361
132
|
/**
|
|
362
133
|
* Controls which runtime injections are applied. `"full"` (default) runs
|
|
363
134
|
* every gating branch; `"minimal"` skips high-token optional blocks
|
|
@@ -365,12 +136,37 @@ export interface TurnInjectionInputs {
|
|
|
365
136
|
* context (unified turn context, etc.). Drives per-injector gating.
|
|
366
137
|
*/
|
|
367
138
|
readonly mode?: InjectionMode;
|
|
368
|
-
/**
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
readonly
|
|
139
|
+
/**
|
|
140
|
+
* Wall-clock timestamp for the turn, formatted in the actor's effective
|
|
141
|
+
* timezone. Drives the `current_time` line of the `<turn_context>` block;
|
|
142
|
+
* when absent the `unified-turn-context` injector emits nothing.
|
|
143
|
+
*/
|
|
144
|
+
readonly timestamp?: string;
|
|
145
|
+
/** Human-readable interface label (e.g. "vellum", "telegram"). */
|
|
146
|
+
readonly interfaceName?: string;
|
|
147
|
+
/** Channel label gating response-discretion guidance in `<turn_context>`. */
|
|
148
|
+
readonly channelName?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Inbound actor identity and trust fields. Populated only on non-guardian
|
|
151
|
+
* turns; `null`/absent suppresses the actor section of `<turn_context>`.
|
|
152
|
+
*/
|
|
153
|
+
readonly actorContext?: InboundActorContext | null;
|
|
154
|
+
/** Guardian-configured timezone, used to detect a client/config mismatch. */
|
|
155
|
+
readonly configuredUserTimezone?: string | null;
|
|
156
|
+
/** Client-reported timezone, used to detect a client/config mismatch. */
|
|
157
|
+
readonly clientTimezone?: string | null;
|
|
158
|
+
/** Server-detected timezone fallback when the client does not report one. */
|
|
159
|
+
readonly detectedTimezone?: string | null;
|
|
160
|
+
/**
|
|
161
|
+
* Human-readable gap since the previous user message (e.g. "14h ago"), only
|
|
162
|
+
* set when the gap exceeds the long-absence threshold.
|
|
163
|
+
*/
|
|
164
|
+
readonly timeSinceLastMessage?: string | null;
|
|
165
|
+
/**
|
|
166
|
+
* Human-readable active inference profile, only set when it changed since
|
|
167
|
+
* the last turn (or on the first turn).
|
|
168
|
+
*/
|
|
169
|
+
readonly modelProfile?: string | null;
|
|
374
170
|
/** Pre-built `<active_subagents>` block or null to skip. */
|
|
375
171
|
readonly subagentStatusBlock?: string | null;
|
|
376
172
|
/** Channel capabilities — drives slack gating. */
|
|
@@ -387,18 +183,6 @@ export interface TurnInjectionInputs {
|
|
|
387
183
|
* no focus block is appended.
|
|
388
184
|
*/
|
|
389
185
|
readonly slackActiveThreadFocusBlock?: string | null;
|
|
390
|
-
/**
|
|
391
|
-
* Active dashboard-surface context (read from `<active_workspace>`). Kept
|
|
392
|
-
* on the injection inputs bag (not its own injector) because it is
|
|
393
|
-
* orchestrator-owned surface state, not a default-chain element.
|
|
394
|
-
*/
|
|
395
|
-
readonly activeSurface?: ActiveSurfaceContext | null;
|
|
396
|
-
/** Channel command context (e.g. Telegram /start) or null to skip. */
|
|
397
|
-
readonly channelCommandContext?: ChannelCommandContext | null;
|
|
398
|
-
/** Voice call-control prompt or null to skip. */
|
|
399
|
-
readonly voiceCallControlPrompt?: string | null;
|
|
400
|
-
/** Gateway-provided transport hints (e.g. Slack thread context). */
|
|
401
|
-
readonly transportHints?: string[] | null;
|
|
402
186
|
/**
|
|
403
187
|
* When true, inject the `<non_interactive_context>` block so the model
|
|
404
188
|
* knows no human is present to answer clarification questions.
|
|
@@ -422,77 +206,18 @@ export interface TurnInjectionInputs {
|
|
|
422
206
|
wordCount: number;
|
|
423
207
|
updatedAt: number;
|
|
424
208
|
}> | null;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
export interface DiskPressureInjectionContext {
|
|
428
|
-
/** True when the current turn is allowed to run only for storage cleanup. */
|
|
429
|
-
readonly cleanupModeActive: boolean;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Per-turn execution context threaded through every middleware invocation.
|
|
434
|
-
*
|
|
435
|
-
* Combines turn-level identifiers (`requestId`, `conversationId`,
|
|
436
|
-
* `turnIndex`), the optionally-bound `pluginName` (set by the pipeline
|
|
437
|
-
* runner when invoking a specific plugin's middleware, for error
|
|
438
|
-
* attribution), and the canonical {@link TrustContext} that carries trust
|
|
439
|
-
* class and channel identity for the inbound actor.
|
|
440
|
-
*
|
|
441
|
-
* `TrustContext` is re-exposed here (rather than redefined) so the plugin
|
|
442
|
-
* surface always stays in sync with the assistant's trust model.
|
|
443
|
-
*/
|
|
444
|
-
export interface TurnContext {
|
|
445
|
-
/** Stable ID for the current request (one per inbound message). */
|
|
446
|
-
requestId: string;
|
|
447
|
-
/** Conversation ID the turn is scoped to. */
|
|
448
|
-
conversationId: string;
|
|
449
|
-
/** 0-based turn index within the conversation. */
|
|
450
|
-
turnIndex: number;
|
|
451
|
-
/**
|
|
452
|
-
* When the pipeline runner is executing a specific plugin's middleware,
|
|
453
|
-
* this is set to that plugin's name so downstream code (error wrapping,
|
|
454
|
-
* telemetry) can attribute work accurately.
|
|
455
|
-
*/
|
|
456
|
-
pluginName?: string;
|
|
457
|
-
/** Trust classification and channel identity for the inbound actor. */
|
|
458
|
-
trust: TrustContext;
|
|
459
|
-
/**
|
|
460
|
-
* Optional handle to the conversation's {@link ContextWindowManager}.
|
|
461
|
-
*
|
|
462
|
-
* Attached by the orchestrator when building the per-turn context for
|
|
463
|
-
* pipeline invocations that need to defer to the real compaction machinery
|
|
464
|
-
* (notably the default `compaction` plugin). Pipelines that never touch
|
|
465
|
-
* compaction can ignore this field; the default compaction plugin throws
|
|
466
|
-
* a {@link PluginExecutionError} if it is missing, which keeps the failure
|
|
467
|
-
* attributed to the plugin rather than surfacing as a late NPE downstream.
|
|
468
|
-
*
|
|
469
|
-
* Declared as an optional typed field so plugin code can read it without a
|
|
470
|
-
* lenient cast. The optional shape is load-bearing: pipeline runner tests,
|
|
471
|
-
* synthesized handler contexts, and other non-compaction call sites still
|
|
472
|
-
* construct valid `TurnContext` literals without attaching a manager.
|
|
473
|
-
*/
|
|
474
|
-
contextWindowManager?: ContextWindowManager;
|
|
475
209
|
/**
|
|
476
|
-
*
|
|
210
|
+
* The {@link LLMCallSite} this turn belongs to — `"mainAgent"` for the
|
|
211
|
+
* user-facing conversational reply, or the specific background/utility site
|
|
212
|
+
* (`"compactionAgent"`, `"subagentSpawn"`, `"memoryConsolidation"`,
|
|
213
|
+
* `"conversationTitle"`, …) when the agent loop is driving non-main work
|
|
214
|
+
* that happens to share the same `conversationId`.
|
|
477
215
|
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
* a
|
|
482
|
-
|
|
483
|
-
injectionInputs?: TurnInjectionInputs;
|
|
484
|
-
/**
|
|
485
|
-
* The {@link LLMCallSite} this turn's pipeline work belongs to —
|
|
486
|
-
* `"mainAgent"` for the user-facing conversational reply, or the specific
|
|
487
|
-
* background/utility site (`"compactionAgent"`, `"subagentSpawn"`,
|
|
488
|
-
* `"memoryConsolidation"`, `"conversationTitle"`, …) when the agent loop is
|
|
489
|
-
* driving non-main work that happens to share the same `conversationId`.
|
|
490
|
-
*
|
|
491
|
-
* Lets {@link Injector}s and pipeline middleware scope their behaviour to
|
|
492
|
-
* the main reply and stay out of background turns, which `onEvent` presence
|
|
493
|
-
* alone cannot distinguish (compaction and subagent loops also stream).
|
|
494
|
-
* Omitted by call sites that don't tag a site (synthesized test contexts);
|
|
495
|
-
* consumers should treat absence conservatively.
|
|
216
|
+
* Lets {@link Injector}s scope their behaviour to the main reply and stay
|
|
217
|
+
* out of background turns, which `onEvent` presence alone cannot distinguish
|
|
218
|
+
* (compaction and subagent loops also stream). Omitted by call sites that
|
|
219
|
+
* don't tag a site (synthesized test contexts); consumers should treat
|
|
220
|
+
* absence conservatively.
|
|
496
221
|
*/
|
|
497
222
|
callSite?: LLMCallSite;
|
|
498
223
|
}
|
|
@@ -675,7 +400,7 @@ export type PluginHooks = Record<string, PluginHookFn<any>>;
|
|
|
675
400
|
|
|
676
401
|
/**
|
|
677
402
|
* A registered plugin. Every field besides `manifest` is optional — a plugin
|
|
678
|
-
* may contribute any combination of
|
|
403
|
+
* may contribute any combination of lifecycle hooks and model-visible
|
|
679
404
|
* capabilities. Lifecycle hooks live under `hooks`.
|
|
680
405
|
*/
|
|
681
406
|
export interface Plugin {
|
|
@@ -697,43 +422,13 @@ export interface Plugin {
|
|
|
697
422
|
routes?: PluginRouteRegistration[];
|
|
698
423
|
/** Skill registrations loaded at startup. */
|
|
699
424
|
skills?: PluginSkillRegistration[];
|
|
700
|
-
/**
|
|
701
|
-
* Named middleware slots. At most one middleware per slot per plugin.
|
|
702
|
-
* The registry composes multiple plugins' middleware for a slot in
|
|
703
|
-
* registration order (outermost first).
|
|
704
|
-
*/
|
|
705
|
-
middleware?: Partial<PipelineMiddlewareMap>;
|
|
706
425
|
}
|
|
707
426
|
|
|
708
427
|
// ─── Errors ──────────────────────────────────────────────────────────────────
|
|
709
428
|
|
|
710
|
-
/**
|
|
711
|
-
* Thrown by the pipeline runner when a plugin's middleware exceeds the
|
|
712
|
-
* pipeline's configured timeout. Carries the pipeline name, the offending
|
|
713
|
-
* plugin (if known), and the elapsed-milliseconds budget that was breached.
|
|
714
|
-
*/
|
|
715
|
-
export class PluginTimeoutError extends AssistantError {
|
|
716
|
-
constructor(
|
|
717
|
-
public readonly pipeline: PipelineName,
|
|
718
|
-
public readonly pluginName: string | undefined,
|
|
719
|
-
public readonly elapsedMs: number,
|
|
720
|
-
options?: { cause?: unknown },
|
|
721
|
-
) {
|
|
722
|
-
super(
|
|
723
|
-
`Plugin pipeline '${pipeline}' timed out after ${elapsedMs}ms${
|
|
724
|
-
pluginName ? ` (offending plugin: ${pluginName})` : ""
|
|
725
|
-
}`,
|
|
726
|
-
ErrorCode.INTERNAL_ERROR,
|
|
727
|
-
options,
|
|
728
|
-
);
|
|
729
|
-
this.name = "PluginTimeoutError";
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
|
|
733
429
|
/**
|
|
734
430
|
* Thrown by registry and bootstrap for plugin lifecycle errors — registration
|
|
735
|
-
* validation failures, API-version mismatches, init throw-outs.
|
|
736
|
-
* {@link PluginTimeoutError} so callers can discriminate.
|
|
431
|
+
* validation failures, API-version mismatches, init throw-outs.
|
|
737
432
|
*/
|
|
738
433
|
export class PluginExecutionError extends AssistantError {
|
|
739
434
|
constructor(
|