@posthog/ai 8.22.5 → 8.23.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.
package/dist/index.d.ts CHANGED
@@ -80,6 +80,7 @@ type PromptVariables = Record<string, string | number | boolean>;
80
80
  * Direct options for initializing Prompts without a PostHog client
81
81
  */
82
82
  interface PromptsDirectOptions {
83
+ /** A personal API key (`phx_`) or a project secret API key (`phs_`) with the `llm_prompt:read` scope. */
83
84
  personalApiKey: string;
84
85
  projectApiKey: string;
85
86
  host?: string;
package/dist/index.mjs CHANGED
@@ -603,7 +603,7 @@ function sanitizeValues(obj) {
603
603
  }
604
604
  //#endregion
605
605
  //#region package.json
606
- var version = "8.22.5";
606
+ var version = "8.23.1";
607
607
  //#endregion
608
608
  //#region src/serializeError.ts
609
609
  const DEFAULT_MAX_DEPTH = 3;
@@ -1835,7 +1835,7 @@ var Prompts = class {
1835
1835
  if (pages >= MAX_PROMPT_LIST_PAGES) throw new Error(`[PostHog Prompts] ${reference} spans more than ${MAX_PROMPT_LIST_PAGES} pages. Refusing to return an incomplete result.`);
1836
1836
  const { response, data } = await fetchJsonWithTimeout(url, this.personalApiKey, reference);
1837
1837
  if (!response.ok) {
1838
- if (response.status === 403) throw new Error(`[PostHog Prompts] Access denied for ${reference}. Check that your personalApiKey has the correct permissions and the LLM prompts feature is enabled.`);
1838
+ if (response.status === 403) throw new Error(`[PostHog Prompts] Access denied for ${reference}. Check that the key in personalApiKey has the llm_prompt:read scope and the LLM prompts feature is enabled.`);
1839
1839
  throw new PromptFetchError(`[PostHog Prompts] Failed to fetch ${reference}: HTTP ${response.status}`, response.status === 429 ? parseRetryAfterSeconds(response.headers?.get("Retry-After")) : void 0);
1840
1840
  }
1841
1841
  if (typeof data !== "object" || data === null || !Array.isArray(data.results)) throw new Error(`[PostHog Prompts] Invalid response format for ${reference}`);
@@ -1857,7 +1857,7 @@ var Prompts = class {
1857
1857
  const { response, data } = await fetchJsonWithTimeout(`${this.host}/api/environments/@current/llm_prompts/name/${encodedPromptName}/?token=${encodedProjectApiKey}${versionQuery}${labelQuery}`, this.personalApiKey, `prompt ${promptReference}`);
1858
1858
  if (!response.ok) {
1859
1859
  if (response.status === 404) throw new Error(`[PostHog Prompts] Prompt ${promptReference} not found`);
1860
- if (response.status === 403) throw new Error(`[PostHog Prompts] Access denied for prompt ${promptReference}. Check that your personalApiKey has the correct permissions and the LLM prompts feature is enabled.`);
1860
+ if (response.status === 403) throw new Error(`[PostHog Prompts] Access denied for prompt ${promptReference}. Check that the key in personalApiKey has the llm_prompt:read scope and the LLM prompts feature is enabled.`);
1861
1861
  throw new PromptFetchError(`[PostHog Prompts] Failed to fetch prompt ${promptReference}: HTTP ${response.status}`, response.status === 429 ? parseRetryAfterSeconds(response.headers?.get("Retry-After")) : void 0);
1862
1862
  }
1863
1863
  if (!isPromptApiResponse(data)) throw new Error(`[PostHog Prompts] Invalid response format for prompt ${promptReference}`);