@axiom-lattice/core 2.1.29 → 2.1.31
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/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +394 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +436 -176
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -699,11 +699,11 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
699
699
|
* @param key Lattice键名
|
|
700
700
|
* @param tool 已有的StructuredTool实例
|
|
701
701
|
*/
|
|
702
|
-
registerExistingTool(key,
|
|
702
|
+
registerExistingTool(key, tool48) {
|
|
703
703
|
const config = {
|
|
704
|
-
name:
|
|
705
|
-
description:
|
|
706
|
-
schema:
|
|
704
|
+
name: tool48.name,
|
|
705
|
+
description: tool48.description,
|
|
706
|
+
schema: tool48.schema,
|
|
707
707
|
// StructuredTool的schema已经是Zod兼容的
|
|
708
708
|
needUserApprove: false
|
|
709
709
|
// MCP工具默认不需要用户批准
|
|
@@ -711,7 +711,7 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
711
711
|
const toolLattice = {
|
|
712
712
|
key,
|
|
713
713
|
config,
|
|
714
|
-
client:
|
|
714
|
+
client: tool48
|
|
715
715
|
};
|
|
716
716
|
this.register(key, toolLattice);
|
|
717
717
|
}
|
|
@@ -737,7 +737,7 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
737
737
|
};
|
|
738
738
|
var toolLatticeManager = ToolLatticeManager.getInstance();
|
|
739
739
|
var registerToolLattice = (key, config, executor) => toolLatticeManager.registerLattice(key, config, executor);
|
|
740
|
-
var registerExistingTool = (key,
|
|
740
|
+
var registerExistingTool = (key, tool48) => toolLatticeManager.registerExistingTool(key, tool48);
|
|
741
741
|
var getToolLattice = (key) => toolLatticeManager.getToolLattice(key);
|
|
742
742
|
var getToolDefinition = (key) => toolLatticeManager.getToolDefinition(key);
|
|
743
743
|
var getToolClient = (key) => toolLatticeManager.getToolClient(key);
|
|
@@ -749,11 +749,17 @@ registerToolLattice(
|
|
|
749
749
|
"get_current_date_time",
|
|
750
750
|
{
|
|
751
751
|
name: "get_current_date_time",
|
|
752
|
-
description: "
|
|
752
|
+
description: "Access the authoritative system clock to synchronize the real-world timeline. Essential for anchoring all relative time expressions (e.g., 'recent', 'last quarter', 'YTD') and establishing precise temporal filters for data retrieval, trend analysis, and decision-making logic. Avoid data hallucinations from training data.",
|
|
753
753
|
schema: import_zod.default.object({})
|
|
754
754
|
},
|
|
755
755
|
async () => {
|
|
756
|
-
|
|
756
|
+
const now = /* @__PURE__ */ new Date();
|
|
757
|
+
return JSON.stringify({
|
|
758
|
+
local_time: now.toLocaleString(),
|
|
759
|
+
iso_date: now.toISOString().split("T")[0],
|
|
760
|
+
// 方便直接用于 SQL: 2026-03-10
|
|
761
|
+
timestamp: now.toISOString()
|
|
762
|
+
});
|
|
757
763
|
}
|
|
758
764
|
);
|
|
759
765
|
|
|
@@ -2088,7 +2094,7 @@ ${lines.join("\n")}`;
|
|
|
2088
2094
|
);
|
|
2089
2095
|
};
|
|
2090
2096
|
|
|
2091
|
-
// src/tool_lattice/metrics/
|
|
2097
|
+
// src/tool_lattice/metrics/list_datasources.ts
|
|
2092
2098
|
var import_zod8 = __toESM(require("zod"));
|
|
2093
2099
|
var import_langchain6 = require("langchain");
|
|
2094
2100
|
var LIST_METRICS_DATASOURCES_DESCRIPTION = `List all available datasources from all configured metrics servers. Returns a table with Server Key, DataSource ID, and DataSource Name. Use this tool first to discover what datasources are available before querying metrics.`;
|
|
@@ -2160,7 +2166,7 @@ To view all available data sources, please clear the current selection or reopen
|
|
|
2160
2166
|
}
|
|
2161
2167
|
},
|
|
2162
2168
|
{
|
|
2163
|
-
name: "
|
|
2169
|
+
name: "list_datasources",
|
|
2164
2170
|
description: `${LIST_METRICS_DATASOURCES_DESCRIPTION}${availableServersText}`,
|
|
2165
2171
|
schema: import_zod8.default.object({})
|
|
2166
2172
|
}
|
|
@@ -3062,10 +3068,10 @@ When to Use This Tool:
|
|
|
3062
3068
|
|
|
3063
3069
|
When NOT to Use This Tool:
|
|
3064
3070
|
- For simple metric queries - use query_semantic_metric_data instead
|
|
3065
|
-
- When you haven't identified the correct datasource yet - use
|
|
3071
|
+
- When you haven't identified the correct datasource yet - use list_datasources first
|
|
3066
3072
|
|
|
3067
3073
|
Prerequisites:
|
|
3068
|
-
1. Call
|
|
3074
|
+
1. Call list_datasources to get available datasource IDs
|
|
3069
3075
|
2. Call query_tables_list to see available tables and their structures
|
|
3070
3076
|
3. Call query_table_definition to understand table columns before writing SQL
|
|
3071
3077
|
|
|
@@ -3084,7 +3090,7 @@ Example:
|
|
|
3084
3090
|
"params": {
|
|
3085
3091
|
"year": "2024"
|
|
3086
3092
|
},
|
|
3087
|
-
"limit":
|
|
3093
|
+
"limit": 100
|
|
3088
3094
|
}`;
|
|
3089
3095
|
var createExecuteSqlQueryTool = ({ serverKeys, serverDescriptions }) => {
|
|
3090
3096
|
const availableServersText = serverKeys.length > 0 ? `
|
|
@@ -3142,7 +3148,7 @@ ${serverKeys.map(
|
|
|
3142
3148
|
datasourceId: import_zod14.default.string().optional().describe("The data source ID to execute SQL against. Optional if configured in runConfig.metricsDataSource"),
|
|
3143
3149
|
customSql: import_zod14.default.string().describe("Custom SQL query string with named parameters (e.g., :year, :category). Use double quotes for identifiers."),
|
|
3144
3150
|
params: import_zod14.default.record(import_zod14.default.union([import_zod14.default.string(), import_zod14.default.number(), import_zod14.default.boolean()])).optional().describe("Optional parameters for the SQL query. Keys should match the :paramName placeholders in customSql."),
|
|
3145
|
-
limit: import_zod14.default.number().optional().describe("Maximum number of results to return (default:
|
|
3151
|
+
limit: import_zod14.default.number().optional().describe("Maximum number of results to return (default: 100).")
|
|
3146
3152
|
})
|
|
3147
3153
|
}
|
|
3148
3154
|
);
|
|
@@ -4515,7 +4521,7 @@ var createReactAgentSchema = (schema) => {
|
|
|
4515
4521
|
};
|
|
4516
4522
|
|
|
4517
4523
|
// src/agent_lattice/builders/ReActAgentGraphBuilder.ts
|
|
4518
|
-
var
|
|
4524
|
+
var import_langchain48 = require("langchain");
|
|
4519
4525
|
|
|
4520
4526
|
// src/deep_agent_new/backends/sandboxFiles.ts
|
|
4521
4527
|
var import_sandbox2 = require("@agent-infra/sandbox");
|
|
@@ -5930,6 +5936,122 @@ var InMemoryMetricsServerConfigStore = class {
|
|
|
5930
5936
|
}
|
|
5931
5937
|
};
|
|
5932
5938
|
|
|
5939
|
+
// src/store_lattice/InMemoryMcpServerConfigStore.ts
|
|
5940
|
+
var InMemoryMcpServerConfigStore = class {
|
|
5941
|
+
constructor() {
|
|
5942
|
+
this.configs = /* @__PURE__ */ new Map();
|
|
5943
|
+
}
|
|
5944
|
+
/**
|
|
5945
|
+
* Get composite key for storage
|
|
5946
|
+
*/
|
|
5947
|
+
getKey(tenantId, id) {
|
|
5948
|
+
return `${tenantId}:${id}`;
|
|
5949
|
+
}
|
|
5950
|
+
/**
|
|
5951
|
+
* Get all MCP server configurations for a tenant
|
|
5952
|
+
*/
|
|
5953
|
+
async getAllConfigs(tenantId) {
|
|
5954
|
+
return Array.from(this.configs.values()).filter(
|
|
5955
|
+
(config) => config.tenantId === tenantId
|
|
5956
|
+
);
|
|
5957
|
+
}
|
|
5958
|
+
/**
|
|
5959
|
+
* Get all MCP server configurations across all tenants
|
|
5960
|
+
*/
|
|
5961
|
+
async getAllConfigsWithoutTenant() {
|
|
5962
|
+
return Array.from(this.configs.values());
|
|
5963
|
+
}
|
|
5964
|
+
/**
|
|
5965
|
+
* Get MCP server configuration by ID
|
|
5966
|
+
*/
|
|
5967
|
+
async getConfigById(tenantId, id) {
|
|
5968
|
+
const key = this.getKey(tenantId, id);
|
|
5969
|
+
return this.configs.get(key) || null;
|
|
5970
|
+
}
|
|
5971
|
+
/**
|
|
5972
|
+
* Get MCP server configuration by business key
|
|
5973
|
+
*/
|
|
5974
|
+
async getConfigByKey(tenantId, key) {
|
|
5975
|
+
const configs = await this.getAllConfigs(tenantId);
|
|
5976
|
+
return configs.find((config) => config.key === key) || null;
|
|
5977
|
+
}
|
|
5978
|
+
/**
|
|
5979
|
+
* Create a new MCP server configuration
|
|
5980
|
+
*/
|
|
5981
|
+
async createConfig(tenantId, id, data) {
|
|
5982
|
+
const now = /* @__PURE__ */ new Date();
|
|
5983
|
+
const entry = {
|
|
5984
|
+
id,
|
|
5985
|
+
tenantId,
|
|
5986
|
+
key: data.key,
|
|
5987
|
+
config: data.config,
|
|
5988
|
+
selectedTools: data.selectedTools || [],
|
|
5989
|
+
isEnvEncrypted: false,
|
|
5990
|
+
status: "disconnected",
|
|
5991
|
+
name: data.name,
|
|
5992
|
+
description: data.description,
|
|
5993
|
+
createdAt: now,
|
|
5994
|
+
updatedAt: now
|
|
5995
|
+
};
|
|
5996
|
+
const storageKey = this.getKey(tenantId, id);
|
|
5997
|
+
this.configs.set(storageKey, entry);
|
|
5998
|
+
return entry;
|
|
5999
|
+
}
|
|
6000
|
+
/**
|
|
6001
|
+
* Update an existing MCP server configuration
|
|
6002
|
+
*/
|
|
6003
|
+
async updateConfig(tenantId, id, updates) {
|
|
6004
|
+
const key = this.getKey(tenantId, id);
|
|
6005
|
+
const existing = this.configs.get(key);
|
|
6006
|
+
if (!existing) {
|
|
6007
|
+
return null;
|
|
6008
|
+
}
|
|
6009
|
+
const updated = {
|
|
6010
|
+
...existing,
|
|
6011
|
+
...updates,
|
|
6012
|
+
config: updates.config ? { ...existing.config, ...updates.config } : existing.config,
|
|
6013
|
+
key: updates.key || existing.key,
|
|
6014
|
+
name: updates.name !== void 0 ? updates.name : existing.name,
|
|
6015
|
+
description: updates.description !== void 0 ? updates.description : existing.description,
|
|
6016
|
+
selectedTools: updates.selectedTools !== void 0 ? updates.selectedTools : existing.selectedTools,
|
|
6017
|
+
status: updates.status !== void 0 ? updates.status : existing.status,
|
|
6018
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
6019
|
+
};
|
|
6020
|
+
this.configs.set(key, updated);
|
|
6021
|
+
return updated;
|
|
6022
|
+
}
|
|
6023
|
+
/**
|
|
6024
|
+
* Delete a MCP server configuration by ID
|
|
6025
|
+
*/
|
|
6026
|
+
async deleteConfig(tenantId, id) {
|
|
6027
|
+
const key = this.getKey(tenantId, id);
|
|
6028
|
+
return this.configs.delete(key);
|
|
6029
|
+
}
|
|
6030
|
+
/**
|
|
6031
|
+
* Check if configuration exists
|
|
6032
|
+
*/
|
|
6033
|
+
async hasConfig(tenantId, id) {
|
|
6034
|
+
const key = this.getKey(tenantId, id);
|
|
6035
|
+
return this.configs.has(key);
|
|
6036
|
+
}
|
|
6037
|
+
/**
|
|
6038
|
+
* Clear all configurations (useful for testing)
|
|
6039
|
+
*/
|
|
6040
|
+
clear() {
|
|
6041
|
+
this.configs.clear();
|
|
6042
|
+
}
|
|
6043
|
+
/**
|
|
6044
|
+
* Clear configurations for a specific tenant
|
|
6045
|
+
*/
|
|
6046
|
+
clearByTenant(tenantId) {
|
|
6047
|
+
for (const key of this.configs.keys()) {
|
|
6048
|
+
if (key.startsWith(`${tenantId}:`)) {
|
|
6049
|
+
this.configs.delete(key);
|
|
6050
|
+
}
|
|
6051
|
+
}
|
|
6052
|
+
}
|
|
6053
|
+
};
|
|
6054
|
+
|
|
5933
6055
|
// src/store_lattice/InMemoryUserStore.ts
|
|
5934
6056
|
var InMemoryUserStore = class {
|
|
5935
6057
|
constructor() {
|
|
@@ -6235,6 +6357,7 @@ var defaultWorkspaceStore = new InMemoryWorkspaceStore();
|
|
|
6235
6357
|
var defaultProjectStore = new InMemoryProjectStore();
|
|
6236
6358
|
var defaultDatabaseConfigStore = new InMemoryDatabaseConfigStore();
|
|
6237
6359
|
var defaultMetricsServerConfigStore = new InMemoryMetricsServerConfigStore();
|
|
6360
|
+
var defaultMcpServerConfigStore = new InMemoryMcpServerConfigStore();
|
|
6238
6361
|
storeLatticeManager.registerLattice("default", "thread", defaultThreadStore);
|
|
6239
6362
|
storeLatticeManager.registerLattice(
|
|
6240
6363
|
"default",
|
|
@@ -6246,6 +6369,7 @@ storeLatticeManager.registerLattice("default", "workspace", defaultWorkspaceStor
|
|
|
6246
6369
|
storeLatticeManager.registerLattice("default", "project", defaultProjectStore);
|
|
6247
6370
|
storeLatticeManager.registerLattice("default", "database", defaultDatabaseConfigStore);
|
|
6248
6371
|
storeLatticeManager.registerLattice("default", "metrics", defaultMetricsServerConfigStore);
|
|
6372
|
+
storeLatticeManager.registerLattice("default", "mcp", defaultMcpServerConfigStore);
|
|
6249
6373
|
var defaultUserStore = new InMemoryUserStore();
|
|
6250
6374
|
var defaultTenantStore = new InMemoryTenantStore();
|
|
6251
6375
|
var defaultUserTenantLinkStore = new InMemoryUserTenantLinkStore();
|
|
@@ -7154,7 +7278,7 @@ function createFilesystemMiddleware(options = {}) {
|
|
|
7154
7278
|
backend = async (stateAndStore) => new StateBackend(stateAndStore),
|
|
7155
7279
|
systemPrompt: customSystemPrompt = null,
|
|
7156
7280
|
customToolDescriptions = null,
|
|
7157
|
-
toolTokenLimitBeforeEvict =
|
|
7281
|
+
toolTokenLimitBeforeEvict = 1e5
|
|
7158
7282
|
} = options;
|
|
7159
7283
|
const systemPrompt = customSystemPrompt || FILESYSTEM_SYSTEM_PROMPT;
|
|
7160
7284
|
const tools = [
|
|
@@ -7189,7 +7313,24 @@ ${systemPrompt}` : systemPrompt;
|
|
|
7189
7313
|
return handler({ ...request, systemPrompt: newSystemPrompt });
|
|
7190
7314
|
} : void 0,
|
|
7191
7315
|
wrapToolCall: toolTokenLimitBeforeEvict ? (async (request, handler) => {
|
|
7192
|
-
|
|
7316
|
+
let result;
|
|
7317
|
+
try {
|
|
7318
|
+
result = await handler(request);
|
|
7319
|
+
} catch (error) {
|
|
7320
|
+
if (error instanceof import_langgraph4.GraphInterrupt) {
|
|
7321
|
+
throw error;
|
|
7322
|
+
}
|
|
7323
|
+
console.error(request.toolCall?.name, error);
|
|
7324
|
+
return new import_langgraph4.Command({
|
|
7325
|
+
update: {
|
|
7326
|
+
messages: [new import_langchain44.ToolMessage({
|
|
7327
|
+
content: error instanceof Error ? error.message : "Unknown error",
|
|
7328
|
+
tool_call_id: request.toolCall?.id,
|
|
7329
|
+
name: request.toolCall?.name
|
|
7330
|
+
})]
|
|
7331
|
+
}
|
|
7332
|
+
});
|
|
7333
|
+
}
|
|
7193
7334
|
async function processToolMessage(msg) {
|
|
7194
7335
|
if (typeof msg.content === "string" && msg.content.length > toolTokenLimitBeforeEvict * 4) {
|
|
7195
7336
|
const stateAndStore = {
|
|
@@ -7303,6 +7444,122 @@ function createMetricsMiddleware(params) {
|
|
|
7303
7444
|
});
|
|
7304
7445
|
}
|
|
7305
7446
|
|
|
7447
|
+
// src/middlewares/askUserClarifyMiddleware.ts
|
|
7448
|
+
var import_langchain47 = require("langchain");
|
|
7449
|
+
var import_langgraph5 = require("@langchain/langgraph");
|
|
7450
|
+
|
|
7451
|
+
// src/tool_lattice/ask_user_to_clarify/index.ts
|
|
7452
|
+
var import_langchain46 = require("langchain");
|
|
7453
|
+
var import_zod45 = __toESM(require("zod"));
|
|
7454
|
+
var questionSchema = import_zod45.default.object({
|
|
7455
|
+
question: import_zod45.default.string().describe("The question text to ask the user"),
|
|
7456
|
+
options: import_zod45.default.array(import_zod45.default.string()).describe("List of EXACT, selectable values. Maximum 3 options allowed. DO NOT include any 'placeholder' options that require the user to type (e.g., do NOT add 'Enter manual value'). If manual input is needed, set allowOther to true instead."),
|
|
7457
|
+
type: import_zod45.default.enum(["single", "multiple"]).describe("Whether the question allows single or multiple selections"),
|
|
7458
|
+
required: import_zod45.default.boolean().optional().default(false).describe("Whether this question must be answered"),
|
|
7459
|
+
allowOther: import_zod45.default.boolean().optional().default(true).describe("Set to true to append an 'Other' option that opens a free-text input field. Use this for open-ended answers or when the 3 options cannot cover all possibilities.")
|
|
7460
|
+
});
|
|
7461
|
+
var inputSchema = import_zod45.default.object({
|
|
7462
|
+
questions: import_zod45.default.array(questionSchema).min(1, "At least one question is required").describe("A structured sequence of clarification questions. Use these to gather missing parameters or disambiguate user intent before proceeding.")
|
|
7463
|
+
});
|
|
7464
|
+
function createAskUserToClarifyTool() {
|
|
7465
|
+
return (0, import_langchain46.tool)(
|
|
7466
|
+
async (input) => {
|
|
7467
|
+
return JSON.stringify(input);
|
|
7468
|
+
},
|
|
7469
|
+
{
|
|
7470
|
+
name: "ask_user_to_clarify",
|
|
7471
|
+
description: "Prompts the user to choose from a list of predefined values OR provide custom input. USE CASES: 1. Use 'options' ONLY for distinct, mutually exclusive choices (e.g., ['Standard', 'Express']). 2. Set 'allowOther: true' ONLY when you need to capture free-text information that doesn't fit into the predefined options. IMPORTANT: Never put placeholders like 'Please specify' or 'Other' inside the 'options' list. ",
|
|
7472
|
+
schema: inputSchema
|
|
7473
|
+
}
|
|
7474
|
+
);
|
|
7475
|
+
}
|
|
7476
|
+
|
|
7477
|
+
// src/middlewares/askUserClarifyMiddleware.ts
|
|
7478
|
+
function createAskUserClarifyMiddleware() {
|
|
7479
|
+
return (0, import_langchain47.createMiddleware)({
|
|
7480
|
+
name: "AskUserClarifyMiddleware",
|
|
7481
|
+
tools: [createAskUserToClarifyTool()],
|
|
7482
|
+
wrapToolCall: async (request, handler) => {
|
|
7483
|
+
const toolCall = request.toolCall;
|
|
7484
|
+
const toolName = toolCall?.name;
|
|
7485
|
+
if (toolName !== "ask_user_to_clarify") {
|
|
7486
|
+
try {
|
|
7487
|
+
return await handler(request);
|
|
7488
|
+
} catch (error) {
|
|
7489
|
+
if (error instanceof import_langgraph5.GraphInterrupt) {
|
|
7490
|
+
throw error;
|
|
7491
|
+
}
|
|
7492
|
+
console.error(`Error executing tool "${toolName}":`, error);
|
|
7493
|
+
return new import_langchain47.ToolMessage({
|
|
7494
|
+
content: `Error executing tool: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
7495
|
+
tool_call_id: toolCall?.id,
|
|
7496
|
+
name: toolName
|
|
7497
|
+
});
|
|
7498
|
+
}
|
|
7499
|
+
}
|
|
7500
|
+
const input = toolCall?.args;
|
|
7501
|
+
if (!input?.questions || input.questions.length === 0) {
|
|
7502
|
+
return new import_langchain47.ToolMessage({
|
|
7503
|
+
content: "No questions provided.",
|
|
7504
|
+
tool_call_id: toolCall?.id,
|
|
7505
|
+
name: toolName
|
|
7506
|
+
});
|
|
7507
|
+
}
|
|
7508
|
+
const uiData = {
|
|
7509
|
+
questions: input.questions.map((q) => ({
|
|
7510
|
+
question: q.question,
|
|
7511
|
+
options: q.options,
|
|
7512
|
+
type: q.type,
|
|
7513
|
+
required: q.required,
|
|
7514
|
+
allowOther: q.allowOther
|
|
7515
|
+
}))
|
|
7516
|
+
};
|
|
7517
|
+
const md = genUIMarkdown("clarify", uiData);
|
|
7518
|
+
const result = await (0, import_langgraph5.interrupt)(md);
|
|
7519
|
+
const response = result.data;
|
|
7520
|
+
if (!response?.answers || response.answers.length === 0) {
|
|
7521
|
+
return new import_langchain47.ToolMessage({
|
|
7522
|
+
content: "No clarification questions were answered.",
|
|
7523
|
+
tool_call_id: toolCall?.id,
|
|
7524
|
+
name: toolName
|
|
7525
|
+
});
|
|
7526
|
+
}
|
|
7527
|
+
const answeredQuestions = response.answers.filter(
|
|
7528
|
+
(answer) => answer.selectedOptions.length > 0 || answer.otherText && answer.otherText.trim() !== ""
|
|
7529
|
+
);
|
|
7530
|
+
if (answeredQuestions.length === 0) {
|
|
7531
|
+
return new import_langchain47.ToolMessage({
|
|
7532
|
+
content: "No clarification questions were answered.",
|
|
7533
|
+
tool_call_id: toolCall?.id,
|
|
7534
|
+
name: toolName
|
|
7535
|
+
});
|
|
7536
|
+
}
|
|
7537
|
+
const lines = ["## Clarification Questions Answered", ""];
|
|
7538
|
+
for (const answer of answeredQuestions) {
|
|
7539
|
+
const question = input.questions[answer.questionIndex];
|
|
7540
|
+
if (!question) continue;
|
|
7541
|
+
lines.push(`**Q${answer.questionIndex + 1}: ${question.question}**`);
|
|
7542
|
+
const parts = [];
|
|
7543
|
+
if (answer.selectedOptions.length > 0) {
|
|
7544
|
+
parts.push(...answer.selectedOptions);
|
|
7545
|
+
}
|
|
7546
|
+
if (answer.otherText && answer.otherText.trim() !== "") {
|
|
7547
|
+
parts.push(`Other: ${answer.otherText.trim()}`);
|
|
7548
|
+
}
|
|
7549
|
+
if (parts.length > 0) {
|
|
7550
|
+
lines.push(`A: ${parts.join(", ")}`);
|
|
7551
|
+
}
|
|
7552
|
+
lines.push("");
|
|
7553
|
+
}
|
|
7554
|
+
return new import_langchain47.ToolMessage({
|
|
7555
|
+
content: lines.join("\n"),
|
|
7556
|
+
tool_call_id: toolCall?.id,
|
|
7557
|
+
name: toolName
|
|
7558
|
+
});
|
|
7559
|
+
}
|
|
7560
|
+
});
|
|
7561
|
+
}
|
|
7562
|
+
|
|
7306
7563
|
// src/agent_lattice/builders/commonMiddleware.ts
|
|
7307
7564
|
function createCommonMiddlewares(middlewareConfigs, filesystemBackend) {
|
|
7308
7565
|
const middlewares = [];
|
|
@@ -7349,6 +7606,9 @@ function createCommonMiddlewares(middlewareConfigs, filesystemBackend) {
|
|
|
7349
7606
|
}
|
|
7350
7607
|
}
|
|
7351
7608
|
break;
|
|
7609
|
+
case "ask_user_to_clarify":
|
|
7610
|
+
middlewares.push(createAskUserClarifyMiddleware());
|
|
7611
|
+
break;
|
|
7352
7612
|
}
|
|
7353
7613
|
}
|
|
7354
7614
|
return middlewares;
|
|
@@ -7392,14 +7652,14 @@ var ReActAgentGraphBuilder = class {
|
|
|
7392
7652
|
*/
|
|
7393
7653
|
build(agentLattice, params) {
|
|
7394
7654
|
const tools = params.tools.map((t) => {
|
|
7395
|
-
const
|
|
7396
|
-
return
|
|
7397
|
-
}).filter((
|
|
7655
|
+
const tool48 = getToolClient(t.key);
|
|
7656
|
+
return tool48;
|
|
7657
|
+
}).filter((tool48) => tool48 !== void 0);
|
|
7398
7658
|
const stateSchema2 = createReactAgentSchema(params.stateSchema);
|
|
7399
7659
|
const middlewareConfigs = params.middleware || [];
|
|
7400
7660
|
const filesystemBackend = this.createFilesystemBackendFactory(middlewareConfigs);
|
|
7401
7661
|
const middlewares = createCommonMiddlewares(middlewareConfigs, filesystemBackend);
|
|
7402
|
-
return (0,
|
|
7662
|
+
return (0, import_langchain48.createAgent)({
|
|
7403
7663
|
model: params.model,
|
|
7404
7664
|
tools,
|
|
7405
7665
|
systemPrompt: params.prompt,
|
|
@@ -7412,16 +7672,16 @@ var ReActAgentGraphBuilder = class {
|
|
|
7412
7672
|
};
|
|
7413
7673
|
|
|
7414
7674
|
// src/deep_agent_new/agent.ts
|
|
7415
|
-
var
|
|
7675
|
+
var import_langchain52 = require("langchain");
|
|
7416
7676
|
|
|
7417
7677
|
// src/deep_agent_new/middleware/subagents.ts
|
|
7418
7678
|
var import_v32 = require("zod/v3");
|
|
7419
|
-
var
|
|
7420
|
-
var
|
|
7679
|
+
var import_langchain49 = require("langchain");
|
|
7680
|
+
var import_langgraph7 = require("@langchain/langgraph");
|
|
7421
7681
|
var import_messages = require("@langchain/core/messages");
|
|
7422
7682
|
|
|
7423
7683
|
// src/agent_worker/agent_worker_graph.ts
|
|
7424
|
-
var
|
|
7684
|
+
var import_langgraph6 = require("@langchain/langgraph");
|
|
7425
7685
|
|
|
7426
7686
|
// src/constants/agent_task_types.ts
|
|
7427
7687
|
var AGENT_TASK_EVENT = "agent:execute";
|
|
@@ -7710,41 +7970,41 @@ var AgentManager = class _AgentManager {
|
|
|
7710
7970
|
};
|
|
7711
7971
|
|
|
7712
7972
|
// src/agent_worker/agent_worker_graph.ts
|
|
7713
|
-
var AgentWorkerState =
|
|
7973
|
+
var AgentWorkerState = import_langgraph6.Annotation.Root({
|
|
7714
7974
|
// Input parameters
|
|
7715
|
-
assistant_id: (0,
|
|
7975
|
+
assistant_id: (0, import_langgraph6.Annotation)({
|
|
7716
7976
|
reducer: (x, y) => y ?? x,
|
|
7717
7977
|
default: () => ""
|
|
7718
7978
|
}),
|
|
7719
|
-
thread_id: (0,
|
|
7979
|
+
thread_id: (0, import_langgraph6.Annotation)({
|
|
7720
7980
|
reducer: (x, y) => y ?? x,
|
|
7721
7981
|
default: () => ""
|
|
7722
7982
|
}),
|
|
7723
|
-
input: (0,
|
|
7983
|
+
input: (0, import_langgraph6.Annotation)({
|
|
7724
7984
|
reducer: (x, y) => y ?? x,
|
|
7725
7985
|
default: () => ({})
|
|
7726
7986
|
}),
|
|
7727
|
-
command2: (0,
|
|
7987
|
+
command2: (0, import_langgraph6.Annotation)({
|
|
7728
7988
|
reducer: (x, y) => y ?? x,
|
|
7729
7989
|
default: () => void 0
|
|
7730
7990
|
}),
|
|
7731
7991
|
// RunConfig for passing configuration through the graph
|
|
7732
|
-
runConfig: (0,
|
|
7992
|
+
runConfig: (0, import_langgraph6.Annotation)({
|
|
7733
7993
|
reducer: (x, y) => y ?? x,
|
|
7734
7994
|
default: () => void 0
|
|
7735
7995
|
}),
|
|
7736
7996
|
// Execution result
|
|
7737
|
-
result: (0,
|
|
7997
|
+
result: (0, import_langgraph6.Annotation)({
|
|
7738
7998
|
reducer: (x, y) => y ?? x,
|
|
7739
7999
|
default: () => void 0
|
|
7740
8000
|
}),
|
|
7741
8001
|
// Interrupt data
|
|
7742
|
-
interruptValue: (0,
|
|
8002
|
+
interruptValue: (0, import_langgraph6.Annotation)({
|
|
7743
8003
|
reducer: (x, y) => y ?? x,
|
|
7744
8004
|
default: () => void 0
|
|
7745
8005
|
}),
|
|
7746
8006
|
// Final state to return
|
|
7747
|
-
finalState: (0,
|
|
8007
|
+
finalState: (0, import_langgraph6.Annotation)({
|
|
7748
8008
|
reducer: (x, y) => y ?? x,
|
|
7749
8009
|
default: () => void 0
|
|
7750
8010
|
})
|
|
@@ -7774,7 +8034,7 @@ async function interruptNode(state) {
|
|
|
7774
8034
|
"Interrupt node called but no interrupt value found in result"
|
|
7775
8035
|
);
|
|
7776
8036
|
}
|
|
7777
|
-
const response = await (0,
|
|
8037
|
+
const response = await (0, import_langgraph6.interrupt)(interruptValue);
|
|
7778
8038
|
return {
|
|
7779
8039
|
command2: {
|
|
7780
8040
|
resume: response
|
|
@@ -7801,7 +8061,7 @@ function endNode(state) {
|
|
|
7801
8061
|
};
|
|
7802
8062
|
}
|
|
7803
8063
|
function createAgentWorkerGraph() {
|
|
7804
|
-
const workflow = new
|
|
8064
|
+
const workflow = new import_langgraph6.StateGraph(AgentWorkerState);
|
|
7805
8065
|
workflow.addNode("execute", executeNode);
|
|
7806
8066
|
workflow.addNode("interrupt", interruptNode);
|
|
7807
8067
|
workflow.addNode("end", endNode);
|
|
@@ -7811,7 +8071,7 @@ function createAgentWorkerGraph() {
|
|
|
7811
8071
|
end: "end"
|
|
7812
8072
|
});
|
|
7813
8073
|
workflow.addEdge("interrupt", "execute");
|
|
7814
|
-
workflow.addEdge("end",
|
|
8074
|
+
workflow.addEdge("end", import_langgraph6.END);
|
|
7815
8075
|
return workflow.compile();
|
|
7816
8076
|
}
|
|
7817
8077
|
var agentWorkerGraph = createAgentWorkerGraph();
|
|
@@ -7973,11 +8233,11 @@ function returnCommandWithStateUpdate(result, toolCallId) {
|
|
|
7973
8233
|
const stateUpdate = filterStateForSubagent(result);
|
|
7974
8234
|
const messages = result.messages;
|
|
7975
8235
|
const lastMessage = messages?.[messages.length - 1];
|
|
7976
|
-
return new
|
|
8236
|
+
return new import_langgraph7.Command({
|
|
7977
8237
|
update: {
|
|
7978
8238
|
...stateUpdate,
|
|
7979
8239
|
messages: [
|
|
7980
|
-
new
|
|
8240
|
+
new import_langchain49.ToolMessage({
|
|
7981
8241
|
content: lastMessage?.content || "Task Failed to complete",
|
|
7982
8242
|
tool_call_id: toolCallId,
|
|
7983
8243
|
name: "task"
|
|
@@ -8002,10 +8262,10 @@ function getSubagents(options) {
|
|
|
8002
8262
|
const generalPurposeMiddleware = [...defaultSubagentMiddleware];
|
|
8003
8263
|
if (defaultInterruptOn) {
|
|
8004
8264
|
generalPurposeMiddleware.push(
|
|
8005
|
-
(0,
|
|
8265
|
+
(0, import_langchain49.humanInTheLoopMiddleware)({ interruptOn: defaultInterruptOn })
|
|
8006
8266
|
);
|
|
8007
8267
|
}
|
|
8008
|
-
const generalPurposeSubagent = (0,
|
|
8268
|
+
const generalPurposeSubagent = (0, import_langchain49.createAgent)({
|
|
8009
8269
|
model: defaultModel,
|
|
8010
8270
|
systemPrompt: DEFAULT_SUBAGENT_PROMPT,
|
|
8011
8271
|
tools: defaultTools,
|
|
@@ -8026,8 +8286,8 @@ function getSubagents(options) {
|
|
|
8026
8286
|
const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
|
|
8027
8287
|
const interruptOn = agentParams.interruptOn || defaultInterruptOn;
|
|
8028
8288
|
if (interruptOn)
|
|
8029
|
-
middleware.push((0,
|
|
8030
|
-
agents[agentParams.key] = (0,
|
|
8289
|
+
middleware.push((0, import_langchain49.humanInTheLoopMiddleware)({ interruptOn }));
|
|
8290
|
+
agents[agentParams.key] = (0, import_langchain49.createAgent)({
|
|
8031
8291
|
model: agentParams.model ?? defaultModel,
|
|
8032
8292
|
systemPrompt: agentParams.systemPrompt,
|
|
8033
8293
|
tools: agentParams.tools ?? defaultTools,
|
|
@@ -8056,7 +8316,7 @@ function createTaskTool(options) {
|
|
|
8056
8316
|
generalPurposeAgent
|
|
8057
8317
|
});
|
|
8058
8318
|
const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
|
|
8059
|
-
return (0,
|
|
8319
|
+
return (0, import_langchain49.tool)(
|
|
8060
8320
|
async (input, config) => {
|
|
8061
8321
|
const { description, subagent_type } = input;
|
|
8062
8322
|
try {
|
|
@@ -8067,7 +8327,7 @@ function createTaskTool(options) {
|
|
|
8067
8327
|
);
|
|
8068
8328
|
}
|
|
8069
8329
|
const subagent = subagentGraphs[subagent_type];
|
|
8070
|
-
const currentState = (0,
|
|
8330
|
+
const currentState = (0, import_langgraph7.getCurrentTaskInput)();
|
|
8071
8331
|
const subagentState = filterStateForSubagent(currentState);
|
|
8072
8332
|
subagentState.messages = [new import_messages.HumanMessage({ content: description })];
|
|
8073
8333
|
const subagent_thread_id = config.configurable?.thread_id + "____" + subagent_type + "_" + config.toolCall.id;
|
|
@@ -8088,10 +8348,10 @@ function createTaskTool(options) {
|
|
|
8088
8348
|
}
|
|
8089
8349
|
return returnCommandWithStateUpdate(result, config.toolCall.id);
|
|
8090
8350
|
} catch (error) {
|
|
8091
|
-
return new
|
|
8351
|
+
return new import_langgraph7.Command({
|
|
8092
8352
|
update: {
|
|
8093
8353
|
messages: [
|
|
8094
|
-
new
|
|
8354
|
+
new import_langchain49.ToolMessage({
|
|
8095
8355
|
content: error instanceof Error ? error.message : "Task Failed to complete",
|
|
8096
8356
|
tool_call_id: config.toolCall.id,
|
|
8097
8357
|
name: "task"
|
|
@@ -8135,7 +8395,7 @@ function createSubAgentMiddleware(options) {
|
|
|
8135
8395
|
generalPurposeAgent,
|
|
8136
8396
|
taskDescription
|
|
8137
8397
|
});
|
|
8138
|
-
return (0,
|
|
8398
|
+
return (0, import_langchain49.createMiddleware)({
|
|
8139
8399
|
name: "subAgentMiddleware",
|
|
8140
8400
|
tools: [taskTool],
|
|
8141
8401
|
wrapModelCall: async (request, handler) => {
|
|
@@ -8155,11 +8415,11 @@ ${systemPrompt}` : systemPrompt;
|
|
|
8155
8415
|
}
|
|
8156
8416
|
|
|
8157
8417
|
// src/deep_agent_new/middleware/patch_tool_calls.ts
|
|
8158
|
-
var
|
|
8418
|
+
var import_langchain50 = require("langchain");
|
|
8159
8419
|
var import_messages2 = require("@langchain/core/messages");
|
|
8160
|
-
var
|
|
8420
|
+
var import_langgraph8 = require("@langchain/langgraph");
|
|
8161
8421
|
function createPatchToolCallsMiddleware() {
|
|
8162
|
-
return (0,
|
|
8422
|
+
return (0, import_langchain50.createMiddleware)({
|
|
8163
8423
|
name: "patchToolCallsMiddleware",
|
|
8164
8424
|
beforeAgent: async (state) => {
|
|
8165
8425
|
const messages = state.messages;
|
|
@@ -8170,15 +8430,15 @@ function createPatchToolCallsMiddleware() {
|
|
|
8170
8430
|
for (let i = 0; i < messages.length; i++) {
|
|
8171
8431
|
const msg = messages[i];
|
|
8172
8432
|
patchedMessages.push(msg);
|
|
8173
|
-
if (
|
|
8433
|
+
if (import_langchain50.AIMessage.isInstance(msg) && msg.tool_calls != null) {
|
|
8174
8434
|
for (const toolCall of msg.tool_calls) {
|
|
8175
8435
|
const correspondingToolMsg = messages.slice(i).find(
|
|
8176
|
-
(m) =>
|
|
8436
|
+
(m) => import_langchain50.ToolMessage.isInstance(m) && m.tool_call_id === toolCall.id
|
|
8177
8437
|
);
|
|
8178
8438
|
if (!correspondingToolMsg) {
|
|
8179
8439
|
const toolMsg = `Tool call ${toolCall.name} with id ${toolCall.id} was cancelled - another message came in before it could be completed.`;
|
|
8180
8440
|
patchedMessages.push(
|
|
8181
|
-
new
|
|
8441
|
+
new import_langchain50.ToolMessage({
|
|
8182
8442
|
content: toolMsg,
|
|
8183
8443
|
name: toolCall.name,
|
|
8184
8444
|
tool_call_id: toolCall.id
|
|
@@ -8190,7 +8450,7 @@ function createPatchToolCallsMiddleware() {
|
|
|
8190
8450
|
}
|
|
8191
8451
|
return {
|
|
8192
8452
|
messages: [
|
|
8193
|
-
new import_messages2.RemoveMessage({ id:
|
|
8453
|
+
new import_messages2.RemoveMessage({ id: import_langgraph8.REMOVE_ALL_MESSAGES }),
|
|
8194
8454
|
...patchedMessages
|
|
8195
8455
|
]
|
|
8196
8456
|
};
|
|
@@ -9290,9 +9550,9 @@ var MemoryBackend = class {
|
|
|
9290
9550
|
};
|
|
9291
9551
|
|
|
9292
9552
|
// src/deep_agent_new/middleware/todos.ts
|
|
9293
|
-
var
|
|
9294
|
-
var
|
|
9295
|
-
var
|
|
9553
|
+
var import_langgraph9 = require("@langchain/langgraph");
|
|
9554
|
+
var import_zod46 = require("zod");
|
|
9555
|
+
var import_langchain51 = require("langchain");
|
|
9296
9556
|
var WRITE_TODOS_DESCRIPTION = `Use this tool to create and manage a structured task list for your current work session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
9297
9557
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
9298
9558
|
Only use this tool if you think it will be helpful in staying organized. If the user's request is trivial and takes less than 3 steps, it is better to NOT use this tool and just do the taks directly.
|
|
@@ -9519,20 +9779,20 @@ Writing todos takes time and tokens, use it when it is helpful for managing comp
|
|
|
9519
9779
|
## Important To-Do List Usage Notes to Remember
|
|
9520
9780
|
- The \`write_todos\` tool should never be called multiple times in parallel.
|
|
9521
9781
|
- Don't be afraid to revise the To-Do list as you go. New information may reveal new tasks that need to be done, or old tasks that are irrelevant.`;
|
|
9522
|
-
var TodoStatus =
|
|
9523
|
-
var TodoSchema =
|
|
9524
|
-
content:
|
|
9782
|
+
var TodoStatus = import_zod46.z.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
|
|
9783
|
+
var TodoSchema = import_zod46.z.object({
|
|
9784
|
+
content: import_zod46.z.string().describe("Content of the todo item"),
|
|
9525
9785
|
status: TodoStatus
|
|
9526
9786
|
});
|
|
9527
|
-
var stateSchema =
|
|
9787
|
+
var stateSchema = import_zod46.z.object({ todos: import_zod46.z.array(TodoSchema).default([]) });
|
|
9528
9788
|
function todoListMiddleware(options) {
|
|
9529
|
-
const writeTodos = (0,
|
|
9789
|
+
const writeTodos = (0, import_langchain51.tool)(
|
|
9530
9790
|
({ todos }, config) => {
|
|
9531
|
-
return new
|
|
9791
|
+
return new import_langgraph9.Command({
|
|
9532
9792
|
update: {
|
|
9533
9793
|
todos,
|
|
9534
9794
|
messages: [
|
|
9535
|
-
new
|
|
9795
|
+
new import_langchain51.ToolMessage({
|
|
9536
9796
|
content: genUIMarkdown("todo_list", todos),
|
|
9537
9797
|
tool_call_id: config.toolCall?.id
|
|
9538
9798
|
})
|
|
@@ -9543,12 +9803,12 @@ function todoListMiddleware(options) {
|
|
|
9543
9803
|
{
|
|
9544
9804
|
name: "write_todos",
|
|
9545
9805
|
description: options?.toolDescription ?? WRITE_TODOS_DESCRIPTION,
|
|
9546
|
-
schema:
|
|
9547
|
-
todos:
|
|
9806
|
+
schema: import_zod46.z.object({
|
|
9807
|
+
todos: import_zod46.z.array(TodoSchema).describe("List of todo items to update")
|
|
9548
9808
|
})
|
|
9549
9809
|
}
|
|
9550
9810
|
);
|
|
9551
|
-
return (0,
|
|
9811
|
+
return (0, import_langchain51.createMiddleware)({
|
|
9552
9812
|
name: "todoListMiddleware",
|
|
9553
9813
|
stateSchema,
|
|
9554
9814
|
tools: [writeTodos],
|
|
@@ -9600,13 +9860,13 @@ ${BASE_PROMPT}` : BASE_PROMPT;
|
|
|
9600
9860
|
backend: filesystemBackend
|
|
9601
9861
|
}),
|
|
9602
9862
|
// Subagent middleware: Automatic conversation summarization when token limits are approached
|
|
9603
|
-
(0,
|
|
9863
|
+
(0, import_langchain52.summarizationMiddleware)({
|
|
9604
9864
|
model,
|
|
9605
9865
|
trigger: { tokens: 17e4 },
|
|
9606
9866
|
keep: { messages: 6 }
|
|
9607
9867
|
}),
|
|
9608
9868
|
// Subagent middleware: Anthropic prompt caching for improved performance
|
|
9609
|
-
(0,
|
|
9869
|
+
(0, import_langchain52.anthropicPromptCachingMiddleware)({
|
|
9610
9870
|
unsupportedModelBehavior: "ignore"
|
|
9611
9871
|
}),
|
|
9612
9872
|
// Subagent middleware: Patches tool calls for compatibility
|
|
@@ -9617,23 +9877,23 @@ ${BASE_PROMPT}` : BASE_PROMPT;
|
|
|
9617
9877
|
generalPurposeAgent: false
|
|
9618
9878
|
}),
|
|
9619
9879
|
// Automatically summarizes conversation history when token limits are approached
|
|
9620
|
-
(0,
|
|
9880
|
+
(0, import_langchain52.summarizationMiddleware)({
|
|
9621
9881
|
model,
|
|
9622
9882
|
trigger: { tokens: 17e4 },
|
|
9623
9883
|
keep: { messages: 6 }
|
|
9624
9884
|
}),
|
|
9625
9885
|
// Enables Anthropic prompt caching for improved performance and reduced costs
|
|
9626
|
-
(0,
|
|
9886
|
+
(0, import_langchain52.anthropicPromptCachingMiddleware)({
|
|
9627
9887
|
unsupportedModelBehavior: "ignore"
|
|
9628
9888
|
}),
|
|
9629
9889
|
// Patches tool calls to ensure compatibility across different model providers
|
|
9630
9890
|
createPatchToolCallsMiddleware()
|
|
9631
9891
|
];
|
|
9632
9892
|
if (interruptOn) {
|
|
9633
|
-
middleware.push((0,
|
|
9893
|
+
middleware.push((0, import_langchain52.humanInTheLoopMiddleware)({ interruptOn }));
|
|
9634
9894
|
}
|
|
9635
9895
|
middleware.push(...customMiddleware);
|
|
9636
|
-
return (0,
|
|
9896
|
+
return (0, import_langchain52.createAgent)({
|
|
9637
9897
|
model,
|
|
9638
9898
|
systemPrompt: finalSystemPrompt,
|
|
9639
9899
|
tools,
|
|
@@ -9691,7 +9951,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
9691
9951
|
const tools = params.tools.map((t) => {
|
|
9692
9952
|
const toolClient = getToolClient(t.key);
|
|
9693
9953
|
return toolClient;
|
|
9694
|
-
}).filter((
|
|
9954
|
+
}).filter((tool48) => tool48 !== void 0);
|
|
9695
9955
|
const subagents = params.subAgents.map((sa) => {
|
|
9696
9956
|
if (sa.client) {
|
|
9697
9957
|
return {
|
|
@@ -9732,7 +9992,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
9732
9992
|
|
|
9733
9993
|
// src/agent_team/agent_team.ts
|
|
9734
9994
|
var import_v35 = require("zod/v3");
|
|
9735
|
-
var
|
|
9995
|
+
var import_langchain55 = require("langchain");
|
|
9736
9996
|
|
|
9737
9997
|
// src/agent_team/types.ts
|
|
9738
9998
|
var TaskStatus = /* @__PURE__ */ ((TaskStatus3) => {
|
|
@@ -10168,14 +10428,14 @@ var InMemoryMailboxStore = class {
|
|
|
10168
10428
|
|
|
10169
10429
|
// src/agent_team/middleware/team.ts
|
|
10170
10430
|
var import_v34 = require("zod/v3");
|
|
10171
|
-
var
|
|
10172
|
-
var
|
|
10431
|
+
var import_langchain54 = require("langchain");
|
|
10432
|
+
var import_langgraph11 = require("@langchain/langgraph");
|
|
10173
10433
|
var import_uuid = require("uuid");
|
|
10174
10434
|
|
|
10175
10435
|
// src/agent_team/middleware/teammate_tools.ts
|
|
10176
10436
|
var import_v33 = require("zod/v3");
|
|
10177
|
-
var
|
|
10178
|
-
var
|
|
10437
|
+
var import_langchain53 = require("langchain");
|
|
10438
|
+
var import_langgraph10 = require("@langchain/langgraph");
|
|
10179
10439
|
|
|
10180
10440
|
// src/agent_team/middleware/formatMessages.ts
|
|
10181
10441
|
function formatMessagesAsMarkdown(msgs) {
|
|
@@ -10199,7 +10459,7 @@ ${meta}${body}`;
|
|
|
10199
10459
|
// src/agent_team/middleware/teammate_tools.ts
|
|
10200
10460
|
function createTeammateTools(options) {
|
|
10201
10461
|
const { teamId, agentId, taskListStore, mailboxStore } = options;
|
|
10202
|
-
const claimTaskTool = (0,
|
|
10462
|
+
const claimTaskTool = (0, import_langchain53.tool)(
|
|
10203
10463
|
async (input) => {
|
|
10204
10464
|
const task = await taskListStore.claimTaskById(
|
|
10205
10465
|
teamId,
|
|
@@ -10229,7 +10489,7 @@ function createTeammateTools(options) {
|
|
|
10229
10489
|
})
|
|
10230
10490
|
}
|
|
10231
10491
|
);
|
|
10232
|
-
const completeTaskTool = (0,
|
|
10492
|
+
const completeTaskTool = (0, import_langchain53.tool)(
|
|
10233
10493
|
async (input) => {
|
|
10234
10494
|
const task = await taskListStore.completeTask(
|
|
10235
10495
|
teamId,
|
|
@@ -10256,7 +10516,7 @@ function createTeammateTools(options) {
|
|
|
10256
10516
|
})
|
|
10257
10517
|
}
|
|
10258
10518
|
);
|
|
10259
|
-
const failTaskTool = (0,
|
|
10519
|
+
const failTaskTool = (0, import_langchain53.tool)(
|
|
10260
10520
|
async (input) => {
|
|
10261
10521
|
const task = await taskListStore.failTask(
|
|
10262
10522
|
teamId,
|
|
@@ -10283,7 +10543,7 @@ function createTeammateTools(options) {
|
|
|
10283
10543
|
})
|
|
10284
10544
|
}
|
|
10285
10545
|
);
|
|
10286
|
-
const sendMessageTool = (0,
|
|
10546
|
+
const sendMessageTool = (0, import_langchain53.tool)(
|
|
10287
10547
|
async (input) => {
|
|
10288
10548
|
await mailboxStore.sendMessage(
|
|
10289
10549
|
teamId,
|
|
@@ -10321,7 +10581,7 @@ function createTeammateTools(options) {
|
|
|
10321
10581
|
read: msg.read
|
|
10322
10582
|
}));
|
|
10323
10583
|
};
|
|
10324
|
-
const readMessagesTool = (0,
|
|
10584
|
+
const readMessagesTool = (0, import_langchain53.tool)(
|
|
10325
10585
|
async (input, config) => {
|
|
10326
10586
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
10327
10587
|
for (const msg of msgs2) {
|
|
@@ -10333,12 +10593,12 @@ function createTeammateTools(options) {
|
|
|
10333
10593
|
if (msgs.length > 0) {
|
|
10334
10594
|
const formatted2 = await formatAndMarkAsRead(msgs);
|
|
10335
10595
|
const relevantMsgs2 = await getRelevantMessagesForState();
|
|
10336
|
-
const toolMessage2 = new
|
|
10596
|
+
const toolMessage2 = new import_langchain53.ToolMessage({
|
|
10337
10597
|
content: formatted2,
|
|
10338
10598
|
tool_call_id: config.toolCall?.id,
|
|
10339
10599
|
name: "read_messages"
|
|
10340
10600
|
});
|
|
10341
|
-
return new
|
|
10601
|
+
return new import_langgraph10.Command({
|
|
10342
10602
|
update: { team_mailbox: relevantMsgs2, messages: [toolMessage2] }
|
|
10343
10603
|
});
|
|
10344
10604
|
}
|
|
@@ -10358,22 +10618,22 @@ function createTeammateTools(options) {
|
|
|
10358
10618
|
});
|
|
10359
10619
|
const relevantMsgs = await getRelevantMessagesForState();
|
|
10360
10620
|
if (msgs.length === 0) {
|
|
10361
|
-
const toolMessage2 = new
|
|
10621
|
+
const toolMessage2 = new import_langchain53.ToolMessage({
|
|
10362
10622
|
content: "No unread messages.",
|
|
10363
10623
|
tool_call_id: config.toolCall?.id,
|
|
10364
10624
|
name: "read_messages"
|
|
10365
10625
|
});
|
|
10366
|
-
return new
|
|
10626
|
+
return new import_langgraph10.Command({
|
|
10367
10627
|
update: { team_mailbox: relevantMsgs, messages: [toolMessage2] }
|
|
10368
10628
|
});
|
|
10369
10629
|
}
|
|
10370
10630
|
const formatted = await formatAndMarkAsRead(msgs);
|
|
10371
|
-
const toolMessage = new
|
|
10631
|
+
const toolMessage = new import_langchain53.ToolMessage({
|
|
10372
10632
|
content: formatted,
|
|
10373
10633
|
tool_call_id: config.toolCall?.id,
|
|
10374
10634
|
name: "read_messages"
|
|
10375
10635
|
});
|
|
10376
|
-
return new
|
|
10636
|
+
return new import_langgraph10.Command({
|
|
10377
10637
|
update: { team_mailbox: relevantMsgs, messages: [toolMessage] }
|
|
10378
10638
|
});
|
|
10379
10639
|
},
|
|
@@ -10383,7 +10643,7 @@ function createTeammateTools(options) {
|
|
|
10383
10643
|
schema: import_v33.z.object({})
|
|
10384
10644
|
}
|
|
10385
10645
|
);
|
|
10386
|
-
const checkTasksTool = (0,
|
|
10646
|
+
const checkTasksTool = (0, import_langchain53.tool)(
|
|
10387
10647
|
async () => {
|
|
10388
10648
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
10389
10649
|
return formatTaskSummary(tasks);
|
|
@@ -10394,7 +10654,7 @@ function createTeammateTools(options) {
|
|
|
10394
10654
|
schema: import_v33.z.object({})
|
|
10395
10655
|
}
|
|
10396
10656
|
);
|
|
10397
|
-
const broadcastMessageTool = (0,
|
|
10657
|
+
const broadcastMessageTool = (0, import_langchain53.tool)(
|
|
10398
10658
|
async (input) => {
|
|
10399
10659
|
const allAgents = await mailboxStore.getRegisteredAgents(teamId);
|
|
10400
10660
|
const recipients = allAgents.filter((a) => a !== agentId);
|
|
@@ -10579,7 +10839,7 @@ You have access to these tools:
|
|
|
10579
10839
|
- \`read_messages\`: Read messages from team_lead or teammates
|
|
10580
10840
|
- \`check_tasks\`: Get current status of all tasks in the team`;
|
|
10581
10841
|
const assistantId = getTeammateAssistantId(ctx.teamId, spec.name);
|
|
10582
|
-
agent = (0,
|
|
10842
|
+
agent = (0, import_langchain54.createAgent)({
|
|
10583
10843
|
model: spec.model ?? ctx.defaultModel,
|
|
10584
10844
|
systemPrompt: teammatePrompt,
|
|
10585
10845
|
tools: allTools,
|
|
@@ -10637,12 +10897,12 @@ async function spawnTeammate(options) {
|
|
|
10637
10897
|
function createTeamMiddleware(options) {
|
|
10638
10898
|
const { teamConfig, taskListStore, mailboxStore } = options;
|
|
10639
10899
|
const defaultModel = teamConfig.model ?? "claude-sonnet-4-5-20250929";
|
|
10640
|
-
const createTeamTool = (0,
|
|
10900
|
+
const createTeamTool = (0, import_langchain54.tool)(
|
|
10641
10901
|
async (input, config) => {
|
|
10642
|
-
const state = (0,
|
|
10902
|
+
const state = (0, import_langgraph11.getCurrentTaskInput)();
|
|
10643
10903
|
if (state?.team?.teamId) {
|
|
10644
10904
|
const existingId = state.team.teamId;
|
|
10645
|
-
const msg = new
|
|
10905
|
+
const msg = new import_langchain54.ToolMessage({
|
|
10646
10906
|
content: `A team is already active (id: ${existingId}). Use this team_id for \`check_tasks\`, \`read_messages\`, \`add_tasks\`, \`send_message\`, \`assign_task\`, \`set_task_status\`, and \`set_task_dependencies\`. Do not call \`create_team\` again unless you need a fresh team for a new objective.`,
|
|
10647
10907
|
tool_call_id: config.toolCall?.id,
|
|
10648
10908
|
name: "create_team"
|
|
@@ -10727,7 +10987,7 @@ Teammates are now working in the background. Keep calling \`check_tasks\` and \`
|
|
|
10727
10987
|
\`\`\`json
|
|
10728
10988
|
${teamJson}
|
|
10729
10989
|
\`\`\``;
|
|
10730
|
-
const toolMessage = new
|
|
10990
|
+
const toolMessage = new import_langchain54.ToolMessage({
|
|
10731
10991
|
content: summary,
|
|
10732
10992
|
tool_call_id: config.toolCall?.id,
|
|
10733
10993
|
name: "create_team"
|
|
@@ -10748,7 +11008,7 @@ ${teamJson}
|
|
|
10748
11008
|
})),
|
|
10749
11009
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
10750
11010
|
};
|
|
10751
|
-
return new
|
|
11011
|
+
return new import_langgraph11.Command({
|
|
10752
11012
|
update: { team: teamState, messages: [toolMessage] }
|
|
10753
11013
|
});
|
|
10754
11014
|
},
|
|
@@ -10808,11 +11068,11 @@ After calling create_team, you MUST:
|
|
|
10808
11068
|
}
|
|
10809
11069
|
);
|
|
10810
11070
|
const resolveTeamId = () => {
|
|
10811
|
-
const state = (0,
|
|
11071
|
+
const state = (0, import_langgraph11.getCurrentTaskInput)();
|
|
10812
11072
|
if (state?.team?.teamId) return state.team.teamId;
|
|
10813
11073
|
throw new Error("No team_id provided and no team in state. Call create_team first.");
|
|
10814
11074
|
};
|
|
10815
|
-
const addTasksTool = (0,
|
|
11075
|
+
const addTasksTool = (0, import_langchain54.tool)(
|
|
10816
11076
|
async (input, config) => {
|
|
10817
11077
|
const teamId = resolveTeamId();
|
|
10818
11078
|
const created = await taskListStore.addTasks(
|
|
@@ -10826,7 +11086,7 @@ After calling create_team, you MUST:
|
|
|
10826
11086
|
}))
|
|
10827
11087
|
);
|
|
10828
11088
|
const summary = created.map((t) => `- ${t.id}: "${t.title}"`).join("\n");
|
|
10829
|
-
return new
|
|
11089
|
+
return new import_langchain54.ToolMessage({
|
|
10830
11090
|
content: `Added ${created.length} task(s) to team ${teamId}:
|
|
10831
11091
|
${summary}
|
|
10832
11092
|
Sleeping teammates will wake up and claim these.`,
|
|
@@ -10877,20 +11137,20 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
10877
11137
|
})
|
|
10878
11138
|
}
|
|
10879
11139
|
);
|
|
10880
|
-
const assignTaskTool = (0,
|
|
11140
|
+
const assignTaskTool = (0, import_langchain54.tool)(
|
|
10881
11141
|
async (input, config) => {
|
|
10882
11142
|
const teamId = resolveTeamId();
|
|
10883
11143
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
10884
11144
|
assignee: input.assignee
|
|
10885
11145
|
});
|
|
10886
11146
|
if (!task) {
|
|
10887
|
-
return new
|
|
11147
|
+
return new import_langchain54.ToolMessage({
|
|
10888
11148
|
content: `Task ${input.task_id} not found in team ${teamId}.`,
|
|
10889
11149
|
tool_call_id: config.toolCall?.id,
|
|
10890
11150
|
name: "assign_task"
|
|
10891
11151
|
});
|
|
10892
11152
|
}
|
|
10893
|
-
return new
|
|
11153
|
+
return new import_langchain54.ToolMessage({
|
|
10894
11154
|
content: `Task "${task.title}" (${task.id}) assigned to ${input.assignee}.`,
|
|
10895
11155
|
tool_call_id: config.toolCall?.id,
|
|
10896
11156
|
name: "assign_task"
|
|
@@ -10905,20 +11165,20 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
10905
11165
|
})
|
|
10906
11166
|
}
|
|
10907
11167
|
);
|
|
10908
|
-
const setTaskStatusTool = (0,
|
|
11168
|
+
const setTaskStatusTool = (0, import_langchain54.tool)(
|
|
10909
11169
|
async (input, config) => {
|
|
10910
11170
|
const teamId = resolveTeamId();
|
|
10911
11171
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
10912
11172
|
status: input.status
|
|
10913
11173
|
});
|
|
10914
11174
|
if (!task) {
|
|
10915
|
-
return new
|
|
11175
|
+
return new import_langchain54.ToolMessage({
|
|
10916
11176
|
content: `Task ${input.task_id} not found in team ${teamId}.`,
|
|
10917
11177
|
tool_call_id: config.toolCall?.id,
|
|
10918
11178
|
name: "set_task_status"
|
|
10919
11179
|
});
|
|
10920
11180
|
}
|
|
10921
|
-
return new
|
|
11181
|
+
return new import_langchain54.ToolMessage({
|
|
10922
11182
|
content: `Task "${task.title}" (${task.id}) status set to ${input.status}.`,
|
|
10923
11183
|
tool_call_id: config.toolCall?.id,
|
|
10924
11184
|
name: "set_task_status"
|
|
@@ -10933,20 +11193,20 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
10933
11193
|
})
|
|
10934
11194
|
}
|
|
10935
11195
|
);
|
|
10936
|
-
const setTaskDependenciesTool = (0,
|
|
11196
|
+
const setTaskDependenciesTool = (0, import_langchain54.tool)(
|
|
10937
11197
|
async (input, config) => {
|
|
10938
11198
|
const teamId = resolveTeamId();
|
|
10939
11199
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
10940
11200
|
dependencies: input.dependencies
|
|
10941
11201
|
});
|
|
10942
11202
|
if (!task) {
|
|
10943
|
-
return new
|
|
11203
|
+
return new import_langchain54.ToolMessage({
|
|
10944
11204
|
content: `Task ${input.task_id} not found in team ${teamId}.`,
|
|
10945
11205
|
tool_call_id: config.toolCall?.id,
|
|
10946
11206
|
name: "set_task_dependencies"
|
|
10947
11207
|
});
|
|
10948
11208
|
}
|
|
10949
|
-
return new
|
|
11209
|
+
return new import_langchain54.ToolMessage({
|
|
10950
11210
|
content: `Task "${task.title}" (${task.id}) dependencies set to [${input.dependencies.join(", ")}].`,
|
|
10951
11211
|
tool_call_id: config.toolCall?.id,
|
|
10952
11212
|
name: "set_task_dependencies"
|
|
@@ -10961,16 +11221,16 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
10961
11221
|
})
|
|
10962
11222
|
}
|
|
10963
11223
|
);
|
|
10964
|
-
const checkTasksTool = (0,
|
|
11224
|
+
const checkTasksTool = (0, import_langchain54.tool)(
|
|
10965
11225
|
async (input, config) => {
|
|
10966
11226
|
const teamId = resolveTeamId();
|
|
10967
11227
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
10968
11228
|
const tasksSnapshot = tasks;
|
|
10969
|
-
return new
|
|
11229
|
+
return new import_langgraph11.Command({
|
|
10970
11230
|
update: {
|
|
10971
11231
|
tasks: tasksSnapshot,
|
|
10972
11232
|
messages: [
|
|
10973
|
-
new
|
|
11233
|
+
new import_langchain54.ToolMessage({
|
|
10974
11234
|
content: formatTaskSummary(tasks),
|
|
10975
11235
|
tool_call_id: config.toolCall?.id,
|
|
10976
11236
|
name: "check_tasks"
|
|
@@ -11006,7 +11266,7 @@ Task Status Values:
|
|
|
11006
11266
|
})
|
|
11007
11267
|
}
|
|
11008
11268
|
);
|
|
11009
|
-
const sendMessageTool = (0,
|
|
11269
|
+
const sendMessageTool = (0, import_langchain54.tool)(
|
|
11010
11270
|
async (input, config) => {
|
|
11011
11271
|
const teamId = resolveTeamId();
|
|
11012
11272
|
await mailboxStore.sendMessage(
|
|
@@ -11016,7 +11276,7 @@ Task Status Values:
|
|
|
11016
11276
|
input.content,
|
|
11017
11277
|
"direct_message" /* DIRECT_MESSAGE */
|
|
11018
11278
|
);
|
|
11019
|
-
return new
|
|
11279
|
+
return new import_langchain54.ToolMessage({
|
|
11020
11280
|
content: `Message sent to ${input.to}.`,
|
|
11021
11281
|
tool_call_id: config.toolCall?.id,
|
|
11022
11282
|
name: "send_message"
|
|
@@ -11031,7 +11291,7 @@ Task Status Values:
|
|
|
11031
11291
|
})
|
|
11032
11292
|
}
|
|
11033
11293
|
);
|
|
11034
|
-
const readMessagesTool = (0,
|
|
11294
|
+
const readMessagesTool = (0, import_langchain54.tool)(
|
|
11035
11295
|
async (input, config) => {
|
|
11036
11296
|
const teamId = resolveTeamId();
|
|
11037
11297
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
@@ -11059,12 +11319,12 @@ Task Status Values:
|
|
|
11059
11319
|
if (msgs.length > 0) {
|
|
11060
11320
|
const formatted2 = await formatAndMarkAsRead(msgs);
|
|
11061
11321
|
const allTeamMessages2 = await getAllTeamMessagesForState();
|
|
11062
|
-
const toolMessage2 = new
|
|
11322
|
+
const toolMessage2 = new import_langchain54.ToolMessage({
|
|
11063
11323
|
content: formatted2,
|
|
11064
11324
|
tool_call_id: config.toolCall?.id,
|
|
11065
11325
|
name: "read_messages"
|
|
11066
11326
|
});
|
|
11067
|
-
return new
|
|
11327
|
+
return new import_langgraph11.Command({
|
|
11068
11328
|
update: { team_mailbox: allTeamMessages2, messages: [toolMessage2] }
|
|
11069
11329
|
});
|
|
11070
11330
|
}
|
|
@@ -11091,22 +11351,22 @@ Task Status Values:
|
|
|
11091
11351
|
);
|
|
11092
11352
|
const allTeamMessages = await getAllTeamMessagesForState();
|
|
11093
11353
|
if (msgs.length === 0) {
|
|
11094
|
-
const toolMessage2 = new
|
|
11354
|
+
const toolMessage2 = new import_langchain54.ToolMessage({
|
|
11095
11355
|
content: "No unread messages from teammates.",
|
|
11096
11356
|
tool_call_id: config.toolCall?.id,
|
|
11097
11357
|
name: "read_messages"
|
|
11098
11358
|
});
|
|
11099
|
-
return new
|
|
11359
|
+
return new import_langgraph11.Command({
|
|
11100
11360
|
update: { team_mailbox: allTeamMessages, messages: [toolMessage2] }
|
|
11101
11361
|
});
|
|
11102
11362
|
}
|
|
11103
11363
|
const formatted = await formatAndMarkAsRead(msgs);
|
|
11104
|
-
const toolMessage = new
|
|
11364
|
+
const toolMessage = new import_langchain54.ToolMessage({
|
|
11105
11365
|
content: formatted,
|
|
11106
11366
|
tool_call_id: config.toolCall?.id,
|
|
11107
11367
|
name: "read_messages"
|
|
11108
11368
|
});
|
|
11109
|
-
return new
|
|
11369
|
+
return new import_langgraph11.Command({
|
|
11110
11370
|
update: { team_mailbox: allTeamMessages, messages: [toolMessage] }
|
|
11111
11371
|
});
|
|
11112
11372
|
},
|
|
@@ -11118,7 +11378,7 @@ Task Status Values:
|
|
|
11118
11378
|
})
|
|
11119
11379
|
}
|
|
11120
11380
|
);
|
|
11121
|
-
const disbandTeamTool = (0,
|
|
11381
|
+
const disbandTeamTool = (0, import_langchain54.tool)(
|
|
11122
11382
|
async (input, config) => {
|
|
11123
11383
|
const teamId = resolveTeamId();
|
|
11124
11384
|
await mailboxStore.broadcastMessage(
|
|
@@ -11128,7 +11388,7 @@ Task Status Values:
|
|
|
11128
11388
|
"shutdown_request" /* SHUTDOWN_REQUEST */
|
|
11129
11389
|
);
|
|
11130
11390
|
await new Promise((r) => setTimeout(r, 2e3));
|
|
11131
|
-
return new
|
|
11391
|
+
return new import_langchain54.ToolMessage({
|
|
11132
11392
|
content: `Team ${teamId} has been disbanded. All teammates notified and resources cleaned up.`,
|
|
11133
11393
|
tool_call_id: config.toolCall?.id,
|
|
11134
11394
|
name: "disband_team"
|
|
@@ -11139,7 +11399,7 @@ Task Status Values:
|
|
|
11139
11399
|
description: "Disband a team when all work is done. Before calling: (1) Call check_tasks to verify no tasks are still pending/in_progress; (2) if any are, discuss with the team via read_messages and broadcast_message/send_message whether to continue or stop/cancel them; (3) only after alignment (all tasks completed/failed or explicitly stopped), then call this tool. This will: 1) Send a shutdown message to all teammates, 2) Wait briefly for them to clean up, 3) Clear all tasks and messages. Omit team_id to use the active team from state."
|
|
11140
11400
|
}
|
|
11141
11401
|
);
|
|
11142
|
-
const broadcastMessageTool = (0,
|
|
11402
|
+
const broadcastMessageTool = (0, import_langchain54.tool)(
|
|
11143
11403
|
async (input, config) => {
|
|
11144
11404
|
const teamId = resolveTeamId();
|
|
11145
11405
|
await mailboxStore.broadcastMessage(
|
|
@@ -11148,7 +11408,7 @@ Task Status Values:
|
|
|
11148
11408
|
input.content,
|
|
11149
11409
|
"broadcast" /* BROADCAST */
|
|
11150
11410
|
);
|
|
11151
|
-
return new
|
|
11411
|
+
return new import_langchain54.ToolMessage({
|
|
11152
11412
|
content: `Broadcast message sent to all teammates.`,
|
|
11153
11413
|
tool_call_id: config.toolCall?.id,
|
|
11154
11414
|
name: "broadcast_message"
|
|
@@ -11162,7 +11422,7 @@ Task Status Values:
|
|
|
11162
11422
|
})
|
|
11163
11423
|
}
|
|
11164
11424
|
);
|
|
11165
|
-
return (0,
|
|
11425
|
+
return (0, import_langchain54.createMiddleware)({
|
|
11166
11426
|
name: "teamMiddleware",
|
|
11167
11427
|
tools: [
|
|
11168
11428
|
createTeamTool,
|
|
@@ -11270,7 +11530,7 @@ function createAgentTeam(config) {
|
|
|
11270
11530
|
];
|
|
11271
11531
|
const systemPrompt = config.systemPrompt + "\n\n" + TEAM_LEAD_BASE_PROMPT;
|
|
11272
11532
|
const stateSchema2 = createReactAgentSchema(TEAM_STATE_SCHEMA);
|
|
11273
|
-
return (0,
|
|
11533
|
+
return (0, import_langchain55.createAgent)({
|
|
11274
11534
|
model: config.model ?? "claude-sonnet-4-5-20250929",
|
|
11275
11535
|
systemPrompt,
|
|
11276
11536
|
tools: [],
|
|
@@ -11300,7 +11560,7 @@ var TeamAgentGraphBuilder = class {
|
|
|
11300
11560
|
const tools = params.tools.map((t) => {
|
|
11301
11561
|
const toolClient = getToolClient(t.key);
|
|
11302
11562
|
return toolClient;
|
|
11303
|
-
}).filter((
|
|
11563
|
+
}).filter((tool48) => tool48 !== void 0);
|
|
11304
11564
|
const teammates = params.subAgents.map((sa) => {
|
|
11305
11565
|
const baseConfig = sa.config;
|
|
11306
11566
|
return {
|
|
@@ -13960,10 +14220,10 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
13960
14220
|
}
|
|
13961
14221
|
const tools = await this.getAllTools();
|
|
13962
14222
|
console.log(`[MCP] Registering ${tools.length} tools to Tool Lattice...`);
|
|
13963
|
-
for (const
|
|
13964
|
-
const toolKey = prefix ? `${prefix}_${
|
|
13965
|
-
|
|
13966
|
-
toolLatticeManager.registerExistingTool(toolKey,
|
|
14223
|
+
for (const tool48 of tools) {
|
|
14224
|
+
const toolKey = prefix ? `${prefix}_${tool48.name}` : tool48.name;
|
|
14225
|
+
tool48.name = toolKey;
|
|
14226
|
+
toolLatticeManager.registerExistingTool(toolKey, tool48);
|
|
13967
14227
|
console.log(`[MCP] Registered tool: ${toolKey}`);
|
|
13968
14228
|
}
|
|
13969
14229
|
console.log(`[MCP] Successfully registered ${tools.length} tools to Tool Lattice`);
|