@langwatch/scenario 0.4.5 → 0.4.6

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
@@ -3897,6 +3897,7 @@ var ScenarioExecution = class {
3897
3897
  });
3898
3898
  this.currentTurnSpan = this.tracer.startSpan("Scenario Turn", {
3899
3899
  attributes: {
3900
+ "langwatch.origin": "simulation",
3900
3901
  "scenario.name": this.config.name,
3901
3902
  "scenario.id": this.config.id,
3902
3903
  [import_observability3.attributes.ATTR_LANGWATCH_THREAD_ID]: this.state.threadId,
@@ -4412,12 +4413,17 @@ var EventBus = class _EventBus {
4412
4413
  }
4413
4414
  /**
4414
4415
  * Stops accepting new events and drains the processing queue.
4416
+ * Times out after the specified duration to prevent blocking indefinitely
4417
+ * when the events endpoint is slow or unavailable.
4415
4418
  */
4416
- async drain() {
4419
+ async drain(timeoutMs = 3e5) {
4417
4420
  this.logger.debug("Draining event stream");
4418
4421
  this.events$.complete();
4419
4422
  if (this.processingPromise) {
4420
- await this.processingPromise;
4423
+ await Promise.race([
4424
+ this.processingPromise,
4425
+ new Promise((resolve) => setTimeout(resolve, timeoutMs))
4426
+ ]);
4421
4427
  }
4422
4428
  }
4423
4429
  /**
package/dist/index.mjs CHANGED
@@ -3837,6 +3837,7 @@ var ScenarioExecution = class {
3837
3837
  });
3838
3838
  this.currentTurnSpan = this.tracer.startSpan("Scenario Turn", {
3839
3839
  attributes: {
3840
+ "langwatch.origin": "simulation",
3840
3841
  "scenario.name": this.config.name,
3841
3842
  "scenario.id": this.config.id,
3842
3843
  [attributes3.ATTR_LANGWATCH_THREAD_ID]: this.state.threadId,
@@ -4359,12 +4360,17 @@ var EventBus = class _EventBus {
4359
4360
  }
4360
4361
  /**
4361
4362
  * Stops accepting new events and drains the processing queue.
4363
+ * Times out after the specified duration to prevent blocking indefinitely
4364
+ * when the events endpoint is slow or unavailable.
4362
4365
  */
4363
- async drain() {
4366
+ async drain(timeoutMs = 3e5) {
4364
4367
  this.logger.debug("Draining event stream");
4365
4368
  this.events$.complete();
4366
4369
  if (this.processingPromise) {
4367
- await this.processingPromise;
4370
+ await Promise.race([
4371
+ this.processingPromise,
4372
+ new Promise((resolve) => setTimeout(resolve, timeoutMs))
4373
+ ]);
4368
4374
  }
4369
4375
  }
4370
4376
  /**
@@ -606,12 +606,17 @@ var EventBus = class _EventBus {
606
606
  }
607
607
  /**
608
608
  * Stops accepting new events and drains the processing queue.
609
+ * Times out after the specified duration to prevent blocking indefinitely
610
+ * when the events endpoint is slow or unavailable.
609
611
  */
610
- async drain() {
612
+ async drain(timeoutMs = 3e5) {
611
613
  this.logger.debug("Draining event stream");
612
614
  this.events$.complete();
613
615
  if (this.processingPromise) {
614
- await this.processingPromise;
616
+ await Promise.race([
617
+ this.processingPromise,
618
+ new Promise((resolve) => setTimeout(resolve, timeoutMs))
619
+ ]);
615
620
  }
616
621
  }
617
622
  /**
@@ -589,12 +589,17 @@ var EventBus = class _EventBus {
589
589
  }
590
590
  /**
591
591
  * Stops accepting new events and drains the processing queue.
592
+ * Times out after the specified duration to prevent blocking indefinitely
593
+ * when the events endpoint is slow or unavailable.
592
594
  */
593
- async drain() {
595
+ async drain(timeoutMs = 3e5) {
594
596
  this.logger.debug("Draining event stream");
595
597
  this.events$.complete();
596
598
  if (this.processingPromise) {
597
- await this.processingPromise;
599
+ await Promise.race([
600
+ this.processingPromise,
601
+ new Promise((resolve) => setTimeout(resolve, timeoutMs))
602
+ ]);
598
603
  }
599
604
  }
600
605
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langwatch/scenario",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "A TypeScript library for testing AI agents using scenarios",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "homepage": "https://github.com/langwatch/scenario#readme",
24
24
  "author": "LangWatch",
25
- "license": "MIT",
25
+ "license": "AGPL-3.0",
26
26
  "engines": {
27
27
  "node": ">=20",
28
28
  "pnpm": ">=8"