@chances-ai/client 24.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-core/client.d.ts +145 -0
- package/dist/client-core/client.d.ts.map +1 -0
- package/dist/client-core/client.js +533 -0
- package/dist/client-core/client.js.map +1 -0
- package/dist/client-core/index.d.ts +16 -0
- package/dist/client-core/index.d.ts.map +1 -0
- package/dist/client-core/index.js +15 -0
- package/dist/client-core/index.js.map +1 -0
- package/dist/client-core/reverse-map.d.ts +66 -0
- package/dist/client-core/reverse-map.d.ts.map +1 -0
- package/dist/client-core/reverse-map.js +86 -0
- package/dist/client-core/reverse-map.js.map +1 -0
- package/dist/client-core/store.d.ts +144 -0
- package/dist/client-core/store.d.ts.map +1 -0
- package/dist/client-core/store.js +36 -0
- package/dist/client-core/store.js.map +1 -0
- package/dist/client-core/transport.d.ts +53 -0
- package/dist/client-core/transport.d.ts.map +1 -0
- package/dist/client-core/transport.js +103 -0
- package/dist/client-core/transport.js.map +1 -0
- package/dist/web-ui/approval-badge.d.ts +17 -0
- package/dist/web-ui/approval-badge.d.ts.map +1 -0
- package/dist/web-ui/approval-badge.js +24 -0
- package/dist/web-ui/approval-badge.js.map +1 -0
- package/dist/web-ui/button.d.ts +10 -0
- package/dist/web-ui/button.d.ts.map +1 -0
- package/dist/web-ui/button.js +16 -0
- package/dist/web-ui/button.js.map +1 -0
- package/dist/web-ui/code-view.d.ts +6 -0
- package/dist/web-ui/code-view.d.ts.map +1 -0
- package/dist/web-ui/code-view.js +14 -0
- package/dist/web-ui/code-view.js.map +1 -0
- package/dist/web-ui/code-viewer.d.ts +11 -0
- package/dist/web-ui/code-viewer.d.ts.map +1 -0
- package/dist/web-ui/code-viewer.js +55 -0
- package/dist/web-ui/code-viewer.js.map +1 -0
- package/dist/web-ui/commands.d.ts +23 -0
- package/dist/web-ui/commands.d.ts.map +1 -0
- package/dist/web-ui/commands.js +26 -0
- package/dist/web-ui/commands.js.map +1 -0
- package/dist/web-ui/control-panel.d.ts +9 -0
- package/dist/web-ui/control-panel.d.ts.map +1 -0
- package/dist/web-ui/control-panel.js +70 -0
- package/dist/web-ui/control-panel.js.map +1 -0
- package/dist/web-ui/diff-view.d.ts +8 -0
- package/dist/web-ui/diff-view.d.ts.map +1 -0
- package/dist/web-ui/diff-view.js +28 -0
- package/dist/web-ui/diff-view.js.map +1 -0
- package/dist/web-ui/environment-panel.d.ts +9 -0
- package/dist/web-ui/environment-panel.d.ts.map +1 -0
- package/dist/web-ui/environment-panel.js +38 -0
- package/dist/web-ui/environment-panel.js.map +1 -0
- package/dist/web-ui/file-tree.d.ts +9 -0
- package/dist/web-ui/file-tree.d.ts.map +1 -0
- package/dist/web-ui/file-tree.js +77 -0
- package/dist/web-ui/file-tree.js.map +1 -0
- package/dist/web-ui/help-view.d.ts +13 -0
- package/dist/web-ui/help-view.d.ts.map +1 -0
- package/dist/web-ui/help-view.js +15 -0
- package/dist/web-ui/help-view.js.map +1 -0
- package/dist/web-ui/helpers.d.ts +77 -0
- package/dist/web-ui/helpers.d.ts.map +1 -0
- package/dist/web-ui/helpers.js +176 -0
- package/dist/web-ui/helpers.js.map +1 -0
- package/dist/web-ui/hooks.d.ts +7 -0
- package/dist/web-ui/hooks.d.ts.map +1 -0
- package/dist/web-ui/hooks.js +26 -0
- package/dist/web-ui/hooks.js.map +1 -0
- package/dist/web-ui/index.d.ts +32 -0
- package/dist/web-ui/index.d.ts.map +1 -0
- package/dist/web-ui/index.js +38 -0
- package/dist/web-ui/index.js.map +1 -0
- package/dist/web-ui/markdown.d.ts +12 -0
- package/dist/web-ui/markdown.d.ts.map +1 -0
- package/dist/web-ui/markdown.js +55 -0
- package/dist/web-ui/markdown.js.map +1 -0
- package/dist/web-ui/model-picker.d.ts +9 -0
- package/dist/web-ui/model-picker.d.ts.map +1 -0
- package/dist/web-ui/model-picker.js +119 -0
- package/dist/web-ui/model-picker.js.map +1 -0
- package/dist/web-ui/permission.d.ts +7 -0
- package/dist/web-ui/permission.d.ts.map +1 -0
- package/dist/web-ui/permission.js +25 -0
- package/dist/web-ui/permission.js.map +1 -0
- package/dist/web-ui/primitives.d.ts +59 -0
- package/dist/web-ui/primitives.d.ts.map +1 -0
- package/dist/web-ui/primitives.js +38 -0
- package/dist/web-ui/primitives.js.map +1 -0
- package/dist/web-ui/progress.d.ts +28 -0
- package/dist/web-ui/progress.d.ts.map +1 -0
- package/dist/web-ui/progress.js +45 -0
- package/dist/web-ui/progress.js.map +1 -0
- package/dist/web-ui/prompt-input.d.ts +15 -0
- package/dist/web-ui/prompt-input.d.ts.map +1 -0
- package/dist/web-ui/prompt-input.js +129 -0
- package/dist/web-ui/prompt-input.js.map +1 -0
- package/dist/web-ui/question-view.d.ts +7 -0
- package/dist/web-ui/question-view.d.ts.map +1 -0
- package/dist/web-ui/question-view.js +60 -0
- package/dist/web-ui/question-view.js.map +1 -0
- package/dist/web-ui/segments.d.ts +8 -0
- package/dist/web-ui/segments.d.ts.map +1 -0
- package/dist/web-ui/segments.js +19 -0
- package/dist/web-ui/segments.js.map +1 -0
- package/dist/web-ui/session-sidebar.d.ts +15 -0
- package/dist/web-ui/session-sidebar.d.ts.map +1 -0
- package/dist/web-ui/session-sidebar.js +10 -0
- package/dist/web-ui/session-sidebar.js.map +1 -0
- package/dist/web-ui/status-bar.d.ts +10 -0
- package/dist/web-ui/status-bar.d.ts.map +1 -0
- package/dist/web-ui/status-bar.js +10 -0
- package/dist/web-ui/status-bar.js.map +1 -0
- package/dist/web-ui/theme-context.d.ts +13 -0
- package/dist/web-ui/theme-context.d.ts.map +1 -0
- package/dist/web-ui/theme-context.js +31 -0
- package/dist/web-ui/theme-context.js.map +1 -0
- package/dist/web-ui/transcript.d.ts +27 -0
- package/dist/web-ui/transcript.d.ts.map +1 -0
- package/dist/web-ui/transcript.js +56 -0
- package/dist/web-ui/transcript.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (v17 M1 B3) Pure, framework-free helpers for the web control panel — colour
|
|
3
|
+
* lookups, label formatting, key/permission logic. Extracted out of the `.tsx`
|
|
4
|
+
* components so the BEHAVIOUR is unit-tested directly (no DOM, no Tamagui), and
|
|
5
|
+
* the components stay thin presentational shells. Everything here is a pure
|
|
6
|
+
* function of its inputs (the ui-core `Theme` + protocol/view types).
|
|
7
|
+
*/
|
|
8
|
+
import { SCOPE_TO_THEME } from "@chances-ai/ui-core";
|
|
9
|
+
/** Web monospace stack for code / diffs / the prompt box (a CSS value, applied
|
|
10
|
+
* via the `style` escape hatch — `fontFamily` is not a Tamagui token here). */
|
|
11
|
+
export const MONO = "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
|
|
12
|
+
/** The `⏺` tool dot colour: running (no result yet) → accent, ok → success,
|
|
13
|
+
* failed → error. `undefined` ⇒ inherit (NO_COLOR palette). */
|
|
14
|
+
export function toolDotColor(line, theme) {
|
|
15
|
+
if (line.ok === undefined)
|
|
16
|
+
return theme.accent;
|
|
17
|
+
return line.ok ? theme.success : theme.error;
|
|
18
|
+
}
|
|
19
|
+
/** Map a highlight scope to its themed colour, or `undefined` for plain text. */
|
|
20
|
+
export function segmentColor(scope, theme) {
|
|
21
|
+
const key = SCOPE_TO_THEME[scope];
|
|
22
|
+
return key ? theme[key] : undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Full-line background for a diff row (`undefined` for elision / NO_COLOR). */
|
|
25
|
+
export function diffRowBg(kind, theme) {
|
|
26
|
+
if (kind === "add")
|
|
27
|
+
return theme.diffAddedBg;
|
|
28
|
+
if (kind === "remove")
|
|
29
|
+
return theme.diffRemovedBg;
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
/** Word-level (intra-line) background for a changed word on an add/remove row. */
|
|
33
|
+
export function wordBg(kind, theme) {
|
|
34
|
+
if (kind === "add")
|
|
35
|
+
return theme.diffAddedWordBg;
|
|
36
|
+
if (kind === "remove")
|
|
37
|
+
return theme.diffRemovedWordBg;
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
/** `provider/model` — the option label + select value for {@link ModelInfo}. */
|
|
41
|
+
export function modelLabel(info) {
|
|
42
|
+
return `${info.provider}/${info.model}`;
|
|
43
|
+
}
|
|
44
|
+
/** (v22) Case-insensitive substring filter over `provider/model` labels. Empty
|
|
45
|
+
* query ⇒ every model (the picker's initial open state). Pure — unit-tested. */
|
|
46
|
+
export function filterModels(models, query) {
|
|
47
|
+
const q = query.trim().toLowerCase();
|
|
48
|
+
if (!q)
|
|
49
|
+
return [...models];
|
|
50
|
+
return models.filter((m) => modelLabel(m).toLowerCase().includes(q));
|
|
51
|
+
}
|
|
52
|
+
/** Whether a key event in the prompt box should submit: Enter without Shift,
|
|
53
|
+
* and not mid-IME-composition (so CJK candidate selection doesn't submit). */
|
|
54
|
+
export function shouldSubmit(e) {
|
|
55
|
+
if (e.key !== "Enter" || e.shiftKey)
|
|
56
|
+
return false;
|
|
57
|
+
return e.nativeEvent?.isComposing !== true;
|
|
58
|
+
}
|
|
59
|
+
/** The three permission choices, in display order (mirrors the TUI y / a / n). */
|
|
60
|
+
export function permissionActions() {
|
|
61
|
+
return [
|
|
62
|
+
{ key: "allow", label: "Allow once", allow: true, remember: false, tone: "success" },
|
|
63
|
+
{ key: "always", label: "Allow & don't ask", allow: true, remember: true, tone: "accent" },
|
|
64
|
+
{ key: "deny", label: "Deny", allow: false, remember: false, tone: "error" },
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
/** The colour a `tone` resolves to against a palette. */
|
|
68
|
+
export function toneColor(tone, theme) {
|
|
69
|
+
return theme[tone];
|
|
70
|
+
}
|
|
71
|
+
/** Build the permission buttons, each press bound to `onAnswer(allow, remember)`
|
|
72
|
+
* for its action. The single source of the prompt's interactive behaviour. */
|
|
73
|
+
export function buildPermissionButtons(theme, onAnswer) {
|
|
74
|
+
return permissionActions().map((a) => ({
|
|
75
|
+
key: a.key,
|
|
76
|
+
label: a.label,
|
|
77
|
+
color: toneColor(a.tone, theme),
|
|
78
|
+
onPress: () => onAnswer(a.allow, a.remember),
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
/** Human-readable connection status for the status bar. */
|
|
82
|
+
export function statusText(status) {
|
|
83
|
+
switch (status) {
|
|
84
|
+
case "connecting":
|
|
85
|
+
return "connecting…";
|
|
86
|
+
case "ready":
|
|
87
|
+
return "ready";
|
|
88
|
+
case "reconnecting":
|
|
89
|
+
return "reconnecting…";
|
|
90
|
+
case "closed":
|
|
91
|
+
return "disconnected";
|
|
92
|
+
case "error":
|
|
93
|
+
return "error";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Status dot / label colour. */
|
|
97
|
+
export function statusColor(status, theme) {
|
|
98
|
+
switch (status) {
|
|
99
|
+
case "ready":
|
|
100
|
+
return theme.success;
|
|
101
|
+
case "connecting":
|
|
102
|
+
case "reconnecting":
|
|
103
|
+
return theme.warning;
|
|
104
|
+
case "error":
|
|
105
|
+
return theme.error;
|
|
106
|
+
case "closed":
|
|
107
|
+
return theme.synComment;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** Compact usage line: `in→out tok · $cost`. */
|
|
111
|
+
export function formatUsage(u) {
|
|
112
|
+
return `${u.inputTokens}→${u.outputTokens} tok · $${u.costUsd.toFixed(4)}`;
|
|
113
|
+
}
|
|
114
|
+
// -- (v23 M5) file tree / code viewer helpers --------------------------------
|
|
115
|
+
/** Map a file extension to a highlight.js language the shared `highlightToSegments`
|
|
116
|
+
* knows (its registered set). `undefined` ⇒ render as plain text. Pure. */
|
|
117
|
+
export function langFromPath(path) {
|
|
118
|
+
const dot = path.lastIndexOf(".");
|
|
119
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
120
|
+
const ext = dot > 0 ? path.slice(dot + 1).toLowerCase() : "";
|
|
121
|
+
// Extensionless files keyed by name (Dockerfile, Makefile-ish).
|
|
122
|
+
if (base === "Dockerfile")
|
|
123
|
+
return "dockerfile";
|
|
124
|
+
const map = {
|
|
125
|
+
ts: "typescript",
|
|
126
|
+
tsx: "typescript",
|
|
127
|
+
mts: "typescript",
|
|
128
|
+
cts: "typescript",
|
|
129
|
+
js: "javascript",
|
|
130
|
+
jsx: "javascript",
|
|
131
|
+
mjs: "javascript",
|
|
132
|
+
cjs: "javascript",
|
|
133
|
+
py: "python",
|
|
134
|
+
rs: "rust",
|
|
135
|
+
go: "go",
|
|
136
|
+
java: "java",
|
|
137
|
+
rb: "ruby",
|
|
138
|
+
c: "c",
|
|
139
|
+
h: "c",
|
|
140
|
+
cpp: "cpp",
|
|
141
|
+
cc: "cpp",
|
|
142
|
+
hpp: "cpp",
|
|
143
|
+
css: "css",
|
|
144
|
+
json: "json",
|
|
145
|
+
md: "markdown",
|
|
146
|
+
markdown: "markdown",
|
|
147
|
+
sql: "sql",
|
|
148
|
+
toml: "toml",
|
|
149
|
+
yaml: "yaml",
|
|
150
|
+
yml: "yaml",
|
|
151
|
+
sh: "bash",
|
|
152
|
+
bash: "bash",
|
|
153
|
+
zsh: "bash",
|
|
154
|
+
xml: "xml",
|
|
155
|
+
html: "xml",
|
|
156
|
+
};
|
|
157
|
+
return map[ext];
|
|
158
|
+
}
|
|
159
|
+
/** A git porcelain XY status code → a one-letter badge + theme tone for the file
|
|
160
|
+
* tree. `??` untracked, `A` added, `M` modified, `D` deleted, `R` renamed. Pure. */
|
|
161
|
+
export function gitBadge(status) {
|
|
162
|
+
if (!status)
|
|
163
|
+
return null;
|
|
164
|
+
if (status === "??")
|
|
165
|
+
return { char: "U", tone: "warning" };
|
|
166
|
+
if (status.includes("D"))
|
|
167
|
+
return { char: "D", tone: "error" };
|
|
168
|
+
if (status.includes("A"))
|
|
169
|
+
return { char: "A", tone: "success" };
|
|
170
|
+
if (status.includes("R"))
|
|
171
|
+
return { char: "R", tone: "accent" };
|
|
172
|
+
if (status.includes("M"))
|
|
173
|
+
return { char: "M", tone: "warning" };
|
|
174
|
+
return { char: status.trim().charAt(0) || "•", tone: "accent" };
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/web-ui/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAuC,MAAM,qBAAqB,CAAC;AAG1F;gFACgF;AAChF,MAAM,CAAC,MAAM,IAAI,GAAG,0DAA0D,CAAC;AAE/E;gEACgE;AAChE,MAAM,UAAU,YAAY,CAAC,IAAsB,EAAE,KAAY;IAC/D,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,MAAM,CAAC;IAC/C,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;AAC/C,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,KAAY;IACvD,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,SAAS,CAAC,IAAkC,EAAE,KAAY;IACxE,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC,WAAW,CAAC;IAC7C,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,aAAa,CAAC;IAClD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,MAAM,CAAC,IAAkC,EAAE,KAAY;IACrE,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC,eAAe,CAAC;IACjD,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,iBAAiB,CAAC;IACtD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,EAAE,MAAM;QACZ,GAAG,EAAE,MAAM;QACX,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,MAAM;QACX,GAAG,EAAE,KAAK;QACV,IAAI,EAAE,KAAK;KACZ,CAAC;IACF,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC;AAED;qFACqF;AACrF,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC3D,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC9D,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAChE,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC/D,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAChE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClientState, ClientStore } from "../client-core/index.js";
|
|
2
|
+
import type { ChatViewModel, Line } from "@chances-ai/ui-core";
|
|
3
|
+
/** Subscribe React to the connection/control store; returns the live snapshot. */
|
|
4
|
+
export declare function useClientState(store: ClientStore): ClientState;
|
|
5
|
+
/** Subscribe React to the transcript view-model; returns the current lines. */
|
|
6
|
+
export declare function useTranscript(view: ChatViewModel): Line[];
|
|
7
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/web-ui/hooks.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE/D,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAE9D;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,EAAE,CAGzD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (v17 M1 B3) The two `useSyncExternalStore` bridges that connect React to the
|
|
3
|
+
* client-core state. They are intentionally tiny — the hard logic lives in
|
|
4
|
+
* client-core (the store + the ChatViewModel); these just subscribe React to it.
|
|
5
|
+
*
|
|
6
|
+
* `useClientState` returns the WHOLE store snapshot: vanilla-zustand `setState`
|
|
7
|
+
* publishes a fresh object reference on every change, so React's `Object.is`
|
|
8
|
+
* bail-out re-renders exactly when the connection state changes — no selector /
|
|
9
|
+
* equality function needed for an M1 single-panel surface.
|
|
10
|
+
*
|
|
11
|
+
* `useTranscript` subscribes to the ChatViewModel's monotonic version counter
|
|
12
|
+
* (its `getSnapshot`); the line array is mutated in place (streamed text grows
|
|
13
|
+
* on the same object), so the version — NOT the array reference — is the change
|
|
14
|
+
* signal. The hook returns `view.lines` read fresh after a confirmed re-render.
|
|
15
|
+
*/
|
|
16
|
+
import { useSyncExternalStore } from "react";
|
|
17
|
+
/** Subscribe React to the connection/control store; returns the live snapshot. */
|
|
18
|
+
export function useClientState(store) {
|
|
19
|
+
return useSyncExternalStore(store.subscribe, store.getState, store.getState);
|
|
20
|
+
}
|
|
21
|
+
/** Subscribe React to the transcript view-model; returns the current lines. */
|
|
22
|
+
export function useTranscript(view) {
|
|
23
|
+
useSyncExternalStore(view.subscribe, view.getSnapshot, view.getSnapshot);
|
|
24
|
+
return view.lines;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/web-ui/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAI7C,kFAAkF;AAClF,MAAM,UAAU,cAAc,CAAC,KAAkB;IAC/C,OAAO,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC/E,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,aAAa,CAAC,IAAmB;IAC/C,oBAAoB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACzE,OAAO,IAAI,CAAC,KAAK,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@chances-ai/web-ui` — the React-DOM component layer for the web (and, later,
|
|
3
|
+
* Electron) control panel. It composes the browser-safe `@chances-ai/client-core`
|
|
4
|
+
* RpcClient + `@chances-ai/ui-core` view-model (palette + `themeCssVars`) with
|
|
5
|
+
* HeroUI v3 components to render the live agent transcript, the permission
|
|
6
|
+
* round-trip, and the prompt/model/abort controls. No engine code, no `node:*`
|
|
7
|
+
* (docs/6.1 §4 / v17 M1 B3; v22 retired the Tamagui design-system).
|
|
8
|
+
*/
|
|
9
|
+
export { ControlPanel, type ControlPanelProps } from "./control-panel.js";
|
|
10
|
+
export { Transcript, TranscriptLine } from "./transcript.js";
|
|
11
|
+
export { Markdown } from "./markdown.js";
|
|
12
|
+
export { CodeView, type CodeViewProps } from "./code-view.js";
|
|
13
|
+
export { Progress, type ProgressProps } from "./progress.js";
|
|
14
|
+
export { ApprovalBadge, type ApprovalBadgeProps } from "./approval-badge.js";
|
|
15
|
+
export { CodeSegments, type CodeSegmentsProps } from "./segments.js";
|
|
16
|
+
export { DiffBlock, type DiffBlockProps } from "./diff-view.js";
|
|
17
|
+
export { PermissionPrompt, type PermissionPromptProps } from "./permission.js";
|
|
18
|
+
export { QuestionView, type QuestionViewProps } from "./question-view.js";
|
|
19
|
+
export { HelpView, type HelpViewProps } from "./help-view.js";
|
|
20
|
+
export { type WebCommand, suggestWebCommands, parseCommandName } from "./commands.js";
|
|
21
|
+
export { PromptInput, type PromptInputProps } from "./prompt-input.js";
|
|
22
|
+
export { ModelPicker, type ModelPickerProps } from "./model-picker.js";
|
|
23
|
+
export { StatusBar } from "./status-bar.js";
|
|
24
|
+
export { Button, type ButtonProps } from "./button.js";
|
|
25
|
+
export { FileTree, type FileTreeProps } from "./file-tree.js";
|
|
26
|
+
export { CodeViewer, type CodeViewerProps } from "./code-viewer.js";
|
|
27
|
+
export { EnvironmentPanel, type EnvironmentPanelProps } from "./environment-panel.js";
|
|
28
|
+
export { SessionSidebar, type SessionSidebarProps } from "./session-sidebar.js";
|
|
29
|
+
export { useClientState, useTranscript } from "./hooks.js";
|
|
30
|
+
export { GLYPHS, themeFor, UiThemeProvider, useUiTheme, type Mode } from "./theme-context.js";
|
|
31
|
+
export { MONO, buildPermissionButtons, diffRowBg, filterModels, formatUsage, gitBadge, langFromPath, modelLabel, permissionActions, segmentColor, shouldSubmit, statusColor, statusText, toneColor, toolDotColor, wordBg, type PermissionAction, type PermissionButton, } from "./helpers.js";
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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gB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG9F,OAAO,EACL,IAAI,EACJ,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@chances-ai/web-ui` — the React-DOM component layer for the web (and, later,
|
|
3
|
+
* Electron) control panel. It composes the browser-safe `@chances-ai/client-core`
|
|
4
|
+
* RpcClient + `@chances-ai/ui-core` view-model (palette + `themeCssVars`) with
|
|
5
|
+
* HeroUI v3 components to render the live agent transcript, the permission
|
|
6
|
+
* round-trip, and the prompt/model/abort controls. No engine code, no `node:*`
|
|
7
|
+
* (docs/6.1 §4 / v17 M1 B3; v22 retired the Tamagui design-system).
|
|
8
|
+
*/
|
|
9
|
+
// The composed app shell `apps/web` mounts.
|
|
10
|
+
export { ControlPanel } from "./control-panel.js";
|
|
11
|
+
// Presentational pieces (also the units rendered by the smoke tests).
|
|
12
|
+
export { Transcript, TranscriptLine } from "./transcript.js";
|
|
13
|
+
export { Markdown } from "./markdown.js";
|
|
14
|
+
export { CodeView } from "./code-view.js";
|
|
15
|
+
export { Progress } from "./progress.js";
|
|
16
|
+
export { ApprovalBadge } from "./approval-badge.js";
|
|
17
|
+
export { CodeSegments } from "./segments.js";
|
|
18
|
+
export { DiffBlock } from "./diff-view.js";
|
|
19
|
+
export { PermissionPrompt } from "./permission.js";
|
|
20
|
+
export { QuestionView } from "./question-view.js";
|
|
21
|
+
export { HelpView } from "./help-view.js";
|
|
22
|
+
export { suggestWebCommands, parseCommandName } from "./commands.js";
|
|
23
|
+
export { PromptInput } from "./prompt-input.js";
|
|
24
|
+
export { ModelPicker } from "./model-picker.js";
|
|
25
|
+
export { StatusBar } from "./status-bar.js";
|
|
26
|
+
export { Button } from "./button.js";
|
|
27
|
+
// (v23 M5) The 3-pane IDE surfaces.
|
|
28
|
+
export { FileTree } from "./file-tree.js";
|
|
29
|
+
export { CodeViewer } from "./code-viewer.js";
|
|
30
|
+
export { EnvironmentPanel } from "./environment-panel.js";
|
|
31
|
+
export { SessionSidebar } from "./session-sidebar.js";
|
|
32
|
+
// React ↔ client-core bridges.
|
|
33
|
+
export { useClientState, useTranscript } from "./hooks.js";
|
|
34
|
+
// Theme plumbing.
|
|
35
|
+
export { GLYPHS, themeFor, UiThemeProvider, useUiTheme } from "./theme-context.js";
|
|
36
|
+
// Pure helpers (colour/label/key/permission logic).
|
|
37
|
+
export { MONO, buildPermissionButtons, diffRowBg, filterModels, formatUsage, gitBadge, langFromPath, modelLabel, permissionActions, segmentColor, shouldSubmit, statusColor, statusText, toneColor, toolDotColor, wordBg, } from "./helpers.js";
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/web-ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,4CAA4C;AAC5C,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAE1E,sEAAsE;AACtE,OAAO,EAAE,UAAU,EAAE,cAAc,EAA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,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,GAGP,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (v22 / docs/6.5b §C3) Render committed assistant text as Markdown in the DOM —
|
|
3
|
+
* the web twin of `tui/markdown.tsx`. Parsing is the SHARED `parseMarkdown`
|
|
4
|
+
* (ui-core), so the terminal and web agree on what every block/inline means; this
|
|
5
|
+
* file only walks the `MdNode[]` with DOM + the ui-core palette. Content colors
|
|
6
|
+
* (h1 accent, codespan, link) come from the ui-core `Theme` via `useUiTheme`.
|
|
7
|
+
*/
|
|
8
|
+
import type { JSX } from "react";
|
|
9
|
+
export declare function Markdown({ text }: {
|
|
10
|
+
text: string;
|
|
11
|
+
}): JSX.Element;
|
|
12
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/web-ui/markdown.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,OAAO,CAAC;AAO5C,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAUhE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { parseMarkdown } from "@chances-ai/ui-core";
|
|
3
|
+
import { CodeView } from "./code-view.js";
|
|
4
|
+
import { MONO } from "./helpers.js";
|
|
5
|
+
import { Box, Txt } from "./primitives.js";
|
|
6
|
+
import { GLYPHS, useUiTheme } from "./theme-context.js";
|
|
7
|
+
export function Markdown({ text }) {
|
|
8
|
+
const theme = useUiTheme();
|
|
9
|
+
const nodes = parseMarkdown(text);
|
|
10
|
+
return (_jsx(Box, { gap: 4, children: nodes.map((node, i) => (_jsx(Block, { node: node, theme: theme }, i))) }));
|
|
11
|
+
}
|
|
12
|
+
function Block({ node, theme }) {
|
|
13
|
+
switch (node.kind) {
|
|
14
|
+
case "space":
|
|
15
|
+
return null;
|
|
16
|
+
case "heading":
|
|
17
|
+
return (_jsx(Txt, { color: node.depth === 1 ? theme.accent : "var(--ch-fg)", fontWeight: 700, style: { display: "block", fontSize: node.depth === 1 ? 18 : 15 }, children: renderInline(node.children, theme) }));
|
|
18
|
+
case "paragraph":
|
|
19
|
+
return (_jsx(Txt, { color: "var(--ch-fg)", style: { display: "block", overflowWrap: "anywhere" }, children: renderInline(node.children, theme) }));
|
|
20
|
+
case "code":
|
|
21
|
+
return _jsx(CodeView, { code: node.text, lang: node.lang });
|
|
22
|
+
case "blockquote":
|
|
23
|
+
return (_jsx(Box, { children: node.lines.map((line, i) => (_jsxs(Txt, { color: theme.synComment, style: { display: "block" }, children: [GLYPHS.blockquote, " ", line] }, i))) }));
|
|
24
|
+
case "list":
|
|
25
|
+
return (_jsx(Box, { children: node.items.map((item, i) => (_jsxs(Txt, { color: "var(--ch-fg)", style: { display: "block" }, children: [node.ordered ? `${node.start + i}.` : GLYPHS.bullet, " ", renderInline(item, theme)] }, i))) }));
|
|
26
|
+
case "hr":
|
|
27
|
+
return _jsx("hr", { style: { width: "100%", border: "none", borderTop: `1px solid ${theme.synComment ?? "currentColor"}`, opacity: 0.5, margin: "4px 0" } });
|
|
28
|
+
case "table":
|
|
29
|
+
return (_jsxs("table", { style: { borderCollapse: "collapse", fontFamily: MONO, fontSize: 13 }, children: [_jsx("thead", { children: _jsx("tr", { children: node.header.map((h, i) => (_jsx("th", { style: { textAlign: "left", padding: "2px 8px", borderBottom: `1px solid ${theme.synComment ?? "currentColor"}` }, children: h }, i))) }) }), _jsx("tbody", { children: node.rows.map((row, i) => (_jsx("tr", { children: row.map((c, j) => (_jsx("td", { style: { padding: "2px 8px" }, children: c }, j))) }, i))) })] }));
|
|
30
|
+
case "raw":
|
|
31
|
+
return node.text ? (_jsx(Txt, { color: "var(--ch-fg)", style: { display: "block", whiteSpace: "pre-wrap", overflowWrap: "anywhere" }, children: node.text })) : null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Render inline nodes into DOM runs (the web twin of the Ink inline renderer). */
|
|
35
|
+
function renderInline(nodes, theme) {
|
|
36
|
+
return nodes.map((n, i) => {
|
|
37
|
+
switch (n.kind) {
|
|
38
|
+
case "text":
|
|
39
|
+
return n.text;
|
|
40
|
+
case "strong":
|
|
41
|
+
return (_jsx("strong", { children: renderInline(n.children, theme) }, i));
|
|
42
|
+
case "em":
|
|
43
|
+
return _jsx("em", { children: renderInline(n.children, theme) }, i);
|
|
44
|
+
case "del":
|
|
45
|
+
return _jsx("del", { children: renderInline(n.children, theme) }, i);
|
|
46
|
+
case "codespan":
|
|
47
|
+
return (_jsx(Txt, { color: theme.synString, style: { fontFamily: MONO }, children: n.text }, i));
|
|
48
|
+
case "link":
|
|
49
|
+
return (_jsxs(Txt, { children: [_jsx("a", { href: n.href, target: "_blank", rel: "noopener noreferrer", style: { color: theme.accent }, children: renderInline(n.children, theme) }), n.showUrl ? (_jsxs(Txt, { color: theme.synComment, children: [" (", n.href, ")"] })) : null] }, i));
|
|
50
|
+
case "br":
|
|
51
|
+
return _jsx("br", {}, i);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/web-ui/markdown.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,aAAa,EAA0C,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO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iB,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAnC,CAAC,CAA4C,CAC3D,CAAC;YACJ,KAAK,IAAI;gBACP,OAAO,uBAAa,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAnC,CAAC,CAAwC,CAAC;YAC5D,KAAK,KAAK;gBACR,OAAO,wBAAc,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAnC,CAAC,CAAyC,CAAC;YAC9D,KAAK,UAAU;gBACb,OAAO,CACL,KAAC,GAAG,IAAS,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAC7D,CAAC,CAAC,IAAI,IADC,CAAC,CAEL,CACP,CAAC;YACJ,KAAK,MAAM;gBACT,OAAO,CACL,MAAC,GAAG,eACF,YAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,qBAAqB,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,YACtF,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,GAC9B,EACH,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CACX,MAAC,GAAG,IAAC,KAAK,EAAE,KAAK,CAAC,UAAU,mBAAK,CAAC,CAAC,IAAI,SAAQ,CAChD,CAAC,CAAC,CAAC,IAAI,KANA,CAAC,CAOL,CACP,CAAC;YACJ,KAAK,IAAI;gBACP,OAAO,eAAS,CAAC,CAAI,CAAC;QAC1B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ModelInfo } from "../client-core/index.js";
|
|
2
|
+
export interface ModelPickerProps {
|
|
3
|
+
models: ModelInfo[];
|
|
4
|
+
selected: ModelInfo | null;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
onSelect: (info: ModelInfo) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function ModelPicker({ models, selected, disabled, onSelect }: ModelPickerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
//# sourceMappingURL=model-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-picker.d.ts","sourceRoot":"","sources":["../../src/web-ui/model-picker.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIzD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACrC;AAED,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,gBAAgB,kDAmJrF"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* (v22 / docs/6.5b §C4) Filterable model picker — the web twin of the TUI's
|
|
4
|
+
* `Select`-based model picker, replacing the v17 native `<select>`. A trigger
|
|
5
|
+
* button opens a small dropdown with a filter input + a keyboard-navigable list
|
|
6
|
+
* (↑↓ move, Enter selects, Esc closes, click selects). The filtering is the pure
|
|
7
|
+
* `filterModels` (unit-tested); the component is the thin interactive shell
|
|
8
|
+
* (DOM-tested). Hidden when no models are advertised (pre-`ready`).
|
|
9
|
+
*
|
|
10
|
+
* Bespoke rather than a HeroUI compound `Autocomplete` on purpose: a tinted,
|
|
11
|
+
* inline, fully-keyboard-driven picker is small, self-contained, and reliably
|
|
12
|
+
* testable under happy-dom. HeroUI v3 components are used where their richer
|
|
13
|
+
* behaviour (modal focus-trap, tabs) earns the compound API.
|
|
14
|
+
*/
|
|
15
|
+
import { useEffect, useRef, useState } from "react";
|
|
16
|
+
import { filterModels, MONO, modelLabel } from "./helpers.js";
|
|
17
|
+
import { useUiTheme } from "./theme-context.js";
|
|
18
|
+
export function ModelPicker({ models, selected, disabled, onSelect }) {
|
|
19
|
+
const theme = useUiTheme();
|
|
20
|
+
const [open, setOpen] = useState(false);
|
|
21
|
+
const [query, setQuery] = useState("");
|
|
22
|
+
const [cursor, setCursor] = useState(0);
|
|
23
|
+
const inputRef = useRef(null);
|
|
24
|
+
const filtered = filterModels(models, query);
|
|
25
|
+
// Keep the cursor in range as the filtered list shrinks/grows.
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setCursor((c) => Math.max(0, Math.min(c, filtered.length - 1)));
|
|
28
|
+
}, [filtered.length]);
|
|
29
|
+
// Focus the filter input when the panel opens.
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (open)
|
|
32
|
+
inputRef.current?.focus();
|
|
33
|
+
}, [open]);
|
|
34
|
+
if (models.length === 0)
|
|
35
|
+
return null;
|
|
36
|
+
const close = () => {
|
|
37
|
+
setOpen(false);
|
|
38
|
+
setQuery("");
|
|
39
|
+
setCursor(0);
|
|
40
|
+
};
|
|
41
|
+
const choose = (m) => {
|
|
42
|
+
onSelect(m);
|
|
43
|
+
close();
|
|
44
|
+
};
|
|
45
|
+
const onKeyDown = (e) => {
|
|
46
|
+
if (e.key === "ArrowDown") {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
setCursor((c) => Math.min(filtered.length - 1, c + 1));
|
|
49
|
+
}
|
|
50
|
+
else if (e.key === "ArrowUp") {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
setCursor((c) => Math.max(0, c - 1));
|
|
53
|
+
}
|
|
54
|
+
else if (e.key === "Enter") {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
const m = filtered[cursor];
|
|
57
|
+
if (m)
|
|
58
|
+
choose(m);
|
|
59
|
+
}
|
|
60
|
+
else if (e.key === "Escape") {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
close();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const border = theme.synComment ?? "#555";
|
|
66
|
+
return (_jsxs("div", { style: { position: "relative" }, children: [_jsxs("button", { type: "button", disabled: disabled, "aria-haspopup": "listbox", "aria-expanded": open, onClick: () => (open ? close() : setOpen(true)), className: disabled ? "" : "transition-opacity hover:opacity-70", style: {
|
|
67
|
+
fontFamily: MONO,
|
|
68
|
+
fontSize: 13,
|
|
69
|
+
padding: "4px 8px",
|
|
70
|
+
borderRadius: 6,
|
|
71
|
+
background: "transparent",
|
|
72
|
+
color: "inherit",
|
|
73
|
+
border: `1px solid ${border}`,
|
|
74
|
+
cursor: disabled ? "default" : "pointer",
|
|
75
|
+
opacity: disabled ? 0.5 : 1,
|
|
76
|
+
}, children: [selected ? modelLabel(selected) : "select model", " \u25BE"] }), open ? (_jsxs("div", { role: "listbox", "aria-label": "models", style: {
|
|
77
|
+
position: "absolute",
|
|
78
|
+
top: "calc(100% + 4px)",
|
|
79
|
+
right: 0,
|
|
80
|
+
zIndex: 10,
|
|
81
|
+
minWidth: 240,
|
|
82
|
+
maxHeight: 320,
|
|
83
|
+
overflowY: "auto",
|
|
84
|
+
background: "var(--ch-bg)",
|
|
85
|
+
border: `1px solid ${border}`,
|
|
86
|
+
borderRadius: 8,
|
|
87
|
+
padding: 6,
|
|
88
|
+
display: "flex",
|
|
89
|
+
flexDirection: "column",
|
|
90
|
+
gap: 2,
|
|
91
|
+
}, children: [_jsx("input", { ref: inputRef, value: query, placeholder: "filter models\u2026", "aria-label": "filter models", onChange: (e) => {
|
|
92
|
+
setQuery(e.target.value);
|
|
93
|
+
setCursor(0);
|
|
94
|
+
}, onKeyDown: onKeyDown, style: {
|
|
95
|
+
fontFamily: MONO,
|
|
96
|
+
fontSize: 13,
|
|
97
|
+
padding: "4px 6px",
|
|
98
|
+
marginBottom: 4,
|
|
99
|
+
background: "transparent",
|
|
100
|
+
color: "inherit",
|
|
101
|
+
border: `1px solid ${border}`,
|
|
102
|
+
borderRadius: 6,
|
|
103
|
+
outline: "none",
|
|
104
|
+
} }), filtered.length === 0 ? (_jsx("span", { style: { color: theme.synComment, fontSize: 13, padding: "4px 6px" }, children: "no match" })) : (filtered.map((m, i) => {
|
|
105
|
+
const label = modelLabel(m);
|
|
106
|
+
const isCurrent = selected ? modelLabel(selected) === label : false;
|
|
107
|
+
const highlighted = i === cursor;
|
|
108
|
+
return (_jsxs("div", { role: "option", "aria-selected": highlighted, onMouseEnter: () => setCursor(i), onClick: () => choose(m), style: {
|
|
109
|
+
fontFamily: MONO,
|
|
110
|
+
fontSize: 13,
|
|
111
|
+
padding: "4px 6px",
|
|
112
|
+
borderRadius: 6,
|
|
113
|
+
cursor: "pointer",
|
|
114
|
+
background: highlighted ? theme.userMessageBg : "transparent",
|
|
115
|
+
color: isCurrent ? theme.accent : "var(--ch-fg)",
|
|
116
|
+
}, children: [isCurrent ? "● " : " ", label] }, label));
|
|
117
|
+
}))] })) : null] }));
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=model-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-picker.js","sourceRoot":"","sources":["../../src/web-ui/model-picker.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAShD,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAoB;IACpF,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;IAC3B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC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;oBACJ,CAAC,CAAC,CACH,IACG,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PendingPermission } from "../client-core/index.js";
|
|
2
|
+
export interface PermissionPromptProps {
|
|
3
|
+
pending: PendingPermission;
|
|
4
|
+
onAnswer: (allow: boolean, remember: boolean) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function PermissionPrompt({ pending, onAnswer }: PermissionPromptProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=permission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../src/web-ui/permission.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAOjE,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,qBAAqB,2CAyB5E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* (v17 M1 B3 / R1 M1; v22) The permission round-trip's UI half — without it a
|
|
4
|
+
* write/bash turn dead-locks (the engine parks on `request_permission`). The
|
|
5
|
+
* card surfaces the pending ask (tool + category + summary, with the write/edit
|
|
6
|
+
* diff rendered structurally) and three choices mirroring the TUI's y / a / n.
|
|
7
|
+
* Each press calls `RpcClient.answerPermission(allow, remember)`, which sends
|
|
8
|
+
* `permission_response` back over the wire and clears the pending state.
|
|
9
|
+
*/
|
|
10
|
+
import { extractDiff, toolDisplayName } from "@chances-ai/ui-core";
|
|
11
|
+
import { Button } from "./button.js";
|
|
12
|
+
import { DiffBlock } from "./diff-view.js";
|
|
13
|
+
import { buildPermissionButtons } from "./helpers.js";
|
|
14
|
+
import { Box, Txt } from "./primitives.js";
|
|
15
|
+
import { useUiTheme } from "./theme-context.js";
|
|
16
|
+
export function PermissionPrompt({ pending, onAnswer }) {
|
|
17
|
+
const theme = useUiTheme();
|
|
18
|
+
const diff = extractDiff(pending.summary);
|
|
19
|
+
// The prose head is everything before the diff hunk (or the whole summary).
|
|
20
|
+
const head = diff
|
|
21
|
+
? pending.summary.slice(0, pending.summary.indexOf(diff)).trimEnd()
|
|
22
|
+
: pending.summary;
|
|
23
|
+
return (_jsxs(Box, { borderWidth: 1, borderColor: theme.permission, borderRadius: 8, padding: 12, gap: 8, backgroundColor: "var(--ch-bg)", children: [_jsxs(Txt, { color: theme.permission, fontWeight: "700", children: ["Permission required \u00B7 ", toolDisplayName(pending.tool), " (", pending.category, ")"] }), head ? (_jsx(Txt, { color: "var(--ch-fg)", style: { whiteSpace: "pre-wrap", overflowWrap: "anywhere" }, children: head })) : null, diff ? _jsx(DiffBlock, { diff: diff, anchored: pending.tool === "write" }) : null, _jsx(Box, { flexDirection: "row", gap: 8, flexWrap: "wrap", children: buildPermissionButtons(theme, onAnswer).map((b) => (_jsx(Button, { label: b.label, color: b.color, onPress: b.onPress }, b.key))) })] }));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=permission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission.js","sourceRoot":"","sources":["../../src/web-ui/permission.tsx"],"names":[],"mappings":";AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;A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