@vellumai/assistant 0.8.2 → 0.8.4
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 +11 -12
- package/docker-entrypoint.sh +13 -2
- package/docker-init-apt-root.sh +79 -6
- package/node_modules/@vellumai/gateway-client/src/types.ts +2 -0
- package/openapi.yaml +945 -36
- package/package.json +1 -1
- package/src/__tests__/agent-loop-exit-reason.test.ts +271 -0
- package/src/__tests__/agent-loop-override-profile.test.ts +1 -1
- package/src/__tests__/agent-loop-provider-error-recording.test.ts +195 -0
- package/src/__tests__/agent-loop.test.ts +88 -3
- package/src/__tests__/anthropic-provider.test.ts +272 -0
- package/src/__tests__/approval-cascade.test.ts +1 -1
- package/src/__tests__/background-workers-disk-pressure.test.ts +2 -1
- package/src/__tests__/channel-delivery-store.test.ts +193 -0
- package/src/__tests__/channel-reply-delivery.test.ts +284 -5
- package/src/__tests__/channel-retry-sweep.test.ts +274 -1
- package/src/__tests__/compaction-events.test.ts +1 -1
- package/src/__tests__/compactor-preserved-tail-count.test.ts +110 -0
- package/src/__tests__/compactor-tail-resolution.test.ts +107 -1
- package/src/__tests__/config-get-vision-flag.test.ts +136 -0
- package/src/__tests__/config-loader-backfill.test.ts +115 -18
- package/src/__tests__/config-watcher.test.ts +1 -1
- package/src/__tests__/context-token-estimator.test.ts +112 -57
- package/src/__tests__/conversation-abort-tool-results.test.ts +1 -1
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +54 -3
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +31 -6
- package/src/__tests__/conversation-agent-loop.test.ts +77 -3
- package/src/__tests__/conversation-app-control-lifecycle.test.ts +1 -1
- package/src/__tests__/conversation-clean-command.test.ts +137 -0
- package/src/__tests__/conversation-confirmation-signals.test.ts +1 -1
- package/src/__tests__/conversation-fork-crud.test.ts +161 -0
- package/src/__tests__/conversation-lifecycle.test.ts +1 -1
- package/src/__tests__/conversation-load-cleaned-at.test.ts +279 -0
- package/src/__tests__/conversation-load-history-repair.test.ts +1 -1
- package/src/__tests__/conversation-media-retry.test.ts +19 -8
- package/src/__tests__/conversation-pairing.test.ts +2 -2
- package/src/__tests__/conversation-process-callsite.test.ts +1 -1
- package/src/__tests__/conversation-provider-retry-repair.test.ts +1 -1
- package/src/__tests__/conversation-queue.test.ts +1 -1
- package/src/__tests__/conversation-runtime-assembly.test.ts +290 -85
- package/src/__tests__/conversation-seed-composer.test.ts +66 -4
- package/src/__tests__/conversation-slash-commands.test.ts +36 -8
- package/src/__tests__/conversation-slash-queue.test.ts +1 -1
- package/src/__tests__/conversation-slash-unknown.test.ts +1 -1
- package/src/__tests__/conversation-speed-override.test.ts +1 -1
- package/src/__tests__/conversation-surfaces-task-progress.test.ts +220 -0
- package/src/__tests__/conversation-workspace-cache-state.test.ts +1 -1
- package/src/__tests__/conversation-workspace-injection.test.ts +5 -1
- package/src/__tests__/conversation-workspace-tool-tracking.test.ts +5 -1
- package/src/__tests__/credential-security-invariants.test.ts +6 -0
- package/src/__tests__/cu-unified-flow.test.ts +10 -1
- package/src/__tests__/date-context.test.ts +45 -0
- package/src/__tests__/dm-backfill.test.ts +64 -0
- package/src/__tests__/dm-persistence.test.ts +33 -0
- package/src/__tests__/document-find-replace.test.ts +501 -0
- package/src/__tests__/external-plugin-loader.test.ts +91 -19
- package/src/__tests__/first-greeting.test.ts +23 -2
- package/src/__tests__/guardian-action-no-hardcoded-copy.test.ts +0 -1
- package/src/__tests__/guardian-dispatch.test.ts +1 -0
- package/src/__tests__/headless-browser-navigate.test.ts +172 -0
- package/src/__tests__/heartbeat-service.test.ts +24 -164
- package/src/__tests__/helpers/channel-test-adapter.ts +0 -2
- package/src/__tests__/host-app-control-proxy.test.ts +241 -0
- package/src/__tests__/host-bash-proxy.test.ts +6 -0
- package/src/__tests__/host-browser-proxy.test.ts +10 -0
- package/src/__tests__/host-cu-proxy.test.ts +8 -1
- package/src/__tests__/host-file-proxy.test.ts +8 -1
- package/src/__tests__/host-proxy-preactivation.test.ts +200 -13
- package/src/__tests__/host-transfer-proxy.test.ts +8 -1
- package/src/__tests__/identity-routes.test.ts +57 -0
- package/src/__tests__/inbound-slack-persistence.test.ts +3 -0
- package/src/__tests__/injector-background-turn.test.ts +153 -0
- package/src/__tests__/injector-chain.test.ts +7 -0
- package/src/__tests__/injector-document-comments.test.ts +378 -0
- package/src/__tests__/injector-pkb-v2-silenced.test.ts +4 -25
- package/src/__tests__/lifecycle-memory-v2-seed.test.ts +9 -2
- package/src/__tests__/list-messages-attachments.test.ts +21 -17
- package/src/__tests__/list-messages-hidden-metadata.test.ts +217 -0
- package/src/__tests__/list-messages-page-latest.test.ts +130 -14
- package/src/__tests__/list-messages-tool-merge.test.ts +17 -16
- package/src/__tests__/llm-callsite-catalog.test.ts +25 -0
- package/src/__tests__/llm-catalog-parity.test.ts +3 -0
- package/src/__tests__/llm-context-normalization.test.ts +0 -2
- package/src/__tests__/llm-request-log-agent-loop-exit-reason.test.ts +116 -0
- package/src/__tests__/llm-request-log-error-payload.test.ts +138 -0
- package/src/__tests__/llm-request-log-source-clickhouse.test.ts +2 -0
- package/src/__tests__/llm-resolver.test.ts +340 -3
- package/src/__tests__/log-export-routes.test.ts +99 -2
- package/src/__tests__/managed-profile-guard.test.ts +10 -0
- package/src/__tests__/message-queue-steer.test.ts +114 -0
- package/src/__tests__/notification-decision-fallback.test.ts +0 -91
- package/src/__tests__/notification-decision-strategy.test.ts +14 -31
- package/src/__tests__/notification-deep-link.test.ts +15 -0
- package/src/__tests__/notification-guardian-path.test.ts +1 -2
- package/src/__tests__/notification-platform-adapter.test.ts +5 -4
- package/src/__tests__/notification-telegram-adapter.test.ts +1 -0
- package/src/__tests__/notification-vellum-adapter.test.ts +113 -0
- package/src/__tests__/openai-provider.test.ts +323 -3
- package/src/__tests__/openai-responses-cutover-guard.test.ts +3 -3
- package/src/__tests__/openai-responses-provider.test.ts +4 -4
- package/src/__tests__/openrouter-provider-only.test.ts +51 -3
- package/src/__tests__/openrouter-token-estimation.test.ts +34 -25
- package/src/__tests__/outbound-slack-persistence.test.ts +187 -20
- package/src/__tests__/pending-interactions-resolved-event.test.ts +190 -0
- package/src/__tests__/platform-proxy-context.test.ts +6 -1
- package/src/__tests__/platform.test.ts +0 -3
- package/src/__tests__/plugin-source-watcher.test.ts +302 -0
- package/src/__tests__/plugin-tool-contribution.test.ts +3 -3
- package/src/__tests__/plugin-types.test.ts +2 -2
- package/src/__tests__/process-message-background-slack.test.ts +1 -51
- package/src/__tests__/process-message-display-content.test.ts +21 -16
- package/src/__tests__/provider-catalog-visibility.test.ts +16 -0
- package/src/__tests__/provider-platform-proxy-integration.test.ts +27 -25
- package/src/__tests__/secret-routes-platform-proxy.test.ts +1 -1
- package/src/__tests__/server-history-render.test.ts +83 -4
- package/src/__tests__/steer-tool-repair.test.ts +249 -0
- package/src/__tests__/system-prompt.test.ts +57 -101
- package/src/__tests__/terminal-tools.test.ts +11 -1
- package/src/__tests__/thinking-block-replay.test.ts +113 -0
- package/src/__tests__/thread-backfill.test.ts +370 -22
- package/src/__tests__/tool-executor.test.ts +90 -1
- package/src/__tests__/tool-result-metadata-plumbing.test.ts +167 -0
- package/src/__tests__/twilio-routes.test.ts +1 -1
- package/src/__tests__/web-fetch.test.ts +2 -2
- package/src/__tests__/workspace-git-service.test.ts +88 -5
- package/src/__tests__/workspace-migration-087-memory-router-balanced-profile.test.ts +228 -0
- package/src/__tests__/workspace-migration-088-deprecate-background-conversation-override.test.ts +158 -0
- package/src/a2a/__tests__/agent-card.test.ts +98 -0
- package/src/a2a/__tests__/e2e-a2a-channel.test.ts +597 -0
- package/src/a2a/__tests__/protocol-helpers.test.ts +113 -0
- package/src/a2a/__tests__/task-store.test.ts +246 -0
- package/src/a2a/agent-card.ts +58 -0
- package/src/a2a/feature-gate.ts +8 -0
- package/src/a2a/protocol-constants.ts +21 -0
- package/src/a2a/protocol-errors.ts +50 -0
- package/src/a2a/protocol-types.ts +162 -0
- package/src/a2a/task-store.ts +168 -0
- package/src/agent/attachments.ts +1 -0
- package/src/agent/loop.ts +208 -22
- package/src/background-wake/next-wake.test.ts +289 -0
- package/src/background-wake/next-wake.ts +172 -0
- package/src/browser/operations.ts +15 -0
- package/src/channels/config.ts +9 -0
- package/src/channels/types.ts +14 -0
- package/src/cli/commands/__tests__/conversations-slack.test.ts +572 -0
- package/src/cli/commands/__tests__/memory-v2.test.ts +9 -12
- package/src/cli/{__tests__ → commands/__tests__}/notifications.test.ts +201 -28
- package/src/cli/commands/__tests__/schedules.test.ts +469 -0
- package/src/cli/commands/conversations.ts +128 -1
- package/src/cli/commands/inference-providers.ts +147 -1
- package/src/cli/commands/memory-v2.ts +308 -0
- package/src/cli/commands/notifications.ts +89 -37
- package/src/cli/commands/plugins.ts +67 -0
- package/src/cli/commands/schedules.ts +297 -5
- package/src/cli/lib/__tests__/search-plugins.test.ts +261 -0
- package/src/cli/lib/install-from-github.ts +8 -9
- package/src/cli/lib/search-plugins.ts +163 -0
- package/src/cli/program.ts +14 -0
- package/src/cli/utils/conversation-id.ts +17 -5
- package/src/config/assistant-feature-flags.ts +24 -54
- package/src/config/bundled-skills/app-builder/SKILL.md +117 -1
- package/src/config/bundled-skills/document-editor/SKILL.md +115 -0
- package/src/config/bundled-skills/document-editor/TOOLS.json +240 -0
- package/src/config/bundled-skills/document-editor/tools/comment-list.ts +12 -0
- package/src/config/bundled-skills/document-editor/tools/comment-reply.ts +12 -0
- package/src/config/bundled-skills/document-editor/tools/comment-resolve.ts +12 -0
- package/src/config/bundled-skills/document-editor/tools/document-find.ts +12 -0
- package/src/config/bundled-skills/document-editor/tools/document-replace-text.ts +12 -0
- package/src/config/bundled-skills/media-processing/SKILL.md +8 -0
- package/src/config/bundled-skills/phone-calls/SKILL.md +1 -1
- package/src/config/bundled-skills/schedule/SKILL.md +8 -0
- package/src/config/bundled-tool-registry.ts +22 -12
- package/src/config/call-site-defaults.ts +124 -0
- package/src/config/feature-flag-registry.json +111 -23
- package/src/config/llm-resolver.ts +66 -1
- package/src/config/schema.ts +2 -0
- package/src/config/schemas/__tests__/memory-v2.test.ts +7 -3
- package/src/config/schemas/call-site-catalog.ts +21 -0
- package/src/config/schemas/channels.ts +9 -0
- package/src/config/schemas/conversations.ts +10 -0
- package/src/config/schemas/heartbeat.ts +14 -0
- package/src/config/schemas/llm.ts +4 -3
- package/src/config/schemas/memory-retrospective.ts +1 -1
- package/src/config/schemas/memory-v2.ts +51 -4
- package/src/config/schemas/memory.ts +3 -1
- package/src/config/seed-inference-profiles.ts +99 -29
- package/src/context/compactor.ts +80 -13
- package/src/context/token-estimator.ts +72 -31
- package/src/context/window-manager.ts +25 -0
- package/src/credential-health/credential-health-service.ts +34 -19
- package/src/daemon/__tests__/conversation-lifecycle-auto-analyze.test.ts +3 -22
- package/src/daemon/__tests__/conversation-tool-setup.test.ts +66 -6
- package/src/daemon/__tests__/native-web-search-metadata.test.ts +357 -0
- package/src/daemon/__tests__/web-search-status-text.test.ts +287 -0
- package/src/daemon/conversation-agent-loop-handlers.ts +231 -23
- package/src/daemon/conversation-agent-loop.ts +252 -56
- package/src/daemon/conversation-lifecycle.ts +142 -116
- package/src/daemon/conversation-messaging.ts +3 -0
- package/src/daemon/conversation-process.ts +273 -0
- package/src/daemon/conversation-queue-manager.ts +14 -0
- package/src/daemon/conversation-runtime-assembly.ts +144 -75
- package/src/daemon/conversation-slash.ts +37 -5
- package/src/daemon/conversation-surfaces.ts +45 -2
- package/src/daemon/conversation-tool-setup.ts +7 -0
- package/src/daemon/conversation.ts +42 -12
- package/src/daemon/date-context.ts +40 -0
- package/src/daemon/first-greeting.ts +10 -0
- package/src/daemon/guardian-action-generators.ts +1 -125
- package/src/daemon/handlers/__tests__/config-a2a-accept.test.ts +498 -0
- package/src/daemon/handlers/__tests__/config-a2a-complete.test.ts +248 -0
- package/src/daemon/handlers/__tests__/config-a2a-invite.test.ts +154 -0
- package/src/daemon/handlers/__tests__/config-a2a-redeem.test.ts +133 -0
- package/src/daemon/handlers/__tests__/config-a2a.test.ts +95 -0
- package/src/daemon/handlers/config-a2a.ts +449 -0
- package/src/daemon/handlers/config-model.test.ts +1 -0
- package/src/daemon/handlers/conversations.ts +80 -0
- package/src/daemon/handlers/shared.ts +92 -29
- package/src/daemon/host-app-control-proxy.ts +69 -18
- package/src/daemon/host-bash-proxy.ts +1 -1
- package/src/daemon/host-cu-proxy.ts +1 -1
- package/src/daemon/host-file-proxy.ts +1 -1
- package/src/daemon/host-proxy-preactivation.ts +85 -18
- package/src/daemon/host-transfer-proxy.ts +1 -1
- package/src/daemon/lifecycle.ts +67 -65
- package/src/daemon/memory-v2-startup.ts +49 -13
- package/src/daemon/message-protocol.ts +4 -0
- package/src/daemon/message-types/conversations.ts +8 -0
- package/src/daemon/message-types/document-comments.ts +50 -0
- package/src/daemon/message-types/messages.ts +68 -1
- package/src/daemon/message-types/notifications.ts +21 -0
- package/src/daemon/message-types/surfaces.ts +3 -1
- package/src/daemon/message-types/web-activity.ts +57 -0
- package/src/daemon/pkb-reminder-builder.test.ts +10 -53
- package/src/daemon/pkb-reminder-builder.ts +4 -19
- package/src/daemon/plugin-source-watcher.ts +135 -3
- package/src/daemon/process-message.ts +72 -12
- package/src/daemon/query-complexity-router.ts +75 -0
- package/src/daemon/skill-memory-refresh.ts +5 -1
- package/src/daemon/trust-context.ts +6 -0
- package/src/daemon/wake-target-adapter.ts +2 -0
- package/src/documents/document-comments-store.test.ts +338 -0
- package/src/documents/document-comments-store.ts +237 -0
- package/src/documents/document-store.ts +202 -0
- package/src/export/__tests__/transcript-formatter.test.ts +121 -0
- package/src/export/transcript-formatter.ts +54 -20
- package/src/heartbeat/__tests__/heartbeat-service.test.ts +44 -1
- package/src/heartbeat/heartbeat-service.ts +35 -191
- package/src/home/__tests__/feed-types.test.ts +40 -0
- package/src/home/__tests__/suggested-prompts.test.ts +33 -2
- package/src/home/feed-types.ts +20 -3
- package/src/home/home-content-refresh.ts +52 -0
- package/src/home/home-greeting-cache.ts +69 -0
- package/src/home/home-greeting.ts +94 -0
- package/src/home/suggested-prompts.ts +177 -9
- package/src/ipc/cli-client.ts +147 -45
- package/src/memory/__tests__/conversation-queries.test.ts +220 -0
- package/src/memory/__tests__/jobs-worker-v2-schedule.test.ts +135 -2
- package/src/memory/__tests__/memory-retrospective-enqueue.test.ts +2 -50
- package/src/memory/__tests__/memory-retrospective-job.test.ts +407 -10
- package/src/memory/conversation-crud.ts +133 -43
- package/src/memory/conversation-queries.ts +87 -1
- package/src/memory/conversation-title-service.ts +26 -4
- package/src/memory/db-init.ts +22 -0
- package/src/memory/delivery-crud.ts +41 -0
- package/src/memory/delivery-status.ts +141 -15
- package/src/memory/external-conversation-store.ts +32 -1
- package/src/memory/graph/__tests__/conversation-graph-memory-v2-routing.test.ts +84 -3
- package/src/memory/graph/conversation-graph-memory.ts +18 -6
- package/src/memory/graph/tools.ts +6 -37
- package/src/memory/invite-store.ts +53 -0
- package/src/memory/jobs-worker.ts +21 -1
- package/src/memory/llm-request-log-source-clickhouse.ts +7 -2
- package/src/memory/llm-request-log-store.ts +92 -1
- package/src/memory/memory-retrospective-constants.ts +28 -0
- package/src/memory/memory-retrospective-enqueue.ts +4 -22
- package/src/memory/memory-retrospective-job.ts +438 -21
- package/src/memory/memory-retrospective-startup-cleanup.ts +3 -3
- package/src/memory/memory-v2-activation-log-store.ts +26 -8
- package/src/memory/migrations/100-core-tables.ts +1 -0
- package/src/memory/migrations/109-external-conversation-bindings.ts +1 -0
- package/src/memory/migrations/250-provider-connection-base-url-and-models.ts +28 -0
- package/src/memory/migrations/251-a2a-tasks.ts +49 -0
- package/src/memory/migrations/252-llm-request-log-agent-loop-exit-reason.ts +32 -0
- package/src/memory/migrations/253-conversation-last-notified-profile.ts +15 -0
- package/src/memory/migrations/253-document-comments.ts +47 -0
- package/src/memory/migrations/254-external-conversation-binding-chat-name.ts +43 -0
- package/src/memory/migrations/255-channel-inbound-delivery-attempts.ts +24 -0
- package/src/memory/migrations/256-memory-v2-injection-events.ts +113 -0
- package/src/memory/migrations/257-strip-base-url-non-openai-compatible.ts +22 -0
- package/src/memory/migrations/258-onboarding-events-prior-assistants.ts +13 -0
- package/src/memory/migrations/259-conversation-cleaned-at.ts +33 -0
- package/src/memory/migrations/index.ts +20 -0
- package/src/memory/migrations/registry.ts +33 -0
- package/src/memory/onboarding-events-store.ts +7 -0
- package/src/memory/schema/a2a.ts +15 -0
- package/src/memory/schema/calls.ts +1 -0
- package/src/memory/schema/conversations.ts +3 -0
- package/src/memory/schema/index.ts +1 -0
- package/src/memory/schema/inference.ts +2 -0
- package/src/memory/schema/infrastructure.ts +2 -0
- package/src/memory/v2/__tests__/activation-store.test.ts +25 -23
- package/src/memory/v2/__tests__/cli-command-store.test.ts +404 -0
- package/src/memory/v2/__tests__/frontmatter-sweep.test.ts +25 -4
- package/src/memory/v2/__tests__/injection-events.test.ts +318 -0
- package/src/memory/v2/__tests__/injection.test.ts +221 -17
- package/src/memory/v2/__tests__/page-index.test.ts +365 -1
- package/src/memory/v2/__tests__/router.test.ts +489 -1
- package/src/memory/v2/__tests__/static-context.test.ts +12 -1
- package/src/memory/v2/activation-store.ts +14 -16
- package/src/memory/v2/cli-command-content.ts +19 -0
- package/src/memory/v2/cli-command-store.ts +304 -0
- package/src/memory/v2/consolidation-job.ts +14 -0
- package/src/memory/v2/frontmatter-sweep.ts +7 -1
- package/src/memory/v2/injection-events.ts +101 -0
- package/src/memory/v2/injection.ts +69 -29
- package/src/memory/v2/page-index.ts +246 -19
- package/src/memory/v2/page-store.ts +18 -0
- package/src/memory/v2/router.ts +209 -55
- package/src/memory/v2/static-context.ts +4 -4
- package/src/memory/v2/types.ts +23 -0
- package/src/messaging/providers/a2a/__tests__/deliver.test.ts +274 -0
- package/src/messaging/providers/a2a/deliver.ts +156 -0
- package/src/messaging/providers/gmail/client.ts +9 -2
- package/src/messaging/providers/index.ts +18 -3
- package/src/messaging/providers/slack/__tests__/adapter-mention-rendering.test.ts +329 -3
- package/src/messaging/providers/slack/__tests__/adapter-token-routing.test.ts +34 -1
- package/src/messaging/providers/slack/adapter.ts +178 -25
- package/src/messaging/providers/slack/api.test.ts +54 -0
- package/src/messaging/providers/slack/api.ts +119 -3
- package/src/messaging/providers/slack/client.ts +12 -0
- package/src/messaging/providers/slack/deep-link.ts +20 -1
- package/src/messaging/providers/slack/message-metadata.test.ts +48 -0
- package/src/messaging/providers/slack/message-metadata.ts +156 -0
- package/src/messaging/providers/slack/render-transcript.test.ts +107 -75
- package/src/messaging/providers/slack/render-transcript.ts +176 -49
- package/src/messaging/providers/slack/send.test.ts +77 -0
- package/src/messaging/providers/slack/send.ts +8 -2
- package/src/messaging/providers/slack/types.ts +14 -0
- package/src/notifications/__tests__/broadcaster.test.ts +203 -0
- package/src/notifications/__tests__/decision-engine.test.ts +283 -0
- package/src/notifications/__tests__/deterministic-checks.test.ts +286 -0
- package/src/notifications/__tests__/emit-signal-home-feed.test.ts +5 -1
- package/src/notifications/__tests__/home-feed-side-effect.test.ts +521 -36
- package/src/notifications/adapters/macos.ts +12 -2
- package/src/notifications/broadcaster.ts +29 -4
- package/src/notifications/conversation-seed-composer.ts +14 -2
- package/src/notifications/copy-composer.ts +17 -64
- package/src/notifications/decision-engine.ts +111 -44
- package/src/notifications/deferred-emit.ts +135 -0
- package/src/notifications/deterministic-checks.ts +96 -0
- package/src/notifications/emit-signal.ts +10 -1
- package/src/notifications/home-feed-side-effect.ts +136 -27
- package/src/notifications/signal.ts +0 -4
- package/src/notifications/types.ts +8 -0
- package/src/oauth/connect-orchestrator.ts +3 -0
- package/src/oauth/credential-token-resolver.ts +2 -0
- package/src/oauth/manual-token-connection.ts +19 -0
- package/src/oauth/oauth-store.ts +12 -0
- package/src/oauth/platform-connection.test.ts +43 -3
- package/src/oauth/platform-connection.ts +13 -4
- package/src/oauth/seed-providers.ts +22 -0
- package/src/permissions/prompter.ts +5 -2
- package/src/permissions/secret-prompter.ts +4 -1
- package/src/plugins/defaults/injectors.ts +118 -26
- package/src/plugins/external-plugin-loader.ts +82 -10
- package/src/plugins/types.ts +16 -7
- package/src/prompts/__tests__/system-prompt.test.ts +44 -45
- package/src/prompts/__tests__/task-progress-hint-section.test.ts +4 -8
- package/src/prompts/normalize-onboarding.ts +40 -0
- package/src/prompts/sections.ts +32 -14
- package/src/prompts/system-prompt.ts +105 -76
- package/src/prompts/template-detection.ts +37 -0
- package/src/prompts/templates/BOOTSTRAP-CONTENT-AUTOMATION.md +141 -0
- package/src/prompts/templates/BOOTSTRAP.md +13 -5
- package/src/prompts/templates/VOICE.md +3 -0
- package/src/prompts/templates/system-sections.ts +51 -10
- package/src/providers/__tests__/inference.test.ts +2 -0
- package/src/providers/anthropic/client.ts +132 -5
- package/src/providers/call-site-routing.ts +24 -6
- package/src/providers/connection-resolution.ts +63 -13
- package/src/providers/fireworks/client.ts +20 -2
- package/src/providers/inference/__tests__/adapter-factory-openai-compatible.test.ts +74 -0
- package/src/providers/inference/__tests__/base-url-route-validation.test.ts +342 -0
- package/src/providers/inference/__tests__/base-url-security.test.ts +189 -0
- package/src/providers/inference/__tests__/codex-token-refresh.test.ts +254 -0
- package/src/providers/inference/__tests__/connections-openai-compatible.test.ts +175 -0
- package/src/providers/inference/__tests__/connections-status-label.test.ts +15 -0
- package/src/providers/inference/adapter-factory.ts +24 -21
- package/src/providers/inference/auth.ts +15 -3
- package/src/providers/inference/backfill.ts +14 -1
- package/src/providers/inference/codex-token-refresh.ts +128 -0
- package/src/providers/inference/connections.ts +85 -5
- package/src/providers/inference/resolve-auth.ts +50 -5
- package/src/providers/model-catalog.ts +244 -242
- package/src/providers/model-intents.ts +3 -3
- package/src/providers/openai/__tests__/chat-completions-provider-reasoning.test.ts +235 -0
- package/src/providers/openai/chat-completions-provider.ts +215 -25
- package/src/providers/openai/responses-provider.ts +9 -3
- package/src/providers/openrouter/client.ts +46 -4
- package/src/providers/platform-proxy/constants.ts +3 -4
- package/src/providers/provider-catalog-visibility.ts +3 -1
- package/src/providers/provider-send-message.ts +27 -12
- package/src/providers/registry.ts +30 -1
- package/src/providers/types.ts +25 -0
- package/src/runtime/__tests__/agent-wake.test.ts +214 -0
- package/src/runtime/__tests__/background-job-runner.test.ts +128 -0
- package/src/runtime/agent-wake.ts +212 -57
- package/src/runtime/auth/route-policy.ts +20 -3
- package/src/runtime/background-job-runner.ts +26 -0
- package/src/runtime/channel-reply-delivery.ts +182 -47
- package/src/runtime/channel-retry-sweep.ts +141 -16
- package/src/runtime/http-server.ts +7 -16
- package/src/runtime/http-types.ts +7 -51
- package/src/runtime/pending-interactions.ts +51 -8
- package/src/runtime/routes/__tests__/consolidation-routes.test.ts +258 -0
- package/src/runtime/routes/__tests__/content-source-routes.test.ts +162 -0
- package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +121 -5
- package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +275 -44
- package/src/runtime/routes/__tests__/llm-call-sites-routes.test.ts +12 -0
- package/src/runtime/routes/__tests__/memory-v2-routes.test.ts +14 -0
- package/src/runtime/routes/__tests__/memory-v2-simulate-route.test.ts +271 -0
- package/src/runtime/routes/__tests__/sanity-routes.test.ts +280 -0
- package/src/runtime/routes/__tests__/slack-channel-routes.test.ts +266 -0
- package/src/runtime/routes/approval-routes.ts +4 -1
- package/src/runtime/routes/channel-availability-routes.ts +5 -0
- package/src/runtime/routes/chatgpt-subscription-auth-routes.ts +246 -0
- package/src/runtime/routes/consolidation-routes.ts +100 -0
- package/src/runtime/routes/content-source-routes.ts +78 -0
- package/src/runtime/routes/conversation-cli-routes.ts +146 -1
- package/src/runtime/routes/conversation-query-routes.ts +130 -12
- package/src/runtime/routes/conversation-routes.ts +288 -76
- package/src/runtime/routes/document-comments-routes.ts +287 -0
- package/src/runtime/routes/documents-routes.ts +33 -0
- package/src/runtime/routes/home-feed-routes.ts +6 -3
- package/src/runtime/routes/host-app-control-routes.ts +1 -1
- package/src/runtime/routes/host-browser-routes.ts +8 -1
- package/src/runtime/routes/identity-routes.ts +21 -0
- package/src/runtime/routes/inbound-message-handler.ts +288 -58
- package/src/runtime/routes/inbound-stages/background-dispatch.test.ts +365 -6
- package/src/runtime/routes/inbound-stages/background-dispatch.ts +283 -82
- package/src/runtime/routes/index.ts +14 -4
- package/src/runtime/routes/inference-provider-connection-routes.ts +192 -3
- package/src/runtime/routes/integrations/a2a.ts +294 -0
- package/src/runtime/routes/llm-call-sites-routes.ts +11 -1
- package/src/runtime/routes/log-export-routes.ts +39 -0
- package/src/runtime/routes/memory-v2-routes.ts +217 -0
- package/src/runtime/routes/notification-routes.ts +19 -2
- package/src/runtime/routes/question-routes.ts +4 -1
- package/src/runtime/routes/sanity-routes.ts +159 -0
- package/src/runtime/routes/slack-channel-routes.ts +187 -0
- package/src/runtime/routes/subagents-routes.ts +41 -0
- package/src/runtime/services/conversation-serializer.ts +30 -4
- package/src/schedule/integration-status.ts +3 -1
- package/src/security/__tests__/oauth2-device-code.test.ts +479 -0
- package/src/security/oauth2-device-code.ts +307 -0
- package/src/security/oauth2.ts +26 -9
- package/src/security/secure-keys.ts +5 -0
- package/src/skills/catalog-install.ts +6 -2
- package/src/subagent/manager.ts +2 -0
- package/src/tools/browser/__tests__/pinned-tabs.test.ts +80 -0
- package/src/tools/browser/browser-execution.ts +93 -0
- package/src/tools/browser/cdp-client/__tests__/factory.test.ts +28 -0
- package/src/tools/browser/cdp-client/__tests__/types.test.ts +1 -0
- package/src/tools/browser/cdp-client/cdp-inspect-client.ts +10 -0
- package/src/tools/browser/cdp-client/extension-cdp-client.ts +15 -1
- package/src/tools/browser/cdp-client/factory.ts +87 -3
- package/src/tools/browser/cdp-client/local-cdp-client.ts +9 -0
- package/src/tools/browser/cdp-client/types.ts +36 -0
- package/src/tools/browser/pinned-tabs.ts +90 -0
- package/src/tools/document/document-comment-tool.test.ts +379 -0
- package/src/tools/document/document-comment-tool.ts +156 -0
- package/src/tools/document/document-tool.ts +128 -2
- package/src/tools/memory/register.ts +1 -9
- package/src/tools/network/__tests__/web-fetch-metadata.test.ts +229 -0
- package/src/tools/network/__tests__/web-search-metadata.test.ts +346 -0
- package/src/tools/network/domain-normalize.ts +17 -0
- package/src/tools/network/web-fetch.ts +213 -64
- package/src/tools/network/web-search.ts +191 -66
- package/src/tools/registry.ts +2 -2
- package/src/tools/terminal/safe-env.ts +3 -2
- package/src/tools/tool-approval-handler.ts +19 -12
- package/src/tools/types.ts +41 -2
- package/src/tools/ui-surface/definitions.ts +3 -1
- package/src/types/onboarding-context.ts +4 -0
- package/src/util/__tests__/favicon.test.ts +84 -0
- package/src/util/favicon.ts +40 -0
- package/src/util/platform.ts +0 -5
- package/src/workspace/git-service.ts +75 -4
- package/src/workspace/migrations/087-memory-router-balanced-profile.ts +91 -0
- package/src/workspace/migrations/088-deprecate-background-conversation-override.ts +103 -0
- package/src/workspace/migrations/registry.ts +4 -0
- package/src/__tests__/guardian-action-conversation-turn.test.ts +0 -441
- package/src/config/bundled-skills/document/SKILL.md +0 -54
- package/src/config/bundled-skills/document/TOOLS.json +0 -106
- package/src/daemon/seed-files.ts +0 -18
- package/src/memory/graph/__tests__/remember-description.test.ts +0 -55
- package/src/runtime/guardian-action-conversation-turn.ts +0 -99
- package/src/runtime/routes/interface-routes.ts +0 -43
- /package/src/config/bundled-skills/{document → document-editor}/tools/document-create.ts +0 -0
- /package/src/config/bundled-skills/{document → document-editor}/tools/document-delete.ts +0 -0
- /package/src/config/bundled-skills/{document → document-editor}/tools/document-list.ts +0 -0
- /package/src/config/bundled-skills/{document → document-editor}/tools/document-read.ts +0 -0
- /package/src/config/bundled-skills/{document → document-editor}/tools/document-update.ts +0 -0
|
@@ -12,9 +12,14 @@ import { findGuardianForChannel } from "../../../contacts/contact-store.js";
|
|
|
12
12
|
import type { ServerMessage } from "../../../daemon/message-protocol.js";
|
|
13
13
|
import type { TrustContext } from "../../../daemon/trust-context.js";
|
|
14
14
|
import { updateDeliveredSegmentCount } from "../../../memory/delivery-channels.js";
|
|
15
|
-
import { linkMessage } from "../../../memory/delivery-crud.js";
|
|
16
15
|
import {
|
|
16
|
+
linkMessage,
|
|
17
|
+
storeReplyMessageId,
|
|
18
|
+
} from "../../../memory/delivery-crud.js";
|
|
19
|
+
import {
|
|
20
|
+
markDeliveryDelivered,
|
|
17
21
|
markProcessed,
|
|
22
|
+
recordDeliveryFailure,
|
|
18
23
|
recordProcessingFailure,
|
|
19
24
|
} from "../../../memory/delivery-status.js";
|
|
20
25
|
import {
|
|
@@ -76,7 +81,6 @@ export interface BackgroundProcessingParams {
|
|
|
76
81
|
externalChatId: string;
|
|
77
82
|
trustCtx: TrustContext;
|
|
78
83
|
metadataHints: string[];
|
|
79
|
-
slackRuntimeContextNotice?: string;
|
|
80
84
|
metadataUxBrief?: string;
|
|
81
85
|
replyCallbackUrl?: string;
|
|
82
86
|
assistantId?: string;
|
|
@@ -85,6 +89,8 @@ export interface BackgroundProcessingParams {
|
|
|
85
89
|
sourceLanguageCode?: string;
|
|
86
90
|
/** Chat type from the gateway (e.g. "private", "group", "supergroup"). */
|
|
87
91
|
chatType?: string;
|
|
92
|
+
/** IANA timezone reported by the active client for the current turn. */
|
|
93
|
+
clientTimezone?: string;
|
|
88
94
|
/** Slack app_mention/direct bot mention signal from the gateway. */
|
|
89
95
|
slackBotMentioned?: boolean;
|
|
90
96
|
/**
|
|
@@ -114,7 +120,6 @@ export function processChannelMessageInBackground(
|
|
|
114
120
|
externalChatId,
|
|
115
121
|
trustCtx,
|
|
116
122
|
metadataHints,
|
|
117
|
-
slackRuntimeContextNotice,
|
|
118
123
|
metadataUxBrief,
|
|
119
124
|
replyCallbackUrl,
|
|
120
125
|
assistantId,
|
|
@@ -122,6 +127,7 @@ export function processChannelMessageInBackground(
|
|
|
122
127
|
commandIntent,
|
|
123
128
|
sourceLanguageCode,
|
|
124
129
|
chatType,
|
|
130
|
+
clientTimezone,
|
|
125
131
|
slackBotMentioned,
|
|
126
132
|
slackInbound,
|
|
127
133
|
} = params;
|
|
@@ -190,8 +196,10 @@ export function processChannelMessageInBackground(
|
|
|
190
196
|
// rejected as already-processing and our update would erase that
|
|
191
197
|
// in-flight turn's mapping. Snapshot the prior state here and restore
|
|
192
198
|
// it in the `already processing` rejection path below.
|
|
193
|
-
let priorSlackMapping: {
|
|
194
|
-
|
|
199
|
+
let priorSlackMapping: {
|
|
200
|
+
threadTs: string;
|
|
201
|
+
channelId: string;
|
|
202
|
+
} | null = null;
|
|
195
203
|
let slackMappingMutated = false;
|
|
196
204
|
if (sourceChannel === "slack" && replyCallbackUrl) {
|
|
197
205
|
priorSlackMapping = peekThreadMapping(conversationId);
|
|
@@ -219,76 +227,103 @@ export function processChannelMessageInBackground(
|
|
|
219
227
|
: {}),
|
|
220
228
|
}
|
|
221
229
|
: undefined;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
assistantId,
|
|
234
|
-
trustContext: trustCtx,
|
|
235
|
-
isInteractive: resolveRoutingState(trustCtx).promptWaitingAllowed,
|
|
236
|
-
...(displayContent !== undefined ? { displayContent } : {}),
|
|
237
|
-
...(cmdIntent ? { commandIntent: cmdIntent } : {}),
|
|
238
|
-
...(slackRuntimeContextNotice ? { slackRuntimeContextNotice } : {}),
|
|
239
|
-
...(slackInbound ? { slackInbound } : {}),
|
|
240
|
-
...(slackThinkingStatus
|
|
241
|
-
? {
|
|
242
|
-
onEvent: (msg: ServerMessage) =>
|
|
243
|
-
slackThinkingStatus.observeEvent(msg),
|
|
244
|
-
}
|
|
245
|
-
: {}),
|
|
246
|
-
},
|
|
247
|
-
sourceChannel,
|
|
248
|
-
sourceInterface,
|
|
249
|
-
);
|
|
250
|
-
linkMessage(eventId, userMessageId);
|
|
251
|
-
markProcessed(eventId);
|
|
230
|
+
let replyMessageId: string | undefined;
|
|
231
|
+
const observeAgentEvent = (msg: ServerMessage): void => {
|
|
232
|
+
if (
|
|
233
|
+
msg.type === "message_complete" &&
|
|
234
|
+
(msg.source === undefined || msg.source === "main") &&
|
|
235
|
+
typeof msg.messageId === "string"
|
|
236
|
+
) {
|
|
237
|
+
replyMessageId = msg.messageId;
|
|
238
|
+
}
|
|
239
|
+
slackThinkingStatus?.observeEvent(msg);
|
|
240
|
+
};
|
|
252
241
|
|
|
253
|
-
|
|
254
|
-
|
|
242
|
+
let userMessageId: string | undefined;
|
|
243
|
+
try {
|
|
244
|
+
const result = await processMessage(
|
|
255
245
|
conversationId,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
assistantId,
|
|
246
|
+
content,
|
|
247
|
+
attachmentIds,
|
|
259
248
|
{
|
|
260
|
-
|
|
261
|
-
|
|
249
|
+
transport: {
|
|
250
|
+
channelId: sourceChannel,
|
|
251
|
+
hints: metadataHints.length > 0 ? metadataHints : undefined,
|
|
252
|
+
uxBrief: metadataUxBrief,
|
|
253
|
+
chatType,
|
|
254
|
+
...(clientTimezone ? { clientTimezone } : {}),
|
|
255
|
+
},
|
|
256
|
+
assistantId,
|
|
257
|
+
trustContext: trustCtx,
|
|
258
|
+
isInteractive: resolveRoutingState(trustCtx).promptWaitingAllowed,
|
|
259
|
+
...(displayContent !== undefined ? { displayContent } : {}),
|
|
260
|
+
...(cmdIntent ? { commandIntent: cmdIntent } : {}),
|
|
261
|
+
...(slackInbound ? { slackInbound } : {}),
|
|
262
|
+
onEvent: observeAgentEvent,
|
|
262
263
|
},
|
|
264
|
+
sourceChannel,
|
|
265
|
+
sourceInterface,
|
|
266
|
+
);
|
|
267
|
+
userMessageId = result.messageId;
|
|
268
|
+
linkMessage(eventId, userMessageId);
|
|
269
|
+
markProcessed(eventId);
|
|
270
|
+
replyMessageId ??= result.assistantMessageId;
|
|
271
|
+
if (replyMessageId) {
|
|
272
|
+
storeReplyMessageId(eventId, replyMessageId);
|
|
273
|
+
}
|
|
274
|
+
} catch (err) {
|
|
275
|
+
// When another turn is already processing this conversation,
|
|
276
|
+
// `prepareConversationForMessage` throws before any of this turn's
|
|
277
|
+
// work runs. Our pre-await mapping update would otherwise stomp the
|
|
278
|
+
// in-flight turn's mapping, causing its outbound persistence to
|
|
279
|
+
// record `slackMeta` with the wrong (or missing) `threadTs`. Restore
|
|
280
|
+
// the snapshot so the in-flight turn sees the mapping it installed.
|
|
281
|
+
if (
|
|
282
|
+
slackMappingMutated &&
|
|
283
|
+
err instanceof Error &&
|
|
284
|
+
err.message.includes("already processing a message")
|
|
285
|
+
) {
|
|
286
|
+
if (priorSlackMapping) {
|
|
287
|
+
setThreadTs(
|
|
288
|
+
conversationId,
|
|
289
|
+
priorSlackMapping.channelId,
|
|
290
|
+
priorSlackMapping.threadTs,
|
|
291
|
+
);
|
|
292
|
+
} else {
|
|
293
|
+
clearThreadTs(conversationId);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
log.error(
|
|
297
|
+
{ err, conversationId },
|
|
298
|
+
"Background channel message processing failed",
|
|
263
299
|
);
|
|
300
|
+
recordProcessingFailure(eventId, err);
|
|
301
|
+
return;
|
|
264
302
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
// in-flight turn's mapping, causing its outbound persistence to
|
|
270
|
-
// record `slackMeta` with the wrong (or missing) `threadTs`. Restore
|
|
271
|
-
// the snapshot so the in-flight turn sees the mapping it installed.
|
|
272
|
-
if (
|
|
273
|
-
slackMappingMutated &&
|
|
274
|
-
err instanceof Error &&
|
|
275
|
-
err.message.includes("already processing a message")
|
|
276
|
-
) {
|
|
277
|
-
if (priorSlackMapping) {
|
|
278
|
-
setThreadTs(
|
|
303
|
+
|
|
304
|
+
if (replyCallbackUrl) {
|
|
305
|
+
try {
|
|
306
|
+
await deliverReplyViaCallback(
|
|
279
307
|
conversationId,
|
|
280
|
-
|
|
281
|
-
|
|
308
|
+
externalChatId,
|
|
309
|
+
replyCallbackUrl,
|
|
310
|
+
assistantId,
|
|
311
|
+
{
|
|
312
|
+
messageId: replyMessageId,
|
|
313
|
+
sinceMessageId: userMessageId,
|
|
314
|
+
onSegmentDelivered: (count) =>
|
|
315
|
+
updateDeliveredSegmentCount(eventId, count),
|
|
316
|
+
},
|
|
317
|
+
);
|
|
318
|
+
markDeliveryDelivered(eventId);
|
|
319
|
+
} catch (err) {
|
|
320
|
+
log.error(
|
|
321
|
+
{ err, conversationId },
|
|
322
|
+
"Background channel reply delivery failed",
|
|
282
323
|
);
|
|
283
|
-
|
|
284
|
-
clearThreadTs(conversationId);
|
|
324
|
+
recordDeliveryFailure(eventId, err);
|
|
285
325
|
}
|
|
286
326
|
}
|
|
287
|
-
log.error(
|
|
288
|
-
{ err, conversationId },
|
|
289
|
-
"Background channel message processing failed",
|
|
290
|
-
);
|
|
291
|
-
recordProcessingFailure(eventId, err);
|
|
292
327
|
} finally {
|
|
293
328
|
stopTypingHeartbeat?.();
|
|
294
329
|
slackThinkingStatus?.stop();
|
|
@@ -363,6 +398,20 @@ type SlackThinkingStatusController = {
|
|
|
363
398
|
stop: () => void;
|
|
364
399
|
};
|
|
365
400
|
|
|
401
|
+
type SlackThinkingStatusHandle = {
|
|
402
|
+
updateLoadingMessages: (loadingMessages?: string[]) => void;
|
|
403
|
+
clear: () => void;
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
type TaskProgressStep = {
|
|
407
|
+
label: string;
|
|
408
|
+
status: "pending" | "in_progress" | "completed" | "failed";
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
type TaskProgressData = {
|
|
412
|
+
steps: TaskProgressStep[];
|
|
413
|
+
};
|
|
414
|
+
|
|
366
415
|
const NO_RESPONSE_RE = /^\s*<no_response\s*\/?>\s*$/i;
|
|
367
416
|
const NO_RESPONSE_INLINE_RE = /<no_response\s*\/?>/gi;
|
|
368
417
|
const NO_RESPONSE_SENTINEL_FORMS = [
|
|
@@ -431,16 +480,51 @@ function createSlackThinkingStatusController(params: {
|
|
|
431
480
|
const callbackUrl = replyCallbackUrl;
|
|
432
481
|
|
|
433
482
|
let stopped = false;
|
|
434
|
-
let
|
|
483
|
+
let slackThinkingStatus: SlackThinkingStatusHandle | undefined;
|
|
435
484
|
let observedAssistantText = "";
|
|
485
|
+
let currentLoadingMessages: string[] | undefined = startImmediately
|
|
486
|
+
? [...SLACK_GENERIC_LOADING_MESSAGES]
|
|
487
|
+
: undefined;
|
|
488
|
+
let lastSentLoadingMessageKey: string | undefined;
|
|
489
|
+
const taskProgressBySurfaceId = new Map<string, TaskProgressData>();
|
|
436
490
|
|
|
437
491
|
const start = (): void => {
|
|
438
|
-
if (stopped ||
|
|
439
|
-
|
|
492
|
+
if (stopped || slackThinkingStatus) return;
|
|
493
|
+
slackThinkingStatus = setSlackThinkingStatus(
|
|
440
494
|
callbackUrl,
|
|
441
495
|
chatId,
|
|
442
496
|
assistantId,
|
|
497
|
+
currentLoadingMessages,
|
|
443
498
|
);
|
|
499
|
+
lastSentLoadingMessageKey = getLoadingMessagesKey(currentLoadingMessages);
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
const maybeUpdateLoadingMessages = (): void => {
|
|
503
|
+
const nextLoadingMessageKey = getLoadingMessagesKey(currentLoadingMessages);
|
|
504
|
+
if (nextLoadingMessageKey === lastSentLoadingMessageKey) return;
|
|
505
|
+
lastSentLoadingMessageKey = nextLoadingMessageKey;
|
|
506
|
+
slackThinkingStatus?.updateLoadingMessages(currentLoadingMessages);
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
const observeTaskProgress = (msg: ServerMessage): void => {
|
|
510
|
+
if (msg.type === "ui_surface_show") {
|
|
511
|
+
const progress = getTaskProgressDataFromSurfaceData(msg.data);
|
|
512
|
+
if (!progress) return;
|
|
513
|
+
taskProgressBySurfaceId.set(msg.surfaceId, progress);
|
|
514
|
+
} else if (msg.type === "ui_surface_update") {
|
|
515
|
+
const existing = taskProgressBySurfaceId.get(msg.surfaceId);
|
|
516
|
+
const progress = mergeTaskProgressData(existing, msg.data);
|
|
517
|
+
if (!progress) return;
|
|
518
|
+
taskProgressBySurfaceId.set(msg.surfaceId, progress);
|
|
519
|
+
} else {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
currentLoadingMessages =
|
|
524
|
+
getTaskProgressLoadingMessage(
|
|
525
|
+
taskProgressBySurfaceId.get(msg.surfaceId),
|
|
526
|
+
) ?? [];
|
|
527
|
+
maybeUpdateLoadingMessages();
|
|
444
528
|
};
|
|
445
529
|
|
|
446
530
|
if (startImmediately) {
|
|
@@ -449,8 +533,14 @@ function createSlackThinkingStatusController(params: {
|
|
|
449
533
|
|
|
450
534
|
return {
|
|
451
535
|
observeEvent(msg) {
|
|
452
|
-
if (stopped
|
|
453
|
-
|
|
536
|
+
if (stopped) return;
|
|
537
|
+
|
|
538
|
+
if (msg.type === "ui_surface_show" || msg.type === "ui_surface_update") {
|
|
539
|
+
observeTaskProgress(msg);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if (slackThinkingStatus || msg.type !== "assistant_text_delta") return;
|
|
454
544
|
|
|
455
545
|
observedAssistantText += msg.text;
|
|
456
546
|
if (shouldStartSlackThinkingStatusForText(observedAssistantText)) {
|
|
@@ -459,16 +549,91 @@ function createSlackThinkingStatusController(params: {
|
|
|
459
549
|
},
|
|
460
550
|
stop() {
|
|
461
551
|
stopped = true;
|
|
462
|
-
|
|
552
|
+
slackThinkingStatus?.clear();
|
|
463
553
|
},
|
|
464
554
|
};
|
|
465
555
|
}
|
|
466
556
|
|
|
467
557
|
const SLACK_THINKING_MAX_DURATION_MS = 120_000;
|
|
558
|
+
const SLACK_GENERIC_LOADING_MESSAGES = ["Working on it..."] as const;
|
|
559
|
+
const SLACK_THINKING_STATUSES = ["is on it", "is working hard"] as const;
|
|
560
|
+
|
|
561
|
+
function getRandomSlackThinkingStatus(): string {
|
|
562
|
+
return SLACK_THINKING_STATUSES[
|
|
563
|
+
Math.floor(Math.random() * SLACK_THINKING_STATUSES.length)
|
|
564
|
+
]!;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function getLoadingMessagesKey(loadingMessages?: string[]): string | undefined {
|
|
568
|
+
return loadingMessages?.join("\n");
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
572
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function getTaskProgressDataFromSurfaceData(
|
|
576
|
+
data: unknown,
|
|
577
|
+
): TaskProgressData | undefined {
|
|
578
|
+
if (!isRecord(data)) return undefined;
|
|
579
|
+
if (data.template !== "task_progress") return undefined;
|
|
580
|
+
return parseTaskProgressData(data.templateData);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function parseTaskProgressData(value: unknown): TaskProgressData | undefined {
|
|
584
|
+
if (!isRecord(value) || !Array.isArray(value.steps)) return undefined;
|
|
585
|
+
|
|
586
|
+
const steps = value.steps.flatMap((step): TaskProgressStep[] => {
|
|
587
|
+
if (!isRecord(step)) return [];
|
|
588
|
+
if (typeof step.label !== "string") return [];
|
|
589
|
+
if (
|
|
590
|
+
step.status !== "pending" &&
|
|
591
|
+
step.status !== "in_progress" &&
|
|
592
|
+
step.status !== "completed" &&
|
|
593
|
+
step.status !== "failed"
|
|
594
|
+
) {
|
|
595
|
+
return [];
|
|
596
|
+
}
|
|
597
|
+
return [{ label: step.label, status: step.status }];
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
return steps.length > 0 ? { steps } : undefined;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function mergeTaskProgressData(
|
|
604
|
+
existing: TaskProgressData | undefined,
|
|
605
|
+
data: unknown,
|
|
606
|
+
): TaskProgressData | undefined {
|
|
607
|
+
if (!isRecord(data)) return existing;
|
|
608
|
+
const update = getTaskProgressDataFromSurfaceData(data);
|
|
609
|
+
if (update) return update;
|
|
610
|
+
if (!existing || !("templateData" in data)) return existing;
|
|
611
|
+
|
|
612
|
+
return parseTaskProgressData({
|
|
613
|
+
steps: existing.steps,
|
|
614
|
+
...(isRecord(data.templateData) ? data.templateData : {}),
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function getTaskProgressLoadingMessage(
|
|
619
|
+
progress: TaskProgressData | undefined,
|
|
620
|
+
): string[] | undefined {
|
|
621
|
+
if (!progress) return undefined;
|
|
622
|
+
|
|
623
|
+
const activeStepIndex = progress.steps.findIndex(
|
|
624
|
+
(step) => step.status === "in_progress",
|
|
625
|
+
);
|
|
626
|
+
if (activeStepIndex < 0) return undefined;
|
|
627
|
+
|
|
628
|
+
const activeStep = progress.steps[activeStepIndex]!;
|
|
629
|
+
return [
|
|
630
|
+
`In progress (${activeStepIndex + 1}/${progress.steps.length}): ${activeStep.label}`,
|
|
631
|
+
];
|
|
632
|
+
}
|
|
468
633
|
|
|
469
634
|
/**
|
|
470
|
-
* Set
|
|
471
|
-
*
|
|
635
|
+
* Set Slack Assistants API status on the thread and return a handle for
|
|
636
|
+
* updating loading messages or clearing the indicator.
|
|
472
637
|
*
|
|
473
638
|
* A safety timer auto-clears the status after {@link SLACK_THINKING_MAX_DURATION_MS}
|
|
474
639
|
* to prevent a stuck indicator when `processMessage` hangs.
|
|
@@ -477,7 +642,8 @@ function setSlackThinkingStatus(
|
|
|
477
642
|
callbackUrl: string,
|
|
478
643
|
chatId: string,
|
|
479
644
|
assistantId?: string,
|
|
480
|
-
|
|
645
|
+
loadingMessages?: string[],
|
|
646
|
+
): SlackThinkingStatusHandle {
|
|
481
647
|
let cleared = false;
|
|
482
648
|
|
|
483
649
|
// Extract the thread timestamp from the callback URL so we can target
|
|
@@ -487,7 +653,12 @@ function setSlackThinkingStatus(
|
|
|
487
653
|
// For non-threaded DMs, fall back to emoji reaction on the original message.
|
|
488
654
|
if (!threadTs) {
|
|
489
655
|
const messageTs = extractMessageTsFromCallbackUrl(callbackUrl);
|
|
490
|
-
if (!messageTs)
|
|
656
|
+
if (!messageTs) {
|
|
657
|
+
return {
|
|
658
|
+
updateLoadingMessages: () => {},
|
|
659
|
+
clear: () => {},
|
|
660
|
+
};
|
|
661
|
+
}
|
|
491
662
|
|
|
492
663
|
const addPromise = deliverChannelReply(callbackUrl, {
|
|
493
664
|
chatId,
|
|
@@ -500,7 +671,7 @@ function setSlackThinkingStatus(
|
|
|
500
671
|
);
|
|
501
672
|
});
|
|
502
673
|
|
|
503
|
-
const clearReaction = () => {
|
|
674
|
+
const clearReaction = (): void => {
|
|
504
675
|
if (cleared) return;
|
|
505
676
|
cleared = true;
|
|
506
677
|
clearTimeout(safetyTimer);
|
|
@@ -524,28 +695,55 @@ function setSlackThinkingStatus(
|
|
|
524
695
|
);
|
|
525
696
|
(safetyTimer as { unref?: () => void }).unref?.();
|
|
526
697
|
|
|
527
|
-
return
|
|
698
|
+
return {
|
|
699
|
+
updateLoadingMessages: () => {},
|
|
700
|
+
clear: clearReaction,
|
|
701
|
+
};
|
|
528
702
|
}
|
|
529
703
|
|
|
530
704
|
// Track the set promise so clear waits for it to settle first,
|
|
531
705
|
// preventing a race where clear arrives at Slack before set.
|
|
532
|
-
|
|
706
|
+
let statusPromise = deliverChannelReply(callbackUrl, {
|
|
533
707
|
chatId,
|
|
534
708
|
assistantId,
|
|
535
709
|
assistantThreadStatus: {
|
|
536
710
|
channel: chatId,
|
|
537
711
|
threadTs,
|
|
538
|
-
status:
|
|
712
|
+
status: getRandomSlackThinkingStatus(),
|
|
713
|
+
...(loadingMessages ? { loadingMessages } : {}),
|
|
539
714
|
},
|
|
540
715
|
}).catch((err) => {
|
|
541
716
|
log.debug({ err, chatId, threadTs }, "Failed to set Slack thinking status");
|
|
542
717
|
});
|
|
543
718
|
|
|
544
|
-
const
|
|
719
|
+
const updateLoadingMessages = (nextLoadingMessages?: string[]): void => {
|
|
720
|
+
if (cleared) return;
|
|
721
|
+
statusPromise = statusPromise.then(() =>
|
|
722
|
+
deliverChannelReply(callbackUrl, {
|
|
723
|
+
chatId,
|
|
724
|
+
assistantId,
|
|
725
|
+
assistantThreadStatus: {
|
|
726
|
+
channel: chatId,
|
|
727
|
+
threadTs,
|
|
728
|
+
status: getRandomSlackThinkingStatus(),
|
|
729
|
+
...(nextLoadingMessages
|
|
730
|
+
? { loadingMessages: nextLoadingMessages }
|
|
731
|
+
: {}),
|
|
732
|
+
},
|
|
733
|
+
}).catch((err) => {
|
|
734
|
+
log.debug(
|
|
735
|
+
{ err, chatId, threadTs },
|
|
736
|
+
"Failed to update Slack thinking status",
|
|
737
|
+
);
|
|
738
|
+
}),
|
|
739
|
+
);
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
const clearStatus = (): void => {
|
|
545
743
|
if (cleared) return;
|
|
546
744
|
cleared = true;
|
|
547
745
|
clearTimeout(safetyTimer);
|
|
548
|
-
void
|
|
746
|
+
void statusPromise.then(() =>
|
|
549
747
|
deliverChannelReply(callbackUrl, {
|
|
550
748
|
chatId,
|
|
551
749
|
assistantId,
|
|
@@ -566,7 +764,10 @@ function setSlackThinkingStatus(
|
|
|
566
764
|
const safetyTimer = setTimeout(clearStatus, SLACK_THINKING_MAX_DURATION_MS);
|
|
567
765
|
(safetyTimer as { unref?: () => void }).unref?.();
|
|
568
766
|
|
|
569
|
-
return
|
|
767
|
+
return {
|
|
768
|
+
updateLoadingMessages,
|
|
769
|
+
clear: clearStatus,
|
|
770
|
+
};
|
|
570
771
|
}
|
|
571
772
|
|
|
572
773
|
// ---------------------------------------------------------------------------
|
|
@@ -29,10 +29,12 @@ import { ROUTES as CHANNEL_AVAILABILITY_ROUTES } from "./channel-availability-ro
|
|
|
29
29
|
import { ROUTES as CHANNEL_READINESS_ROUTES } from "./channel-readiness-routes.js";
|
|
30
30
|
import { CHANNEL_ROUTES } from "./channel-route-definitions.js";
|
|
31
31
|
import { ROUTES as CHANNEL_VERIFICATION_ROUTES } from "./channel-verification-routes.js";
|
|
32
|
+
import { ROUTES as CHATGPT_SUBSCRIPTION_AUTH_ROUTES } from "./chatgpt-subscription-auth-routes.js";
|
|
32
33
|
import { ROUTES as CLIENT_ROUTES } from "./client-routes.js";
|
|
33
34
|
import { ROUTES as CONSOLIDATION_ROUTES } from "./consolidation-routes.js";
|
|
34
35
|
import { CONTACT_PROMPT_ROUTES } from "./contact-prompt-routes.js";
|
|
35
36
|
import { ROUTES as CONTACT_ROUTES } from "./contact-routes.js";
|
|
37
|
+
import { ROUTES as CONTENT_SOURCE_ROUTES } from "./content-source-routes.js";
|
|
36
38
|
import { ROUTES as CONVERSATION_ANALYSIS_ROUTES } from "./conversation-analysis-routes.js";
|
|
37
39
|
import { ROUTES as CONVERSATION_ATTENTION_ROUTES } from "./conversation-attention-routes.js";
|
|
38
40
|
import { ROUTES as CONVERSATION_CLI_ROUTES } from "./conversation-cli-routes.js";
|
|
@@ -49,6 +51,7 @@ import { ROUTES as DEBUG_ROUTES } from "./debug-routes.js";
|
|
|
49
51
|
import { ROUTES as DEFER_ROUTES } from "./defer-routes.js";
|
|
50
52
|
import { ROUTES as DIAGNOSTICS_ROUTES } from "./diagnostics-routes.js";
|
|
51
53
|
import { ROUTES as DISK_PRESSURE_ROUTES } from "./disk-pressure-routes.js";
|
|
54
|
+
import { ROUTES as DOCUMENT_COMMENT_ROUTES } from "./document-comments-routes.js";
|
|
52
55
|
import { ROUTES as DOCUMENT_ROUTES } from "./documents-routes.js";
|
|
53
56
|
import { ROUTES as DOMAIN_ROUTES } from "./domain-routes.js";
|
|
54
57
|
import { ROUTES as EMAIL_ROUTES } from "./email-routes.js";
|
|
@@ -72,12 +75,12 @@ import { ROUTES as IMAGE_GENERATION_ROUTES } from "./image-generation-routes.js"
|
|
|
72
75
|
import { ROUTES as INFERENCE_PROFILE_SESSION_ROUTES } from "./inference-profile-session-routes.js";
|
|
73
76
|
import { ROUTES as INFERENCE_PROVIDER_CONNECTION_ROUTES } from "./inference-provider-connection-routes.js";
|
|
74
77
|
import { ROUTES as INFERENCE_SEND_ROUTES } from "./inference-send-routes.js";
|
|
75
|
-
import { ROUTES as
|
|
78
|
+
import { ROUTES as A2A_ROUTES } from "./integrations/a2a.js";
|
|
79
|
+
import { ROUTES as SLACK_CHANNEL_CONFIG_ROUTES } from "./integrations/slack/channel.js";
|
|
76
80
|
import { ROUTES as SLACK_SHARE_ROUTES } from "./integrations/slack/share.js";
|
|
77
81
|
import { ROUTES as TELEGRAM_ROUTES } from "./integrations/telegram.js";
|
|
78
82
|
import { ROUTES as TWILIO_ROUTES } from "./integrations/twilio.js";
|
|
79
83
|
import { ROUTES as VERCEL_ROUTES } from "./integrations/vercel.js";
|
|
80
|
-
import { ROUTES as INTERFACE_ROUTES } from "./interface-routes.js";
|
|
81
84
|
import { ROUTES as INTERNAL_OAUTH_ROUTES } from "./internal-oauth-routes.js";
|
|
82
85
|
import { ROUTES as INTERNAL_TWILIO_ROUTES } from "./internal-twilio-routes.js";
|
|
83
86
|
import { ROUTES as LLM_CALL_SITES_ROUTES } from "./llm-call-sites-routes.js";
|
|
@@ -101,11 +104,13 @@ import { ROUTES as PUBLISH_ROUTES } from "./publish-routes.js";
|
|
|
101
104
|
import { ROUTES as QUESTION_ROUTES } from "./question-routes.js";
|
|
102
105
|
import { ROUTES as RECORDING_ROUTES } from "./recording-routes.js";
|
|
103
106
|
import { ROUTES as RENAME_CONVERSATION_ROUTES } from "./rename-conversation-routes.js";
|
|
107
|
+
import { ROUTES as SANITY_ROUTES } from "./sanity-routes.js";
|
|
104
108
|
import { ROUTES as SCHEDULE_ROUTES } from "./schedule-routes.js";
|
|
105
109
|
import { ROUTES as SECRET_ROUTES } from "./secret-routes.js";
|
|
106
110
|
import { ROUTES as SEQUENCE_ROUTES } from "./sequence-routes.js";
|
|
107
111
|
import { ROUTES as SETTINGS_ROUTES } from "./settings-routes.js";
|
|
108
112
|
import { ROUTES as SKILL_ROUTES } from "./skills-routes.js";
|
|
113
|
+
import { ROUTES as SLACK_CHANNEL_RESOLVE_ROUTES } from "./slack-channel-routes.js";
|
|
109
114
|
import { ROUTES as STT_ROUTES } from "./stt-routes.js";
|
|
110
115
|
import { ROUTES as SUBAGENT_ROUTES } from "./subagents-routes.js";
|
|
111
116
|
import { ROUTES as SUGGEST_TRUST_RULE_ROUTES } from "./suggest-trust-rule-routes.js";
|
|
@@ -145,6 +150,7 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
145
150
|
...BOOKMARK_ROUTES,
|
|
146
151
|
...CACHE_ROUTES,
|
|
147
152
|
...CALL_ROUTES,
|
|
153
|
+
...CHATGPT_SUBSCRIPTION_AUTH_ROUTES,
|
|
148
154
|
...CHANNEL_ROUTES,
|
|
149
155
|
...CHANNEL_VERIFICATION_ROUTES,
|
|
150
156
|
...CHANNEL_AVAILABILITY_ROUTES,
|
|
@@ -153,6 +159,7 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
153
159
|
...BTW_ROUTES,
|
|
154
160
|
...BRAIN_GRAPH_ROUTES,
|
|
155
161
|
...CLIENT_ROUTES,
|
|
162
|
+
...CONTENT_SOURCE_ROUTES,
|
|
156
163
|
...CONTACT_PROMPT_ROUTES,
|
|
157
164
|
...CONTACT_ROUTES,
|
|
158
165
|
...CONVERSATION_ANALYSIS_ROUTES,
|
|
@@ -173,6 +180,7 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
173
180
|
...DIAGNOSTICS_ROUTES,
|
|
174
181
|
...DISK_PRESSURE_ROUTES,
|
|
175
182
|
...DOMAIN_ROUTES,
|
|
183
|
+
...DOCUMENT_COMMENT_ROUTES,
|
|
176
184
|
...DOCUMENT_ROUTES,
|
|
177
185
|
...EMAIL_ROUTES,
|
|
178
186
|
...EVENTS_ROUTES,
|
|
@@ -195,7 +203,6 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
195
203
|
...INFERENCE_PROFILE_SESSION_ROUTES,
|
|
196
204
|
...INFERENCE_PROVIDER_CONNECTION_ROUTES,
|
|
197
205
|
...INFERENCE_SEND_ROUTES,
|
|
198
|
-
...INTERFACE_ROUTES,
|
|
199
206
|
...INTERNAL_OAUTH_ROUTES,
|
|
200
207
|
...MCP_AUTH_ROUTES,
|
|
201
208
|
...OAUTH_CONNECT_ROUTES,
|
|
@@ -220,10 +227,13 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
220
227
|
...RECORDING_ROUTES,
|
|
221
228
|
...RENAME_CONVERSATION_ROUTES,
|
|
222
229
|
...SCHEDULE_ROUTES,
|
|
230
|
+
...SANITY_ROUTES,
|
|
223
231
|
...SECRET_ROUTES,
|
|
224
232
|
...SETTINGS_ROUTES,
|
|
225
233
|
...SKILL_ROUTES,
|
|
226
|
-
...
|
|
234
|
+
...A2A_ROUTES,
|
|
235
|
+
...SLACK_CHANNEL_CONFIG_ROUTES,
|
|
236
|
+
...SLACK_CHANNEL_RESOLVE_ROUTES,
|
|
227
237
|
...SLACK_SHARE_ROUTES,
|
|
228
238
|
...STT_ROUTES,
|
|
229
239
|
...SUGGEST_TRUST_RULE_ROUTES,
|