@inkeep/agents-core 0.20.1 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4FMDWUE4.js → chunk-QEXLYPVZ.js} +1 -1
- package/dist/{chunk-B6F3RF4T.js → chunk-TNHJH73I.js} +14 -41
- package/dist/{chunk-LZJWVTQ2.js → chunk-TTIPV5QP.js} +11 -0
- package/dist/{chunk-VICWT3WO.js → chunk-XKJPMUGE.js} +1 -1
- package/dist/client-exports.cjs +10 -37
- package/dist/client-exports.js +2 -2
- package/dist/constants/models.cjs +11 -0
- package/dist/constants/models.d.cts +11 -0
- package/dist/constants/models.d.ts +11 -0
- package/dist/constants/models.js +1 -1
- package/dist/db/schema.cjs +13 -40
- package/dist/db/schema.d.cts +1 -1
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.js +1 -1
- package/dist/index.cjs +143 -99
- package/dist/index.d.cts +27 -16
- package/dist/index.d.ts +27 -16
- package/dist/index.js +124 -64
- package/dist/{schema-CcSN2XcZ.d.cts → schema-BjQKqtdC.d.cts} +18 -18
- package/dist/{schema-D8h85qdU.d.ts → schema-DylNIx0j.d.ts} +18 -18
- package/dist/types/index.d.cts +8 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/validation/index.cjs +10 -37
- package/dist/validation/index.js +2 -2
- package/drizzle/0008_mysterious_crusher_hogan.sql +20 -0
- package/drizzle/meta/0008_snapshot.json +2753 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -212899,18 +212899,29 @@ async function apiFetch(url, options = {}) {
|
|
|
212899
212899
|
|
|
212900
212900
|
// src/constants/models.ts
|
|
212901
212901
|
var ANTHROPIC_MODELS = {
|
|
212902
|
+
CLAUDE_OPUS_4_1: "anthropic/claude-opus-4-1",
|
|
212902
212903
|
CLAUDE_OPUS_4_1_20250805: "anthropic/claude-opus-4-1-20250805",
|
|
212904
|
+
CLAUDE_SONNET_4_5: "anthropic/claude-sonnet-4-5",
|
|
212903
212905
|
CLAUDE_SONNET_4_5_20250929: "anthropic/claude-sonnet-4-5-20250929",
|
|
212906
|
+
CLAUDE_SONNET_4: "anthropic/claude-sonnet-4",
|
|
212904
212907
|
CLAUDE_SONNET_4_20250514: "anthropic/claude-sonnet-4-20250514",
|
|
212908
|
+
CLAUDE_3_5_SONNET: "anthropic/claude-3-5-sonnet",
|
|
212905
212909
|
CLAUDE_3_5_SONNET_20241022: "anthropic/claude-3-5-sonnet-20241022",
|
|
212910
|
+
CLAUDE_3_5_HAIKU: "anthropic/claude-3-5-haiku",
|
|
212906
212911
|
CLAUDE_3_5_HAIKU_20241022: "anthropic/claude-3-5-haiku-20241022"
|
|
212907
212912
|
};
|
|
212908
212913
|
var OPENAI_MODELS = {
|
|
212914
|
+
GPT_5: "openai/gpt-5",
|
|
212909
212915
|
GPT_5_20250807: "openai/gpt-5-2025-08-07",
|
|
212916
|
+
GPT_5_MINI: "openai/gpt-5-mini",
|
|
212910
212917
|
GPT_5_MINI_20250807: "openai/gpt-5-mini-2025-08-07",
|
|
212918
|
+
GPT_5_NANO: "openai/gpt-5-nano",
|
|
212911
212919
|
GPT_5_NANO_20250807: "openai/gpt-5-nano-2025-08-07",
|
|
212920
|
+
GPT_4_1: "openai/gpt-4.1",
|
|
212912
212921
|
GPT_4_1_20250414: "openai/gpt-4.1-2025-04-14",
|
|
212922
|
+
GPT_4_1_MINI: "openai/gpt-4.1-mini",
|
|
212913
212923
|
GPT_4_1_MINI_20250414: "openai/gpt-4.1-mini-2025-04-14",
|
|
212924
|
+
GPT_4_1_NANO: "openai/gpt-4.1-nano",
|
|
212914
212925
|
GPT_4_1_NANO_20250414: "openai/gpt-4.1-nano-2025-04-14"
|
|
212915
212926
|
};
|
|
212916
212927
|
var GOOGLE_MODELS = {
|
|
@@ -213422,8 +213433,6 @@ function extractPreviewFields(schema) {
|
|
|
213422
213433
|
// src/db/schema.ts
|
|
213423
213434
|
var schema_exports = {};
|
|
213424
213435
|
__export(schema_exports, {
|
|
213425
|
-
agentFunctionToolRelations: () => agentFunctionToolRelations,
|
|
213426
|
-
agentFunctionToolRelationsRelations: () => agentFunctionToolRelationsRelations,
|
|
213427
213436
|
agentRelations: () => agentRelations,
|
|
213428
213437
|
agentToolRelationsRelations: () => agentToolRelationsRelations,
|
|
213429
213438
|
agents: () => agents,
|
|
@@ -213457,6 +213466,8 @@ __export(schema_exports, {
|
|
|
213457
213466
|
subAgentArtifactComponentsRelations: () => subAgentArtifactComponentsRelations,
|
|
213458
213467
|
subAgentDataComponents: () => subAgentDataComponents,
|
|
213459
213468
|
subAgentDataComponentsRelations: () => subAgentDataComponentsRelations,
|
|
213469
|
+
subAgentFunctionToolRelations: () => subAgentFunctionToolRelations,
|
|
213470
|
+
subAgentFunctionToolRelationsRelations: () => subAgentFunctionToolRelationsRelations,
|
|
213460
213471
|
subAgentRelations: () => subAgentRelations,
|
|
213461
213472
|
subAgentRelationsRelations: () => subAgentRelationsRelations,
|
|
213462
213473
|
subAgentToolRelations: () => subAgentToolRelations,
|
|
@@ -213498,11 +213509,8 @@ var projects = sqliteCore.sqliteTable(
|
|
|
213498
213509
|
{
|
|
213499
213510
|
...tenantScoped,
|
|
213500
213511
|
...uiProperties,
|
|
213501
|
-
// Project-level default model settings that can be inherited by agents
|
|
213502
213512
|
models: sqliteCore.text("models", { mode: "json" }).$type(),
|
|
213503
|
-
// Project-level stopWhen configuration that can be inherited by agents
|
|
213504
213513
|
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
213505
|
-
// Project-level sandbox configuration for function execution
|
|
213506
213514
|
sandboxConfig: sqliteCore.text("sandbox_config", { mode: "json" }).$type(),
|
|
213507
213515
|
...timestamps
|
|
213508
213516
|
},
|
|
@@ -213535,9 +213543,7 @@ var contextConfigs = sqliteCore.sqliteTable(
|
|
|
213535
213543
|
"context_configs",
|
|
213536
213544
|
{
|
|
213537
213545
|
...agentScoped,
|
|
213538
|
-
// Developer-defined Zod schema for validating incoming request context
|
|
213539
213546
|
headersSchema: sqliteCore.blob("headers_schema", { mode: "json" }).$type(),
|
|
213540
|
-
// Object mapping template keys to fetch definitions that use request context data
|
|
213541
213547
|
contextVariables: sqliteCore.blob("context_variables", { mode: "json" }).$type(),
|
|
213542
213548
|
...timestamps
|
|
213543
213549
|
},
|
|
@@ -213554,15 +213560,11 @@ var contextCache = sqliteCore.sqliteTable(
|
|
|
213554
213560
|
"context_cache",
|
|
213555
213561
|
{
|
|
213556
213562
|
...projectScoped,
|
|
213557
|
-
// Always scoped to conversation for complete data isolation
|
|
213558
213563
|
conversationId: sqliteCore.text("conversation_id").notNull(),
|
|
213559
|
-
// Reference to the context config and specific fetch definition
|
|
213560
213564
|
contextConfigId: sqliteCore.text("context_config_id").notNull(),
|
|
213561
213565
|
contextVariableKey: sqliteCore.text("context_variable_key").notNull(),
|
|
213562
213566
|
value: sqliteCore.blob("value", { mode: "json" }).$type().notNull(),
|
|
213563
|
-
// Request hash for cache invalidation based on context changes
|
|
213564
213567
|
requestHash: sqliteCore.text("request_hash"),
|
|
213565
|
-
// Metadata for monitoring and debugging
|
|
213566
213568
|
fetchedAt: sqliteCore.text("fetched_at").notNull(),
|
|
213567
213569
|
fetchSource: sqliteCore.text("fetch_source"),
|
|
213568
213570
|
fetchDurationMs: sqliteCore.integer("fetch_duration_ms"),
|
|
@@ -213609,9 +213611,7 @@ var subAgentRelations = sqliteCore.sqliteTable(
|
|
|
213609
213611
|
{
|
|
213610
213612
|
...agentScoped,
|
|
213611
213613
|
sourceSubAgentId: sqliteCore.text("source_sub_agent_id").notNull(),
|
|
213612
|
-
// For internal relationships
|
|
213613
213614
|
targetSubAgentId: sqliteCore.text("target_sub_agent_id"),
|
|
213614
|
-
// For external relationships
|
|
213615
213615
|
externalSubAgentId: sqliteCore.text("external_sub_agent_id"),
|
|
213616
213616
|
relationType: sqliteCore.text("relation_type"),
|
|
213617
213617
|
...timestamps
|
|
@@ -213780,9 +213780,7 @@ var tools = sqliteCore.sqliteTable(
|
|
|
213780
213780
|
config: sqliteCore.blob("config", { mode: "json" }).$type().notNull(),
|
|
213781
213781
|
credentialReferenceId: sqliteCore.text("credential_reference_id"),
|
|
213782
213782
|
headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
|
|
213783
|
-
// Image URL for custom tool icon (supports regular URLs and base64 encoded images)
|
|
213784
213783
|
imageUrl: sqliteCore.text("image_url"),
|
|
213785
|
-
// Server capabilities and status (only for MCP tools)
|
|
213786
213784
|
capabilities: sqliteCore.blob("capabilities", { mode: "json" }).$type(),
|
|
213787
213785
|
lastError: sqliteCore.text("last_error"),
|
|
213788
213786
|
...timestamps
|
|
@@ -213812,7 +213810,6 @@ var functionTools = sqliteCore.sqliteTable(
|
|
|
213812
213810
|
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
213813
213811
|
name: "function_tools_agent_fk"
|
|
213814
213812
|
}).onDelete("cascade"),
|
|
213815
|
-
// Foreign key constraint to functions table
|
|
213816
213813
|
sqliteCore.foreignKey({
|
|
213817
213814
|
columns: [table.tenantId, table.projectId, table.functionId],
|
|
213818
213815
|
foreignColumns: [functions.tenantId, functions.projectId, functions.id],
|
|
@@ -213861,8 +213858,8 @@ var subAgentToolRelations = sqliteCore.sqliteTable(
|
|
|
213861
213858
|
}).onDelete("cascade")
|
|
213862
213859
|
]
|
|
213863
213860
|
);
|
|
213864
|
-
var
|
|
213865
|
-
"
|
|
213861
|
+
var subAgentFunctionToolRelations = sqliteCore.sqliteTable(
|
|
213862
|
+
"sub_agent_function_tool_relations",
|
|
213866
213863
|
{
|
|
213867
213864
|
...subAgentScoped,
|
|
213868
213865
|
functionToolId: sqliteCore.text("function_tool_id").notNull(),
|
|
@@ -213870,13 +213867,11 @@ var agentFunctionToolRelations = sqliteCore.sqliteTable(
|
|
|
213870
213867
|
},
|
|
213871
213868
|
(table) => [
|
|
213872
213869
|
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
213873
|
-
// Foreign key constraint to agents table
|
|
213874
213870
|
sqliteCore.foreignKey({
|
|
213875
213871
|
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
213876
213872
|
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
213877
|
-
name: "
|
|
213873
|
+
name: "sub_agent_function_tool_relations_sub_agent_fk"
|
|
213878
213874
|
}).onDelete("cascade"),
|
|
213879
|
-
// Foreign key constraint to functionTools table
|
|
213880
213875
|
sqliteCore.foreignKey({
|
|
213881
213876
|
columns: [table.tenantId, table.projectId, table.agentId, table.functionToolId],
|
|
213882
213877
|
foreignColumns: [
|
|
@@ -213885,7 +213880,7 @@ var agentFunctionToolRelations = sqliteCore.sqliteTable(
|
|
|
213885
213880
|
functionTools.agentId,
|
|
213886
213881
|
functionTools.id
|
|
213887
213882
|
],
|
|
213888
|
-
name: "
|
|
213883
|
+
name: "sub_agent_function_tool_relations_function_tool_fk"
|
|
213889
213884
|
}).onDelete("cascade")
|
|
213890
213885
|
]
|
|
213891
213886
|
);
|
|
@@ -213914,26 +213909,18 @@ var messages = sqliteCore.sqliteTable(
|
|
|
213914
213909
|
{
|
|
213915
213910
|
...projectScoped,
|
|
213916
213911
|
conversationId: sqliteCore.text("conversation_id").notNull(),
|
|
213917
|
-
// Role mapping: user, agent, system (unified for both formats)
|
|
213918
213912
|
role: sqliteCore.text("role").notNull(),
|
|
213919
|
-
// Agent sender/recipient tracking (nullable - only populated when relevant)
|
|
213920
213913
|
fromSubAgentId: sqliteCore.text("from_sub_agent_id"),
|
|
213921
213914
|
toSubAgentId: sqliteCore.text("to_sub_agent_id"),
|
|
213922
|
-
// External agent sender tracking
|
|
213923
213915
|
fromExternalAgentId: sqliteCore.text("from_external_sub_agent_id"),
|
|
213924
|
-
// External agent recipient tracking
|
|
213925
213916
|
toExternalAgentId: sqliteCore.text("to_external_sub_agent_id"),
|
|
213926
|
-
// Message content stored as JSON to support both formats
|
|
213927
213917
|
content: sqliteCore.blob("content", { mode: "json" }).$type().notNull(),
|
|
213928
|
-
// Message classification and filtering
|
|
213929
213918
|
visibility: sqliteCore.text("visibility").notNull().default("user-facing"),
|
|
213930
213919
|
messageType: sqliteCore.text("message_type").notNull().default("chat"),
|
|
213931
213920
|
taskId: sqliteCore.text("task_id"),
|
|
213932
213921
|
parentMessageId: sqliteCore.text("parent_message_id"),
|
|
213933
|
-
// A2A specific fields
|
|
213934
213922
|
a2aTaskId: sqliteCore.text("a2a_task_id"),
|
|
213935
213923
|
a2aSessionId: sqliteCore.text("a2a_session_id"),
|
|
213936
|
-
// Metadata for extensions
|
|
213937
213924
|
metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
|
|
213938
213925
|
...timestamps
|
|
213939
213926
|
},
|
|
@@ -213950,17 +213937,14 @@ var ledgerArtifacts = sqliteCore.sqliteTable(
|
|
|
213950
213937
|
"ledger_artifacts",
|
|
213951
213938
|
{
|
|
213952
213939
|
...projectScoped,
|
|
213953
|
-
// Links
|
|
213954
213940
|
taskId: sqliteCore.text("task_id").notNull(),
|
|
213955
213941
|
toolCallId: sqliteCore.text("tool_call_id"),
|
|
213956
213942
|
contextId: sqliteCore.text("context_id").notNull(),
|
|
213957
|
-
// Core Artifact fields
|
|
213958
213943
|
type: sqliteCore.text("type").notNull().default("source"),
|
|
213959
213944
|
name: sqliteCore.text("name"),
|
|
213960
213945
|
description: sqliteCore.text("description"),
|
|
213961
213946
|
parts: sqliteCore.blob("parts", { mode: "json" }).$type(),
|
|
213962
213947
|
metadata: sqliteCore.blob("metadata", { mode: "json" }).$type(),
|
|
213963
|
-
// Extra ledger information (not part of the Artifact spec – kept optional)
|
|
213964
213948
|
summary: sqliteCore.text("summary"),
|
|
213965
213949
|
mime: sqliteCore.blob("mime", { mode: "json" }).$type(),
|
|
213966
213950
|
visibility: sqliteCore.text("visibility").default("context"),
|
|
@@ -214111,7 +214095,7 @@ var subAgentsRelations = drizzleOrm.relations(subAgents, ({ many, one }) => ({
|
|
|
214111
214095
|
relationName: "receivedMessages"
|
|
214112
214096
|
}),
|
|
214113
214097
|
toolRelations: many(subAgentToolRelations),
|
|
214114
|
-
functionToolRelations: many(
|
|
214098
|
+
functionToolRelations: many(subAgentFunctionToolRelations),
|
|
214115
214099
|
dataComponentRelations: many(subAgentDataComponents),
|
|
214116
214100
|
artifactComponentRelations: many(subAgentArtifactComponents)
|
|
214117
214101
|
}));
|
|
@@ -214316,17 +214300,17 @@ var functionToolsRelations = drizzleOrm.relations(functionTools, ({ one, many })
|
|
|
214316
214300
|
fields: [functionTools.tenantId, functionTools.projectId, functionTools.functionId],
|
|
214317
214301
|
references: [functions.tenantId, functions.projectId, functions.id]
|
|
214318
214302
|
}),
|
|
214319
|
-
|
|
214303
|
+
subAgentRelations: many(subAgentFunctionToolRelations)
|
|
214320
214304
|
}));
|
|
214321
|
-
var
|
|
214322
|
-
|
|
214305
|
+
var subAgentFunctionToolRelationsRelations = drizzleOrm.relations(
|
|
214306
|
+
subAgentFunctionToolRelations,
|
|
214323
214307
|
({ one }) => ({
|
|
214324
|
-
|
|
214325
|
-
fields: [
|
|
214308
|
+
subAgent: one(subAgents, {
|
|
214309
|
+
fields: [subAgentFunctionToolRelations.subAgentId],
|
|
214326
214310
|
references: [subAgents.id]
|
|
214327
214311
|
}),
|
|
214328
214312
|
functionTool: one(functionTools, {
|
|
214329
|
-
fields: [
|
|
214313
|
+
fields: [subAgentFunctionToolRelations.functionToolId],
|
|
214330
214314
|
references: [functionTools.id]
|
|
214331
214315
|
})
|
|
214332
214316
|
})
|
|
@@ -215709,7 +215693,6 @@ var CredentialStuffer = class {
|
|
|
215709
215693
|
if (mcpType === MCPServerType.nango) {
|
|
215710
215694
|
return {
|
|
215711
215695
|
headers: {
|
|
215712
|
-
// For Nango MCP, authenticate with the Nango secret key
|
|
215713
215696
|
Authorization: `Bearer ${nangoCredentialData.secretKey}`,
|
|
215714
215697
|
"provider-config-key": nangoCredentialData.providerConfigKey,
|
|
215715
215698
|
"connection-id": nangoCredentialData.connectionId
|
|
@@ -216403,12 +216386,12 @@ var getFunctionToolsForSubAgent = (db) => {
|
|
|
216403
216386
|
scopes: { tenantId, projectId, agentId },
|
|
216404
216387
|
pagination: { page: 1, limit: 1e3 }
|
|
216405
216388
|
});
|
|
216406
|
-
const relations2 = await db.select().from(
|
|
216389
|
+
const relations2 = await db.select().from(subAgentFunctionToolRelations).where(
|
|
216407
216390
|
drizzleOrm.and(
|
|
216408
|
-
drizzleOrm.eq(
|
|
216409
|
-
drizzleOrm.eq(
|
|
216410
|
-
drizzleOrm.eq(
|
|
216411
|
-
drizzleOrm.eq(
|
|
216391
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, tenantId),
|
|
216392
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.projectId, projectId),
|
|
216393
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.agentId, agentId),
|
|
216394
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.subAgentId, subAgentId)
|
|
216412
216395
|
)
|
|
216413
216396
|
);
|
|
216414
216397
|
const relatedFunctionToolIds = new Set(relations2.map((r) => r.functionToolId));
|
|
@@ -216429,17 +216412,43 @@ var getFunctionToolsForSubAgent = (db) => {
|
|
|
216429
216412
|
};
|
|
216430
216413
|
};
|
|
216431
216414
|
var upsertSubAgentFunctionToolRelation = (db) => async (params) => {
|
|
216432
|
-
|
|
216415
|
+
const { scopes, subAgentId, functionToolId, relationId } = params;
|
|
216416
|
+
const { tenantId, projectId, agentId } = scopes;
|
|
216417
|
+
if (relationId) {
|
|
216433
216418
|
return await updateSubAgentFunctionToolRelation(db)({
|
|
216434
|
-
scopes
|
|
216435
|
-
relationId
|
|
216419
|
+
scopes,
|
|
216420
|
+
relationId,
|
|
216436
216421
|
data: {
|
|
216437
|
-
subAgentId
|
|
216438
|
-
functionToolId
|
|
216422
|
+
subAgentId,
|
|
216423
|
+
functionToolId
|
|
216439
216424
|
}
|
|
216440
216425
|
});
|
|
216441
216426
|
}
|
|
216442
|
-
|
|
216427
|
+
try {
|
|
216428
|
+
const existingRelations = await db.select().from(subAgentFunctionToolRelations).where(
|
|
216429
|
+
drizzleOrm.and(
|
|
216430
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, tenantId),
|
|
216431
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.projectId, projectId),
|
|
216432
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.agentId, agentId),
|
|
216433
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.subAgentId, subAgentId),
|
|
216434
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.functionToolId, functionToolId)
|
|
216435
|
+
)
|
|
216436
|
+
).limit(1);
|
|
216437
|
+
if (existingRelations.length > 0) {
|
|
216438
|
+
logger4.info(
|
|
216439
|
+
{ tenantId, projectId, agentId, subAgentId, functionToolId, relationId: existingRelations[0].id },
|
|
216440
|
+
"Sub_agent-function tool relation already exists, returning existing relation"
|
|
216441
|
+
);
|
|
216442
|
+
return { id: existingRelations[0].id };
|
|
216443
|
+
}
|
|
216444
|
+
return await addFunctionToolToSubAgent(db)(params);
|
|
216445
|
+
} catch (error) {
|
|
216446
|
+
logger4.error(
|
|
216447
|
+
{ tenantId, projectId, agentId, subAgentId, functionToolId, error },
|
|
216448
|
+
"Failed to upsert sub_agent-function tool relation"
|
|
216449
|
+
);
|
|
216450
|
+
throw error;
|
|
216451
|
+
}
|
|
216443
216452
|
};
|
|
216444
216453
|
var addFunctionToolToSubAgent = (db) => {
|
|
216445
216454
|
return async (params) => {
|
|
@@ -216447,7 +216456,7 @@ var addFunctionToolToSubAgent = (db) => {
|
|
|
216447
216456
|
const { tenantId, projectId, agentId } = scopes;
|
|
216448
216457
|
try {
|
|
216449
216458
|
const relationId = nanoid.nanoid();
|
|
216450
|
-
await db.insert(
|
|
216459
|
+
await db.insert(subAgentFunctionToolRelations).values({
|
|
216451
216460
|
id: relationId,
|
|
216452
216461
|
tenantId,
|
|
216453
216462
|
projectId,
|
|
@@ -216457,7 +216466,7 @@ var addFunctionToolToSubAgent = (db) => {
|
|
|
216457
216466
|
});
|
|
216458
216467
|
logger4.info(
|
|
216459
216468
|
{ tenantId, projectId, agentId, subAgentId, functionToolId, relationId },
|
|
216460
|
-
"Function tool added to
|
|
216469
|
+
"Function tool added to sub_agent"
|
|
216461
216470
|
);
|
|
216462
216471
|
return { id: relationId };
|
|
216463
216472
|
} catch (error) {
|
|
@@ -216474,20 +216483,20 @@ var updateSubAgentFunctionToolRelation = (db) => {
|
|
|
216474
216483
|
const { scopes, relationId, data } = params;
|
|
216475
216484
|
const { tenantId, projectId, agentId } = scopes;
|
|
216476
216485
|
try {
|
|
216477
|
-
await db.update(
|
|
216486
|
+
await db.update(subAgentFunctionToolRelations).set({
|
|
216478
216487
|
subAgentId: data.subAgentId,
|
|
216479
216488
|
functionToolId: data.functionToolId
|
|
216480
216489
|
}).where(
|
|
216481
216490
|
drizzleOrm.and(
|
|
216482
|
-
drizzleOrm.eq(
|
|
216483
|
-
drizzleOrm.eq(
|
|
216484
|
-
drizzleOrm.eq(
|
|
216485
|
-
drizzleOrm.eq(
|
|
216491
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.id, relationId),
|
|
216492
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, tenantId),
|
|
216493
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.projectId, projectId),
|
|
216494
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.agentId, agentId)
|
|
216486
216495
|
)
|
|
216487
216496
|
);
|
|
216488
216497
|
logger4.info(
|
|
216489
216498
|
{ tenantId, projectId, agentId, relationId, data },
|
|
216490
|
-
"
|
|
216499
|
+
"SubAgent-function tool relation updated"
|
|
216491
216500
|
);
|
|
216492
216501
|
return { id: relationId };
|
|
216493
216502
|
} catch (error) {
|
|
@@ -216566,7 +216575,7 @@ var getAgentRelationsBySource = (db) => async (params) => {
|
|
|
216566
216575
|
pagination: { page, limit, total, pages }
|
|
216567
216576
|
};
|
|
216568
216577
|
};
|
|
216569
|
-
var
|
|
216578
|
+
var getSubAgentRelationsByTarget = (db) => async (params) => {
|
|
216570
216579
|
const page = params.pagination?.page || 1;
|
|
216571
216580
|
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
216572
216581
|
const offset = (page - 1) * limit;
|
|
@@ -216694,7 +216703,7 @@ var getAgentRelationByParams = (db) => async (params) => {
|
|
|
216694
216703
|
where: drizzleOrm.and(...whereConditions)
|
|
216695
216704
|
});
|
|
216696
216705
|
};
|
|
216697
|
-
var
|
|
216706
|
+
var upsertSubAgentRelation = (db) => async (params) => {
|
|
216698
216707
|
const existing = await getAgentRelationByParams(db)({
|
|
216699
216708
|
scopes: { tenantId: params.tenantId, projectId: params.projectId, agentId: params.agentId },
|
|
216700
216709
|
sourceSubAgentId: params.sourceSubAgentId,
|
|
@@ -217420,7 +217429,6 @@ function createApiError({
|
|
|
217420
217429
|
const status = errorCodeToHttpStatus[code];
|
|
217421
217430
|
const title = getTitleFromCode(code);
|
|
217422
217431
|
const problemDetails = {
|
|
217423
|
-
// type,
|
|
217424
217432
|
title,
|
|
217425
217433
|
status,
|
|
217426
217434
|
detail: message,
|
|
@@ -218531,21 +218539,21 @@ var getFullAgentDefinition = (db) => async ({
|
|
|
218531
218539
|
tenantId: functionTools.tenantId,
|
|
218532
218540
|
projectId: functionTools.projectId,
|
|
218533
218541
|
agentId: functionTools.agentId,
|
|
218534
|
-
agentToolRelationId:
|
|
218535
|
-
}).from(
|
|
218542
|
+
agentToolRelationId: subAgentFunctionToolRelations.id
|
|
218543
|
+
}).from(subAgentFunctionToolRelations).innerJoin(
|
|
218536
218544
|
functionTools,
|
|
218537
218545
|
drizzleOrm.and(
|
|
218538
|
-
drizzleOrm.eq(
|
|
218539
|
-
drizzleOrm.eq(
|
|
218540
|
-
drizzleOrm.eq(
|
|
218541
|
-
drizzleOrm.eq(
|
|
218546
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.functionToolId, functionTools.id),
|
|
218547
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, functionTools.tenantId),
|
|
218548
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.projectId, functionTools.projectId),
|
|
218549
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.agentId, functionTools.agentId)
|
|
218542
218550
|
)
|
|
218543
218551
|
).where(
|
|
218544
218552
|
drizzleOrm.and(
|
|
218545
|
-
drizzleOrm.eq(
|
|
218546
|
-
drizzleOrm.eq(
|
|
218547
|
-
drizzleOrm.eq(
|
|
218548
|
-
drizzleOrm.eq(
|
|
218553
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.tenantId, tenantId),
|
|
218554
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.projectId, projectId),
|
|
218555
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.agentId, agentId),
|
|
218556
|
+
drizzleOrm.eq(subAgentFunctionToolRelations.subAgentId, agent2.id)
|
|
218549
218557
|
)
|
|
218550
218558
|
);
|
|
218551
218559
|
const agentDataComponentRelations = await db.query.subAgentDataComponents.findMany({
|
|
@@ -220487,18 +220495,18 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220487
220495
|
}
|
|
220488
220496
|
await Promise.all(agentArtifactComponentPromises);
|
|
220489
220497
|
logger14.info({}, "All agent-artifact component relations created");
|
|
220490
|
-
const
|
|
220498
|
+
const subAgentRelationPromises = [];
|
|
220491
220499
|
for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
|
|
220492
220500
|
if (isInternalAgent(agentData2) && agentData2.canTransferTo) {
|
|
220493
220501
|
for (const targetSubAgentId of agentData2.canTransferTo) {
|
|
220494
|
-
|
|
220502
|
+
subAgentRelationPromises.push(
|
|
220495
220503
|
(async () => {
|
|
220496
220504
|
try {
|
|
220497
220505
|
logger14.info(
|
|
220498
220506
|
{ subAgentId, targetSubAgentId, type: "transfer" },
|
|
220499
220507
|
"Processing agent transfer relation"
|
|
220500
220508
|
);
|
|
220501
|
-
await
|
|
220509
|
+
await upsertSubAgentRelation(db)({
|
|
220502
220510
|
id: nanoid.nanoid(),
|
|
220503
220511
|
tenantId,
|
|
220504
220512
|
projectId,
|
|
@@ -220525,14 +220533,14 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220525
220533
|
for (const targetSubAgentId of agentData2.canDelegateTo) {
|
|
220526
220534
|
const targetAgentData = typed.subAgents[targetSubAgentId];
|
|
220527
220535
|
const isTargetExternal = isExternalAgent(targetAgentData);
|
|
220528
|
-
|
|
220536
|
+
subAgentRelationPromises.push(
|
|
220529
220537
|
(async () => {
|
|
220530
220538
|
try {
|
|
220531
220539
|
logger14.info(
|
|
220532
220540
|
{ subAgentId, targetSubAgentId, type: "delegate" },
|
|
220533
220541
|
"Processing agent delegation relation"
|
|
220534
220542
|
);
|
|
220535
|
-
await
|
|
220543
|
+
await upsertSubAgentRelation(db)({
|
|
220536
220544
|
id: nanoid.nanoid(),
|
|
220537
220545
|
tenantId,
|
|
220538
220546
|
projectId,
|
|
@@ -220557,10 +220565,10 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220557
220565
|
}
|
|
220558
220566
|
}
|
|
220559
220567
|
}
|
|
220560
|
-
await Promise.all(
|
|
220568
|
+
await Promise.all(subAgentRelationPromises);
|
|
220561
220569
|
logger14.info(
|
|
220562
|
-
{
|
|
220563
|
-
"All agent relations created"
|
|
220570
|
+
{ subAgentRelationCount: subAgentRelationPromises.length },
|
|
220571
|
+
"All sub-agent relations created"
|
|
220564
220572
|
);
|
|
220565
220573
|
const createdAgent = await getFullAgentDefinition(db)({
|
|
220566
220574
|
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
@@ -221343,10 +221351,8 @@ function determineMimeTypes(artifact) {
|
|
|
221343
221351
|
function sanitizeArtifactForDatabase(artifact) {
|
|
221344
221352
|
return {
|
|
221345
221353
|
...artifact,
|
|
221346
|
-
// Ensure text fields don't exceed reasonable limits
|
|
221347
221354
|
name: artifact.name?.slice(0, 255) || void 0,
|
|
221348
221355
|
description: artifact.description?.slice(0, 1e3) || void 0,
|
|
221349
|
-
// Clean any undefined values from JSON fields
|
|
221350
221356
|
parts: artifact.parts ? JSON.parse(JSON.stringify(artifact.parts)) : null,
|
|
221351
221357
|
metadata: artifact.metadata ? JSON.parse(JSON.stringify(artifact.metadata)) : null
|
|
221352
221358
|
};
|
|
@@ -221453,7 +221459,6 @@ var addLedgerArtifacts = (db) => async (params) => {
|
|
|
221453
221459
|
description: sanitizedArt.description,
|
|
221454
221460
|
parts: sanitizedArt.parts,
|
|
221455
221461
|
metadata: sanitizedArt.metadata,
|
|
221456
|
-
// extra (optional) ledger fields
|
|
221457
221462
|
summary: sanitizedArt.description?.slice(0, 200) ?? null,
|
|
221458
221463
|
mime: determineMimeTypes(sanitizedArt),
|
|
221459
221464
|
// Simple string fallback until we debug the issue
|
|
@@ -222543,8 +222548,6 @@ var getFullProject = (db, logger14 = defaultLogger2) => async (params) => {
|
|
|
222543
222548
|
imageUrl: tool2.imageUrl || void 0,
|
|
222544
222549
|
capabilities: tool2.capabilities || void 0,
|
|
222545
222550
|
lastError: tool2.lastError || void 0
|
|
222546
|
-
// Don't include runtime fields in configuration
|
|
222547
|
-
// status, lastHealthCheck, availableTools, activeTools, lastToolsSync are all runtime
|
|
222548
222551
|
};
|
|
222549
222552
|
}
|
|
222550
222553
|
logger14.info(
|
|
@@ -224401,6 +224404,21 @@ var KeyChainStore = class {
|
|
|
224401
224404
|
const credential = await this.get(key);
|
|
224402
224405
|
return credential !== null;
|
|
224403
224406
|
}
|
|
224407
|
+
/**
|
|
224408
|
+
* Check if the credential store is available and functional
|
|
224409
|
+
*/
|
|
224410
|
+
async checkAvailability() {
|
|
224411
|
+
await this.initializationPromise;
|
|
224412
|
+
if (!this.keytarAvailable || !this.keytar) {
|
|
224413
|
+
return {
|
|
224414
|
+
available: false,
|
|
224415
|
+
reason: "Keytar not available - cannot store credentials in system keychain"
|
|
224416
|
+
};
|
|
224417
|
+
}
|
|
224418
|
+
return {
|
|
224419
|
+
available: true
|
|
224420
|
+
};
|
|
224421
|
+
}
|
|
224404
224422
|
/**
|
|
224405
224423
|
* Delete a credential from the keychain
|
|
224406
224424
|
*/
|
|
@@ -224542,6 +224560,14 @@ var InMemoryCredentialStore = class {
|
|
|
224542
224560
|
async delete(key) {
|
|
224543
224561
|
return this.credentials.delete(key);
|
|
224544
224562
|
}
|
|
224563
|
+
/**
|
|
224564
|
+
* Check if the credential store is available and functional
|
|
224565
|
+
*/
|
|
224566
|
+
async checkAvailability() {
|
|
224567
|
+
return {
|
|
224568
|
+
available: true
|
|
224569
|
+
};
|
|
224570
|
+
}
|
|
224545
224571
|
};
|
|
224546
224572
|
var logger13 = getLogger("nango-credential-store");
|
|
224547
224573
|
var CredentialKeySchema = zod.z.object({
|
|
@@ -224956,6 +224982,26 @@ var NangoCredentialStore = class {
|
|
|
224956
224982
|
return false;
|
|
224957
224983
|
}
|
|
224958
224984
|
}
|
|
224985
|
+
/**
|
|
224986
|
+
* Check if the credential store is available and functional
|
|
224987
|
+
*/
|
|
224988
|
+
async checkAvailability() {
|
|
224989
|
+
if (!this.nangoConfig.secretKey) {
|
|
224990
|
+
return {
|
|
224991
|
+
available: false,
|
|
224992
|
+
reason: "Nango secret key not configured"
|
|
224993
|
+
};
|
|
224994
|
+
}
|
|
224995
|
+
if (this.nangoConfig.secretKey.includes("mock") || this.nangoConfig.secretKey === "your_nango_secret_key") {
|
|
224996
|
+
return {
|
|
224997
|
+
available: false,
|
|
224998
|
+
reason: "Nango secret key appears to be a placeholder or mock value"
|
|
224999
|
+
};
|
|
225000
|
+
}
|
|
225001
|
+
return {
|
|
225002
|
+
available: true
|
|
225003
|
+
};
|
|
225004
|
+
}
|
|
224959
225005
|
};
|
|
224960
225006
|
function createNangoCredentialStore(id, config) {
|
|
224961
225007
|
const nangoSecretKey = config?.secretKey || process.env.NANGO_SECRET_KEY;
|
|
@@ -224983,15 +225029,13 @@ function createDefaultCredentialStores() {
|
|
|
224983
225029
|
})
|
|
224984
225030
|
);
|
|
224985
225031
|
}
|
|
224986
|
-
|
|
224987
|
-
|
|
224988
|
-
|
|
224989
|
-
|
|
224990
|
-
|
|
224991
|
-
|
|
224992
|
-
|
|
224993
|
-
);
|
|
224994
|
-
}
|
|
225032
|
+
try {
|
|
225033
|
+
stores.push(createKeyChainStore("keychain-default"));
|
|
225034
|
+
} catch (error) {
|
|
225035
|
+
console.warn(
|
|
225036
|
+
"Failed to create keychain store:",
|
|
225037
|
+
error instanceof Error ? error.message : error
|
|
225038
|
+
);
|
|
224995
225039
|
}
|
|
224996
225040
|
return stores;
|
|
224997
225041
|
}
|
|
@@ -225390,8 +225434,6 @@ exports.VALID_RELATION_TYPES = VALID_RELATION_TYPES;
|
|
|
225390
225434
|
exports.addFunctionToolToSubAgent = addFunctionToolToSubAgent;
|
|
225391
225435
|
exports.addLedgerArtifacts = addLedgerArtifacts;
|
|
225392
225436
|
exports.addToolToAgent = addToolToAgent;
|
|
225393
|
-
exports.agentFunctionToolRelations = agentFunctionToolRelations;
|
|
225394
|
-
exports.agentFunctionToolRelationsRelations = agentFunctionToolRelationsRelations;
|
|
225395
225437
|
exports.agentHasArtifactComponents = agentHasArtifactComponents;
|
|
225396
225438
|
exports.agentRelations = agentRelations;
|
|
225397
225439
|
exports.agentToolRelationsRelations = agentToolRelationsRelations;
|
|
@@ -225515,7 +225557,6 @@ exports.getAgentRelationByParams = getAgentRelationByParams;
|
|
|
225515
225557
|
exports.getAgentRelations = getAgentRelations;
|
|
225516
225558
|
exports.getAgentRelationsByAgent = getAgentRelationsByAgent;
|
|
225517
225559
|
exports.getAgentRelationsBySource = getAgentRelationsBySource;
|
|
225518
|
-
exports.getAgentRelationsByTarget = getAgentRelationsByTarget;
|
|
225519
225560
|
exports.getAgentSubAgentInfos = getAgentSubAgentInfos;
|
|
225520
225561
|
exports.getAgentToolRelationByAgent = getAgentToolRelationByAgent;
|
|
225521
225562
|
exports.getAgentToolRelationById = getAgentToolRelationById;
|
|
@@ -225562,6 +225603,7 @@ exports.getProjectResourceCounts = getProjectResourceCounts;
|
|
|
225562
225603
|
exports.getRelatedAgentsForAgent = getRelatedAgentsForAgent;
|
|
225563
225604
|
exports.getRequestExecutionContext = getRequestExecutionContext;
|
|
225564
225605
|
exports.getSubAgentById = getSubAgentById;
|
|
225606
|
+
exports.getSubAgentRelationsByTarget = getSubAgentRelationsByTarget;
|
|
225565
225607
|
exports.getSubAgentsByIds = getSubAgentsByIds;
|
|
225566
225608
|
exports.getTask = getTask;
|
|
225567
225609
|
exports.getToolById = getToolById;
|
|
@@ -225638,6 +225680,8 @@ exports.subAgentArtifactComponents = subAgentArtifactComponents;
|
|
|
225638
225680
|
exports.subAgentArtifactComponentsRelations = subAgentArtifactComponentsRelations;
|
|
225639
225681
|
exports.subAgentDataComponents = subAgentDataComponents;
|
|
225640
225682
|
exports.subAgentDataComponentsRelations = subAgentDataComponentsRelations;
|
|
225683
|
+
exports.subAgentFunctionToolRelations = subAgentFunctionToolRelations;
|
|
225684
|
+
exports.subAgentFunctionToolRelationsRelations = subAgentFunctionToolRelationsRelations;
|
|
225641
225685
|
exports.subAgentRelations = subAgentRelations;
|
|
225642
225686
|
exports.subAgentRelationsRelations = subAgentRelationsRelations;
|
|
225643
225687
|
exports.subAgentToolRelations = subAgentToolRelations;
|
|
@@ -225673,7 +225717,6 @@ exports.updateTool = updateTool;
|
|
|
225673
225717
|
exports.upsertAgent = upsertAgent;
|
|
225674
225718
|
exports.upsertAgentArtifactComponentRelation = upsertAgentArtifactComponentRelation;
|
|
225675
225719
|
exports.upsertAgentDataComponentRelation = upsertAgentDataComponentRelation;
|
|
225676
|
-
exports.upsertAgentRelation = upsertAgentRelation;
|
|
225677
225720
|
exports.upsertArtifactComponent = upsertArtifactComponent;
|
|
225678
225721
|
exports.upsertContextConfig = upsertContextConfig;
|
|
225679
225722
|
exports.upsertCredentialReference = upsertCredentialReference;
|
|
@@ -225684,6 +225727,7 @@ exports.upsertFunctionTool = upsertFunctionTool;
|
|
|
225684
225727
|
exports.upsertLedgerArtifact = upsertLedgerArtifact;
|
|
225685
225728
|
exports.upsertSubAgent = upsertSubAgent;
|
|
225686
225729
|
exports.upsertSubAgentFunctionToolRelation = upsertSubAgentFunctionToolRelation;
|
|
225730
|
+
exports.upsertSubAgentRelation = upsertSubAgentRelation;
|
|
225687
225731
|
exports.upsertSubAgentToolRelation = upsertSubAgentToolRelation;
|
|
225688
225732
|
exports.upsertTool = upsertTool;
|
|
225689
225733
|
exports.validateAgainstJsonSchema = validateAgainstJsonSchema;
|