@inkeep/agents-core 0.31.6 → 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.
- package/dist/{chunk-RBUBOGX6.js → chunk-FUJJ4OQ2.js} +62 -10
- package/dist/chunk-SVXWB2HF.js +592 -0
- package/dist/{chunk-T5TTDZ6L.js → chunk-VSQY72K5.js} +133 -133
- package/dist/{chunk-PPBBIDK4.js → chunk-X6ZMJ3G6.js} +1 -1
- package/dist/client-exports.cjs +283 -224
- package/dist/client-exports.d.cts +4 -4
- package/dist/client-exports.d.ts +4 -4
- package/dist/client-exports.js +15 -7
- package/dist/db/schema.cjs +211 -211
- package/dist/db/schema.d.cts +3 -3
- package/dist/db/schema.d.ts +3 -3
- package/dist/db/schema.js +1 -1
- package/dist/index.cjs +18511 -12300
- package/dist/index.d.cts +161 -104
- package/dist/index.d.ts +161 -104
- package/dist/index.js +16250 -11076
- package/dist/nodefs-X2JO4ZHZ.js +21 -0
- package/dist/opfs-ahp-2UFDGV73.js +318 -0
- package/dist/{schema-BiVwgjkS.d.ts → schema-CuEjPQt7.d.ts} +876 -1014
- package/dist/{schema-DcDuYlEP.d.cts → schema-D1P8r3qm.d.cts} +876 -1014
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/{utility-DNsYIxBh.d.cts → utility-DF5IUC9K.d.cts} +967 -1131
- package/dist/{utility-DNsYIxBh.d.ts → utility-DF5IUC9K.d.ts} +967 -1131
- package/dist/validation/index.cjs +270 -219
- package/dist/validation/index.d.cts +3 -3
- package/dist/validation/index.d.ts +3 -3
- package/dist/validation/index.js +2 -2
- package/drizzle/0000_exotic_mysterio.sql +398 -0
- package/drizzle/meta/0000_snapshot.json +1683 -1223
- package/drizzle/meta/_journal.json +4 -102
- package/package.json +6 -3
- package/drizzle/0000_material_menace.sql +0 -326
- package/drizzle/0001_eminent_fixer.sql +0 -43
- package/drizzle/0002_bumpy_romulus.sql +0 -3
- package/drizzle/0003_soft_forgotten_one.sql +0 -39
- package/drizzle/0004_melted_omega_flight.sql +0 -3
- package/drizzle/0005_wide_shriek.sql +0 -127
- package/drizzle/0006_damp_lenny_balinger.sql +0 -52
- package/drizzle/0007_mighty_typhoid_mary.sql +0 -227
- package/drizzle/0008_mysterious_crusher_hogan.sql +0 -20
- package/drizzle/0009_old_black_cat.sql +0 -1
- package/drizzle/0010_wet_vampiro.sql +0 -2
- package/drizzle/0011_slippery_korg.sql +0 -36
- package/drizzle/0012_salty_psynapse.sql +0 -17
- package/drizzle/0013_shocking_blur.sql +0 -19
- package/drizzle/0014_broad_hellfire_club.sql +0 -29
- package/drizzle/meta/0001_snapshot.json +0 -2435
- package/drizzle/meta/0002_snapshot.json +0 -2428
- package/drizzle/meta/0003_snapshot.json +0 -2559
- package/drizzle/meta/0004_snapshot.json +0 -2547
- package/drizzle/meta/0005_snapshot.json +0 -2558
- package/drizzle/meta/0006_snapshot.json +0 -2751
- package/drizzle/meta/0007_snapshot.json +0 -2766
- package/drizzle/meta/0008_snapshot.json +0 -2753
- package/drizzle/meta/0009_snapshot.json +0 -2744
- package/drizzle/meta/0010_snapshot.json +0 -2751
- package/drizzle/meta/0011_snapshot.json +0 -2849
- package/drizzle/meta/0012_snapshot.json +0 -2985
- package/drizzle/meta/0013_snapshot.json +0 -2988
- package/drizzle/meta/0014_snapshot.json +0 -2992
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var zodOpenapi = require('@hono/zod-openapi');
|
|
4
4
|
var drizzleZod = require('drizzle-zod');
|
|
5
5
|
var drizzleOrm = require('drizzle-orm');
|
|
6
|
-
var
|
|
6
|
+
var pgCore = require('drizzle-orm/pg-core');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
var Ajv = require('ajv');
|
|
9
9
|
|
|
@@ -55,166 +55,198 @@ function buildDelegationGraph(agentData) {
|
|
|
55
55
|
}
|
|
56
56
|
return graph;
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
// src/constants/schema-validation/defaults.ts
|
|
60
|
+
var schemaValidationDefaults = {
|
|
61
|
+
// Agent Execution Transfer Count
|
|
62
|
+
// Controls how many times an agent can transfer control to sub-agents in a single conversation turn.
|
|
63
|
+
// This prevents infinite transfer loops while allowing multi-agent collaboration workflows.
|
|
64
|
+
AGENT_EXECUTION_TRANSFER_COUNT_MIN: 1,
|
|
65
|
+
AGENT_EXECUTION_TRANSFER_COUNT_MAX: 1e3,
|
|
66
|
+
// Sub-Agent Turn Generation Steps
|
|
67
|
+
// Limits how many AI generation steps a sub-agent can perform within a single turn.
|
|
68
|
+
// Each generation step typically involves sending a prompt to the LLM and processing its response.
|
|
69
|
+
// This prevents runaway token usage while allowing complex multi-step reasoning.
|
|
70
|
+
SUB_AGENT_TURN_GENERATION_STEPS_MIN: 1,
|
|
71
|
+
SUB_AGENT_TURN_GENERATION_STEPS_MAX: 1e3,
|
|
72
|
+
// Status Update Thresholds
|
|
73
|
+
// Real-time status updates are triggered when either threshold is exceeded during longer operations.
|
|
74
|
+
// MAX_NUM_EVENTS: Maximum number of internal events before forcing a status update to the client.
|
|
75
|
+
// MAX_INTERVAL_SECONDS: Maximum time between status updates regardless of event count.
|
|
76
|
+
STATUS_UPDATE_MAX_NUM_EVENTS: 100,
|
|
77
|
+
STATUS_UPDATE_MAX_INTERVAL_SECONDS: 600,
|
|
78
|
+
// 10 minutes
|
|
79
|
+
// Prompt Text Length Validation
|
|
80
|
+
// Maximum character limits for agent and sub-agent system prompts to prevent excessive token usage.
|
|
81
|
+
// Enforced during agent configuration to ensure prompts remain focused and manageable.
|
|
82
|
+
VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS: 2e3,
|
|
83
|
+
VALIDATION_AGENT_PROMPT_MAX_CHARS: 5e3,
|
|
84
|
+
// Context Fetcher HTTP Timeout
|
|
85
|
+
// Maximum time allowed for HTTP requests made by Context Fetchers (e.g., CRM lookups, external API calls).
|
|
86
|
+
// Context Fetchers automatically retrieve external data at the start of a conversation to enrich agent context.
|
|
87
|
+
CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT: 1e4
|
|
88
|
+
// 10 seconds
|
|
89
|
+
};
|
|
58
90
|
var tenantScoped = {
|
|
59
|
-
tenantId:
|
|
60
|
-
id:
|
|
91
|
+
tenantId: pgCore.varchar("tenant_id", { length: 256 }).notNull(),
|
|
92
|
+
id: pgCore.varchar("id", { length: 256 }).notNull()
|
|
61
93
|
};
|
|
62
94
|
var projectScoped = {
|
|
63
95
|
...tenantScoped,
|
|
64
|
-
projectId:
|
|
96
|
+
projectId: pgCore.varchar("project_id", { length: 256 }).notNull()
|
|
65
97
|
};
|
|
66
98
|
var agentScoped = {
|
|
67
99
|
...projectScoped,
|
|
68
|
-
agentId:
|
|
100
|
+
agentId: pgCore.varchar("agent_id", { length: 256 }).notNull()
|
|
69
101
|
};
|
|
70
102
|
var subAgentScoped = {
|
|
71
103
|
...agentScoped,
|
|
72
|
-
subAgentId:
|
|
104
|
+
subAgentId: pgCore.varchar("sub_agent_id", { length: 256 }).notNull()
|
|
73
105
|
};
|
|
74
106
|
var uiProperties = {
|
|
75
|
-
name:
|
|
76
|
-
description:
|
|
107
|
+
name: pgCore.varchar("name", { length: 256 }).notNull(),
|
|
108
|
+
description: pgCore.text("description").notNull()
|
|
77
109
|
};
|
|
78
110
|
var timestamps = {
|
|
79
|
-
createdAt:
|
|
80
|
-
updatedAt:
|
|
111
|
+
createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow(),
|
|
112
|
+
updatedAt: pgCore.timestamp("updated_at", { mode: "string" }).notNull().defaultNow()
|
|
81
113
|
};
|
|
82
|
-
var projects =
|
|
114
|
+
var projects = pgCore.pgTable(
|
|
83
115
|
"projects",
|
|
84
116
|
{
|
|
85
117
|
...tenantScoped,
|
|
86
118
|
...uiProperties,
|
|
87
|
-
models:
|
|
88
|
-
stopWhen:
|
|
119
|
+
models: pgCore.jsonb("models").$type(),
|
|
120
|
+
stopWhen: pgCore.jsonb("stop_when").$type(),
|
|
89
121
|
...timestamps
|
|
90
122
|
},
|
|
91
|
-
(table) => [
|
|
123
|
+
(table) => [pgCore.primaryKey({ columns: [table.tenantId, table.id] })]
|
|
92
124
|
);
|
|
93
|
-
var agents =
|
|
125
|
+
var agents = pgCore.pgTable(
|
|
94
126
|
"agent",
|
|
95
127
|
{
|
|
96
128
|
...projectScoped,
|
|
97
|
-
name:
|
|
98
|
-
description:
|
|
99
|
-
defaultSubAgentId:
|
|
100
|
-
contextConfigId:
|
|
101
|
-
models:
|
|
102
|
-
statusUpdates:
|
|
103
|
-
prompt:
|
|
104
|
-
stopWhen:
|
|
129
|
+
name: pgCore.varchar("name", { length: 256 }).notNull(),
|
|
130
|
+
description: pgCore.text("description"),
|
|
131
|
+
defaultSubAgentId: pgCore.varchar("default_sub_agent_id", { length: 256 }),
|
|
132
|
+
contextConfigId: pgCore.varchar("context_config_id", { length: 256 }),
|
|
133
|
+
models: pgCore.jsonb("models").$type(),
|
|
134
|
+
statusUpdates: pgCore.jsonb("status_updates").$type(),
|
|
135
|
+
prompt: pgCore.text("prompt"),
|
|
136
|
+
stopWhen: pgCore.jsonb("stop_when").$type(),
|
|
105
137
|
...timestamps
|
|
106
138
|
},
|
|
107
139
|
(table) => [
|
|
108
|
-
|
|
109
|
-
|
|
140
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
141
|
+
pgCore.foreignKey({
|
|
110
142
|
columns: [table.tenantId, table.projectId],
|
|
111
143
|
foreignColumns: [projects.tenantId, projects.id],
|
|
112
144
|
name: "agent_project_fk"
|
|
113
145
|
}).onDelete("cascade")
|
|
114
146
|
]
|
|
115
147
|
);
|
|
116
|
-
var contextConfigs =
|
|
148
|
+
var contextConfigs = pgCore.pgTable(
|
|
117
149
|
"context_configs",
|
|
118
150
|
{
|
|
119
151
|
...agentScoped,
|
|
120
|
-
headersSchema:
|
|
121
|
-
contextVariables:
|
|
152
|
+
headersSchema: pgCore.jsonb("headers_schema").$type(),
|
|
153
|
+
contextVariables: pgCore.jsonb("context_variables").$type(),
|
|
122
154
|
...timestamps
|
|
123
155
|
},
|
|
124
156
|
(table) => [
|
|
125
|
-
|
|
126
|
-
|
|
157
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
158
|
+
pgCore.foreignKey({
|
|
127
159
|
columns: [table.tenantId, table.projectId, table.agentId],
|
|
128
160
|
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
129
161
|
name: "context_configs_agent_fk"
|
|
130
162
|
}).onDelete("cascade")
|
|
131
163
|
]
|
|
132
164
|
);
|
|
133
|
-
var contextCache =
|
|
165
|
+
var contextCache = pgCore.pgTable(
|
|
134
166
|
"context_cache",
|
|
135
167
|
{
|
|
136
168
|
...projectScoped,
|
|
137
|
-
conversationId:
|
|
138
|
-
contextConfigId:
|
|
139
|
-
contextVariableKey:
|
|
140
|
-
value:
|
|
141
|
-
requestHash:
|
|
142
|
-
fetchedAt:
|
|
143
|
-
fetchSource:
|
|
144
|
-
fetchDurationMs:
|
|
169
|
+
conversationId: pgCore.varchar("conversation_id", { length: 256 }).notNull(),
|
|
170
|
+
contextConfigId: pgCore.varchar("context_config_id", { length: 256 }).notNull(),
|
|
171
|
+
contextVariableKey: pgCore.varchar("context_variable_key", { length: 256 }).notNull(),
|
|
172
|
+
value: pgCore.jsonb("value").$type().notNull(),
|
|
173
|
+
requestHash: pgCore.varchar("request_hash", { length: 256 }),
|
|
174
|
+
fetchedAt: pgCore.timestamp("fetched_at", { mode: "string" }).notNull().defaultNow(),
|
|
175
|
+
fetchSource: pgCore.varchar("fetch_source", { length: 256 }),
|
|
176
|
+
fetchDurationMs: pgCore.integer("fetch_duration_ms"),
|
|
145
177
|
...timestamps
|
|
146
178
|
},
|
|
147
179
|
(table) => [
|
|
148
|
-
|
|
149
|
-
|
|
180
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
181
|
+
pgCore.foreignKey({
|
|
150
182
|
columns: [table.tenantId, table.projectId],
|
|
151
183
|
foreignColumns: [projects.tenantId, projects.id],
|
|
152
184
|
name: "context_cache_project_fk"
|
|
153
185
|
}).onDelete("cascade"),
|
|
154
|
-
|
|
186
|
+
pgCore.index("context_cache_lookup_idx").on(
|
|
155
187
|
table.conversationId,
|
|
156
188
|
table.contextConfigId,
|
|
157
189
|
table.contextVariableKey
|
|
158
190
|
)
|
|
159
191
|
]
|
|
160
192
|
);
|
|
161
|
-
var subAgents =
|
|
193
|
+
var subAgents = pgCore.pgTable(
|
|
162
194
|
"sub_agents",
|
|
163
195
|
{
|
|
164
196
|
...agentScoped,
|
|
165
197
|
...uiProperties,
|
|
166
|
-
prompt:
|
|
167
|
-
conversationHistoryConfig:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
models:
|
|
171
|
-
stopWhen:
|
|
198
|
+
prompt: pgCore.text("prompt").notNull(),
|
|
199
|
+
conversationHistoryConfig: pgCore.jsonb(
|
|
200
|
+
"conversation_history_config"
|
|
201
|
+
).$type(),
|
|
202
|
+
models: pgCore.jsonb("models").$type(),
|
|
203
|
+
stopWhen: pgCore.jsonb("stop_when").$type(),
|
|
172
204
|
...timestamps
|
|
173
205
|
},
|
|
174
206
|
(table) => [
|
|
175
|
-
|
|
176
|
-
|
|
207
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
208
|
+
pgCore.foreignKey({
|
|
177
209
|
columns: [table.tenantId, table.projectId, table.agentId],
|
|
178
210
|
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
179
211
|
name: "sub_agents_agents_fk"
|
|
180
212
|
}).onDelete("cascade")
|
|
181
213
|
]
|
|
182
214
|
);
|
|
183
|
-
var subAgentRelations =
|
|
215
|
+
var subAgentRelations = pgCore.pgTable(
|
|
184
216
|
"sub_agent_relations",
|
|
185
217
|
{
|
|
186
218
|
...agentScoped,
|
|
187
|
-
sourceSubAgentId:
|
|
188
|
-
targetSubAgentId:
|
|
189
|
-
relationType:
|
|
219
|
+
sourceSubAgentId: pgCore.varchar("source_sub_agent_id", { length: 256 }).notNull(),
|
|
220
|
+
targetSubAgentId: pgCore.varchar("target_sub_agent_id", { length: 256 }),
|
|
221
|
+
relationType: pgCore.varchar("relation_type", { length: 256 }),
|
|
190
222
|
...timestamps
|
|
191
223
|
},
|
|
192
224
|
(table) => [
|
|
193
|
-
|
|
194
|
-
|
|
225
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
226
|
+
pgCore.foreignKey({
|
|
195
227
|
columns: [table.tenantId, table.projectId, table.agentId],
|
|
196
228
|
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
197
229
|
name: "sub_agent_relations_agent_fk"
|
|
198
230
|
}).onDelete("cascade")
|
|
199
231
|
]
|
|
200
232
|
);
|
|
201
|
-
var externalAgents =
|
|
233
|
+
var externalAgents = pgCore.pgTable(
|
|
202
234
|
"external_agents",
|
|
203
235
|
{
|
|
204
236
|
...projectScoped,
|
|
205
237
|
...uiProperties,
|
|
206
|
-
baseUrl:
|
|
207
|
-
credentialReferenceId:
|
|
238
|
+
baseUrl: pgCore.text("base_url").notNull(),
|
|
239
|
+
credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
|
|
208
240
|
...timestamps
|
|
209
241
|
},
|
|
210
242
|
(table) => [
|
|
211
|
-
|
|
212
|
-
|
|
243
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
244
|
+
pgCore.foreignKey({
|
|
213
245
|
columns: [table.tenantId, table.projectId],
|
|
214
246
|
foreignColumns: [projects.tenantId, projects.id],
|
|
215
247
|
name: "external_agents_project_fk"
|
|
216
248
|
}).onDelete("cascade"),
|
|
217
|
-
|
|
249
|
+
pgCore.foreignKey({
|
|
218
250
|
columns: [table.tenantId, table.projectId, table.credentialReferenceId],
|
|
219
251
|
foreignColumns: [
|
|
220
252
|
credentialReferences.tenantId,
|
|
@@ -222,118 +254,118 @@ var externalAgents = sqliteCore.sqliteTable(
|
|
|
222
254
|
credentialReferences.id
|
|
223
255
|
],
|
|
224
256
|
name: "external_agents_credential_reference_fk"
|
|
225
|
-
}).onDelete("
|
|
257
|
+
}).onDelete("cascade")
|
|
226
258
|
]
|
|
227
259
|
);
|
|
228
|
-
var tasks =
|
|
260
|
+
var tasks = pgCore.pgTable(
|
|
229
261
|
"tasks",
|
|
230
262
|
{
|
|
231
263
|
...subAgentScoped,
|
|
232
|
-
contextId:
|
|
233
|
-
status:
|
|
234
|
-
metadata:
|
|
264
|
+
contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
|
|
265
|
+
status: pgCore.varchar("status", { length: 256 }).notNull(),
|
|
266
|
+
metadata: pgCore.jsonb("metadata").$type(),
|
|
235
267
|
...timestamps
|
|
236
268
|
},
|
|
237
269
|
(table) => [
|
|
238
|
-
|
|
239
|
-
|
|
270
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
271
|
+
pgCore.foreignKey({
|
|
240
272
|
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
241
273
|
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
242
274
|
name: "tasks_sub_agent_fk"
|
|
243
275
|
}).onDelete("cascade")
|
|
244
276
|
]
|
|
245
277
|
);
|
|
246
|
-
var taskRelations =
|
|
278
|
+
var taskRelations = pgCore.pgTable(
|
|
247
279
|
"task_relations",
|
|
248
280
|
{
|
|
249
281
|
...projectScoped,
|
|
250
|
-
parentTaskId:
|
|
251
|
-
childTaskId:
|
|
252
|
-
relationType:
|
|
282
|
+
parentTaskId: pgCore.varchar("parent_task_id", { length: 256 }).notNull(),
|
|
283
|
+
childTaskId: pgCore.varchar("child_task_id", { length: 256 }).notNull(),
|
|
284
|
+
relationType: pgCore.varchar("relation_type", { length: 256 }).default("parent_child"),
|
|
253
285
|
...timestamps
|
|
254
286
|
},
|
|
255
287
|
(table) => [
|
|
256
|
-
|
|
257
|
-
|
|
288
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
289
|
+
pgCore.foreignKey({
|
|
258
290
|
columns: [table.tenantId, table.projectId],
|
|
259
291
|
foreignColumns: [projects.tenantId, projects.id],
|
|
260
292
|
name: "task_relations_project_fk"
|
|
261
293
|
}).onDelete("cascade")
|
|
262
294
|
]
|
|
263
295
|
);
|
|
264
|
-
var dataComponents =
|
|
296
|
+
var dataComponents = pgCore.pgTable(
|
|
265
297
|
"data_components",
|
|
266
298
|
{
|
|
267
299
|
...projectScoped,
|
|
268
300
|
...uiProperties,
|
|
269
|
-
props:
|
|
270
|
-
render:
|
|
301
|
+
props: pgCore.jsonb("props").$type(),
|
|
302
|
+
render: pgCore.jsonb("render").$type(),
|
|
271
303
|
...timestamps
|
|
272
304
|
},
|
|
273
305
|
(table) => [
|
|
274
|
-
|
|
275
|
-
|
|
306
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
307
|
+
pgCore.foreignKey({
|
|
276
308
|
columns: [table.tenantId, table.projectId],
|
|
277
309
|
foreignColumns: [projects.tenantId, projects.id],
|
|
278
310
|
name: "data_components_project_fk"
|
|
279
311
|
}).onDelete("cascade")
|
|
280
312
|
]
|
|
281
313
|
);
|
|
282
|
-
var subAgentDataComponents =
|
|
314
|
+
var subAgentDataComponents = pgCore.pgTable(
|
|
283
315
|
"sub_agent_data_components",
|
|
284
316
|
{
|
|
285
317
|
...subAgentScoped,
|
|
286
|
-
dataComponentId:
|
|
287
|
-
createdAt:
|
|
318
|
+
dataComponentId: pgCore.varchar("data_component_id", { length: 256 }).notNull(),
|
|
319
|
+
createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
|
|
288
320
|
},
|
|
289
321
|
(table) => [
|
|
290
|
-
|
|
291
|
-
|
|
322
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
323
|
+
pgCore.foreignKey({
|
|
292
324
|
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
293
325
|
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
294
326
|
name: "sub_agent_data_components_sub_agent_fk"
|
|
295
327
|
}).onDelete("cascade"),
|
|
296
|
-
|
|
328
|
+
pgCore.foreignKey({
|
|
297
329
|
columns: [table.tenantId, table.projectId, table.dataComponentId],
|
|
298
330
|
foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
|
|
299
331
|
name: "sub_agent_data_components_data_component_fk"
|
|
300
332
|
}).onDelete("cascade")
|
|
301
333
|
]
|
|
302
334
|
);
|
|
303
|
-
var artifactComponents =
|
|
335
|
+
var artifactComponents = pgCore.pgTable(
|
|
304
336
|
"artifact_components",
|
|
305
337
|
{
|
|
306
338
|
...projectScoped,
|
|
307
339
|
...uiProperties,
|
|
308
|
-
props:
|
|
340
|
+
props: pgCore.jsonb("props").$type(),
|
|
309
341
|
...timestamps
|
|
310
342
|
},
|
|
311
343
|
(table) => [
|
|
312
|
-
|
|
313
|
-
|
|
344
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
345
|
+
pgCore.foreignKey({
|
|
314
346
|
columns: [table.tenantId, table.projectId],
|
|
315
347
|
foreignColumns: [projects.tenantId, projects.id],
|
|
316
348
|
name: "artifact_components_project_fk"
|
|
317
349
|
}).onDelete("cascade")
|
|
318
350
|
]
|
|
319
351
|
);
|
|
320
|
-
var subAgentArtifactComponents =
|
|
352
|
+
var subAgentArtifactComponents = pgCore.pgTable(
|
|
321
353
|
"sub_agent_artifact_components",
|
|
322
354
|
{
|
|
323
355
|
...subAgentScoped,
|
|
324
|
-
artifactComponentId:
|
|
325
|
-
createdAt:
|
|
356
|
+
artifactComponentId: pgCore.varchar("artifact_component_id", { length: 256 }).notNull(),
|
|
357
|
+
createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
|
|
326
358
|
},
|
|
327
359
|
(table) => [
|
|
328
|
-
|
|
360
|
+
pgCore.primaryKey({
|
|
329
361
|
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId, table.id]
|
|
330
362
|
}),
|
|
331
|
-
|
|
363
|
+
pgCore.foreignKey({
|
|
332
364
|
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
333
365
|
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
334
366
|
name: "sub_agent_artifact_components_sub_agent_fk"
|
|
335
367
|
}).onDelete("cascade"),
|
|
336
|
-
|
|
368
|
+
pgCore.foreignKey({
|
|
337
369
|
columns: [table.tenantId, table.projectId, table.artifactComponentId],
|
|
338
370
|
foreignColumns: [
|
|
339
371
|
artifactComponents.tenantId,
|
|
@@ -344,152 +376,152 @@ var subAgentArtifactComponents = sqliteCore.sqliteTable(
|
|
|
344
376
|
}).onDelete("cascade")
|
|
345
377
|
]
|
|
346
378
|
);
|
|
347
|
-
var tools =
|
|
379
|
+
var tools = pgCore.pgTable(
|
|
348
380
|
"tools",
|
|
349
381
|
{
|
|
350
382
|
...projectScoped,
|
|
351
|
-
name:
|
|
352
|
-
description:
|
|
353
|
-
config:
|
|
354
|
-
credentialReferenceId:
|
|
355
|
-
headers:
|
|
356
|
-
imageUrl:
|
|
357
|
-
capabilities:
|
|
358
|
-
lastError:
|
|
383
|
+
name: pgCore.varchar("name", { length: 256 }).notNull(),
|
|
384
|
+
description: pgCore.text("description"),
|
|
385
|
+
config: pgCore.jsonb("config").$type().notNull(),
|
|
386
|
+
credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
|
|
387
|
+
headers: pgCore.jsonb("headers").$type(),
|
|
388
|
+
imageUrl: pgCore.text("image_url"),
|
|
389
|
+
capabilities: pgCore.jsonb("capabilities").$type(),
|
|
390
|
+
lastError: pgCore.text("last_error"),
|
|
359
391
|
...timestamps
|
|
360
392
|
},
|
|
361
393
|
(table) => [
|
|
362
|
-
|
|
363
|
-
|
|
394
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
395
|
+
pgCore.foreignKey({
|
|
364
396
|
columns: [table.tenantId, table.projectId],
|
|
365
397
|
foreignColumns: [projects.tenantId, projects.id],
|
|
366
398
|
name: "tools_project_fk"
|
|
367
399
|
}).onDelete("cascade")
|
|
368
400
|
]
|
|
369
401
|
);
|
|
370
|
-
var functionTools =
|
|
402
|
+
var functionTools = pgCore.pgTable(
|
|
371
403
|
"function_tools",
|
|
372
404
|
{
|
|
373
405
|
...agentScoped,
|
|
374
|
-
name:
|
|
375
|
-
description:
|
|
376
|
-
functionId:
|
|
406
|
+
name: pgCore.varchar("name", { length: 256 }).notNull(),
|
|
407
|
+
description: pgCore.text("description"),
|
|
408
|
+
functionId: pgCore.varchar("function_id", { length: 256 }).notNull(),
|
|
377
409
|
...timestamps
|
|
378
410
|
},
|
|
379
411
|
(table) => [
|
|
380
|
-
|
|
381
|
-
|
|
412
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
413
|
+
pgCore.foreignKey({
|
|
382
414
|
columns: [table.tenantId, table.projectId, table.agentId],
|
|
383
415
|
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
384
416
|
name: "function_tools_agent_fk"
|
|
385
417
|
}).onDelete("cascade"),
|
|
386
|
-
|
|
418
|
+
pgCore.foreignKey({
|
|
387
419
|
columns: [table.tenantId, table.projectId, table.functionId],
|
|
388
420
|
foreignColumns: [functions.tenantId, functions.projectId, functions.id],
|
|
389
421
|
name: "function_tools_function_fk"
|
|
390
422
|
}).onDelete("cascade")
|
|
391
423
|
]
|
|
392
424
|
);
|
|
393
|
-
var functions =
|
|
425
|
+
var functions = pgCore.pgTable(
|
|
394
426
|
"functions",
|
|
395
427
|
{
|
|
396
428
|
...projectScoped,
|
|
397
|
-
inputSchema:
|
|
398
|
-
executeCode:
|
|
399
|
-
dependencies:
|
|
429
|
+
inputSchema: pgCore.jsonb("input_schema").$type(),
|
|
430
|
+
executeCode: pgCore.text("execute_code").notNull(),
|
|
431
|
+
dependencies: pgCore.jsonb("dependencies").$type(),
|
|
400
432
|
...timestamps
|
|
401
433
|
},
|
|
402
434
|
(table) => [
|
|
403
|
-
|
|
404
|
-
|
|
435
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
436
|
+
pgCore.foreignKey({
|
|
405
437
|
columns: [table.tenantId, table.projectId],
|
|
406
438
|
foreignColumns: [projects.tenantId, projects.id],
|
|
407
439
|
name: "functions_project_fk"
|
|
408
440
|
}).onDelete("cascade")
|
|
409
441
|
]
|
|
410
442
|
);
|
|
411
|
-
var subAgentToolRelations =
|
|
443
|
+
var subAgentToolRelations = pgCore.pgTable(
|
|
412
444
|
"sub_agent_tool_relations",
|
|
413
445
|
{
|
|
414
446
|
...subAgentScoped,
|
|
415
|
-
toolId:
|
|
416
|
-
selectedTools:
|
|
417
|
-
headers:
|
|
447
|
+
toolId: pgCore.varchar("tool_id", { length: 256 }).notNull(),
|
|
448
|
+
selectedTools: pgCore.jsonb("selected_tools").$type(),
|
|
449
|
+
headers: pgCore.jsonb("headers").$type(),
|
|
418
450
|
...timestamps
|
|
419
451
|
},
|
|
420
452
|
(table) => [
|
|
421
|
-
|
|
422
|
-
|
|
453
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
454
|
+
pgCore.foreignKey({
|
|
423
455
|
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
424
456
|
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
425
457
|
name: "sub_agent_tool_relations_agent_fk"
|
|
426
458
|
}).onDelete("cascade"),
|
|
427
|
-
|
|
459
|
+
pgCore.foreignKey({
|
|
428
460
|
columns: [table.tenantId, table.projectId, table.toolId],
|
|
429
461
|
foreignColumns: [tools.tenantId, tools.projectId, tools.id],
|
|
430
462
|
name: "sub_agent_tool_relations_tool_fk"
|
|
431
463
|
}).onDelete("cascade")
|
|
432
464
|
]
|
|
433
465
|
);
|
|
434
|
-
var subAgentExternalAgentRelations =
|
|
466
|
+
var subAgentExternalAgentRelations = pgCore.pgTable(
|
|
435
467
|
"sub_agent_external_agent_relations",
|
|
436
468
|
{
|
|
437
469
|
...subAgentScoped,
|
|
438
|
-
externalAgentId:
|
|
439
|
-
headers:
|
|
470
|
+
externalAgentId: pgCore.varchar("external_agent_id", { length: 256 }).notNull(),
|
|
471
|
+
headers: pgCore.jsonb("headers").$type(),
|
|
440
472
|
...timestamps
|
|
441
473
|
},
|
|
442
474
|
(table) => [
|
|
443
|
-
|
|
444
|
-
|
|
475
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
476
|
+
pgCore.foreignKey({
|
|
445
477
|
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
446
478
|
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
447
479
|
name: "sub_agent_external_agent_relations_sub_agent_fk"
|
|
448
480
|
}).onDelete("cascade"),
|
|
449
|
-
|
|
481
|
+
pgCore.foreignKey({
|
|
450
482
|
columns: [table.tenantId, table.projectId, table.externalAgentId],
|
|
451
483
|
foreignColumns: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
|
|
452
484
|
name: "sub_agent_external_agent_relations_external_agent_fk"
|
|
453
485
|
}).onDelete("cascade")
|
|
454
486
|
]
|
|
455
487
|
);
|
|
456
|
-
var subAgentTeamAgentRelations =
|
|
488
|
+
var subAgentTeamAgentRelations = pgCore.pgTable(
|
|
457
489
|
"sub_agent_team_agent_relations",
|
|
458
490
|
{
|
|
459
491
|
...subAgentScoped,
|
|
460
|
-
targetAgentId:
|
|
461
|
-
headers:
|
|
492
|
+
targetAgentId: pgCore.varchar("target_agent_id", { length: 256 }).notNull(),
|
|
493
|
+
headers: pgCore.jsonb("headers").$type(),
|
|
462
494
|
...timestamps
|
|
463
495
|
},
|
|
464
496
|
(table) => [
|
|
465
|
-
|
|
466
|
-
|
|
497
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
498
|
+
pgCore.foreignKey({
|
|
467
499
|
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
468
500
|
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
469
501
|
name: "sub_agent_team_agent_relations_sub_agent_fk"
|
|
470
502
|
}).onDelete("cascade"),
|
|
471
|
-
|
|
503
|
+
pgCore.foreignKey({
|
|
472
504
|
columns: [table.tenantId, table.projectId, table.targetAgentId],
|
|
473
505
|
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
474
506
|
name: "sub_agent_team_agent_relations_target_agent_fk"
|
|
475
507
|
}).onDelete("cascade")
|
|
476
508
|
]
|
|
477
509
|
);
|
|
478
|
-
var subAgentFunctionToolRelations =
|
|
510
|
+
var subAgentFunctionToolRelations = pgCore.pgTable(
|
|
479
511
|
"sub_agent_function_tool_relations",
|
|
480
512
|
{
|
|
481
513
|
...subAgentScoped,
|
|
482
|
-
functionToolId:
|
|
514
|
+
functionToolId: pgCore.varchar("function_tool_id", { length: 256 }).notNull(),
|
|
483
515
|
...timestamps
|
|
484
516
|
},
|
|
485
517
|
(table) => [
|
|
486
|
-
|
|
487
|
-
|
|
518
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
519
|
+
pgCore.foreignKey({
|
|
488
520
|
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
489
521
|
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
490
522
|
name: "sub_agent_function_tool_relations_sub_agent_fk"
|
|
491
523
|
}).onDelete("cascade"),
|
|
492
|
-
|
|
524
|
+
pgCore.foreignKey({
|
|
493
525
|
columns: [table.tenantId, table.projectId, table.agentId, table.functionToolId],
|
|
494
526
|
foreignColumns: [
|
|
495
527
|
functionTools.tenantId,
|
|
@@ -501,134 +533,134 @@ var subAgentFunctionToolRelations = sqliteCore.sqliteTable(
|
|
|
501
533
|
}).onDelete("cascade")
|
|
502
534
|
]
|
|
503
535
|
);
|
|
504
|
-
var conversations =
|
|
536
|
+
var conversations = pgCore.pgTable(
|
|
505
537
|
"conversations",
|
|
506
538
|
{
|
|
507
539
|
...projectScoped,
|
|
508
|
-
userId:
|
|
509
|
-
activeSubAgentId:
|
|
510
|
-
title:
|
|
511
|
-
lastContextResolution:
|
|
512
|
-
metadata:
|
|
540
|
+
userId: pgCore.varchar("user_id", { length: 256 }),
|
|
541
|
+
activeSubAgentId: pgCore.varchar("active_sub_agent_id", { length: 256 }).notNull(),
|
|
542
|
+
title: pgCore.text("title"),
|
|
543
|
+
lastContextResolution: pgCore.timestamp("last_context_resolution", { mode: "string" }),
|
|
544
|
+
metadata: pgCore.jsonb("metadata").$type(),
|
|
513
545
|
...timestamps
|
|
514
546
|
},
|
|
515
547
|
(table) => [
|
|
516
|
-
|
|
517
|
-
|
|
548
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
549
|
+
pgCore.foreignKey({
|
|
518
550
|
columns: [table.tenantId, table.projectId],
|
|
519
551
|
foreignColumns: [projects.tenantId, projects.id],
|
|
520
552
|
name: "conversations_project_fk"
|
|
521
553
|
}).onDelete("cascade")
|
|
522
554
|
]
|
|
523
555
|
);
|
|
524
|
-
var messages =
|
|
556
|
+
var messages = pgCore.pgTable(
|
|
525
557
|
"messages",
|
|
526
558
|
{
|
|
527
559
|
...projectScoped,
|
|
528
|
-
conversationId:
|
|
529
|
-
role:
|
|
530
|
-
fromSubAgentId:
|
|
531
|
-
toSubAgentId:
|
|
532
|
-
fromExternalAgentId:
|
|
533
|
-
toExternalAgentId:
|
|
534
|
-
fromTeamAgentId:
|
|
535
|
-
toTeamAgentId:
|
|
536
|
-
content:
|
|
537
|
-
visibility:
|
|
538
|
-
messageType:
|
|
539
|
-
taskId:
|
|
540
|
-
parentMessageId:
|
|
541
|
-
a2aTaskId:
|
|
542
|
-
a2aSessionId:
|
|
543
|
-
metadata:
|
|
560
|
+
conversationId: pgCore.varchar("conversation_id", { length: 256 }).notNull(),
|
|
561
|
+
role: pgCore.varchar("role", { length: 256 }).notNull(),
|
|
562
|
+
fromSubAgentId: pgCore.varchar("from_sub_agent_id", { length: 256 }),
|
|
563
|
+
toSubAgentId: pgCore.varchar("to_sub_agent_id", { length: 256 }),
|
|
564
|
+
fromExternalAgentId: pgCore.varchar("from_external_sub_agent_id", { length: 256 }),
|
|
565
|
+
toExternalAgentId: pgCore.varchar("to_external_sub_agent_id", { length: 256 }),
|
|
566
|
+
fromTeamAgentId: pgCore.varchar("from_team_agent_id", { length: 256 }),
|
|
567
|
+
toTeamAgentId: pgCore.varchar("to_team_agent_id", { length: 256 }),
|
|
568
|
+
content: pgCore.jsonb("content").$type().notNull(),
|
|
569
|
+
visibility: pgCore.varchar("visibility", { length: 256 }).notNull().default("user-facing"),
|
|
570
|
+
messageType: pgCore.varchar("message_type", { length: 256 }).notNull().default("chat"),
|
|
571
|
+
taskId: pgCore.varchar("task_id", { length: 256 }),
|
|
572
|
+
parentMessageId: pgCore.varchar("parent_message_id", { length: 256 }),
|
|
573
|
+
a2aTaskId: pgCore.varchar("a2a_task_id", { length: 256 }),
|
|
574
|
+
a2aSessionId: pgCore.varchar("a2a_session_id", { length: 256 }),
|
|
575
|
+
metadata: pgCore.jsonb("metadata").$type(),
|
|
544
576
|
...timestamps
|
|
545
577
|
},
|
|
546
578
|
(table) => [
|
|
547
|
-
|
|
548
|
-
|
|
579
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
580
|
+
pgCore.foreignKey({
|
|
549
581
|
columns: [table.tenantId, table.projectId],
|
|
550
582
|
foreignColumns: [projects.tenantId, projects.id],
|
|
551
583
|
name: "messages_project_fk"
|
|
552
584
|
}).onDelete("cascade")
|
|
553
585
|
]
|
|
554
586
|
);
|
|
555
|
-
var ledgerArtifacts =
|
|
587
|
+
var ledgerArtifacts = pgCore.pgTable(
|
|
556
588
|
"ledger_artifacts",
|
|
557
589
|
{
|
|
558
590
|
...projectScoped,
|
|
559
|
-
taskId:
|
|
560
|
-
toolCallId:
|
|
561
|
-
contextId:
|
|
562
|
-
type:
|
|
563
|
-
name:
|
|
564
|
-
description:
|
|
565
|
-
parts:
|
|
566
|
-
metadata:
|
|
567
|
-
summary:
|
|
568
|
-
mime:
|
|
569
|
-
visibility:
|
|
570
|
-
allowedAgents:
|
|
571
|
-
derivedFrom:
|
|
591
|
+
taskId: pgCore.varchar("task_id", { length: 256 }).notNull(),
|
|
592
|
+
toolCallId: pgCore.varchar("tool_call_id", { length: 256 }),
|
|
593
|
+
contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
|
|
594
|
+
type: pgCore.varchar("type", { length: 256 }).notNull().default("source"),
|
|
595
|
+
name: pgCore.varchar("name", { length: 256 }),
|
|
596
|
+
description: pgCore.text("description"),
|
|
597
|
+
parts: pgCore.jsonb("parts").$type(),
|
|
598
|
+
metadata: pgCore.jsonb("metadata").$type(),
|
|
599
|
+
summary: pgCore.text("summary"),
|
|
600
|
+
mime: pgCore.jsonb("mime").$type(),
|
|
601
|
+
visibility: pgCore.varchar("visibility", { length: 256 }).default("context"),
|
|
602
|
+
allowedAgents: pgCore.jsonb("allowed_agents").$type(),
|
|
603
|
+
derivedFrom: pgCore.varchar("derived_from", { length: 256 }),
|
|
572
604
|
...timestamps
|
|
573
605
|
},
|
|
574
606
|
(table) => [
|
|
575
|
-
|
|
576
|
-
|
|
607
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
|
|
608
|
+
pgCore.foreignKey({
|
|
577
609
|
columns: [table.tenantId, table.projectId],
|
|
578
610
|
foreignColumns: [projects.tenantId, projects.id],
|
|
579
611
|
name: "ledger_artifacts_project_fk"
|
|
580
612
|
}).onDelete("cascade"),
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
613
|
+
pgCore.index("ledger_artifacts_task_id_idx").on(table.taskId),
|
|
614
|
+
pgCore.index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
|
|
615
|
+
pgCore.index("ledger_artifacts_context_id_idx").on(table.contextId),
|
|
616
|
+
pgCore.unique("ledger_artifacts_task_context_name_unique").on(
|
|
585
617
|
table.taskId,
|
|
586
618
|
table.contextId,
|
|
587
619
|
table.name
|
|
588
620
|
)
|
|
589
621
|
]
|
|
590
622
|
);
|
|
591
|
-
var apiKeys =
|
|
623
|
+
var apiKeys = pgCore.pgTable(
|
|
592
624
|
"api_keys",
|
|
593
625
|
{
|
|
594
626
|
...agentScoped,
|
|
595
|
-
publicId:
|
|
596
|
-
keyHash:
|
|
597
|
-
keyPrefix:
|
|
598
|
-
name:
|
|
599
|
-
lastUsedAt:
|
|
600
|
-
expiresAt:
|
|
627
|
+
publicId: pgCore.varchar("public_id", { length: 256 }).notNull().unique(),
|
|
628
|
+
keyHash: pgCore.varchar("key_hash", { length: 256 }).notNull(),
|
|
629
|
+
keyPrefix: pgCore.varchar("key_prefix", { length: 256 }).notNull(),
|
|
630
|
+
name: pgCore.varchar("name", { length: 256 }),
|
|
631
|
+
lastUsedAt: pgCore.timestamp("last_used_at", { mode: "string" }),
|
|
632
|
+
expiresAt: pgCore.timestamp("expires_at", { mode: "string" }),
|
|
601
633
|
...timestamps
|
|
602
634
|
},
|
|
603
635
|
(t) => [
|
|
604
|
-
|
|
636
|
+
pgCore.foreignKey({
|
|
605
637
|
columns: [t.tenantId, t.projectId],
|
|
606
638
|
foreignColumns: [projects.tenantId, projects.id],
|
|
607
639
|
name: "api_keys_project_fk"
|
|
608
640
|
}).onDelete("cascade"),
|
|
609
|
-
|
|
641
|
+
pgCore.foreignKey({
|
|
610
642
|
columns: [t.tenantId, t.projectId, t.agentId],
|
|
611
643
|
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
612
644
|
name: "api_keys_agent_fk"
|
|
613
645
|
}).onDelete("cascade"),
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
646
|
+
pgCore.index("api_keys_tenant_agent_idx").on(t.tenantId, t.agentId),
|
|
647
|
+
pgCore.index("api_keys_prefix_idx").on(t.keyPrefix),
|
|
648
|
+
pgCore.index("api_keys_public_id_idx").on(t.publicId)
|
|
617
649
|
]
|
|
618
650
|
);
|
|
619
|
-
var credentialReferences =
|
|
651
|
+
var credentialReferences = pgCore.pgTable(
|
|
620
652
|
"credential_references",
|
|
621
653
|
{
|
|
622
654
|
...projectScoped,
|
|
623
|
-
name:
|
|
624
|
-
type:
|
|
625
|
-
credentialStoreId:
|
|
626
|
-
retrievalParams:
|
|
655
|
+
name: pgCore.varchar("name", { length: 256 }).notNull(),
|
|
656
|
+
type: pgCore.varchar("type", { length: 256 }).notNull(),
|
|
657
|
+
credentialStoreId: pgCore.varchar("credential_store_id", { length: 256 }).notNull(),
|
|
658
|
+
retrievalParams: pgCore.jsonb("retrieval_params").$type(),
|
|
627
659
|
...timestamps
|
|
628
660
|
},
|
|
629
661
|
(t) => [
|
|
630
|
-
|
|
631
|
-
|
|
662
|
+
pgCore.primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
|
|
663
|
+
pgCore.foreignKey({
|
|
632
664
|
columns: [t.tenantId, t.projectId],
|
|
633
665
|
foreignColumns: [projects.tenantId, projects.id],
|
|
634
666
|
name: "credential_references_project_fk"
|
|
@@ -1004,9 +1036,20 @@ var CredentialStoreType = {
|
|
|
1004
1036
|
};
|
|
1005
1037
|
|
|
1006
1038
|
// src/validation/schemas.ts
|
|
1039
|
+
var {
|
|
1040
|
+
AGENT_EXECUTION_TRANSFER_COUNT_MAX,
|
|
1041
|
+
AGENT_EXECUTION_TRANSFER_COUNT_MIN,
|
|
1042
|
+
CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT,
|
|
1043
|
+
STATUS_UPDATE_MAX_INTERVAL_SECONDS,
|
|
1044
|
+
STATUS_UPDATE_MAX_NUM_EVENTS,
|
|
1045
|
+
SUB_AGENT_TURN_GENERATION_STEPS_MAX,
|
|
1046
|
+
SUB_AGENT_TURN_GENERATION_STEPS_MIN,
|
|
1047
|
+
VALIDATION_AGENT_PROMPT_MAX_CHARS,
|
|
1048
|
+
VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS
|
|
1049
|
+
} = schemaValidationDefaults;
|
|
1007
1050
|
var StopWhenSchema = zodOpenapi.z.object({
|
|
1008
|
-
transferCountIs: zodOpenapi.z.number().min(
|
|
1009
|
-
stepCountIs: zodOpenapi.z.number().min(
|
|
1051
|
+
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."),
|
|
1052
|
+
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.")
|
|
1010
1053
|
}).openapi("StopWhen");
|
|
1011
1054
|
var AgentStopWhenSchema = StopWhenSchema.pick({ transferCountIs: true }).openapi(
|
|
1012
1055
|
"AgentStopWhen"
|
|
@@ -1125,7 +1168,8 @@ var ExternalSubAgentRelationApiInsertSchema = createApiInsertSchema(
|
|
|
1125
1168
|
);
|
|
1126
1169
|
var AgentSelectSchema = drizzleZod.createSelectSchema(agents);
|
|
1127
1170
|
var AgentInsertSchema = drizzleZod.createInsertSchema(agents).extend({
|
|
1128
|
-
id: resourceIdSchema
|
|
1171
|
+
id: resourceIdSchema,
|
|
1172
|
+
name: zodOpenapi.z.string().trim().nonempty()
|
|
1129
1173
|
});
|
|
1130
1174
|
var AgentUpdateSchema = AgentInsertSchema.partial();
|
|
1131
1175
|
var AgentApiSelectSchema = createApiSchema(AgentSelectSchema).openapi("Agent");
|
|
@@ -1485,7 +1529,7 @@ var FetchConfigSchema = zodOpenapi.z.object({
|
|
|
1485
1529
|
body: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
1486
1530
|
transform: zodOpenapi.z.string().optional(),
|
|
1487
1531
|
// JSONPath or JS transform function
|
|
1488
|
-
timeout: zodOpenapi.z.number().min(0).optional().default(
|
|
1532
|
+
timeout: zodOpenapi.z.number().min(0).optional().default(CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT).optional()
|
|
1489
1533
|
}).openapi("FetchConfig");
|
|
1490
1534
|
var FetchDefinitionSchema = zodOpenapi.z.object({
|
|
1491
1535
|
id: zodOpenapi.z.string().min(1, "Fetch definition ID is required"),
|
|
@@ -1604,9 +1648,12 @@ var StatusComponentSchema = zodOpenapi.z.object({
|
|
|
1604
1648
|
}).openapi("StatusComponent");
|
|
1605
1649
|
var StatusUpdateSchema = zodOpenapi.z.object({
|
|
1606
1650
|
enabled: zodOpenapi.z.boolean().optional(),
|
|
1607
|
-
numEvents: zodOpenapi.z.number().min(1).max(
|
|
1608
|
-
timeInSeconds: zodOpenapi.z.number().min(1).max(
|
|
1609
|
-
prompt: zodOpenapi.z.string().max(
|
|
1651
|
+
numEvents: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_NUM_EVENTS).optional(),
|
|
1652
|
+
timeInSeconds: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_INTERVAL_SECONDS).optional(),
|
|
1653
|
+
prompt: zodOpenapi.z.string().max(
|
|
1654
|
+
VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS,
|
|
1655
|
+
`Custom prompt cannot exceed ${VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS} characters`
|
|
1656
|
+
).optional(),
|
|
1610
1657
|
statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
|
|
1611
1658
|
}).openapi("StatusUpdate");
|
|
1612
1659
|
var CanUseItemSchema = zodOpenapi.z.object({
|
|
@@ -1637,6 +1684,7 @@ var FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
|
|
|
1637
1684
|
dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
1638
1685
|
artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
1639
1686
|
canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
1687
|
+
prompt: zodOpenapi.z.string().trim().nonempty(),
|
|
1640
1688
|
canDelegateTo: zodOpenapi.z.array(
|
|
1641
1689
|
zodOpenapi.z.union([
|
|
1642
1690
|
zodOpenapi.z.string(),
|
|
@@ -1665,7 +1713,10 @@ var AgentWithinContextOfProjectSchema = AgentApiInsertSchema.extend({
|
|
|
1665
1713
|
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
1666
1714
|
models: ModelSchema.optional(),
|
|
1667
1715
|
stopWhen: AgentStopWhenSchema.optional(),
|
|
1668
|
-
prompt: zodOpenapi.z.string().max(
|
|
1716
|
+
prompt: zodOpenapi.z.string().max(
|
|
1717
|
+
VALIDATION_AGENT_PROMPT_MAX_CHARS,
|
|
1718
|
+
`Agent prompt cannot exceed ${VALIDATION_AGENT_PROMPT_MAX_CHARS} characters`
|
|
1719
|
+
).optional()
|
|
1669
1720
|
});
|
|
1670
1721
|
var PaginationSchema = zodOpenapi.z.object({
|
|
1671
1722
|
page: zodOpenapi.z.coerce.number().min(1).default(1),
|