@inkeep/agents-core 0.0.0-chat-to-edit-20251119071712
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +56 -0
- package/README.md +458 -0
- package/SUPPLEMENTAL_TERMS.md +40 -0
- package/dist/auth-detection-CGqhPDnj.d.cts +435 -0
- package/dist/auth-detection-CGqhPDnj.d.ts +435 -0
- package/dist/chunk-7CLFCY6J.js +36 -0
- package/dist/chunk-A6JWG7FI.js +1689 -0
- package/dist/chunk-CMNLBV2A.js +39 -0
- package/dist/chunk-E6R6PML7.js +19 -0
- package/dist/chunk-OP3KPT4T.js +442 -0
- package/dist/chunk-TLSKVSBR.js +1234 -0
- package/dist/chunk-WG46C2WU.js +394 -0
- package/dist/chunk-YECQCT5N.js +223 -0
- package/dist/chunk-YFHT5M2R.js +18 -0
- package/dist/client-exports.cjs +3421 -0
- package/dist/client-exports.d.cts +292 -0
- package/dist/client-exports.d.ts +292 -0
- package/dist/client-exports.js +178 -0
- package/dist/constants/models.cjs +40 -0
- package/dist/constants/models.d.cts +42 -0
- package/dist/constants/models.d.ts +42 -0
- package/dist/constants/models.js +1 -0
- package/dist/db/schema.cjs +1686 -0
- package/dist/db/schema.d.cts +7 -0
- package/dist/db/schema.d.ts +7 -0
- package/dist/db/schema.js +1 -0
- package/dist/index.cjs +229792 -0
- package/dist/index.d.cts +5138 -0
- package/dist/index.d.ts +5138 -0
- package/dist/index.js +224908 -0
- package/dist/props-validation-BMR1qNiy.d.cts +15 -0
- package/dist/props-validation-BMR1qNiy.d.ts +15 -0
- package/dist/schema-C90zXlqp.d.ts +8012 -0
- package/dist/schema-keglUDw0.d.cts +8012 -0
- package/dist/types/index.cjs +64 -0
- package/dist/types/index.d.cts +175 -0
- package/dist/types/index.d.ts +175 -0
- package/dist/types/index.js +2 -0
- package/dist/utility-CXEG5391.d.cts +17265 -0
- package/dist/utility-CXEG5391.d.ts +17265 -0
- package/dist/utils/schema-conversion.cjs +236 -0
- package/dist/utils/schema-conversion.d.cts +26 -0
- package/dist/utils/schema-conversion.d.ts +26 -0
- package/dist/utils/schema-conversion.js +1 -0
- package/dist/validation/index.cjs +3521 -0
- package/dist/validation/index.d.cts +279 -0
- package/dist/validation/index.d.ts +279 -0
- package/dist/validation/index.js +2 -0
- package/drizzle/0000_exotic_mysterio.sql +398 -0
- package/drizzle/0001_greedy_the_phantom.sql +4 -0
- package/drizzle/0002_add_evaluation_features.sql +252 -0
- package/drizzle/0003_brave_micromax.sql +2 -0
- package/drizzle/meta/0000_snapshot.json +2519 -0
- package/drizzle/meta/0001_snapshot.json +2892 -0
- package/drizzle/meta/0002_snapshot.json +4485 -0
- package/drizzle/meta/_journal.json +34 -0
- package/package.json +133 -0
|
@@ -0,0 +1,3421 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
var zodOpenapi = require('@hono/zod-openapi');
|
|
5
|
+
var drizzleOrm = require('drizzle-orm');
|
|
6
|
+
var pgCore = require('drizzle-orm/pg-core');
|
|
7
|
+
var drizzleZod = require('drizzle-zod');
|
|
8
|
+
var Ajv = require('ajv');
|
|
9
|
+
var auth_js = require('@modelcontextprotocol/sdk/client/auth.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
14
|
+
|
|
15
|
+
// src/client-exports.ts
|
|
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
|
+
|
|
49
|
+
// src/types/utility.ts
|
|
50
|
+
var TOOL_STATUS_VALUES = ["healthy", "unhealthy", "unknown", "needs_auth"];
|
|
51
|
+
var VALID_RELATION_TYPES = ["transfer", "delegate"];
|
|
52
|
+
var MCPTransportType = {
|
|
53
|
+
streamableHttp: "streamable_http",
|
|
54
|
+
sse: "sse"
|
|
55
|
+
};
|
|
56
|
+
var MCPServerType = {
|
|
57
|
+
nango: "nango",
|
|
58
|
+
generic: "generic"
|
|
59
|
+
};
|
|
60
|
+
var CredentialStoreType = {
|
|
61
|
+
memory: "memory",
|
|
62
|
+
keychain: "keychain",
|
|
63
|
+
nango: "nango"
|
|
64
|
+
};
|
|
65
|
+
var tenantScoped = {
|
|
66
|
+
tenantId: pgCore.varchar("tenant_id", { length: 256 }).notNull(),
|
|
67
|
+
id: pgCore.varchar("id", { length: 256 }).notNull()
|
|
68
|
+
};
|
|
69
|
+
var projectScoped = {
|
|
70
|
+
...tenantScoped,
|
|
71
|
+
projectId: pgCore.varchar("project_id", { length: 256 }).notNull()
|
|
72
|
+
};
|
|
73
|
+
var agentScoped = {
|
|
74
|
+
...projectScoped,
|
|
75
|
+
agentId: pgCore.varchar("agent_id", { length: 256 }).notNull()
|
|
76
|
+
};
|
|
77
|
+
var subAgentScoped = {
|
|
78
|
+
...agentScoped,
|
|
79
|
+
subAgentId: pgCore.varchar("sub_agent_id", { length: 256 }).notNull()
|
|
80
|
+
};
|
|
81
|
+
var uiProperties = {
|
|
82
|
+
name: pgCore.varchar("name", { length: 256 }).notNull(),
|
|
83
|
+
description: pgCore.text("description").notNull()
|
|
84
|
+
};
|
|
85
|
+
var timestamps = {
|
|
86
|
+
createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow(),
|
|
87
|
+
updatedAt: pgCore.timestamp("updated_at", { mode: "string" }).notNull().defaultNow()
|
|
88
|
+
};
|
|
89
|
+
var projects = pgCore.pgTable(
|
|
90
|
+
"projects",
|
|
91
|
+
{
|
|
92
|
+
...tenantScoped,
|
|
93
|
+
...uiProperties,
|
|
94
|
+
models: pgCore.jsonb("models").$type(),
|
|
95
|
+
stopWhen: pgCore.jsonb("stop_when").$type(),
|
|
96
|
+
...timestamps
|
|
97
|
+
},
|
|
98
|
+
(table) => [pgCore.primaryKey({ columns: [table.tenantId, table.id] })]
|
|
99
|
+
);
|
|
100
|
+
var agents = pgCore.pgTable(
|
|
101
|
+
"agent",
|
|
102
|
+
{
|
|
103
|
+
...projectScoped,
|
|
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(),
|
|
112
|
+
...timestamps
|
|
113
|
+
},
|
|
114
|
+
(table) => [
|
|
115
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
116
|
+
pgCore.foreignKey({
|
|
117
|
+
columns: [table.tenantId, table.projectId],
|
|
118
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
119
|
+
name: "agent_project_fk"
|
|
120
|
+
}).onDelete("cascade")
|
|
121
|
+
]
|
|
122
|
+
);
|
|
123
|
+
var contextConfigs = pgCore.pgTable(
|
|
124
|
+
"context_configs",
|
|
125
|
+
{
|
|
126
|
+
...agentScoped,
|
|
127
|
+
headersSchema: pgCore.jsonb("headers_schema").$type(),
|
|
128
|
+
contextVariables: pgCore.jsonb("context_variables").$type(),
|
|
129
|
+
...timestamps
|
|
130
|
+
},
|
|
131
|
+
(table) => [
|
|
132
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
133
|
+
pgCore.foreignKey({
|
|
134
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
135
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
136
|
+
name: "context_configs_agent_fk"
|
|
137
|
+
}).onDelete("cascade")
|
|
138
|
+
]
|
|
139
|
+
);
|
|
140
|
+
var contextCache = pgCore.pgTable(
|
|
141
|
+
"context_cache",
|
|
142
|
+
{
|
|
143
|
+
...projectScoped,
|
|
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"),
|
|
152
|
+
...timestamps
|
|
153
|
+
},
|
|
154
|
+
(table) => [
|
|
155
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
156
|
+
pgCore.foreignKey({
|
|
157
|
+
columns: [table.tenantId, table.projectId],
|
|
158
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
159
|
+
name: "context_cache_project_fk"
|
|
160
|
+
}).onDelete("cascade"),
|
|
161
|
+
pgCore.index("context_cache_lookup_idx").on(
|
|
162
|
+
table.conversationId,
|
|
163
|
+
table.contextConfigId,
|
|
164
|
+
table.contextVariableKey
|
|
165
|
+
)
|
|
166
|
+
]
|
|
167
|
+
);
|
|
168
|
+
var subAgents = pgCore.pgTable(
|
|
169
|
+
"sub_agents",
|
|
170
|
+
{
|
|
171
|
+
...agentScoped,
|
|
172
|
+
...uiProperties,
|
|
173
|
+
prompt: pgCore.text("prompt").notNull(),
|
|
174
|
+
conversationHistoryConfig: pgCore.jsonb("conversation_history_config").$type().default({
|
|
175
|
+
mode: "full",
|
|
176
|
+
limit: 50,
|
|
177
|
+
maxOutputTokens: 4e3,
|
|
178
|
+
includeInternal: false,
|
|
179
|
+
messageTypes: ["chat", "tool-result"]
|
|
180
|
+
}),
|
|
181
|
+
models: pgCore.jsonb("models").$type(),
|
|
182
|
+
stopWhen: pgCore.jsonb("stop_when").$type(),
|
|
183
|
+
...timestamps
|
|
184
|
+
},
|
|
185
|
+
(table) => [
|
|
186
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
187
|
+
pgCore.foreignKey({
|
|
188
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
189
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
190
|
+
name: "sub_agents_agents_fk"
|
|
191
|
+
}).onDelete("cascade")
|
|
192
|
+
]
|
|
193
|
+
);
|
|
194
|
+
var subAgentRelations = pgCore.pgTable(
|
|
195
|
+
"sub_agent_relations",
|
|
196
|
+
{
|
|
197
|
+
...agentScoped,
|
|
198
|
+
sourceSubAgentId: pgCore.varchar("source_sub_agent_id", { length: 256 }).notNull(),
|
|
199
|
+
targetSubAgentId: pgCore.varchar("target_sub_agent_id", { length: 256 }),
|
|
200
|
+
relationType: pgCore.varchar("relation_type", { length: 256 }),
|
|
201
|
+
...timestamps
|
|
202
|
+
},
|
|
203
|
+
(table) => [
|
|
204
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
205
|
+
pgCore.foreignKey({
|
|
206
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
207
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
208
|
+
name: "sub_agent_relations_agent_fk"
|
|
209
|
+
}).onDelete("cascade")
|
|
210
|
+
]
|
|
211
|
+
);
|
|
212
|
+
var externalAgents = pgCore.pgTable(
|
|
213
|
+
"external_agents",
|
|
214
|
+
{
|
|
215
|
+
...projectScoped,
|
|
216
|
+
...uiProperties,
|
|
217
|
+
baseUrl: pgCore.text("base_url").notNull(),
|
|
218
|
+
credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
|
|
219
|
+
...timestamps
|
|
220
|
+
},
|
|
221
|
+
(table) => [
|
|
222
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
223
|
+
pgCore.foreignKey({
|
|
224
|
+
columns: [table.tenantId, table.projectId],
|
|
225
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
226
|
+
name: "external_agents_project_fk"
|
|
227
|
+
}).onDelete("cascade"),
|
|
228
|
+
pgCore.foreignKey({
|
|
229
|
+
columns: [table.tenantId, table.projectId, table.credentialReferenceId],
|
|
230
|
+
foreignColumns: [
|
|
231
|
+
credentialReferences.tenantId,
|
|
232
|
+
credentialReferences.projectId,
|
|
233
|
+
credentialReferences.id
|
|
234
|
+
],
|
|
235
|
+
name: "external_agents_credential_reference_fk"
|
|
236
|
+
}).onDelete("cascade")
|
|
237
|
+
]
|
|
238
|
+
);
|
|
239
|
+
var tasks = pgCore.pgTable(
|
|
240
|
+
"tasks",
|
|
241
|
+
{
|
|
242
|
+
...subAgentScoped,
|
|
243
|
+
contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
|
|
244
|
+
status: pgCore.varchar("status", { length: 256 }).notNull(),
|
|
245
|
+
metadata: pgCore.jsonb("metadata").$type(),
|
|
246
|
+
...timestamps
|
|
247
|
+
},
|
|
248
|
+
(table) => [
|
|
249
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
250
|
+
pgCore.foreignKey({
|
|
251
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
252
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
253
|
+
name: "tasks_sub_agent_fk"
|
|
254
|
+
}).onDelete("cascade")
|
|
255
|
+
]
|
|
256
|
+
);
|
|
257
|
+
var taskRelations = pgCore.pgTable(
|
|
258
|
+
"task_relations",
|
|
259
|
+
{
|
|
260
|
+
...projectScoped,
|
|
261
|
+
parentTaskId: pgCore.varchar("parent_task_id", { length: 256 }).notNull(),
|
|
262
|
+
childTaskId: pgCore.varchar("child_task_id", { length: 256 }).notNull(),
|
|
263
|
+
relationType: pgCore.varchar("relation_type", { length: 256 }).default("parent_child"),
|
|
264
|
+
...timestamps
|
|
265
|
+
},
|
|
266
|
+
(table) => [
|
|
267
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
268
|
+
pgCore.foreignKey({
|
|
269
|
+
columns: [table.tenantId, table.projectId],
|
|
270
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
271
|
+
name: "task_relations_project_fk"
|
|
272
|
+
}).onDelete("cascade")
|
|
273
|
+
]
|
|
274
|
+
);
|
|
275
|
+
var dataComponents = pgCore.pgTable(
|
|
276
|
+
"data_components",
|
|
277
|
+
{
|
|
278
|
+
...projectScoped,
|
|
279
|
+
...uiProperties,
|
|
280
|
+
props: pgCore.jsonb("props").$type(),
|
|
281
|
+
render: pgCore.jsonb("render").$type(),
|
|
282
|
+
...timestamps
|
|
283
|
+
},
|
|
284
|
+
(table) => [
|
|
285
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
286
|
+
pgCore.foreignKey({
|
|
287
|
+
columns: [table.tenantId, table.projectId],
|
|
288
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
289
|
+
name: "data_components_project_fk"
|
|
290
|
+
}).onDelete("cascade")
|
|
291
|
+
]
|
|
292
|
+
);
|
|
293
|
+
var subAgentDataComponents = pgCore.pgTable(
|
|
294
|
+
"sub_agent_data_components",
|
|
295
|
+
{
|
|
296
|
+
...subAgentScoped,
|
|
297
|
+
dataComponentId: pgCore.varchar("data_component_id", { length: 256 }).notNull(),
|
|
298
|
+
createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
|
|
299
|
+
},
|
|
300
|
+
(table) => [
|
|
301
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
302
|
+
pgCore.foreignKey({
|
|
303
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
304
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
305
|
+
name: "sub_agent_data_components_sub_agent_fk"
|
|
306
|
+
}).onDelete("cascade"),
|
|
307
|
+
pgCore.foreignKey({
|
|
308
|
+
columns: [table.tenantId, table.projectId, table.dataComponentId],
|
|
309
|
+
foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
|
|
310
|
+
name: "sub_agent_data_components_data_component_fk"
|
|
311
|
+
}).onDelete("cascade")
|
|
312
|
+
]
|
|
313
|
+
);
|
|
314
|
+
var artifactComponents = pgCore.pgTable(
|
|
315
|
+
"artifact_components",
|
|
316
|
+
{
|
|
317
|
+
...projectScoped,
|
|
318
|
+
...uiProperties,
|
|
319
|
+
props: pgCore.jsonb("props").$type(),
|
|
320
|
+
...timestamps
|
|
321
|
+
},
|
|
322
|
+
(table) => [
|
|
323
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
324
|
+
pgCore.foreignKey({
|
|
325
|
+
columns: [table.tenantId, table.projectId],
|
|
326
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
327
|
+
name: "artifact_components_project_fk"
|
|
328
|
+
}).onDelete("cascade")
|
|
329
|
+
]
|
|
330
|
+
);
|
|
331
|
+
var subAgentArtifactComponents = pgCore.pgTable(
|
|
332
|
+
"sub_agent_artifact_components",
|
|
333
|
+
{
|
|
334
|
+
...subAgentScoped,
|
|
335
|
+
artifactComponentId: pgCore.varchar("artifact_component_id", { length: 256 }).notNull(),
|
|
336
|
+
createdAt: pgCore.timestamp("created_at", { mode: "string" }).notNull().defaultNow()
|
|
337
|
+
},
|
|
338
|
+
(table) => [
|
|
339
|
+
pgCore.primaryKey({
|
|
340
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId, table.id]
|
|
341
|
+
}),
|
|
342
|
+
pgCore.foreignKey({
|
|
343
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
344
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
345
|
+
name: "sub_agent_artifact_components_sub_agent_fk"
|
|
346
|
+
}).onDelete("cascade"),
|
|
347
|
+
pgCore.foreignKey({
|
|
348
|
+
columns: [table.tenantId, table.projectId, table.artifactComponentId],
|
|
349
|
+
foreignColumns: [
|
|
350
|
+
artifactComponents.tenantId,
|
|
351
|
+
artifactComponents.projectId,
|
|
352
|
+
artifactComponents.id
|
|
353
|
+
],
|
|
354
|
+
name: "sub_agent_artifact_components_artifact_component_fk"
|
|
355
|
+
}).onDelete("cascade")
|
|
356
|
+
]
|
|
357
|
+
);
|
|
358
|
+
var tools = pgCore.pgTable(
|
|
359
|
+
"tools",
|
|
360
|
+
{
|
|
361
|
+
...projectScoped,
|
|
362
|
+
name: pgCore.varchar("name", { length: 256 }).notNull(),
|
|
363
|
+
description: pgCore.text("description"),
|
|
364
|
+
config: pgCore.jsonb("config").$type().notNull(),
|
|
365
|
+
credentialReferenceId: pgCore.varchar("credential_reference_id", { length: 256 }),
|
|
366
|
+
headers: pgCore.jsonb("headers").$type(),
|
|
367
|
+
imageUrl: pgCore.text("image_url"),
|
|
368
|
+
capabilities: pgCore.jsonb("capabilities").$type(),
|
|
369
|
+
lastError: pgCore.text("last_error"),
|
|
370
|
+
...timestamps
|
|
371
|
+
},
|
|
372
|
+
(table) => [
|
|
373
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
374
|
+
pgCore.foreignKey({
|
|
375
|
+
columns: [table.tenantId, table.projectId],
|
|
376
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
377
|
+
name: "tools_project_fk"
|
|
378
|
+
}).onDelete("cascade")
|
|
379
|
+
]
|
|
380
|
+
);
|
|
381
|
+
var functionTools = pgCore.pgTable(
|
|
382
|
+
"function_tools",
|
|
383
|
+
{
|
|
384
|
+
...agentScoped,
|
|
385
|
+
name: pgCore.varchar("name", { length: 256 }).notNull(),
|
|
386
|
+
description: pgCore.text("description"),
|
|
387
|
+
functionId: pgCore.varchar("function_id", { length: 256 }).notNull(),
|
|
388
|
+
...timestamps
|
|
389
|
+
},
|
|
390
|
+
(table) => [
|
|
391
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
392
|
+
pgCore.foreignKey({
|
|
393
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
394
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
395
|
+
name: "function_tools_agent_fk"
|
|
396
|
+
}).onDelete("cascade"),
|
|
397
|
+
pgCore.foreignKey({
|
|
398
|
+
columns: [table.tenantId, table.projectId, table.functionId],
|
|
399
|
+
foreignColumns: [functions.tenantId, functions.projectId, functions.id],
|
|
400
|
+
name: "function_tools_function_fk"
|
|
401
|
+
}).onDelete("cascade")
|
|
402
|
+
]
|
|
403
|
+
);
|
|
404
|
+
var functions = pgCore.pgTable(
|
|
405
|
+
"functions",
|
|
406
|
+
{
|
|
407
|
+
...projectScoped,
|
|
408
|
+
inputSchema: pgCore.jsonb("input_schema").$type(),
|
|
409
|
+
executeCode: pgCore.text("execute_code").notNull(),
|
|
410
|
+
dependencies: pgCore.jsonb("dependencies").$type(),
|
|
411
|
+
...timestamps
|
|
412
|
+
},
|
|
413
|
+
(table) => [
|
|
414
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
415
|
+
pgCore.foreignKey({
|
|
416
|
+
columns: [table.tenantId, table.projectId],
|
|
417
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
418
|
+
name: "functions_project_fk"
|
|
419
|
+
}).onDelete("cascade")
|
|
420
|
+
]
|
|
421
|
+
);
|
|
422
|
+
var subAgentToolRelations = pgCore.pgTable(
|
|
423
|
+
"sub_agent_tool_relations",
|
|
424
|
+
{
|
|
425
|
+
...subAgentScoped,
|
|
426
|
+
toolId: pgCore.varchar("tool_id", { length: 256 }).notNull(),
|
|
427
|
+
selectedTools: pgCore.jsonb("selected_tools").$type(),
|
|
428
|
+
headers: pgCore.jsonb("headers").$type(),
|
|
429
|
+
toolPolicies: pgCore.jsonb("tool_policies").$type(),
|
|
430
|
+
...timestamps
|
|
431
|
+
},
|
|
432
|
+
(table) => [
|
|
433
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
434
|
+
pgCore.foreignKey({
|
|
435
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
436
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
437
|
+
name: "sub_agent_tool_relations_agent_fk"
|
|
438
|
+
}).onDelete("cascade"),
|
|
439
|
+
pgCore.foreignKey({
|
|
440
|
+
columns: [table.tenantId, table.projectId, table.toolId],
|
|
441
|
+
foreignColumns: [tools.tenantId, tools.projectId, tools.id],
|
|
442
|
+
name: "sub_agent_tool_relations_tool_fk"
|
|
443
|
+
}).onDelete("cascade")
|
|
444
|
+
]
|
|
445
|
+
);
|
|
446
|
+
var subAgentExternalAgentRelations = pgCore.pgTable(
|
|
447
|
+
"sub_agent_external_agent_relations",
|
|
448
|
+
{
|
|
449
|
+
...subAgentScoped,
|
|
450
|
+
externalAgentId: pgCore.varchar("external_agent_id", { length: 256 }).notNull(),
|
|
451
|
+
headers: pgCore.jsonb("headers").$type(),
|
|
452
|
+
...timestamps
|
|
453
|
+
},
|
|
454
|
+
(table) => [
|
|
455
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
456
|
+
pgCore.foreignKey({
|
|
457
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
458
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
459
|
+
name: "sub_agent_external_agent_relations_sub_agent_fk"
|
|
460
|
+
}).onDelete("cascade"),
|
|
461
|
+
pgCore.foreignKey({
|
|
462
|
+
columns: [table.tenantId, table.projectId, table.externalAgentId],
|
|
463
|
+
foreignColumns: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
|
|
464
|
+
name: "sub_agent_external_agent_relations_external_agent_fk"
|
|
465
|
+
}).onDelete("cascade")
|
|
466
|
+
]
|
|
467
|
+
);
|
|
468
|
+
var subAgentTeamAgentRelations = pgCore.pgTable(
|
|
469
|
+
"sub_agent_team_agent_relations",
|
|
470
|
+
{
|
|
471
|
+
...subAgentScoped,
|
|
472
|
+
targetAgentId: pgCore.varchar("target_agent_id", { length: 256 }).notNull(),
|
|
473
|
+
headers: pgCore.jsonb("headers").$type(),
|
|
474
|
+
...timestamps
|
|
475
|
+
},
|
|
476
|
+
(table) => [
|
|
477
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
478
|
+
pgCore.foreignKey({
|
|
479
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
480
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
481
|
+
name: "sub_agent_team_agent_relations_sub_agent_fk"
|
|
482
|
+
}).onDelete("cascade"),
|
|
483
|
+
pgCore.foreignKey({
|
|
484
|
+
columns: [table.tenantId, table.projectId, table.targetAgentId],
|
|
485
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
486
|
+
name: "sub_agent_team_agent_relations_target_agent_fk"
|
|
487
|
+
}).onDelete("cascade")
|
|
488
|
+
]
|
|
489
|
+
);
|
|
490
|
+
var subAgentFunctionToolRelations = pgCore.pgTable(
|
|
491
|
+
"sub_agent_function_tool_relations",
|
|
492
|
+
{
|
|
493
|
+
...subAgentScoped,
|
|
494
|
+
functionToolId: pgCore.varchar("function_tool_id", { length: 256 }).notNull(),
|
|
495
|
+
...timestamps
|
|
496
|
+
},
|
|
497
|
+
(table) => [
|
|
498
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
499
|
+
pgCore.foreignKey({
|
|
500
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
501
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
502
|
+
name: "sub_agent_function_tool_relations_sub_agent_fk"
|
|
503
|
+
}).onDelete("cascade"),
|
|
504
|
+
pgCore.foreignKey({
|
|
505
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.functionToolId],
|
|
506
|
+
foreignColumns: [
|
|
507
|
+
functionTools.tenantId,
|
|
508
|
+
functionTools.projectId,
|
|
509
|
+
functionTools.agentId,
|
|
510
|
+
functionTools.id
|
|
511
|
+
],
|
|
512
|
+
name: "sub_agent_function_tool_relations_function_tool_fk"
|
|
513
|
+
}).onDelete("cascade")
|
|
514
|
+
]
|
|
515
|
+
);
|
|
516
|
+
var conversations = pgCore.pgTable(
|
|
517
|
+
"conversations",
|
|
518
|
+
{
|
|
519
|
+
...projectScoped,
|
|
520
|
+
userId: pgCore.varchar("user_id", { length: 256 }),
|
|
521
|
+
activeSubAgentId: pgCore.varchar("active_sub_agent_id", { length: 256 }).notNull(),
|
|
522
|
+
title: pgCore.text("title"),
|
|
523
|
+
lastContextResolution: pgCore.timestamp("last_context_resolution", { mode: "string" }),
|
|
524
|
+
metadata: pgCore.jsonb("metadata").$type(),
|
|
525
|
+
...timestamps
|
|
526
|
+
},
|
|
527
|
+
(table) => [
|
|
528
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
529
|
+
pgCore.foreignKey({
|
|
530
|
+
columns: [table.tenantId, table.projectId],
|
|
531
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
532
|
+
name: "conversations_project_fk"
|
|
533
|
+
}).onDelete("cascade")
|
|
534
|
+
]
|
|
535
|
+
);
|
|
536
|
+
var messages = pgCore.pgTable(
|
|
537
|
+
"messages",
|
|
538
|
+
{
|
|
539
|
+
...projectScoped,
|
|
540
|
+
conversationId: pgCore.varchar("conversation_id", { length: 256 }).notNull(),
|
|
541
|
+
role: pgCore.varchar("role", { length: 256 }).notNull(),
|
|
542
|
+
fromSubAgentId: pgCore.varchar("from_sub_agent_id", { length: 256 }),
|
|
543
|
+
toSubAgentId: pgCore.varchar("to_sub_agent_id", { length: 256 }),
|
|
544
|
+
fromExternalAgentId: pgCore.varchar("from_external_sub_agent_id", { length: 256 }),
|
|
545
|
+
toExternalAgentId: pgCore.varchar("to_external_sub_agent_id", { length: 256 }),
|
|
546
|
+
fromTeamAgentId: pgCore.varchar("from_team_agent_id", { length: 256 }),
|
|
547
|
+
toTeamAgentId: pgCore.varchar("to_team_agent_id", { length: 256 }),
|
|
548
|
+
content: pgCore.jsonb("content").$type().notNull(),
|
|
549
|
+
visibility: pgCore.varchar("visibility", { length: 256 }).notNull().default("user-facing"),
|
|
550
|
+
messageType: pgCore.varchar("message_type", { length: 256 }).notNull().default("chat"),
|
|
551
|
+
taskId: pgCore.varchar("task_id", { length: 256 }),
|
|
552
|
+
parentMessageId: pgCore.varchar("parent_message_id", { length: 256 }),
|
|
553
|
+
a2aTaskId: pgCore.varchar("a2a_task_id", { length: 256 }),
|
|
554
|
+
a2aSessionId: pgCore.varchar("a2a_session_id", { length: 256 }),
|
|
555
|
+
metadata: pgCore.jsonb("metadata").$type(),
|
|
556
|
+
...timestamps
|
|
557
|
+
},
|
|
558
|
+
(table) => [
|
|
559
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
560
|
+
pgCore.foreignKey({
|
|
561
|
+
columns: [table.tenantId, table.projectId],
|
|
562
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
563
|
+
name: "messages_project_fk"
|
|
564
|
+
}).onDelete("cascade")
|
|
565
|
+
]
|
|
566
|
+
);
|
|
567
|
+
var ledgerArtifacts = pgCore.pgTable(
|
|
568
|
+
"ledger_artifacts",
|
|
569
|
+
{
|
|
570
|
+
...projectScoped,
|
|
571
|
+
taskId: pgCore.varchar("task_id", { length: 256 }).notNull(),
|
|
572
|
+
toolCallId: pgCore.varchar("tool_call_id", { length: 256 }),
|
|
573
|
+
contextId: pgCore.varchar("context_id", { length: 256 }).notNull(),
|
|
574
|
+
type: pgCore.varchar("type", { length: 256 }).notNull().default("source"),
|
|
575
|
+
name: pgCore.varchar("name", { length: 256 }),
|
|
576
|
+
description: pgCore.text("description"),
|
|
577
|
+
parts: pgCore.jsonb("parts").$type(),
|
|
578
|
+
metadata: pgCore.jsonb("metadata").$type(),
|
|
579
|
+
summary: pgCore.text("summary"),
|
|
580
|
+
mime: pgCore.jsonb("mime").$type(),
|
|
581
|
+
visibility: pgCore.varchar("visibility", { length: 256 }).default("context"),
|
|
582
|
+
allowedAgents: pgCore.jsonb("allowed_agents").$type(),
|
|
583
|
+
derivedFrom: pgCore.varchar("derived_from", { length: 256 }),
|
|
584
|
+
...timestamps
|
|
585
|
+
},
|
|
586
|
+
(table) => [
|
|
587
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id, table.taskId] }),
|
|
588
|
+
pgCore.foreignKey({
|
|
589
|
+
columns: [table.tenantId, table.projectId],
|
|
590
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
591
|
+
name: "ledger_artifacts_project_fk"
|
|
592
|
+
}).onDelete("cascade"),
|
|
593
|
+
pgCore.index("ledger_artifacts_task_id_idx").on(table.taskId),
|
|
594
|
+
pgCore.index("ledger_artifacts_tool_call_id_idx").on(table.toolCallId),
|
|
595
|
+
pgCore.index("ledger_artifacts_context_id_idx").on(table.contextId),
|
|
596
|
+
pgCore.unique("ledger_artifacts_task_context_name_unique").on(
|
|
597
|
+
table.taskId,
|
|
598
|
+
table.contextId,
|
|
599
|
+
table.name
|
|
600
|
+
)
|
|
601
|
+
]
|
|
602
|
+
);
|
|
603
|
+
var apiKeys = pgCore.pgTable(
|
|
604
|
+
"api_keys",
|
|
605
|
+
{
|
|
606
|
+
...agentScoped,
|
|
607
|
+
publicId: pgCore.varchar("public_id", { length: 256 }).notNull().unique(),
|
|
608
|
+
keyHash: pgCore.varchar("key_hash", { length: 256 }).notNull(),
|
|
609
|
+
keyPrefix: pgCore.varchar("key_prefix", { length: 256 }).notNull(),
|
|
610
|
+
name: pgCore.varchar("name", { length: 256 }),
|
|
611
|
+
lastUsedAt: pgCore.timestamp("last_used_at", { mode: "string" }),
|
|
612
|
+
expiresAt: pgCore.timestamp("expires_at", { mode: "string" }),
|
|
613
|
+
...timestamps
|
|
614
|
+
},
|
|
615
|
+
(t) => [
|
|
616
|
+
pgCore.foreignKey({
|
|
617
|
+
columns: [t.tenantId, t.projectId],
|
|
618
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
619
|
+
name: "api_keys_project_fk"
|
|
620
|
+
}).onDelete("cascade"),
|
|
621
|
+
pgCore.foreignKey({
|
|
622
|
+
columns: [t.tenantId, t.projectId, t.agentId],
|
|
623
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
624
|
+
name: "api_keys_agent_fk"
|
|
625
|
+
}).onDelete("cascade"),
|
|
626
|
+
pgCore.index("api_keys_tenant_agent_idx").on(t.tenantId, t.agentId),
|
|
627
|
+
pgCore.index("api_keys_prefix_idx").on(t.keyPrefix),
|
|
628
|
+
pgCore.index("api_keys_public_id_idx").on(t.publicId)
|
|
629
|
+
]
|
|
630
|
+
);
|
|
631
|
+
var credentialReferences = pgCore.pgTable(
|
|
632
|
+
"credential_references",
|
|
633
|
+
{
|
|
634
|
+
...projectScoped,
|
|
635
|
+
name: pgCore.varchar("name", { length: 256 }).notNull(),
|
|
636
|
+
type: pgCore.varchar("type", { length: 256 }).notNull(),
|
|
637
|
+
credentialStoreId: pgCore.varchar("credential_store_id", { length: 256 }).notNull(),
|
|
638
|
+
retrievalParams: pgCore.jsonb("retrieval_params").$type(),
|
|
639
|
+
...timestamps
|
|
640
|
+
},
|
|
641
|
+
(t) => [
|
|
642
|
+
pgCore.primaryKey({ columns: [t.tenantId, t.projectId, t.id] }),
|
|
643
|
+
pgCore.foreignKey({
|
|
644
|
+
columns: [t.tenantId, t.projectId],
|
|
645
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
646
|
+
name: "credential_references_project_fk"
|
|
647
|
+
}).onDelete("cascade")
|
|
648
|
+
]
|
|
649
|
+
);
|
|
650
|
+
var dataset = pgCore.pgTable(
|
|
651
|
+
"dataset",
|
|
652
|
+
{
|
|
653
|
+
...projectScoped,
|
|
654
|
+
...uiProperties,
|
|
655
|
+
...timestamps
|
|
656
|
+
},
|
|
657
|
+
(table) => [
|
|
658
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
659
|
+
pgCore.foreignKey({
|
|
660
|
+
columns: [table.tenantId, table.projectId],
|
|
661
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
662
|
+
name: "dataset_project_fk"
|
|
663
|
+
}).onDelete("cascade")
|
|
664
|
+
]
|
|
665
|
+
);
|
|
666
|
+
var datasetItem = pgCore.pgTable(
|
|
667
|
+
"dataset_item",
|
|
668
|
+
{
|
|
669
|
+
...projectScoped,
|
|
670
|
+
datasetId: pgCore.text("dataset_id").notNull(),
|
|
671
|
+
input: pgCore.jsonb("input").$type().notNull(),
|
|
672
|
+
expectedOutput: pgCore.jsonb("expected_output").$type(),
|
|
673
|
+
simulationAgent: pgCore.jsonb("simulation_agent").$type(),
|
|
674
|
+
...timestamps
|
|
675
|
+
},
|
|
676
|
+
(table) => [
|
|
677
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
678
|
+
pgCore.foreignKey({
|
|
679
|
+
columns: [table.tenantId, table.projectId, table.datasetId],
|
|
680
|
+
foreignColumns: [dataset.tenantId, dataset.projectId, dataset.id],
|
|
681
|
+
name: "dataset_item_dataset_fk"
|
|
682
|
+
}).onDelete("cascade")
|
|
683
|
+
]
|
|
684
|
+
);
|
|
685
|
+
var evaluator = pgCore.pgTable(
|
|
686
|
+
"evaluator",
|
|
687
|
+
{
|
|
688
|
+
...projectScoped,
|
|
689
|
+
...uiProperties,
|
|
690
|
+
prompt: pgCore.text("prompt").notNull(),
|
|
691
|
+
schema: pgCore.jsonb("schema").$type().notNull(),
|
|
692
|
+
model: pgCore.jsonb("model").$type().notNull(),
|
|
693
|
+
passCriteria: pgCore.jsonb("pass_criteria").$type(),
|
|
694
|
+
...timestamps
|
|
695
|
+
},
|
|
696
|
+
(table) => [
|
|
697
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
698
|
+
pgCore.foreignKey({
|
|
699
|
+
columns: [table.tenantId, table.projectId],
|
|
700
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
701
|
+
name: "evaluator_project_fk"
|
|
702
|
+
}).onDelete("cascade")
|
|
703
|
+
]
|
|
704
|
+
);
|
|
705
|
+
var datasetRunConfig = pgCore.pgTable(
|
|
706
|
+
"dataset_run_config",
|
|
707
|
+
{
|
|
708
|
+
...projectScoped,
|
|
709
|
+
...uiProperties,
|
|
710
|
+
datasetId: pgCore.text("dataset_id").notNull(),
|
|
711
|
+
...timestamps
|
|
712
|
+
},
|
|
713
|
+
(table) => [
|
|
714
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
715
|
+
pgCore.foreignKey({
|
|
716
|
+
columns: [table.tenantId, table.projectId],
|
|
717
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
718
|
+
name: "dataset_run_config_project_fk"
|
|
719
|
+
}).onDelete("cascade"),
|
|
720
|
+
pgCore.foreignKey({
|
|
721
|
+
columns: [table.tenantId, table.projectId, table.datasetId],
|
|
722
|
+
foreignColumns: [dataset.tenantId, dataset.projectId, dataset.id],
|
|
723
|
+
name: "dataset_run_config_dataset_fk"
|
|
724
|
+
}).onDelete("cascade")
|
|
725
|
+
]
|
|
726
|
+
);
|
|
727
|
+
var datasetRunConfigAgentRelations = pgCore.pgTable(
|
|
728
|
+
"dataset_run_config_agent_relations",
|
|
729
|
+
{
|
|
730
|
+
...projectScoped,
|
|
731
|
+
datasetRunConfigId: pgCore.text("dataset_run_config_id").notNull(),
|
|
732
|
+
agentId: pgCore.text("agent_id").notNull(),
|
|
733
|
+
...timestamps
|
|
734
|
+
},
|
|
735
|
+
(table) => [
|
|
736
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
737
|
+
pgCore.foreignKey({
|
|
738
|
+
columns: [table.tenantId, table.projectId, table.datasetRunConfigId],
|
|
739
|
+
foreignColumns: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id],
|
|
740
|
+
name: "dataset_run_config_agent_relations_dataset_run_config_fk"
|
|
741
|
+
}).onDelete("cascade"),
|
|
742
|
+
pgCore.foreignKey({
|
|
743
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
744
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
745
|
+
name: "dataset_run_config_agent_relations_agent_fk"
|
|
746
|
+
}).onDelete("cascade")
|
|
747
|
+
]
|
|
748
|
+
);
|
|
749
|
+
var datasetRunConfigEvaluationRunConfigRelations = pgCore.pgTable(
|
|
750
|
+
"dataset_run_config_evaluation_run_config_relations",
|
|
751
|
+
{
|
|
752
|
+
...projectScoped,
|
|
753
|
+
datasetRunConfigId: pgCore.text("dataset_run_config_id").notNull(),
|
|
754
|
+
evaluationRunConfigId: pgCore.text("evaluation_run_config_id").notNull(),
|
|
755
|
+
enabled: pgCore.boolean("enabled").notNull().default(true),
|
|
756
|
+
...timestamps
|
|
757
|
+
},
|
|
758
|
+
(table) => [
|
|
759
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
760
|
+
pgCore.foreignKey({
|
|
761
|
+
columns: [table.tenantId, table.projectId, table.datasetRunConfigId],
|
|
762
|
+
foreignColumns: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id],
|
|
763
|
+
name: "dataset_run_config_evaluation_run_config_relations_dataset_run_config_fk"
|
|
764
|
+
}).onDelete("cascade"),
|
|
765
|
+
pgCore.foreignKey({
|
|
766
|
+
columns: [table.tenantId, table.projectId, table.evaluationRunConfigId],
|
|
767
|
+
foreignColumns: [
|
|
768
|
+
evaluationRunConfig.tenantId,
|
|
769
|
+
evaluationRunConfig.projectId,
|
|
770
|
+
evaluationRunConfig.id
|
|
771
|
+
],
|
|
772
|
+
name: "dataset_run_config_evaluation_run_config_relations_evaluation_run_config_fk"
|
|
773
|
+
}).onDelete("cascade")
|
|
774
|
+
]
|
|
775
|
+
);
|
|
776
|
+
var datasetRun = pgCore.pgTable(
|
|
777
|
+
"dataset_run",
|
|
778
|
+
{
|
|
779
|
+
...projectScoped,
|
|
780
|
+
datasetId: pgCore.text("dataset_id").notNull(),
|
|
781
|
+
datasetRunConfigId: pgCore.text("dataset_run_config_id").notNull(),
|
|
782
|
+
evaluationJobConfigId: pgCore.text("evaluation_job_config_id"),
|
|
783
|
+
...timestamps
|
|
784
|
+
},
|
|
785
|
+
(table) => [
|
|
786
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
787
|
+
pgCore.foreignKey({
|
|
788
|
+
columns: [table.tenantId, table.projectId, table.datasetId],
|
|
789
|
+
foreignColumns: [dataset.tenantId, dataset.projectId, dataset.id],
|
|
790
|
+
name: "dataset_run_dataset_fk"
|
|
791
|
+
}).onDelete("cascade"),
|
|
792
|
+
pgCore.foreignKey({
|
|
793
|
+
columns: [table.tenantId, table.projectId, table.datasetRunConfigId],
|
|
794
|
+
foreignColumns: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id],
|
|
795
|
+
name: "dataset_run_dataset_run_config_fk"
|
|
796
|
+
}).onDelete("cascade"),
|
|
797
|
+
pgCore.foreignKey({
|
|
798
|
+
columns: [table.tenantId, table.projectId, table.evaluationJobConfigId],
|
|
799
|
+
foreignColumns: [
|
|
800
|
+
evaluationJobConfig.tenantId,
|
|
801
|
+
evaluationJobConfig.projectId,
|
|
802
|
+
evaluationJobConfig.id
|
|
803
|
+
],
|
|
804
|
+
name: "dataset_run_evaluation_job_config_fk"
|
|
805
|
+
}).onDelete("set null")
|
|
806
|
+
]
|
|
807
|
+
);
|
|
808
|
+
var datasetRunConversationRelations = pgCore.pgTable(
|
|
809
|
+
"dataset_run_conversation_relations",
|
|
810
|
+
{
|
|
811
|
+
...projectScoped,
|
|
812
|
+
datasetRunId: pgCore.text("dataset_run_id").notNull(),
|
|
813
|
+
conversationId: pgCore.text("conversation_id").notNull(),
|
|
814
|
+
datasetItemId: pgCore.text("dataset_item_id").notNull(),
|
|
815
|
+
...timestamps
|
|
816
|
+
},
|
|
817
|
+
(table) => [
|
|
818
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
819
|
+
pgCore.foreignKey({
|
|
820
|
+
columns: [table.tenantId, table.projectId, table.datasetRunId],
|
|
821
|
+
foreignColumns: [datasetRun.tenantId, datasetRun.projectId, datasetRun.id],
|
|
822
|
+
name: "dataset_run_conversation_relations_run_fk"
|
|
823
|
+
}).onDelete("cascade"),
|
|
824
|
+
pgCore.foreignKey({
|
|
825
|
+
columns: [table.tenantId, table.projectId, table.conversationId],
|
|
826
|
+
foreignColumns: [conversations.tenantId, conversations.projectId, conversations.id],
|
|
827
|
+
name: "dataset_run_conversation_relations_conversation_fk"
|
|
828
|
+
}).onDelete("cascade"),
|
|
829
|
+
pgCore.foreignKey({
|
|
830
|
+
columns: [table.tenantId, table.projectId, table.datasetItemId],
|
|
831
|
+
foreignColumns: [datasetItem.tenantId, datasetItem.projectId, datasetItem.id],
|
|
832
|
+
name: "dataset_run_conversation_relations_item_fk"
|
|
833
|
+
}).onDelete("cascade"),
|
|
834
|
+
pgCore.unique("dataset_run_conversation_relations_unique").on(
|
|
835
|
+
table.datasetRunId,
|
|
836
|
+
table.conversationId
|
|
837
|
+
)
|
|
838
|
+
]
|
|
839
|
+
);
|
|
840
|
+
var evaluationSuiteConfig = pgCore.pgTable(
|
|
841
|
+
"evaluation_suite_config",
|
|
842
|
+
{
|
|
843
|
+
...projectScoped,
|
|
844
|
+
...uiProperties,
|
|
845
|
+
filters: pgCore.jsonb("filters").$type(),
|
|
846
|
+
// Filters for the evaluation suite (supports and/or operations)
|
|
847
|
+
sampleRate: pgCore.doublePrecision("sample_rate"),
|
|
848
|
+
...timestamps
|
|
849
|
+
},
|
|
850
|
+
(table) => [
|
|
851
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
852
|
+
pgCore.foreignKey({
|
|
853
|
+
columns: [table.tenantId, table.projectId],
|
|
854
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
855
|
+
name: "evaluation_suite_config_project_fk"
|
|
856
|
+
}).onDelete("cascade")
|
|
857
|
+
]
|
|
858
|
+
);
|
|
859
|
+
var evaluationSuiteConfigEvaluatorRelations = pgCore.pgTable(
|
|
860
|
+
"evaluation_suite_config_evaluator_relations",
|
|
861
|
+
{
|
|
862
|
+
...projectScoped,
|
|
863
|
+
evaluationSuiteConfigId: pgCore.text("evaluation_suite_config_id").notNull(),
|
|
864
|
+
evaluatorId: pgCore.text("evaluator_id").notNull(),
|
|
865
|
+
...timestamps
|
|
866
|
+
},
|
|
867
|
+
(table) => [
|
|
868
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
869
|
+
pgCore.foreignKey({
|
|
870
|
+
columns: [table.tenantId, table.projectId, table.evaluationSuiteConfigId],
|
|
871
|
+
foreignColumns: [
|
|
872
|
+
evaluationSuiteConfig.tenantId,
|
|
873
|
+
evaluationSuiteConfig.projectId,
|
|
874
|
+
evaluationSuiteConfig.id
|
|
875
|
+
],
|
|
876
|
+
name: "evaluation_suite_config_evaluator_relations_evaluation_suite_config_fk"
|
|
877
|
+
}).onDelete("cascade"),
|
|
878
|
+
pgCore.foreignKey({
|
|
879
|
+
columns: [table.tenantId, table.projectId, table.evaluatorId],
|
|
880
|
+
foreignColumns: [evaluator.tenantId, evaluator.projectId, evaluator.id],
|
|
881
|
+
name: "evaluation_suite_config_evaluator_relations_evaluator_fk"
|
|
882
|
+
}).onDelete("cascade")
|
|
883
|
+
]
|
|
884
|
+
);
|
|
885
|
+
var evaluationRunConfig = pgCore.pgTable(
|
|
886
|
+
"evaluation_run_config",
|
|
887
|
+
{
|
|
888
|
+
...projectScoped,
|
|
889
|
+
...uiProperties,
|
|
890
|
+
isActive: pgCore.boolean("is_active").notNull().default(true),
|
|
891
|
+
...timestamps
|
|
892
|
+
},
|
|
893
|
+
(table) => [
|
|
894
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
895
|
+
pgCore.foreignKey({
|
|
896
|
+
columns: [table.tenantId, table.projectId],
|
|
897
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
898
|
+
name: "evaluation_run_config_project_fk"
|
|
899
|
+
}).onDelete("cascade")
|
|
900
|
+
]
|
|
901
|
+
);
|
|
902
|
+
var evaluationRunConfigEvaluationSuiteConfigRelations = pgCore.pgTable(
|
|
903
|
+
"evaluation_run_config_evaluation_suite_config_relations",
|
|
904
|
+
{
|
|
905
|
+
...projectScoped,
|
|
906
|
+
evaluationRunConfigId: pgCore.text("evaluation_run_config_id").notNull(),
|
|
907
|
+
evaluationSuiteConfigId: pgCore.text("evaluation_suite_config_id").notNull(),
|
|
908
|
+
...timestamps
|
|
909
|
+
},
|
|
910
|
+
(table) => [
|
|
911
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
912
|
+
pgCore.foreignKey({
|
|
913
|
+
columns: [table.tenantId, table.projectId, table.evaluationRunConfigId],
|
|
914
|
+
foreignColumns: [
|
|
915
|
+
evaluationRunConfig.tenantId,
|
|
916
|
+
evaluationRunConfig.projectId,
|
|
917
|
+
evaluationRunConfig.id
|
|
918
|
+
],
|
|
919
|
+
name: "eval_run_config_eval_suite_rel_run_config_fk"
|
|
920
|
+
}).onDelete("cascade"),
|
|
921
|
+
pgCore.foreignKey({
|
|
922
|
+
columns: [table.tenantId, table.projectId, table.evaluationSuiteConfigId],
|
|
923
|
+
foreignColumns: [
|
|
924
|
+
evaluationSuiteConfig.tenantId,
|
|
925
|
+
evaluationSuiteConfig.projectId,
|
|
926
|
+
evaluationSuiteConfig.id
|
|
927
|
+
],
|
|
928
|
+
name: "eval_run_config_eval_suite_rel_suite_config_fk"
|
|
929
|
+
}).onDelete("cascade")
|
|
930
|
+
]
|
|
931
|
+
);
|
|
932
|
+
var evaluationJobConfig = pgCore.pgTable(
|
|
933
|
+
"evaluation_job_config",
|
|
934
|
+
{
|
|
935
|
+
...projectScoped,
|
|
936
|
+
jobFilters: pgCore.jsonb("job_filters").$type(),
|
|
937
|
+
...timestamps
|
|
938
|
+
},
|
|
939
|
+
(table) => [
|
|
940
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
941
|
+
pgCore.foreignKey({
|
|
942
|
+
columns: [table.tenantId, table.projectId],
|
|
943
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
944
|
+
name: "evaluation_job_config_project_fk"
|
|
945
|
+
}).onDelete("cascade")
|
|
946
|
+
]
|
|
947
|
+
);
|
|
948
|
+
var evaluationJobConfigEvaluatorRelations = pgCore.pgTable(
|
|
949
|
+
"evaluation_job_config_evaluator_relations",
|
|
950
|
+
{
|
|
951
|
+
...projectScoped,
|
|
952
|
+
evaluationJobConfigId: pgCore.text("evaluation_job_config_id").notNull(),
|
|
953
|
+
evaluatorId: pgCore.text("evaluator_id").notNull(),
|
|
954
|
+
...timestamps
|
|
955
|
+
},
|
|
956
|
+
(table) => [
|
|
957
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
958
|
+
pgCore.foreignKey({
|
|
959
|
+
columns: [table.tenantId, table.projectId, table.evaluationJobConfigId],
|
|
960
|
+
foreignColumns: [
|
|
961
|
+
evaluationJobConfig.tenantId,
|
|
962
|
+
evaluationJobConfig.projectId,
|
|
963
|
+
evaluationJobConfig.id
|
|
964
|
+
],
|
|
965
|
+
name: "evaluation_job_config_evaluator_relations_evaluation_job_config_fk"
|
|
966
|
+
}).onDelete("cascade"),
|
|
967
|
+
pgCore.foreignKey({
|
|
968
|
+
columns: [table.tenantId, table.projectId, table.evaluatorId],
|
|
969
|
+
foreignColumns: [evaluator.tenantId, evaluator.projectId, evaluator.id],
|
|
970
|
+
name: "evaluation_job_config_evaluator_relations_evaluator_fk"
|
|
971
|
+
}).onDelete("cascade")
|
|
972
|
+
]
|
|
973
|
+
);
|
|
974
|
+
var evaluationRun = pgCore.pgTable(
|
|
975
|
+
"evaluation_run",
|
|
976
|
+
{
|
|
977
|
+
...projectScoped,
|
|
978
|
+
evaluationJobConfigId: pgCore.text("evaluation_job_config_id"),
|
|
979
|
+
// Optional: if created from a job
|
|
980
|
+
evaluationRunConfigId: pgCore.text("evaluation_run_config_id"),
|
|
981
|
+
// Optional: if created from a run config
|
|
982
|
+
...timestamps
|
|
983
|
+
},
|
|
984
|
+
(table) => [
|
|
985
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
986
|
+
pgCore.foreignKey({
|
|
987
|
+
columns: [table.tenantId, table.projectId, table.evaluationJobConfigId],
|
|
988
|
+
foreignColumns: [
|
|
989
|
+
evaluationJobConfig.tenantId,
|
|
990
|
+
evaluationJobConfig.projectId,
|
|
991
|
+
evaluationJobConfig.id
|
|
992
|
+
],
|
|
993
|
+
name: "evaluation_run_evaluation_job_config_fk"
|
|
994
|
+
}).onDelete("cascade"),
|
|
995
|
+
pgCore.foreignKey({
|
|
996
|
+
columns: [table.tenantId, table.projectId, table.evaluationRunConfigId],
|
|
997
|
+
foreignColumns: [
|
|
998
|
+
evaluationRunConfig.tenantId,
|
|
999
|
+
evaluationRunConfig.projectId,
|
|
1000
|
+
evaluationRunConfig.id
|
|
1001
|
+
],
|
|
1002
|
+
name: "evaluation_run_evaluation_run_config_fk"
|
|
1003
|
+
}).onDelete("cascade")
|
|
1004
|
+
]
|
|
1005
|
+
);
|
|
1006
|
+
var evaluationResult = pgCore.pgTable(
|
|
1007
|
+
"evaluation_result",
|
|
1008
|
+
{
|
|
1009
|
+
...projectScoped,
|
|
1010
|
+
conversationId: pgCore.text("conversation_id").notNull(),
|
|
1011
|
+
evaluatorId: pgCore.text("evaluator_id").notNull(),
|
|
1012
|
+
evaluationRunId: pgCore.text("evaluation_run_id"),
|
|
1013
|
+
output: pgCore.jsonb("output").$type(),
|
|
1014
|
+
...timestamps
|
|
1015
|
+
},
|
|
1016
|
+
(table) => [
|
|
1017
|
+
pgCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
1018
|
+
pgCore.foreignKey({
|
|
1019
|
+
columns: [table.tenantId, table.projectId, table.conversationId],
|
|
1020
|
+
foreignColumns: [conversations.tenantId, conversations.projectId, conversations.id],
|
|
1021
|
+
name: "evaluation_result_conversation_fk"
|
|
1022
|
+
}).onDelete("cascade"),
|
|
1023
|
+
pgCore.foreignKey({
|
|
1024
|
+
columns: [table.tenantId, table.projectId, table.evaluatorId],
|
|
1025
|
+
foreignColumns: [evaluator.tenantId, evaluator.projectId, evaluator.id],
|
|
1026
|
+
name: "evaluation_result_evaluator_fk"
|
|
1027
|
+
}).onDelete("cascade"),
|
|
1028
|
+
pgCore.foreignKey({
|
|
1029
|
+
columns: [table.tenantId, table.projectId, table.evaluationRunId],
|
|
1030
|
+
foreignColumns: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.id],
|
|
1031
|
+
name: "evaluation_result_evaluation_run_fk"
|
|
1032
|
+
}).onDelete("cascade")
|
|
1033
|
+
]
|
|
1034
|
+
);
|
|
1035
|
+
drizzleOrm.relations(tasks, ({ one, many }) => ({
|
|
1036
|
+
project: one(projects, {
|
|
1037
|
+
fields: [tasks.tenantId, tasks.projectId],
|
|
1038
|
+
references: [projects.tenantId, projects.id]
|
|
1039
|
+
}),
|
|
1040
|
+
// A task can have many parent relationships (where it's the child)
|
|
1041
|
+
parentRelations: many(taskRelations, {
|
|
1042
|
+
relationName: "childTask"
|
|
1043
|
+
}),
|
|
1044
|
+
// A task can have many child relationships (where it's the parent)
|
|
1045
|
+
childRelations: many(taskRelations, {
|
|
1046
|
+
relationName: "parentTask"
|
|
1047
|
+
}),
|
|
1048
|
+
subAgent: one(subAgents, {
|
|
1049
|
+
fields: [tasks.subAgentId],
|
|
1050
|
+
references: [subAgents.id]
|
|
1051
|
+
}),
|
|
1052
|
+
messages: many(messages),
|
|
1053
|
+
ledgerArtifacts: many(ledgerArtifacts)
|
|
1054
|
+
}));
|
|
1055
|
+
drizzleOrm.relations(projects, ({ many }) => ({
|
|
1056
|
+
subAgents: many(subAgents),
|
|
1057
|
+
agents: many(agents),
|
|
1058
|
+
tools: many(tools),
|
|
1059
|
+
functions: many(functions),
|
|
1060
|
+
contextConfigs: many(contextConfigs),
|
|
1061
|
+
externalAgents: many(externalAgents),
|
|
1062
|
+
conversations: many(conversations),
|
|
1063
|
+
tasks: many(tasks),
|
|
1064
|
+
dataComponents: many(dataComponents),
|
|
1065
|
+
artifactComponents: many(artifactComponents),
|
|
1066
|
+
ledgerArtifacts: many(ledgerArtifacts),
|
|
1067
|
+
credentialReferences: many(credentialReferences),
|
|
1068
|
+
datasets: many(dataset),
|
|
1069
|
+
evaluators: many(evaluator),
|
|
1070
|
+
evaluationSuiteConfigs: many(evaluationSuiteConfig),
|
|
1071
|
+
datasetRunConfigs: many(datasetRunConfig)
|
|
1072
|
+
}));
|
|
1073
|
+
drizzleOrm.relations(taskRelations, ({ one }) => ({
|
|
1074
|
+
parentTask: one(tasks, {
|
|
1075
|
+
fields: [taskRelations.parentTaskId],
|
|
1076
|
+
references: [tasks.id],
|
|
1077
|
+
relationName: "parentTask"
|
|
1078
|
+
}),
|
|
1079
|
+
childTask: one(tasks, {
|
|
1080
|
+
fields: [taskRelations.childTaskId],
|
|
1081
|
+
references: [tasks.id],
|
|
1082
|
+
relationName: "childTask"
|
|
1083
|
+
})
|
|
1084
|
+
}));
|
|
1085
|
+
drizzleOrm.relations(contextConfigs, ({ many, one }) => ({
|
|
1086
|
+
project: one(projects, {
|
|
1087
|
+
fields: [contextConfigs.tenantId, contextConfigs.projectId],
|
|
1088
|
+
references: [projects.tenantId, projects.id]
|
|
1089
|
+
}),
|
|
1090
|
+
agents: many(agents),
|
|
1091
|
+
cache: many(contextCache)
|
|
1092
|
+
}));
|
|
1093
|
+
drizzleOrm.relations(contextCache, ({ one }) => ({
|
|
1094
|
+
contextConfig: one(contextConfigs, {
|
|
1095
|
+
fields: [contextCache.contextConfigId],
|
|
1096
|
+
references: [contextConfigs.id]
|
|
1097
|
+
})
|
|
1098
|
+
}));
|
|
1099
|
+
drizzleOrm.relations(subAgents, ({ many, one }) => ({
|
|
1100
|
+
project: one(projects, {
|
|
1101
|
+
fields: [subAgents.tenantId, subAgents.projectId],
|
|
1102
|
+
references: [projects.tenantId, projects.id]
|
|
1103
|
+
}),
|
|
1104
|
+
tasks: many(tasks),
|
|
1105
|
+
defaultForAgents: many(agents),
|
|
1106
|
+
sourceRelations: many(subAgentRelations, {
|
|
1107
|
+
relationName: "sourceRelations"
|
|
1108
|
+
}),
|
|
1109
|
+
targetRelations: many(subAgentRelations, {
|
|
1110
|
+
relationName: "targetRelations"
|
|
1111
|
+
}),
|
|
1112
|
+
sentMessages: many(messages, {
|
|
1113
|
+
relationName: "sentMessages"
|
|
1114
|
+
}),
|
|
1115
|
+
receivedMessages: many(messages, {
|
|
1116
|
+
relationName: "receivedMessages"
|
|
1117
|
+
}),
|
|
1118
|
+
toolRelations: many(subAgentToolRelations),
|
|
1119
|
+
functionToolRelations: many(subAgentFunctionToolRelations),
|
|
1120
|
+
dataComponentRelations: many(subAgentDataComponents),
|
|
1121
|
+
artifactComponentRelations: many(subAgentArtifactComponents)
|
|
1122
|
+
}));
|
|
1123
|
+
drizzleOrm.relations(agents, ({ one, many }) => ({
|
|
1124
|
+
project: one(projects, {
|
|
1125
|
+
fields: [agents.tenantId, agents.projectId],
|
|
1126
|
+
references: [projects.tenantId, projects.id]
|
|
1127
|
+
}),
|
|
1128
|
+
defaultSubAgent: one(subAgents, {
|
|
1129
|
+
fields: [agents.defaultSubAgentId],
|
|
1130
|
+
references: [subAgents.id]
|
|
1131
|
+
}),
|
|
1132
|
+
contextConfig: one(contextConfigs, {
|
|
1133
|
+
fields: [agents.contextConfigId],
|
|
1134
|
+
references: [contextConfigs.id]
|
|
1135
|
+
}),
|
|
1136
|
+
functionTools: many(functionTools)
|
|
1137
|
+
}));
|
|
1138
|
+
drizzleOrm.relations(externalAgents, ({ one, many }) => ({
|
|
1139
|
+
project: one(projects, {
|
|
1140
|
+
fields: [externalAgents.tenantId, externalAgents.projectId],
|
|
1141
|
+
references: [projects.tenantId, projects.id]
|
|
1142
|
+
}),
|
|
1143
|
+
subAgentExternalAgentRelations: many(subAgentExternalAgentRelations),
|
|
1144
|
+
credentialReference: one(credentialReferences, {
|
|
1145
|
+
fields: [externalAgents.credentialReferenceId],
|
|
1146
|
+
references: [credentialReferences.id]
|
|
1147
|
+
})
|
|
1148
|
+
}));
|
|
1149
|
+
drizzleOrm.relations(apiKeys, ({ one }) => ({
|
|
1150
|
+
project: one(projects, {
|
|
1151
|
+
fields: [apiKeys.tenantId, apiKeys.projectId],
|
|
1152
|
+
references: [projects.tenantId, projects.id]
|
|
1153
|
+
}),
|
|
1154
|
+
agent: one(agents, {
|
|
1155
|
+
fields: [apiKeys.agentId],
|
|
1156
|
+
references: [agents.id]
|
|
1157
|
+
})
|
|
1158
|
+
}));
|
|
1159
|
+
drizzleOrm.relations(subAgentToolRelations, ({ one }) => ({
|
|
1160
|
+
subAgent: one(subAgents, {
|
|
1161
|
+
fields: [subAgentToolRelations.subAgentId],
|
|
1162
|
+
references: [subAgents.id]
|
|
1163
|
+
}),
|
|
1164
|
+
tool: one(tools, {
|
|
1165
|
+
fields: [subAgentToolRelations.toolId],
|
|
1166
|
+
references: [tools.id]
|
|
1167
|
+
})
|
|
1168
|
+
}));
|
|
1169
|
+
drizzleOrm.relations(credentialReferences, ({ one, many }) => ({
|
|
1170
|
+
project: one(projects, {
|
|
1171
|
+
fields: [credentialReferences.tenantId, credentialReferences.projectId],
|
|
1172
|
+
references: [projects.tenantId, projects.id]
|
|
1173
|
+
}),
|
|
1174
|
+
tools: many(tools),
|
|
1175
|
+
externalAgents: many(externalAgents)
|
|
1176
|
+
}));
|
|
1177
|
+
drizzleOrm.relations(tools, ({ one, many }) => ({
|
|
1178
|
+
project: one(projects, {
|
|
1179
|
+
fields: [tools.tenantId, tools.projectId],
|
|
1180
|
+
references: [projects.tenantId, projects.id]
|
|
1181
|
+
}),
|
|
1182
|
+
subAgentRelations: many(subAgentToolRelations),
|
|
1183
|
+
credentialReference: one(credentialReferences, {
|
|
1184
|
+
fields: [tools.credentialReferenceId],
|
|
1185
|
+
references: [credentialReferences.id]
|
|
1186
|
+
})
|
|
1187
|
+
}));
|
|
1188
|
+
drizzleOrm.relations(conversations, ({ one, many }) => ({
|
|
1189
|
+
project: one(projects, {
|
|
1190
|
+
fields: [conversations.tenantId, conversations.projectId],
|
|
1191
|
+
references: [projects.tenantId, projects.id]
|
|
1192
|
+
}),
|
|
1193
|
+
messages: many(messages),
|
|
1194
|
+
activeSubAgent: one(subAgents, {
|
|
1195
|
+
fields: [conversations.activeSubAgentId],
|
|
1196
|
+
references: [subAgents.id]
|
|
1197
|
+
})
|
|
1198
|
+
}));
|
|
1199
|
+
drizzleOrm.relations(messages, ({ one, many }) => ({
|
|
1200
|
+
conversation: one(conversations, {
|
|
1201
|
+
fields: [messages.conversationId],
|
|
1202
|
+
references: [conversations.id]
|
|
1203
|
+
}),
|
|
1204
|
+
fromSubAgent: one(subAgents, {
|
|
1205
|
+
fields: [messages.fromSubAgentId],
|
|
1206
|
+
references: [subAgents.id],
|
|
1207
|
+
relationName: "sentMessages"
|
|
1208
|
+
}),
|
|
1209
|
+
toSubAgent: one(subAgents, {
|
|
1210
|
+
fields: [messages.toSubAgentId],
|
|
1211
|
+
references: [subAgents.id],
|
|
1212
|
+
relationName: "receivedMessages"
|
|
1213
|
+
}),
|
|
1214
|
+
fromTeamAgent: one(agents, {
|
|
1215
|
+
fields: [messages.fromTeamAgentId],
|
|
1216
|
+
references: [agents.id],
|
|
1217
|
+
relationName: "receivedTeamMessages"
|
|
1218
|
+
}),
|
|
1219
|
+
toTeamAgent: one(agents, {
|
|
1220
|
+
fields: [messages.toTeamAgentId],
|
|
1221
|
+
references: [agents.id],
|
|
1222
|
+
relationName: "sentTeamMessages"
|
|
1223
|
+
}),
|
|
1224
|
+
fromExternalAgent: one(externalAgents, {
|
|
1225
|
+
fields: [messages.tenantId, messages.projectId, messages.fromExternalAgentId],
|
|
1226
|
+
references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
|
|
1227
|
+
relationName: "receivedExternalMessages"
|
|
1228
|
+
}),
|
|
1229
|
+
toExternalAgent: one(externalAgents, {
|
|
1230
|
+
fields: [messages.tenantId, messages.projectId, messages.toExternalAgentId],
|
|
1231
|
+
references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
|
|
1232
|
+
relationName: "sentExternalMessages"
|
|
1233
|
+
}),
|
|
1234
|
+
task: one(tasks, {
|
|
1235
|
+
fields: [messages.taskId],
|
|
1236
|
+
references: [tasks.id]
|
|
1237
|
+
}),
|
|
1238
|
+
parentMessage: one(messages, {
|
|
1239
|
+
fields: [messages.parentMessageId],
|
|
1240
|
+
references: [messages.id],
|
|
1241
|
+
relationName: "parentChild"
|
|
1242
|
+
}),
|
|
1243
|
+
childMessages: many(messages, {
|
|
1244
|
+
relationName: "parentChild"
|
|
1245
|
+
})
|
|
1246
|
+
}));
|
|
1247
|
+
drizzleOrm.relations(artifactComponents, ({ many, one }) => ({
|
|
1248
|
+
project: one(projects, {
|
|
1249
|
+
fields: [artifactComponents.tenantId, artifactComponents.projectId],
|
|
1250
|
+
references: [projects.tenantId, projects.id]
|
|
1251
|
+
}),
|
|
1252
|
+
subAgentRelations: many(subAgentArtifactComponents)
|
|
1253
|
+
}));
|
|
1254
|
+
drizzleOrm.relations(
|
|
1255
|
+
subAgentArtifactComponents,
|
|
1256
|
+
({ one }) => ({
|
|
1257
|
+
subAgent: one(subAgents, {
|
|
1258
|
+
fields: [subAgentArtifactComponents.subAgentId],
|
|
1259
|
+
references: [subAgents.id]
|
|
1260
|
+
}),
|
|
1261
|
+
artifactComponent: one(artifactComponents, {
|
|
1262
|
+
fields: [subAgentArtifactComponents.artifactComponentId],
|
|
1263
|
+
references: [artifactComponents.id]
|
|
1264
|
+
})
|
|
1265
|
+
})
|
|
1266
|
+
);
|
|
1267
|
+
drizzleOrm.relations(dataComponents, ({ many, one }) => ({
|
|
1268
|
+
project: one(projects, {
|
|
1269
|
+
fields: [dataComponents.tenantId, dataComponents.projectId],
|
|
1270
|
+
references: [projects.tenantId, projects.id]
|
|
1271
|
+
}),
|
|
1272
|
+
subAgentRelations: many(subAgentDataComponents)
|
|
1273
|
+
}));
|
|
1274
|
+
drizzleOrm.relations(subAgentDataComponents, ({ one }) => ({
|
|
1275
|
+
subAgent: one(subAgents, {
|
|
1276
|
+
fields: [subAgentDataComponents.subAgentId],
|
|
1277
|
+
references: [subAgents.id]
|
|
1278
|
+
}),
|
|
1279
|
+
dataComponent: one(dataComponents, {
|
|
1280
|
+
fields: [subAgentDataComponents.dataComponentId],
|
|
1281
|
+
references: [dataComponents.id]
|
|
1282
|
+
})
|
|
1283
|
+
}));
|
|
1284
|
+
drizzleOrm.relations(ledgerArtifacts, ({ one }) => ({
|
|
1285
|
+
project: one(projects, {
|
|
1286
|
+
fields: [ledgerArtifacts.tenantId, ledgerArtifacts.projectId],
|
|
1287
|
+
references: [projects.tenantId, projects.id]
|
|
1288
|
+
}),
|
|
1289
|
+
task: one(tasks, {
|
|
1290
|
+
fields: [ledgerArtifacts.taskId],
|
|
1291
|
+
references: [tasks.id]
|
|
1292
|
+
})
|
|
1293
|
+
}));
|
|
1294
|
+
drizzleOrm.relations(functions, ({ many, one }) => ({
|
|
1295
|
+
functionTools: many(functionTools),
|
|
1296
|
+
project: one(projects, {
|
|
1297
|
+
fields: [functions.tenantId, functions.projectId],
|
|
1298
|
+
references: [projects.tenantId, projects.id]
|
|
1299
|
+
})
|
|
1300
|
+
}));
|
|
1301
|
+
drizzleOrm.relations(subAgentRelations, ({ one }) => ({
|
|
1302
|
+
agent: one(agents, {
|
|
1303
|
+
fields: [subAgentRelations.agentId],
|
|
1304
|
+
references: [agents.id]
|
|
1305
|
+
}),
|
|
1306
|
+
sourceSubAgent: one(subAgents, {
|
|
1307
|
+
fields: [subAgentRelations.sourceSubAgentId],
|
|
1308
|
+
references: [subAgents.id],
|
|
1309
|
+
relationName: "sourceRelations"
|
|
1310
|
+
}),
|
|
1311
|
+
targetSubAgent: one(subAgents, {
|
|
1312
|
+
fields: [subAgentRelations.targetSubAgentId],
|
|
1313
|
+
references: [subAgents.id],
|
|
1314
|
+
relationName: "targetRelations"
|
|
1315
|
+
})
|
|
1316
|
+
}));
|
|
1317
|
+
drizzleOrm.relations(functionTools, ({ one, many }) => ({
|
|
1318
|
+
project: one(projects, {
|
|
1319
|
+
fields: [functionTools.tenantId, functionTools.projectId],
|
|
1320
|
+
references: [projects.tenantId, projects.id]
|
|
1321
|
+
}),
|
|
1322
|
+
agent: one(agents, {
|
|
1323
|
+
fields: [functionTools.tenantId, functionTools.projectId, functionTools.agentId],
|
|
1324
|
+
references: [agents.tenantId, agents.projectId, agents.id]
|
|
1325
|
+
}),
|
|
1326
|
+
function: one(functions, {
|
|
1327
|
+
fields: [functionTools.tenantId, functionTools.projectId, functionTools.functionId],
|
|
1328
|
+
references: [functions.tenantId, functions.projectId, functions.id]
|
|
1329
|
+
}),
|
|
1330
|
+
subAgentRelations: many(subAgentFunctionToolRelations)
|
|
1331
|
+
}));
|
|
1332
|
+
drizzleOrm.relations(
|
|
1333
|
+
subAgentFunctionToolRelations,
|
|
1334
|
+
({ one }) => ({
|
|
1335
|
+
subAgent: one(subAgents, {
|
|
1336
|
+
fields: [subAgentFunctionToolRelations.subAgentId],
|
|
1337
|
+
references: [subAgents.id]
|
|
1338
|
+
}),
|
|
1339
|
+
functionTool: one(functionTools, {
|
|
1340
|
+
fields: [subAgentFunctionToolRelations.functionToolId],
|
|
1341
|
+
references: [functionTools.id]
|
|
1342
|
+
})
|
|
1343
|
+
})
|
|
1344
|
+
);
|
|
1345
|
+
drizzleOrm.relations(
|
|
1346
|
+
subAgentExternalAgentRelations,
|
|
1347
|
+
({ one }) => ({
|
|
1348
|
+
subAgent: one(subAgents, {
|
|
1349
|
+
fields: [
|
|
1350
|
+
subAgentExternalAgentRelations.tenantId,
|
|
1351
|
+
subAgentExternalAgentRelations.projectId,
|
|
1352
|
+
subAgentExternalAgentRelations.agentId,
|
|
1353
|
+
subAgentExternalAgentRelations.subAgentId
|
|
1354
|
+
],
|
|
1355
|
+
references: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id]
|
|
1356
|
+
}),
|
|
1357
|
+
externalAgent: one(externalAgents, {
|
|
1358
|
+
fields: [
|
|
1359
|
+
subAgentExternalAgentRelations.tenantId,
|
|
1360
|
+
subAgentExternalAgentRelations.projectId,
|
|
1361
|
+
subAgentExternalAgentRelations.externalAgentId
|
|
1362
|
+
],
|
|
1363
|
+
references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id]
|
|
1364
|
+
})
|
|
1365
|
+
})
|
|
1366
|
+
);
|
|
1367
|
+
drizzleOrm.relations(
|
|
1368
|
+
subAgentTeamAgentRelations,
|
|
1369
|
+
({ one }) => ({
|
|
1370
|
+
subAgent: one(subAgents, {
|
|
1371
|
+
fields: [
|
|
1372
|
+
subAgentTeamAgentRelations.tenantId,
|
|
1373
|
+
subAgentTeamAgentRelations.projectId,
|
|
1374
|
+
subAgentTeamAgentRelations.agentId,
|
|
1375
|
+
subAgentTeamAgentRelations.subAgentId
|
|
1376
|
+
],
|
|
1377
|
+
references: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id]
|
|
1378
|
+
}),
|
|
1379
|
+
targetAgent: one(agents, {
|
|
1380
|
+
fields: [
|
|
1381
|
+
subAgentTeamAgentRelations.tenantId,
|
|
1382
|
+
subAgentTeamAgentRelations.projectId,
|
|
1383
|
+
subAgentTeamAgentRelations.targetAgentId
|
|
1384
|
+
],
|
|
1385
|
+
references: [agents.tenantId, agents.projectId, agents.id]
|
|
1386
|
+
})
|
|
1387
|
+
})
|
|
1388
|
+
);
|
|
1389
|
+
drizzleOrm.relations(dataset, ({ one, many }) => ({
|
|
1390
|
+
project: one(projects, {
|
|
1391
|
+
fields: [dataset.tenantId, dataset.projectId],
|
|
1392
|
+
references: [projects.tenantId, projects.id]
|
|
1393
|
+
}),
|
|
1394
|
+
items: many(datasetItem),
|
|
1395
|
+
datasetRuns: many(datasetRun)
|
|
1396
|
+
}));
|
|
1397
|
+
drizzleOrm.relations(datasetItem, ({ one }) => ({
|
|
1398
|
+
dataset: one(dataset, {
|
|
1399
|
+
fields: [datasetItem.tenantId, datasetItem.projectId, datasetItem.datasetId],
|
|
1400
|
+
references: [dataset.tenantId, dataset.projectId, dataset.id]
|
|
1401
|
+
})
|
|
1402
|
+
}));
|
|
1403
|
+
drizzleOrm.relations(evaluator, ({ one, many }) => ({
|
|
1404
|
+
project: one(projects, {
|
|
1405
|
+
fields: [evaluator.tenantId, evaluator.projectId],
|
|
1406
|
+
references: [projects.tenantId, projects.id]
|
|
1407
|
+
}),
|
|
1408
|
+
evaluationResults: many(evaluationResult),
|
|
1409
|
+
evaluationSuiteConfigs: many(evaluationSuiteConfigEvaluatorRelations),
|
|
1410
|
+
evaluationJobConfigs: many(evaluationJobConfigEvaluatorRelations)
|
|
1411
|
+
}));
|
|
1412
|
+
drizzleOrm.relations(datasetRunConfig, ({ one, many }) => ({
|
|
1413
|
+
project: one(projects, {
|
|
1414
|
+
fields: [datasetRunConfig.tenantId, datasetRunConfig.projectId],
|
|
1415
|
+
references: [projects.tenantId, projects.id]
|
|
1416
|
+
}),
|
|
1417
|
+
dataset: one(dataset, {
|
|
1418
|
+
fields: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.datasetId],
|
|
1419
|
+
references: [dataset.tenantId, dataset.projectId, dataset.id]
|
|
1420
|
+
}),
|
|
1421
|
+
agents: many(datasetRunConfigAgentRelations),
|
|
1422
|
+
evaluationRunConfigs: many(datasetRunConfigEvaluationRunConfigRelations),
|
|
1423
|
+
runs: many(datasetRun)
|
|
1424
|
+
}));
|
|
1425
|
+
drizzleOrm.relations(
|
|
1426
|
+
datasetRunConfigAgentRelations,
|
|
1427
|
+
({ one }) => ({
|
|
1428
|
+
datasetRunConfig: one(datasetRunConfig, {
|
|
1429
|
+
fields: [
|
|
1430
|
+
datasetRunConfigAgentRelations.tenantId,
|
|
1431
|
+
datasetRunConfigAgentRelations.projectId,
|
|
1432
|
+
datasetRunConfigAgentRelations.datasetRunConfigId
|
|
1433
|
+
],
|
|
1434
|
+
references: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id]
|
|
1435
|
+
}),
|
|
1436
|
+
agent: one(agents, {
|
|
1437
|
+
fields: [
|
|
1438
|
+
datasetRunConfigAgentRelations.tenantId,
|
|
1439
|
+
datasetRunConfigAgentRelations.projectId,
|
|
1440
|
+
datasetRunConfigAgentRelations.agentId
|
|
1441
|
+
],
|
|
1442
|
+
references: [agents.tenantId, agents.projectId, agents.id]
|
|
1443
|
+
})
|
|
1444
|
+
})
|
|
1445
|
+
);
|
|
1446
|
+
drizzleOrm.relations(
|
|
1447
|
+
datasetRunConfigEvaluationRunConfigRelations,
|
|
1448
|
+
({ one }) => ({
|
|
1449
|
+
datasetRunConfig: one(datasetRunConfig, {
|
|
1450
|
+
fields: [
|
|
1451
|
+
datasetRunConfigEvaluationRunConfigRelations.tenantId,
|
|
1452
|
+
datasetRunConfigEvaluationRunConfigRelations.projectId,
|
|
1453
|
+
datasetRunConfigEvaluationRunConfigRelations.datasetRunConfigId
|
|
1454
|
+
],
|
|
1455
|
+
references: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id]
|
|
1456
|
+
}),
|
|
1457
|
+
evaluationRunConfig: one(evaluationRunConfig, {
|
|
1458
|
+
fields: [
|
|
1459
|
+
datasetRunConfigEvaluationRunConfigRelations.tenantId,
|
|
1460
|
+
datasetRunConfigEvaluationRunConfigRelations.projectId,
|
|
1461
|
+
datasetRunConfigEvaluationRunConfigRelations.evaluationRunConfigId
|
|
1462
|
+
],
|
|
1463
|
+
references: [
|
|
1464
|
+
evaluationRunConfig.tenantId,
|
|
1465
|
+
evaluationRunConfig.projectId,
|
|
1466
|
+
evaluationRunConfig.id
|
|
1467
|
+
]
|
|
1468
|
+
})
|
|
1469
|
+
})
|
|
1470
|
+
);
|
|
1471
|
+
drizzleOrm.relations(datasetRun, ({ one, many }) => ({
|
|
1472
|
+
dataset: one(dataset, {
|
|
1473
|
+
fields: [datasetRun.tenantId, datasetRun.projectId, datasetRun.datasetId],
|
|
1474
|
+
references: [dataset.tenantId, dataset.projectId, dataset.id]
|
|
1475
|
+
}),
|
|
1476
|
+
datasetRunConfig: one(datasetRunConfig, {
|
|
1477
|
+
fields: [datasetRun.tenantId, datasetRun.projectId, datasetRun.datasetRunConfigId],
|
|
1478
|
+
references: [datasetRunConfig.tenantId, datasetRunConfig.projectId, datasetRunConfig.id]
|
|
1479
|
+
}),
|
|
1480
|
+
conversations: many(datasetRunConversationRelations)
|
|
1481
|
+
}));
|
|
1482
|
+
drizzleOrm.relations(evaluationSuiteConfig, ({ one, many }) => ({
|
|
1483
|
+
project: one(projects, {
|
|
1484
|
+
fields: [evaluationSuiteConfig.tenantId, evaluationSuiteConfig.projectId],
|
|
1485
|
+
references: [projects.tenantId, projects.id]
|
|
1486
|
+
}),
|
|
1487
|
+
runConfigs: many(evaluationRunConfigEvaluationSuiteConfigRelations),
|
|
1488
|
+
evaluators: many(evaluationSuiteConfigEvaluatorRelations)
|
|
1489
|
+
}));
|
|
1490
|
+
drizzleOrm.relations(
|
|
1491
|
+
evaluationSuiteConfigEvaluatorRelations,
|
|
1492
|
+
({ one }) => ({
|
|
1493
|
+
evaluationSuiteConfig: one(evaluationSuiteConfig, {
|
|
1494
|
+
fields: [
|
|
1495
|
+
evaluationSuiteConfigEvaluatorRelations.tenantId,
|
|
1496
|
+
evaluationSuiteConfigEvaluatorRelations.projectId,
|
|
1497
|
+
evaluationSuiteConfigEvaluatorRelations.evaluationSuiteConfigId
|
|
1498
|
+
],
|
|
1499
|
+
references: [
|
|
1500
|
+
evaluationSuiteConfig.tenantId,
|
|
1501
|
+
evaluationSuiteConfig.projectId,
|
|
1502
|
+
evaluationSuiteConfig.id
|
|
1503
|
+
]
|
|
1504
|
+
}),
|
|
1505
|
+
evaluator: one(evaluator, {
|
|
1506
|
+
fields: [
|
|
1507
|
+
evaluationSuiteConfigEvaluatorRelations.tenantId,
|
|
1508
|
+
evaluationSuiteConfigEvaluatorRelations.projectId,
|
|
1509
|
+
evaluationSuiteConfigEvaluatorRelations.evaluatorId
|
|
1510
|
+
],
|
|
1511
|
+
references: [evaluator.tenantId, evaluator.projectId, evaluator.id]
|
|
1512
|
+
})
|
|
1513
|
+
})
|
|
1514
|
+
);
|
|
1515
|
+
drizzleOrm.relations(
|
|
1516
|
+
evaluationJobConfigEvaluatorRelations,
|
|
1517
|
+
({ one }) => ({
|
|
1518
|
+
evaluationJobConfig: one(evaluationJobConfig, {
|
|
1519
|
+
fields: [
|
|
1520
|
+
evaluationJobConfigEvaluatorRelations.tenantId,
|
|
1521
|
+
evaluationJobConfigEvaluatorRelations.projectId,
|
|
1522
|
+
evaluationJobConfigEvaluatorRelations.evaluationJobConfigId
|
|
1523
|
+
],
|
|
1524
|
+
references: [
|
|
1525
|
+
evaluationJobConfig.tenantId,
|
|
1526
|
+
evaluationJobConfig.projectId,
|
|
1527
|
+
evaluationJobConfig.id
|
|
1528
|
+
]
|
|
1529
|
+
}),
|
|
1530
|
+
evaluator: one(evaluator, {
|
|
1531
|
+
fields: [
|
|
1532
|
+
evaluationJobConfigEvaluatorRelations.tenantId,
|
|
1533
|
+
evaluationJobConfigEvaluatorRelations.projectId,
|
|
1534
|
+
evaluationJobConfigEvaluatorRelations.evaluatorId
|
|
1535
|
+
],
|
|
1536
|
+
references: [evaluator.tenantId, evaluator.projectId, evaluator.id]
|
|
1537
|
+
})
|
|
1538
|
+
})
|
|
1539
|
+
);
|
|
1540
|
+
drizzleOrm.relations(evaluationJobConfig, ({ one, many }) => ({
|
|
1541
|
+
project: one(projects, {
|
|
1542
|
+
fields: [evaluationJobConfig.tenantId, evaluationJobConfig.projectId],
|
|
1543
|
+
references: [projects.tenantId, projects.id]
|
|
1544
|
+
}),
|
|
1545
|
+
run: one(evaluationRun, {
|
|
1546
|
+
fields: [evaluationJobConfig.tenantId, evaluationJobConfig.projectId, evaluationJobConfig.id],
|
|
1547
|
+
references: [
|
|
1548
|
+
evaluationRun.tenantId,
|
|
1549
|
+
evaluationRun.projectId,
|
|
1550
|
+
evaluationRun.evaluationJobConfigId
|
|
1551
|
+
]
|
|
1552
|
+
}),
|
|
1553
|
+
evaluators: many(evaluationJobConfigEvaluatorRelations)
|
|
1554
|
+
}));
|
|
1555
|
+
drizzleOrm.relations(
|
|
1556
|
+
evaluationRunConfigEvaluationSuiteConfigRelations,
|
|
1557
|
+
({ one }) => ({
|
|
1558
|
+
evaluationRunConfig: one(evaluationRunConfig, {
|
|
1559
|
+
fields: [
|
|
1560
|
+
evaluationRunConfigEvaluationSuiteConfigRelations.tenantId,
|
|
1561
|
+
evaluationRunConfigEvaluationSuiteConfigRelations.projectId,
|
|
1562
|
+
evaluationRunConfigEvaluationSuiteConfigRelations.evaluationRunConfigId
|
|
1563
|
+
],
|
|
1564
|
+
references: [
|
|
1565
|
+
evaluationRunConfig.tenantId,
|
|
1566
|
+
evaluationRunConfig.projectId,
|
|
1567
|
+
evaluationRunConfig.id
|
|
1568
|
+
]
|
|
1569
|
+
}),
|
|
1570
|
+
evaluationSuiteConfig: one(evaluationSuiteConfig, {
|
|
1571
|
+
fields: [
|
|
1572
|
+
evaluationRunConfigEvaluationSuiteConfigRelations.tenantId,
|
|
1573
|
+
evaluationRunConfigEvaluationSuiteConfigRelations.projectId,
|
|
1574
|
+
evaluationRunConfigEvaluationSuiteConfigRelations.evaluationSuiteConfigId
|
|
1575
|
+
],
|
|
1576
|
+
references: [
|
|
1577
|
+
evaluationSuiteConfig.tenantId,
|
|
1578
|
+
evaluationSuiteConfig.projectId,
|
|
1579
|
+
evaluationSuiteConfig.id
|
|
1580
|
+
]
|
|
1581
|
+
})
|
|
1582
|
+
})
|
|
1583
|
+
);
|
|
1584
|
+
drizzleOrm.relations(evaluationRunConfig, ({ one, many }) => ({
|
|
1585
|
+
project: one(projects, {
|
|
1586
|
+
fields: [evaluationRunConfig.tenantId, evaluationRunConfig.projectId],
|
|
1587
|
+
references: [projects.tenantId, projects.id]
|
|
1588
|
+
}),
|
|
1589
|
+
suiteConfigs: many(evaluationRunConfigEvaluationSuiteConfigRelations),
|
|
1590
|
+
datasetRunConfigs: many(datasetRunConfigEvaluationRunConfigRelations),
|
|
1591
|
+
runs: many(evaluationRun)
|
|
1592
|
+
}));
|
|
1593
|
+
drizzleOrm.relations(evaluationRun, ({ one, many }) => ({
|
|
1594
|
+
evaluationJobConfig: one(evaluationJobConfig, {
|
|
1595
|
+
fields: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.evaluationJobConfigId],
|
|
1596
|
+
references: [
|
|
1597
|
+
evaluationJobConfig.tenantId,
|
|
1598
|
+
evaluationJobConfig.projectId,
|
|
1599
|
+
evaluationJobConfig.id
|
|
1600
|
+
]
|
|
1601
|
+
}),
|
|
1602
|
+
evaluationRunConfig: one(evaluationRunConfig, {
|
|
1603
|
+
fields: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.evaluationRunConfigId],
|
|
1604
|
+
references: [
|
|
1605
|
+
evaluationRunConfig.tenantId,
|
|
1606
|
+
evaluationRunConfig.projectId,
|
|
1607
|
+
evaluationRunConfig.id
|
|
1608
|
+
]
|
|
1609
|
+
}),
|
|
1610
|
+
results: many(evaluationResult)
|
|
1611
|
+
}));
|
|
1612
|
+
drizzleOrm.relations(evaluationResult, ({ one }) => ({
|
|
1613
|
+
conversation: one(conversations, {
|
|
1614
|
+
fields: [
|
|
1615
|
+
evaluationResult.tenantId,
|
|
1616
|
+
evaluationResult.projectId,
|
|
1617
|
+
evaluationResult.conversationId
|
|
1618
|
+
],
|
|
1619
|
+
references: [conversations.tenantId, conversations.projectId, conversations.id],
|
|
1620
|
+
relationName: "conversationEvaluationResults"
|
|
1621
|
+
}),
|
|
1622
|
+
evaluator: one(evaluator, {
|
|
1623
|
+
fields: [evaluationResult.tenantId, evaluationResult.projectId, evaluationResult.evaluatorId],
|
|
1624
|
+
references: [evaluator.tenantId, evaluator.projectId, evaluator.id]
|
|
1625
|
+
}),
|
|
1626
|
+
evaluationRun: one(evaluationRun, {
|
|
1627
|
+
fields: [
|
|
1628
|
+
evaluationResult.tenantId,
|
|
1629
|
+
evaluationResult.projectId,
|
|
1630
|
+
evaluationResult.evaluationRunId
|
|
1631
|
+
],
|
|
1632
|
+
references: [evaluationRun.tenantId, evaluationRun.projectId, evaluationRun.id]
|
|
1633
|
+
})
|
|
1634
|
+
}));
|
|
1635
|
+
drizzleOrm.relations(conversations, ({ many }) => ({
|
|
1636
|
+
evaluationResults: many(evaluationResult, {
|
|
1637
|
+
relationName: "conversationEvaluationResults"
|
|
1638
|
+
})
|
|
1639
|
+
}));
|
|
1640
|
+
drizzleOrm.relations(
|
|
1641
|
+
datasetRunConversationRelations,
|
|
1642
|
+
({ one }) => ({
|
|
1643
|
+
datasetRun: one(datasetRun, {
|
|
1644
|
+
fields: [
|
|
1645
|
+
datasetRunConversationRelations.tenantId,
|
|
1646
|
+
datasetRunConversationRelations.projectId,
|
|
1647
|
+
datasetRunConversationRelations.datasetRunId
|
|
1648
|
+
],
|
|
1649
|
+
references: [datasetRun.tenantId, datasetRun.projectId, datasetRun.id]
|
|
1650
|
+
}),
|
|
1651
|
+
conversation: one(conversations, {
|
|
1652
|
+
fields: [
|
|
1653
|
+
datasetRunConversationRelations.tenantId,
|
|
1654
|
+
datasetRunConversationRelations.projectId,
|
|
1655
|
+
datasetRunConversationRelations.conversationId
|
|
1656
|
+
],
|
|
1657
|
+
references: [conversations.tenantId, conversations.projectId, conversations.id]
|
|
1658
|
+
})
|
|
1659
|
+
})
|
|
1660
|
+
);
|
|
1661
|
+
var MIN_ID_LENGTH = 1;
|
|
1662
|
+
var MAX_ID_LENGTH = 255;
|
|
1663
|
+
var URL_SAFE_ID_PATTERN = /^[a-zA-Z0-9\-_.]+$/;
|
|
1664
|
+
var resourceIdSchema = zodOpenapi.z.string().min(MIN_ID_LENGTH).max(MAX_ID_LENGTH).describe("Resource identifier").regex(URL_SAFE_ID_PATTERN, {
|
|
1665
|
+
message: "ID must contain only letters, numbers, hyphens, underscores, and dots"
|
|
1666
|
+
}).openapi({
|
|
1667
|
+
description: "Resource identifier",
|
|
1668
|
+
example: "resource_789"
|
|
1669
|
+
});
|
|
1670
|
+
resourceIdSchema.meta({
|
|
1671
|
+
description: "Resource identifier"
|
|
1672
|
+
});
|
|
1673
|
+
var FIELD_MODIFIERS = {
|
|
1674
|
+
id: (schema) => {
|
|
1675
|
+
const modified = schema.min(MIN_ID_LENGTH).max(MAX_ID_LENGTH).describe("Resource identifier").regex(URL_SAFE_ID_PATTERN, {
|
|
1676
|
+
message: "ID must contain only letters, numbers, hyphens, underscores, and dots"
|
|
1677
|
+
}).openapi({
|
|
1678
|
+
description: "Resource identifier",
|
|
1679
|
+
example: "resource_789"
|
|
1680
|
+
});
|
|
1681
|
+
modified.meta({
|
|
1682
|
+
description: "Resource identifier"
|
|
1683
|
+
});
|
|
1684
|
+
return modified;
|
|
1685
|
+
},
|
|
1686
|
+
name: (_schema) => {
|
|
1687
|
+
const modified = zodOpenapi.z.string().describe("Name");
|
|
1688
|
+
modified.meta({ description: "Name" });
|
|
1689
|
+
return modified;
|
|
1690
|
+
},
|
|
1691
|
+
description: (_schema) => {
|
|
1692
|
+
const modified = zodOpenapi.z.string().describe("Description");
|
|
1693
|
+
modified.meta({ description: "Description" });
|
|
1694
|
+
return modified;
|
|
1695
|
+
},
|
|
1696
|
+
tenantId: (schema) => {
|
|
1697
|
+
const modified = schema.describe("Tenant identifier");
|
|
1698
|
+
modified.meta({ description: "Tenant identifier" });
|
|
1699
|
+
return modified;
|
|
1700
|
+
},
|
|
1701
|
+
projectId: (schema) => {
|
|
1702
|
+
const modified = schema.describe("Project identifier");
|
|
1703
|
+
modified.meta({ description: "Project identifier" });
|
|
1704
|
+
return modified;
|
|
1705
|
+
},
|
|
1706
|
+
agentId: (schema) => {
|
|
1707
|
+
const modified = schema.describe("Agent identifier");
|
|
1708
|
+
modified.meta({ description: "Agent identifier" });
|
|
1709
|
+
return modified;
|
|
1710
|
+
},
|
|
1711
|
+
subAgentId: (schema) => {
|
|
1712
|
+
const modified = schema.describe("Sub-agent identifier");
|
|
1713
|
+
modified.meta({ description: "Sub-agent identifier" });
|
|
1714
|
+
return modified;
|
|
1715
|
+
},
|
|
1716
|
+
createdAt: (schema) => {
|
|
1717
|
+
const modified = schema.describe("Creation timestamp");
|
|
1718
|
+
modified.meta({ description: "Creation timestamp" });
|
|
1719
|
+
return modified;
|
|
1720
|
+
},
|
|
1721
|
+
updatedAt: (schema) => {
|
|
1722
|
+
const modified = schema.describe("Last update timestamp");
|
|
1723
|
+
modified.meta({ description: "Last update timestamp" });
|
|
1724
|
+
return modified;
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
function createSelectSchemaWithModifiers(table, overrides) {
|
|
1728
|
+
const tableColumns = table._?.columns;
|
|
1729
|
+
if (!tableColumns) {
|
|
1730
|
+
return drizzleZod.createSelectSchema(table, overrides);
|
|
1731
|
+
}
|
|
1732
|
+
const tableFieldNames = Object.keys(tableColumns);
|
|
1733
|
+
const modifiers = {};
|
|
1734
|
+
for (const fieldName of tableFieldNames) {
|
|
1735
|
+
const fieldNameStr = String(fieldName);
|
|
1736
|
+
if (fieldNameStr in FIELD_MODIFIERS) {
|
|
1737
|
+
modifiers[fieldNameStr] = FIELD_MODIFIERS[fieldNameStr];
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
const mergedModifiers = { ...modifiers, ...overrides };
|
|
1741
|
+
return drizzleZod.createSelectSchema(table, mergedModifiers);
|
|
1742
|
+
}
|
|
1743
|
+
function createInsertSchemaWithModifiers(table, overrides) {
|
|
1744
|
+
const tableColumns = table._?.columns;
|
|
1745
|
+
if (!tableColumns) {
|
|
1746
|
+
return drizzleZod.createInsertSchema(table, overrides);
|
|
1747
|
+
}
|
|
1748
|
+
const tableFieldNames = Object.keys(tableColumns);
|
|
1749
|
+
const modifiers = {};
|
|
1750
|
+
for (const fieldName of tableFieldNames) {
|
|
1751
|
+
const fieldNameStr = String(fieldName);
|
|
1752
|
+
if (fieldNameStr in FIELD_MODIFIERS) {
|
|
1753
|
+
modifiers[fieldNameStr] = FIELD_MODIFIERS[fieldNameStr];
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
const mergedModifiers = { ...modifiers, ...overrides };
|
|
1757
|
+
return drizzleZod.createInsertSchema(table, mergedModifiers);
|
|
1758
|
+
}
|
|
1759
|
+
var createSelectSchema = createSelectSchemaWithModifiers;
|
|
1760
|
+
var createInsertSchema = createInsertSchemaWithModifiers;
|
|
1761
|
+
function registerFieldSchemas(schema) {
|
|
1762
|
+
if (!(schema instanceof zodOpenapi.z.ZodObject)) {
|
|
1763
|
+
return schema;
|
|
1764
|
+
}
|
|
1765
|
+
const shape = schema.shape;
|
|
1766
|
+
const fieldMetadata = {
|
|
1767
|
+
id: { description: "Resource identifier" },
|
|
1768
|
+
name: { description: "Name" },
|
|
1769
|
+
description: { description: "Description" },
|
|
1770
|
+
tenantId: { description: "Tenant identifier" },
|
|
1771
|
+
projectId: { description: "Project identifier" },
|
|
1772
|
+
agentId: { description: "Agent identifier" },
|
|
1773
|
+
subAgentId: { description: "Sub-agent identifier" },
|
|
1774
|
+
createdAt: { description: "Creation timestamp" },
|
|
1775
|
+
updatedAt: { description: "Last update timestamp" }
|
|
1776
|
+
};
|
|
1777
|
+
for (const [fieldName, fieldSchema] of Object.entries(shape)) {
|
|
1778
|
+
if (fieldName in fieldMetadata && fieldSchema) {
|
|
1779
|
+
let zodFieldSchema = fieldSchema;
|
|
1780
|
+
let innerSchema = null;
|
|
1781
|
+
if (zodFieldSchema instanceof zodOpenapi.z.ZodOptional) {
|
|
1782
|
+
innerSchema = zodFieldSchema._def.innerType;
|
|
1783
|
+
zodFieldSchema = innerSchema;
|
|
1784
|
+
}
|
|
1785
|
+
zodFieldSchema.meta(fieldMetadata[fieldName]);
|
|
1786
|
+
if (fieldName === "id" && zodFieldSchema instanceof zodOpenapi.z.ZodString) {
|
|
1787
|
+
zodFieldSchema.openapi({
|
|
1788
|
+
description: "Resource identifier",
|
|
1789
|
+
minLength: MIN_ID_LENGTH,
|
|
1790
|
+
maxLength: MAX_ID_LENGTH,
|
|
1791
|
+
pattern: URL_SAFE_ID_PATTERN.source,
|
|
1792
|
+
example: "resource_789"
|
|
1793
|
+
});
|
|
1794
|
+
} else if (zodFieldSchema instanceof zodOpenapi.z.ZodString) {
|
|
1795
|
+
zodFieldSchema.openapi({
|
|
1796
|
+
description: fieldMetadata[fieldName].description
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
if (innerSchema && fieldSchema instanceof zodOpenapi.z.ZodOptional) {
|
|
1800
|
+
fieldSchema.meta(fieldMetadata[fieldName]);
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
return schema;
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
// src/validation/schemas.ts
|
|
1808
|
+
var {
|
|
1809
|
+
AGENT_EXECUTION_TRANSFER_COUNT_MAX,
|
|
1810
|
+
AGENT_EXECUTION_TRANSFER_COUNT_MIN,
|
|
1811
|
+
CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT,
|
|
1812
|
+
STATUS_UPDATE_MAX_INTERVAL_SECONDS,
|
|
1813
|
+
STATUS_UPDATE_MAX_NUM_EVENTS,
|
|
1814
|
+
SUB_AGENT_TURN_GENERATION_STEPS_MAX,
|
|
1815
|
+
SUB_AGENT_TURN_GENERATION_STEPS_MIN,
|
|
1816
|
+
VALIDATION_AGENT_PROMPT_MAX_CHARS,
|
|
1817
|
+
VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS
|
|
1818
|
+
} = schemaValidationDefaults;
|
|
1819
|
+
var StopWhenSchema = zodOpenapi.z.object({
|
|
1820
|
+
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."),
|
|
1821
|
+
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.")
|
|
1822
|
+
}).openapi("StopWhen");
|
|
1823
|
+
var AgentStopWhenSchema = StopWhenSchema.pick({ transferCountIs: true }).openapi(
|
|
1824
|
+
"AgentStopWhen"
|
|
1825
|
+
);
|
|
1826
|
+
var SubAgentStopWhenSchema = StopWhenSchema.pick({ stepCountIs: true }).openapi(
|
|
1827
|
+
"SubAgentStopWhen"
|
|
1828
|
+
);
|
|
1829
|
+
var pageNumber = zodOpenapi.z.coerce.number().min(1).default(1).openapi("PaginationPageQueryParam");
|
|
1830
|
+
var limitNumber = zodOpenapi.z.coerce.number().min(1).max(100).default(10).openapi("PaginationLimitQueryParam");
|
|
1831
|
+
var ModelSettingsSchema = zodOpenapi.z.object({
|
|
1832
|
+
model: zodOpenapi.z.string().optional().describe("The model to use for the project."),
|
|
1833
|
+
providerOptions: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.any()).optional().describe("The provider options to use for the project.")
|
|
1834
|
+
}).openapi("ModelSettings");
|
|
1835
|
+
var ModelSchema = zodOpenapi.z.object({
|
|
1836
|
+
base: ModelSettingsSchema.optional(),
|
|
1837
|
+
structuredOutput: ModelSettingsSchema.optional(),
|
|
1838
|
+
summarizer: ModelSettingsSchema.optional()
|
|
1839
|
+
}).openapi("Model");
|
|
1840
|
+
var ProjectModelSchema = zodOpenapi.z.object({
|
|
1841
|
+
base: ModelSettingsSchema,
|
|
1842
|
+
structuredOutput: ModelSettingsSchema.optional(),
|
|
1843
|
+
summarizer: ModelSettingsSchema.optional()
|
|
1844
|
+
}).openapi("ProjectModel");
|
|
1845
|
+
zodOpenapi.z.object({
|
|
1846
|
+
name: zodOpenapi.z.string(),
|
|
1847
|
+
description: zodOpenapi.z.string(),
|
|
1848
|
+
inputSchema: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()),
|
|
1849
|
+
dependencies: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).optional(),
|
|
1850
|
+
execute: zodOpenapi.z.union([zodOpenapi.z.function(), zodOpenapi.z.string()])
|
|
1851
|
+
});
|
|
1852
|
+
var createApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
|
|
1853
|
+
var createApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
|
|
1854
|
+
var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true }).partial();
|
|
1855
|
+
var createAgentScopedApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true, agentId: true });
|
|
1856
|
+
var createAgentScopedApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true, agentId: true });
|
|
1857
|
+
var createAgentScopedApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true, agentId: true }).partial();
|
|
1858
|
+
var SubAgentSelectSchema = createSelectSchema(subAgents);
|
|
1859
|
+
var SubAgentInsertSchema = createInsertSchema(subAgents).extend({
|
|
1860
|
+
id: resourceIdSchema,
|
|
1861
|
+
models: ModelSchema.optional()
|
|
1862
|
+
});
|
|
1863
|
+
var SubAgentUpdateSchema = SubAgentInsertSchema.partial();
|
|
1864
|
+
var SubAgentApiSelectSchema = createAgentScopedApiSchema(SubAgentSelectSchema).openapi("SubAgent");
|
|
1865
|
+
var SubAgentApiInsertSchema = createAgentScopedApiInsertSchema(SubAgentInsertSchema).openapi("SubAgentCreate");
|
|
1866
|
+
createAgentScopedApiUpdateSchema(SubAgentUpdateSchema).openapi("SubAgentUpdate");
|
|
1867
|
+
var SubAgentRelationSelectSchema = createSelectSchema(subAgentRelations);
|
|
1868
|
+
var SubAgentRelationInsertSchema = createInsertSchema(subAgentRelations).extend({
|
|
1869
|
+
id: resourceIdSchema,
|
|
1870
|
+
agentId: resourceIdSchema,
|
|
1871
|
+
sourceSubAgentId: resourceIdSchema,
|
|
1872
|
+
targetSubAgentId: resourceIdSchema.optional(),
|
|
1873
|
+
externalSubAgentId: resourceIdSchema.optional(),
|
|
1874
|
+
teamSubAgentId: resourceIdSchema.optional()
|
|
1875
|
+
});
|
|
1876
|
+
var SubAgentRelationUpdateSchema = SubAgentRelationInsertSchema.partial();
|
|
1877
|
+
var SubAgentRelationApiSelectSchema = createAgentScopedApiSchema(
|
|
1878
|
+
SubAgentRelationSelectSchema
|
|
1879
|
+
).openapi("SubAgentRelation");
|
|
1880
|
+
createAgentScopedApiInsertSchema(
|
|
1881
|
+
SubAgentRelationInsertSchema
|
|
1882
|
+
).extend({
|
|
1883
|
+
relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES)
|
|
1884
|
+
}).refine(
|
|
1885
|
+
(data) => {
|
|
1886
|
+
const hasTarget = data.targetSubAgentId != null;
|
|
1887
|
+
const hasExternal = data.externalSubAgentId != null;
|
|
1888
|
+
const hasTeam = data.teamSubAgentId != null;
|
|
1889
|
+
const count = [hasTarget, hasExternal, hasTeam].filter(Boolean).length;
|
|
1890
|
+
return count === 1;
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
message: "Must specify exactly one of targetSubAgentId, externalSubAgentId, or teamSubAgentId",
|
|
1894
|
+
path: ["targetSubAgentId", "externalSubAgentId", "teamSubAgentId"]
|
|
1895
|
+
}
|
|
1896
|
+
).openapi("SubAgentRelationCreate");
|
|
1897
|
+
createAgentScopedApiUpdateSchema(
|
|
1898
|
+
SubAgentRelationUpdateSchema
|
|
1899
|
+
).extend({
|
|
1900
|
+
relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES).optional()
|
|
1901
|
+
}).refine(
|
|
1902
|
+
(data) => {
|
|
1903
|
+
const hasTarget = data.targetSubAgentId != null;
|
|
1904
|
+
const hasExternal = data.externalSubAgentId != null;
|
|
1905
|
+
const hasTeam = data.teamSubAgentId != null;
|
|
1906
|
+
const count = [hasTarget, hasExternal, hasTeam].filter(Boolean).length;
|
|
1907
|
+
if (count === 0) {
|
|
1908
|
+
return true;
|
|
1909
|
+
}
|
|
1910
|
+
return count === 1;
|
|
1911
|
+
},
|
|
1912
|
+
{
|
|
1913
|
+
message: "Must specify exactly one of targetSubAgentId, externalSubAgentId, or teamSubAgentId when updating sub-agent relationships",
|
|
1914
|
+
path: ["targetSubAgentId", "externalSubAgentId", "teamSubAgentId"]
|
|
1915
|
+
}
|
|
1916
|
+
).openapi("SubAgentRelationUpdate");
|
|
1917
|
+
zodOpenapi.z.object({
|
|
1918
|
+
sourceSubAgentId: zodOpenapi.z.string().optional(),
|
|
1919
|
+
targetSubAgentId: zodOpenapi.z.string().optional(),
|
|
1920
|
+
externalSubAgentId: zodOpenapi.z.string().optional(),
|
|
1921
|
+
teamSubAgentId: zodOpenapi.z.string().optional()
|
|
1922
|
+
});
|
|
1923
|
+
var ExternalSubAgentRelationInsertSchema = createInsertSchema(subAgentRelations).extend({
|
|
1924
|
+
id: resourceIdSchema,
|
|
1925
|
+
agentId: resourceIdSchema,
|
|
1926
|
+
sourceSubAgentId: resourceIdSchema,
|
|
1927
|
+
externalSubAgentId: resourceIdSchema
|
|
1928
|
+
});
|
|
1929
|
+
createApiInsertSchema(
|
|
1930
|
+
ExternalSubAgentRelationInsertSchema
|
|
1931
|
+
);
|
|
1932
|
+
var AgentSelectSchema = createSelectSchema(agents);
|
|
1933
|
+
var AgentInsertSchema = createInsertSchema(agents).extend({
|
|
1934
|
+
id: resourceIdSchema,
|
|
1935
|
+
name: zodOpenapi.z.string().trim().nonempty()
|
|
1936
|
+
});
|
|
1937
|
+
var AgentUpdateSchema = AgentInsertSchema.partial();
|
|
1938
|
+
var AgentApiSelectSchema = createApiSchema(AgentSelectSchema).openapi("Agent");
|
|
1939
|
+
var AgentApiInsertSchema = createApiInsertSchema(AgentInsertSchema).extend({
|
|
1940
|
+
id: resourceIdSchema
|
|
1941
|
+
}).openapi("AgentCreate");
|
|
1942
|
+
createApiUpdateSchema(AgentUpdateSchema).openapi("AgentUpdate");
|
|
1943
|
+
var TaskSelectSchema = createSelectSchema(tasks);
|
|
1944
|
+
var TaskInsertSchema = createInsertSchema(tasks).extend({
|
|
1945
|
+
id: resourceIdSchema,
|
|
1946
|
+
conversationId: resourceIdSchema.optional()
|
|
1947
|
+
});
|
|
1948
|
+
var TaskUpdateSchema = TaskInsertSchema.partial();
|
|
1949
|
+
createApiSchema(TaskSelectSchema);
|
|
1950
|
+
createApiInsertSchema(TaskInsertSchema);
|
|
1951
|
+
createApiUpdateSchema(TaskUpdateSchema);
|
|
1952
|
+
var TaskRelationSelectSchema = createSelectSchema(taskRelations);
|
|
1953
|
+
var TaskRelationInsertSchema = createInsertSchema(taskRelations).extend({
|
|
1954
|
+
id: resourceIdSchema,
|
|
1955
|
+
parentTaskId: resourceIdSchema,
|
|
1956
|
+
childTaskId: resourceIdSchema
|
|
1957
|
+
});
|
|
1958
|
+
var TaskRelationUpdateSchema = TaskRelationInsertSchema.partial();
|
|
1959
|
+
createApiSchema(TaskRelationSelectSchema);
|
|
1960
|
+
createApiInsertSchema(TaskRelationInsertSchema);
|
|
1961
|
+
createApiUpdateSchema(TaskRelationUpdateSchema);
|
|
1962
|
+
var imageUrlSchema = zodOpenapi.z.string().optional().refine(
|
|
1963
|
+
(url) => {
|
|
1964
|
+
if (!url) return true;
|
|
1965
|
+
if (url.startsWith("data:image/")) {
|
|
1966
|
+
const base64Part = url.split(",")[1];
|
|
1967
|
+
if (!base64Part) return false;
|
|
1968
|
+
return base64Part.length < 14e5;
|
|
1969
|
+
}
|
|
1970
|
+
try {
|
|
1971
|
+
const parsed = new URL(url);
|
|
1972
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
1973
|
+
} catch {
|
|
1974
|
+
return false;
|
|
1975
|
+
}
|
|
1976
|
+
},
|
|
1977
|
+
{
|
|
1978
|
+
message: "Image URL must be a valid HTTP(S) URL or a base64 data URL (max 1MB)"
|
|
1979
|
+
}
|
|
1980
|
+
);
|
|
1981
|
+
var McpTransportConfigSchema = zodOpenapi.z.object({
|
|
1982
|
+
type: zodOpenapi.z.enum(MCPTransportType),
|
|
1983
|
+
requestInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
1984
|
+
eventSourceInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
1985
|
+
reconnectionOptions: zodOpenapi.z.any().optional().openapi({
|
|
1986
|
+
type: "object",
|
|
1987
|
+
description: "Reconnection options for streamable HTTP transport"
|
|
1988
|
+
}),
|
|
1989
|
+
sessionId: zodOpenapi.z.string().optional()
|
|
1990
|
+
}).openapi("McpTransportConfig");
|
|
1991
|
+
var ToolStatusSchema = zodOpenapi.z.enum(TOOL_STATUS_VALUES);
|
|
1992
|
+
var McpToolDefinitionSchema = zodOpenapi.z.object({
|
|
1993
|
+
name: zodOpenapi.z.string(),
|
|
1994
|
+
description: zodOpenapi.z.string().optional(),
|
|
1995
|
+
inputSchema: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional()
|
|
1996
|
+
});
|
|
1997
|
+
var ToolSelectSchema = createSelectSchema(tools);
|
|
1998
|
+
var ToolInsertSchema = createInsertSchema(tools).extend({
|
|
1999
|
+
id: resourceIdSchema,
|
|
2000
|
+
imageUrl: imageUrlSchema,
|
|
2001
|
+
config: zodOpenapi.z.object({
|
|
2002
|
+
type: zodOpenapi.z.literal("mcp"),
|
|
2003
|
+
mcp: zodOpenapi.z.object({
|
|
2004
|
+
server: zodOpenapi.z.object({
|
|
2005
|
+
url: zodOpenapi.z.url()
|
|
2006
|
+
}),
|
|
2007
|
+
transport: zodOpenapi.z.object({
|
|
2008
|
+
type: zodOpenapi.z.enum(MCPTransportType),
|
|
2009
|
+
requestInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
2010
|
+
eventSourceInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
2011
|
+
reconnectionOptions: zodOpenapi.z.any().optional().openapi({
|
|
2012
|
+
type: "object",
|
|
2013
|
+
description: "Reconnection options for streamable HTTP transport"
|
|
2014
|
+
}),
|
|
2015
|
+
sessionId: zodOpenapi.z.string().optional()
|
|
2016
|
+
}).optional(),
|
|
2017
|
+
activeTools: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
|
|
2018
|
+
})
|
|
2019
|
+
})
|
|
2020
|
+
});
|
|
2021
|
+
var ConversationSelectSchema = createSelectSchema(conversations);
|
|
2022
|
+
var ConversationInsertSchema = createInsertSchema(conversations).extend({
|
|
2023
|
+
id: resourceIdSchema,
|
|
2024
|
+
contextConfigId: resourceIdSchema.optional()
|
|
2025
|
+
});
|
|
2026
|
+
var ConversationUpdateSchema = ConversationInsertSchema.partial();
|
|
2027
|
+
var ConversationApiSelectSchema = createApiSchema(ConversationSelectSchema).openapi("Conversation");
|
|
2028
|
+
createApiInsertSchema(ConversationInsertSchema).openapi("ConversationCreate");
|
|
2029
|
+
createApiUpdateSchema(ConversationUpdateSchema).openapi("ConversationUpdate");
|
|
2030
|
+
var MessageSelectSchema = createSelectSchema(messages);
|
|
2031
|
+
var MessageInsertSchema = createInsertSchema(messages).extend({
|
|
2032
|
+
id: resourceIdSchema,
|
|
2033
|
+
conversationId: resourceIdSchema,
|
|
2034
|
+
taskId: resourceIdSchema.optional()
|
|
2035
|
+
});
|
|
2036
|
+
var MessageUpdateSchema = MessageInsertSchema.partial();
|
|
2037
|
+
var MessageApiSelectSchema = createApiSchema(MessageSelectSchema).openapi("Message");
|
|
2038
|
+
createApiInsertSchema(MessageInsertSchema).openapi("MessageCreate");
|
|
2039
|
+
createApiUpdateSchema(MessageUpdateSchema).openapi("MessageUpdate");
|
|
2040
|
+
var ContextCacheSelectSchema = createSelectSchema(contextCache);
|
|
2041
|
+
var ContextCacheInsertSchema = createInsertSchema(contextCache);
|
|
2042
|
+
var ContextCacheUpdateSchema = ContextCacheInsertSchema.partial();
|
|
2043
|
+
createApiSchema(ContextCacheSelectSchema);
|
|
2044
|
+
createApiInsertSchema(ContextCacheInsertSchema);
|
|
2045
|
+
createApiUpdateSchema(ContextCacheUpdateSchema);
|
|
2046
|
+
var DataComponentSelectSchema = createSelectSchema(dataComponents);
|
|
2047
|
+
var DataComponentInsertSchema = createInsertSchema(dataComponents).extend({
|
|
2048
|
+
id: resourceIdSchema
|
|
2049
|
+
});
|
|
2050
|
+
DataComponentInsertSchema.omit({
|
|
2051
|
+
createdAt: true,
|
|
2052
|
+
updatedAt: true
|
|
2053
|
+
});
|
|
2054
|
+
var DataComponentUpdateSchema = DataComponentInsertSchema.partial();
|
|
2055
|
+
var DataComponentApiSelectSchema = createApiSchema(DataComponentSelectSchema).openapi("DataComponent");
|
|
2056
|
+
var DataComponentApiInsertSchema = createApiInsertSchema(DataComponentInsertSchema).openapi("DataComponentCreate");
|
|
2057
|
+
createApiUpdateSchema(DataComponentUpdateSchema).openapi("DataComponentUpdate");
|
|
2058
|
+
var SubAgentDataComponentSelectSchema = createSelectSchema(subAgentDataComponents);
|
|
2059
|
+
var SubAgentDataComponentInsertSchema = createInsertSchema(subAgentDataComponents);
|
|
2060
|
+
var SubAgentDataComponentUpdateSchema = SubAgentDataComponentInsertSchema.partial();
|
|
2061
|
+
var SubAgentDataComponentApiSelectSchema = createAgentScopedApiSchema(
|
|
2062
|
+
SubAgentDataComponentSelectSchema
|
|
2063
|
+
);
|
|
2064
|
+
SubAgentDataComponentInsertSchema.omit({
|
|
2065
|
+
tenantId: true,
|
|
2066
|
+
projectId: true,
|
|
2067
|
+
id: true,
|
|
2068
|
+
createdAt: true
|
|
2069
|
+
});
|
|
2070
|
+
createAgentScopedApiUpdateSchema(
|
|
2071
|
+
SubAgentDataComponentUpdateSchema
|
|
2072
|
+
);
|
|
2073
|
+
var ArtifactComponentSelectSchema = createSelectSchema(artifactComponents);
|
|
2074
|
+
var ArtifactComponentInsertSchema = createInsertSchema(artifactComponents).extend({
|
|
2075
|
+
id: resourceIdSchema
|
|
2076
|
+
});
|
|
2077
|
+
var ArtifactComponentUpdateSchema = ArtifactComponentInsertSchema.partial();
|
|
2078
|
+
var ArtifactComponentApiSelectSchema = createApiSchema(
|
|
2079
|
+
ArtifactComponentSelectSchema
|
|
2080
|
+
).openapi("ArtifactComponent");
|
|
2081
|
+
var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
|
|
2082
|
+
tenantId: true,
|
|
2083
|
+
projectId: true,
|
|
2084
|
+
createdAt: true,
|
|
2085
|
+
updatedAt: true
|
|
2086
|
+
}).openapi("ArtifactComponentCreate");
|
|
2087
|
+
createApiUpdateSchema(
|
|
2088
|
+
ArtifactComponentUpdateSchema
|
|
2089
|
+
).openapi("ArtifactComponentUpdate");
|
|
2090
|
+
var SubAgentArtifactComponentSelectSchema = createSelectSchema(subAgentArtifactComponents);
|
|
2091
|
+
var SubAgentArtifactComponentInsertSchema = createInsertSchema(
|
|
2092
|
+
subAgentArtifactComponents
|
|
2093
|
+
).extend({
|
|
2094
|
+
id: resourceIdSchema,
|
|
2095
|
+
subAgentId: resourceIdSchema,
|
|
2096
|
+
artifactComponentId: resourceIdSchema
|
|
2097
|
+
});
|
|
2098
|
+
var SubAgentArtifactComponentUpdateSchema = SubAgentArtifactComponentInsertSchema.partial();
|
|
2099
|
+
var SubAgentArtifactComponentApiSelectSchema = createAgentScopedApiSchema(
|
|
2100
|
+
SubAgentArtifactComponentSelectSchema
|
|
2101
|
+
);
|
|
2102
|
+
SubAgentArtifactComponentInsertSchema.omit({
|
|
2103
|
+
tenantId: true,
|
|
2104
|
+
projectId: true,
|
|
2105
|
+
id: true,
|
|
2106
|
+
createdAt: true
|
|
2107
|
+
});
|
|
2108
|
+
createAgentScopedApiUpdateSchema(
|
|
2109
|
+
SubAgentArtifactComponentUpdateSchema
|
|
2110
|
+
);
|
|
2111
|
+
var ExternalAgentSelectSchema = createSelectSchema(externalAgents).extend({
|
|
2112
|
+
credentialReferenceId: zodOpenapi.z.string().nullable().optional()
|
|
2113
|
+
});
|
|
2114
|
+
var ExternalAgentInsertSchema = createInsertSchema(externalAgents).extend({
|
|
2115
|
+
id: resourceIdSchema
|
|
2116
|
+
});
|
|
2117
|
+
var ExternalAgentUpdateSchema = ExternalAgentInsertSchema.partial();
|
|
2118
|
+
var ExternalAgentApiSelectSchema = createApiSchema(ExternalAgentSelectSchema).openapi("ExternalAgent");
|
|
2119
|
+
var ExternalAgentApiInsertSchema = createApiInsertSchema(ExternalAgentInsertSchema).openapi("ExternalAgentCreate");
|
|
2120
|
+
createApiUpdateSchema(ExternalAgentUpdateSchema).openapi("ExternalAgentUpdate");
|
|
2121
|
+
zodOpenapi.z.discriminatedUnion("type", [
|
|
2122
|
+
SubAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("internal") }),
|
|
2123
|
+
ExternalAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("external") })
|
|
2124
|
+
]);
|
|
2125
|
+
var ApiKeySelectSchema = createSelectSchema(apiKeys);
|
|
2126
|
+
var ApiKeyInsertSchema = createInsertSchema(apiKeys).extend({
|
|
2127
|
+
id: resourceIdSchema,
|
|
2128
|
+
agentId: resourceIdSchema
|
|
2129
|
+
});
|
|
2130
|
+
var ApiKeyUpdateSchema = ApiKeyInsertSchema.partial().omit({
|
|
2131
|
+
tenantId: true,
|
|
2132
|
+
projectId: true,
|
|
2133
|
+
id: true,
|
|
2134
|
+
publicId: true,
|
|
2135
|
+
keyHash: true,
|
|
2136
|
+
keyPrefix: true,
|
|
2137
|
+
createdAt: true
|
|
2138
|
+
});
|
|
2139
|
+
var ApiKeyApiSelectSchema = ApiKeySelectSchema.omit({
|
|
2140
|
+
tenantId: true,
|
|
2141
|
+
projectId: true,
|
|
2142
|
+
keyHash: true
|
|
2143
|
+
// Never expose the hash
|
|
2144
|
+
}).openapi("ApiKey");
|
|
2145
|
+
zodOpenapi.z.object({
|
|
2146
|
+
data: zodOpenapi.z.object({
|
|
2147
|
+
apiKey: ApiKeyApiSelectSchema,
|
|
2148
|
+
key: zodOpenapi.z.string().describe("The full API key (shown only once)")
|
|
2149
|
+
})
|
|
2150
|
+
});
|
|
2151
|
+
ApiKeyInsertSchema.omit({
|
|
2152
|
+
tenantId: true,
|
|
2153
|
+
projectId: true,
|
|
2154
|
+
id: true,
|
|
2155
|
+
// Auto-generated
|
|
2156
|
+
publicId: true,
|
|
2157
|
+
// Auto-generated
|
|
2158
|
+
keyHash: true,
|
|
2159
|
+
// Auto-generated
|
|
2160
|
+
keyPrefix: true,
|
|
2161
|
+
// Auto-generated
|
|
2162
|
+
lastUsedAt: true
|
|
2163
|
+
// Not set on creation
|
|
2164
|
+
}).openapi("ApiKeyCreate");
|
|
2165
|
+
ApiKeyUpdateSchema.openapi("ApiKeyUpdate");
|
|
2166
|
+
var CredentialReferenceSelectSchema = zodOpenapi.z.object({
|
|
2167
|
+
id: zodOpenapi.z.string(),
|
|
2168
|
+
tenantId: zodOpenapi.z.string(),
|
|
2169
|
+
projectId: zodOpenapi.z.string(),
|
|
2170
|
+
name: zodOpenapi.z.string(),
|
|
2171
|
+
type: zodOpenapi.z.string(),
|
|
2172
|
+
credentialStoreId: zodOpenapi.z.string(),
|
|
2173
|
+
retrievalParams: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).nullish(),
|
|
2174
|
+
createdAt: zodOpenapi.z.string(),
|
|
2175
|
+
updatedAt: zodOpenapi.z.string()
|
|
2176
|
+
});
|
|
2177
|
+
var CredentialReferenceInsertSchema = createInsertSchema(credentialReferences).extend({
|
|
2178
|
+
id: resourceIdSchema,
|
|
2179
|
+
type: zodOpenapi.z.string(),
|
|
2180
|
+
credentialStoreId: resourceIdSchema,
|
|
2181
|
+
retrievalParams: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).nullish()
|
|
2182
|
+
});
|
|
2183
|
+
var CredentialReferenceUpdateSchema = CredentialReferenceInsertSchema.partial();
|
|
2184
|
+
var CredentialReferenceApiSelectSchema = createApiSchema(CredentialReferenceSelectSchema).extend({
|
|
2185
|
+
type: zodOpenapi.z.enum(CredentialStoreType),
|
|
2186
|
+
tools: zodOpenapi.z.array(ToolSelectSchema).optional(),
|
|
2187
|
+
externalAgents: zodOpenapi.z.array(ExternalAgentSelectSchema).optional()
|
|
2188
|
+
}).openapi("CredentialReference");
|
|
2189
|
+
var CredentialReferenceApiInsertSchema = createApiInsertSchema(
|
|
2190
|
+
CredentialReferenceInsertSchema
|
|
2191
|
+
).extend({
|
|
2192
|
+
type: zodOpenapi.z.enum(CredentialStoreType)
|
|
2193
|
+
}).openapi("CredentialReferenceCreate");
|
|
2194
|
+
createApiUpdateSchema(
|
|
2195
|
+
CredentialReferenceUpdateSchema
|
|
2196
|
+
).extend({
|
|
2197
|
+
type: zodOpenapi.z.enum(CredentialStoreType).optional()
|
|
2198
|
+
}).openapi("CredentialReferenceUpdate");
|
|
2199
|
+
var CredentialStoreSchema = zodOpenapi.z.object({
|
|
2200
|
+
id: zodOpenapi.z.string().describe("Unique identifier of the credential store"),
|
|
2201
|
+
type: zodOpenapi.z.enum(CredentialStoreType),
|
|
2202
|
+
available: zodOpenapi.z.boolean().describe("Whether the store is functional and ready to use"),
|
|
2203
|
+
reason: zodOpenapi.z.string().nullable().describe("Reason why store is not available, if applicable")
|
|
2204
|
+
}).openapi("CredentialStore");
|
|
2205
|
+
zodOpenapi.z.object({
|
|
2206
|
+
data: zodOpenapi.z.array(CredentialStoreSchema).describe("List of credential stores")
|
|
2207
|
+
}).openapi("CredentialStoreListResponse");
|
|
2208
|
+
zodOpenapi.z.object({
|
|
2209
|
+
key: zodOpenapi.z.string().describe("The credential key"),
|
|
2210
|
+
value: zodOpenapi.z.string().describe("The credential value"),
|
|
2211
|
+
metadata: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish().describe("The metadata for the credential")
|
|
2212
|
+
}).openapi("CreateCredentialInStoreRequest");
|
|
2213
|
+
zodOpenapi.z.object({
|
|
2214
|
+
data: zodOpenapi.z.object({
|
|
2215
|
+
key: zodOpenapi.z.string().describe("The credential key"),
|
|
2216
|
+
storeId: zodOpenapi.z.string().describe("The store ID where credential was created"),
|
|
2217
|
+
createdAt: zodOpenapi.z.string().describe("ISO timestamp of creation")
|
|
2218
|
+
})
|
|
2219
|
+
}).openapi("CreateCredentialInStoreResponse");
|
|
2220
|
+
var RelatedAgentInfoSchema = zodOpenapi.z.object({
|
|
2221
|
+
id: zodOpenapi.z.string(),
|
|
2222
|
+
name: zodOpenapi.z.string(),
|
|
2223
|
+
description: zodOpenapi.z.string()
|
|
2224
|
+
}).openapi("RelatedAgentInfo");
|
|
2225
|
+
var ComponentAssociationSchema = zodOpenapi.z.object({
|
|
2226
|
+
subAgentId: zodOpenapi.z.string(),
|
|
2227
|
+
createdAt: zodOpenapi.z.string()
|
|
2228
|
+
}).openapi("ComponentAssociation");
|
|
2229
|
+
zodOpenapi.z.object({
|
|
2230
|
+
tenantId: zodOpenapi.z.string().min(1, "Tenant ID is required"),
|
|
2231
|
+
projectId: zodOpenapi.z.string().min(1, "Project ID is required"),
|
|
2232
|
+
toolId: zodOpenapi.z.string().min(1, "Tool ID is required")
|
|
2233
|
+
}).openapi("OAuthLoginQuery");
|
|
2234
|
+
zodOpenapi.z.object({
|
|
2235
|
+
code: zodOpenapi.z.string().min(1, "Authorization code is required"),
|
|
2236
|
+
state: zodOpenapi.z.string().min(1, "State parameter is required"),
|
|
2237
|
+
error: zodOpenapi.z.string().optional(),
|
|
2238
|
+
error_description: zodOpenapi.z.string().optional()
|
|
2239
|
+
}).openapi("OAuthCallbackQuery");
|
|
2240
|
+
var McpToolSchema = ToolInsertSchema.extend({
|
|
2241
|
+
imageUrl: imageUrlSchema,
|
|
2242
|
+
availableTools: zodOpenapi.z.array(McpToolDefinitionSchema).optional(),
|
|
2243
|
+
status: ToolStatusSchema.default("unknown"),
|
|
2244
|
+
version: zodOpenapi.z.string().optional(),
|
|
2245
|
+
expiresAt: zodOpenapi.z.string().optional(),
|
|
2246
|
+
relationshipId: zodOpenapi.z.string().optional()
|
|
2247
|
+
}).openapi("McpTool");
|
|
2248
|
+
McpToolSchema.omit({
|
|
2249
|
+
config: true,
|
|
2250
|
+
tenantId: true,
|
|
2251
|
+
projectId: true,
|
|
2252
|
+
status: true,
|
|
2253
|
+
version: true,
|
|
2254
|
+
createdAt: true,
|
|
2255
|
+
updatedAt: true,
|
|
2256
|
+
credentialReferenceId: true
|
|
2257
|
+
}).extend({
|
|
2258
|
+
tenantId: zodOpenapi.z.string().optional(),
|
|
2259
|
+
projectId: zodOpenapi.z.string().optional(),
|
|
2260
|
+
description: zodOpenapi.z.string().optional(),
|
|
2261
|
+
serverUrl: zodOpenapi.z.url(),
|
|
2262
|
+
activeTools: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
2263
|
+
mcpType: zodOpenapi.z.enum(MCPServerType).optional(),
|
|
2264
|
+
transport: McpTransportConfigSchema.optional(),
|
|
2265
|
+
credential: CredentialReferenceApiInsertSchema.optional()
|
|
2266
|
+
});
|
|
2267
|
+
var ToolUpdateSchema = ToolInsertSchema.partial();
|
|
2268
|
+
var ToolApiSelectSchema = createApiSchema(ToolSelectSchema).openapi("Tool");
|
|
2269
|
+
var ToolApiInsertSchema = createApiInsertSchema(ToolInsertSchema).openapi("ToolCreate");
|
|
2270
|
+
createApiUpdateSchema(ToolUpdateSchema).openapi("ToolUpdate");
|
|
2271
|
+
var FunctionToolSelectSchema = createSelectSchema(functionTools);
|
|
2272
|
+
var FunctionToolInsertSchema = createInsertSchema(functionTools).extend({
|
|
2273
|
+
id: resourceIdSchema
|
|
2274
|
+
});
|
|
2275
|
+
var FunctionToolUpdateSchema = FunctionToolInsertSchema.partial();
|
|
2276
|
+
var FunctionToolApiSelectSchema = createApiSchema(FunctionToolSelectSchema).openapi("FunctionTool");
|
|
2277
|
+
var FunctionToolApiInsertSchema = createAgentScopedApiInsertSchema(FunctionToolInsertSchema).openapi("FunctionToolCreate");
|
|
2278
|
+
createApiUpdateSchema(FunctionToolUpdateSchema).openapi("FunctionToolUpdate");
|
|
2279
|
+
var FunctionSelectSchema = createSelectSchema(functions);
|
|
2280
|
+
var FunctionInsertSchema = createInsertSchema(functions).extend({
|
|
2281
|
+
id: resourceIdSchema
|
|
2282
|
+
});
|
|
2283
|
+
var FunctionUpdateSchema = FunctionInsertSchema.partial();
|
|
2284
|
+
var FunctionApiSelectSchema = createApiSchema(FunctionSelectSchema).openapi("Function");
|
|
2285
|
+
var FunctionApiInsertSchema = createApiInsertSchema(FunctionInsertSchema).openapi("FunctionCreate");
|
|
2286
|
+
var FunctionApiUpdateSchema = createApiUpdateSchema(FunctionUpdateSchema).openapi("FunctionUpdate");
|
|
2287
|
+
var FetchConfigSchema = zodOpenapi.z.object({
|
|
2288
|
+
url: zodOpenapi.z.string().min(1, "URL is required"),
|
|
2289
|
+
method: zodOpenapi.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).optional().default("GET"),
|
|
2290
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).optional(),
|
|
2291
|
+
body: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
2292
|
+
transform: zodOpenapi.z.string().optional(),
|
|
2293
|
+
// JSONPath or JS transform function
|
|
2294
|
+
timeout: zodOpenapi.z.number().min(0).optional().default(CONTEXT_FETCHER_HTTP_TIMEOUT_MS_DEFAULT).optional()
|
|
2295
|
+
}).openapi("FetchConfig");
|
|
2296
|
+
zodOpenapi.z.object({
|
|
2297
|
+
id: zodOpenapi.z.string().min(1, "Fetch definition ID is required"),
|
|
2298
|
+
name: zodOpenapi.z.string().optional(),
|
|
2299
|
+
trigger: zodOpenapi.z.enum(["initialization", "invocation"]),
|
|
2300
|
+
fetchConfig: FetchConfigSchema,
|
|
2301
|
+
responseSchema: zodOpenapi.z.any().optional(),
|
|
2302
|
+
// JSON Schema for validating HTTP response
|
|
2303
|
+
defaultValue: zodOpenapi.z.any().optional().openapi({
|
|
2304
|
+
description: "Default value if fetch fails"
|
|
2305
|
+
}),
|
|
2306
|
+
credential: CredentialReferenceApiInsertSchema.optional()
|
|
2307
|
+
}).openapi("FetchDefinition");
|
|
2308
|
+
var ContextConfigSelectSchema = createSelectSchema(contextConfigs).extend({
|
|
2309
|
+
headersSchema: zodOpenapi.z.any().optional().openapi({
|
|
2310
|
+
type: "object",
|
|
2311
|
+
description: "JSON Schema for validating request headers"
|
|
2312
|
+
})
|
|
2313
|
+
});
|
|
2314
|
+
var ContextConfigInsertSchema = createInsertSchema(contextConfigs).extend({
|
|
2315
|
+
id: resourceIdSchema.optional(),
|
|
2316
|
+
headersSchema: zodOpenapi.z.any().nullable().optional().openapi({
|
|
2317
|
+
type: "object",
|
|
2318
|
+
description: "JSON Schema for validating request headers"
|
|
2319
|
+
}),
|
|
2320
|
+
contextVariables: zodOpenapi.z.any().nullable().optional().openapi({
|
|
2321
|
+
type: "object",
|
|
2322
|
+
description: "Context variables configuration with fetch definitions"
|
|
2323
|
+
})
|
|
2324
|
+
}).omit({
|
|
2325
|
+
createdAt: true,
|
|
2326
|
+
updatedAt: true
|
|
2327
|
+
});
|
|
2328
|
+
var ContextConfigUpdateSchema = ContextConfigInsertSchema.partial();
|
|
2329
|
+
var ContextConfigApiSelectSchema = createApiSchema(ContextConfigSelectSchema).omit({
|
|
2330
|
+
agentId: true
|
|
2331
|
+
}).openapi("ContextConfig");
|
|
2332
|
+
var ContextConfigApiInsertSchema = createApiInsertSchema(ContextConfigInsertSchema).omit({
|
|
2333
|
+
agentId: true
|
|
2334
|
+
}).openapi("ContextConfigCreate");
|
|
2335
|
+
createApiUpdateSchema(ContextConfigUpdateSchema).omit({
|
|
2336
|
+
agentId: true
|
|
2337
|
+
}).openapi("ContextConfigUpdate");
|
|
2338
|
+
var SubAgentToolRelationSelectSchema = createSelectSchema(subAgentToolRelations);
|
|
2339
|
+
var SubAgentToolRelationInsertSchema = createInsertSchema(subAgentToolRelations).extend({
|
|
2340
|
+
id: resourceIdSchema,
|
|
2341
|
+
subAgentId: resourceIdSchema,
|
|
2342
|
+
toolId: resourceIdSchema,
|
|
2343
|
+
selectedTools: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
|
|
2344
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish(),
|
|
2345
|
+
toolPolicies: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.object({ needsApproval: zodOpenapi.z.boolean().optional() })).nullish()
|
|
2346
|
+
});
|
|
2347
|
+
var SubAgentToolRelationUpdateSchema = SubAgentToolRelationInsertSchema.partial();
|
|
2348
|
+
var SubAgentToolRelationApiSelectSchema = createAgentScopedApiSchema(
|
|
2349
|
+
SubAgentToolRelationSelectSchema
|
|
2350
|
+
).openapi("SubAgentToolRelation");
|
|
2351
|
+
createAgentScopedApiInsertSchema(
|
|
2352
|
+
SubAgentToolRelationInsertSchema
|
|
2353
|
+
).openapi("SubAgentToolRelationCreate");
|
|
2354
|
+
createAgentScopedApiUpdateSchema(
|
|
2355
|
+
SubAgentToolRelationUpdateSchema
|
|
2356
|
+
).openapi("SubAgentToolRelationUpdate");
|
|
2357
|
+
var SubAgentExternalAgentRelationSelectSchema = createSelectSchema(
|
|
2358
|
+
subAgentExternalAgentRelations
|
|
2359
|
+
);
|
|
2360
|
+
var SubAgentExternalAgentRelationInsertSchema = createInsertSchema(
|
|
2361
|
+
subAgentExternalAgentRelations
|
|
2362
|
+
).extend({
|
|
2363
|
+
id: resourceIdSchema,
|
|
2364
|
+
subAgentId: resourceIdSchema,
|
|
2365
|
+
externalAgentId: resourceIdSchema,
|
|
2366
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
2367
|
+
});
|
|
2368
|
+
var SubAgentExternalAgentRelationUpdateSchema = SubAgentExternalAgentRelationInsertSchema.partial();
|
|
2369
|
+
var SubAgentExternalAgentRelationApiSelectSchema = createAgentScopedApiSchema(
|
|
2370
|
+
SubAgentExternalAgentRelationSelectSchema
|
|
2371
|
+
).openapi("SubAgentExternalAgentRelation");
|
|
2372
|
+
createAgentScopedApiInsertSchema(
|
|
2373
|
+
SubAgentExternalAgentRelationInsertSchema
|
|
2374
|
+
).omit({ id: true, subAgentId: true }).openapi("SubAgentExternalAgentRelationCreate");
|
|
2375
|
+
createAgentScopedApiUpdateSchema(
|
|
2376
|
+
SubAgentExternalAgentRelationUpdateSchema
|
|
2377
|
+
).openapi("SubAgentExternalAgentRelationUpdate");
|
|
2378
|
+
var SubAgentTeamAgentRelationSelectSchema = createSelectSchema(subAgentTeamAgentRelations);
|
|
2379
|
+
var SubAgentTeamAgentRelationInsertSchema = createInsertSchema(
|
|
2380
|
+
subAgentTeamAgentRelations
|
|
2381
|
+
).extend({
|
|
2382
|
+
id: resourceIdSchema,
|
|
2383
|
+
subAgentId: resourceIdSchema,
|
|
2384
|
+
targetAgentId: resourceIdSchema,
|
|
2385
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
2386
|
+
});
|
|
2387
|
+
var SubAgentTeamAgentRelationUpdateSchema = SubAgentTeamAgentRelationInsertSchema.partial();
|
|
2388
|
+
var SubAgentTeamAgentRelationApiSelectSchema = createAgentScopedApiSchema(
|
|
2389
|
+
SubAgentTeamAgentRelationSelectSchema
|
|
2390
|
+
).openapi("SubAgentTeamAgentRelation");
|
|
2391
|
+
createAgentScopedApiInsertSchema(
|
|
2392
|
+
SubAgentTeamAgentRelationInsertSchema
|
|
2393
|
+
).omit({ id: true, subAgentId: true }).openapi("SubAgentTeamAgentRelationCreate");
|
|
2394
|
+
createAgentScopedApiUpdateSchema(
|
|
2395
|
+
SubAgentTeamAgentRelationUpdateSchema
|
|
2396
|
+
).openapi("SubAgentTeamAgentRelationUpdate");
|
|
2397
|
+
var LedgerArtifactSelectSchema = createSelectSchema(ledgerArtifacts);
|
|
2398
|
+
var LedgerArtifactInsertSchema = createInsertSchema(ledgerArtifacts);
|
|
2399
|
+
var LedgerArtifactUpdateSchema = LedgerArtifactInsertSchema.partial();
|
|
2400
|
+
createApiSchema(LedgerArtifactSelectSchema);
|
|
2401
|
+
createApiInsertSchema(LedgerArtifactInsertSchema);
|
|
2402
|
+
createApiUpdateSchema(LedgerArtifactUpdateSchema);
|
|
2403
|
+
var StatusComponentSchema = zodOpenapi.z.object({
|
|
2404
|
+
type: zodOpenapi.z.string(),
|
|
2405
|
+
description: zodOpenapi.z.string().optional(),
|
|
2406
|
+
detailsSchema: zodOpenapi.z.object({
|
|
2407
|
+
type: zodOpenapi.z.literal("object"),
|
|
2408
|
+
properties: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.any()),
|
|
2409
|
+
required: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
|
|
2410
|
+
}).optional()
|
|
2411
|
+
}).openapi("StatusComponent");
|
|
2412
|
+
var StatusUpdateSchema = zodOpenapi.z.object({
|
|
2413
|
+
enabled: zodOpenapi.z.boolean().optional(),
|
|
2414
|
+
numEvents: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_NUM_EVENTS).optional(),
|
|
2415
|
+
timeInSeconds: zodOpenapi.z.number().min(1).max(STATUS_UPDATE_MAX_INTERVAL_SECONDS).optional(),
|
|
2416
|
+
prompt: zodOpenapi.z.string().max(
|
|
2417
|
+
VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS,
|
|
2418
|
+
`Custom prompt cannot exceed ${VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS} characters`
|
|
2419
|
+
).optional(),
|
|
2420
|
+
statusComponents: zodOpenapi.z.array(StatusComponentSchema).optional()
|
|
2421
|
+
}).openapi("StatusUpdate");
|
|
2422
|
+
var CanUseItemSchema = zodOpenapi.z.object({
|
|
2423
|
+
agentToolRelationId: zodOpenapi.z.string().optional(),
|
|
2424
|
+
toolId: zodOpenapi.z.string(),
|
|
2425
|
+
toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
|
|
2426
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish(),
|
|
2427
|
+
toolPolicies: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.object({ needsApproval: zodOpenapi.z.boolean().optional() })).nullish()
|
|
2428
|
+
}).openapi("CanUseItem");
|
|
2429
|
+
var canDelegateToExternalAgentSchema = zodOpenapi.z.object({
|
|
2430
|
+
externalAgentId: zodOpenapi.z.string(),
|
|
2431
|
+
subAgentExternalAgentRelationId: zodOpenapi.z.string().optional(),
|
|
2432
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
2433
|
+
}).openapi("CanDelegateToExternalAgent");
|
|
2434
|
+
var canDelegateToTeamAgentSchema = zodOpenapi.z.object({
|
|
2435
|
+
agentId: zodOpenapi.z.string(),
|
|
2436
|
+
subAgentTeamAgentRelationId: zodOpenapi.z.string().optional(),
|
|
2437
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
2438
|
+
}).openapi("CanDelegateToTeamAgent");
|
|
2439
|
+
var TeamAgentSchema = zodOpenapi.z.object({
|
|
2440
|
+
id: zodOpenapi.z.string(),
|
|
2441
|
+
name: zodOpenapi.z.string(),
|
|
2442
|
+
description: zodOpenapi.z.string()
|
|
2443
|
+
}).openapi("TeamAgent");
|
|
2444
|
+
var FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
|
|
2445
|
+
type: zodOpenapi.z.literal("internal"),
|
|
2446
|
+
canUse: zodOpenapi.z.array(CanUseItemSchema),
|
|
2447
|
+
// All tools (both MCP and function tools)
|
|
2448
|
+
dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
2449
|
+
artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
2450
|
+
canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
2451
|
+
prompt: zodOpenapi.z.string().trim().nonempty(),
|
|
2452
|
+
canDelegateTo: zodOpenapi.z.array(
|
|
2453
|
+
zodOpenapi.z.union([
|
|
2454
|
+
zodOpenapi.z.string(),
|
|
2455
|
+
// Internal subAgent ID
|
|
2456
|
+
canDelegateToExternalAgentSchema,
|
|
2457
|
+
// External agent with headers
|
|
2458
|
+
canDelegateToTeamAgentSchema
|
|
2459
|
+
// Team agent with headers
|
|
2460
|
+
])
|
|
2461
|
+
).optional()
|
|
2462
|
+
}).openapi("FullAgentAgentInsert");
|
|
2463
|
+
var AgentWithinContextOfProjectSchema = AgentApiInsertSchema.extend({
|
|
2464
|
+
subAgents: zodOpenapi.z.record(zodOpenapi.z.string(), FullAgentAgentInsertSchema),
|
|
2465
|
+
// Lookup maps for UI to resolve canUse items
|
|
2466
|
+
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
|
|
2467
|
+
// MCP tools (project-scoped)
|
|
2468
|
+
externalAgents: zodOpenapi.z.record(zodOpenapi.z.string(), ExternalAgentApiInsertSchema).optional(),
|
|
2469
|
+
// External agents (project-scoped)
|
|
2470
|
+
teamAgents: zodOpenapi.z.record(zodOpenapi.z.string(), TeamAgentSchema).optional(),
|
|
2471
|
+
// Team agents contain basic metadata for the agent to be delegated to
|
|
2472
|
+
functionTools: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionToolApiInsertSchema).optional(),
|
|
2473
|
+
// Function tools (agent-scoped)
|
|
2474
|
+
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
2475
|
+
// Get function code for function tools
|
|
2476
|
+
contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
|
|
2477
|
+
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
2478
|
+
models: ModelSchema.optional(),
|
|
2479
|
+
stopWhen: AgentStopWhenSchema.optional(),
|
|
2480
|
+
prompt: zodOpenapi.z.string().max(
|
|
2481
|
+
VALIDATION_AGENT_PROMPT_MAX_CHARS,
|
|
2482
|
+
`Agent prompt cannot exceed ${VALIDATION_AGENT_PROMPT_MAX_CHARS} characters`
|
|
2483
|
+
).optional()
|
|
2484
|
+
}).openapi("AgentWithinContextOfProject");
|
|
2485
|
+
var PaginationSchema = zodOpenapi.z.object({
|
|
2486
|
+
page: pageNumber,
|
|
2487
|
+
limit: limitNumber,
|
|
2488
|
+
total: zodOpenapi.z.number(),
|
|
2489
|
+
pages: zodOpenapi.z.number()
|
|
2490
|
+
}).openapi("Pagination");
|
|
2491
|
+
zodOpenapi.z.object({
|
|
2492
|
+
error: zodOpenapi.z.string(),
|
|
2493
|
+
message: zodOpenapi.z.string().optional(),
|
|
2494
|
+
details: zodOpenapi.z.any().optional().openapi({
|
|
2495
|
+
description: "Additional error details"
|
|
2496
|
+
})
|
|
2497
|
+
}).openapi("ErrorResponse");
|
|
2498
|
+
zodOpenapi.z.object({
|
|
2499
|
+
exists: zodOpenapi.z.boolean()
|
|
2500
|
+
}).openapi("ExistsResponse");
|
|
2501
|
+
zodOpenapi.z.object({
|
|
2502
|
+
message: zodOpenapi.z.string(),
|
|
2503
|
+
removed: zodOpenapi.z.boolean()
|
|
2504
|
+
}).openapi("RemovedResponse");
|
|
2505
|
+
var ProjectSelectSchema = registerFieldSchemas(
|
|
2506
|
+
createSelectSchema(projects).extend({
|
|
2507
|
+
models: ProjectModelSchema.nullable(),
|
|
2508
|
+
stopWhen: StopWhenSchema.nullable()
|
|
2509
|
+
})
|
|
2510
|
+
);
|
|
2511
|
+
var ProjectInsertSchema = createInsertSchema(projects).extend({
|
|
2512
|
+
models: ProjectModelSchema,
|
|
2513
|
+
stopWhen: StopWhenSchema.optional()
|
|
2514
|
+
}).omit({
|
|
2515
|
+
createdAt: true,
|
|
2516
|
+
updatedAt: true
|
|
2517
|
+
});
|
|
2518
|
+
var ProjectUpdateSchema = ProjectInsertSchema.partial().omit({
|
|
2519
|
+
id: true,
|
|
2520
|
+
tenantId: true
|
|
2521
|
+
});
|
|
2522
|
+
var ProjectApiSelectSchema = ProjectSelectSchema.omit({ tenantId: true }).openapi(
|
|
2523
|
+
"Project"
|
|
2524
|
+
);
|
|
2525
|
+
var ProjectApiInsertSchema = ProjectInsertSchema.omit({ tenantId: true }).openapi(
|
|
2526
|
+
"ProjectCreate"
|
|
2527
|
+
);
|
|
2528
|
+
ProjectUpdateSchema.openapi("ProjectUpdate");
|
|
2529
|
+
var FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
|
|
2530
|
+
agents: zodOpenapi.z.record(zodOpenapi.z.string(), AgentWithinContextOfProjectSchema),
|
|
2531
|
+
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema),
|
|
2532
|
+
functionTools: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionToolApiInsertSchema).optional(),
|
|
2533
|
+
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
2534
|
+
dataComponents: zodOpenapi.z.record(zodOpenapi.z.string(), DataComponentApiInsertSchema).optional(),
|
|
2535
|
+
artifactComponents: zodOpenapi.z.record(zodOpenapi.z.string(), ArtifactComponentApiInsertSchema).optional(),
|
|
2536
|
+
externalAgents: zodOpenapi.z.record(zodOpenapi.z.string(), ExternalAgentApiInsertSchema).optional(),
|
|
2537
|
+
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
2538
|
+
credentialReferences: zodOpenapi.z.record(zodOpenapi.z.string(), CredentialReferenceApiInsertSchema).optional(),
|
|
2539
|
+
createdAt: zodOpenapi.z.string().optional(),
|
|
2540
|
+
updatedAt: zodOpenapi.z.string().optional()
|
|
2541
|
+
}).openapi("FullProjectDefinition");
|
|
2542
|
+
zodOpenapi.z.object({ data: ProjectApiSelectSchema }).openapi("ProjectResponse");
|
|
2543
|
+
zodOpenapi.z.object({ data: SubAgentApiSelectSchema }).openapi("SubAgentResponse");
|
|
2544
|
+
zodOpenapi.z.object({ data: AgentApiSelectSchema }).openapi("AgentResponse");
|
|
2545
|
+
zodOpenapi.z.object({ data: ToolApiSelectSchema }).openapi("ToolResponse");
|
|
2546
|
+
zodOpenapi.z.object({ data: ExternalAgentApiSelectSchema }).openapi("ExternalAgentResponse");
|
|
2547
|
+
zodOpenapi.z.object({ data: ContextConfigApiSelectSchema }).openapi("ContextConfigResponse");
|
|
2548
|
+
zodOpenapi.z.object({ data: ApiKeyApiSelectSchema }).openapi("ApiKeyResponse");
|
|
2549
|
+
zodOpenapi.z.object({ data: CredentialReferenceApiSelectSchema }).openapi("CredentialReferenceResponse");
|
|
2550
|
+
zodOpenapi.z.object({ data: FunctionApiSelectSchema }).openapi("FunctionResponse");
|
|
2551
|
+
zodOpenapi.z.object({ data: FunctionToolApiSelectSchema }).openapi("FunctionToolResponse");
|
|
2552
|
+
zodOpenapi.z.object({ data: DataComponentApiSelectSchema }).openapi("DataComponentResponse");
|
|
2553
|
+
zodOpenapi.z.object({ data: ArtifactComponentApiSelectSchema }).openapi("ArtifactComponentResponse");
|
|
2554
|
+
zodOpenapi.z.object({ data: SubAgentRelationApiSelectSchema }).openapi("SubAgentRelationResponse");
|
|
2555
|
+
zodOpenapi.z.object({ data: SubAgentToolRelationApiSelectSchema }).openapi("SubAgentToolRelationResponse");
|
|
2556
|
+
zodOpenapi.z.object({ data: ConversationApiSelectSchema }).openapi("ConversationResponse");
|
|
2557
|
+
zodOpenapi.z.object({ data: MessageApiSelectSchema }).openapi("MessageResponse");
|
|
2558
|
+
zodOpenapi.z.object({
|
|
2559
|
+
data: zodOpenapi.z.array(ProjectApiSelectSchema),
|
|
2560
|
+
pagination: PaginationSchema
|
|
2561
|
+
}).openapi("ProjectListResponse");
|
|
2562
|
+
zodOpenapi.z.object({
|
|
2563
|
+
data: zodOpenapi.z.array(SubAgentApiSelectSchema),
|
|
2564
|
+
pagination: PaginationSchema
|
|
2565
|
+
}).openapi("SubAgentListResponse");
|
|
2566
|
+
zodOpenapi.z.object({
|
|
2567
|
+
data: zodOpenapi.z.array(AgentApiSelectSchema),
|
|
2568
|
+
pagination: PaginationSchema
|
|
2569
|
+
}).openapi("AgentListResponse");
|
|
2570
|
+
zodOpenapi.z.object({
|
|
2571
|
+
data: zodOpenapi.z.array(ToolApiSelectSchema),
|
|
2572
|
+
pagination: PaginationSchema
|
|
2573
|
+
}).openapi("ToolListResponse");
|
|
2574
|
+
zodOpenapi.z.object({
|
|
2575
|
+
data: zodOpenapi.z.array(ExternalAgentApiSelectSchema),
|
|
2576
|
+
pagination: PaginationSchema
|
|
2577
|
+
}).openapi("ExternalAgentListResponse");
|
|
2578
|
+
zodOpenapi.z.object({
|
|
2579
|
+
data: zodOpenapi.z.array(ContextConfigApiSelectSchema),
|
|
2580
|
+
pagination: PaginationSchema
|
|
2581
|
+
}).openapi("ContextConfigListResponse");
|
|
2582
|
+
zodOpenapi.z.object({
|
|
2583
|
+
data: zodOpenapi.z.array(ApiKeyApiSelectSchema),
|
|
2584
|
+
pagination: PaginationSchema
|
|
2585
|
+
}).openapi("ApiKeyListResponse");
|
|
2586
|
+
zodOpenapi.z.object({
|
|
2587
|
+
data: zodOpenapi.z.array(CredentialReferenceApiSelectSchema),
|
|
2588
|
+
pagination: PaginationSchema
|
|
2589
|
+
}).openapi("CredentialReferenceListResponse");
|
|
2590
|
+
zodOpenapi.z.object({
|
|
2591
|
+
data: zodOpenapi.z.array(FunctionApiSelectSchema),
|
|
2592
|
+
pagination: PaginationSchema
|
|
2593
|
+
}).openapi("FunctionListResponse");
|
|
2594
|
+
zodOpenapi.z.object({
|
|
2595
|
+
data: zodOpenapi.z.array(FunctionToolApiSelectSchema),
|
|
2596
|
+
pagination: PaginationSchema
|
|
2597
|
+
}).openapi("FunctionToolListResponse");
|
|
2598
|
+
zodOpenapi.z.object({
|
|
2599
|
+
data: zodOpenapi.z.array(DataComponentApiSelectSchema),
|
|
2600
|
+
pagination: PaginationSchema
|
|
2601
|
+
}).openapi("DataComponentListResponse");
|
|
2602
|
+
zodOpenapi.z.object({
|
|
2603
|
+
data: zodOpenapi.z.array(ArtifactComponentApiSelectSchema),
|
|
2604
|
+
pagination: PaginationSchema
|
|
2605
|
+
}).openapi("ArtifactComponentListResponse");
|
|
2606
|
+
zodOpenapi.z.object({
|
|
2607
|
+
data: zodOpenapi.z.array(SubAgentRelationApiSelectSchema),
|
|
2608
|
+
pagination: PaginationSchema
|
|
2609
|
+
}).openapi("SubAgentRelationListResponse");
|
|
2610
|
+
zodOpenapi.z.object({
|
|
2611
|
+
data: zodOpenapi.z.array(SubAgentToolRelationApiSelectSchema),
|
|
2612
|
+
pagination: PaginationSchema
|
|
2613
|
+
}).openapi("SubAgentToolRelationListResponse");
|
|
2614
|
+
zodOpenapi.z.object({
|
|
2615
|
+
data: zodOpenapi.z.array(ConversationApiSelectSchema),
|
|
2616
|
+
pagination: PaginationSchema
|
|
2617
|
+
}).openapi("ConversationListResponse");
|
|
2618
|
+
zodOpenapi.z.object({
|
|
2619
|
+
data: zodOpenapi.z.array(MessageApiSelectSchema),
|
|
2620
|
+
pagination: PaginationSchema
|
|
2621
|
+
}).openapi("MessageListResponse");
|
|
2622
|
+
zodOpenapi.z.object({ data: SubAgentDataComponentApiSelectSchema }).openapi("SubAgentDataComponentResponse");
|
|
2623
|
+
zodOpenapi.z.object({ data: SubAgentArtifactComponentApiSelectSchema }).openapi("SubAgentArtifactComponentResponse");
|
|
2624
|
+
zodOpenapi.z.object({
|
|
2625
|
+
data: zodOpenapi.z.array(SubAgentDataComponentApiSelectSchema),
|
|
2626
|
+
pagination: PaginationSchema
|
|
2627
|
+
}).openapi("SubAgentDataComponentListResponse");
|
|
2628
|
+
zodOpenapi.z.object({
|
|
2629
|
+
data: zodOpenapi.z.array(SubAgentArtifactComponentApiSelectSchema),
|
|
2630
|
+
pagination: PaginationSchema
|
|
2631
|
+
}).openapi("SubAgentArtifactComponentListResponse");
|
|
2632
|
+
zodOpenapi.z.object({ data: FullProjectDefinitionSchema }).openapi("FullProjectDefinitionResponse");
|
|
2633
|
+
zodOpenapi.z.object({ data: AgentWithinContextOfProjectSchema }).openapi("AgentWithinContextOfProjectResponse");
|
|
2634
|
+
zodOpenapi.z.object({
|
|
2635
|
+
data: zodOpenapi.z.array(RelatedAgentInfoSchema),
|
|
2636
|
+
pagination: PaginationSchema
|
|
2637
|
+
}).openapi("RelatedAgentInfoListResponse");
|
|
2638
|
+
zodOpenapi.z.object({ data: zodOpenapi.z.array(ComponentAssociationSchema) }).openapi("ComponentAssociationListResponse");
|
|
2639
|
+
zodOpenapi.z.object({ data: McpToolSchema }).openapi("McpToolResponse");
|
|
2640
|
+
zodOpenapi.z.object({
|
|
2641
|
+
data: zodOpenapi.z.array(McpToolSchema),
|
|
2642
|
+
pagination: PaginationSchema
|
|
2643
|
+
}).openapi("McpToolListResponse");
|
|
2644
|
+
zodOpenapi.z.object({ data: SubAgentTeamAgentRelationApiSelectSchema }).openapi("SubAgentTeamAgentRelationResponse");
|
|
2645
|
+
zodOpenapi.z.object({
|
|
2646
|
+
data: zodOpenapi.z.array(SubAgentTeamAgentRelationApiSelectSchema),
|
|
2647
|
+
pagination: PaginationSchema
|
|
2648
|
+
}).openapi("SubAgentTeamAgentRelationListResponse");
|
|
2649
|
+
zodOpenapi.z.object({ data: SubAgentExternalAgentRelationApiSelectSchema }).openapi("SubAgentExternalAgentRelationResponse");
|
|
2650
|
+
zodOpenapi.z.object({
|
|
2651
|
+
data: zodOpenapi.z.array(SubAgentExternalAgentRelationApiSelectSchema),
|
|
2652
|
+
pagination: PaginationSchema
|
|
2653
|
+
}).openapi("SubAgentExternalAgentRelationListResponse");
|
|
2654
|
+
zodOpenapi.z.object({ data: zodOpenapi.z.array(DataComponentApiSelectSchema) }).openapi("DataComponentArrayResponse");
|
|
2655
|
+
zodOpenapi.z.object({ data: zodOpenapi.z.array(ArtifactComponentApiSelectSchema) }).openapi("ArtifactComponentArrayResponse");
|
|
2656
|
+
zodOpenapi.z.object({
|
|
2657
|
+
"x-inkeep-tenant-id": zodOpenapi.z.string().optional().openapi({
|
|
2658
|
+
description: "Tenant identifier",
|
|
2659
|
+
example: "tenant_123"
|
|
2660
|
+
}),
|
|
2661
|
+
"x-inkeep-project-id": zodOpenapi.z.string().optional().openapi({
|
|
2662
|
+
description: "Project identifier",
|
|
2663
|
+
example: "project_456"
|
|
2664
|
+
}),
|
|
2665
|
+
"x-inkeep-agent-id": zodOpenapi.z.string().optional().openapi({
|
|
2666
|
+
description: "Agent identifier",
|
|
2667
|
+
example: "agent_789"
|
|
2668
|
+
})
|
|
2669
|
+
});
|
|
2670
|
+
var TenantId = zodOpenapi.z.string().openapi("TenantIdPathParam", {
|
|
2671
|
+
param: {
|
|
2672
|
+
name: "tenantId",
|
|
2673
|
+
in: "path"
|
|
2674
|
+
},
|
|
2675
|
+
description: "Tenant identifier",
|
|
2676
|
+
example: "tenant_123"
|
|
2677
|
+
});
|
|
2678
|
+
var ProjectId = zodOpenapi.z.string().openapi("ProjectIdPathParam", {
|
|
2679
|
+
param: {
|
|
2680
|
+
name: "projectId",
|
|
2681
|
+
in: "path"
|
|
2682
|
+
},
|
|
2683
|
+
description: "Project identifier",
|
|
2684
|
+
example: "project_456"
|
|
2685
|
+
});
|
|
2686
|
+
var AgentId = zodOpenapi.z.string().openapi("AgentIdPathParam", {
|
|
2687
|
+
param: {
|
|
2688
|
+
name: "agentId",
|
|
2689
|
+
in: "path"
|
|
2690
|
+
},
|
|
2691
|
+
description: "Agent identifier",
|
|
2692
|
+
example: "agent_789"
|
|
2693
|
+
});
|
|
2694
|
+
var SubAgentId = zodOpenapi.z.string().openapi("SubAgentIdPathParam", {
|
|
2695
|
+
param: {
|
|
2696
|
+
name: "subAgentId",
|
|
2697
|
+
in: "path"
|
|
2698
|
+
},
|
|
2699
|
+
description: "Sub-agent identifier",
|
|
2700
|
+
example: "sub_agent_123"
|
|
2701
|
+
});
|
|
2702
|
+
var TenantParamsSchema = zodOpenapi.z.object({
|
|
2703
|
+
tenantId: TenantId
|
|
2704
|
+
});
|
|
2705
|
+
TenantParamsSchema.extend({
|
|
2706
|
+
id: resourceIdSchema
|
|
2707
|
+
});
|
|
2708
|
+
var TenantProjectParamsSchema = TenantParamsSchema.extend({
|
|
2709
|
+
projectId: ProjectId
|
|
2710
|
+
});
|
|
2711
|
+
TenantProjectParamsSchema.extend({
|
|
2712
|
+
id: resourceIdSchema
|
|
2713
|
+
});
|
|
2714
|
+
var TenantProjectAgentParamsSchema = TenantProjectParamsSchema.extend({
|
|
2715
|
+
agentId: AgentId
|
|
2716
|
+
});
|
|
2717
|
+
TenantProjectAgentParamsSchema.extend({
|
|
2718
|
+
id: resourceIdSchema
|
|
2719
|
+
});
|
|
2720
|
+
var TenantProjectAgentSubAgentParamsSchema = TenantProjectAgentParamsSchema.extend({
|
|
2721
|
+
subAgentId: SubAgentId
|
|
2722
|
+
});
|
|
2723
|
+
TenantProjectAgentSubAgentParamsSchema.extend({
|
|
2724
|
+
id: resourceIdSchema
|
|
2725
|
+
});
|
|
2726
|
+
zodOpenapi.z.object({
|
|
2727
|
+
page: pageNumber,
|
|
2728
|
+
limit: limitNumber
|
|
2729
|
+
}).openapi("PaginationQueryParams");
|
|
2730
|
+
var PrebuiltMCPServerSchema = zodOpenapi.z.object({
|
|
2731
|
+
id: zodOpenapi.z.string().describe("Unique identifier for the MCP server"),
|
|
2732
|
+
name: zodOpenapi.z.string().describe("Display name of the MCP server"),
|
|
2733
|
+
url: zodOpenapi.z.url().describe("URL endpoint for the MCP server"),
|
|
2734
|
+
transport: zodOpenapi.z.enum(MCPTransportType).describe("Transport protocol type"),
|
|
2735
|
+
imageUrl: zodOpenapi.z.url().optional().describe("Logo/icon URL for the MCP server"),
|
|
2736
|
+
isOpen: zodOpenapi.z.boolean().optional().describe("Whether the MCP server is open (doesn't require authentication)"),
|
|
2737
|
+
category: zodOpenapi.z.string().optional().describe("Category of the MCP server (e.g., communication, project_management)"),
|
|
2738
|
+
description: zodOpenapi.z.string().optional().describe("Brief description of what the MCP server does"),
|
|
2739
|
+
thirdPartyConnectAccountUrl: zodOpenapi.z.url().optional().describe("URL to connect to the third party account")
|
|
2740
|
+
});
|
|
2741
|
+
zodOpenapi.z.object({
|
|
2742
|
+
data: zodOpenapi.z.array(PrebuiltMCPServerSchema)
|
|
2743
|
+
}).openapi("MCPCatalogListResponse");
|
|
2744
|
+
zodOpenapi.z.object({
|
|
2745
|
+
data: PrebuiltMCPServerSchema.nullable()
|
|
2746
|
+
}).openapi("ThirdPartyMCPServerResponse");
|
|
2747
|
+
function validatePropsAsJsonSchema(props) {
|
|
2748
|
+
if (!props || typeof props === "object" && Object.keys(props).length === 0) {
|
|
2749
|
+
return {
|
|
2750
|
+
isValid: true,
|
|
2751
|
+
errors: []
|
|
2752
|
+
};
|
|
2753
|
+
}
|
|
2754
|
+
if (typeof props !== "object" || Array.isArray(props)) {
|
|
2755
|
+
return {
|
|
2756
|
+
isValid: false,
|
|
2757
|
+
errors: [
|
|
2758
|
+
{
|
|
2759
|
+
field: "props",
|
|
2760
|
+
message: "Props must be a valid JSON Schema object",
|
|
2761
|
+
value: props
|
|
2762
|
+
}
|
|
2763
|
+
]
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
2766
|
+
if (!props.type) {
|
|
2767
|
+
return {
|
|
2768
|
+
isValid: false,
|
|
2769
|
+
errors: [
|
|
2770
|
+
{
|
|
2771
|
+
field: "props.type",
|
|
2772
|
+
message: 'JSON Schema must have a "type" field'
|
|
2773
|
+
}
|
|
2774
|
+
]
|
|
2775
|
+
};
|
|
2776
|
+
}
|
|
2777
|
+
if (props.type !== "object") {
|
|
2778
|
+
return {
|
|
2779
|
+
isValid: false,
|
|
2780
|
+
errors: [
|
|
2781
|
+
{
|
|
2782
|
+
field: "props.type",
|
|
2783
|
+
message: 'JSON Schema type must be "object" for component props',
|
|
2784
|
+
value: props.type
|
|
2785
|
+
}
|
|
2786
|
+
]
|
|
2787
|
+
};
|
|
2788
|
+
}
|
|
2789
|
+
if (!props.properties || typeof props.properties !== "object") {
|
|
2790
|
+
return {
|
|
2791
|
+
isValid: false,
|
|
2792
|
+
errors: [
|
|
2793
|
+
{
|
|
2794
|
+
field: "props.properties",
|
|
2795
|
+
message: 'JSON Schema must have a "properties" object'
|
|
2796
|
+
}
|
|
2797
|
+
]
|
|
2798
|
+
};
|
|
2799
|
+
}
|
|
2800
|
+
if (props.required !== void 0 && !Array.isArray(props.required)) {
|
|
2801
|
+
return {
|
|
2802
|
+
isValid: false,
|
|
2803
|
+
errors: [
|
|
2804
|
+
{
|
|
2805
|
+
field: "props.required",
|
|
2806
|
+
message: 'If present, "required" must be an array'
|
|
2807
|
+
}
|
|
2808
|
+
]
|
|
2809
|
+
};
|
|
2810
|
+
}
|
|
2811
|
+
try {
|
|
2812
|
+
const schemaToValidate = { ...props };
|
|
2813
|
+
delete schemaToValidate.$schema;
|
|
2814
|
+
const schemaValidator = new Ajv__default.default({
|
|
2815
|
+
strict: false,
|
|
2816
|
+
// Allow unknown keywords like inPreview
|
|
2817
|
+
validateSchema: true,
|
|
2818
|
+
// Validate the schema itself
|
|
2819
|
+
addUsedSchema: false
|
|
2820
|
+
// Don't add schemas to the instance
|
|
2821
|
+
});
|
|
2822
|
+
const isValid = schemaValidator.validateSchema(schemaToValidate);
|
|
2823
|
+
if (!isValid) {
|
|
2824
|
+
const errors = schemaValidator.errors || [];
|
|
2825
|
+
return {
|
|
2826
|
+
isValid: false,
|
|
2827
|
+
errors: errors.map((error) => ({
|
|
2828
|
+
field: `props${error.instancePath || ""}`,
|
|
2829
|
+
message: error.message || "Invalid schema"
|
|
2830
|
+
}))
|
|
2831
|
+
};
|
|
2832
|
+
}
|
|
2833
|
+
return {
|
|
2834
|
+
isValid: true,
|
|
2835
|
+
errors: []
|
|
2836
|
+
};
|
|
2837
|
+
} catch (error) {
|
|
2838
|
+
return {
|
|
2839
|
+
isValid: false,
|
|
2840
|
+
errors: [
|
|
2841
|
+
{
|
|
2842
|
+
field: "props",
|
|
2843
|
+
message: `Schema validation failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
2844
|
+
}
|
|
2845
|
+
]
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
// src/constants/otel-attributes.ts
|
|
2851
|
+
var DELEGATION_FROM_SUB_AGENT_ID = "delegation.from_sub_agent_id";
|
|
2852
|
+
var DELEGATION_TO_SUB_AGENT_ID = "delegation.to_sub_agent_id";
|
|
2853
|
+
var DELEGATION_ID = "delegation.id";
|
|
2854
|
+
var TRANSFER_FROM_SUB_AGENT_ID = "transfer.from_sub_agent_id";
|
|
2855
|
+
var TRANSFER_TO_SUB_AGENT_ID = "transfer.to_sub_agent_id";
|
|
2856
|
+
var SPAN_NAMES = {
|
|
2857
|
+
AI_TOOL_CALL: "ai.toolCall",
|
|
2858
|
+
CONTEXT_RESOLUTION: "context-resolver.resolve_single_fetch_definition",
|
|
2859
|
+
CONTEXT_HANDLE: "context.handle_context_resolution",
|
|
2860
|
+
AGENT_GENERATION: "agent.generate",
|
|
2861
|
+
CONTEXT_FETCHER: "context-fetcher.http-request",
|
|
2862
|
+
ARTIFACT_PROCESSING: "agent_session.process_artifact"
|
|
2863
|
+
};
|
|
2864
|
+
var AI_OPERATIONS = {
|
|
2865
|
+
GENERATE_TEXT: "ai.generateText.doGenerate",
|
|
2866
|
+
STREAM_TEXT: "ai.streamText.doStream",
|
|
2867
|
+
STREAM_OBJECT: "ai.streamObject.doStream"
|
|
2868
|
+
};
|
|
2869
|
+
var SPAN_KEYS = {
|
|
2870
|
+
// Core span attributes
|
|
2871
|
+
SPAN_ID: "spanID",
|
|
2872
|
+
TRACE_ID: "traceID",
|
|
2873
|
+
DURATION_NANO: "durationNano",
|
|
2874
|
+
TIMESTAMP: "timestamp",
|
|
2875
|
+
HAS_ERROR: "hasError",
|
|
2876
|
+
STATUS_MESSAGE: "status_message",
|
|
2877
|
+
OTEL_STATUS_CODE: "otel.status_code",
|
|
2878
|
+
OTEL_STATUS_DESCRIPTION: "otel.status_description",
|
|
2879
|
+
// Agent attributesa
|
|
2880
|
+
AGENT_ID: "agent.id",
|
|
2881
|
+
AGENT_NAME: "agent.name",
|
|
2882
|
+
TENANT_ID: "tenant.id",
|
|
2883
|
+
PROJECT_ID: "project.id",
|
|
2884
|
+
SUB_AGENT_NAME: "subAgent.name",
|
|
2885
|
+
SUB_AGENT_ID: "subAgent.id",
|
|
2886
|
+
// AI/Agent attributes
|
|
2887
|
+
AI_OPERATION_ID: "ai.operationId",
|
|
2888
|
+
AI_RESPONSE_TIMESTAMP: "ai.response.timestamp",
|
|
2889
|
+
AI_RESPONSE_CONTENT: "ai.response.content",
|
|
2890
|
+
AI_RESPONSE_TEXT: "ai.response.text",
|
|
2891
|
+
AI_RESPONSE_OBJECT: "ai.response.object",
|
|
2892
|
+
AI_RESPONSE_MODEL: "ai.response.model",
|
|
2893
|
+
AI_RESPONSE_TOOL_CALLS: "ai.response.toolCalls",
|
|
2894
|
+
AI_PROMPT_MESSAGES: "ai.prompt.messages",
|
|
2895
|
+
AI_MODEL_PROVIDER: "ai.model.provider",
|
|
2896
|
+
AI_TELEMETRY_FUNCTION_ID: "ai.telemetry.functionId",
|
|
2897
|
+
AI_TELEMETRY_SUB_AGENT_ID: "ai.telemetry.metadata.subAgentId",
|
|
2898
|
+
AI_TELEMETRY_SUB_AGENT_NAME: "ai.telemetry.metadata.subAgentName",
|
|
2899
|
+
AI_MODEL_ID: "ai.model.id",
|
|
2900
|
+
// Tool attributes
|
|
2901
|
+
AI_TOOL_CALL_NAME: "ai.toolCall.name",
|
|
2902
|
+
AI_TOOL_CALL_RESULT: "ai.toolCall.result",
|
|
2903
|
+
AI_TOOL_CALL_ARGS: "ai.toolCall.args",
|
|
2904
|
+
AI_TOOL_CALL_ID: "ai.toolCall.id",
|
|
2905
|
+
AI_TOOL_TYPE: "ai.toolType",
|
|
2906
|
+
TOOL_PURPOSE: "tool.purpose",
|
|
2907
|
+
// Token usage
|
|
2908
|
+
GEN_AI_USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens",
|
|
2909
|
+
GEN_AI_USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens",
|
|
2910
|
+
// Context attributes
|
|
2911
|
+
CONTEXT_URL: "context.url",
|
|
2912
|
+
CONTEXT_CONFIG_ID: "context.context_config_id",
|
|
2913
|
+
CONTEXT_AGENT_ID: "context.agent_id",
|
|
2914
|
+
CONTEXT_HEADERS_KEYS: "context.headers_keys",
|
|
2915
|
+
// Message attributes
|
|
2916
|
+
MESSAGE_CONTENT: "message.content",
|
|
2917
|
+
MESSAGE_TIMESTAMP: "message.timestamp",
|
|
2918
|
+
MCP_TOOL_DESCRIPTION: "mcp.tool.description",
|
|
2919
|
+
// Delegation/Transfer attributes
|
|
2920
|
+
DELEGATION_FROM_SUB_AGENT_ID,
|
|
2921
|
+
DELEGATION_TO_SUB_AGENT_ID,
|
|
2922
|
+
DELEGATION_ID,
|
|
2923
|
+
TRANSFER_FROM_SUB_AGENT_ID,
|
|
2924
|
+
TRANSFER_TO_SUB_AGENT_ID,
|
|
2925
|
+
// HTTP attributes
|
|
2926
|
+
HTTP_URL: "http.url",
|
|
2927
|
+
HTTP_STATUS_CODE: "http.status_code",
|
|
2928
|
+
HTTP_RESPONSE_BODY_SIZE: "http.response.body_size",
|
|
2929
|
+
// Core attributes
|
|
2930
|
+
NAME: "name",
|
|
2931
|
+
PARENT_SPAN_ID: "parentSpanID",
|
|
2932
|
+
CONVERSATION_ID: "conversation.id",
|
|
2933
|
+
// Artifact processing attributes
|
|
2934
|
+
ARTIFACT_ID: "artifact.id",
|
|
2935
|
+
ARTIFACT_TYPE: "artifact.type",
|
|
2936
|
+
ARTIFACT_TOOL_CALL_ID: "artifact.tool_call_id",
|
|
2937
|
+
ARTIFACT_DATA: "artifact.data",
|
|
2938
|
+
ARTIFACT_NAME: "artifact.name",
|
|
2939
|
+
ARTIFACT_DESCRIPTION: "artifact.description"
|
|
2940
|
+
};
|
|
2941
|
+
var UNKNOWN_VALUE = "unknown";
|
|
2942
|
+
var ACTIVITY_TYPES = {
|
|
2943
|
+
TOOL_CALL: "tool_call",
|
|
2944
|
+
AI_GENERATION: "ai_generation",
|
|
2945
|
+
AGENT_GENERATION: "agent_generation",
|
|
2946
|
+
CONTEXT_FETCH: "context_fetch",
|
|
2947
|
+
CONTEXT_RESOLUTION: "context_resolution",
|
|
2948
|
+
USER_MESSAGE: "user_message",
|
|
2949
|
+
AI_ASSISTANT_MESSAGE: "ai_assistant_message",
|
|
2950
|
+
AI_MODEL_STREAMED_TEXT: "ai_model_streamed_text",
|
|
2951
|
+
AI_MODEL_STREAMED_OBJECT: "ai_model_streamed_object"
|
|
2952
|
+
};
|
|
2953
|
+
var ACTIVITY_STATUS = {
|
|
2954
|
+
SUCCESS: "success",
|
|
2955
|
+
ERROR: "error",
|
|
2956
|
+
PENDING: "pending"
|
|
2957
|
+
};
|
|
2958
|
+
var AGENT_IDS = {
|
|
2959
|
+
USER: "user",
|
|
2960
|
+
AI_ASSISTANT: "ai-assistant"
|
|
2961
|
+
};
|
|
2962
|
+
var ACTIVITY_NAMES = {
|
|
2963
|
+
CONTEXT_FETCH: "Context Fetch",
|
|
2964
|
+
USER_MESSAGE: "User Message",
|
|
2965
|
+
AI_ASSISTANT_MESSAGE: "AI Assistant Message",
|
|
2966
|
+
AI_TEXT_GENERATION: "AI Text Generation",
|
|
2967
|
+
AI_STREAMING_TEXT: "AI Streaming Text",
|
|
2968
|
+
AI_STREAMING_OBJECT: "AI Streaming Object",
|
|
2969
|
+
UNKNOWN_AGENT: "Unknown Agent",
|
|
2970
|
+
USER: "User"
|
|
2971
|
+
};
|
|
2972
|
+
var AI_TOOL_TYPES = {
|
|
2973
|
+
MCP: "mcp",
|
|
2974
|
+
TRANSFER: "transfer",
|
|
2975
|
+
DELEGATION: "delegation"
|
|
2976
|
+
};
|
|
2977
|
+
|
|
2978
|
+
// src/constants/signoz-queries.ts
|
|
2979
|
+
var DATA_TYPES = {
|
|
2980
|
+
STRING: "string",
|
|
2981
|
+
INT64: "int64",
|
|
2982
|
+
FLOAT64: "float64",
|
|
2983
|
+
BOOL: "bool"
|
|
2984
|
+
};
|
|
2985
|
+
var FIELD_TYPES = {
|
|
2986
|
+
TAG: "tag",
|
|
2987
|
+
RESOURCE: "resource"
|
|
2988
|
+
};
|
|
2989
|
+
var QUERY_FIELD_CONFIGS = {
|
|
2990
|
+
// String tag fields
|
|
2991
|
+
STRING_TAG: {
|
|
2992
|
+
dataType: DATA_TYPES.STRING,
|
|
2993
|
+
type: FIELD_TYPES.TAG,
|
|
2994
|
+
isColumn: false
|
|
2995
|
+
},
|
|
2996
|
+
STRING_TAG_COLUMN: {
|
|
2997
|
+
dataType: DATA_TYPES.STRING,
|
|
2998
|
+
type: FIELD_TYPES.TAG,
|
|
2999
|
+
isColumn: true
|
|
3000
|
+
},
|
|
3001
|
+
// Numeric tag fields
|
|
3002
|
+
INT64_TAG: {
|
|
3003
|
+
dataType: DATA_TYPES.INT64,
|
|
3004
|
+
type: FIELD_TYPES.TAG,
|
|
3005
|
+
isColumn: false
|
|
3006
|
+
},
|
|
3007
|
+
INT64_TAG_COLUMN: {
|
|
3008
|
+
dataType: DATA_TYPES.INT64,
|
|
3009
|
+
type: FIELD_TYPES.TAG,
|
|
3010
|
+
isColumn: true
|
|
3011
|
+
},
|
|
3012
|
+
FLOAT64_TAG: {
|
|
3013
|
+
dataType: DATA_TYPES.FLOAT64,
|
|
3014
|
+
type: FIELD_TYPES.TAG,
|
|
3015
|
+
isColumn: false
|
|
3016
|
+
},
|
|
3017
|
+
FLOAT64_TAG_COLUMN: {
|
|
3018
|
+
dataType: DATA_TYPES.FLOAT64,
|
|
3019
|
+
type: FIELD_TYPES.TAG,
|
|
3020
|
+
isColumn: true
|
|
3021
|
+
},
|
|
3022
|
+
// Boolean tag fields
|
|
3023
|
+
BOOL_TAG: {
|
|
3024
|
+
dataType: DATA_TYPES.BOOL,
|
|
3025
|
+
type: FIELD_TYPES.TAG,
|
|
3026
|
+
isColumn: false
|
|
3027
|
+
},
|
|
3028
|
+
BOOL_TAG_COLUMN: {
|
|
3029
|
+
dataType: DATA_TYPES.BOOL,
|
|
3030
|
+
type: FIELD_TYPES.TAG,
|
|
3031
|
+
isColumn: true
|
|
3032
|
+
}
|
|
3033
|
+
};
|
|
3034
|
+
var OPERATORS = {
|
|
3035
|
+
// Comparison operators
|
|
3036
|
+
EQUALS: "=",
|
|
3037
|
+
NOT_EQUALS: "!=",
|
|
3038
|
+
LESS_THAN: "<",
|
|
3039
|
+
GREATER_THAN: ">",
|
|
3040
|
+
LESS_THAN_OR_EQUAL: "<=",
|
|
3041
|
+
GREATER_THAN_OR_EQUAL: ">=",
|
|
3042
|
+
// String operators
|
|
3043
|
+
LIKE: "like",
|
|
3044
|
+
NOT_LIKE: "nlike",
|
|
3045
|
+
// Existence operators
|
|
3046
|
+
EXISTS: "exists",
|
|
3047
|
+
NOT_EXISTS: "nexists",
|
|
3048
|
+
// Set operators
|
|
3049
|
+
IN: "in",
|
|
3050
|
+
NOT_IN: "nin",
|
|
3051
|
+
// Logical operators
|
|
3052
|
+
AND: "AND",
|
|
3053
|
+
OR: "OR"
|
|
3054
|
+
};
|
|
3055
|
+
var QUERY_EXPRESSIONS = {
|
|
3056
|
+
SPAN_NAMES: "spanNames",
|
|
3057
|
+
AGENT_MODEL_CALLS: "agentModelCalls",
|
|
3058
|
+
MODEL_CALLS: "modelCalls",
|
|
3059
|
+
LAST_ACTIVITY: "lastActivity",
|
|
3060
|
+
CONVERSATION_METADATA: "conversationMetadata",
|
|
3061
|
+
FILTERED_CONVERSATIONS: "filteredConversations",
|
|
3062
|
+
TOOLS: "tools",
|
|
3063
|
+
TRANSFERS: "transfers",
|
|
3064
|
+
DELEGATIONS: "delegations",
|
|
3065
|
+
AI_CALLS: "aiCalls",
|
|
3066
|
+
CONTEXT_ERRORS: "contextErrors",
|
|
3067
|
+
AGENT_GENERATION_ERRORS: "agentGenerationErrors",
|
|
3068
|
+
USER_MESSAGES: "userMessages",
|
|
3069
|
+
UNIQUE_AGENTS: "uniqueAgents",
|
|
3070
|
+
UNIQUE_MODELS: "uniqueModels",
|
|
3071
|
+
// Route-specific query names
|
|
3072
|
+
TOOL_CALLS: "toolCalls",
|
|
3073
|
+
CONTEXT_RESOLUTION: "contextResolution",
|
|
3074
|
+
CONTEXT_HANDLE: "contextHandle",
|
|
3075
|
+
AI_ASSISTANT_MESSAGES: "aiAssistantMessages",
|
|
3076
|
+
AI_GENERATIONS: "aiGenerations",
|
|
3077
|
+
AI_STREAMING_TEXT: "aiStreamingText",
|
|
3078
|
+
AI_STREAMING_OBJECT: "aiStreamingObject",
|
|
3079
|
+
CONTEXT_FETCHERS: "contextFetchers",
|
|
3080
|
+
DURATION_SPANS: "durationSpans",
|
|
3081
|
+
AGENT_GENERATIONS: "agentGenerations",
|
|
3082
|
+
SPANS_WITH_ERRORS: "spansWithErrors",
|
|
3083
|
+
ARTIFACT_PROCESSING: "artifactProcessing"
|
|
3084
|
+
};
|
|
3085
|
+
var REDUCE_OPERATIONS = {
|
|
3086
|
+
SUM: "sum",
|
|
3087
|
+
MAX: "max",
|
|
3088
|
+
MIN: "min",
|
|
3089
|
+
AVG: "avg",
|
|
3090
|
+
COUNT: "count"
|
|
3091
|
+
};
|
|
3092
|
+
var ORDER_DIRECTIONS = {
|
|
3093
|
+
ASC: "asc",
|
|
3094
|
+
DESC: "desc"
|
|
3095
|
+
};
|
|
3096
|
+
var QUERY_TYPES = {
|
|
3097
|
+
BUILDER: "builder",
|
|
3098
|
+
CLICKHOUSE: "clickhouse",
|
|
3099
|
+
PROMQL: "promql"
|
|
3100
|
+
};
|
|
3101
|
+
var PANEL_TYPES = {
|
|
3102
|
+
LIST: "list",
|
|
3103
|
+
TABLE: "table",
|
|
3104
|
+
AGENT: "agent",
|
|
3105
|
+
VALUE: "value"
|
|
3106
|
+
};
|
|
3107
|
+
var DATA_SOURCES = {
|
|
3108
|
+
TRACES: "traces",
|
|
3109
|
+
METRICS: "metrics",
|
|
3110
|
+
LOGS: "logs"
|
|
3111
|
+
};
|
|
3112
|
+
var AGGREGATE_OPERATORS = {
|
|
3113
|
+
COUNT: "count",
|
|
3114
|
+
COUNT_DISTINCT: "count_distinct",
|
|
3115
|
+
SUM: "sum",
|
|
3116
|
+
AVG: "avg",
|
|
3117
|
+
MIN: "min",
|
|
3118
|
+
MAX: "max",
|
|
3119
|
+
NOOP: "noop"
|
|
3120
|
+
};
|
|
3121
|
+
var QUERY_DEFAULTS = {
|
|
3122
|
+
STEP: 60,
|
|
3123
|
+
STEP_INTERVAL: 60,
|
|
3124
|
+
OFFSET: 0,
|
|
3125
|
+
DISABLED: false,
|
|
3126
|
+
HAVING: [],
|
|
3127
|
+
LEGEND: "",
|
|
3128
|
+
LIMIT_UNLIMITED: 1e4,
|
|
3129
|
+
EMPTY_GROUP_BY: []
|
|
3130
|
+
};
|
|
3131
|
+
function discoverScopes(resourceMetadata, metadata) {
|
|
3132
|
+
const resourceScopes = resourceMetadata?.scopes_supported;
|
|
3133
|
+
const oauthScopes = metadata?.scopes_supported;
|
|
3134
|
+
const scopes = (resourceScopes?.length ? resourceScopes : oauthScopes) || [];
|
|
3135
|
+
return scopes.length > 0 ? scopes.join(" ") : void 0;
|
|
3136
|
+
}
|
|
3137
|
+
async function discoverMcpMetadata(mcpServerUrl, logger) {
|
|
3138
|
+
try {
|
|
3139
|
+
let resourceMetadata = null;
|
|
3140
|
+
let authServerUrl = new URL(mcpServerUrl);
|
|
3141
|
+
try {
|
|
3142
|
+
resourceMetadata = await auth_js.discoverOAuthProtectedResourceMetadata(mcpServerUrl);
|
|
3143
|
+
if (resourceMetadata?.authorization_servers?.length && resourceMetadata.authorization_servers[0]) {
|
|
3144
|
+
authServerUrl = new URL(resourceMetadata.authorization_servers[0]);
|
|
3145
|
+
}
|
|
3146
|
+
} catch {
|
|
3147
|
+
}
|
|
3148
|
+
const metadata = await auth_js.discoverAuthorizationServerMetadata(authServerUrl.href);
|
|
3149
|
+
if (!metadata) {
|
|
3150
|
+
throw new Error("Failed to discover OAuth authorization server metadata");
|
|
3151
|
+
}
|
|
3152
|
+
logger?.debug(
|
|
3153
|
+
{
|
|
3154
|
+
tokenEndpoint: metadata.token_endpoint,
|
|
3155
|
+
authEndpoint: metadata.authorization_endpoint
|
|
3156
|
+
},
|
|
3157
|
+
"MCP metadata discovery successful"
|
|
3158
|
+
);
|
|
3159
|
+
const discoveredScopes = discoverScopes(resourceMetadata ?? void 0, metadata);
|
|
3160
|
+
return {
|
|
3161
|
+
success: true,
|
|
3162
|
+
metadata,
|
|
3163
|
+
...resourceMetadata && { resourceMetadata },
|
|
3164
|
+
...discoveredScopes && { scopes: discoveredScopes }
|
|
3165
|
+
};
|
|
3166
|
+
} catch (err) {
|
|
3167
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
3168
|
+
logger?.debug({ error: errorMessage }, "MCP metadata discovery failed");
|
|
3169
|
+
return { success: false, error: errorMessage };
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
var detectAuthenticationRequired = async ({
|
|
3173
|
+
serverUrl,
|
|
3174
|
+
error,
|
|
3175
|
+
logger
|
|
3176
|
+
}) => {
|
|
3177
|
+
try {
|
|
3178
|
+
const discoveryResult = await discoverMcpMetadata(serverUrl, logger);
|
|
3179
|
+
if (discoveryResult.success && discoveryResult.metadata) {
|
|
3180
|
+
logger?.info({ serverUrl }, "MCP OAuth support confirmed via metadata discovery");
|
|
3181
|
+
return true;
|
|
3182
|
+
}
|
|
3183
|
+
} catch (discoveryError) {
|
|
3184
|
+
logger?.debug({ discoveryError }, "MCP OAuth metadata discovery failed");
|
|
3185
|
+
}
|
|
3186
|
+
logger?.debug({ error: error?.message }, "No MCP OAuth authentication requirement detected");
|
|
3187
|
+
return false;
|
|
3188
|
+
};
|
|
3189
|
+
|
|
3190
|
+
// src/client-exports.ts
|
|
3191
|
+
var {
|
|
3192
|
+
AGENT_EXECUTION_TRANSFER_COUNT_MAX: AGENT_EXECUTION_TRANSFER_COUNT_MAX2,
|
|
3193
|
+
AGENT_EXECUTION_TRANSFER_COUNT_MIN: AGENT_EXECUTION_TRANSFER_COUNT_MIN2,
|
|
3194
|
+
STATUS_UPDATE_MAX_INTERVAL_SECONDS: STATUS_UPDATE_MAX_INTERVAL_SECONDS2,
|
|
3195
|
+
STATUS_UPDATE_MAX_NUM_EVENTS: STATUS_UPDATE_MAX_NUM_EVENTS2,
|
|
3196
|
+
VALIDATION_AGENT_PROMPT_MAX_CHARS: VALIDATION_AGENT_PROMPT_MAX_CHARS2,
|
|
3197
|
+
VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS: VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS2
|
|
3198
|
+
} = schemaValidationDefaults;
|
|
3199
|
+
var TenantParamsSchema2 = zod.z.object({
|
|
3200
|
+
tenantId: zod.z.string()
|
|
3201
|
+
});
|
|
3202
|
+
var TenantProjectParamsSchema2 = TenantParamsSchema2.extend({
|
|
3203
|
+
projectId: zod.z.string()
|
|
3204
|
+
});
|
|
3205
|
+
var TenantProjectIdParamsSchema2 = TenantProjectParamsSchema2.extend({
|
|
3206
|
+
id: zod.z.string()
|
|
3207
|
+
});
|
|
3208
|
+
var IdParamsSchema = zod.z.object({
|
|
3209
|
+
id: zod.z.string()
|
|
3210
|
+
});
|
|
3211
|
+
var PaginationSchema2 = zod.z.object({
|
|
3212
|
+
page: zod.z.coerce.number().min(1).default(1),
|
|
3213
|
+
limit: zod.z.coerce.number().min(1).max(100).default(10),
|
|
3214
|
+
total: zod.z.number(),
|
|
3215
|
+
pages: zod.z.number()
|
|
3216
|
+
});
|
|
3217
|
+
var ListResponseSchema = (itemSchema) => zod.z.object({
|
|
3218
|
+
data: zod.z.array(itemSchema),
|
|
3219
|
+
pagination: PaginationSchema2
|
|
3220
|
+
});
|
|
3221
|
+
var SingleResponseSchema = (itemSchema) => zod.z.object({
|
|
3222
|
+
data: itemSchema
|
|
3223
|
+
});
|
|
3224
|
+
var ErrorResponseSchema2 = zod.z.object({
|
|
3225
|
+
error: zod.z.string(),
|
|
3226
|
+
message: zod.z.string().optional(),
|
|
3227
|
+
details: zod.z.unknown().optional()
|
|
3228
|
+
});
|
|
3229
|
+
var AgentApiInsertSchema2 = zod.z.object({
|
|
3230
|
+
id: zod.z.string().optional(),
|
|
3231
|
+
name: zod.z.string(),
|
|
3232
|
+
description: zod.z.string().optional(),
|
|
3233
|
+
prompt: zod.z.string().optional(),
|
|
3234
|
+
model: ModelSettingsSchema.optional(),
|
|
3235
|
+
tools: zod.z.array(zod.z.string()).optional(),
|
|
3236
|
+
dataComponents: zod.z.array(zod.z.string()).optional(),
|
|
3237
|
+
artifactComponents: zod.z.array(zod.z.string()).optional(),
|
|
3238
|
+
canTransferTo: zod.z.array(zod.z.string()).optional(),
|
|
3239
|
+
canDelegateTo: zod.z.array(zod.z.string()).optional(),
|
|
3240
|
+
type: zod.z.enum(["internal", "external"]).optional()
|
|
3241
|
+
});
|
|
3242
|
+
var ToolApiInsertSchema2 = zod.z.object({
|
|
3243
|
+
id: zod.z.string().optional(),
|
|
3244
|
+
name: zod.z.string(),
|
|
3245
|
+
description: zod.z.string().optional(),
|
|
3246
|
+
type: zod.z.enum(["mcp", "hosted"]),
|
|
3247
|
+
config: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
3248
|
+
credentialReferenceId: zod.z.string().optional()
|
|
3249
|
+
});
|
|
3250
|
+
var ApiKeyApiSelectSchema2 = zod.z.object({
|
|
3251
|
+
id: zod.z.string(),
|
|
3252
|
+
tenantId: zod.z.string(),
|
|
3253
|
+
projectId: zod.z.string(),
|
|
3254
|
+
agentId: zod.z.string(),
|
|
3255
|
+
publicId: zod.z.string(),
|
|
3256
|
+
keyHash: zod.z.string(),
|
|
3257
|
+
keyPrefix: zod.z.string(),
|
|
3258
|
+
name: zod.z.string().optional(),
|
|
3259
|
+
lastUsedAt: zod.z.string().optional(),
|
|
3260
|
+
expiresAt: zod.z.string().optional(),
|
|
3261
|
+
createdAt: zod.z.string(),
|
|
3262
|
+
updatedAt: zod.z.string()
|
|
3263
|
+
});
|
|
3264
|
+
var ApiKeyApiCreationResponseSchema2 = zod.z.object({
|
|
3265
|
+
data: zod.z.object({
|
|
3266
|
+
apiKey: ApiKeyApiSelectSchema2,
|
|
3267
|
+
key: zod.z.string()
|
|
3268
|
+
})
|
|
3269
|
+
});
|
|
3270
|
+
var CredentialReferenceApiInsertSchema2 = zod.z.object({
|
|
3271
|
+
id: zod.z.string(),
|
|
3272
|
+
tenantId: zod.z.string().optional(),
|
|
3273
|
+
projectId: zod.z.string().optional(),
|
|
3274
|
+
name: zod.z.string(),
|
|
3275
|
+
type: zod.z.enum(CredentialStoreType),
|
|
3276
|
+
credentialStoreId: zod.z.string(),
|
|
3277
|
+
retrievalParams: zod.z.record(zod.z.string(), zod.z.unknown()).nullish()
|
|
3278
|
+
});
|
|
3279
|
+
var DataComponentApiInsertSchema2 = zod.z.object({
|
|
3280
|
+
id: zod.z.string(),
|
|
3281
|
+
name: zod.z.string(),
|
|
3282
|
+
description: zod.z.string().optional(),
|
|
3283
|
+
props: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
3284
|
+
render: zod.z.object({
|
|
3285
|
+
component: zod.z.string(),
|
|
3286
|
+
mockData: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
3287
|
+
}).nullable().optional()
|
|
3288
|
+
});
|
|
3289
|
+
var ArtifactComponentApiInsertSchema2 = ArtifactComponentApiInsertSchema;
|
|
3290
|
+
var ContextConfigApiInsertSchema2 = zod.z.object({
|
|
3291
|
+
id: zod.z.string().optional(),
|
|
3292
|
+
name: zod.z.string().optional(),
|
|
3293
|
+
description: zod.z.string().optional(),
|
|
3294
|
+
type: zod.z.string().optional(),
|
|
3295
|
+
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3296
|
+
});
|
|
3297
|
+
var ExternalAgentApiInsertSchema2 = zod.z.object({
|
|
3298
|
+
id: zod.z.string().optional(),
|
|
3299
|
+
name: zod.z.string(),
|
|
3300
|
+
description: zod.z.string().optional(),
|
|
3301
|
+
baseUrl: zod.z.string(),
|
|
3302
|
+
headers: zod.z.record(zod.z.string(), zod.z.string()).nullable().optional(),
|
|
3303
|
+
credentialReferenceId: zod.z.string().nullable().optional(),
|
|
3304
|
+
type: zod.z.literal("external").optional()
|
|
3305
|
+
});
|
|
3306
|
+
var AgentAgentApiInsertSchema = zod.z.object({
|
|
3307
|
+
id: zod.z.string().optional(),
|
|
3308
|
+
name: zod.z.string(),
|
|
3309
|
+
description: zod.z.string().optional(),
|
|
3310
|
+
defaultSubAgentId: zod.z.string().optional()
|
|
3311
|
+
});
|
|
3312
|
+
var FullAgentDefinitionSchema = AgentAgentApiInsertSchema.extend({
|
|
3313
|
+
subAgents: zod.z.record(zod.z.string(), zod.z.union([FullAgentAgentInsertSchema])),
|
|
3314
|
+
contextConfig: zod.z.optional(ContextConfigApiInsertSchema2),
|
|
3315
|
+
models: zod.z.object({
|
|
3316
|
+
base: zod.z.object({
|
|
3317
|
+
model: zod.z.string(),
|
|
3318
|
+
providerOptions: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.unknown())).optional()
|
|
3319
|
+
}).optional(),
|
|
3320
|
+
structuredOutput: zod.z.object({
|
|
3321
|
+
model: zod.z.string(),
|
|
3322
|
+
providerOptions: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.unknown())).optional()
|
|
3323
|
+
}).optional(),
|
|
3324
|
+
summarizer: zod.z.object({
|
|
3325
|
+
model: zod.z.string(),
|
|
3326
|
+
providerOptions: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.unknown())).optional()
|
|
3327
|
+
}).optional()
|
|
3328
|
+
}).optional(),
|
|
3329
|
+
stopWhen: zod.z.object({
|
|
3330
|
+
transferCountIs: zod.z.number().min(AGENT_EXECUTION_TRANSFER_COUNT_MIN2).max(AGENT_EXECUTION_TRANSFER_COUNT_MAX2).optional()
|
|
3331
|
+
}).optional(),
|
|
3332
|
+
prompt: zod.z.string().max(VALIDATION_AGENT_PROMPT_MAX_CHARS2).optional(),
|
|
3333
|
+
statusUpdates: zod.z.object({
|
|
3334
|
+
enabled: zod.z.boolean().optional(),
|
|
3335
|
+
numEvents: zod.z.number().min(1).max(STATUS_UPDATE_MAX_NUM_EVENTS2).optional(),
|
|
3336
|
+
timeInSeconds: zod.z.number().min(1).max(STATUS_UPDATE_MAX_INTERVAL_SECONDS2).optional(),
|
|
3337
|
+
prompt: zod.z.string().max(VALIDATION_SUB_AGENT_PROMPT_MAX_CHARS2).optional(),
|
|
3338
|
+
statusComponents: zod.z.array(
|
|
3339
|
+
zod.z.object({
|
|
3340
|
+
type: zod.z.string(),
|
|
3341
|
+
description: zod.z.string().optional(),
|
|
3342
|
+
detailsSchema: zod.z.object({
|
|
3343
|
+
type: zod.z.literal("object"),
|
|
3344
|
+
properties: zod.z.record(zod.z.string(), zod.z.any()),
|
|
3345
|
+
required: zod.z.array(zod.z.string()).optional()
|
|
3346
|
+
}).optional()
|
|
3347
|
+
})
|
|
3348
|
+
).optional()
|
|
3349
|
+
}).optional()
|
|
3350
|
+
});
|
|
3351
|
+
var MIN_ID_LENGTH2 = 1;
|
|
3352
|
+
var MAX_ID_LENGTH2 = 255;
|
|
3353
|
+
var URL_SAFE_ID_PATTERN2 = /^[a-zA-Z0-9\-_.]+$/;
|
|
3354
|
+
var resourceIdSchema2 = zod.z.string().min(MIN_ID_LENGTH2).max(MAX_ID_LENGTH2).regex(URL_SAFE_ID_PATTERN2, {
|
|
3355
|
+
message: "ID must contain only letters, numbers, hyphens, underscores, and dots"
|
|
3356
|
+
});
|
|
3357
|
+
function generateIdFromName(name) {
|
|
3358
|
+
return name.toLowerCase().replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, MAX_ID_LENGTH2);
|
|
3359
|
+
}
|
|
3360
|
+
|
|
3361
|
+
exports.ACTIVITY_NAMES = ACTIVITY_NAMES;
|
|
3362
|
+
exports.ACTIVITY_STATUS = ACTIVITY_STATUS;
|
|
3363
|
+
exports.ACTIVITY_TYPES = ACTIVITY_TYPES;
|
|
3364
|
+
exports.AGENT_IDS = AGENT_IDS;
|
|
3365
|
+
exports.AGGREGATE_OPERATORS = AGGREGATE_OPERATORS;
|
|
3366
|
+
exports.AI_OPERATIONS = AI_OPERATIONS;
|
|
3367
|
+
exports.AI_TOOL_TYPES = AI_TOOL_TYPES;
|
|
3368
|
+
exports.AgentAgentApiInsertSchema = AgentAgentApiInsertSchema;
|
|
3369
|
+
exports.AgentApiInsertSchema = AgentApiInsertSchema2;
|
|
3370
|
+
exports.AgentStopWhenSchema = AgentStopWhenSchema;
|
|
3371
|
+
exports.ApiKeyApiCreationResponseSchema = ApiKeyApiCreationResponseSchema2;
|
|
3372
|
+
exports.ApiKeyApiSelectSchema = ApiKeyApiSelectSchema2;
|
|
3373
|
+
exports.ArtifactComponentApiInsertSchema = ArtifactComponentApiInsertSchema2;
|
|
3374
|
+
exports.ContextConfigApiInsertSchema = ContextConfigApiInsertSchema2;
|
|
3375
|
+
exports.CredentialReferenceApiInsertSchema = CredentialReferenceApiInsertSchema2;
|
|
3376
|
+
exports.CredentialStoreType = CredentialStoreType;
|
|
3377
|
+
exports.DATA_SOURCES = DATA_SOURCES;
|
|
3378
|
+
exports.DATA_TYPES = DATA_TYPES;
|
|
3379
|
+
exports.DELEGATION_FROM_SUB_AGENT_ID = DELEGATION_FROM_SUB_AGENT_ID;
|
|
3380
|
+
exports.DELEGATION_ID = DELEGATION_ID;
|
|
3381
|
+
exports.DELEGATION_TO_SUB_AGENT_ID = DELEGATION_TO_SUB_AGENT_ID;
|
|
3382
|
+
exports.DataComponentApiInsertSchema = DataComponentApiInsertSchema2;
|
|
3383
|
+
exports.ErrorResponseSchema = ErrorResponseSchema2;
|
|
3384
|
+
exports.ExternalAgentApiInsertSchema = ExternalAgentApiInsertSchema2;
|
|
3385
|
+
exports.FIELD_TYPES = FIELD_TYPES;
|
|
3386
|
+
exports.FullAgentDefinitionSchema = FullAgentDefinitionSchema;
|
|
3387
|
+
exports.FunctionApiInsertSchema = FunctionApiInsertSchema;
|
|
3388
|
+
exports.FunctionApiSelectSchema = FunctionApiSelectSchema;
|
|
3389
|
+
exports.FunctionApiUpdateSchema = FunctionApiUpdateSchema;
|
|
3390
|
+
exports.IdParamsSchema = IdParamsSchema;
|
|
3391
|
+
exports.ListResponseSchema = ListResponseSchema;
|
|
3392
|
+
exports.MAX_ID_LENGTH = MAX_ID_LENGTH2;
|
|
3393
|
+
exports.MCPTransportType = MCPTransportType;
|
|
3394
|
+
exports.MIN_ID_LENGTH = MIN_ID_LENGTH2;
|
|
3395
|
+
exports.ModelSettingsSchema = ModelSettingsSchema;
|
|
3396
|
+
exports.OPERATORS = OPERATORS;
|
|
3397
|
+
exports.ORDER_DIRECTIONS = ORDER_DIRECTIONS;
|
|
3398
|
+
exports.PANEL_TYPES = PANEL_TYPES;
|
|
3399
|
+
exports.PaginationSchema = PaginationSchema2;
|
|
3400
|
+
exports.QUERY_DEFAULTS = QUERY_DEFAULTS;
|
|
3401
|
+
exports.QUERY_EXPRESSIONS = QUERY_EXPRESSIONS;
|
|
3402
|
+
exports.QUERY_FIELD_CONFIGS = QUERY_FIELD_CONFIGS;
|
|
3403
|
+
exports.QUERY_TYPES = QUERY_TYPES;
|
|
3404
|
+
exports.REDUCE_OPERATIONS = REDUCE_OPERATIONS;
|
|
3405
|
+
exports.SPAN_KEYS = SPAN_KEYS;
|
|
3406
|
+
exports.SPAN_NAMES = SPAN_NAMES;
|
|
3407
|
+
exports.SingleResponseSchema = SingleResponseSchema;
|
|
3408
|
+
exports.StopWhenSchema = StopWhenSchema;
|
|
3409
|
+
exports.SubAgentStopWhenSchema = SubAgentStopWhenSchema;
|
|
3410
|
+
exports.TRANSFER_FROM_SUB_AGENT_ID = TRANSFER_FROM_SUB_AGENT_ID;
|
|
3411
|
+
exports.TRANSFER_TO_SUB_AGENT_ID = TRANSFER_TO_SUB_AGENT_ID;
|
|
3412
|
+
exports.TenantParamsSchema = TenantParamsSchema2;
|
|
3413
|
+
exports.TenantProjectIdParamsSchema = TenantProjectIdParamsSchema2;
|
|
3414
|
+
exports.TenantProjectParamsSchema = TenantProjectParamsSchema2;
|
|
3415
|
+
exports.ToolApiInsertSchema = ToolApiInsertSchema2;
|
|
3416
|
+
exports.UNKNOWN_VALUE = UNKNOWN_VALUE;
|
|
3417
|
+
exports.URL_SAFE_ID_PATTERN = URL_SAFE_ID_PATTERN2;
|
|
3418
|
+
exports.detectAuthenticationRequired = detectAuthenticationRequired;
|
|
3419
|
+
exports.generateIdFromName = generateIdFromName;
|
|
3420
|
+
exports.resourceIdSchema = resourceIdSchema2;
|
|
3421
|
+
exports.validatePropsAsJsonSchema = validatePropsAsJsonSchema;
|