@standardagents/builder 0.27.2 → 0.27.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.
@@ -12333,6 +12333,7 @@ var init_ThreadStateImpl = __esm({
12333
12333
  _executionState = null;
12334
12334
  _childrenCache = [];
12335
12335
  _terminatedCache = null;
12336
+ _pendingEventDeliveries = /* @__PURE__ */ new Set();
12336
12337
  constructor(flowState, threadInstance, metadata, runtimeContext = {}) {
12337
12338
  this._flowState = flowState;
12338
12339
  this._threadInstance = threadInstance;
@@ -12784,6 +12785,22 @@ var init_ThreadStateImpl = __esm({
12784
12785
  emit(event, data) {
12785
12786
  if (this._flowState?.emitEvent) {
12786
12787
  this._flowState.emitEvent(event, data);
12788
+ return;
12789
+ }
12790
+ if (this._threadInstance.emitThreadEvent) {
12791
+ const delivery = this._threadInstance.emitThreadEvent(this.threadId, event, data);
12792
+ if (delivery && typeof delivery.then === "function") {
12793
+ const pending = Promise.resolve(delivery).catch((error) => {
12794
+ console.error(`[ThreadState] Custom event "${event}" delivery failed:`, error);
12795
+ }).finally(() => this._pendingEventDeliveries.delete(pending));
12796
+ this._pendingEventDeliveries.add(pending);
12797
+ }
12798
+ }
12799
+ }
12800
+ /** Runtime-only drain used by thread endpoint wrappers before responding. */
12801
+ async flushPendingEventDeliveries() {
12802
+ while (this._pendingEventDeliveries.size > 0) {
12803
+ await Promise.all([...this._pendingEventDeliveries]);
12787
12804
  }
12788
12805
  }
12789
12806
  // ─────────────────────────────────────────────────────────────────────────
@@ -66175,7 +66192,7 @@ var config_get_default = defineController2(async ({ config, env: env2, req }) =>
66175
66192
  });
66176
66193
 
66177
66194
  // src/version.ts
66178
- var BUILDER_VERSION = "0.27.2".length > 0 ? "0.27.2" : "dev";
66195
+ var BUILDER_VERSION = "0.27.3".length > 0 ? "0.27.3" : "dev";
66179
66196
 
66180
66197
  // src/api/diagnostics.get.ts
66181
66198
  init_LLMRequest();