@corbat-tech/coco 2.22.1 → 2.23.0

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.js CHANGED
@@ -12640,6 +12640,7 @@ var AnthropicProvider = class {
12640
12640
  */
12641
12641
  async *stream(messages, options) {
12642
12642
  this.ensureInitialized();
12643
+ let timeoutTriggered = false;
12643
12644
  try {
12644
12645
  const stream = await this.client.messages.stream(
12645
12646
  {
@@ -12657,6 +12658,7 @@ var AnthropicProvider = class {
12657
12658
  const timeoutInterval = setInterval(() => {
12658
12659
  if (Date.now() - lastActivityTime > streamTimeout) {
12659
12660
  clearInterval(timeoutInterval);
12661
+ timeoutTriggered = true;
12660
12662
  timeoutController.abort();
12661
12663
  }
12662
12664
  }, 5e3);
@@ -12687,6 +12689,11 @@ var AnthropicProvider = class {
12687
12689
  throw new Error(`Stream timeout: No response from LLM for ${streamTimeout / 1e3}s`);
12688
12690
  }
12689
12691
  } catch (error) {
12692
+ if (timeoutTriggered) {
12693
+ throw new Error(
12694
+ `Stream timeout: No response from LLM for ${(this.config.timeout ?? 12e4) / 1e3}s`
12695
+ );
12696
+ }
12690
12697
  throw this.handleError(error);
12691
12698
  }
12692
12699
  }
@@ -12695,6 +12702,7 @@ var AnthropicProvider = class {
12695
12702
  */
12696
12703
  async *streamWithTools(messages, options) {
12697
12704
  this.ensureInitialized();
12705
+ let timeoutTriggered = false;
12698
12706
  try {
12699
12707
  const stream = await this.client.messages.stream(
12700
12708
  {
@@ -12716,6 +12724,7 @@ var AnthropicProvider = class {
12716
12724
  const timeoutInterval = setInterval(() => {
12717
12725
  if (Date.now() - lastActivityTime > streamTimeout) {
12718
12726
  clearInterval(timeoutInterval);
12727
+ timeoutTriggered = true;
12719
12728
  timeoutController.abort();
12720
12729
  }
12721
12730
  }, 5e3);
@@ -12810,6 +12819,11 @@ var AnthropicProvider = class {
12810
12819
  throw new Error(`Stream timeout: No response from LLM for ${streamTimeout / 1e3}s`);
12811
12820
  }
12812
12821
  } catch (error) {
12822
+ if (timeoutTriggered) {
12823
+ throw new Error(
12824
+ `Stream timeout: No response from LLM for ${(this.config.timeout ?? 12e4) / 1e3}s`
12825
+ );
12826
+ }
12813
12827
  throw this.handleError(error);
12814
12828
  }
12815
12829
  }
@@ -13375,6 +13389,7 @@ var OpenAIProvider = class {
13375
13389
  yield* this.streamWithToolsViaResponses(messages, options);
13376
13390
  return;
13377
13391
  }
13392
+ let timeoutTriggered = false;
13378
13393
  try {
13379
13394
  const supportsTemp = this.supportsTemperature(model);
13380
13395
  const extraBody = this.getExtraBody(model);
@@ -13403,6 +13418,7 @@ var OpenAIProvider = class {
13403
13418
  const timeoutInterval = setInterval(() => {
13404
13419
  if (Date.now() - lastActivityTime > streamTimeout) {
13405
13420
  clearInterval(timeoutInterval);
13421
+ timeoutTriggered = true;
13406
13422
  timeoutController.abort();
13407
13423
  }
13408
13424
  }, 5e3);
@@ -13516,6 +13532,11 @@ var OpenAIProvider = class {
13516
13532
  throw new Error(`Stream timeout: No response from LLM for ${streamTimeout / 1e3}s`);
13517
13533
  }
13518
13534
  } catch (error) {
13535
+ if (timeoutTriggered) {
13536
+ throw new Error(
13537
+ `Stream timeout: No response from LLM for ${(this.config.timeout ?? 12e4) / 1e3}s`
13538
+ );
13539
+ }
13519
13540
  throw this.handleError(error);
13520
13541
  }
13521
13542
  }
@@ -13961,6 +13982,7 @@ var OpenAIProvider = class {
13961
13982
  */
13962
13983
  async *streamViaResponses(messages, options) {
13963
13984
  this.ensureInitialized();
13985
+ let timeoutTriggered = false;
13964
13986
  try {
13965
13987
  const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
13966
13988
  const { input, instructions } = this.convertToResponsesInput(messages, options?.system);
@@ -13979,6 +14001,7 @@ var OpenAIProvider = class {
13979
14001
  const timeoutInterval = setInterval(() => {
13980
14002
  if (Date.now() - lastActivityTime > streamTimeout) {
13981
14003
  clearInterval(timeoutInterval);
14004
+ timeoutTriggered = true;
13982
14005
  timeoutController.abort();
13983
14006
  }
13984
14007
  }, 5e3);
@@ -14003,6 +14026,11 @@ var OpenAIProvider = class {
14003
14026
  throw new Error(`Stream timeout: No response from LLM for ${streamTimeout / 1e3}s`);
14004
14027
  }
14005
14028
  } catch (error) {
14029
+ if (timeoutTriggered) {
14030
+ throw new Error(
14031
+ `Stream timeout: No response from LLM for ${(this.config.timeout ?? 12e4) / 1e3}s`
14032
+ );
14033
+ }
14006
14034
  throw this.handleError(error);
14007
14035
  }
14008
14036
  }
@@ -14015,6 +14043,7 @@ var OpenAIProvider = class {
14015
14043
  */
14016
14044
  async *streamWithToolsViaResponses(messages, options) {
14017
14045
  this.ensureInitialized();
14046
+ let timeoutTriggered = false;
14018
14047
  try {
14019
14048
  const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
14020
14049
  const { input, instructions } = this.convertToResponsesInput(messages, options?.system);
@@ -14041,6 +14070,7 @@ var OpenAIProvider = class {
14041
14070
  const timeoutInterval = setInterval(() => {
14042
14071
  if (Date.now() - lastActivityTime > streamTimeout) {
14043
14072
  clearInterval(timeoutInterval);
14073
+ timeoutTriggered = true;
14044
14074
  timeoutController.abort();
14045
14075
  }
14046
14076
  }, 5e3);
@@ -14126,6 +14156,11 @@ var OpenAIProvider = class {
14126
14156
  throw new Error(`Stream timeout: No response from LLM for ${streamTimeout / 1e3}s`);
14127
14157
  }
14128
14158
  } catch (error) {
14159
+ if (timeoutTriggered) {
14160
+ throw new Error(
14161
+ `Stream timeout: No response from LLM for ${(this.config.timeout ?? 12e4) / 1e3}s`
14162
+ );
14163
+ }
14129
14164
  throw this.handleError(error);
14130
14165
  }
14131
14166
  }