llmist 5.1.0 → 6.0.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.cjs CHANGED
@@ -3936,6 +3936,8 @@ var init_stream_processor = __esm({
3936
3936
  completedResults = /* @__PURE__ */ new Map();
3937
3937
  /** Invocation IDs of gadgets that have failed (error or skipped due to dependency) */
3938
3938
  failedInvocations = /* @__PURE__ */ new Set();
3939
+ /** Promises for independent gadgets currently executing (fire-and-forget) */
3940
+ inFlightExecutions = /* @__PURE__ */ new Map();
3939
3941
  constructor(options) {
3940
3942
  this.iteration = options.iteration;
3941
3943
  this.registry = options.registry;
@@ -4044,6 +4046,16 @@ var init_stream_processor = __esm({
4044
4046
  }
4045
4047
  }
4046
4048
  }
4049
+ const inFlightResults = await this.collectInFlightResults();
4050
+ for (const evt of inFlightResults) {
4051
+ yield evt;
4052
+ if (evt.type === "gadget_result") {
4053
+ didExecuteGadgets = true;
4054
+ if (evt.result.breaksLoop) {
4055
+ shouldBreakLoop = true;
4056
+ }
4057
+ }
4058
+ }
4047
4059
  for await (const evt of this.processPendingGadgetsGenerator()) {
4048
4060
  yield evt;
4049
4061
  if (evt.type === "gadget_result") {
@@ -4229,12 +4241,24 @@ var init_stream_processor = __esm({
4229
4241
  this.gadgetsAwaitingDependencies.set(call.invocationId, call);
4230
4242
  return;
4231
4243
  }
4244
+ for await (const evt of this.executeGadgetGenerator(call)) {
4245
+ yield evt;
4246
+ }
4247
+ for await (const evt of this.processPendingGadgetsGenerator()) {
4248
+ yield evt;
4249
+ }
4250
+ return;
4232
4251
  }
4233
- for await (const evt of this.executeGadgetGenerator(call)) {
4234
- yield evt;
4235
- }
4236
- for await (const evt of this.processPendingGadgetsGenerator()) {
4237
- yield evt;
4252
+ if (this.stopOnGadgetError) {
4253
+ for await (const evt of this.executeGadgetGenerator(call)) {
4254
+ yield evt;
4255
+ }
4256
+ for await (const evt of this.processPendingGadgetsGenerator()) {
4257
+ yield evt;
4258
+ }
4259
+ } else {
4260
+ const executionPromise = this.executeGadgetAndCollect(call);
4261
+ this.inFlightExecutions.set(call.invocationId, executionPromise);
4238
4262
  }
4239
4263
  }
4240
4264
  /**
@@ -4546,6 +4570,36 @@ var init_stream_processor = __esm({
4546
4570
  }
4547
4571
  }
4548
4572
  }
4573
+ /**
4574
+ * Execute a gadget and collect all events into an array (non-blocking).
4575
+ * Used for fire-and-forget parallel execution of independent gadgets.
4576
+ */
4577
+ async executeGadgetAndCollect(call) {
4578
+ const events = [];
4579
+ for await (const evt of this.executeGadgetGenerator(call)) {
4580
+ events.push(evt);
4581
+ }
4582
+ return events;
4583
+ }
4584
+ /**
4585
+ * Collect results from all fire-and-forget (in-flight) gadget executions.
4586
+ * Called at stream end to await parallel independent gadgets.
4587
+ * Clears the inFlightExecutions map after collection.
4588
+ * @returns Array of all events from completed gadgets
4589
+ */
4590
+ async collectInFlightResults() {
4591
+ if (this.inFlightExecutions.size === 0) {
4592
+ return [];
4593
+ }
4594
+ this.logger.debug("Collecting in-flight gadget results", {
4595
+ count: this.inFlightExecutions.size,
4596
+ invocationIds: Array.from(this.inFlightExecutions.keys())
4597
+ });
4598
+ const promises = Array.from(this.inFlightExecutions.values());
4599
+ const results = await Promise.all(promises);
4600
+ this.inFlightExecutions.clear();
4601
+ return results.flat();
4602
+ }
4549
4603
  /**
4550
4604
  * Handle a gadget that cannot execute because a dependency failed.
4551
4605
  * Calls the onDependencySkipped controller to allow customization.