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