@relayfx/sdk 0.0.23 → 0.0.25

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 (33) hide show
  1. package/dist/index.js +582 -542
  2. package/dist/migrations/mysql/0001_baseline.sql +429 -0
  3. package/dist/migrations/sqlite/0001_baseline.sql +429 -0
  4. package/dist/types/store-sql/database/database-service.d.ts +16 -2
  5. package/package.json +1 -1
  6. /package/dist/migrations/{20260701002839_sour_cerebro → pg/20260701002839_sour_cerebro}/migration.sql +0 -0
  7. /package/dist/migrations/{20260701002839_sour_cerebro → pg/20260701002839_sour_cerebro}/snapshot.json +0 -0
  8. /package/dist/migrations/{20260701041134_acoustic_hulk → pg/20260701041134_acoustic_hulk}/migration.sql +0 -0
  9. /package/dist/migrations/{20260701041134_acoustic_hulk → pg/20260701041134_acoustic_hulk}/snapshot.json +0 -0
  10. /package/dist/migrations/{20260701160543_condemned_stryfe → pg/20260701160543_condemned_stryfe}/migration.sql +0 -0
  11. /package/dist/migrations/{20260701160543_condemned_stryfe → pg/20260701160543_condemned_stryfe}/snapshot.json +0 -0
  12. /package/dist/migrations/{20260701220315_heavy_gorgon → pg/20260701220315_heavy_gorgon}/migration.sql +0 -0
  13. /package/dist/migrations/{20260701220315_heavy_gorgon → pg/20260701220315_heavy_gorgon}/snapshot.json +0 -0
  14. /package/dist/migrations/{20260701225444_polite_lord_hawal → pg/20260701225444_polite_lord_hawal}/migration.sql +0 -0
  15. /package/dist/migrations/{20260701225444_polite_lord_hawal → pg/20260701225444_polite_lord_hawal}/snapshot.json +0 -0
  16. /package/dist/migrations/{20260702030128_flaky_misty_knight → pg/20260702030128_flaky_misty_knight}/migration.sql +0 -0
  17. /package/dist/migrations/{20260702030128_flaky_misty_knight → pg/20260702030128_flaky_misty_knight}/snapshot.json +0 -0
  18. /package/dist/migrations/{20260705003847_nervous_banshee → pg/20260705003847_nervous_banshee}/migration.sql +0 -0
  19. /package/dist/migrations/{20260705003847_nervous_banshee → pg/20260705003847_nervous_banshee}/snapshot.json +0 -0
  20. /package/dist/migrations/{20260705012626_common_stryfe → pg/20260705012626_common_stryfe}/migration.sql +0 -0
  21. /package/dist/migrations/{20260705012626_common_stryfe → pg/20260705012626_common_stryfe}/snapshot.json +0 -0
  22. /package/dist/migrations/{20260705015420_sweet_captain_marvel → pg/20260705015420_sweet_captain_marvel}/migration.sql +0 -0
  23. /package/dist/migrations/{20260705015420_sweet_captain_marvel → pg/20260705015420_sweet_captain_marvel}/snapshot.json +0 -0
  24. /package/dist/migrations/{20260705023041_chunky_scalphunter → pg/20260705023041_chunky_scalphunter}/migration.sql +0 -0
  25. /package/dist/migrations/{20260705023041_chunky_scalphunter → pg/20260705023041_chunky_scalphunter}/snapshot.json +0 -0
  26. /package/dist/migrations/{20260705030344_short_patriot → pg/20260705030344_short_patriot}/migration.sql +0 -0
  27. /package/dist/migrations/{20260705030344_short_patriot → pg/20260705030344_short_patriot}/snapshot.json +0 -0
  28. /package/dist/migrations/{20260705045546_heavy_ben_grimm → pg/20260705045546_heavy_ben_grimm}/migration.sql +0 -0
  29. /package/dist/migrations/{20260705045546_heavy_ben_grimm → pg/20260705045546_heavy_ben_grimm}/snapshot.json +0 -0
  30. /package/dist/migrations/{20260706185931_regular_shadow_king → pg/20260706185931_regular_shadow_king}/migration.sql +0 -0
  31. /package/dist/migrations/{20260706185931_regular_shadow_king → pg/20260706185931_regular_shadow_king}/snapshot.json +0 -0
  32. /package/dist/migrations/{20260706233300_equal_cyclops → pg/20260706233300_equal_cyclops}/migration.sql +0 -0
  33. /package/dist/migrations/{20260706233300_equal_cyclops → pg/20260706233300_equal_cyclops}/snapshot.json +0 -0
@@ -0,0 +1,429 @@
1
+ CREATE TABLE "relay_address_book_entries" (
2
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
3
+ "id" TEXT NOT NULL,
4
+ "address_id" TEXT NOT NULL,
5
+ "route_kind" TEXT NOT NULL,
6
+ "route_key" TEXT NOT NULL,
7
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
8
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
9
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
10
+ CONSTRAINT "pk_relay_address_book_entries" PRIMARY KEY ("tenant_id", "id")
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE UNIQUE INDEX "uq_relay_address_book_address" ON "relay_address_book_entries" ("tenant_id", "address_id");
14
+ --> statement-breakpoint
15
+ CREATE TABLE "relay_agent_definitions" (
16
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
17
+ "id" TEXT NOT NULL,
18
+ "name" TEXT NOT NULL,
19
+ "current_revision" INTEGER NOT NULL,
20
+ "definition_json" TEXT NOT NULL,
21
+ "tool_input_schema_digests_json" TEXT NOT NULL DEFAULT '{}',
22
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
23
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
24
+ CONSTRAINT "pk_relay_agent_definitions" PRIMARY KEY ("tenant_id", "id")
25
+ );
26
+ --> statement-breakpoint
27
+ CREATE INDEX "idx_relay_agent_definitions_name" ON "relay_agent_definitions" ("tenant_id", "name");
28
+ --> statement-breakpoint
29
+ CREATE TABLE "relay_agent_definition_revisions" (
30
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
31
+ "agent_definition_id" TEXT NOT NULL,
32
+ "revision" INTEGER NOT NULL,
33
+ "name" TEXT NOT NULL,
34
+ "definition_json" TEXT NOT NULL,
35
+ "tool_input_schema_digests_json" TEXT NOT NULL DEFAULT '{}',
36
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
37
+ CONSTRAINT "pk_relay_agent_definition_revisions" PRIMARY KEY ("tenant_id", "agent_definition_id", "revision")
38
+ );
39
+ --> statement-breakpoint
40
+ CREATE INDEX "idx_relay_agent_definition_revisions_definition" ON "relay_agent_definition_revisions" ("tenant_id", "agent_definition_id", "revision");
41
+ --> statement-breakpoint
42
+ CREATE TABLE "relay_skill_definitions" (
43
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
44
+ "id" TEXT NOT NULL,
45
+ "name" TEXT NOT NULL,
46
+ "current_revision" INTEGER NOT NULL,
47
+ "definition_json" TEXT NOT NULL,
48
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
49
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
50
+ CONSTRAINT "pk_relay_skill_definitions" PRIMARY KEY ("tenant_id", "id")
51
+ );
52
+ --> statement-breakpoint
53
+ CREATE INDEX "idx_relay_skill_definitions_name" ON "relay_skill_definitions" ("tenant_id", "name");
54
+ --> statement-breakpoint
55
+ CREATE TABLE "relay_skill_definition_revisions" (
56
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
57
+ "skill_definition_id" TEXT NOT NULL,
58
+ "revision" INTEGER NOT NULL,
59
+ "name" TEXT NOT NULL,
60
+ "definition_json" TEXT NOT NULL,
61
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
62
+ CONSTRAINT "pk_relay_skill_definition_revisions" PRIMARY KEY ("tenant_id", "skill_definition_id", "revision")
63
+ );
64
+ --> statement-breakpoint
65
+ CREATE INDEX "idx_relay_skill_definition_revisions_definition" ON "relay_skill_definition_revisions" ("tenant_id", "skill_definition_id", "revision");
66
+ --> statement-breakpoint
67
+ CREATE TABLE "relay_execution_skill_pins" (
68
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
69
+ "execution_id" TEXT NOT NULL,
70
+ "skill_definition_id" TEXT NOT NULL,
71
+ "skill_definition_revision" INTEGER NOT NULL,
72
+ "skill_definition_snapshot_json" TEXT NOT NULL,
73
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
74
+ CONSTRAINT "pk_relay_execution_skill_pins" PRIMARY KEY ("tenant_id", "execution_id", "skill_definition_id")
75
+ );
76
+ --> statement-breakpoint
77
+ CREATE INDEX "idx_relay_execution_skill_pins_execution" ON "relay_execution_skill_pins" ("tenant_id", "execution_id");
78
+ --> statement-breakpoint
79
+ CREATE TABLE "relay_agent_chats" (
80
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
81
+ "execution_id" TEXT NOT NULL,
82
+ "export_json" TEXT NOT NULL,
83
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
84
+ CONSTRAINT "pk_relay_agent_chats" PRIMARY KEY ("tenant_id", "execution_id")
85
+ );
86
+ --> statement-breakpoint
87
+ CREATE TABLE "relay_agent_compactions" (
88
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
89
+ "execution_id" TEXT NOT NULL,
90
+ "checkpoint_id" TEXT NOT NULL,
91
+ "summary" TEXT NOT NULL,
92
+ "first_kept_entry_id" TEXT NOT NULL,
93
+ "turn" INTEGER NOT NULL,
94
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
95
+ CONSTRAINT "pk_relay_agent_compactions" PRIMARY KEY ("tenant_id", "execution_id", "checkpoint_id")
96
+ );
97
+ --> statement-breakpoint
98
+ CREATE INDEX "idx_relay_agent_compactions_execution_turn" ON "relay_agent_compactions" ("tenant_id", "execution_id", "turn");
99
+ --> statement-breakpoint
100
+ CREATE TABLE "relay_memory_records" (
101
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
102
+ "id" TEXT NOT NULL,
103
+ "agent" TEXT NOT NULL,
104
+ "subject" TEXT NOT NULL,
105
+ "embedding" TEXT NOT NULL,
106
+ "parts_json" TEXT NOT NULL,
107
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
108
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
109
+ CONSTRAINT "pk_relay_memory_records" PRIMARY KEY ("tenant_id", "id")
110
+ );
111
+ --> statement-breakpoint
112
+ CREATE INDEX "idx_relay_memory_records_agent_subject" ON "relay_memory_records" ("tenant_id", "agent", "subject");
113
+ --> statement-breakpoint
114
+ CREATE TABLE "relay_permission_rules" (
115
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
116
+ "agent" TEXT NOT NULL,
117
+ "scope" TEXT NOT NULL,
118
+ "pattern" TEXT NOT NULL,
119
+ "rule_json" TEXT NOT NULL,
120
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
121
+ CONSTRAINT "pk_relay_permission_rules" PRIMARY KEY ("tenant_id", "agent", "scope", "pattern")
122
+ );
123
+ --> statement-breakpoint
124
+ CREATE INDEX "idx_relay_permission_rules_agent_scope" ON "relay_permission_rules" ("tenant_id", "agent", "scope");
125
+ --> statement-breakpoint
126
+ CREATE TABLE "relay_steering_messages" (
127
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
128
+ "execution_id" TEXT NOT NULL,
129
+ "kind" TEXT NOT NULL,
130
+ "sequence" INTEGER NOT NULL,
131
+ "content_json" TEXT NOT NULL,
132
+ "drain_id" TEXT,
133
+ "consumed_at" INTEGER,
134
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
135
+ CONSTRAINT "pk_relay_steering_messages" PRIMARY KEY ("tenant_id", "execution_id", "kind", "sequence")
136
+ );
137
+ --> statement-breakpoint
138
+ CREATE INDEX "idx_relay_steering_messages_unconsumed" ON "relay_steering_messages" ("tenant_id", "execution_id", "kind", "consumed_at", "sequence");
139
+ --> statement-breakpoint
140
+ CREATE INDEX "idx_relay_steering_messages_drain" ON "relay_steering_messages" ("tenant_id", "execution_id", "kind", "drain_id", "sequence");
141
+ --> statement-breakpoint
142
+ CREATE TABLE "relay_steering_drains" (
143
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
144
+ "execution_id" TEXT NOT NULL,
145
+ "kind" TEXT NOT NULL,
146
+ "drain_id" TEXT NOT NULL,
147
+ "message_sequences_json" TEXT NOT NULL DEFAULT '[]',
148
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
149
+ CONSTRAINT "pk_relay_steering_drains" PRIMARY KEY ("tenant_id", "execution_id", "kind", "drain_id")
150
+ );
151
+ --> statement-breakpoint
152
+ CREATE TABLE "relay_sessions" (
153
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
154
+ "id" TEXT NOT NULL,
155
+ "root_address_id" TEXT NOT NULL,
156
+ "leaf_entry_id" TEXT,
157
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
158
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
159
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
160
+ CONSTRAINT "pk_relay_sessions" PRIMARY KEY ("tenant_id", "id")
161
+ );
162
+ --> statement-breakpoint
163
+ CREATE INDEX "idx_relay_sessions_updated_id" ON "relay_sessions" ("tenant_id", "updated_at", "id");
164
+ --> statement-breakpoint
165
+ CREATE INDEX "idx_relay_sessions_root_updated_id" ON "relay_sessions" ("tenant_id", "root_address_id", "updated_at", "id");
166
+ --> statement-breakpoint
167
+ CREATE TABLE "relay_session_entries" (
168
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
169
+ "id" TEXT NOT NULL,
170
+ "session_id" TEXT NOT NULL,
171
+ "parent_id" TEXT,
172
+ "tag" TEXT NOT NULL,
173
+ "payload_json" TEXT NOT NULL,
174
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
175
+ CONSTRAINT "pk_relay_session_entries" PRIMARY KEY ("tenant_id", "id")
176
+ );
177
+ --> statement-breakpoint
178
+ CREATE INDEX "idx_relay_session_entries_session_created" ON "relay_session_entries" ("tenant_id", "session_id", "created_at", "id");
179
+ --> statement-breakpoint
180
+ CREATE INDEX "idx_relay_session_entries_session_parent" ON "relay_session_entries" ("tenant_id", "session_id", "parent_id");
181
+ --> statement-breakpoint
182
+ CREATE TABLE "relay_execution_context_epochs" (
183
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
184
+ "execution_id" TEXT NOT NULL,
185
+ "baseline" TEXT NOT NULL,
186
+ "dynamic_source_ids_json" TEXT NOT NULL DEFAULT '[]',
187
+ "opened_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
188
+ CONSTRAINT "pk_relay_execution_context_epochs" PRIMARY KEY ("tenant_id", "execution_id")
189
+ );
190
+ --> statement-breakpoint
191
+ CREATE TABLE "relay_executions" (
192
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
193
+ "id" TEXT NOT NULL,
194
+ "root_address_id" TEXT NOT NULL,
195
+ "session_id" TEXT,
196
+ "status" TEXT NOT NULL,
197
+ "agent_definition_id" TEXT,
198
+ "agent_definition_revision" INTEGER,
199
+ "agent_definition_snapshot_json" TEXT,
200
+ "agent_definition_tool_input_schema_digests_json" TEXT NOT NULL DEFAULT '{}',
201
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
202
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
203
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
204
+ CONSTRAINT "pk_relay_executions" PRIMARY KEY ("tenant_id", "id")
205
+ );
206
+ --> statement-breakpoint
207
+ CREATE INDEX "idx_relay_executions_root_status" ON "relay_executions" ("tenant_id", "root_address_id", "status");
208
+ --> statement-breakpoint
209
+ CREATE INDEX "idx_relay_executions_session_updated_id" ON "relay_executions" ("tenant_id", "session_id", "updated_at", "id");
210
+ --> statement-breakpoint
211
+ CREATE INDEX "idx_relay_executions_updated_id" ON "relay_executions" ("tenant_id", "updated_at", "id");
212
+ --> statement-breakpoint
213
+ CREATE INDEX "idx_relay_executions_root_status_updated_id" ON "relay_executions" ("tenant_id", "root_address_id", "status", "updated_at", "id");
214
+ --> statement-breakpoint
215
+ CREATE TABLE "relay_child_executions" (
216
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
217
+ "id" TEXT NOT NULL,
218
+ "execution_id" TEXT NOT NULL,
219
+ "address_id" TEXT NOT NULL,
220
+ "status" TEXT NOT NULL,
221
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
222
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
223
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
224
+ CONSTRAINT "pk_relay_child_executions" PRIMARY KEY ("tenant_id", "id")
225
+ );
226
+ --> statement-breakpoint
227
+ CREATE INDEX "idx_relay_child_executions_parent" ON "relay_child_executions" ("tenant_id", "execution_id");
228
+ --> statement-breakpoint
229
+ CREATE TABLE "relay_envelopes" (
230
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
231
+ "id" TEXT NOT NULL,
232
+ "execution_id" TEXT NOT NULL,
233
+ "from_address_id" TEXT NOT NULL,
234
+ "to_address_id" TEXT NOT NULL,
235
+ "content_json" TEXT NOT NULL,
236
+ "wait_json" TEXT,
237
+ "correlation_key" TEXT,
238
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
239
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
240
+ CONSTRAINT "pk_relay_envelopes" PRIMARY KEY ("tenant_id", "id")
241
+ );
242
+ --> statement-breakpoint
243
+ CREATE INDEX "idx_relay_envelopes_execution" ON "relay_envelopes" ("tenant_id", "execution_id", "created_at");
244
+ --> statement-breakpoint
245
+ CREATE INDEX "idx_relay_envelopes_to_address" ON "relay_envelopes" ("tenant_id", "to_address_id", "created_at");
246
+ --> statement-breakpoint
247
+ CREATE TABLE "relay_waits" (
248
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
249
+ "id" TEXT NOT NULL,
250
+ "execution_id" TEXT NOT NULL,
251
+ "envelope_id" TEXT,
252
+ "mode" TEXT NOT NULL,
253
+ "correlation_key" TEXT,
254
+ "state" TEXT NOT NULL DEFAULT 'open',
255
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
256
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
257
+ "resolved_at" INTEGER,
258
+ CONSTRAINT "pk_relay_waits" PRIMARY KEY ("tenant_id", "id")
259
+ );
260
+ --> statement-breakpoint
261
+ CREATE INDEX "idx_relay_waits_execution_state" ON "relay_waits" ("tenant_id", "execution_id", "state");
262
+ --> statement-breakpoint
263
+ CREATE TABLE "relay_workspace_leases" (
264
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
265
+ "id" TEXT NOT NULL,
266
+ "execution_id" TEXT NOT NULL,
267
+ "provider_key" TEXT NOT NULL,
268
+ "sandbox_ref" TEXT,
269
+ "latest_snapshot_ref" TEXT,
270
+ "status" TEXT NOT NULL,
271
+ "resume_strategy" TEXT NOT NULL,
272
+ "region" TEXT,
273
+ "request_json" TEXT,
274
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
275
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
276
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
277
+ CONSTRAINT "pk_relay_workspace_leases" PRIMARY KEY ("tenant_id", "id")
278
+ );
279
+ --> statement-breakpoint
280
+ CREATE UNIQUE INDEX "uq_relay_workspace_leases_active_execution" ON "relay_workspace_leases" ("tenant_id", "execution_id") WHERE "status" NOT IN ('released', 'failed');
281
+ --> statement-breakpoint
282
+ CREATE INDEX "idx_relay_workspace_leases_execution" ON "relay_workspace_leases" ("tenant_id", "execution_id");
283
+ --> statement-breakpoint
284
+ CREATE INDEX "idx_relay_workspace_leases_status_updated" ON "relay_workspace_leases" ("tenant_id", "status", "updated_at");
285
+ --> statement-breakpoint
286
+ CREATE TABLE "relay_workspace_snapshots" (
287
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
288
+ "id" TEXT NOT NULL,
289
+ "lease_id" TEXT NOT NULL,
290
+ "execution_id" TEXT NOT NULL,
291
+ "reason" TEXT NOT NULL,
292
+ "snapshot_ref" TEXT NOT NULL,
293
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
294
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
295
+ CONSTRAINT "pk_relay_workspace_snapshots" PRIMARY KEY ("tenant_id", "id")
296
+ );
297
+ --> statement-breakpoint
298
+ CREATE INDEX "idx_relay_workspace_snapshots_lease" ON "relay_workspace_snapshots" ("tenant_id", "lease_id", "created_at");
299
+ --> statement-breakpoint
300
+ CREATE INDEX "idx_relay_workspace_snapshots_execution" ON "relay_workspace_snapshots" ("tenant_id", "execution_id", "created_at");
301
+ --> statement-breakpoint
302
+ CREATE TABLE "relay_envelope_ready" (
303
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
304
+ "id" TEXT NOT NULL,
305
+ "envelope_id" TEXT NOT NULL,
306
+ "route_type" TEXT NOT NULL,
307
+ "route_key" TEXT NOT NULL,
308
+ "state" TEXT NOT NULL DEFAULT 'ready',
309
+ "available_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
310
+ "attempt" INTEGER NOT NULL DEFAULT 0,
311
+ "claim_owner" TEXT,
312
+ "claim_expires_at" INTEGER,
313
+ "last_error" TEXT,
314
+ "idempotency_key" TEXT,
315
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
316
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
317
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
318
+ "claimed_at" INTEGER,
319
+ "acknowledged_at" INTEGER,
320
+ CONSTRAINT "pk_relay_envelope_ready" PRIMARY KEY ("tenant_id", "id")
321
+ );
322
+ --> statement-breakpoint
323
+ CREATE INDEX "idx_relay_envelope_ready_state_available" ON "relay_envelope_ready" ("tenant_id", "state", "available_at");
324
+ --> statement-breakpoint
325
+ CREATE INDEX "idx_relay_envelope_ready_claim_expires" ON "relay_envelope_ready" ("tenant_id", "claim_expires_at");
326
+ --> statement-breakpoint
327
+ CREATE UNIQUE INDEX "uq_relay_envelope_ready_idempotency" ON "relay_envelope_ready" ("tenant_id", "idempotency_key");
328
+ --> statement-breakpoint
329
+ CREATE TABLE "relay_schedules" (
330
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
331
+ "id" TEXT NOT NULL,
332
+ "kind" TEXT NOT NULL,
333
+ "target_kind" TEXT NOT NULL,
334
+ "address_id" TEXT,
335
+ "wait_id" TEXT,
336
+ "cron_expr" TEXT,
337
+ "input_json" TEXT,
338
+ "state" TEXT NOT NULL DEFAULT 'active',
339
+ "next_run_at" INTEGER NOT NULL,
340
+ "attempt" INTEGER NOT NULL DEFAULT 0,
341
+ "claim_owner" TEXT,
342
+ "claim_expires_at" INTEGER,
343
+ "last_error" TEXT,
344
+ "idempotency_key" TEXT,
345
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
346
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
347
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
348
+ CONSTRAINT "pk_relay_schedules" PRIMARY KEY ("tenant_id", "id")
349
+ );
350
+ --> statement-breakpoint
351
+ CREATE INDEX "idx_relay_schedules_state_next_run" ON "relay_schedules" ("tenant_id", "state", "next_run_at");
352
+ --> statement-breakpoint
353
+ CREATE INDEX "idx_relay_schedules_claim_expires" ON "relay_schedules" ("tenant_id", "claim_expires_at");
354
+ --> statement-breakpoint
355
+ CREATE INDEX "idx_relay_schedules_wait" ON "relay_schedules" ("tenant_id", "wait_id");
356
+ --> statement-breakpoint
357
+ CREATE UNIQUE INDEX "uq_relay_schedules_idempotency" ON "relay_schedules" ("tenant_id", "idempotency_key");
358
+ --> statement-breakpoint
359
+ CREATE TABLE "relay_execution_events" (
360
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
361
+ "id" TEXT NOT NULL,
362
+ "execution_id" TEXT NOT NULL,
363
+ "child_execution_id" TEXT,
364
+ "type" TEXT NOT NULL,
365
+ "sequence" INTEGER NOT NULL,
366
+ "cursor" TEXT NOT NULL,
367
+ "content_json" TEXT,
368
+ "data_json" TEXT NOT NULL DEFAULT '{}',
369
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
370
+ CONSTRAINT "pk_relay_execution_events" PRIMARY KEY ("tenant_id", "id")
371
+ );
372
+ --> statement-breakpoint
373
+ CREATE INDEX "idx_relay_execution_events_execution" ON "relay_execution_events" ("tenant_id", "execution_id", "created_at");
374
+ --> statement-breakpoint
375
+ CREATE UNIQUE INDEX "uq_relay_execution_events_sequence" ON "relay_execution_events" ("tenant_id", "execution_id", "sequence");
376
+ --> statement-breakpoint
377
+ CREATE UNIQUE INDEX "uq_relay_execution_events_cursor" ON "relay_execution_events" ("tenant_id", "cursor");
378
+ --> statement-breakpoint
379
+ CREATE TABLE "relay_tool_calls" (
380
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
381
+ "id" TEXT NOT NULL,
382
+ "execution_id" TEXT NOT NULL,
383
+ "name" TEXT NOT NULL,
384
+ "input_json" TEXT NOT NULL,
385
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
386
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
387
+ CONSTRAINT "pk_relay_tool_calls" PRIMARY KEY ("tenant_id", "id")
388
+ );
389
+ --> statement-breakpoint
390
+ CREATE INDEX "idx_relay_tool_calls_execution" ON "relay_tool_calls" ("tenant_id", "execution_id", "created_at");
391
+ --> statement-breakpoint
392
+ CREATE TABLE "relay_tool_results" (
393
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
394
+ "tool_call_id" TEXT NOT NULL,
395
+ "output_json" TEXT NOT NULL,
396
+ "error" TEXT,
397
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
398
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
399
+ CONSTRAINT "pk_relay_tool_results" PRIMARY KEY ("tenant_id", "tool_call_id")
400
+ );
401
+ --> statement-breakpoint
402
+ CREATE TABLE "relay_route_attempts" (
403
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
404
+ "id" TEXT NOT NULL,
405
+ "envelope_ready_id" TEXT NOT NULL,
406
+ "route_key" TEXT NOT NULL,
407
+ "state" TEXT NOT NULL,
408
+ "detail" TEXT,
409
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
410
+ CONSTRAINT "pk_relay_route_attempts" PRIMARY KEY ("tenant_id", "id")
411
+ );
412
+ --> statement-breakpoint
413
+ CREATE INDEX "idx_relay_route_attempts_ready" ON "relay_route_attempts" ("tenant_id", "envelope_ready_id", "created_at");
414
+ --> statement-breakpoint
415
+ CREATE TABLE "relay_idempotency_keys" (
416
+ "tenant_id" TEXT NOT NULL DEFAULT 'system',
417
+ "id" TEXT NOT NULL,
418
+ "scope" TEXT NOT NULL,
419
+ "operation" TEXT NOT NULL,
420
+ "key" TEXT NOT NULL,
421
+ "result_json" TEXT,
422
+ "metadata_json" TEXT NOT NULL DEFAULT '{}',
423
+ "created_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
424
+ "updated_at" INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)),
425
+ "expires_at" INTEGER,
426
+ CONSTRAINT "pk_relay_idempotency_keys" PRIMARY KEY ("tenant_id", "id")
427
+ );
428
+ --> statement-breakpoint
429
+ CREATE UNIQUE INDEX "uq_relay_idempotency_scope_operation_key" ON "relay_idempotency_keys" ("tenant_id", "scope", "operation", "key");
@@ -1,7 +1,10 @@
1
+ import * as MysqlClient from "@effect/sql-mysql2/MysqlClient";
1
2
  import * as PgClient from "@effect/sql-pg/PgClient";
3
+ import * as SqliteClient from "@effect/sql-sqlite-bun/SqliteClient";
2
4
  import * as PgDrizzle from "drizzle-orm/effect-postgres";
3
5
  import type { EffectDrizzleQueryError } from "drizzle-orm/effect-core/errors";
4
- import { Config, Context, Effect, Layer } from "effect";
6
+ import { Config, Context, Effect, Layer, Schema } from "effect";
7
+ import * as SqlClient from "effect/unstable/sql/SqlClient";
5
8
  import type { SqlError } from "effect/unstable/sql/SqlError";
6
9
  export type Drizzle = PgDrizzle.EffectPgDatabase & {
7
10
  readonly $client: PgClient.PgClient;
@@ -17,9 +20,20 @@ export declare const fromNullablePgDate: (timestamp: PgTimestamp | null | undefi
17
20
  export declare const pgTypeParsers: {
18
21
  getTypeParser: (typeId: number, format?: "text" | "binary") => any;
19
22
  };
20
- export declare const PgClientLive: Layer.Layer<PgClient.PgClient | import("effect/unstable/sql/SqlClient").SqlClient, SqlError | Config.ConfigError, never>;
23
+ export declare const PgClientLive: Layer.Layer<PgClient.PgClient | SqlClient.SqlClient, SqlError | Config.ConfigError, never>;
21
24
  export declare const layerFromPgClient: Layer.Layer<Service, never, PgClient.PgClient>;
22
25
  export declare const layer: Layer.Layer<Service, SqlError | Config.ConfigError, never>;
23
26
  export declare const testLayer: (db: Drizzle) => Layer.Layer<Service, never, never>;
24
27
  export declare const check: () => Effect.Effect<void, EffectDrizzleQueryError, Service>;
28
+ export declare const Dialect: Schema.Literals<readonly ["pg", "mysql", "sqlite"]>;
29
+ export type Dialect = typeof Dialect.Type;
30
+ export declare const dialect: Effect.Effect<Dialect, never, SqlClient.SqlClient>;
31
+ export declare const MysqlClientLive: Layer.Layer<SqlClient.SqlClient | MysqlClient.MysqlClient, SqlError | Config.ConfigError, never>;
32
+ export declare const SqliteClientLive: Layer.Layer<SqlClient.SqlClient | SqliteClient.SqliteClient, Config.ConfigError, never>;
33
+ export declare const timestampParam: (client: SqlClient.SqlClient, millis: number) => Date | number;
34
+ export declare const fromDbTimestamp: (timestamp: PgTimestamp) => number;
35
+ export declare const fromNullableDbTimestamp: (timestamp: PgTimestamp | null | undefined) => number | undefined;
36
+ export declare const encodeJson: (value: unknown) => string;
37
+ export declare const decodeJson: (value: unknown) => unknown;
38
+ export declare const decodeBool: (value: unknown) => boolean;
25
39
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@relayfx/sdk",
4
- "version": "0.0.23",
4
+ "version": "0.0.25",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {