@agent-native/dispatch 0.42.7-nightly-20261113032548 → 0.42.7
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/CHANGELOG.md +5 -12
- package/README.md +20 -18
- package/dist/actions/create-vault-grant.d.ts +2 -1
- package/dist/actions/create-vault-secret.d.ts +1 -1
- package/dist/actions/create-vault-secret.js +2 -2
- package/dist/actions/create-vault-secret.js.map +1 -1
- package/dist/actions/grant-vault-secrets-to-app.d.ts +1 -0
- package/dist/actions/list-vault-grants.d.ts +1 -0
- package/dist/actions/list-vault-secret-options.js +1 -1
- package/dist/actions/list-vault-secret-options.js.map +1 -1
- package/dist/actions/list-vault-secrets.js +3 -5
- package/dist/actions/list-vault-secrets.js.map +1 -1
- package/dist/actions/revoke-vault-grant.d.ts +2 -1
- package/dist/actions/update-vault-secret.d.ts +1 -1
- package/dist/actions/update-vault-secret.js +2 -2
- package/dist/actions/update-vault-secret.js.map +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +19 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/schema.d.ts +8 -185
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +3 -13
- package/dist/db/schema.js.map +1 -1
- package/dist/routes/pages/vault.d.ts.map +1 -1
- package/dist/routes/pages/vault.js +1 -1
- package/dist/routes/pages/vault.js.map +1 -1
- package/dist/server/lib/vault-store.d.ts +67 -93
- package/dist/server/lib/vault-store.d.ts.map +1 -1
- package/dist/server/lib/vault-store.js +227 -280
- package/dist/server/lib/vault-store.js.map +1 -1
- package/dist/server/plugins/db.d.ts.map +1 -1
- package/dist/server/plugins/db.js +2 -0
- package/dist/server/plugins/db.js.map +1 -1
- package/package.json +4 -4
- package/src/actions/create-vault-secret.ts +2 -5
- package/src/actions/list-vault-secret-options.ts +1 -1
- package/src/actions/list-vault-secrets.ts +3 -8
- package/src/actions/update-vault-secret.ts +2 -6
- package/src/db/migrations.spec.ts +117 -1
- package/src/db/migrations.ts +19 -0
- package/src/db/schema.ts +3 -14
- package/src/routes/pages/vault.tsx +0 -4
- package/src/server/lib/vault-store.spec.ts +1188 -475
- package/src/server/lib/vault-store.ts +343 -405
- package/src/server/plugins/db.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# @agent-native/dispatch
|
|
2
2
|
|
|
3
|
-
## 0.42.7
|
|
3
|
+
## 0.42.7
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Release all public npm packages with a patch version bump.
|
|
8
|
+
- 77f6fe8: The Dispatch Vault now stores its keys only in `app_secrets` and no longer reads or writes `vault_secrets`. `app_secrets` gains nullable `label`, `provider` and `created_by` columns, and a key's id is its `app_secrets` row id. The Vault page lists the organization's keys (or your own solo workspace's), a key created or edited in the Vault is marked with `created_by`, and a rename moves the stored ciphertext with the row. `vault_grants` gains a nullable `credential_key`, which core's manual-mode check now reads instead of joining `vault_secrets`; grants from before this release grant nothing until `credential_key` is backfilled. The table stays in existing databases, untouched, until it is dropped. The new `guard:no-vault-secrets-table` fails when source reads or writes it.
|
|
9
|
+
- Updated dependencies
|
|
8
10
|
- Updated dependencies [75f2dbb]
|
|
9
|
-
- @agent-native/
|
|
10
|
-
- @agent-native/toolkit@0.228.2-nightly-20261113032548
|
|
11
|
+
- @agent-native/toolkit@0.228.2
|
|
11
12
|
|
|
12
13
|
## 0.42.6
|
|
13
14
|
|
|
@@ -1547,12 +1548,4 @@
|
|
|
1547
1548
|
|
|
1548
1549
|
- dc0978d: Fix action request context to use the forwarded workspace gateway origin instead of the internal dev proxy host.
|
|
1549
1550
|
|
|
1550
|
-
## 0.31.11
|
|
1551
|
-
|
|
1552
|
-
### Patch Changes
|
|
1553
|
-
|
|
1554
|
-
- e5e6934: Fix embedded workspace-app chat routes when the framework mount middleware strips the proxy prefix before dispatching the request.
|
|
1555
|
-
- dd80d09: Keep the full workspace credential workflow reachable from the redesigned integrations catalog.
|
|
1556
|
-
- e5e6934: Refresh integration and Dispatch app surfaces with connected-first layouts and two-column cards.
|
|
1557
|
-
|
|
1558
1551
|
For the full list of releases, see the [changelog archive](./changelog/archive/CHANGELOG.md).
|
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@ and cross-app delegation, shipped as a single drop-in package.
|
|
|
10
10
|
Powers the `dispatch` template. Provides:
|
|
11
11
|
|
|
12
12
|
- **Drizzle schemas** — destinations, identity links, link tokens, approval
|
|
13
|
-
requests, audit events, dream reports/proposals, vault
|
|
14
|
-
|
|
13
|
+
requests, audit events, dream reports/proposals, vault grants/requests/
|
|
14
|
+
audit, workspace resources/grants
|
|
15
15
|
- **Server layer** — `setupDispatch(config)` plus Nitro plugins for auth,
|
|
16
16
|
integrations, agent chat, DB, and core routes
|
|
17
17
|
- **Actions** — ~90 `defineAction` modules (vault grants/requests, workspace
|
|
@@ -90,21 +90,21 @@ file in the consumer's own `actions/` to override any single action.
|
|
|
90
90
|
|
|
91
91
|
## Exports
|
|
92
92
|
|
|
93
|
-
| Subpath | What it is
|
|
94
|
-
| ---------------------------------- |
|
|
95
|
-
| `.` | Shared config types only — `DispatchConfig`, `DispatchAuthConfig`, `DispatchIntegrationsConfig`. Import this where a type is needed without pulling in server/client code.
|
|
96
|
-
| `./routes` | `dispatchRoutes` — a programmatic `RouteConfig[]` covering every Dispatch page (chat, overview, metrics, operations, apps, vault, integrations, agents, workspace, messaging, destinations, identities, approvals, automations, audit, settings, dreams, extensions, thread-debug, team, and a workspace-app catch-all route).
|
|
97
|
-
| `./routes/pages/*` | Individual compiled page modules the routes above point at (e.g. `./routes/pages/vault.js`). Not normally imported directly.
|
|
98
|
-
| `./server` | `setupDispatch(config)` plus the Nitro plugin set: `dispatchAuthPlugin`, `dispatchIntegrationsPlugin`, `dispatchAgentChatPlugin`, `dispatchDbPlugin`, `dispatchCoreRoutesPlugin`. Importing this module also side-effect-registers all Dispatch actions.
|
|
99
|
-
| `./shared/feature-flags` | The default-off `DISPATCH_WORKSPACE_SSO_FLAG` definition used to target browser workspace sign-in safely.
|
|
100
|
-
| `./shared/workspace-sso` | Exact first-party workspace SSO origins and the additive custom registration parser shared by Dispatch and the identity hub.
|
|
101
|
-
| `./server/lib/thread-link-preview` | `loadThreadLinkPreview(threadId)` — server-only helper (reads request context and checks thread ownership) that builds link-preview metadata for shared thread URLs.
|
|
102
|
-
| `./actions` | `dispatchActions` — the flat name → `ActionEntry` map of every Dispatch action (vault, workspace resources, destinations, dream jobs, provider-api catalog/docs/request, connected agents, audit, approvals, platform messaging, and more).
|
|
103
|
-
| `./db` | `getDb()` / `db()`, the Drizzle `schema` namespace, the Dispatch table exports (`dispatchDestinations`, `dispatchIdentityLinks`, `dispatchLinkTokens`, `dispatchApprovalRequests`, `dispatchAuditEvents`, `dispatchDreams`, `dispatchDreamProposals`, `
|
|
104
|
-
| `./lib/thread-link-preview` | Isomorphic helpers behind the server one above — `extractThreadPreviewImageUrl`, `buildThreadLinkPreviewMeta`, and the `ThreadLinkPreview` type. Safe to import from client code.
|
|
105
|
-
| `./components` | Escape-hatch UI pieces for custom layouts: `DispatchShell`, `Layout`/`NavContent` (plus `DispatchExtensionConfig`/`DispatchNavIcon`/`DispatchNavItem`/`DispatchNavSection` types), `CreateAppPopover`/`CreateAppFlow`, `AppKeysPopover`. Most consumers only need `dispatchRoutes` and never import from here directly.
|
|
106
|
-
| `./components/ui/*` | The shadcn/ui primitive set Dispatch's own UI is built on (`button`, `dialog`, `dropdown-menu`, `card`, `command`, `calendar`, `chart`, ...), exported per-file so a consumer can reuse one primitive without pulling in the rest.
|
|
107
|
-
| `./styles/dispatch.css` | Tailwind layer with Dispatch-specific styles. Import once in the consumer's global CSS entry.
|
|
93
|
+
| Subpath | What it is |
|
|
94
|
+
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
95
|
+
| `.` | Shared config types only — `DispatchConfig`, `DispatchAuthConfig`, `DispatchIntegrationsConfig`. Import this where a type is needed without pulling in server/client code. |
|
|
96
|
+
| `./routes` | `dispatchRoutes` — a programmatic `RouteConfig[]` covering every Dispatch page (chat, overview, metrics, operations, apps, vault, integrations, agents, workspace, messaging, destinations, identities, approvals, automations, audit, settings, dreams, extensions, thread-debug, team, and a workspace-app catch-all route). |
|
|
97
|
+
| `./routes/pages/*` | Individual compiled page modules the routes above point at (e.g. `./routes/pages/vault.js`). Not normally imported directly. |
|
|
98
|
+
| `./server` | `setupDispatch(config)` plus the Nitro plugin set: `dispatchAuthPlugin`, `dispatchIntegrationsPlugin`, `dispatchAgentChatPlugin`, `dispatchDbPlugin`, `dispatchCoreRoutesPlugin`. Importing this module also side-effect-registers all Dispatch actions. |
|
|
99
|
+
| `./shared/feature-flags` | The default-off `DISPATCH_WORKSPACE_SSO_FLAG` definition used to target browser workspace sign-in safely. |
|
|
100
|
+
| `./shared/workspace-sso` | Exact first-party workspace SSO origins and the additive custom registration parser shared by Dispatch and the identity hub. |
|
|
101
|
+
| `./server/lib/thread-link-preview` | `loadThreadLinkPreview(threadId)` — server-only helper (reads request context and checks thread ownership) that builds link-preview metadata for shared thread URLs. |
|
|
102
|
+
| `./actions` | `dispatchActions` — the flat name → `ActionEntry` map of every Dispatch action (vault, workspace resources, destinations, dream jobs, provider-api catalog/docs/request, connected agents, audit, approvals, platform messaging, and more). |
|
|
103
|
+
| `./db` | `getDb()` / `db()`, the Drizzle `schema` namespace, the Dispatch table exports (`dispatchDestinations`, `dispatchIdentityLinks`, `dispatchLinkTokens`, `dispatchApprovalRequests`, `dispatchAuditEvents`, `dispatchDreams`, `dispatchDreamProposals`, `vaultGrants`, `vaultRequests`, `vaultAuditLog`, `workspaceResources`, `workspaceResourceGrants`), and migrations. |
|
|
104
|
+
| `./lib/thread-link-preview` | Isomorphic helpers behind the server one above — `extractThreadPreviewImageUrl`, `buildThreadLinkPreviewMeta`, and the `ThreadLinkPreview` type. Safe to import from client code. |
|
|
105
|
+
| `./components` | Escape-hatch UI pieces for custom layouts: `DispatchShell`, `Layout`/`NavContent` (plus `DispatchExtensionConfig`/`DispatchNavIcon`/`DispatchNavItem`/`DispatchNavSection` types), `CreateAppPopover`/`CreateAppFlow`, `AppKeysPopover`. Most consumers only need `dispatchRoutes` and never import from here directly. |
|
|
106
|
+
| `./components/ui/*` | The shadcn/ui primitive set Dispatch's own UI is built on (`button`, `dialog`, `dropdown-menu`, `card`, `command`, `calendar`, `chart`, ...), exported per-file so a consumer can reuse one primitive without pulling in the rest. |
|
|
107
|
+
| `./styles/dispatch.css` | Tailwind layer with Dispatch-specific styles. Import once in the consumer's global CSS entry. |
|
|
108
108
|
|
|
109
109
|
Hosts that compose the exported layout can brand its desktop and mobile
|
|
110
110
|
navigation together without forking Dispatch:
|
|
@@ -165,7 +165,9 @@ Dispatch is the workspace control plane sitting above individual template
|
|
|
165
165
|
apps:
|
|
166
166
|
|
|
167
167
|
- **Vault** — shared workspace secrets with a request → grant → audit flow,
|
|
168
|
-
scoped per app.
|
|
168
|
+
scoped per app. Each key is one encrypted row of the credential store
|
|
169
|
+
(`app_secrets`, owned by `@agent-native/core`); Dispatch's own tables hold
|
|
170
|
+
only grants, requests, and the audit log.
|
|
169
171
|
- **Workspace resources** — cross-app resources (e.g. shared instructions or
|
|
170
172
|
data) with explicit per-app grants and effective-context resolution.
|
|
171
173
|
- **Simple agents and agent packs** — reusable agents keep a Claude-compatible
|
|
@@ -6,12 +6,13 @@ declare const _default: import("@agent-native/core/action").ActionDefinition<{
|
|
|
6
6
|
ownerEmail: string;
|
|
7
7
|
orgId: string | null;
|
|
8
8
|
secretId: string;
|
|
9
|
+
credentialKey: string | null;
|
|
9
10
|
appId: string;
|
|
10
11
|
grantedBy: string;
|
|
11
12
|
status: string;
|
|
12
13
|
syncedAt: number | null;
|
|
13
14
|
createdAt: number;
|
|
14
15
|
updatedAt: number;
|
|
15
|
-
}>;
|
|
16
|
+
} | null>;
|
|
16
17
|
export default _default;
|
|
17
18
|
//# sourceMappingURL=create-vault-grant.d.ts.map
|
|
@@ -4,6 +4,6 @@ declare const _default: import("@agent-native/core/action").ActionDefinition<{
|
|
|
4
4
|
name: string;
|
|
5
5
|
provider?: string | undefined;
|
|
6
6
|
description?: string | undefined;
|
|
7
|
-
}, import("../server/lib/vault-store.js").VaultSecretMetadata
|
|
7
|
+
}, import("../server/lib/vault-store.js").VaultSecretMetadata>;
|
|
8
8
|
export default _default;
|
|
9
9
|
//# sourceMappingURL=create-vault-secret.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core/action";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { createSecret
|
|
3
|
+
import { createSecret } from "../server/lib/vault-store.js";
|
|
4
4
|
export default defineAction({
|
|
5
5
|
description: "Store a secret in the workspace vault. Admin only. Existing credential keys are updated. By default, saved vault keys are available to every workspace app; manual mode uses per-app grants.",
|
|
6
6
|
schema: z.object({
|
|
@@ -25,6 +25,6 @@ export default defineAction({
|
|
|
25
25
|
// call needs the user's approval, and "always allow" is not offered.
|
|
26
26
|
needsApproval: true,
|
|
27
27
|
allowPersistentApproval: false,
|
|
28
|
-
run: async (args) =>
|
|
28
|
+
run: async (args) => createSecret(args),
|
|
29
29
|
});
|
|
30
30
|
//# sourceMappingURL=create-vault-secret.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-vault-secret.js","sourceRoot":"","sources":["../../src/actions/create-vault-secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,
|
|
1
|
+
{"version":3,"file":"create-vault-secret.js","sourceRoot":"","sources":["../../src/actions/create-vault-secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,8LAA8L;IAChM,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,aAAa,EAAE,CAAC;aACb,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CAAC,kDAAkD,CAAC;QAC/D,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACrD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sCAAsC,CAAC;QACxE,QAAQ,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,qDAAqD,CAAC;QAClE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;KACpE,CAAC;IACF,2EAA2E;IAC3E,8EAA8E;IAC9E,yEAAyE;IACzE,4BAA4B;IAC5B,KAAK,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE;IAC9B,yEAAyE;IACzE,qEAAqE;IACrE,aAAa,EAAE,IAAI;IACnB,uBAAuB,EAAE,KAAK;IAC9B,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;CACxC,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core/action\";\nimport { z } from \"zod\";\n\nimport { createSecret } from \"../server/lib/vault-store.js\";\n\nexport default defineAction({\n description:\n \"Store a secret in the workspace vault. Admin only. Existing credential keys are updated. By default, saved vault keys are available to every workspace app; manual mode uses per-app grants.\",\n schema: z.object({\n credentialKey: z\n .string()\n .min(1)\n .describe(\"Environment variable name, e.g. GOOGLE_CLIENT_ID\"),\n value: z.string().min(1).describe(\"The secret value\"),\n name: z.string().min(1).describe(\"Human-readable label for this secret\"),\n provider: z\n .string()\n .optional()\n .describe(\"Provider grouping tag, e.g. google, sendgrid, slack\"),\n description: z.string().optional().describe(\"Optional description\"),\n }),\n // This action's whole purpose is to carry a secret `value`. The vault owns\n // secret storage; the audit log must record THAT a secret was created — never\n // the value. Opt out of input capture so the trail can't become a second\n // durable credential store.\n audit: { recordInputs: false },\n // It creates, changes, or revokes a credential or who may use one: every\n // call needs the user's approval, and \"always allow\" is not offered.\n needsApproval: true,\n allowPersistentApproval: false,\n run: async (args) => createSecret(args),\n});\n"]}
|
|
@@ -2,7 +2,7 @@ import { defineAction } from "@agent-native/core/action";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { listSecretOptions } from "../server/lib/vault-store.js";
|
|
4
4
|
export default defineAction({
|
|
5
|
-
description: "List vault secrets as safe picker options for creating a new app. Does not include secret values.",
|
|
5
|
+
description: "List vault secrets as safe picker options for creating a new app. Does not include secret values. Admins see every key in the vault; members see only keys the Vault manages.",
|
|
6
6
|
schema: z.object({}),
|
|
7
7
|
http: { method: "GET" },
|
|
8
8
|
run: async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-vault-secret-options.js","sourceRoot":"","sources":["../../src/actions/list-vault-secret-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT
|
|
1
|
+
{"version":3,"file":"list-vault-secret-options.js","sourceRoot":"","sources":["../../src/actions/list-vault-secret-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,+KAA+K;IACjL,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACpB,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;IACvB,GAAG,EAAE,KAAK,IAAI,EAAE;QACd,OAAO,iBAAiB,EAAE,CAAC;IAC7B,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core/action\";\nimport { z } from \"zod\";\n\nimport { listSecretOptions } from \"../server/lib/vault-store.js\";\n\nexport default defineAction({\n description:\n \"List vault secrets as safe picker options for creating a new app. Does not include secret values. Admins see every key in the vault; members see only keys the Vault manages.\",\n schema: z.object({}),\n http: { method: \"GET\" },\n run: async () => {\n return listSecretOptions();\n },\n});\n"]}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core/action";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { listSecrets
|
|
3
|
+
import { listSecrets } from "../server/lib/vault-store.js";
|
|
4
4
|
export default defineAction({
|
|
5
|
-
description: "List all secrets stored in the workspace vault. Admin only. Returns metadata, a masked last-four preview, and `valueStatus` (stored
|
|
5
|
+
description: "List all secrets stored in the workspace vault, including organization keys an app registered for itself. Admin only. Returns metadata, a masked last-four preview, and `valueStatus` (stored or unreadable) for each key; never returns secret values.",
|
|
6
6
|
schema: z.object({}),
|
|
7
7
|
http: { method: "GET" },
|
|
8
|
-
run: async () =>
|
|
9
|
-
return listVaultSecretMetadata(await listSecrets());
|
|
10
|
-
},
|
|
8
|
+
run: async () => listSecrets(),
|
|
11
9
|
});
|
|
12
10
|
//# sourceMappingURL=list-vault-secrets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-vault-secrets.js","sourceRoot":"","sources":["../../src/actions/list-vault-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,
|
|
1
|
+
{"version":3,"file":"list-vault-secrets.js","sourceRoot":"","sources":["../../src/actions/list-vault-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,yPAAyP;IAC3P,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACpB,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;IACvB,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,WAAW,EAAE;CAC/B,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core/action\";\nimport { z } from \"zod\";\n\nimport { listSecrets } from \"../server/lib/vault-store.js\";\n\nexport default defineAction({\n description:\n \"List all secrets stored in the workspace vault, including organization keys an app registered for itself. Admin only. Returns metadata, a masked last-four preview, and `valueStatus` (stored or unreadable) for each key; never returns secret values.\",\n schema: z.object({}),\n http: { method: \"GET\" },\n run: async () => listSecrets(),\n});\n"]}
|
|
@@ -5,12 +5,13 @@ declare const _default: import("@agent-native/core/action").ActionDefinition<{
|
|
|
5
5
|
ownerEmail: string;
|
|
6
6
|
orgId: string | null;
|
|
7
7
|
secretId: string;
|
|
8
|
+
credentialKey: string | null;
|
|
8
9
|
appId: string;
|
|
9
10
|
grantedBy: string;
|
|
10
11
|
status: string;
|
|
11
12
|
syncedAt: number | null;
|
|
12
13
|
createdAt: number;
|
|
13
14
|
updatedAt: number;
|
|
14
|
-
}>;
|
|
15
|
+
} | null>;
|
|
15
16
|
export default _default;
|
|
16
17
|
//# sourceMappingURL=revoke-vault-grant.d.ts.map
|
|
@@ -5,6 +5,6 @@ declare const _default: import("@agent-native/core/action").ActionDefinition<{
|
|
|
5
5
|
name?: string | undefined;
|
|
6
6
|
provider?: string | null | undefined;
|
|
7
7
|
description?: string | null | undefined;
|
|
8
|
-
}, import("../server/lib/vault-store.js").VaultSecretMetadata
|
|
8
|
+
}, import("../server/lib/vault-store.js").VaultSecretMetadata>;
|
|
9
9
|
export default _default;
|
|
10
10
|
//# sourceMappingURL=update-vault-secret.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core/action";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { updateSecret } from "../server/lib/vault-store.js";
|
|
4
4
|
export default defineAction({
|
|
5
5
|
description: "Update an existing vault secret's label, credential key, value, provider, or description. Admin only.",
|
|
6
6
|
schema: z
|
|
@@ -46,6 +46,6 @@ export default defineAction({
|
|
|
46
46
|
// call needs the user's approval, and "always allow" is not offered.
|
|
47
47
|
needsApproval: true,
|
|
48
48
|
allowPersistentApproval: false,
|
|
49
|
-
run: async (args) =>
|
|
49
|
+
run: async (args) => updateSecret(args.id, args),
|
|
50
50
|
});
|
|
51
51
|
//# sourceMappingURL=update-vault-secret.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-vault-secret.js","sourceRoot":"","sources":["../../src/actions/update-vault-secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,
|
|
1
|
+
{"version":3,"file":"update-vault-secret.js","sourceRoot":"","sources":["../../src/actions/update-vault-secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D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AAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC;CACjD,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core/action\";\nimport { z } from \"zod\";\n\nimport { updateSecret } from \"../server/lib/vault-store.js\";\n\nexport default defineAction({\n description:\n \"Update an existing vault secret's label, credential key, value, provider, or description. Admin only.\",\n schema: z\n .object({\n id: z.string().min(1).describe(\"Secret ID\"),\n credentialKey: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\"Environment variable name, e.g. GOOGLE_CLIENT_ID\"),\n value: z\n .string()\n .min(1)\n .optional()\n .describe(\"New secret value; omit to keep the existing value\"),\n name: z\n .string()\n .trim()\n .min(1)\n .optional()\n .describe(\"Human-readable label for this secret\"),\n provider: z\n .string()\n .nullable()\n .optional()\n .describe(\"Provider grouping tag, e.g. google, sendgrid, slack\"),\n description: z\n .string()\n .nullable()\n .optional()\n .describe(\"Optional description\"),\n })\n .refine(\n ({ credentialKey, value, name, provider, description }) =>\n credentialKey !== undefined ||\n value !== undefined ||\n name !== undefined ||\n provider !== undefined ||\n description !== undefined,\n \"At least one secret field must be updated\",\n ),\n // Carries a secret `value`. Record THAT the secret changed, never the value —\n // keep the audit trail from becoming a second credential store.\n audit: { recordInputs: false },\n // It creates, changes, or revokes a credential or who may use one: every\n // call needs the user's approval, and \"always allow\" is not offered.\n needsApproval: true,\n allowPersistentApproval: false,\n run: async (args) => updateSecret(args.id, args),\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAuDzE,eAAO,MAAM,kBAAkB,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAuDzE,eAAO,MAAM,kBAAkB,EAAE,cAAc,EA4U9C,CAAC"}
|
package/dist/db/migrations.js
CHANGED
|
@@ -356,5 +356,24 @@ export const dispatchMigrations = [
|
|
|
356
356
|
ADD COLUMN IF NOT EXISTS browser_binding_hash TEXT;
|
|
357
357
|
`,
|
|
358
358
|
},
|
|
359
|
+
{
|
|
360
|
+
version: 10,
|
|
361
|
+
name: "vault-grants-credential-key",
|
|
362
|
+
sql: `
|
|
363
|
+
ALTER TABLE IF EXISTS vault_grants ADD COLUMN IF NOT EXISTS credential_key TEXT;
|
|
364
|
+
DO $$
|
|
365
|
+
BEGIN
|
|
366
|
+
IF to_regclass('vault_secrets') IS NOT NULL
|
|
367
|
+
AND to_regclass('vault_grants') IS NOT NULL THEN
|
|
368
|
+
UPDATE vault_grants AS g
|
|
369
|
+
SET credential_key = s.credential_key
|
|
370
|
+
FROM vault_secrets AS s
|
|
371
|
+
WHERE g.credential_key IS NULL
|
|
372
|
+
AND s.id = g.secret_id
|
|
373
|
+
AND s.org_id = g.org_id;
|
|
374
|
+
END IF;
|
|
375
|
+
END $$;
|
|
376
|
+
`,
|
|
377
|
+
},
|
|
359
378
|
];
|
|
360
379
|
//# sourceMappingURL=migrations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAEA,MAAM,wBAAwB,GAA6B;IACzD,qBAAqB,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;IACnD,uBAAuB,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;IACrD,oBAAoB,EAAE;QACpB,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;KACb;IACD,0BAA0B,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,YAAY,CAAC;IACvE,qBAAqB,EAAE,CAAC,YAAY,CAAC;IACrC,eAA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;;;;;;;;;;;KAkBJ;KACF;IACD;QACE,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,wCAAwC;QAC9C,GAAG,EAAE;;;;;;;;;KASJ;QACD,GAAG,EAAE,6BAA6B;KACnC;IACD;QACE,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,4DAA4D;QAClE,GAAG,EAAE;;;;;;;;;KASJ;KACF;CACF,CAAC","sourcesContent":["import { type DbExec, type MigrationEntry } from \"@agent-native/core/db\";\n\nconst dispatchTimestampColumns: Record<string, string[]> = {\n dispatch_destinations: [\"created_at\", \"updated_at\"],\n dispatch_identity_links: [\"created_at\", \"updated_at\"],\n dispatch_link_tokens: [\n \"expires_at\",\n \"claimed_at\",\n \"created_at\",\n \"updated_at\",\n ],\n dispatch_approval_requests: [\"reviewed_at\", \"created_at\", \"updated_at\"],\n dispatch_audit_events: [\"created_at\"],\n dispatch_dreams: [\"started_at\", \"completed_at\", \"created_at\", \"updated_at\"],\n dispatch_dream_proposals: [\n \"applied_at\",\n \"rejected_at\",\n \"created_at\",\n \"updated_at\",\n ],\n vault_secrets: [\"created_at\", \"updated_at\"],\n vault_grants: [\"synced_at\", \"created_at\", \"updated_at\"],\n vault_requests: [\"reviewed_at\", \"created_at\", \"updated_at\"],\n vault_audit_log: [\"created_at\"],\n workspace_resources: [\"created_at\", \"updated_at\"],\n workspace_resource_grants: [\"synced_at\", \"created_at\", \"updated_at\"],\n identity_sso_authorization_code: [\"created_at\", \"expires_at\", \"consumed_at\"],\n identity_sso_bootstrap: [\"created_at\", \"expires_at\", \"consumed_at\"],\n};\n\nasync function widenLegacyDispatchTimestamps(exec: DbExec): Promise<void> {\n const tables = Object.keys(dispatchTimestampColumns);\n const { rows } = await exec.execute({\n sql: `SELECT table_name, column_name FROM information_schema.columns\n WHERE table_schema = 'public' AND data_type = 'integer'\n AND table_name IN (${tables.map(() => \"?\").join(\", \")})`,\n args: tables,\n });\n const int4Columns = new Set(\n rows.map((row) => `${String(row.table_name)}.${String(row.column_name)}`),\n );\n\n for (const [table, columns] of Object.entries(dispatchTimestampColumns)) {\n const legacyColumns = columns.filter((column) =>\n int4Columns.has(`${table}.${column}`),\n );\n if (legacyColumns.length === 0) continue;\n await exec.execute(\n `ALTER TABLE ${table} ${legacyColumns\n .map((column) => `ALTER COLUMN ${column} TYPE BIGINT`)\n .join(\", \")}`,\n );\n }\n}\n\nexport const dispatchMigrations: MigrationEntry[] = [\n {\n version: 1,\n sql: `\n CREATE TABLE IF NOT EXISTS dispatch_destinations (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n name TEXT NOT NULL,\n platform TEXT NOT NULL,\n destination TEXT NOT NULL,\n thread_ref TEXT,\n notes TEXT,\n created_by TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_identity_links (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n platform TEXT NOT NULL,\n external_user_id TEXT NOT NULL,\n external_user_name TEXT,\n linked_by TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_link_tokens (\n id TEXT PRIMARY KEY,\n token TEXT NOT NULL,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n platform TEXT NOT NULL,\n created_by TEXT NOT NULL,\n expires_at BIGINT NOT NULL,\n claimed_at BIGINT,\n claimed_by_external_user_id TEXT,\n claimed_by_external_user_name TEXT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_approval_requests (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n change_type TEXT NOT NULL,\n target_type TEXT NOT NULL,\n target_id TEXT,\n status TEXT NOT NULL,\n summary TEXT NOT NULL,\n payload TEXT NOT NULL,\n before_value TEXT,\n after_value TEXT,\n requested_by TEXT NOT NULL,\n reviewed_by TEXT,\n reviewed_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_audit_events (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n actor TEXT NOT NULL,\n action TEXT NOT NULL,\n target_type TEXT NOT NULL,\n target_id TEXT,\n summary TEXT NOT NULL,\n metadata TEXT,\n created_at BIGINT NOT NULL\n );\n `,\n },\n {\n version: 2,\n sql: `\n CREATE TABLE IF NOT EXISTS vault_secrets (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n name TEXT NOT NULL,\n credential_key TEXT NOT NULL,\n value TEXT NOT NULL,\n provider TEXT,\n description TEXT,\n created_by TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS vault_grants (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n secret_id TEXT NOT NULL,\n app_id TEXT NOT NULL,\n granted_by TEXT NOT NULL,\n status TEXT NOT NULL,\n synced_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS vault_requests (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n credential_key TEXT NOT NULL,\n app_id TEXT NOT NULL,\n reason TEXT,\n requested_by TEXT NOT NULL,\n status TEXT NOT NULL,\n reviewed_by TEXT,\n reviewed_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS vault_audit_log (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n secret_id TEXT,\n app_id TEXT,\n action TEXT NOT NULL,\n actor TEXT NOT NULL,\n summary TEXT NOT NULL,\n metadata TEXT,\n created_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS workspace_resources (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n kind TEXT NOT NULL,\n name TEXT NOT NULL,\n description TEXT,\n path TEXT NOT NULL,\n content TEXT NOT NULL,\n scope TEXT NOT NULL,\n created_by TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS workspace_resource_grants (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n resource_id TEXT NOT NULL,\n app_id TEXT NOT NULL,\n status TEXT NOT NULL,\n synced_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n `,\n },\n {\n version: 3,\n sql: `\n CREATE TABLE IF NOT EXISTS dispatch_dreams (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n source_id TEXT NOT NULL,\n title TEXT NOT NULL,\n status TEXT NOT NULL,\n query TEXT,\n report TEXT,\n summary TEXT,\n candidate_count INTEGER NOT NULL,\n inspected_thread_count INTEGER NOT NULL,\n created_by TEXT NOT NULL,\n error TEXT,\n started_at BIGINT NOT NULL,\n completed_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_dream_proposals (\n id TEXT PRIMARY KEY,\n dream_id TEXT NOT NULL,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n target_type TEXT NOT NULL,\n target_path TEXT NOT NULL,\n title TEXT NOT NULL,\n summary TEXT NOT NULL,\n rationale TEXT NOT NULL,\n content TEXT NOT NULL,\n evidence TEXT NOT NULL,\n confidence INTEGER NOT NULL,\n risk TEXT NOT NULL,\n status TEXT NOT NULL,\n applied_by TEXT,\n applied_at BIGINT,\n rejected_by TEXT,\n rejected_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS dispatch_dreams_owner_updated_idx\n ON dispatch_dreams (owner_email, org_id, updated_at);\n\n CREATE INDEX IF NOT EXISTS dispatch_dream_proposals_dream_status_idx\n ON dispatch_dream_proposals (dream_id, status);\n `,\n },\n {\n version: 4,\n sql: `\n ALTER TABLE dispatch_dreams ADD COLUMN IF NOT EXISTS source_health TEXT;\n `,\n },\n {\n version: 5,\n name: \"identity-sso-authorization-code-table\",\n sql: `\n CREATE TABLE IF NOT EXISTS identity_sso_authorization_code (\n code_hash TEXT PRIMARY KEY,\n state TEXT NOT NULL,\n app_id TEXT NOT NULL,\n client_id TEXT NOT NULL,\n redirect_uri TEXT NOT NULL,\n authority TEXT NOT NULL,\n code_challenge TEXT NOT NULL,\n email TEXT NOT NULL,\n name TEXT,\n org_domain TEXT,\n jti TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n expires_at BIGINT NOT NULL,\n consumed_at BIGINT,\n org_id TEXT,\n org_name TEXT,\n org_role TEXT\n );\n\n CREATE INDEX IF NOT EXISTS identity_sso_authorization_code_expires_idx\n ON identity_sso_authorization_code (expires_at);\n `,\n },\n {\n version: 6,\n name: \"dispatch-millisecond-timestamps-bigint-and-identity-sso-organization-claims\",\n sql: `\n ALTER TABLE identity_sso_authorization_code ADD COLUMN IF NOT EXISTS org_id TEXT;\n ALTER TABLE identity_sso_authorization_code ADD COLUMN IF NOT EXISTS org_name TEXT;\n ALTER TABLE identity_sso_authorization_code ADD COLUMN IF NOT EXISTS org_role TEXT;\n `,\n run: widenLegacyDispatchTimestamps,\n },\n {\n version: 7,\n name: \"identity-sso-bootstrap-handle-table\",\n sql: `\n CREATE TABLE IF NOT EXISTS identity_sso_bootstrap (\n handle_hash TEXT PRIMARY KEY,\n state TEXT NOT NULL,\n app_id TEXT NOT NULL,\n client_id TEXT NOT NULL,\n redirect_uri TEXT NOT NULL,\n authority TEXT NOT NULL,\n code_challenge TEXT NOT NULL,\n email TEXT NOT NULL,\n name TEXT,\n created_at BIGINT NOT NULL,\n expires_at BIGINT NOT NULL,\n consumed_at BIGINT\n );\n\n CREATE INDEX IF NOT EXISTS identity_sso_bootstrap_expires_idx\n ON identity_sso_bootstrap (expires_at);\n `,\n },\n {\n version: 8,\n name: \"identity-sso-pkce-bootstrap-activation\",\n sql: `\n ALTER TABLE identity_sso_authorization_code\n ADD COLUMN IF NOT EXISTS bootstrap_handle_hash TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS activation_hash TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS activation_expires_at BIGINT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS activated_at BIGINT;\n `,\n run: widenLegacyDispatchTimestamps,\n },\n {\n version: 9,\n name: \"identity-sso-bootstrap-browser-binding-and-rollout-context\",\n sql: `\n ALTER TABLE identity_sso_authorization_code\n ADD COLUMN IF NOT EXISTS bootstrap_auth_provider TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS org_id TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS auth_provider TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS browser_binding_hash TEXT;\n `,\n },\n];\n"]}
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAEA,MAAM,wBAAwB,GAA6B;IACzD,qBAAqB,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;IACnD,uBAAuB,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;IACrD,oBAAoB,EAAE;QACpB,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,YAAY;KACb;IACD,0BAA0B,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,YAAY,CAAC;IACvE,qBAAqB,EAAE,CAAC,YAAY,CAAC;IACrC,eAAe,EAAE,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,CAAC;IAC3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AE,wCAAwC;QAC9C,GAAG,EAAE;;;;;;;;;KASJ;QACD,GAAG,EAAE,6BAA6B;KACnC;IACD;QACE,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,4DAA4D;QAClE,GAAG,EAAE;;;;;;;;;KASJ;KACF;IACD;QACE,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,6BAA6B;QACnC,GAAG,EAAE;;;;;;;;;;;;;;KAcJ;KACF;CACF,CAAC","sourcesContent":["import { type DbExec, type MigrationEntry } from \"@agent-native/core/db\";\n\nconst dispatchTimestampColumns: Record<string, string[]> = {\n dispatch_destinations: [\"created_at\", \"updated_at\"],\n dispatch_identity_links: [\"created_at\", \"updated_at\"],\n dispatch_link_tokens: [\n \"expires_at\",\n \"claimed_at\",\n \"created_at\",\n \"updated_at\",\n ],\n dispatch_approval_requests: [\"reviewed_at\", \"created_at\", \"updated_at\"],\n dispatch_audit_events: [\"created_at\"],\n dispatch_dreams: [\"started_at\", \"completed_at\", \"created_at\", \"updated_at\"],\n dispatch_dream_proposals: [\n \"applied_at\",\n \"rejected_at\",\n \"created_at\",\n \"updated_at\",\n ],\n vault_secrets: [\"created_at\", \"updated_at\"],\n vault_grants: [\"synced_at\", \"created_at\", \"updated_at\"],\n vault_requests: [\"reviewed_at\", \"created_at\", \"updated_at\"],\n vault_audit_log: [\"created_at\"],\n workspace_resources: [\"created_at\", \"updated_at\"],\n workspace_resource_grants: [\"synced_at\", \"created_at\", \"updated_at\"],\n identity_sso_authorization_code: [\"created_at\", \"expires_at\", \"consumed_at\"],\n identity_sso_bootstrap: [\"created_at\", \"expires_at\", \"consumed_at\"],\n};\n\nasync function widenLegacyDispatchTimestamps(exec: DbExec): Promise<void> {\n const tables = Object.keys(dispatchTimestampColumns);\n const { rows } = await exec.execute({\n sql: `SELECT table_name, column_name FROM information_schema.columns\n WHERE table_schema = 'public' AND data_type = 'integer'\n AND table_name IN (${tables.map(() => \"?\").join(\", \")})`,\n args: tables,\n });\n const int4Columns = new Set(\n rows.map((row) => `${String(row.table_name)}.${String(row.column_name)}`),\n );\n\n for (const [table, columns] of Object.entries(dispatchTimestampColumns)) {\n const legacyColumns = columns.filter((column) =>\n int4Columns.has(`${table}.${column}`),\n );\n if (legacyColumns.length === 0) continue;\n await exec.execute(\n `ALTER TABLE ${table} ${legacyColumns\n .map((column) => `ALTER COLUMN ${column} TYPE BIGINT`)\n .join(\", \")}`,\n );\n }\n}\n\nexport const dispatchMigrations: MigrationEntry[] = [\n {\n version: 1,\n sql: `\n CREATE TABLE IF NOT EXISTS dispatch_destinations (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n name TEXT NOT NULL,\n platform TEXT NOT NULL,\n destination TEXT NOT NULL,\n thread_ref TEXT,\n notes TEXT,\n created_by TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_identity_links (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n platform TEXT NOT NULL,\n external_user_id TEXT NOT NULL,\n external_user_name TEXT,\n linked_by TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_link_tokens (\n id TEXT PRIMARY KEY,\n token TEXT NOT NULL,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n platform TEXT NOT NULL,\n created_by TEXT NOT NULL,\n expires_at BIGINT NOT NULL,\n claimed_at BIGINT,\n claimed_by_external_user_id TEXT,\n claimed_by_external_user_name TEXT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_approval_requests (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n change_type TEXT NOT NULL,\n target_type TEXT NOT NULL,\n target_id TEXT,\n status TEXT NOT NULL,\n summary TEXT NOT NULL,\n payload TEXT NOT NULL,\n before_value TEXT,\n after_value TEXT,\n requested_by TEXT NOT NULL,\n reviewed_by TEXT,\n reviewed_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_audit_events (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n actor TEXT NOT NULL,\n action TEXT NOT NULL,\n target_type TEXT NOT NULL,\n target_id TEXT,\n summary TEXT NOT NULL,\n metadata TEXT,\n created_at BIGINT NOT NULL\n );\n `,\n },\n {\n version: 2,\n sql: `\n CREATE TABLE IF NOT EXISTS vault_secrets (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n name TEXT NOT NULL,\n credential_key TEXT NOT NULL,\n value TEXT NOT NULL,\n provider TEXT,\n description TEXT,\n created_by TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS vault_grants (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n secret_id TEXT NOT NULL,\n app_id TEXT NOT NULL,\n granted_by TEXT NOT NULL,\n status TEXT NOT NULL,\n synced_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS vault_requests (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n credential_key TEXT NOT NULL,\n app_id TEXT NOT NULL,\n reason TEXT,\n requested_by TEXT NOT NULL,\n status TEXT NOT NULL,\n reviewed_by TEXT,\n reviewed_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS vault_audit_log (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n secret_id TEXT,\n app_id TEXT,\n action TEXT NOT NULL,\n actor TEXT NOT NULL,\n summary TEXT NOT NULL,\n metadata TEXT,\n created_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS workspace_resources (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n kind TEXT NOT NULL,\n name TEXT NOT NULL,\n description TEXT,\n path TEXT NOT NULL,\n content TEXT NOT NULL,\n scope TEXT NOT NULL,\n created_by TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS workspace_resource_grants (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n resource_id TEXT NOT NULL,\n app_id TEXT NOT NULL,\n status TEXT NOT NULL,\n synced_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n `,\n },\n {\n version: 3,\n sql: `\n CREATE TABLE IF NOT EXISTS dispatch_dreams (\n id TEXT PRIMARY KEY,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n source_id TEXT NOT NULL,\n title TEXT NOT NULL,\n status TEXT NOT NULL,\n query TEXT,\n report TEXT,\n summary TEXT,\n candidate_count INTEGER NOT NULL,\n inspected_thread_count INTEGER NOT NULL,\n created_by TEXT NOT NULL,\n error TEXT,\n started_at BIGINT NOT NULL,\n completed_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dispatch_dream_proposals (\n id TEXT PRIMARY KEY,\n dream_id TEXT NOT NULL,\n owner_email TEXT NOT NULL,\n org_id TEXT,\n target_type TEXT NOT NULL,\n target_path TEXT NOT NULL,\n title TEXT NOT NULL,\n summary TEXT NOT NULL,\n rationale TEXT NOT NULL,\n content TEXT NOT NULL,\n evidence TEXT NOT NULL,\n confidence INTEGER NOT NULL,\n risk TEXT NOT NULL,\n status TEXT NOT NULL,\n applied_by TEXT,\n applied_at BIGINT,\n rejected_by TEXT,\n rejected_at BIGINT,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS dispatch_dreams_owner_updated_idx\n ON dispatch_dreams (owner_email, org_id, updated_at);\n\n CREATE INDEX IF NOT EXISTS dispatch_dream_proposals_dream_status_idx\n ON dispatch_dream_proposals (dream_id, status);\n `,\n },\n {\n version: 4,\n sql: `\n ALTER TABLE dispatch_dreams ADD COLUMN IF NOT EXISTS source_health TEXT;\n `,\n },\n {\n version: 5,\n name: \"identity-sso-authorization-code-table\",\n sql: `\n CREATE TABLE IF NOT EXISTS identity_sso_authorization_code (\n code_hash TEXT PRIMARY KEY,\n state TEXT NOT NULL,\n app_id TEXT NOT NULL,\n client_id TEXT NOT NULL,\n redirect_uri TEXT NOT NULL,\n authority TEXT NOT NULL,\n code_challenge TEXT NOT NULL,\n email TEXT NOT NULL,\n name TEXT,\n org_domain TEXT,\n jti TEXT NOT NULL,\n created_at BIGINT NOT NULL,\n expires_at BIGINT NOT NULL,\n consumed_at BIGINT,\n org_id TEXT,\n org_name TEXT,\n org_role TEXT\n );\n\n CREATE INDEX IF NOT EXISTS identity_sso_authorization_code_expires_idx\n ON identity_sso_authorization_code (expires_at);\n `,\n },\n {\n version: 6,\n name: \"dispatch-millisecond-timestamps-bigint-and-identity-sso-organization-claims\",\n sql: `\n ALTER TABLE identity_sso_authorization_code ADD COLUMN IF NOT EXISTS org_id TEXT;\n ALTER TABLE identity_sso_authorization_code ADD COLUMN IF NOT EXISTS org_name TEXT;\n ALTER TABLE identity_sso_authorization_code ADD COLUMN IF NOT EXISTS org_role TEXT;\n `,\n run: widenLegacyDispatchTimestamps,\n },\n {\n version: 7,\n name: \"identity-sso-bootstrap-handle-table\",\n sql: `\n CREATE TABLE IF NOT EXISTS identity_sso_bootstrap (\n handle_hash TEXT PRIMARY KEY,\n state TEXT NOT NULL,\n app_id TEXT NOT NULL,\n client_id TEXT NOT NULL,\n redirect_uri TEXT NOT NULL,\n authority TEXT NOT NULL,\n code_challenge TEXT NOT NULL,\n email TEXT NOT NULL,\n name TEXT,\n created_at BIGINT NOT NULL,\n expires_at BIGINT NOT NULL,\n consumed_at BIGINT\n );\n\n CREATE INDEX IF NOT EXISTS identity_sso_bootstrap_expires_idx\n ON identity_sso_bootstrap (expires_at);\n `,\n },\n {\n version: 8,\n name: \"identity-sso-pkce-bootstrap-activation\",\n sql: `\n ALTER TABLE identity_sso_authorization_code\n ADD COLUMN IF NOT EXISTS bootstrap_handle_hash TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS activation_hash TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS activation_expires_at BIGINT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS activated_at BIGINT;\n `,\n run: widenLegacyDispatchTimestamps,\n },\n {\n version: 9,\n name: \"identity-sso-bootstrap-browser-binding-and-rollout-context\",\n sql: `\n ALTER TABLE identity_sso_authorization_code\n ADD COLUMN IF NOT EXISTS bootstrap_auth_provider TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS org_id TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS auth_provider TEXT;\n ALTER TABLE identity_sso_bootstrap\n ADD COLUMN IF NOT EXISTS browser_binding_hash TEXT;\n `,\n },\n {\n version: 10,\n name: \"vault-grants-credential-key\",\n sql: `\n ALTER TABLE IF EXISTS vault_grants ADD COLUMN IF NOT EXISTS credential_key TEXT;\n DO $$\n BEGIN\n IF to_regclass('vault_secrets') IS NOT NULL\n AND to_regclass('vault_grants') IS NOT NULL THEN\n UPDATE vault_grants AS g\n SET credential_key = s.credential_key\n FROM vault_secrets AS s\n WHERE g.credential_key IS NULL\n AND s.id = g.secret_id\n AND s.org_id = g.org_id;\n END IF;\n END $$;\n `,\n },\n];\n"]}
|