@adonis-agora/agent 0.75.0 → 0.76.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/CHANGELOG.md +13 -0
- package/README.md +16 -0
- package/dist/src/genui/sandbox.d.ts +7 -0
- package/dist/src/genui/sandbox.d.ts.map +1 -1
- package/dist/src/genui/sandbox.js +11 -4
- package/dist/src/genui/sandbox.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/react-native/genui/index.d.ts +20 -0
- package/dist/src/react-native/genui/index.d.ts.map +1 -0
- package/dist/src/react-native/genui/index.js +18 -0
- package/dist/src/react-native/genui/index.js.map +1 -0
- package/dist/src/react-native/genui/provider.d.ts +19 -0
- package/dist/src/react-native/genui/provider.d.ts.map +1 -0
- package/dist/src/react-native/genui/provider.js +23 -0
- package/dist/src/react-native/genui/provider.js.map +1 -0
- package/dist/src/react-native/genui/sandbox-assets.d.ts +57 -0
- package/dist/src/react-native/genui/sandbox-assets.d.ts.map +1 -0
- package/dist/src/react-native/genui/sandbox-assets.js +153 -0
- package/dist/src/react-native/genui/sandbox-assets.js.map +1 -0
- package/dist/src/react-native/genui/sandbox-host.d.ts +119 -0
- package/dist/src/react-native/genui/sandbox-host.d.ts.map +1 -0
- package/dist/src/react-native/genui/sandbox-host.js +188 -0
- package/dist/src/react-native/genui/sandbox-host.js.map +1 -0
- package/dist/src/react-native/genui/sandbox.d.ts +86 -0
- package/dist/src/react-native/genui/sandbox.d.ts.map +1 -0
- package/dist/src/react-native/genui/sandbox.js +376 -0
- package/dist/src/react-native/genui/sandbox.js.map +1 -0
- package/package.json +16 -1
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
4
|
+
import { Text, View } from 'react-native';
|
|
5
|
+
import { WebView, } from 'react-native-webview';
|
|
6
|
+
import { buildSandboxDocument, previewHtml, SANDBOX_DEFAULTS, SANDBOX_MESSAGE, sandboxPolicyOf, } from '../../genui/sandbox.js';
|
|
7
|
+
import { GenuiActionContext, useGenuiNode, useGenuiProvider, } from '../../react/core/genui/generative-ui.js';
|
|
8
|
+
import { useNativeSandboxAsset, useNativeSandboxConfig, } from './sandbox-assets.js';
|
|
9
|
+
import { checkSandboxSend, clampSandboxHeight, hostMessageScript, nativeThemeCss, parseFrameMessage, sandboxToken, shouldStartSandboxLoad, } from './sandbox-host.js';
|
|
10
|
+
/**
|
|
11
|
+
* The WebView props every sandbox gets. JavaScript runs inside it; it stores nothing (no DOM
|
|
12
|
+
* storage, incognito, no cache, no cookies), reads no file, opens no window, loads no mixed content,
|
|
13
|
+
* shows no link preview, does not scroll (the host sizes it to its content) and goes nowhere: every
|
|
14
|
+
* URL reaches `onShouldStartLoadWithRequest` (the whitelist lets them through — a URL it refuses
|
|
15
|
+
* would be handed to `Linking.openURL`), which allows only the inline document.
|
|
16
|
+
*/
|
|
17
|
+
export const NATIVE_SANDBOX_WEBVIEW_PROPS = Object.freeze({
|
|
18
|
+
// Frozen with the rest: one shared array must not be widened by anyone.
|
|
19
|
+
originWhitelist: Object.freeze(['*']),
|
|
20
|
+
onShouldStartLoadWithRequest: shouldStartSandboxLoad,
|
|
21
|
+
javaScriptEnabled: true,
|
|
22
|
+
javaScriptCanOpenWindowsAutomatically: false,
|
|
23
|
+
setSupportMultipleWindows: false,
|
|
24
|
+
domStorageEnabled: false,
|
|
25
|
+
allowFileAccess: false,
|
|
26
|
+
allowFileAccessFromFileURLs: false,
|
|
27
|
+
allowUniversalAccessFromFileURLs: false,
|
|
28
|
+
allowsLinkPreview: false,
|
|
29
|
+
incognito: true,
|
|
30
|
+
cacheEnabled: false,
|
|
31
|
+
cacheMode: 'LOAD_NO_CACHE',
|
|
32
|
+
mixedContentMode: 'never',
|
|
33
|
+
sharedCookiesEnabled: false,
|
|
34
|
+
thirdPartyCookiesEnabled: false,
|
|
35
|
+
geolocationEnabled: false,
|
|
36
|
+
mediaCapturePermissionGrantType: 'deny',
|
|
37
|
+
mediaPlaybackRequiresUserAction: true,
|
|
38
|
+
allowsFullscreenVideo: false,
|
|
39
|
+
allowsAirPlayForMediaPlayback: false,
|
|
40
|
+
allowsProtectedMedia: false,
|
|
41
|
+
allowsBackForwardNavigationGestures: false,
|
|
42
|
+
pullToRefreshEnabled: false,
|
|
43
|
+
dataDetectorTypes: 'none',
|
|
44
|
+
saveFormDataDisabled: true,
|
|
45
|
+
setBuiltInZoomControls: false,
|
|
46
|
+
setDisplayZoomControls: false,
|
|
47
|
+
textZoom: 100,
|
|
48
|
+
paymentRequestEnabled: false,
|
|
49
|
+
enableApplePay: false,
|
|
50
|
+
webviewDebuggingEnabled: false,
|
|
51
|
+
scrollEnabled: false,
|
|
52
|
+
bounces: false,
|
|
53
|
+
overScrollMode: 'never',
|
|
54
|
+
nestedScrollEnabled: false,
|
|
55
|
+
showsVerticalScrollIndicator: false,
|
|
56
|
+
showsHorizontalScrollIndicator: false,
|
|
57
|
+
automaticallyAdjustContentInsets: false,
|
|
58
|
+
contentInsetAdjustmentBehavior: 'never',
|
|
59
|
+
startInLoadingState: false,
|
|
60
|
+
});
|
|
61
|
+
// The package's class declaration (`Component<WebViewProps & P>`, `P = undefined`) types its props
|
|
62
|
+
// as `never` under strict null checks; this is the component as it is.
|
|
63
|
+
const SandboxWebView = WebView;
|
|
64
|
+
/** A URL that is neither the inline document nor a `data:` one — the WebView left the sandbox. */
|
|
65
|
+
function isForeignUrl(url) {
|
|
66
|
+
return typeof url === 'string' && url !== '' && !/^(about|data):/i.test(url);
|
|
67
|
+
}
|
|
68
|
+
/** How many times a view whose WebView process died is drawn afresh before it gives up. */
|
|
69
|
+
const MAX_RESTARTS = 2;
|
|
70
|
+
const placeholderBox = {
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
borderWidth: 1,
|
|
74
|
+
borderStyle: 'dashed',
|
|
75
|
+
borderColor: 'rgba(127,127,127,0.35)',
|
|
76
|
+
borderRadius: 8,
|
|
77
|
+
padding: 12,
|
|
78
|
+
};
|
|
79
|
+
function DefaultPlaceholder({ height, messages, title, }) {
|
|
80
|
+
const [index, setIndex] = useState(0);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (messages.length < 2)
|
|
83
|
+
return;
|
|
84
|
+
const timer = setInterval(() => setIndex((value) => (value + 1) % messages.length), 1800);
|
|
85
|
+
return () => clearInterval(timer);
|
|
86
|
+
}, [messages.length]);
|
|
87
|
+
const line = messages[index % Math.max(1, messages.length)] ?? 'Building the view…';
|
|
88
|
+
return (_jsx(View, { testID: "sandbox-placeholder", accessibilityRole: "progressbar", accessibilityState: { busy: true }, style: [placeholderBox, { height }], children: _jsx(Text, { style: { color: 'rgba(90,90,90,0.9)', fontSize: 13 }, children: title !== undefined ? `${title} — ${line}` : line }) }));
|
|
89
|
+
}
|
|
90
|
+
function Note({ testID, title, text }) {
|
|
91
|
+
return (_jsxs(View, { testID: testID, style: [placeholderBox, { alignItems: 'flex-start' }], children: [title !== undefined ? _jsx(Text, { style: { fontWeight: '600' }, children: title }) : null, _jsx(Text, { children: text })] }));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A React Native renderer for the sandbox component (`Sandbox`): the model's HTML, CSS and JS in a
|
|
95
|
+
* hardened `react-native-webview` ({@link NATIVE_SANDBOX_WEBVIEW_PROPS}) — the same document as the
|
|
96
|
+
* web renderer's iframe (`buildSandboxDocument`, the same CSP: no network unless the policy lists an
|
|
97
|
+
* origin), sized to its content.
|
|
98
|
+
*
|
|
99
|
+
* It streams like the web one: a placeholder of `initialHeight`, a preview of the styled markup (no
|
|
100
|
+
* code runs), then the live view, whose code is posted in as it closes. The only bridge is the one
|
|
101
|
+
* the document carries: `ReactNativeWebView.postMessage` out (ready, resize, error, `agent.send`),
|
|
102
|
+
* `injectJavaScript` dispatching a `message` event in (render, run, theme, jsx). Everything the
|
|
103
|
+
* WebView says is checked as the web host checks it — length capped before parsing, the frame's
|
|
104
|
+
* token, size, interval and count limits, JSON only, `schema`, `confirm` — and an accepted
|
|
105
|
+
* `agent.send` is handed on as a `UiAction`.
|
|
106
|
+
*
|
|
107
|
+
* ```tsx
|
|
108
|
+
* <GenuiProvider registry={{ Sandbox: createNativeSandboxRenderer({ theme: () => useSandboxTheme() }) }} onAction={chat.sendUiAction}>
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export function createNativeSandboxRenderer(options = {}) {
|
|
112
|
+
const themeOption = options.theme;
|
|
113
|
+
// Fixed per renderer, so the hook below is always (or never) called.
|
|
114
|
+
const useThemeOption = typeof themeOption === 'function'
|
|
115
|
+
? themeOption
|
|
116
|
+
: () => (themeOption === false ? null : themeOption);
|
|
117
|
+
function NativeSandboxView(props) {
|
|
118
|
+
const node = useGenuiNode();
|
|
119
|
+
const provided = useGenuiProvider();
|
|
120
|
+
const contextAction = useContext(GenuiActionContext);
|
|
121
|
+
const definition = provided?.catalog?.get?.(node?.type ?? 'Sandbox');
|
|
122
|
+
const policy = useMemo(() => options.policy ?? sandboxPolicyOf(definition) ?? {}, [definition]);
|
|
123
|
+
const incomplete = node?.incomplete === true;
|
|
124
|
+
const client = useNativeSandboxConfig(options.config, options.baseUrl, options.fetch);
|
|
125
|
+
const view = definition?.sandboxView;
|
|
126
|
+
const themeOn = themeOption !== false && (client.config?.theme ?? view?.theme ?? true) !== false;
|
|
127
|
+
const themeInput = useThemeOption();
|
|
128
|
+
const themeKey = themeOn && themeInput ? JSON.stringify(themeInput) : '';
|
|
129
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: keyed on the theme's content
|
|
130
|
+
const theme = useMemo(() => (themeOn && themeInput ? nativeThemeCss(themeInput) : null), [themeKey]);
|
|
131
|
+
const jsxMode = typeof props.jsx === 'string';
|
|
132
|
+
const tailwindConfig = client.config?.tailwind;
|
|
133
|
+
const tailwindText = useNativeSandboxAsset(tailwindConfig !== undefined
|
|
134
|
+
? { inline: tailwindConfig.runtime, url: tailwindConfig.url }
|
|
135
|
+
: undefined, options.baseUrl, options.fetch);
|
|
136
|
+
const cssConfig = client.config?.css;
|
|
137
|
+
const cssText = useNativeSandboxAsset(cssConfig !== undefined ? { inline: cssConfig.source, url: cssConfig.url } : undefined, options.baseUrl, options.fetch);
|
|
138
|
+
const kitConfig = client.config?.kit;
|
|
139
|
+
const kitText = useNativeSandboxAsset(jsxMode && kitConfig !== undefined
|
|
140
|
+
? { inline: kitConfig.source, url: kitConfig.url }
|
|
141
|
+
: undefined, options.baseUrl, options.fetch);
|
|
142
|
+
const assetsPending = (tailwindConfig !== undefined && tailwindText === undefined) ||
|
|
143
|
+
(cssConfig !== undefined && cssText === undefined) ||
|
|
144
|
+
(jsxMode && (client.loading || kitText === undefined));
|
|
145
|
+
const themeRef = useRef(theme);
|
|
146
|
+
themeRef.current = theme;
|
|
147
|
+
// The server drops half-written code from what it previews (`sandboxPartialProps`); props
|
|
148
|
+
// from anywhere else may hold it, so their code waits for the whole view.
|
|
149
|
+
const trimmed = incomplete && node?.streamSafe === true;
|
|
150
|
+
const token = useMemo(sandboxToken, []);
|
|
151
|
+
const web = useRef(null);
|
|
152
|
+
const ready = useRef(false);
|
|
153
|
+
const ran = useRef({ functions: false, expressions: 0 });
|
|
154
|
+
const sends = useRef({ count: 0, last: 0 });
|
|
155
|
+
const initial = clampSandboxHeight(props.initialHeight ?? SANDBOX_DEFAULTS.initialHeight, policy);
|
|
156
|
+
const [measured, setMeasured] = useState(null);
|
|
157
|
+
const height = measured ?? initial;
|
|
158
|
+
const streamedIn = useRef(incomplete);
|
|
159
|
+
// The WebView left the inline document (it never should), or its process died too often.
|
|
160
|
+
const [lost, setLost] = useState(null);
|
|
161
|
+
const [generation, setGeneration] = useState(0);
|
|
162
|
+
const hasMarkup = typeof props.html === 'string' && props.html.length > 0;
|
|
163
|
+
const markupDone = !incomplete || props.jsFunctions !== undefined || props.jsExpressions !== undefined;
|
|
164
|
+
const hasJsx = jsxMode && props.jsx.trim().length > 0;
|
|
165
|
+
const phase = assetsPending
|
|
166
|
+
? 'placeholder'
|
|
167
|
+
: jsxMode
|
|
168
|
+
? !hasJsx
|
|
169
|
+
? 'placeholder'
|
|
170
|
+
: incomplete
|
|
171
|
+
? 'preview'
|
|
172
|
+
: 'live'
|
|
173
|
+
: !incomplete
|
|
174
|
+
? 'live'
|
|
175
|
+
: markupDone && hasMarkup && trimmed
|
|
176
|
+
? 'live'
|
|
177
|
+
: props.css !== undefined || hasMarkup
|
|
178
|
+
? 'preview'
|
|
179
|
+
: 'placeholder';
|
|
180
|
+
const inlineJs = !streamedIn.current;
|
|
181
|
+
const css = props.css;
|
|
182
|
+
const html = props.html;
|
|
183
|
+
const kit = jsxMode && typeof kitText === 'string' ? kitText : undefined;
|
|
184
|
+
const documentPhase = jsxMode && phase !== 'placeholder' ? 'jsx' : phase;
|
|
185
|
+
// Built once per markup, like the web renderer's: code that arrives later is posted in.
|
|
186
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rebuilt on the markup only
|
|
187
|
+
const documentHtml = useMemo(() => {
|
|
188
|
+
if (phase === 'placeholder')
|
|
189
|
+
return '';
|
|
190
|
+
const current = themeRef.current;
|
|
191
|
+
const look = {
|
|
192
|
+
...(current !== null
|
|
193
|
+
? { theme: { css: current.css, dark: current.dark, attributes: current.attributes } }
|
|
194
|
+
: {}),
|
|
195
|
+
...(typeof cssText === 'string' ? { styles: cssText } : {}),
|
|
196
|
+
...(typeof tailwindText === 'string'
|
|
197
|
+
? {
|
|
198
|
+
tailwind: {
|
|
199
|
+
runtime: tailwindText,
|
|
200
|
+
theme: [current?.tailwind ?? '', tailwindConfig?.css ?? '']
|
|
201
|
+
.filter((part) => part !== '')
|
|
202
|
+
.join('\n'),
|
|
203
|
+
},
|
|
204
|
+
}
|
|
205
|
+
: {}),
|
|
206
|
+
};
|
|
207
|
+
const base = { token, hostOrigin: '', policy, transport: 'react-native', ...look };
|
|
208
|
+
if (jsxMode) {
|
|
209
|
+
return buildSandboxDocument({ css: css ?? '' }, { ...base, mode: 'live', inlineJs: false, ...(kit !== undefined ? { kit } : {}) });
|
|
210
|
+
}
|
|
211
|
+
return phase === 'preview'
|
|
212
|
+
? buildSandboxDocument({}, { ...base, mode: 'preview' })
|
|
213
|
+
: buildSandboxDocument(props, { ...base, mode: 'live', inlineJs });
|
|
214
|
+
}, [
|
|
215
|
+
documentPhase,
|
|
216
|
+
token,
|
|
217
|
+
jsxMode ? '' : css,
|
|
218
|
+
html,
|
|
219
|
+
inlineJs,
|
|
220
|
+
policy,
|
|
221
|
+
tailwindText,
|
|
222
|
+
cssText,
|
|
223
|
+
kit,
|
|
224
|
+
]);
|
|
225
|
+
const source = useMemo(() => ({ html: documentHtml, baseUrl: 'about:blank' }), [documentHtml]);
|
|
226
|
+
const post = useCallback((message) => {
|
|
227
|
+
web.current?.injectJavaScript(hostMessageScript({ ...message, token }));
|
|
228
|
+
}, [token]);
|
|
229
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: jsxMode only gates it off
|
|
230
|
+
const runPending = useCallback(() => {
|
|
231
|
+
if (!ready.current || inlineJs || phase !== 'live' || jsxMode)
|
|
232
|
+
return;
|
|
233
|
+
if (!trimmed && incomplete)
|
|
234
|
+
return;
|
|
235
|
+
const done = ran.current;
|
|
236
|
+
if (!done.functions && typeof props.jsFunctions === 'string') {
|
|
237
|
+
post({ type: SANDBOX_MESSAGE.run, code: props.jsFunctions });
|
|
238
|
+
done.functions = true;
|
|
239
|
+
}
|
|
240
|
+
if (!done.functions && incomplete && props.jsExpressions === undefined)
|
|
241
|
+
return;
|
|
242
|
+
const expressions = props.jsExpressions ?? [];
|
|
243
|
+
while (done.expressions < expressions.length) {
|
|
244
|
+
const code = expressions[done.expressions];
|
|
245
|
+
done.expressions += 1;
|
|
246
|
+
if (typeof code === 'string')
|
|
247
|
+
post({ type: SANDBOX_MESSAGE.run, code });
|
|
248
|
+
}
|
|
249
|
+
}, [inlineJs, phase, trimmed, incomplete, props.jsFunctions, props.jsExpressions, post]);
|
|
250
|
+
const preview = useCallback(() => {
|
|
251
|
+
if (!ready.current)
|
|
252
|
+
return;
|
|
253
|
+
if (jsxMode) {
|
|
254
|
+
if (phase !== 'placeholder')
|
|
255
|
+
post({ type: SANDBOX_MESSAGE.jsx, code: props.jsx ?? '', final: phase === 'live' });
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (phase !== 'preview')
|
|
259
|
+
return;
|
|
260
|
+
post({ type: SANDBOX_MESSAGE.render, css: css ?? '', html: previewHtml(html ?? '') });
|
|
261
|
+
}, [jsxMode, phase, props.jsx, css, html, post]);
|
|
262
|
+
// The app's theme changed: the view follows, without reloading.
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
if (theme === null || !ready.current)
|
|
265
|
+
return;
|
|
266
|
+
post({
|
|
267
|
+
type: SANDBOX_MESSAGE.theme,
|
|
268
|
+
css: theme.css,
|
|
269
|
+
dark: theme.dark,
|
|
270
|
+
attributes: theme.attributes,
|
|
271
|
+
});
|
|
272
|
+
}, [theme, post]);
|
|
273
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new document starts from nothing
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
ready.current = false;
|
|
276
|
+
ran.current = { functions: false, expressions: 0 };
|
|
277
|
+
}, [documentHtml, generation]);
|
|
278
|
+
useEffect(() => {
|
|
279
|
+
preview();
|
|
280
|
+
runPending();
|
|
281
|
+
}, [preview, runPending]);
|
|
282
|
+
const onAction = options.onAction ?? contextAction;
|
|
283
|
+
const title = props.title;
|
|
284
|
+
const nodeId = node?.id;
|
|
285
|
+
const send = useCallback(async (payload) => {
|
|
286
|
+
const result = await checkSandboxSend({
|
|
287
|
+
payload,
|
|
288
|
+
state: sends.current,
|
|
289
|
+
policy,
|
|
290
|
+
incomplete,
|
|
291
|
+
...(options.schema !== undefined ? { schema: options.schema } : {}),
|
|
292
|
+
...(options.confirm !== undefined ? { confirm: options.confirm } : {}),
|
|
293
|
+
hasHandler: onAction !== null && onAction !== undefined,
|
|
294
|
+
...(nodeId !== undefined ? { componentId: nodeId } : {}),
|
|
295
|
+
...(title !== undefined ? { title } : {}),
|
|
296
|
+
});
|
|
297
|
+
if (!result.ok)
|
|
298
|
+
return options.onRefused?.(result.refusal);
|
|
299
|
+
onAction?.(result.action);
|
|
300
|
+
}, [policy, nodeId, title, onAction, incomplete]);
|
|
301
|
+
const limit = policy.maxPayloadBytes ?? SANDBOX_DEFAULTS.maxPayloadBytes;
|
|
302
|
+
const onMessage = useCallback((event) => {
|
|
303
|
+
const native = event.nativeEvent;
|
|
304
|
+
// Only the inline document speaks for the sandbox (it cannot navigate; this is the backstop).
|
|
305
|
+
if (isForeignUrl(native.url))
|
|
306
|
+
return;
|
|
307
|
+
const message = parseFrameMessage(native.data, token, limit);
|
|
308
|
+
if (message.kind === 'too-large') {
|
|
309
|
+
options.onRefused?.({ reason: 'too-large', bytes: message.bytes, limit });
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (message.kind === 'drop')
|
|
313
|
+
return;
|
|
314
|
+
const data = message.data;
|
|
315
|
+
switch (data.type) {
|
|
316
|
+
case SANDBOX_MESSAGE.ready:
|
|
317
|
+
ready.current = true;
|
|
318
|
+
if (typeof data.height === 'number' && Number.isFinite(data.height) && data.height > 0)
|
|
319
|
+
setMeasured(clampSandboxHeight(data.height, policy));
|
|
320
|
+
if (themeRef.current !== null)
|
|
321
|
+
post({
|
|
322
|
+
type: SANDBOX_MESSAGE.theme,
|
|
323
|
+
css: themeRef.current.css,
|
|
324
|
+
dark: themeRef.current.dark,
|
|
325
|
+
attributes: themeRef.current.attributes,
|
|
326
|
+
});
|
|
327
|
+
preview();
|
|
328
|
+
runPending();
|
|
329
|
+
return;
|
|
330
|
+
case SANDBOX_MESSAGE.resize:
|
|
331
|
+
if (typeof data.height === 'number' && Number.isFinite(data.height))
|
|
332
|
+
setMeasured(clampSandboxHeight(data.height, policy));
|
|
333
|
+
return;
|
|
334
|
+
case SANDBOX_MESSAGE.send:
|
|
335
|
+
void send(data.payload);
|
|
336
|
+
return;
|
|
337
|
+
case SANDBOX_MESSAGE.error:
|
|
338
|
+
options.onError?.(typeof data.message === 'string' ? data.message.slice(0, 500) : 'error');
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
}, [token, limit, policy, post, preview, runPending, send]);
|
|
342
|
+
const onNavigation = useCallback((navigation) => {
|
|
343
|
+
if (!isForeignUrl(navigation.url))
|
|
344
|
+
return;
|
|
345
|
+
setLost('navigated');
|
|
346
|
+
options.onError?.('The view tried to leave the sandbox.');
|
|
347
|
+
}, []);
|
|
348
|
+
// Handled (Android crashes the app on a render process gone that nobody handles): draw afresh.
|
|
349
|
+
const restarts = useRef(0);
|
|
350
|
+
const onProcessGone = useCallback(() => {
|
|
351
|
+
if (restarts.current >= MAX_RESTARTS) {
|
|
352
|
+
setLost('crashed');
|
|
353
|
+
options.onError?.('The view stopped working.');
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
restarts.current += 1;
|
|
357
|
+
setGeneration((value) => value + 1);
|
|
358
|
+
}, []);
|
|
359
|
+
const messages = (props.placeholderMessages ?? []).filter((line) => typeof line === 'string');
|
|
360
|
+
if (lost !== null) {
|
|
361
|
+
return (_jsx(Note, { testID: "sandbox-lost", ...(title !== undefined ? { title } : {}), text: props.summary ?? 'This interactive view is unavailable.' }));
|
|
362
|
+
}
|
|
363
|
+
if (jsxMode && kitText === null && !assetsPending) {
|
|
364
|
+
return (_jsx(Note, { testID: "sandbox-no-kit", ...(title !== undefined ? { title } : {}), text: props.summary ?? "An interactive view that needs the app's components." }));
|
|
365
|
+
}
|
|
366
|
+
if (phase === 'placeholder') {
|
|
367
|
+
const state = { height: initial, messages, ...(title !== undefined ? { title } : {}) };
|
|
368
|
+
return (_jsx(_Fragment, { children: options.placeholder ? options.placeholder(state) : _jsx(DefaultPlaceholder, { ...state }) }));
|
|
369
|
+
}
|
|
370
|
+
return (_createElement(SandboxWebView, { ...NATIVE_SANDBOX_WEBVIEW_PROPS, ref: web, key: `${documentPhase}:${generation}`, testID: "sandbox-frame", accessibilityLabel: title ?? 'Interactive view', source: source, onMessage: onMessage, onNavigationStateChange: onNavigation, onRenderProcessGone: onProcessGone, onContentProcessDidTerminate: onProcessGone, style: [{ width: '100%', height, backgroundColor: 'transparent' }, options.style] }));
|
|
371
|
+
}
|
|
372
|
+
return NativeSandboxView;
|
|
373
|
+
}
|
|
374
|
+
/** The native sandbox renderer with its defaults (theme from nothing, no Tailwind, no kit). */
|
|
375
|
+
export const NativeSandboxView = createNativeSandboxRenderer();
|
|
376
|
+
//# sourceMappingURL=sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../../../src/react-native/genui/sandbox.tsx"],"names":[],"mappings":";;AACA,OAAO,EAIL,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAkB,IAAI,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AAC1E,OAAO,EACL,OAAO,GAIR,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,eAAe,EAGf,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAGL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EAEjB,cAAc,EACd,iBAAiB,EAEjB,YAAY,EACZ,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AA6C3B;;;;;;GAM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}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.76.0",
|
|
4
4
|
"description": "Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -247,6 +247,11 @@
|
|
|
247
247
|
"types": "./dist/src/react/genui/server_playwright.d.ts",
|
|
248
248
|
"import": "./dist/src/react/genui/server_playwright.js",
|
|
249
249
|
"default": "./dist/src/react/genui/server_playwright.js"
|
|
250
|
+
},
|
|
251
|
+
"./react-native/genui": {
|
|
252
|
+
"types": "./dist/src/react-native/genui/index.d.ts",
|
|
253
|
+
"import": "./dist/src/react-native/genui/index.js",
|
|
254
|
+
"default": "./dist/src/react-native/genui/index.js"
|
|
250
255
|
}
|
|
251
256
|
},
|
|
252
257
|
"files": [
|
|
@@ -287,6 +292,8 @@
|
|
|
287
292
|
"react": "^18.0.0 || ^19.0.0",
|
|
288
293
|
"react-dom": ">=18",
|
|
289
294
|
"react-markdown": "^10.1.0",
|
|
295
|
+
"react-native": ">=0.74",
|
|
296
|
+
"react-native-webview": ">=13",
|
|
290
297
|
"rehype-katex": "^7.0.1",
|
|
291
298
|
"rehype-sanitize": "^6.0.0",
|
|
292
299
|
"remark-gfm": "^4.0.1",
|
|
@@ -396,6 +403,12 @@
|
|
|
396
403
|
},
|
|
397
404
|
"typescript": {
|
|
398
405
|
"optional": true
|
|
406
|
+
},
|
|
407
|
+
"react-native": {
|
|
408
|
+
"optional": true
|
|
409
|
+
},
|
|
410
|
+
"react-native-webview": {
|
|
411
|
+
"optional": true
|
|
399
412
|
}
|
|
400
413
|
},
|
|
401
414
|
"devDependencies": {
|
|
@@ -454,6 +467,8 @@
|
|
|
454
467
|
"react": "19.3.0",
|
|
455
468
|
"react-dom": "19.3.0",
|
|
456
469
|
"react-markdown": "10.1.0",
|
|
470
|
+
"react-native": "0.87.1",
|
|
471
|
+
"react-native-webview": "14.0.1",
|
|
457
472
|
"rehype-katex": "7.0.1",
|
|
458
473
|
"rehype-sanitize": "6.0.0",
|
|
459
474
|
"remark-gfm": "4.0.1",
|