@posthog/ai 8.19.2 → 8.20.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.
@@ -465,7 +465,7 @@ function addDefaults(params) {
465
465
  }
466
466
  //#endregion
467
467
  //#region package.json
468
- var version = "8.19.2";
468
+ var version = "8.20.0";
469
469
  //#endregion
470
470
  //#region src/serializeError.ts
471
471
  const DEFAULT_MAX_DEPTH = 3;
@@ -461,7 +461,7 @@ function addDefaults(params) {
461
461
  }
462
462
  //#endregion
463
463
  //#region package.json
464
- var version = "8.19.2";
464
+ var version = "8.20.0";
465
465
  //#endregion
466
466
  //#region src/serializeError.ts
467
467
  const DEFAULT_MAX_DEPTH = 3;
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let uuid = require("uuid");
3
3
  let _posthog_core = require("@posthog/core");
4
4
  //#region package.json
5
- var version = "8.19.2";
5
+ var version = "8.20.0";
6
6
  //#endregion
7
7
  //#region src/captureAiEvent.ts
8
8
  /** @internal */
@@ -1,7 +1,7 @@
1
1
  import { v4 } from "uuid";
2
2
  import { toJsonSafeValue, uuidv7 } from "@posthog/core";
3
3
  //#region package.json
4
- var version = "8.19.2";
4
+ var version = "8.20.0";
5
5
  //#endregion
6
6
  //#region src/captureAiEvent.ts
7
7
  /** @internal */
package/dist/index.cjs CHANGED
@@ -419,7 +419,7 @@ function sanitizeValues(obj) {
419
419
  }
420
420
  //#endregion
421
421
  //#region package.json
422
- var version = "8.19.2";
422
+ var version = "8.20.0";
423
423
  //#endregion
424
424
  //#region src/serializeError.ts
425
425
  const DEFAULT_MAX_DEPTH = 3;
package/dist/index.mjs CHANGED
@@ -418,7 +418,7 @@ function sanitizeValues(obj) {
418
418
  }
419
419
  //#endregion
420
420
  //#region package.json
421
- var version = "8.19.2";
421
+ var version = "8.20.0";
422
422
  //#endregion
423
423
  //#region src/serializeError.ts
424
424
  const DEFAULT_MAX_DEPTH = 3;
@@ -308,7 +308,7 @@ function redactMcpToolCredentials(tools) {
308
308
  }
309
309
  //#endregion
310
310
  //#region package.json
311
- var version = "8.19.2";
311
+ var version = "8.20.0";
312
312
  //#endregion
313
313
  //#region src/serializeError.ts
314
314
  const DEFAULT_MAX_DEPTH = 3;
@@ -307,7 +307,7 @@ function redactMcpToolCredentials(tools) {
307
307
  }
308
308
  //#endregion
309
309
  //#region package.json
310
- var version = "8.19.2";
310
+ var version = "8.20.0";
311
311
  //#endregion
312
312
  //#region src/serializeError.ts
313
313
  const DEFAULT_MAX_DEPTH = 3;
@@ -313,7 +313,7 @@ function redactMcpToolCredentials(tools) {
313
313
  }
314
314
  //#endregion
315
315
  //#region package.json
316
- var version = "8.19.2";
316
+ var version = "8.20.0";
317
317
  //#endregion
318
318
  //#region src/serializeError.ts
319
319
  const DEFAULT_MAX_DEPTH = 3;
@@ -312,7 +312,7 @@ function redactMcpToolCredentials(tools) {
312
312
  }
313
313
  //#endregion
314
314
  //#region package.json
315
- var version = "8.19.2";
315
+ var version = "8.20.0";
316
316
  //#endregion
317
317
  //#region src/serializeError.ts
318
318
  const DEFAULT_MAX_DEPTH = 3;
@@ -556,7 +556,7 @@ function formatOpenAIResponsesInput(input, instructions) {
556
556
  }
557
557
  //#endregion
558
558
  //#region package.json
559
- var version = "8.19.2";
559
+ var version = "8.20.0";
560
560
  //#endregion
561
561
  //#region src/serializeError.ts
562
562
  const DEFAULT_MAX_DEPTH = 3;
@@ -1318,8 +1318,10 @@ var OpenAIChatStreamAccumulator = class {
1318
1318
  arguments: ""
1319
1319
  };
1320
1320
  if (toolCall.id) current.id = toolCall.id;
1321
- if (toolCall.function?.name) current.name = toolCall.function.name;
1322
- if (toolCall.function?.arguments) current.arguments += toolCall.function.arguments;
1321
+ const name = toolCall.function?.name ?? toolCall.custom?.name;
1322
+ const argumentsDelta = toolCall.function?.arguments ?? toolCall.custom?.input;
1323
+ if (name) current.name = name;
1324
+ if (argumentsDelta) current.arguments += argumentsDelta;
1323
1325
  this.toolCalls.set(key, current);
1324
1326
  this.lastToolCallKey = key;
1325
1327
  }
@@ -1336,14 +1338,15 @@ var OpenAIChatStreamAccumulator = class {
1336
1338
  }
1337
1339
  /**
1338
1340
  * Some OpenAI-compatible providers stream tool calls without an `index`. Match those deltas by a known
1339
- * `id`; a new `id` or a function name opens a new call, and anything else continues the latest call.
1341
+ * `id`; a new `id`, a function name, or a custom tool name opens a new call, and anything else continues
1342
+ * the latest call.
1340
1343
  */
1341
1344
  toolCallKey(toolCall) {
1342
1345
  if (toolCall.index !== void 0) return toolCall.index;
1343
1346
  if (toolCall.id) {
1344
1347
  for (const [key, existing] of this.toolCalls) if (existing.id === toolCall.id) return key;
1345
1348
  }
1346
- if (toolCall.id || toolCall.function?.name || this.lastToolCallKey === void 0) return `no-index-${this.toolCalls.size}`;
1349
+ if (toolCall.id || toolCall.function?.name || toolCall.custom?.name || this.lastToolCallKey === void 0) return `no-index-${this.toolCalls.size}`;
1347
1350
  return this.lastToolCallKey;
1348
1351
  }
1349
1352
  result() {