@defai.digital/automatosx 6.2.1 → 6.2.2

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/README.md CHANGED
@@ -7,7 +7,7 @@ AutomatosX is the only AI CLI that combines declarative workflow specs, policy-d
7
7
  [![npm version](https://img.shields.io/npm/v/@defai.digital/automatosx.svg)](https://www.npmjs.com/package/@defai.digital/automatosx)
8
8
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
9
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-100%25-blue.svg)](https://www.typescriptlang.org/)
10
- [![Tests](https://img.shields.io/badge/tests-2,457%20passing-brightgreen.svg)](#)
10
+ [![Tests](https://img.shields.io/badge/tests-2,466%20passing-brightgreen.svg)](#)
11
11
  [![macOS](https://img.shields.io/badge/macOS-26.0-blue.svg)](https://www.apple.com/macos)
12
12
  [![Windows](https://img.shields.io/badge/Windows-10+-blue.svg)](https://www.microsoft.com/windows)
13
13
  [![Ubuntu](https://img.shields.io/badge/Ubuntu-24.04-orange.svg)](https://ubuntu.com)
package/dist/index.js CHANGED
@@ -6364,12 +6364,16 @@ var init_openai_sdk_provider = __esm({
6364
6364
  init_provider_connection_pool();
6365
6365
  init_provider_limit_manager();
6366
6366
  init_streaming_feedback();
6367
+ init_timeout_estimator();
6367
6368
  OpenAISDKProvider = class extends BaseProvider {
6368
6369
  sdkConfig;
6369
6370
  connectionPool = getProviderConnectionPool();
6370
6371
  initialized = false;
6371
6372
  // v6.0.7: Streaming feedback
6372
6373
  currentStreamingFeedback = null;
6374
+ // v6.2.2: Progress tracking for SDK streaming (bugfix #5, #6)
6375
+ currentProgressTracker = null;
6376
+ progressInterval = null;
6373
6377
  constructor(config, sdkConfig = {}) {
6374
6378
  super(config);
6375
6379
  this.sdkConfig = sdkConfig;
@@ -6437,10 +6441,25 @@ var init_openai_sdk_provider = __esm({
6437
6441
  */
6438
6442
  async executeRequest(request) {
6439
6443
  const startTime = Date.now();
6444
+ const fullPrompt = `${request.systemPrompt || ""}
6445
+ ${request.prompt}`.trim();
6446
+ const timeoutEstimate = estimateTimeout({
6447
+ prompt: fullPrompt,
6448
+ systemPrompt: request.systemPrompt,
6449
+ model: typeof request.model === "string" ? request.model : void 0,
6450
+ maxTokens: request.maxTokens
6451
+ });
6452
+ if (process.env.AUTOMATOSX_QUIET !== "true") {
6453
+ logger.info(formatTimeoutEstimate(timeoutEstimate));
6454
+ }
6455
+ if (timeoutEstimate.estimatedDurationMs > 1e4) {
6456
+ this.startProgressTracking(timeoutEstimate.estimatedDurationMs);
6457
+ }
6440
6458
  const useMock = process.env.AUTOMATOSX_MOCK_PROVIDERS === "true" || process.env.NODE_ENV === "test" || process.env.VITEST === "true";
6441
6459
  if (useMock) {
6442
6460
  const mockPrompt = request.prompt.substring(0, 100);
6443
6461
  const latency = Date.now() - startTime;
6462
+ this.stopProgressTracking();
6444
6463
  return {
6445
6464
  content: `[Mock Response from OpenAI SDK]
6446
6465
 
@@ -6477,6 +6496,7 @@ This is a placeholder response. Set AUTOMATOSX_MOCK_PROVIDERS=false to use real
6477
6496
  // Non-streaming for this method
6478
6497
  });
6479
6498
  await this.connectionPool.release(this.config.name, connection);
6499
+ this.stopProgressTracking();
6480
6500
  const content = response.choices[0]?.message?.content || "";
6481
6501
  const finishReason = this.mapFinishReason(response.choices[0]?.finish_reason);
6482
6502
  const latency = Date.now() - startTime;
@@ -6500,9 +6520,11 @@ This is a placeholder response. Set AUTOMATOSX_MOCK_PROVIDERS=false to use real
6500
6520
  };
6501
6521
  } catch (error) {
6502
6522
  await this.connectionPool.release(this.config.name, connection);
6523
+ this.stopProgressTracking();
6503
6524
  throw error;
6504
6525
  }
6505
6526
  } catch (error) {
6527
+ this.stopProgressTracking();
6506
6528
  return this.handleSDKError(error, request, startTime);
6507
6529
  }
6508
6530
  }
@@ -6511,6 +6533,20 @@ This is a placeholder response. Set AUTOMATOSX_MOCK_PROVIDERS=false to use real
6511
6533
  */
6512
6534
  async executeStreaming(request, options) {
6513
6535
  const startTime = Date.now();
6536
+ const fullPrompt = `${request.systemPrompt || ""}
6537
+ ${request.prompt}`.trim();
6538
+ const timeoutEstimate = estimateTimeout({
6539
+ prompt: fullPrompt,
6540
+ systemPrompt: request.systemPrompt,
6541
+ model: typeof request.model === "string" ? request.model : void 0,
6542
+ maxTokens: request.maxTokens
6543
+ });
6544
+ if (process.env.AUTOMATOSX_QUIET !== "true") {
6545
+ logger.info(formatTimeoutEstimate(timeoutEstimate));
6546
+ }
6547
+ if (timeoutEstimate.estimatedDurationMs > 1e4) {
6548
+ this.startProgressTracking(timeoutEstimate.estimatedDurationMs);
6549
+ }
6514
6550
  const estimatedOutputTokens = request.maxTokens || this.estimateTokens(request.prompt) * 2;
6515
6551
  this.currentStreamingFeedback = createStreamingFeedback(estimatedOutputTokens);
6516
6552
  const useMock = process.env.AUTOMATOSX_MOCK_PROVIDERS === "true" || process.env.NODE_ENV === "test" || process.env.VITEST === "true";
@@ -6531,6 +6567,7 @@ This is a placeholder streaming response. Set AUTOMATOSX_MOCK_PROVIDERS=false to
6531
6567
  this.currentStreamingFeedback.stop(50);
6532
6568
  this.currentStreamingFeedback = null;
6533
6569
  }
6570
+ this.stopProgressTracking();
6534
6571
  return {
6535
6572
  content: mockContent,
6536
6573
  model: request.model || "gpt-4o",
@@ -6586,6 +6623,19 @@ This is a placeholder streaming response. Set AUTOMATOSX_MOCK_PROVIDERS=false to
6586
6623
  });
6587
6624
  }
6588
6625
  }
6626
+ if (options.onProgress) {
6627
+ try {
6628
+ const currentTokens = this.estimateTokens(fullContent);
6629
+ const expectedTokens = request.maxTokens || 4096;
6630
+ const progress = Math.min(currentTokens / expectedTokens, 0.95);
6631
+ options.onProgress(progress);
6632
+ } catch (error) {
6633
+ logger.warn("Streaming onProgress callback error", {
6634
+ provider: this.config.name,
6635
+ error: error instanceof Error ? error.message : String(error)
6636
+ });
6637
+ }
6638
+ }
6589
6639
  }
6590
6640
  if (chunk.choices[0]?.finish_reason) {
6591
6641
  finishReason = this.mapFinishReason(chunk.choices[0].finish_reason);
@@ -6616,6 +6666,17 @@ This is a placeholder streaming response. Set AUTOMATOSX_MOCK_PROVIDERS=false to
6616
6666
  this.currentStreamingFeedback.stop(completionTokens);
6617
6667
  this.currentStreamingFeedback = null;
6618
6668
  }
6669
+ if (options.onProgress) {
6670
+ try {
6671
+ options.onProgress(1);
6672
+ } catch (error) {
6673
+ logger.warn("Final streaming onProgress callback error", {
6674
+ provider: this.config.name,
6675
+ error: error instanceof Error ? error.message : String(error)
6676
+ });
6677
+ }
6678
+ }
6679
+ this.stopProgressTracking();
6619
6680
  return {
6620
6681
  content: fullContent,
6621
6682
  model: modelUsed,
@@ -6633,6 +6694,7 @@ This is a placeholder streaming response. Set AUTOMATOSX_MOCK_PROVIDERS=false to
6633
6694
  this.currentStreamingFeedback.stop();
6634
6695
  this.currentStreamingFeedback = null;
6635
6696
  }
6697
+ this.stopProgressTracking();
6636
6698
  throw error;
6637
6699
  }
6638
6700
  } catch (error) {
@@ -6640,6 +6702,7 @@ This is a placeholder streaming response. Set AUTOMATOSX_MOCK_PROVIDERS=false to
6640
6702
  this.currentStreamingFeedback.stop();
6641
6703
  this.currentStreamingFeedback = null;
6642
6704
  }
6705
+ this.stopProgressTracking();
6643
6706
  return this.handleSDKError(error, request, startTime);
6644
6707
  }
6645
6708
  }
@@ -6808,6 +6871,38 @@ This is a placeholder streaming response. Set AUTOMATOSX_MOCK_PROVIDERS=false to
6808
6871
  tokensUsed: inputTokens + outputTokens
6809
6872
  };
6810
6873
  }
6874
+ /**
6875
+ * Start progress tracking for long operations
6876
+ * v6.2.2: Consistency with CLI providers (bugfix #5, #6)
6877
+ * @param estimatedDurationMs - Estimated duration in milliseconds
6878
+ */
6879
+ startProgressTracking(estimatedDurationMs) {
6880
+ if (process.env.AUTOMATOSX_QUIET === "true") {
6881
+ return;
6882
+ }
6883
+ this.currentProgressTracker = new ProgressTracker(estimatedDurationMs);
6884
+ this.progressInterval = setInterval(() => {
6885
+ if (this.currentProgressTracker && this.currentProgressTracker.shouldUpdate()) {
6886
+ process.stderr.write("\r" + this.currentProgressTracker.formatProgress());
6887
+ }
6888
+ }, 1e3);
6889
+ }
6890
+ /**
6891
+ * Stop progress tracking
6892
+ * v6.2.2: Consistency with CLI providers (bugfix #5, #6)
6893
+ */
6894
+ stopProgressTracking() {
6895
+ if (this.progressInterval) {
6896
+ clearInterval(this.progressInterval);
6897
+ this.progressInterval = null;
6898
+ }
6899
+ if (this.currentProgressTracker) {
6900
+ if (process.env.AUTOMATOSX_QUIET !== "true") {
6901
+ process.stderr.write("\r" + " ".repeat(80) + "\r");
6902
+ }
6903
+ this.currentProgressTracker = null;
6904
+ }
6905
+ }
6811
6906
  };
6812
6907
  }
6813
6908
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defai.digital/automatosx",
3
- "version": "6.2.1",
3
+ "version": "6.2.2",
4
4
  "description": "AI Agent Orchestration Platform",
5
5
  "type": "module",
6
6
  "publishConfig": {