clikcode 1.0.2 → 1.0.4
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/ai-router-runtime.cjs +166 -117
- package/dist/cli.js +1012 -535
- package/dist/computer-tools.js +3 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -12649,30 +12649,295 @@ var init_structured_output = __esm({
|
|
|
12649
12649
|
}
|
|
12650
12650
|
});
|
|
12651
12651
|
|
|
12652
|
-
// src/tui/
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
if (
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12652
|
+
// src/tui/render/hyperlinks.ts
|
|
12653
|
+
function hyperlinksSupported(environment = process.env, isTty = Boolean(process.stdout.isTTY)) {
|
|
12654
|
+
const flag = (value) => value !== void 0 && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
12655
|
+
if (!isTty || (environment.TERM ?? "").toLowerCase() === "dumb") return false;
|
|
12656
|
+
if (flag(environment.CLIKCODE_HYPERLINKS) || flag(environment.FORCE_HYPERLINK)) return true;
|
|
12657
|
+
if (environment.TMUX || environment.STY || /^(?:screen|tmux)/.test(environment.TERM ?? "")) return false;
|
|
12658
|
+
const program3 = (environment.TERM_PROGRAM ?? "").toLowerCase();
|
|
12659
|
+
if (["iterm.app", "wezterm", "vscode", "ghostty", "hyper", "kitty", "rio", "warpterminal", "termius"].includes(program3)) return true;
|
|
12660
|
+
if (environment.KITTY_WINDOW_ID || environment.WT_SESSION || environment.KONSOLE_VERSION || environment.DOMTERM) return true;
|
|
12661
|
+
if (Number(environment.VTE_VERSION ?? 0) >= 5e3) return true;
|
|
12662
|
+
return /^(?:xterm-kitty|xterm-ghostty|foot|alacritty|wezterm|contour)/.test(environment.TERM ?? "");
|
|
12663
|
+
}
|
|
12664
|
+
function closeOpenHyperlink(row) {
|
|
12665
|
+
const last2 = row.lastIndexOf("\x1B]8;");
|
|
12666
|
+
const closedLink = last2 === -1 || row.startsWith(HYPERLINK_CLOSE, last2) ? row : `${row}${HYPERLINK_CLOSE}`;
|
|
12667
|
+
if (!UNDERLINE_ON.test(closedLink)) return closedLink;
|
|
12668
|
+
let underline = false;
|
|
12669
|
+
for (const match of closedLink.matchAll(/\u001b\[([0-9;]*)m/g)) {
|
|
12670
|
+
const params = match[1].split(";").filter(Boolean).map(Number);
|
|
12671
|
+
if (params.length === 0 || params.includes(0)) {
|
|
12672
|
+
underline = false;
|
|
12673
|
+
continue;
|
|
12674
|
+
}
|
|
12675
|
+
if (params.includes(4)) underline = true;
|
|
12676
|
+
if (params.includes(24)) underline = false;
|
|
12677
|
+
}
|
|
12678
|
+
return underline ? `${closedLink}\x1B[24m` : closedLink;
|
|
12679
|
+
}
|
|
12680
|
+
var HYPERLINK_CLOSE, hyperlinkOpen, hyperlinksEnabled, linksOn, UNDERLINE_ON;
|
|
12681
|
+
var init_hyperlinks = __esm({
|
|
12682
|
+
"src/tui/render/hyperlinks.ts"() {
|
|
12683
|
+
"use strict";
|
|
12684
|
+
HYPERLINK_CLOSE = "\x1B]8;;\x1B\\";
|
|
12685
|
+
hyperlinkOpen = (href) => `\x1B]8;;${href}\x1B\\`;
|
|
12686
|
+
linksOn = () => hyperlinksEnabled ?? (hyperlinksEnabled = hyperlinksSupported());
|
|
12687
|
+
UNDERLINE_ON = /\u001b\[(?:[0-9;]*;)?4[;m]/;
|
|
12688
|
+
}
|
|
12689
|
+
});
|
|
12690
|
+
|
|
12691
|
+
// src/tui/render/width.ts
|
|
12692
|
+
function visibleSlice(value, width) {
|
|
12693
|
+
if (terminalCellWidth(value) <= width) return value;
|
|
12694
|
+
const available = Math.max(0, width - 1);
|
|
12695
|
+
let rendered = "";
|
|
12696
|
+
let renderedWidth = 0;
|
|
12697
|
+
let sawAnsi = false;
|
|
12698
|
+
const tokens = displayTokens(value);
|
|
12699
|
+
let linkOpen = false;
|
|
12700
|
+
for (const token of tokens) {
|
|
12701
|
+
if (token[0] === "\x1B") {
|
|
12702
|
+
rendered += token;
|
|
12703
|
+
if (OSC8_SEQUENCE.test(token)) linkOpen = token !== HYPERLINK_CLOSE;
|
|
12704
|
+
else sawAnsi = true;
|
|
12705
|
+
continue;
|
|
12660
12706
|
}
|
|
12707
|
+
const tokenWidth = terminalCellWidth(token);
|
|
12708
|
+
if (renderedWidth + tokenWidth > available) break;
|
|
12709
|
+
rendered += token;
|
|
12710
|
+
renderedWidth += tokenWidth;
|
|
12711
|
+
}
|
|
12712
|
+
return `${rendered}${linkOpen ? HYPERLINK_CLOSE : ""}${sawAnsi ? "\x1B[0m" : ""}\u2026`;
|
|
12713
|
+
}
|
|
12714
|
+
function visibleTail(value, width) {
|
|
12715
|
+
if (terminalCellWidth(value) <= width) return value;
|
|
12716
|
+
const tokens = displayTokens(value);
|
|
12717
|
+
let kept = "";
|
|
12718
|
+
let keptWidth = 0;
|
|
12719
|
+
for (let index = tokens.length - 1; index >= 0; index -= 1) {
|
|
12720
|
+
const tokenWidth = terminalCellWidth(tokens[index]);
|
|
12721
|
+
if (keptWidth + tokenWidth > Math.max(0, width - 1)) break;
|
|
12722
|
+
kept = tokens[index] + kept;
|
|
12723
|
+
keptWidth += tokenWidth;
|
|
12724
|
+
}
|
|
12725
|
+
return `\u2026${kept}`;
|
|
12726
|
+
}
|
|
12727
|
+
function visiblePathTail(path57, width) {
|
|
12728
|
+
if (terminalCellWidth(path57) <= width) return path57;
|
|
12729
|
+
const parts = path57.split(/(?=[\\/])/);
|
|
12730
|
+
let kept = "";
|
|
12731
|
+
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
12732
|
+
if (terminalCellWidth(`\u2026${parts[index]}${kept}`) > width) break;
|
|
12733
|
+
kept = `${parts[index]}${kept}`;
|
|
12734
|
+
}
|
|
12735
|
+
return kept ? `\u2026${kept}` : visibleSlice(`\u2026${parts[parts.length - 1]}`, width);
|
|
12736
|
+
}
|
|
12737
|
+
function isWideCodePoint(code) {
|
|
12738
|
+
if (code < 4352) return false;
|
|
12739
|
+
return code <= 4447 || code === 9001 || code === 9002 || code >= 11904 && code <= 12350 || code >= 12353 && code <= 19903 || code >= 19968 && code <= 42191 || code >= 43360 && code <= 43391 || code >= 44032 && code <= 55203 || code >= 63744 && code <= 64255 || code >= 65040 && code <= 65049 || code >= 65072 && code <= 65135 || code >= 65281 && code <= 65376 || code >= 65504 && code <= 65510 || code >= 127462 && code <= 127487 || code >= 94176 && code <= 94180 || code >= 94208 && code <= 101119 || code >= 110592 && code <= 111359 || code >= 127488 && code <= 127490 || code >= 127504 && code <= 127547 || code >= 127552 && code <= 127560 || code >= 127568 && code <= 127569 || code >= 127584 && code <= 127589 || code >= 127744 && code <= 129791 || code >= 131072 && code <= 262141;
|
|
12740
|
+
}
|
|
12741
|
+
function drawsNothing(code, character) {
|
|
12742
|
+
if (code < 160) return false;
|
|
12743
|
+
if (code === 8232 || code === 8233) return true;
|
|
12744
|
+
return FORMAT.test(character) && !(code >= 1536 && code <= 1541 || code === 1757 || code === 1807 || code === 2192 || code === 2193 || code === 2274);
|
|
12745
|
+
}
|
|
12746
|
+
function displayTokens(value) {
|
|
12747
|
+
const tokens = [];
|
|
12748
|
+
const pushText = (text7) => {
|
|
12749
|
+
for (const { segment } of graphemes().segment(text7)) tokens.push(segment);
|
|
12750
|
+
};
|
|
12751
|
+
let consumed = 0;
|
|
12752
|
+
for (const match of value.matchAll(ZERO_WIDTH_SEQUENCES)) {
|
|
12753
|
+
const start2 = match.index;
|
|
12754
|
+
if (start2 > consumed) pushText(value.slice(consumed, start2));
|
|
12755
|
+
tokens.push(match[0]);
|
|
12756
|
+
consumed = start2 + match[0].length;
|
|
12757
|
+
}
|
|
12758
|
+
if (consumed < value.length) pushText(value.slice(consumed));
|
|
12759
|
+
return tokens;
|
|
12760
|
+
}
|
|
12761
|
+
function oneCell(code) {
|
|
12762
|
+
let known = ONE_CELL[code];
|
|
12763
|
+
if (!known) {
|
|
12764
|
+
const character = String.fromCharCode(code);
|
|
12765
|
+
const joins = code >= 55296 && code <= 57343 || code >= 4352 && code <= 4607 || code >= 43360 && code <= 43391 || code >= 55216 && code <= 55295 || code >= 1536 && code <= 1541 || code === 1757 || code === 1807 || code === 2192 || code === 2193 || code === 2274 || code === 3406 || code === 3635 || code === 3763 || code === 8205;
|
|
12766
|
+
known = joins || isWideCodePoint(code) || MARK.test(character) || GRAPHEME_EXTEND.test(character) || drawsNothing(code, character) || EMOJI_PRESENTATION.test(character) ? 2 : 1;
|
|
12767
|
+
ONE_CELL[code] = known;
|
|
12661
12768
|
}
|
|
12662
|
-
return
|
|
12769
|
+
return known === 1;
|
|
12663
12770
|
}
|
|
12664
|
-
function
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
if (
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12771
|
+
function simpleWidth(value) {
|
|
12772
|
+
let width = 0;
|
|
12773
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
12774
|
+
const code = value.charCodeAt(index);
|
|
12775
|
+
if (code >= 32 && code < 127) width += 1;
|
|
12776
|
+
else if (code === 27) {
|
|
12777
|
+
const next = value.charCodeAt(index + 1);
|
|
12778
|
+
let end = index + 2;
|
|
12779
|
+
if (next === 91) {
|
|
12780
|
+
while (end < value.length && (value.charCodeAt(end) >= 48 && value.charCodeAt(end) <= 57 || value.charCodeAt(end) === 59)) end += 1;
|
|
12781
|
+
if (value.charCodeAt(end) !== 109) return -1;
|
|
12782
|
+
} else if (next === 93 && value.startsWith("8;", end)) {
|
|
12783
|
+
while (end < value.length && !"\x07\x1B\n".includes(value[end])) end += 1;
|
|
12784
|
+
if (value.charCodeAt(end) !== 27 || value.charCodeAt(end + 1) !== 92) return -1;
|
|
12785
|
+
end += 1;
|
|
12786
|
+
} else return -1;
|
|
12787
|
+
index = end;
|
|
12788
|
+
} else if (code === 9) width += TAB_WIDTH - width % TAB_WIDTH;
|
|
12789
|
+
else if (code < 160) continue;
|
|
12790
|
+
else if (oneCell(code)) width += 1;
|
|
12791
|
+
else return -1;
|
|
12792
|
+
}
|
|
12793
|
+
return width;
|
|
12794
|
+
}
|
|
12795
|
+
function terminalCellWidth(value) {
|
|
12796
|
+
const simple = simpleWidth(value);
|
|
12797
|
+
if (simple >= 0) return simple;
|
|
12798
|
+
const plain3 = value.includes("\x1B") ? value.replace(ZERO_WIDTH_SEQUENCES, "") : value;
|
|
12799
|
+
let width = 0;
|
|
12800
|
+
for (const { segment } of graphemes().segment(plain3)) {
|
|
12801
|
+
if (segment === " ") {
|
|
12802
|
+
width += TAB_WIDTH - width % TAB_WIDTH;
|
|
12803
|
+
continue;
|
|
12804
|
+
}
|
|
12805
|
+
if (CONTROLS.test(segment)) continue;
|
|
12806
|
+
const code = segment.codePointAt(0) ?? 0;
|
|
12807
|
+
if (segment.length === 1 && code < 127) {
|
|
12808
|
+
width += 1;
|
|
12809
|
+
continue;
|
|
12810
|
+
}
|
|
12811
|
+
const base = String.fromCodePoint(code);
|
|
12812
|
+
if (MARK.test(base) || drawsNothing(code, base)) continue;
|
|
12813
|
+
const wide = segment.includes("\uFE0E") ? isWideCodePoint(code) && code >= 126976 : isWideCodePoint(code) || EMOJI_PRESENTATION.test(base) || segment.includes("\uFE0F") && EMOJI.test(base) && !KEYCAP_BASE.test(base) || segment.includes("\u20E3");
|
|
12814
|
+
width += wide ? 2 : 1;
|
|
12815
|
+
}
|
|
12816
|
+
return width;
|
|
12817
|
+
}
|
|
12818
|
+
function previousCharacterIndex(value, index) {
|
|
12819
|
+
if (index <= 0) return 0;
|
|
12820
|
+
const start2 = Math.max(0, index - CLUSTER_WINDOW);
|
|
12821
|
+
let boundary = 0;
|
|
12822
|
+
for (const { index: offset } of graphemes().segment(value.slice(start2, index))) boundary = offset;
|
|
12823
|
+
return start2 + boundary;
|
|
12824
|
+
}
|
|
12825
|
+
function nextCharacterIndex(value, index) {
|
|
12826
|
+
if (index >= value.length) return value.length;
|
|
12827
|
+
const [first2] = graphemes().segment(value.slice(index, index + CLUSTER_WINDOW));
|
|
12828
|
+
return index + (first2 ? first2.segment.length : 1);
|
|
12829
|
+
}
|
|
12830
|
+
var OSC8_SEQUENCE, ZERO_WIDTH_SEQUENCES, TAB_WIDTH, graphemeSegmenter, graphemes, CLUSTER_WINDOW, FORMAT, CONTROLS, MARK, EMOJI_PRESENTATION, EMOJI, KEYCAP_BASE, GRAPHEME_EXTEND, ONE_CELL;
|
|
12831
|
+
var init_width = __esm({
|
|
12832
|
+
"src/tui/render/width.ts"() {
|
|
12833
|
+
"use strict";
|
|
12834
|
+
init_hyperlinks();
|
|
12835
|
+
OSC8_SEQUENCE = /^\u001b\]8;[^\u0007\u001b\n]*\u001b\\$/;
|
|
12836
|
+
ZERO_WIDTH_SEQUENCES = /\u001b\[[0-9;]*m|\u001b\]8;[^\u0007\u001b\n]*\u001b\\/g;
|
|
12837
|
+
TAB_WIDTH = 4;
|
|
12838
|
+
graphemes = () => graphemeSegmenter ??= new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
12839
|
+
CLUSTER_WINDOW = 32;
|
|
12840
|
+
FORMAT = new RegExp("\\p{Cf}", "u");
|
|
12841
|
+
CONTROLS = /^[\u0000-\u001f\u007f-\u009f]+$/;
|
|
12842
|
+
MARK = new RegExp("\\p{Mark}", "u");
|
|
12843
|
+
EMOJI_PRESENTATION = new RegExp("\\p{Emoji_Presentation}", "u");
|
|
12844
|
+
EMOJI = new RegExp("\\p{Emoji}", "u");
|
|
12845
|
+
KEYCAP_BASE = /^[0-9#*]$/;
|
|
12846
|
+
GRAPHEME_EXTEND = new RegExp("\\p{Grapheme_Extend}", "u");
|
|
12847
|
+
ONE_CELL = new Uint8Array(65536);
|
|
12848
|
+
}
|
|
12849
|
+
});
|
|
12850
|
+
|
|
12851
|
+
// src/tui/render/text.ts
|
|
12852
|
+
function expandTabs(value, tabWidth = TAB_WIDTH) {
|
|
12853
|
+
if (!value.includes(" ")) return value;
|
|
12854
|
+
return value.split("\n").map((line3) => {
|
|
12855
|
+
if (!line3.includes(" ")) return line3;
|
|
12856
|
+
let column = 0;
|
|
12857
|
+
let expanded = "";
|
|
12858
|
+
for (const [index, part] of line3.split(" ").entries()) {
|
|
12859
|
+
if (index > 0) {
|
|
12860
|
+
const fill2 = tabWidth - column % tabWidth;
|
|
12861
|
+
expanded += " ".repeat(fill2);
|
|
12862
|
+
column += fill2;
|
|
12863
|
+
}
|
|
12864
|
+
expanded += part;
|
|
12865
|
+
column += terminalCellWidth(part);
|
|
12866
|
+
}
|
|
12867
|
+
return expanded;
|
|
12868
|
+
}).join("\n");
|
|
12869
|
+
}
|
|
12870
|
+
function sanitizeTerminalText(value, options2 = {}) {
|
|
12871
|
+
const clean2 = options2.keepSgr ? !UNSAFE_IN_STYLED_TEXT.test(value) : !(options2.keepTabs ? NEEDS_SANITIZING_KEEP_TABS : NEEDS_SANITIZING).test(value);
|
|
12872
|
+
if (clean2 && !(options2.singleLine && value.includes("\n"))) return value;
|
|
12873
|
+
let text7 = value.replace(/\r\n?/g, "\n");
|
|
12874
|
+
text7 = text7.replace(ESCAPE_SEQUENCE, (sequence) => options2.keepSgr && (SGR_SEQUENCE.test(sequence) || OSC8_SEQUENCE.test(sequence)) ? sequence : "");
|
|
12875
|
+
text7 = text7.replace(CONTROL_CHARACTERS, (character) => character === "\x1B" && options2.keepSgr ? character : "");
|
|
12876
|
+
if (!options2.keepTabs) text7 = expandTabs(text7, options2.tabWidth ?? TAB_WIDTH);
|
|
12877
|
+
return options2.singleLine ? text7.replace(/\n/g, " ") : text7;
|
|
12878
|
+
}
|
|
12879
|
+
var ESCAPE_SEQUENCE, SGR_SEQUENCE, SAFE_LINK, NEEDS_SANITIZING, NEEDS_SANITIZING_KEEP_TABS, UNSAFE_IN_STYLED_TEXT, CONTROL_CHARACTERS;
|
|
12880
|
+
var init_text = __esm({
|
|
12881
|
+
"src/tui/render/text.ts"() {
|
|
12882
|
+
"use strict";
|
|
12883
|
+
init_width();
|
|
12884
|
+
ESCAPE_SEQUENCE = new RegExp([
|
|
12885
|
+
"\\u001b\\][^\\u0007\\u001b\\n]*(?:\\u0007|\\u001b\\\\)?",
|
|
12886
|
+
"\\u001b[PX^_][^\\u001b\\n]*(?:\\u001b\\\\)?",
|
|
12887
|
+
"(?:\\u001b\\[|\\u009b)[0-?]*[ -/]*[@-~]?",
|
|
12888
|
+
"\\u001b[ -/]*[0-~]?"
|
|
12889
|
+
].join("|"), "g");
|
|
12890
|
+
SGR_SEQUENCE = /^\u001b\[[0-9;]*m$/;
|
|
12891
|
+
SAFE_LINK = /^(?:https?:\/\/|mailto:)[^\s\u0000-\u001f\u007f-\u009f]+$/i;
|
|
12892
|
+
NEEDS_SANITIZING = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f\t]/;
|
|
12893
|
+
NEEDS_SANITIZING_KEEP_TABS = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/;
|
|
12894
|
+
UNSAFE_IN_STYLED_TEXT = /[\u0000-\u0009\u000b-\u001a\u001c-\u001f\u007f-\u009f]|\u001b(?!\[[0-9;]*m|\]8;[^\u0007\u001b\n]*\u001b\\)/;
|
|
12895
|
+
CONTROL_CHARACTERS = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g;
|
|
12896
|
+
}
|
|
12897
|
+
});
|
|
12898
|
+
|
|
12899
|
+
// src/tui/keys.ts
|
|
12900
|
+
function environmentFlag(...values) {
|
|
12901
|
+
return values.some((value) => {
|
|
12902
|
+
const normalized = (value ?? "").trim().toLowerCase();
|
|
12903
|
+
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
12904
|
+
});
|
|
12905
|
+
}
|
|
12906
|
+
function pastedText(key3) {
|
|
12907
|
+
return key3.startsWith(PASTE_START) && key3.endsWith(PASTE_END) ? sanitizeTerminalText(key3.slice(PASTE_START.length, key3.length - PASTE_END.length), { keepTabs: true }) : void 0;
|
|
12908
|
+
}
|
|
12909
|
+
function kittyKeyboardSafe(environment = process.env) {
|
|
12910
|
+
if (environmentFlag(environment.CLIKCODE_NO_KITTY_KEYBOARD)) return false;
|
|
12911
|
+
if (environment.TMUX || environment.STY || /^(?:screen|tmux)/.test(environment.TERM ?? "")) return false;
|
|
12912
|
+
const program3 = (environment.TERM_PROGRAM ?? "").toLowerCase();
|
|
12913
|
+
return Boolean(environment.KITTY_WINDOW_ID || environment.GHOSTTY_RESOURCES_DIR || environment.WEZTERM_PANE || /^(?:xterm-kitty|xterm-ghostty|foot|alacritty|wezterm)/.test(environment.TERM ?? "") || program3 === "wezterm" || program3 === "ghostty" || program3 === "kitty");
|
|
12914
|
+
}
|
|
12915
|
+
var PASTE_START, PASTE_END, PUSH_KITTY_KEYBOARD, POP_KITTY_KEYBOARD, NEWLINE_KEY;
|
|
12916
|
+
var init_keys = __esm({
|
|
12917
|
+
"src/tui/keys.ts"() {
|
|
12918
|
+
"use strict";
|
|
12919
|
+
init_text();
|
|
12920
|
+
PASTE_START = "\x1B[200~";
|
|
12921
|
+
PASTE_END = "\x1B[201~";
|
|
12922
|
+
PUSH_KITTY_KEYBOARD = "\x1B[>1u";
|
|
12923
|
+
POP_KITTY_KEYBOARD = "\x1B[<u";
|
|
12924
|
+
NEWLINE_KEY = "\x1B\r";
|
|
12925
|
+
}
|
|
12926
|
+
});
|
|
12927
|
+
|
|
12928
|
+
// src/tui/inline.ts
|
|
12929
|
+
function inlineHistoryMode(env3 = process.env) {
|
|
12930
|
+
if (env3.CLIKDEPLOY_CLIENT === "mobile") return false;
|
|
12931
|
+
return env3.CLIKCODE_INLINE === "1";
|
|
12932
|
+
}
|
|
12933
|
+
function swallowsAlternateScreen(env3 = process.env) {
|
|
12934
|
+
return Boolean(env3.STY) && !env3.TMUX;
|
|
12935
|
+
}
|
|
12936
|
+
function restoreMainBlock() {
|
|
12937
|
+
const main = inlineBlock.main;
|
|
12938
|
+
inlineBlock.main = void 0;
|
|
12939
|
+
inlineBlock.page = false;
|
|
12940
|
+
if (main) Object.assign(inlineBlock, main, { found: void 0, lost: false });
|
|
12676
12941
|
}
|
|
12677
12942
|
function eraseInlineBlock() {
|
|
12678
12943
|
const out2 = inlineBlock.rows ? `${inlineBlock.cursorRow > 0 ? `\x1B[${inlineBlock.cursorRow}A` : ""}\r\x1B[J` : "";
|
|
@@ -12681,15 +12946,12 @@ function eraseInlineBlock() {
|
|
|
12681
12946
|
inlineBlock.last = "";
|
|
12682
12947
|
inlineBlock.liveRows = [];
|
|
12683
12948
|
inlineBlock.pad = 0;
|
|
12684
|
-
inlineBlock.slack = 0;
|
|
12685
12949
|
return out2;
|
|
12686
12950
|
}
|
|
12687
|
-
var
|
|
12951
|
+
var CLEAR_SCREEN_AND_SCROLLBACK, CLEAR_SCREEN, inlineBlock, ENTER_PAGE_SCREEN, LEAVE_PAGE_SCREEN;
|
|
12688
12952
|
var init_inline = __esm({
|
|
12689
12953
|
"src/tui/inline.ts"() {
|
|
12690
12954
|
"use strict";
|
|
12691
|
-
GOOD_TERMINAL_PROGRAMS = /* @__PURE__ */ new Set(["iterm.app", "apple_terminal", "wezterm", "ghostty", "kitty", "vscode", "alacritty"]);
|
|
12692
|
-
GOOD_TERMS = /* @__PURE__ */ new Set(["xterm-kitty", "alacritty", "xterm-ghostty", "wezterm"]);
|
|
12693
12955
|
CLEAR_SCREEN_AND_SCROLLBACK = "\x1B[2J\x1B[3J\x1B[H";
|
|
12694
12956
|
CLEAR_SCREEN = "\x1B[H\x1B[K\x1B[2;1H\x1B[J\x1B[H";
|
|
12695
12957
|
inlineBlock = {
|
|
@@ -12699,26 +12961,35 @@ var init_inline = __esm({
|
|
|
12699
12961
|
last: "",
|
|
12700
12962
|
liveRows: [],
|
|
12701
12963
|
columns: 0,
|
|
12702
|
-
/** The blank rows above the conversation (a conversation shorter than the screen
|
|
12964
|
+
/** The blank rows above the conversation (a conversation shorter than the screen, drawn on the last rows at the start) that
|
|
12965
|
+
* retired rows have not yet used. Only true while the block ends on the last row: a resize or a shrinking block zeroes it. */
|
|
12703
12966
|
pad: 0,
|
|
12704
|
-
/** The
|
|
12705
|
-
|
|
12706
|
-
|
|
12707
|
-
/** The screen height the block was last placed for: it ended on the last row of a screen this tall. */
|
|
12967
|
+
/** The screen row the block's first row is on: measured after a change of height, otherwise followed from where it was drawn. */
|
|
12968
|
+
top: 0,
|
|
12969
|
+
/** The screen height the block was last drawn for. */
|
|
12708
12970
|
height: 0,
|
|
12709
|
-
/** After a settled change of height, the screen row the
|
|
12710
|
-
*
|
|
12971
|
+
/** After a settled change of height, the screen row the block's first row is on, from the terminal's cursor report
|
|
12972
|
+
* (negative: its top rows went into the saved lines); undefined when nothing was asked. The next frame consumes it.
|
|
12973
|
+
* `measuring` holds frames back while the question is out. */
|
|
12711
12974
|
found: void 0,
|
|
12712
12975
|
measuring: false,
|
|
12713
|
-
/** The cursor report never came back after a change of height:
|
|
12714
|
-
*
|
|
12976
|
+
/** The cursor report never came back after a change of height: the block is erased and drawn again relative to where
|
|
12977
|
+
* it was last left (see anchorBlock). */
|
|
12715
12978
|
lost: false,
|
|
12716
|
-
/** A modal surface (the board, the palette, a picker) is on screen: it is the
|
|
12717
|
-
* row,
|
|
12718
|
-
*
|
|
12979
|
+
/** A modal surface (the board, the palette, a picker) is on screen: it is drawn on the ALTERNATE screen (`?1049h`), from its
|
|
12980
|
+
* top row, so no saved lines exist behind it in any client and the main screen (the conversation and its live block) is not
|
|
12981
|
+
* touched; closing it (`?1049l`) shows that screen again as it was. `main` is the block's state on the main screen, kept while
|
|
12982
|
+
* the page is up and put back when it closes. `tail` is every row the conversation retired meanwhile: written above the block
|
|
12983
|
+
* once the page is gone. `resized`: the size changed while it was up, so the main screen is measured again on close.
|
|
12984
|
+
* `wipe`: the conversation was rewritten (a new width) while it was up, so the main screen is cleared and it is written whole. */
|
|
12719
12985
|
page: false,
|
|
12720
|
-
tail: []
|
|
12986
|
+
tail: [],
|
|
12987
|
+
resized: false,
|
|
12988
|
+
wipe: false,
|
|
12989
|
+
main: void 0
|
|
12721
12990
|
};
|
|
12991
|
+
ENTER_PAGE_SCREEN = `\x1B[?1049h${CLEAR_SCREEN}`;
|
|
12992
|
+
LEAVE_PAGE_SCREEN = "\x1B[?1049l";
|
|
12722
12993
|
}
|
|
12723
12994
|
});
|
|
12724
12995
|
|
|
@@ -12760,11 +13031,47 @@ var init_terminal_signals = __esm({
|
|
|
12760
13031
|
// src/tui/restore.ts
|
|
12761
13032
|
import { writeSync } from "node:fs";
|
|
12762
13033
|
import { stdin as input, stdout as output } from "node:process";
|
|
13034
|
+
function reexecHandover(env3 = process.env) {
|
|
13035
|
+
return inlineHistoryMode(env3) ? "inline" : "alt";
|
|
13036
|
+
}
|
|
13037
|
+
function parseReexecHandover(value) {
|
|
13038
|
+
return value === "inline" || value === "alt" || value === "1" ? value : void 0;
|
|
13039
|
+
}
|
|
13040
|
+
function reconcileScreen(handover, inline2, rows) {
|
|
13041
|
+
const inlineStart = `${CLEAR_SCREEN_AND_SCROLLBACK}\x1B[${Math.max(1, rows)};1H`;
|
|
13042
|
+
if (inline2) return { write: `${handover === "alt" || handover === "1" ? "\x1B[?1049l" : ""}${inlineStart}`, inherited: handover !== void 0 };
|
|
13043
|
+
if (handover === void 0) return { write: enterAlternateScreenSequence(), inherited: false };
|
|
13044
|
+
if (handover === "alt") return { write: "", inherited: true };
|
|
13045
|
+
return { write: `${CLEAR_SCREEN_AND_SCROLLBACK}${enterAlternateScreenSequence()}`, inherited: true };
|
|
13046
|
+
}
|
|
13047
|
+
function enterAlternateScreenSequence() {
|
|
13048
|
+
if (!swallowsAlternateScreen()) return "\x1B[?1049h\x1B[2J\x1B[H";
|
|
13049
|
+
return `\x1B[?1049h${"\r\n".repeat(Math.max(1, output.rows || 24))}${CLEAR_SCREEN}`;
|
|
13050
|
+
}
|
|
13051
|
+
function historyDumpSequence() {
|
|
13052
|
+
if (historyDump.suppressed || !historyDump.source || inlineHistoryMode()) return "";
|
|
13053
|
+
let text7 = "";
|
|
13054
|
+
try {
|
|
13055
|
+
text7 = historyDump.source();
|
|
13056
|
+
} catch {
|
|
13057
|
+
}
|
|
13058
|
+
const wipe = swallowsAlternateScreen() ? `${CLEAR_SCREEN}` : "";
|
|
13059
|
+
return text7 || wipe ? `${wipe}${text7}` : "";
|
|
13060
|
+
}
|
|
12763
13061
|
function enterAlternateScreen() {
|
|
12764
13062
|
if (terminalModes.alternateScreen || inlineHistoryMode()) return;
|
|
12765
|
-
output.write(
|
|
13063
|
+
output.write(enterAlternateScreenSequence());
|
|
12766
13064
|
terminalModes.alternateScreen = true;
|
|
12767
13065
|
}
|
|
13066
|
+
function leavePage() {
|
|
13067
|
+
if (!inlineBlock.page) return "";
|
|
13068
|
+
restoreMainBlock();
|
|
13069
|
+
inlineBlock.tail = [];
|
|
13070
|
+
inlineBlock.resized = false;
|
|
13071
|
+
inlineBlock.wipe = false;
|
|
13072
|
+
terminalModes.alternateScreen = false;
|
|
13073
|
+
return LEAVE_PAGE_SCREEN;
|
|
13074
|
+
}
|
|
12768
13075
|
function pushShellTitle() {
|
|
12769
13076
|
if (!output.isTTY || terminalModes.titlePushed) return false;
|
|
12770
13077
|
output.write(PUSH_TITLE);
|
|
@@ -12772,7 +13079,7 @@ function pushShellTitle() {
|
|
|
12772
13079
|
return true;
|
|
12773
13080
|
}
|
|
12774
13081
|
function giveBackTerminal(readModesOff) {
|
|
12775
|
-
output.write(`${readModesOff}` + terminalTeardown(terminalModes.alternateScreen) + signalsTeardown());
|
|
13082
|
+
output.write(`${readModesOff}` + terminalTeardown(terminalModes.alternateScreen) + signalsTeardown() + historyDumpSequence());
|
|
12776
13083
|
terminalModes.alternateScreen = false;
|
|
12777
13084
|
terminalModes.painted = false;
|
|
12778
13085
|
}
|
|
@@ -12783,14 +13090,18 @@ function signalsTeardown() {
|
|
|
12783
13090
|
return sequence;
|
|
12784
13091
|
}
|
|
12785
13092
|
function terminalPrepare() {
|
|
12786
|
-
|
|
13093
|
+
const kitty = kittyKeyboardSafe() ? CLEAR_KITTY_KEYBOARD : "";
|
|
13094
|
+
return `${kitty}${MOUSE_MODES_OFF}${READ_MODES_OFF}${LATCHED_OFF}`;
|
|
12787
13095
|
}
|
|
12788
13096
|
function terminalTeardown(leavingAlternateScreen) {
|
|
12789
|
-
|
|
13097
|
+
const scroll = terminalModes.alternateScroll ? "\x1B[?1007l" : "";
|
|
13098
|
+
terminalModes.alternateScroll = false;
|
|
13099
|
+
const modesOff = `${MOUSE_MODES_OFF}${READ_MODES_OFF}${scroll}`;
|
|
13100
|
+
return `${leavingAlternateScreen ? `${modesOff}\x1B[?1049l` : ""}${modesOff}${LATCHED_OFF}\x1B[?7h\x1B[?25h`;
|
|
12790
13101
|
}
|
|
12791
13102
|
function restoreTerminal(options2 = {}) {
|
|
12792
13103
|
try {
|
|
12793
|
-
const touched = terminalModes.uiStarted || terminalModes.painted || terminalModes.kittyKeyboard || terminalModes.bracketedPaste || terminalModes.wheelReporting || terminalModes.alternateScreen || terminalModes.rawMode || terminalModes.titlePushed || terminalModes.progress;
|
|
13104
|
+
const touched = terminalModes.uiStarted || terminalModes.painted || terminalModes.kittyKeyboard || terminalModes.bracketedPaste || terminalModes.wheelReporting || terminalModes.alternateScroll || terminalModes.alternateScreen || terminalModes.rawMode || terminalModes.titlePushed || terminalModes.progress;
|
|
12794
13105
|
if (!touched) {
|
|
12795
13106
|
if (input.isRaw && input.isTTY && typeof input.setRawMode === "function") input.setRawMode(false);
|
|
12796
13107
|
return;
|
|
@@ -12798,8 +13109,10 @@ function restoreTerminal(options2 = {}) {
|
|
|
12798
13109
|
let sequence = "";
|
|
12799
13110
|
if (terminalModes.painted) sequence += "\x1B[?2026l";
|
|
12800
13111
|
if (terminalModes.kittyKeyboard) sequence += "\x1B[<u";
|
|
12801
|
-
|
|
13112
|
+
const leavingAlternate = terminalModes.alternateScreen;
|
|
13113
|
+
sequence += terminalTeardown(leavingAlternate);
|
|
12802
13114
|
sequence += signalsTeardown();
|
|
13115
|
+
if (leavingAlternate) sequence += historyDumpSequence();
|
|
12803
13116
|
const wasRaw = terminalModes.rawMode;
|
|
12804
13117
|
terminalModes.uiStarted = false;
|
|
12805
13118
|
terminalModes.painted = false;
|
|
@@ -12832,18 +13145,20 @@ function installTerminalRestoreSignals() {
|
|
|
12832
13145
|
});
|
|
12833
13146
|
}
|
|
12834
13147
|
}
|
|
12835
|
-
var REEXEC_TERMINAL_ENV,
|
|
13148
|
+
var REEXEC_TERMINAL_ENV, historyDump, terminalModes, CLEAR_KITTY_KEYBOARD, MOUSE_MODES_OFF, READ_MODES_OFF, LATCHED_OFF, RESTORE_SIGNALS, restoreSignalsInstalled;
|
|
12836
13149
|
var init_restore = __esm({
|
|
12837
13150
|
"src/tui/restore.ts"() {
|
|
12838
13151
|
"use strict";
|
|
13152
|
+
init_keys();
|
|
12839
13153
|
init_inline();
|
|
12840
13154
|
init_terminal_signals();
|
|
12841
13155
|
REEXEC_TERMINAL_ENV = "CLIKCODE_KEEP_TERMINAL_ON_REEXEC";
|
|
12842
|
-
|
|
13156
|
+
historyDump = { source: void 0, suppressed: false };
|
|
12843
13157
|
terminalModes = {
|
|
12844
13158
|
bracketedPaste: false,
|
|
12845
13159
|
kittyKeyboard: false,
|
|
12846
13160
|
wheelReporting: false,
|
|
13161
|
+
alternateScroll: false,
|
|
12847
13162
|
alternateScreen: false,
|
|
12848
13163
|
rawMode: false,
|
|
12849
13164
|
painted: false,
|
|
@@ -12851,6 +13166,7 @@ var init_restore = __esm({
|
|
|
12851
13166
|
titlePushed: false,
|
|
12852
13167
|
progress: false
|
|
12853
13168
|
};
|
|
13169
|
+
CLEAR_KITTY_KEYBOARD = "\x1B[<99u";
|
|
12854
13170
|
MOUSE_MODES_OFF = "\x1B[?1006l\x1B[?1016l\x1B[?1003l\x1B[?1002l\x1B[?1000l";
|
|
12855
13171
|
READ_MODES_OFF = `\x1B[?2004l\x1B[?2031l${FOCUS_REPORTING_OFF}`;
|
|
12856
13172
|
LATCHED_OFF = "\x1B[>4m\x1B(B\x1B7\x1B[r\x1B8";
|
|
@@ -12864,9 +13180,9 @@ var CLIKCODE_VERSION, CLIKCODE_USER_AGENT, CLIKCODE_COMMIT;
|
|
|
12864
13180
|
var init_version = __esm({
|
|
12865
13181
|
"src/version.ts"() {
|
|
12866
13182
|
"use strict";
|
|
12867
|
-
CLIKCODE_VERSION = "1.0.
|
|
13183
|
+
CLIKCODE_VERSION = "1.0.4" ? "1.0.4" : CLIKCODE_VERSION_FALLBACK;
|
|
12868
13184
|
CLIKCODE_USER_AGENT = `ClikCode/${CLIKCODE_VERSION}`;
|
|
12869
|
-
CLIKCODE_COMMIT = "
|
|
13185
|
+
CLIKCODE_COMMIT = "974aeaf4f794ca21868f8db062af7dcd93a0db9a" ? "974aeaf4f794ca21868f8db062af7dcd93a0db9a" : void 0;
|
|
12870
13186
|
}
|
|
12871
13187
|
});
|
|
12872
13188
|
|
|
@@ -15287,7 +15603,7 @@ var require_cross_spawn = __commonJS({
|
|
|
15287
15603
|
enoent.hookChildProcess(spawned, parsed2);
|
|
15288
15604
|
return spawned;
|
|
15289
15605
|
}
|
|
15290
|
-
function
|
|
15606
|
+
function spawnSync3(command, args, options2) {
|
|
15291
15607
|
const parsed2 = parse3(command, args, options2);
|
|
15292
15608
|
const result = cp3.spawnSync(parsed2.command, parsed2.args, parsed2.options);
|
|
15293
15609
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed2);
|
|
@@ -15295,7 +15611,7 @@ var require_cross_spawn = __commonJS({
|
|
|
15295
15611
|
}
|
|
15296
15612
|
module.exports = spawn18;
|
|
15297
15613
|
module.exports.spawn = spawn18;
|
|
15298
|
-
module.exports.sync =
|
|
15614
|
+
module.exports.sync = spawnSync3;
|
|
15299
15615
|
module.exports._parse = parse3;
|
|
15300
15616
|
module.exports._enoent = enoent;
|
|
15301
15617
|
}
|
|
@@ -16890,199 +17206,6 @@ var init_resources = __esm({
|
|
|
16890
17206
|
}
|
|
16891
17207
|
});
|
|
16892
17208
|
|
|
16893
|
-
// src/tui/render/hyperlinks.ts
|
|
16894
|
-
function hyperlinksSupported(environment = process.env, isTty = Boolean(process.stdout.isTTY)) {
|
|
16895
|
-
const flag = (value) => value !== void 0 && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
16896
|
-
if (!isTty || (environment.TERM ?? "").toLowerCase() === "dumb") return false;
|
|
16897
|
-
if (flag(environment.CLIKCODE_HYPERLINKS) || flag(environment.FORCE_HYPERLINK)) return true;
|
|
16898
|
-
if (environment.TMUX || environment.STY || /^(?:screen|tmux)/.test(environment.TERM ?? "")) return false;
|
|
16899
|
-
const program3 = (environment.TERM_PROGRAM ?? "").toLowerCase();
|
|
16900
|
-
if (["iterm.app", "wezterm", "vscode", "ghostty", "hyper", "kitty", "rio", "warpterminal", "termius"].includes(program3)) return true;
|
|
16901
|
-
if (environment.KITTY_WINDOW_ID || environment.WT_SESSION || environment.KONSOLE_VERSION || environment.DOMTERM) return true;
|
|
16902
|
-
if (Number(environment.VTE_VERSION ?? 0) >= 5e3) return true;
|
|
16903
|
-
return /^(?:xterm-kitty|xterm-ghostty|foot|alacritty|wezterm|contour)/.test(environment.TERM ?? "");
|
|
16904
|
-
}
|
|
16905
|
-
function closeOpenHyperlink(row) {
|
|
16906
|
-
const last2 = row.lastIndexOf("\x1B]8;");
|
|
16907
|
-
const closedLink = last2 === -1 || row.startsWith(HYPERLINK_CLOSE, last2) ? row : `${row}${HYPERLINK_CLOSE}`;
|
|
16908
|
-
if (!UNDERLINE_ON.test(closedLink)) return closedLink;
|
|
16909
|
-
let underline = false;
|
|
16910
|
-
for (const match of closedLink.matchAll(/\u001b\[([0-9;]*)m/g)) {
|
|
16911
|
-
const params = match[1].split(";").filter(Boolean).map(Number);
|
|
16912
|
-
if (params.length === 0 || params.includes(0)) {
|
|
16913
|
-
underline = false;
|
|
16914
|
-
continue;
|
|
16915
|
-
}
|
|
16916
|
-
if (params.includes(4)) underline = true;
|
|
16917
|
-
if (params.includes(24)) underline = false;
|
|
16918
|
-
}
|
|
16919
|
-
return underline ? `${closedLink}\x1B[24m` : closedLink;
|
|
16920
|
-
}
|
|
16921
|
-
var HYPERLINK_CLOSE, hyperlinkOpen, hyperlinksEnabled, linksOn, UNDERLINE_ON;
|
|
16922
|
-
var init_hyperlinks = __esm({
|
|
16923
|
-
"src/tui/render/hyperlinks.ts"() {
|
|
16924
|
-
"use strict";
|
|
16925
|
-
HYPERLINK_CLOSE = "\x1B]8;;\x1B\\";
|
|
16926
|
-
hyperlinkOpen = (href) => `\x1B]8;;${href}\x1B\\`;
|
|
16927
|
-
linksOn = () => hyperlinksEnabled ?? (hyperlinksEnabled = hyperlinksSupported());
|
|
16928
|
-
UNDERLINE_ON = /\u001b\[(?:[0-9;]*;)?4[;m]/;
|
|
16929
|
-
}
|
|
16930
|
-
});
|
|
16931
|
-
|
|
16932
|
-
// src/tui/render/width.ts
|
|
16933
|
-
function visibleSlice(value, width) {
|
|
16934
|
-
if (terminalCellWidth(value) <= width) return value;
|
|
16935
|
-
const available = Math.max(0, width - 1);
|
|
16936
|
-
let rendered = "";
|
|
16937
|
-
let renderedWidth = 0;
|
|
16938
|
-
let sawAnsi = false;
|
|
16939
|
-
const tokens = displayTokens(value);
|
|
16940
|
-
let linkOpen = false;
|
|
16941
|
-
for (const token of tokens) {
|
|
16942
|
-
if (token[0] === "\x1B") {
|
|
16943
|
-
rendered += token;
|
|
16944
|
-
if (OSC8_SEQUENCE.test(token)) linkOpen = token !== HYPERLINK_CLOSE;
|
|
16945
|
-
else sawAnsi = true;
|
|
16946
|
-
continue;
|
|
16947
|
-
}
|
|
16948
|
-
const tokenWidth = terminalCellWidth(token);
|
|
16949
|
-
if (renderedWidth + tokenWidth > available) break;
|
|
16950
|
-
rendered += token;
|
|
16951
|
-
renderedWidth += tokenWidth;
|
|
16952
|
-
}
|
|
16953
|
-
return `${rendered}${linkOpen ? HYPERLINK_CLOSE : ""}${sawAnsi ? "\x1B[0m" : ""}\u2026`;
|
|
16954
|
-
}
|
|
16955
|
-
function visibleTail(value, width) {
|
|
16956
|
-
if (terminalCellWidth(value) <= width) return value;
|
|
16957
|
-
const tokens = displayTokens(value);
|
|
16958
|
-
let kept = "";
|
|
16959
|
-
let keptWidth = 0;
|
|
16960
|
-
for (let index = tokens.length - 1; index >= 0; index -= 1) {
|
|
16961
|
-
const tokenWidth = terminalCellWidth(tokens[index]);
|
|
16962
|
-
if (keptWidth + tokenWidth > Math.max(0, width - 1)) break;
|
|
16963
|
-
kept = tokens[index] + kept;
|
|
16964
|
-
keptWidth += tokenWidth;
|
|
16965
|
-
}
|
|
16966
|
-
return `\u2026${kept}`;
|
|
16967
|
-
}
|
|
16968
|
-
function visiblePathTail(path57, width) {
|
|
16969
|
-
if (terminalCellWidth(path57) <= width) return path57;
|
|
16970
|
-
const parts = path57.split(/(?=[\\/])/);
|
|
16971
|
-
let kept = "";
|
|
16972
|
-
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
16973
|
-
if (terminalCellWidth(`\u2026${parts[index]}${kept}`) > width) break;
|
|
16974
|
-
kept = `${parts[index]}${kept}`;
|
|
16975
|
-
}
|
|
16976
|
-
return kept ? `\u2026${kept}` : visibleSlice(`\u2026${parts[parts.length - 1]}`, width);
|
|
16977
|
-
}
|
|
16978
|
-
function isWideCodePoint(code) {
|
|
16979
|
-
if (code < 4352) return false;
|
|
16980
|
-
return code <= 4447 || code === 9001 || code === 9002 || code >= 11904 && code <= 42191 || code >= 44032 && code <= 55203 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65135 || code >= 65281 && code <= 65376 || code >= 65504 && code <= 65510 || code >= 127462 && code <= 127487 || code >= 127744 && code <= 129791 || code >= 131072 && code <= 262141;
|
|
16981
|
-
}
|
|
16982
|
-
function displayTokens(value) {
|
|
16983
|
-
const tokens = [];
|
|
16984
|
-
const pushText = (text7) => {
|
|
16985
|
-
for (const { segment } of graphemes().segment(text7)) tokens.push(segment);
|
|
16986
|
-
};
|
|
16987
|
-
let consumed = 0;
|
|
16988
|
-
for (const match of value.matchAll(ZERO_WIDTH_SEQUENCES)) {
|
|
16989
|
-
const start2 = match.index;
|
|
16990
|
-
if (start2 > consumed) pushText(value.slice(consumed, start2));
|
|
16991
|
-
tokens.push(match[0]);
|
|
16992
|
-
consumed = start2 + match[0].length;
|
|
16993
|
-
}
|
|
16994
|
-
if (consumed < value.length) pushText(value.slice(consumed));
|
|
16995
|
-
return tokens;
|
|
16996
|
-
}
|
|
16997
|
-
function oneCell(code) {
|
|
16998
|
-
let known = ONE_CELL[code];
|
|
16999
|
-
if (!known) {
|
|
17000
|
-
const character = String.fromCharCode(code);
|
|
17001
|
-
const joins = code >= 55296 && code <= 57343 || code >= 4352 && code <= 4607 || code >= 43360 && code <= 43391 || code >= 55216 && code <= 55295 || code >= 1536 && code <= 1541 || code === 1757 || code === 1807 || code === 2192 || code === 2193 || code === 2274 || code === 3406 || code === 3635 || code === 3763 || code === 8205;
|
|
17002
|
-
known = joins || isWideCodePoint(code) || MARK.test(character) || GRAPHEME_EXTEND.test(character) || EMOJI_PRESENTATION.test(character) ? 2 : 1;
|
|
17003
|
-
ONE_CELL[code] = known;
|
|
17004
|
-
}
|
|
17005
|
-
return known === 1;
|
|
17006
|
-
}
|
|
17007
|
-
function simpleWidth(value) {
|
|
17008
|
-
let width = 0;
|
|
17009
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
17010
|
-
const code = value.charCodeAt(index);
|
|
17011
|
-
if (code >= 32 && code < 127) width += 1;
|
|
17012
|
-
else if (code === 27) {
|
|
17013
|
-
const next = value.charCodeAt(index + 1);
|
|
17014
|
-
let end = index + 2;
|
|
17015
|
-
if (next === 91) {
|
|
17016
|
-
while (end < value.length && (value.charCodeAt(end) >= 48 && value.charCodeAt(end) <= 57 || value.charCodeAt(end) === 59)) end += 1;
|
|
17017
|
-
if (value.charCodeAt(end) !== 109) return -1;
|
|
17018
|
-
} else if (next === 93 && value.startsWith("8;", end)) {
|
|
17019
|
-
while (end < value.length && !"\x07\x1B\n".includes(value[end])) end += 1;
|
|
17020
|
-
if (value.charCodeAt(end) !== 27 || value.charCodeAt(end + 1) !== 92) return -1;
|
|
17021
|
-
end += 1;
|
|
17022
|
-
} else return -1;
|
|
17023
|
-
index = end;
|
|
17024
|
-
} else if (code === 9) width += TAB_WIDTH - width % TAB_WIDTH;
|
|
17025
|
-
else if (code < 160) continue;
|
|
17026
|
-
else if (oneCell(code)) width += 1;
|
|
17027
|
-
else return -1;
|
|
17028
|
-
}
|
|
17029
|
-
return width;
|
|
17030
|
-
}
|
|
17031
|
-
function terminalCellWidth(value) {
|
|
17032
|
-
const simple = simpleWidth(value);
|
|
17033
|
-
if (simple >= 0) return simple;
|
|
17034
|
-
const plain3 = value.includes("\x1B") ? value.replace(ZERO_WIDTH_SEQUENCES, "") : value;
|
|
17035
|
-
let width = 0;
|
|
17036
|
-
for (const { segment } of graphemes().segment(plain3)) {
|
|
17037
|
-
if (segment === " ") {
|
|
17038
|
-
width += TAB_WIDTH - width % TAB_WIDTH;
|
|
17039
|
-
continue;
|
|
17040
|
-
}
|
|
17041
|
-
if (CONTROLS.test(segment)) continue;
|
|
17042
|
-
const code = segment.codePointAt(0) ?? 0;
|
|
17043
|
-
if (segment.length === 1 && code < 127) {
|
|
17044
|
-
width += 1;
|
|
17045
|
-
continue;
|
|
17046
|
-
}
|
|
17047
|
-
const base = String.fromCodePoint(code);
|
|
17048
|
-
if (MARK.test(base)) continue;
|
|
17049
|
-
const wide = segment.includes("\uFE0E") ? isWideCodePoint(code) && code >= 126976 : isWideCodePoint(code) || EMOJI_PRESENTATION.test(base) || segment.includes("\uFE0F") && EMOJI.test(base) && !KEYCAP_BASE.test(base) || segment.includes("\u20E3");
|
|
17050
|
-
width += wide ? 2 : 1;
|
|
17051
|
-
}
|
|
17052
|
-
return width;
|
|
17053
|
-
}
|
|
17054
|
-
function previousCharacterIndex(value, index) {
|
|
17055
|
-
if (index <= 0) return 0;
|
|
17056
|
-
const start2 = Math.max(0, index - CLUSTER_WINDOW);
|
|
17057
|
-
let boundary = 0;
|
|
17058
|
-
for (const { index: offset } of graphemes().segment(value.slice(start2, index))) boundary = offset;
|
|
17059
|
-
return start2 + boundary;
|
|
17060
|
-
}
|
|
17061
|
-
function nextCharacterIndex(value, index) {
|
|
17062
|
-
if (index >= value.length) return value.length;
|
|
17063
|
-
const [first2] = graphemes().segment(value.slice(index, index + CLUSTER_WINDOW));
|
|
17064
|
-
return index + (first2 ? first2.segment.length : 1);
|
|
17065
|
-
}
|
|
17066
|
-
var OSC8_SEQUENCE, ZERO_WIDTH_SEQUENCES, TAB_WIDTH, graphemeSegmenter, graphemes, CLUSTER_WINDOW, CONTROLS, MARK, EMOJI_PRESENTATION, EMOJI, KEYCAP_BASE, GRAPHEME_EXTEND, ONE_CELL;
|
|
17067
|
-
var init_width = __esm({
|
|
17068
|
-
"src/tui/render/width.ts"() {
|
|
17069
|
-
"use strict";
|
|
17070
|
-
init_hyperlinks();
|
|
17071
|
-
OSC8_SEQUENCE = /^\u001b\]8;[^\u0007\u001b\n]*\u001b\\$/;
|
|
17072
|
-
ZERO_WIDTH_SEQUENCES = /\u001b\[[0-9;]*m|\u001b\]8;[^\u0007\u001b\n]*\u001b\\/g;
|
|
17073
|
-
TAB_WIDTH = 4;
|
|
17074
|
-
graphemes = () => graphemeSegmenter ??= new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
17075
|
-
CLUSTER_WINDOW = 32;
|
|
17076
|
-
CONTROLS = /^[\u0000-\u001f\u007f-\u009f]+$/;
|
|
17077
|
-
MARK = new RegExp("\\p{Mark}", "u");
|
|
17078
|
-
EMOJI_PRESENTATION = new RegExp("\\p{Emoji_Presentation}", "u");
|
|
17079
|
-
EMOJI = new RegExp("\\p{Emoji}", "u");
|
|
17080
|
-
KEYCAP_BASE = /^[0-9#*]$/;
|
|
17081
|
-
GRAPHEME_EXTEND = new RegExp("\\p{Grapheme_Extend}", "u");
|
|
17082
|
-
ONE_CELL = new Uint8Array(65536);
|
|
17083
|
-
}
|
|
17084
|
-
});
|
|
17085
|
-
|
|
17086
17209
|
// src/harness/protocol/tools.ts
|
|
17087
17210
|
function formatToolRow(name, detail, category) {
|
|
17088
17211
|
const lines4 = detail?.trim().split(/\r?\n/) ?? [];
|
|
@@ -18384,6 +18507,65 @@ var init_version_memo = __esm({
|
|
|
18384
18507
|
}
|
|
18385
18508
|
});
|
|
18386
18509
|
|
|
18510
|
+
// src/runtime/installer-env.ts
|
|
18511
|
+
function installerEnv(env3, extra = {}) {
|
|
18512
|
+
const kept = {};
|
|
18513
|
+
for (const [name, value] of Object.entries(env3)) {
|
|
18514
|
+
if (value === void 0) continue;
|
|
18515
|
+
if (KEEP.has(name) || KEEP.has(name.toUpperCase()) || /^LC_/.test(name) || /^XDG_/.test(name)) kept[name] = value;
|
|
18516
|
+
}
|
|
18517
|
+
return { ...kept, ...extra };
|
|
18518
|
+
}
|
|
18519
|
+
var KEEP;
|
|
18520
|
+
var init_installer_env = __esm({
|
|
18521
|
+
"src/runtime/installer-env.ts"() {
|
|
18522
|
+
"use strict";
|
|
18523
|
+
KEEP = /* @__PURE__ */ new Set([
|
|
18524
|
+
"PATH",
|
|
18525
|
+
"HOME",
|
|
18526
|
+
"USER",
|
|
18527
|
+
"LOGNAME",
|
|
18528
|
+
"SHELL",
|
|
18529
|
+
"TERM",
|
|
18530
|
+
"LANG",
|
|
18531
|
+
"TMPDIR",
|
|
18532
|
+
"TMP",
|
|
18533
|
+
"TEMP",
|
|
18534
|
+
"TZ",
|
|
18535
|
+
"HTTP_PROXY",
|
|
18536
|
+
"HTTPS_PROXY",
|
|
18537
|
+
"NO_PROXY",
|
|
18538
|
+
"ALL_PROXY",
|
|
18539
|
+
"http_proxy",
|
|
18540
|
+
"https_proxy",
|
|
18541
|
+
"no_proxy",
|
|
18542
|
+
"all_proxy",
|
|
18543
|
+
"SSL_CERT_FILE",
|
|
18544
|
+
"SSL_CERT_DIR",
|
|
18545
|
+
"NODE_EXTRA_CA_CERTS",
|
|
18546
|
+
"REQUESTS_CA_BUNDLE",
|
|
18547
|
+
"CURL_CA_BUNDLE",
|
|
18548
|
+
// Windows: the profile, system and program locations an installer resolves paths from.
|
|
18549
|
+
"USERPROFILE",
|
|
18550
|
+
"APPDATA",
|
|
18551
|
+
"LOCALAPPDATA",
|
|
18552
|
+
"PROGRAMDATA",
|
|
18553
|
+
"PROGRAMFILES",
|
|
18554
|
+
"PROGRAMFILES(X86)",
|
|
18555
|
+
"SYSTEMROOT",
|
|
18556
|
+
"WINDIR",
|
|
18557
|
+
"COMSPEC",
|
|
18558
|
+
"PATHEXT",
|
|
18559
|
+
"HOMEDRIVE",
|
|
18560
|
+
"HOMEPATH",
|
|
18561
|
+
"USERNAME",
|
|
18562
|
+
"OS",
|
|
18563
|
+
"PROCESSOR_ARCHITECTURE",
|
|
18564
|
+
"NUMBER_OF_PROCESSORS"
|
|
18565
|
+
]);
|
|
18566
|
+
}
|
|
18567
|
+
});
|
|
18568
|
+
|
|
18387
18569
|
// src/tui/active-terminal.ts
|
|
18388
18570
|
var TERMINAL;
|
|
18389
18571
|
var init_active_terminal = __esm({
|
|
@@ -18804,15 +18986,15 @@ var init_activity_view = __esm({
|
|
|
18804
18986
|
|
|
18805
18987
|
// src/tui/capabilities.ts
|
|
18806
18988
|
import { stdin as input3, stdout as output4 } from "node:process";
|
|
18807
|
-
function
|
|
18989
|
+
function environmentFlag2(...values) {
|
|
18808
18990
|
const value = values.find((candidate) => candidate !== void 0 && candidate !== "");
|
|
18809
18991
|
return value !== void 0 && value !== "0" && value.toLowerCase() !== "false";
|
|
18810
18992
|
}
|
|
18811
18993
|
function screenReaderMode(environment = process.env) {
|
|
18812
|
-
return
|
|
18994
|
+
return environmentFlag2(environment.CLIKCODE_SCREEN_READER);
|
|
18813
18995
|
}
|
|
18814
18996
|
function reducedMotion(environment = process.env) {
|
|
18815
|
-
return
|
|
18997
|
+
return environmentFlag2(environment.CLIKCODE_REDUCED_MOTION, environment.NO_MOTION);
|
|
18816
18998
|
}
|
|
18817
18999
|
function terminalUiSupported(stdinTty = Boolean(input3.isTTY), stdoutTty = Boolean(output4.isTTY), environment = process.env) {
|
|
18818
19000
|
if (environment.CLIKCODE_TUI?.trim().toLowerCase() === "classic") return false;
|
|
@@ -19179,7 +19361,7 @@ async function runInstallerScript(step) {
|
|
|
19179
19361
|
try {
|
|
19180
19362
|
const script = join13(directory2, windows2 ? "install.ps1" : "install.sh");
|
|
19181
19363
|
await downloadInstaller(step.url, script);
|
|
19182
|
-
const env3 =
|
|
19364
|
+
const env3 = installerEnv(process.env, step.env ?? {});
|
|
19183
19365
|
let command;
|
|
19184
19366
|
let args;
|
|
19185
19367
|
if (windows2) {
|
|
@@ -19274,6 +19456,7 @@ var processReporter, inFlight, INSTALL_TIMEOUT_MS, UV_INSTALLER, LOCK_STALE_MS,
|
|
|
19274
19456
|
var init_install = __esm({
|
|
19275
19457
|
"src/harness/transport/native/install.ts"() {
|
|
19276
19458
|
"use strict";
|
|
19459
|
+
init_installer_env();
|
|
19277
19460
|
init_lifecycle_log();
|
|
19278
19461
|
init_paths();
|
|
19279
19462
|
init_active_terminal();
|
|
@@ -25643,53 +25826,6 @@ var init_memoize = __esm({
|
|
|
25643
25826
|
}
|
|
25644
25827
|
});
|
|
25645
25828
|
|
|
25646
|
-
// src/tui/render/text.ts
|
|
25647
|
-
function expandTabs(value, tabWidth = TAB_WIDTH) {
|
|
25648
|
-
if (!value.includes(" ")) return value;
|
|
25649
|
-
return value.split("\n").map((line3) => {
|
|
25650
|
-
if (!line3.includes(" ")) return line3;
|
|
25651
|
-
let column = 0;
|
|
25652
|
-
let expanded = "";
|
|
25653
|
-
for (const [index, part] of line3.split(" ").entries()) {
|
|
25654
|
-
if (index > 0) {
|
|
25655
|
-
const fill2 = tabWidth - column % tabWidth;
|
|
25656
|
-
expanded += " ".repeat(fill2);
|
|
25657
|
-
column += fill2;
|
|
25658
|
-
}
|
|
25659
|
-
expanded += part;
|
|
25660
|
-
column += terminalCellWidth(part);
|
|
25661
|
-
}
|
|
25662
|
-
return expanded;
|
|
25663
|
-
}).join("\n");
|
|
25664
|
-
}
|
|
25665
|
-
function sanitizeTerminalText(value, options2 = {}) {
|
|
25666
|
-
const clean2 = options2.keepSgr ? !UNSAFE_IN_STYLED_TEXT.test(value) : !NEEDS_SANITIZING.test(value);
|
|
25667
|
-
if (clean2 && !(options2.singleLine && value.includes("\n"))) return value;
|
|
25668
|
-
let text7 = value.replace(/\r\n?/g, "\n");
|
|
25669
|
-
text7 = text7.replace(ESCAPE_SEQUENCE, (sequence) => options2.keepSgr && (SGR_SEQUENCE.test(sequence) || OSC8_SEQUENCE.test(sequence)) ? sequence : "");
|
|
25670
|
-
text7 = text7.replace(CONTROL_CHARACTERS, (character) => character === "\x1B" && options2.keepSgr ? character : "");
|
|
25671
|
-
text7 = expandTabs(text7, options2.tabWidth ?? TAB_WIDTH);
|
|
25672
|
-
return options2.singleLine ? text7.replace(/\n/g, " ") : text7;
|
|
25673
|
-
}
|
|
25674
|
-
var ESCAPE_SEQUENCE, SGR_SEQUENCE, SAFE_LINK, NEEDS_SANITIZING, UNSAFE_IN_STYLED_TEXT, CONTROL_CHARACTERS;
|
|
25675
|
-
var init_text = __esm({
|
|
25676
|
-
"src/tui/render/text.ts"() {
|
|
25677
|
-
"use strict";
|
|
25678
|
-
init_width();
|
|
25679
|
-
ESCAPE_SEQUENCE = new RegExp([
|
|
25680
|
-
"\\u001b\\][^\\u0007\\u001b\\n]*(?:\\u0007|\\u001b\\\\)?",
|
|
25681
|
-
"\\u001b[PX^_][^\\u001b\\n]*(?:\\u001b\\\\)?",
|
|
25682
|
-
"(?:\\u001b\\[|\\u009b)[0-?]*[ -/]*[@-~]?",
|
|
25683
|
-
"\\u001b[ -/]*[0-~]?"
|
|
25684
|
-
].join("|"), "g");
|
|
25685
|
-
SGR_SEQUENCE = /^\u001b\[[0-9;]*m$/;
|
|
25686
|
-
SAFE_LINK = /^(?:https?:\/\/|mailto:)[^\s\u0000-\u001f\u007f-\u009f]+$/i;
|
|
25687
|
-
NEEDS_SANITIZING = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f\t]/;
|
|
25688
|
-
UNSAFE_IN_STYLED_TEXT = /[\u0000-\u0009\u000b-\u001a\u001c-\u001f\u007f-\u009f]|\u001b(?!\[[0-9;]*m|\]8;[^\u0007\u001b\n]*\u001b\\)/;
|
|
25689
|
-
CONTROL_CHARACTERS = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g;
|
|
25690
|
-
}
|
|
25691
|
-
});
|
|
25692
|
-
|
|
25693
25829
|
// src/tui/render/wrap.ts
|
|
25694
25830
|
function wrapCodeLine(value, width) {
|
|
25695
25831
|
const safeWidth = Math.max(1, width);
|
|
@@ -26264,9 +26400,9 @@ function enqueueSessionTurn(session2, submission, now) {
|
|
|
26264
26400
|
session2.updatedAt = now;
|
|
26265
26401
|
}
|
|
26266
26402
|
function consumeSessionTurn(session2, id) {
|
|
26267
|
-
const
|
|
26268
|
-
const next =
|
|
26269
|
-
if (next.length ===
|
|
26403
|
+
const queued2 = session2.queuedTurns ?? [];
|
|
26404
|
+
const next = queued2.filter((item) => item.id !== id);
|
|
26405
|
+
if (next.length === queued2.length) return false;
|
|
26270
26406
|
if (next.length) session2.queuedTurns = next;
|
|
26271
26407
|
else delete session2.queuedTurns;
|
|
26272
26408
|
return true;
|
|
@@ -28842,20 +28978,20 @@ async function claudeSessionTitle(path57) {
|
|
|
28842
28978
|
for (const line3 of prefix.split("\n")) {
|
|
28843
28979
|
if (!line3.trim()) continue;
|
|
28844
28980
|
let text7;
|
|
28845
|
-
let
|
|
28981
|
+
let queued2 = false;
|
|
28846
28982
|
try {
|
|
28847
28983
|
const record6 = JSON.parse(line3);
|
|
28848
|
-
|
|
28849
|
-
if (record6.type !== "user" && !
|
|
28850
|
-
text7 = visibleNativeUserText(
|
|
28984
|
+
queued2 = record6.type === "queue-operation" && record6.operation === "enqueue";
|
|
28985
|
+
if (record6.type !== "user" && !queued2) continue;
|
|
28986
|
+
text7 = visibleNativeUserText(queued2 ? typeof record6.content === "string" ? record6.content : "" : extractMessageText(record6.message?.content));
|
|
28851
28987
|
} catch {
|
|
28852
|
-
|
|
28853
|
-
if (!
|
|
28988
|
+
queued2 = /"type"\s*:\s*"queue-operation"/.test(line3) && line3.includes('"enqueue"');
|
|
28989
|
+
if (!queued2 && !/"type"\s*:\s*"user"|"role"\s*:\s*"user"/.test(line3)) continue;
|
|
28854
28990
|
text7 = visibleNativeUserText(leadingText(line3) ?? "");
|
|
28855
28991
|
}
|
|
28856
28992
|
if (!text7) continue;
|
|
28857
28993
|
opening ??= text7;
|
|
28858
|
-
if (!
|
|
28994
|
+
if (!queued2) {
|
|
28859
28995
|
first2 = text7;
|
|
28860
28996
|
break;
|
|
28861
28997
|
}
|
|
@@ -34420,7 +34556,12 @@ function adoptHandedOverDraft() {
|
|
|
34420
34556
|
} catch {
|
|
34421
34557
|
}
|
|
34422
34558
|
}
|
|
34423
|
-
|
|
34559
|
+
function adoptHandedOverTyped() {
|
|
34560
|
+
const text7 = process.env[REEXEC_TYPED_ENV];
|
|
34561
|
+
delete process.env[REEXEC_TYPED_ENV];
|
|
34562
|
+
return text7 || void 0;
|
|
34563
|
+
}
|
|
34564
|
+
var byHome, forced, pinned, REEXEC_DRAFT_ENV, REEXEC_TYPED_ENV;
|
|
34424
34565
|
var init_ephemeral = __esm({
|
|
34425
34566
|
"src/session/ephemeral.ts"() {
|
|
34426
34567
|
"use strict";
|
|
@@ -34430,6 +34571,7 @@ var init_ephemeral = __esm({
|
|
|
34430
34571
|
forced = /* @__PURE__ */ new Set();
|
|
34431
34572
|
pinned = /* @__PURE__ */ new Set();
|
|
34432
34573
|
REEXEC_DRAFT_ENV = "CLIKCODE_REEXEC_DRAFT";
|
|
34574
|
+
REEXEC_TYPED_ENV = "CLIKCODE_REEXEC_TYPED";
|
|
34433
34575
|
}
|
|
34434
34576
|
});
|
|
34435
34577
|
|
|
@@ -44522,7 +44664,7 @@ var init_route_models = __esm({
|
|
|
44522
44664
|
});
|
|
44523
44665
|
|
|
44524
44666
|
// src/agent/sandbox.ts
|
|
44525
|
-
import { spawnSync
|
|
44667
|
+
import { spawnSync } from "node:child_process";
|
|
44526
44668
|
import { accessSync, constants as constants5, existsSync as existsSync8, realpathSync } from "node:fs";
|
|
44527
44669
|
import os4 from "node:os";
|
|
44528
44670
|
import path12 from "node:path";
|
|
@@ -44536,7 +44678,7 @@ function parseSandboxMode(value) {
|
|
|
44536
44678
|
return void 0;
|
|
44537
44679
|
}
|
|
44538
44680
|
function sandboxModeText(mode) {
|
|
44539
|
-
return mode === "workspace" ? "Sandbox on \xB7 shell commands write only the workspace, the temp dir and tool caches; they read everything and keep the network" : "Sandbox off \xB7 shell commands run with your full permissions";
|
|
44681
|
+
return mode === "workspace" ? "Sandbox on \xB7 shell commands write only the workspace, the temp dir and tool caches; they read everything except ClikCode's stored sign-ins and secrets, and keep the network" : "Sandbox off \xB7 shell commands run with your full permissions";
|
|
44540
44682
|
}
|
|
44541
44683
|
function sandboxWritableDirs(input11) {
|
|
44542
44684
|
const dirs = [
|
|
@@ -44553,10 +44695,16 @@ function sandboxWritableDirs(input11) {
|
|
|
44553
44695
|
];
|
|
44554
44696
|
return [...new Set(dirs.map((dir2) => path12.resolve(dir2)))];
|
|
44555
44697
|
}
|
|
44698
|
+
function sandboxHiddenPaths(stateDir) {
|
|
44699
|
+
return {
|
|
44700
|
+
dirs: ["profiles", "computer", "mcp-oauth"].map((name) => path12.join(stateDir, name)),
|
|
44701
|
+
files: ["api-key", "secrets.json"].map((name) => path12.join(stateDir, name))
|
|
44702
|
+
};
|
|
44703
|
+
}
|
|
44556
44704
|
function maskedDirs(request3) {
|
|
44557
44705
|
return request3.exists?.(SSH_CONFIG_DROPINS) ? [SSH_CONFIG_DROPINS] : [];
|
|
44558
44706
|
}
|
|
44559
|
-
function bwrapInvocation(command, writable, cwd, masked = [], readOnly = []) {
|
|
44707
|
+
function bwrapInvocation(command, writable, cwd, masked = [], readOnly = [], hidden3 = { dirs: [], files: [] }) {
|
|
44560
44708
|
return {
|
|
44561
44709
|
file: "bwrap",
|
|
44562
44710
|
args: [
|
|
@@ -44570,6 +44718,9 @@ function bwrapInvocation(command, writable, cwd, masked = [], readOnly = []) {
|
|
|
44570
44718
|
...masked.flatMap((dir2) => ["--tmpfs", dir2]),
|
|
44571
44719
|
...writable.flatMap((dir2) => ["--bind-try", dir2, dir2]),
|
|
44572
44720
|
...readOnly.flatMap((entry2) => ["--ro-bind-try", entry2, entry2]),
|
|
44721
|
+
// Last, so a writable or read-only bind above can never put a secret back in view.
|
|
44722
|
+
...hidden3.dirs.flatMap((dir2) => ["--tmpfs", dir2]),
|
|
44723
|
+
...hidden3.files.flatMap((file6) => ["--ro-bind", "/dev/null", file6]),
|
|
44573
44724
|
"--die-with-parent",
|
|
44574
44725
|
"--chdir",
|
|
44575
44726
|
cwd,
|
|
@@ -44579,27 +44730,36 @@ function bwrapInvocation(command, writable, cwd, masked = [], readOnly = []) {
|
|
|
44579
44730
|
]
|
|
44580
44731
|
};
|
|
44581
44732
|
}
|
|
44582
|
-
function seatbeltProfile(writableCount) {
|
|
44733
|
+
function seatbeltProfile(writableCount, hiddenDirs = 0, hiddenFiles = 0) {
|
|
44583
44734
|
const allowed = Array.from({ length: writableCount }, (_, index) => ` (subpath (param "W${index}"))`).join("");
|
|
44735
|
+
const dirs = Array.from({ length: hiddenDirs }, (_, index) => ` (subpath (param "HD${index}"))`).join("");
|
|
44736
|
+
const files = Array.from({ length: hiddenFiles }, (_, index) => ` (literal (param "HF${index}"))`).join("");
|
|
44737
|
+
const hide = hiddenDirs + hiddenFiles ? `(deny file-read* file-write*${dirs}${files})
|
|
44738
|
+
` : "";
|
|
44584
44739
|
return `(version 1)
|
|
44585
44740
|
(allow default)
|
|
44586
44741
|
(deny file-write*)
|
|
44587
44742
|
(allow file-write* (subpath "/dev")${allowed})
|
|
44588
|
-
`;
|
|
44743
|
+
${hide}`;
|
|
44589
44744
|
}
|
|
44590
|
-
function sandboxExecInvocation(command, writable) {
|
|
44745
|
+
function sandboxExecInvocation(command, writable, hidden3 = { dirs: [], files: [] }) {
|
|
44591
44746
|
return {
|
|
44592
44747
|
file: "/usr/bin/sandbox-exec",
|
|
44593
|
-
args: ["-p", seatbeltProfile(writable.length), ...writable.flatMap((dir2, index) => ["-D", `W${index}=${dir2}`]), command.file, ...command.args]
|
|
44748
|
+
args: ["-p", seatbeltProfile(writable.length, hidden3.dirs.length, hidden3.files.length), ...writable.flatMap((dir2, index) => ["-D", `W${index}=${dir2}`]), ...hidden3.dirs.flatMap((dir2, index) => ["-D", `HD${index}=${dir2}`]), ...hidden3.files.flatMap((file6, index) => ["-D", `HF${index}=${file6}`]), command.file, ...command.args]
|
|
44594
44749
|
};
|
|
44595
44750
|
}
|
|
44751
|
+
function presentHidden(request3) {
|
|
44752
|
+
const hidden3 = request3.hidden ?? { dirs: [], files: [] };
|
|
44753
|
+
const exists4 = request3.exists ?? (() => false);
|
|
44754
|
+
return { dirs: hidden3.dirs.filter(exists4), files: hidden3.files.filter(exists4) };
|
|
44755
|
+
}
|
|
44596
44756
|
function wrapForSandbox(request3) {
|
|
44597
44757
|
if (request3.mode !== "workspace") return { sandboxed: false, invocation: request3.command };
|
|
44598
44758
|
if (request3.platform === "linux") {
|
|
44599
|
-
return request3.available("bwrap") ? { sandboxed: true, invocation: bwrapInvocation(request3.command, request3.writable, request3.cwd, maskedDirs(request3), request3.readOnly) } : { sandboxed: false, invocation: request3.command, missing: "bubblewrap (bwrap)" };
|
|
44759
|
+
return request3.available("bwrap") ? { sandboxed: true, invocation: bwrapInvocation(request3.command, request3.writable, request3.cwd, maskedDirs(request3), request3.readOnly, presentHidden(request3)) } : { sandboxed: false, invocation: request3.command, missing: "bubblewrap (bwrap)" };
|
|
44600
44760
|
}
|
|
44601
44761
|
if (request3.platform === "darwin") {
|
|
44602
|
-
return request3.available("/usr/bin/sandbox-exec") ? { sandboxed: true, invocation: sandboxExecInvocation(request3.command, request3.writable) } : { sandboxed: false, invocation: request3.command, missing: "sandbox-exec" };
|
|
44762
|
+
return request3.available("/usr/bin/sandbox-exec") ? { sandboxed: true, invocation: sandboxExecInvocation(request3.command, request3.writable, presentHidden(request3)) } : { sandboxed: false, invocation: request3.command, missing: "sandbox-exec" };
|
|
44603
44763
|
}
|
|
44604
44764
|
return { sandboxed: false, invocation: request3.command, missing: `a sandbox for ${request3.platform}` };
|
|
44605
44765
|
}
|
|
@@ -44632,7 +44792,7 @@ function onPath(binary) {
|
|
|
44632
44792
|
function sandboxAvailable(binary) {
|
|
44633
44793
|
if (!onPath(binary)) return false;
|
|
44634
44794
|
if (binary !== "bwrap") return true;
|
|
44635
|
-
bwrapRuns ??=
|
|
44795
|
+
bwrapRuns ??= spawnSync("bwrap", ["--ro-bind", "/", "/", "--dev", "/dev", "--proc", "/proc", "--", "/bin/true"], { stdio: "ignore", timeout: 5e3 }).status === 0;
|
|
44636
44796
|
return bwrapRuns;
|
|
44637
44797
|
}
|
|
44638
44798
|
function realOrSame(dir2) {
|
|
@@ -44649,14 +44809,14 @@ function realOrSame(dir2) {
|
|
|
44649
44809
|
function platformDirs() {
|
|
44650
44810
|
if (process.platform !== "darwin") return [];
|
|
44651
44811
|
darwinDirs ??= ["DARWIN_USER_TEMP_DIR", "DARWIN_USER_CACHE_DIR"].flatMap((name) => {
|
|
44652
|
-
const result =
|
|
44812
|
+
const result = spawnSync("/usr/bin/getconf", [name], { encoding: "utf8", timeout: 5e3 });
|
|
44653
44813
|
const dir2 = result.status === 0 ? result.stdout.trim() : "";
|
|
44654
44814
|
return dir2 && path12.isAbsolute(dir2) ? [dir2] : [];
|
|
44655
44815
|
});
|
|
44656
44816
|
return darwinDirs;
|
|
44657
44817
|
}
|
|
44658
44818
|
function linkedWorktreeGit(cwd) {
|
|
44659
|
-
const result =
|
|
44819
|
+
const result = spawnSync("git", ["rev-parse", "--path-format=absolute", "--git-dir", "--git-common-dir"], { cwd, encoding: "utf8", timeout: 5e3 });
|
|
44660
44820
|
if (result.status !== 0) return { writable: [], readOnly: [] };
|
|
44661
44821
|
const [gitDir, common2] = result.stdout.trim().split("\n");
|
|
44662
44822
|
if (!gitDir || !common2 || gitDir === common2) return { writable: [], readOnly: [] };
|
|
@@ -44666,12 +44826,13 @@ function sandboxCommand(mode, command, scope) {
|
|
|
44666
44826
|
const git3 = mode === "workspace" ? linkedWorktreeGit(scope.cwd) : { writable: [], readOnly: [] };
|
|
44667
44827
|
const named2 = sandboxWritableDirs({ ...scope, addDirs: [...scope.addDirs, ...git3.writable], tmpDir: os4.tmpdir(), env: process.env, platformDirs: platformDirs() });
|
|
44668
44828
|
const resolved = [...new Set(named2.map(realOrSame))];
|
|
44669
|
-
return { ...wrapForSandbox({ mode, platform: process.platform, command, writable: resolved, cwd: scope.cwd, available: sandboxAvailable, exists: existsSync8, readOnly: git3.readOnly.map(realOrSame) }), writable: [.../* @__PURE__ */ new Set([...resolved, ...named2])] };
|
|
44829
|
+
return { ...wrapForSandbox({ mode, platform: process.platform, command, writable: resolved, cwd: scope.cwd, available: sandboxAvailable, exists: existsSync8, readOnly: git3.readOnly.map(realOrSame), hidden: sandboxHiddenPaths(realOrSame(stateDirectory())) }), writable: [.../* @__PURE__ */ new Set([...resolved, ...named2])] };
|
|
44670
44830
|
}
|
|
44671
44831
|
var HOME_CACHE_DIRS, CACHE_ENV_VARS, SSH_CONFIG_DROPINS, SANDBOX_DENIAL_HINT, DENIAL, PATHS, bwrapRuns, darwinDirs;
|
|
44672
44832
|
var init_sandbox = __esm({
|
|
44673
44833
|
"src/agent/sandbox.ts"() {
|
|
44674
44834
|
"use strict";
|
|
44835
|
+
init_paths();
|
|
44675
44836
|
HOME_CACHE_DIRS = [
|
|
44676
44837
|
".cache",
|
|
44677
44838
|
".npm",
|
|
@@ -47355,35 +47516,6 @@ var init_pending_prompt = __esm({
|
|
|
47355
47516
|
}
|
|
47356
47517
|
});
|
|
47357
47518
|
|
|
47358
|
-
// src/tui/keys.ts
|
|
47359
|
-
function environmentFlag2(...values) {
|
|
47360
|
-
return values.some((value) => {
|
|
47361
|
-
const normalized = (value ?? "").trim().toLowerCase();
|
|
47362
|
-
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
47363
|
-
});
|
|
47364
|
-
}
|
|
47365
|
-
function pastedText(key3) {
|
|
47366
|
-
return key3.startsWith(PASTE_START) && key3.endsWith(PASTE_END) ? sanitizeTerminalText(key3.slice(PASTE_START.length, key3.length - PASTE_END.length)) : void 0;
|
|
47367
|
-
}
|
|
47368
|
-
function kittyKeyboardSafe(environment = process.env) {
|
|
47369
|
-
if (environmentFlag2(environment.CLIKCODE_NO_KITTY_KEYBOARD)) return false;
|
|
47370
|
-
if (environment.TMUX || environment.STY || /^(?:screen|tmux)/.test(environment.TERM ?? "")) return false;
|
|
47371
|
-
const program3 = (environment.TERM_PROGRAM ?? "").toLowerCase();
|
|
47372
|
-
return Boolean(environment.KITTY_WINDOW_ID || environment.GHOSTTY_RESOURCES_DIR || environment.WEZTERM_PANE || /^(?:xterm-kitty|xterm-ghostty|foot|alacritty|wezterm)/.test(environment.TERM ?? "") || program3 === "wezterm" || program3 === "ghostty" || program3 === "kitty");
|
|
47373
|
-
}
|
|
47374
|
-
var PASTE_START, PASTE_END, PUSH_KITTY_KEYBOARD, POP_KITTY_KEYBOARD, NEWLINE_KEY;
|
|
47375
|
-
var init_keys = __esm({
|
|
47376
|
-
"src/tui/keys.ts"() {
|
|
47377
|
-
"use strict";
|
|
47378
|
-
init_text();
|
|
47379
|
-
PASTE_START = "\x1B[200~";
|
|
47380
|
-
PASTE_END = "\x1B[201~";
|
|
47381
|
-
PUSH_KITTY_KEYBOARD = "\x1B[>1u";
|
|
47382
|
-
POP_KITTY_KEYBOARD = "\x1B[<u";
|
|
47383
|
-
NEWLINE_KEY = "\x1B\r";
|
|
47384
|
-
}
|
|
47385
|
-
});
|
|
47386
|
-
|
|
47387
47519
|
// src/tui/cursor-log.ts
|
|
47388
47520
|
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync5, renameSync as renameSync2, statSync as statSync6 } from "node:fs";
|
|
47389
47521
|
import { join as join87 } from "node:path";
|
|
@@ -47404,12 +47536,29 @@ function logCursorEvent(line3) {
|
|
|
47404
47536
|
if (cursorLogLines >= FRAME_LOG_LINES) return;
|
|
47405
47537
|
cursorLogLines += 1;
|
|
47406
47538
|
}
|
|
47539
|
+
queued.push(`[${(/* @__PURE__ */ new Date()).toISOString()}] pid ${process.pid} ${line3}
|
|
47540
|
+
`);
|
|
47541
|
+
scheduleFlush();
|
|
47542
|
+
}
|
|
47543
|
+
function scheduleFlush() {
|
|
47544
|
+
if (!exitHooked2) {
|
|
47545
|
+
exitHooked2 = true;
|
|
47546
|
+
process.once("exit", flushCursorLog);
|
|
47547
|
+
}
|
|
47548
|
+
if (flushTimer) return;
|
|
47549
|
+
flushTimer = setTimeout(flushCursorLog, FLUSH_MS);
|
|
47550
|
+
flushTimer.unref();
|
|
47551
|
+
}
|
|
47552
|
+
function flushCursorLog() {
|
|
47553
|
+
if (flushTimer) clearTimeout(flushTimer);
|
|
47554
|
+
flushTimer = void 0;
|
|
47555
|
+
if (!queued.length) return;
|
|
47556
|
+
const text7 = queued.splice(0).join("");
|
|
47407
47557
|
try {
|
|
47408
47558
|
const dir2 = stateDirectory();
|
|
47409
47559
|
mkdirSync5(dir2, { recursive: true });
|
|
47410
47560
|
rotateIfLarge(join87(dir2, "cursor.log"));
|
|
47411
|
-
appendFileSync4(join87(dir2, "cursor.log"),
|
|
47412
|
-
`, { encoding: "utf8", mode: 384 });
|
|
47561
|
+
appendFileSync4(join87(dir2, "cursor.log"), text7, { encoding: "utf8", mode: 384 });
|
|
47413
47562
|
} catch {
|
|
47414
47563
|
}
|
|
47415
47564
|
}
|
|
@@ -47428,7 +47577,7 @@ function traceRawInput(chunk) {
|
|
|
47428
47577
|
} catch {
|
|
47429
47578
|
}
|
|
47430
47579
|
}
|
|
47431
|
-
var cursorLogLines, inputLogLines, FRAME_LOG_LINES, INPUT_LOG_LINES, ROTATE_BYTES2, ROTATE_CHECK_EVERY2, linesSinceCheck2, TRACE_LIMIT_BYTES, traceBytes, traceLast;
|
|
47580
|
+
var cursorLogLines, inputLogLines, FRAME_LOG_LINES, INPUT_LOG_LINES, ROTATE_BYTES2, ROTATE_CHECK_EVERY2, linesSinceCheck2, queued, FLUSH_MS, flushTimer, exitHooked2, TRACE_LIMIT_BYTES, traceBytes, traceLast;
|
|
47432
47581
|
var init_cursor_log = __esm({
|
|
47433
47582
|
"src/tui/cursor-log.ts"() {
|
|
47434
47583
|
"use strict";
|
|
@@ -47440,6 +47589,9 @@ var init_cursor_log = __esm({
|
|
|
47440
47589
|
ROTATE_BYTES2 = 5 * 1024 * 1024;
|
|
47441
47590
|
ROTATE_CHECK_EVERY2 = 200;
|
|
47442
47591
|
linesSinceCheck2 = ROTATE_CHECK_EVERY2;
|
|
47592
|
+
queued = [];
|
|
47593
|
+
FLUSH_MS = 1e3;
|
|
47594
|
+
exitHooked2 = false;
|
|
47443
47595
|
TRACE_LIMIT_BYTES = 256 * 1024;
|
|
47444
47596
|
traceBytes = 0;
|
|
47445
47597
|
traceLast = 0;
|
|
@@ -47500,11 +47652,16 @@ var init_probe = __esm({
|
|
|
47500
47652
|
|
|
47501
47653
|
// src/tui/modes.ts
|
|
47502
47654
|
import { stdin as input4 } from "node:process";
|
|
47503
|
-
function
|
|
47655
|
+
function mouseWanted(env3 = process.env) {
|
|
47656
|
+
return env3.CLIKCODE_MOUSE === "1" && !inlineHistoryMode(env3);
|
|
47657
|
+
}
|
|
47658
|
+
function sessionModesOn() {
|
|
47504
47659
|
terminalModes.bracketedPaste = true;
|
|
47505
|
-
terminalModes.wheelReporting = !SELECTION_MODE.active;
|
|
47506
|
-
const mouse = SELECTION_MODE.active ? "" :
|
|
47507
|
-
|
|
47660
|
+
terminalModes.wheelReporting = mouseWanted() && !SELECTION_MODE.active;
|
|
47661
|
+
const mouse = SELECTION_MODE.active ? "" : ENABLE_MOUSE_TRACKING();
|
|
47662
|
+
const scroll = mouseWanted() || inlineHistoryMode() ? "" : ALTERNATE_SCROLL_ON;
|
|
47663
|
+
terminalModes.alternateScroll = scroll !== "";
|
|
47664
|
+
return `${ENABLE_BRACKETED_PASTE}${mouse}${scroll}${FOCUS_REPORTING_ON}`;
|
|
47508
47665
|
}
|
|
47509
47666
|
function sessionModesOff(leavingAlternateScreen) {
|
|
47510
47667
|
terminalModes.bracketedPaste = false;
|
|
@@ -47540,7 +47697,7 @@ function enterInputModes() {
|
|
|
47540
47697
|
sequence += ENABLE_BRACKETED_PASTE;
|
|
47541
47698
|
terminalModes.bracketedPaste = true;
|
|
47542
47699
|
}
|
|
47543
|
-
if (!terminalModes.wheelReporting && !SELECTION_MODE.active) {
|
|
47700
|
+
if (!terminalModes.wheelReporting && !SELECTION_MODE.active && mouseWanted()) {
|
|
47544
47701
|
sequence += ENABLE_MOUSE_TRACKING();
|
|
47545
47702
|
terminalModes.wheelReporting = true;
|
|
47546
47703
|
}
|
|
@@ -47557,6 +47714,9 @@ function popReadModes() {
|
|
|
47557
47714
|
return POP_KITTY_KEYBOARD;
|
|
47558
47715
|
}
|
|
47559
47716
|
function setSelectionMode(active2) {
|
|
47717
|
+
if (!mouseWanted()) {
|
|
47718
|
+
return inlineHistoryMode() ? "The terminal's own selection is always on: select and copy as usual." : "The terminal's own selection is always on: select and copy as usual. PageUp, PageDown, Home, End and the arrows read the conversation back.";
|
|
47719
|
+
}
|
|
47560
47720
|
SELECTION_MODE.active = active2;
|
|
47561
47721
|
if (active2) {
|
|
47562
47722
|
queuedModes += MOUSE_MODES_OFF;
|
|
@@ -47564,11 +47724,10 @@ function setSelectionMode(active2) {
|
|
|
47564
47724
|
return "Selection mode on \u2014 select and copy with your terminal as usual. Swipe-scrolling is off until you run /select again.";
|
|
47565
47725
|
}
|
|
47566
47726
|
queuedModes += ENABLE_MOUSE_TRACKING();
|
|
47567
|
-
terminalModes.wheelReporting =
|
|
47568
|
-
if (inlineHistoryMode()) return "Selection mode off.";
|
|
47727
|
+
terminalModes.wheelReporting = true;
|
|
47569
47728
|
return "Selection mode off \u2014 swipe-scrolling is back.";
|
|
47570
47729
|
}
|
|
47571
|
-
var ENABLE_BRACKETED_PASTE, MOUSE_TRACKING_ON,
|
|
47730
|
+
var ENABLE_BRACKETED_PASTE, MOUSE_TRACKING_ON, ALTERNATE_SCROLL_ON, ENABLE_MOUSE_TRACKING, SELECTION_MODE, queuedModes, MOUSE_EVENT, LEGACY_MOUSE_PREFIX, LEGACY_MOUSE_EVENT, isMouseEvent, SWIPE_ROWS;
|
|
47572
47731
|
var init_modes = __esm({
|
|
47573
47732
|
"src/tui/modes.ts"() {
|
|
47574
47733
|
"use strict";
|
|
@@ -47578,10 +47737,9 @@ var init_modes = __esm({
|
|
|
47578
47737
|
init_cursor_log();
|
|
47579
47738
|
init_inline();
|
|
47580
47739
|
ENABLE_BRACKETED_PASTE = "\x1B[?2004h";
|
|
47581
|
-
MOUSE_TRACKING_ON = "\x1B[?1000h\x1B[?1002h\x1B[?1003h\x1B[?1006h";
|
|
47582
|
-
|
|
47583
|
-
ENABLE_MOUSE_TRACKING = () =>
|
|
47584
|
-
OPENING_MOUSE_TRACKING = () => inlineHistoryMode() ? "" : OPENING_MOUSE_TRACKING_ON;
|
|
47740
|
+
MOUSE_TRACKING_ON = "\x1B[?1000h\x1B[?1002h\x1B[?1003h\x1B[?1006l\x1B[?1006h";
|
|
47741
|
+
ALTERNATE_SCROLL_ON = "\x1B[?1007h";
|
|
47742
|
+
ENABLE_MOUSE_TRACKING = () => mouseWanted() ? MOUSE_TRACKING_ON : "";
|
|
47585
47743
|
SELECTION_MODE = { active: false };
|
|
47586
47744
|
queuedModes = "";
|
|
47587
47745
|
MOUSE_EVENT = /^\u001b\[<(\d+);\d+;\d+[Mm]$/;
|
|
@@ -47667,7 +47825,7 @@ function listenForTerminalKeys(onKey) {
|
|
|
47667
47825
|
const owner = {};
|
|
47668
47826
|
keyOwners.push(owner);
|
|
47669
47827
|
const decoder = new TerminalInputDecoder();
|
|
47670
|
-
let
|
|
47828
|
+
let flushTimer2;
|
|
47671
47829
|
const deliver = (keys) => {
|
|
47672
47830
|
keyBatchDepth += 1;
|
|
47673
47831
|
try {
|
|
@@ -47699,18 +47857,18 @@ function listenForTerminalKeys(onKey) {
|
|
|
47699
47857
|
};
|
|
47700
47858
|
const onData = (chunk) => {
|
|
47701
47859
|
if (keyOwners.at(-1) !== owner) {
|
|
47702
|
-
if (
|
|
47703
|
-
|
|
47860
|
+
if (flushTimer2) clearTimeout(flushTimer2);
|
|
47861
|
+
flushTimer2 = void 0;
|
|
47704
47862
|
decoder.flush();
|
|
47705
47863
|
return;
|
|
47706
47864
|
}
|
|
47707
47865
|
traceRawInput(chunk);
|
|
47708
|
-
if (
|
|
47866
|
+
if (flushTimer2) clearTimeout(flushTimer2);
|
|
47709
47867
|
deliver(decoder.push(chunk));
|
|
47710
47868
|
const delay2 = decoder.flushDelayMs();
|
|
47711
47869
|
if (delay2 !== void 0) {
|
|
47712
|
-
|
|
47713
|
-
|
|
47870
|
+
flushTimer2 = setTimeout(() => deliver(decoder.flush()), delay2);
|
|
47871
|
+
flushTimer2.unref();
|
|
47714
47872
|
}
|
|
47715
47873
|
};
|
|
47716
47874
|
input5.on("data", onData);
|
|
@@ -47731,8 +47889,8 @@ function listenForTerminalKeys(onKey) {
|
|
|
47731
47889
|
const at = keyOwners.indexOf(owner);
|
|
47732
47890
|
if (at >= 0) keyOwners.splice(at, 1);
|
|
47733
47891
|
readers -= 1;
|
|
47734
|
-
if (
|
|
47735
|
-
|
|
47892
|
+
if (flushTimer2) clearTimeout(flushTimer2);
|
|
47893
|
+
flushTimer2 = void 0;
|
|
47736
47894
|
input5.off("data", onData);
|
|
47737
47895
|
};
|
|
47738
47896
|
}
|
|
@@ -47741,7 +47899,7 @@ function takeTerminalKeys(onKey) {
|
|
|
47741
47899
|
input5.resume();
|
|
47742
47900
|
return listenForTerminalKeys(onKey);
|
|
47743
47901
|
}
|
|
47744
|
-
var ESCAPE_SEQUENCE_TIMEOUT_MS, MAX_OSC_LENGTH, OPEN_PASTE_TIMEOUT_MS, FOCUS_EVENT, DEVICE_ATTRIBUTES_REPLY, PRIVATE_REPORT, readers, unread, unreadBytes, UNREAD_LIMIT, KEEP_STDIN_FLOWING, TerminalInputDecoder, CURSOR_POSITION_REPORT, cursorReports, keyBatchDepth, keyBatchEndListeners, focusListeners, keyOwners;
|
|
47902
|
+
var ESCAPE_SEQUENCE_TIMEOUT_MS, SLOW_LINK_ESCAPE_TIMEOUT_MS, REJOIN_WINDOW_MS, CSI_REMAINDER, SS3_REMAINDER, slowLink, MAX_OSC_LENGTH, OPEN_PASTE_TIMEOUT_MS, FOCUS_EVENT, DEVICE_ATTRIBUTES_REPLY, PRIVATE_REPORT, readers, unread, unreadBytes, UNREAD_LIMIT, KEEP_STDIN_FLOWING, TerminalInputDecoder, CURSOR_POSITION_REPORT, cursorReports, keyBatchDepth, keyBatchEndListeners, focusListeners, keyOwners;
|
|
47745
47903
|
var init_input_decoder = __esm({
|
|
47746
47904
|
"src/tui/input-decoder.ts"() {
|
|
47747
47905
|
"use strict";
|
|
@@ -47751,11 +47909,16 @@ var init_input_decoder = __esm({
|
|
|
47751
47909
|
init_probe();
|
|
47752
47910
|
init_modes();
|
|
47753
47911
|
ESCAPE_SEQUENCE_TIMEOUT_MS = 120;
|
|
47912
|
+
SLOW_LINK_ESCAPE_TIMEOUT_MS = 500;
|
|
47913
|
+
REJOIN_WINDOW_MS = 1e3;
|
|
47914
|
+
CSI_REMAINDER = /^\[[\d;:?<]*[@-~]?$/;
|
|
47915
|
+
SS3_REMAINDER = /^O[ABCDHF]$/;
|
|
47916
|
+
slowLink = false;
|
|
47754
47917
|
MAX_OSC_LENGTH = 4096;
|
|
47755
47918
|
OPEN_PASTE_TIMEOUT_MS = 1e4;
|
|
47756
47919
|
FOCUS_EVENT = /^\u001b\[[IO]$/;
|
|
47757
47920
|
DEVICE_ATTRIBUTES_REPLY = /^\u001b\[\?[0-9;]*c$/;
|
|
47758
|
-
PRIVATE_REPORT = /^\u001b\[\?\d+(?:;\d+)
|
|
47921
|
+
PRIVATE_REPORT = /^\u001b\[\?\d+(?:;\d+)*\$y$/;
|
|
47759
47922
|
readers = 0;
|
|
47760
47923
|
unread = [];
|
|
47761
47924
|
unreadBytes = 0;
|
|
@@ -47768,10 +47931,34 @@ var init_input_decoder = __esm({
|
|
|
47768
47931
|
TerminalInputDecoder = class {
|
|
47769
47932
|
utf8 = new StringDecoder("utf8");
|
|
47770
47933
|
pending = "";
|
|
47934
|
+
/** When a bare Esc was given up on at a flush (its sequence may still be on the wire). */
|
|
47935
|
+
loneEscAt;
|
|
47936
|
+
/** An unfinished `ESC [ ...` dropped at a flush, and when. */
|
|
47937
|
+
orphan;
|
|
47771
47938
|
push(chunk) {
|
|
47772
|
-
|
|
47939
|
+
const text7 = typeof chunk === "string" ? chunk : this.utf8.write(chunk);
|
|
47940
|
+
this.rejoin(text7);
|
|
47941
|
+
this.pending += text7;
|
|
47773
47942
|
return this.drain(false);
|
|
47774
47943
|
}
|
|
47944
|
+
/** A sequence whose first bytes were given up on and whose rest arrives within the window is one sequence: the rest is not
|
|
47945
|
+
* typed text. An unfinished `ESC [ ...` that was dropped is put back in front of it. A bare Esc already delivered cannot be
|
|
47946
|
+
* taken back, but the rest is read as the key it was and not typed as `[A`; and this link now waits longer for the next. */
|
|
47947
|
+
rejoin(text7) {
|
|
47948
|
+
const now = Date.now();
|
|
47949
|
+
const orphan = this.orphan;
|
|
47950
|
+
const lone = this.loneEscAt;
|
|
47951
|
+
this.orphan = void 0;
|
|
47952
|
+
this.loneEscAt = void 0;
|
|
47953
|
+
if (this.pending) return;
|
|
47954
|
+
if (orphan && now - orphan.at <= REJOIN_WINDOW_MS && !text7.startsWith("\x1B")) {
|
|
47955
|
+
this.pending = orphan.text;
|
|
47956
|
+
slowLink = true;
|
|
47957
|
+
} else if (lone !== void 0 && now - lone <= REJOIN_WINDOW_MS && (CSI_REMAINDER.test(text7) || SS3_REMAINDER.test(text7))) {
|
|
47958
|
+
this.pending = "\x1B";
|
|
47959
|
+
slowLink = true;
|
|
47960
|
+
}
|
|
47961
|
+
}
|
|
47775
47962
|
flush() {
|
|
47776
47963
|
this.pending += this.utf8.end();
|
|
47777
47964
|
return this.drain(true);
|
|
@@ -47780,7 +47967,7 @@ var init_input_decoder = __esm({
|
|
|
47780
47967
|
* pending, or undefined when nothing is. */
|
|
47781
47968
|
flushDelayMs() {
|
|
47782
47969
|
if (!this.pending) return void 0;
|
|
47783
|
-
return this.pending.startsWith(PASTE_START) ? OPEN_PASTE_TIMEOUT_MS : ESCAPE_SEQUENCE_TIMEOUT_MS;
|
|
47970
|
+
return this.pending.startsWith(PASTE_START) ? OPEN_PASTE_TIMEOUT_MS : slowLink ? SLOW_LINK_ESCAPE_TIMEOUT_MS : ESCAPE_SEQUENCE_TIMEOUT_MS;
|
|
47784
47971
|
}
|
|
47785
47972
|
drain(flush) {
|
|
47786
47973
|
const keys = [];
|
|
@@ -47795,6 +47982,7 @@ var init_input_decoder = __esm({
|
|
|
47795
47982
|
if (flush) {
|
|
47796
47983
|
keys.push("\x1B");
|
|
47797
47984
|
this.pending = "";
|
|
47985
|
+
this.loneEscAt = Date.now();
|
|
47798
47986
|
}
|
|
47799
47987
|
break;
|
|
47800
47988
|
}
|
|
@@ -47839,8 +48027,8 @@ var init_input_decoder = __esm({
|
|
|
47839
48027
|
while (end < this.pending.length && !/[\x40-\x7e]/.test(this.pending[end])) end++;
|
|
47840
48028
|
if (end >= this.pending.length) {
|
|
47841
48029
|
if (flush) {
|
|
47842
|
-
|
|
47843
|
-
this.pending =
|
|
48030
|
+
this.orphan = { text: this.pending, at: Date.now() };
|
|
48031
|
+
this.pending = "";
|
|
47844
48032
|
continue;
|
|
47845
48033
|
}
|
|
47846
48034
|
break;
|
|
@@ -47852,8 +48040,8 @@ var init_input_decoder = __esm({
|
|
|
47852
48040
|
if (prefix === "O") {
|
|
47853
48041
|
if (this.pending.length < 3) {
|
|
47854
48042
|
if (flush) {
|
|
47855
|
-
|
|
47856
|
-
this.pending =
|
|
48043
|
+
this.orphan = { text: this.pending, at: Date.now() };
|
|
48044
|
+
this.pending = "";
|
|
47857
48045
|
continue;
|
|
47858
48046
|
}
|
|
47859
48047
|
break;
|
|
@@ -47903,12 +48091,13 @@ var init_input_decoder = __esm({
|
|
|
47903
48091
|
});
|
|
47904
48092
|
|
|
47905
48093
|
// src/tui/prompter/state.ts
|
|
47906
|
-
var EXIT_CONFIRM_MS, RESIZE_SETTLE_MS, SCROLL_DRAIN_MIN, SCROLL_DRAIN_MS, ALTERNATE_TRANSCRIPT_ROWS, SELECTION_SCROLL_MS, LIVE_OUTPUT_LINES, EMPTY_COMPOSER;
|
|
48094
|
+
var EXIT_CONFIRM_MS, RESIZE_SETTLE_MS, CURSOR_REPORT_MS, SCROLL_DRAIN_MIN, SCROLL_DRAIN_MS, ALTERNATE_TRANSCRIPT_ROWS, SELECTION_SCROLL_MS, LIVE_OUTPUT_LINES, EMPTY_COMPOSER;
|
|
47907
48095
|
var init_state = __esm({
|
|
47908
48096
|
"src/tui/prompter/state.ts"() {
|
|
47909
48097
|
"use strict";
|
|
47910
48098
|
EXIT_CONFIRM_MS = 2e3;
|
|
47911
48099
|
RESIZE_SETTLE_MS = 100;
|
|
48100
|
+
CURSOR_REPORT_MS = 120;
|
|
47912
48101
|
SCROLL_DRAIN_MIN = 4;
|
|
47913
48102
|
SCROLL_DRAIN_MS = 16;
|
|
47914
48103
|
ALTERNATE_TRANSCRIPT_ROWS = 2e3;
|
|
@@ -47918,6 +48107,43 @@ var init_state = __esm({
|
|
|
47918
48107
|
}
|
|
47919
48108
|
});
|
|
47920
48109
|
|
|
48110
|
+
// src/tui/prompter/history-dump.ts
|
|
48111
|
+
function resumeFrom(p, resume2, end) {
|
|
48112
|
+
const start2 = p.messageLines.get(resume2.message);
|
|
48113
|
+
if (start2 === void 0) {
|
|
48114
|
+
let first2 = Number.POSITIVE_INFINITY;
|
|
48115
|
+
for (const index of p.messageLines.keys()) first2 = Math.min(first2, index);
|
|
48116
|
+
return resume2.message < first2 ? 0 : end;
|
|
48117
|
+
}
|
|
48118
|
+
const next = p.messageLines.get(resume2.message + 1);
|
|
48119
|
+
return start2 + Math.min(resume2.into, (next ?? end) - start2);
|
|
48120
|
+
}
|
|
48121
|
+
function takeHistoryDump() {
|
|
48122
|
+
const trimmed = this.alternateTrimmed;
|
|
48123
|
+
const all = [...this.alternateTranscript, ...this.pendingFinished];
|
|
48124
|
+
let from = this.dumpedThrough === void 0 ? 0 : Math.max(0, this.dumpedThrough - trimmed);
|
|
48125
|
+
const resume2 = this.dumpResume;
|
|
48126
|
+
if (this.dumpedThrough === void 0 && resume2) {
|
|
48127
|
+
this.dumpResume = void 0;
|
|
48128
|
+
if (resume2.session === this.currentSession?.id) from = resumeFrom(this, resume2, trimmed + all.length) - trimmed;
|
|
48129
|
+
}
|
|
48130
|
+
this.dumpedThrough = trimmed + all.length;
|
|
48131
|
+
const fresh = all.slice(from);
|
|
48132
|
+
if (!fresh.length) return "";
|
|
48133
|
+
const shown2 = fresh.slice(-HISTORY_DUMP_ROWS);
|
|
48134
|
+
const cut = fresh.length - shown2.length;
|
|
48135
|
+
const note = cut > 0 ? [`\x1B[2m\u2026 ${cut} earlier row${cut === 1 ? "" : "s"} not shown; /resume reopens the whole conversation\x1B[0m`] : [];
|
|
48136
|
+
return `\x1B[?7h${[...note, ...shown2].map((row) => `${row}${ROW_END}`).join("")}`;
|
|
48137
|
+
}
|
|
48138
|
+
var HISTORY_DUMP_ROWS, ROW_END;
|
|
48139
|
+
var init_history_dump = __esm({
|
|
48140
|
+
"src/tui/prompter/history-dump.ts"() {
|
|
48141
|
+
"use strict";
|
|
48142
|
+
HISTORY_DUMP_ROWS = 2e3;
|
|
48143
|
+
ROW_END = "\x1B[0m\r\n";
|
|
48144
|
+
}
|
|
48145
|
+
});
|
|
48146
|
+
|
|
47921
48147
|
// src/tui/prompter/terminal-lifecycle.ts
|
|
47922
48148
|
import { stdin as input6, stdout as output9 } from "node:process";
|
|
47923
48149
|
function retakeScreen() {
|
|
@@ -47968,7 +48194,8 @@ function suspendToShell() {
|
|
|
47968
48194
|
this.responsePaintTimer = void 0;
|
|
47969
48195
|
this.pendingLive = void 0;
|
|
47970
48196
|
setTerminalRawMode(false);
|
|
47971
|
-
|
|
48197
|
+
const paged = inlineBlock.page;
|
|
48198
|
+
output9.write(`${leavePage()}${eraseInlineBlock()}${sessionModesOff(!paged)}${historyDumpSequence()}`);
|
|
47972
48199
|
terminalModes.alternateScreen = false;
|
|
47973
48200
|
process.once("SIGCONT", this.onContinue);
|
|
47974
48201
|
process.kill(process.pid, "SIGTSTP");
|
|
@@ -48005,7 +48232,7 @@ function close() {
|
|
|
48005
48232
|
process.off("exit", restoreTerminal);
|
|
48006
48233
|
setTerminalRawMode(false);
|
|
48007
48234
|
input6.pause();
|
|
48008
|
-
giveBackTerminal(`${eraseInlineBlock()}${popReadModes()}`);
|
|
48235
|
+
giveBackTerminal(`${leavePage()}${eraseInlineBlock()}${popReadModes()}`);
|
|
48009
48236
|
}
|
|
48010
48237
|
async function suspend() {
|
|
48011
48238
|
lifecycle("window.suspend");
|
|
@@ -48016,8 +48243,10 @@ async function suspend() {
|
|
|
48016
48243
|
this.responsePaintTimer = void 0;
|
|
48017
48244
|
setTerminalRawMode(false);
|
|
48018
48245
|
input6.pause();
|
|
48246
|
+
const paged = inlineBlock.page;
|
|
48019
48247
|
await new Promise((resolveWritten) => {
|
|
48020
|
-
output9.write(`${eraseInlineBlock()}${sessionModesOff(
|
|
48248
|
+
output9.write(`${leavePage()}${eraseInlineBlock()}${sessionModesOff(!paged)}${historyDumpSequence()}`, () => resolveWritten());
|
|
48249
|
+
terminalModes.alternateScreen = false;
|
|
48021
48250
|
});
|
|
48022
48251
|
}
|
|
48023
48252
|
function resume() {
|
|
@@ -50088,7 +50317,10 @@ function schedulePaint(delay2 = PAINT_COALESCE_MS) {
|
|
|
50088
50317
|
if (this.responsePaintTimer || this.closed || this.suspended || this.selecting || this.paletteActive) return;
|
|
50089
50318
|
this.responsePaintTimer = setTimeout(() => {
|
|
50090
50319
|
this.responsePaintTimer = void 0;
|
|
50091
|
-
if (this.resizePaintTimer)
|
|
50320
|
+
if (this.resizePaintTimer) {
|
|
50321
|
+
this.paintDropped = true;
|
|
50322
|
+
return;
|
|
50323
|
+
}
|
|
50092
50324
|
if (!this.closed && !this.selecting && !this.paletteActive) {
|
|
50093
50325
|
if (this.turn) this.paintWaiting(this.turn);
|
|
50094
50326
|
else this.repaint();
|
|
@@ -50100,7 +50332,11 @@ function flushPaint() {
|
|
|
50100
50332
|
if (!this.responsePaintTimer) return;
|
|
50101
50333
|
clearTimeout(this.responsePaintTimer);
|
|
50102
50334
|
this.responsePaintTimer = void 0;
|
|
50103
|
-
if (this.closed || this.suspended || this.selecting || this.paletteActive
|
|
50335
|
+
if (this.closed || this.suspended || this.selecting || this.paletteActive) return;
|
|
50336
|
+
if (this.resizePaintTimer) {
|
|
50337
|
+
this.paintDropped = true;
|
|
50338
|
+
return;
|
|
50339
|
+
}
|
|
50104
50340
|
if (this.turn) this.paintWaiting(this.turn);
|
|
50105
50341
|
else this.repaint();
|
|
50106
50342
|
}
|
|
@@ -50176,7 +50412,17 @@ function onWaitingKey(key3) {
|
|
|
50176
50412
|
this.flushPaint();
|
|
50177
50413
|
return;
|
|
50178
50414
|
}
|
|
50179
|
-
if (
|
|
50415
|
+
if (this.handleScrollKey(key3)) return;
|
|
50416
|
+
if (this.pendingApproval && !this.pendingApproval.question && !this.tellingInstead) {
|
|
50417
|
+
if (key3 === "\x1B[A" || key3 === "\x1B[B") {
|
|
50418
|
+
if (!this.scrollTranscript(key3 === "\x1B[A" ? SWIPE_ROWS : -SWIPE_ROWS) && key3 === "\x1B[B") this.noteReadingDirection();
|
|
50419
|
+
return;
|
|
50420
|
+
}
|
|
50421
|
+
if (key3 === "" || key3 === "") {
|
|
50422
|
+
this.scrollTranscript(key3 === "" ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER);
|
|
50423
|
+
return;
|
|
50424
|
+
}
|
|
50425
|
+
}
|
|
50180
50426
|
if (!this.pendingApproval && key3 === "\x1B" && this.scrolledBack) {
|
|
50181
50427
|
this.scrollTranscript(-Number.MAX_SAFE_INTEGER);
|
|
50182
50428
|
return;
|
|
@@ -50195,14 +50441,14 @@ function onWaitingKey(key3) {
|
|
|
50195
50441
|
let stopWithApproval = false;
|
|
50196
50442
|
if (this.pendingApproval && (key3 === "\x1B" || key3 === "")) {
|
|
50197
50443
|
this.restoreTellingDraft();
|
|
50198
|
-
for (const
|
|
50444
|
+
for (const queued2 of this.approvalQueue.splice(0)) queued2.resolve(false);
|
|
50199
50445
|
this.answerApproval(this.pendingApproval, false);
|
|
50200
50446
|
stopWithApproval = true;
|
|
50201
50447
|
} else if (this.pendingApproval) {
|
|
50202
50448
|
approvalKey.call(this, turn, this.pendingApproval, key3);
|
|
50203
50449
|
return;
|
|
50204
50450
|
}
|
|
50205
|
-
if ((key3 === "\x1B[A" || key3 === "\x1B[B") && !turn.draft) {
|
|
50451
|
+
if ((key3 === "\x1B[A" || key3 === "\x1B[B") && (!turn.draft || this.scrolledBack)) {
|
|
50206
50452
|
if (this.scrollTranscript(key3 === "\x1B[A" ? SWIPE_ROWS : -SWIPE_ROWS)) return;
|
|
50207
50453
|
if (key3 === "\x1B[B") this.noteReadingDirection();
|
|
50208
50454
|
return;
|
|
@@ -51158,6 +51404,12 @@ function onResize() {
|
|
|
51158
51404
|
if (!this.closed) {
|
|
51159
51405
|
logCursorEvent(`resize screen=${output13.columns}x${output13.rows} raw=${terminalModes.rawMode} alternate=${terminalModes.alternateScreen}`);
|
|
51160
51406
|
this.requestRedraw("resize");
|
|
51407
|
+
if (!inlineHistoryMode() && !this.suspended && !this.resizePaintTimer) {
|
|
51408
|
+
this.rewrapIfWidthChanged();
|
|
51409
|
+
this.forgetScreenPosition();
|
|
51410
|
+
this.repaint();
|
|
51411
|
+
this.resizeSettled = true;
|
|
51412
|
+
} else this.resizeSettled = false;
|
|
51161
51413
|
this.repaintAfterResize();
|
|
51162
51414
|
}
|
|
51163
51415
|
}
|
|
@@ -51167,6 +51419,12 @@ function repaintAfterResize() {
|
|
|
51167
51419
|
this.resizePaintTimer = void 0;
|
|
51168
51420
|
lifecycle("window.resize", { cols: output13.columns, rows: output13.rows });
|
|
51169
51421
|
if (this.closed || this.suspended) return;
|
|
51422
|
+
const dropped = this.paintDropped;
|
|
51423
|
+
this.paintDropped = false;
|
|
51424
|
+
if (this.resizeSettled && !inlineHistoryMode()) {
|
|
51425
|
+
if (dropped) this.repaint();
|
|
51426
|
+
return;
|
|
51427
|
+
}
|
|
51170
51428
|
const rewritten = this.rewrapIfWidthChanged();
|
|
51171
51429
|
this.forgetScreenPosition();
|
|
51172
51430
|
if (inlineHistoryMode() && !rewritten) this.anchorBlock();
|
|
@@ -51199,15 +51457,30 @@ function anchorBlock() {
|
|
|
51199
51457
|
if (this.closed || this.suspended) return;
|
|
51200
51458
|
this.repaint();
|
|
51201
51459
|
};
|
|
51202
|
-
askCursorRow(done);
|
|
51460
|
+
askCursorRow(done, CURSOR_REPORT_MS);
|
|
51461
|
+
}
|
|
51462
|
+
function dumpPlace(p) {
|
|
51463
|
+
const end = p.dumpedThrough;
|
|
51464
|
+
let message2;
|
|
51465
|
+
let line3 = 0;
|
|
51466
|
+
for (const [index, start2] of p.messageLines) if (start2 < end && (message2 === void 0 || index > message2)) {
|
|
51467
|
+
message2 = index;
|
|
51468
|
+
line3 = start2;
|
|
51469
|
+
}
|
|
51470
|
+
if (message2 === void 0) return void 0;
|
|
51471
|
+
return { session: p.currentSession?.id, message: message2, into: end - line3 };
|
|
51203
51472
|
}
|
|
51204
51473
|
function clearTranscript() {
|
|
51205
51474
|
this.alternateTrimmed += this.alternateTranscript.length;
|
|
51206
51475
|
this.alternateTranscript.length = 0;
|
|
51476
|
+
this.capDropped = 0;
|
|
51477
|
+
this.capMarkerLine = void 0;
|
|
51207
51478
|
this.pendingFinished = [];
|
|
51208
51479
|
this.lastFinishedRow = void 0;
|
|
51209
51480
|
this.secondLastFinishedRow = void 0;
|
|
51210
51481
|
this.alternateScrollback = 0;
|
|
51482
|
+
this.dumpResume = this.dumpedThrough === void 0 ? this.dumpResume : dumpPlace(this);
|
|
51483
|
+
this.dumpedThrough = void 0;
|
|
51211
51484
|
if (inlineHistoryMode()) inlineBlock.clearNext = true;
|
|
51212
51485
|
this.messageLines.clear();
|
|
51213
51486
|
this.lineTags.clear();
|
|
@@ -51409,6 +51682,9 @@ var init_glyphs = __esm({
|
|
|
51409
51682
|
|
|
51410
51683
|
// src/tui/prompter/frame-flush.ts
|
|
51411
51684
|
import { stdout as output15 } from "node:process";
|
|
51685
|
+
function earlierRowsNotice(count2) {
|
|
51686
|
+
return `\x1B[2m\u2026 ${count2} earlier row${count2 === 1 ? "" : "s"} not shown; /resume reopens the whole conversation\x1B[0m`;
|
|
51687
|
+
}
|
|
51412
51688
|
function safeRow(row, limit) {
|
|
51413
51689
|
const clean2 = sanitizeTerminalText(row, { keepSgr: true, singleLine: true });
|
|
51414
51690
|
return closeOpenHyperlink(visibleSlice(asciiMode() ? foldAscii(clean2) : clean2, limit));
|
|
@@ -51463,8 +51739,12 @@ function flushAlternateFrame(finished, pending4) {
|
|
|
51463
51739
|
focusLine === void 0 ? Number.POSITIVE_INFINITY : focusLine - this.alternateTrimmed
|
|
51464
51740
|
);
|
|
51465
51741
|
if (excess > 0) {
|
|
51742
|
+
const markerWasFirst = this.capMarkerLine === this.alternateTrimmed;
|
|
51466
51743
|
this.alternateTranscript.splice(0, excess);
|
|
51467
51744
|
this.alternateTrimmed += excess;
|
|
51745
|
+
this.capDropped += excess - (markerWasFirst ? 1 : 0) + 1;
|
|
51746
|
+
this.alternateTranscript[0] = earlierRowsNotice(this.capDropped);
|
|
51747
|
+
this.capMarkerLine = this.alternateTrimmed;
|
|
51468
51748
|
}
|
|
51469
51749
|
}
|
|
51470
51750
|
const extra = this.viewExtra;
|
|
@@ -51516,13 +51796,14 @@ function flushAlternateFrame(finished, pending4) {
|
|
|
51516
51796
|
}
|
|
51517
51797
|
}
|
|
51518
51798
|
const full = this.alternatePrevious.length !== rows.length;
|
|
51519
|
-
const scrolling = this.paintingScroll;
|
|
51799
|
+
const scrolling = this.paintingScroll || finished.length > 0 && !swallowsAlternateScreen();
|
|
51520
51800
|
this.paintingScroll = false;
|
|
51521
51801
|
const moving = Math.min(above, aboveBefore);
|
|
51522
51802
|
const shift = full || !scrolling ? 0 : scrollShift(this.alternatePrevious, rows, moving);
|
|
51523
51803
|
const updates = [];
|
|
51524
51804
|
let exposedFrom = -1;
|
|
51525
51805
|
let exposedTo = -1;
|
|
51806
|
+
let drawnRows = 0;
|
|
51526
51807
|
if (shift !== 0) {
|
|
51527
51808
|
const span2 = Math.abs(shift);
|
|
51528
51809
|
updates.push(`\x1B[1;${moving}r`);
|
|
@@ -51533,6 +51814,7 @@ function flushAlternateFrame(finished, pending4) {
|
|
|
51533
51814
|
exposedTo = exposedFrom + span2;
|
|
51534
51815
|
for (const [offset, row] of exposed.entries()) {
|
|
51535
51816
|
updates.push(`\x1B[${exposedFrom + offset + 1};1H${row}\x1B[K`);
|
|
51817
|
+
drawnRows += 1;
|
|
51536
51818
|
}
|
|
51537
51819
|
}
|
|
51538
51820
|
for (const [index, row] of rows.entries()) {
|
|
@@ -51540,6 +51822,7 @@ function flushAlternateFrame(finished, pending4) {
|
|
|
51540
51822
|
if (index >= exposedFrom && index < exposedTo) continue;
|
|
51541
51823
|
if (shift !== 0 && index < moving && shiftedRow(this.alternatePrevious, index, shift) === row) continue;
|
|
51542
51824
|
updates.push(`\x1B[${index + 1};1H${row}\x1B[K`);
|
|
51825
|
+
drawnRows += 1;
|
|
51543
51826
|
}
|
|
51544
51827
|
this.alternatePrevious = rows;
|
|
51545
51828
|
const composerRow = rows.length - live2.length + pending4.cursorRow + 1;
|
|
@@ -51553,8 +51836,9 @@ function flushAlternateFrame(finished, pending4) {
|
|
|
51553
51836
|
const draw = updates.length ? `${redrawPreamble(redraw)}${updates.join("")}` : "";
|
|
51554
51837
|
if (updates.length && redraw === this.pendingRedraw) this.pendingRedraw = void 0;
|
|
51555
51838
|
const visibleBefore = updates.length > 0 && redraw !== void 0 ? false : this.cursorShown;
|
|
51556
|
-
const
|
|
51557
|
-
const
|
|
51839
|
+
const bulk = drawnRows > BULK_ROWS;
|
|
51840
|
+
const hideFirst = (!showCursor || bulk) && visibleBefore !== false ? "\x1B[?25l" : "";
|
|
51841
|
+
const cursor = showCursor && (visibleBefore !== true || hideFirst !== "") ? "\x1B[?25h" : "";
|
|
51558
51842
|
const frame = `${syncBegin()}${modes}${signals}${hideFirst}${draw}${park2}${cursor}${syncEnd()}`;
|
|
51559
51843
|
this.lastPark = park2;
|
|
51560
51844
|
this.cursorShown = showCursor;
|
|
@@ -51571,10 +51855,6 @@ function flushInlineFrame(finished, pending4) {
|
|
|
51571
51855
|
const overlay2 = this.pickerOverlay;
|
|
51572
51856
|
const chrome = this.chromeRows;
|
|
51573
51857
|
const page = chrome > 0 && pending4.live.length >= chrome && (this.surface === "history" || overlay2.length > 0);
|
|
51574
|
-
if (page && !inlineBlock.page) {
|
|
51575
|
-
const above = Math.max(0, inlineBlock.height - inlineBlock.rows - inlineBlock.slack - inlineBlock.pad);
|
|
51576
|
-
inlineBlock.tail = inlineBlock.rows > 0 && above > 0 ? this.alternateTranscript.slice(-above) : [];
|
|
51577
|
-
}
|
|
51578
51858
|
if (finished.length) {
|
|
51579
51859
|
this.alternateTranscript.push(...finished);
|
|
51580
51860
|
const excess = this.alternateTranscript.length - ALTERNATE_TRANSCRIPT_ROWS;
|
|
@@ -51595,26 +51875,35 @@ function flushInlineFrame(finished, pending4) {
|
|
|
51595
51875
|
live2 = [...live2.slice(0, at), ...overlay2.map((row) => safeRow(row, limit)), ...live2.slice(at)];
|
|
51596
51876
|
if (cursorRow >= at) cursorRow += overlay2.length;
|
|
51597
51877
|
}
|
|
51878
|
+
const dropTail = inlineBlock.clearNext;
|
|
51598
51879
|
const leaving = inlineBlock.page;
|
|
51599
|
-
|
|
51600
|
-
|
|
51880
|
+
let leave = "";
|
|
51881
|
+
if (leaving) {
|
|
51882
|
+
const resizedWhile = inlineBlock.resized;
|
|
51883
|
+
if (inlineBlock.wipe) inlineBlock.clearNext = true;
|
|
51884
|
+
restoreMainBlock();
|
|
51885
|
+
inlineBlock.resized = false;
|
|
51886
|
+
inlineBlock.wipe = false;
|
|
51887
|
+
terminalModes.alternateScreen = false;
|
|
51888
|
+
leave = LEAVE_PAGE_SCREEN;
|
|
51889
|
+
if (resizedWhile && !inlineBlock.clearNext && inlineBlock.rows > 0) {
|
|
51890
|
+
inlineBlock.tail = [...inlineBlock.tail, ...finished];
|
|
51891
|
+
output15.write(`${syncBegin()}${leave}${syncEnd()}`);
|
|
51892
|
+
this.anchorBlock();
|
|
51893
|
+
return;
|
|
51894
|
+
}
|
|
51895
|
+
}
|
|
51896
|
+
const carried = dropTail ? [] : inlineBlock.tail;
|
|
51601
51897
|
inlineBlock.tail = [];
|
|
51898
|
+
const retired = carried.length ? [...carried, ...finished] : finished;
|
|
51602
51899
|
const wipe = inlineBlock.clearNext;
|
|
51603
|
-
const clear = wipe || leaving;
|
|
51900
|
+
const clear = wipe || leaving && inlineBlock.rows === 0;
|
|
51604
51901
|
inlineBlock.clearNext = false;
|
|
51605
51902
|
const anchored = !clear && inlineBlock.rows > 0;
|
|
51606
51903
|
const found = anchored ? inlineBlock.found : void 0;
|
|
51607
51904
|
inlineBlock.found = void 0;
|
|
51608
|
-
const
|
|
51609
|
-
|
|
51610
|
-
const onScreen = inlineBlock.pad > 0 || moved < 0;
|
|
51611
|
-
if (anchored) {
|
|
51612
|
-
const spacer = Math.max(0, inlineBlock.rows - finished.length - live2.length);
|
|
51613
|
-
if (spacer) {
|
|
51614
|
-
live2 = [...Array(spacer).fill(""), ...live2];
|
|
51615
|
-
cursorRow += spacer;
|
|
51616
|
-
}
|
|
51617
|
-
}
|
|
51905
|
+
const lost = anchored && inlineBlock.lost;
|
|
51906
|
+
inlineBlock.lost = false;
|
|
51618
51907
|
if (live2.length > height) {
|
|
51619
51908
|
cursorRow -= live2.length - height;
|
|
51620
51909
|
live2 = live2.slice(-height);
|
|
@@ -51624,29 +51913,19 @@ function flushInlineFrame(finished, pending4) {
|
|
|
51624
51913
|
this.frameLayout = { live: [...live2], tags: pending4.tags?.slice(-height) ?? [] };
|
|
51625
51914
|
const showCursor = !pending4.hideCursor;
|
|
51626
51915
|
const signature2 = JSON.stringify([live2, cursorRow, pending4.cursorColumn, showCursor]);
|
|
51627
|
-
const modes = takeQueuedModes()
|
|
51916
|
+
const modes = `${leave}${takeQueuedModes()}`;
|
|
51628
51917
|
const signals = this.pendingSignals;
|
|
51629
51918
|
this.pendingSignals = "";
|
|
51630
|
-
const
|
|
51631
|
-
inlineBlock.
|
|
51632
|
-
if (!clear && !lost && !finished.length && !modes && !signals && signature2 === inlineBlock.last) {
|
|
51633
|
-
if (found === void 0) return;
|
|
51634
|
-
const gap = height - found - inlineBlock.rows;
|
|
51635
|
-
if (!blanksOnly && (gap === 0 || gap > 0 && !onScreen)) {
|
|
51636
|
-
inlineBlock.height = height;
|
|
51637
|
-
inlineBlock.slack = Math.max(0, gap);
|
|
51638
|
-
inlineBlock.pad = Math.max(0, inlineBlock.pad - Math.max(0, moved));
|
|
51639
|
-
return;
|
|
51640
|
-
}
|
|
51641
|
-
}
|
|
51919
|
+
const resized = found !== void 0 || lost;
|
|
51920
|
+
if (!clear && !resized && !retired.length && !modes && !signals && signature2 === inlineBlock.last) return;
|
|
51642
51921
|
const previous = inlineBlock.liveRows;
|
|
51643
51922
|
const columns3 = output15.columns || 100;
|
|
51644
|
-
const diff = anchored && !
|
|
51923
|
+
const diff = anchored && !resized && !retired.length && previous.length === inlineBlock.rows && inlineBlock.columns === columns3;
|
|
51645
51924
|
let lead = "";
|
|
51646
51925
|
let text7 = "";
|
|
51647
51926
|
let park2;
|
|
51648
|
-
let nextPad =
|
|
51649
|
-
let
|
|
51927
|
+
let nextPad = resized ? 0 : inlineBlock.pad;
|
|
51928
|
+
let top2 = inlineBlock.top;
|
|
51650
51929
|
if (diff) {
|
|
51651
51930
|
let at = inlineBlock.cursorRow;
|
|
51652
51931
|
const move = (to) => {
|
|
@@ -51654,11 +51933,12 @@ function flushInlineFrame(finished, pending4) {
|
|
|
51654
51933
|
at = to;
|
|
51655
51934
|
return step < 0 ? `\x1B[${-step}A` : step > 0 ? `\x1B[${step}B` : "";
|
|
51656
51935
|
};
|
|
51657
|
-
|
|
51658
|
-
|
|
51659
|
-
const take = Math.min(
|
|
51936
|
+
const scrolls = Math.max(0, top2 + live2.length - height);
|
|
51937
|
+
if (live2.length > previous.length && scrolls > 0 && nextPad > 0) {
|
|
51938
|
+
const take = Math.min(scrolls, nextPad);
|
|
51660
51939
|
text7 += `${top2 + at > 0 ? `\x1B[${top2 + at}A` : ""}\x1B[${take}M`;
|
|
51661
51940
|
at = -(top2 - take);
|
|
51941
|
+
top2 -= take;
|
|
51662
51942
|
nextPad -= take;
|
|
51663
51943
|
}
|
|
51664
51944
|
const common2 = Math.min(previous.length, live2.length);
|
|
@@ -51670,46 +51950,44 @@ function flushInlineFrame(finished, pending4) {
|
|
|
51670
51950
|
for (let index = previous.length; index < live2.length; index += 1) text7 += `\r
|
|
51671
51951
|
${live2[index]}\x1B[K`;
|
|
51672
51952
|
at = live2.length - 1;
|
|
51673
|
-
|
|
51674
|
-
} else
|
|
51953
|
+
top2 = Math.min(top2, height - live2.length);
|
|
51954
|
+
} else if (live2.length < previous.length) {
|
|
51955
|
+
text7 += `${move(live2.length)}\r\x1B[J`;
|
|
51956
|
+
}
|
|
51675
51957
|
park2 = `${move(cursorRow)}\x1B[${Math.max(1, pending4.cursorColumn)}G`;
|
|
51676
51958
|
} else {
|
|
51677
|
-
const
|
|
51678
|
-
|
|
51679
|
-
nextPad = 0;
|
|
51680
|
-
nextSlack = 0;
|
|
51681
|
-
}
|
|
51959
|
+
const body = [...retired, ...live2];
|
|
51960
|
+
let amount = 0;
|
|
51682
51961
|
if (clear) {
|
|
51683
51962
|
lead = wipe ? CLEAR_SCREEN_AND_SCROLLBACK : CLEAR_SCREEN;
|
|
51684
51963
|
inlineBlock.rows = 0;
|
|
51685
51964
|
inlineBlock.cursorRow = 0;
|
|
51686
|
-
} else lead = eraseInlineBlock();
|
|
51687
|
-
const body = [...keptTail, ...finished, ...live2];
|
|
51688
|
-
if (clear) {
|
|
51689
51965
|
nextPad = Math.max(0, height - body.length);
|
|
51690
51966
|
if (nextPad > 0) lead += `\x1B[${nextPad + 1};1H`;
|
|
51691
|
-
|
|
51692
|
-
|
|
51967
|
+
top2 = nextPad;
|
|
51968
|
+
} else {
|
|
51969
|
+
if (found !== void 0) {
|
|
51970
|
+
const up = Math.max(0, inlineBlock.cursorRow + Math.min(0, found));
|
|
51971
|
+
lead = inlineBlock.rows ? `${up > 0 ? `\x1B[${up}A` : ""}\r\x1B[J` : "";
|
|
51972
|
+
eraseInlineBlock();
|
|
51973
|
+
top2 = Math.max(0, found);
|
|
51974
|
+
} else lead = eraseInlineBlock();
|
|
51975
|
+
amount = Math.min(Math.max(0, top2 + body.length - height), nextPad);
|
|
51693
51976
|
if (amount > 0) {
|
|
51694
|
-
lead += `${
|
|
51695
|
-
|
|
51696
|
-
if (to > 0) lead += `\x1B[${to}B`;
|
|
51977
|
+
lead += `${top2 > 0 ? `\x1B[${top2}A` : ""}\x1B[${amount}M`;
|
|
51978
|
+
if (top2 - amount > 0) lead += `\x1B[${top2 - amount}B`;
|
|
51697
51979
|
nextPad -= amount;
|
|
51980
|
+
top2 -= amount;
|
|
51698
51981
|
}
|
|
51699
|
-
const gap = height - oldTop - body.length;
|
|
51700
|
-
if (gap > 0 && onScreen) {
|
|
51701
|
-
lead += `\x1B[1;1H\x1B[${gap}L\x1B[${oldTop + gap + 1};1H`;
|
|
51702
|
-
nextPad += gap;
|
|
51703
|
-
} else if (gap > 0) nextSlack = gap;
|
|
51704
|
-
if (blanksOnly) lead += "\x1B[3J";
|
|
51705
51982
|
}
|
|
51983
|
+
top2 = Math.min(top2 + body.length - live2.length, height - live2.length);
|
|
51706
51984
|
text7 = body.map((row, index) => `${row}\x1B[K${index < body.length - 1 ? "\r\n" : ""}`).join("");
|
|
51707
51985
|
const back = lastRow - cursorRow;
|
|
51708
51986
|
park2 = `${back ? `\x1B[${back}A` : ""}\x1B[${Math.max(1, pending4.cursorColumn)}G`;
|
|
51709
51987
|
}
|
|
51710
51988
|
inlineBlock.pad = nextPad;
|
|
51711
|
-
inlineBlock.
|
|
51712
|
-
|
|
51989
|
+
inlineBlock.top = top2;
|
|
51990
|
+
inlineBlock.height = height;
|
|
51713
51991
|
inlineBlock.rows = live2.length;
|
|
51714
51992
|
inlineBlock.cursorRow = cursorRow;
|
|
51715
51993
|
inlineBlock.last = signature2;
|
|
@@ -51721,7 +51999,7 @@ ${live2[index]}\x1B[K`;
|
|
|
51721
51999
|
const frame = `${syncBegin()}${modes}${signals}\x1B[?25l\x1B[?7l${lead}${text7}${park2}${showCursor ? "\x1B[?25h" : ""}${syncEnd()}`;
|
|
51722
52000
|
this.frameInFlight = true;
|
|
51723
52001
|
terminalModes.painted = true;
|
|
51724
|
-
logCursorEvent(`inline frame: block=${live2.length} finished=${
|
|
52002
|
+
logCursorEvent(`inline frame: block=${live2.length} finished=${retired.length} composer=${cursorRow} col=${pending4.cursorColumn}`);
|
|
51725
52003
|
output15.write(frame, () => {
|
|
51726
52004
|
this.frameInFlight = false;
|
|
51727
52005
|
if (this.pendingLive && !this.closed && !this.suspended) this.flushFrame();
|
|
@@ -51737,20 +52015,32 @@ function flushInlinePage(finished, pending4, height) {
|
|
|
51737
52015
|
const blank = Math.max(0, height - rows.length);
|
|
51738
52016
|
rows.splice(rows.length - footer.length, 0, ...Array(blank).fill(""));
|
|
51739
52017
|
const cursorRow = Math.max(0, Math.min(rows.length - 1, rows.length - footer.length + Math.max(0, pending4.cursorRow - at)));
|
|
51740
|
-
const
|
|
51741
|
-
|
|
52018
|
+
const opening = !inlineBlock.page;
|
|
52019
|
+
if (opening) {
|
|
52020
|
+
const { rows: blockRows, cursorRow: blockCursor, last: last2, liveRows, pad: pad3, top: top2, height: blockHeight, columns: blockColumns } = inlineBlock;
|
|
52021
|
+
inlineBlock.main = { rows: blockRows, cursorRow: blockCursor, last: last2, liveRows: [...liveRows], pad: pad3, top: top2, height: blockHeight, columns: blockColumns };
|
|
52022
|
+
inlineBlock.tail = [];
|
|
52023
|
+
inlineBlock.resized = false;
|
|
52024
|
+
inlineBlock.wipe = false;
|
|
52025
|
+
terminalModes.alternateScreen = true;
|
|
52026
|
+
}
|
|
52027
|
+
const resized = !opening && (inlineBlock.height !== height || inlineBlock.columns !== columns3);
|
|
52028
|
+
if (resized) inlineBlock.resized = true;
|
|
52029
|
+
const fresh = opening || resized || inlineBlock.clearNext;
|
|
51742
52030
|
const showCursor = !pending4.hideCursor;
|
|
51743
52031
|
const signature2 = JSON.stringify([rows, cursorRow, pending4.cursorColumn, showCursor]);
|
|
51744
52032
|
const modes = takeQueuedModes();
|
|
51745
52033
|
const signals = this.pendingSignals;
|
|
51746
52034
|
this.pendingSignals = "";
|
|
51747
|
-
inlineBlock.
|
|
51748
|
-
|
|
52035
|
+
if (inlineBlock.clearNext) {
|
|
52036
|
+
inlineBlock.wipe = true;
|
|
52037
|
+
inlineBlock.tail = [...finished];
|
|
52038
|
+
} else inlineBlock.tail.push(...finished);
|
|
51749
52039
|
if (!fresh && !modes && !signals && signature2 === inlineBlock.last) return;
|
|
51750
52040
|
const previous = fresh ? [] : inlineBlock.liveRows;
|
|
51751
52041
|
let text7 = "";
|
|
51752
52042
|
for (const [index, row] of rows.entries()) if (previous[index] !== row) text7 += `\x1B[${index + 1};1H${row}\x1B[K`;
|
|
51753
|
-
const lead =
|
|
52043
|
+
const lead = opening ? ENTER_PAGE_SCREEN : fresh ? CLEAR_SCREEN : "";
|
|
51754
52044
|
const park2 = `\x1B[${cursorRow + 1};${Math.max(1, pending4.cursorColumn)}H`;
|
|
51755
52045
|
this.frameLayout = { live: [...rows], tags: [] };
|
|
51756
52046
|
inlineBlock.clearNext = false;
|
|
@@ -51762,7 +52052,7 @@ function flushInlinePage(finished, pending4, height) {
|
|
|
51762
52052
|
inlineBlock.columns = columns3;
|
|
51763
52053
|
inlineBlock.height = height;
|
|
51764
52054
|
inlineBlock.pad = 0;
|
|
51765
|
-
inlineBlock.
|
|
52055
|
+
inlineBlock.top = 0;
|
|
51766
52056
|
inlineBlock.found = void 0;
|
|
51767
52057
|
inlineBlock.lost = false;
|
|
51768
52058
|
this.pendingRedraw = void 0;
|
|
@@ -51777,6 +52067,7 @@ function flushInlinePage(finished, pending4, height) {
|
|
|
51777
52067
|
if (this.pendingLive && !this.closed && !this.suspended) this.flushFrame();
|
|
51778
52068
|
});
|
|
51779
52069
|
}
|
|
52070
|
+
var BULK_ROWS;
|
|
51780
52071
|
var init_frame_flush = __esm({
|
|
51781
52072
|
"src/tui/prompter/frame-flush.ts"() {
|
|
51782
52073
|
"use strict";
|
|
@@ -51793,6 +52084,7 @@ var init_frame_flush = __esm({
|
|
|
51793
52084
|
init_modes();
|
|
51794
52085
|
init_state();
|
|
51795
52086
|
init_group_actions();
|
|
52087
|
+
BULK_ROWS = 8;
|
|
51796
52088
|
}
|
|
51797
52089
|
});
|
|
51798
52090
|
|
|
@@ -52556,6 +52848,8 @@ var init_prompt_input = __esm({
|
|
|
52556
52848
|
cursor;
|
|
52557
52849
|
selected = 0;
|
|
52558
52850
|
historyIndex;
|
|
52851
|
+
/** The draft as typed, kept while history is recalled over it (at index `history.length`), so Down past the newest entry restores it. */
|
|
52852
|
+
stashedDraft;
|
|
52559
52853
|
// Long pastes, held out of the draft as placeholders (held-pastes.ts)
|
|
52560
52854
|
// and put back when it is sent.
|
|
52561
52855
|
held = [];
|
|
@@ -52753,6 +53047,7 @@ ${kept}` : kept;
|
|
|
52753
53047
|
this.held = [];
|
|
52754
53048
|
this.selected = 0;
|
|
52755
53049
|
this.historyIndex = p.history.length;
|
|
53050
|
+
this.stashedDraft = void 0;
|
|
52756
53051
|
this.draw();
|
|
52757
53052
|
return true;
|
|
52758
53053
|
}
|
|
@@ -52822,17 +53117,31 @@ ${kept}` : kept;
|
|
|
52822
53117
|
return false;
|
|
52823
53118
|
}
|
|
52824
53119
|
historyStep(direction) {
|
|
53120
|
+
const live2 = this.p.history.length;
|
|
53121
|
+
if (direction < 0 && this.historyIndex === live2 && this.historyIndex > 0) this.stashedDraft = { value: this.value, cursor: this.cursor, held: [...this.held] };
|
|
52825
53122
|
if (direction < 0 && this.historyIndex > 0) this.historyIndex -= 1;
|
|
52826
|
-
else if (direction > 0) this.historyIndex = Math.min(
|
|
53123
|
+
else if (direction > 0) this.historyIndex = Math.min(live2, this.historyIndex + 1);
|
|
52827
53124
|
else return;
|
|
53125
|
+
if (this.historyIndex === live2) {
|
|
53126
|
+
const draft = this.stashedDraft;
|
|
53127
|
+
this.stashedDraft = void 0;
|
|
53128
|
+
if (draft) {
|
|
53129
|
+
this.apply(draft);
|
|
53130
|
+
return;
|
|
53131
|
+
}
|
|
53132
|
+
}
|
|
52828
53133
|
this.value = this.p.history[this.historyIndex] ?? "";
|
|
52829
53134
|
this.cursor = this.value.length;
|
|
52830
53135
|
}
|
|
52831
53136
|
/** Arrows and history keys: true when the key was handled here.
|
|
52832
53137
|
* Up/Down navigate palette options; otherwise they move through a
|
|
52833
53138
|
* multi-line draft and fall through to input history from its first
|
|
52834
|
-
* and last line.
|
|
52835
|
-
*
|
|
53139
|
+
* and last line. With the composer empty, or the view already scrolled
|
|
53140
|
+
* back, they read the conversation instead: a swipe or wheel notch reaches
|
|
53141
|
+
* the program as these keys (alternate scroll, `?1007`) and cannot be told
|
|
53142
|
+
* from typing them. Recalling history over a draft keeps the draft (Down
|
|
53143
|
+
* past the newest entry brings it back). Ctrl+P/Ctrl+N always mean
|
|
53144
|
+
* history. */
|
|
52836
53145
|
navigationKey(key3, { completing, options: options2 }) {
|
|
52837
53146
|
const { p, value, commands, settings } = this;
|
|
52838
53147
|
if (key3 === "\x1B[A" || key3 === "\x1B[B") {
|
|
@@ -52842,7 +53151,7 @@ ${kept}` : kept;
|
|
|
52842
53151
|
this.draw();
|
|
52843
53152
|
return true;
|
|
52844
53153
|
}
|
|
52845
|
-
if (!value) {
|
|
53154
|
+
if (!value || p.scrolledBack) {
|
|
52846
53155
|
if (p.scrollTranscript(direction === -1 ? SWIPE_ROWS : -SWIPE_ROWS)) return true;
|
|
52847
53156
|
if (direction === 1 && p.noteReadingDirection()) return true;
|
|
52848
53157
|
}
|
|
@@ -52852,6 +53161,10 @@ ${kept}` : kept;
|
|
|
52852
53161
|
this.draw();
|
|
52853
53162
|
return true;
|
|
52854
53163
|
}
|
|
53164
|
+
if (!value && !options2.length && (key3 === "" || key3 === "")) {
|
|
53165
|
+
p.scrollTranscript(key3 === "" ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER);
|
|
53166
|
+
return true;
|
|
53167
|
+
}
|
|
52855
53168
|
if (key3 === "" && !options2.length) {
|
|
52856
53169
|
this.historyStep(-1);
|
|
52857
53170
|
this.draw();
|
|
@@ -53020,7 +53333,7 @@ function composerLayout(value, cursor, available, maxRows = 6) {
|
|
|
53020
53333
|
index = next;
|
|
53021
53334
|
continue;
|
|
53022
53335
|
}
|
|
53023
|
-
const characterWidth = Math.max(1, terminalCellWidth(character));
|
|
53336
|
+
const characterWidth = character === " " ? TAB_WIDTH - column % TAB_WIDTH : Math.max(1, terminalCellWidth(character));
|
|
53024
53337
|
if (column > 0 && column + characterWidth > width) {
|
|
53025
53338
|
if (/\s/u.test(character)) {
|
|
53026
53339
|
ranges.push({ start: rowStart, end: index });
|
|
@@ -53064,13 +53377,14 @@ function composerLayout(value, cursor, available, maxRows = 6) {
|
|
|
53064
53377
|
break;
|
|
53065
53378
|
}
|
|
53066
53379
|
const start2 = Math.max(0, Math.min(position2.row - maxRows + 1, rows.length - maxRows));
|
|
53067
|
-
const visible3 = rows.slice(start2, start2 + maxRows);
|
|
53380
|
+
const visible3 = rows.slice(start2, start2 + maxRows).map((row) => expandTabs(row));
|
|
53068
53381
|
return { rows: visible3, cursorRow: position2.row - start2, cursorWidth: position2.column };
|
|
53069
53382
|
}
|
|
53070
53383
|
var init_composer_layout = __esm({
|
|
53071
53384
|
"src/tui/render/composer-layout.ts"() {
|
|
53072
53385
|
"use strict";
|
|
53073
53386
|
init_width();
|
|
53387
|
+
init_text();
|
|
53074
53388
|
}
|
|
53075
53389
|
});
|
|
53076
53390
|
|
|
@@ -53548,7 +53862,7 @@ function createToolRows(p, builders) {
|
|
|
53548
53862
|
lines: open13(["", ` ${row}`, ...live2])
|
|
53549
53863
|
};
|
|
53550
53864
|
};
|
|
53551
|
-
const waitingOnApproval = (event) => event.id !== void 0 && (p.pendingApproval?.callId === event.id || p.approvalQueue.some((
|
|
53865
|
+
const waitingOnApproval = (event) => event.id !== void 0 && (p.pendingApproval?.callId === event.id || p.approvalQueue.some((queued2) => queued2.callId === event.id));
|
|
53552
53866
|
const tagged = (lines4, group, item) => lines4.map((line3) => line3.trim() ? tagRow(line3, { group, item }) : line3);
|
|
53553
53867
|
const summaryLine = (items, running4, plainOnly, open13 = false) => {
|
|
53554
53868
|
const summary = groupSummary(items.map((item) => ({ id: item.key, event: item.event, ...item.thought ? { thought: item.thought } : {} })), running4, waitingOnApproval);
|
|
@@ -54200,6 +54514,7 @@ var init_prompter = __esm({
|
|
|
54200
54514
|
init_modes();
|
|
54201
54515
|
init_probe();
|
|
54202
54516
|
init_state();
|
|
54517
|
+
init_history_dump();
|
|
54203
54518
|
init_terminal_lifecycle();
|
|
54204
54519
|
init_scroll_selection();
|
|
54205
54520
|
init_mention();
|
|
@@ -54334,6 +54649,15 @@ var init_prompter = __esm({
|
|
|
54334
54649
|
/** The width the transcript's rows were wrapped at. A resize to another
|
|
54335
54650
|
* width wraps the whole conversation again (see rewrapTranscript). */
|
|
54336
54651
|
transcriptColumns = output19.columns || 0;
|
|
54652
|
+
/** The first conversation row number (alternateTrimmed + index) not yet written into the normal screen; undefined: none of the current text has been. */
|
|
54653
|
+
dumpedThrough;
|
|
54654
|
+
/** Where the history dump stood when the transcript was rewritten for a new width: by message, which rewrapping keeps (row
|
|
54655
|
+
* numbers it does not). `into` is how many rows of that message were written. */
|
|
54656
|
+
dumpResume;
|
|
54657
|
+
/** Full-screen: the last size change was drawn whole the moment it arrived and no other came while the settle timer ran. */
|
|
54658
|
+
resizeSettled = false;
|
|
54659
|
+
/** A coalesced paint came due during a resize settle and was dropped; the settle repaints for it. */
|
|
54660
|
+
paintDropped = false;
|
|
54337
54661
|
usageLabel;
|
|
54338
54662
|
/** The owner of a conversation reached over SSH, shown in the status line. */
|
|
54339
54663
|
remoteMachineName;
|
|
@@ -54465,6 +54789,9 @@ var init_prompter = __esm({
|
|
|
54465
54789
|
/** Rows retired out of the viewport, kept so the conversation above the
|
|
54466
54790
|
* live region is still there to scroll back to on the alternate screen. */
|
|
54467
54791
|
alternateTranscript = [];
|
|
54792
|
+
/** Rows the cap on alternateTranscript has kept out of the view, and the line of the notice that says so (undefined: none). */
|
|
54793
|
+
capDropped = 0;
|
|
54794
|
+
capMarkerLine;
|
|
54468
54795
|
/** Exactly the rows the last alternate-screen frame left on screen, so the
|
|
54469
54796
|
* next one writes only what differs. */
|
|
54470
54797
|
alternatePrevious = [];
|
|
@@ -54487,7 +54814,8 @@ var init_prompter = __esm({
|
|
|
54487
54814
|
if (!output19.isTTY) {
|
|
54488
54815
|
throw new Error("TerminalHarnessPrompter requires a TTY on stdout; construct it behind terminalUiSupported()");
|
|
54489
54816
|
}
|
|
54490
|
-
const
|
|
54817
|
+
const handover = parseReexecHandover(process.env[REEXEC_TERMINAL_ENV]);
|
|
54818
|
+
const inheritedScreen = handover !== void 0;
|
|
54491
54819
|
delete process.env[REEXEC_TERMINAL_ENV];
|
|
54492
54820
|
terminalModes.uiStarted = true;
|
|
54493
54821
|
setTerminalRawMode(true);
|
|
@@ -54496,13 +54824,10 @@ var init_prompter = __esm({
|
|
|
54496
54824
|
output19.write(terminalPrepare());
|
|
54497
54825
|
{
|
|
54498
54826
|
logProcessWarnings();
|
|
54499
|
-
|
|
54500
|
-
|
|
54501
|
-
|
|
54502
|
-
|
|
54503
|
-
terminalModes.alternateScreen = true;
|
|
54504
|
-
}
|
|
54505
|
-
output19.write(sessionModesOn(true));
|
|
54827
|
+
output19.write(reconcileScreen(handover, inlineHistoryMode(), output19.rows || 24).write);
|
|
54828
|
+
if (!inlineHistoryMode()) terminalModes.alternateScreen = true;
|
|
54829
|
+
output19.write(sessionModesOn());
|
|
54830
|
+
if (!inlineHistoryMode()) historyDump.source = () => this.takeHistoryDump();
|
|
54506
54831
|
void probeTerminal();
|
|
54507
54832
|
}
|
|
54508
54833
|
if (inheritedScreen) terminalModes.titlePushed = true;
|
|
@@ -54773,6 +55098,7 @@ var init_prompter = __esm({
|
|
|
54773
55098
|
rewrapIfWidthChanged,
|
|
54774
55099
|
anchorBlock,
|
|
54775
55100
|
clearTranscript,
|
|
55101
|
+
takeHistoryDump,
|
|
54776
55102
|
activity,
|
|
54777
55103
|
setPlan,
|
|
54778
55104
|
settlePlan,
|
|
@@ -71161,7 +71487,7 @@ function watchConsole(page) {
|
|
|
71161
71487
|
logs.set(page, entries);
|
|
71162
71488
|
const push = (entry2) => {
|
|
71163
71489
|
entries.push(entry2);
|
|
71164
|
-
if (entries.length >
|
|
71490
|
+
if (entries.length > KEEP2) entries.splice(0, entries.length - KEEP2);
|
|
71165
71491
|
};
|
|
71166
71492
|
page.on("console", (message2) => {
|
|
71167
71493
|
const at = message2.location();
|
|
@@ -71174,7 +71500,7 @@ function pickConsole(entries, options2 = {}) {
|
|
|
71174
71500
|
const floor = options2.level ? order.indexOf(options2.level === "warn" ? "warning" : options2.level) : -1;
|
|
71175
71501
|
const wanted = options2.find?.toLowerCase();
|
|
71176
71502
|
const kept = entries.filter((entry2) => (floor < 0 || order.indexOf(entry2.level) <= floor) && (!wanted || entry2.text.toLowerCase().includes(wanted)));
|
|
71177
|
-
return kept.slice(-Math.min(Math.max(Math.floor(options2.limit ?? 30), 1),
|
|
71503
|
+
return kept.slice(-Math.min(Math.max(Math.floor(options2.limit ?? 30), 1), KEEP2));
|
|
71178
71504
|
}
|
|
71179
71505
|
function describeConsole(entries, total) {
|
|
71180
71506
|
if (!entries.length) return total ? "No console messages match." : "The console is empty: nothing logged and no page errors in this tab.";
|
|
@@ -71189,7 +71515,7 @@ async function readConsole(page, options2 = {}) {
|
|
|
71189
71515
|
if (options2.clear) all.length = 0;
|
|
71190
71516
|
return hideKeyLikeText(scrubSecrets(await maskSensitive(page, text7))).text;
|
|
71191
71517
|
}
|
|
71192
|
-
var
|
|
71518
|
+
var KEEP2, MAX_TEXT, logs, watched, LEVELS;
|
|
71193
71519
|
var init_console_log = __esm({
|
|
71194
71520
|
"src/agent/computer/console-log.ts"() {
|
|
71195
71521
|
"use strict";
|
|
@@ -71197,7 +71523,7 @@ var init_console_log = __esm({
|
|
|
71197
71523
|
init_secret_finder();
|
|
71198
71524
|
init_sensitive_fields();
|
|
71199
71525
|
init_secret_scrubber();
|
|
71200
|
-
|
|
71526
|
+
KEEP2 = 200;
|
|
71201
71527
|
MAX_TEXT = 600;
|
|
71202
71528
|
logs = sharedState("console-logs", () => /* @__PURE__ */ new WeakMap());
|
|
71203
71529
|
watched = sharedState("console-watched", () => /* @__PURE__ */ new WeakSet());
|
|
@@ -82952,6 +83278,70 @@ function createToolRunner(rt, runTurn) {
|
|
|
82952
83278
|
}
|
|
82953
83279
|
});
|
|
82954
83280
|
const runSubagent = innerSubagent;
|
|
83281
|
+
const foregroundSubagent = (callId, request3, run4) => {
|
|
83282
|
+
const hand = (handler) => {
|
|
83283
|
+
if (handler) rt.foregroundSteers.set(callId, handler);
|
|
83284
|
+
else rt.foregroundSteers.delete(callId);
|
|
83285
|
+
};
|
|
83286
|
+
const agents = rt.backgroundAgents;
|
|
83287
|
+
if (request3.background || !agents) return run4({ ...request3, callId, ...request3.background ? {} : signal ? { signal } : {}, ...request3.background ? {} : { onSteerReady: hand } });
|
|
83288
|
+
const own = new AbortController();
|
|
83289
|
+
const relay = () => own.abort();
|
|
83290
|
+
if (signal?.aborted) own.abort();
|
|
83291
|
+
else signal?.addEventListener("abort", relay, { once: true });
|
|
83292
|
+
let current5;
|
|
83293
|
+
let promoted;
|
|
83294
|
+
let over = false;
|
|
83295
|
+
const running4 = run4({
|
|
83296
|
+
...request3,
|
|
83297
|
+
callId,
|
|
83298
|
+
signal: own.signal,
|
|
83299
|
+
onSteerReady: (handler) => {
|
|
83300
|
+
current5 = handler;
|
|
83301
|
+
if (promoted) promoted(handler);
|
|
83302
|
+
else hand(handler);
|
|
83303
|
+
}
|
|
83304
|
+
});
|
|
83305
|
+
const alert = steerAlert(rt);
|
|
83306
|
+
return new Promise((resolve14, reject) => {
|
|
83307
|
+
const detach = () => {
|
|
83308
|
+
alert.signal.removeEventListener("abort", promote);
|
|
83309
|
+
alert.dispose();
|
|
83310
|
+
};
|
|
83311
|
+
function promote() {
|
|
83312
|
+
if (over) return;
|
|
83313
|
+
detach();
|
|
83314
|
+
hand(void 0);
|
|
83315
|
+
signal?.removeEventListener("abort", relay);
|
|
83316
|
+
const label3 = request3.description?.trim() || request3.prompt.split("\n")[0].slice(0, 80);
|
|
83317
|
+
const id = agents.start(label3, (ready) => {
|
|
83318
|
+
promoted = ready;
|
|
83319
|
+
ready(current5);
|
|
83320
|
+
return running4;
|
|
83321
|
+
});
|
|
83322
|
+
resolve14({
|
|
83323
|
+
output: `[Returned early because the user sent a message; read it before anything else. The sub-agent is NOT stopped: it carries on as background agent ${id}, and its result arrives as a message when it finishes. agent_send("${id}", ...) gives it instructions, agent_wait("${id}") gets its result.]`,
|
|
83324
|
+
continuesAs: id
|
|
83325
|
+
});
|
|
83326
|
+
}
|
|
83327
|
+
running4.then(
|
|
83328
|
+
(result) => {
|
|
83329
|
+
over = true;
|
|
83330
|
+
detach();
|
|
83331
|
+
signal?.removeEventListener("abort", relay);
|
|
83332
|
+
resolve14(result);
|
|
83333
|
+
},
|
|
83334
|
+
(error) => {
|
|
83335
|
+
over = true;
|
|
83336
|
+
detach();
|
|
83337
|
+
signal?.removeEventListener("abort", relay);
|
|
83338
|
+
reject(error);
|
|
83339
|
+
}
|
|
83340
|
+
);
|
|
83341
|
+
if (alert.signal.aborted) queueMicrotask(promote);
|
|
83342
|
+
else alert.signal.addEventListener("abort", promote, { once: true });
|
|
83343
|
+
});
|
|
83344
|
+
};
|
|
82955
83345
|
const toolContext = (callId, toolName, emitOutput) => ({
|
|
82956
83346
|
cwd,
|
|
82957
83347
|
addDirs,
|
|
@@ -82975,16 +83365,7 @@ function createToolRunner(rt, runTurn) {
|
|
|
82975
83365
|
...input11.onPlan ? { onPlan: input11.onPlan } : {},
|
|
82976
83366
|
...input11.net ? { net: input11.net } : {},
|
|
82977
83367
|
...sandboxNow(input11) === "workspace" ? { sandbox: "workspace" } : {},
|
|
82978
|
-
...runSubagent ? { runSubagent: (request3) => runSubagent
|
|
82979
|
-
...request3,
|
|
82980
|
-
callId,
|
|
82981
|
-
...request3.background ? {} : signal ? { signal } : {},
|
|
82982
|
-
// A foreground sub-agent is steerable while its call is open (turn-runtime.ts).
|
|
82983
|
-
...request3.background ? {} : { onSteerReady: (handler) => {
|
|
82984
|
-
if (handler) rt.foregroundSteers.set(callId, handler);
|
|
82985
|
-
else rt.foregroundSteers.delete(callId);
|
|
82986
|
-
} }
|
|
82987
|
-
}) } : {},
|
|
83368
|
+
...runSubagent ? { runSubagent: (request3) => foregroundSubagent(callId, request3, runSubagent) } : {},
|
|
82988
83369
|
...rt.backgroundAgents ? { agents: rt.backgroundAgents } : {}
|
|
82989
83370
|
});
|
|
82990
83371
|
const authorize = async (call, tool, ctx) => {
|
|
@@ -92450,10 +92831,10 @@ async function commandDuringTurn(sessionId, line3) {
|
|
|
92450
92831
|
if (!session2) throw new Error(`AI session "${sessionId}" was not found`);
|
|
92451
92832
|
const submission = { id: randomUUID42(), text: line3, submittedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
92452
92833
|
if (isShellCommandLine(line3)) {
|
|
92453
|
-
const
|
|
92454
|
-
enqueueSessionTurn(session2,
|
|
92834
|
+
const queued3 = { ...submission, kind: "command" };
|
|
92835
|
+
enqueueSessionTurn(session2, queued3, queued3.submittedAt);
|
|
92455
92836
|
await writeState(state);
|
|
92456
|
-
return { disposition: "command", submission:
|
|
92837
|
+
return { disposition: "command", submission: queued3, commandOutcome: "later" };
|
|
92457
92838
|
}
|
|
92458
92839
|
const route = routeSlashInput(line3, slashRouteContextFor(
|
|
92459
92840
|
session2,
|
|
@@ -92471,10 +92852,10 @@ async function commandDuringTurn(sessionId, line3) {
|
|
|
92471
92852
|
return { disposition: "command", submission, commandOutcome: "applied" };
|
|
92472
92853
|
}
|
|
92473
92854
|
const isCommand = route.kind !== "prompt" && route.kind !== "native";
|
|
92474
|
-
const
|
|
92475
|
-
enqueueSessionTurn(session2,
|
|
92855
|
+
const queued2 = { ...submission, ...isCommand ? { kind: "command" } : {} };
|
|
92856
|
+
enqueueSessionTurn(session2, queued2, queued2.submittedAt);
|
|
92476
92857
|
await writeState(state);
|
|
92477
|
-
return { disposition: isCommand ? "command" : "queued", submission:
|
|
92858
|
+
return { disposition: isCommand ? "command" : "queued", submission: queued2, ...isCommand ? { commandOutcome: "later" } : {} };
|
|
92478
92859
|
}
|
|
92479
92860
|
var init_queue = __esm({
|
|
92480
92861
|
"src/tui/slash/queue.ts"() {
|
|
@@ -93870,6 +94251,50 @@ var init_status = __esm({
|
|
|
93870
94251
|
}
|
|
93871
94252
|
});
|
|
93872
94253
|
|
|
94254
|
+
// src/runtime/event-loop-monitor.ts
|
|
94255
|
+
import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
94256
|
+
function blockedLogger(write2, now = Date.now, thresholdMs = BLOCKED_THRESHOLD_MS, gapMs = BLOCKED_LOG_GAP_MS) {
|
|
94257
|
+
let lastWritten;
|
|
94258
|
+
let suppressed = 0;
|
|
94259
|
+
return (worstMs) => {
|
|
94260
|
+
if (worstMs <= thresholdMs) return;
|
|
94261
|
+
const at = now();
|
|
94262
|
+
if (lastWritten !== void 0 && at - lastWritten < gapMs) {
|
|
94263
|
+
suppressed += 1;
|
|
94264
|
+
return;
|
|
94265
|
+
}
|
|
94266
|
+
lastWritten = at;
|
|
94267
|
+
const skipped = suppressed;
|
|
94268
|
+
suppressed = 0;
|
|
94269
|
+
write2({ ms: Math.round(worstMs), suppressed: skipped });
|
|
94270
|
+
};
|
|
94271
|
+
}
|
|
94272
|
+
function startEventLoopMonitor() {
|
|
94273
|
+
const histogram = monitorEventLoopDelay({ resolution: 20 });
|
|
94274
|
+
histogram.enable();
|
|
94275
|
+
const note = blockedLogger(({ ms, suppressed }) => lifecycle("event-loop.blocked", { ms, ...suppressed ? { suppressed } : {} }));
|
|
94276
|
+
const timer = setInterval(() => {
|
|
94277
|
+
const worstMs = histogram.max / 1e6;
|
|
94278
|
+
histogram.reset();
|
|
94279
|
+
note(worstMs);
|
|
94280
|
+
}, SAMPLE_MS);
|
|
94281
|
+
timer.unref();
|
|
94282
|
+
return () => {
|
|
94283
|
+
clearInterval(timer);
|
|
94284
|
+
histogram.disable();
|
|
94285
|
+
};
|
|
94286
|
+
}
|
|
94287
|
+
var BLOCKED_THRESHOLD_MS, BLOCKED_LOG_GAP_MS, SAMPLE_MS;
|
|
94288
|
+
var init_event_loop_monitor = __esm({
|
|
94289
|
+
"src/runtime/event-loop-monitor.ts"() {
|
|
94290
|
+
"use strict";
|
|
94291
|
+
init_lifecycle_log();
|
|
94292
|
+
BLOCKED_THRESHOLD_MS = 100;
|
|
94293
|
+
BLOCKED_LOG_GAP_MS = 1e4;
|
|
94294
|
+
SAMPLE_MS = 1e3;
|
|
94295
|
+
}
|
|
94296
|
+
});
|
|
94297
|
+
|
|
93873
94298
|
// src/session/state/sweep.ts
|
|
93874
94299
|
import { stat as stat59, utimes as utimes4, writeFile as writeFile31 } from "node:fs/promises";
|
|
93875
94300
|
import { join as join103 } from "node:path";
|
|
@@ -94158,9 +94583,9 @@ async function prepareTurn(targetId) {
|
|
|
94158
94583
|
}
|
|
94159
94584
|
async function afterTurnFailure(prompter, id, error, turn) {
|
|
94160
94585
|
const cancelled = isTurnCancelled(error);
|
|
94161
|
-
const
|
|
94162
|
-
if (
|
|
94163
|
-
const back =
|
|
94586
|
+
const queued2 = Boolean(turn.queuedTurnId && !cancelled);
|
|
94587
|
+
if (queued2) await releaseQueuedTurn(id, turn.queuedTurnId).catch(quiet("session/attach"));
|
|
94588
|
+
const back = queued2 && turn.line ? [turn.line] : [];
|
|
94164
94589
|
const message2 = error instanceof Error ? error.message : String(error);
|
|
94165
94590
|
if (cancelled || !prompter || !turn.line || !isUsageExhaustedMessage(message2)) return { cancelled, back };
|
|
94166
94591
|
const next = await carryOnAfterExhaustion(prompter, id, turn.line, turn.guard, turn.sent ?? turn.line);
|
|
@@ -94438,7 +94863,7 @@ var init_credit_label = __esm({
|
|
|
94438
94863
|
});
|
|
94439
94864
|
|
|
94440
94865
|
// src/commands/ai/build-replace.ts
|
|
94441
|
-
import { spawnSync as
|
|
94866
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
94442
94867
|
import { stdout } from "node:process";
|
|
94443
94868
|
function relaunchArgv(entry2, sessionId) {
|
|
94444
94869
|
return sessionId ? [entry2, "sessions", "resume", sessionId] : [entry2];
|
|
@@ -94454,26 +94879,38 @@ function replaceCliWithNewBuild(input11) {
|
|
|
94454
94879
|
await input11.release();
|
|
94455
94880
|
} catch {
|
|
94456
94881
|
}
|
|
94882
|
+
const handOverTyped = () => {
|
|
94883
|
+
let text7 = "";
|
|
94884
|
+
try {
|
|
94885
|
+
text7 = input11.typed?.() ?? "";
|
|
94886
|
+
} catch {
|
|
94887
|
+
}
|
|
94888
|
+
if (text7) process.env[REEXEC_TYPED_ENV] = text7;
|
|
94889
|
+
else delete process.env[REEXEC_TYPED_ENV];
|
|
94890
|
+
};
|
|
94457
94891
|
if (typeof process.execve === "function") {
|
|
94458
|
-
await new Promise((resolve14) => stdout.write(
|
|
94892
|
+
await new Promise((resolve14) => stdout.write(popReadModes(), () => resolve14()));
|
|
94459
94893
|
await fileLocksIdle();
|
|
94894
|
+
handOverTyped();
|
|
94460
94895
|
try {
|
|
94461
94896
|
process.execve(
|
|
94462
94897
|
process.execPath,
|
|
94463
94898
|
[process.execPath, ...relaunchArgv(entry2, sessionId)],
|
|
94464
|
-
{ ...process.env, [REEXEC_TERMINAL_ENV]:
|
|
94899
|
+
{ ...process.env, [REEXEC_TERMINAL_ENV]: reexecHandover() }
|
|
94465
94900
|
);
|
|
94466
94901
|
} catch {
|
|
94467
94902
|
}
|
|
94468
94903
|
}
|
|
94904
|
+
historyDump.suppressed = true;
|
|
94469
94905
|
try {
|
|
94470
94906
|
input11.closeUi();
|
|
94471
94907
|
} catch {
|
|
94472
94908
|
}
|
|
94473
94909
|
await fileLocksIdle();
|
|
94910
|
+
handOverTyped();
|
|
94474
94911
|
let status3 = 1;
|
|
94475
94912
|
try {
|
|
94476
|
-
const result =
|
|
94913
|
+
const result = spawnSync2(process.execPath, relaunchArgv(entry2, sessionId), { stdio: "inherit" });
|
|
94477
94914
|
status3 = result.status ?? 1;
|
|
94478
94915
|
} finally {
|
|
94479
94916
|
process.exit(status3);
|
|
@@ -94487,6 +94924,7 @@ var init_build_replace2 = __esm({
|
|
|
94487
94924
|
"use strict";
|
|
94488
94925
|
init_locks();
|
|
94489
94926
|
init_restore();
|
|
94927
|
+
init_modes();
|
|
94490
94928
|
init_ephemeral();
|
|
94491
94929
|
}
|
|
94492
94930
|
});
|
|
@@ -95042,11 +95480,15 @@ __export(connection_exports, {
|
|
|
95042
95480
|
tapWindowMachine: () => tapWindowMachine
|
|
95043
95481
|
});
|
|
95044
95482
|
import { randomUUID as randomUUID47 } from "node:crypto";
|
|
95483
|
+
import { networkInterfaces as networkInterfaces2 } from "node:os";
|
|
95045
95484
|
import { createInterface as createInterface4 } from "node:readline";
|
|
95046
95485
|
function needsUpdate(ready, localCommit = localBuildCommit()) {
|
|
95047
95486
|
if (ready.protocol !== void 0 && ready.protocol !== IDE_PROTOCOL.version) return true;
|
|
95048
95487
|
return Boolean(ready.commit && localCommit && ready.commit !== localCommit);
|
|
95049
95488
|
}
|
|
95489
|
+
function networkSignature() {
|
|
95490
|
+
return JSON.stringify(Object.values(networkInterfaces2()).flatMap((list2) => (list2 ?? []).filter((i) => !i.internal).map((i) => i.address)).sort());
|
|
95491
|
+
}
|
|
95050
95492
|
function holdWindowMachines(use2 = {}, options2 = {}) {
|
|
95051
95493
|
windowMachines ??= new RemoteMachines(options2, true);
|
|
95052
95494
|
return windowMachines.hold(use2);
|
|
@@ -95070,7 +95512,7 @@ async function closeWindowMachines() {
|
|
|
95070
95512
|
windowMachines = void 0;
|
|
95071
95513
|
await machines?.close();
|
|
95072
95514
|
}
|
|
95073
|
-
var CHAT, READY_TIMEOUT_MS, REQUEST_TIMEOUT_MS3, STDERR_KEEP2, BACKOFF_MS, CACHE_WRITE_MS, RemoteLink, RemoteMachines, windowMachines;
|
|
95515
|
+
var CHAT, READY_TIMEOUT_MS, REQUEST_TIMEOUT_MS3, STDERR_KEEP2, BACKOFF_MS, NETWORK_POLL_MS, CACHE_WRITE_MS, RemoteLink, RemoteMachines, windowMachines;
|
|
95074
95516
|
var init_connection = __esm({
|
|
95075
95517
|
"src/remote/connection.ts"() {
|
|
95076
95518
|
"use strict";
|
|
@@ -95087,7 +95529,8 @@ var init_connection = __esm({
|
|
|
95087
95529
|
READY_TIMEOUT_MS = 3e4;
|
|
95088
95530
|
REQUEST_TIMEOUT_MS3 = 6e4;
|
|
95089
95531
|
STDERR_KEEP2 = 16e3;
|
|
95090
|
-
BACKOFF_MS = [1e3, 2e3, 5e3, 1e4, 3e4];
|
|
95532
|
+
BACKOFF_MS = [1e3, 2e3, 5e3, 1e4, 3e4, 6e4, 12e4, 24e4, 48e4, 6e5];
|
|
95533
|
+
NETWORK_POLL_MS = 3e4;
|
|
95091
95534
|
CACHE_WRITE_MS = 5e3;
|
|
95092
95535
|
RemoteLink = class {
|
|
95093
95536
|
constructor(machine, changed, options2 = {}) {
|
|
@@ -95144,6 +95587,7 @@ var init_connection = __esm({
|
|
|
95144
95587
|
/** When the connection being made began: how long a host takes to say it is ready is the number that says the link is slow. */
|
|
95145
95588
|
connectedAt = 0;
|
|
95146
95589
|
connect() {
|
|
95590
|
+
this.stopNetworkWatch();
|
|
95147
95591
|
const machine = this.view.machine;
|
|
95148
95592
|
this.connectedAt = Date.now();
|
|
95149
95593
|
lifecycle("remote.connect", { machine: machine.name, attempt: this.attempt });
|
|
@@ -95221,6 +95665,30 @@ ${error.message}`;
|
|
|
95221
95665
|
this.connect();
|
|
95222
95666
|
}, wait);
|
|
95223
95667
|
this.retry.unref();
|
|
95668
|
+
if (wait >= NETWORK_POLL_MS * 2) {
|
|
95669
|
+
const signature2 = this.options.networkSignature ?? networkSignature;
|
|
95670
|
+
const before = signature2();
|
|
95671
|
+
this.netWatch = setInterval(() => {
|
|
95672
|
+
if (signature2() === before) return;
|
|
95673
|
+
this.stopNetworkWatch();
|
|
95674
|
+
clearTimeout(this.retry);
|
|
95675
|
+
this.retry = void 0;
|
|
95676
|
+
if (this.stopped || !this.wanted()) {
|
|
95677
|
+
this.parked = !this.stopped;
|
|
95678
|
+
return;
|
|
95679
|
+
}
|
|
95680
|
+
this.attempt = 0;
|
|
95681
|
+
lifecycle("remote.network-changed", { machine: this.view.machine.name });
|
|
95682
|
+
this.set({ state: "connecting", error: void 0 });
|
|
95683
|
+
this.connect();
|
|
95684
|
+
}, NETWORK_POLL_MS);
|
|
95685
|
+
this.netWatch.unref();
|
|
95686
|
+
}
|
|
95687
|
+
}
|
|
95688
|
+
netWatch;
|
|
95689
|
+
stopNetworkWatch() {
|
|
95690
|
+
if (this.netWatch) clearInterval(this.netWatch);
|
|
95691
|
+
this.netWatch = void 0;
|
|
95224
95692
|
}
|
|
95225
95693
|
/** A list shows the machine again: one offline is tried at once, not after
|
|
95226
95694
|
* its pause (as a fresh connection would be); one connected is left as is. */
|
|
@@ -95468,6 +95936,7 @@ ${error.message}`;
|
|
|
95468
95936
|
async stop() {
|
|
95469
95937
|
this.stopped = true;
|
|
95470
95938
|
clearTimeout(this.retry);
|
|
95939
|
+
this.stopNetworkWatch();
|
|
95471
95940
|
clearTimeout(this.readyTimer);
|
|
95472
95941
|
const child = this.child;
|
|
95473
95942
|
this.child = void 0;
|
|
@@ -95678,6 +96147,8 @@ async function openWindow(config2, startId) {
|
|
|
95678
96147
|
return conversationCommands(target, ref.paletteState);
|
|
95679
96148
|
};
|
|
95680
96149
|
const terminal = terminalUiSupported() ? new TerminalHarnessPrompter() : void 0;
|
|
96150
|
+
const handedTyped = adoptHandedOverTyped();
|
|
96151
|
+
if (terminal && handedTyped) terminal.restoreDraft(handedTyped);
|
|
95681
96152
|
const rl = terminal ?? createInterface5({
|
|
95682
96153
|
input: input10,
|
|
95683
96154
|
output: output22,
|
|
@@ -95781,6 +96252,7 @@ function startBuildWatch(terminal, ref, refreshUsage, stopLockNotices) {
|
|
|
95781
96252
|
sessionId,
|
|
95782
96253
|
...draft ? { draft } : {},
|
|
95783
96254
|
closeUi: () => terminal.close(),
|
|
96255
|
+
typed: () => terminal.composer.text,
|
|
95784
96256
|
release: async () => {
|
|
95785
96257
|
await releaseWindow();
|
|
95786
96258
|
await releaseConversationClaim(sessionId).catch(quiet("commands/ai/interactive/window"));
|
|
@@ -98242,7 +98714,7 @@ async function runRemoteChat(terminal, localId, first2, firstDraft, startBridge2
|
|
|
98242
98714
|
commandsFor = key3;
|
|
98243
98715
|
};
|
|
98244
98716
|
const submissions = /* @__PURE__ */ new Map();
|
|
98245
|
-
const
|
|
98717
|
+
const queued2 = async (text7, windowId) => {
|
|
98246
98718
|
const id = windowId ?? randomUUID49();
|
|
98247
98719
|
const submission = { id, text: text7, submittedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
98248
98720
|
const answered = new Promise((resolve14, reject) => {
|
|
@@ -98265,7 +98737,7 @@ async function runRemoteChat(terminal, localId, first2, firstDraft, startBridge2
|
|
|
98265
98737
|
};
|
|
98266
98738
|
const windowCommandOrQueued = async (text7, windowId) => {
|
|
98267
98739
|
const own = resolveSlashCommand(parseSlashInput(text7)?.head ?? "")?.name;
|
|
98268
|
-
if (own !== "restart" && own !== "send") return
|
|
98740
|
+
if (own !== "restart" && own !== "send") return queued2(text7, windowId);
|
|
98269
98741
|
const submission = { id: windowId ?? randomUUID49(), text: text7, submittedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
98270
98742
|
if (own === "restart") {
|
|
98271
98743
|
const leaving = replaceWindowBuild();
|
|
@@ -98311,7 +98783,7 @@ async function runRemoteChat(terminal, localId, first2, firstDraft, startBridge2
|
|
|
98311
98783
|
terminal.startWaiting(
|
|
98312
98784
|
label3,
|
|
98313
98785
|
(restoreDraft) => bridge.post({ type: "cancel", restoreDraft }),
|
|
98314
|
-
|
|
98786
|
+
queued2,
|
|
98315
98787
|
windowCommandOrQueued,
|
|
98316
98788
|
leave,
|
|
98317
98789
|
// Esc on a waiting message takes that message back, and does not stop the turn; "Enter again" offers it to the running turn now.
|
|
@@ -98668,6 +99140,9 @@ async function runRemoteChat(terminal, localId, first2, firstDraft, startBridge2
|
|
|
98668
99140
|
if (!/^[/!]/.test(line3)) setupSession = void 0;
|
|
98669
99141
|
const complete = new Promise((resolve14, reject) => completions.set(id, { resolve: resolve14, reject }));
|
|
98670
99142
|
sending = line3;
|
|
99143
|
+
const stepped = new Promise((resolve14) => {
|
|
99144
|
+
wakeLeave = resolve14;
|
|
99145
|
+
});
|
|
98671
99146
|
if (!/^[/!]/.test(line3)) {
|
|
98672
99147
|
early = line3;
|
|
98673
99148
|
typed.set(id, line3);
|
|
@@ -98693,9 +99168,6 @@ async function runRemoteChat(terminal, localId, first2, firstDraft, startBridge2
|
|
|
98693
99168
|
dropEarly();
|
|
98694
99169
|
throw error;
|
|
98695
99170
|
}
|
|
98696
|
-
const stepped = new Promise((resolve14) => {
|
|
98697
|
-
wakeLeave = resolve14;
|
|
98698
|
-
});
|
|
98699
99171
|
await Promise.race([complete, stepped]);
|
|
98700
99172
|
wakeLeave = void 0;
|
|
98701
99173
|
sending = void 0;
|
|
@@ -99888,8 +100360,8 @@ var init_loop = __esm({
|
|
|
99888
100360
|
let line3;
|
|
99889
100361
|
let queuedTurnId;
|
|
99890
100362
|
let fromQueuedCommand = false;
|
|
99891
|
-
let
|
|
99892
|
-
if (terminal?.takeStopped() && !running4 && !this.openBoard &&
|
|
100363
|
+
let queued2 = latest3.queuedTurns?.[0];
|
|
100364
|
+
if (terminal?.takeStopped() && !running4 && !this.openBoard && queued2 && queued2.kind !== "command" && queued2.kind !== "notification") {
|
|
99893
100365
|
const back = [];
|
|
99894
100366
|
for (const entry2 of [...latest3.queuedTurns ?? []]) {
|
|
99895
100367
|
if (entry2.kind === "command" || entry2.kind === "notification") continue;
|
|
@@ -99899,7 +100371,7 @@ var init_loop = __esm({
|
|
|
99899
100371
|
await writeState(latestState);
|
|
99900
100372
|
terminal.restoreDraft([terminal.queuedDraft, ...back].filter(Boolean).join("\n"));
|
|
99901
100373
|
}
|
|
99902
|
-
|
|
100374
|
+
queued2 = latest3.queuedTurns?.[0];
|
|
99903
100375
|
}
|
|
99904
100376
|
if (this.openBoard) {
|
|
99905
100377
|
this.openBoard = false;
|
|
@@ -100070,6 +100542,7 @@ async function aiSessionInteractive(config2, id) {
|
|
|
100070
100542
|
process.on("SIGINT", ignoreInterrupt);
|
|
100071
100543
|
setLifecycleRole("window", id);
|
|
100072
100544
|
lifecycle("window.open", { cols: process.stdout.columns, rows: process.stdout.rows, tty: Boolean(process.stdin.isTTY) });
|
|
100545
|
+
const stopMonitor = startEventLoopMonitor();
|
|
100073
100546
|
try {
|
|
100074
100547
|
await aiSessionInteractiveInner(config2, id);
|
|
100075
100548
|
lifecycle("window.exit", { how: "left" });
|
|
@@ -100077,6 +100550,7 @@ async function aiSessionInteractive(config2, id) {
|
|
|
100077
100550
|
lifecycle("window.exit", { how: "error", message: error instanceof Error ? error.message.slice(0, 300) : String(error) });
|
|
100078
100551
|
throw error;
|
|
100079
100552
|
} finally {
|
|
100553
|
+
stopMonitor();
|
|
100080
100554
|
process.off("SIGINT", ignoreInterrupt);
|
|
100081
100555
|
}
|
|
100082
100556
|
}
|
|
@@ -100090,6 +100564,7 @@ var init_interactive = __esm({
|
|
|
100090
100564
|
"src/commands/ai/interactive.ts"() {
|
|
100091
100565
|
"use strict";
|
|
100092
100566
|
init_lifecycle_log();
|
|
100567
|
+
init_event_loop_monitor();
|
|
100093
100568
|
init_ephemeral();
|
|
100094
100569
|
init_attach();
|
|
100095
100570
|
init_window();
|
|
@@ -105289,13 +105764,13 @@ var init_bridge_turns = __esm({
|
|
|
105289
105764
|
const session2 = state.sessions.find((item) => item.id === this.host.sessionId);
|
|
105290
105765
|
const next = session2 ? queuedNext(session2, { stopped: this.host.link.stopped, ...previous ? { justRan: previous } : {} }) : void 0;
|
|
105291
105766
|
if (!session2 || !next) return;
|
|
105292
|
-
const
|
|
105293
|
-
previous =
|
|
105767
|
+
const queued2 = next.entry;
|
|
105768
|
+
previous = queued2.id;
|
|
105294
105769
|
if (next.kind === "command") {
|
|
105295
|
-
if (consumeSessionTurn(session2,
|
|
105296
|
-
await this.host.execute(
|
|
105770
|
+
if (consumeSessionTurn(session2, queued2.id)) await writeState(state);
|
|
105771
|
+
await this.host.execute(queued2.text, { fromQueuedCommand: true });
|
|
105297
105772
|
} else {
|
|
105298
|
-
await this.host.execute(
|
|
105773
|
+
await this.host.execute(queued2.text, { queuedTurnId: queued2.id });
|
|
105299
105774
|
}
|
|
105300
105775
|
}
|
|
105301
105776
|
}
|
|
@@ -105421,14 +105896,14 @@ var init_bridge_turns = __esm({
|
|
|
105421
105896
|
|
|
105422
105897
|
// src/ide/bridge-choose-conversation.ts
|
|
105423
105898
|
async function chooseConversation(cx, choice) {
|
|
105424
|
-
const { host, queued } = cx;
|
|
105899
|
+
const { host, queued: queued2 } = cx;
|
|
105425
105900
|
switch (choice.kind) {
|
|
105426
105901
|
case "conversation": {
|
|
105427
105902
|
const current5 = choice.sessionId === host.sessionId;
|
|
105428
105903
|
if (current5 && host.link.workerTurnRunning && choice.action === "delete") {
|
|
105429
105904
|
throw new Error("A turn is running in this conversation: stop it first.");
|
|
105430
105905
|
}
|
|
105431
|
-
|
|
105906
|
+
queued2(async () => {
|
|
105432
105907
|
const replacement = current5 && choice.action === "delete" ? await newConversation(choice.sessionId) : void 0;
|
|
105433
105908
|
if (choice.action === "rename") {
|
|
105434
105909
|
const name = choice.name?.trim();
|
|
@@ -105455,10 +105930,10 @@ var init_bridge_choose_conversation = __esm({
|
|
|
105455
105930
|
|
|
105456
105931
|
// src/ide/bridge-choose-provider.ts
|
|
105457
105932
|
async function chooseProvider(cx, choice) {
|
|
105458
|
-
const { host, done, queued } = cx;
|
|
105933
|
+
const { host, done, queued: queued2 } = cx;
|
|
105459
105934
|
switch (choice.kind) {
|
|
105460
105935
|
case "provider": {
|
|
105461
|
-
|
|
105936
|
+
queued2(async () => {
|
|
105462
105937
|
const id = host.requireSession();
|
|
105463
105938
|
const moved = await selectProviderConversation(host.config, host.prompter, id, providerConversationKey(choice.provider), { offerLocal: true });
|
|
105464
105939
|
if (choice.model) {
|
|
@@ -105475,7 +105950,7 @@ async function chooseProvider(cx, choice) {
|
|
|
105475
105950
|
return true;
|
|
105476
105951
|
}
|
|
105477
105952
|
case "hosted":
|
|
105478
|
-
|
|
105953
|
+
queued2(async () => {
|
|
105479
105954
|
const selection = await hostedAdapter(choice.row.target).start(choice.row);
|
|
105480
105955
|
const id = host.requireSession();
|
|
105481
105956
|
const moved = selection.route === "gateway" ? await selectProviderConversation(host.config, host.prompter, id, providerConversationKey(GATEWAY_ID)) : id;
|
|
@@ -105489,7 +105964,7 @@ async function chooseProvider(cx, choice) {
|
|
|
105489
105964
|
});
|
|
105490
105965
|
return true;
|
|
105491
105966
|
case "add-account":
|
|
105492
|
-
|
|
105967
|
+
queued2(async () => {
|
|
105493
105968
|
const harness = localHarnessForCommand(choice.provider);
|
|
105494
105969
|
if (!harness) throw new Error(`unknown provider "${choice.provider}"`);
|
|
105495
105970
|
const added2 = await addAccountForHarness(host.prompter, harness);
|
|
@@ -105502,7 +105977,7 @@ async function chooseProvider(cx, choice) {
|
|
|
105502
105977
|
});
|
|
105503
105978
|
return true;
|
|
105504
105979
|
case "account-action":
|
|
105505
|
-
|
|
105980
|
+
queued2(async () => {
|
|
105506
105981
|
await manageAccountAction(host.prompter, choice.accountId, choice.action);
|
|
105507
105982
|
await host.emitSession().catch(quiet("ide/bridge-choose-provider"));
|
|
105508
105983
|
});
|
|
@@ -105626,7 +106101,7 @@ async function choose(host, requestId, choice) {
|
|
|
105626
106101
|
});
|
|
105627
106102
|
await host.emitSession();
|
|
105628
106103
|
};
|
|
105629
|
-
const
|
|
106104
|
+
const queued2 = (job) => {
|
|
105630
106105
|
host.enqueue(async () => {
|
|
105631
106106
|
try {
|
|
105632
106107
|
done(await quietly(job));
|
|
@@ -105635,7 +106110,7 @@ async function choose(host, requestId, choice) {
|
|
|
105635
106110
|
}
|
|
105636
106111
|
});
|
|
105637
106112
|
};
|
|
105638
|
-
const cx = { host, done, setting: setting2, queued };
|
|
106113
|
+
const cx = { host, done, setting: setting2, queued: queued2 };
|
|
105639
106114
|
try {
|
|
105640
106115
|
const routed = await routedChoice(host, choice);
|
|
105641
106116
|
if (await chooseSetting(cx, routed)) return;
|
|
@@ -106854,13 +107329,13 @@ function killCgroup(dir2) {
|
|
|
106854
107329
|
return false;
|
|
106855
107330
|
}
|
|
106856
107331
|
}
|
|
106857
|
-
var
|
|
107332
|
+
var KEEP3, isKept, boot, realReaders;
|
|
106858
107333
|
var init_cgroup_inspect = __esm({
|
|
106859
107334
|
"src/worker/cgroup-inspect.ts"() {
|
|
106860
107335
|
"use strict";
|
|
106861
107336
|
init_command_groups();
|
|
106862
|
-
|
|
106863
|
-
isKept = (commandLine3) => !!commandLine3 && (commandLine3.includes(
|
|
107337
|
+
KEEP3 = "clikcode:keep";
|
|
107338
|
+
isKept = (commandLine3) => !!commandLine3 && (commandLine3.includes(KEEP3) || /\bcomputer-host\b/.test(commandLine3));
|
|
106864
107339
|
realReaders = {
|
|
106865
107340
|
pids: groupPids,
|
|
106866
107341
|
startedAt: (pid) => {
|
|
@@ -107234,7 +107709,7 @@ async function installViaOfficialScript(deps, version) {
|
|
|
107234
107709
|
if (!response.ok) throw new Error(`Could not download Cua's installer from ${OFFICIAL_INSTALLER} (HTTP ${response.status}).`);
|
|
107235
107710
|
const script = await response.text();
|
|
107236
107711
|
deps.log(`running Cua's macOS installer, pinned to ${version}`);
|
|
107237
|
-
const code = await deps.runVisible("/bin/bash", ["-c", script, "cua-driver-install"],
|
|
107712
|
+
const code = await deps.runVisible("/bin/bash", ["-c", script, "cua-driver-install"], installerEnv(deps.env, { CUA_DRIVER_RS_VERSION: version }));
|
|
107238
107713
|
if (code !== 0) throw new Error(`Cua's installer exited with ${code}.`);
|
|
107239
107714
|
return { action: "delegated", version, notes: ["Accessibility and Screen Recording must be granted once: run `cua-driver permissions grant`."] };
|
|
107240
107715
|
}
|
|
@@ -107348,6 +107823,7 @@ var DRIVER_REPO, TAG_PREFIX, WITHDRAWN, CHECKSUMS_REQUIRED_FROM, COSIGN_ISSUER,
|
|
|
107348
107823
|
var init_driver_install = __esm({
|
|
107349
107824
|
"src/agent/computer/driver-install.ts"() {
|
|
107350
107825
|
"use strict";
|
|
107826
|
+
init_installer_env();
|
|
107351
107827
|
init_lifecycle_log();
|
|
107352
107828
|
init_driver();
|
|
107353
107829
|
DRIVER_REPO = "trycua/cua";
|
|
@@ -107487,7 +107963,7 @@ async function exploreForKeys(deps, start2, options2 = {}) {
|
|
|
107487
107963
|
const visited = [...options2.seen ?? []];
|
|
107488
107964
|
const menus = [...options2.seenMenus ?? []];
|
|
107489
107965
|
const tried = /* @__PURE__ */ new Set();
|
|
107490
|
-
const
|
|
107966
|
+
const queued2 = /* @__PURE__ */ new Set();
|
|
107491
107967
|
const frontier = [];
|
|
107492
107968
|
let pages = 0;
|
|
107493
107969
|
let current5 = start2;
|
|
@@ -107502,8 +107978,8 @@ async function exploreForKeys(deps, start2, options2 = {}) {
|
|
|
107502
107978
|
const enqueue2 = (c, from, rank, via) => {
|
|
107503
107979
|
const href = httpsHref(c);
|
|
107504
107980
|
const key3 = href ? pathOf(href) : `${via ?? ""}>${c.name}`;
|
|
107505
|
-
if (
|
|
107506
|
-
|
|
107981
|
+
if (queued2.has(key3) || href && visited.includes(pathOf(href))) return;
|
|
107982
|
+
queued2.add(key3);
|
|
107507
107983
|
frontier.push({ name: c.name, ...href ? { href } : {}, from, ...via ? { via } : {}, rank });
|
|
107508
107984
|
frontier.sort((a2, b) => a2.rank - b.rank);
|
|
107509
107985
|
};
|
|
@@ -115682,10 +116158,11 @@ function handleCommandError(error) {
|
|
|
115682
116158
|
}
|
|
115683
116159
|
var TERMINAL_ENVIRONMENT_HELP = `
|
|
115684
116160
|
Terminal environment:
|
|
115685
|
-
CLIKCODE_INLINE=1
|
|
115686
|
-
|
|
115687
|
-
|
|
115688
|
-
|
|
116161
|
+
CLIKCODE_INLINE=1 Inline-history mode: the conversation is printed into the terminal's own scrollback and only
|
|
116162
|
+
the composer is redrawn. Unset: full-screen everywhere (the alternate screen; the conversation
|
|
116163
|
+
is written into your scrollback when ClikCode ends or is suspended).
|
|
116164
|
+
CLIKCODE_MOUSE=1 Ask the terminal for mouse reporting (wheel and its own selection). Unset: none, so the
|
|
116165
|
+
terminal's selection and copy work; PageUp, PageDown, Home, End and the arrows scroll.
|
|
115689
116166
|
CLIKCODE_ASCII=1|0 Force ASCII rules, box drawing and spinner on or off. Unset: on when the locale
|
|
115690
116167
|
(LC_ALL, LC_CTYPE, LANG) is not UTF-8 or TERM=linux.
|
|
115691
116168
|
CLIKCODE_TUI=classic Line-oriented output instead of the live terminal UI.
|