@agimon-ai/po-native-dashboard 0.0.0-alpha.2 → 0.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CompletionSheet.d.mts +3 -1
- package/dist/components/CompletionSheet.d.mts.map +1 -1
- package/dist/components/CompletionSheet.mjs +8 -6
- package/dist/components/CompletionSheet.mjs.map +1 -1
- package/dist/components/Composer.d.mts +3 -1
- package/dist/components/Composer.d.mts.map +1 -1
- package/dist/components/Composer.mjs +4 -2
- package/dist/components/Composer.mjs.map +1 -1
- package/dist/components/slotProps.d.mts +1 -1
- package/dist/components/slotProps.d.mts.map +1 -1
- package/dist/components/slotProps.mjs.map +1 -1
- package/dist/screens/SessionScreen.d.mts +10 -3
- package/dist/screens/SessionScreen.d.mts.map +1 -1
- package/dist/screens/SessionScreen.mjs +19 -8
- package/dist/screens/SessionScreen.mjs.map +1 -1
- package/dist/screens/SessionsScreen.d.mts.map +1 -1
- package/dist/screens/SessionsScreen.mjs +23 -26
- package/dist/screens/SessionsScreen.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { CommandInfo, CompletionItem, CompletionKind } from "@agimon-ai/po-web-dashboard/core";
|
|
1
|
+
import { CommandInfo, CompletionItem, CompletionKind, MentionableSession } from "@agimon-ai/po-web-dashboard/core";
|
|
2
2
|
import { WebPluginSlotProps } from "@agimon-ai/po-core/web";
|
|
3
3
|
//#region src/components/CompletionSheet.d.ts
|
|
4
4
|
export interface CompletionSource {
|
|
5
5
|
commands: readonly CommandInfo[];
|
|
6
6
|
searchFiles: (query: string) => Promise<string[]>;
|
|
7
|
+
/** Sessions `@` may name, offered before files. */
|
|
8
|
+
sessions?: () => readonly MentionableSession[];
|
|
7
9
|
}
|
|
8
10
|
/** The items one kind offers for a query; files come from the hub, the rest from the session's commands. */
|
|
9
11
|
export declare function useCompletionItems(source: CompletionSource | undefined, kind: CompletionKind | null, query: string): CompletionItem[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompletionSheet.d.mts","names":[],"sources":["../../src/components/CompletionSheet.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CompletionSheet.d.mts","names":[],"sources":["../../src/components/CompletionSheet.tsx"],"mappings":";;;iBA+CiB;EACf,mBAAmB;EACnB,cAAc,kBAAkB;;EAEhC,0BAA0B;;;wBAiCZ,mBACd,QAAQ,8BACR,MAAM,uBACN,gBACC;;wBA2Ba,iBACd,OACA;EAEA,gBAAgB;EAChB,SAAS,MAAM;oBAChB,IAAA;iBA2BgB;EACf;EACA,eAAe;EACf,QAAQ;EACR,SAAS,MAAM,gBAAgB,MAAM;;EAErC,cAAc;EACd;;EAEA;;EAEA,YAAY;;EAEZ,mBAAmB;;iBAGJ;EACf;EACA;EACA;EACA;EACA;;;wBAIc,kBACd,MACA,cACA,QACA,QACA,aACA,cACA,aACA,WACA,WACC,uCAAoB,IAAA;;wBA2HP,mBAAmB;EAAa;oBAAqB,IAAA"}
|
|
@@ -4,7 +4,7 @@ import { ChevronRightIcon, Input, Sheet, SheetContent, SparklesIcon, Spinner, fo
|
|
|
4
4
|
import { StyleSheet } from "react-native-unistyles";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
7
|
-
import { HOST_SLOTS, TRIGGER_CHARS, commandCompletions, fileCompletions, slotFills } from "@agimon-ai/po-web-dashboard/core";
|
|
7
|
+
import { HOST_SLOTS, TRIGGER_CHARS, commandCompletions, fileCompletions, sessionCompletions, slotFills } from "@agimon-ai/po-web-dashboard/core";
|
|
8
8
|
import { useEffect, useEffectEvent, useState } from "react";
|
|
9
9
|
|
|
10
10
|
//#region src/components/CompletionSheet.tsx
|
|
@@ -12,10 +12,10 @@ import { useEffect, useEffectEvent, useState } from "react";
|
|
|
12
12
|
const KINDS = [
|
|
13
13
|
{
|
|
14
14
|
kind: "file",
|
|
15
|
-
title: "Files",
|
|
16
|
-
hint: "Point Po at a file in this folder",
|
|
17
|
-
search: "Search files",
|
|
18
|
-
none: "No files match"
|
|
15
|
+
title: "Files and sessions",
|
|
16
|
+
hint: "Point Po at a file in this folder or another session",
|
|
17
|
+
search: "Search files and sessions",
|
|
18
|
+
none: "No files or sessions match"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
kind: "skill",
|
|
@@ -86,7 +86,9 @@ function useCompletionItems(source, kind, query) {
|
|
|
86
86
|
]);
|
|
87
87
|
if (source === void 0 || kind === null) return [];
|
|
88
88
|
if (kind !== "file") return commandCompletions(source.commands, kind, query);
|
|
89
|
-
|
|
89
|
+
const sessions = sessionCompletions(source.sessions?.() ?? [], query);
|
|
90
|
+
if (files?.query === query) return [...sessions, ...files.items];
|
|
91
|
+
return sessions.length > 0 ? sessions : void 0;
|
|
90
92
|
}
|
|
91
93
|
/** Completion items as tappable rows: the name in mono, what it does beneath. */
|
|
92
94
|
function CompletionRows({ items, onPick }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompletionSheet.mjs","names":["WebPluginSlotProps","ChevronRightIcon","fontOf","Input","Sheet","SheetContent","SparklesIcon","Spinner","CommandInfo","CompletionItem","CompletionKind","commandCompletions","fileCompletions","HOST_SLOTS","slotFills","TRIGGER_CHARS","ComponentType","useEffect","useEffectEvent","useState","StyleSheet","KINDS","kind","title","hint","search","none","FILE_SEARCH_DEBOUNCE_MS","CompletionSource","commands","searchFiles","query","Promise","InsertPage","key","glyph","component","textField","data","undefined","value","Reflect","get","insertPages","sessionId","composerMenu","flatMap","pluginId","id","charAt","useCompletionItems","source","files","setFiles","items","searchable","text","resolve","current","timer","setTimeout","then","found","clearTimeout","CompletionRows","onPick","item","styles","list","map","index","insert","detail","label","pressed","divider","flex","itemLabel","meta","CompletionSheetProps","open","onOpenChange","defaultKind","defaultQuery","defaultPage","slotProps","actions","InsertAction","onPress","CompletionSheet","setKind","pageKey","setPageKey","setQuery","page","find","entry","pages","plugin","choose","next","close","rows","head","back","hidden","flip","appendComposerDraft","body","glyphText","kindLabel","waiting","length","CompletionButton","magic","magicPressed","create","theme","sans","fontFamily","mono","size","color","fontSize","lineHeight","minWidth","opacity","transform","rotate","flexDirection","alignItems","paddingHorizontal","spacing","paddingBottom","uni__dependencies","width","height","justifyContent","colors","hi","fontWeight","semibold","textAlign","gap","borderRadius","lg","borderWidth","borderColor","backgroundColor","bg","overflow","minHeight","paddingVertical","borderTopWidth","hairlineWidth","borderTopColor","green","medium","dim"],"sources":["../../src/components/CompletionSheet.tsx"],"sourcesContent":["import type { WebPluginSlotProps } from '@agimon-ai/po-core/web';\nimport {\n ChevronRightIcon,\n fontOf,\n Input,\n Sheet,\n SheetContent,\n SparklesIcon,\n Spinner,\n} from '@agimon-ai/po-native-components';\nimport {\n type CommandInfo,\n type CompletionItem,\n type CompletionKind,\n commandCompletions,\n fileCompletions,\n HOST_SLOTS,\n slotFills,\n TRIGGER_CHARS,\n} from '@agimon-ai/po-web-dashboard/core';\nimport { type ComponentType, useEffect, useEffectEvent, useState } from 'react';\nimport { Pressable, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\n/** The phone's way into `@`, `$` and `/`: what each kind is called and what it is for. */\nconst KINDS: readonly { kind: CompletionKind; title: string; hint: string; search: string; none: string }[] = [\n {\n kind: 'file',\n title: 'Files',\n hint: 'Point Po at a file in this folder',\n search: 'Search files',\n none: 'No files match',\n },\n { kind: 'skill', title: 'Skills', hint: 'Use one of your skills', search: 'Search skills', none: 'No skills match' },\n {\n kind: 'command',\n title: 'Slash commands',\n hint: 'Run a session command',\n search: 'Search commands',\n none: 'No commands match',\n },\n];\n/** The hub is a tunnel away, so wait for a pause in typing before asking it. */\nconst FILE_SEARCH_DEBOUNCE_MS = 150;\n\nexport interface CompletionSource {\n commands: readonly CommandInfo[];\n searchFiles: (query: string) => Promise<string[]>;\n}\n\n/** A row a plugin adds after the three kinds, and the page it opens in this sheet. */\ninterface InsertPage {\n key: string;\n title: string;\n hint: string;\n glyph: string;\n component: ComponentType<WebPluginSlotProps>;\n}\n\nfunction textField(data: unknown, key: string): string | undefined {\n if (typeof data !== 'object' || data === null) return undefined;\n const value: unknown = Reflect.get(data, key);\n return typeof value === 'string' ? value : undefined;\n}\n\n/**\n * The phone's `composer-menu` fills. The cockpit draws a fill's component as the\n * menu row itself; a sheet has room for a page, so here `data.title` (with\n * optional `hint` and `glyph`) is the row and the component is the page.\n */\nfunction insertPages(sessionId: string | null): InsertPage[] {\n return slotFills(HOST_SLOTS.composerMenu, sessionId).flatMap(({ pluginId, id, data, component }) => {\n const title = textField(data, 'title');\n if (!component || title === undefined) return [];\n const hint = textField(data, 'hint') ?? '';\n const glyph = textField(data, 'glyph') ?? title.charAt(0);\n return [{ key: `${pluginId}:${id}`, title, hint, glyph, component }];\n });\n}\n/** The items one kind offers for a query; files come from the hub, the rest from the session's commands. */\nexport function useCompletionItems(\n source: CompletionSource | undefined,\n kind: CompletionKind | null,\n query: string,\n): CompletionItem[] | undefined {\n const [files, setFiles] = useState<{ query: string; items: CompletionItem[] }>();\n const searchable = source?.searchFiles !== undefined;\n // Hosts rebuild searchFiles every render; an effect event keeps a streaming session from restarting the debounce forever.\n const searchFiles = useEffectEvent((text: string) => source?.searchFiles(text) ?? Promise.resolve([]));\n useEffect(() => {\n if (kind !== 'file' || !searchable) return;\n let current = true;\n const timer = setTimeout(() => {\n void searchFiles(query).then((found) => {\n if (current) setFiles({ query, items: fileCompletions(found) });\n });\n }, FILE_SEARCH_DEBOUNCE_MS);\n return () => {\n current = false;\n clearTimeout(timer);\n };\n }, [kind, query, searchable]);\n if (source === undefined || kind === null) return [];\n if (kind !== 'file') return commandCompletions(source.commands, kind, query);\n // Undefined while the answer for this query is on its way.\n return files?.query === query ? files.items : undefined;\n}\n\n/** Completion items as tappable rows: the name in mono, what it does beneath. */\nexport function CompletionRows({\n items,\n onPick,\n}: {\n items: readonly CompletionItem[];\n onPick: (item: CompletionItem) => void;\n}) {\n return (\n <View style={styles.list}>\n {items.map((item, index) => (\n <Pressable\n key={item.insert}\n accessibilityRole=\"button\"\n accessibilityLabel={item.detail ? `${item.label}, ${item.detail}` : item.label}\n onPress={() => onPick(item)}\n style={({ pressed }) => [styles.item, index > 0 && styles.divider, pressed && styles.pressed]}\n >\n <View style={styles.flex}>\n <Text style={styles.itemLabel} numberOfLines={1} ellipsizeMode=\"middle\">\n {item.label}\n </Text>\n {item.detail ? (\n <Text style={styles.meta} numberOfLines={1}>\n {item.detail}\n </Text>\n ) : null}\n </View>\n </Pressable>\n ))}\n </View>\n );\n}\n\nexport interface CompletionSheetProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n source: CompletionSource;\n onPick: (kind: CompletionKind, item: CompletionItem) => void;\n /** Opens on one kind's search rather than the choice of kinds. */\n defaultKind?: CompletionKind;\n defaultQuery?: string;\n /** Opens on a plugin page, keyed `<pluginId>:<fillId>`. */\n defaultPage?: string;\n /** The session's plugin props; with them, its `composer-menu` fills join the list. */\n slotProps?: WebPluginSlotProps;\n /** Rows after the pages that close the sheet and run, such as attaching a photo or file. */\n actions?: readonly InsertAction[];\n}\n\nexport interface InsertAction {\n key: string;\n glyph: string;\n title: string;\n hint: string;\n onPress: () => void;\n}\n\n/** The magic button's sheet: choose Files, Skills, Slash commands, a plugin page or an attachment, then pick one. */\nexport function CompletionSheet({\n open,\n onOpenChange,\n source,\n onPick,\n defaultKind,\n defaultQuery = '',\n defaultPage,\n slotProps,\n actions = [],\n}: CompletionSheetProps) {\n const [kind, setKind] = useState<CompletionKind | null>(defaultKind ?? null);\n const [pageKey, setPageKey] = useState<string | null>(defaultPage ?? null);\n const [query, setQuery] = useState(defaultQuery);\n const items = useCompletionItems(source, kind, query);\n const page = KINDS.find((entry) => entry.kind === kind);\n const pages = slotProps ? insertPages(slotProps.sessionId) : [];\n const plugin = pages.find((entry) => entry.key === pageKey);\n\n const choose = (next: CompletionKind | null) => {\n setKind(next);\n setPageKey(null);\n setQuery('');\n };\n const close = (next: boolean) => {\n if (!next) choose(null);\n onOpenChange(next);\n };\n const rows = [\n ...KINDS.map((entry) => ({\n key: entry.kind,\n glyph: TRIGGER_CHARS[entry.kind],\n title: entry.title,\n hint: entry.hint,\n onPress: () => choose(entry.kind),\n })),\n ...pages.map((entry) => ({ ...entry, onPress: () => setPageKey(entry.key) })),\n ...actions.map((entry) => ({\n ...entry,\n onPress: () => {\n close(false);\n entry.onPress();\n },\n })),\n ];\n\n return (\n <Sheet open={open} onOpenChange={close}>\n <SheetContent>\n <View style={styles.head}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel=\"Back to insert\"\n onPress={() => choose(null)}\n disabled={page === undefined && plugin === undefined}\n style={[styles.back, page === undefined && plugin === undefined && styles.hidden]}\n >\n <View style={styles.flip}>\n <ChevronRightIcon size={18} color=\"hi\" />\n </View>\n </Pressable>\n <Text style={styles.title} accessibilityRole=\"header\">\n {page?.title ?? plugin?.title ?? 'Insert'}\n </Text>\n <View style={[styles.back, styles.hidden]} />\n </View>\n {plugin && slotProps ? (\n <plugin.component\n {...slotProps}\n appendComposerDraft={(text) => {\n slotProps.appendComposerDraft(text);\n close(false);\n }}\n />\n ) : (\n <View style={styles.body}>\n {page === undefined ? (\n <View style={styles.list}>\n {rows.map((entry, index) => (\n <Pressable\n key={entry.key}\n accessibilityRole=\"button\"\n accessibilityLabel={entry.hint ? `${entry.title}, ${entry.hint}` : entry.title}\n onPress={entry.onPress}\n style={({ pressed }) => [styles.item, index > 0 && styles.divider, pressed && styles.pressed]}\n >\n <View style={styles.glyph}>\n <Text style={styles.glyphText}>{entry.glyph}</Text>\n </View>\n <View style={styles.flex}>\n <Text style={styles.kindLabel}>{entry.title}</Text>\n {entry.hint ? <Text style={styles.meta}>{entry.hint}</Text> : null}\n </View>\n <ChevronRightIcon size={16} color=\"faint\" />\n </Pressable>\n ))}\n </View>\n ) : (\n <>\n <Input\n value={query}\n onChangeText={setQuery}\n placeholder={page.search}\n accessibilityLabel={page.search}\n autoFocus\n autoCapitalize=\"none\"\n autoCorrect={false}\n />\n {items === undefined ? (\n <View style={styles.waiting}>\n <Spinner size=\"small\" color=\"dim\" label=\"Searching\" />\n </View>\n ) : items.length === 0 ? (\n <Text style={styles.none}>{page.none}</Text>\n ) : (\n <CompletionRows\n items={items}\n onPick={(item) => {\n onPick(page.kind, item);\n close(false);\n }}\n />\n )}\n </>\n )}\n </View>\n )}\n </SheetContent>\n </Sheet>\n );\n}\n\n/** The composer's round button that opens the sheet. */\nexport function CompletionButton({ onPress }: { onPress: () => void }) {\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel=\"Insert or attach\"\n onPress={onPress}\n hitSlop={6}\n style={({ pressed }) => [styles.magic, pressed && styles.magicPressed]}\n >\n <SparklesIcon size={16} color=\"green\" />\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => {\n const sans = fontOf(theme.fontFamily.sans);\n const mono = fontOf(theme.fontFamily.mono);\n const text = (size: 'sm' | 'base' | 'lg', color: string) => ({\n fontFamily: sans,\n fontSize: theme.fontSize[size],\n lineHeight: theme.lineHeight[size],\n color,\n });\n return {\n flex: { flex: 1, minWidth: 0 },\n hidden: { opacity: 0 },\n flip: { transform: [{ rotate: '180deg' }] },\n head: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: theme.spacing(3),\n paddingBottom: theme.spacing(2),\n },\n back: { width: 36, height: 36, alignItems: 'center', justifyContent: 'center' },\n title: { ...text('lg', theme.colors.hi), fontWeight: theme.fontWeight.semibold, flex: 1, textAlign: 'center' },\n body: { gap: theme.spacing(3), paddingHorizontal: theme.spacing(4), paddingBottom: theme.spacing(4) },\n list: {\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.bg,\n overflow: 'hidden',\n },\n item: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(3),\n minHeight: 48,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(2.5),\n },\n divider: { borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: theme.colors['border-soft'] },\n pressed: { backgroundColor: theme.colors['tint-green'] },\n glyph: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors['tint-green'],\n },\n glyphText: { ...text('lg', theme.colors.green), fontFamily: mono, fontWeight: theme.fontWeight.semibold },\n kindLabel: { ...text('base', theme.colors.hi), fontWeight: theme.fontWeight.medium },\n itemLabel: { ...text('base', theme.colors.hi), fontFamily: mono },\n meta: text('sm', theme.colors.dim),\n none: { ...text('base', theme.colors.dim), textAlign: 'center', paddingVertical: theme.spacing(4) },\n waiting: { alignItems: 'center', paddingVertical: theme.spacing(6) },\n magic: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors['tint-green'],\n },\n magicPressed: { opacity: 0.7 },\n };\n});\n"],"mappings":";;;;;;;;;;;AAyBA,MAAMqB,QAAwG;CAC5G;EACEC,MAAM;EACNC,OAAO;EACPC,MAAM;EACNC,QAAQ;EACRC,MAAM;CACR;CACA;EAAEJ,MAAM;EAASC,OAAO;EAAUC,MAAM;EAA0BC,QAAQ;EAAiBC,MAAM;CAAkB;CACnH;EACEJ,MAAM;EACNC,OAAO;EACPC,MAAM;EACNC,QAAQ;EACRC,MAAM;CACR;AAAC;;AAGH,MAAMC,0BAA0B;AAgBhC,SAASU,UAAUC,MAAeJ,KAAiC;CACjE,IAAI,OAAOI,SAAS,YAAYA,SAAS,MAAM,OAAOC;CACtD,MAAMC,QAAiBC,QAAQC,IAAIJ,MAAMJ,GAAG;CAC5C,OAAO,OAAOM,UAAU,WAAWA,QAAQD;AAC7C;;;;;;AAOA,SAASI,YAAYC,WAAwC;CAC3D,OAAO9B,UAAUD,WAAWgC,cAAcD,SAAS,CAAC,CAACE,SAAS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,CAAC;GAACE,mBAAA,CAAA,CAAA;EAAC;EAClGvB,SAAS;GAAEmB,YAAY;GAAUsB,iBAAiBnC,MAAMe,QAAQ,CAAC;GAACE,mBAAA,CAAA,CAAA;EAAC;EACnEpB,OAAO;GACLqB,OAAO;GACPC,QAAQ;GACRQ,cAAc;GACdd,YAAY;GACZO,gBAAgB;GAChBW,iBAAiB/B,MAAMqB,OAAO;GAAaJ,mBAAA,CAAA,CAAA;EAC7C;EACAnB,cAAc,EAAEW,SAAS,GAAI;CAC/B;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"CompletionSheet.mjs","names":["WebPluginSlotProps","ChevronRightIcon","fontOf","Input","Sheet","SheetContent","SparklesIcon","Spinner","CommandInfo","CompletionItem","CompletionKind","commandCompletions","fileCompletions","HOST_SLOTS","MentionableSession","sessionCompletions","slotFills","TRIGGER_CHARS","ComponentType","useEffect","useEffectEvent","useState","StyleSheet","KINDS","kind","title","hint","search","none","FILE_SEARCH_DEBOUNCE_MS","CompletionSource","commands","searchFiles","query","Promise","sessions","InsertPage","key","glyph","component","textField","data","undefined","value","Reflect","get","insertPages","sessionId","composerMenu","flatMap","pluginId","id","charAt","useCompletionItems","source","files","setFiles","items","searchable","text","resolve","current","timer","setTimeout","then","found","clearTimeout","length","CompletionRows","onPick","item","styles","list","map","index","insert","detail","label","pressed","divider","flex","itemLabel","meta","CompletionSheetProps","open","onOpenChange","defaultKind","defaultQuery","defaultPage","slotProps","actions","InsertAction","onPress","CompletionSheet","setKind","pageKey","setPageKey","setQuery","page","find","entry","pages","plugin","choose","next","close","rows","head","back","hidden","flip","appendComposerDraft","body","glyphText","kindLabel","waiting","CompletionButton","magic","magicPressed","create","theme","sans","fontFamily","mono","size","color","fontSize","lineHeight","minWidth","opacity","transform","rotate","flexDirection","alignItems","paddingHorizontal","spacing","paddingBottom","uni__dependencies","width","height","justifyContent","colors","hi","fontWeight","semibold","textAlign","gap","borderRadius","lg","borderWidth","borderColor","backgroundColor","bg","overflow","minHeight","paddingVertical","borderTopWidth","hairlineWidth","borderTopColor","green","medium","dim"],"sources":["../../src/components/CompletionSheet.tsx"],"sourcesContent":["import type { WebPluginSlotProps } from '@agimon-ai/po-core/web';\nimport {\n ChevronRightIcon,\n fontOf,\n Input,\n Sheet,\n SheetContent,\n SparklesIcon,\n Spinner,\n} from '@agimon-ai/po-native-components';\nimport {\n type CommandInfo,\n type CompletionItem,\n type CompletionKind,\n commandCompletions,\n fileCompletions,\n HOST_SLOTS,\n type MentionableSession,\n sessionCompletions,\n slotFills,\n TRIGGER_CHARS,\n} from '@agimon-ai/po-web-dashboard/core';\nimport { type ComponentType, useEffect, useEffectEvent, useState } from 'react';\nimport { Pressable, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\n/** The phone's way into `@`, `$` and `/`: what each kind is called and what it is for. */\nconst KINDS: readonly { kind: CompletionKind; title: string; hint: string; search: string; none: string }[] = [\n {\n kind: 'file',\n title: 'Files and sessions',\n hint: 'Point Po at a file in this folder or another session',\n search: 'Search files and sessions',\n none: 'No files or sessions match',\n },\n { kind: 'skill', title: 'Skills', hint: 'Use one of your skills', search: 'Search skills', none: 'No skills match' },\n {\n kind: 'command',\n title: 'Slash commands',\n hint: 'Run a session command',\n search: 'Search commands',\n none: 'No commands match',\n },\n];\n/** The hub is a tunnel away, so wait for a pause in typing before asking it. */\nconst FILE_SEARCH_DEBOUNCE_MS = 150;\n\nexport interface CompletionSource {\n commands: readonly CommandInfo[];\n searchFiles: (query: string) => Promise<string[]>;\n /** Sessions `@` may name, offered before files. */\n sessions?: () => readonly MentionableSession[];\n}\n\n/** A row a plugin adds after the three kinds, and the page it opens in this sheet. */\ninterface InsertPage {\n key: string;\n title: string;\n hint: string;\n glyph: string;\n component: ComponentType<WebPluginSlotProps>;\n}\n\nfunction textField(data: unknown, key: string): string | undefined {\n if (typeof data !== 'object' || data === null) return undefined;\n const value: unknown = Reflect.get(data, key);\n return typeof value === 'string' ? value : undefined;\n}\n\n/**\n * The phone's `composer-menu` fills. The cockpit draws a fill's component as the\n * menu row itself; a sheet has room for a page, so here `data.title` (with\n * optional `hint` and `glyph`) is the row and the component is the page.\n */\nfunction insertPages(sessionId: string | null): InsertPage[] {\n return slotFills(HOST_SLOTS.composerMenu, sessionId).flatMap(({ pluginId, id, data, component }) => {\n const title = textField(data, 'title');\n if (!component || title === undefined) return [];\n const hint = textField(data, 'hint') ?? '';\n const glyph = textField(data, 'glyph') ?? title.charAt(0);\n return [{ key: `${pluginId}:${id}`, title, hint, glyph, component }];\n });\n}\n/** The items one kind offers for a query; files come from the hub, the rest from the session's commands. */\nexport function useCompletionItems(\n source: CompletionSource | undefined,\n kind: CompletionKind | null,\n query: string,\n): CompletionItem[] | undefined {\n const [files, setFiles] = useState<{ query: string; items: CompletionItem[] }>();\n const searchable = source?.searchFiles !== undefined;\n // Hosts rebuild searchFiles every render; an effect event keeps a streaming session from restarting the debounce forever.\n const searchFiles = useEffectEvent((text: string) => source?.searchFiles(text) ?? Promise.resolve([]));\n useEffect(() => {\n if (kind !== 'file' || !searchable) return;\n let current = true;\n const timer = setTimeout(() => {\n void searchFiles(query).then((found) => {\n if (current) setFiles({ query, items: fileCompletions(found) });\n });\n }, FILE_SEARCH_DEBOUNCE_MS);\n return () => {\n current = false;\n clearTimeout(timer);\n };\n }, [kind, query, searchable]);\n if (source === undefined || kind === null) return [];\n if (kind !== 'file') return commandCompletions(source.commands, kind, query);\n // Sessions come from memory, so they show at once; files join them when the hub answers.\n const sessions = sessionCompletions(source.sessions?.() ?? [], query);\n if (files?.query === query) return [...sessions, ...files.items];\n return sessions.length > 0 ? sessions : undefined;\n}\n\n/** Completion items as tappable rows: the name in mono, what it does beneath. */\nexport function CompletionRows({\n items,\n onPick,\n}: {\n items: readonly CompletionItem[];\n onPick: (item: CompletionItem) => void;\n}) {\n return (\n <View style={styles.list}>\n {items.map((item, index) => (\n <Pressable\n key={item.insert}\n accessibilityRole=\"button\"\n accessibilityLabel={item.detail ? `${item.label}, ${item.detail}` : item.label}\n onPress={() => onPick(item)}\n style={({ pressed }) => [styles.item, index > 0 && styles.divider, pressed && styles.pressed]}\n >\n <View style={styles.flex}>\n <Text style={styles.itemLabel} numberOfLines={1} ellipsizeMode=\"middle\">\n {item.label}\n </Text>\n {item.detail ? (\n <Text style={styles.meta} numberOfLines={1}>\n {item.detail}\n </Text>\n ) : null}\n </View>\n </Pressable>\n ))}\n </View>\n );\n}\n\nexport interface CompletionSheetProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n source: CompletionSource;\n onPick: (kind: CompletionKind, item: CompletionItem) => void;\n /** Opens on one kind's search rather than the choice of kinds. */\n defaultKind?: CompletionKind;\n defaultQuery?: string;\n /** Opens on a plugin page, keyed `<pluginId>:<fillId>`. */\n defaultPage?: string;\n /** The session's plugin props; with them, its `composer-menu` fills join the list. */\n slotProps?: WebPluginSlotProps;\n /** Rows after the pages that close the sheet and run, such as attaching a photo or file. */\n actions?: readonly InsertAction[];\n}\n\nexport interface InsertAction {\n key: string;\n glyph: string;\n title: string;\n hint: string;\n onPress: () => void;\n}\n\n/** The magic button's sheet: choose Files, Skills, Slash commands, a plugin page or an attachment, then pick one. */\nexport function CompletionSheet({\n open,\n onOpenChange,\n source,\n onPick,\n defaultKind,\n defaultQuery = '',\n defaultPage,\n slotProps,\n actions = [],\n}: CompletionSheetProps) {\n const [kind, setKind] = useState<CompletionKind | null>(defaultKind ?? null);\n const [pageKey, setPageKey] = useState<string | null>(defaultPage ?? null);\n const [query, setQuery] = useState(defaultQuery);\n const items = useCompletionItems(source, kind, query);\n const page = KINDS.find((entry) => entry.kind === kind);\n const pages = slotProps ? insertPages(slotProps.sessionId) : [];\n const plugin = pages.find((entry) => entry.key === pageKey);\n\n const choose = (next: CompletionKind | null) => {\n setKind(next);\n setPageKey(null);\n setQuery('');\n };\n const close = (next: boolean) => {\n if (!next) choose(null);\n onOpenChange(next);\n };\n const rows = [\n ...KINDS.map((entry) => ({\n key: entry.kind,\n glyph: TRIGGER_CHARS[entry.kind],\n title: entry.title,\n hint: entry.hint,\n onPress: () => choose(entry.kind),\n })),\n ...pages.map((entry) => ({ ...entry, onPress: () => setPageKey(entry.key) })),\n ...actions.map((entry) => ({\n ...entry,\n onPress: () => {\n close(false);\n entry.onPress();\n },\n })),\n ];\n\n return (\n <Sheet open={open} onOpenChange={close}>\n <SheetContent>\n <View style={styles.head}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel=\"Back to insert\"\n onPress={() => choose(null)}\n disabled={page === undefined && plugin === undefined}\n style={[styles.back, page === undefined && plugin === undefined && styles.hidden]}\n >\n <View style={styles.flip}>\n <ChevronRightIcon size={18} color=\"hi\" />\n </View>\n </Pressable>\n <Text style={styles.title} accessibilityRole=\"header\">\n {page?.title ?? plugin?.title ?? 'Insert'}\n </Text>\n <View style={[styles.back, styles.hidden]} />\n </View>\n {plugin && slotProps ? (\n <plugin.component\n {...slotProps}\n appendComposerDraft={(text) => {\n slotProps.appendComposerDraft(text);\n close(false);\n }}\n />\n ) : (\n <View style={styles.body}>\n {page === undefined ? (\n <View style={styles.list}>\n {rows.map((entry, index) => (\n <Pressable\n key={entry.key}\n accessibilityRole=\"button\"\n accessibilityLabel={entry.hint ? `${entry.title}, ${entry.hint}` : entry.title}\n onPress={entry.onPress}\n style={({ pressed }) => [styles.item, index > 0 && styles.divider, pressed && styles.pressed]}\n >\n <View style={styles.glyph}>\n <Text style={styles.glyphText}>{entry.glyph}</Text>\n </View>\n <View style={styles.flex}>\n <Text style={styles.kindLabel}>{entry.title}</Text>\n {entry.hint ? <Text style={styles.meta}>{entry.hint}</Text> : null}\n </View>\n <ChevronRightIcon size={16} color=\"faint\" />\n </Pressable>\n ))}\n </View>\n ) : (\n <>\n <Input\n value={query}\n onChangeText={setQuery}\n placeholder={page.search}\n accessibilityLabel={page.search}\n autoFocus\n autoCapitalize=\"none\"\n autoCorrect={false}\n />\n {items === undefined ? (\n <View style={styles.waiting}>\n <Spinner size=\"small\" color=\"dim\" label=\"Searching\" />\n </View>\n ) : items.length === 0 ? (\n <Text style={styles.none}>{page.none}</Text>\n ) : (\n <CompletionRows\n items={items}\n onPick={(item) => {\n onPick(page.kind, item);\n close(false);\n }}\n />\n )}\n </>\n )}\n </View>\n )}\n </SheetContent>\n </Sheet>\n );\n}\n\n/** The composer's round button that opens the sheet. */\nexport function CompletionButton({ onPress }: { onPress: () => void }) {\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel=\"Insert or attach\"\n onPress={onPress}\n hitSlop={6}\n style={({ pressed }) => [styles.magic, pressed && styles.magicPressed]}\n >\n <SparklesIcon size={16} color=\"green\" />\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => {\n const sans = fontOf(theme.fontFamily.sans);\n const mono = fontOf(theme.fontFamily.mono);\n const text = (size: 'sm' | 'base' | 'lg', color: string) => ({\n fontFamily: sans,\n fontSize: theme.fontSize[size],\n lineHeight: theme.lineHeight[size],\n color,\n });\n return {\n flex: { flex: 1, minWidth: 0 },\n hidden: { opacity: 0 },\n flip: { transform: [{ rotate: '180deg' }] },\n head: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: theme.spacing(3),\n paddingBottom: theme.spacing(2),\n },\n back: { width: 36, height: 36, alignItems: 'center', justifyContent: 'center' },\n title: { ...text('lg', theme.colors.hi), fontWeight: theme.fontWeight.semibold, flex: 1, textAlign: 'center' },\n body: { gap: theme.spacing(3), paddingHorizontal: theme.spacing(4), paddingBottom: theme.spacing(4) },\n list: {\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.bg,\n overflow: 'hidden',\n },\n item: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(3),\n minHeight: 48,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(2.5),\n },\n divider: { borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: theme.colors['border-soft'] },\n pressed: { backgroundColor: theme.colors['tint-green'] },\n glyph: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors['tint-green'],\n },\n glyphText: { ...text('lg', theme.colors.green), fontFamily: mono, fontWeight: theme.fontWeight.semibold },\n kindLabel: { ...text('base', theme.colors.hi), fontWeight: theme.fontWeight.medium },\n itemLabel: { ...text('base', theme.colors.hi), fontFamily: mono },\n meta: text('sm', theme.colors.dim),\n none: { ...text('base', theme.colors.dim), textAlign: 'center', paddingVertical: theme.spacing(4) },\n waiting: { alignItems: 'center', paddingVertical: theme.spacing(6) },\n magic: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors['tint-green'],\n },\n magicPressed: { opacity: 0.7 },\n };\n});\n"],"mappings":";;;;;;;;;;;AA2BA,MAAMuB,QAAwG;CAC5G;EACEC,MAAM;EACNC,OAAO;EACPC,MAAM;EACNC,QAAQ;EACRC,MAAM;CACR;CACA;EAAEJ,MAAM;EAASC,OAAO;EAAUC,MAAM;EAA0BC,QAAQ;EAAiBC,MAAM;CAAkB;CACnH;EACEJ,MAAM;EACNC,OAAO;EACPC,MAAM;EACNC,QAAQ;EACRC,MAAM;CACR;AAAC;;AAGH,MAAMC,0BAA0B;AAkBhC,SAASW,UAAUC,MAAeJ,KAAiC;CACjE,IAAI,OAAOI,SAAS,YAAYA,SAAS,MAAM,OAAOC;CACtD,MAAMC,QAAiBC,QAAQC,IAAIJ,MAAMJ,GAAG;CAC5C,OAAO,OAAOM,UAAU,WAAWA,QAAQD;AAC7C;;;;;;AAOA,SAASI,YAAYC,WAAwC;CAC3D,OAAO/B,UAAUH,WAAWmC,cAAcD,SAAS,CAAC,CAACE,SAAS,EAAEC,UAAUC,IAAIV,MAAMF,gBAAgB;EAClG,MAAMd,QAAQe,UAAUC,MAAM,OAAO;EACrC,IAAI,CAACF,aAAad,UAAUiB,QAAW,OAAO,CAAA;EAC9C,MAAMhB,OA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AAMe,QAAQ,CAAC;GAACE,mBAAA,CAAA,CAAA;EAAC;EAClGtB,SAAS;GAAEkB,YAAY;GAAUsB,iBAAiBnC,MAAMe,QAAQ,CAAC;GAACE,mBAAA,CAAA,CAAA;EAAC;EACnEpB,OAAO;GACLqB,OAAO;GACPC,QAAQ;GACRQ,cAAc;GACdd,YAAY;GACZO,gBAAgB;GAChBW,iBAAiB/B,MAAMqB,OAAO;GAAaJ,mBAAA,CAAA,CAAA;EAC7C;EACAnB,cAAc,EAAEW,SAAS,GAAI;CAC/B;AACF,CAAC"}
|
|
@@ -15,6 +15,8 @@ export interface ComposerProps {
|
|
|
15
15
|
/** Runtime controls subscribe here, outside the navigator and transcript. */
|
|
16
16
|
live?: boolean;
|
|
17
17
|
searchFiles?: (query: string) => Promise<string[]>;
|
|
18
|
+
/** Sessions `@` may name, offered before files. */
|
|
19
|
+
mentionSessions?: CompletionSource['sessions'];
|
|
18
20
|
/** Stores a picked file on the host and returns its path; without it the File option reports it is unavailable. */
|
|
19
21
|
uploadAttachment?: (sessionId: string, file: {
|
|
20
22
|
name: string;
|
|
@@ -42,6 +44,6 @@ export interface ComposerProps {
|
|
|
42
44
|
quiet?: boolean;
|
|
43
45
|
}
|
|
44
46
|
/** The text box, then the options button and Send in one row outside it. Context and cost sit in the options sheet. */
|
|
45
|
-
export declare function Composer({ onSend, disabled, initialText, value, onChangeText, running: suppliedRunning, onAbort, mode: suppliedMode, onOpenOptions, completion: suppliedCompletion, draftStore, sessionId, live, searchFiles, uploadAttachment, slotProps, captures, onRemoveCapture, quiet }: ComposerProps): string | number | bigint | boolean |
|
|
47
|
+
export declare function Composer({ onSend, disabled, initialText, value, onChangeText, running: suppliedRunning, onAbort, mode: suppliedMode, onOpenOptions, completion: suppliedCompletion, draftStore, sessionId, live, searchFiles, mentionSessions, uploadAttachment, slotProps, captures, onRemoveCapture, quiet }: ComposerProps): string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
46
48
|
//#endregion
|
|
47
49
|
//# sourceMappingURL=Composer.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Composer.d.mts","names":[],"sources":["../../src/components/Composer.tsx"],"mappings":";;;;iBAiDiB;;EAEf,SAAS;EACT;EACA;;EAEA;EACA,gBAAgB;EAChB,aAAa,MAAM;EACnB;;EAEA;EACA,eAAe,kBAAkB;;EAEjC,oBACE,mBACA;IAAQ;IAAc;IAAkB,OAAO,WAAW;QACvD;IAAU;IAAc;IAAkB;;;EAE/C;EACA;;EAEA;EACA;;EAEA,aAAa;;EAEb,YAAY;;EAEZ,oBAAoB;EACpB,mBAAmB,SAAS;;EAE5B;;;wBAkBc,WACd,QACA,UACA,aACA,OACA,cACA,SAAS,iBACT,SACA,MAAM,cACN,eACA,YAAY,oBACZ,YACA,WACA,MACA,aACA,kBACA,WACA,UACA,iBACA,SACC,
|
|
1
|
+
{"version":3,"file":"Composer.d.mts","names":[],"sources":["../../src/components/Composer.tsx"],"mappings":";;;;iBAiDiB;;EAEf,SAAS;EACT;EACA;;EAEA;EACA,gBAAgB;EAChB,aAAa,MAAM;EACnB;;EAEA;EACA,eAAe,kBAAkB;;EAEjC,kBAAkB;;EAElB,oBACE,mBACA;IAAQ;IAAc;IAAkB,OAAO,WAAW;QACvD;IAAU;IAAc;IAAkB;;;EAE/C;EACA;;EAEA;EACA;;EAEA,aAAa;;EAEb,YAAY;;EAEZ,oBAAoB;EACpB,mBAAmB,SAAS;;EAE5B;;;wBAkBc,WACd,QACA,UACA,aACA,OACA,cACA,SAAS,iBACT,SACA,MAAM,cACN,eACA,YAAY,oBACZ,YACA,WACA,MACA,aACA,iBACA,kBACA,WACA,UACA,iBACA,SACC,qDAAa,yBAAA,aAAA,6DAAA,8BAAA,+CAAA,8BAAA,yBAAA,iDAAA,IAAA"}
|
|
@@ -44,7 +44,7 @@ function withCompletion(text, caret, kind, item) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
/** The text box, then the options button and Send in one row outside it. Context and cost sit in the options sheet. */
|
|
47
|
-
function Composer({ onSend, disabled = false, initialText = "", value, onChangeText, running: suppliedRunning = false, onAbort, mode: suppliedMode, onOpenOptions, completion: suppliedCompletion, draftStore, sessionId = "", live = false, searchFiles, uploadAttachment, slotProps, captures = NO_CAPTURES, onRemoveCapture, quiet }) {
|
|
47
|
+
function Composer({ onSend, disabled = false, initialText = "", value, onChangeText, running: suppliedRunning = false, onAbort, mode: suppliedMode, onOpenOptions, completion: suppliedCompletion, draftStore, sessionId = "", live = false, searchFiles, mentionSessions, uploadAttachment, slotProps, captures = NO_CAPTURES, onRemoveCapture, quiet }) {
|
|
48
48
|
useRenderTrace("Composer");
|
|
49
49
|
const [localText, setLocalText] = useState(initialText);
|
|
50
50
|
const storedText = useStore(draftStore ?? EMPTY_DRAFT_STORE, (state) => state[sessionId] ?? initialText);
|
|
@@ -59,10 +59,12 @@ function Composer({ onSend, disabled = false, initialText = "", value, onChangeT
|
|
|
59
59
|
const commands = useStore(store, (state) => live ? state.commands : void 0);
|
|
60
60
|
const completion = useMemo(() => commands && searchFiles ? {
|
|
61
61
|
commands,
|
|
62
|
-
searchFiles
|
|
62
|
+
searchFiles,
|
|
63
|
+
sessions: mentionSessions
|
|
63
64
|
} : suppliedCompletion, [
|
|
64
65
|
commands,
|
|
65
66
|
searchFiles,
|
|
67
|
+
mentionSessions,
|
|
66
68
|
suppliedCompletion
|
|
67
69
|
]);
|
|
68
70
|
const running = live ? liveRunning : suppliedRunning;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Composer.mjs","names":["ComposerCapture","WebPluginSlotProps","Button","ChevronDownIcon","fontOf","PlusIcon","SendIcon","StopIcon","Textarea","CompletionItem","CompletionKind","HOST_SLOTS","renderRegion","slotFills","triggerTokenAt","sessionStoreFor","parseSelection","useRenderTrace","useStore","Store","addClipboardListener","ContentType","GetImageOptions","getImageAsync","hasImageAsync","getDocumentAsync","File","launchImageLibraryAsync","useEffect","useMemo","useState","Alert","StyleSheet","CaptureTray","CompletionButton","CompletionRows","CompletionSheet","CompletionSource","useCompletionItems","PASTED_IMAGE_SOURCE","PICKED_IMAGE_SOURCE","uploadedFileContext","PASTED_IMAGE_OPTIONS","format","jpegQuality","MAX_CAPTURES","MAX_UPLOAD_BYTES","NO_CAPTURES","EMPTY_DRAFT_STORE","Record","ComposerProps","onSend","text","disabled","initialText","value","onChangeText","draftStore","sessionId","live","searchFiles","query","Promise","uploadAttachment","file","name","mimeType","bytes","Uint8Array","ArrayBuffer","path","size","running","onAbort","mode","onOpenOptions","completion","slotProps","captures","onRemoveCapture","capture","quiet","withCompletion","caret","kind","item","rest","replace","insert","length","before","slice","space","test","Composer","suppliedRunning","suppliedMode","suppliedCompletion","localText","setLocalText","storedText","state","setText","next","setState","store","liveRunning","streaming","liveMode","statuses","majorMode","undefined","commands","selection","setSelection","sheetOpen","setSheetOpen","focused","setFocused","clipboardImage","setClipboardImage","attachError","setAttachError","attaching","setAttaching","attachCapture","attachComposerCapture","attachContext","attachComposerContext","canPaste","then","has","subscription","contentTypes","includes","IMAGE","remove","pasteImage","image","data","indexOf","context","source","id","Date","now","label","content","error","Error","message","pickPhotos","result","mediaTypes","allowsMultipleSelection","selectionLimit","base64","quality","canceled","assets","forEach","asset","index","pickFile","copyToCacheDirectory","uri","stored","runAttach","pick","catch","finally","canAttach","Boolean","canAttachPhoto","attachActions","key","glyph","title","hint","onPress","chooseAttachment","alert","style","const","Math","min","trigger","suggestions","accept","start","canSend","trim","send","dock","styles","box","plain","quietInput","input","event","nativeEvent","end","row","busy","pressed","attach","options","optionsText","flex","composerActions","map","pluginId","component","Action","sendText","composerRegion","create","theme","rt","sans","fontFamily","gap","spacing","paddingHorizontal","paddingTop","paddingBottom","insets","ime","bottom","backgroundColor","colors","bg","uni__dependencies","minHeight","maxHeight","paddingVertical","borderRadius","borderWidth","borderColor","border","color","fontSize","lg","lineHeight","flexGrow","flexDirection","alignItems","height","maxWidth","flexShrink","opacity","width","justifyContent","base","fontWeight","semibold","green","sm","red"],"sources":["../../src/components/Composer.tsx"],"sourcesContent":["import type { ComposerCapture, WebPluginSlotProps } from '@agimon-ai/po-core/web';\nimport {\n Button,\n ChevronDownIcon,\n fontOf,\n PlusIcon,\n SendIcon,\n StopIcon,\n Textarea,\n} from '@agimon-ai/po-native-components';\nimport {\n type CompletionItem,\n type CompletionKind,\n HOST_SLOTS,\n renderRegion,\n slotFills,\n triggerTokenAt,\n sessionStoreFor,\n parseSelection,\n useRenderTrace,\n} from '@agimon-ai/po-web-dashboard/core';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\nimport { addClipboardListener, ContentType, type GetImageOptions, getImageAsync, hasImageAsync } from 'expo-clipboard';\nimport { getDocumentAsync } from 'expo-document-picker';\nimport { File } from 'expo-file-system';\nimport { launchImageLibraryAsync } from 'expo-image-picker';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Alert, Pressable, ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { CaptureTray } from './CaptureTray';\nimport {\n CompletionButton,\n CompletionRows,\n CompletionSheet,\n type CompletionSource,\n useCompletionItems,\n} from './CompletionSheet';\nimport { PASTED_IMAGE_SOURCE, PICKED_IMAGE_SOURCE, uploadedFileContext } from './slotProps';\n\n// JPEG keeps a pasted photo well under the 10 MB image limit; screenshots stay readable.\nconst PASTED_IMAGE_OPTIONS: GetImageOptions = { format: 'jpeg', jpegQuality: 0.8 };\n// ponytail: the attachment budget (stageNativeCapture) fits four images with no other context; the error covers less.\nconst MAX_CAPTURES = 4;\n// The host's upload limit; checked before reading so a huge file never loads into memory.\nconst MAX_UPLOAD_BYTES = 8 * 1024 * 1024;\nconst NO_CAPTURES: readonly ComposerCapture[] = [];\nconst EMPTY_DRAFT_STORE = new Store<Record<string, string>>({});\nexport interface ComposerProps {\n /** Returning false means it was not sent, so the draft stays. */\n onSend: (text: string) => boolean | void;\n disabled?: boolean;\n initialText?: string;\n /** A session host may retain the draft while a prompt temporarily replaces this composer. */\n value?: string;\n onChangeText?: (text: string) => void;\n draftStore?: Store<Record<string, string>>;\n sessionId?: string;\n /** Runtime controls subscribe here, outside the navigator and transcript. */\n live?: boolean;\n searchFiles?: (query: string) => Promise<string[]>;\n /** Stores a picked file on the host and returns its path; without it the File option reports it is unavailable. */\n uploadAttachment?: (\n sessionId: string,\n file: { name: string; mimeType: string; bytes: Uint8Array<ArrayBuffer> },\n ) => Promise<{ path: string; mimeType: string; size: number }>;\n /** A run is in progress: Send steers it and Abort stops it. */\n running?: boolean;\n onAbort?: () => void;\n /** The current major mode, shown on the options button. */\n mode?: string;\n onOpenOptions?: () => void;\n /** Offers `@` files, `$` skills and `/` commands while typing and from the insert button. */\n completion?: CompletionSource;\n /** The session's plugin props, so plugin pages can join the insert sheet. */\n slotProps?: WebPluginSlotProps;\n /** Images staged for the next message, shown as thumbnails above the text box. */\n captures?: readonly ComposerCapture[];\n onRemoveCapture?: (capture: ComposerCapture) => void;\n /** One outlined box holding the text and its controls, with an icon Send; absent keeps the default layout. */\n quiet?: boolean;\n}\n\n/** The draft with a picked item in place: commands and skills lead the message, files go where the caret is. */\nfunction withCompletion(text: string, caret: number, kind: CompletionKind, item: CompletionItem) {\n if (kind !== 'file') {\n const rest = text.replace(/^[/$]\\S*\\s*/u, '');\n return { text: `${item.insert}${rest}`, caret: item.insert.length };\n }\n const before = text.slice(0, caret);\n const space = before === '' || /\\s$/u.test(before) ? '' : ' ';\n return {\n text: `${before}${space}${item.insert}${text.slice(caret)}`,\n caret: before.length + space.length + item.insert.length,\n };\n}\n\n/** The text box, then the options button and Send in one row outside it. Context and cost sit in the options sheet. */\nexport function Composer({\n onSend,\n disabled = false,\n initialText = '',\n value,\n onChangeText,\n running: suppliedRunning = false,\n onAbort,\n mode: suppliedMode,\n onOpenOptions,\n completion: suppliedCompletion,\n draftStore,\n sessionId = '',\n live = false,\n searchFiles,\n uploadAttachment,\n slotProps,\n captures = NO_CAPTURES,\n onRemoveCapture,\n quiet,\n}: ComposerProps) {\n useRenderTrace('Composer');\n const [localText, setLocalText] = useState(initialText);\n const storedText = useStore(draftStore ?? EMPTY_DRAFT_STORE, (state) => state[sessionId] ?? initialText);\n const text = draftStore ? storedText : (value ?? localText);\n const setText = draftStore\n ? (next: string) =>\n draftStore.setState((state) => (state[sessionId] === next ? state : { ...state, [sessionId]: next }))\n : (onChangeText ?? setLocalText);\n const store = sessionStoreFor(sessionId);\n const liveRunning = useStore(store, (state) => live && state.streaming);\n const liveMode = useStore(store, (state) =>\n live ? parseSelection(state.statuses['po-major-mode'] ?? '').majorMode : undefined,\n );\n const commands = useStore(store, (state) => (live ? state.commands : undefined));\n const completion = useMemo(\n () => (commands && searchFiles ? { commands, searchFiles } : suppliedCompletion),\n [commands, searchFiles, suppliedCompletion],\n );\n const running = live ? liveRunning : suppliedRunning;\n const mode = live ? liveMode : suppliedMode;\n const [selection, setSelection] = useState<number>();\n const [sheetOpen, setSheetOpen] = useState(false);\n const [focused, setFocused] = useState(false);\n const [clipboardImage, setClipboardImage] = useState(false);\n const [attachError, setAttachError] = useState<string>();\n const [attaching, setAttaching] = useState(false);\n const attachCapture = slotProps?.attachComposerCapture;\n const attachContext = slotProps?.attachComposerContext;\n const canPaste = focused && attachCapture !== undefined;\n // The Paste tile shows only while typing, and only when the clipboard holds an image.\n useEffect(() => {\n if (!canPaste) return;\n let live = true;\n hasImageAsync().then(\n (has) => live && setClipboardImage(has),\n // An unreadable clipboard offers nothing to paste, so hide the chip.\n () => live && setClipboardImage(false),\n );\n const subscription = addClipboardListener(({ contentTypes }) =>\n setClipboardImage(contentTypes.includes(ContentType.IMAGE)),\n );\n return () => {\n live = false;\n subscription.remove();\n };\n }, [canPaste]);\n const pasteImage = (image: { data: string } | null) => {\n if (!attachCapture) return;\n // iOS silently refuses an old copy (or a declined prompt); a fresh copy reads fine.\n if (!image) return setAttachError('Could not read the image. Copy it again, then paste.');\n try {\n attachCapture({\n data: image.data.slice(image.data.indexOf(',') + 1),\n mimeType: 'image/jpeg',\n context: {\n kind: 'image',\n source: PASTED_IMAGE_SOURCE,\n id: `paste-${Date.now()}`,\n label: 'Pasted image',\n content: 'An image pasted from the clipboard.',\n },\n });\n setAttachError(undefined);\n } catch (error) {\n setAttachError(error instanceof Error ? error.message : 'Could not attach the image.');\n }\n };\n // Photos ride along as images; base64 always comes back as JPEG, even for HEIC originals.\n const pickPhotos = async () => {\n if (!attachCapture) return;\n const result = await launchImageLibraryAsync({\n mediaTypes: ['images'],\n allowsMultipleSelection: true,\n selectionLimit: MAX_CAPTURES - captures.length,\n base64: true,\n quality: 0.8,\n });\n if (result.canceled) return;\n result.assets.forEach((asset, index) => {\n if (!asset.base64) throw new Error('Could not read the photo.');\n attachCapture({\n data: asset.base64,\n mimeType: 'image/jpeg',\n context: {\n kind: 'image',\n source: PICKED_IMAGE_SOURCE,\n id: `photo-${Date.now()}-${index}`,\n label: 'Photo',\n content: 'An image attached from the photo library.',\n },\n });\n });\n };\n // Other files are stored on the host, as on web, and the message carries their path.\n const pickFile = async () => {\n if (!attachContext) return;\n if (!uploadAttachment) throw new Error('Attaching files is not available here.');\n const result = await getDocumentAsync({ copyToCacheDirectory: true });\n if (result.canceled) return;\n const [asset] = result.assets;\n const file = new File(asset.uri);\n if ((asset.size ?? file.size) > MAX_UPLOAD_BYTES) throw new Error('The file is over the 8 MB upload limit.');\n const stored = await uploadAttachment(sessionId, {\n name: asset.name,\n mimeType: asset.mimeType || 'application/octet-stream',\n bytes: await file.bytes(),\n });\n attachContext(uploadedFileContext(asset.name, stored));\n };\n const runAttach = (pick: () => Promise<void>) => {\n setAttaching(true);\n setAttachError(undefined);\n pick()\n .catch((error: unknown) => setAttachError(error instanceof Error ? error.message : 'Could not attach.'))\n .finally(() => setAttaching(false));\n };\n const canAttach = Boolean(attachContext && sessionId && !disabled && !attaching);\n const canAttachPhoto = Boolean(attachCapture && captures.length < MAX_CAPTURES);\n // The Insert sheet carries these rows; the alert is the fallback when a session offers no completions.\n const attachActions = canAttach\n ? [\n ...(canAttachPhoto\n ? [\n {\n key: 'attach-photo',\n glyph: '+',\n title: 'Photo',\n hint: 'Attach one from your library',\n onPress: () => runAttach(pickPhotos),\n },\n ]\n : []),\n {\n key: 'attach-file',\n glyph: '+',\n title: 'Upload a file',\n hint: 'Send a file from this phone',\n onPress: () => runAttach(pickFile),\n },\n ]\n : [];\n const chooseAttachment = () =>\n Alert.alert('Attach', undefined, [\n ...(canAttachPhoto ? [{ text: 'Photo', onPress: () => runAttach(pickPhotos) }] : []),\n { text: 'File', onPress: () => runAttach(pickFile) },\n { text: 'Cancel', style: 'cancel' as const },\n ]);\n const caret = Math.min(selection ?? text.length, text.length);\n const trigger = completion ? triggerTokenAt(text, caret) : null;\n const suggestions = useCompletionItems(completion, trigger?.kind ?? null, trigger?.query ?? '');\n const accept = (item: CompletionItem) => {\n if (!trigger) return;\n const next = `${text.slice(0, trigger.start)}${item.insert}${text.slice(caret)}`;\n setText(next);\n setSelection(trigger.start + item.insert.length);\n };\n const insert = (kind: CompletionKind, item: CompletionItem) => {\n const next = withCompletion(text, caret, kind, item);\n setText(next.text);\n setSelection(next.caret);\n };\n const canSend = !disabled && text.trim().length > 0;\n const send = () => {\n if (!canSend) return;\n if (onSend(text.trim()) === false) return;\n setText('');\n };\n const dock = (\n <View style={styles.dock}>\n {trigger && suggestions && suggestions.length > 0 ? (\n <ScrollView style={styles.suggestions} keyboardShouldPersistTaps=\"handled\">\n <CompletionRows items={suggestions} onPick={accept} />\n </ScrollView>\n ) : null}\n {/* ponytail: iOS asks \"Allow Paste\" on each tap. expo-clipboard's ClipboardPasteButton (UIPasteControl)\n skips the prompt but rendered blank on the iOS 26.5 simulator; try it again on a device. */}\n <CaptureTray\n captures={captures}\n onPaste={\n canPaste && clipboardImage && captures.length < MAX_CAPTURES\n ? () =>\n getImageAsync(PASTED_IMAGE_OPTIONS).then(pasteImage, () =>\n setAttachError('Could not read the clipboard.'),\n )\n : undefined\n }\n onRemove={(capture) => onRemoveCapture?.(capture)}\n />\n {attachError ? <Text style={styles.attachError}>{attachError}</Text> : null}\n <View style={quiet ? styles.box : styles.plain}>\n <Textarea\n style={quiet ? styles.quietInput : styles.input}\n value={text}\n onChangeText={setText}\n onSelectionChange={(event) => setSelection(event.nativeEvent.selection.end)}\n onFocus={() => setFocused(true)}\n onBlur={() => {\n setFocused(false);\n setAttachError(undefined);\n }}\n placeholder={\n quiet\n ? running\n ? 'Interrupt the run and respond…'\n : 'Ask anything…'\n : running\n ? 'Steer the run, or queue a reply...'\n : 'Ask anything · / commands · $ skills · @ files'\n }\n accessibilityLabel=\"Message\"\n disabled={disabled}\n />\n <View style={styles.row}>\n {!completion && attachContext && sessionId && !disabled ? (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={attaching ? 'Attaching' : 'Attach a photo or file'}\n accessibilityState={{ busy: attaching, disabled: attaching }}\n disabled={attaching}\n onPress={chooseAttachment}\n hitSlop={6}\n style={({ pressed }) => [styles.attach, (pressed || attaching) && styles.pressed]}\n >\n <PlusIcon size={16} color=\"green\" />\n </Pressable>\n ) : null}\n {completion ? <CompletionButton onPress={() => setSheetOpen(true)} /> : null}\n {onOpenOptions ? (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={`Session options, ${mode ?? 'mode'}`}\n onPress={onOpenOptions}\n style={({ pressed }) => [styles.options, pressed && styles.pressed]}\n >\n <Text style={styles.optionsText} numberOfLines={1}>\n {mode || 'Options'}\n </Text>\n <ChevronDownIcon size={12} color=\"green\" />\n </Pressable>\n ) : null}\n <View style={styles.flex} />\n {/* Plugin actions, such as voice dictation, sit beside Send. */}\n {slotProps\n ? slotFills(HOST_SLOTS.composerActions, slotProps.sessionId).map(({ pluginId, id, component: Action }) =>\n Action ? <Action key={`${pluginId}:${id}`} {...slotProps} /> : null,\n )\n : null}\n {/* An icon, so Abort and Steer both fit beside the meter and dictation on a phone. */}\n {running && onAbort ? (\n <Button variant=\"danger-outline\" size=\"icon-md\" onPress={onAbort} accessibilityLabel=\"Abort the run\">\n <StopIcon size={16} color=\"red\" />\n </Button>\n ) : null}\n {quiet ? (\n <Button\n variant=\"primary\"\n size=\"icon-md\"\n onPress={send}\n disabled={!canSend}\n accessibilityLabel={running ? 'Steer' : 'Send'}\n >\n <SendIcon size={16} color=\"on-selected\" />\n </Button>\n ) : (\n <Button\n variant=\"primary\"\n size=\"md\"\n onPress={send}\n disabled={!canSend}\n accessibilityLabel={running ? 'Steer' : 'Send'}\n >\n <View style={styles.send}>\n <SendIcon size={14} color=\"on-selected\" />\n <Text style={styles.sendText}>{running ? 'Steer' : 'Send'}</Text>\n </View>\n </Button>\n )}\n </View>\n </View>\n {completion ? (\n <CompletionSheet\n open={sheetOpen}\n onOpenChange={setSheetOpen}\n source={completion}\n onPick={insert}\n slotProps={slotProps}\n actions={attachActions}\n />\n ) : null}\n </View>\n );\n // A person's own package may wrap the composer on the phone as in the cockpit.\n return slotProps ? renderRegion(HOST_SLOTS.composerRegion, dock, slotProps, slotProps.sessionId) : dock;\n}\n\nconst styles = StyleSheet.create((theme, rt) => {\n const sans = fontOf(theme.fontFamily.sans);\n return {\n flex: { flex: 1 },\n dock: {\n gap: theme.spacing(2),\n paddingHorizontal: theme.spacing(3),\n paddingTop: theme.spacing(2),\n // Clears the home indicator; the keyboard covers that edge while it is open.\n paddingBottom: theme.spacing(2) + (rt.insets.ime > 0 ? 0 : rt.insets.bottom),\n backgroundColor: theme.colors.bg,\n },\n input: {\n minHeight: 48,\n maxHeight: theme.spacing(32),\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n // Like the cockpit composer: an outline, no fill.\n borderRadius: 22,\n borderWidth: 1,\n borderColor: theme.colors.border,\n backgroundColor: 'transparent',\n color: theme.colors.text,\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n },\n plain: { gap: theme.spacing(2) },\n box: {\n gap: theme.spacing(1),\n paddingHorizontal: theme.spacing(3),\n paddingTop: theme.spacing(1),\n paddingBottom: theme.spacing(2),\n borderRadius: 22,\n borderWidth: 1,\n borderColor: theme.colors.border,\n },\n quietInput: {\n minHeight: 44,\n maxHeight: theme.spacing(32),\n paddingHorizontal: theme.spacing(1),\n paddingVertical: theme.spacing(2),\n borderWidth: 0,\n backgroundColor: 'transparent',\n color: theme.colors.text,\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n },\n suggestions: { maxHeight: 4 * 56, flexGrow: 0 },\n row: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2) },\n options: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(1.5),\n height: 32,\n maxWidth: 170,\n flexShrink: 1,\n paddingHorizontal: theme.spacing(3),\n borderRadius: 16,\n backgroundColor: theme.colors['tint-green'],\n },\n pressed: { opacity: 0.7 },\n attach: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors['tint-green'],\n },\n optionsText: {\n fontFamily: sans,\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors.green,\n flexShrink: 1,\n },\n attachError: {\n fontFamily: sans,\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.red,\n },\n send: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(1.5) },\n sendText: {\n fontFamily: sans,\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors['on-selected'],\n },\n };\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM0C,uBAAwC;CAAEC,QAAQ;CAAQC,aAAa;AAAI;AAEjF,MAAMC,eAAe;AAErB,MAAMC,mBAAmB;AACzB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zE1B,SAAS;GACPuC,eAAe;GACfC,YAAY;GACZzB,KAAKJ,MAAMK,QAAQ,GAAG;GACtByB,QAAQ;GACRC,UAAU;GACVC,YAAY;GACZ1B,mBAAmBN,MAAMK,QAAQ,CAAC;GAClCc,cAAc;GACdP,iBAAiBZ,MAAMa,OAAO;GAAaE,mBAAA,CAAA,CAAA;EAC7C;EACA5B,SAAS,EAAE8C,SAAS,GAAI;EACxB7C,QAAQ;GACN8C,OAAO;GACPJ,QAAQ;GACRX,cAAc;GACdU,YAAY;GACZM,gBAAgB;GAChBvB,iBAAiBZ,MAAMa,OAAO;GAAaE,mBAAA,CAAA,CAAA;EAC7C;EACAzB,aAAa;GACXa,YAAYD;GACZsB,UAAUxB,MAAMwB,SAASY;GACzBV,YAAY1B,MAAM0B,WAAWU;GAC7BC,YAAYrC,MAAMqC,WAAWC;GAC7Bf,OAAOvB,MAAMa,OAAO0B;GACpBP,YAAY;GAACjB,mBAAA,CAAA,CAAA;EACf;EACA/G,aAAa;GACXmG,YAAYD;GACZsB,UAAUxB,MAAMwB,SAASgB;GACzBd,YAAY1B,MAAM0B,WAAWc;GAC7BjB,OAAOvB,MAAMa,OAAO4B;GAAG1B,mBAAA,CAAA,CAAA;EACzB;EACAxC,MAAM;GAAEqD,eAAe;GAAOC,YAAY;GAAUzB,KAAKJ,MAAMK,QAAQ,GAAG;GAACU,mBAAA,CAAA,CAAA;EAAC;EAC5ElB,UAAU;GACRM,YAAYD;GACZsB,UAAUxB,MAAMwB,SAASY;GACzBV,YAAY1B,MAAM0B,WAAWU;GAC7BC,YAAYrC,MAAMqC,WAAWC;GAC7Bf,OAAOvB,MAAMa,OAAO;GAAcE,mBAAA,CAAA,CAAA;EACpC;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"Composer.mjs","names":["ComposerCapture","WebPluginSlotProps","Button","ChevronDownIcon","fontOf","PlusIcon","SendIcon","StopIcon","Textarea","CompletionItem","CompletionKind","HOST_SLOTS","renderRegion","slotFills","triggerTokenAt","sessionStoreFor","parseSelection","useRenderTrace","useStore","Store","addClipboardListener","ContentType","GetImageOptions","getImageAsync","hasImageAsync","getDocumentAsync","File","launchImageLibraryAsync","useEffect","useMemo","useState","Alert","StyleSheet","CaptureTray","CompletionButton","CompletionRows","CompletionSheet","CompletionSource","useCompletionItems","PASTED_IMAGE_SOURCE","PICKED_IMAGE_SOURCE","uploadedFileContext","PASTED_IMAGE_OPTIONS","format","jpegQuality","MAX_CAPTURES","MAX_UPLOAD_BYTES","NO_CAPTURES","EMPTY_DRAFT_STORE","Record","ComposerProps","onSend","text","disabled","initialText","value","onChangeText","draftStore","sessionId","live","searchFiles","query","Promise","mentionSessions","uploadAttachment","file","name","mimeType","bytes","Uint8Array","ArrayBuffer","path","size","running","onAbort","mode","onOpenOptions","completion","slotProps","captures","onRemoveCapture","capture","quiet","withCompletion","caret","kind","item","rest","replace","insert","length","before","slice","space","test","Composer","suppliedRunning","suppliedMode","suppliedCompletion","localText","setLocalText","storedText","state","setText","next","setState","store","liveRunning","streaming","liveMode","statuses","majorMode","undefined","commands","sessions","selection","setSelection","sheetOpen","setSheetOpen","focused","setFocused","clipboardImage","setClipboardImage","attachError","setAttachError","attaching","setAttaching","attachCapture","attachComposerCapture","attachContext","attachComposerContext","canPaste","then","has","subscription","contentTypes","includes","IMAGE","remove","pasteImage","image","data","indexOf","context","source","id","Date","now","label","content","error","Error","message","pickPhotos","result","mediaTypes","allowsMultipleSelection","selectionLimit","base64","quality","canceled","assets","forEach","asset","index","pickFile","copyToCacheDirectory","uri","stored","runAttach","pick","catch","finally","canAttach","Boolean","canAttachPhoto","attachActions","key","glyph","title","hint","onPress","chooseAttachment","alert","style","const","Math","min","trigger","suggestions","accept","start","canSend","trim","send","dock","styles","box","plain","quietInput","input","event","nativeEvent","end","row","busy","pressed","attach","options","optionsText","flex","composerActions","map","pluginId","component","Action","sendText","composerRegion","create","theme","rt","sans","fontFamily","gap","spacing","paddingHorizontal","paddingTop","paddingBottom","insets","ime","bottom","backgroundColor","colors","bg","uni__dependencies","minHeight","maxHeight","paddingVertical","borderRadius","borderWidth","borderColor","border","color","fontSize","lg","lineHeight","flexGrow","flexDirection","alignItems","height","maxWidth","flexShrink","opacity","width","justifyContent","base","fontWeight","semibold","green","sm","red"],"sources":["../../src/components/Composer.tsx"],"sourcesContent":["import type { ComposerCapture, WebPluginSlotProps } from '@agimon-ai/po-core/web';\nimport {\n Button,\n ChevronDownIcon,\n fontOf,\n PlusIcon,\n SendIcon,\n StopIcon,\n Textarea,\n} from '@agimon-ai/po-native-components';\nimport {\n type CompletionItem,\n type CompletionKind,\n HOST_SLOTS,\n renderRegion,\n slotFills,\n triggerTokenAt,\n sessionStoreFor,\n parseSelection,\n useRenderTrace,\n} from '@agimon-ai/po-web-dashboard/core';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\nimport { addClipboardListener, ContentType, type GetImageOptions, getImageAsync, hasImageAsync } from 'expo-clipboard';\nimport { getDocumentAsync } from 'expo-document-picker';\nimport { File } from 'expo-file-system';\nimport { launchImageLibraryAsync } from 'expo-image-picker';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Alert, Pressable, ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { CaptureTray } from './CaptureTray';\nimport {\n CompletionButton,\n CompletionRows,\n CompletionSheet,\n type CompletionSource,\n useCompletionItems,\n} from './CompletionSheet';\nimport { PASTED_IMAGE_SOURCE, PICKED_IMAGE_SOURCE, uploadedFileContext } from './slotProps';\n\n// JPEG keeps a pasted photo well under the 10 MB image limit; screenshots stay readable.\nconst PASTED_IMAGE_OPTIONS: GetImageOptions = { format: 'jpeg', jpegQuality: 0.8 };\n// ponytail: the attachment budget (stageNativeCapture) fits four images with no other context; the error covers less.\nconst MAX_CAPTURES = 4;\n// The host's upload limit; checked before reading so a huge file never loads into memory.\nconst MAX_UPLOAD_BYTES = 8 * 1024 * 1024;\nconst NO_CAPTURES: readonly ComposerCapture[] = [];\nconst EMPTY_DRAFT_STORE = new Store<Record<string, string>>({});\nexport interface ComposerProps {\n /** Returning false means it was not sent, so the draft stays. */\n onSend: (text: string) => boolean | void;\n disabled?: boolean;\n initialText?: string;\n /** A session host may retain the draft while a prompt temporarily replaces this composer. */\n value?: string;\n onChangeText?: (text: string) => void;\n draftStore?: Store<Record<string, string>>;\n sessionId?: string;\n /** Runtime controls subscribe here, outside the navigator and transcript. */\n live?: boolean;\n searchFiles?: (query: string) => Promise<string[]>;\n /** Sessions `@` may name, offered before files. */\n mentionSessions?: CompletionSource['sessions'];\n /** Stores a picked file on the host and returns its path; without it the File option reports it is unavailable. */\n uploadAttachment?: (\n sessionId: string,\n file: { name: string; mimeType: string; bytes: Uint8Array<ArrayBuffer> },\n ) => Promise<{ path: string; mimeType: string; size: number }>;\n /** A run is in progress: Send steers it and Abort stops it. */\n running?: boolean;\n onAbort?: () => void;\n /** The current major mode, shown on the options button. */\n mode?: string;\n onOpenOptions?: () => void;\n /** Offers `@` files, `$` skills and `/` commands while typing and from the insert button. */\n completion?: CompletionSource;\n /** The session's plugin props, so plugin pages can join the insert sheet. */\n slotProps?: WebPluginSlotProps;\n /** Images staged for the next message, shown as thumbnails above the text box. */\n captures?: readonly ComposerCapture[];\n onRemoveCapture?: (capture: ComposerCapture) => void;\n /** One outlined box holding the text and its controls, with an icon Send; absent keeps the default layout. */\n quiet?: boolean;\n}\n\n/** The draft with a picked item in place: commands and skills lead the message, files go where the caret is. */\nfunction withCompletion(text: string, caret: number, kind: CompletionKind, item: CompletionItem) {\n if (kind !== 'file') {\n const rest = text.replace(/^[/$]\\S*\\s*/u, '');\n return { text: `${item.insert}${rest}`, caret: item.insert.length };\n }\n const before = text.slice(0, caret);\n const space = before === '' || /\\s$/u.test(before) ? '' : ' ';\n return {\n text: `${before}${space}${item.insert}${text.slice(caret)}`,\n caret: before.length + space.length + item.insert.length,\n };\n}\n\n/** The text box, then the options button and Send in one row outside it. Context and cost sit in the options sheet. */\nexport function Composer({\n onSend,\n disabled = false,\n initialText = '',\n value,\n onChangeText,\n running: suppliedRunning = false,\n onAbort,\n mode: suppliedMode,\n onOpenOptions,\n completion: suppliedCompletion,\n draftStore,\n sessionId = '',\n live = false,\n searchFiles,\n mentionSessions,\n uploadAttachment,\n slotProps,\n captures = NO_CAPTURES,\n onRemoveCapture,\n quiet,\n}: ComposerProps) {\n useRenderTrace('Composer');\n const [localText, setLocalText] = useState(initialText);\n const storedText = useStore(draftStore ?? EMPTY_DRAFT_STORE, (state) => state[sessionId] ?? initialText);\n const text = draftStore ? storedText : (value ?? localText);\n const setText = draftStore\n ? (next: string) =>\n draftStore.setState((state) => (state[sessionId] === next ? state : { ...state, [sessionId]: next }))\n : (onChangeText ?? setLocalText);\n const store = sessionStoreFor(sessionId);\n const liveRunning = useStore(store, (state) => live && state.streaming);\n const liveMode = useStore(store, (state) =>\n live ? parseSelection(state.statuses['po-major-mode'] ?? '').majorMode : undefined,\n );\n const commands = useStore(store, (state) => (live ? state.commands : undefined));\n const completion = useMemo(\n () => (commands && searchFiles ? { commands, searchFiles, sessions: mentionSessions } : suppliedCompletion),\n [commands, searchFiles, mentionSessions, suppliedCompletion],\n );\n const running = live ? liveRunning : suppliedRunning;\n const mode = live ? liveMode : suppliedMode;\n const [selection, setSelection] = useState<number>();\n const [sheetOpen, setSheetOpen] = useState(false);\n const [focused, setFocused] = useState(false);\n const [clipboardImage, setClipboardImage] = useState(false);\n const [attachError, setAttachError] = useState<string>();\n const [attaching, setAttaching] = useState(false);\n const attachCapture = slotProps?.attachComposerCapture;\n const attachContext = slotProps?.attachComposerContext;\n const canPaste = focused && attachCapture !== undefined;\n // The Paste tile shows only while typing, and only when the clipboard holds an image.\n useEffect(() => {\n if (!canPaste) return;\n let live = true;\n hasImageAsync().then(\n (has) => live && setClipboardImage(has),\n // An unreadable clipboard offers nothing to paste, so hide the chip.\n () => live && setClipboardImage(false),\n );\n const subscription = addClipboardListener(({ contentTypes }) =>\n setClipboardImage(contentTypes.includes(ContentType.IMAGE)),\n );\n return () => {\n live = false;\n subscription.remove();\n };\n }, [canPaste]);\n const pasteImage = (image: { data: string } | null) => {\n if (!attachCapture) return;\n // iOS silently refuses an old copy (or a declined prompt); a fresh copy reads fine.\n if (!image) return setAttachError('Could not read the image. Copy it again, then paste.');\n try {\n attachCapture({\n data: image.data.slice(image.data.indexOf(',') + 1),\n mimeType: 'image/jpeg',\n context: {\n kind: 'image',\n source: PASTED_IMAGE_SOURCE,\n id: `paste-${Date.now()}`,\n label: 'Pasted image',\n content: 'An image pasted from the clipboard.',\n },\n });\n setAttachError(undefined);\n } catch (error) {\n setAttachError(error instanceof Error ? error.message : 'Could not attach the image.');\n }\n };\n // Photos ride along as images; base64 always comes back as JPEG, even for HEIC originals.\n const pickPhotos = async () => {\n if (!attachCapture) return;\n const result = await launchImageLibraryAsync({\n mediaTypes: ['images'],\n allowsMultipleSelection: true,\n selectionLimit: MAX_CAPTURES - captures.length,\n base64: true,\n quality: 0.8,\n });\n if (result.canceled) return;\n result.assets.forEach((asset, index) => {\n if (!asset.base64) throw new Error('Could not read the photo.');\n attachCapture({\n data: asset.base64,\n mimeType: 'image/jpeg',\n context: {\n kind: 'image',\n source: PICKED_IMAGE_SOURCE,\n id: `photo-${Date.now()}-${index}`,\n label: 'Photo',\n content: 'An image attached from the photo library.',\n },\n });\n });\n };\n // Other files are stored on the host, as on web, and the message carries their path.\n const pickFile = async () => {\n if (!attachContext) return;\n if (!uploadAttachment) throw new Error('Attaching files is not available here.');\n const result = await getDocumentAsync({ copyToCacheDirectory: true });\n if (result.canceled) return;\n const [asset] = result.assets;\n const file = new File(asset.uri);\n if ((asset.size ?? file.size) > MAX_UPLOAD_BYTES) throw new Error('The file is over the 8 MB upload limit.');\n const stored = await uploadAttachment(sessionId, {\n name: asset.name,\n mimeType: asset.mimeType || 'application/octet-stream',\n bytes: await file.bytes(),\n });\n attachContext(uploadedFileContext(asset.name, stored));\n };\n const runAttach = (pick: () => Promise<void>) => {\n setAttaching(true);\n setAttachError(undefined);\n pick()\n .catch((error: unknown) => setAttachError(error instanceof Error ? error.message : 'Could not attach.'))\n .finally(() => setAttaching(false));\n };\n const canAttach = Boolean(attachContext && sessionId && !disabled && !attaching);\n const canAttachPhoto = Boolean(attachCapture && captures.length < MAX_CAPTURES);\n // The Insert sheet carries these rows; the alert is the fallback when a session offers no completions.\n const attachActions = canAttach\n ? [\n ...(canAttachPhoto\n ? [\n {\n key: 'attach-photo',\n glyph: '+',\n title: 'Photo',\n hint: 'Attach one from your library',\n onPress: () => runAttach(pickPhotos),\n },\n ]\n : []),\n {\n key: 'attach-file',\n glyph: '+',\n title: 'Upload a file',\n hint: 'Send a file from this phone',\n onPress: () => runAttach(pickFile),\n },\n ]\n : [];\n const chooseAttachment = () =>\n Alert.alert('Attach', undefined, [\n ...(canAttachPhoto ? [{ text: 'Photo', onPress: () => runAttach(pickPhotos) }] : []),\n { text: 'File', onPress: () => runAttach(pickFile) },\n { text: 'Cancel', style: 'cancel' as const },\n ]);\n const caret = Math.min(selection ?? text.length, text.length);\n const trigger = completion ? triggerTokenAt(text, caret) : null;\n const suggestions = useCompletionItems(completion, trigger?.kind ?? null, trigger?.query ?? '');\n const accept = (item: CompletionItem) => {\n if (!trigger) return;\n const next = `${text.slice(0, trigger.start)}${item.insert}${text.slice(caret)}`;\n setText(next);\n setSelection(trigger.start + item.insert.length);\n };\n const insert = (kind: CompletionKind, item: CompletionItem) => {\n const next = withCompletion(text, caret, kind, item);\n setText(next.text);\n setSelection(next.caret);\n };\n const canSend = !disabled && text.trim().length > 0;\n const send = () => {\n if (!canSend) return;\n if (onSend(text.trim()) === false) return;\n setText('');\n };\n const dock = (\n <View style={styles.dock}>\n {trigger && suggestions && suggestions.length > 0 ? (\n <ScrollView style={styles.suggestions} keyboardShouldPersistTaps=\"handled\">\n <CompletionRows items={suggestions} onPick={accept} />\n </ScrollView>\n ) : null}\n {/* ponytail: iOS asks \"Allow Paste\" on each tap. expo-clipboard's ClipboardPasteButton (UIPasteControl)\n skips the prompt but rendered blank on the iOS 26.5 simulator; try it again on a device. */}\n <CaptureTray\n captures={captures}\n onPaste={\n canPaste && clipboardImage && captures.length < MAX_CAPTURES\n ? () =>\n getImageAsync(PASTED_IMAGE_OPTIONS).then(pasteImage, () =>\n setAttachError('Could not read the clipboard.'),\n )\n : undefined\n }\n onRemove={(capture) => onRemoveCapture?.(capture)}\n />\n {attachError ? <Text style={styles.attachError}>{attachError}</Text> : null}\n <View style={quiet ? styles.box : styles.plain}>\n <Textarea\n style={quiet ? styles.quietInput : styles.input}\n value={text}\n onChangeText={setText}\n onSelectionChange={(event) => setSelection(event.nativeEvent.selection.end)}\n onFocus={() => setFocused(true)}\n onBlur={() => {\n setFocused(false);\n setAttachError(undefined);\n }}\n placeholder={\n quiet\n ? running\n ? 'Interrupt the run and respond…'\n : 'Ask anything…'\n : running\n ? 'Steer the run, or queue a reply...'\n : 'Ask anything · / commands · $ skills · @ files'\n }\n accessibilityLabel=\"Message\"\n disabled={disabled}\n />\n <View style={styles.row}>\n {!completion && attachContext && sessionId && !disabled ? (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={attaching ? 'Attaching' : 'Attach a photo or file'}\n accessibilityState={{ busy: attaching, disabled: attaching }}\n disabled={attaching}\n onPress={chooseAttachment}\n hitSlop={6}\n style={({ pressed }) => [styles.attach, (pressed || attaching) && styles.pressed]}\n >\n <PlusIcon size={16} color=\"green\" />\n </Pressable>\n ) : null}\n {completion ? <CompletionButton onPress={() => setSheetOpen(true)} /> : null}\n {onOpenOptions ? (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={`Session options, ${mode ?? 'mode'}`}\n onPress={onOpenOptions}\n style={({ pressed }) => [styles.options, pressed && styles.pressed]}\n >\n <Text style={styles.optionsText} numberOfLines={1}>\n {mode || 'Options'}\n </Text>\n <ChevronDownIcon size={12} color=\"green\" />\n </Pressable>\n ) : null}\n <View style={styles.flex} />\n {/* Plugin actions, such as voice dictation, sit beside Send. */}\n {slotProps\n ? slotFills(HOST_SLOTS.composerActions, slotProps.sessionId).map(({ pluginId, id, component: Action }) =>\n Action ? <Action key={`${pluginId}:${id}`} {...slotProps} /> : null,\n )\n : null}\n {/* An icon, so Abort and Steer both fit beside the meter and dictation on a phone. */}\n {running && onAbort ? (\n <Button variant=\"danger-outline\" size=\"icon-md\" onPress={onAbort} accessibilityLabel=\"Abort the run\">\n <StopIcon size={16} color=\"red\" />\n </Button>\n ) : null}\n {quiet ? (\n <Button\n variant=\"primary\"\n size=\"icon-md\"\n onPress={send}\n disabled={!canSend}\n accessibilityLabel={running ? 'Steer' : 'Send'}\n >\n <SendIcon size={16} color=\"on-selected\" />\n </Button>\n ) : (\n <Button\n variant=\"primary\"\n size=\"md\"\n onPress={send}\n disabled={!canSend}\n accessibilityLabel={running ? 'Steer' : 'Send'}\n >\n <View style={styles.send}>\n <SendIcon size={14} color=\"on-selected\" />\n <Text style={styles.sendText}>{running ? 'Steer' : 'Send'}</Text>\n </View>\n </Button>\n )}\n </View>\n </View>\n {completion ? (\n <CompletionSheet\n open={sheetOpen}\n onOpenChange={setSheetOpen}\n source={completion}\n onPick={insert}\n slotProps={slotProps}\n actions={attachActions}\n />\n ) : null}\n </View>\n );\n // A person's own package may wrap the composer on the phone as in the cockpit.\n return slotProps ? renderRegion(HOST_SLOTS.composerRegion, dock, slotProps, slotProps.sessionId) : dock;\n}\n\nconst styles = StyleSheet.create((theme, rt) => {\n const sans = fontOf(theme.fontFamily.sans);\n return {\n flex: { flex: 1 },\n dock: {\n gap: theme.spacing(2),\n paddingHorizontal: theme.spacing(3),\n paddingTop: theme.spacing(2),\n // Clears the home indicator; the keyboard covers that edge while it is open.\n paddingBottom: theme.spacing(2) + (rt.insets.ime > 0 ? 0 : rt.insets.bottom),\n backgroundColor: theme.colors.bg,\n },\n input: {\n minHeight: 48,\n maxHeight: theme.spacing(32),\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n // Like the cockpit composer: an outline, no fill.\n borderRadius: 22,\n borderWidth: 1,\n borderColor: theme.colors.border,\n backgroundColor: 'transparent',\n color: theme.colors.text,\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n },\n plain: { gap: theme.spacing(2) },\n box: {\n gap: theme.spacing(1),\n paddingHorizontal: theme.spacing(3),\n paddingTop: theme.spacing(1),\n paddingBottom: theme.spacing(2),\n borderRadius: 22,\n borderWidth: 1,\n borderColor: theme.colors.border,\n },\n quietInput: {\n minHeight: 44,\n maxHeight: theme.spacing(32),\n paddingHorizontal: theme.spacing(1),\n paddingVertical: theme.spacing(2),\n borderWidth: 0,\n backgroundColor: 'transparent',\n color: theme.colors.text,\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n },\n suggestions: { maxHeight: 4 * 56, flexGrow: 0 },\n row: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2) },\n options: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(1.5),\n height: 32,\n maxWidth: 170,\n flexShrink: 1,\n paddingHorizontal: theme.spacing(3),\n borderRadius: 16,\n backgroundColor: theme.colors['tint-green'],\n },\n pressed: { opacity: 0.7 },\n attach: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors['tint-green'],\n },\n optionsText: {\n fontFamily: sans,\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors.green,\n flexShrink: 1,\n },\n attachError: {\n fontFamily: sans,\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.red,\n },\n send: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(1.5) },\n sendText: {\n fontFamily: sans,\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors['on-selected'],\n },\n };\n});\n"],"mappings":";;;;;;;;;;;;;;;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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComposerCapture, TransientTab, WebPluginContextItem, WebPluginSlotProps } from "@agimon-ai/po-core/web";
|
|
2
2
|
//#region src/components/slotProps.d.ts
|
|
3
3
|
/** Capabilities bound to the session owner, never the currently focused detail. */
|
|
4
|
-
export type NativeSlotHost = Partial<Pick<WebPluginSlotProps, 'runNativeVoice' | 'nativeAudio' | 'nativeRealtime' | 'renderMediaPreview' | 'nativeSaveFile' | 'nativeAuthor' | 'renderStoryPreview' | 'renderFilePreview' | 'renderMcpApp' | 'renderRunnerTerminal' | 'attachComposerCapture' | 'submitCapture' | 'openSession' | 'openPage' | 'openWorkspace' | 'openTransientTab' | 'closeTransientTab' | 'setTransientTabSession' | 'attachComposerContext' | 'openSettings' | 'renderThread' | 'renderSessionTranscript' | 'renderSessionActivity'>>;
|
|
4
|
+
export type NativeSlotHost = Partial<Pick<WebPluginSlotProps, 'runNativeVoice' | 'nativeAudio' | 'nativeRealtime' | 'renderMediaPreview' | 'nativeSaveFile' | 'nativeAuthor' | 'renderStoryPreview' | 'renderFilePreview' | 'renderMcpApp' | 'renderRunnerTerminal' | 'attachComposerCapture' | 'submitCapture' | 'openSession' | 'openPage' | 'openWorkspace' | 'openTransientTab' | 'closeTransientTab' | 'setTransientTabSession' | 'attachComposerContext' | 'openSettings' | 'renderThread' | 'renderSessionTranscript' | 'renderSessionActivity' | 'takeComposerDraft' | 'listSessions'>>;
|
|
5
5
|
/** Reuses the DOM-free host props for nested fills, typed slot data and source-bound actions. */
|
|
6
6
|
export declare function nativeSlotProps(sessionId: string, statuses: Readonly<Record<string, string>>, openTab: (tabId: string | null) => void, appendComposerDraft?: (text: string) => void, host?: NativeSlotHost): WebPluginSlotProps;
|
|
7
7
|
/** Invalid or throwing plugin context never prevents sending, and slash actions stay unchanged. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slotProps.d.mts","names":[],"sources":["../../src/components/slotProps.ts"],"mappings":";;;YAcY,iBAAiB,QAC3B,KACE;;
|
|
1
|
+
{"version":3,"file":"slotProps.d.mts","names":[],"sources":["../../src/components/slotProps.ts"],"mappings":";;;YAcY,iBAAiB,QAC3B,KACE;;wBA8BY,gBACd,mBACA,UAAU,SAAS,yBACnB,UAAU,+BACV,uBAAsB,uBACtB,OAAM,iBACL;;wBA4Ba,sBACd,cACA,mBACA,gBAAgB,wBAChB,OAAO;;qBA+BI;;qBAEA;qBACA;;wBAGG,oBACd,cACA;EAAQ;EAAc;EAAkB;IACvC;;wBAYa,mBACd,mBAAmB,mBACnB,mBAAmB,wBACnB,SAAS,kBACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slotProps.mjs","names":[],"sources":["../../src/components/slotProps.ts"],"sourcesContent":["import type { ComposerCapture, TransientTab, WebPluginContextItem, WebPluginSlotProps } from '@agimon-ai/po-core/web';\nimport {\n closeTransientTab,\n openTransientTab,\n pluginSlotProps,\n holdVoiceSession,\n sessionMinorModes,\n validateComposerCapture,\n} from '@agimon-ai/po-web-dashboard/core';\n\nconst noop = () => {};\nconst MAX_CONTEXT_BYTES = 100 * 1024;\n\n/** Capabilities bound to the session owner, never the currently focused detail. */\nexport type NativeSlotHost = Partial<\n Pick<\n WebPluginSlotProps,\n | 'runNativeVoice'\n | 'nativeAudio'\n | 'nativeRealtime'\n | 'renderMediaPreview'\n | 'nativeSaveFile'\n | 'nativeAuthor'\n | 'renderStoryPreview'\n | 'renderFilePreview'\n | 'renderMcpApp'\n | 'renderRunnerTerminal'\n | 'attachComposerCapture'\n | 'submitCapture'\n | 'openSession'\n | 'openPage'\n | 'openWorkspace'\n | 'openTransientTab'\n | 'closeTransientTab'\n | 'setTransientTabSession'\n | 'attachComposerContext'\n | 'openSettings'\n | 'renderThread'\n | 'renderSessionTranscript'\n | 'renderSessionActivity'\n >\n>;\n\n/** Reuses the DOM-free host props for nested fills, typed slot data and source-bound actions. */\nexport function nativeSlotProps(\n sessionId: string,\n statuses: Readonly<Record<string, string>>,\n openTab: (tabId: string | null) => void,\n appendComposerDraft: (text: string) => void = noop,\n host: NativeSlotHost = {},\n): WebPluginSlotProps {\n const props = pluginSlotProps(\n sessionId,\n openTab,\n statuses,\n {\n open:\n host.openTransientTab ??\n ((tab) => {\n openTransientTab(sessionId, tab);\n openTab(tab.id);\n }),\n close:\n host.closeTransientTab ??\n ((tabId) => {\n closeTransientTab(sessionId, tabId);\n openTab(null);\n }),\n },\n appendComposerDraft,\n host.attachComposerContext ?? noop,\n );\n props.activeMinorModes = sessionMinorModes.active(sessionId);\n props.holdVoiceSession = holdVoiceSession;\n return Object.assign(props, host);\n}\n\n/** Invalid or throwing plugin context never prevents sending, and slash actions stay unchanged. */\nexport function nativeComposerMessage(\n text: string,\n sessionId: string,\n items: readonly WebPluginContextItem[],\n read?: TransientTab['composerContext'],\n): string {\n if (text.trim().startsWith('/')) return text;\n let context: WebPluginContextItem | undefined;\n try {\n context = read?.(sessionId);\n } catch {\n context = undefined; // A failed optional context read sends the person's message unchanged.\n }\n const valid = [...items, ...(context ? [context] : [])].filter(\n (item) =>\n item !== null &&\n typeof item === 'object' &&\n [item.kind, item.source, item.id, item.label, item.content].every(\n (value) => typeof value === 'string' && value.trim() !== '',\n ) &&\n new TextEncoder().encode(item.content).byteLength <= MAX_CONTEXT_BYTES,\n );\n return [\n text,\n ...valid.map(\n (item) =>\n `Referenced context \"${item.label\n .trim()\n .replace(/[\\r\\n]+/g, ' ')\n .slice(0, 200)}\":\\n\\n${item.content.trim()}`,\n ),\n ].join('\\n\\n');\n}\n\n/** Clipboard pastes follow attachment limits, as on web: the 10 MB image cap applies but not the capture pixel cap. */\nexport const PASTED_IMAGE_SOURCE = 'clipboard';\n/** Photos picked from the library are attachments too, under the same limits as pastes. */\nexport const PICKED_IMAGE_SOURCE = 'photos';\nexport const UPLOADED_FILE_SOURCE = 'upload';\n\n/** A file stored on the host, worded as web's attachmentPrompt words it, so a tool can be handed its path. */\nexport function uploadedFileContext(\n name: string,\n file: { path: string; mimeType: string; size: number },\n): WebPluginContextItem {\n const label = name.replace(/[\\r\\n]/g, ' ').slice(0, 200);\n return {\n kind: 'file',\n source: UPLOADED_FILE_SOURCE,\n id: file.path,\n label,\n content: `Attached file \"${label}\" (${file.mimeType}, ${String(file.size)} bytes) saved at ${file.path}. To send it to a tool's file parameter, pass {\"path\": ${JSON.stringify(file.path)}}.`,\n };\n}\n\n/** A capture is staged atomically with its context, without touching transport or draft. */\nexport function stageNativeCapture(\n captures: readonly ComposerCapture[],\n contexts: readonly WebPluginContextItem[],\n capture: ComposerCapture,\n): ComposerCapture[] {\n const attached = capture.context.source === PASTED_IMAGE_SOURCE || capture.context.source === PICKED_IMAGE_SOURCE;\n if (!attached) validateComposerCapture(capture);\n else if (capture.data.length > Math.ceil((10 * 1024 * 1024) / 3) * 4) {\n throw new Error('The image is over the 10 MB limit.');\n }\n const staged = [...captures, capture];\n const imageBytes = staged.reduce(\n (total, item) =>\n total + (item.data.length * 3) / 4 - (item.data.endsWith('==') ? 2 : item.data.endsWith('=') ? 1 : 0),\n 0,\n );\n const textBytes = [...contexts, ...staged.map((item) => item.context)].reduce(\n (total, item) => total + new TextEncoder().encode(item.content).byteLength,\n 0,\n );\n if (staged.length * 2 + contexts.length > 8 || imageBytes > 20 * 1024 * 1024 || textBytes > 200 * 1024) {\n throw new Error('Capture exceeds the attachment budget.');\n }\n return staged;\n}\n"],"mappings":";;;AAUA,MAAM,aAAa,CAAC;AACpB,MAAM,oBAAoB;;
|
|
1
|
+
{"version":3,"file":"slotProps.mjs","names":[],"sources":["../../src/components/slotProps.ts"],"sourcesContent":["import type { ComposerCapture, TransientTab, WebPluginContextItem, WebPluginSlotProps } from '@agimon-ai/po-core/web';\nimport {\n closeTransientTab,\n openTransientTab,\n pluginSlotProps,\n holdVoiceSession,\n sessionMinorModes,\n validateComposerCapture,\n} from '@agimon-ai/po-web-dashboard/core';\n\nconst noop = () => {};\nconst MAX_CONTEXT_BYTES = 100 * 1024;\n\n/** Capabilities bound to the session owner, never the currently focused detail. */\nexport type NativeSlotHost = Partial<\n Pick<\n WebPluginSlotProps,\n | 'runNativeVoice'\n | 'nativeAudio'\n | 'nativeRealtime'\n | 'renderMediaPreview'\n | 'nativeSaveFile'\n | 'nativeAuthor'\n | 'renderStoryPreview'\n | 'renderFilePreview'\n | 'renderMcpApp'\n | 'renderRunnerTerminal'\n | 'attachComposerCapture'\n | 'submitCapture'\n | 'openSession'\n | 'openPage'\n | 'openWorkspace'\n | 'openTransientTab'\n | 'closeTransientTab'\n | 'setTransientTabSession'\n | 'attachComposerContext'\n | 'openSettings'\n | 'renderThread'\n | 'renderSessionTranscript'\n | 'renderSessionActivity'\n | 'takeComposerDraft'\n | 'listSessions'\n >\n>;\n\n/** Reuses the DOM-free host props for nested fills, typed slot data and source-bound actions. */\nexport function nativeSlotProps(\n sessionId: string,\n statuses: Readonly<Record<string, string>>,\n openTab: (tabId: string | null) => void,\n appendComposerDraft: (text: string) => void = noop,\n host: NativeSlotHost = {},\n): WebPluginSlotProps {\n const props = pluginSlotProps(\n sessionId,\n openTab,\n statuses,\n {\n open:\n host.openTransientTab ??\n ((tab) => {\n openTransientTab(sessionId, tab);\n openTab(tab.id);\n }),\n close:\n host.closeTransientTab ??\n ((tabId) => {\n closeTransientTab(sessionId, tabId);\n openTab(null);\n }),\n },\n appendComposerDraft,\n host.attachComposerContext ?? noop,\n );\n props.activeMinorModes = sessionMinorModes.active(sessionId);\n props.holdVoiceSession = holdVoiceSession;\n return Object.assign(props, host);\n}\n\n/** Invalid or throwing plugin context never prevents sending, and slash actions stay unchanged. */\nexport function nativeComposerMessage(\n text: string,\n sessionId: string,\n items: readonly WebPluginContextItem[],\n read?: TransientTab['composerContext'],\n): string {\n if (text.trim().startsWith('/')) return text;\n let context: WebPluginContextItem | undefined;\n try {\n context = read?.(sessionId);\n } catch {\n context = undefined; // A failed optional context read sends the person's message unchanged.\n }\n const valid = [...items, ...(context ? [context] : [])].filter(\n (item) =>\n item !== null &&\n typeof item === 'object' &&\n [item.kind, item.source, item.id, item.label, item.content].every(\n (value) => typeof value === 'string' && value.trim() !== '',\n ) &&\n new TextEncoder().encode(item.content).byteLength <= MAX_CONTEXT_BYTES,\n );\n return [\n text,\n ...valid.map(\n (item) =>\n `Referenced context \"${item.label\n .trim()\n .replace(/[\\r\\n]+/g, ' ')\n .slice(0, 200)}\":\\n\\n${item.content.trim()}`,\n ),\n ].join('\\n\\n');\n}\n\n/** Clipboard pastes follow attachment limits, as on web: the 10 MB image cap applies but not the capture pixel cap. */\nexport const PASTED_IMAGE_SOURCE = 'clipboard';\n/** Photos picked from the library are attachments too, under the same limits as pastes. */\nexport const PICKED_IMAGE_SOURCE = 'photos';\nexport const UPLOADED_FILE_SOURCE = 'upload';\n\n/** A file stored on the host, worded as web's attachmentPrompt words it, so a tool can be handed its path. */\nexport function uploadedFileContext(\n name: string,\n file: { path: string; mimeType: string; size: number },\n): WebPluginContextItem {\n const label = name.replace(/[\\r\\n]/g, ' ').slice(0, 200);\n return {\n kind: 'file',\n source: UPLOADED_FILE_SOURCE,\n id: file.path,\n label,\n content: `Attached file \"${label}\" (${file.mimeType}, ${String(file.size)} bytes) saved at ${file.path}. To send it to a tool's file parameter, pass {\"path\": ${JSON.stringify(file.path)}}.`,\n };\n}\n\n/** A capture is staged atomically with its context, without touching transport or draft. */\nexport function stageNativeCapture(\n captures: readonly ComposerCapture[],\n contexts: readonly WebPluginContextItem[],\n capture: ComposerCapture,\n): ComposerCapture[] {\n const attached = capture.context.source === PASTED_IMAGE_SOURCE || capture.context.source === PICKED_IMAGE_SOURCE;\n if (!attached) validateComposerCapture(capture);\n else if (capture.data.length > Math.ceil((10 * 1024 * 1024) / 3) * 4) {\n throw new Error('The image is over the 10 MB limit.');\n }\n const staged = [...captures, capture];\n const imageBytes = staged.reduce(\n (total, item) =>\n total + (item.data.length * 3) / 4 - (item.data.endsWith('==') ? 2 : item.data.endsWith('=') ? 1 : 0),\n 0,\n );\n const textBytes = [...contexts, ...staged.map((item) => item.context)].reduce(\n (total, item) => total + new TextEncoder().encode(item.content).byteLength,\n 0,\n );\n if (staged.length * 2 + contexts.length > 8 || imageBytes > 20 * 1024 * 1024 || textBytes > 200 * 1024) {\n throw new Error('Capture exceeds the attachment budget.');\n }\n return staged;\n}\n"],"mappings":";;;AAUA,MAAM,aAAa,CAAC;AACpB,MAAM,oBAAoB;;AAmC1B,SAAgB,gBACd,WACA,UACA,SACA,sBAA8C,MAC9C,OAAuB,CAAC,GACJ;CACpB,MAAM,QAAQ,gBACZ,WACA,SACA,UACA;EACE,MACE,KAAK,sBACH,QAAQ;GACR,iBAAiB,WAAW,GAAG;GAC/B,QAAQ,IAAI,EAAE;EAChB;EACF,OACE,KAAK,uBACH,UAAU;GACV,kBAAkB,WAAW,KAAK;GAClC,QAAQ,IAAI;EACd;CACJ,GACA,qBACA,KAAK,yBAAyB,IAChC;CACA,MAAM,mBAAmB,kBAAkB,OAAO,SAAS;CAC3D,MAAM,mBAAmB;CACzB,OAAO,OAAO,OAAO,OAAO,IAAI;AAClC;;AAGA,SAAgB,sBACd,MACA,WACA,OACA,MACQ;CACR,IAAI,KAAK,KAAK,CAAC,CAAC,WAAW,GAAG,GAAG,OAAO;CACxC,IAAI;CACJ,IAAI;EACF,UAAU,OAAO,SAAS;CAC5B,QAAQ;EACN,UAAU;CACZ;CAUA,OAAO,CACL,MACA,GAXY,CAAC,GAAG,OAAO,GAAI,UAAU,CAAC,OAAO,IAAI,CAAC,CAAE,CAAC,CAAC,QACrD,SACC,SAAS,QACT,OAAO,SAAS,YAChB;EAAC,KAAK;EAAM,KAAK;EAAQ,KAAK;EAAI,KAAK;EAAO,KAAK;CAAO,CAAC,CAAC,OACzD,UAAU,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,EAC3D,KACA,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,cAAc,iBAIhD,CAAC,CAAC,KACN,SACC,uBAAuB,KAAK,MACzB,KAAK,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+3,7 @@ import { TimelineEntry as TimelineEntry$1 } from "../components/TimelineItem.mjs
|
|
|
3
3
|
import { MarkdownProps } from "@agimon-ai/po-native-components";
|
|
4
4
|
import { TimelineEntry } from "@agimon-ai/po-web-dashboard/core";
|
|
5
5
|
import { ReactElement } from "react";
|
|
6
|
-
import { ThreadViewOptions, ToolResultView } from "@agimon-ai/po-core/web";
|
|
6
|
+
import { ThreadViewOptions, ToolResultView, WebPluginSlotProps } from "@agimon-ai/po-core/web";
|
|
7
7
|
import { NativeTemplateSessionProps } from "@agimon-ai/po-core/native";
|
|
8
8
|
//#region src/screens/SessionScreen.d.ts
|
|
9
9
|
/** The tool entry fields a plugin renderer reads, carried as TimelineEntry.payload. */
|
|
@@ -29,8 +29,15 @@ export interface SessionScreenProps extends NativeTemplateSessionProps {
|
|
|
29
29
|
export interface SessionTranscript {
|
|
30
30
|
/** Called once per transcript, so the grouper can keep unchanged groups by identity between renders. */
|
|
31
31
|
createGrouper: () => (entries: readonly TimelineEntry$1[]) => TimelineEntry$1[];
|
|
32
|
-
/**
|
|
33
|
-
|
|
32
|
+
/**
|
|
33
|
+
* `entry` arrives with images the transcript sent by reference filled in once read.
|
|
34
|
+
* `builtIn` draws one entry the default way, with plugin tool cards, for rows the template keeps.
|
|
35
|
+
*/
|
|
36
|
+
renderItem: (entry: TimelineEntry$1, builtIn: (entry: TimelineEntry$1) => ReactElement,
|
|
37
|
+
/** The session's slot props, for a row that opens plugin surfaces such as Author. */
|
|
38
|
+
slotProps: WebPluginSlotProps) => ReactElement | null;
|
|
39
|
+
/** True when a row already shows the turn at work, so the screen leaves out its own Working line. */
|
|
40
|
+
showsWork?: (entries: readonly TimelineEntry$1[]) => boolean;
|
|
34
41
|
}
|
|
35
42
|
export declare function SessionScreen(props: SessionScreenProps): import("react").JSX.Element;
|
|
36
43
|
/** Each transcript owns its cache; removed dashboard entries are only weakly referenced. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionScreen.d.mts","names":["TimelineEntry","DashboardEntry"],"sources":["../../src/screens/SessionScreen.tsx"],"mappings":";;;;;;;;;iBA6DiB;EACf;EACA,MAAM;EACN,QAAQ;EACR;EACA;EACA;;;;;;iBAOe,2BAA2B;EAC1C,mBAAmBA;;EAEnB,WAAW,KAAK;;EAEhB,aAAa;;iBAGE;;EAEf,sBAAsB,kBAAkBA,sBAAoBA
|
|
1
|
+
{"version":3,"file":"SessionScreen.d.mts","names":["TimelineEntry","DashboardEntry"],"sources":["../../src/screens/SessionScreen.tsx"],"mappings":";;;;;;;;;iBA6DiB;EACf;EACA,MAAM;EACN,QAAQ;EACR;EACA;EACA;;;;;;iBAOe,2BAA2B;EAC1C,mBAAmBA;;EAEnB,WAAW,KAAK;;EAEhB,aAAa;;iBAGE;;EAEf,sBAAsB,kBAAkBA,sBAAoBA;;;;;EAK5D,aACE,OAAOA,iBACP,UAAU,OAAOA,oBAAkB;;EAEnC,WAAW,uBACR;;EAEL,aAAa,kBAAkBA;;wBAUjB,cAAc,OAAO,qCAAkB,IAAA;;wBA0XvC,4BAA4B,OAAOC,kBAAmBD;;;;;;;;wBAmBtD,sBAAsB,kBAAkBA,sBAAoBA;;wBAmG5D,YAAY,OAAOC,gBAAiBD;;wBA2DpC,mBACd,WACA,UACA,SACA;EAEA;EACA;EACA,UAAU;EACV,WAAW,KAAK;oBACjB,IAAA"}
|
|
@@ -122,11 +122,12 @@ function SessionScreen(props) {
|
|
|
122
122
|
markdown: props.markdown,
|
|
123
123
|
transcript: props.transcript
|
|
124
124
|
}),
|
|
125
|
-
props.liveTranscript ? /* @__PURE__ */ jsx(LiveActivity, {
|
|
125
|
+
props.panel !== void 0 ? /* @__PURE__ */ jsx(ActivityPanel, { error }) : props.liveTranscript ? /* @__PURE__ */ jsx(LiveActivity, {
|
|
126
126
|
sessionId,
|
|
127
|
-
error
|
|
127
|
+
error,
|
|
128
|
+
showsWork: props.transcript?.showsWork
|
|
128
129
|
}) : /* @__PURE__ */ jsx(ActivityPanel, {
|
|
129
|
-
status: activity,
|
|
130
|
+
status: props.transcript?.showsWork?.(entries) ? void 0 : activity,
|
|
130
131
|
error
|
|
131
132
|
}),
|
|
132
133
|
offline && !props.readOnly && !stopped ? /* @__PURE__ */ jsxs(View, {
|
|
@@ -215,10 +216,15 @@ function PluginToolMessage({ message: Message, props }) {
|
|
|
215
216
|
result
|
|
216
217
|
});
|
|
217
218
|
}
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
/** A template row reads images inline too, so it gets the entry with referenced images filled in. */
|
|
220
|
+
function TemplateItem({ entry, render }) {
|
|
221
|
+
return render(useImageRefs(entry));
|
|
222
|
+
}
|
|
223
|
+
function LiveActivity({ sessionId, error, showsWork }) {
|
|
224
|
+
const mapEntry = useMemo(createNativeEntryMapper, []);
|
|
225
|
+
const working = useStore(sessionStoreFor(sessionId), (state) => state.streaming && !showsWork?.(state.entries.flatMap(mapEntry)));
|
|
220
226
|
return /* @__PURE__ */ jsx(ActivityPanel, {
|
|
221
|
-
status:
|
|
227
|
+
status: working ? "Working..." : void 0,
|
|
222
228
|
error
|
|
223
229
|
});
|
|
224
230
|
}
|
|
@@ -292,12 +298,16 @@ const SessionTimeline = memo(function SessionTimeline({ sessionId, entries, live
|
|
|
292
298
|
onMessageActions,
|
|
293
299
|
markdown
|
|
294
300
|
});
|
|
295
|
-
return transcript ?
|
|
301
|
+
return transcript ? /* @__PURE__ */ jsx(TemplateItem, {
|
|
302
|
+
entry,
|
|
303
|
+
render: (item) => transcript.renderItem(item, builtIn, slotProps)
|
|
304
|
+
}) : builtIn(entry);
|
|
296
305
|
}, [
|
|
297
306
|
renderTool,
|
|
298
307
|
onMessageActions,
|
|
299
308
|
markdown,
|
|
300
|
-
transcript
|
|
309
|
+
transcript,
|
|
310
|
+
slotProps
|
|
301
311
|
]);
|
|
302
312
|
return /* @__PURE__ */ jsx(ImageRefScope, {
|
|
303
313
|
value: sessionId,
|
|
@@ -505,6 +515,7 @@ function nativeEntry(entry) {
|
|
|
505
515
|
payload: {
|
|
506
516
|
toolCallId: entry.toolCallId,
|
|
507
517
|
args: entry.args,
|
|
518
|
+
argSummary: entry.argSummary,
|
|
508
519
|
result: entry.result,
|
|
509
520
|
output: entry.output,
|
|
510
521
|
running: entry.running,
|