llmist 15.8.1 → 15.9.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
@@ -9158,6 +9158,7 @@ var init_builder = __esm({
9158
9158
  textOnlyHandler;
9159
9159
  textWithGadgetsHandler;
9160
9160
  defaultGadgetTimeoutMs;
9161
+ gadgetExecutionMode;
9161
9162
  gadgetOutputLimit;
9162
9163
  gadgetOutputLimitPercent;
9163
9164
  compactionConfig;
@@ -9533,6 +9534,29 @@ var init_builder = __esm({
9533
9534
  this.defaultGadgetTimeoutMs = timeoutMs;
9534
9535
  return this;
9535
9536
  }
9537
+ /**
9538
+ * Set the gadget execution mode.
9539
+ *
9540
+ * Controls how multiple gadgets are executed when the LLM calls them:
9541
+ * - `'parallel'` (default): Gadgets without dependencies execute concurrently
9542
+ * - `'sequential'`: Gadgets execute one at a time, each awaiting completion
9543
+ *
9544
+ * @param mode - Execution mode ('parallel' or 'sequential')
9545
+ * @returns This builder for chaining
9546
+ *
9547
+ * @example
9548
+ * ```typescript
9549
+ * // Sequential execution for ordered file operations
9550
+ * .withGadgetExecutionMode('sequential')
9551
+ *
9552
+ * // Parallel execution (default) for independent operations
9553
+ * .withGadgetExecutionMode('parallel')
9554
+ * ```
9555
+ */
9556
+ withGadgetExecutionMode(mode) {
9557
+ this.gadgetExecutionMode = mode;
9558
+ return this;
9559
+ }
9536
9560
  /**
9537
9561
  * Enable or disable gadget output limiting.
9538
9562
  *
@@ -10013,6 +10037,7 @@ ${endPrefix}`
10013
10037
  textOnlyHandler: this.textOnlyHandler,
10014
10038
  textWithGadgetsHandler: this.textWithGadgetsHandler,
10015
10039
  defaultGadgetTimeoutMs: this.defaultGadgetTimeoutMs,
10040
+ gadgetExecutionMode: this.gadgetExecutionMode,
10016
10041
  gadgetOutputLimit: this.gadgetOutputLimit,
10017
10042
  gadgetOutputLimitPercent: this.gadgetOutputLimitPercent,
10018
10043
  compactionConfig: this.compactionConfig,
@@ -10199,6 +10224,7 @@ ${endPrefix}`
10199
10224
  textOnlyHandler: this.textOnlyHandler,
10200
10225
  textWithGadgetsHandler: this.textWithGadgetsHandler,
10201
10226
  defaultGadgetTimeoutMs: this.defaultGadgetTimeoutMs,
10227
+ gadgetExecutionMode: this.gadgetExecutionMode,
10202
10228
  gadgetOutputLimit: this.gadgetOutputLimit,
10203
10229
  gadgetOutputLimitPercent: this.gadgetOutputLimitPercent,
10204
10230
  compactionConfig: this.compactionConfig,
@@ -11795,6 +11821,8 @@ var init_stream_processor = __esm({
11795
11821
  tree;
11796
11822
  parentNodeId;
11797
11823
  baseDepth;
11824
+ // Gadget execution mode
11825
+ gadgetExecutionMode;
11798
11826
  responseText = "";
11799
11827
  observerFailureCount = 0;
11800
11828
  // Dependency tracking for gadget execution DAG
@@ -11830,6 +11858,7 @@ var init_stream_processor = __esm({
11830
11858
  this.tree = options.tree;
11831
11859
  this.parentNodeId = options.parentNodeId ?? null;
11832
11860
  this.baseDepth = options.baseDepth ?? 0;
11861
+ this.gadgetExecutionMode = options.gadgetExecutionMode ?? "parallel";
11833
11862
  this.priorCompletedInvocations = options.priorCompletedInvocations ?? /* @__PURE__ */ new Set();
11834
11863
  this.priorFailedInvocations = options.priorFailedInvocations ?? /* @__PURE__ */ new Set();
11835
11864
  this.subagentConfig = options.subagentConfig;
@@ -12141,7 +12170,13 @@ var init_stream_processor = __esm({
12141
12170
  this.concurrencyQueue.set(call.gadgetName, queue);
12142
12171
  return;
12143
12172
  }
12144
- this.startGadgetWithConcurrencyTracking(call);
12173
+ if (this.gadgetExecutionMode === "sequential") {
12174
+ for await (const evt of this.executeGadgetGenerator(call)) {
12175
+ yield evt;
12176
+ }
12177
+ } else {
12178
+ this.startGadgetWithConcurrencyTracking(call);
12179
+ }
12145
12180
  }
12146
12181
  /**
12147
12182
  * Get the effective concurrency limit for a gadget.
@@ -12593,25 +12628,37 @@ var init_stream_processor = __esm({
12593
12628
  progress = true;
12594
12629
  }
12595
12630
  if (readyToExecute.length > 0) {
12596
- this.logger.debug("Executing ready gadgets in parallel", {
12597
- count: readyToExecute.length,
12598
- invocationIds: readyToExecute.map((c) => c.invocationId)
12599
- });
12600
12631
  for (const call of readyToExecute) {
12601
12632
  this.gadgetsAwaitingDependencies.delete(call.invocationId);
12602
12633
  }
12603
- const eventSets = await Promise.all(
12604
- readyToExecute.map(async (call) => {
12605
- const events = [];
12634
+ if (this.gadgetExecutionMode === "sequential") {
12635
+ this.logger.debug("Executing ready gadgets sequentially", {
12636
+ count: readyToExecute.length,
12637
+ invocationIds: readyToExecute.map((c) => c.invocationId)
12638
+ });
12639
+ for (const call of readyToExecute) {
12606
12640
  for await (const evt of this.executeGadgetGenerator(call)) {
12607
- events.push(evt);
12641
+ yield evt;
12642
+ }
12643
+ }
12644
+ } else {
12645
+ this.logger.debug("Executing ready gadgets in parallel", {
12646
+ count: readyToExecute.length,
12647
+ invocationIds: readyToExecute.map((c) => c.invocationId)
12648
+ });
12649
+ const eventSets = await Promise.all(
12650
+ readyToExecute.map(async (call) => {
12651
+ const events = [];
12652
+ for await (const evt of this.executeGadgetGenerator(call)) {
12653
+ events.push(evt);
12654
+ }
12655
+ return events;
12656
+ })
12657
+ );
12658
+ for (const events of eventSets) {
12659
+ for (const evt of events) {
12660
+ yield evt;
12608
12661
  }
12609
- return events;
12610
- })
12611
- );
12612
- for (const events of eventSets) {
12613
- for (const evt of events) {
12614
- yield evt;
12615
12662
  }
12616
12663
  }
12617
12664
  progress = true;
@@ -12765,6 +12812,7 @@ var init_agent = __esm({
12765
12812
  textOnlyHandler;
12766
12813
  textWithGadgetsHandler;
12767
12814
  defaultGadgetTimeoutMs;
12815
+ gadgetExecutionMode;
12768
12816
  defaultMaxTokens;
12769
12817
  hasUserPrompt;
12770
12818
  // Gadget output limiting
@@ -12820,6 +12868,7 @@ var init_agent = __esm({
12820
12868
  this.textOnlyHandler = options.textOnlyHandler ?? "terminate";
12821
12869
  this.textWithGadgetsHandler = options.textWithGadgetsHandler;
12822
12870
  this.defaultGadgetTimeoutMs = options.defaultGadgetTimeoutMs;
12871
+ this.gadgetExecutionMode = options.gadgetExecutionMode ?? "parallel";
12823
12872
  this.defaultMaxTokens = this.resolveMaxTokensFromCatalog(options.model);
12824
12873
  this.outputLimitEnabled = options.gadgetOutputLimit ?? DEFAULT_GADGET_OUTPUT_LIMIT;
12825
12874
  this.outputStore = new GadgetOutputStore();
@@ -13151,6 +13200,7 @@ var init_agent = __esm({
13151
13200
  logger: this.logger.getSubLogger({ name: "stream-processor" }),
13152
13201
  requestHumanInput: this.requestHumanInput,
13153
13202
  defaultGadgetTimeoutMs: this.defaultGadgetTimeoutMs,
13203
+ gadgetExecutionMode: this.gadgetExecutionMode,
13154
13204
  client: this.client,
13155
13205
  mediaStore: this.mediaStore,
13156
13206
  agentConfig: this.agentContextConfig,