@agent-native/core 0.15.13 → 0.16.0
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/README.md +37 -0
- package/dist/agent/app-model-defaults.d.ts +37 -0
- package/dist/agent/app-model-defaults.d.ts.map +1 -0
- package/dist/agent/app-model-defaults.js +136 -0
- package/dist/agent/app-model-defaults.js.map +1 -0
- package/dist/agent/engine/registry.d.ts +12 -7
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +28 -8
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/production-agent.d.ts +2 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +3 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/browser-sessions/actions.d.ts +7 -0
- package/dist/browser-sessions/actions.d.ts.map +1 -0
- package/dist/browser-sessions/actions.js +223 -0
- package/dist/browser-sessions/actions.js.map +1 -0
- package/dist/browser-sessions/routes.d.ts +7 -0
- package/dist/browser-sessions/routes.d.ts.map +1 -0
- package/dist/browser-sessions/routes.js +159 -0
- package/dist/browser-sessions/routes.js.map +1 -0
- package/dist/browser-sessions/store.d.ts +33 -0
- package/dist/browser-sessions/store.d.ts.map +1 -0
- package/dist/browser-sessions/store.js +506 -0
- package/dist/browser-sessions/store.js.map +1 -0
- package/dist/browser-sessions/types.d.ts +68 -0
- package/dist/browser-sessions/types.d.ts.map +1 -0
- package/dist/browser-sessions/types.js +2 -0
- package/dist/browser-sessions/types.js.map +1 -0
- package/dist/cli/code-agent-commands.d.ts +36 -0
- package/dist/cli/code-agent-commands.d.ts.map +1 -0
- package/dist/cli/code-agent-commands.js +192 -0
- package/dist/cli/code-agent-commands.js.map +1 -0
- package/dist/cli/code-agent-connector.d.ts +17 -0
- package/dist/cli/code-agent-connector.d.ts.map +1 -0
- package/dist/cli/code-agent-connector.js +724 -0
- package/dist/cli/code-agent-connector.js.map +1 -0
- package/dist/cli/code-agent-executor.d.ts +31 -0
- package/dist/cli/code-agent-executor.d.ts.map +1 -0
- package/dist/cli/code-agent-executor.js +921 -0
- package/dist/cli/code-agent-executor.js.map +1 -0
- package/dist/cli/code-agent-runs.d.ts +102 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -0
- package/dist/cli/code-agent-runs.js +277 -0
- package/dist/cli/code-agent-runs.js.map +1 -0
- package/dist/cli/code.d.ts +66 -0
- package/dist/cli/code.d.ts.map +1 -0
- package/dist/cli/code.js +1306 -0
- package/dist/cli/code.js.map +1 -0
- package/dist/cli/create.d.ts +2 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +11 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +26 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/migrate.d.ts +27 -0
- package/dist/cli/migrate.d.ts.map +1 -1
- package/dist/cli/migrate.js +1328 -20
- package/dist/cli/migrate.js.map +1 -1
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +26 -2
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/cli/workspacify.d.ts +2 -0
- package/dist/cli/workspacify.d.ts.map +1 -1
- package/dist/cli/workspacify.js +2 -1
- package/dist/cli/workspacify.js.map +1 -1
- package/dist/client/AgentNative.d.ts +32 -0
- package/dist/client/AgentNative.d.ts.map +1 -0
- package/dist/client/AgentNative.js +79 -0
- package/dist/client/AgentNative.js.map +1 -0
- package/dist/client/AgentNativeEmbedded.d.ts +47 -0
- package/dist/client/AgentNativeEmbedded.d.ts.map +1 -0
- package/dist/client/AgentNativeEmbedded.js +148 -0
- package/dist/client/AgentNativeEmbedded.js.map +1 -0
- package/dist/client/AgentNativeFrame.d.ts +25 -0
- package/dist/client/AgentNativeFrame.d.ts.map +1 -0
- package/dist/client/AgentNativeFrame.js +68 -0
- package/dist/client/AgentNativeFrame.js.map +1 -0
- package/dist/client/AgentPanel.d.ts +19 -2
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +15 -4
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +79 -48
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +2 -1
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/NewWorkspaceAppFlow.d.ts.map +1 -1
- package/dist/client/NewWorkspaceAppFlow.js +3 -2
- package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
- package/dist/client/browser-session-bridge.d.ts +44 -0
- package/dist/client/browser-session-bridge.d.ts.map +1 -0
- package/dist/client/browser-session-bridge.js +339 -0
- package/dist/client/browser-session-bridge.js.map +1 -0
- package/dist/client/client-action.d.ts +7 -0
- package/dist/client/client-action.d.ts.map +1 -0
- package/dist/client/client-action.js +4 -0
- package/dist/client/client-action.js.map +1 -0
- package/dist/client/components/ui/tooltip.d.ts.map +1 -1
- package/dist/client/components/ui/tooltip.js +1 -1
- package/dist/client/components/ui/tooltip.js.map +1 -1
- package/dist/client/composer/AgentComposerFrame.d.ts +17 -0
- package/dist/client/composer/AgentComposerFrame.d.ts.map +1 -0
- package/dist/client/composer/AgentComposerFrame.js +14 -0
- package/dist/client/composer/AgentComposerFrame.js.map +1 -0
- package/dist/client/composer/MentionPopover.d.ts.map +1 -1
- package/dist/client/composer/MentionPopover.js +2 -2
- package/dist/client/composer/MentionPopover.js.map +1 -1
- package/dist/client/composer/PromptComposer.d.ts +35 -2
- package/dist/client/composer/PromptComposer.d.ts.map +1 -1
- package/dist/client/composer/PromptComposer.js +31 -17
- package/dist/client/composer/PromptComposer.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +20 -2
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +112 -22
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/index.d.ts +3 -2
- package/dist/client/composer/index.d.ts.map +1 -1
- package/dist/client/composer/index.js +1 -0
- package/dist/client/composer/index.js.map +1 -1
- package/dist/client/composer/types.d.ts +1 -0
- package/dist/client/composer/types.d.ts.map +1 -1
- package/dist/client/composer/types.js.map +1 -1
- package/dist/client/extensions/AgentNativeExtensionFrame.d.ts +58 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.d.ts.map +1 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.d.ts +2 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.d.ts.map +1 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.js +110 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.js.map +1 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.js +354 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.js.map +1 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.spec.d.ts +2 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.spec.d.ts.map +1 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.spec.js +68 -0
- package/dist/client/extensions/AgentNativeExtensionFrame.spec.js.map +1 -0
- package/dist/client/extensions/agent-native-extension-runtime.d.ts +69 -0
- package/dist/client/extensions/agent-native-extension-runtime.d.ts.map +1 -0
- package/dist/client/extensions/agent-native-extension-runtime.js +348 -0
- package/dist/client/extensions/agent-native-extension-runtime.js.map +1 -0
- package/dist/client/extensions/index.d.ts +2 -0
- package/dist/client/extensions/index.d.ts.map +1 -1
- package/dist/client/extensions/index.js +2 -0
- package/dist/client/extensions/index.js.map +1 -1
- package/dist/client/extensions/portable-extension.d.ts +86 -0
- package/dist/client/extensions/portable-extension.d.ts.map +1 -0
- package/dist/client/extensions/portable-extension.js +480 -0
- package/dist/client/extensions/portable-extension.js.map +1 -0
- package/dist/client/host-bridge.d.ts +266 -0
- package/dist/client/host-bridge.d.ts.map +1 -0
- package/dist/client/host-bridge.js +745 -0
- package/dist/client/host-bridge.js.map +1 -0
- package/dist/client/host-tools.d.ts +40 -0
- package/dist/client/host-tools.d.ts.map +1 -0
- package/dist/client/host-tools.js +94 -0
- package/dist/client/host-tools.js.map +1 -0
- package/dist/client/index.d.ts +13 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +11 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.d.ts +10 -0
- package/dist/client/resources/BuiltinCapabilityDetail.d.ts.map +1 -0
- package/dist/client/resources/BuiltinCapabilityDetail.js +51 -0
- package/dist/client/resources/BuiltinCapabilityDetail.js.map +1 -0
- package/dist/client/resources/ResourceEditor.d.ts +3 -1
- package/dist/client/resources/ResourceEditor.d.ts.map +1 -1
- package/dist/client/resources/ResourceEditor.js +40 -17
- package/dist/client/resources/ResourceEditor.js.map +1 -1
- package/dist/client/resources/ResourceTree.d.ts.map +1 -1
- package/dist/client/resources/ResourceTree.js +23 -2
- package/dist/client/resources/ResourceTree.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +77 -17
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/resources/index.d.ts +1 -0
- package/dist/client/resources/index.d.ts.map +1 -1
- package/dist/client/resources/index.js +1 -0
- package/dist/client/resources/index.js.map +1 -1
- package/dist/client/resources/use-builtin-capabilities.d.ts +62 -0
- package/dist/client/resources/use-builtin-capabilities.d.ts.map +1 -0
- package/dist/client/resources/use-builtin-capabilities.js +54 -0
- package/dist/client/resources/use-builtin-capabilities.js.map +1 -0
- package/dist/client/resources/use-resources.d.ts +30 -2
- package/dist/client/resources/use-resources.d.ts.map +1 -1
- package/dist/client/resources/use-resources.js +42 -1
- package/dist/client/resources/use-resources.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +151 -2
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/use-chat-models.d.ts.map +1 -1
- package/dist/client/use-chat-models.js +20 -0
- package/dist/client/use-chat-models.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +46 -2
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/use-chat-threads.spec.js +77 -0
- package/dist/client/use-chat-threads.spec.js.map +1 -1
- package/dist/code-agents/index.d.ts +4 -0
- package/dist/code-agents/index.d.ts.map +1 -0
- package/dist/code-agents/index.js +4 -0
- package/dist/code-agents/index.js.map +1 -0
- package/dist/connections/catalog.d.ts +134 -0
- package/dist/connections/catalog.d.ts.map +1 -0
- package/dist/connections/catalog.js +180 -0
- package/dist/connections/catalog.js.map +1 -0
- package/dist/connections/index.d.ts +2 -0
- package/dist/connections/index.d.ts.map +1 -0
- package/dist/connections/index.js +2 -0
- package/dist/connections/index.js.map +1 -0
- package/dist/extensions/change-marker.d.ts +10 -0
- package/dist/extensions/change-marker.d.ts.map +1 -0
- package/dist/extensions/change-marker.js +42 -0
- package/dist/extensions/change-marker.js.map +1 -0
- package/dist/extensions/routes.d.ts.map +1 -1
- package/dist/extensions/routes.js +1 -7
- package/dist/extensions/routes.js.map +1 -1
- package/dist/extensions/schema.d.ts +1 -0
- package/dist/extensions/schema.d.ts.map +1 -1
- package/dist/extensions/schema.js +1 -0
- package/dist/extensions/schema.js.map +1 -1
- package/dist/extensions/slots/routes.js +1 -1
- package/dist/extensions/slots/routes.js.map +1 -1
- package/dist/extensions/store.d.ts +3 -0
- package/dist/extensions/store.d.ts.map +1 -1
- package/dist/extensions/store.js +112 -4
- package/dist/extensions/store.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/adapters/telegram.d.ts.map +1 -1
- package/dist/integrations/adapters/telegram.js +1 -0
- package/dist/integrations/adapters/telegram.js.map +1 -1
- package/dist/integrations/index.d.ts +5 -1
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +4 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/plugin.d.ts +8 -0
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +760 -32
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/remote-commands-store.d.ts +36 -0
- package/dist/integrations/remote-commands-store.d.ts.map +1 -0
- package/dist/integrations/remote-commands-store.js +273 -0
- package/dist/integrations/remote-commands-store.js.map +1 -0
- package/dist/integrations/remote-devices-store.d.ts +43 -0
- package/dist/integrations/remote-devices-store.d.ts.map +1 -0
- package/dist/integrations/remote-devices-store.js +315 -0
- package/dist/integrations/remote-devices-store.js.map +1 -0
- package/dist/integrations/remote-push-store.d.ts +37 -0
- package/dist/integrations/remote-push-store.d.ts.map +1 -0
- package/dist/integrations/remote-push-store.js +299 -0
- package/dist/integrations/remote-push-store.js.map +1 -0
- package/dist/integrations/remote-retry-job.d.ts +7 -0
- package/dist/integrations/remote-retry-job.d.ts.map +1 -0
- package/dist/integrations/remote-retry-job.js +45 -0
- package/dist/integrations/remote-retry-job.js.map +1 -0
- package/dist/integrations/remote-run-events-store.d.ts +18 -0
- package/dist/integrations/remote-run-events-store.d.ts.map +1 -0
- package/dist/integrations/remote-run-events-store.js +82 -0
- package/dist/integrations/remote-run-events-store.js.map +1 -0
- package/dist/integrations/remote-types.d.ts +101 -0
- package/dist/integrations/remote-types.d.ts.map +1 -0
- package/dist/integrations/remote-types.js +2 -0
- package/dist/integrations/remote-types.js.map +1 -0
- package/dist/integrations/webhook-handler.d.ts +2 -0
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +4 -1
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/jobs/scheduler.d.ts +4 -2
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +9 -3
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/mcp-client/builtin-capabilities.d.ts +20 -0
- package/dist/mcp-client/builtin-capabilities.d.ts.map +1 -0
- package/dist/mcp-client/builtin-capabilities.js +75 -0
- package/dist/mcp-client/builtin-capabilities.js.map +1 -0
- package/dist/mcp-client/builtin-store.d.ts +10 -0
- package/dist/mcp-client/builtin-store.d.ts.map +1 -0
- package/dist/mcp-client/builtin-store.js +55 -0
- package/dist/mcp-client/builtin-store.js.map +1 -0
- package/dist/mcp-client/index.d.ts +3 -1
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +3 -1
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/mcp-client/routes.d.ts +28 -0
- package/dist/mcp-client/routes.d.ts.map +1 -1
- package/dist/mcp-client/routes.js +195 -1
- package/dist/mcp-client/routes.js.map +1 -1
- package/dist/org/context.d.ts.map +1 -1
- package/dist/org/context.js +34 -0
- package/dist/org/context.js.map +1 -1
- package/dist/resources/handlers.d.ts +4 -0
- package/dist/resources/handlers.d.ts.map +1 -1
- package/dist/resources/handlers.js +46 -7
- package/dist/resources/handlers.js.map +1 -1
- package/dist/resources/script-helpers.d.ts +8 -1
- package/dist/resources/script-helpers.d.ts.map +1 -1
- package/dist/resources/script-helpers.js +18 -8
- package/dist/resources/script-helpers.js.map +1 -1
- package/dist/resources/store.d.ts +19 -0
- package/dist/resources/store.d.ts.map +1 -1
- package/dist/resources/store.js +86 -3
- package/dist/resources/store.js.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.d.ts +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.js +18 -7
- package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
- package/dist/scripts/agent-engines/manage-agent-engine.d.ts.map +1 -1
- package/dist/scripts/agent-engines/manage-agent-engine.js +100 -7
- package/dist/scripts/agent-engines/manage-agent-engine.js.map +1 -1
- package/dist/scripts/resources/delete.d.ts.map +1 -1
- package/dist/scripts/resources/delete.js +4 -1
- package/dist/scripts/resources/delete.js.map +1 -1
- package/dist/scripts/resources/effective.d.ts +11 -0
- package/dist/scripts/resources/effective.d.ts.map +1 -0
- package/dist/scripts/resources/effective.js +54 -0
- package/dist/scripts/resources/effective.js.map +1 -0
- package/dist/scripts/resources/index.d.ts.map +1 -1
- package/dist/scripts/resources/index.js +1 -0
- package/dist/scripts/resources/index.js.map +1 -1
- package/dist/scripts/resources/list.d.ts +1 -1
- package/dist/scripts/resources/list.d.ts.map +1 -1
- package/dist/scripts/resources/list.js +17 -5
- package/dist/scripts/resources/list.js.map +1 -1
- package/dist/scripts/resources/read.d.ts +1 -1
- package/dist/scripts/resources/read.d.ts.map +1 -1
- package/dist/scripts/resources/read.js +20 -5
- package/dist/scripts/resources/read.js.map +1 -1
- package/dist/scripts/resources/write.d.ts.map +1 -1
- package/dist/scripts/resources/write.js +4 -1
- package/dist/scripts/resources/write.js.map +1 -1
- package/dist/scripts/runner.d.ts +11 -1
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +75 -27
- package/dist/scripts/runner.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +5 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +24 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +608 -54
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +2 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/embedded.d.ts +72 -0
- package/dist/server/embedded.d.ts.map +1 -0
- package/dist/server/embedded.js +119 -0
- package/dist/server/embedded.js.map +1 -0
- package/dist/server/index.d.ts +8 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +7 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/poll.d.ts.map +1 -1
- package/dist/server/poll.js +184 -13
- package/dist/server/poll.js.map +1 -1
- package/dist/server/resources-plugin.d.ts.map +1 -1
- package/dist/server/resources-plugin.js +11 -2
- package/dist/server/resources-plugin.js.map +1 -1
- package/dist/sharing/actions/extension-change.d.ts +4 -0
- package/dist/sharing/actions/extension-change.d.ts.map +1 -0
- package/dist/sharing/actions/extension-change.js +13 -0
- package/dist/sharing/actions/extension-change.js.map +1 -0
- package/dist/sharing/actions/set-resource-visibility.d.ts.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.js +3 -0
- package/dist/sharing/actions/set-resource-visibility.js.map +1 -1
- package/dist/sharing/actions/share-resource.d.ts.map +1 -1
- package/dist/sharing/actions/share-resource.js +4 -0
- package/dist/sharing/actions/share-resource.js.map +1 -1
- package/dist/sharing/actions/unshare-resource.d.ts.map +1 -1
- package/dist/sharing/actions/unshare-resource.js +3 -0
- package/dist/sharing/actions/unshare-resource.js.map +1 -1
- package/dist/templates/default/AGENTS.md +3 -3
- package/dist/templates/workspace-core/AGENTS.md +7 -0
- package/dist/templates/workspace-root/AGENTS.md +7 -0
- package/dist/templates/workspace-root/README.md +25 -0
- package/dist/triggers/dispatcher.d.ts +3 -1
- package/dist/triggers/dispatcher.d.ts.map +1 -1
- package/dist/triggers/dispatcher.js +9 -3
- package/dist/triggers/dispatcher.js.map +1 -1
- package/dist/workspace-connections/index.d.ts +2 -0
- package/dist/workspace-connections/index.d.ts.map +1 -0
- package/dist/workspace-connections/index.js +2 -0
- package/dist/workspace-connections/index.js.map +1 -0
- package/dist/workspace-connections/store.d.ts +229 -0
- package/dist/workspace-connections/store.d.ts.map +1 -0
- package/dist/workspace-connections/store.js +938 -0
- package/dist/workspace-connections/store.js.map +1 -0
- package/docs/content/agent-teams.md +6 -0
- package/docs/content/cloneable-saas.md +1 -0
- package/docs/content/code-agents-ui.md +261 -0
- package/docs/content/dispatch.md +40 -3
- package/docs/content/embedding-sdk.md +459 -0
- package/docs/content/faq.md +1 -0
- package/docs/content/getting-started.md +1 -0
- package/docs/content/mcp-clients.md +41 -3
- package/docs/content/migration-workbench.md +237 -54
- package/docs/content/multi-app-workspace.md +41 -0
- package/docs/content/multi-tenancy.md +1 -1
- package/docs/content/template-brain.md +418 -0
- package/docs/content/template-dispatch.md +30 -0
- package/docs/content/workspace-connections.md +509 -0
- package/docs/content/workspace-management.md +12 -12
- package/docs/content/workspace.md +180 -40
- package/package.json +7 -2
- package/src/templates/default/AGENTS.md +3 -3
- package/src/templates/workspace-core/AGENTS.md +7 -0
- package/src/templates/workspace-root/AGENTS.md +7 -0
- package/src/templates/workspace-root/README.md +25 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/workspace-connections/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,SAAS,EACT,OAAO,EACP,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,GAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,gCAAgC,GAIjC,MAAM,2BAA2B,CAAC;AAuQnC,IAAI,YAAuC,CAAC;AAE5C,SAAS,yBAAyB;IAChC,OAAO,UAAU,EAAE;QACjB,CAAC,CAAC,8BAA8B;QAChC,CAAC,CAAC,uBAAuB,CAAC;AAC9B,CAAC;AAED,SAAS,8BAA8B;IACrC,OAAO,UAAU,EAAE;QACjB,CAAC,CAAC,oCAAoC;QACtC,CAAC,CAAC,6BAA6B,CAAC;AACpC,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAY;IAC1C,MAAM,IAAI,GAAG,MAAM,CAAE,GAA0B,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,MAAM,CAAE,GAA6B,EAAE,OAAO,IAAI,GAAG,CAAC;SACnE,WAAW,EAAE;SACb,IAAI,E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,eAAe,KAAK,qBAAqB,KAAK,CAAC,GAAG,EAAE;QACzD,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;KAC1B,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,MAAM,CAAC,OAAO,CAAC;YACnB,GAAG,EAAE,eAAe,WAAW,gCAAgC,KAAK,CAAC,GAAG,EAAE;YAC1E,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport {\n getDbExec,\n intType,\n isPostgres,\n isUniqueViolation,\n retryOnDdlRace,\n safeJsonParse,\n type DbExec,\n} from \"../db/client.js\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n} from \"../server/request-context.js\";\nimport {\n listWorkspaceConnectionProviders,\n type WorkspaceConnectionCapability,\n type WorkspaceConnectionProvider,\n type WorkspaceConnectionTemplateUse,\n} from \"../connections/catalog.js\";\n\nexport type WorkspaceConnectionStatus =\n | \"connected\"\n | \"checking\"\n | \"needs_reauth\"\n | \"error\"\n | \"disabled\";\n\nexport interface WorkspaceConnectionCredentialRef {\n key: string;\n scope?: \"user\" | \"org\" | \"workspace\";\n provider?: string;\n label?: string;\n [key: string]: unknown;\n}\n\nexport interface WorkspaceConnection {\n id: string;\n provider: string;\n label: string;\n accountId: string | null;\n accountLabel: string | null;\n status: WorkspaceConnectionStatus;\n scopes: string[];\n config: Record<string, unknown>;\n allowedApps: string[];\n credentialRefs: WorkspaceConnectionCredentialRef[];\n ownerEmail: string;\n orgId: string | null;\n createdAt: string;\n updatedAt: string;\n lastCheckedAt: string | null;\n lastError: string | null;\n}\n\nexport type SerializedWorkspaceConnection = WorkspaceConnection;\n\nexport interface WorkspaceConnectionGrant {\n id: string;\n connectionId: string;\n provider: string;\n appId: string;\n scopes: string[];\n config: Record<string, unknown>;\n credentialRefs: WorkspaceConnectionCredentialRef[];\n grantedByEmail: string;\n ownerEmail: string;\n orgId: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport type SerializedWorkspaceConnectionGrant = WorkspaceConnectionGrant;\n\nexport interface ListWorkspaceConnectionsOptions {\n provider?: string;\n appId?: string;\n includeDisabled?: boolean;\n}\n\nexport interface ListWorkspaceConnectionGrantsOptions {\n connectionId?: string;\n appId?: string;\n provider?: string;\n}\n\nexport interface ListWorkspaceConnectionsForAppOptions {\n appId: string;\n provider?: string;\n includeDisabled?: boolean;\n}\n\nexport interface ResolveWorkspaceConnectionForAppOptions extends ListWorkspaceConnectionsForAppOptions {\n connectionId?: string;\n requireConnected?: boolean;\n}\n\nexport interface UpsertWorkspaceConnectionInput {\n id?: string;\n provider: string;\n label?: string;\n accountId?: string | null;\n accountLabel?: string | null;\n status?: WorkspaceConnectionStatus;\n scopes?: string[];\n config?: Record<string, unknown>;\n allowedApps?: string[];\n credentialRefs?: WorkspaceConnectionCredentialRef[];\n lastCheckedAt?: Date | number | string | null;\n lastError?: string | null;\n}\n\nexport interface UpsertWorkspaceConnectionGrantInput {\n id?: string;\n connectionId: string;\n appId: string;\n provider?: string;\n scopes?: string[];\n config?: Record<string, unknown>;\n credentialRefs?: WorkspaceConnectionCredentialRef[];\n}\n\nexport type WorkspaceConnectionAppAccessMode =\n | \"all-apps\"\n | \"allowed-app\"\n | \"explicit-grant\"\n | \"unavailable\";\n\nexport interface WorkspaceConnectionAppAccess {\n appId: string;\n available: boolean;\n mode: WorkspaceConnectionAppAccessMode;\n reason: string;\n grantId: string | null;\n}\n\nexport type WorkspaceConnectionGrantState =\n | \"connected\"\n | \"granted\"\n | \"needs_grant\"\n | \"not_connected\";\n\nexport type WorkspaceConnectionGrantAvailability =\n | \"available\"\n | \"needs_grant\"\n | \"not_connected\";\n\nexport type WorkspaceConnectionProviderReadinessStatus =\n | \"ready\"\n | \"checking\"\n | \"needs_credentials\"\n | \"needs_attention\"\n | \"disabled\"\n | \"not_configured\";\n\nexport interface WorkspaceConnectionPublicCredentialRef {\n key: string;\n scope?: string;\n provider?: string;\n label?: string;\n source: \"connection\" | \"grant\";\n}\n\nexport interface WorkspaceConnectionExplicitGrantSummary {\n id: string;\n appId: string;\n scopes: string[];\n credentialRefs: WorkspaceConnectionPublicCredentialRef[];\n updatedAt: string;\n}\n\nexport interface WorkspaceConnectionForAppSummary {\n id: string;\n label: string;\n provider: string;\n accountId: string | null;\n accountLabel: string | null;\n status: WorkspaceConnectionStatus;\n grantedToApp: boolean;\n grantScope: \"all-apps\" | \"selected-apps\";\n appAccess: WorkspaceConnectionAppAccess;\n allowedApps: string[];\n credentialRefs: WorkspaceConnectionPublicCredentialRef[];\n lastCheckedAt: string | null;\n lastError: string | null;\n explicitGrant: WorkspaceConnectionExplicitGrantSummary | null;\n}\n\nexport interface WorkspaceConnectionForApp extends SerializedWorkspaceConnection {\n appAccess: WorkspaceConnectionAppAccess;\n explicitGrant: SerializedWorkspaceConnectionGrant | null;\n}\n\nexport interface ResolvedWorkspaceConnectionForApp {\n available: boolean;\n connection: WorkspaceConnectionForApp | null;\n appAccess: WorkspaceConnectionAppAccess | null;\n reason: string;\n}\n\nexport interface WorkspaceConnectionProviderAppSummary {\n appId: string;\n provider: string;\n grantState: WorkspaceConnectionGrantState;\n grantAvailability: WorkspaceConnectionGrantAvailability;\n grantAvailabilityMessage: string;\n connectionCount: number;\n grantedConnectionCount: number;\n activeConnectionCount: number;\n ungrantedConnectionCount: number;\n unhealthyGrantedConnectionCount: number;\n explicitGrantCount: number;\n credentialRefCount: number;\n hasWorkspaceConnection: boolean;\n hasGrantedWorkspaceConnection: boolean;\n hasActiveWorkspaceConnection: boolean;\n statuses: WorkspaceConnectionStatus[];\n connections: WorkspaceConnectionForAppSummary[];\n}\n\nexport interface WorkspaceConnectionProviderReadiness {\n status: WorkspaceConnectionProviderReadinessStatus;\n connectionCount: number;\n activeConnectionCount: number;\n readyConnectionCount: number;\n requiredCredentialKeys: string[];\n missingRequiredCredentialKeys: string[];\n appGrant: WorkspaceConnectionProviderAppSummary | null;\n}\n\nexport interface WorkspaceConnectionProviderLike {\n id: string;\n label?: string;\n credentialKeys?: readonly {\n key: string;\n required?: boolean;\n }[];\n}\n\nexport interface SummarizeWorkspaceConnectionProviderForAppOptions {\n providerId: string;\n appId: string;\n connections: SerializedWorkspaceConnection[];\n grants?: SerializedWorkspaceConnectionGrant[];\n includeConnections?: \"all\" | \"granted\";\n}\n\nexport interface SummarizeWorkspaceConnectionProviderReadinessOptions {\n provider: WorkspaceConnectionProviderLike;\n connections: SerializedWorkspaceConnection[];\n grants?: SerializedWorkspaceConnectionGrant[];\n appId?: string;\n includeConnections?: \"all\" | \"granted\";\n}\n\nexport interface ListWorkspaceConnectionProviderCatalogForAppOptions {\n appId: string;\n provider?: string;\n capability?: WorkspaceConnectionCapability;\n templateUse?: WorkspaceConnectionTemplateUse;\n includeDisabled?: boolean;\n includeConnections?: \"all\" | \"granted\";\n}\n\nexport interface WorkspaceConnectionProviderCatalogForAppItem extends WorkspaceConnectionProvider {\n workspaceConnection: WorkspaceConnectionProviderAppSummary;\n readiness: WorkspaceConnectionProviderReadiness;\n}\n\nexport interface WorkspaceConnectionProviderCatalogForApp {\n appId: string;\n providers: WorkspaceConnectionProviderCatalogForAppItem[];\n connections: SerializedWorkspaceConnection[];\n grants: SerializedWorkspaceConnectionGrant[];\n counts: {\n providers: number;\n connections: number;\n grants: number;\n readyProviders: number;\n };\n}\n\nlet _initPromise: Promise<void> | undefined;\n\nfunction workspaceConnectionsTable(): string {\n return isPostgres()\n ? \"public.workspace_connections\"\n : \"workspace_connections\";\n}\n\nfunction workspaceConnectionGrantsTable(): string {\n return isPostgres()\n ? \"public.workspace_connection_grants\"\n : \"workspace_connection_grants\";\n}\n\nfunction isDuplicateColumnError(err: unknown): boolean {\n const code = String((err as { code?: unknown })?.code ?? \"\");\n const message = String((err as { message?: unknown })?.message ?? err)\n .toLowerCase()\n .trim();\n return (\n code === \"42701\" ||\n message.includes(\"duplicate column\") ||\n message.includes(\"already exists\")\n );\n}\n\nasync function ensureColumn(\n client: DbExec,\n table: string,\n name: string,\n definition: string,\n): Promise<void> {\n try {\n await retryOnDdlRace(() =>\n client.execute(\n isPostgres()\n ? `ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS ${name} ${definition}`\n : `ALTER TABLE ${table} ADD COLUMN ${name} ${definition}`,\n ),\n );\n } catch (err) {\n if (!isDuplicateColumnError(err)) throw err;\n }\n}\n\nasync function ensureWorkspaceConnectionColumns(\n client: DbExec,\n table: string,\n): Promise<void> {\n await ensureColumn(client, table, \"provider\", \"TEXT NOT NULL DEFAULT ''\");\n await ensureColumn(client, table, \"label\", \"TEXT NOT NULL DEFAULT ''\");\n await ensureColumn(client, table, \"account_id\", \"TEXT\");\n await ensureColumn(client, table, \"account_label\", \"TEXT\");\n await ensureColumn(\n client,\n table,\n \"status\",\n \"TEXT NOT NULL DEFAULT 'connected'\",\n );\n await ensureColumn(\n client,\n table,\n \"scopes_json\",\n \"TEXT NOT NULL DEFAULT '[]'\",\n );\n await ensureColumn(\n client,\n table,\n \"config_json\",\n \"TEXT NOT NULL DEFAULT '{}'\",\n );\n await ensureColumn(\n client,\n table,\n \"allowed_apps_json\",\n \"TEXT NOT NULL DEFAULT '[]'\",\n );\n await ensureColumn(\n client,\n table,\n \"credential_refs_json\",\n \"TEXT NOT NULL DEFAULT '[]'\",\n );\n await ensureColumn(client, table, \"owner_email\", \"TEXT NOT NULL DEFAULT ''\");\n await ensureColumn(client, table, \"org_id\", \"TEXT\");\n await ensureColumn(\n client,\n table,\n \"created_at\",\n `${intType()} NOT NULL DEFAULT 0`,\n );\n await ensureColumn(\n client,\n table,\n \"updated_at\",\n `${intType()} NOT NULL DEFAULT 0`,\n );\n await ensureColumn(client, table, \"last_checked_at\", intType());\n await ensureColumn(client, table, \"last_error\", \"TEXT\");\n}\n\nasync function ensureWorkspaceConnectionGrantColumns(\n client: DbExec,\n table: string,\n): Promise<void> {\n await ensureColumn(\n client,\n table,\n \"connection_id\",\n \"TEXT NOT NULL DEFAULT ''\",\n );\n await ensureColumn(client, table, \"provider\", \"TEXT NOT NULL DEFAULT ''\");\n await ensureColumn(client, table, \"app_id\", \"TEXT NOT NULL DEFAULT ''\");\n await ensureColumn(\n client,\n table,\n \"scopes_json\",\n \"TEXT NOT NULL DEFAULT '[]'\",\n );\n await ensureColumn(\n client,\n table,\n \"config_json\",\n \"TEXT NOT NULL DEFAULT '{}'\",\n );\n await ensureColumn(\n client,\n table,\n \"credential_refs_json\",\n \"TEXT NOT NULL DEFAULT '[]'\",\n );\n await ensureColumn(\n client,\n table,\n \"granted_by_email\",\n \"TEXT NOT NULL DEFAULT ''\",\n );\n await ensureColumn(client, table, \"owner_email\", \"TEXT NOT NULL DEFAULT ''\");\n await ensureColumn(client, table, \"org_id\", \"TEXT\");\n await ensureColumn(\n client,\n table,\n \"created_at\",\n `${intType()} NOT NULL DEFAULT 0`,\n );\n await ensureColumn(\n client,\n table,\n \"updated_at\",\n `${intType()} NOT NULL DEFAULT 0`,\n );\n}\n\nexport async function ensureWorkspaceConnectionsTable(): Promise<void> {\n if (!_initPromise) {\n _initPromise = (async () => {\n const client = getDbExec();\n const table = workspaceConnectionsTable();\n const grantsTable = workspaceConnectionGrantsTable();\n await retryOnDdlRace(() =>\n client.execute(`\n CREATE TABLE IF NOT EXISTS ${table} (\n id TEXT PRIMARY KEY,\n provider TEXT NOT NULL DEFAULT '',\n label TEXT NOT NULL DEFAULT '',\n account_id TEXT,\n account_label TEXT,\n status TEXT NOT NULL DEFAULT 'connected',\n scopes_json TEXT NOT NULL DEFAULT '[]',\n config_json TEXT NOT NULL DEFAULT '{}',\n allowed_apps_json TEXT NOT NULL DEFAULT '[]',\n credential_refs_json TEXT NOT NULL DEFAULT '[]',\n owner_email TEXT NOT NULL DEFAULT '',\n org_id TEXT,\n created_at ${intType()} NOT NULL DEFAULT 0,\n updated_at ${intType()} NOT NULL DEFAULT 0,\n last_checked_at ${intType()},\n last_error TEXT\n )\n `),\n );\n\n await ensureWorkspaceConnectionColumns(client, table);\n\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_workspace_connections_scope_provider ON ${table} (org_id, owner_email, provider)`,\n ),\n );\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_workspace_connections_updated_at ON ${table} (updated_at)`,\n ),\n );\n await retryOnDdlRace(() =>\n client.execute(`\n CREATE TABLE IF NOT EXISTS ${grantsTable} (\n id TEXT PRIMARY KEY,\n connection_id TEXT NOT NULL DEFAULT '',\n provider TEXT NOT NULL DEFAULT '',\n app_id TEXT NOT NULL DEFAULT '',\n scopes_json TEXT NOT NULL DEFAULT '[]',\n config_json TEXT NOT NULL DEFAULT '{}',\n credential_refs_json TEXT NOT NULL DEFAULT '[]',\n granted_by_email TEXT NOT NULL DEFAULT '',\n owner_email TEXT NOT NULL DEFAULT '',\n org_id TEXT,\n created_at ${intType()} NOT NULL DEFAULT 0,\n updated_at ${intType()} NOT NULL DEFAULT 0\n )\n `),\n );\n\n await ensureWorkspaceConnectionGrantColumns(client, grantsTable);\n\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE UNIQUE INDEX IF NOT EXISTS idx_workspace_connection_grants_connection_app ON ${grantsTable} (connection_id, app_id)`,\n ),\n );\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_workspace_connection_grants_scope_app ON ${grantsTable} (org_id, owner_email, app_id)`,\n ),\n );\n await retryOnDdlRace(() =>\n client.execute(\n `CREATE INDEX IF NOT EXISTS idx_workspace_connection_grants_updated_at ON ${grantsTable} (updated_at)`,\n ),\n );\n })().catch((err) => {\n _initPromise = undefined;\n throw err;\n });\n }\n return _initPromise;\n}\n\nfunction requireWorkspaceConnectionScope(): {\n ownerEmail: string;\n orgId: string | null;\n} {\n const ownerEmail = getRequestUserEmail()?.trim().toLowerCase();\n if (!ownerEmail) {\n throw new Error(\"Workspace connections require an authenticated user.\");\n }\n return {\n ownerEmail,\n orgId: getRequestOrgId()?.trim() || null,\n };\n}\n\nfunction scopedWhere(\n scope: ReturnType<typeof requireWorkspaceConnectionScope>,\n): { sql: string; args: string[] } {\n if (scope.orgId) {\n return { sql: \"org_id = ?\", args: [scope.orgId] };\n }\n return {\n sql: \"owner_email = ? AND org_id IS NULL\",\n args: [scope.ownerEmail],\n };\n}\n\nfunction normalizeStringArray(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value\n .filter((entry): entry is string => typeof entry === \"string\")\n .map((entry) => entry.trim())\n .filter(Boolean);\n}\n\nfunction normalizeRequiredString(value: unknown, label: string): string {\n const normalized = typeof value === \"string\" ? value.trim() : \"\";\n if (!normalized) {\n throw new Error(`${label} is required.`);\n }\n return normalized;\n}\n\nfunction normalizeObject(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n return value as Record<string, unknown>;\n}\n\nfunction normalizeCredentialRefs(\n value: unknown,\n): WorkspaceConnectionCredentialRef[] {\n if (!Array.isArray(value)) return [];\n return value\n .filter(\n (entry): entry is WorkspaceConnectionCredentialRef =>\n !!entry &&\n typeof entry === \"object\" &&\n !Array.isArray(entry) &&\n typeof (entry as WorkspaceConnectionCredentialRef).key === \"string\",\n )\n .map((entry) => sanitizeCredentialRef(entry))\n .filter((entry) => entry.key.trim().length > 0);\n}\n\nfunction normalizeStatus(value: unknown): WorkspaceConnectionStatus {\n if (\n value === \"checking\" ||\n value === \"needs_reauth\" ||\n value === \"error\" ||\n value === \"disabled\"\n ) {\n return value;\n }\n return \"connected\";\n}\n\nfunction millis(\n value: Date | number | string | null | undefined,\n): number | null {\n if (value == null) return null;\n if (value instanceof Date) return value.getTime();\n if (typeof value === \"number\" && Number.isFinite(value)) return value;\n const parsed = Date.parse(String(value));\n return Number.isFinite(parsed) ? parsed : null;\n}\n\nfunction iso(value: unknown): string | null {\n if (value == null) return null;\n const num = Number(value);\n if (!Number.isFinite(num) || num <= 0) return null;\n return new Date(num).toISOString();\n}\n\nconst SECRET_KEYS = new Set([\n \"apikey\",\n \"authorization\",\n \"clientsecret\",\n \"cookie\",\n \"password\",\n \"privatekey\",\n \"refreshtoken\",\n \"secret\",\n \"token\",\n \"accesstoken\",\n]);\n\nfunction normalizedKey(key: string): string {\n return key.toLowerCase().replace(/[^a-z0-9]/g, \"\");\n}\n\nfunction sanitizeJson(value: unknown, allowCredentialRefKey = false): unknown {\n if (Array.isArray(value)) {\n return value.map((entry) => sanitizeJson(entry, allowCredentialRefKey));\n }\n if (!value || typeof value !== \"object\") return value;\n\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const normalized = normalizedKey(key);\n if (\n SECRET_KEYS.has(normalized) &&\n !(allowCredentialRefKey && normalized === \"key\")\n ) {\n result[key] = \"[redacted]\";\n continue;\n }\n result[key] = sanitizeJson(entry, allowCredentialRefKey);\n }\n return result;\n}\n\nfunction sanitizeConfig(\n config: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n return sanitizeJson(normalizeObject(config), false) as Record<\n string,\n unknown\n >;\n}\n\nfunction sanitizeCredentialRef(\n ref: WorkspaceConnectionCredentialRef,\n): WorkspaceConnectionCredentialRef {\n const sanitized = sanitizeJson(ref, true) as WorkspaceConnectionCredentialRef;\n if (Object.prototype.hasOwnProperty.call(sanitized, \"value\")) {\n sanitized.value = \"[redacted]\";\n }\n return sanitized;\n}\n\nfunction parseRow(row: Record<string, unknown>): WorkspaceConnection {\n return serializeWorkspaceConnection({\n id: String(row.id),\n provider: String(row.provider ?? \"\"),\n label: String(row.label ?? \"\"),\n accountId: row.account_id == null ? null : String(row.account_id),\n accountLabel: row.account_label == null ? null : String(row.account_label),\n status: normalizeStatus(row.status),\n scopes: normalizeStringArray(safeJsonParse<unknown>(row.scopes_json, [])),\n config: normalizeObject(safeJsonParse<unknown>(row.config_json, {})),\n allowedApps: normalizeStringArray(\n safeJsonParse<unknown>(row.allowed_apps_json, []),\n ),\n credentialRefs: normalizeCredentialRefs(\n safeJsonParse<unknown>(row.credential_refs_json, []),\n ),\n ownerEmail: String(row.owner_email ?? \"\"),\n orgId: row.org_id == null ? null : String(row.org_id),\n createdAt: iso(row.created_at) ?? new Date(0).toISOString(),\n updatedAt: iso(row.updated_at) ?? new Date(0).toISOString(),\n lastCheckedAt: iso(row.last_checked_at),\n lastError: row.last_error == null ? null : String(row.last_error),\n });\n}\n\nfunction parseGrantRow(row: Record<string, unknown>): WorkspaceConnectionGrant {\n return serializeWorkspaceConnectionGrant({\n id: String(row.id),\n connectionId: String(row.connection_id ?? \"\"),\n provider: String(row.provider ?? \"\"),\n appId: String(row.app_id ?? \"\"),\n scopes: normalizeStringArray(safeJsonParse<unknown>(row.scopes_json, [])),\n config: normalizeObject(safeJsonParse<unknown>(row.config_json, {})),\n credentialRefs: normalizeCredentialRefs(\n safeJsonParse<unknown>(row.credential_refs_json, []),\n ),\n grantedByEmail: String(row.granted_by_email ?? \"\"),\n ownerEmail: String(row.owner_email ?? \"\"),\n orgId: row.org_id == null ? null : String(row.org_id),\n createdAt: iso(row.created_at) ?? new Date(0).toISOString(),\n updatedAt: iso(row.updated_at) ?? new Date(0).toISOString(),\n });\n}\n\nexport function serializeWorkspaceConnection(\n connection: WorkspaceConnection,\n): SerializedWorkspaceConnection {\n return {\n ...connection,\n scopes: normalizeStringArray(connection.scopes),\n config: sanitizeConfig(connection.config),\n allowedApps: normalizeStringArray(connection.allowedApps),\n credentialRefs: normalizeCredentialRefs(connection.credentialRefs),\n };\n}\n\nexport function serializeWorkspaceConnectionGrant(\n grant: WorkspaceConnectionGrant,\n): SerializedWorkspaceConnectionGrant {\n return {\n ...grant,\n scopes: normalizeStringArray(grant.scopes),\n config: sanitizeConfig(grant.config),\n credentialRefs: normalizeCredentialRefs(grant.credentialRefs),\n };\n}\n\nexport function getWorkspaceConnectionAppAccess(\n connection: Pick<\n SerializedWorkspaceConnection,\n \"id\" | \"allowedApps\" | \"label\"\n >,\n appId: string,\n grants: Pick<\n SerializedWorkspaceConnectionGrant,\n \"id\" | \"connectionId\" | \"appId\"\n >[] = [],\n): WorkspaceConnectionAppAccess {\n const normalizedAppId = appId.trim();\n if (!normalizedAppId) {\n return {\n appId: normalizedAppId,\n available: false,\n mode: \"unavailable\",\n reason: \"No app id was provided.\",\n grantId: null,\n };\n }\n\n if (connection.allowedApps.length === 0) {\n return {\n appId: normalizedAppId,\n available: true,\n mode: \"all-apps\",\n reason: \"Connection is available to every app in the workspace.\",\n grantId: null,\n };\n }\n\n if (connection.allowedApps.includes(normalizedAppId)) {\n return {\n appId: normalizedAppId,\n available: true,\n mode: \"allowed-app\",\n reason: `Connection is directly allowed for ${normalizedAppId}.`,\n grantId: null,\n };\n }\n\n const explicitGrant = grants.find(\n (grant) =>\n grant.connectionId === connection.id && grant.appId === normalizedAppId,\n );\n if (explicitGrant) {\n return {\n appId: normalizedAppId,\n available: true,\n mode: \"explicit-grant\",\n reason: `Connection has an explicit grant for ${normalizedAppId}.`,\n grantId: explicitGrant.id,\n };\n }\n\n return {\n appId: normalizedAppId,\n available: false,\n mode: \"unavailable\",\n reason: `Grant ${normalizedAppId} access before this connection can be reused by the app.`,\n grantId: null,\n };\n}\n\nexport function workspaceConnectionIsAvailableToApp(\n connection: Pick<\n SerializedWorkspaceConnection,\n \"id\" | \"allowedApps\" | \"label\"\n >,\n appId: string,\n grants: Pick<\n SerializedWorkspaceConnectionGrant,\n \"id\" | \"connectionId\" | \"appId\"\n >[] = [],\n): boolean {\n return getWorkspaceConnectionAppAccess(connection, appId, grants).available;\n}\n\nfunction uniqueStrings(values: string[]): string[] {\n return Array.from(\n new Set(values.map((value) => value.trim()).filter(Boolean)),\n );\n}\n\nfunction publicCredentialRefs(\n refs: WorkspaceConnectionCredentialRef[],\n source: WorkspaceConnectionPublicCredentialRef[\"source\"],\n): WorkspaceConnectionPublicCredentialRef[] {\n return refs.map((ref) => ({\n key: ref.key,\n scope: ref.scope,\n provider: ref.provider,\n label: ref.label,\n source,\n }));\n}\n\nfunction grantsForConnection(\n connectionId: string,\n grants: SerializedWorkspaceConnectionGrant[],\n appId?: string,\n): SerializedWorkspaceConnectionGrant[] {\n return grants.filter(\n (grant) =>\n grant.connectionId === connectionId && (!appId || grant.appId === appId),\n );\n}\n\nfunction explicitGrantForConnection(\n connectionId: string,\n grants: SerializedWorkspaceConnectionGrant[],\n appId?: string,\n): SerializedWorkspaceConnectionGrant | undefined {\n return grantsForConnection(connectionId, grants, appId)[0];\n}\n\nfunction connectionForApp(\n connection: SerializedWorkspaceConnection,\n appId: string,\n grants: SerializedWorkspaceConnectionGrant[],\n): WorkspaceConnectionForApp {\n const normalizedAppId = appId.trim();\n const appAccess = getWorkspaceConnectionAppAccess(\n connection,\n normalizedAppId,\n grants,\n );\n return {\n ...connection,\n appAccess,\n explicitGrant:\n explicitGrantForConnection(connection.id, grants, normalizedAppId) ??\n null,\n };\n}\n\nfunction serializeConnectionForApp(\n connection: SerializedWorkspaceConnection,\n appId: string,\n grants: SerializedWorkspaceConnectionGrant[],\n): WorkspaceConnectionForAppSummary {\n const explicitGrant = explicitGrantForConnection(\n connection.id,\n grants,\n appId,\n );\n const appAccess = getWorkspaceConnectionAppAccess(connection, appId, grants);\n return {\n id: connection.id,\n label: connection.label,\n provider: connection.provider,\n accountId: connection.accountId,\n accountLabel: connection.accountLabel,\n status: connection.status,\n grantedToApp: appAccess.available,\n grantScope:\n connection.allowedApps.length === 0 ? \"all-apps\" : \"selected-apps\",\n appAccess,\n allowedApps: connection.allowedApps,\n credentialRefs: publicCredentialRefs(\n connection.credentialRefs,\n \"connection\",\n ),\n lastCheckedAt: connection.lastCheckedAt,\n lastError: connection.lastError,\n explicitGrant: explicitGrant\n ? {\n id: explicitGrant.id,\n appId: explicitGrant.appId,\n scopes: explicitGrant.scopes,\n credentialRefs: publicCredentialRefs(\n explicitGrant.credentialRefs,\n \"grant\",\n ),\n updatedAt: explicitGrant.updatedAt,\n }\n : null,\n };\n}\n\nfunction grantAvailabilityMessage(\n grantState: WorkspaceConnectionGrantState,\n providerId: string,\n appId: string,\n): string {\n switch (grantState) {\n case \"connected\":\n return `${appId} has an active ${providerId} workspace connection.`;\n case \"granted\":\n return `${appId} has ${providerId} access, but the granted connection is not connected yet.`;\n case \"needs_grant\":\n return `A ${providerId} workspace connection exists; grant ${appId} access to reuse it.`;\n case \"not_connected\":\n default:\n return `No shared ${providerId} workspace connection is available yet.`;\n }\n}\n\nexport function summarizeWorkspaceConnectionProviderForApp({\n providerId,\n appId,\n connections,\n grants = [],\n includeConnections = \"granted\",\n}: SummarizeWorkspaceConnectionProviderForAppOptions): WorkspaceConnectionProviderAppSummary {\n const normalizedProviderId = providerId.trim();\n const normalizedAppId = appId.trim();\n const allConnections = connections.filter(\n (connection) => connection.provider === normalizedProviderId,\n );\n const grantedConnections = allConnections.filter(\n (connection) =>\n getWorkspaceConnectionAppAccess(connection, normalizedAppId, grants)\n .available,\n );\n const connectedConnections = grantedConnections.filter(\n (connection) => connection.status === \"connected\",\n );\n const ungrantedConnectionCount =\n allConnections.length - grantedConnections.length;\n const unhealthyGrantedConnectionCount =\n grantedConnections.length - connectedConnections.length;\n const grantState: WorkspaceConnectionGrantState = connectedConnections.length\n ? \"connected\"\n : grantedConnections.length\n ? \"granted\"\n : allConnections.length\n ? \"needs_grant\"\n : \"not_connected\";\n const explicitGrantCount = allConnections.reduce(\n (count, connection) =>\n explicitGrantForConnection(connection.id, grants, normalizedAppId)\n ? count + 1\n : count,\n 0,\n );\n const credentialRefCount = allConnections.reduce((count, connection) => {\n const explicitGrant = explicitGrantForConnection(\n connection.id,\n grants,\n normalizedAppId,\n );\n return (\n count +\n connection.credentialRefs.length +\n (explicitGrant?.credentialRefs.length ?? 0)\n );\n }, 0);\n const visibleConnections =\n includeConnections === \"all\" ? allConnections : grantedConnections;\n\n return {\n appId: normalizedAppId,\n provider: normalizedProviderId,\n grantState,\n grantAvailability:\n grantState === \"connected\" || grantState === \"granted\"\n ? \"available\"\n : grantState,\n grantAvailabilityMessage: grantAvailabilityMessage(\n grantState,\n normalizedProviderId,\n normalizedAppId,\n ),\n connectionCount: allConnections.length,\n grantedConnectionCount: grantedConnections.length,\n activeConnectionCount: connectedConnections.length,\n ungrantedConnectionCount,\n unhealthyGrantedConnectionCount,\n explicitGrantCount,\n credentialRefCount,\n hasWorkspaceConnection: allConnections.length > 0,\n hasGrantedWorkspaceConnection: grantedConnections.length > 0,\n hasActiveWorkspaceConnection: connectedConnections.length > 0,\n statuses: uniqueStrings(\n allConnections.map((connection) => connection.status),\n ) as WorkspaceConnectionStatus[],\n connections: visibleConnections.map((connection) =>\n serializeConnectionForApp(connection, normalizedAppId, grants),\n ),\n };\n}\n\nfunction requiredCredentialKeys(provider: WorkspaceConnectionProviderLike) {\n return uniqueStrings(\n (provider.credentialKeys ?? [])\n .filter((credential) => credential.required ?? false)\n .map((credential) => credential.key),\n );\n}\n\nfunction missingRequiredCredentialKeys(\n provider: WorkspaceConnectionProviderLike,\n connection: SerializedWorkspaceConnection,\n grants: SerializedWorkspaceConnectionGrant[] = [],\n): string[] {\n const available = new Set(\n [\n ...connection.credentialRefs,\n ...grants.flatMap((grant) => grant.credentialRefs),\n ]\n .map((ref) => ref.key.trim())\n .filter(Boolean),\n );\n return requiredCredentialKeys(provider).filter((key) => !available.has(key));\n}\n\nexport function summarizeWorkspaceConnectionProviderReadiness({\n provider,\n connections,\n grants = [],\n appId,\n includeConnections,\n}: SummarizeWorkspaceConnectionProviderReadinessOptions): WorkspaceConnectionProviderReadiness {\n const providerConnections = connections.filter(\n (connection) => connection.provider === provider.id,\n );\n const activeConnections = providerConnections.filter(\n (connection) => connection.status !== \"disabled\",\n );\n const attentionConnections = activeConnections.filter(\n (connection) =>\n connection.status === \"error\" ||\n connection.status === \"needs_reauth\" ||\n Boolean(connection.lastError),\n );\n const missingKeys = uniqueStrings(\n activeConnections.flatMap((connection) =>\n missingRequiredCredentialKeys(\n provider,\n connection,\n grantsForConnection(connection.id, grants, appId),\n ),\n ),\n );\n const readyConnections = activeConnections.filter(\n (connection) =>\n connection.status === \"connected\" &&\n missingRequiredCredentialKeys(\n provider,\n connection,\n grantsForConnection(connection.id, grants, appId),\n ).length === 0,\n );\n const checkingConnections = activeConnections.filter(\n (connection) => connection.status === \"checking\",\n );\n\n let status: WorkspaceConnectionProviderReadinessStatus = \"not_configured\";\n if (readyConnections.length > 0) {\n status = \"ready\";\n } else if (attentionConnections.length > 0) {\n status = \"needs_attention\";\n } else if (missingKeys.length > 0) {\n status = \"needs_credentials\";\n } else if (checkingConnections.length > 0) {\n status = \"checking\";\n } else if (providerConnections.length > 0) {\n status = \"disabled\";\n }\n\n return {\n status,\n connectionCount: providerConnections.length,\n activeConnectionCount: activeConnections.length,\n readyConnectionCount: readyConnections.length,\n requiredCredentialKeys: requiredCredentialKeys(provider),\n missingRequiredCredentialKeys: missingKeys,\n appGrant: appId\n ? summarizeWorkspaceConnectionProviderForApp({\n providerId: provider.id,\n appId,\n connections,\n grants,\n includeConnections,\n })\n : null,\n };\n}\n\nexport async function listWorkspaceConnectionProviderCatalogForApp({\n appId,\n provider,\n capability,\n templateUse,\n includeDisabled = true,\n includeConnections = \"all\",\n}: ListWorkspaceConnectionProviderCatalogForAppOptions): Promise<WorkspaceConnectionProviderCatalogForApp> {\n const [connections, grants] = await Promise.all([\n listWorkspaceConnections({ provider, includeDisabled }),\n listWorkspaceConnectionGrants({ provider, appId }),\n ]);\n const providers = listWorkspaceConnectionProviders({\n capability,\n templateUse,\n })\n .filter((item) => !provider || item.id === provider)\n .map((item) => {\n const workspaceConnection = summarizeWorkspaceConnectionProviderForApp({\n providerId: item.id,\n appId,\n connections,\n grants,\n includeConnections,\n });\n const readiness = summarizeWorkspaceConnectionProviderReadiness({\n provider: item,\n connections,\n grants,\n appId,\n includeConnections,\n });\n return {\n ...item,\n workspaceConnection,\n readiness,\n };\n });\n\n return {\n appId,\n providers,\n connections,\n grants,\n counts: {\n providers: providers.length,\n connections: connections.length,\n grants: grants.length,\n readyProviders: providers.filter(\n (item) => item.readiness.status === \"ready\",\n ).length,\n },\n };\n}\n\nexport async function listWorkspaceConnectionsForApp({\n appId,\n provider,\n includeDisabled = false,\n}: ListWorkspaceConnectionsForAppOptions): Promise<\n WorkspaceConnectionForApp[]\n> {\n const normalizedAppId = normalizeRequiredString(\n appId,\n \"listWorkspaceConnectionsForApp appId\",\n );\n const [connections, grants] = await Promise.all([\n listWorkspaceConnections({ provider, includeDisabled }),\n listWorkspaceConnectionGrants({ provider, appId: normalizedAppId }),\n ]);\n\n return connections\n .map((connection) => connectionForApp(connection, normalizedAppId, grants))\n .filter((connection) => connection.appAccess.available);\n}\n\nexport async function resolveWorkspaceConnectionForApp({\n appId,\n provider,\n includeDisabled = false,\n connectionId,\n requireConnected = false,\n}: ResolveWorkspaceConnectionForAppOptions): Promise<ResolvedWorkspaceConnectionForApp> {\n const normalizedAppId = normalizeRequiredString(\n appId,\n \"resolveWorkspaceConnectionForApp appId\",\n );\n const normalizedConnectionId = connectionId?.trim();\n const requestedConnections = await listWorkspaceConnections({\n provider,\n includeDisabled: includeDisabled || Boolean(normalizedConnectionId),\n });\n const candidateConnections = normalizedConnectionId\n ? requestedConnections.filter(\n (connection) => connection.id === normalizedConnectionId,\n )\n : requestedConnections;\n const grants = await listWorkspaceConnectionGrants({\n provider,\n appId: normalizedAppId,\n connectionId: normalizedConnectionId,\n });\n\n if (normalizedConnectionId && candidateConnections.length === 0) {\n return {\n available: false,\n connection: null,\n appAccess: null,\n reason: `Workspace connection \"${normalizedConnectionId}\" was not found in the current request scope.`,\n };\n }\n\n for (const connection of candidateConnections) {\n const connectionWithAccess = connectionForApp(\n connection,\n normalizedAppId,\n grants,\n );\n\n if (!connectionWithAccess.appAccess.available) {\n if (normalizedConnectionId) {\n return {\n available: false,\n connection: connectionWithAccess,\n appAccess: connectionWithAccess.appAccess,\n reason: connectionWithAccess.appAccess.reason,\n };\n }\n continue;\n }\n\n if (!includeDisabled && connection.status === \"disabled\") {\n if (normalizedConnectionId) {\n return {\n available: false,\n connection: connectionWithAccess,\n appAccess: connectionWithAccess.appAccess,\n reason: `Workspace connection \"${connection.id}\" is disabled.`,\n };\n }\n continue;\n }\n\n if (requireConnected && connection.status !== \"connected\") {\n if (normalizedConnectionId) {\n return {\n available: false,\n connection: connectionWithAccess,\n appAccess: connectionWithAccess.appAccess,\n reason: `Workspace connection \"${connection.id}\" is ${connection.status}; a connected workspace connection is required.`,\n };\n }\n continue;\n }\n\n return {\n available: true,\n connection: connectionWithAccess,\n appAccess: connectionWithAccess.appAccess,\n reason: connectionWithAccess.appAccess.reason,\n };\n }\n\n return {\n available: false,\n connection: null,\n appAccess: null,\n reason: provider\n ? `No available ${provider} workspace connection was found for ${normalizedAppId}.`\n : `No available workspace connection was found for ${normalizedAppId}.`,\n };\n}\n\nasync function getGrantedConnectionIdsForApp(\n client: DbExec,\n scope: ReturnType<typeof requireWorkspaceConnectionScope>,\n appId: string,\n): Promise<Set<string>> {\n const table = workspaceConnectionGrantsTable();\n const where = scopedWhere(scope);\n const { rows } = await client.execute({\n sql: `SELECT connection_id FROM ${table} WHERE app_id = ? AND ${where.sql}`,\n args: [appId, ...where.args],\n });\n return new Set(\n rows\n .map((row) =>\n String((row as Record<string, unknown>).connection_id ?? \"\"),\n )\n .filter(Boolean),\n );\n}\n\nexport async function listWorkspaceConnections(\n options: ListWorkspaceConnectionsOptions = {},\n): Promise<SerializedWorkspaceConnection[]> {\n await ensureWorkspaceConnectionsTable();\n const client = getDbExec();\n const table = workspaceConnectionsTable();\n const scope = requireWorkspaceConnectionScope();\n const where = scopedWhere(scope);\n const clauses = [where.sql];\n const args: unknown[] = [...where.args];\n const appId = options.appId?.trim();\n\n if (options.provider) {\n clauses.push(\"provider = ?\");\n args.push(options.provider);\n }\n if (!options.includeDisabled) {\n clauses.push(\"status != ?\");\n args.push(\"disabled\");\n }\n\n const { rows } = await client.execute({\n sql: `SELECT * FROM ${table} WHERE ${clauses.join(\n \" AND \",\n )} ORDER BY updated_at DESC`,\n args,\n });\n\n const connections = rows.map((row) =>\n parseRow(row as Record<string, unknown>),\n );\n if (!appId) return connections;\n\n const grantedConnectionIds = await getGrantedConnectionIdsForApp(\n client,\n scope,\n appId,\n );\n return connections.filter(\n (connection) =>\n connection.allowedApps.length === 0 ||\n connection.allowedApps.includes(appId) ||\n grantedConnectionIds.has(connection.id),\n );\n}\n\nexport async function getWorkspaceConnection(\n id: string,\n): Promise<SerializedWorkspaceConnection | null> {\n await ensureWorkspaceConnectionsTable();\n const client = getDbExec();\n const table = workspaceConnectionsTable();\n const scope = requireWorkspaceConnectionScope();\n const where = scopedWhere(scope);\n const { rows } = await client.execute({\n sql: `SELECT * FROM ${table} WHERE id = ? AND ${where.sql} LIMIT 1`,\n args: [id, ...where.args],\n });\n if (rows.length === 0) return null;\n return parseRow(rows[0] as Record<string, unknown>);\n}\n\nexport async function upsertWorkspaceConnection(\n input: UpsertWorkspaceConnectionInput,\n): Promise<SerializedWorkspaceConnection> {\n await ensureWorkspaceConnectionsTable();\n const provider = input.provider.trim();\n if (!provider) {\n throw new Error(\"upsertWorkspaceConnection requires a provider.\");\n }\n\n const client = getDbExec();\n const table = workspaceConnectionsTable();\n const scope = requireWorkspaceConnectionScope();\n const where = scopedWhere(scope);\n const id = input.id?.trim() || randomUUID();\n const now = Date.now();\n const label = input.label?.trim() || input.accountLabel?.trim() || provider;\n const status = normalizeStatus(input.status);\n const scopes = normalizeStringArray(input.scopes);\n const config = sanitizeConfig(input.config);\n const allowedApps = normalizeStringArray(input.allowedApps);\n const credentialRefs = normalizeCredentialRefs(input.credentialRefs);\n const lastCheckedAt = millis(input.lastCheckedAt);\n const lastError = input.lastError ?? null;\n\n const update = await client.execute({\n sql: `UPDATE ${table}\n SET provider = ?, label = ?, account_id = ?, account_label = ?,\n status = ?, scopes_json = ?, config_json = ?, allowed_apps_json = ?,\n credential_refs_json = ?, updated_at = ?, last_checked_at = ?,\n last_error = ?\n WHERE id = ? AND ${where.sql}`,\n args: [\n provider,\n label,\n input.accountId ?? null,\n input.accountLabel ?? null,\n status,\n JSON.stringify(scopes),\n JSON.stringify(config),\n JSON.stringify(allowedApps),\n JSON.stringify(credentialRefs),\n now,\n lastCheckedAt,\n lastError,\n id,\n ...where.args,\n ],\n });\n\n if (update.rowsAffected === 0) {\n try {\n await client.execute({\n sql: `INSERT INTO ${table}\n (id, provider, label, account_id, account_label, status,\n scopes_json, config_json, allowed_apps_json, credential_refs_json,\n owner_email, org_id, created_at, updated_at, last_checked_at,\n last_error)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n args: [\n id,\n provider,\n label,\n input.accountId ?? null,\n input.accountLabel ?? null,\n status,\n JSON.stringify(scopes),\n JSON.stringify(config),\n JSON.stringify(allowedApps),\n JSON.stringify(credentialRefs),\n scope.ownerEmail,\n scope.orgId,\n now,\n now,\n lastCheckedAt,\n lastError,\n ],\n });\n } catch (err) {\n if (isUniqueViolation(err)) {\n throw new Error(\n `Workspace connection \"${id}\" already exists outside the current request scope.`,\n );\n }\n throw err;\n }\n }\n\n const connection = await getWorkspaceConnection(id);\n if (!connection) {\n throw new Error(`Workspace connection \"${id}\" was not found after upsert.`);\n }\n return connection;\n}\n\nexport async function listWorkspaceConnectionGrants(\n options: ListWorkspaceConnectionGrantsOptions = {},\n): Promise<SerializedWorkspaceConnectionGrant[]> {\n await ensureWorkspaceConnectionsTable();\n const client = getDbExec();\n const table = workspaceConnectionGrantsTable();\n const scope = requireWorkspaceConnectionScope();\n const where = scopedWhere(scope);\n const clauses = [where.sql];\n const args: unknown[] = [...where.args];\n const connectionId = options.connectionId?.trim();\n const appId = options.appId?.trim();\n const provider = options.provider?.trim();\n\n if (connectionId) {\n clauses.push(\"connection_id = ?\");\n args.push(connectionId);\n }\n if (appId) {\n clauses.push(\"app_id = ?\");\n args.push(appId);\n }\n if (provider) {\n clauses.push(\"provider = ?\");\n args.push(provider);\n }\n\n const { rows } = await client.execute({\n sql: `SELECT * FROM ${table} WHERE ${clauses.join(\n \" AND \",\n )} ORDER BY updated_at DESC`,\n args,\n });\n\n return rows.map((row) => parseGrantRow(row as Record<string, unknown>));\n}\n\nexport async function getWorkspaceConnectionGrant(\n connectionId: string,\n appId: string,\n): Promise<SerializedWorkspaceConnectionGrant | null> {\n await ensureWorkspaceConnectionsTable();\n const normalizedConnectionId = normalizeRequiredString(\n connectionId,\n \"getWorkspaceConnectionGrant connectionId\",\n );\n const normalizedAppId = normalizeRequiredString(\n appId,\n \"getWorkspaceConnectionGrant appId\",\n );\n const client = getDbExec();\n const table = workspaceConnectionGrantsTable();\n const scope = requireWorkspaceConnectionScope();\n const where = scopedWhere(scope);\n const { rows } = await client.execute({\n sql: `SELECT * FROM ${table} WHERE connection_id = ? AND app_id = ? AND ${where.sql} LIMIT 1`,\n args: [normalizedConnectionId, normalizedAppId, ...where.args],\n });\n if (rows.length === 0) return null;\n return parseGrantRow(rows[0] as Record<string, unknown>);\n}\n\nexport async function upsertWorkspaceConnectionGrant(\n input: UpsertWorkspaceConnectionGrantInput,\n): Promise<SerializedWorkspaceConnectionGrant> {\n await ensureWorkspaceConnectionsTable();\n const connectionId = normalizeRequiredString(\n input.connectionId,\n \"upsertWorkspaceConnectionGrant connectionId\",\n );\n const appId = normalizeRequiredString(\n input.appId,\n \"upsertWorkspaceConnectionGrant appId\",\n );\n\n const connection = await getWorkspaceConnection(connectionId);\n if (!connection) {\n throw new Error(\n `Workspace connection \"${connectionId}\" was not found in the current request scope.`,\n );\n }\n\n const client = getDbExec();\n const table = workspaceConnectionGrantsTable();\n const scope = requireWorkspaceConnectionScope();\n const where = scopedWhere(scope);\n const id = input.id?.trim() || randomUUID();\n const now = Date.now();\n const provider = input.provider?.trim() || connection.provider;\n const scopes = normalizeStringArray(input.scopes);\n const config = sanitizeConfig(input.config);\n const credentialRefs = normalizeCredentialRefs(input.credentialRefs);\n\n const update = await client.execute({\n sql: `UPDATE ${table}\n SET provider = ?, scopes_json = ?, config_json = ?,\n credential_refs_json = ?, granted_by_email = ?, updated_at = ?\n WHERE connection_id = ? AND app_id = ? AND ${where.sql}`,\n args: [\n provider,\n JSON.stringify(scopes),\n JSON.stringify(config),\n JSON.stringify(credentialRefs),\n scope.ownerEmail,\n now,\n connectionId,\n appId,\n ...where.args,\n ],\n });\n\n if (update.rowsAffected === 0) {\n try {\n await client.execute({\n sql: `INSERT INTO ${table}\n (id, connection_id, provider, app_id, scopes_json, config_json,\n credential_refs_json, granted_by_email, owner_email, org_id,\n created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n args: [\n id,\n connectionId,\n provider,\n appId,\n JSON.stringify(scopes),\n JSON.stringify(config),\n JSON.stringify(credentialRefs),\n scope.ownerEmail,\n scope.ownerEmail,\n scope.orgId,\n now,\n now,\n ],\n });\n } catch (err) {\n if (isUniqueViolation(err)) {\n throw new Error(\n `Workspace connection grant for \"${connectionId}\" and \"${appId}\" already exists outside the current request scope.`,\n );\n }\n throw err;\n }\n }\n\n const grant = await getWorkspaceConnectionGrant(connectionId, appId);\n if (!grant) {\n throw new Error(\n `Workspace connection grant for \"${connectionId}\" and \"${appId}\" was not found after upsert.`,\n );\n }\n return grant;\n}\n\nexport async function revokeWorkspaceConnectionGrant(\n connectionId: string,\n appId: string,\n): Promise<boolean> {\n await ensureWorkspaceConnectionsTable();\n const normalizedConnectionId = normalizeRequiredString(\n connectionId,\n \"revokeWorkspaceConnectionGrant connectionId\",\n );\n const normalizedAppId = normalizeRequiredString(\n appId,\n \"revokeWorkspaceConnectionGrant appId\",\n );\n const client = getDbExec();\n const table = workspaceConnectionGrantsTable();\n const scope = requireWorkspaceConnectionScope();\n const where = scopedWhere(scope);\n const result = await client.execute({\n sql: `DELETE FROM ${table} WHERE connection_id = ? AND app_id = ? AND ${where.sql}`,\n args: [normalizedConnectionId, normalizedAppId, ...where.args],\n });\n return result.rowsAffected > 0;\n}\n\nexport async function deleteWorkspaceConnection(id: string): Promise<boolean> {\n await ensureWorkspaceConnectionsTable();\n const client = getDbExec();\n const table = workspaceConnectionsTable();\n const grantsTable = workspaceConnectionGrantsTable();\n const scope = requireWorkspaceConnectionScope();\n const where = scopedWhere(scope);\n const result = await client.execute({\n sql: `DELETE FROM ${table} WHERE id = ? AND ${where.sql}`,\n args: [id, ...where.args],\n });\n if (result.rowsAffected > 0) {\n await client.execute({\n sql: `DELETE FROM ${grantsTable} WHERE connection_id = ? AND ${where.sql}`,\n args: [id, ...where.args],\n });\n }\n return result.rowsAffected > 0;\n}\n"]}
|
|
@@ -18,6 +18,12 @@ This keeps the main thread focused, lets sub-agents run in parallel, and gives y
|
|
|
18
18
|
|
|
19
19
|
Sub-agent state is persisted in the `application_state` SQL table (under `agent-task:<taskId>`), so tasks survive serverless cold starts and work across multiple processes.
|
|
20
20
|
|
|
21
|
+
Agent Teams runs on the same core `run-manager` harness as hosted agent chat:
|
|
22
|
+
events are streamed and persisted, aborts propagate through SQL, heartbeats mark
|
|
23
|
+
active work, and stale runs can be reaped consistently. New background-agent UIs
|
|
24
|
+
should reuse `run-manager` or `spawnTask()` instead of introducing a separate
|
|
25
|
+
runner with its own lifecycle rules.
|
|
26
|
+
|
|
21
27
|
## When to spawn a sub-agent {#when-to-spawn}
|
|
22
28
|
|
|
23
29
|
Spawn when the task:
|
|
@@ -18,6 +18,7 @@ Each one is a real app you could use today, and the launching pad for your own v
|
|
|
18
18
|
| **Mail** | An agent-native Superhuman. Inbox, labels, AI triage, keyboard-first, drafts and sends through the agent. |
|
|
19
19
|
| **Calendar** | An agent-native Google Calendar. Events, sync, public booking links, agent-driven scheduling. |
|
|
20
20
|
| **Content** | An agent-native Notion / Google Docs. Markdown + Tiptap editor, Notion sync, real-time multi-user collab. |
|
|
21
|
+
| **Brain** | A whole-company memory app: full-page company chat, cited decisions, review queue, and approved sources. |
|
|
21
22
|
| **Slides** | An agent-native Google Slides. React-based decks the agent generates and edits directly. |
|
|
22
23
|
| **Video** | An agent-native video editor on Remotion. Prompt for a cut, the agent assembles it. |
|
|
23
24
|
| **Analytics** | An agent-native Amplitude/Mixpanel. Connect data sources, prompt for charts, pin to dashboards. |
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Agent-Native Code UI"
|
|
3
|
+
description: "Build and customize Agent-Native Code surfaces with the shared UI package, Desktop host bridge, CLI run store, and hidden code template."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent-Native Code UI
|
|
7
|
+
|
|
8
|
+
Agent-Native Code is the Agent-Native coding surface: a local Claude Code/Codex-style workspace for coding sessions, slash commands, migrations, audits, transcripts, and follow-ups.
|
|
9
|
+
|
|
10
|
+
There are three layers:
|
|
11
|
+
|
|
12
|
+
- **CLI**: `npx @agent-native/core@latest code` starts and resumes runs.
|
|
13
|
+
- **Desktop**: the left-sidebar Code surface adds native terminal launch, app webviews, and desktop deep links.
|
|
14
|
+
- **Shared UI**: `@agent-native/code-agents-ui` renders the reusable React surface.
|
|
15
|
+
|
|
16
|
+
The shared UI is host-driven. It does not know whether it is running in Electron, a browser template, or a future hosted shell. Hosts provide a `CodeAgentsHost` implementation.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { CodeAgentsApp, type CodeAgentsHost } from "@agent-native/code-agents-ui";
|
|
20
|
+
import "@agent-native/code-agents-ui/styles.css";
|
|
21
|
+
|
|
22
|
+
const host: CodeAgentsHost = {
|
|
23
|
+
listRuns: (goalId) => listRunsSomehow(goalId),
|
|
24
|
+
listCodePacks: () => listCodePacksSomehow(),
|
|
25
|
+
createRun: (request) => createRunSomehow(request),
|
|
26
|
+
readTranscript: (request) => readTranscriptSomehow(request),
|
|
27
|
+
appendFollowUp: (request) => appendFollowUpSomehow(request),
|
|
28
|
+
updateRun: (request) => updateRunSomehow(request),
|
|
29
|
+
retryRun: (request) => retryRunSomehow(request),
|
|
30
|
+
rerunRun: (request) => rerunRunSomehow(request),
|
|
31
|
+
controlRun: (goalId, runId, command, permissionMode) =>
|
|
32
|
+
controlRunSomehow({ goalId, runId, command, permissionMode }),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function CodeSurface() {
|
|
36
|
+
return <CodeAgentsApp apps={[]} host={host} />;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Desktop Host
|
|
41
|
+
|
|
42
|
+
Desktop uses the shared UI but keeps privileged capabilities in Electron:
|
|
43
|
+
|
|
44
|
+
- opening a native terminal
|
|
45
|
+
- rendering optional app-backed surfaces with `AppWebview`
|
|
46
|
+
- handling `agentnative://open?...` links
|
|
47
|
+
- tracking local run processes
|
|
48
|
+
- recording steering vs queued follow-ups for active runs
|
|
49
|
+
- retrying and re-running native Code sessions, including `/migrate` and `/audit`
|
|
50
|
+
- stopping a process it started
|
|
51
|
+
|
|
52
|
+
That separation matters. The UI can be reused by templates, but native process control should stay in Desktop or CLI.
|
|
53
|
+
|
|
54
|
+
## Browser Template
|
|
55
|
+
|
|
56
|
+
The hidden `code` template is a starting point for building your own Agent-Native Code UI:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx @agent-native/core@latest create my-code-ui --template code
|
|
60
|
+
cd my-code-ui
|
|
61
|
+
pnpm install
|
|
62
|
+
pnpm dev
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Inside the framework repo, run it directly with:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cd templates/code
|
|
69
|
+
pnpm install
|
|
70
|
+
pnpm dev
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The template wraps the local run store through normal actions:
|
|
74
|
+
|
|
75
|
+
- `list-code-agent-runs`
|
|
76
|
+
- `list-code-agent-packs`
|
|
77
|
+
- `create-code-agent-run`
|
|
78
|
+
- `read-code-agent-transcript`
|
|
79
|
+
- `append-code-agent-follow-up`
|
|
80
|
+
- `update-code-agent-run`
|
|
81
|
+
- `control-code-agent-run`
|
|
82
|
+
|
|
83
|
+
It uses `@agent-native/core/code-agents`, which exposes the same file-backed run store and executor used by the CLI.
|
|
84
|
+
|
|
85
|
+
## Run Store
|
|
86
|
+
|
|
87
|
+
Local Agent-Native Code runs are stored at:
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
~/.agent-native/code-agents
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Set `AGENT_NATIVE_CODE_AGENTS_HOME` to isolate a template or test run store.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
AGENT_NATIVE_CODE_AGENTS_HOME=./data/code-agents pnpm dev
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Host Contract
|
|
100
|
+
|
|
101
|
+
`CodeAgentsHost` is intentionally small:
|
|
102
|
+
|
|
103
|
+
| Method | Purpose |
|
|
104
|
+
| ----------------------------------------------------- | ------------------------------------------------------ |
|
|
105
|
+
| `listRuns(goalId?)` | List sessions for the selected goal |
|
|
106
|
+
| `listCodePacks?()` | List `.agents/commands` and `.agents/skills` |
|
|
107
|
+
| `createRun(request)` | Start a new run |
|
|
108
|
+
| `readTranscript(request)` | Read transcript/tool/status events |
|
|
109
|
+
| `appendFollowUp(request)` | Add a follow-up, either steering active work or queued |
|
|
110
|
+
| `updateRun(request)` | Update mode or run metadata |
|
|
111
|
+
| `retryRun?(request)` | Retry the selected run in place |
|
|
112
|
+
| `rerunRun?(request)` | Start a new run from a previous prompt |
|
|
113
|
+
| `controlRun(goalId, runId, command, permissionMode?)` | Resume, approve, refresh, or stop |
|
|
114
|
+
| `openTerminal?(request)` | Optional native terminal hook |
|
|
115
|
+
|
|
116
|
+
Browser hosts should return a graceful `openTerminal` error instead of trying to emulate native terminal launch.
|
|
117
|
+
|
|
118
|
+
## Shared Composer
|
|
119
|
+
|
|
120
|
+
Agent-Native Code uses the same `AgentComposerFrame` + `PromptComposer` /
|
|
121
|
+
`TiptapComposer` stack as the framework agent sidebar. Do not fork a separate
|
|
122
|
+
textarea, shell, upload picker, voice button, model picker, or Enter-to-submit
|
|
123
|
+
implementation for Code-like surfaces. If a host needs one extra control, pass
|
|
124
|
+
it through the shared composer extension points so the sidebar, Code UI, and
|
|
125
|
+
Brain chat keep the same interaction model and visual field.
|
|
126
|
+
|
|
127
|
+
Brain's Ask route uses `AgentChatSurface`, which is already backed by the
|
|
128
|
+
standard sidebar composer. Code uses `PromptComposer` directly because the host
|
|
129
|
+
owns run creation, transcripts, and follow-up delivery.
|
|
130
|
+
|
|
131
|
+
Code-specific UI belongs around the composer, not inside a forked chatfield. The
|
|
132
|
+
shared Code UI may add slots for:
|
|
133
|
+
|
|
134
|
+
- Auto / Plan mode controls.
|
|
135
|
+
- The selected cwd, project picker, and run metadata.
|
|
136
|
+
- Host-only affordances such as opening a terminal.
|
|
137
|
+
|
|
138
|
+
Everything else stays in the shared composer: attachments, references, slash and
|
|
139
|
+
skill insertion, pasted-text handling, voice dictation, drafts, keyboard
|
|
140
|
+
shortcuts, and submission semantics.
|
|
141
|
+
|
|
142
|
+
## Slash Commands
|
|
143
|
+
|
|
144
|
+
Agent-Native Code treats migration as a capability, not a separate app category. `/migrate` can be a built-in goal, a project command, or a custom instruction pack on top of the same host contract.
|
|
145
|
+
|
|
146
|
+
Project-specific commands live in:
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
.agents/commands/*.md
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Use these for team workflows such as release checks, migration variants, framework upgrades, or audits.
|
|
153
|
+
|
|
154
|
+
Project skills live in:
|
|
155
|
+
|
|
156
|
+
```text
|
|
157
|
+
.agents/skills/*/SKILL.md
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
When the host implements `listCodePacks`, the shared UI shows project commands and skills in the rail. Command rows insert `/<command>`, and skill rows insert a focused “Use the <skill> skill…” prompt so the rail stays actionable. Built-in names such as `/migrate`, `/audit`, `/status`, and `/resume` stay reserved for the global Agent-Native Code controls.
|
|
161
|
+
|
|
162
|
+
Do not create a separate slash-command registry for a new Code host. Project
|
|
163
|
+
commands and skills are discovered from `.agents/commands/*.md` and
|
|
164
|
+
`.agents/skills/*/SKILL.md`; the UI should render those packs and insert prompts
|
|
165
|
+
through the shared composer.
|
|
166
|
+
|
|
167
|
+
## Background Agent Harness
|
|
168
|
+
|
|
169
|
+
Background coding-agent work should reuse the same harness as the rest of
|
|
170
|
+
Agent-Native:
|
|
171
|
+
|
|
172
|
+
- Use the Code run store/executor for local Code sessions.
|
|
173
|
+
- Use core `run-manager` for hosted agent runs so streams, aborts, heartbeats,
|
|
174
|
+
resumability, soft timeouts, and stuck-run cleanup behave consistently.
|
|
175
|
+
- Use `agent-teams` / `spawnTask()` when the UI is delegating work to a
|
|
176
|
+
background sub-agent from a normal app chat.
|
|
177
|
+
|
|
178
|
+
Do not add a parallel background-agent runner just because a new surface needs a
|
|
179
|
+
different layout. Build a host adapter or UI slot on top of the shared harness
|
|
180
|
+
instead.
|
|
181
|
+
|
|
182
|
+
## Follow-Ups
|
|
183
|
+
|
|
184
|
+
Follow-ups on active runs support two delivery modes:
|
|
185
|
+
|
|
186
|
+
- **Send now** records a steering prompt that the active runner applies at the next safe continuation point.
|
|
187
|
+
- **Queue** runs after the current turn finishes.
|
|
188
|
+
|
|
189
|
+
Inactive runs keep the compatible behavior: the follow-up is appended and the run resumes immediately.
|
|
190
|
+
|
|
191
|
+
## Remote Dispatch
|
|
192
|
+
|
|
193
|
+
Desktop can expose the local Code Agent runner to a deployed Dispatch relay so a
|
|
194
|
+
phone or Telegram chat can start, monitor, and continue sessions while the
|
|
195
|
+
computer is awake.
|
|
196
|
+
|
|
197
|
+
The connection is outbound-only from Desktop:
|
|
198
|
+
|
|
199
|
+
1. Desktop pairs with Dispatch and stores a device token locally.
|
|
200
|
+
2. Desktop long-polls `/_agent-native/integrations/remote/poll`.
|
|
201
|
+
3. Mobile Sessions and Telegram `/code` enqueue commands in the relay database.
|
|
202
|
+
4. Desktop claims commands, drives the local run store, and posts results and
|
|
203
|
+
transcript events back to Dispatch.
|
|
204
|
+
5. Mobile reads `hosts`, `runs`, and `transcript` from Dispatch; it never talks
|
|
205
|
+
directly to the desktop.
|
|
206
|
+
|
|
207
|
+
The canonical remote relay endpoints are:
|
|
208
|
+
|
|
209
|
+
| Method | Route | Caller | Purpose |
|
|
210
|
+
| ---------- | -------------------------------------------------------- | --------------- | ------------------------------------------- |
|
|
211
|
+
| `POST` | `/_agent-native/integrations/remote/register` | Desktop session | Pair a desktop host and return a token once |
|
|
212
|
+
| `GET` | `/_agent-native/integrations/remote/hosts` | Mobile/session | List paired hosts |
|
|
213
|
+
| `DELETE` | `/_agent-native/integrations/remote/devices/:id` | Mobile/session | Revoke a paired host |
|
|
214
|
+
| `POST` | `/_agent-native/integrations/remote/devices/:id/revoke` | Mobile/session | Revoke a paired host |
|
|
215
|
+
| `POST/GET` | `/_agent-native/integrations/remote/poll` | Desktop token | Claim work |
|
|
216
|
+
| `POST` | `/_agent-native/integrations/remote/result` | Desktop token | Complete or fail work |
|
|
217
|
+
| `POST` | `/_agent-native/integrations/remote/run-events` | Desktop token | Mirror transcript events |
|
|
218
|
+
| `GET` | `/_agent-native/integrations/remote/runs` | Mobile/session | List sessions |
|
|
219
|
+
| `GET` | `/_agent-native/integrations/remote/runs/:id` | Mobile/session | Read session summary |
|
|
220
|
+
| `GET` | `/_agent-native/integrations/remote/runs/:id/transcript` | Mobile/session | Read mirrored transcript |
|
|
221
|
+
| `POST` | `/_agent-native/integrations/remote/push/register` | Mobile/session | Register Expo/mobile push token |
|
|
222
|
+
|
|
223
|
+
Telegram uses the same relay through Dispatch. Supported commands are:
|
|
224
|
+
|
|
225
|
+
```text
|
|
226
|
+
/code <prompt>
|
|
227
|
+
/code list
|
|
228
|
+
/code status <run>
|
|
229
|
+
/code continue <run> <text>
|
|
230
|
+
/code approve <id>
|
|
231
|
+
/code deny <id>
|
|
232
|
+
/code stop <run>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Smoke checklist
|
|
236
|
+
|
|
237
|
+
Before shipping a remote-control change, run the automated relay route smoke in
|
|
238
|
+
`remote-plugin.spec.ts`, then do one real-device pass:
|
|
239
|
+
|
|
240
|
+
1. Pair Desktop from Settings and confirm the host appears in mobile Sessions.
|
|
241
|
+
2. Start a session from mobile and confirm Desktop claims it.
|
|
242
|
+
3. Send `/code <prompt>` from Telegram and confirm it queues to the same host.
|
|
243
|
+
4. Verify transcript mirroring, follow-up, approve or deny, and stop.
|
|
244
|
+
5. Revoke the host from mobile and confirm new commands stay queued/offline
|
|
245
|
+
instead of being sent to the revoked device.
|
|
246
|
+
6. Enable mobile push alerts and confirm command completion creates a push
|
|
247
|
+
outbox row.
|
|
248
|
+
|
|
249
|
+
## Styling
|
|
250
|
+
|
|
251
|
+
Import the package stylesheet:
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
import "@agent-native/code-agents-ui/styles.css";
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The stylesheet uses the same shadcn-style HSL custom properties as the templates and Desktop shell. Prefer changing tokens or small class overrides in the host app before forking the shared UI.
|
|
258
|
+
|
|
259
|
+
## Limits
|
|
260
|
+
|
|
261
|
+
The browser template is local-first. It can start and resume runs while its local Node server is alive. For native process lifecycle, terminal launch, and app webviews, use Desktop.
|
package/docs/content/dispatch.md
CHANGED
|
@@ -47,11 +47,48 @@ The behavioral rule lives in the dispatch agent's instructions: domain work belo
|
|
|
47
47
|
|
|
48
48
|
### Workspace resources
|
|
49
49
|
|
|
50
|
-
Skills, agent profiles, and
|
|
50
|
+
Skills, guardrail instructions, agent profiles, and reference resources can be authored once in Dispatch and inherited by the rest of the workspace. Resources with **All apps** scope are global: Dispatch stores them once at workspace scope, and every app agent reads them at runtime. They are not copied into each app, and there is no manual workspace-resource sync step. App shared resources and personal resources can override or narrow the workspace defaults locally. Selected resources use explicit per-app grants for app-specific exceptions.
|
|
51
|
+
|
|
52
|
+
Use the canonical paths to control how agents consume them:
|
|
53
|
+
|
|
54
|
+
- `AGENTS.md` or `instructions/<slug>.md` for always-on guardrails loaded by every app agent
|
|
55
|
+
- `skills/<slug>/SKILL.md` for on-demand skills available through `/` commands and the prompt skill index
|
|
56
|
+
- `context/<slug>.md` for brand, persona, positioning, messaging, company facts, and other reference material the agent reads when relevant
|
|
57
|
+
- `agents/<slug>.md` for reusable custom agent profiles
|
|
58
|
+
|
|
59
|
+
Starter global resources usually look like:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
context/company.md
|
|
63
|
+
context/brand.md
|
|
64
|
+
context/messaging.md
|
|
65
|
+
instructions/guardrails.md
|
|
66
|
+
skills/company-voice/SKILL.md
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Set these to **All apps** when every app should inherit the same company facts, brand rules, messaging, safety constraints, and customer-facing writing style. Use selected-app grants only for resources that are genuinely app-specific.
|
|
70
|
+
|
|
71
|
+
The **Resources** page highlights this starter pack in a Global context section so admins can quickly see which files exist, whether they are scoped to all apps, restore missing starter files without overwriting existing ones, and edit their contents. Expand any resource to preview its effective runtime stack for a selected app/user: workspace default, organization/app override, then personal override. Each app card also has a **Context** view that shows exactly what that app receives: inherited workspace resources, selected grants, and auto-loaded instructions. Use a resource row's **Stack** control to inspect which layer wins for that app.
|
|
72
|
+
|
|
73
|
+
This is how a team-wide change ("always use British English in customer-facing replies") or a shared brand guideline propagates without editing ten repos.
|
|
74
|
+
|
|
75
|
+
### Dreams
|
|
76
|
+
|
|
77
|
+
Dispatch Dreams review prior agent runs, feedback, evals, and repeated failures to propose durable improvements. A dream report is a review surface, not a silent rewrite: it can suggest personal memory updates, stale-memory cleanup, shared `LEARNINGS.md` edits, workspace instruction/skill/knowledge/agent resources, or recurring jobs, and each proposal links back to the runs that justify it. Shared instructions and team-wide resources require review before they are applied, especially when the evidence came from inbound Slack, email, Telegram, WhatsApp, or web content.
|
|
78
|
+
|
|
79
|
+
Before proposing a write, Dreams compare the evidence against the personal memory index, existing `memory/*.md` notes, and shared `LEARNINGS.md`. If a lesson is already captured, the report records that it was skipped; if a related personal memory looks stale, the proposal targets that existing note instead of creating a duplicate. Dream reports deduplicate repeated evidence by thread, signal type, and normalized quote, strip injected context from correction detection, and summarize raw eval/tool rows into readable bullets. If a pass finds signals but creates no proposals, guardrail notes explain which evidence was suppressed.
|
|
80
|
+
|
|
81
|
+
Use Dreams as the workspace's offline reflection loop: "what did agents keep getting wrong this week?", "what should we remember?", and "which repeated workflow should become a skill or scheduled job?"
|
|
82
|
+
|
|
83
|
+
Start from the **Dreams** tab in Dispatch. Run a manual pass first, open a proposal review sheet to compare the current target with the proposed content and source evidence, then apply only the changes you want to keep. Once the reports are consistently useful, Dispatch can create a recurring dream job that keeps producing proposals without auto-applying shared or instruction-level changes. Workspace-instruction proposals require durable evidence from at least two threads or two source apps, while eval-only noise, account setup issues, quota limits, and single-app UI wording corrections remain out of all-app instructions.
|
|
84
|
+
|
|
85
|
+
When a workspace has several thread-debug sources, Dreams can scan them together with `sourceId: "all"` or an explicit `sourceIds` list. Each source gets its own timeout, start stagger, concurrency cap, per-thread timeout, and persisted health row, so a slow or unavailable production database produces a partial result instead of blocking the whole dream pass.
|
|
86
|
+
|
|
87
|
+
Recurring dream settings are stored at user or org scope and can be edited from the Dreams settings sheet. They control the cron schedule, source selection, per-source timeout, source concurrency, source start stagger, per-thread timeout, candidate limit, and minimum candidate threshold. The default recurring shape is a weekly all-source review that writes proposals only; applying shared or workspace-resource proposals still goes through review and approval.
|
|
51
88
|
|
|
52
89
|
### Approval flow
|
|
53
90
|
|
|
54
|
-
Dispatch can gate sensitive runtime changes behind admin review. Today this covers **saved destinations** (the Slack channels and email addresses the agent can proactively send to) and **dispatch approval policy** itself. When the policy is enabled, the change is queued and the agent surfaces an inline approval preview directly in chat — admins approve or reject without leaving the conversation.
|
|
91
|
+
Dispatch can gate sensitive runtime changes behind admin review. Today this covers **saved destinations** (the Slack channels and email addresses the agent can proactively send to), shared/team **dream proposals**, All-app **workspace resource** creates/updates/deletes, and **dispatch approval policy** itself. When the policy is enabled, the change is queued and the agent surfaces an inline approval preview directly in chat — admins approve or reject without leaving the conversation.
|
|
55
92
|
|
|
56
93
|
## How a Slack message flows through Dispatch {#flow}
|
|
57
94
|
|
|
@@ -83,7 +120,7 @@ Three short steps:
|
|
|
83
120
|
2. **Connect messaging.** Open **Settings → Messaging** in Dispatch and click connect for Slack, Email, Telegram, or WhatsApp. The form fields match the env vars in the [Messaging](/docs/messaging) doc — refer there for what each platform needs.
|
|
84
121
|
3. **Add other apps.** Run `npx @agent-native/core add-app` from the workspace root for each domain app. They auto-appear as A2A peers in Dispatch's `list-workspace-apps` — no manual registration, no agent-card editing. Dispatch will start delegating to them as soon as their agent cards are reachable.
|
|
85
122
|
|
|
86
|
-
Then add credentials to the vault
|
|
123
|
+
Then add credentials to the vault and (optionally) author global workspace resources under **Resources**. Vault keys can still be synced or granted depending on access mode; All-app workspace resources are inherited automatically. If you need per-app secret isolation, switch the vault access setting to manual before granting individual apps.
|
|
87
124
|
|
|
88
125
|
## See also {#see-also}
|
|
89
126
|
|