@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.mjs CHANGED
@@ -5831,8 +5831,7 @@ var DeepAgentGraphBuilder = class {
5831
5831
  * 根据 middleware 配置创建 middlewares
5832
5832
  */
5833
5833
  createMiddlewares(middlewareConfigs) {
5834
- const filesystemBackend = this.createFilesystemBackendFactory(middlewareConfigs);
5835
- return createCommonMiddlewares(middlewareConfigs, filesystemBackend);
5834
+ return createCommonMiddlewares(middlewareConfigs);
5836
5835
  }
5837
5836
  /**
5838
5837
  * 构建Deep Agent Graph
@@ -6000,6 +5999,26 @@ var AgentParamsBuilder = class {
6000
5999
  }
6001
6000
  };
6002
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
+
6003
6022
  // src/agent_lattice/AgentLatticeManager.ts
6004
6023
  function assistantToConfig(assistant) {
6005
6024
  const graphDef = typeof assistant.graphDefinition === "object" && assistant.graphDefinition !== null ? assistant.graphDefinition : {};
@@ -6155,6 +6174,39 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
6155
6174
  return false;
6156
6175
  }
6157
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
+ }
6158
6210
  /**
6159
6211
  * 构建Agent参数
6160
6212
  *
@@ -6177,10 +6229,15 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
6177
6229
  * @returns AgentClient instance
6178
6230
  */
6179
6231
  createAgentClientFromConfig(agentLattice, options) {
6232
+ const resolvedConfig = this.resolveInheritedConfig(agentLattice.config);
6233
+ const resolvedLattice = {
6234
+ ...agentLattice,
6235
+ config: resolvedConfig
6236
+ };
6180
6237
  const factory = AgentGraphBuilderFactory.getInstance();
6181
- const builder = factory.getBuilder(agentLattice.config.type);
6182
- const params = this.buildAgentParams(agentLattice, options);
6183
- return builder.build(agentLattice, params);
6238
+ const builder = factory.getBuilder(resolvedConfig.type);
6239
+ const params = this.buildAgentParams(resolvedLattice, options);
6240
+ return builder.build(resolvedLattice, params);
6184
6241
  }
6185
6242
  /**
6186
6243
  * 初始化Agent客户端