@inkeep/agents-core 0.0.0-dev-20251012022558 → 0.0.0-dev-20251012052609
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 +4 -4
- package/dist/{chunk-ASA7FU3H.js → chunk-3GZBRBXP.js} +84 -87
- package/dist/{chunk-JK3LPVOW.js → chunk-3XUV5Q4D.js} +34 -34
- package/dist/{chunk-OEKS3RQI.js → chunk-B6F3RF4T.js} +86 -119
- package/dist/{chunk-H6PMWHNV.js → chunk-SLL6V3AE.js} +12 -12
- package/dist/client-exports.cjs +189 -225
- package/dist/client-exports.d.cts +13 -14
- package/dist/client-exports.d.ts +13 -14
- package/dist/client-exports.js +10 -10
- package/dist/db/schema.cjs +85 -118
- package/dist/db/schema.d.cts +2 -3
- package/dist/db/schema.d.ts +2 -3
- package/dist/db/schema.js +1 -1
- package/dist/index.cjs +983 -1038
- package/dist/index.d.cts +208 -208
- package/dist/index.d.ts +208 -208
- package/dist/index.js +744 -762
- package/dist/{schema-ULFEZCOL.d.cts → schema-Dp-qgdBT.d.ts} +54 -52
- package/dist/{schema-wbZXiVWb.d.ts → schema-DrDaCn6H.d.cts} +54 -52
- package/dist/{signoz-queries-BuiipZTk.d.cts → signoz-queries-CuWMQh1H.d.cts} +10 -10
- package/dist/{signoz-queries-BuiipZTk.d.ts → signoz-queries-CuWMQh1H.d.ts} +10 -10
- package/dist/types/index.d.cts +2 -3
- package/dist/types/index.d.ts +2 -3
- package/dist/{utility-CyPQ1tC_.d.cts → utility-BxbySenH.d.cts} +152 -301
- package/dist/{utility-CyPQ1tC_.d.ts → utility-BxbySenH.d.ts} +152 -301
- package/dist/validation/index.cjs +212 -249
- package/dist/validation/index.d.cts +12 -13
- package/dist/validation/index.d.ts +12 -13
- package/dist/validation/index.js +2 -2
- package/drizzle/0007_mighty_typhoid_mary.sql +227 -0
- package/drizzle/meta/0007_snapshot.json +2766 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -212935,7 +212935,7 @@ var SPAN_NAMES = {
|
|
|
212935
212935
|
CONTEXT_HANDLE: "context.handle_context_resolution",
|
|
212936
212936
|
AGENT_GENERATION: "agent.generate",
|
|
212937
212937
|
CONTEXT_FETCHER: "context-fetcher.http-request",
|
|
212938
|
-
ARTIFACT_PROCESSING: "
|
|
212938
|
+
ARTIFACT_PROCESSING: "agent_session.process_artifact"
|
|
212939
212939
|
};
|
|
212940
212940
|
var AI_OPERATIONS = {
|
|
212941
212941
|
GENERATE_TEXT: "ai.generateText.doGenerate",
|
|
@@ -212951,14 +212951,14 @@ var SPAN_KEYS = {
|
|
|
212951
212951
|
STATUS_MESSAGE: "status_message",
|
|
212952
212952
|
OTEL_STATUS_CODE: "otel.status_code",
|
|
212953
212953
|
OTEL_STATUS_DESCRIPTION: "otel.status_description",
|
|
212954
|
-
//
|
|
212955
|
-
|
|
212956
|
-
|
|
212954
|
+
// Agent attributesa
|
|
212955
|
+
AGENT_ID: "agent.id",
|
|
212956
|
+
AGENT_NAME: "agent.name",
|
|
212957
212957
|
TENANT_ID: "tenant.id",
|
|
212958
212958
|
PROJECT_ID: "project.id",
|
|
212959
212959
|
// AI/Agent attributes
|
|
212960
|
-
|
|
212961
|
-
|
|
212960
|
+
AI_SUB_AGENT_NAME: "ai.subAgentName",
|
|
212961
|
+
AI_SUB_AGENT_NAME_ALT: "ai.subAgent.name",
|
|
212962
212962
|
AI_OPERATION_ID: "ai.operationId",
|
|
212963
212963
|
AI_RESPONSE_TIMESTAMP: "ai.response.timestamp",
|
|
212964
212964
|
AI_RESPONSE_CONTENT: "ai.response.content",
|
|
@@ -212976,16 +212976,16 @@ var SPAN_KEYS = {
|
|
|
212976
212976
|
AI_TOOL_CALL_ID: "ai.toolCall.id",
|
|
212977
212977
|
AI_TOOL_TYPE: "ai.toolType",
|
|
212978
212978
|
TOOL_PURPOSE: "tool.purpose",
|
|
212979
|
-
//
|
|
212980
|
-
|
|
212981
|
-
|
|
212979
|
+
// SubAgent attributes
|
|
212980
|
+
SUB_AGENT_ID: "subagent.id",
|
|
212981
|
+
SUB_AGENT_NAME: "subagent.name",
|
|
212982
212982
|
// Token usage
|
|
212983
212983
|
GEN_AI_USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens",
|
|
212984
212984
|
GEN_AI_USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens",
|
|
212985
212985
|
// Context attributes
|
|
212986
212986
|
CONTEXT_URL: "context.url",
|
|
212987
212987
|
CONTEXT_CONFIG_ID: "context.context_config_id",
|
|
212988
|
-
|
|
212988
|
+
CONTEXT_AGENT_ID: "context.agent_id",
|
|
212989
212989
|
CONTEXT_HEADERS_KEYS: "context.headers_keys",
|
|
212990
212990
|
// Message attributes
|
|
212991
212991
|
MESSAGE_CONTENT: "message.content",
|
|
@@ -213137,7 +213137,7 @@ var QUERY_EXPRESSIONS = {
|
|
|
213137
213137
|
CONTEXT_ERRORS: "contextErrors",
|
|
213138
213138
|
AGENT_GENERATION_ERRORS: "agentGenerationErrors",
|
|
213139
213139
|
USER_MESSAGES: "userMessages",
|
|
213140
|
-
|
|
213140
|
+
UNIQUE_AGENTS: "uniqueAgents",
|
|
213141
213141
|
UNIQUE_MODELS: "uniqueModels",
|
|
213142
213142
|
// Route-specific query names
|
|
213143
213143
|
TOOL_CALLS: "toolCalls",
|
|
@@ -213171,7 +213171,7 @@ var QUERY_TYPES = {
|
|
|
213171
213171
|
var PANEL_TYPES = {
|
|
213172
213172
|
LIST: "list",
|
|
213173
213173
|
TABLE: "table",
|
|
213174
|
-
|
|
213174
|
+
AGENT: "agent",
|
|
213175
213175
|
VALUE: "value"
|
|
213176
213176
|
};
|
|
213177
213177
|
var DATA_SOURCES = {
|
|
@@ -213423,9 +213423,9 @@ var schema_exports = {};
|
|
|
213423
213423
|
__export(schema_exports, {
|
|
213424
213424
|
agentFunctionToolRelations: () => agentFunctionToolRelations,
|
|
213425
213425
|
agentFunctionToolRelationsRelations: () => agentFunctionToolRelationsRelations,
|
|
213426
|
-
|
|
213427
|
-
agentGraphRelations: () => agentGraphRelations,
|
|
213426
|
+
agentRelations: () => agentRelations,
|
|
213428
213427
|
agentToolRelationsRelations: () => agentToolRelationsRelations,
|
|
213428
|
+
agents: () => agents,
|
|
213429
213429
|
apiKeys: () => apiKeys,
|
|
213430
213430
|
apiKeysRelations: () => apiKeysRelations,
|
|
213431
213431
|
artifactComponents: () => artifactComponents,
|
|
@@ -213476,12 +213476,12 @@ var projectScoped = {
|
|
|
213476
213476
|
...tenantScoped,
|
|
213477
213477
|
projectId: sqliteCore.text("project_id").notNull()
|
|
213478
213478
|
};
|
|
213479
|
-
var
|
|
213479
|
+
var agentScoped = {
|
|
213480
213480
|
...projectScoped,
|
|
213481
|
-
|
|
213481
|
+
agentId: sqliteCore.text("agent_id").notNull()
|
|
213482
213482
|
};
|
|
213483
213483
|
var subAgentScoped = {
|
|
213484
|
-
...
|
|
213484
|
+
...agentScoped,
|
|
213485
213485
|
subAgentId: sqliteCore.text("sub_agent_id").notNull()
|
|
213486
213486
|
};
|
|
213487
213487
|
var uiProperties = {
|
|
@@ -213497,9 +213497,9 @@ var projects = sqliteCore.sqliteTable(
|
|
|
213497
213497
|
{
|
|
213498
213498
|
...tenantScoped,
|
|
213499
213499
|
...uiProperties,
|
|
213500
|
-
// Project-level default model settings that can be inherited by
|
|
213500
|
+
// Project-level default model settings that can be inherited by agents
|
|
213501
213501
|
models: sqliteCore.text("models", { mode: "json" }).$type(),
|
|
213502
|
-
// Project-level stopWhen configuration that can be inherited by
|
|
213502
|
+
// Project-level stopWhen configuration that can be inherited by agents
|
|
213503
213503
|
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
213504
213504
|
// Project-level sandbox configuration for function execution
|
|
213505
213505
|
sandboxConfig: sqliteCore.text("sandbox_config", { mode: "json" }).$type(),
|
|
@@ -213507,23 +213507,17 @@ var projects = sqliteCore.sqliteTable(
|
|
|
213507
213507
|
},
|
|
213508
213508
|
(table) => [sqliteCore.primaryKey({ columns: [table.tenantId, table.id] })]
|
|
213509
213509
|
);
|
|
213510
|
-
var
|
|
213511
|
-
"
|
|
213510
|
+
var agents = sqliteCore.sqliteTable(
|
|
213511
|
+
"agent",
|
|
213512
213512
|
{
|
|
213513
213513
|
...projectScoped,
|
|
213514
213514
|
name: sqliteCore.text("name").notNull(),
|
|
213515
213515
|
description: sqliteCore.text("description"),
|
|
213516
213516
|
defaultSubAgentId: sqliteCore.text("default_sub_agent_id"),
|
|
213517
|
-
// Reference to shared context configuration for all agents in this graph
|
|
213518
213517
|
contextConfigId: sqliteCore.text("context_config_id"),
|
|
213519
|
-
// add fk relationship
|
|
213520
|
-
// Graph-level model settingsuration that can be inherited by agents
|
|
213521
213518
|
models: sqliteCore.text("models", { mode: "json" }).$type(),
|
|
213522
|
-
// Status updates configuration for intelligent progress summaries
|
|
213523
213519
|
statusUpdates: sqliteCore.text("status_updates", { mode: "json" }).$type(),
|
|
213524
|
-
|
|
213525
|
-
graphPrompt: sqliteCore.text("graph_prompt"),
|
|
213526
|
-
// Graph-level stopWhen configuration that can be inherited by agents
|
|
213520
|
+
prompt: sqliteCore.text("prompt"),
|
|
213527
213521
|
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
213528
213522
|
...timestamps
|
|
213529
213523
|
},
|
|
@@ -213532,27 +213526,26 @@ var agentGraph = sqliteCore.sqliteTable(
|
|
|
213532
213526
|
sqliteCore.foreignKey({
|
|
213533
213527
|
columns: [table.tenantId, table.projectId],
|
|
213534
213528
|
foreignColumns: [projects.tenantId, projects.id],
|
|
213535
|
-
name: "
|
|
213529
|
+
name: "agent_project_fk"
|
|
213536
213530
|
}).onDelete("cascade")
|
|
213537
213531
|
]
|
|
213538
213532
|
);
|
|
213539
213533
|
var contextConfigs = sqliteCore.sqliteTable(
|
|
213540
213534
|
"context_configs",
|
|
213541
213535
|
{
|
|
213542
|
-
...
|
|
213536
|
+
...agentScoped,
|
|
213543
213537
|
// Developer-defined Zod schema for validating incoming request context
|
|
213544
213538
|
headersSchema: sqliteCore.blob("headers_schema", { mode: "json" }).$type(),
|
|
213545
|
-
// Stores serialized Zod schema
|
|
213546
213539
|
// Object mapping template keys to fetch definitions that use request context data
|
|
213547
213540
|
contextVariables: sqliteCore.blob("context_variables", { mode: "json" }).$type(),
|
|
213548
213541
|
...timestamps
|
|
213549
213542
|
},
|
|
213550
213543
|
(table) => [
|
|
213551
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.
|
|
213544
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
213552
213545
|
sqliteCore.foreignKey({
|
|
213553
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213554
|
-
foreignColumns: [
|
|
213555
|
-
name: "
|
|
213546
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
213547
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
213548
|
+
name: "context_configs_agent_fk"
|
|
213556
213549
|
}).onDelete("cascade")
|
|
213557
213550
|
]
|
|
213558
213551
|
);
|
|
@@ -213565,16 +213558,12 @@ var contextCache = sqliteCore.sqliteTable(
|
|
|
213565
213558
|
// Reference to the context config and specific fetch definition
|
|
213566
213559
|
contextConfigId: sqliteCore.text("context_config_id").notNull(),
|
|
213567
213560
|
contextVariableKey: sqliteCore.text("context_variable_key").notNull(),
|
|
213568
|
-
// Key from contextVariables object
|
|
213569
|
-
// The actual cached context data
|
|
213570
213561
|
value: sqliteCore.blob("value", { mode: "json" }).$type().notNull(),
|
|
213571
213562
|
// Request hash for cache invalidation based on context changes
|
|
213572
213563
|
requestHash: sqliteCore.text("request_hash"),
|
|
213573
|
-
// Hash of request context that triggered this cache
|
|
213574
213564
|
// Metadata for monitoring and debugging
|
|
213575
213565
|
fetchedAt: sqliteCore.text("fetched_at").notNull(),
|
|
213576
213566
|
fetchSource: sqliteCore.text("fetch_source"),
|
|
213577
|
-
// URL or source identifier
|
|
213578
213567
|
fetchDurationMs: sqliteCore.integer("fetch_duration_ms"),
|
|
213579
213568
|
...timestamps
|
|
213580
213569
|
},
|
|
@@ -213595,30 +213584,29 @@ var contextCache = sqliteCore.sqliteTable(
|
|
|
213595
213584
|
var subAgents = sqliteCore.sqliteTable(
|
|
213596
213585
|
"sub_agents",
|
|
213597
213586
|
{
|
|
213598
|
-
...
|
|
213587
|
+
...agentScoped,
|
|
213599
213588
|
...uiProperties,
|
|
213600
213589
|
prompt: sqliteCore.text("prompt").notNull(),
|
|
213601
213590
|
conversationHistoryConfig: sqliteCore.text("conversation_history_config", {
|
|
213602
213591
|
mode: "json"
|
|
213603
213592
|
}).$type(),
|
|
213604
213593
|
models: sqliteCore.text("models", { mode: "json" }).$type(),
|
|
213605
|
-
// Agent-level stopWhen configuration (inherited from project)
|
|
213606
213594
|
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
213607
213595
|
...timestamps
|
|
213608
213596
|
},
|
|
213609
213597
|
(table) => [
|
|
213610
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.
|
|
213598
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
213611
213599
|
sqliteCore.foreignKey({
|
|
213612
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213613
|
-
foreignColumns: [
|
|
213614
|
-
name: "
|
|
213600
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
213601
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
213602
|
+
name: "sub_agents_agents_fk"
|
|
213615
213603
|
}).onDelete("cascade")
|
|
213616
213604
|
]
|
|
213617
213605
|
);
|
|
213618
213606
|
var subAgentRelations = sqliteCore.sqliteTable(
|
|
213619
213607
|
"sub_agent_relations",
|
|
213620
213608
|
{
|
|
213621
|
-
...
|
|
213609
|
+
...agentScoped,
|
|
213622
213610
|
sourceSubAgentId: sqliteCore.text("source_sub_agent_id").notNull(),
|
|
213623
213611
|
// For internal relationships
|
|
213624
213612
|
targetSubAgentId: sqliteCore.text("target_sub_agent_id"),
|
|
@@ -213628,31 +213616,30 @@ var subAgentRelations = sqliteCore.sqliteTable(
|
|
|
213628
213616
|
...timestamps
|
|
213629
213617
|
},
|
|
213630
213618
|
(table) => [
|
|
213631
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.
|
|
213619
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
213632
213620
|
sqliteCore.foreignKey({
|
|
213633
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213634
|
-
foreignColumns: [
|
|
213635
|
-
name: "
|
|
213621
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
213622
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
213623
|
+
name: "sub_agent_relations_agent_fk"
|
|
213636
213624
|
}).onDelete("cascade")
|
|
213637
213625
|
]
|
|
213638
213626
|
);
|
|
213639
213627
|
var externalAgents = sqliteCore.sqliteTable(
|
|
213640
213628
|
"external_agents",
|
|
213641
213629
|
{
|
|
213642
|
-
...
|
|
213630
|
+
...agentScoped,
|
|
213643
213631
|
...uiProperties,
|
|
213644
213632
|
baseUrl: sqliteCore.text("base_url").notNull(),
|
|
213645
|
-
// A2A endpoint URL
|
|
213646
213633
|
credentialReferenceId: sqliteCore.text("credential_reference_id"),
|
|
213647
213634
|
headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
|
|
213648
213635
|
...timestamps
|
|
213649
213636
|
},
|
|
213650
213637
|
(table) => [
|
|
213651
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.
|
|
213638
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
213652
213639
|
sqliteCore.foreignKey({
|
|
213653
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213654
|
-
foreignColumns: [
|
|
213655
|
-
name: "
|
|
213640
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
213641
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
213642
|
+
name: "external_agents_agent_fk"
|
|
213656
213643
|
}).onDelete("cascade"),
|
|
213657
213644
|
sqliteCore.foreignKey({
|
|
213658
213645
|
columns: [table.tenantId, table.projectId, table.credentialReferenceId],
|
|
@@ -213677,8 +213664,8 @@ var tasks = sqliteCore.sqliteTable(
|
|
|
213677
213664
|
(table) => [
|
|
213678
213665
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
213679
213666
|
sqliteCore.foreignKey({
|
|
213680
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213681
|
-
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.
|
|
213667
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
213668
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
213682
213669
|
name: "tasks_sub_agent_fk"
|
|
213683
213670
|
}).onDelete("cascade")
|
|
213684
213671
|
]
|
|
@@ -213690,7 +213677,6 @@ var taskRelations = sqliteCore.sqliteTable(
|
|
|
213690
213677
|
parentTaskId: sqliteCore.text("parent_task_id").notNull(),
|
|
213691
213678
|
childTaskId: sqliteCore.text("child_task_id").notNull(),
|
|
213692
213679
|
relationType: sqliteCore.text("relation_type").default("parent_child"),
|
|
213693
|
-
// Could be extended for other relation types
|
|
213694
213680
|
...timestamps
|
|
213695
213681
|
},
|
|
213696
213682
|
(table) => [
|
|
@@ -213728,13 +213714,11 @@ var subAgentDataComponents = sqliteCore.sqliteTable(
|
|
|
213728
213714
|
},
|
|
213729
213715
|
(table) => [
|
|
213730
213716
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
213731
|
-
// Foreign key constraint to agents table (ensures graph and project exist via cascade)
|
|
213732
213717
|
sqliteCore.foreignKey({
|
|
213733
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213734
|
-
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.
|
|
213718
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
213719
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
213735
213720
|
name: "sub_agent_data_components_sub_agent_fk"
|
|
213736
213721
|
}).onDelete("cascade"),
|
|
213737
|
-
// Foreign key constraint to data_components table
|
|
213738
213722
|
sqliteCore.foreignKey({
|
|
213739
213723
|
columns: [table.tenantId, table.projectId, table.dataComponentId],
|
|
213740
213724
|
foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
|
|
@@ -213768,15 +213752,13 @@ var subAgentArtifactComponents = sqliteCore.sqliteTable(
|
|
|
213768
213752
|
},
|
|
213769
213753
|
(table) => [
|
|
213770
213754
|
sqliteCore.primaryKey({
|
|
213771
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213755
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId, table.id]
|
|
213772
213756
|
}),
|
|
213773
|
-
// Foreign key constraint to agents table (ensures graph and project exist via cascade)
|
|
213774
213757
|
sqliteCore.foreignKey({
|
|
213775
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213776
|
-
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.
|
|
213758
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
213759
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
213777
213760
|
name: "sub_agent_artifact_components_sub_agent_fk"
|
|
213778
213761
|
}).onDelete("cascade"),
|
|
213779
|
-
// Foreign key constraint to artifact_components table
|
|
213780
213762
|
sqliteCore.foreignKey({
|
|
213781
213763
|
columns: [table.tenantId, table.projectId, table.artifactComponentId],
|
|
213782
213764
|
foreignColumns: [
|
|
@@ -213816,18 +213798,18 @@ var tools = sqliteCore.sqliteTable(
|
|
|
213816
213798
|
var functionTools = sqliteCore.sqliteTable(
|
|
213817
213799
|
"function_tools",
|
|
213818
213800
|
{
|
|
213819
|
-
...
|
|
213801
|
+
...agentScoped,
|
|
213820
213802
|
name: sqliteCore.text("name").notNull(),
|
|
213821
213803
|
description: sqliteCore.text("description"),
|
|
213822
213804
|
functionId: sqliteCore.text("function_id").notNull(),
|
|
213823
213805
|
...timestamps
|
|
213824
213806
|
},
|
|
213825
213807
|
(table) => [
|
|
213826
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.
|
|
213808
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
213827
213809
|
sqliteCore.foreignKey({
|
|
213828
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213829
|
-
foreignColumns: [
|
|
213830
|
-
name: "
|
|
213810
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
213811
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
213812
|
+
name: "function_tools_agent_fk"
|
|
213831
213813
|
}).onDelete("cascade"),
|
|
213832
213814
|
// Foreign key constraint to functions table
|
|
213833
213815
|
sqliteCore.foreignKey({
|
|
@@ -213865,14 +213847,12 @@ var subAgentToolRelations = sqliteCore.sqliteTable(
|
|
|
213865
213847
|
...timestamps
|
|
213866
213848
|
},
|
|
213867
213849
|
(table) => [
|
|
213868
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.
|
|
213869
|
-
// Foreign key constraint to agents table (which includes project and graph scope)
|
|
213850
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
213870
213851
|
sqliteCore.foreignKey({
|
|
213871
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213872
|
-
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.
|
|
213852
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
213853
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
213873
213854
|
name: "sub_agent_tool_relations_agent_fk"
|
|
213874
213855
|
}).onDelete("cascade"),
|
|
213875
|
-
// Foreign key constraint to tools table (MCP tools)
|
|
213876
213856
|
sqliteCore.foreignKey({
|
|
213877
213857
|
columns: [table.tenantId, table.projectId, table.toolId],
|
|
213878
213858
|
foreignColumns: [tools.tenantId, tools.projectId, tools.id],
|
|
@@ -213888,20 +213868,20 @@ var agentFunctionToolRelations = sqliteCore.sqliteTable(
|
|
|
213888
213868
|
...timestamps
|
|
213889
213869
|
},
|
|
213890
213870
|
(table) => [
|
|
213891
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.
|
|
213871
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
213892
213872
|
// Foreign key constraint to agents table
|
|
213893
213873
|
sqliteCore.foreignKey({
|
|
213894
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213895
|
-
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.
|
|
213874
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
213875
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
213896
213876
|
name: "agent_function_tool_relations_agent_fk"
|
|
213897
213877
|
}).onDelete("cascade"),
|
|
213898
213878
|
// Foreign key constraint to functionTools table
|
|
213899
213879
|
sqliteCore.foreignKey({
|
|
213900
|
-
columns: [table.tenantId, table.projectId, table.
|
|
213880
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.functionToolId],
|
|
213901
213881
|
foreignColumns: [
|
|
213902
213882
|
functionTools.tenantId,
|
|
213903
213883
|
functionTools.projectId,
|
|
213904
|
-
functionTools.
|
|
213884
|
+
functionTools.agentId,
|
|
213905
213885
|
functionTools.id
|
|
213906
213886
|
],
|
|
213907
213887
|
name: "agent_function_tool_relations_function_tool_fk"
|
|
@@ -213935,33 +213915,23 @@ var messages = sqliteCore.sqliteTable(
|
|
|
213935
213915
|
conversationId: sqliteCore.text("conversation_id").notNull(),
|
|
213936
213916
|
// Role mapping: user, agent, system (unified for both formats)
|
|
213937
213917
|
role: sqliteCore.text("role").notNull(),
|
|
213938
|
-
// 'user' | 'agent' | 'system'
|
|
213939
213918
|
// Agent sender/recipient tracking (nullable - only populated when relevant)
|
|
213940
213919
|
fromSubAgentId: sqliteCore.text("from_sub_agent_id"),
|
|
213941
|
-
// Populated when message is from an agent
|
|
213942
213920
|
toSubAgentId: sqliteCore.text("to_sub_agent_id"),
|
|
213943
|
-
// Populated when message is directed to a specific agent (e.g., transfers/delegations)
|
|
213944
213921
|
// External agent sender tracking
|
|
213945
213922
|
fromExternalAgentId: sqliteCore.text("from_external_sub_agent_id"),
|
|
213946
|
-
// Populated when message is directed from an external agent
|
|
213947
213923
|
// External agent recipient tracking
|
|
213948
213924
|
toExternalAgentId: sqliteCore.text("to_external_sub_agent_id"),
|
|
213949
|
-
// Populated when message is directed to an external agent
|
|
213950
213925
|
// Message content stored as JSON to support both formats
|
|
213951
213926
|
content: sqliteCore.blob("content", { mode: "json" }).$type().notNull(),
|
|
213952
213927
|
// Message classification and filtering
|
|
213953
213928
|
visibility: sqliteCore.text("visibility").notNull().default("user-facing"),
|
|
213954
|
-
// 'user-facing' | 'internal' | 'system' | 'external'
|
|
213955
213929
|
messageType: sqliteCore.text("message_type").notNull().default("chat"),
|
|
213956
|
-
// 'chat' | 'a2a-request' | 'a2a-response' | 'task-update' | 'tool-call'
|
|
213957
213930
|
taskId: sqliteCore.text("task_id"),
|
|
213958
213931
|
parentMessageId: sqliteCore.text("parent_message_id"),
|
|
213959
|
-
// Remove self-reference constraint here
|
|
213960
213932
|
// A2A specific fields
|
|
213961
213933
|
a2aTaskId: sqliteCore.text("a2a_task_id"),
|
|
213962
|
-
// Links to A2A task when relevant
|
|
213963
213934
|
a2aSessionId: sqliteCore.text("a2a_session_id"),
|
|
213964
|
-
// A2A session identifier
|
|
213965
213935
|
// Metadata for extensions
|
|
213966
213936
|
metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
|
|
213967
213937
|
...timestamps
|
|
@@ -213982,7 +213952,6 @@ var ledgerArtifacts = sqliteCore.sqliteTable(
|
|
|
213982
213952
|
// Links
|
|
213983
213953
|
taskId: sqliteCore.text("task_id").notNull(),
|
|
213984
213954
|
toolCallId: sqliteCore.text("tool_call_id"),
|
|
213985
|
-
// Added for traceability to the specific tool execution
|
|
213986
213955
|
contextId: sqliteCore.text("context_id").notNull(),
|
|
213987
213956
|
// Core Artifact fields
|
|
213988
213957
|
type: sqliteCore.text("type").notNull().default("source"),
|
|
@@ -214018,13 +213987,10 @@ var ledgerArtifacts = sqliteCore.sqliteTable(
|
|
|
214018
213987
|
var apiKeys = sqliteCore.sqliteTable(
|
|
214019
213988
|
"api_keys",
|
|
214020
213989
|
{
|
|
214021
|
-
...
|
|
213990
|
+
...agentScoped,
|
|
214022
213991
|
publicId: sqliteCore.text("public_id").notNull().unique(),
|
|
214023
|
-
// Public ID for O(1) lookup (e.g., "abc123def456")
|
|
214024
213992
|
keyHash: sqliteCore.text("key_hash").notNull(),
|
|
214025
|
-
// Hashed API key (never store plaintext)
|
|
214026
213993
|
keyPrefix: sqliteCore.text("key_prefix").notNull(),
|
|
214027
|
-
// First 8 chars for identification (e.g., "sk_live_abc...")
|
|
214028
213994
|
name: sqliteCore.text("name"),
|
|
214029
213995
|
lastUsedAt: sqliteCore.text("last_used_at"),
|
|
214030
213996
|
expiresAt: sqliteCore.text("expires_at"),
|
|
@@ -214037,11 +214003,11 @@ var apiKeys = sqliteCore.sqliteTable(
|
|
|
214037
214003
|
name: "api_keys_project_fk"
|
|
214038
214004
|
}).onDelete("cascade"),
|
|
214039
214005
|
sqliteCore.foreignKey({
|
|
214040
|
-
columns: [t.tenantId, t.projectId, t.
|
|
214041
|
-
foreignColumns: [
|
|
214042
|
-
name: "
|
|
214006
|
+
columns: [t.tenantId, t.projectId, t.agentId],
|
|
214007
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
214008
|
+
name: "api_keys_agent_fk"
|
|
214043
214009
|
}).onDelete("cascade"),
|
|
214044
|
-
sqliteCore.index("
|
|
214010
|
+
sqliteCore.index("api_keys_tenant_agent_idx").on(t.tenantId, t.agentId),
|
|
214045
214011
|
sqliteCore.index("api_keys_prefix_idx").on(t.keyPrefix),
|
|
214046
214012
|
sqliteCore.index("api_keys_public_id_idx").on(t.publicId)
|
|
214047
214013
|
]
|
|
@@ -214051,9 +214017,7 @@ var credentialReferences = sqliteCore.sqliteTable(
|
|
|
214051
214017
|
{
|
|
214052
214018
|
...projectScoped,
|
|
214053
214019
|
type: sqliteCore.text("type").notNull(),
|
|
214054
|
-
// Implementation type: 'keychain', 'nango', 'memory', etc.
|
|
214055
214020
|
credentialStoreId: sqliteCore.text("credential_store_id").notNull(),
|
|
214056
|
-
// Maps to framework.getCredentialStore(id)
|
|
214057
214021
|
retrievalParams: sqliteCore.blob("retrieval_params", { mode: "json" }).$type(),
|
|
214058
214022
|
...timestamps
|
|
214059
214023
|
},
|
|
@@ -214067,7 +214031,6 @@ var credentialReferences = sqliteCore.sqliteTable(
|
|
|
214067
214031
|
]
|
|
214068
214032
|
);
|
|
214069
214033
|
var tasksRelations = drizzleOrm.relations(tasks, ({ one, many }) => ({
|
|
214070
|
-
// A task belongs to one project
|
|
214071
214034
|
project: one(projects, {
|
|
214072
214035
|
fields: [tasks.tenantId, tasks.projectId],
|
|
214073
214036
|
references: [projects.tenantId, projects.id]
|
|
@@ -214084,14 +214047,12 @@ var tasksRelations = drizzleOrm.relations(tasks, ({ one, many }) => ({
|
|
|
214084
214047
|
fields: [tasks.subAgentId],
|
|
214085
214048
|
references: [subAgents.id]
|
|
214086
214049
|
}),
|
|
214087
|
-
// A task can have many messages associated with it
|
|
214088
214050
|
messages: many(messages),
|
|
214089
|
-
// A task can have many ledger artifacts
|
|
214090
214051
|
ledgerArtifacts: many(ledgerArtifacts)
|
|
214091
214052
|
}));
|
|
214092
214053
|
var projectsRelations = drizzleOrm.relations(projects, ({ many }) => ({
|
|
214093
214054
|
subAgents: many(subAgents),
|
|
214094
|
-
|
|
214055
|
+
agents: many(agents),
|
|
214095
214056
|
tools: many(tools),
|
|
214096
214057
|
functions: many(functions),
|
|
214097
214058
|
contextConfigs: many(contextConfigs),
|
|
@@ -214120,7 +214081,7 @@ var contextConfigsRelations = drizzleOrm.relations(contextConfigs, ({ many, one
|
|
|
214120
214081
|
fields: [contextConfigs.tenantId, contextConfigs.projectId],
|
|
214121
214082
|
references: [projects.tenantId, projects.id]
|
|
214122
214083
|
}),
|
|
214123
|
-
|
|
214084
|
+
agents: many(agents),
|
|
214124
214085
|
cache: many(contextCache)
|
|
214125
214086
|
}));
|
|
214126
214087
|
var contextCacheRelations = drizzleOrm.relations(contextCache, ({ one }) => ({
|
|
@@ -214135,7 +214096,7 @@ var subAgentsRelations = drizzleOrm.relations(subAgents, ({ many, one }) => ({
|
|
|
214135
214096
|
references: [projects.tenantId, projects.id]
|
|
214136
214097
|
}),
|
|
214137
214098
|
tasks: many(tasks),
|
|
214138
|
-
|
|
214099
|
+
defaultForAgents: many(agents),
|
|
214139
214100
|
sourceRelations: many(subAgentRelations, {
|
|
214140
214101
|
relationName: "sourceRelations"
|
|
214141
214102
|
}),
|
|
@@ -214148,25 +214109,22 @@ var subAgentsRelations = drizzleOrm.relations(subAgents, ({ many, one }) => ({
|
|
|
214148
214109
|
receivedMessages: many(messages, {
|
|
214149
214110
|
relationName: "receivedMessages"
|
|
214150
214111
|
}),
|
|
214151
|
-
associatedMessages: many(messages, {
|
|
214152
|
-
relationName: "associatedAgent"
|
|
214153
|
-
}),
|
|
214154
214112
|
toolRelations: many(subAgentToolRelations),
|
|
214155
214113
|
functionToolRelations: many(agentFunctionToolRelations),
|
|
214156
214114
|
dataComponentRelations: many(subAgentDataComponents),
|
|
214157
214115
|
artifactComponentRelations: many(subAgentArtifactComponents)
|
|
214158
214116
|
}));
|
|
214159
|
-
var
|
|
214117
|
+
var agentRelations = drizzleOrm.relations(agents, ({ one, many }) => ({
|
|
214160
214118
|
project: one(projects, {
|
|
214161
|
-
fields: [
|
|
214119
|
+
fields: [agents.tenantId, agents.projectId],
|
|
214162
214120
|
references: [projects.tenantId, projects.id]
|
|
214163
214121
|
}),
|
|
214164
214122
|
defaultSubAgent: one(subAgents, {
|
|
214165
|
-
fields: [
|
|
214123
|
+
fields: [agents.defaultSubAgentId],
|
|
214166
214124
|
references: [subAgents.id]
|
|
214167
214125
|
}),
|
|
214168
214126
|
contextConfig: one(contextConfigs, {
|
|
214169
|
-
fields: [
|
|
214127
|
+
fields: [agents.contextConfigId],
|
|
214170
214128
|
references: [contextConfigs.id]
|
|
214171
214129
|
}),
|
|
214172
214130
|
functionTools: many(functionTools)
|
|
@@ -214187,9 +214145,9 @@ var apiKeysRelations = drizzleOrm.relations(apiKeys, ({ one }) => ({
|
|
|
214187
214145
|
fields: [apiKeys.tenantId, apiKeys.projectId],
|
|
214188
214146
|
references: [projects.tenantId, projects.id]
|
|
214189
214147
|
}),
|
|
214190
|
-
|
|
214191
|
-
fields: [apiKeys.
|
|
214192
|
-
references: [
|
|
214148
|
+
agent: one(agents, {
|
|
214149
|
+
fields: [apiKeys.agentId],
|
|
214150
|
+
references: [agents.id]
|
|
214193
214151
|
})
|
|
214194
214152
|
}));
|
|
214195
214153
|
var agentToolRelationsRelations = drizzleOrm.relations(subAgentToolRelations, ({ one }) => ({
|
|
@@ -214202,8 +214160,13 @@ var agentToolRelationsRelations = drizzleOrm.relations(subAgentToolRelations, ({
|
|
|
214202
214160
|
references: [tools.id]
|
|
214203
214161
|
})
|
|
214204
214162
|
}));
|
|
214205
|
-
var credentialReferencesRelations = drizzleOrm.relations(credentialReferences, ({ many }) => ({
|
|
214206
|
-
|
|
214163
|
+
var credentialReferencesRelations = drizzleOrm.relations(credentialReferences, ({ one, many }) => ({
|
|
214164
|
+
project: one(projects, {
|
|
214165
|
+
fields: [credentialReferences.tenantId, credentialReferences.projectId],
|
|
214166
|
+
references: [projects.tenantId, projects.id]
|
|
214167
|
+
}),
|
|
214168
|
+
tools: many(tools),
|
|
214169
|
+
externalAgents: many(externalAgents)
|
|
214207
214170
|
}));
|
|
214208
214171
|
var toolsRelations = drizzleOrm.relations(tools, ({ one, many }) => ({
|
|
214209
214172
|
project: one(projects, {
|
|
@@ -214312,13 +214275,17 @@ var ledgerArtifactsRelations = drizzleOrm.relations(ledgerArtifacts, ({ one }) =
|
|
|
214312
214275
|
references: [tasks.id]
|
|
214313
214276
|
})
|
|
214314
214277
|
}));
|
|
214315
|
-
var functionsRelations = drizzleOrm.relations(functions, ({ many }) => ({
|
|
214316
|
-
functionTools: many(functionTools)
|
|
214278
|
+
var functionsRelations = drizzleOrm.relations(functions, ({ many, one }) => ({
|
|
214279
|
+
functionTools: many(functionTools),
|
|
214280
|
+
project: one(projects, {
|
|
214281
|
+
fields: [functions.tenantId, functions.projectId],
|
|
214282
|
+
references: [projects.tenantId, projects.id]
|
|
214283
|
+
})
|
|
214317
214284
|
}));
|
|
214318
214285
|
var subAgentRelationsRelations = drizzleOrm.relations(subAgentRelations, ({ one }) => ({
|
|
214319
|
-
|
|
214320
|
-
fields: [subAgentRelations.
|
|
214321
|
-
references: [
|
|
214286
|
+
agent: one(agents, {
|
|
214287
|
+
fields: [subAgentRelations.agentId],
|
|
214288
|
+
references: [agents.id]
|
|
214322
214289
|
}),
|
|
214323
214290
|
sourceSubAgent: one(subAgents, {
|
|
214324
214291
|
fields: [subAgentRelations.sourceSubAgentId],
|
|
@@ -214340,9 +214307,9 @@ var functionToolsRelations = drizzleOrm.relations(functionTools, ({ one, many })
|
|
|
214340
214307
|
fields: [functionTools.tenantId, functionTools.projectId],
|
|
214341
214308
|
references: [projects.tenantId, projects.id]
|
|
214342
214309
|
}),
|
|
214343
|
-
|
|
214344
|
-
fields: [functionTools.tenantId, functionTools.projectId, functionTools.
|
|
214345
|
-
references: [
|
|
214310
|
+
agent: one(agents, {
|
|
214311
|
+
fields: [functionTools.tenantId, functionTools.projectId, functionTools.agentId],
|
|
214312
|
+
references: [agents.tenantId, agents.projectId, agents.id]
|
|
214346
214313
|
}),
|
|
214347
214314
|
function: one(functions, {
|
|
214348
214315
|
fields: [functionTools.tenantId, functionTools.projectId, functionTools.functionId],
|
|
@@ -214386,7 +214353,7 @@ var StopWhenSchema = zodOpenapi.z.object({
|
|
|
214386
214353
|
transferCountIs: zodOpenapi.z.number().min(1).max(100).optional(),
|
|
214387
214354
|
stepCountIs: zodOpenapi.z.number().min(1).max(1e3).optional()
|
|
214388
214355
|
});
|
|
214389
|
-
var
|
|
214356
|
+
var AgentStopWhenSchema = StopWhenSchema.pick({ transferCountIs: true });
|
|
214390
214357
|
var SubAgentStopWhenSchema = StopWhenSchema.pick({ stepCountIs: true });
|
|
214391
214358
|
var MIN_ID_LENGTH = 1;
|
|
214392
214359
|
var MAX_ID_LENGTH = 255;
|
|
@@ -214427,31 +214394,31 @@ var FunctionToolConfigSchema = zodOpenapi.z.object({
|
|
|
214427
214394
|
var createApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
|
|
214428
214395
|
var createApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
|
|
214429
214396
|
var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true }).partial();
|
|
214430
|
-
var
|
|
214431
|
-
var
|
|
214432
|
-
var
|
|
214397
|
+
var createAgentScopedApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true, agentId: true });
|
|
214398
|
+
var createAgentScopedApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true, agentId: true });
|
|
214399
|
+
var createAgentScopedApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true, agentId: true }).partial();
|
|
214433
214400
|
var SubAgentSelectSchema = drizzleZod.createSelectSchema(subAgents);
|
|
214434
214401
|
var SubAgentInsertSchema = drizzleZod.createInsertSchema(subAgents).extend({
|
|
214435
214402
|
id: resourceIdSchema,
|
|
214436
214403
|
models: ModelSchema.optional()
|
|
214437
214404
|
});
|
|
214438
214405
|
var SubAgentUpdateSchema = SubAgentInsertSchema.partial();
|
|
214439
|
-
var SubAgentApiSelectSchema =
|
|
214440
|
-
var SubAgentApiInsertSchema =
|
|
214441
|
-
var SubAgentApiUpdateSchema =
|
|
214406
|
+
var SubAgentApiSelectSchema = createAgentScopedApiSchema(SubAgentSelectSchema);
|
|
214407
|
+
var SubAgentApiInsertSchema = createAgentScopedApiInsertSchema(SubAgentInsertSchema);
|
|
214408
|
+
var SubAgentApiUpdateSchema = createAgentScopedApiUpdateSchema(SubAgentUpdateSchema);
|
|
214442
214409
|
var SubAgentRelationSelectSchema = drizzleZod.createSelectSchema(subAgentRelations);
|
|
214443
214410
|
var SubAgentRelationInsertSchema = drizzleZod.createInsertSchema(subAgentRelations).extend({
|
|
214444
214411
|
id: resourceIdSchema,
|
|
214445
|
-
|
|
214412
|
+
agentId: resourceIdSchema,
|
|
214446
214413
|
sourceSubAgentId: resourceIdSchema,
|
|
214447
214414
|
targetSubAgentId: resourceIdSchema.optional(),
|
|
214448
214415
|
externalSubAgentId: resourceIdSchema.optional()
|
|
214449
214416
|
});
|
|
214450
214417
|
var SubAgentRelationUpdateSchema = SubAgentRelationInsertSchema.partial();
|
|
214451
|
-
var SubAgentRelationApiSelectSchema =
|
|
214418
|
+
var SubAgentRelationApiSelectSchema = createAgentScopedApiSchema(
|
|
214452
214419
|
SubAgentRelationSelectSchema
|
|
214453
214420
|
);
|
|
214454
|
-
var SubAgentRelationApiInsertSchema =
|
|
214421
|
+
var SubAgentRelationApiInsertSchema = createAgentScopedApiInsertSchema(
|
|
214455
214422
|
SubAgentRelationInsertSchema
|
|
214456
214423
|
).extend({
|
|
214457
214424
|
relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES)
|
|
@@ -214466,7 +214433,7 @@ var SubAgentRelationApiInsertSchema = createGraphScopedApiInsertSchema(
|
|
|
214466
214433
|
path: ["targetSubAgentId", "externalSubAgentId"]
|
|
214467
214434
|
}
|
|
214468
214435
|
);
|
|
214469
|
-
var SubAgentRelationApiUpdateSchema =
|
|
214436
|
+
var SubAgentRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
|
|
214470
214437
|
SubAgentRelationUpdateSchema
|
|
214471
214438
|
).extend({
|
|
214472
214439
|
relationType: zodOpenapi.z.enum(VALID_RELATION_TYPES).optional()
|
|
@@ -214491,23 +214458,23 @@ var SubAgentRelationQuerySchema = zodOpenapi.z.object({
|
|
|
214491
214458
|
});
|
|
214492
214459
|
var ExternalSubAgentRelationInsertSchema = drizzleZod.createInsertSchema(subAgentRelations).extend({
|
|
214493
214460
|
id: resourceIdSchema,
|
|
214494
|
-
|
|
214461
|
+
agentId: resourceIdSchema,
|
|
214495
214462
|
sourceSubAgentId: resourceIdSchema,
|
|
214496
214463
|
externalSubAgentId: resourceIdSchema
|
|
214497
214464
|
});
|
|
214498
214465
|
var ExternalSubAgentRelationApiInsertSchema = createApiInsertSchema(
|
|
214499
214466
|
ExternalSubAgentRelationInsertSchema
|
|
214500
214467
|
);
|
|
214501
|
-
var
|
|
214502
|
-
var
|
|
214468
|
+
var AgentSelectSchema = drizzleZod.createSelectSchema(agents);
|
|
214469
|
+
var AgentInsertSchema = drizzleZod.createInsertSchema(agents).extend({
|
|
214503
214470
|
id: resourceIdSchema
|
|
214504
214471
|
});
|
|
214505
|
-
var
|
|
214506
|
-
var
|
|
214507
|
-
var
|
|
214472
|
+
var AgentUpdateSchema = AgentInsertSchema.partial();
|
|
214473
|
+
var AgentApiSelectSchema = createApiSchema(AgentSelectSchema);
|
|
214474
|
+
var AgentApiInsertSchema = createApiInsertSchema(AgentInsertSchema).extend({
|
|
214508
214475
|
id: resourceIdSchema
|
|
214509
214476
|
});
|
|
214510
|
-
var
|
|
214477
|
+
var AgentApiUpdateSchema = createApiUpdateSchema(AgentUpdateSchema);
|
|
214511
214478
|
var TaskSelectSchema = drizzleZod.createSelectSchema(tasks);
|
|
214512
214479
|
var TaskInsertSchema = drizzleZod.createInsertSchema(tasks).extend({
|
|
214513
214480
|
id: resourceIdSchema,
|
|
@@ -214550,7 +214517,10 @@ var McpTransportConfigSchema = zodOpenapi.z.object({
|
|
|
214550
214517
|
type: zodOpenapi.z.enum(MCPTransportType),
|
|
214551
214518
|
requestInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
214552
214519
|
eventSourceInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
214553
|
-
reconnectionOptions: zodOpenapi.z.
|
|
214520
|
+
reconnectionOptions: zodOpenapi.z.any().optional().openapi({
|
|
214521
|
+
type: "object",
|
|
214522
|
+
description: "Reconnection options for streamable HTTP transport"
|
|
214523
|
+
}),
|
|
214554
214524
|
sessionId: zodOpenapi.z.string().optional()
|
|
214555
214525
|
});
|
|
214556
214526
|
var ToolStatusSchema = zodOpenapi.z.enum(TOOL_STATUS_VALUES);
|
|
@@ -214567,13 +214537,16 @@ var ToolInsertSchema = drizzleZod.createInsertSchema(tools).extend({
|
|
|
214567
214537
|
type: zodOpenapi.z.literal("mcp"),
|
|
214568
214538
|
mcp: zodOpenapi.z.object({
|
|
214569
214539
|
server: zodOpenapi.z.object({
|
|
214570
|
-
url: zodOpenapi.z.
|
|
214540
|
+
url: zodOpenapi.z.url()
|
|
214571
214541
|
}),
|
|
214572
214542
|
transport: zodOpenapi.z.object({
|
|
214573
214543
|
type: zodOpenapi.z.enum(MCPTransportType),
|
|
214574
214544
|
requestInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
214575
214545
|
eventSourceInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
214576
|
-
reconnectionOptions: zodOpenapi.z.
|
|
214546
|
+
reconnectionOptions: zodOpenapi.z.any().optional().openapi({
|
|
214547
|
+
type: "object",
|
|
214548
|
+
description: "Reconnection options for streamable HTTP transport"
|
|
214549
|
+
}),
|
|
214577
214550
|
sessionId: zodOpenapi.z.string().optional()
|
|
214578
214551
|
}).optional(),
|
|
214579
214552
|
activeTools: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
|
|
@@ -214620,7 +214593,7 @@ var DataComponentApiUpdateSchema = createApiUpdateSchema(DataComponentUpdateSche
|
|
|
214620
214593
|
var SubAgentDataComponentSelectSchema = drizzleZod.createSelectSchema(subAgentDataComponents);
|
|
214621
214594
|
var SubAgentDataComponentInsertSchema = drizzleZod.createInsertSchema(subAgentDataComponents);
|
|
214622
214595
|
var SubAgentDataComponentUpdateSchema = SubAgentDataComponentInsertSchema.partial();
|
|
214623
|
-
var SubAgentDataComponentApiSelectSchema =
|
|
214596
|
+
var SubAgentDataComponentApiSelectSchema = createAgentScopedApiSchema(
|
|
214624
214597
|
SubAgentDataComponentSelectSchema
|
|
214625
214598
|
);
|
|
214626
214599
|
var SubAgentDataComponentApiInsertSchema = SubAgentDataComponentInsertSchema.omit({
|
|
@@ -214629,7 +214602,7 @@ var SubAgentDataComponentApiInsertSchema = SubAgentDataComponentInsertSchema.omi
|
|
|
214629
214602
|
id: true,
|
|
214630
214603
|
createdAt: true
|
|
214631
214604
|
});
|
|
214632
|
-
var SubAgentDataComponentApiUpdateSchema =
|
|
214605
|
+
var SubAgentDataComponentApiUpdateSchema = createAgentScopedApiUpdateSchema(
|
|
214633
214606
|
SubAgentDataComponentUpdateSchema
|
|
214634
214607
|
);
|
|
214635
214608
|
var ArtifactComponentSelectSchema = drizzleZod.createSelectSchema(artifactComponents);
|
|
@@ -214656,7 +214629,7 @@ var SubAgentArtifactComponentInsertSchema = drizzleZod.createInsertSchema(
|
|
|
214656
214629
|
artifactComponentId: resourceIdSchema
|
|
214657
214630
|
});
|
|
214658
214631
|
var SubAgentArtifactComponentUpdateSchema = SubAgentArtifactComponentInsertSchema.partial();
|
|
214659
|
-
var SubAgentArtifactComponentApiSelectSchema =
|
|
214632
|
+
var SubAgentArtifactComponentApiSelectSchema = createAgentScopedApiSchema(
|
|
214660
214633
|
SubAgentArtifactComponentSelectSchema
|
|
214661
214634
|
);
|
|
214662
214635
|
var SubAgentArtifactComponentApiInsertSchema = SubAgentArtifactComponentInsertSchema.omit({
|
|
@@ -214665,7 +214638,7 @@ var SubAgentArtifactComponentApiInsertSchema = SubAgentArtifactComponentInsertSc
|
|
|
214665
214638
|
id: true,
|
|
214666
214639
|
createdAt: true
|
|
214667
214640
|
});
|
|
214668
|
-
var SubAgentArtifactComponentApiUpdateSchema =
|
|
214641
|
+
var SubAgentArtifactComponentApiUpdateSchema = createAgentScopedApiUpdateSchema(
|
|
214669
214642
|
SubAgentArtifactComponentUpdateSchema
|
|
214670
214643
|
);
|
|
214671
214644
|
var ExternalAgentSelectSchema = drizzleZod.createSelectSchema(externalAgents).extend({
|
|
@@ -214676,9 +214649,9 @@ var ExternalAgentInsertSchema = drizzleZod.createInsertSchema(externalAgents).ex
|
|
|
214676
214649
|
id: resourceIdSchema
|
|
214677
214650
|
});
|
|
214678
214651
|
var ExternalAgentUpdateSchema = ExternalAgentInsertSchema.partial();
|
|
214679
|
-
var ExternalAgentApiSelectSchema =
|
|
214680
|
-
var ExternalAgentApiInsertSchema =
|
|
214681
|
-
var ExternalAgentApiUpdateSchema =
|
|
214652
|
+
var ExternalAgentApiSelectSchema = createAgentScopedApiSchema(ExternalAgentSelectSchema);
|
|
214653
|
+
var ExternalAgentApiInsertSchema = createAgentScopedApiInsertSchema(ExternalAgentInsertSchema);
|
|
214654
|
+
var ExternalAgentApiUpdateSchema = createAgentScopedApiUpdateSchema(ExternalAgentUpdateSchema);
|
|
214682
214655
|
var AllAgentSchema = zodOpenapi.z.discriminatedUnion("type", [
|
|
214683
214656
|
SubAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("internal") }),
|
|
214684
214657
|
ExternalAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("external") })
|
|
@@ -214686,7 +214659,7 @@ var AllAgentSchema = zodOpenapi.z.discriminatedUnion("type", [
|
|
|
214686
214659
|
var ApiKeySelectSchema = drizzleZod.createSelectSchema(apiKeys);
|
|
214687
214660
|
var ApiKeyInsertSchema = drizzleZod.createInsertSchema(apiKeys).extend({
|
|
214688
214661
|
id: resourceIdSchema,
|
|
214689
|
-
|
|
214662
|
+
agentId: resourceIdSchema
|
|
214690
214663
|
});
|
|
214691
214664
|
var ApiKeyUpdateSchema = ApiKeyInsertSchema.partial().omit({
|
|
214692
214665
|
tenantId: true,
|
|
@@ -214794,7 +214767,7 @@ var FunctionToolInsertSchema = drizzleZod.createInsertSchema(functionTools).exte
|
|
|
214794
214767
|
});
|
|
214795
214768
|
var FunctionToolUpdateSchema = FunctionToolInsertSchema.partial();
|
|
214796
214769
|
var FunctionToolApiSelectSchema = createApiSchema(FunctionToolSelectSchema);
|
|
214797
|
-
var FunctionToolApiInsertSchema =
|
|
214770
|
+
var FunctionToolApiInsertSchema = createAgentScopedApiInsertSchema(FunctionToolInsertSchema);
|
|
214798
214771
|
var FunctionToolApiUpdateSchema = createApiUpdateSchema(FunctionToolUpdateSchema);
|
|
214799
214772
|
var FunctionSelectSchema = drizzleZod.createSelectSchema(functions);
|
|
214800
214773
|
var FunctionInsertSchema = drizzleZod.createInsertSchema(functions).extend({
|
|
@@ -214820,28 +214793,40 @@ var FetchDefinitionSchema = zodOpenapi.z.object({
|
|
|
214820
214793
|
fetchConfig: FetchConfigSchema,
|
|
214821
214794
|
responseSchema: zodOpenapi.z.any().optional(),
|
|
214822
214795
|
// JSON Schema for validating HTTP response
|
|
214823
|
-
defaultValue: zodOpenapi.z.
|
|
214796
|
+
defaultValue: zodOpenapi.z.any().optional().openapi({
|
|
214797
|
+
description: "Default value if fetch fails"
|
|
214798
|
+
}),
|
|
214824
214799
|
credential: CredentialReferenceApiInsertSchema.optional()
|
|
214825
214800
|
});
|
|
214826
214801
|
var ContextConfigSelectSchema = drizzleZod.createSelectSchema(contextConfigs).extend({
|
|
214827
|
-
headersSchema: zodOpenapi.z.
|
|
214802
|
+
headersSchema: zodOpenapi.z.any().optional().openapi({
|
|
214803
|
+
type: "object",
|
|
214804
|
+
description: "JSON Schema for validating request headers"
|
|
214805
|
+
})
|
|
214828
214806
|
});
|
|
214829
214807
|
var ContextConfigInsertSchema = drizzleZod.createInsertSchema(contextConfigs).extend({
|
|
214830
214808
|
id: resourceIdSchema.optional(),
|
|
214831
|
-
headersSchema: zodOpenapi.z.
|
|
214809
|
+
headersSchema: zodOpenapi.z.any().nullable().optional().openapi({
|
|
214810
|
+
type: "object",
|
|
214811
|
+
description: "JSON Schema for validating request headers"
|
|
214812
|
+
}),
|
|
214813
|
+
contextVariables: zodOpenapi.z.any().nullable().optional().openapi({
|
|
214814
|
+
type: "object",
|
|
214815
|
+
description: "Context variables configuration with fetch definitions"
|
|
214816
|
+
})
|
|
214832
214817
|
}).omit({
|
|
214833
214818
|
createdAt: true,
|
|
214834
214819
|
updatedAt: true
|
|
214835
214820
|
});
|
|
214836
214821
|
var ContextConfigUpdateSchema = ContextConfigInsertSchema.partial();
|
|
214837
214822
|
var ContextConfigApiSelectSchema = createApiSchema(ContextConfigSelectSchema).omit({
|
|
214838
|
-
|
|
214823
|
+
agentId: true
|
|
214839
214824
|
});
|
|
214840
214825
|
var ContextConfigApiInsertSchema = createApiInsertSchema(ContextConfigInsertSchema).omit({
|
|
214841
|
-
|
|
214826
|
+
agentId: true
|
|
214842
214827
|
});
|
|
214843
214828
|
var ContextConfigApiUpdateSchema = createApiUpdateSchema(ContextConfigUpdateSchema).omit({
|
|
214844
|
-
|
|
214829
|
+
agentId: true
|
|
214845
214830
|
});
|
|
214846
214831
|
var SubAgentToolRelationSelectSchema = drizzleZod.createSelectSchema(subAgentToolRelations);
|
|
214847
214832
|
var SubAgentToolRelationInsertSchema = drizzleZod.createInsertSchema(subAgentToolRelations).extend({
|
|
@@ -214852,13 +214837,13 @@ var SubAgentToolRelationInsertSchema = drizzleZod.createInsertSchema(subAgentToo
|
|
|
214852
214837
|
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
214853
214838
|
});
|
|
214854
214839
|
var SubAgentToolRelationUpdateSchema = SubAgentToolRelationInsertSchema.partial();
|
|
214855
|
-
var SubAgentToolRelationApiSelectSchema =
|
|
214840
|
+
var SubAgentToolRelationApiSelectSchema = createAgentScopedApiSchema(
|
|
214856
214841
|
SubAgentToolRelationSelectSchema
|
|
214857
214842
|
);
|
|
214858
|
-
var SubAgentToolRelationApiInsertSchema =
|
|
214843
|
+
var SubAgentToolRelationApiInsertSchema = createAgentScopedApiInsertSchema(
|
|
214859
214844
|
SubAgentToolRelationInsertSchema
|
|
214860
214845
|
);
|
|
214861
|
-
var SubAgentToolRelationApiUpdateSchema =
|
|
214846
|
+
var SubAgentToolRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
|
|
214862
214847
|
SubAgentToolRelationUpdateSchema
|
|
214863
214848
|
);
|
|
214864
214849
|
var LedgerArtifactSelectSchema = drizzleZod.createSelectSchema(ledgerArtifacts);
|
|
@@ -214889,7 +214874,7 @@ var CanUseItemSchema = zodOpenapi.z.object({
|
|
|
214889
214874
|
toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
|
|
214890
214875
|
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
214891
214876
|
});
|
|
214892
|
-
var
|
|
214877
|
+
var FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
|
|
214893
214878
|
type: zodOpenapi.z.literal("internal"),
|
|
214894
214879
|
canUse: zodOpenapi.z.array(CanUseItemSchema),
|
|
214895
214880
|
// All tools (both MCP and function tools)
|
|
@@ -214898,44 +214883,23 @@ var FullGraphAgentInsertSchema = SubAgentApiInsertSchema.extend({
|
|
|
214898
214883
|
canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
214899
214884
|
canDelegateTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
|
|
214900
214885
|
});
|
|
214901
|
-
var
|
|
214902
|
-
subAgents: zodOpenapi.z.record(
|
|
214903
|
-
zodOpenapi.z.string(),
|
|
214904
|
-
zodOpenapi.z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])
|
|
214905
|
-
),
|
|
214906
|
-
// Lookup maps for UI to resolve canUse items
|
|
214907
|
-
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
|
|
214908
|
-
// MCP tools (project-scoped)
|
|
214909
|
-
functionTools: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionToolApiInsertSchema).optional(),
|
|
214910
|
-
// Function tools (graph-scoped)
|
|
214911
|
-
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
214912
|
-
// Get function code for function tools
|
|
214913
|
-
contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
|
|
214914
|
-
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
214915
|
-
models: ModelSchema.optional(),
|
|
214916
|
-
stopWhen: GraphStopWhenSchema.optional(),
|
|
214917
|
-
graphPrompt: zodOpenapi.z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
|
|
214918
|
-
});
|
|
214919
|
-
var GraphWithinContextOfProjectSchema = AgentGraphApiInsertSchema.extend({
|
|
214886
|
+
var AgentWithinContextOfProjectSchema = AgentApiInsertSchema.extend({
|
|
214920
214887
|
subAgents: zodOpenapi.z.record(
|
|
214921
214888
|
zodOpenapi.z.string(),
|
|
214922
|
-
zodOpenapi.z.
|
|
214923
|
-
FullGraphAgentInsertSchema,
|
|
214924
|
-
ExternalAgentApiInsertSchema.extend({ type: zodOpenapi.z.literal("external") })
|
|
214925
|
-
])
|
|
214889
|
+
zodOpenapi.z.union([FullAgentAgentInsertSchema, ExternalAgentApiInsertSchema])
|
|
214926
214890
|
),
|
|
214927
214891
|
// Lookup maps for UI to resolve canUse items
|
|
214928
214892
|
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
|
|
214929
214893
|
// MCP tools (project-scoped)
|
|
214930
214894
|
functionTools: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionToolApiInsertSchema).optional(),
|
|
214931
|
-
// Function tools (
|
|
214895
|
+
// Function tools (agent-scoped)
|
|
214932
214896
|
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
214933
214897
|
// Get function code for function tools
|
|
214934
214898
|
contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
|
|
214935
214899
|
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
214936
214900
|
models: ModelSchema.optional(),
|
|
214937
|
-
stopWhen:
|
|
214938
|
-
|
|
214901
|
+
stopWhen: AgentStopWhenSchema.optional(),
|
|
214902
|
+
prompt: zodOpenapi.z.string().max(5e3, "Agent prompt cannot exceed 5000 characters").optional()
|
|
214939
214903
|
});
|
|
214940
214904
|
var PaginationSchema = zodOpenapi.z.object({
|
|
214941
214905
|
page: zodOpenapi.z.coerce.number().min(1).default(1),
|
|
@@ -214953,7 +214917,9 @@ var SingleResponseSchema = (itemSchema) => zodOpenapi.z.object({
|
|
|
214953
214917
|
var ErrorResponseSchema = zodOpenapi.z.object({
|
|
214954
214918
|
error: zodOpenapi.z.string(),
|
|
214955
214919
|
message: zodOpenapi.z.string().optional(),
|
|
214956
|
-
details: zodOpenapi.z.
|
|
214920
|
+
details: zodOpenapi.z.any().optional().openapi({
|
|
214921
|
+
description: "Additional error details"
|
|
214922
|
+
})
|
|
214957
214923
|
});
|
|
214958
214924
|
var ExistsResponseSchema = zodOpenapi.z.object({
|
|
214959
214925
|
exists: zodOpenapi.z.boolean()
|
|
@@ -214976,11 +214942,9 @@ var ProjectApiSelectSchema = ProjectSelectSchema.omit({ tenantId: true });
|
|
|
214976
214942
|
var ProjectApiInsertSchema = ProjectInsertSchema.omit({ tenantId: true });
|
|
214977
214943
|
var ProjectApiUpdateSchema = ProjectUpdateSchema.omit({ tenantId: true });
|
|
214978
214944
|
var FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
|
|
214979
|
-
|
|
214945
|
+
agents: zodOpenapi.z.record(zodOpenapi.z.string(), AgentWithinContextOfProjectSchema),
|
|
214980
214946
|
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema),
|
|
214981
|
-
// MCP tools (project-scoped)
|
|
214982
214947
|
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
214983
|
-
// Functions (project-scoped)
|
|
214984
214948
|
dataComponents: zodOpenapi.z.record(zodOpenapi.z.string(), DataComponentApiInsertSchema).optional(),
|
|
214985
214949
|
artifactComponents: zodOpenapi.z.record(zodOpenapi.z.string(), ArtifactComponentApiInsertSchema).optional(),
|
|
214986
214950
|
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
@@ -214997,9 +214961,9 @@ var HeadersScopeSchema = zodOpenapi.z.object({
|
|
|
214997
214961
|
description: "Project identifier",
|
|
214998
214962
|
example: "project_456"
|
|
214999
214963
|
}),
|
|
215000
|
-
"x-inkeep-
|
|
215001
|
-
description: "
|
|
215002
|
-
example: "
|
|
214964
|
+
"x-inkeep-agent-id": zodOpenapi.z.string().optional().openapi({
|
|
214965
|
+
description: "Agent identifier",
|
|
214966
|
+
example: "agent_789"
|
|
215003
214967
|
})
|
|
215004
214968
|
});
|
|
215005
214969
|
var TenantId = zodOpenapi.z.string().openapi({
|
|
@@ -215010,9 +214974,9 @@ var ProjectId = zodOpenapi.z.string().openapi({
|
|
|
215010
214974
|
description: "Project identifier",
|
|
215011
214975
|
example: "project_456"
|
|
215012
214976
|
});
|
|
215013
|
-
var
|
|
215014
|
-
description: "
|
|
215015
|
-
example: "
|
|
214977
|
+
var AgentId = zodOpenapi.z.string().openapi({
|
|
214978
|
+
description: "Agent identifier",
|
|
214979
|
+
example: "agent_789"
|
|
215016
214980
|
});
|
|
215017
214981
|
var SubAgentId = zodOpenapi.z.string().openapi({
|
|
215018
214982
|
description: "Sub-agent identifier",
|
|
@@ -215030,18 +214994,18 @@ var TenantProjectParamsSchema = TenantParamsSchema.extend({
|
|
|
215030
214994
|
var TenantProjectIdParamsSchema = TenantProjectParamsSchema.extend({
|
|
215031
214995
|
id: resourceIdSchema
|
|
215032
214996
|
}).openapi("TenantProjectIdParams");
|
|
215033
|
-
var
|
|
215034
|
-
|
|
215035
|
-
}).openapi("
|
|
215036
|
-
var
|
|
214997
|
+
var TenantProjectAgentParamsSchema = TenantProjectParamsSchema.extend({
|
|
214998
|
+
agentId: AgentId
|
|
214999
|
+
}).openapi("TenantProjectAgentParams");
|
|
215000
|
+
var TenantProjectAgentIdParamsSchema = TenantProjectAgentParamsSchema.extend({
|
|
215037
215001
|
id: resourceIdSchema
|
|
215038
|
-
}).openapi("
|
|
215039
|
-
var
|
|
215002
|
+
}).openapi("TenantProjectAgentIdParams");
|
|
215003
|
+
var TenantProjectAgentSubAgentParamsSchema = TenantProjectAgentParamsSchema.extend({
|
|
215040
215004
|
subAgentId: SubAgentId
|
|
215041
|
-
}).openapi("
|
|
215042
|
-
var
|
|
215005
|
+
}).openapi("TenantProjectAgentSubAgentParams");
|
|
215006
|
+
var TenantProjectAgentSubAgentIdParamsSchema = TenantProjectAgentSubAgentParamsSchema.extend({
|
|
215043
215007
|
id: resourceIdSchema
|
|
215044
|
-
}).openapi("
|
|
215008
|
+
}).openapi("TenantProjectAgentSubAgentIdParams");
|
|
215045
215009
|
var PaginationQueryParamsSchema = zodOpenapi.z.object({
|
|
215046
215010
|
page: zodOpenapi.z.coerce.number().min(1).default(1),
|
|
215047
215011
|
limit: zodOpenapi.z.coerce.number().min(1).max(100).default(10)
|
|
@@ -215071,10 +215035,10 @@ var ContextConfigBuilder = class {
|
|
|
215071
215035
|
__publicField(this, "baseURL");
|
|
215072
215036
|
__publicField(this, "tenantId");
|
|
215073
215037
|
__publicField(this, "projectId");
|
|
215074
|
-
__publicField(this, "
|
|
215038
|
+
__publicField(this, "agentId");
|
|
215075
215039
|
this.tenantId = options.tenantId || "default";
|
|
215076
215040
|
this.projectId = options.projectId || "default";
|
|
215077
|
-
this.
|
|
215041
|
+
this.agentId = options.agentId || "default";
|
|
215078
215042
|
this.baseURL = process.env.INKEEP_AGENTS_MANAGE_API_URL || "http://localhost:3002";
|
|
215079
215043
|
let headers2;
|
|
215080
215044
|
if (options.headers) {
|
|
@@ -215123,23 +215087,23 @@ var ContextConfigBuilder = class {
|
|
|
215123
215087
|
);
|
|
215124
215088
|
}
|
|
215125
215089
|
/**
|
|
215126
|
-
* Set the context (tenantId, projectId,
|
|
215127
|
-
* Called by
|
|
215090
|
+
* Set the context (tenantId, projectId, agentId) for this context config
|
|
215091
|
+
* Called by agent.setConfig() when the agent is configured
|
|
215128
215092
|
*/
|
|
215129
|
-
setContext(tenantId, projectId,
|
|
215093
|
+
setContext(tenantId, projectId, agentId, baseURL) {
|
|
215130
215094
|
this.tenantId = tenantId;
|
|
215131
215095
|
this.projectId = projectId;
|
|
215132
|
-
this.
|
|
215096
|
+
this.agentId = agentId;
|
|
215133
215097
|
this.baseURL = baseURL;
|
|
215134
215098
|
this.config.tenantId = tenantId;
|
|
215135
215099
|
this.config.projectId = projectId;
|
|
215136
|
-
this.config.
|
|
215100
|
+
this.config.agentId = agentId;
|
|
215137
215101
|
logger2.info(
|
|
215138
215102
|
{
|
|
215139
215103
|
contextConfigId: this.config.id,
|
|
215140
215104
|
tenantId: this.tenantId,
|
|
215141
215105
|
projectId: this.projectId,
|
|
215142
|
-
|
|
215106
|
+
agentId: this.agentId
|
|
215143
215107
|
},
|
|
215144
215108
|
"ContextConfig context updated"
|
|
215145
215109
|
);
|
|
@@ -215152,7 +215116,7 @@ var ContextConfigBuilder = class {
|
|
|
215152
215116
|
id: this.getId(),
|
|
215153
215117
|
tenantId: this.tenantId,
|
|
215154
215118
|
projectId: this.projectId,
|
|
215155
|
-
|
|
215119
|
+
agentId: this.agentId,
|
|
215156
215120
|
headersSchema: this.getHeadersSchema(),
|
|
215157
215121
|
contextVariables: this.getContextVariables(),
|
|
215158
215122
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -215243,7 +215207,7 @@ var ContextConfigBuilder = class {
|
|
|
215243
215207
|
};
|
|
215244
215208
|
try {
|
|
215245
215209
|
const updateResponse = await fetch(
|
|
215246
|
-
`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/
|
|
215210
|
+
`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent/${this.agentId}/context-configs/${this.getId()}`,
|
|
215247
215211
|
{
|
|
215248
215212
|
method: "PUT",
|
|
215249
215213
|
headers: {
|
|
@@ -215269,7 +215233,7 @@ var ContextConfigBuilder = class {
|
|
|
215269
215233
|
"Context config not found, creating new config"
|
|
215270
215234
|
);
|
|
215271
215235
|
const createResponse = await fetch(
|
|
215272
|
-
`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/
|
|
215236
|
+
`${this.baseURL}/tenants/${this.tenantId}/projects/${this.projectId}/agent/${this.agentId}/context-configs`,
|
|
215273
215237
|
{
|
|
215274
215238
|
method: "POST",
|
|
215275
215239
|
headers: {
|
|
@@ -215764,7 +215728,7 @@ var getContextConfigById = (db) => async (params) => {
|
|
|
215764
215728
|
where: drizzleOrm.and(
|
|
215765
215729
|
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
215766
215730
|
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
215767
|
-
drizzleOrm.eq(contextConfigs.
|
|
215731
|
+
drizzleOrm.eq(contextConfigs.agentId, params.scopes.agentId),
|
|
215768
215732
|
drizzleOrm.eq(contextConfigs.id, params.id)
|
|
215769
215733
|
)
|
|
215770
215734
|
});
|
|
@@ -215774,7 +215738,7 @@ var listContextConfigs = (db) => async (params) => {
|
|
|
215774
215738
|
where: drizzleOrm.and(
|
|
215775
215739
|
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
215776
215740
|
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
215777
|
-
drizzleOrm.eq(contextConfigs.
|
|
215741
|
+
drizzleOrm.eq(contextConfigs.agentId, params.scopes.agentId)
|
|
215778
215742
|
),
|
|
215779
215743
|
orderBy: [drizzleOrm.desc(contextConfigs.createdAt)]
|
|
215780
215744
|
});
|
|
@@ -215786,7 +215750,7 @@ var listContextConfigsPaginated = (db) => async (params) => {
|
|
|
215786
215750
|
const whereClause = drizzleOrm.and(
|
|
215787
215751
|
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
215788
215752
|
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
215789
|
-
drizzleOrm.eq(contextConfigs.
|
|
215753
|
+
drizzleOrm.eq(contextConfigs.agentId, params.scopes.agentId)
|
|
215790
215754
|
);
|
|
215791
215755
|
const [contextConfigList, totalResult] = await Promise.all([
|
|
215792
215756
|
db.select().from(contextConfigs).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(contextConfigs.createdAt)),
|
|
@@ -215815,7 +215779,7 @@ var createContextConfig = (db) => async (params) => {
|
|
|
215815
215779
|
id,
|
|
215816
215780
|
tenantId: params.tenantId,
|
|
215817
215781
|
projectId: params.projectId,
|
|
215818
|
-
|
|
215782
|
+
agentId: params.agentId,
|
|
215819
215783
|
headersSchema: params.headersSchema ?? null,
|
|
215820
215784
|
contextVariables: contextVariables ?? null,
|
|
215821
215785
|
createdAt: now,
|
|
@@ -215841,7 +215805,7 @@ var updateContextConfig = (db) => async (params) => {
|
|
|
215841
215805
|
drizzleOrm.and(
|
|
215842
215806
|
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
215843
215807
|
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
215844
|
-
drizzleOrm.eq(contextConfigs.
|
|
215808
|
+
drizzleOrm.eq(contextConfigs.agentId, params.scopes.agentId),
|
|
215845
215809
|
drizzleOrm.eq(contextConfigs.id, params.id)
|
|
215846
215810
|
)
|
|
215847
215811
|
).returning();
|
|
@@ -215853,7 +215817,7 @@ var deleteContextConfig = (db) => async (params) => {
|
|
|
215853
215817
|
drizzleOrm.and(
|
|
215854
215818
|
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
215855
215819
|
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
215856
|
-
drizzleOrm.eq(contextConfigs.
|
|
215820
|
+
drizzleOrm.eq(contextConfigs.agentId, params.scopes.agentId),
|
|
215857
215821
|
drizzleOrm.eq(contextConfigs.id, params.id)
|
|
215858
215822
|
)
|
|
215859
215823
|
).returning();
|
|
@@ -215872,7 +215836,7 @@ var countContextConfigs = (db) => async (params) => {
|
|
|
215872
215836
|
drizzleOrm.and(
|
|
215873
215837
|
drizzleOrm.eq(contextConfigs.tenantId, params.scopes.tenantId),
|
|
215874
215838
|
drizzleOrm.eq(contextConfigs.projectId, params.scopes.projectId),
|
|
215875
|
-
drizzleOrm.eq(contextConfigs.
|
|
215839
|
+
drizzleOrm.eq(contextConfigs.agentId, params.scopes.agentId)
|
|
215876
215840
|
)
|
|
215877
215841
|
);
|
|
215878
215842
|
const total = result[0]?.count || 0;
|
|
@@ -215882,7 +215846,7 @@ var upsertContextConfig = (db) => async (params) => {
|
|
|
215882
215846
|
const scopes = {
|
|
215883
215847
|
tenantId: params.data.tenantId,
|
|
215884
215848
|
projectId: params.data.projectId,
|
|
215885
|
-
|
|
215849
|
+
agentId: params.data.agentId
|
|
215886
215850
|
};
|
|
215887
215851
|
if (params.data.id) {
|
|
215888
215852
|
const existing = await getContextConfigById(db)({
|
|
@@ -215911,7 +215875,7 @@ var getExternalAgent = (db) => async (params) => {
|
|
|
215911
215875
|
where: drizzleOrm.and(
|
|
215912
215876
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215913
215877
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
215914
|
-
drizzleOrm.eq(externalAgents.
|
|
215878
|
+
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId),
|
|
215915
215879
|
drizzleOrm.eq(externalAgents.id, params.subAgentId)
|
|
215916
215880
|
)
|
|
215917
215881
|
});
|
|
@@ -215922,7 +215886,7 @@ var getExternalAgentByUrl = (db) => async (params) => {
|
|
|
215922
215886
|
where: drizzleOrm.and(
|
|
215923
215887
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215924
215888
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
215925
|
-
drizzleOrm.eq(externalAgents.
|
|
215889
|
+
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId),
|
|
215926
215890
|
drizzleOrm.eq(externalAgents.baseUrl, params.baseUrl)
|
|
215927
215891
|
)
|
|
215928
215892
|
});
|
|
@@ -215933,7 +215897,7 @@ var listExternalAgents = (db) => async (params) => {
|
|
|
215933
215897
|
where: drizzleOrm.and(
|
|
215934
215898
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215935
215899
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
215936
|
-
drizzleOrm.eq(externalAgents.
|
|
215900
|
+
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId)
|
|
215937
215901
|
),
|
|
215938
215902
|
orderBy: [drizzleOrm.asc(externalAgents.name)]
|
|
215939
215903
|
});
|
|
@@ -215947,14 +215911,14 @@ var listExternalAgentsPaginated = (db) => async (params) => {
|
|
|
215947
215911
|
drizzleOrm.and(
|
|
215948
215912
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215949
215913
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
215950
|
-
drizzleOrm.eq(externalAgents.
|
|
215914
|
+
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId)
|
|
215951
215915
|
)
|
|
215952
215916
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(externalAgents.createdAt)),
|
|
215953
215917
|
db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
215954
215918
|
drizzleOrm.and(
|
|
215955
215919
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215956
215920
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
215957
|
-
drizzleOrm.eq(externalAgents.
|
|
215921
|
+
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId)
|
|
215958
215922
|
)
|
|
215959
215923
|
)
|
|
215960
215924
|
]);
|
|
@@ -215983,7 +215947,7 @@ var updateExternalAgent = (db) => async (params) => {
|
|
|
215983
215947
|
drizzleOrm.and(
|
|
215984
215948
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215985
215949
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
215986
|
-
drizzleOrm.eq(externalAgents.
|
|
215950
|
+
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId),
|
|
215987
215951
|
drizzleOrm.eq(externalAgents.id, params.subAgentId)
|
|
215988
215952
|
)
|
|
215989
215953
|
).returning();
|
|
@@ -215993,7 +215957,7 @@ var upsertExternalAgent = (db) => async (params) => {
|
|
|
215993
215957
|
const scopes = {
|
|
215994
215958
|
tenantId: params.data.tenantId,
|
|
215995
215959
|
projectId: params.data.projectId,
|
|
215996
|
-
|
|
215960
|
+
agentId: params.data.agentId
|
|
215997
215961
|
};
|
|
215998
215962
|
const existing = await getExternalAgent(db)({
|
|
215999
215963
|
scopes,
|
|
@@ -216025,7 +215989,7 @@ var deleteExternalAgent = (db) => async (params) => {
|
|
|
216025
215989
|
drizzleOrm.and(
|
|
216026
215990
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
216027
215991
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
216028
|
-
drizzleOrm.eq(externalAgents.
|
|
215992
|
+
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId),
|
|
216029
215993
|
drizzleOrm.eq(externalAgents.id, params.subAgentId)
|
|
216030
215994
|
)
|
|
216031
215995
|
).returning();
|
|
@@ -216048,7 +216012,7 @@ var countExternalAgents = (db) => async (params) => {
|
|
|
216048
216012
|
drizzleOrm.and(
|
|
216049
216013
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
216050
216014
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
216051
|
-
drizzleOrm.eq(externalAgents.
|
|
216015
|
+
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId)
|
|
216052
216016
|
)
|
|
216053
216017
|
);
|
|
216054
216018
|
const countValue = result[0]?.count;
|
|
@@ -216192,7 +216156,7 @@ var getFunctionToolById = (db) => async (params) => {
|
|
|
216192
216156
|
drizzleOrm.and(
|
|
216193
216157
|
drizzleOrm.eq(functionTools.tenantId, params.scopes.tenantId),
|
|
216194
216158
|
drizzleOrm.eq(functionTools.projectId, params.scopes.projectId),
|
|
216195
|
-
drizzleOrm.eq(functionTools.
|
|
216159
|
+
drizzleOrm.eq(functionTools.agentId, params.scopes.agentId),
|
|
216196
216160
|
drizzleOrm.eq(functionTools.id, params.functionToolId)
|
|
216197
216161
|
)
|
|
216198
216162
|
).limit(1);
|
|
@@ -216205,7 +216169,7 @@ var listFunctionTools = (db) => async (params) => {
|
|
|
216205
216169
|
const whereClause = drizzleOrm.and(
|
|
216206
216170
|
drizzleOrm.eq(functionTools.tenantId, params.scopes.tenantId),
|
|
216207
216171
|
drizzleOrm.eq(functionTools.projectId, params.scopes.projectId),
|
|
216208
|
-
drizzleOrm.eq(functionTools.
|
|
216172
|
+
drizzleOrm.eq(functionTools.agentId, params.scopes.agentId)
|
|
216209
216173
|
);
|
|
216210
216174
|
const [functionToolsDbResults, totalResult] = await Promise.all([
|
|
216211
216175
|
db.select().from(functionTools).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(functionTools.createdAt)),
|
|
@@ -216220,11 +216184,11 @@ var listFunctionTools = (db) => async (params) => {
|
|
|
216220
216184
|
};
|
|
216221
216185
|
var createFunctionTool = (db) => async (params) => {
|
|
216222
216186
|
const { data, scopes } = params;
|
|
216223
|
-
const { tenantId, projectId,
|
|
216187
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
216224
216188
|
const [created] = await db.insert(functionTools).values({
|
|
216225
216189
|
tenantId,
|
|
216226
216190
|
projectId,
|
|
216227
|
-
|
|
216191
|
+
agentId,
|
|
216228
216192
|
id: data.id,
|
|
216229
216193
|
name: data.name,
|
|
216230
216194
|
description: data.description,
|
|
@@ -216243,7 +216207,7 @@ var updateFunctionTool = (db) => async (params) => {
|
|
|
216243
216207
|
drizzleOrm.and(
|
|
216244
216208
|
drizzleOrm.eq(functionTools.tenantId, params.scopes.tenantId),
|
|
216245
216209
|
drizzleOrm.eq(functionTools.projectId, params.scopes.projectId),
|
|
216246
|
-
drizzleOrm.eq(functionTools.
|
|
216210
|
+
drizzleOrm.eq(functionTools.agentId, params.scopes.agentId),
|
|
216247
216211
|
drizzleOrm.eq(functionTools.id, params.functionToolId)
|
|
216248
216212
|
)
|
|
216249
216213
|
).returning();
|
|
@@ -216254,7 +216218,7 @@ var deleteFunctionTool = (db) => async (params) => {
|
|
|
216254
216218
|
drizzleOrm.and(
|
|
216255
216219
|
drizzleOrm.eq(functionTools.tenantId, params.scopes.tenantId),
|
|
216256
216220
|
drizzleOrm.eq(functionTools.projectId, params.scopes.projectId),
|
|
216257
|
-
drizzleOrm.eq(functionTools.
|
|
216221
|
+
drizzleOrm.eq(functionTools.agentId, params.scopes.agentId),
|
|
216258
216222
|
drizzleOrm.eq(functionTools.id, params.functionToolId)
|
|
216259
216223
|
)
|
|
216260
216224
|
).returning();
|
|
@@ -216264,7 +216228,7 @@ var upsertFunctionTool = (db) => async (params) => {
|
|
|
216264
216228
|
const scopes = {
|
|
216265
216229
|
tenantId: params.scopes.tenantId,
|
|
216266
216230
|
projectId: params.scopes.projectId,
|
|
216267
|
-
|
|
216231
|
+
agentId: params.scopes.agentId
|
|
216268
216232
|
};
|
|
216269
216233
|
const existing = await getFunctionToolById(db)({
|
|
216270
216234
|
scopes,
|
|
@@ -216290,17 +216254,17 @@ var upsertFunctionTool = (db) => async (params) => {
|
|
|
216290
216254
|
var getFunctionToolsForSubAgent = (db) => {
|
|
216291
216255
|
return async (params) => {
|
|
216292
216256
|
const { scopes, subAgentId } = params;
|
|
216293
|
-
const { tenantId, projectId,
|
|
216257
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
216294
216258
|
try {
|
|
216295
216259
|
const functionToolsList = await listFunctionTools(db)({
|
|
216296
|
-
scopes: { tenantId, projectId,
|
|
216260
|
+
scopes: { tenantId, projectId, agentId },
|
|
216297
216261
|
pagination: { page: 1, limit: 1e3 }
|
|
216298
216262
|
});
|
|
216299
216263
|
const relations2 = await db.select().from(agentFunctionToolRelations).where(
|
|
216300
216264
|
drizzleOrm.and(
|
|
216301
216265
|
drizzleOrm.eq(agentFunctionToolRelations.tenantId, tenantId),
|
|
216302
216266
|
drizzleOrm.eq(agentFunctionToolRelations.projectId, projectId),
|
|
216303
|
-
drizzleOrm.eq(agentFunctionToolRelations.
|
|
216267
|
+
drizzleOrm.eq(agentFunctionToolRelations.agentId, agentId),
|
|
216304
216268
|
drizzleOrm.eq(agentFunctionToolRelations.subAgentId, subAgentId)
|
|
216305
216269
|
)
|
|
216306
216270
|
);
|
|
@@ -216314,7 +216278,7 @@ var getFunctionToolsForSubAgent = (db) => {
|
|
|
216314
216278
|
};
|
|
216315
216279
|
} catch (error) {
|
|
216316
216280
|
logger4.error(
|
|
216317
|
-
{ tenantId, projectId,
|
|
216281
|
+
{ tenantId, projectId, agentId, subAgentId, error },
|
|
216318
216282
|
"Failed to get function tools for agent"
|
|
216319
216283
|
);
|
|
216320
216284
|
throw error;
|
|
@@ -216337,25 +216301,25 @@ var upsertSubAgentFunctionToolRelation = (db) => async (params) => {
|
|
|
216337
216301
|
var addFunctionToolToSubAgent = (db) => {
|
|
216338
216302
|
return async (params) => {
|
|
216339
216303
|
const { scopes, subAgentId, functionToolId } = params;
|
|
216340
|
-
const { tenantId, projectId,
|
|
216304
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
216341
216305
|
try {
|
|
216342
216306
|
const relationId = nanoid.nanoid();
|
|
216343
216307
|
await db.insert(agentFunctionToolRelations).values({
|
|
216344
216308
|
id: relationId,
|
|
216345
216309
|
tenantId,
|
|
216346
216310
|
projectId,
|
|
216347
|
-
|
|
216311
|
+
agentId,
|
|
216348
216312
|
subAgentId,
|
|
216349
216313
|
functionToolId
|
|
216350
216314
|
});
|
|
216351
216315
|
logger4.info(
|
|
216352
|
-
{ tenantId, projectId,
|
|
216316
|
+
{ tenantId, projectId, agentId, subAgentId, functionToolId, relationId },
|
|
216353
216317
|
"Function tool added to agent"
|
|
216354
216318
|
);
|
|
216355
216319
|
return { id: relationId };
|
|
216356
216320
|
} catch (error) {
|
|
216357
216321
|
logger4.error(
|
|
216358
|
-
{ tenantId, projectId,
|
|
216322
|
+
{ tenantId, projectId, agentId, subAgentId, functionToolId, error },
|
|
216359
216323
|
"Failed to add function tool to agent"
|
|
216360
216324
|
);
|
|
216361
216325
|
throw error;
|
|
@@ -216365,7 +216329,7 @@ var addFunctionToolToSubAgent = (db) => {
|
|
|
216365
216329
|
var updateSubAgentFunctionToolRelation = (db) => {
|
|
216366
216330
|
return async (params) => {
|
|
216367
216331
|
const { scopes, relationId, data } = params;
|
|
216368
|
-
const { tenantId, projectId,
|
|
216332
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
216369
216333
|
try {
|
|
216370
216334
|
await db.update(agentFunctionToolRelations).set({
|
|
216371
216335
|
subAgentId: data.subAgentId,
|
|
@@ -216375,17 +216339,17 @@ var updateSubAgentFunctionToolRelation = (db) => {
|
|
|
216375
216339
|
drizzleOrm.eq(agentFunctionToolRelations.id, relationId),
|
|
216376
216340
|
drizzleOrm.eq(agentFunctionToolRelations.tenantId, tenantId),
|
|
216377
216341
|
drizzleOrm.eq(agentFunctionToolRelations.projectId, projectId),
|
|
216378
|
-
drizzleOrm.eq(agentFunctionToolRelations.
|
|
216342
|
+
drizzleOrm.eq(agentFunctionToolRelations.agentId, agentId)
|
|
216379
216343
|
)
|
|
216380
216344
|
);
|
|
216381
216345
|
logger4.info(
|
|
216382
|
-
{ tenantId, projectId,
|
|
216346
|
+
{ tenantId, projectId, agentId, relationId, data },
|
|
216383
216347
|
"Agent-function tool relation updated"
|
|
216384
216348
|
);
|
|
216385
216349
|
return { id: relationId };
|
|
216386
216350
|
} catch (error) {
|
|
216387
216351
|
logger4.error(
|
|
216388
|
-
{ tenantId, projectId,
|
|
216352
|
+
{ tenantId, projectId, agentId, relationId, data, error },
|
|
216389
216353
|
"Failed to update agent-function tool relation"
|
|
216390
216354
|
);
|
|
216391
216355
|
throw error;
|
|
@@ -216397,7 +216361,7 @@ var getAgentRelationById = (db) => async (params) => {
|
|
|
216397
216361
|
where: drizzleOrm.and(
|
|
216398
216362
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216399
216363
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216400
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216364
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216401
216365
|
drizzleOrm.eq(subAgentRelations.id, params.relationId)
|
|
216402
216366
|
)
|
|
216403
216367
|
});
|
|
@@ -216409,7 +216373,7 @@ var listAgentRelations = (db) => async (params) => {
|
|
|
216409
216373
|
const whereClause = drizzleOrm.and(
|
|
216410
216374
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216411
216375
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216412
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216376
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId)
|
|
216413
216377
|
);
|
|
216414
216378
|
const [data, totalResult] = await Promise.all([
|
|
216415
216379
|
db.select().from(subAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentRelations.createdAt)),
|
|
@@ -216424,17 +216388,17 @@ var getAgentRelations = (db) => async (params) => {
|
|
|
216424
216388
|
where: drizzleOrm.and(
|
|
216425
216389
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216426
216390
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216427
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216391
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216428
216392
|
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.scopes.subAgentId)
|
|
216429
216393
|
)
|
|
216430
216394
|
});
|
|
216431
216395
|
};
|
|
216432
|
-
var
|
|
216396
|
+
var getAgentRelationsByAgent = (db) => async (params) => {
|
|
216433
216397
|
return await db.query.subAgentRelations.findMany({
|
|
216434
216398
|
where: drizzleOrm.and(
|
|
216435
216399
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216436
216400
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216437
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216401
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId)
|
|
216438
216402
|
)
|
|
216439
216403
|
});
|
|
216440
216404
|
};
|
|
@@ -216445,7 +216409,7 @@ var getAgentRelationsBySource = (db) => async (params) => {
|
|
|
216445
216409
|
const whereClause = drizzleOrm.and(
|
|
216446
216410
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216447
216411
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216448
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216412
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216449
216413
|
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.sourceSubAgentId)
|
|
216450
216414
|
);
|
|
216451
216415
|
const [data, totalResult] = await Promise.all([
|
|
@@ -216466,7 +216430,7 @@ var getAgentRelationsByTarget = (db) => async (params) => {
|
|
|
216466
216430
|
const whereClause = drizzleOrm.and(
|
|
216467
216431
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216468
216432
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216469
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216433
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216470
216434
|
drizzleOrm.eq(subAgentRelations.targetSubAgentId, params.targetSubAgentId)
|
|
216471
216435
|
);
|
|
216472
216436
|
const [data, totalResult] = await Promise.all([
|
|
@@ -216487,7 +216451,7 @@ var getExternalAgentRelations = (db) => async (params) => {
|
|
|
216487
216451
|
const whereClause = drizzleOrm.and(
|
|
216488
216452
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216489
216453
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216490
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216454
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216491
216455
|
drizzleOrm.eq(subAgentRelations.externalSubAgentId, params.externalSubAgentId)
|
|
216492
216456
|
);
|
|
216493
216457
|
const [data, totalResult] = await Promise.all([
|
|
@@ -216501,7 +216465,7 @@ var getExternalAgentRelations = (db) => async (params) => {
|
|
|
216501
216465
|
pagination: { page, limit, total, pages }
|
|
216502
216466
|
};
|
|
216503
216467
|
};
|
|
216504
|
-
var
|
|
216468
|
+
var getRelatedAgentsForAgent = (db) => async (params) => {
|
|
216505
216469
|
const internalRelations = await db.select({
|
|
216506
216470
|
id: subAgents.id,
|
|
216507
216471
|
name: subAgents.name,
|
|
@@ -216513,13 +216477,13 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
|
|
|
216513
216477
|
drizzleOrm.eq(subAgentRelations.targetSubAgentId, subAgents.id),
|
|
216514
216478
|
drizzleOrm.eq(subAgentRelations.tenantId, subAgents.tenantId),
|
|
216515
216479
|
drizzleOrm.eq(subAgentRelations.projectId, subAgents.projectId),
|
|
216516
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216480
|
+
drizzleOrm.eq(subAgentRelations.agentId, subAgents.agentId)
|
|
216517
216481
|
)
|
|
216518
216482
|
).where(
|
|
216519
216483
|
drizzleOrm.and(
|
|
216520
216484
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216521
216485
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216522
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216486
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216523
216487
|
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.subAgentId),
|
|
216524
216488
|
drizzleOrm.isNotNull(subAgentRelations.targetSubAgentId)
|
|
216525
216489
|
)
|
|
@@ -216539,13 +216503,13 @@ var getRelatedAgentsForGraph = (db) => async (params) => {
|
|
|
216539
216503
|
drizzleOrm.eq(subAgentRelations.externalSubAgentId, externalAgents.id),
|
|
216540
216504
|
drizzleOrm.eq(subAgentRelations.tenantId, externalAgents.tenantId),
|
|
216541
216505
|
drizzleOrm.eq(subAgentRelations.projectId, externalAgents.projectId),
|
|
216542
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216506
|
+
drizzleOrm.eq(subAgentRelations.agentId, externalAgents.agentId)
|
|
216543
216507
|
)
|
|
216544
216508
|
).where(
|
|
216545
216509
|
drizzleOrm.and(
|
|
216546
216510
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216547
216511
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216548
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216512
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216549
216513
|
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.subAgentId),
|
|
216550
216514
|
drizzleOrm.isNotNull(subAgentRelations.externalSubAgentId)
|
|
216551
216515
|
)
|
|
@@ -216573,7 +216537,7 @@ var getAgentRelationByParams = (db) => async (params) => {
|
|
|
216573
216537
|
const whereConditions = [
|
|
216574
216538
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216575
216539
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216576
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216540
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216577
216541
|
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.sourceSubAgentId),
|
|
216578
216542
|
drizzleOrm.eq(subAgentRelations.relationType, params.relationType)
|
|
216579
216543
|
];
|
|
@@ -216589,7 +216553,7 @@ var getAgentRelationByParams = (db) => async (params) => {
|
|
|
216589
216553
|
};
|
|
216590
216554
|
var upsertAgentRelation = (db) => async (params) => {
|
|
216591
216555
|
const existing = await getAgentRelationByParams(db)({
|
|
216592
|
-
scopes: { tenantId: params.tenantId, projectId: params.projectId,
|
|
216556
|
+
scopes: { tenantId: params.tenantId, projectId: params.projectId, agentId: params.agentId },
|
|
216593
216557
|
sourceSubAgentId: params.sourceSubAgentId,
|
|
216594
216558
|
targetSubAgentId: params.targetSubAgentId,
|
|
216595
216559
|
externalSubAgentId: params.externalSubAgentId,
|
|
@@ -216615,7 +216579,7 @@ var updateAgentRelation = (db) => async (params) => {
|
|
|
216615
216579
|
drizzleOrm.and(
|
|
216616
216580
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216617
216581
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216618
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216582
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216619
216583
|
drizzleOrm.eq(subAgentRelations.id, params.relationId)
|
|
216620
216584
|
)
|
|
216621
216585
|
).returning();
|
|
@@ -216626,17 +216590,17 @@ var deleteSubAgentRelation = (db) => async (params) => {
|
|
|
216626
216590
|
drizzleOrm.and(
|
|
216627
216591
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216628
216592
|
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216629
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216593
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216630
216594
|
drizzleOrm.eq(subAgentRelations.id, params.relationId)
|
|
216631
216595
|
)
|
|
216632
216596
|
);
|
|
216633
216597
|
return (result.rowsAffected || 0) > 0;
|
|
216634
216598
|
};
|
|
216635
|
-
var
|
|
216599
|
+
var deleteAgentRelationsByAgent = (db) => async (params) => {
|
|
216636
216600
|
const result = await db.delete(subAgentRelations).where(
|
|
216637
216601
|
drizzleOrm.and(
|
|
216638
216602
|
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216639
|
-
drizzleOrm.eq(subAgentRelations.
|
|
216603
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId)
|
|
216640
216604
|
)
|
|
216641
216605
|
);
|
|
216642
216606
|
return (result.rowsAffected || 0) > 0;
|
|
@@ -216647,7 +216611,7 @@ var createAgentToolRelation = (db) => async (params) => {
|
|
|
216647
216611
|
id: finalRelationId,
|
|
216648
216612
|
tenantId: params.scopes.tenantId,
|
|
216649
216613
|
projectId: params.scopes.projectId,
|
|
216650
|
-
|
|
216614
|
+
agentId: params.scopes.agentId,
|
|
216651
216615
|
subAgentId: params.data.subAgentId,
|
|
216652
216616
|
toolId: params.data.toolId,
|
|
216653
216617
|
selectedTools: params.data.selectedTools,
|
|
@@ -216664,7 +216628,7 @@ var updateAgentToolRelation = (db) => async (params) => {
|
|
|
216664
216628
|
drizzleOrm.and(
|
|
216665
216629
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216666
216630
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216667
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216631
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216668
216632
|
drizzleOrm.eq(subAgentToolRelations.id, params.relationId)
|
|
216669
216633
|
)
|
|
216670
216634
|
).returning();
|
|
@@ -216675,7 +216639,7 @@ var deleteAgentToolRelation = (db) => async (params) => {
|
|
|
216675
216639
|
drizzleOrm.and(
|
|
216676
216640
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216677
216641
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216678
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216642
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216679
216643
|
drizzleOrm.eq(subAgentToolRelations.id, params.relationId)
|
|
216680
216644
|
)
|
|
216681
216645
|
);
|
|
@@ -216686,7 +216650,7 @@ var deleteAgentToolRelationByAgent = (db) => async (params) => {
|
|
|
216686
216650
|
drizzleOrm.and(
|
|
216687
216651
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216688
216652
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216689
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216653
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216690
216654
|
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
|
|
216691
216655
|
)
|
|
216692
216656
|
);
|
|
@@ -216697,7 +216661,7 @@ var getAgentToolRelationById = (db) => async (params) => {
|
|
|
216697
216661
|
where: drizzleOrm.and(
|
|
216698
216662
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216699
216663
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216700
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216664
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216701
216665
|
drizzleOrm.eq(subAgentToolRelations.id, params.relationId)
|
|
216702
216666
|
)
|
|
216703
216667
|
});
|
|
@@ -216738,7 +216702,7 @@ var getAgentToolRelationByTool = (db) => async (params) => {
|
|
|
216738
216702
|
drizzleOrm.and(
|
|
216739
216703
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216740
216704
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216741
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216705
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216742
216706
|
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
216743
216707
|
)
|
|
216744
216708
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentToolRelations.createdAt)),
|
|
@@ -216746,7 +216710,7 @@ var getAgentToolRelationByTool = (db) => async (params) => {
|
|
|
216746
216710
|
drizzleOrm.and(
|
|
216747
216711
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216748
216712
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216749
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216713
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216750
216714
|
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
216751
216715
|
)
|
|
216752
216716
|
)
|
|
@@ -216767,14 +216731,14 @@ var listAgentToolRelations = (db) => async (params) => {
|
|
|
216767
216731
|
drizzleOrm.and(
|
|
216768
216732
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216769
216733
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216770
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216734
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId)
|
|
216771
216735
|
)
|
|
216772
216736
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentToolRelations.createdAt)),
|
|
216773
216737
|
db.select({ count: drizzleOrm.count() }).from(subAgentToolRelations).where(
|
|
216774
216738
|
drizzleOrm.and(
|
|
216775
216739
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216776
216740
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216777
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216741
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId)
|
|
216778
216742
|
)
|
|
216779
216743
|
)
|
|
216780
216744
|
]);
|
|
@@ -216825,7 +216789,7 @@ var getToolsForAgent = (db) => async (params) => {
|
|
|
216825
216789
|
drizzleOrm.and(
|
|
216826
216790
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216827
216791
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216828
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216792
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216829
216793
|
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
|
|
216830
216794
|
)
|
|
216831
216795
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentToolRelations.createdAt)),
|
|
@@ -216833,7 +216797,7 @@ var getToolsForAgent = (db) => async (params) => {
|
|
|
216833
216797
|
drizzleOrm.and(
|
|
216834
216798
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216835
216799
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216836
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216800
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216837
216801
|
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.scopes.subAgentId)
|
|
216838
216802
|
)
|
|
216839
216803
|
)
|
|
@@ -216876,13 +216840,13 @@ var getAgentsForTool = (db) => async (params) => {
|
|
|
216876
216840
|
drizzleOrm.eq(subAgentToolRelations.subAgentId, subAgents.id),
|
|
216877
216841
|
drizzleOrm.eq(subAgentToolRelations.tenantId, subAgents.tenantId),
|
|
216878
216842
|
drizzleOrm.eq(subAgentToolRelations.projectId, subAgents.projectId),
|
|
216879
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216843
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, subAgents.agentId)
|
|
216880
216844
|
)
|
|
216881
216845
|
).where(
|
|
216882
216846
|
drizzleOrm.and(
|
|
216883
216847
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216884
216848
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216885
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216849
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216886
216850
|
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
216887
216851
|
)
|
|
216888
216852
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentToolRelations.createdAt)),
|
|
@@ -216890,7 +216854,7 @@ var getAgentsForTool = (db) => async (params) => {
|
|
|
216890
216854
|
drizzleOrm.and(
|
|
216891
216855
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
216892
216856
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
216893
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
216857
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
216894
216858
|
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
216895
216859
|
)
|
|
216896
216860
|
)
|
|
@@ -216907,7 +216871,7 @@ var validateInternalSubAgent = (db) => async (params) => {
|
|
|
216907
216871
|
drizzleOrm.and(
|
|
216908
216872
|
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
216909
216873
|
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
216910
|
-
drizzleOrm.eq(subAgents.
|
|
216874
|
+
drizzleOrm.eq(subAgents.agentId, params.scopes.agentId),
|
|
216911
216875
|
drizzleOrm.eq(subAgents.id, params.scopes.subAgentId)
|
|
216912
216876
|
)
|
|
216913
216877
|
).limit(1);
|
|
@@ -216918,7 +216882,7 @@ var validateExternalAgent = (db) => async (params) => {
|
|
|
216918
216882
|
drizzleOrm.and(
|
|
216919
216883
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
216920
216884
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
216921
|
-
drizzleOrm.eq(externalAgents.
|
|
216885
|
+
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId),
|
|
216922
216886
|
drizzleOrm.eq(externalAgents.id, params.scopes.subAgentId)
|
|
216923
216887
|
)
|
|
216924
216888
|
).limit(1);
|
|
@@ -216929,7 +216893,7 @@ var getSubAgentById = (db) => async (params) => {
|
|
|
216929
216893
|
where: drizzleOrm.and(
|
|
216930
216894
|
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
216931
216895
|
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
216932
|
-
drizzleOrm.eq(subAgents.
|
|
216896
|
+
drizzleOrm.eq(subAgents.agentId, params.scopes.agentId),
|
|
216933
216897
|
drizzleOrm.eq(subAgents.id, params.subAgentId)
|
|
216934
216898
|
)
|
|
216935
216899
|
});
|
|
@@ -216940,7 +216904,7 @@ var listSubAgents = (db) => async (params) => {
|
|
|
216940
216904
|
where: drizzleOrm.and(
|
|
216941
216905
|
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
216942
216906
|
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
216943
|
-
drizzleOrm.eq(subAgents.
|
|
216907
|
+
drizzleOrm.eq(subAgents.agentId, params.scopes.agentId)
|
|
216944
216908
|
)
|
|
216945
216909
|
});
|
|
216946
216910
|
};
|
|
@@ -216951,7 +216915,7 @@ var listSubAgentsPaginated = (db) => async (params) => {
|
|
|
216951
216915
|
const whereClause = drizzleOrm.and(
|
|
216952
216916
|
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
216953
216917
|
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
216954
|
-
drizzleOrm.eq(subAgents.
|
|
216918
|
+
drizzleOrm.eq(subAgents.agentId, params.scopes.agentId)
|
|
216955
216919
|
);
|
|
216956
216920
|
const [data, totalResult] = await Promise.all([
|
|
216957
216921
|
db.select().from(subAgents).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgents.createdAt)),
|
|
@@ -216983,7 +216947,7 @@ var updateSubAgent = (db) => async (params) => {
|
|
|
216983
216947
|
drizzleOrm.and(
|
|
216984
216948
|
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
216985
216949
|
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
216986
|
-
drizzleOrm.eq(subAgents.
|
|
216950
|
+
drizzleOrm.eq(subAgents.agentId, params.scopes.agentId),
|
|
216987
216951
|
drizzleOrm.eq(subAgents.id, params.subAgentId)
|
|
216988
216952
|
)
|
|
216989
216953
|
).returning();
|
|
@@ -216993,7 +216957,7 @@ var upsertSubAgent = (db) => async (params) => {
|
|
|
216993
216957
|
const scopes = {
|
|
216994
216958
|
tenantId: params.data.tenantId,
|
|
216995
216959
|
projectId: params.data.projectId,
|
|
216996
|
-
|
|
216960
|
+
agentId: params.data.agentId
|
|
216997
216961
|
};
|
|
216998
216962
|
const existing = await getSubAgentById(db)({
|
|
216999
216963
|
scopes,
|
|
@@ -217025,7 +216989,7 @@ var deleteSubAgent = (db) => async (params) => {
|
|
|
217025
216989
|
drizzleOrm.and(
|
|
217026
216990
|
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
217027
216991
|
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
217028
|
-
drizzleOrm.eq(subAgents.
|
|
216992
|
+
drizzleOrm.eq(subAgents.agentId, params.scopes.agentId),
|
|
217029
216993
|
drizzleOrm.eq(subAgents.id, params.subAgentId)
|
|
217030
216994
|
)
|
|
217031
216995
|
);
|
|
@@ -217043,7 +217007,7 @@ var getSubAgentsByIds = (db) => async (params) => {
|
|
|
217043
217007
|
drizzleOrm.and(
|
|
217044
217008
|
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
217045
217009
|
drizzleOrm.eq(subAgents.projectId, params.scopes.projectId),
|
|
217046
|
-
drizzleOrm.eq(subAgents.
|
|
217010
|
+
drizzleOrm.eq(subAgents.agentId, params.scopes.agentId),
|
|
217047
217011
|
drizzleOrm.inArray(subAgents.id, params.subAgentIds)
|
|
217048
217012
|
)
|
|
217049
217013
|
);
|
|
@@ -217511,7 +217475,7 @@ function createExecutionContext(params) {
|
|
|
217511
217475
|
apiKey: params.apiKey,
|
|
217512
217476
|
tenantId: params.tenantId,
|
|
217513
217477
|
projectId: params.projectId,
|
|
217514
|
-
|
|
217478
|
+
agentId: params.agentId,
|
|
217515
217479
|
baseUrl: params.baseUrl || process.env.API_URL || "http://localhost:3003",
|
|
217516
217480
|
apiKeyId: params.apiKeyId
|
|
217517
217481
|
};
|
|
@@ -218131,7 +218095,7 @@ var addToolToAgent = (db) => async (params) => {
|
|
|
218131
218095
|
id,
|
|
218132
218096
|
tenantId: params.scopes.tenantId,
|
|
218133
218097
|
projectId: params.scopes.projectId,
|
|
218134
|
-
|
|
218098
|
+
agentId: params.scopes.agentId,
|
|
218135
218099
|
subAgentId: params.subAgentId,
|
|
218136
218100
|
toolId: params.toolId,
|
|
218137
218101
|
selectedTools: params.selectedTools,
|
|
@@ -218146,7 +218110,7 @@ var removeToolFromAgent = (db) => async (params) => {
|
|
|
218146
218110
|
drizzleOrm.and(
|
|
218147
218111
|
drizzleOrm.eq(subAgentToolRelations.tenantId, params.scopes.tenantId),
|
|
218148
218112
|
drizzleOrm.eq(subAgentToolRelations.projectId, params.scopes.projectId),
|
|
218149
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
218113
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, params.scopes.agentId),
|
|
218150
218114
|
drizzleOrm.eq(subAgentToolRelations.subAgentId, params.subAgentId),
|
|
218151
218115
|
drizzleOrm.eq(subAgentToolRelations.toolId, params.toolId)
|
|
218152
218116
|
)
|
|
@@ -218191,23 +218155,23 @@ var upsertTool = (db) => async (params) => {
|
|
|
218191
218155
|
}
|
|
218192
218156
|
};
|
|
218193
218157
|
|
|
218194
|
-
// src/data-access/
|
|
218195
|
-
var
|
|
218196
|
-
const result = await db.query.
|
|
218158
|
+
// src/data-access/agents.ts
|
|
218159
|
+
var getAgentById = (db) => async (params) => {
|
|
218160
|
+
const result = await db.query.agents.findFirst({
|
|
218197
218161
|
where: drizzleOrm.and(
|
|
218198
|
-
drizzleOrm.eq(
|
|
218199
|
-
drizzleOrm.eq(
|
|
218200
|
-
drizzleOrm.eq(
|
|
218162
|
+
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
218163
|
+
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
218164
|
+
drizzleOrm.eq(agents.id, params.scopes.agentId)
|
|
218201
218165
|
)
|
|
218202
218166
|
});
|
|
218203
218167
|
return result ?? null;
|
|
218204
218168
|
};
|
|
218205
|
-
var
|
|
218206
|
-
const result = await db.query.
|
|
218169
|
+
var getAgentWithDefaultSubAgent = (db) => async (params) => {
|
|
218170
|
+
const result = await db.query.agents.findFirst({
|
|
218207
218171
|
where: drizzleOrm.and(
|
|
218208
|
-
drizzleOrm.eq(
|
|
218209
|
-
drizzleOrm.eq(
|
|
218210
|
-
drizzleOrm.eq(
|
|
218172
|
+
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
218173
|
+
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
218174
|
+
drizzleOrm.eq(agents.id, params.scopes.agentId)
|
|
218211
218175
|
),
|
|
218212
218176
|
with: {
|
|
218213
218177
|
defaultSubAgent: true
|
|
@@ -218215,26 +218179,26 @@ var getAgentGraphWithDefaultSubAgent = (db) => async (params) => {
|
|
|
218215
218179
|
});
|
|
218216
218180
|
return result ?? null;
|
|
218217
218181
|
};
|
|
218218
|
-
var
|
|
218219
|
-
return await db.query.
|
|
218182
|
+
var listAgents = (db) => async (params) => {
|
|
218183
|
+
return await db.query.agents.findMany({
|
|
218220
218184
|
where: drizzleOrm.and(
|
|
218221
|
-
drizzleOrm.eq(
|
|
218222
|
-
drizzleOrm.eq(
|
|
218185
|
+
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
218186
|
+
drizzleOrm.eq(agents.projectId, params.scopes.projectId)
|
|
218223
218187
|
)
|
|
218224
218188
|
});
|
|
218225
218189
|
};
|
|
218226
|
-
var
|
|
218190
|
+
var listAgentsPaginated = (db) => async (params) => {
|
|
218227
218191
|
const page = params.pagination?.page || 1;
|
|
218228
218192
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
218229
218193
|
const offset = (page - 1) * limit;
|
|
218230
218194
|
const whereClause = drizzleOrm.and(
|
|
218231
|
-
drizzleOrm.eq(
|
|
218232
|
-
drizzleOrm.eq(
|
|
218195
|
+
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
218196
|
+
drizzleOrm.eq(agents.projectId, params.scopes.projectId)
|
|
218233
218197
|
);
|
|
218234
|
-
const query = db.select().from(
|
|
218198
|
+
const query = db.select().from(agents).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(agents.createdAt));
|
|
218235
218199
|
const [data, totalResult] = await Promise.all([
|
|
218236
218200
|
query,
|
|
218237
|
-
db.select({ count: drizzleOrm.count() }).from(
|
|
218201
|
+
db.select({ count: drizzleOrm.count() }).from(agents).where(whereClause)
|
|
218238
218202
|
]);
|
|
218239
218203
|
const total = totalResult[0]?.count || 0;
|
|
218240
218204
|
const pages = Math.ceil(total / limit);
|
|
@@ -218243,74 +218207,62 @@ var listAgentGraphsPaginated = (db) => async (params) => {
|
|
|
218243
218207
|
pagination: { page, limit, total, pages }
|
|
218244
218208
|
};
|
|
218245
218209
|
};
|
|
218246
|
-
var
|
|
218210
|
+
var createAgent = (db) => async (data) => {
|
|
218247
218211
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
218248
218212
|
const insertData = {
|
|
218249
218213
|
...data,
|
|
218250
218214
|
createdAt: now,
|
|
218251
|
-
updatedAt: now
|
|
218215
|
+
updatedAt: now,
|
|
218216
|
+
...data.description !== void 0 && { description: data.description },
|
|
218217
|
+
...data.contextConfigId !== void 0 && { contextConfigId: data.contextConfigId },
|
|
218218
|
+
...data.models !== void 0 && { models: data.models },
|
|
218219
|
+
...data.statusUpdates !== void 0 && { statusUpdates: data.statusUpdates },
|
|
218220
|
+
...data.prompt !== void 0 && { prompt: data.prompt },
|
|
218221
|
+
...data.stopWhen !== void 0 && { stopWhen: data.stopWhen }
|
|
218252
218222
|
};
|
|
218253
|
-
|
|
218254
|
-
|
|
218255
|
-
}
|
|
218256
|
-
if (data.contextConfigId !== void 0) {
|
|
218257
|
-
insertData.contextConfigId = data.contextConfigId;
|
|
218258
|
-
}
|
|
218259
|
-
if (data.models !== void 0) {
|
|
218260
|
-
insertData.models = data.models;
|
|
218261
|
-
}
|
|
218262
|
-
if (data.statusUpdates !== void 0) {
|
|
218263
|
-
insertData.statusUpdates = data.statusUpdates;
|
|
218264
|
-
}
|
|
218265
|
-
if (data.graphPrompt !== void 0) {
|
|
218266
|
-
insertData.graphPrompt = data.graphPrompt;
|
|
218267
|
-
}
|
|
218268
|
-
if (data.stopWhen !== void 0) {
|
|
218269
|
-
insertData.stopWhen = data.stopWhen;
|
|
218270
|
-
}
|
|
218271
|
-
const graph = await db.insert(agentGraph).values(insertData).returning();
|
|
218272
|
-
return graph[0];
|
|
218223
|
+
const agent = await db.insert(agents).values(insertData).returning();
|
|
218224
|
+
return agent[0];
|
|
218273
218225
|
};
|
|
218274
|
-
var
|
|
218226
|
+
var updateAgent = (db) => async (params) => {
|
|
218275
218227
|
const data = params.data;
|
|
218228
|
+
const updateData = {
|
|
218229
|
+
...data,
|
|
218230
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
218231
|
+
};
|
|
218276
218232
|
if (data.models !== void 0) {
|
|
218277
218233
|
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) {
|
|
218278
|
-
|
|
218234
|
+
updateData.models = null;
|
|
218279
218235
|
}
|
|
218280
218236
|
}
|
|
218281
218237
|
if (data.statusUpdates !== void 0) {
|
|
218282
218238
|
if (!data.statusUpdates) {
|
|
218283
|
-
|
|
218239
|
+
updateData.statusUpdates = null;
|
|
218284
218240
|
}
|
|
218285
218241
|
}
|
|
218286
218242
|
if (data.contextConfigId !== void 0 && !data.contextConfigId) {
|
|
218287
|
-
|
|
218243
|
+
updateData.contextConfigId = null;
|
|
218288
218244
|
}
|
|
218289
|
-
if (data.
|
|
218290
|
-
|
|
218245
|
+
if (data.prompt !== void 0 && !data.prompt) {
|
|
218246
|
+
updateData.prompt = null;
|
|
218291
218247
|
}
|
|
218292
218248
|
if (data.stopWhen !== void 0 && !data.stopWhen) {
|
|
218293
|
-
|
|
218249
|
+
updateData.stopWhen = null;
|
|
218294
218250
|
}
|
|
218295
|
-
const
|
|
218296
|
-
...data,
|
|
218297
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
218298
|
-
};
|
|
218299
|
-
const graph = await db.update(agentGraph).set(updateData).where(
|
|
218251
|
+
const agent = await db.update(agents).set(updateData).where(
|
|
218300
218252
|
drizzleOrm.and(
|
|
218301
|
-
drizzleOrm.eq(
|
|
218302
|
-
drizzleOrm.eq(
|
|
218303
|
-
drizzleOrm.eq(
|
|
218253
|
+
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
218254
|
+
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
218255
|
+
drizzleOrm.eq(agents.id, params.scopes.agentId)
|
|
218304
218256
|
)
|
|
218305
218257
|
).returning();
|
|
218306
|
-
return
|
|
218258
|
+
return agent[0] ?? null;
|
|
218307
218259
|
};
|
|
218308
|
-
var
|
|
218309
|
-
const result = await db.delete(
|
|
218260
|
+
var deleteAgent = (db) => async (params) => {
|
|
218261
|
+
const result = await db.delete(agents).where(
|
|
218310
218262
|
drizzleOrm.and(
|
|
218311
|
-
drizzleOrm.eq(
|
|
218312
|
-
drizzleOrm.eq(
|
|
218313
|
-
drizzleOrm.eq(
|
|
218263
|
+
drizzleOrm.eq(agents.tenantId, params.scopes.tenantId),
|
|
218264
|
+
drizzleOrm.eq(agents.projectId, params.scopes.projectId),
|
|
218265
|
+
drizzleOrm.eq(agents.id, params.scopes.agentId)
|
|
218314
218266
|
)
|
|
218315
218267
|
).returning();
|
|
218316
218268
|
return result.length > 0;
|
|
@@ -218318,7 +218270,10 @@ var deleteAgentGraph = (db) => async (params) => {
|
|
|
218318
218270
|
var fetchComponentRelationships = (db) => async (scopes, subAgentIds, config) => {
|
|
218319
218271
|
const componentsObject = {};
|
|
218320
218272
|
if (subAgentIds.length > 0) {
|
|
218321
|
-
const results = await db.select(config.selectFields).from(config.relationTable).innerJoin(
|
|
218273
|
+
const results = await db.select(config.selectFields).from(config.relationTable).innerJoin(
|
|
218274
|
+
config.componentTable,
|
|
218275
|
+
drizzleOrm.eq(config.relationIdField, config.componentIdField)
|
|
218276
|
+
).where(
|
|
218322
218277
|
drizzleOrm.and(
|
|
218323
218278
|
drizzleOrm.eq(config.relationTable.tenantId, scopes.tenantId),
|
|
218324
218279
|
drizzleOrm.eq(config.relationTable.projectId, scopes.projectId),
|
|
@@ -218331,20 +218286,19 @@ var fetchComponentRelationships = (db) => async (scopes, subAgentIds, config) =>
|
|
|
218331
218286
|
}
|
|
218332
218287
|
return componentsObject;
|
|
218333
218288
|
};
|
|
218334
|
-
var
|
|
218335
|
-
scopes,
|
|
218336
|
-
|
|
218289
|
+
var getAgentSubAgentInfos = (db) => async ({
|
|
218290
|
+
scopes: { tenantId, projectId },
|
|
218291
|
+
agentId,
|
|
218337
218292
|
subAgentId
|
|
218338
218293
|
}) => {
|
|
218339
|
-
const
|
|
218340
|
-
|
|
218341
|
-
scopes: { tenantId, projectId, graphId }
|
|
218294
|
+
const agent = await getAgentById(db)({
|
|
218295
|
+
scopes: { tenantId, projectId, agentId }
|
|
218342
218296
|
});
|
|
218343
|
-
if (!
|
|
218344
|
-
throw new Error(`Agent
|
|
218297
|
+
if (!agent) {
|
|
218298
|
+
throw new Error(`Agent with ID ${agentId} not found for tenant ${tenantId}`);
|
|
218345
218299
|
}
|
|
218346
218300
|
const relations2 = await getAgentRelations(db)({
|
|
218347
|
-
scopes: { tenantId, projectId,
|
|
218301
|
+
scopes: { tenantId, projectId, agentId, subAgentId }
|
|
218348
218302
|
});
|
|
218349
218303
|
const targetSubAgentIds = relations2.map((relation) => relation.targetSubAgentId).filter((id) => id !== null);
|
|
218350
218304
|
if (targetSubAgentIds.length === 0) {
|
|
@@ -218352,48 +218306,45 @@ var getGraphAgentInfos = (db) => async ({
|
|
|
218352
218306
|
}
|
|
218353
218307
|
const agentInfos = await Promise.all(
|
|
218354
218308
|
targetSubAgentIds.map(async (subAgentId2) => {
|
|
218355
|
-
const
|
|
218356
|
-
scopes: { tenantId, projectId,
|
|
218309
|
+
const agent2 = await getSubAgentById(db)({
|
|
218310
|
+
scopes: { tenantId, projectId, agentId },
|
|
218357
218311
|
subAgentId: subAgentId2
|
|
218358
218312
|
});
|
|
218359
|
-
|
|
218360
|
-
return { id: agent.id, name: agent.name, description: agent.description };
|
|
218361
|
-
}
|
|
218362
|
-
return null;
|
|
218313
|
+
return agent2 ? { id: agent2.id, name: agent2.name, description: agent2.description } : null;
|
|
218363
218314
|
})
|
|
218364
218315
|
);
|
|
218365
|
-
return agentInfos.filter((
|
|
218316
|
+
return agentInfos.filter((agent2) => agent2 !== null);
|
|
218366
218317
|
};
|
|
218367
|
-
var
|
|
218368
|
-
scopes: { tenantId, projectId,
|
|
218318
|
+
var getFullAgentDefinition = (db) => async ({
|
|
218319
|
+
scopes: { tenantId, projectId, agentId }
|
|
218369
218320
|
}) => {
|
|
218370
|
-
const
|
|
218371
|
-
scopes: { tenantId, projectId,
|
|
218321
|
+
const agent = await getAgentById(db)({
|
|
218322
|
+
scopes: { tenantId, projectId, agentId }
|
|
218372
218323
|
});
|
|
218373
|
-
if (!
|
|
218324
|
+
if (!agent) {
|
|
218374
218325
|
return null;
|
|
218375
218326
|
}
|
|
218376
|
-
const
|
|
218377
|
-
scopes: { tenantId, projectId,
|
|
218327
|
+
const agentRelations2 = await getAgentRelationsByAgent(db)({
|
|
218328
|
+
scopes: { tenantId, projectId, agentId }
|
|
218378
218329
|
});
|
|
218379
|
-
const
|
|
218330
|
+
const agentSubAgents = await db.query.subAgents.findMany({
|
|
218380
218331
|
where: drizzleOrm.and(
|
|
218381
218332
|
drizzleOrm.eq(subAgents.tenantId, tenantId),
|
|
218382
218333
|
drizzleOrm.eq(subAgents.projectId, projectId),
|
|
218383
|
-
drizzleOrm.eq(subAgents.
|
|
218334
|
+
drizzleOrm.eq(subAgents.agentId, agentId)
|
|
218384
218335
|
)
|
|
218385
218336
|
});
|
|
218386
218337
|
const externalSubAgentIds = /* @__PURE__ */ new Set();
|
|
218387
|
-
for (const relation of
|
|
218338
|
+
for (const relation of agentRelations2) {
|
|
218388
218339
|
if (relation.externalSubAgentId) {
|
|
218389
218340
|
externalSubAgentIds.add(relation.externalSubAgentId);
|
|
218390
218341
|
}
|
|
218391
218342
|
}
|
|
218392
218343
|
const processedSubAgents = await Promise.all(
|
|
218393
|
-
|
|
218394
|
-
if (!
|
|
218395
|
-
const subAgentRelationsList =
|
|
218396
|
-
(relation) => relation.sourceSubAgentId ===
|
|
218344
|
+
agentSubAgents.map(async (agent2) => {
|
|
218345
|
+
if (!agent2) return null;
|
|
218346
|
+
const subAgentRelationsList = agentRelations2.filter(
|
|
218347
|
+
(relation) => relation.sourceSubAgentId === agent2.id
|
|
218397
218348
|
);
|
|
218398
218349
|
const canTransferTo = subAgentRelationsList.filter((rel) => rel.relationType === "transfer" || rel.relationType === "transfer_to").map((rel) => rel.targetSubAgentId).filter((id) => id !== null);
|
|
218399
218350
|
const canDelegateTo = subAgentRelationsList.filter((rel) => rel.relationType === "delegate" || rel.relationType === "delegate_to").map((rel) => rel.targetSubAgentId || rel.externalSubAgentId).filter((id) => id !== null);
|
|
@@ -218423,8 +218374,8 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218423
218374
|
drizzleOrm.and(
|
|
218424
218375
|
drizzleOrm.eq(subAgentToolRelations.tenantId, tenantId),
|
|
218425
218376
|
drizzleOrm.eq(subAgentToolRelations.projectId, projectId),
|
|
218426
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
218427
|
-
drizzleOrm.eq(subAgentToolRelations.subAgentId,
|
|
218377
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, agentId),
|
|
218378
|
+
drizzleOrm.eq(subAgentToolRelations.subAgentId, agent2.id)
|
|
218428
218379
|
)
|
|
218429
218380
|
);
|
|
218430
218381
|
const agentFunctionTools = await db.select({
|
|
@@ -218436,7 +218387,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218436
218387
|
updatedAt: functionTools.updatedAt,
|
|
218437
218388
|
tenantId: functionTools.tenantId,
|
|
218438
218389
|
projectId: functionTools.projectId,
|
|
218439
|
-
|
|
218390
|
+
agentId: functionTools.agentId,
|
|
218440
218391
|
agentToolRelationId: agentFunctionToolRelations.id
|
|
218441
218392
|
}).from(agentFunctionToolRelations).innerJoin(
|
|
218442
218393
|
functionTools,
|
|
@@ -218444,27 +218395,27 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218444
218395
|
drizzleOrm.eq(agentFunctionToolRelations.functionToolId, functionTools.id),
|
|
218445
218396
|
drizzleOrm.eq(agentFunctionToolRelations.tenantId, functionTools.tenantId),
|
|
218446
218397
|
drizzleOrm.eq(agentFunctionToolRelations.projectId, functionTools.projectId),
|
|
218447
|
-
drizzleOrm.eq(agentFunctionToolRelations.
|
|
218398
|
+
drizzleOrm.eq(agentFunctionToolRelations.agentId, functionTools.agentId)
|
|
218448
218399
|
)
|
|
218449
218400
|
).where(
|
|
218450
218401
|
drizzleOrm.and(
|
|
218451
218402
|
drizzleOrm.eq(agentFunctionToolRelations.tenantId, tenantId),
|
|
218452
218403
|
drizzleOrm.eq(agentFunctionToolRelations.projectId, projectId),
|
|
218453
|
-
drizzleOrm.eq(agentFunctionToolRelations.
|
|
218454
|
-
drizzleOrm.eq(agentFunctionToolRelations.subAgentId,
|
|
218404
|
+
drizzleOrm.eq(agentFunctionToolRelations.agentId, agentId),
|
|
218405
|
+
drizzleOrm.eq(agentFunctionToolRelations.subAgentId, agent2.id)
|
|
218455
218406
|
)
|
|
218456
218407
|
);
|
|
218457
218408
|
const agentDataComponentRelations = await db.query.subAgentDataComponents.findMany({
|
|
218458
218409
|
where: drizzleOrm.and(
|
|
218459
218410
|
drizzleOrm.eq(subAgentDataComponents.tenantId, tenantId),
|
|
218460
|
-
drizzleOrm.eq(subAgentDataComponents.subAgentId,
|
|
218411
|
+
drizzleOrm.eq(subAgentDataComponents.subAgentId, agent2.id)
|
|
218461
218412
|
)
|
|
218462
218413
|
});
|
|
218463
218414
|
const agentDataComponentIds = agentDataComponentRelations.map((rel) => rel.dataComponentId);
|
|
218464
218415
|
const agentArtifactComponentRelations = await db.query.subAgentArtifactComponents.findMany({
|
|
218465
218416
|
where: drizzleOrm.and(
|
|
218466
218417
|
drizzleOrm.eq(subAgentArtifactComponents.tenantId, tenantId),
|
|
218467
|
-
drizzleOrm.eq(subAgentArtifactComponents.subAgentId,
|
|
218418
|
+
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, agent2.id)
|
|
218468
218419
|
)
|
|
218469
218420
|
});
|
|
218470
218421
|
const agentArtifactComponentIds = agentArtifactComponentRelations.map(
|
|
@@ -218486,12 +218437,12 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218486
218437
|
}));
|
|
218487
218438
|
const canUse = [...mcpToolCanUse, ...functionToolCanUse];
|
|
218488
218439
|
return {
|
|
218489
|
-
id:
|
|
218490
|
-
name:
|
|
218491
|
-
description:
|
|
218492
|
-
prompt:
|
|
218493
|
-
models:
|
|
218494
|
-
stopWhen:
|
|
218440
|
+
id: agent2.id,
|
|
218441
|
+
name: agent2.name,
|
|
218442
|
+
description: agent2.description,
|
|
218443
|
+
prompt: agent2.prompt,
|
|
218444
|
+
models: agent2.models,
|
|
218445
|
+
stopWhen: agent2.stopWhen,
|
|
218495
218446
|
canTransferTo,
|
|
218496
218447
|
canDelegateTo,
|
|
218497
218448
|
dataComponents: agentDataComponentIds,
|
|
@@ -218503,54 +218454,48 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218503
218454
|
const externalAgents2 = await Promise.all(
|
|
218504
218455
|
Array.from(externalSubAgentIds).map(async (subAgentId) => {
|
|
218505
218456
|
const subAgent = await getExternalAgent(db)({
|
|
218506
|
-
scopes: { tenantId, projectId,
|
|
218457
|
+
scopes: { tenantId, projectId, agentId },
|
|
218507
218458
|
subAgentId
|
|
218508
218459
|
});
|
|
218509
218460
|
if (!subAgent) return null;
|
|
218510
218461
|
return {
|
|
218511
|
-
|
|
218512
|
-
name: subAgent.name,
|
|
218513
|
-
description: subAgent.description,
|
|
218514
|
-
baseUrl: subAgent.baseUrl,
|
|
218515
|
-
headers: subAgent.headers,
|
|
218516
|
-
credentialReferenceId: subAgent.credentialReferenceId,
|
|
218462
|
+
...subAgent,
|
|
218517
218463
|
type: "external"
|
|
218518
218464
|
};
|
|
218519
218465
|
})
|
|
218520
218466
|
);
|
|
218521
|
-
const
|
|
218522
|
-
(
|
|
218467
|
+
const validSubAgents = [...processedSubAgents, ...externalAgents2].filter(
|
|
218468
|
+
(agent2) => agent2 !== null
|
|
218523
218469
|
);
|
|
218524
218470
|
const agentsObject = {};
|
|
218525
|
-
for (const
|
|
218526
|
-
|
|
218527
|
-
|
|
218528
|
-
|
|
218529
|
-
|
|
218530
|
-
|
|
218531
|
-
|
|
218532
|
-
|
|
218533
|
-
|
|
218534
|
-
headers: agent.headers,
|
|
218471
|
+
for (const subAgent of validSubAgents) {
|
|
218472
|
+
if ("baseUrl" in subAgent && subAgent.baseUrl) {
|
|
218473
|
+
agentsObject[subAgent.id] = {
|
|
218474
|
+
id: subAgent.id,
|
|
218475
|
+
name: subAgent.name,
|
|
218476
|
+
description: subAgent.description,
|
|
218477
|
+
baseUrl: subAgent.baseUrl,
|
|
218478
|
+
credentialReferenceId: subAgent.credentialReferenceId,
|
|
218479
|
+
headers: subAgent.headers,
|
|
218535
218480
|
type: "external"
|
|
218536
218481
|
};
|
|
218537
218482
|
} else {
|
|
218538
|
-
agentsObject[
|
|
218483
|
+
agentsObject[subAgent.id] = subAgent;
|
|
218539
218484
|
}
|
|
218540
218485
|
}
|
|
218541
218486
|
let contextConfig2 = null;
|
|
218542
|
-
if (
|
|
218487
|
+
if (agent.contextConfigId) {
|
|
218543
218488
|
try {
|
|
218544
218489
|
contextConfig2 = await getContextConfigById(db)({
|
|
218545
|
-
scopes: { tenantId, projectId,
|
|
218546
|
-
id:
|
|
218490
|
+
scopes: { tenantId, projectId, agentId },
|
|
218491
|
+
id: agent.contextConfigId
|
|
218547
218492
|
});
|
|
218548
218493
|
} catch (error) {
|
|
218549
|
-
console.warn(`Failed to retrieve contextConfig ${
|
|
218494
|
+
console.warn(`Failed to retrieve contextConfig ${agent.contextConfigId}:`, error);
|
|
218550
218495
|
}
|
|
218551
218496
|
}
|
|
218552
218497
|
try {
|
|
218553
|
-
const internalAgentIds =
|
|
218498
|
+
const internalAgentIds = agentSubAgents.map((subAgent) => subAgent.id);
|
|
218554
218499
|
const subAgentIds = Array.from(internalAgentIds);
|
|
218555
218500
|
await fetchComponentRelationships(db)({ tenantId, projectId }, subAgentIds, {
|
|
218556
218501
|
relationTable: subAgentDataComponents,
|
|
@@ -218569,7 +218514,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218569
218514
|
console.warn("Failed to retrieve dataComponents:", error);
|
|
218570
218515
|
}
|
|
218571
218516
|
try {
|
|
218572
|
-
const internalAgentIds =
|
|
218517
|
+
const internalAgentIds = agentSubAgents.map((subAgent) => subAgent.id);
|
|
218573
218518
|
const subAgentIds = Array.from(internalAgentIds);
|
|
218574
218519
|
await fetchComponentRelationships(db)({ tenantId, projectId }, subAgentIds, {
|
|
218575
218520
|
relationTable: subAgentArtifactComponents,
|
|
@@ -218588,33 +218533,29 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218588
218533
|
console.warn("Failed to retrieve artifactComponents:", error);
|
|
218589
218534
|
}
|
|
218590
218535
|
const result = {
|
|
218591
|
-
id:
|
|
218592
|
-
name:
|
|
218593
|
-
description:
|
|
218594
|
-
defaultSubAgentId:
|
|
218536
|
+
id: agent.id,
|
|
218537
|
+
name: agent.name,
|
|
218538
|
+
description: agent.description,
|
|
218539
|
+
defaultSubAgentId: agent.defaultSubAgentId,
|
|
218595
218540
|
subAgents: agentsObject,
|
|
218596
|
-
|
|
218597
|
-
|
|
218598
|
-
updatedAt: graph.updatedAt && !Number.isNaN(new Date(graph.updatedAt).getTime()) ? new Date(graph.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
218541
|
+
createdAt: agent.createdAt && !Number.isNaN(new Date(agent.createdAt).getTime()) ? new Date(agent.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
218542
|
+
updatedAt: agent.updatedAt && !Number.isNaN(new Date(agent.updatedAt).getTime()) ? new Date(agent.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
218599
218543
|
};
|
|
218600
|
-
if (
|
|
218601
|
-
result.models =
|
|
218544
|
+
if (agent.models) {
|
|
218545
|
+
result.models = agent.models;
|
|
218602
218546
|
}
|
|
218603
|
-
if (
|
|
218604
|
-
result.statusUpdates =
|
|
218547
|
+
if (agent.statusUpdates) {
|
|
218548
|
+
result.statusUpdates = agent.statusUpdates;
|
|
218605
218549
|
}
|
|
218606
|
-
if (
|
|
218607
|
-
result.
|
|
218550
|
+
if (agent.prompt) {
|
|
218551
|
+
result.prompt = agent.prompt;
|
|
218608
218552
|
}
|
|
218609
|
-
if (
|
|
218610
|
-
result.stopWhen =
|
|
218553
|
+
if (agent.stopWhen) {
|
|
218554
|
+
result.stopWhen = agent.stopWhen;
|
|
218611
218555
|
}
|
|
218612
218556
|
if (contextConfig2) {
|
|
218613
|
-
|
|
218614
|
-
|
|
218615
|
-
headersSchema: contextConfig2.headersSchema,
|
|
218616
|
-
contextVariables: contextConfig2.contextVariables
|
|
218617
|
-
};
|
|
218557
|
+
const { id, headersSchema, contextVariables } = contextConfig2;
|
|
218558
|
+
result.contextConfig = { id, headersSchema, contextVariables };
|
|
218618
218559
|
}
|
|
218619
218560
|
try {
|
|
218620
218561
|
if (!db.query?.projects?.findFirst) {
|
|
@@ -218625,33 +218566,36 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218625
218566
|
});
|
|
218626
218567
|
if (project?.stopWhen) {
|
|
218627
218568
|
const projectStopWhen = project.stopWhen;
|
|
218628
|
-
if (projectStopWhen
|
|
218629
|
-
|
|
218630
|
-
|
|
218631
|
-
|
|
218632
|
-
|
|
218633
|
-
|
|
218634
|
-
|
|
218635
|
-
|
|
218636
|
-
|
|
218637
|
-
|
|
218638
|
-
|
|
218639
|
-
|
|
218640
|
-
|
|
218641
|
-
|
|
218642
|
-
|
|
218643
|
-
|
|
218644
|
-
|
|
218645
|
-
drizzleOrm.
|
|
218646
|
-
|
|
218647
|
-
|
|
218648
|
-
|
|
218649
|
-
|
|
218650
|
-
|
|
218651
|
-
|
|
218652
|
-
|
|
218653
|
-
|
|
218654
|
-
|
|
218569
|
+
if (projectStopWhen.stepCountIs !== void 0) {
|
|
218570
|
+
const resultSubAgents = result.subAgents;
|
|
218571
|
+
if (resultSubAgents) {
|
|
218572
|
+
for (const [subAgentId, agentData] of Object.entries(resultSubAgents)) {
|
|
218573
|
+
if (agentData && typeof agentData === "object" && !("baseUrl" in agentData)) {
|
|
218574
|
+
const agent2 = agentData;
|
|
218575
|
+
const needsInheritance = !agent2.stopWhen || agent2.stopWhen.stepCountIs === void 0;
|
|
218576
|
+
if (needsInheritance) {
|
|
218577
|
+
if (!agent2.stopWhen) {
|
|
218578
|
+
agent2.stopWhen = {};
|
|
218579
|
+
}
|
|
218580
|
+
agent2.stopWhen.stepCountIs = projectStopWhen.stepCountIs;
|
|
218581
|
+
try {
|
|
218582
|
+
await db.update(subAgents).set({
|
|
218583
|
+
stopWhen: agent2.stopWhen,
|
|
218584
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
218585
|
+
}).where(
|
|
218586
|
+
drizzleOrm.and(
|
|
218587
|
+
drizzleOrm.eq(subAgents.tenantId, tenantId),
|
|
218588
|
+
drizzleOrm.eq(subAgents.projectId, projectId),
|
|
218589
|
+
drizzleOrm.eq(subAgents.id, subAgentId)
|
|
218590
|
+
)
|
|
218591
|
+
);
|
|
218592
|
+
result.subAgents[subAgentId] = {
|
|
218593
|
+
...result.subAgents[subAgentId],
|
|
218594
|
+
stopWhen: agent2.stopWhen
|
|
218595
|
+
};
|
|
218596
|
+
} catch (dbError) {
|
|
218597
|
+
console.warn(`Failed to persist stopWhen for agent ${subAgentId}:`, dbError);
|
|
218598
|
+
}
|
|
218655
218599
|
}
|
|
218656
218600
|
}
|
|
218657
218601
|
}
|
|
@@ -218679,7 +218623,7 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218679
218623
|
}
|
|
218680
218624
|
result.tools = toolsObject;
|
|
218681
218625
|
const functionToolsList = await listFunctionTools(db)({
|
|
218682
|
-
scopes: { tenantId, projectId,
|
|
218626
|
+
scopes: { tenantId, projectId, agentId },
|
|
218683
218627
|
pagination: { page: 1, limit: 1e3 }
|
|
218684
218628
|
});
|
|
218685
218629
|
const functionToolsObject = {};
|
|
@@ -218699,36 +218643,38 @@ var getFullGraphDefinition = (db) => async ({
|
|
|
218699
218643
|
}
|
|
218700
218644
|
}
|
|
218701
218645
|
if (functionIds.size > 0) {
|
|
218702
|
-
const
|
|
218703
|
-
|
|
218704
|
-
|
|
218705
|
-
|
|
218706
|
-
|
|
218707
|
-
|
|
218708
|
-
|
|
218709
|
-
|
|
218710
|
-
|
|
218711
|
-
|
|
218712
|
-
|
|
218713
|
-
|
|
218714
|
-
|
|
218715
|
-
|
|
218716
|
-
|
|
218717
|
-
|
|
218646
|
+
const functions2 = (await Promise.all(
|
|
218647
|
+
Array.from(functionIds).map(async (functionId) => {
|
|
218648
|
+
const func = await getFunction(db)({
|
|
218649
|
+
functionId,
|
|
218650
|
+
scopes: { tenantId, projectId }
|
|
218651
|
+
});
|
|
218652
|
+
return func ? [
|
|
218653
|
+
functionId,
|
|
218654
|
+
{
|
|
218655
|
+
id: func.id,
|
|
218656
|
+
inputSchema: func.inputSchema,
|
|
218657
|
+
executeCode: func.executeCode,
|
|
218658
|
+
dependencies: func.dependencies
|
|
218659
|
+
}
|
|
218660
|
+
] : null;
|
|
218661
|
+
})
|
|
218662
|
+
)).filter((entry) => entry !== null);
|
|
218663
|
+
result.functions = Object.fromEntries(functions2);
|
|
218718
218664
|
}
|
|
218719
218665
|
} catch (error) {
|
|
218720
218666
|
console.warn("Failed to load tools/functions lookups:", error);
|
|
218721
218667
|
}
|
|
218722
218668
|
return result;
|
|
218723
218669
|
};
|
|
218724
|
-
var
|
|
218725
|
-
const
|
|
218726
|
-
const scopes = { tenantId: params.data.tenantId, projectId: params.data.projectId,
|
|
218727
|
-
const existing = await
|
|
218670
|
+
var upsertAgent = (db) => async (params) => {
|
|
218671
|
+
const agentId = params.data.id || nanoid.nanoid();
|
|
218672
|
+
const scopes = { tenantId: params.data.tenantId, projectId: params.data.projectId, agentId };
|
|
218673
|
+
const existing = await getAgentById(db)({
|
|
218728
218674
|
scopes
|
|
218729
218675
|
});
|
|
218730
218676
|
if (existing) {
|
|
218731
|
-
return await
|
|
218677
|
+
return await updateAgent(db)({
|
|
218732
218678
|
scopes,
|
|
218733
218679
|
data: {
|
|
218734
218680
|
name: params.data.name,
|
|
@@ -218739,12 +218685,11 @@ var upsertAgentGraph = (db) => async (params) => {
|
|
|
218739
218685
|
statusUpdates: params.data.statusUpdates
|
|
218740
218686
|
}
|
|
218741
218687
|
});
|
|
218742
|
-
} else {
|
|
218743
|
-
return await createAgentGraph(db)({
|
|
218744
|
-
...params.data,
|
|
218745
|
-
id: graphId
|
|
218746
|
-
});
|
|
218747
218688
|
}
|
|
218689
|
+
return await createAgent(db)({
|
|
218690
|
+
...params.data,
|
|
218691
|
+
id: agentId
|
|
218692
|
+
});
|
|
218748
218693
|
};
|
|
218749
218694
|
var getApiKeyById = (db) => async (params) => {
|
|
218750
218695
|
return await db.query.apiKeys.findFirst({
|
|
@@ -218765,8 +218710,8 @@ var listApiKeys = (db) => async (params) => {
|
|
|
218765
218710
|
drizzleOrm.eq(apiKeys.tenantId, params.scopes.tenantId),
|
|
218766
218711
|
drizzleOrm.eq(apiKeys.projectId, params.scopes.projectId)
|
|
218767
218712
|
];
|
|
218768
|
-
if (params.
|
|
218769
|
-
conditions.push(drizzleOrm.eq(apiKeys.
|
|
218713
|
+
if (params.agentId) {
|
|
218714
|
+
conditions.push(drizzleOrm.eq(apiKeys.agentId, params.agentId));
|
|
218770
218715
|
}
|
|
218771
218716
|
return await db.query.apiKeys.findMany({
|
|
218772
218717
|
where: drizzleOrm.and(...conditions),
|
|
@@ -218781,8 +218726,8 @@ var listApiKeysPaginated = (db) => async (params) => {
|
|
|
218781
218726
|
drizzleOrm.eq(apiKeys.tenantId, params.scopes.tenantId),
|
|
218782
218727
|
drizzleOrm.eq(apiKeys.projectId, params.scopes.projectId)
|
|
218783
218728
|
];
|
|
218784
|
-
if (params.
|
|
218785
|
-
conditions.push(drizzleOrm.eq(apiKeys.
|
|
218729
|
+
if (params.agentId) {
|
|
218730
|
+
conditions.push(drizzleOrm.eq(apiKeys.agentId, params.agentId));
|
|
218786
218731
|
}
|
|
218787
218732
|
const whereClause = drizzleOrm.and(...conditions);
|
|
218788
218733
|
const [data, totalResult] = await Promise.all([
|
|
@@ -218804,7 +218749,7 @@ var createApiKey = (db) => async (params) => {
|
|
|
218804
218749
|
name: params.name,
|
|
218805
218750
|
tenantId: params.tenantId,
|
|
218806
218751
|
projectId: params.projectId,
|
|
218807
|
-
|
|
218752
|
+
agentId: params.agentId,
|
|
218808
218753
|
publicId: params.publicId,
|
|
218809
218754
|
keyHash: params.keyHash,
|
|
218810
218755
|
keyPrefix: params.keyPrefix,
|
|
@@ -218863,20 +218808,20 @@ var countApiKeys = (db) => async (params) => {
|
|
|
218863
218808
|
drizzleOrm.eq(apiKeys.tenantId, params.scopes.tenantId),
|
|
218864
218809
|
drizzleOrm.eq(apiKeys.projectId, params.scopes.projectId)
|
|
218865
218810
|
];
|
|
218866
|
-
if (params.
|
|
218867
|
-
conditions.push(drizzleOrm.eq(apiKeys.
|
|
218811
|
+
if (params.agentId) {
|
|
218812
|
+
conditions.push(drizzleOrm.eq(apiKeys.agentId, params.agentId));
|
|
218868
218813
|
}
|
|
218869
218814
|
const result = await db.select({ count: drizzleOrm.count() }).from(apiKeys).where(drizzleOrm.and(...conditions));
|
|
218870
218815
|
const total = result[0]?.count || 0;
|
|
218871
218816
|
return typeof total === "string" ? Number.parseInt(total, 10) : total;
|
|
218872
218817
|
};
|
|
218873
218818
|
var generateAndCreateApiKey = async (params, db) => {
|
|
218874
|
-
const { tenantId, projectId,
|
|
218819
|
+
const { tenantId, projectId, agentId, expiresAt, name } = params;
|
|
218875
218820
|
const keyData = await generateApiKey();
|
|
218876
218821
|
const apiKey = await createApiKey(db)({
|
|
218877
218822
|
tenantId,
|
|
218878
218823
|
projectId,
|
|
218879
|
-
|
|
218824
|
+
agentId,
|
|
218880
218825
|
name,
|
|
218881
218826
|
expiresAt,
|
|
218882
218827
|
...keyData
|
|
@@ -219120,7 +219065,7 @@ var getArtifactComponentsForAgent = (db) => async (params) => {
|
|
|
219120
219065
|
drizzleOrm.and(
|
|
219121
219066
|
drizzleOrm.eq(artifactComponents.tenantId, params.scopes.tenantId),
|
|
219122
219067
|
drizzleOrm.eq(artifactComponents.projectId, params.scopes.projectId),
|
|
219123
|
-
drizzleOrm.eq(subAgentArtifactComponents.
|
|
219068
|
+
drizzleOrm.eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
|
|
219124
219069
|
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
|
|
219125
219070
|
)
|
|
219126
219071
|
).orderBy(drizzleOrm.desc(artifactComponents.createdAt));
|
|
@@ -219130,7 +219075,7 @@ var associateArtifactComponentWithAgent = (db) => async (params) => {
|
|
|
219130
219075
|
id: nanoid.nanoid(),
|
|
219131
219076
|
tenantId: params.scopes.tenantId,
|
|
219132
219077
|
projectId: params.scopes.projectId,
|
|
219133
|
-
|
|
219078
|
+
agentId: params.scopes.agentId,
|
|
219134
219079
|
subAgentId: params.scopes.subAgentId,
|
|
219135
219080
|
artifactComponentId: params.artifactComponentId,
|
|
219136
219081
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -219143,7 +219088,7 @@ var removeArtifactComponentFromAgent = (db) => async (params) => {
|
|
|
219143
219088
|
drizzleOrm.and(
|
|
219144
219089
|
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
219145
219090
|
drizzleOrm.eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
|
|
219146
|
-
drizzleOrm.eq(subAgentArtifactComponents.
|
|
219091
|
+
drizzleOrm.eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
|
|
219147
219092
|
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId),
|
|
219148
219093
|
drizzleOrm.eq(subAgentArtifactComponents.artifactComponentId, params.artifactComponentId)
|
|
219149
219094
|
)
|
|
@@ -219158,7 +219103,7 @@ var deleteAgentArtifactComponentRelationByAgent = (db) => async (params) => {
|
|
|
219158
219103
|
const result = await db.delete(subAgentArtifactComponents).where(
|
|
219159
219104
|
drizzleOrm.and(
|
|
219160
219105
|
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
219161
|
-
drizzleOrm.eq(subAgentArtifactComponents.
|
|
219106
|
+
drizzleOrm.eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
|
|
219162
219107
|
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
|
|
219163
219108
|
)
|
|
219164
219109
|
);
|
|
@@ -219166,7 +219111,7 @@ var deleteAgentArtifactComponentRelationByAgent = (db) => async (params) => {
|
|
|
219166
219111
|
};
|
|
219167
219112
|
var getAgentsUsingArtifactComponent = (db) => async (params) => {
|
|
219168
219113
|
return await db.select({
|
|
219169
|
-
|
|
219114
|
+
agentId: subAgentArtifactComponents.agentId,
|
|
219170
219115
|
subAgentId: subAgentArtifactComponents.subAgentId,
|
|
219171
219116
|
createdAt: subAgentArtifactComponents.createdAt
|
|
219172
219117
|
}).from(subAgentArtifactComponents).where(
|
|
@@ -219182,14 +219127,14 @@ var isArtifactComponentAssociatedWithAgent = (db) => async (params) => {
|
|
|
219182
219127
|
drizzleOrm.and(
|
|
219183
219128
|
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
219184
219129
|
drizzleOrm.eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
|
|
219185
|
-
drizzleOrm.eq(subAgentArtifactComponents.
|
|
219130
|
+
drizzleOrm.eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
|
|
219186
219131
|
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId),
|
|
219187
219132
|
drizzleOrm.eq(subAgentArtifactComponents.artifactComponentId, params.artifactComponentId)
|
|
219188
219133
|
)
|
|
219189
219134
|
).limit(1);
|
|
219190
219135
|
return result.length > 0;
|
|
219191
219136
|
};
|
|
219192
|
-
var
|
|
219137
|
+
var agentHasArtifactComponents = (db) => async (params) => {
|
|
219193
219138
|
const result = await db.select({ count: drizzleOrm.count() }).from(subAgentArtifactComponents).innerJoin(
|
|
219194
219139
|
subAgents,
|
|
219195
219140
|
drizzleOrm.and(
|
|
@@ -219202,13 +219147,13 @@ var graphHasArtifactComponents = (db) => async (params) => {
|
|
|
219202
219147
|
drizzleOrm.eq(subAgents.id, subAgentRelations.sourceSubAgentId),
|
|
219203
219148
|
drizzleOrm.eq(subAgents.tenantId, subAgentRelations.tenantId),
|
|
219204
219149
|
drizzleOrm.eq(subAgents.projectId, subAgentRelations.projectId),
|
|
219205
|
-
drizzleOrm.eq(subAgents.
|
|
219150
|
+
drizzleOrm.eq(subAgents.agentId, subAgentRelations.agentId)
|
|
219206
219151
|
)
|
|
219207
219152
|
).where(
|
|
219208
219153
|
drizzleOrm.and(
|
|
219209
219154
|
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
219210
219155
|
drizzleOrm.eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
|
|
219211
|
-
drizzleOrm.eq(subAgentRelations.
|
|
219156
|
+
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId)
|
|
219212
219157
|
)
|
|
219213
219158
|
).limit(1);
|
|
219214
219159
|
const total = result[0]?.count || 0;
|
|
@@ -219230,7 +219175,7 @@ var countArtifactComponentsForAgent = (db) => async (params) => {
|
|
|
219230
219175
|
drizzleOrm.and(
|
|
219231
219176
|
drizzleOrm.eq(subAgentArtifactComponents.tenantId, params.scopes.tenantId),
|
|
219232
219177
|
drizzleOrm.eq(subAgentArtifactComponents.projectId, params.scopes.projectId),
|
|
219233
|
-
drizzleOrm.eq(subAgentArtifactComponents.
|
|
219178
|
+
drizzleOrm.eq(subAgentArtifactComponents.agentId, params.scopes.agentId),
|
|
219234
219179
|
drizzleOrm.eq(subAgentArtifactComponents.subAgentId, params.scopes.subAgentId)
|
|
219235
219180
|
)
|
|
219236
219181
|
);
|
|
@@ -219714,7 +219659,7 @@ var getDataComponentsForAgent = (db) => async (params) => {
|
|
|
219714
219659
|
drizzleOrm.and(
|
|
219715
219660
|
drizzleOrm.eq(dataComponents.tenantId, params.scopes.tenantId),
|
|
219716
219661
|
drizzleOrm.eq(dataComponents.projectId, params.scopes.projectId),
|
|
219717
|
-
drizzleOrm.eq(subAgentDataComponents.
|
|
219662
|
+
drizzleOrm.eq(subAgentDataComponents.agentId, params.scopes.agentId),
|
|
219718
219663
|
drizzleOrm.eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId)
|
|
219719
219664
|
)
|
|
219720
219665
|
).orderBy(drizzleOrm.desc(dataComponents.createdAt));
|
|
@@ -219724,7 +219669,7 @@ var associateDataComponentWithAgent = (db) => async (params) => {
|
|
|
219724
219669
|
id: nanoid.nanoid(),
|
|
219725
219670
|
tenantId: params.scopes.tenantId,
|
|
219726
219671
|
projectId: params.scopes.projectId,
|
|
219727
|
-
|
|
219672
|
+
agentId: params.scopes.agentId,
|
|
219728
219673
|
subAgentId: params.scopes.subAgentId,
|
|
219729
219674
|
dataComponentId: params.dataComponentId
|
|
219730
219675
|
}).returning();
|
|
@@ -219735,7 +219680,7 @@ var removeDataComponentFromAgent = (db) => async (params) => {
|
|
|
219735
219680
|
drizzleOrm.and(
|
|
219736
219681
|
drizzleOrm.eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
|
|
219737
219682
|
drizzleOrm.eq(subAgentDataComponents.projectId, params.scopes.projectId),
|
|
219738
|
-
drizzleOrm.eq(subAgentDataComponents.
|
|
219683
|
+
drizzleOrm.eq(subAgentDataComponents.agentId, params.scopes.agentId),
|
|
219739
219684
|
drizzleOrm.eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId),
|
|
219740
219685
|
drizzleOrm.eq(subAgentDataComponents.dataComponentId, params.dataComponentId)
|
|
219741
219686
|
)
|
|
@@ -219746,7 +219691,7 @@ var deleteAgentDataComponentRelationByAgent = (db) => async (params) => {
|
|
|
219746
219691
|
const result = await db.delete(subAgentDataComponents).where(
|
|
219747
219692
|
drizzleOrm.and(
|
|
219748
219693
|
drizzleOrm.eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
|
|
219749
|
-
drizzleOrm.eq(subAgentDataComponents.
|
|
219694
|
+
drizzleOrm.eq(subAgentDataComponents.agentId, params.scopes.agentId),
|
|
219750
219695
|
drizzleOrm.eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId)
|
|
219751
219696
|
)
|
|
219752
219697
|
);
|
|
@@ -219769,7 +219714,7 @@ var isDataComponentAssociatedWithAgent = (db) => async (params) => {
|
|
|
219769
219714
|
drizzleOrm.and(
|
|
219770
219715
|
drizzleOrm.eq(subAgentDataComponents.tenantId, params.scopes.tenantId),
|
|
219771
219716
|
drizzleOrm.eq(subAgentDataComponents.projectId, params.scopes.projectId),
|
|
219772
|
-
drizzleOrm.eq(subAgentDataComponents.
|
|
219717
|
+
drizzleOrm.eq(subAgentDataComponents.agentId, params.scopes.agentId),
|
|
219773
219718
|
drizzleOrm.eq(subAgentDataComponents.subAgentId, params.scopes.subAgentId),
|
|
219774
219719
|
drizzleOrm.eq(subAgentDataComponents.dataComponentId, params.dataComponentId)
|
|
219775
219720
|
)
|
|
@@ -219814,24 +219759,24 @@ var upsertDataComponent = (db) => async (params) => {
|
|
|
219814
219759
|
}
|
|
219815
219760
|
};
|
|
219816
219761
|
|
|
219817
|
-
// src/validation/
|
|
219762
|
+
// src/validation/agentFull.ts
|
|
219818
219763
|
function isInternalAgent(agent) {
|
|
219819
219764
|
return "prompt" in agent;
|
|
219820
219765
|
}
|
|
219821
219766
|
function isExternalAgent(agent) {
|
|
219822
219767
|
return "baseUrl" in agent;
|
|
219823
219768
|
}
|
|
219824
|
-
function
|
|
219825
|
-
return
|
|
219769
|
+
function validateAndTypeAgentData(data) {
|
|
219770
|
+
return AgentWithinContextOfProjectSchema.parse(data);
|
|
219826
219771
|
}
|
|
219827
|
-
function validateToolReferences(
|
|
219772
|
+
function validateToolReferences(agentData, availableToolIds) {
|
|
219828
219773
|
if (!availableToolIds) {
|
|
219829
219774
|
return;
|
|
219830
219775
|
}
|
|
219831
219776
|
const errors = [];
|
|
219832
|
-
for (const [subAgentId,
|
|
219833
|
-
if (isInternalAgent(
|
|
219834
|
-
for (const canUseItem of
|
|
219777
|
+
for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
|
|
219778
|
+
if (isInternalAgent(subAgent) && subAgent.canUse && Array.isArray(subAgent.canUse)) {
|
|
219779
|
+
for (const canUseItem of subAgent.canUse) {
|
|
219835
219780
|
if (!availableToolIds.has(canUseItem.toolId)) {
|
|
219836
219781
|
errors.push(`Agent '${subAgentId}' references non-existent tool '${canUseItem.toolId}'`);
|
|
219837
219782
|
}
|
|
@@ -219843,14 +219788,14 @@ function validateToolReferences(graphData, availableToolIds) {
|
|
|
219843
219788
|
${errors.join("\n")}`);
|
|
219844
219789
|
}
|
|
219845
219790
|
}
|
|
219846
|
-
function validateDataComponentReferences(
|
|
219791
|
+
function validateDataComponentReferences(agentData, availableDataComponentIds) {
|
|
219847
219792
|
if (!availableDataComponentIds) {
|
|
219848
219793
|
return;
|
|
219849
219794
|
}
|
|
219850
219795
|
const errors = [];
|
|
219851
|
-
for (const [subAgentId,
|
|
219852
|
-
if (isInternalAgent(
|
|
219853
|
-
for (const dataComponentId of
|
|
219796
|
+
for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
|
|
219797
|
+
if (isInternalAgent(subAgent) && subAgent.dataComponents) {
|
|
219798
|
+
for (const dataComponentId of subAgent.dataComponents) {
|
|
219854
219799
|
if (!availableDataComponentIds.has(dataComponentId)) {
|
|
219855
219800
|
errors.push(
|
|
219856
219801
|
`Agent '${subAgentId}' references non-existent dataComponent '${dataComponentId}'`
|
|
@@ -219864,14 +219809,14 @@ function validateDataComponentReferences(graphData, availableDataComponentIds) {
|
|
|
219864
219809
|
${errors.join("\n")}`);
|
|
219865
219810
|
}
|
|
219866
219811
|
}
|
|
219867
|
-
function validateArtifactComponentReferences(
|
|
219812
|
+
function validateArtifactComponentReferences(agentData, availableArtifactComponentIds) {
|
|
219868
219813
|
if (!availableArtifactComponentIds) {
|
|
219869
219814
|
return;
|
|
219870
219815
|
}
|
|
219871
219816
|
const errors = [];
|
|
219872
|
-
for (const [subAgentId,
|
|
219873
|
-
if (isInternalAgent(
|
|
219874
|
-
for (const artifactComponentId of
|
|
219817
|
+
for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
|
|
219818
|
+
if (isInternalAgent(subAgent) && subAgent.artifactComponents) {
|
|
219819
|
+
for (const artifactComponentId of subAgent.artifactComponents) {
|
|
219875
219820
|
if (!availableArtifactComponentIds.has(artifactComponentId)) {
|
|
219876
219821
|
errors.push(
|
|
219877
219822
|
`Agent '${subAgentId}' references non-existent artifactComponent '${artifactComponentId}'`
|
|
@@ -219885,25 +219830,25 @@ function validateArtifactComponentReferences(graphData, availableArtifactCompone
|
|
|
219885
219830
|
${errors.join("\n")}`);
|
|
219886
219831
|
}
|
|
219887
219832
|
}
|
|
219888
|
-
function validateAgentRelationships(
|
|
219833
|
+
function validateAgentRelationships(agentData) {
|
|
219889
219834
|
const errors = [];
|
|
219890
|
-
const availableAgentIds = new Set(Object.keys(
|
|
219891
|
-
for (const [subAgentId,
|
|
219892
|
-
if (isInternalAgent(
|
|
219893
|
-
if (
|
|
219894
|
-
for (const targetId of
|
|
219835
|
+
const availableAgentIds = new Set(Object.keys(agentData.subAgents));
|
|
219836
|
+
for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
|
|
219837
|
+
if (isInternalAgent(subAgent)) {
|
|
219838
|
+
if (subAgent.canTransferTo && Array.isArray(subAgent.canTransferTo)) {
|
|
219839
|
+
for (const targetId of subAgent.canTransferTo) {
|
|
219895
219840
|
if (!availableAgentIds.has(targetId)) {
|
|
219896
219841
|
errors.push(
|
|
219897
|
-
`Agent '${subAgentId}' has transfer target '${targetId}' that doesn't exist in
|
|
219842
|
+
`Agent '${subAgentId}' has transfer target '${targetId}' that doesn't exist in agent`
|
|
219898
219843
|
);
|
|
219899
219844
|
}
|
|
219900
219845
|
}
|
|
219901
219846
|
}
|
|
219902
|
-
if (
|
|
219903
|
-
for (const targetId of
|
|
219847
|
+
if (subAgent.canDelegateTo && Array.isArray(subAgent.canDelegateTo)) {
|
|
219848
|
+
for (const targetId of subAgent.canDelegateTo) {
|
|
219904
219849
|
if (!availableAgentIds.has(targetId)) {
|
|
219905
219850
|
errors.push(
|
|
219906
|
-
`Agent '${subAgentId}' has delegation target '${targetId}' that doesn't exist in
|
|
219851
|
+
`Agent '${subAgentId}' has delegation target '${targetId}' that doesn't exist in agent`
|
|
219907
219852
|
);
|
|
219908
219853
|
}
|
|
219909
219854
|
}
|
|
@@ -219915,26 +219860,26 @@ function validateAgentRelationships(graphData) {
|
|
|
219915
219860
|
${errors.join("\n")}`);
|
|
219916
219861
|
}
|
|
219917
219862
|
}
|
|
219918
|
-
function
|
|
219919
|
-
if (
|
|
219920
|
-
throw new Error(`Default agent '${
|
|
219863
|
+
function validateAgentStructure(agentData, projectResources) {
|
|
219864
|
+
if (agentData.defaultSubAgentId && !agentData.subAgents[agentData.defaultSubAgentId]) {
|
|
219865
|
+
throw new Error(`Default agent '${agentData.defaultSubAgentId}' does not exist in agents`);
|
|
219921
219866
|
}
|
|
219922
219867
|
if (projectResources) {
|
|
219923
|
-
validateToolReferences(
|
|
219924
|
-
validateDataComponentReferences(
|
|
219925
|
-
validateArtifactComponentReferences(
|
|
219868
|
+
validateToolReferences(agentData, projectResources.toolIds);
|
|
219869
|
+
validateDataComponentReferences(agentData, projectResources.dataComponentIds);
|
|
219870
|
+
validateArtifactComponentReferences(agentData, projectResources.artifactComponentIds);
|
|
219926
219871
|
}
|
|
219927
|
-
validateAgentRelationships(
|
|
219872
|
+
validateAgentRelationships(agentData);
|
|
219928
219873
|
}
|
|
219929
219874
|
|
|
219930
|
-
// src/data-access/
|
|
219875
|
+
// src/data-access/agentFull.ts
|
|
219931
219876
|
var defaultLogger = {
|
|
219932
219877
|
info: () => {
|
|
219933
219878
|
},
|
|
219934
219879
|
error: () => {
|
|
219935
219880
|
}
|
|
219936
219881
|
};
|
|
219937
|
-
async function applyExecutionLimitsInheritance(db, logger14, scopes,
|
|
219882
|
+
async function applyExecutionLimitsInheritance(db, logger14, scopes, agentData) {
|
|
219938
219883
|
const { tenantId, projectId } = scopes;
|
|
219939
219884
|
try {
|
|
219940
219885
|
const project = await db.query.projects.findFirst({
|
|
@@ -219952,27 +219897,27 @@ async function applyExecutionLimitsInheritance(db, logger14, scopes, graphData)
|
|
|
219952
219897
|
},
|
|
219953
219898
|
"Found project stopWhen configuration"
|
|
219954
219899
|
);
|
|
219955
|
-
if (!
|
|
219956
|
-
|
|
219900
|
+
if (!agentData.stopWhen) {
|
|
219901
|
+
agentData.stopWhen = {};
|
|
219957
219902
|
}
|
|
219958
|
-
if (
|
|
219959
|
-
|
|
219903
|
+
if (agentData.stopWhen.transferCountIs === void 0 && projectStopWhen?.transferCountIs !== void 0) {
|
|
219904
|
+
agentData.stopWhen.transferCountIs = projectStopWhen.transferCountIs;
|
|
219960
219905
|
logger14.info(
|
|
219961
219906
|
{
|
|
219962
|
-
|
|
219907
|
+
agentId: agentData.id,
|
|
219963
219908
|
inheritedValue: projectStopWhen.transferCountIs
|
|
219964
219909
|
},
|
|
219965
|
-
"
|
|
219910
|
+
"Agent inherited transferCountIs from project"
|
|
219966
219911
|
);
|
|
219967
219912
|
}
|
|
219968
|
-
if (
|
|
219969
|
-
|
|
219913
|
+
if (agentData.stopWhen.transferCountIs === void 0) {
|
|
219914
|
+
agentData.stopWhen.transferCountIs = 10;
|
|
219970
219915
|
logger14.info(
|
|
219971
219916
|
{
|
|
219972
|
-
|
|
219917
|
+
agentId: agentData.id,
|
|
219973
219918
|
defaultValue: 10
|
|
219974
219919
|
},
|
|
219975
|
-
"
|
|
219920
|
+
"Agent set to default transferCountIs"
|
|
219976
219921
|
);
|
|
219977
219922
|
}
|
|
219978
219923
|
if (projectStopWhen?.stepCountIs !== void 0) {
|
|
@@ -219983,8 +219928,8 @@ async function applyExecutionLimitsInheritance(db, logger14, scopes, graphData)
|
|
|
219983
219928
|
},
|
|
219984
219929
|
"Propagating stepCountIs to agents"
|
|
219985
219930
|
);
|
|
219986
|
-
for (const [subAgentId,
|
|
219987
|
-
if (isInternalAgent(
|
|
219931
|
+
for (const [subAgentId, subAgentData] of Object.entries(agentData.subAgents)) {
|
|
219932
|
+
if (isInternalAgent(subAgentData)) {
|
|
219988
219933
|
const agent = agentData;
|
|
219989
219934
|
if (!agent.stopWhen) {
|
|
219990
219935
|
agent.stopWhen = {};
|
|
@@ -220012,24 +219957,24 @@ async function applyExecutionLimitsInheritance(db, logger14, scopes, graphData)
|
|
|
220012
219957
|
);
|
|
220013
219958
|
}
|
|
220014
219959
|
}
|
|
220015
|
-
var
|
|
219960
|
+
var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes, agentData) => {
|
|
220016
219961
|
const { tenantId, projectId } = scopes;
|
|
220017
|
-
const typed =
|
|
220018
|
-
|
|
219962
|
+
const typed = validateAndTypeAgentData(agentData);
|
|
219963
|
+
validateAgentStructure(typed);
|
|
220019
219964
|
await applyExecutionLimitsInheritance(db, logger14, { tenantId, projectId }, typed);
|
|
220020
219965
|
try {
|
|
220021
219966
|
logger14.info(
|
|
220022
219967
|
{},
|
|
220023
|
-
"CredentialReferences are project-scoped - skipping credential reference creation in
|
|
219968
|
+
"CredentialReferences are project-scoped - skipping credential reference creation in agent"
|
|
220024
219969
|
);
|
|
220025
|
-
logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in
|
|
220026
|
-
let
|
|
219970
|
+
logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in agent");
|
|
219971
|
+
let finalAgentId;
|
|
220027
219972
|
try {
|
|
220028
|
-
const
|
|
220029
|
-
logger14.info({
|
|
220030
|
-
const
|
|
219973
|
+
const agentId = typed.id || nanoid.nanoid();
|
|
219974
|
+
logger14.info({ agentId }, "Creating agent metadata");
|
|
219975
|
+
const agent = await upsertAgent(db)({
|
|
220031
219976
|
data: {
|
|
220032
|
-
id:
|
|
219977
|
+
id: agentId,
|
|
220033
219978
|
tenantId,
|
|
220034
219979
|
projectId,
|
|
220035
219980
|
name: typed.name,
|
|
@@ -220039,14 +219984,17 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220039
219984
|
// Will be updated later if context config exists
|
|
220040
219985
|
models: typed.models,
|
|
220041
219986
|
statusUpdates: typed.statusUpdates,
|
|
220042
|
-
|
|
219987
|
+
prompt: typed.prompt,
|
|
220043
219988
|
stopWhen: typed.stopWhen
|
|
220044
219989
|
}
|
|
220045
219990
|
});
|
|
220046
|
-
|
|
220047
|
-
|
|
219991
|
+
if (!agent?.id) {
|
|
219992
|
+
throw new Error("Failed to create agent: no ID returned");
|
|
219993
|
+
}
|
|
219994
|
+
finalAgentId = agent.id;
|
|
219995
|
+
logger14.info({ agentId: finalAgentId }, "Agent metadata created successfully");
|
|
220048
219996
|
} catch (error) {
|
|
220049
|
-
logger14.error({
|
|
219997
|
+
logger14.error({ agentId: typed.id, error }, "Failed to create/update agent metadata");
|
|
220050
219998
|
throw error;
|
|
220051
219999
|
}
|
|
220052
220000
|
let contextConfigId;
|
|
@@ -220056,7 +220004,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220056
220004
|
const contextConfig2 = await upsertContextConfig(db)({
|
|
220057
220005
|
data: {
|
|
220058
220006
|
...typed.contextConfig,
|
|
220059
|
-
|
|
220007
|
+
agentId: finalAgentId,
|
|
220060
220008
|
tenantId,
|
|
220061
220009
|
projectId
|
|
220062
220010
|
}
|
|
@@ -220074,12 +220022,12 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220074
220022
|
if (contextConfigId) {
|
|
220075
220023
|
try {
|
|
220076
220024
|
logger14.info(
|
|
220077
|
-
{
|
|
220078
|
-
"Updating
|
|
220025
|
+
{ agentId: finalAgentId, contextConfigId },
|
|
220026
|
+
"Updating agent with contextConfigId"
|
|
220079
220027
|
);
|
|
220080
|
-
await
|
|
220028
|
+
await upsertAgent(db)({
|
|
220081
220029
|
data: {
|
|
220082
|
-
id:
|
|
220030
|
+
id: finalAgentId,
|
|
220083
220031
|
tenantId,
|
|
220084
220032
|
projectId,
|
|
220085
220033
|
name: typed.name,
|
|
@@ -220088,42 +220036,42 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220088
220036
|
contextConfigId,
|
|
220089
220037
|
models: typed.models,
|
|
220090
220038
|
statusUpdates: typed.statusUpdates,
|
|
220091
|
-
|
|
220039
|
+
prompt: typed.prompt,
|
|
220092
220040
|
stopWhen: typed.stopWhen
|
|
220093
220041
|
}
|
|
220094
220042
|
});
|
|
220095
220043
|
logger14.info(
|
|
220096
|
-
{
|
|
220097
|
-
"
|
|
220044
|
+
{ agentId: finalAgentId, contextConfigId },
|
|
220045
|
+
"Agent updated with contextConfigId successfully"
|
|
220098
220046
|
);
|
|
220099
220047
|
} catch (error) {
|
|
220100
220048
|
logger14.error(
|
|
220101
|
-
{
|
|
220102
|
-
"Failed to update
|
|
220049
|
+
{ agentId: finalAgentId, contextConfigId, error },
|
|
220050
|
+
"Failed to update agent with contextConfigId"
|
|
220103
220051
|
);
|
|
220104
220052
|
throw error;
|
|
220105
220053
|
}
|
|
220106
220054
|
}
|
|
220107
220055
|
logger14.info(
|
|
220108
220056
|
{},
|
|
220109
|
-
"DataComponents are project-scoped - skipping dataComponent creation in
|
|
220057
|
+
"DataComponents are project-scoped - skipping dataComponent creation in agent"
|
|
220110
220058
|
);
|
|
220111
220059
|
logger14.info(
|
|
220112
220060
|
{},
|
|
220113
|
-
"ArtifactComponents are project-scoped - skipping artifactComponent creation in
|
|
220061
|
+
"ArtifactComponents are project-scoped - skipping artifactComponent creation in agent"
|
|
220114
220062
|
);
|
|
220115
220063
|
if (typed.functions && Object.keys(typed.functions).length > 0) {
|
|
220116
220064
|
logger14.info(
|
|
220117
220065
|
{
|
|
220118
|
-
|
|
220066
|
+
agentId: finalAgentId,
|
|
220119
220067
|
functionCount: Object.keys(typed.functions).length
|
|
220120
220068
|
},
|
|
220121
|
-
"Creating functions for
|
|
220069
|
+
"Creating functions for agent"
|
|
220122
220070
|
);
|
|
220123
220071
|
const functionPromises = Object.entries(typed.functions).map(
|
|
220124
220072
|
async ([functionId, functionData]) => {
|
|
220125
220073
|
try {
|
|
220126
|
-
logger14.info({
|
|
220074
|
+
logger14.info({ agentId: finalAgentId, functionId }, "Creating function for agent");
|
|
220127
220075
|
await upsertFunction(db)({
|
|
220128
220076
|
data: {
|
|
220129
220077
|
...functionData,
|
|
@@ -220131,11 +220079,11 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220131
220079
|
},
|
|
220132
220080
|
scopes: { tenantId, projectId }
|
|
220133
220081
|
});
|
|
220134
|
-
logger14.info({
|
|
220082
|
+
logger14.info({ agentId: finalAgentId, functionId }, "Function created successfully");
|
|
220135
220083
|
} catch (error) {
|
|
220136
220084
|
logger14.error(
|
|
220137
|
-
{
|
|
220138
|
-
"Failed to create function for
|
|
220085
|
+
{ agentId: finalAgentId, functionId, error },
|
|
220086
|
+
"Failed to create function for agent"
|
|
220139
220087
|
);
|
|
220140
220088
|
throw error;
|
|
220141
220089
|
}
|
|
@@ -220144,7 +220092,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220144
220092
|
await Promise.all(functionPromises);
|
|
220145
220093
|
logger14.info(
|
|
220146
220094
|
{
|
|
220147
|
-
|
|
220095
|
+
agentId: finalAgentId,
|
|
220148
220096
|
functionCount: Object.keys(typed.functions).length
|
|
220149
220097
|
},
|
|
220150
220098
|
"All functions created successfully"
|
|
@@ -220153,33 +220101,33 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220153
220101
|
if (typed.functionTools && Object.keys(typed.functionTools).length > 0) {
|
|
220154
220102
|
logger14.info(
|
|
220155
220103
|
{
|
|
220156
|
-
|
|
220104
|
+
agentId: finalAgentId,
|
|
220157
220105
|
functionToolCount: Object.keys(typed.functionTools).length
|
|
220158
220106
|
},
|
|
220159
|
-
"Creating function tools for
|
|
220107
|
+
"Creating function tools for agent"
|
|
220160
220108
|
);
|
|
220161
220109
|
const functionToolPromises = Object.entries(typed.functionTools).map(
|
|
220162
220110
|
async ([functionToolId, functionToolData]) => {
|
|
220163
220111
|
try {
|
|
220164
220112
|
logger14.info(
|
|
220165
|
-
{
|
|
220166
|
-
"Creating function tool in
|
|
220113
|
+
{ agentId: finalAgentId, functionToolId },
|
|
220114
|
+
"Creating function tool in agent"
|
|
220167
220115
|
);
|
|
220168
220116
|
await upsertFunctionTool(db)({
|
|
220169
220117
|
data: {
|
|
220170
220118
|
...functionToolData,
|
|
220171
220119
|
id: functionToolId
|
|
220172
220120
|
},
|
|
220173
|
-
scopes: { tenantId, projectId,
|
|
220121
|
+
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
220174
220122
|
});
|
|
220175
220123
|
logger14.info(
|
|
220176
|
-
{
|
|
220124
|
+
{ agentId: finalAgentId, functionToolId },
|
|
220177
220125
|
"Function tool created successfully"
|
|
220178
220126
|
);
|
|
220179
220127
|
} catch (error) {
|
|
220180
220128
|
logger14.error(
|
|
220181
|
-
{
|
|
220182
|
-
"Failed to create function tool in
|
|
220129
|
+
{ agentId: finalAgentId, functionToolId, error },
|
|
220130
|
+
"Failed to create function tool in agent"
|
|
220183
220131
|
);
|
|
220184
220132
|
throw error;
|
|
220185
220133
|
}
|
|
@@ -220188,14 +220136,14 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220188
220136
|
await Promise.all(functionToolPromises);
|
|
220189
220137
|
logger14.info(
|
|
220190
220138
|
{
|
|
220191
|
-
|
|
220139
|
+
agentId: finalAgentId,
|
|
220192
220140
|
functionToolCount: Object.keys(typed.functionTools).length
|
|
220193
220141
|
},
|
|
220194
220142
|
"All function tools created successfully"
|
|
220195
220143
|
);
|
|
220196
220144
|
}
|
|
220197
|
-
const internalAgentPromises = Object.entries(typed.subAgents).filter(([_,
|
|
220198
|
-
const internalAgent =
|
|
220145
|
+
const internalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData2]) => isInternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
|
|
220146
|
+
const internalAgent = agentData2;
|
|
220199
220147
|
try {
|
|
220200
220148
|
logger14.info({ subAgentId }, "Processing internal agent");
|
|
220201
220149
|
await upsertSubAgent(db)({
|
|
@@ -220203,7 +220151,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220203
220151
|
id: subAgentId,
|
|
220204
220152
|
tenantId,
|
|
220205
220153
|
projectId,
|
|
220206
|
-
|
|
220154
|
+
agentId: finalAgentId,
|
|
220207
220155
|
name: internalAgent.name || "",
|
|
220208
220156
|
description: internalAgent.description || "",
|
|
220209
220157
|
prompt: internalAgent.prompt || "",
|
|
@@ -220220,11 +220168,11 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220220
220168
|
});
|
|
220221
220169
|
await Promise.all(internalAgentPromises);
|
|
220222
220170
|
const internalAgentCount = Object.entries(typed.subAgents).filter(
|
|
220223
|
-
([_,
|
|
220171
|
+
([_, agentData2]) => isInternalAgent(agentData2)
|
|
220224
220172
|
).length;
|
|
220225
220173
|
logger14.info({ internalAgentCount }, "All internal agents created/updated successfully");
|
|
220226
|
-
const externalAgentPromises = Object.entries(typed.subAgents).filter(([_,
|
|
220227
|
-
const externalAgent =
|
|
220174
|
+
const externalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData2]) => isExternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
|
|
220175
|
+
const externalAgent = agentData2;
|
|
220228
220176
|
try {
|
|
220229
220177
|
logger14.info({ subAgentId }, "Processing external agent");
|
|
220230
220178
|
await upsertExternalAgent(db)({
|
|
@@ -220232,7 +220180,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220232
220180
|
id: subAgentId,
|
|
220233
220181
|
tenantId,
|
|
220234
220182
|
projectId,
|
|
220235
|
-
|
|
220183
|
+
agentId: finalAgentId,
|
|
220236
220184
|
name: externalAgent.name,
|
|
220237
220185
|
description: externalAgent.description || "",
|
|
220238
220186
|
baseUrl: externalAgent.baseUrl,
|
|
@@ -220248,32 +220196,32 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220248
220196
|
});
|
|
220249
220197
|
await Promise.all(externalAgentPromises);
|
|
220250
220198
|
const externalAgentCount = Object.entries(typed.subAgents).filter(
|
|
220251
|
-
([_,
|
|
220199
|
+
([_, agentData2]) => isExternalAgent(agentData2)
|
|
220252
220200
|
).length;
|
|
220253
220201
|
logger14.info({ externalAgentCount }, "All external agents created/updated successfully");
|
|
220254
220202
|
if (contextConfigId) {
|
|
220255
220203
|
try {
|
|
220256
220204
|
logger14.info(
|
|
220257
|
-
{
|
|
220258
|
-
"Updating
|
|
220205
|
+
{ agentId: finalAgentId, contextConfigId },
|
|
220206
|
+
"Updating agent with context config"
|
|
220259
220207
|
);
|
|
220260
|
-
await
|
|
220261
|
-
scopes: { tenantId, projectId,
|
|
220208
|
+
await updateAgent(db)({
|
|
220209
|
+
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
220262
220210
|
data: { contextConfigId }
|
|
220263
220211
|
});
|
|
220264
|
-
logger14.info({
|
|
220212
|
+
logger14.info({ agentId: finalAgentId }, "Agent updated with context config");
|
|
220265
220213
|
} catch (error) {
|
|
220266
220214
|
logger14.error(
|
|
220267
|
-
{
|
|
220268
|
-
"Failed to update
|
|
220215
|
+
{ agentId: finalAgentId, error },
|
|
220216
|
+
"Failed to update agent with context config"
|
|
220269
220217
|
);
|
|
220270
220218
|
throw error;
|
|
220271
220219
|
}
|
|
220272
220220
|
}
|
|
220273
220221
|
const agentToolPromises = [];
|
|
220274
|
-
for (const [subAgentId,
|
|
220275
|
-
if (isInternalAgent(
|
|
220276
|
-
for (const canUseItem of
|
|
220222
|
+
for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
|
|
220223
|
+
if (isInternalAgent(agentData2) && agentData2.canUse && Array.isArray(agentData2.canUse)) {
|
|
220224
|
+
for (const canUseItem of agentData2.canUse) {
|
|
220277
220225
|
agentToolPromises.push(
|
|
220278
220226
|
(async () => {
|
|
220279
220227
|
try {
|
|
@@ -220292,7 +220240,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220292
220240
|
if (isFunctionTool) {
|
|
220293
220241
|
logger14.info({ subAgentId, toolId }, "Processing agent-function tool relation");
|
|
220294
220242
|
await upsertSubAgentFunctionToolRelation(db)({
|
|
220295
|
-
scopes: { tenantId, projectId,
|
|
220243
|
+
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
220296
220244
|
subAgentId,
|
|
220297
220245
|
functionToolId: toolId,
|
|
220298
220246
|
relationId: agentToolRelationId
|
|
@@ -220304,7 +220252,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220304
220252
|
} else {
|
|
220305
220253
|
logger14.info({ subAgentId, toolId }, "Processing agent-MCP tool relation");
|
|
220306
220254
|
await upsertSubAgentToolRelation(db)({
|
|
220307
|
-
scopes: { tenantId, projectId,
|
|
220255
|
+
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
220308
220256
|
subAgentId,
|
|
220309
220257
|
toolId,
|
|
220310
220258
|
selectedTools: toolSelection || void 0,
|
|
@@ -220333,9 +220281,9 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220333
220281
|
"All agent-tool relations created"
|
|
220334
220282
|
);
|
|
220335
220283
|
const agentDataComponentPromises = [];
|
|
220336
|
-
for (const [subAgentId,
|
|
220337
|
-
if (isInternalAgent(
|
|
220338
|
-
for (const dataComponentId of
|
|
220284
|
+
for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
|
|
220285
|
+
if (isInternalAgent(agentData2) && agentData2.dataComponents) {
|
|
220286
|
+
for (const dataComponentId of agentData2.dataComponents) {
|
|
220339
220287
|
agentDataComponentPromises.push(
|
|
220340
220288
|
(async () => {
|
|
220341
220289
|
try {
|
|
@@ -220344,7 +220292,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220344
220292
|
"Processing agent-data component relation"
|
|
220345
220293
|
);
|
|
220346
220294
|
await upsertAgentDataComponentRelation(db)({
|
|
220347
|
-
scopes: { tenantId, projectId,
|
|
220295
|
+
scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId },
|
|
220348
220296
|
dataComponentId
|
|
220349
220297
|
});
|
|
220350
220298
|
logger14.info(
|
|
@@ -220365,9 +220313,9 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220365
220313
|
await Promise.all(agentDataComponentPromises);
|
|
220366
220314
|
logger14.info({}, "All agent-data component relations created");
|
|
220367
220315
|
const agentArtifactComponentPromises = [];
|
|
220368
|
-
for (const [subAgentId,
|
|
220369
|
-
if (isInternalAgent(
|
|
220370
|
-
for (const artifactComponentId of
|
|
220316
|
+
for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
|
|
220317
|
+
if (isInternalAgent(agentData2) && agentData2.artifactComponents) {
|
|
220318
|
+
for (const artifactComponentId of agentData2.artifactComponents) {
|
|
220371
220319
|
agentArtifactComponentPromises.push(
|
|
220372
220320
|
(async () => {
|
|
220373
220321
|
try {
|
|
@@ -220376,7 +220324,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220376
220324
|
"Processing agent-artifact component relation"
|
|
220377
220325
|
);
|
|
220378
220326
|
await upsertAgentArtifactComponentRelation(db)({
|
|
220379
|
-
scopes: { tenantId, projectId,
|
|
220327
|
+
scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId },
|
|
220380
220328
|
artifactComponentId
|
|
220381
220329
|
});
|
|
220382
220330
|
logger14.info(
|
|
@@ -220397,9 +220345,9 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220397
220345
|
await Promise.all(agentArtifactComponentPromises);
|
|
220398
220346
|
logger14.info({}, "All agent-artifact component relations created");
|
|
220399
220347
|
const agentRelationPromises = [];
|
|
220400
|
-
for (const [subAgentId,
|
|
220401
|
-
if (isInternalAgent(
|
|
220402
|
-
for (const targetSubAgentId of
|
|
220348
|
+
for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
|
|
220349
|
+
if (isInternalAgent(agentData2) && agentData2.canTransferTo) {
|
|
220350
|
+
for (const targetSubAgentId of agentData2.canTransferTo) {
|
|
220403
220351
|
agentRelationPromises.push(
|
|
220404
220352
|
(async () => {
|
|
220405
220353
|
try {
|
|
@@ -220411,7 +220359,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220411
220359
|
id: nanoid.nanoid(),
|
|
220412
220360
|
tenantId,
|
|
220413
220361
|
projectId,
|
|
220414
|
-
|
|
220362
|
+
agentId: finalAgentId,
|
|
220415
220363
|
sourceSubAgentId: subAgentId,
|
|
220416
220364
|
targetSubAgentId,
|
|
220417
220365
|
relationType: "transfer"
|
|
@@ -220430,8 +220378,8 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220430
220378
|
);
|
|
220431
220379
|
}
|
|
220432
220380
|
}
|
|
220433
|
-
if (isInternalAgent(
|
|
220434
|
-
for (const targetSubAgentId of
|
|
220381
|
+
if (isInternalAgent(agentData2) && agentData2.canDelegateTo) {
|
|
220382
|
+
for (const targetSubAgentId of agentData2.canDelegateTo) {
|
|
220435
220383
|
const targetAgentData = typed.subAgents[targetSubAgentId];
|
|
220436
220384
|
const isTargetExternal = isExternalAgent(targetAgentData);
|
|
220437
220385
|
agentRelationPromises.push(
|
|
@@ -220445,7 +220393,7 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220445
220393
|
id: nanoid.nanoid(),
|
|
220446
220394
|
tenantId,
|
|
220447
220395
|
projectId,
|
|
220448
|
-
|
|
220396
|
+
agentId: finalAgentId,
|
|
220449
220397
|
sourceSubAgentId: subAgentId,
|
|
220450
220398
|
targetSubAgentId: isTargetExternal ? void 0 : targetSubAgentId,
|
|
220451
220399
|
externalSubAgentId: isTargetExternal ? targetSubAgentId : void 0,
|
|
@@ -220471,100 +220419,103 @@ var createFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220471
220419
|
{ agentRelationCount: agentRelationPromises.length },
|
|
220472
220420
|
"All agent relations created"
|
|
220473
220421
|
);
|
|
220474
|
-
const
|
|
220475
|
-
scopes: { tenantId, projectId,
|
|
220422
|
+
const createdAgent = await getFullAgentDefinition(db)({
|
|
220423
|
+
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
220476
220424
|
});
|
|
220477
|
-
if (!
|
|
220478
|
-
throw new Error("Failed to retrieve created
|
|
220425
|
+
if (!createdAgent) {
|
|
220426
|
+
throw new Error("Failed to retrieve created agent");
|
|
220479
220427
|
}
|
|
220480
|
-
logger14.info({ tenantId,
|
|
220481
|
-
return
|
|
220428
|
+
logger14.info({ tenantId, agentId: finalAgentId }, "Full agent created successfully");
|
|
220429
|
+
return createdAgent;
|
|
220482
220430
|
} catch (error) {
|
|
220483
|
-
const
|
|
220484
|
-
logger14.error({ tenantId,
|
|
220431
|
+
const errorAgentId = typed.id || "unknown";
|
|
220432
|
+
logger14.error({ tenantId, agentId: errorAgentId, error }, "Failed to create full agent");
|
|
220485
220433
|
throw error;
|
|
220486
220434
|
}
|
|
220487
220435
|
};
|
|
220488
|
-
var
|
|
220436
|
+
var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes, agentData) => {
|
|
220489
220437
|
const { tenantId, projectId } = scopes;
|
|
220490
|
-
const
|
|
220491
|
-
if (!
|
|
220492
|
-
throw new Error("
|
|
220438
|
+
const typedAgentDefinition = validateAndTypeAgentData(agentData);
|
|
220439
|
+
if (!typedAgentDefinition.id) {
|
|
220440
|
+
throw new Error("Agent ID is required");
|
|
220493
220441
|
}
|
|
220494
220442
|
logger14.info(
|
|
220495
220443
|
{
|
|
220496
220444
|
tenantId,
|
|
220497
|
-
|
|
220498
|
-
agentCount: Object.keys(
|
|
220445
|
+
agentId: typedAgentDefinition.id,
|
|
220446
|
+
agentCount: Object.keys(typedAgentDefinition.subAgents).length
|
|
220499
220447
|
},
|
|
220500
|
-
"Updating full
|
|
220448
|
+
"Updating full agent in database"
|
|
220501
220449
|
);
|
|
220502
|
-
|
|
220450
|
+
validateAgentStructure(typedAgentDefinition);
|
|
220503
220451
|
await applyExecutionLimitsInheritance(
|
|
220504
220452
|
db,
|
|
220505
220453
|
logger14,
|
|
220506
220454
|
{ tenantId, projectId },
|
|
220507
|
-
|
|
220455
|
+
typedAgentDefinition
|
|
220508
220456
|
);
|
|
220509
220457
|
try {
|
|
220510
|
-
const
|
|
220511
|
-
scopes: { tenantId, projectId,
|
|
220458
|
+
const existingAgent = await getAgentById(db)({
|
|
220459
|
+
scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
|
|
220512
220460
|
});
|
|
220513
|
-
if (!
|
|
220461
|
+
if (!existingAgent) {
|
|
220514
220462
|
logger14.info(
|
|
220515
|
-
{
|
|
220516
|
-
"
|
|
220463
|
+
{ agentId: typedAgentDefinition.id },
|
|
220464
|
+
"Agent does not exist, creating new agent"
|
|
220517
220465
|
);
|
|
220518
|
-
return
|
|
220466
|
+
return createFullAgentServerSide(db, logger14)(scopes, agentData);
|
|
220519
220467
|
}
|
|
220520
|
-
const
|
|
220468
|
+
const existingAgentModels = existingAgent.models;
|
|
220521
220469
|
logger14.info(
|
|
220522
220470
|
{},
|
|
220523
|
-
"CredentialReferences are project-scoped - skipping credential reference update in
|
|
220471
|
+
"CredentialReferences are project-scoped - skipping credential reference update in agent"
|
|
220524
220472
|
);
|
|
220525
|
-
logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in
|
|
220526
|
-
let
|
|
220473
|
+
logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in agent update");
|
|
220474
|
+
let finalAgentId;
|
|
220527
220475
|
try {
|
|
220528
|
-
const
|
|
220529
|
-
logger14.info({
|
|
220530
|
-
const
|
|
220476
|
+
const agentId = typedAgentDefinition.id || nanoid.nanoid();
|
|
220477
|
+
logger14.info({ agentId }, "Getting/creating agent metadata");
|
|
220478
|
+
const agent = await upsertAgent(db)({
|
|
220531
220479
|
data: {
|
|
220532
|
-
id:
|
|
220480
|
+
id: agentId,
|
|
220533
220481
|
tenantId,
|
|
220534
220482
|
projectId,
|
|
220535
|
-
name:
|
|
220536
|
-
defaultSubAgentId:
|
|
220537
|
-
description:
|
|
220483
|
+
name: typedAgentDefinition.name,
|
|
220484
|
+
defaultSubAgentId: typedAgentDefinition.defaultSubAgentId,
|
|
220485
|
+
description: typedAgentDefinition.description,
|
|
220538
220486
|
contextConfigId: void 0,
|
|
220539
220487
|
// Will be updated later if context config exists
|
|
220540
|
-
models:
|
|
220541
|
-
statusUpdates:
|
|
220542
|
-
|
|
220543
|
-
stopWhen:
|
|
220488
|
+
models: typedAgentDefinition.models,
|
|
220489
|
+
statusUpdates: typedAgentDefinition.statusUpdates,
|
|
220490
|
+
prompt: typedAgentDefinition.prompt,
|
|
220491
|
+
stopWhen: typedAgentDefinition.stopWhen
|
|
220544
220492
|
}
|
|
220545
220493
|
});
|
|
220546
|
-
|
|
220547
|
-
|
|
220494
|
+
if (!agent?.id) {
|
|
220495
|
+
throw new Error("Failed to upsert agent: no ID returned");
|
|
220496
|
+
}
|
|
220497
|
+
finalAgentId = agent.id;
|
|
220498
|
+
logger14.info({ agentId: finalAgentId }, "Agent metadata ready");
|
|
220548
220499
|
} catch (error) {
|
|
220549
220500
|
logger14.error(
|
|
220550
|
-
{
|
|
220551
|
-
"Failed to get/update
|
|
220501
|
+
{ agentId: typedAgentDefinition.id, error },
|
|
220502
|
+
"Failed to get/update agent metadata"
|
|
220552
220503
|
);
|
|
220553
220504
|
throw error;
|
|
220554
220505
|
}
|
|
220555
220506
|
let contextConfigId;
|
|
220556
|
-
if (
|
|
220507
|
+
if (typedAgentDefinition.contextConfig) {
|
|
220557
220508
|
logger14.info(
|
|
220558
|
-
{ contextConfigId:
|
|
220509
|
+
{ contextConfigId: typedAgentDefinition.contextConfig?.id },
|
|
220559
220510
|
" context config exists"
|
|
220560
220511
|
);
|
|
220561
220512
|
}
|
|
220562
|
-
if (
|
|
220513
|
+
if (typedAgentDefinition.contextConfig) {
|
|
220563
220514
|
try {
|
|
220564
220515
|
const contextConfig2 = await upsertContextConfig(db)({
|
|
220565
220516
|
data: {
|
|
220566
|
-
...
|
|
220567
|
-
|
|
220517
|
+
...typedAgentDefinition.contextConfig,
|
|
220518
|
+
agentId: finalAgentId,
|
|
220568
220519
|
tenantId,
|
|
220569
220520
|
projectId
|
|
220570
220521
|
}
|
|
@@ -220573,7 +220524,7 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220573
220524
|
logger14.info({ contextConfigId }, "Context config processed successfully");
|
|
220574
220525
|
} catch (error) {
|
|
220575
220526
|
logger14.error(
|
|
220576
|
-
{ contextConfigId:
|
|
220527
|
+
{ contextConfigId: typedAgentDefinition.contextConfig.id, error },
|
|
220577
220528
|
"Failed to create/update context config"
|
|
220578
220529
|
);
|
|
220579
220530
|
throw error;
|
|
@@ -220582,53 +220533,53 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220582
220533
|
if (contextConfigId) {
|
|
220583
220534
|
try {
|
|
220584
220535
|
logger14.info(
|
|
220585
|
-
{
|
|
220586
|
-
"Updating
|
|
220536
|
+
{ agentId: finalAgentId, contextConfigId },
|
|
220537
|
+
"Updating agent with contextConfigId"
|
|
220587
220538
|
);
|
|
220588
|
-
await
|
|
220539
|
+
await upsertAgent(db)({
|
|
220589
220540
|
data: {
|
|
220590
|
-
id:
|
|
220541
|
+
id: finalAgentId,
|
|
220591
220542
|
tenantId,
|
|
220592
220543
|
projectId,
|
|
220593
|
-
name:
|
|
220594
|
-
defaultSubAgentId:
|
|
220595
|
-
description:
|
|
220544
|
+
name: typedAgentDefinition.name,
|
|
220545
|
+
defaultSubAgentId: typedAgentDefinition.defaultSubAgentId,
|
|
220546
|
+
description: typedAgentDefinition.description,
|
|
220596
220547
|
contextConfigId,
|
|
220597
|
-
models:
|
|
220598
|
-
statusUpdates:
|
|
220599
|
-
|
|
220600
|
-
stopWhen:
|
|
220548
|
+
models: typedAgentDefinition.models,
|
|
220549
|
+
statusUpdates: typedAgentDefinition.statusUpdates,
|
|
220550
|
+
prompt: typedAgentDefinition.prompt,
|
|
220551
|
+
stopWhen: typedAgentDefinition.stopWhen
|
|
220601
220552
|
}
|
|
220602
220553
|
});
|
|
220603
220554
|
logger14.info(
|
|
220604
|
-
{
|
|
220605
|
-
"
|
|
220555
|
+
{ agentId: finalAgentId, contextConfigId },
|
|
220556
|
+
"Agent updated with contextConfigId successfully"
|
|
220606
220557
|
);
|
|
220607
220558
|
} catch (error) {
|
|
220608
220559
|
logger14.error(
|
|
220609
|
-
{
|
|
220610
|
-
"Failed to update
|
|
220560
|
+
{ agentId: finalAgentId, contextConfigId, error },
|
|
220561
|
+
"Failed to update agent with contextConfigId"
|
|
220611
220562
|
);
|
|
220612
220563
|
throw error;
|
|
220613
220564
|
}
|
|
220614
220565
|
}
|
|
220615
|
-
logger14.info({}, "DataComponents are project-scoped - skipping dataComponent update in
|
|
220566
|
+
logger14.info({}, "DataComponents are project-scoped - skipping dataComponent update in agent");
|
|
220616
220567
|
logger14.info(
|
|
220617
220568
|
{},
|
|
220618
|
-
"ArtifactComponents are project-scoped - skipping artifactComponent update in
|
|
220569
|
+
"ArtifactComponents are project-scoped - skipping artifactComponent update in agent"
|
|
220619
220570
|
);
|
|
220620
|
-
if (
|
|
220571
|
+
if (typedAgentDefinition.functions && Object.keys(typedAgentDefinition.functions).length > 0) {
|
|
220621
220572
|
logger14.info(
|
|
220622
220573
|
{
|
|
220623
|
-
|
|
220624
|
-
functionCount: Object.keys(
|
|
220574
|
+
agentId: finalAgentId,
|
|
220575
|
+
functionCount: Object.keys(typedAgentDefinition.functions).length
|
|
220625
220576
|
},
|
|
220626
|
-
"Updating functions for
|
|
220577
|
+
"Updating functions for agent"
|
|
220627
220578
|
);
|
|
220628
|
-
const functionPromises = Object.entries(
|
|
220579
|
+
const functionPromises = Object.entries(typedAgentDefinition.functions).map(
|
|
220629
220580
|
async ([functionId, functionData]) => {
|
|
220630
220581
|
try {
|
|
220631
|
-
logger14.info({
|
|
220582
|
+
logger14.info({ agentId: finalAgentId, functionId }, "Updating function for agent");
|
|
220632
220583
|
await upsertFunction(db)({
|
|
220633
220584
|
data: {
|
|
220634
220585
|
...functionData,
|
|
@@ -220636,11 +220587,11 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220636
220587
|
},
|
|
220637
220588
|
scopes: { tenantId, projectId }
|
|
220638
220589
|
});
|
|
220639
|
-
logger14.info({
|
|
220590
|
+
logger14.info({ agentId: finalAgentId, functionId }, "Function updated successfully");
|
|
220640
220591
|
} catch (error) {
|
|
220641
220592
|
logger14.error(
|
|
220642
|
-
{
|
|
220643
|
-
"Failed to update function for
|
|
220593
|
+
{ agentId: finalAgentId, functionId, error },
|
|
220594
|
+
"Failed to update function for agent"
|
|
220644
220595
|
);
|
|
220645
220596
|
throw error;
|
|
220646
220597
|
}
|
|
@@ -220649,42 +220600,42 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220649
220600
|
await Promise.all(functionPromises);
|
|
220650
220601
|
logger14.info(
|
|
220651
220602
|
{
|
|
220652
|
-
|
|
220653
|
-
functionCount: Object.keys(
|
|
220603
|
+
agentId: finalAgentId,
|
|
220604
|
+
functionCount: Object.keys(typedAgentDefinition.functions).length
|
|
220654
220605
|
},
|
|
220655
220606
|
"All functions updated successfully"
|
|
220656
220607
|
);
|
|
220657
220608
|
}
|
|
220658
|
-
if (
|
|
220609
|
+
if (typedAgentDefinition.functionTools && Object.keys(typedAgentDefinition.functionTools).length > 0) {
|
|
220659
220610
|
logger14.info(
|
|
220660
220611
|
{
|
|
220661
|
-
|
|
220662
|
-
functionToolCount: Object.keys(
|
|
220612
|
+
agentId: finalAgentId,
|
|
220613
|
+
functionToolCount: Object.keys(typedAgentDefinition.functionTools).length
|
|
220663
220614
|
},
|
|
220664
|
-
"Updating function tools for
|
|
220615
|
+
"Updating function tools for agent"
|
|
220665
220616
|
);
|
|
220666
|
-
const functionToolPromises = Object.entries(
|
|
220617
|
+
const functionToolPromises = Object.entries(typedAgentDefinition.functionTools).map(
|
|
220667
220618
|
async ([functionToolId, functionToolData]) => {
|
|
220668
220619
|
try {
|
|
220669
220620
|
logger14.info(
|
|
220670
|
-
{
|
|
220671
|
-
"Updating function tool in
|
|
220621
|
+
{ agentId: finalAgentId, functionToolId },
|
|
220622
|
+
"Updating function tool in agent"
|
|
220672
220623
|
);
|
|
220673
220624
|
await upsertFunctionTool(db)({
|
|
220674
220625
|
data: {
|
|
220675
220626
|
...functionToolData,
|
|
220676
220627
|
id: functionToolId
|
|
220677
220628
|
},
|
|
220678
|
-
scopes: { tenantId, projectId,
|
|
220629
|
+
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
220679
220630
|
});
|
|
220680
220631
|
logger14.info(
|
|
220681
|
-
{
|
|
220632
|
+
{ agentId: finalAgentId, functionToolId },
|
|
220682
220633
|
"Function tool updated successfully"
|
|
220683
220634
|
);
|
|
220684
220635
|
} catch (error) {
|
|
220685
220636
|
logger14.error(
|
|
220686
|
-
{
|
|
220687
|
-
"Failed to update function tool in
|
|
220637
|
+
{ agentId: finalAgentId, functionToolId, error },
|
|
220638
|
+
"Failed to update function tool in agent"
|
|
220688
220639
|
);
|
|
220689
220640
|
throw error;
|
|
220690
220641
|
}
|
|
@@ -220693,17 +220644,17 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220693
220644
|
await Promise.all(functionToolPromises);
|
|
220694
220645
|
logger14.info(
|
|
220695
220646
|
{
|
|
220696
|
-
|
|
220697
|
-
functionToolCount: Object.keys(
|
|
220647
|
+
agentId: finalAgentId,
|
|
220648
|
+
functionToolCount: Object.keys(typedAgentDefinition.functionTools).length
|
|
220698
220649
|
},
|
|
220699
220650
|
"All function tools updated successfully"
|
|
220700
220651
|
);
|
|
220701
220652
|
}
|
|
220702
|
-
const internalAgentPromises = Object.entries(
|
|
220703
|
-
const internalAgent =
|
|
220704
|
-
let
|
|
220653
|
+
const internalAgentPromises = Object.entries(typedAgentDefinition.subAgents).filter(([_, agentData2]) => isInternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
|
|
220654
|
+
const internalAgent = agentData2;
|
|
220655
|
+
let existingSubAgent = null;
|
|
220705
220656
|
try {
|
|
220706
|
-
|
|
220657
|
+
existingSubAgent = await db.query.subAgents.findFirst({
|
|
220707
220658
|
where: drizzleOrm.and(
|
|
220708
220659
|
drizzleOrm.eq(subAgents.id, subAgentId),
|
|
220709
220660
|
drizzleOrm.eq(subAgents.tenantId, tenantId),
|
|
@@ -220716,25 +220667,25 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220716
220667
|
} catch (_error) {
|
|
220717
220668
|
}
|
|
220718
220669
|
let finalModelSettings = internalAgent.models === void 0 ? void 0 : internalAgent.models;
|
|
220719
|
-
if (
|
|
220720
|
-
const
|
|
220721
|
-
const
|
|
220670
|
+
if (existingSubAgent?.models && typedAgentDefinition.models) {
|
|
220671
|
+
const subAgentModels = existingSubAgent.models;
|
|
220672
|
+
const agentModels = typedAgentDefinition.models;
|
|
220722
220673
|
const modelTypes = ["base", "structuredOutput", "summarizer"];
|
|
220723
220674
|
const cascadedModels = { ...finalModelSettings };
|
|
220724
220675
|
for (const modelType of modelTypes) {
|
|
220725
|
-
if (
|
|
220726
|
-
(
|
|
220727
|
-
JSON.stringify(
|
|
220728
|
-
cascadedModels[modelType] =
|
|
220676
|
+
if (subAgentModels[modelType]?.model && existingAgentModels?.[modelType]?.model && subAgentModels[modelType].model === existingAgentModels[modelType].model && agentModels[modelType] && // Model name changed
|
|
220677
|
+
(agentModels[modelType].model !== existingAgentModels[modelType]?.model || // OR providerOptions changed
|
|
220678
|
+
JSON.stringify(agentModels[modelType].providerOptions) !== JSON.stringify(existingAgentModels[modelType]?.providerOptions))) {
|
|
220679
|
+
cascadedModels[modelType] = agentModels[modelType];
|
|
220729
220680
|
logger14.info(
|
|
220730
220681
|
{
|
|
220731
220682
|
subAgentId,
|
|
220732
220683
|
modelType,
|
|
220733
|
-
oldModel:
|
|
220734
|
-
newModel:
|
|
220735
|
-
hasProviderOptions: !!
|
|
220684
|
+
oldModel: existingAgentModels[modelType]?.model,
|
|
220685
|
+
newModel: agentModels[modelType].model,
|
|
220686
|
+
hasProviderOptions: !!agentModels[modelType].providerOptions
|
|
220736
220687
|
},
|
|
220737
|
-
"Cascading model change from
|
|
220688
|
+
"Cascading model change from parent agent to subAgent"
|
|
220738
220689
|
);
|
|
220739
220690
|
}
|
|
220740
220691
|
}
|
|
@@ -220747,7 +220698,7 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220747
220698
|
id: subAgentId,
|
|
220748
220699
|
tenantId,
|
|
220749
220700
|
projectId,
|
|
220750
|
-
|
|
220701
|
+
agentId: finalAgentId,
|
|
220751
220702
|
name: internalAgent.name || "",
|
|
220752
220703
|
description: internalAgent.description || "",
|
|
220753
220704
|
prompt: internalAgent.prompt || "",
|
|
@@ -220763,12 +220714,12 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220763
220714
|
}
|
|
220764
220715
|
});
|
|
220765
220716
|
await Promise.all(internalAgentPromises);
|
|
220766
|
-
const internalAgentCount = Object.entries(
|
|
220767
|
-
([_,
|
|
220717
|
+
const internalAgentCount = Object.entries(typedAgentDefinition.subAgents).filter(
|
|
220718
|
+
([_, agentData2]) => isInternalAgent(agentData2)
|
|
220768
220719
|
).length;
|
|
220769
220720
|
logger14.info({ internalAgentCount }, "All internal agents created/updated successfully");
|
|
220770
|
-
const externalAgentPromises = Object.entries(
|
|
220771
|
-
const externalAgent =
|
|
220721
|
+
const externalAgentPromises = Object.entries(typedAgentDefinition.subAgents).filter(([_, agentData2]) => isExternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
|
|
220722
|
+
const externalAgent = agentData2;
|
|
220772
220723
|
try {
|
|
220773
220724
|
logger14.info({ subAgentId }, "Processing external agent");
|
|
220774
220725
|
await upsertExternalAgent(db)({
|
|
@@ -220776,7 +220727,7 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220776
220727
|
id: subAgentId,
|
|
220777
220728
|
tenantId,
|
|
220778
220729
|
projectId,
|
|
220779
|
-
|
|
220730
|
+
agentId: finalAgentId,
|
|
220780
220731
|
name: externalAgent.name,
|
|
220781
220732
|
description: externalAgent.description || "",
|
|
220782
220733
|
baseUrl: externalAgent.baseUrl,
|
|
@@ -220791,23 +220742,23 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220791
220742
|
}
|
|
220792
220743
|
});
|
|
220793
220744
|
await Promise.all(externalAgentPromises);
|
|
220794
|
-
const externalAgentCount = Object.entries(
|
|
220795
|
-
([_,
|
|
220745
|
+
const externalAgentCount = Object.entries(typedAgentDefinition.subAgents).filter(
|
|
220746
|
+
([_, agentData2]) => isExternalAgent(agentData2)
|
|
220796
220747
|
).length;
|
|
220797
220748
|
logger14.info({ externalAgentCount }, "All external agents created/updated successfully");
|
|
220798
|
-
const incomingAgentIds = new Set(Object.keys(
|
|
220749
|
+
const incomingAgentIds = new Set(Object.keys(typedAgentDefinition.subAgents));
|
|
220799
220750
|
const existingInternalAgents = await listSubAgents(db)({
|
|
220800
|
-
scopes: { tenantId, projectId,
|
|
220751
|
+
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
220801
220752
|
});
|
|
220802
220753
|
const existingExternalAgents = await listExternalAgents(db)({
|
|
220803
|
-
scopes: { tenantId, projectId,
|
|
220754
|
+
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
220804
220755
|
});
|
|
220805
220756
|
let deletedInternalCount = 0;
|
|
220806
220757
|
for (const agent of existingInternalAgents) {
|
|
220807
220758
|
if (!incomingAgentIds.has(agent.id)) {
|
|
220808
220759
|
try {
|
|
220809
220760
|
await deleteSubAgent(db)({
|
|
220810
|
-
scopes: { tenantId, projectId,
|
|
220761
|
+
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
220811
220762
|
subAgentId: agent.id
|
|
220812
220763
|
});
|
|
220813
220764
|
deletedInternalCount++;
|
|
@@ -220825,7 +220776,7 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220825
220776
|
if (!incomingAgentIds.has(agent.id)) {
|
|
220826
220777
|
try {
|
|
220827
220778
|
await deleteExternalAgent(db)({
|
|
220828
|
-
scopes: { tenantId, projectId,
|
|
220779
|
+
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
220829
220780
|
subAgentId: agent.id
|
|
220830
220781
|
});
|
|
220831
220782
|
deletedExternalCount++;
|
|
@@ -220845,34 +220796,34 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220845
220796
|
deletedExternalCount,
|
|
220846
220797
|
totalDeleted: deletedInternalCount + deletedExternalCount
|
|
220847
220798
|
},
|
|
220848
|
-
"Deleted orphaned agents from
|
|
220799
|
+
"Deleted orphaned agents from agent"
|
|
220849
220800
|
);
|
|
220850
220801
|
}
|
|
220851
|
-
await
|
|
220852
|
-
scopes: { tenantId, projectId,
|
|
220802
|
+
await updateAgent(db)({
|
|
220803
|
+
scopes: { tenantId, projectId, agentId: typedAgentDefinition.id },
|
|
220853
220804
|
data: {
|
|
220854
|
-
name:
|
|
220855
|
-
defaultSubAgentId:
|
|
220856
|
-
description:
|
|
220805
|
+
name: typedAgentDefinition.name,
|
|
220806
|
+
defaultSubAgentId: typedAgentDefinition.defaultSubAgentId,
|
|
220807
|
+
description: typedAgentDefinition.description,
|
|
220857
220808
|
contextConfigId,
|
|
220858
|
-
models:
|
|
220859
|
-
statusUpdates:
|
|
220860
|
-
|
|
220861
|
-
stopWhen:
|
|
220809
|
+
models: typedAgentDefinition.models,
|
|
220810
|
+
statusUpdates: typedAgentDefinition.statusUpdates,
|
|
220811
|
+
prompt: typedAgentDefinition.prompt,
|
|
220812
|
+
stopWhen: typedAgentDefinition.stopWhen
|
|
220862
220813
|
}
|
|
220863
220814
|
});
|
|
220864
|
-
logger14.info({
|
|
220815
|
+
logger14.info({ agentId: typedAgentDefinition.id }, "Agent metadata updated");
|
|
220865
220816
|
const incomingRelationshipIds = /* @__PURE__ */ new Set();
|
|
220866
|
-
for (const [_subAgentId,
|
|
220867
|
-
if (isInternalAgent(
|
|
220868
|
-
for (const canUseItem of
|
|
220817
|
+
for (const [_subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
220818
|
+
if (isInternalAgent(agentData2) && agentData2.canUse && Array.isArray(agentData2.canUse)) {
|
|
220819
|
+
for (const canUseItem of agentData2.canUse) {
|
|
220869
220820
|
if (canUseItem.agentToolRelationId) {
|
|
220870
220821
|
incomingRelationshipIds.add(canUseItem.agentToolRelationId);
|
|
220871
220822
|
}
|
|
220872
220823
|
}
|
|
220873
220824
|
}
|
|
220874
220825
|
}
|
|
220875
|
-
for (const subAgentId of Object.keys(
|
|
220826
|
+
for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
|
|
220876
220827
|
try {
|
|
220877
220828
|
let deletedCount = 0;
|
|
220878
220829
|
if (incomingRelationshipIds.size === 0) {
|
|
@@ -220880,7 +220831,7 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220880
220831
|
drizzleOrm.and(
|
|
220881
220832
|
drizzleOrm.eq(subAgentToolRelations.tenantId, tenantId),
|
|
220882
220833
|
drizzleOrm.eq(subAgentToolRelations.projectId, projectId),
|
|
220883
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
220834
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, finalAgentId),
|
|
220884
220835
|
drizzleOrm.eq(subAgentToolRelations.subAgentId, subAgentId)
|
|
220885
220836
|
)
|
|
220886
220837
|
);
|
|
@@ -220890,7 +220841,7 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220890
220841
|
drizzleOrm.and(
|
|
220891
220842
|
drizzleOrm.eq(subAgentToolRelations.tenantId, tenantId),
|
|
220892
220843
|
drizzleOrm.eq(subAgentToolRelations.projectId, projectId),
|
|
220893
|
-
drizzleOrm.eq(subAgentToolRelations.
|
|
220844
|
+
drizzleOrm.eq(subAgentToolRelations.agentId, finalAgentId),
|
|
220894
220845
|
drizzleOrm.eq(subAgentToolRelations.subAgentId, subAgentId),
|
|
220895
220846
|
drizzleOrm.not(drizzleOrm.inArray(subAgentToolRelations.id, Array.from(incomingRelationshipIds)))
|
|
220896
220847
|
)
|
|
@@ -220905,18 +220856,18 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220905
220856
|
}
|
|
220906
220857
|
}
|
|
220907
220858
|
const agentToolPromises = [];
|
|
220908
|
-
for (const [subAgentId,
|
|
220909
|
-
if (isInternalAgent(
|
|
220910
|
-
for (const canUseItem of
|
|
220859
|
+
for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
220860
|
+
if (isInternalAgent(agentData2) && agentData2.canUse && Array.isArray(agentData2.canUse)) {
|
|
220861
|
+
for (const canUseItem of agentData2.canUse) {
|
|
220911
220862
|
agentToolPromises.push(
|
|
220912
220863
|
(async () => {
|
|
220913
220864
|
try {
|
|
220914
220865
|
const { toolId, toolSelection, headers: headers2, agentToolRelationId } = canUseItem;
|
|
220915
|
-
const isFunctionTool =
|
|
220866
|
+
const isFunctionTool = typedAgentDefinition.functionTools && toolId in typedAgentDefinition.functionTools;
|
|
220916
220867
|
if (isFunctionTool) {
|
|
220917
220868
|
logger14.info({ subAgentId, toolId }, "Processing agent-function tool relation");
|
|
220918
220869
|
await upsertSubAgentFunctionToolRelation(db)({
|
|
220919
|
-
scopes: { tenantId, projectId,
|
|
220870
|
+
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
220920
220871
|
subAgentId,
|
|
220921
220872
|
functionToolId: toolId,
|
|
220922
220873
|
relationId: agentToolRelationId
|
|
@@ -220928,7 +220879,7 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220928
220879
|
} else {
|
|
220929
220880
|
logger14.info({ subAgentId, toolId }, "Processing agent-MCP tool relation");
|
|
220930
220881
|
await upsertSubAgentToolRelation(db)({
|
|
220931
|
-
scopes: { tenantId, projectId,
|
|
220882
|
+
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
220932
220883
|
subAgentId,
|
|
220933
220884
|
toolId,
|
|
220934
220885
|
selectedTools: toolSelection || void 0,
|
|
@@ -220961,20 +220912,20 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220961
220912
|
{ agentToolPromisesCount: agentToolPromises.length },
|
|
220962
220913
|
"All agent-tool relations updated"
|
|
220963
220914
|
);
|
|
220964
|
-
for (const subAgentId of Object.keys(
|
|
220915
|
+
for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
|
|
220965
220916
|
await deleteAgentDataComponentRelationByAgent(db)({
|
|
220966
|
-
scopes: { tenantId, projectId,
|
|
220917
|
+
scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId }
|
|
220967
220918
|
});
|
|
220968
220919
|
}
|
|
220969
220920
|
const agentDataComponentPromises = [];
|
|
220970
|
-
for (const [subAgentId,
|
|
220971
|
-
if (isInternalAgent(
|
|
220972
|
-
for (const dataComponentId of
|
|
220921
|
+
for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
220922
|
+
if (isInternalAgent(agentData2) && agentData2.dataComponents) {
|
|
220923
|
+
for (const dataComponentId of agentData2.dataComponents) {
|
|
220973
220924
|
agentDataComponentPromises.push(
|
|
220974
220925
|
(async () => {
|
|
220975
220926
|
try {
|
|
220976
220927
|
await associateDataComponentWithAgent(db)({
|
|
220977
|
-
scopes: { tenantId, projectId,
|
|
220928
|
+
scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId },
|
|
220978
220929
|
dataComponentId
|
|
220979
220930
|
});
|
|
220980
220931
|
logger14.info(
|
|
@@ -220997,20 +220948,20 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220997
220948
|
{ agentDataComponentPromisesCount: agentDataComponentPromises.length },
|
|
220998
220949
|
"All agent-dataComponent relations updated"
|
|
220999
220950
|
);
|
|
221000
|
-
for (const subAgentId of Object.keys(
|
|
220951
|
+
for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
|
|
221001
220952
|
await deleteAgentArtifactComponentRelationByAgent(db)({
|
|
221002
|
-
scopes: { tenantId, projectId,
|
|
220953
|
+
scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId }
|
|
221003
220954
|
});
|
|
221004
220955
|
}
|
|
221005
220956
|
const agentArtifactComponentPromises = [];
|
|
221006
|
-
for (const [subAgentId,
|
|
221007
|
-
if (isInternalAgent(
|
|
221008
|
-
for (const artifactComponentId of
|
|
220957
|
+
for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
220958
|
+
if (isInternalAgent(agentData2) && agentData2.artifactComponents) {
|
|
220959
|
+
for (const artifactComponentId of agentData2.artifactComponents) {
|
|
221009
220960
|
agentArtifactComponentPromises.push(
|
|
221010
220961
|
(async () => {
|
|
221011
220962
|
try {
|
|
221012
220963
|
await associateArtifactComponentWithAgent(db)({
|
|
221013
|
-
scopes: { tenantId, projectId,
|
|
220964
|
+
scopes: { tenantId, projectId, agentId: finalAgentId, subAgentId },
|
|
221014
220965
|
artifactComponentId
|
|
221015
220966
|
});
|
|
221016
220967
|
logger14.info(
|
|
@@ -221033,22 +220984,22 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221033
220984
|
{ agentArtifactComponentPromisesCount: agentArtifactComponentPromises.length },
|
|
221034
220985
|
"All agent-artifactComponent relations updated"
|
|
221035
220986
|
);
|
|
221036
|
-
await
|
|
221037
|
-
scopes: { tenantId, projectId,
|
|
220987
|
+
await deleteAgentRelationsByAgent(db)({
|
|
220988
|
+
scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
|
|
221038
220989
|
});
|
|
221039
220990
|
const agentRelationPromises = [];
|
|
221040
|
-
for (const [subAgentId,
|
|
221041
|
-
if (isInternalAgent(
|
|
221042
|
-
for (const targetSubAgentId of
|
|
220991
|
+
for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
220992
|
+
if (isInternalAgent(agentData2) && agentData2.canTransferTo) {
|
|
220993
|
+
for (const targetSubAgentId of agentData2.canTransferTo) {
|
|
221043
220994
|
agentRelationPromises.push(
|
|
221044
220995
|
(async () => {
|
|
221045
220996
|
try {
|
|
221046
|
-
const targetAgentData =
|
|
220997
|
+
const targetAgentData = typedAgentDefinition.subAgents[targetSubAgentId];
|
|
221047
220998
|
const isTargetExternal = isExternalAgent(targetAgentData);
|
|
221048
220999
|
const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
|
|
221049
221000
|
const relationData = {
|
|
221050
221001
|
id: nanoid.nanoid(),
|
|
221051
|
-
|
|
221002
|
+
agentId: typedAgentDefinition.id || "",
|
|
221052
221003
|
sourceSubAgentId: subAgentId,
|
|
221053
221004
|
relationType: "transfer",
|
|
221054
221005
|
[targetField]: targetSubAgentId
|
|
@@ -221072,9 +221023,9 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221072
221023
|
);
|
|
221073
221024
|
}
|
|
221074
221025
|
}
|
|
221075
|
-
if (isInternalAgent(
|
|
221076
|
-
for (const targetSubAgentId of
|
|
221077
|
-
const targetAgentData =
|
|
221026
|
+
if (isInternalAgent(agentData2) && agentData2.canDelegateTo) {
|
|
221027
|
+
for (const targetSubAgentId of agentData2.canDelegateTo) {
|
|
221028
|
+
const targetAgentData = typedAgentDefinition.subAgents[targetSubAgentId];
|
|
221078
221029
|
const isTargetExternal = isExternalAgent(targetAgentData);
|
|
221079
221030
|
const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
|
|
221080
221031
|
agentRelationPromises.push(
|
|
@@ -221082,7 +221033,7 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221082
221033
|
try {
|
|
221083
221034
|
const relationData = {
|
|
221084
221035
|
id: nanoid.nanoid(),
|
|
221085
|
-
|
|
221036
|
+
agentId: typedAgentDefinition.id || "",
|
|
221086
221037
|
sourceSubAgentId: subAgentId,
|
|
221087
221038
|
relationType: "delegate",
|
|
221088
221039
|
[targetField]: targetSubAgentId
|
|
@@ -221109,93 +221060,93 @@ var updateFullGraphServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221109
221060
|
{ agentRelationPromisesCount: agentRelationPromises.length },
|
|
221110
221061
|
"All agent relations updated"
|
|
221111
221062
|
);
|
|
221112
|
-
const
|
|
221113
|
-
scopes: { tenantId, projectId,
|
|
221063
|
+
const updatedAgent = await getFullAgentDefinition(db)({
|
|
221064
|
+
scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
|
|
221114
221065
|
});
|
|
221115
|
-
if (!
|
|
221116
|
-
throw new Error("Failed to retrieve updated
|
|
221066
|
+
if (!updatedAgent) {
|
|
221067
|
+
throw new Error("Failed to retrieve updated agent");
|
|
221117
221068
|
}
|
|
221118
|
-
logger14.info({
|
|
221119
|
-
return
|
|
221069
|
+
logger14.info({ agentId: typedAgentDefinition.id }, "Full agent updated successfully");
|
|
221070
|
+
return updatedAgent;
|
|
221120
221071
|
} catch (error) {
|
|
221121
|
-
logger14.error({
|
|
221072
|
+
logger14.error({ agentId: typedAgentDefinition.id, error }, "Failed to update full agent");
|
|
221122
221073
|
throw error;
|
|
221123
221074
|
}
|
|
221124
221075
|
};
|
|
221125
|
-
var
|
|
221076
|
+
var getFullAgent = (db, logger14 = defaultLogger) => async (params) => {
|
|
221126
221077
|
const { scopes } = params;
|
|
221127
221078
|
const { tenantId, projectId } = scopes;
|
|
221128
|
-
logger14.info({ tenantId,
|
|
221079
|
+
logger14.info({ tenantId, agentId: scopes.agentId }, "Retrieving full agent definition");
|
|
221129
221080
|
try {
|
|
221130
|
-
const
|
|
221131
|
-
scopes: { tenantId, projectId,
|
|
221081
|
+
const agent = await getFullAgentDefinition(db)({
|
|
221082
|
+
scopes: { tenantId, projectId, agentId: scopes.agentId }
|
|
221132
221083
|
});
|
|
221133
|
-
if (!
|
|
221134
|
-
logger14.info({ tenantId,
|
|
221084
|
+
if (!agent) {
|
|
221085
|
+
logger14.info({ tenantId, agentId: scopes.agentId }, "Agent not found");
|
|
221135
221086
|
return null;
|
|
221136
221087
|
}
|
|
221137
221088
|
logger14.info(
|
|
221138
221089
|
{
|
|
221139
221090
|
tenantId,
|
|
221140
|
-
|
|
221141
|
-
agentCount: Object.keys(
|
|
221091
|
+
agentId: scopes.agentId,
|
|
221092
|
+
agentCount: Object.keys(agent.subAgents).length
|
|
221142
221093
|
},
|
|
221143
|
-
"Full
|
|
221094
|
+
"Full agent retrieved successfully"
|
|
221144
221095
|
);
|
|
221145
|
-
return
|
|
221096
|
+
return agent;
|
|
221146
221097
|
} catch (error) {
|
|
221147
221098
|
logger14.error(
|
|
221148
221099
|
{
|
|
221149
221100
|
tenantId,
|
|
221150
|
-
|
|
221101
|
+
agentId: scopes.agentId,
|
|
221151
221102
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
221152
221103
|
},
|
|
221153
|
-
"Failed to retrieve full
|
|
221104
|
+
"Failed to retrieve full agent"
|
|
221154
221105
|
);
|
|
221155
221106
|
throw error;
|
|
221156
221107
|
}
|
|
221157
221108
|
};
|
|
221158
|
-
var
|
|
221159
|
-
const { tenantId, projectId,
|
|
221160
|
-
logger14.info({ tenantId,
|
|
221109
|
+
var deleteFullAgent = (db, logger14 = defaultLogger) => async (params) => {
|
|
221110
|
+
const { tenantId, projectId, agentId } = params.scopes;
|
|
221111
|
+
logger14.info({ tenantId, agentId }, "Deleting full agent and related entities");
|
|
221161
221112
|
try {
|
|
221162
|
-
const
|
|
221163
|
-
scopes: { tenantId, projectId,
|
|
221113
|
+
const agent = await getFullAgentDefinition(db)({
|
|
221114
|
+
scopes: { tenantId, projectId, agentId }
|
|
221164
221115
|
});
|
|
221165
|
-
if (!
|
|
221166
|
-
logger14.info({ tenantId,
|
|
221116
|
+
if (!agent) {
|
|
221117
|
+
logger14.info({ tenantId, agentId }, "Agent not found for deletion");
|
|
221167
221118
|
return false;
|
|
221168
221119
|
}
|
|
221169
|
-
await
|
|
221170
|
-
scopes: { tenantId, projectId,
|
|
221120
|
+
await deleteAgentRelationsByAgent(db)({
|
|
221121
|
+
scopes: { tenantId, projectId, agentId }
|
|
221171
221122
|
});
|
|
221172
|
-
logger14.info({ tenantId,
|
|
221173
|
-
const subAgentIds = Object.keys(
|
|
221123
|
+
logger14.info({ tenantId, agentId }, "Agent relations deleted");
|
|
221124
|
+
const subAgentIds = Object.keys(agent.subAgents);
|
|
221174
221125
|
if (subAgentIds.length > 0) {
|
|
221175
221126
|
for (const subAgentId of subAgentIds) {
|
|
221176
221127
|
await deleteAgentToolRelationByAgent(db)({
|
|
221177
|
-
scopes: { tenantId, projectId,
|
|
221128
|
+
scopes: { tenantId, projectId, agentId, subAgentId }
|
|
221178
221129
|
});
|
|
221179
221130
|
}
|
|
221180
221131
|
logger14.info(
|
|
221181
|
-
{ tenantId,
|
|
221132
|
+
{ tenantId, agentId, agentCount: subAgentIds.length },
|
|
221182
221133
|
"Agent-tool relations deleted"
|
|
221183
221134
|
);
|
|
221184
221135
|
}
|
|
221185
|
-
await
|
|
221186
|
-
scopes: { tenantId, projectId,
|
|
221136
|
+
await deleteAgent(db)({
|
|
221137
|
+
scopes: { tenantId, projectId, agentId }
|
|
221187
221138
|
});
|
|
221188
|
-
logger14.info({ tenantId,
|
|
221189
|
-
logger14.info({ tenantId,
|
|
221139
|
+
logger14.info({ tenantId, agentId }, "Agent metadata deleted");
|
|
221140
|
+
logger14.info({ tenantId, agentId }, "Full agent deleted successfully");
|
|
221190
221141
|
return true;
|
|
221191
221142
|
} catch (error) {
|
|
221192
221143
|
logger14.error(
|
|
221193
221144
|
{
|
|
221194
221145
|
tenantId,
|
|
221195
|
-
|
|
221146
|
+
agentId,
|
|
221196
221147
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
221197
221148
|
},
|
|
221198
|
-
"Failed to delete full
|
|
221149
|
+
"Failed to delete full agent"
|
|
221199
221150
|
);
|
|
221200
221151
|
throw error;
|
|
221201
221152
|
}
|
|
@@ -221578,7 +221529,7 @@ var listProjects = (db) => async (params) => {
|
|
|
221578
221529
|
}
|
|
221579
221530
|
const projectIdSets = await Promise.all([
|
|
221580
221531
|
db.selectDistinct({ projectId: subAgents.projectId }).from(subAgents).where(drizzleOrm.eq(subAgents.tenantId, params.tenantId)),
|
|
221581
|
-
db.selectDistinct({ projectId:
|
|
221532
|
+
db.selectDistinct({ projectId: agents.projectId }).from(agents).where(drizzleOrm.eq(agents.tenantId, params.tenantId)),
|
|
221582
221533
|
db.selectDistinct({ projectId: tools.projectId }).from(tools).where(drizzleOrm.eq(tools.tenantId, params.tenantId)),
|
|
221583
221534
|
db.selectDistinct({ projectId: contextConfigs.projectId }).from(contextConfigs).where(drizzleOrm.eq(contextConfigs.tenantId, params.tenantId)),
|
|
221584
221535
|
db.selectDistinct({ projectId: externalAgents.projectId }).from(externalAgents).where(drizzleOrm.eq(externalAgents.tenantId, params.tenantId)),
|
|
@@ -221624,16 +221575,16 @@ var listProjectsPaginated = (db) => async (params) => {
|
|
|
221624
221575
|
};
|
|
221625
221576
|
var getProjectResourceCounts = (db) => async (params) => {
|
|
221626
221577
|
const whereClause = (table) => drizzleOrm.and(drizzleOrm.eq(table.tenantId, params.tenantId), drizzleOrm.eq(table.projectId, params.projectId));
|
|
221627
|
-
const [
|
|
221578
|
+
const [subAgentResults, agentResults, toolResults, contextConfigResults, externalAgentResults] = await Promise.all([
|
|
221628
221579
|
db.select({ count: subAgents.id }).from(subAgents).where(whereClause(subAgents)),
|
|
221629
|
-
db.select({ count:
|
|
221580
|
+
db.select({ count: agents.id }).from(agents).where(whereClause(agents)),
|
|
221630
221581
|
db.select({ count: tools.id }).from(tools).where(whereClause(tools)),
|
|
221631
221582
|
db.select({ count: contextConfigs.id }).from(contextConfigs).where(whereClause(contextConfigs)),
|
|
221632
221583
|
db.select({ count: externalAgents.id }).from(externalAgents).where(whereClause(externalAgents))
|
|
221633
221584
|
]);
|
|
221634
221585
|
return {
|
|
221586
|
+
subAgents: subAgentResults.length,
|
|
221635
221587
|
agents: agentResults.length,
|
|
221636
|
-
agentGraphs: graphResults.length,
|
|
221637
221588
|
tools: toolResults.length,
|
|
221638
221589
|
contextConfigs: contextConfigResults.length,
|
|
221639
221590
|
externalAgents: externalAgentResults.length
|
|
@@ -221643,7 +221594,7 @@ var projectExists = (db) => async (params) => {
|
|
|
221643
221594
|
const whereClause = (table) => drizzleOrm.and(drizzleOrm.eq(table.tenantId, params.tenantId), drizzleOrm.eq(table.projectId, params.projectId));
|
|
221644
221595
|
const checks = [
|
|
221645
221596
|
db.select({ id: subAgents.id }).from(subAgents).where(whereClause(subAgents)).limit(1),
|
|
221646
|
-
db.select({ id:
|
|
221597
|
+
db.select({ id: agents.id }).from(agents).where(whereClause(agents)).limit(1),
|
|
221647
221598
|
db.select({ id: tools.id }).from(tools).where(whereClause(tools)).limit(1),
|
|
221648
221599
|
db.select({ id: contextConfigs.id }).from(contextConfigs).where(whereClause(contextConfigs)).limit(1),
|
|
221649
221600
|
db.select({ id: externalAgents.id }).from(externalAgents).where(whereClause(externalAgents)).limit(1),
|
|
@@ -221725,24 +221676,24 @@ var deleteProject = (db) => async (params) => {
|
|
|
221725
221676
|
async function cascadeStopWhenUpdates(db, scopes, oldStopWhen, newStopWhen) {
|
|
221726
221677
|
const { tenantId, projectId } = scopes;
|
|
221727
221678
|
if (oldStopWhen?.transferCountIs !== newStopWhen?.transferCountIs) {
|
|
221728
|
-
const
|
|
221729
|
-
where: drizzleOrm.and(drizzleOrm.eq(
|
|
221679
|
+
const agentsToUpdate = await db.query.agents.findMany({
|
|
221680
|
+
where: drizzleOrm.and(drizzleOrm.eq(agents.tenantId, tenantId), drizzleOrm.eq(agents.projectId, projectId))
|
|
221730
221681
|
});
|
|
221731
|
-
for (const
|
|
221732
|
-
const
|
|
221733
|
-
if (!
|
|
221682
|
+
for (const agent of agentsToUpdate) {
|
|
221683
|
+
const agentStopWhen = agent.stopWhen;
|
|
221684
|
+
if (!agentStopWhen?.transferCountIs || agentStopWhen.transferCountIs === oldStopWhen?.transferCountIs) {
|
|
221734
221685
|
const updatedStopWhen = {
|
|
221735
|
-
...
|
|
221686
|
+
...agentStopWhen || {},
|
|
221736
221687
|
transferCountIs: newStopWhen?.transferCountIs
|
|
221737
221688
|
};
|
|
221738
|
-
await db.update(
|
|
221689
|
+
await db.update(agents).set({
|
|
221739
221690
|
stopWhen: updatedStopWhen,
|
|
221740
221691
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
221741
221692
|
}).where(
|
|
221742
221693
|
drizzleOrm.and(
|
|
221743
|
-
drizzleOrm.eq(
|
|
221744
|
-
drizzleOrm.eq(
|
|
221745
|
-
drizzleOrm.eq(
|
|
221694
|
+
drizzleOrm.eq(agents.tenantId, tenantId),
|
|
221695
|
+
drizzleOrm.eq(agents.projectId, projectId),
|
|
221696
|
+
drizzleOrm.eq(agents.id, agent.id)
|
|
221746
221697
|
)
|
|
221747
221698
|
);
|
|
221748
221699
|
}
|
|
@@ -221786,7 +221737,7 @@ var createFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
221786
221737
|
{
|
|
221787
221738
|
tenantId,
|
|
221788
221739
|
projectId: typed.id,
|
|
221789
|
-
|
|
221740
|
+
agentCount: Object.keys(typed.agents || {}).length
|
|
221790
221741
|
},
|
|
221791
221742
|
"Creating full project in database"
|
|
221792
221743
|
);
|
|
@@ -222005,19 +221956,19 @@ var createFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
222005
221956
|
"All project artifactComponents created successfully"
|
|
222006
221957
|
);
|
|
222007
221958
|
}
|
|
222008
|
-
if (typed.
|
|
221959
|
+
if (typed.agents && Object.keys(typed.agents).length > 0) {
|
|
222009
221960
|
logger14.info(
|
|
222010
221961
|
{
|
|
222011
221962
|
projectId: typed.id,
|
|
222012
|
-
|
|
221963
|
+
agentCount: Object.keys(typed.agents).length
|
|
222013
221964
|
},
|
|
222014
|
-
"Creating project
|
|
221965
|
+
"Creating project agent"
|
|
222015
221966
|
);
|
|
222016
|
-
const
|
|
221967
|
+
const agentPromises = Object.entries(typed.agents).map(async ([agentId, agentData]) => {
|
|
222017
221968
|
try {
|
|
222018
|
-
logger14.info({ projectId: typed.id,
|
|
222019
|
-
const
|
|
222020
|
-
...
|
|
221969
|
+
logger14.info({ projectId: typed.id, agentId }, "Creating agent in project");
|
|
221970
|
+
const agentDataWithProjectResources = {
|
|
221971
|
+
...agentData,
|
|
222021
221972
|
tools: typed.tools || {},
|
|
222022
221973
|
// Pass project-level MCP tools for validation
|
|
222023
221974
|
functions: typed.functions || {},
|
|
@@ -222025,28 +221976,28 @@ var createFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
222025
221976
|
dataComponents: typed.dataComponents || {},
|
|
222026
221977
|
artifactComponents: typed.artifactComponents || {},
|
|
222027
221978
|
credentialReferences: typed.credentialReferences || {},
|
|
222028
|
-
statusUpdates:
|
|
221979
|
+
statusUpdates: agentData.statusUpdates === null ? void 0 : agentData.statusUpdates
|
|
222029
221980
|
};
|
|
222030
|
-
await
|
|
221981
|
+
await createFullAgentServerSide(db, logger14)(
|
|
222031
221982
|
{ tenantId, projectId: typed.id },
|
|
222032
|
-
|
|
221983
|
+
agentDataWithProjectResources
|
|
222033
221984
|
);
|
|
222034
|
-
logger14.info({ projectId: typed.id,
|
|
221985
|
+
logger14.info({ projectId: typed.id, agentId }, "Agent created successfully in project");
|
|
222035
221986
|
} catch (error) {
|
|
222036
221987
|
logger14.error(
|
|
222037
|
-
{ projectId: typed.id,
|
|
222038
|
-
"Failed to create
|
|
221988
|
+
{ projectId: typed.id, agentId, error },
|
|
221989
|
+
"Failed to create agent in project"
|
|
222039
221990
|
);
|
|
222040
221991
|
throw error;
|
|
222041
221992
|
}
|
|
222042
221993
|
});
|
|
222043
|
-
await Promise.all(
|
|
221994
|
+
await Promise.all(agentPromises);
|
|
222044
221995
|
logger14.info(
|
|
222045
221996
|
{
|
|
222046
221997
|
projectId: typed.id,
|
|
222047
|
-
|
|
221998
|
+
agentCount: Object.keys(typed.agents).length
|
|
222048
221999
|
},
|
|
222049
|
-
"All project
|
|
222000
|
+
"All project agent created successfully"
|
|
222050
222001
|
);
|
|
222051
222002
|
}
|
|
222052
222003
|
logger14.info({ projectId: typed.id }, "Full project created successfully");
|
|
@@ -222078,7 +222029,7 @@ var updateFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
222078
222029
|
{
|
|
222079
222030
|
tenantId,
|
|
222080
222031
|
projectId: typed.id,
|
|
222081
|
-
|
|
222032
|
+
agentCount: Object.keys(typed.agents || {}).length
|
|
222082
222033
|
},
|
|
222083
222034
|
"Updating full project in database"
|
|
222084
222035
|
);
|
|
@@ -222313,52 +222264,52 @@ var updateFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
222313
222264
|
"All project artifactComponents updated successfully"
|
|
222314
222265
|
);
|
|
222315
222266
|
}
|
|
222316
|
-
const
|
|
222317
|
-
const
|
|
222267
|
+
const incomingAgentIds = new Set(Object.keys(typed.agents || {}));
|
|
222268
|
+
const existingAgents = await listAgents(db)({
|
|
222318
222269
|
scopes: { tenantId, projectId: typed.id }
|
|
222319
222270
|
});
|
|
222320
|
-
let
|
|
222321
|
-
for (const
|
|
222322
|
-
if (!
|
|
222271
|
+
let deletedAgentCount = 0;
|
|
222272
|
+
for (const agent of existingAgents) {
|
|
222273
|
+
if (!incomingAgentIds.has(agent.id)) {
|
|
222323
222274
|
try {
|
|
222324
|
-
await
|
|
222275
|
+
await deleteFullAgent(
|
|
222325
222276
|
db,
|
|
222326
222277
|
logger14
|
|
222327
222278
|
)({
|
|
222328
|
-
scopes: { tenantId, projectId: typed.id,
|
|
222279
|
+
scopes: { tenantId, projectId: typed.id, agentId: agent.id }
|
|
222329
222280
|
});
|
|
222330
|
-
|
|
222331
|
-
logger14.info({
|
|
222281
|
+
deletedAgentCount++;
|
|
222282
|
+
logger14.info({ agentId: agent.id }, "Deleted orphaned agent from project");
|
|
222332
222283
|
} catch (error) {
|
|
222333
222284
|
logger14.error(
|
|
222334
|
-
{
|
|
222335
|
-
"Failed to delete orphaned
|
|
222285
|
+
{ agentId: agent.id, error },
|
|
222286
|
+
"Failed to delete orphaned agent from project"
|
|
222336
222287
|
);
|
|
222337
222288
|
}
|
|
222338
222289
|
}
|
|
222339
222290
|
}
|
|
222340
|
-
if (
|
|
222291
|
+
if (deletedAgentCount > 0) {
|
|
222341
222292
|
logger14.info(
|
|
222342
222293
|
{
|
|
222343
|
-
|
|
222294
|
+
deletedAgentCount,
|
|
222344
222295
|
projectId: typed.id
|
|
222345
222296
|
},
|
|
222346
|
-
"Deleted orphaned
|
|
222297
|
+
"Deleted orphaned agent from project"
|
|
222347
222298
|
);
|
|
222348
222299
|
}
|
|
222349
|
-
if (typed.
|
|
222300
|
+
if (typed.agents && Object.keys(typed.agents).length > 0) {
|
|
222350
222301
|
logger14.info(
|
|
222351
222302
|
{
|
|
222352
222303
|
projectId: typed.id,
|
|
222353
|
-
|
|
222304
|
+
agentCount: Object.keys(typed.agents).length
|
|
222354
222305
|
},
|
|
222355
|
-
"Updating project
|
|
222306
|
+
"Updating project agent"
|
|
222356
222307
|
);
|
|
222357
|
-
const
|
|
222308
|
+
const agentPromises = Object.entries(typed.agents).map(async ([agentId, agentData]) => {
|
|
222358
222309
|
try {
|
|
222359
|
-
logger14.info({ projectId: typed.id,
|
|
222360
|
-
const
|
|
222361
|
-
...
|
|
222310
|
+
logger14.info({ projectId: typed.id, agentId }, "Updating agent in project");
|
|
222311
|
+
const agentDataWithProjectResources = {
|
|
222312
|
+
...agentData,
|
|
222362
222313
|
tools: typed.tools || {},
|
|
222363
222314
|
// Pass project-level MCP tools for validation
|
|
222364
222315
|
functions: typed.functions || {},
|
|
@@ -222366,28 +222317,28 @@ var updateFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
222366
222317
|
dataComponents: typed.dataComponents || {},
|
|
222367
222318
|
artifactComponents: typed.artifactComponents || {},
|
|
222368
222319
|
credentialReferences: typed.credentialReferences || {},
|
|
222369
|
-
statusUpdates:
|
|
222320
|
+
statusUpdates: agentData.statusUpdates === null ? void 0 : agentData.statusUpdates
|
|
222370
222321
|
};
|
|
222371
|
-
await
|
|
222322
|
+
await updateFullAgentServerSide(db, logger14)(
|
|
222372
222323
|
{ tenantId, projectId: typed.id },
|
|
222373
|
-
|
|
222324
|
+
agentDataWithProjectResources
|
|
222374
222325
|
);
|
|
222375
|
-
logger14.info({ projectId: typed.id,
|
|
222326
|
+
logger14.info({ projectId: typed.id, agentId }, "Agent updated successfully in project");
|
|
222376
222327
|
} catch (error) {
|
|
222377
222328
|
logger14.error(
|
|
222378
|
-
{ projectId: typed.id,
|
|
222379
|
-
"Failed to update
|
|
222329
|
+
{ projectId: typed.id, agentId, error },
|
|
222330
|
+
"Failed to update agent in project"
|
|
222380
222331
|
);
|
|
222381
222332
|
throw error;
|
|
222382
222333
|
}
|
|
222383
222334
|
});
|
|
222384
|
-
await Promise.all(
|
|
222335
|
+
await Promise.all(agentPromises);
|
|
222385
222336
|
logger14.info(
|
|
222386
222337
|
{
|
|
222387
222338
|
projectId: typed.id,
|
|
222388
|
-
|
|
222339
|
+
agentCount: Object.keys(typed.agents).length
|
|
222389
222340
|
},
|
|
222390
|
-
"All project
|
|
222341
|
+
"All project agent updated successfully"
|
|
222391
222342
|
);
|
|
222392
222343
|
}
|
|
222393
222344
|
logger14.info({ projectId: typed.id }, "Full project updated successfully");
|
|
@@ -222422,16 +222373,16 @@ var getFullProject = (db, logger14 = defaultLogger2) => async (params) => {
|
|
|
222422
222373
|
return null;
|
|
222423
222374
|
}
|
|
222424
222375
|
logger14.info({ tenantId, projectId }, "Project metadata retrieved");
|
|
222425
|
-
const
|
|
222376
|
+
const agentList = await listAgents(db)({
|
|
222426
222377
|
scopes: { tenantId, projectId }
|
|
222427
222378
|
});
|
|
222428
222379
|
logger14.info(
|
|
222429
222380
|
{
|
|
222430
222381
|
tenantId,
|
|
222431
222382
|
projectId,
|
|
222432
|
-
|
|
222383
|
+
agentCount: agentList.length
|
|
222433
222384
|
},
|
|
222434
|
-
"Found
|
|
222385
|
+
"Found agent for project"
|
|
222435
222386
|
);
|
|
222436
222387
|
const projectTools = {};
|
|
222437
222388
|
try {
|
|
@@ -222529,34 +222480,34 @@ var getFullProject = (db, logger14 = defaultLogger2) => async (params) => {
|
|
|
222529
222480
|
"Failed to retrieve credentialReferences for project"
|
|
222530
222481
|
);
|
|
222531
222482
|
}
|
|
222532
|
-
const
|
|
222533
|
-
if (
|
|
222534
|
-
const
|
|
222483
|
+
const agents2 = {};
|
|
222484
|
+
if (agentList.length > 0) {
|
|
222485
|
+
const agentPromises = agentList.map(async (agent) => {
|
|
222535
222486
|
try {
|
|
222536
222487
|
logger14.info(
|
|
222537
|
-
{ tenantId, projectId,
|
|
222538
|
-
"Retrieving full
|
|
222488
|
+
{ tenantId, projectId, agentId: agent.id },
|
|
222489
|
+
"Retrieving full agent definition"
|
|
222539
222490
|
);
|
|
222540
|
-
const
|
|
222541
|
-
scopes: { tenantId, projectId,
|
|
222491
|
+
const fullAgent = await getFullAgent(db)({
|
|
222492
|
+
scopes: { tenantId, projectId, agentId: agent.id }
|
|
222542
222493
|
});
|
|
222543
|
-
if (
|
|
222544
|
-
|
|
222494
|
+
if (fullAgent) {
|
|
222495
|
+
agents2[agent.id] = fullAgent;
|
|
222545
222496
|
logger14.info(
|
|
222546
|
-
{ tenantId, projectId,
|
|
222547
|
-
"Full
|
|
222497
|
+
{ tenantId, projectId, agentId: agent.id },
|
|
222498
|
+
"Full agent definition retrieved"
|
|
222548
222499
|
);
|
|
222549
222500
|
} else {
|
|
222550
|
-
logger14.warn({ tenantId, projectId,
|
|
222501
|
+
logger14.warn({ tenantId, projectId, agentId: agent.id }, "Agent definition not found");
|
|
222551
222502
|
}
|
|
222552
222503
|
} catch (error) {
|
|
222553
222504
|
logger14.error(
|
|
222554
|
-
{ tenantId, projectId,
|
|
222555
|
-
"Failed to retrieve full
|
|
222505
|
+
{ tenantId, projectId, agentId: agent.id, error },
|
|
222506
|
+
"Failed to retrieve full agent definition"
|
|
222556
222507
|
);
|
|
222557
222508
|
}
|
|
222558
222509
|
});
|
|
222559
|
-
await Promise.all(
|
|
222510
|
+
await Promise.all(agentPromises);
|
|
222560
222511
|
}
|
|
222561
222512
|
if (!project.models) {
|
|
222562
222513
|
throw new Error(
|
|
@@ -222569,7 +222520,7 @@ var getFullProject = (db, logger14 = defaultLogger2) => async (params) => {
|
|
|
222569
222520
|
description: project.description,
|
|
222570
222521
|
models: project.models,
|
|
222571
222522
|
stopWhen: project.stopWhen || void 0,
|
|
222572
|
-
|
|
222523
|
+
agents: agents2,
|
|
222573
222524
|
tools: projectTools,
|
|
222574
222525
|
dataComponents: projectDataComponents,
|
|
222575
222526
|
artifactComponents: projectArtifactComponents,
|
|
@@ -222581,7 +222532,7 @@ var getFullProject = (db, logger14 = defaultLogger2) => async (params) => {
|
|
|
222581
222532
|
{
|
|
222582
222533
|
tenantId,
|
|
222583
222534
|
projectId,
|
|
222584
|
-
|
|
222535
|
+
agentCount: Object.keys(fullProjectDefinition.agents).length
|
|
222585
222536
|
},
|
|
222586
222537
|
"Full project definition retrieved"
|
|
222587
222538
|
);
|
|
@@ -222613,44 +222564,44 @@ var deleteFullProject = (db, logger14 = defaultLogger2) => async (params) => {
|
|
|
222613
222564
|
logger14.info({ tenantId, projectId }, "Project not found for deletion");
|
|
222614
222565
|
return false;
|
|
222615
222566
|
}
|
|
222616
|
-
if (project.
|
|
222567
|
+
if (project.agents && Object.keys(project.agents).length > 0) {
|
|
222617
222568
|
logger14.info(
|
|
222618
222569
|
{
|
|
222619
222570
|
tenantId,
|
|
222620
222571
|
projectId,
|
|
222621
|
-
|
|
222572
|
+
agentCount: Object.keys(project.agents).length
|
|
222622
222573
|
},
|
|
222623
|
-
"Deleting project
|
|
222574
|
+
"Deleting project agent"
|
|
222624
222575
|
);
|
|
222625
|
-
const
|
|
222576
|
+
const agentPromises = Object.keys(project.agents).map(async (agentId) => {
|
|
222626
222577
|
try {
|
|
222627
|
-
logger14.info({ tenantId, projectId,
|
|
222628
|
-
await
|
|
222578
|
+
logger14.info({ tenantId, projectId, agentId }, "Deleting agent from project");
|
|
222579
|
+
await deleteFullAgent(
|
|
222629
222580
|
db,
|
|
222630
222581
|
logger14
|
|
222631
222582
|
)({
|
|
222632
|
-
scopes: { tenantId, projectId,
|
|
222583
|
+
scopes: { tenantId, projectId, agentId }
|
|
222633
222584
|
});
|
|
222634
222585
|
logger14.info(
|
|
222635
|
-
{ tenantId, projectId,
|
|
222636
|
-
"
|
|
222586
|
+
{ tenantId, projectId, agentId },
|
|
222587
|
+
"Agent deleted successfully from project"
|
|
222637
222588
|
);
|
|
222638
222589
|
} catch (error) {
|
|
222639
222590
|
logger14.error(
|
|
222640
|
-
{ tenantId, projectId,
|
|
222641
|
-
"Failed to delete
|
|
222591
|
+
{ tenantId, projectId, agentId, error },
|
|
222592
|
+
"Failed to delete agent from project"
|
|
222642
222593
|
);
|
|
222643
222594
|
throw error;
|
|
222644
222595
|
}
|
|
222645
222596
|
});
|
|
222646
|
-
await Promise.all(
|
|
222597
|
+
await Promise.all(agentPromises);
|
|
222647
222598
|
logger14.info(
|
|
222648
222599
|
{
|
|
222649
222600
|
tenantId,
|
|
222650
222601
|
projectId,
|
|
222651
|
-
|
|
222602
|
+
agentCount: Object.keys(project.agents).length
|
|
222652
222603
|
},
|
|
222653
|
-
"All project
|
|
222604
|
+
"All project agent deleted successfully"
|
|
222654
222605
|
);
|
|
222655
222606
|
}
|
|
222656
222607
|
const deleted = await deleteProject(db)({
|
|
@@ -223439,10 +223390,7 @@ async function fetchExistingHeaders({
|
|
|
223439
223390
|
credentialStores
|
|
223440
223391
|
}) {
|
|
223441
223392
|
const contextResolver = new ContextResolver(tenantId, projectId, dbClient, credentialStores);
|
|
223442
|
-
const headers2 = await contextResolver.resolveHeaders(
|
|
223443
|
-
conversationId,
|
|
223444
|
-
contextConfig2.id
|
|
223445
|
-
);
|
|
223393
|
+
const headers2 = await contextResolver.resolveHeaders(conversationId, contextConfig2.id);
|
|
223446
223394
|
if (Object.keys(headers2).length > 0) {
|
|
223447
223395
|
return {
|
|
223448
223396
|
valid: true,
|
|
@@ -223450,25 +223398,23 @@ async function fetchExistingHeaders({
|
|
|
223450
223398
|
validatedContext: headers2
|
|
223451
223399
|
};
|
|
223452
223400
|
}
|
|
223453
|
-
throw new Error(
|
|
223454
|
-
"No headers found in cache. Please provide headers in request."
|
|
223455
|
-
);
|
|
223401
|
+
throw new Error("No headers found in cache. Please provide headers in request.");
|
|
223456
223402
|
}
|
|
223457
223403
|
async function validateHeaders({
|
|
223458
223404
|
tenantId,
|
|
223459
223405
|
projectId,
|
|
223460
|
-
|
|
223406
|
+
agentId,
|
|
223461
223407
|
conversationId,
|
|
223462
223408
|
parsedRequest,
|
|
223463
223409
|
dbClient,
|
|
223464
223410
|
credentialStores
|
|
223465
223411
|
}) {
|
|
223466
223412
|
try {
|
|
223467
|
-
const
|
|
223468
|
-
scopes: { tenantId, projectId,
|
|
223413
|
+
const agent = await getAgentWithDefaultSubAgent(dbClient)({
|
|
223414
|
+
scopes: { tenantId, projectId, agentId }
|
|
223469
223415
|
});
|
|
223470
|
-
if (!
|
|
223471
|
-
logger10.debug({
|
|
223416
|
+
if (!agent?.contextConfigId) {
|
|
223417
|
+
logger10.debug({ agentId }, "No context config found for agent, skipping validation");
|
|
223472
223418
|
return {
|
|
223473
223419
|
valid: true,
|
|
223474
223420
|
errors: [],
|
|
@@ -223476,11 +223422,11 @@ async function validateHeaders({
|
|
|
223476
223422
|
};
|
|
223477
223423
|
}
|
|
223478
223424
|
const contextConfig2 = await getContextConfigById(dbClient)({
|
|
223479
|
-
scopes: { tenantId, projectId,
|
|
223480
|
-
id:
|
|
223425
|
+
scopes: { tenantId, projectId, agentId },
|
|
223426
|
+
id: agent.contextConfigId
|
|
223481
223427
|
});
|
|
223482
223428
|
if (!contextConfig2) {
|
|
223483
|
-
logger10.warn({ contextConfigId:
|
|
223429
|
+
logger10.warn({ contextConfigId: agent.contextConfigId }, "Context config not found");
|
|
223484
223430
|
return {
|
|
223485
223431
|
valid: false,
|
|
223486
223432
|
errors: [
|
|
@@ -223548,7 +223494,7 @@ async function validateHeaders({
|
|
|
223548
223494
|
logger10.error(
|
|
223549
223495
|
{
|
|
223550
223496
|
tenantId,
|
|
223551
|
-
|
|
223497
|
+
agentId,
|
|
223552
223498
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
223553
223499
|
},
|
|
223554
223500
|
"Failed to validate headers"
|
|
@@ -223568,13 +223514,13 @@ function contextValidationMiddleware(dbClient) {
|
|
|
223568
223514
|
return async (c, next) => {
|
|
223569
223515
|
try {
|
|
223570
223516
|
const executionContext = getRequestExecutionContext(c);
|
|
223571
|
-
let { tenantId, projectId,
|
|
223572
|
-
if (!tenantId || !projectId || !
|
|
223517
|
+
let { tenantId, projectId, agentId } = executionContext;
|
|
223518
|
+
if (!tenantId || !projectId || !agentId) {
|
|
223573
223519
|
tenantId = c.req.param("tenantId");
|
|
223574
223520
|
projectId = c.req.param("projectId");
|
|
223575
|
-
|
|
223521
|
+
agentId = c.req.param("agentId");
|
|
223576
223522
|
}
|
|
223577
|
-
if (!tenantId || !projectId || !
|
|
223523
|
+
if (!tenantId || !projectId || !agentId) {
|
|
223578
223524
|
return next();
|
|
223579
223525
|
}
|
|
223580
223526
|
const body = c.get("requestBody") || {};
|
|
@@ -223590,7 +223536,7 @@ function contextValidationMiddleware(dbClient) {
|
|
|
223590
223536
|
const validationResult = await validateHeaders({
|
|
223591
223537
|
tenantId,
|
|
223592
223538
|
projectId,
|
|
223593
|
-
|
|
223539
|
+
agentId,
|
|
223594
223540
|
conversationId,
|
|
223595
223541
|
parsedRequest,
|
|
223596
223542
|
dbClient,
|
|
@@ -223600,7 +223546,7 @@ function contextValidationMiddleware(dbClient) {
|
|
|
223600
223546
|
logger10.warn(
|
|
223601
223547
|
{
|
|
223602
223548
|
tenantId,
|
|
223603
|
-
|
|
223549
|
+
agentId,
|
|
223604
223550
|
errors: validationResult.errors
|
|
223605
223551
|
},
|
|
223606
223552
|
"Headers validation failed"
|
|
@@ -223615,7 +223561,7 @@ function contextValidationMiddleware(dbClient) {
|
|
|
223615
223561
|
logger10.debug(
|
|
223616
223562
|
{
|
|
223617
223563
|
tenantId,
|
|
223618
|
-
|
|
223564
|
+
agentId,
|
|
223619
223565
|
contextKeys: Object.keys(validationResult.validatedContext || {})
|
|
223620
223566
|
},
|
|
223621
223567
|
"Request context validation successful"
|
|
@@ -223642,8 +223588,8 @@ var checkGraphQLErrors = (data) => {
|
|
|
223642
223588
|
if (data && typeof data === "object" && "errors" in data) {
|
|
223643
223589
|
const errorObj = data;
|
|
223644
223590
|
if (Array.isArray(errorObj.errors) && errorObj.errors.length > 0) {
|
|
223645
|
-
const
|
|
223646
|
-
const errorMessage = `GraphQL request failed with ${
|
|
223591
|
+
const agentqlErrors = errorObj.errors;
|
|
223592
|
+
const errorMessage = `GraphQL request failed with ${agentqlErrors.length} errors: ${agentqlErrors.map((e) => e.message || "Unknown error").join(", ")}`;
|
|
223647
223593
|
throw new Error(errorMessage);
|
|
223648
223594
|
}
|
|
223649
223595
|
}
|
|
@@ -223988,7 +223934,7 @@ async function determineContextTrigger(tenantId, projectId, conversationId, dbCl
|
|
|
223988
223934
|
}
|
|
223989
223935
|
return "invocation";
|
|
223990
223936
|
}
|
|
223991
|
-
async function handleContextConfigChange(tenantId, projectId, conversationId,
|
|
223937
|
+
async function handleContextConfigChange(tenantId, projectId, conversationId, agentId, newContextConfigId, dbClient, credentialStores) {
|
|
223992
223938
|
const conversation = await getConversation(dbClient)({
|
|
223993
223939
|
scopes: { tenantId, projectId },
|
|
223994
223940
|
conversationId
|
|
@@ -224000,7 +223946,7 @@ async function handleContextConfigChange(tenantId, projectId, conversationId, gr
|
|
|
224000
223946
|
logger12.info(
|
|
224001
223947
|
{
|
|
224002
223948
|
conversationId,
|
|
224003
|
-
|
|
223949
|
+
agentId,
|
|
224004
223950
|
contextConfigId: newContextConfigId
|
|
224005
223951
|
},
|
|
224006
223952
|
"Potential context config change for existing conversation, cache cleared"
|
|
@@ -224010,7 +223956,7 @@ async function handleContextConfigChange(tenantId, projectId, conversationId, gr
|
|
|
224010
223956
|
async function handleContextResolution({
|
|
224011
223957
|
tenantId,
|
|
224012
223958
|
projectId,
|
|
224013
|
-
|
|
223959
|
+
agentId,
|
|
224014
223960
|
conversationId,
|
|
224015
223961
|
headers: headers2,
|
|
224016
223962
|
dbClient,
|
|
@@ -224024,38 +223970,38 @@ async function handleContextResolution({
|
|
|
224024
223970
|
}
|
|
224025
223971
|
},
|
|
224026
223972
|
async (parentSpan) => {
|
|
224027
|
-
let
|
|
223973
|
+
let agent;
|
|
224028
223974
|
let trigger;
|
|
224029
223975
|
try {
|
|
224030
|
-
|
|
224031
|
-
scopes: { tenantId, projectId,
|
|
223976
|
+
agent = await getAgentWithDefaultSubAgent(dbClient)({
|
|
223977
|
+
scopes: { tenantId, projectId, agentId }
|
|
224032
223978
|
});
|
|
224033
|
-
if (!
|
|
224034
|
-
logger12.debug({
|
|
223979
|
+
if (!agent?.contextConfigId) {
|
|
223980
|
+
logger12.debug({ agentId }, "No context config found for agent");
|
|
224035
223981
|
return null;
|
|
224036
223982
|
}
|
|
224037
223983
|
await handleContextConfigChange(
|
|
224038
223984
|
tenantId,
|
|
224039
223985
|
projectId,
|
|
224040
223986
|
conversationId,
|
|
224041
|
-
|
|
224042
|
-
|
|
223987
|
+
agentId,
|
|
223988
|
+
agent.contextConfigId,
|
|
224043
223989
|
dbClient,
|
|
224044
223990
|
credentialStores
|
|
224045
223991
|
);
|
|
224046
223992
|
trigger = await determineContextTrigger(tenantId, projectId, conversationId, dbClient);
|
|
224047
223993
|
const contextConfig2 = await getContextConfigById(dbClient)({
|
|
224048
|
-
scopes: { tenantId, projectId,
|
|
224049
|
-
id:
|
|
223994
|
+
scopes: { tenantId, projectId, agentId },
|
|
223995
|
+
id: agent.contextConfigId
|
|
224050
223996
|
});
|
|
224051
223997
|
if (!contextConfig2) {
|
|
224052
223998
|
logger12.warn(
|
|
224053
|
-
{ contextConfigId:
|
|
223999
|
+
{ contextConfigId: agent.contextConfigId },
|
|
224054
224000
|
"Context config not found, proceeding without context resolution"
|
|
224055
224001
|
);
|
|
224056
224002
|
parentSpan.setStatus({ code: api.SpanStatusCode.ERROR });
|
|
224057
224003
|
parentSpan.addEvent("context.config_not_found", {
|
|
224058
|
-
contextConfigId:
|
|
224004
|
+
contextConfigId: agent.contextConfigId
|
|
224059
224005
|
});
|
|
224060
224006
|
return null;
|
|
224061
224007
|
}
|
|
@@ -224094,7 +224040,7 @@ async function handleContextResolution({
|
|
|
224094
224040
|
logger12.info(
|
|
224095
224041
|
{
|
|
224096
224042
|
conversationId,
|
|
224097
|
-
|
|
224043
|
+
agentId,
|
|
224098
224044
|
contextConfigId: contextConfig2.id,
|
|
224099
224045
|
trigger,
|
|
224100
224046
|
resolvedKeys: Object.keys(resolvedContext),
|
|
@@ -224103,7 +224049,7 @@ async function handleContextResolution({
|
|
|
224103
224049
|
fetchedDefinitions: contextResult.fetchedDefinitions.length,
|
|
224104
224050
|
errors: contextResult.errors.length
|
|
224105
224051
|
},
|
|
224106
|
-
"Context resolution completed (contextConfigId derived from
|
|
224052
|
+
"Context resolution completed (contextConfigId derived from agent)"
|
|
224107
224053
|
);
|
|
224108
224054
|
return resolvedContext;
|
|
224109
224055
|
} catch (error) {
|
|
@@ -224116,7 +224062,7 @@ async function handleContextResolution({
|
|
|
224116
224062
|
logger12.error(
|
|
224117
224063
|
{
|
|
224118
224064
|
error: errorMessage,
|
|
224119
|
-
contextConfigId:
|
|
224065
|
+
contextConfigId: agent?.contextConfigId,
|
|
224120
224066
|
trigger: await determineContextTrigger(
|
|
224121
224067
|
tenantId,
|
|
224122
224068
|
projectId,
|
|
@@ -225038,12 +224984,14 @@ exports.AGGREGATE_OPERATORS = AGGREGATE_OPERATORS;
|
|
|
225038
224984
|
exports.AI_OPERATIONS = AI_OPERATIONS;
|
|
225039
224985
|
exports.AI_TOOL_TYPES = AI_TOOL_TYPES;
|
|
225040
224986
|
exports.ANTHROPIC_MODELS = ANTHROPIC_MODELS;
|
|
225041
|
-
exports.
|
|
225042
|
-
exports.
|
|
225043
|
-
exports.
|
|
225044
|
-
exports.
|
|
225045
|
-
exports.
|
|
225046
|
-
exports.
|
|
224987
|
+
exports.AgentApiInsertSchema = AgentApiInsertSchema;
|
|
224988
|
+
exports.AgentApiSelectSchema = AgentApiSelectSchema;
|
|
224989
|
+
exports.AgentApiUpdateSchema = AgentApiUpdateSchema;
|
|
224990
|
+
exports.AgentInsertSchema = AgentInsertSchema;
|
|
224991
|
+
exports.AgentSelectSchema = AgentSelectSchema;
|
|
224992
|
+
exports.AgentStopWhenSchema = AgentStopWhenSchema;
|
|
224993
|
+
exports.AgentUpdateSchema = AgentUpdateSchema;
|
|
224994
|
+
exports.AgentWithinContextOfProjectSchema = AgentWithinContextOfProjectSchema;
|
|
225047
224995
|
exports.AllAgentSchema = AllAgentSchema;
|
|
225048
224996
|
exports.ApiKeyApiCreationResponseSchema = ApiKeyApiCreationResponseSchema;
|
|
225049
224997
|
exports.ApiKeyApiInsertSchema = ApiKeyApiInsertSchema;
|
|
@@ -225121,8 +225069,7 @@ exports.ExternalSubAgentRelationInsertSchema = ExternalSubAgentRelationInsertSch
|
|
|
225121
225069
|
exports.FIELD_TYPES = FIELD_TYPES;
|
|
225122
225070
|
exports.FetchConfigSchema = FetchConfigSchema;
|
|
225123
225071
|
exports.FetchDefinitionSchema = FetchDefinitionSchema;
|
|
225124
|
-
exports.
|
|
225125
|
-
exports.FullGraphDefinitionSchema = FullGraphDefinitionSchema;
|
|
225072
|
+
exports.FullAgentAgentInsertSchema = FullAgentAgentInsertSchema;
|
|
225126
225073
|
exports.FullProjectDefinitionSchema = FullProjectDefinitionSchema;
|
|
225127
225074
|
exports.FunctionApiInsertSchema = FunctionApiInsertSchema;
|
|
225128
225075
|
exports.FunctionApiSelectSchema = FunctionApiSelectSchema;
|
|
@@ -225138,8 +225085,6 @@ exports.FunctionToolSelectSchema = FunctionToolSelectSchema;
|
|
|
225138
225085
|
exports.FunctionToolUpdateSchema = FunctionToolUpdateSchema;
|
|
225139
225086
|
exports.FunctionUpdateSchema = FunctionUpdateSchema;
|
|
225140
225087
|
exports.GOOGLE_MODELS = GOOGLE_MODELS;
|
|
225141
|
-
exports.GraphStopWhenSchema = GraphStopWhenSchema;
|
|
225142
|
-
exports.GraphWithinContextOfProjectSchema = GraphWithinContextOfProjectSchema;
|
|
225143
225088
|
exports.HTTP_REQUEST_PARTS = HTTP_REQUEST_PARTS;
|
|
225144
225089
|
exports.HeadersScopeSchema = HeadersScopeSchema;
|
|
225145
225090
|
exports.InMemoryCredentialStore = InMemoryCredentialStore;
|
|
@@ -225247,10 +225192,10 @@ exports.TaskUpdateSchema = TaskUpdateSchema;
|
|
|
225247
225192
|
exports.TemplateEngine = TemplateEngine;
|
|
225248
225193
|
exports.TenantIdParamsSchema = TenantIdParamsSchema;
|
|
225249
225194
|
exports.TenantParamsSchema = TenantParamsSchema;
|
|
225250
|
-
exports.
|
|
225251
|
-
exports.
|
|
225252
|
-
exports.
|
|
225253
|
-
exports.
|
|
225195
|
+
exports.TenantProjectAgentIdParamsSchema = TenantProjectAgentIdParamsSchema;
|
|
225196
|
+
exports.TenantProjectAgentParamsSchema = TenantProjectAgentParamsSchema;
|
|
225197
|
+
exports.TenantProjectAgentSubAgentIdParamsSchema = TenantProjectAgentSubAgentIdParamsSchema;
|
|
225198
|
+
exports.TenantProjectAgentSubAgentParamsSchema = TenantProjectAgentSubAgentParamsSchema;
|
|
225254
225199
|
exports.TenantProjectIdParamsSchema = TenantProjectIdParamsSchema;
|
|
225255
225200
|
exports.TenantProjectParamsSchema = TenantProjectParamsSchema;
|
|
225256
225201
|
exports.ToolApiInsertSchema = ToolApiInsertSchema;
|
|
@@ -225269,9 +225214,10 @@ exports.addLedgerArtifacts = addLedgerArtifacts;
|
|
|
225269
225214
|
exports.addToolToAgent = addToolToAgent;
|
|
225270
225215
|
exports.agentFunctionToolRelations = agentFunctionToolRelations;
|
|
225271
225216
|
exports.agentFunctionToolRelationsRelations = agentFunctionToolRelationsRelations;
|
|
225272
|
-
exports.
|
|
225273
|
-
exports.
|
|
225217
|
+
exports.agentHasArtifactComponents = agentHasArtifactComponents;
|
|
225218
|
+
exports.agentRelations = agentRelations;
|
|
225274
225219
|
exports.agentToolRelationsRelations = agentToolRelationsRelations;
|
|
225220
|
+
exports.agents = agents;
|
|
225275
225221
|
exports.apiFetch = apiFetch;
|
|
225276
225222
|
exports.apiKeys = apiKeys;
|
|
225277
225223
|
exports.apiKeysRelations = apiKeysRelations;
|
|
@@ -225306,7 +225252,7 @@ exports.countExternalAgents = countExternalAgents;
|
|
|
225306
225252
|
exports.countLedgerArtifactsByTask = countLedgerArtifactsByTask;
|
|
225307
225253
|
exports.countMessagesByConversation = countMessagesByConversation;
|
|
225308
225254
|
exports.countProjects = countProjects;
|
|
225309
|
-
exports.
|
|
225255
|
+
exports.createAgent = createAgent;
|
|
225310
225256
|
exports.createAgentToolRelation = createAgentToolRelation;
|
|
225311
225257
|
exports.createApiError = createApiError;
|
|
225312
225258
|
exports.createApiKey = createApiKey;
|
|
@@ -225320,7 +225266,7 @@ exports.createDefaultCredentialStores = createDefaultCredentialStores;
|
|
|
225320
225266
|
exports.createExecutionContext = createExecutionContext;
|
|
225321
225267
|
exports.createExternalAgent = createExternalAgent;
|
|
225322
225268
|
exports.createExternalAgentRelation = createExternalAgentRelation;
|
|
225323
|
-
exports.
|
|
225269
|
+
exports.createFullAgentServerSide = createFullAgentServerSide;
|
|
225324
225270
|
exports.createFullProjectServerSide = createFullProjectServerSide;
|
|
225325
225271
|
exports.createFunctionTool = createFunctionTool;
|
|
225326
225272
|
exports.createInMemoryDatabaseClient = createInMemoryDatabaseClient;
|
|
@@ -225339,10 +225285,10 @@ exports.credentialReferencesRelations = credentialReferencesRelations;
|
|
|
225339
225285
|
exports.dataComponents = dataComponents;
|
|
225340
225286
|
exports.dataComponentsRelations = dataComponentsRelations;
|
|
225341
225287
|
exports.dbResultToMcpTool = dbResultToMcpTool;
|
|
225288
|
+
exports.deleteAgent = deleteAgent;
|
|
225342
225289
|
exports.deleteAgentArtifactComponentRelationByAgent = deleteAgentArtifactComponentRelationByAgent;
|
|
225343
225290
|
exports.deleteAgentDataComponentRelationByAgent = deleteAgentDataComponentRelationByAgent;
|
|
225344
|
-
exports.
|
|
225345
|
-
exports.deleteAgentRelationsByGraph = deleteAgentRelationsByGraph;
|
|
225291
|
+
exports.deleteAgentRelationsByAgent = deleteAgentRelationsByAgent;
|
|
225346
225292
|
exports.deleteAgentToolRelation = deleteAgentToolRelation;
|
|
225347
225293
|
exports.deleteAgentToolRelationByAgent = deleteAgentToolRelationByAgent;
|
|
225348
225294
|
exports.deleteApiKey = deleteApiKey;
|
|
@@ -225352,7 +225298,7 @@ exports.deleteConversation = deleteConversation;
|
|
|
225352
225298
|
exports.deleteCredentialReference = deleteCredentialReference;
|
|
225353
225299
|
exports.deleteDataComponent = deleteDataComponent;
|
|
225354
225300
|
exports.deleteExternalAgent = deleteExternalAgent;
|
|
225355
|
-
exports.
|
|
225301
|
+
exports.deleteFullAgent = deleteFullAgent;
|
|
225356
225302
|
exports.deleteFullProject = deleteFullProject;
|
|
225357
225303
|
exports.deleteFunction = deleteFunction;
|
|
225358
225304
|
exports.deleteFunctionTool = deleteFunctionTool;
|
|
@@ -225385,17 +225331,18 @@ exports.generateApiKey = generateApiKey;
|
|
|
225385
225331
|
exports.generateId = generateId;
|
|
225386
225332
|
exports.generateIdFromName = generateIdFromName;
|
|
225387
225333
|
exports.getActiveAgentForConversation = getActiveAgentForConversation;
|
|
225388
|
-
exports.
|
|
225389
|
-
exports.getAgentGraphWithDefaultSubAgent = getAgentGraphWithDefaultSubAgent;
|
|
225334
|
+
exports.getAgentById = getAgentById;
|
|
225390
225335
|
exports.getAgentRelationById = getAgentRelationById;
|
|
225391
225336
|
exports.getAgentRelationByParams = getAgentRelationByParams;
|
|
225392
225337
|
exports.getAgentRelations = getAgentRelations;
|
|
225393
|
-
exports.
|
|
225338
|
+
exports.getAgentRelationsByAgent = getAgentRelationsByAgent;
|
|
225394
225339
|
exports.getAgentRelationsBySource = getAgentRelationsBySource;
|
|
225395
225340
|
exports.getAgentRelationsByTarget = getAgentRelationsByTarget;
|
|
225341
|
+
exports.getAgentSubAgentInfos = getAgentSubAgentInfos;
|
|
225396
225342
|
exports.getAgentToolRelationByAgent = getAgentToolRelationByAgent;
|
|
225397
225343
|
exports.getAgentToolRelationById = getAgentToolRelationById;
|
|
225398
225344
|
exports.getAgentToolRelationByTool = getAgentToolRelationByTool;
|
|
225345
|
+
exports.getAgentWithDefaultSubAgent = getAgentWithDefaultSubAgent;
|
|
225399
225346
|
exports.getAgentsForTool = getAgentsForTool;
|
|
225400
225347
|
exports.getAgentsUsingArtifactComponent = getAgentsUsingArtifactComponent;
|
|
225401
225348
|
exports.getAgentsUsingDataComponent = getAgentsUsingDataComponent;
|
|
@@ -225420,13 +225367,12 @@ exports.getDataComponentsForAgent = getDataComponentsForAgent;
|
|
|
225420
225367
|
exports.getExternalAgent = getExternalAgent;
|
|
225421
225368
|
exports.getExternalAgentByUrl = getExternalAgentByUrl;
|
|
225422
225369
|
exports.getExternalAgentRelations = getExternalAgentRelations;
|
|
225423
|
-
exports.
|
|
225424
|
-
exports.
|
|
225370
|
+
exports.getFullAgent = getFullAgent;
|
|
225371
|
+
exports.getFullAgentDefinition = getFullAgentDefinition;
|
|
225425
225372
|
exports.getFullProject = getFullProject;
|
|
225426
225373
|
exports.getFunction = getFunction;
|
|
225427
225374
|
exports.getFunctionToolById = getFunctionToolById;
|
|
225428
225375
|
exports.getFunctionToolsForSubAgent = getFunctionToolsForSubAgent;
|
|
225429
|
-
exports.getGraphAgentInfos = getGraphAgentInfos;
|
|
225430
225376
|
exports.getLedgerArtifacts = getLedgerArtifacts;
|
|
225431
225377
|
exports.getLedgerArtifactsByContext = getLedgerArtifactsByContext;
|
|
225432
225378
|
exports.getLogger = getLogger;
|
|
@@ -225435,7 +225381,7 @@ exports.getMessagesByConversation = getMessagesByConversation;
|
|
|
225435
225381
|
exports.getMessagesByTask = getMessagesByTask;
|
|
225436
225382
|
exports.getProject = getProject;
|
|
225437
225383
|
exports.getProjectResourceCounts = getProjectResourceCounts;
|
|
225438
|
-
exports.
|
|
225384
|
+
exports.getRelatedAgentsForAgent = getRelatedAgentsForAgent;
|
|
225439
225385
|
exports.getRequestExecutionContext = getRequestExecutionContext;
|
|
225440
225386
|
exports.getSubAgentById = getSubAgentById;
|
|
225441
225387
|
exports.getSubAgentsByIds = getSubAgentsByIds;
|
|
@@ -225444,7 +225390,6 @@ exports.getToolById = getToolById;
|
|
|
225444
225390
|
exports.getToolsForAgent = getToolsForAgent;
|
|
225445
225391
|
exports.getTracer = getTracer;
|
|
225446
225392
|
exports.getVisibleMessages = getVisibleMessages;
|
|
225447
|
-
exports.graphHasArtifactComponents = graphHasArtifactComponents;
|
|
225448
225393
|
exports.handleApiError = handleApiError;
|
|
225449
225394
|
exports.handleContextConfigChange = handleContextConfigChange;
|
|
225450
225395
|
exports.handleContextResolution = handleContextResolution;
|
|
@@ -225465,10 +225410,10 @@ exports.isValidResourceId = isValidResourceId;
|
|
|
225465
225410
|
exports.isZodSchema = isZodSchema;
|
|
225466
225411
|
exports.ledgerArtifacts = ledgerArtifacts;
|
|
225467
225412
|
exports.ledgerArtifactsRelations = ledgerArtifactsRelations;
|
|
225468
|
-
exports.listAgentGraphs = listAgentGraphs;
|
|
225469
|
-
exports.listAgentGraphsPaginated = listAgentGraphsPaginated;
|
|
225470
225413
|
exports.listAgentRelations = listAgentRelations;
|
|
225471
225414
|
exports.listAgentToolRelations = listAgentToolRelations;
|
|
225415
|
+
exports.listAgents = listAgents;
|
|
225416
|
+
exports.listAgentsPaginated = listAgentsPaginated;
|
|
225472
225417
|
exports.listApiKeys = listApiKeys;
|
|
225473
225418
|
exports.listApiKeysPaginated = listApiKeysPaginated;
|
|
225474
225419
|
exports.listArtifactComponents = listArtifactComponents;
|
|
@@ -225526,7 +225471,7 @@ exports.tasks = tasks;
|
|
|
225526
225471
|
exports.tasksRelations = tasksRelations;
|
|
225527
225472
|
exports.tools = tools;
|
|
225528
225473
|
exports.toolsRelations = toolsRelations;
|
|
225529
|
-
exports.
|
|
225474
|
+
exports.updateAgent = updateAgent;
|
|
225530
225475
|
exports.updateAgentRelation = updateAgentRelation;
|
|
225531
225476
|
exports.updateAgentToolRelation = updateAgentToolRelation;
|
|
225532
225477
|
exports.updateApiKey = updateApiKey;
|
|
@@ -225538,7 +225483,7 @@ exports.updateConversationActiveAgent = updateConversationActiveAgent;
|
|
|
225538
225483
|
exports.updateCredentialReference = updateCredentialReference;
|
|
225539
225484
|
exports.updateDataComponent = updateDataComponent;
|
|
225540
225485
|
exports.updateExternalAgent = updateExternalAgent;
|
|
225541
|
-
exports.
|
|
225486
|
+
exports.updateFullAgentServerSide = updateFullAgentServerSide;
|
|
225542
225487
|
exports.updateFullProjectServerSide = updateFullProjectServerSide;
|
|
225543
225488
|
exports.updateFunctionTool = updateFunctionTool;
|
|
225544
225489
|
exports.updateMessage = updateMessage;
|
|
@@ -225547,9 +225492,9 @@ exports.updateSubAgent = updateSubAgent;
|
|
|
225547
225492
|
exports.updateSubAgentFunctionToolRelation = updateSubAgentFunctionToolRelation;
|
|
225548
225493
|
exports.updateTask = updateTask;
|
|
225549
225494
|
exports.updateTool = updateTool;
|
|
225495
|
+
exports.upsertAgent = upsertAgent;
|
|
225550
225496
|
exports.upsertAgentArtifactComponentRelation = upsertAgentArtifactComponentRelation;
|
|
225551
225497
|
exports.upsertAgentDataComponentRelation = upsertAgentDataComponentRelation;
|
|
225552
|
-
exports.upsertAgentGraph = upsertAgentGraph;
|
|
225553
225498
|
exports.upsertAgentRelation = upsertAgentRelation;
|
|
225554
225499
|
exports.upsertArtifactComponent = upsertArtifactComponent;
|
|
225555
225500
|
exports.upsertContextConfig = upsertContextConfig;
|
|
@@ -225565,13 +225510,13 @@ exports.upsertSubAgentToolRelation = upsertSubAgentToolRelation;
|
|
|
225565
225510
|
exports.upsertTool = upsertTool;
|
|
225566
225511
|
exports.validateAgainstJsonSchema = validateAgainstJsonSchema;
|
|
225567
225512
|
exports.validateAgentRelationships = validateAgentRelationships;
|
|
225513
|
+
exports.validateAgentStructure = validateAgentStructure;
|
|
225568
225514
|
exports.validateAndGetApiKey = validateAndGetApiKey;
|
|
225569
|
-
exports.
|
|
225515
|
+
exports.validateAndTypeAgentData = validateAndTypeAgentData;
|
|
225570
225516
|
exports.validateApiKey = validateApiKey;
|
|
225571
225517
|
exports.validateArtifactComponentReferences = validateArtifactComponentReferences;
|
|
225572
225518
|
exports.validateDataComponentReferences = validateDataComponentReferences;
|
|
225573
225519
|
exports.validateExternalAgent = validateExternalAgent;
|
|
225574
|
-
exports.validateGraphStructure = validateGraphStructure;
|
|
225575
225520
|
exports.validateHeaders = validateHeaders;
|
|
225576
225521
|
exports.validateHttpRequestHeaders = validateHttpRequestHeaders;
|
|
225577
225522
|
exports.validateInternalSubAgent = validateInternalSubAgent;
|