@jami-studio/orchestra 0.1.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/LICENSE ADDED
@@ -0,0 +1,159 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20
+ or more of the outstanding shares, or (iii) beneficial ownership of such
21
+ entity.
22
+
23
+ "You" or "Your" shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source, and
28
+ configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation or
31
+ translation of a Source form, including but not limited to compiled object
32
+ code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object form,
35
+ made available under the License, as indicated by a copyright notice that is
36
+ included in or attached to the work.
37
+
38
+ "Derivative Works" shall mean any work, whether in Source or Object form,
39
+ that is based on or derived from the Work and for which the editorial
40
+ revisions, annotations, elaborations, or other modifications represent, as a
41
+ whole, an original work of authorship. For the purposes of this License,
42
+ Derivative Works shall not include works that remain separable from, or
43
+ merely link or bind by name to the interfaces of, the Work and Derivative
44
+ Works thereof.
45
+
46
+ "Contribution" shall mean any work of authorship, including the original
47
+ version of the Work and any modifications or additions to that Work or
48
+ Derivative Works thereof, that is intentionally submitted to Licensor for
49
+ inclusion in the Work by the copyright owner or by an individual or Legal
50
+ Entity authorized to submit on behalf of the copyright owner. For the purposes
51
+ of this definition, "submitted" means any form of electronic, verbal, or
52
+ written communication sent to the Licensor or its representatives, including
53
+ but not limited to communication on electronic mailing lists, source code
54
+ control systems, and issue tracking systems that are managed by, or on behalf
55
+ of, the Licensor for the purpose of discussing and improving the Work, but
56
+ excluding communication that is conspicuously marked or otherwise designated
57
+ in writing by the copyright owner as "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
60
+ behalf of whom a Contribution has been received by Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
64
+ License, each Contributor hereby grants to You a perpetual, worldwide,
65
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
66
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
67
+ sublicense, and distribute the Work and such Derivative Works in Source or
68
+ Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of this
71
+ License, each Contributor hereby grants to You a perpetual, worldwide,
72
+ non-exclusive, no-charge, royalty-free, irrevocable patent license to make,
73
+ have made, use, offer to sell, sell, import, and otherwise transfer the Work,
74
+ where such license applies only to those patent claims licensable by such
75
+ Contributor that are necessarily infringed by their Contribution alone or by
76
+ combination of their Contribution with the Work to which such Contribution was
77
+ submitted. If You institute patent litigation against any entity alleging that
78
+ the Work or a Contribution incorporated within the Work constitutes direct or
79
+ contributory patent infringement, then any patent licenses granted to You
80
+ under this License for that Work shall terminate as of the date such
81
+ litigation is filed.
82
+
83
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
84
+ Derivative Works thereof in any medium, with or without modifications, and in
85
+ Source or Object form, provided that You meet the following conditions:
86
+
87
+ (a) You must give any other recipients of the Work or Derivative Works a copy
88
+ of this License; and
89
+
90
+ (b) You must cause any modified files to carry prominent notices stating that
91
+ You changed the files; and
92
+
93
+ (c) You must retain, in the Source form of any Derivative Works that You
94
+ distribute, all copyright, patent, trademark, and attribution notices from the
95
+ Source form of the Work, excluding those notices that do not pertain to any
96
+ part of the Derivative Works; and
97
+
98
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
99
+ any Derivative Works that You distribute must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, excluding those notices
101
+ that do not pertain to any part of the Derivative Works, in at least one of
102
+ the following places: within a NOTICE text file distributed as part of the
103
+ Derivative Works; within the Source form or documentation, if provided along
104
+ with the Derivative Works; or within a display generated by the Derivative
105
+ Works, if and wherever such third-party notices normally appear. The contents
106
+ of the NOTICE file are for informational purposes only and do not modify the
107
+ License. You may add Your own attribution notices within Derivative Works that
108
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
109
+ provided that such additional attribution notices cannot be construed as
110
+ modifying the License.
111
+
112
+ You may add Your own copyright statement to Your modifications and may provide
113
+ additional or different license terms and conditions for use, reproduction, or
114
+ distribution of Your modifications, or for any such Derivative Works as a
115
+ whole, provided Your use, reproduction, and distribution of the Work otherwise
116
+ complies with the conditions stated in this License.
117
+
118
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
119
+ Contribution intentionally submitted for inclusion in the Work by You to the
120
+ Licensor shall be under the terms and conditions of this License, without any
121
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
122
+ supersede or modify the terms of any separate license agreement you may have
123
+ executed with Licensor regarding such Contributions.
124
+
125
+ 6. Trademarks. This License does not grant permission to use the trade names,
126
+ trademarks, service marks, or product names of the Licensor, except as
127
+ required for reasonable and customary use in describing the origin of the Work
128
+ and reproducing the content of the NOTICE file.
129
+
130
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
131
+ writing, Licensor provides the Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR
132
+ CONDITIONS OF ANY KIND, either express or implied, including, without
133
+ limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
134
+ MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
135
+ responsible for determining the appropriateness of using or redistributing the
136
+ Work and assume any risks associated with Your exercise of permissions under
137
+ this License.
138
+
139
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
140
+ tort, contract, or otherwise, unless required by applicable law or agreed to in
141
+ writing, shall any Contributor be liable to You for damages, including any
142
+ direct, indirect, special, incidental, or consequential damages of any
143
+ character arising as a result of this License or out of the use or inability
144
+ to use the Work, including but not limited to damages for loss of goodwill,
145
+ work stoppage, computer failure or malfunction, or any and all other
146
+ commercial damages or losses, even if such Contributor has been advised of the
147
+ possibility of such damages.
148
+
149
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
150
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
151
+ acceptance of support, warranty, indemnity, or other liability obligations
152
+ and/or rights consistent with this License. However, in accepting such
153
+ obligations, You may act only on Your own behalf and on Your sole
154
+ responsibility, not on behalf of any other Contributor, and only if You agree
155
+ to indemnify, defend, and hold each Contributor harmless for any liability
156
+ incurred by, or claims asserted against, such Contributor by reason of your
157
+ accepting any such warranty or additional liability.
158
+
159
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @jami-studio/orchestra
2
+
3
+ `@jami-studio/orchestra` is the Jami Studio orchestration control-plane package. It owns the durable dispatch state that sits above harness runs without moving model runtime, tool execution, memory, artifacts, or UI rendering out of their existing packages.
4
+
5
+ ## Current package surface
6
+
7
+ - A 13-table Drizzle schema exported for Postgres and libSQL.
8
+ - In-memory control-plane implementation for directory records, agents, dreams, tasks, runs, run events, tool calls, artifacts, grants, approvals, sealed secrets, key versions, and audit logs.
9
+ - Sealed-at-rest vault envelopes using AES-256-GCM, explicit key-version records, and a rotation path that reseals existing secret envelopes.
10
+ - Migration fixture descriptors for the initial vault schema and key rotation.
11
+ - Source attribution for BuilderIO `@agent-native/dispatch@0.11.5`.
12
+
13
+ ## Source attribution
14
+
15
+ The package records official npm metadata for BuilderIO `@agent-native/dispatch@0.11.5` in `DISPATCH_SOURCE_ATTRIBUTION`: MIT license, upstream repository, package version, and tarball URL verified on 2026-06-22. The implementation does not vendor upstream source files; dispatch concepts are reimplemented behind Jami-owned schema, approvals, grants, vault, and audit contracts.
16
+
17
+ ## Verification
18
+
19
+ ```powershell
20
+ pnpm -C orchestra test
21
+ ```
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@jami-studio/orchestra",
3
+ "version": "0.1.0",
4
+ "description": "Jami Studio orchestration control-plane schema, sealed vault, approvals, grants, audit, dreams, and dispatch state.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/studio-jami/jami-harness.git",
9
+ "directory": "orchestra"
10
+ },
11
+ "type": "module",
12
+ "exports": {
13
+ ".": "./src/index.mjs",
14
+ "./drizzle": "./src/drizzle.mjs"
15
+ },
16
+ "dependencies": {
17
+ "drizzle-orm": "^0.45.2",
18
+ "jose": "6.2.3"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "files": [
24
+ "src/",
25
+ "README.md"
26
+ ],
27
+ "jamiRelease": {
28
+ "publishable": true
29
+ },
30
+ "scripts": {
31
+ "test": "node --test test/*.test.mjs"
32
+ }
33
+ }
@@ -0,0 +1,321 @@
1
+ import { jsonb, integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";
2
+ import { integer as sqliteInteger, sqliteTable, text as sqliteText } from "drizzle-orm/sqlite-core";
3
+ import { ORCHESTRA_SCHEMA_VERSION, ORCHESTRA_TABLES } from "./schema.mjs";
4
+
5
+ const pgJson = (name) => jsonb(name).notNull();
6
+ const pgCreated = (name) => timestamp(name, { withTimezone: true }).notNull();
7
+ const pgOptionalTime = (name) => timestamp(name, { withTimezone: true });
8
+ const sqliteJson = (name) => sqliteText(name, { mode: "json" }).notNull();
9
+ const sqliteCreated = (name) => sqliteText(name).notNull();
10
+ const sqliteOptionalTime = (name) => sqliteText(name);
11
+
12
+ export const pgOrchestraOrgDirectory = pgTable("orchestra_org_directory", {
13
+ actorId: text("actor_id").primaryKey(),
14
+ actorType: text("actor_type").notNull(),
15
+ displayName: text("display_name").notNull(),
16
+ status: text("status").notNull(),
17
+ metadata: pgJson("metadata"),
18
+ createdAt: pgCreated("created_at"),
19
+ updatedAt: pgCreated("updated_at"),
20
+ });
21
+
22
+ export const pgOrchestraAgents = pgTable("orchestra_agents", {
23
+ agentId: text("agent_id").primaryKey(),
24
+ directoryActorId: text("directory_actor_id").notNull(),
25
+ modelFamily: text("model_family").notNull(),
26
+ capabilities: pgJson("capabilities"),
27
+ status: text("status").notNull(),
28
+ createdAt: pgCreated("created_at"),
29
+ updatedAt: pgCreated("updated_at"),
30
+ });
31
+
32
+ export const pgOrchestraDreams = pgTable("orchestra_dreams", {
33
+ dreamId: text("dream_id").primaryKey(),
34
+ title: text("title").notNull(),
35
+ status: text("status").notNull(),
36
+ ownerActorId: text("owner_actor_id").notNull(),
37
+ priority: integer("priority").notNull(),
38
+ metadata: pgJson("metadata"),
39
+ createdAt: pgCreated("created_at"),
40
+ updatedAt: pgCreated("updated_at"),
41
+ });
42
+
43
+ export const pgOrchestraTasks = pgTable("orchestra_tasks", {
44
+ taskId: text("task_id").primaryKey(),
45
+ dreamId: text("dream_id"),
46
+ assigneeAgentId: text("assignee_agent_id").notNull(),
47
+ status: text("status").notNull(),
48
+ input: pgJson("input"),
49
+ requiredScopes: pgJson("required_scopes"),
50
+ createdAt: pgCreated("created_at"),
51
+ updatedAt: pgCreated("updated_at"),
52
+ });
53
+
54
+ export const pgOrchestraRuns = pgTable("orchestra_runs", {
55
+ runId: text("run_id").primaryKey(),
56
+ taskId: text("task_id").notNull(),
57
+ agentId: text("agent_id").notNull(),
58
+ status: text("status").notNull(),
59
+ attempt: integer("attempt").notNull(),
60
+ startedAt: pgCreated("started_at"),
61
+ completedAt: pgOptionalTime("completed_at"),
62
+ metadata: pgJson("metadata"),
63
+ });
64
+
65
+ export const pgOrchestraRunEvents = pgTable("orchestra_run_events", {
66
+ eventId: text("event_id").primaryKey(),
67
+ runId: text("run_id").notNull(),
68
+ eventType: text("event_type").notNull(),
69
+ sequence: integer("sequence").notNull(),
70
+ payload: pgJson("payload"),
71
+ recordedAt: pgCreated("recorded_at"),
72
+ });
73
+
74
+ export const pgOrchestraToolCalls = pgTable("orchestra_tool_calls", {
75
+ toolCallId: text("tool_call_id").primaryKey(),
76
+ runId: text("run_id").notNull(),
77
+ toolName: text("tool_name").notNull(),
78
+ risk: text("risk").notNull(),
79
+ status: text("status").notNull(),
80
+ inputRef: text("input_ref").notNull(),
81
+ outputRef: text("output_ref"),
82
+ createdAt: pgCreated("created_at"),
83
+ });
84
+
85
+ export const pgOrchestraArtifacts = pgTable("orchestra_artifacts", {
86
+ artifactId: text("artifact_id").primaryKey(),
87
+ runId: text("run_id").notNull(),
88
+ kind: text("kind").notNull(),
89
+ uri: text("uri").notNull(),
90
+ provenance: pgJson("provenance"),
91
+ createdAt: pgCreated("created_at"),
92
+ });
93
+
94
+ export const pgOrchestraGrants = pgTable("orchestra_grants", {
95
+ grantId: text("grant_id").primaryKey(),
96
+ subjectActorId: text("subject_actor_id").notNull(),
97
+ scope: text("scope").notNull(),
98
+ resourceRef: text("resource_ref").notNull(),
99
+ status: text("status").notNull(),
100
+ expiresAt: pgOptionalTime("expires_at"),
101
+ createdAt: pgCreated("created_at"),
102
+ });
103
+
104
+ export const pgOrchestraApprovals = pgTable("orchestra_approvals", {
105
+ approvalId: text("approval_id").primaryKey(),
106
+ runId: text("run_id").notNull(),
107
+ actionId: text("action_id").notNull(),
108
+ requestedBy: text("requested_by").notNull(),
109
+ decidedBy: text("decided_by"),
110
+ status: text("status").notNull(),
111
+ requiredScopes: pgJson("required_scopes"),
112
+ requestedAt: pgCreated("requested_at"),
113
+ decidedAt: pgOptionalTime("decided_at"),
114
+ expiresAt: pgOptionalTime("expires_at"),
115
+ });
116
+
117
+ export const pgOrchestraSecrets = pgTable("orchestra_secrets", {
118
+ secretId: text("secret_id").primaryKey(),
119
+ name: text("name").notNull(),
120
+ keyVersionId: text("key_version_id").notNull(),
121
+ sealedPayload: pgJson("sealed_payload"),
122
+ metadata: pgJson("metadata"),
123
+ createdAt: pgCreated("created_at"),
124
+ rotatedAt: pgOptionalTime("rotated_at"),
125
+ });
126
+
127
+ export const pgOrchestraSecretKeyVersions = pgTable("orchestra_secret_key_versions", {
128
+ keyVersionId: text("key_version_id").primaryKey(),
129
+ status: text("status").notNull(),
130
+ algorithm: text("algorithm").notNull(),
131
+ createdAt: pgCreated("created_at"),
132
+ retiredAt: pgOptionalTime("retired_at"),
133
+ rotationPolicy: pgJson("rotation_policy"),
134
+ });
135
+
136
+ export const pgOrchestraAuditLogs = pgTable("orchestra_audit_logs", {
137
+ auditId: text("audit_id").primaryKey(),
138
+ actorId: text("actor_id").notNull(),
139
+ eventType: text("event_type").notNull(),
140
+ resourceRef: text("resource_ref").notNull(),
141
+ outcome: text("outcome").notNull(),
142
+ summary: text("summary").notNull(),
143
+ recordedAt: pgCreated("recorded_at"),
144
+ metadata: pgJson("metadata"),
145
+ });
146
+
147
+ export const libsqlOrchestraOrgDirectory = sqliteTable("orchestra_org_directory", {
148
+ actorId: sqliteText("actor_id").primaryKey(),
149
+ actorType: sqliteText("actor_type").notNull(),
150
+ displayName: sqliteText("display_name").notNull(),
151
+ status: sqliteText("status").notNull(),
152
+ metadata: sqliteJson("metadata"),
153
+ createdAt: sqliteCreated("created_at"),
154
+ updatedAt: sqliteCreated("updated_at"),
155
+ });
156
+
157
+ export const libsqlOrchestraAgents = sqliteTable("orchestra_agents", {
158
+ agentId: sqliteText("agent_id").primaryKey(),
159
+ directoryActorId: sqliteText("directory_actor_id").notNull(),
160
+ modelFamily: sqliteText("model_family").notNull(),
161
+ capabilities: sqliteJson("capabilities"),
162
+ status: sqliteText("status").notNull(),
163
+ createdAt: sqliteCreated("created_at"),
164
+ updatedAt: sqliteCreated("updated_at"),
165
+ });
166
+
167
+ export const libsqlOrchestraDreams = sqliteTable("orchestra_dreams", {
168
+ dreamId: sqliteText("dream_id").primaryKey(),
169
+ title: sqliteText("title").notNull(),
170
+ status: sqliteText("status").notNull(),
171
+ ownerActorId: sqliteText("owner_actor_id").notNull(),
172
+ priority: sqliteInteger("priority").notNull(),
173
+ metadata: sqliteJson("metadata"),
174
+ createdAt: sqliteCreated("created_at"),
175
+ updatedAt: sqliteCreated("updated_at"),
176
+ });
177
+
178
+ export const libsqlOrchestraTasks = sqliteTable("orchestra_tasks", {
179
+ taskId: sqliteText("task_id").primaryKey(),
180
+ dreamId: sqliteText("dream_id"),
181
+ assigneeAgentId: sqliteText("assignee_agent_id").notNull(),
182
+ status: sqliteText("status").notNull(),
183
+ input: sqliteJson("input"),
184
+ requiredScopes: sqliteJson("required_scopes"),
185
+ createdAt: sqliteCreated("created_at"),
186
+ updatedAt: sqliteCreated("updated_at"),
187
+ });
188
+
189
+ export const libsqlOrchestraRuns = sqliteTable("orchestra_runs", {
190
+ runId: sqliteText("run_id").primaryKey(),
191
+ taskId: sqliteText("task_id").notNull(),
192
+ agentId: sqliteText("agent_id").notNull(),
193
+ status: sqliteText("status").notNull(),
194
+ attempt: sqliteInteger("attempt").notNull(),
195
+ startedAt: sqliteCreated("started_at"),
196
+ completedAt: sqliteOptionalTime("completed_at"),
197
+ metadata: sqliteJson("metadata"),
198
+ });
199
+
200
+ export const libsqlOrchestraRunEvents = sqliteTable("orchestra_run_events", {
201
+ eventId: sqliteText("event_id").primaryKey(),
202
+ runId: sqliteText("run_id").notNull(),
203
+ eventType: sqliteText("event_type").notNull(),
204
+ sequence: sqliteInteger("sequence").notNull(),
205
+ payload: sqliteJson("payload"),
206
+ recordedAt: sqliteCreated("recorded_at"),
207
+ });
208
+
209
+ export const libsqlOrchestraToolCalls = sqliteTable("orchestra_tool_calls", {
210
+ toolCallId: sqliteText("tool_call_id").primaryKey(),
211
+ runId: sqliteText("run_id").notNull(),
212
+ toolName: sqliteText("tool_name").notNull(),
213
+ risk: sqliteText("risk").notNull(),
214
+ status: sqliteText("status").notNull(),
215
+ inputRef: sqliteText("input_ref").notNull(),
216
+ outputRef: sqliteText("output_ref"),
217
+ createdAt: sqliteCreated("created_at"),
218
+ });
219
+
220
+ export const libsqlOrchestraArtifacts = sqliteTable("orchestra_artifacts", {
221
+ artifactId: sqliteText("artifact_id").primaryKey(),
222
+ runId: sqliteText("run_id").notNull(),
223
+ kind: sqliteText("kind").notNull(),
224
+ uri: sqliteText("uri").notNull(),
225
+ provenance: sqliteJson("provenance"),
226
+ createdAt: sqliteCreated("created_at"),
227
+ });
228
+
229
+ export const libsqlOrchestraGrants = sqliteTable("orchestra_grants", {
230
+ grantId: sqliteText("grant_id").primaryKey(),
231
+ subjectActorId: sqliteText("subject_actor_id").notNull(),
232
+ scope: sqliteText("scope").notNull(),
233
+ resourceRef: sqliteText("resource_ref").notNull(),
234
+ status: sqliteText("status").notNull(),
235
+ expiresAt: sqliteOptionalTime("expires_at"),
236
+ createdAt: sqliteCreated("created_at"),
237
+ });
238
+
239
+ export const libsqlOrchestraApprovals = sqliteTable("orchestra_approvals", {
240
+ approvalId: sqliteText("approval_id").primaryKey(),
241
+ runId: sqliteText("run_id").notNull(),
242
+ actionId: sqliteText("action_id").notNull(),
243
+ requestedBy: sqliteText("requested_by").notNull(),
244
+ decidedBy: sqliteText("decided_by"),
245
+ status: sqliteText("status").notNull(),
246
+ requiredScopes: sqliteJson("required_scopes"),
247
+ requestedAt: sqliteCreated("requested_at"),
248
+ decidedAt: sqliteOptionalTime("decided_at"),
249
+ expiresAt: sqliteOptionalTime("expires_at"),
250
+ });
251
+
252
+ export const libsqlOrchestraSecrets = sqliteTable("orchestra_secrets", {
253
+ secretId: sqliteText("secret_id").primaryKey(),
254
+ name: sqliteText("name").notNull(),
255
+ keyVersionId: sqliteText("key_version_id").notNull(),
256
+ sealedPayload: sqliteJson("sealed_payload"),
257
+ metadata: sqliteJson("metadata"),
258
+ createdAt: sqliteCreated("created_at"),
259
+ rotatedAt: sqliteOptionalTime("rotated_at"),
260
+ });
261
+
262
+ export const libsqlOrchestraSecretKeyVersions = sqliteTable("orchestra_secret_key_versions", {
263
+ keyVersionId: sqliteText("key_version_id").primaryKey(),
264
+ status: sqliteText("status").notNull(),
265
+ algorithm: sqliteText("algorithm").notNull(),
266
+ createdAt: sqliteCreated("created_at"),
267
+ retiredAt: sqliteOptionalTime("retired_at"),
268
+ rotationPolicy: sqliteJson("rotation_policy"),
269
+ });
270
+
271
+ export const libsqlOrchestraAuditLogs = sqliteTable("orchestra_audit_logs", {
272
+ auditId: sqliteText("audit_id").primaryKey(),
273
+ actorId: sqliteText("actor_id").notNull(),
274
+ eventType: sqliteText("event_type").notNull(),
275
+ resourceRef: sqliteText("resource_ref").notNull(),
276
+ outcome: sqliteText("outcome").notNull(),
277
+ summary: sqliteText("summary").notNull(),
278
+ recordedAt: sqliteCreated("recorded_at"),
279
+ metadata: sqliteJson("metadata"),
280
+ });
281
+
282
+ export const pgOrchestraSchema = {
283
+ orgDirectory: pgOrchestraOrgDirectory,
284
+ agents: pgOrchestraAgents,
285
+ dreams: pgOrchestraDreams,
286
+ tasks: pgOrchestraTasks,
287
+ runs: pgOrchestraRuns,
288
+ runEvents: pgOrchestraRunEvents,
289
+ toolCalls: pgOrchestraToolCalls,
290
+ artifacts: pgOrchestraArtifacts,
291
+ grants: pgOrchestraGrants,
292
+ approvals: pgOrchestraApprovals,
293
+ secrets: pgOrchestraSecrets,
294
+ secretKeyVersions: pgOrchestraSecretKeyVersions,
295
+ auditLogs: pgOrchestraAuditLogs,
296
+ };
297
+
298
+ export const libsqlOrchestraSchema = {
299
+ orgDirectory: libsqlOrchestraOrgDirectory,
300
+ agents: libsqlOrchestraAgents,
301
+ dreams: libsqlOrchestraDreams,
302
+ tasks: libsqlOrchestraTasks,
303
+ runs: libsqlOrchestraRuns,
304
+ runEvents: libsqlOrchestraRunEvents,
305
+ toolCalls: libsqlOrchestraToolCalls,
306
+ artifacts: libsqlOrchestraArtifacts,
307
+ grants: libsqlOrchestraGrants,
308
+ approvals: libsqlOrchestraApprovals,
309
+ secrets: libsqlOrchestraSecrets,
310
+ secretKeyVersions: libsqlOrchestraSecretKeyVersions,
311
+ auditLogs: libsqlOrchestraAuditLogs,
312
+ };
313
+
314
+ export const ORCHESTRA_DRIZZLE_SCHEMA = {
315
+ schemaVersion: ORCHESTRA_SCHEMA_VERSION,
316
+ tableCount: ORCHESTRA_TABLES.length,
317
+ dialects: {
318
+ postgres: pgOrchestraSchema,
319
+ libsql: libsqlOrchestraSchema,
320
+ },
321
+ };