@posthog/ai 7.16.0 → 7.16.2

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.
@@ -10,7 +10,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
11
  var AnthropicOriginal__default = /*#__PURE__*/_interopDefault(AnthropicOriginal);
12
12
 
13
- var version = "7.16.0";
13
+ var version = "7.16.2";
14
14
 
15
15
  // Type guards for safer type checking
16
16
 
@@ -2,7 +2,7 @@ import AnthropicOriginal from '@anthropic-ai/sdk';
2
2
  import { v4 } from 'uuid';
3
3
  import { uuidv7 } from '@posthog/core';
4
4
 
5
- var version = "7.16.0";
5
+ var version = "7.16.2";
6
6
 
7
7
  // Type guards for safer type checking
8
8
 
@@ -6,7 +6,7 @@ var genai = require('@google/genai');
6
6
  var uuid = require('uuid');
7
7
  var core = require('@posthog/core');
8
8
 
9
- var version = "7.16.0";
9
+ var version = "7.16.2";
10
10
 
11
11
  // Type guards for safer type checking
12
12
 
@@ -2,7 +2,7 @@ import { GoogleGenAI } from '@google/genai';
2
2
  import { v4 } from 'uuid';
3
3
  import { uuidv7 } from '@posthog/core';
4
4
 
5
- var version = "7.16.0";
5
+ var version = "7.16.2";
6
6
 
7
7
  // Type guards for safer type checking
8
8
 
package/dist/index.cjs CHANGED
@@ -29,7 +29,7 @@ function _interopNamespace(e) {
29
29
  var uuid__namespace = /*#__PURE__*/_interopNamespace(uuid);
30
30
  var AnthropicOriginal__default = /*#__PURE__*/_interopDefault(AnthropicOriginal);
31
31
 
32
- var version = "7.16.0";
32
+ var version = "7.16.2";
33
33
 
34
34
  // Type guards for safer type checking
35
35
  const isString = value => {
@@ -2213,12 +2213,14 @@ const mapVercelOutput = result => {
2213
2213
  };
2214
2214
  }
2215
2215
  if (item.type === 'tool-call') {
2216
+ const toolCall = item;
2217
+ const rawArgs = toolCall.input ?? toolCall.args ?? toolCall.arguments ?? {};
2216
2218
  return {
2217
2219
  type: 'tool-call',
2218
2220
  id: item.toolCallId,
2219
2221
  function: {
2220
2222
  name: item.toolName,
2221
- arguments: item.args || JSON.stringify(item.arguments || {})
2223
+ arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs)
2222
2224
  }
2223
2225
  };
2224
2226
  }
@@ -4460,6 +4462,14 @@ class LangChainCallbackHandler extends BaseCallbackHandler {
4460
4462
 
4461
4463
  /// <reference lib="dom" />
4462
4464
  const DEFAULT_CACHE_TTL_SECONDS = 300; // 5 minutes
4465
+ const DEFAULT_PROMPTS_HOST = 'https://us.posthog.com';
4466
+ function normalizeApiKey(value) {
4467
+ return typeof value === 'string' ? value.trim() : '';
4468
+ }
4469
+ function normalizeHost(value) {
4470
+ const normalizedHost = typeof value === 'string' ? value.trim() : '';
4471
+ return (normalizedHost || DEFAULT_PROMPTS_HOST).replace(/\/+$/, '');
4472
+ }
4463
4473
  function isPromptApiResponse(data) {
4464
4474
  if (typeof data !== 'object' || data === null) {
4465
4475
  return false;
@@ -4510,13 +4520,13 @@ class Prompts {
4510
4520
  this.defaultCacheTtlSeconds = options.defaultCacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS;
4511
4521
  if (isPromptsWithPostHog(options)) {
4512
4522
  this.personalApiKey = options.posthog.options.personalApiKey ?? '';
4513
- this.projectApiKey = options.posthog.apiKey ?? '';
4523
+ this.projectApiKey = options.posthog.apiKey;
4514
4524
  this.host = options.posthog.host;
4515
4525
  } else {
4516
4526
  // Direct options
4517
- this.personalApiKey = options.personalApiKey;
4518
- this.projectApiKey = options.projectApiKey;
4519
- this.host = options.host ?? 'https://us.posthog.com';
4527
+ this.personalApiKey = normalizeApiKey(options.personalApiKey);
4528
+ this.projectApiKey = normalizeApiKey(options.projectApiKey);
4529
+ this.host = normalizeHost(options.host);
4520
4530
  }
4521
4531
  }
4522
4532
  getPromptCache(name) {