@posthog/ai 8.11.2 → 8.12.1

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.
Files changed (44) hide show
  1. package/README.md +24 -0
  2. package/dist/adk/index.cjs +1 -1
  3. package/dist/adk/index.cjs.map +1 -1
  4. package/dist/adk/index.mjs +1 -1
  5. package/dist/adk/index.mjs.map +1 -1
  6. package/dist/anthropic/index.cjs +1 -1
  7. package/dist/anthropic/index.cjs.map +1 -1
  8. package/dist/anthropic/index.mjs +1 -1
  9. package/dist/anthropic/index.mjs.map +1 -1
  10. package/dist/claude-agent-sdk/index.cjs +1142 -0
  11. package/dist/claude-agent-sdk/index.cjs.map +1 -0
  12. package/dist/claude-agent-sdk/index.d.ts +148 -0
  13. package/dist/claude-agent-sdk/index.mjs +1139 -0
  14. package/dist/claude-agent-sdk/index.mjs.map +1 -0
  15. package/dist/gemini/index.cjs +1 -1
  16. package/dist/gemini/index.cjs.map +1 -1
  17. package/dist/gemini/index.mjs +1 -1
  18. package/dist/gemini/index.mjs.map +1 -1
  19. package/dist/index.cjs +11 -7
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +6 -3
  22. package/dist/index.mjs +11 -7
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/langchain/index.cjs +1 -1
  25. package/dist/langchain/index.cjs.map +1 -1
  26. package/dist/langchain/index.mjs +1 -1
  27. package/dist/langchain/index.mjs.map +1 -1
  28. package/dist/langchain/middleware/index.cjs +1 -1
  29. package/dist/langchain/middleware/index.cjs.map +1 -1
  30. package/dist/langchain/middleware/index.mjs +1 -1
  31. package/dist/langchain/middleware/index.mjs.map +1 -1
  32. package/dist/openai/index.cjs +1 -1
  33. package/dist/openai/index.cjs.map +1 -1
  34. package/dist/openai/index.mjs +1 -1
  35. package/dist/openai/index.mjs.map +1 -1
  36. package/dist/openai-agents/index.cjs +4 -4
  37. package/dist/openai-agents/index.cjs.map +1 -1
  38. package/dist/openai-agents/index.mjs +4 -4
  39. package/dist/openai-agents/index.mjs.map +1 -1
  40. package/dist/vercel/index.cjs +4 -4
  41. package/dist/vercel/index.cjs.map +1 -1
  42. package/dist/vercel/index.mjs +4 -4
  43. package/dist/vercel/index.mjs.map +1 -1
  44. package/package.json +11 -1
package/dist/index.d.ts CHANGED
@@ -192,9 +192,12 @@ declare class Prompts {
192
192
  * with many prompts can call this once per cache cycle instead of making one
193
193
  * `get()` request per prompt.
194
194
  *
195
- * Throws if the request fails, or if the server does not support fetching
196
- * prompts by label on the list endpoint (PostHog releases from before
197
- * September 2026).
195
+ * Unlike `get()`, there is no `fallback` option, so callers should handle
196
+ * the error themselves.
197
+ *
198
+ * @throws {Error} When the request fails, when the response is malformed,
199
+ * or when the server does not support fetching prompts by label on the list
200
+ * endpoint (PostHog releases from before September 2026).
198
201
  */
199
202
  getAll(options: {
200
203
  label: string;
package/dist/index.mjs CHANGED
@@ -294,13 +294,13 @@ function toSafeString(input) {
294
294
  return "";
295
295
  }
296
296
  }
297
- const truncate = (input, client) => {
297
+ const truncate = (input, client, maxBytes = MAX_OUTPUT_SIZE) => {
298
298
  const str = toSafeString(input);
299
299
  if (str === "") return "";
300
300
  if (isFullAiCaptureEnabled(client)) return str;
301
301
  const buffer = sharedTextEncoder.encode(str);
302
- if (buffer.length <= 2e5) return sharedTextDecoder.decode(buffer);
303
- const truncatedBuffer = buffer.slice(0, MAX_OUTPUT_SIZE);
302
+ if (buffer.length <= maxBytes) return sharedTextDecoder.decode(buffer);
303
+ const truncatedBuffer = buffer.slice(0, maxBytes);
304
304
  let truncatedStr = sharedTextDecoder.decode(truncatedBuffer);
305
305
  if (truncatedStr.endsWith("�")) truncatedStr = truncatedStr.slice(0, -1);
306
306
  return `${truncatedStr}... [truncated]`;
@@ -395,7 +395,7 @@ function sanitizeValues(obj) {
395
395
  }
396
396
  //#endregion
397
397
  //#region package.json
398
- var version = "8.11.2";
398
+ var version = "8.12.1";
399
399
  //#endregion
400
400
  //#region src/serializeError.ts
401
401
  const DEFAULT_MAX_DEPTH = 3;
@@ -1264,9 +1264,12 @@ var Prompts = class {
1264
1264
  * with many prompts can call this once per cache cycle instead of making one
1265
1265
  * `get()` request per prompt.
1266
1266
  *
1267
- * Throws if the request fails, or if the server does not support fetching
1268
- * prompts by label on the list endpoint (PostHog releases from before
1269
- * September 2026).
1267
+ * Unlike `get()`, there is no `fallback` option, so callers should handle
1268
+ * the error themselves.
1269
+ *
1270
+ * @throws {Error} When the request fails, when the response is malformed,
1271
+ * or when the server does not support fetching prompts by label on the list
1272
+ * endpoint (PostHog releases from before September 2026).
1270
1273
  */
1271
1274
  async getAll(options) {
1272
1275
  const label = options.label;
@@ -1283,6 +1286,7 @@ var Prompts = class {
1283
1286
  }
1284
1287
  resolvedRows.push(row);
1285
1288
  }
1289
+ if (rows.length > 0 && resolvedRows.length === 0) throw new Error(`[PostHog Prompts] The server returned prompts, but none resolve label "${label}". It may not support fetching prompts by label on the list endpoint yet. Upgrade PostHog, or fetch prompts one by one with get().`);
1286
1290
  const now = Date.now();
1287
1291
  const results = /* @__PURE__ */ new Map();
1288
1292
  for (const row of resolvedRows) {