@vellumai/assistant 0.7.0 → 0.7.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/ARCHITECTURE.md +6 -7
- package/Dockerfile +1 -0
- package/README.md +2 -2
- package/__tests__/permissions/gateway-threshold-reader.test.ts +79 -139
- package/bun.lock +3 -0
- package/docs/architecture/security.md +18 -16
- package/knip.json +1 -0
- package/node_modules/@vellumai/skill-host-contracts/__tests__/client.test.ts +1 -5
- package/node_modules/@vellumai/skill-host-contracts/src/assistant-event.ts +0 -5
- package/node_modules/@vellumai/skill-host-contracts/src/client.ts +10 -16
- package/node_modules/@vellumai/skill-host-contracts/src/skill-host.ts +1 -9
- package/node_modules/@vellumai/skill-host-contracts/src/tool-types.ts +12 -12
- package/node_modules/@vellumai/slack-text/bun.lock +24 -0
- package/node_modules/@vellumai/slack-text/package.json +18 -0
- package/node_modules/@vellumai/slack-text/src/index.test.ts +153 -0
- package/node_modules/@vellumai/slack-text/src/index.ts +235 -0
- package/node_modules/@vellumai/slack-text/tsconfig.json +20 -0
- package/openapi.yaml +294 -107
- package/package.json +4 -2
- package/scripts/generate-openapi.ts +16 -111
- package/src/__tests__/agent-wake-override-profile.test.ts +23 -1
- package/src/__tests__/anthropic-provider.test.ts +56 -13
- package/src/__tests__/app-conversation-ids-backfill.test.ts +278 -0
- package/src/__tests__/app-conversation-ids.test.ts +151 -0
- package/src/__tests__/approval-cascade.test.ts +0 -15
- package/src/__tests__/approval-routes-http.test.ts +6 -17
- package/src/__tests__/assistant-event-hub.test.ts +126 -77
- package/src/__tests__/assistant-event.test.ts +0 -5
- package/src/__tests__/assistant-events-sse-hardening.test.ts +37 -15
- package/src/__tests__/assistant-feature-flags-integration.test.ts +0 -29
- package/src/__tests__/background-shell-host-bash.test.ts +34 -43
- package/src/__tests__/call-controller.test.ts +1 -1
- package/src/__tests__/call-site-routing-provider.test.ts +193 -0
- package/src/__tests__/channel-approval-routes.test.ts +10 -296
- package/src/__tests__/channel-approvals.test.ts +25 -17
- package/src/__tests__/channel-guardian.test.ts +100 -146
- package/src/__tests__/checker.test.ts +20 -34
- package/src/__tests__/compact-event-conversation-id-guard.test.ts +50 -0
- package/src/__tests__/compaction-events.test.ts +2 -0
- package/src/__tests__/config-schema.test.ts +6 -48
- package/src/__tests__/config-watcher.test.ts +12 -0
- package/src/__tests__/connection-policy.test.ts +1 -52
- package/src/__tests__/contacts-write.test.ts +2 -64
- package/src/__tests__/context-image-dimensions.test.ts +1 -1
- package/src/__tests__/context-search-memory-source.test.ts +120 -1
- package/src/__tests__/context-search-memory-v2-source.test.ts +383 -0
- package/src/__tests__/context-search-pkb-source.test.ts +49 -0
- package/src/__tests__/context-search-workspace-source.test.ts +9 -22
- package/src/__tests__/context-window-manager.test.ts +46 -0
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +2 -0
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +102 -29
- package/src/__tests__/conversation-agent-loop.test.ts +980 -13
- package/src/__tests__/conversation-analysis-routes.test.ts +12 -10
- package/src/__tests__/conversation-attention-telegram.test.ts +11 -3
- package/src/__tests__/conversation-confirmation-signals.test.ts +0 -291
- package/src/__tests__/conversation-history-web-search.test.ts +4 -3
- package/src/__tests__/conversation-inference-profile-route.test.ts +12 -23
- package/src/__tests__/conversation-lifecycle.test.ts +4 -4
- package/src/__tests__/conversation-process-callsite.test.ts +79 -2
- package/src/__tests__/conversation-queue.test.ts +3 -8
- package/src/__tests__/conversation-routes-disk-view.test.ts +1 -161
- package/src/__tests__/conversation-routes-guardian-reply.test.ts +0 -32
- package/src/__tests__/conversation-routes-slash-commands.test.ts +75 -66
- package/src/__tests__/conversation-runtime-assembly.test.ts +257 -3
- package/src/__tests__/conversation-slash-commands.test.ts +24 -4
- package/src/__tests__/conversation-slash-queue.test.ts +2 -0
- package/src/__tests__/conversation-speed-override.test.ts +0 -3
- package/src/__tests__/conversation-starter-routes.test.ts +79 -2
- package/src/__tests__/conversation-surfaces-standalone-payloads.test.ts +12 -5
- package/src/__tests__/conversation-surfaces-standalone.test.ts +18 -14
- package/src/__tests__/conversation-surfaces-state-update.test.ts +3 -2
- package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +8 -46
- package/src/__tests__/conversation-usage.test.ts +253 -3
- package/src/__tests__/credential-execution-shell-lockdown.test.ts +0 -39
- package/src/__tests__/credential-health-service.test.ts +68 -0
- package/src/__tests__/credential-security-e2e.test.ts +4 -3
- package/src/__tests__/credential-security-invariants.test.ts +1 -5
- package/src/__tests__/credential-token-resolver.test.ts +180 -0
- package/src/__tests__/cu-unified-flow.test.ts +33 -16
- package/src/__tests__/daemon-assistant-events.test.ts +34 -21
- package/src/__tests__/daemon-credential-client.test.ts +4 -1
- package/src/__tests__/db-connection-isolation.test.ts +125 -0
- package/src/__tests__/db-migration-rollback.test.ts +101 -0
- package/src/__tests__/db-slack-compaction-watermark-migration.test.ts +169 -0
- package/src/__tests__/deterministic-verification-control-plane.test.ts +7 -80
- package/src/__tests__/document-conversations.test.ts +332 -0
- package/src/__tests__/embedding-managed-proxy-selection.test.ts +2 -2
- package/src/__tests__/emit-event-signal.test.ts +4 -6
- package/src/__tests__/events-client-registration.test.ts +193 -49
- package/src/__tests__/filing-service.test.ts +58 -7
- package/src/__tests__/first-greeting.test.ts +156 -150
- package/src/__tests__/fixtures/mock-chrome-extension.ts +108 -66
- package/src/__tests__/get-skill-detail-audit.test.ts +3 -8
- package/src/__tests__/guardian-binding-drift-heal.test.ts +1 -1
- package/src/__tests__/guardian-dispatch.test.ts +1 -1
- package/src/__tests__/guardian-grant-minting.test.ts +7 -2
- package/src/__tests__/guardian-routing-invariants.test.ts +7 -2
- package/src/__tests__/guardian-routing-state.test.ts +1 -1
- package/src/__tests__/handlers-skills-memory-v2-reseed.test.ts +32 -11
- package/src/__tests__/handlers-user-message-approval-consumption.test.ts +2 -83
- package/src/__tests__/headless-browser-mode.test.ts +4 -9
- package/src/__tests__/headless-browser-navigate.test.ts +21 -20
- package/src/__tests__/heartbeat-service.test.ts +289 -7
- package/src/__tests__/helpers/channel-test-adapter.ts +2 -2
- package/src/__tests__/helpers/create-guardian-binding.ts +91 -0
- package/src/__tests__/host-bash-proxy.test.ts +46 -122
- package/src/__tests__/host-browser-e2e-cloud.test.ts +36 -497
- package/src/__tests__/host-browser-e2e-self-hosted-capability.test.ts +26 -96
- package/src/__tests__/host-browser-proxy.test.ts +111 -185
- package/src/__tests__/host-browser-routes.test.ts +45 -75
- package/src/__tests__/host-browser-ws-events-e2e.test.ts +26 -30
- package/src/__tests__/host-cu-proxy.test.ts +56 -111
- package/src/__tests__/host-file-proxy.test.ts +44 -98
- package/src/__tests__/host-file-read-tool.test.ts +42 -21
- package/src/__tests__/host-shell-tool.test.ts +33 -68
- package/src/__tests__/host-transfer-pending-interactions.test.ts +2 -18
- package/src/__tests__/host-transfer-proxy.test.ts +43 -53
- package/src/__tests__/http-user-message-parity.test.ts +0 -6
- package/src/__tests__/inbound-slack-persistence.test.ts +31 -0
- package/src/__tests__/injector-chain.test.ts +10 -5
- package/src/__tests__/injector-pkb-v2-silenced.test.ts +124 -0
- package/src/__tests__/inline-command-runner.test.ts +0 -66
- package/src/__tests__/inline-skill-load-permissions.test.ts +0 -2
- package/src/__tests__/install-skill-routing.test.ts +1 -13
- package/src/__tests__/llm-callsite-catalog.test.ts +34 -0
- package/src/__tests__/llm-catalog-parity.test.ts +90 -0
- package/src/__tests__/llm-context-resolution.test.ts +180 -0
- package/src/__tests__/llm-resolver.test.ts +80 -12
- package/src/__tests__/llm-usage-store.test.ts +269 -4
- package/src/__tests__/log-export-routes.test.ts +89 -0
- package/src/__tests__/managed-profile-guard.test.ts +225 -0
- package/src/__tests__/managed-skill-lifecycle.test.ts +0 -10
- package/src/__tests__/manual-token-reconciliation.test.ts +334 -0
- package/src/__tests__/memory-v2-static-injector.test.ts +95 -0
- package/src/__tests__/migration-cross-version-compatibility.test.ts +197 -291
- package/src/__tests__/migration-export-http.test.ts +33 -26
- package/src/__tests__/migration-export-streaming.test.ts +18 -10
- package/src/__tests__/migration-export-to-gcs.test.ts +49 -9
- package/src/__tests__/migration-import-commit-http.test.ts +66 -21
- package/src/__tests__/migration-import-from-gcs.test.ts +50 -9
- package/src/__tests__/migration-import-from-url.test.ts +20 -6
- package/src/__tests__/migration-import-preflight-http.test.ts +95 -95
- package/src/__tests__/migration-parity-persistence.test.ts +62 -25
- package/src/__tests__/migration-transport.test.ts +115 -23
- package/src/__tests__/migration-validate-http.test.ts +105 -80
- package/src/__tests__/migration-wizard.test.ts +133 -27
- package/src/__tests__/non-member-access-request.test.ts +1 -1
- package/src/__tests__/notification-guardian-path.test.ts +1 -1
- package/src/__tests__/oauth-store.test.ts +19 -0
- package/src/__tests__/platform-bash-auto-approve.test.ts +21 -12
- package/src/__tests__/prechat-onboarding-contract.test.ts +31 -7
- package/src/__tests__/pricing.test.ts +68 -4
- package/src/__tests__/process-message-background-slack.test.ts +331 -0
- package/src/__tests__/provider-managed-proxy-integration.test.ts +153 -17
- package/src/__tests__/provider-send-message-override-profile.test.ts +50 -0
- package/src/__tests__/provider-usage-tracking.test.ts +208 -0
- package/src/__tests__/reaction-persistence.test.ts +9 -6
- package/src/__tests__/rebind-secrets-screen.test.ts +53 -16
- package/src/__tests__/recording-handler.test.ts +64 -81
- package/src/__tests__/regenerate-fire-and-forget-trace.test.ts +4 -3
- package/src/__tests__/relay-server.test.ts +18 -13
- package/src/__tests__/require-fresh-approval.test.ts +13 -22
- package/src/__tests__/runtime-attachment-metadata.test.ts +1 -1
- package/src/__tests__/runtime-events-sse-parity.test.ts +3 -4
- package/src/__tests__/runtime-events-sse.test.ts +3 -12
- package/src/__tests__/search-skills-unified.test.ts +9 -15
- package/src/__tests__/secret-ingress-cli.test.ts +2 -5
- package/src/__tests__/secret-ingress-http.test.ts +0 -4
- package/src/__tests__/secret-onetime-send.test.ts +4 -2
- package/src/__tests__/secret-prompt-log-hygiene.test.ts +24 -7
- package/src/__tests__/secret-prompter-channel-fallback.test.ts +42 -47
- package/src/__tests__/secret-response-routing.test.ts +29 -15
- package/src/__tests__/secret-routes-managed-proxy.test.ts +5 -1
- package/src/__tests__/secret-scanner.test.ts +2 -545
- package/src/__tests__/send-endpoint-busy.test.ts +9 -24
- package/src/__tests__/settings-routes.test.ts +1 -1
- package/src/__tests__/shell-credential-ref.test.ts +0 -8
- package/src/__tests__/shell-tool-proxy-mode.test.ts +0 -56
- package/src/__tests__/skill-script-runner-sandbox.test.ts +0 -11
- package/src/__tests__/skill-tool-factory.test.ts +97 -0
- package/src/__tests__/skills-file-content-endpoint.test.ts +9 -30
- package/src/__tests__/skills-files-catalog-fallback.test.ts +11 -17
- package/src/__tests__/slack-inbound-verification.test.ts +1 -62
- package/src/__tests__/subagent-fork-notifications.test.ts +57 -47
- package/src/__tests__/subagent-manager-notify.test.ts +70 -70
- package/src/__tests__/subagent-notify-parent.test.ts +80 -83
- package/src/__tests__/system-prompt.test.ts +115 -13
- package/src/__tests__/terminal-tools.test.ts +0 -89
- package/src/__tests__/thread-backfill.test.ts +945 -31
- package/src/__tests__/tool-domain-event-publisher.test.ts +0 -36
- package/src/__tests__/tool-execute-pipeline.test.ts +0 -6
- package/src/__tests__/tool-execution-abort-cleanup.test.ts +0 -16
- package/src/__tests__/tool-execution-pipeline.benchmark.test.ts +9 -19
- package/src/__tests__/tool-executor-lifecycle-events.test.ts +4 -7
- package/src/__tests__/tool-executor.test.ts +12 -19
- package/src/__tests__/tool-metrics-listener.test.ts +0 -35
- package/src/__tests__/tool-side-effects-slack-dm.test.ts +1 -0
- package/src/__tests__/tool-trace-listener.test.ts +0 -17
- package/src/__tests__/transfer-progress-screen.test.ts +63 -26
- package/src/__tests__/trusted-contact-lifecycle-notifications.test.ts +2 -149
- package/src/__tests__/trusted-contact-multichannel.test.ts +2 -4
- package/src/__tests__/trusted-contact-verification.test.ts +1 -1
- package/src/__tests__/tts-catalog-parity.test.ts +16 -5
- package/src/__tests__/usage-attribution.test.ts +247 -0
- package/src/__tests__/usage-cli.test.ts +143 -0
- package/src/__tests__/usage-grouped-buckets.test.ts +155 -0
- package/src/__tests__/usage-routes.test.ts +150 -0
- package/src/__tests__/validation-results-screen.test.ts +39 -16
- package/src/__tests__/vbundle-pax-and-symlink.test.ts +12 -3
- package/src/__tests__/vellum-self-knowledge-inline-command.test.ts +49 -137
- package/src/__tests__/verification-control-plane-policy.test.ts +4 -7
- package/src/__tests__/voice-session-bridge.test.ts +5 -5
- package/src/__tests__/workspace-migration-062-drop-memory-v2-edges-json.test.ts +103 -0
- package/src/__tests__/workspace-migration-063-release-notes-dynamic-model-context.test.ts +77 -0
- package/src/__tests__/workspace-migration-064-unwind-main-agent-opus-seed.test.ts +225 -0
- package/src/__tests__/workspace-migration-memory-v2-init.test.ts +8 -30
- package/src/acp/index.ts +0 -15
- package/src/acp/session-manager.ts +37 -34
- package/src/agent/loop.ts +16 -1
- package/src/approvals/AGENTS.md +4 -0
- package/src/approvals/__tests__/guardian-feed-event.test.ts +10 -3
- package/src/approvals/guardian-request-resolvers.ts +10 -2
- package/src/backup/__tests__/backup-worker.test.ts +36 -8
- package/src/backup/__tests__/paths.test.ts +2 -2
- package/src/backup/__tests__/restore.test.ts +45 -28
- package/src/backup/backup-worker.ts +36 -2
- package/src/backup/paths.ts +9 -6
- package/src/browser-session/events.ts +0 -9
- package/src/calls/call-store.ts +1 -34
- package/src/calls/guardian-question-copy.ts +0 -108
- package/src/calls/relay-server.ts +0 -24
- package/src/calls/twilio-rest.ts +0 -38
- package/src/calls/twilio-routes.ts +1 -1
- package/src/calls/voice-session-bridge.ts +7 -38
- package/src/channels/types.ts +1 -36
- package/src/cli/commands/__tests__/cache.test.ts +152 -5
- package/src/cli/commands/__tests__/memory-v2.test.ts +14 -28
- package/src/cli/commands/__tests__/trust.test.ts +21 -387
- package/src/cli/commands/backup.ts +4 -4
- package/src/cli/commands/cache-fs.ts +8 -0
- package/src/cli/commands/cache.ts +153 -82
- package/src/cli/commands/clients.ts +63 -5
- package/src/cli/commands/completions.ts +3 -3
- package/src/cli/commands/contacts.ts +231 -76
- package/src/cli/commands/keys.ts +4 -1
- package/src/cli/commands/memory-v2.ts +24 -52
- package/src/cli/commands/oauth/shared.ts +2 -29
- package/src/cli/commands/pending.ts +102 -0
- package/src/cli/commands/skills.ts +77 -35
- package/src/cli/commands/trust.ts +70 -430
- package/src/cli/commands/usage.ts +25 -16
- package/src/cli/lib/daemon-credential-client.ts +14 -0
- package/src/cli/program.ts +2 -0
- package/src/cli.ts +0 -21
- package/src/config/__tests__/feature-flag-registry-guard.test.ts +2 -2
- package/src/config/bundled-skills/messaging/TOOLS.json +14 -4
- package/src/config/env-registry.ts +12 -2
- package/src/config/env.ts +3 -14
- package/src/config/feature-flag-registry.json +30 -30
- package/src/config/llm-callsite-catalog.ts +12 -0
- package/src/config/llm-context-resolution.ts +80 -0
- package/src/config/llm-resolver.ts +58 -22
- package/src/config/loader.ts +3 -3
- package/src/config/schema.ts +2 -158
- package/src/config/schemas/__tests__/memory-v2.test.ts +1 -0
- package/src/config/schemas/call-site-catalog.ts +271 -0
- package/src/config/schemas/calls.ts +5 -5
- package/src/config/schemas/inference.ts +1 -1
- package/src/config/schemas/ingress.ts +1 -1
- package/src/config/schemas/llm.ts +31 -3
- package/src/config/schemas/memory-retrieval.ts +2 -2
- package/src/config/schemas/memory-v2.ts +9 -0
- package/src/config/schemas/security.ts +1 -42
- package/src/config/schemas/services.ts +6 -6
- package/src/config/schemas/skills.ts +5 -5
- package/src/config/schemas/tts.ts +1 -1
- package/src/config/seed-inference-profiles.ts +117 -0
- package/src/config/skills.ts +0 -90
- package/src/config/types.ts +3 -6
- package/src/contacts/contact-store.ts +0 -17
- package/src/contacts/contacts-write.ts +1 -105
- package/src/context/window-manager.ts +44 -5
- package/src/credential-execution/process-manager.ts +34 -10
- package/src/credential-health/credential-health-service.ts +21 -16
- package/src/daemon/__tests__/conversation-surfaces-launch.test.ts +75 -82
- package/src/daemon/__tests__/daemon-skill-host.test.ts +2 -9
- package/src/daemon/connection-policy.ts +1 -26
- package/src/daemon/conversation-agent-loop-handlers.ts +53 -4
- package/src/daemon/conversation-agent-loop.ts +277 -36
- package/src/daemon/conversation-history.ts +8 -8
- package/src/daemon/conversation-launch.ts +20 -135
- package/src/daemon/conversation-lifecycle.ts +1 -1
- package/src/daemon/conversation-messaging.ts +1 -0
- package/src/daemon/conversation-process.ts +83 -163
- package/src/daemon/conversation-runtime-assembly.ts +219 -76
- package/src/daemon/conversation-slash.ts +47 -5
- package/src/daemon/conversation-store.ts +7 -31
- package/src/daemon/conversation-surfaces.ts +22 -28
- package/src/daemon/conversation-tool-setup.ts +3 -33
- package/src/daemon/conversation-usage.ts +36 -0
- package/src/daemon/conversation.ts +117 -233
- package/src/daemon/daemon-control.ts +3 -71
- package/src/daemon/daemon-skill-host.ts +8 -11
- package/src/daemon/dictation-profile-store.ts +2 -26
- package/src/daemon/first-greeting.ts +44 -156
- package/src/daemon/handlers/config-channels.ts +12 -12
- package/src/daemon/handlers/config-ingress.ts +4 -165
- package/src/daemon/handlers/config-model.ts +1 -1
- package/src/daemon/handlers/config-voice.ts +0 -42
- package/src/daemon/handlers/conversations.ts +11 -190
- package/src/daemon/handlers/recording.ts +26 -158
- package/src/daemon/handlers/shared.ts +23 -71
- package/src/daemon/handlers/skills.ts +42 -93
- package/src/daemon/host-bash-proxy.ts +67 -45
- package/src/daemon/host-browser-proxy.ts +65 -27
- package/src/daemon/host-cu-proxy.ts +40 -39
- package/src/daemon/host-file-proxy.ts +58 -37
- package/src/daemon/host-transfer-proxy.ts +84 -46
- package/src/daemon/lifecycle.ts +49 -15
- package/src/daemon/message-types/conversations.ts +7 -0
- package/src/daemon/message-types/host-bash.ts +1 -0
- package/src/daemon/message-types/host-cu.ts +1 -0
- package/src/daemon/message-types/host-file.ts +1 -0
- package/src/daemon/message-types/host-transfer.ts +1 -0
- package/src/daemon/message-types/messages.ts +10 -9
- package/src/daemon/message-types/workspace.ts +1 -1
- package/src/daemon/process-message.ts +102 -239
- package/src/daemon/server.ts +13 -462
- package/src/daemon/shutdown-handlers.ts +2 -2
- package/src/daemon/tool-side-effects.ts +125 -107
- package/src/daemon/trust-context.ts +13 -0
- package/src/daemon/wake-target-adapter.ts +4 -9
- package/src/events/domain-events.ts +0 -8
- package/src/events/tool-audit-listener.ts +3 -1
- package/src/events/tool-domain-event-publisher.ts +0 -10
- package/src/events/tool-metrics-listener.ts +0 -17
- package/src/events/tool-trace-listener.ts +0 -14
- package/src/filing/filing-service.ts +13 -1
- package/src/heartbeat/__tests__/heartbeat-feed-event.test.ts +6 -2
- package/src/heartbeat/heartbeat-service.ts +23 -5
- package/src/home/__tests__/feed-writer.test.ts +0 -4
- package/src/home/__tests__/relationship-state-writer.test.ts +30 -0
- package/src/home/feed-writer.ts +1 -2
- package/src/home/relationship-state-writer.ts +16 -3
- package/src/ipc/__tests__/browser-ipc.test.ts +2 -12
- package/src/ipc/__tests__/skill-server-bidirectional.test.ts +0 -1
- package/src/ipc/assistant-server.ts +3 -10
- package/src/ipc/routes/__tests__/memory-v2-backfill.test.ts +39 -20
- package/src/ipc/routes/route-adapter.ts +1 -1
- package/src/ipc/routes/trust-rules.test.ts +0 -95
- package/src/ipc/skill-ipc-types.ts +41 -0
- package/src/ipc/skill-routes/__tests__/events-ipc.test.ts +13 -27
- package/src/ipc/skill-routes/__tests__/identity.test.ts +4 -23
- package/src/ipc/skill-routes/events.ts +12 -23
- package/src/ipc/skill-routes/identity.ts +4 -17
- package/src/ipc/skill-routes/index.ts +1 -1
- package/src/ipc/skill-server.ts +6 -39
- package/src/live-voice/__tests__/runtime-websocket-shell.test.ts +0 -8
- package/src/live-voice/protocol.ts +4 -13
- package/src/mcp/manager.ts +0 -5
- package/src/memory/__tests__/fixtures/memory-v2-activation-fixtures.ts +55 -0
- package/src/memory/__tests__/memory-v2-activation-log-store.test.ts +127 -0
- package/src/memory/app-git-service.ts +0 -32
- package/src/memory/app-store.ts +154 -0
- package/src/memory/attachments-store.ts +6 -0
- package/src/memory/context-search/sources/memory-v2.ts +578 -0
- package/src/memory/context-search/sources/memory.ts +5 -0
- package/src/memory/context-search/sources/pkb.ts +10 -1
- package/src/memory/context-search/sources/workspace.ts +3 -2
- package/src/memory/conversation-crud.ts +29 -4
- package/src/memory/conversation-disk-view.ts +1 -5
- package/src/memory/conversation-starter-checkpoints.ts +63 -0
- package/src/memory/db-connection.ts +62 -0
- package/src/memory/db-init.ts +14 -0
- package/src/memory/embedding-backend.ts +3 -21
- package/src/memory/embedding-gemini.ts +0 -2
- package/src/memory/embedding-local.ts +6 -6
- package/src/memory/embedding-ollama.ts +6 -6
- package/src/memory/embedding-openai.ts +6 -6
- package/src/memory/embedding-types.ts +21 -0
- package/src/memory/graph/__tests__/conversation-graph-memory-v2-routing.test.ts +3 -7
- package/src/memory/graph/conversation-graph-memory.ts +35 -13
- package/src/memory/graph/injection.test.ts +2 -2
- package/src/memory/graph/injection.ts +1 -1
- package/src/memory/guardian-action-store.ts +0 -83
- package/src/memory/guardian-approvals.ts +0 -48
- package/src/memory/indexer.ts +1 -15
- package/src/memory/job-handlers/conversation-starters.ts +36 -53
- package/src/memory/job-utils.ts +0 -6
- package/src/memory/jobs-store.ts +0 -1
- package/src/memory/jobs-worker.ts +2 -16
- package/src/memory/llm-request-log-store.ts +0 -41
- package/src/memory/llm-usage-store.ts +129 -43
- package/src/memory/memory-v2-activation-log-store.ts +115 -0
- package/src/memory/migrations/233-document-conversations.ts +54 -0
- package/src/memory/migrations/234-memory-v2-activation-logs.ts +55 -0
- package/src/memory/migrations/235-llm-usage-attribution.ts +31 -0
- package/src/memory/migrations/235-slack-compaction-watermark.ts +44 -0
- package/src/memory/migrations/236-tool-invocations-matched-rule-id.ts +26 -0
- package/src/memory/migrations/__tests__/234-memory-v2-activation-logs.test.ts +182 -0
- package/src/memory/migrations/index.ts +14 -0
- package/src/memory/migrations/registry.ts +24 -0
- package/src/memory/raw-query.ts +2 -68
- package/src/memory/schema/conversations.ts +7 -0
- package/src/memory/schema/infrastructure.ts +25 -0
- package/src/memory/search/semantic.ts +5 -16
- package/src/memory/tool-usage-store.ts +2 -0
- package/src/memory/usage-buckets.ts +40 -1
- package/src/memory/usage-grouped-buckets.ts +127 -0
- package/src/memory/v2/__tests__/activation.test.ts +289 -90
- package/src/memory/v2/__tests__/backfill-jobs.test.ts +2 -129
- package/src/memory/v2/__tests__/consolidation-job.test.ts +28 -11
- package/src/memory/v2/__tests__/edge-index.test.ts +278 -0
- package/src/memory/v2/__tests__/injection.test.ts +384 -15
- package/src/memory/v2/__tests__/migration.test.ts +64 -36
- package/src/memory/v2/__tests__/page-store.test.ts +191 -8
- package/src/memory/v2/__tests__/prompts-consolidation.test.ts +181 -0
- package/src/memory/v2/__tests__/skill-store.test.ts +115 -3
- package/src/memory/v2/__tests__/static-context.test.ts +153 -0
- package/src/memory/v2/activation.ts +168 -97
- package/src/memory/v2/backfill-jobs.ts +15 -100
- package/src/memory/v2/consolidation-job.ts +14 -12
- package/src/memory/v2/edge-index.ts +191 -0
- package/src/memory/v2/injection.ts +182 -58
- package/src/memory/v2/migration.ts +57 -64
- package/src/memory/v2/now-text.ts +2 -3
- package/src/memory/v2/page-store.ts +168 -31
- package/src/memory/v2/prompts/consolidation.ts +118 -42
- package/src/memory/v2/prompts/sweep.ts +3 -3
- package/src/memory/v2/skill-store.ts +55 -7
- package/src/memory/v2/static-context.ts +62 -0
- package/src/memory/v2/types.ts +10 -20
- package/src/memory/validation.ts +0 -11
- package/src/messaging/draft-store.ts +0 -6
- package/src/messaging/provider-types.ts +8 -0
- package/src/messaging/provider.ts +7 -0
- package/src/messaging/providers/gmail/client.ts +1 -121
- package/src/messaging/providers/outlook/client.ts +0 -73
- package/src/messaging/providers/slack/__tests__/adapter-mention-rendering.test.ts +226 -0
- package/src/messaging/providers/slack/adapter.ts +122 -21
- package/src/messaging/providers/slack/backfill.test.ts +95 -6
- package/src/messaging/providers/slack/backfill.ts +89 -11
- package/src/messaging/providers/slack/client.ts +10 -124
- package/src/messaging/providers/slack/message-metadata.ts +12 -2
- package/src/messaging/providers/slack/render-transcript.test.ts +56 -0
- package/src/messaging/providers/slack/render-transcript.ts +126 -25
- package/src/messaging/providers/slack/types.ts +1 -0
- package/src/oauth/connection-resolver.test.ts +8 -0
- package/src/oauth/connection-resolver.ts +8 -16
- package/src/oauth/credential-token-resolver.ts +97 -0
- package/src/oauth/manual-token-connection.ts +30 -34
- package/src/oauth/oauth-store.ts +6 -4
- package/src/outbound-proxy/certs.ts +0 -7
- package/src/outbound-proxy/config.ts +0 -74
- package/src/outbound-proxy/health.ts +0 -44
- package/src/outbound-proxy/index.ts +0 -22
- package/src/permissions/approval-provenance.test.ts +184 -0
- package/src/permissions/approval-provenance.ts +70 -0
- package/src/permissions/checker.ts +4 -1
- package/src/permissions/gateway-threshold-reader.ts +4 -1
- package/src/permissions/prompter.ts +9 -2
- package/src/permissions/secret-prompter.ts +21 -48
- package/src/permissions/types.ts +33 -0
- package/src/permissions/workspace-policy.ts +0 -5
- package/src/platform/sync-identity.ts +0 -8
- package/src/plugins/defaults/injectors.ts +69 -2
- package/src/plugins/defaults/overflow-reduce.ts +3 -2
- package/src/plugins/types.ts +8 -0
- package/src/prompts/system-prompt.ts +34 -70
- package/src/prompts/templates/BOOTSTRAP.md +52 -6
- package/src/prompts/update-bulletin-job.ts +2 -0
- package/src/providers/__tests__/retry-callsite.test.ts +138 -1
- package/src/providers/anthropic/client.ts +72 -33
- package/src/providers/call-site-routing.ts +42 -3
- package/src/providers/gemini/client.ts +18 -2
- package/src/providers/managed-proxy/context.ts +0 -5
- package/src/providers/model-catalog.ts +105 -19
- package/src/providers/openai/chat-completions-provider.ts +6 -0
- package/src/providers/openai/responses-provider.ts +7 -1
- package/src/providers/provider-send-message.ts +45 -2
- package/src/providers/ratelimit.ts +7 -2
- package/src/providers/registry.ts +14 -9
- package/src/providers/retry.ts +96 -8
- package/src/providers/types.ts +13 -0
- package/src/providers/usage-tracking.ts +96 -0
- package/src/runtime/AGENTS.md +10 -6
- package/src/runtime/__tests__/agent-wake.test.ts +89 -0
- package/src/runtime/agent-wake.ts +39 -2
- package/src/runtime/assistant-event-hub.ts +541 -45
- package/src/runtime/assistant-event.ts +1 -6
- package/src/runtime/auth/context.ts +0 -9
- package/src/runtime/auth/middleware.ts +1 -1
- package/src/runtime/auth/route-policy.ts +11 -9
- package/src/runtime/auth/token-service.ts +0 -11
- package/src/runtime/channel-approvals.ts +6 -2
- package/src/runtime/channel-verification-service.ts +3 -5
- package/src/runtime/http-errors.ts +0 -34
- package/src/runtime/http-router.ts +6 -3
- package/src/runtime/http-server.ts +22 -82
- package/src/runtime/http-types.ts +5 -0
- package/src/runtime/interactive-ui.ts +0 -1
- package/src/runtime/middleware/auth.ts +0 -20
- package/src/runtime/migrations/__tests__/v1-test-helpers.ts +112 -0
- package/src/runtime/migrations/__tests__/vbundle-builder-credentials.test.ts +11 -4
- package/src/runtime/migrations/__tests__/vbundle-builder-v1-shape.test.ts +253 -0
- package/src/runtime/migrations/__tests__/vbundle-import-credentials.test.ts +19 -6
- package/src/runtime/migrations/__tests__/vbundle-legacy-user-md.test.ts +71 -27
- package/src/runtime/migrations/__tests__/vbundle-metadata-merge-integration.test.ts +41 -2
- package/src/runtime/migrations/__tests__/vbundle-streaming-importer.test.ts +143 -79
- package/src/runtime/migrations/__tests__/vbundle-streaming-validator.test.ts +143 -23
- package/src/runtime/migrations/__tests__/vbundle-tar-stream.test.ts +2 -2
- package/src/runtime/migrations/__tests__/vbundle-validator-v1-schema.test.ts +371 -0
- package/src/runtime/migrations/migration-transport.ts +46 -13
- package/src/runtime/migrations/migration-wizard.ts +2 -2
- package/src/runtime/migrations/origin-mode.ts +40 -0
- package/src/runtime/migrations/vbundle-builder.ts +133 -79
- package/src/runtime/migrations/vbundle-import-analyzer.ts +9 -7
- package/src/runtime/migrations/vbundle-importer.ts +7 -7
- package/src/runtime/migrations/vbundle-metadata-merge.ts +1 -1
- package/src/runtime/migrations/vbundle-streaming-importer.ts +3 -3
- package/src/runtime/migrations/vbundle-streaming-validator.ts +48 -26
- package/src/runtime/migrations/vbundle-validator.ts +214 -41
- package/src/runtime/pending-interactions.ts +13 -4
- package/src/runtime/routes/__tests__/acp-routes.test.ts +0 -1
- package/src/runtime/routes/__tests__/backup-routes.test.ts +28 -19
- package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +235 -0
- package/src/runtime/routes/__tests__/llm-call-sites-routes.test.ts +58 -0
- package/src/runtime/routes/__tests__/migration-export-secrets-redacted.test.ts +54 -0
- package/src/runtime/routes/__tests__/migration-import-credential-filter.test.ts +19 -6
- package/src/runtime/routes/__tests__/user-route-dispatcher.test.ts +7 -7
- package/src/runtime/routes/acp-routes.test.ts +0 -3
- package/src/runtime/routes/acp-routes.ts +3 -7
- package/src/runtime/routes/app-management-routes.ts +18 -9
- package/src/runtime/routes/approval-routes.ts +55 -14
- package/src/runtime/routes/avatar-routes.ts +3 -5
- package/src/runtime/routes/browser-routes.ts +1 -15
- package/src/runtime/routes/channel-guardian-routes.ts +1 -5
- package/src/runtime/routes/channel-readiness-routes.ts +3 -7
- package/src/runtime/routes/channel-route-shared.ts +2 -28
- package/src/runtime/routes/client-routes.ts +45 -12
- package/src/runtime/routes/consolidation-routes.ts +115 -0
- package/src/runtime/routes/conversation-list-routes.ts +12 -29
- package/src/runtime/routes/conversation-management-routes.ts +14 -51
- package/src/runtime/routes/conversation-query-routes.ts +120 -8
- package/src/runtime/routes/conversation-routes.ts +44 -528
- package/src/runtime/routes/conversation-starter-routes.ts +19 -40
- package/src/runtime/routes/documents-routes.ts +53 -18
- package/src/runtime/routes/events-routes.ts +59 -91
- package/src/runtime/routes/filing-routes.ts +18 -1
- package/src/runtime/routes/guardian-action-routes.ts +4 -9
- package/src/runtime/routes/host-bash-routes.ts +3 -2
- package/src/runtime/routes/host-browser-routes.ts +9 -33
- package/src/runtime/routes/host-cu-routes.ts +6 -1
- package/src/runtime/routes/host-file-routes.ts +3 -2
- package/src/runtime/routes/host-transfer-routes.ts +11 -15
- package/src/runtime/routes/identity-routes.ts +78 -6
- package/src/runtime/routes/inbound-message-handler.ts +580 -137
- package/src/runtime/routes/inbound-stages/acl-enforcement.ts +2 -88
- package/src/runtime/routes/inbound-stages/background-dispatch.ts +3 -0
- package/src/runtime/routes/index.ts +4 -0
- package/src/runtime/routes/integrations/slack/channel.ts +0 -24
- package/src/runtime/routes/llm-call-sites-routes.ts +22 -0
- package/src/runtime/routes/memory-v2-routes.ts +10 -15
- package/src/runtime/routes/migration-routes.ts +188 -31
- package/src/runtime/routes/playground/guard.ts +1 -1
- package/src/runtime/routes/playground/index.ts +0 -2
- package/src/runtime/routes/recording-routes.ts +4 -24
- package/src/runtime/routes/rename-conversation-routes.ts +2 -6
- package/src/runtime/routes/schedule-routes.ts +3 -6
- package/src/runtime/routes/secret-routes.ts +87 -18
- package/src/runtime/routes/settings-routes.ts +29 -28
- package/src/runtime/routes/skills-routes.ts +12 -31
- package/src/runtime/routes/suggest-trust-rule-routes.ts +32 -1
- package/src/runtime/routes/task-routes.ts +6 -6
- package/src/runtime/routes/trust-rules-routes.ts +3 -94
- package/src/runtime/routes/types.ts +4 -4
- package/src/runtime/routes/upgrade-broadcast-routes.ts +3 -10
- package/src/runtime/routes/usage-routes.ts +87 -10
- package/src/runtime/routes/user-routes.ts +17 -31
- package/src/runtime/routes/work-items-routes.ts +1 -4
- package/src/runtime/services/__tests__/analyze-conversation.test.ts +2 -2
- package/src/runtime/services/analyze-conversation.ts +7 -17
- package/src/runtime/services/conversation-serializer.ts +2 -4
- package/src/runtime/verification-outbound-actions.ts +1 -1
- package/src/runtime/verification-rate-limiter.ts +1 -1
- package/src/schedule/schedule-store.ts +0 -16
- package/src/security/secret-scanner.ts +14 -547
- package/src/security/secure-keys.ts +31 -11
- package/src/security/token-manager.ts +7 -3
- package/src/signals/cancel.ts +16 -25
- package/src/signals/conversation-undo.ts +2 -27
- package/src/signals/emit-event.ts +1 -2
- package/src/signals/user-message.ts +108 -22
- package/src/skills/catalog-install.ts +1 -0
- package/src/skills/clawhub.ts +2 -2
- package/src/skills/inline-command-runner.ts +1 -7
- package/src/subagent/manager.ts +67 -84
- package/src/tasks/task-store.ts +1 -28
- package/src/telemetry/types.ts +6 -0
- package/src/telemetry/usage-telemetry-reporter.test.ts +38 -15
- package/src/telemetry/usage-telemetry-reporter.ts +3 -5
- package/src/tools/acp/spawn.test.ts +1 -2
- package/src/tools/acp/steer.test.ts +1 -2
- package/src/tools/browser/__tests__/browser-status.test.ts +44 -127
- package/src/tools/browser/browser-execution.ts +31 -147
- package/src/tools/browser/cdp-client/__tests__/factory.test.ts +92 -68
- package/src/tools/browser/cdp-client/factory.ts +48 -76
- package/src/tools/browser/cdp-client/index.ts +1 -14
- package/src/tools/executor.ts +44 -31
- package/src/tools/host-filesystem/edit.ts +3 -2
- package/src/tools/host-filesystem/read.ts +3 -2
- package/src/tools/host-filesystem/transfer.test.ts +45 -42
- package/src/tools/host-filesystem/transfer.ts +4 -3
- package/src/tools/host-filesystem/write.ts +3 -2
- package/src/tools/host-terminal/host-shell.ts +4 -3
- package/src/tools/network/script-proxy/index.ts +1 -10
- package/src/tools/permission-checker.ts +66 -1
- package/src/tools/skills/sandbox-runner.ts +1 -6
- package/src/tools/skills/skill-tool-factory.ts +32 -0
- package/src/tools/terminal/safe-env.ts +1 -0
- package/src/tools/terminal/shell.ts +2 -78
- package/src/tools/types.ts +12 -39
- package/src/tts/__tests__/provider-catalog.test.ts +2 -2
- package/src/tts/provider-catalog.ts +1 -1
- package/src/usage/actors.ts +2 -1
- package/src/usage/attribution.ts +185 -0
- package/src/usage/pricing.ts +166 -0
- package/src/usage/types.ts +14 -0
- package/src/util/json.ts +13 -0
- package/src/util/logger.ts +3 -3
- package/src/util/pricing.ts +50 -3
- package/src/work-items/work-item-runner.ts +15 -42
- package/src/workspace/migrations/050-seed-main-agent-opus-callsite.ts +4 -3
- package/src/workspace/migrations/052-seed-default-inference-profiles.ts +3 -3
- package/src/workspace/migrations/060-memory-v2-init.ts +2 -18
- package/src/workspace/migrations/061-move-backup-key-to-workspace.ts +59 -0
- package/src/workspace/migrations/062-drop-memory-v2-edges-json.ts +27 -0
- package/src/workspace/migrations/063-release-notes-dynamic-model-context.ts +70 -0
- package/src/workspace/migrations/064-unwind-main-agent-opus-seed.ts +64 -0
- package/src/workspace/migrations/registry.ts +8 -0
- package/src/workspace/provider-commit-message-generator.ts +3 -3
- package/src/__tests__/sandbox-diagnostics.test.ts +0 -138
- package/src/__tests__/sandbox-host-parity.test.ts +0 -1024
- package/src/__tests__/secret-detection-handler.test.ts +0 -67
- package/src/__tests__/secret-scanner-executor.test.ts +0 -450
- package/src/__tests__/tcc-sandbox-deny.test.ts +0 -198
- package/src/__tests__/terminal-sandbox.test.ts +0 -374
- package/src/__tests__/tool-notification-listener.test.ts +0 -65
- package/src/context/__tests__/microcompact.test.ts +0 -805
- package/src/context/microcompact.ts +0 -443
- package/src/daemon/handlers/slack-channel-oauth-install.ts +0 -197
- package/src/events/tool-notification-listener.ts +0 -17
- package/src/ipc/routes/__tests__/memory-v2-validate.test.ts +0 -219
- package/src/memory/v2/__tests__/edges.test.ts +0 -435
- package/src/memory/v2/edges.ts +0 -217
- package/src/prompts/__tests__/system-prompt-memory-v2.test.ts +0 -197
- package/src/runtime/__tests__/chrome-extension-registry.test.ts +0 -518
- package/src/runtime/__tests__/client-registry.test.ts +0 -271
- package/src/runtime/chrome-extension-registry.ts +0 -368
- package/src/runtime/client-registry.ts +0 -254
- package/src/runtime/routes/inbound-stages/verification-intercept.ts +0 -329
- package/src/tools/secret-detection-handler.ts +0 -269
- package/src/tools/terminal/backends/native.ts +0 -327
- package/src/tools/terminal/backends/types.ts +0 -37
- package/src/tools/terminal/sandbox-diagnostics.ts +0 -87
- package/src/tools/terminal/sandbox.ts +0 -40
|
@@ -9,6 +9,7 @@ import { existsSync, readFileSync, statSync } from "node:fs";
|
|
|
9
9
|
import { join, resolve } from "node:path";
|
|
10
10
|
|
|
11
11
|
import { type ChannelId, parseInterfaceId } from "../channels/types.js";
|
|
12
|
+
import { createContextSummaryMessage } from "../context/window-manager.js";
|
|
12
13
|
import { getAppDirPath, listAppFiles } from "../memory/app-store.js";
|
|
13
14
|
import {
|
|
14
15
|
getMessages as defaultGetMessages,
|
|
@@ -21,10 +22,14 @@ import {
|
|
|
21
22
|
import type { QdrantSparseVector } from "../memory/qdrant-client.js";
|
|
22
23
|
import { readSlackMetadata } from "../messaging/providers/slack/message-metadata.js";
|
|
23
24
|
import {
|
|
25
|
+
compareSlackTs,
|
|
24
26
|
extractTagLineTexts,
|
|
25
27
|
isReactionTagLine,
|
|
28
|
+
isSlackTsAfter,
|
|
26
29
|
type RenderableSlackMessage,
|
|
30
|
+
type RenderedSlackTranscriptMessage,
|
|
27
31
|
renderSlackTranscript,
|
|
32
|
+
renderSlackTranscriptWithProvenance,
|
|
28
33
|
} from "../messaging/providers/slack/render-transcript.js";
|
|
29
34
|
import { getInjectors } from "../plugins/registry.js";
|
|
30
35
|
import type {
|
|
@@ -499,11 +504,6 @@ function injectVoiceCallControlContext(
|
|
|
499
504
|
};
|
|
500
505
|
}
|
|
501
506
|
|
|
502
|
-
/** Strip `<voice_call_control>` blocks injected by `injectVoiceCallControlContext`. */
|
|
503
|
-
export function stripVoiceCallControlContext(messages: Message[]): Message[] {
|
|
504
|
-
return stripUserTextBlocksByPrefix(messages, ["<voice_call_control>"]);
|
|
505
|
-
}
|
|
506
|
-
|
|
507
507
|
// ---------------------------------------------------------------------------
|
|
508
508
|
// NOW.md scratchpad injection
|
|
509
509
|
// ---------------------------------------------------------------------------
|
|
@@ -637,19 +637,6 @@ export function readPkbContext(): string | null {
|
|
|
637
637
|
return parts.length > 0 ? parts.join("\n\n") : null;
|
|
638
638
|
}
|
|
639
639
|
|
|
640
|
-
// The `<knowledge_base>` block is emitted by the `pkb-context` default
|
|
641
|
-
// injector (`plugins/defaults/injectors.ts`) as an `after-memory-prefix`
|
|
642
|
-
// placement, splicing immediately after any leading memory-prefix blocks.
|
|
643
|
-
// Use {@link applyRuntimeInjections} with `options.pkbContext` set.
|
|
644
|
-
|
|
645
|
-
/** Strip `<knowledge_base>` blocks injected by `injectPkbContext`. */
|
|
646
|
-
export function stripPkbContext(messages: Message[]): Message[] {
|
|
647
|
-
return stripUserTextBlocksByPrefix(messages, [
|
|
648
|
-
"<knowledge_base>",
|
|
649
|
-
"<pkb>", // backward-compat: strip legacy blocks from pre-rename history
|
|
650
|
-
]);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
640
|
/**
|
|
654
641
|
* Prepend channel capability context to the last user message so the
|
|
655
642
|
* model knows what the current channel can and cannot do.
|
|
@@ -1010,31 +997,6 @@ export function stripChannelCapabilityContext(messages: Message[]): Message[] {
|
|
|
1010
997
|
return stripUserTextBlocksByPrefix(messages, ["<channel_capabilities>"]);
|
|
1011
998
|
}
|
|
1012
999
|
|
|
1013
|
-
// The workspace top-level context block is emitted by the
|
|
1014
|
-
// `workspace-context` default injector (`plugins/defaults/injectors.ts`)
|
|
1015
|
-
// as a `prepend-user-tail` placement. Use {@link applyRuntimeInjections}
|
|
1016
|
-
// with `options.workspaceTopLevelContext` set.
|
|
1017
|
-
|
|
1018
|
-
/**
|
|
1019
|
-
* Strip `<active_workspace>` (and legacy `<active_dynamic_page>`) blocks
|
|
1020
|
-
* injected by `injectActiveSurfaceContext`.
|
|
1021
|
-
*/
|
|
1022
|
-
export function stripActiveSurfaceContext(messages: Message[]): Message[] {
|
|
1023
|
-
return stripUserTextBlocksByPrefix(messages, [
|
|
1024
|
-
"<active_workspace>",
|
|
1025
|
-
"<active_dynamic_page>",
|
|
1026
|
-
]);
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
// ---------------------------------------------------------------------------
|
|
1030
|
-
// Declarative strip pipeline
|
|
1031
|
-
// ---------------------------------------------------------------------------
|
|
1032
|
-
|
|
1033
|
-
/** Strip `<channel_command_context>` blocks injected by `injectChannelCommandContext`. */
|
|
1034
|
-
export function stripChannelCommandContext(messages: Message[]): Message[] {
|
|
1035
|
-
return stripUserTextBlocksByPrefix(messages, ["<channel_command_context>"]);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
1000
|
// ---------------------------------------------------------------------------
|
|
1039
1001
|
// Transport hints injection (e.g. Slack thread context from the gateway)
|
|
1040
1002
|
// ---------------------------------------------------------------------------
|
|
@@ -1047,9 +1009,15 @@ function injectTransportHints(message: Message, hints: string[]): Message {
|
|
|
1047
1009
|
};
|
|
1048
1010
|
}
|
|
1049
1011
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1012
|
+
function injectSlackRuntimeContextNotice(
|
|
1013
|
+
message: Message,
|
|
1014
|
+
notice: string,
|
|
1015
|
+
): Message {
|
|
1016
|
+
const block = `<slack_context_notice>\n${notice}\n</slack_context_notice>`;
|
|
1017
|
+
return {
|
|
1018
|
+
...message,
|
|
1019
|
+
content: [{ type: "text", text: block }, ...message.content],
|
|
1020
|
+
};
|
|
1053
1021
|
}
|
|
1054
1022
|
|
|
1055
1023
|
// ---------------------------------------------------------------------------
|
|
@@ -1097,6 +1065,29 @@ export interface SlackTranscriptInputRow {
|
|
|
1097
1065
|
metadata: string | null;
|
|
1098
1066
|
}
|
|
1099
1067
|
|
|
1068
|
+
export interface SlackChronologicalContext {
|
|
1069
|
+
readonly renderedMessages: readonly RenderedSlackTranscriptMessage[];
|
|
1070
|
+
/** Convenience projection of `renderedMessages[].message`. */
|
|
1071
|
+
readonly messages: Message[];
|
|
1072
|
+
readonly compactableStartIndex: number;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
interface SlackBoundaryOptions {
|
|
1076
|
+
readonly contextCompactedMessageCount?: number;
|
|
1077
|
+
readonly slackContextCompactionWatermarkTs?: string | null;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
function messageRowsToSlackTranscriptRows(
|
|
1081
|
+
rows: MessageRow[],
|
|
1082
|
+
): SlackTranscriptInputRow[] {
|
|
1083
|
+
return rows.map((row) => ({
|
|
1084
|
+
role: row.role === "assistant" ? "assistant" : "user",
|
|
1085
|
+
content: row.content,
|
|
1086
|
+
createdAt: row.createdAt,
|
|
1087
|
+
metadata: row.metadata,
|
|
1088
|
+
}));
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1100
1091
|
/**
|
|
1101
1092
|
* Extract the user-facing plain text from an already-parsed `ContentBlock[]`.
|
|
1102
1093
|
* Only `text` blocks contribute to the rendered transcript line. Tool-use /
|
|
@@ -1242,9 +1233,10 @@ function rowToRenderable(row: SlackTranscriptInputRow): RenderableSlackMessage {
|
|
|
1242
1233
|
}
|
|
1243
1234
|
|
|
1244
1235
|
/**
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1236
|
+
* Compatibility projection for callers that still need the legacy
|
|
1237
|
+
* `Message[] | null` shape. New runtime callers should use
|
|
1238
|
+
* `assembleSlackChronologicalContext` so compaction provenance stays
|
|
1239
|
+
* available with the rendered messages.
|
|
1248
1240
|
*
|
|
1249
1241
|
* Returns `null` when the channel is not Slack (caller should fall through
|
|
1250
1242
|
* to the default message history). Legacy pre-upgrade rows without
|
|
@@ -1259,20 +1251,110 @@ export function assembleSlackChronologicalMessages(
|
|
|
1259
1251
|
rows: SlackTranscriptInputRow[],
|
|
1260
1252
|
capabilities: ChannelCapabilities,
|
|
1261
1253
|
): Message[] | null {
|
|
1254
|
+
return (
|
|
1255
|
+
assembleSlackChronologicalContext(rows, capabilities)?.messages ?? null
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
function maxSlackTs(values: readonly (string | null)[]): string | null {
|
|
1260
|
+
let max: string | null = null;
|
|
1261
|
+
for (const value of values) {
|
|
1262
|
+
if (value === null) continue;
|
|
1263
|
+
if (max === null || compareSlackTs(value, max) > 0) {
|
|
1264
|
+
max = value;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
return max;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
function legacyRowIsAfterWatermark(
|
|
1271
|
+
row: SlackTranscriptInputRow,
|
|
1272
|
+
watermarkTs: string,
|
|
1273
|
+
): boolean {
|
|
1274
|
+
return compareSlackTs(String(row.createdAt / 1000), watermarkTs) > 0;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
function filterRowsAfterSlackCompactionBoundary(
|
|
1278
|
+
rows: SlackTranscriptInputRow[],
|
|
1279
|
+
options: SlackBoundaryOptions,
|
|
1280
|
+
): SlackTranscriptInputRow[] {
|
|
1281
|
+
const fallbackCount = Math.max(
|
|
1282
|
+
0,
|
|
1283
|
+
Math.floor(options.contextCompactedMessageCount ?? 0),
|
|
1284
|
+
);
|
|
1285
|
+
const watermarkTs = options.slackContextCompactionWatermarkTs ?? null;
|
|
1286
|
+
if (watermarkTs === null) {
|
|
1287
|
+
return fallbackCount > 0 ? rows.slice(fallbackCount) : rows;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
return rows.filter((row, index) => {
|
|
1291
|
+
const meta = rowToRenderable(row).metadata;
|
|
1292
|
+
if (meta) {
|
|
1293
|
+
return isSlackTsAfter(meta.channelTs, watermarkTs);
|
|
1294
|
+
}
|
|
1295
|
+
if (index < fallbackCount) {
|
|
1296
|
+
return false;
|
|
1297
|
+
}
|
|
1298
|
+
return legacyRowIsAfterWatermark(row, watermarkTs);
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
export function getSlackCompactionWatermarkForPrefix(
|
|
1303
|
+
context: SlackChronologicalContext | null,
|
|
1304
|
+
compactedRenderedMessages: number,
|
|
1305
|
+
): string | null {
|
|
1306
|
+
if (!context || compactedRenderedMessages <= 0) return null;
|
|
1307
|
+
const start = context.compactableStartIndex;
|
|
1308
|
+
const end = Math.min(
|
|
1309
|
+
context.renderedMessages.length,
|
|
1310
|
+
start + compactedRenderedMessages,
|
|
1311
|
+
);
|
|
1312
|
+
if (end <= start) return null;
|
|
1313
|
+
return maxSlackTs(
|
|
1314
|
+
context.renderedMessages
|
|
1315
|
+
.slice(start, end)
|
|
1316
|
+
.map((entry) => entry.sourceChannelTs),
|
|
1317
|
+
);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
export function assembleSlackChronologicalContext(
|
|
1321
|
+
rows: SlackTranscriptInputRow[],
|
|
1322
|
+
capabilities: ChannelCapabilities,
|
|
1323
|
+
options: {
|
|
1324
|
+
contextSummary?: string | null;
|
|
1325
|
+
} = {},
|
|
1326
|
+
): SlackChronologicalContext | null {
|
|
1262
1327
|
if (capabilities.channel !== "slack") {
|
|
1263
1328
|
return null;
|
|
1264
1329
|
}
|
|
1265
1330
|
const renderable = rows.map(rowToRenderable);
|
|
1266
|
-
|
|
1331
|
+
const rendered = renderSlackTranscriptWithProvenance(renderable);
|
|
1332
|
+
const contextSummary = options.contextSummary?.trim();
|
|
1333
|
+
const renderedMessages = rendered.renderedMessages;
|
|
1334
|
+
if (contextSummary) {
|
|
1335
|
+
const withSummary: RenderedSlackTranscriptMessage[] = [
|
|
1336
|
+
{
|
|
1337
|
+
message: createContextSummaryMessage(contextSummary),
|
|
1338
|
+
sourceChannelTs: null,
|
|
1339
|
+
},
|
|
1340
|
+
...renderedMessages,
|
|
1341
|
+
];
|
|
1342
|
+
return {
|
|
1343
|
+
renderedMessages: withSummary,
|
|
1344
|
+
messages: withSummary.map((entry) => entry.message),
|
|
1345
|
+
compactableStartIndex: 1,
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
return {
|
|
1349
|
+
renderedMessages,
|
|
1350
|
+
messages: renderedMessages.map((entry) => entry.message),
|
|
1351
|
+
compactableStartIndex: 0,
|
|
1352
|
+
};
|
|
1267
1353
|
}
|
|
1268
1354
|
|
|
1269
1355
|
/**
|
|
1270
|
-
*
|
|
1271
|
-
*
|
|
1272
|
-
*
|
|
1273
|
-
* Convenience wrapper over `getMessages` + `assembleSlackChronologicalMessages`.
|
|
1274
|
-
* The loader is exposed as a parameter so tests can substitute a stub. In
|
|
1275
|
-
* production it defaults to `getMessages` from `conversation-crud.ts`.
|
|
1356
|
+
* Compatibility wrapper over `loadSlackChronologicalContext` for callers that
|
|
1357
|
+
* still need only the legacy `Message[] | null` projection.
|
|
1276
1358
|
*
|
|
1277
1359
|
* When `trustClass` identifies an untrusted actor (guardian-scoped rows
|
|
1278
1360
|
* must not leak into the model context), rows are passed through
|
|
@@ -1289,8 +1371,39 @@ export function loadSlackChronologicalMessages(
|
|
|
1289
1371
|
options: {
|
|
1290
1372
|
loader?: (id: string) => MessageRow[];
|
|
1291
1373
|
trustClass?: TrustClass;
|
|
1374
|
+
contextSummary?: string | null;
|
|
1375
|
+
contextCompactedMessageCount?: number;
|
|
1376
|
+
slackContextCompactionWatermarkTs?: string | null;
|
|
1292
1377
|
} = {},
|
|
1293
1378
|
): Message[] | null {
|
|
1379
|
+
return (
|
|
1380
|
+
loadSlackChronologicalContext(conversationId, capabilities, options)
|
|
1381
|
+
?.messages ?? null
|
|
1382
|
+
);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* Load DB rows for a Slack conversation and project them onto the
|
|
1387
|
+
* chronological transcript shape plus source metadata used by compaction.
|
|
1388
|
+
*
|
|
1389
|
+
* If a Slack timestamp watermark exists, rows at or before that Slack
|
|
1390
|
+
* `channelTs` are omitted. When no timestamp watermark exists yet, the
|
|
1391
|
+
* legacy `contextCompactedMessageCount` is used as a DB-order fallback so
|
|
1392
|
+
* old compacted Slack conversations do not immediately resurrect history;
|
|
1393
|
+
* the next successful Slack compaction replaces that count boundary with a
|
|
1394
|
+
* durable Slack timestamp watermark.
|
|
1395
|
+
*/
|
|
1396
|
+
export function loadSlackChronologicalContext(
|
|
1397
|
+
conversationId: string,
|
|
1398
|
+
capabilities: ChannelCapabilities,
|
|
1399
|
+
options: {
|
|
1400
|
+
loader?: (id: string) => MessageRow[];
|
|
1401
|
+
trustClass?: TrustClass;
|
|
1402
|
+
contextSummary?: string | null;
|
|
1403
|
+
contextCompactedMessageCount?: number;
|
|
1404
|
+
slackContextCompactionWatermarkTs?: string | null;
|
|
1405
|
+
} = {},
|
|
1406
|
+
): SlackChronologicalContext | null {
|
|
1294
1407
|
if (capabilities.channel !== "slack") {
|
|
1295
1408
|
return null;
|
|
1296
1409
|
}
|
|
@@ -1299,14 +1412,15 @@ export function loadSlackChronologicalMessages(
|
|
|
1299
1412
|
const scopedRows = isUntrustedTrustClass(options.trustClass)
|
|
1300
1413
|
? filterMessagesForUntrustedActor(allRows)
|
|
1301
1414
|
: allRows;
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1415
|
+
const rows = filterRowsAfterSlackCompactionBoundary(
|
|
1416
|
+
messageRowsToSlackTranscriptRows(scopedRows),
|
|
1417
|
+
options,
|
|
1418
|
+
);
|
|
1419
|
+
return assembleSlackChronologicalContext(rows, capabilities, {
|
|
1420
|
+
contextSummary: isUntrustedTrustClass(options.trustClass)
|
|
1421
|
+
? null
|
|
1422
|
+
: options.contextSummary,
|
|
1423
|
+
});
|
|
1310
1424
|
}
|
|
1311
1425
|
|
|
1312
1426
|
// ---------------------------------------------------------------------------
|
|
@@ -1473,6 +1587,8 @@ export function loadSlackActiveThreadFocusBlock(
|
|
|
1473
1587
|
options: {
|
|
1474
1588
|
loader?: (id: string) => MessageRow[];
|
|
1475
1589
|
trustClass?: TrustClass;
|
|
1590
|
+
contextCompactedMessageCount?: number;
|
|
1591
|
+
slackContextCompactionWatermarkTs?: string | null;
|
|
1476
1592
|
} = {},
|
|
1477
1593
|
): string | null {
|
|
1478
1594
|
if (capabilities.channel !== "slack") return null;
|
|
@@ -1482,12 +1598,10 @@ export function loadSlackActiveThreadFocusBlock(
|
|
|
1482
1598
|
const scopedRows = isUntrustedTrustClass(options.trustClass)
|
|
1483
1599
|
? filterMessagesForUntrustedActor(allRows)
|
|
1484
1600
|
: allRows;
|
|
1485
|
-
const rows
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
metadata: row.metadata,
|
|
1490
|
-
}));
|
|
1601
|
+
const rows = filterRowsAfterSlackCompactionBoundary(
|
|
1602
|
+
messageRowsToSlackTranscriptRows(scopedRows),
|
|
1603
|
+
options,
|
|
1604
|
+
);
|
|
1491
1605
|
return assembleSlackActiveThreadFocusBlock(rows, capabilities);
|
|
1492
1606
|
}
|
|
1493
1607
|
|
|
@@ -1503,11 +1617,12 @@ const RUNTIME_INJECTION_PREFIXES = [
|
|
|
1503
1617
|
// blocks persist in history so the assistant retains temporal/actor grounding.
|
|
1504
1618
|
"<memory_context __injected>",
|
|
1505
1619
|
"<memory_context>", // backward-compat: strip legacy blocks from pre-__injected history
|
|
1506
|
-
// NOTE:
|
|
1507
|
-
//
|
|
1508
|
-
//
|
|
1509
|
-
// the
|
|
1510
|
-
//
|
|
1620
|
+
// NOTE: `<memory>` blocks (both the dynamic activation block from
|
|
1621
|
+
// `prependMemoryV2Block` and the static `memory-v2-static` injector) are
|
|
1622
|
+
// intentionally NOT stripped — memory injections persist in history so
|
|
1623
|
+
// the assistant retains intra-turn memory state. The activation pipeline
|
|
1624
|
+
// dedupes via `everInjected`, and compaction handles aggregate growth, so
|
|
1625
|
+
// accumulation does not cause unbounded context growth.
|
|
1511
1626
|
"<voice_call_control>",
|
|
1512
1627
|
"<workspace_top_level>", // backward-compat: strip legacy workspace blocks
|
|
1513
1628
|
// NOTE: <workspace> is intentionally NOT stripped — workspace context
|
|
@@ -1525,6 +1640,7 @@ const RUNTIME_INJECTION_PREFIXES = [
|
|
|
1525
1640
|
"<pkb>", // backward-compat: strip legacy tag from pre-rename history
|
|
1526
1641
|
"<system_reminder>",
|
|
1527
1642
|
"<transport_hints>",
|
|
1643
|
+
"<slack_context_notice>",
|
|
1528
1644
|
// The Slack active-thread focus block is non-persisted and injected on
|
|
1529
1645
|
// the FINAL user turn only. Strip it here so re-assembly during compaction
|
|
1530
1646
|
// and overflow recovery does not duplicate it across turns.
|
|
@@ -1797,10 +1913,19 @@ export interface RuntimeInjectionOptions {
|
|
|
1797
1913
|
* `pkb/threads.md`. Falls back to `pkbRoot` when omitted.
|
|
1798
1914
|
*/
|
|
1799
1915
|
pkbWorkingDir?: string;
|
|
1916
|
+
/**
|
|
1917
|
+
* Pre-rendered v2 static memory content (essentials/threads/recent/buffer
|
|
1918
|
+
* concatenated, header-wrapped). When non-null on full-mode turns the
|
|
1919
|
+
* `memory-v2-static` injector wraps it in `<memory>` and splices it onto
|
|
1920
|
+
* the user message; subsequent turns leave the prior block cached on its
|
|
1921
|
+
* original user message.
|
|
1922
|
+
*/
|
|
1923
|
+
memoryV2Static?: string | null;
|
|
1800
1924
|
nowScratchpad?: string | null;
|
|
1801
1925
|
subagentStatusBlock?: string | null;
|
|
1802
1926
|
isNonInteractive?: boolean;
|
|
1803
1927
|
transportHints?: string[] | null;
|
|
1928
|
+
slackRuntimeContextNotice?: string | null;
|
|
1804
1929
|
/**
|
|
1805
1930
|
* Pre-rendered Slack chronological transcript that replaces the
|
|
1806
1931
|
* default `runMessages` history for any Slack conversation (channels
|
|
@@ -1814,7 +1939,7 @@ export interface RuntimeInjectionOptions {
|
|
|
1814
1939
|
* skipped for any Slack conversation so the persisted view isn't
|
|
1815
1940
|
* duplicated by gateway-side hints.
|
|
1816
1941
|
*
|
|
1817
|
-
* Callers build this via `
|
|
1942
|
+
* Callers build this via `loadSlackChronologicalContext` (or the
|
|
1818
1943
|
* underlying `assembleSlackChronologicalMessages`) before invoking
|
|
1819
1944
|
* this function so the assembly path stays free of direct DB calls
|
|
1820
1945
|
* and remains easy to test.
|
|
@@ -1876,6 +2001,7 @@ function buildTurnInjectionInputs(
|
|
|
1876
2001
|
pkbAutoInjectList: options.pkbAutoInjectList,
|
|
1877
2002
|
pkbRoot: options.pkbRoot,
|
|
1878
2003
|
pkbWorkingDir: options.pkbWorkingDir,
|
|
2004
|
+
memoryV2Static: options.memoryV2Static,
|
|
1879
2005
|
nowScratchpad: options.nowScratchpad,
|
|
1880
2006
|
subagentStatusBlock: options.subagentStatusBlock,
|
|
1881
2007
|
channelCapabilities: options.channelCapabilities,
|
|
@@ -2132,6 +2258,23 @@ export async function applyRuntimeInjections(
|
|
|
2132
2258
|
}
|
|
2133
2259
|
}
|
|
2134
2260
|
|
|
2261
|
+
if (
|
|
2262
|
+
mode === "full" &&
|
|
2263
|
+
slackConversation &&
|
|
2264
|
+
options.slackRuntimeContextNotice
|
|
2265
|
+
) {
|
|
2266
|
+
const userTail = result[result.length - 1];
|
|
2267
|
+
if (userTail && userTail.role === "user") {
|
|
2268
|
+
result = [
|
|
2269
|
+
...result.slice(0, -1),
|
|
2270
|
+
injectSlackRuntimeContextNotice(
|
|
2271
|
+
userTail,
|
|
2272
|
+
options.slackRuntimeContextNotice,
|
|
2273
|
+
),
|
|
2274
|
+
];
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2135
2278
|
if (mode === "full" && options.channelCommandContext) {
|
|
2136
2279
|
const userTail = result[result.length - 1];
|
|
2137
2280
|
if (userTail && userTail.role === "user") {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { InterfaceId } from "../channels/types.js";
|
|
2
|
+
import { resolveEffectiveContextWindow } from "../config/llm-context-resolution.js";
|
|
2
3
|
import { getConfig } from "../config/loader.js";
|
|
4
|
+
import { getConversationOverrideProfile } from "../memory/conversation-crud.js";
|
|
3
5
|
import { PROVIDER_CATALOG } from "../providers/model-catalog.js";
|
|
4
6
|
import { getConfiguredProviders } from "../providers/provider-availability.js";
|
|
5
7
|
|
|
@@ -8,7 +10,7 @@ export type SlashResolution =
|
|
|
8
10
|
| { kind: "unknown"; message: string }
|
|
9
11
|
| { kind: "compact" };
|
|
10
12
|
|
|
11
|
-
// ── /status
|
|
13
|
+
// ── /context and /status commands ────────────────────────────────────
|
|
12
14
|
|
|
13
15
|
export interface SlashContext {
|
|
14
16
|
messageCount: number;
|
|
@@ -21,6 +23,39 @@ export interface SlashContext {
|
|
|
21
23
|
userMessageInterface?: InterfaceId;
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
export interface SlashContextSource {
|
|
27
|
+
conversationId: string;
|
|
28
|
+
messageCount: number;
|
|
29
|
+
inputTokens: number;
|
|
30
|
+
outputTokens: number;
|
|
31
|
+
estimatedCost: number;
|
|
32
|
+
userMessageInterface?: InterfaceId;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function buildSlashContextForContent(
|
|
36
|
+
content: string,
|
|
37
|
+
source: SlashContextSource,
|
|
38
|
+
): SlashContext | undefined {
|
|
39
|
+
if (classifySlash(content) === "passthrough") return undefined;
|
|
40
|
+
|
|
41
|
+
const config = getConfig();
|
|
42
|
+
const contextWindow = resolveEffectiveContextWindow({
|
|
43
|
+
llm: config.llm,
|
|
44
|
+
callSite: "mainAgent",
|
|
45
|
+
overrideProfile: getConversationOverrideProfile(source.conversationId),
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
messageCount: source.messageCount,
|
|
49
|
+
inputTokens: source.inputTokens,
|
|
50
|
+
outputTokens: source.outputTokens,
|
|
51
|
+
maxInputTokens: contextWindow.maxInputTokens,
|
|
52
|
+
model: contextWindow.model,
|
|
53
|
+
provider: contextWindow.provider,
|
|
54
|
+
estimatedCost: source.estimatedCost,
|
|
55
|
+
userMessageInterface: source.userMessageInterface,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
24
59
|
// ── Deprecated model-switching shortcuts ─────────────────────────────
|
|
25
60
|
|
|
26
61
|
/**
|
|
@@ -107,8 +142,11 @@ function resolveCommandsList(context?: SlashContext): string[] {
|
|
|
107
142
|
const fallbackLines = [
|
|
108
143
|
"/commands — List all available commands",
|
|
109
144
|
"/compact — Force context compaction immediately",
|
|
110
|
-
"/models — List all available models",
|
|
111
145
|
];
|
|
146
|
+
if (context) {
|
|
147
|
+
fallbackLines.push("/context — Show conversation context usage");
|
|
148
|
+
}
|
|
149
|
+
fallbackLines.push("/models — List all available models");
|
|
112
150
|
if (context) {
|
|
113
151
|
fallbackLines.push("/status — Show conversation status and context usage");
|
|
114
152
|
}
|
|
@@ -119,6 +157,7 @@ function resolveCommandsList(context?: SlashContext): string[] {
|
|
|
119
157
|
return [
|
|
120
158
|
"/commands — List all available commands",
|
|
121
159
|
"/compact — Force context compaction immediately",
|
|
160
|
+
"/context — Show conversation context usage",
|
|
122
161
|
"/models — List all available models",
|
|
123
162
|
"/status — Show conversation status and context usage",
|
|
124
163
|
"/btw — Ask a side question while the assistant is working",
|
|
@@ -130,6 +169,7 @@ function resolveCommandsList(context?: SlashContext): string[] {
|
|
|
130
169
|
return [
|
|
131
170
|
"/commands — List all available commands",
|
|
132
171
|
"/compact — Force context compaction immediately",
|
|
172
|
+
"/context — Show conversation context usage",
|
|
133
173
|
"/models — List all available models",
|
|
134
174
|
"/status — Show conversation status and context usage",
|
|
135
175
|
"/btw — Ask a side question while the assistant is working",
|
|
@@ -140,6 +180,7 @@ function resolveCommandsList(context?: SlashContext): string[] {
|
|
|
140
180
|
return [
|
|
141
181
|
"/commands — List all available commands",
|
|
142
182
|
"/compact — Force context compaction immediately",
|
|
183
|
+
"/context — Show conversation context usage",
|
|
143
184
|
"/models — List all available models",
|
|
144
185
|
"/status — Show conversation status and context usage",
|
|
145
186
|
"/btw — Ask a side question while the assistant is working",
|
|
@@ -174,13 +215,14 @@ export function classifySlash(
|
|
|
174
215
|
}
|
|
175
216
|
if (trimmed === "/models") return "unknown";
|
|
176
217
|
if (trimmed === "/compact") return "compact";
|
|
218
|
+
if (trimmed === "/context") return "unknown";
|
|
177
219
|
if (trimmed === "/status") return "unknown";
|
|
178
220
|
if (trimmed === "/commands") return "unknown";
|
|
179
221
|
return "passthrough";
|
|
180
222
|
}
|
|
181
223
|
|
|
182
224
|
/**
|
|
183
|
-
* Resolve built-in slash commands (/models, /status, /commands, /compact).
|
|
225
|
+
* Resolve built-in slash commands (/models, /context, /status, /commands, /compact).
|
|
184
226
|
* Returns `unknown` with a deterministic message, `compact` for forced compaction,
|
|
185
227
|
* or the (possibly rewritten) content as `passthrough`.
|
|
186
228
|
*/
|
|
@@ -223,8 +265,8 @@ export async function resolveSlash(
|
|
|
223
265
|
return { kind: "compact" };
|
|
224
266
|
}
|
|
225
267
|
|
|
226
|
-
// Handle /status
|
|
227
|
-
if (trimmed === "/status") {
|
|
268
|
+
// Handle /context and legacy /status commands
|
|
269
|
+
if (trimmed === "/context" || trimmed === "/status") {
|
|
228
270
|
if (!context) {
|
|
229
271
|
return {
|
|
230
272
|
kind: "unknown",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* shared rate-limit timestamps, broadcast).
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { broadcastToAllClients } from "../acp/index.js";
|
|
18
17
|
import { getConfig } from "../config/loader.js";
|
|
19
18
|
import type { CesClient } from "../credential-execution/client.js";
|
|
20
19
|
import { buildSystemPrompt } from "../prompts/system-prompt.js";
|
|
@@ -23,10 +22,7 @@ import { RateLimitProvider } from "../providers/ratelimit.js";
|
|
|
23
22
|
import { getProvider } from "../providers/registry.js";
|
|
24
23
|
import { getSubagentManager } from "../subagent/index.js";
|
|
25
24
|
import { getSandboxWorkingDir } from "../util/platform.js";
|
|
26
|
-
import {
|
|
27
|
-
Conversation,
|
|
28
|
-
DEFAULT_MEMORY_POLICY,
|
|
29
|
-
} from "./conversation.js";
|
|
25
|
+
import { Conversation, DEFAULT_MEMORY_POLICY } from "./conversation.js";
|
|
30
26
|
import type { ConversationEvictor } from "./conversation-evictor.js";
|
|
31
27
|
import type { ConversationCreateOptions } from "./handlers/shared.js";
|
|
32
28
|
import { buildTransportHints } from "./transport-hints.js";
|
|
@@ -72,11 +68,7 @@ export function findConversationBySurfaceId(
|
|
|
72
68
|
return undefined;
|
|
73
69
|
}
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
return conversations.has(conversationId);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function conversationCount(): number {
|
|
71
|
+
function conversationCount(): number {
|
|
80
72
|
return conversations.size;
|
|
81
73
|
}
|
|
82
74
|
|
|
@@ -93,7 +85,7 @@ export function conversationEntries(): IterableIterator<
|
|
|
93
85
|
}
|
|
94
86
|
|
|
95
87
|
/** Iterate over all active conversation IDs. */
|
|
96
|
-
|
|
88
|
+
function conversationIds(): IterableIterator<string> {
|
|
97
89
|
return conversations.keys();
|
|
98
90
|
}
|
|
99
91
|
|
|
@@ -129,19 +121,6 @@ export function getConversationMap(): Map<string, Conversation> {
|
|
|
129
121
|
|
|
130
122
|
const conversationOptions = new Map<string, ConversationCreateOptions>();
|
|
131
123
|
|
|
132
|
-
export function getConversationOptions(
|
|
133
|
-
conversationId: string,
|
|
134
|
-
): ConversationCreateOptions | undefined {
|
|
135
|
-
return conversationOptions.get(conversationId);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function setConversationOptions(
|
|
139
|
-
conversationId: string,
|
|
140
|
-
options: ConversationCreateOptions,
|
|
141
|
-
): void {
|
|
142
|
-
conversationOptions.set(conversationId, options);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
124
|
export function mergeConversationOptions(
|
|
146
125
|
conversationId: string,
|
|
147
126
|
patch: Partial<ConversationCreateOptions>,
|
|
@@ -152,11 +131,11 @@ export function mergeConversationOptions(
|
|
|
152
131
|
});
|
|
153
132
|
}
|
|
154
133
|
|
|
155
|
-
|
|
134
|
+
function deleteConversationOptions(conversationId: string): void {
|
|
156
135
|
conversationOptions.delete(conversationId);
|
|
157
136
|
}
|
|
158
137
|
|
|
159
|
-
|
|
138
|
+
function clearConversationOptions(): void {
|
|
160
139
|
conversationOptions.clear();
|
|
161
140
|
}
|
|
162
141
|
|
|
@@ -262,13 +241,11 @@ export async function getOrCreateConversation(
|
|
|
262
241
|
|
|
263
242
|
const systemPrompt =
|
|
264
243
|
storedOptions?.systemPromptOverride ?? buildSystemPrompt();
|
|
265
|
-
const maxTokens =
|
|
266
|
-
storedOptions?.maxResponseTokens ?? config.llm.default.maxTokens;
|
|
244
|
+
const maxTokens = storedOptions?.maxResponseTokens;
|
|
267
245
|
|
|
268
246
|
const sharedCesClient = _cesClientPromise
|
|
269
247
|
? await _cesClientPromise
|
|
270
248
|
: undefined;
|
|
271
|
-
const broadcast = broadcastToAllClients ?? (() => {});
|
|
272
249
|
const newConversation = new Conversation(
|
|
273
250
|
conversationId,
|
|
274
251
|
provider,
|
|
@@ -276,7 +253,6 @@ export async function getOrCreateConversation(
|
|
|
276
253
|
maxTokens,
|
|
277
254
|
sendToClient,
|
|
278
255
|
workingDir,
|
|
279
|
-
broadcast,
|
|
280
256
|
DEFAULT_MEMORY_POLICY,
|
|
281
257
|
sharedCesClient,
|
|
282
258
|
storedOptions?.speed,
|
|
@@ -329,7 +305,7 @@ export function touchConversation(conversationId: string): void {
|
|
|
329
305
|
_evictor?.touch(conversationId);
|
|
330
306
|
}
|
|
331
307
|
|
|
332
|
-
|
|
308
|
+
function removeFromEvictor(conversationId: string): void {
|
|
333
309
|
_evictor?.remove(conversationId);
|
|
334
310
|
}
|
|
335
311
|
|