@visual-z/xeno 0.1.4 → 0.2.1
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/CHANGELOG.md +25 -0
- package/README.md +143 -33
- package/docs/install.md +23 -6
- package/docs/providers.md +147 -0
- package/package.json +8 -2
- package/src/apps/cli.ts +45 -18
- package/src/apps/commands.ts +32 -4
- package/src/apps/completions.ts +9 -6
- package/src/apps/export-cli.ts +24 -0
- package/src/apps/extension-ui.ts +330 -0
- package/src/apps/input.ts +16 -1
- package/src/apps/model-catalog.ts +42 -0
- package/src/apps/project-trust.ts +49 -0
- package/src/apps/render.ts +1 -0
- package/src/apps/resource-browser.ts +75 -0
- package/src/apps/resources.ts +25 -0
- package/src/apps/session-browser.ts +113 -0
- package/src/apps/session-picker.ts +55 -0
- package/src/apps/shell.ts +1177 -378
- package/src/apps/startup-input.ts +94 -0
- package/src/apps/startup.ts +413 -295
- package/src/core/action-defaults.ts +306 -0
- package/src/core/attachment-input.ts +17 -0
- package/src/core/catalog-merge.ts +19 -0
- package/src/core/event-validation.ts +19 -2
- package/src/core/events.ts +45 -2
- package/src/core/export.ts +6 -2
- package/src/core/extension-flags.ts +14 -0
- package/src/core/images.ts +46 -0
- package/src/core/json-event.ts +2 -0
- package/src/core/keymap.ts +43 -119
- package/src/core/model-replay.ts +22 -0
- package/src/core/model-scope.ts +53 -0
- package/src/core/packages.ts +47 -0
- package/src/core/project.ts +21 -3
- package/src/core/prompts.ts +33 -5
- package/src/core/queue.ts +18 -0
- package/src/core/resource-selection.ts +36 -0
- package/src/{runtime → core}/resume.ts +15 -22
- package/src/core/session-archive.ts +4 -0
- package/src/core/session-browser.ts +82 -0
- package/src/core/session-entry.ts +56 -0
- package/src/core/session-position.ts +26 -0
- package/src/core/settings.ts +169 -154
- package/src/core/theme.ts +15 -6
- package/src/core/thinking.ts +26 -0
- package/src/core/tokens.ts +2 -0
- package/src/core/transcript.ts +15 -5
- package/src/runtime/auth.ts +116 -11
- package/src/runtime/catalog.ts +54 -151
- package/src/runtime/clipboard.ts +114 -0
- package/src/runtime/extension-loader.ts +37 -0
- package/src/runtime/extension-ui.ts +55 -0
- package/src/runtime/extensions.ts +273 -0
- package/src/runtime/images.ts +76 -0
- package/src/runtime/loop.ts +213 -83
- package/src/runtime/model-config.ts +232 -0
- package/src/runtime/model-data.LICENSE +27 -0
- package/src/runtime/model-data.ts +21 -0
- package/src/runtime/model-replay.ts +10 -0
- package/src/runtime/model-scope.ts +20 -0
- package/src/runtime/model-sources.ts +151 -0
- package/src/runtime/model.ts +74 -11
- package/src/runtime/models-fetch.ts +6 -104
- package/src/runtime/oauth.ts +4 -3
- package/src/runtime/openai-responses.ts +12 -4
- package/src/runtime/openai.ts +13 -4
- package/src/runtime/package-manager.ts +125 -0
- package/src/runtime/pi-provider.ts +235 -0
- package/src/runtime/progress.ts +26 -0
- package/src/runtime/provider-access.ts +21 -0
- package/src/runtime/provider-protocols.ts +29 -0
- package/src/runtime/provider-request.ts +73 -0
- package/src/runtime/provider.ts +26 -6
- package/src/runtime/rich-text.ts +36 -0
- package/src/runtime/tools.ts +41 -5
- package/src/store/command.ts +7 -1
- package/src/store/context-files.ts +1 -1
- package/src/store/log.ts +65 -0
- package/src/store/models.ts +28 -9
- package/src/store/observations.ts +4 -2
- package/src/store/packages.ts +98 -0
- package/src/store/recovery.ts +8 -0
- package/src/store/resource-index.ts +170 -0
- package/src/store/resources.ts +75 -142
- package/src/store/session-archive.ts +162 -0
- package/src/store/session-browser.ts +68 -0
- package/src/store/session-position.ts +27 -0
- package/src/store/sessions.ts +87 -66
- package/src/store/trust.ts +13 -0
- package/src/tui/chat-viewport.ts +47 -0
- package/src/tui/editor.ts +62 -15
- package/src/tui/host.ts +50 -9
- package/src/tui/input.ts +8 -2
- package/src/tui/select.ts +24 -6
- package/src/tui/settings.ts +4 -0
- package/src/tui/system-theme.ts +700 -0
- package/src/tui/transcript.ts +63 -11
- package/src/tui/tree.ts +161 -95
- package/src/vendor/pi-rich/LICENSE.upstream +21 -0
- package/src/vendor/pi-rich/UPSTREAM.json +17 -0
- package/src/vendor/pi-rich/clipboard-command.ts +44 -0
- package/src/vendor/pi-rich/exif-orientation.ts +182 -0
- package/src/vendor/pi-rich/html.ts +51 -0
- package/src/vendor/pi-rich/image-convert.ts +49 -0
- package/src/vendor/pi-rich/image-resize-core.ts +164 -0
- package/src/vendor/pi-rich/image-resize-worker.ts +42 -0
- package/src/vendor/pi-rich/image-resize.ts +123 -0
- package/src/vendor/pi-rich/mime.ts +116 -0
- package/src/vendor/pi-rich/photon.ts +139 -0
- package/src/vendor/pi-rich/syntax-highlight.ts +214 -0
- package/src/vendor/pi-tui/UPSTREAM.json +50 -0
- package/src/vendor/pi-tui/VENDOR.md +7 -5
- package/src/vendor/pi-tui/autocomplete.ts +35 -10
- package/src/vendor/pi-tui/colors.ts +367 -0
- package/src/vendor/pi-tui/components/box.ts +8 -9
- package/src/vendor/pi-tui/components/editor.ts +4 -2
- package/src/vendor/pi-tui/components/markdown.ts +8 -2
- package/src/vendor/pi-tui/index.ts +31 -1
- package/src/vendor/pi-tui/native/UPSTREAM.json +23 -0
- package/src/vendor/pi-tui/native/clipboard.h +208 -0
- package/src/vendor/pi-tui/native/darwin/README.md +22 -0
- package/src/vendor/pi-tui/native/darwin/build.sh +69 -0
- package/src/vendor/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
- package/src/vendor/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
- package/src/vendor/pi-tui/native/darwin/src/darwin-platform.m +132 -0
- package/src/vendor/pi-tui/native/linux/README.md +23 -0
- package/src/vendor/pi-tui/native/linux/build.sh +65 -0
- package/src/vendor/pi-tui/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
- package/src/vendor/pi-tui/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
- package/src/vendor/pi-tui/native/linux/src/clipboard-worker.h +70 -0
- package/src/vendor/pi-tui/native/linux/src/linux-platform-x11.c +274 -0
- package/src/vendor/pi-tui/native/napi.h +91 -0
- package/src/vendor/pi-tui/native/win32/README.md +31 -0
- package/src/vendor/pi-tui/native/win32/build.mjs +232 -0
- package/src/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
- package/src/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
- package/src/vendor/pi-tui/native/win32/src/win32-platform.c +241 -0
- package/src/vendor/pi-tui/native-platform.ts +2 -0
- package/src/vendor/pi-tui/oklab.ts +233 -0
- package/src/vendor/pi-tui/terminal-colors.ts +26 -8
- package/src/vendor/pi-tui/terminal-image.ts +43 -8
- package/src/vendor/pi-tui/terminal.ts +16 -9
- package/src/vendor/pi-tui/tui-alt-screen.ts +26 -18
- package/src/vendor/pi-tui/tui.ts +112 -75
- package/src/vendor/pi-tui/utils.ts +89 -49
- package/src/vendor/pi-tui/wheel-scroll.ts +82 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** Startup owns raw input until a Pi screen can own it (D19). */
|
|
2
|
+
import { StdinBuffer } from "../vendor/pi-tui/stdin-buffer.ts";
|
|
3
|
+
import { isKeyRelease, matchesKey } from "../vendor/pi-tui/keys.ts";
|
|
4
|
+
import { resolveEscapeTimeoutMs } from "../vendor/pi-tui/terminal.ts";
|
|
5
|
+
|
|
6
|
+
type StartupStdin = Pick<NodeJS.ReadStream, "isTTY" | "isRaw" | "setRawMode" | "setEncoding" | "on" | "off" | "resume" | "pause" | "unshift">;
|
|
7
|
+
export interface StartupInput {
|
|
8
|
+
phase(name: string): void;
|
|
9
|
+
/** Pause, restore the shell's mode and replay held bytes to the next input owner. */
|
|
10
|
+
handoff(): void;
|
|
11
|
+
/** Final cleanup discards unsubmitted input instead of leaking it to the shell. */
|
|
12
|
+
restore(): void;
|
|
13
|
+
runWithTerminal<T>(run: (handoff: () => void) => Promise<T>): Promise<T>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function createStartupInput(opts: {
|
|
17
|
+
interactive: boolean;
|
|
18
|
+
stdin?: StartupStdin;
|
|
19
|
+
signals?: NodeJS.EventEmitter;
|
|
20
|
+
report?: (message: string) => void;
|
|
21
|
+
exit?: (code: number) => void;
|
|
22
|
+
}): StartupInput {
|
|
23
|
+
const stdin = opts.stdin ?? process.stdin;
|
|
24
|
+
if (!opts.interactive || stdin.isTTY !== true) return {
|
|
25
|
+
phase() {}, handoff() {}, restore() {}, runWithTerminal: run => run(() => {}),
|
|
26
|
+
};
|
|
27
|
+
const signals = opts.signals ?? process;
|
|
28
|
+
const report = opts.report ?? (message => console.error(message));
|
|
29
|
+
const exit = opts.exit ?? (code => process.exit(code));
|
|
30
|
+
const wasRaw = stdin.isRaw === true;
|
|
31
|
+
let active = false, closed = false, announced = false;
|
|
32
|
+
let phase = "Reading configuration";
|
|
33
|
+
let pending: string[] = [];
|
|
34
|
+
let parser: StdinBuffer | undefined;
|
|
35
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
36
|
+
|
|
37
|
+
const release = () => {
|
|
38
|
+
if (!active) return;
|
|
39
|
+
active = false;
|
|
40
|
+
clearTimeout(timer);
|
|
41
|
+
stdin.pause();
|
|
42
|
+
stdin.off("data", receive);
|
|
43
|
+
signals.off("SIGINT", interrupt); signals.off("SIGTERM", terminate); signals.off("SIGHUP", hangup);
|
|
44
|
+
parser?.destroy(); parser = undefined;
|
|
45
|
+
stdin.setRawMode(wasRaw);
|
|
46
|
+
};
|
|
47
|
+
const restore = () => { closed = true; release(); pending = []; };
|
|
48
|
+
const cancel = (code: number) => {
|
|
49
|
+
if (!active) return;
|
|
50
|
+
restore();
|
|
51
|
+
if (code === 130) report("Startup cancelled.");
|
|
52
|
+
exit(code);
|
|
53
|
+
};
|
|
54
|
+
const interrupt = () => cancel(130), terminate = () => cancel(143), hangup = () => cancel(129);
|
|
55
|
+
const receive = (data: string) => {
|
|
56
|
+
// Keep original chunks, including partial escapes/pastes, for Pi's own decoder.
|
|
57
|
+
// The temporary parser only recognizes cancellation outside bracketed paste.
|
|
58
|
+
pending.push(data);
|
|
59
|
+
parser?.process(data);
|
|
60
|
+
};
|
|
61
|
+
const announce = () => { if (active) { announced = true; report(` Starting xeno: ${phase} (Ctrl+C to cancel)`); } };
|
|
62
|
+
const capture = () => {
|
|
63
|
+
if (closed || active) return;
|
|
64
|
+
active = true; announced = false;
|
|
65
|
+
parser = new StdinBuffer({ escapeTimeout: resolveEscapeTimeoutMs() });
|
|
66
|
+
parser.on("data", (data: string) => { if (!isKeyRelease(data) && matchesKey(data, "ctrl+c")) interrupt(); });
|
|
67
|
+
stdin.setEncoding("utf8");
|
|
68
|
+
stdin.on("data", receive);
|
|
69
|
+
signals.on("SIGINT", interrupt); signals.on("SIGTERM", terminate); signals.on("SIGHUP", hangup);
|
|
70
|
+
stdin.setRawMode(true);
|
|
71
|
+
stdin.resume();
|
|
72
|
+
// Assumed UI grace period, not a work deadline: fast starts stay quiet;
|
|
73
|
+
// a slow stage remains visible without truncating or abandoning its work.
|
|
74
|
+
timer = setTimeout(announce, 750);
|
|
75
|
+
timer.unref();
|
|
76
|
+
};
|
|
77
|
+
const handoff = () => {
|
|
78
|
+
if (!active) return;
|
|
79
|
+
release();
|
|
80
|
+
const buffered = pending.join(""); pending = [];
|
|
81
|
+
if (buffered) stdin.unshift(buffered);
|
|
82
|
+
};
|
|
83
|
+
capture();
|
|
84
|
+
return {
|
|
85
|
+
phase(name) { if (name === phase) return; phase = name; if (announced) announce(); },
|
|
86
|
+
handoff, restore,
|
|
87
|
+
async runWithTerminal(run) {
|
|
88
|
+
// A selector can load settings/history before mounting. Keep owning input
|
|
89
|
+
// until its synchronous screen.start(), then reacquire only after stop().
|
|
90
|
+
try { return await run(handoff); }
|
|
91
|
+
finally { capture(); }
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|