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
package/dist/renderer.js
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* surfaces render anywhere without a build step.
|
|
11
11
|
*
|
|
12
12
|
* AINUI (docs/AINUI.md, catalog AINUI_CATALOG in ./ainui.ts) is understood too:
|
|
13
|
-
* Grid, Tile, FileView, Breadcrumbs, Segmented,
|
|
13
|
+
* Grid, Tile, FileView, Breadcrumbs, Segmented, FilePicker, AgentPicker
|
|
14
|
+
* (the same `ainui.picker.*` payloads as ain-ui/react), Button `tone`/`confirm`,
|
|
14
15
|
* Text `mono`, TextField `longText`, and `{$asset}` references, resolved by
|
|
15
16
|
* `opts.resolveAsset(asset)` or — by default — through aindrive's own routes
|
|
16
17
|
* (`{assetBase}/api/drives/{drive_id}/fs/thumbnail|stream?path=…`), which only
|
|
@@ -18,10 +19,46 @@
|
|
|
18
19
|
* `opts.resolveAsset({...asset, variant: "original"}, { download: true })`
|
|
19
20
|
* (default: `fs/download`). Unknown components draw their children, else nothing.
|
|
20
21
|
*
|
|
21
|
-
* Plain ES module, browser-only APIs, no imports. Everything user-supplied is
|
|
22
|
+
* Plain ES module, browser-only APIs, no imports. Reads A2UI 1.0 and v0.9 messages. Everything user-supplied is
|
|
22
23
|
* written via textContent / escaped HTML; media URLs are limited to data:,
|
|
23
24
|
* https:, blob: and same-origin paths.
|
|
24
25
|
*/
|
|
26
|
+
/**
|
|
27
|
+
* A2UI 1.0 → the layout this renderer works in (one operation per message, bindings as `{path}`). v0.9
|
|
28
|
+
* messages pass through. The same conversion as `flattenMessages` in ./protocol.ts, repeated here because
|
|
29
|
+
* this file must stay importable on its own.
|
|
30
|
+
*/
|
|
31
|
+
function normalize(messages) {
|
|
32
|
+
const value = (v) => {
|
|
33
|
+
if (Array.isArray(v))
|
|
34
|
+
return v.map(value);
|
|
35
|
+
if (!v || typeof v !== "object")
|
|
36
|
+
return v;
|
|
37
|
+
const keys = Object.keys(v);
|
|
38
|
+
if (typeof v["@path"] === "string" && keys.length === 1)
|
|
39
|
+
return { path: v["@path"] };
|
|
40
|
+
if (typeof v["@call"] === "string")
|
|
41
|
+
return { call: v["@call"], ...(v.args === undefined ? {} : { args: value(v.args) }) };
|
|
42
|
+
return Object.fromEntries(keys.map((k) => [k === "@checks" ? "checks" : k === "@accessibility" ? "accessibility" : k, value(v[k])]));
|
|
43
|
+
};
|
|
44
|
+
const out = [];
|
|
45
|
+
for (const m of messages) {
|
|
46
|
+
if (m && m.createSurface) {
|
|
47
|
+
const { components, dataModel, ...rest } = m.createSurface;
|
|
48
|
+
out.push({ ...m, createSurface: rest });
|
|
49
|
+
if (components)
|
|
50
|
+
out.push({ version: m.version, updateComponents: { surfaceId: rest.surfaceId, components: components.map(value) } });
|
|
51
|
+
if (dataModel !== undefined)
|
|
52
|
+
out.push({ version: m.version, updateDataModel: { surfaceId: rest.surfaceId, path: "/", value: dataModel } });
|
|
53
|
+
}
|
|
54
|
+
else if (m && m.updateComponents) {
|
|
55
|
+
out.push({ ...m, updateComponents: { ...m.updateComponents, components: (m.updateComponents.components || []).map(value) } });
|
|
56
|
+
}
|
|
57
|
+
else
|
|
58
|
+
out.push(m);
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
25
62
|
const KIND_EMOJI = { folder: "📁", image: "🖼", video: "🎬", audio: "🎵", pdf: "📕", file: "📄" };
|
|
26
63
|
/** Media URLs we let into src attributes. */
|
|
27
64
|
function safeMediaUrl(u) {
|
|
@@ -99,6 +136,49 @@ function pointerSet(obj, pointer, value) {
|
|
|
99
136
|
o[keys[keys.length - 1]] = value;
|
|
100
137
|
return obj;
|
|
101
138
|
}
|
|
139
|
+
// ── Pickers (docs §3 FilePicker / AgentPicker; labels mirror ./pickers.ts) ──
|
|
140
|
+
// Everything user-supplied goes through textContent. The renderer applies no
|
|
141
|
+
// permission logic: the origin's availability / entitlement / canInvoke flags
|
|
142
|
+
// only decide whether the pick control is enabled and what reason it announces.
|
|
143
|
+
const PICKER = {
|
|
144
|
+
fileScopes: [["mine", "내 파일"], ["shared_with_me", "나에게 공유됨"], ["shared_with_org", "조직 공유"], ["recent", "최근"]],
|
|
145
|
+
agentScopes: [["mine", "내 에이전트"], ["shared_with_me", "나에게 공유됨"], ["shared_with_org", "조직 공유"], ["public", "공개"]],
|
|
146
|
+
shareOrigin: { own: "내 파일", direct: "직접 공유", org: "조직 공유", link: "링크 공유", paid: "유료 공유" },
|
|
147
|
+
role: { owner: "소유자", editor: "편집 가능", viewer: "보기 전용", none: "권한 없음" },
|
|
148
|
+
availability: { online: "온라인", offline: "오프라인", deleted: "삭제됨", unknown: "확인 안 됨" },
|
|
149
|
+
agentStatus: { active: "활성", disabled: "비활성", stopped: "중지됨", deleted: "삭제됨" },
|
|
150
|
+
visibility: { public: "공개", org: "조직", private: "비공개", unlisted: "링크 공개" },
|
|
151
|
+
paidBadge: "구매 필요",
|
|
152
|
+
more: "더 보기",
|
|
153
|
+
};
|
|
154
|
+
const fileKey = (r) => `${r.issuer}#${r.driveId}#${r.fileId}`;
|
|
155
|
+
const agentKey = (r) => `${r.registryIssuer}#${r.agentId}`;
|
|
156
|
+
function filePickReason(item) {
|
|
157
|
+
const state = item.ref.availability && item.ref.availability.state;
|
|
158
|
+
if (state === "offline")
|
|
159
|
+
return "오프라인: 보관 기기가 연결되어 있지 않아 지금은 사용할 수 없습니다";
|
|
160
|
+
if (state === "deleted")
|
|
161
|
+
return "삭제됨: 원본이 더 이상 존재하지 않습니다";
|
|
162
|
+
if (item.paid && !item.paid.entitled)
|
|
163
|
+
return "구매 필요: 구매 후 사용할 수 있습니다";
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
function agentPickReason(item) {
|
|
167
|
+
if (item.ref.status !== "active")
|
|
168
|
+
return `${PICKER.agentStatus[item.ref.status] || item.ref.status}: 새 호출을 받지 않습니다`;
|
|
169
|
+
if (!item.canInvoke)
|
|
170
|
+
return "호출 권한이 없습니다";
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
function mk(tag, className, text) {
|
|
174
|
+
const e = document.createElement(tag);
|
|
175
|
+
if (className)
|
|
176
|
+
e.className = className;
|
|
177
|
+
if (text !== undefined)
|
|
178
|
+
e.textContent = String(text);
|
|
179
|
+
return e;
|
|
180
|
+
}
|
|
181
|
+
const badge = (text, tone) => mk("span", `ainui-picker-badge${tone ? ` ainui-picker-badge-${tone}` : ""}`, text);
|
|
102
182
|
/**
|
|
103
183
|
* @param {HTMLElement} container
|
|
104
184
|
* @param {{
|
|
@@ -136,8 +216,13 @@ export function createA2uiRenderer(container, { onAction, resolveAsset, assetBas
|
|
|
136
216
|
if (v && typeof v === "object" && typeof v.path === "string") {
|
|
137
217
|
return v.path.startsWith("/") ? pointerGet(surf.data, v.path) : pointerGet(scope ?? {}, "/" + v.path);
|
|
138
218
|
}
|
|
139
|
-
if (v && typeof v === "object" && typeof v.call === "string")
|
|
219
|
+
if (v && typeof v === "object" && typeof v.call === "string") {
|
|
220
|
+
// The one function a heading needs: "${/path}" pieces of a formatString template.
|
|
221
|
+
if (v.call === "formatString" && v.args && typeof v.args.value === "string") {
|
|
222
|
+
return v.args.value.replace(/\$\{([^}]+)\}/g, (_, path) => String(resolve({ path: path.trim() }, surf, scope) ?? ""));
|
|
223
|
+
}
|
|
140
224
|
return "";
|
|
225
|
+
}
|
|
141
226
|
return v;
|
|
142
227
|
}
|
|
143
228
|
function childIds(spec, surf, scope) {
|
|
@@ -184,6 +269,14 @@ export function createA2uiRenderer(container, { onAction, resolveAsset, assetBas
|
|
|
184
269
|
el.className = "a2ui-card";
|
|
185
270
|
el.appendChild(renderNode(surfaceId, c.child, scope));
|
|
186
271
|
break;
|
|
272
|
+
case "Title":
|
|
273
|
+
case "Caption": {
|
|
274
|
+
// The AINUI 1.0 catalog's heading and caption; drawn with the classes the Text variants always had.
|
|
275
|
+
const level = { "5xl": 1, "4xl": 1, "3xl": 1, "2xl": 1, xl: 2, lg: 3, md: 4, sm: 5 }[c.size] || 3;
|
|
276
|
+
el.className = c.component === "Title" ? `a2ui-text a2ui-text-h${level}` : "a2ui-text a2ui-text-caption";
|
|
277
|
+
el.textContent = String(resolve(c.text, surf, scope) ?? "");
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
187
280
|
case "Text": {
|
|
188
281
|
const v = c.variant || "body";
|
|
189
282
|
const t = resolve(c.text, surf, scope) ?? "";
|
|
@@ -539,6 +632,186 @@ export function createA2uiRenderer(container, { onAction, resolveAsset, assetBas
|
|
|
539
632
|
}
|
|
540
633
|
break;
|
|
541
634
|
}
|
|
635
|
+
case "FilePicker":
|
|
636
|
+
case "AgentPicker": {
|
|
637
|
+
const isFile = c.component === "FilePicker";
|
|
638
|
+
const kind = isFile ? "file" : "agent";
|
|
639
|
+
const items = resolve(c.items, surf, scope);
|
|
640
|
+
const rows = (Array.isArray(items) ? items : []).filter((i) => i && i.ref);
|
|
641
|
+
const rawCtx = c.context && typeof c.context === "object" && typeof c.context.path === "string" ? resolve(c.context, surf, scope) : c.context;
|
|
642
|
+
const base = rawCtx && typeof rawCtx === "object" ? rawCtx : {};
|
|
643
|
+
const send = (name, context) => onAction && onAction({ name, surfaceId, sourceComponentId: c.id, timestamp: new Date().toISOString(), context: { ...base, ...context } });
|
|
644
|
+
const current = String(resolve(c.scope, surf, scope) ?? "mine");
|
|
645
|
+
el.className = `ainui-picker ainui-picker-${kind}`;
|
|
646
|
+
el.setAttribute("aria-label", isFile ? "파일 선택" : "에이전트 선택");
|
|
647
|
+
// scope tabs
|
|
648
|
+
const tabs = mk("div", "ainui-picker-scopes");
|
|
649
|
+
tabs.setAttribute("role", "tablist");
|
|
650
|
+
tabs.setAttribute("aria-label", isFile ? "파일 범위" : "에이전트 범위");
|
|
651
|
+
for (const [value, label] of (isFile ? PICKER.fileScopes : PICKER.agentScopes)) {
|
|
652
|
+
const b = mk("button", "ainui-picker-scope", label);
|
|
653
|
+
b.type = "button";
|
|
654
|
+
b.setAttribute("role", "tab");
|
|
655
|
+
b.setAttribute("aria-selected", String(value === current));
|
|
656
|
+
b.addEventListener("click", () => { if (value !== current)
|
|
657
|
+
send("ainui.picker.scope", { kind, scope: value }); });
|
|
658
|
+
tabs.appendChild(b);
|
|
659
|
+
}
|
|
660
|
+
// search
|
|
661
|
+
const form = mk("form", "ainui-picker-search");
|
|
662
|
+
form.setAttribute("role", "search");
|
|
663
|
+
const input = mk("input");
|
|
664
|
+
input.type = "search";
|
|
665
|
+
input.setAttribute("aria-label", "검색");
|
|
666
|
+
input.placeholder = isFile ? "파일 이름 검색" : "에이전트 검색";
|
|
667
|
+
input.value = String(resolve(c.query, surf, scope) ?? "");
|
|
668
|
+
const go = mk("button", "a2ui-button", "검색");
|
|
669
|
+
go.type = "submit";
|
|
670
|
+
form.addEventListener("submit", (e) => { e.preventDefault(); send("ainui.picker.search", { kind, query: input.value.trim() }); });
|
|
671
|
+
form.append(input, go);
|
|
672
|
+
el.append(tabs, form);
|
|
673
|
+
// as-of / expired cursor
|
|
674
|
+
const asOf = resolve(c.asOf, surf, scope);
|
|
675
|
+
const expired = resolve(c.cursorExpired, surf, scope) === true;
|
|
676
|
+
if (asOf || expired) {
|
|
677
|
+
const line = mk("div", "ainui-picker-asof");
|
|
678
|
+
if (asOf) {
|
|
679
|
+
const t = mk("small");
|
|
680
|
+
t.textContent = "기준 시각: ";
|
|
681
|
+
const time = mk("time", "", asOf);
|
|
682
|
+
time.dateTime = String(asOf);
|
|
683
|
+
t.appendChild(time);
|
|
684
|
+
line.appendChild(t);
|
|
685
|
+
}
|
|
686
|
+
if (expired) {
|
|
687
|
+
const r = mk("button", "a2ui-button", "목록이 만료됨 — 처음부터 다시 불러오기");
|
|
688
|
+
r.type = "button";
|
|
689
|
+
r.addEventListener("click", () => send("ainui.picker.more", { kind, cursor: null }));
|
|
690
|
+
line.appendChild(r);
|
|
691
|
+
}
|
|
692
|
+
el.appendChild(line);
|
|
693
|
+
}
|
|
694
|
+
if (!rows.length)
|
|
695
|
+
el.appendChild(mk("p", "ainui-picker-empty", isFile ? "표시할 파일이 없습니다" : "표시할 에이전트가 없습니다"));
|
|
696
|
+
const list = mk("ul", "ainui-picker-list");
|
|
697
|
+
list.setAttribute("aria-label", isFile ? "파일 목록" : "에이전트 목록");
|
|
698
|
+
const multiple = isFile && resolve(c.selection, surf, scope) === "multiple";
|
|
699
|
+
const preselected = resolve(c.selected, surf, scope);
|
|
700
|
+
const chosen = new Set(isFile ? (Array.isArray(preselected) ? preselected : []) : []);
|
|
701
|
+
const selectedAgent = !isFile && typeof preselected === "string" ? preselected : "";
|
|
702
|
+
const doneBtn = multiple ? mk("button", "a2ui-button a2ui-button-primary ainui-picker-done") : null;
|
|
703
|
+
const syncDone = () => { if (!doneBtn)
|
|
704
|
+
return; const n = rows.filter((r) => chosen.has(fileKey(r.ref)) && !filePickReason(r)).length; doneBtn.textContent = `${n}개 선택 완료`; doneBtn.disabled = n === 0; };
|
|
705
|
+
for (const item of rows) {
|
|
706
|
+
const ref = item.ref;
|
|
707
|
+
const key = isFile ? fileKey(ref) : agentKey(ref);
|
|
708
|
+
const reason = isFile ? filePickReason(item) : agentPickReason(item);
|
|
709
|
+
const li = mk("li", `ainui-picker-row${reason ? " ainui-picker-row-unavailable" : ""}`);
|
|
710
|
+
li.setAttribute("aria-disabled", String(!!reason));
|
|
711
|
+
li.setAttribute(isFile ? "data-file-key" : "data-agent-key", key);
|
|
712
|
+
const setSelected = (on) => { li.setAttribute("aria-selected", String(on)); li.classList.toggle("ainui-picker-row-selected", on); };
|
|
713
|
+
setSelected(isFile ? chosen.has(key) : selectedAgent === key);
|
|
714
|
+
if (isFile) {
|
|
715
|
+
const icon = mk("span", "ainui-picker-icon");
|
|
716
|
+
icon.setAttribute("aria-hidden", "true");
|
|
717
|
+
icon.appendChild(kindIcon(ref.kind === "folder" ? "folder" : "file"));
|
|
718
|
+
li.appendChild(icon);
|
|
719
|
+
}
|
|
720
|
+
const main = mk("span", "ainui-picker-main");
|
|
721
|
+
const name = mk("span", "ainui-picker-name", ref.displayName);
|
|
722
|
+
name.title = String(ref.displayName ?? "");
|
|
723
|
+
main.appendChild(name);
|
|
724
|
+
if (!isFile && ref.description)
|
|
725
|
+
main.appendChild(mk("span", "ainui-picker-description", ref.description));
|
|
726
|
+
const meta = mk("span", "ainui-picker-meta");
|
|
727
|
+
if (isFile) {
|
|
728
|
+
const state = (ref.availability && ref.availability.state) || "unknown";
|
|
729
|
+
meta.append(badge(PICKER.shareOrigin[item.shareOrigin] || item.shareOrigin), badge(PICKER.role[item.role] || item.role, "muted"), badge(PICKER.availability[state] || state, state === "online" ? "" : state === "unknown" ? "muted" : "danger"));
|
|
730
|
+
if (item.paid && !item.paid.entitled)
|
|
731
|
+
meta.appendChild(badge(PICKER.paidBadge, "warn"));
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
meta.append(badge(PICKER.agentStatus[ref.status] || ref.status, ref.status === "active" ? "" : "danger"), badge(PICKER.visibility[ref.visibility] || ref.visibility, "muted"));
|
|
735
|
+
for (const sk of (Array.isArray(ref.skills) ? ref.skills : []).slice(0, 3))
|
|
736
|
+
meta.appendChild(badge(sk.name, "muted"));
|
|
737
|
+
}
|
|
738
|
+
main.appendChild(meta);
|
|
739
|
+
if (!isFile) {
|
|
740
|
+
const renders = resolve(c.renders, surf, scope);
|
|
741
|
+
const r = new Set(Array.isArray(renders) ? renders : []);
|
|
742
|
+
const caps = Array.isArray(ref.uiCapabilities) ? ref.uiCapabilities : [];
|
|
743
|
+
const enabled = caps.filter((x) => r.has(x)), fallbacks = caps.filter((x) => !r.has(x));
|
|
744
|
+
const line = mk("small", "ainui-picker-capabilities");
|
|
745
|
+
if (enabled.length)
|
|
746
|
+
line.appendChild(mk("span", "ainui-picker-enabled", `지원: ${enabled.join(", ")}`));
|
|
747
|
+
if (fallbacks.length)
|
|
748
|
+
line.appendChild(mk("span", "ainui-picker-fallbacks", `대체: ${fallbacks.join(", ")}`));
|
|
749
|
+
main.appendChild(line);
|
|
750
|
+
}
|
|
751
|
+
if (reason)
|
|
752
|
+
main.appendChild(mk("small", "ainui-picker-reason", reason));
|
|
753
|
+
li.appendChild(main);
|
|
754
|
+
const actions = mk("span", "ainui-picker-actions");
|
|
755
|
+
const pick = mk("button", `a2ui-button ainui-picker-pick${chosen.has(key) ? "" : " a2ui-button-primary"}`, multiple && chosen.has(key) ? "선택 해제" : "선택");
|
|
756
|
+
pick.type = "button";
|
|
757
|
+
pick.disabled = !!reason;
|
|
758
|
+
pick.setAttribute("aria-label", reason ? `${ref.displayName}: ${reason}` : `${ref.displayName} ${pick.textContent}`);
|
|
759
|
+
if (reason)
|
|
760
|
+
pick.title = reason;
|
|
761
|
+
pick.addEventListener("click", () => {
|
|
762
|
+
if (reason)
|
|
763
|
+
return;
|
|
764
|
+
if (!isFile)
|
|
765
|
+
return send("ainui.picker.pick", { kind: "agent", ref });
|
|
766
|
+
if (!multiple)
|
|
767
|
+
return send("ainui.picker.pick", { kind: "file", refs: [ref] });
|
|
768
|
+
if (chosen.has(key))
|
|
769
|
+
chosen.delete(key);
|
|
770
|
+
else
|
|
771
|
+
chosen.add(key);
|
|
772
|
+
const on = chosen.has(key);
|
|
773
|
+
setSelected(on);
|
|
774
|
+
pick.textContent = on ? "선택 해제" : "선택";
|
|
775
|
+
pick.classList.toggle("a2ui-button-primary", !on);
|
|
776
|
+
pick.setAttribute("aria-label", `${ref.displayName} ${pick.textContent}`);
|
|
777
|
+
syncDone();
|
|
778
|
+
});
|
|
779
|
+
actions.appendChild(pick);
|
|
780
|
+
if (isFile && ref.sourceUrl) {
|
|
781
|
+
const open = mk("button", "a2ui-button ainui-picker-open", "열기");
|
|
782
|
+
open.type = "button";
|
|
783
|
+
open.setAttribute("aria-label", `${ref.displayName} 원본 열기`);
|
|
784
|
+
open.addEventListener("click", () => send("ainui.picker.open", { kind: "file", sourceUrl: ref.sourceUrl }));
|
|
785
|
+
actions.appendChild(open);
|
|
786
|
+
}
|
|
787
|
+
if (!isFile) {
|
|
788
|
+
const card = mk("button", "a2ui-button ainui-picker-card", "카드");
|
|
789
|
+
card.type = "button";
|
|
790
|
+
card.setAttribute("aria-label", `${ref.displayName} 에이전트 카드`);
|
|
791
|
+
card.addEventListener("click", () => send("ainui.picker.card", { kind: "agent", agentCardUrl: ref.agentCardUrl }));
|
|
792
|
+
actions.appendChild(card);
|
|
793
|
+
}
|
|
794
|
+
li.appendChild(actions);
|
|
795
|
+
list.appendChild(li);
|
|
796
|
+
}
|
|
797
|
+
el.appendChild(list);
|
|
798
|
+
const footer = mk("div", "ainui-picker-footer");
|
|
799
|
+
const cursor = resolve(c.cursor, surf, scope);
|
|
800
|
+
if (typeof cursor === "string" && cursor) {
|
|
801
|
+
const more = mk("button", "a2ui-button ainui-picker-more", PICKER.more);
|
|
802
|
+
more.type = "button";
|
|
803
|
+
more.addEventListener("click", () => send("ainui.picker.more", { kind, cursor }));
|
|
804
|
+
footer.appendChild(more);
|
|
805
|
+
}
|
|
806
|
+
if (doneBtn) {
|
|
807
|
+
doneBtn.type = "button";
|
|
808
|
+
syncDone();
|
|
809
|
+
doneBtn.addEventListener("click", () => send("ainui.picker.pick", { kind: "file", refs: rows.filter((r) => chosen.has(fileKey(r.ref)) && !filePickReason(r)).map((r) => r.ref) }));
|
|
810
|
+
footer.appendChild(doneBtn);
|
|
811
|
+
}
|
|
812
|
+
el.appendChild(footer);
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
542
815
|
default:
|
|
543
816
|
// Unknown component: draw its children if it has any, else nothing (AINUI §3).
|
|
544
817
|
el.className = "a2ui-unknown";
|
|
@@ -575,7 +848,7 @@ export function createA2uiRenderer(container, { onAction, resolveAsset, assetBas
|
|
|
575
848
|
}
|
|
576
849
|
/** Apply a batch of server→client messages, then re-render. */
|
|
577
850
|
function process(messages) {
|
|
578
|
-
for (const m of messages || []) {
|
|
851
|
+
for (const m of normalize(messages || [])) {
|
|
579
852
|
if (m.createSurface)
|
|
580
853
|
surfaces.set(m.createSurface.surfaceId, { components: new Map(), data: {} });
|
|
581
854
|
else if (m.updateComponents) {
|
|
@@ -649,5 +922,27 @@ export const A2UI_RENDERER_CSS = `
|
|
|
649
922
|
.a2ui-segmented{display:inline-flex;border:1px solid #dce3ec;border-radius:999px;overflow:hidden}
|
|
650
923
|
.a2ui-segment{font:inherit;border:0;background:#fff;color:inherit;padding:4px 14px;cursor:pointer;min-height:36px}
|
|
651
924
|
.a2ui-segment[aria-pressed=true]{background:#0b57d0;color:#fff}
|
|
925
|
+
.ainui-picker{display:flex;flex-direction:column;gap:10px;min-width:0}
|
|
926
|
+
.ainui-picker-scopes{display:flex;flex-wrap:wrap;gap:4px;padding:3px;border:1px solid #dce3ec;border-radius:10px;background:#f2f5f9}
|
|
927
|
+
.ainui-picker-scope{font:inherit;border:0;border-radius:7px;background:transparent;color:#54607a;padding:6px 12px;min-height:36px;cursor:pointer}
|
|
928
|
+
.ainui-picker-scope[aria-selected=true]{background:#fff;color:inherit;box-shadow:0 1px 3px #00000014}
|
|
929
|
+
.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}
|
|
930
|
+
.ainui-picker-asof{display:flex;flex-wrap:wrap;gap:8px;align-items:center;font-size:12px;color:#54607a}
|
|
931
|
+
.ainui-picker-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}
|
|
932
|
+
.ainui-picker-row{display:flex;align-items:center;gap:10px;padding:8px;border-radius:10px}
|
|
933
|
+
.ainui-picker-row:hover{background:#eaeef4}.ainui-picker-row-selected{background:#e3ecfb}
|
|
934
|
+
.ainui-picker-row-unavailable .ainui-picker-main{opacity:.55}
|
|
935
|
+
.ainui-picker-icon{font-size:22px}.ainui-picker-main{display:flex;flex:1;flex-direction:column;gap:3px;min-width:0}
|
|
936
|
+
.ainui-picker-name{font-weight:600;overflow-wrap:anywhere}.ainui-picker-description{font-size:13px;color:#54607a}
|
|
937
|
+
.ainui-picker-meta{display:flex;flex-wrap:wrap;gap:4px}
|
|
938
|
+
.ainui-picker-badge{font-size:11px;line-height:18px;padding:0 7px;border-radius:999px;background:#eaeef4;color:inherit}
|
|
939
|
+
.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}
|
|
940
|
+
.ainui-picker-capabilities{display:flex;flex-wrap:wrap;gap:8px;font-size:12px;color:#54607a}.ainui-picker-fallbacks{color:#7a4b00}
|
|
941
|
+
.ainui-picker-reason{font-size:12px;color:#8c1d18;opacity:1}
|
|
942
|
+
.ainui-picker-actions{display:flex;flex-direction:column;gap:4px;flex:0 0 auto}
|
|
943
|
+
.ainui-picker-footer{display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between}.ainui-picker-footer:empty{display:none}
|
|
944
|
+
.ainui-picker-empty{margin:0;color:#54607a}
|
|
945
|
+
@media (max-width:600px){.ainui-picker-row{flex-wrap:wrap}.ainui-picker-actions{flex-direction:row;width:100%;justify-content:flex-end}}
|
|
946
|
+
@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}}
|
|
652
947
|
@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}}
|
|
653
948
|
`;
|