@ljoukov/llm 5.0.2 → 5.0.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.
package/dist/index.cjs CHANGED
@@ -6281,6 +6281,9 @@ async function maybeSpillToolOutputItem(item, toolName, options) {
6281
6281
  return item;
6282
6282
  }
6283
6283
  async function maybeSpillToolOutput(value, toolName, options) {
6284
+ if (options?.provider === "chatgpt") {
6285
+ return value;
6286
+ }
6284
6287
  if (typeof value === "string") {
6285
6288
  if (options?.force !== true && import_node_buffer4.Buffer.byteLength(value, "utf8") <= TOOL_OUTPUT_SPILL_THRESHOLD_BYTES) {
6286
6289
  return value;
@@ -6334,7 +6337,7 @@ function estimateToolOutputPayloadBytes(value) {
6334
6337
  }
6335
6338
  return 0;
6336
6339
  }
6337
- async function maybeSpillCombinedToolCallOutputs(callResults) {
6340
+ async function maybeSpillCombinedToolCallOutputs(callResults, options) {
6338
6341
  const totalBytes = callResults.reduce(
6339
6342
  (sum, callResult) => sum + estimateToolOutputPayloadBytes(callResult.outputPayload),
6340
6343
  0
@@ -6351,7 +6354,8 @@ async function maybeSpillCombinedToolCallOutputs(callResults) {
6351
6354
  callResult.outputPayload,
6352
6355
  callResult.entry.toolName,
6353
6356
  {
6354
- force: true
6357
+ force: true,
6358
+ provider: options?.provider
6355
6359
  }
6356
6360
  );
6357
6361
  return {
@@ -6581,7 +6585,7 @@ function extractSpawnStartupMetrics(outputPayload) {
6581
6585
  };
6582
6586
  }
6583
6587
  async function executeToolCall(params) {
6584
- const { callKind, toolName, tool: tool2, rawInput, parseError } = params;
6588
+ const { callKind, toolName, tool: tool2, rawInput, parseError, provider } = params;
6585
6589
  const startedAtMs = Date.now();
6586
6590
  const finalize = (base, outputPayload, metrics) => {
6587
6591
  const completedAtMs = Date.now();
@@ -6616,7 +6620,7 @@ async function executeToolCall(params) {
6616
6620
  const input = typeof rawInput === "string" ? rawInput : String(rawInput ?? "");
6617
6621
  try {
6618
6622
  const output = await tool2.execute(input);
6619
- const outputPayload = await maybeSpillToolOutput(output, toolName);
6623
+ const outputPayload = await maybeSpillToolOutput(output, toolName, { provider });
6620
6624
  const metrics = toolName === "spawn_agent" ? extractSpawnStartupMetrics(outputPayload) : void 0;
6621
6625
  return finalize({ toolName, input, output: outputPayload }, outputPayload, metrics);
6622
6626
  } catch (error) {
@@ -6652,7 +6656,7 @@ async function executeToolCall(params) {
6652
6656
  }
6653
6657
  try {
6654
6658
  const output = await tool2.execute(parsed.data);
6655
- const outputPayload = await maybeSpillToolOutput(output, toolName);
6659
+ const outputPayload = await maybeSpillToolOutput(output, toolName, { provider });
6656
6660
  const metrics = toolName === "spawn_agent" ? extractSpawnStartupMetrics(outputPayload) : void 0;
6657
6661
  return finalize(
6658
6662
  { toolName, input: parsed.data, output: outputPayload },
@@ -8452,13 +8456,15 @@ async function runToolLoop(request) {
8452
8456
  toolName: entry.toolName,
8453
8457
  tool: request.tools[entry.toolName],
8454
8458
  rawInput: entry.value,
8455
- parseError: entry.parseError
8459
+ parseError: entry.parseError,
8460
+ provider: providerInfo.provider
8456
8461
  });
8457
8462
  return { entry, result, outputPayload };
8458
8463
  }
8459
8464
  );
8460
8465
  })
8461
- )
8466
+ ),
8467
+ { provider: providerInfo.provider }
8462
8468
  );
8463
8469
  const toolOutputs = [];
8464
8470
  let toolExecutionMs = 0;
@@ -8755,13 +8761,15 @@ async function runToolLoop(request) {
8755
8761
  toolName: entry.toolName,
8756
8762
  tool: request.tools[entry.toolName],
8757
8763
  rawInput: entry.value,
8758
- parseError: entry.parseError
8764
+ parseError: entry.parseError,
8765
+ provider: "chatgpt"
8759
8766
  });
8760
8767
  return { entry, result, outputPayload };
8761
8768
  }
8762
8769
  );
8763
8770
  })
8764
- )
8771
+ ),
8772
+ { provider: "chatgpt" }
8765
8773
  );
8766
8774
  let toolExecutionMs = 0;
8767
8775
  let waitToolMs = 0;
@@ -9049,13 +9057,15 @@ async function runToolLoop(request) {
9049
9057
  toolName: entry.toolName,
9050
9058
  tool: request.tools[entry.toolName],
9051
9059
  rawInput: entry.value,
9052
- parseError: entry.parseError
9060
+ parseError: entry.parseError,
9061
+ provider: providerInfo.provider
9053
9062
  });
9054
9063
  return { entry, result, outputPayload };
9055
9064
  }
9056
9065
  );
9057
9066
  })
9058
- )
9067
+ ),
9068
+ { provider: providerInfo.provider }
9059
9069
  );
9060
9070
  const assistantToolCalls = [];
9061
9071
  const toolMessages = [];
@@ -9402,13 +9412,15 @@ async function runToolLoop(request) {
9402
9412
  callKind: "function",
9403
9413
  toolName: entry.toolName,
9404
9414
  tool: request.tools[entry.toolName],
9405
- rawInput: entry.rawInput
9415
+ rawInput: entry.rawInput,
9416
+ provider: "gemini"
9406
9417
  });
9407
9418
  return { entry, result, outputPayload };
9408
9419
  }
9409
9420
  );
9410
9421
  })
9411
- )
9422
+ ),
9423
+ { provider: "gemini" }
9412
9424
  );
9413
9425
  let toolExecutionMs = 0;
9414
9426
  let waitToolMs = 0;