@g9tm/aiassistant-lynx 1.9.4 → 1.9.6

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /** @g9tm/aiassistant-lynx: ReactLynx components of the G9 AI assistant, customisable like the Svelte ones. */
2
2
  export { AssistantRoot, AssistantChat, AssistantPanel, MessageList, PdfDownload, RECYCLE_FROM, Surfaces } from "./surfaces.jsx";
3
3
  export type { SurfaceKind, SurfaceProps } from "./surfaces.jsx";
4
- export { ApprovalCard, BlockView, Cards, Composer, CsvButton, Message, RateRow, RevealText, Small, StagesThinking, TextView, ThinkingOrb, WorkCard } from "./parts.jsx";
4
+ export { ApprovalCard, BlockView, Cards, Composer, CsvButton, Message, ModelPicker, RateRow, RevealText, Small, StagesThinking, TextView, ThinkingOrb, WorkCard } from "./parts.jsx";
5
5
  export { Chart } from "./chart.jsx";
6
6
  export { DraftButton, EntityChips, OpenButton, TourCard } from "./guide.jsx";
7
7
  export type { ChartView } from "./chart.jsx";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /** @g9tm/aiassistant-lynx: ReactLynx components of the G9 AI assistant, customisable like the Svelte ones. */
2
2
  export { AssistantRoot, AssistantChat, AssistantPanel, MessageList, PdfDownload, RECYCLE_FROM, Surfaces } from "./surfaces.jsx";
3
- export { ApprovalCard, BlockView, Cards, Composer, CsvButton, Message, RateRow, RevealText, Small, StagesThinking, TextView, ThinkingOrb, WorkCard } from "./parts.jsx";
3
+ export { ApprovalCard, BlockView, Cards, Composer, CsvButton, Message, ModelPicker, RateRow, RevealText, Small, StagesThinking, TextView, ThinkingOrb, WorkCard } from "./parts.jsx";
4
4
  export { Chart } from "./chart.jsx";
5
5
  export { DraftButton, EntityChips, OpenButton, TourCard } from "./guide.jsx";
6
6
  export { Button, Dialog, field, PinPad, SecretField } from "./slots.jsx";
package/dist/parts.d.ts CHANGED
@@ -64,6 +64,15 @@ export declare const ThinkingOrb: Part<Record<string, never>>;
64
64
  export declare const RateRow: Part<{
65
65
  message: MessageView;
66
66
  }>;
67
+ /**
68
+ * The model and thinking effort for what the person sends next (`assistant.model`, kept on the conversation by the
69
+ * server). Drawn only where the host lets the person choose (`GET models` says `choose`); "automatic" leaves it to the
70
+ * route. Lynx has no select: each choice is a `Button` (role `model` or `effort`; the chosen one `primary`), and a model
71
+ * that cannot answer now is shown greyed and does nothing. The host places it; replaceable as `ModelPicker`.
72
+ */
73
+ export declare const ModelPicker: Part<{
74
+ efforts?: readonly string[];
75
+ }>;
67
76
  /** Named stages lit by the run's real stage events (a pipeline's roles too, by the names given); never a show of thinking. */
68
77
  export declare const StagesThinking: Part<{
69
78
  run: RunView;
package/dist/parts.jsx CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { useEffect, useState } from "@lynx-js/react";
7
7
  import { arr, blockView, can, finished, item, LONG_RUNNING_MS, needsCode, obj, parseText, REMOTE_EXPIRED, REVEAL_MS, str, visibleText, windowView } from "@g9tm/aiassistant";
8
- import { askAgain, atWord, blockText, chatOf, composerOf, editLast, FEEDBACK_REASONS, guideBlock, matchQuick, pageTexts, pickRefs, putPick, rateAnswer, ratingsOf, refsIn, saveCsv, slashQuery, statusOf, tableText } from "@g9tm/aiassistant/pages";
8
+ import { askAgain, atWord, blockText, chatOf, composerOf, editLast, FEEDBACK_REASONS, guideBlock, matchQuick, pageCalls, pageTexts, pickRefs, putPick, rateAnswer, ratingsOf, readModels, refsIn, saveCsv, slashQuery, statusOf, tableText } from "@g9tm/aiassistant/pages";
9
9
  import { Chart } from "./chart.jsx";
10
10
  import { blockOverride, cls, fill, inkOf, override, rowOf, startText, swappable, tok, useUi } from "./context.jsx";
11
11
  import { Button, field, hint, PinPad, SecretField } from "./slots.jsx";
@@ -23,13 +23,13 @@ export function TextView(props) {
23
23
  const ink = { color: tok(ui, "ink", "#22201d"), ...startText(ui) };
24
24
  const line = (xs) => xs.map((x, i) => (<text key={i} style={x.kind === "bold" ? { fontWeight: "bold" } : x.kind === "code" ? { fontFamily: "monospace" } : x.kind === "link" && x.href ? { color: tok(ui, "accent", "#8a4b2a") } : {}} {...(x.kind === "link" && x.href ? { bindtap: () => host.openUrl?.(x.href ?? "") } : {})}>{x.text}</text>));
25
25
  const copy = (b) => (!select && chatOf(ui.assistant).copyParts && host.copy ? { bindlongpress: () => { void host.copy?.(blockText(b)); host.haptic?.("tick"); } } : {});
26
- return (<view>
26
+ return (<view>
27
27
  {parseText(props.text, host.linkHosts ?? []).map((b, i) => b.kind === "paragraph"
28
28
  ? <text key={i} text-selection={select} style={{ ...ink, marginBottom: "6px" }} {...copy(b)}>{line(b.inlines)}</text>
29
- : <view key={i} className="g9a-list" style={{ marginBottom: "6px" }} {...copy(b)}>{b.items.map((it, n) => (<view key={n} style={{ ...rowOf(ui), alignItems: "flex-start" }}>
30
- <text style={{ ...ink, width: b.ordered ? "24px" : "16px", flexShrink: 0 }}>{b.ordered ? String(n + 1) + "." : "•"}</text>
31
- <text text-selection={select} style={{ ...ink, ...grow }}>{line(it)}</text>
32
- </view>))}</view>)}
29
+ : <view key={i} className="g9a-list" style={{ marginBottom: "6px" }} {...copy(b)}>{b.items.map((it, n) => (<view key={n} style={{ ...rowOf(ui), alignItems: "flex-start" }}>
30
+ <text style={{ ...ink, width: b.ordered ? "24px" : "16px", flexShrink: 0 }}>{b.ordered ? String(n + 1) + "." : "•"}</text>
31
+ <text text-selection={select} style={{ ...ink, ...grow }}>{line(it)}</text>
32
+ </view>))}</view>)}
33
33
  </view>);
34
34
  }
35
35
  export function RevealText(props) {
@@ -56,9 +56,9 @@ export function Small(props) {
56
56
  return <view className={cls(ui, "mode-banner")} style={{ padding: "6px 12px", backgroundColor: tok(ui, "surface-2", "#f6f4f1") }}><text style={{ color: tok(ui, "warn", "#a35a00") }}>{s.mode === "off" ? t("mode.off") : t("mode.offline")}</text></view>;
57
57
  const w = s?.usage[0] ? windowView(s.usage[0], Date.now()) : null;
58
58
  if (props.kind === "usage" && w) {
59
- return (<view className={cls(ui, "usage-chip")} style={{ ...rowOf(ui), height: "22px", borderRadius: "11px", overflow: "hidden", backgroundColor: tok(ui, "surface-2", "#f6f4f1") }}>
60
- <view style={{ position: "absolute", left: 0, top: 0, bottom: 0, width: String(Math.round(w.left * 100)) + "%", backgroundColor: tok(ui, "accent", "#8a4b2a"), opacity: 0.25 }}/>
61
- <text style={{ fontSize: "11px", paddingLeft: "8px", paddingRight: "8px" }}>{t("usage.left", { percent: Math.round(w.left * 100) + "%" })}</text>
59
+ return (<view className={cls(ui, "usage-chip")} style={{ ...rowOf(ui), height: "22px", borderRadius: "11px", overflow: "hidden", backgroundColor: tok(ui, "surface-2", "#f6f4f1") }}>
60
+ <view style={{ position: "absolute", left: 0, top: 0, bottom: 0, width: String(Math.round(w.left * 100)) + "%", backgroundColor: tok(ui, "accent", "#8a4b2a"), opacity: 0.25 }}/>
61
+ <text style={{ fontSize: "11px", paddingLeft: "8px", paddingRight: "8px" }}>{t("usage.left", { percent: Math.round(w.left * 100) + "%" })}</text>
62
62
  </view>);
63
63
  }
64
64
  return null;
@@ -69,14 +69,14 @@ export function Small(props) {
69
69
  */
70
70
  export const CsvButton = swappable("CsvButton", (props) => {
71
71
  const ui = useUi();
72
- const t = ui.texts.t;
72
+ const t = pageTexts(ui.texts).t; // its words are the pages entry's
73
73
  const [notice, setNotice] = useState(null);
74
74
  if (!can(ui.assistant.host, "save"))
75
75
  return null;
76
76
  const save = () => { void saveCsv(ui.assistant.host, props.title, props.labels, props.rows).then((ok) => setNotice(ok ? "csv.saved" : "csv.not_saved")); };
77
- return (<view className="g9a-csv" style={{ ...rowOf(ui, "8px"), marginTop: "6px" }}>
78
- <Button label={t("csv.save")} onTap={save}/>
79
- {notice ? <view style={grow}><text className="g9a-csv-notice" style={{ fontSize: "12px", color: notice === "csv.saved" ? tok(ui, "muted", "#6b6660") : tok(ui, "danger", "#b42318") }} text-maxline="1">{t(notice)}</text></view> : null}
77
+ return (<view className="g9a-csv" style={{ ...rowOf(ui, "8px"), marginTop: "6px" }}>
78
+ <Button label={t("csv.save")} onTap={save}/>
79
+ {notice ? <view style={grow}><text className="g9a-csv-notice" style={{ fontSize: "12px", color: notice === "csv.saved" ? tok(ui, "muted", "#6b6660") : tok(ui, "danger", "#b42318") }} text-maxline="1">{t(notice)}</text></view> : null}
80
80
  </view>);
81
81
  });
82
82
  export function BlockView(props) {
@@ -98,31 +98,31 @@ export function BlockView(props) {
98
98
  case "text":
99
99
  case "callout": return <view className={cls(ui, v.type === "text" ? "block.text" : "block.callout")}><TextView text={v.text}/></view>;
100
100
  case "table":
101
- return (<view className={cls(ui, "block.table")}>
102
- {v.title ? <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{v.title}</text> : null}
103
- {v.asCards || props.compact ? null : <view style={rowOf(ui)}>{v.columns.map((c) => <text key={c.name} style={{ ...grow, fontWeight: "bold" }} text-maxline="1">{c.label}</text>)}</view>}
101
+ return (<view className={cls(ui, "block.table")}>
102
+ {v.title ? <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{v.title}</text> : null}
103
+ {v.asCards || props.compact ? null : <view style={rowOf(ui)}>{v.columns.map((c) => <text key={c.name} style={{ ...grow, fontWeight: "bold" }} text-maxline="1">{c.label}</text>)}</view>}
104
104
  {v.rows.slice(0, open ? v.rows.length : v.shown).map((r, i) => v.asCards || props.compact
105
- ? <view key={i} className={cls(ui, "block.table.card")} style={{ padding: "6px 8px", marginBottom: "6px", borderRadius: "6px", backgroundColor: tok(ui, "surface", "#fff") }}>
106
- {v.columns.map((c, j) => <view key={c.name} style={rowOf(ui)}><text style={{ ...grow, color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{c.label}</text><text text-maxline="2">{item(r, j)}</text></view>)}
105
+ ? <view key={i} className={cls(ui, "block.table.card")} style={{ padding: "6px 8px", marginBottom: "6px", borderRadius: "6px", backgroundColor: tok(ui, "surface", "#fff") }}>
106
+ {v.columns.map((c, j) => <view key={c.name} style={rowOf(ui)}><text style={{ ...grow, color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{c.label}</text><text text-maxline="2">{item(r, j)}</text></view>)}
107
107
  </view>
108
- : <view key={i} style={rowOf(ui)}>{r.map((c, j) => <text key={j} style={grow} text-maxline="1">{c}</text>)}</view>)}
109
- {v.more > 0 && !open ? <Button label={t("block.more_rows", { count: v.more })} onTap={() => setOpen(true)}/> : null}
110
- <view style={rowOf(ui, "8px")}>
111
- <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
112
- {chatOf(ui.assistant).copyParts && ui.assistant.host.copy ? <Button role="copy" label={pageTexts(ui.texts).t("copy.table")} onTap={() => void ui.assistant.host.copy?.(tableText(v.columns.map((c) => c.label), v.rows))}/> : null}
113
- </view>
108
+ : <view key={i} style={rowOf(ui)}>{r.map((c, j) => <text key={j} style={grow} text-maxline="1">{c}</text>)}</view>)}
109
+ {v.more > 0 && !open ? <Button label={t("block.more_rows", { count: v.more })} onTap={() => setOpen(true)}/> : null}
110
+ <view style={rowOf(ui, "8px")}>
111
+ <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
112
+ {chatOf(ui.assistant).copyParts && ui.assistant.host.copy ? <Button role="copy" label={pageTexts(ui.texts).t("copy.table")} onTap={() => void ui.assistant.host.copy?.(tableText(v.columns.map((c) => c.label), v.rows))}/> : null}
113
+ </view>
114
114
  </view>);
115
115
  case "export":
116
- return (<view className="g9a-block-export">
117
- {v.title ? <text style={{ fontWeight: "bold" }} text-maxline="2">{v.title}</text> : null}
118
- <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="3">{v.fallbackText}</text>
119
- <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
116
+ return (<view className="g9a-block-export">
117
+ {v.title ? <text style={{ fontWeight: "bold" }} text-maxline="2">{v.title}</text> : null}
118
+ <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="3">{v.fallbackText}</text>
119
+ <CsvButton title={v.title} labels={v.columns.map((c) => c.label)} rows={v.rows}/>
120
120
  </view>);
121
121
  case "chart":
122
- return (<view className={cls(ui, "block.chart")} accessibility-label={v.fallbackText}>
123
- {v.title ? <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{v.title}</text> : null}
124
- <Chart view={v}/>
125
- {v.fewData ? <text style={{ fontSize: "12px" }}>{t("block.few_data")}</text> : null}
122
+ return (<view className={cls(ui, "block.chart")} accessibility-label={v.fallbackText}>
123
+ {v.title ? <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{v.title}</text> : null}
124
+ <Chart view={v}/>
125
+ {v.fewData ? <text style={{ fontSize: "12px" }}>{t("block.few_data")}</text> : null}
126
126
  </view>);
127
127
  case "kpi": return <view className={cls(ui, "block.kpi")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{v.items.map((k, i) => <view key={i} style={{ marginRight: "8px" }}><text style={inkOf(ui)}>{k.label}</text><text text-selection={chatOf(ui.assistant).selectable} style={{ ...inkOf(ui), fontWeight: "bold" }} {...(chatOf(ui.assistant).copyParts && ui.assistant.host.copy ? { bindlongpress: () => { void ui.assistant.host.copy?.(k.value); ui.assistant.host.haptic?.("tick"); } } : {})}>{k.value}</text></view>)}</view>;
128
128
  case "steps": return <view className={cls(ui, "block.steps")}>{v.items.map((s, i) => <text key={i}>{s.text}</text>)}</view>;
@@ -148,22 +148,22 @@ export function ApprovalCard(props) {
148
148
  setCode("");
149
149
  setEpoch((n) => n + 1);
150
150
  };
151
- return (<view className={cls(ui, "card.approval")} style={{ padding: "12px", borderRadius: "10px", borderWidth: "1px", borderColor: tok(ui, "approval-card-border", "#8a4b2a") }}>
152
- <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{p.readOnly ? t("card.readonly_routine") : p.title}</text>
153
- {p.warning ? <text style={{ color: tok(ui, "warn", "#a35a00") }}>{t("card.tainted")}</text> : null}
154
- {p.steps.map((s) => (<view key={s.index} className={cls(ui, "card.approval.step")} accessibility-element={true} accessibility-label={s.text} bindtap={() => ui.assistant.tick(p.id, s.index)}>
155
- <view style={rowOf(ui)}><text style={inkOf(ui)}>{s.ticked ? "☑ " : "☐ "}</text><text style={{ ...grow, ...inkOf(ui) }}>{s.text}{s.undoable ? "" : " (" + t("card.irreversible") + ")"}</text></view>
156
- {s.facts.map((f, i) => <text key={i} className={cls(ui, "card.approval.fact")} style={{ ...inkOf(ui), fontSize: "12px" }}>{say(f.key, f.args)}</text>)}
157
- {s.diff.map((d, i) => <text key={"d" + String(i)} className={cls(ui, "card.approval.fact")} style={{ ...inkOf(ui), fontSize: "12px" }}>{say(d.name, d.args) + ": " + (d.before ?? "—") + " ← " + (d.after ?? "—")}</text>)}
158
- </view>))}
159
- {p.answered === null ? (<view>
160
- {needsCode(p.method) || p.failCode === REMOTE_EXPIRED ? <view className={cls(ui, "card.approval.code")}><PinPad key={epoch} label={t("card.code")} onInput={setCode}/></view> : null}
161
- {p.failCode === "confirm.waiting" ? <text style={inkOf(ui)}>{t("card.waiting")}</text> : p.failCode ? <text style={inkOf(ui)}>{pageTexts(ui.texts).t(p.failCode)}{p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : ""}</text> : null}
162
- <view style={rowOf(ui)}>
163
- <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void confirm()}/>
164
- <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => void ui.assistant.refuse(p.id)}/>
165
- </view>
166
- </view>) : <text style={inkOf(ui)}>{t("card.answered")}</text>}
151
+ return (<view className={cls(ui, "card.approval")} style={{ padding: "12px", borderRadius: "10px", borderWidth: "1px", borderColor: tok(ui, "approval-card-border", "#8a4b2a") }}>
152
+ <text style={{ ...inkOf(ui), fontWeight: "bold" }}>{p.readOnly ? t("card.readonly_routine") : p.title}</text>
153
+ {p.warning ? <text style={{ color: tok(ui, "warn", "#a35a00") }}>{t("card.tainted")}</text> : null}
154
+ {p.steps.map((s) => (<view key={s.index} className={cls(ui, "card.approval.step")} accessibility-element={true} accessibility-label={s.text} bindtap={() => ui.assistant.tick(p.id, s.index)}>
155
+ <view style={rowOf(ui)}><text style={inkOf(ui)}>{s.ticked ? "☑ " : "☐ "}</text><text style={{ ...grow, ...inkOf(ui) }}>{s.text}{s.undoable ? "" : " (" + t("card.irreversible") + ")"}</text></view>
156
+ {s.facts.map((f, i) => <text key={i} className={cls(ui, "card.approval.fact")} style={{ ...inkOf(ui), fontSize: "12px" }}>{say(f.key, f.args)}</text>)}
157
+ {s.diff.map((d, i) => <text key={"d" + String(i)} className={cls(ui, "card.approval.fact")} style={{ ...inkOf(ui), fontSize: "12px" }}>{say(d.name, d.args) + ": " + (d.before ?? "—") + " ← " + (d.after ?? "—")}</text>)}
158
+ </view>))}
159
+ {p.answered === null ? (<view>
160
+ {needsCode(p.method) || p.failCode === REMOTE_EXPIRED ? <view className={cls(ui, "card.approval.code")}><PinPad key={epoch} label={t("card.code")} onInput={setCode}/></view> : null}
161
+ {p.failCode === "confirm.waiting" ? <text style={inkOf(ui)}>{t("card.waiting")}</text> : p.failCode ? <text style={inkOf(ui)}>{pageTexts(ui.texts).t(p.failCode)}{p.triesLeft !== null ? " · " + t("card.tries_left", { count: p.triesLeft }) : ""}</text> : null}
162
+ <view style={rowOf(ui)}>
163
+ <Button part="card.approval.confirm" primary label={t("card.confirm")} onTap={() => void confirm()}/>
164
+ <Button part="card.approval.refuse" label={t("card.refuse")} onTap={() => void ui.assistant.refuse(p.id)}/>
165
+ </view>
166
+ </view>) : <text style={inkOf(ui)}>{t("card.answered")}</text>}
167
167
  </view>);
168
168
  }
169
169
  export function Message(props) {
@@ -178,20 +178,20 @@ export function Message(props) {
178
178
  // A card's rows grow from a zero basis: in a bubble sized by its content they had no width and a step's text ran one
179
179
  // letter per line (a host's phone). A message with a card takes a definite width.
180
180
  style={{ padding: "8px 12px", borderRadius: "10px", marginBottom: "8px", alignSelf: m.role === "user" ? "flex-start" : "flex-end", ...(m.card ? { width: "88%" } : { maxWidth: "88%" }),
181
- backgroundColor: m.role === "user" ? tok(ui, "user-bubble", "#f1e9e5") : tok(ui, "surface-2", "#f6f4f1"), opacity: m.pending ? 0.7 : 1 }}>
182
- {plan ? <Approval plan={plan}/> : m.card ? <Other card={m.card} runId={props.runId}/> : (<view>
183
- {m.text.length > 0 ? <RevealText text={m.text} reveal={reveal}/> : null}
184
- {m.blocks.map((b, i) => <BlockView key={i} block={b} at={m.id + ":" + String(i)}/>)}
185
- {m.next.length > 0 ? <view className={cls(ui, "block.actions")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{m.next.map((n) => <Button key={n} part="block.action" role="next" label={n} onTap={() => void ui.assistant.send(n)}/>)}</view> : null}
186
- {m.role === "assistant" ? (<view className={cls(ui, "message.feedback")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
187
- <Small kind="provenance" provenance={m.provenance}/>
188
- {ui.assistant.host.copy ? <Button role="copy" label={t("feedback.copy")} onTap={() => void ui.assistant.host.copy?.(m.text)}/> : null}
189
- {m.provenance === "learned" ? <Button role="feedback" label={t("feedback.not_right")} onTap={() => void ui.assistant.notRight(m.id)}/> : null}
190
- {props.last && chatOf(ui.assistant).again && !m.pending && !m.card ? <Button role="again" label={pageTexts(ui.texts).t("message.again")} onTap={() => void askAgain(ui.assistant)}/> : null}
191
- {props.last && chatOf(ui.assistant).again && !m.pending && !m.card ? <Button role="edit" label={pageTexts(ui.texts).t("message.edit")} onTap={() => editLast(ui.assistant)}/> : null}
192
- </view>) : null}
193
- {m.role === "assistant" && chatOf(ui.assistant).feedback && !m.pending && m.id.length > 0 ? <RateRow message={m}/> : null}
194
- </view>)}
181
+ backgroundColor: m.role === "user" ? tok(ui, "user-bubble", "#f1e9e5") : tok(ui, "surface-2", "#f6f4f1"), opacity: m.pending ? 0.7 : 1 }}>
182
+ {plan ? <Approval plan={plan}/> : m.card ? <Other card={m.card} runId={props.runId}/> : (<view>
183
+ {m.text.length > 0 ? <RevealText text={m.text} reveal={reveal}/> : null}
184
+ {m.blocks.map((b, i) => <BlockView key={i} block={b} at={m.id + ":" + String(i)}/>)}
185
+ {m.next.length > 0 ? <view className={cls(ui, "block.actions")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{m.next.map((n) => <Button key={n} part="block.action" role="next" label={n} onTap={() => void ui.assistant.send(n)}/>)}</view> : null}
186
+ {m.role === "assistant" ? (<view className={cls(ui, "message.feedback")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
187
+ <Small kind="provenance" provenance={m.provenance}/>
188
+ {ui.assistant.host.copy ? <Button role="copy" label={t("feedback.copy")} onTap={() => void ui.assistant.host.copy?.(m.text)}/> : null}
189
+ {m.provenance === "learned" ? <Button role="feedback" label={t("feedback.not_right")} onTap={() => void ui.assistant.notRight(m.id)}/> : null}
190
+ {props.last && chatOf(ui.assistant).again && !m.pending && !m.card ? <Button role="again" label={pageTexts(ui.texts).t("message.again")} onTap={() => void askAgain(ui.assistant)}/> : null}
191
+ {props.last && chatOf(ui.assistant).again && !m.pending && !m.card ? <Button role="edit" label={pageTexts(ui.texts).t("message.edit")} onTap={() => editLast(ui.assistant)}/> : null}
192
+ </view>) : null}
193
+ {m.role === "assistant" && chatOf(ui.assistant).feedback && !m.pending && m.id.length > 0 ? <RateRow message={m}/> : null}
194
+ </view>)}
195
195
  </view>);
196
196
  }
197
197
  /** The other cards: undo all (its steps, then what the undo said), a question (options, a field or a secret field), "learn this?" and "make it a routine?". */
@@ -207,36 +207,36 @@ export function Cards(props) {
207
207
  const steps = arr(b["steps"]).map(obj).map((s) => str(s["text"], str(s["title"], str(s["tool"]))));
208
208
  const list = steps.map((s, i) => <text key={i} text-maxline="2">{String(i + 1) + ". " + s}</text>);
209
209
  if (c.kind === "undo") {
210
- return (<view className={cls(ui, "card.undo")}>
211
- {list}
210
+ return (<view className={cls(ui, "card.undo")}>
211
+ {list}
212
212
  {undone === null ? <Button label={t("undo.all")} onTap={() => { ui.assistant.undo(c.id).then((r) => setUndone(str(obj(r)["text"], t("card.answered"))), () => setUndone(t("card.answered"))); }}/>
213
- : <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }}>{undone}</text>}
213
+ : <text style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }}>{undone}</text>}
214
214
  </view>);
215
215
  }
216
216
  if (c.kind === "ask" && props.runId) {
217
217
  const runId = props.runId;
218
- return (<view className={cls(ui, "card.ask")}>
219
- <text style={inkOf(ui)}>{str(b["question"])}</text>
220
- {answered ? <text style={inkOf(ui)}>{t("card.answered")}</text> : (<view>
221
- {options.map((o) => <Button key={o} label={o} onTap={() => void ui.assistant.answer(runId, c.id, [o], null)}/>)}
222
- {b["secret"] === true ? <SecretField onSubmit={(v) => void ui.assistant.answer(runId, c.id, [], v)}/> : (<view style={rowOf(ui, "8px")}>
223
- <view style={grow}><input placeholder-color={hint(ui)} style={{ ...field(ui), width: "100%" }} type="text" accessibility-label={t("ask.send")} bindinput={(e) => setText(e.detail.value)}/></view>
224
- <Button label={t("ask.send")} onTap={() => { const v = text; setText(""); void ui.assistant.answer(runId, c.id, [], v); }}/>
225
- </view>)}
226
- </view>)}
218
+ return (<view className={cls(ui, "card.ask")}>
219
+ <text style={inkOf(ui)}>{str(b["question"])}</text>
220
+ {answered ? <text style={inkOf(ui)}>{t("card.answered")}</text> : (<view>
221
+ {options.map((o) => <Button key={o} label={o} onTap={() => void ui.assistant.answer(runId, c.id, [o], null)}/>)}
222
+ {b["secret"] === true ? <SecretField onSubmit={(v) => void ui.assistant.answer(runId, c.id, [], v)}/> : (<view style={rowOf(ui, "8px")}>
223
+ <view style={grow}><input placeholder-color={hint(ui)} style={{ ...field(ui), width: "100%" }} type="text" accessibility-label={t("ask.send")} bindinput={(e) => setText(e.detail.value)}/></view>
224
+ <Button label={t("ask.send")} onTap={() => { const v = text; setText(""); void ui.assistant.answer(runId, c.id, [], v); }}/>
225
+ </view>)}
226
+ </view>)}
227
227
  </view>);
228
228
  }
229
229
  if (c.kind !== "learn" && c.kind !== "routine" && c.kind !== "routine_revision")
230
230
  return null;
231
231
  const learn = c.kind === "learn";
232
232
  const id = str(b["id"], c.id);
233
- return (<view className={cls(ui, "card.choice")}>
234
- <text style={inkOf(ui)}>{learn ? t("learn.ask") : t("routine.ask")}</text>
235
- {learn ? <text style={{ color: tok(ui, "muted", "#6b6660") }} text-maxline="6">{str(b["text"])}</text> : list}
236
- {answered ? <text style={inkOf(ui)}>{t("card.answered")}</text> : (<view style={rowOf(ui)}>
237
- <Button label={t("yes")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "accept" : "approve")}/>
238
- <Button label={t("no")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "refuse" : "retire")}/>
239
- </view>)}
233
+ return (<view className={cls(ui, "card.choice")}>
234
+ <text style={inkOf(ui)}>{learn ? t("learn.ask") : t("routine.ask")}</text>
235
+ {learn ? <text style={{ color: tok(ui, "muted", "#6b6660") }} text-maxline="6">{str(b["text"])}</text> : list}
236
+ {answered ? <text style={inkOf(ui)}>{t("card.answered")}</text> : (<view style={rowOf(ui)}>
237
+ <Button label={t("yes")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "accept" : "approve")}/>
238
+ <Button label={t("no")} onTap={() => void ui.assistant.choose(learn ? "knowledge" : "learned", id, learn ? "refuse" : "retire")}/>
239
+ </view>)}
240
240
  </view>);
241
241
  }
242
242
  /** The thinking orb: only transform and opacity change (a slow pulse); still with reduced motion. */
@@ -268,16 +268,62 @@ export const RateRow = swappable("RateRow", (props) => {
268
268
  return <view className={cls(ui, "message.rate")} style={rowOf(ui, "6px")}><text style={muted} text-maxline="1">{t("feedback.thanks")}</text></view>;
269
269
  }
270
270
  if (rating === "asking") {
271
- return (<view className={cls(ui, "message.rate")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
272
- <text style={muted} text-maxline="1">{t("feedback.why")}</text>
273
- {FEEDBACK_REASONS.map((r) => <Button key={r} role="reason" label={t("feedback.reason." + r)} onTap={() => void rateAnswer(ui.assistant, props.message, false, r)}/>)}
274
- <Button role="reason" label={t("feedback.skip")} onTap={() => void rateAnswer(ui.assistant, props.message, false, null)}/>
271
+ return (<view className={cls(ui, "message.rate")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
272
+ <text style={muted} text-maxline="1">{t("feedback.why")}</text>
273
+ {FEEDBACK_REASONS.map((r) => <Button key={r} role="reason" label={t("feedback.reason." + r)} onTap={() => void rateAnswer(ui.assistant, props.message, false, r)}/>)}
274
+ <Button role="reason" label={t("feedback.skip")} onTap={() => void rateAnswer(ui.assistant, props.message, false, null)}/>
275
275
  </view>);
276
276
  }
277
- return (<view className={cls(ui, "message.rate")} style={rowOf(ui, "6px")}>
278
- <text style={muted} text-maxline="1">{t("feedback.ask")}</text>
279
- <Button role="good" label={t("feedback.good")} onTap={() => void rateAnswer(ui.assistant, props.message, true)}/>
280
- <Button role="bad" label={t("feedback.bad")} onTap={() => void rateAnswer(ui.assistant, props.message, false)}/>
277
+ return (<view className={cls(ui, "message.rate")} style={rowOf(ui, "6px")}>
278
+ <text style={muted} text-maxline="1">{t("feedback.ask")}</text>
279
+ <Button role="good" label={t("feedback.good")} onTap={() => void rateAnswer(ui.assistant, props.message, true)}/>
280
+ <Button role="bad" label={t("feedback.bad")} onTap={() => void rateAnswer(ui.assistant, props.message, false)}/>
281
+ </view>);
282
+ });
283
+ /**
284
+ * The model and thinking effort for what the person sends next (`assistant.model`, kept on the conversation by the
285
+ * server). Drawn only where the host lets the person choose (`GET models` says `choose`); "automatic" leaves it to the
286
+ * route. Lynx has no select: each choice is a `Button` (role `model` or `effort`; the chosen one `primary`), and a model
287
+ * that cannot answer now is shown greyed and does nothing. The host places it; replaceable as `ModelPicker`.
288
+ */
289
+ export const ModelPicker = swappable("ModelPicker", (props) => {
290
+ const ui = useUi();
291
+ const t = pageTexts(ui.texts).t;
292
+ const efforts = props.efforts ?? ["low", "medium", "high"];
293
+ const [choose, setChoose] = useState(false);
294
+ const [models, setModels] = useState([]);
295
+ const at = (ui.assistant.model ?? "").lastIndexOf("@");
296
+ const [id, setId] = useState(at > 0 ? (ui.assistant.model ?? "").slice(0, at) : (ui.assistant.model ?? ""));
297
+ const [effort, setEffort] = useState(at > 0 ? (ui.assistant.model ?? "").slice(at + 1) : "");
298
+ useEffect(() => {
299
+ pageCalls.models(ui.assistant.api).then((raw) => { const r = readModels(raw); setChoose(r.choose && r.models.length > 0); setModels(r.models); }, () => setChoose(false));
300
+ }, [ui.assistant]);
301
+ const pick = (nextId, nextEffort) => {
302
+ setId(nextId);
303
+ setEffort(nextEffort);
304
+ ui.assistant.model = nextId.length === 0 ? null : nextEffort.length > 0 ? nextId + "@" + nextEffort : nextId;
305
+ };
306
+ if (!choose)
307
+ return null;
308
+ const label = { fontSize: "12px", color: tok(ui, "muted", "#6b6660") };
309
+ const effortLabel = (e) => (t("model.effort." + e) === "model.effort." + e ? e : t("model.effort." + e));
310
+ return (<view className={cls(ui, "model-picker")} style={{ display: "flex", flexDirection: "column" }}>
311
+ <text style={label} text-maxline="1">{t("model.label")}</text>
312
+ <view style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
313
+ <Button role="model" primary={id.length === 0} label={t("model.auto")} onTap={() => pick("", "")}/>
314
+ {models.map((m) => m.ready
315
+ ? <Button key={m.id} role="model" primary={id === m.id} label={m.id} onTap={() => pick(m.id, effort)}/>
316
+ : <view key={m.id} accessibility-element={true} accessibility-label={m.id + " (" + t("model.unavailable") + ")"} style={{ minHeight: "38px", paddingLeft: "12px", paddingRight: "12px", justifyContent: "center", opacity: 0.5 }}>
317
+ <text style={label} text-maxline="1">{m.id + " (" + t("model.unavailable") + ")"}</text>
318
+ </view>)}
319
+ </view>
320
+ {id.length > 0 && efforts.length > 0 ? (<view style={{ display: "flex", flexDirection: "column", marginTop: "6px" }}>
321
+ <text style={label} text-maxline="1">{t("model.effort")}</text>
322
+ <view style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
323
+ <Button role="effort" primary={effort.length === 0} label={t("model.effort.default")} onTap={() => pick(id, "")}/>
324
+ {efforts.map((e) => <Button key={e} role="effort" primary={effort === e} label={effortLabel(e)} onTap={() => pick(id, e)}/>)}
325
+ </view>
326
+ </view>) : null}
281
327
  </view>);
282
328
  });
283
329
  /** Named stages lit by the run's real stage events (a pipeline's roles too, by the names given); never a show of thinking. */
@@ -285,8 +331,8 @@ export const StagesThinking = swappable("StagesThinking", (props) => {
285
331
  const ui = useUi();
286
332
  const names = new Map(Object.entries(props.names ?? {}));
287
333
  const name = (s) => (s.role ? (names.get(s.role) ?? s.role) : ui.texts.t("stage." + s.id));
288
- return (<view className={cls(ui, "stages-thinking")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
289
- {props.run.stages.filter((s) => s.id === "role" || names.has(s.id) || s.id !== "waiting").map((s, i) => (<text key={i} className={cls(ui, "work.stage")} style={{ fontSize: "12px", opacity: s.state === "on" ? 1 : 0.5 }} text-maxline="1">{name(s)}</text>))}
334
+ return (<view className={cls(ui, "stages-thinking")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap" }}>
335
+ {props.run.stages.filter((s) => s.id === "role" || names.has(s.id) || s.id !== "waiting").map((s, i) => (<text key={i} className={cls(ui, "work.stage")} style={{ fontSize: "12px", opacity: s.state === "on" ? 1 : 0.5 }} text-maxline="1">{name(s)}</text>))}
290
336
  </view>);
291
337
  });
292
338
  export function WorkCard(props) {
@@ -304,16 +350,16 @@ export function WorkCard(props) {
304
350
  const what = chatOf(ui.assistant).status ? statusOf(r) : null;
305
351
  const whatText = what ? t(what.key, what.args) : "";
306
352
  const said = what && whatText !== what.key ? pageTexts(ui.texts).t("work.status", { what: whatText }) : null;
307
- return (<view className={cls(ui, "work")} style={{ ...rowOf(ui, "8px"), alignItems: "flex-start", padding: "12px" }}>
308
- <ThinkingOrb />
309
- <view style={grow}>
310
- <view style={rowOf(ui)}><text style={{ ...grow, ...inkOf(ui) }}>{long ? t("work.long") : t("work.title")}</text><text className={cls(ui, "work.elapsed")}>{t("work.elapsed", { seconds })}</text></view>
311
- {said ? <text className={cls(ui, "work.status")} style={inkOf(ui)} text-maxline="1">{said}</text> : <StagesThinking run={r}/>}
312
- {r.progress ? <text className={cls(ui, "work.progress")} text-maxline="2">{t(r.progress.key, r.progress.args)}</text> : null}
313
- {said ? null : r.tools.slice(-3).map((x, i) => t(x.title.key) === x.title.key ? null : <text key={i} className={cls(ui, "work.tool")} style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{t(x.title.key)}</text>)}
314
- {r.streamingText ? <text className="g9a-stream" text-maxline="4">{r.streamingText}</text> : null}
315
- </view>
316
- {/* the composer's send turns into stop while a run works: one stop, where the person's thumb is */}
353
+ return (<view className={cls(ui, "work")} style={{ ...rowOf(ui, "8px"), alignItems: "flex-start", padding: "12px" }}>
354
+ <ThinkingOrb />
355
+ <view style={grow}>
356
+ <view style={rowOf(ui)}><text style={{ ...grow, ...inkOf(ui) }}>{long ? t("work.long") : t("work.title")}</text><text className={cls(ui, "work.elapsed")}>{t("work.elapsed", { seconds })}</text></view>
357
+ {said ? <text className={cls(ui, "work.status")} style={inkOf(ui)} text-maxline="1">{said}</text> : <StagesThinking run={r}/>}
358
+ {r.progress ? <text className={cls(ui, "work.progress")} text-maxline="2">{t(r.progress.key, r.progress.args)}</text> : null}
359
+ {said ? null : r.tools.slice(-3).map((x, i) => t(x.title.key) === x.title.key ? null : <text key={i} className={cls(ui, "work.tool")} style={{ fontSize: "12px", color: tok(ui, "muted", "#6b6660") }} text-maxline="1">{t(x.title.key)}</text>)}
360
+ {r.streamingText ? <text className="g9a-stream" text-maxline="4">{r.streamingText}</text> : null}
361
+ </view>
362
+ {/* the composer's send turns into stop while a run works: one stop, where the person's thumb is */}
317
363
  </view>);
318
364
  }
319
365
  /**
@@ -388,21 +434,21 @@ export function Composer(props) {
388
434
  redraw(putPick(text, r));
389
435
  };
390
436
  const field1 = { ...field(ui), width: "100%" };
391
- return (<view className={cls(ui, "composer")} style={{ padding: "12px" }}>
392
- {props.attachments.length > 0 ? <view className={cls(ui, "file-chips")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{props.attachments.map((a) => <Button key={a.id} part="file-chip" label={a.name + " ×"} onTap={() => ui.assistant.detach(a.id)}/>)}</view> : null}
393
- {quick.length > 0 || found.length > 0 ? (<view className={cls(ui, "composer.menu")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap", marginBottom: "6px" }}>
394
- {quick.map((q) => <Button key={"q" + q.label} role="quick" label={q.label} onTap={() => { redraw(""); void ui.assistant.ask(q.send); }}/>)}
395
- {found.map((r) => <Button key={"p" + r.kind + r.id} role="pick" label={r.label} onTap={() => pickOne(r)}/>)}
396
- </view>) : null}
397
- <view style={{ ...rowOf(ui), alignItems: "flex-end" }}>
398
- {host.pickFile || host.uploadFile ? <Button part="composer.attach" role="attach" label={t("composer.attach")} onTap={() => ui.assistant.attachFromDevice()}/> : null}
399
- {can(host, "mic") ? <Button part="composer.mic" role="mic" label={listening ? pageTexts(ui.texts).t("composer.listening") : t("composer.mic")} onTap={() => void dictate()}/> : null}
400
- <view style={{ ...grow, marginLeft: "8px", marginRight: "8px" }}>
437
+ return (<view className={cls(ui, "composer")} style={{ padding: "12px" }}>
438
+ {props.attachments.length > 0 ? <view className={cls(ui, "file-chips")} style={{ ...rowOf(ui), flexWrap: "wrap" }}>{props.attachments.map((a) => <Button key={a.id} part="file-chip" label={a.name + " ×"} onTap={() => ui.assistant.detach(a.id)}/>)}</view> : null}
439
+ {quick.length > 0 || found.length > 0 ? (<view className={cls(ui, "composer.menu")} style={{ ...rowOf(ui, "6px"), flexWrap: "wrap", marginBottom: "6px" }}>
440
+ {quick.map((q) => <Button key={"q" + q.label} role="quick" label={q.label} onTap={() => { redraw(""); void ui.assistant.ask(q.send); }}/>)}
441
+ {found.map((r) => <Button key={"p" + r.kind + r.id} role="pick" label={r.label} onTap={() => pickOne(r)}/>)}
442
+ </view>) : null}
443
+ <view style={{ ...rowOf(ui), alignItems: "flex-end" }}>
444
+ {host.pickFile || host.uploadFile ? <Button part="composer.attach" role="attach" label={t("composer.attach")} onTap={() => ui.assistant.attachFromDevice()}/> : null}
445
+ {can(host, "mic") ? <Button part="composer.mic" role="mic" label={listening ? pageTexts(ui.texts).t("composer.listening") : t("composer.mic")} onTap={() => void dictate()}/> : null}
446
+ <view style={{ ...grow, marginLeft: "8px", marginRight: "8px" }}>
401
447
  {lines > 1
402
448
  ? <textarea key={epoch} default-value={text} maxlines={lines} placeholder-color={hint(ui)} className={cls(ui, "composer.input")} style={{ ...field1, height: "auto", minHeight: "40px", paddingTop: "9px", paddingBottom: "9px" }} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} {...(chatOf(ui.assistant).enterSends === true ? { "confirm-type": "send", bindconfirm: () => void send() } : {})} bindinput={(e) => setText(e.detail.value)}/>
403
- : <input key={epoch} default-value={text} placeholder-color={hint(ui)} className={cls(ui, "composer.input")} style={field1} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} {...(chatOf(ui.assistant).enterSends === true ? { "confirm-type": "send", bindconfirm: () => void send() } : {})} bindinput={(e) => setText(e.detail.value)}/>}
404
- </view>
405
- <Button part={props.busy ? "composer.stop" : "composer.send"} role={props.busy ? "stop" : "send"} primary label={props.busy ? t("composer.stop") : t("composer.send")} onTap={() => void send()}/>
406
- </view>
449
+ : <input key={epoch} default-value={text} placeholder-color={hint(ui)} className={cls(ui, "composer.input")} style={field1} placeholder={t("composer.placeholder")} accessibility-label={t("composer.placeholder")} {...(chatOf(ui.assistant).enterSends === true ? { "confirm-type": "send", bindconfirm: () => void send() } : {})} bindinput={(e) => setText(e.detail.value)}/>}
450
+ </view>
451
+ <Button part={props.busy ? "composer.stop" : "composer.send"} role={props.busy ? "stop" : "send"} primary label={props.busy ? t("composer.stop") : t("composer.send")} onTap={() => void send()}/>
452
+ </view>
407
453
  </view>);
408
454
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/aiassistant-lynx",
3
- "version": "1.9.4",
3
+ "version": "1.9.6",
4
4
  "description": "ReactLynx components for the G9 AI assistant, fully customisable (layouts, tokens, per-part classes, overrides, parts).",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@g9tm/aiassistant": "1.9.4"
32
+ "@g9tm/aiassistant": "1.9.6"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@lynx-js/react": "0.129.2",