@axiom-lattice/core 2.1.20 → 2.1.22
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 +62 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -5
- 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
|
@@ -5926,8 +5926,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
5926
5926
|
* 根据 middleware 配置创建 middlewares
|
|
5927
5927
|
*/
|
|
5928
5928
|
createMiddlewares(middlewareConfigs) {
|
|
5929
|
-
|
|
5930
|
-
return createCommonMiddlewares(middlewareConfigs, filesystemBackend);
|
|
5929
|
+
return createCommonMiddlewares(middlewareConfigs);
|
|
5931
5930
|
}
|
|
5932
5931
|
/**
|
|
5933
5932
|
* 构建Deep Agent Graph
|
|
@@ -6091,6 +6090,26 @@ var AgentParamsBuilder = class {
|
|
|
6091
6090
|
}
|
|
6092
6091
|
};
|
|
6093
6092
|
|
|
6093
|
+
// src/agent_lattice/utils/mergeAgentConfig.ts
|
|
6094
|
+
var NON_INHERITABLE_FIELDS = /* @__PURE__ */ new Set([
|
|
6095
|
+
"key",
|
|
6096
|
+
"extendsAgent"
|
|
6097
|
+
]);
|
|
6098
|
+
function mergeAgentConfig(parent, child) {
|
|
6099
|
+
const merged = { ...parent };
|
|
6100
|
+
for (const [key, value] of Object.entries(child)) {
|
|
6101
|
+
if (NON_INHERITABLE_FIELDS.has(key)) {
|
|
6102
|
+
continue;
|
|
6103
|
+
}
|
|
6104
|
+
if (value !== void 0) {
|
|
6105
|
+
merged[key] = value;
|
|
6106
|
+
}
|
|
6107
|
+
}
|
|
6108
|
+
merged.key = child.key;
|
|
6109
|
+
delete merged.extendsAgent;
|
|
6110
|
+
return merged;
|
|
6111
|
+
}
|
|
6112
|
+
|
|
6094
6113
|
// src/agent_lattice/AgentLatticeManager.ts
|
|
6095
6114
|
function assistantToConfig(assistant) {
|
|
6096
6115
|
const graphDef = typeof assistant.graphDefinition === "object" && assistant.graphDefinition !== null ? assistant.graphDefinition : {};
|
|
@@ -6246,6 +6265,39 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
|
|
|
6246
6265
|
return false;
|
|
6247
6266
|
}
|
|
6248
6267
|
}
|
|
6268
|
+
/**
|
|
6269
|
+
* Resolve inherited config by walking the extendsAgent chain.
|
|
6270
|
+
*
|
|
6271
|
+
* If config.extendsAgent is set, fetches the parent config, recursively
|
|
6272
|
+
* resolves the parent's own inheritance, then merges parent with child
|
|
6273
|
+
* (child's explicit fields override parent's).
|
|
6274
|
+
*
|
|
6275
|
+
* @param config - The agent config to resolve
|
|
6276
|
+
* @param visited - Set of visited keys to detect circular inheritance
|
|
6277
|
+
* @returns A fully resolved AgentConfig with inheritance applied
|
|
6278
|
+
*/
|
|
6279
|
+
resolveInheritedConfig(config, visited = /* @__PURE__ */ new Set()) {
|
|
6280
|
+
if (!config.extendsAgent) {
|
|
6281
|
+
return config;
|
|
6282
|
+
}
|
|
6283
|
+
if (visited.has(config.key)) {
|
|
6284
|
+
throw new Error(
|
|
6285
|
+
`Circular agent inheritance detected: "${config.key}" already visited in chain [${[...visited].join(" -> ")}]`
|
|
6286
|
+
);
|
|
6287
|
+
}
|
|
6288
|
+
visited.add(config.key);
|
|
6289
|
+
const parentLattice = this.getAgentLattice(config.extendsAgent);
|
|
6290
|
+
if (!parentLattice) {
|
|
6291
|
+
throw new Error(
|
|
6292
|
+
`Parent agent "${config.extendsAgent}" not found when resolving inheritance for "${config.key}"`
|
|
6293
|
+
);
|
|
6294
|
+
}
|
|
6295
|
+
const resolvedParent = this.resolveInheritedConfig(
|
|
6296
|
+
parentLattice.config,
|
|
6297
|
+
visited
|
|
6298
|
+
);
|
|
6299
|
+
return mergeAgentConfig(resolvedParent, config);
|
|
6300
|
+
}
|
|
6249
6301
|
/**
|
|
6250
6302
|
* 构建Agent参数
|
|
6251
6303
|
*
|
|
@@ -6268,10 +6320,15 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
|
|
|
6268
6320
|
* @returns AgentClient instance
|
|
6269
6321
|
*/
|
|
6270
6322
|
createAgentClientFromConfig(agentLattice, options) {
|
|
6323
|
+
const resolvedConfig = this.resolveInheritedConfig(agentLattice.config);
|
|
6324
|
+
const resolvedLattice = {
|
|
6325
|
+
...agentLattice,
|
|
6326
|
+
config: resolvedConfig
|
|
6327
|
+
};
|
|
6271
6328
|
const factory = AgentGraphBuilderFactory.getInstance();
|
|
6272
|
-
const builder = factory.getBuilder(
|
|
6273
|
-
const params = this.buildAgentParams(
|
|
6274
|
-
return builder.build(
|
|
6329
|
+
const builder = factory.getBuilder(resolvedConfig.type);
|
|
6330
|
+
const params = this.buildAgentParams(resolvedLattice, options);
|
|
6331
|
+
return builder.build(resolvedLattice, params);
|
|
6275
6332
|
}
|
|
6276
6333
|
/**
|
|
6277
6334
|
* 初始化Agent客户端
|