@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.js CHANGED
@@ -6167,6 +6167,9 @@ async function maybeSpillToolOutputItem(item, toolName, options) {
6167
6167
  return item;
6168
6168
  }
6169
6169
  async function maybeSpillToolOutput(value, toolName, options) {
6170
+ if (options?.provider === "chatgpt") {
6171
+ return value;
6172
+ }
6170
6173
  if (typeof value === "string") {
6171
6174
  if (options?.force !== true && Buffer5.byteLength(value, "utf8") <= TOOL_OUTPUT_SPILL_THRESHOLD_BYTES) {
6172
6175
  return value;
@@ -6220,7 +6223,7 @@ function estimateToolOutputPayloadBytes(value) {
6220
6223
  }
6221
6224
  return 0;
6222
6225
  }
6223
- async function maybeSpillCombinedToolCallOutputs(callResults) {
6226
+ async function maybeSpillCombinedToolCallOutputs(callResults, options) {
6224
6227
  const totalBytes = callResults.reduce(
6225
6228
  (sum, callResult) => sum + estimateToolOutputPayloadBytes(callResult.outputPayload),
6226
6229
  0
@@ -6237,7 +6240,8 @@ async function maybeSpillCombinedToolCallOutputs(callResults) {
6237
6240
  callResult.outputPayload,
6238
6241
  callResult.entry.toolName,
6239
6242
  {
6240
- force: true
6243
+ force: true,
6244
+ provider: options?.provider
6241
6245
  }
6242
6246
  );
6243
6247
  return {
@@ -6467,7 +6471,7 @@ function extractSpawnStartupMetrics(outputPayload) {
6467
6471
  };
6468
6472
  }
6469
6473
  async function executeToolCall(params) {
6470
- const { callKind, toolName, tool: tool2, rawInput, parseError } = params;
6474
+ const { callKind, toolName, tool: tool2, rawInput, parseError, provider } = params;
6471
6475
  const startedAtMs = Date.now();
6472
6476
  const finalize = (base, outputPayload, metrics) => {
6473
6477
  const completedAtMs = Date.now();
@@ -6502,7 +6506,7 @@ async function executeToolCall(params) {
6502
6506
  const input = typeof rawInput === "string" ? rawInput : String(rawInput ?? "");
6503
6507
  try {
6504
6508
  const output = await tool2.execute(input);
6505
- const outputPayload = await maybeSpillToolOutput(output, toolName);
6509
+ const outputPayload = await maybeSpillToolOutput(output, toolName, { provider });
6506
6510
  const metrics = toolName === "spawn_agent" ? extractSpawnStartupMetrics(outputPayload) : void 0;
6507
6511
  return finalize({ toolName, input, output: outputPayload }, outputPayload, metrics);
6508
6512
  } catch (error) {
@@ -6538,7 +6542,7 @@ async function executeToolCall(params) {
6538
6542
  }
6539
6543
  try {
6540
6544
  const output = await tool2.execute(parsed.data);
6541
- const outputPayload = await maybeSpillToolOutput(output, toolName);
6545
+ const outputPayload = await maybeSpillToolOutput(output, toolName, { provider });
6542
6546
  const metrics = toolName === "spawn_agent" ? extractSpawnStartupMetrics(outputPayload) : void 0;
6543
6547
  return finalize(
6544
6548
  { toolName, input: parsed.data, output: outputPayload },
@@ -8338,13 +8342,15 @@ async function runToolLoop(request) {
8338
8342
  toolName: entry.toolName,
8339
8343
  tool: request.tools[entry.toolName],
8340
8344
  rawInput: entry.value,
8341
- parseError: entry.parseError
8345
+ parseError: entry.parseError,
8346
+ provider: providerInfo.provider
8342
8347
  });
8343
8348
  return { entry, result, outputPayload };
8344
8349
  }
8345
8350
  );
8346
8351
  })
8347
- )
8352
+ ),
8353
+ { provider: providerInfo.provider }
8348
8354
  );
8349
8355
  const toolOutputs = [];
8350
8356
  let toolExecutionMs = 0;
@@ -8641,13 +8647,15 @@ async function runToolLoop(request) {
8641
8647
  toolName: entry.toolName,
8642
8648
  tool: request.tools[entry.toolName],
8643
8649
  rawInput: entry.value,
8644
- parseError: entry.parseError
8650
+ parseError: entry.parseError,
8651
+ provider: "chatgpt"
8645
8652
  });
8646
8653
  return { entry, result, outputPayload };
8647
8654
  }
8648
8655
  );
8649
8656
  })
8650
- )
8657
+ ),
8658
+ { provider: "chatgpt" }
8651
8659
  );
8652
8660
  let toolExecutionMs = 0;
8653
8661
  let waitToolMs = 0;
@@ -8935,13 +8943,15 @@ async function runToolLoop(request) {
8935
8943
  toolName: entry.toolName,
8936
8944
  tool: request.tools[entry.toolName],
8937
8945
  rawInput: entry.value,
8938
- parseError: entry.parseError
8946
+ parseError: entry.parseError,
8947
+ provider: providerInfo.provider
8939
8948
  });
8940
8949
  return { entry, result, outputPayload };
8941
8950
  }
8942
8951
  );
8943
8952
  })
8944
- )
8953
+ ),
8954
+ { provider: providerInfo.provider }
8945
8955
  );
8946
8956
  const assistantToolCalls = [];
8947
8957
  const toolMessages = [];
@@ -9288,13 +9298,15 @@ async function runToolLoop(request) {
9288
9298
  callKind: "function",
9289
9299
  toolName: entry.toolName,
9290
9300
  tool: request.tools[entry.toolName],
9291
- rawInput: entry.rawInput
9301
+ rawInput: entry.rawInput,
9302
+ provider: "gemini"
9292
9303
  });
9293
9304
  return { entry, result, outputPayload };
9294
9305
  }
9295
9306
  );
9296
9307
  })
9297
- )
9308
+ ),
9309
+ { provider: "gemini" }
9298
9310
  );
9299
9311
  let toolExecutionMs = 0;
9300
9312
  let waitToolMs = 0;