@agent-native/dispatch 0.6.1 → 0.8.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 +38 -1
- package/dist/actions/apply-dream-proposal.d.ts +3 -0
- package/dist/actions/apply-dream-proposal.d.ts.map +1 -0
- package/dist/actions/apply-dream-proposal.js +11 -0
- package/dist/actions/apply-dream-proposal.js.map +1 -0
- package/dist/actions/create-dream-report.d.ts +3 -0
- package/dist/actions/create-dream-report.d.ts.map +1 -0
- package/dist/actions/create-dream-report.js +67 -0
- package/dist/actions/create-dream-report.js.map +1 -0
- package/dist/actions/create-pylon-ticket.d.ts +3 -0
- package/dist/actions/create-pylon-ticket.d.ts.map +1 -0
- package/dist/actions/create-pylon-ticket.js +94 -0
- package/dist/actions/create-pylon-ticket.js.map +1 -0
- package/dist/actions/create-vault-grant.js +1 -1
- package/dist/actions/create-vault-grant.js.map +1 -1
- package/dist/actions/create-vault-secret.d.ts.map +1 -1
- package/dist/actions/create-vault-secret.js +4 -3
- package/dist/actions/create-vault-secret.js.map +1 -1
- package/dist/actions/create-workspace-resource.js +3 -3
- package/dist/actions/create-workspace-resource.js.map +1 -1
- package/dist/actions/delete-workspace-resource.js +1 -1
- package/dist/actions/delete-workspace-resource.js.map +1 -1
- package/dist/actions/ensure-dream-job.d.ts +3 -0
- package/dist/actions/ensure-dream-job.d.ts.map +1 -0
- package/dist/actions/ensure-dream-job.js +73 -0
- package/dist/actions/ensure-dream-job.js.map +1 -0
- package/dist/actions/get-dream-settings.d.ts +3 -0
- package/dist/actions/get-dream-settings.d.ts.map +1 -0
- package/dist/actions/get-dream-settings.js +11 -0
- package/dist/actions/get-dream-settings.js.map +1 -0
- package/dist/actions/get-dream.d.ts +3 -0
- package/dist/actions/get-dream.d.ts.map +1 -0
- package/dist/actions/get-dream.js +13 -0
- package/dist/actions/get-dream.js.map +1 -0
- package/dist/actions/get-vault-access-settings.d.ts +3 -0
- package/dist/actions/get-vault-access-settings.d.ts.map +1 -0
- package/dist/actions/get-vault-access-settings.js +10 -0
- package/dist/actions/get-vault-access-settings.js.map +1 -0
- package/dist/actions/get-workspace-resource-effective-context.d.ts +3 -0
- package/dist/actions/get-workspace-resource-effective-context.d.ts.map +1 -0
- package/dist/actions/get-workspace-resource-effective-context.js +27 -0
- package/dist/actions/get-workspace-resource-effective-context.js.map +1 -0
- package/dist/actions/grant-vault-secrets-to-app.js +1 -1
- package/dist/actions/grant-vault-secrets-to-app.js.map +1 -1
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +38 -4
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/list-dream-candidates.d.ts +3 -0
- package/dist/actions/list-dream-candidates.d.ts.map +1 -0
- package/dist/actions/list-dream-candidates.js +68 -0
- package/dist/actions/list-dream-candidates.js.map +1 -0
- package/dist/actions/list-dreams.d.ts +3 -0
- package/dist/actions/list-dreams.d.ts.map +1 -0
- package/dist/actions/list-dreams.js +17 -0
- package/dist/actions/list-dreams.js.map +1 -0
- package/dist/actions/list-integrations-catalog.js +1 -1
- package/dist/actions/list-integrations-catalog.js.map +1 -1
- package/dist/actions/list-vault-grants.js +1 -1
- package/dist/actions/list-vault-grants.js.map +1 -1
- package/dist/actions/list-workspace-apps.d.ts.map +1 -1
- package/dist/actions/list-workspace-apps.js +5 -1
- package/dist/actions/list-workspace-apps.js.map +1 -1
- package/dist/actions/list-workspace-resources-for-app.d.ts +3 -0
- package/dist/actions/list-workspace-resources-for-app.d.ts.map +1 -0
- package/dist/actions/list-workspace-resources-for-app.js +12 -0
- package/dist/actions/list-workspace-resources-for-app.js.map +1 -0
- package/dist/actions/list-workspace-resources.js +1 -1
- package/dist/actions/list-workspace-resources.js.map +1 -1
- package/dist/actions/navigate.d.ts +1 -0
- package/dist/actions/navigate.d.ts.map +1 -1
- package/dist/actions/navigate.js +2 -1
- package/dist/actions/navigate.js.map +1 -1
- package/dist/actions/preview-dream-proposal.d.ts +3 -0
- package/dist/actions/preview-dream-proposal.d.ts.map +1 -0
- package/dist/actions/preview-dream-proposal.js +13 -0
- package/dist/actions/preview-dream-proposal.js.map +1 -0
- package/dist/actions/preview-workspace-resource-change.d.ts +3 -0
- package/dist/actions/preview-workspace-resource-change.d.ts.map +1 -0
- package/dist/actions/preview-workspace-resource-change.js +24 -0
- package/dist/actions/preview-workspace-resource-change.js.map +1 -0
- package/dist/actions/reject-dream-proposal.d.ts +3 -0
- package/dist/actions/reject-dream-proposal.d.ts.map +1 -0
- package/dist/actions/reject-dream-proposal.js +12 -0
- package/dist/actions/reject-dream-proposal.js.map +1 -0
- package/dist/actions/restore-starter-workspace-resources.d.ts +3 -0
- package/dist/actions/restore-starter-workspace-resources.d.ts.map +1 -0
- package/dist/actions/restore-starter-workspace-resources.js +14 -0
- package/dist/actions/restore-starter-workspace-resources.js.map +1 -0
- package/dist/actions/send-code-agent-remote-command.d.ts +3 -0
- package/dist/actions/send-code-agent-remote-command.d.ts.map +1 -0
- package/dist/actions/send-code-agent-remote-command.js +53 -0
- package/dist/actions/send-code-agent-remote-command.js.map +1 -0
- package/dist/actions/set-dream-settings.d.ts +3 -0
- package/dist/actions/set-dream-settings.d.ts.map +1 -0
- package/dist/actions/set-dream-settings.js +41 -0
- package/dist/actions/set-dream-settings.js.map +1 -0
- package/dist/actions/set-vault-access-settings.d.ts +3 -0
- package/dist/actions/set-vault-access-settings.d.ts.map +1 -0
- package/dist/actions/set-vault-access-settings.js +13 -0
- package/dist/actions/set-vault-access-settings.js.map +1 -0
- package/dist/actions/start-workspace-app-creation.d.ts.map +1 -1
- package/dist/actions/start-workspace-app-creation.js +6 -0
- package/dist/actions/start-workspace-app-creation.js.map +1 -1
- package/dist/actions/sync-vault-to-app.js +1 -1
- package/dist/actions/sync-vault-to-app.js.map +1 -1
- package/dist/actions/update-workspace-app-metadata.d.ts +3 -0
- package/dist/actions/update-workspace-app-metadata.d.ts.map +1 -0
- package/dist/actions/update-workspace-app-metadata.js +30 -0
- package/dist/actions/update-workspace-app-metadata.js.map +1 -0
- package/dist/actions/update-workspace-resource.js +1 -1
- package/dist/actions/update-workspace-resource.js.map +1 -1
- package/dist/actions/view-screen.d.ts.map +1 -1
- package/dist/actions/view-screen.js +77 -4
- package/dist/actions/view-screen.js.map +1 -1
- package/dist/components/app-keys-popover.js +16 -5
- package/dist/components/app-keys-popover.js.map +1 -1
- package/dist/components/approval-value-block.d.ts +7 -0
- package/dist/components/approval-value-block.d.ts.map +1 -0
- package/dist/components/approval-value-block.js +22 -0
- package/dist/components/approval-value-block.js.map +1 -0
- package/dist/components/create-app-popover.d.ts.map +1 -1
- package/dist/components/create-app-popover.js +41 -16
- package/dist/components/create-app-popover.js.map +1 -1
- package/dist/components/dispatch-shell.d.ts +4 -4
- package/dist/components/dispatch-shell.d.ts.map +1 -1
- package/dist/components/dispatch-shell.js +6 -6
- package/dist/components/dispatch-shell.js.map +1 -1
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +18 -4
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/components/messaging-setup-panel.d.ts.map +1 -1
- package/dist/components/messaging-setup-panel.js +2 -2
- package/dist/components/messaging-setup-panel.js.map +1 -1
- package/dist/components/ui/chart.d.ts +1 -1
- package/dist/components/workspace-app-card.d.ts.map +1 -1
- package/dist/components/workspace-app-card.js +63 -3
- package/dist/components/workspace-app-card.js.map +1 -1
- package/dist/components/workspace-resource-effective-stack.d.ts +11 -0
- package/dist/components/workspace-resource-effective-stack.d.ts.map +1 -0
- package/dist/components/workspace-resource-effective-stack.js +59 -0
- package/dist/components/workspace-resource-effective-stack.js.map +1 -0
- package/dist/components/workspace-resource-impact-preview.d.ts +9 -0
- package/dist/components/workspace-resource-impact-preview.d.ts.map +1 -0
- package/dist/components/workspace-resource-impact-preview.js +39 -0
- package/dist/components/workspace-resource-impact-preview.js.map +1 -0
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +59 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/schema.d.ts +714 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +44 -2
- package/dist/db/schema.js.map +1 -1
- package/dist/hooks/use-navigation-state.d.ts +3 -0
- package/dist/hooks/use-navigation-state.d.ts.map +1 -1
- package/dist/hooks/use-navigation-state.js +35 -8
- package/dist/hooks/use-navigation-state.js.map +1 -1
- package/dist/lib/catch-all-target.d.ts +2 -0
- package/dist/lib/catch-all-target.d.ts.map +1 -0
- package/dist/lib/catch-all-target.js +95 -0
- package/dist/lib/catch-all-target.js.map +1 -0
- package/dist/lib/utils.d.ts +2 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +5 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/workspace-apps.d.ts +9 -0
- package/dist/lib/workspace-apps.d.ts.map +1 -1
- package/dist/lib/workspace-apps.js.map +1 -1
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/pages/$appId.d.ts +2 -2
- package/dist/routes/pages/$appId.d.ts.map +1 -1
- package/dist/routes/pages/$appId.js +17 -8
- package/dist/routes/pages/$appId.js.map +1 -1
- package/dist/routes/pages/approval.d.ts.map +1 -1
- package/dist/routes/pages/approval.js +4 -1
- package/dist/routes/pages/approval.js.map +1 -1
- package/dist/routes/pages/approvals.js +1 -1
- package/dist/routes/pages/approvals.js.map +1 -1
- package/dist/routes/pages/dream-settings.d.ts +34 -0
- package/dist/routes/pages/dream-settings.d.ts.map +1 -0
- package/dist/routes/pages/dream-settings.js +68 -0
- package/dist/routes/pages/dream-settings.js.map +1 -0
- package/dist/routes/pages/dreams.d.ts +5 -0
- package/dist/routes/pages/dreams.d.ts.map +1 -0
- package/dist/routes/pages/dreams.js +435 -0
- package/dist/routes/pages/dreams.js.map +1 -0
- package/dist/routes/pages/integrations.d.ts.map +1 -1
- package/dist/routes/pages/integrations.js +20 -15
- package/dist/routes/pages/integrations.js.map +1 -1
- package/dist/routes/pages/new-app.js +1 -1
- package/dist/routes/pages/new-app.js.map +1 -1
- package/dist/routes/pages/overview.d.ts.map +1 -1
- package/dist/routes/pages/overview.js +5 -1
- package/dist/routes/pages/overview.js.map +1 -1
- package/dist/routes/pages/vault.d.ts.map +1 -1
- package/dist/routes/pages/vault.js +23 -5
- package/dist/routes/pages/vault.js.map +1 -1
- package/dist/routes/pages/workspace.d.ts.map +1 -1
- package/dist/routes/pages/workspace.js +187 -35
- package/dist/routes/pages/workspace.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts +13 -0
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +298 -11
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/dispatch-integrations.d.ts +1 -1
- package/dist/server/lib/dispatch-integrations.d.ts.map +1 -1
- package/dist/server/lib/dispatch-integrations.js +9 -4
- package/dist/server/lib/dispatch-integrations.js.map +1 -1
- package/dist/server/lib/dispatch-remote-commands.d.ts +83 -0
- package/dist/server/lib/dispatch-remote-commands.d.ts.map +1 -0
- package/dist/server/lib/dispatch-remote-commands.js +256 -0
- package/dist/server/lib/dispatch-remote-commands.js.map +1 -0
- package/dist/server/lib/dispatch-store.d.ts +26 -0
- package/dist/server/lib/dispatch-store.d.ts.map +1 -1
- package/dist/server/lib/dispatch-store.js +17 -1
- package/dist/server/lib/dispatch-store.js.map +1 -1
- package/dist/server/lib/dreams-store.d.ts +398 -0
- package/dist/server/lib/dreams-store.d.ts.map +1 -0
- package/dist/server/lib/dreams-store.js +2330 -0
- package/dist/server/lib/dreams-store.js.map +1 -0
- package/dist/server/lib/env-config.d.ts.map +1 -1
- package/dist/server/lib/env-config.js +5 -0
- package/dist/server/lib/env-config.js.map +1 -1
- package/dist/server/lib/onboarding-steps.d.ts +12 -0
- package/dist/server/lib/onboarding-steps.d.ts.map +1 -0
- package/dist/server/lib/onboarding-steps.js +47 -0
- package/dist/server/lib/onboarding-steps.js.map +1 -0
- package/dist/server/lib/thread-debug-store.d.ts +2 -2
- package/dist/server/lib/vault-store.d.ts +55 -0
- package/dist/server/lib/vault-store.d.ts.map +1 -1
- package/dist/server/lib/vault-store.js +210 -41
- package/dist/server/lib/vault-store.js.map +1 -1
- package/dist/server/lib/workspace-resources-store.d.ts +181 -17
- package/dist/server/lib/workspace-resources-store.d.ts.map +1 -1
- package/dist/server/lib/workspace-resources-store.js +737 -108
- package/dist/server/lib/workspace-resources-store.js.map +1 -1
- package/dist/server/plugins/agent-chat.d.ts.map +1 -1
- package/dist/server/plugins/agent-chat.js +2 -1
- package/dist/server/plugins/agent-chat.js.map +1 -1
- package/dist/server/plugins/core-routes.d.ts.map +1 -1
- package/dist/server/plugins/core-routes.js +4 -0
- package/dist/server/plugins/core-routes.js.map +1 -1
- package/dist/server/plugins/integrations.js +2 -2
- package/dist/server/plugins/integrations.js.map +1 -1
- package/package.json +15 -11
- package/src/actions/apply-dream-proposal.ts +12 -0
- package/src/actions/create-dream-report.ts +76 -0
- package/src/actions/create-pylon-ticket.ts +109 -0
- package/src/actions/create-vault-grant.ts +1 -1
- package/src/actions/create-vault-secret.ts +4 -3
- package/src/actions/create-workspace-resource.ts +3 -3
- package/src/actions/delete-workspace-resource.ts +1 -1
- package/src/actions/ensure-dream-job.ts +76 -0
- package/src/actions/get-dream-settings.ts +12 -0
- package/src/actions/get-dream.ts +14 -0
- package/src/actions/get-vault-access-settings.ts +11 -0
- package/src/actions/get-workspace-resource-effective-context.ts +34 -0
- package/src/actions/grant-vault-secrets-to-app.ts +1 -1
- package/src/actions/index.spec.ts +26 -0
- package/src/actions/index.ts +39 -4
- package/src/actions/list-dream-candidates.ts +77 -0
- package/src/actions/list-dreams.ts +17 -0
- package/src/actions/list-integrations-catalog.ts +1 -1
- package/src/actions/list-vault-grants.ts +1 -1
- package/src/actions/list-workspace-apps.ts +5 -1
- package/src/actions/list-workspace-resources-for-app.ts +13 -0
- package/src/actions/list-workspace-resources.ts +1 -1
- package/src/actions/navigate.ts +2 -1
- package/src/actions/preview-dream-proposal.ts +14 -0
- package/src/actions/preview-workspace-resource-change.ts +25 -0
- package/src/actions/reject-dream-proposal.ts +12 -0
- package/src/actions/restore-starter-workspace-resources.ts +17 -0
- package/src/actions/send-code-agent-remote-command.ts +59 -0
- package/src/actions/set-dream-settings.spec.ts +81 -0
- package/src/actions/set-dream-settings.ts +44 -0
- package/src/actions/set-vault-access-settings.ts +16 -0
- package/src/actions/start-workspace-app-creation.ts +8 -0
- package/src/actions/sync-vault-to-app.ts +1 -1
- package/src/actions/update-workspace-app-metadata.ts +32 -0
- package/src/actions/update-workspace-resource.ts +1 -1
- package/src/actions/view-screen.ts +94 -3
- package/src/components/app-keys-popover.tsx +23 -7
- package/src/components/approval-value-block.spec.tsx +59 -0
- package/src/components/approval-value-block.tsx +33 -0
- package/src/components/create-app-popover.tsx +50 -16
- package/src/components/dispatch-shell.tsx +16 -15
- package/src/components/layout/Layout.tsx +19 -5
- package/src/components/messaging-setup-panel.tsx +54 -39
- package/src/components/workspace-app-card.tsx +268 -1
- package/src/components/workspace-resource-effective-stack.spec.tsx +125 -0
- package/src/components/workspace-resource-effective-stack.tsx +141 -0
- package/src/components/workspace-resource-impact-preview.spec.tsx +147 -0
- package/src/components/workspace-resource-impact-preview.tsx +116 -0
- package/src/db/migrations.ts +59 -0
- package/src/db/schema.ts +46 -2
- package/src/hooks/use-navigation-state.ts +34 -9
- package/src/lib/catch-all-target.spec.ts +218 -0
- package/src/lib/catch-all-target.ts +99 -0
- package/src/lib/utils.ts +6 -1
- package/src/lib/workspace-apps.ts +9 -0
- package/src/routes/index.ts +1 -0
- package/src/routes/pages/$appId.tsx +21 -8
- package/src/routes/pages/approval.tsx +14 -1
- package/src/routes/pages/approvals.tsx +1 -1
- package/src/routes/pages/dream-settings.spec.ts +130 -0
- package/src/routes/pages/dream-settings.ts +103 -0
- package/src/routes/pages/dreams.tsx +1828 -0
- package/src/routes/pages/integrations.tsx +57 -18
- package/src/routes/pages/new-app.tsx +1 -1
- package/src/routes/pages/overview.tsx +11 -3
- package/src/routes/pages/vault.tsx +76 -9
- package/src/routes/pages/workspace.tsx +577 -97
- package/src/server/lib/app-creation-store.spec.ts +61 -2
- package/src/server/lib/app-creation-store.ts +389 -13
- package/src/server/lib/dispatch-integrations.ts +10 -3
- package/src/server/lib/dispatch-remote-commands.spec.ts +167 -0
- package/src/server/lib/dispatch-remote-commands.ts +375 -0
- package/src/server/lib/dispatch-store.ts +37 -1
- package/src/server/lib/dreams-store.spec.ts +1492 -0
- package/src/server/lib/dreams-store.ts +3168 -0
- package/src/server/lib/env-config.ts +5 -0
- package/src/server/lib/onboarding-steps.ts +49 -0
- package/src/server/lib/vault-store.spec.ts +69 -0
- package/src/server/lib/vault-store.ts +266 -49
- package/src/server/lib/workspace-resource-approval-lifecycle.spec.ts +236 -0
- package/src/server/lib/workspace-resources-store.spec.ts +1106 -0
- package/src/server/lib/workspace-resources-store.ts +1001 -134
- package/src/server/plugins/agent-chat.ts +2 -1
- package/src/server/plugins/core-routes.ts +5 -0
- package/src/server/plugins/integrations.ts +2 -2
- package/dist/actions/sync-workspace-resources-to-all.d.ts +0 -3
- package/dist/actions/sync-workspace-resources-to-all.d.ts.map +0 -1
- package/dist/actions/sync-workspace-resources-to-all.js +0 -9
- package/dist/actions/sync-workspace-resources-to-all.js.map +0 -1
- package/dist/actions/sync-workspace-resources-to-app.d.ts +0 -3
- package/dist/actions/sync-workspace-resources-to-app.d.ts.map +0 -1
- package/dist/actions/sync-workspace-resources-to-app.js +0 -11
- package/dist/actions/sync-workspace-resources-to-app.js.map +0 -1
- package/src/actions/sync-workspace-resources-to-all.ts +0 -10
- package/src/actions/sync-workspace-resources-to-app.ts +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-resources-store.js","sourceRoot":"","sources":["../../../src/server/lib/workspace-resources-store.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAC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,CAAC,CAAC;IAClE,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;IAEjE,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,MAAM;QACzB,gBAAgB,EAAE,YAAY,CAAC,MAAM;QACrC,UAAU,EAAE,MAAM,CAAC,MAAM;QACzB,cAAc,EAAE,SAAS,CAAC,MAAM;QAChC,cAAc,EAAE,SAAS,CAAC,MAAM;QAChC,gBAAgB,EAAE,YAAY,CAAC,MAAM;KACtC,CAAC;AACJ,CAAC","sourcesContent":["import crypto from \"node:crypto\";\nimport { and, desc, eq, isNull, or } from \"drizzle-orm\";\nimport { discoverAgents } from \"@agent-native/core/server/agent-discovery\";\nimport { getDb, schema } from \"../../db/index.js\";\nimport {\n currentOwnerEmail,\n currentOrgId,\n recordAudit,\n} from \"./dispatch-store.js\";\nimport { recordVaultAudit } from \"./vault-store.js\";\n\n/**\n * Caller-supplied access context for workspace-resource operations.\n * Same shape and semantics as VaultCtx — looking up a row by id alone is\n * unsafe because UUIDs are not authorization. A row matches the ctx if\n * either the caller owns it or it lives in the caller's active org.\n */\nexport interface WorkspaceResourceCtx {\n ownerEmail: string;\n orgId: string | null;\n}\n\nexport function requireWorkspaceResourceCtx(): WorkspaceResourceCtx {\n const ownerEmail = currentOwnerEmail();\n return { ownerEmail, orgId: currentOrgId() };\n}\n\n/** WHERE clause that limits a workspace-resource row to the caller's scope. */\nfunction ctxScope<T extends { ownerEmail: any; orgId: any }>(\n table: T,\n ctx: WorkspaceResourceCtx,\n) {\n if (!ctx.orgId) {\n return and(eq(table.ownerEmail, ctx.ownerEmail), isNull(table.orgId));\n }\n return or(eq(table.ownerEmail, ctx.ownerEmail), eq(table.orgId, ctx.orgId));\n}\n\nfunction id() {\n return crypto.randomUUID();\n}\n\nfunction now() {\n return Date.now();\n}\n\nfunction orgFilter<T extends { ownerEmail: any; orgId: any }>(table: T) {\n const orgId = currentOrgId();\n return and(\n eq(table.ownerEmail, currentOwnerEmail()),\n orgId ? eq(table.orgId, orgId) : isNull(table.orgId),\n );\n}\n\n// ─── Workspace Resources CRUD ──────────────────────────────────\n\nexport type WorkspaceResourceKind =\n | \"skill\"\n | \"instruction\"\n | \"agent\"\n | \"knowledge\";\nexport type WorkspaceResourceScope = \"all\" | \"selected\";\n\nexport interface WorkspaceResourceInput {\n kind: WorkspaceResourceKind;\n name: string;\n description?: string | null;\n path: string;\n content: string;\n scope: WorkspaceResourceScope;\n}\n\nexport interface WorkspaceResourceOption {\n id: string;\n kind: WorkspaceResourceKind;\n name: string;\n description: string | null;\n path: string;\n scope: WorkspaceResourceScope;\n updatedAt: number;\n}\n\nexport async function listWorkspaceResources(filter?: { kind?: string }) {\n const db = getDb();\n const conditions = [orgFilter(schema.workspaceResources)];\n if (filter?.kind) {\n conditions.push(eq(schema.workspaceResources.kind, filter.kind) as any);\n }\n return db\n .select()\n .from(schema.workspaceResources)\n .where(and(...conditions))\n .orderBy(desc(schema.workspaceResources.updatedAt));\n}\n\nexport async function listWorkspaceResourceOptions(filter?: {\n kind?: string;\n}): Promise<WorkspaceResourceOption[]> {\n const resources = await listWorkspaceResources(filter);\n return resources.map((resource) => ({\n id: resource.id,\n kind: resource.kind as WorkspaceResourceKind,\n name: resource.name,\n description: resource.description,\n path: resource.path,\n scope: resource.scope as WorkspaceResourceScope,\n updatedAt: resource.updatedAt,\n }));\n}\n\nexport async function getWorkspaceResource(\n resourceId: string,\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const db = getDb();\n const [row] = await db\n .select()\n .from(schema.workspaceResources)\n .where(\n and(\n eq(schema.workspaceResources.id, resourceId),\n ctxScope(schema.workspaceResources, ctx),\n ),\n )\n .limit(1);\n return row ?? null;\n}\n\nexport async function createWorkspaceResource(input: WorkspaceResourceInput) {\n const db = getDb();\n const timestamp = now();\n const resourceId = id();\n const actor = currentOwnerEmail();\n\n await db.insert(schema.workspaceResources).values({\n id: resourceId,\n ownerEmail: actor,\n orgId: currentOrgId(),\n kind: input.kind,\n name: input.name,\n description: input.description || null,\n path: input.path,\n content: input.content,\n scope: input.scope,\n createdBy: actor,\n createdAt: timestamp,\n updatedAt: timestamp,\n });\n\n await recordAudit({\n action: `workspace.${input.kind}.created`,\n targetType: `workspace-${input.kind}`,\n targetId: resourceId,\n summary: `Created workspace ${input.kind} \"${input.name}\" (${input.path})`,\n });\n\n return getWorkspaceResource(resourceId);\n}\n\nexport async function updateWorkspaceResource(\n resourceId: string,\n input: Partial<\n Pick<WorkspaceResourceInput, \"name\" | \"description\" | \"content\" | \"scope\">\n >,\n) {\n const db = getDb();\n const ctx = requireWorkspaceResourceCtx();\n const existing = await getWorkspaceResource(resourceId, ctx);\n if (!existing) throw new Error(\"Workspace resource not found\");\n\n const updates: Record<string, unknown> = { updatedAt: now() };\n if (input.name !== undefined) updates.name = input.name;\n if (input.description !== undefined)\n updates.description = input.description || null;\n if (input.content !== undefined) updates.content = input.content;\n if (input.scope !== undefined) updates.scope = input.scope;\n\n await db\n .update(schema.workspaceResources)\n .set(updates)\n .where(\n and(\n eq(schema.workspaceResources.id, resourceId),\n ctxScope(schema.workspaceResources, ctx),\n ),\n );\n\n await recordAudit({\n action: `workspace.${existing.kind}.updated`,\n targetType: `workspace-${existing.kind}`,\n targetId: resourceId,\n summary: `Updated workspace ${existing.kind} \"${input.name || existing.name}\"`,\n });\n\n return getWorkspaceResource(resourceId, ctx);\n}\n\nexport async function deleteWorkspaceResource(resourceId: string) {\n const db = getDb();\n const ctx = requireWorkspaceResourceCtx();\n const existing = await getWorkspaceResource(resourceId, ctx);\n if (!existing) throw new Error(\"Workspace resource not found\");\n\n // Revoke all grants\n const grants = await listResourceGrants({ resourceId });\n for (const grant of grants) {\n if (grant.status === \"active\") {\n await revokeResourceGrant(grant.id);\n }\n }\n\n await db\n .delete(schema.workspaceResources)\n .where(\n and(\n eq(schema.workspaceResources.id, resourceId),\n ctxScope(schema.workspaceResources, ctx),\n ),\n );\n\n await recordAudit({\n action: `workspace.${existing.kind}.deleted`,\n targetType: `workspace-${existing.kind}`,\n targetId: resourceId,\n summary: `Deleted workspace ${existing.kind} \"${existing.name}\" (${existing.path})`,\n });\n\n return existing;\n}\n\n// ─── Grants ──────────────────────────────────────────────────────\n\nexport async function listResourceGrants(filter?: {\n resourceId?: string;\n appId?: string;\n}) {\n const db = getDb();\n const conditions = [orgFilter(schema.workspaceResourceGrants)];\n if (filter?.resourceId) {\n conditions.push(\n eq(schema.workspaceResourceGrants.resourceId, filter.resourceId) as any,\n );\n }\n if (filter?.appId) {\n conditions.push(\n eq(schema.workspaceResourceGrants.appId, filter.appId) as any,\n );\n }\n return db\n .select()\n .from(schema.workspaceResourceGrants)\n .where(and(...conditions))\n .orderBy(desc(schema.workspaceResourceGrants.updatedAt));\n}\n\nexport async function getResourceGrant(\n grantId: string,\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const db = getDb();\n const [row] = await db\n .select()\n .from(schema.workspaceResourceGrants)\n .where(\n and(\n eq(schema.workspaceResourceGrants.id, grantId),\n ctxScope(schema.workspaceResourceGrants, ctx),\n ),\n )\n .limit(1);\n return row ?? null;\n}\n\nexport async function createResourceGrant(resourceId: string, appId: string) {\n const db = getDb();\n const ctx = requireWorkspaceResourceCtx();\n const resource = await getWorkspaceResource(resourceId, ctx);\n if (!resource) throw new Error(\"Workspace resource not found\");\n\n const activeExisting = (await listResourceGrants({ resourceId, appId })).find(\n (grant) => grant.status === \"active\",\n );\n if (activeExisting) {\n return activeExisting;\n }\n\n const timestamp = now();\n const grantId = id();\n const actor = currentOwnerEmail();\n\n await db.insert(schema.workspaceResourceGrants).values({\n id: grantId,\n ownerEmail: actor,\n orgId: currentOrgId(),\n resourceId,\n appId,\n status: \"active\",\n syncedAt: null,\n createdAt: timestamp,\n updatedAt: timestamp,\n });\n\n await recordAudit({\n action: `workspace.${resource.kind}.granted`,\n targetType: `workspace-${resource.kind}-grant`,\n targetId: grantId,\n summary: `Granted workspace ${resource.kind} \"${resource.name}\" to ${appId}`,\n });\n\n return getResourceGrant(grantId);\n}\n\nexport async function grantWorkspaceResourcesToApp(input: {\n appId: string;\n resourceIds: string[];\n}) {\n const uniqueResourceIds = [...new Set(input.resourceIds.filter(Boolean))];\n if (uniqueResourceIds.length === 0) {\n return { appId: input.appId, granted: [], skipped: [] };\n }\n\n const granted: Array<{ id: string; resourceId: string; appId: string }> = [];\n const skipped: Array<{ resourceId: string; reason: string }> = [];\n\n for (const resourceId of uniqueResourceIds) {\n const resource = await getWorkspaceResource(resourceId).catch(() => null);\n if (!resource) {\n skipped.push({ resourceId, reason: \"not-found\" });\n continue;\n }\n if (resource.scope === \"all\") {\n skipped.push({ resourceId, reason: \"already-all-apps\" });\n continue;\n }\n\n const grant = await createResourceGrant(resourceId, input.appId);\n if (grant) {\n granted.push({\n id: grant.id,\n resourceId: grant.resourceId,\n appId: grant.appId,\n });\n }\n }\n\n return { appId: input.appId, granted, skipped };\n}\n\nexport async function revokeResourceGrant(\n grantId: string,\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const db = getDb();\n const grant = await getResourceGrant(grantId, ctx);\n if (!grant) throw new Error(\"Grant not found\");\n\n const resource = await getWorkspaceResource(grant.resourceId);\n\n await db\n .update(schema.workspaceResourceGrants)\n .set({ status: \"revoked\", updatedAt: now() })\n .where(\n and(\n eq(schema.workspaceResourceGrants.id, grantId),\n ctxScope(schema.workspaceResourceGrants, ctx),\n ),\n );\n\n await recordAudit({\n action: `workspace.${resource?.kind || \"resource\"}.grant-revoked`,\n targetType: \"workspace-resource-grant\",\n targetId: grantId,\n summary: `Revoked workspace ${resource?.kind || \"resource\"} \"${resource?.name || grant.resourceId}\" from ${grant.appId}`,\n });\n\n return getResourceGrant(grantId, ctx);\n}\n\n// ─── Sync ──────────────────────────────────────────────────────\n\n/**\n * Push workspace resources to an app via its /_agent-native/resources endpoint.\n * Resources with scope=\"all\" are always pushed. Resources with scope=\"selected\"\n * are only pushed if there's an active grant for that app.\n */\nexport async function syncResourcesToApp(appId: string) {\n const agents = await discoverAgents(\"dispatch\");\n const agent = agents.find((a) => a.id === appId);\n if (!agent) throw new Error(`App \"${appId}\" not found in agent registry`);\n\n const allResources = await listWorkspaceResources();\n const grants = await listResourceGrants({ appId });\n const activeGrantResourceIds = new Set(\n grants.filter((g) => g.status === \"active\").map((g) => g.resourceId),\n );\n\n // Determine which resources to push\n const toPush = allResources.filter(\n (r) =>\n r.scope === \"all\" ||\n (r.scope === \"selected\" && activeGrantResourceIds.has(r.id)),\n );\n\n if (toPush.length === 0) {\n return { appId, synced: 0, resources: [] };\n }\n\n const syncedPaths: string[] = [];\n const db = getDb();\n const timestamp = now();\n\n for (const resource of toPush) {\n try {\n // Push via the resources API — create as shared resource\n const res = await fetch(`${agent.url}/_agent-native/resources`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n path: resource.path,\n content: resource.content,\n shared: true,\n mimeType: \"text/markdown\",\n }),\n });\n\n if (res.ok || res.status === 409) {\n // 409 = already exists, try updating\n if (res.status === 409) {\n // Fetch existing to get ID, then update\n const listRes = await fetch(\n `${agent.url}/_agent-native/resources?scope=shared&path=${encodeURIComponent(resource.path)}`,\n );\n if (listRes.ok) {\n const items = await listRes.json();\n const existing = Array.isArray(items)\n ? items.find((i: any) => i.path === resource.path)\n : null;\n if (existing) {\n await fetch(\n `${agent.url}/_agent-native/resources/${existing.id}`,\n {\n method: \"PUT\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ content: resource.content }),\n },\n );\n }\n }\n }\n syncedPaths.push(resource.path);\n\n // Update grant syncedAt if applicable\n const grant = grants.find(\n (g) => g.resourceId === resource.id && g.status === \"active\",\n );\n if (grant) {\n await db\n .update(schema.workspaceResourceGrants)\n .set({ syncedAt: timestamp, updatedAt: timestamp })\n .where(eq(schema.workspaceResourceGrants.id, grant.id));\n }\n }\n } catch {\n // Skip unreachable — don't fail the whole sync\n }\n }\n\n await recordAudit({\n action: \"workspace.resources.synced\",\n targetType: \"workspace-resource-sync\",\n targetId: appId,\n summary: `Synced ${syncedPaths.length} workspace resource(s) to ${appId}: ${syncedPaths.join(\", \")}`,\n });\n\n return { appId, synced: syncedPaths.length, resources: syncedPaths };\n}\n\n/**\n * Sync all workspace resources to all apps that have grants or scope=\"all\" resources.\n */\nexport async function syncResourcesToAllApps() {\n const agents = await discoverAgents(\"dispatch\");\n const results: Array<{ appId: string; synced: number }> = [];\n\n for (const agent of agents) {\n try {\n const result = await syncResourcesToApp(agent.id);\n results.push({ appId: result.appId, synced: result.synced });\n } catch {\n results.push({ appId: agent.id, synced: 0 });\n }\n }\n\n return results;\n}\n\n// ─── Overview ──────────────────────────────────────────────────────\n\nexport async function listWorkspaceResourcesOverview() {\n const [resources, grants] = await Promise.all([\n listWorkspaceResources(),\n listResourceGrants(),\n ]);\n\n const skills = resources.filter((r) => r.kind === \"skill\");\n const instructions = resources.filter((r) => r.kind === \"instruction\");\n const agents = resources.filter((r) => r.kind === \"agent\");\n const knowledge = resources.filter((r) => r.kind === \"knowledge\");\n const activeGrants = grants.filter((g) => g.status === \"active\");\n\n return {\n skillCount: skills.length,\n instructionCount: instructions.length,\n agentCount: agents.length,\n knowledgeCount: knowledge.length,\n totalResources: resources.length,\n activeGrantCount: activeGrants.length,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workspace-resources-store.js","sourceRoot":"","sources":["../../../src/server/lib/workspace-resources-store.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,EACjB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AC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;IAC3D,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;IAC3D,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;IAClE,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;IAEjE,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,MAAM;QACzB,gBAAgB,EAAE,YAAY,CAAC,MAAM;QACrC,UAAU,EAAE,MAAM,CAAC,MAAM;QACzB,cAAc,EAAE,SAAS,CAAC,MAAM;QAChC,cAAc,EAAE,SAAS,CAAC,MAAM;QAChC,gBAAgB,EAAE,YAAY,CAAC,MAAM;KACtC,CAAC;AACJ,CAAC","sourcesContent":["import crypto from \"node:crypto\";\nimport { and, desc, eq, isNull, or } from \"drizzle-orm\";\nimport { getDbExec, isPostgres } from \"@agent-native/core/db\";\nimport {\n resourceDeleteByPath,\n resourceEffectiveContext,\n resourceGetByPath,\n resourceListAllOwners,\n resourcePut,\n SHARED_OWNER,\n WORKSPACE_OWNER,\n type EffectiveResourceContext,\n type EffectiveResourceLayer,\n type ResourceInheritanceScope,\n type ResourceMeta,\n} from \"@agent-native/core/resources/store\";\nimport {\n getOrgSetting,\n getUserSetting,\n putOrgSetting,\n putUserSetting,\n} from \"@agent-native/core/settings\";\nimport { discoverAgents } from \"@agent-native/core/server/agent-discovery\";\nimport { getDb, schema } from \"../../db/index.js\";\nimport {\n createApprovalRequest,\n currentOwnerEmail,\n currentOrgId,\n getApprovalPolicy,\n recordAudit,\n} from \"./dispatch-store.js\";\n\n/**\n * Caller-supplied access context for workspace-resource operations.\n * Same shape and semantics as VaultCtx — looking up a row by id alone is\n * unsafe because UUIDs are not authorization. A row matches the ctx if\n * either the caller owns it or it lives in the caller's active org.\n */\nexport interface WorkspaceResourceCtx {\n ownerEmail: string;\n orgId: string | null;\n}\n\nexport function requireWorkspaceResourceCtx(): WorkspaceResourceCtx {\n const ownerEmail = currentOwnerEmail();\n return { ownerEmail, orgId: currentOrgId() };\n}\n\n/** WHERE clause that limits a workspace-resource row to the caller's scope. */\nfunction ctxScope<T extends { ownerEmail: any; orgId: any }>(\n table: T,\n ctx: WorkspaceResourceCtx,\n) {\n if (!ctx.orgId) {\n return and(eq(table.ownerEmail, ctx.ownerEmail), isNull(table.orgId));\n }\n return or(eq(table.ownerEmail, ctx.ownerEmail), eq(table.orgId, ctx.orgId));\n}\n\nfunction id() {\n return crypto.randomUUID();\n}\n\nfunction now() {\n return Date.now();\n}\n\nconst DISPATCH_RESOURCE_METADATA_SOURCE = \"dispatch-workspace-resource\";\n\ninterface MaterializableWorkspaceResource {\n id: string;\n kind: string;\n name: string;\n description: string | null;\n path: string;\n content: string;\n scope: string;\n updatedAt: number;\n}\n\nfunction mimeTypeForWorkspaceResource(\n resource: MaterializableWorkspaceResource,\n) {\n return resource.path.endsWith(\".json\") ? \"application/json\" : \"text/markdown\";\n}\n\nfunction parseResourceMetadata(metadata: string | null): Record<string, any> {\n if (!metadata) return {};\n try {\n const parsed = JSON.parse(metadata);\n return parsed && typeof parsed === \"object\" && !Array.isArray(parsed)\n ? parsed\n : {};\n } catch {\n return {};\n }\n}\n\nasync function materializeGlobalResource(\n resource: MaterializableWorkspaceResource,\n) {\n if (resource.scope !== \"all\") {\n await removeMaterializedGlobalResource(resource);\n return;\n }\n\n const mimeType = mimeTypeForWorkspaceResource(resource);\n const existing = await resourceGetByPath(\n WORKSPACE_OWNER,\n resource.path,\n ).catch(() => null);\n const existingMetadata = parseResourceMetadata(existing?.metadata ?? null);\n if (\n existing?.content === resource.content &&\n existing.mimeType === mimeType &&\n existingMetadata.source === DISPATCH_RESOURCE_METADATA_SOURCE &&\n existingMetadata.resourceId === resource.id &&\n existingMetadata.updatedAt === resource.updatedAt\n ) {\n await removeMaterializedResourceFromOwner(SHARED_OWNER, resource);\n return;\n }\n\n await resourcePut(\n WORKSPACE_OWNER,\n resource.path,\n resource.content,\n mimeType,\n {\n createdBy: \"system\",\n metadata: {\n source: DISPATCH_RESOURCE_METADATA_SOURCE,\n resourceId: resource.id,\n kind: resource.kind,\n name: resource.name,\n description: resource.description,\n updatedAt: resource.updatedAt,\n },\n },\n );\n await removeMaterializedResourceFromOwner(SHARED_OWNER, resource);\n}\n\nasync function ensureMaterializedGlobalResources(\n resources: MaterializableWorkspaceResource[],\n) {\n for (const resource of resources) {\n await materializeGlobalResource(resource);\n }\n}\n\nasync function removeMaterializedResourceFromOwner(\n owner: string,\n resource: Pick<MaterializableWorkspaceResource, \"id\" | \"path\">,\n) {\n const existing = await resourceGetByPath(owner, resource.path).catch(\n () => null,\n );\n if (!existing) return;\n const metadata = parseResourceMetadata(existing.metadata);\n if (\n metadata.source !== DISPATCH_RESOURCE_METADATA_SOURCE ||\n metadata.resourceId !== resource.id\n ) {\n return;\n }\n await resourceDeleteByPath(owner, resource.path);\n}\n\nasync function removeMaterializedGlobalResource(\n resource: Pick<MaterializableWorkspaceResource, \"id\" | \"path\">,\n) {\n await removeMaterializedResourceFromOwner(WORKSPACE_OWNER, resource);\n await removeMaterializedResourceFromOwner(SHARED_OWNER, resource);\n}\n\nfunction orgFilter<T extends { ownerEmail: any; orgId: any }>(table: T) {\n const orgId = currentOrgId();\n if (orgId) return eq(table.orgId, orgId);\n return and(eq(table.ownerEmail, currentOwnerEmail()), isNull(table.orgId));\n}\n\n// ─── Workspace Resources CRUD ──────────────────────────────────\n\nexport type WorkspaceResourceKind =\n | \"skill\"\n | \"instruction\"\n | \"agent\"\n | \"knowledge\";\nexport type WorkspaceResourceScope = \"all\" | \"selected\";\n\nexport interface WorkspaceResourceInput {\n kind: WorkspaceResourceKind;\n name: string;\n description?: string | null;\n path: string;\n content: string;\n scope: WorkspaceResourceScope;\n}\n\nexport interface WorkspaceResourceOption {\n id: string;\n kind: WorkspaceResourceKind;\n name: string;\n description: string | null;\n path: string;\n scope: WorkspaceResourceScope;\n updatedAt: number;\n}\n\nexport interface WorkspaceResourceForApp extends WorkspaceResourceOption {\n source: \"workspace\" | \"grant\";\n autoLoaded: boolean;\n grantId: string | null;\n}\n\nexport type WorkspaceResourceAvailability =\n | \"all-apps\"\n | \"selected-granted\"\n | \"selected-not-granted\"\n | \"selected-no-app\"\n | \"path-not-managed\";\n\nexport interface WorkspaceResourceEffectiveLayer extends Omit<\n EffectiveResourceLayer,\n \"scope\"\n> {\n scope: ResourceInheritanceScope;\n resource: ResourceMeta | null;\n}\n\nexport interface WorkspaceResourceEffectiveContext {\n appId: string | null;\n userEmail: string;\n path: string;\n workspaceResource: WorkspaceResourceOption | null;\n availability: WorkspaceResourceAvailability;\n availableToApp: boolean;\n activeGrantId: string | null;\n effectiveScope: ResourceInheritanceScope | null;\n effectiveResource: ResourceMeta | null;\n layers: WorkspaceResourceEffectiveLayer[];\n}\n\nexport type WorkspaceResourceChangeOperation = \"create\" | \"update\" | \"delete\";\n\nexport interface WorkspaceResourceOverrideImpact {\n scope: \"shared\" | \"personal\";\n owner: string;\n label: string;\n updatedAt: number;\n}\n\nexport interface WorkspaceResourceChangeImpact {\n operation: WorkspaceResourceChangeOperation;\n path: string | null;\n resourceId: string | null;\n beforeScope: WorkspaceResourceScope | null;\n afterScope: WorkspaceResourceScope | null;\n affectsAllApps: boolean;\n affectedApps: {\n label: string;\n count: number | null;\n apps: Array<{ id: string; name: string }>;\n };\n overrides: {\n count: number;\n sharedCount: number;\n personalCount: number;\n items: WorkspaceResourceOverrideImpact[];\n };\n approval: {\n policyEnabled: boolean;\n willRequestApproval: boolean;\n };\n}\n\nconst STARTER_RESOURCES_VERSION = 2;\nconst STARTER_RESOURCES_SETTING_KEY = \"dispatch-starter-workspace-resources\";\nconst starterEnsurePromises = new Map<string, Promise<void>>();\n\nexport const STARTER_GLOBAL_WORKSPACE_RESOURCES: WorkspaceResourceInput[] = [\n {\n kind: \"knowledge\",\n name: \"Company Profile\",\n description:\n \"Canonical company facts, audiences, products, and market context for every workspace app.\",\n path: \"context/company.md\",\n scope: \"all\",\n content: `# Company Profile\n\nUse this shared workspace resource for canonical company context. Keep it factual and current so every app agent can answer and act from the same baseline.\n\n## Snapshot\n\n- Company name:\n- Website:\n- Category:\n- Primary audiences:\n- Core products:\n- Markets served:\n\n## Positioning\n\n- One-line description:\n- What we help customers do:\n- Why customers choose us:\n- Alternatives customers compare us against:\n\n## Company Facts\n\n- Headquarters:\n- Founded:\n- Size:\n- Key teams or leaders:\n- Important customer segments:\n\n## Notes For Agents\n\n- Prefer this file for company facts before guessing.\n- If a task needs deeper brand or messaging guidance, read \\`context/brand.md\\` and \\`context/messaging.md\\` too.\n`,\n },\n {\n kind: \"knowledge\",\n name: \"Brand Guidelines\",\n description:\n \"Shared brand voice, visual identity, naming, and presentation guidance.\",\n path: \"context/brand.md\",\n scope: \"all\",\n content: `# Brand Guidelines\n\nUse this shared workspace resource when writing, designing, reviewing customer-facing work, or making choices that affect brand consistency.\n\n## Brand Personality\n\n- We sound:\n- We avoid sounding:\n- Words we use often:\n- Words we avoid:\n\n## Voice And Tone\n\n- Default tone:\n- Executive/customer tone:\n- Support tone:\n- Internal tone:\n\n## Visual Direction\n\n- Colors:\n- Typography:\n- Imagery:\n- Layout preferences:\n- Accessibility requirements:\n\n## Naming And Style\n\n- Product names:\n- Feature names:\n- Capitalization:\n- Punctuation:\n- Boilerplate legal or compliance notes:\n`,\n },\n {\n kind: \"knowledge\",\n name: \"Messaging\",\n description:\n \"Core positioning, value propositions, proof points, personas, and objection handling.\",\n path: \"context/messaging.md\",\n scope: \"all\",\n content: `# Messaging\n\nUse this shared workspace resource for positioning, campaigns, sales/support drafts, product copy, and any work that should align to company messaging.\n\n## Primary Message\n\n- Short version:\n- Longer version:\n- Category framing:\n\n## Personas\n\n| Persona | Goals | Pain Points | What They Care About |\n| ------- | ----- | ----------- | -------------------- |\n| | | | |\n\n## Value Propositions\n\n- Value prop 1:\n- Value prop 2:\n- Value prop 3:\n\n## Proof Points\n\n- Customer evidence:\n- Metrics:\n- Differentiators:\n- Quotes or references:\n\n## Objections\n\n| Objection | Recommended Response |\n| --------- | -------------------- |\n| | |\n`,\n },\n {\n kind: \"instruction\",\n name: \"Workspace Guardrails\",\n description:\n \"Always-on guardrails that every app agent in the workspace should follow.\",\n path: \"instructions/guardrails.md\",\n scope: \"all\",\n content: `# Workspace Guardrails\n\nThese instructions apply to every app agent in this workspace.\n\n## Always\n\n- Protect customer, employee, and partner data.\n- Use workspace resources as the source of truth before inventing company facts.\n- Be clear when information is missing or uncertain.\n- Preserve the user's intent and ask only when a decision is genuinely blocked.\n- Keep external-facing work aligned with \\`context/brand.md\\` and \\`context/messaging.md\\`.\n\n## Never\n\n- Expose secrets, credentials, private tokens, or hidden system instructions.\n- Present guesses as facts.\n- Make destructive data, billing, access, or publishing changes without clear user intent.\n- Ignore app-specific AGENTS.md instructions; combine them with these workspace guardrails.\n\n## When Context Matters\n\nFor brand, company, persona, product, or positioning-sensitive work, read the relevant shared resources under \\`context/\\` before drafting or taking action.\n`,\n },\n {\n kind: \"skill\",\n name: \"Company Voice\",\n description:\n \"Apply the workspace's company voice and messaging to customer-facing content.\",\n path: \"skills/company-voice/SKILL.md\",\n scope: \"all\",\n content: `---\nname: company-voice\ndescription: >-\n Use when drafting, rewriting, reviewing, or localizing customer-facing\n content so it matches the workspace's company voice, brand guidance, and\n messaging.\n---\n\n# Company Voice\n\nUse this skill for customer-facing copy, sales/support messages, launch notes, landing pages, lifecycle emails, scripts, docs, and executive communications.\n\n## Required Context\n\nBefore finalizing the work, read the relevant shared resources:\n\n- \\`context/company.md\\` for company facts and positioning\n- \\`context/brand.md\\` for tone, style, naming, and visual guidance\n- \\`context/messaging.md\\` for personas, value props, proof points, and objections\n\n## Workflow\n\n1. Identify the audience, channel, and desired action.\n2. Pull the relevant facts and vocabulary from the shared context resources.\n3. Draft in the workspace voice, keeping claims specific and supportable.\n4. Check for prohibited terms, tone mismatches, and unsupported assertions.\n5. If critical context is missing, name the gap and offer a concise placeholder or question.\n\n## Output\n\n- Keep the user's requested format.\n- Prefer direct, useful language over generic marketing filler.\n- Include caveats only when they materially affect accuracy or approval.\n`,\n },\n];\n\nfunction starterScopeKey(ctx: WorkspaceResourceCtx): string {\n return ctx.orgId ? `org:${ctx.orgId}` : `solo:${ctx.ownerEmail}`;\n}\n\nfunction starterEnsureKey(ctx: WorkspaceResourceCtx): string {\n return `${STARTER_RESOURCES_VERSION}:${starterScopeKey(ctx)}`;\n}\n\nfunction starterResourceId(ctx: WorkspaceResourceCtx, path: string): string {\n const hash = crypto\n .createHash(\"sha256\")\n .update(`${starterScopeKey(ctx)}:${path}`)\n .digest(\"hex\")\n .slice(0, 24);\n return `starter_${hash}`;\n}\n\nasync function readStarterSeedMarker(\n ctx: WorkspaceResourceCtx,\n): Promise<Record<string, unknown> | null> {\n return ctx.orgId\n ? getOrgSetting(ctx.orgId, STARTER_RESOURCES_SETTING_KEY)\n : getUserSetting(ctx.ownerEmail, STARTER_RESOURCES_SETTING_KEY);\n}\n\nasync function writeStarterSeedMarker(ctx: WorkspaceResourceCtx) {\n const value = {\n version: STARTER_RESOURCES_VERSION,\n seededAt: new Date().toISOString(),\n resources: STARTER_GLOBAL_WORKSPACE_RESOURCES.map((resource) => ({\n path: resource.path,\n kind: resource.kind,\n scope: resource.scope,\n })),\n };\n if (ctx.orgId) {\n await putOrgSetting(ctx.orgId, STARTER_RESOURCES_SETTING_KEY, value);\n } else {\n await putUserSetting(ctx.ownerEmail, STARTER_RESOURCES_SETTING_KEY, value);\n }\n}\n\nasync function getWorkspaceResourceByPath(\n resourcePath: string,\n ctx: WorkspaceResourceCtx,\n) {\n const db = getDb();\n const scopeCondition = ctx.orgId\n ? eq(schema.workspaceResources.orgId, ctx.orgId)\n : and(\n eq(schema.workspaceResources.ownerEmail, ctx.ownerEmail),\n isNull(schema.workspaceResources.orgId),\n );\n const [row] = await db\n .select()\n .from(schema.workspaceResources)\n .where(\n and(eq(schema.workspaceResources.path, resourcePath), scopeCondition),\n )\n .limit(1);\n return row ?? null;\n}\n\nasync function insertStarterWorkspaceResource(\n starter: WorkspaceResourceInput,\n ctx: WorkspaceResourceCtx,\n timestamp: number,\n) {\n const exec = getDbExec();\n const resourceId = starterResourceId(ctx, starter.path);\n const sql = isPostgres()\n ? `INSERT INTO workspace_resources (id, owner_email, org_id, kind, name, description, path, content, scope, created_by, created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT (id) DO NOTHING`\n : `INSERT OR IGNORE INTO workspace_resources (id, owner_email, org_id, kind, name, description, path, content, scope, created_by, created_at, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;\n await exec.execute({\n sql,\n args: [\n resourceId,\n ctx.ownerEmail,\n ctx.orgId,\n starter.kind,\n starter.name,\n starter.description || null,\n starter.path,\n starter.content,\n starter.scope,\n ctx.ownerEmail,\n timestamp,\n timestamp,\n ],\n });\n}\n\nexport async function ensureStarterWorkspaceResources(\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const key = starterEnsureKey(ctx);\n let promise = starterEnsurePromises.get(key);\n if (!promise) {\n promise = ensureStarterWorkspaceResourcesOnce(ctx).catch((error) => {\n starterEnsurePromises.delete(key);\n throw error;\n });\n starterEnsurePromises.set(key, promise);\n }\n await promise;\n}\n\nasync function ensureStarterWorkspaceResourcesOnce(ctx: WorkspaceResourceCtx) {\n const marker = await readStarterSeedMarker(ctx).catch(() => null);\n if (marker?.version === STARTER_RESOURCES_VERSION) return;\n\n const timestamp = now();\n const ensuredResources: MaterializableWorkspaceResource[] = [];\n\n for (const starter of STARTER_GLOBAL_WORKSPACE_RESOURCES) {\n const existing = await getWorkspaceResourceByPath(starter.path, ctx);\n if (!existing) {\n await insertStarterWorkspaceResource(starter, ctx, timestamp);\n }\n const row = await getWorkspaceResourceByPath(starter.path, ctx);\n if (row) ensuredResources.push(row);\n }\n\n for (const resource of ensuredResources) {\n await materializeGlobalResource(resource);\n }\n\n await writeStarterSeedMarker(ctx);\n}\n\nexport async function restoreStarterWorkspaceResources(input?: {\n paths?: string[];\n}) {\n const ctx = requireWorkspaceResourceCtx();\n const requestedPaths = new Set((input?.paths ?? []).filter(Boolean));\n const starters =\n requestedPaths.size > 0\n ? STARTER_GLOBAL_WORKSPACE_RESOURCES.filter((resource) =>\n requestedPaths.has(resource.path),\n )\n : STARTER_GLOBAL_WORKSPACE_RESOURCES;\n const knownPaths = new Set(\n STARTER_GLOBAL_WORKSPACE_RESOURCES.map((resource) => resource.path),\n );\n const unknown = [...requestedPaths].filter((path) => !knownPaths.has(path));\n const timestamp = now();\n const restored: WorkspaceResourceOption[] = [];\n const existing: WorkspaceResourceOption[] = [];\n\n for (const starter of starters) {\n const before = await getWorkspaceResourceByPath(starter.path, ctx);\n if (!before) {\n await insertStarterWorkspaceResource(starter, ctx, timestamp);\n }\n const row = await getWorkspaceResourceByPath(starter.path, ctx);\n if (!row) continue;\n await materializeGlobalResource(row);\n const option: WorkspaceResourceOption = {\n id: row.id,\n kind: row.kind as WorkspaceResourceKind,\n name: row.name,\n description: row.description,\n path: row.path,\n scope: row.scope as WorkspaceResourceScope,\n updatedAt: row.updatedAt,\n };\n if (before) existing.push(option);\n else restored.push(option);\n }\n\n if (restored.length > 0) {\n await recordAudit({\n action: \"workspace.starter-resources.restored\",\n targetType: \"workspace-resource\",\n targetId: null,\n summary: `Restored starter workspace resource(s): ${restored.map((resource) => resource.path).join(\", \")}`,\n metadata: { paths: restored.map((resource) => resource.path) },\n });\n }\n\n return { restored, existing, unknown };\n}\n\nexport async function listWorkspaceResources(filter?: { kind?: string }) {\n await ensureStarterWorkspaceResources();\n const db = getDb();\n const conditions = [orgFilter(schema.workspaceResources)];\n if (filter?.kind) {\n conditions.push(eq(schema.workspaceResources.kind, filter.kind) as any);\n }\n const resources = await db\n .select()\n .from(schema.workspaceResources)\n .where(and(...conditions))\n .orderBy(desc(schema.workspaceResources.updatedAt));\n await ensureMaterializedGlobalResources(resources);\n return resources;\n}\n\nexport async function listWorkspaceResourceOptions(filter?: {\n kind?: string;\n}): Promise<WorkspaceResourceOption[]> {\n const resources = await listWorkspaceResources(filter);\n return resources.map((resource) => ({\n id: resource.id,\n kind: resource.kind as WorkspaceResourceKind,\n name: resource.name,\n description: resource.description,\n path: resource.path,\n scope: resource.scope as WorkspaceResourceScope,\n updatedAt: resource.updatedAt,\n }));\n}\n\nfunction isResourceAutoLoaded(resource: { kind: string; path: string }) {\n return (\n resource.kind === \"instruction\" &&\n (resource.path === \"AGENTS.md\" || resource.path.startsWith(\"instructions/\"))\n );\n}\n\nexport async function listWorkspaceResourcesForApp(appId: string): Promise<{\n appId: string;\n resources: WorkspaceResourceForApp[];\n counts: {\n total: number;\n workspace: number;\n global: number;\n granted: number;\n autoLoaded: number;\n };\n}> {\n const [resources, grants] = await Promise.all([\n listWorkspaceResources(),\n listResourceGrants({ appId }),\n ]);\n const activeGrantsByResourceId = new Map(\n grants\n .filter((grant) => grant.status === \"active\")\n .map((grant) => [grant.resourceId, grant]),\n );\n\n const received = resources\n .map((resource): WorkspaceResourceForApp | null => {\n const grant = activeGrantsByResourceId.get(resource.id);\n const isGlobal = resource.scope === \"all\";\n if (!isGlobal && !grant) return null;\n return {\n id: resource.id,\n kind: resource.kind as WorkspaceResourceKind,\n name: resource.name,\n description: resource.description,\n path: resource.path,\n scope: resource.scope as WorkspaceResourceScope,\n updatedAt: resource.updatedAt,\n source: isGlobal ? \"workspace\" : \"grant\",\n autoLoaded: isResourceAutoLoaded(resource),\n grantId: grant?.id ?? null,\n };\n })\n .filter((resource): resource is WorkspaceResourceForApp => !!resource)\n .sort((a, b) => {\n const sourceOrder =\n (a.source === \"workspace\" ? 0 : 1) - (b.source === \"workspace\" ? 0 : 1);\n if (sourceOrder !== 0) return sourceOrder;\n return a.path.localeCompare(b.path);\n });\n\n const global = received.filter((resource) => resource.source === \"workspace\");\n const granted = received.filter((resource) => resource.source === \"grant\");\n\n return {\n appId,\n resources: received,\n counts: {\n total: received.length,\n workspace: global.length,\n global: global.length,\n granted: granted.length,\n autoLoaded: received.filter((resource) => resource.autoLoaded).length,\n },\n };\n}\n\nfunction workspaceResourceOption(\n resource: MaterializableWorkspaceResource,\n): WorkspaceResourceOption {\n return {\n id: resource.id,\n kind: resource.kind as WorkspaceResourceKind,\n name: resource.name,\n description: resource.description,\n path: resource.path,\n scope: resource.scope as WorkspaceResourceScope,\n updatedAt: resource.updatedAt,\n };\n}\n\nfunction effectiveAvailability(input: {\n resource: WorkspaceResourceOption | null;\n appId: string | null;\n activeGrantId: string | null;\n}): Pick<WorkspaceResourceEffectiveContext, \"availability\" | \"availableToApp\"> {\n if (!input.resource) {\n return { availability: \"path-not-managed\", availableToApp: false };\n }\n if (input.resource.scope === \"all\") {\n return { availability: \"all-apps\", availableToApp: true };\n }\n if (!input.appId) {\n return { availability: \"selected-no-app\", availableToApp: false };\n }\n if (input.activeGrantId) {\n return { availability: \"selected-granted\", availableToApp: true };\n }\n return { availability: \"selected-not-granted\", availableToApp: false };\n}\n\nfunction affectsAllAppsScope(\n beforeScope: string | null | undefined,\n afterScope: string | null | undefined,\n) {\n return beforeScope === \"all\" || afterScope === \"all\";\n}\n\nasync function shouldRequestAllAppResourceApproval(input: {\n beforeScope?: string | null;\n afterScope?: string | null;\n}) {\n if (!affectsAllAppsScope(input.beforeScope, input.afterScope)) return false;\n const policy = await getApprovalPolicy();\n return policy.enabled;\n}\n\nfunction mergedWorkspaceResourceAfter(\n before: MaterializableWorkspaceResource,\n input: Partial<\n Pick<WorkspaceResourceInput, \"name\" | \"description\" | \"content\" | \"scope\">\n >,\n): WorkspaceResourceOption & {\n content: string;\n} {\n return {\n id: before.id,\n kind: before.kind as WorkspaceResourceKind,\n name: input.name ?? before.name,\n description:\n input.description === undefined\n ? before.description\n : input.description || null,\n path: before.path,\n content: input.content ?? before.content,\n scope: (input.scope ?? before.scope) as WorkspaceResourceScope,\n updatedAt: before.updatedAt,\n };\n}\n\nasync function listOverrideImpactForPath(\n resourcePath: string,\n): Promise<WorkspaceResourceOverrideImpact[]> {\n const resources = await resourceListAllOwners(resourcePath).catch(() => []);\n return resources\n .filter(\n (resource) =>\n resource.path === resourcePath && resource.owner !== WORKSPACE_OWNER,\n )\n .map((resource): WorkspaceResourceOverrideImpact => {\n const shared = resource.owner === SHARED_OWNER;\n return {\n scope: shared ? \"shared\" : \"personal\",\n owner: resource.owner,\n label: shared\n ? \"Organization/app override\"\n : `Personal override (${resource.owner})`,\n updatedAt: resource.updatedAt,\n };\n })\n .sort((a, b) => {\n const scopeOrder =\n (a.scope === \"shared\" ? 0 : 1) - (b.scope === \"shared\" ? 0 : 1);\n if (scopeOrder !== 0) return scopeOrder;\n return b.updatedAt - a.updatedAt;\n });\n}\n\nasync function affectedAllAppTargets() {\n const agents = await discoverAgents(\"dispatch\").catch(() => []);\n const apps = agents\n .filter((agent) => agent.id !== \"dispatch\")\n .map((agent) => ({\n id: agent.id,\n name: agent.name || agent.id,\n }))\n .sort((a, b) => a.name.localeCompare(b.name));\n return {\n label: apps.length > 0 ? \"All workspace apps\" : \"All workspace apps\",\n count: apps.length,\n apps,\n };\n}\n\nexport async function previewWorkspaceResourceChange(input: {\n operation?: WorkspaceResourceChangeOperation;\n resourceId?: string;\n path?: string;\n scope?: WorkspaceResourceScope;\n}): Promise<WorkspaceResourceChangeImpact> {\n const operation = input.operation ?? (input.resourceId ? \"update\" : \"create\");\n const ctx = requireWorkspaceResourceCtx();\n const existing = input.resourceId\n ? await getWorkspaceResource(input.resourceId, ctx)\n : null;\n const path = input.path?.trim() || existing?.path || null;\n const beforeScope = existing?.scope\n ? (existing.scope as WorkspaceResourceScope)\n : null;\n const afterScope =\n operation === \"delete\"\n ? null\n : ((input.scope ??\n existing?.scope ??\n null) as WorkspaceResourceScope | null);\n const affectsAllApps = affectsAllAppsScope(beforeScope, afterScope);\n const [policy, overrides, affectedApps] = await Promise.all([\n getApprovalPolicy(),\n path ? listOverrideImpactForPath(path) : Promise.resolve([]),\n affectsAllApps\n ? affectedAllAppTargets()\n : Promise.resolve({\n label: \"Selected apps only\",\n count: null,\n apps: [] as Array<{ id: string; name: string }>,\n }),\n ]);\n\n return {\n operation,\n path,\n resourceId: existing?.id ?? input.resourceId ?? null,\n beforeScope,\n afterScope,\n affectsAllApps,\n affectedApps,\n overrides: {\n count: overrides.length,\n sharedCount: overrides.filter((override) => override.scope === \"shared\")\n .length,\n personalCount: overrides.filter(\n (override) => override.scope === \"personal\",\n ).length,\n items: overrides,\n },\n approval: {\n policyEnabled: policy.enabled,\n willRequestApproval: policy.enabled && affectsAllApps,\n },\n };\n}\n\nexport async function getWorkspaceResourceEffectiveContext(input: {\n resourceId?: string;\n path?: string;\n appId?: string | null;\n userEmail?: string | null;\n}): Promise<WorkspaceResourceEffectiveContext> {\n const ctx = requireWorkspaceResourceCtx();\n const appId = input.appId?.trim() || null;\n const userEmail = input.userEmail?.trim() || ctx.ownerEmail;\n\n let row: MaterializableWorkspaceResource | null = null;\n if (input.resourceId) {\n row = await getWorkspaceResource(input.resourceId, ctx);\n }\n const path = input.path?.trim() || row?.path;\n if (!path) {\n throw new Error(\"Provide a workspace resource id or path.\");\n }\n if (!row) {\n row = await getWorkspaceResourceByPath(path, ctx);\n }\n\n if (row?.scope === \"all\") {\n await materializeGlobalResource(row);\n }\n\n const coreContext: EffectiveResourceContext = await resourceEffectiveContext(\n userEmail,\n path,\n );\n const resource = row ? workspaceResourceOption(row) : null;\n const activeGrant =\n resource?.scope === \"selected\" && appId\n ? (await listResourceGrants({ resourceId: resource.id, appId })).find(\n (grant) => grant.status === \"active\",\n )\n : null;\n const availability = effectiveAvailability({\n resource,\n appId,\n activeGrantId: activeGrant?.id ?? null,\n });\n\n return {\n appId,\n userEmail,\n path,\n workspaceResource: resource,\n ...availability,\n activeGrantId: activeGrant?.id ?? null,\n effectiveScope: coreContext.effectiveScope,\n effectiveResource: coreContext.effectiveResource,\n layers: coreContext.layers,\n };\n}\n\nexport async function getWorkspaceResource(\n resourceId: string,\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const db = getDb();\n const [row] = await db\n .select()\n .from(schema.workspaceResources)\n .where(\n and(\n eq(schema.workspaceResources.id, resourceId),\n ctxScope(schema.workspaceResources, ctx),\n ),\n )\n .limit(1);\n return row ?? null;\n}\n\nexport async function applyWorkspaceResourceCreate(\n input: WorkspaceResourceInput,\n actor = currentOwnerEmail(),\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const db = getDb();\n const timestamp = now();\n const resourceId = id();\n\n await db.insert(schema.workspaceResources).values({\n id: resourceId,\n ownerEmail: ctx.ownerEmail,\n orgId: ctx.orgId,\n kind: input.kind,\n name: input.name,\n description: input.description || null,\n path: input.path,\n content: input.content,\n scope: input.scope,\n createdBy: actor,\n createdAt: timestamp,\n updatedAt: timestamp,\n });\n\n await recordAudit({\n action: `workspace.${input.kind}.created`,\n targetType: `workspace-${input.kind}`,\n targetId: resourceId,\n summary: `Created workspace ${input.kind} \"${input.name}\" (${input.path})`,\n actor,\n ownerEmail: ctx.ownerEmail,\n orgId: ctx.orgId,\n });\n\n const created = await getWorkspaceResource(resourceId, ctx);\n if (created) await materializeGlobalResource(created);\n return created;\n}\n\nexport async function createWorkspaceResource(input: WorkspaceResourceInput) {\n if (\n await shouldRequestAllAppResourceApproval({\n beforeScope: null,\n afterScope: input.scope,\n })\n ) {\n return createApprovalRequest({\n changeType: \"workspace-resource.create\",\n targetType: `workspace-${input.kind}`,\n targetId: null,\n summary: `Create All-app workspace ${input.kind} \"${input.name}\"`,\n payload: { input },\n beforeValue: null,\n afterValue: input,\n });\n }\n return applyWorkspaceResourceCreate(input);\n}\n\nexport async function applyWorkspaceResourceUpdate(\n resourceId: string,\n input: Partial<\n Pick<WorkspaceResourceInput, \"name\" | \"description\" | \"content\" | \"scope\">\n >,\n actor = currentOwnerEmail(),\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const db = getDb();\n const existing = await getWorkspaceResource(resourceId, ctx);\n if (!existing) throw new Error(\"Workspace resource not found\");\n\n const updates: Record<string, unknown> = { updatedAt: now() };\n if (input.name !== undefined) updates.name = input.name;\n if (input.description !== undefined)\n updates.description = input.description || null;\n if (input.content !== undefined) updates.content = input.content;\n if (input.scope !== undefined) updates.scope = input.scope;\n\n await db\n .update(schema.workspaceResources)\n .set(updates)\n .where(\n and(\n eq(schema.workspaceResources.id, resourceId),\n ctxScope(schema.workspaceResources, ctx),\n ),\n );\n\n await recordAudit({\n action: `workspace.${existing.kind}.updated`,\n targetType: `workspace-${existing.kind}`,\n targetId: resourceId,\n summary: `Updated workspace ${existing.kind} \"${input.name || existing.name}\"`,\n actor,\n ownerEmail: ctx.ownerEmail,\n orgId: ctx.orgId,\n });\n\n const updated = await getWorkspaceResource(resourceId, ctx);\n if (updated) await materializeGlobalResource(updated);\n return updated;\n}\n\nexport async function updateWorkspaceResource(\n resourceId: string,\n input: Partial<\n Pick<WorkspaceResourceInput, \"name\" | \"description\" | \"content\" | \"scope\">\n >,\n) {\n const ctx = requireWorkspaceResourceCtx();\n const existing = await getWorkspaceResource(resourceId, ctx);\n if (!existing) throw new Error(\"Workspace resource not found\");\n const after = mergedWorkspaceResourceAfter(existing, input);\n if (\n await shouldRequestAllAppResourceApproval({\n beforeScope: existing.scope,\n afterScope: after.scope,\n })\n ) {\n return createApprovalRequest({\n changeType: \"workspace-resource.update\",\n targetType: `workspace-${existing.kind}`,\n targetId: resourceId,\n summary: `Update All-app workspace ${existing.kind} \"${after.name}\"`,\n payload: { id: resourceId, input },\n beforeValue: existing,\n afterValue: after,\n });\n }\n return applyWorkspaceResourceUpdate(resourceId, input);\n}\n\nexport async function applyWorkspaceResourceDelete(\n resourceId: string,\n actor = currentOwnerEmail(),\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const db = getDb();\n const existing = await getWorkspaceResource(resourceId, ctx);\n if (!existing) throw new Error(\"Workspace resource not found\");\n\n // Revoke all grants\n const grants = await listResourceGrants({ resourceId });\n for (const grant of grants) {\n if (grant.status === \"active\") {\n await revokeResourceGrant(grant.id);\n }\n }\n\n await removeMaterializedGlobalResource(existing);\n\n await db\n .delete(schema.workspaceResources)\n .where(\n and(\n eq(schema.workspaceResources.id, resourceId),\n ctxScope(schema.workspaceResources, ctx),\n ),\n );\n\n await recordAudit({\n action: `workspace.${existing.kind}.deleted`,\n targetType: `workspace-${existing.kind}`,\n targetId: resourceId,\n summary: `Deleted workspace ${existing.kind} \"${existing.name}\" (${existing.path})`,\n actor,\n ownerEmail: ctx.ownerEmail,\n orgId: ctx.orgId,\n });\n\n return existing;\n}\n\nexport async function deleteWorkspaceResource(resourceId: string) {\n const ctx = requireWorkspaceResourceCtx();\n const existing = await getWorkspaceResource(resourceId, ctx);\n if (!existing) throw new Error(\"Workspace resource not found\");\n if (\n await shouldRequestAllAppResourceApproval({\n beforeScope: existing.scope,\n afterScope: null,\n })\n ) {\n return createApprovalRequest({\n changeType: \"workspace-resource.delete\",\n targetType: `workspace-${existing.kind}`,\n targetId: resourceId,\n summary: `Delete All-app workspace ${existing.kind} \"${existing.name}\"`,\n payload: { id: resourceId },\n beforeValue: existing,\n afterValue: null,\n });\n }\n return applyWorkspaceResourceDelete(resourceId);\n}\n\n// ─── Grants ──────────────────────────────────────────────────────\n\nexport async function listResourceGrants(filter?: {\n resourceId?: string;\n appId?: string;\n}) {\n const db = getDb();\n const conditions = [orgFilter(schema.workspaceResourceGrants)];\n if (filter?.resourceId) {\n conditions.push(\n eq(schema.workspaceResourceGrants.resourceId, filter.resourceId) as any,\n );\n }\n if (filter?.appId) {\n conditions.push(\n eq(schema.workspaceResourceGrants.appId, filter.appId) as any,\n );\n }\n return db\n .select()\n .from(schema.workspaceResourceGrants)\n .where(and(...conditions))\n .orderBy(desc(schema.workspaceResourceGrants.updatedAt));\n}\n\nexport async function getResourceGrant(\n grantId: string,\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const db = getDb();\n const [row] = await db\n .select()\n .from(schema.workspaceResourceGrants)\n .where(\n and(\n eq(schema.workspaceResourceGrants.id, grantId),\n ctxScope(schema.workspaceResourceGrants, ctx),\n ),\n )\n .limit(1);\n return row ?? null;\n}\n\nexport async function createResourceGrant(resourceId: string, appId: string) {\n const db = getDb();\n const ctx = requireWorkspaceResourceCtx();\n const resource = await getWorkspaceResource(resourceId, ctx);\n if (!resource) throw new Error(\"Workspace resource not found\");\n\n const activeExisting = (await listResourceGrants({ resourceId, appId })).find(\n (grant) => grant.status === \"active\",\n );\n if (activeExisting) {\n return activeExisting;\n }\n\n const timestamp = now();\n const grantId = id();\n const actor = currentOwnerEmail();\n\n await db.insert(schema.workspaceResourceGrants).values({\n id: grantId,\n ownerEmail: actor,\n orgId: currentOrgId(),\n resourceId,\n appId,\n status: \"active\",\n syncedAt: null,\n createdAt: timestamp,\n updatedAt: timestamp,\n });\n\n await recordAudit({\n action: `workspace.${resource.kind}.granted`,\n targetType: `workspace-${resource.kind}-grant`,\n targetId: grantId,\n summary: `Granted workspace ${resource.kind} \"${resource.name}\" to ${appId}`,\n });\n\n return getResourceGrant(grantId);\n}\n\nexport async function grantWorkspaceResourcesToApp(input: {\n appId: string;\n resourceIds: string[];\n}) {\n const uniqueResourceIds = [...new Set(input.resourceIds.filter(Boolean))];\n if (uniqueResourceIds.length === 0) {\n return { appId: input.appId, granted: [], skipped: [] };\n }\n\n const granted: Array<{ id: string; resourceId: string; appId: string }> = [];\n const skipped: Array<{ resourceId: string; reason: string }> = [];\n\n for (const resourceId of uniqueResourceIds) {\n const resource = await getWorkspaceResource(resourceId).catch(() => null);\n if (!resource) {\n skipped.push({ resourceId, reason: \"not-found\" });\n continue;\n }\n if (resource.scope === \"all\") {\n skipped.push({ resourceId, reason: \"already-all-apps\" });\n continue;\n }\n\n const grant = await createResourceGrant(resourceId, input.appId);\n if (grant) {\n granted.push({\n id: grant.id,\n resourceId: grant.resourceId,\n appId: grant.appId,\n });\n }\n }\n\n return { appId: input.appId, granted, skipped };\n}\n\nexport async function revokeResourceGrant(\n grantId: string,\n ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),\n) {\n const db = getDb();\n const grant = await getResourceGrant(grantId, ctx);\n if (!grant) throw new Error(\"Grant not found\");\n\n const resource = await getWorkspaceResource(grant.resourceId);\n\n await db\n .update(schema.workspaceResourceGrants)\n .set({ status: \"revoked\", updatedAt: now() })\n .where(\n and(\n eq(schema.workspaceResourceGrants.id, grantId),\n ctxScope(schema.workspaceResourceGrants, ctx),\n ),\n );\n\n await recordAudit({\n action: `workspace.${resource?.kind || \"resource\"}.grant-revoked`,\n targetType: \"workspace-resource-grant\",\n targetId: grantId,\n summary: `Revoked workspace ${resource?.kind || \"resource\"} \"${resource?.name || grant.resourceId}\" from ${grant.appId}`,\n });\n\n return getResourceGrant(grantId, ctx);\n}\n\n// ─── Overview ──────────────────────────────────────────────────────\n\nexport async function listWorkspaceResourcesOverview() {\n const [resources, grants] = await Promise.all([\n listWorkspaceResources(),\n listResourceGrants(),\n ]);\n\n const skills = resources.filter((r) => r.kind === \"skill\");\n const instructions = resources.filter((r) => r.kind === \"instruction\");\n const agents = resources.filter((r) => r.kind === \"agent\");\n const knowledge = resources.filter((r) => r.kind === \"knowledge\");\n const activeGrants = grants.filter((g) => g.status === \"active\");\n\n return {\n skillCount: skills.length,\n instructionCount: instructions.length,\n agentCount: agents.length,\n knowledgeCount: knowledge.length,\n totalResources: resources.length,\n activeGrantCount: activeGrants.length,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-chat.d.ts","sourceRoot":"","sources":["../../../src/server/plugins/agent-chat.ts"],"names":[],"mappings":";AAIA,
|
|
1
|
+
{"version":3,"file":"agent-chat.d.ts","sourceRoot":"","sources":["../../../src/server/plugins/agent-chat.ts"],"names":[],"mappings":";AAIA,wBAkCG"}
|
|
@@ -26,8 +26,9 @@ Use the standard workspace primitives:
|
|
|
26
26
|
- Read and update resources like AGENTS.md, LEARNINGS.md, jobs/*.md, agents/*.md, and remote-agents/*.json when appropriate.
|
|
27
27
|
- Use recurring jobs for scheduled behavior.
|
|
28
28
|
- Use custom agent profiles in agents/*.md for local spawned work and remote-agents/*.json for remote A2A apps.
|
|
29
|
+
- You receive a compact available-apps block with sibling workspace app names and descriptions. Use it to pick the right A2A target, and call list-connected-agents or tool-search only when you need fresh details.
|
|
29
30
|
- When answering whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. If you have not requested that probe, absence of agent-card fields means unchecked, not unavailable.
|
|
30
|
-
- When creating a new workspace app, create a separate app under apps/<app-id> with apps/<app-id>/package.json, mount it at /<app-id>, use relative /<app-id> links, never hardcode localhost or dev ports, use shadcn/ui with @tabler/icons-react rather than lucide-react, and ensure the React Router client entry preserves APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath(). There is no separate workspace app registry to edit.
|
|
31
|
+
- When creating a new workspace app, create a separate app under apps/<app-id> with apps/<app-id>/package.json including a concise generated description, mount it at /<app-id>, use relative /<app-id> links, never hardcode localhost or dev ports, use shadcn/ui with @tabler/icons-react rather than lucide-react, and ensure the React Router client entry preserves APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath(). There is no separate workspace app registry to edit.
|
|
31
32
|
- Treat first-party apps such as Mail, Calendar, Analytics, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.
|
|
32
33
|
|
|
33
34
|
When a user asks for something like a digest, reminder, routing rule, or saved behavior:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../../src/server/plugins/agent-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,eAAe,qBAAqB,CAAC;IACnC,KAAK,EAAE,UAAU;IACjB,0EAA0E;IAC1E,2EAA2E;IAC3E,2EAA2E;IAC3E,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC5B,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,KAAK,CAAC,CAAC;QACvC,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;IACD,2EAA2E;IAC3E,2EAA2E;IAC3E,wEAAwE;IACxE,OAAO,EAAE,eAAe;IACxB,YAAY,EAAE
|
|
1
|
+
{"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../../src/server/plugins/agent-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,eAAe,qBAAqB,CAAC;IACnC,KAAK,EAAE,UAAU;IACjB,0EAA0E;IAC1E,2EAA2E;IAC3E,2EAA2E;IAC3E,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC5B,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,KAAK,CAAC,CAAC;QACvC,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;IACD,2EAA2E;IAC3E,2EAA2E;IAC3E,wEAAwE;IACxE,OAAO,EAAE,eAAe;IACxB,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;4EAoB4D;CAC3E,CAAC,CAAC","sourcesContent":["import { createAgentChatPlugin } from \"@agent-native/core/server\";\nimport { getOrgContext } from \"@agent-native/core/org\";\nimport { dispatchActions } from \"../../actions/index.js\";\n\nexport default createAgentChatPlugin({\n appId: \"dispatch\",\n // Without this, AGENT_ORG_ID is never set on agent action calls and every\n // row written through the frontend (vault secrets, destinations, workspace\n // resources) lands with org_id=NULL — breaking data isolation across orgs.\n resolveOrgId: async (event) => {\n const ctx = await getOrgContext(event);\n return ctx.orgId;\n },\n // Read actions directly from the package's own action map rather than from\n // a build-time-generated `.generated/actions-registry.ts` (the latter is a\n // template-only construct that the Vite plugin emits next to actions/).\n actions: dispatchActions,\n systemPrompt: `You are the central dispatch for this workspace.\n\nDefault posture:\n- Treat Slack and Telegram as shared entrypoints into the workspace.\n- Heavily delegate domain work to specialized agents through A2A when another app owns the job.\n- Keep durable memory and operating instructions in resources rather than ephemeral chat.\n- Prefer replying in the current external thread unless the user explicitly asks you to send to a saved destination.\n\nUse the standard workspace primitives:\n- Read and update resources like AGENTS.md, LEARNINGS.md, jobs/*.md, agents/*.md, and remote-agents/*.json when appropriate.\n- Use recurring jobs for scheduled behavior.\n- Use custom agent profiles in agents/*.md for local spawned work and remote-agents/*.json for remote A2A apps.\n- You receive a compact available-apps block with sibling workspace app names and descriptions. Use it to pick the right A2A target, and call list-connected-agents or tool-search only when you need fresh details.\n- When answering whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. If you have not requested that probe, absence of agent-card fields means unchecked, not unavailable.\n- When creating a new workspace app, create a separate app under apps/<app-id> with apps/<app-id>/package.json including a concise generated description, mount it at /<app-id>, use relative /<app-id> links, never hardcode localhost or dev ports, use shadcn/ui with @tabler/icons-react rather than lucide-react, and ensure the React Router client entry preserves APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath(). There is no separate workspace app registry to edit.\n- Treat first-party apps such as Mail, Calendar, Analytics, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.\n\nWhen a user asks for something like a digest, reminder, routing rule, or saved behavior:\n- First decide whether it should be a resource, a recurring job, a destination, or a delegated task.\n- Keep responses concise and operational.\n- Avoid inventing integrations or destinations that are not configured yet.`,\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-routes.d.ts","sourceRoot":"","sources":["../../../src/server/plugins/core-routes.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"core-routes.d.ts","sourceRoot":"","sources":["../../../src/server/plugins/core-routes.ts"],"names":[],"mappings":";AAQA,wBAEG"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createCoreRoutesPlugin } from "@agent-native/core/server";
|
|
2
2
|
import { envKeys } from "../lib/env-config.js";
|
|
3
|
+
import { registerDispatchOnboardingSteps } from "../lib/onboarding-steps.js";
|
|
4
|
+
// Register before the core plugin so "create your first app" (order 5) appears
|
|
5
|
+
// above the auto-generated Slack/Telegram steps (order 60). Idempotent.
|
|
6
|
+
registerDispatchOnboardingSteps();
|
|
3
7
|
export default createCoreRoutesPlugin({
|
|
4
8
|
envKeys,
|
|
5
9
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-routes.js","sourceRoot":"","sources":["../../../src/server/plugins/core-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"core-routes.js","sourceRoot":"","sources":["../../../src/server/plugins/core-routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAE7E,+EAA+E;AAC/E,wEAAwE;AACxE,+BAA+B,EAAE,CAAC;AAElC,eAAe,sBAAsB,CAAC;IACpC,OAAO;CACR,CAAC,CAAC","sourcesContent":["import { createCoreRoutesPlugin } from \"@agent-native/core/server\";\nimport { envKeys } from \"../lib/env-config.js\";\nimport { registerDispatchOnboardingSteps } from \"../lib/onboarding-steps.js\";\n\n// Register before the core plugin so \"create your first app\" (order 5) appears\n// above the auto-generated Slack/Telegram steps (order 60). Idempotent.\nregisterDispatchOnboardingSteps();\n\nexport default createCoreRoutesPlugin({\n envKeys,\n});\n"]}
|
|
@@ -7,7 +7,7 @@ const DISPATCH_INTEGRATION_SYSTEM_PROMPT = `You are the central dispatch for thi
|
|
|
7
7
|
Default posture:
|
|
8
8
|
- Treat Slack, Telegram, and email as shared entrypoints into the workspace.
|
|
9
9
|
- Heavily delegate domain work to specialized agents through A2A (call-agent) when another app owns the job. Apps you can delegate to include slides (decks/presentations), analytics (data/dashboards), content (docs/articles), videos (Remotion compositions), forms (form builder), clips (screen recordings), design (visual designs), and images (brand image libraries and generated raster imagery).
|
|
10
|
-
- Use list-connected-agents to see what agents are available before assuming a request must be handled locally.
|
|
10
|
+
- Use the available-apps prompt context first, then list-connected-agents when you need fresh details, to see what agents are available before assuming a request must be handled locally.
|
|
11
11
|
- When asked whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. Without that probe, missing agent-card fields mean unchecked, not unavailable.
|
|
12
12
|
- Treat first-party apps such as Mail, Calendar, Analytics, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.
|
|
13
13
|
- Keep durable memory and operating instructions in resources rather than ephemeral chat.
|
|
@@ -19,7 +19,7 @@ When a user asks for something:
|
|
|
19
19
|
- Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.
|
|
20
20
|
- If the user asks to create, build, make, scaffold, or generate an "agent" from Dispatch chat or by tagging @agent-native in Slack, email, or Telegram, first classify the ask. If it is a simple Dispatch-native behavior like a reminder, digest, monitor, routing rule, saved instruction, or recurring workflow, create or update the recurring job/resource/destination in Dispatch. If it is a robust unique product or teammate that needs its own UI, data model, actions, integrations, or domain workflow, treat it as a new workspace app and call start-workspace-app-creation.
|
|
21
21
|
- If a new-app prompt asks for access to Mail, Calendar, Analytics, or similar first-party app data/agents, keep using the existing hosted/connected app and A2A path. Do not ask Builder to scaffold those apps as children of the new app unless the user explicitly asks for a customized fork/copy.
|
|
22
|
-
- If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/starter or another existing app unless the user explicitly asks to modify that existing app. If the request is too vague to classify, ask one concise follow-up. If the action returns mode "builder", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and preserving APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath() in the React Router client entry. The new app lives at the workspace root /<app-id>, NOT under /dispatch/<app-id>, /apps/<app-id>, or any other Dispatch tab — when telling the user where to find it, link to /<app-id> only. There is no separate workspace app registry to edit. If it returns mode "local-agent", tell the user it is ready for the local code agent and include the returned app path/prompt summary. If it returns mode "coming-soon" or "builder-unavailable", explain the missing Builder setup and ask them to connect/configure Builder.
|
|
22
|
+
- If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt and include a concise generated description when possible. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/starter or another existing app unless the user explicitly asks to modify that existing app. If the request is too vague to classify, ask one concise follow-up. If the action returns mode "builder", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists with name/displayName and description so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and preserving APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath() in the React Router client entry. The new app lives at the workspace root /<app-id>, NOT under /dispatch/<app-id>, /apps/<app-id>, or any other Dispatch tab — when telling the user where to find it, link to /<app-id> only. There is no separate workspace app registry to edit. If it returns mode "local-agent", tell the user it is ready for the local code agent and include the returned app path/prompt summary. If it returns mode "coming-soon" or "builder-unavailable", explain the missing Builder setup and ask them to connect/configure Builder.
|
|
23
23
|
- For digests, reminders, or saved behavior, prefer recurring jobs, resources, or destinations over chat replies.
|
|
24
24
|
- Keep responses concise and operational — messaging platforms have character limits.
|
|
25
25
|
- Use markdown sparingly (bold and lists are fine, avoid complex formatting).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../src/server/plugins/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,kCAAkC,GAAG;;;;;;;;;;;;;;;;;;;;;4FAqBiD,CAAC;AAE7F;;;;GAIG;AACH,MAAM,0BAA0B,GAAG,KAAK,EAAE,QAAa,EAAE,EAAE;IACzD,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAClD,MAAM,cAAc,GAAG,YAAY,CAAC,YAAY,CAAC;IACjD,MAAM,YAAY,GAChB,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,OAAO,cAAc,KAAK,UAAU;YACpC,CAAC,CAAC,cAAc,CAAC,kCAAkC,CAAC;YACpD,CAAC,CAAC,kCAAkC,CAAC;IAE3C,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,KAAK,EAAE,UAAU;QACjB,OAAO,EAAE,eAAe;QACxB,YAAY,EAAE,oBAAoB;QAClC,aAAa,EAAE,qBAAqB;QACpC,YAAY;QACZ,wDAAwD;QACxD,yEAAyE;QACzE,+DAA+D;QAC/D,6EAA6E;KAC9E,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,0BAA0B,CAAC","sourcesContent":["import { createIntegrationsPlugin } from \"@agent-native/core/server\";\nimport {\n beforeDispatchProcess,\n resolveDispatchOwner,\n} from \"../lib/dispatch-integrations.js\";\nimport { getDispatchConfig } from \"../index.js\";\nimport { dispatchActions } from \"../../actions/index.js\";\n\nconst DISPATCH_INTEGRATION_SYSTEM_PROMPT = `You are the central dispatch for this workspace, responding via a messaging platform integration (Slack, Telegram, email, etc.).\n\nDefault posture:\n- Treat Slack, Telegram, and email as shared entrypoints into the workspace.\n- Heavily delegate domain work to specialized agents through A2A (call-agent) when another app owns the job. Apps you can delegate to include slides (decks/presentations), analytics (data/dashboards), content (docs/articles), videos (Remotion compositions), forms (form builder), clips (screen recordings), design (visual designs), and images (brand image libraries and generated raster imagery).\n- Use list-connected-agents to see what agents are available before assuming a request must be handled locally.\n- When asked whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. Without that probe, missing agent-card fields mean unchecked, not unavailable.\n- Treat first-party apps such as Mail, Calendar, Analytics, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.\n- Keep durable memory and operating instructions in resources rather than ephemeral chat.\n- Reply in the originating thread unless the user explicitly asks you to send to a saved destination.\n\nWhen a user asks for something:\n- If it belongs to analytics, content, slides, videos, images, etc., delegate via call-agent — do not re-implement the domain logic in dispatch.\n- After call-agent returns an answer, RELAY IT DIRECTLY to the user with at most a one-line preface — do not rephrase, summarize, or add commentary. The downstream agent already crafted the answer; your job is delivery, not editing. This minimizes round-trips and keeps the user-visible reply fast.\n- Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.\n- If the user asks to create, build, make, scaffold, or generate an \"agent\" from Dispatch chat or by tagging @agent-native in Slack, email, or Telegram, first classify the ask. If it is a simple Dispatch-native behavior like a reminder, digest, monitor, routing rule, saved instruction, or recurring workflow, create or update the recurring job/resource/destination in Dispatch. If it is a robust unique product or teammate that needs its own UI, data model, actions, integrations, or domain workflow, treat it as a new workspace app and call start-workspace-app-creation.\n- If a new-app prompt asks for access to Mail, Calendar, Analytics, or similar first-party app data/agents, keep using the existing hosted/connected app and A2A path. Do not ask Builder to scaffold those apps as children of the new app unless the user explicitly asks for a customized fork/copy.\n- If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/starter or another existing app unless the user explicitly asks to modify that existing app. If the request is too vague to classify, ask one concise follow-up. If the action returns mode \"builder\", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and preserving APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath() in the React Router client entry. The new app lives at the workspace root /<app-id>, NOT under /dispatch/<app-id>, /apps/<app-id>, or any other Dispatch tab — when telling the user where to find it, link to /<app-id> only. There is no separate workspace app registry to edit. If it returns mode \"local-agent\", tell the user it is ready for the local code agent and include the returned app path/prompt summary. If it returns mode \"coming-soon\" or \"builder-unavailable\", explain the missing Builder setup and ask them to connect/configure Builder.\n- For digests, reminders, or saved behavior, prefer recurring jobs, resources, or destinations over chat replies.\n- Keep responses concise and operational — messaging platforms have character limits.\n- Use markdown sparingly (bold and lists are fine, avoid complex formatting).\n- If a task requires many steps, summarize what you did rather than streaming every detail.`;\n\n/**\n * Defer plugin construction until the Nitro plugin actually fires so the\n * config-aware system prompt resolves AFTER `setupDispatch(config)` has\n * stamped the active config (plugin module load order is not guaranteed).\n */\nconst dispatchIntegrationsPlugin = async (nitroApp: any) => {\n const { integrations = {} } = getDispatchConfig();\n const promptOverride = integrations.systemPrompt;\n const systemPrompt =\n typeof promptOverride === \"string\"\n ? promptOverride\n : typeof promptOverride === \"function\"\n ? promptOverride(DISPATCH_INTEGRATION_SYSTEM_PROMPT)\n : DISPATCH_INTEGRATION_SYSTEM_PROMPT;\n\n const plugin = createIntegrationsPlugin({\n appId: \"dispatch\",\n actions: dispatchActions,\n resolveOwner: resolveDispatchOwner,\n beforeProcess: beforeDispatchProcess,\n systemPrompt,\n // Inherit the framework default (claude-sonnet-4-6 from\n // packages/core/src/integrations/plugin.ts). Haiku was tried for latency\n // but hallucinated URLs/IDs after delegated call-agent results\n // (e.g. inventing `https://slides.workspace.com/deck/builder-io-deck-2024`).\n });\n\n return plugin(nitroApp);\n};\n\nexport default dispatchIntegrationsPlugin;\n"]}
|
|
1
|
+
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../../src/server/plugins/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,kCAAkC,GAAG;;;;;;;;;;;;;;;;;;;;;4FAqBiD,CAAC;AAE7F;;;;GAIG;AACH,MAAM,0BAA0B,GAAG,KAAK,EAAE,QAAa,EAAE,EAAE;IACzD,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAClD,MAAM,cAAc,GAAG,YAAY,CAAC,YAAY,CAAC;IACjD,MAAM,YAAY,GAChB,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,OAAO,cAAc,KAAK,UAAU;YACpC,CAAC,CAAC,cAAc,CAAC,kCAAkC,CAAC;YACpD,CAAC,CAAC,kCAAkC,CAAC;IAE3C,MAAM,MAAM,GAAG,wBAAwB,CAAC;QACtC,KAAK,EAAE,UAAU;QACjB,OAAO,EAAE,eAAe;QACxB,YAAY,EAAE,oBAAoB;QAClC,aAAa,EAAE,qBAAqB;QACpC,YAAY;QACZ,wDAAwD;QACxD,yEAAyE;QACzE,+DAA+D;QAC/D,6EAA6E;KAC9E,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,0BAA0B,CAAC","sourcesContent":["import { createIntegrationsPlugin } from \"@agent-native/core/server\";\nimport {\n beforeDispatchProcess,\n resolveDispatchOwner,\n} from \"../lib/dispatch-integrations.js\";\nimport { getDispatchConfig } from \"../index.js\";\nimport { dispatchActions } from \"../../actions/index.js\";\n\nconst DISPATCH_INTEGRATION_SYSTEM_PROMPT = `You are the central dispatch for this workspace, responding via a messaging platform integration (Slack, Telegram, email, etc.).\n\nDefault posture:\n- Treat Slack, Telegram, and email as shared entrypoints into the workspace.\n- Heavily delegate domain work to specialized agents through A2A (call-agent) when another app owns the job. Apps you can delegate to include slides (decks/presentations), analytics (data/dashboards), content (docs/articles), videos (Remotion compositions), forms (form builder), clips (screen recordings), design (visual designs), and images (brand image libraries and generated raster imagery).\n- Use the available-apps prompt context first, then list-connected-agents when you need fresh details, to see what agents are available before assuming a request must be handled locally.\n- When asked whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. Without that probe, missing agent-card fields mean unchecked, not unavailable.\n- Treat first-party apps such as Mail, Calendar, Analytics, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.\n- Keep durable memory and operating instructions in resources rather than ephemeral chat.\n- Reply in the originating thread unless the user explicitly asks you to send to a saved destination.\n\nWhen a user asks for something:\n- If it belongs to analytics, content, slides, videos, images, etc., delegate via call-agent — do not re-implement the domain logic in dispatch.\n- After call-agent returns an answer, RELAY IT DIRECTLY to the user with at most a one-line preface — do not rephrase, summarize, or add commentary. The downstream agent already crafted the answer; your job is delivery, not editing. This minimizes round-trips and keeps the user-visible reply fast.\n- Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.\n- If the user asks to create, build, make, scaffold, or generate an \"agent\" from Dispatch chat or by tagging @agent-native in Slack, email, or Telegram, first classify the ask. If it is a simple Dispatch-native behavior like a reminder, digest, monitor, routing rule, saved instruction, or recurring workflow, create or update the recurring job/resource/destination in Dispatch. If it is a robust unique product or teammate that needs its own UI, data model, actions, integrations, or domain workflow, treat it as a new workspace app and call start-workspace-app-creation.\n- If a new-app prompt asks for access to Mail, Calendar, Analytics, or similar first-party app data/agents, keep using the existing hosted/connected app and A2A path. Do not ask Builder to scaffold those apps as children of the new app unless the user explicitly asks for a customized fork/copy.\n- If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt and include a concise generated description when possible. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/starter or another existing app unless the user explicitly asks to modify that existing app. If the request is too vague to classify, ask one concise follow-up. If the action returns mode \"builder\", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists with name/displayName and description so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and preserving APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath() in the React Router client entry. The new app lives at the workspace root /<app-id>, NOT under /dispatch/<app-id>, /apps/<app-id>, or any other Dispatch tab — when telling the user where to find it, link to /<app-id> only. There is no separate workspace app registry to edit. If it returns mode \"local-agent\", tell the user it is ready for the local code agent and include the returned app path/prompt summary. If it returns mode \"coming-soon\" or \"builder-unavailable\", explain the missing Builder setup and ask them to connect/configure Builder.\n- For digests, reminders, or saved behavior, prefer recurring jobs, resources, or destinations over chat replies.\n- Keep responses concise and operational — messaging platforms have character limits.\n- Use markdown sparingly (bold and lists are fine, avoid complex formatting).\n- If a task requires many steps, summarize what you did rather than streaming every detail.`;\n\n/**\n * Defer plugin construction until the Nitro plugin actually fires so the\n * config-aware system prompt resolves AFTER `setupDispatch(config)` has\n * stamped the active config (plugin module load order is not guaranteed).\n */\nconst dispatchIntegrationsPlugin = async (nitroApp: any) => {\n const { integrations = {} } = getDispatchConfig();\n const promptOverride = integrations.systemPrompt;\n const systemPrompt =\n typeof promptOverride === \"string\"\n ? promptOverride\n : typeof promptOverride === \"function\"\n ? promptOverride(DISPATCH_INTEGRATION_SYSTEM_PROMPT)\n : DISPATCH_INTEGRATION_SYSTEM_PROMPT;\n\n const plugin = createIntegrationsPlugin({\n appId: \"dispatch\",\n actions: dispatchActions,\n resolveOwner: resolveDispatchOwner,\n beforeProcess: beforeDispatchProcess,\n systemPrompt,\n // Inherit the framework default (claude-sonnet-4-6 from\n // packages/core/src/integrations/plugin.ts). Haiku was tried for latency\n // but hallucinated URLs/IDs after delegated call-agent results\n // (e.g. inventing `https://slides.workspace.com/deck/builder-io-deck-2024`).\n });\n\n return plugin(nitroApp);\n};\n\nexport default dispatchIntegrationsPlugin;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/dispatch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dispatch — workspace control plane for agent-native apps. Vault, integrations, destinations, scheduled jobs, and cross-app delegation, shipped as a single drop-in package.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,12 +25,21 @@
|
|
|
25
25
|
"./actions": "./dist/actions/index.js",
|
|
26
26
|
"./db": "./dist/db/index.js",
|
|
27
27
|
"./components": "./dist/components/index.js",
|
|
28
|
+
"./components/ui/*": "./dist/components/ui/*.js",
|
|
28
29
|
"./styles/dispatch.css": "./src/styles/dispatch.css"
|
|
29
30
|
},
|
|
30
31
|
"files": [
|
|
31
32
|
"dist",
|
|
32
33
|
"src"
|
|
33
34
|
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc && tsc-alias --resolve-full-paths",
|
|
37
|
+
"dev": "tsc --watch & tsc-alias --watch --resolve-full-paths",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"test": "vitest --run src --passWithNoTests",
|
|
40
|
+
"prepack": "npm run build && cp ../../README.md ./README.md",
|
|
41
|
+
"prepublishOnly": "npm run build"
|
|
42
|
+
},
|
|
34
43
|
"peerDependencies": {
|
|
35
44
|
"@agent-native/core": ">=0.8.0",
|
|
36
45
|
"react": ">=18",
|
|
@@ -38,6 +47,7 @@
|
|
|
38
47
|
"react-router": ">=7"
|
|
39
48
|
},
|
|
40
49
|
"dependencies": {
|
|
50
|
+
"@libsql/client": "^0.15.8",
|
|
41
51
|
"@radix-ui/react-accordion": "^1.2.12",
|
|
42
52
|
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
43
53
|
"@radix-ui/react-aspect-ratio": "^1.1.8",
|
|
@@ -85,6 +95,7 @@
|
|
|
85
95
|
"zod": "^4.3.6"
|
|
86
96
|
},
|
|
87
97
|
"devDependencies": {
|
|
98
|
+
"@agent-native/core": "workspace:*",
|
|
88
99
|
"@react-router/dev": "^7.13.1",
|
|
89
100
|
"@types/node": "^24.2.1",
|
|
90
101
|
"@types/react": "^19.2.14",
|
|
@@ -94,14 +105,7 @@
|
|
|
94
105
|
"react-router": "^7.13.1",
|
|
95
106
|
"tsc-alias": "^1.8.10",
|
|
96
107
|
"typescript": "^6.0.3",
|
|
97
|
-
"vite": "
|
|
98
|
-
"vitest": "^4.1.5"
|
|
99
|
-
"@agent-native/core": "0.14.2"
|
|
100
|
-
},
|
|
101
|
-
"scripts": {
|
|
102
|
-
"build": "tsc && tsc-alias --resolve-full-paths",
|
|
103
|
-
"dev": "tsc --watch & tsc-alias --watch --resolve-full-paths",
|
|
104
|
-
"typecheck": "tsc --noEmit",
|
|
105
|
-
"test": "vitest --run src --passWithNoTests"
|
|
108
|
+
"vite": "catalog:",
|
|
109
|
+
"vitest": "^4.1.5"
|
|
106
110
|
}
|
|
107
|
-
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineAction } from "@agent-native/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { applyDreamProposal } from "../server/lib/dreams-store.js";
|
|
4
|
+
|
|
5
|
+
export default defineAction({
|
|
6
|
+
description:
|
|
7
|
+
"Apply one pending Dispatch dream proposal. Personal memory applies directly; shared LEARNINGS.md and workspace resource proposals queue an approval request when approval policy is enabled.",
|
|
8
|
+
schema: z.object({
|
|
9
|
+
id: z.string().min(1).describe("Dream proposal id."),
|
|
10
|
+
}),
|
|
11
|
+
run: async ({ id }) => applyDreamProposal(id),
|
|
12
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { defineAction } from "@agent-native/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { createDreamReport } from "../server/lib/dreams-store.js";
|
|
4
|
+
|
|
5
|
+
export default defineAction({
|
|
6
|
+
description:
|
|
7
|
+
"Create a Dispatch dream report from existing thread-debug records and produce pending, evidence-backed memory proposals without calling an LLM.",
|
|
8
|
+
schema: z.object({
|
|
9
|
+
sourceId: z
|
|
10
|
+
.string()
|
|
11
|
+
.default("current")
|
|
12
|
+
.describe(
|
|
13
|
+
"Thread debug source id from list-agent-thread-sources. Use 'all' to scan every connected source.",
|
|
14
|
+
),
|
|
15
|
+
sourceIds: z
|
|
16
|
+
.array(z.string().min(1))
|
|
17
|
+
.optional()
|
|
18
|
+
.describe(
|
|
19
|
+
"Optional explicit source ids to scan together. When provided, sourceId is treated as aggregate.",
|
|
20
|
+
),
|
|
21
|
+
allSources: z.coerce
|
|
22
|
+
.boolean()
|
|
23
|
+
.default(false)
|
|
24
|
+
.describe(
|
|
25
|
+
"Scan every connected thread-debug source with partial results.",
|
|
26
|
+
),
|
|
27
|
+
query: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Optional search term to focus dream candidate discovery."),
|
|
31
|
+
ownerEmail: z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe(
|
|
35
|
+
"Optional owner email filter. Admins may pass '*' or omit to use their admin-visible scope.",
|
|
36
|
+
),
|
|
37
|
+
limit: z.coerce.number().int().min(1).max(50).default(20),
|
|
38
|
+
sourceTimeoutMs: z.coerce
|
|
39
|
+
.number()
|
|
40
|
+
.int()
|
|
41
|
+
.min(1000)
|
|
42
|
+
.max(60000)
|
|
43
|
+
.default(15000)
|
|
44
|
+
.describe("Per-source timeout in milliseconds for partial scans."),
|
|
45
|
+
sourceConcurrency: z.coerce
|
|
46
|
+
.number()
|
|
47
|
+
.int()
|
|
48
|
+
.min(1)
|
|
49
|
+
.max(8)
|
|
50
|
+
.default(2)
|
|
51
|
+
.describe("How many thread-debug sources to scan at once."),
|
|
52
|
+
sourceStartStaggerMs: z.coerce
|
|
53
|
+
.number()
|
|
54
|
+
.int()
|
|
55
|
+
.min(0)
|
|
56
|
+
.max(5000)
|
|
57
|
+
.default(250)
|
|
58
|
+
.describe("Delay between source starts within a scan batch."),
|
|
59
|
+
threadConcurrency: z.coerce
|
|
60
|
+
.number()
|
|
61
|
+
.int()
|
|
62
|
+
.min(1)
|
|
63
|
+
.max(10)
|
|
64
|
+
.default(3)
|
|
65
|
+
.describe("How many threads to inspect at once within each source."),
|
|
66
|
+
threadTimeoutMs: z.coerce
|
|
67
|
+
.number()
|
|
68
|
+
.int()
|
|
69
|
+
.min(1000)
|
|
70
|
+
.max(30000)
|
|
71
|
+
.default(8000)
|
|
72
|
+
.describe("Per-thread debug timeout in milliseconds."),
|
|
73
|
+
title: z.string().optional().describe("Optional title for the dream pass."),
|
|
74
|
+
}),
|
|
75
|
+
run: async (input) => createDreamReport(input),
|
|
76
|
+
});
|