@axiom-lattice/core 2.1.21 → 2.1.23
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 +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +97 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -605,6 +605,18 @@ declare class AgentLatticeManager extends BaseLatticeManager<AgentLattice> {
|
|
|
605
605
|
* @param input 输入参数
|
|
606
606
|
*/
|
|
607
607
|
validateAgentInput(key: string, input: any): boolean;
|
|
608
|
+
/**
|
|
609
|
+
* Resolve inherited config by walking the extendsAgent chain.
|
|
610
|
+
*
|
|
611
|
+
* If config.extendsAgent is set, fetches the parent config, recursively
|
|
612
|
+
* resolves the parent's own inheritance, then merges parent with child
|
|
613
|
+
* (child's explicit fields override parent's).
|
|
614
|
+
*
|
|
615
|
+
* @param config - The agent config to resolve
|
|
616
|
+
* @param visited - Set of visited keys to detect circular inheritance
|
|
617
|
+
* @returns A fully resolved AgentConfig with inheritance applied
|
|
618
|
+
*/
|
|
619
|
+
private resolveInheritedConfig;
|
|
608
620
|
/**
|
|
609
621
|
* 构建Agent参数
|
|
610
622
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -605,6 +605,18 @@ declare class AgentLatticeManager extends BaseLatticeManager<AgentLattice> {
|
|
|
605
605
|
* @param input 输入参数
|
|
606
606
|
*/
|
|
607
607
|
validateAgentInput(key: string, input: any): boolean;
|
|
608
|
+
/**
|
|
609
|
+
* Resolve inherited config by walking the extendsAgent chain.
|
|
610
|
+
*
|
|
611
|
+
* If config.extendsAgent is set, fetches the parent config, recursively
|
|
612
|
+
* resolves the parent's own inheritance, then merges parent with child
|
|
613
|
+
* (child's explicit fields override parent's).
|
|
614
|
+
*
|
|
615
|
+
* @param config - The agent config to resolve
|
|
616
|
+
* @param visited - Set of visited keys to detect circular inheritance
|
|
617
|
+
* @returns A fully resolved AgentConfig with inheritance applied
|
|
618
|
+
*/
|
|
619
|
+
private resolveInheritedConfig;
|
|
608
620
|
/**
|
|
609
621
|
* 构建Agent参数
|
|
610
622
|
*
|
package/dist/index.js
CHANGED
|
@@ -5331,7 +5331,7 @@ function returnCommandWithStateUpdate(result, toolCallId) {
|
|
|
5331
5331
|
...stateUpdate,
|
|
5332
5332
|
messages: [
|
|
5333
5333
|
new import_langchain37.ToolMessage({
|
|
5334
|
-
content: lastMessage?.content || "Task
|
|
5334
|
+
content: lastMessage?.content || "Task Failed to complete",
|
|
5335
5335
|
tool_call_id: toolCallId,
|
|
5336
5336
|
name: "task"
|
|
5337
5337
|
})
|
|
@@ -5412,28 +5412,42 @@ function createTaskTool(options) {
|
|
|
5412
5412
|
return (0, import_langchain37.tool)(
|
|
5413
5413
|
async (input, config) => {
|
|
5414
5414
|
const { description, subagent_type } = input;
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5415
|
+
try {
|
|
5416
|
+
if (!(subagent_type in subagentGraphs)) {
|
|
5417
|
+
const allowedTypes = Object.keys(subagentGraphs).map((k) => `\`${k}\``).join(", ");
|
|
5418
|
+
throw new Error(
|
|
5419
|
+
`Error: invoked agent of type ${subagent_type}, the only allowed types are ${allowedTypes}`
|
|
5420
|
+
);
|
|
5421
|
+
}
|
|
5422
|
+
const subagent = subagentGraphs[subagent_type];
|
|
5423
|
+
const currentState = (0, import_langgraph6.getCurrentTaskInput)();
|
|
5424
|
+
const subagentState = filterStateForSubagent(currentState);
|
|
5425
|
+
subagentState.messages = [new import_messages.HumanMessage({ content: description })];
|
|
5426
|
+
const subagent_thread_id = config.configurable?.thread_id + "____" + subagent_type + "_" + config.toolCall.id;
|
|
5427
|
+
console.log(subagent_thread_id);
|
|
5428
|
+
const workerResult = await agentWorkerGraph.invoke({
|
|
5429
|
+
assistant_id: subagent_type,
|
|
5430
|
+
thread_id: subagent_thread_id,
|
|
5431
|
+
input: { ...subagentState, message: description }
|
|
5432
|
+
});
|
|
5433
|
+
const result = workerResult.finalState?.values;
|
|
5434
|
+
if (!config.toolCall?.id) {
|
|
5435
|
+
throw new Error("Tool call ID is required for subagent invocation");
|
|
5436
|
+
}
|
|
5437
|
+
return returnCommandWithStateUpdate(result, config.toolCall.id);
|
|
5438
|
+
} catch (error) {
|
|
5439
|
+
return new import_langgraph6.Command({
|
|
5440
|
+
update: {
|
|
5441
|
+
messages: [
|
|
5442
|
+
new import_langchain37.ToolMessage({
|
|
5443
|
+
content: error instanceof Error ? error.message : "Task Failed to complete",
|
|
5444
|
+
tool_call_id: config.toolCall.id,
|
|
5445
|
+
name: "task"
|
|
5446
|
+
})
|
|
5447
|
+
]
|
|
5448
|
+
}
|
|
5449
|
+
});
|
|
5435
5450
|
}
|
|
5436
|
-
return returnCommandWithStateUpdate(result, config.toolCall.id);
|
|
5437
5451
|
},
|
|
5438
5452
|
{
|
|
5439
5453
|
name: "task",
|
|
@@ -6090,6 +6104,26 @@ var AgentParamsBuilder = class {
|
|
|
6090
6104
|
}
|
|
6091
6105
|
};
|
|
6092
6106
|
|
|
6107
|
+
// src/agent_lattice/utils/mergeAgentConfig.ts
|
|
6108
|
+
var NON_INHERITABLE_FIELDS = /* @__PURE__ */ new Set([
|
|
6109
|
+
"key",
|
|
6110
|
+
"extendsAgent"
|
|
6111
|
+
]);
|
|
6112
|
+
function mergeAgentConfig(parent, child) {
|
|
6113
|
+
const merged = { ...parent };
|
|
6114
|
+
for (const [key, value] of Object.entries(child)) {
|
|
6115
|
+
if (NON_INHERITABLE_FIELDS.has(key)) {
|
|
6116
|
+
continue;
|
|
6117
|
+
}
|
|
6118
|
+
if (value !== void 0) {
|
|
6119
|
+
merged[key] = value;
|
|
6120
|
+
}
|
|
6121
|
+
}
|
|
6122
|
+
merged.key = child.key;
|
|
6123
|
+
delete merged.extendsAgent;
|
|
6124
|
+
return merged;
|
|
6125
|
+
}
|
|
6126
|
+
|
|
6093
6127
|
// src/agent_lattice/AgentLatticeManager.ts
|
|
6094
6128
|
function assistantToConfig(assistant) {
|
|
6095
6129
|
const graphDef = typeof assistant.graphDefinition === "object" && assistant.graphDefinition !== null ? assistant.graphDefinition : {};
|
|
@@ -6245,6 +6279,39 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
|
|
|
6245
6279
|
return false;
|
|
6246
6280
|
}
|
|
6247
6281
|
}
|
|
6282
|
+
/**
|
|
6283
|
+
* Resolve inherited config by walking the extendsAgent chain.
|
|
6284
|
+
*
|
|
6285
|
+
* If config.extendsAgent is set, fetches the parent config, recursively
|
|
6286
|
+
* resolves the parent's own inheritance, then merges parent with child
|
|
6287
|
+
* (child's explicit fields override parent's).
|
|
6288
|
+
*
|
|
6289
|
+
* @param config - The agent config to resolve
|
|
6290
|
+
* @param visited - Set of visited keys to detect circular inheritance
|
|
6291
|
+
* @returns A fully resolved AgentConfig with inheritance applied
|
|
6292
|
+
*/
|
|
6293
|
+
resolveInheritedConfig(config, visited = /* @__PURE__ */ new Set()) {
|
|
6294
|
+
if (!config.extendsAgent) {
|
|
6295
|
+
return config;
|
|
6296
|
+
}
|
|
6297
|
+
if (visited.has(config.key)) {
|
|
6298
|
+
throw new Error(
|
|
6299
|
+
`Circular agent inheritance detected: "${config.key}" already visited in chain [${[...visited].join(" -> ")}]`
|
|
6300
|
+
);
|
|
6301
|
+
}
|
|
6302
|
+
visited.add(config.key);
|
|
6303
|
+
const parentLattice = this.getAgentLattice(config.extendsAgent);
|
|
6304
|
+
if (!parentLattice) {
|
|
6305
|
+
throw new Error(
|
|
6306
|
+
`Parent agent "${config.extendsAgent}" not found when resolving inheritance for "${config.key}"`
|
|
6307
|
+
);
|
|
6308
|
+
}
|
|
6309
|
+
const resolvedParent = this.resolveInheritedConfig(
|
|
6310
|
+
parentLattice.config,
|
|
6311
|
+
visited
|
|
6312
|
+
);
|
|
6313
|
+
return mergeAgentConfig(resolvedParent, config);
|
|
6314
|
+
}
|
|
6248
6315
|
/**
|
|
6249
6316
|
* 构建Agent参数
|
|
6250
6317
|
*
|
|
@@ -6267,10 +6334,15 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
|
|
|
6267
6334
|
* @returns AgentClient instance
|
|
6268
6335
|
*/
|
|
6269
6336
|
createAgentClientFromConfig(agentLattice, options) {
|
|
6337
|
+
const resolvedConfig = this.resolveInheritedConfig(agentLattice.config);
|
|
6338
|
+
const resolvedLattice = {
|
|
6339
|
+
...agentLattice,
|
|
6340
|
+
config: resolvedConfig
|
|
6341
|
+
};
|
|
6270
6342
|
const factory = AgentGraphBuilderFactory.getInstance();
|
|
6271
|
-
const builder = factory.getBuilder(
|
|
6272
|
-
const params = this.buildAgentParams(
|
|
6273
|
-
return builder.build(
|
|
6343
|
+
const builder = factory.getBuilder(resolvedConfig.type);
|
|
6344
|
+
const params = this.buildAgentParams(resolvedLattice, options);
|
|
6345
|
+
return builder.build(resolvedLattice, params);
|
|
6274
6346
|
}
|
|
6275
6347
|
/**
|
|
6276
6348
|
* 初始化Agent客户端
|