@defai.digital/automatosx 9.2.0 → 9.2.3

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.
Files changed (4) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/README.md +426 -1106
  3. package/dist/index.js +337 -109
  4. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -11084,20 +11084,73 @@ var init_adapter2 = __esm({
11084
11084
  */
11085
11085
  async execute(prompt, options) {
11086
11086
  const startTime = Date.now();
11087
+ let totalTokens = 0;
11087
11088
  try {
11088
11089
  if (!await this.ensureSDKAvailable()) {
11089
11090
  throw new Error("ax-cli SDK not available. Install with: npm install @defai.digital/ax-cli");
11090
11091
  }
11091
- if (!this.agent || this.hasConfigChanged(options)) {
11092
+ if (!this.agent || await this.hasConfigChanged(options)) {
11092
11093
  await this.initializeAgent(options);
11093
11094
  }
11094
- logger.debug("Executing via SDK", {
11095
- model: options.model,
11095
+ logger.debug("Executing via SDK (streaming mode for token tracking)", {
11096
11096
  promptLength: prompt.length,
11097
- streaming: this.streamingEnabled
11097
+ userWantsCallbacks: !!(options.onStream || options.onTool),
11098
+ note: "SDK handles custom instructions and project memory"
11098
11099
  });
11099
- const result = await this.agent.processUserMessage(prompt);
11100
- const response = this.convertToExecutionResponse(result, prompt, startTime);
11100
+ const historyLengthBefore = this.agent.getChatHistory().length;
11101
+ for await (const chunk of this.agent.processUserMessageStream(prompt)) {
11102
+ if (chunk.type === "token_count" && chunk.tokenCount) {
11103
+ totalTokens += chunk.tokenCount;
11104
+ logger.debug("Token count from stream", {
11105
+ count: chunk.tokenCount,
11106
+ total: totalTokens
11107
+ });
11108
+ }
11109
+ if (options.onStream && (chunk.type === "content" || chunk.type === "reasoning")) {
11110
+ try {
11111
+ options.onStream({
11112
+ type: chunk.type === "reasoning" ? "thinking" : "content",
11113
+ content: chunk.content || chunk.reasoningContent,
11114
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
11115
+ });
11116
+ } catch (error) {
11117
+ logger.warn("Stream callback error", {
11118
+ error: error instanceof Error ? error.message : String(error)
11119
+ });
11120
+ }
11121
+ }
11122
+ if (options.onTool && chunk.type === "tool_calls" && chunk.toolCalls) {
11123
+ try {
11124
+ for (const toolCall of chunk.toolCalls) {
11125
+ options.onTool({
11126
+ name: toolCall.function.name,
11127
+ args: toolCall.function.arguments
11128
+ });
11129
+ }
11130
+ } catch (error) {
11131
+ logger.warn("Tool callback error", {
11132
+ error: error instanceof Error ? error.message : String(error)
11133
+ });
11134
+ }
11135
+ }
11136
+ }
11137
+ const fullHistory = this.agent.getChatHistory();
11138
+ const result = fullHistory.slice(historyLengthBefore);
11139
+ logger.debug("Chat history extraction", {
11140
+ historyLengthBefore,
11141
+ historyLengthAfter: fullHistory.length,
11142
+ newEntries: result.length,
11143
+ entryTypes: result.map((e) => e.type)
11144
+ });
11145
+ if (result.length === 0) {
11146
+ logger.error("No new chat entries after execution", {
11147
+ historyLengthBefore,
11148
+ historyLengthAfter: fullHistory.length,
11149
+ fullHistory: fullHistory.map((e) => ({ type: e.type, content: e.content?.substring(0, 50) }))
11150
+ });
11151
+ throw new Error("SDK did not add any new chat entries. This may indicate an execution error.");
11152
+ }
11153
+ const response = this.convertToExecutionResponse(result, prompt, startTime, totalTokens);
11101
11154
  logger.info("SDK execution successful", {
11102
11155
  model: response.model,
11103
11156
  contentLength: response.content.length,
@@ -11108,64 +11161,96 @@ var init_adapter2 = __esm({
11108
11161
  } catch (error) {
11109
11162
  logger.error("SDK execution failed", {
11110
11163
  error: error instanceof Error ? error.message : String(error),
11111
- model: options.model
11164
+ note: "Model configured via ax-cli setup"
11112
11165
  });
11113
11166
  throw this.mapError(error);
11114
11167
  }
11115
11168
  }
11116
11169
  /**
11117
11170
  * Initialize or reinitialize agent
11171
+ *
11172
+ * IMPORTANT: The SDK loads ALL credentials (API key, base URL, model) from
11173
+ * ~/.ax-cli/config.json which is created by running "ax-cli setup".
11174
+ *
11175
+ * We do NOT pass credentials to the SDK - it manages its own configuration.
11118
11176
  */
11119
11177
  async initializeAgent(options) {
11178
+ const { createAgent } = await import('@defai.digital/ax-cli/sdk');
11120
11179
  try {
11121
- const { createAgent, initializeSDK } = await import('@defai.digital/ax-cli/sdk');
11122
11180
  const config = {
11123
- apiKey: options.apiKey,
11124
- model: options.model || "glm-4.6",
11125
- baseURL: options.baseUrl,
11126
11181
  maxToolRounds: options.maxToolRounds || 400
11127
11182
  };
11128
- await initializeSDK({
11129
- apiKey: config.apiKey,
11130
- model: config.model,
11131
- baseURL: config.baseURL
11132
- });
11133
- logger.debug("Initializing SDK agent", {
11134
- model: config.model,
11183
+ logger.debug("Creating SDK agent (credentials from ax-cli settings)", {
11135
11184
  maxToolRounds: config.maxToolRounds,
11136
- reuse: this.reuseEnabled
11185
+ reuse: this.reuseEnabled,
11186
+ note: "SDK loads apiKey, baseURL, model from ~/.ax-cli/config.json"
11187
+ });
11188
+ this.agent = await createAgent({
11189
+ maxToolRounds: config.maxToolRounds
11137
11190
  });
11138
- this.agent = await createAgent(config);
11139
11191
  this.agentConfig = config;
11140
11192
  if (this.streamingEnabled) {
11141
11193
  this.setupEventHandlers();
11142
11194
  }
11143
- logger.info("SDK agent initialized", {
11144
- model: config.model
11195
+ logger.info("SDK agent initialized successfully", {
11196
+ maxToolRounds: config.maxToolRounds,
11197
+ note: "Using credentials from ax-cli setup"
11145
11198
  });
11146
- } catch (error) {
11199
+ } catch (err) {
11200
+ const error = err instanceof Error ? err : new Error(String(err));
11201
+ const errorMsg = error.message.toLowerCase();
11202
+ if (errorMsg.includes("setup") || errorMsg.includes("not configured")) {
11203
+ logger.error("ax-cli setup required", {
11204
+ error: error.message,
11205
+ solution: "Run: ax-cli setup"
11206
+ });
11207
+ throw new Error(
11208
+ `ax-cli setup has not been run. Please run "ax-cli setup" to configure your API key, model, and base URL. Original error: ${error.message}`
11209
+ );
11210
+ }
11211
+ if (errorMsg.includes("api key") || errorMsg.includes("apikey")) {
11212
+ logger.error("API key not configured", {
11213
+ error: error.message,
11214
+ solution: "Run: ax-cli setup"
11215
+ });
11216
+ throw new Error(
11217
+ `No API key configured in ax-cli settings. Please run "ax-cli setup" to configure your credentials. Original error: ${error.message}`
11218
+ );
11219
+ }
11220
+ if (errorMsg.includes("base url") || errorMsg.includes("baseurl") || errorMsg.includes("endpoint")) {
11221
+ logger.error("Base URL not configured", {
11222
+ error: error.message,
11223
+ solution: "Run: ax-cli setup"
11224
+ });
11225
+ throw new Error(
11226
+ `No base URL configured in ax-cli settings. Please run "ax-cli setup" to configure your AI provider endpoint. Original error: ${error.message}`
11227
+ );
11228
+ }
11147
11229
  logger.error("Failed to initialize SDK agent", {
11148
- error: error instanceof Error ? error.message : String(error)
11230
+ error: error.message
11149
11231
  });
11150
- throw new Error(`Failed to initialize SDK agent: ${error instanceof Error ? error.message : String(error)}`);
11232
+ throw new Error(`Failed to initialize SDK agent: ${error.message}`);
11151
11233
  }
11152
11234
  }
11153
11235
  /**
11154
11236
  * Check if agent config has changed (requires new agent)
11237
+ *
11238
+ * Since SDK manages credentials via settings, we only track maxToolRounds
11155
11239
  */
11156
- hasConfigChanged(options) {
11240
+ async hasConfigChanged(options) {
11157
11241
  if (!this.agentConfig) return true;
11158
- const changed = this.agentConfig.model !== (options.model || "glm-4.6") || this.agentConfig.apiKey !== options.apiKey || this.agentConfig.baseURL !== options.baseUrl || this.agentConfig.maxToolRounds !== (options.maxToolRounds || 400);
11242
+ const changed = this.agentConfig.maxToolRounds !== (options.maxToolRounds || 400);
11159
11243
  if (changed) {
11160
11244
  logger.debug("Agent config changed, will reinitialize", {
11161
- oldModel: this.agentConfig.model,
11162
- newModel: options.model || "glm-4.6"
11245
+ oldMaxToolRounds: this.agentConfig.maxToolRounds,
11246
+ newMaxToolRounds: options.maxToolRounds || 400,
11247
+ note: "SDK credentials managed by ax-cli setup"
11163
11248
  });
11164
11249
  }
11165
11250
  return changed;
11166
11251
  }
11167
11252
  /**
11168
- * Set up streaming event handlers
11253
+ * Set up streaming event handlers (for initialization)
11169
11254
  */
11170
11255
  setupEventHandlers() {
11171
11256
  if (!this.agent) return;
@@ -11192,6 +11277,50 @@ var init_adapter2 = __esm({
11192
11277
  });
11193
11278
  }
11194
11279
  }
11280
+ /**
11281
+ * Set up streaming callbacks for execution
11282
+ */
11283
+ setupStreamingCallbacks(options) {
11284
+ if (!this.agent) return;
11285
+ try {
11286
+ this.agent.removeAllListeners("stream");
11287
+ this.agent.removeAllListeners("tool");
11288
+ if (options.onStream) {
11289
+ this.agent.on("stream", (chunk) => {
11290
+ try {
11291
+ options.onStream({
11292
+ type: chunk.type || "content",
11293
+ content: chunk.content,
11294
+ tool: chunk.tool,
11295
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
11296
+ });
11297
+ } catch (error) {
11298
+ logger.warn("Stream callback error", {
11299
+ error: error instanceof Error ? error.message : String(error)
11300
+ });
11301
+ }
11302
+ });
11303
+ }
11304
+ if (options.onTool) {
11305
+ this.agent.on("tool", (data) => {
11306
+ try {
11307
+ options.onTool({
11308
+ name: data.name,
11309
+ args: data.args
11310
+ });
11311
+ } catch (error) {
11312
+ logger.warn("Tool callback error", {
11313
+ error: error instanceof Error ? error.message : String(error)
11314
+ });
11315
+ }
11316
+ });
11317
+ }
11318
+ } catch (error) {
11319
+ logger.warn("Failed to setup streaming callbacks", {
11320
+ error: error instanceof Error ? error.message : String(error)
11321
+ });
11322
+ }
11323
+ }
11195
11324
  /**
11196
11325
  * Convert SDK response to ExecutionResponse format
11197
11326
  *
@@ -11201,69 +11330,135 @@ var init_adapter2 = __esm({
11201
11330
  * { type: "assistant", content: "...", timestamp: "..." }
11202
11331
  * ]
11203
11332
  *
11204
- * Note: SDK doesn't expose token counts, so we estimate them based on content length.
11333
+ * Token usage priority: SDK events (totalTokens) > ChatEntry.usage > estimation fallback
11205
11334
  */
11206
- convertToExecutionResponse(result, prompt, startTime) {
11335
+ convertToExecutionResponse(result, prompt, startTime, totalTokensFromEvents = 0) {
11207
11336
  const latencyMs = Date.now() - startTime;
11208
11337
  if (Array.isArray(result)) {
11209
11338
  const assistantMessages = result.filter((entry) => entry.type === "assistant");
11210
11339
  if (assistantMessages.length === 0) {
11211
- throw new Error("No assistant response found in SDK result");
11340
+ logger.error("No assistant message in result", {
11341
+ resultLength: result.length,
11342
+ entryTypes: result.map((e) => e.type),
11343
+ entries: result.map((e) => ({
11344
+ type: e.type,
11345
+ content: e.content?.substring(0, 100),
11346
+ hasToolCalls: !!e.toolCalls,
11347
+ hasToolResults: !!e.toolResult
11348
+ }))
11349
+ });
11350
+ throw new Error(`No assistant response found in SDK result. Got ${result.length} entries with types: ${result.map((e) => e.type).join(", ")}`);
11212
11351
  }
11213
11352
  const lastAssistant = assistantMessages[assistantMessages.length - 1];
11214
11353
  const content2 = lastAssistant.content || "";
11215
- const usage2 = lastAssistant.usage || lastAssistant.tokens || {};
11216
- const actualTokens2 = {
11217
- prompt: usage2.prompt || usage2.input || usage2.promptTokens,
11218
- completion: usage2.completion || usage2.output || usage2.completionTokens,
11219
- total: usage2.total || usage2.totalTokens
11220
- };
11221
- const estimated2 = TokenEstimator.estimateUsage(prompt, content2);
11222
- const finalTokens2 = TokenEstimator.mergeWithActual(estimated2, actualTokens2);
11223
- logger.debug("Token usage", {
11224
- estimated: TokenEstimator.format(estimated2, true),
11225
- actual: actualTokens2.total ? TokenEstimator.format(actualTokens2) : "not available",
11226
- final: TokenEstimator.format(finalTokens2)
11227
- });
11228
- const model2 = lastAssistant.model || this.agentConfig?.model || "glm-4.6";
11229
- let finishReason2 = "stop";
11230
- if (lastAssistant.finishReason) {
11231
- finishReason2 = lastAssistant.finishReason;
11232
- } else if (lastAssistant.stopReason) {
11233
- finishReason2 = lastAssistant.stopReason === "max_tokens" ? "length" : "stop";
11354
+ let finalTokens2;
11355
+ if (totalTokensFromEvents > 0) {
11356
+ const estimated = TokenEstimator.estimateUsage(prompt, content2);
11357
+ finalTokens2 = {
11358
+ prompt: estimated.prompt,
11359
+ // Estimated split
11360
+ completion: estimated.completion,
11361
+ // Estimated split
11362
+ total: totalTokensFromEvents
11363
+ // Actual total from events
11364
+ };
11365
+ logger.info("Using token count from SDK events", {
11366
+ tokens: TokenEstimator.format(finalTokens2),
11367
+ accuracy: "100% (total), 80-90% (split)",
11368
+ source: "token_count events"
11369
+ });
11370
+ } else {
11371
+ const usage = lastAssistant.usage || lastAssistant.tokens || {};
11372
+ const actualTokens = {
11373
+ prompt: usage.prompt_tokens || usage.prompt || usage.input || usage.promptTokens || 0,
11374
+ completion: usage.completion_tokens || usage.completion || usage.output || usage.completionTokens || 0,
11375
+ total: usage.total_tokens || usage.total || usage.totalTokens || 0
11376
+ };
11377
+ const hasActualTokens = actualTokens.total > 0;
11378
+ if (hasActualTokens) {
11379
+ finalTokens2 = {
11380
+ prompt: actualTokens.prompt,
11381
+ completion: actualTokens.completion,
11382
+ total: actualTokens.total
11383
+ };
11384
+ logger.info("Using token counts from ChatEntry.usage", {
11385
+ tokens: TokenEstimator.format(finalTokens2),
11386
+ accuracy: "100%",
11387
+ source: "ChatEntry.usage"
11388
+ });
11389
+ } else {
11390
+ finalTokens2 = TokenEstimator.estimateUsage(prompt, content2);
11391
+ logger.warn("SDK did not provide token counts, using estimation", {
11392
+ tokens: TokenEstimator.format(finalTokens2, true),
11393
+ accuracy: "80-90% (estimated)",
11394
+ source: "estimation"
11395
+ });
11396
+ }
11234
11397
  }
11398
+ const model2 = this.agent.getCurrentModel();
11399
+ const finishReason2 = "stop";
11235
11400
  return {
11236
11401
  content: content2,
11237
11402
  model: model2,
11238
11403
  tokensUsed: finalTokens2,
11239
11404
  latencyMs,
11240
11405
  finishReason: finishReason2,
11241
- cached: lastAssistant.cached || false
11406
+ cached: false
11407
+ // SDK doesn't expose cache status via ChatEntry
11242
11408
  };
11243
11409
  }
11244
11410
  const content = typeof result === "string" ? result : result.content || result.text || "";
11245
- const usage = result.usage || result.tokens || {};
11246
- const actualTokens = {
11247
- prompt: usage.prompt || usage.input || usage.promptTokens,
11248
- completion: usage.completion || usage.output || usage.completionTokens,
11249
- total: usage.total || usage.totalTokens
11250
- };
11251
- const estimated = TokenEstimator.estimateUsage(prompt, content);
11252
- const finalTokens = TokenEstimator.mergeWithActual(estimated, actualTokens);
11253
- const model = result.model || this.agentConfig?.model || "glm-4.6";
11254
- let finishReason = "stop";
11255
- if (result.finishReason) {
11256
- finishReason = result.finishReason;
11257
- } else if (result.stopReason) {
11258
- finishReason = result.stopReason === "max_tokens" ? "length" : "stop";
11411
+ let finalTokens;
11412
+ if (totalTokensFromEvents > 0) {
11413
+ const estimated = TokenEstimator.estimateUsage(prompt, content);
11414
+ finalTokens = {
11415
+ prompt: estimated.prompt,
11416
+ completion: estimated.completion,
11417
+ total: totalTokensFromEvents
11418
+ };
11419
+ logger.info("Using token count from SDK events (fallback path)", {
11420
+ tokens: TokenEstimator.format(finalTokens),
11421
+ accuracy: "100% (total), 80-90% (split)",
11422
+ source: "token_count events"
11423
+ });
11424
+ } else {
11425
+ const usage = result.usage || result.tokens || {};
11426
+ const actualTokens = {
11427
+ prompt: usage.prompt_tokens || usage.prompt || usage.input || usage.promptTokens || 0,
11428
+ completion: usage.completion_tokens || usage.completion || usage.output || usage.completionTokens || 0,
11429
+ total: usage.total_tokens || usage.total || usage.totalTokens || 0
11430
+ };
11431
+ const hasActualTokens = actualTokens.total > 0;
11432
+ if (hasActualTokens) {
11433
+ finalTokens = {
11434
+ prompt: actualTokens.prompt,
11435
+ completion: actualTokens.completion,
11436
+ total: actualTokens.total
11437
+ };
11438
+ logger.info("Using token counts from response.usage (fallback path)", {
11439
+ tokens: TokenEstimator.format(finalTokens),
11440
+ accuracy: "100%",
11441
+ source: "response.usage"
11442
+ });
11443
+ } else {
11444
+ finalTokens = TokenEstimator.estimateUsage(prompt, content);
11445
+ logger.warn("SDK did not provide token counts (fallback path), using estimation", {
11446
+ tokens: TokenEstimator.format(finalTokens, true),
11447
+ accuracy: "80-90% (estimated)",
11448
+ source: "estimation"
11449
+ });
11450
+ }
11259
11451
  }
11452
+ const model = this.agent.getCurrentModel();
11453
+ const finishReason = "stop";
11260
11454
  return {
11261
11455
  content,
11262
11456
  model,
11263
11457
  tokensUsed: finalTokens,
11264
11458
  latencyMs,
11265
11459
  finishReason,
11266
- cached: result.cached || false
11460
+ cached: false
11461
+ // SDK doesn't expose cache status
11267
11462
  };
11268
11463
  }
11269
11464
  /**
@@ -11333,8 +11528,8 @@ var init_adapter2 = __esm({
11333
11528
  */
11334
11529
  async getVersion() {
11335
11530
  try {
11336
- const { GLM_MODELS } = await import('@defai.digital/ax-cli/sdk');
11337
- return "3.4.6";
11531
+ await import('@defai.digital/ax-cli/sdk');
11532
+ return "3.7.0+";
11338
11533
  } catch (error) {
11339
11534
  logger.warn("Failed to get SDK version", {
11340
11535
  error: error instanceof Error ? error.message : String(error)
@@ -11360,9 +11555,7 @@ var init_adapter2 = __esm({
11360
11555
  async destroy() {
11361
11556
  if (this.agent) {
11362
11557
  try {
11363
- if (typeof this.agent.cleanup === "function") {
11364
- await this.agent.cleanup();
11365
- }
11558
+ this.agent.dispose();
11366
11559
  this.agent = null;
11367
11560
  this.agentConfig = null;
11368
11561
  logger.debug("SDK agent destroyed");
@@ -11435,8 +11628,8 @@ var init_hybrid_adapter = __esm({
11435
11628
  throw new Error("SDK adapter not initialized");
11436
11629
  }
11437
11630
  logger.debug("Executing via SDK", {
11438
- model: options.model,
11439
- promptLength: prompt.length
11631
+ promptLength: prompt.length,
11632
+ note: "Model configured via ax-cli setup"
11440
11633
  });
11441
11634
  return await this.sdkAdapter.execute(prompt, options);
11442
11635
  }
@@ -11448,7 +11641,7 @@ var init_hybrid_adapter = __esm({
11448
11641
  throw new Error("CLI adapter not initialized");
11449
11642
  }
11450
11643
  logger.debug("Executing via CLI", {
11451
- model: options.model,
11644
+ model: options.model || "(from ax-cli setup)",
11452
11645
  promptLength: prompt.length
11453
11646
  });
11454
11647
  return await this.cliAdapter.execute(prompt, options);
@@ -11640,9 +11833,9 @@ var init_ax_cli_provider = __esm({
11640
11833
  });
11641
11834
  logger.info("AxCliProvider initialized", {
11642
11835
  mode,
11643
- provider: config.axCli?.provider || "glm",
11644
- model: config.axCli?.model || "glm-4.6",
11645
- sdkOptions: config.axCliSdk
11836
+ model: config.axCli?.model || "(from ax-cli setup)",
11837
+ sdkOptions: config.axCliSdk,
11838
+ note: "Provider configured via ax-cli setup"
11646
11839
  });
11647
11840
  }
11648
11841
  /**
@@ -11655,17 +11848,21 @@ var init_ax_cli_provider = __esm({
11655
11848
  async execute(request) {
11656
11849
  const axCliConfig = this.config.axCli || {};
11657
11850
  const options = {
11658
- provider: axCliConfig.provider || "glm",
11659
- model: request.model || axCliConfig.model || "glm-4.6",
11851
+ model: request.model || axCliConfig.model,
11852
+ // Optional model override
11660
11853
  maxToolRounds: axCliConfig.maxToolRounds || 400,
11661
11854
  timeout: this.config.timeout,
11855
+ // Note: apiKey and baseUrl are ignored by SDK adapter (v3.7.0+)
11856
+ // SDK loads credentials from ax-cli setup (~/.ax-cli/config.json)
11662
11857
  apiKey: axCliConfig.apiKey,
11858
+ // Only used by CLI adapter (deprecated)
11663
11859
  baseUrl: axCliConfig.baseUrl
11860
+ // Only used by CLI adapter (deprecated)
11664
11861
  };
11665
11862
  logger.debug("Executing task via ax-cli", {
11666
- provider: options.provider,
11667
- model: options.model,
11668
- promptLength: request.prompt.length
11863
+ model: options.model || "(from ax-cli setup)",
11864
+ promptLength: request.prompt.length,
11865
+ note: "Provider configured via ax-cli setup"
11669
11866
  });
11670
11867
  try {
11671
11868
  const response = await this.adapter.execute(request.prompt, options);
@@ -11679,8 +11876,7 @@ var init_ax_cli_provider = __esm({
11679
11876
  } catch (error) {
11680
11877
  logger.error("Task execution failed", {
11681
11878
  error: error instanceof Error ? error.message : String(error),
11682
- provider: options.provider,
11683
- model: options.model
11879
+ model: options.model || "(from ax-cli setup)"
11684
11880
  });
11685
11881
  throw error;
11686
11882
  }
@@ -13120,6 +13316,41 @@ function calculateMaxConcurrentAgents(staticLimit) {
13120
13316
  init_esm_shims();
13121
13317
  var PRECOMPILED_CONFIG = {
13122
13318
  "providers": {
13319
+ "ax-cli": {
13320
+ "enabled": true,
13321
+ "priority": 4,
13322
+ "timeout": 27e5,
13323
+ "command": "ax-cli",
13324
+ "mode": "auto",
13325
+ "healthCheck": {
13326
+ "enabled": true,
13327
+ "interval": 3e5,
13328
+ "timeout": 5e3
13329
+ },
13330
+ "circuitBreaker": {
13331
+ "enabled": true,
13332
+ "failureThreshold": 3,
13333
+ "recoveryTimeout": 6e4
13334
+ },
13335
+ "processManagement": {
13336
+ "gracefulShutdownTimeout": 5e3,
13337
+ "forceKillDelay": 1e3
13338
+ },
13339
+ "versionDetection": {
13340
+ "timeout": 5e3,
13341
+ "forceKillDelay": 1e3,
13342
+ "cacheEnabled": true
13343
+ },
13344
+ "limitTracking": {
13345
+ "enabled": true,
13346
+ "window": "daily",
13347
+ "resetHourUtc": 0
13348
+ },
13349
+ "axCliSdk": {
13350
+ "streamingEnabled": true,
13351
+ "reuseEnabled": true
13352
+ }
13353
+ },
13123
13354
  "claude-code": {
13124
13355
  "enabled": true,
13125
13356
  "priority": 3,
@@ -36475,32 +36706,29 @@ Complexity Score: ${complexity.score}/10
36475
36706
  minVersion: geminiConfig.minVersion
36476
36707
  }));
36477
36708
  }
36478
- if (config.providers["glm"]?.enabled) {
36709
+ const axCliConfigKey = config.providers["ax-cli"] ? "ax-cli" : config.providers["glm"] ? "glm" : null;
36710
+ if (axCliConfigKey && config.providers[axCliConfigKey]?.enabled) {
36479
36711
  try {
36480
- const { AxCliProvider: AxCliProvider2, GlmProvider: GlmProvider2 } = await Promise.resolve().then(() => (init_ax_cli_provider(), ax_cli_provider_exports));
36481
- const glmConfig = config.providers["glm"];
36482
- if (glmConfig) {
36483
- providers.push(new GlmProvider2({
36484
- name: "glm",
36485
- enabled: true,
36486
- priority: glmConfig.priority ?? 4,
36487
- // Default priority
36488
- timeout: glmConfig.timeout ?? 12e4,
36489
- // Default 2 minutes
36490
- command: glmConfig.command || "ax-cli",
36491
- // v11.0.0: ax-cli only
36492
- // Phase 2: Enhanced CLI detection parameters
36493
- customPath: glmConfig.customPath,
36494
- versionArg: glmConfig.versionArg,
36495
- minVersion: glmConfig.minVersion,
36496
- // v11.0.0: Simplified ax-cli configuration
36497
- axCli: glmConfig.axCli
36498
- }));
36499
- } else {
36500
- logger.warn("GLM provider enabled but configuration is missing");
36712
+ const { AxCliProvider: AxCliProvider2 } = await Promise.resolve().then(() => (init_ax_cli_provider(), ax_cli_provider_exports));
36713
+ const axCliConfig = config.providers[axCliConfigKey];
36714
+ providers.push(new AxCliProvider2({
36715
+ name: "ax-cli",
36716
+ enabled: true,
36717
+ priority: axCliConfig.priority ?? 4,
36718
+ timeout: axCliConfig.timeout ?? 12e4,
36719
+ command: axCliConfig.command || "ax-cli",
36720
+ mode: axCliConfig.mode || "auto",
36721
+ customPath: axCliConfig.customPath,
36722
+ versionArg: axCliConfig.versionArg,
36723
+ minVersion: axCliConfig.minVersion,
36724
+ axCli: axCliConfig.axCli,
36725
+ axCliSdk: axCliConfig.axCliSdk
36726
+ }));
36727
+ if (axCliConfigKey === "glm") {
36728
+ logger.warn('Using deprecated "glm" provider config. Please rename to "ax-cli" in ax.config.json');
36501
36729
  }
36502
36730
  } catch (error) {
36503
- logger.error("Failed to initialize GLM provider", { error });
36731
+ logger.error("Failed to initialize ax-cli provider", { error });
36504
36732
  }
36505
36733
  }
36506
36734
  if (config.providers["openai"]?.enabled) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@defai.digital/automatosx",
3
- "version": "9.2.0",
4
- "description": "AI Agent Orchestration Platform",
3
+ "version": "9.2.3",
4
+ "description": "AutomatosX is a unified automation core that orchestrates AI agents, workflows, and memory",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -86,7 +86,7 @@
86
86
  "vitest": "^3.2.4"
87
87
  },
88
88
  "dependencies": {
89
- "@defai.digital/ax-cli": "^3.4.6",
89
+ "@defai.digital/ax-cli": "^3.6.2",
90
90
  "@iarna/toml": "^2.2.5",
91
91
  "ajv": "^8.17.1",
92
92
  "ajv-formats": "^3.0.1",