@inkeep/agents-core 0.31.7 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/{chunk-RBUBOGX6.js → chunk-FUJJ4OQ2.js} +62 -10
  2. package/dist/chunk-SVXWB2HF.js +592 -0
  3. package/dist/{chunk-T5TTDZ6L.js → chunk-VSQY72K5.js} +133 -133
  4. package/dist/{chunk-PPBBIDK4.js → chunk-X6ZMJ3G6.js} +1 -1
  5. package/dist/client-exports.cjs +283 -224
  6. package/dist/client-exports.d.cts +7 -7
  7. package/dist/client-exports.d.ts +7 -7
  8. package/dist/client-exports.js +15 -7
  9. package/dist/db/schema.cjs +211 -211
  10. package/dist/db/schema.d.cts +3 -3
  11. package/dist/db/schema.d.ts +3 -3
  12. package/dist/db/schema.js +1 -1
  13. package/dist/index.cjs +18511 -12300
  14. package/dist/index.d.cts +409 -352
  15. package/dist/index.d.ts +409 -352
  16. package/dist/index.js +16250 -11076
  17. package/dist/nodefs-X2JO4ZHZ.js +21 -0
  18. package/dist/opfs-ahp-2UFDGV73.js +318 -0
  19. package/dist/{schema-lEFnfOQ-.d.ts → schema-CuEjPQt7.d.ts} +876 -1014
  20. package/dist/{schema-ztSm-Iv6.d.cts → schema-D1P8r3qm.d.cts} +876 -1014
  21. package/dist/types/index.d.cts +3 -3
  22. package/dist/types/index.d.ts +3 -3
  23. package/dist/{utility-qLyZ45lb.d.cts → utility-DF5IUC9K.d.cts} +1230 -1394
  24. package/dist/{utility-qLyZ45lb.d.ts → utility-DF5IUC9K.d.ts} +1230 -1394
  25. package/dist/validation/index.cjs +270 -219
  26. package/dist/validation/index.d.cts +3 -3
  27. package/dist/validation/index.d.ts +3 -3
  28. package/dist/validation/index.js +2 -2
  29. package/drizzle/0000_exotic_mysterio.sql +398 -0
  30. package/drizzle/meta/0000_snapshot.json +1683 -1223
  31. package/drizzle/meta/_journal.json +4 -102
  32. package/package.json +6 -3
  33. package/drizzle/0000_material_menace.sql +0 -326
  34. package/drizzle/0001_eminent_fixer.sql +0 -43
  35. package/drizzle/0002_bumpy_romulus.sql +0 -3
  36. package/drizzle/0003_soft_forgotten_one.sql +0 -39
  37. package/drizzle/0004_melted_omega_flight.sql +0 -3
  38. package/drizzle/0005_wide_shriek.sql +0 -127
  39. package/drizzle/0006_damp_lenny_balinger.sql +0 -52
  40. package/drizzle/0007_mighty_typhoid_mary.sql +0 -227
  41. package/drizzle/0008_mysterious_crusher_hogan.sql +0 -20
  42. package/drizzle/0009_old_black_cat.sql +0 -1
  43. package/drizzle/0010_wet_vampiro.sql +0 -2
  44. package/drizzle/0011_slippery_korg.sql +0 -36
  45. package/drizzle/0012_salty_psynapse.sql +0 -17
  46. package/drizzle/0013_shocking_blur.sql +0 -19
  47. package/drizzle/0014_broad_hellfire_club.sql +0 -29
  48. package/drizzle/meta/0001_snapshot.json +0 -2435
  49. package/drizzle/meta/0002_snapshot.json +0 -2428
  50. package/drizzle/meta/0003_snapshot.json +0 -2559
  51. package/drizzle/meta/0004_snapshot.json +0 -2547
  52. package/drizzle/meta/0005_snapshot.json +0 -2558
  53. package/drizzle/meta/0006_snapshot.json +0 -2751
  54. package/drizzle/meta/0007_snapshot.json +0 -2766
  55. package/drizzle/meta/0008_snapshot.json +0 -2753
  56. package/drizzle/meta/0009_snapshot.json +0 -2744
  57. package/drizzle/meta/0010_snapshot.json +0 -2751
  58. package/drizzle/meta/0011_snapshot.json +0 -2849
  59. package/drizzle/meta/0012_snapshot.json +0 -2985
  60. package/drizzle/meta/0013_snapshot.json +0 -2988
  61. package/drizzle/meta/0014_snapshot.json +0 -2992
@@ -4,7 +4,7 @@ var zod = require('zod');
4
4
  var zodOpenapi = require('@hono/zod-openapi');
5
5
  var drizzleZod = require('drizzle-zod');
6
6
  var drizzleOrm = require('drizzle-orm');
7
- var sqliteCore = require('drizzle-orm/sqlite-core');
7
+ var pgCore = require('drizzle-orm/pg-core');
8
8
  var Ajv = require('ajv');
9
9
  var auth_js = require('@modelcontextprotocol/sdk/client/auth.js');
10
10
 
@@ -14,6 +14,38 @@ var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
14
14
 
15
15
  // src/client-exports.ts
16
16
 
17
+ // src/constants/schema-validation/defaults.ts
18
+ var schemaValidationDefaults = {
19
+ // Agent Execution Transfer Count
20
+ // Controls how many times an agent can transfer control to sub-agents in a single conversation turn.
21
+ // This prevents infinite transfer loops while allowing multi-agent collaboration workflows.
22
+ AGENT_EXECUTION_TRANSFER_COUNT_MIN: 1,
23
+ AGENT_EXECUTION_TRANSFER_COUNT_MAX: 1e3,
24
+ // Sub-Agent Turn Generation Steps
25
+ // Limits how many AI generation steps a sub-agent can perform within a single turn.
26
+ // Each generation step typically involves sending a prompt to the LLM and processing its response.
27
+ // This prevents runaway token usage while allowing complex multi-step reasoning.
28
+ SUB_AGENT_TURN_GENERATION_STEPS_MIN: 1,
29
+ SUB_AGENT_TURN_GENERATION_STEPS_MAX: 1e3,
30
+ // Status Update Thresholds
31
+ // Real-time status updates are triggered when either threshold is exceeded during longer operations.
32
+ // MAX_NUM_EVENTS: Maximum number of internal events before forcing a status update to the client.
33
+ // MAX_INTERVAL_SECONDS: Maximum time between status updates regardless of event count.
34
+ STATUS_UPDATE_MAX_NUM_EVENTS: 100,
35
+ STATUS_UPDATE_MAX_INTERVAL_SECONDS: 600,
36
+ // 10 minutes
37
+ // Prompt Text Length Validation
38
+ // Maximum character limits for agent and sub-agent system prompts to prevent excessive token usage.
39
+ // Enforced during agent configuration to ensure prompts remain focused and manageable.
40
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS: 2e3,
41
+ VALIDATION_AGENT_PROMPT_MAX_CHARS: 5e3,
42
+ // Context Fetcher HTTP Timeout
43
+ // Maximum time allowed for HTTP requests made by Context Fetchers (e.g., CRM lookups, external API calls).
44
+ // Context Fetchers automatically retrieve external data at the start of a conversation to enrich agent context.
45
+ CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT: 1e4
46
+ // 10 seconds
47
+ };
48
+
17
49
  // src/types/utility.ts
18
50
  var TOOL_STATUS_VALUES = ["healthy", "unhealthy", "unknown", "needs_auth"];
19
51
  var VALID_RELATION_TYPES = ["transfer", "delegate"];
@@ -31,165 +63,165 @@ var CredentialStoreType = {
31
63
  nango: "nango"
32
64
  };
33
65
  var tenantScoped = {
34
- tenantId: sqliteCore.text("tenant_id").notNull(),
35
- id: sqliteCore.text("id").notNull()
66
+ tenantId: pgCore.varchar("tenant_id", { length: 256 }).notNull(),
67
+ id: pgCore.varchar("id", { length: 256 }).notNull()
36
68
  };
37
69
  var projectScoped = {
38
70
  ...tenantScoped,
39
- projectId: sqliteCore.text("project_id").notNull()
71
+ projectId: pgCore.varchar("project_id", { length: 256 }).notNull()
40
72
  };
41
73
  var agentScoped = {
42
74
  ...projectScoped,
43
- agentId: sqliteCore.text("agent_id").notNull()
75
+ agentId: pgCore.varchar("agent_id", { length: 256 }).notNull()
44
76
  };
45
77
  var subAgentScoped = {
46
78
  ...agentScoped,
47
- subAgentId: sqliteCore.text("sub_agent_id").notNull()
79
+ subAgentId: pgCore.varchar("sub_agent_id", { length: 256 }).notNull()
48
80
  };
49
81
  var uiProperties = {
50
- name: sqliteCore.text("name").notNull(),
51
- description: sqliteCore.text("description").notNull()
82
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
83
+ description: pgCore.text("description").notNull()
52
84
  };
53
85
  var timestamps = {
54
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
55
- updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
86
+ createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow(),
87
+ updatedAt: pgCore.timestamp("updated_at", { mode: "string" }).notNull().defaultNow()
56
88
  };
57
- var projects = sqliteCore.sqliteTable(
89
+ var projects = pgCore.pgTable(
58
90
  "projects",
59
91
  {
60
92
  ...tenantScoped,
61
93
  ...uiProperties,
62
- models: sqliteCore.text("models", { mode: "json" }).$type(),
63
- stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
94
+ models: pgCore.jsonb("models").$type(),
95
+ stopWhen: pgCore.jsonb("stop_when").$type(),
64
96
  ...timestamps
65
97
  },
66
- (table) => [sqliteCore.primaryKey({ columns: [table.tenantId, table.id] })]
98
+ (table) => [pgCore.primaryKey({ columns: [table.tenantId, table.id] })]
67
99
  );
68
- var agents = sqliteCore.sqliteTable(
100
+ var agents = pgCore.pgTable(
69
101
  "agent",
70
102
  {
71
103
  ...projectScoped,
72
- name: sqliteCore.text("name").notNull(),
73
- description: sqliteCore.text("description"),
74
- defaultSubAgentId: sqliteCore.text("default_sub_agent_id"),
75
- contextConfigId: sqliteCore.text("context_config_id"),
76
- models: sqliteCore.text("models", { mode: "json" }).$type(),
77
- statusUpdates: sqliteCore.text("status_updates", { mode: "json" }).$type(),
78
- prompt: sqliteCore.text("prompt"),
79
- stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
104
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
105
+ description: pgCore.text("description"),
106
+ defaultSubAgentId: pgCore.varchar("default_sub_agent_id", { length: 256 }),
107
+ contextConfigId: pgCore.varchar("context_config_id", { length: 256 }),
108
+ models: pgCore.jsonb("models").$type(),
109
+ statusUpdates: pgCore.jsonb("status_updates").$type(),
110
+ prompt: pgCore.text("prompt"),
111
+ stopWhen: pgCore.jsonb("stop_when").$type(),
80
112
  ...timestamps
81
113
  },
82
114
  (table) => [
83
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
84
- sqliteCore.foreignKey({
115
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
116
+ pgCore.foreignKey({
85
117
  columns: [table.tenantId, table.projectId],
86
118
  foreignColumns: [projects.tenantId, projects.id],
87
119
  name: "agent_project_fk"
88
120
  }).onDelete("cascade")
89
121
  ]
90
122
  );
91
- var contextConfigs = sqliteCore.sqliteTable(
123
+ var contextConfigs = pgCore.pgTable(
92
124
  "context_configs",
93
125
  {
94
126
  ...agentScoped,
95
- headersSchema: sqliteCore.blob("headers_schema", { mode: "json" }).$type(),
96
- contextVariables: sqliteCore.blob("context_variables", { mode: "json" }).$type(),
127
+ headersSchema: pgCore.jsonb("headers_schema").$type(),
128
+ contextVariables: pgCore.jsonb("context_variables").$type(),
97
129
  ...timestamps
98
130
  },
99
131
  (table) => [
100
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
101
- sqliteCore.foreignKey({
132
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
133
+ pgCore.foreignKey({
102
134
  columns: [table.tenantId, table.projectId, table.agentId],
103
135
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
104
136
  name: "context_configs_agent_fk"
105
137
  }).onDelete("cascade")
106
138
  ]
107
139
  );
108
- var contextCache = sqliteCore.sqliteTable(
140
+ var contextCache = pgCore.pgTable(
109
141
  "context_cache",
110
142
  {
111
143
  ...projectScoped,
112
- conversationId: sqliteCore.text("conversation_id").notNull(),
113
- contextConfigId: sqliteCore.text("context_config_id").notNull(),
114
- contextVariableKey: sqliteCore.text("context_variable_key").notNull(),
115
- value: sqliteCore.blob("value", { mode: "json" }).$type().notNull(),
116
- requestHash: sqliteCore.text("request_hash"),
117
- fetchedAt: sqliteCore.text("fetched_at").notNull(),
118
- fetchSource: sqliteCore.text("fetch_source"),
119
- fetchDurationMs: sqliteCore.integer("fetch_duration_ms"),
144
+ conversationId: pgCore.varchar("conversation_id", { length: 256 }).notNull(),
145
+ contextConfigId: pgCore.varchar("context_config_id", { length: 256 }).notNull(),
146
+ contextVariableKey: pgCore.varchar("context_variable_key", { length: 256 }).notNull(),
147
+ value: pgCore.jsonb("value").$type().notNull(),
148
+ requestHash: pgCore.varchar("request_hash", { length: 256 }),
149
+ fetchedAt: pgCore.timestamp("fetched_at", { mode: "string" }).notNull().defaultNow(),
150
+ fetchSource: pgCore.varchar("fetch_source", { length: 256 }),
151
+ fetchDurationMs: pgCore.integer("fetch_duration_ms"),
120
152
  ...timestamps
121
153
  },
122
154
  (table) => [
123
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
124
- sqliteCore.foreignKey({
155
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
156
+ pgCore.foreignKey({
125
157
  columns: [table.tenantId, table.projectId],
126
158
  foreignColumns: [projects.tenantId, projects.id],
127
159
  name: "context_cache_project_fk"
128
160
  }).onDelete("cascade"),
129
- sqliteCore.index("context_cache_lookup_idx").on(
161
+ pgCore.index("context_cache_lookup_idx").on(
130
162
  table.conversationId,
131
163
  table.contextConfigId,
132
164
  table.contextVariableKey
133
165
  )
134
166
  ]
135
167
  );
136
- var subAgents = sqliteCore.sqliteTable(
168
+ var subAgents = pgCore.pgTable(
137
169
  "sub_agents",
138
170
  {
139
171
  ...agentScoped,
140
172
  ...uiProperties,
141
- prompt: sqliteCore.text("prompt").notNull(),
142
- conversationHistoryConfig: sqliteCore.text("conversation_history_config", {
143
- mode: "json"
144
- }).$type(),
145
- models: sqliteCore.text("models", { mode: "json" }).$type(),
146
- stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
173
+ prompt: pgCore.text("prompt").notNull(),
174
+ conversationHistoryConfig: pgCore.jsonb(
175
+ "conversation_history_config"
176
+ ).$type(),
177
+ models: pgCore.jsonb("models").$type(),
178
+ stopWhen: pgCore.jsonb("stop_when").$type(),
147
179
  ...timestamps
148
180
  },
149
181
  (table) => [
150
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
151
- sqliteCore.foreignKey({
182
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
183
+ pgCore.foreignKey({
152
184
  columns: [table.tenantId, table.projectId, table.agentId],
153
185
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
154
186
  name: "sub_agents_agents_fk"
155
187
  }).onDelete("cascade")
156
188
  ]
157
189
  );
158
- var subAgentRelations = sqliteCore.sqliteTable(
190
+ var subAgentRelations = pgCore.pgTable(
159
191
  "sub_agent_relations",
160
192
  {
161
193
  ...agentScoped,
162
- sourceSubAgentId: sqliteCore.text("source_sub_agent_id").notNull(),
163
- targetSubAgentId: sqliteCore.text("target_sub_agent_id"),
164
- relationType: sqliteCore.text("relation_type"),
194
+ sourceSubAgentId: pgCore.varchar("source_sub_agent_id", { length: 256 }).notNull(),
195
+ targetSubAgentId: pgCore.varchar("target_sub_agent_id", { length: 256 }),
196
+ relationType: pgCore.varchar("relation_type", { length: 256 }),
165
197
  ...timestamps
166
198
  },
167
199
  (table) => [
168
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
169
- sqliteCore.foreignKey({
200
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
201
+ pgCore.foreignKey({
170
202
  columns: [table.tenantId, table.projectId, table.agentId],
171
203
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
172
204
  name: "sub_agent_relations_agent_fk"
173
205
  }).onDelete("cascade")
174
206
  ]
175
207
  );
176
- var externalAgents = sqliteCore.sqliteTable(
208
+ var externalAgents = pgCore.pgTable(
177
209
  "external_agents",
178
210
  {
179
211
  ...projectScoped,
180
212
  ...uiProperties,
181
- baseUrl: sqliteCore.text("base_url").notNull(),
182
- credentialReferenceId: sqliteCore.text("credential_reference_id"),
213
+ baseUrl: pgCore.text("base_url").notNull(),
214
+ credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
183
215
  ...timestamps
184
216
  },
185
217
  (table) => [
186
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
187
- sqliteCore.foreignKey({
218
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
219
+ pgCore.foreignKey({
188
220
  columns: [table.tenantId, table.projectId],
189
221
  foreignColumns: [projects.tenantId, projects.id],
190
222
  name: "external_agents_project_fk"
191
223
  }).onDelete("cascade"),
192
- sqliteCore.foreignKey({
224
+ pgCore.foreignKey({
193
225
  columns: [table.tenantId, table.projectId, table.credentialReferenceId],
194
226
  foreignColumns: [
195
227
  credentialReferences.tenantId,
@@ -197,118 +229,118 @@ var externalAgents = sqliteCore.sqliteTable(
197
229
  credentialReferences.id
198
230
  ],
199
231
  name: "external_agents_credential_reference_fk"
200
- }).onDelete("set null")
232
+ }).onDelete("cascade")
201
233
  ]
202
234
  );
203
- var tasks = sqliteCore.sqliteTable(
235
+ var tasks = pgCore.pgTable(
204
236
  "tasks",
205
237
  {
206
238
  ...subAgentScoped,
207
- contextId: sqliteCore.text("context_id").notNull(),
208
- status: sqliteCore.text("status").notNull(),
209
- metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
239
+ contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
240
+ status: pgCore.varchar("status", { length: 256 }).notNull(),
241
+ metadata: pgCore.jsonb("metadata").$type(),
210
242
  ...timestamps
211
243
  },
212
244
  (table) => [
213
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
214
- sqliteCore.foreignKey({
245
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
246
+ pgCore.foreignKey({
215
247
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
216
248
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
217
249
  name: "tasks_sub_agent_fk"
218
250
  }).onDelete("cascade")
219
251
  ]
220
252
  );
221
- var taskRelations = sqliteCore.sqliteTable(
253
+ var taskRelations = pgCore.pgTable(
222
254
  "task_relations",
223
255
  {
224
256
  ...projectScoped,
225
- parentTaskId: sqliteCore.text("parent_task_id").notNull(),
226
- childTaskId: sqliteCore.text("child_task_id").notNull(),
227
- relationType: sqliteCore.text("relation_type").default("parent_child"),
257
+ parentTaskId: pgCore.varchar("parent_task_id", { length: 256 }).notNull(),
258
+ childTaskId: pgCore.varchar("child_task_id", { length: 256 }).notNull(),
259
+ relationType: pgCore.varchar("relation_type", { length: 256 }).default("parent_child"),
228
260
  ...timestamps
229
261
  },
230
262
  (table) => [
231
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
232
- sqliteCore.foreignKey({
263
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
264
+ pgCore.foreignKey({
233
265
  columns: [table.tenantId, table.projectId],
234
266
  foreignColumns: [projects.tenantId, projects.id],
235
267
  name: "task_relations_project_fk"
236
268
  }).onDelete("cascade")
237
269
  ]
238
270
  );
239
- var dataComponents = sqliteCore.sqliteTable(
271
+ var dataComponents = pgCore.pgTable(
240
272
  "data_components",
241
273
  {
242
274
  ...projectScoped,
243
275
  ...uiProperties,
244
- props: sqliteCore.blob("props", { mode: "json" }).$type(),
245
- render: sqliteCore.blob("render", { mode: "json" }).$type(),
276
+ props: pgCore.jsonb("props").$type(),
277
+ render: pgCore.jsonb("render").$type(),
246
278
  ...timestamps
247
279
  },
248
280
  (table) => [
249
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
250
- sqliteCore.foreignKey({
281
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
282
+ pgCore.foreignKey({
251
283
  columns: [table.tenantId, table.projectId],
252
284
  foreignColumns: [projects.tenantId, projects.id],
253
285
  name: "data_components_project_fk"
254
286
  }).onDelete("cascade")
255
287
  ]
256
288
  );
257
- var subAgentDataComponents = sqliteCore.sqliteTable(
289
+ var subAgentDataComponents = pgCore.pgTable(
258
290
  "sub_agent_data_components",
259
291
  {
260
292
  ...subAgentScoped,
261
- dataComponentId: sqliteCore.text("data_component_id").notNull(),
262
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
293
+ dataComponentId: pgCore.varchar("data_component_id", { length: 256 }).notNull(),
294
+ createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
263
295
  },
264
296
  (table) => [
265
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
266
- sqliteCore.foreignKey({
297
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
298
+ pgCore.foreignKey({
267
299
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
268
300
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
269
301
  name: "sub_agent_data_components_sub_agent_fk"
270
302
  }).onDelete("cascade"),
271
- sqliteCore.foreignKey({
303
+ pgCore.foreignKey({
272
304
  columns: [table.tenantId, table.projectId, table.dataComponentId],
273
305
  foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
274
306
  name: "sub_agent_data_components_data_component_fk"
275
307
  }).onDelete("cascade")
276
308
  ]
277
309
  );
278
- var artifactComponents = sqliteCore.sqliteTable(
310
+ var artifactComponents = pgCore.pgTable(
279
311
  "artifact_components",
280
312
  {
281
313
  ...projectScoped,
282
314
  ...uiProperties,
283
- props: sqliteCore.blob("props", { mode: "json" }).$type(),
315
+ props: pgCore.jsonb("props").$type(),
284
316
  ...timestamps
285
317
  },
286
318
  (table) => [
287
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
288
- sqliteCore.foreignKey({
319
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
320
+ pgCore.foreignKey({
289
321
  columns: [table.tenantId, table.projectId],
290
322
  foreignColumns: [projects.tenantId, projects.id],
291
323
  name: "artifact_components_project_fk"
292
324
  }).onDelete("cascade")
293
325
  ]
294
326
  );
295
- var subAgentArtifactComponents = sqliteCore.sqliteTable(
327
+ var subAgentArtifactComponents = pgCore.pgTable(
296
328
  "sub_agent_artifact_components",
297
329
  {
298
330
  ...subAgentScoped,
299
- artifactComponentId: sqliteCore.text("artifact_component_id").notNull(),
300
- createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
331
+ artifactComponentId: pgCore.varchar("artifact_component_id", { length: 256 }).notNull(),
332
+ createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
301
333
  },
302
334
  (table) => [
303
- sqliteCore.primaryKey({
335
+ pgCore.primaryKey({
304
336
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId, table.id]
305
337
  }),
306
- sqliteCore.foreignKey({
338
+ pgCore.foreignKey({
307
339
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
308
340
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
309
341
  name: "sub_agent_artifact_components_sub_agent_fk"
310
342
  }).onDelete("cascade"),
311
- sqliteCore.foreignKey({
343
+ pgCore.foreignKey({
312
344
  columns: [table.tenantId, table.projectId, table.artifactComponentId],
313
345
  foreignColumns: [
314
346
  artifactComponents.tenantId,
@@ -319,152 +351,152 @@ var subAgentArtifactComponents = sqliteCore.sqliteTable(
319
351
  }).onDelete("cascade")
320
352
  ]
321
353
  );
322
- var tools = sqliteCore.sqliteTable(
354
+ var tools = pgCore.pgTable(
323
355
  "tools",
324
356
  {
325
357
  ...projectScoped,
326
- name: sqliteCore.text("name").notNull(),
327
- description: sqliteCore.text("description"),
328
- config: sqliteCore.blob("config", { mode: "json" }).$type().notNull(),
329
- credentialReferenceId: sqliteCore.text("credential_reference_id"),
330
- headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
331
- imageUrl: sqliteCore.text("image_url"),
332
- capabilities: sqliteCore.blob("capabilities", { mode: "json" }).$type(),
333
- lastError: sqliteCore.text("last_error"),
358
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
359
+ description: pgCore.text("description"),
360
+ config: pgCore.jsonb("config").$type().notNull(),
361
+ credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
362
+ headers: pgCore.jsonb("headers").$type(),
363
+ imageUrl: pgCore.text("image_url"),
364
+ capabilities: pgCore.jsonb("capabilities").$type(),
365
+ lastError: pgCore.text("last_error"),
334
366
  ...timestamps
335
367
  },
336
368
  (table) => [
337
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
338
- sqliteCore.foreignKey({
369
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
370
+ pgCore.foreignKey({
339
371
  columns: [table.tenantId, table.projectId],
340
372
  foreignColumns: [projects.tenantId, projects.id],
341
373
  name: "tools_project_fk"
342
374
  }).onDelete("cascade")
343
375
  ]
344
376
  );
345
- var functionTools = sqliteCore.sqliteTable(
377
+ var functionTools = pgCore.pgTable(
346
378
  "function_tools",
347
379
  {
348
380
  ...agentScoped,
349
- name: sqliteCore.text("name").notNull(),
350
- description: sqliteCore.text("description"),
351
- functionId: sqliteCore.text("function_id").notNull(),
381
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
382
+ description: pgCore.text("description"),
383
+ functionId: pgCore.varchar("function_id", { length: 256 }).notNull(),
352
384
  ...timestamps
353
385
  },
354
386
  (table) => [
355
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
356
- sqliteCore.foreignKey({
387
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
388
+ pgCore.foreignKey({
357
389
  columns: [table.tenantId, table.projectId, table.agentId],
358
390
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
359
391
  name: "function_tools_agent_fk"
360
392
  }).onDelete("cascade"),
361
- sqliteCore.foreignKey({
393
+ pgCore.foreignKey({
362
394
  columns: [table.tenantId, table.projectId, table.functionId],
363
395
  foreignColumns: [functions.tenantId, functions.projectId, functions.id],
364
396
  name: "function_tools_function_fk"
365
397
  }).onDelete("cascade")
366
398
  ]
367
399
  );
368
- var functions = sqliteCore.sqliteTable(
400
+ var functions = pgCore.pgTable(
369
401
  "functions",
370
402
  {
371
403
  ...projectScoped,
372
- inputSchema: sqliteCore.blob("input_schema", { mode: "json" }).$type(),
373
- executeCode: sqliteCore.text("execute_code").notNull(),
374
- dependencies: sqliteCore.blob("dependencies", { mode: "json" }).$type(),
404
+ inputSchema: pgCore.jsonb("input_schema").$type(),
405
+ executeCode: pgCore.text("execute_code").notNull(),
406
+ dependencies: pgCore.jsonb("dependencies").$type(),
375
407
  ...timestamps
376
408
  },
377
409
  (table) => [
378
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
379
- sqliteCore.foreignKey({
410
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
411
+ pgCore.foreignKey({
380
412
  columns: [table.tenantId, table.projectId],
381
413
  foreignColumns: [projects.tenantId, projects.id],
382
414
  name: "functions_project_fk"
383
415
  }).onDelete("cascade")
384
416
  ]
385
417
  );
386
- var subAgentToolRelations = sqliteCore.sqliteTable(
418
+ var subAgentToolRelations = pgCore.pgTable(
387
419
  "sub_agent_tool_relations",
388
420
  {
389
421
  ...subAgentScoped,
390
- toolId: sqliteCore.text("tool_id").notNull(),
391
- selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
392
- headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
422
+ toolId: pgCore.varchar("tool_id", { length: 256 }).notNull(),
423
+ selectedTools: pgCore.jsonb("selected_tools").$type(),
424
+ headers: pgCore.jsonb("headers").$type(),
393
425
  ...timestamps
394
426
  },
395
427
  (table) => [
396
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
397
- sqliteCore.foreignKey({
428
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
429
+ pgCore.foreignKey({
398
430
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
399
431
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
400
432
  name: "sub_agent_tool_relations_agent_fk"
401
433
  }).onDelete("cascade"),
402
- sqliteCore.foreignKey({
434
+ pgCore.foreignKey({
403
435
  columns: [table.tenantId, table.projectId, table.toolId],
404
436
  foreignColumns: [tools.tenantId, tools.projectId, tools.id],
405
437
  name: "sub_agent_tool_relations_tool_fk"
406
438
  }).onDelete("cascade")
407
439
  ]
408
440
  );
409
- var subAgentExternalAgentRelations = sqliteCore.sqliteTable(
441
+ var subAgentExternalAgentRelations = pgCore.pgTable(
410
442
  "sub_agent_external_agent_relations",
411
443
  {
412
444
  ...subAgentScoped,
413
- externalAgentId: sqliteCore.text("external_agent_id").notNull(),
414
- headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
445
+ externalAgentId: pgCore.varchar("external_agent_id", { length: 256 }).notNull(),
446
+ headers: pgCore.jsonb("headers").$type(),
415
447
  ...timestamps
416
448
  },
417
449
  (table) => [
418
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
419
- sqliteCore.foreignKey({
450
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
451
+ pgCore.foreignKey({
420
452
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
421
453
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
422
454
  name: "sub_agent_external_agent_relations_sub_agent_fk"
423
455
  }).onDelete("cascade"),
424
- sqliteCore.foreignKey({
456
+ pgCore.foreignKey({
425
457
  columns: [table.tenantId, table.projectId, table.externalAgentId],
426
458
  foreignColumns: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
427
459
  name: "sub_agent_external_agent_relations_external_agent_fk"
428
460
  }).onDelete("cascade")
429
461
  ]
430
462
  );
431
- var subAgentTeamAgentRelations = sqliteCore.sqliteTable(
463
+ var subAgentTeamAgentRelations = pgCore.pgTable(
432
464
  "sub_agent_team_agent_relations",
433
465
  {
434
466
  ...subAgentScoped,
435
- targetAgentId: sqliteCore.text("target_agent_id").notNull(),
436
- headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
467
+ targetAgentId: pgCore.varchar("target_agent_id", { length: 256 }).notNull(),
468
+ headers: pgCore.jsonb("headers").$type(),
437
469
  ...timestamps
438
470
  },
439
471
  (table) => [
440
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
441
- sqliteCore.foreignKey({
472
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
473
+ pgCore.foreignKey({
442
474
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
443
475
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
444
476
  name: "sub_agent_team_agent_relations_sub_agent_fk"
445
477
  }).onDelete("cascade"),
446
- sqliteCore.foreignKey({
478
+ pgCore.foreignKey({
447
479
  columns: [table.tenantId, table.projectId, table.targetAgentId],
448
480
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
449
481
  name: "sub_agent_team_agent_relations_target_agent_fk"
450
482
  }).onDelete("cascade")
451
483
  ]
452
484
  );
453
- var subAgentFunctionToolRelations = sqliteCore.sqliteTable(
485
+ var subAgentFunctionToolRelations = pgCore.pgTable(
454
486
  "sub_agent_function_tool_relations",
455
487
  {
456
488
  ...subAgentScoped,
457
- functionToolId: sqliteCore.text("function_tool_id").notNull(),
489
+ functionToolId: pgCore.varchar("function_tool_id", { length: 256 }).notNull(),
458
490
  ...timestamps
459
491
  },
460
492
  (table) => [
461
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
462
- sqliteCore.foreignKey({
493
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
494
+ pgCore.foreignKey({
463
495
  columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
464
496
  foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
465
497
  name: "sub_agent_function_tool_relations_sub_agent_fk"
466
498
  }).onDelete("cascade"),
467
- sqliteCore.foreignKey({
499
+ pgCore.foreignKey({
468
500
  columns: [table.tenantId, table.projectId, table.agentId, table.functionToolId],
469
501
  foreignColumns: [
470
502
  functionTools.tenantId,
@@ -476,134 +508,134 @@ var subAgentFunctionToolRelations = sqliteCore.sqliteTable(
476
508
  }).onDelete("cascade")
477
509
  ]
478
510
  );
479
- var conversations = sqliteCore.sqliteTable(
511
+ var conversations = pgCore.pgTable(
480
512
  "conversations",
481
513
  {
482
514
  ...projectScoped,
483
- userId: sqliteCore.text("user_id"),
484
- activeSubAgentId: sqliteCore.text("active_sub_agent_id").notNull(),
485
- title: sqliteCore.text("title"),
486
- lastContextResolution: sqliteCore.text("last_context_resolution"),
487
- metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
515
+ userId: pgCore.varchar("user_id", { length: 256 }),
516
+ activeSubAgentId: pgCore.varchar("active_sub_agent_id", { length: 256 }).notNull(),
517
+ title: pgCore.text("title"),
518
+ lastContextResolution: pgCore.timestamp("last_context_resolution", { mode: "string" }),
519
+ metadata: pgCore.jsonb("metadata").$type(),
488
520
  ...timestamps
489
521
  },
490
522
  (table) => [
491
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
492
- sqliteCore.foreignKey({
523
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
524
+ pgCore.foreignKey({
493
525
  columns: [table.tenantId, table.projectId],
494
526
  foreignColumns: [projects.tenantId, projects.id],
495
527
  name: "conversations_project_fk"
496
528
  }).onDelete("cascade")
497
529
  ]
498
530
  );
499
- var messages = sqliteCore.sqliteTable(
531
+ var messages = pgCore.pgTable(
500
532
  "messages",
501
533
  {
502
534
  ...projectScoped,
503
- conversationId: sqliteCore.text("conversation_id").notNull(),
504
- role: sqliteCore.text("role").notNull(),
505
- fromSubAgentId: sqliteCore.text("from_sub_agent_id"),
506
- toSubAgentId: sqliteCore.text("to_sub_agent_id"),
507
- fromExternalAgentId: sqliteCore.text("from_external_sub_agent_id"),
508
- toExternalAgentId: sqliteCore.text("to_external_sub_agent_id"),
509
- fromTeamAgentId: sqliteCore.text("from_team_agent_id"),
510
- toTeamAgentId: sqliteCore.text("to_team_agent_id"),
511
- content: sqliteCore.blob("content", { mode: "json" }).$type().notNull(),
512
- visibility: sqliteCore.text("visibility").notNull().default("user-facing"),
513
- messageType: sqliteCore.text("message_type").notNull().default("chat"),
514
- taskId: sqliteCore.text("task_id"),
515
- parentMessageId: sqliteCore.text("parent_message_id"),
516
- a2aTaskId: sqliteCore.text("a2a_task_id"),
517
- a2aSessionId: sqliteCore.text("a2a_session_id"),
518
- metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
535
+ conversationId: pgCore.varchar("conversation_id", { length: 256 }).notNull(),
536
+ role: pgCore.varchar("role", { length: 256 }).notNull(),
537
+ fromSubAgentId: pgCore.varchar("from_sub_agent_id", { length: 256 }),
538
+ toSubAgentId: pgCore.varchar("to_sub_agent_id", { length: 256 }),
539
+ fromExternalAgentId: pgCore.varchar("from_external_sub_agent_id", { length: 256 }),
540
+ toExternalAgentId: pgCore.varchar("to_external_sub_agent_id", { length: 256 }),
541
+ fromTeamAgentId: pgCore.varchar("from_team_agent_id", { length: 256 }),
542
+ toTeamAgentId: pgCore.varchar("to_team_agent_id", { length: 256 }),
543
+ content: pgCore.jsonb("content").$type().notNull(),
544
+ visibility: pgCore.varchar("visibility", { length: 256 }).notNull().default("user-facing"),
545
+ messageType: pgCore.varchar("message_type", { length: 256 }).notNull().default("chat"),
546
+ taskId: pgCore.varchar("task_id", { length: 256 }),
547
+ parentMessageId: pgCore.varchar("parent_message_id", { length: 256 }),
548
+ a2aTaskId: pgCore.varchar("a2a_task_id", { length: 256 }),
549
+ a2aSessionId: pgCore.varchar("a2a_session_id", { length: 256 }),
550
+ metadata: pgCore.jsonb("metadata").$type(),
519
551
  ...timestamps
520
552
  },
521
553
  (table) => [
522
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
523
- sqliteCore.foreignKey({
554
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
555
+ pgCore.foreignKey({
524
556
  columns: [table.tenantId, table.projectId],
525
557
  foreignColumns: [projects.tenantId, projects.id],
526
558
  name: "messages_project_fk"
527
559
  }).onDelete("cascade")
528
560
  ]
529
561
  );
530
- var ledgerArtifacts = sqliteCore.sqliteTable(
562
+ var ledgerArtifacts = pgCore.pgTable(
531
563
  "ledger_artifacts",
532
564
  {
533
565
  ...projectScoped,
534
- taskId: sqliteCore.text("task_id").notNull(),
535
- toolCallId: sqliteCore.text("tool_call_id"),
536
- contextId: sqliteCore.text("context_id").notNull(),
537
- type: sqliteCore.text("type").notNull().default("source"),
538
- name: sqliteCore.text("name"),
539
- description: sqliteCore.text("description"),
540
- parts: sqliteCore.blob("parts", { mode: "json" }).$type(),
541
- metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
542
- summary: sqliteCore.text("summary"),
543
- mime: sqliteCore.blob("mime", { mode: "json" }).$type(),
544
- visibility: sqliteCore.text("visibility").default("context"),
545
- allowedAgents: sqliteCore.blob("allowed_agents", { mode: "json" }).$type(),
546
- derivedFrom: sqliteCore.text("derived_from"),
566
+ taskId: pgCore.varchar("task_id", { length: 256 }).notNull(),
567
+ toolCallId: pgCore.varchar("tool_call_id", { length: 256 }),
568
+ contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
569
+ type: pgCore.varchar("type", { length: 256 }).notNull().default("source"),
570
+ name: pgCore.varchar("name", { length: 256 }),
571
+ description: pgCore.text("description"),
572
+ parts: pgCore.jsonb("parts").$type(),
573
+ metadata: pgCore.jsonb("metadata").$type(),
574
+ summary: pgCore.text("summary"),
575
+ mime: pgCore.jsonb("mime").$type(),
576
+ visibility: pgCore.varchar("visibility", { length: 256 }).default("context"),
577
+ allowedAgents: pgCore.jsonb("allowed_agents").$type(),
578
+ derivedFrom: pgCore.varchar("derived_from", { length: 256 }),
547
579
  ...timestamps
548
580
  },
549
581
  (table) => [
550
- sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
551
- sqliteCore.foreignKey({
582
+ pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
583
+ pgCore.foreignKey({
552
584
  columns: [table.tenantId, table.projectId],
553
585
  foreignColumns: [projects.tenantId, projects.id],
554
586
  name: "ledger_artifacts_project_fk"
555
587
  }).onDelete("cascade"),
556
- sqliteCore.index("ledger_artifacts_task_id_idx").on(table.taskId),
557
- sqliteCore.index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
558
- sqliteCore.index("ledger_artifacts_context_id_idx").on(table.contextId),
559
- sqliteCore.unique("ledger_artifacts_task_context_name_unique").on(
588
+ pgCore.index("ledger_artifacts_task_id_idx").on(table.taskId),
589
+ pgCore.index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
590
+ pgCore.index("ledger_artifacts_context_id_idx").on(table.contextId),
591
+ pgCore.unique("ledger_artifacts_task_context_name_unique").on(
560
592
  table.taskId,
561
593
  table.contextId,
562
594
  table.name
563
595
  )
564
596
  ]
565
597
  );
566
- var apiKeys = sqliteCore.sqliteTable(
598
+ var apiKeys = pgCore.pgTable(
567
599
  "api_keys",
568
600
  {
569
601
  ...agentScoped,
570
- publicId: sqliteCore.text("public_id").notNull().unique(),
571
- keyHash: sqliteCore.text("key_hash").notNull(),
572
- keyPrefix: sqliteCore.text("key_prefix").notNull(),
573
- name: sqliteCore.text("name"),
574
- lastUsedAt: sqliteCore.text("last_used_at"),
575
- expiresAt: sqliteCore.text("expires_at"),
602
+ publicId: pgCore.varchar("public_id", { length: 256 }).notNull().unique(),
603
+ keyHash: pgCore.varchar("key_hash", { length: 256 }).notNull(),
604
+ keyPrefix: pgCore.varchar("key_prefix", { length: 256 }).notNull(),
605
+ name: pgCore.varchar("name", { length: 256 }),
606
+ lastUsedAt: pgCore.timestamp("last_used_at", { mode: "string" }),
607
+ expiresAt: pgCore.timestamp("expires_at", { mode: "string" }),
576
608
  ...timestamps
577
609
  },
578
610
  (t) => [
579
- sqliteCore.foreignKey({
611
+ pgCore.foreignKey({
580
612
  columns: [t.tenantId, t.projectId],
581
613
  foreignColumns: [projects.tenantId, projects.id],
582
614
  name: "api_keys_project_fk"
583
615
  }).onDelete("cascade"),
584
- sqliteCore.foreignKey({
616
+ pgCore.foreignKey({
585
617
  columns: [t.tenantId, t.projectId, t.agentId],
586
618
  foreignColumns: [agents.tenantId, agents.projectId, agents.id],
587
619
  name: "api_keys_agent_fk"
588
620
  }).onDelete("cascade"),
589
- sqliteCore.index("api_keys_tenant_agent_idx").on(t.tenantId, t.agentId),
590
- sqliteCore.index("api_keys_prefix_idx").on(t.keyPrefix),
591
- sqliteCore.index("api_keys_public_id_idx").on(t.publicId)
621
+ pgCore.index("api_keys_tenant_agent_idx").on(t.tenantId, t.agentId),
622
+ pgCore.index("api_keys_prefix_idx").on(t.keyPrefix),
623
+ pgCore.index("api_keys_public_id_idx").on(t.publicId)
592
624
  ]
593
625
  );
594
- var credentialReferences = sqliteCore.sqliteTable(
626
+ var credentialReferences = pgCore.pgTable(
595
627
  "credential_references",
596
628
  {
597
629
  ...projectScoped,
598
- name: sqliteCore.text("name").notNull(),
599
- type: sqliteCore.text("type").notNull(),
600
- credentialStoreId: sqliteCore.text("credential_store_id").notNull(),
601
- retrievalParams: sqliteCore.blob("retrieval_params", { mode: "json" }).$type(),
630
+ name: pgCore.varchar("name", { length: 256 }).notNull(),
631
+ type: pgCore.varchar("type", { length: 256 }).notNull(),
632
+ credentialStoreId: pgCore.varchar("credential_store_id", { length: 256 }).notNull(),
633
+ retrievalParams: pgCore.jsonb("retrieval_params").$type(),
602
634
  ...timestamps
603
635
  },
604
636
  (t) => [
605
- sqliteCore.primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
606
- sqliteCore.foreignKey({
637
+ pgCore.primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
638
+ pgCore.foreignKey({
607
639
  columns: [t.tenantId, t.projectId],
608
640
  foreignColumns: [projects.tenantId, projects.id],
609
641
  name: "credential_references_project_fk"
@@ -962,9 +994,20 @@ drizzleOrm.relations(
962
994
  );
963
995
 
964
996
  // src/validation/schemas.ts
997
+ var {
998
+ AGENT_EXECUTION_TRANSFER_COUNT_MAX,
999
+ AGENT_EXECUTION_TRANSFER_COUNT_MIN,
1000
+ CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT,
1001
+ STATUS_UPDATE_MAX_INTERVAL_SECONDS,
1002
+ STATUS_UPDATE_MAX_NUM_EVENTS,
1003
+ SUB_AGENT_TURN_GENERATION_STEPS_MAX,
1004
+ SUB_AGENT_TURN_GENERATION_STEPS_MIN,
1005
+ VALIDATION_AGENT_PROMPT_MAX_CHARS,
1006
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS
1007
+ } = schemaValidationDefaults;
965
1008
  var StopWhenSchema = zodOpenapi.z.object({
966
- transferCountIs: zodOpenapi.z.number().min(1).max(100).optional().describe("The maximum number of transfers to trigger the stop condition."),
967
- stepCountIs: zodOpenapi.z.number().min(1).max(1e3).optional().describe("The maximum number of steps to trigger the stop condition.")
1009
+ transferCountIs: zodOpenapi.z.number().min(AGENT_EXECUTION_TRANSFER_COUNT_MIN).max(AGENT_EXECUTION_TRANSFER_COUNT_MAX).optional().describe("The maximum number of transfers to trigger the stop condition."),
1010
+ stepCountIs: zodOpenapi.z.number().min(SUB_AGENT_TURN_GENERATION_STEPS_MIN).max(SUB_AGENT_TURN_GENERATION_STEPS_MAX).optional().describe("The maximum number of steps to trigger the stop condition.")
968
1011
  }).openapi("StopWhen");
969
1012
  var AgentStopWhenSchema = StopWhenSchema.pick({ transferCountIs: true }).openapi(
970
1013
  "AgentStopWhen"
@@ -1083,7 +1126,8 @@ createApiInsertSchema(
1083
1126
  );
1084
1127
  var AgentSelectSchema = drizzleZod.createSelectSchema(agents);
1085
1128
  var AgentInsertSchema = drizzleZod.createInsertSchema(agents).extend({
1086
- id: resourceIdSchema
1129
+ id: resourceIdSchema,
1130
+ name: zodOpenapi.z.string().trim().nonempty()
1087
1131
  });
1088
1132
  var AgentUpdateSchema = AgentInsertSchema.partial();
1089
1133
  var AgentApiSelectSchema = createApiSchema(AgentSelectSchema).openapi("Agent");
@@ -1443,7 +1487,7 @@ var FetchConfigSchema = zodOpenapi.z.object({
1443
1487
  body: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
1444
1488
  transform: zodOpenapi.z.string().optional(),
1445
1489
  // JSONPath or JS transform function
1446
- timeout: zodOpenapi.z.number().min(0).optional().default(1e4).optional()
1490
+ timeout: zodOpenapi.z.number().min(0).optional().default(CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT).optional()
1447
1491
  }).openapi("FetchConfig");
1448
1492
  zodOpenapi.z.object({
1449
1493
  id: zodOpenapi.z.string().min(1, "Fetch definition ID is required"),
@@ -1562,9 +1606,12 @@ var StatusComponentSchema = zodOpenapi.z.object({
1562
1606
  }).openapi("StatusComponent");
1563
1607
  var StatusUpdateSchema = zodOpenapi.z.object({
1564
1608
  enabled: zodOpenapi.z.boolean().optional(),
1565
- numEvents: zodOpenapi.z.number().min(1).max(100).optional(),
1566
- timeInSeconds: zodOpenapi.z.number().min(1).max(600).optional(),
1567
- prompt: zodOpenapi.z.string().max(2e3, "Custom prompt cannot exceed 2000 characters").optional(),
1609
+ numEvents: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_NUM_EVENTS).optional(),
1610
+ timeInSeconds: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_INTERVAL_SECONDS).optional(),
1611
+ prompt: zodOpenapi.z.string().max(
1612
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS,
1613
+ `Custom prompt cannot exceed ${VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS} characters`
1614
+ ).optional(),
1568
1615
  statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
1569
1616
  }).openapi("StatusUpdate");
1570
1617
  var CanUseItemSchema = zodOpenapi.z.object({
@@ -1595,6 +1642,7 @@ var FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
1595
1642
  dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1596
1643
  artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1597
1644
  canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
1645
+ prompt: zodOpenapi.z.string().trim().nonempty(),
1598
1646
  canDelegateTo: zodOpenapi.z.array(
1599
1647
  zodOpenapi.z.union([
1600
1648
  zodOpenapi.z.string(),
@@ -1623,7 +1671,10 @@ var AgentWithinContextOfProjectSchema = AgentApiInsertSchema.extend({
1623
1671
  statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
1624
1672
  models: ModelSchema.optional(),
1625
1673
  stopWhen: AgentStopWhenSchema.optional(),
1626
- prompt: zodOpenapi.z.string().max(5e3, "Agent prompt cannot exceed 5000 characters").optional()
1674
+ prompt: zodOpenapi.z.string().max(
1675
+ VALIDATION_AGENT_PROMPT_MAX_CHARS,
1676
+ `Agent prompt cannot exceed ${VALIDATION_AGENT_PROMPT_MAX_CHARS} characters`
1677
+ ).optional()
1627
1678
  });
1628
1679
  var PaginationSchema = zodOpenapi.z.object({
1629
1680
  page: zodOpenapi.z.coerce.number().min(1).default(1),
@@ -2268,6 +2319,14 @@ var detectAuthenticationRequired = async ({
2268
2319
  };
2269
2320
 
2270
2321
  // src/client-exports.ts
2322
+ var {
2323
+ AGENT_EXECUTION_TRANSFER_COUNT_MAX: AGENT_EXECUTION_TRANSFER_COUNT_MAX2,
2324
+ AGENT_EXECUTION_TRANSFER_COUNT_MIN: AGENT_EXECUTION_TRANSFER_COUNT_MIN2,
2325
+ STATUS_UPDATE_MAX_INTERVAL_SECONDS: STATUS_UPDATE_MAX_INTERVAL_SECONDS2,
2326
+ STATUS_UPDATE_MAX_NUM_EVENTS: STATUS_UPDATE_MAX_NUM_EVENTS2,
2327
+ VALIDATION_AGENT_PROMPT_MAX_CHARS: VALIDATION_AGENT_PROMPT_MAX_CHARS2,
2328
+ VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS: VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS2
2329
+ } = schemaValidationDefaults;
2271
2330
  var TenantParamsSchema2 = zod.z.object({
2272
2331
  tenantId: zod.z.string()
2273
2332
  });
@@ -2399,14 +2458,14 @@ var FullAgentDefinitionSchema = AgentAgentApiInsertSchema.extend({
2399
2458
  }).optional()
2400
2459
  }).optional(),
2401
2460
  stopWhen: zod.z.object({
2402
- transferCountIs: zod.z.number().min(1).max(100).optional()
2461
+ transferCountIs: zod.z.number().min(AGENT_EXECUTION_TRANSFER_COUNT_MIN2).max(AGENT_EXECUTION_TRANSFER_COUNT_MAX2).optional()
2403
2462
  }).optional(),
2404
- prompt: zod.z.string().max(5e3).optional(),
2463
+ prompt: zod.z.string().max(VALIDATION_AGENT_PROMPT_MAX_CHARS2).optional(),
2405
2464
  statusUpdates: zod.z.object({
2406
2465
  enabled: zod.z.boolean().optional(),
2407
- numEvents: zod.z.number().min(1).max(100).optional(),
2408
- timeInSeconds: zod.z.number().min(1).max(600).optional(),
2409
- prompt: zod.z.string().max(2e3).optional(),
2466
+ numEvents: zod.z.number().min(1).max(STATUS_UPDATE_MAX_NUM_EVENTS2).optional(),
2467
+ timeInSeconds: zod.z.number().min(1).max(STATUS_UPDATE_MAX_INTERVAL_SECONDS2).optional(),
2468
+ prompt: zod.z.string().max(VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS2).optional(),
2410
2469
  statusComponents: zod.z.array(
2411
2470
  zod.z.object({
2412
2471
  type: zod.z.string(),