@relayfx/sdk 0.3.7 → 0.4.1

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 (89) hide show
  1. package/dist/ai.js +1 -1
  2. package/dist/http-server.js +1 -1
  3. package/dist/{index-pw46cfne.js → index-3w6txjtg.js} +59 -426
  4. package/dist/{index-8awt651b.js → index-p2d0xyat.js} +5803 -5288
  5. package/dist/{index-h8rx4xya.js → index-vthtj624.js} +1 -1
  6. package/dist/{index-t5bbk8cp.js → index-x32kbvxv.js} +935 -954
  7. package/dist/index.js +487 -22
  8. package/dist/migrations/20260719120000_rename_entity_to_resident/migration.sql +9 -0
  9. package/dist/migrations/mysql/0012_rename_entity_to_resident.sql +5 -0
  10. package/dist/migrations/pg/20260719120000_rename_entity_to_resident/migration.sql +9 -0
  11. package/dist/migrations/sqlite/0012_rename_entity_to_resident.sql +7 -0
  12. package/dist/mysql.js +18 -5
  13. package/dist/postgres.js +569 -550
  14. package/dist/sqlite.js +16 -5
  15. package/dist/types/relay/client-baton-agent.d.ts +30 -0
  16. package/dist/types/relay/client-child-runs.d.ts +35 -0
  17. package/dist/types/relay/client-error-mapping.d.ts +5 -0
  18. package/dist/types/relay/client-event-sequence.d.ts +3 -0
  19. package/dist/types/relay/client-execution-payloads.d.ts +12 -0
  20. package/dist/types/relay/client-public-agents.d.ts +15 -0
  21. package/dist/types/relay/client-public-child-runs.d.ts +9 -0
  22. package/dist/types/relay/client-public-envelope-ready.d.ts +6 -0
  23. package/dist/types/relay/client-public-executions.d.ts +247 -0
  24. package/dist/types/relay/client-public-messaging.d.ts +18 -0
  25. package/dist/types/relay/client-public-residents.d.ts +14 -0
  26. package/dist/types/relay/client-public-schedules.d.ts +6 -0
  27. package/dist/types/relay/client-public-tools.d.ts +12 -0
  28. package/dist/types/relay/client-public-workflows.d.ts +10 -0
  29. package/dist/types/relay/client-public.d.ts +133 -313
  30. package/dist/types/relay/client-runtime-wake.d.ts +10 -0
  31. package/dist/types/relay/client-tool-outcome.d.ts +16 -0
  32. package/dist/types/relay/client-view-mappers.d.ts +16 -0
  33. package/dist/types/relay/client-wait-signal.d.ts +5 -0
  34. package/dist/types/relay/client.d.ts +118 -1
  35. package/dist/types/relay/command.d.ts +6 -6
  36. package/dist/types/relay/http-server.d.ts +55 -37
  37. package/dist/types/relay/index.d.ts +3 -4
  38. package/dist/types/relay/internal-client.d.ts +5 -5
  39. package/dist/types/relay/mysql-migrations.d.ts +1 -1
  40. package/dist/types/relay/operation.d.ts +41 -41
  41. package/dist/types/relay/sqlite-migrations.d.ts +6 -1
  42. package/dist/types/runtime/agent/agent-loop-events.d.ts +24 -0
  43. package/dist/types/runtime/execution/event-log-memory.d.ts +7 -0
  44. package/dist/types/runtime/execution/event-log-repository.d.ts +8 -0
  45. package/dist/types/runtime/index.d.ts +2 -2
  46. package/dist/types/runtime/resident/resident-instance-service.d.ts +76 -0
  47. package/dist/types/runtime/resident/resident-registry-service.d.ts +35 -0
  48. package/dist/types/runtime/runner/runner-runtime-service.d.ts +14 -14
  49. package/dist/types/runtime/workflow/execution-workflow-state.d.ts +43 -0
  50. package/dist/types/schema/execution-schema.d.ts +2 -2
  51. package/dist/types/schema/ids-schema.d.ts +6 -6
  52. package/dist/types/schema/index.d.ts +1 -1
  53. package/dist/types/schema/{entity-schema.d.ts → resident-schema.d.ts} +6 -6
  54. package/dist/types/store-sql/envelope/envelope-ready-records.d.ts +51 -0
  55. package/dist/types/store-sql/envelope/envelope-records.d.ts +43 -0
  56. package/dist/types/store-sql/envelope/envelope-repository.d.ts +1 -2
  57. package/dist/types/store-sql/envelope/wait-records.d.ts +64 -0
  58. package/dist/types/store-sql/execution/execution-event-repository-memory.d.ts +8 -0
  59. package/dist/types/store-sql/execution/execution-event-repository-sql.d.ts +13 -0
  60. package/dist/types/store-sql/execution/execution-event-repository.d.ts +3 -4
  61. package/dist/types/store-sql/index.d.ts +1 -1
  62. package/dist/types/store-sql/portable.d.ts +1 -1
  63. package/dist/types/store-sql/resident/resident-repository.d.ts +36 -0
  64. package/dist/types/store-sql/schema/address-book-schema.d.ts +131 -0
  65. package/dist/types/store-sql/schema/agent-schema.d.ts +954 -0
  66. package/dist/types/store-sql/schema/communication-schema.d.ts +743 -0
  67. package/dist/types/store-sql/schema/envelope-schema.d.ts +701 -0
  68. package/dist/types/store-sql/schema/execution-schema.d.ts +1119 -0
  69. package/dist/types/store-sql/schema/idempotency-schema.d.ts +161 -0
  70. package/dist/types/store-sql/schema/presence-schema.d.ts +116 -0
  71. package/dist/types/store-sql/schema/relay-schema.d.ts +13 -6684
  72. package/dist/types/store-sql/schema/resident-schema.d.ts +294 -0
  73. package/dist/types/store-sql/schema/schedule-schema.d.ts +282 -0
  74. package/dist/types/store-sql/schema/schema-columns.d.ts +1 -0
  75. package/dist/types/store-sql/schema/session-schema.d.ts +228 -0
  76. package/dist/types/store-sql/schema/tool-schema.d.ts +627 -0
  77. package/dist/types/store-sql/schema/workflow-schema.d.ts +996 -0
  78. package/dist/types/store-sql/schema/workspace-schema.d.ts +338 -0
  79. package/dist/types/store-sql/session/session-entry-records.d.ts +52 -0
  80. package/dist/types/store-sql/session/session-records.d.ts +51 -0
  81. package/dist/types/store-sql/session/session-repository.d.ts +2 -3
  82. package/dist/types/store-sql/tool/tool-attempt-records.d.ts +52 -0
  83. package/dist/types/store-sql/tool/tool-call-records.d.ts +121 -0
  84. package/dist/types/store-sql/tool/tool-call-repository.d.ts +1 -2
  85. package/dist/types/store-sql/tool/tool-work-operations.d.ts +11 -0
  86. package/package.json +3 -3
  87. package/dist/types/runtime/entity/entity-instance-service.d.ts +0 -76
  88. package/dist/types/runtime/entity/entity-registry-service.d.ts +0 -35
  89. package/dist/types/store-sql/entity/entity-repository.d.ts +0 -36
package/dist/postgres.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  database,
4
4
  normalizeMigrationCause
5
- } from "./index-h8rx4xya.js";
5
+ } from "./index-vthtj624.js";
6
6
  import {
7
7
  Dialect,
8
8
  RuntimeMigrationError,
@@ -14,11 +14,11 @@ import {
14
14
  fromDbTimestamp,
15
15
  fromNullableDbTimestamp,
16
16
  timestampParam
17
- } from "./index-8awt651b.js";
18
- import"./index-t5bbk8cp.js";
17
+ } from "./index-p2d0xyat.js";
18
+ import"./index-x32kbvxv.js";
19
19
  import {
20
20
  exports_ids_schema
21
- } from "./index-pw46cfne.js";
21
+ } from "./index-3w6txjtg.js";
22
22
  import {
23
23
  __export
24
24
  } from "./index-nb39b5ae.js";
@@ -80,26 +80,19 @@ var check = Effect.fn("Database.check")(function* () {
80
80
  const db = yield* Service;
81
81
  yield* db.execute(sql`select 1 as ok`).pipe(Effect.asVoid);
82
82
  });
83
- // ../store-sql/src/schema/relay-schema.ts
84
- import {
85
- boolean,
86
- doublePrecision,
87
- index,
88
- integer,
89
- jsonb,
90
- pgTable,
91
- primaryKey,
92
- text,
93
- timestamp,
94
- uniqueIndex
95
- } from "drizzle-orm/pg-core";
96
- import { sql as sql2 } from "drizzle-orm";
83
+ // ../store-sql/src/schema/workflow-schema.ts
84
+ import { boolean, integer, jsonb, pgTable, primaryKey, text as text2, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
85
+
86
+ // ../store-sql/src/schema/schema-columns.ts
87
+ import { text } from "drizzle-orm/pg-core";
97
88
  var tenantId = () => text("tenant_id").$type().notNull().default(exports_ids_schema.SystemTenantId);
89
+
90
+ // ../store-sql/src/schema/workflow-schema.ts
98
91
  var relayWorkflowDefinitionRevisions = pgTable("relay_workflow_definition_revisions", {
99
92
  tenantId: tenantId(),
100
- workflowDefinitionId: text("workflow_definition_id").$type().notNull(),
93
+ workflowDefinitionId: text2("workflow_definition_id").$type().notNull(),
101
94
  revision: integer("revision").$type().notNull(),
102
- digest: text("digest").$type().notNull(),
95
+ digest: text2("digest").$type().notNull(),
103
96
  definitionJson: jsonb("definition_json").$type().notNull(),
104
97
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
105
98
  }, (table) => [
@@ -108,626 +101,651 @@ var relayWorkflowDefinitionRevisions = pgTable("relay_workflow_definition_revisi
108
101
  ]);
109
102
  var relayWorkflowRuns = pgTable("relay_workflow_runs", {
110
103
  tenantId: tenantId(),
111
- executionId: text("execution_id").$type().notNull(),
112
- workflowDefinitionId: text("workflow_definition_id").$type().notNull(),
104
+ executionId: text2("execution_id").$type().notNull(),
105
+ workflowDefinitionId: text2("workflow_definition_id").$type().notNull(),
113
106
  workflowDefinitionRevision: integer("workflow_definition_revision").$type().notNull(),
114
- workflowDefinitionDigest: text("workflow_definition_digest").$type().notNull(),
115
- status: text("status").$type().notNull(),
107
+ workflowDefinitionDigest: text2("workflow_definition_digest").$type().notNull(),
108
+ status: text2("status").$type().notNull(),
116
109
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
117
110
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
118
111
  }, (table) => [primaryKey({ columns: [table.tenantId, table.executionId] })]);
119
112
  var relayWorkflowOperationStates = pgTable("relay_workflow_operation_states", {
120
113
  tenantId: tenantId(),
121
- executionId: text("execution_id").$type().notNull(),
122
- operationId: text("operation_id").$type().notNull(),
123
- status: text("status").notNull(),
124
- fanOutId: text("fan_out_id"),
114
+ executionId: text2("execution_id").$type().notNull(),
115
+ operationId: text2("operation_id").$type().notNull(),
116
+ status: text2("status").notNull(),
117
+ fanOutId: text2("fan_out_id"),
125
118
  decision: boolean("decision"),
126
119
  outputJson: jsonb("output_json"),
127
120
  attempt: integer("attempt"),
128
121
  backoffUntil: timestamp("backoff_until", { withTimezone: true }),
129
- compensationOperationId: text("compensation_operation_id"),
122
+ compensationOperationId: text2("compensation_operation_id"),
130
123
  startedAt: timestamp("started_at", { withTimezone: true }),
131
124
  completedAt: timestamp("completed_at", { withTimezone: true }),
132
125
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
133
126
  }, (table) => [primaryKey({ columns: [table.tenantId, table.executionId, table.operationId] })]);
134
127
  var relayWorkflowLifecycleEvents = pgTable("relay_workflow_lifecycle_events", {
135
128
  tenantId: tenantId(),
136
- executionId: text("execution_id").$type().notNull(),
129
+ executionId: text2("execution_id").$type().notNull(),
137
130
  sequence: integer("sequence").notNull(),
138
- eventType: text("event_type").notNull(),
139
- operationId: text("operation_id"),
131
+ eventType: text2("event_type").notNull(),
132
+ operationId: text2("operation_id"),
140
133
  dataJson: jsonb("data_json"),
141
134
  createdAt: timestamp("created_at", { withTimezone: true }).notNull()
142
135
  }, (table) => [primaryKey({ columns: [table.tenantId, table.executionId, table.sequence] })]);
143
- var relayEntityKinds = pgTable("relay_entity_kinds", {
144
- tenantId: tenantId(),
145
- kind: text("kind").$type().notNull(),
146
- agentId: text("agent_id").$type().notNull(),
147
- inboxPolicyJson: jsonb("inbox_policy_json").$type(),
148
- stateEnabled: integer("state_enabled").$type(),
149
- continueAsNewAfterTurns: integer("continue_as_new_after_turns"),
150
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
151
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
152
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
153
- }, (table) => [primaryKey({ columns: [table.tenantId, table.kind], name: "pk_relay_entity_kinds" })]);
154
- var relayEntityInstances = pgTable("relay_entity_instances", {
155
- tenantId: tenantId(),
156
- kind: text("kind").$type().notNull(),
157
- key: text("key").$type().notNull(),
158
- addressId: text("address_id").$type().notNull(),
159
- executionId: text("execution_id").$type().notNull(),
160
- generation: integer("generation").notNull(),
161
- status: text("status").$type().notNull(),
162
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
163
- destroyedAt: timestamp("destroyed_at", { withTimezone: true })
164
- }, (table) => [
165
- primaryKey({ columns: [table.tenantId, table.kind, table.key], name: "pk_relay_entity_instances" }),
166
- index("idx_relay_entity_instances_kind_status").on(table.tenantId, table.kind, table.status)
167
- ]);
168
- var relayAddressBookEntries = pgTable("relay_address_book_entries", {
169
- tenantId: tenantId(),
170
- id: text("id").$type().notNull(),
171
- addressId: text("address_id").$type().notNull(),
172
- routeKind: text("route_kind").notNull(),
173
- routeKey: text("route_key").notNull(),
174
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
175
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
176
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
177
- }, (table) => [
178
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_address_book_entries" }),
179
- uniqueIndex("uq_relay_address_book_address").on(table.tenantId, table.addressId)
180
- ]);
181
- var relayAgentDefinitions = pgTable("relay_agent_definitions", {
182
- tenantId: tenantId(),
183
- id: text("id").$type().notNull(),
184
- name: text("name").notNull(),
185
- currentRevision: integer("current_revision").$type().notNull(),
186
- definitionJson: jsonb("definition_json").$type().notNull(),
187
- toolInputSchemaDigestsJson: jsonb("tool_input_schema_digests_json").$type().notNull().default({}),
188
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
189
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
190
- }, (table) => [
191
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_agent_definitions" }),
192
- index("idx_relay_agent_definitions_name").on(table.tenantId, table.name)
193
- ]);
194
- var relayAgentDefinitionRevisions = pgTable("relay_agent_revisions", {
195
- tenantId: tenantId(),
196
- agentId: text("agent_id").$type().notNull(),
197
- revision: integer("revision").$type().notNull(),
198
- name: text("name").notNull(),
199
- definitionJson: jsonb("definition_json").$type().notNull(),
200
- toolInputSchemaDigestsJson: jsonb("tool_input_schema_digests_json").$type().notNull().default({}),
201
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
202
- }, (table) => [
203
- primaryKey({
136
+ // ../store-sql/src/schema/resident-schema.ts
137
+ import { index, integer as integer2, jsonb as jsonb2, pgTable as pgTable2, primaryKey as primaryKey2, text as text3, timestamp as timestamp2 } from "drizzle-orm/pg-core";
138
+ var relayResidentKinds = pgTable2("relay_resident_kinds", {
139
+ tenantId: tenantId(),
140
+ kind: text3("kind").$type().notNull(),
141
+ agentId: text3("agent_id").$type().notNull(),
142
+ inboxPolicyJson: jsonb2("inbox_policy_json").$type(),
143
+ stateEnabled: integer2("state_enabled").$type(),
144
+ continueAsNewAfterTurns: integer2("continue_as_new_after_turns"),
145
+ metadataJson: jsonb2("metadata_json").$type().notNull().default({}),
146
+ createdAt: timestamp2("created_at", { withTimezone: true }).notNull().defaultNow(),
147
+ updatedAt: timestamp2("updated_at", { withTimezone: true }).notNull().defaultNow()
148
+ }, (table) => [primaryKey2({ columns: [table.tenantId, table.kind], name: "pk_relay_resident_kinds" })]);
149
+ var relayResidentInstances = pgTable2("relay_resident_instances", {
150
+ tenantId: tenantId(),
151
+ kind: text3("kind").$type().notNull(),
152
+ key: text3("key").$type().notNull(),
153
+ addressId: text3("address_id").$type().notNull(),
154
+ executionId: text3("execution_id").$type().notNull(),
155
+ generation: integer2("generation").notNull(),
156
+ status: text3("status").$type().notNull(),
157
+ createdAt: timestamp2("created_at", { withTimezone: true }).notNull().defaultNow(),
158
+ destroyedAt: timestamp2("destroyed_at", { withTimezone: true })
159
+ }, (table) => [
160
+ primaryKey2({ columns: [table.tenantId, table.kind, table.key], name: "pk_relay_resident_instances" }),
161
+ index("idx_relay_resident_instances_kind_status").on(table.tenantId, table.kind, table.status)
162
+ ]);
163
+ // ../store-sql/src/schema/address-book-schema.ts
164
+ import { jsonb as jsonb3, pgTable as pgTable3, primaryKey as primaryKey3, text as text4, timestamp as timestamp3, uniqueIndex as uniqueIndex2 } from "drizzle-orm/pg-core";
165
+ var relayAddressBookEntries = pgTable3("relay_address_book_entries", {
166
+ tenantId: tenantId(),
167
+ id: text4("id").$type().notNull(),
168
+ addressId: text4("address_id").$type().notNull(),
169
+ routeKind: text4("route_kind").notNull(),
170
+ routeKey: text4("route_key").notNull(),
171
+ metadataJson: jsonb3("metadata_json").$type().notNull().default({}),
172
+ createdAt: timestamp3("created_at", { withTimezone: true }).notNull().defaultNow(),
173
+ updatedAt: timestamp3("updated_at", { withTimezone: true }).notNull().defaultNow()
174
+ }, (table) => [
175
+ primaryKey3({ columns: [table.tenantId, table.id], name: "pk_relay_address_book_entries" }),
176
+ uniqueIndex2("uq_relay_address_book_address").on(table.tenantId, table.addressId)
177
+ ]);
178
+ // ../store-sql/src/schema/agent-schema.ts
179
+ import { doublePrecision, index as index2, integer as integer3, jsonb as jsonb4, pgTable as pgTable4, primaryKey as primaryKey4, text as text5, timestamp as timestamp4 } from "drizzle-orm/pg-core";
180
+ var relayAgentDefinitions = pgTable4("relay_agent_definitions", {
181
+ tenantId: tenantId(),
182
+ id: text5("id").$type().notNull(),
183
+ name: text5("name").notNull(),
184
+ currentRevision: integer3("current_revision").$type().notNull(),
185
+ definitionJson: jsonb4("definition_json").$type().notNull(),
186
+ toolInputSchemaDigestsJson: jsonb4("tool_input_schema_digests_json").$type().notNull().default({}),
187
+ createdAt: timestamp4("created_at", { withTimezone: true }).notNull().defaultNow(),
188
+ updatedAt: timestamp4("updated_at", { withTimezone: true }).notNull().defaultNow()
189
+ }, (table) => [
190
+ primaryKey4({ columns: [table.tenantId, table.id], name: "pk_relay_agent_definitions" }),
191
+ index2("idx_relay_agent_definitions_name").on(table.tenantId, table.name)
192
+ ]);
193
+ var relayAgentDefinitionRevisions = pgTable4("relay_agent_revisions", {
194
+ tenantId: tenantId(),
195
+ agentId: text5("agent_id").$type().notNull(),
196
+ revision: integer3("revision").$type().notNull(),
197
+ name: text5("name").notNull(),
198
+ definitionJson: jsonb4("definition_json").$type().notNull(),
199
+ toolInputSchemaDigestsJson: jsonb4("tool_input_schema_digests_json").$type().notNull().default({}),
200
+ createdAt: timestamp4("created_at", { withTimezone: true }).notNull().defaultNow()
201
+ }, (table) => [
202
+ primaryKey4({
204
203
  columns: [table.tenantId, table.agentId, table.revision],
205
204
  name: "pk_relay_agent_revisions"
206
205
  }),
207
- index("idx_relay_agent_revisions_definition").on(table.tenantId, table.agentId, table.revision)
206
+ index2("idx_relay_agent_revisions_definition").on(table.tenantId, table.agentId, table.revision)
208
207
  ]);
209
- var relaySkillDefinitions = pgTable("relay_skill_definitions", {
208
+ var relaySkillDefinitions = pgTable4("relay_skill_definitions", {
210
209
  tenantId: tenantId(),
211
- id: text("id").$type().notNull(),
212
- name: text("name").notNull(),
213
- currentRevision: integer("current_revision").$type().notNull(),
214
- definitionJson: jsonb("definition_json").$type().notNull(),
215
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
216
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
210
+ id: text5("id").$type().notNull(),
211
+ name: text5("name").notNull(),
212
+ currentRevision: integer3("current_revision").$type().notNull(),
213
+ definitionJson: jsonb4("definition_json").$type().notNull(),
214
+ createdAt: timestamp4("created_at", { withTimezone: true }).notNull().defaultNow(),
215
+ updatedAt: timestamp4("updated_at", { withTimezone: true }).notNull().defaultNow()
217
216
  }, (table) => [
218
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_skill_definitions" }),
219
- index("idx_relay_skill_definitions_name").on(table.tenantId, table.name)
217
+ primaryKey4({ columns: [table.tenantId, table.id], name: "pk_relay_skill_definitions" }),
218
+ index2("idx_relay_skill_definitions_name").on(table.tenantId, table.name)
220
219
  ]);
221
- var relaySkillDefinitionRevisions = pgTable("relay_skill_definition_revisions", {
220
+ var relaySkillDefinitionRevisions = pgTable4("relay_skill_definition_revisions", {
222
221
  tenantId: tenantId(),
223
- skillDefinitionId: text("skill_definition_id").notNull().$type(),
224
- revision: integer("revision").notNull().$type(),
225
- name: text("name").notNull(),
226
- definitionJson: jsonb("definition_json").$type().notNull(),
227
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
222
+ skillDefinitionId: text5("skill_definition_id").notNull().$type(),
223
+ revision: integer3("revision").notNull().$type(),
224
+ name: text5("name").notNull(),
225
+ definitionJson: jsonb4("definition_json").$type().notNull(),
226
+ createdAt: timestamp4("created_at", { withTimezone: true }).notNull().defaultNow()
228
227
  }, (table) => [
229
- primaryKey({
228
+ primaryKey4({
230
229
  columns: [table.tenantId, table.skillDefinitionId, table.revision],
231
230
  name: "pk_relay_skill_definition_revisions"
232
231
  }),
233
- index("idx_relay_skill_definition_revisions_definition").on(table.tenantId, table.skillDefinitionId, table.revision)
232
+ index2("idx_relay_skill_definition_revisions_definition").on(table.tenantId, table.skillDefinitionId, table.revision)
234
233
  ]);
235
- var relayExecutionSkillPins = pgTable("relay_execution_skill_pins", {
234
+ var relayExecutionSkillPins = pgTable4("relay_execution_skill_pins", {
236
235
  tenantId: tenantId(),
237
- executionId: text("execution_id").notNull().$type(),
238
- skillDefinitionId: text("skill_definition_id").notNull().$type(),
239
- skillDefinitionRevision: integer("skill_definition_revision").notNull().$type(),
240
- skillDefinitionSnapshotJson: jsonb("skill_definition_snapshot_json").$type().notNull(),
241
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
236
+ executionId: text5("execution_id").notNull().$type(),
237
+ skillDefinitionId: text5("skill_definition_id").notNull().$type(),
238
+ skillDefinitionRevision: integer3("skill_definition_revision").notNull().$type(),
239
+ skillDefinitionSnapshotJson: jsonb4("skill_definition_snapshot_json").$type().notNull(),
240
+ createdAt: timestamp4("created_at", { withTimezone: true }).notNull().defaultNow()
242
241
  }, (table) => [
243
- primaryKey({
242
+ primaryKey4({
244
243
  columns: [table.tenantId, table.executionId, table.skillDefinitionId],
245
244
  name: "pk_relay_execution_skill_pins"
246
245
  }),
247
- index("idx_relay_execution_skill_pins_execution").on(table.tenantId, table.executionId)
246
+ index2("idx_relay_execution_skill_pins_execution").on(table.tenantId, table.executionId)
248
247
  ]);
249
- var relayAgentChats = pgTable("relay_agent_chats", {
248
+ var relayAgentChats = pgTable4("relay_agent_chats", {
250
249
  tenantId: tenantId(),
251
- executionId: text("execution_id").$type().notNull(),
252
- exportJson: jsonb("export_json").notNull(),
253
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
254
- }, (table) => [primaryKey({ columns: [table.tenantId, table.executionId], name: "pk_relay_agent_chats" })]);
255
- var relayExecutionState = pgTable("relay_execution_state", {
256
- tenantId: tenantId(),
257
- executionId: text("execution_id").$type().notNull(),
258
- key: text("state_key").notNull(),
259
- valueJson: jsonb("value_json").$type().notNull(),
260
- version: integer("version").notNull(),
261
- createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
262
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
263
- }, (table) => [
264
- primaryKey({ columns: [table.tenantId, table.executionId, table.key], name: "pk_relay_execution_state" })
265
- ]);
266
- var relayExecutionStateOps = pgTable("relay_execution_state_ops", {
250
+ executionId: text5("execution_id").$type().notNull(),
251
+ exportJson: jsonb4("export_json").notNull(),
252
+ updatedAt: timestamp4("updated_at", { withTimezone: true }).notNull().defaultNow()
253
+ }, (table) => [primaryKey4({ columns: [table.tenantId, table.executionId], name: "pk_relay_agent_chats" })]);
254
+ var relayAgentCompactions = pgTable4("relay_agent_compactions", {
267
255
  tenantId: tenantId(),
268
- executionId: text("execution_id").$type().notNull(),
269
- idempotencyKey: text("idempotency_key").notNull(),
270
- key: text("state_key").notNull(),
271
- version: integer("version").notNull(),
272
- op: text("op").notNull(),
273
- resultPresent: boolean("result_present").notNull(),
274
- resultValueJson: jsonb("result_value_json").$type(),
275
- resultCreatedAt: timestamp("result_created_at", { withTimezone: true }),
276
- resultUpdatedAt: timestamp("result_updated_at", { withTimezone: true }),
277
- createdAt: timestamp("created_at", { withTimezone: true }).notNull()
256
+ executionId: text5("execution_id").notNull().$type(),
257
+ checkpointId: text5("checkpoint_id").notNull(),
258
+ summary: text5("summary").notNull(),
259
+ firstKeptEntryId: text5("first_kept_entry_id").$type().notNull(),
260
+ turn: integer3("turn").notNull(),
261
+ createdAt: timestamp4("created_at", { withTimezone: true }).notNull().defaultNow()
278
262
  }, (table) => [
279
- primaryKey({
280
- columns: [table.tenantId, table.executionId, table.idempotencyKey],
281
- name: "pk_relay_execution_state_ops"
282
- }),
283
- index("idx_relay_execution_state_ops_version").on(table.tenantId, table.executionId, table.key, table.version)
284
- ]);
285
- var relayAgentCompactions = pgTable("relay_agent_compactions", {
286
- tenantId: tenantId(),
287
- executionId: text("execution_id").notNull().$type(),
288
- checkpointId: text("checkpoint_id").notNull(),
289
- summary: text("summary").notNull(),
290
- firstKeptEntryId: text("first_kept_entry_id").$type().notNull(),
291
- turn: integer("turn").notNull(),
292
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
293
- }, (table) => [
294
- primaryKey({
263
+ primaryKey4({
295
264
  columns: [table.tenantId, table.executionId, table.checkpointId],
296
265
  name: "pk_relay_agent_compactions"
297
266
  }),
298
- index("idx_relay_agent_compactions_execution_turn").on(table.tenantId, table.executionId, table.turn)
267
+ index2("idx_relay_agent_compactions_execution_turn").on(table.tenantId, table.executionId, table.turn)
299
268
  ]);
300
- var relayMemoryRecords = pgTable("relay_memory_records", {
269
+ var relayMemoryRecords = pgTable4("relay_memory_records", {
301
270
  tenantId: tenantId(),
302
- id: text("id").notNull(),
303
- agent: text("agent").notNull(),
304
- subject: text("subject").$type().notNull(),
271
+ id: text5("id").notNull(),
272
+ agent: text5("agent").notNull(),
273
+ subject: text5("subject").$type().notNull(),
305
274
  embedding: doublePrecision("embedding").array().notNull(),
306
- partsJson: jsonb("parts_json").$type().notNull(),
307
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
308
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
275
+ partsJson: jsonb4("parts_json").$type().notNull(),
276
+ metadataJson: jsonb4("metadata_json").$type().notNull().default({}),
277
+ createdAt: timestamp4("created_at", { withTimezone: true }).notNull().defaultNow()
309
278
  }, (table) => [
310
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_memory_records" }),
311
- index("idx_relay_memory_records_agent_subject").on(table.tenantId, table.agent, table.subject)
279
+ primaryKey4({ columns: [table.tenantId, table.id], name: "pk_relay_memory_records" }),
280
+ index2("idx_relay_memory_records_agent_subject").on(table.tenantId, table.agent, table.subject)
312
281
  ]);
313
- var relayPermissionRules = pgTable("relay_permission_rules", {
282
+ var relayPermissionRules = pgTable4("relay_permission_rules", {
314
283
  tenantId: tenantId(),
315
- agent: text("agent").notNull(),
316
- scope: text("scope").notNull(),
317
- pattern: text("pattern").notNull(),
318
- ruleJson: jsonb("rule_json").$type().notNull(),
319
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
284
+ agent: text5("agent").notNull(),
285
+ scope: text5("scope").notNull(),
286
+ pattern: text5("pattern").notNull(),
287
+ ruleJson: jsonb4("rule_json").$type().notNull(),
288
+ createdAt: timestamp4("created_at", { withTimezone: true }).notNull().defaultNow()
320
289
  }, (table) => [
321
- primaryKey({
290
+ primaryKey4({
322
291
  columns: [table.tenantId, table.agent, table.scope, table.pattern],
323
292
  name: "pk_relay_permission_rules"
324
293
  }),
325
- index("idx_relay_permission_rules_agent_scope").on(table.tenantId, table.agent, table.scope)
326
- ]);
327
- var relaySteeringMessages = pgTable("relay_steering_messages", {
328
- tenantId: tenantId(),
329
- executionId: text("execution_id").notNull(),
330
- kind: text("kind").notNull(),
331
- sequence: integer("sequence").notNull(),
332
- contentJson: jsonb("content_json").$type().notNull(),
333
- drainId: text("drain_id"),
334
- consumedAt: timestamp("consumed_at", { withTimezone: true }),
335
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
336
- }, (table) => [
337
- primaryKey({
294
+ index2("idx_relay_permission_rules_agent_scope").on(table.tenantId, table.agent, table.scope)
295
+ ]);
296
+ // ../store-sql/src/schema/execution-schema.ts
297
+ import { boolean as boolean2, index as index3, integer as integer4, jsonb as jsonb5, pgTable as pgTable5, primaryKey as primaryKey5, text as text6, timestamp as timestamp5, uniqueIndex as uniqueIndex3 } from "drizzle-orm/pg-core";
298
+ var relayExecutionState = pgTable5("relay_execution_state", {
299
+ tenantId: tenantId(),
300
+ executionId: text6("execution_id").$type().notNull(),
301
+ key: text6("state_key").notNull(),
302
+ valueJson: jsonb5("value_json").$type().notNull(),
303
+ version: integer4("version").notNull(),
304
+ createdAt: timestamp5("created_at", { withTimezone: true }).notNull(),
305
+ updatedAt: timestamp5("updated_at", { withTimezone: true }).notNull()
306
+ }, (table) => [
307
+ primaryKey5({ columns: [table.tenantId, table.executionId, table.key], name: "pk_relay_execution_state" })
308
+ ]);
309
+ var relayExecutionStateOps = pgTable5("relay_execution_state_ops", {
310
+ tenantId: tenantId(),
311
+ executionId: text6("execution_id").$type().notNull(),
312
+ idempotencyKey: text6("idempotency_key").notNull(),
313
+ key: text6("state_key").notNull(),
314
+ version: integer4("version").notNull(),
315
+ op: text6("op").notNull(),
316
+ resultPresent: boolean2("result_present").notNull(),
317
+ resultValueJson: jsonb5("result_value_json").$type(),
318
+ resultCreatedAt: timestamp5("result_created_at", { withTimezone: true }),
319
+ resultUpdatedAt: timestamp5("result_updated_at", { withTimezone: true }),
320
+ createdAt: timestamp5("created_at", { withTimezone: true }).notNull()
321
+ }, (table) => [
322
+ primaryKey5({
323
+ columns: [table.tenantId, table.executionId, table.idempotencyKey],
324
+ name: "pk_relay_execution_state_ops"
325
+ }),
326
+ index3("idx_relay_execution_state_ops_version").on(table.tenantId, table.executionId, table.key, table.version)
327
+ ]);
328
+ var relayExecutionContextEpochs = pgTable5("relay_execution_context_epochs", {
329
+ tenantId: tenantId(),
330
+ executionId: text6("execution_id").$type().notNull(),
331
+ baseline: text6("baseline").notNull(),
332
+ dynamicSourceIdsJson: jsonb5("dynamic_source_ids_json").$type().notNull().default([]),
333
+ openedAt: timestamp5("opened_at", { withTimezone: true }).notNull().defaultNow()
334
+ }, (table) => [primaryKey5({ columns: [table.tenantId, table.executionId], name: "pk_relay_execution_context_epochs" })]);
335
+ var relayExecutions = pgTable5("relay_executions", {
336
+ tenantId: tenantId(),
337
+ id: text6("id").$type().notNull(),
338
+ rootAddressId: text6("root_address_id").$type().notNull(),
339
+ sessionId: text6("session_id").$type(),
340
+ status: text6("status").$type().notNull(),
341
+ agentId: text6("agent_id").$type(),
342
+ agentRevision: integer4("agent_revision").$type(),
343
+ agentSnapshotJson: jsonb5("agent_snapshot_json").$type(),
344
+ agentToolInputSchemaDigestsJson: jsonb5("agent_tool_input_schema_digests_json").$type().notNull().default({}),
345
+ metadataJson: jsonb5("metadata_json").$type().notNull().default({}),
346
+ createdAt: timestamp5("created_at", { withTimezone: true }).notNull().defaultNow(),
347
+ updatedAt: timestamp5("updated_at", { withTimezone: true }).notNull().defaultNow()
348
+ }, (table) => [
349
+ primaryKey5({ columns: [table.tenantId, table.id], name: "pk_relay_executions" }),
350
+ index3("idx_relay_executions_root_status").on(table.tenantId, table.rootAddressId, table.status),
351
+ index3("idx_relay_executions_session_updated_id").on(table.tenantId, table.sessionId, table.updatedAt, table.id),
352
+ index3("idx_relay_executions_updated_id").on(table.tenantId, table.updatedAt, table.id),
353
+ index3("idx_relay_executions_root_status_updated_id").on(table.tenantId, table.rootAddressId, table.status, table.updatedAt, table.id)
354
+ ]);
355
+ var relayChildExecutions = pgTable5("relay_child_executions", {
356
+ tenantId: tenantId(),
357
+ id: text6("id").$type().notNull(),
358
+ executionId: text6("execution_id").$type().notNull(),
359
+ addressId: text6("address_id").$type().notNull(),
360
+ status: text6("status").$type().notNull(),
361
+ metadataJson: jsonb5("metadata_json").$type().notNull().default({}),
362
+ createdAt: timestamp5("created_at", { withTimezone: true }).notNull().defaultNow(),
363
+ updatedAt: timestamp5("updated_at", { withTimezone: true }).notNull().defaultNow()
364
+ }, (table) => [
365
+ primaryKey5({ columns: [table.tenantId, table.id], name: "pk_relay_child_executions" }),
366
+ index3("idx_relay_child_executions_parent").on(table.tenantId, table.executionId)
367
+ ]);
368
+ var relayChildFanOuts = pgTable5("relay_child_fan_outs", {
369
+ tenantId: tenantId(),
370
+ id: text6("id").$type().notNull(),
371
+ parentExecutionId: text6("parent_execution_id").$type().notNull(),
372
+ definitionJson: jsonb5("definition_json").$type().notNull(),
373
+ state: text6("state").$type().notNull().default("joining"),
374
+ satisfiedAt: timestamp5("satisfied_at", { withTimezone: true }),
375
+ failedAt: timestamp5("failed_at", { withTimezone: true }),
376
+ cancelledAt: timestamp5("cancelled_at", { withTimezone: true }),
377
+ createdAt: timestamp5("created_at", { withTimezone: true }).notNull().defaultNow()
378
+ }, (table) => [
379
+ primaryKey5({ columns: [table.tenantId, table.id], name: "pk_relay_child_fan_outs" }),
380
+ index3("idx_relay_child_fan_outs_parent").on(table.tenantId, table.parentExecutionId)
381
+ ]);
382
+ var relayChildFanOutMembers = pgTable5("relay_child_fan_out_members", {
383
+ tenantId: tenantId(),
384
+ fanOutId: text6("fan_out_id").$type().notNull(),
385
+ childExecutionId: text6("child_execution_id").$type().notNull(),
386
+ ordinal: integer4("ordinal").notNull(),
387
+ state: text6("state").$type().notNull().default("queued"),
388
+ outputJson: jsonb5("output_json").$type(),
389
+ error: text6("error"),
390
+ completedAt: timestamp5("completed_at", { withTimezone: true })
391
+ }, (table) => [
392
+ primaryKey5({
393
+ columns: [table.tenantId, table.fanOutId, table.childExecutionId],
394
+ name: "pk_relay_child_fan_out_members"
395
+ }),
396
+ uniqueIndex3("uq_relay_child_fan_out_member_ordinal").on(table.tenantId, table.fanOutId, table.ordinal)
397
+ ]);
398
+ var relayExecutionEvents = pgTable5("relay_execution_events", {
399
+ tenantId: tenantId(),
400
+ id: text6("id").$type().notNull(),
401
+ executionId: text6("execution_id").$type().notNull(),
402
+ childExecutionId: text6("child_execution_id").$type(),
403
+ type: text6("type").notNull(),
404
+ sequence: integer4("sequence").notNull(),
405
+ cursor: text6("cursor").notNull(),
406
+ contentJson: jsonb5("content_json").$type(),
407
+ dataJson: jsonb5("data_json").$type().notNull().default({}),
408
+ createdAt: timestamp5("created_at", { withTimezone: true }).notNull().defaultNow()
409
+ }, (table) => [
410
+ primaryKey5({ columns: [table.tenantId, table.id], name: "pk_relay_execution_events" }),
411
+ index3("idx_relay_execution_events_execution").on(table.tenantId, table.executionId, table.createdAt),
412
+ uniqueIndex3("uq_relay_execution_events_sequence").on(table.tenantId, table.executionId, table.sequence),
413
+ uniqueIndex3("uq_relay_execution_events_cursor").on(table.tenantId, table.cursor)
414
+ ]);
415
+ // ../store-sql/src/schema/communication-schema.ts
416
+ import { index as index4, integer as integer5, jsonb as jsonb6, pgTable as pgTable6, primaryKey as primaryKey6, text as text7, timestamp as timestamp6, uniqueIndex as uniqueIndex4 } from "drizzle-orm/pg-core";
417
+ var relaySteeringMessages = pgTable6("relay_steering_messages", {
418
+ tenantId: tenantId(),
419
+ executionId: text7("execution_id").notNull(),
420
+ kind: text7("kind").notNull(),
421
+ sequence: integer5("sequence").notNull(),
422
+ contentJson: jsonb6("content_json").$type().notNull(),
423
+ drainId: text7("drain_id"),
424
+ consumedAt: timestamp6("consumed_at", { withTimezone: true }),
425
+ createdAt: timestamp6("created_at", { withTimezone: true }).notNull().defaultNow()
426
+ }, (table) => [
427
+ primaryKey6({
338
428
  columns: [table.tenantId, table.executionId, table.kind, table.sequence],
339
429
  name: "pk_relay_steering_messages"
340
430
  }),
341
- index("idx_relay_steering_messages_unconsumed").on(table.tenantId, table.executionId, table.kind, table.consumedAt, table.sequence),
342
- index("idx_relay_steering_messages_drain").on(table.tenantId, table.executionId, table.kind, table.drainId, table.sequence)
431
+ index4("idx_relay_steering_messages_unconsumed").on(table.tenantId, table.executionId, table.kind, table.consumedAt, table.sequence),
432
+ index4("idx_relay_steering_messages_drain").on(table.tenantId, table.executionId, table.kind, table.drainId, table.sequence)
343
433
  ]);
344
- var relaySteeringDrains = pgTable("relay_steering_drains", {
434
+ var relaySteeringDrains = pgTable6("relay_steering_drains", {
345
435
  tenantId: tenantId(),
346
- executionId: text("execution_id").notNull(),
347
- kind: text("kind").notNull(),
348
- drainId: text("drain_id").notNull(),
349
- messageSequencesJson: jsonb("message_sequences_json").$type().notNull().default([]),
350
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
436
+ executionId: text7("execution_id").notNull(),
437
+ kind: text7("kind").notNull(),
438
+ drainId: text7("drain_id").notNull(),
439
+ messageSequencesJson: jsonb6("message_sequences_json").$type().notNull().default([]),
440
+ createdAt: timestamp6("created_at", { withTimezone: true }).notNull().defaultNow()
351
441
  }, (table) => [
352
- primaryKey({
442
+ primaryKey6({
353
443
  columns: [table.tenantId, table.executionId, table.kind, table.drainId],
354
444
  name: "pk_relay_steering_drains"
355
445
  })
356
446
  ]);
357
- var relayInboxMessages = pgTable("relay_inbox_messages", {
447
+ var relayInboxMessages = pgTable6("relay_inbox_messages", {
358
448
  tenantId: tenantId(),
359
- executionId: text("execution_id").$type().notNull(),
360
- sequence: integer("sequence").notNull(),
361
- fromAddressId: text("from_address_id").$type().notNull(),
362
- envelopeId: text("envelope_id").$type(),
363
- contentJson: jsonb("content_json").$type().notNull(),
364
- replyWaitId: text("reply_wait_id").$type(),
365
- correlationKey: text("correlation_key"),
366
- idempotencyKey: text("idempotency_key"),
367
- drainId: text("drain_id"),
368
- consumedAt: timestamp("consumed_at", { withTimezone: true }),
369
- metadataJson: jsonb("metadata_json").$type(),
370
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
449
+ executionId: text7("execution_id").$type().notNull(),
450
+ sequence: integer5("sequence").notNull(),
451
+ fromAddressId: text7("from_address_id").$type().notNull(),
452
+ envelopeId: text7("envelope_id").$type(),
453
+ contentJson: jsonb6("content_json").$type().notNull(),
454
+ replyWaitId: text7("reply_wait_id").$type(),
455
+ correlationKey: text7("correlation_key"),
456
+ idempotencyKey: text7("idempotency_key"),
457
+ drainId: text7("drain_id"),
458
+ consumedAt: timestamp6("consumed_at", { withTimezone: true }),
459
+ metadataJson: jsonb6("metadata_json").$type(),
460
+ createdAt: timestamp6("created_at", { withTimezone: true }).notNull().defaultNow()
371
461
  }, (table) => [
372
- primaryKey({ columns: [table.tenantId, table.executionId, table.sequence], name: "pk_relay_inbox_messages" }),
373
- uniqueIndex("uq_relay_inbox_messages_idempotency").on(table.tenantId, table.executionId, table.idempotencyKey),
374
- index("idx_relay_inbox_messages_unconsumed").on(table.tenantId, table.executionId, table.consumedAt, table.sequence),
375
- index("idx_relay_inbox_messages_drain").on(table.tenantId, table.executionId, table.drainId, table.sequence)
462
+ primaryKey6({ columns: [table.tenantId, table.executionId, table.sequence], name: "pk_relay_inbox_messages" }),
463
+ uniqueIndex4("uq_relay_inbox_messages_idempotency").on(table.tenantId, table.executionId, table.idempotencyKey),
464
+ index4("idx_relay_inbox_messages_unconsumed").on(table.tenantId, table.executionId, table.consumedAt, table.sequence),
465
+ index4("idx_relay_inbox_messages_drain").on(table.tenantId, table.executionId, table.drainId, table.sequence)
376
466
  ]);
377
- var relayInboxDrains = pgTable("relay_inbox_drains", {
467
+ var relayInboxDrains = pgTable6("relay_inbox_drains", {
378
468
  tenantId: tenantId(),
379
- executionId: text("execution_id").$type().notNull(),
380
- drainId: text("drain_id").notNull(),
381
- messageSequencesJson: jsonb("message_sequences_json").$type().notNull().default([]),
382
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
469
+ executionId: text7("execution_id").$type().notNull(),
470
+ drainId: text7("drain_id").notNull(),
471
+ messageSequencesJson: jsonb6("message_sequences_json").$type().notNull().default([]),
472
+ createdAt: timestamp6("created_at", { withTimezone: true }).notNull().defaultNow()
383
473
  }, (table) => [
384
- primaryKey({ columns: [table.tenantId, table.executionId, table.drainId], name: "pk_relay_inbox_drains" })
474
+ primaryKey6({ columns: [table.tenantId, table.executionId, table.drainId], name: "pk_relay_inbox_drains" })
385
475
  ]);
386
- var relayTopicSubscriptions = pgTable("relay_topic_subscriptions", {
476
+ var relayTopicSubscriptions = pgTable6("relay_topic_subscriptions", {
387
477
  tenantId: tenantId(),
388
- topicAddressId: text("topic_address_id").$type().notNull(),
389
- subscriberExecutionId: text("subscriber_execution_id").$type().notNull(),
390
- metadataJson: jsonb("metadata_json").$type(),
391
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
478
+ topicAddressId: text7("topic_address_id").$type().notNull(),
479
+ subscriberExecutionId: text7("subscriber_execution_id").$type().notNull(),
480
+ metadataJson: jsonb6("metadata_json").$type(),
481
+ createdAt: timestamp6("created_at", { withTimezone: true }).notNull().defaultNow()
392
482
  }, (table) => [
393
- primaryKey({
483
+ primaryKey6({
394
484
  columns: [table.tenantId, table.topicAddressId, table.subscriberExecutionId],
395
485
  name: "pk_relay_topic_subscriptions"
396
486
  }),
397
- index("idx_relay_topic_subscriptions_subscriber").on(table.tenantId, table.subscriberExecutionId)
398
- ]);
399
- var relaySessions = pgTable("relay_sessions", {
400
- tenantId: tenantId(),
401
- id: text("id").$type().notNull(),
402
- rootAddressId: text("root_address_id").$type().notNull(),
403
- leafEntryId: text("leaf_entry_id").$type(),
404
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
405
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
406
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
407
- }, (table) => [
408
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_sessions" }),
409
- index("idx_relay_sessions_updated_id").on(table.tenantId, table.updatedAt, table.id),
410
- index("idx_relay_sessions_root_updated_id").on(table.tenantId, table.rootAddressId, table.updatedAt, table.id)
411
- ]);
412
- var relaySessionEntries = pgTable("relay_session_entries", {
413
- tenantId: tenantId(),
414
- id: text("id").$type().notNull(),
415
- sessionId: text("session_id").$type().notNull(),
416
- parentId: text("parent_id").$type(),
417
- tag: text("tag").notNull(),
418
- payloadJson: jsonb("payload_json").notNull(),
419
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
420
- }, (table) => [
421
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_session_entries" }),
422
- index("idx_relay_session_entries_session_created").on(table.tenantId, table.sessionId, table.createdAt, table.id),
423
- index("idx_relay_session_entries_session_parent").on(table.tenantId, table.sessionId, table.parentId)
424
- ]);
425
- var relayExecutionContextEpochs = pgTable("relay_execution_context_epochs", {
426
- tenantId: tenantId(),
427
- executionId: text("execution_id").$type().notNull(),
428
- baseline: text("baseline").notNull(),
429
- dynamicSourceIdsJson: jsonb("dynamic_source_ids_json").$type().notNull().default([]),
430
- openedAt: timestamp("opened_at", { withTimezone: true }).notNull().defaultNow()
431
- }, (table) => [primaryKey({ columns: [table.tenantId, table.executionId], name: "pk_relay_execution_context_epochs" })]);
432
- var relayExecutions = pgTable("relay_executions", {
433
- tenantId: tenantId(),
434
- id: text("id").$type().notNull(),
435
- rootAddressId: text("root_address_id").$type().notNull(),
436
- sessionId: text("session_id").$type(),
437
- status: text("status").$type().notNull(),
438
- agentId: text("agent_id").$type(),
439
- agentRevision: integer("agent_revision").$type(),
440
- agentSnapshotJson: jsonb("agent_snapshot_json").$type(),
441
- agentToolInputSchemaDigestsJson: jsonb("agent_tool_input_schema_digests_json").$type().notNull().default({}),
442
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
443
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
444
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
445
- }, (table) => [
446
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_executions" }),
447
- index("idx_relay_executions_root_status").on(table.tenantId, table.rootAddressId, table.status),
448
- index("idx_relay_executions_session_updated_id").on(table.tenantId, table.sessionId, table.updatedAt, table.id),
449
- index("idx_relay_executions_updated_id").on(table.tenantId, table.updatedAt, table.id),
450
- index("idx_relay_executions_root_status_updated_id").on(table.tenantId, table.rootAddressId, table.status, table.updatedAt, table.id)
451
- ]);
452
- var relayChildExecutions = pgTable("relay_child_executions", {
453
- tenantId: tenantId(),
454
- id: text("id").$type().notNull(),
455
- executionId: text("execution_id").$type().notNull(),
456
- addressId: text("address_id").$type().notNull(),
457
- status: text("status").$type().notNull(),
458
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
459
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
460
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
461
- }, (table) => [
462
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_child_executions" }),
463
- index("idx_relay_child_executions_parent").on(table.tenantId, table.executionId)
464
- ]);
465
- var relayChildFanOuts = pgTable("relay_child_fan_outs", {
466
- tenantId: tenantId(),
467
- id: text("id").$type().notNull(),
468
- parentExecutionId: text("parent_execution_id").$type().notNull(),
469
- definitionJson: jsonb("definition_json").$type().notNull(),
470
- state: text("state").$type().notNull().default("joining"),
471
- satisfiedAt: timestamp("satisfied_at", { withTimezone: true }),
472
- failedAt: timestamp("failed_at", { withTimezone: true }),
473
- cancelledAt: timestamp("cancelled_at", { withTimezone: true }),
474
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
475
- }, (table) => [
476
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_child_fan_outs" }),
477
- index("idx_relay_child_fan_outs_parent").on(table.tenantId, table.parentExecutionId)
478
- ]);
479
- var relayChildFanOutMembers = pgTable("relay_child_fan_out_members", {
480
- tenantId: tenantId(),
481
- fanOutId: text("fan_out_id").$type().notNull(),
482
- childExecutionId: text("child_execution_id").$type().notNull(),
483
- ordinal: integer("ordinal").notNull(),
484
- state: text("state").$type().notNull().default("queued"),
485
- outputJson: jsonb("output_json").$type(),
486
- error: text("error"),
487
- completedAt: timestamp("completed_at", { withTimezone: true })
488
- }, (table) => [
489
- primaryKey({
490
- columns: [table.tenantId, table.fanOutId, table.childExecutionId],
491
- name: "pk_relay_child_fan_out_members"
492
- }),
493
- uniqueIndex("uq_relay_child_fan_out_member_ordinal").on(table.tenantId, table.fanOutId, table.ordinal)
494
- ]);
495
- var relayEnvelopes = pgTable("relay_envelopes", {
496
- tenantId: tenantId(),
497
- id: text("id").$type().notNull(),
498
- executionId: text("execution_id").$type().notNull(),
499
- fromAddressId: text("from_address_id").$type().notNull(),
500
- toAddressId: text("to_address_id").$type().notNull(),
501
- contentJson: jsonb("content_json").$type().notNull(),
502
- waitJson: jsonb("wait_json").$type(),
503
- correlationKey: text("correlation_key"),
504
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
505
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
506
- }, (table) => [
507
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_envelopes" }),
508
- index("idx_relay_envelopes_execution").on(table.tenantId, table.executionId, table.createdAt),
509
- index("idx_relay_envelopes_to_address").on(table.tenantId, table.toAddressId, table.createdAt)
510
- ]);
511
- var relayWaits = pgTable("relay_waits", {
512
- tenantId: tenantId(),
513
- id: text("id").$type().notNull(),
514
- executionId: text("execution_id").$type().notNull(),
515
- envelopeId: text("envelope_id").$type(),
516
- mode: text("mode").$type().notNull(),
517
- correlationKey: text("correlation_key"),
518
- state: text("state").notNull().default("open"),
519
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
520
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
521
- resolvedAt: timestamp("resolved_at", { withTimezone: true })
522
- }, (table) => [
523
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_waits" }),
524
- index("idx_relay_waits_execution_state").on(table.tenantId, table.executionId, table.state)
525
- ]);
526
- var relayWorkspaceLeases = pgTable("relay_workspace_leases", {
527
- tenantId: tenantId(),
528
- id: text("id").$type().notNull(),
529
- executionId: text("execution_id").$type().notNull(),
530
- providerKey: text("provider_key").$type().notNull(),
531
- sandboxRef: text("sandbox_ref").$type(),
532
- latestSnapshotRef: text("latest_snapshot_ref").$type(),
533
- status: text("status").$type().notNull(),
534
- resumeStrategy: text("resume_strategy").$type().notNull(),
535
- region: text("region"),
536
- requestJson: jsonb("request_json").$type(),
537
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
538
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
539
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
540
- }, (table) => [
541
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_workspace_leases" }),
542
- uniqueIndex("uq_relay_workspace_leases_active_execution").on(table.tenantId, table.executionId).where(sql2`${table.status} not in ('released', 'failed')`),
543
- index("idx_relay_workspace_leases_execution").on(table.tenantId, table.executionId),
544
- index("idx_relay_workspace_leases_status_updated").on(table.tenantId, table.status, table.updatedAt)
545
- ]);
546
- var relayWorkspaceSnapshots = pgTable("relay_workspace_snapshots", {
547
- tenantId: tenantId(),
548
- id: text("id").$type().notNull(),
549
- leaseId: text("lease_id").$type().notNull(),
550
- executionId: text("execution_id").$type().notNull(),
551
- reason: text("reason").$type().notNull(),
552
- snapshotRef: text("snapshot_ref").$type().notNull(),
553
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
554
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
555
- }, (table) => [
556
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_workspace_snapshots" }),
557
- index("idx_relay_workspace_snapshots_lease").on(table.tenantId, table.leaseId, table.createdAt),
558
- index("idx_relay_workspace_snapshots_execution").on(table.tenantId, table.executionId, table.createdAt)
559
- ]);
560
- var relayEnvelopeReady = pgTable("relay_envelope_ready", {
561
- tenantId: tenantId(),
562
- id: text("id").$type().notNull(),
563
- envelopeId: text("envelope_id").$type().notNull(),
564
- routeType: text("route_type").notNull(),
565
- routeKey: text("route_key").notNull(),
566
- state: text("state").notNull().default("ready"),
567
- availableAt: timestamp("available_at", { withTimezone: true }).notNull().defaultNow(),
568
- attempt: integer("attempt").notNull().default(0),
569
- claimOwner: text("claim_owner"),
570
- claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
571
- lastError: text("last_error"),
572
- idempotencyKey: text("idempotency_key"),
573
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
574
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
575
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
576
- claimedAt: timestamp("claimed_at", { withTimezone: true }),
577
- acknowledgedAt: timestamp("acknowledged_at", { withTimezone: true })
578
- }, (table) => [
579
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_envelope_ready" }),
580
- index("idx_relay_envelope_ready_state_available").on(table.tenantId, table.state, table.availableAt),
581
- index("idx_relay_envelope_ready_claim_expires").on(table.tenantId, table.claimExpiresAt),
582
- uniqueIndex("uq_relay_envelope_ready_idempotency").on(table.tenantId, table.idempotencyKey)
583
- ]);
584
- var relaySchedules = pgTable("relay_schedules", {
585
- tenantId: tenantId(),
586
- id: text("id").$type().notNull(),
587
- kind: text("kind").notNull(),
588
- targetKind: text("target_kind").notNull(),
589
- addressId: text("address_id").$type(),
590
- waitId: text("wait_id").$type(),
591
- cronExpr: text("cron_expr"),
592
- inputJson: jsonb("input_json").$type(),
593
- state: text("state").notNull().default("active"),
594
- nextRunAt: timestamp("next_run_at", { withTimezone: true }).notNull(),
595
- attempt: integer("attempt").notNull().default(0),
596
- claimOwner: text("claim_owner"),
597
- claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
598
- lastError: text("last_error"),
599
- idempotencyKey: text("idempotency_key"),
600
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
601
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
602
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
603
- }, (table) => [
604
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_schedules" }),
605
- index("idx_relay_schedules_state_next_run").on(table.tenantId, table.state, table.nextRunAt),
606
- index("idx_relay_schedules_claim_expires").on(table.tenantId, table.claimExpiresAt),
607
- index("idx_relay_schedules_wait").on(table.tenantId, table.waitId),
608
- uniqueIndex("uq_relay_schedules_idempotency").on(table.tenantId, table.idempotencyKey)
609
- ]);
610
- var relayExecutionEvents = pgTable("relay_execution_events", {
611
- tenantId: tenantId(),
612
- id: text("id").$type().notNull(),
613
- executionId: text("execution_id").$type().notNull(),
614
- childExecutionId: text("child_execution_id").$type(),
615
- type: text("type").notNull(),
616
- sequence: integer("sequence").notNull(),
617
- cursor: text("cursor").notNull(),
618
- contentJson: jsonb("content_json").$type(),
619
- dataJson: jsonb("data_json").$type().notNull().default({}),
620
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
621
- }, (table) => [
622
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_execution_events" }),
623
- index("idx_relay_execution_events_execution").on(table.tenantId, table.executionId, table.createdAt),
624
- uniqueIndex("uq_relay_execution_events_sequence").on(table.tenantId, table.executionId, table.sequence),
625
- uniqueIndex("uq_relay_execution_events_cursor").on(table.tenantId, table.cursor)
626
- ]);
627
- var relayPresence = pgTable("relay_presence", {
628
- tenantId: tenantId(),
629
- id: text("id").notNull(),
630
- scopeKind: text("scope_kind").$type().notNull(),
631
- scopeId: text("scope_id").notNull(),
632
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
633
- connectedAt: timestamp("connected_at", { withTimezone: true }).notNull().defaultNow(),
634
- expiresAt: timestamp("expires_at", { withTimezone: true }).notNull()
635
- }, (table) => [
636
- primaryKey({ columns: [table.tenantId, table.id, table.scopeKind, table.scopeId], name: "pk_relay_presence" }),
637
- index("idx_relay_presence_scope_expires").on(table.tenantId, table.scopeKind, table.scopeId, table.expiresAt)
638
- ]);
639
- var relayToolCalls = pgTable("relay_tool_calls", {
640
- tenantId: tenantId(),
641
- id: text("id").$type().notNull(),
642
- executionId: text("execution_id").$type().notNull(),
643
- name: text("name").notNull(),
644
- inputJson: jsonb("input_json").notNull(),
645
- definitionJson: jsonb("definition_json").$type(),
646
- placementKind: text("placement_kind").$type().notNull().default("local"),
647
- placementKey: text("placement_key"),
648
- state: text("state").$type().notNull().default("requested"),
649
- waitId: text("wait_id").$type(),
650
- idempotencyKey: text("idempotency_key").notNull(),
651
- availableAt: timestamp("available_at", { withTimezone: true }).notNull().defaultNow(),
652
- activeAttemptId: text("active_attempt_id").$type(),
653
- claimOwner: text("claim_owner"),
654
- claimedAt: timestamp("claimed_at", { withTimezone: true }),
655
- claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
656
- externalOutcomeJson: jsonb("external_outcome_json").$type(),
657
- externalOutcomeAt: timestamp("external_outcome_at", { withTimezone: true }),
658
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
659
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
660
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
661
- }, (table) => [
662
- primaryKey({ columns: [table.tenantId, table.executionId, table.id], name: "pk_relay_tool_calls" }),
663
- index("idx_relay_tool_calls_execution").on(table.tenantId, table.executionId, table.createdAt),
664
- index("idx_relay_tool_calls_remote_claim").on(table.tenantId, table.placementKind, table.placementKey, table.state, table.availableAt, table.createdAt, table.id),
665
- index("idx_relay_tool_calls_stale_claim").on(table.tenantId, table.state, table.claimExpiresAt),
666
- index("idx_relay_tool_calls_client_pending").on(table.tenantId, table.placementKind, table.state, table.createdAt, table.id)
667
- ]);
668
- var relayToolAttempts = pgTable("relay_tool_attempts", {
669
- tenantId: tenantId(),
670
- executionId: text("execution_id").$type().notNull(),
671
- id: text("id").$type().notNull(),
672
- toolCallId: text("tool_call_id").$type().notNull(),
673
- attemptNumber: integer("attempt_number").notNull(),
674
- state: text("state").$type().notNull(),
675
- workerId: text("worker_id"),
676
- claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
677
- error: text("error"),
678
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
679
- completedAt: timestamp("completed_at", { withTimezone: true })
680
- }, (table) => [
681
- primaryKey({
487
+ index4("idx_relay_topic_subscriptions_subscriber").on(table.tenantId, table.subscriberExecutionId)
488
+ ]);
489
+ // ../store-sql/src/schema/session-schema.ts
490
+ import { index as index5, jsonb as jsonb7, pgTable as pgTable7, primaryKey as primaryKey7, text as text8, timestamp as timestamp7 } from "drizzle-orm/pg-core";
491
+ var relaySessions = pgTable7("relay_sessions", {
492
+ tenantId: tenantId(),
493
+ id: text8("id").$type().notNull(),
494
+ rootAddressId: text8("root_address_id").$type().notNull(),
495
+ leafEntryId: text8("leaf_entry_id").$type(),
496
+ metadataJson: jsonb7("metadata_json").$type().notNull().default({}),
497
+ createdAt: timestamp7("created_at", { withTimezone: true }).notNull().defaultNow(),
498
+ updatedAt: timestamp7("updated_at", { withTimezone: true }).notNull().defaultNow()
499
+ }, (table) => [
500
+ primaryKey7({ columns: [table.tenantId, table.id], name: "pk_relay_sessions" }),
501
+ index5("idx_relay_sessions_updated_id").on(table.tenantId, table.updatedAt, table.id),
502
+ index5("idx_relay_sessions_root_updated_id").on(table.tenantId, table.rootAddressId, table.updatedAt, table.id)
503
+ ]);
504
+ var relaySessionEntries = pgTable7("relay_session_entries", {
505
+ tenantId: tenantId(),
506
+ id: text8("id").$type().notNull(),
507
+ sessionId: text8("session_id").$type().notNull(),
508
+ parentId: text8("parent_id").$type(),
509
+ tag: text8("tag").notNull(),
510
+ payloadJson: jsonb7("payload_json").notNull(),
511
+ createdAt: timestamp7("created_at", { withTimezone: true }).notNull().defaultNow()
512
+ }, (table) => [
513
+ primaryKey7({ columns: [table.tenantId, table.id], name: "pk_relay_session_entries" }),
514
+ index5("idx_relay_session_entries_session_created").on(table.tenantId, table.sessionId, table.createdAt, table.id),
515
+ index5("idx_relay_session_entries_session_parent").on(table.tenantId, table.sessionId, table.parentId)
516
+ ]);
517
+ // ../store-sql/src/schema/envelope-schema.ts
518
+ import { index as index6, integer as integer6, jsonb as jsonb8, pgTable as pgTable8, primaryKey as primaryKey8, text as text9, timestamp as timestamp8, uniqueIndex as uniqueIndex5 } from "drizzle-orm/pg-core";
519
+ var relayEnvelopes = pgTable8("relay_envelopes", {
520
+ tenantId: tenantId(),
521
+ id: text9("id").$type().notNull(),
522
+ executionId: text9("execution_id").$type().notNull(),
523
+ fromAddressId: text9("from_address_id").$type().notNull(),
524
+ toAddressId: text9("to_address_id").$type().notNull(),
525
+ contentJson: jsonb8("content_json").$type().notNull(),
526
+ waitJson: jsonb8("wait_json").$type(),
527
+ correlationKey: text9("correlation_key"),
528
+ metadataJson: jsonb8("metadata_json").$type().notNull().default({}),
529
+ createdAt: timestamp8("created_at", { withTimezone: true }).notNull().defaultNow()
530
+ }, (table) => [
531
+ primaryKey8({ columns: [table.tenantId, table.id], name: "pk_relay_envelopes" }),
532
+ index6("idx_relay_envelopes_execution").on(table.tenantId, table.executionId, table.createdAt),
533
+ index6("idx_relay_envelopes_to_address").on(table.tenantId, table.toAddressId, table.createdAt)
534
+ ]);
535
+ var relayWaits = pgTable8("relay_waits", {
536
+ tenantId: tenantId(),
537
+ id: text9("id").$type().notNull(),
538
+ executionId: text9("execution_id").$type().notNull(),
539
+ envelopeId: text9("envelope_id").$type(),
540
+ mode: text9("mode").$type().notNull(),
541
+ correlationKey: text9("correlation_key"),
542
+ state: text9("state").notNull().default("open"),
543
+ metadataJson: jsonb8("metadata_json").$type().notNull().default({}),
544
+ createdAt: timestamp8("created_at", { withTimezone: true }).notNull().defaultNow(),
545
+ resolvedAt: timestamp8("resolved_at", { withTimezone: true })
546
+ }, (table) => [
547
+ primaryKey8({ columns: [table.tenantId, table.id], name: "pk_relay_waits" }),
548
+ index6("idx_relay_waits_execution_state").on(table.tenantId, table.executionId, table.state)
549
+ ]);
550
+ var relayEnvelopeReady = pgTable8("relay_envelope_ready", {
551
+ tenantId: tenantId(),
552
+ id: text9("id").$type().notNull(),
553
+ envelopeId: text9("envelope_id").$type().notNull(),
554
+ routeType: text9("route_type").notNull(),
555
+ routeKey: text9("route_key").notNull(),
556
+ state: text9("state").notNull().default("ready"),
557
+ availableAt: timestamp8("available_at", { withTimezone: true }).notNull().defaultNow(),
558
+ attempt: integer6("attempt").notNull().default(0),
559
+ claimOwner: text9("claim_owner"),
560
+ claimExpiresAt: timestamp8("claim_expires_at", { withTimezone: true }),
561
+ lastError: text9("last_error"),
562
+ idempotencyKey: text9("idempotency_key"),
563
+ metadataJson: jsonb8("metadata_json").$type().notNull().default({}),
564
+ createdAt: timestamp8("created_at", { withTimezone: true }).notNull().defaultNow(),
565
+ updatedAt: timestamp8("updated_at", { withTimezone: true }).notNull().defaultNow(),
566
+ claimedAt: timestamp8("claimed_at", { withTimezone: true }),
567
+ acknowledgedAt: timestamp8("acknowledged_at", { withTimezone: true })
568
+ }, (table) => [
569
+ primaryKey8({ columns: [table.tenantId, table.id], name: "pk_relay_envelope_ready" }),
570
+ index6("idx_relay_envelope_ready_state_available").on(table.tenantId, table.state, table.availableAt),
571
+ index6("idx_relay_envelope_ready_claim_expires").on(table.tenantId, table.claimExpiresAt),
572
+ uniqueIndex5("uq_relay_envelope_ready_idempotency").on(table.tenantId, table.idempotencyKey)
573
+ ]);
574
+ var relayRouteAttempts = pgTable8("relay_route_attempts", {
575
+ tenantId: tenantId(),
576
+ id: text9("id").notNull(),
577
+ envelopeReadyId: text9("envelope_ready_id").$type().notNull(),
578
+ routeKey: text9("route_key").notNull(),
579
+ state: text9("state").notNull(),
580
+ detail: text9("detail"),
581
+ createdAt: timestamp8("created_at", { withTimezone: true }).notNull().defaultNow()
582
+ }, (table) => [
583
+ primaryKey8({ columns: [table.tenantId, table.id], name: "pk_relay_route_attempts" }),
584
+ index6("idx_relay_route_attempts_ready").on(table.tenantId, table.envelopeReadyId, table.createdAt)
585
+ ]);
586
+ // ../store-sql/src/schema/workspace-schema.ts
587
+ import { index as index7, jsonb as jsonb9, pgTable as pgTable9, primaryKey as primaryKey9, text as text10, timestamp as timestamp9, uniqueIndex as uniqueIndex6 } from "drizzle-orm/pg-core";
588
+ import { sql as sql2 } from "drizzle-orm";
589
+ var relayWorkspaceLeases = pgTable9("relay_workspace_leases", {
590
+ tenantId: tenantId(),
591
+ id: text10("id").$type().notNull(),
592
+ executionId: text10("execution_id").$type().notNull(),
593
+ providerKey: text10("provider_key").$type().notNull(),
594
+ sandboxRef: text10("sandbox_ref").$type(),
595
+ latestSnapshotRef: text10("latest_snapshot_ref").$type(),
596
+ status: text10("status").$type().notNull(),
597
+ resumeStrategy: text10("resume_strategy").$type().notNull(),
598
+ region: text10("region"),
599
+ requestJson: jsonb9("request_json").$type(),
600
+ metadataJson: jsonb9("metadata_json").$type().notNull().default({}),
601
+ createdAt: timestamp9("created_at", { withTimezone: true }).notNull().defaultNow(),
602
+ updatedAt: timestamp9("updated_at", { withTimezone: true }).notNull().defaultNow()
603
+ }, (table) => [
604
+ primaryKey9({ columns: [table.tenantId, table.id], name: "pk_relay_workspace_leases" }),
605
+ uniqueIndex6("uq_relay_workspace_leases_active_execution").on(table.tenantId, table.executionId).where(sql2`${table.status} not in ('released', 'failed')`),
606
+ index7("idx_relay_workspace_leases_execution").on(table.tenantId, table.executionId),
607
+ index7("idx_relay_workspace_leases_status_updated").on(table.tenantId, table.status, table.updatedAt)
608
+ ]);
609
+ var relayWorkspaceSnapshots = pgTable9("relay_workspace_snapshots", {
610
+ tenantId: tenantId(),
611
+ id: text10("id").$type().notNull(),
612
+ leaseId: text10("lease_id").$type().notNull(),
613
+ executionId: text10("execution_id").$type().notNull(),
614
+ reason: text10("reason").$type().notNull(),
615
+ snapshotRef: text10("snapshot_ref").$type().notNull(),
616
+ metadataJson: jsonb9("metadata_json").$type().notNull().default({}),
617
+ createdAt: timestamp9("created_at", { withTimezone: true }).notNull().defaultNow()
618
+ }, (table) => [
619
+ primaryKey9({ columns: [table.tenantId, table.id], name: "pk_relay_workspace_snapshots" }),
620
+ index7("idx_relay_workspace_snapshots_lease").on(table.tenantId, table.leaseId, table.createdAt),
621
+ index7("idx_relay_workspace_snapshots_execution").on(table.tenantId, table.executionId, table.createdAt)
622
+ ]);
623
+ // ../store-sql/src/schema/schedule-schema.ts
624
+ import { index as index8, integer as integer7, jsonb as jsonb10, pgTable as pgTable10, primaryKey as primaryKey10, text as text11, timestamp as timestamp10, uniqueIndex as uniqueIndex7 } from "drizzle-orm/pg-core";
625
+ var relaySchedules = pgTable10("relay_schedules", {
626
+ tenantId: tenantId(),
627
+ id: text11("id").$type().notNull(),
628
+ kind: text11("kind").notNull(),
629
+ targetKind: text11("target_kind").notNull(),
630
+ addressId: text11("address_id").$type(),
631
+ waitId: text11("wait_id").$type(),
632
+ cronExpr: text11("cron_expr"),
633
+ inputJson: jsonb10("input_json").$type(),
634
+ state: text11("state").notNull().default("active"),
635
+ nextRunAt: timestamp10("next_run_at", { withTimezone: true }).notNull(),
636
+ attempt: integer7("attempt").notNull().default(0),
637
+ claimOwner: text11("claim_owner"),
638
+ claimExpiresAt: timestamp10("claim_expires_at", { withTimezone: true }),
639
+ lastError: text11("last_error"),
640
+ idempotencyKey: text11("idempotency_key"),
641
+ metadataJson: jsonb10("metadata_json").$type().notNull().default({}),
642
+ createdAt: timestamp10("created_at", { withTimezone: true }).notNull().defaultNow(),
643
+ updatedAt: timestamp10("updated_at", { withTimezone: true }).notNull().defaultNow()
644
+ }, (table) => [
645
+ primaryKey10({ columns: [table.tenantId, table.id], name: "pk_relay_schedules" }),
646
+ index8("idx_relay_schedules_state_next_run").on(table.tenantId, table.state, table.nextRunAt),
647
+ index8("idx_relay_schedules_claim_expires").on(table.tenantId, table.claimExpiresAt),
648
+ index8("idx_relay_schedules_wait").on(table.tenantId, table.waitId),
649
+ uniqueIndex7("uq_relay_schedules_idempotency").on(table.tenantId, table.idempotencyKey)
650
+ ]);
651
+ // ../store-sql/src/schema/presence-schema.ts
652
+ import { index as index9, jsonb as jsonb11, pgTable as pgTable11, primaryKey as primaryKey11, text as text12, timestamp as timestamp11 } from "drizzle-orm/pg-core";
653
+ var relayPresence = pgTable11("relay_presence", {
654
+ tenantId: tenantId(),
655
+ id: text12("id").notNull(),
656
+ scopeKind: text12("scope_kind").$type().notNull(),
657
+ scopeId: text12("scope_id").notNull(),
658
+ metadataJson: jsonb11("metadata_json").$type().notNull().default({}),
659
+ connectedAt: timestamp11("connected_at", { withTimezone: true }).notNull().defaultNow(),
660
+ expiresAt: timestamp11("expires_at", { withTimezone: true }).notNull()
661
+ }, (table) => [
662
+ primaryKey11({ columns: [table.tenantId, table.id, table.scopeKind, table.scopeId], name: "pk_relay_presence" }),
663
+ index9("idx_relay_presence_scope_expires").on(table.tenantId, table.scopeKind, table.scopeId, table.expiresAt)
664
+ ]);
665
+ // ../store-sql/src/schema/tool-schema.ts
666
+ import { index as index10, integer as integer8, jsonb as jsonb12, pgTable as pgTable12, primaryKey as primaryKey12, text as text13, timestamp as timestamp12, uniqueIndex as uniqueIndex8 } from "drizzle-orm/pg-core";
667
+ var relayToolCalls = pgTable12("relay_tool_calls", {
668
+ tenantId: tenantId(),
669
+ id: text13("id").$type().notNull(),
670
+ executionId: text13("execution_id").$type().notNull(),
671
+ name: text13("name").notNull(),
672
+ inputJson: jsonb12("input_json").notNull(),
673
+ definitionJson: jsonb12("definition_json").$type(),
674
+ placementKind: text13("placement_kind").$type().notNull().default("local"),
675
+ placementKey: text13("placement_key"),
676
+ state: text13("state").$type().notNull().default("requested"),
677
+ waitId: text13("wait_id").$type(),
678
+ idempotencyKey: text13("idempotency_key").notNull(),
679
+ availableAt: timestamp12("available_at", { withTimezone: true }).notNull().defaultNow(),
680
+ activeAttemptId: text13("active_attempt_id").$type(),
681
+ claimOwner: text13("claim_owner"),
682
+ claimedAt: timestamp12("claimed_at", { withTimezone: true }),
683
+ claimExpiresAt: timestamp12("claim_expires_at", { withTimezone: true }),
684
+ externalOutcomeJson: jsonb12("external_outcome_json").$type(),
685
+ externalOutcomeAt: timestamp12("external_outcome_at", { withTimezone: true }),
686
+ metadataJson: jsonb12("metadata_json").$type().notNull().default({}),
687
+ createdAt: timestamp12("created_at", { withTimezone: true }).notNull().defaultNow(),
688
+ updatedAt: timestamp12("updated_at", { withTimezone: true }).notNull().defaultNow()
689
+ }, (table) => [
690
+ primaryKey12({ columns: [table.tenantId, table.executionId, table.id], name: "pk_relay_tool_calls" }),
691
+ index10("idx_relay_tool_calls_execution").on(table.tenantId, table.executionId, table.createdAt),
692
+ index10("idx_relay_tool_calls_remote_claim").on(table.tenantId, table.placementKind, table.placementKey, table.state, table.availableAt, table.createdAt, table.id),
693
+ index10("idx_relay_tool_calls_stale_claim").on(table.tenantId, table.state, table.claimExpiresAt),
694
+ index10("idx_relay_tool_calls_client_pending").on(table.tenantId, table.placementKind, table.state, table.createdAt, table.id)
695
+ ]);
696
+ var relayToolAttempts = pgTable12("relay_tool_attempts", {
697
+ tenantId: tenantId(),
698
+ executionId: text13("execution_id").$type().notNull(),
699
+ id: text13("id").$type().notNull(),
700
+ toolCallId: text13("tool_call_id").$type().notNull(),
701
+ attemptNumber: integer8("attempt_number").notNull(),
702
+ state: text13("state").$type().notNull(),
703
+ workerId: text13("worker_id"),
704
+ claimExpiresAt: timestamp12("claim_expires_at", { withTimezone: true }),
705
+ error: text13("error"),
706
+ createdAt: timestamp12("created_at", { withTimezone: true }).notNull().defaultNow(),
707
+ completedAt: timestamp12("completed_at", { withTimezone: true })
708
+ }, (table) => [
709
+ primaryKey12({
682
710
  columns: [table.tenantId, table.executionId, table.toolCallId, table.id],
683
711
  name: "pk_relay_tool_attempts"
684
712
  }),
685
- uniqueIndex("uq_relay_tool_attempts_number").on(table.tenantId, table.executionId, table.toolCallId, table.attemptNumber),
686
- index("idx_relay_tool_attempts_call").on(table.tenantId, table.executionId, table.toolCallId, table.attemptNumber)
713
+ uniqueIndex8("uq_relay_tool_attempts_number").on(table.tenantId, table.executionId, table.toolCallId, table.attemptNumber),
714
+ index10("idx_relay_tool_attempts_call").on(table.tenantId, table.executionId, table.toolCallId, table.attemptNumber)
687
715
  ]);
688
- var relayToolResults = pgTable("relay_tool_results", {
716
+ var relayToolResults = pgTable12("relay_tool_results", {
689
717
  tenantId: tenantId(),
690
- executionId: text("execution_id").$type().notNull(),
691
- toolCallId: text("tool_call_id").$type().notNull(),
692
- outputJson: jsonb("output_json").notNull(),
693
- error: text("error"),
694
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
695
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
718
+ executionId: text13("execution_id").$type().notNull(),
719
+ toolCallId: text13("tool_call_id").$type().notNull(),
720
+ outputJson: jsonb12("output_json").notNull(),
721
+ error: text13("error"),
722
+ metadataJson: jsonb12("metadata_json").$type().notNull().default({}),
723
+ createdAt: timestamp12("created_at", { withTimezone: true }).notNull().defaultNow()
696
724
  }, (table) => [
697
- primaryKey({
725
+ primaryKey12({
698
726
  columns: [table.tenantId, table.executionId, table.toolCallId],
699
727
  name: "pk_relay_tool_results"
700
728
  })
701
729
  ]);
702
- var relayRouteAttempts = pgTable("relay_route_attempts", {
730
+ // ../store-sql/src/schema/idempotency-schema.ts
731
+ import { jsonb as jsonb13, pgTable as pgTable13, primaryKey as primaryKey13, text as text14, timestamp as timestamp13, uniqueIndex as uniqueIndex9 } from "drizzle-orm/pg-core";
732
+ var relayIdempotencyKeys = pgTable13("relay_idempotency_keys", {
703
733
  tenantId: tenantId(),
704
- id: text("id").notNull(),
705
- envelopeReadyId: text("envelope_ready_id").$type().notNull(),
706
- routeKey: text("route_key").notNull(),
707
- state: text("state").notNull(),
708
- detail: text("detail"),
709
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
710
- }, (table) => [
711
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_route_attempts" }),
712
- index("idx_relay_route_attempts_ready").on(table.tenantId, table.envelopeReadyId, table.createdAt)
713
- ]);
714
- var relayIdempotencyKeys = pgTable("relay_idempotency_keys", {
715
- tenantId: tenantId(),
716
- id: text("id").notNull(),
717
- scope: text("scope").notNull(),
718
- operation: text("operation").notNull(),
719
- key: text("key").notNull(),
720
- resultJson: jsonb("result_json").$type(),
721
- metadataJson: jsonb("metadata_json").$type().notNull().default({}),
722
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
723
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
724
- expiresAt: timestamp("expires_at", { withTimezone: true })
734
+ id: text14("id").notNull(),
735
+ scope: text14("scope").notNull(),
736
+ operation: text14("operation").notNull(),
737
+ key: text14("key").notNull(),
738
+ resultJson: jsonb13("result_json").$type(),
739
+ metadataJson: jsonb13("metadata_json").$type().notNull().default({}),
740
+ createdAt: timestamp13("created_at", { withTimezone: true }).notNull().defaultNow(),
741
+ updatedAt: timestamp13("updated_at", { withTimezone: true }).notNull().defaultNow(),
742
+ expiresAt: timestamp13("expires_at", { withTimezone: true })
725
743
  }, (table) => [
726
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_idempotency_keys" }),
727
- uniqueIndex("uq_relay_idempotency_scope_operation_key").on(table.tenantId, table.scope, table.operation, table.key)
744
+ primaryKey13({ columns: [table.tenantId, table.id], name: "pk_relay_idempotency_keys" }),
745
+ uniqueIndex9("uq_relay_idempotency_scope_operation_key").on(table.tenantId, table.scope, table.operation, table.key)
728
746
  ]);
729
747
  // src/postgres.ts
730
- var schemaHead = "20260718140000_execution_scoped_tool_calls";
748
+ var schemaHead = "20260719120000_rename_entity_to_resident";
731
749
  var migrationNames = [
732
750
  "20260701002839_sour_cerebro",
733
751
  "20260701041134_acoustic_hulk",
@@ -754,6 +772,7 @@ var migrationNames = [
754
772
  "20260712180000_child_fan_out",
755
773
  "20260712190000_workflow_definitions",
756
774
  "20260712200000_workflow_runtime",
775
+ "20260718140000_execution_scoped_tool_calls",
757
776
  schemaHead
758
777
  ];
759
778
  var migrationsFolderUrl = import.meta.url.endsWith("/src/postgres.ts") ? new URL("../../../migrations/pg", import.meta.url) : new URL("./migrations/pg", import.meta.url);