@intx/db 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -2
- package/dist/approval-store.d.ts +59 -0
- package/dist/approval-store.js +92 -0
- package/dist/asset-resolution.d.ts +2 -2
- package/dist/backfill-principal-keys.d.ts +9 -0
- package/dist/backfill-principal-keys.js +51 -0
- package/dist/client.d.ts +37 -2
- package/dist/client.js +6 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/connection.js +12 -8
- package/dist/credential-resolution.d.ts +181 -20
- package/dist/credential-resolution.js +251 -3
- package/dist/grant-store.js +35 -13
- package/dist/index.d.ts +20 -5
- package/dist/index.js +19 -5
- package/dist/model-source-resolution.d.ts +54 -7
- package/dist/model-source-resolution.js +177 -22
- package/dist/parse-row.d.ts +245 -34
- package/dist/parse-row.js +117 -18
- package/dist/principal-key-store.d.ts +51 -0
- package/dist/principal-key-store.js +82 -0
- package/dist/principal-store.d.ts +44 -0
- package/dist/principal-store.js +67 -0
- package/dist/rekey-credential-secrets.d.ts +13 -0
- package/dist/rekey-credential-secrets.js +61 -0
- package/dist/schema/approvals.d.ts +245 -0
- package/dist/schema/approvals.js +57 -0
- package/dist/schema/catalog.d.ts +17 -0
- package/dist/schema/catalog.js +7 -1
- package/dist/schema/credentials.d.ts +1 -1
- package/dist/schema/git-tokens.js +1 -1
- package/dist/schema/grants.js +8 -2
- package/dist/schema/index.d.ts +10 -4
- package/dist/schema/index.js +10 -4
- package/dist/schema/messages.d.ts +5 -5
- package/dist/schema/messages.js +20 -9
- package/dist/schema/offerings.js +8 -2
- package/dist/schema/{workflow-deployments.d.ts → principal-keys.d.ts} +29 -32
- package/dist/schema/principal-keys.js +28 -0
- package/dist/schema/principals.d.ts +2 -2
- package/dist/schema/principals.js +7 -5
- package/dist/schema/providers.d.ts +17 -0
- package/dist/schema/providers.js +5 -0
- package/dist/schema/roles.js +6 -2
- package/dist/schema/session-assets.d.ts +1 -38
- package/dist/schema/session-assets.js +36 -19
- package/dist/schema/sessions.js +7 -2
- package/dist/schema/sidecar-allocation.d.ts +385 -0
- package/dist/schema/sidecar-allocation.js +53 -0
- package/dist/schema/sidecar.d.ts +2 -2
- package/dist/schema/sidecar.js +3 -1
- package/dist/schema/signal-correlations.d.ts +177 -0
- package/dist/schema/signal-correlations.js +31 -0
- package/dist/schema/tenants.js +13 -3
- package/dist/schema/wallets.d.ts +3 -3
- package/dist/schema/wallets.js +4 -2
- package/dist/schema/{agents.d.ts → workflow-definitions.d.ts} +79 -113
- package/dist/schema/workflow-definitions.js +97 -0
- package/dist/schema/workflow-probe.d.ts +358 -0
- package/dist/schema/workflow-probe.js +51 -0
- package/dist/schema/workflow-run-dispatch.d.ts +345 -0
- package/dist/schema/workflow-run-dispatch.js +63 -0
- package/dist/schema/{agent-assets.d.ts → workflow-run-execution.d.ts} +44 -27
- package/dist/schema/workflow-run-execution.js +48 -0
- package/dist/schema/workflow-run-launch-spec.d.ts +200 -0
- package/dist/schema/workflow-run-launch-spec.js +26 -0
- package/dist/schema/{instances.d.ts → workflow-run.d.ts} +61 -66
- package/dist/schema/workflow-run.js +110 -0
- package/dist/sender-key-resolver.d.ts +91 -0
- package/dist/sender-key-resolver.js +184 -0
- package/dist/sidecar-allocation-store.d.ts +206 -0
- package/dist/sidecar-allocation-store.js +714 -0
- package/dist/signal-correlation-store.d.ts +36 -0
- package/dist/signal-correlation-store.js +63 -0
- package/dist/signer-identity.d.ts +12 -0
- package/dist/signer-identity.js +15 -0
- package/dist/tenant-hierarchy.d.ts +4 -1
- package/dist/tenant-hierarchy.js +37 -5
- package/dist/workflow-definition-store.d.ts +55 -0
- package/dist/workflow-definition-store.js +93 -0
- package/dist/workflow-probe-store.d.ts +47 -0
- package/dist/workflow-probe-store.js +124 -0
- package/dist/workflow-run-dispatch-store.d.ts +83 -0
- package/dist/workflow-run-dispatch-store.js +308 -0
- package/dist/workflow-run-launch-spec-store.d.ts +13 -0
- package/dist/workflow-run-launch-spec-store.js +30 -0
- package/dist/workflow-run-store.d.ts +54 -0
- package/dist/workflow-run-store.js +85 -0
- package/migrations/0037_credential_use_backfill.sql +39 -0
- package/migrations/0038_chilly_blacklash.sql +37 -0
- package/migrations/0039_quick_carnage.sql +2 -0
- package/migrations/0040_reshape_approval_origin.sql +24 -0
- package/migrations/0041_make_approval_timeout_at_nullable.sql +1 -0
- package/migrations/0042_youthful_mantis.sql +2 -0
- package/migrations/0043_signal_correlation_deployment_fk.sql +1 -0
- package/migrations/0044_model_offering_quirks.sql +1 -0
- package/migrations/0045_create_workflow_run.sql +13 -0
- package/migrations/0046_approval_signal_correlation_run_fk.sql +2 -0
- package/migrations/0047_create_workflow_definition.sql +30 -0
- package/migrations/0048_workflow_definition_origin_agent_id.sql +2 -0
- package/migrations/0049_curly_omega_flight.sql +2 -0
- package/migrations/0050_late_crystal.sql +10 -0
- package/migrations/0051_funny_madelyne_pryor.sql +1 -0
- package/migrations/0052_drop_inference_turn_instance_fk.sql +1 -0
- package/migrations/0053_session_mail_session_id_index.sql +1 -0
- package/migrations/0054_rekey_instance_grants_to_workflow_run.sql +10 -0
- package/migrations/0055_backfill_anchor_workflow_runs.sql +69 -0
- package/migrations/0056_repoint_deployment_fks_to_anchor_run.sql +32 -0
- package/migrations/0057_drop_workflow_deployment_projection.sql +22 -0
- package/migrations/0058_repoint_offering_fk_to_definition.sql +41 -0
- package/migrations/0059_repoint_transaction_fk_to_run.sql +10 -0
- package/migrations/0060_drop_session_mail_instance_fk.sql +6 -0
- package/migrations/0061_drop_session_asset_instance_fk.sql +7 -0
- package/migrations/0062_drop_agent_asset_table.sql +11 -0
- package/migrations/0063_repoint_agent_role_fk_to_definition.sql +39 -0
- package/migrations/0064_repoint_agent_session_fk_to_definition.sql +47 -0
- package/migrations/0065_add_workflow_definition_model_requirements.sql +37 -0
- package/migrations/0066_rekey_agent_definition_principals_to_workflow.sql +27 -0
- package/migrations/0067_add_workflow_definition_kind.sql +10 -0
- package/migrations/0068_drop_agent_tables_and_origin_agent_id.sql +31 -0
- package/migrations/0069_drop_workflow_definition_kind.sql +10 -0
- package/migrations/0070_flashy_proteus.sql +13 -0
- package/migrations/0072_add_workflow_definition_credential_bindings.sql +1 -0
- package/migrations/0073_grant_target_exactly_one_check.sql +13 -0
- package/migrations/0074_add_provider_api_base_url.sql +1 -0
- package/migrations/0075_workflow_run_launch_spec.sql +17 -0
- package/migrations/0076_sidecar_allocation.sql +40 -0
- package/migrations/0077_workflow_run_dispatch.sql +29 -0
- package/migrations/0078_workflow_run_dispatch_kind.sql +2 -0
- package/migrations/0079_rename_workflow_run_deployment_id_to_anchor_run_id.sql +4 -0
- package/migrations/0080_rename_correlation_approval_deployment_id_to_anchor_run_id.sql +9 -0
- package/migrations/0081_workflow_definition_content_hash_and_approved_wire_hash.sql +4 -0
- package/migrations/0082_blue_black_queen.sql +1 -0
- package/migrations/0083_replace_launch_spec_snapshot_with_frozen_bundle.sql +3 -0
- package/migrations/0084_delete_orphaned_credential_grants.sql +22 -0
- package/migrations/0085_add_approval_run_idx.sql +1 -0
- package/migrations/0086_cool_human_cannonball.sql +1 -0
- package/migrations/0087_drop_sidecar_placement.sql +3 -0
- package/migrations/0088_thick_sprite.sql +32 -0
- package/migrations/0089_tense_selene.sql +13 -0
- package/migrations/0090_tenant_domain_lower_unique.sql +2 -0
- package/migrations/0091_workflow_run_dispatch_sender_address.sql +21 -0
- package/migrations/0092_sidecar_destroy_failed.sql +4 -0
- package/migrations/0093_sidecar_initialization.sql +2 -0
- package/migrations/meta/0037_snapshot.json +3237 -0
- package/migrations/meta/0038_snapshot.json +3470 -0
- package/migrations/meta/0039_snapshot.json +3470 -0
- package/migrations/meta/0040_snapshot.json +3489 -0
- package/migrations/meta/0041_snapshot.json +3489 -0
- package/migrations/meta/0042_snapshot.json +3489 -0
- package/migrations/meta/0043_snapshot.json +3498 -0
- package/migrations/meta/0044_snapshot.json +3504 -0
- package/migrations/meta/0045_snapshot.json +3589 -0
- package/migrations/meta/0046_snapshot.json +3607 -0
- package/migrations/meta/0047_snapshot.json +3832 -0
- package/migrations/meta/0048_snapshot.json +3853 -0
- package/migrations/meta/0049_snapshot.json +3854 -0
- package/migrations/meta/0050_snapshot.json +3924 -0
- package/migrations/meta/0051_snapshot.json +3940 -0
- package/migrations/meta/0052_snapshot.json +3931 -0
- package/migrations/meta/0053_snapshot.json +3952 -0
- package/migrations/meta/0054_snapshot.json +3952 -0
- package/migrations/meta/0055_snapshot.json +3952 -0
- package/migrations/meta/0056_snapshot.json +3952 -0
- package/migrations/meta/0057_snapshot.json +3839 -0
- package/migrations/meta/0058_snapshot.json +3839 -0
- package/migrations/meta/0059_snapshot.json +3839 -0
- package/migrations/meta/0060_snapshot.json +3830 -0
- package/migrations/meta/0061_snapshot.json +3821 -0
- package/migrations/meta/0062_snapshot.json +3723 -0
- package/migrations/meta/0063_snapshot.json +3723 -0
- package/migrations/meta/0064_snapshot.json +3723 -0
- package/migrations/meta/0065_snapshot.json +3729 -0
- package/migrations/meta/0066_snapshot.json +3729 -0
- package/migrations/meta/0067_snapshot.json +3736 -0
- package/migrations/meta/0068_snapshot.json +3347 -0
- package/migrations/meta/0069_snapshot.json +3340 -0
- package/migrations/meta/0070_snapshot.json +3444 -0
- package/migrations/meta/0072_snapshot.json +3450 -0
- package/migrations/meta/0073_snapshot.json +3455 -0
- package/migrations/meta/0074_snapshot.json +3461 -0
- package/migrations/meta/0075_snapshot.json +3567 -0
- package/migrations/meta/0076_snapshot.json +3851 -0
- package/migrations/meta/0077_snapshot.json +4067 -0
- package/migrations/meta/0078_snapshot.json +4078 -0
- package/migrations/meta/0079_snapshot.json +4078 -0
- package/migrations/meta/0080_snapshot.json +4078 -0
- package/migrations/meta/0081_snapshot.json +4096 -0
- package/migrations/meta/0082_snapshot.json +4102 -0
- package/migrations/meta/0083_snapshot.json +4096 -0
- package/migrations/meta/0084_snapshot.json +4096 -0
- package/migrations/meta/0085_snapshot.json +4111 -0
- package/migrations/meta/0086_snapshot.json +4117 -0
- package/migrations/meta/0087_snapshot.json +4100 -0
- package/migrations/meta/0088_snapshot.json +4286 -0
- package/migrations/meta/0089_snapshot.json +4376 -0
- package/migrations/meta/0090_snapshot.json +4387 -0
- package/migrations/meta/0091_snapshot.json +4397 -0
- package/migrations/meta/0092_snapshot.json +4397 -0
- package/migrations/meta/0093_snapshot.json +4407 -0
- package/migrations/meta/_journal.json +392 -0
- package/package.json +7 -3
- package/dist/schema/agent-assets.js +0 -15
- package/dist/schema/agents.js +0 -57
- package/dist/schema/instances.js +0 -39
- package/dist/schema/workflow-deployments.js +0 -37
package/dist/schema/tenants.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import { foreignKey, jsonb, pgTable, text, timestamp, unique, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
2
3
|
export const tenant = pgTable("tenant", {
|
|
3
4
|
id: text("id").primaryKey(),
|
|
4
5
|
name: text("name").notNull(),
|
|
5
6
|
slug: text("slug").notNull().unique(),
|
|
6
|
-
|
|
7
|
+
// Unique on `lower(domain)`, not the raw column: an inbound mail `From` is
|
|
8
|
+
// lowercased when parsed, so a sender address must map to exactly one
|
|
9
|
+
// tenant. A case-sensitive unique would let case-variant domains coexist and
|
|
10
|
+
// let a case-variant registration shadow another tenant's senders. The
|
|
11
|
+
// creation boundary lowercases the domain; this index enforces it for every
|
|
12
|
+
// write path.
|
|
13
|
+
domain: text("domain").notNull(),
|
|
7
14
|
parentId: text("parent_id"),
|
|
8
15
|
config: jsonb("config"),
|
|
9
16
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
10
17
|
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
11
|
-
}, (t) => [
|
|
18
|
+
}, (t) => [
|
|
19
|
+
foreignKey({ columns: [t.parentId], foreignColumns: [t.id] }),
|
|
20
|
+
uniqueIndex("tenant_domain_lower_idx").on(sql `lower(${t.domain})`),
|
|
21
|
+
]);
|
|
12
22
|
export const federationTrust = pgTable("federation_trust", {
|
|
13
23
|
id: text("id").primaryKey(),
|
|
14
24
|
tenantId: text("tenant_id")
|
package/dist/schema/wallets.d.ts
CHANGED
|
@@ -196,8 +196,8 @@ export declare const transaction: import("drizzle-orm/pg-core").PgTableWithColum
|
|
|
196
196
|
identity: undefined;
|
|
197
197
|
generated: undefined;
|
|
198
198
|
}, {}, {}>;
|
|
199
|
-
|
|
200
|
-
name: "
|
|
199
|
+
runId: import("drizzle-orm/pg-core").PgColumn<{
|
|
200
|
+
name: "run_id";
|
|
201
201
|
tableName: "transaction";
|
|
202
202
|
dataType: "string";
|
|
203
203
|
columnType: "PgText";
|
|
@@ -320,7 +320,7 @@ export declare const transaction: import("drizzle-orm/pg-core").PgTableWithColum
|
|
|
320
320
|
tableName: "transaction";
|
|
321
321
|
dataType: "string";
|
|
322
322
|
columnType: "PgText";
|
|
323
|
-
data: "failed" | "
|
|
323
|
+
data: "failed" | "completed" | "pending";
|
|
324
324
|
driverParam: string;
|
|
325
325
|
notNull: true;
|
|
326
326
|
hasDefault: true;
|
package/dist/schema/wallets.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
2
|
-
import { agent } from "./agents.js";
|
|
3
2
|
import { tenant } from "./tenants.js";
|
|
3
|
+
import { workflowRun } from "./workflow-run.js";
|
|
4
4
|
export const wallet = pgTable("wallet", {
|
|
5
5
|
id: text("id").primaryKey(),
|
|
6
6
|
tenantId: text("tenant_id")
|
|
@@ -21,7 +21,9 @@ export const transaction = pgTable("transaction", {
|
|
|
21
21
|
walletId: text("wallet_id")
|
|
22
22
|
.notNull()
|
|
23
23
|
.references(() => wallet.id, { onDelete: "cascade" }),
|
|
24
|
-
|
|
24
|
+
// The run this ledger entry is attributed to. Nullable with set-null on
|
|
25
|
+
// delete: ledger history must survive deletion of the run it references.
|
|
26
|
+
runId: text("run_id").references(() => workflowRun.id, {
|
|
25
27
|
onDelete: "set null",
|
|
26
28
|
}),
|
|
27
29
|
direction: text("direction", {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
name: "
|
|
1
|
+
export declare const workflowDefinition: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "workflow_definition";
|
|
3
3
|
schema: undefined;
|
|
4
4
|
columns: {
|
|
5
5
|
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
6
|
name: "id";
|
|
7
|
-
tableName: "
|
|
7
|
+
tableName: "workflow_definition";
|
|
8
8
|
dataType: "string";
|
|
9
9
|
columnType: "PgText";
|
|
10
10
|
data: string;
|
|
@@ -21,7 +21,7 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
21
21
|
}, {}, {}>;
|
|
22
22
|
tenantId: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
23
|
name: "tenant_id";
|
|
24
|
-
tableName: "
|
|
24
|
+
tableName: "workflow_definition";
|
|
25
25
|
dataType: "string";
|
|
26
26
|
columnType: "PgText";
|
|
27
27
|
data: string;
|
|
@@ -38,12 +38,12 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
38
38
|
}, {}, {}>;
|
|
39
39
|
creatorPrincipalId: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
40
|
name: "creator_principal_id";
|
|
41
|
-
tableName: "
|
|
41
|
+
tableName: "workflow_definition";
|
|
42
42
|
dataType: "string";
|
|
43
43
|
columnType: "PgText";
|
|
44
44
|
data: string;
|
|
45
45
|
driverParam: string;
|
|
46
|
-
notNull:
|
|
46
|
+
notNull: false;
|
|
47
47
|
hasDefault: false;
|
|
48
48
|
isPrimaryKey: false;
|
|
49
49
|
isAutoincrement: false;
|
|
@@ -53,14 +53,14 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
53
53
|
identity: undefined;
|
|
54
54
|
generated: undefined;
|
|
55
55
|
}, {}, {}>;
|
|
56
|
-
|
|
57
|
-
name: "
|
|
58
|
-
tableName: "
|
|
56
|
+
assetId: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "asset_id";
|
|
58
|
+
tableName: "workflow_definition";
|
|
59
59
|
dataType: "string";
|
|
60
60
|
columnType: "PgText";
|
|
61
61
|
data: string;
|
|
62
62
|
driverParam: string;
|
|
63
|
-
notNull:
|
|
63
|
+
notNull: false;
|
|
64
64
|
hasDefault: false;
|
|
65
65
|
isPrimaryKey: false;
|
|
66
66
|
isAutoincrement: false;
|
|
@@ -70,9 +70,9 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
70
70
|
identity: undefined;
|
|
71
71
|
generated: undefined;
|
|
72
72
|
}, {}, {}>;
|
|
73
|
-
|
|
74
|
-
name: "
|
|
75
|
-
tableName: "
|
|
73
|
+
wireHash: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "wire_hash";
|
|
75
|
+
tableName: "workflow_definition";
|
|
76
76
|
dataType: "string";
|
|
77
77
|
columnType: "PgText";
|
|
78
78
|
data: string;
|
|
@@ -87,14 +87,14 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
87
87
|
identity: undefined;
|
|
88
88
|
generated: undefined;
|
|
89
89
|
}, {}, {}>;
|
|
90
|
-
|
|
91
|
-
name: "
|
|
92
|
-
tableName: "
|
|
90
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "name";
|
|
92
|
+
tableName: "workflow_definition";
|
|
93
93
|
dataType: "string";
|
|
94
94
|
columnType: "PgText";
|
|
95
95
|
data: string;
|
|
96
96
|
driverParam: string;
|
|
97
|
-
notNull:
|
|
97
|
+
notNull: true;
|
|
98
98
|
hasDefault: false;
|
|
99
99
|
isPrimaryKey: false;
|
|
100
100
|
isAutoincrement: false;
|
|
@@ -104,77 +104,26 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
104
104
|
identity: undefined;
|
|
105
105
|
generated: undefined;
|
|
106
106
|
}, {}, {}>;
|
|
107
|
-
|
|
108
|
-
name: "
|
|
109
|
-
tableName: "
|
|
110
|
-
dataType: "
|
|
111
|
-
columnType: "
|
|
112
|
-
data:
|
|
113
|
-
driverParam:
|
|
114
|
-
notNull: false;
|
|
115
|
-
hasDefault: false;
|
|
116
|
-
isPrimaryKey: false;
|
|
117
|
-
isAutoincrement: false;
|
|
118
|
-
hasRuntimeDefault: false;
|
|
119
|
-
enumValues: undefined;
|
|
120
|
-
baseColumn: never;
|
|
121
|
-
identity: undefined;
|
|
122
|
-
generated: undefined;
|
|
123
|
-
}, {}, {}>;
|
|
124
|
-
initialState: import("drizzle-orm/pg-core").PgColumn<{
|
|
125
|
-
name: "initial_state";
|
|
126
|
-
tableName: "agent";
|
|
127
|
-
dataType: "json";
|
|
128
|
-
columnType: "PgJsonb";
|
|
129
|
-
data: unknown;
|
|
130
|
-
driverParam: unknown;
|
|
131
|
-
notNull: false;
|
|
132
|
-
hasDefault: false;
|
|
133
|
-
isPrimaryKey: false;
|
|
134
|
-
isAutoincrement: false;
|
|
135
|
-
hasRuntimeDefault: false;
|
|
136
|
-
enumValues: undefined;
|
|
137
|
-
baseColumn: never;
|
|
138
|
-
identity: undefined;
|
|
139
|
-
generated: undefined;
|
|
140
|
-
}, {}, {}>;
|
|
141
|
-
modelConfig: import("drizzle-orm/pg-core").PgColumn<{
|
|
142
|
-
name: "model_config";
|
|
143
|
-
tableName: "agent";
|
|
144
|
-
dataType: "json";
|
|
145
|
-
columnType: "PgJsonb";
|
|
146
|
-
data: unknown;
|
|
147
|
-
driverParam: unknown;
|
|
148
|
-
notNull: false;
|
|
149
|
-
hasDefault: false;
|
|
150
|
-
isPrimaryKey: false;
|
|
151
|
-
isAutoincrement: false;
|
|
152
|
-
hasRuntimeDefault: false;
|
|
153
|
-
enumValues: undefined;
|
|
154
|
-
baseColumn: never;
|
|
155
|
-
identity: undefined;
|
|
156
|
-
generated: undefined;
|
|
157
|
-
}, {}, {}>;
|
|
158
|
-
capabilities: import("drizzle-orm/pg-core").PgColumn<{
|
|
159
|
-
name: "capabilities";
|
|
160
|
-
tableName: "agent";
|
|
161
|
-
dataType: "json";
|
|
162
|
-
columnType: "PgJsonb";
|
|
163
|
-
data: unknown;
|
|
164
|
-
driverParam: unknown;
|
|
107
|
+
description: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "description";
|
|
109
|
+
tableName: "workflow_definition";
|
|
110
|
+
dataType: "string";
|
|
111
|
+
columnType: "PgText";
|
|
112
|
+
data: string;
|
|
113
|
+
driverParam: string;
|
|
165
114
|
notNull: false;
|
|
166
115
|
hasDefault: false;
|
|
167
116
|
isPrimaryKey: false;
|
|
168
117
|
isAutoincrement: false;
|
|
169
118
|
hasRuntimeDefault: false;
|
|
170
|
-
enumValues:
|
|
119
|
+
enumValues: [string, ...string[]];
|
|
171
120
|
baseColumn: never;
|
|
172
121
|
identity: undefined;
|
|
173
122
|
generated: undefined;
|
|
174
123
|
}, {}, {}>;
|
|
175
|
-
|
|
176
|
-
name: "
|
|
177
|
-
tableName: "
|
|
124
|
+
grantRequirements: import("drizzle-orm/pg-core").PgColumn<{
|
|
125
|
+
name: "grant_requirements";
|
|
126
|
+
tableName: "workflow_definition";
|
|
178
127
|
dataType: "json";
|
|
179
128
|
columnType: "PgJsonb";
|
|
180
129
|
data: unknown;
|
|
@@ -191,7 +140,7 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
191
140
|
}, {}, {}>;
|
|
192
141
|
modelRequirements: import("drizzle-orm/pg-core").PgColumn<{
|
|
193
142
|
name: "model_requirements";
|
|
194
|
-
tableName: "
|
|
143
|
+
tableName: "workflow_definition";
|
|
195
144
|
dataType: "json";
|
|
196
145
|
columnType: "PgJsonb";
|
|
197
146
|
data: unknown;
|
|
@@ -206,26 +155,9 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
206
155
|
identity: undefined;
|
|
207
156
|
generated: undefined;
|
|
208
157
|
}, {}, {}>;
|
|
209
|
-
|
|
210
|
-
name: "
|
|
211
|
-
tableName: "
|
|
212
|
-
dataType: "json";
|
|
213
|
-
columnType: "PgJsonb";
|
|
214
|
-
data: unknown;
|
|
215
|
-
driverParam: unknown;
|
|
216
|
-
notNull: true;
|
|
217
|
-
hasDefault: true;
|
|
218
|
-
isPrimaryKey: false;
|
|
219
|
-
isAutoincrement: false;
|
|
220
|
-
hasRuntimeDefault: false;
|
|
221
|
-
enumValues: undefined;
|
|
222
|
-
baseColumn: never;
|
|
223
|
-
identity: undefined;
|
|
224
|
-
generated: undefined;
|
|
225
|
-
}, {}, {}>;
|
|
226
|
-
grantRequirements: import("drizzle-orm/pg-core").PgColumn<{
|
|
227
|
-
name: "grant_requirements";
|
|
228
|
-
tableName: "agent";
|
|
158
|
+
credentialBindings: import("drizzle-orm/pg-core").PgColumn<{
|
|
159
|
+
name: "credential_bindings";
|
|
160
|
+
tableName: "workflow_definition";
|
|
229
161
|
dataType: "json";
|
|
230
162
|
columnType: "PgJsonb";
|
|
231
163
|
data: unknown;
|
|
@@ -242,7 +174,7 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
242
174
|
}, {}, {}>;
|
|
243
175
|
currentVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
244
176
|
name: "current_version";
|
|
245
|
-
tableName: "
|
|
177
|
+
tableName: "workflow_definition";
|
|
246
178
|
dataType: "string";
|
|
247
179
|
columnType: "PgText";
|
|
248
180
|
data: string;
|
|
@@ -259,7 +191,7 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
259
191
|
}, {}, {}>;
|
|
260
192
|
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
261
193
|
name: "status";
|
|
262
|
-
tableName: "
|
|
194
|
+
tableName: "workflow_definition";
|
|
263
195
|
dataType: "string";
|
|
264
196
|
columnType: "PgText";
|
|
265
197
|
data: "deployed" | "stopped";
|
|
@@ -276,7 +208,7 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
276
208
|
}, {}, {}>;
|
|
277
209
|
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
278
210
|
name: "created_at";
|
|
279
|
-
tableName: "
|
|
211
|
+
tableName: "workflow_definition";
|
|
280
212
|
dataType: "date";
|
|
281
213
|
columnType: "PgTimestamp";
|
|
282
214
|
data: Date;
|
|
@@ -293,7 +225,7 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
293
225
|
}, {}, {}>;
|
|
294
226
|
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
295
227
|
name: "updated_at";
|
|
296
|
-
tableName: "
|
|
228
|
+
tableName: "workflow_definition";
|
|
297
229
|
dataType: "date";
|
|
298
230
|
columnType: "PgTimestamp";
|
|
299
231
|
data: Date;
|
|
@@ -311,13 +243,13 @@ export declare const agent: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
311
243
|
};
|
|
312
244
|
dialect: "pg";
|
|
313
245
|
}>;
|
|
314
|
-
export declare const
|
|
315
|
-
name: "
|
|
246
|
+
export declare const workflowDefinitionVersion: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
247
|
+
name: "workflow_definition_version";
|
|
316
248
|
schema: undefined;
|
|
317
249
|
columns: {
|
|
318
250
|
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
319
251
|
name: "id";
|
|
320
|
-
tableName: "
|
|
252
|
+
tableName: "workflow_definition_version";
|
|
321
253
|
dataType: "string";
|
|
322
254
|
columnType: "PgText";
|
|
323
255
|
data: string;
|
|
@@ -332,9 +264,9 @@ export declare const agentVersion: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
332
264
|
identity: undefined;
|
|
333
265
|
generated: undefined;
|
|
334
266
|
}, {}, {}>;
|
|
335
|
-
|
|
336
|
-
name: "
|
|
337
|
-
tableName: "
|
|
267
|
+
definitionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
268
|
+
name: "definition_id";
|
|
269
|
+
tableName: "workflow_definition_version";
|
|
338
270
|
dataType: "string";
|
|
339
271
|
columnType: "PgText";
|
|
340
272
|
data: string;
|
|
@@ -351,7 +283,7 @@ export declare const agentVersion: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
351
283
|
}, {}, {}>;
|
|
352
284
|
version: import("drizzle-orm/pg-core").PgColumn<{
|
|
353
285
|
name: "version";
|
|
354
|
-
tableName: "
|
|
286
|
+
tableName: "workflow_definition_version";
|
|
355
287
|
dataType: "string";
|
|
356
288
|
columnType: "PgText";
|
|
357
289
|
data: string;
|
|
@@ -368,7 +300,7 @@ export declare const agentVersion: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
368
300
|
}, {}, {}>;
|
|
369
301
|
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
370
302
|
name: "status";
|
|
371
|
-
tableName: "
|
|
303
|
+
tableName: "workflow_definition_version";
|
|
372
304
|
dataType: "string";
|
|
373
305
|
columnType: "PgText";
|
|
374
306
|
data: "active" | "inactive" | "failed";
|
|
@@ -383,9 +315,43 @@ export declare const agentVersion: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
383
315
|
identity: undefined;
|
|
384
316
|
generated: undefined;
|
|
385
317
|
}, {}, {}>;
|
|
318
|
+
approvedWireHash: import("drizzle-orm/pg-core").PgColumn<{
|
|
319
|
+
name: "approved_wire_hash";
|
|
320
|
+
tableName: "workflow_definition_version";
|
|
321
|
+
dataType: "string";
|
|
322
|
+
columnType: "PgText";
|
|
323
|
+
data: string;
|
|
324
|
+
driverParam: string;
|
|
325
|
+
notNull: false;
|
|
326
|
+
hasDefault: false;
|
|
327
|
+
isPrimaryKey: false;
|
|
328
|
+
isAutoincrement: false;
|
|
329
|
+
hasRuntimeDefault: false;
|
|
330
|
+
enumValues: [string, ...string[]];
|
|
331
|
+
baseColumn: never;
|
|
332
|
+
identity: undefined;
|
|
333
|
+
generated: undefined;
|
|
334
|
+
}, {}, {}>;
|
|
335
|
+
grantSnapshot: import("drizzle-orm/pg-core").PgColumn<{
|
|
336
|
+
name: "grant_snapshot";
|
|
337
|
+
tableName: "workflow_definition_version";
|
|
338
|
+
dataType: "json";
|
|
339
|
+
columnType: "PgJsonb";
|
|
340
|
+
data: unknown;
|
|
341
|
+
driverParam: unknown;
|
|
342
|
+
notNull: false;
|
|
343
|
+
hasDefault: false;
|
|
344
|
+
isPrimaryKey: false;
|
|
345
|
+
isAutoincrement: false;
|
|
346
|
+
hasRuntimeDefault: false;
|
|
347
|
+
enumValues: undefined;
|
|
348
|
+
baseColumn: never;
|
|
349
|
+
identity: undefined;
|
|
350
|
+
generated: undefined;
|
|
351
|
+
}, {}, {}>;
|
|
386
352
|
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
387
353
|
name: "created_at";
|
|
388
|
-
tableName: "
|
|
354
|
+
tableName: "workflow_definition_version";
|
|
389
355
|
dataType: "date";
|
|
390
356
|
columnType: "PgTimestamp";
|
|
391
357
|
data: Date;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { index, jsonb, pgTable, text, timestamp, unique, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
2
|
+
import { asset } from "./assets.js";
|
|
3
|
+
import { principal } from "./principals.js";
|
|
4
|
+
import { tenant } from "./tenants.js";
|
|
5
|
+
// workflow_definition is the first-class definition entity for the workflow
|
|
6
|
+
// model: one row per deployable definition, with a version table alongside it.
|
|
7
|
+
//
|
|
8
|
+
// The definition body (system prompt, context/model config, tool packages) is
|
|
9
|
+
// not stored on this row -- it lives in the `workflow`-kind asset the row
|
|
10
|
+
// points at, and the run reads it back from there. `asset_id` is nullable at
|
|
11
|
+
// the schema level, but a runnable definition points at a materialized asset.
|
|
12
|
+
//
|
|
13
|
+
// Identity is selector-keyed on the wire-projection hash, not one definition
|
|
14
|
+
// per asset: a single asset (e.g. a monorepo package) backs many definitions
|
|
15
|
+
// distinguished by the content hash of their wire projection. `wire_hash` is
|
|
16
|
+
// that content handle; the unique index over `(asset_id, wire_hash)` keys
|
|
17
|
+
// identity so definitions sharing an asset but carrying different wire hashes
|
|
18
|
+
// resolve independently. `wire_hash` is nullable so definitions predating this
|
|
19
|
+
// key carry none; Postgres treats those NULLs as distinct.
|
|
20
|
+
export const workflowDefinition = pgTable("workflow_definition", {
|
|
21
|
+
id: text("id").primaryKey(),
|
|
22
|
+
tenantId: text("tenant_id")
|
|
23
|
+
.notNull()
|
|
24
|
+
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
25
|
+
// Nullable to match the weaker of the two definition sources: `asset`'s
|
|
26
|
+
// creator principal is `onDelete: "set null"`, so a workflow asset whose
|
|
27
|
+
// creator principal was removed carries no creator onto the definition.
|
|
28
|
+
creatorPrincipalId: text("creator_principal_id").references(() => principal.id),
|
|
29
|
+
// The asset holding this definition's body. `restrict`: the definition is
|
|
30
|
+
// the first-class entity, so deleting the asset must not cascade into
|
|
31
|
+
// deleting it.
|
|
32
|
+
assetId: text("asset_id").references(() => asset.id, {
|
|
33
|
+
onDelete: "restrict",
|
|
34
|
+
}),
|
|
35
|
+
// Content hash of this definition's wire projection: the selector that
|
|
36
|
+
// keys identity within an asset. Nullable so definitions predating the
|
|
37
|
+
// selector-keyed key carry none.
|
|
38
|
+
wireHash: text("wire_hash"),
|
|
39
|
+
name: text("name").notNull(),
|
|
40
|
+
description: text("description"),
|
|
41
|
+
// Grant requirements manifest, resolved at launch into materialized grants.
|
|
42
|
+
// Validated as GrantRequirement[] at parse time.
|
|
43
|
+
grantRequirements: jsonb("grant_requirements"),
|
|
44
|
+
// Model requirements manifest: the canonical model names + provider
|
|
45
|
+
// preferences a definition launched as a single interactive run resolves
|
|
46
|
+
// against the live tenant catalog into credential-bearing inference
|
|
47
|
+
// sources, fresh each launch. Non-null marks such a definition and gates
|
|
48
|
+
// the interactive-launch path; null for a definition deployed as a workflow,
|
|
49
|
+
// which supplies its sources at deploy time. Validated as ModelRequirements
|
|
50
|
+
// at parse time.
|
|
51
|
+
modelRequirements: jsonb("model_requirements"),
|
|
52
|
+
// Credential bindings manifest: maps a tool package's declared credential
|
|
53
|
+
// handle (package, handle) to a concrete credential resolved fresh at
|
|
54
|
+
// launch (by locator + provider + name against the tenant walk-up).
|
|
55
|
+
// Validated as CredentialBinding[] at parse time. A binding is a request
|
|
56
|
+
// the launch-time grant gate authorizes; it consents to nothing on its own.
|
|
57
|
+
credentialBindings: jsonb("credential_bindings"),
|
|
58
|
+
currentVersion: text("current_version").notNull().default("1"),
|
|
59
|
+
status: text("status", {
|
|
60
|
+
enum: ["deployed", "stopped"],
|
|
61
|
+
})
|
|
62
|
+
.notNull()
|
|
63
|
+
.default("deployed"),
|
|
64
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
65
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
66
|
+
}, (t) => [
|
|
67
|
+
index("workflow_definition_tenant_idx").on(t.tenantId, t.createdAt),
|
|
68
|
+
uniqueIndex("workflow_definition_asset_wire_hash_idx").on(t.assetId, t.wireHash),
|
|
69
|
+
]);
|
|
70
|
+
export const workflowDefinitionVersion = pgTable("workflow_definition_version", {
|
|
71
|
+
id: text("id").primaryKey(),
|
|
72
|
+
definitionId: text("definition_id")
|
|
73
|
+
.notNull()
|
|
74
|
+
.references(() => workflowDefinition.id, { onDelete: "cascade" }),
|
|
75
|
+
version: text("version").notNull(),
|
|
76
|
+
status: text("status", {
|
|
77
|
+
enum: ["active", "inactive", "failed"],
|
|
78
|
+
})
|
|
79
|
+
.notNull()
|
|
80
|
+
.default("active"),
|
|
81
|
+
// Hash of the wire bytes approved for this version, recorded at approval
|
|
82
|
+
// and read back during re-verify to detect drift. Null before approval is
|
|
83
|
+
// a legitimate state, so the column takes no NOT NULL constraint.
|
|
84
|
+
approvedWireHash: text("approved_wire_hash"),
|
|
85
|
+
// Serializable projection of the deploy-time capability walk, recorded
|
|
86
|
+
// at approval so a run materializes grants from it instead of re-reading
|
|
87
|
+
// and re-walking a workflow.json blob. Validated as GrantWalkSnapshot at
|
|
88
|
+
// parse time. Null before approval is a legitimate state, so the column
|
|
89
|
+
// takes no NOT NULL constraint.
|
|
90
|
+
grantSnapshot: jsonb("grant_snapshot"),
|
|
91
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
92
|
+
}, (t) => [
|
|
93
|
+
// Unique per definition so rollback-by-version resolves to one row. The
|
|
94
|
+
// mirror source `agent_version` omits this; the fresh table constrains it.
|
|
95
|
+
unique("workflow_definition_version_definition_version").on(t.definitionId, t.version),
|
|
96
|
+
index("workflow_definition_version_definition_idx").on(t.definitionId),
|
|
97
|
+
]);
|