@intx/db 0.2.2 → 0.3.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.
Files changed (170) hide show
  1. package/README.md +2 -2
  2. package/dist/approval-store.d.ts +52 -0
  3. package/dist/approval-store.js +79 -0
  4. package/dist/asset-resolution.d.ts +2 -2
  5. package/dist/client.d.ts +10 -0
  6. package/dist/connection.js +11 -8
  7. package/dist/credential-resolution.d.ts +130 -18
  8. package/dist/credential-resolution.js +142 -3
  9. package/dist/grant-store.js +35 -13
  10. package/dist/index.d.ts +13 -4
  11. package/dist/index.js +11 -3
  12. package/dist/model-source-resolution.d.ts +52 -6
  13. package/dist/model-source-resolution.js +145 -19
  14. package/dist/parse-row.d.ts +212 -32
  15. package/dist/parse-row.js +109 -18
  16. package/dist/rekey-credential-secrets.d.ts +13 -0
  17. package/dist/rekey-credential-secrets.js +61 -0
  18. package/dist/schema/approvals.d.ts +245 -0
  19. package/dist/schema/approvals.js +52 -0
  20. package/dist/schema/catalog.d.ts +17 -0
  21. package/dist/schema/catalog.js +7 -1
  22. package/dist/schema/credentials.d.ts +1 -1
  23. package/dist/schema/git-tokens.js +1 -1
  24. package/dist/schema/grants.js +8 -2
  25. package/dist/schema/index.d.ts +8 -4
  26. package/dist/schema/index.js +8 -4
  27. package/dist/schema/messages.d.ts +5 -5
  28. package/dist/schema/messages.js +20 -9
  29. package/dist/schema/offerings.js +8 -2
  30. package/dist/schema/principals.d.ts +2 -2
  31. package/dist/schema/principals.js +7 -5
  32. package/dist/schema/providers.d.ts +17 -0
  33. package/dist/schema/providers.js +5 -0
  34. package/dist/schema/roles.js +6 -2
  35. package/dist/schema/session-assets.d.ts +1 -38
  36. package/dist/schema/session-assets.js +36 -19
  37. package/dist/schema/sessions.js +7 -2
  38. package/dist/schema/sidecar-allocation.d.ts +406 -0
  39. package/dist/schema/sidecar-allocation.js +57 -0
  40. package/dist/schema/sidecar.d.ts +19 -2
  41. package/dist/schema/sidecar.js +13 -3
  42. package/dist/schema/signal-correlations.d.ts +177 -0
  43. package/dist/schema/signal-correlations.js +31 -0
  44. package/dist/schema/wallets.d.ts +3 -3
  45. package/dist/schema/wallets.js +4 -2
  46. package/dist/schema/{agents.d.ts → workflow-definitions.d.ts} +79 -113
  47. package/dist/schema/workflow-definitions.js +97 -0
  48. package/dist/schema/workflow-run-dispatch.d.ts +328 -0
  49. package/dist/schema/workflow-run-dispatch.js +56 -0
  50. package/dist/schema/{workflow-deployments.d.ts → workflow-run-execution.d.ts} +43 -46
  51. package/dist/schema/workflow-run-execution.js +48 -0
  52. package/dist/schema/workflow-run-launch-spec.d.ts +200 -0
  53. package/dist/schema/workflow-run-launch-spec.js +26 -0
  54. package/dist/schema/{instances.d.ts → workflow-run.d.ts} +39 -71
  55. package/dist/schema/workflow-run.js +102 -0
  56. package/dist/sidecar-allocation-store.d.ts +171 -0
  57. package/dist/sidecar-allocation-store.js +512 -0
  58. package/dist/signal-correlation-store.d.ts +36 -0
  59. package/dist/signal-correlation-store.js +63 -0
  60. package/dist/tenant-hierarchy.d.ts +2 -1
  61. package/dist/tenant-hierarchy.js +10 -5
  62. package/dist/workflow-definition-store.d.ts +55 -0
  63. package/dist/workflow-definition-store.js +93 -0
  64. package/dist/workflow-run-dispatch-store.d.ts +80 -0
  65. package/dist/workflow-run-dispatch-store.js +298 -0
  66. package/dist/workflow-run-launch-spec-store.d.ts +13 -0
  67. package/dist/workflow-run-launch-spec-store.js +30 -0
  68. package/dist/workflow-run-store.d.ts +54 -0
  69. package/dist/workflow-run-store.js +85 -0
  70. package/migrations/0037_credential_use_backfill.sql +39 -0
  71. package/migrations/0038_chilly_blacklash.sql +37 -0
  72. package/migrations/0039_quick_carnage.sql +2 -0
  73. package/migrations/0040_reshape_approval_origin.sql +24 -0
  74. package/migrations/0041_make_approval_timeout_at_nullable.sql +1 -0
  75. package/migrations/0042_youthful_mantis.sql +2 -0
  76. package/migrations/0043_signal_correlation_deployment_fk.sql +1 -0
  77. package/migrations/0044_model_offering_quirks.sql +1 -0
  78. package/migrations/0045_create_workflow_run.sql +13 -0
  79. package/migrations/0046_approval_signal_correlation_run_fk.sql +2 -0
  80. package/migrations/0047_create_workflow_definition.sql +30 -0
  81. package/migrations/0048_workflow_definition_origin_agent_id.sql +2 -0
  82. package/migrations/0049_curly_omega_flight.sql +2 -0
  83. package/migrations/0050_late_crystal.sql +10 -0
  84. package/migrations/0051_funny_madelyne_pryor.sql +1 -0
  85. package/migrations/0052_drop_inference_turn_instance_fk.sql +1 -0
  86. package/migrations/0053_session_mail_session_id_index.sql +1 -0
  87. package/migrations/0054_rekey_instance_grants_to_workflow_run.sql +10 -0
  88. package/migrations/0055_backfill_anchor_workflow_runs.sql +69 -0
  89. package/migrations/0056_repoint_deployment_fks_to_anchor_run.sql +32 -0
  90. package/migrations/0057_drop_workflow_deployment_projection.sql +22 -0
  91. package/migrations/0058_repoint_offering_fk_to_definition.sql +41 -0
  92. package/migrations/0059_repoint_transaction_fk_to_run.sql +10 -0
  93. package/migrations/0060_drop_session_mail_instance_fk.sql +6 -0
  94. package/migrations/0061_drop_session_asset_instance_fk.sql +7 -0
  95. package/migrations/0062_drop_agent_asset_table.sql +11 -0
  96. package/migrations/0063_repoint_agent_role_fk_to_definition.sql +39 -0
  97. package/migrations/0064_repoint_agent_session_fk_to_definition.sql +47 -0
  98. package/migrations/0065_add_workflow_definition_model_requirements.sql +37 -0
  99. package/migrations/0066_rekey_agent_definition_principals_to_workflow.sql +27 -0
  100. package/migrations/0067_add_workflow_definition_kind.sql +10 -0
  101. package/migrations/0068_drop_agent_tables_and_origin_agent_id.sql +31 -0
  102. package/migrations/0069_drop_workflow_definition_kind.sql +10 -0
  103. package/migrations/0070_flashy_proteus.sql +13 -0
  104. package/migrations/0072_add_workflow_definition_credential_bindings.sql +1 -0
  105. package/migrations/0073_grant_target_exactly_one_check.sql +13 -0
  106. package/migrations/0074_add_provider_api_base_url.sql +1 -0
  107. package/migrations/0075_workflow_run_launch_spec.sql +17 -0
  108. package/migrations/0076_sidecar_allocation.sql +40 -0
  109. package/migrations/0077_workflow_run_dispatch.sql +29 -0
  110. package/migrations/0078_workflow_run_dispatch_kind.sql +2 -0
  111. package/migrations/0079_rename_workflow_run_deployment_id_to_anchor_run_id.sql +4 -0
  112. package/migrations/0080_rename_correlation_approval_deployment_id_to_anchor_run_id.sql +9 -0
  113. package/migrations/0081_workflow_definition_content_hash_and_approved_wire_hash.sql +4 -0
  114. package/migrations/0082_blue_black_queen.sql +1 -0
  115. package/migrations/0083_replace_launch_spec_snapshot_with_frozen_bundle.sql +3 -0
  116. package/migrations/0084_delete_orphaned_credential_grants.sql +22 -0
  117. package/migrations/meta/0037_snapshot.json +3237 -0
  118. package/migrations/meta/0038_snapshot.json +3470 -0
  119. package/migrations/meta/0039_snapshot.json +3470 -0
  120. package/migrations/meta/0040_snapshot.json +3489 -0
  121. package/migrations/meta/0041_snapshot.json +3489 -0
  122. package/migrations/meta/0042_snapshot.json +3489 -0
  123. package/migrations/meta/0043_snapshot.json +3498 -0
  124. package/migrations/meta/0044_snapshot.json +3504 -0
  125. package/migrations/meta/0045_snapshot.json +3589 -0
  126. package/migrations/meta/0046_snapshot.json +3607 -0
  127. package/migrations/meta/0047_snapshot.json +3832 -0
  128. package/migrations/meta/0048_snapshot.json +3853 -0
  129. package/migrations/meta/0049_snapshot.json +3854 -0
  130. package/migrations/meta/0050_snapshot.json +3924 -0
  131. package/migrations/meta/0051_snapshot.json +3940 -0
  132. package/migrations/meta/0052_snapshot.json +3931 -0
  133. package/migrations/meta/0053_snapshot.json +3952 -0
  134. package/migrations/meta/0054_snapshot.json +3952 -0
  135. package/migrations/meta/0055_snapshot.json +3952 -0
  136. package/migrations/meta/0056_snapshot.json +3952 -0
  137. package/migrations/meta/0057_snapshot.json +3839 -0
  138. package/migrations/meta/0058_snapshot.json +3839 -0
  139. package/migrations/meta/0059_snapshot.json +3839 -0
  140. package/migrations/meta/0060_snapshot.json +3830 -0
  141. package/migrations/meta/0061_snapshot.json +3821 -0
  142. package/migrations/meta/0062_snapshot.json +3723 -0
  143. package/migrations/meta/0063_snapshot.json +3723 -0
  144. package/migrations/meta/0064_snapshot.json +3723 -0
  145. package/migrations/meta/0065_snapshot.json +3729 -0
  146. package/migrations/meta/0066_snapshot.json +3729 -0
  147. package/migrations/meta/0067_snapshot.json +3736 -0
  148. package/migrations/meta/0068_snapshot.json +3347 -0
  149. package/migrations/meta/0069_snapshot.json +3340 -0
  150. package/migrations/meta/0070_snapshot.json +3444 -0
  151. package/migrations/meta/0072_snapshot.json +3450 -0
  152. package/migrations/meta/0073_snapshot.json +3455 -0
  153. package/migrations/meta/0074_snapshot.json +3461 -0
  154. package/migrations/meta/0075_snapshot.json +3567 -0
  155. package/migrations/meta/0076_snapshot.json +3851 -0
  156. package/migrations/meta/0077_snapshot.json +4067 -0
  157. package/migrations/meta/0078_snapshot.json +4078 -0
  158. package/migrations/meta/0079_snapshot.json +4078 -0
  159. package/migrations/meta/0080_snapshot.json +4078 -0
  160. package/migrations/meta/0081_snapshot.json +4096 -0
  161. package/migrations/meta/0082_snapshot.json +4102 -0
  162. package/migrations/meta/0083_snapshot.json +4096 -0
  163. package/migrations/meta/0084_snapshot.json +4096 -0
  164. package/migrations/meta/_journal.json +329 -0
  165. package/package.json +6 -3
  166. package/dist/schema/agent-assets.d.ts +0 -109
  167. package/dist/schema/agent-assets.js +0 -15
  168. package/dist/schema/agents.js +0 -57
  169. package/dist/schema/instances.js +0 -39
  170. package/dist/schema/workflow-deployments.js +0 -37
@@ -1,52 +1,48 @@
1
- import type { agent, agentVersion, credential, gitToken, grant, modelOffering, modelProvider, oauthClient, offering, provider, tenant, transaction, turnPart, wallet } from "./schema/index.js";
1
+ import type { approval, credential, gitToken, grant, modelOffering, modelProvider, oauthClient, offering, principal, provider, signalCorrelation, tenant, transaction, turnPart, wallet, workflowDefinition, workflowDefinitionVersion, workflowRun, workflowRunDispatch, workflowRunLaunchSpec } from "./schema/index.js";
2
2
  export declare const GitTokenKindValidator: import("arktype/internal/variants/string.ts").StringType<"pat" | "svc", {}>;
3
- export declare function parseAgentRow(row: typeof agent.$inferSelect): {
4
- contextConfig: Record<string, unknown> | null;
5
- initialState: Record<string, unknown> | null;
6
- modelConfig: Record<string, unknown> | null;
7
- capabilities: Record<string, unknown> | null;
8
- credentialRequirements: {
9
- providerName: string;
10
- source: "tenant" | "creator" | "invoker";
11
- scopes?: string[];
12
- name?: string;
3
+ export declare function parseWorkflowDefinitionRow(row: typeof workflowDefinition.$inferSelect): {
4
+ status: "deployed" | "stopped";
5
+ grantRequirements: {
6
+ resource: string;
7
+ action: string;
8
+ source: "creator" | "invoker";
9
+ effect?: "allow" | "deny" | "ask";
10
+ conditions?: Record<string, unknown> | null;
13
11
  }[] | null;
14
12
  modelRequirements: {
15
13
  model: string;
16
- capabilities?: ("vision" | "audio-input" | "tool-use" | "extended-thinking" | "structured-output" | "long-context" | "prompt-caching")[];
14
+ capabilities?: ("plain-text" | "plain-text-streaming" | "function-calling" | "function-calling-multi-turn" | "function-calling-multi-turn-streaming" | "function-calling-with-thinking" | "function-calling-with-thinking-streaming" | "vision-input" | "vision-input-streaming" | "audio-input" | "audio-input-streaming" | "video-input" | "video-input-streaming" | "document-input" | "document-input-streaming" | "image-output" | "image-output-streaming" | "code-execution" | "code-execution-streaming" | "reasoning-content" | "reasoning-content-streaming" | "grounding" | "grounding-streaming" | "files-api-reference" | "files-api-reference-streaming" | "redacted-thinking" | "redacted-thinking-streaming" | "structured-output" | "structured-output-streaming" | "long-context" | "prompt-caching")[];
17
15
  providers?: {
18
16
  mode: "prefer" | "pin";
19
17
  order: string[];
20
18
  };
21
19
  }[] | null;
22
- grantRequirements: {
23
- resource: string;
24
- action: string;
25
- source: "creator" | "invoker";
26
- effect?: "allow" | "deny" | "ask";
27
- conditions?: Record<string, unknown> | null;
20
+ credentialBindings: {
21
+ package: string;
22
+ handle: string;
23
+ provider: string;
24
+ locator: "tenant";
25
+ name?: string;
28
26
  }[] | null;
29
- toolPackages: {
30
- name: string;
31
- version: string;
32
- }[];
33
27
  id: string;
34
28
  name: string;
35
29
  createdAt: Date;
36
30
  updatedAt: Date;
37
31
  tenantId: string;
38
- status: "deployed" | "stopped";
39
- creatorPrincipalId: string;
32
+ creatorPrincipalId: string | null;
33
+ assetId: string | null;
34
+ wireHash: string | null;
40
35
  description: string | null;
41
- systemPrompt: string | null;
42
36
  currentVersion: string;
43
37
  };
44
- export declare function parseAgentVersionRow(row: typeof agentVersion.$inferSelect): {
38
+ export declare function parseWorkflowDefinitionVersionRow(row: typeof workflowDefinitionVersion.$inferSelect): {
45
39
  status: "active" | "inactive" | "failed";
46
40
  id: string;
47
41
  createdAt: Date;
48
- agentId: string;
42
+ definitionId: string;
49
43
  version: string;
44
+ approvedWireHash: string | null;
45
+ grantSnapshot: unknown;
50
46
  };
51
47
  export declare function parseGrantRow(row: typeof grant.$inferSelect): {
52
48
  effect: "allow" | "deny" | "ask";
@@ -62,6 +58,182 @@ export declare function parseGrantRow(row: typeof grant.$inferSelect): {
62
58
  resource: string;
63
59
  action: string;
64
60
  };
61
+ export declare function parseApprovalRow(row: typeof approval.$inferSelect): {
62
+ scope: "always" | "once" | null;
63
+ status: "pending" | "approved" | "rejected" | "timeout" | "expired";
64
+ toolDefinition: Record<string, unknown>;
65
+ toolArguments: Record<string, unknown>;
66
+ id: string;
67
+ createdAt: Date;
68
+ updatedAt: Date;
69
+ tenantId: string;
70
+ anchorRunId: string;
71
+ runId: string;
72
+ agentAddress: string;
73
+ correlationId: string;
74
+ timeoutAt: Date | null;
75
+ resolvedAt: Date | null;
76
+ };
77
+ export declare function parsePrincipalRow(row: typeof principal.$inferSelect): {
78
+ kind: "user" | "agent" | "workflow";
79
+ status: "active" | "suspended" | "invited" | "deactivated";
80
+ id: string;
81
+ createdAt: Date;
82
+ updatedAt: Date;
83
+ tenantId: string;
84
+ refId: string;
85
+ };
86
+ export declare function parseSignalCorrelationRow(row: typeof signalCorrelation.$inferSelect): {
87
+ kind: "approval";
88
+ createdAt: Date;
89
+ tenantId: string;
90
+ anchorRunId: string;
91
+ runId: string;
92
+ agentAddress: string;
93
+ correlationId: string;
94
+ resolvedAt: Date | null;
95
+ signalName: string;
96
+ signalId: string | null;
97
+ };
98
+ export declare function parseWorkflowRunRow(row: typeof workflowRun.$inferSelect): {
99
+ status: "deployed" | "failed" | "running" | "completed" | "cancelled";
100
+ modelPreferences: {
101
+ model: string;
102
+ providers: {
103
+ mode: "prefer" | "pin";
104
+ order: string[];
105
+ };
106
+ }[] | null;
107
+ id: string;
108
+ createdAt: Date;
109
+ tenantId: string;
110
+ definitionId: string;
111
+ principalId: string | null;
112
+ anchorRunId: string | null;
113
+ address: string | null;
114
+ publicKey: string | null;
115
+ sidecarId: string | null;
116
+ kernelId: string | null;
117
+ endedAt: Date | null;
118
+ };
119
+ export declare function parseWorkflowRunLaunchSpecRow(row: typeof workflowRunLaunchSpec.$inferSelect): {
120
+ frozenApprovalBundle: {
121
+ source: {
122
+ kind: "registry";
123
+ registry: string;
124
+ } | {
125
+ kind: "asset";
126
+ assetId: string;
127
+ package: {
128
+ format: "tarball";
129
+ } | {
130
+ format: "source";
131
+ commitSha: string;
132
+ packageName?: string;
133
+ };
134
+ };
135
+ entry: string;
136
+ projection: {
137
+ id: string;
138
+ triggers: unknown[];
139
+ stepOrder: string[];
140
+ steps: {
141
+ [x: string]: unknown;
142
+ };
143
+ state?: Record<string, unknown>;
144
+ credentialBindings?: {
145
+ package: string;
146
+ handle: string;
147
+ provider: string;
148
+ locator: "tenant";
149
+ name?: string;
150
+ }[];
151
+ };
152
+ closure: {
153
+ schemaVersion: "1";
154
+ topLevel: {
155
+ name: string;
156
+ version: string;
157
+ credentials?: {
158
+ handle: string;
159
+ scopes?: string[];
160
+ }[];
161
+ }[];
162
+ entries: {
163
+ name: string;
164
+ version: string;
165
+ source: {
166
+ kind: "registry";
167
+ registry: string;
168
+ integrity: string;
169
+ } | {
170
+ kind: "asset";
171
+ assetId: string;
172
+ package: {
173
+ format: "tarball";
174
+ path: string;
175
+ integrity: string;
176
+ } | {
177
+ format: "source";
178
+ commitSha: string;
179
+ packageDir: string;
180
+ treeOid: string;
181
+ };
182
+ };
183
+ os?: string[];
184
+ cpu?: string[];
185
+ tarballUrl?: string;
186
+ }[];
187
+ };
188
+ approvedWireHash: string;
189
+ approvedGrants: string[];
190
+ };
191
+ sourceOfferingIds: string[];
192
+ deployContent: Record<string, unknown>;
193
+ toolPackagePins: {
194
+ name: string;
195
+ version: string;
196
+ }[] | null;
197
+ createdAt: Date;
198
+ anchorRunId: string;
199
+ sessionId: string;
200
+ schemaVersion: number;
201
+ deploymentDomain: string;
202
+ sourceAuthorityPrincipalId: string;
203
+ defaultSourceOfferingId: string;
204
+ };
205
+ export declare function parseWorkflowRunDispatchRow(row: typeof workflowRunDispatch.$inferSelect): {
206
+ kind: "signal" | "mail";
207
+ status: "failed" | "pending" | "acknowledged" | "settled";
208
+ stepGrants: {
209
+ id: string;
210
+ resource: string;
211
+ action: string;
212
+ effect: "allow" | "deny" | "ask";
213
+ origin: "role" | "system" | "creator" | "invoker";
214
+ conditions: {
215
+ [x: string]: unknown;
216
+ } | null;
217
+ expiresAt: Date | null;
218
+ roleId: string | null;
219
+ principalId: string | null;
220
+ }[];
221
+ id: string;
222
+ createdAt: Date;
223
+ updatedAt: Date;
224
+ anchorRunId: string;
225
+ messageId: string;
226
+ nextAttemptAt: Date | null;
227
+ failureCode: string | null;
228
+ failureMessage: string | null;
229
+ rawMessage: Uint8Array<ArrayBufferLike>;
230
+ acknowledgedGeneration: number | null;
231
+ attemptCount: number;
232
+ deliveryLeaseId: string | null;
233
+ deliveryLeaseExpiresAt: Date | null;
234
+ acknowledgedAt: Date | null;
235
+ settledAt: Date | null;
236
+ };
65
237
  export declare function parseOfferingRow(row: typeof offering.$inferSelect): {
66
238
  pricing: Record<string, unknown> | null;
67
239
  schema: Record<string, unknown> | null;
@@ -75,7 +247,7 @@ export declare function parseOfferingRow(row: typeof offering.$inferSelect): {
75
247
  };
76
248
  export declare function parseCredentialRow(row: typeof credential.$inferSelect): {
77
249
  type: "api_key" | "oauth_token" | "certificate" | "other";
78
- status: "active" | "expired" | "revoked" | "error";
250
+ status: "active" | "error" | "expired" | "revoked";
79
251
  metadata: Record<string, unknown> | null;
80
252
  id: string;
81
253
  name: string;
@@ -99,6 +271,7 @@ export declare function parseProviderRow(row: typeof provider.$inferSelect): {
99
271
  updatedAt: Date;
100
272
  tenantId: string;
101
273
  plugin: string;
274
+ apiBaseUrl: string | null;
102
275
  authorizationUrl: string | null;
103
276
  tokenUrl: string | null;
104
277
  userInfoUrl: string | null;
@@ -117,7 +290,8 @@ export declare function parseModelProviderRow(row: typeof modelProvider.$inferSe
117
290
  credentialId: string | null;
118
291
  };
119
292
  export declare function parseModelOfferingRow(row: typeof modelOffering.$inferSelect): {
120
- capabilities: ("vision" | "audio-input" | "tool-use" | "extended-thinking" | "structured-output" | "long-context" | "prompt-caching")[];
293
+ capabilities: ("plain-text" | "plain-text-streaming" | "function-calling" | "function-calling-multi-turn" | "function-calling-multi-turn-streaming" | "function-calling-with-thinking" | "function-calling-with-thinking-streaming" | "vision-input" | "vision-input-streaming" | "audio-input" | "audio-input-streaming" | "video-input" | "video-input-streaming" | "document-input" | "document-input-streaming" | "image-output" | "image-output-streaming" | "code-execution" | "code-execution-streaming" | "reasoning-content" | "reasoning-content-streaming" | "grounding" | "grounding-streaming" | "files-api-reference" | "files-api-reference-streaming" | "redacted-thinking" | "redacted-thinking-streaming" | "structured-output" | "structured-output-streaming" | "long-context" | "prompt-caching")[];
294
+ quirks: Record<string, unknown> | null;
121
295
  id: string;
122
296
  createdAt: Date;
123
297
  updatedAt: Date;
@@ -129,7 +303,13 @@ export declare function parseModelOfferingRow(row: typeof modelOffering.$inferSe
129
303
  deploymentTags: string[];
130
304
  };
131
305
  export declare function parseTenantRow(row: typeof tenant.$inferSelect): {
132
- config: Record<string, unknown> | null;
306
+ config: {
307
+ [x: string]: unknown;
308
+ sidecarPlacement?: {
309
+ sharing: "exclusive";
310
+ reuse?: "never" | "same-deployment";
311
+ };
312
+ } | null;
133
313
  domain: string;
134
314
  id: string;
135
315
  name: string;
@@ -151,10 +331,10 @@ export declare function parseWalletRow(row: typeof wallet.$inferSelect): {
151
331
  };
152
332
  export declare function parseTransactionRow(row: typeof transaction.$inferSelect): {
153
333
  direction: "inbound" | "outbound";
154
- status: "failed" | "pending" | "completed";
334
+ status: "failed" | "completed" | "pending";
155
335
  id: string;
156
336
  createdAt: Date;
157
- agentId: string | null;
337
+ runId: string | null;
158
338
  currency: string;
159
339
  walletId: string;
160
340
  amount: string;
package/dist/parse-row.js CHANGED
@@ -1,12 +1,38 @@
1
1
  import { type } from "arktype";
2
- import { Capability, CredentialRequirement, GrantRequirement, grantEffects, grantOrigins, ModelProviderPlugin, ModelRequirements, } from "@intx/types";
3
- import { RepoAction } from "@intx/types/sidecar";
2
+ import { Capability, CredentialBinding, GrantRequirement, grantEffects, grantOrigins, InvokerModelPreferences, ModelProviderPlugin, ModelRequirements, principalKinds, principalStatuses, signalKinds, TenantConfig, workflowDefinitionStatuses, workflowDefinitionVersionStatuses, } from "@intx/types";
3
+ import { WireGrantRule } from "@intx/types/grant-wire";
4
+ import { FrozenApprovalBundle, RepoAction } from "@intx/types/sidecar";
4
5
  import { ToolPackagePinArray } from "@intx/types/tool-packages";
5
6
  const JSONObject = type("Record<string, unknown>");
7
+ const StringArray = type("string[]");
8
+ const WireGrantRuleArray = WireGrantRule.array();
6
9
  const GrantEffectValidator = type.enumerated(...grantEffects);
7
10
  const GrantOriginValidator = type.enumerated(...grantOrigins);
8
- const agentVersionStatuses = ["active", "inactive", "failed"];
9
- const AgentVersionStatusValidator = type.enumerated(...agentVersionStatuses);
11
+ const approvalScopes = ["once", "always"];
12
+ const ApprovalScopeValidator = type.enumerated(...approvalScopes);
13
+ const approvalStatuses = [
14
+ "pending",
15
+ "approved",
16
+ "rejected",
17
+ "timeout",
18
+ "expired",
19
+ ];
20
+ const ApprovalStatusValidator = type.enumerated(...approvalStatuses);
21
+ const SignalKindValidator = type.enumerated(...signalKinds);
22
+ const workflowRunStatuses = [
23
+ "deployed",
24
+ "running",
25
+ "completed",
26
+ "failed",
27
+ "cancelled",
28
+ ];
29
+ const WorkflowRunStatusValidator = type.enumerated(...workflowRunStatuses);
30
+ const WorkflowRunDispatchStatusValidator = type.enumerated("pending", "acknowledged", "settled", "failed");
31
+ const WorkflowRunDispatchKindValidator = type.enumerated("mail", "signal");
32
+ const WorkflowDefinitionStatusValidator = type.enumerated(...workflowDefinitionStatuses);
33
+ const WorkflowDefinitionVersionStatusValidator = type.enumerated(...workflowDefinitionVersionStatuses);
34
+ const PrincipalKindValidator = type.enumerated(...principalKinds);
35
+ const PrincipalStatusValidator = type.enumerated(...principalStatuses);
10
36
  const credentialTypes = [
11
37
  "api_key",
12
38
  "oauth_token",
@@ -31,35 +57,36 @@ const turnPartTypes = [
31
57
  "file",
32
58
  "error",
33
59
  "refusal",
60
+ "safety_rating",
34
61
  "step-start",
35
62
  "step-finish",
36
63
  "snapshot",
37
64
  "patch",
38
65
  ];
39
66
  const TurnPartTypeValidator = type.enumerated(...turnPartTypes);
40
- export function parseAgentRow(row) {
67
+ export function parseWorkflowDefinitionRow(row) {
41
68
  return {
42
69
  ...row,
43
- contextConfig: row.contextConfig !== null ? JSONObject.assert(row.contextConfig) : null,
44
- initialState: row.initialState !== null ? JSONObject.assert(row.initialState) : null,
45
- modelConfig: row.modelConfig !== null ? JSONObject.assert(row.modelConfig) : null,
46
- capabilities: row.capabilities !== null ? JSONObject.assert(row.capabilities) : null,
47
- credentialRequirements: row.credentialRequirements !== null
48
- ? CredentialRequirement.array().assert(row.credentialRequirements)
70
+ status: WorkflowDefinitionStatusValidator.assert(row.status),
71
+ grantRequirements: row.grantRequirements !== null
72
+ ? GrantRequirement.array().assert(row.grantRequirements)
49
73
  : null,
50
74
  modelRequirements: row.modelRequirements !== null
51
75
  ? ModelRequirements.assert(row.modelRequirements)
52
76
  : null,
53
- grantRequirements: row.grantRequirements !== null
54
- ? GrantRequirement.array().assert(row.grantRequirements)
55
- : null,
56
- toolPackages: ToolPackagePinArray.assert(row.toolPackages),
77
+ // Nullable jsonb: `null` on a real drizzle row, `undefined` only on a
78
+ // partial row-shaped test stub that predates the column. Both mean "no
79
+ // bindings" -- treat them alike rather than asserting `undefined` as an
80
+ // array.
81
+ credentialBindings: row.credentialBindings === null || row.credentialBindings === undefined
82
+ ? null
83
+ : CredentialBinding.array().assert(row.credentialBindings),
57
84
  };
58
85
  }
59
- export function parseAgentVersionRow(row) {
86
+ export function parseWorkflowDefinitionVersionRow(row) {
60
87
  return {
61
88
  ...row,
62
- status: AgentVersionStatusValidator.assert(row.status),
89
+ status: WorkflowDefinitionVersionStatusValidator.assert(row.status),
63
90
  };
64
91
  }
65
92
  export function parseGrantRow(row) {
@@ -70,6 +97,69 @@ export function parseGrantRow(row) {
70
97
  conditions: row.conditions !== null ? JSONObject.assert(row.conditions) : null,
71
98
  };
72
99
  }
100
+ export function parseApprovalRow(row) {
101
+ return {
102
+ ...row,
103
+ scope: row.scope !== null ? ApprovalScopeValidator.assert(row.scope) : null,
104
+ status: ApprovalStatusValidator.assert(row.status),
105
+ toolDefinition: JSONObject.assert(row.toolDefinition),
106
+ toolArguments: JSONObject.assert(row.toolArguments),
107
+ };
108
+ }
109
+ export function parsePrincipalRow(row) {
110
+ return {
111
+ ...row,
112
+ kind: PrincipalKindValidator.assert(row.kind),
113
+ status: PrincipalStatusValidator.assert(row.status),
114
+ };
115
+ }
116
+ export function parseSignalCorrelationRow(row) {
117
+ return {
118
+ ...row,
119
+ kind: SignalKindValidator.assert(row.kind),
120
+ };
121
+ }
122
+ export function parseWorkflowRunRow(row) {
123
+ return {
124
+ ...row,
125
+ status: WorkflowRunStatusValidator.assert(row.status),
126
+ modelPreferences: row.modelPreferences !== null
127
+ ? InvokerModelPreferences.assert(row.modelPreferences)
128
+ : null,
129
+ };
130
+ }
131
+ export function parseWorkflowRunLaunchSpecRow(row) {
132
+ const sourceOfferingIds = StringArray.assert(row.sourceOfferingIds);
133
+ assertLaunchSpecSources(sourceOfferingIds, row.defaultSourceOfferingId);
134
+ return {
135
+ ...row,
136
+ frozenApprovalBundle: FrozenApprovalBundle.assert(row.frozenApprovalBundle),
137
+ sourceOfferingIds,
138
+ deployContent: JSONObject.assert(row.deployContent),
139
+ toolPackagePins: row.toolPackagePins !== null
140
+ ? ToolPackagePinArray.assert(row.toolPackagePins)
141
+ : null,
142
+ };
143
+ }
144
+ export function parseWorkflowRunDispatchRow(row) {
145
+ return {
146
+ ...row,
147
+ kind: WorkflowRunDispatchKindValidator.assert(row.kind),
148
+ status: WorkflowRunDispatchStatusValidator.assert(row.status),
149
+ stepGrants: WireGrantRuleArray.assert(row.stepGrants),
150
+ };
151
+ }
152
+ function assertLaunchSpecSources(sourceOfferingIds, defaultSourceOfferingId) {
153
+ if (sourceOfferingIds.length === 0) {
154
+ throw new Error("workflow launch spec requires at least one source offering");
155
+ }
156
+ if (new Set(sourceOfferingIds).size !== sourceOfferingIds.length) {
157
+ throw new Error("workflow launch spec source offering ids must be unique");
158
+ }
159
+ if (!sourceOfferingIds.includes(defaultSourceOfferingId)) {
160
+ throw new Error(`workflow launch spec default source ${defaultSourceOfferingId} is not in its source offering ids`);
161
+ }
162
+ }
73
163
  export function parseOfferingRow(row) {
74
164
  return {
75
165
  ...row,
@@ -101,12 +191,13 @@ export function parseModelOfferingRow(row) {
101
191
  return {
102
192
  ...row,
103
193
  capabilities: Capability.array().assert(row.capabilities),
194
+ quirks: row.quirks !== null ? JSONObject.assert(row.quirks) : null,
104
195
  };
105
196
  }
106
197
  export function parseTenantRow(row) {
107
198
  return {
108
199
  ...row,
109
- config: row.config !== null ? JSONObject.assert(row.config) : null,
200
+ config: row.config !== null ? TenantConfig.assert(row.config) : null,
110
201
  };
111
202
  }
112
203
  export function parseWalletRow(row) {
@@ -0,0 +1,13 @@
1
+ import { type CredentialCipher } from "@intx/types";
2
+ import type { DB } from "./client.js";
3
+ export type RekeyReport = {
4
+ /** Credential `secret` columns newly encrypted. */
5
+ credentialSecrets: number;
6
+ /** Credential `refresh_secret` columns newly encrypted. */
7
+ credentialRefreshSecrets: number;
8
+ /** OAuth-client `client_secret` columns newly encrypted. */
9
+ oauthClientSecrets: number;
10
+ /** Columns already encrypted and left unchanged. */
11
+ alreadyEncrypted: number;
12
+ };
13
+ export declare function rekeyCredentialSecrets(db: DB["db"], cipher: CredentialCipher): Promise<RekeyReport>;
@@ -0,0 +1,61 @@
1
+ // Re-key existing credential secrets: encrypt any secret still stored as
2
+ // plaintext, in place, under the given cipher.
3
+ //
4
+ // Ordinarily every secret is encrypted at its write site, so on a database
5
+ // created after encryption-at-rest landed there is nothing to do. This pass
6
+ // exists for the transition: a database whose rows predate encryption still
7
+ // holds plaintext, and the strict read path throws on a non-ciphertext value.
8
+ // Running this once (against a stopped hub, so no write races an un-re-keyed
9
+ // row) brings every row to the encrypted form.
10
+ //
11
+ // Idempotent: a value already a ciphertext is skipped, so the pass is safe to
12
+ // re-run or resume after a partial failure.
13
+ import { eq } from "drizzle-orm";
14
+ import { credentialAad } from "@intx/types";
15
+ import { isCiphertext } from "@intx/crypto";
16
+ import { credential } from "./schema/credentials.js";
17
+ import { oauthClient } from "./schema/oauth-clients.js";
18
+ export async function rekeyCredentialSecrets(db, cipher) {
19
+ const report = {
20
+ credentialSecrets: 0,
21
+ credentialRefreshSecrets: 0,
22
+ oauthClientSecrets: 0,
23
+ alreadyEncrypted: 0,
24
+ };
25
+ for (const row of await db.select().from(credential)) {
26
+ const updates = {};
27
+ if (isCiphertext(row.secret)) {
28
+ report.alreadyEncrypted += 1;
29
+ }
30
+ else {
31
+ updates.secret = await cipher.encrypt(row.secret, credentialAad(row.id, "secret"));
32
+ report.credentialSecrets += 1;
33
+ }
34
+ if (row.refreshSecret !== null) {
35
+ if (isCiphertext(row.refreshSecret)) {
36
+ report.alreadyEncrypted += 1;
37
+ }
38
+ else {
39
+ updates.refreshSecret = await cipher.encrypt(row.refreshSecret, credentialAad(row.id, "refreshSecret"));
40
+ report.credentialRefreshSecrets += 1;
41
+ }
42
+ }
43
+ if (updates.secret !== undefined || updates.refreshSecret !== undefined) {
44
+ await db.update(credential).set(updates).where(eq(credential.id, row.id));
45
+ }
46
+ }
47
+ for (const row of await db.select().from(oauthClient)) {
48
+ if (isCiphertext(row.clientSecret)) {
49
+ report.alreadyEncrypted += 1;
50
+ continue;
51
+ }
52
+ await db
53
+ .update(oauthClient)
54
+ .set({
55
+ clientSecret: await cipher.encrypt(row.clientSecret, credentialAad(row.id, "clientSecret")),
56
+ })
57
+ .where(eq(oauthClient.id, row.id));
58
+ report.oauthClientSecrets += 1;
59
+ }
60
+ return report;
61
+ }