@appilots/sdk 0.4.1 → 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.
- package/dist/{chunk-P2BR4DFF.mjs → chunk-DR75QTYK.mjs} +1 -1
- package/dist/{chunk-J75B2HWG.js → chunk-DZ7QRFHD.js} +130 -10
- package/dist/{chunk-YSLDAQV7.js → chunk-HFRIB4YN.js} +160 -159
- package/dist/{chunk-L2A4EZ6V.mjs → chunk-KUFWRJC4.mjs} +2 -1
- package/dist/{chunk-ZWPABTLA.js → chunk-KYFAXT6V.js} +5 -5
- package/dist/{chunk-4GUPZDWT.mjs → chunk-R4D34FEW.mjs} +128 -11
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +11 -11
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-Cb0D6uKH.d.mts → index-nI-s3Exg.d.mts} +56 -2
- package/dist/{index-Cb0D6uKH.d.ts → index-nI-s3Exg.d.ts} +56 -2
- package/dist/index.d.mts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +73 -65
- package/dist/index.mjs +5 -5
- package/dist/navigation/index.js +13 -13
- package/dist/navigation/index.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFiberRoot, 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-
|
|
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
|
|
|
@@ -748,6 +748,7 @@ function captureSnapshot() {
|
|
|
748
748
|
console.warn(
|
|
749
749
|
"[Appilots] captureSnapshot: fiber root not captured yet. Ensure <AppilotsProvider> has rendered before calling this."
|
|
750
750
|
);
|
|
751
|
+
recordIntrospectionFailure("never-mounted", null);
|
|
751
752
|
return {
|
|
752
753
|
route: getCurrentScreen(),
|
|
753
754
|
texts: [],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
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 } =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -44,6 +59,7 @@ var AppilotsClient = class {
|
|
|
44
59
|
timeout;
|
|
45
60
|
debug;
|
|
46
61
|
mcpVersion;
|
|
62
|
+
introspectionReporter;
|
|
47
63
|
user;
|
|
48
64
|
sessionId = null;
|
|
49
65
|
/** Guard so identify fires at most once per client instance. */
|
|
@@ -54,6 +70,7 @@ var AppilotsClient = class {
|
|
|
54
70
|
this.timeout = options.timeout ?? 6e4;
|
|
55
71
|
this.debug = options.debug ?? false;
|
|
56
72
|
this.mcpVersion = options.mcpVersion;
|
|
73
|
+
this.introspectionReporter = options.introspectionReporter;
|
|
57
74
|
this.user = options.user;
|
|
58
75
|
this.headers = {
|
|
59
76
|
"Content-Type": "application/json",
|
|
@@ -98,6 +115,15 @@ var AppilotsClient = class {
|
|
|
98
115
|
}
|
|
99
116
|
if (!response.ok) {
|
|
100
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
|
+
}
|
|
101
127
|
throw new Error(errorMsg);
|
|
102
128
|
}
|
|
103
129
|
return json.data ?? json;
|
|
@@ -156,6 +182,21 @@ var AppilotsClient = class {
|
|
|
156
182
|
getSessionId() {
|
|
157
183
|
return this.sessionId;
|
|
158
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Wire fragment for introspection health. Empty on the happy path —
|
|
187
|
+
* a working client sends nothing, so the field costs a byte only
|
|
188
|
+
* when something is actually wrong. Never throws: a broken reporter
|
|
189
|
+
* must not take the message down with it.
|
|
190
|
+
*/
|
|
191
|
+
introspectionFragment() {
|
|
192
|
+
try {
|
|
193
|
+
const report = this.introspectionReporter?.();
|
|
194
|
+
if (!report || report.captured !== false) return {};
|
|
195
|
+
return { introspection: report };
|
|
196
|
+
} catch {
|
|
197
|
+
return {};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
159
200
|
// ── Messages ──────────────────────────────────────────────────
|
|
160
201
|
async sendMessage(content, context) {
|
|
161
202
|
if (!this.sessionId) {
|
|
@@ -169,7 +210,8 @@ var AppilotsClient = class {
|
|
|
169
210
|
context,
|
|
170
211
|
// Optional MCP version bundled with this app build. Server
|
|
171
212
|
// compares vs the active MCP doc to detect stale uploads.
|
|
172
|
-
...this.mcpVersion ? { mcpVersion: this.mcpVersion } : {}
|
|
213
|
+
...this.mcpVersion ? { mcpVersion: this.mcpVersion } : {},
|
|
214
|
+
...this.introspectionFragment()
|
|
173
215
|
})
|
|
174
216
|
});
|
|
175
217
|
if (data.sessionId) {
|
|
@@ -326,11 +368,25 @@ var AppilotsClient = class {
|
|
|
326
368
|
const contentType = String(xhr.getResponseHeader?.("content-type") ?? "");
|
|
327
369
|
if (xhr.status !== 200 || !contentType.includes("text/event-stream")) {
|
|
328
370
|
let message2 = `HTTP ${xhr.status || 0}`;
|
|
371
|
+
let retryAfterSeconds;
|
|
329
372
|
try {
|
|
330
373
|
const json = JSON.parse(xhr.responseText || "{}");
|
|
331
374
|
message2 = json?.error?.message ?? json?.error ?? message2;
|
|
375
|
+
retryAfterSeconds = json?.error?.retryAfterSeconds;
|
|
332
376
|
} catch {
|
|
333
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
|
+
}
|
|
334
390
|
fail(
|
|
335
391
|
sawAnyEvent ? new Error(message2) : new StreamTransportError(message2)
|
|
336
392
|
);
|
|
@@ -396,7 +452,8 @@ var AppilotsClient = class {
|
|
|
396
452
|
content,
|
|
397
453
|
sessionId: this.sessionId,
|
|
398
454
|
context,
|
|
399
|
-
...this.mcpVersion ? { mcpVersion: this.mcpVersion } : {}
|
|
455
|
+
...this.mcpVersion ? { mcpVersion: this.mcpVersion } : {},
|
|
456
|
+
...this.introspectionFragment()
|
|
400
457
|
})
|
|
401
458
|
);
|
|
402
459
|
});
|
|
@@ -917,25 +974,41 @@ function detectLocaleFromUserTexts(texts) {
|
|
|
917
974
|
var copy = {
|
|
918
975
|
pt: {
|
|
919
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}.`,
|
|
920
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?",
|
|
921
979
|
generic: (detail) => `Perdi o fio da automa\xE7\xE3o (${detail}). Pode continuar manualmente ou me pedir de novo?`
|
|
922
980
|
},
|
|
923
981
|
es: {
|
|
924
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}.`,
|
|
925
984
|
invalidInput: "No pude continuar la automatizaci\xF3n por un problema interno de sincronizaci\xF3n. \xBFPuedes intentarlo de nuevo o hacer esta parte manualmente?",
|
|
926
985
|
generic: (detail) => `Perd\xED el hilo de la automatizaci\xF3n (${detail}). \xBFPuedes continuar manualmente o ped\xEDrmelo de nuevo?`
|
|
927
986
|
},
|
|
928
987
|
fr: {
|
|
929
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}.`,
|
|
930
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 ?",
|
|
931
991
|
generic: (detail) => `J'ai perdu le fil de l'automatisation (${detail}). Vous pouvez continuer manuellement ou me redemander ?`
|
|
932
992
|
},
|
|
933
993
|
en: {
|
|
934
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}.`,
|
|
935
996
|
invalidInput: "I could not continue the automation because of an internal sync issue. You can try again or take over manually.",
|
|
936
997
|
generic: (detail) => `I lost my footing during automation (${detail}). You can take over from here.`
|
|
937
998
|
}
|
|
938
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
|
+
}
|
|
939
1012
|
function buildContinuationFailureMessage(rawError, recentUserTexts) {
|
|
940
1013
|
const locale = detectLocaleFromUserTexts(recentUserTexts);
|
|
941
1014
|
const strings = copy[locale] ?? copy.en;
|
|
@@ -1539,7 +1612,7 @@ var ChatSessionMachine = class {
|
|
|
1539
1612
|
const raw = err instanceof Error ? err.message : "Continuation failed";
|
|
1540
1613
|
this.warn("ChatSessionMachine: continuation failed \u2014", raw);
|
|
1541
1614
|
const recentUserTexts = this.state.messages.filter((m) => m.role === "user").slice(-4).map((m) => m.content);
|
|
1542
|
-
const friendly = buildContinuationFailureMessage(raw, recentUserTexts);
|
|
1615
|
+
const friendly = err instanceof RateLimitedError ? buildRateLimitedMessage(err.retryAfterSeconds, recentUserTexts) : buildContinuationFailureMessage(raw, recentUserTexts);
|
|
1543
1616
|
this.addAssistantMessage({
|
|
1544
1617
|
id: `error_${++this.messageIdCounter}`,
|
|
1545
1618
|
role: "assistant",
|
|
@@ -1701,6 +1774,17 @@ var ChatSessionMachine = class {
|
|
|
1701
1774
|
removeStreamingPlaceholder();
|
|
1702
1775
|
const errorMessage = err instanceof Error ? err.message : "Failed to send message";
|
|
1703
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
|
+
}
|
|
1704
1788
|
this.addAssistantMessage({
|
|
1705
1789
|
id: `error_${++this.messageIdCounter}`,
|
|
1706
1790
|
role: "assistant",
|
|
@@ -3622,15 +3706,32 @@ function getGlobalConfig() {
|
|
|
3622
3706
|
|
|
3623
3707
|
// src/introspection/fiberRoot.ts
|
|
3624
3708
|
var _fiberRoot = null;
|
|
3709
|
+
var _diagnostics = {
|
|
3710
|
+
captured: false,
|
|
3711
|
+
failureReason: null,
|
|
3712
|
+
reactVersion: null,
|
|
3713
|
+
failureCount: 0
|
|
3714
|
+
};
|
|
3625
3715
|
function setFiberRoot(fiber) {
|
|
3626
3716
|
if (_fiberRoot !== fiber) {
|
|
3627
3717
|
console.log(`[Appilots] Introspection: fiber root captured (type=${typeName(fiber)})`);
|
|
3628
3718
|
_fiberRoot = fiber;
|
|
3629
3719
|
}
|
|
3720
|
+
_diagnostics.captured = true;
|
|
3630
3721
|
}
|
|
3631
3722
|
function getFiberRoot() {
|
|
3632
3723
|
return _fiberRoot;
|
|
3633
3724
|
}
|
|
3725
|
+
function recordIntrospectionFailure(reason, reactVersion) {
|
|
3726
|
+
_diagnostics.failureCount += 1;
|
|
3727
|
+
if (_diagnostics.failureReason === null) {
|
|
3728
|
+
_diagnostics.failureReason = reason;
|
|
3729
|
+
_diagnostics.reactVersion = reactVersion;
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
function getIntrospectionDiagnostics() {
|
|
3733
|
+
return { ..._diagnostics };
|
|
3734
|
+
}
|
|
3634
3735
|
function typeName(fiber) {
|
|
3635
3736
|
const t = fiber?.type ?? fiber?.elementType;
|
|
3636
3737
|
if (!t) return "unknown";
|
|
@@ -3639,15 +3740,16 @@ function typeName(fiber) {
|
|
|
3639
3740
|
if (typeof t === "object") return t.displayName ?? t.render?.displayName ?? t.render?.name ?? "forwardRef/memo";
|
|
3640
3741
|
return String(t);
|
|
3641
3742
|
}
|
|
3642
|
-
|
|
3643
|
-
// src/introspection/AppilotsFiberRoot.tsx
|
|
3644
3743
|
var FiberSentinel = class extends React2.Component {
|
|
3645
3744
|
componentDidMount() {
|
|
3646
3745
|
const fiber = this._reactInternals ?? this._reactInternalFiber ?? null;
|
|
3647
3746
|
if (!fiber) {
|
|
3747
|
+
const reactVersion = React2.version ?? null;
|
|
3648
3748
|
console.warn(
|
|
3649
|
-
|
|
3749
|
+
`[Appilots] FiberSentinel: this._reactInternals is undefined; snapshot capture will fall back to render-time owner. React version may be incompatible (react=${reactVersion}).`
|
|
3650
3750
|
);
|
|
3751
|
+
recordIntrospectionFailure("sentinel-missing-internals", reactVersion);
|
|
3752
|
+
this.props.onUnavailable?.({ reactVersion });
|
|
3651
3753
|
return;
|
|
3652
3754
|
}
|
|
3653
3755
|
let top = fiber;
|
|
@@ -3658,13 +3760,16 @@ var FiberSentinel = class extends React2.Component {
|
|
|
3658
3760
|
return this.props.children ?? null;
|
|
3659
3761
|
}
|
|
3660
3762
|
};
|
|
3661
|
-
function AppilotsFiberRoot({
|
|
3763
|
+
function AppilotsFiberRoot({
|
|
3764
|
+
children,
|
|
3765
|
+
onUnavailable
|
|
3766
|
+
}) {
|
|
3662
3767
|
const Internals = React2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED_IN_THIS_VERSION_OF_REACT;
|
|
3663
3768
|
const ownerFiber = Internals?.ReactCurrentOwner?.current;
|
|
3664
3769
|
if (ownerFiber && !getFiberRoot()) {
|
|
3665
3770
|
setFiberRoot(ownerFiber);
|
|
3666
3771
|
}
|
|
3667
|
-
return /* @__PURE__ */ React2.createElement(FiberSentinel,
|
|
3772
|
+
return /* @__PURE__ */ React2.createElement(FiberSentinel, { onUnavailable }, children);
|
|
3668
3773
|
}
|
|
3669
3774
|
|
|
3670
3775
|
// src/debug/logger.ts
|
|
@@ -3721,6 +3826,16 @@ function AppilotsProvider({ config: configProp, children, client: externalClient
|
|
|
3721
3826
|
recordAppilotsEventTrace(event);
|
|
3722
3827
|
listenersRef.current.forEach((handler) => handler(event));
|
|
3723
3828
|
}, []);
|
|
3829
|
+
const handleIntrospectionUnavailable = useCallback(
|
|
3830
|
+
({ reactVersion }) => {
|
|
3831
|
+
emit({
|
|
3832
|
+
type: "sdk:introspection:unavailable",
|
|
3833
|
+
timestamp: Date.now(),
|
|
3834
|
+
data: { reason: "sentinel-missing-internals", reactVersion }
|
|
3835
|
+
});
|
|
3836
|
+
},
|
|
3837
|
+
[emit]
|
|
3838
|
+
);
|
|
3724
3839
|
const client = useMemo(
|
|
3725
3840
|
() => externalClient ?? new AppilotsClient({
|
|
3726
3841
|
projectId: config.projectId,
|
|
@@ -3729,7 +3844,9 @@ function AppilotsProvider({ config: configProp, children, client: externalClient
|
|
|
3729
3844
|
debug: config.debug,
|
|
3730
3845
|
appVersion: config.appVersion,
|
|
3731
3846
|
mcpVersion: config.mcpVersion,
|
|
3732
|
-
user: config.user
|
|
3847
|
+
user: config.user,
|
|
3848
|
+
// Only reports a FAILED reading; the happy path sends nothing.
|
|
3849
|
+
introspectionReporter: getIntrospectionDiagnostics
|
|
3733
3850
|
}),
|
|
3734
3851
|
[config.projectId, config.apiBaseUrl, config.apiKey, config.debug, config.appVersion, config.mcpVersion, config.user, externalClient]
|
|
3735
3852
|
);
|
|
@@ -3750,7 +3867,7 @@ function AppilotsProvider({ config: configProp, children, client: externalClient
|
|
|
3750
3867
|
() => ({ config, client, subscribe, emit, remotePersonalization }),
|
|
3751
3868
|
[config, client, subscribe, emit, remotePersonalization]
|
|
3752
3869
|
);
|
|
3753
|
-
return /* @__PURE__ */ React2.createElement(AppilotsContext.Provider, { value }, /* @__PURE__ */ React2.createElement(AppilotsFiberRoot,
|
|
3870
|
+
return /* @__PURE__ */ React2.createElement(AppilotsContext.Provider, { value }, /* @__PURE__ */ React2.createElement(AppilotsFiberRoot, { onUnavailable: handleIntrospectionUnavailable }, children));
|
|
3754
3871
|
}
|
|
3755
3872
|
function useAppilotsContext() {
|
|
3756
3873
|
const context = useContext(AppilotsContext);
|
|
@@ -4269,4 +4386,4 @@ function clearScreenRegistry() {
|
|
|
4269
4386
|
screenRegistry.clear();
|
|
4270
4387
|
}
|
|
4271
4388
|
|
|
4272
|
-
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, getNavigationRef, getNavigationStateSnapshot, getScreenMetadata, humanizeError, idLooselyMatches, initAppilots, isAutoTrackingEnabled, isGenericSelectValue, isListItemPressTarget, isOptionalStepAutomationFailure, listRegistry, looksDestructiveActionLabel, matchScore, mergeThemeTokens, normalize3, parseStableElementId, probeLoadingState, recordAppilotsDebugTrace, 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 };
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
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';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
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';
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
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
|
|
10
|
+
get: function () { return chunkHFRIB4YN_js.useAppilots; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "useAppilotsActions", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkHFRIB4YN_js.useAppilotsActions; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "useAppilotsChat", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkHFRIB4YN_js.useAppilotsChat; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "useAppilotsField", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkHFRIB4YN_js.useAppilotsField; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "useAppilotsNavigation", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkHFRIB4YN_js.useAppilotsNavigation; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "useAppilotsSlider", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkHFRIB4YN_js.useAppilotsSlider; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "useAppilotsTarget", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkHFRIB4YN_js.useAppilotsTarget; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "useAppilotsToggle", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkHFRIB4YN_js.useAppilotsToggle; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "useSuggestedPrompts", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkHFRIB4YN_js.useSuggestedPrompts; }
|
|
43
43
|
});
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useAppilots, useAppilotsActions, useAppilotsChat, useAppilotsField, useAppilotsNavigation, useAppilotsSlider, useAppilotsTarget, useAppilotsToggle, useSuggestedPrompts } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { useAppilots, useAppilotsActions, useAppilotsChat, useAppilotsField, useAppilotsNavigation, useAppilotsSlider, useAppilotsTarget, useAppilotsToggle, useSuggestedPrompts } from '../chunk-KUFWRJC4.mjs';
|
|
2
|
+
import '../chunk-R4D34FEW.mjs';
|
|
@@ -281,7 +281,7 @@ interface AgentPermissions {
|
|
|
281
281
|
blockedScreens?: string[];
|
|
282
282
|
allowedActions?: AgentActionType[];
|
|
283
283
|
}
|
|
284
|
-
type AppilotsEventType = 'agent:action:start' | 'agent:action:complete' | 'agent:action:error' | 'agent:message' | 'navigation:change' | 'chat:open' | 'chat:close' | 'chat:escalation:start' | 'chat:escalation:message' | 'chat:escalation:end';
|
|
284
|
+
type AppilotsEventType = 'agent:action:start' | 'agent:action:complete' | 'agent:action:error' | 'agent:message' | 'navigation:change' | 'chat:open' | 'chat:close' | 'chat:escalation:start' | 'chat:escalation:message' | 'chat:escalation:end' | 'sdk:introspection:unavailable';
|
|
285
285
|
interface AppilotsEvent {
|
|
286
286
|
type: AppilotsEventType;
|
|
287
287
|
timestamp: number;
|
|
@@ -300,6 +300,17 @@ interface EscalationState {
|
|
|
300
300
|
operatorName?: string;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Mirrors `introspectionDiagnosticsSchema` on the wire. Declared here
|
|
305
|
+
* rather than imported so client-core stays free of the server's
|
|
306
|
+
* validator package.
|
|
307
|
+
*/
|
|
308
|
+
interface IntrospectionDiagnosticsInput {
|
|
309
|
+
captured: boolean;
|
|
310
|
+
failureReason?: 'sentinel-missing-internals' | 'never-mounted' | null;
|
|
311
|
+
reactVersion?: string | null;
|
|
312
|
+
failureCount?: number;
|
|
313
|
+
}
|
|
303
314
|
interface AppilotsClientOptions {
|
|
304
315
|
projectId: string;
|
|
305
316
|
apiBaseUrl?: string;
|
|
@@ -318,6 +329,17 @@ interface AppilotsClientOptions {
|
|
|
318
329
|
* from your app's package.json so it stays in lockstep with releases.
|
|
319
330
|
*/
|
|
320
331
|
mcpVersion?: string;
|
|
332
|
+
/**
|
|
333
|
+
* Reports whether the platform binding could read the host app's UI
|
|
334
|
+
* tree. Called once per message; return `null` (or omit the option)
|
|
335
|
+
* when there is nothing to report.
|
|
336
|
+
*
|
|
337
|
+
* Only a FAILED reading is put on the wire. When introspection is
|
|
338
|
+
* dead every observation is empty but perfectly well-formed, so the
|
|
339
|
+
* server cannot tell a blind session from a user looking at empty
|
|
340
|
+
* screens — this is the only signal that distinguishes them.
|
|
341
|
+
*/
|
|
342
|
+
introspectionReporter?: () => IntrospectionDiagnosticsInput | null | undefined;
|
|
321
343
|
/**
|
|
322
344
|
* The host app's version (e.g. from package.json or
|
|
323
345
|
* react-native-device-info). Sent as `X-App-Version` on every request
|
|
@@ -364,6 +386,30 @@ interface SendMessageStreamOptions {
|
|
|
364
386
|
/** Abort mid-generation (stop button). Rejects with name='AbortError'. */
|
|
365
387
|
signal?: AbortSignal;
|
|
366
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
|
+
}
|
|
367
413
|
/** Runtime context sent with every user message. */
|
|
368
414
|
interface SendMessageContext {
|
|
369
415
|
/**
|
|
@@ -417,6 +463,7 @@ declare class AppilotsClient {
|
|
|
417
463
|
private readonly timeout;
|
|
418
464
|
private readonly debug;
|
|
419
465
|
private readonly mcpVersion;
|
|
466
|
+
private readonly introspectionReporter;
|
|
420
467
|
private readonly user;
|
|
421
468
|
private sessionId;
|
|
422
469
|
/** Guard so identify fires at most once per client instance. */
|
|
@@ -434,6 +481,13 @@ declare class AppilotsClient {
|
|
|
434
481
|
private identifyConfiguredUser;
|
|
435
482
|
destroySession(): Promise<void>;
|
|
436
483
|
getSessionId(): string | null;
|
|
484
|
+
/**
|
|
485
|
+
* Wire fragment for introspection health. Empty on the happy path —
|
|
486
|
+
* a working client sends nothing, so the field costs a byte only
|
|
487
|
+
* when something is actually wrong. Never throws: a broken reporter
|
|
488
|
+
* must not take the message down with it.
|
|
489
|
+
*/
|
|
490
|
+
private introspectionFragment;
|
|
437
491
|
sendMessage(content: string, context?: SendMessageContext): Promise<SendMessageResponse>;
|
|
438
492
|
/**
|
|
439
493
|
* Streaming variant of `sendMessage` — consumes the server's SSE
|
|
@@ -1540,4 +1594,4 @@ interface UseSuggestedPromptsReturn {
|
|
|
1540
1594
|
*/
|
|
1541
1595
|
declare function useSuggestedPrompts(options: UseSuggestedPromptsOptions): UseSuggestedPromptsReturn;
|
|
1542
1596
|
|
|
1543
|
-
export {
|
|
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 };
|
|
@@ -281,7 +281,7 @@ interface AgentPermissions {
|
|
|
281
281
|
blockedScreens?: string[];
|
|
282
282
|
allowedActions?: AgentActionType[];
|
|
283
283
|
}
|
|
284
|
-
type AppilotsEventType = 'agent:action:start' | 'agent:action:complete' | 'agent:action:error' | 'agent:message' | 'navigation:change' | 'chat:open' | 'chat:close' | 'chat:escalation:start' | 'chat:escalation:message' | 'chat:escalation:end';
|
|
284
|
+
type AppilotsEventType = 'agent:action:start' | 'agent:action:complete' | 'agent:action:error' | 'agent:message' | 'navigation:change' | 'chat:open' | 'chat:close' | 'chat:escalation:start' | 'chat:escalation:message' | 'chat:escalation:end' | 'sdk:introspection:unavailable';
|
|
285
285
|
interface AppilotsEvent {
|
|
286
286
|
type: AppilotsEventType;
|
|
287
287
|
timestamp: number;
|
|
@@ -300,6 +300,17 @@ interface EscalationState {
|
|
|
300
300
|
operatorName?: string;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Mirrors `introspectionDiagnosticsSchema` on the wire. Declared here
|
|
305
|
+
* rather than imported so client-core stays free of the server's
|
|
306
|
+
* validator package.
|
|
307
|
+
*/
|
|
308
|
+
interface IntrospectionDiagnosticsInput {
|
|
309
|
+
captured: boolean;
|
|
310
|
+
failureReason?: 'sentinel-missing-internals' | 'never-mounted' | null;
|
|
311
|
+
reactVersion?: string | null;
|
|
312
|
+
failureCount?: number;
|
|
313
|
+
}
|
|
303
314
|
interface AppilotsClientOptions {
|
|
304
315
|
projectId: string;
|
|
305
316
|
apiBaseUrl?: string;
|
|
@@ -318,6 +329,17 @@ interface AppilotsClientOptions {
|
|
|
318
329
|
* from your app's package.json so it stays in lockstep with releases.
|
|
319
330
|
*/
|
|
320
331
|
mcpVersion?: string;
|
|
332
|
+
/**
|
|
333
|
+
* Reports whether the platform binding could read the host app's UI
|
|
334
|
+
* tree. Called once per message; return `null` (or omit the option)
|
|
335
|
+
* when there is nothing to report.
|
|
336
|
+
*
|
|
337
|
+
* Only a FAILED reading is put on the wire. When introspection is
|
|
338
|
+
* dead every observation is empty but perfectly well-formed, so the
|
|
339
|
+
* server cannot tell a blind session from a user looking at empty
|
|
340
|
+
* screens — this is the only signal that distinguishes them.
|
|
341
|
+
*/
|
|
342
|
+
introspectionReporter?: () => IntrospectionDiagnosticsInput | null | undefined;
|
|
321
343
|
/**
|
|
322
344
|
* The host app's version (e.g. from package.json or
|
|
323
345
|
* react-native-device-info). Sent as `X-App-Version` on every request
|
|
@@ -364,6 +386,30 @@ interface SendMessageStreamOptions {
|
|
|
364
386
|
/** Abort mid-generation (stop button). Rejects with name='AbortError'. */
|
|
365
387
|
signal?: AbortSignal;
|
|
366
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
|
+
}
|
|
367
413
|
/** Runtime context sent with every user message. */
|
|
368
414
|
interface SendMessageContext {
|
|
369
415
|
/**
|
|
@@ -417,6 +463,7 @@ declare class AppilotsClient {
|
|
|
417
463
|
private readonly timeout;
|
|
418
464
|
private readonly debug;
|
|
419
465
|
private readonly mcpVersion;
|
|
466
|
+
private readonly introspectionReporter;
|
|
420
467
|
private readonly user;
|
|
421
468
|
private sessionId;
|
|
422
469
|
/** Guard so identify fires at most once per client instance. */
|
|
@@ -434,6 +481,13 @@ declare class AppilotsClient {
|
|
|
434
481
|
private identifyConfiguredUser;
|
|
435
482
|
destroySession(): Promise<void>;
|
|
436
483
|
getSessionId(): string | null;
|
|
484
|
+
/**
|
|
485
|
+
* Wire fragment for introspection health. Empty on the happy path —
|
|
486
|
+
* a working client sends nothing, so the field costs a byte only
|
|
487
|
+
* when something is actually wrong. Never throws: a broken reporter
|
|
488
|
+
* must not take the message down with it.
|
|
489
|
+
*/
|
|
490
|
+
private introspectionFragment;
|
|
437
491
|
sendMessage(content: string, context?: SendMessageContext): Promise<SendMessageResponse>;
|
|
438
492
|
/**
|
|
439
493
|
* Streaming variant of `sendMessage` — consumes the server's SSE
|
|
@@ -1540,4 +1594,4 @@ interface UseSuggestedPromptsReturn {
|
|
|
1540
1594
|
*/
|
|
1541
1595
|
declare function useSuggestedPrompts(options: UseSuggestedPromptsOptions): UseSuggestedPromptsReturn;
|
|
1542
1596
|
|
|
1543
|
-
export {
|
|
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 };
|