@vellumai/assistant 0.5.10 → 0.5.12
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/AGENTS.md +8 -0
- package/ARCHITECTURE.md +43 -43
- package/Dockerfile +3 -0
- package/docs/architecture/integrations.md +37 -42
- package/docs/architecture/memory.md +7 -12
- package/docs/credential-execution-service.md +9 -9
- package/docs/skills.md +1 -1
- package/node_modules/@vellumai/ces-contracts/src/__tests__/grants.test.ts +7 -7
- package/node_modules/@vellumai/ces-contracts/src/handles.ts +5 -4
- package/node_modules/@vellumai/credential-storage/src/index.ts +3 -3
- package/node_modules/@vellumai/credential-storage/src/static-credentials.ts +1 -1
- package/openapi.yaml +7208 -0
- package/package.json +2 -1
- package/scripts/generate-openapi.ts +562 -0
- package/src/__tests__/acp-session.test.ts +239 -44
- package/src/__tests__/assistant-feature-flag-guard.test.ts +8 -8
- package/src/__tests__/assistant-feature-flag-guardrails.test.ts +5 -86
- package/src/__tests__/assistant-feature-flags-integration.test.ts +7 -14
- package/src/__tests__/browser-skill-endstate.test.ts +1 -1
- package/src/__tests__/btw-routes.test.ts +8 -0
- package/src/__tests__/bundled-skill-retrieval-guard.test.ts +10 -10
- package/src/__tests__/catalog-cache.test.ts +164 -0
- package/src/__tests__/catalog-search.test.ts +61 -0
- package/src/__tests__/channel-approvals.test.ts +7 -7
- package/src/__tests__/channel-readiness-service.test.ts +41 -0
- package/src/__tests__/cli-command-risk-guard.test.ts +181 -6
- package/src/__tests__/config-schema.test.ts +10 -2
- package/src/__tests__/context-memory-e2e.test.ts +2 -6
- package/src/__tests__/conversation-delete-schedule-cleanup.test.ts +396 -0
- package/src/__tests__/conversation-error.test.ts +3 -2
- package/src/__tests__/conversation-skill-tools.test.ts +1 -3
- package/src/__tests__/conversation-title-service.test.ts +2 -15
- package/src/__tests__/credential-execution-feature-gates.test.ts +4 -8
- package/src/__tests__/credential-execution-managed-contract.test.ts +8 -8
- package/src/__tests__/credential-security-e2e.test.ts +4 -4
- package/src/__tests__/credential-security-invariants.test.ts +12 -18
- package/src/__tests__/credential-vault-unit.test.ts +32 -34
- package/src/__tests__/credential-vault.test.ts +25 -33
- package/src/__tests__/credentials-cli.test.ts +3 -3
- package/src/__tests__/daemon-credential-client.test.ts +2 -2
- package/src/__tests__/dynamic-skill-workflow-prompt.test.ts +1 -1
- package/src/__tests__/gateway-only-guard.test.ts +3 -0
- package/src/__tests__/heartbeat-service.test.ts +35 -0
- package/src/__tests__/host-bash-proxy.test.ts +79 -0
- package/src/__tests__/host-cu-proxy.test.ts +90 -0
- package/src/__tests__/host-file-proxy.test.ts +89 -0
- package/src/__tests__/host-shell-tool.test.ts +1 -1
- package/src/__tests__/inline-skill-load-permissions.test.ts +3 -3
- package/src/__tests__/integration-status.test.ts +5 -5
- package/src/__tests__/list-messages-attachments.test.ts +171 -0
- package/src/__tests__/llm-request-log-turn-query.test.ts +64 -0
- package/src/__tests__/log-export-workspace.test.ts +1 -1
- package/src/__tests__/mcp-abort-signal.test.ts +205 -0
- package/src/__tests__/mcp-client-auth.test.ts +1 -1
- package/src/__tests__/memory-lifecycle-e2e.test.ts +2 -2
- package/src/__tests__/memory-recall-log-store.test.ts +182 -0
- package/src/__tests__/memory-recall-quality.test.ts +6 -8
- package/src/__tests__/memory-regressions.test.ts +53 -42
- package/src/__tests__/memory-retrieval.benchmark.test.ts +5 -9
- package/src/__tests__/messaging-send-tool.test.ts +5 -5
- package/src/__tests__/messaging-skill-split.test.ts +2 -17
- package/src/__tests__/notification-telegram-adapter.test.ts +125 -0
- package/src/__tests__/oauth-cli.test.ts +203 -649
- package/src/__tests__/oauth-provider-profiles.test.ts +55 -20
- package/src/__tests__/oauth-scope-policy.test.ts +4 -6
- package/src/__tests__/onboarding-template-contract.test.ts +2 -2
- package/src/__tests__/platform-callback-registration.test.ts +119 -0
- package/src/__tests__/secret-ingress-channel.test.ts +261 -0
- package/src/__tests__/secret-ingress-cli.test.ts +201 -0
- package/src/__tests__/secret-ingress-http.test.ts +312 -0
- package/src/__tests__/secret-ingress.test.ts +283 -0
- package/src/__tests__/secret-onetime-send.test.ts +4 -4
- package/src/__tests__/secret-routes-managed-proxy.test.ts +78 -0
- package/src/__tests__/secure-keys-managed-failover.test.ts +73 -0
- package/src/__tests__/skill-feature-flags-integration.test.ts +4 -4
- package/src/__tests__/skill-feature-flags.test.ts +11 -19
- package/src/__tests__/skill-load-feature-flag.test.ts +1 -1
- package/src/__tests__/skill-load-inline-command.test.ts +3 -3
- package/src/__tests__/skill-load-inline-includes.test.ts +2 -2
- package/src/__tests__/skill-memory.test.ts +2 -4
- package/src/__tests__/skill-projection-feature-flag.test.ts +2 -4
- package/src/__tests__/skill-projection.benchmark.test.ts +1 -3
- package/src/__tests__/skills-uninstall.test.ts +2 -2
- package/src/__tests__/skills.test.ts +16 -2
- package/src/__tests__/slack-channel-config.test.ts +1 -1
- package/src/__tests__/slack-messaging-token-resolution.test.ts +22 -24
- package/src/__tests__/slack-share-routes.test.ts +5 -5
- package/src/__tests__/slack-skill.test.ts +5 -69
- package/src/__tests__/system-prompt.test.ts +39 -0
- package/src/__tests__/vellum-self-knowledge-inline-command.test.ts +1 -1
- package/src/__tests__/workspace-migration-018-rekey-compound-credential-keys.test.ts +181 -0
- package/src/__tests__/workspace-migration-backfill-installation-id.test.ts +5 -4
- package/src/acp/client-handler.ts +113 -31
- package/src/acp/session-manager.ts +29 -27
- package/src/approvals/guardian-request-resolvers.ts +1 -1
- package/src/cli/AGENTS.md +113 -0
- package/src/cli/commands/autonomy.ts +3 -5
- package/src/cli/commands/browser-relay.ts +2 -17
- package/src/cli/commands/contacts.ts +6 -4
- package/src/cli/commands/conversations.ts +13 -1
- package/src/cli/commands/credential-execution.ts +17 -3
- package/src/cli/commands/credentials.ts +2 -8
- package/src/cli/commands/memory.ts +2 -3
- package/src/cli/commands/oauth/__tests__/connect.test.ts +706 -0
- package/src/cli/commands/oauth/__tests__/disconnect.test.ts +686 -0
- package/src/cli/commands/oauth/__tests__/mode.test.ts +625 -0
- package/src/cli/commands/oauth/__tests__/ping.test.ts +631 -0
- package/src/cli/commands/oauth/__tests__/providers-delete.test.ts +574 -0
- package/src/cli/commands/oauth/__tests__/providers-update.test.ts +416 -0
- package/src/cli/commands/oauth/__tests__/status.test.ts +551 -0
- package/src/cli/commands/oauth/__tests__/token.test.ts +420 -0
- package/src/cli/commands/oauth/apps.ts +87 -50
- package/src/cli/commands/oauth/connect.ts +405 -0
- package/src/cli/commands/oauth/disconnect.ts +285 -0
- package/src/cli/commands/oauth/index.ts +62 -20
- package/src/cli/commands/oauth/mode.ts +251 -0
- package/src/cli/commands/oauth/ping.ts +196 -0
- package/src/cli/commands/oauth/providers.ts +589 -55
- package/src/cli/commands/oauth/request.ts +564 -0
- package/src/cli/commands/oauth/shared.ts +114 -0
- package/src/cli/commands/oauth/status.ts +191 -0
- package/src/cli/commands/oauth/token.ts +150 -0
- package/src/cli/commands/platform/connect.ts +104 -0
- package/src/cli/commands/platform/disconnect.ts +118 -0
- package/src/cli/commands/platform/index.ts +252 -0
- package/src/cli/commands/sequence.ts +5 -4
- package/src/cli/commands/shotgun.ts +16 -0
- package/src/cli/commands/skills.ts +173 -41
- package/src/cli/commands/usage.ts +5 -11
- package/src/cli/lib/daemon-credential-client.ts +22 -38
- package/src/cli/program.ts +1 -1
- package/src/cli.ts +82 -17
- package/src/config/assistant-feature-flags.ts +77 -18
- package/src/config/bundled-skills/_shared/CLI_RETRIEVAL_PATTERN.md +1 -1
- package/src/config/bundled-skills/app-builder/tools/app-create.ts +1 -1
- package/src/config/bundled-skills/contacts/tools/google-contacts.ts +1 -1
- package/src/config/bundled-skills/conversations/SKILL.md +20 -0
- package/src/config/bundled-skills/conversations/TOOLS.json +23 -0
- package/src/config/bundled-skills/conversations/tools/rename-conversation.ts +66 -0
- package/src/config/bundled-skills/gmail/SKILL.md +13 -13
- package/src/config/bundled-skills/gmail/tools/gmail-archive.ts +3 -3
- package/src/config/bundled-skills/gmail/tools/gmail-attachments.ts +2 -2
- package/src/config/bundled-skills/gmail/tools/gmail-draft.ts +1 -1
- package/src/config/bundled-skills/gmail/tools/gmail-filters.ts +1 -1
- package/src/config/bundled-skills/gmail/tools/gmail-follow-up.ts +1 -1
- package/src/config/bundled-skills/gmail/tools/gmail-forward.ts +1 -1
- package/src/config/bundled-skills/gmail/tools/gmail-label.ts +2 -2
- package/src/config/bundled-skills/gmail/tools/gmail-outreach-scan.ts +1 -1
- package/src/config/bundled-skills/gmail/tools/gmail-send-draft.ts +1 -1
- package/src/config/bundled-skills/gmail/tools/gmail-sender-digest.ts +1 -1
- package/src/config/bundled-skills/gmail/tools/gmail-trash.ts +1 -1
- package/src/config/bundled-skills/gmail/tools/gmail-unsubscribe.ts +1 -1
- package/src/config/bundled-skills/gmail/tools/gmail-vacation.ts +1 -1
- package/src/config/bundled-skills/google-calendar/SKILL.md +10 -4
- package/src/config/bundled-skills/google-calendar/tools/shared.ts +1 -1
- package/src/config/bundled-skills/messaging/SKILL.md +19 -42
- package/src/config/bundled-skills/messaging/TOOLS.json +9 -9
- package/src/config/bundled-skills/messaging/tools/messaging-analyze-style.ts +1 -1
- package/src/config/bundled-skills/messaging/tools/messaging-send.ts +5 -2
- package/src/config/bundled-skills/messaging/tools/shared.ts +5 -6
- package/src/config/bundled-skills/notifications/SKILL.md +1 -1
- package/src/config/bundled-skills/schedule/SKILL.md +2 -2
- package/src/config/bundled-skills/settings/SKILL.md +5 -3
- package/src/config/bundled-skills/settings/TOOLS.json +17 -0
- package/src/config/bundled-skills/settings/tools/avatar-get.ts +50 -0
- package/src/config/bundled-skills/settings/tools/avatar-remove.ts +7 -0
- package/src/config/bundled-skills/settings/tools/avatar-update.ts +6 -1
- package/src/config/bundled-skills/settings/tools/identity-avatar.ts +55 -0
- package/src/config/bundled-skills/skills-catalog/SKILL.md +3 -3
- package/src/config/bundled-skills/slack/SKILL.md +58 -44
- package/src/config/bundled-tool-registry.ts +7 -19
- package/src/config/env.ts +5 -1
- package/src/config/feature-flag-registry.json +58 -42
- package/src/config/loader.ts +4 -0
- package/src/config/schemas/platform.ts +0 -8
- package/src/config/schemas/security.ts +9 -1
- package/src/config/schemas/services.ts +1 -1
- package/src/config/skill-state.ts +1 -3
- package/src/config/skills.ts +2 -4
- package/src/credential-execution/client.ts +1 -1
- package/src/credential-execution/feature-gates.ts +9 -16
- package/src/credential-execution/process-manager.ts +12 -0
- package/src/daemon/config-watcher.ts +4 -0
- package/src/daemon/conversation-agent-loop-handlers.ts +10 -0
- package/src/daemon/conversation-agent-loop.ts +51 -2
- package/src/daemon/conversation-error.ts +36 -6
- package/src/daemon/conversation-memory.ts +0 -1
- package/src/daemon/conversation-messaging.ts +9 -0
- package/src/daemon/conversation-runtime-assembly.ts +33 -0
- package/src/daemon/conversation-surfaces.ts +120 -14
- package/src/daemon/conversation.ts +5 -0
- package/src/daemon/handlers/config-slack-channel.ts +43 -1
- package/src/daemon/handlers/conversations.ts +41 -33
- package/src/daemon/handlers/skills.ts +148 -3
- package/src/daemon/host-bash-proxy.ts +16 -0
- package/src/daemon/host-cu-proxy.ts +16 -0
- package/src/daemon/host-file-proxy.ts +16 -0
- package/src/daemon/lifecycle.ts +73 -3
- package/src/daemon/message-types/acp.ts +0 -15
- package/src/daemon/message-types/conversations.ts +1 -0
- package/src/daemon/message-types/guardian-actions.ts +2 -0
- package/src/daemon/message-types/host-bash.ts +6 -1
- package/src/daemon/message-types/host-cu.ts +6 -1
- package/src/daemon/message-types/host-file.ts +6 -1
- package/src/daemon/message-types/integrations.ts +0 -1
- package/src/daemon/message-types/memory.ts +0 -1
- package/src/daemon/message-types/messages.ts +9 -1
- package/src/daemon/message-types/schedules.ts +9 -0
- package/src/daemon/server.ts +48 -9
- package/src/email/feature-gate.ts +3 -3
- package/src/heartbeat/heartbeat-service.ts +48 -0
- package/src/hooks/cli.ts +74 -0
- package/src/inbound/platform-callback-registration.ts +68 -19
- package/src/mcp/client.ts +6 -1
- package/src/mcp/manager.ts +2 -1
- package/src/mcp/mcp-oauth-provider.ts +3 -3
- package/src/memory/app-store.ts +3 -3
- package/src/memory/conversation-crud.ts +213 -0
- package/src/memory/conversation-key-store.ts +26 -0
- package/src/memory/conversation-title-service.ts +7 -17
- package/src/memory/db-init.ts +24 -0
- package/src/memory/embedding-local.ts +47 -2
- package/src/memory/indexer.ts +13 -10
- package/src/memory/items-extractor.ts +12 -4
- package/src/memory/job-utils.ts +5 -0
- package/src/memory/jobs-store.ts +10 -2
- package/src/memory/journal-memory.ts +6 -2
- package/src/memory/llm-request-log-store.ts +88 -21
- package/src/memory/memory-recall-log-store.ts +128 -0
- package/src/memory/migrations/194-memory-recall-logs.ts +50 -0
- package/src/memory/migrations/195-oauth-providers-ping-config.ts +23 -0
- package/src/memory/migrations/196-messages-conversation-created-at-index.ts +9 -0
- package/src/memory/migrations/196-strip-integration-prefix-from-provider-keys.ts +186 -0
- package/src/memory/migrations/197-oauth-providers-behavior-columns.ts +29 -0
- package/src/memory/migrations/198-drop-setup-skill-id-column.ts +11 -0
- package/src/memory/migrations/index.ts +6 -0
- package/src/memory/migrations/registry.ts +8 -0
- package/src/memory/retriever.test.ts +4 -5
- package/src/memory/schema/infrastructure.ts +31 -0
- package/src/memory/schema/oauth.ts +14 -0
- package/src/messaging/provider.ts +13 -12
- package/src/messaging/providers/gmail/adapter.ts +44 -35
- package/src/messaging/providers/slack/adapter.ts +63 -33
- package/src/messaging/providers/telegram-bot/adapter.ts +7 -9
- package/src/messaging/providers/whatsapp/adapter.ts +6 -8
- package/src/notifications/adapters/telegram.ts +78 -2
- package/src/oauth/__tests__/identity-verifier.test.ts +464 -0
- package/src/oauth/byo-connection.test.ts +22 -24
- package/src/oauth/connect-orchestrator.ts +79 -64
- package/src/oauth/connect-types.ts +7 -65
- package/src/oauth/connection-resolver.test.ts +13 -13
- package/src/oauth/connection-resolver.ts +3 -4
- package/src/oauth/identity-verifier.ts +177 -0
- package/src/oauth/manual-token-connection.ts +5 -5
- package/src/oauth/oauth-store.ts +251 -5
- package/src/oauth/platform-connection.test.ts +56 -6
- package/src/oauth/platform-connection.ts +8 -1
- package/src/oauth/seed-providers.ts +256 -34
- package/src/permissions/checker.ts +129 -3
- package/src/permissions/trust-client.ts +2 -2
- package/src/platform/client.ts +2 -2
- package/src/prompts/journal-context.ts +6 -1
- package/src/prompts/system-prompt.ts +43 -9
- package/src/prompts/templates/BOOTSTRAP.md +16 -5
- package/src/providers/anthropic/client.ts +139 -28
- package/src/runtime/auth/__tests__/middleware.test.ts +19 -0
- package/src/runtime/auth/route-policy.ts +0 -1
- package/src/runtime/btw-sidechain.ts +7 -1
- package/src/runtime/channel-approvals.ts +2 -2
- package/src/runtime/channel-readiness-service.ts +30 -7
- package/src/runtime/guardian-action-service.ts +7 -2
- package/src/runtime/http-router.ts +31 -0
- package/src/runtime/http-server.ts +26 -7
- package/src/runtime/http-types.ts +9 -0
- package/src/runtime/pending-interactions.ts +21 -3
- package/src/runtime/routes/acp-routes.ts +46 -28
- package/src/runtime/routes/app-management-routes.ts +123 -0
- package/src/runtime/routes/app-routes.ts +31 -0
- package/src/runtime/routes/approval-routes.ts +108 -3
- package/src/runtime/routes/attachment-routes.ts +45 -0
- package/src/runtime/routes/avatar-routes.ts +16 -0
- package/src/runtime/routes/brain-graph-routes.ts +18 -0
- package/src/runtime/routes/btw-routes.ts +20 -0
- package/src/runtime/routes/call-routes.ts +81 -0
- package/src/runtime/routes/channel-readiness-routes.ts +48 -7
- package/src/runtime/routes/channel-routes.ts +18 -0
- package/src/runtime/routes/channel-verification-routes.ts +49 -1
- package/src/runtime/routes/contact-routes.ts +77 -0
- package/src/runtime/routes/conversation-attention-routes.ts +37 -0
- package/src/runtime/routes/conversation-management-routes.ts +125 -0
- package/src/runtime/routes/conversation-query-routes.ts +78 -0
- package/src/runtime/routes/conversation-routes.ts +191 -39
- package/src/runtime/routes/conversation-starter-routes.ts +29 -0
- package/src/runtime/routes/debug-routes.ts +23 -0
- package/src/runtime/routes/diagnostics-routes.ts +30 -0
- package/src/runtime/routes/documents-routes.ts +42 -0
- package/src/runtime/routes/events-routes.ts +10 -0
- package/src/runtime/routes/global-search-routes.ts +35 -0
- package/src/runtime/routes/guardian-action-routes.ts +61 -3
- package/src/runtime/routes/guardian-approval-prompt.ts +77 -2
- package/src/runtime/routes/heartbeat-routes.ts +278 -0
- package/src/runtime/routes/host-bash-routes.ts +16 -1
- package/src/runtime/routes/host-cu-routes.ts +23 -1
- package/src/runtime/routes/host-file-routes.ts +18 -1
- package/src/runtime/routes/identity-routes.ts +35 -0
- package/src/runtime/routes/inbound-message-handler.ts +46 -25
- package/src/runtime/routes/inbound-stages/acl-enforcement.ts +21 -8
- package/src/runtime/routes/inbound-stages/secret-ingress-check.ts +30 -2
- package/src/runtime/routes/inbound-stages/transcribe-audio.ts +1 -2
- package/src/runtime/routes/integrations/slack/share.ts +1 -1
- package/src/runtime/routes/integrations/twilio.ts +32 -22
- package/src/runtime/routes/invite-routes.ts +83 -0
- package/src/runtime/routes/log-export-routes.ts +14 -0
- package/src/runtime/routes/memory-item-routes.ts +99 -1
- package/src/runtime/routes/migration-rollback-routes.ts +25 -0
- package/src/runtime/routes/migration-routes.ts +40 -0
- package/src/runtime/routes/notification-routes.ts +20 -0
- package/src/runtime/routes/oauth-apps.ts +13 -4
- package/src/runtime/routes/pairing-routes.ts +15 -0
- package/src/runtime/routes/recording-routes.ts +72 -0
- package/src/runtime/routes/schedule-routes.ts +77 -5
- package/src/runtime/routes/secret-routes.ts +99 -14
- package/src/runtime/routes/settings-routes.ts +102 -19
- package/src/runtime/routes/skills-routes.ts +141 -18
- package/src/runtime/routes/subagents-routes.ts +38 -3
- package/src/runtime/routes/surface-action-routes.ts +66 -24
- package/src/runtime/routes/surface-content-routes.ts +20 -0
- package/src/runtime/routes/telemetry-routes.ts +12 -0
- package/src/runtime/routes/trace-event-routes.ts +25 -0
- package/src/runtime/routes/trust-rules-routes.ts +46 -0
- package/src/runtime/routes/tts-routes.ts +15 -4
- package/src/runtime/routes/upgrade-broadcast-routes.ts +38 -0
- package/src/runtime/routes/usage-routes.ts +59 -0
- package/src/runtime/routes/watch-routes.ts +28 -0
- package/src/runtime/routes/work-items-routes.ts +59 -0
- package/src/runtime/routes/workspace-commit-routes.ts +12 -0
- package/src/runtime/routes/workspace-routes.ts +102 -0
- package/src/schedule/integration-status.ts +2 -2
- package/src/schedule/scheduler.ts +7 -1
- package/src/security/AGENTS.md +7 -0
- package/src/security/ces-rpc-credential-backend.ts +19 -16
- package/src/security/credential-backend.ts +1 -1
- package/src/security/encrypted-store.ts +3 -3
- package/src/security/oauth-completion-page.ts +153 -0
- package/src/security/oauth2.ts +58 -17
- package/src/security/secret-ingress.ts +174 -0
- package/src/security/secret-patterns.ts +133 -0
- package/src/security/secret-scanner.ts +28 -117
- package/src/security/secure-keys.ts +207 -7
- package/src/security/token-manager.ts +3 -6
- package/src/signals/bash.ts +6 -1
- package/src/signals/confirm.ts +12 -8
- package/src/signals/user-message.ts +18 -3
- package/src/skills/catalog-cache.ts +44 -0
- package/src/skills/catalog-search.ts +18 -0
- package/src/skills/skill-memory.ts +1 -2
- package/src/tasks/task-runner.ts +7 -1
- package/src/tools/credentials/broker.ts +1 -1
- package/src/tools/credentials/metadata-store.ts +1 -1
- package/src/tools/credentials/post-connect-hooks.ts +1 -1
- package/src/tools/credentials/vault.ts +36 -48
- package/src/tools/host-terminal/host-shell.ts +16 -3
- package/src/tools/mcp/mcp-tool-factory.ts +2 -1
- package/src/tools/memory/definitions.ts +1 -1
- package/src/tools/memory/handlers.test.ts +2 -4
- package/src/tools/skills/load.ts +1 -1
- package/src/tools/skills/sandbox-runner.ts +16 -3
- package/src/tools/terminal/safe-env.ts +7 -0
- package/src/tools/terminal/shell.ts +16 -3
- package/src/tools/tool-manifest.ts +1 -1
- package/src/util/log-redact.ts +9 -34
- package/src/util/logger.ts +11 -1
- package/src/util/sentry-log-stream.ts +51 -0
- package/src/watcher/providers/github.ts +2 -2
- package/src/watcher/providers/gmail.ts +1 -1
- package/src/watcher/providers/google-calendar.ts +1 -1
- package/src/watcher/providers/linear.ts +2 -2
- package/src/workspace/migrations/011-backfill-installation-id.ts +5 -3
- package/src/workspace/migrations/020-rename-oauth-skill-dirs.ts +119 -0
- package/src/workspace/migrations/registry.ts +2 -0
- package/docs/architecture/keychain-broker.md +0 -68
- package/src/cli/commands/oauth/connections.ts +0 -734
- package/src/cli/commands/oauth/platform.ts +0 -525
- package/src/cli/commands/platform.ts +0 -176
- package/src/config/bundled-skills/slack/TOOLS.json +0 -272
- package/src/config/bundled-skills/slack/tools/shared.ts +0 -34
- package/src/config/bundled-skills/slack/tools/slack-add-reaction.ts +0 -27
- package/src/config/bundled-skills/slack/tools/slack-channel-details.ts +0 -38
- package/src/config/bundled-skills/slack/tools/slack-channel-permissions.ts +0 -146
- package/src/config/bundled-skills/slack/tools/slack-configure-channels.ts +0 -105
- package/src/config/bundled-skills/slack/tools/slack-delete-message.ts +0 -26
- package/src/config/bundled-skills/slack/tools/slack-edit-message.ts +0 -27
- package/src/config/bundled-skills/slack/tools/slack-leave-channel.ts +0 -25
- package/src/config/bundled-skills/slack/tools/slack-scan-digest.ts +0 -372
- package/src/oauth/provider-behaviors.ts +0 -634
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Mock state
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
let mockGetProvider: (
|
|
10
|
+
key: string,
|
|
11
|
+
) => Record<string, unknown> | undefined = () => undefined;
|
|
12
|
+
|
|
13
|
+
let mockListActiveConnectionsByProvider: (
|
|
14
|
+
providerKey: string,
|
|
15
|
+
) => Array<Record<string, unknown>> = () => [];
|
|
16
|
+
|
|
17
|
+
let mockGetManagedServiceConfigKey: (key: string) => string | null = () => null;
|
|
18
|
+
|
|
19
|
+
let mockPlatformClientResult: Record<string, unknown> | null = null;
|
|
20
|
+
let mockPlatformFetchResults: Array<{
|
|
21
|
+
ok: boolean;
|
|
22
|
+
status: number;
|
|
23
|
+
body: unknown;
|
|
24
|
+
}> = [];
|
|
25
|
+
let mockPlatformFetchCallIndex = 0;
|
|
26
|
+
|
|
27
|
+
let mockRawConfig: Record<string, unknown> = {};
|
|
28
|
+
let mockSaveRawConfigCalls: Array<Record<string, unknown>> = [];
|
|
29
|
+
let mockSetNestedValueCalls: Array<{
|
|
30
|
+
obj: Record<string, unknown>;
|
|
31
|
+
path: string;
|
|
32
|
+
value: unknown;
|
|
33
|
+
}> = [];
|
|
34
|
+
|
|
35
|
+
let mockConfigServices: Record<string, unknown> = {};
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Mocks
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
mock.module("../../../../config/loader.js", () => ({
|
|
42
|
+
getConfig: () => ({ services: mockConfigServices }),
|
|
43
|
+
loadRawConfig: () => mockRawConfig,
|
|
44
|
+
saveRawConfig: (config: Record<string, unknown>) => {
|
|
45
|
+
mockSaveRawConfigCalls.push(structuredClone(config));
|
|
46
|
+
},
|
|
47
|
+
setNestedValue: (
|
|
48
|
+
obj: Record<string, unknown>,
|
|
49
|
+
path: string,
|
|
50
|
+
value: unknown,
|
|
51
|
+
) => {
|
|
52
|
+
mockSetNestedValueCalls.push({ obj, path, value });
|
|
53
|
+
// Actually set the value so the mock raw config is mutated
|
|
54
|
+
const keys = path.split(".");
|
|
55
|
+
let current: Record<string, unknown> = obj;
|
|
56
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
57
|
+
const key = keys[i];
|
|
58
|
+
if (current[key] == null || typeof current[key] !== "object") {
|
|
59
|
+
current[key] = {};
|
|
60
|
+
}
|
|
61
|
+
current = current[key] as Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
current[keys[keys.length - 1]] = value;
|
|
64
|
+
},
|
|
65
|
+
API_KEY_PROVIDERS: [],
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
mock.module("../../../../oauth/oauth-store.js", () => ({
|
|
69
|
+
getProvider: (key: string) => mockGetProvider(key),
|
|
70
|
+
listActiveConnectionsByProvider: (providerKey: string) =>
|
|
71
|
+
mockListActiveConnectionsByProvider(providerKey),
|
|
72
|
+
listConnections: () => [],
|
|
73
|
+
getConnection: () => undefined,
|
|
74
|
+
getConnectionByProvider: () => undefined,
|
|
75
|
+
getActiveConnection: () => undefined,
|
|
76
|
+
disconnectOAuthProvider: async () => "not-found" as const,
|
|
77
|
+
upsertApp: async () => ({}),
|
|
78
|
+
getApp: () => undefined,
|
|
79
|
+
getAppByProviderAndClientId: () => undefined,
|
|
80
|
+
getMostRecentAppByProvider: () => undefined,
|
|
81
|
+
listApps: () => [],
|
|
82
|
+
deleteApp: async () => false,
|
|
83
|
+
listProviders: () => [],
|
|
84
|
+
registerProvider: () => ({}),
|
|
85
|
+
seedProviders: () => {},
|
|
86
|
+
isProviderConnected: () => false,
|
|
87
|
+
createConnection: () => ({}),
|
|
88
|
+
updateConnection: () => ({}),
|
|
89
|
+
deleteConnection: () => false,
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
mock.module("../../../../platform/client.js", () => ({
|
|
93
|
+
VellumPlatformClient: {
|
|
94
|
+
create: async () => mockPlatformClientResult,
|
|
95
|
+
},
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
mock.module("../../../../util/logger.js", () => ({
|
|
99
|
+
getLogger: () => ({
|
|
100
|
+
info: () => {},
|
|
101
|
+
warn: () => {},
|
|
102
|
+
error: () => {},
|
|
103
|
+
debug: () => {},
|
|
104
|
+
}),
|
|
105
|
+
getCliLogger: () => ({
|
|
106
|
+
info: () => {},
|
|
107
|
+
warn: () => {},
|
|
108
|
+
error: () => {},
|
|
109
|
+
debug: () => {},
|
|
110
|
+
}),
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
mock.module("../../../lib/daemon-credential-client.js", () => ({
|
|
114
|
+
getSecureKeyViaDaemon: async () => undefined,
|
|
115
|
+
deleteSecureKeyViaDaemon: async () => "not-found" as const,
|
|
116
|
+
}));
|
|
117
|
+
|
|
118
|
+
// Mock shared.js helpers
|
|
119
|
+
mock.module("../shared.js", () => ({
|
|
120
|
+
isManagedMode: () => false,
|
|
121
|
+
getManagedServiceConfigKey: (key: string) =>
|
|
122
|
+
mockGetManagedServiceConfigKey(key),
|
|
123
|
+
requirePlatformClient: async (_cmd: Command) => {
|
|
124
|
+
if (
|
|
125
|
+
!mockPlatformClientResult ||
|
|
126
|
+
!(mockPlatformClientResult as Record<string, unknown>).platformAssistantId
|
|
127
|
+
) {
|
|
128
|
+
process.exitCode = 1;
|
|
129
|
+
process.stdout.write(
|
|
130
|
+
JSON.stringify({
|
|
131
|
+
ok: false,
|
|
132
|
+
error:
|
|
133
|
+
"Platform prerequisites not met (not logged in or missing assistant ID)",
|
|
134
|
+
}) + "\n",
|
|
135
|
+
);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
platformAssistantId: (mockPlatformClientResult as Record<string, unknown>)
|
|
140
|
+
.platformAssistantId,
|
|
141
|
+
fetch: async (): Promise<Response> => {
|
|
142
|
+
const idx = mockPlatformFetchCallIndex++;
|
|
143
|
+
const result = mockPlatformFetchResults[idx] ?? {
|
|
144
|
+
ok: false,
|
|
145
|
+
status: 500,
|
|
146
|
+
body: "mock not configured",
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
ok: result.ok,
|
|
150
|
+
status: result.status,
|
|
151
|
+
json: async () => result.body,
|
|
152
|
+
text: async () =>
|
|
153
|
+
typeof result.body === "string"
|
|
154
|
+
? result.body
|
|
155
|
+
: JSON.stringify(result.body),
|
|
156
|
+
} as unknown as Response;
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
fetchActiveConnections: async (
|
|
161
|
+
_client: Record<string, unknown>,
|
|
162
|
+
_provider: string,
|
|
163
|
+
_cmd: Command,
|
|
164
|
+
_options?: { silent?: boolean },
|
|
165
|
+
): Promise<Array<Record<string, unknown>> | null> => {
|
|
166
|
+
const idx = mockPlatformFetchCallIndex++;
|
|
167
|
+
const result = mockPlatformFetchResults[idx];
|
|
168
|
+
if (!result) return [];
|
|
169
|
+
if (!result.ok) return null;
|
|
170
|
+
return result.body as Array<Record<string, unknown>>;
|
|
171
|
+
},
|
|
172
|
+
}));
|
|
173
|
+
|
|
174
|
+
// ---------------------------------------------------------------------------
|
|
175
|
+
// Import module under test (after mocks are registered)
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
|
|
178
|
+
const { registerModeCommand } = await import("../mode.js");
|
|
179
|
+
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
// Test helper
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
|
|
184
|
+
async function runCommand(
|
|
185
|
+
args: string[],
|
|
186
|
+
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
|
187
|
+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
188
|
+
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
|
189
|
+
const stdoutChunks: string[] = [];
|
|
190
|
+
const stderrChunks: string[] = [];
|
|
191
|
+
|
|
192
|
+
process.stdout.write = ((chunk: unknown) => {
|
|
193
|
+
stdoutChunks.push(typeof chunk === "string" ? chunk : String(chunk));
|
|
194
|
+
return true;
|
|
195
|
+
}) as typeof process.stdout.write;
|
|
196
|
+
|
|
197
|
+
process.stderr.write = ((chunk: unknown) => {
|
|
198
|
+
stderrChunks.push(typeof chunk === "string" ? chunk : String(chunk));
|
|
199
|
+
return true;
|
|
200
|
+
}) as typeof process.stderr.write;
|
|
201
|
+
|
|
202
|
+
process.exitCode = 0;
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
const program = new Command();
|
|
206
|
+
program.exitOverride();
|
|
207
|
+
program.option("--json", "JSON output");
|
|
208
|
+
program.configureOutput({
|
|
209
|
+
writeErr: () => {},
|
|
210
|
+
writeOut: (str: string) => stdoutChunks.push(str),
|
|
211
|
+
});
|
|
212
|
+
registerModeCommand(program);
|
|
213
|
+
await program.parseAsync(["node", "assistant", ...args]);
|
|
214
|
+
} catch {
|
|
215
|
+
if (process.exitCode === 0) process.exitCode = 1;
|
|
216
|
+
} finally {
|
|
217
|
+
process.stdout.write = originalStdoutWrite;
|
|
218
|
+
process.stderr.write = originalStderrWrite;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const exitCode = process.exitCode ?? 0;
|
|
222
|
+
process.exitCode = 0;
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
exitCode,
|
|
226
|
+
stdout: stdoutChunks.join(""),
|
|
227
|
+
stderr: stderrChunks.join(""),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// ---------------------------------------------------------------------------
|
|
232
|
+
// Tests
|
|
233
|
+
// ---------------------------------------------------------------------------
|
|
234
|
+
|
|
235
|
+
describe("assistant oauth mode", () => {
|
|
236
|
+
beforeEach(() => {
|
|
237
|
+
mockGetProvider = () => undefined;
|
|
238
|
+
mockListActiveConnectionsByProvider = () => [];
|
|
239
|
+
mockGetManagedServiceConfigKey = () => null;
|
|
240
|
+
mockPlatformClientResult = null;
|
|
241
|
+
mockPlatformFetchResults = [];
|
|
242
|
+
mockPlatformFetchCallIndex = 0;
|
|
243
|
+
mockRawConfig = {};
|
|
244
|
+
mockSaveRawConfigCalls = [];
|
|
245
|
+
mockSetNestedValueCalls = [];
|
|
246
|
+
mockConfigServices = {};
|
|
247
|
+
process.exitCode = 0;
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// =========================================================================
|
|
251
|
+
// Get mode
|
|
252
|
+
// =========================================================================
|
|
253
|
+
|
|
254
|
+
describe("get mode", () => {
|
|
255
|
+
test("unknown provider returns error", async () => {
|
|
256
|
+
mockGetProvider = () => undefined;
|
|
257
|
+
|
|
258
|
+
const { exitCode, stdout } = await runCommand([
|
|
259
|
+
"mode",
|
|
260
|
+
"nonexistent",
|
|
261
|
+
"--json",
|
|
262
|
+
]);
|
|
263
|
+
expect(exitCode).toBe(1);
|
|
264
|
+
const parsed = JSON.parse(stdout);
|
|
265
|
+
expect(parsed.ok).toBe(false);
|
|
266
|
+
expect(parsed.error).toContain("Unknown provider");
|
|
267
|
+
expect(parsed.error).toContain("providers list");
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test("provider without managedServiceConfigKey returns your-own with managedModeSupported: false", async () => {
|
|
271
|
+
mockGetProvider = () => ({
|
|
272
|
+
providerKey: "slack",
|
|
273
|
+
managedServiceConfigKey: null,
|
|
274
|
+
});
|
|
275
|
+
mockGetManagedServiceConfigKey = () => null;
|
|
276
|
+
|
|
277
|
+
const { exitCode, stdout } = await runCommand([
|
|
278
|
+
"mode",
|
|
279
|
+
"slack",
|
|
280
|
+
"--json",
|
|
281
|
+
]);
|
|
282
|
+
expect(exitCode).toBe(0);
|
|
283
|
+
const parsed = JSON.parse(stdout);
|
|
284
|
+
expect(parsed.ok).toBe(true);
|
|
285
|
+
expect(parsed.provider).toBe("slack");
|
|
286
|
+
expect(parsed.mode).toBe("your-own");
|
|
287
|
+
expect(parsed.managedModeSupported).toBe(false);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test("provider in managed mode returns mode: managed with managedModeSupported: true", async () => {
|
|
291
|
+
mockGetProvider = () => ({
|
|
292
|
+
providerKey: "google",
|
|
293
|
+
managedServiceConfigKey: "google-oauth",
|
|
294
|
+
});
|
|
295
|
+
mockGetManagedServiceConfigKey = () => "google-oauth";
|
|
296
|
+
mockConfigServices = {
|
|
297
|
+
"google-oauth": { mode: "managed" },
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const { exitCode, stdout } = await runCommand([
|
|
301
|
+
"mode",
|
|
302
|
+
"google",
|
|
303
|
+
"--json",
|
|
304
|
+
]);
|
|
305
|
+
expect(exitCode).toBe(0);
|
|
306
|
+
const parsed = JSON.parse(stdout);
|
|
307
|
+
expect(parsed.ok).toBe(true);
|
|
308
|
+
expect(parsed.provider).toBe("google");
|
|
309
|
+
expect(parsed.mode).toBe("managed");
|
|
310
|
+
expect(parsed.managedModeSupported).toBe(true);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
test("provider in your-own mode returns mode: your-own with managedModeSupported: true", async () => {
|
|
314
|
+
mockGetProvider = () => ({
|
|
315
|
+
providerKey: "google",
|
|
316
|
+
managedServiceConfigKey: "google-oauth",
|
|
317
|
+
});
|
|
318
|
+
mockGetManagedServiceConfigKey = () => "google-oauth";
|
|
319
|
+
mockConfigServices = {
|
|
320
|
+
"google-oauth": { mode: "your-own" },
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const { exitCode, stdout } = await runCommand([
|
|
324
|
+
"mode",
|
|
325
|
+
"google",
|
|
326
|
+
"--json",
|
|
327
|
+
]);
|
|
328
|
+
expect(exitCode).toBe(0);
|
|
329
|
+
const parsed = JSON.parse(stdout);
|
|
330
|
+
expect(parsed.ok).toBe(true);
|
|
331
|
+
expect(parsed.provider).toBe("google");
|
|
332
|
+
expect(parsed.mode).toBe("your-own");
|
|
333
|
+
expect(parsed.managedModeSupported).toBe(true);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// =========================================================================
|
|
338
|
+
// Set mode
|
|
339
|
+
// =========================================================================
|
|
340
|
+
|
|
341
|
+
describe("set mode", () => {
|
|
342
|
+
test("invalid mode value returns error listing valid values", async () => {
|
|
343
|
+
mockGetProvider = () => ({
|
|
344
|
+
providerKey: "google",
|
|
345
|
+
managedServiceConfigKey: "google-oauth",
|
|
346
|
+
});
|
|
347
|
+
mockGetManagedServiceConfigKey = () => "google-oauth";
|
|
348
|
+
|
|
349
|
+
const { exitCode, stdout } = await runCommand([
|
|
350
|
+
"mode",
|
|
351
|
+
"google",
|
|
352
|
+
"--set",
|
|
353
|
+
"invalid",
|
|
354
|
+
"--json",
|
|
355
|
+
]);
|
|
356
|
+
expect(exitCode).toBe(1);
|
|
357
|
+
const parsed = JSON.parse(stdout);
|
|
358
|
+
expect(parsed.ok).toBe(false);
|
|
359
|
+
expect(parsed.error).toContain("invalid");
|
|
360
|
+
expect(parsed.error).toContain("managed");
|
|
361
|
+
expect(parsed.error).toContain("your-own");
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
test("provider without managedServiceConfigKey returns error about managed mode not available when --set managed", async () => {
|
|
365
|
+
mockGetProvider = () => ({
|
|
366
|
+
providerKey: "slack",
|
|
367
|
+
managedServiceConfigKey: null,
|
|
368
|
+
});
|
|
369
|
+
mockGetManagedServiceConfigKey = () => null;
|
|
370
|
+
|
|
371
|
+
const { exitCode, stdout } = await runCommand([
|
|
372
|
+
"mode",
|
|
373
|
+
"slack",
|
|
374
|
+
"--set",
|
|
375
|
+
"managed",
|
|
376
|
+
"--json",
|
|
377
|
+
]);
|
|
378
|
+
expect(exitCode).toBe(1);
|
|
379
|
+
const parsed = JSON.parse(stdout);
|
|
380
|
+
expect(parsed.ok).toBe(false);
|
|
381
|
+
expect(parsed.error).toContain("Managed mode is not available");
|
|
382
|
+
expect(parsed.error).toContain("slack");
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
test("provider without managedServiceConfigKey treats --set your-own as successful no-op", async () => {
|
|
386
|
+
mockGetProvider = () => ({
|
|
387
|
+
providerKey: "slack",
|
|
388
|
+
managedServiceConfigKey: null,
|
|
389
|
+
});
|
|
390
|
+
mockGetManagedServiceConfigKey = () => null;
|
|
391
|
+
|
|
392
|
+
const { exitCode, stdout } = await runCommand([
|
|
393
|
+
"mode",
|
|
394
|
+
"slack",
|
|
395
|
+
"--set",
|
|
396
|
+
"your-own",
|
|
397
|
+
"--json",
|
|
398
|
+
]);
|
|
399
|
+
expect(exitCode).toBe(0);
|
|
400
|
+
const parsed = JSON.parse(stdout);
|
|
401
|
+
expect(parsed.ok).toBe(true);
|
|
402
|
+
expect(parsed.provider).toBe("slack");
|
|
403
|
+
expect(parsed.mode).toBe("your-own");
|
|
404
|
+
expect(parsed.changed).toBe(false);
|
|
405
|
+
expect(parsed.managedModeSupported).toBe(false);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
test("set to same mode returns changed: false", async () => {
|
|
409
|
+
mockGetProvider = () => ({
|
|
410
|
+
providerKey: "google",
|
|
411
|
+
managedServiceConfigKey: "google-oauth",
|
|
412
|
+
});
|
|
413
|
+
mockGetManagedServiceConfigKey = () => "google-oauth";
|
|
414
|
+
mockConfigServices = {
|
|
415
|
+
"google-oauth": { mode: "managed" },
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
const { exitCode, stdout } = await runCommand([
|
|
419
|
+
"mode",
|
|
420
|
+
"google",
|
|
421
|
+
"--set",
|
|
422
|
+
"managed",
|
|
423
|
+
"--json",
|
|
424
|
+
]);
|
|
425
|
+
expect(exitCode).toBe(0);
|
|
426
|
+
const parsed = JSON.parse(stdout);
|
|
427
|
+
expect(parsed.ok).toBe(true);
|
|
428
|
+
expect(parsed.provider).toBe("google");
|
|
429
|
+
expect(parsed.mode).toBe("managed");
|
|
430
|
+
expect(parsed.changed).toBe(false);
|
|
431
|
+
expect(parsed.managedModeSupported).toBe(true);
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
test("switch managed -> your-own with active managed connections and no BYO connections includes hint", async () => {
|
|
435
|
+
mockGetProvider = () => ({
|
|
436
|
+
providerKey: "google",
|
|
437
|
+
managedServiceConfigKey: "google-oauth",
|
|
438
|
+
});
|
|
439
|
+
mockGetManagedServiceConfigKey = () => "google-oauth";
|
|
440
|
+
mockConfigServices = {
|
|
441
|
+
"google-oauth": { mode: "managed" },
|
|
442
|
+
};
|
|
443
|
+
mockRawConfig = { services: { "google-oauth": { mode: "managed" } } };
|
|
444
|
+
|
|
445
|
+
// Platform has active connections (old mode = managed)
|
|
446
|
+
mockPlatformClientResult = { platformAssistantId: "asst-123" };
|
|
447
|
+
mockPlatformFetchResults = [
|
|
448
|
+
{
|
|
449
|
+
ok: true,
|
|
450
|
+
status: 200,
|
|
451
|
+
body: [{ id: "conn-1", account_label: "user@gmail.com" }],
|
|
452
|
+
},
|
|
453
|
+
];
|
|
454
|
+
|
|
455
|
+
// No BYO connections (new mode = your-own)
|
|
456
|
+
mockListActiveConnectionsByProvider = () => [];
|
|
457
|
+
|
|
458
|
+
const { exitCode, stdout } = await runCommand([
|
|
459
|
+
"mode",
|
|
460
|
+
"google",
|
|
461
|
+
"--set",
|
|
462
|
+
"your-own",
|
|
463
|
+
"--json",
|
|
464
|
+
]);
|
|
465
|
+
expect(exitCode).toBe(0);
|
|
466
|
+
const parsed = JSON.parse(stdout);
|
|
467
|
+
expect(parsed.ok).toBe(true);
|
|
468
|
+
expect(parsed.provider).toBe("google");
|
|
469
|
+
expect(parsed.mode).toBe("your-own");
|
|
470
|
+
expect(parsed.changed).toBe(true);
|
|
471
|
+
expect(parsed.managedModeSupported).toBe(true);
|
|
472
|
+
expect(parsed.hint).toContain("No active connections");
|
|
473
|
+
expect(parsed.hint).toContain("your-own");
|
|
474
|
+
expect(parsed.hint).toContain("connect");
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
test("switch your-own -> managed with active BYO connections and no managed connections includes hint", async () => {
|
|
478
|
+
mockGetProvider = () => ({
|
|
479
|
+
providerKey: "google",
|
|
480
|
+
managedServiceConfigKey: "google-oauth",
|
|
481
|
+
});
|
|
482
|
+
mockGetManagedServiceConfigKey = () => "google-oauth";
|
|
483
|
+
mockConfigServices = {
|
|
484
|
+
"google-oauth": { mode: "your-own" },
|
|
485
|
+
};
|
|
486
|
+
mockRawConfig = { services: { "google-oauth": { mode: "your-own" } } };
|
|
487
|
+
|
|
488
|
+
// BYO has active connections (old mode = your-own)
|
|
489
|
+
mockListActiveConnectionsByProvider = () => [
|
|
490
|
+
{
|
|
491
|
+
id: "conn-local-1",
|
|
492
|
+
providerKey: "google",
|
|
493
|
+
status: "active",
|
|
494
|
+
},
|
|
495
|
+
];
|
|
496
|
+
|
|
497
|
+
// Platform has no connections (new mode = managed)
|
|
498
|
+
mockPlatformClientResult = { platformAssistantId: "asst-123" };
|
|
499
|
+
mockPlatformFetchResults = [{ ok: true, status: 200, body: [] }];
|
|
500
|
+
|
|
501
|
+
const { exitCode, stdout } = await runCommand([
|
|
502
|
+
"mode",
|
|
503
|
+
"google",
|
|
504
|
+
"--set",
|
|
505
|
+
"managed",
|
|
506
|
+
"--json",
|
|
507
|
+
]);
|
|
508
|
+
expect(exitCode).toBe(0);
|
|
509
|
+
const parsed = JSON.parse(stdout);
|
|
510
|
+
expect(parsed.ok).toBe(true);
|
|
511
|
+
expect(parsed.provider).toBe("google");
|
|
512
|
+
expect(parsed.mode).toBe("managed");
|
|
513
|
+
expect(parsed.changed).toBe(true);
|
|
514
|
+
expect(parsed.managedModeSupported).toBe(true);
|
|
515
|
+
expect(parsed.hint).toContain("No active connections");
|
|
516
|
+
expect(parsed.hint).toContain("managed");
|
|
517
|
+
expect(parsed.hint).toContain("connect");
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
test("switch mode with connections on both sides has no hint", async () => {
|
|
521
|
+
mockGetProvider = () => ({
|
|
522
|
+
providerKey: "google",
|
|
523
|
+
managedServiceConfigKey: "google-oauth",
|
|
524
|
+
});
|
|
525
|
+
mockGetManagedServiceConfigKey = () => "google-oauth";
|
|
526
|
+
mockConfigServices = {
|
|
527
|
+
"google-oauth": { mode: "managed" },
|
|
528
|
+
};
|
|
529
|
+
mockRawConfig = { services: { "google-oauth": { mode: "managed" } } };
|
|
530
|
+
|
|
531
|
+
// Platform has active connections (old mode = managed)
|
|
532
|
+
mockPlatformClientResult = { platformAssistantId: "asst-123" };
|
|
533
|
+
mockPlatformFetchResults = [
|
|
534
|
+
{
|
|
535
|
+
ok: true,
|
|
536
|
+
status: 200,
|
|
537
|
+
body: [{ id: "conn-1", account_label: "user@gmail.com" }],
|
|
538
|
+
},
|
|
539
|
+
];
|
|
540
|
+
|
|
541
|
+
// BYO also has connections (new mode = your-own)
|
|
542
|
+
mockListActiveConnectionsByProvider = () => [
|
|
543
|
+
{
|
|
544
|
+
id: "conn-local-1",
|
|
545
|
+
providerKey: "google",
|
|
546
|
+
status: "active",
|
|
547
|
+
},
|
|
548
|
+
];
|
|
549
|
+
|
|
550
|
+
const { exitCode, stdout } = await runCommand([
|
|
551
|
+
"mode",
|
|
552
|
+
"google",
|
|
553
|
+
"--set",
|
|
554
|
+
"your-own",
|
|
555
|
+
"--json",
|
|
556
|
+
]);
|
|
557
|
+
expect(exitCode).toBe(0);
|
|
558
|
+
const parsed = JSON.parse(stdout);
|
|
559
|
+
expect(parsed.ok).toBe(true);
|
|
560
|
+
expect(parsed.changed).toBe(true);
|
|
561
|
+
expect(parsed.managedModeSupported).toBe(true);
|
|
562
|
+
expect(parsed.hint).toBeUndefined();
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
test("switch mode with no connections on either side has no hint", async () => {
|
|
566
|
+
mockGetProvider = () => ({
|
|
567
|
+
providerKey: "google",
|
|
568
|
+
managedServiceConfigKey: "google-oauth",
|
|
569
|
+
});
|
|
570
|
+
mockGetManagedServiceConfigKey = () => "google-oauth";
|
|
571
|
+
mockConfigServices = {
|
|
572
|
+
"google-oauth": { mode: "managed" },
|
|
573
|
+
};
|
|
574
|
+
mockRawConfig = { services: { "google-oauth": { mode: "managed" } } };
|
|
575
|
+
|
|
576
|
+
// No platform connections
|
|
577
|
+
mockPlatformClientResult = { platformAssistantId: "asst-123" };
|
|
578
|
+
mockPlatformFetchResults = [{ ok: true, status: 200, body: [] }];
|
|
579
|
+
|
|
580
|
+
// No BYO connections
|
|
581
|
+
mockListActiveConnectionsByProvider = () => [];
|
|
582
|
+
|
|
583
|
+
const { exitCode, stdout } = await runCommand([
|
|
584
|
+
"mode",
|
|
585
|
+
"google",
|
|
586
|
+
"--set",
|
|
587
|
+
"your-own",
|
|
588
|
+
"--json",
|
|
589
|
+
]);
|
|
590
|
+
expect(exitCode).toBe(0);
|
|
591
|
+
const parsed = JSON.parse(stdout);
|
|
592
|
+
expect(parsed.ok).toBe(true);
|
|
593
|
+
expect(parsed.changed).toBe(true);
|
|
594
|
+
expect(parsed.managedModeSupported).toBe(true);
|
|
595
|
+
expect(parsed.hint).toBeUndefined();
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
test("saveRawConfig is called with the correct nested path", async () => {
|
|
599
|
+
mockGetProvider = () => ({
|
|
600
|
+
providerKey: "google",
|
|
601
|
+
managedServiceConfigKey: "google-oauth",
|
|
602
|
+
});
|
|
603
|
+
mockGetManagedServiceConfigKey = () => "google-oauth";
|
|
604
|
+
mockConfigServices = {
|
|
605
|
+
"google-oauth": { mode: "managed" },
|
|
606
|
+
};
|
|
607
|
+
mockRawConfig = { services: { "google-oauth": { mode: "managed" } } };
|
|
608
|
+
|
|
609
|
+
// No platform client — skip connection checking
|
|
610
|
+
mockPlatformClientResult = null;
|
|
611
|
+
mockListActiveConnectionsByProvider = () => [];
|
|
612
|
+
|
|
613
|
+
await runCommand(["mode", "google", "--set", "your-own", "--json"]);
|
|
614
|
+
|
|
615
|
+
// Verify setNestedValue was called with correct path and value
|
|
616
|
+
expect(mockSetNestedValueCalls.length).toBeGreaterThanOrEqual(1);
|
|
617
|
+
const setCall = mockSetNestedValueCalls[0];
|
|
618
|
+
expect(setCall.path).toBe("services.google-oauth.mode");
|
|
619
|
+
expect(setCall.value).toBe("your-own");
|
|
620
|
+
|
|
621
|
+
// Verify saveRawConfig was called
|
|
622
|
+
expect(mockSaveRawConfigCalls.length).toBe(1);
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
});
|