@inkeep/agents-core 0.0.0-dev-20251009192735 → 0.0.0-dev-20251009215610
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/README.md +2 -2
- package/dist/{chunk-VPJ6Z5QZ.js → chunk-5LRSB445.js} +115 -118
- package/dist/{chunk-TO2HNKGP.js → chunk-BVURASVM.js} +74 -110
- package/dist/chunk-TCLX6C3C.js +271 -0
- package/dist/chunk-ZSQFZL3Y.js +173 -0
- package/dist/client-exports.cjs +483 -225
- package/dist/client-exports.d.cts +6 -5
- package/dist/client-exports.d.ts +6 -5
- package/dist/client-exports.js +5 -4
- package/dist/db/schema.cjs +114 -117
- package/dist/db/schema.d.cts +2 -2
- package/dist/db/schema.d.ts +2 -2
- package/dist/db/schema.js +1 -1
- package/dist/index.cjs +1687 -1360
- package/dist/index.d.cts +1530 -1524
- package/dist/index.d.ts +1530 -1524
- package/dist/index.js +1016 -989
- package/dist/{schema-Ct2NlO81.d.cts → schema-B1rukNyF.d.ts} +118 -137
- package/dist/{schema-BQk_FMBV.d.ts → schema-BIYOOKX_.d.cts} +118 -137
- package/dist/signoz-queries-CifqdbnO.d.cts +269 -0
- package/dist/signoz-queries-CifqdbnO.d.ts +269 -0
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/{utility-s9c5CVOe.d.cts → utility-BEeDGMP9.d.cts} +226 -297
- package/dist/{utility-s9c5CVOe.d.ts → utility-BEeDGMP9.d.ts} +226 -297
- package/dist/validation/index.cjs +243 -238
- package/dist/validation/index.d.cts +76 -4
- package/dist/validation/index.d.ts +76 -4
- package/dist/validation/index.js +2 -2
- package/drizzle/0005_wide_shriek.sql +127 -0
- package/drizzle/meta/0005_snapshot.json +2558 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
- package/dist/chunk-L53XWAYG.js +0 -134
package/dist/index.cjs
CHANGED
|
@@ -64,6 +64,276 @@ async function apiFetch(url, options = {}) {
|
|
|
64
64
|
headers: headers2
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
+
|
|
68
|
+
// src/constants/otel-attributes.ts
|
|
69
|
+
var DELEGATION_FROM_SUB_AGENT_ID = "delegation.from_sub_agent_id";
|
|
70
|
+
var DELEGATION_TO_SUB_AGENT_ID = "delegation.to_sub_agent_id";
|
|
71
|
+
var DELEGATION_ID = "delegation.id";
|
|
72
|
+
var TRANSFER_FROM_SUB_AGENT_ID = "transfer.from_sub_agent_id";
|
|
73
|
+
var TRANSFER_TO_SUB_AGENT_ID = "transfer.to_sub_agent_id";
|
|
74
|
+
var SPAN_NAMES = {
|
|
75
|
+
AI_TOOL_CALL: "ai.toolCall",
|
|
76
|
+
CONTEXT_RESOLUTION: "context-resolver.resolve_single_fetch_definition",
|
|
77
|
+
CONTEXT_HANDLE: "context.handle_context_resolution",
|
|
78
|
+
AGENT_GENERATION: "agent.generate",
|
|
79
|
+
CONTEXT_FETCHER: "context-fetcher.http-request"
|
|
80
|
+
};
|
|
81
|
+
var AI_OPERATIONS = {
|
|
82
|
+
GENERATE_TEXT: "ai.generateText.doGenerate",
|
|
83
|
+
STREAM_TEXT: "ai.streamText.doStream"
|
|
84
|
+
};
|
|
85
|
+
var SPAN_KEYS = {
|
|
86
|
+
// Core span attributes
|
|
87
|
+
SPAN_ID: "spanID",
|
|
88
|
+
TRACE_ID: "traceID",
|
|
89
|
+
DURATION_NANO: "durationNano",
|
|
90
|
+
TIMESTAMP: "timestamp",
|
|
91
|
+
HAS_ERROR: "hasError",
|
|
92
|
+
STATUS_MESSAGE: "status_message",
|
|
93
|
+
OTEL_STATUS_CODE: "otel.status_code",
|
|
94
|
+
OTEL_STATUS_DESCRIPTION: "otel.status_description",
|
|
95
|
+
// Graph attributes
|
|
96
|
+
GRAPH_ID: "graph.id",
|
|
97
|
+
GRAPH_NAME: "graph.name",
|
|
98
|
+
TENANT_ID: "tenant.id",
|
|
99
|
+
PROJECT_ID: "project.id",
|
|
100
|
+
// AI/Agent attributes
|
|
101
|
+
AI_AGENT_NAME: "ai.agentName",
|
|
102
|
+
AI_AGENT_NAME_ALT: "ai.agent.name",
|
|
103
|
+
AI_OPERATION_ID: "ai.operationId",
|
|
104
|
+
AI_RESPONSE_TIMESTAMP: "ai.response.timestamp",
|
|
105
|
+
AI_RESPONSE_CONTENT: "ai.response.content",
|
|
106
|
+
AI_RESPONSE_TEXT: "ai.response.text",
|
|
107
|
+
AI_RESPONSE_MODEL: "ai.response.model",
|
|
108
|
+
AI_RESPONSE_TOOL_CALLS: "ai.response.toolCalls",
|
|
109
|
+
AI_PROMPT_MESSAGES: "ai.prompt.messages",
|
|
110
|
+
AI_MODEL_PROVIDER: "ai.model.provider",
|
|
111
|
+
AI_TELEMETRY_FUNCTION_ID: "ai.telemetry.functionId",
|
|
112
|
+
AI_MODEL_ID: "ai.model.id",
|
|
113
|
+
// Tool attributes
|
|
114
|
+
AI_TOOL_CALL_NAME: "ai.toolCall.name",
|
|
115
|
+
AI_TOOL_CALL_RESULT: "ai.toolCall.result",
|
|
116
|
+
AI_TOOL_CALL_ARGS: "ai.toolCall.args",
|
|
117
|
+
AI_TOOL_CALL_ID: "ai.toolCall.id",
|
|
118
|
+
AI_TOOL_TYPE: "ai.toolType",
|
|
119
|
+
TOOL_PURPOSE: "tool.purpose",
|
|
120
|
+
// Agent attributes
|
|
121
|
+
AGENT_ID: "agent.id",
|
|
122
|
+
AGENT_NAME: "agent.name",
|
|
123
|
+
// Token usage
|
|
124
|
+
GEN_AI_USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens",
|
|
125
|
+
GEN_AI_USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens",
|
|
126
|
+
// Context attributes
|
|
127
|
+
CONTEXT_URL: "context.url",
|
|
128
|
+
CONTEXT_CONFIG_ID: "context.context_config_id",
|
|
129
|
+
CONTEXT_AGENT_GRAPH_ID: "context.agent_graph_id",
|
|
130
|
+
CONTEXT_HEADERS_KEYS: "context.headers_keys",
|
|
131
|
+
// Message attributes
|
|
132
|
+
MESSAGE_CONTENT: "message.content",
|
|
133
|
+
MESSAGE_TIMESTAMP: "message.timestamp",
|
|
134
|
+
MCP_TOOL_DESCRIPTION: "mcp.tool.description",
|
|
135
|
+
// Delegation/Transfer attributes
|
|
136
|
+
DELEGATION_FROM_SUB_AGENT_ID,
|
|
137
|
+
DELEGATION_TO_SUB_AGENT_ID,
|
|
138
|
+
DELEGATION_ID,
|
|
139
|
+
TRANSFER_FROM_SUB_AGENT_ID,
|
|
140
|
+
TRANSFER_TO_SUB_AGENT_ID,
|
|
141
|
+
// HTTP attributes
|
|
142
|
+
HTTP_URL: "http.url",
|
|
143
|
+
HTTP_STATUS_CODE: "http.status_code",
|
|
144
|
+
HTTP_RESPONSE_BODY_SIZE: "http.response.body_size",
|
|
145
|
+
// Core attributes
|
|
146
|
+
NAME: "name",
|
|
147
|
+
PARENT_SPAN_ID: "parentSpanID",
|
|
148
|
+
CONVERSATION_ID: "conversation.id"
|
|
149
|
+
};
|
|
150
|
+
var UNKNOWN_VALUE = "unknown";
|
|
151
|
+
var ACTIVITY_TYPES = {
|
|
152
|
+
TOOL_CALL: "tool_call",
|
|
153
|
+
AI_GENERATION: "ai_generation",
|
|
154
|
+
AGENT_GENERATION: "agent_generation",
|
|
155
|
+
CONTEXT_FETCH: "context_fetch",
|
|
156
|
+
CONTEXT_RESOLUTION: "context_resolution",
|
|
157
|
+
USER_MESSAGE: "user_message",
|
|
158
|
+
AI_ASSISTANT_MESSAGE: "ai_assistant_message",
|
|
159
|
+
AI_MODEL_STREAMED_TEXT: "ai_model_streamed_text"
|
|
160
|
+
};
|
|
161
|
+
var ACTIVITY_STATUS = {
|
|
162
|
+
SUCCESS: "success",
|
|
163
|
+
ERROR: "error",
|
|
164
|
+
PENDING: "pending"
|
|
165
|
+
};
|
|
166
|
+
var AGENT_IDS = {
|
|
167
|
+
USER: "user",
|
|
168
|
+
AI_ASSISTANT: "ai-assistant"
|
|
169
|
+
};
|
|
170
|
+
var ACTIVITY_NAMES = {
|
|
171
|
+
CONTEXT_FETCH: "Context Fetch",
|
|
172
|
+
USER_MESSAGE: "User Message",
|
|
173
|
+
AI_ASSISTANT_MESSAGE: "AI Assistant Message",
|
|
174
|
+
AI_TEXT_GENERATION: "AI Text Generation",
|
|
175
|
+
AI_STREAMING_TEXT: "AI Streaming Text",
|
|
176
|
+
UNKNOWN_AGENT: "Unknown Agent",
|
|
177
|
+
USER: "User"
|
|
178
|
+
};
|
|
179
|
+
var TOOL_NAMES = {
|
|
180
|
+
SAVE_TOOL_RESULT: "save_tool_result"
|
|
181
|
+
};
|
|
182
|
+
var AI_TOOL_TYPES = {
|
|
183
|
+
MCP: "mcp",
|
|
184
|
+
TRANSFER: "transfer",
|
|
185
|
+
DELEGATION: "delegation"
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// src/constants/signoz-queries.ts
|
|
189
|
+
var DATA_TYPES = {
|
|
190
|
+
STRING: "string",
|
|
191
|
+
INT64: "int64",
|
|
192
|
+
FLOAT64: "float64",
|
|
193
|
+
BOOL: "bool"
|
|
194
|
+
};
|
|
195
|
+
var FIELD_TYPES = {
|
|
196
|
+
TAG: "tag",
|
|
197
|
+
RESOURCE: "resource"
|
|
198
|
+
};
|
|
199
|
+
var QUERY_FIELD_CONFIGS = {
|
|
200
|
+
// String tag fields
|
|
201
|
+
STRING_TAG: {
|
|
202
|
+
dataType: DATA_TYPES.STRING,
|
|
203
|
+
type: FIELD_TYPES.TAG,
|
|
204
|
+
isColumn: false
|
|
205
|
+
},
|
|
206
|
+
STRING_TAG_COLUMN: {
|
|
207
|
+
dataType: DATA_TYPES.STRING,
|
|
208
|
+
type: FIELD_TYPES.TAG,
|
|
209
|
+
isColumn: true
|
|
210
|
+
},
|
|
211
|
+
// Numeric tag fields
|
|
212
|
+
INT64_TAG: {
|
|
213
|
+
dataType: DATA_TYPES.INT64,
|
|
214
|
+
type: FIELD_TYPES.TAG,
|
|
215
|
+
isColumn: false
|
|
216
|
+
},
|
|
217
|
+
INT64_TAG_COLUMN: {
|
|
218
|
+
dataType: DATA_TYPES.INT64,
|
|
219
|
+
type: FIELD_TYPES.TAG,
|
|
220
|
+
isColumn: true
|
|
221
|
+
},
|
|
222
|
+
FLOAT64_TAG: {
|
|
223
|
+
dataType: DATA_TYPES.FLOAT64,
|
|
224
|
+
type: FIELD_TYPES.TAG,
|
|
225
|
+
isColumn: false
|
|
226
|
+
},
|
|
227
|
+
FLOAT64_TAG_COLUMN: {
|
|
228
|
+
dataType: DATA_TYPES.FLOAT64,
|
|
229
|
+
type: FIELD_TYPES.TAG,
|
|
230
|
+
isColumn: true
|
|
231
|
+
},
|
|
232
|
+
// Boolean tag fields
|
|
233
|
+
BOOL_TAG: {
|
|
234
|
+
dataType: DATA_TYPES.BOOL,
|
|
235
|
+
type: FIELD_TYPES.TAG,
|
|
236
|
+
isColumn: false
|
|
237
|
+
},
|
|
238
|
+
BOOL_TAG_COLUMN: {
|
|
239
|
+
dataType: DATA_TYPES.BOOL,
|
|
240
|
+
type: FIELD_TYPES.TAG,
|
|
241
|
+
isColumn: true
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
var OPERATORS = {
|
|
245
|
+
// Comparison operators
|
|
246
|
+
EQUALS: "=",
|
|
247
|
+
NOT_EQUALS: "!=",
|
|
248
|
+
LESS_THAN: "<",
|
|
249
|
+
GREATER_THAN: ">",
|
|
250
|
+
LESS_THAN_OR_EQUAL: "<=",
|
|
251
|
+
GREATER_THAN_OR_EQUAL: ">=",
|
|
252
|
+
// String operators
|
|
253
|
+
LIKE: "like",
|
|
254
|
+
NOT_LIKE: "nlike",
|
|
255
|
+
// Existence operators
|
|
256
|
+
EXISTS: "exists",
|
|
257
|
+
NOT_EXISTS: "nexists",
|
|
258
|
+
// Logical operators
|
|
259
|
+
AND: "AND",
|
|
260
|
+
OR: "OR"
|
|
261
|
+
};
|
|
262
|
+
var QUERY_EXPRESSIONS = {
|
|
263
|
+
SPAN_NAMES: "spanNames",
|
|
264
|
+
AGENT_MODEL_CALLS: "agentModelCalls",
|
|
265
|
+
MODEL_CALLS: "modelCalls",
|
|
266
|
+
LAST_ACTIVITY: "lastActivity",
|
|
267
|
+
CONVERSATION_METADATA: "conversationMetadata",
|
|
268
|
+
FILTERED_CONVERSATIONS: "filteredConversations",
|
|
269
|
+
TOOLS: "tools",
|
|
270
|
+
TRANSFERS: "transfers",
|
|
271
|
+
DELEGATIONS: "delegations",
|
|
272
|
+
AI_CALLS: "aiCalls",
|
|
273
|
+
CONTEXT_ERRORS: "contextErrors",
|
|
274
|
+
AGENT_GENERATION_ERRORS: "agentGenerationErrors",
|
|
275
|
+
USER_MESSAGES: "userMessages",
|
|
276
|
+
UNIQUE_GRAPHS: "uniqueGraphs",
|
|
277
|
+
UNIQUE_MODELS: "uniqueModels",
|
|
278
|
+
// Route-specific query names
|
|
279
|
+
TOOL_CALLS: "toolCalls",
|
|
280
|
+
CONTEXT_RESOLUTION: "contextResolution",
|
|
281
|
+
CONTEXT_HANDLE: "contextHandle",
|
|
282
|
+
AI_ASSISTANT_MESSAGES: "aiAssistantMessages",
|
|
283
|
+
AI_GENERATIONS: "aiGenerations",
|
|
284
|
+
AI_STREAMING_TEXT: "aiStreamingText",
|
|
285
|
+
CONTEXT_FETCHERS: "contextFetchers",
|
|
286
|
+
DURATION_SPANS: "durationSpans",
|
|
287
|
+
AGENT_GENERATIONS: "agentGenerations",
|
|
288
|
+
SPANS_WITH_ERRORS: "spansWithErrors"
|
|
289
|
+
};
|
|
290
|
+
var REDUCE_OPERATIONS = {
|
|
291
|
+
SUM: "sum",
|
|
292
|
+
MAX: "max",
|
|
293
|
+
MIN: "min",
|
|
294
|
+
AVG: "avg",
|
|
295
|
+
COUNT: "count"
|
|
296
|
+
};
|
|
297
|
+
var ORDER_DIRECTIONS = {
|
|
298
|
+
ASC: "asc",
|
|
299
|
+
DESC: "desc"
|
|
300
|
+
};
|
|
301
|
+
var QUERY_TYPES = {
|
|
302
|
+
BUILDER: "builder",
|
|
303
|
+
CLICKHOUSE: "clickhouse",
|
|
304
|
+
PROMQL: "promql"
|
|
305
|
+
};
|
|
306
|
+
var PANEL_TYPES = {
|
|
307
|
+
LIST: "list",
|
|
308
|
+
TABLE: "table",
|
|
309
|
+
GRAPH: "graph",
|
|
310
|
+
VALUE: "value"
|
|
311
|
+
};
|
|
312
|
+
var DATA_SOURCES = {
|
|
313
|
+
TRACES: "traces",
|
|
314
|
+
METRICS: "metrics",
|
|
315
|
+
LOGS: "logs"
|
|
316
|
+
};
|
|
317
|
+
var AGGREGATE_OPERATORS = {
|
|
318
|
+
COUNT: "count",
|
|
319
|
+
SUM: "sum",
|
|
320
|
+
AVG: "avg",
|
|
321
|
+
MIN: "min",
|
|
322
|
+
MAX: "max",
|
|
323
|
+
NOOP: "noop"
|
|
324
|
+
};
|
|
325
|
+
var QUERY_DEFAULTS = {
|
|
326
|
+
STEP: 60,
|
|
327
|
+
STEP_INTERVAL: 60,
|
|
328
|
+
OFFSET: 0,
|
|
329
|
+
DISABLED: false,
|
|
330
|
+
HAVING: [],
|
|
331
|
+
LEGEND: "",
|
|
332
|
+
LIMIT_NULL: null,
|
|
333
|
+
LIMIT_ZERO: 0,
|
|
334
|
+
LIMIT_1000: 1e3,
|
|
335
|
+
EMPTY_GROUP_BY: []
|
|
336
|
+
};
|
|
67
337
|
var generateId = nanoid.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789", 21);
|
|
68
338
|
function getConversationId() {
|
|
69
339
|
return generateId();
|
|
@@ -286,18 +556,9 @@ function extractPreviewFields(schema) {
|
|
|
286
556
|
// src/db/schema.ts
|
|
287
557
|
var schema_exports = {};
|
|
288
558
|
__export(schema_exports, {
|
|
289
|
-
agentArtifactComponents: () => agentArtifactComponents,
|
|
290
|
-
agentArtifactComponentsRelations: () => agentArtifactComponentsRelations,
|
|
291
|
-
agentDataComponents: () => agentDataComponents,
|
|
292
|
-
agentDataComponentsRelations: () => agentDataComponentsRelations,
|
|
293
559
|
agentGraph: () => agentGraph,
|
|
294
560
|
agentGraphRelations: () => agentGraphRelations,
|
|
295
|
-
agentRelations: () => agentRelations,
|
|
296
|
-
agentRelationsRelations: () => agentRelationsRelations,
|
|
297
|
-
agentToolRelations: () => agentToolRelations,
|
|
298
561
|
agentToolRelationsRelations: () => agentToolRelationsRelations,
|
|
299
|
-
agents: () => agents,
|
|
300
|
-
agentsRelations: () => agentsRelations,
|
|
301
562
|
apiKeys: () => apiKeys,
|
|
302
563
|
apiKeysRelations: () => apiKeysRelations,
|
|
303
564
|
artifactComponents: () => artifactComponents,
|
|
@@ -322,6 +583,15 @@ __export(schema_exports, {
|
|
|
322
583
|
messagesRelations: () => messagesRelations,
|
|
323
584
|
projects: () => projects,
|
|
324
585
|
projectsRelations: () => projectsRelations,
|
|
586
|
+
subAgentArtifactComponents: () => subAgentArtifactComponents,
|
|
587
|
+
subAgentArtifactComponentsRelations: () => subAgentArtifactComponentsRelations,
|
|
588
|
+
subAgentDataComponents: () => subAgentDataComponents,
|
|
589
|
+
subAgentDataComponentsRelations: () => subAgentDataComponentsRelations,
|
|
590
|
+
subAgentRelations: () => subAgentRelations,
|
|
591
|
+
subAgentRelationsRelations: () => subAgentRelationsRelations,
|
|
592
|
+
subAgentToolRelations: () => subAgentToolRelations,
|
|
593
|
+
subAgents: () => subAgents,
|
|
594
|
+
subAgentsRelations: () => subAgentsRelations,
|
|
325
595
|
taskRelations: () => taskRelations,
|
|
326
596
|
taskRelationsRelations: () => taskRelationsRelations,
|
|
327
597
|
tasks: () => tasks,
|
|
@@ -341,9 +611,9 @@ var graphScoped = {
|
|
|
341
611
|
...projectScoped,
|
|
342
612
|
graphId: sqliteCore.text("graph_id").notNull()
|
|
343
613
|
};
|
|
344
|
-
var
|
|
614
|
+
var subAgentScoped = {
|
|
345
615
|
...graphScoped,
|
|
346
|
-
|
|
616
|
+
subAgentId: sqliteCore.text("sub_agent_id").notNull()
|
|
347
617
|
};
|
|
348
618
|
var uiProperties = {
|
|
349
619
|
name: sqliteCore.text("name").notNull(),
|
|
@@ -374,7 +644,7 @@ var agentGraph = sqliteCore.sqliteTable(
|
|
|
374
644
|
...projectScoped,
|
|
375
645
|
name: sqliteCore.text("name").notNull(),
|
|
376
646
|
description: sqliteCore.text("description"),
|
|
377
|
-
|
|
647
|
+
defaultSubAgentId: sqliteCore.text("default_sub_agent_id"),
|
|
378
648
|
// Reference to shared context configuration for all agents in this graph
|
|
379
649
|
contextConfigId: sqliteCore.text("context_config_id"),
|
|
380
650
|
// add fk relationship
|
|
@@ -453,8 +723,8 @@ var contextCache = sqliteCore.sqliteTable(
|
|
|
453
723
|
)
|
|
454
724
|
]
|
|
455
725
|
);
|
|
456
|
-
var
|
|
457
|
-
"
|
|
726
|
+
var subAgents = sqliteCore.sqliteTable(
|
|
727
|
+
"sub_agents",
|
|
458
728
|
{
|
|
459
729
|
...graphScoped,
|
|
460
730
|
...uiProperties,
|
|
@@ -476,17 +746,16 @@ var agents = sqliteCore.sqliteTable(
|
|
|
476
746
|
}).onDelete("cascade")
|
|
477
747
|
]
|
|
478
748
|
);
|
|
479
|
-
var
|
|
480
|
-
"
|
|
749
|
+
var subAgentRelations = sqliteCore.sqliteTable(
|
|
750
|
+
"sub_agent_relations",
|
|
481
751
|
{
|
|
482
752
|
...graphScoped,
|
|
483
|
-
|
|
753
|
+
sourceSubAgentId: sqliteCore.text("source_sub_agent_id").notNull(),
|
|
484
754
|
// For internal relationships
|
|
485
|
-
|
|
755
|
+
targetSubAgentId: sqliteCore.text("target_sub_agent_id"),
|
|
486
756
|
// For external relationships
|
|
487
|
-
|
|
757
|
+
externalSubAgentId: sqliteCore.text("external_sub_agent_id"),
|
|
488
758
|
relationType: sqliteCore.text("relation_type"),
|
|
489
|
-
// 'transfer' | 'delegate'
|
|
490
759
|
...timestamps
|
|
491
760
|
},
|
|
492
761
|
(table) => [
|
|
@@ -494,7 +763,7 @@ var agentRelations = sqliteCore.sqliteTable(
|
|
|
494
763
|
sqliteCore.foreignKey({
|
|
495
764
|
columns: [table.tenantId, table.projectId, table.graphId],
|
|
496
765
|
foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
|
|
497
|
-
name: "
|
|
766
|
+
name: "sub_agent_relations_graph_fk"
|
|
498
767
|
}).onDelete("cascade")
|
|
499
768
|
]
|
|
500
769
|
);
|
|
@@ -530,7 +799,7 @@ var externalAgents = sqliteCore.sqliteTable(
|
|
|
530
799
|
var tasks = sqliteCore.sqliteTable(
|
|
531
800
|
"tasks",
|
|
532
801
|
{
|
|
533
|
-
...
|
|
802
|
+
...subAgentScoped,
|
|
534
803
|
contextId: sqliteCore.text("context_id").notNull(),
|
|
535
804
|
status: sqliteCore.text("status").notNull(),
|
|
536
805
|
metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
|
|
@@ -539,9 +808,9 @@ var tasks = sqliteCore.sqliteTable(
|
|
|
539
808
|
(table) => [
|
|
540
809
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
541
810
|
sqliteCore.foreignKey({
|
|
542
|
-
columns: [table.tenantId, table.projectId, table.graphId, table.
|
|
543
|
-
foreignColumns: [
|
|
544
|
-
name: "
|
|
811
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
|
|
812
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
|
|
813
|
+
name: "tasks_sub_agent_fk"
|
|
545
814
|
}).onDelete("cascade")
|
|
546
815
|
]
|
|
547
816
|
);
|
|
@@ -581,10 +850,10 @@ var dataComponents = sqliteCore.sqliteTable(
|
|
|
581
850
|
}).onDelete("cascade")
|
|
582
851
|
]
|
|
583
852
|
);
|
|
584
|
-
var
|
|
585
|
-
"
|
|
853
|
+
var subAgentDataComponents = sqliteCore.sqliteTable(
|
|
854
|
+
"sub_agent_data_components",
|
|
586
855
|
{
|
|
587
|
-
...
|
|
856
|
+
...subAgentScoped,
|
|
588
857
|
dataComponentId: sqliteCore.text("data_component_id").notNull(),
|
|
589
858
|
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
590
859
|
},
|
|
@@ -592,15 +861,15 @@ var agentDataComponents = sqliteCore.sqliteTable(
|
|
|
592
861
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
593
862
|
// Foreign key constraint to agents table (ensures graph and project exist via cascade)
|
|
594
863
|
sqliteCore.foreignKey({
|
|
595
|
-
columns: [table.tenantId, table.projectId, table.graphId, table.
|
|
596
|
-
foreignColumns: [
|
|
597
|
-
name: "
|
|
864
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
|
|
865
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
|
|
866
|
+
name: "sub_agent_data_components_sub_agent_fk"
|
|
598
867
|
}).onDelete("cascade"),
|
|
599
868
|
// Foreign key constraint to data_components table
|
|
600
869
|
sqliteCore.foreignKey({
|
|
601
870
|
columns: [table.tenantId, table.projectId, table.dataComponentId],
|
|
602
871
|
foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
|
|
603
|
-
name: "
|
|
872
|
+
name: "sub_agent_data_components_data_component_fk"
|
|
604
873
|
}).onDelete("cascade")
|
|
605
874
|
]
|
|
606
875
|
);
|
|
@@ -621,22 +890,22 @@ var artifactComponents = sqliteCore.sqliteTable(
|
|
|
621
890
|
}).onDelete("cascade")
|
|
622
891
|
]
|
|
623
892
|
);
|
|
624
|
-
var
|
|
625
|
-
"
|
|
893
|
+
var subAgentArtifactComponents = sqliteCore.sqliteTable(
|
|
894
|
+
"sub_agent_artifact_components",
|
|
626
895
|
{
|
|
627
|
-
...
|
|
896
|
+
...subAgentScoped,
|
|
628
897
|
artifactComponentId: sqliteCore.text("artifact_component_id").notNull(),
|
|
629
898
|
createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
|
|
630
899
|
},
|
|
631
900
|
(table) => [
|
|
632
901
|
sqliteCore.primaryKey({
|
|
633
|
-
columns: [table.tenantId, table.projectId, table.graphId, table.
|
|
902
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId, table.id]
|
|
634
903
|
}),
|
|
635
904
|
// Foreign key constraint to agents table (ensures graph and project exist via cascade)
|
|
636
905
|
sqliteCore.foreignKey({
|
|
637
|
-
columns: [table.tenantId, table.projectId, table.graphId, table.
|
|
638
|
-
foreignColumns: [
|
|
639
|
-
name: "
|
|
906
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
|
|
907
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
|
|
908
|
+
name: "sub_agent_artifact_components_sub_agent_fk"
|
|
640
909
|
}).onDelete("cascade"),
|
|
641
910
|
// Foreign key constraint to artifact_components table
|
|
642
911
|
sqliteCore.foreignKey({
|
|
@@ -646,7 +915,7 @@ var agentArtifactComponents = sqliteCore.sqliteTable(
|
|
|
646
915
|
artifactComponents.projectId,
|
|
647
916
|
artifactComponents.id
|
|
648
917
|
],
|
|
649
|
-
name: "
|
|
918
|
+
name: "sub_agent_artifact_components_artifact_component_fk"
|
|
650
919
|
}).onDelete("cascade")
|
|
651
920
|
]
|
|
652
921
|
);
|
|
@@ -702,10 +971,10 @@ var functions = sqliteCore.sqliteTable(
|
|
|
702
971
|
}).onDelete("cascade")
|
|
703
972
|
]
|
|
704
973
|
);
|
|
705
|
-
var
|
|
706
|
-
"
|
|
974
|
+
var subAgentToolRelations = sqliteCore.sqliteTable(
|
|
975
|
+
"sub_agent_tool_relations",
|
|
707
976
|
{
|
|
708
|
-
...
|
|
977
|
+
...subAgentScoped,
|
|
709
978
|
toolId: sqliteCore.text("tool_id").notNull(),
|
|
710
979
|
selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
|
|
711
980
|
headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
|
|
@@ -715,15 +984,15 @@ var agentToolRelations = sqliteCore.sqliteTable(
|
|
|
715
984
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
|
|
716
985
|
// Foreign key constraint to agents table (which includes project and graph scope)
|
|
717
986
|
sqliteCore.foreignKey({
|
|
718
|
-
columns: [table.tenantId, table.projectId, table.graphId, table.
|
|
719
|
-
foreignColumns: [
|
|
720
|
-
name: "
|
|
987
|
+
columns: [table.tenantId, table.projectId, table.graphId, table.subAgentId],
|
|
988
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.graphId, subAgents.id],
|
|
989
|
+
name: "sub_agent_tool_relations_agent_fk"
|
|
721
990
|
}).onDelete("cascade"),
|
|
722
991
|
// Foreign key constraint to tools table
|
|
723
992
|
sqliteCore.foreignKey({
|
|
724
993
|
columns: [table.tenantId, table.projectId, table.toolId],
|
|
725
994
|
foreignColumns: [tools.tenantId, tools.projectId, tools.id],
|
|
726
|
-
name: "
|
|
995
|
+
name: "sub_agent_tool_relations_tool_fk"
|
|
727
996
|
}).onDelete("cascade")
|
|
728
997
|
]
|
|
729
998
|
);
|
|
@@ -732,7 +1001,7 @@ var conversations = sqliteCore.sqliteTable(
|
|
|
732
1001
|
{
|
|
733
1002
|
...projectScoped,
|
|
734
1003
|
userId: sqliteCore.text("user_id"),
|
|
735
|
-
|
|
1004
|
+
activeSubAgentId: sqliteCore.text("active_sub_agent_id").notNull(),
|
|
736
1005
|
title: sqliteCore.text("title"),
|
|
737
1006
|
lastContextResolution: sqliteCore.text("last_context_resolution"),
|
|
738
1007
|
metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
|
|
@@ -756,15 +1025,15 @@ var messages = sqliteCore.sqliteTable(
|
|
|
756
1025
|
role: sqliteCore.text("role").notNull(),
|
|
757
1026
|
// 'user' | 'agent' | 'system'
|
|
758
1027
|
// Agent sender/recipient tracking (nullable - only populated when relevant)
|
|
759
|
-
|
|
1028
|
+
fromSubAgentId: sqliteCore.text("from_sub_agent_id"),
|
|
760
1029
|
// Populated when message is from an agent
|
|
761
|
-
|
|
1030
|
+
toSubAgentId: sqliteCore.text("to_sub_agent_id"),
|
|
762
1031
|
// Populated when message is directed to a specific agent (e.g., transfers/delegations)
|
|
763
1032
|
// External agent sender tracking
|
|
764
|
-
fromExternalAgentId: sqliteCore.text("
|
|
1033
|
+
fromExternalAgentId: sqliteCore.text("from_external_sub_agent_id"),
|
|
765
1034
|
// Populated when message is directed from an external agent
|
|
766
1035
|
// External agent recipient tracking
|
|
767
|
-
toExternalAgentId: sqliteCore.text("
|
|
1036
|
+
toExternalAgentId: sqliteCore.text("to_external_sub_agent_id"),
|
|
768
1037
|
// Populated when message is directed to an external agent
|
|
769
1038
|
// Message content stored as JSON to support both formats
|
|
770
1039
|
content: sqliteCore.blob("content", { mode: "json" }).$type().notNull(),
|
|
@@ -773,8 +1042,6 @@ var messages = sqliteCore.sqliteTable(
|
|
|
773
1042
|
// 'user-facing' | 'internal' | 'system' | 'external'
|
|
774
1043
|
messageType: sqliteCore.text("message_type").notNull().default("chat"),
|
|
775
1044
|
// 'chat' | 'a2a-request' | 'a2a-response' | 'task-update' | 'tool-call'
|
|
776
|
-
// Legacy agent association (consider deprecating in favor of fromAgentId/toAgentId)
|
|
777
|
-
agentId: sqliteCore.text("agent_id"),
|
|
778
1045
|
taskId: sqliteCore.text("task_id"),
|
|
779
1046
|
parentMessageId: sqliteCore.text("parent_message_id"),
|
|
780
1047
|
// Remove self-reference constraint here
|
|
@@ -901,10 +1168,9 @@ var tasksRelations = drizzleOrm.relations(tasks, ({ one, many }) => ({
|
|
|
901
1168
|
childRelations: many(taskRelations, {
|
|
902
1169
|
relationName: "parentTask"
|
|
903
1170
|
}),
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
references: [agents.id]
|
|
1171
|
+
subAgent: one(subAgents, {
|
|
1172
|
+
fields: [tasks.subAgentId],
|
|
1173
|
+
references: [subAgents.id]
|
|
908
1174
|
}),
|
|
909
1175
|
// A task can have many messages associated with it
|
|
910
1176
|
messages: many(messages),
|
|
@@ -912,7 +1178,7 @@ var tasksRelations = drizzleOrm.relations(tasks, ({ one, many }) => ({
|
|
|
912
1178
|
ledgerArtifacts: many(ledgerArtifacts)
|
|
913
1179
|
}));
|
|
914
1180
|
var projectsRelations = drizzleOrm.relations(projects, ({ many }) => ({
|
|
915
|
-
|
|
1181
|
+
subAgents: many(subAgents),
|
|
916
1182
|
agentGraphs: many(agentGraph),
|
|
917
1183
|
tools: many(tools),
|
|
918
1184
|
contextConfigs: many(contextConfigs),
|
|
@@ -950,17 +1216,17 @@ var contextCacheRelations = drizzleOrm.relations(contextCache, ({ one }) => ({
|
|
|
950
1216
|
references: [contextConfigs.id]
|
|
951
1217
|
})
|
|
952
1218
|
}));
|
|
953
|
-
var
|
|
1219
|
+
var subAgentsRelations = drizzleOrm.relations(subAgents, ({ many, one }) => ({
|
|
954
1220
|
project: one(projects, {
|
|
955
|
-
fields: [
|
|
1221
|
+
fields: [subAgents.tenantId, subAgents.projectId],
|
|
956
1222
|
references: [projects.tenantId, projects.id]
|
|
957
1223
|
}),
|
|
958
1224
|
tasks: many(tasks),
|
|
959
1225
|
defaultForGraphs: many(agentGraph),
|
|
960
|
-
sourceRelations: many(
|
|
1226
|
+
sourceRelations: many(subAgentRelations, {
|
|
961
1227
|
relationName: "sourceRelations"
|
|
962
1228
|
}),
|
|
963
|
-
targetRelations: many(
|
|
1229
|
+
targetRelations: many(subAgentRelations, {
|
|
964
1230
|
relationName: "targetRelations"
|
|
965
1231
|
}),
|
|
966
1232
|
sentMessages: many(messages, {
|
|
@@ -972,18 +1238,18 @@ var agentsRelations = drizzleOrm.relations(agents, ({ many, one }) => ({
|
|
|
972
1238
|
associatedMessages: many(messages, {
|
|
973
1239
|
relationName: "associatedAgent"
|
|
974
1240
|
}),
|
|
975
|
-
toolRelations: many(
|
|
976
|
-
dataComponentRelations: many(
|
|
977
|
-
artifactComponentRelations: many(
|
|
1241
|
+
toolRelations: many(subAgentToolRelations),
|
|
1242
|
+
dataComponentRelations: many(subAgentDataComponents),
|
|
1243
|
+
artifactComponentRelations: many(subAgentArtifactComponents)
|
|
978
1244
|
}));
|
|
979
1245
|
var agentGraphRelations = drizzleOrm.relations(agentGraph, ({ one }) => ({
|
|
980
1246
|
project: one(projects, {
|
|
981
1247
|
fields: [agentGraph.tenantId, agentGraph.projectId],
|
|
982
1248
|
references: [projects.tenantId, projects.id]
|
|
983
1249
|
}),
|
|
984
|
-
|
|
985
|
-
fields: [agentGraph.
|
|
986
|
-
references: [
|
|
1250
|
+
defaultSubAgent: one(subAgents, {
|
|
1251
|
+
fields: [agentGraph.defaultSubAgentId],
|
|
1252
|
+
references: [subAgents.id]
|
|
987
1253
|
}),
|
|
988
1254
|
contextConfig: one(contextConfigs, {
|
|
989
1255
|
fields: [agentGraph.contextConfigId],
|
|
@@ -995,7 +1261,7 @@ var externalAgentsRelations = drizzleOrm.relations(externalAgents, ({ one, many
|
|
|
995
1261
|
fields: [externalAgents.tenantId, externalAgents.projectId],
|
|
996
1262
|
references: [projects.tenantId, projects.id]
|
|
997
1263
|
}),
|
|
998
|
-
|
|
1264
|
+
subAgentRelations: many(subAgentRelations),
|
|
999
1265
|
credentialReference: one(credentialReferences, {
|
|
1000
1266
|
fields: [externalAgents.credentialReferenceId],
|
|
1001
1267
|
references: [credentialReferences.id]
|
|
@@ -1011,13 +1277,13 @@ var apiKeysRelations = drizzleOrm.relations(apiKeys, ({ one }) => ({
|
|
|
1011
1277
|
references: [agentGraph.id]
|
|
1012
1278
|
})
|
|
1013
1279
|
}));
|
|
1014
|
-
var agentToolRelationsRelations = drizzleOrm.relations(
|
|
1015
|
-
|
|
1016
|
-
fields: [
|
|
1017
|
-
references: [
|
|
1280
|
+
var agentToolRelationsRelations = drizzleOrm.relations(subAgentToolRelations, ({ one }) => ({
|
|
1281
|
+
subAgent: one(subAgents, {
|
|
1282
|
+
fields: [subAgentToolRelations.subAgentId],
|
|
1283
|
+
references: [subAgents.id]
|
|
1018
1284
|
}),
|
|
1019
1285
|
tool: one(tools, {
|
|
1020
|
-
fields: [
|
|
1286
|
+
fields: [subAgentToolRelations.toolId],
|
|
1021
1287
|
references: [tools.id]
|
|
1022
1288
|
})
|
|
1023
1289
|
}));
|
|
@@ -1029,7 +1295,7 @@ var toolsRelations = drizzleOrm.relations(tools, ({ one, many }) => ({
|
|
|
1029
1295
|
fields: [tools.tenantId, tools.projectId],
|
|
1030
1296
|
references: [projects.tenantId, projects.id]
|
|
1031
1297
|
}),
|
|
1032
|
-
|
|
1298
|
+
subAgentRelations: many(subAgentToolRelations),
|
|
1033
1299
|
credentialReference: one(credentialReferences, {
|
|
1034
1300
|
fields: [tools.credentialReferenceId],
|
|
1035
1301
|
references: [credentialReferences.id]
|
|
@@ -1045,9 +1311,9 @@ var conversationsRelations = drizzleOrm.relations(conversations, ({ one, many })
|
|
|
1045
1311
|
references: [projects.tenantId, projects.id]
|
|
1046
1312
|
}),
|
|
1047
1313
|
messages: many(messages),
|
|
1048
|
-
|
|
1049
|
-
fields: [conversations.
|
|
1050
|
-
references: [
|
|
1314
|
+
activeSubAgent: one(subAgents, {
|
|
1315
|
+
fields: [conversations.activeSubAgentId],
|
|
1316
|
+
references: [subAgents.id]
|
|
1051
1317
|
})
|
|
1052
1318
|
}));
|
|
1053
1319
|
var messagesRelations = drizzleOrm.relations(messages, ({ one, many }) => ({
|
|
@@ -1055,20 +1321,14 @@ var messagesRelations = drizzleOrm.relations(messages, ({ one, many }) => ({
|
|
|
1055
1321
|
fields: [messages.conversationId],
|
|
1056
1322
|
references: [conversations.id]
|
|
1057
1323
|
}),
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
references: [agents.id],
|
|
1062
|
-
relationName: "associatedAgent"
|
|
1063
|
-
}),
|
|
1064
|
-
fromAgent: one(agents, {
|
|
1065
|
-
fields: [messages.fromAgentId],
|
|
1066
|
-
references: [agents.id],
|
|
1324
|
+
fromSubAgent: one(subAgents, {
|
|
1325
|
+
fields: [messages.fromSubAgentId],
|
|
1326
|
+
references: [subAgents.id],
|
|
1067
1327
|
relationName: "sentMessages"
|
|
1068
1328
|
}),
|
|
1069
|
-
|
|
1070
|
-
fields: [messages.
|
|
1071
|
-
references: [
|
|
1329
|
+
toSubAgent: one(subAgents, {
|
|
1330
|
+
fields: [messages.toSubAgentId],
|
|
1331
|
+
references: [subAgents.id],
|
|
1072
1332
|
relationName: "receivedMessages"
|
|
1073
1333
|
}),
|
|
1074
1334
|
fromExternalAgent: one(externalAgents, {
|
|
@@ -1094,33 +1354,40 @@ var messagesRelations = drizzleOrm.relations(messages, ({ one, many }) => ({
|
|
|
1094
1354
|
relationName: "parentChild"
|
|
1095
1355
|
})
|
|
1096
1356
|
}));
|
|
1097
|
-
var artifactComponentsRelations = drizzleOrm.relations(artifactComponents, ({ many }) => ({
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
agent: one(agents, {
|
|
1102
|
-
fields: [agentArtifactComponents.agentId],
|
|
1103
|
-
references: [agents.id]
|
|
1357
|
+
var artifactComponentsRelations = drizzleOrm.relations(artifactComponents, ({ many, one }) => ({
|
|
1358
|
+
project: one(projects, {
|
|
1359
|
+
fields: [artifactComponents.tenantId, artifactComponents.projectId],
|
|
1360
|
+
references: [projects.tenantId, projects.id]
|
|
1104
1361
|
}),
|
|
1105
|
-
|
|
1106
|
-
fields: [agentArtifactComponents.artifactComponentId],
|
|
1107
|
-
references: [artifactComponents.id]
|
|
1108
|
-
})
|
|
1362
|
+
subAgentRelations: many(subAgentArtifactComponents)
|
|
1109
1363
|
}));
|
|
1364
|
+
var subAgentArtifactComponentsRelations = drizzleOrm.relations(
|
|
1365
|
+
subAgentArtifactComponents,
|
|
1366
|
+
({ one }) => ({
|
|
1367
|
+
subAgent: one(subAgents, {
|
|
1368
|
+
fields: [subAgentArtifactComponents.subAgentId],
|
|
1369
|
+
references: [subAgents.id]
|
|
1370
|
+
}),
|
|
1371
|
+
artifactComponent: one(artifactComponents, {
|
|
1372
|
+
fields: [subAgentArtifactComponents.artifactComponentId],
|
|
1373
|
+
references: [artifactComponents.id]
|
|
1374
|
+
})
|
|
1375
|
+
})
|
|
1376
|
+
);
|
|
1110
1377
|
var dataComponentsRelations = drizzleOrm.relations(dataComponents, ({ many, one }) => ({
|
|
1111
1378
|
project: one(projects, {
|
|
1112
1379
|
fields: [dataComponents.tenantId, dataComponents.projectId],
|
|
1113
1380
|
references: [projects.tenantId, projects.id]
|
|
1114
1381
|
}),
|
|
1115
|
-
|
|
1382
|
+
subAgentRelations: many(subAgentDataComponents)
|
|
1116
1383
|
}));
|
|
1117
|
-
var
|
|
1118
|
-
|
|
1119
|
-
fields: [
|
|
1120
|
-
references: [
|
|
1384
|
+
var subAgentDataComponentsRelations = drizzleOrm.relations(subAgentDataComponents, ({ one }) => ({
|
|
1385
|
+
subAgent: one(subAgents, {
|
|
1386
|
+
fields: [subAgentDataComponents.subAgentId],
|
|
1387
|
+
references: [subAgents.id]
|
|
1121
1388
|
}),
|
|
1122
1389
|
dataComponent: one(dataComponents, {
|
|
1123
|
-
fields: [
|
|
1390
|
+
fields: [subAgentDataComponents.dataComponentId],
|
|
1124
1391
|
references: [dataComponents.id]
|
|
1125
1392
|
})
|
|
1126
1393
|
}));
|
|
@@ -1137,23 +1404,23 @@ var ledgerArtifactsRelations = drizzleOrm.relations(ledgerArtifacts, ({ one }) =
|
|
|
1137
1404
|
var functionsRelations = drizzleOrm.relations(functions, ({ many }) => ({
|
|
1138
1405
|
tools: many(tools)
|
|
1139
1406
|
}));
|
|
1140
|
-
var
|
|
1407
|
+
var subAgentRelationsRelations = drizzleOrm.relations(subAgentRelations, ({ one }) => ({
|
|
1141
1408
|
graph: one(agentGraph, {
|
|
1142
|
-
fields: [
|
|
1409
|
+
fields: [subAgentRelations.graphId],
|
|
1143
1410
|
references: [agentGraph.id]
|
|
1144
1411
|
}),
|
|
1145
|
-
|
|
1146
|
-
fields: [
|
|
1147
|
-
references: [
|
|
1412
|
+
sourceSubAgent: one(subAgents, {
|
|
1413
|
+
fields: [subAgentRelations.sourceSubAgentId],
|
|
1414
|
+
references: [subAgents.id],
|
|
1148
1415
|
relationName: "sourceRelations"
|
|
1149
1416
|
}),
|
|
1150
|
-
|
|
1151
|
-
fields: [
|
|
1152
|
-
references: [
|
|
1417
|
+
targetSubAgent: one(subAgents, {
|
|
1418
|
+
fields: [subAgentRelations.targetSubAgentId],
|
|
1419
|
+
references: [subAgents.id],
|
|
1153
1420
|
relationName: "targetRelations"
|
|
1154
1421
|
}),
|
|
1155
1422
|
externalAgent: one(externalAgents, {
|
|
1156
|
-
fields: [
|
|
1423
|
+
fields: [subAgentRelations.externalSubAgentId],
|
|
1157
1424
|
references: [externalAgents.id]
|
|
1158
1425
|
})
|
|
1159
1426
|
}));
|
|
@@ -1224,22 +1491,22 @@ var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId:
|
|
|
1224
1491
|
var createGraphScopedApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
|
|
1225
1492
|
var createGraphScopedApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
|
|
1226
1493
|
var createGraphScopedApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true }).partial();
|
|
1227
|
-
var
|
|
1228
|
-
var
|
|
1494
|
+
var SubAgentSelectSchema = drizzleZod.createSelectSchema(subAgents);
|
|
1495
|
+
var SubAgentInsertSchema = drizzleZod.createInsertSchema(subAgents).extend({
|
|
1229
1496
|
id: resourceIdSchema,
|
|
1230
1497
|
models: ModelSchema.optional()
|
|
1231
1498
|
});
|
|
1232
|
-
var
|
|
1233
|
-
var
|
|
1234
|
-
var
|
|
1235
|
-
var
|
|
1236
|
-
var AgentRelationSelectSchema = drizzleZod.createSelectSchema(
|
|
1237
|
-
var AgentRelationInsertSchema = drizzleZod.createInsertSchema(
|
|
1499
|
+
var SubAgentUpdateSchema = SubAgentInsertSchema.partial();
|
|
1500
|
+
var SubAgentApiSelectSchema = createGraphScopedApiSchema(SubAgentSelectSchema);
|
|
1501
|
+
var SubAgentApiInsertSchema = createGraphScopedApiInsertSchema(SubAgentInsertSchema);
|
|
1502
|
+
var SubAgentApiUpdateSchema = createGraphScopedApiUpdateSchema(SubAgentUpdateSchema);
|
|
1503
|
+
var AgentRelationSelectSchema = drizzleZod.createSelectSchema(subAgentRelations);
|
|
1504
|
+
var AgentRelationInsertSchema = drizzleZod.createInsertSchema(subAgentRelations).extend({
|
|
1238
1505
|
id: resourceIdSchema,
|
|
1239
1506
|
graphId: resourceIdSchema,
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1507
|
+
sourceSubAgentId: resourceIdSchema,
|
|
1508
|
+
targetSubAgentId: resourceIdSchema.optional(),
|
|
1509
|
+
externalSubAgentId: resourceIdSchema.optional()
|
|
1243
1510
|
});
|
|
1244
1511
|
var AgentRelationUpdateSchema = AgentRelationInsertSchema.partial();
|
|
1245
1512
|
var AgentRelationApiSelectSchema = createGraphScopedApiSchema(AgentRelationSelectSchema);
|
|
@@ -1249,13 +1516,13 @@ var AgentRelationApiInsertSchema = createGraphScopedApiInsertSchema(
|
|
|
1249
1516
|
relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES)
|
|
1250
1517
|
}).refine(
|
|
1251
1518
|
(data) => {
|
|
1252
|
-
const hasTarget = data.
|
|
1253
|
-
const hasExternal = data.
|
|
1519
|
+
const hasTarget = data.targetSubAgentId != null;
|
|
1520
|
+
const hasExternal = data.externalSubAgentId != null;
|
|
1254
1521
|
return hasTarget !== hasExternal;
|
|
1255
1522
|
},
|
|
1256
1523
|
{
|
|
1257
|
-
message: "Must specify exactly one of
|
|
1258
|
-
path: ["
|
|
1524
|
+
message: "Must specify exactly one of targetSubAgentId or externalSubAgentId",
|
|
1525
|
+
path: ["targetSubAgentId", "externalSubAgentId"]
|
|
1259
1526
|
}
|
|
1260
1527
|
);
|
|
1261
1528
|
var AgentRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
|
|
@@ -1264,28 +1531,28 @@ var AgentRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
|
|
|
1264
1531
|
relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES).optional()
|
|
1265
1532
|
}).refine(
|
|
1266
1533
|
(data) => {
|
|
1267
|
-
const hasTarget = data.
|
|
1268
|
-
const hasExternal = data.
|
|
1534
|
+
const hasTarget = data.targetSubAgentId != null;
|
|
1535
|
+
const hasExternal = data.externalSubAgentId != null;
|
|
1269
1536
|
if (!hasTarget && !hasExternal) {
|
|
1270
1537
|
return true;
|
|
1271
1538
|
}
|
|
1272
1539
|
return hasTarget !== hasExternal;
|
|
1273
1540
|
},
|
|
1274
1541
|
{
|
|
1275
|
-
message: "Must specify exactly one of
|
|
1276
|
-
path: ["
|
|
1542
|
+
message: "Must specify exactly one of targetSubAgentId or externalSubAgentId when updating agent relationships",
|
|
1543
|
+
path: ["targetSubAgentId", "externalSubAgentId"]
|
|
1277
1544
|
}
|
|
1278
1545
|
);
|
|
1279
1546
|
var AgentRelationQuerySchema = zodOpenapi.z.object({
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1547
|
+
sourceSubAgentId: zodOpenapi.z.string().optional(),
|
|
1548
|
+
targetSubAgentId: zodOpenapi.z.string().optional(),
|
|
1549
|
+
externalSubAgentId: zodOpenapi.z.string().optional()
|
|
1283
1550
|
});
|
|
1284
|
-
var ExternalAgentRelationInsertSchema = drizzleZod.createInsertSchema(
|
|
1551
|
+
var ExternalAgentRelationInsertSchema = drizzleZod.createInsertSchema(subAgentRelations).extend({
|
|
1285
1552
|
id: resourceIdSchema,
|
|
1286
1553
|
graphId: resourceIdSchema,
|
|
1287
|
-
|
|
1288
|
-
|
|
1554
|
+
sourceSubAgentId: resourceIdSchema,
|
|
1555
|
+
externalSubAgentId: resourceIdSchema
|
|
1289
1556
|
});
|
|
1290
1557
|
var ExternalAgentRelationApiInsertSchema = createApiInsertSchema(
|
|
1291
1558
|
ExternalAgentRelationInsertSchema
|
|
@@ -1419,8 +1686,8 @@ var DataComponentUpdateSchema = DataComponentInsertSchema.partial();
|
|
|
1419
1686
|
var DataComponentApiSelectSchema = createApiSchema(DataComponentSelectSchema);
|
|
1420
1687
|
var DataComponentApiInsertSchema = createApiInsertSchema(DataComponentInsertSchema);
|
|
1421
1688
|
var DataComponentApiUpdateSchema = createApiUpdateSchema(DataComponentUpdateSchema);
|
|
1422
|
-
var AgentDataComponentSelectSchema = drizzleZod.createSelectSchema(
|
|
1423
|
-
var AgentDataComponentInsertSchema = drizzleZod.createInsertSchema(
|
|
1689
|
+
var AgentDataComponentSelectSchema = drizzleZod.createSelectSchema(subAgentDataComponents);
|
|
1690
|
+
var AgentDataComponentInsertSchema = drizzleZod.createInsertSchema(subAgentDataComponents);
|
|
1424
1691
|
var AgentDataComponentUpdateSchema = AgentDataComponentInsertSchema.partial();
|
|
1425
1692
|
var AgentDataComponentApiSelectSchema = createGraphScopedApiSchema(
|
|
1426
1693
|
AgentDataComponentSelectSchema
|
|
@@ -1449,12 +1716,12 @@ var ArtifactComponentApiInsertSchema = ArtifactComponentInsertSchema.omit({
|
|
|
1449
1716
|
var ArtifactComponentApiUpdateSchema = createApiUpdateSchema(
|
|
1450
1717
|
ArtifactComponentUpdateSchema
|
|
1451
1718
|
);
|
|
1452
|
-
var AgentArtifactComponentSelectSchema = drizzleZod.createSelectSchema(
|
|
1719
|
+
var AgentArtifactComponentSelectSchema = drizzleZod.createSelectSchema(subAgentArtifactComponents);
|
|
1453
1720
|
var AgentArtifactComponentInsertSchema = drizzleZod.createInsertSchema(
|
|
1454
|
-
|
|
1721
|
+
subAgentArtifactComponents
|
|
1455
1722
|
).extend({
|
|
1456
1723
|
id: resourceIdSchema,
|
|
1457
|
-
|
|
1724
|
+
subAgentId: resourceIdSchema,
|
|
1458
1725
|
artifactComponentId: resourceIdSchema
|
|
1459
1726
|
});
|
|
1460
1727
|
var AgentArtifactComponentUpdateSchema = AgentArtifactComponentInsertSchema.partial();
|
|
@@ -1482,7 +1749,7 @@ var ExternalAgentApiSelectSchema = createGraphScopedApiSchema(ExternalAgentSelec
|
|
|
1482
1749
|
var ExternalAgentApiInsertSchema = createGraphScopedApiInsertSchema(ExternalAgentInsertSchema);
|
|
1483
1750
|
var ExternalAgentApiUpdateSchema = createGraphScopedApiUpdateSchema(ExternalAgentUpdateSchema);
|
|
1484
1751
|
var AllAgentSchema = zodOpenapi.z.discriminatedUnion("type", [
|
|
1485
|
-
|
|
1752
|
+
SubAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("internal") }),
|
|
1486
1753
|
ExternalAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("external") })
|
|
1487
1754
|
]);
|
|
1488
1755
|
var ApiKeySelectSchema = drizzleZod.createSelectSchema(apiKeys);
|
|
@@ -1637,10 +1904,10 @@ var ContextConfigApiInsertSchema = createApiInsertSchema(ContextConfigInsertSche
|
|
|
1637
1904
|
var ContextConfigApiUpdateSchema = createApiUpdateSchema(ContextConfigUpdateSchema).omit({
|
|
1638
1905
|
graphId: true
|
|
1639
1906
|
});
|
|
1640
|
-
var AgentToolRelationSelectSchema = drizzleZod.createSelectSchema(
|
|
1641
|
-
var AgentToolRelationInsertSchema = drizzleZod.createInsertSchema(
|
|
1907
|
+
var AgentToolRelationSelectSchema = drizzleZod.createSelectSchema(subAgentToolRelations);
|
|
1908
|
+
var AgentToolRelationInsertSchema = drizzleZod.createInsertSchema(subAgentToolRelations).extend({
|
|
1642
1909
|
id: resourceIdSchema,
|
|
1643
|
-
|
|
1910
|
+
subAgentId: resourceIdSchema,
|
|
1644
1911
|
toolId: resourceIdSchema,
|
|
1645
1912
|
selectedTools: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
|
|
1646
1913
|
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
@@ -1683,7 +1950,7 @@ var CanUseItemSchema = zodOpenapi.z.object({
|
|
|
1683
1950
|
toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
|
|
1684
1951
|
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
1685
1952
|
});
|
|
1686
|
-
var FullGraphAgentInsertSchema =
|
|
1953
|
+
var FullGraphAgentInsertSchema = SubAgentApiInsertSchema.extend({
|
|
1687
1954
|
type: zodOpenapi.z.literal("internal"),
|
|
1688
1955
|
canUse: zodOpenapi.z.array(CanUseItemSchema),
|
|
1689
1956
|
// All tools (both MCP and function tools)
|
|
@@ -1692,27 +1959,17 @@ var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
|
|
|
1692
1959
|
canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
1693
1960
|
canDelegateTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
|
|
1694
1961
|
});
|
|
1695
|
-
var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
|
|
1696
|
-
agents: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
|
|
1697
|
-
// Lookup maps for UI to resolve canUse items
|
|
1698
|
-
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
|
|
1699
|
-
// Get tool name/description from toolId
|
|
1700
|
-
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
1701
|
-
// Get function code for function tools
|
|
1702
|
-
contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
|
|
1703
|
-
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
1704
|
-
models: ModelSchema.optional(),
|
|
1705
|
-
stopWhen: GraphStopWhenSchema.optional(),
|
|
1706
|
-
graphPrompt: zodOpenapi.z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
|
|
1707
|
-
});
|
|
1708
1962
|
var GraphWithinContextOfProjectSchema = AgentGraphApiInsertSchema.extend({
|
|
1709
|
-
|
|
1963
|
+
subAgents: zodOpenapi.z.record(
|
|
1710
1964
|
zodOpenapi.z.string(),
|
|
1711
1965
|
zodOpenapi.z.discriminatedUnion("type", [
|
|
1712
1966
|
FullGraphAgentInsertSchema,
|
|
1713
1967
|
ExternalAgentApiInsertSchema.extend({ type: zodOpenapi.z.literal("external") })
|
|
1714
1968
|
])
|
|
1715
1969
|
),
|
|
1970
|
+
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
|
|
1971
|
+
// Get tool name/description from toolId
|
|
1972
|
+
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
1716
1973
|
contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
|
|
1717
1974
|
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
1718
1975
|
models: ModelSchema.optional(),
|
|
@@ -1784,72 +2041,46 @@ var HeadersScopeSchema = zodOpenapi.z.object({
|
|
|
1784
2041
|
example: "graph_789"
|
|
1785
2042
|
})
|
|
1786
2043
|
});
|
|
2044
|
+
var TenantId = zodOpenapi.z.string().openapi({
|
|
2045
|
+
description: "Tenant identifier",
|
|
2046
|
+
example: "tenant_123"
|
|
2047
|
+
});
|
|
2048
|
+
var ProjectId = zodOpenapi.z.string().openapi({
|
|
2049
|
+
description: "Project identifier",
|
|
2050
|
+
example: "project_456"
|
|
2051
|
+
});
|
|
2052
|
+
var GraphId = zodOpenapi.z.string().openapi({
|
|
2053
|
+
description: "Graph identifier",
|
|
2054
|
+
example: "graph_789"
|
|
2055
|
+
});
|
|
2056
|
+
var SubAgentId = zodOpenapi.z.string().openapi({
|
|
2057
|
+
description: "Sub-agent identifier",
|
|
2058
|
+
example: "sub_agent_123"
|
|
2059
|
+
});
|
|
1787
2060
|
var TenantParamsSchema = zodOpenapi.z.object({
|
|
1788
|
-
tenantId:
|
|
1789
|
-
description: "Tenant identifier",
|
|
1790
|
-
example: "tenant_123"
|
|
1791
|
-
})
|
|
2061
|
+
tenantId: TenantId
|
|
1792
2062
|
}).openapi("TenantParams");
|
|
1793
|
-
var
|
|
1794
|
-
tenantId: zodOpenapi.z.string().openapi({
|
|
1795
|
-
description: "Tenant identifier",
|
|
1796
|
-
example: "tenant_123"
|
|
1797
|
-
}),
|
|
1798
|
-
projectId: zodOpenapi.z.string().openapi({
|
|
1799
|
-
description: "Project identifier",
|
|
1800
|
-
example: "project_456"
|
|
1801
|
-
})
|
|
1802
|
-
}).openapi("TenantProjectParams");
|
|
1803
|
-
var TenantProjectGraphParamsSchema = zodOpenapi.z.object({
|
|
1804
|
-
tenantId: zodOpenapi.z.string().openapi({
|
|
1805
|
-
description: "Tenant identifier",
|
|
1806
|
-
example: "tenant_123"
|
|
1807
|
-
}),
|
|
1808
|
-
projectId: zodOpenapi.z.string().openapi({
|
|
1809
|
-
description: "Project identifier",
|
|
1810
|
-
example: "project_456"
|
|
1811
|
-
}),
|
|
1812
|
-
graphId: zodOpenapi.z.string().openapi({
|
|
1813
|
-
description: "Graph identifier",
|
|
1814
|
-
example: "graph_789"
|
|
1815
|
-
})
|
|
1816
|
-
}).openapi("TenantProjectGraphParams");
|
|
1817
|
-
var TenantProjectGraphIdParamsSchema = zodOpenapi.z.object({
|
|
1818
|
-
tenantId: zodOpenapi.z.string().openapi({
|
|
1819
|
-
description: "Tenant identifier",
|
|
1820
|
-
example: "tenant_123"
|
|
1821
|
-
}),
|
|
1822
|
-
projectId: zodOpenapi.z.string().openapi({
|
|
1823
|
-
description: "Project identifier",
|
|
1824
|
-
example: "project_456"
|
|
1825
|
-
}),
|
|
1826
|
-
graphId: zodOpenapi.z.string().openapi({
|
|
1827
|
-
description: "Graph identifier",
|
|
1828
|
-
example: "graph_789"
|
|
1829
|
-
}),
|
|
2063
|
+
var TenantIdParamsSchema = TenantParamsSchema.extend({
|
|
1830
2064
|
id: resourceIdSchema
|
|
1831
|
-
}).openapi("
|
|
1832
|
-
var
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
}),
|
|
1837
|
-
projectId: zodOpenapi.z.string().openapi({
|
|
1838
|
-
description: "Project identifier",
|
|
1839
|
-
example: "project_456"
|
|
1840
|
-
}),
|
|
2065
|
+
}).openapi("TenantIdParams");
|
|
2066
|
+
var TenantProjectParamsSchema = TenantParamsSchema.extend({
|
|
2067
|
+
projectId: ProjectId
|
|
2068
|
+
}).openapi("TenantProjectParams");
|
|
2069
|
+
var TenantProjectIdParamsSchema = TenantProjectParamsSchema.extend({
|
|
1841
2070
|
id: resourceIdSchema
|
|
1842
2071
|
}).openapi("TenantProjectIdParams");
|
|
1843
|
-
var
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
}),
|
|
2072
|
+
var TenantProjectGraphParamsSchema = TenantProjectParamsSchema.extend({
|
|
2073
|
+
graphId: GraphId
|
|
2074
|
+
}).openapi("TenantProjectGraphParams");
|
|
2075
|
+
var TenantProjectGraphIdParamsSchema = TenantProjectGraphParamsSchema.extend({
|
|
1848
2076
|
id: resourceIdSchema
|
|
1849
|
-
}).openapi("
|
|
1850
|
-
var
|
|
2077
|
+
}).openapi("TenantProjectGraphIdParams");
|
|
2078
|
+
var TenantProjectGraphSubAgentParamsSchema = TenantProjectGraphParamsSchema.extend({
|
|
2079
|
+
subAgentId: SubAgentId
|
|
2080
|
+
}).openapi("TenantProjectGraphSubAgentParams");
|
|
2081
|
+
var TenantProjectGraphSubAgentIdParamsSchema = TenantProjectGraphSubAgentParamsSchema.extend({
|
|
1851
2082
|
id: resourceIdSchema
|
|
1852
|
-
}).openapi("
|
|
2083
|
+
}).openapi("TenantProjectGraphSubAgentIdParams");
|
|
1853
2084
|
var PaginationQueryParamsSchema = zodOpenapi.z.object({
|
|
1854
2085
|
page: zodOpenapi.z.coerce.number().min(1).default(1),
|
|
1855
2086
|
limit: zodOpenapi.z.coerce.number().min(1).max(100).default(10)
|
|
@@ -2567,263 +2798,623 @@ function createInMemoryDatabaseClient() {
|
|
|
2567
2798
|
const db = createDatabaseClient({ url: ":memory:" });
|
|
2568
2799
|
return db;
|
|
2569
2800
|
}
|
|
2570
|
-
var
|
|
2571
|
-
return db.query.
|
|
2572
|
-
where: drizzleOrm.and(
|
|
2573
|
-
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2574
|
-
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2575
|
-
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2576
|
-
drizzleOrm.eq(agentRelations.id, params.relationId)
|
|
2577
|
-
)
|
|
2578
|
-
});
|
|
2579
|
-
};
|
|
2580
|
-
var listAgentRelations = (db) => async (params) => {
|
|
2581
|
-
const page = params.pagination?.page || 1;
|
|
2582
|
-
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
2583
|
-
const offset = (page - 1) * limit;
|
|
2584
|
-
const whereClause = drizzleOrm.and(
|
|
2585
|
-
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2586
|
-
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2587
|
-
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId)
|
|
2588
|
-
);
|
|
2589
|
-
const [data, totalResult] = await Promise.all([
|
|
2590
|
-
db.select().from(agentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentRelations.createdAt)),
|
|
2591
|
-
db.select({ count: drizzleOrm.count() }).from(agentRelations).where(whereClause)
|
|
2592
|
-
]);
|
|
2593
|
-
const total = totalResult[0]?.count || 0;
|
|
2594
|
-
const pages = Math.ceil(total / limit);
|
|
2595
|
-
return { data, pagination: { page, limit, total, pages } };
|
|
2596
|
-
};
|
|
2597
|
-
var getAgentRelations = (db) => async (params) => {
|
|
2598
|
-
return await db.query.agentRelations.findMany({
|
|
2801
|
+
var getContextConfigById = (db) => async (params) => {
|
|
2802
|
+
return await db.query.contextConfigs.findFirst({
|
|
2599
2803
|
where: drizzleOrm.and(
|
|
2600
|
-
drizzleOrm.eq(
|
|
2601
|
-
drizzleOrm.eq(
|
|
2602
|
-
drizzleOrm.eq(
|
|
2603
|
-
drizzleOrm.eq(
|
|
2804
|
+
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
2805
|
+
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
2806
|
+
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId),
|
|
2807
|
+
drizzleOrm.eq(contextConfigs.id, params.id)
|
|
2604
2808
|
)
|
|
2605
2809
|
});
|
|
2606
2810
|
};
|
|
2607
|
-
var
|
|
2608
|
-
return await db.query.
|
|
2811
|
+
var listContextConfigs = (db) => async (params) => {
|
|
2812
|
+
return await db.query.contextConfigs.findMany({
|
|
2609
2813
|
where: drizzleOrm.and(
|
|
2610
|
-
drizzleOrm.eq(
|
|
2611
|
-
drizzleOrm.eq(
|
|
2612
|
-
drizzleOrm.eq(
|
|
2613
|
-
)
|
|
2814
|
+
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
2815
|
+
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
2816
|
+
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId)
|
|
2817
|
+
),
|
|
2818
|
+
orderBy: [drizzleOrm.desc(contextConfigs.createdAt)]
|
|
2614
2819
|
});
|
|
2615
2820
|
};
|
|
2616
|
-
var
|
|
2617
|
-
const page = params.pagination?.page || 1;
|
|
2618
|
-
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
2619
|
-
const offset = (page - 1) * limit;
|
|
2620
|
-
const whereClause = drizzleOrm.and(
|
|
2621
|
-
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2622
|
-
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2623
|
-
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2624
|
-
drizzleOrm.eq(agentRelations.sourceAgentId, params.sourceAgentId)
|
|
2625
|
-
);
|
|
2626
|
-
const [data, totalResult] = await Promise.all([
|
|
2627
|
-
db.select().from(agentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentRelations.createdAt)),
|
|
2628
|
-
db.select({ count: drizzleOrm.count() }).from(agentRelations).where(whereClause)
|
|
2629
|
-
]);
|
|
2630
|
-
const total = totalResult[0]?.count || 0;
|
|
2631
|
-
const pages = Math.ceil(total / limit);
|
|
2632
|
-
return {
|
|
2633
|
-
data,
|
|
2634
|
-
pagination: { page, limit, total, pages }
|
|
2635
|
-
};
|
|
2636
|
-
};
|
|
2637
|
-
var getAgentRelationsByTarget = (db) => async (params) => {
|
|
2638
|
-
const page = params.pagination?.page || 1;
|
|
2639
|
-
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
2640
|
-
const offset = (page - 1) * limit;
|
|
2641
|
-
const whereClause = drizzleOrm.and(
|
|
2642
|
-
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2643
|
-
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2644
|
-
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2645
|
-
drizzleOrm.eq(agentRelations.targetAgentId, params.targetAgentId)
|
|
2646
|
-
);
|
|
2647
|
-
const [data, totalResult] = await Promise.all([
|
|
2648
|
-
db.select().from(agentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentRelations.createdAt)),
|
|
2649
|
-
db.select({ count: drizzleOrm.count() }).from(agentRelations).where(whereClause)
|
|
2650
|
-
]);
|
|
2651
|
-
const total = totalResult[0]?.count || 0;
|
|
2652
|
-
const pages = Math.ceil(total / limit);
|
|
2653
|
-
return {
|
|
2654
|
-
data,
|
|
2655
|
-
pagination: { page, limit, total, pages }
|
|
2656
|
-
};
|
|
2657
|
-
};
|
|
2658
|
-
var getExternalAgentRelations = (db) => async (params) => {
|
|
2821
|
+
var listContextConfigsPaginated = (db) => async (params) => {
|
|
2659
2822
|
const page = params.pagination?.page || 1;
|
|
2660
2823
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
2661
2824
|
const offset = (page - 1) * limit;
|
|
2662
2825
|
const whereClause = drizzleOrm.and(
|
|
2663
|
-
drizzleOrm.eq(
|
|
2664
|
-
drizzleOrm.eq(
|
|
2665
|
-
drizzleOrm.eq(
|
|
2666
|
-
drizzleOrm.eq(agentRelations.externalAgentId, params.externalAgentId)
|
|
2826
|
+
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
2827
|
+
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
2828
|
+
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId)
|
|
2667
2829
|
);
|
|
2668
|
-
const [
|
|
2669
|
-
db.select().from(
|
|
2670
|
-
db.select({ count: drizzleOrm.
|
|
2830
|
+
const [contextConfigList, totalResult] = await Promise.all([
|
|
2831
|
+
db.select().from(contextConfigs).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(contextConfigs.createdAt)),
|
|
2832
|
+
db.select({ count: drizzleOrm.sql`COUNT(*)` }).from(contextConfigs).where(whereClause)
|
|
2671
2833
|
]);
|
|
2672
|
-
const total = totalResult[0]?.count || 0;
|
|
2834
|
+
const total = Number(totalResult[0]?.count || 0);
|
|
2673
2835
|
const pages = Math.ceil(total / limit);
|
|
2674
2836
|
return {
|
|
2675
|
-
data,
|
|
2676
|
-
pagination: {
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
id: agents.id,
|
|
2682
|
-
name: agents.name,
|
|
2683
|
-
description: agents.description,
|
|
2684
|
-
relationType: agentRelations.relationType
|
|
2685
|
-
}).from(agentRelations).innerJoin(
|
|
2686
|
-
agents,
|
|
2687
|
-
drizzleOrm.and(
|
|
2688
|
-
drizzleOrm.eq(agentRelations.targetAgentId, agents.id),
|
|
2689
|
-
drizzleOrm.eq(agentRelations.tenantId, agents.tenantId),
|
|
2690
|
-
drizzleOrm.eq(agentRelations.projectId, agents.projectId),
|
|
2691
|
-
drizzleOrm.eq(agentRelations.graphId, agents.graphId)
|
|
2692
|
-
)
|
|
2693
|
-
).where(
|
|
2694
|
-
drizzleOrm.and(
|
|
2695
|
-
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2696
|
-
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2697
|
-
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2698
|
-
drizzleOrm.eq(agentRelations.sourceAgentId, params.agentId),
|
|
2699
|
-
drizzleOrm.isNotNull(agentRelations.targetAgentId)
|
|
2700
|
-
)
|
|
2701
|
-
);
|
|
2702
|
-
const externalRelations = await db.select({
|
|
2703
|
-
id: agentRelations.id,
|
|
2704
|
-
relationType: agentRelations.relationType,
|
|
2705
|
-
externalAgent: {
|
|
2706
|
-
id: externalAgents.id,
|
|
2707
|
-
name: externalAgents.name,
|
|
2708
|
-
description: externalAgents.description,
|
|
2709
|
-
baseUrl: externalAgents.baseUrl
|
|
2837
|
+
data: contextConfigList,
|
|
2838
|
+
pagination: {
|
|
2839
|
+
page,
|
|
2840
|
+
limit,
|
|
2841
|
+
total,
|
|
2842
|
+
pages
|
|
2710
2843
|
}
|
|
2711
|
-
}).from(agentRelations).innerJoin(
|
|
2712
|
-
externalAgents,
|
|
2713
|
-
drizzleOrm.and(
|
|
2714
|
-
drizzleOrm.eq(agentRelations.externalAgentId, externalAgents.id),
|
|
2715
|
-
drizzleOrm.eq(agentRelations.tenantId, externalAgents.tenantId),
|
|
2716
|
-
drizzleOrm.eq(agentRelations.projectId, externalAgents.projectId),
|
|
2717
|
-
drizzleOrm.eq(agentRelations.graphId, externalAgents.graphId)
|
|
2718
|
-
)
|
|
2719
|
-
).where(
|
|
2720
|
-
drizzleOrm.and(
|
|
2721
|
-
drizzleOrm.eq(agentRelations.tenantId, params.scopes.tenantId),
|
|
2722
|
-
drizzleOrm.eq(agentRelations.projectId, params.scopes.projectId),
|
|
2723
|
-
drizzleOrm.eq(agentRelations.graphId, params.scopes.graphId),
|
|
2724
|
-
drizzleOrm.eq(agentRelations.sourceAgentId, params.agentId),
|
|
2725
|
-
drizzleOrm.isNotNull(agentRelations.externalAgentId)
|
|
2726
|
-
)
|
|
2727
|
-
);
|
|
2728
|
-
return {
|
|
2729
|
-
internalRelations,
|
|
2730
|
-
externalRelations
|
|
2731
2844
|
};
|
|
2732
2845
|
};
|
|
2733
|
-
var
|
|
2734
|
-
const
|
|
2735
|
-
const
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
if (!hasTargetAgent && !hasExternalAgent) {
|
|
2740
|
-
throw new Error("Must specify either targetAgentId or externalAgentId");
|
|
2846
|
+
var createContextConfig = (db) => async (params) => {
|
|
2847
|
+
const id = params.id || nanoid.nanoid();
|
|
2848
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2849
|
+
let contextVariables = params.contextVariables;
|
|
2850
|
+
if (contextVariables !== void 0 && contextVariables !== null && typeof contextVariables === "object" && Object.keys(contextVariables).length === 0) {
|
|
2851
|
+
contextVariables = null;
|
|
2741
2852
|
}
|
|
2742
|
-
const
|
|
2743
|
-
|
|
2853
|
+
const contextConfig2 = await db.insert(contextConfigs).values({
|
|
2854
|
+
id,
|
|
2855
|
+
tenantId: params.tenantId,
|
|
2856
|
+
projectId: params.projectId,
|
|
2857
|
+
graphId: params.graphId,
|
|
2858
|
+
headersSchema: params.headersSchema ?? null,
|
|
2859
|
+
contextVariables: contextVariables ?? null,
|
|
2860
|
+
createdAt: now,
|
|
2861
|
+
updatedAt: now
|
|
2744
2862
|
}).returning();
|
|
2745
|
-
return
|
|
2863
|
+
return contextConfig2[0];
|
|
2746
2864
|
};
|
|
2747
|
-
var
|
|
2748
|
-
const
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
];
|
|
2755
|
-
if (params.targetAgentId) {
|
|
2756
|
-
whereConditions.push(drizzleOrm.eq(agentRelations.targetAgentId, params.targetAgentId));
|
|
2757
|
-
}
|
|
2758
|
-
if (params.externalAgentId) {
|
|
2759
|
-
whereConditions.push(drizzleOrm.eq(agentRelations.externalAgentId, params.externalAgentId));
|
|
2865
|
+
var updateContextConfig = (db) => async (params) => {
|
|
2866
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2867
|
+
const processedData = { ...params.data };
|
|
2868
|
+
if ("contextVariables" in params.data) {
|
|
2869
|
+
if (params.data.contextVariables === null || typeof params.data.contextVariables === "object" && params.data.contextVariables !== null && Object.keys(params.data.contextVariables).length === 0) {
|
|
2870
|
+
processedData.contextVariables = null;
|
|
2871
|
+
}
|
|
2760
2872
|
}
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
});
|
|
2764
|
-
};
|
|
2765
|
-
var upsertAgentRelation = (db) => async (params) => {
|
|
2766
|
-
const existing = await getAgentRelationByParams(db)({
|
|
2767
|
-
scopes: { tenantId: params.tenantId, projectId: params.projectId, graphId: params.graphId },
|
|
2768
|
-
sourceAgentId: params.sourceAgentId,
|
|
2769
|
-
targetAgentId: params.targetAgentId,
|
|
2770
|
-
externalAgentId: params.externalAgentId,
|
|
2771
|
-
relationType: params.relationType ?? ""
|
|
2772
|
-
});
|
|
2773
|
-
if (!existing) {
|
|
2774
|
-
return await createAgentRelation(db)(params);
|
|
2873
|
+
if ("headersSchema" in params.data && params.data.headersSchema === null) {
|
|
2874
|
+
processedData.headersSchema = null;
|
|
2775
2875
|
}
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
...params,
|
|
2781
|
-
targetAgentId: void 0
|
|
2782
|
-
});
|
|
2783
|
-
};
|
|
2784
|
-
var updateAgentRelation = (db) => async (params) => {
|
|
2785
|
-
const updateData = {
|
|
2786
|
-
...params.data,
|
|
2787
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2788
|
-
};
|
|
2789
|
-
const relation = await db.update(agentRelations).set(updateData).where(
|
|
2876
|
+
const updated = await db.update(contextConfigs).set({
|
|
2877
|
+
...processedData,
|
|
2878
|
+
updatedAt: now
|
|
2879
|
+
}).where(
|
|
2790
2880
|
drizzleOrm.and(
|
|
2791
|
-
drizzleOrm.eq(
|
|
2792
|
-
drizzleOrm.eq(
|
|
2793
|
-
drizzleOrm.eq(
|
|
2794
|
-
drizzleOrm.eq(
|
|
2881
|
+
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
2882
|
+
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
2883
|
+
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId),
|
|
2884
|
+
drizzleOrm.eq(contextConfigs.id, params.id)
|
|
2795
2885
|
)
|
|
2796
2886
|
).returning();
|
|
2797
|
-
return
|
|
2887
|
+
return updated[0];
|
|
2798
2888
|
};
|
|
2799
|
-
var
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
drizzleOrm.
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2889
|
+
var deleteContextConfig = (db) => async (params) => {
|
|
2890
|
+
try {
|
|
2891
|
+
const result = await db.delete(contextConfigs).where(
|
|
2892
|
+
drizzleOrm.and(
|
|
2893
|
+
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
2894
|
+
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
2895
|
+
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId),
|
|
2896
|
+
drizzleOrm.eq(contextConfigs.id, params.id)
|
|
2897
|
+
)
|
|
2898
|
+
).returning();
|
|
2899
|
+
return result.length > 0;
|
|
2900
|
+
} catch (error) {
|
|
2901
|
+
console.error("Error deleting context config:", error);
|
|
2902
|
+
return false;
|
|
2903
|
+
}
|
|
2904
|
+
};
|
|
2905
|
+
var hasContextConfig = (db) => async (params) => {
|
|
2906
|
+
const contextConfig2 = await getContextConfigById(db)(params);
|
|
2907
|
+
return contextConfig2 !== null;
|
|
2908
|
+
};
|
|
2909
|
+
var countContextConfigs = (db) => async (params) => {
|
|
2910
|
+
const result = await db.select({ count: drizzleOrm.count() }).from(contextConfigs).where(
|
|
2911
|
+
drizzleOrm.and(
|
|
2912
|
+
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
2913
|
+
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
2914
|
+
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId)
|
|
2915
|
+
)
|
|
2916
|
+
);
|
|
2917
|
+
const total = result[0]?.count || 0;
|
|
2918
|
+
return typeof total === "string" ? Number.parseInt(total, 10) : total;
|
|
2919
|
+
};
|
|
2920
|
+
var upsertContextConfig = (db) => async (params) => {
|
|
2921
|
+
const scopes = {
|
|
2922
|
+
tenantId: params.data.tenantId,
|
|
2923
|
+
projectId: params.data.projectId,
|
|
2924
|
+
graphId: params.data.graphId
|
|
2925
|
+
};
|
|
2926
|
+
if (params.data.id) {
|
|
2927
|
+
const existing = await getContextConfigById(db)({
|
|
2928
|
+
scopes,
|
|
2929
|
+
id: params.data.id
|
|
2930
|
+
});
|
|
2931
|
+
if (existing) {
|
|
2932
|
+
return await updateContextConfig(db)({
|
|
2933
|
+
scopes,
|
|
2934
|
+
id: params.data.id,
|
|
2935
|
+
data: {
|
|
2936
|
+
headersSchema: params.data.headersSchema,
|
|
2937
|
+
contextVariables: params.data.contextVariables
|
|
2938
|
+
}
|
|
2939
|
+
});
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
return await createContextConfig(db)(params.data);
|
|
2943
|
+
};
|
|
2944
|
+
var createExternalAgent = (db) => async (params) => {
|
|
2945
|
+
const agent = await db.insert(externalAgents).values(params).returning();
|
|
2946
|
+
return agent[0];
|
|
2947
|
+
};
|
|
2948
|
+
var getExternalAgent = (db) => async (params) => {
|
|
2949
|
+
const result = await db.query.externalAgents.findFirst({
|
|
2950
|
+
where: drizzleOrm.and(
|
|
2951
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
2952
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
2953
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
2954
|
+
drizzleOrm.eq(externalAgents.id, params.subAgentId)
|
|
2955
|
+
)
|
|
2956
|
+
});
|
|
2957
|
+
return result || null;
|
|
2958
|
+
};
|
|
2959
|
+
var getExternalAgentByUrl = (db) => async (params) => {
|
|
2960
|
+
const result = await db.query.externalAgents.findFirst({
|
|
2961
|
+
where: drizzleOrm.and(
|
|
2962
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
2963
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
2964
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
2965
|
+
drizzleOrm.eq(externalAgents.baseUrl, params.baseUrl)
|
|
2966
|
+
)
|
|
2967
|
+
});
|
|
2968
|
+
return result || null;
|
|
2969
|
+
};
|
|
2970
|
+
var listExternalAgents = (db) => async (params) => {
|
|
2971
|
+
return await db.query.externalAgents.findMany({
|
|
2972
|
+
where: drizzleOrm.and(
|
|
2973
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
2974
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
2975
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
2976
|
+
),
|
|
2977
|
+
orderBy: [drizzleOrm.asc(externalAgents.name)]
|
|
2978
|
+
});
|
|
2979
|
+
};
|
|
2980
|
+
var listExternalAgentsPaginated = (db) => async (params) => {
|
|
2981
|
+
const page = params.pagination?.page || 1;
|
|
2982
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
2983
|
+
const offset = (page - 1) * limit;
|
|
2984
|
+
const [data, totalResult] = await Promise.all([
|
|
2985
|
+
db.select().from(externalAgents).where(
|
|
2986
|
+
drizzleOrm.and(
|
|
2987
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
2988
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
2989
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
2990
|
+
)
|
|
2991
|
+
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(externalAgents.createdAt)),
|
|
2992
|
+
db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
2993
|
+
drizzleOrm.and(
|
|
2994
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
2995
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
2996
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
2997
|
+
)
|
|
2998
|
+
)
|
|
2999
|
+
]);
|
|
3000
|
+
const total = typeof totalResult[0]?.count === "string" ? parseInt(totalResult[0].count, 10) : totalResult[0]?.count || 0;
|
|
3001
|
+
const pages = Math.ceil(total / limit);
|
|
3002
|
+
return {
|
|
3003
|
+
data,
|
|
3004
|
+
pagination: { page, limit, total, pages }
|
|
3005
|
+
};
|
|
3006
|
+
};
|
|
3007
|
+
var updateExternalAgent = (db) => async (params) => {
|
|
3008
|
+
const updateData = {
|
|
3009
|
+
...params.data,
|
|
3010
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3011
|
+
};
|
|
3012
|
+
if (Object.keys(updateData).length === 1) {
|
|
3013
|
+
throw new Error("No fields to update");
|
|
3014
|
+
}
|
|
3015
|
+
if (updateData.headers !== void 0 && (updateData.headers === null || Object.keys(updateData.headers || {}).length === 0)) {
|
|
3016
|
+
updateData.headers = null;
|
|
3017
|
+
}
|
|
3018
|
+
if (updateData.credentialReferenceId === void 0) {
|
|
3019
|
+
updateData.credentialReferenceId = null;
|
|
3020
|
+
}
|
|
3021
|
+
const result = await db.update(externalAgents).set(updateData).where(
|
|
3022
|
+
drizzleOrm.and(
|
|
3023
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3024
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3025
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
3026
|
+
drizzleOrm.eq(externalAgents.id, params.subAgentId)
|
|
3027
|
+
)
|
|
3028
|
+
).returning();
|
|
3029
|
+
return result[0] || null;
|
|
3030
|
+
};
|
|
3031
|
+
var upsertExternalAgent = (db) => async (params) => {
|
|
3032
|
+
const scopes = {
|
|
3033
|
+
tenantId: params.data.tenantId,
|
|
3034
|
+
projectId: params.data.projectId,
|
|
3035
|
+
graphId: params.data.graphId
|
|
3036
|
+
};
|
|
3037
|
+
const existing = await getExternalAgent(db)({
|
|
3038
|
+
scopes,
|
|
3039
|
+
subAgentId: params.data.id
|
|
3040
|
+
});
|
|
3041
|
+
if (existing) {
|
|
3042
|
+
const updated = await updateExternalAgent(db)({
|
|
3043
|
+
scopes,
|
|
3044
|
+
subAgentId: params.data.id,
|
|
3045
|
+
data: {
|
|
3046
|
+
name: params.data.name,
|
|
3047
|
+
description: params.data.description,
|
|
3048
|
+
baseUrl: params.data.baseUrl,
|
|
3049
|
+
credentialReferenceId: params.data.credentialReferenceId,
|
|
3050
|
+
headers: params.data.headers
|
|
3051
|
+
}
|
|
3052
|
+
});
|
|
3053
|
+
if (!updated) {
|
|
3054
|
+
throw new Error("Failed to update external agent - no rows affected");
|
|
3055
|
+
}
|
|
3056
|
+
return updated;
|
|
3057
|
+
} else {
|
|
3058
|
+
return await createExternalAgent(db)(params.data);
|
|
3059
|
+
}
|
|
3060
|
+
};
|
|
3061
|
+
var deleteExternalAgent = (db) => async (params) => {
|
|
3062
|
+
try {
|
|
3063
|
+
const result = await db.delete(externalAgents).where(
|
|
3064
|
+
drizzleOrm.and(
|
|
3065
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3066
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3067
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
3068
|
+
drizzleOrm.eq(externalAgents.id, params.subAgentId)
|
|
3069
|
+
)
|
|
3070
|
+
).returning();
|
|
3071
|
+
return result.length > 0;
|
|
3072
|
+
} catch (error) {
|
|
3073
|
+
console.error("Error deleting external agent:", error);
|
|
3074
|
+
return false;
|
|
3075
|
+
}
|
|
3076
|
+
};
|
|
3077
|
+
var externalAgentExists = (db) => async (params) => {
|
|
3078
|
+
const agent = await getExternalAgent(db)(params);
|
|
3079
|
+
return agent !== null;
|
|
3080
|
+
};
|
|
3081
|
+
var externalAgentUrlExists = (db) => async (params) => {
|
|
3082
|
+
const agent = await getExternalAgentByUrl(db)(params);
|
|
3083
|
+
return agent !== null;
|
|
3084
|
+
};
|
|
3085
|
+
var countExternalAgents = (db) => async (params) => {
|
|
3086
|
+
const result = await db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
3087
|
+
drizzleOrm.and(
|
|
3088
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3089
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3090
|
+
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
3091
|
+
)
|
|
3092
|
+
);
|
|
3093
|
+
const countValue = result[0]?.count;
|
|
3094
|
+
return typeof countValue === "string" ? parseInt(countValue, 10) : countValue || 0;
|
|
3095
|
+
};
|
|
3096
|
+
var upsertFunction = (db) => async (params) => {
|
|
3097
|
+
const { data, scopes } = params;
|
|
3098
|
+
const { tenantId, projectId } = scopes;
|
|
3099
|
+
const existingFunction = await db.select().from(functions).where(
|
|
3100
|
+
drizzleOrm.and(
|
|
3101
|
+
drizzleOrm.eq(functions.tenantId, tenantId),
|
|
3102
|
+
drizzleOrm.eq(functions.projectId, projectId),
|
|
3103
|
+
drizzleOrm.eq(functions.id, data.id)
|
|
3104
|
+
)
|
|
3105
|
+
).limit(1);
|
|
3106
|
+
if (existingFunction.length > 0) {
|
|
3107
|
+
await db.update(functions).set({
|
|
3108
|
+
inputSchema: data.inputSchema,
|
|
3109
|
+
executeCode: data.executeCode,
|
|
3110
|
+
dependencies: data.dependencies,
|
|
3111
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3112
|
+
}).where(
|
|
3113
|
+
drizzleOrm.and(
|
|
3114
|
+
drizzleOrm.eq(functions.tenantId, tenantId),
|
|
3115
|
+
drizzleOrm.eq(functions.projectId, projectId),
|
|
3116
|
+
drizzleOrm.eq(functions.id, data.id)
|
|
3117
|
+
)
|
|
3118
|
+
);
|
|
3119
|
+
} else {
|
|
3120
|
+
await db.insert(functions).values({
|
|
3121
|
+
tenantId,
|
|
3122
|
+
projectId,
|
|
3123
|
+
id: data.id,
|
|
3124
|
+
inputSchema: data.inputSchema,
|
|
3125
|
+
executeCode: data.executeCode,
|
|
3126
|
+
dependencies: data.dependencies,
|
|
3127
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3128
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3129
|
+
});
|
|
3130
|
+
}
|
|
3131
|
+
};
|
|
3132
|
+
var getFunction = (db) => async (params) => {
|
|
3133
|
+
const { functionId, scopes } = params;
|
|
3134
|
+
const { tenantId, projectId } = scopes;
|
|
3135
|
+
const result = await db.select().from(functions).where(
|
|
3136
|
+
drizzleOrm.and(
|
|
3137
|
+
drizzleOrm.eq(functions.tenantId, tenantId),
|
|
3138
|
+
drizzleOrm.eq(functions.projectId, projectId),
|
|
3139
|
+
drizzleOrm.eq(functions.id, functionId)
|
|
3140
|
+
)
|
|
3141
|
+
).limit(1);
|
|
3142
|
+
return result[0] || null;
|
|
3143
|
+
};
|
|
3144
|
+
var listFunctions = (db) => async (params) => {
|
|
3145
|
+
const { scopes } = params;
|
|
3146
|
+
const { tenantId, projectId } = scopes;
|
|
3147
|
+
const result = await db.select().from(functions).where(drizzleOrm.and(drizzleOrm.eq(functions.tenantId, tenantId), drizzleOrm.eq(functions.projectId, projectId)));
|
|
3148
|
+
return result;
|
|
3149
|
+
};
|
|
3150
|
+
var deleteFunction = (db) => async (params) => {
|
|
3151
|
+
const { functionId, scopes } = params;
|
|
3152
|
+
const { tenantId, projectId } = scopes;
|
|
3153
|
+
await db.delete(functions).where(
|
|
3154
|
+
drizzleOrm.and(
|
|
3155
|
+
drizzleOrm.eq(functions.tenantId, tenantId),
|
|
3156
|
+
drizzleOrm.eq(functions.projectId, projectId),
|
|
3157
|
+
drizzleOrm.eq(functions.id, functionId)
|
|
3158
|
+
)
|
|
3159
|
+
);
|
|
3160
|
+
};
|
|
3161
|
+
var getAgentRelationById = (db) => async (params) => {
|
|
3162
|
+
return db.query.subAgentRelations.findFirst({
|
|
3163
|
+
where: drizzleOrm.and(
|
|
3164
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3165
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3166
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3167
|
+
drizzleOrm.eq(subAgentRelations.id, params.relationId)
|
|
3168
|
+
)
|
|
3169
|
+
});
|
|
3170
|
+
};
|
|
3171
|
+
var listAgentRelations = (db) => async (params) => {
|
|
3172
|
+
const page = params.pagination?.page || 1;
|
|
3173
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
3174
|
+
const offset = (page - 1) * limit;
|
|
3175
|
+
const whereClause = drizzleOrm.and(
|
|
3176
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3177
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3178
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId)
|
|
3179
|
+
);
|
|
3180
|
+
const [data, totalResult] = await Promise.all([
|
|
3181
|
+
db.select().from(subAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentRelations.createdAt)),
|
|
3182
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentRelations).where(whereClause)
|
|
3183
|
+
]);
|
|
3184
|
+
const total = totalResult[0]?.count || 0;
|
|
3185
|
+
const pages = Math.ceil(total / limit);
|
|
3186
|
+
return { data, pagination: { page, limit, total, pages } };
|
|
3187
|
+
};
|
|
3188
|
+
var getAgentRelations = (db) => async (params) => {
|
|
3189
|
+
return await db.query.subAgentRelations.findMany({
|
|
3190
|
+
where: drizzleOrm.and(
|
|
3191
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3192
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3193
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3194
|
+
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.scopes.subAgentId)
|
|
3195
|
+
)
|
|
3196
|
+
});
|
|
3197
|
+
};
|
|
3198
|
+
var getAgentRelationsByGraph = (db) => async (params) => {
|
|
3199
|
+
return await db.query.subAgentRelations.findMany({
|
|
3200
|
+
where: drizzleOrm.and(
|
|
3201
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3202
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3203
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId)
|
|
3204
|
+
)
|
|
3205
|
+
});
|
|
3206
|
+
};
|
|
3207
|
+
var getAgentRelationsBySource = (db) => async (params) => {
|
|
3208
|
+
const page = params.pagination?.page || 1;
|
|
3209
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
3210
|
+
const offset = (page - 1) * limit;
|
|
3211
|
+
const whereClause = drizzleOrm.and(
|
|
3212
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3213
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3214
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3215
|
+
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.sourceSubAgentId)
|
|
3216
|
+
);
|
|
3217
|
+
const [data, totalResult] = await Promise.all([
|
|
3218
|
+
db.select().from(subAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentRelations.createdAt)),
|
|
3219
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentRelations).where(whereClause)
|
|
3220
|
+
]);
|
|
3221
|
+
const total = totalResult[0]?.count || 0;
|
|
3222
|
+
const pages = Math.ceil(total / limit);
|
|
3223
|
+
return {
|
|
3224
|
+
data,
|
|
3225
|
+
pagination: { page, limit, total, pages }
|
|
3226
|
+
};
|
|
3227
|
+
};
|
|
3228
|
+
var getAgentRelationsByTarget = (db) => async (params) => {
|
|
3229
|
+
const page = params.pagination?.page || 1;
|
|
3230
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
3231
|
+
const offset = (page - 1) * limit;
|
|
3232
|
+
const whereClause = drizzleOrm.and(
|
|
3233
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3234
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3235
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3236
|
+
drizzleOrm.eq(subAgentRelations.targetSubAgentId, params.targetSubAgentId)
|
|
3237
|
+
);
|
|
3238
|
+
const [data, totalResult] = await Promise.all([
|
|
3239
|
+
db.select().from(subAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentRelations.createdAt)),
|
|
3240
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentRelations).where(whereClause)
|
|
3241
|
+
]);
|
|
3242
|
+
const total = totalResult[0]?.count || 0;
|
|
3243
|
+
const pages = Math.ceil(total / limit);
|
|
3244
|
+
return {
|
|
3245
|
+
data,
|
|
3246
|
+
pagination: { page, limit, total, pages }
|
|
3247
|
+
};
|
|
3248
|
+
};
|
|
3249
|
+
var getExternalAgentRelations = (db) => async (params) => {
|
|
3250
|
+
const page = params.pagination?.page || 1;
|
|
3251
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
3252
|
+
const offset = (page - 1) * limit;
|
|
3253
|
+
const whereClause = drizzleOrm.and(
|
|
3254
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3255
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3256
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3257
|
+
drizzleOrm.eq(subAgentRelations.externalSubAgentId, params.externalSubAgentId)
|
|
3258
|
+
);
|
|
3259
|
+
const [data, totalResult] = await Promise.all([
|
|
3260
|
+
db.select().from(subAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentRelations.createdAt)),
|
|
3261
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentRelations).where(whereClause)
|
|
3262
|
+
]);
|
|
3263
|
+
const total = totalResult[0]?.count || 0;
|
|
3264
|
+
const pages = Math.ceil(total / limit);
|
|
3265
|
+
return {
|
|
3266
|
+
data,
|
|
3267
|
+
pagination: { page, limit, total, pages }
|
|
3268
|
+
};
|
|
3269
|
+
};
|
|
3270
|
+
var getRelatedAgentsForGraph = (db) => async (params) => {
|
|
3271
|
+
const internalRelations = await db.select({
|
|
3272
|
+
id: subAgents.id,
|
|
3273
|
+
name: subAgents.name,
|
|
3274
|
+
description: subAgents.description,
|
|
3275
|
+
relationType: subAgentRelations.relationType
|
|
3276
|
+
}).from(subAgentRelations).innerJoin(
|
|
3277
|
+
subAgents,
|
|
3278
|
+
drizzleOrm.and(
|
|
3279
|
+
drizzleOrm.eq(subAgentRelations.targetSubAgentId, subAgents.id),
|
|
3280
|
+
drizzleOrm.eq(subAgentRelations.tenantId, subAgents.tenantId),
|
|
3281
|
+
drizzleOrm.eq(subAgentRelations.projectId, subAgents.projectId),
|
|
3282
|
+
drizzleOrm.eq(subAgentRelations.graphId, subAgents.graphId)
|
|
3283
|
+
)
|
|
3284
|
+
).where(
|
|
3285
|
+
drizzleOrm.and(
|
|
3286
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3287
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3288
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3289
|
+
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.subAgentId),
|
|
3290
|
+
drizzleOrm.isNotNull(subAgentRelations.targetSubAgentId)
|
|
3291
|
+
)
|
|
3292
|
+
);
|
|
3293
|
+
const externalRelations = await db.select({
|
|
3294
|
+
id: subAgentRelations.id,
|
|
3295
|
+
relationType: subAgentRelations.relationType,
|
|
3296
|
+
externalAgent: {
|
|
3297
|
+
id: externalAgents.id,
|
|
3298
|
+
name: externalAgents.name,
|
|
3299
|
+
description: externalAgents.description,
|
|
3300
|
+
baseUrl: externalAgents.baseUrl
|
|
3301
|
+
}
|
|
3302
|
+
}).from(subAgentRelations).innerJoin(
|
|
3303
|
+
externalAgents,
|
|
3304
|
+
drizzleOrm.and(
|
|
3305
|
+
drizzleOrm.eq(subAgentRelations.externalSubAgentId, externalAgents.id),
|
|
3306
|
+
drizzleOrm.eq(subAgentRelations.tenantId, externalAgents.tenantId),
|
|
3307
|
+
drizzleOrm.eq(subAgentRelations.projectId, externalAgents.projectId),
|
|
3308
|
+
drizzleOrm.eq(subAgentRelations.graphId, externalAgents.graphId)
|
|
3309
|
+
)
|
|
3310
|
+
).where(
|
|
3311
|
+
drizzleOrm.and(
|
|
3312
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3313
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3314
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3315
|
+
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.subAgentId),
|
|
3316
|
+
drizzleOrm.isNotNull(subAgentRelations.externalSubAgentId)
|
|
3317
|
+
)
|
|
3318
|
+
);
|
|
3319
|
+
return {
|
|
3320
|
+
internalRelations,
|
|
3321
|
+
externalRelations
|
|
3322
|
+
};
|
|
3323
|
+
};
|
|
3324
|
+
var createSubAgentRelation = (db) => async (params) => {
|
|
3325
|
+
const hasTargetAgent = params.targetSubAgentId != null;
|
|
3326
|
+
const hasExternalAgent = params.externalSubAgentId != null;
|
|
3327
|
+
if (hasTargetAgent && hasExternalAgent) {
|
|
3328
|
+
throw new Error("Cannot specify both targetSubAgentId and externalSubAgentId");
|
|
3329
|
+
}
|
|
3330
|
+
if (!hasTargetAgent && !hasExternalAgent) {
|
|
3331
|
+
throw new Error("Must specify either targetSubAgentId or externalSubAgentId");
|
|
3332
|
+
}
|
|
3333
|
+
const relation = await db.insert(subAgentRelations).values({
|
|
3334
|
+
...params
|
|
3335
|
+
}).returning();
|
|
3336
|
+
return relation[0];
|
|
3337
|
+
};
|
|
3338
|
+
var getAgentRelationByParams = (db) => async (params) => {
|
|
3339
|
+
const whereConditions = [
|
|
3340
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3341
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3342
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3343
|
+
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.sourceSubAgentId),
|
|
3344
|
+
drizzleOrm.eq(subAgentRelations.relationType, params.relationType)
|
|
3345
|
+
];
|
|
3346
|
+
if (params.targetSubAgentId) {
|
|
3347
|
+
whereConditions.push(drizzleOrm.eq(subAgentRelations.targetSubAgentId, params.targetSubAgentId));
|
|
3348
|
+
}
|
|
3349
|
+
if (params.externalSubAgentId) {
|
|
3350
|
+
whereConditions.push(drizzleOrm.eq(subAgentRelations.externalSubAgentId, params.externalSubAgentId));
|
|
3351
|
+
}
|
|
3352
|
+
return db.query.subAgentRelations.findFirst({
|
|
3353
|
+
where: drizzleOrm.and(...whereConditions)
|
|
3354
|
+
});
|
|
3355
|
+
};
|
|
3356
|
+
var upsertAgentRelation = (db) => async (params) => {
|
|
3357
|
+
const existing = await getAgentRelationByParams(db)({
|
|
3358
|
+
scopes: { tenantId: params.tenantId, projectId: params.projectId, graphId: params.graphId },
|
|
3359
|
+
sourceSubAgentId: params.sourceSubAgentId,
|
|
3360
|
+
targetSubAgentId: params.targetSubAgentId,
|
|
3361
|
+
externalSubAgentId: params.externalSubAgentId,
|
|
3362
|
+
relationType: params.relationType ?? ""
|
|
3363
|
+
});
|
|
3364
|
+
if (!existing) {
|
|
3365
|
+
return await createSubAgentRelation(db)(params);
|
|
3366
|
+
}
|
|
3367
|
+
return existing;
|
|
3368
|
+
};
|
|
3369
|
+
var createExternalAgentRelation = (db) => async (params) => {
|
|
3370
|
+
return await createSubAgentRelation(db)({
|
|
3371
|
+
...params,
|
|
3372
|
+
targetSubAgentId: void 0
|
|
3373
|
+
});
|
|
3374
|
+
};
|
|
3375
|
+
var updateAgentRelation = (db) => async (params) => {
|
|
3376
|
+
const updateData = {
|
|
3377
|
+
...params.data,
|
|
3378
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3379
|
+
};
|
|
3380
|
+
const relation = await db.update(subAgentRelations).set(updateData).where(
|
|
3381
|
+
drizzleOrm.and(
|
|
3382
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3383
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3384
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3385
|
+
drizzleOrm.eq(subAgentRelations.id, params.relationId)
|
|
3386
|
+
)
|
|
3387
|
+
).returning();
|
|
3388
|
+
return relation[0];
|
|
3389
|
+
};
|
|
3390
|
+
var deleteSubAgentRelation = (db) => async (params) => {
|
|
3391
|
+
const result = await db.delete(subAgentRelations).where(
|
|
3392
|
+
drizzleOrm.and(
|
|
3393
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3394
|
+
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
3395
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId),
|
|
3396
|
+
drizzleOrm.eq(subAgentRelations.id, params.relationId)
|
|
3397
|
+
)
|
|
3398
|
+
);
|
|
2808
3399
|
return (result.rowsAffected || 0) > 0;
|
|
2809
3400
|
};
|
|
2810
3401
|
var deleteAgentRelationsByGraph = (db) => async (params) => {
|
|
2811
|
-
const result = await db.delete(
|
|
3402
|
+
const result = await db.delete(subAgentRelations).where(
|
|
2812
3403
|
drizzleOrm.and(
|
|
2813
|
-
drizzleOrm.eq(
|
|
2814
|
-
drizzleOrm.eq(
|
|
3404
|
+
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
3405
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId)
|
|
2815
3406
|
)
|
|
2816
3407
|
);
|
|
2817
3408
|
return (result.rowsAffected || 0) > 0;
|
|
2818
3409
|
};
|
|
2819
3410
|
var createAgentToolRelation = (db) => async (params) => {
|
|
2820
3411
|
const finalRelationId = params.relationId ?? nanoid.nanoid();
|
|
2821
|
-
const relation = await db.insert(
|
|
3412
|
+
const relation = await db.insert(subAgentToolRelations).values({
|
|
2822
3413
|
id: finalRelationId,
|
|
2823
3414
|
tenantId: params.scopes.tenantId,
|
|
2824
3415
|
projectId: params.scopes.projectId,
|
|
2825
3416
|
graphId: params.scopes.graphId,
|
|
2826
|
-
|
|
3417
|
+
subAgentId: params.data.subAgentId,
|
|
2827
3418
|
toolId: params.data.toolId,
|
|
2828
3419
|
selectedTools: params.data.selectedTools,
|
|
2829
3420
|
headers: params.data.headers
|
|
@@ -2835,45 +3426,45 @@ var updateAgentToolRelation = (db) => async (params) => {
|
|
|
2835
3426
|
...params.data,
|
|
2836
3427
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2837
3428
|
};
|
|
2838
|
-
const relation = await db.update(
|
|
3429
|
+
const relation = await db.update(subAgentToolRelations).set(updateData).where(
|
|
2839
3430
|
drizzleOrm.and(
|
|
2840
|
-
drizzleOrm.eq(
|
|
2841
|
-
drizzleOrm.eq(
|
|
2842
|
-
drizzleOrm.eq(
|
|
2843
|
-
drizzleOrm.eq(
|
|
3431
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3432
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3433
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3434
|
+
drizzleOrm.eq(subAgentToolRelations.id, params.relationId)
|
|
2844
3435
|
)
|
|
2845
3436
|
).returning();
|
|
2846
3437
|
return relation[0];
|
|
2847
3438
|
};
|
|
2848
3439
|
var deleteAgentToolRelation = (db) => async (params) => {
|
|
2849
|
-
const result = await db.delete(
|
|
3440
|
+
const result = await db.delete(subAgentToolRelations).where(
|
|
2850
3441
|
drizzleOrm.and(
|
|
2851
|
-
drizzleOrm.eq(
|
|
2852
|
-
drizzleOrm.eq(
|
|
2853
|
-
drizzleOrm.eq(
|
|
2854
|
-
drizzleOrm.eq(
|
|
3442
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3443
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3444
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3445
|
+
drizzleOrm.eq(subAgentToolRelations.id, params.relationId)
|
|
2855
3446
|
)
|
|
2856
3447
|
);
|
|
2857
3448
|
return (result.rowsAffected || 0) > 0;
|
|
2858
3449
|
};
|
|
2859
3450
|
var deleteAgentToolRelationByAgent = (db) => async (params) => {
|
|
2860
|
-
const result = await db.delete(
|
|
3451
|
+
const result = await db.delete(subAgentToolRelations).where(
|
|
2861
3452
|
drizzleOrm.and(
|
|
2862
|
-
drizzleOrm.eq(
|
|
2863
|
-
drizzleOrm.eq(
|
|
2864
|
-
drizzleOrm.eq(
|
|
2865
|
-
drizzleOrm.eq(
|
|
3453
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3454
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3455
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3456
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
|
|
2866
3457
|
)
|
|
2867
3458
|
);
|
|
2868
3459
|
return (result.rowsAffected || 0) > 0;
|
|
2869
3460
|
};
|
|
2870
3461
|
var getAgentToolRelationById = (db) => async (params) => {
|
|
2871
|
-
return await db.query.
|
|
3462
|
+
return await db.query.subAgentToolRelations.findFirst({
|
|
2872
3463
|
where: drizzleOrm.and(
|
|
2873
|
-
drizzleOrm.eq(
|
|
2874
|
-
drizzleOrm.eq(
|
|
2875
|
-
drizzleOrm.eq(
|
|
2876
|
-
drizzleOrm.eq(
|
|
3464
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3465
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3466
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3467
|
+
drizzleOrm.eq(subAgentToolRelations.id, params.relationId)
|
|
2877
3468
|
)
|
|
2878
3469
|
});
|
|
2879
3470
|
};
|
|
@@ -2882,18 +3473,18 @@ var getAgentToolRelationByAgent = (db) => async (params) => {
|
|
|
2882
3473
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
2883
3474
|
const offset = (page - 1) * limit;
|
|
2884
3475
|
const [data, totalResult] = await Promise.all([
|
|
2885
|
-
db.select().from(
|
|
3476
|
+
db.select().from(subAgentToolRelations).where(
|
|
2886
3477
|
drizzleOrm.and(
|
|
2887
|
-
drizzleOrm.eq(
|
|
2888
|
-
drizzleOrm.eq(
|
|
2889
|
-
drizzleOrm.eq(
|
|
3478
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3479
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3480
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
|
|
2890
3481
|
)
|
|
2891
|
-
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(
|
|
2892
|
-
db.select({ count: drizzleOrm.count() }).from(
|
|
3482
|
+
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentToolRelations.createdAt)),
|
|
3483
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentToolRelations).where(
|
|
2893
3484
|
drizzleOrm.and(
|
|
2894
|
-
drizzleOrm.eq(
|
|
2895
|
-
drizzleOrm.eq(
|
|
2896
|
-
drizzleOrm.eq(
|
|
3485
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3486
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3487
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
|
|
2897
3488
|
)
|
|
2898
3489
|
)
|
|
2899
3490
|
]);
|
|
@@ -2909,20 +3500,20 @@ var getAgentToolRelationByTool = (db) => async (params) => {
|
|
|
2909
3500
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
2910
3501
|
const offset = (page - 1) * limit;
|
|
2911
3502
|
const [data, totalResult] = await Promise.all([
|
|
2912
|
-
db.select().from(
|
|
3503
|
+
db.select().from(subAgentToolRelations).where(
|
|
2913
3504
|
drizzleOrm.and(
|
|
2914
|
-
drizzleOrm.eq(
|
|
2915
|
-
drizzleOrm.eq(
|
|
2916
|
-
drizzleOrm.eq(
|
|
2917
|
-
drizzleOrm.eq(
|
|
3505
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3506
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3507
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3508
|
+
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
2918
3509
|
)
|
|
2919
|
-
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(
|
|
2920
|
-
db.select({ count: drizzleOrm.count() }).from(
|
|
3510
|
+
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentToolRelations.createdAt)),
|
|
3511
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentToolRelations).where(
|
|
2921
3512
|
drizzleOrm.and(
|
|
2922
|
-
drizzleOrm.eq(
|
|
2923
|
-
drizzleOrm.eq(
|
|
2924
|
-
drizzleOrm.eq(
|
|
2925
|
-
drizzleOrm.eq(
|
|
3513
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3514
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3515
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3516
|
+
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
2926
3517
|
)
|
|
2927
3518
|
)
|
|
2928
3519
|
]);
|
|
@@ -2938,18 +3529,18 @@ var listAgentToolRelations = (db) => async (params) => {
|
|
|
2938
3529
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
2939
3530
|
const offset = (page - 1) * limit;
|
|
2940
3531
|
const [data, totalResult] = await Promise.all([
|
|
2941
|
-
db.select().from(
|
|
3532
|
+
db.select().from(subAgentToolRelations).where(
|
|
2942
3533
|
drizzleOrm.and(
|
|
2943
|
-
drizzleOrm.eq(
|
|
2944
|
-
drizzleOrm.eq(
|
|
2945
|
-
drizzleOrm.eq(
|
|
3534
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3535
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3536
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId)
|
|
2946
3537
|
)
|
|
2947
|
-
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(
|
|
2948
|
-
db.select({ count: drizzleOrm.count() }).from(
|
|
3538
|
+
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentToolRelations.createdAt)),
|
|
3539
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentToolRelations).where(
|
|
2949
3540
|
drizzleOrm.and(
|
|
2950
|
-
drizzleOrm.eq(
|
|
2951
|
-
drizzleOrm.eq(
|
|
2952
|
-
drizzleOrm.eq(
|
|
3541
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3542
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3543
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId)
|
|
2953
3544
|
)
|
|
2954
3545
|
)
|
|
2955
3546
|
]);
|
|
@@ -2966,14 +3557,14 @@ var getToolsForAgent = (db) => async (params) => {
|
|
|
2966
3557
|
const offset = (page - 1) * limit;
|
|
2967
3558
|
const [data, totalResult] = await Promise.all([
|
|
2968
3559
|
db.select({
|
|
2969
|
-
id:
|
|
2970
|
-
tenantId:
|
|
2971
|
-
|
|
2972
|
-
toolId:
|
|
2973
|
-
selectedTools:
|
|
2974
|
-
headers:
|
|
2975
|
-
createdAt:
|
|
2976
|
-
updatedAt:
|
|
3560
|
+
id: subAgentToolRelations.id,
|
|
3561
|
+
tenantId: subAgentToolRelations.tenantId,
|
|
3562
|
+
subAgentId: subAgentToolRelations.subAgentId,
|
|
3563
|
+
toolId: subAgentToolRelations.toolId,
|
|
3564
|
+
selectedTools: subAgentToolRelations.selectedTools,
|
|
3565
|
+
headers: subAgentToolRelations.headers,
|
|
3566
|
+
createdAt: subAgentToolRelations.createdAt,
|
|
3567
|
+
updatedAt: subAgentToolRelations.updatedAt,
|
|
2977
3568
|
tool: {
|
|
2978
3569
|
id: tools.id,
|
|
2979
3570
|
name: tools.name,
|
|
@@ -2990,27 +3581,27 @@ var getToolsForAgent = (db) => async (params) => {
|
|
|
2990
3581
|
headers: tools.headers,
|
|
2991
3582
|
imageUrl: tools.imageUrl
|
|
2992
3583
|
}
|
|
2993
|
-
}).from(
|
|
3584
|
+
}).from(subAgentToolRelations).innerJoin(
|
|
2994
3585
|
tools,
|
|
2995
3586
|
drizzleOrm.and(
|
|
2996
|
-
drizzleOrm.eq(
|
|
2997
|
-
drizzleOrm.eq(
|
|
2998
|
-
drizzleOrm.eq(
|
|
3587
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, tools.tenantId),
|
|
3588
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, tools.projectId),
|
|
3589
|
+
drizzleOrm.eq(subAgentToolRelations.toolId, tools.id)
|
|
2999
3590
|
)
|
|
3000
3591
|
).where(
|
|
3001
3592
|
drizzleOrm.and(
|
|
3002
|
-
drizzleOrm.eq(
|
|
3003
|
-
drizzleOrm.eq(
|
|
3004
|
-
drizzleOrm.eq(
|
|
3005
|
-
drizzleOrm.eq(
|
|
3593
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3594
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3595
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3596
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
|
|
3006
3597
|
)
|
|
3007
|
-
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(
|
|
3008
|
-
db.select({ count: drizzleOrm.count() }).from(
|
|
3598
|
+
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentToolRelations.createdAt)),
|
|
3599
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentToolRelations).where(
|
|
3009
3600
|
drizzleOrm.and(
|
|
3010
|
-
drizzleOrm.eq(
|
|
3011
|
-
drizzleOrm.eq(
|
|
3012
|
-
drizzleOrm.eq(
|
|
3013
|
-
drizzleOrm.eq(
|
|
3601
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3602
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3603
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3604
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
|
|
3014
3605
|
)
|
|
3015
3606
|
)
|
|
3016
3607
|
]);
|
|
@@ -3027,560 +3618,200 @@ var getAgentsForTool = (db) => async (params) => {
|
|
|
3027
3618
|
const offset = (page - 1) * limit;
|
|
3028
3619
|
const [data, totalResult] = await Promise.all([
|
|
3029
3620
|
db.select({
|
|
3030
|
-
id:
|
|
3031
|
-
tenantId:
|
|
3032
|
-
|
|
3033
|
-
toolId:
|
|
3034
|
-
selectedTools:
|
|
3035
|
-
headers:
|
|
3036
|
-
createdAt:
|
|
3037
|
-
updatedAt:
|
|
3038
|
-
|
|
3039
|
-
id:
|
|
3040
|
-
name:
|
|
3041
|
-
description:
|
|
3042
|
-
prompt:
|
|
3043
|
-
conversationHistoryConfig:
|
|
3044
|
-
models:
|
|
3045
|
-
stopWhen:
|
|
3046
|
-
createdAt:
|
|
3047
|
-
updatedAt:
|
|
3048
|
-
}
|
|
3049
|
-
}).from(
|
|
3050
|
-
|
|
3621
|
+
id: subAgentToolRelations.id,
|
|
3622
|
+
tenantId: subAgentToolRelations.tenantId,
|
|
3623
|
+
subAgentId: subAgentToolRelations.subAgentId,
|
|
3624
|
+
toolId: subAgentToolRelations.toolId,
|
|
3625
|
+
selectedTools: subAgentToolRelations.selectedTools,
|
|
3626
|
+
headers: subAgentToolRelations.headers,
|
|
3627
|
+
createdAt: subAgentToolRelations.createdAt,
|
|
3628
|
+
updatedAt: subAgentToolRelations.updatedAt,
|
|
3629
|
+
subAgent: {
|
|
3630
|
+
id: subAgents.id,
|
|
3631
|
+
name: subAgents.name,
|
|
3632
|
+
description: subAgents.description,
|
|
3633
|
+
prompt: subAgents.prompt,
|
|
3634
|
+
conversationHistoryConfig: subAgents.conversationHistoryConfig,
|
|
3635
|
+
models: subAgents.models,
|
|
3636
|
+
stopWhen: subAgents.stopWhen,
|
|
3637
|
+
createdAt: subAgents.createdAt,
|
|
3638
|
+
updatedAt: subAgents.updatedAt
|
|
3639
|
+
}
|
|
3640
|
+
}).from(subAgentToolRelations).innerJoin(
|
|
3641
|
+
subAgents,
|
|
3051
3642
|
drizzleOrm.and(
|
|
3052
|
-
drizzleOrm.eq(
|
|
3053
|
-
drizzleOrm.eq(
|
|
3054
|
-
drizzleOrm.eq(
|
|
3055
|
-
drizzleOrm.eq(
|
|
3643
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, subAgents.id),
|
|
3644
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, subAgents.tenantId),
|
|
3645
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, subAgents.projectId),
|
|
3646
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, subAgents.graphId)
|
|
3056
3647
|
)
|
|
3057
3648
|
).where(
|
|
3058
3649
|
drizzleOrm.and(
|
|
3059
|
-
drizzleOrm.eq(
|
|
3060
|
-
drizzleOrm.eq(
|
|
3061
|
-
drizzleOrm.eq(
|
|
3062
|
-
drizzleOrm.eq(
|
|
3063
|
-
)
|
|
3064
|
-
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agentToolRelations.createdAt)),
|
|
3065
|
-
db.select({ count: drizzleOrm.count() }).from(agentToolRelations).where(
|
|
3066
|
-
drizzleOrm.and(
|
|
3067
|
-
drizzleOrm.eq(agentToolRelations.tenantId, params.scopes.tenantId),
|
|
3068
|
-
drizzleOrm.eq(agentToolRelations.projectId, params.scopes.projectId),
|
|
3069
|
-
drizzleOrm.eq(agentToolRelations.graphId, params.scopes.graphId),
|
|
3070
|
-
drizzleOrm.eq(agentToolRelations.toolId, params.toolId)
|
|
3650
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3651
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3652
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3653
|
+
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
3071
3654
|
)
|
|
3072
|
-
)
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
};
|
|
3080
|
-
};
|
|
3081
|
-
var validateInternalAgent = (db) => async (params) => {
|
|
3082
|
-
const result = await db.select({ id: agents.id }).from(agents).where(
|
|
3083
|
-
drizzleOrm.and(
|
|
3084
|
-
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
3085
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
3086
|
-
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
3087
|
-
drizzleOrm.eq(agents.id, params.scopes.agentId)
|
|
3088
|
-
)
|
|
3089
|
-
).limit(1);
|
|
3090
|
-
return result.length > 0;
|
|
3091
|
-
};
|
|
3092
|
-
var validateExternalAgent = (db) => async (params) => {
|
|
3093
|
-
const result = await db.select({ id: externalAgents.id }).from(externalAgents).where(
|
|
3094
|
-
drizzleOrm.and(
|
|
3095
|
-
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3096
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3097
|
-
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
3098
|
-
drizzleOrm.eq(externalAgents.id, params.scopes.agentId)
|
|
3099
|
-
)
|
|
3100
|
-
).limit(1);
|
|
3101
|
-
return result.length > 0;
|
|
3102
|
-
};
|
|
3103
|
-
var getAgentById = (db) => async (params) => {
|
|
3104
|
-
const result = await db.query.agents.findFirst({
|
|
3105
|
-
where: drizzleOrm.and(
|
|
3106
|
-
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
3107
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
3108
|
-
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
3109
|
-
drizzleOrm.eq(agents.id, params.agentId)
|
|
3110
|
-
)
|
|
3111
|
-
});
|
|
3112
|
-
return result;
|
|
3113
|
-
};
|
|
3114
|
-
var listAgents = (db) => async (params) => {
|
|
3115
|
-
return await db.query.agents.findMany({
|
|
3116
|
-
where: drizzleOrm.and(
|
|
3117
|
-
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
3118
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
3119
|
-
drizzleOrm.eq(agents.graphId, params.scopes.graphId)
|
|
3120
|
-
)
|
|
3121
|
-
});
|
|
3122
|
-
};
|
|
3123
|
-
var listAgentsPaginated = (db) => async (params) => {
|
|
3124
|
-
const page = params.pagination?.page || 1;
|
|
3125
|
-
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
3126
|
-
const offset = (page - 1) * limit;
|
|
3127
|
-
const whereClause = drizzleOrm.and(
|
|
3128
|
-
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
3129
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
3130
|
-
drizzleOrm.eq(agents.graphId, params.scopes.graphId)
|
|
3131
|
-
);
|
|
3132
|
-
const [data, totalResult] = await Promise.all([
|
|
3133
|
-
db.select().from(agents).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agents.createdAt)),
|
|
3134
|
-
db.select({ count: drizzleOrm.count() }).from(agents).where(whereClause)
|
|
3135
|
-
]);
|
|
3136
|
-
const total = totalResult[0]?.count || 0;
|
|
3137
|
-
const pages = Math.ceil(total / limit);
|
|
3138
|
-
return {
|
|
3139
|
-
data,
|
|
3140
|
-
pagination: { page, limit, total, pages }
|
|
3141
|
-
};
|
|
3142
|
-
};
|
|
3143
|
-
var createAgent = (db) => async (params) => {
|
|
3144
|
-
const agent = await db.insert(agents).values(params).returning();
|
|
3145
|
-
return agent[0];
|
|
3146
|
-
};
|
|
3147
|
-
var updateAgent = (db) => async (params) => {
|
|
3148
|
-
const data = params.data;
|
|
3149
|
-
if (data.models !== void 0) {
|
|
3150
|
-
if (!data.models || !data.models.base?.model && !data.models.structuredOutput?.model && !data.models.summarizer?.model && !data.models.base?.providerOptions && !data.models.structuredOutput?.providerOptions && !data.models.summarizer?.providerOptions) {
|
|
3151
|
-
data.models = null;
|
|
3152
|
-
}
|
|
3153
|
-
}
|
|
3154
|
-
const updateData = {
|
|
3155
|
-
...data,
|
|
3156
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3157
|
-
};
|
|
3158
|
-
const agent = await db.update(agents).set(updateData).where(
|
|
3159
|
-
drizzleOrm.and(
|
|
3160
|
-
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
3161
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
3162
|
-
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
3163
|
-
drizzleOrm.eq(agents.id, params.agentId)
|
|
3164
|
-
)
|
|
3165
|
-
).returning();
|
|
3166
|
-
return agent[0] ?? null;
|
|
3167
|
-
};
|
|
3168
|
-
var upsertAgent = (db) => async (params) => {
|
|
3169
|
-
const scopes = {
|
|
3170
|
-
tenantId: params.data.tenantId,
|
|
3171
|
-
projectId: params.data.projectId,
|
|
3172
|
-
graphId: params.data.graphId
|
|
3173
|
-
};
|
|
3174
|
-
const existing = await getAgentById(db)({
|
|
3175
|
-
scopes,
|
|
3176
|
-
agentId: params.data.id
|
|
3177
|
-
});
|
|
3178
|
-
if (existing) {
|
|
3179
|
-
const updated = await updateAgent(db)({
|
|
3180
|
-
scopes,
|
|
3181
|
-
agentId: params.data.id,
|
|
3182
|
-
data: {
|
|
3183
|
-
name: params.data.name,
|
|
3184
|
-
description: params.data.description,
|
|
3185
|
-
prompt: params.data.prompt,
|
|
3186
|
-
conversationHistoryConfig: params.data.conversationHistoryConfig,
|
|
3187
|
-
models: params.data.models,
|
|
3188
|
-
stopWhen: params.data.stopWhen
|
|
3189
|
-
}
|
|
3190
|
-
});
|
|
3191
|
-
if (!updated) {
|
|
3192
|
-
throw new Error("Failed to update agent - no rows affected");
|
|
3193
|
-
}
|
|
3194
|
-
return updated;
|
|
3195
|
-
} else {
|
|
3196
|
-
return await createAgent(db)(params.data);
|
|
3197
|
-
}
|
|
3198
|
-
};
|
|
3199
|
-
var deleteAgent = (db) => async (params) => {
|
|
3200
|
-
await db.delete(agents).where(
|
|
3201
|
-
drizzleOrm.and(
|
|
3202
|
-
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
3203
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
3204
|
-
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
3205
|
-
drizzleOrm.eq(agents.id, params.agentId)
|
|
3206
|
-
)
|
|
3207
|
-
);
|
|
3208
|
-
const deletedAgent = await getAgentById(db)({
|
|
3209
|
-
scopes: params.scopes,
|
|
3210
|
-
agentId: params.agentId
|
|
3211
|
-
});
|
|
3212
|
-
return deletedAgent === void 0;
|
|
3213
|
-
};
|
|
3214
|
-
var getAgentsByIds = (db) => async (params) => {
|
|
3215
|
-
if (params.agentIds.length === 0) {
|
|
3216
|
-
return [];
|
|
3217
|
-
}
|
|
3218
|
-
return await db.select().from(agents).where(
|
|
3219
|
-
drizzleOrm.and(
|
|
3220
|
-
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
3221
|
-
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
3222
|
-
drizzleOrm.eq(agents.graphId, params.scopes.graphId),
|
|
3223
|
-
drizzleOrm.inArray(agents.id, params.agentIds)
|
|
3224
|
-
)
|
|
3225
|
-
);
|
|
3226
|
-
};
|
|
3227
|
-
var getContextConfigById = (db) => async (params) => {
|
|
3228
|
-
return await db.query.contextConfigs.findFirst({
|
|
3229
|
-
where: drizzleOrm.and(
|
|
3230
|
-
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
3231
|
-
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
3232
|
-
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId),
|
|
3233
|
-
drizzleOrm.eq(contextConfigs.id, params.id)
|
|
3234
|
-
)
|
|
3235
|
-
});
|
|
3236
|
-
};
|
|
3237
|
-
var listContextConfigs = (db) => async (params) => {
|
|
3238
|
-
return await db.query.contextConfigs.findMany({
|
|
3239
|
-
where: drizzleOrm.and(
|
|
3240
|
-
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
3241
|
-
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
3242
|
-
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId)
|
|
3243
|
-
),
|
|
3244
|
-
orderBy: [drizzleOrm.desc(contextConfigs.createdAt)]
|
|
3245
|
-
});
|
|
3246
|
-
};
|
|
3247
|
-
var listContextConfigsPaginated = (db) => async (params) => {
|
|
3248
|
-
const page = params.pagination?.page || 1;
|
|
3249
|
-
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
3250
|
-
const offset = (page - 1) * limit;
|
|
3251
|
-
const whereClause = drizzleOrm.and(
|
|
3252
|
-
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
3253
|
-
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
3254
|
-
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId)
|
|
3255
|
-
);
|
|
3256
|
-
const [contextConfigList, totalResult] = await Promise.all([
|
|
3257
|
-
db.select().from(contextConfigs).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(contextConfigs.createdAt)),
|
|
3258
|
-
db.select({ count: drizzleOrm.sql`COUNT(*)` }).from(contextConfigs).where(whereClause)
|
|
3259
|
-
]);
|
|
3260
|
-
const total = Number(totalResult[0]?.count || 0);
|
|
3261
|
-
const pages = Math.ceil(total / limit);
|
|
3262
|
-
return {
|
|
3263
|
-
data: contextConfigList,
|
|
3264
|
-
pagination: {
|
|
3265
|
-
page,
|
|
3266
|
-
limit,
|
|
3267
|
-
total,
|
|
3268
|
-
pages
|
|
3269
|
-
}
|
|
3270
|
-
};
|
|
3271
|
-
};
|
|
3272
|
-
var createContextConfig = (db) => async (params) => {
|
|
3273
|
-
const id = params.id || nanoid.nanoid();
|
|
3274
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3275
|
-
let contextVariables = params.contextVariables;
|
|
3276
|
-
if (contextVariables !== void 0 && contextVariables !== null && typeof contextVariables === "object" && Object.keys(contextVariables).length === 0) {
|
|
3277
|
-
contextVariables = null;
|
|
3278
|
-
}
|
|
3279
|
-
const contextConfig2 = await db.insert(contextConfigs).values({
|
|
3280
|
-
id,
|
|
3281
|
-
tenantId: params.tenantId,
|
|
3282
|
-
projectId: params.projectId,
|
|
3283
|
-
graphId: params.graphId,
|
|
3284
|
-
headersSchema: params.headersSchema ?? null,
|
|
3285
|
-
contextVariables: contextVariables ?? null,
|
|
3286
|
-
createdAt: now,
|
|
3287
|
-
updatedAt: now
|
|
3288
|
-
}).returning();
|
|
3289
|
-
return contextConfig2[0];
|
|
3290
|
-
};
|
|
3291
|
-
var updateContextConfig = (db) => async (params) => {
|
|
3292
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3293
|
-
const processedData = { ...params.data };
|
|
3294
|
-
if ("contextVariables" in params.data) {
|
|
3295
|
-
if (params.data.contextVariables === null || typeof params.data.contextVariables === "object" && params.data.contextVariables !== null && Object.keys(params.data.contextVariables).length === 0) {
|
|
3296
|
-
processedData.contextVariables = null;
|
|
3297
|
-
}
|
|
3298
|
-
}
|
|
3299
|
-
if ("headersSchema" in params.data && params.data.headersSchema === null) {
|
|
3300
|
-
processedData.headersSchema = null;
|
|
3301
|
-
}
|
|
3302
|
-
const updated = await db.update(contextConfigs).set({
|
|
3303
|
-
...processedData,
|
|
3304
|
-
updatedAt: now
|
|
3305
|
-
}).where(
|
|
3306
|
-
drizzleOrm.and(
|
|
3307
|
-
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
3308
|
-
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
3309
|
-
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId),
|
|
3310
|
-
drizzleOrm.eq(contextConfigs.id, params.id)
|
|
3311
|
-
)
|
|
3312
|
-
).returning();
|
|
3313
|
-
return updated[0];
|
|
3314
|
-
};
|
|
3315
|
-
var deleteContextConfig = (db) => async (params) => {
|
|
3316
|
-
try {
|
|
3317
|
-
const result = await db.delete(contextConfigs).where(
|
|
3318
|
-
drizzleOrm.and(
|
|
3319
|
-
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
3320
|
-
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
3321
|
-
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId),
|
|
3322
|
-
drizzleOrm.eq(contextConfigs.id, params.id)
|
|
3655
|
+
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentToolRelations.createdAt)),
|
|
3656
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentToolRelations).where(
|
|
3657
|
+
drizzleOrm.and(
|
|
3658
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
3659
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
3660
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
3661
|
+
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
3323
3662
|
)
|
|
3324
|
-
).returning();
|
|
3325
|
-
return result.length > 0;
|
|
3326
|
-
} catch (error) {
|
|
3327
|
-
console.error("Error deleting context config:", error);
|
|
3328
|
-
return false;
|
|
3329
|
-
}
|
|
3330
|
-
};
|
|
3331
|
-
var hasContextConfig = (db) => async (params) => {
|
|
3332
|
-
const contextConfig2 = await getContextConfigById(db)(params);
|
|
3333
|
-
return contextConfig2 !== null;
|
|
3334
|
-
};
|
|
3335
|
-
var countContextConfigs = (db) => async (params) => {
|
|
3336
|
-
const result = await db.select({ count: drizzleOrm.count() }).from(contextConfigs).where(
|
|
3337
|
-
drizzleOrm.and(
|
|
3338
|
-
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
3339
|
-
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
3340
|
-
drizzleOrm.eq(contextConfigs.graphId, params.scopes.graphId)
|
|
3341
3663
|
)
|
|
3342
|
-
);
|
|
3343
|
-
const total =
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
tenantId: params.data.tenantId,
|
|
3349
|
-
projectId: params.data.projectId,
|
|
3350
|
-
graphId: params.data.graphId
|
|
3664
|
+
]);
|
|
3665
|
+
const total = totalResult[0]?.count || 0;
|
|
3666
|
+
const pages = Math.ceil(total / limit);
|
|
3667
|
+
return {
|
|
3668
|
+
data,
|
|
3669
|
+
pagination: { page, limit, total, pages }
|
|
3351
3670
|
};
|
|
3352
|
-
if (params.data.id) {
|
|
3353
|
-
const existing = await getContextConfigById(db)({
|
|
3354
|
-
scopes,
|
|
3355
|
-
id: params.data.id
|
|
3356
|
-
});
|
|
3357
|
-
if (existing) {
|
|
3358
|
-
return await updateContextConfig(db)({
|
|
3359
|
-
scopes,
|
|
3360
|
-
id: params.data.id,
|
|
3361
|
-
data: {
|
|
3362
|
-
headersSchema: params.data.headersSchema,
|
|
3363
|
-
contextVariables: params.data.contextVariables
|
|
3364
|
-
}
|
|
3365
|
-
});
|
|
3366
|
-
}
|
|
3367
|
-
}
|
|
3368
|
-
return await createContextConfig(db)(params.data);
|
|
3369
3671
|
};
|
|
3370
|
-
var
|
|
3371
|
-
const
|
|
3372
|
-
|
|
3672
|
+
var validateInternalSubAgent = (db) => async (params) => {
|
|
3673
|
+
const result = await db.select({ id: subAgents.id }).from(subAgents).where(
|
|
3674
|
+
drizzleOrm.and(
|
|
3675
|
+
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
3676
|
+
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
3677
|
+
drizzleOrm.eq(subAgents.graphId, params.scopes.graphId),
|
|
3678
|
+
drizzleOrm.eq(subAgents.id, params.scopes.subAgentId)
|
|
3679
|
+
)
|
|
3680
|
+
).limit(1);
|
|
3681
|
+
return result.length > 0;
|
|
3373
3682
|
};
|
|
3374
|
-
var
|
|
3375
|
-
const result = await db.
|
|
3376
|
-
|
|
3683
|
+
var validateExternalAgent = (db) => async (params) => {
|
|
3684
|
+
const result = await db.select({ id: externalAgents.id }).from(externalAgents).where(
|
|
3685
|
+
drizzleOrm.and(
|
|
3377
3686
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3378
3687
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3379
3688
|
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
3380
|
-
drizzleOrm.eq(externalAgents.id, params.
|
|
3689
|
+
drizzleOrm.eq(externalAgents.id, params.scopes.subAgentId)
|
|
3381
3690
|
)
|
|
3382
|
-
|
|
3383
|
-
return result
|
|
3691
|
+
).limit(1);
|
|
3692
|
+
return result.length > 0;
|
|
3384
3693
|
};
|
|
3385
|
-
var
|
|
3386
|
-
const result = await db.query.
|
|
3694
|
+
var getSubAgentById = (db) => async (params) => {
|
|
3695
|
+
const result = await db.query.subAgents.findFirst({
|
|
3387
3696
|
where: drizzleOrm.and(
|
|
3388
|
-
drizzleOrm.eq(
|
|
3389
|
-
drizzleOrm.eq(
|
|
3390
|
-
drizzleOrm.eq(
|
|
3391
|
-
drizzleOrm.eq(
|
|
3697
|
+
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
3698
|
+
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
3699
|
+
drizzleOrm.eq(subAgents.graphId, params.scopes.graphId),
|
|
3700
|
+
drizzleOrm.eq(subAgents.id, params.subAgentId)
|
|
3392
3701
|
)
|
|
3393
3702
|
});
|
|
3394
|
-
return result
|
|
3703
|
+
return result;
|
|
3395
3704
|
};
|
|
3396
|
-
var
|
|
3397
|
-
return await db.query.
|
|
3705
|
+
var listSubAgents = (db) => async (params) => {
|
|
3706
|
+
return await db.query.subAgents.findMany({
|
|
3398
3707
|
where: drizzleOrm.and(
|
|
3399
|
-
drizzleOrm.eq(
|
|
3400
|
-
drizzleOrm.eq(
|
|
3401
|
-
drizzleOrm.eq(
|
|
3402
|
-
)
|
|
3403
|
-
orderBy: [drizzleOrm.asc(externalAgents.name)]
|
|
3708
|
+
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
3709
|
+
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
3710
|
+
drizzleOrm.eq(subAgents.graphId, params.scopes.graphId)
|
|
3711
|
+
)
|
|
3404
3712
|
});
|
|
3405
3713
|
};
|
|
3406
|
-
var
|
|
3714
|
+
var listSubAgentsPaginated = (db) => async (params) => {
|
|
3407
3715
|
const page = params.pagination?.page || 1;
|
|
3408
3716
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
3409
3717
|
const offset = (page - 1) * limit;
|
|
3718
|
+
const whereClause = drizzleOrm.and(
|
|
3719
|
+
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
3720
|
+
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
3721
|
+
drizzleOrm.eq(subAgents.graphId, params.scopes.graphId)
|
|
3722
|
+
);
|
|
3410
3723
|
const [data, totalResult] = await Promise.all([
|
|
3411
|
-
db.select().from(
|
|
3412
|
-
|
|
3413
|
-
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3414
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3415
|
-
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
3416
|
-
)
|
|
3417
|
-
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(externalAgents.createdAt)),
|
|
3418
|
-
db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
3419
|
-
drizzleOrm.and(
|
|
3420
|
-
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3421
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3422
|
-
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId)
|
|
3423
|
-
)
|
|
3424
|
-
)
|
|
3724
|
+
db.select().from(subAgents).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgents.createdAt)),
|
|
3725
|
+
db.select({ count: drizzleOrm.count() }).from(subAgents).where(whereClause)
|
|
3425
3726
|
]);
|
|
3426
|
-
const total =
|
|
3727
|
+
const total = totalResult[0]?.count || 0;
|
|
3427
3728
|
const pages = Math.ceil(total / limit);
|
|
3428
3729
|
return {
|
|
3429
3730
|
data,
|
|
3430
3731
|
pagination: { page, limit, total, pages }
|
|
3431
3732
|
};
|
|
3432
3733
|
};
|
|
3433
|
-
var
|
|
3734
|
+
var createSubAgent = (db) => async (params) => {
|
|
3735
|
+
const agent = await db.insert(subAgents).values(params).returning();
|
|
3736
|
+
return agent[0];
|
|
3737
|
+
};
|
|
3738
|
+
var updateSubAgent = (db) => async (params) => {
|
|
3739
|
+
const data = params.data;
|
|
3740
|
+
if (data.models !== void 0) {
|
|
3741
|
+
if (!data.models || !data.models.base?.model && !data.models.structuredOutput?.model && !data.models.summarizer?.model && !data.models.base?.providerOptions && !data.models.structuredOutput?.providerOptions && !data.models.summarizer?.providerOptions) {
|
|
3742
|
+
data.models = null;
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3434
3745
|
const updateData = {
|
|
3435
|
-
...
|
|
3746
|
+
...data,
|
|
3436
3747
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3437
3748
|
};
|
|
3438
|
-
|
|
3439
|
-
throw new Error("No fields to update");
|
|
3440
|
-
}
|
|
3441
|
-
if (updateData.headers !== void 0 && (updateData.headers === null || Object.keys(updateData.headers || {}).length === 0)) {
|
|
3442
|
-
updateData.headers = null;
|
|
3443
|
-
}
|
|
3444
|
-
if (updateData.credentialReferenceId === void 0) {
|
|
3445
|
-
updateData.credentialReferenceId = null;
|
|
3446
|
-
}
|
|
3447
|
-
const result = await db.update(externalAgents).set(updateData).where(
|
|
3749
|
+
const agent = await db.update(subAgents).set(updateData).where(
|
|
3448
3750
|
drizzleOrm.and(
|
|
3449
|
-
drizzleOrm.eq(
|
|
3450
|
-
drizzleOrm.eq(
|
|
3451
|
-
drizzleOrm.eq(
|
|
3452
|
-
drizzleOrm.eq(
|
|
3751
|
+
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
3752
|
+
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
3753
|
+
drizzleOrm.eq(subAgents.graphId, params.scopes.graphId),
|
|
3754
|
+
drizzleOrm.eq(subAgents.id, params.subAgentId)
|
|
3453
3755
|
)
|
|
3454
3756
|
).returning();
|
|
3455
|
-
return
|
|
3757
|
+
return agent[0] ?? null;
|
|
3456
3758
|
};
|
|
3457
|
-
var
|
|
3759
|
+
var upsertSubAgent = (db) => async (params) => {
|
|
3458
3760
|
const scopes = {
|
|
3459
3761
|
tenantId: params.data.tenantId,
|
|
3460
3762
|
projectId: params.data.projectId,
|
|
3461
3763
|
graphId: params.data.graphId
|
|
3462
3764
|
};
|
|
3463
|
-
const existing = await
|
|
3765
|
+
const existing = await getSubAgentById(db)({
|
|
3464
3766
|
scopes,
|
|
3465
|
-
|
|
3767
|
+
subAgentId: params.data.id
|
|
3466
3768
|
});
|
|
3467
3769
|
if (existing) {
|
|
3468
|
-
const updated = await
|
|
3770
|
+
const updated = await updateSubAgent(db)({
|
|
3469
3771
|
scopes,
|
|
3470
|
-
|
|
3772
|
+
subAgentId: params.data.id,
|
|
3471
3773
|
data: {
|
|
3472
3774
|
name: params.data.name,
|
|
3473
3775
|
description: params.data.description,
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3776
|
+
prompt: params.data.prompt,
|
|
3777
|
+
conversationHistoryConfig: params.data.conversationHistoryConfig,
|
|
3778
|
+
models: params.data.models,
|
|
3779
|
+
stopWhen: params.data.stopWhen
|
|
3477
3780
|
}
|
|
3478
3781
|
});
|
|
3479
3782
|
if (!updated) {
|
|
3480
|
-
throw new Error("Failed to update
|
|
3783
|
+
throw new Error("Failed to update agent - no rows affected");
|
|
3481
3784
|
}
|
|
3482
3785
|
return updated;
|
|
3483
3786
|
} else {
|
|
3484
|
-
return await
|
|
3485
|
-
}
|
|
3486
|
-
};
|
|
3487
|
-
var deleteExternalAgent = (db) => async (params) => {
|
|
3488
|
-
try {
|
|
3489
|
-
const result = await db.delete(externalAgents).where(
|
|
3490
|
-
drizzleOrm.and(
|
|
3491
|
-
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
3492
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
3493
|
-
drizzleOrm.eq(externalAgents.graphId, params.scopes.graphId),
|
|
3494
|
-
drizzleOrm.eq(externalAgents.id, params.agentId)
|
|
3495
|
-
)
|
|
3496
|
-
).returning();
|
|
3497
|
-
return result.length > 0;
|
|
3498
|
-
} catch (error) {
|
|
3499
|
-
console.error("Error deleting external agent:", error);
|
|
3500
|
-
return false;
|
|
3787
|
+
return await createSubAgent(db)(params.data);
|
|
3501
3788
|
}
|
|
3502
3789
|
};
|
|
3503
|
-
var
|
|
3504
|
-
|
|
3505
|
-
return agent !== null;
|
|
3506
|
-
};
|
|
3507
|
-
var externalAgentUrlExists = (db) => async (params) => {
|
|
3508
|
-
const agent = await getExternalAgentByUrl(db)(params);
|
|
3509
|
-
return agent !== null;
|
|
3510
|
-
};
|
|
3511
|
-
var countExternalAgents = (db) => async (params) => {
|
|
3512
|
-
const result = await db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
3790
|
+
var deleteSubAgent = (db) => async (params) => {
|
|
3791
|
+
await db.delete(subAgents).where(
|
|
3513
3792
|
drizzleOrm.and(
|
|
3514
|
-
drizzleOrm.eq(
|
|
3515
|
-
drizzleOrm.eq(
|
|
3516
|
-
drizzleOrm.eq(
|
|
3793
|
+
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
3794
|
+
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
3795
|
+
drizzleOrm.eq(subAgents.graphId, params.scopes.graphId),
|
|
3796
|
+
drizzleOrm.eq(subAgents.id, params.subAgentId)
|
|
3517
3797
|
)
|
|
3518
3798
|
);
|
|
3519
|
-
const
|
|
3520
|
-
|
|
3799
|
+
const deletedSubAgent = await getSubAgentById(db)({
|
|
3800
|
+
scopes: params.scopes,
|
|
3801
|
+
subAgentId: params.subAgentId
|
|
3802
|
+
});
|
|
3803
|
+
return deletedSubAgent === void 0;
|
|
3521
3804
|
};
|
|
3522
|
-
var
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
const existingFunction = await db.select().from(functions).where(
|
|
3526
|
-
drizzleOrm.and(
|
|
3527
|
-
drizzleOrm.eq(functions.tenantId, tenantId),
|
|
3528
|
-
drizzleOrm.eq(functions.projectId, projectId),
|
|
3529
|
-
drizzleOrm.eq(functions.id, data.id)
|
|
3530
|
-
)
|
|
3531
|
-
).limit(1);
|
|
3532
|
-
if (existingFunction.length > 0) {
|
|
3533
|
-
await db.update(functions).set({
|
|
3534
|
-
inputSchema: data.inputSchema,
|
|
3535
|
-
executeCode: data.executeCode,
|
|
3536
|
-
dependencies: data.dependencies,
|
|
3537
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3538
|
-
}).where(
|
|
3539
|
-
drizzleOrm.and(
|
|
3540
|
-
drizzleOrm.eq(functions.tenantId, tenantId),
|
|
3541
|
-
drizzleOrm.eq(functions.projectId, projectId),
|
|
3542
|
-
drizzleOrm.eq(functions.id, data.id)
|
|
3543
|
-
)
|
|
3544
|
-
);
|
|
3545
|
-
} else {
|
|
3546
|
-
await db.insert(functions).values({
|
|
3547
|
-
tenantId,
|
|
3548
|
-
projectId,
|
|
3549
|
-
id: data.id,
|
|
3550
|
-
inputSchema: data.inputSchema,
|
|
3551
|
-
executeCode: data.executeCode,
|
|
3552
|
-
dependencies: data.dependencies,
|
|
3553
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3554
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3555
|
-
});
|
|
3805
|
+
var getSubAgentsByIds = (db) => async (params) => {
|
|
3806
|
+
if (params.subAgentIds.length === 0) {
|
|
3807
|
+
return [];
|
|
3556
3808
|
}
|
|
3557
|
-
|
|
3558
|
-
var getFunction = (db) => async (params) => {
|
|
3559
|
-
const { functionId, scopes } = params;
|
|
3560
|
-
const { tenantId, projectId } = scopes;
|
|
3561
|
-
const result = await db.select().from(functions).where(
|
|
3562
|
-
drizzleOrm.and(
|
|
3563
|
-
drizzleOrm.eq(functions.tenantId, tenantId),
|
|
3564
|
-
drizzleOrm.eq(functions.projectId, projectId),
|
|
3565
|
-
drizzleOrm.eq(functions.id, functionId)
|
|
3566
|
-
)
|
|
3567
|
-
).limit(1);
|
|
3568
|
-
return result[0] || null;
|
|
3569
|
-
};
|
|
3570
|
-
var listFunctions = (db) => async (params) => {
|
|
3571
|
-
const { scopes } = params;
|
|
3572
|
-
const { tenantId, projectId } = scopes;
|
|
3573
|
-
const result = await db.select().from(functions).where(drizzleOrm.and(drizzleOrm.eq(functions.tenantId, tenantId), drizzleOrm.eq(functions.projectId, projectId)));
|
|
3574
|
-
return result;
|
|
3575
|
-
};
|
|
3576
|
-
var deleteFunction = (db) => async (params) => {
|
|
3577
|
-
const { functionId, scopes } = params;
|
|
3578
|
-
const { tenantId, projectId } = scopes;
|
|
3579
|
-
await db.delete(functions).where(
|
|
3809
|
+
return await db.select().from(subAgents).where(
|
|
3580
3810
|
drizzleOrm.and(
|
|
3581
|
-
drizzleOrm.eq(
|
|
3582
|
-
drizzleOrm.eq(
|
|
3583
|
-
drizzleOrm.eq(
|
|
3811
|
+
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
3812
|
+
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
3813
|
+
drizzleOrm.eq(subAgents.graphId, params.scopes.graphId),
|
|
3814
|
+
drizzleOrm.inArray(subAgents.id, params.subAgentIds)
|
|
3584
3815
|
)
|
|
3585
3816
|
);
|
|
3586
3817
|
};
|
|
@@ -4661,12 +4892,12 @@ var deleteTool = (db) => async (params) => {
|
|
|
4661
4892
|
var addToolToAgent = (db) => async (params) => {
|
|
4662
4893
|
const id = nanoid.nanoid();
|
|
4663
4894
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4664
|
-
const [created] = await db.insert(
|
|
4895
|
+
const [created] = await db.insert(subAgentToolRelations).values({
|
|
4665
4896
|
id,
|
|
4666
4897
|
tenantId: params.scopes.tenantId,
|
|
4667
4898
|
projectId: params.scopes.projectId,
|
|
4668
4899
|
graphId: params.scopes.graphId,
|
|
4669
|
-
|
|
4900
|
+
subAgentId: params.subAgentId,
|
|
4670
4901
|
toolId: params.toolId,
|
|
4671
4902
|
selectedTools: params.selectedTools,
|
|
4672
4903
|
headers: params.headers,
|
|
@@ -4676,13 +4907,13 @@ var addToolToAgent = (db) => async (params) => {
|
|
|
4676
4907
|
return created;
|
|
4677
4908
|
};
|
|
4678
4909
|
var removeToolFromAgent = (db) => async (params) => {
|
|
4679
|
-
const [deleted] = await db.delete(
|
|
4910
|
+
const [deleted] = await db.delete(subAgentToolRelations).where(
|
|
4680
4911
|
drizzleOrm.and(
|
|
4681
|
-
drizzleOrm.eq(
|
|
4682
|
-
drizzleOrm.eq(
|
|
4683
|
-
drizzleOrm.eq(
|
|
4684
|
-
drizzleOrm.eq(
|
|
4685
|
-
drizzleOrm.eq(
|
|
4912
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
4913
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
4914
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, params.scopes.graphId),
|
|
4915
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.subAgentId),
|
|
4916
|
+
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
4686
4917
|
)
|
|
4687
4918
|
).returning();
|
|
4688
4919
|
return deleted;
|
|
@@ -4693,7 +4924,7 @@ var upsertAgentToolRelation = (db) => async (params) => {
|
|
|
4693
4924
|
scopes: params.scopes,
|
|
4694
4925
|
relationId: params.relationId,
|
|
4695
4926
|
data: {
|
|
4696
|
-
|
|
4927
|
+
subAgentId: params.subAgentId,
|
|
4697
4928
|
toolId: params.toolId,
|
|
4698
4929
|
selectedTools: params.selectedTools,
|
|
4699
4930
|
headers: params.headers
|
|
@@ -4736,7 +4967,7 @@ var getAgentGraphById = (db) => async (params) => {
|
|
|
4736
4967
|
});
|
|
4737
4968
|
return result ?? null;
|
|
4738
4969
|
};
|
|
4739
|
-
var
|
|
4970
|
+
var getAgentGraphWithDefaultSubAgent = (db) => async (params) => {
|
|
4740
4971
|
const result = await db.query.agentGraph.findFirst({
|
|
4741
4972
|
where: drizzleOrm.and(
|
|
4742
4973
|
drizzleOrm.eq(agentGraph.tenantId, params.scopes.tenantId),
|
|
@@ -4744,7 +4975,7 @@ var getAgentGraphWithDefaultAgent = (db) => async (params) => {
|
|
|
4744
4975
|
drizzleOrm.eq(agentGraph.id, params.scopes.graphId)
|
|
4745
4976
|
),
|
|
4746
4977
|
with: {
|
|
4747
|
-
|
|
4978
|
+
defaultSubAgent: true
|
|
4748
4979
|
}
|
|
4749
4980
|
});
|
|
4750
4981
|
return result ?? null;
|
|
@@ -4849,14 +5080,14 @@ var deleteAgentGraph = (db) => async (params) => {
|
|
|
4849
5080
|
).returning();
|
|
4850
5081
|
return result.length > 0;
|
|
4851
5082
|
};
|
|
4852
|
-
var fetchComponentRelationships = (db) => async (scopes,
|
|
5083
|
+
var fetchComponentRelationships = (db) => async (scopes, subAgentIds, config) => {
|
|
4853
5084
|
const componentsObject = {};
|
|
4854
|
-
if (
|
|
5085
|
+
if (subAgentIds.length > 0) {
|
|
4855
5086
|
const results = await db.select(config.selectFields).from(config.relationTable).innerJoin(config.componentTable, drizzleOrm.eq(config.relationIdField, config.componentIdField)).where(
|
|
4856
5087
|
drizzleOrm.and(
|
|
4857
5088
|
drizzleOrm.eq(config.relationTable.tenantId, scopes.tenantId),
|
|
4858
5089
|
drizzleOrm.eq(config.relationTable.projectId, scopes.projectId),
|
|
4859
|
-
drizzleOrm.inArray(config.
|
|
5090
|
+
drizzleOrm.inArray(config.subAgentIdField, subAgentIds)
|
|
4860
5091
|
)
|
|
4861
5092
|
);
|
|
4862
5093
|
for (const component of results) {
|
|
@@ -4868,7 +5099,7 @@ var fetchComponentRelationships = (db) => async (scopes, agentIds, config) => {
|
|
|
4868
5099
|
var getGraphAgentInfos = (db) => async ({
|
|
4869
5100
|
scopes,
|
|
4870
5101
|
graphId,
|
|
4871
|
-
|
|
5102
|
+
subAgentId
|
|
4872
5103
|
}) => {
|
|
4873
5104
|
const { tenantId, projectId } = scopes;
|
|
4874
5105
|
const graph = await getAgentGraphById(db)({
|
|
@@ -4878,17 +5109,17 @@ var getGraphAgentInfos = (db) => async ({
|
|
|
4878
5109
|
throw new Error(`Agent graph with ID ${graphId} not found for tenant ${tenantId}`);
|
|
4879
5110
|
}
|
|
4880
5111
|
const relations2 = await getAgentRelations(db)({
|
|
4881
|
-
scopes: { tenantId, projectId, graphId,
|
|
5112
|
+
scopes: { tenantId, projectId, graphId, subAgentId }
|
|
4882
5113
|
});
|
|
4883
|
-
const
|
|
4884
|
-
if (
|
|
5114
|
+
const targetSubAgentIds = relations2.map((relation) => relation.targetSubAgentId).filter((id) => id !== null);
|
|
5115
|
+
if (targetSubAgentIds.length === 0) {
|
|
4885
5116
|
return [];
|
|
4886
5117
|
}
|
|
4887
5118
|
const agentInfos = await Promise.all(
|
|
4888
|
-
|
|
4889
|
-
const agent = await
|
|
5119
|
+
targetSubAgentIds.map(async (subAgentId2) => {
|
|
5120
|
+
const agent = await getSubAgentById(db)({
|
|
4890
5121
|
scopes: { tenantId, projectId, graphId },
|
|
4891
|
-
|
|
5122
|
+
subAgentId: subAgentId2
|
|
4892
5123
|
});
|
|
4893
5124
|
if (agent !== void 0) {
|
|
4894
5125
|
return { id: agent.id, name: agent.name, description: agent.description };
|
|
@@ -4910,28 +5141,28 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
4910
5141
|
const graphRelations = await getAgentRelationsByGraph(db)({
|
|
4911
5142
|
scopes: { tenantId, projectId, graphId }
|
|
4912
5143
|
});
|
|
4913
|
-
const
|
|
5144
|
+
const graphSubAgents = await db.query.subAgents.findMany({
|
|
4914
5145
|
where: drizzleOrm.and(
|
|
4915
|
-
drizzleOrm.eq(
|
|
4916
|
-
drizzleOrm.eq(
|
|
4917
|
-
drizzleOrm.eq(
|
|
5146
|
+
drizzleOrm.eq(subAgents.tenantId, tenantId),
|
|
5147
|
+
drizzleOrm.eq(subAgents.projectId, projectId),
|
|
5148
|
+
drizzleOrm.eq(subAgents.graphId, graphId)
|
|
4918
5149
|
)
|
|
4919
5150
|
});
|
|
4920
|
-
const
|
|
5151
|
+
const externalSubAgentIds = /* @__PURE__ */ new Set();
|
|
4921
5152
|
for (const relation of graphRelations) {
|
|
4922
|
-
if (relation.
|
|
4923
|
-
|
|
5153
|
+
if (relation.externalSubAgentId) {
|
|
5154
|
+
externalSubAgentIds.add(relation.externalSubAgentId);
|
|
4924
5155
|
}
|
|
4925
5156
|
}
|
|
4926
|
-
const
|
|
4927
|
-
|
|
5157
|
+
const processedSubAgents = await Promise.all(
|
|
5158
|
+
graphSubAgents.map(async (agent) => {
|
|
4928
5159
|
if (!agent) return null;
|
|
4929
|
-
const
|
|
4930
|
-
(relation) => relation.
|
|
5160
|
+
const subAgentRelationsList = graphRelations.filter(
|
|
5161
|
+
(relation) => relation.sourceSubAgentId === agent.id
|
|
4931
5162
|
);
|
|
4932
|
-
const canTransferTo =
|
|
4933
|
-
const canDelegateTo =
|
|
4934
|
-
const
|
|
5163
|
+
const canTransferTo = subAgentRelationsList.filter((rel) => rel.relationType === "transfer" || rel.relationType === "transfer_to").map((rel) => rel.targetSubAgentId).filter((id) => id !== null);
|
|
5164
|
+
const canDelegateTo = subAgentRelationsList.filter((rel) => rel.relationType === "delegate" || rel.relationType === "delegate_to").map((rel) => rel.targetSubAgentId || rel.externalSubAgentId).filter((id) => id !== null);
|
|
5165
|
+
const subAgentTools = await db.select({
|
|
4935
5166
|
id: tools.id,
|
|
4936
5167
|
name: tools.name,
|
|
4937
5168
|
config: tools.config,
|
|
@@ -4943,41 +5174,41 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
4943
5174
|
tenantId: tools.tenantId,
|
|
4944
5175
|
projectId: tools.projectId,
|
|
4945
5176
|
imageUrl: tools.imageUrl,
|
|
4946
|
-
selectedTools:
|
|
4947
|
-
headers:
|
|
4948
|
-
agentToolRelationId:
|
|
4949
|
-
}).from(
|
|
5177
|
+
selectedTools: subAgentToolRelations.selectedTools,
|
|
5178
|
+
headers: subAgentToolRelations.headers,
|
|
5179
|
+
agentToolRelationId: subAgentToolRelations.id
|
|
5180
|
+
}).from(subAgentToolRelations).innerJoin(
|
|
4950
5181
|
tools,
|
|
4951
5182
|
drizzleOrm.and(
|
|
4952
|
-
drizzleOrm.eq(
|
|
4953
|
-
drizzleOrm.eq(
|
|
4954
|
-
drizzleOrm.eq(
|
|
5183
|
+
drizzleOrm.eq(subAgentToolRelations.toolId, tools.id),
|
|
5184
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, tools.tenantId),
|
|
5185
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, tools.projectId)
|
|
4955
5186
|
)
|
|
4956
5187
|
).where(
|
|
4957
5188
|
drizzleOrm.and(
|
|
4958
|
-
drizzleOrm.eq(
|
|
4959
|
-
drizzleOrm.eq(
|
|
4960
|
-
drizzleOrm.eq(
|
|
4961
|
-
drizzleOrm.eq(
|
|
5189
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, tenantId),
|
|
5190
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, projectId),
|
|
5191
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, graphId),
|
|
5192
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, agent.id)
|
|
4962
5193
|
)
|
|
4963
5194
|
);
|
|
4964
|
-
const agentDataComponentRelations = await db.query.
|
|
5195
|
+
const agentDataComponentRelations = await db.query.subAgentDataComponents.findMany({
|
|
4965
5196
|
where: drizzleOrm.and(
|
|
4966
|
-
drizzleOrm.eq(
|
|
4967
|
-
drizzleOrm.eq(
|
|
5197
|
+
drizzleOrm.eq(subAgentDataComponents.tenantId, tenantId),
|
|
5198
|
+
drizzleOrm.eq(subAgentDataComponents.subAgentId, agent.id)
|
|
4968
5199
|
)
|
|
4969
5200
|
});
|
|
4970
5201
|
const agentDataComponentIds = agentDataComponentRelations.map((rel) => rel.dataComponentId);
|
|
4971
|
-
const agentArtifactComponentRelations = await db.query.
|
|
5202
|
+
const agentArtifactComponentRelations = await db.query.subAgentArtifactComponents.findMany({
|
|
4972
5203
|
where: drizzleOrm.and(
|
|
4973
|
-
drizzleOrm.eq(
|
|
4974
|
-
drizzleOrm.eq(
|
|
5204
|
+
drizzleOrm.eq(subAgentArtifactComponents.tenantId, tenantId),
|
|
5205
|
+
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, agent.id)
|
|
4975
5206
|
)
|
|
4976
5207
|
});
|
|
4977
5208
|
const agentArtifactComponentIds = agentArtifactComponentRelations.map(
|
|
4978
5209
|
(rel) => rel.artifactComponentId
|
|
4979
5210
|
);
|
|
4980
|
-
const canUse =
|
|
5211
|
+
const canUse = subAgentTools.map((tool2) => ({
|
|
4981
5212
|
agentToolRelationId: tool2.agentToolRelationId,
|
|
4982
5213
|
toolId: tool2.id,
|
|
4983
5214
|
toolSelection: tool2.selectedTools || null,
|
|
@@ -4999,24 +5230,24 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
4999
5230
|
})
|
|
5000
5231
|
);
|
|
5001
5232
|
const externalAgents2 = await Promise.all(
|
|
5002
|
-
Array.from(
|
|
5003
|
-
const
|
|
5233
|
+
Array.from(externalSubAgentIds).map(async (subAgentId) => {
|
|
5234
|
+
const subAgent = await getExternalAgent(db)({
|
|
5004
5235
|
scopes: { tenantId, projectId, graphId },
|
|
5005
|
-
|
|
5236
|
+
subAgentId
|
|
5006
5237
|
});
|
|
5007
|
-
if (!
|
|
5238
|
+
if (!subAgent) return null;
|
|
5008
5239
|
return {
|
|
5009
|
-
id:
|
|
5010
|
-
name:
|
|
5011
|
-
description:
|
|
5012
|
-
baseUrl:
|
|
5013
|
-
headers:
|
|
5014
|
-
credentialReferenceId:
|
|
5240
|
+
id: subAgent.id,
|
|
5241
|
+
name: subAgent.name,
|
|
5242
|
+
description: subAgent.description,
|
|
5243
|
+
baseUrl: subAgent.baseUrl,
|
|
5244
|
+
headers: subAgent.headers,
|
|
5245
|
+
credentialReferenceId: subAgent.credentialReferenceId,
|
|
5015
5246
|
type: "external"
|
|
5016
5247
|
};
|
|
5017
5248
|
})
|
|
5018
5249
|
);
|
|
5019
|
-
const validAgents = [...
|
|
5250
|
+
const validAgents = [...processedSubAgents, ...externalAgents2].filter(
|
|
5020
5251
|
(agent) => agent !== null
|
|
5021
5252
|
);
|
|
5022
5253
|
const agentsObject = {};
|
|
@@ -5048,13 +5279,14 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
5048
5279
|
}
|
|
5049
5280
|
}
|
|
5050
5281
|
try {
|
|
5051
|
-
const internalAgentIds =
|
|
5052
|
-
const
|
|
5053
|
-
await fetchComponentRelationships(db)({ tenantId, projectId },
|
|
5054
|
-
relationTable:
|
|
5282
|
+
const internalAgentIds = graphSubAgents.map((agent) => agent.id);
|
|
5283
|
+
const subAgentIds = Array.from(internalAgentIds);
|
|
5284
|
+
await fetchComponentRelationships(db)({ tenantId, projectId }, subAgentIds, {
|
|
5285
|
+
relationTable: subAgentDataComponents,
|
|
5055
5286
|
componentTable: dataComponents,
|
|
5056
|
-
relationIdField:
|
|
5287
|
+
relationIdField: subAgentDataComponents.dataComponentId,
|
|
5057
5288
|
componentIdField: dataComponents.id,
|
|
5289
|
+
subAgentIdField: subAgentDataComponents.subAgentId,
|
|
5058
5290
|
selectFields: {
|
|
5059
5291
|
id: dataComponents.id,
|
|
5060
5292
|
name: dataComponents.name,
|
|
@@ -5066,13 +5298,14 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
5066
5298
|
console.warn("Failed to retrieve dataComponents:", error);
|
|
5067
5299
|
}
|
|
5068
5300
|
try {
|
|
5069
|
-
const internalAgentIds =
|
|
5070
|
-
const
|
|
5071
|
-
await fetchComponentRelationships(db)({ tenantId, projectId },
|
|
5072
|
-
relationTable:
|
|
5301
|
+
const internalAgentIds = graphSubAgents.map((agent) => agent.id);
|
|
5302
|
+
const subAgentIds = Array.from(internalAgentIds);
|
|
5303
|
+
await fetchComponentRelationships(db)({ tenantId, projectId }, subAgentIds, {
|
|
5304
|
+
relationTable: subAgentArtifactComponents,
|
|
5073
5305
|
componentTable: artifactComponents,
|
|
5074
|
-
relationIdField:
|
|
5306
|
+
relationIdField: subAgentArtifactComponents.artifactComponentId,
|
|
5075
5307
|
componentIdField: artifactComponents.id,
|
|
5308
|
+
subAgentIdField: subAgentArtifactComponents.subAgentId,
|
|
5076
5309
|
selectFields: {
|
|
5077
5310
|
id: artifactComponents.id,
|
|
5078
5311
|
name: artifactComponents.name,
|
|
@@ -5087,8 +5320,8 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
5087
5320
|
id: graph.id,
|
|
5088
5321
|
name: graph.name,
|
|
5089
5322
|
description: graph.description,
|
|
5090
|
-
|
|
5091
|
-
|
|
5323
|
+
defaultSubAgentId: graph.defaultSubAgentId,
|
|
5324
|
+
subAgents: agentsObject,
|
|
5092
5325
|
// No tools field - tools are defined at project level
|
|
5093
5326
|
createdAt: graph.createdAt && !Number.isNaN(new Date(graph.createdAt).getTime()) ? new Date(graph.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
5094
5327
|
updatedAt: graph.updatedAt && !Number.isNaN(new Date(graph.updatedAt).getTime()) ? new Date(graph.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -5122,7 +5355,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
5122
5355
|
if (project?.stopWhen) {
|
|
5123
5356
|
const projectStopWhen = project.stopWhen;
|
|
5124
5357
|
if (projectStopWhen?.stepCountIs !== void 0) {
|
|
5125
|
-
for (const [
|
|
5358
|
+
for (const [subAgentId, agentData] of Object.entries(result.subAgents)) {
|
|
5126
5359
|
if (agentData && typeof agentData === "object" && !("baseUrl" in agentData)) {
|
|
5127
5360
|
const agent = agentData;
|
|
5128
5361
|
const needsInheritance = !agent.stopWhen || agent.stopWhen.stepCountIs === void 0;
|
|
@@ -5132,22 +5365,22 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
5132
5365
|
}
|
|
5133
5366
|
agent.stopWhen.stepCountIs = projectStopWhen.stepCountIs;
|
|
5134
5367
|
try {
|
|
5135
|
-
await db.update(
|
|
5368
|
+
await db.update(subAgents).set({
|
|
5136
5369
|
stopWhen: agent.stopWhen,
|
|
5137
5370
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5138
5371
|
}).where(
|
|
5139
5372
|
drizzleOrm.and(
|
|
5140
|
-
drizzleOrm.eq(
|
|
5141
|
-
drizzleOrm.eq(
|
|
5142
|
-
drizzleOrm.eq(
|
|
5373
|
+
drizzleOrm.eq(subAgents.tenantId, tenantId),
|
|
5374
|
+
drizzleOrm.eq(subAgents.projectId, projectId),
|
|
5375
|
+
drizzleOrm.eq(subAgents.id, subAgentId)
|
|
5143
5376
|
)
|
|
5144
5377
|
);
|
|
5145
|
-
result.
|
|
5146
|
-
...result.
|
|
5378
|
+
result.subAgents[subAgentId] = {
|
|
5379
|
+
...result.subAgents[subAgentId],
|
|
5147
5380
|
stopWhen: agent.stopWhen
|
|
5148
5381
|
};
|
|
5149
5382
|
} catch (dbError) {
|
|
5150
|
-
console.warn(`Failed to persist stopWhen for agent ${
|
|
5383
|
+
console.warn(`Failed to persist stopWhen for agent ${subAgentId}:`, dbError);
|
|
5151
5384
|
}
|
|
5152
5385
|
}
|
|
5153
5386
|
}
|
|
@@ -5215,7 +5448,7 @@ var upsertAgentGraph = (db) => async (params) => {
|
|
|
5215
5448
|
scopes,
|
|
5216
5449
|
data: {
|
|
5217
5450
|
name: params.data.name,
|
|
5218
|
-
|
|
5451
|
+
defaultSubAgentId: params.data.defaultSubAgentId,
|
|
5219
5452
|
description: params.data.description,
|
|
5220
5453
|
contextConfigId: params.data.contextConfigId,
|
|
5221
5454
|
models: params.data.models,
|
|
@@ -5597,24 +5830,24 @@ var getArtifactComponentsForAgent = (db) => async (params) => {
|
|
|
5597
5830
|
createdAt: artifactComponents.createdAt,
|
|
5598
5831
|
updatedAt: artifactComponents.updatedAt
|
|
5599
5832
|
}).from(artifactComponents).innerJoin(
|
|
5600
|
-
|
|
5601
|
-
drizzleOrm.eq(artifactComponents.id,
|
|
5833
|
+
subAgentArtifactComponents,
|
|
5834
|
+
drizzleOrm.eq(artifactComponents.id, subAgentArtifactComponents.artifactComponentId)
|
|
5602
5835
|
).where(
|
|
5603
5836
|
drizzleOrm.and(
|
|
5604
5837
|
drizzleOrm.eq(artifactComponents.tenantId, params.scopes.tenantId),
|
|
5605
5838
|
drizzleOrm.eq(artifactComponents.projectId, params.scopes.projectId),
|
|
5606
|
-
drizzleOrm.eq(
|
|
5607
|
-
drizzleOrm.eq(
|
|
5839
|
+
drizzleOrm.eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
|
|
5840
|
+
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
|
|
5608
5841
|
)
|
|
5609
5842
|
).orderBy(drizzleOrm.desc(artifactComponents.createdAt));
|
|
5610
5843
|
};
|
|
5611
5844
|
var associateArtifactComponentWithAgent = (db) => async (params) => {
|
|
5612
|
-
const [association] = await db.insert(
|
|
5845
|
+
const [association] = await db.insert(subAgentArtifactComponents).values({
|
|
5613
5846
|
id: nanoid.nanoid(),
|
|
5614
5847
|
tenantId: params.scopes.tenantId,
|
|
5615
5848
|
projectId: params.scopes.projectId,
|
|
5616
5849
|
graphId: params.scopes.graphId,
|
|
5617
|
-
|
|
5850
|
+
subAgentId: params.scopes.subAgentId,
|
|
5618
5851
|
artifactComponentId: params.artifactComponentId,
|
|
5619
5852
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5620
5853
|
}).returning();
|
|
@@ -5622,13 +5855,13 @@ var associateArtifactComponentWithAgent = (db) => async (params) => {
|
|
|
5622
5855
|
};
|
|
5623
5856
|
var removeArtifactComponentFromAgent = (db) => async (params) => {
|
|
5624
5857
|
try {
|
|
5625
|
-
const result = await db.delete(
|
|
5858
|
+
const result = await db.delete(subAgentArtifactComponents).where(
|
|
5626
5859
|
drizzleOrm.and(
|
|
5627
|
-
drizzleOrm.eq(
|
|
5628
|
-
drizzleOrm.eq(
|
|
5629
|
-
drizzleOrm.eq(
|
|
5630
|
-
drizzleOrm.eq(
|
|
5631
|
-
drizzleOrm.eq(
|
|
5860
|
+
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
5861
|
+
drizzleOrm.eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
|
|
5862
|
+
drizzleOrm.eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
|
|
5863
|
+
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId),
|
|
5864
|
+
drizzleOrm.eq(subAgentArtifactComponents.artifactComponentId, params.artifactComponentId)
|
|
5632
5865
|
)
|
|
5633
5866
|
).returning();
|
|
5634
5867
|
return result.length > 0;
|
|
@@ -5638,60 +5871,60 @@ var removeArtifactComponentFromAgent = (db) => async (params) => {
|
|
|
5638
5871
|
}
|
|
5639
5872
|
};
|
|
5640
5873
|
var deleteAgentArtifactComponentRelationByAgent = (db) => async (params) => {
|
|
5641
|
-
const result = await db.delete(
|
|
5874
|
+
const result = await db.delete(subAgentArtifactComponents).where(
|
|
5642
5875
|
drizzleOrm.and(
|
|
5643
|
-
drizzleOrm.eq(
|
|
5644
|
-
drizzleOrm.eq(
|
|
5645
|
-
drizzleOrm.eq(
|
|
5876
|
+
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
5877
|
+
drizzleOrm.eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
|
|
5878
|
+
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
|
|
5646
5879
|
)
|
|
5647
5880
|
);
|
|
5648
5881
|
return (result.rowsAffected || 0) > 0;
|
|
5649
5882
|
};
|
|
5650
5883
|
var getAgentsUsingArtifactComponent = (db) => async (params) => {
|
|
5651
5884
|
return await db.select({
|
|
5652
|
-
graphId:
|
|
5653
|
-
|
|
5654
|
-
createdAt:
|
|
5655
|
-
}).from(
|
|
5885
|
+
graphId: subAgentArtifactComponents.graphId,
|
|
5886
|
+
subAgentId: subAgentArtifactComponents.subAgentId,
|
|
5887
|
+
createdAt: subAgentArtifactComponents.createdAt
|
|
5888
|
+
}).from(subAgentArtifactComponents).where(
|
|
5656
5889
|
drizzleOrm.and(
|
|
5657
|
-
drizzleOrm.eq(
|
|
5658
|
-
drizzleOrm.eq(
|
|
5659
|
-
drizzleOrm.eq(
|
|
5890
|
+
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
5891
|
+
drizzleOrm.eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
|
|
5892
|
+
drizzleOrm.eq(subAgentArtifactComponents.artifactComponentId, params.artifactComponentId)
|
|
5660
5893
|
)
|
|
5661
|
-
).orderBy(drizzleOrm.desc(
|
|
5894
|
+
).orderBy(drizzleOrm.desc(subAgentArtifactComponents.createdAt));
|
|
5662
5895
|
};
|
|
5663
5896
|
var isArtifactComponentAssociatedWithAgent = (db) => async (params) => {
|
|
5664
|
-
const result = await db.select({ id:
|
|
5897
|
+
const result = await db.select({ id: subAgentArtifactComponents.id }).from(subAgentArtifactComponents).where(
|
|
5665
5898
|
drizzleOrm.and(
|
|
5666
|
-
drizzleOrm.eq(
|
|
5667
|
-
drizzleOrm.eq(
|
|
5668
|
-
drizzleOrm.eq(
|
|
5669
|
-
drizzleOrm.eq(
|
|
5670
|
-
drizzleOrm.eq(
|
|
5899
|
+
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
5900
|
+
drizzleOrm.eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
|
|
5901
|
+
drizzleOrm.eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
|
|
5902
|
+
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId),
|
|
5903
|
+
drizzleOrm.eq(subAgentArtifactComponents.artifactComponentId, params.artifactComponentId)
|
|
5671
5904
|
)
|
|
5672
5905
|
).limit(1);
|
|
5673
5906
|
return result.length > 0;
|
|
5674
5907
|
};
|
|
5675
5908
|
var graphHasArtifactComponents = (db) => async (params) => {
|
|
5676
|
-
const result = await db.select({ count: drizzleOrm.count() }).from(
|
|
5677
|
-
|
|
5909
|
+
const result = await db.select({ count: drizzleOrm.count() }).from(subAgentArtifactComponents).innerJoin(
|
|
5910
|
+
subAgents,
|
|
5678
5911
|
drizzleOrm.and(
|
|
5679
|
-
drizzleOrm.eq(
|
|
5680
|
-
drizzleOrm.eq(
|
|
5912
|
+
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, subAgents.id),
|
|
5913
|
+
drizzleOrm.eq(subAgentArtifactComponents.tenantId, subAgents.tenantId)
|
|
5681
5914
|
)
|
|
5682
5915
|
).innerJoin(
|
|
5683
|
-
|
|
5916
|
+
subAgentRelations,
|
|
5684
5917
|
drizzleOrm.and(
|
|
5685
|
-
drizzleOrm.eq(
|
|
5686
|
-
drizzleOrm.eq(
|
|
5687
|
-
drizzleOrm.eq(
|
|
5688
|
-
drizzleOrm.eq(
|
|
5918
|
+
drizzleOrm.eq(subAgents.id, subAgentRelations.sourceSubAgentId),
|
|
5919
|
+
drizzleOrm.eq(subAgents.tenantId, subAgentRelations.tenantId),
|
|
5920
|
+
drizzleOrm.eq(subAgents.projectId, subAgentRelations.projectId),
|
|
5921
|
+
drizzleOrm.eq(subAgents.graphId, subAgentRelations.graphId)
|
|
5689
5922
|
)
|
|
5690
5923
|
).where(
|
|
5691
5924
|
drizzleOrm.and(
|
|
5692
|
-
drizzleOrm.eq(
|
|
5693
|
-
drizzleOrm.eq(
|
|
5694
|
-
drizzleOrm.eq(
|
|
5925
|
+
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
5926
|
+
drizzleOrm.eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
|
|
5927
|
+
drizzleOrm.eq(subAgentRelations.graphId, params.scopes.graphId)
|
|
5695
5928
|
)
|
|
5696
5929
|
).limit(1);
|
|
5697
5930
|
const total = result[0]?.count || 0;
|
|
@@ -5709,12 +5942,12 @@ var countArtifactComponents = (db) => async (params) => {
|
|
|
5709
5942
|
return typeof total === "string" ? Number.parseInt(total, 10) : total;
|
|
5710
5943
|
};
|
|
5711
5944
|
var countArtifactComponentsForAgent = (db) => async (params) => {
|
|
5712
|
-
const result = await db.select({ count: drizzleOrm.count() }).from(
|
|
5945
|
+
const result = await db.select({ count: drizzleOrm.count() }).from(subAgentArtifactComponents).where(
|
|
5713
5946
|
drizzleOrm.and(
|
|
5714
|
-
drizzleOrm.eq(
|
|
5715
|
-
drizzleOrm.eq(
|
|
5716
|
-
drizzleOrm.eq(
|
|
5717
|
-
drizzleOrm.eq(
|
|
5947
|
+
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
5948
|
+
drizzleOrm.eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
|
|
5949
|
+
drizzleOrm.eq(subAgentArtifactComponents.graphId, params.scopes.graphId),
|
|
5950
|
+
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
|
|
5718
5951
|
)
|
|
5719
5952
|
);
|
|
5720
5953
|
const total = result[0]?.count || 0;
|
|
@@ -5949,7 +6182,7 @@ var updateConversationActiveAgent = (db) => async (params) => {
|
|
|
5949
6182
|
scopes: params.scopes,
|
|
5950
6183
|
conversationId: params.conversationId,
|
|
5951
6184
|
data: {
|
|
5952
|
-
|
|
6185
|
+
activeSubAgentId: params.activeSubAgentId
|
|
5953
6186
|
}
|
|
5954
6187
|
});
|
|
5955
6188
|
};
|
|
@@ -5969,12 +6202,12 @@ var createOrGetConversation = (db) => async (input) => {
|
|
|
5969
6202
|
where: drizzleOrm.and(drizzleOrm.eq(conversations.tenantId, input.tenantId), drizzleOrm.eq(conversations.id, input.id))
|
|
5970
6203
|
});
|
|
5971
6204
|
if (existing) {
|
|
5972
|
-
if (existing.
|
|
6205
|
+
if (existing.activeSubAgentId !== input.activeSubAgentId) {
|
|
5973
6206
|
await db.update(conversations).set({
|
|
5974
|
-
|
|
6207
|
+
activeSubAgentId: input.activeSubAgentId,
|
|
5975
6208
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5976
6209
|
}).where(drizzleOrm.eq(conversations.id, input.id));
|
|
5977
|
-
return { ...existing,
|
|
6210
|
+
return { ...existing, activeSubAgentId: input.activeSubAgentId };
|
|
5978
6211
|
}
|
|
5979
6212
|
return existing;
|
|
5980
6213
|
}
|
|
@@ -5984,7 +6217,7 @@ var createOrGetConversation = (db) => async (input) => {
|
|
|
5984
6217
|
tenantId: input.tenantId,
|
|
5985
6218
|
projectId: input.projectId,
|
|
5986
6219
|
userId: input.userId,
|
|
5987
|
-
|
|
6220
|
+
activeSubAgentId: input.activeSubAgentId,
|
|
5988
6221
|
title: input.title,
|
|
5989
6222
|
lastContextResolution: input.lastContextResolution,
|
|
5990
6223
|
metadata: input.metadata,
|
|
@@ -6070,13 +6303,13 @@ var setActiveAgentForConversation = (db) => async (params) => {
|
|
|
6070
6303
|
id: params.conversationId,
|
|
6071
6304
|
tenantId: params.scopes.tenantId,
|
|
6072
6305
|
projectId: params.scopes.projectId,
|
|
6073
|
-
|
|
6306
|
+
activeSubAgentId: params.subAgentId,
|
|
6074
6307
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6075
6308
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6076
6309
|
}).onConflictDoUpdate({
|
|
6077
6310
|
target: [conversations.tenantId, conversations.projectId, conversations.id],
|
|
6078
6311
|
set: {
|
|
6079
|
-
|
|
6312
|
+
activeSubAgentId: params.subAgentId,
|
|
6080
6313
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6081
6314
|
}
|
|
6082
6315
|
});
|
|
@@ -6084,9 +6317,13 @@ var setActiveAgentForConversation = (db) => async (params) => {
|
|
|
6084
6317
|
var setActiveAgentForThread = (db) => async ({
|
|
6085
6318
|
scopes,
|
|
6086
6319
|
threadId,
|
|
6087
|
-
|
|
6320
|
+
subAgentId
|
|
6088
6321
|
}) => {
|
|
6089
|
-
return setActiveAgentForConversation(db)({
|
|
6322
|
+
return setActiveAgentForConversation(db)({
|
|
6323
|
+
scopes,
|
|
6324
|
+
conversationId: threadId,
|
|
6325
|
+
subAgentId
|
|
6326
|
+
});
|
|
6090
6327
|
};
|
|
6091
6328
|
var getDataComponent = (db) => async (params) => {
|
|
6092
6329
|
const result = await db.query.dataComponents.findFirst({
|
|
@@ -6186,68 +6423,71 @@ var getDataComponentsForAgent = (db) => async (params) => {
|
|
|
6186
6423
|
props: dataComponents.props,
|
|
6187
6424
|
createdAt: dataComponents.createdAt,
|
|
6188
6425
|
updatedAt: dataComponents.updatedAt
|
|
6189
|
-
}).from(dataComponents).innerJoin(
|
|
6426
|
+
}).from(dataComponents).innerJoin(
|
|
6427
|
+
subAgentDataComponents,
|
|
6428
|
+
drizzleOrm.eq(dataComponents.id, subAgentDataComponents.dataComponentId)
|
|
6429
|
+
).where(
|
|
6190
6430
|
drizzleOrm.and(
|
|
6191
6431
|
drizzleOrm.eq(dataComponents.tenantId, params.scopes.tenantId),
|
|
6192
6432
|
drizzleOrm.eq(dataComponents.projectId, params.scopes.projectId),
|
|
6193
|
-
drizzleOrm.eq(
|
|
6194
|
-
drizzleOrm.eq(
|
|
6433
|
+
drizzleOrm.eq(subAgentDataComponents.graphId, params.scopes.graphId),
|
|
6434
|
+
drizzleOrm.eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId)
|
|
6195
6435
|
)
|
|
6196
6436
|
).orderBy(drizzleOrm.desc(dataComponents.createdAt));
|
|
6197
6437
|
};
|
|
6198
6438
|
var associateDataComponentWithAgent = (db) => async (params) => {
|
|
6199
|
-
const association = await db.insert(
|
|
6439
|
+
const association = await db.insert(subAgentDataComponents).values({
|
|
6200
6440
|
id: nanoid.nanoid(),
|
|
6201
6441
|
tenantId: params.scopes.tenantId,
|
|
6202
6442
|
projectId: params.scopes.projectId,
|
|
6203
6443
|
graphId: params.scopes.graphId,
|
|
6204
|
-
|
|
6444
|
+
subAgentId: params.scopes.subAgentId,
|
|
6205
6445
|
dataComponentId: params.dataComponentId
|
|
6206
6446
|
}).returning();
|
|
6207
6447
|
return association[0];
|
|
6208
6448
|
};
|
|
6209
6449
|
var removeDataComponentFromAgent = (db) => async (params) => {
|
|
6210
|
-
const result = await db.delete(
|
|
6450
|
+
const result = await db.delete(subAgentDataComponents).where(
|
|
6211
6451
|
drizzleOrm.and(
|
|
6212
|
-
drizzleOrm.eq(
|
|
6213
|
-
drizzleOrm.eq(
|
|
6214
|
-
drizzleOrm.eq(
|
|
6215
|
-
drizzleOrm.eq(
|
|
6216
|
-
drizzleOrm.eq(
|
|
6452
|
+
drizzleOrm.eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
|
|
6453
|
+
drizzleOrm.eq(subAgentDataComponents.projectId, params.scopes.projectId),
|
|
6454
|
+
drizzleOrm.eq(subAgentDataComponents.graphId, params.scopes.graphId),
|
|
6455
|
+
drizzleOrm.eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId),
|
|
6456
|
+
drizzleOrm.eq(subAgentDataComponents.dataComponentId, params.dataComponentId)
|
|
6217
6457
|
)
|
|
6218
6458
|
).returning();
|
|
6219
6459
|
return result.length > 0;
|
|
6220
6460
|
};
|
|
6221
6461
|
var deleteAgentDataComponentRelationByAgent = (db) => async (params) => {
|
|
6222
|
-
const result = await db.delete(
|
|
6462
|
+
const result = await db.delete(subAgentDataComponents).where(
|
|
6223
6463
|
drizzleOrm.and(
|
|
6224
|
-
drizzleOrm.eq(
|
|
6225
|
-
drizzleOrm.eq(
|
|
6226
|
-
drizzleOrm.eq(
|
|
6464
|
+
drizzleOrm.eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
|
|
6465
|
+
drizzleOrm.eq(subAgentDataComponents.graphId, params.scopes.graphId),
|
|
6466
|
+
drizzleOrm.eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId)
|
|
6227
6467
|
)
|
|
6228
6468
|
);
|
|
6229
6469
|
return (result.rowsAffected || 0) > 0;
|
|
6230
6470
|
};
|
|
6231
6471
|
var getAgentsUsingDataComponent = (db) => async (params) => {
|
|
6232
6472
|
return await db.select({
|
|
6233
|
-
|
|
6234
|
-
createdAt:
|
|
6235
|
-
}).from(
|
|
6473
|
+
subAgentId: subAgentDataComponents.subAgentId,
|
|
6474
|
+
createdAt: subAgentDataComponents.createdAt
|
|
6475
|
+
}).from(subAgentDataComponents).where(
|
|
6236
6476
|
drizzleOrm.and(
|
|
6237
|
-
drizzleOrm.eq(
|
|
6238
|
-
drizzleOrm.eq(
|
|
6239
|
-
drizzleOrm.eq(
|
|
6477
|
+
drizzleOrm.eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
|
|
6478
|
+
drizzleOrm.eq(subAgentDataComponents.projectId, params.scopes.projectId),
|
|
6479
|
+
drizzleOrm.eq(subAgentDataComponents.dataComponentId, params.dataComponentId)
|
|
6240
6480
|
)
|
|
6241
|
-
).orderBy(drizzleOrm.desc(
|
|
6481
|
+
).orderBy(drizzleOrm.desc(subAgentDataComponents.createdAt));
|
|
6242
6482
|
};
|
|
6243
6483
|
var isDataComponentAssociatedWithAgent = (db) => async (params) => {
|
|
6244
|
-
const result = await db.select({ id:
|
|
6484
|
+
const result = await db.select({ id: subAgentDataComponents.id }).from(subAgentDataComponents).where(
|
|
6245
6485
|
drizzleOrm.and(
|
|
6246
|
-
drizzleOrm.eq(
|
|
6247
|
-
drizzleOrm.eq(
|
|
6248
|
-
drizzleOrm.eq(
|
|
6249
|
-
drizzleOrm.eq(
|
|
6250
|
-
drizzleOrm.eq(
|
|
6486
|
+
drizzleOrm.eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
|
|
6487
|
+
drizzleOrm.eq(subAgentDataComponents.projectId, params.scopes.projectId),
|
|
6488
|
+
drizzleOrm.eq(subAgentDataComponents.graphId, params.scopes.graphId),
|
|
6489
|
+
drizzleOrm.eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId),
|
|
6490
|
+
drizzleOrm.eq(subAgentDataComponents.dataComponentId, params.dataComponentId)
|
|
6251
6491
|
)
|
|
6252
6492
|
).limit(1);
|
|
6253
6493
|
return result.length > 0;
|
|
@@ -6298,18 +6538,18 @@ function isExternalAgent(agent) {
|
|
|
6298
6538
|
return "baseUrl" in agent;
|
|
6299
6539
|
}
|
|
6300
6540
|
function validateAndTypeGraphData(data) {
|
|
6301
|
-
return
|
|
6541
|
+
return GraphWithinContextOfProjectSchema.parse(data);
|
|
6302
6542
|
}
|
|
6303
6543
|
function validateToolReferences(graphData, availableToolIds) {
|
|
6304
6544
|
if (!availableToolIds) {
|
|
6305
6545
|
return;
|
|
6306
6546
|
}
|
|
6307
6547
|
const errors = [];
|
|
6308
|
-
for (const [
|
|
6548
|
+
for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
|
|
6309
6549
|
if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
|
|
6310
6550
|
for (const canUseItem of agentData.canUse) {
|
|
6311
6551
|
if (!availableToolIds.has(canUseItem.toolId)) {
|
|
6312
|
-
errors.push(`Agent '${
|
|
6552
|
+
errors.push(`Agent '${subAgentId}' references non-existent tool '${canUseItem.toolId}'`);
|
|
6313
6553
|
}
|
|
6314
6554
|
}
|
|
6315
6555
|
}
|
|
@@ -6324,12 +6564,12 @@ function validateDataComponentReferences(graphData, availableDataComponentIds) {
|
|
|
6324
6564
|
return;
|
|
6325
6565
|
}
|
|
6326
6566
|
const errors = [];
|
|
6327
|
-
for (const [
|
|
6567
|
+
for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
|
|
6328
6568
|
if (isInternalAgent(agentData) && agentData.dataComponents) {
|
|
6329
6569
|
for (const dataComponentId of agentData.dataComponents) {
|
|
6330
6570
|
if (!availableDataComponentIds.has(dataComponentId)) {
|
|
6331
6571
|
errors.push(
|
|
6332
|
-
`Agent '${
|
|
6572
|
+
`Agent '${subAgentId}' references non-existent dataComponent '${dataComponentId}'`
|
|
6333
6573
|
);
|
|
6334
6574
|
}
|
|
6335
6575
|
}
|
|
@@ -6345,12 +6585,12 @@ function validateArtifactComponentReferences(graphData, availableArtifactCompone
|
|
|
6345
6585
|
return;
|
|
6346
6586
|
}
|
|
6347
6587
|
const errors = [];
|
|
6348
|
-
for (const [
|
|
6588
|
+
for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
|
|
6349
6589
|
if (isInternalAgent(agentData) && agentData.artifactComponents) {
|
|
6350
6590
|
for (const artifactComponentId of agentData.artifactComponents) {
|
|
6351
6591
|
if (!availableArtifactComponentIds.has(artifactComponentId)) {
|
|
6352
6592
|
errors.push(
|
|
6353
|
-
`Agent '${
|
|
6593
|
+
`Agent '${subAgentId}' references non-existent artifactComponent '${artifactComponentId}'`
|
|
6354
6594
|
);
|
|
6355
6595
|
}
|
|
6356
6596
|
}
|
|
@@ -6363,14 +6603,14 @@ ${errors.join("\n")}`);
|
|
|
6363
6603
|
}
|
|
6364
6604
|
function validateAgentRelationships(graphData) {
|
|
6365
6605
|
const errors = [];
|
|
6366
|
-
const availableAgentIds = new Set(Object.keys(graphData.
|
|
6367
|
-
for (const [
|
|
6606
|
+
const availableAgentIds = new Set(Object.keys(graphData.subAgents));
|
|
6607
|
+
for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
|
|
6368
6608
|
if (isInternalAgent(agentData)) {
|
|
6369
6609
|
if (agentData.canTransferTo && Array.isArray(agentData.canTransferTo)) {
|
|
6370
6610
|
for (const targetId of agentData.canTransferTo) {
|
|
6371
6611
|
if (!availableAgentIds.has(targetId)) {
|
|
6372
6612
|
errors.push(
|
|
6373
|
-
`Agent '${
|
|
6613
|
+
`Agent '${subAgentId}' has transfer target '${targetId}' that doesn't exist in graph`
|
|
6374
6614
|
);
|
|
6375
6615
|
}
|
|
6376
6616
|
}
|
|
@@ -6379,7 +6619,7 @@ function validateAgentRelationships(graphData) {
|
|
|
6379
6619
|
for (const targetId of agentData.canDelegateTo) {
|
|
6380
6620
|
if (!availableAgentIds.has(targetId)) {
|
|
6381
6621
|
errors.push(
|
|
6382
|
-
`Agent '${
|
|
6622
|
+
`Agent '${subAgentId}' has delegation target '${targetId}' that doesn't exist in graph`
|
|
6383
6623
|
);
|
|
6384
6624
|
}
|
|
6385
6625
|
}
|
|
@@ -6392,8 +6632,8 @@ ${errors.join("\n")}`);
|
|
|
6392
6632
|
}
|
|
6393
6633
|
}
|
|
6394
6634
|
function validateGraphStructure(graphData, projectResources) {
|
|
6395
|
-
if (graphData.
|
|
6396
|
-
throw new Error(`Default agent '${graphData.
|
|
6635
|
+
if (graphData.defaultSubAgentId && !graphData.subAgents[graphData.defaultSubAgentId]) {
|
|
6636
|
+
throw new Error(`Default agent '${graphData.defaultSubAgentId}' does not exist in agents`);
|
|
6397
6637
|
}
|
|
6398
6638
|
if (projectResources) {
|
|
6399
6639
|
validateToolReferences(graphData, projectResources.toolIds);
|
|
@@ -6459,7 +6699,7 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
|
|
|
6459
6699
|
},
|
|
6460
6700
|
"Propagating stepCountIs to agents"
|
|
6461
6701
|
);
|
|
6462
|
-
for (const [
|
|
6702
|
+
for (const [subAgentId, agentData] of Object.entries(graphData.subAgents)) {
|
|
6463
6703
|
if (isInternalAgent(agentData)) {
|
|
6464
6704
|
const agent = agentData;
|
|
6465
6705
|
if (!agent.stopWhen) {
|
|
@@ -6469,7 +6709,7 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, graphData)
|
|
|
6469
6709
|
agent.stopWhen.stepCountIs = projectStopWhen.stepCountIs;
|
|
6470
6710
|
logger13.info(
|
|
6471
6711
|
{
|
|
6472
|
-
|
|
6712
|
+
subAgentId,
|
|
6473
6713
|
inheritedValue: projectStopWhen.stepCountIs
|
|
6474
6714
|
},
|
|
6475
6715
|
"Agent inherited stepCountIs from project"
|
|
@@ -6509,7 +6749,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6509
6749
|
tenantId,
|
|
6510
6750
|
projectId,
|
|
6511
6751
|
name: typed.name,
|
|
6512
|
-
|
|
6752
|
+
defaultSubAgentId: typed.defaultSubAgentId,
|
|
6513
6753
|
description: typed.description,
|
|
6514
6754
|
contextConfigId: void 0,
|
|
6515
6755
|
// Will be updated later if context config exists
|
|
@@ -6559,7 +6799,7 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6559
6799
|
tenantId,
|
|
6560
6800
|
projectId,
|
|
6561
6801
|
name: typed.name,
|
|
6562
|
-
|
|
6802
|
+
defaultSubAgentId: typed.defaultSubAgentId,
|
|
6563
6803
|
description: typed.description,
|
|
6564
6804
|
contextConfigId,
|
|
6565
6805
|
models: typed.models,
|
|
@@ -6588,13 +6828,13 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6588
6828
|
{},
|
|
6589
6829
|
"ArtifactComponents are project-scoped - skipping artifactComponent creation in graph"
|
|
6590
6830
|
);
|
|
6591
|
-
const internalAgentPromises = Object.entries(typed.
|
|
6831
|
+
const internalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData]) => isInternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
|
|
6592
6832
|
const internalAgent = agentData;
|
|
6593
6833
|
try {
|
|
6594
|
-
logger13.info({
|
|
6595
|
-
await
|
|
6834
|
+
logger13.info({ subAgentId }, "Processing internal agent");
|
|
6835
|
+
await upsertSubAgent(db)({
|
|
6596
6836
|
data: {
|
|
6597
|
-
id:
|
|
6837
|
+
id: subAgentId,
|
|
6598
6838
|
tenantId,
|
|
6599
6839
|
projectId,
|
|
6600
6840
|
graphId: finalGraphId,
|
|
@@ -6606,24 +6846,24 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6606
6846
|
stopWhen: internalAgent.stopWhen
|
|
6607
6847
|
}
|
|
6608
6848
|
});
|
|
6609
|
-
logger13.info({
|
|
6849
|
+
logger13.info({ subAgentId }, "Internal agent processed successfully");
|
|
6610
6850
|
} catch (error) {
|
|
6611
|
-
logger13.error({
|
|
6851
|
+
logger13.error({ subAgentId, error }, "Failed to create/update internal agent");
|
|
6612
6852
|
throw error;
|
|
6613
6853
|
}
|
|
6614
6854
|
});
|
|
6615
6855
|
await Promise.all(internalAgentPromises);
|
|
6616
|
-
const internalAgentCount = Object.entries(typed.
|
|
6856
|
+
const internalAgentCount = Object.entries(typed.subAgents).filter(
|
|
6617
6857
|
([_, agentData]) => isInternalAgent(agentData)
|
|
6618
6858
|
).length;
|
|
6619
6859
|
logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
|
|
6620
|
-
const externalAgentPromises = Object.entries(typed.
|
|
6860
|
+
const externalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData]) => isExternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
|
|
6621
6861
|
const externalAgent = agentData;
|
|
6622
6862
|
try {
|
|
6623
|
-
logger13.info({
|
|
6863
|
+
logger13.info({ subAgentId }, "Processing external agent");
|
|
6624
6864
|
await upsertExternalAgent(db)({
|
|
6625
6865
|
data: {
|
|
6626
|
-
id:
|
|
6866
|
+
id: subAgentId,
|
|
6627
6867
|
tenantId,
|
|
6628
6868
|
projectId,
|
|
6629
6869
|
graphId: finalGraphId,
|
|
@@ -6634,14 +6874,14 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6634
6874
|
headers: externalAgent.headers || void 0
|
|
6635
6875
|
}
|
|
6636
6876
|
});
|
|
6637
|
-
logger13.info({
|
|
6877
|
+
logger13.info({ subAgentId }, "External agent processed successfully");
|
|
6638
6878
|
} catch (error) {
|
|
6639
|
-
logger13.error({
|
|
6879
|
+
logger13.error({ subAgentId, error }, "Failed to create/update external agent");
|
|
6640
6880
|
throw error;
|
|
6641
6881
|
}
|
|
6642
6882
|
});
|
|
6643
6883
|
await Promise.all(externalAgentPromises);
|
|
6644
|
-
const externalAgentCount = Object.entries(typed.
|
|
6884
|
+
const externalAgentCount = Object.entries(typed.subAgents).filter(
|
|
6645
6885
|
([_, agentData]) => isExternalAgent(agentData)
|
|
6646
6886
|
).length;
|
|
6647
6887
|
logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
|
|
@@ -6665,26 +6905,26 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6665
6905
|
}
|
|
6666
6906
|
}
|
|
6667
6907
|
const agentToolPromises = [];
|
|
6668
|
-
for (const [
|
|
6908
|
+
for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
|
|
6669
6909
|
if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
|
|
6670
6910
|
for (const canUseItem of agentData.canUse) {
|
|
6671
6911
|
agentToolPromises.push(
|
|
6672
6912
|
(async () => {
|
|
6673
6913
|
try {
|
|
6674
6914
|
const { toolId, toolSelection, headers: headers2, agentToolRelationId } = canUseItem;
|
|
6675
|
-
logger13.info({
|
|
6915
|
+
logger13.info({ subAgentId, toolId }, "Processing agent-tool relation");
|
|
6676
6916
|
await upsertAgentToolRelation(db)({
|
|
6677
6917
|
scopes: { tenantId, projectId, graphId: finalGraphId },
|
|
6678
|
-
|
|
6918
|
+
subAgentId,
|
|
6679
6919
|
toolId,
|
|
6680
6920
|
selectedTools: toolSelection || void 0,
|
|
6681
6921
|
headers: headers2 || void 0,
|
|
6682
6922
|
relationId: agentToolRelationId
|
|
6683
6923
|
});
|
|
6684
|
-
logger13.info({
|
|
6924
|
+
logger13.info({ subAgentId, toolId }, "Agent-tool relation processed successfully");
|
|
6685
6925
|
} catch (error) {
|
|
6686
6926
|
logger13.error(
|
|
6687
|
-
{
|
|
6927
|
+
{ subAgentId, toolId: canUseItem.toolId, error },
|
|
6688
6928
|
"Failed to create agent-tool relation"
|
|
6689
6929
|
);
|
|
6690
6930
|
}
|
|
@@ -6695,31 +6935,31 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6695
6935
|
}
|
|
6696
6936
|
await Promise.all(agentToolPromises);
|
|
6697
6937
|
logger13.info(
|
|
6698
|
-
{ agentToolCount: Object.keys(typed.
|
|
6938
|
+
{ agentToolCount: Object.keys(typed.subAgents).length },
|
|
6699
6939
|
"All agent-tool relations created"
|
|
6700
6940
|
);
|
|
6701
6941
|
const agentDataComponentPromises = [];
|
|
6702
|
-
for (const [
|
|
6942
|
+
for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
|
|
6703
6943
|
if (isInternalAgent(agentData) && agentData.dataComponents) {
|
|
6704
6944
|
for (const dataComponentId of agentData.dataComponents) {
|
|
6705
6945
|
agentDataComponentPromises.push(
|
|
6706
6946
|
(async () => {
|
|
6707
6947
|
try {
|
|
6708
6948
|
logger13.info(
|
|
6709
|
-
{
|
|
6949
|
+
{ subAgentId, dataComponentId },
|
|
6710
6950
|
"Processing agent-data component relation"
|
|
6711
6951
|
);
|
|
6712
6952
|
await upsertAgentDataComponentRelation(db)({
|
|
6713
|
-
scopes: { tenantId, projectId, graphId: finalGraphId,
|
|
6953
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
|
|
6714
6954
|
dataComponentId
|
|
6715
6955
|
});
|
|
6716
6956
|
logger13.info(
|
|
6717
|
-
{
|
|
6957
|
+
{ subAgentId, dataComponentId },
|
|
6718
6958
|
"Agent-data component relation processed successfully"
|
|
6719
6959
|
);
|
|
6720
6960
|
} catch (error) {
|
|
6721
6961
|
logger13.error(
|
|
6722
|
-
{
|
|
6962
|
+
{ subAgentId, dataComponentId, error },
|
|
6723
6963
|
"Failed to create agent-data component relation"
|
|
6724
6964
|
);
|
|
6725
6965
|
}
|
|
@@ -6731,27 +6971,27 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6731
6971
|
await Promise.all(agentDataComponentPromises);
|
|
6732
6972
|
logger13.info({}, "All agent-data component relations created");
|
|
6733
6973
|
const agentArtifactComponentPromises = [];
|
|
6734
|
-
for (const [
|
|
6974
|
+
for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
|
|
6735
6975
|
if (isInternalAgent(agentData) && agentData.artifactComponents) {
|
|
6736
6976
|
for (const artifactComponentId of agentData.artifactComponents) {
|
|
6737
6977
|
agentArtifactComponentPromises.push(
|
|
6738
6978
|
(async () => {
|
|
6739
6979
|
try {
|
|
6740
6980
|
logger13.info(
|
|
6741
|
-
{
|
|
6981
|
+
{ subAgentId, artifactComponentId },
|
|
6742
6982
|
"Processing agent-artifact component relation"
|
|
6743
6983
|
);
|
|
6744
6984
|
await upsertAgentArtifactComponentRelation(db)({
|
|
6745
|
-
scopes: { tenantId, projectId, graphId: finalGraphId,
|
|
6985
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
|
|
6746
6986
|
artifactComponentId
|
|
6747
6987
|
});
|
|
6748
6988
|
logger13.info(
|
|
6749
|
-
{
|
|
6989
|
+
{ subAgentId, artifactComponentId },
|
|
6750
6990
|
"Agent-artifact component relation processed successfully"
|
|
6751
6991
|
);
|
|
6752
6992
|
} catch (error) {
|
|
6753
6993
|
logger13.error(
|
|
6754
|
-
{
|
|
6994
|
+
{ subAgentId, artifactComponentId, error },
|
|
6755
6995
|
"Failed to create agent-artifact component relation"
|
|
6756
6996
|
);
|
|
6757
6997
|
}
|
|
@@ -6763,14 +7003,14 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6763
7003
|
await Promise.all(agentArtifactComponentPromises);
|
|
6764
7004
|
logger13.info({}, "All agent-artifact component relations created");
|
|
6765
7005
|
const agentRelationPromises = [];
|
|
6766
|
-
for (const [
|
|
7006
|
+
for (const [subAgentId, agentData] of Object.entries(typed.subAgents)) {
|
|
6767
7007
|
if (isInternalAgent(agentData) && agentData.canTransferTo) {
|
|
6768
|
-
for (const
|
|
7008
|
+
for (const targetSubAgentId of agentData.canTransferTo) {
|
|
6769
7009
|
agentRelationPromises.push(
|
|
6770
7010
|
(async () => {
|
|
6771
7011
|
try {
|
|
6772
7012
|
logger13.info(
|
|
6773
|
-
{
|
|
7013
|
+
{ subAgentId, targetSubAgentId, type: "transfer" },
|
|
6774
7014
|
"Processing agent transfer relation"
|
|
6775
7015
|
);
|
|
6776
7016
|
await upsertAgentRelation(db)({
|
|
@@ -6778,17 +7018,17 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6778
7018
|
tenantId,
|
|
6779
7019
|
projectId,
|
|
6780
7020
|
graphId: finalGraphId,
|
|
6781
|
-
|
|
6782
|
-
|
|
7021
|
+
sourceSubAgentId: subAgentId,
|
|
7022
|
+
targetSubAgentId,
|
|
6783
7023
|
relationType: "transfer"
|
|
6784
7024
|
});
|
|
6785
7025
|
logger13.info(
|
|
6786
|
-
{
|
|
7026
|
+
{ subAgentId, targetSubAgentId, type: "transfer" },
|
|
6787
7027
|
"Agent transfer relation processed successfully"
|
|
6788
7028
|
);
|
|
6789
7029
|
} catch (error) {
|
|
6790
7030
|
logger13.error(
|
|
6791
|
-
{
|
|
7031
|
+
{ subAgentId, targetSubAgentId, type: "transfer", error },
|
|
6792
7032
|
"Failed to create transfer relation"
|
|
6793
7033
|
);
|
|
6794
7034
|
}
|
|
@@ -6797,14 +7037,14 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6797
7037
|
}
|
|
6798
7038
|
}
|
|
6799
7039
|
if (isInternalAgent(agentData) && agentData.canDelegateTo) {
|
|
6800
|
-
for (const
|
|
6801
|
-
const targetAgentData = typed.
|
|
7040
|
+
for (const targetSubAgentId of agentData.canDelegateTo) {
|
|
7041
|
+
const targetAgentData = typed.subAgents[targetSubAgentId];
|
|
6802
7042
|
const isTargetExternal = isExternalAgent(targetAgentData);
|
|
6803
7043
|
agentRelationPromises.push(
|
|
6804
7044
|
(async () => {
|
|
6805
7045
|
try {
|
|
6806
7046
|
logger13.info(
|
|
6807
|
-
{
|
|
7047
|
+
{ subAgentId, targetSubAgentId, type: "delegate" },
|
|
6808
7048
|
"Processing agent delegation relation"
|
|
6809
7049
|
);
|
|
6810
7050
|
await upsertAgentRelation(db)({
|
|
@@ -6812,18 +7052,18 @@ var createFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6812
7052
|
tenantId,
|
|
6813
7053
|
projectId,
|
|
6814
7054
|
graphId: finalGraphId,
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
7055
|
+
sourceSubAgentId: subAgentId,
|
|
7056
|
+
targetSubAgentId: isTargetExternal ? void 0 : targetSubAgentId,
|
|
7057
|
+
externalSubAgentId: isTargetExternal ? targetSubAgentId : void 0,
|
|
6818
7058
|
relationType: "delegate"
|
|
6819
7059
|
});
|
|
6820
7060
|
logger13.info(
|
|
6821
|
-
{
|
|
7061
|
+
{ subAgentId, targetSubAgentId, type: "delegate" },
|
|
6822
7062
|
"Agent delegation relation processed successfully"
|
|
6823
7063
|
);
|
|
6824
7064
|
} catch (error) {
|
|
6825
7065
|
logger13.error(
|
|
6826
|
-
{
|
|
7066
|
+
{ subAgentId, targetSubAgentId, type: "delegate", error },
|
|
6827
7067
|
"Failed to create delegation relation"
|
|
6828
7068
|
);
|
|
6829
7069
|
}
|
|
@@ -6861,7 +7101,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6861
7101
|
{
|
|
6862
7102
|
tenantId,
|
|
6863
7103
|
graphId: typedGraphDefinition.id,
|
|
6864
|
-
agentCount: Object.keys(typedGraphDefinition.
|
|
7104
|
+
agentCount: Object.keys(typedGraphDefinition.subAgents).length
|
|
6865
7105
|
},
|
|
6866
7106
|
"Updating full graph in database"
|
|
6867
7107
|
);
|
|
@@ -6899,7 +7139,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6899
7139
|
tenantId,
|
|
6900
7140
|
projectId,
|
|
6901
7141
|
name: typedGraphDefinition.name,
|
|
6902
|
-
|
|
7142
|
+
defaultSubAgentId: typedGraphDefinition.defaultSubAgentId,
|
|
6903
7143
|
description: typedGraphDefinition.description,
|
|
6904
7144
|
contextConfigId: void 0,
|
|
6905
7145
|
// Will be updated later if context config exists
|
|
@@ -6957,7 +7197,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6957
7197
|
tenantId,
|
|
6958
7198
|
projectId,
|
|
6959
7199
|
name: typedGraphDefinition.name,
|
|
6960
|
-
|
|
7200
|
+
defaultSubAgentId: typedGraphDefinition.defaultSubAgentId,
|
|
6961
7201
|
description: typedGraphDefinition.description,
|
|
6962
7202
|
contextConfigId,
|
|
6963
7203
|
models: typedGraphDefinition.models,
|
|
@@ -6983,15 +7223,15 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
6983
7223
|
{},
|
|
6984
7224
|
"ArtifactComponents are project-scoped - skipping artifactComponent update in graph"
|
|
6985
7225
|
);
|
|
6986
|
-
const internalAgentPromises = Object.entries(typedGraphDefinition.
|
|
7226
|
+
const internalAgentPromises = Object.entries(typedGraphDefinition.subAgents).filter(([_, agentData]) => isInternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
|
|
6987
7227
|
const internalAgent = agentData;
|
|
6988
7228
|
let existingAgent = null;
|
|
6989
7229
|
try {
|
|
6990
|
-
existingAgent = await db.query.
|
|
7230
|
+
existingAgent = await db.query.subAgents.findFirst({
|
|
6991
7231
|
where: drizzleOrm.and(
|
|
6992
|
-
drizzleOrm.eq(
|
|
6993
|
-
drizzleOrm.eq(
|
|
6994
|
-
drizzleOrm.eq(
|
|
7232
|
+
drizzleOrm.eq(subAgents.id, subAgentId),
|
|
7233
|
+
drizzleOrm.eq(subAgents.tenantId, tenantId),
|
|
7234
|
+
drizzleOrm.eq(subAgents.projectId, projectId)
|
|
6995
7235
|
),
|
|
6996
7236
|
columns: {
|
|
6997
7237
|
models: true
|
|
@@ -7012,7 +7252,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7012
7252
|
cascadedModels[modelType] = graphModels[modelType];
|
|
7013
7253
|
logger13.info(
|
|
7014
7254
|
{
|
|
7015
|
-
|
|
7255
|
+
subAgentId,
|
|
7016
7256
|
modelType,
|
|
7017
7257
|
oldModel: agentModels[modelType].model,
|
|
7018
7258
|
newModel: graphModels[modelType].model,
|
|
@@ -7025,10 +7265,10 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7025
7265
|
finalModelSettings = cascadedModels;
|
|
7026
7266
|
}
|
|
7027
7267
|
try {
|
|
7028
|
-
logger13.info({
|
|
7029
|
-
await
|
|
7268
|
+
logger13.info({ subAgentId }, "Processing internal agent");
|
|
7269
|
+
await upsertSubAgent(db)({
|
|
7030
7270
|
data: {
|
|
7031
|
-
id:
|
|
7271
|
+
id: subAgentId,
|
|
7032
7272
|
tenantId,
|
|
7033
7273
|
projectId,
|
|
7034
7274
|
graphId: finalGraphId,
|
|
@@ -7040,24 +7280,24 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7040
7280
|
stopWhen: internalAgent.stopWhen
|
|
7041
7281
|
}
|
|
7042
7282
|
});
|
|
7043
|
-
logger13.info({
|
|
7283
|
+
logger13.info({ subAgentId }, "Internal agent processed successfully");
|
|
7044
7284
|
} catch (error) {
|
|
7045
|
-
logger13.error({
|
|
7285
|
+
logger13.error({ subAgentId, error }, "Failed to create/update internal agent");
|
|
7046
7286
|
throw error;
|
|
7047
7287
|
}
|
|
7048
7288
|
});
|
|
7049
7289
|
await Promise.all(internalAgentPromises);
|
|
7050
|
-
const internalAgentCount = Object.entries(typedGraphDefinition.
|
|
7290
|
+
const internalAgentCount = Object.entries(typedGraphDefinition.subAgents).filter(
|
|
7051
7291
|
([_, agentData]) => isInternalAgent(agentData)
|
|
7052
7292
|
).length;
|
|
7053
7293
|
logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
|
|
7054
|
-
const externalAgentPromises = Object.entries(typedGraphDefinition.
|
|
7294
|
+
const externalAgentPromises = Object.entries(typedGraphDefinition.subAgents).filter(([_, agentData]) => isExternalAgent(agentData)).map(async ([subAgentId, agentData]) => {
|
|
7055
7295
|
const externalAgent = agentData;
|
|
7056
7296
|
try {
|
|
7057
|
-
logger13.info({
|
|
7297
|
+
logger13.info({ subAgentId }, "Processing external agent");
|
|
7058
7298
|
await upsertExternalAgent(db)({
|
|
7059
7299
|
data: {
|
|
7060
|
-
id:
|
|
7300
|
+
id: subAgentId,
|
|
7061
7301
|
tenantId,
|
|
7062
7302
|
projectId,
|
|
7063
7303
|
graphId: finalGraphId,
|
|
@@ -7068,19 +7308,19 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7068
7308
|
headers: externalAgent.headers || void 0
|
|
7069
7309
|
}
|
|
7070
7310
|
});
|
|
7071
|
-
logger13.info({
|
|
7311
|
+
logger13.info({ subAgentId }, "External agent processed successfully");
|
|
7072
7312
|
} catch (error) {
|
|
7073
|
-
logger13.error({
|
|
7313
|
+
logger13.error({ subAgentId, error }, "Failed to create/update external agent");
|
|
7074
7314
|
throw error;
|
|
7075
7315
|
}
|
|
7076
7316
|
});
|
|
7077
7317
|
await Promise.all(externalAgentPromises);
|
|
7078
|
-
const externalAgentCount = Object.entries(typedGraphDefinition.
|
|
7318
|
+
const externalAgentCount = Object.entries(typedGraphDefinition.subAgents).filter(
|
|
7079
7319
|
([_, agentData]) => isExternalAgent(agentData)
|
|
7080
7320
|
).length;
|
|
7081
7321
|
logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
|
|
7082
|
-
const incomingAgentIds = new Set(Object.keys(typedGraphDefinition.
|
|
7083
|
-
const existingInternalAgents = await
|
|
7322
|
+
const incomingAgentIds = new Set(Object.keys(typedGraphDefinition.subAgents));
|
|
7323
|
+
const existingInternalAgents = await listSubAgents(db)({
|
|
7084
7324
|
scopes: { tenantId, projectId, graphId: finalGraphId }
|
|
7085
7325
|
});
|
|
7086
7326
|
const existingExternalAgents = await listExternalAgents(db)({
|
|
@@ -7090,14 +7330,17 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7090
7330
|
for (const agent of existingInternalAgents) {
|
|
7091
7331
|
if (!incomingAgentIds.has(agent.id)) {
|
|
7092
7332
|
try {
|
|
7093
|
-
await
|
|
7333
|
+
await deleteSubAgent(db)({
|
|
7094
7334
|
scopes: { tenantId, projectId, graphId: finalGraphId },
|
|
7095
|
-
|
|
7335
|
+
subAgentId: agent.id
|
|
7096
7336
|
});
|
|
7097
7337
|
deletedInternalCount++;
|
|
7098
|
-
logger13.info({
|
|
7338
|
+
logger13.info({ subAgentId: agent.id }, "Deleted orphaned internal agent");
|
|
7099
7339
|
} catch (error) {
|
|
7100
|
-
logger13.error(
|
|
7340
|
+
logger13.error(
|
|
7341
|
+
{ subAgentId: agent.id, error },
|
|
7342
|
+
"Failed to delete orphaned internal agent"
|
|
7343
|
+
);
|
|
7101
7344
|
}
|
|
7102
7345
|
}
|
|
7103
7346
|
}
|
|
@@ -7107,12 +7350,15 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7107
7350
|
try {
|
|
7108
7351
|
await deleteExternalAgent(db)({
|
|
7109
7352
|
scopes: { tenantId, projectId, graphId: finalGraphId },
|
|
7110
|
-
|
|
7353
|
+
subAgentId: agent.id
|
|
7111
7354
|
});
|
|
7112
7355
|
deletedExternalCount++;
|
|
7113
|
-
logger13.info({
|
|
7356
|
+
logger13.info({ subAgentId: agent.id }, "Deleted orphaned external agent");
|
|
7114
7357
|
} catch (error) {
|
|
7115
|
-
logger13.error(
|
|
7358
|
+
logger13.error(
|
|
7359
|
+
{ subAgentId: agent.id, error },
|
|
7360
|
+
"Failed to delete orphaned external agent"
|
|
7361
|
+
);
|
|
7116
7362
|
}
|
|
7117
7363
|
}
|
|
7118
7364
|
}
|
|
@@ -7130,7 +7376,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7130
7376
|
scopes: { tenantId, projectId, graphId: typedGraphDefinition.id },
|
|
7131
7377
|
data: {
|
|
7132
7378
|
name: typedGraphDefinition.name,
|
|
7133
|
-
|
|
7379
|
+
defaultSubAgentId: typedGraphDefinition.defaultSubAgentId,
|
|
7134
7380
|
description: typedGraphDefinition.description,
|
|
7135
7381
|
contextConfigId,
|
|
7136
7382
|
models: typedGraphDefinition.models,
|
|
@@ -7141,7 +7387,7 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7141
7387
|
});
|
|
7142
7388
|
logger13.info({ graphId: typedGraphDefinition.id }, "Graph metadata updated");
|
|
7143
7389
|
const incomingRelationshipIds = /* @__PURE__ */ new Set();
|
|
7144
|
-
for (const [
|
|
7390
|
+
for (const [_subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
|
|
7145
7391
|
if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
|
|
7146
7392
|
for (const canUseItem of agentData.canUse) {
|
|
7147
7393
|
if (canUseItem.agentToolRelationId) {
|
|
@@ -7150,63 +7396,63 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7150
7396
|
}
|
|
7151
7397
|
}
|
|
7152
7398
|
}
|
|
7153
|
-
for (const
|
|
7399
|
+
for (const subAgentId of Object.keys(typedGraphDefinition.subAgents)) {
|
|
7154
7400
|
try {
|
|
7155
7401
|
let deletedCount = 0;
|
|
7156
7402
|
if (incomingRelationshipIds.size === 0) {
|
|
7157
|
-
const result = await db.delete(
|
|
7403
|
+
const result = await db.delete(subAgentToolRelations).where(
|
|
7158
7404
|
drizzleOrm.and(
|
|
7159
|
-
drizzleOrm.eq(
|
|
7160
|
-
drizzleOrm.eq(
|
|
7161
|
-
drizzleOrm.eq(
|
|
7162
|
-
drizzleOrm.eq(
|
|
7405
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, tenantId),
|
|
7406
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, projectId),
|
|
7407
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, finalGraphId),
|
|
7408
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, subAgentId)
|
|
7163
7409
|
)
|
|
7164
7410
|
);
|
|
7165
7411
|
deletedCount = result.rowsAffected || 0;
|
|
7166
7412
|
} else {
|
|
7167
|
-
const result = await db.delete(
|
|
7413
|
+
const result = await db.delete(subAgentToolRelations).where(
|
|
7168
7414
|
drizzleOrm.and(
|
|
7169
|
-
drizzleOrm.eq(
|
|
7170
|
-
drizzleOrm.eq(
|
|
7171
|
-
drizzleOrm.eq(
|
|
7172
|
-
drizzleOrm.eq(
|
|
7173
|
-
drizzleOrm.not(drizzleOrm.inArray(
|
|
7415
|
+
drizzleOrm.eq(subAgentToolRelations.tenantId, tenantId),
|
|
7416
|
+
drizzleOrm.eq(subAgentToolRelations.projectId, projectId),
|
|
7417
|
+
drizzleOrm.eq(subAgentToolRelations.graphId, finalGraphId),
|
|
7418
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, subAgentId),
|
|
7419
|
+
drizzleOrm.not(drizzleOrm.inArray(subAgentToolRelations.id, Array.from(incomingRelationshipIds)))
|
|
7174
7420
|
)
|
|
7175
7421
|
);
|
|
7176
7422
|
deletedCount = result.rowsAffected || 0;
|
|
7177
7423
|
}
|
|
7178
7424
|
if (deletedCount > 0) {
|
|
7179
|
-
logger13.info({
|
|
7425
|
+
logger13.info({ subAgentId, deletedCount }, "Deleted orphaned agent-tool relations");
|
|
7180
7426
|
}
|
|
7181
7427
|
} catch (error) {
|
|
7182
|
-
logger13.error({
|
|
7428
|
+
logger13.error({ subAgentId, error }, "Failed to delete orphaned agent-tool relations");
|
|
7183
7429
|
}
|
|
7184
7430
|
}
|
|
7185
7431
|
const agentToolPromises = [];
|
|
7186
|
-
for (const [
|
|
7432
|
+
for (const [subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
|
|
7187
7433
|
if (isInternalAgent(agentData) && agentData.canUse && Array.isArray(agentData.canUse)) {
|
|
7188
7434
|
for (const canUseItem of agentData.canUse) {
|
|
7189
7435
|
agentToolPromises.push(
|
|
7190
7436
|
(async () => {
|
|
7191
7437
|
try {
|
|
7192
7438
|
const { toolId, toolSelection, headers: headers2, agentToolRelationId } = canUseItem;
|
|
7193
|
-
logger13.info({
|
|
7439
|
+
logger13.info({ subAgentId, toolId }, "Processing agent-tool relation");
|
|
7194
7440
|
await upsertAgentToolRelation(db)({
|
|
7195
7441
|
scopes: { tenantId, projectId, graphId: finalGraphId },
|
|
7196
|
-
|
|
7442
|
+
subAgentId,
|
|
7197
7443
|
toolId,
|
|
7198
7444
|
selectedTools: toolSelection || void 0,
|
|
7199
7445
|
headers: headers2 || void 0,
|
|
7200
7446
|
relationId: agentToolRelationId
|
|
7201
7447
|
});
|
|
7202
7448
|
logger13.info(
|
|
7203
|
-
{
|
|
7449
|
+
{ subAgentId, toolId, relationId: agentToolRelationId },
|
|
7204
7450
|
"Agent-tool relation upserted"
|
|
7205
7451
|
);
|
|
7206
7452
|
} catch (error) {
|
|
7207
7453
|
logger13.error(
|
|
7208
7454
|
{
|
|
7209
|
-
|
|
7455
|
+
subAgentId,
|
|
7210
7456
|
toolId: canUseItem.toolId,
|
|
7211
7457
|
relationId: canUseItem.agentToolRelationId,
|
|
7212
7458
|
error
|
|
@@ -7224,26 +7470,29 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7224
7470
|
{ agentToolPromisesCount: agentToolPromises.length },
|
|
7225
7471
|
"All agent-tool relations updated"
|
|
7226
7472
|
);
|
|
7227
|
-
for (const
|
|
7473
|
+
for (const subAgentId of Object.keys(typedGraphDefinition.subAgents)) {
|
|
7228
7474
|
await deleteAgentDataComponentRelationByAgent(db)({
|
|
7229
|
-
scopes: { tenantId, projectId, graphId: finalGraphId,
|
|
7475
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId }
|
|
7230
7476
|
});
|
|
7231
7477
|
}
|
|
7232
7478
|
const agentDataComponentPromises = [];
|
|
7233
|
-
for (const [
|
|
7479
|
+
for (const [subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
|
|
7234
7480
|
if (isInternalAgent(agentData) && agentData.dataComponents) {
|
|
7235
7481
|
for (const dataComponentId of agentData.dataComponents) {
|
|
7236
7482
|
agentDataComponentPromises.push(
|
|
7237
7483
|
(async () => {
|
|
7238
7484
|
try {
|
|
7239
7485
|
await associateDataComponentWithAgent(db)({
|
|
7240
|
-
scopes: { tenantId, projectId, graphId: finalGraphId,
|
|
7486
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
|
|
7241
7487
|
dataComponentId
|
|
7242
7488
|
});
|
|
7243
|
-
logger13.info(
|
|
7489
|
+
logger13.info(
|
|
7490
|
+
{ subAgentId, dataComponentId },
|
|
7491
|
+
"Agent-dataComponent relation created"
|
|
7492
|
+
);
|
|
7244
7493
|
} catch (error) {
|
|
7245
7494
|
logger13.error(
|
|
7246
|
-
{
|
|
7495
|
+
{ subAgentId, dataComponentId, error },
|
|
7247
7496
|
"Failed to create agent-dataComponent relation"
|
|
7248
7497
|
);
|
|
7249
7498
|
}
|
|
@@ -7257,29 +7506,29 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7257
7506
|
{ agentDataComponentPromisesCount: agentDataComponentPromises.length },
|
|
7258
7507
|
"All agent-dataComponent relations updated"
|
|
7259
7508
|
);
|
|
7260
|
-
for (const
|
|
7509
|
+
for (const subAgentId of Object.keys(typedGraphDefinition.subAgents)) {
|
|
7261
7510
|
await deleteAgentArtifactComponentRelationByAgent(db)({
|
|
7262
|
-
scopes: { tenantId, projectId, graphId: finalGraphId,
|
|
7511
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId }
|
|
7263
7512
|
});
|
|
7264
7513
|
}
|
|
7265
7514
|
const agentArtifactComponentPromises = [];
|
|
7266
|
-
for (const [
|
|
7515
|
+
for (const [subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
|
|
7267
7516
|
if (isInternalAgent(agentData) && agentData.artifactComponents) {
|
|
7268
7517
|
for (const artifactComponentId of agentData.artifactComponents) {
|
|
7269
7518
|
agentArtifactComponentPromises.push(
|
|
7270
7519
|
(async () => {
|
|
7271
7520
|
try {
|
|
7272
7521
|
await associateArtifactComponentWithAgent(db)({
|
|
7273
|
-
scopes: { tenantId, projectId, graphId: finalGraphId,
|
|
7522
|
+
scopes: { tenantId, projectId, graphId: finalGraphId, subAgentId },
|
|
7274
7523
|
artifactComponentId
|
|
7275
7524
|
});
|
|
7276
7525
|
logger13.info(
|
|
7277
|
-
{
|
|
7526
|
+
{ subAgentId, artifactComponentId },
|
|
7278
7527
|
"Agent-artifactComponent relation created"
|
|
7279
7528
|
);
|
|
7280
7529
|
} catch (error) {
|
|
7281
7530
|
logger13.error(
|
|
7282
|
-
{
|
|
7531
|
+
{ subAgentId, artifactComponentId, error },
|
|
7283
7532
|
"Failed to create agent-artifactComponent relation"
|
|
7284
7533
|
);
|
|
7285
7534
|
}
|
|
@@ -7297,34 +7546,34 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7297
7546
|
scopes: { tenantId, projectId, graphId: typedGraphDefinition.id }
|
|
7298
7547
|
});
|
|
7299
7548
|
const agentRelationPromises = [];
|
|
7300
|
-
for (const [
|
|
7549
|
+
for (const [subAgentId, agentData] of Object.entries(typedGraphDefinition.subAgents)) {
|
|
7301
7550
|
if (isInternalAgent(agentData) && agentData.canTransferTo) {
|
|
7302
|
-
for (const
|
|
7551
|
+
for (const targetSubAgentId of agentData.canTransferTo) {
|
|
7303
7552
|
agentRelationPromises.push(
|
|
7304
7553
|
(async () => {
|
|
7305
7554
|
try {
|
|
7306
|
-
const targetAgentData = typedGraphDefinition.
|
|
7555
|
+
const targetAgentData = typedGraphDefinition.subAgents[targetSubAgentId];
|
|
7307
7556
|
const isTargetExternal = isExternalAgent(targetAgentData);
|
|
7308
|
-
const targetField = isTargetExternal ? "
|
|
7557
|
+
const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
|
|
7309
7558
|
const relationData = {
|
|
7310
7559
|
id: nanoid.nanoid(),
|
|
7311
7560
|
graphId: typedGraphDefinition.id || "",
|
|
7312
|
-
|
|
7561
|
+
sourceSubAgentId: subAgentId,
|
|
7313
7562
|
relationType: "transfer",
|
|
7314
|
-
[targetField]:
|
|
7563
|
+
[targetField]: targetSubAgentId
|
|
7315
7564
|
};
|
|
7316
|
-
await
|
|
7565
|
+
await createSubAgentRelation(db)({
|
|
7317
7566
|
tenantId,
|
|
7318
7567
|
projectId,
|
|
7319
7568
|
...relationData
|
|
7320
7569
|
});
|
|
7321
7570
|
logger13.info(
|
|
7322
|
-
{
|
|
7571
|
+
{ subAgentId, targetSubAgentId, isTargetExternal },
|
|
7323
7572
|
"Transfer relation created"
|
|
7324
7573
|
);
|
|
7325
7574
|
} catch (error) {
|
|
7326
7575
|
logger13.error(
|
|
7327
|
-
{
|
|
7576
|
+
{ subAgentId, targetSubAgentId, error },
|
|
7328
7577
|
"Failed to create transfer relation"
|
|
7329
7578
|
);
|
|
7330
7579
|
}
|
|
@@ -7333,29 +7582,29 @@ var updateFullGraphServerSide = (db, logger13 = defaultLogger) => async (scopes,
|
|
|
7333
7582
|
}
|
|
7334
7583
|
}
|
|
7335
7584
|
if (isInternalAgent(agentData) && agentData.canDelegateTo) {
|
|
7336
|
-
for (const
|
|
7337
|
-
const targetAgentData = typedGraphDefinition.
|
|
7585
|
+
for (const targetSubAgentId of agentData.canDelegateTo) {
|
|
7586
|
+
const targetAgentData = typedGraphDefinition.subAgents[targetSubAgentId];
|
|
7338
7587
|
const isTargetExternal = isExternalAgent(targetAgentData);
|
|
7339
|
-
const targetField = isTargetExternal ? "
|
|
7588
|
+
const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
|
|
7340
7589
|
agentRelationPromises.push(
|
|
7341
7590
|
(async () => {
|
|
7342
7591
|
try {
|
|
7343
7592
|
const relationData = {
|
|
7344
7593
|
id: nanoid.nanoid(),
|
|
7345
7594
|
graphId: typedGraphDefinition.id || "",
|
|
7346
|
-
|
|
7595
|
+
sourceSubAgentId: subAgentId,
|
|
7347
7596
|
relationType: "delegate",
|
|
7348
|
-
[targetField]:
|
|
7597
|
+
[targetField]: targetSubAgentId
|
|
7349
7598
|
};
|
|
7350
|
-
await
|
|
7599
|
+
await createSubAgentRelation(db)({
|
|
7351
7600
|
tenantId,
|
|
7352
7601
|
projectId,
|
|
7353
7602
|
...relationData
|
|
7354
7603
|
});
|
|
7355
|
-
logger13.info({
|
|
7604
|
+
logger13.info({ subAgentId, targetSubAgentId }, "Delegation relation created");
|
|
7356
7605
|
} catch (error) {
|
|
7357
7606
|
logger13.error(
|
|
7358
|
-
{
|
|
7607
|
+
{ subAgentId, targetSubAgentId, error },
|
|
7359
7608
|
"Failed to create delegation relation"
|
|
7360
7609
|
);
|
|
7361
7610
|
}
|
|
@@ -7398,7 +7647,7 @@ var getFullGraph = (db, logger13 = defaultLogger) => async (params) => {
|
|
|
7398
7647
|
{
|
|
7399
7648
|
tenantId,
|
|
7400
7649
|
graphId: scopes.graphId,
|
|
7401
|
-
agentCount: Object.keys(graph.
|
|
7650
|
+
agentCount: Object.keys(graph.subAgents).length
|
|
7402
7651
|
},
|
|
7403
7652
|
"Full graph retrieved successfully"
|
|
7404
7653
|
);
|
|
@@ -7430,15 +7679,15 @@ var deleteFullGraph = (db, logger13 = defaultLogger) => async (params) => {
|
|
|
7430
7679
|
scopes: { tenantId, projectId, graphId }
|
|
7431
7680
|
});
|
|
7432
7681
|
logger13.info({ tenantId, graphId }, "Agent relations deleted");
|
|
7433
|
-
const
|
|
7434
|
-
if (
|
|
7435
|
-
for (const
|
|
7682
|
+
const subAgentIds = Object.keys(graph.subAgents);
|
|
7683
|
+
if (subAgentIds.length > 0) {
|
|
7684
|
+
for (const subAgentId of subAgentIds) {
|
|
7436
7685
|
await deleteAgentToolRelationByAgent(db)({
|
|
7437
|
-
scopes: { tenantId, projectId, graphId,
|
|
7686
|
+
scopes: { tenantId, projectId, graphId, subAgentId }
|
|
7438
7687
|
});
|
|
7439
7688
|
}
|
|
7440
7689
|
logger13.info(
|
|
7441
|
-
{ tenantId, graphId, agentCount:
|
|
7690
|
+
{ tenantId, graphId, agentCount: subAgentIds.length },
|
|
7442
7691
|
"Agent-tool relations deleted"
|
|
7443
7692
|
);
|
|
7444
7693
|
}
|
|
@@ -7837,15 +8086,15 @@ var listProjects = (db) => async (params) => {
|
|
|
7837
8086
|
return projectsFromTable.map((p) => ({ projectId: p.projectId }));
|
|
7838
8087
|
}
|
|
7839
8088
|
const projectIdSets = await Promise.all([
|
|
7840
|
-
db.selectDistinct({ projectId:
|
|
8089
|
+
db.selectDistinct({ projectId: subAgents.projectId }).from(subAgents).where(drizzleOrm.eq(subAgents.tenantId, params.tenantId)),
|
|
7841
8090
|
db.selectDistinct({ projectId: agentGraph.projectId }).from(agentGraph).where(drizzleOrm.eq(agentGraph.tenantId, params.tenantId)),
|
|
7842
8091
|
db.selectDistinct({ projectId: tools.projectId }).from(tools).where(drizzleOrm.eq(tools.tenantId, params.tenantId)),
|
|
7843
8092
|
db.selectDistinct({ projectId: contextConfigs.projectId }).from(contextConfigs).where(drizzleOrm.eq(contextConfigs.tenantId, params.tenantId)),
|
|
7844
8093
|
db.selectDistinct({ projectId: externalAgents.projectId }).from(externalAgents).where(drizzleOrm.eq(externalAgents.tenantId, params.tenantId)),
|
|
7845
|
-
db.selectDistinct({ projectId:
|
|
7846
|
-
db.selectDistinct({ projectId:
|
|
7847
|
-
db.selectDistinct({ projectId:
|
|
7848
|
-
db.selectDistinct({ projectId:
|
|
8094
|
+
db.selectDistinct({ projectId: subAgentRelations.projectId }).from(subAgentRelations).where(drizzleOrm.eq(subAgentRelations.tenantId, params.tenantId)),
|
|
8095
|
+
db.selectDistinct({ projectId: subAgentToolRelations.projectId }).from(subAgentToolRelations).where(drizzleOrm.eq(subAgentToolRelations.tenantId, params.tenantId)),
|
|
8096
|
+
db.selectDistinct({ projectId: subAgentDataComponents.projectId }).from(subAgentDataComponents).where(drizzleOrm.eq(subAgentDataComponents.tenantId, params.tenantId)),
|
|
8097
|
+
db.selectDistinct({ projectId: subAgentArtifactComponents.projectId }).from(subAgentArtifactComponents).where(drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.tenantId)),
|
|
7849
8098
|
db.selectDistinct({ projectId: dataComponents.projectId }).from(dataComponents).where(drizzleOrm.eq(dataComponents.tenantId, params.tenantId)),
|
|
7850
8099
|
db.selectDistinct({ projectId: artifactComponents.projectId }).from(artifactComponents).where(drizzleOrm.eq(artifactComponents.tenantId, params.tenantId)),
|
|
7851
8100
|
db.selectDistinct({ projectId: tasks.projectId }).from(tasks).where(drizzleOrm.eq(tasks.tenantId, params.tenantId)),
|
|
@@ -7885,7 +8134,7 @@ var listProjectsPaginated = (db) => async (params) => {
|
|
|
7885
8134
|
var getProjectResourceCounts = (db) => async (params) => {
|
|
7886
8135
|
const whereClause = (table) => drizzleOrm.and(drizzleOrm.eq(table.tenantId, params.tenantId), drizzleOrm.eq(table.projectId, params.projectId));
|
|
7887
8136
|
const [agentResults, graphResults, toolResults, contextConfigResults, externalAgentResults] = await Promise.all([
|
|
7888
|
-
db.select({ count:
|
|
8137
|
+
db.select({ count: subAgents.id }).from(subAgents).where(whereClause(subAgents)),
|
|
7889
8138
|
db.select({ count: agentGraph.id }).from(agentGraph).where(whereClause(agentGraph)),
|
|
7890
8139
|
db.select({ count: tools.id }).from(tools).where(whereClause(tools)),
|
|
7891
8140
|
db.select({ count: contextConfigs.id }).from(contextConfigs).where(whereClause(contextConfigs)),
|
|
@@ -7902,7 +8151,7 @@ var getProjectResourceCounts = (db) => async (params) => {
|
|
|
7902
8151
|
var projectExists = (db) => async (params) => {
|
|
7903
8152
|
const whereClause = (table) => drizzleOrm.and(drizzleOrm.eq(table.tenantId, params.tenantId), drizzleOrm.eq(table.projectId, params.projectId));
|
|
7904
8153
|
const checks = [
|
|
7905
|
-
db.select({ id:
|
|
8154
|
+
db.select({ id: subAgents.id }).from(subAgents).where(whereClause(subAgents)).limit(1),
|
|
7906
8155
|
db.select({ id: agentGraph.id }).from(agentGraph).where(whereClause(agentGraph)).limit(1),
|
|
7907
8156
|
db.select({ id: tools.id }).from(tools).where(whereClause(tools)).limit(1),
|
|
7908
8157
|
db.select({ id: contextConfigs.id }).from(contextConfigs).where(whereClause(contextConfigs)).limit(1),
|
|
@@ -8009,8 +8258,8 @@ async function cascadeStopWhenUpdates(db, scopes, oldStopWhen, newStopWhen) {
|
|
|
8009
8258
|
}
|
|
8010
8259
|
}
|
|
8011
8260
|
if (oldStopWhen?.stepCountIs !== newStopWhen?.stepCountIs) {
|
|
8012
|
-
const agentsToUpdate = await db.query.
|
|
8013
|
-
where: drizzleOrm.and(drizzleOrm.eq(
|
|
8261
|
+
const agentsToUpdate = await db.query.subAgents.findMany({
|
|
8262
|
+
where: drizzleOrm.and(drizzleOrm.eq(subAgents.tenantId, tenantId), drizzleOrm.eq(subAgents.projectId, projectId))
|
|
8014
8263
|
});
|
|
8015
8264
|
for (const agent of agentsToUpdate) {
|
|
8016
8265
|
const agentStopWhen = agent.stopWhen;
|
|
@@ -8019,14 +8268,14 @@ async function cascadeStopWhenUpdates(db, scopes, oldStopWhen, newStopWhen) {
|
|
|
8019
8268
|
...agentStopWhen || {},
|
|
8020
8269
|
stepCountIs: newStopWhen?.stepCountIs
|
|
8021
8270
|
};
|
|
8022
|
-
await db.update(
|
|
8271
|
+
await db.update(subAgents).set({
|
|
8023
8272
|
stopWhen: updatedStopWhen,
|
|
8024
8273
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8025
8274
|
}).where(
|
|
8026
8275
|
drizzleOrm.and(
|
|
8027
|
-
drizzleOrm.eq(
|
|
8028
|
-
drizzleOrm.eq(
|
|
8029
|
-
drizzleOrm.eq(
|
|
8276
|
+
drizzleOrm.eq(subAgents.tenantId, tenantId),
|
|
8277
|
+
drizzleOrm.eq(subAgents.projectId, projectId),
|
|
8278
|
+
drizzleOrm.eq(subAgents.id, agent.id)
|
|
8030
8279
|
)
|
|
8031
8280
|
);
|
|
8032
8281
|
}
|
|
@@ -8278,6 +8527,10 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
|
|
|
8278
8527
|
logger13.info({ projectId: typed.id, graphId }, "Creating graph in project");
|
|
8279
8528
|
const graphDataWithProjectResources = {
|
|
8280
8529
|
...graphData,
|
|
8530
|
+
agents: void 0,
|
|
8531
|
+
// Remove 'agents' property from GraphWithinContextOfProjectSchema
|
|
8532
|
+
subAgents: graphData.subAgents,
|
|
8533
|
+
// Map 'agents' to 'subAgents' for FullGraphDefinitionSchema
|
|
8281
8534
|
tools: typed.tools || {},
|
|
8282
8535
|
// Pass project-level resources for validation
|
|
8283
8536
|
dataComponents: typed.dataComponents || {},
|
|
@@ -8617,6 +8870,10 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
|
|
|
8617
8870
|
logger13.info({ projectId: typed.id, graphId }, "Updating graph in project");
|
|
8618
8871
|
const graphDataWithProjectResources = {
|
|
8619
8872
|
...graphData,
|
|
8873
|
+
agents: void 0,
|
|
8874
|
+
// Remove 'agents' property from GraphWithinContextOfProjectSchema
|
|
8875
|
+
subAgents: graphData.subAgents,
|
|
8876
|
+
// Map 'agents' to 'subAgents' for FullGraphDefinitionSchema
|
|
8620
8877
|
tools: typed.tools || {},
|
|
8621
8878
|
// Pass project-level resources for validation
|
|
8622
8879
|
dataComponents: typed.dataComponents || {},
|
|
@@ -9720,7 +9977,7 @@ async function validateHeaders({
|
|
|
9720
9977
|
credentialStores
|
|
9721
9978
|
}) {
|
|
9722
9979
|
try {
|
|
9723
|
-
const agentGraph2 = await
|
|
9980
|
+
const agentGraph2 = await getAgentGraphWithDefaultSubAgent(dbClient)({
|
|
9724
9981
|
scopes: { tenantId, projectId, graphId }
|
|
9725
9982
|
});
|
|
9726
9983
|
if (!agentGraph2?.contextConfigId) {
|
|
@@ -10283,7 +10540,7 @@ async function handleContextResolution({
|
|
|
10283
10540
|
let agentGraph2;
|
|
10284
10541
|
let trigger;
|
|
10285
10542
|
try {
|
|
10286
|
-
agentGraph2 = await
|
|
10543
|
+
agentGraph2 = await getAgentGraphWithDefaultSubAgent(dbClient)({
|
|
10287
10544
|
scopes: { tenantId, projectId, graphId }
|
|
10288
10545
|
});
|
|
10289
10546
|
if (!agentGraph2?.contextConfigId) {
|
|
@@ -11211,6 +11468,43 @@ ${error.message}`
|
|
|
11211
11468
|
}
|
|
11212
11469
|
};
|
|
11213
11470
|
parseEnv();
|
|
11471
|
+
var TransferDataSchema = zod.z.object({
|
|
11472
|
+
fromSubAgent: zod.z.string().describe("ID of the sub-agent transferring control"),
|
|
11473
|
+
targetSubAgent: zod.z.string().describe("ID of the sub-agent receiving control"),
|
|
11474
|
+
reason: zod.z.string().optional().describe("Reason for the transfer"),
|
|
11475
|
+
context: zod.z.any().optional().describe("Additional context data")
|
|
11476
|
+
});
|
|
11477
|
+
var DelegationSentDataSchema = zod.z.object({
|
|
11478
|
+
delegationId: zod.z.string().describe("Unique identifier for this delegation"),
|
|
11479
|
+
fromSubAgent: zod.z.string().describe("ID of the delegating sub-agent"),
|
|
11480
|
+
targetSubAgent: zod.z.string().describe("ID of the sub-agent receiving the delegation"),
|
|
11481
|
+
taskDescription: zod.z.string().describe("Description of the delegated task"),
|
|
11482
|
+
context: zod.z.any().optional().describe("Additional context data")
|
|
11483
|
+
});
|
|
11484
|
+
var DelegationReturnedDataSchema = zod.z.object({
|
|
11485
|
+
delegationId: zod.z.string().describe("Unique identifier matching the original delegation"),
|
|
11486
|
+
fromSubAgent: zod.z.string().describe("ID of the sub-agent that completed the task"),
|
|
11487
|
+
targetSubAgent: zod.z.string().describe("ID of the sub-agent receiving the result"),
|
|
11488
|
+
result: zod.z.any().optional().describe("Result data from the delegated task")
|
|
11489
|
+
});
|
|
11490
|
+
var DataOperationDetailsSchema = zod.z.object({
|
|
11491
|
+
timestamp: zod.z.number().describe("Unix timestamp in milliseconds"),
|
|
11492
|
+
subAgentId: zod.z.string().describe("ID of the sub-agent that generated this data"),
|
|
11493
|
+
data: zod.z.any().describe("The actual data payload")
|
|
11494
|
+
});
|
|
11495
|
+
var DataOperationEventSchema = zod.z.object({
|
|
11496
|
+
type: zod.z.string().describe("Event type identifier"),
|
|
11497
|
+
label: zod.z.string().describe("Human-readable label for the event"),
|
|
11498
|
+
details: DataOperationDetailsSchema
|
|
11499
|
+
});
|
|
11500
|
+
var A2AMessageMetadataSchema = zod.z.object({
|
|
11501
|
+
fromSubAgentId: zod.z.string().optional().describe("ID of the sending sub-agent"),
|
|
11502
|
+
toSubAgentId: zod.z.string().optional().describe("ID of the receiving sub-agent"),
|
|
11503
|
+
fromExternalAgentId: zod.z.string().optional().describe("ID of the sending external agent"),
|
|
11504
|
+
toExternalAgentId: zod.z.string().optional().describe("ID of the receiving external agent"),
|
|
11505
|
+
taskId: zod.z.string().optional().describe("Associated task ID"),
|
|
11506
|
+
a2aTaskId: zod.z.string().optional().describe("A2A-specific task ID")
|
|
11507
|
+
});
|
|
11214
11508
|
|
|
11215
11509
|
// src/validation/id-validation.ts
|
|
11216
11510
|
function isValidResourceId(id) {
|
|
@@ -11230,9 +11524,14 @@ function generateIdFromName(name) {
|
|
|
11230
11524
|
return truncatedId;
|
|
11231
11525
|
}
|
|
11232
11526
|
|
|
11233
|
-
exports.
|
|
11234
|
-
exports.
|
|
11235
|
-
exports.
|
|
11527
|
+
exports.A2AMessageMetadataSchema = A2AMessageMetadataSchema;
|
|
11528
|
+
exports.ACTIVITY_NAMES = ACTIVITY_NAMES;
|
|
11529
|
+
exports.ACTIVITY_STATUS = ACTIVITY_STATUS;
|
|
11530
|
+
exports.ACTIVITY_TYPES = ACTIVITY_TYPES;
|
|
11531
|
+
exports.AGENT_IDS = AGENT_IDS;
|
|
11532
|
+
exports.AGGREGATE_OPERATORS = AGGREGATE_OPERATORS;
|
|
11533
|
+
exports.AI_OPERATIONS = AI_OPERATIONS;
|
|
11534
|
+
exports.AI_TOOL_TYPES = AI_TOOL_TYPES;
|
|
11236
11535
|
exports.AgentArtifactComponentApiInsertSchema = AgentArtifactComponentApiInsertSchema;
|
|
11237
11536
|
exports.AgentArtifactComponentApiSelectSchema = AgentArtifactComponentApiSelectSchema;
|
|
11238
11537
|
exports.AgentArtifactComponentApiUpdateSchema = AgentArtifactComponentApiUpdateSchema;
|
|
@@ -11251,7 +11550,6 @@ exports.AgentGraphApiUpdateSchema = AgentGraphApiUpdateSchema;
|
|
|
11251
11550
|
exports.AgentGraphInsertSchema = AgentGraphInsertSchema;
|
|
11252
11551
|
exports.AgentGraphSelectSchema = AgentGraphSelectSchema;
|
|
11253
11552
|
exports.AgentGraphUpdateSchema = AgentGraphUpdateSchema;
|
|
11254
|
-
exports.AgentInsertSchema = AgentInsertSchema;
|
|
11255
11553
|
exports.AgentRelationApiInsertSchema = AgentRelationApiInsertSchema;
|
|
11256
11554
|
exports.AgentRelationApiSelectSchema = AgentRelationApiSelectSchema;
|
|
11257
11555
|
exports.AgentRelationApiUpdateSchema = AgentRelationApiUpdateSchema;
|
|
@@ -11259,7 +11557,6 @@ exports.AgentRelationInsertSchema = AgentRelationInsertSchema;
|
|
|
11259
11557
|
exports.AgentRelationQuerySchema = AgentRelationQuerySchema;
|
|
11260
11558
|
exports.AgentRelationSelectSchema = AgentRelationSelectSchema;
|
|
11261
11559
|
exports.AgentRelationUpdateSchema = AgentRelationUpdateSchema;
|
|
11262
|
-
exports.AgentSelectSchema = AgentSelectSchema;
|
|
11263
11560
|
exports.AgentStopWhenSchema = AgentStopWhenSchema;
|
|
11264
11561
|
exports.AgentToolRelationApiInsertSchema = AgentToolRelationApiInsertSchema;
|
|
11265
11562
|
exports.AgentToolRelationApiSelectSchema = AgentToolRelationApiSelectSchema;
|
|
@@ -11267,7 +11564,6 @@ exports.AgentToolRelationApiUpdateSchema = AgentToolRelationApiUpdateSchema;
|
|
|
11267
11564
|
exports.AgentToolRelationInsertSchema = AgentToolRelationInsertSchema;
|
|
11268
11565
|
exports.AgentToolRelationSelectSchema = AgentToolRelationSelectSchema;
|
|
11269
11566
|
exports.AgentToolRelationUpdateSchema = AgentToolRelationUpdateSchema;
|
|
11270
|
-
exports.AgentUpdateSchema = AgentUpdateSchema;
|
|
11271
11567
|
exports.AllAgentSchema = AllAgentSchema;
|
|
11272
11568
|
exports.ApiKeyApiCreationResponseSchema = ApiKeyApiCreationResponseSchema;
|
|
11273
11569
|
exports.ApiKeyApiInsertSchema = ApiKeyApiInsertSchema;
|
|
@@ -11314,6 +11610,11 @@ exports.CredentialReferenceUpdateSchema = CredentialReferenceUpdateSchema;
|
|
|
11314
11610
|
exports.CredentialStoreRegistry = CredentialStoreRegistry;
|
|
11315
11611
|
exports.CredentialStoreType = CredentialStoreType;
|
|
11316
11612
|
exports.CredentialStuffer = CredentialStuffer;
|
|
11613
|
+
exports.DATA_SOURCES = DATA_SOURCES;
|
|
11614
|
+
exports.DATA_TYPES = DATA_TYPES;
|
|
11615
|
+
exports.DELEGATION_FROM_SUB_AGENT_ID = DELEGATION_FROM_SUB_AGENT_ID;
|
|
11616
|
+
exports.DELEGATION_ID = DELEGATION_ID;
|
|
11617
|
+
exports.DELEGATION_TO_SUB_AGENT_ID = DELEGATION_TO_SUB_AGENT_ID;
|
|
11317
11618
|
exports.DataComponentApiInsertSchema = DataComponentApiInsertSchema;
|
|
11318
11619
|
exports.DataComponentApiSelectSchema = DataComponentApiSelectSchema;
|
|
11319
11620
|
exports.DataComponentApiUpdateSchema = DataComponentApiUpdateSchema;
|
|
@@ -11321,6 +11622,10 @@ exports.DataComponentBaseSchema = DataComponentBaseSchema;
|
|
|
11321
11622
|
exports.DataComponentInsertSchema = DataComponentInsertSchema;
|
|
11322
11623
|
exports.DataComponentSelectSchema = DataComponentSelectSchema;
|
|
11323
11624
|
exports.DataComponentUpdateSchema = DataComponentUpdateSchema;
|
|
11625
|
+
exports.DataOperationDetailsSchema = DataOperationDetailsSchema;
|
|
11626
|
+
exports.DataOperationEventSchema = DataOperationEventSchema;
|
|
11627
|
+
exports.DelegationReturnedDataSchema = DelegationReturnedDataSchema;
|
|
11628
|
+
exports.DelegationSentDataSchema = DelegationSentDataSchema;
|
|
11324
11629
|
exports.ERROR_DOCS_BASE_URL = ERROR_DOCS_BASE_URL;
|
|
11325
11630
|
exports.ErrorCode = ErrorCode;
|
|
11326
11631
|
exports.ErrorResponseSchema = ErrorResponseSchema;
|
|
@@ -11333,10 +11638,10 @@ exports.ExternalAgentRelationApiInsertSchema = ExternalAgentRelationApiInsertSch
|
|
|
11333
11638
|
exports.ExternalAgentRelationInsertSchema = ExternalAgentRelationInsertSchema;
|
|
11334
11639
|
exports.ExternalAgentSelectSchema = ExternalAgentSelectSchema;
|
|
11335
11640
|
exports.ExternalAgentUpdateSchema = ExternalAgentUpdateSchema;
|
|
11641
|
+
exports.FIELD_TYPES = FIELD_TYPES;
|
|
11336
11642
|
exports.FetchConfigSchema = FetchConfigSchema;
|
|
11337
11643
|
exports.FetchDefinitionSchema = FetchDefinitionSchema;
|
|
11338
11644
|
exports.FullGraphAgentInsertSchema = FullGraphAgentInsertSchema;
|
|
11339
|
-
exports.FullGraphDefinitionSchema = FullGraphDefinitionSchema;
|
|
11340
11645
|
exports.FullProjectDefinitionSchema = FullProjectDefinitionSchema;
|
|
11341
11646
|
exports.FunctionApiInsertSchema = FunctionApiInsertSchema;
|
|
11342
11647
|
exports.FunctionApiSelectSchema = FunctionApiSelectSchema;
|
|
@@ -11349,7 +11654,6 @@ exports.GraphStopWhenSchema = GraphStopWhenSchema;
|
|
|
11349
11654
|
exports.GraphWithinContextOfProjectSchema = GraphWithinContextOfProjectSchema;
|
|
11350
11655
|
exports.HTTP_REQUEST_PARTS = HTTP_REQUEST_PARTS;
|
|
11351
11656
|
exports.HeadersScopeSchema = HeadersScopeSchema;
|
|
11352
|
-
exports.IdParamsSchema = IdParamsSchema;
|
|
11353
11657
|
exports.InMemoryCredentialStore = InMemoryCredentialStore;
|
|
11354
11658
|
exports.KeyChainStore = KeyChainStore;
|
|
11355
11659
|
exports.LedgerArtifactApiInsertSchema = LedgerArtifactApiInsertSchema;
|
|
@@ -11377,6 +11681,9 @@ exports.MessageUpdateSchema = MessageUpdateSchema;
|
|
|
11377
11681
|
exports.ModelSchema = ModelSchema;
|
|
11378
11682
|
exports.ModelSettingsSchema = ModelSettingsSchema;
|
|
11379
11683
|
exports.NangoCredentialStore = NangoCredentialStore;
|
|
11684
|
+
exports.OPERATORS = OPERATORS;
|
|
11685
|
+
exports.ORDER_DIRECTIONS = ORDER_DIRECTIONS;
|
|
11686
|
+
exports.PANEL_TYPES = PANEL_TYPES;
|
|
11380
11687
|
exports.PaginationQueryParamsSchema = PaginationQueryParamsSchema;
|
|
11381
11688
|
exports.PaginationSchema = PaginationSchema;
|
|
11382
11689
|
exports.PinoLogger = PinoLogger;
|
|
@@ -11387,13 +11694,29 @@ exports.ProjectInsertSchema = ProjectInsertSchema;
|
|
|
11387
11694
|
exports.ProjectModelSchema = ProjectModelSchema;
|
|
11388
11695
|
exports.ProjectSelectSchema = ProjectSelectSchema;
|
|
11389
11696
|
exports.ProjectUpdateSchema = ProjectUpdateSchema;
|
|
11697
|
+
exports.QUERY_DEFAULTS = QUERY_DEFAULTS;
|
|
11698
|
+
exports.QUERY_EXPRESSIONS = QUERY_EXPRESSIONS;
|
|
11699
|
+
exports.QUERY_FIELD_CONFIGS = QUERY_FIELD_CONFIGS;
|
|
11700
|
+
exports.QUERY_TYPES = QUERY_TYPES;
|
|
11701
|
+
exports.REDUCE_OPERATIONS = REDUCE_OPERATIONS;
|
|
11390
11702
|
exports.RemovedResponseSchema = RemovedResponseSchema;
|
|
11703
|
+
exports.SPAN_KEYS = SPAN_KEYS;
|
|
11704
|
+
exports.SPAN_NAMES = SPAN_NAMES;
|
|
11391
11705
|
exports.SandboxConfigSchema = SandboxConfigSchema;
|
|
11392
11706
|
exports.SingleResponseSchema = SingleResponseSchema;
|
|
11393
11707
|
exports.StatusComponentSchema = StatusComponentSchema;
|
|
11394
11708
|
exports.StatusUpdateSchema = StatusUpdateSchema;
|
|
11395
11709
|
exports.StopWhenSchema = StopWhenSchema;
|
|
11710
|
+
exports.SubAgentApiInsertSchema = SubAgentApiInsertSchema;
|
|
11711
|
+
exports.SubAgentApiSelectSchema = SubAgentApiSelectSchema;
|
|
11712
|
+
exports.SubAgentApiUpdateSchema = SubAgentApiUpdateSchema;
|
|
11713
|
+
exports.SubAgentInsertSchema = SubAgentInsertSchema;
|
|
11714
|
+
exports.SubAgentSelectSchema = SubAgentSelectSchema;
|
|
11715
|
+
exports.SubAgentUpdateSchema = SubAgentUpdateSchema;
|
|
11716
|
+
exports.TOOL_NAMES = TOOL_NAMES;
|
|
11396
11717
|
exports.TOOL_STATUS_VALUES = TOOL_STATUS_VALUES;
|
|
11718
|
+
exports.TRANSFER_FROM_SUB_AGENT_ID = TRANSFER_FROM_SUB_AGENT_ID;
|
|
11719
|
+
exports.TRANSFER_TO_SUB_AGENT_ID = TRANSFER_TO_SUB_AGENT_ID;
|
|
11397
11720
|
exports.TaskApiInsertSchema = TaskApiInsertSchema;
|
|
11398
11721
|
exports.TaskApiSelectSchema = TaskApiSelectSchema;
|
|
11399
11722
|
exports.TaskApiUpdateSchema = TaskApiUpdateSchema;
|
|
@@ -11412,6 +11735,8 @@ exports.TenantIdParamsSchema = TenantIdParamsSchema;
|
|
|
11412
11735
|
exports.TenantParamsSchema = TenantParamsSchema;
|
|
11413
11736
|
exports.TenantProjectGraphIdParamsSchema = TenantProjectGraphIdParamsSchema;
|
|
11414
11737
|
exports.TenantProjectGraphParamsSchema = TenantProjectGraphParamsSchema;
|
|
11738
|
+
exports.TenantProjectGraphSubAgentIdParamsSchema = TenantProjectGraphSubAgentIdParamsSchema;
|
|
11739
|
+
exports.TenantProjectGraphSubAgentParamsSchema = TenantProjectGraphSubAgentParamsSchema;
|
|
11415
11740
|
exports.TenantProjectIdParamsSchema = TenantProjectIdParamsSchema;
|
|
11416
11741
|
exports.TenantProjectParamsSchema = TenantProjectParamsSchema;
|
|
11417
11742
|
exports.ToolApiInsertSchema = ToolApiInsertSchema;
|
|
@@ -11421,22 +11746,15 @@ exports.ToolInsertSchema = ToolInsertSchema;
|
|
|
11421
11746
|
exports.ToolSelectSchema = ToolSelectSchema;
|
|
11422
11747
|
exports.ToolStatusSchema = ToolStatusSchema;
|
|
11423
11748
|
exports.ToolUpdateSchema = ToolUpdateSchema;
|
|
11749
|
+
exports.TransferDataSchema = TransferDataSchema;
|
|
11750
|
+
exports.UNKNOWN_VALUE = UNKNOWN_VALUE;
|
|
11424
11751
|
exports.URL_SAFE_ID_PATTERN = URL_SAFE_ID_PATTERN;
|
|
11425
11752
|
exports.VALID_RELATION_TYPES = VALID_RELATION_TYPES;
|
|
11426
11753
|
exports.addLedgerArtifacts = addLedgerArtifacts;
|
|
11427
11754
|
exports.addToolToAgent = addToolToAgent;
|
|
11428
|
-
exports.agentArtifactComponents = agentArtifactComponents;
|
|
11429
|
-
exports.agentArtifactComponentsRelations = agentArtifactComponentsRelations;
|
|
11430
|
-
exports.agentDataComponents = agentDataComponents;
|
|
11431
|
-
exports.agentDataComponentsRelations = agentDataComponentsRelations;
|
|
11432
11755
|
exports.agentGraph = agentGraph;
|
|
11433
11756
|
exports.agentGraphRelations = agentGraphRelations;
|
|
11434
|
-
exports.agentRelations = agentRelations;
|
|
11435
|
-
exports.agentRelationsRelations = agentRelationsRelations;
|
|
11436
|
-
exports.agentToolRelations = agentToolRelations;
|
|
11437
11757
|
exports.agentToolRelationsRelations = agentToolRelationsRelations;
|
|
11438
|
-
exports.agents = agents;
|
|
11439
|
-
exports.agentsRelations = agentsRelations;
|
|
11440
11758
|
exports.apiFetch = apiFetch;
|
|
11441
11759
|
exports.apiKeys = apiKeys;
|
|
11442
11760
|
exports.apiKeysRelations = apiKeysRelations;
|
|
@@ -11471,9 +11789,7 @@ exports.countExternalAgents = countExternalAgents;
|
|
|
11471
11789
|
exports.countLedgerArtifactsByTask = countLedgerArtifactsByTask;
|
|
11472
11790
|
exports.countMessagesByConversation = countMessagesByConversation;
|
|
11473
11791
|
exports.countProjects = countProjects;
|
|
11474
|
-
exports.createAgent = createAgent;
|
|
11475
11792
|
exports.createAgentGraph = createAgentGraph;
|
|
11476
|
-
exports.createAgentRelation = createAgentRelation;
|
|
11477
11793
|
exports.createAgentToolRelation = createAgentToolRelation;
|
|
11478
11794
|
exports.createApiError = createApiError;
|
|
11479
11795
|
exports.createApiKey = createApiKey;
|
|
@@ -11495,6 +11811,8 @@ exports.createMessage = createMessage;
|
|
|
11495
11811
|
exports.createNangoCredentialStore = createNangoCredentialStore;
|
|
11496
11812
|
exports.createOrGetConversation = createOrGetConversation;
|
|
11497
11813
|
exports.createProject = createProject;
|
|
11814
|
+
exports.createSubAgent = createSubAgent;
|
|
11815
|
+
exports.createSubAgentRelation = createSubAgentRelation;
|
|
11498
11816
|
exports.createTask = createTask;
|
|
11499
11817
|
exports.createTool = createTool;
|
|
11500
11818
|
exports.createValidatedDataAccess = createValidatedDataAccess;
|
|
@@ -11503,11 +11821,9 @@ exports.credentialReferencesRelations = credentialReferencesRelations;
|
|
|
11503
11821
|
exports.dataComponents = dataComponents;
|
|
11504
11822
|
exports.dataComponentsRelations = dataComponentsRelations;
|
|
11505
11823
|
exports.dbResultToMcpTool = dbResultToMcpTool;
|
|
11506
|
-
exports.deleteAgent = deleteAgent;
|
|
11507
11824
|
exports.deleteAgentArtifactComponentRelationByAgent = deleteAgentArtifactComponentRelationByAgent;
|
|
11508
11825
|
exports.deleteAgentDataComponentRelationByAgent = deleteAgentDataComponentRelationByAgent;
|
|
11509
11826
|
exports.deleteAgentGraph = deleteAgentGraph;
|
|
11510
|
-
exports.deleteAgentRelation = deleteAgentRelation;
|
|
11511
11827
|
exports.deleteAgentRelationsByGraph = deleteAgentRelationsByGraph;
|
|
11512
11828
|
exports.deleteAgentToolRelation = deleteAgentToolRelation;
|
|
11513
11829
|
exports.deleteAgentToolRelationByAgent = deleteAgentToolRelationByAgent;
|
|
@@ -11525,6 +11841,8 @@ exports.deleteLedgerArtifactsByContext = deleteLedgerArtifactsByContext;
|
|
|
11525
11841
|
exports.deleteLedgerArtifactsByTask = deleteLedgerArtifactsByTask;
|
|
11526
11842
|
exports.deleteMessage = deleteMessage;
|
|
11527
11843
|
exports.deleteProject = deleteProject;
|
|
11844
|
+
exports.deleteSubAgent = deleteSubAgent;
|
|
11845
|
+
exports.deleteSubAgentRelation = deleteSubAgentRelation;
|
|
11528
11846
|
exports.deleteTool = deleteTool;
|
|
11529
11847
|
exports.detectAuthenticationRequired = detectAuthenticationRequired;
|
|
11530
11848
|
exports.determineContextTrigger = determineContextTrigger;
|
|
@@ -11546,9 +11864,8 @@ exports.generateApiKey = generateApiKey;
|
|
|
11546
11864
|
exports.generateId = generateId;
|
|
11547
11865
|
exports.generateIdFromName = generateIdFromName;
|
|
11548
11866
|
exports.getActiveAgentForConversation = getActiveAgentForConversation;
|
|
11549
|
-
exports.getAgentById = getAgentById;
|
|
11550
11867
|
exports.getAgentGraphById = getAgentGraphById;
|
|
11551
|
-
exports.
|
|
11868
|
+
exports.getAgentGraphWithDefaultSubAgent = getAgentGraphWithDefaultSubAgent;
|
|
11552
11869
|
exports.getAgentRelationById = getAgentRelationById;
|
|
11553
11870
|
exports.getAgentRelationByParams = getAgentRelationByParams;
|
|
11554
11871
|
exports.getAgentRelations = getAgentRelations;
|
|
@@ -11558,7 +11875,6 @@ exports.getAgentRelationsByTarget = getAgentRelationsByTarget;
|
|
|
11558
11875
|
exports.getAgentToolRelationByAgent = getAgentToolRelationByAgent;
|
|
11559
11876
|
exports.getAgentToolRelationById = getAgentToolRelationById;
|
|
11560
11877
|
exports.getAgentToolRelationByTool = getAgentToolRelationByTool;
|
|
11561
|
-
exports.getAgentsByIds = getAgentsByIds;
|
|
11562
11878
|
exports.getAgentsForTool = getAgentsForTool;
|
|
11563
11879
|
exports.getAgentsUsingArtifactComponent = getAgentsUsingArtifactComponent;
|
|
11564
11880
|
exports.getAgentsUsingDataComponent = getAgentsUsingDataComponent;
|
|
@@ -11598,6 +11914,8 @@ exports.getProject = getProject;
|
|
|
11598
11914
|
exports.getProjectResourceCounts = getProjectResourceCounts;
|
|
11599
11915
|
exports.getRelatedAgentsForGraph = getRelatedAgentsForGraph;
|
|
11600
11916
|
exports.getRequestExecutionContext = getRequestExecutionContext;
|
|
11917
|
+
exports.getSubAgentById = getSubAgentById;
|
|
11918
|
+
exports.getSubAgentsByIds = getSubAgentsByIds;
|
|
11601
11919
|
exports.getTask = getTask;
|
|
11602
11920
|
exports.getToolById = getToolById;
|
|
11603
11921
|
exports.getToolsForAgent = getToolsForAgent;
|
|
@@ -11628,8 +11946,6 @@ exports.listAgentGraphs = listAgentGraphs;
|
|
|
11628
11946
|
exports.listAgentGraphsPaginated = listAgentGraphsPaginated;
|
|
11629
11947
|
exports.listAgentRelations = listAgentRelations;
|
|
11630
11948
|
exports.listAgentToolRelations = listAgentToolRelations;
|
|
11631
|
-
exports.listAgents = listAgents;
|
|
11632
|
-
exports.listAgentsPaginated = listAgentsPaginated;
|
|
11633
11949
|
exports.listApiKeys = listApiKeys;
|
|
11634
11950
|
exports.listApiKeysPaginated = listApiKeysPaginated;
|
|
11635
11951
|
exports.listArtifactComponents = listArtifactComponents;
|
|
@@ -11647,6 +11963,8 @@ exports.listFunctions = listFunctions;
|
|
|
11647
11963
|
exports.listMessages = listMessages;
|
|
11648
11964
|
exports.listProjects = listProjects;
|
|
11649
11965
|
exports.listProjectsPaginated = listProjectsPaginated;
|
|
11966
|
+
exports.listSubAgents = listSubAgents;
|
|
11967
|
+
exports.listSubAgentsPaginated = listSubAgentsPaginated;
|
|
11650
11968
|
exports.listTaskIdsByContextId = listTaskIdsByContextId;
|
|
11651
11969
|
exports.listTools = listTools;
|
|
11652
11970
|
exports.loadEnvironmentFiles = loadEnvironmentFiles;
|
|
@@ -11669,13 +11987,21 @@ exports.setActiveAgentForConversation = setActiveAgentForConversation;
|
|
|
11669
11987
|
exports.setActiveAgentForThread = setActiveAgentForThread;
|
|
11670
11988
|
exports.setCacheEntry = setCacheEntry;
|
|
11671
11989
|
exports.setSpanWithError = setSpanWithError;
|
|
11990
|
+
exports.subAgentArtifactComponents = subAgentArtifactComponents;
|
|
11991
|
+
exports.subAgentArtifactComponentsRelations = subAgentArtifactComponentsRelations;
|
|
11992
|
+
exports.subAgentDataComponents = subAgentDataComponents;
|
|
11993
|
+
exports.subAgentDataComponentsRelations = subAgentDataComponentsRelations;
|
|
11994
|
+
exports.subAgentRelations = subAgentRelations;
|
|
11995
|
+
exports.subAgentRelationsRelations = subAgentRelationsRelations;
|
|
11996
|
+
exports.subAgentToolRelations = subAgentToolRelations;
|
|
11997
|
+
exports.subAgents = subAgents;
|
|
11998
|
+
exports.subAgentsRelations = subAgentsRelations;
|
|
11672
11999
|
exports.taskRelations = taskRelations;
|
|
11673
12000
|
exports.taskRelationsRelations = taskRelationsRelations;
|
|
11674
12001
|
exports.tasks = tasks;
|
|
11675
12002
|
exports.tasksRelations = tasksRelations;
|
|
11676
12003
|
exports.tools = tools;
|
|
11677
12004
|
exports.toolsRelations = toolsRelations;
|
|
11678
|
-
exports.updateAgent = updateAgent;
|
|
11679
12005
|
exports.updateAgentGraph = updateAgentGraph;
|
|
11680
12006
|
exports.updateAgentRelation = updateAgentRelation;
|
|
11681
12007
|
exports.updateAgentToolRelation = updateAgentToolRelation;
|
|
@@ -11692,9 +12018,9 @@ exports.updateFullGraphServerSide = updateFullGraphServerSide;
|
|
|
11692
12018
|
exports.updateFullProjectServerSide = updateFullProjectServerSide;
|
|
11693
12019
|
exports.updateMessage = updateMessage;
|
|
11694
12020
|
exports.updateProject = updateProject;
|
|
12021
|
+
exports.updateSubAgent = updateSubAgent;
|
|
11695
12022
|
exports.updateTask = updateTask;
|
|
11696
12023
|
exports.updateTool = updateTool;
|
|
11697
|
-
exports.upsertAgent = upsertAgent;
|
|
11698
12024
|
exports.upsertAgentArtifactComponentRelation = upsertAgentArtifactComponentRelation;
|
|
11699
12025
|
exports.upsertAgentDataComponentRelation = upsertAgentDataComponentRelation;
|
|
11700
12026
|
exports.upsertAgentGraph = upsertAgentGraph;
|
|
@@ -11707,6 +12033,7 @@ exports.upsertDataComponent = upsertDataComponent;
|
|
|
11707
12033
|
exports.upsertExternalAgent = upsertExternalAgent;
|
|
11708
12034
|
exports.upsertFunction = upsertFunction;
|
|
11709
12035
|
exports.upsertLedgerArtifact = upsertLedgerArtifact;
|
|
12036
|
+
exports.upsertSubAgent = upsertSubAgent;
|
|
11710
12037
|
exports.upsertTool = upsertTool;
|
|
11711
12038
|
exports.validateAgainstJsonSchema = validateAgainstJsonSchema;
|
|
11712
12039
|
exports.validateAgentRelationships = validateAgentRelationships;
|
|
@@ -11719,7 +12046,7 @@ exports.validateExternalAgent = validateExternalAgent;
|
|
|
11719
12046
|
exports.validateGraphStructure = validateGraphStructure;
|
|
11720
12047
|
exports.validateHeaders = validateHeaders;
|
|
11721
12048
|
exports.validateHttpRequestHeaders = validateHttpRequestHeaders;
|
|
11722
|
-
exports.
|
|
12049
|
+
exports.validateInternalSubAgent = validateInternalSubAgent;
|
|
11723
12050
|
exports.validateProjectExists = validateProjectExists;
|
|
11724
12051
|
exports.validatePropsAsJsonSchema = validatePropsAsJsonSchema;
|
|
11725
12052
|
exports.validateToolReferences = validateToolReferences;
|