acryl 0.1.15 → 0.1.17
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/README.md +64 -3
- package/lib/bin.js +385 -49
- package/lib/bin.js.map +1 -1
- package/lib/index.js +385 -49
- package/lib/index.js.map +1 -1
- package/package.json +12 -5
package/README.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ACRYL
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A persistent, agent-agnostic coding environment.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Keep your project, context, and workflow while changing coding agents.
|
|
6
|
+
|
|
7
|
+
ACRYL owns the persistent development environment - workspace, context, tasks, artifacts, sessions, and handoffs - while coding agents remain replaceable workers. Use Claude Code, Codex, OpenCode, Pi, Gemini CLI, DeepSeek, ACP-compatible agents, or your own agent without tying your project to any one of them.
|
|
8
|
+
|
|
9
|
+
**Same project. Same context. Same work. Different agents.**
|
|
10
|
+
|
|
11
|
+
ACRYL is built to adapt to your workflow, not lock you into an agent. Extend it with agents, tools, context systems, memory, workflows, terminals, UI capabilities, and Cordis plugins.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g acryl
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Run
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
acryl # terminal client (default)
|
|
23
|
+
acryl web # serve the local ACRYL web runtime
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
A standalone Desktop application is distributed separately.
|
|
27
|
+
|
|
28
|
+
## Why ACRYL?
|
|
29
|
+
|
|
30
|
+
Coding agents are temporary. Your development context shouldn't be.
|
|
31
|
+
|
|
32
|
+
Most coding agents own their own sessions, context, tools, and history. Switching agents usually means starting over, copying context manually, or maintaining several disconnected development environments.
|
|
33
|
+
|
|
34
|
+
ACRYL reverses that relationship:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
Project and context
|
|
38
|
+
↓
|
|
39
|
+
ACRYL
|
|
40
|
+
↓
|
|
41
|
+
Coding agents
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The project belongs to ACRYL. Agents enter, work, and leave.
|
|
45
|
+
|
|
46
|
+
## Make it yours
|
|
47
|
+
|
|
48
|
+
ACRYL is built around composable capabilities rather than a sealed application.
|
|
49
|
+
|
|
50
|
+
Agents, models, tools, memory systems, context engines, terminals, workflows, editors, and UI surfaces can be provided as replaceable capabilities.
|
|
51
|
+
|
|
52
|
+
Underneath, ACRYL uses Cordis for lifecycle-managed plugins, replaceable services, reactive dependency injection, typed events, scoped composition, and reversible effects.
|
|
53
|
+
|
|
54
|
+
The goal is simple:
|
|
55
|
+
|
|
56
|
+
**Change the agent, extend the environment, keep the work.**
|
|
57
|
+
|
|
58
|
+
## Links
|
|
59
|
+
|
|
60
|
+
- Website: https://acryl.dev
|
|
61
|
+
- Source: https://github.com/acryldev/acryl
|
|
62
|
+
- Discord: https://discord.gg/cY9KXMex69
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
package/lib/bin.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { existsSync, realpathSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join, relative, resolve } from "node:path";
|
|
6
|
-
import { spawn } from "node:child_process";
|
|
6
|
+
import { execFile, spawn } from "node:child_process";
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
8
8
|
import { BlockAssembler, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
9
9
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
@@ -276,22 +276,29 @@ const ACRYL_RUNTIME_ROWS = [{
|
|
|
276
276
|
id: "system-prompt",
|
|
277
277
|
name: "@deepseek-ai/dsh-system-prompt",
|
|
278
278
|
config: { persona: "You are a coding agent powered by the {{model}} model. Your working directory is {{cwd}}." }
|
|
279
|
-
}, { insert: [
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
279
|
+
}, { insert: [
|
|
280
|
+
{
|
|
281
|
+
id: "agent-presets",
|
|
282
|
+
name: "@deepseek-ai/dsh-agent-presets",
|
|
283
|
+
config: {
|
|
284
|
+
default: "standard",
|
|
285
|
+
roots: existsSync(shippedPresetsDir) ? [{
|
|
286
|
+
path: shippedPresetsDir,
|
|
287
|
+
trust: "system"
|
|
288
|
+
}] : [],
|
|
289
|
+
includeShippedRoot: false,
|
|
290
|
+
includeUserRoot: true
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
id: "session-stats",
|
|
295
|
+
name: "@deepseek-ai/dsh-session-stats"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: "authorization",
|
|
299
|
+
name: "@deepseek-ai/dsh-authorization"
|
|
290
300
|
}
|
|
291
|
-
}
|
|
292
|
-
id: "session-stats",
|
|
293
|
-
name: "@deepseek-ai/dsh-session-stats"
|
|
294
|
-
}] }];
|
|
301
|
+
] }];
|
|
295
302
|
/** Boot one normal pinned-Harness ACRYL profile in a single Cordis root. */
|
|
296
303
|
async function bootAcrylHarnessProfile(options) {
|
|
297
304
|
if (options.profile.trim() === "") throw new Error("ACRYL Harness profile must not be empty");
|
|
@@ -439,7 +446,7 @@ const ESC = "\x1B[";
|
|
|
439
446
|
const dim$2 = fg(theme.muted);
|
|
440
447
|
const cyan$1 = fg(theme.secondary);
|
|
441
448
|
const primary = fg(theme.primary);
|
|
442
|
-
const bold$
|
|
449
|
+
const bold$11 = (s) => `${ESC}1m${s}${ESC}0m`;
|
|
443
450
|
const italic = (s) => `${ESC}3m${s}${ESC}0m`;
|
|
444
451
|
const strike = (s) => `${ESC}9m${s}${ESC}0m`;
|
|
445
452
|
const underline = (s) => `${ESC}4m${s}${ESC}0m`;
|
|
@@ -483,7 +490,7 @@ function looksLikeMarkdown(text) {
|
|
|
483
490
|
/** Style links, bold, strikethrough, and emphasis in a span already known to contain no inline code. */
|
|
484
491
|
function applyNonCodeInline(text) {
|
|
485
492
|
let working = text.replaceAll(LINK_RE_G, (_match, label, url) => hyperlink(url, underline(primary(label))));
|
|
486
|
-
working = working.replaceAll(BOLD_RE_G, (_match, a, b) => bold$
|
|
493
|
+
working = working.replaceAll(BOLD_RE_G, (_match, a, b) => bold$11(a ?? b ?? ""));
|
|
487
494
|
working = working.replaceAll(STRIKE_RE_G, (_match, t) => strike(t));
|
|
488
495
|
return working.replaceAll(ITALIC_RE_G, (_match, a, b) => italic(a ?? b ?? ""));
|
|
489
496
|
}
|
|
@@ -549,7 +556,7 @@ function padCell(styled, width, align) {
|
|
|
549
556
|
}
|
|
550
557
|
/** Pad one row of already-styled cells (header or body) to a single column-aligned line. */
|
|
551
558
|
function formatTableRow(styledCells, widths, aligns, isHeader) {
|
|
552
|
-
return widths.map((width, i) => padCell(isHeader ? bold$
|
|
559
|
+
return widths.map((width, i) => padCell(isHeader ? bold$11(styledCells[i] ?? "") : styledCells[i] ?? "", width, aligns[i] ?? "left")).join(dim$2(" │ "));
|
|
553
560
|
}
|
|
554
561
|
/** A dim horizontal rule under the header row, with a cross at each column boundary. */
|
|
555
562
|
function formatTableRule(widths) {
|
|
@@ -606,7 +613,7 @@ function renderMarkdown(text) {
|
|
|
606
613
|
if (header !== null) {
|
|
607
614
|
const level = header[1].length;
|
|
608
615
|
const content = applyInline(header[2]);
|
|
609
|
-
out.push(level === 1 ? bold$
|
|
616
|
+
out.push(level === 1 ? bold$11(primary(content)) : level === 2 ? bold$11(cyan$1(content)) : bold$11(content));
|
|
610
617
|
continue;
|
|
611
618
|
}
|
|
612
619
|
if (HR_RE.test(line)) {
|
|
@@ -1231,6 +1238,31 @@ var TuiStore = class {
|
|
|
1231
1238
|
}
|
|
1232
1239
|
} });
|
|
1233
1240
|
}
|
|
1241
|
+
/** Open the `/login` sign-in overlay to a fresh, loading flow list. */
|
|
1242
|
+
openLogin() {
|
|
1243
|
+
this.set({ overlay: {
|
|
1244
|
+
kind: "login",
|
|
1245
|
+
login: {
|
|
1246
|
+
flows: void 0,
|
|
1247
|
+
selected: 0,
|
|
1248
|
+
signingIn: void 0,
|
|
1249
|
+
prompt: void 0,
|
|
1250
|
+
busy: true,
|
|
1251
|
+
error: void 0
|
|
1252
|
+
}
|
|
1253
|
+
} });
|
|
1254
|
+
}
|
|
1255
|
+
/** Patch the open `/login` overlay's sub-state; a no-op once it's closed. */
|
|
1256
|
+
updateLogin(patch) {
|
|
1257
|
+
if (this.state.overlay.kind !== "login") return;
|
|
1258
|
+
this.set({ overlay: {
|
|
1259
|
+
kind: "login",
|
|
1260
|
+
login: {
|
|
1261
|
+
...this.state.overlay.login,
|
|
1262
|
+
...patch
|
|
1263
|
+
}
|
|
1264
|
+
} });
|
|
1265
|
+
}
|
|
1234
1266
|
/** Open the `/trajectory` ledger overlay. */
|
|
1235
1267
|
openTrajectory() {
|
|
1236
1268
|
this.set({ overlay: { kind: "trajectory" } });
|
|
@@ -1782,10 +1814,10 @@ function runSlashCommand(command, actions) {
|
|
|
1782
1814
|
}
|
|
1783
1815
|
//#endregion
|
|
1784
1816
|
//#region src/tui/piTheme.ts
|
|
1785
|
-
const bold$
|
|
1817
|
+
const bold$10 = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
1786
1818
|
const selectListTheme = {
|
|
1787
1819
|
selectedPrefix: fg(theme.primary),
|
|
1788
|
-
selectedText: (s) => bold$
|
|
1820
|
+
selectedText: (s) => bold$10(fg(theme.primary)(s)),
|
|
1789
1821
|
description: fg(theme.muted),
|
|
1790
1822
|
scrollInfo: fg(theme.muted),
|
|
1791
1823
|
noMatch: fg(theme.muted)
|
|
@@ -2110,6 +2142,68 @@ var Spinner = class {
|
|
|
2110
2142
|
}
|
|
2111
2143
|
};
|
|
2112
2144
|
//#endregion
|
|
2145
|
+
//#region src/tui/clipboard.ts
|
|
2146
|
+
/**
|
|
2147
|
+
* System-clipboard read, used for right-click paste. Node has no built-in
|
|
2148
|
+
* clipboard API, so this shells out to the platform's clipboard tool via
|
|
2149
|
+
* `execFile` (the same `node:child_process` approach used elsewhere for
|
|
2150
|
+
* platform launchers like `open`/`xdg-open`).
|
|
2151
|
+
* @module @tomowang/dsh-tui/tui/clipboard
|
|
2152
|
+
*/
|
|
2153
|
+
function clipboardCommands() {
|
|
2154
|
+
switch (process.platform) {
|
|
2155
|
+
case "darwin": return [["pbpaste", []]];
|
|
2156
|
+
case "win32": return [["powershell.exe", [
|
|
2157
|
+
"-NoProfile",
|
|
2158
|
+
"-NonInteractive",
|
|
2159
|
+
"-Command",
|
|
2160
|
+
"Get-Clipboard"
|
|
2161
|
+
]]];
|
|
2162
|
+
default: return [
|
|
2163
|
+
["xclip", [
|
|
2164
|
+
"-selection",
|
|
2165
|
+
"clipboard",
|
|
2166
|
+
"-o"
|
|
2167
|
+
]],
|
|
2168
|
+
["xsel", ["--clipboard", "--output"]],
|
|
2169
|
+
["wl-paste", ["--no-newline"]]
|
|
2170
|
+
];
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
/**
|
|
2174
|
+
* Read the system clipboard. Resolves with the clipboard text (possibly empty).
|
|
2175
|
+
* Rejects when no supported clipboard tool is available on this host.
|
|
2176
|
+
*
|
|
2177
|
+
* A single trailing newline is stripped: `pbpaste` prints the clipboard verbatim,
|
|
2178
|
+
* while `xclip`/`xsel`/`Get-Clipboard` append one, so this keeps the result
|
|
2179
|
+
* consistent with a native terminal paste (which inserts exactly what was copied).
|
|
2180
|
+
*/
|
|
2181
|
+
function readClipboard() {
|
|
2182
|
+
return new Promise((resolve, reject) => {
|
|
2183
|
+
const commands = clipboardCommands();
|
|
2184
|
+
let index = 0;
|
|
2185
|
+
const attempt = () => {
|
|
2186
|
+
if (index >= commands.length) {
|
|
2187
|
+
reject(/* @__PURE__ */ new Error("no clipboard tool available"));
|
|
2188
|
+
return;
|
|
2189
|
+
}
|
|
2190
|
+
const [command, args] = commands[index];
|
|
2191
|
+
index += 1;
|
|
2192
|
+
execFile(command, args, {
|
|
2193
|
+
encoding: "utf8",
|
|
2194
|
+
maxBuffer: 10 * 1024 * 1024
|
|
2195
|
+
}, (error, stdout) => {
|
|
2196
|
+
if (error) {
|
|
2197
|
+
attempt();
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
resolve(stdout.replace(/\r?\n$/, ""));
|
|
2201
|
+
});
|
|
2202
|
+
};
|
|
2203
|
+
attempt();
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
//#endregion
|
|
2113
2207
|
//#region src/yly/yly-frames.generated.ts
|
|
2114
2208
|
const YLY_FRAMES = {
|
|
2115
2209
|
"small": [
|
|
@@ -3029,6 +3123,15 @@ var YlyPet = class {
|
|
|
3029
3123
|
* delegate keystrokes to a field nested inside a larger custom overlay.
|
|
3030
3124
|
* @module @tomowang/dsh-tui/tui/miniTextField
|
|
3031
3125
|
*/
|
|
3126
|
+
const BRACKETED_PASTE_START = "\x1B[200~";
|
|
3127
|
+
const BRACKETED_PASTE_END = "\x1B[201~";
|
|
3128
|
+
/** Extract the content of one bracketed-paste sequence, or `undefined` if `data` is not one. */
|
|
3129
|
+
function extractBracketedPaste(data) {
|
|
3130
|
+
if (!data.startsWith(BRACKETED_PASTE_START)) return void 0;
|
|
3131
|
+
const end = data.indexOf(BRACKETED_PASTE_END);
|
|
3132
|
+
if (end === -1) return void 0;
|
|
3133
|
+
return data.slice(6, end);
|
|
3134
|
+
}
|
|
3032
3135
|
function emptyMiniTextField(value = "") {
|
|
3033
3136
|
return {
|
|
3034
3137
|
value,
|
|
@@ -3067,6 +3170,15 @@ function miniTextFieldInput(state, data) {
|
|
|
3067
3170
|
cursor: state.cursor
|
|
3068
3171
|
};
|
|
3069
3172
|
}
|
|
3173
|
+
const paste = extractBracketedPaste(data);
|
|
3174
|
+
if (paste !== void 0) {
|
|
3175
|
+
const text = paste.replace(/[\r\n]+/g, "");
|
|
3176
|
+
if (text.length === 0) return state;
|
|
3177
|
+
return {
|
|
3178
|
+
value: state.value.slice(0, state.cursor) + text + state.value.slice(state.cursor),
|
|
3179
|
+
cursor: state.cursor + text.length
|
|
3180
|
+
};
|
|
3181
|
+
}
|
|
3070
3182
|
if (data.length > 0 && !data.startsWith("\x1B") && data !== "\r" && data !== "\n" && data !== " ") return {
|
|
3071
3183
|
value: state.value.slice(0, state.cursor) + data + state.value.slice(state.cursor),
|
|
3072
3184
|
cursor: state.cursor + data.length
|
|
@@ -3080,11 +3192,11 @@ function renderMiniTextField(state, cursorVisible, mask) {
|
|
|
3080
3192
|
}
|
|
3081
3193
|
//#endregion
|
|
3082
3194
|
//#region src/tui/modelProfile/ModelProfileOverlay.ts
|
|
3083
|
-
const bold$
|
|
3084
|
-
const secondary$
|
|
3085
|
-
const muted$
|
|
3086
|
-
const errorColor$
|
|
3087
|
-
const invert$
|
|
3195
|
+
const bold$9 = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
3196
|
+
const secondary$9 = fg(theme.secondary);
|
|
3197
|
+
const muted$10 = fg(theme.muted);
|
|
3198
|
+
const errorColor$5 = fg(theme.error);
|
|
3199
|
+
const invert$5 = (s) => `\x1b[7m${s}\x1b[0m`;
|
|
3088
3200
|
var ModelProfileOverlay = class {
|
|
3089
3201
|
store;
|
|
3090
3202
|
actions;
|
|
@@ -3161,19 +3273,19 @@ var ModelProfileOverlay = class {
|
|
|
3161
3273
|
}
|
|
3162
3274
|
renderList(mp) {
|
|
3163
3275
|
const { providers, selected, busy, error } = mp;
|
|
3164
|
-
const lines = [bold$
|
|
3165
|
-
if (error !== void 0) lines.push(errorColor$
|
|
3166
|
-
if (busy && providers === void 0) lines.push(muted$
|
|
3276
|
+
const lines = [bold$9(secondary$9("Model providers"))];
|
|
3277
|
+
if (error !== void 0) lines.push(errorColor$5(error));
|
|
3278
|
+
if (busy && providers === void 0) lines.push(muted$10("Loading…"));
|
|
3167
3279
|
providers?.forEach((row, index) => {
|
|
3168
3280
|
const marker = row.configured ? "● " : "○ ";
|
|
3169
3281
|
const active = row.live ? " (active)" : "";
|
|
3170
3282
|
const noKey = row.apiKeyConfigured ? "" : " [no api key]";
|
|
3171
3283
|
const confirm = this.confirmDelete === index ? " — press d again to delete" : "";
|
|
3172
3284
|
const text = `${index === selected ? "› " : " "}${marker}${row.displayName}${active}${noKey}${confirm}`;
|
|
3173
|
-
lines.push(index === selected ? invert$
|
|
3285
|
+
lines.push(index === selected ? invert$5(text) : text);
|
|
3174
3286
|
});
|
|
3175
|
-
if (providers?.length === 0) lines.push(muted$
|
|
3176
|
-
lines.push(muted$
|
|
3287
|
+
if (providers?.length === 0) lines.push(muted$10("No providers configured yet — press a to add one."));
|
|
3288
|
+
lines.push(muted$10("↑↓ select · enter edit · a add · d delete · s set active model · esc close"));
|
|
3177
3289
|
return lines;
|
|
3178
3290
|
}
|
|
3179
3291
|
handleListInput(data, mp) {
|
|
@@ -3237,8 +3349,8 @@ var ModelProfileOverlay = class {
|
|
|
3237
3349
|
baseURL: "Base URL",
|
|
3238
3350
|
apiKey: draft.apiKeyConfigured ? "API key (set — leave blank to keep)" : "API key"
|
|
3239
3351
|
};
|
|
3240
|
-
const lines = [bold$
|
|
3241
|
-
if (mp.error !== void 0) lines.push(errorColor$
|
|
3352
|
+
const lines = [bold$9(secondary$9(draft.isNew ? "Add provider" : `Edit ${draft.displayName || draft.route}`))];
|
|
3353
|
+
if (mp.error !== void 0) lines.push(errorColor$5(mp.error));
|
|
3242
3354
|
textFields.forEach((field, index) => {
|
|
3243
3355
|
const isFocused = this.focused === index;
|
|
3244
3356
|
const mask = field === "apiKey" ? "*" : void 0;
|
|
@@ -3246,10 +3358,10 @@ var ModelProfileOverlay = class {
|
|
|
3246
3358
|
lines.push(`${prefix}${renderMiniTextField(fieldState[field], isFocused, mask)}`);
|
|
3247
3359
|
});
|
|
3248
3360
|
const modelsText = `${this.focused === modelsRow ? "› " : " "}Models (${this.models.length}) — enter to edit`;
|
|
3249
|
-
lines.push(this.focused === modelsRow ? invert$
|
|
3361
|
+
lines.push(this.focused === modelsRow ? invert$5(modelsText) : modelsText);
|
|
3250
3362
|
const saveText = `${this.focused === saveRow ? "› " : " "}${mp.busy ? "Saving…" : "Save"}`;
|
|
3251
|
-
lines.push(this.focused === saveRow ? invert$
|
|
3252
|
-
lines.push(muted$
|
|
3363
|
+
lines.push(this.focused === saveRow ? invert$5(saveText) : saveText);
|
|
3364
|
+
lines.push(muted$10("tab/shift+tab move · enter confirm field / activate row · esc cancel"));
|
|
3253
3365
|
return lines;
|
|
3254
3366
|
}
|
|
3255
3367
|
handleFormInput(data, draft) {
|
|
@@ -3299,21 +3411,21 @@ var ModelProfileOverlay = class {
|
|
|
3299
3411
|
}
|
|
3300
3412
|
}
|
|
3301
3413
|
renderModelListEditor(mp) {
|
|
3302
|
-
const lines = [bold$
|
|
3414
|
+
const lines = [bold$9(secondary$9("Models"))];
|
|
3303
3415
|
this.models.forEach((model, index) => {
|
|
3304
3416
|
const isSelected = !this.modelInputFocused && index === this.modelSelected;
|
|
3305
3417
|
const text = `${isSelected ? "› " : " "}${model.id}${model.name === void 0 ? "" : ` — ${model.name}`}`;
|
|
3306
|
-
lines.push(isSelected ? invert$
|
|
3418
|
+
lines.push(isSelected ? invert$5(text) : text);
|
|
3307
3419
|
});
|
|
3308
|
-
if (this.models.length === 0) lines.push(muted$
|
|
3420
|
+
if (this.models.length === 0) lines.push(muted$10("No models yet."));
|
|
3309
3421
|
lines.push(`${this.modelInputFocused ? "› " : " "}Add id: ${renderMiniTextField(this.modelDraftId, this.modelInputFocused)}`);
|
|
3310
|
-
if (mp.busy) lines.push(muted$
|
|
3311
|
-
if (mp.discovered !== void 0) if (mp.discovered.length === 0) lines.push(muted$
|
|
3422
|
+
if (mp.busy) lines.push(muted$10("Discovering…"));
|
|
3423
|
+
if (mp.discovered !== void 0) if (mp.discovered.length === 0) lines.push(muted$10("No models discovered."));
|
|
3312
3424
|
else {
|
|
3313
|
-
lines.push(muted$
|
|
3314
|
-
for (const model of mp.discovered) lines.push(muted$
|
|
3425
|
+
lines.push(muted$10("Discovered — tab to the id field and type one to adopt it:"));
|
|
3426
|
+
for (const model of mp.discovered) lines.push(muted$10(` ${model.id}${model.name === void 0 ? "" : ` — ${model.name}`}`));
|
|
3315
3427
|
}
|
|
3316
|
-
lines.push(muted$
|
|
3428
|
+
lines.push(muted$10("tab toggle list/input · ↑↓ select · x remove · g discover · esc back"));
|
|
3317
3429
|
return lines;
|
|
3318
3430
|
}
|
|
3319
3431
|
addModel(id) {
|
|
@@ -3374,6 +3486,111 @@ var ModelProfileOverlay = class {
|
|
|
3374
3486
|
}
|
|
3375
3487
|
};
|
|
3376
3488
|
//#endregion
|
|
3489
|
+
//#region src/tui/login/LoginOverlay.ts
|
|
3490
|
+
const bold$8 = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
3491
|
+
const secondary$8 = fg(theme.secondary);
|
|
3492
|
+
const muted$9 = fg(theme.muted);
|
|
3493
|
+
const errorColor$4 = fg(theme.error);
|
|
3494
|
+
const invert$4 = (s) => `\x1b[7m${s}\x1b[0m`;
|
|
3495
|
+
var LoginOverlay = class {
|
|
3496
|
+
store;
|
|
3497
|
+
actions;
|
|
3498
|
+
promptField = emptyMiniTextField();
|
|
3499
|
+
promptCursor = 0;
|
|
3500
|
+
constructor(store, actions) {
|
|
3501
|
+
this.store = store;
|
|
3502
|
+
this.actions = actions;
|
|
3503
|
+
}
|
|
3504
|
+
invalidate() {}
|
|
3505
|
+
renderList(login) {
|
|
3506
|
+
const lines = [bold$8(secondary$8("Sign in"))];
|
|
3507
|
+
if (login.error !== void 0) lines.push(errorColor$4(login.error));
|
|
3508
|
+
if (login.busy && login.flows === void 0) lines.push(muted$9("Loading…"));
|
|
3509
|
+
login.flows?.forEach((flow, index) => {
|
|
3510
|
+
const marker = flow.inFlight ? "· " : "○ ";
|
|
3511
|
+
const signingIn = login.signingIn === flow.key ? " — signing in…" : "";
|
|
3512
|
+
const text = `${index === login.selected ? "› " : " "}${marker}${flow.label}${signingIn}`;
|
|
3513
|
+
lines.push(index === login.selected ? invert$4(text) : text);
|
|
3514
|
+
});
|
|
3515
|
+
if (login.flows?.length === 0) lines.push(muted$9("No sign-in providers are available in this profile."));
|
|
3516
|
+
lines.push(muted$9("↑↓ select · enter sign in · esc close"));
|
|
3517
|
+
return lines;
|
|
3518
|
+
}
|
|
3519
|
+
renderPrompt(prompt) {
|
|
3520
|
+
const lines = [bold$8(secondary$8("Sign in"))];
|
|
3521
|
+
lines.push(prompt.message);
|
|
3522
|
+
if (prompt.kind === "select") {
|
|
3523
|
+
prompt.options.forEach((option, index) => {
|
|
3524
|
+
const row = `${index === this.promptCursor ? "› " : " "}${option.label}`;
|
|
3525
|
+
lines.push(index === this.promptCursor ? invert$4(row) : row);
|
|
3526
|
+
if (option.description !== void 0) lines.push(muted$9(` ${option.description}`));
|
|
3527
|
+
});
|
|
3528
|
+
lines.push(muted$9("↑↓ choose · enter select · esc cancel"));
|
|
3529
|
+
} else {
|
|
3530
|
+
const mask = prompt.kind === "secret" ? "•" : void 0;
|
|
3531
|
+
const placeholder = prompt.placeholder ?? (prompt.kind === "secret" ? "API key" : "code");
|
|
3532
|
+
const field = this.promptField.value === "" ? `(${placeholder})` : renderMiniTextField(this.promptField, true, mask);
|
|
3533
|
+
lines.push(`> ${field}`);
|
|
3534
|
+
lines.push(muted$9("type + enter submit · esc cancel"));
|
|
3535
|
+
}
|
|
3536
|
+
return lines;
|
|
3537
|
+
}
|
|
3538
|
+
render(_width) {
|
|
3539
|
+
const overlay = this.store.getSnapshot().overlay;
|
|
3540
|
+
if (overlay.kind !== "login") return [];
|
|
3541
|
+
const { prompt } = overlay.login;
|
|
3542
|
+
return prompt === void 0 ? this.renderList(overlay.login) : this.renderPrompt(prompt);
|
|
3543
|
+
}
|
|
3544
|
+
handleInput(data) {
|
|
3545
|
+
const overlay = this.store.getSnapshot().overlay;
|
|
3546
|
+
if (overlay.kind !== "login") return;
|
|
3547
|
+
const { prompt } = overlay.login;
|
|
3548
|
+
if (prompt !== void 0) this.handlePromptInput(data, prompt);
|
|
3549
|
+
else this.handleListInput(data, overlay.login);
|
|
3550
|
+
}
|
|
3551
|
+
handlePromptInput(data, prompt) {
|
|
3552
|
+
if (matchesKey(data, Key.escape)) {
|
|
3553
|
+
this.actions.answerAuthorizationPrompt("");
|
|
3554
|
+
return;
|
|
3555
|
+
}
|
|
3556
|
+
if (prompt.kind === "select") {
|
|
3557
|
+
if (matchesKey(data, Key.up)) {
|
|
3558
|
+
this.promptCursor = Math.max(0, this.promptCursor - 1);
|
|
3559
|
+
return;
|
|
3560
|
+
}
|
|
3561
|
+
if (matchesKey(data, Key.down)) {
|
|
3562
|
+
this.promptCursor = Math.min(prompt.options.length - 1, this.promptCursor + 1);
|
|
3563
|
+
return;
|
|
3564
|
+
}
|
|
3565
|
+
if (matchesKey(data, Key.enter)) this.actions.answerAuthorizationPrompt(prompt.options[this.promptCursor].id);
|
|
3566
|
+
return;
|
|
3567
|
+
}
|
|
3568
|
+
if (matchesKey(data, Key.enter)) {
|
|
3569
|
+
this.actions.answerAuthorizationPrompt(this.promptField.value.trim());
|
|
3570
|
+
return;
|
|
3571
|
+
}
|
|
3572
|
+
const next = miniTextFieldInput(this.promptField, data);
|
|
3573
|
+
if (next !== void 0) this.promptField = next;
|
|
3574
|
+
}
|
|
3575
|
+
handleListInput(data, login) {
|
|
3576
|
+
if (matchesKey(data, Key.escape)) {
|
|
3577
|
+
this.actions.closeLogin();
|
|
3578
|
+
return;
|
|
3579
|
+
}
|
|
3580
|
+
const flows = login.flows;
|
|
3581
|
+
if (flows === void 0 || flows.length === 0) return;
|
|
3582
|
+
if (matchesKey(data, Key.up)) {
|
|
3583
|
+
this.actions.selectLoginFlow(Math.max(0, login.selected - 1));
|
|
3584
|
+
return;
|
|
3585
|
+
}
|
|
3586
|
+
if (matchesKey(data, Key.down)) {
|
|
3587
|
+
this.actions.selectLoginFlow(Math.min(flows.length - 1, login.selected + 1));
|
|
3588
|
+
return;
|
|
3589
|
+
}
|
|
3590
|
+
if (matchesKey(data, Key.enter)) this.actions.beginAuthorization(flows[login.selected].key);
|
|
3591
|
+
}
|
|
3592
|
+
};
|
|
3593
|
+
//#endregion
|
|
3377
3594
|
//#region src/tui/trajectory/layout.ts
|
|
3378
3595
|
const LABEL_LIMIT = 100;
|
|
3379
3596
|
function prettyJson(raw) {
|
|
@@ -4613,7 +4830,12 @@ var TuiApp = class {
|
|
|
4613
4830
|
this.options = options;
|
|
4614
4831
|
const { store, actions } = options;
|
|
4615
4832
|
const terminal = new ProcessTerminal();
|
|
4616
|
-
this.tui = new TuiAltScreen(terminal, true, void 0, {
|
|
4833
|
+
this.tui = new TuiAltScreen(terminal, true, void 0, {
|
|
4834
|
+
mouse: true,
|
|
4835
|
+
onRightClickPaste: () => {
|
|
4836
|
+
readClipboard().then((text) => this.tui.getFocusedComponent()?.handleInput?.(`\x1b[200~${text}\x1b[201~`)).catch(() => {});
|
|
4837
|
+
}
|
|
4838
|
+
});
|
|
4617
4839
|
this.spinner = new Spinner(this.tui);
|
|
4618
4840
|
this.pet = new YlyPet(this.tui);
|
|
4619
4841
|
const transcriptScrollView = new ScrollView(this.documentContainer, {
|
|
@@ -4801,6 +5023,7 @@ var TuiApp = class {
|
|
|
4801
5023
|
switch (overlay.kind) {
|
|
4802
5024
|
case "none": return;
|
|
4803
5025
|
case "modelProfile": return new ModelProfileOverlay(store, actions);
|
|
5026
|
+
case "login": return new LoginOverlay(store, actions);
|
|
4804
5027
|
case "trajectory": return new TrajectoryOverlay(this.tui, store, actions, getTool);
|
|
4805
5028
|
case "toolCards": return new ToolCardsOverlay(this.tui, store, actions, getTool, getToolCall);
|
|
4806
5029
|
case "context": return new ContextOverlay(store, actions);
|
|
@@ -4991,6 +5214,19 @@ function deriveApiKeyRef(route) {
|
|
|
4991
5214
|
const upper = route.toUpperCase().replace(/[^A-Z0-9]+/g, "_");
|
|
4992
5215
|
return `${/^[A-Z_]/.test(upper) ? upper : `P_${upper}`}_API_KEY`;
|
|
4993
5216
|
}
|
|
5217
|
+
/** Open a URL in the platform's default browser (fire-and-forget). */
|
|
5218
|
+
function openBrowser(url) {
|
|
5219
|
+
const platform = process.platform;
|
|
5220
|
+
const command = platform === "darwin" ? ["open", [url]] : platform === "win32" ? ["cmd", [
|
|
5221
|
+
"/c",
|
|
5222
|
+
"start",
|
|
5223
|
+
"",
|
|
5224
|
+
url
|
|
5225
|
+
]] : ["xdg-open", [url]];
|
|
5226
|
+
return new Promise((resolve) => {
|
|
5227
|
+
execFile(command[0], command[1], () => resolve());
|
|
5228
|
+
});
|
|
5229
|
+
}
|
|
4994
5230
|
/** Nest a provider settings section at its path, e.g. `['providers','deepseek']` -> `{ providers: { deepseek: section } }`. */
|
|
4995
5231
|
function nestAtPath(path, section) {
|
|
4996
5232
|
let patch = section;
|
|
@@ -5086,6 +5322,30 @@ async function attachSession(host, resumeId) {
|
|
|
5086
5322
|
selected: 0
|
|
5087
5323
|
});
|
|
5088
5324
|
}
|
|
5325
|
+
async function loadAuthorizationFlows() {
|
|
5326
|
+
const authSvc = host.ctx.get("authorization");
|
|
5327
|
+
if (authSvc === void 0) {
|
|
5328
|
+
store.updateLogin({
|
|
5329
|
+
flows: [],
|
|
5330
|
+
busy: false,
|
|
5331
|
+
error: "Sign-in is not available in this profile."
|
|
5332
|
+
});
|
|
5333
|
+
return;
|
|
5334
|
+
}
|
|
5335
|
+
try {
|
|
5336
|
+
const list = authSvc.list();
|
|
5337
|
+
store.updateLogin({
|
|
5338
|
+
flows: list,
|
|
5339
|
+
busy: false,
|
|
5340
|
+
error: void 0
|
|
5341
|
+
});
|
|
5342
|
+
} catch (error) {
|
|
5343
|
+
store.updateLogin({
|
|
5344
|
+
busy: false,
|
|
5345
|
+
error: error instanceof Error ? error.message : String(error)
|
|
5346
|
+
});
|
|
5347
|
+
}
|
|
5348
|
+
}
|
|
5089
5349
|
async function loadAgentPresets() {
|
|
5090
5350
|
const presetsSvc = host.ctx.get("agentPresets");
|
|
5091
5351
|
if (presetsSvc === void 0) {
|
|
@@ -5116,6 +5376,7 @@ async function attachSession(host, resumeId) {
|
|
|
5116
5376
|
});
|
|
5117
5377
|
}
|
|
5118
5378
|
}
|
|
5379
|
+
let pendingPromptResolve;
|
|
5119
5380
|
const actions = {
|
|
5120
5381
|
send(text) {
|
|
5121
5382
|
store.setNotice(void 0);
|
|
@@ -5234,8 +5495,83 @@ async function attachSession(host, resumeId) {
|
|
|
5234
5495
|
loadProviders();
|
|
5235
5496
|
},
|
|
5236
5497
|
login() {
|
|
5237
|
-
store.
|
|
5238
|
-
|
|
5498
|
+
store.openLogin();
|
|
5499
|
+
loadAuthorizationFlows();
|
|
5500
|
+
},
|
|
5501
|
+
closeLogin() {
|
|
5502
|
+
store.closeOverlay();
|
|
5503
|
+
},
|
|
5504
|
+
selectLoginFlow(index) {
|
|
5505
|
+
store.updateLogin({ selected: index });
|
|
5506
|
+
},
|
|
5507
|
+
beginAuthorization(key) {
|
|
5508
|
+
(async () => {
|
|
5509
|
+
const authSvc = host.ctx.get("authorization");
|
|
5510
|
+
if (authSvc === void 0) {
|
|
5511
|
+
store.setNotice("Sign-in is not available in this profile.");
|
|
5512
|
+
return;
|
|
5513
|
+
}
|
|
5514
|
+
const overlay = store.getSnapshot().overlay;
|
|
5515
|
+
const flow = overlay.kind === "login" ? overlay.login.flows?.find((entry) => entry.key === key) : void 0;
|
|
5516
|
+
if (flow === void 0) return;
|
|
5517
|
+
store.updateLogin({ signingIn: key });
|
|
5518
|
+
const interaction = {
|
|
5519
|
+
notify(notice) {
|
|
5520
|
+
if (notice.url !== void 0) openBrowser(notice.url);
|
|
5521
|
+
const parts = [notice.message];
|
|
5522
|
+
if (notice.url !== void 0) parts.push(notice.url);
|
|
5523
|
+
if (notice.code !== void 0) parts.push(`Code: ${notice.code}`);
|
|
5524
|
+
store.setNotice(parts.join("\n"));
|
|
5525
|
+
},
|
|
5526
|
+
async prompt(prompt) {
|
|
5527
|
+
return await new Promise((resolve, reject) => {
|
|
5528
|
+
if (prompt.signal?.aborted) {
|
|
5529
|
+
reject(/* @__PURE__ */ new Error("authorization prompt withdrawn"));
|
|
5530
|
+
return;
|
|
5531
|
+
}
|
|
5532
|
+
pendingPromptResolve = resolve;
|
|
5533
|
+
const state = prompt.kind === "select" ? {
|
|
5534
|
+
kind: "select",
|
|
5535
|
+
message: prompt.message,
|
|
5536
|
+
options: (prompt.options ?? []).map((option) => ({
|
|
5537
|
+
id: option.id,
|
|
5538
|
+
label: option.label,
|
|
5539
|
+
description: option.description
|
|
5540
|
+
}))
|
|
5541
|
+
} : {
|
|
5542
|
+
kind: prompt.kind,
|
|
5543
|
+
message: prompt.message,
|
|
5544
|
+
placeholder: prompt.placeholder
|
|
5545
|
+
};
|
|
5546
|
+
store.updateLogin({ prompt: state });
|
|
5547
|
+
prompt.signal?.addEventListener("abort", () => {
|
|
5548
|
+
if (pendingPromptResolve === resolve) pendingPromptResolve = void 0;
|
|
5549
|
+
store.updateLogin({ prompt: void 0 });
|
|
5550
|
+
reject(/* @__PURE__ */ new Error("authorization prompt withdrawn"));
|
|
5551
|
+
}, { once: true });
|
|
5552
|
+
});
|
|
5553
|
+
}
|
|
5554
|
+
};
|
|
5555
|
+
try {
|
|
5556
|
+
if ((await authSvc.begin({
|
|
5557
|
+
key,
|
|
5558
|
+
interaction
|
|
5559
|
+
})).status === "authorized") {
|
|
5560
|
+
store.setNotice(`Signed in to ${flow.label}.`);
|
|
5561
|
+
loadAuthorizationFlows();
|
|
5562
|
+
} else store.setNotice("Sign-in cancelled.");
|
|
5563
|
+
} catch (error) {
|
|
5564
|
+
store.setNotice(`Sign-in failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
5565
|
+
} finally {
|
|
5566
|
+
store.updateLogin({ signingIn: void 0 });
|
|
5567
|
+
}
|
|
5568
|
+
})();
|
|
5569
|
+
},
|
|
5570
|
+
answerAuthorizationPrompt(value) {
|
|
5571
|
+
const resolve = pendingPromptResolve;
|
|
5572
|
+
pendingPromptResolve = void 0;
|
|
5573
|
+
store.updateLogin({ prompt: void 0 });
|
|
5574
|
+
if (resolve !== void 0) resolve(value);
|
|
5239
5575
|
},
|
|
5240
5576
|
logout() {
|
|
5241
5577
|
(async () => {
|