ain-ui 0.2.3 → 1.0.3
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/NOTICE +37 -0
- package/README.md +179 -77
- package/dist/agent.d.ts +131 -0
- package/dist/agent.js +802 -0
- package/dist/ainui.d.ts +15 -1
- package/dist/ainui.js +48 -10
- package/dist/basic.d.ts +5 -47
- package/dist/basic.js +11 -25
- package/dist/catalog/standard.gen.d.ts +5 -0
- package/dist/catalog/standard.gen.js +6 -0
- package/dist/catalog-v1.json +2560 -0
- package/dist/catalog.json +19917 -2061
- package/dist/chat.js +6 -7
- package/dist/expression.d.ts +23 -0
- package/dist/expression.js +222 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/macros.d.ts +12 -0
- package/dist/macros.js +57 -0
- package/dist/payment.js +6 -7
- package/dist/pickers.d.ts +158 -0
- package/dist/pickers.js +110 -0
- package/dist/protocol.d.ts +100 -0
- package/dist/protocol.js +232 -0
- package/dist/react/ain.d.ts +1 -0
- package/dist/react/ain.js +225 -0
- package/dist/react/catalog.d.ts +9 -0
- package/dist/react/catalog.js +23 -0
- package/dist/react/core.d.ts +84 -0
- package/dist/react/core.js +158 -0
- package/dist/react/functions.d.ts +2 -0
- package/dist/react/functions.js +29 -0
- package/dist/react/standard/composites.d.ts +1 -0
- package/dist/react/standard/composites.js +110 -0
- package/dist/react/standard/data.d.ts +1 -0
- package/dist/react/standard/data.js +481 -0
- package/dist/react/standard/feedback.d.ts +11 -0
- package/dist/react/standard/feedback.js +111 -0
- package/dist/react/standard/inputs.d.ts +5 -0
- package/dist/react/standard/inputs.js +467 -0
- package/dist/react/standard/layout.d.ts +5 -0
- package/dist/react/standard/layout.js +104 -0
- package/dist/react/standard/media.d.ts +33 -0
- package/dist/react/standard/media.js +208 -0
- package/dist/react/standard/rich.d.ts +1 -0
- package/dist/react/standard/rich.js +146 -0
- package/dist/react/standard/text.d.ts +9 -0
- package/dist/react/standard/text.js +209 -0
- package/dist/react/surface.d.ts +44 -0
- package/dist/react/surface.js +134 -0
- package/dist/react.d.ts +3 -35
- package/dist/react.js +3 -272
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.js +299 -4
- package/dist/styles.css +805 -20
- package/package.json +28 -11
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type A2uiAction, type A2uiMessage } from "../protocol.js";
|
|
3
|
+
import { type ChatUpdate, type FolderChatAgent } from "../chat.js";
|
|
4
|
+
import { type AssetResolver, type FileViewRenderer } from "./core.js";
|
|
5
|
+
/**
|
|
6
|
+
* What this renderer can draw, in the form an agent reads it (`a2uiRendererCapabilities`): the catalog ids, and
|
|
7
|
+
* with `inline` the catalogs themselves so an agent that has never seen AIN-UI can still write for it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ainuiCapabilities(options?: {
|
|
10
|
+
inline?: boolean;
|
|
11
|
+
}): Record<string, unknown>;
|
|
12
|
+
export type AinuiSurfaceProps = {
|
|
13
|
+
/** A2UI messages, 1.0 or v0.9. Appending to the list updates the surfaces in place; any other change redraws. */
|
|
14
|
+
messages: readonly A2uiMessage[];
|
|
15
|
+
onAction: (action: A2uiAction) => void | Promise<void>;
|
|
16
|
+
/** Every renderer→agent message as the 1.0 envelope: actions, errors, function calls and responses. */
|
|
17
|
+
onMessage?: (message: Record<string, unknown>) => void;
|
|
18
|
+
onError?: (error: Error) => void;
|
|
19
|
+
resolveAsset?: AssetResolver;
|
|
20
|
+
renderFile?: FileViewRenderer;
|
|
21
|
+
/** A follow-up suggestion was chosen: send its text as the user's next message. */
|
|
22
|
+
sendMessage?: (text: string) => void;
|
|
23
|
+
openUrl?: (href: string) => void;
|
|
24
|
+
/** Design system: "ain" (default), "plain" or "material", or any name the host styles via `[data-ainui-theme]`. */
|
|
25
|
+
theme?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function AinuiSurface({ messages, onAction, onMessage, onError, resolveAsset, renderFile, sendMessage, openUrl, theme, className }: AinuiSurfaceProps): React.JSX.Element;
|
|
29
|
+
export type FolderChatSend = (turn: {
|
|
30
|
+
q: string;
|
|
31
|
+
agentId: string;
|
|
32
|
+
contextId?: string;
|
|
33
|
+
signal: AbortSignal;
|
|
34
|
+
onUpdate: (update: ChatUpdate) => void;
|
|
35
|
+
}) => Promise<ChatUpdate>;
|
|
36
|
+
/** Scope changes unmount the old chat, abort its request and drop its context ids. */
|
|
37
|
+
export declare function AinuiFolderChat(props: {
|
|
38
|
+
driveId: string;
|
|
39
|
+
path: string;
|
|
40
|
+
agents: FolderChatAgent[];
|
|
41
|
+
onSend: FolderChatSend;
|
|
42
|
+
theme?: string;
|
|
43
|
+
className?: string;
|
|
44
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { A2uiSurface, MarkdownContext } from "@a2ui/react";
|
|
5
|
+
import { MessageProcessor, STRICT_VALIDATION } from "@a2ui/web_core";
|
|
6
|
+
import { basicCatalog, injectBasicCatalogStyles } from "@a2ui/web_core/catalogs/basic/v1";
|
|
7
|
+
import { renderMarkdown } from "@a2ui/markdown-it";
|
|
8
|
+
import { upgradeMessages } from "../protocol.js";
|
|
9
|
+
import { ainuiFolderChat } from "../chat.js";
|
|
10
|
+
import { ainuiCatalog } from "./catalog.js";
|
|
11
|
+
import { HostContext } from "./core.js";
|
|
12
|
+
const catalogs = [ainuiCatalog, basicCatalog];
|
|
13
|
+
/**
|
|
14
|
+
* What this renderer can draw, in the form an agent reads it (`a2uiRendererCapabilities`): the catalog ids, and
|
|
15
|
+
* with `inline` the catalogs themselves so an agent that has never seen AIN-UI can still write for it.
|
|
16
|
+
*/
|
|
17
|
+
export function ainuiCapabilities(options = {}) {
|
|
18
|
+
const p = new MessageProcessor(catalogs);
|
|
19
|
+
try {
|
|
20
|
+
return p.getRendererCapabilities({ versions: ["1.0"], includeInlineCatalogs: !!options.inline });
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
p.dispose?.();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function AinuiSurface({ messages, onAction, onMessage, onError, resolveAsset, renderFile, sendMessage, openUrl, theme, className }) {
|
|
27
|
+
const handlers = useRef({ onAction, onMessage, onError });
|
|
28
|
+
handlers.current = { onAction, onMessage, onError };
|
|
29
|
+
const live = useRef(null);
|
|
30
|
+
const [state, setState] = useState({ processor: null, error: "", tick: 0 });
|
|
31
|
+
useEffect(() => { injectBasicCatalogStyles?.(); }, []);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const fail = (e) => { const error = e instanceof Error ? e : new Error(String(e)); handlers.current.onError?.(error); return error.message; };
|
|
34
|
+
const current = live.current;
|
|
35
|
+
const appended = current && messages.length >= current.seen.length && current.seen.every((m, i) => m === messages[i]);
|
|
36
|
+
if (current && appended) {
|
|
37
|
+
// The same conversation grew: apply only what is new, so the surface keeps its state (inputs, scroll, tabs).
|
|
38
|
+
const tail = messages.slice(current.seen.length);
|
|
39
|
+
current.seen = messages;
|
|
40
|
+
if (!tail.length)
|
|
41
|
+
return;
|
|
42
|
+
try {
|
|
43
|
+
current.processor.processMessages(upgradeMessages(tail));
|
|
44
|
+
setState((s) => ({ ...s, error: "", tick: s.tick + 1 }));
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
setState((s) => ({ ...s, error: fail(e) }));
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
current?.processor.dispose?.();
|
|
52
|
+
const processor = new MessageProcessor(catalogs, undefined, {
|
|
53
|
+
version: "1.0",
|
|
54
|
+
// What an agent sent is checked against the catalog before it is drawn: a wrong component is an error
|
|
55
|
+
// the host hears about, not a blank space.
|
|
56
|
+
validationConfig: STRICT_VALIDATION,
|
|
57
|
+
unifiedOutbound: true,
|
|
58
|
+
outboundListener: (message) => {
|
|
59
|
+
handlers.current.onMessage?.(message);
|
|
60
|
+
const action = message.action;
|
|
61
|
+
if (action && typeof action.name === "string")
|
|
62
|
+
return handlers.current.onAction(action);
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
live.current = { processor, seen: messages };
|
|
66
|
+
try {
|
|
67
|
+
processor.processMessages(upgradeMessages(messages));
|
|
68
|
+
setState((s) => ({ processor, error: "", tick: s.tick + 1 }));
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
setState((s) => ({ processor: null, error: fail(e), tick: s.tick + 1 }));
|
|
72
|
+
}
|
|
73
|
+
}, [messages]);
|
|
74
|
+
useEffect(() => () => { live.current?.processor.dispose?.(); live.current = null; }, []);
|
|
75
|
+
const host = useMemo(() => ({ resolveAsset: resolveAsset ?? (() => ""), renderFile, sendMessage, openUrl }), [resolveAsset, renderFile, sendMessage, openUrl]);
|
|
76
|
+
const shell = `ain-ui${className ? ` ${className}` : ""}`;
|
|
77
|
+
if (state.error)
|
|
78
|
+
return _jsx("div", { className: shell, "data-ainui-theme": theme, role: "alert", children: state.error });
|
|
79
|
+
if (!state.processor)
|
|
80
|
+
return _jsx("div", { className: shell, "data-ainui-theme": theme, "aria-busy": "true" });
|
|
81
|
+
return _jsx(MarkdownContext.Provider, { value: renderMarkdown, children: _jsx(HostContext.Provider, { value: host, children: _jsx("div", { className: shell, "data-ainui-theme": theme, children: Array.from(state.processor.model.surfacesMap.values()).map((surface) => _jsx(A2uiSurface, { surface: surface }, surface.id)) }) }) });
|
|
82
|
+
}
|
|
83
|
+
/** Scope changes unmount the old chat, abort its request and drop its context ids. */
|
|
84
|
+
export function AinuiFolderChat(props) {
|
|
85
|
+
return _jsx(FolderChatSession, { ...props }, `${props.driveId}:${props.path}`);
|
|
86
|
+
}
|
|
87
|
+
function FolderChatSession({ driveId, path, agents, onSend, theme, className }) {
|
|
88
|
+
const [agentId, select] = useState(agents[0]?.id ?? "");
|
|
89
|
+
const [messages, setMessages] = useState([]);
|
|
90
|
+
const [busy, setBusy] = useState(false);
|
|
91
|
+
const pending = useRef(null);
|
|
92
|
+
const contexts = useRef(new Map());
|
|
93
|
+
useEffect(() => () => { pending.current?.abort(); pending.current = null; }, []);
|
|
94
|
+
const selected = agents.some(a => a.id === agentId) ? agentId : agents[0]?.id ?? "";
|
|
95
|
+
const surface = ainuiFolderChat({ driveId, path, agents, agentId: selected, messages, busy });
|
|
96
|
+
return _jsx(AinuiSurface, { messages: surface, theme: theme, className: className, onAction: async (action) => {
|
|
97
|
+
const c = action.context ?? {};
|
|
98
|
+
if (c.operation === "cancel") {
|
|
99
|
+
pending.current?.abort();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (c.operation === "select" && !pending.current) {
|
|
103
|
+
select(String(c.agentId));
|
|
104
|
+
setMessages([]);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (c.operation !== "send" || pending.current || typeof c.q !== "string" || !selected)
|
|
108
|
+
return;
|
|
109
|
+
const controller = new AbortController();
|
|
110
|
+
pending.current = controller;
|
|
111
|
+
setBusy(true);
|
|
112
|
+
setMessages(m => [...m.slice(-98), { role: "user", text: c.q }, { role: "agent", text: "" }]);
|
|
113
|
+
const onUpdate = (u) => {
|
|
114
|
+
if (pending.current !== controller || controller.signal.aborted)
|
|
115
|
+
return;
|
|
116
|
+
if (u.contextId)
|
|
117
|
+
contexts.current.set(selected, u.contextId);
|
|
118
|
+
setMessages(m => [...m.slice(0, -1), { role: "agent", text: u.text }]);
|
|
119
|
+
};
|
|
120
|
+
try {
|
|
121
|
+
onUpdate(await onSend({ q: c.q, agentId: selected, contextId: contexts.current.get(selected), signal: controller.signal, onUpdate }));
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
if (pending.current === controller)
|
|
125
|
+
setMessages(m => [...m, { role: "error", text: controller.signal.aborted ? "Stopped" : e.message }]);
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
if (pending.current === controller) {
|
|
129
|
+
pending.current = null;
|
|
130
|
+
setBusy(false);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
} });
|
|
134
|
+
}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { type FolderChatAgent, type ChatUpdate } from "./chat.js";
|
|
5
|
-
import type { A2uiAction, A2uiMessage } from "./basic.js";
|
|
6
|
-
export type AssetResolver = (asset: AssetRef["$asset"], options?: {
|
|
7
|
-
download?: boolean;
|
|
8
|
-
}) => string;
|
|
9
|
-
export type FileViewRenderer = (file: {
|
|
10
|
-
src: string;
|
|
11
|
-
download: string;
|
|
12
|
-
name: string;
|
|
13
|
-
mime: string;
|
|
14
|
-
size?: number;
|
|
15
|
-
}) => React.ReactNode;
|
|
16
|
-
export declare const ainuiCatalog: Catalog<import("@a2ui/react/v0_9").ReactComponentImplementation, import("@a2ui/web_core/v0_9").FunctionImplementation>;
|
|
17
|
-
export declare function AinuiSurface({ messages, onAction, resolveAsset, renderFile }: {
|
|
18
|
-
messages: A2uiMessage[];
|
|
19
|
-
onAction: (action: A2uiAction) => void | Promise<void>;
|
|
20
|
-
resolveAsset?: AssetResolver;
|
|
21
|
-
renderFile?: FileViewRenderer;
|
|
22
|
-
}): React.JSX.Element;
|
|
23
|
-
export type FolderChatSend = (turn: {
|
|
24
|
-
q: string;
|
|
25
|
-
agentId: string;
|
|
26
|
-
contextId?: string;
|
|
27
|
-
signal: AbortSignal;
|
|
28
|
-
onUpdate: (update: ChatUpdate) => void;
|
|
29
|
-
}) => Promise<ChatUpdate>;
|
|
30
|
-
export declare function AinuiFolderChat(props: {
|
|
31
|
-
driveId: string;
|
|
32
|
-
path: string;
|
|
33
|
-
agents: FolderChatAgent[];
|
|
34
|
-
onSend: FolderChatSend;
|
|
35
|
-
}): React.JSX.Element;
|
|
1
|
+
export { AinuiSurface, AinuiFolderChat, ainuiCapabilities, type AinuiSurfaceProps, type FolderChatSend } from "./react/surface.js";
|
|
2
|
+
export { ainuiCatalog, standardComponents, missingStandardViews, AINUI_INSTRUCTIONS } from "./react/catalog.js";
|
|
3
|
+
export { STANDARD, HostContext, useHost, standard, type AssetResolver, type FileViewRenderer, type Host, type ViewProps } from "./react/core.js";
|
package/dist/react.js
CHANGED
|
@@ -1,273 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Catalog, CommonSchemas, MessageProcessor } from "@a2ui/web_core/v0_9";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { renderMarkdown } from "@a2ui/markdown-it";
|
|
8
|
-
import { AINUI_CATALOG, AINUI_UPLOAD_MAX_BYTES } from "./ainui.js";
|
|
9
|
-
import { ainuiFolderChat } from "./chat.js";
|
|
10
|
-
const FileRenderer = createContext(undefined);
|
|
11
|
-
const Assets = createContext(() => "");
|
|
12
|
-
const box = { display: "flex", flexDirection: "column", gap: 8, minWidth: 0 };
|
|
13
|
-
const button = { padding: "8px 12px", border: "1px solid #8885", borderRadius: 8, color: "inherit", background: "transparent" };
|
|
14
|
-
function useValue(ctx, raw) {
|
|
15
|
-
const signal = useMemo(() => ctx.dataContext.resolveSignal(raw), [ctx, raw]);
|
|
16
|
-
return useSignalValue(signal);
|
|
17
|
-
}
|
|
18
|
-
function urlOf(value, resolver, download = false) {
|
|
19
|
-
const raw = value && typeof value === "object" && "$asset" in value
|
|
20
|
-
? resolver(value.$asset, { download }) : value;
|
|
21
|
-
if (typeof raw !== "string")
|
|
22
|
-
return "";
|
|
23
|
-
if (/^\/(?!\/)/.test(raw) || /^https?:\/\//i.test(raw) || /^blob:/i.test(raw))
|
|
24
|
-
return raw;
|
|
25
|
-
return "";
|
|
26
|
-
}
|
|
27
|
-
async function fire(ctx, extra = {}) {
|
|
28
|
-
const raw = ctx.componentModel.properties.action;
|
|
29
|
-
if (!raw)
|
|
30
|
-
return;
|
|
31
|
-
const action = ctx.dataContext.resolveAction(raw);
|
|
32
|
-
if (action?.event)
|
|
33
|
-
await ctx.dispatchAction({ event: { ...action.event, context: { ...action.event.context, ...extra } } });
|
|
34
|
-
}
|
|
35
|
-
// A2UI owns state, bindings, action validation and surface lifecycle. These
|
|
36
|
-
// implementations add only AIN-UI's component views to the official catalog.
|
|
37
|
-
const api = (name, shape) => ({ name, schema: z.object(shape).passthrough() });
|
|
38
|
-
const dynamic = z.union([CommonSchemas.DynamicValue, z.object({ $asset: z.object({
|
|
39
|
-
drive_id: z.string(), path: z.string(), variant: z.enum(["thumb", "original"]), mime: z.string(), v: z.number().optional(),
|
|
40
|
-
}) }), z.null()]).optional();
|
|
41
|
-
function Glyph({ kind }) {
|
|
42
|
-
const paths = { grid: "M3 3h6v6H3z M15 3h6v6h-6z M3 15h6v6H3z M15 15h6v6h-6z", list: "M8 5h13M8 12h13M8 19h13M3 5h.01M3 12h.01M3 19h.01", upload: "M12 16V3m-5 5 5-5 5 5M4 16v5h16v-5", folder: "M3 7V5h6l2 2h10v13H3z", file: "M5 3h9l5 5v13H5z M14 3v6h5" };
|
|
43
|
-
return _jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: paths[kind] }) });
|
|
44
|
-
}
|
|
45
|
-
const Toolbar = createBinderlessComponentImplementation(api("Toolbar", { children: CommonSchemas.ChildList }), ({ context, buildChild }) => {
|
|
46
|
-
const spec = context.componentModel.properties.children;
|
|
47
|
-
const rows = useValue(context, !Array.isArray(spec) && spec ? { path: spec.path } : []);
|
|
48
|
-
return _jsx("div", { className: "ainui-toolbar", children: Array.isArray(spec) ? spec.map(id => _jsx(React.Fragment, { children: buildChild(id) }, id)) :
|
|
49
|
-
(Array.isArray(rows) ? rows : []).map((_, i) => _jsx(React.Fragment, { children: buildChild(spec.componentId, `${spec.path}/${i}`) }, i)) });
|
|
50
|
-
});
|
|
51
|
-
const Grid = createBinderlessComponentImplementation(api("Grid", { children: CommonSchemas.ChildList, minItemWidth: z.number().optional(), gap: z.number().optional() }), ({ context, buildChild }) => {
|
|
52
|
-
const p = context.componentModel.properties;
|
|
53
|
-
const spec = p.children;
|
|
54
|
-
const rows = useValue(context, !Array.isArray(spec) && spec ? { path: spec.path } : []);
|
|
55
|
-
return _jsx("div", { className: "ainui-grid", style: { display: "grid", width: "100%", minWidth: 0, gridTemplateColumns: `repeat(auto-fill,minmax(min(100%,var(--ainui-tile-min,${Math.max(64, Number(p.minItemWidth) || 176)}px)),1fr))`, gap: Number(p.gap) || 20 }, children: Array.isArray(spec) ? spec.map((id) => _jsx(React.Fragment, { children: buildChild(id) }, id)) :
|
|
56
|
-
(Array.isArray(rows) ? rows : []).map((_, i) => _jsx(React.Fragment, { children: buildChild(spec.componentId, `${spec.path}/${i}`) }, i)) });
|
|
57
|
-
});
|
|
58
|
-
const Tile = createBinderlessComponentImplementation(api("Tile", { media: dynamic, label: dynamic, caption: dynamic, kind: dynamic, action: CommonSchemas.Action.optional() }), ({ context }) => {
|
|
59
|
-
const p = context.componentModel.properties;
|
|
60
|
-
const media = useValue(context, p.media);
|
|
61
|
-
const label = useValue(context, p.label);
|
|
62
|
-
const caption = useValue(context, p.caption);
|
|
63
|
-
const kind = useValue(context, p.kind);
|
|
64
|
-
const resolver = useContext(Assets);
|
|
65
|
-
const src = urlOf(media, resolver);
|
|
66
|
-
const [failed, setFailed] = useState(false);
|
|
67
|
-
useEffect(() => setFailed(false), [src]);
|
|
68
|
-
return _jsxs("button", { type: "button", className: "ainui-tile", onClick: () => void fire(context), children: [_jsx("span", { className: "ainui-tile-media", children: src && !failed ? _jsx("img", { src: src, alt: "", loading: "lazy", onError: () => setFailed(true) }) :
|
|
69
|
-
_jsx("span", { className: "ainui-tile-placeholder", children: _jsx(Glyph, { kind: kind === "folder" ? "folder" : "file" }) }) }), _jsx("span", { className: "ainui-tile-name", title: label, children: label }), _jsx("small", { className: "ainui-tile-caption", children: caption })] });
|
|
70
|
-
});
|
|
71
|
-
const FileView = createBinderlessComponentImplementation(api("FileView", { src: dynamic, name: dynamic, mime: dynamic, size: dynamic }), ({ context }) => {
|
|
72
|
-
const p = context.componentModel.properties;
|
|
73
|
-
const asset = useValue(context, p.src);
|
|
74
|
-
const name = useValue(context, p.name);
|
|
75
|
-
const mime = useValue(context, p.mime) || "";
|
|
76
|
-
const resolver = useContext(Assets);
|
|
77
|
-
const src = urlOf(asset, resolver);
|
|
78
|
-
const render = useContext(FileRenderer);
|
|
79
|
-
const size = useValue(context, p.size);
|
|
80
|
-
if (render && src)
|
|
81
|
-
return _jsx(_Fragment, { children: render({ src, download: urlOf(asset, resolver, true), name, mime, size }) });
|
|
82
|
-
return _jsxs("div", { style: box, children: [src && (mime.startsWith("image/") ? _jsx("img", { src: src, alt: name, style: { maxHeight: "70vh", objectFit: "contain" } }) :
|
|
83
|
-
mime.startsWith("video/") ? _jsx("video", { controls: true, src: src }) : mime.startsWith("audio/") ? _jsx("audio", { controls: true, src: src }) :
|
|
84
|
-
mime === "application/pdf" ? _jsx("iframe", { title: name, src: src, style: { height: "70vh", border: 0 } }) : null), _jsx("strong", { children: name }), _jsx("a", { href: urlOf(asset, resolver, true), download: name, children: "Download" })] });
|
|
85
|
-
});
|
|
86
|
-
const Breadcrumbs = createBinderlessComponentImplementation(api("Breadcrumbs", { items: dynamic, action: CommonSchemas.Action.optional() }), ({ context }) => {
|
|
87
|
-
const items = useValue(context, context.componentModel.properties.items) || [];
|
|
88
|
-
return _jsx("nav", { "aria-label": "Folder path", className: "ainui-breadcrumbs", children: items.map((item, i) => _jsxs(React.Fragment, { children: [i > 0 && _jsx("span", { className: "ainui-breadcrumb-separator", "aria-hidden": "true", children: "/" }), i === items.length - 1 ? _jsx("span", { "aria-current": "page", children: item.label }) :
|
|
89
|
-
_jsx("button", { onClick: () => void fire(context, { path: item.path }), children: item.label === "/" ? "Drive" : item.label })] }, i)) });
|
|
90
|
-
});
|
|
91
|
-
const Segmented = createBinderlessComponentImplementation(api("Segmented", { options: z.array(z.object({ value: z.string(), label: z.string() })), value: dynamic, action: CommonSchemas.Action.optional() }), ({ context }) => {
|
|
92
|
-
const p = context.componentModel.properties;
|
|
93
|
-
const value = useValue(context, p.value);
|
|
94
|
-
return _jsx("div", { role: "group", "aria-label": "View options", className: "ainui-segmented", children: p.options.map((o) => _jsxs("button", { type: "button", "aria-pressed": value === o.value, onClick: () => {
|
|
95
|
-
const binding = p.value;
|
|
96
|
-
if (binding?.path)
|
|
97
|
-
context.dataContext.set(binding.path, o.value);
|
|
98
|
-
void fire(context, { value: o.value });
|
|
99
|
-
}, children: [(o.value === "grid" || o.value === "list") && _jsx(Glyph, { kind: o.value }), _jsx("span", { children: o.label })] }, o.value)) });
|
|
100
|
-
});
|
|
101
|
-
const FileUpload = createBinderlessComponentImplementation(api("FileUpload", { label: dynamic, maxBytes: z.number().optional(), action: CommonSchemas.Action.optional() }), ({ context }) => {
|
|
102
|
-
const p = context.componentModel.properties;
|
|
103
|
-
const label = useValue(context, p.label) || "Upload file";
|
|
104
|
-
const [busy, setBusy] = useState(false);
|
|
105
|
-
const [error, setError] = useState("");
|
|
106
|
-
const input = useRef(null);
|
|
107
|
-
const limit = Math.min(Number(p.maxBytes) || AINUI_UPLOAD_MAX_BYTES, AINUI_UPLOAD_MAX_BYTES);
|
|
108
|
-
return _jsxs("div", { className: "ainui-upload", children: [_jsxs("button", { className: "ainui-button ainui-button-primary", type: "button", disabled: busy, onClick: () => input.current?.click(), children: [_jsx(Glyph, { kind: "upload" }), busy ? "Uploading…" : label] }), _jsx("input", { ref: input, hidden: true, tabIndex: -1, "aria-label": label, type: "file", disabled: busy, onChange: async (e) => {
|
|
109
|
-
const file = e.target.files?.[0];
|
|
110
|
-
e.target.value = "";
|
|
111
|
-
if (!file)
|
|
112
|
-
return;
|
|
113
|
-
if (file.size > limit) {
|
|
114
|
-
setError(`Maximum file size: ${limit / 1024 / 1024} MiB`);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
setBusy(true);
|
|
118
|
-
setError("");
|
|
119
|
-
try {
|
|
120
|
-
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
121
|
-
let binary = "";
|
|
122
|
-
for (let i = 0; i < bytes.length; i += 8192)
|
|
123
|
-
binary += String.fromCharCode(...bytes.subarray(i, i + 8192));
|
|
124
|
-
await fire(context, { name: file.name, content: btoa(binary), encoding: "base64" });
|
|
125
|
-
}
|
|
126
|
-
catch (e) {
|
|
127
|
-
setError(e.message);
|
|
128
|
-
}
|
|
129
|
-
finally {
|
|
130
|
-
setBusy(false);
|
|
131
|
-
}
|
|
132
|
-
} }), busy && _jsx("span", { className: "ainui-sr-only", role: "status", children: "Uploading\u2026" }), error && _jsx("small", { role: "alert", children: error })] });
|
|
133
|
-
});
|
|
134
|
-
const X402Payment = createBinderlessComponentImplementation(api("X402Payment", { amount: dynamic, currency: dynamic, network: dynamic, payTo: dynamic, action: CommonSchemas.Action.optional() }), ({ context }) => {
|
|
135
|
-
const p = context.componentModel.properties;
|
|
136
|
-
const amount = useValue(context, p.amount);
|
|
137
|
-
const currency = useValue(context, p.currency);
|
|
138
|
-
const network = useValue(context, p.network);
|
|
139
|
-
const payTo = useValue(context, p.payTo);
|
|
140
|
-
const [busy, setBusy] = useState(false);
|
|
141
|
-
const [error, setError] = useState("");
|
|
142
|
-
return _jsxs("div", { style: box, children: [_jsxs("strong", { children: [amount, " ", currency] }), _jsxs("small", { children: ["Network: ", network] }), _jsxs("small", { style: { overflowWrap: "anywhere" }, children: ["To: ", payTo] }), _jsx("button", { style: button, disabled: busy, onClick: async () => {
|
|
143
|
-
if (busy)
|
|
144
|
-
return;
|
|
145
|
-
setBusy(true);
|
|
146
|
-
setError("");
|
|
147
|
-
try {
|
|
148
|
-
await fire(context);
|
|
149
|
-
}
|
|
150
|
-
catch (e) {
|
|
151
|
-
setError(e.message);
|
|
152
|
-
}
|
|
153
|
-
finally {
|
|
154
|
-
setBusy(false);
|
|
155
|
-
}
|
|
156
|
-
}, children: busy ? "Confirm in your wallet…" : `Pay ${amount} ${currency}` }), error && _jsx("small", { role: "alert", children: error })] });
|
|
157
|
-
});
|
|
158
|
-
const FolderChat = createBinderlessComponentImplementation(api("FolderChat", { value: dynamic, action: CommonSchemas.Action.optional() }), ({ context }) => {
|
|
159
|
-
const state = useValue(context, context.componentModel.properties.value);
|
|
160
|
-
const [input, setInput] = useState("");
|
|
161
|
-
if (!state)
|
|
162
|
-
return null;
|
|
163
|
-
return _jsxs("section", { "aria-label": "Folder chat", className: "ainui-chat", children: [_jsx("strong", { className: "ainui-chat-title", children: state.path.split("/").filter(Boolean).at(-1) || "Folder chat" }), _jsxs("label", { className: "ainui-chat-agent", children: ["Agent ", _jsx("select", { "aria-label": "Chat agent", disabled: state.busy, value: state.agentId, onChange: e => void fire(context, { operation: "select", agentId: e.target.value }), children: state.agents.map(a => _jsx("option", { value: a.id, children: a.label }, a.id)) })] }), _jsx("div", { role: "log", "aria-live": "polite", className: "ainui-chat-log", children: state.messages.map((m, i) => _jsxs("div", { role: m.role === "error" ? "alert" : undefined, className: `ainui-chat-message ainui-chat-message-${m.role}`, children: [_jsx("strong", { children: m.role === "user" ? "You" : m.role === "error" ? "Error" : state.agents.find(a => a.id === state.agentId)?.label || "Agent" }), m.role === "agent" ? _jsx(AgentText, { text: m.text }) : _jsx("div", { className: "ainui-chat-text", children: m.text })] }, i)) }), _jsxs("form", { onSubmit: e => { e.preventDefault(); if (input.trim() && !state.busy) {
|
|
164
|
-
void fire(context, { operation: "send", q: input.trim(), agentId: state.agentId });
|
|
165
|
-
setInput("");
|
|
166
|
-
} }, style: box, children: [_jsx("textarea", { "aria-label": "Message", placeholder: "Ask about the files in this folder\u2026", rows: 3, disabled: state.busy, value: input, onChange: e => setInput(e.target.value) }), state.busy ? _jsx("button", { type: "button", className: "ainui-button", onClick: () => void fire(context, { operation: "cancel" }), children: "Stop" }) : _jsx("button", { className: "ainui-button ainui-button-primary", disabled: !input.trim() || !state.agentId, children: "Send" })] })] });
|
|
167
|
-
});
|
|
168
|
-
// Preserve AIN-UI's confirmation extension on the basic Button.
|
|
169
|
-
const Button = createBinderlessComponentImplementation(api("Button", { child: CommonSchemas.ComponentId, action: CommonSchemas.Action.optional(), confirm: dynamic, variant: dynamic, tone: dynamic }), ({ context, buildChild }) => {
|
|
170
|
-
const p = context.componentModel.properties;
|
|
171
|
-
const confirm = useValue(context, p.confirm);
|
|
172
|
-
const variant = useValue(context, p.variant);
|
|
173
|
-
const tone = useValue(context, p.tone);
|
|
174
|
-
return _jsx("button", { className: `ainui-button ${variant === "primary" ? "ainui-button-primary" : variant === "borderless" ? "ainui-button-ghost" : ""} ${tone === "danger" ? "ainui-button-danger" : ""}`, onClick: () => { if (!confirm || window.confirm(confirm))
|
|
175
|
-
void fire(context); }, children: buildChild(String(p.child)) });
|
|
176
|
-
});
|
|
177
|
-
export const ainuiCatalog = new Catalog(AINUI_CATALOG, [...basicCatalog.components.values()].filter((c) => c.name !== "Button").concat([Button, Toolbar, Grid, Tile, FileView, Breadcrumbs, Segmented, FileUpload, X402Payment, FolderChat]), [...basicCatalog.functions.values()]);
|
|
178
|
-
export function AinuiSurface({ messages, onAction, resolveAsset, renderFile }) {
|
|
179
|
-
const handler = useRef(onAction);
|
|
180
|
-
handler.current = onAction;
|
|
181
|
-
const [processor, setProcessor] = useState(null);
|
|
182
|
-
const [error, setError] = useState("");
|
|
183
|
-
useEffect(() => {
|
|
184
|
-
const p = new MessageProcessor([ainuiCatalog, basicCatalog], (action) => handler.current(action));
|
|
185
|
-
try {
|
|
186
|
-
p.processMessages(messages);
|
|
187
|
-
setProcessor(p);
|
|
188
|
-
setError("");
|
|
189
|
-
}
|
|
190
|
-
catch (e) {
|
|
191
|
-
setProcessor(null);
|
|
192
|
-
setError(e.message);
|
|
193
|
-
}
|
|
194
|
-
return () => { for (const surface of p.model.surfacesMap.values())
|
|
195
|
-
surface.dispose(); };
|
|
196
|
-
}, [messages]);
|
|
197
|
-
if (error)
|
|
198
|
-
return _jsx("div", { className: "ain-ui", role: "alert", children: error });
|
|
199
|
-
if (!processor)
|
|
200
|
-
return _jsx("div", { className: "ain-ui", "aria-busy": "true" });
|
|
201
|
-
return _jsx(MarkdownContext.Provider, { value: renderMarkdown, children: _jsx(Assets.Provider, { value: resolveAsset ?? (() => ""), children: _jsx(FileRenderer.Provider, { value: renderFile, children: _jsx("div", { className: "ain-ui", children: Array.from(processor.model.surfacesMap.values()).map((surface) => _jsx(A2uiSurface, { surface: surface }, surface.id)) }) }) }) });
|
|
202
|
-
}
|
|
203
|
-
/** Scope changes unmount the old chat, abort its request and drop its context ids. */
|
|
204
|
-
/**
|
|
205
|
-
* An agent's message as Markdown — agents answer in it (headings, lists, tables, code). The same
|
|
206
|
-
* markdown-it the A2UI Text component uses (it sanitizes); the plain text shows until the render lands, so a
|
|
207
|
-
* streamed message never flickers to empty. A person's own message stays as typed.
|
|
208
|
-
*/
|
|
209
|
-
function AgentText({ text }) {
|
|
210
|
-
const [html, setHtml] = useState(null);
|
|
211
|
-
useEffect(() => {
|
|
212
|
-
let live = true;
|
|
213
|
-
// an empty render (no live DOM for the sanitizer, a failure) shows the text as typed rather than nothing
|
|
214
|
-
renderMarkdown(text).then(h => { if (live)
|
|
215
|
-
setHtml(h && h.trim() ? h : null); }).catch(() => { if (live)
|
|
216
|
-
setHtml(null); });
|
|
217
|
-
return () => { live = false; };
|
|
218
|
-
}, [text]);
|
|
219
|
-
return html == null
|
|
220
|
-
? _jsx("div", { className: "ainui-chat-text", children: text })
|
|
221
|
-
: _jsx("div", { className: "ainui-chat-text ainui-chat-markdown", dangerouslySetInnerHTML: { __html: html } });
|
|
222
|
-
}
|
|
223
|
-
export function AinuiFolderChat(props) {
|
|
224
|
-
return _jsx(FolderChatSession, { ...props }, `${props.driveId}:${props.path}`);
|
|
225
|
-
}
|
|
226
|
-
function FolderChatSession({ driveId, path, agents, onSend }) {
|
|
227
|
-
const [agentId, select] = useState(agents[0]?.id ?? "");
|
|
228
|
-
const [messages, setMessages] = useState([]);
|
|
229
|
-
const [busy, setBusy] = useState(false);
|
|
230
|
-
const pending = useRef(null);
|
|
231
|
-
const contexts = useRef(new Map());
|
|
232
|
-
useEffect(() => () => { pending.current?.abort(); pending.current = null; }, []);
|
|
233
|
-
const selected = agents.some(a => a.id === agentId) ? agentId : agents[0]?.id ?? "";
|
|
234
|
-
const surface = ainuiFolderChat({ driveId, path, agents, agentId: selected, messages, busy });
|
|
235
|
-
return _jsx(AinuiSurface, { messages: surface, onAction: async (action) => {
|
|
236
|
-
const c = action.context ?? {};
|
|
237
|
-
if (c.operation === "cancel") {
|
|
238
|
-
pending.current?.abort();
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
if (c.operation === "select" && !pending.current) {
|
|
242
|
-
select(String(c.agentId));
|
|
243
|
-
setMessages([]);
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (c.operation !== "send" || pending.current || typeof c.q !== "string" || !selected)
|
|
247
|
-
return;
|
|
248
|
-
const controller = new AbortController();
|
|
249
|
-
pending.current = controller;
|
|
250
|
-
setBusy(true);
|
|
251
|
-
setMessages(m => [...m.slice(-98), { role: "user", text: c.q }, { role: "agent", text: "" }]);
|
|
252
|
-
const onUpdate = (u) => {
|
|
253
|
-
if (pending.current !== controller || controller.signal.aborted)
|
|
254
|
-
return;
|
|
255
|
-
if (u.contextId)
|
|
256
|
-
contexts.current.set(selected, u.contextId);
|
|
257
|
-
setMessages(m => [...m.slice(0, -1), { role: "agent", text: u.text }]);
|
|
258
|
-
};
|
|
259
|
-
try {
|
|
260
|
-
onUpdate(await onSend({ q: c.q, agentId: selected, contextId: contexts.current.get(selected), signal: controller.signal, onUpdate }));
|
|
261
|
-
}
|
|
262
|
-
catch (e) {
|
|
263
|
-
if (pending.current === controller)
|
|
264
|
-
setMessages(m => [...m, { role: "error", text: controller.signal.aborted ? "Stopped" : e.message }]);
|
|
265
|
-
}
|
|
266
|
-
finally {
|
|
267
|
-
if (pending.current === controller) {
|
|
268
|
-
pending.current = null;
|
|
269
|
-
setBusy(false);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
} });
|
|
273
|
-
}
|
|
2
|
+
export { AinuiSurface, AinuiFolderChat, ainuiCapabilities } from "./react/surface.js";
|
|
3
|
+
export { ainuiCatalog, standardComponents, missingStandardViews, AINUI_INSTRUCTIONS } from "./react/catalog.js";
|
|
4
|
+
export { STANDARD, HostContext, useHost, standard } from "./react/core.js";
|
package/dist/renderer.d.ts
CHANGED
|
@@ -31,4 +31,4 @@ export function createA2uiRenderer(container: HTMLElement, { onAction, resolveAs
|
|
|
31
31
|
replace: (messages: any) => void;
|
|
32
32
|
surfaces: Map<any, any>;
|
|
33
33
|
};
|
|
34
|
-
export const A2UI_RENDERER_CSS: "\n.a2ui-surface{font:14px/1.5 system-ui,-apple-system,\"Segoe UI\",sans-serif;color:#0f1319}\n.a2ui-column,.a2ui-row,.a2ui-list{display:flex;gap:8px}\n.a2ui-list{gap:2px}\n.a2ui-card{border:1px solid #dce3ec;border-radius:12px;padding:12px;background:#fff;overflow:auto;max-height:480px}\n.a2ui-text p,.a2ui-text ul,.a2ui-text ol{margin:0 0 6px}.a2ui-text ul{list-style:disc;padding-left:20px}.a2ui-text ol{list-style:decimal;padding-left:20px}.a2ui-text h1,.a2ui-text h2,.a2ui-text h3{margin:4px 0}\n.a2ui-text-h1{font-size:24px;font-weight:600}.a2ui-text-h2{font-size:20px;font-weight:600}.a2ui-text-h3{font-size:16px;font-weight:600}\n.a2ui-text-caption{font-size:12px;color:#54607a}.a2ui-text-caption p{margin:0}\n.a2ui-text pre{background:#f2f5f9;padding:8px;border-radius:8px;overflow:auto;white-space:pre-wrap;word-break:break-word}\n.a2ui-button{font:inherit;border:1px solid #dce3ec;background:#fff;border-radius:999px;padding:4px 12px;cursor:pointer}\n.a2ui-button:hover{background:#eaeef4}\n.a2ui-button-primary{background:#0b57d0;border-color:#0b57d0;color:#fff}.a2ui-button-primary:hover{background:#0842a0}\n.a2ui-button-borderless{border:0;background:none;padding:2px 4px;text-align:left}.a2ui-button-borderless:hover{background:#eaeef4}\n.a2ui-button .a2ui-text p{margin:0}\n.a2ui-textfield{display:flex;flex-direction:column;flex:1}.a2ui-textfield span{display:none}\n.a2ui-textfield input{font:inherit;border:1px solid #dce3ec;border-radius:999px;padding:4px 12px;min-width:120px}\n.a2ui-image{max-width:100%;max-height:420px;object-fit:contain}\n.a2ui-divider{border-top:1px solid #dce3ec;margin:4px 0}\n.a2ui-row .a2ui-text-caption{white-space:nowrap}\n.a2ui-button-danger{color:#b3261e;border-color:#f2b8b5}.a2ui-button-danger.a2ui-button-primary,.a2ui-confirm .a2ui-button-danger{background:#b3261e;border-color:#b3261e;color:#fff}\n.a2ui-confirm{display:inline-flex;flex-wrap:wrap;align-items:center;gap:6px}\n.a2ui-text-mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:13px}\n.a2ui-textfield-long{min-width:0}.a2ui-textfield-long textarea{font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;border:1px solid #dce3ec;border-radius:12px;padding:8px 12px;resize:vertical;min-height:240px;width:100%;box-sizing:border-box}\n.a2ui-row{flex-wrap:wrap}\n.a2ui-grid{display:grid}\n.a2ui-tile-wrap{min-width:0}\n.a2ui-tile{display:flex;flex-direction:column;gap:4px;width:100%;font:inherit;color:inherit;text-align:left;border:0;background:none;padding:4px;border-radius:12px;cursor:pointer}\n.a2ui-tile:hover,.a2ui-tile:focus-visible{background:#eaeef4}\n.a2ui-tile-media{display:flex;align-items:center;justify-content:center;aspect-ratio:1;width:100%;border-radius:10px;overflow:hidden;background:#f2f5f9}\n.a2ui-tile-media img{width:100%;height:100%;object-fit:cover}\n.a2ui-tile-media .a2ui-kind-icon{font-size:40px}\n.a2ui-tile-label{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.a2ui-tile-caption{font-size:12px;color:#54607a;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.a2ui-fileview{display:flex;flex-direction:column;gap:8px}\n.a2ui-fileview-img,.a2ui-fileview-video{max-width:100%;max-height:70vh;object-fit:contain;border-radius:10px;background:#f2f5f9}\n.a2ui-fileview-audio{width:100%}\n.a2ui-fileview-icon{display:flex;align-items:center;justify-content:center;height:160px;border-radius:10px;background:#f2f5f9;font-size:56px}\n.a2ui-fileview-info{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap}.a2ui-fileview-name{font-weight:600;word-break:break-all}\n.a2ui-fileview-download{display:inline-flex;align-items:center;min-height:36px;box-sizing:border-box;margin-left:auto;color:inherit;text-decoration:none}\n.a2ui-breadcrumbs{display:flex;flex-wrap:wrap;align-items:center;gap:2px;font-size:13px}\n.a2ui-crumb{display:inline-flex;align-items:center;font:inherit;color:#0b57d0;border:0;background:none;padding:0 6px;border-radius:8px;cursor:pointer;min-height:36px;box-sizing:border-box}\n.a2ui-crumb:hover{background:#eaeef4}.a2ui-crumb-current{color:inherit;font-weight:600;cursor:default}\n.a2ui-crumb-sep{color:#54607a}\n.a2ui-segmented{display:inline-flex;border:1px solid #dce3ec;border-radius:999px;overflow:hidden}\n.a2ui-segment{font:inherit;border:0;background:#fff;color:inherit;padding:4px 14px;cursor:pointer;min-height:36px}\n.a2ui-segment[aria-pressed=true]{background:#0b57d0;color:#fff}\n@media (prefers-color-scheme:dark){.a2ui-surface{color:#e6e9ef}.a2ui-card,.a2ui-button,.a2ui-textfield input,.a2ui-textfield textarea,.a2ui-segment{background:#1b1f27;border-color:#343b48;color:inherit}.a2ui-segmented{border-color:#343b48}.a2ui-segment[aria-pressed=true]{background:#0b57d0;color:#fff}.a2ui-button:hover,.a2ui-button-borderless:hover,.a2ui-tile:hover,.a2ui-crumb:hover{background:#262c36}.a2ui-text pre,.a2ui-tile-media,.a2ui-fileview-icon,.a2ui-fileview-img,.a2ui-fileview-video{background:#262c36}.a2ui-text-caption,.a2ui-tile-caption,.a2ui-crumb-sep{color:#9aa4b8}.a2ui-crumb{color:#a8c7fa}.a2ui-button-danger{color:#f2b8b5;border-color:#8c1d18}}\n";
|
|
34
|
+
export const A2UI_RENDERER_CSS: "\n.a2ui-surface{font:14px/1.5 system-ui,-apple-system,\"Segoe UI\",sans-serif;color:#0f1319}\n.a2ui-column,.a2ui-row,.a2ui-list{display:flex;gap:8px}\n.a2ui-list{gap:2px}\n.a2ui-card{border:1px solid #dce3ec;border-radius:12px;padding:12px;background:#fff;overflow:auto;max-height:480px}\n.a2ui-text p,.a2ui-text ul,.a2ui-text ol{margin:0 0 6px}.a2ui-text ul{list-style:disc;padding-left:20px}.a2ui-text ol{list-style:decimal;padding-left:20px}.a2ui-text h1,.a2ui-text h2,.a2ui-text h3{margin:4px 0}\n.a2ui-text-h1{font-size:24px;font-weight:600}.a2ui-text-h2{font-size:20px;font-weight:600}.a2ui-text-h3{font-size:16px;font-weight:600}\n.a2ui-text-caption{font-size:12px;color:#54607a}.a2ui-text-caption p{margin:0}\n.a2ui-text pre{background:#f2f5f9;padding:8px;border-radius:8px;overflow:auto;white-space:pre-wrap;word-break:break-word}\n.a2ui-button{font:inherit;border:1px solid #dce3ec;background:#fff;border-radius:999px;padding:4px 12px;cursor:pointer}\n.a2ui-button:hover{background:#eaeef4}\n.a2ui-button-primary{background:#0b57d0;border-color:#0b57d0;color:#fff}.a2ui-button-primary:hover{background:#0842a0}\n.a2ui-button-borderless{border:0;background:none;padding:2px 4px;text-align:left}.a2ui-button-borderless:hover{background:#eaeef4}\n.a2ui-button .a2ui-text p{margin:0}\n.a2ui-textfield{display:flex;flex-direction:column;flex:1}.a2ui-textfield span{display:none}\n.a2ui-textfield input{font:inherit;border:1px solid #dce3ec;border-radius:999px;padding:4px 12px;min-width:120px}\n.a2ui-image{max-width:100%;max-height:420px;object-fit:contain}\n.a2ui-divider{border-top:1px solid #dce3ec;margin:4px 0}\n.a2ui-row .a2ui-text-caption{white-space:nowrap}\n.a2ui-button-danger{color:#b3261e;border-color:#f2b8b5}.a2ui-button-danger.a2ui-button-primary,.a2ui-confirm .a2ui-button-danger{background:#b3261e;border-color:#b3261e;color:#fff}\n.a2ui-confirm{display:inline-flex;flex-wrap:wrap;align-items:center;gap:6px}\n.a2ui-text-mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:13px}\n.a2ui-textfield-long{min-width:0}.a2ui-textfield-long textarea{font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;border:1px solid #dce3ec;border-radius:12px;padding:8px 12px;resize:vertical;min-height:240px;width:100%;box-sizing:border-box}\n.a2ui-row{flex-wrap:wrap}\n.a2ui-grid{display:grid}\n.a2ui-tile-wrap{min-width:0}\n.a2ui-tile{display:flex;flex-direction:column;gap:4px;width:100%;font:inherit;color:inherit;text-align:left;border:0;background:none;padding:4px;border-radius:12px;cursor:pointer}\n.a2ui-tile:hover,.a2ui-tile:focus-visible{background:#eaeef4}\n.a2ui-tile-media{display:flex;align-items:center;justify-content:center;aspect-ratio:1;width:100%;border-radius:10px;overflow:hidden;background:#f2f5f9}\n.a2ui-tile-media img{width:100%;height:100%;object-fit:cover}\n.a2ui-tile-media .a2ui-kind-icon{font-size:40px}\n.a2ui-tile-label{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.a2ui-tile-caption{font-size:12px;color:#54607a;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.a2ui-fileview{display:flex;flex-direction:column;gap:8px}\n.a2ui-fileview-img,.a2ui-fileview-video{max-width:100%;max-height:70vh;object-fit:contain;border-radius:10px;background:#f2f5f9}\n.a2ui-fileview-audio{width:100%}\n.a2ui-fileview-icon{display:flex;align-items:center;justify-content:center;height:160px;border-radius:10px;background:#f2f5f9;font-size:56px}\n.a2ui-fileview-info{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap}.a2ui-fileview-name{font-weight:600;word-break:break-all}\n.a2ui-fileview-download{display:inline-flex;align-items:center;min-height:36px;box-sizing:border-box;margin-left:auto;color:inherit;text-decoration:none}\n.a2ui-breadcrumbs{display:flex;flex-wrap:wrap;align-items:center;gap:2px;font-size:13px}\n.a2ui-crumb{display:inline-flex;align-items:center;font:inherit;color:#0b57d0;border:0;background:none;padding:0 6px;border-radius:8px;cursor:pointer;min-height:36px;box-sizing:border-box}\n.a2ui-crumb:hover{background:#eaeef4}.a2ui-crumb-current{color:inherit;font-weight:600;cursor:default}\n.a2ui-crumb-sep{color:#54607a}\n.a2ui-segmented{display:inline-flex;border:1px solid #dce3ec;border-radius:999px;overflow:hidden}\n.a2ui-segment{font:inherit;border:0;background:#fff;color:inherit;padding:4px 14px;cursor:pointer;min-height:36px}\n.a2ui-segment[aria-pressed=true]{background:#0b57d0;color:#fff}\n.ainui-picker{display:flex;flex-direction:column;gap:10px;min-width:0}\n.ainui-picker-scopes{display:flex;flex-wrap:wrap;gap:4px;padding:3px;border:1px solid #dce3ec;border-radius:10px;background:#f2f5f9}\n.ainui-picker-scope{font:inherit;border:0;border-radius:7px;background:transparent;color:#54607a;padding:6px 12px;min-height:36px;cursor:pointer}\n.ainui-picker-scope[aria-selected=true]{background:#fff;color:inherit;box-shadow:0 1px 3px #00000014}\n.ainui-picker-search{display:flex;gap:6px}.ainui-picker-search input{flex:1;min-width:0;font:inherit;border:1px solid #dce3ec;border-radius:999px;padding:6px 12px}\n.ainui-picker-asof{display:flex;flex-wrap:wrap;gap:8px;align-items:center;font-size:12px;color:#54607a}\n.ainui-picker-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}\n.ainui-picker-row{display:flex;align-items:center;gap:10px;padding:8px;border-radius:10px}\n.ainui-picker-row:hover{background:#eaeef4}.ainui-picker-row-selected{background:#e3ecfb}\n.ainui-picker-row-unavailable .ainui-picker-main{opacity:.55}\n.ainui-picker-icon{font-size:22px}.ainui-picker-main{display:flex;flex:1;flex-direction:column;gap:3px;min-width:0}\n.ainui-picker-name{font-weight:600;overflow-wrap:anywhere}.ainui-picker-description{font-size:13px;color:#54607a}\n.ainui-picker-meta{display:flex;flex-wrap:wrap;gap:4px}\n.ainui-picker-badge{font-size:11px;line-height:18px;padding:0 7px;border-radius:999px;background:#eaeef4;color:inherit}\n.ainui-picker-badge-muted{background:transparent;border:1px solid #dce3ec;color:#54607a}.ainui-picker-badge-warn{background:#fff3cd;color:#7a4b00}.ainui-picker-badge-danger{background:#fde7e6;color:#8c1d18}\n.ainui-picker-capabilities{display:flex;flex-wrap:wrap;gap:8px;font-size:12px;color:#54607a}.ainui-picker-fallbacks{color:#7a4b00}\n.ainui-picker-reason{font-size:12px;color:#8c1d18;opacity:1}\n.ainui-picker-actions{display:flex;flex-direction:column;gap:4px;flex:0 0 auto}\n.ainui-picker-footer{display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between}.ainui-picker-footer:empty{display:none}\n.ainui-picker-empty{margin:0;color:#54607a}\n@media (max-width:600px){.ainui-picker-row{flex-wrap:wrap}.ainui-picker-actions{flex-direction:row;width:100%;justify-content:flex-end}}\n@media (prefers-color-scheme:dark){.ainui-picker-scopes{background:#1b1f27;border-color:#343b48}.ainui-picker-scope[aria-selected=true]{background:#262c36}.ainui-picker-search input{background:#1b1f27;border-color:#343b48;color:inherit}.ainui-picker-row:hover{background:#262c36}.ainui-picker-row-selected{background:#1e2a44}.ainui-picker-badge{background:#262c36}.ainui-picker-badge-muted{border-color:#343b48;color:#9aa4b8}.ainui-picker-badge-warn{background:#4a3200;color:#ffd77a}.ainui-picker-badge-danger{background:#4a1512;color:#f2b8b5}.ainui-picker-reason{color:#f2b8b5}.ainui-picker-fallbacks{color:#ffd77a}}\n@media (prefers-color-scheme:dark){.a2ui-surface{color:#e6e9ef}.a2ui-card,.a2ui-button,.a2ui-textfield input,.a2ui-textfield textarea,.a2ui-segment{background:#1b1f27;border-color:#343b48;color:inherit}.a2ui-segmented{border-color:#343b48}.a2ui-segment[aria-pressed=true]{background:#0b57d0;color:#fff}.a2ui-button:hover,.a2ui-button-borderless:hover,.a2ui-tile:hover,.a2ui-crumb:hover{background:#262c36}.a2ui-text pre,.a2ui-tile-media,.a2ui-fileview-icon,.a2ui-fileview-img,.a2ui-fileview-video{background:#262c36}.a2ui-text-caption,.a2ui-tile-caption,.a2ui-crumb-sep{color:#9aa4b8}.a2ui-crumb{color:#a8c7fa}.a2ui-button-danger{color:#f2b8b5;border-color:#8c1d18}}\n";
|