@agent-native/dispatch 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +220 -0
- package/dist/actions/approve-dispatch-change.d.ts +3 -0
- package/dist/actions/approve-dispatch-change.d.ts.map +1 -0
- package/dist/actions/approve-dispatch-change.js +11 -0
- package/dist/actions/approve-dispatch-change.js.map +1 -0
- package/dist/actions/approve-vault-request.d.ts +3 -0
- package/dist/actions/approve-vault-request.d.ts.map +1 -0
- package/dist/actions/approve-vault-request.js +16 -0
- package/dist/actions/approve-vault-request.js.map +1 -0
- package/dist/actions/create-link-token.d.ts +3 -0
- package/dist/actions/create-link-token.d.ts.map +1 -0
- package/dist/actions/create-link-token.js +11 -0
- package/dist/actions/create-link-token.js.map +1 -0
- package/dist/actions/create-vault-grant.d.ts +3 -0
- package/dist/actions/create-vault-grant.d.ts.map +1 -0
- package/dist/actions/create-vault-grant.js +14 -0
- package/dist/actions/create-vault-grant.js.map +1 -0
- package/dist/actions/create-vault-secret.d.ts +3 -0
- package/dist/actions/create-vault-secret.d.ts.map +1 -0
- package/dist/actions/create-vault-secret.js +20 -0
- package/dist/actions/create-vault-secret.js.map +1 -0
- package/dist/actions/create-workspace-resource-grant.d.ts +3 -0
- package/dist/actions/create-workspace-resource-grant.d.ts.map +1 -0
- package/dist/actions/create-workspace-resource-grant.js +14 -0
- package/dist/actions/create-workspace-resource-grant.js.map +1 -0
- package/dist/actions/create-workspace-resource.d.ts +3 -0
- package/dist/actions/create-workspace-resource.d.ts.map +1 -0
- package/dist/actions/create-workspace-resource.js +24 -0
- package/dist/actions/create-workspace-resource.js.map +1 -0
- package/dist/actions/delete-destination.d.ts +3 -0
- package/dist/actions/delete-destination.d.ts.map +1 -0
- package/dist/actions/delete-destination.js +11 -0
- package/dist/actions/delete-destination.js.map +1 -0
- package/dist/actions/delete-vault-secret.d.ts +3 -0
- package/dist/actions/delete-vault-secret.d.ts.map +1 -0
- package/dist/actions/delete-vault-secret.js +11 -0
- package/dist/actions/delete-vault-secret.js.map +1 -0
- package/dist/actions/delete-workspace-resource.d.ts +3 -0
- package/dist/actions/delete-workspace-resource.d.ts.map +1 -0
- package/dist/actions/delete-workspace-resource.js +11 -0
- package/dist/actions/delete-workspace-resource.js.map +1 -0
- package/dist/actions/deny-vault-request.d.ts +3 -0
- package/dist/actions/deny-vault-request.d.ts.map +1 -0
- package/dist/actions/deny-vault-request.js +12 -0
- package/dist/actions/deny-vault-request.js.map +1 -0
- package/dist/actions/get-app-creation-settings.d.ts +3 -0
- package/dist/actions/get-app-creation-settings.d.ts.map +1 -0
- package/dist/actions/get-app-creation-settings.js +10 -0
- package/dist/actions/get-app-creation-settings.js.map +1 -0
- package/dist/actions/get-dispatch-settings.d.ts +3 -0
- package/dist/actions/get-dispatch-settings.d.ts.map +1 -0
- package/dist/actions/get-dispatch-settings.js +10 -0
- package/dist/actions/get-dispatch-settings.js.map +1 -0
- package/dist/actions/get-workspace-info.d.ts +3 -0
- package/dist/actions/get-workspace-info.d.ts.map +1 -0
- package/dist/actions/get-workspace-info.js +10 -0
- package/dist/actions/get-workspace-info.js.map +1 -0
- package/dist/actions/grant-vault-secrets-to-app.d.ts +3 -0
- package/dist/actions/grant-vault-secrets-to-app.d.ts.map +1 -0
- package/dist/actions/grant-vault-secrets-to-app.js +19 -0
- package/dist/actions/grant-vault-secrets-to-app.js.map +1 -0
- package/dist/actions/index.d.ts +9 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +101 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/list-connected-agents.d.ts +3 -0
- package/dist/actions/list-connected-agents.d.ts.map +1 -0
- package/dist/actions/list-connected-agents.js +79 -0
- package/dist/actions/list-connected-agents.js.map +1 -0
- package/dist/actions/list-destinations.d.ts +3 -0
- package/dist/actions/list-destinations.d.ts.map +1 -0
- package/dist/actions/list-destinations.js +10 -0
- package/dist/actions/list-destinations.js.map +1 -0
- package/dist/actions/list-dispatch-approvals.d.ts +3 -0
- package/dist/actions/list-dispatch-approvals.d.ts.map +1 -0
- package/dist/actions/list-dispatch-approvals.js +10 -0
- package/dist/actions/list-dispatch-approvals.js.map +1 -0
- package/dist/actions/list-dispatch-audit.d.ts +3 -0
- package/dist/actions/list-dispatch-audit.d.ts.map +1 -0
- package/dist/actions/list-dispatch-audit.js +12 -0
- package/dist/actions/list-dispatch-audit.js.map +1 -0
- package/dist/actions/list-dispatch-overview.d.ts +3 -0
- package/dist/actions/list-dispatch-overview.d.ts.map +1 -0
- package/dist/actions/list-dispatch-overview.js +17 -0
- package/dist/actions/list-dispatch-overview.js.map +1 -0
- package/dist/actions/list-integrations-catalog.d.ts +3 -0
- package/dist/actions/list-integrations-catalog.d.ts.map +1 -0
- package/dist/actions/list-integrations-catalog.js +10 -0
- package/dist/actions/list-integrations-catalog.js.map +1 -0
- package/dist/actions/list-linked-identities.d.ts +3 -0
- package/dist/actions/list-linked-identities.d.ts.map +1 -0
- package/dist/actions/list-linked-identities.js +10 -0
- package/dist/actions/list-linked-identities.js.map +1 -0
- package/dist/actions/list-vault-audit.d.ts +3 -0
- package/dist/actions/list-vault-audit.d.ts.map +1 -0
- package/dist/actions/list-vault-audit.js +15 -0
- package/dist/actions/list-vault-audit.js.map +1 -0
- package/dist/actions/list-vault-grants.d.ts +3 -0
- package/dist/actions/list-vault-grants.d.ts.map +1 -0
- package/dist/actions/list-vault-grants.js +13 -0
- package/dist/actions/list-vault-grants.js.map +1 -0
- package/dist/actions/list-vault-requests.d.ts +3 -0
- package/dist/actions/list-vault-requests.d.ts.map +1 -0
- package/dist/actions/list-vault-requests.js +15 -0
- package/dist/actions/list-vault-requests.js.map +1 -0
- package/dist/actions/list-vault-secret-options.d.ts +3 -0
- package/dist/actions/list-vault-secret-options.d.ts.map +1 -0
- package/dist/actions/list-vault-secret-options.js +19 -0
- package/dist/actions/list-vault-secret-options.js.map +1 -0
- package/dist/actions/list-vault-secrets.d.ts +3 -0
- package/dist/actions/list-vault-secrets.d.ts.map +1 -0
- package/dist/actions/list-vault-secrets.js +25 -0
- package/dist/actions/list-vault-secrets.js.map +1 -0
- package/dist/actions/list-workspace-apps.d.ts +3 -0
- package/dist/actions/list-workspace-apps.d.ts.map +1 -0
- package/dist/actions/list-workspace-apps.js +24 -0
- package/dist/actions/list-workspace-apps.js.map +1 -0
- package/dist/actions/list-workspace-resource-grants.d.ts +3 -0
- package/dist/actions/list-workspace-resource-grants.d.ts.map +1 -0
- package/dist/actions/list-workspace-resource-grants.js +13 -0
- package/dist/actions/list-workspace-resource-grants.js.map +1 -0
- package/dist/actions/list-workspace-resources.d.ts +3 -0
- package/dist/actions/list-workspace-resources.d.ts.map +1 -0
- package/dist/actions/list-workspace-resources.js +15 -0
- package/dist/actions/list-workspace-resources.js.map +1 -0
- package/dist/actions/navigate.d.ts +16 -0
- package/dist/actions/navigate.d.ts.map +1 -0
- package/dist/actions/navigate.js +55 -0
- package/dist/actions/navigate.js.map +1 -0
- package/dist/actions/reject-dispatch-change.d.ts +3 -0
- package/dist/actions/reject-dispatch-change.d.ts.map +1 -0
- package/dist/actions/reject-dispatch-change.js +12 -0
- package/dist/actions/reject-dispatch-change.js.map +1 -0
- package/dist/actions/request-vault-secret.d.ts +3 -0
- package/dist/actions/request-vault-secret.d.ts.map +1 -0
- package/dist/actions/request-vault-secret.js +15 -0
- package/dist/actions/request-vault-secret.js.map +1 -0
- package/dist/actions/revoke-vault-grant.d.ts +3 -0
- package/dist/actions/revoke-vault-grant.d.ts.map +1 -0
- package/dist/actions/revoke-vault-grant.js +11 -0
- package/dist/actions/revoke-vault-grant.js.map +1 -0
- package/dist/actions/revoke-workspace-resource-grant.d.ts +3 -0
- package/dist/actions/revoke-workspace-resource-grant.d.ts.map +1 -0
- package/dist/actions/revoke-workspace-resource-grant.js +11 -0
- package/dist/actions/revoke-workspace-resource-grant.js.map +1 -0
- package/dist/actions/send-platform-message.d.ts +3 -0
- package/dist/actions/send-platform-message.d.ts.map +1 -0
- package/dist/actions/send-platform-message.js +73 -0
- package/dist/actions/send-platform-message.js.map +1 -0
- package/dist/actions/set-app-creation-settings.d.ts +3 -0
- package/dist/actions/set-app-creation-settings.d.ts.map +1 -0
- package/dist/actions/set-app-creation-settings.js +18 -0
- package/dist/actions/set-app-creation-settings.js.map +1 -0
- package/dist/actions/set-dispatch-approval-policy.d.ts +3 -0
- package/dist/actions/set-dispatch-approval-policy.d.ts.map +1 -0
- package/dist/actions/set-dispatch-approval-policy.js +19 -0
- package/dist/actions/set-dispatch-approval-policy.js.map +1 -0
- package/dist/actions/start-workspace-app-creation.d.ts +3 -0
- package/dist/actions/start-workspace-app-creation.d.ts.map +1 -0
- package/dist/actions/start-workspace-app-creation.js +31 -0
- package/dist/actions/start-workspace-app-creation.js.map +1 -0
- package/dist/actions/sync-vault-to-app.d.ts +3 -0
- package/dist/actions/sync-vault-to-app.d.ts.map +1 -0
- package/dist/actions/sync-vault-to-app.js +13 -0
- package/dist/actions/sync-vault-to-app.js.map +1 -0
- package/dist/actions/sync-workspace-resources-to-all.d.ts +3 -0
- package/dist/actions/sync-workspace-resources-to-all.d.ts.map +1 -0
- package/dist/actions/sync-workspace-resources-to-all.js +9 -0
- package/dist/actions/sync-workspace-resources-to-all.js.map +1 -0
- package/dist/actions/sync-workspace-resources-to-app.d.ts +3 -0
- package/dist/actions/sync-workspace-resources-to-app.d.ts.map +1 -0
- package/dist/actions/sync-workspace-resources-to-app.js +11 -0
- package/dist/actions/sync-workspace-resources-to-app.js.map +1 -0
- package/dist/actions/update-vault-secret.d.ts +3 -0
- package/dist/actions/update-vault-secret.d.ts.map +1 -0
- package/dist/actions/update-vault-secret.js +12 -0
- package/dist/actions/update-vault-secret.js.map +1 -0
- package/dist/actions/update-workspace-resource.d.ts +3 -0
- package/dist/actions/update-workspace-resource.d.ts.map +1 -0
- package/dist/actions/update-workspace-resource.js +18 -0
- package/dist/actions/update-workspace-resource.js.map +1 -0
- package/dist/actions/upsert-destination.d.ts +3 -0
- package/dist/actions/upsert-destination.d.ts.map +1 -0
- package/dist/actions/upsert-destination.js +26 -0
- package/dist/actions/upsert-destination.js.map +1 -0
- package/dist/actions/view-screen.d.ts +11 -0
- package/dist/actions/view-screen.d.ts.map +1 -0
- package/dist/actions/view-screen.js +68 -0
- package/dist/actions/view-screen.js.map +1 -0
- package/dist/components/agents-panel.d.ts +16 -0
- package/dist/components/agents-panel.d.ts.map +1 -0
- package/dist/components/agents-panel.js +64 -0
- package/dist/components/agents-panel.js.map +1 -0
- package/dist/components/app-keys-popover.d.ts +11 -0
- package/dist/components/app-keys-popover.d.ts.map +1 -0
- package/dist/components/app-keys-popover.js +84 -0
- package/dist/components/app-keys-popover.js.map +1 -0
- package/dist/components/create-app-popover.d.ts +24 -0
- package/dist/components/create-app-popover.d.ts.map +1 -0
- package/dist/components/create-app-popover.js +188 -0
- package/dist/components/create-app-popover.js.map +1 -0
- package/dist/components/dispatch-shell.d.ts +13 -0
- package/dist/components/dispatch-shell.d.ts.map +1 -0
- package/dist/components/dispatch-shell.js +15 -0
- package/dist/components/dispatch-shell.js.map +1 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +12 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/layout/Header.d.ts +5 -0
- package/dist/components/layout/Header.d.ts.map +1 -0
- package/dist/components/layout/Header.js +34 -0
- package/dist/components/layout/Header.js.map +1 -0
- package/dist/components/layout/HeaderActions.d.ts +18 -0
- package/dist/components/layout/HeaderActions.d.ts.map +1 -0
- package/dist/components/layout/HeaderActions.js +52 -0
- package/dist/components/layout/HeaderActions.js.map +1 -0
- package/dist/components/layout/Layout.d.ts +8 -0
- package/dist/components/layout/Layout.d.ts.map +1 -0
- package/dist/components/layout/Layout.js +70 -0
- package/dist/components/layout/Layout.js.map +1 -0
- package/dist/components/messaging-setup-panel.d.ts +2 -0
- package/dist/components/messaging-setup-panel.d.ts.map +1 -0
- package/dist/components/messaging-setup-panel.js +300 -0
- package/dist/components/messaging-setup-panel.js.map +1 -0
- package/dist/components/ui/accordion.d.ts +8 -0
- package/dist/components/ui/accordion.d.ts.map +1 -0
- package/dist/components/ui/accordion.js +14 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +21 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +27 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/alert.d.ts +9 -0
- package/dist/components/ui/alert.d.ts.map +1 -0
- package/dist/components/ui/alert.js +23 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/aspect-ratio.d.ts +4 -0
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -0
- package/dist/components/ui/aspect-ratio.js +4 -0
- package/dist/components/ui/aspect-ratio.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +7 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +12 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +21 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +20 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.js +24 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +34 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/calendar.d.ts +9 -0
- package/dist/components/ui/calendar.d.ts.map +1 -0
- package/dist/components/ui/calendar.js +41 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +17 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/carousel.d.ts +19 -0
- package/dist/components/ui/carousel.d.ts.map +1 -0
- package/dist/components/ui/carousel.js +99 -0
- package/dist/components/ui/carousel.js.map +1 -0
- package/dist/components/ui/chart.d.ts +80 -0
- package/dist/components/ui/chart.d.ts.map +1 -0
- package/dist/components/ui/chart.js +131 -0
- package/dist/components/ui/chart.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +9 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +6 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/command.d.ts +83 -0
- package/dist/components/ui/command.d.ts.map +1 -0
- package/dist/components/ui/command.js +29 -0
- package/dist/components/ui/command.js.map +1 -0
- package/dist/components/ui/context-menu.d.ts +28 -0
- package/dist/components/ui/context-menu.d.ts.map +1 -0
- package/dist/components/ui/context-menu.js +34 -0
- package/dist/components/ui/context-menu.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +20 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +23 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/drawer.d.ts +23 -0
- package/dist/components/ui/drawer.d.ts.map +1 -0
- package/dist/components/ui/drawer.js +23 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +28 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +36 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/form.d.ts +24 -0
- package/dist/components/ui/form.d.ts.map +1 -0
- package/dist/components/ui/form.js +63 -0
- package/dist/components/ui/form.js.map +1 -0
- package/dist/components/ui/hover-card.d.ts +7 -0
- package/dist/components/ui/hover-card.d.ts.map +1 -0
- package/dist/components/ui/hover-card.js +10 -0
- package/dist/components/ui/hover-card.js.map +1 -0
- package/dist/components/ui/input-otp.d.ts +35 -0
- package/dist/components/ui/input-otp.d.ts.map +1 -0
- package/dist/components/ui/input-otp.js +19 -0
- package/dist/components/ui/input-otp.js.map +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +9 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +10 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/menubar.d.ts +29 -0
- package/dist/components/ui/menubar.d.ts.map +1 -0
- package/dist/components/ui/menubar.js +41 -0
- package/dist/components/ui/menubar.js.map +1 -0
- package/dist/components/ui/navigation-menu.d.ts +13 -0
- package/dist/components/ui/navigation-menu.d.ts.map +1 -0
- package/dist/components/ui/navigation-menu.js +25 -0
- package/dist/components/ui/navigation-menu.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +29 -0
- package/dist/components/ui/pagination.d.ts.map +1 -0
- package/dist/components/ui/pagination.js +24 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/popover.d.ts +7 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +10 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.d.ts +5 -0
- package/dist/components/ui/progress.d.ts.map +1 -0
- package/dist/components/ui/progress.js +8 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +6 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +15 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/resizable.d.ts +8 -0
- package/dist/components/ui/resizable.d.ts.map +1 -0
- package/dist/components/ui/resizable.js +9 -0
- package/dist/components/ui/resizable.js.map +1 -0
- package/dist/components/ui/scroll-area.d.ts +6 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +12 -0
- package/dist/components/ui/scroll-area.js.map +1 -0
- package/dist/components/ui/select.d.ts +14 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +27 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +8 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/sheet.d.ts +26 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +37 -0
- package/dist/components/ui/sheet.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +67 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +233 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +7 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/slider.d.ts +5 -0
- package/dist/components/ui/slider.d.ts.map +1 -0
- package/dist/components/ui/slider.js +8 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/sonner.d.ts +5 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/sonner.js +25 -0
- package/dist/components/ui/sonner.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +3 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +7 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +8 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.d.ts +11 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +21 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.d.ts +8 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +13 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +6 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +9 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/toast.d.ts +16 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +34 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toaster.d.ts +2 -0
- package/dist/components/ui/toaster.d.ts.map +1 -0
- package/dist/components/ui/toaster.js +10 -0
- package/dist/components/ui/toaster.js.map +1 -0
- package/dist/components/ui/toggle-group.d.ts +13 -0
- package/dist/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/components/ui/toggle-group.js +21 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +13 -0
- package/dist/components/ui/toggle.d.ts.map +1 -0
- package/dist/components/ui/toggle.js +26 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +11 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/ui/use-toast.d.ts +3 -0
- package/dist/components/ui/use-toast.d.ts.map +1 -0
- package/dist/components/ui/use-toast.js +3 -0
- package/dist/components/ui/use-toast.js.map +1 -0
- package/dist/config.d.ts +33 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -0
- package/dist/db/index.d.ts +7 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +10 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations.d.ts +5 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +166 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/schema.d.ts +2344 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +148 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +16 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-navigation-state.d.ts +6 -0
- package/dist/hooks/use-navigation-state.d.ts.map +1 -0
- package/dist/hooks/use-navigation-state.js +129 -0
- package/dist/hooks/use-navigation-state.js.map +1 -0
- package/dist/hooks/use-toast.d.ts +45 -0
- package/dist/hooks/use-toast.d.ts.map +1 -0
- package/dist/hooks/use-toast.js +127 -0
- package/dist/hooks/use-toast.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +2 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/routes/index.d.ts +32 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +51 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/pages/_index.d.ts +15 -0
- package/dist/routes/pages/_index.d.ts.map +1 -0
- package/dist/routes/pages/_index.js +42 -0
- package/dist/routes/pages/_index.js.map +1 -0
- package/dist/routes/pages/agents.d.ts +5 -0
- package/dist/routes/pages/agents.d.ts.map +1 -0
- package/dist/routes/pages/agents.js +12 -0
- package/dist/routes/pages/agents.js.map +1 -0
- package/dist/routes/pages/approval.d.ts +5 -0
- package/dist/routes/pages/approval.d.ts.map +1 -0
- package/dist/routes/pages/approval.js +47 -0
- package/dist/routes/pages/approval.js.map +1 -0
- package/dist/routes/pages/approvals.d.ts +5 -0
- package/dist/routes/pages/approvals.d.ts.map +1 -0
- package/dist/routes/pages/approvals.js +48 -0
- package/dist/routes/pages/approvals.js.map +1 -0
- package/dist/routes/pages/apps.$appId.d.ts +5 -0
- package/dist/routes/pages/apps.$appId.d.ts.map +1 -0
- package/dist/routes/pages/apps.$appId.js +31 -0
- package/dist/routes/pages/apps.$appId.js.map +1 -0
- package/dist/routes/pages/apps.d.ts +5 -0
- package/dist/routes/pages/apps.d.ts.map +1 -0
- package/dist/routes/pages/apps.js +42 -0
- package/dist/routes/pages/apps.js.map +1 -0
- package/dist/routes/pages/audit.d.ts +5 -0
- package/dist/routes/pages/audit.d.ts.map +1 -0
- package/dist/routes/pages/audit.js +11 -0
- package/dist/routes/pages/audit.js.map +1 -0
- package/dist/routes/pages/destinations.d.ts +5 -0
- package/dist/routes/pages/destinations.d.ts.map +1 -0
- package/dist/routes/pages/destinations.js +80 -0
- package/dist/routes/pages/destinations.js.map +1 -0
- package/dist/routes/pages/identities.d.ts +5 -0
- package/dist/routes/pages/identities.d.ts.map +1 -0
- package/dist/routes/pages/identities.js +18 -0
- package/dist/routes/pages/identities.js.map +1 -0
- package/dist/routes/pages/integrations.d.ts +5 -0
- package/dist/routes/pages/integrations.d.ts.map +1 -0
- package/dist/routes/pages/integrations.js +46 -0
- package/dist/routes/pages/integrations.js.map +1 -0
- package/dist/routes/pages/messaging.d.ts +5 -0
- package/dist/routes/pages/messaging.d.ts.map +1 -0
- package/dist/routes/pages/messaging.js +10 -0
- package/dist/routes/pages/messaging.js.map +1 -0
- package/dist/routes/pages/new-app.d.ts +5 -0
- package/dist/routes/pages/new-app.d.ts.map +1 -0
- package/dist/routes/pages/new-app.js +10 -0
- package/dist/routes/pages/new-app.js.map +1 -0
- package/dist/routes/pages/overview.d.ts +5 -0
- package/dist/routes/pages/overview.d.ts.map +1 -0
- package/dist/routes/pages/overview.js +225 -0
- package/dist/routes/pages/overview.js.map +1 -0
- package/dist/routes/pages/team.d.ts +5 -0
- package/dist/routes/pages/team.d.ts.map +1 -0
- package/dist/routes/pages/team.js +10 -0
- package/dist/routes/pages/team.js.map +1 -0
- package/dist/routes/pages/tools.$id.d.ts +2 -0
- package/dist/routes/pages/tools.$id.d.ts.map +1 -0
- package/dist/routes/pages/tools.$id.js +6 -0
- package/dist/routes/pages/tools.$id.js.map +1 -0
- package/dist/routes/pages/tools._index.d.ts +2 -0
- package/dist/routes/pages/tools._index.d.ts.map +1 -0
- package/dist/routes/pages/tools._index.js +6 -0
- package/dist/routes/pages/tools._index.js.map +1 -0
- package/dist/routes/pages/vault.d.ts +5 -0
- package/dist/routes/pages/vault.d.ts.map +1 -0
- package/dist/routes/pages/vault.js +131 -0
- package/dist/routes/pages/vault.js.map +1 -0
- package/dist/routes/pages/workspace.d.ts +5 -0
- package/dist/routes/pages/workspace.d.ts.map +1 -0
- package/dist/routes/pages/workspace.js +149 -0
- package/dist/routes/pages/workspace.js.map +1 -0
- package/dist/server/index.d.ts +44 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +68 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/lib/app-creation-store.d.ts +102 -0
- package/dist/server/lib/app-creation-store.d.ts.map +1 -0
- package/dist/server/lib/app-creation-store.js +780 -0
- package/dist/server/lib/app-creation-store.js.map +1 -0
- package/dist/server/lib/dispatch-integrations.d.ts +10 -0
- package/dist/server/lib/dispatch-integrations.d.ts.map +1 -0
- package/dist/server/lib/dispatch-integrations.js +105 -0
- package/dist/server/lib/dispatch-integrations.js.map +1 -0
- package/dist/server/lib/dispatch-store.d.ts +313 -0
- package/dist/server/lib/dispatch-store.d.ts.map +1 -0
- package/dist/server/lib/dispatch-store.js +669 -0
- package/dist/server/lib/dispatch-store.js.map +1 -0
- package/dist/server/lib/env-config.d.ts +3 -0
- package/dist/server/lib/env-config.d.ts.map +1 -0
- package/dist/server/lib/env-config.js +43 -0
- package/dist/server/lib/env-config.js.map +1 -0
- package/dist/server/lib/pre-auth-routing.d.ts +2 -0
- package/dist/server/lib/pre-auth-routing.d.ts.map +1 -0
- package/dist/server/lib/pre-auth-routing.js +128 -0
- package/dist/server/lib/pre-auth-routing.js.map +1 -0
- package/dist/server/lib/vault-store.d.ts +270 -0
- package/dist/server/lib/vault-store.d.ts.map +1 -0
- package/dist/server/lib/vault-store.js +554 -0
- package/dist/server/lib/vault-store.js.map +1 -0
- package/dist/server/lib/workspace-resources-store.d.ts +165 -0
- package/dist/server/lib/workspace-resources-store.d.ts.map +1 -0
- package/dist/server/lib/workspace-resources-store.js +310 -0
- package/dist/server/lib/workspace-resources-store.js.map +1 -0
- package/dist/server/plugins/agent-chat.d.ts +3 -0
- package/dist/server/plugins/agent-chat.d.ts.map +1 -0
- package/dist/server/plugins/agent-chat.js +36 -0
- package/dist/server/plugins/agent-chat.js.map +1 -0
- package/dist/server/plugins/auth.d.ts +9 -0
- package/dist/server/plugins/auth.d.ts.map +1 -0
- package/dist/server/plugins/auth.js +30 -0
- package/dist/server/plugins/auth.js.map +1 -0
- package/dist/server/plugins/core-routes.d.ts +3 -0
- package/dist/server/plugins/core-routes.d.ts.map +1 -0
- package/dist/server/plugins/core-routes.js +6 -0
- package/dist/server/plugins/core-routes.js.map +1 -0
- package/dist/server/plugins/db.d.ts +3 -0
- package/dist/server/plugins/db.d.ts.map +1 -0
- package/dist/server/plugins/db.js +6 -0
- package/dist/server/plugins/db.js.map +1 -0
- package/dist/server/plugins/integrations.d.ts +8 -0
- package/dist/server/plugins/integrations.d.ts.map +1 -0
- package/dist/server/plugins/integrations.js +51 -0
- package/dist/server/plugins/integrations.js.map +1 -0
- package/package.json +103 -0
- package/src/actions/approve-dispatch-change.ts +11 -0
- package/src/actions/approve-vault-request.ts +23 -0
- package/src/actions/create-link-token.ts +12 -0
- package/src/actions/create-vault-grant.ts +15 -0
- package/src/actions/create-vault-secret.ts +21 -0
- package/src/actions/create-workspace-resource-grant.ts +15 -0
- package/src/actions/create-workspace-resource.ts +29 -0
- package/src/actions/delete-destination.ts +11 -0
- package/src/actions/delete-vault-secret.ts +12 -0
- package/src/actions/delete-workspace-resource.ts +12 -0
- package/src/actions/deny-vault-request.ts +12 -0
- package/src/actions/get-app-creation-settings.ts +11 -0
- package/src/actions/get-dispatch-settings.ts +10 -0
- package/src/actions/get-workspace-info.ts +11 -0
- package/src/actions/grant-vault-secrets-to-app.ts +20 -0
- package/src/actions/index.ts +102 -0
- package/src/actions/list-connected-agents.ts +103 -0
- package/src/actions/list-destinations.ts +10 -0
- package/src/actions/list-dispatch-approvals.ts +10 -0
- package/src/actions/list-dispatch-audit.ts +12 -0
- package/src/actions/list-dispatch-overview.ts +18 -0
- package/src/actions/list-integrations-catalog.ts +11 -0
- package/src/actions/list-linked-identities.ts +10 -0
- package/src/actions/list-vault-audit.ts +16 -0
- package/src/actions/list-vault-grants.ts +14 -0
- package/src/actions/list-vault-requests.ts +16 -0
- package/src/actions/list-vault-secret-options.ts +20 -0
- package/src/actions/list-vault-secrets.ts +26 -0
- package/src/actions/list-workspace-apps.ts +25 -0
- package/src/actions/list-workspace-resource-grants.ts +14 -0
- package/src/actions/list-workspace-resources.ts +16 -0
- package/src/actions/navigate.ts +55 -0
- package/src/actions/reject-dispatch-change.ts +12 -0
- package/src/actions/request-vault-secret.ts +16 -0
- package/src/actions/revoke-vault-grant.ts +11 -0
- package/src/actions/revoke-workspace-resource-grant.ts +15 -0
- package/src/actions/send-platform-message.ts +96 -0
- package/src/actions/set-app-creation-settings.ts +19 -0
- package/src/actions/set-dispatch-approval-policy.ts +24 -0
- package/src/actions/start-workspace-app-creation.ts +33 -0
- package/src/actions/sync-vault-to-app.ts +14 -0
- package/src/actions/sync-workspace-resources-to-all.ts +10 -0
- package/src/actions/sync-workspace-resources-to-app.ts +12 -0
- package/src/actions/update-vault-secret.ts +12 -0
- package/src/actions/update-workspace-resource.ts +19 -0
- package/src/actions/upsert-destination.ts +29 -0
- package/src/actions/view-screen.ts +78 -0
- package/src/components/agents-panel.tsx +262 -0
- package/src/components/app-keys-popover.tsx +231 -0
- package/src/components/create-app-popover.tsx +423 -0
- package/src/components/dispatch-shell.tsx +53 -0
- package/src/components/index.ts +11 -0
- package/src/components/layout/Header.tsx +69 -0
- package/src/components/layout/HeaderActions.tsx +84 -0
- package/src/components/layout/Layout.tsx +243 -0
- package/src/components/messaging-setup-panel.tsx +666 -0
- package/src/components/ui/accordion.tsx +56 -0
- package/src/components/ui/alert-dialog.tsx +139 -0
- package/src/components/ui/alert.tsx +59 -0
- package/src/components/ui/aspect-ratio.tsx +5 -0
- package/src/components/ui/avatar.tsx +48 -0
- package/src/components/ui/badge.tsx +37 -0
- package/src/components/ui/breadcrumb.tsx +115 -0
- package/src/components/ui/button.tsx +57 -0
- package/src/components/ui/calendar.tsx +68 -0
- package/src/components/ui/card.tsx +86 -0
- package/src/components/ui/carousel.tsx +260 -0
- package/src/components/ui/chart.tsx +375 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/collapsible.tsx +9 -0
- package/src/components/ui/command.tsx +154 -0
- package/src/components/ui/context-menu.tsx +198 -0
- package/src/components/ui/dialog.tsx +120 -0
- package/src/components/ui/drawer.tsx +116 -0
- package/src/components/ui/dropdown-menu.tsx +198 -0
- package/src/components/ui/form.tsx +177 -0
- package/src/components/ui/hover-card.tsx +27 -0
- package/src/components/ui/input-otp.tsx +69 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/menubar.tsx +235 -0
- package/src/components/ui/navigation-menu.tsx +128 -0
- package/src/components/ui/pagination.tsx +121 -0
- package/src/components/ui/popover.tsx +29 -0
- package/src/components/ui/progress.tsx +26 -0
- package/src/components/ui/radio-group.tsx +42 -0
- package/src/components/ui/resizable.tsx +43 -0
- package/src/components/ui/scroll-area.tsx +46 -0
- package/src/components/ui/select.tsx +158 -0
- package/src/components/ui/separator.tsx +29 -0
- package/src/components/ui/sheet.tsx +139 -0
- package/src/components/ui/sidebar.tsx +778 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/slider.tsx +26 -0
- package/src/components/ui/sonner.tsx +58 -0
- package/src/components/ui/spinner.tsx +17 -0
- package/src/components/ui/switch.tsx +27 -0
- package/src/components/ui/table.tsx +117 -0
- package/src/components/ui/tabs.tsx +53 -0
- package/src/components/ui/textarea.tsx +23 -0
- package/src/components/ui/toast.tsx +127 -0
- package/src/components/ui/toaster.tsx +33 -0
- package/src/components/ui/toggle-group.tsx +59 -0
- package/src/components/ui/toggle.tsx +43 -0
- package/src/components/ui/tooltip.tsx +28 -0
- package/src/components/ui/use-toast.ts +3 -0
- package/src/config.ts +35 -0
- package/src/db/index.ts +12 -0
- package/src/db/migrations.ts +165 -0
- package/src/db/schema.ts +160 -0
- package/src/hooks/use-mobile.tsx +21 -0
- package/src/hooks/use-navigation-state.ts +132 -0
- package/src/hooks/use-toast.ts +188 -0
- package/src/index.ts +19 -0
- package/src/lib/utils.ts +1 -0
- package/src/routes/index.ts +51 -0
- package/src/routes/pages/_index.tsx +51 -0
- package/src/routes/pages/agents.tsx +23 -0
- package/src/routes/pages/approval.tsx +243 -0
- package/src/routes/pages/approvals.tsx +157 -0
- package/src/routes/pages/apps.$appId.tsx +134 -0
- package/src/routes/pages/apps.tsx +163 -0
- package/src/routes/pages/audit.tsx +41 -0
- package/src/routes/pages/destinations.tsx +253 -0
- package/src/routes/pages/identities.tsx +91 -0
- package/src/routes/pages/integrations.tsx +278 -0
- package/src/routes/pages/messaging.tsx +17 -0
- package/src/routes/pages/new-app.tsx +17 -0
- package/src/routes/pages/overview.tsx +792 -0
- package/src/routes/pages/team.tsx +23 -0
- package/src/routes/pages/tools.$id.tsx +5 -0
- package/src/routes/pages/tools._index.tsx +5 -0
- package/src/routes/pages/vault.tsx +617 -0
- package/src/routes/pages/workspace.tsx +598 -0
- package/src/server/index.ts +78 -0
- package/src/server/lib/app-creation-store.ts +996 -0
- package/src/server/lib/dispatch-integrations.ts +125 -0
- package/src/server/lib/dispatch-store.ts +889 -0
- package/src/server/lib/env-config.ts +44 -0
- package/src/server/lib/pre-auth-routing.ts +150 -0
- package/src/server/lib/vault-store.ts +811 -0
- package/src/server/lib/workspace-resources-store.ts +445 -0
- package/src/server/plugins/agent-chat.ts +36 -0
- package/src/server/plugins/auth.ts +34 -0
- package/src/server/plugins/core-routes.ts +6 -0
- package/src/server/plugins/db.ts +6 -0
- package/src/server/plugins/integrations.ts +59 -0
|
@@ -0,0 +1,811 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { and, desc, eq, isNull, or } from "drizzle-orm";
|
|
3
|
+
import { discoverAgents } from "@agent-native/core/server/agent-discovery";
|
|
4
|
+
import { getDb, schema } from "../../db/index.js";
|
|
5
|
+
import {
|
|
6
|
+
currentOwnerEmail,
|
|
7
|
+
currentOrgId,
|
|
8
|
+
recordAudit,
|
|
9
|
+
} from "./dispatch-store.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Caller-supplied access context for vault operations.
|
|
13
|
+
*
|
|
14
|
+
* Every getSecret / updateSecret / deleteSecret / createGrant call must
|
|
15
|
+
* pass the ctx of the *current request* so the row is scoped to that
|
|
16
|
+
* caller's tenant. Looking up a vault secret by id alone is unsafe — UUIDs
|
|
17
|
+
* are not authorization. A row matches the ctx if either the caller owns
|
|
18
|
+
* it or it lives in the caller's active org.
|
|
19
|
+
*/
|
|
20
|
+
export interface VaultCtx {
|
|
21
|
+
ownerEmail: string;
|
|
22
|
+
orgId: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Build a VaultCtx from the current request. Throws if the request is
|
|
27
|
+
* unauthenticated — the previous behavior of falling back to "local@localhost"
|
|
28
|
+
* leaked rows across tenants when a misconfigured environment skipped auth.
|
|
29
|
+
*/
|
|
30
|
+
export function requireVaultCtx(): VaultCtx {
|
|
31
|
+
const ownerEmail = currentOwnerEmail();
|
|
32
|
+
if (!ownerEmail) {
|
|
33
|
+
throw new Error("Vault operation requires an authenticated user");
|
|
34
|
+
}
|
|
35
|
+
return { ownerEmail, orgId: currentOrgId() };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** WHERE clause that limits a vault row to the caller's ownership scope. */
|
|
39
|
+
function ctxScope<T extends { ownerEmail: any; orgId: any }>(
|
|
40
|
+
table: T,
|
|
41
|
+
ctx: VaultCtx,
|
|
42
|
+
) {
|
|
43
|
+
return or(
|
|
44
|
+
eq(table.ownerEmail, ctx.ownerEmail),
|
|
45
|
+
ctx.orgId ? eq(table.orgId, ctx.orgId) : isNull(table.orgId),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Build a ctx that scopes to a specific row's owner/org (used when a
|
|
50
|
+
* request approver acts on behalf of the original requester so the
|
|
51
|
+
* created secret lands in the request's org). */
|
|
52
|
+
function ctxForRow(row: {
|
|
53
|
+
ownerEmail: string;
|
|
54
|
+
orgId: string | null;
|
|
55
|
+
}): VaultCtx {
|
|
56
|
+
return { ownerEmail: row.ownerEmail, orgId: row.orgId };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function id() {
|
|
60
|
+
return crypto.randomUUID();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function now() {
|
|
64
|
+
return Date.now();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function safeJson(value: unknown) {
|
|
68
|
+
return JSON.stringify(value ?? null);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function orgFilter<T extends { ownerEmail: any; orgId: any }>(table: T) {
|
|
72
|
+
const orgId = currentOrgId();
|
|
73
|
+
return and(
|
|
74
|
+
eq(table.ownerEmail, currentOwnerEmail()),
|
|
75
|
+
orgId ? eq(table.orgId, orgId) : isNull(table.orgId),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ─── Vault Audit ──────────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
export async function recordVaultAudit(input: {
|
|
82
|
+
action: string;
|
|
83
|
+
secretId?: string | null;
|
|
84
|
+
appId?: string | null;
|
|
85
|
+
summary: string;
|
|
86
|
+
metadata?: unknown;
|
|
87
|
+
actor?: string;
|
|
88
|
+
}) {
|
|
89
|
+
const db = getDb();
|
|
90
|
+
await db.insert(schema.vaultAuditLog).values({
|
|
91
|
+
id: id(),
|
|
92
|
+
ownerEmail: currentOwnerEmail(),
|
|
93
|
+
orgId: currentOrgId(),
|
|
94
|
+
secretId: input.secretId || null,
|
|
95
|
+
appId: input.appId || null,
|
|
96
|
+
action: input.action,
|
|
97
|
+
actor: input.actor || currentOwnerEmail(),
|
|
98
|
+
summary: input.summary,
|
|
99
|
+
metadata: input.metadata ? safeJson(input.metadata) : null,
|
|
100
|
+
createdAt: now(),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function listVaultAudit(limit = 50) {
|
|
105
|
+
const db = getDb();
|
|
106
|
+
return db
|
|
107
|
+
.select()
|
|
108
|
+
.from(schema.vaultAuditLog)
|
|
109
|
+
.where(orgFilter(schema.vaultAuditLog))
|
|
110
|
+
.orderBy(desc(schema.vaultAuditLog.createdAt))
|
|
111
|
+
.limit(limit);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ─── Secrets ──────────────────────────────────────────────────────
|
|
115
|
+
|
|
116
|
+
export async function listSecrets() {
|
|
117
|
+
const db = getDb();
|
|
118
|
+
return db
|
|
119
|
+
.select()
|
|
120
|
+
.from(schema.vaultSecrets)
|
|
121
|
+
.where(orgFilter(schema.vaultSecrets))
|
|
122
|
+
.orderBy(desc(schema.vaultSecrets.updatedAt));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function getSecret(secretId: string, ctx: VaultCtx) {
|
|
126
|
+
const db = getDb();
|
|
127
|
+
const [row] = await db
|
|
128
|
+
.select()
|
|
129
|
+
.from(schema.vaultSecrets)
|
|
130
|
+
.where(
|
|
131
|
+
and(
|
|
132
|
+
eq(schema.vaultSecrets.id, secretId),
|
|
133
|
+
ctxScope(schema.vaultSecrets, ctx),
|
|
134
|
+
),
|
|
135
|
+
)
|
|
136
|
+
.limit(1);
|
|
137
|
+
return row ?? null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export async function createSecret(
|
|
141
|
+
input: {
|
|
142
|
+
credentialKey: string;
|
|
143
|
+
value: string;
|
|
144
|
+
name: string;
|
|
145
|
+
provider?: string | null;
|
|
146
|
+
description?: string | null;
|
|
147
|
+
},
|
|
148
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
149
|
+
) {
|
|
150
|
+
const db = getDb();
|
|
151
|
+
const timestamp = now();
|
|
152
|
+
const secretId = id();
|
|
153
|
+
const actor = ctx.ownerEmail;
|
|
154
|
+
|
|
155
|
+
await db.insert(schema.vaultSecrets).values({
|
|
156
|
+
id: secretId,
|
|
157
|
+
ownerEmail: actor,
|
|
158
|
+
orgId: ctx.orgId,
|
|
159
|
+
name: input.name,
|
|
160
|
+
credentialKey: input.credentialKey,
|
|
161
|
+
value: input.value,
|
|
162
|
+
provider: input.provider || null,
|
|
163
|
+
description: input.description || null,
|
|
164
|
+
createdBy: actor,
|
|
165
|
+
createdAt: timestamp,
|
|
166
|
+
updatedAt: timestamp,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
await recordVaultAudit({
|
|
170
|
+
action: "secret.created",
|
|
171
|
+
secretId,
|
|
172
|
+
summary: `Created secret "${input.name}" (${input.credentialKey})`,
|
|
173
|
+
metadata: { credentialKey: input.credentialKey, provider: input.provider },
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
await recordAudit({
|
|
177
|
+
action: "vault.secret.created",
|
|
178
|
+
targetType: "vault-secret",
|
|
179
|
+
targetId: secretId,
|
|
180
|
+
summary: `Created vault secret "${input.name}" (${input.credentialKey})`,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
return getSecret(secretId, ctx);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export async function updateSecret(
|
|
187
|
+
secretId: string,
|
|
188
|
+
value: string,
|
|
189
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
190
|
+
) {
|
|
191
|
+
const db = getDb();
|
|
192
|
+
const existing = await getSecret(secretId, ctx);
|
|
193
|
+
if (!existing) throw new Error("Secret not found");
|
|
194
|
+
|
|
195
|
+
await db
|
|
196
|
+
.update(schema.vaultSecrets)
|
|
197
|
+
.set({ value, updatedAt: now() })
|
|
198
|
+
.where(
|
|
199
|
+
and(
|
|
200
|
+
eq(schema.vaultSecrets.id, secretId),
|
|
201
|
+
ctxScope(schema.vaultSecrets, ctx),
|
|
202
|
+
),
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
await recordVaultAudit({
|
|
206
|
+
action: "secret.updated",
|
|
207
|
+
secretId,
|
|
208
|
+
summary: `Updated value for secret "${existing.name}" (${existing.credentialKey})`,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
return getSecret(secretId, ctx);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export async function deleteSecret(
|
|
215
|
+
secretId: string,
|
|
216
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
217
|
+
) {
|
|
218
|
+
const db = getDb();
|
|
219
|
+
const existing = await getSecret(secretId, ctx);
|
|
220
|
+
if (!existing) throw new Error("Secret not found");
|
|
221
|
+
|
|
222
|
+
// Revoke all active grants first
|
|
223
|
+
const grants = await listGrants({ secretId });
|
|
224
|
+
for (const grant of grants) {
|
|
225
|
+
if (grant.status === "active") {
|
|
226
|
+
await revokeGrant(grant.id, ctx);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
await db
|
|
231
|
+
.delete(schema.vaultSecrets)
|
|
232
|
+
.where(
|
|
233
|
+
and(
|
|
234
|
+
eq(schema.vaultSecrets.id, secretId),
|
|
235
|
+
ctxScope(schema.vaultSecrets, ctx),
|
|
236
|
+
),
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
await recordVaultAudit({
|
|
240
|
+
action: "secret.deleted",
|
|
241
|
+
secretId,
|
|
242
|
+
summary: `Deleted secret "${existing.name}" (${existing.credentialKey})`,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
await recordAudit({
|
|
246
|
+
action: "vault.secret.deleted",
|
|
247
|
+
targetType: "vault-secret",
|
|
248
|
+
targetId: secretId,
|
|
249
|
+
summary: `Deleted vault secret "${existing.name}" (${existing.credentialKey})`,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
return existing;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ─── Grants ──────────────────────────────────────────────────────
|
|
256
|
+
|
|
257
|
+
export async function listGrants(filter?: {
|
|
258
|
+
secretId?: string;
|
|
259
|
+
appId?: string;
|
|
260
|
+
}) {
|
|
261
|
+
const db = getDb();
|
|
262
|
+
const conditions = [orgFilter(schema.vaultGrants)];
|
|
263
|
+
if (filter?.secretId) {
|
|
264
|
+
conditions.push(eq(schema.vaultGrants.secretId, filter.secretId) as any);
|
|
265
|
+
}
|
|
266
|
+
if (filter?.appId) {
|
|
267
|
+
conditions.push(eq(schema.vaultGrants.appId, filter.appId) as any);
|
|
268
|
+
}
|
|
269
|
+
return db
|
|
270
|
+
.select()
|
|
271
|
+
.from(schema.vaultGrants)
|
|
272
|
+
.where(and(...conditions))
|
|
273
|
+
.orderBy(desc(schema.vaultGrants.updatedAt));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export async function getGrant(
|
|
277
|
+
grantId: string,
|
|
278
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
279
|
+
) {
|
|
280
|
+
const db = getDb();
|
|
281
|
+
const [row] = await db
|
|
282
|
+
.select()
|
|
283
|
+
.from(schema.vaultGrants)
|
|
284
|
+
.where(
|
|
285
|
+
and(
|
|
286
|
+
eq(schema.vaultGrants.id, grantId),
|
|
287
|
+
ctxScope(schema.vaultGrants, ctx),
|
|
288
|
+
),
|
|
289
|
+
)
|
|
290
|
+
.limit(1);
|
|
291
|
+
return row ?? null;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export async function createGrant(
|
|
295
|
+
secretId: string,
|
|
296
|
+
appId: string,
|
|
297
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
298
|
+
) {
|
|
299
|
+
const db = getDb();
|
|
300
|
+
const secret = await getSecret(secretId, ctx);
|
|
301
|
+
if (!secret) throw new Error("Secret not found");
|
|
302
|
+
|
|
303
|
+
const timestamp = now();
|
|
304
|
+
const grantId = id();
|
|
305
|
+
const actor = ctx.ownerEmail;
|
|
306
|
+
|
|
307
|
+
await db.insert(schema.vaultGrants).values({
|
|
308
|
+
id: grantId,
|
|
309
|
+
ownerEmail: actor,
|
|
310
|
+
orgId: ctx.orgId,
|
|
311
|
+
secretId,
|
|
312
|
+
appId,
|
|
313
|
+
grantedBy: actor,
|
|
314
|
+
status: "active",
|
|
315
|
+
syncedAt: null,
|
|
316
|
+
createdAt: timestamp,
|
|
317
|
+
updatedAt: timestamp,
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
await recordVaultAudit({
|
|
321
|
+
action: "grant.created",
|
|
322
|
+
secretId,
|
|
323
|
+
appId,
|
|
324
|
+
summary: `Granted "${secret.name}" (${secret.credentialKey}) to ${appId}`,
|
|
325
|
+
metadata: { grantId },
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
await recordAudit({
|
|
329
|
+
action: "vault.grant.created",
|
|
330
|
+
targetType: "vault-grant",
|
|
331
|
+
targetId: grantId,
|
|
332
|
+
summary: `Granted vault secret "${secret.name}" to ${appId}`,
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
return getGrant(grantId);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export async function grantSecretsToApp(
|
|
339
|
+
secretIds: string[],
|
|
340
|
+
appId: string,
|
|
341
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
342
|
+
) {
|
|
343
|
+
const uniqueSecretIds = Array.from(new Set(secretIds));
|
|
344
|
+
const existingActive = (await listGrants({ appId })).filter(
|
|
345
|
+
(grant) => grant.status === "active",
|
|
346
|
+
);
|
|
347
|
+
const existingSecretIds = new Set(
|
|
348
|
+
existingActive.map((grant) => grant.secretId),
|
|
349
|
+
);
|
|
350
|
+
const created = [];
|
|
351
|
+
const skipped: string[] = [];
|
|
352
|
+
|
|
353
|
+
for (const secretId of uniqueSecretIds) {
|
|
354
|
+
if (existingSecretIds.has(secretId)) {
|
|
355
|
+
skipped.push(secretId);
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
const grant = await createGrant(secretId, appId, ctx);
|
|
359
|
+
if (grant) {
|
|
360
|
+
created.push(grant);
|
|
361
|
+
existingSecretIds.add(secretId);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return { appId, created, skipped };
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export async function revokeGrant(
|
|
369
|
+
grantId: string,
|
|
370
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
371
|
+
) {
|
|
372
|
+
const db = getDb();
|
|
373
|
+
const grant = await getGrant(grantId, ctx);
|
|
374
|
+
if (!grant) throw new Error("Grant not found");
|
|
375
|
+
|
|
376
|
+
const secret = await getSecret(grant.secretId, ctx);
|
|
377
|
+
|
|
378
|
+
await db
|
|
379
|
+
.update(schema.vaultGrants)
|
|
380
|
+
.set({ status: "revoked", updatedAt: now() })
|
|
381
|
+
.where(
|
|
382
|
+
and(
|
|
383
|
+
eq(schema.vaultGrants.id, grantId),
|
|
384
|
+
ctxScope(schema.vaultGrants, ctx),
|
|
385
|
+
),
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
await recordVaultAudit({
|
|
389
|
+
action: "grant.revoked",
|
|
390
|
+
secretId: grant.secretId,
|
|
391
|
+
appId: grant.appId,
|
|
392
|
+
summary: `Revoked ${secret?.credentialKey || grant.secretId} from ${grant.appId}`,
|
|
393
|
+
metadata: { grantId },
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
await recordAudit({
|
|
397
|
+
action: "vault.grant.revoked",
|
|
398
|
+
targetType: "vault-grant",
|
|
399
|
+
targetId: grantId,
|
|
400
|
+
summary: `Revoked vault secret "${secret?.name || grant.secretId}" from ${grant.appId}`,
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
return getGrant(grantId, ctx);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// ─── Sync ──────────────────────────────────────────────────────
|
|
407
|
+
|
|
408
|
+
export async function syncGrantsToApp(
|
|
409
|
+
appId: string,
|
|
410
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
411
|
+
) {
|
|
412
|
+
const db = getDb();
|
|
413
|
+
const agents = await discoverAgents("dispatch");
|
|
414
|
+
const agent = agents.find((a) => a.id === appId);
|
|
415
|
+
if (!agent) throw new Error(`App "${appId}" not found in agent registry`);
|
|
416
|
+
|
|
417
|
+
const grants = await listGrants({ appId });
|
|
418
|
+
const activeGrants = grants.filter((g) => g.status === "active");
|
|
419
|
+
if (activeGrants.length === 0) {
|
|
420
|
+
return { appId, synced: 0, keys: [] };
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Resolve secret values for each grant
|
|
424
|
+
const vars: Array<{ key: string; value: string }> = [];
|
|
425
|
+
for (const grant of activeGrants) {
|
|
426
|
+
const secret = await getSecret(grant.secretId, ctx);
|
|
427
|
+
if (secret) {
|
|
428
|
+
vars.push({ key: secret.credentialKey, value: secret.value });
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (vars.length === 0) {
|
|
433
|
+
return { appId, synced: 0, keys: [] };
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// Push to the app's env-vars endpoint
|
|
437
|
+
const res = await fetch(`${agent.url}/_agent-native/env-vars`, {
|
|
438
|
+
method: "POST",
|
|
439
|
+
headers: { "Content-Type": "application/json" },
|
|
440
|
+
body: JSON.stringify({ vars }),
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
if (!res.ok) {
|
|
444
|
+
const err = await res.text().catch(() => "Unknown error");
|
|
445
|
+
throw new Error(`Failed to sync to ${appId}: ${err}`);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const result = await res.json();
|
|
449
|
+
const syncedKeys: string[] = result.saved || [];
|
|
450
|
+
const timestamp = now();
|
|
451
|
+
|
|
452
|
+
// Update syncedAt on grants that were successfully pushed
|
|
453
|
+
for (const grant of activeGrants) {
|
|
454
|
+
const secret = await getSecret(grant.secretId, ctx);
|
|
455
|
+
if (secret && syncedKeys.includes(secret.credentialKey)) {
|
|
456
|
+
await db
|
|
457
|
+
.update(schema.vaultGrants)
|
|
458
|
+
.set({ syncedAt: timestamp, updatedAt: timestamp })
|
|
459
|
+
.where(eq(schema.vaultGrants.id, grant.id));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
await recordVaultAudit({
|
|
464
|
+
action: "secret.synced",
|
|
465
|
+
appId,
|
|
466
|
+
summary: `Synced ${syncedKeys.length} secret(s) to ${appId}: ${syncedKeys.join(", ")}`,
|
|
467
|
+
metadata: { syncedKeys },
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
return { appId, synced: syncedKeys.length, keys: syncedKeys };
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// ─── Requests ──────────────────────────────────────────────────────
|
|
474
|
+
|
|
475
|
+
export async function listRequests(filter?: { status?: string }) {
|
|
476
|
+
const db = getDb();
|
|
477
|
+
const conditions = [orgFilter(schema.vaultRequests)];
|
|
478
|
+
if (filter?.status) {
|
|
479
|
+
conditions.push(eq(schema.vaultRequests.status, filter.status) as any);
|
|
480
|
+
}
|
|
481
|
+
return db
|
|
482
|
+
.select()
|
|
483
|
+
.from(schema.vaultRequests)
|
|
484
|
+
.where(and(...conditions))
|
|
485
|
+
.orderBy(desc(schema.vaultRequests.updatedAt));
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export async function getRequest(
|
|
489
|
+
requestId: string,
|
|
490
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
491
|
+
) {
|
|
492
|
+
const db = getDb();
|
|
493
|
+
const [row] = await db
|
|
494
|
+
.select()
|
|
495
|
+
.from(schema.vaultRequests)
|
|
496
|
+
.where(
|
|
497
|
+
and(
|
|
498
|
+
eq(schema.vaultRequests.id, requestId),
|
|
499
|
+
ctxScope(schema.vaultRequests, ctx),
|
|
500
|
+
),
|
|
501
|
+
)
|
|
502
|
+
.limit(1);
|
|
503
|
+
return row ?? null;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export async function createRequest(input: {
|
|
507
|
+
credentialKey: string;
|
|
508
|
+
appId: string;
|
|
509
|
+
reason?: string | null;
|
|
510
|
+
}) {
|
|
511
|
+
const db = getDb();
|
|
512
|
+
const timestamp = now();
|
|
513
|
+
const requestId = id();
|
|
514
|
+
const actor = currentOwnerEmail();
|
|
515
|
+
|
|
516
|
+
await db.insert(schema.vaultRequests).values({
|
|
517
|
+
id: requestId,
|
|
518
|
+
ownerEmail: actor,
|
|
519
|
+
orgId: currentOrgId(),
|
|
520
|
+
credentialKey: input.credentialKey,
|
|
521
|
+
appId: input.appId,
|
|
522
|
+
reason: input.reason || null,
|
|
523
|
+
requestedBy: actor,
|
|
524
|
+
status: "pending",
|
|
525
|
+
reviewedBy: null,
|
|
526
|
+
reviewedAt: null,
|
|
527
|
+
createdAt: timestamp,
|
|
528
|
+
updatedAt: timestamp,
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
await recordVaultAudit({
|
|
532
|
+
action: "request.created",
|
|
533
|
+
appId: input.appId,
|
|
534
|
+
summary: `${actor} requested ${input.credentialKey} for ${input.appId}`,
|
|
535
|
+
metadata: { requestId, reason: input.reason },
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
await notifyAdminsOfRequest(requestId, input);
|
|
539
|
+
|
|
540
|
+
return getRequest(requestId);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export async function approveRequest(
|
|
544
|
+
requestId: string,
|
|
545
|
+
secretValue: string,
|
|
546
|
+
secretName?: string,
|
|
547
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
548
|
+
) {
|
|
549
|
+
const db = getDb();
|
|
550
|
+
const request = await getRequest(requestId, ctx);
|
|
551
|
+
if (!request) throw new Error("Request not found");
|
|
552
|
+
if (request.status !== "pending") {
|
|
553
|
+
throw new Error("Only pending requests can be approved");
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
const timestamp = now();
|
|
557
|
+
const reviewer = ctx.ownerEmail;
|
|
558
|
+
|
|
559
|
+
// Update request status — scoped to caller's tenant.
|
|
560
|
+
await db
|
|
561
|
+
.update(schema.vaultRequests)
|
|
562
|
+
.set({
|
|
563
|
+
status: "approved",
|
|
564
|
+
reviewedBy: reviewer,
|
|
565
|
+
reviewedAt: timestamp,
|
|
566
|
+
updatedAt: timestamp,
|
|
567
|
+
})
|
|
568
|
+
.where(
|
|
569
|
+
and(
|
|
570
|
+
eq(schema.vaultRequests.id, requestId),
|
|
571
|
+
ctxScope(schema.vaultRequests, ctx),
|
|
572
|
+
),
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
// Secret + grant must land in the REQUEST's tenant, not the approver's
|
|
576
|
+
// (the approver may be acting on behalf of another user in the same org).
|
|
577
|
+
const requestCtx = ctxForRow(request);
|
|
578
|
+
|
|
579
|
+
// Check if secret already exists in the request's tenant for this key.
|
|
580
|
+
const existingSecrets = await db
|
|
581
|
+
.select()
|
|
582
|
+
.from(schema.vaultSecrets)
|
|
583
|
+
.where(
|
|
584
|
+
and(
|
|
585
|
+
eq(schema.vaultSecrets.credentialKey, request.credentialKey),
|
|
586
|
+
ctxScope(schema.vaultSecrets, requestCtx),
|
|
587
|
+
),
|
|
588
|
+
);
|
|
589
|
+
let secret = existingSecrets[0] ?? null;
|
|
590
|
+
|
|
591
|
+
if (!secret) {
|
|
592
|
+
secret = await createSecret(
|
|
593
|
+
{
|
|
594
|
+
credentialKey: request.credentialKey,
|
|
595
|
+
value: secretValue,
|
|
596
|
+
name: secretName || request.credentialKey,
|
|
597
|
+
},
|
|
598
|
+
requestCtx,
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (secret) {
|
|
603
|
+
// Create the grant in the request's tenant as well.
|
|
604
|
+
await createGrant(secret.id, request.appId, requestCtx);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
await recordVaultAudit({
|
|
608
|
+
action: "request.approved",
|
|
609
|
+
appId: request.appId,
|
|
610
|
+
summary: `Approved ${request.credentialKey} for ${request.appId} (requested by ${request.requestedBy})`,
|
|
611
|
+
metadata: { requestId, reviewer },
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
return getRequest(requestId, ctx);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export async function denyRequest(
|
|
618
|
+
requestId: string,
|
|
619
|
+
reason?: string | null,
|
|
620
|
+
ctx: VaultCtx = requireVaultCtx(),
|
|
621
|
+
) {
|
|
622
|
+
const db = getDb();
|
|
623
|
+
const request = await getRequest(requestId, ctx);
|
|
624
|
+
if (!request) throw new Error("Request not found");
|
|
625
|
+
if (request.status !== "pending") {
|
|
626
|
+
throw new Error("Only pending requests can be denied");
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
const timestamp = now();
|
|
630
|
+
const reviewer = ctx.ownerEmail;
|
|
631
|
+
|
|
632
|
+
await db
|
|
633
|
+
.update(schema.vaultRequests)
|
|
634
|
+
.set({
|
|
635
|
+
status: "denied",
|
|
636
|
+
reviewedBy: reviewer,
|
|
637
|
+
reviewedAt: timestamp,
|
|
638
|
+
updatedAt: timestamp,
|
|
639
|
+
})
|
|
640
|
+
.where(
|
|
641
|
+
and(
|
|
642
|
+
eq(schema.vaultRequests.id, requestId),
|
|
643
|
+
ctxScope(schema.vaultRequests, ctx),
|
|
644
|
+
),
|
|
645
|
+
);
|
|
646
|
+
|
|
647
|
+
await recordVaultAudit({
|
|
648
|
+
action: "request.denied",
|
|
649
|
+
appId: request.appId,
|
|
650
|
+
summary: `Denied ${request.credentialKey} for ${request.appId} (requested by ${request.requestedBy})`,
|
|
651
|
+
metadata: { requestId, reviewer, reason },
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
return getRequest(requestId, ctx);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// ─── Integrations Catalog ────────────────────────────────────────
|
|
658
|
+
|
|
659
|
+
export interface IntegrationEntry {
|
|
660
|
+
key: string;
|
|
661
|
+
label: string;
|
|
662
|
+
required: boolean;
|
|
663
|
+
configured: boolean;
|
|
664
|
+
vaultGranted: boolean;
|
|
665
|
+
vaultSecretId?: string;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
export interface AppIntegrations {
|
|
669
|
+
appId: string;
|
|
670
|
+
appName: string;
|
|
671
|
+
url: string;
|
|
672
|
+
color: string;
|
|
673
|
+
integrations: IntegrationEntry[];
|
|
674
|
+
reachable: boolean;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
export async function listIntegrationsCatalog(): Promise<AppIntegrations[]> {
|
|
678
|
+
const agents = await discoverAgents("dispatch");
|
|
679
|
+
const grants = await listGrants();
|
|
680
|
+
const secrets = await listSecrets();
|
|
681
|
+
|
|
682
|
+
const secretByKey = new Map(secrets.map((s) => [s.credentialKey, s]));
|
|
683
|
+
|
|
684
|
+
const results: AppIntegrations[] = [];
|
|
685
|
+
|
|
686
|
+
for (const agent of agents) {
|
|
687
|
+
try {
|
|
688
|
+
const res = await fetch(`${agent.url}/_agent-native/env-status`, {
|
|
689
|
+
signal: AbortSignal.timeout(3000),
|
|
690
|
+
});
|
|
691
|
+
if (!res.ok) {
|
|
692
|
+
results.push({
|
|
693
|
+
appId: agent.id,
|
|
694
|
+
appName: agent.name,
|
|
695
|
+
url: agent.url,
|
|
696
|
+
color: agent.color,
|
|
697
|
+
integrations: [],
|
|
698
|
+
reachable: false,
|
|
699
|
+
});
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
const envStatus: Array<{
|
|
704
|
+
key: string;
|
|
705
|
+
label: string;
|
|
706
|
+
required: boolean;
|
|
707
|
+
configured: boolean;
|
|
708
|
+
}> = await res.json();
|
|
709
|
+
|
|
710
|
+
const appGrants = grants.filter(
|
|
711
|
+
(g) => g.appId === agent.id && g.status === "active",
|
|
712
|
+
);
|
|
713
|
+
const grantedSecretIds = new Set(appGrants.map((g) => g.secretId));
|
|
714
|
+
|
|
715
|
+
const integrations: IntegrationEntry[] = envStatus.map((env) => {
|
|
716
|
+
const matchingSecret = secretByKey.get(env.key);
|
|
717
|
+
return {
|
|
718
|
+
key: env.key,
|
|
719
|
+
label: env.label,
|
|
720
|
+
required: env.required,
|
|
721
|
+
configured: env.configured,
|
|
722
|
+
vaultGranted:
|
|
723
|
+
!!matchingSecret && grantedSecretIds.has(matchingSecret.id),
|
|
724
|
+
vaultSecretId: matchingSecret?.id,
|
|
725
|
+
};
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
results.push({
|
|
729
|
+
appId: agent.id,
|
|
730
|
+
appName: agent.name,
|
|
731
|
+
url: agent.url,
|
|
732
|
+
color: agent.color,
|
|
733
|
+
integrations,
|
|
734
|
+
reachable: true,
|
|
735
|
+
});
|
|
736
|
+
} catch {
|
|
737
|
+
results.push({
|
|
738
|
+
appId: agent.id,
|
|
739
|
+
appName: agent.name,
|
|
740
|
+
url: agent.url,
|
|
741
|
+
color: agent.color,
|
|
742
|
+
integrations: [],
|
|
743
|
+
reachable: false,
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return results;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// ─── Vault Overview (for dashboard) ──────────────────────────────
|
|
752
|
+
|
|
753
|
+
export async function listVaultOverview() {
|
|
754
|
+
const [secrets, grants, requests] = await Promise.all([
|
|
755
|
+
listSecrets(),
|
|
756
|
+
listGrants(),
|
|
757
|
+
listRequests(),
|
|
758
|
+
]);
|
|
759
|
+
|
|
760
|
+
return {
|
|
761
|
+
secretCount: secrets.length,
|
|
762
|
+
activeGrantCount: grants.filter((g) => g.status === "active").length,
|
|
763
|
+
pendingRequestCount: requests.filter((r) => r.status === "pending").length,
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// ─── SendGrid Notifications ──────────────────────────────────────
|
|
768
|
+
|
|
769
|
+
async function notifyAdminsOfRequest(
|
|
770
|
+
requestId: string,
|
|
771
|
+
input: { credentialKey: string; appId: string; reason?: string | null },
|
|
772
|
+
) {
|
|
773
|
+
const apiKey = process.env.SENDGRID_API_KEY;
|
|
774
|
+
const from = process.env.SENDGRID_FROM_EMAIL;
|
|
775
|
+
const appUrl = process.env.APP_URL;
|
|
776
|
+
if (!apiKey || !from || !appUrl) return;
|
|
777
|
+
|
|
778
|
+
// Use approval policy approver emails as admin notification targets
|
|
779
|
+
const { getApprovalPolicy } = await import("./dispatch-store.js");
|
|
780
|
+
const policy = await getApprovalPolicy();
|
|
781
|
+
if (policy.approverEmails.length === 0) return;
|
|
782
|
+
|
|
783
|
+
const body = [
|
|
784
|
+
`Secret request: ${input.credentialKey} for ${input.appId}`,
|
|
785
|
+
input.reason ? `Reason: ${input.reason}` : "",
|
|
786
|
+
`Requested by: ${currentOwnerEmail()}`,
|
|
787
|
+
"",
|
|
788
|
+
`Review it here: ${appUrl}/vault`,
|
|
789
|
+
]
|
|
790
|
+
.filter(Boolean)
|
|
791
|
+
.join("\n");
|
|
792
|
+
|
|
793
|
+
await fetch("https://api.sendgrid.com/v3/mail/send", {
|
|
794
|
+
method: "POST",
|
|
795
|
+
headers: {
|
|
796
|
+
Authorization: `Bearer ${apiKey}`,
|
|
797
|
+
"Content-Type": "application/json",
|
|
798
|
+
},
|
|
799
|
+
body: JSON.stringify({
|
|
800
|
+
personalizations: [
|
|
801
|
+
{
|
|
802
|
+
to: policy.approverEmails.map((email) => ({ email })),
|
|
803
|
+
subject: `Vault request: ${input.credentialKey} for ${input.appId}`,
|
|
804
|
+
},
|
|
805
|
+
],
|
|
806
|
+
from: { email: from },
|
|
807
|
+
content: [{ type: "text/plain", value: body }],
|
|
808
|
+
custom_args: { requestId },
|
|
809
|
+
}),
|
|
810
|
+
}).catch(() => {});
|
|
811
|
+
}
|