@appilots/sdk 0.5.0 → 0.6.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.
@@ -1,4 +1,4 @@
1
- import { getFiberRoot, recordIntrospectionFailure, getCurrentScreen, getActiveRouteNames, deriveInteractionElements, attachElementIdsToChoiceGroups, elementRegistry, appilotsDebugWarn, getDefaultRegistry, useAppilotsContext, ChatSessionMachine, getCurrentScreenSignature, ActionQueueMachine, getScreenMetadata, setCurrentScreen, useResolvedRegistry, listRegistry, componentRegistry, probeLoadingState, isListItemPressTarget, waitForLoadingSettle, appilotsDebugLog, waitForScreenSettle, screenDepartedBaseline, routesBelongToSameFeature, actionPressTargetId, getNavigationStateSnapshot, getNavigationRef, isOptionalStepAutomationFailure, OPTIONAL_STEP_AUTOMATION_HINT, normalize3, matchScore, idLooselyMatches, parseStableElementId, getAllScreens, snapshotShowsOpenCreateForm, looksDestructiveActionLabel, isGenericSelectValue } from './chunk-BIEF6MNR.mjs';
1
+ import { getFiberRoot, recordIntrospectionFailure, getCurrentScreen, getActiveRouteNames, deriveInteractionElements, attachElementIdsToChoiceGroups, elementRegistry, appilotsDebugWarn, getDefaultRegistry, useAppilotsContext, ChatSessionMachine, getCurrentScreenSignature, ActionQueueMachine, getScreenMetadata, setCurrentScreen, useResolvedRegistry, listRegistry, componentRegistry, probeLoadingState, isListItemPressTarget, waitForLoadingSettle, appilotsDebugLog, waitForScreenSettle, screenDepartedBaseline, routesBelongToSameFeature, actionPressTargetId, getNavigationStateSnapshot, getNavigationRef, isOptionalStepAutomationFailure, OPTIONAL_STEP_AUTOMATION_HINT, normalize3, matchScore, idLooselyMatches, parseStableElementId, getAllScreens, snapshotShowsOpenCreateForm, looksDestructiveActionLabel, isGenericSelectValue } from './chunk-R4D34FEW.mjs';
2
2
  import { useMemo, useRef, useSyncExternalStore, useEffect, useCallback, useState } from 'react';
3
3
  import { Alert } from 'react-native';
4
4
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkPQHZTAFG_js = require('./chunk-PQHZTAFG.js');
3
+ var chunkDZ7QRFHD_js = require('./chunk-DZ7QRFHD.js');
4
4
  var React = require('react');
5
5
 
6
6
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -15,11 +15,11 @@ function getActiveRouteName(state) {
15
15
  return route.name;
16
16
  }
17
17
  function AppilotsNavigationContainer({ children }) {
18
- const { emit } = chunkPQHZTAFG_js.useAppilotsContext();
18
+ const { emit } = chunkDZ7QRFHD_js.useAppilotsContext();
19
19
  const internalRef = React.useRef(null);
20
20
  const handleRef = React.useCallback((instance) => {
21
21
  internalRef.current = instance;
22
- chunkPQHZTAFG_js.setNavigationRef(instance);
22
+ chunkDZ7QRFHD_js.setNavigationRef(instance);
23
23
  const childRef = children.ref;
24
24
  if (typeof childRef === "function") childRef(instance);
25
25
  else if (childRef && typeof childRef === "object") childRef.current = instance;
@@ -32,7 +32,7 @@ function AppilotsNavigationContainer({ children }) {
32
32
  const routeName = getActiveRouteName(state);
33
33
  if (routeName) {
34
34
  console.log(`[Appilots] Screen changed \u2192 "${routeName}"`);
35
- chunkPQHZTAFG_js.setCurrentScreen(routeName);
35
+ chunkDZ7QRFHD_js.setCurrentScreen(routeName);
36
36
  emit({
37
37
  type: "navigation:change",
38
38
  timestamp: Date.now(),
@@ -48,7 +48,7 @@ function AppilotsNavigationContainer({ children }) {
48
48
  const route = internalRef.current?.getCurrentRoute?.();
49
49
  if (route?.name) {
50
50
  console.log(`[Appilots] Initial screen \u2192 "${route.name}"`);
51
- chunkPQHZTAFG_js.setCurrentScreen(route.name);
51
+ chunkDZ7QRFHD_js.setCurrentScreen(route.name);
52
52
  emit({
53
53
  type: "navigation:change",
54
54
  timestamp: Date.now(),
@@ -36,6 +36,21 @@ var StreamAbortError = class extends Error {
36
36
  this.partialContent = partialContent;
37
37
  }
38
38
  };
39
+ var RateLimitedError = class extends Error {
40
+ retryAfterSeconds;
41
+ constructor(message, retryAfterSeconds) {
42
+ super(message);
43
+ this.name = "RateLimitedError";
44
+ this.retryAfterSeconds = retryAfterSeconds;
45
+ }
46
+ };
47
+ function parseRetryAfter(...candidates) {
48
+ for (const candidate of candidates) {
49
+ const seconds = Number(candidate);
50
+ if (Number.isFinite(seconds) && seconds > 0) return Math.ceil(seconds);
51
+ }
52
+ return 60;
53
+ }
39
54
  var CONTINUATION_TIMEOUT_MS = 15e4;
40
55
  var AppilotsClient = class {
41
56
  baseUrl;
@@ -100,6 +115,15 @@ var AppilotsClient = class {
100
115
  }
101
116
  if (!response.ok) {
102
117
  const errorMsg = json?.error?.message ?? json?.error ?? `HTTP ${response.status}`;
118
+ if (response.status === 429) {
119
+ throw new RateLimitedError(
120
+ errorMsg,
121
+ parseRetryAfter(
122
+ json?.error?.retryAfterSeconds,
123
+ response.headers?.get?.("retry-after")
124
+ )
125
+ );
126
+ }
103
127
  throw new Error(errorMsg);
104
128
  }
105
129
  return json.data ?? json;
@@ -344,11 +368,25 @@ var AppilotsClient = class {
344
368
  const contentType = String(xhr.getResponseHeader?.("content-type") ?? "");
345
369
  if (xhr.status !== 200 || !contentType.includes("text/event-stream")) {
346
370
  let message2 = `HTTP ${xhr.status || 0}`;
371
+ let retryAfterSeconds;
347
372
  try {
348
373
  const json = JSON.parse(xhr.responseText || "{}");
349
374
  message2 = json?.error?.message ?? json?.error ?? message2;
375
+ retryAfterSeconds = json?.error?.retryAfterSeconds;
350
376
  } catch {
351
377
  }
378
+ if (xhr.status === 429) {
379
+ fail(
380
+ new RateLimitedError(
381
+ message2,
382
+ parseRetryAfter(
383
+ retryAfterSeconds,
384
+ xhr.getResponseHeader?.("retry-after")
385
+ )
386
+ )
387
+ );
388
+ return;
389
+ }
352
390
  fail(
353
391
  sawAnyEvent ? new Error(message2) : new StreamTransportError(message2)
354
392
  );
@@ -936,25 +974,41 @@ function detectLocaleFromUserTexts(texts) {
936
974
  var copy = {
937
975
  pt: {
938
976
  rateLimit: "O provedor de IA atingiu o limite de uso durante a automa\xE7\xE3o. Aguarde um momento e pe\xE7a para continuar, ou aumente o limite de tokens por minuto.",
977
+ platformRateLimit: (wait) => `Recebi pedidos demais em pouco tempo e precisei pausar. Tente de novo em ${wait}.`,
939
978
  invalidInput: "N\xE3o consegui continuar a automa\xE7\xE3o por um problema interno de sincroniza\xE7\xE3o. Pode tentar de novo ou fazer essa parte manualmente?",
940
979
  generic: (detail) => `Perdi o fio da automa\xE7\xE3o (${detail}). Pode continuar manualmente ou me pedir de novo?`
941
980
  },
942
981
  es: {
943
982
  rateLimit: "El proveedor de IA alcanz\xF3 su l\xEDmite de uso durante la automatizaci\xF3n. Espera un momento y p\xEDdeme continuar, o aumenta el l\xEDmite de tokens por minuto.",
983
+ platformRateLimit: (wait) => `Recib\xED demasiadas solicitudes en poco tiempo y tuve que pausar. Int\xE9ntalo de nuevo en ${wait}.`,
944
984
  invalidInput: "No pude continuar la automatizaci\xF3n por un problema interno de sincronizaci\xF3n. \xBFPuedes intentarlo de nuevo o hacer esta parte manualmente?",
945
985
  generic: (detail) => `Perd\xED el hilo de la automatizaci\xF3n (${detail}). \xBFPuedes continuar manualmente o ped\xEDrmelo de nuevo?`
946
986
  },
947
987
  fr: {
948
988
  rateLimit: "Le fournisseur d'IA a atteint sa limite d'utilisation pendant l'automatisation. Attendez un instant et demandez-moi de continuer, ou augmentez la limite de tokens par minute.",
989
+ platformRateLimit: (wait) => `J'ai re\xE7u trop de demandes en peu de temps et j'ai d\xFB faire une pause. R\xE9essayez dans ${wait}.`,
949
990
  invalidInput: "Je n'ai pas pu poursuivre l'automatisation \xE0 cause d'un probl\xE8me interne de synchronisation. Pouvez-vous r\xE9essayer ou faire cette \xE9tape manuellement ?",
950
991
  generic: (detail) => `J'ai perdu le fil de l'automatisation (${detail}). Vous pouvez continuer manuellement ou me redemander ?`
951
992
  },
952
993
  en: {
953
994
  rateLimit: "Your AI provider hit its rate limit during automation. Wait a moment and ask me to continue, or raise your TPM limit.",
995
+ platformRateLimit: (wait) => `I got too many requests in a short time and had to pause. Try again in ${wait}.`,
954
996
  invalidInput: "I could not continue the automation because of an internal sync issue. You can try again or take over manually.",
955
997
  generic: (detail) => `I lost my footing during automation (${detail}). You can take over from here.`
956
998
  }
957
999
  };
1000
+ var waitPhrase = {
1001
+ pt: (s) => s < 90 ? `${Math.ceil(s)} segundos` : `cerca de ${Math.ceil(s / 60)} minutos`,
1002
+ es: (s) => s < 90 ? `${Math.ceil(s)} segundos` : `unos ${Math.ceil(s / 60)} minutos`,
1003
+ fr: (s) => s < 90 ? `${Math.ceil(s)} secondes` : `environ ${Math.ceil(s / 60)} minutes`,
1004
+ en: (s) => s < 90 ? `${Math.ceil(s)} seconds` : `about ${Math.ceil(s / 60)} minutes`
1005
+ };
1006
+ function buildRateLimitedMessage(retryAfterSeconds, recentUserTexts) {
1007
+ const locale = detectLocaleFromUserTexts(recentUserTexts);
1008
+ const strings = copy[locale] ?? copy.en;
1009
+ const seconds = Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0 ? retryAfterSeconds : 60;
1010
+ return strings.platformRateLimit(waitPhrase[locale](seconds));
1011
+ }
958
1012
  function buildContinuationFailureMessage(rawError, recentUserTexts) {
959
1013
  const locale = detectLocaleFromUserTexts(recentUserTexts);
960
1014
  const strings = copy[locale] ?? copy.en;
@@ -1558,7 +1612,7 @@ var ChatSessionMachine = class {
1558
1612
  const raw = err instanceof Error ? err.message : "Continuation failed";
1559
1613
  this.warn("ChatSessionMachine: continuation failed \u2014", raw);
1560
1614
  const recentUserTexts = this.state.messages.filter((m) => m.role === "user").slice(-4).map((m) => m.content);
1561
- const friendly = buildContinuationFailureMessage(raw, recentUserTexts);
1615
+ const friendly = err instanceof RateLimitedError ? buildRateLimitedMessage(err.retryAfterSeconds, recentUserTexts) : buildContinuationFailureMessage(raw, recentUserTexts);
1562
1616
  this.addAssistantMessage({
1563
1617
  id: `error_${++this.messageIdCounter}`,
1564
1618
  role: "assistant",
@@ -1720,6 +1774,17 @@ var ChatSessionMachine = class {
1720
1774
  removeStreamingPlaceholder();
1721
1775
  const errorMessage = err instanceof Error ? err.message : "Failed to send message";
1722
1776
  this.setState({ error: errorMessage });
1777
+ if (err instanceof RateLimitedError) {
1778
+ const recentUserTexts = this.state.messages.filter((m) => m.role === "user").slice(-4).map((m) => m.content);
1779
+ this.addAssistantMessage({
1780
+ id: `error_${++this.messageIdCounter}`,
1781
+ role: "assistant",
1782
+ content: buildRateLimitedMessage(err.retryAfterSeconds, recentUserTexts),
1783
+ timestamp: Date.now()
1784
+ });
1785
+ this.setState({ isLoading: false, loadingStatusKey: "thinking" });
1786
+ return;
1787
+ }
1723
1788
  this.addAssistantMessage({
1724
1789
  id: `error_${++this.messageIdCounter}`,
1725
1790
  role: "assistant",
@@ -4321,4 +4386,4 @@ function clearScreenRegistry() {
4321
4386
  screenRegistry.clear();
4322
4387
  }
4323
4388
 
4324
- export { ActionQueueMachine, AppilotsClient, AppilotsProvider, AppilotsRegistryProvider, ChatSessionMachine, OPTIONAL_STEP_AUTOMATION_HINT, SDK_VERSION, _patchJsxRuntimes, actionPressTargetId, appilotsDebugLog, appilotsDebugWarn, attachElementIdsToChoiceGroups, clearAppilotsDebugTraces, clearScreenRegistry, componentRegistry, createComponentRegistry, createElementRegistry, createListRegistry, defaultDarkTheme, defaultLightTheme, deriveInteractionElements, describeAction, elementRegistry, enableAppilotsAutoTracking, getActiveRouteNames, getAllScreens, getAppilotsDebugTraces, getCurrentScreen, getCurrentScreenSignature, getDefaultRegistry, getFiberRoot, getGlobalConfig, getIntrospectionDiagnostics, getNavigationRef, getNavigationStateSnapshot, getScreenMetadata, humanizeError, idLooselyMatches, initAppilots, isAutoTrackingEnabled, isGenericSelectValue, isListItemPressTarget, isOptionalStepAutomationFailure, listRegistry, looksDestructiveActionLabel, matchScore, mergeThemeTokens, normalize3, parseStableElementId, probeLoadingState, recordAppilotsDebugTrace, recordIntrospectionFailure, registerScreen, resolveBaseTheme, routesBelongToSameFeature, screenDepartedBaseline, setCurrentScreen, setNavigationRef, snapshotShowsOpenCreateForm, subscribeAppilotsDebugTraces, useAppilotsContext, useResolvedRegistry, waitForLoadingSettle, waitForScreenSettle };
4389
+ export { ActionQueueMachine, AppilotsClient, AppilotsProvider, AppilotsRegistryProvider, ChatSessionMachine, OPTIONAL_STEP_AUTOMATION_HINT, RateLimitedError, SDK_VERSION, _patchJsxRuntimes, actionPressTargetId, appilotsDebugLog, appilotsDebugWarn, attachElementIdsToChoiceGroups, clearAppilotsDebugTraces, clearScreenRegistry, componentRegistry, createComponentRegistry, createElementRegistry, createListRegistry, defaultDarkTheme, defaultLightTheme, deriveInteractionElements, describeAction, elementRegistry, enableAppilotsAutoTracking, getActiveRouteNames, getAllScreens, getAppilotsDebugTraces, getCurrentScreen, getCurrentScreenSignature, getDefaultRegistry, getFiberRoot, getGlobalConfig, getIntrospectionDiagnostics, getNavigationRef, getNavigationStateSnapshot, getScreenMetadata, humanizeError, idLooselyMatches, initAppilots, isAutoTrackingEnabled, isGenericSelectValue, isListItemPressTarget, isOptionalStepAutomationFailure, listRegistry, looksDestructiveActionLabel, matchScore, mergeThemeTokens, normalize3, parseStableElementId, probeLoadingState, recordAppilotsDebugTrace, recordIntrospectionFailure, registerScreen, resolveBaseTheme, routesBelongToSameFeature, screenDepartedBaseline, setCurrentScreen, setNavigationRef, snapshotShowsOpenCreateForm, subscribeAppilotsDebugTraces, useAppilotsContext, useResolvedRegistry, waitForLoadingSettle, waitForScreenSettle };
@@ -1,2 +1,2 @@
1
- export { H as SuggestedPrompt, O as UseAppilotsFieldOptions, Q as UseAppilotsSliderOptions, V as UseAppilotsTargetOptions, W as UseAppilotsToggleOptions, X as UseSuggestedPromptsOptions, Y as UseSuggestedPromptsReturn, a8 as useAppilots, a9 as useAppilotsActions, aa as useAppilotsChat, ac as useAppilotsField, ad as useAppilotsNavigation, ae as useAppilotsSlider, af as useAppilotsTarget, ag as useAppilotsToggle, ah as useSuggestedPrompts } from '../index-GvF_FlwO.mjs';
1
+ export { J as SuggestedPrompt, Q as UseAppilotsFieldOptions, V as UseAppilotsSliderOptions, W as UseAppilotsTargetOptions, X as UseAppilotsToggleOptions, Y as UseSuggestedPromptsOptions, Z as UseSuggestedPromptsReturn, a9 as useAppilots, aa as useAppilotsActions, ab as useAppilotsChat, ad as useAppilotsField, ae as useAppilotsNavigation, af as useAppilotsSlider, ag as useAppilotsTarget, ah as useAppilotsToggle, ai as useSuggestedPrompts } from '../index-nI-s3Exg.mjs';
2
2
  import 'react';
@@ -1,2 +1,2 @@
1
- export { H as SuggestedPrompt, O as UseAppilotsFieldOptions, Q as UseAppilotsSliderOptions, V as UseAppilotsTargetOptions, W as UseAppilotsToggleOptions, X as UseSuggestedPromptsOptions, Y as UseSuggestedPromptsReturn, a8 as useAppilots, a9 as useAppilotsActions, aa as useAppilotsChat, ac as useAppilotsField, ad as useAppilotsNavigation, ae as useAppilotsSlider, af as useAppilotsTarget, ag as useAppilotsToggle, ah as useSuggestedPrompts } from '../index-GvF_FlwO.js';
1
+ export { J as SuggestedPrompt, Q as UseAppilotsFieldOptions, V as UseAppilotsSliderOptions, W as UseAppilotsTargetOptions, X as UseAppilotsToggleOptions, Y as UseSuggestedPromptsOptions, Z as UseSuggestedPromptsReturn, a9 as useAppilots, aa as useAppilotsActions, ab as useAppilotsChat, ad as useAppilotsField, ae as useAppilotsNavigation, af as useAppilotsSlider, ag as useAppilotsTarget, ah as useAppilotsToggle, ai as useSuggestedPrompts } from '../index-nI-s3Exg.js';
2
2
  import 'react';
@@ -1,43 +1,43 @@
1
1
  'use strict';
2
2
 
3
- var chunkZWQUIDBZ_js = require('../chunk-ZWQUIDBZ.js');
4
- require('../chunk-PQHZTAFG.js');
3
+ var chunkHFRIB4YN_js = require('../chunk-HFRIB4YN.js');
4
+ require('../chunk-DZ7QRFHD.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "useAppilots", {
9
9
  enumerable: true,
10
- get: function () { return chunkZWQUIDBZ_js.useAppilots; }
10
+ get: function () { return chunkHFRIB4YN_js.useAppilots; }
11
11
  });
12
12
  Object.defineProperty(exports, "useAppilotsActions", {
13
13
  enumerable: true,
14
- get: function () { return chunkZWQUIDBZ_js.useAppilotsActions; }
14
+ get: function () { return chunkHFRIB4YN_js.useAppilotsActions; }
15
15
  });
16
16
  Object.defineProperty(exports, "useAppilotsChat", {
17
17
  enumerable: true,
18
- get: function () { return chunkZWQUIDBZ_js.useAppilotsChat; }
18
+ get: function () { return chunkHFRIB4YN_js.useAppilotsChat; }
19
19
  });
20
20
  Object.defineProperty(exports, "useAppilotsField", {
21
21
  enumerable: true,
22
- get: function () { return chunkZWQUIDBZ_js.useAppilotsField; }
22
+ get: function () { return chunkHFRIB4YN_js.useAppilotsField; }
23
23
  });
24
24
  Object.defineProperty(exports, "useAppilotsNavigation", {
25
25
  enumerable: true,
26
- get: function () { return chunkZWQUIDBZ_js.useAppilotsNavigation; }
26
+ get: function () { return chunkHFRIB4YN_js.useAppilotsNavigation; }
27
27
  });
28
28
  Object.defineProperty(exports, "useAppilotsSlider", {
29
29
  enumerable: true,
30
- get: function () { return chunkZWQUIDBZ_js.useAppilotsSlider; }
30
+ get: function () { return chunkHFRIB4YN_js.useAppilotsSlider; }
31
31
  });
32
32
  Object.defineProperty(exports, "useAppilotsTarget", {
33
33
  enumerable: true,
34
- get: function () { return chunkZWQUIDBZ_js.useAppilotsTarget; }
34
+ get: function () { return chunkHFRIB4YN_js.useAppilotsTarget; }
35
35
  });
36
36
  Object.defineProperty(exports, "useAppilotsToggle", {
37
37
  enumerable: true,
38
- get: function () { return chunkZWQUIDBZ_js.useAppilotsToggle; }
38
+ get: function () { return chunkHFRIB4YN_js.useAppilotsToggle; }
39
39
  });
40
40
  Object.defineProperty(exports, "useSuggestedPrompts", {
41
41
  enumerable: true,
42
- get: function () { return chunkZWQUIDBZ_js.useSuggestedPrompts; }
42
+ get: function () { return chunkHFRIB4YN_js.useSuggestedPrompts; }
43
43
  });
@@ -1,2 +1,2 @@
1
- export { useAppilots, useAppilotsActions, useAppilotsChat, useAppilotsField, useAppilotsNavigation, useAppilotsSlider, useAppilotsTarget, useAppilotsToggle, useSuggestedPrompts } from '../chunk-3D7PHOV7.mjs';
2
- import '../chunk-BIEF6MNR.mjs';
1
+ export { useAppilots, useAppilotsActions, useAppilotsChat, useAppilotsField, useAppilotsNavigation, useAppilotsSlider, useAppilotsTarget, useAppilotsToggle, useSuggestedPrompts } from '../chunk-KUFWRJC4.mjs';
2
+ import '../chunk-R4D34FEW.mjs';
@@ -386,6 +386,30 @@ interface SendMessageStreamOptions {
386
386
  /** Abort mid-generation (stop button). Rejects with name='AbortError'. */
387
387
  signal?: AbortSignal;
388
388
  }
389
+ /**
390
+ * The server refused the request because this workspace (or this end
391
+ * user) is going too fast — HTTP 429, `error.code = 'RATE_LIMITED'`.
392
+ * See `apps/api/src/common/services/relay-rate-limit.ts`.
393
+ *
394
+ * A distinct type for two reasons, both of which the plain `Error` the
395
+ * transport used to throw could not express:
396
+ *
397
+ * - It is a POLICY rejection, not a transport failure. On the streaming
398
+ * path that distinction decides whether the caller retries: a stream
399
+ * that dies before its first event is safely retried against the
400
+ * non-streaming endpoint, but retrying a 429 immediately is exactly
401
+ * the behaviour the limit exists to stop, and it earns a second 429.
402
+ * - It carries `retryAfterSeconds`, so a caller can say WHEN instead of
403
+ * "try again later", and can back off instead of spinning.
404
+ *
405
+ * `retryAfterSeconds` is read from the response envelope, falling back
406
+ * to the `Retry-After` header and then to 60 — a client that waits a
407
+ * minute is never wrong by much, and never zero.
408
+ */
409
+ declare class RateLimitedError extends Error {
410
+ readonly retryAfterSeconds: number;
411
+ constructor(message: string, retryAfterSeconds: number);
412
+ }
389
413
  /** Runtime context sent with every user message. */
390
414
  interface SendMessageContext {
391
415
  /**
@@ -1570,4 +1594,4 @@ interface UseSuggestedPromptsReturn {
1570
1594
  */
1571
1595
  declare function useSuggestedPrompts(options: UseSuggestedPromptsOptions): UseSuggestedPromptsReturn;
1572
1596
 
1573
- export { createComponentRegistry as $, type AppilotsThemeTokens as A, type BreadcrumbItem as B, type ComponentRegistry as C, SDK_VERSION as D, type EscalationState as E, type FieldEntry as F, type SliderEntry as G, type SuggestedPrompt as H, type InteractionElementSnapshot as I, type ToggleEntry as J, type ToggleSnapshot as K, type ListItemSnapshot as L, type MessageRole as M, type NavigationPayload as N, type UseAppilotsFieldOptions as O, type PartialThemeTokens as P, type UseAppilotsSliderOptions as Q, type RemotePersonalization as R, type ScreenSnapshot as S, type TargetEntry as T, type UIInteractionPayload as U, type UseAppilotsTargetOptions as V, type UseAppilotsToggleOptions as W, type UseSuggestedPromptsOptions as X, type UseSuggestedPromptsReturn as Y, clearAppilotsDebugTraces as Z, componentRegistry as _, type AppilotsLocale as a, defaultDarkTheme as a0, defaultLightTheme as a1, describeAction as a2, getAppilotsDebugTraces as a3, humanizeError as a4, mergeThemeTokens as a5, recordAppilotsDebugTrace as a6, subscribeAppilotsDebugTraces as a7, useAppilots as a8, useAppilotsActions as a9, useAppilotsChat as aa, useAppilotsContext as ab, useAppilotsField as ac, useAppilotsNavigation as ad, useAppilotsSlider as ae, useAppilotsTarget as af, useAppilotsToggle as ag, useSuggestedPrompts as ah, type AgentAction as b, type AgentPermissions as c, type AppilotsEvent as d, type AgentActionType as e, type AgentMessage as f, AppilotsClient as g, type AppilotsClientOptions as h, type AppilotsConfig as i, type AppilotsEventHandler as j, type AppilotsEventType as k, AppilotsProvider as l, type AppilotsProviderProps as m, type AppilotsTraceEntry as n, type AppilotsUser as o, type BreadcrumbState as p, type ButtonSnapshot as q, type ChatMessage as r, type ChoiceGroupSnapshot as s, type ChoiceOptionSnapshot as t, type ComponentEntry as u, type ComponentKind as v, type FormFillPayload as w, type InputSnapshot as x, type InteractionElementListContext as y, type ListSnapshot as z };
1597
+ export { componentRegistry as $, type AppilotsThemeTokens as A, type BreadcrumbItem as B, type ComponentRegistry as C, type RemotePersonalization as D, type EscalationState as E, type FieldEntry as F, SDK_VERSION as G, type SliderEntry as H, type InteractionElementSnapshot as I, type SuggestedPrompt as J, type ToggleEntry as K, type ListItemSnapshot as L, type MessageRole as M, type NavigationPayload as N, type ToggleSnapshot as O, type PartialThemeTokens as P, type UseAppilotsFieldOptions as Q, RateLimitedError as R, type ScreenSnapshot as S, type TargetEntry as T, type UIInteractionPayload as U, type UseAppilotsSliderOptions as V, type UseAppilotsTargetOptions as W, type UseAppilotsToggleOptions as X, type UseSuggestedPromptsOptions as Y, type UseSuggestedPromptsReturn as Z, clearAppilotsDebugTraces as _, type AppilotsLocale as a, createComponentRegistry as a0, defaultDarkTheme as a1, defaultLightTheme as a2, describeAction as a3, getAppilotsDebugTraces as a4, humanizeError as a5, mergeThemeTokens as a6, recordAppilotsDebugTrace as a7, subscribeAppilotsDebugTraces as a8, useAppilots as a9, useAppilotsActions as aa, useAppilotsChat as ab, useAppilotsContext as ac, useAppilotsField as ad, useAppilotsNavigation as ae, useAppilotsSlider as af, useAppilotsTarget as ag, useAppilotsToggle as ah, useSuggestedPrompts as ai, type AgentAction as b, type AgentPermissions as c, type AppilotsEvent as d, type AgentActionType as e, type AgentMessage as f, AppilotsClient as g, type AppilotsClientOptions as h, type AppilotsConfig as i, type AppilotsEventHandler as j, type AppilotsEventType as k, AppilotsProvider as l, type AppilotsProviderProps as m, type AppilotsTraceEntry as n, type AppilotsUser as o, type BreadcrumbState as p, type ButtonSnapshot as q, type ChatMessage as r, type ChoiceGroupSnapshot as s, type ChoiceOptionSnapshot as t, type ComponentEntry as u, type ComponentKind as v, type FormFillPayload as w, type InputSnapshot as x, type InteractionElementListContext as y, type ListSnapshot as z };
@@ -386,6 +386,30 @@ interface SendMessageStreamOptions {
386
386
  /** Abort mid-generation (stop button). Rejects with name='AbortError'. */
387
387
  signal?: AbortSignal;
388
388
  }
389
+ /**
390
+ * The server refused the request because this workspace (or this end
391
+ * user) is going too fast — HTTP 429, `error.code = 'RATE_LIMITED'`.
392
+ * See `apps/api/src/common/services/relay-rate-limit.ts`.
393
+ *
394
+ * A distinct type for two reasons, both of which the plain `Error` the
395
+ * transport used to throw could not express:
396
+ *
397
+ * - It is a POLICY rejection, not a transport failure. On the streaming
398
+ * path that distinction decides whether the caller retries: a stream
399
+ * that dies before its first event is safely retried against the
400
+ * non-streaming endpoint, but retrying a 429 immediately is exactly
401
+ * the behaviour the limit exists to stop, and it earns a second 429.
402
+ * - It carries `retryAfterSeconds`, so a caller can say WHEN instead of
403
+ * "try again later", and can back off instead of spinning.
404
+ *
405
+ * `retryAfterSeconds` is read from the response envelope, falling back
406
+ * to the `Retry-After` header and then to 60 — a client that waits a
407
+ * minute is never wrong by much, and never zero.
408
+ */
409
+ declare class RateLimitedError extends Error {
410
+ readonly retryAfterSeconds: number;
411
+ constructor(message: string, retryAfterSeconds: number);
412
+ }
389
413
  /** Runtime context sent with every user message. */
390
414
  interface SendMessageContext {
391
415
  /**
@@ -1570,4 +1594,4 @@ interface UseSuggestedPromptsReturn {
1570
1594
  */
1571
1595
  declare function useSuggestedPrompts(options: UseSuggestedPromptsOptions): UseSuggestedPromptsReturn;
1572
1596
 
1573
- export { createComponentRegistry as $, type AppilotsThemeTokens as A, type BreadcrumbItem as B, type ComponentRegistry as C, SDK_VERSION as D, type EscalationState as E, type FieldEntry as F, type SliderEntry as G, type SuggestedPrompt as H, type InteractionElementSnapshot as I, type ToggleEntry as J, type ToggleSnapshot as K, type ListItemSnapshot as L, type MessageRole as M, type NavigationPayload as N, type UseAppilotsFieldOptions as O, type PartialThemeTokens as P, type UseAppilotsSliderOptions as Q, type RemotePersonalization as R, type ScreenSnapshot as S, type TargetEntry as T, type UIInteractionPayload as U, type UseAppilotsTargetOptions as V, type UseAppilotsToggleOptions as W, type UseSuggestedPromptsOptions as X, type UseSuggestedPromptsReturn as Y, clearAppilotsDebugTraces as Z, componentRegistry as _, type AppilotsLocale as a, defaultDarkTheme as a0, defaultLightTheme as a1, describeAction as a2, getAppilotsDebugTraces as a3, humanizeError as a4, mergeThemeTokens as a5, recordAppilotsDebugTrace as a6, subscribeAppilotsDebugTraces as a7, useAppilots as a8, useAppilotsActions as a9, useAppilotsChat as aa, useAppilotsContext as ab, useAppilotsField as ac, useAppilotsNavigation as ad, useAppilotsSlider as ae, useAppilotsTarget as af, useAppilotsToggle as ag, useSuggestedPrompts as ah, type AgentAction as b, type AgentPermissions as c, type AppilotsEvent as d, type AgentActionType as e, type AgentMessage as f, AppilotsClient as g, type AppilotsClientOptions as h, type AppilotsConfig as i, type AppilotsEventHandler as j, type AppilotsEventType as k, AppilotsProvider as l, type AppilotsProviderProps as m, type AppilotsTraceEntry as n, type AppilotsUser as o, type BreadcrumbState as p, type ButtonSnapshot as q, type ChatMessage as r, type ChoiceGroupSnapshot as s, type ChoiceOptionSnapshot as t, type ComponentEntry as u, type ComponentKind as v, type FormFillPayload as w, type InputSnapshot as x, type InteractionElementListContext as y, type ListSnapshot as z };
1597
+ export { componentRegistry as $, type AppilotsThemeTokens as A, type BreadcrumbItem as B, type ComponentRegistry as C, type RemotePersonalization as D, type EscalationState as E, type FieldEntry as F, SDK_VERSION as G, type SliderEntry as H, type InteractionElementSnapshot as I, type SuggestedPrompt as J, type ToggleEntry as K, type ListItemSnapshot as L, type MessageRole as M, type NavigationPayload as N, type ToggleSnapshot as O, type PartialThemeTokens as P, type UseAppilotsFieldOptions as Q, RateLimitedError as R, type ScreenSnapshot as S, type TargetEntry as T, type UIInteractionPayload as U, type UseAppilotsSliderOptions as V, type UseAppilotsTargetOptions as W, type UseAppilotsToggleOptions as X, type UseSuggestedPromptsOptions as Y, type UseSuggestedPromptsReturn as Z, clearAppilotsDebugTraces as _, type AppilotsLocale as a, createComponentRegistry as a0, defaultDarkTheme as a1, defaultLightTheme as a2, describeAction as a3, getAppilotsDebugTraces as a4, humanizeError as a5, mergeThemeTokens as a6, recordAppilotsDebugTrace as a7, subscribeAppilotsDebugTraces as a8, useAppilots as a9, useAppilotsActions as aa, useAppilotsChat as ab, useAppilotsContext as ac, useAppilotsField as ad, useAppilotsNavigation as ae, useAppilotsSlider as af, useAppilotsTarget as ag, useAppilotsToggle as ah, useSuggestedPrompts as ai, type AgentAction as b, type AgentPermissions as c, type AppilotsEvent as d, type AgentActionType as e, type AgentMessage as f, AppilotsClient as g, type AppilotsClientOptions as h, type AppilotsConfig as i, type AppilotsEventHandler as j, type AppilotsEventType as k, AppilotsProvider as l, type AppilotsProviderProps as m, type AppilotsTraceEntry as n, type AppilotsUser as o, type BreadcrumbState as p, type ButtonSnapshot as q, type ChatMessage as r, type ChoiceGroupSnapshot as s, type ChoiceOptionSnapshot as t, type ComponentEntry as u, type ComponentKind as v, type FormFillPayload as w, type InputSnapshot as x, type InteractionElementListContext as y, type ListSnapshot as z };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PartialThemeTokens, A as AppilotsThemeTokens, a as AppilotsLocale, b as AgentAction, I as InteractionElementSnapshot, C as ComponentRegistry, c as AgentPermissions, S as ScreenSnapshot, F as FieldEntry, d as AppilotsEvent } from './index-GvF_FlwO.mjs';
2
- export { e as AgentActionType, f as AgentMessage, g as AppilotsClient, h as AppilotsClientOptions, i as AppilotsConfig, j as AppilotsEventHandler, k as AppilotsEventType, l as AppilotsProvider, m as AppilotsProviderProps, n as AppilotsTraceEntry, o as AppilotsUser, B as BreadcrumbItem, p as BreadcrumbState, q as ButtonSnapshot, r as ChatMessage, s as ChoiceGroupSnapshot, t as ChoiceOptionSnapshot, u as ComponentEntry, v as ComponentKind, E as EscalationState, w as FormFillPayload, x as InputSnapshot, y as InteractionElementListContext, L as ListItemSnapshot, z as ListSnapshot, M as MessageRole, N as NavigationPayload, R as RemotePersonalization, D as SDK_VERSION, G as SliderEntry, H as SuggestedPrompt, T as TargetEntry, J as ToggleEntry, K as ToggleSnapshot, U as UIInteractionPayload, O as UseAppilotsFieldOptions, Q as UseAppilotsSliderOptions, V as UseAppilotsTargetOptions, W as UseAppilotsToggleOptions, X as UseSuggestedPromptsOptions, Y as UseSuggestedPromptsReturn, Z as clearAppilotsDebugTraces, _ as componentRegistry, $ as createComponentRegistry, a0 as defaultDarkTheme, a1 as defaultLightTheme, a2 as describeAction, a3 as getAppilotsDebugTraces, a4 as humanizeError, a5 as mergeThemeTokens, a6 as recordAppilotsDebugTrace, a7 as subscribeAppilotsDebugTraces, a8 as useAppilots, a9 as useAppilotsActions, aa as useAppilotsChat, ab as useAppilotsContext, ac as useAppilotsField, ad as useAppilotsNavigation, ae as useAppilotsSlider, af as useAppilotsTarget, ag as useAppilotsToggle, ah as useSuggestedPrompts } from './index-GvF_FlwO.mjs';
1
+ import { P as PartialThemeTokens, A as AppilotsThemeTokens, a as AppilotsLocale, b as AgentAction, I as InteractionElementSnapshot, C as ComponentRegistry, c as AgentPermissions, S as ScreenSnapshot, F as FieldEntry, d as AppilotsEvent } from './index-nI-s3Exg.mjs';
2
+ export { e as AgentActionType, f as AgentMessage, g as AppilotsClient, h as AppilotsClientOptions, i as AppilotsConfig, j as AppilotsEventHandler, k as AppilotsEventType, l as AppilotsProvider, m as AppilotsProviderProps, n as AppilotsTraceEntry, o as AppilotsUser, B as BreadcrumbItem, p as BreadcrumbState, q as ButtonSnapshot, r as ChatMessage, s as ChoiceGroupSnapshot, t as ChoiceOptionSnapshot, u as ComponentEntry, v as ComponentKind, E as EscalationState, w as FormFillPayload, x as InputSnapshot, y as InteractionElementListContext, L as ListItemSnapshot, z as ListSnapshot, M as MessageRole, N as NavigationPayload, R as RateLimitedError, D as RemotePersonalization, G as SDK_VERSION, H as SliderEntry, J as SuggestedPrompt, T as TargetEntry, K as ToggleEntry, O as ToggleSnapshot, U as UIInteractionPayload, Q as UseAppilotsFieldOptions, V as UseAppilotsSliderOptions, W as UseAppilotsTargetOptions, X as UseAppilotsToggleOptions, Y as UseSuggestedPromptsOptions, Z as UseSuggestedPromptsReturn, _ as clearAppilotsDebugTraces, $ as componentRegistry, a0 as createComponentRegistry, a1 as defaultDarkTheme, a2 as defaultLightTheme, a3 as describeAction, a4 as getAppilotsDebugTraces, a5 as humanizeError, a6 as mergeThemeTokens, a7 as recordAppilotsDebugTrace, a8 as subscribeAppilotsDebugTraces, a9 as useAppilots, aa as useAppilotsActions, ab as useAppilotsChat, ac as useAppilotsContext, ad as useAppilotsField, ae as useAppilotsNavigation, af as useAppilotsSlider, ag as useAppilotsTarget, ah as useAppilotsToggle, ai as useSuggestedPrompts } from './index-nI-s3Exg.mjs';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  export { A as AppilotsNavigationContainer, N as NavigationConfig, b as ScreenMetadata, r as registerScreen } from './registerScreen-D1oGm28T.mjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PartialThemeTokens, A as AppilotsThemeTokens, a as AppilotsLocale, b as AgentAction, I as InteractionElementSnapshot, C as ComponentRegistry, c as AgentPermissions, S as ScreenSnapshot, F as FieldEntry, d as AppilotsEvent } from './index-GvF_FlwO.js';
2
- export { e as AgentActionType, f as AgentMessage, g as AppilotsClient, h as AppilotsClientOptions, i as AppilotsConfig, j as AppilotsEventHandler, k as AppilotsEventType, l as AppilotsProvider, m as AppilotsProviderProps, n as AppilotsTraceEntry, o as AppilotsUser, B as BreadcrumbItem, p as BreadcrumbState, q as ButtonSnapshot, r as ChatMessage, s as ChoiceGroupSnapshot, t as ChoiceOptionSnapshot, u as ComponentEntry, v as ComponentKind, E as EscalationState, w as FormFillPayload, x as InputSnapshot, y as InteractionElementListContext, L as ListItemSnapshot, z as ListSnapshot, M as MessageRole, N as NavigationPayload, R as RemotePersonalization, D as SDK_VERSION, G as SliderEntry, H as SuggestedPrompt, T as TargetEntry, J as ToggleEntry, K as ToggleSnapshot, U as UIInteractionPayload, O as UseAppilotsFieldOptions, Q as UseAppilotsSliderOptions, V as UseAppilotsTargetOptions, W as UseAppilotsToggleOptions, X as UseSuggestedPromptsOptions, Y as UseSuggestedPromptsReturn, Z as clearAppilotsDebugTraces, _ as componentRegistry, $ as createComponentRegistry, a0 as defaultDarkTheme, a1 as defaultLightTheme, a2 as describeAction, a3 as getAppilotsDebugTraces, a4 as humanizeError, a5 as mergeThemeTokens, a6 as recordAppilotsDebugTrace, a7 as subscribeAppilotsDebugTraces, a8 as useAppilots, a9 as useAppilotsActions, aa as useAppilotsChat, ab as useAppilotsContext, ac as useAppilotsField, ad as useAppilotsNavigation, ae as useAppilotsSlider, af as useAppilotsTarget, ag as useAppilotsToggle, ah as useSuggestedPrompts } from './index-GvF_FlwO.js';
1
+ import { P as PartialThemeTokens, A as AppilotsThemeTokens, a as AppilotsLocale, b as AgentAction, I as InteractionElementSnapshot, C as ComponentRegistry, c as AgentPermissions, S as ScreenSnapshot, F as FieldEntry, d as AppilotsEvent } from './index-nI-s3Exg.js';
2
+ export { e as AgentActionType, f as AgentMessage, g as AppilotsClient, h as AppilotsClientOptions, i as AppilotsConfig, j as AppilotsEventHandler, k as AppilotsEventType, l as AppilotsProvider, m as AppilotsProviderProps, n as AppilotsTraceEntry, o as AppilotsUser, B as BreadcrumbItem, p as BreadcrumbState, q as ButtonSnapshot, r as ChatMessage, s as ChoiceGroupSnapshot, t as ChoiceOptionSnapshot, u as ComponentEntry, v as ComponentKind, E as EscalationState, w as FormFillPayload, x as InputSnapshot, y as InteractionElementListContext, L as ListItemSnapshot, z as ListSnapshot, M as MessageRole, N as NavigationPayload, R as RateLimitedError, D as RemotePersonalization, G as SDK_VERSION, H as SliderEntry, J as SuggestedPrompt, T as TargetEntry, K as ToggleEntry, O as ToggleSnapshot, U as UIInteractionPayload, Q as UseAppilotsFieldOptions, V as UseAppilotsSliderOptions, W as UseAppilotsTargetOptions, X as UseAppilotsToggleOptions, Y as UseSuggestedPromptsOptions, Z as UseSuggestedPromptsReturn, _ as clearAppilotsDebugTraces, $ as componentRegistry, a0 as createComponentRegistry, a1 as defaultDarkTheme, a2 as defaultLightTheme, a3 as describeAction, a4 as getAppilotsDebugTraces, a5 as humanizeError, a6 as mergeThemeTokens, a7 as recordAppilotsDebugTrace, a8 as subscribeAppilotsDebugTraces, a9 as useAppilots, aa as useAppilotsActions, ab as useAppilotsChat, ac as useAppilotsContext, ad as useAppilotsField, ae as useAppilotsNavigation, af as useAppilotsSlider, ag as useAppilotsTarget, ah as useAppilotsToggle, ai as useSuggestedPrompts } from './index-nI-s3Exg.js';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  export { A as AppilotsNavigationContainer, N as NavigationConfig, b as ScreenMetadata, r as registerScreen } from './registerScreen-D1oGm28T.js';