@axiom-lattice/core 2.1.21 → 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 +61 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -5999,6 +5999,26 @@ var AgentParamsBuilder = class {
|
|
|
5999
5999
|
}
|
|
6000
6000
|
};
|
|
6001
6001
|
|
|
6002
|
+
// src/agent_lattice/utils/mergeAgentConfig.ts
|
|
6003
|
+
var NON_INHERITABLE_FIELDS = /* @__PURE__ */ new Set([
|
|
6004
|
+
"key",
|
|
6005
|
+
"extendsAgent"
|
|
6006
|
+
]);
|
|
6007
|
+
function mergeAgentConfig(parent, child) {
|
|
6008
|
+
const merged = { ...parent };
|
|
6009
|
+
for (const [key, value] of Object.entries(child)) {
|
|
6010
|
+
if (NON_INHERITABLE_FIELDS.has(key)) {
|
|
6011
|
+
continue;
|
|
6012
|
+
}
|
|
6013
|
+
if (value !== void 0) {
|
|
6014
|
+
merged[key] = value;
|
|
6015
|
+
}
|
|
6016
|
+
}
|
|
6017
|
+
merged.key = child.key;
|
|
6018
|
+
delete merged.extendsAgent;
|
|
6019
|
+
return merged;
|
|
6020
|
+
}
|
|
6021
|
+
|
|
6002
6022
|
// src/agent_lattice/AgentLatticeManager.ts
|
|
6003
6023
|
function assistantToConfig(assistant) {
|
|
6004
6024
|
const graphDef = typeof assistant.graphDefinition === "object" && assistant.graphDefinition !== null ? assistant.graphDefinition : {};
|
|
@@ -6154,6 +6174,39 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
|
|
|
6154
6174
|
return false;
|
|
6155
6175
|
}
|
|
6156
6176
|
}
|
|
6177
|
+
/**
|
|
6178
|
+
* Resolve inherited config by walking the extendsAgent chain.
|
|
6179
|
+
*
|
|
6180
|
+
* If config.extendsAgent is set, fetches the parent config, recursively
|
|
6181
|
+
* resolves the parent's own inheritance, then merges parent with child
|
|
6182
|
+
* (child's explicit fields override parent's).
|
|
6183
|
+
*
|
|
6184
|
+
* @param config - The agent config to resolve
|
|
6185
|
+
* @param visited - Set of visited keys to detect circular inheritance
|
|
6186
|
+
* @returns A fully resolved AgentConfig with inheritance applied
|
|
6187
|
+
*/
|
|
6188
|
+
resolveInheritedConfig(config, visited = /* @__PURE__ */ new Set()) {
|
|
6189
|
+
if (!config.extendsAgent) {
|
|
6190
|
+
return config;
|
|
6191
|
+
}
|
|
6192
|
+
if (visited.has(config.key)) {
|
|
6193
|
+
throw new Error(
|
|
6194
|
+
`Circular agent inheritance detected: "${config.key}" already visited in chain [${[...visited].join(" -> ")}]`
|
|
6195
|
+
);
|
|
6196
|
+
}
|
|
6197
|
+
visited.add(config.key);
|
|
6198
|
+
const parentLattice = this.getAgentLattice(config.extendsAgent);
|
|
6199
|
+
if (!parentLattice) {
|
|
6200
|
+
throw new Error(
|
|
6201
|
+
`Parent agent "${config.extendsAgent}" not found when resolving inheritance for "${config.key}"`
|
|
6202
|
+
);
|
|
6203
|
+
}
|
|
6204
|
+
const resolvedParent = this.resolveInheritedConfig(
|
|
6205
|
+
parentLattice.config,
|
|
6206
|
+
visited
|
|
6207
|
+
);
|
|
6208
|
+
return mergeAgentConfig(resolvedParent, config);
|
|
6209
|
+
}
|
|
6157
6210
|
/**
|
|
6158
6211
|
* 构建Agent参数
|
|
6159
6212
|
*
|
|
@@ -6176,10 +6229,15 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
|
|
|
6176
6229
|
* @returns AgentClient instance
|
|
6177
6230
|
*/
|
|
6178
6231
|
createAgentClientFromConfig(agentLattice, options) {
|
|
6232
|
+
const resolvedConfig = this.resolveInheritedConfig(agentLattice.config);
|
|
6233
|
+
const resolvedLattice = {
|
|
6234
|
+
...agentLattice,
|
|
6235
|
+
config: resolvedConfig
|
|
6236
|
+
};
|
|
6179
6237
|
const factory = AgentGraphBuilderFactory.getInstance();
|
|
6180
|
-
const builder = factory.getBuilder(
|
|
6181
|
-
const params = this.buildAgentParams(
|
|
6182
|
-
return builder.build(
|
|
6238
|
+
const builder = factory.getBuilder(resolvedConfig.type);
|
|
6239
|
+
const params = this.buildAgentParams(resolvedLattice, options);
|
|
6240
|
+
return builder.build(resolvedLattice, params);
|
|
6183
6241
|
}
|
|
6184
6242
|
/**
|
|
6185
6243
|
* 初始化Agent客户端
|