@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
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
name: "workflow_deployment";
|
|
1
|
+
export declare const principalKey: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "principal_key";
|
|
4
3
|
schema: undefined;
|
|
5
4
|
columns: {
|
|
6
5
|
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
7
6
|
name: "id";
|
|
8
|
-
tableName: "
|
|
7
|
+
tableName: "principal_key";
|
|
9
8
|
dataType: "string";
|
|
10
9
|
columnType: "PgText";
|
|
11
10
|
data: string;
|
|
@@ -20,9 +19,9 @@ export declare const workflowDeployment: import("drizzle-orm/pg-core").PgTableWi
|
|
|
20
19
|
identity: undefined;
|
|
21
20
|
generated: undefined;
|
|
22
21
|
}, {}, {}>;
|
|
23
|
-
|
|
24
|
-
name: "
|
|
25
|
-
tableName: "
|
|
22
|
+
principalId: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "principal_id";
|
|
24
|
+
tableName: "principal_key";
|
|
26
25
|
dataType: "string";
|
|
27
26
|
columnType: "PgText";
|
|
28
27
|
data: string;
|
|
@@ -37,9 +36,9 @@ export declare const workflowDeployment: import("drizzle-orm/pg-core").PgTableWi
|
|
|
37
36
|
identity: undefined;
|
|
38
37
|
generated: undefined;
|
|
39
38
|
}, {}, {}>;
|
|
40
|
-
|
|
41
|
-
name: "
|
|
42
|
-
tableName: "
|
|
39
|
+
publicKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "public_key";
|
|
41
|
+
tableName: "principal_key";
|
|
43
42
|
dataType: "string";
|
|
44
43
|
columnType: "PgText";
|
|
45
44
|
data: string;
|
|
@@ -54,9 +53,9 @@ export declare const workflowDeployment: import("drizzle-orm/pg-core").PgTableWi
|
|
|
54
53
|
identity: undefined;
|
|
55
54
|
generated: undefined;
|
|
56
55
|
}, {}, {}>;
|
|
57
|
-
|
|
58
|
-
name: "
|
|
59
|
-
tableName: "
|
|
56
|
+
privateKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "private_key";
|
|
58
|
+
tableName: "principal_key";
|
|
60
59
|
dataType: "string";
|
|
61
60
|
columnType: "PgText";
|
|
62
61
|
data: string;
|
|
@@ -71,45 +70,43 @@ export declare const workflowDeployment: import("drizzle-orm/pg-core").PgTableWi
|
|
|
71
70
|
identity: undefined;
|
|
72
71
|
generated: undefined;
|
|
73
72
|
}, {}, {}>;
|
|
74
|
-
|
|
75
|
-
name: "
|
|
76
|
-
tableName: "
|
|
73
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "status";
|
|
75
|
+
tableName: "principal_key";
|
|
77
76
|
dataType: "string";
|
|
78
77
|
columnType: "PgText";
|
|
79
|
-
data:
|
|
78
|
+
data: "active" | "retired";
|
|
80
79
|
driverParam: string;
|
|
81
|
-
notNull:
|
|
80
|
+
notNull: true;
|
|
82
81
|
hasDefault: false;
|
|
83
82
|
isPrimaryKey: false;
|
|
84
83
|
isAutoincrement: false;
|
|
85
84
|
hasRuntimeDefault: false;
|
|
86
|
-
enumValues: [
|
|
85
|
+
enumValues: ["active", "retired"];
|
|
87
86
|
baseColumn: never;
|
|
88
87
|
identity: undefined;
|
|
89
88
|
generated: undefined;
|
|
90
89
|
}, {}, {}>;
|
|
91
|
-
|
|
92
|
-
name: "
|
|
93
|
-
tableName: "
|
|
94
|
-
dataType: "
|
|
95
|
-
columnType: "
|
|
96
|
-
data:
|
|
90
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "created_at";
|
|
92
|
+
tableName: "principal_key";
|
|
93
|
+
dataType: "date";
|
|
94
|
+
columnType: "PgTimestamp";
|
|
95
|
+
data: Date;
|
|
97
96
|
driverParam: string;
|
|
98
97
|
notNull: true;
|
|
99
98
|
hasDefault: true;
|
|
100
99
|
isPrimaryKey: false;
|
|
101
100
|
isAutoincrement: false;
|
|
102
101
|
hasRuntimeDefault: false;
|
|
103
|
-
enumValues:
|
|
102
|
+
enumValues: undefined;
|
|
104
103
|
baseColumn: never;
|
|
105
104
|
identity: undefined;
|
|
106
105
|
generated: undefined;
|
|
107
|
-
}, {}, {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
name: "created_at";
|
|
112
|
-
tableName: "workflow_deployment";
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "updated_at";
|
|
109
|
+
tableName: "principal_key";
|
|
113
110
|
dataType: "date";
|
|
114
111
|
columnType: "PgTimestamp";
|
|
115
112
|
data: Date;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import { pgTable, text, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
|
|
3
|
+
import { principal } from "./principals.js";
|
|
4
|
+
// A principal's Ed25519 signing key. `public_key` is the hex-encoded 32-byte
|
|
5
|
+
// public point; `private_key` holds the hex-encoded 32-byte seed sealed by the
|
|
6
|
+
// credential cipher (`enc:aead:...` ciphertext), so the seed is never at rest in
|
|
7
|
+
// plaintext under a configured key. The hub custodies the private key: a
|
|
8
|
+
// signature attributes an action to the principal, but is not non-repudiable
|
|
9
|
+
// against the hub operator. See docs/AUTH.md.
|
|
10
|
+
//
|
|
11
|
+
// The `status` axis expresses the one-active-key-per-principal invariant, which
|
|
12
|
+
// the partial unique index below enforces at the database. No path retires a
|
|
13
|
+
// key; every key a principal holds today is "active".
|
|
14
|
+
export const principalKey = pgTable("principal_key", {
|
|
15
|
+
id: text("id").primaryKey(),
|
|
16
|
+
principalId: text("principal_id")
|
|
17
|
+
.notNull()
|
|
18
|
+
.references(() => principal.id, { onDelete: "cascade" }),
|
|
19
|
+
publicKey: text("public_key").notNull().unique(),
|
|
20
|
+
privateKey: text("private_key").notNull(),
|
|
21
|
+
status: text("status", { enum: ["active", "retired"] }).notNull(),
|
|
22
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
23
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
24
|
+
}, (t) => [
|
|
25
|
+
uniqueIndex("principal_key_one_active")
|
|
26
|
+
.on(t.principalId)
|
|
27
|
+
.where(sql `${t.status} = 'active'`),
|
|
28
|
+
]);
|
|
@@ -42,14 +42,14 @@ export declare const principal: import("drizzle-orm/pg-core").PgTableWithColumns
|
|
|
42
42
|
tableName: "principal";
|
|
43
43
|
dataType: "string";
|
|
44
44
|
columnType: "PgText";
|
|
45
|
-
data: "user" | "agent";
|
|
45
|
+
data: "user" | "agent" | "workflow";
|
|
46
46
|
driverParam: string;
|
|
47
47
|
notNull: true;
|
|
48
48
|
hasDefault: false;
|
|
49
49
|
isPrimaryKey: false;
|
|
50
50
|
isAutoincrement: false;
|
|
51
51
|
hasRuntimeDefault: false;
|
|
52
|
-
enumValues: ["user", "agent"];
|
|
52
|
+
enumValues: ["user", "agent", "workflow"];
|
|
53
53
|
baseColumn: never;
|
|
54
54
|
identity: undefined;
|
|
55
55
|
generated: undefined;
|
|
@@ -6,7 +6,7 @@ export const principal = pgTable("principal", {
|
|
|
6
6
|
tenantId: text("tenant_id")
|
|
7
7
|
.notNull()
|
|
8
8
|
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
9
|
-
kind: text("kind", { enum: ["user", "agent"] }).notNull(),
|
|
9
|
+
kind: text("kind", { enum: ["user", "agent", "workflow"] }).notNull(),
|
|
10
10
|
refId: text("ref_id").notNull(),
|
|
11
11
|
status: text("status", {
|
|
12
12
|
enum: ["active", "suspended", "invited", "deactivated"],
|
|
@@ -14,8 +14,10 @@ export const principal = pgTable("principal", {
|
|
|
14
14
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
15
15
|
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
16
16
|
}, (t) => [unique().on(t.tenantId, t.kind, t.refId)]);
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
17
|
+
// refId is polymorphic on kind: the auth user for kind='user', and either a
|
|
18
|
+
// workflow_run or a workflow_definition for kind='workflow'. A `kind='agent'`
|
|
19
|
+
// principal is a legacy survivor of the fold -- its refId named an
|
|
20
|
+
// `agent_instance` row, a table now dropped, so it dangles and is inert.
|
|
21
|
+
// Postgres can't express a conditional FK across those targets, so there is no
|
|
22
|
+
// FK constraint here and the application layer enforces referential integrity.
|
|
21
23
|
export { user };
|
|
@@ -70,6 +70,23 @@ export declare const provider: import("drizzle-orm/pg-core").PgTableWithColumns<
|
|
|
70
70
|
identity: undefined;
|
|
71
71
|
generated: undefined;
|
|
72
72
|
}, {}, {}>;
|
|
73
|
+
apiBaseUrl: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "api_base_url";
|
|
75
|
+
tableName: "provider";
|
|
76
|
+
dataType: "string";
|
|
77
|
+
columnType: "PgText";
|
|
78
|
+
data: string;
|
|
79
|
+
driverParam: string;
|
|
80
|
+
notNull: false;
|
|
81
|
+
hasDefault: false;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: [string, ...string[]];
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {}>;
|
|
73
90
|
authorizationUrl: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
91
|
name: "authorization_url";
|
|
75
92
|
tableName: "provider";
|
package/dist/schema/providers.js
CHANGED
|
@@ -7,6 +7,11 @@ export const provider = pgTable("provider", {
|
|
|
7
7
|
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
8
8
|
name: text("name").notNull(),
|
|
9
9
|
plugin: text("plugin").notNull(),
|
|
10
|
+
// The API origin a credential from this provider authenticates to (e.g.
|
|
11
|
+
// https://api.github.com). Optional: OAuth-login-only providers have no
|
|
12
|
+
// API-call origin. A provider that backs an origin-pinned credential must
|
|
13
|
+
// have one, enforced loudly at credential-shape time, not by the schema.
|
|
14
|
+
apiBaseUrl: text("api_base_url"),
|
|
10
15
|
authorizationUrl: text("authorization_url"),
|
|
11
16
|
tokenUrl: text("token_url"),
|
|
12
17
|
userInfoUrl: text("user_info_url"),
|
package/dist/schema/roles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { boolean, pgTable, primaryKey, text, timestamp, } from "drizzle-orm/pg-core";
|
|
2
|
-
import { agent } from "./agents.js";
|
|
3
2
|
import { principal } from "./principals.js";
|
|
4
3
|
import { tenant } from "./tenants.js";
|
|
4
|
+
import { workflowDefinition } from "./workflow-definitions.js";
|
|
5
5
|
export const role = pgTable("role", {
|
|
6
6
|
id: text("id").primaryKey(),
|
|
7
7
|
tenantId: text("tenant_id")
|
|
@@ -14,9 +14,13 @@ export const role = pgTable("role", {
|
|
|
14
14
|
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
15
15
|
});
|
|
16
16
|
export const agentRole = pgTable("agent_role", {
|
|
17
|
+
// Retains the agent_id column name, but its values are workflow_definition
|
|
18
|
+
// ids: every agent was folded to exactly one definition, and role
|
|
19
|
+
// assignments follow the definition so they survived the agent table's
|
|
20
|
+
// retirement.
|
|
17
21
|
agentId: text("agent_id")
|
|
18
22
|
.notNull()
|
|
19
|
-
.references(() =>
|
|
23
|
+
.references(() => workflowDefinition.id, { onDelete: "cascade" }),
|
|
20
24
|
roleId: text("role_id")
|
|
21
25
|
.notNull()
|
|
22
26
|
.references(() => role.id, { onDelete: "cascade" }),
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export type SessionAssetSource = "direct" | "resolved";
|
|
2
1
|
export declare const sessionAsset: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
3
2
|
name: "session_asset";
|
|
4
3
|
schema: undefined;
|
|
5
4
|
columns: {
|
|
6
|
-
|
|
5
|
+
runId: import("drizzle-orm/pg-core").PgColumn<{
|
|
7
6
|
name: "instance_id";
|
|
8
7
|
tableName: "session_asset";
|
|
9
8
|
dataType: "string";
|
|
@@ -20,23 +19,6 @@ export declare const sessionAsset: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
20
19
|
identity: undefined;
|
|
21
20
|
generated: undefined;
|
|
22
21
|
}, {}, {}>;
|
|
23
|
-
agentAssetId: import("drizzle-orm/pg-core").PgColumn<{
|
|
24
|
-
name: "agent_asset_id";
|
|
25
|
-
tableName: "session_asset";
|
|
26
|
-
dataType: "string";
|
|
27
|
-
columnType: "PgText";
|
|
28
|
-
data: string;
|
|
29
|
-
driverParam: string;
|
|
30
|
-
notNull: false;
|
|
31
|
-
hasDefault: false;
|
|
32
|
-
isPrimaryKey: false;
|
|
33
|
-
isAutoincrement: false;
|
|
34
|
-
hasRuntimeDefault: false;
|
|
35
|
-
enumValues: [string, ...string[]];
|
|
36
|
-
baseColumn: never;
|
|
37
|
-
identity: undefined;
|
|
38
|
-
generated: undefined;
|
|
39
|
-
}, {}, {}>;
|
|
40
22
|
mountPath: import("drizzle-orm/pg-core").PgColumn<{
|
|
41
23
|
name: "mount_path";
|
|
42
24
|
tableName: "session_asset";
|
|
@@ -88,25 +70,6 @@ export declare const sessionAsset: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
88
70
|
identity: undefined;
|
|
89
71
|
generated: undefined;
|
|
90
72
|
}, {}, {}>;
|
|
91
|
-
source: import("drizzle-orm/pg-core").PgColumn<{
|
|
92
|
-
name: "source";
|
|
93
|
-
tableName: "session_asset";
|
|
94
|
-
dataType: "string";
|
|
95
|
-
columnType: "PgText";
|
|
96
|
-
data: SessionAssetSource;
|
|
97
|
-
driverParam: string;
|
|
98
|
-
notNull: true;
|
|
99
|
-
hasDefault: false;
|
|
100
|
-
isPrimaryKey: false;
|
|
101
|
-
isAutoincrement: false;
|
|
102
|
-
hasRuntimeDefault: false;
|
|
103
|
-
enumValues: [string, ...string[]];
|
|
104
|
-
baseColumn: never;
|
|
105
|
-
identity: undefined;
|
|
106
|
-
generated: undefined;
|
|
107
|
-
}, {}, {
|
|
108
|
-
$type: SessionAssetSource;
|
|
109
|
-
}>;
|
|
110
73
|
materializedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
111
74
|
name: "materialized_at";
|
|
112
75
|
tableName: "session_asset";
|
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
import { index, pgTable, primaryKey, text, timestamp, } from "drizzle-orm/pg-core";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// session_asset rows record per-(instance, materialization) pack
|
|
3
|
+
// acknowledgments. A row exists iff the sidecar acked the pack that
|
|
4
|
+
// materialized that asset for that instance. The launchSession flow
|
|
5
|
+
// inserts each row before the corresponding pack send and rolls it
|
|
6
|
+
// back if that single send fails, so each row reflects an ack the
|
|
7
|
+
// hub actually observed for that attachment.
|
|
8
|
+
//
|
|
9
|
+
// Assets reach an instance through the tool-package resolver: it picks
|
|
10
|
+
// package-registry assets out of the tenant-visible set, and the launch
|
|
11
|
+
// fan-out materializes each into the workspace. The mount path and
|
|
12
|
+
// source commit are recorded so forensic queries can trace every
|
|
13
|
+
// materialization.
|
|
14
|
+
//
|
|
15
|
+
// Caveat on multi-attachment partial-success: when a session attaches
|
|
16
|
+
// N assets and the fan-out succeeds for attachments 1..k-1 and fails
|
|
17
|
+
// on attachment k, only attachment k's row is rolled back. Rows
|
|
18
|
+
// 1..k-1 stay. The session as a whole never reached the running
|
|
19
|
+
// state -- attemptCleanup runs sendAgentUndeploy -- but the per-
|
|
20
|
+
// attachment ack invariant holds for the rows that remain.
|
|
21
|
+
// Forensics queries should treat row count as "packs the sidecar
|
|
22
|
+
// acked during this instance's launch," not "sessions that ran with
|
|
23
|
+
// assets." Pairing with agent_instance.status (or its successor
|
|
24
|
+
// session-lifecycle signal) is necessary to distinguish a row left
|
|
25
|
+
// behind by a partially-successful failed launch from one belonging
|
|
26
|
+
// to a fully-running session.
|
|
4
27
|
export const sessionAsset = pgTable("session_asset", {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}),
|
|
28
|
+
// The endpoint this materialization is for: a legacy agent_instance id or a
|
|
29
|
+
// folded workflow_run id, from one shared id space. A polymorphic reference
|
|
30
|
+
// carrying no foreign key (mirroring inference_turn.runId); the launch
|
|
31
|
+
// layer owns the invariant. NOT NULL -- a materialization always names its
|
|
32
|
+
// endpoint -- and part of the (instance_id, mount_path) key. A folded run
|
|
33
|
+
// writes its run id here, which the dropped agent_instance FK would reject.
|
|
34
|
+
runId: text("instance_id").notNull(),
|
|
13
35
|
mountPath: text("mount_path").notNull(),
|
|
14
36
|
assetPackSha: text("asset_pack_sha").notNull(),
|
|
15
37
|
sourceCommitSha: text("source_commit_sha").notNull(),
|
|
16
|
-
source: text("source").$type().notNull(),
|
|
17
38
|
materializedAt: timestamp("materialized_at").notNull().defaultNow(),
|
|
18
39
|
}, (t) => [
|
|
19
|
-
// (
|
|
20
|
-
// asset lands at a distinct mount path inside one
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
// package-registry pick. Pre-split the PK was (instanceId,
|
|
24
|
-
// agentAssetId), but that column is now nullable for the
|
|
25
|
-
// resolved-source rows and Postgres rejects nullable PK columns.
|
|
26
|
-
primaryKey({ columns: [t.instanceId, t.mountPath] }),
|
|
40
|
+
// (runId, mountPath) is the natural key: every materialized
|
|
41
|
+
// asset lands at a distinct mount path inside one run, so this
|
|
42
|
+
// pair uniquely identifies a row.
|
|
43
|
+
primaryKey({ columns: [t.runId, t.mountPath] }),
|
|
27
44
|
index("session_asset_pack_sha_idx").on(t.assetPackSha),
|
|
28
45
|
]);
|
package/dist/schema/sessions.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
2
|
-
import { agent } from "./agents.js";
|
|
3
2
|
import { principal } from "./principals.js";
|
|
4
3
|
import { tenant } from "./tenants.js";
|
|
4
|
+
import { workflowDefinition } from "./workflow-definitions.js";
|
|
5
5
|
export const agentSession = pgTable("agent_session", {
|
|
6
6
|
id: text("id").primaryKey(),
|
|
7
7
|
tenantId: text("tenant_id")
|
|
8
8
|
.notNull()
|
|
9
9
|
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
10
|
+
// Retains the agent_id column name, but its values are workflow_definition
|
|
11
|
+
// ids: a launched session is keyed to the folded definition it runs, so it
|
|
12
|
+
// survives the agent table's retirement. ON DELETE restrict -- session
|
|
13
|
+
// history is an audit record, so a definition with live sessions cannot be
|
|
14
|
+
// dropped out from under them.
|
|
10
15
|
agentId: text("agent_id")
|
|
11
16
|
.notNull()
|
|
12
|
-
.references(() =>
|
|
17
|
+
.references(() => workflowDefinition.id, { onDelete: "restrict" }),
|
|
13
18
|
principalId: text("principal_id")
|
|
14
19
|
.notNull()
|
|
15
20
|
.references(() => principal.id),
|