zidane-gui 9.1.3 → 9.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/main/index.js +128 -88
- package/out/preload/index.mjs +21 -4
- package/out/renderer/assets/{43YPWK3Q-BLwohgFu.js → 43YPWK3Q-z5jpEo82.js} +6 -6
- package/out/renderer/assets/{45MVAN6X-DCPmrh2y.js → 45MVAN6X-GiMurZcH.js} +5 -5
- package/out/renderer/assets/{46GJKBLZ-n_NiMQEY.js → 46GJKBLZ-BK9JvL-z.js} +10 -10
- package/out/renderer/assets/{63WH7YNF-B0-gnOSz.js → 63WH7YNF-oZNJFk32.js} +8 -8
- package/out/renderer/assets/{6DDU7VKX-BKAF5gyQ.js → 6DDU7VKX-Q8ape99y.js} +6 -6
- package/out/renderer/assets/{CLQLV5VT-BIZsXon4.js → CLQLV5VT-1CokruIk.js} +6 -6
- package/out/renderer/assets/{CUSPXG5M-Donlp74Y.js → CUSPXG5M-CXI47Yx3.js} +6 -6
- package/out/renderer/assets/{CodeEditor-80QT2Pyq.js → CodeEditor-D8TMSvb4.js} +3 -3
- package/out/renderer/assets/{ComposerEditor-CXpNHoo1.js → ComposerEditor-MwH3w7kQ.js} +2 -2
- package/out/renderer/assets/{D3L7O4X2-BCbmkNpB.js → D3L7O4X2-CZlDY3Xj.js} +4 -4
- package/out/renderer/assets/{D5TW5CPZ-Bp-wetYa.js → D5TW5CPZ-C04jssFu.js} +1 -1
- package/out/renderer/assets/{DiffsTab-Dy8a_hwG.js → DiffsTab-CD4Z6LsX.js} +5 -5
- package/out/renderer/assets/{EGADTWYV-CqSrkc7g.js → EGADTWYV-C6IiGlh0.js} +5 -5
- package/out/renderer/assets/{EOJSJZXM-BTI84tys.js → EOJSJZXM-Bw1Qp21K.js} +8 -8
- package/out/renderer/assets/{EditorWorkers-Durn1REy.js → EditorWorkers-D0xeQ5Kf.js} +4 -4
- package/out/renderer/assets/{FilesTab-h32FFVsw.js → FilesTab-Pp8_PSfd.js} +6 -6
- package/out/renderer/assets/{G2OEIG6X-CS8YUqSL.js → G2OEIG6X-foim2Z_m.js} +5 -5
- package/out/renderer/assets/{GXJ2T77W-BHaQFzB4.js → GXJ2T77W-FIOAlHlR.js} +6 -6
- package/out/renderer/assets/{HX3UMAK7-DOOY2pSg.js → HX3UMAK7-COan20yP.js} +5 -5
- package/out/renderer/assets/{IU7WZTP6-D7pwhQLH.js → IU7WZTP6-DeXscWir.js} +1 -1
- package/out/renderer/assets/{J5J2NR2G-SPjkbJgo.js → J5J2NR2G-B7up1iuZ.js} +4 -4
- package/out/renderer/assets/{JRCWTJEL-DT7JLR7k.js → JRCWTJEL-M4z7DV1k.js} +3 -3
- package/out/renderer/assets/{KHUP5TOH-BX0A2YHC.js → KHUP5TOH-0CDf31VX.js} +1 -1
- package/out/renderer/assets/{L74FQTH5-MbDLfIZo.js → L74FQTH5-xlC3E1u8.js} +4 -4
- package/out/renderer/assets/{LAV4ZXOS-ClHlsIHg.js → LAV4ZXOS-CWOm214F.js} +6 -6
- package/out/renderer/assets/{LBIZYCRR-DmofT7Vk.js → LBIZYCRR-BRMO_zpo.js} +7 -7
- package/out/renderer/assets/{LFFXNLRS-yLLLefJM.js → LFFXNLRS-CQDwxn8S.js} +3 -3
- package/out/renderer/assets/{LLLWOAQD-DNhT1-qV.js → LLLWOAQD-NLayfyRk.js} +1 -1
- package/out/renderer/assets/{LTYQZ5U5-BxUtiilS.js → LTYQZ5U5-CfgFK_8S.js} +8 -8
- package/out/renderer/assets/{NDSCUZ25-DltJ5xGa.js → NDSCUZ25-CRhHG4rp.js} +2 -2
- package/out/renderer/assets/{NMN3IKWL-BXUYzi9o.js → NMN3IKWL-pNFku5nG.js} +9 -9
- package/out/renderer/assets/{NMUA3R2D-CAVxt8OJ.js → NMUA3R2D-D5EpYecE.js} +7 -7
- package/out/renderer/assets/{NY5A6PPW-B3P5KUoQ.js → NY5A6PPW-BFqrOF96.js} +3 -3
- package/out/renderer/assets/{OHJ2EJXK-CKyEtj37.js → OHJ2EJXK-DUXRo20H.js} +1 -1
- package/out/renderer/assets/{OU2GIT2H-i9HfUuBk.js → OU2GIT2H-RERREQg4.js} +4 -4
- package/out/renderer/assets/{PDMLSE6I-BnbSSXbG.js → PDMLSE6I-B6VLJpYF.js} +2 -2
- package/out/renderer/assets/{PJ7X32S5-Do_rplzd.js → PJ7X32S5-CiX4IRfi.js} +5 -5
- package/out/renderer/assets/{RLLQ44NJ-SEvjKAya.js → RLLQ44NJ-DI-w7C3g.js} +7 -7
- package/out/renderer/assets/{S6DWMCK5-CK9P5x9H.js → S6DWMCK5-BFYfpKyU.js} +8 -8
- package/out/renderer/assets/{STIOTUT7-KYZS5tvF.js → STIOTUT7-BsXqNDoB.js} +6 -6
- package/out/renderer/assets/{SXSLPWUD-ylCpsia5.js → SXSLPWUD-DsiZBZ2L.js} +2 -2
- package/out/renderer/assets/{TR4WJQGX-DXlqK6NQ.js → TR4WJQGX-DdGw5EgP.js} +1 -1
- package/out/renderer/assets/{UWRPUF3N-7_KSfEv0.js → UWRPUF3N-B9f5cVuf.js} +1 -1
- package/out/renderer/assets/{VSWIZJ7B-qmPn48eQ.js → VSWIZJ7B-B67GWWkR.js} +1 -1
- package/out/renderer/assets/{WM7NR6YK-D4oWq6L3.js → WM7NR6YK-BjDcbecJ.js} +4 -4
- package/out/renderer/assets/{WXKV2YEK-DsK-bqP8.js → WXKV2YEK-DkO54WUi.js} +3 -3
- package/out/renderer/assets/{XLHPVVFU-4_9lhZe2.js → XLHPVVFU-CgBgWtsm.js} +1 -1
- package/out/renderer/assets/{YNX532HU-C1DPijVc.js → YNX532HU-GZs01vUI.js} +5 -5
- package/out/renderer/assets/{YUPSMAUO-0pM5w-ie.js → YUPSMAUO-3HW0N7cY.js} +1 -1
- package/out/renderer/assets/{ZFRCZTLK-4EIJek0V.js → ZFRCZTLK-Bv3j48XJ.js} +6 -6
- package/out/renderer/assets/{ZZDR4CN3-B_T2R-Zh.js → ZZDR4CN3-bxop59us.js} +4 -4
- package/out/renderer/assets/{core-2jWUG3m-.js → core-DUTJyMGZ.js} +1967 -1624
- package/out/renderer/assets/{file-tabs-DwqRIh1X.js → file-tabs-CDruoNmZ.js} +5 -5
- package/out/renderer/assets/{ghostty-web-DnI2p8KS.js → ghostty-web-CtIJ7i7e.js} +1 -1
- package/out/renderer/assets/{highlights-6LT5DvBO.js → highlights-26TXpsMP.js} +2 -2
- package/out/renderer/assets/{highlights-DmxOEap0.js → highlights-Bmhv1Dz1.js} +3 -3
- package/out/renderer/assets/{index-C-Dal-Bp.css → index-B5DcyIyT.css} +41 -2
- package/out/renderer/assets/{index-BnnCv70H.js → index-CpGbxp8B.js} +244 -40
- package/out/renderer/assets/{kit-CdRTRA2T.js → kit-u_PHwNWF.js} +3531 -1044
- package/out/renderer/assets/{langs-D9nZatrh.js → langs-DQ-AW7Q8.js} +1 -1
- package/out/renderer/assets/{lazy-C1DShJVi.js → lazy-xGoFzwfG.js} +3 -3
- package/out/renderer/assets/{loader-BlmA-DDi.js → loader-BwgXVB75.js} +1 -1
- package/out/renderer/assets/{pierre-theme-DpuLJ_93.js → pierre-theme-CwuG23St.js} +7 -7
- package/out/renderer/assets/{shiki-RupN-xqP.js → shiki-DCldjjSl.js} +3 -3
- package/out/renderer/assets/{stream-tokenizer-DLDzyMrK.js → stream-tokenizer-BJjKxfTj.js} +1 -1
- package/out/renderer/assets/{themes-B1aebwax.js → themes-Bt8pRd53.js} +2 -2
- package/out/renderer/assets/{useDetachCleanup-BXvhEVk-.js → useDetachCleanup-hiha0T2M.js} +2 -2
- package/out/renderer/assets/{useFolderChanges-BHQktE6l.js → useFolderChanges-AOk0dbsA.js} +144 -73
- package/out/renderer/index.html +4 -4
- package/package.json +2 -2
- package/scripts/app-installer.mjs +1 -1
|
@@ -130,6 +130,7 @@ const SESSION_FIELDS = {
|
|
|
130
130
|
"favorite": "boolean",
|
|
131
131
|
"isMain": "boolean",
|
|
132
132
|
"spaceId": "string",
|
|
133
|
+
"scheduleId": "string",
|
|
133
134
|
"providerKey": "string",
|
|
134
135
|
"modelId": "string",
|
|
135
136
|
"account": "string",
|
|
@@ -205,7 +206,7 @@ function readField(row, path) {
|
|
|
205
206
|
const field = parseFieldPath(path);
|
|
206
207
|
return field ? readParsedField(row, field) : void 0;
|
|
207
208
|
}
|
|
208
|
-
const UNIT_MS = {
|
|
209
|
+
const UNIT_MS$1 = {
|
|
209
210
|
s: 1e3,
|
|
210
211
|
m: 6e4,
|
|
211
212
|
h: 36e5,
|
|
@@ -222,7 +223,7 @@ function resolveTime(bound, now) {
|
|
|
222
223
|
if (typeof bound !== "string") return void 0;
|
|
223
224
|
if (bound === "now") return now;
|
|
224
225
|
const rel = RELATIVE.exec(bound);
|
|
225
|
-
if (rel) return now + (rel[1] === "-" ? -1 : 1) * Number(rel[2]) * UNIT_MS[rel[3]];
|
|
226
|
+
if (rel) return now + (rel[1] === "-" ? -1 : 1) * Number(rel[2]) * UNIT_MS$1[rel[3]];
|
|
226
227
|
if (!ISO_DATE.test(bound)) return void 0;
|
|
227
228
|
const zoned = /(?:Z|[+-]\d{2}:\d{2})$/.test(bound);
|
|
228
229
|
const ms = Date.parse(bound.length === 10 ? `${bound}T00:00:00Z` : zoned ? bound : `${bound}Z`);
|
|
@@ -1134,10 +1135,10 @@ function compileQuery(where, options = {}) {
|
|
|
1134
1135
|
const issues = validateQuery(where);
|
|
1135
1136
|
if (issues.length > 0) throw new SessionQueryError(issues);
|
|
1136
1137
|
const test = build(where);
|
|
1137
|
-
const
|
|
1138
|
+
const clock2 = clockOf(options);
|
|
1138
1139
|
return (row) => {
|
|
1139
1140
|
let at;
|
|
1140
|
-
return test(row, () => at ??=
|
|
1141
|
+
return test(row, () => at ??= clock2());
|
|
1141
1142
|
};
|
|
1142
1143
|
}
|
|
1143
1144
|
const collator$2 = new Intl.Collator("en", {
|
|
@@ -1764,511 +1765,1282 @@ function titleFromText(text) {
|
|
|
1764
1765
|
if (!line) return null;
|
|
1765
1766
|
return line.length > TITLE_FROM_TEXT_MAX ? `${line.slice(0, TITLE_FROM_TEXT_MAX)}…` : line;
|
|
1766
1767
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
const lowerText = lower(text);
|
|
1771
|
-
const phrase = findTermRanges(lowerText, parsed.phraseLower);
|
|
1772
|
-
if (phrase.length > 0) return mergeRanges(phrase, text.length);
|
|
1773
|
-
const exact = parsed.tokens.flatMap((token) => findTermRanges(lowerText, token.lower));
|
|
1774
|
-
if (exact.length > 0) return mergeRanges(exact, text.length);
|
|
1775
|
-
return mergeRanges(parsed.tokens.flatMap((token) => findFuzzyWordRange(lowerText, token.lower) ?? []), text.length);
|
|
1776
|
-
}
|
|
1777
|
-
function highlightSegments(text, ranges) {
|
|
1778
|
-
const normalized = mergeRanges(ranges, text.length);
|
|
1779
|
-
if (!normalized.length) return [{
|
|
1780
|
-
text,
|
|
1781
|
-
highlighted: false
|
|
1782
|
-
}];
|
|
1783
|
-
const segments = [];
|
|
1784
|
-
let cursor = 0;
|
|
1785
|
-
for (const range of normalized) {
|
|
1786
|
-
if (range.start > cursor) segments.push({
|
|
1787
|
-
text: text.slice(cursor, range.start),
|
|
1788
|
-
highlighted: false
|
|
1789
|
-
});
|
|
1790
|
-
if (range.end > range.start) segments.push({
|
|
1791
|
-
text: text.slice(range.start, range.end),
|
|
1792
|
-
highlighted: true
|
|
1793
|
-
});
|
|
1794
|
-
cursor = range.end;
|
|
1795
|
-
}
|
|
1796
|
-
if (cursor < text.length) segments.push({
|
|
1797
|
-
text: text.slice(cursor),
|
|
1798
|
-
highlighted: false
|
|
1799
|
-
});
|
|
1800
|
-
return segments.filter((segment) => segment.text.length > 0);
|
|
1801
|
-
}
|
|
1802
|
-
function parseQuery(query) {
|
|
1803
|
-
const tokens = tokenize(query);
|
|
1804
|
-
const phrase = tokens.map((token) => token.text).join(" ");
|
|
1805
|
-
return {
|
|
1806
|
-
tokens: tokens.map((token) => ({
|
|
1807
|
-
...token,
|
|
1808
|
-
lower: lower(token.text)
|
|
1809
|
-
})),
|
|
1810
|
-
phraseLower: lower(phrase)
|
|
1811
|
-
};
|
|
1812
|
-
}
|
|
1813
|
-
function tokenize(query) {
|
|
1814
|
-
const tokens = [];
|
|
1815
|
-
let i = 0;
|
|
1816
|
-
while (i < query.length) {
|
|
1817
|
-
while (i < query.length && /\s/u.test(query[i])) i += 1;
|
|
1818
|
-
if (i >= query.length) break;
|
|
1819
|
-
if (query[i] === '"') {
|
|
1820
|
-
const start2 = i + 1;
|
|
1821
|
-
i += 1;
|
|
1822
|
-
let value = "";
|
|
1823
|
-
while (i < query.length && query[i] !== '"') {
|
|
1824
|
-
value += query[i];
|
|
1825
|
-
i += 1;
|
|
1826
|
-
}
|
|
1827
|
-
tokens.push({
|
|
1828
|
-
text: value,
|
|
1829
|
-
start: start2,
|
|
1830
|
-
end: i
|
|
1831
|
-
});
|
|
1832
|
-
if (query[i] === '"') i += 1;
|
|
1833
|
-
continue;
|
|
1834
|
-
}
|
|
1835
|
-
const start = i;
|
|
1836
|
-
while (i < query.length && !/\s/u.test(query[i])) i += 1;
|
|
1837
|
-
tokens.push({
|
|
1838
|
-
text: query.slice(start, i),
|
|
1839
|
-
start,
|
|
1840
|
-
end: i
|
|
1841
|
-
});
|
|
1842
|
-
}
|
|
1843
|
-
return tokens.filter((token) => token.text.length > 0);
|
|
1844
|
-
}
|
|
1845
|
-
function findTermRanges(text, termLower) {
|
|
1846
|
-
if (!termLower) return [];
|
|
1847
|
-
const ranges = [];
|
|
1848
|
-
let from = 0;
|
|
1849
|
-
while (from <= text.length) {
|
|
1850
|
-
const index = text.indexOf(termLower, from);
|
|
1851
|
-
if (index === -1) break;
|
|
1852
|
-
ranges.push({
|
|
1853
|
-
start: index,
|
|
1854
|
-
end: index + termLower.length
|
|
1855
|
-
});
|
|
1856
|
-
from = index + Math.max(1, termLower.length);
|
|
1857
|
-
}
|
|
1858
|
-
return ranges;
|
|
1768
|
+
const merged = /* @__PURE__ */ new WeakMap();
|
|
1769
|
+
function isTopPrompt(event) {
|
|
1770
|
+
return event.kind === "user-prompt" && !event.childId && (event.depth ?? 0) === 0;
|
|
1859
1771
|
}
|
|
1860
|
-
function
|
|
1861
|
-
if (
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
if (
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
start,
|
|
1875
|
-
end: start + match[0].length,
|
|
1876
|
-
distance
|
|
1772
|
+
function gatherCommandNotes(events) {
|
|
1773
|
+
if (!events.some((e) => e.kind === "command-note")) return events;
|
|
1774
|
+
const out = [];
|
|
1775
|
+
let notes = [];
|
|
1776
|
+
const flush = () => {
|
|
1777
|
+
if (notes.length === 0) return;
|
|
1778
|
+
const first = notes[0];
|
|
1779
|
+
const key = notes.map((n) => n.text).join("\0");
|
|
1780
|
+
let event = first;
|
|
1781
|
+
if (notes.length > 1) {
|
|
1782
|
+
const cached = merged.get(first);
|
|
1783
|
+
event = cached?.key === key ? cached.event : {
|
|
1784
|
+
...first,
|
|
1785
|
+
text: notes.map((n) => n.text).join(", ")
|
|
1877
1786
|
};
|
|
1787
|
+
merged.set(first, {
|
|
1788
|
+
key,
|
|
1789
|
+
event
|
|
1790
|
+
});
|
|
1878
1791
|
}
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
const current = [i];
|
|
1889
|
-
let rowMin = i;
|
|
1890
|
-
for (let j = 1; j <= right.length; j++) {
|
|
1891
|
-
const value = Math.min(current[j - 1] + 1, previous[j] + 1, previous[j - 1] + (left[i - 1] === right[j - 1] ? 0 : 1));
|
|
1892
|
-
current.push(value);
|
|
1893
|
-
rowMin = Math.min(rowMin, value);
|
|
1894
|
-
}
|
|
1895
|
-
if (rowMin > limit) return null;
|
|
1896
|
-
previous = current;
|
|
1897
|
-
}
|
|
1898
|
-
const distance = previous[right.length];
|
|
1899
|
-
return distance <= limit ? distance : null;
|
|
1900
|
-
}
|
|
1901
|
-
function mergeRanges(ranges, max) {
|
|
1902
|
-
const sorted = ranges.map((range) => ({
|
|
1903
|
-
start: clamp(range.start, 0, max),
|
|
1904
|
-
end: clamp(range.end, 0, max)
|
|
1905
|
-
})).filter((range) => range.end > range.start).sort((a, b) => a.start - b.start || a.end - b.end);
|
|
1906
|
-
const merged2 = [];
|
|
1907
|
-
for (const range of sorted) {
|
|
1908
|
-
const last = merged2[merged2.length - 1];
|
|
1909
|
-
if (!last || range.start > last.end) {
|
|
1910
|
-
merged2.push({ ...range });
|
|
1792
|
+
let at = out.length;
|
|
1793
|
+
while (at > 0 && out[at - 1].kind === "separator") at--;
|
|
1794
|
+
out.splice(at, 0, event);
|
|
1795
|
+
notes = [];
|
|
1796
|
+
};
|
|
1797
|
+
for (const event of events) {
|
|
1798
|
+
if (isTopPrompt(event)) flush();
|
|
1799
|
+
if (event.kind === "command-note" && !event.childId) {
|
|
1800
|
+
notes.push(event);
|
|
1911
1801
|
continue;
|
|
1912
1802
|
}
|
|
1913
|
-
|
|
1803
|
+
out.push(event);
|
|
1914
1804
|
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
function clamp(value, min, max) {
|
|
1918
|
-
return Math.min(max, Math.max(min, value));
|
|
1805
|
+
flush();
|
|
1806
|
+
return out.length === events.length && out.every((e, i) => e === events[i]) ? events : out;
|
|
1919
1807
|
}
|
|
1920
|
-
|
|
1921
|
-
|
|
1808
|
+
const ALWAYS_SHOWN_NESTED_TOOLS = /* @__PURE__ */ new Set(["present_plan", "ask_user"]);
|
|
1809
|
+
function nestedCallShown(call, codemodeShowCalls) {
|
|
1810
|
+
return codemodeShowCalls || call.runsNestedAgent === true || call.tool !== void 0 && ALWAYS_SHOWN_NESTED_TOOLS.has(call.tool);
|
|
1922
1811
|
}
|
|
1923
|
-
const
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1812
|
+
const ESC = 27;
|
|
1813
|
+
const TEXT$1 = 0;
|
|
1814
|
+
const AFTER_ESC = 1;
|
|
1815
|
+
const CSI = 2;
|
|
1816
|
+
const STRING = 3;
|
|
1817
|
+
const STRING_ESC = 4;
|
|
1818
|
+
function hasAnsi(text) {
|
|
1819
|
+
for (let i = 0; i < text.length; i++) {
|
|
1820
|
+
const code = text.charCodeAt(i);
|
|
1821
|
+
if (code === ESC || code === 155 || code === 157 || code === 13 || code === 8) return true;
|
|
1822
|
+
}
|
|
1934
1823
|
return false;
|
|
1935
1824
|
}
|
|
1936
|
-
function
|
|
1937
|
-
|
|
1825
|
+
function sameStyle(a, b) {
|
|
1826
|
+
if (a === b) return true;
|
|
1827
|
+
if (!a || !b) return false;
|
|
1828
|
+
return a.fg === b.fg && a.bg === b.bg && a.bold === b.bold && a.dim === b.dim && a.italic === b.italic && a.underline === b.underline && a.inverse === b.inverse;
|
|
1938
1829
|
}
|
|
1939
|
-
function
|
|
1940
|
-
|
|
1941
|
-
let changed = false;
|
|
1942
|
-
const next = [...events];
|
|
1943
|
-
for (const ref of refs) {
|
|
1944
|
-
const texts = new Set(ref.texts);
|
|
1945
|
-
for (let i = next.length - 1; i >= 0; i--) {
|
|
1946
|
-
const e = next[i];
|
|
1947
|
-
if (e.kind !== "user-prompt" || e.turnId) continue;
|
|
1948
|
-
if (texts.has(e.text) || ref.attachmentOnly && e.text.trim().length === 0 && (e.attachments?.length ?? 0) > 0) {
|
|
1949
|
-
next[i] = {
|
|
1950
|
-
...e,
|
|
1951
|
-
turnId: ref.id
|
|
1952
|
-
};
|
|
1953
|
-
changed = true;
|
|
1954
|
-
break;
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
return changed ? next : events;
|
|
1830
|
+
function hex(n) {
|
|
1831
|
+
return Math.max(0, Math.min(255, n)).toString(16).padStart(2, "0");
|
|
1959
1832
|
}
|
|
1960
|
-
function
|
|
1961
|
-
|
|
1833
|
+
function extendedColor(params, i) {
|
|
1834
|
+
if (params[i] === 5) return [params[i + 1] !== void 0 ? Math.max(0, Math.min(255, params[i + 1])) : void 0, i + 2];
|
|
1835
|
+
if (params[i] === 2) return [`#${hex(params[i + 1] ?? 0)}${hex(params[i + 2] ?? 0)}${hex(params[i + 3] ?? 0)}`, i + 4];
|
|
1836
|
+
return [void 0, i + 1];
|
|
1962
1837
|
}
|
|
1963
|
-
function
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1838
|
+
function applySgr(style, raw) {
|
|
1839
|
+
const params = raw === "" ? [0] : raw.split(/[;:]/).map((p) => p === "" ? 0 : Number(p));
|
|
1840
|
+
let next = { ...style };
|
|
1841
|
+
for (let i = 0; i < params.length; i++) {
|
|
1842
|
+
const p = params[i];
|
|
1843
|
+
if (p === 0) next = {};
|
|
1844
|
+
else if (p === 1) next.bold = true;
|
|
1845
|
+
else if (p === 2) next.dim = true;
|
|
1846
|
+
else if (p === 3) next.italic = true;
|
|
1847
|
+
else if (p === 4) next.underline = true;
|
|
1848
|
+
else if (p === 7) next.inverse = true;
|
|
1849
|
+
else if (p === 22) {
|
|
1850
|
+
delete next.bold;
|
|
1851
|
+
delete next.dim;
|
|
1852
|
+
} else if (p === 23) delete next.italic;
|
|
1853
|
+
else if (p === 24) delete next.underline;
|
|
1854
|
+
else if (p === 27) delete next.inverse;
|
|
1855
|
+
else if (p >= 30 && p <= 37) next.fg = p - 30;
|
|
1856
|
+
else if (p >= 90 && p <= 97) next.fg = p - 90 + 8;
|
|
1857
|
+
else if (p === 39) delete next.fg;
|
|
1858
|
+
else if (p >= 40 && p <= 47) next.bg = p - 40;
|
|
1859
|
+
else if (p >= 100 && p <= 107) next.bg = p - 100 + 8;
|
|
1860
|
+
else if (p === 49) delete next.bg;
|
|
1861
|
+
else if (p === 38 || p === 48) {
|
|
1862
|
+
const [color, after] = extendedColor(params, i + 1);
|
|
1863
|
+
if (color !== void 0) {
|
|
1864
|
+
if (p === 38) next.fg = color;
|
|
1865
|
+
else next.bg = color;
|
|
1866
|
+
}
|
|
1867
|
+
i = after - 1;
|
|
1868
|
+
}
|
|
1987
1869
|
}
|
|
1870
|
+
if (Object.keys(next).length === 0) return void 0;
|
|
1871
|
+
return sameStyle(style, next) ? style : next;
|
|
1988
1872
|
}
|
|
1989
|
-
function
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
summary = {
|
|
2000
|
-
kinds: [],
|
|
2001
|
-
resultCallIds: []
|
|
2002
|
-
};
|
|
2003
|
-
summaryByTurn.set(e.turnId, summary);
|
|
2004
|
-
}
|
|
2005
|
-
summary.kinds.push(e.kind);
|
|
2006
|
-
if (e.callId) {
|
|
2007
|
-
if (e.kind === "tool") callOwner.set(e.callId, e.turnId);
|
|
2008
|
-
else if (e.kind === "tool-result") summary.resultCallIds.push(e.callId);
|
|
1873
|
+
function createAnsiLines() {
|
|
1874
|
+
let state = TEXT$1;
|
|
1875
|
+
let params = "";
|
|
1876
|
+
let style;
|
|
1877
|
+
let line = [];
|
|
1878
|
+
let pendingCr = false;
|
|
1879
|
+
const append = (text) => {
|
|
1880
|
+
if (pendingCr) {
|
|
1881
|
+
line = [];
|
|
1882
|
+
pendingCr = false;
|
|
2009
1883
|
}
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
const { kinds, resultCallIds } = summaryByTurn.get(tid);
|
|
2015
|
-
if (kinds.length > 0 && kinds.every((k) => k === "tool-result")) {
|
|
2016
|
-
const exactOwner = resultCallIds.map((callId) => callOwner.get(callId)).find((owner) => owner !== void 0 && owner !== tid);
|
|
2017
|
-
if (exactOwner) ownership.set(tid, exactOwner);
|
|
2018
|
-
else if (lastToolEmitterTurnId) ownership.set(tid, lastToolEmitterTurnId);
|
|
2019
|
-
continue;
|
|
1884
|
+
const last = line[line.length - 1];
|
|
1885
|
+
if (last && sameStyle(last.style, style)) {
|
|
1886
|
+
last.text += text;
|
|
1887
|
+
return;
|
|
2020
1888
|
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
}
|
|
2025
|
-
function selectableTurnIds(events, settings, visible, opts) {
|
|
2026
|
-
const ownership = turnSelectionOwnership(events);
|
|
2027
|
-
const visibleCount = settings ? /* @__PURE__ */ new Map() : null;
|
|
2028
|
-
if (settings && visibleCount) for (const e of events) {
|
|
2029
|
-
if (!e.turnId || e.childId) continue;
|
|
2030
|
-
if (!isVisible(e, settings)) continue;
|
|
2031
|
-
visibleCount.set(e.turnId, (visibleCount.get(e.turnId) ?? 0) + 1);
|
|
2032
|
-
}
|
|
2033
|
-
const seen2 = /* @__PURE__ */ new Set();
|
|
2034
|
-
const ordered = [];
|
|
2035
|
-
for (const e of events) {
|
|
2036
|
-
if (!e.turnId) continue;
|
|
2037
|
-
if (e.childId) continue;
|
|
2038
|
-
if (seen2.has(e.turnId)) continue;
|
|
2039
|
-
if (ownership.has(e.turnId)) continue;
|
|
2040
|
-
if (visibleCount && (visibleCount.get(e.turnId) ?? 0) === 0) continue;
|
|
2041
|
-
seen2.add(e.turnId);
|
|
2042
|
-
ordered.push(e.turnId);
|
|
2043
|
-
}
|
|
2044
|
-
return ordered;
|
|
2045
|
-
}
|
|
2046
|
-
function parseMachineKind(kind) {
|
|
2047
|
-
const match = /^(local|worktree)@(.+)$/.exec(kind);
|
|
2048
|
-
return match ? {
|
|
2049
|
-
base: match[1],
|
|
2050
|
-
name: match[2]
|
|
2051
|
-
} : null;
|
|
2052
|
-
}
|
|
2053
|
-
function isValidMachineName(name) {
|
|
2054
|
-
return /^[\w.-]{1,64}$/.test(name);
|
|
2055
|
-
}
|
|
2056
|
-
const FAILED = /(?:^|\n\n)\[✗ Streaming failed (before any output|mid-output)(?:: ([\s\S]*))?\.?\]\s*$/;
|
|
2057
|
-
const ABORTED = /(?:^|\n\n)\[⏹ Streaming was aborted\.\]\s*$/;
|
|
2058
|
-
function splitStreamFailure(text) {
|
|
2059
|
-
const aborted = ABORTED.exec(text);
|
|
2060
|
-
if (aborted) {
|
|
2061
|
-
const before = text.slice(0, aborted.index).trimEnd();
|
|
2062
|
-
return {
|
|
2063
|
-
text: before,
|
|
2064
|
-
failure: {
|
|
2065
|
-
message: "",
|
|
2066
|
-
midOutput: before !== "",
|
|
2067
|
-
aborted: true
|
|
2068
|
-
}
|
|
2069
|
-
};
|
|
2070
|
-
}
|
|
2071
|
-
const m = FAILED.exec(text);
|
|
2072
|
-
if (!m) return {
|
|
2073
|
-
text,
|
|
2074
|
-
failure: null
|
|
1889
|
+
line.push(style ? {
|
|
1890
|
+
text,
|
|
1891
|
+
style
|
|
1892
|
+
} : { text });
|
|
2075
1893
|
};
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
aborted: false
|
|
2082
|
-
}
|
|
1894
|
+
const backspace = () => {
|
|
1895
|
+
const last = line[line.length - 1];
|
|
1896
|
+
if (!last) return;
|
|
1897
|
+
last.text = last.text.slice(0, -1);
|
|
1898
|
+
if (last.text === "") line.pop();
|
|
2083
1899
|
};
|
|
2084
|
-
}
|
|
2085
|
-
function mayHaveStreamFailure(text) {
|
|
2086
|
-
return text.includes("[✗ Streaming failed") || text.includes("[⏹ Streaming was aborted");
|
|
2087
|
-
}
|
|
2088
|
-
const SHELL_FENCE_LANGUAGES = /* @__PURE__ */ new Set([
|
|
2089
|
-
"bash",
|
|
2090
|
-
"sh",
|
|
2091
|
-
"shell",
|
|
2092
|
-
"zsh",
|
|
2093
|
-
"console"
|
|
2094
|
-
]);
|
|
2095
|
-
const PROMPT_LINE = /^\$ /;
|
|
2096
|
-
function isShellFence(language) {
|
|
2097
|
-
return language !== void 0 && SHELL_FENCE_LANGUAGES.has(language.trim().toLowerCase());
|
|
2098
|
-
}
|
|
2099
|
-
function shellOf(language) {
|
|
2100
|
-
const lang = language.trim().toLowerCase();
|
|
2101
|
-
return lang === "zsh" ? "zsh" : lang === "sh" ? "sh" : "bash";
|
|
2102
|
-
}
|
|
2103
|
-
function shellBlockPlan(code, language) {
|
|
2104
|
-
if (!isShellFence(language) || code.length > 65536) return null;
|
|
2105
|
-
const lines = code.replace(/\r\n?/g, "\n").split("\n");
|
|
2106
|
-
const script = (lines.some((line) => PROMPT_LINE.test(line)) ? lines.filter((line) => PROMPT_LINE.test(line)).map((line) => line.replace(PROMPT_LINE, "")) : lines).join("\n").trim();
|
|
2107
|
-
if (script === "") return null;
|
|
2108
|
-
const commands = script.split("\n").filter((line) => line.trim() !== "" && !line.trim().startsWith("#"));
|
|
2109
|
-
if (commands.length === 0) return null;
|
|
2110
1900
|
return {
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
1901
|
+
push(chunk) {
|
|
1902
|
+
const done = [];
|
|
1903
|
+
let i = 0;
|
|
1904
|
+
while (i < chunk.length) {
|
|
1905
|
+
const code = chunk.charCodeAt(i);
|
|
1906
|
+
if (state === TEXT$1) {
|
|
1907
|
+
if (code === ESC) state = AFTER_ESC;
|
|
1908
|
+
else if (code === 10) {
|
|
1909
|
+
done.push(line);
|
|
1910
|
+
line = [];
|
|
1911
|
+
pendingCr = false;
|
|
1912
|
+
} else if (code === 13) pendingCr = true;
|
|
1913
|
+
else if (code === 8) backspace();
|
|
1914
|
+
else if (code === 155) {
|
|
1915
|
+
state = CSI;
|
|
1916
|
+
params = "";
|
|
1917
|
+
} else if (code === 157) state = STRING;
|
|
1918
|
+
else if (code === 9 || code >= 32 && !(code >= 127 && code < 160)) {
|
|
1919
|
+
let end = i + 1;
|
|
1920
|
+
while (end < chunk.length) {
|
|
1921
|
+
const c2 = chunk.charCodeAt(end);
|
|
1922
|
+
if (c2 === ESC || c2 === 10 || c2 === 13 || c2 === 8 || c2 < 32 && c2 !== 9 || c2 >= 127 && c2 < 160) break;
|
|
1923
|
+
end++;
|
|
1924
|
+
}
|
|
1925
|
+
append(chunk.slice(i, end));
|
|
1926
|
+
i = end;
|
|
1927
|
+
continue;
|
|
1928
|
+
}
|
|
1929
|
+
} else if (state === AFTER_ESC) {
|
|
1930
|
+
if (code === 91) {
|
|
1931
|
+
state = CSI;
|
|
1932
|
+
params = "";
|
|
1933
|
+
} else if (code === 93 || code === 80 || code === 88 || code === 94 || code === 95) state = STRING;
|
|
1934
|
+
else if (code < 32 || code > 47) state = TEXT$1;
|
|
1935
|
+
} else if (state === CSI) {
|
|
1936
|
+
if (code >= 64 && code <= 126) {
|
|
1937
|
+
if (code === 109) style = applySgr(style, params);
|
|
1938
|
+
state = TEXT$1;
|
|
1939
|
+
} else if (params.length < 64) params += chunk[i];
|
|
1940
|
+
} else if (state === STRING) {
|
|
1941
|
+
if (code === 7 || code === 156) state = TEXT$1;
|
|
1942
|
+
else if (code === ESC) state = STRING_ESC;
|
|
1943
|
+
} else state = code === 92 ? TEXT$1 : STRING;
|
|
1944
|
+
i++;
|
|
1945
|
+
}
|
|
1946
|
+
return done;
|
|
1947
|
+
},
|
|
1948
|
+
partial: () => pendingCr ? [] : line
|
|
2114
1949
|
};
|
|
2115
1950
|
}
|
|
2116
|
-
function
|
|
2117
|
-
const
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
return
|
|
2121
|
-
}
|
|
2122
|
-
function writeScript(script) {
|
|
2123
|
-
const end = delimiter(script);
|
|
2124
|
-
return `f=$(mktemp "\${TMPDIR:-/tmp}/zidane-block.XXXXXX") || exit 1
|
|
2125
|
-
cat > "$f" <<'${end}'
|
|
2126
|
-
${script}
|
|
2127
|
-
${end}
|
|
2128
|
-
`;
|
|
1951
|
+
function parseAnsi(text) {
|
|
1952
|
+
const reader = createAnsiLines();
|
|
1953
|
+
const lines = reader.push(text);
|
|
1954
|
+
lines.push(reader.partial());
|
|
1955
|
+
return lines;
|
|
2129
1956
|
}
|
|
2130
|
-
function
|
|
2131
|
-
|
|
2132
|
-
`;
|
|
2133
|
-
return `${writeScript(plan.script).replace(" || exit 1", "")}${plan.shell} "$f"; rm -f "$f"
|
|
2134
|
-
`;
|
|
1957
|
+
function ansiLineText(spans) {
|
|
1958
|
+
return spans.map((span) => span.text).join("");
|
|
2135
1959
|
}
|
|
2136
|
-
function
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
h ^= text.charCodeAt(i);
|
|
2140
|
-
h = Math.imul(h, 16777619);
|
|
2141
|
-
}
|
|
2142
|
-
return (h >>> 0).toString(16).padStart(8, "0");
|
|
1960
|
+
function stripAnsi(text) {
|
|
1961
|
+
if (!hasAnsi(text)) return text;
|
|
1962
|
+
return parseAnsi(text).map(ansiLineText).join("\n");
|
|
2143
1963
|
}
|
|
2144
|
-
function
|
|
2145
|
-
|
|
1964
|
+
function clipAnsiLine(spans, max) {
|
|
1965
|
+
if (ansiLineText(spans).length <= max) return [...spans];
|
|
1966
|
+
const out = [];
|
|
1967
|
+
let room = max - 1;
|
|
1968
|
+
for (const span of spans) {
|
|
1969
|
+
if (room <= 0) break;
|
|
1970
|
+
const text = span.text.slice(0, room);
|
|
1971
|
+
out.push(span.style ? {
|
|
1972
|
+
text,
|
|
1973
|
+
style: span.style
|
|
1974
|
+
} : { text });
|
|
1975
|
+
room -= text.length;
|
|
1976
|
+
}
|
|
1977
|
+
out.push({ text: "…" });
|
|
1978
|
+
return out;
|
|
2146
1979
|
}
|
|
2147
|
-
|
|
2148
|
-
const
|
|
2149
|
-
const
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
const
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
const altActive = (modes) => ALT_MODES.some((m) => modes.get(m) === true);
|
|
2183
|
-
function scanModes(state, text, base) {
|
|
2184
|
-
if (!text.includes("\x1B")) return state;
|
|
2185
|
-
let next = state;
|
|
2186
|
-
let modes = null;
|
|
2187
|
-
SEQUENCE.lastIndex = 0;
|
|
2188
|
-
for (let m = SEQUENCE.exec(text); m; m = SEQUENCE.exec(text)) {
|
|
2189
|
-
if (m[3] === "c") {
|
|
2190
|
-
next = EMPTY_MODES;
|
|
2191
|
-
modes = null;
|
|
2192
|
-
continue;
|
|
2193
|
-
}
|
|
2194
|
-
if (m[3]) {
|
|
2195
|
-
const keypad = m[3] === "=";
|
|
2196
|
-
if (next.keypad !== keypad) next = {
|
|
2197
|
-
...next,
|
|
2198
|
-
keypad
|
|
2199
|
-
};
|
|
2200
|
-
continue;
|
|
2201
|
-
}
|
|
2202
|
-
const on = m[2] === "h";
|
|
2203
|
-
const wasAlt = next.altAt !== null;
|
|
2204
|
-
for (const p of m[1].split(";")) {
|
|
2205
|
-
const mode = Number(p);
|
|
2206
|
-
if (!TRACKED_MODES.has(mode) || next.modes.get(mode) === on) continue;
|
|
2207
|
-
if (!modes) {
|
|
2208
|
-
modes = new Map(next.modes);
|
|
2209
|
-
next = {
|
|
2210
|
-
...next,
|
|
2211
|
-
modes
|
|
1980
|
+
function createOutputTail(maxLines, lineChars) {
|
|
1981
|
+
const tail = [];
|
|
1982
|
+
const commands = /* @__PURE__ */ new Map();
|
|
1983
|
+
let nextId = 0;
|
|
1984
|
+
const shape = (spans) => {
|
|
1985
|
+
const clipped = clipAnsiLine(spans, lineChars);
|
|
1986
|
+
const text = ansiLineText(clipped);
|
|
1987
|
+
return clipped.some((span) => span.style) ? {
|
|
1988
|
+
text,
|
|
1989
|
+
spans: clipped
|
|
1990
|
+
} : { text };
|
|
1991
|
+
};
|
|
1992
|
+
const push = (entry) => {
|
|
1993
|
+
tail.push(entry);
|
|
1994
|
+
if (tail.length > maxLines) tail.splice(0, tail.length - maxLines);
|
|
1995
|
+
};
|
|
1996
|
+
return {
|
|
1997
|
+
item(stream, text, line) {
|
|
1998
|
+
const at = line !== void 0 ? { line } : {};
|
|
1999
|
+
for (const spans of createAnsiLines().push(`${text}
|
|
2000
|
+
`)) push({
|
|
2001
|
+
id: nextId++,
|
|
2002
|
+
stream,
|
|
2003
|
+
...shape(spans),
|
|
2004
|
+
...at
|
|
2005
|
+
});
|
|
2006
|
+
},
|
|
2007
|
+
chunk(stream, text, line) {
|
|
2008
|
+
const key = `${stream}\0${line ?? ""}`;
|
|
2009
|
+
let command = commands.get(key);
|
|
2010
|
+
if (!command) {
|
|
2011
|
+
command = {
|
|
2012
|
+
reader: createAnsiLines(),
|
|
2013
|
+
stream,
|
|
2014
|
+
...line !== void 0 ? { line } : {}
|
|
2212
2015
|
};
|
|
2016
|
+
commands.set(key, command);
|
|
2213
2017
|
}
|
|
2214
|
-
|
|
2018
|
+
const at = line !== void 0 ? { line } : {};
|
|
2019
|
+
for (const spans of command.reader.push(text)) {
|
|
2020
|
+
push({
|
|
2021
|
+
id: command.openId ?? nextId++,
|
|
2022
|
+
stream,
|
|
2023
|
+
...shape(spans),
|
|
2024
|
+
...at
|
|
2025
|
+
});
|
|
2026
|
+
command.openId = void 0;
|
|
2027
|
+
}
|
|
2028
|
+
if (command.reader.partial().length > 0 && command.openId === void 0) command.openId = nextId++;
|
|
2029
|
+
},
|
|
2030
|
+
lines() {
|
|
2031
|
+
const open = [...commands.values()].flatMap(({ reader, stream, line, openId }) => {
|
|
2032
|
+
const spans = reader.partial();
|
|
2033
|
+
return spans.length === 0 || openId === void 0 ? [] : [{
|
|
2034
|
+
id: openId,
|
|
2035
|
+
stream,
|
|
2036
|
+
...shape(spans),
|
|
2037
|
+
...line !== void 0 ? { line } : {}
|
|
2038
|
+
}];
|
|
2039
|
+
});
|
|
2040
|
+
return [...tail, ...open].slice(-maxLines);
|
|
2215
2041
|
}
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2042
|
+
};
|
|
2043
|
+
}
|
|
2044
|
+
const SCRIPT_OUTPUT_TAIL_LINES = 8;
|
|
2045
|
+
function upsertToolProgress(events, event) {
|
|
2046
|
+
if (event.kind === "tool-progress") {
|
|
2047
|
+
const at = events.findLastIndex((e) => e.kind === "tool-progress" && e.callId === event.callId && e.childId === event.childId);
|
|
2048
|
+
if (at !== -1) {
|
|
2049
|
+
const next = events.slice();
|
|
2050
|
+
next[at] = event;
|
|
2051
|
+
return next;
|
|
2222
2052
|
}
|
|
2223
2053
|
}
|
|
2224
|
-
return
|
|
2054
|
+
return [...events, event];
|
|
2225
2055
|
}
|
|
2226
|
-
function
|
|
2227
|
-
|
|
2228
|
-
for (const
|
|
2229
|
-
|
|
2230
|
-
return out;
|
|
2056
|
+
function scriptProgressByCall(events) {
|
|
2057
|
+
const found = /* @__PURE__ */ new Map();
|
|
2058
|
+
for (const event of events) if (event.kind === "tool-progress" && event.callId && event.scriptProgress) found.set(scriptProgressKey(event.callId, event.childId), event.scriptProgress);
|
|
2059
|
+
return found;
|
|
2231
2060
|
}
|
|
2232
|
-
function
|
|
2233
|
-
return
|
|
2061
|
+
function scriptProgressKey(callId, childId) {
|
|
2062
|
+
return `${childId ?? ""}\0${callId}`;
|
|
2234
2063
|
}
|
|
2235
|
-
const
|
|
2236
|
-
function
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2064
|
+
const OPTIONS_LINE = /^\s*\/\/ @options:(.*)$/;
|
|
2065
|
+
function readOptions(json) {
|
|
2066
|
+
let value;
|
|
2067
|
+
try {
|
|
2068
|
+
value = JSON.parse(json);
|
|
2069
|
+
} catch {
|
|
2070
|
+
return {
|
|
2071
|
+
other: [],
|
|
2072
|
+
raw: json
|
|
2073
|
+
};
|
|
2241
2074
|
}
|
|
2242
|
-
return
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2075
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return {
|
|
2076
|
+
other: [],
|
|
2077
|
+
raw: json
|
|
2078
|
+
};
|
|
2079
|
+
const options = { other: [] };
|
|
2080
|
+
for (const [key, field] of Object.entries(value)) if (key === "timeout_ms" && typeof field === "number") options.timeoutMs = field;
|
|
2081
|
+
else if (key === "max_output_tokens" && typeof field === "number") options.maxOutputTokens = field;
|
|
2082
|
+
else options.other.push({
|
|
2083
|
+
key,
|
|
2084
|
+
value: JSON.stringify(field)
|
|
2085
|
+
});
|
|
2086
|
+
return options;
|
|
2248
2087
|
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2088
|
+
function scriptProgressView(code, progress, finished, ok = true, result) {
|
|
2089
|
+
const ended = finished || progress?.ended !== void 0;
|
|
2090
|
+
const endedOk = progress?.ended !== void 0 ? progress.ended === "ok" : ok;
|
|
2091
|
+
const error = ended && !endedOk && result ? scriptErrorOf(result) : void 0;
|
|
2092
|
+
const source = code.split("\n").map((line) => line.replace(/\r$/, ""));
|
|
2093
|
+
const optionsMatch = source[0] !== void 0 ? OPTIONS_LINE.exec(source[0]) : null;
|
|
2094
|
+
const options = optionsMatch ? readOptions(optionsMatch[1].trim()) : void 0;
|
|
2095
|
+
let first = optionsMatch ? 1 : 0;
|
|
2096
|
+
while (first < source.length && source[first].trim() === "") first++;
|
|
2097
|
+
let last = source.length - 1;
|
|
2098
|
+
while (last >= first && source[last].trim() === "") last--;
|
|
2099
|
+
const byLine = new Map(progress?.lines.map((entry) => [entry.line, entry]));
|
|
2100
|
+
const furthest = progress?.lines.length ? progress.lines[progress.lines.length - 1].line : 0;
|
|
2101
|
+
const reached = ended && endedOk ? Number.POSITIVE_INFINITY : furthest;
|
|
2102
|
+
const lines = [];
|
|
2103
|
+
for (let i = first; i <= last; i++) {
|
|
2104
|
+
const number = i + 1;
|
|
2105
|
+
const entry = byLine.get(number);
|
|
2106
|
+
const state = error?.line === number ? "failed" : !progress ? "passed" : entry ? entry.status === "running" ? "running" : entry.status === "ok" ? "done" : "failed" : number <= reached ? "passed" : "idle";
|
|
2107
|
+
lines.push({
|
|
2108
|
+
number,
|
|
2109
|
+
label: number - first,
|
|
2110
|
+
text: source[i],
|
|
2111
|
+
state,
|
|
2112
|
+
calls: entry?.calls ?? 0
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
const lastLine = lines.at(-1);
|
|
2116
|
+
if (progress && ended && endedOk && lastLine?.state === "passed") lastLine.state = "done";
|
|
2117
|
+
const done = progress?.done ?? 0;
|
|
2118
|
+
const total = progress ? countOnceCallSites(code) : void 0;
|
|
2119
|
+
const exact = total !== void 0 && done + (progress?.running ?? 0) <= total;
|
|
2120
|
+
const running = progress?.lines.find((entry) => entry.status === "running")?.line;
|
|
2121
|
+
return {
|
|
2122
|
+
lines,
|
|
2123
|
+
...options !== void 0 ? { options } : {},
|
|
2124
|
+
tracked: progress !== void 0,
|
|
2125
|
+
done,
|
|
2126
|
+
running: progress?.running ?? 0,
|
|
2127
|
+
failed: progress?.failed ?? 0,
|
|
2128
|
+
...exact ? {
|
|
2129
|
+
total,
|
|
2130
|
+
percent: ended && endedOk ? 100 : Math.min(100, Math.round(done / total * 100))
|
|
2131
|
+
} : {},
|
|
2132
|
+
...!ended && progress ? { active: running ?? (furthest || void 0) } : {},
|
|
2133
|
+
output: progress?.output ?? [],
|
|
2134
|
+
...error && lines.some((line) => line.number === error.line) ? { error } : {}
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
const SCRIPT_ERROR = /^Script error: (.+)$/m;
|
|
2138
|
+
const EXCERPT_LINE = /^(\d+) \| /m;
|
|
2139
|
+
function scriptErrorOf(result) {
|
|
2140
|
+
const message = SCRIPT_ERROR.exec(result)?.[1]?.trim();
|
|
2141
|
+
const line = EXCERPT_LINE.exec(result)?.[1];
|
|
2142
|
+
return message && line ? {
|
|
2143
|
+
line: Number(line),
|
|
2144
|
+
message
|
|
2145
|
+
} : void 0;
|
|
2146
|
+
}
|
|
2147
|
+
function maskScriptSource(code) {
|
|
2148
|
+
const out = code.split("");
|
|
2149
|
+
const blank = (from, to) => {
|
|
2150
|
+
for (let k = from; k < to; k++) if (out[k] !== "\n") out[k] = " ";
|
|
2151
|
+
};
|
|
2152
|
+
const templates = [];
|
|
2153
|
+
let braces = 0;
|
|
2154
|
+
let prev = "";
|
|
2155
|
+
let i = 0;
|
|
2156
|
+
const n = code.length;
|
|
2157
|
+
const templateText = () => {
|
|
2158
|
+
const start = i;
|
|
2159
|
+
while (i < n) {
|
|
2160
|
+
const c2 = code[i];
|
|
2161
|
+
if (c2 === "\\") {
|
|
2162
|
+
i += 2;
|
|
2163
|
+
continue;
|
|
2164
|
+
}
|
|
2165
|
+
if (c2 === "`") {
|
|
2166
|
+
blank(start, i);
|
|
2167
|
+
i++;
|
|
2168
|
+
prev = "`";
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
2171
|
+
if (c2 === "$" && code[i + 1] === "{") {
|
|
2172
|
+
blank(start, i);
|
|
2173
|
+
templates.push(braces);
|
|
2174
|
+
i += 2;
|
|
2175
|
+
prev = "{";
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
i++;
|
|
2179
|
+
}
|
|
2180
|
+
blank(start, n);
|
|
2181
|
+
};
|
|
2182
|
+
while (i < n) {
|
|
2183
|
+
const c2 = code[i];
|
|
2184
|
+
if (c2 === "/" && code[i + 1] === "/") {
|
|
2185
|
+
const end = code.indexOf("\n", i);
|
|
2186
|
+
blank(i, end === -1 ? n : end);
|
|
2187
|
+
i = end === -1 ? n : end;
|
|
2188
|
+
continue;
|
|
2189
|
+
}
|
|
2190
|
+
if (c2 === "/" && code[i + 1] === "*") {
|
|
2191
|
+
const end = code.indexOf("*/", i + 2);
|
|
2192
|
+
blank(i, end === -1 ? n : end + 2);
|
|
2193
|
+
i = end === -1 ? n : end + 2;
|
|
2194
|
+
continue;
|
|
2195
|
+
}
|
|
2196
|
+
if (c2 === '"' || c2 === "'") {
|
|
2197
|
+
let j = i + 1;
|
|
2198
|
+
while (j < n && code[j] !== c2 && code[j] !== "\n") j += code[j] === "\\" ? 2 : 1;
|
|
2199
|
+
blank(i + 1, Math.min(j, n));
|
|
2200
|
+
i = j + 1;
|
|
2201
|
+
prev = c2;
|
|
2202
|
+
continue;
|
|
2203
|
+
}
|
|
2204
|
+
if (c2 === "`") {
|
|
2205
|
+
i++;
|
|
2206
|
+
templateText();
|
|
2207
|
+
continue;
|
|
2208
|
+
}
|
|
2209
|
+
if (c2 === "/" && (prev === "" || "(,=:[!&|?{};+-*%<>~^".includes(prev))) {
|
|
2210
|
+
let j = i + 1;
|
|
2211
|
+
let inClass = false;
|
|
2212
|
+
while (j < n && code[j] !== "\n") {
|
|
2213
|
+
const d = code[j];
|
|
2214
|
+
if (d === "\\") {
|
|
2215
|
+
j += 2;
|
|
2216
|
+
continue;
|
|
2217
|
+
}
|
|
2218
|
+
if (d === "[") inClass = true;
|
|
2219
|
+
else if (d === "]") inClass = false;
|
|
2220
|
+
else if (d === "/" && !inClass) break;
|
|
2221
|
+
j++;
|
|
2222
|
+
}
|
|
2223
|
+
blank(i + 1, Math.min(j, n));
|
|
2224
|
+
i = j + 1;
|
|
2225
|
+
prev = ")";
|
|
2226
|
+
continue;
|
|
2227
|
+
}
|
|
2228
|
+
if (c2 === "{") braces++;
|
|
2229
|
+
else if (c2 === "}") {
|
|
2230
|
+
if (templates.length > 0 && templates[templates.length - 1] === braces) {
|
|
2231
|
+
templates.pop();
|
|
2232
|
+
i++;
|
|
2233
|
+
templateText();
|
|
2234
|
+
continue;
|
|
2235
|
+
}
|
|
2236
|
+
braces--;
|
|
2237
|
+
}
|
|
2238
|
+
if (!/\s/.test(c2)) prev = /[\w$]/.test(c2) ? "w" : c2;
|
|
2239
|
+
i++;
|
|
2240
|
+
}
|
|
2241
|
+
return out.join("");
|
|
2242
|
+
}
|
|
2243
|
+
const TOOL_CALL = /\btools\s*(?:\.\s*[A-Z_$][\w$]*|\[\s*(["'`])\s*\1\s*\])\s*\(/gi;
|
|
2244
|
+
const TOOL_REF = /\btools\b/g;
|
|
2245
|
+
const SH_CALL = /(?<![\w$.])sh\s*\(/g;
|
|
2246
|
+
const SH_REF = /(?<![\w$.])sh\b/g;
|
|
2247
|
+
const WORD = /[\w$]/;
|
|
2248
|
+
function countOnceCallSites(code) {
|
|
2249
|
+
const masked = maskScriptSource(code);
|
|
2250
|
+
const sites = /* @__PURE__ */ new Set();
|
|
2251
|
+
for (const match of masked.matchAll(TOOL_CALL)) sites.add(match.index);
|
|
2252
|
+
if ((masked.match(TOOL_REF)?.length ?? 0) !== sites.size) return void 0;
|
|
2253
|
+
const shCalls = [...masked.matchAll(SH_CALL)];
|
|
2254
|
+
if ((masked.match(SH_REF)?.length ?? 0) !== shCalls.length) return void 0;
|
|
2255
|
+
for (const match of shCalls) sites.add(match.index);
|
|
2256
|
+
if (sites.size === 0) return void 0;
|
|
2257
|
+
const stack = [];
|
|
2258
|
+
let pending = null;
|
|
2259
|
+
let nextParen = null;
|
|
2260
|
+
const repeating = () => stack.some((scope) => scope.repeats);
|
|
2261
|
+
const openBody = () => {
|
|
2262
|
+
if (pending === "loopBody") stack.push({
|
|
2263
|
+
close: "stmt",
|
|
2264
|
+
repeats: true
|
|
2265
|
+
});
|
|
2266
|
+
else if (pending === "arrowBody") stack.push({
|
|
2267
|
+
close: "expr",
|
|
2268
|
+
repeats: true
|
|
2269
|
+
});
|
|
2270
|
+
pending = null;
|
|
2271
|
+
};
|
|
2272
|
+
const closeTo = (close) => {
|
|
2273
|
+
while (stack.length > 0) {
|
|
2274
|
+
const scope = stack.pop();
|
|
2275
|
+
if (scope.close === close) return scope;
|
|
2276
|
+
}
|
|
2277
|
+
};
|
|
2278
|
+
const popWhile = (closes) => {
|
|
2279
|
+
while (stack.length > 0 && closes.includes(stack[stack.length - 1].close)) stack.pop();
|
|
2280
|
+
};
|
|
2281
|
+
let i = 0;
|
|
2282
|
+
const n = masked.length;
|
|
2283
|
+
while (i < n) {
|
|
2284
|
+
const c2 = masked[i];
|
|
2285
|
+
if (/\s/.test(c2)) {
|
|
2286
|
+
i++;
|
|
2287
|
+
continue;
|
|
2288
|
+
}
|
|
2289
|
+
if (WORD.test(c2)) {
|
|
2290
|
+
let j = i;
|
|
2291
|
+
while (j < n && WORD.test(masked[j])) j++;
|
|
2292
|
+
const word = masked.slice(i, j);
|
|
2293
|
+
openBody();
|
|
2294
|
+
if (sites.has(i) && repeating()) return void 0;
|
|
2295
|
+
if (word === "for" || word === "while") nextParen = "loop";
|
|
2296
|
+
else if (word === "if" || word === "switch" || word === "catch" || word === "with") nextParen = "cond";
|
|
2297
|
+
else if (word === "function") nextParen = "fn";
|
|
2298
|
+
else if (word === "do") pending = "loopBody";
|
|
2299
|
+
i = j;
|
|
2300
|
+
continue;
|
|
2301
|
+
}
|
|
2302
|
+
if (c2 === "=" && masked[i + 1] === ">") {
|
|
2303
|
+
pending = "arrowBody";
|
|
2304
|
+
i += 2;
|
|
2305
|
+
continue;
|
|
2306
|
+
}
|
|
2307
|
+
if (c2 === "{") {
|
|
2308
|
+
const repeats = pending === "loopBody" || pending === "fnBody" || pending === "braceIsFn" || pending === "arrowBody";
|
|
2309
|
+
stack.push({
|
|
2310
|
+
close: "}",
|
|
2311
|
+
repeats
|
|
2312
|
+
});
|
|
2313
|
+
pending = null;
|
|
2314
|
+
i++;
|
|
2315
|
+
continue;
|
|
2316
|
+
}
|
|
2317
|
+
if (c2 === ";") {
|
|
2318
|
+
popWhile(["stmt", "expr"]);
|
|
2319
|
+
pending = null;
|
|
2320
|
+
i++;
|
|
2321
|
+
continue;
|
|
2322
|
+
}
|
|
2323
|
+
if (c2 === ",") {
|
|
2324
|
+
popWhile(["expr"]);
|
|
2325
|
+
pending = null;
|
|
2326
|
+
i++;
|
|
2327
|
+
continue;
|
|
2328
|
+
}
|
|
2329
|
+
if (c2 === ")" || c2 === "]" || c2 === "}") {
|
|
2330
|
+
const scope = closeTo(c2);
|
|
2331
|
+
pending = null;
|
|
2332
|
+
if (c2 === ")" && scope) {
|
|
2333
|
+
if (scope.kind === "loop") pending = "loopBody";
|
|
2334
|
+
else if (scope.kind === "fn") pending = "fnBody";
|
|
2335
|
+
else if (scope.kind === "other") pending = "braceIsFn";
|
|
2336
|
+
}
|
|
2337
|
+
i++;
|
|
2338
|
+
continue;
|
|
2339
|
+
}
|
|
2340
|
+
openBody();
|
|
2341
|
+
if (c2 === "(") {
|
|
2342
|
+
stack.push({
|
|
2343
|
+
close: ")",
|
|
2344
|
+
repeats: false,
|
|
2345
|
+
kind: nextParen ?? "other"
|
|
2346
|
+
});
|
|
2347
|
+
nextParen = null;
|
|
2348
|
+
} else if (c2 === "[") stack.push({
|
|
2349
|
+
close: "]",
|
|
2350
|
+
repeats: false
|
|
2351
|
+
});
|
|
2352
|
+
i++;
|
|
2353
|
+
}
|
|
2354
|
+
return sites.size;
|
|
2355
|
+
}
|
|
2356
|
+
function searchHighlightRanges(text, query) {
|
|
2357
|
+
const parsed = parseQuery(query.trim());
|
|
2358
|
+
if (parsed.tokens.length === 0) return [];
|
|
2359
|
+
const lowerText = lower(text);
|
|
2360
|
+
const phrase = findTermRanges(lowerText, parsed.phraseLower);
|
|
2361
|
+
if (phrase.length > 0) return mergeRanges(phrase, text.length);
|
|
2362
|
+
const exact = parsed.tokens.flatMap((token) => findTermRanges(lowerText, token.lower));
|
|
2363
|
+
if (exact.length > 0) return mergeRanges(exact, text.length);
|
|
2364
|
+
return mergeRanges(parsed.tokens.flatMap((token) => findFuzzyWordRange(lowerText, token.lower) ?? []), text.length);
|
|
2365
|
+
}
|
|
2366
|
+
function highlightSegments(text, ranges) {
|
|
2367
|
+
const normalized = mergeRanges(ranges, text.length);
|
|
2368
|
+
if (!normalized.length) return [{
|
|
2369
|
+
text,
|
|
2370
|
+
highlighted: false
|
|
2371
|
+
}];
|
|
2372
|
+
const segments = [];
|
|
2373
|
+
let cursor = 0;
|
|
2374
|
+
for (const range of normalized) {
|
|
2375
|
+
if (range.start > cursor) segments.push({
|
|
2376
|
+
text: text.slice(cursor, range.start),
|
|
2377
|
+
highlighted: false
|
|
2378
|
+
});
|
|
2379
|
+
if (range.end > range.start) segments.push({
|
|
2380
|
+
text: text.slice(range.start, range.end),
|
|
2381
|
+
highlighted: true
|
|
2382
|
+
});
|
|
2383
|
+
cursor = range.end;
|
|
2384
|
+
}
|
|
2385
|
+
if (cursor < text.length) segments.push({
|
|
2386
|
+
text: text.slice(cursor),
|
|
2387
|
+
highlighted: false
|
|
2388
|
+
});
|
|
2389
|
+
return segments.filter((segment) => segment.text.length > 0);
|
|
2390
|
+
}
|
|
2391
|
+
function parseQuery(query) {
|
|
2392
|
+
const tokens = tokenize(query);
|
|
2393
|
+
const phrase = tokens.map((token) => token.text).join(" ");
|
|
2394
|
+
return {
|
|
2395
|
+
tokens: tokens.map((token) => ({
|
|
2396
|
+
...token,
|
|
2397
|
+
lower: lower(token.text)
|
|
2398
|
+
})),
|
|
2399
|
+
phraseLower: lower(phrase)
|
|
2400
|
+
};
|
|
2401
|
+
}
|
|
2402
|
+
function tokenize(query) {
|
|
2403
|
+
const tokens = [];
|
|
2404
|
+
let i = 0;
|
|
2405
|
+
while (i < query.length) {
|
|
2406
|
+
while (i < query.length && /\s/u.test(query[i])) i += 1;
|
|
2407
|
+
if (i >= query.length) break;
|
|
2408
|
+
if (query[i] === '"') {
|
|
2409
|
+
const start2 = i + 1;
|
|
2410
|
+
i += 1;
|
|
2411
|
+
let value = "";
|
|
2412
|
+
while (i < query.length && query[i] !== '"') {
|
|
2413
|
+
value += query[i];
|
|
2414
|
+
i += 1;
|
|
2415
|
+
}
|
|
2416
|
+
tokens.push({
|
|
2417
|
+
text: value,
|
|
2418
|
+
start: start2,
|
|
2419
|
+
end: i
|
|
2420
|
+
});
|
|
2421
|
+
if (query[i] === '"') i += 1;
|
|
2422
|
+
continue;
|
|
2423
|
+
}
|
|
2424
|
+
const start = i;
|
|
2425
|
+
while (i < query.length && !/\s/u.test(query[i])) i += 1;
|
|
2426
|
+
tokens.push({
|
|
2427
|
+
text: query.slice(start, i),
|
|
2428
|
+
start,
|
|
2429
|
+
end: i
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
return tokens.filter((token) => token.text.length > 0);
|
|
2433
|
+
}
|
|
2434
|
+
function findTermRanges(text, termLower) {
|
|
2435
|
+
if (!termLower) return [];
|
|
2436
|
+
const ranges = [];
|
|
2437
|
+
let from = 0;
|
|
2438
|
+
while (from <= text.length) {
|
|
2439
|
+
const index = text.indexOf(termLower, from);
|
|
2440
|
+
if (index === -1) break;
|
|
2441
|
+
ranges.push({
|
|
2442
|
+
start: index,
|
|
2443
|
+
end: index + termLower.length
|
|
2444
|
+
});
|
|
2445
|
+
from = index + Math.max(1, termLower.length);
|
|
2446
|
+
}
|
|
2447
|
+
return ranges;
|
|
2448
|
+
}
|
|
2449
|
+
function findFuzzyWordRange(text, termLower) {
|
|
2450
|
+
if (termLower.length < 4) return null;
|
|
2451
|
+
const maxEdits = termLower.length >= 9 ? 2 : 1;
|
|
2452
|
+
const words2 = text.matchAll(/[\p{L}\p{N}_-]+/gu);
|
|
2453
|
+
let best = null;
|
|
2454
|
+
for (const match of words2) {
|
|
2455
|
+
const candidate = match[0].toLocaleLowerCase();
|
|
2456
|
+
if (Math.abs(candidate.length - termLower.length) > maxEdits) continue;
|
|
2457
|
+
const distance = boundedEditDistance(candidate, termLower, maxEdits);
|
|
2458
|
+
if (distance === null) continue;
|
|
2459
|
+
if (1 - distance / Math.max(candidate.length, termLower.length) < 0.8) continue;
|
|
2460
|
+
if (!best || distance < best.distance || distance === best.distance && candidate.length < best.end - best.start) {
|
|
2461
|
+
const start = match.index ?? 0;
|
|
2462
|
+
best = {
|
|
2463
|
+
start,
|
|
2464
|
+
end: start + match[0].length,
|
|
2465
|
+
distance
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
return best ? [{
|
|
2470
|
+
start: best.start,
|
|
2471
|
+
end: best.end
|
|
2472
|
+
}] : null;
|
|
2473
|
+
}
|
|
2474
|
+
function boundedEditDistance(left, right, limit) {
|
|
2475
|
+
let previous = Array.from({ length: right.length + 1 }, (_, i) => i);
|
|
2476
|
+
for (let i = 1; i <= left.length; i++) {
|
|
2477
|
+
const current = [i];
|
|
2478
|
+
let rowMin = i;
|
|
2479
|
+
for (let j = 1; j <= right.length; j++) {
|
|
2480
|
+
const value = Math.min(current[j - 1] + 1, previous[j] + 1, previous[j - 1] + (left[i - 1] === right[j - 1] ? 0 : 1));
|
|
2481
|
+
current.push(value);
|
|
2482
|
+
rowMin = Math.min(rowMin, value);
|
|
2483
|
+
}
|
|
2484
|
+
if (rowMin > limit) return null;
|
|
2485
|
+
previous = current;
|
|
2486
|
+
}
|
|
2487
|
+
const distance = previous[right.length];
|
|
2488
|
+
return distance <= limit ? distance : null;
|
|
2489
|
+
}
|
|
2490
|
+
function mergeRanges(ranges, max) {
|
|
2491
|
+
const sorted = ranges.map((range) => ({
|
|
2492
|
+
start: clamp(range.start, 0, max),
|
|
2493
|
+
end: clamp(range.end, 0, max)
|
|
2494
|
+
})).filter((range) => range.end > range.start).sort((a, b) => a.start - b.start || a.end - b.end);
|
|
2495
|
+
const merged2 = [];
|
|
2496
|
+
for (const range of sorted) {
|
|
2497
|
+
const last = merged2[merged2.length - 1];
|
|
2498
|
+
if (!last || range.start > last.end) {
|
|
2499
|
+
merged2.push({ ...range });
|
|
2500
|
+
continue;
|
|
2501
|
+
}
|
|
2502
|
+
last.end = Math.max(last.end, range.end);
|
|
2503
|
+
}
|
|
2504
|
+
return merged2;
|
|
2505
|
+
}
|
|
2506
|
+
function clamp(value, min, max) {
|
|
2507
|
+
return Math.min(max, Math.max(min, value));
|
|
2508
|
+
}
|
|
2509
|
+
function lower(value) {
|
|
2510
|
+
return value.toLocaleLowerCase();
|
|
2511
|
+
}
|
|
2512
|
+
const EDIT_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
2513
|
+
"edit",
|
|
2514
|
+
"multi_edit",
|
|
2515
|
+
"write_file"
|
|
2516
|
+
]);
|
|
2517
|
+
function isEditErrorResult(text) {
|
|
2518
|
+
if (text.startsWith("Edit error:")) return true;
|
|
2519
|
+
if (text.startsWith("Tool failed:")) return true;
|
|
2520
|
+
if (text.startsWith("multi_edit error:")) return true;
|
|
2521
|
+
if (text.startsWith("[fully denied]")) return true;
|
|
2522
|
+
if (text.includes("\n<edit-outcomes>\n") || text.startsWith("<edit-outcomes>\n")) return true;
|
|
2523
|
+
return false;
|
|
2524
|
+
}
|
|
2525
|
+
function isUserBashEvent(event) {
|
|
2526
|
+
return event.tool === "shell" && event.callId?.startsWith("bash_") === true;
|
|
2527
|
+
}
|
|
2528
|
+
function retagUserPromptEventsFromRefs(events, refs) {
|
|
2529
|
+
if (refs.length === 0) return events;
|
|
2530
|
+
let changed = false;
|
|
2531
|
+
const next = [...events];
|
|
2532
|
+
for (const ref of refs) {
|
|
2533
|
+
const texts = new Set(ref.texts);
|
|
2534
|
+
for (let i = next.length - 1; i >= 0; i--) {
|
|
2535
|
+
const e = next[i];
|
|
2536
|
+
if (e.kind !== "user-prompt" || e.turnId) continue;
|
|
2537
|
+
if (texts.has(e.text) || ref.attachmentOnly && e.text.trim().length === 0 && (e.attachments?.length ?? 0) > 0) {
|
|
2538
|
+
next[i] = {
|
|
2539
|
+
...e,
|
|
2540
|
+
turnId: ref.id
|
|
2541
|
+
};
|
|
2542
|
+
changed = true;
|
|
2543
|
+
break;
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
return changed ? next : events;
|
|
2548
|
+
}
|
|
2549
|
+
function isCacheNotice(notice) {
|
|
2550
|
+
return notice?.label === "cache" || notice?.label === "reasoning";
|
|
2551
|
+
}
|
|
2552
|
+
function isVisible(event, settings) {
|
|
2553
|
+
if (event.parentToolCallId !== void 0 && !nestedCallShown(event, settings.codemodeShowCalls)) return false;
|
|
2554
|
+
if (settings.hideSubagentOutput) {
|
|
2555
|
+
if ((event.depth ?? 0) > 0) return event.kind === "spawn-start" || event.kind === "spawn-end";
|
|
2556
|
+
if (event.kind === "tool-result" && event.tool === "spawn") return false;
|
|
2557
|
+
}
|
|
2558
|
+
if (settings.showEditDiffs && event.kind === "tool-result" && event.tool && EDIT_TOOL_NAMES.has(event.tool) && !isEditErrorResult(event.text)) return false;
|
|
2559
|
+
switch (event.kind) {
|
|
2560
|
+
case "thinking":
|
|
2561
|
+
return settings.showThinking;
|
|
2562
|
+
case "tool":
|
|
2563
|
+
return settings.toolCallDisplay !== "hidden" || isUserBashEvent(event);
|
|
2564
|
+
case "tool-result":
|
|
2565
|
+
return settings.showToolResults || isUserBashEvent(event);
|
|
2566
|
+
case "run-summary":
|
|
2567
|
+
return settings.showRunReceipt;
|
|
2568
|
+
case "info":
|
|
2569
|
+
return settings.showCacheNotices || !isCacheNotice(event.notice);
|
|
2570
|
+
case "spawn-queued":
|
|
2571
|
+
return settings.transcriptDensity === "compact";
|
|
2572
|
+
case "tool-progress":
|
|
2573
|
+
return false;
|
|
2574
|
+
default:
|
|
2575
|
+
return true;
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
function turnSelectionOwnership(events) {
|
|
2579
|
+
const orderedTurnIds = [];
|
|
2580
|
+
const summaryByTurn = /* @__PURE__ */ new Map();
|
|
2581
|
+
const callOwner = /* @__PURE__ */ new Map();
|
|
2582
|
+
for (const e of events) {
|
|
2583
|
+
if (!e.turnId) continue;
|
|
2584
|
+
if (e.childId) continue;
|
|
2585
|
+
let summary = summaryByTurn.get(e.turnId);
|
|
2586
|
+
if (!summary) {
|
|
2587
|
+
orderedTurnIds.push(e.turnId);
|
|
2588
|
+
summary = {
|
|
2589
|
+
kinds: [],
|
|
2590
|
+
resultCallIds: []
|
|
2591
|
+
};
|
|
2592
|
+
summaryByTurn.set(e.turnId, summary);
|
|
2593
|
+
}
|
|
2594
|
+
summary.kinds.push(e.kind);
|
|
2595
|
+
if (e.callId) {
|
|
2596
|
+
if (e.kind === "tool") callOwner.set(e.callId, e.turnId);
|
|
2597
|
+
else if (e.kind === "tool-result") summary.resultCallIds.push(e.callId);
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
const ownership = /* @__PURE__ */ new Map();
|
|
2601
|
+
let lastToolEmitterTurnId = null;
|
|
2602
|
+
for (const tid of orderedTurnIds) {
|
|
2603
|
+
const { kinds, resultCallIds } = summaryByTurn.get(tid);
|
|
2604
|
+
if (kinds.length > 0 && kinds.every((k) => k === "tool-result")) {
|
|
2605
|
+
const exactOwner = resultCallIds.map((callId) => callOwner.get(callId)).find((owner) => owner !== void 0 && owner !== tid);
|
|
2606
|
+
if (exactOwner) ownership.set(tid, exactOwner);
|
|
2607
|
+
else if (lastToolEmitterTurnId) ownership.set(tid, lastToolEmitterTurnId);
|
|
2608
|
+
continue;
|
|
2609
|
+
}
|
|
2610
|
+
if (kinds.includes("tool")) lastToolEmitterTurnId = tid;
|
|
2611
|
+
}
|
|
2612
|
+
return ownership;
|
|
2613
|
+
}
|
|
2614
|
+
function selectableTurnIds(events, settings, visible, opts) {
|
|
2615
|
+
const ownership = turnSelectionOwnership(events);
|
|
2616
|
+
const visibleCount = settings ? /* @__PURE__ */ new Map() : null;
|
|
2617
|
+
if (settings && visibleCount) for (const e of events) {
|
|
2618
|
+
if (!e.turnId || e.childId) continue;
|
|
2619
|
+
if (!isVisible(e, settings)) continue;
|
|
2620
|
+
visibleCount.set(e.turnId, (visibleCount.get(e.turnId) ?? 0) + 1);
|
|
2621
|
+
}
|
|
2622
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
2623
|
+
const ordered = [];
|
|
2624
|
+
for (const e of events) {
|
|
2625
|
+
if (!e.turnId) continue;
|
|
2626
|
+
if (e.childId) continue;
|
|
2627
|
+
if (seen2.has(e.turnId)) continue;
|
|
2628
|
+
if (ownership.has(e.turnId)) continue;
|
|
2629
|
+
if (visibleCount && (visibleCount.get(e.turnId) ?? 0) === 0) continue;
|
|
2630
|
+
seen2.add(e.turnId);
|
|
2631
|
+
ordered.push(e.turnId);
|
|
2632
|
+
}
|
|
2633
|
+
return ordered;
|
|
2634
|
+
}
|
|
2635
|
+
function parseMachineKind(kind) {
|
|
2636
|
+
const match = /^(local|worktree)@(.+)$/.exec(kind);
|
|
2637
|
+
return match ? {
|
|
2638
|
+
base: match[1],
|
|
2639
|
+
name: match[2]
|
|
2640
|
+
} : null;
|
|
2641
|
+
}
|
|
2642
|
+
function isValidMachineName(name) {
|
|
2643
|
+
return /^[\w.-]{1,64}$/.test(name);
|
|
2644
|
+
}
|
|
2645
|
+
const FAILED = /(?:^|\n\n)\[✗ Streaming failed (before any output|mid-output)(?:: ([\s\S]*))?\.?\]\s*$/;
|
|
2646
|
+
const ABORTED = /(?:^|\n\n)\[⏹ Streaming was aborted\.\]\s*$/;
|
|
2647
|
+
function splitStreamFailure(text) {
|
|
2648
|
+
const aborted = ABORTED.exec(text);
|
|
2649
|
+
if (aborted) {
|
|
2650
|
+
const before = text.slice(0, aborted.index).trimEnd();
|
|
2651
|
+
return {
|
|
2652
|
+
text: before,
|
|
2653
|
+
failure: {
|
|
2654
|
+
message: "",
|
|
2655
|
+
midOutput: before !== "",
|
|
2656
|
+
aborted: true
|
|
2657
|
+
}
|
|
2658
|
+
};
|
|
2659
|
+
}
|
|
2660
|
+
const m = FAILED.exec(text);
|
|
2661
|
+
if (!m) return {
|
|
2662
|
+
text,
|
|
2663
|
+
failure: null
|
|
2664
|
+
};
|
|
2665
|
+
return {
|
|
2666
|
+
text: text.slice(0, m.index).trimEnd(),
|
|
2667
|
+
failure: {
|
|
2668
|
+
message: (m[2] ?? "").trim(),
|
|
2669
|
+
midOutput: m[1] === "mid-output",
|
|
2670
|
+
aborted: false
|
|
2671
|
+
}
|
|
2672
|
+
};
|
|
2673
|
+
}
|
|
2674
|
+
function mayHaveStreamFailure(text) {
|
|
2675
|
+
return text.includes("[✗ Streaming failed") || text.includes("[⏹ Streaming was aborted");
|
|
2676
|
+
}
|
|
2677
|
+
const UNIT_MS = {
|
|
2678
|
+
m: 6e4,
|
|
2679
|
+
min: 6e4,
|
|
2680
|
+
mins: 6e4,
|
|
2681
|
+
minute: 6e4,
|
|
2682
|
+
minutes: 6e4,
|
|
2683
|
+
h: 36e5,
|
|
2684
|
+
hour: 36e5,
|
|
2685
|
+
hours: 36e5,
|
|
2686
|
+
d: 864e5,
|
|
2687
|
+
day: 864e5,
|
|
2688
|
+
days: 864e5
|
|
2689
|
+
};
|
|
2690
|
+
function localTimeZone() {
|
|
2691
|
+
try {
|
|
2692
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
2693
|
+
} catch {
|
|
2694
|
+
return "UTC";
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
const SECOND_MS = {
|
|
2698
|
+
s: 1e3,
|
|
2699
|
+
sec: 1e3,
|
|
2700
|
+
secs: 1e3,
|
|
2701
|
+
second: 1e3,
|
|
2702
|
+
seconds: 1e3
|
|
2703
|
+
};
|
|
2704
|
+
function amount(count, unit, seconds = false) {
|
|
2705
|
+
const key = unit.toLowerCase();
|
|
2706
|
+
const ms = UNIT_MS[key] ?? (seconds ? SECOND_MS[key] : void 0);
|
|
2707
|
+
return ms && Number(count) > 0 ? Number(count) * ms : null;
|
|
2708
|
+
}
|
|
2709
|
+
const WHEN_RULES = [
|
|
2710
|
+
{
|
|
2711
|
+
head: /^in\s+(\d+)\s*([a-z]+)\b/i,
|
|
2712
|
+
trigger: (m, now) => {
|
|
2713
|
+
const ms = amount(m[1], m[2], true);
|
|
2714
|
+
return ms === null ? null : {
|
|
2715
|
+
kind: "at",
|
|
2716
|
+
at: now + ms
|
|
2717
|
+
};
|
|
2718
|
+
}
|
|
2719
|
+
},
|
|
2720
|
+
{
|
|
2721
|
+
head: /^every\s+(\d+)\s*([a-z]+)\b/i,
|
|
2722
|
+
trigger: (m, now) => {
|
|
2723
|
+
const ms = amount(m[1], m[2]);
|
|
2724
|
+
return ms === null ? null : {
|
|
2725
|
+
kind: "every",
|
|
2726
|
+
everyMs: ms,
|
|
2727
|
+
anchor: now
|
|
2728
|
+
};
|
|
2729
|
+
}
|
|
2730
|
+
},
|
|
2731
|
+
{
|
|
2732
|
+
head: /^(?:daily|every\s+day)\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\b/i,
|
|
2733
|
+
trigger: (m, _now, tz) => {
|
|
2734
|
+
const time = clock(m[1], m[2]);
|
|
2735
|
+
return time ? {
|
|
2736
|
+
kind: "cron",
|
|
2737
|
+
expr: `${time.minute} ${time.hour} * * *`,
|
|
2738
|
+
tz
|
|
2739
|
+
} : null;
|
|
2740
|
+
}
|
|
2741
|
+
},
|
|
2742
|
+
{
|
|
2743
|
+
head: /^(?:weekdays|every\s+weekday)\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\b/i,
|
|
2744
|
+
trigger: (m, _now, tz) => {
|
|
2745
|
+
const time = clock(m[1], m[2]);
|
|
2746
|
+
return time ? {
|
|
2747
|
+
kind: "cron",
|
|
2748
|
+
expr: `${time.minute} ${time.hour} * * 1-5`,
|
|
2749
|
+
tz
|
|
2750
|
+
} : null;
|
|
2751
|
+
}
|
|
2752
|
+
},
|
|
2753
|
+
{
|
|
2754
|
+
head: /^cron\s+"([^"]+)"/i,
|
|
2755
|
+
trigger: (m, _now, tz) => ({
|
|
2756
|
+
kind: "cron",
|
|
2757
|
+
expr: m[1].trim(),
|
|
2758
|
+
tz
|
|
2759
|
+
})
|
|
2760
|
+
},
|
|
2761
|
+
{
|
|
2762
|
+
head: /^tomorrow\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\b/i,
|
|
2763
|
+
trigger: (m, now) => {
|
|
2764
|
+
const time = clock(m[1], m[2]);
|
|
2765
|
+
return time ? {
|
|
2766
|
+
kind: "at",
|
|
2767
|
+
at: localTime(now, time, 1)
|
|
2768
|
+
} : null;
|
|
2769
|
+
}
|
|
2770
|
+
},
|
|
2771
|
+
{
|
|
2772
|
+
head: /^at\s+(\d{1,2})(?::(\d{2}))?\b/i,
|
|
2773
|
+
trigger: (m, now) => {
|
|
2774
|
+
const time = clock(m[1], m[2]);
|
|
2775
|
+
if (!time) return null;
|
|
2776
|
+
const today = localTime(now, time, 0);
|
|
2777
|
+
return {
|
|
2778
|
+
kind: "at",
|
|
2779
|
+
at: today > now ? today : localTime(now, time, 1)
|
|
2780
|
+
};
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
];
|
|
2784
|
+
function parseWhen(text, now, tz = localTimeZone()) {
|
|
2785
|
+
const input = text.trim();
|
|
2786
|
+
for (const rule of WHEN_RULES) {
|
|
2787
|
+
const match = rule.head.exec(input);
|
|
2788
|
+
if (!match) continue;
|
|
2789
|
+
const trigger = rule.trigger(match, now, tz);
|
|
2790
|
+
return trigger ? {
|
|
2791
|
+
trigger,
|
|
2792
|
+
rest: input.slice(match[0].length).trim()
|
|
2793
|
+
} : null;
|
|
2794
|
+
}
|
|
2795
|
+
return null;
|
|
2796
|
+
}
|
|
2797
|
+
function clock(hour, minute) {
|
|
2798
|
+
const h = Number(hour);
|
|
2799
|
+
const min = minute === void 0 ? 0 : Number(minute);
|
|
2800
|
+
return h <= 23 && min <= 59 ? {
|
|
2801
|
+
hour: h,
|
|
2802
|
+
minute: min
|
|
2803
|
+
} : null;
|
|
2804
|
+
}
|
|
2805
|
+
function localTime(now, time, dayOffset) {
|
|
2806
|
+
const date = new Date(now);
|
|
2807
|
+
date.setDate(date.getDate() + dayOffset);
|
|
2808
|
+
date.setHours(time.hour, time.minute, 0, 0);
|
|
2809
|
+
return date.getTime();
|
|
2810
|
+
}
|
|
2811
|
+
function describeTrigger(trigger, now, options) {
|
|
2812
|
+
switch (trigger.kind) {
|
|
2813
|
+
case "at":
|
|
2814
|
+
return `once, ${describeTime(trigger.at, now, options)}`;
|
|
2815
|
+
case "every":
|
|
2816
|
+
return `every ${describeDuration(trigger.everyMs)}`;
|
|
2817
|
+
case "cron":
|
|
2818
|
+
return `cron ${trigger.expr} (${trigger.tz})`;
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
const pad2 = (n) => String(n).padStart(2, "0");
|
|
2822
|
+
function describeTime(at, now, options) {
|
|
2823
|
+
const date = new Date(at);
|
|
2824
|
+
const hm = `${pad2(date.getHours())}:${pad2(date.getMinutes())}${options?.seconds ? `:${pad2(date.getSeconds())}` : ""}`;
|
|
2825
|
+
const day = (offset) => {
|
|
2826
|
+
const d = new Date(now);
|
|
2827
|
+
d.setDate(d.getDate() + offset);
|
|
2828
|
+
return d.toDateString();
|
|
2829
|
+
};
|
|
2830
|
+
if (date.toDateString() === day(0)) return `today ${hm}`;
|
|
2831
|
+
if (date.toDateString() === day(1)) return `tomorrow ${hm}`;
|
|
2832
|
+
return `${date.toLocaleDateString("en-US", {
|
|
2833
|
+
weekday: "short",
|
|
2834
|
+
day: "numeric",
|
|
2835
|
+
month: "short"
|
|
2836
|
+
})} ${hm}`;
|
|
2837
|
+
}
|
|
2838
|
+
function describeDuration(ms) {
|
|
2839
|
+
const minutes = Math.round(ms / 6e4);
|
|
2840
|
+
const d = Math.floor(minutes / 1440);
|
|
2841
|
+
const h = Math.floor(minutes % 1440 / 60);
|
|
2842
|
+
const m = minutes % 60;
|
|
2843
|
+
return [
|
|
2844
|
+
d ? `${d} d` : "",
|
|
2845
|
+
h ? `${h} h` : "",
|
|
2846
|
+
m ? `${m} min` : ""
|
|
2847
|
+
].filter(Boolean).join(" ") || "0 min";
|
|
2848
|
+
}
|
|
2849
|
+
const SHELL_FENCE_LANGUAGES = /* @__PURE__ */ new Set([
|
|
2850
|
+
"bash",
|
|
2851
|
+
"sh",
|
|
2852
|
+
"shell",
|
|
2853
|
+
"zsh",
|
|
2854
|
+
"console"
|
|
2855
|
+
]);
|
|
2856
|
+
const PROMPT_LINE = /^\$ /;
|
|
2857
|
+
function isShellFence(language) {
|
|
2858
|
+
return language !== void 0 && SHELL_FENCE_LANGUAGES.has(language.trim().toLowerCase());
|
|
2859
|
+
}
|
|
2860
|
+
function shellOf(language) {
|
|
2861
|
+
const lang = language.trim().toLowerCase();
|
|
2862
|
+
return lang === "zsh" ? "zsh" : lang === "sh" ? "sh" : "bash";
|
|
2863
|
+
}
|
|
2864
|
+
function promptedLines(lines) {
|
|
2865
|
+
const kept = [];
|
|
2866
|
+
let continued = false;
|
|
2867
|
+
for (const line of lines) {
|
|
2868
|
+
if (PROMPT_LINE.test(line)) kept.push(line.replace(PROMPT_LINE, ""));
|
|
2869
|
+
else if (continued) kept.push(line);
|
|
2870
|
+
else continue;
|
|
2871
|
+
continued = line.trimEnd().endsWith("\\");
|
|
2872
|
+
}
|
|
2873
|
+
return kept;
|
|
2874
|
+
}
|
|
2875
|
+
function shellBlockPlan(code, language) {
|
|
2876
|
+
if (!isShellFence(language) || code.length > 65536) return null;
|
|
2877
|
+
const lines = code.replace(/\r\n?/g, "\n").split("\n");
|
|
2878
|
+
const script = (lines.some((line) => PROMPT_LINE.test(line)) ? promptedLines(lines) : lines).join("\n").trim();
|
|
2879
|
+
if (script === "") return null;
|
|
2880
|
+
const commands = script.split("\n").filter((line) => line.trim() !== "" && !line.trim().startsWith("#"));
|
|
2881
|
+
if (commands.length === 0) return null;
|
|
2882
|
+
return {
|
|
2883
|
+
script,
|
|
2884
|
+
shell: shellOf(language),
|
|
2885
|
+
oneLine: commands.length === 1 && !commands[0].trimEnd().endsWith("\\")
|
|
2886
|
+
};
|
|
2887
|
+
}
|
|
2888
|
+
function delimiter(script) {
|
|
2889
|
+
const lines = new Set(script.split("\n"));
|
|
2890
|
+
let name = "ZIDANE_BLOCK";
|
|
2891
|
+
for (let n = 1; lines.has(name); n++) name = `ZIDANE_BLOCK_${n}`;
|
|
2892
|
+
return name;
|
|
2893
|
+
}
|
|
2894
|
+
function writeScript(script) {
|
|
2895
|
+
const end = delimiter(script);
|
|
2896
|
+
return `f=$(mktemp "\${TMPDIR:-/tmp}/zidane-block.XXXXXX") || exit 1
|
|
2897
|
+
cat > "$f" <<'${end}'
|
|
2898
|
+
${script}
|
|
2899
|
+
${end}
|
|
2900
|
+
`;
|
|
2901
|
+
}
|
|
2902
|
+
function blockTerminalInput(plan) {
|
|
2903
|
+
if (plan.oneLine) return `${plan.script}
|
|
2904
|
+
`;
|
|
2905
|
+
return `${writeScript(plan.script).replace(" || exit 1", "")}${plan.shell} "$f"; rm -f "$f"
|
|
2906
|
+
`;
|
|
2907
|
+
}
|
|
2908
|
+
function hash(text) {
|
|
2909
|
+
let h = 2166136261;
|
|
2910
|
+
for (let i = 0; i < text.length; i++) {
|
|
2911
|
+
h ^= text.charCodeAt(i);
|
|
2912
|
+
h = Math.imul(h, 16777619);
|
|
2913
|
+
}
|
|
2914
|
+
return (h >>> 0).toString(16).padStart(8, "0");
|
|
2915
|
+
}
|
|
2916
|
+
function blockRunKey(turnId, code) {
|
|
2917
|
+
return `${turnId}:${hash(code)}`;
|
|
2918
|
+
}
|
|
2919
|
+
const TERMINAL_HISTORY_MAX_CHARS = 4194304;
|
|
2920
|
+
const TERMINAL_VIEW_SCROLLBACK = 5e3;
|
|
2921
|
+
const TERMINAL_VIEW_MAX_LINES = 6e3;
|
|
2922
|
+
const TRACKED_MODES = /* @__PURE__ */ new Set([
|
|
2923
|
+
1,
|
|
2924
|
+
7,
|
|
2925
|
+
9,
|
|
2926
|
+
12,
|
|
2927
|
+
25,
|
|
2928
|
+
47,
|
|
2929
|
+
1e3,
|
|
2930
|
+
1002,
|
|
2931
|
+
1003,
|
|
2932
|
+
1004,
|
|
2933
|
+
1005,
|
|
2934
|
+
1006,
|
|
2935
|
+
1015,
|
|
2936
|
+
1016,
|
|
2937
|
+
1047,
|
|
2938
|
+
1049,
|
|
2939
|
+
2004
|
|
2940
|
+
]);
|
|
2941
|
+
const DEFAULT_ON = /* @__PURE__ */ new Set([7, 25]);
|
|
2942
|
+
const ALT_MODES = [
|
|
2943
|
+
47,
|
|
2944
|
+
1047,
|
|
2945
|
+
1049
|
|
2946
|
+
];
|
|
2947
|
+
const EMPTY_MODES = {
|
|
2948
|
+
modes: /* @__PURE__ */ new Map(),
|
|
2949
|
+
keypad: null,
|
|
2950
|
+
altAt: null
|
|
2951
|
+
};
|
|
2952
|
+
const SEQUENCE = /\x1B(?:\[\?([0-9;]*)([hl])|([=>c]))/g;
|
|
2953
|
+
const PREFIX = /^(?:\x1B\[\?\d+[hl]|\x1B=)*/;
|
|
2954
|
+
const altActive = (modes) => ALT_MODES.some((m) => modes.get(m) === true);
|
|
2955
|
+
function scanModes(state, text, base) {
|
|
2956
|
+
if (!text.includes("\x1B")) return state;
|
|
2957
|
+
let next = state;
|
|
2958
|
+
let modes = null;
|
|
2959
|
+
SEQUENCE.lastIndex = 0;
|
|
2960
|
+
for (let m = SEQUENCE.exec(text); m; m = SEQUENCE.exec(text)) {
|
|
2961
|
+
if (m[3] === "c") {
|
|
2962
|
+
next = EMPTY_MODES;
|
|
2963
|
+
modes = null;
|
|
2964
|
+
continue;
|
|
2965
|
+
}
|
|
2966
|
+
if (m[3]) {
|
|
2967
|
+
const keypad = m[3] === "=";
|
|
2968
|
+
if (next.keypad !== keypad) next = {
|
|
2969
|
+
...next,
|
|
2970
|
+
keypad
|
|
2971
|
+
};
|
|
2972
|
+
continue;
|
|
2973
|
+
}
|
|
2974
|
+
const on = m[2] === "h";
|
|
2975
|
+
const wasAlt = next.altAt !== null;
|
|
2976
|
+
for (const p of m[1].split(";")) {
|
|
2977
|
+
const mode = Number(p);
|
|
2978
|
+
if (!TRACKED_MODES.has(mode) || next.modes.get(mode) === on) continue;
|
|
2979
|
+
if (!modes) {
|
|
2980
|
+
modes = new Map(next.modes);
|
|
2981
|
+
next = {
|
|
2982
|
+
...next,
|
|
2983
|
+
modes
|
|
2984
|
+
};
|
|
2985
|
+
}
|
|
2986
|
+
modes.set(mode, on);
|
|
2987
|
+
}
|
|
2988
|
+
if (modes && next.modes === modes) {
|
|
2989
|
+
const alt = altActive(modes);
|
|
2990
|
+
if (alt !== wasAlt) next = {
|
|
2991
|
+
...next,
|
|
2992
|
+
altAt: alt ? base + m.index : null
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
return next;
|
|
2997
|
+
}
|
|
2998
|
+
function modePrefix(state) {
|
|
2999
|
+
let out = "";
|
|
3000
|
+
for (const [mode, on] of state.modes) if (on !== DEFAULT_ON.has(mode)) out += `\x1B[?${mode}${on ? "h" : "l"}`;
|
|
3001
|
+
if (state.keypad) out += "\x1B=";
|
|
3002
|
+
return out;
|
|
3003
|
+
}
|
|
3004
|
+
function modePrefixLength(text) {
|
|
3005
|
+
return PREFIX.exec(text)[0].length;
|
|
3006
|
+
}
|
|
3007
|
+
const CARRY_MAX = 32;
|
|
3008
|
+
function sliceEnd(text, from, size) {
|
|
3009
|
+
const end = Math.min(text.length, from + Math.max(1, size));
|
|
3010
|
+
if (end < text.length && end - from > 1) {
|
|
3011
|
+
const code = text.charCodeAt(end - 1);
|
|
3012
|
+
if (code >= 55296 && code <= 56319) return end - 1;
|
|
3013
|
+
}
|
|
3014
|
+
return end;
|
|
3015
|
+
}
|
|
3016
|
+
function countLines(text) {
|
|
3017
|
+
let n = 0;
|
|
3018
|
+
for (let i = text.indexOf("\n"); i !== -1; i = text.indexOf("\n", i + 1)) n++;
|
|
3019
|
+
return n;
|
|
3020
|
+
}
|
|
3021
|
+
var OutputHistory = class {
|
|
3022
|
+
maxChars;
|
|
3023
|
+
chunks = [];
|
|
3024
|
+
head = 0;
|
|
3025
|
+
chars = 0;
|
|
3026
|
+
lineCount = 0;
|
|
3027
|
+
state = EMPTY_MODES;
|
|
3028
|
+
carry = "";
|
|
3029
|
+
clean = true;
|
|
3030
|
+
maxLines;
|
|
3031
|
+
/** Stream offset after the last chunk. */
|
|
3032
|
+
end = 0;
|
|
3033
|
+
/**
|
|
3034
|
+
* @param maxChars - Evict the oldest chunks once more characters than this are kept (the newest chunk always stays).
|
|
3035
|
+
* @param options - Further caps.
|
|
3036
|
+
*/
|
|
3037
|
+
constructor(maxChars, options = {}) {
|
|
3038
|
+
this.maxChars = maxChars;
|
|
3039
|
+
this.maxLines = options.maxLines ?? Infinity;
|
|
3040
|
+
}
|
|
3041
|
+
/** Stream offset of the oldest character kept. */
|
|
3042
|
+
get start() {
|
|
3043
|
+
return this.head < this.chunks.length ? this.chunks[this.head].at : this.end;
|
|
2272
3044
|
}
|
|
2273
3045
|
/** Characters kept. */
|
|
2274
3046
|
get size() {
|
|
@@ -3008,6 +3780,8 @@ const DEFAULT_SETTINGS = {
|
|
|
3008
3780
|
useDaemon: false,
|
|
3009
3781
|
remoteHosts: false,
|
|
3010
3782
|
orchestration: false,
|
|
3783
|
+
schedules: false,
|
|
3784
|
+
schedulesAgent: true,
|
|
3011
3785
|
loadProjectExtensions: false,
|
|
3012
3786
|
importForeignConfigs: false,
|
|
3013
3787
|
importRulerConfigs: true,
|
|
@@ -3015,6 +3789,7 @@ const DEFAULT_SETTINGS = {
|
|
|
3015
3789
|
subagentModels: true,
|
|
3016
3790
|
imageGeneration: true,
|
|
3017
3791
|
webSearch: true,
|
|
3792
|
+
secrets: false,
|
|
3018
3793
|
imageModel: "",
|
|
3019
3794
|
maxParallelSubagents: 3,
|
|
3020
3795
|
queueMessages: true,
|
|
@@ -3723,7 +4498,7 @@ function gruvboxTheme(id, label, p) {
|
|
|
3723
4498
|
}
|
|
3724
4499
|
const GRUVBOX_DARK = /* @__PURE__ */ gruvboxTheme("gruvbox-dark", "Gruvbox Dark", DARK);
|
|
3725
4500
|
const GRUVBOX_LIGHT = /* @__PURE__ */ gruvboxTheme("gruvbox-light", "Gruvbox Light", LIGHT);
|
|
3726
|
-
const TEXT
|
|
4501
|
+
const TEXT = "#1f2328";
|
|
3727
4502
|
const DIM = "#656d76";
|
|
3728
4503
|
const MUTE = "#8c959f";
|
|
3729
4504
|
const BORDER = "#d0d7de";
|
|
@@ -3756,7 +4531,7 @@ const LIGHT_THEME = {
|
|
|
3756
4531
|
focusedBackgroundColor: "transparent",
|
|
3757
4532
|
selectedBackgroundColor: "transparent",
|
|
3758
4533
|
selectedTextColor: BRAND,
|
|
3759
|
-
textColor: TEXT
|
|
4534
|
+
textColor: TEXT,
|
|
3760
4535
|
descriptionColor: MUTE,
|
|
3761
4536
|
selectedDescriptionColor: DIM
|
|
3762
4537
|
},
|
|
@@ -3788,7 +4563,7 @@ const LIGHT_THEME = {
|
|
|
3788
4563
|
}
|
|
3789
4564
|
},
|
|
3790
4565
|
syntax: {
|
|
3791
|
-
"default": { fg: TEXT
|
|
4566
|
+
"default": { fg: TEXT },
|
|
3792
4567
|
"markup.heading": {
|
|
3793
4568
|
fg: BRAND,
|
|
3794
4569
|
bold: true
|
|
@@ -3802,19 +4577,19 @@ const LIGHT_THEME = {
|
|
|
3802
4577
|
bold: true
|
|
3803
4578
|
},
|
|
3804
4579
|
"markup.heading.3": {
|
|
3805
|
-
fg: TEXT
|
|
4580
|
+
fg: TEXT,
|
|
3806
4581
|
bold: true
|
|
3807
4582
|
},
|
|
3808
4583
|
"markup.bold": {
|
|
3809
|
-
fg: TEXT
|
|
4584
|
+
fg: TEXT,
|
|
3810
4585
|
bold: true
|
|
3811
4586
|
},
|
|
3812
4587
|
"markup.strong": {
|
|
3813
|
-
fg: TEXT
|
|
4588
|
+
fg: TEXT,
|
|
3814
4589
|
bold: true
|
|
3815
4590
|
},
|
|
3816
4591
|
"markup.italic": {
|
|
3817
|
-
fg: TEXT
|
|
4592
|
+
fg: TEXT,
|
|
3818
4593
|
italic: true
|
|
3819
4594
|
},
|
|
3820
4595
|
"markup.link": {
|
|
@@ -3866,15 +4641,15 @@ const LIGHT_THEME = {
|
|
|
3866
4641
|
"constructor": { fg: "#953800" },
|
|
3867
4642
|
"attribute": { fg: "#0550ae" },
|
|
3868
4643
|
"tag": { fg: "#116329" },
|
|
3869
|
-
"variable": { fg: TEXT
|
|
4644
|
+
"variable": { fg: TEXT },
|
|
3870
4645
|
"variable.builtin": { fg: "#0550ae" },
|
|
3871
4646
|
"variable.parameter": { fg: "#953800" },
|
|
3872
4647
|
"variable.member": { fg: "#0550ae" },
|
|
3873
4648
|
"property": { fg: "#0550ae" },
|
|
3874
4649
|
"operator": { fg: "#cf222e" },
|
|
3875
4650
|
"punctuation": { fg: DIM },
|
|
3876
|
-
"punctuation.bracket": { fg: TEXT
|
|
3877
|
-
"punctuation.delimiter": { fg: TEXT
|
|
4651
|
+
"punctuation.bracket": { fg: TEXT },
|
|
4652
|
+
"punctuation.delimiter": { fg: TEXT },
|
|
3878
4653
|
"label": { fg: "#0550ae" }
|
|
3879
4654
|
}
|
|
3880
4655
|
};
|
|
@@ -4326,6 +5101,21 @@ const SETTINGS_KEYWORDS = {
|
|
|
4326
5101
|
"main session",
|
|
4327
5102
|
"daemon"
|
|
4328
5103
|
],
|
|
5104
|
+
schedules: [
|
|
5105
|
+
"reminder",
|
|
5106
|
+
"remind",
|
|
5107
|
+
"cron",
|
|
5108
|
+
"schedule",
|
|
5109
|
+
"timer",
|
|
5110
|
+
"recurring"
|
|
5111
|
+
],
|
|
5112
|
+
schedulesAgent: [
|
|
5113
|
+
"reminder",
|
|
5114
|
+
"remind",
|
|
5115
|
+
"cron",
|
|
5116
|
+
"schedule",
|
|
5117
|
+
"agent"
|
|
5118
|
+
],
|
|
4329
5119
|
sidebarRunDetails: [
|
|
4330
5120
|
"sidebar",
|
|
4331
5121
|
"status",
|
|
@@ -4420,6 +5210,18 @@ const SETTINGS_TOGGLES = [
|
|
|
4420
5210
|
label: "Main session",
|
|
4421
5211
|
description: "Pin a session that starts, steers and reads your other sessions. Needs the daemon."
|
|
4422
5212
|
},
|
|
5213
|
+
{
|
|
5214
|
+
category: "agent",
|
|
5215
|
+
key: "schedules",
|
|
5216
|
+
label: "Reminders",
|
|
5217
|
+
description: "Send a prompt to a session at a set time, once or on a repeat. Extensions can schedule their own reminders."
|
|
5218
|
+
},
|
|
5219
|
+
{
|
|
5220
|
+
category: "agent",
|
|
5221
|
+
key: "schedulesAgent",
|
|
5222
|
+
label: "Agent can set reminders",
|
|
5223
|
+
description: 'Give the agent a tool to schedule prompts to its own session, such as "check the CI in 20 minutes". Needs Reminders.'
|
|
5224
|
+
},
|
|
4423
5225
|
{
|
|
4424
5226
|
category: "agent",
|
|
4425
5227
|
key: "useDaemon",
|
|
@@ -4568,6 +5370,12 @@ const SETTINGS_TOGGLES = [
|
|
|
4568
5370
|
label: "Web search",
|
|
4569
5371
|
description: "Let the agent search the web for docs, errors and recent changes."
|
|
4570
5372
|
},
|
|
5373
|
+
{
|
|
5374
|
+
category: "agent",
|
|
5375
|
+
key: "secrets",
|
|
5376
|
+
label: "Secrets",
|
|
5377
|
+
description: "Let the agent ask you for an API key or a token. zidane keeps it in a private file for this project, out of the chat, and hides it in tool output."
|
|
5378
|
+
},
|
|
4571
5379
|
{
|
|
4572
5380
|
category: "agent",
|
|
4573
5381
|
key: "decisions",
|
|
@@ -5763,6 +6571,12 @@ function waitedMs(wait, now) {
|
|
|
5763
6571
|
function workedMs(startedAt, wait, now) {
|
|
5764
6572
|
return Math.max(now - startedAt - waitedMs(wait, now), 0);
|
|
5765
6573
|
}
|
|
6574
|
+
function isRunEstimated(view) {
|
|
6575
|
+
return !("problem" in view);
|
|
6576
|
+
}
|
|
6577
|
+
function estimateViewAt(view) {
|
|
6578
|
+
return isRunEstimated(view) ? view.at : view.problem.at;
|
|
6579
|
+
}
|
|
5766
6580
|
function estimateReadout(view, now) {
|
|
5767
6581
|
const worked = workedMs(view.startedAt, {
|
|
5768
6582
|
ms: view.waitMs,
|
|
@@ -5787,6 +6601,7 @@ function formatEstimate(ms) {
|
|
|
5787
6601
|
if (seconds < 60) return `~${Math.max(Math.ceil(seconds / 10) * 10, 10)}s`;
|
|
5788
6602
|
const minutes = Math.ceil(seconds / 60);
|
|
5789
6603
|
if (minutes < 60) return `~${minutes}m`;
|
|
6604
|
+
if (minutes > 1440) return "24h+";
|
|
5790
6605
|
if (minutes < 600) {
|
|
5791
6606
|
const rounded = Math.round(minutes / 5) * 5;
|
|
5792
6607
|
const h = Math.floor(rounded / 60);
|
|
@@ -6002,6 +6817,15 @@ const ONBOARDING_FEATURES = [
|
|
|
6002
6817
|
unlocks: "Runs that keep going after you close the window, and one session open in several windows.",
|
|
6003
6818
|
prevents: "Losing a long run when its window closes."
|
|
6004
6819
|
},
|
|
6820
|
+
{
|
|
6821
|
+
key: "schedules",
|
|
6822
|
+
group: "background",
|
|
6823
|
+
surfaces: BOTH,
|
|
6824
|
+
includes: ["schedulesAgent"],
|
|
6825
|
+
example: "For example, you type `/remind in 20m check the deploy`. Twenty minutes later, the session gets the message and runs it.",
|
|
6826
|
+
unlocks: "Prompts that run later or on a repeat, and an agent that can come back to a task on its own.",
|
|
6827
|
+
prevents: "Forgetting to come back to a long task, and checking the same thing by hand every morning."
|
|
6828
|
+
},
|
|
6005
6829
|
{
|
|
6006
6830
|
key: "browser",
|
|
6007
6831
|
group: "desktop",
|
|
@@ -6036,6 +6860,14 @@ const ONBOARDING_FEATURES = [
|
|
|
6036
6860
|
example: "For example, a project adds a `/deploy` command in its `.zidane/extensions` folder.",
|
|
6037
6861
|
unlocks: "Extensions that a project ships load when you open it, such as its own commands.",
|
|
6038
6862
|
prevents: "Off, code from a repository that you clone never runs on its own."
|
|
6863
|
+
},
|
|
6864
|
+
{
|
|
6865
|
+
key: "secrets",
|
|
6866
|
+
group: "trust",
|
|
6867
|
+
surfaces: BOTH,
|
|
6868
|
+
example: "For example, the agent needs a Tailscale auth key to set up test machines. It asks for it in a password field, and its commands read it from a private file.",
|
|
6869
|
+
unlocks: "The agent can ask you for an API key or a token when a task needs one. Its commands use it, and the chat never shows it.",
|
|
6870
|
+
prevents: "Keys pasted into the chat, where the model, the transcript and the logs keep them."
|
|
6039
6871
|
}
|
|
6040
6872
|
];
|
|
6041
6873
|
const ONBOARDING_FEATURE_GROUPS = [
|
|
@@ -6347,9 +7179,12 @@ const ONBOARDING_STEP_SETTINGS = {
|
|
|
6347
7179
|
"sandboxNetwork",
|
|
6348
7180
|
"maxCostUsd"
|
|
6349
7181
|
],
|
|
6350
|
-
features: featureStepSettings()
|
|
7182
|
+
features: /* @__PURE__ */ featureStepSettings()
|
|
6351
7183
|
};
|
|
6352
|
-
const ONBOARDING_SETTING_KEYS =
|
|
7184
|
+
const ONBOARDING_SETTING_KEYS = /* @__PURE__ */ stepSettingKeys(ONBOARDING_STEP_SETTINGS);
|
|
7185
|
+
function stepSettingKeys(steps) {
|
|
7186
|
+
return [...new Set(Object.values(steps).flatMap((keys) => keys ?? []))];
|
|
7187
|
+
}
|
|
6353
7188
|
function stepsFor(context, path) {
|
|
6354
7189
|
const mode = context.mode === "full" && path === "quick" ? "quick" : context.mode;
|
|
6355
7190
|
return planOnboarding({
|
|
@@ -7698,6 +8533,23 @@ const TUTORIALS = {
|
|
|
7698
8533
|
detail: "Paste its address and the token. Its sessions run there, and a run keeps going when you close this window."
|
|
7699
8534
|
}
|
|
7700
8535
|
]
|
|
8536
|
+
},
|
|
8537
|
+
secrets: {
|
|
8538
|
+
title: "How secrets work",
|
|
8539
|
+
steps: [
|
|
8540
|
+
{
|
|
8541
|
+
title: "The agent asks for a key",
|
|
8542
|
+
detail: "When a task needs an API key or a token, the agent asks you for it in a password field."
|
|
8543
|
+
},
|
|
8544
|
+
{
|
|
8545
|
+
title: "zidane keeps it out of the chat",
|
|
8546
|
+
detail: "It stays in a private file for this project, for the time you pick. The chat and the transcript never show it."
|
|
8547
|
+
},
|
|
8548
|
+
{
|
|
8549
|
+
title: "Commands read it from the file",
|
|
8550
|
+
detail: "Commands read it at $ZIDANE_SECRETS/NAME, and tool output shows [secret:NAME]. You revoke it in the Secrets panel or in Settings."
|
|
8551
|
+
}
|
|
8552
|
+
]
|
|
7701
8553
|
}
|
|
7702
8554
|
};
|
|
7703
8555
|
const ON_SERVER = {
|
|
@@ -7732,7 +8584,11 @@ const ON_SERVER = {
|
|
|
7732
8584
|
title: "Every app uses them",
|
|
7733
8585
|
detail: `Every session on ${host} uses them, from any app. A key in its environment works too.`
|
|
7734
8586
|
}
|
|
7735
|
-
})
|
|
8587
|
+
}),
|
|
8588
|
+
secrets: (host) => ({ 1: {
|
|
8589
|
+
title: "zidane keeps it out of the chat",
|
|
8590
|
+
detail: `It stays in a private file on ${host}, for this project, for the time you pick. The chat and the transcript never show it.`
|
|
8591
|
+
} })
|
|
7736
8592
|
};
|
|
7737
8593
|
function tutorialOnServer(topic, host) {
|
|
7738
8594
|
const words2 = TUTORIALS[topic];
|
|
@@ -9108,6 +9964,35 @@ function planAttachment(file) {
|
|
|
9108
9964
|
mediaType: isTextType(declared) ? declared : "text/plain"
|
|
9109
9965
|
};
|
|
9110
9966
|
}
|
|
9967
|
+
function authPrimaryAction(auth) {
|
|
9968
|
+
return auth.kind === "busy" || auth.kind === "network" ? "retry" : "sign-in";
|
|
9969
|
+
}
|
|
9970
|
+
function authOffersSignInFallback(auth) {
|
|
9971
|
+
return auth.kind === "busy";
|
|
9972
|
+
}
|
|
9973
|
+
function authProviderKeys(auth) {
|
|
9974
|
+
return [...new Set([auth.providerId, auth.provider].filter((key) => !!key))];
|
|
9975
|
+
}
|
|
9976
|
+
function sameAuthTarget(a, b) {
|
|
9977
|
+
return a.source === b.source && authProviderKeys(a).some((key) => authProviderKeys(b).includes(key)) && (a.accountId ?? null) === (b.accountId ?? null);
|
|
9978
|
+
}
|
|
9979
|
+
function authFailureHeadline(auth, label = auth.provider) {
|
|
9980
|
+
const who = auth.accountLabel ? `${label} (${auth.accountLabel})` : label;
|
|
9981
|
+
switch (auth.kind) {
|
|
9982
|
+
case "expired":
|
|
9983
|
+
return `${who} sign-in expired`;
|
|
9984
|
+
case "revoked":
|
|
9985
|
+
return `${who} sign-in was revoked`;
|
|
9986
|
+
case "missing":
|
|
9987
|
+
return `Not signed in to ${who}`;
|
|
9988
|
+
case "busy":
|
|
9989
|
+
return `${who} sign-in is stuck refreshing in another process${auth.holderPid ? ` (pid ${auth.holderPid})` : ""}`;
|
|
9990
|
+
case "network":
|
|
9991
|
+
return `Couldn't reach ${label} to refresh the sign-in`;
|
|
9992
|
+
case "rejected":
|
|
9993
|
+
return `${who} rejected the credentials`;
|
|
9994
|
+
}
|
|
9995
|
+
}
|
|
9111
9996
|
const SUBCOMMAND_PROGRAMS = /* @__PURE__ */ new Set([
|
|
9112
9997
|
"git",
|
|
9113
9998
|
"gh",
|
|
@@ -9965,7 +10850,6 @@ function parseKeyValueLines(raw, opts) {
|
|
|
9965
10850
|
};
|
|
9966
10851
|
}
|
|
9967
10852
|
const INBOX_PANEL_ID = "inbox";
|
|
9968
|
-
const TODOS_PANEL_ID = "todos";
|
|
9969
10853
|
const QUEUE_PANEL_ID = "queue";
|
|
9970
10854
|
const ARTIFACTS_PANEL_ID = "artifacts";
|
|
9971
10855
|
const DIFFS_PANEL_ID = "diffs";
|
|
@@ -9973,6 +10857,8 @@ const FILES_PANEL_ID = "files";
|
|
|
9973
10857
|
const BROWSER_PANEL_ID = "browser";
|
|
9974
10858
|
const TERMINAL_PANEL_ID = "terminal";
|
|
9975
10859
|
const SIDE_PANEL_ID = "side";
|
|
10860
|
+
const SECRETS_PANEL_ID = "secrets";
|
|
10861
|
+
const REMINDERS_PANEL_ID = "reminders";
|
|
9976
10862
|
const BUILTIN_PANEL_TABS = [
|
|
9977
10863
|
{
|
|
9978
10864
|
id: INBOX_PANEL_ID,
|
|
@@ -9983,15 +10869,6 @@ const BUILTIN_PANEL_TABS = [
|
|
|
9983
10869
|
},
|
|
9984
10870
|
builtin: true
|
|
9985
10871
|
},
|
|
9986
|
-
{
|
|
9987
|
-
id: TODOS_PANEL_ID,
|
|
9988
|
-
label: "Todos",
|
|
9989
|
-
icon: {
|
|
9990
|
-
gui: "i-ph-list-checks",
|
|
9991
|
-
tui: "▣"
|
|
9992
|
-
},
|
|
9993
|
-
builtin: true
|
|
9994
|
-
},
|
|
9995
10872
|
{
|
|
9996
10873
|
id: QUEUE_PANEL_ID,
|
|
9997
10874
|
label: "Queue",
|
|
@@ -10054,12 +10931,32 @@ const BUILTIN_PANEL_TABS = [
|
|
|
10054
10931
|
tui: "◇"
|
|
10055
10932
|
},
|
|
10056
10933
|
builtin: true
|
|
10934
|
+
},
|
|
10935
|
+
{
|
|
10936
|
+
id: SECRETS_PANEL_ID,
|
|
10937
|
+
label: "Secrets",
|
|
10938
|
+
icon: {
|
|
10939
|
+
gui: "i-ph-key",
|
|
10940
|
+
tui: "⚿"
|
|
10941
|
+
},
|
|
10942
|
+
builtin: true
|
|
10943
|
+
},
|
|
10944
|
+
{
|
|
10945
|
+
id: REMINDERS_PANEL_ID,
|
|
10946
|
+
label: "Reminders",
|
|
10947
|
+
icon: {
|
|
10948
|
+
gui: "i-ph-alarm",
|
|
10949
|
+
tui: "◷"
|
|
10950
|
+
},
|
|
10951
|
+
builtin: true
|
|
10057
10952
|
}
|
|
10058
10953
|
];
|
|
10059
10954
|
function buildPanelCatalog(extensionPanels, options = {}) {
|
|
10060
10955
|
const tabs = [];
|
|
10061
10956
|
for (const tab of BUILTIN_PANEL_TABS) {
|
|
10062
10957
|
if (tab.id === "artifacts" && options.showArtifacts === false) continue;
|
|
10958
|
+
if (tab.id === "secrets" && options.showSecrets !== true) continue;
|
|
10959
|
+
if (tab.id === "reminders" && options.showReminders !== true) continue;
|
|
10063
10960
|
if (options.omitBuiltins?.includes(tab.id)) continue;
|
|
10064
10961
|
tabs.push(tab);
|
|
10065
10962
|
}
|
|
@@ -10074,7 +10971,9 @@ function buildPanelCatalog(extensionPanels, options = {}) {
|
|
|
10074
10971
|
label: p.label,
|
|
10075
10972
|
builtin: false,
|
|
10076
10973
|
owner: p.owner,
|
|
10077
|
-
...p.icon ? { icon: p.icon } : {}
|
|
10974
|
+
...p.icon ? { icon: p.icon } : {},
|
|
10975
|
+
...p.ownerName ? { ownerName: p.ownerName } : {},
|
|
10976
|
+
...p.ownerIcon ? { ownerIcon: p.ownerIcon } : {}
|
|
10078
10977
|
});
|
|
10079
10978
|
}
|
|
10080
10979
|
return tabs;
|
|
@@ -10323,867 +11222,293 @@ function stepStreamRate(state, sample) {
|
|
|
10323
11222
|
estimated: sample.estimated
|
|
10324
11223
|
};
|
|
10325
11224
|
if (point.t <= last.t) return state;
|
|
10326
|
-
const kept = [...state.samples, point];
|
|
10327
|
-
let start = 0;
|
|
10328
|
-
while (start < kept.length - 2 && kept[start + 1].t <= point.t - WINDOW_MS) start++;
|
|
10329
|
-
const samples = kept.slice(start);
|
|
10330
|
-
const base = samples[0];
|
|
10331
|
-
const span = point.t - base.t;
|
|
10332
|
-
let rate = state.rate;
|
|
10333
|
-
if (span >= MIN_SPAN_MS) {
|
|
10334
|
-
const reading = (point.n - base.n) / span * 1e3;
|
|
10335
|
-
if (reading >= 0 && reading <= 6e3) rate = rate === null ? reading : rate + SMOOTHING * (reading - rate);
|
|
10336
|
-
}
|
|
10337
|
-
return {
|
|
10338
|
-
turnId: state.turnId,
|
|
10339
|
-
samples,
|
|
10340
|
-
estimated: sample.estimated,
|
|
10341
|
-
rate
|
|
10342
|
-
};
|
|
10343
|
-
}
|
|
10344
|
-
function streamRateValue(state) {
|
|
10345
|
-
if (state.rate === null) return null;
|
|
10346
|
-
const rounded = Math.round(state.rate);
|
|
10347
|
-
return rounded > 0 ? rounded : null;
|
|
10348
|
-
}
|
|
10349
|
-
const USER_TODO_ID_PREFIX = "user-";
|
|
10350
|
-
function nextTodoId(items) {
|
|
10351
|
-
const taken = new Set(items.map((i) => i.id));
|
|
10352
|
-
for (let n = 1; ; n++) {
|
|
10353
|
-
const id = `${USER_TODO_ID_PREFIX}${n}`;
|
|
10354
|
-
if (!taken.has(id)) return id;
|
|
10355
|
-
}
|
|
10356
|
-
}
|
|
10357
|
-
function addTodo(items, content) {
|
|
10358
|
-
const trimmed = content.trim();
|
|
10359
|
-
if (!trimmed) return [...items];
|
|
10360
|
-
return [...items, {
|
|
10361
|
-
id: nextTodoId(items),
|
|
10362
|
-
content: trimmed,
|
|
10363
|
-
status: "pending"
|
|
10364
|
-
}];
|
|
10365
|
-
}
|
|
10366
|
-
function editTodo(items, id, content) {
|
|
10367
|
-
const trimmed = content.trim();
|
|
10368
|
-
if (!trimmed) return [...items];
|
|
10369
|
-
return items.map((item) => item.id === id ? {
|
|
10370
|
-
...item,
|
|
10371
|
-
content: trimmed
|
|
10372
|
-
} : item);
|
|
10373
|
-
}
|
|
10374
|
-
function removeTodo(items, id) {
|
|
10375
|
-
return items.filter((item) => item.id !== id);
|
|
10376
|
-
}
|
|
10377
|
-
function clearTodos() {
|
|
10378
|
-
return [];
|
|
10379
|
-
}
|
|
10380
|
-
function cycleTodoStatus(items, id) {
|
|
10381
|
-
const target = items.find((item) => item.id === id);
|
|
10382
|
-
if (!target) return [...items];
|
|
10383
|
-
const next = nextStatus(target.status);
|
|
10384
|
-
return items.map((item) => {
|
|
10385
|
-
if (item.id === id) return {
|
|
10386
|
-
...item,
|
|
10387
|
-
status: next
|
|
10388
|
-
};
|
|
10389
|
-
if (next === "in_progress" && item.status === "in_progress") return {
|
|
10390
|
-
...item,
|
|
10391
|
-
status: "pending"
|
|
10392
|
-
};
|
|
10393
|
-
return item;
|
|
10394
|
-
});
|
|
10395
|
-
}
|
|
10396
|
-
function nextStatus(status) {
|
|
10397
|
-
switch (status) {
|
|
10398
|
-
case "pending":
|
|
10399
|
-
return "in_progress";
|
|
10400
|
-
case "in_progress":
|
|
10401
|
-
return "completed";
|
|
10402
|
-
default:
|
|
10403
|
-
return "pending";
|
|
10404
|
-
}
|
|
10405
|
-
}
|
|
10406
|
-
function buildTodoRetryMessage(item) {
|
|
10407
|
-
return `Retry this todo (currently ${item.status}): "${item.content}"`;
|
|
10408
|
-
}
|
|
10409
|
-
const RESET_UNITS = [
|
|
10410
|
-
["d", 86400],
|
|
10411
|
-
["h", 3600],
|
|
10412
|
-
["min", 60],
|
|
10413
|
-
["s", 1]
|
|
10414
|
-
];
|
|
10415
|
-
function formatResetDelay(ms) {
|
|
10416
|
-
const largest = (seconds2) => RESET_UNITS.findIndex(([, size2]) => seconds2 >= size2);
|
|
10417
|
-
const seconds = Math.max(1, Math.ceil(ms / 1e3));
|
|
10418
|
-
const grain = RESET_UNITS[Math.min(largest(seconds) + 1, RESET_UNITS.length - 1)][1];
|
|
10419
|
-
const rounded = Math.ceil(seconds / grain) * grain;
|
|
10420
|
-
const index = largest(rounded);
|
|
10421
|
-
const [unit, size] = RESET_UNITS[index];
|
|
10422
|
-
const next = RESET_UNITS[index + 1];
|
|
10423
|
-
const rest = next ? rounded % size / next[1] : 0;
|
|
10424
|
-
return rest > 0 ? `${Math.floor(rounded / size)} ${unit} ${rest} ${next[0]}` : `${Math.floor(rounded / size)} ${unit}`;
|
|
10425
|
-
}
|
|
10426
|
-
const TODO_STATUS_GLYPHS = {
|
|
10427
|
-
pending: "☐",
|
|
10428
|
-
in_progress: "◐",
|
|
10429
|
-
completed: "☑",
|
|
10430
|
-
cancelled: "☒"
|
|
10431
|
-
};
|
|
10432
|
-
function accentColor(accent, COLOR) {
|
|
10433
|
-
switch (accent) {
|
|
10434
|
-
case "brand":
|
|
10435
|
-
return COLOR.brand;
|
|
10436
|
-
case "warn":
|
|
10437
|
-
return COLOR.warn;
|
|
10438
|
-
case "model":
|
|
10439
|
-
return COLOR.model;
|
|
10440
|
-
default:
|
|
10441
|
-
return COLOR.accent;
|
|
10442
|
-
}
|
|
10443
|
-
}
|
|
10444
|
-
function showsAccount(snapshot, all) {
|
|
10445
|
-
return snapshot.account !== null && all.some((s) => s !== snapshot && s.providerKey === snapshot.providerKey);
|
|
10446
|
-
}
|
|
10447
|
-
function activeSnapshotFor(all, providerKey, account) {
|
|
10448
|
-
const mine = all.filter((s) => s.providerKey === providerKey);
|
|
10449
|
-
return (account ? mine.find((s) => s.credentialId === account) : void 0) ?? mine.find((s) => s.activeCredential) ?? mine[0] ?? null;
|
|
10450
|
-
}
|
|
10451
|
-
function mostConstrainedWindow(snapshot) {
|
|
10452
|
-
let worst = null;
|
|
10453
|
-
for (const win of snapshot.windows) if (!worst || win.usedPercent > worst.usedPercent) worst = win;
|
|
10454
|
-
return worst;
|
|
10455
|
-
}
|
|
10456
|
-
function formatUsagePercent(usedPercent) {
|
|
10457
|
-
return Number.isInteger(usedPercent) ? String(usedPercent) : usedPercent.toFixed(1);
|
|
10458
|
-
}
|
|
10459
|
-
function usageTone(usedPercent) {
|
|
10460
|
-
if (usedPercent >= 85) return "error";
|
|
10461
|
-
if (usedPercent >= 60) return "warn";
|
|
10462
|
-
return "ok";
|
|
10463
|
-
}
|
|
10464
|
-
function resetLabel(resetsAt, now = Date.now()) {
|
|
10465
|
-
if (resetsAt === null) return null;
|
|
10466
|
-
const remaining = resetsAt - now;
|
|
10467
|
-
return remaining > 0 ? `resets in ${formatResetDelay(remaining)}` : "resetting";
|
|
10468
|
-
}
|
|
10469
|
-
function updatedLabel(snapshots, now = Date.now()) {
|
|
10470
|
-
let newest = -Infinity;
|
|
10471
|
-
for (const s of snapshots) newest = Math.max(newest, s.fetchedAt);
|
|
10472
|
-
if (!Number.isFinite(newest)) return null;
|
|
10473
|
-
const seconds = Math.max(0, Math.floor((now - newest) / 1e3));
|
|
10474
|
-
if (seconds < 60) return `updated ${seconds}s ago`;
|
|
10475
|
-
return `updated ${Math.floor(seconds / 60)}m ago`;
|
|
10476
|
-
}
|
|
10477
|
-
function formatCredits(value) {
|
|
10478
|
-
return value >= 100 ? value.toFixed(0) : value.toFixed(2);
|
|
10479
|
-
}
|
|
10480
|
-
function formatBalance(credits) {
|
|
10481
|
-
const remaining = formatCredits(credits.remaining);
|
|
10482
|
-
return credits.total === null ? remaining : `${remaining} / ${formatCredits(credits.total)}`;
|
|
10483
|
-
}
|
|
10484
|
-
function mergeReplyText(turn) {
|
|
10485
|
-
const { content } = turn;
|
|
10486
|
-
if (!isClaudeReply(turn)) return content;
|
|
10487
|
-
let merged2;
|
|
10488
|
-
for (let i = 0; i < content.length; i++) {
|
|
10489
|
-
const block = content[i];
|
|
10490
|
-
const prev = merged2 ? merged2.at(-1) : content[i - 1];
|
|
10491
|
-
if (block.type === "text" && prev?.type === "text") {
|
|
10492
|
-
merged2 ??= content.slice(0, i);
|
|
10493
|
-
merged2[merged2.length - 1] = {
|
|
10494
|
-
type: "text",
|
|
10495
|
-
text: prev.text + block.text
|
|
10496
|
-
};
|
|
10497
|
-
} else merged2?.push(block);
|
|
10498
|
-
}
|
|
10499
|
-
return merged2 ?? content;
|
|
10500
|
-
}
|
|
10501
|
-
function isClaudeReply(turn) {
|
|
10502
|
-
return turn.role === "assistant" && turn.usage?.modelId?.startsWith("claude") === true;
|
|
10503
|
-
}
|
|
10504
|
-
function modelPickKey(provider, model, account) {
|
|
10505
|
-
return account ? `${provider}\0${model}\0${account}` : `${provider}\0${model}`;
|
|
10506
|
-
}
|
|
10507
|
-
function toggleKeyed(chain, entry, keyOf2) {
|
|
10508
|
-
const key = keyOf2(entry);
|
|
10509
|
-
const idx = chain.findIndex((e) => keyOf2(e) === key);
|
|
10510
|
-
if (idx === -1) return [...chain, entry];
|
|
10511
|
-
return [...chain.slice(0, idx), ...chain.slice(idx + 1)];
|
|
10512
|
-
}
|
|
10513
|
-
function pickPrimaryKeyed(chain, entry, keyOf2) {
|
|
10514
|
-
const key = keyOf2(entry);
|
|
10515
|
-
return [entry, ...chain.filter((e) => keyOf2(e) !== key)];
|
|
10516
|
-
}
|
|
10517
|
-
function positionKeyed(chain, key, keyOf2) {
|
|
10518
|
-
const idx = chain.findIndex((e) => keyOf2(e) === key);
|
|
10519
|
-
return idx === -1 ? null : idx + 1;
|
|
10520
|
-
}
|
|
10521
|
-
function chainsEqualKeyed(a, b, keyOf2) {
|
|
10522
|
-
return a.length === b.length && a.every((e, i) => keyOf2(e) === keyOf2(b[i]));
|
|
10523
|
-
}
|
|
10524
|
-
function reorderKeyed(chain, key, delta, keyOf2) {
|
|
10525
|
-
const from = chain.findIndex((e) => keyOf2(e) === key);
|
|
10526
|
-
const to = from + delta;
|
|
10527
|
-
if (from < 0 || to < 0 || to >= chain.length) return chain;
|
|
10528
|
-
const next = [...chain];
|
|
10529
|
-
const [entry] = next.splice(from, 1);
|
|
10530
|
-
next.splice(to, 0, entry);
|
|
10531
|
-
return next;
|
|
10532
|
-
}
|
|
10533
|
-
function chainAccountConflict(chain, entry) {
|
|
10534
|
-
return chain.some((e) => e.provider === entry.provider && (e.account ?? void 0) !== (entry.account ?? void 0));
|
|
10535
|
-
}
|
|
10536
|
-
function rememberableChain(chain, providerOf, scope) {
|
|
10537
|
-
const primary = chain[0];
|
|
10538
|
-
if (primary === void 0) return null;
|
|
10539
|
-
if (!scope.onServer) return [...chain];
|
|
10540
|
-
if (!scope.canRunHere(providerOf(primary))) return null;
|
|
10541
|
-
return chain.filter((entry) => scope.canRunHere(providerOf(entry)));
|
|
10542
|
-
}
|
|
10543
|
-
function turnAsText(turn) {
|
|
10544
|
-
const parts = [];
|
|
10545
|
-
for (const block of mergeReplyText(turn)) if (block.type === "text" && !block.systemNote && block.text.trim()) parts.push(block.text);
|
|
10546
|
-
else if (block.type === "thinking" && block.text.trim()) parts.push(`[thinking]
|
|
10547
|
-
${block.text}`);
|
|
10548
|
-
else if (block.type === "tool_call") parts.push(`[tool call: ${block.name}]
|
|
10549
|
-
${stringifyArgs(block.input)}`);
|
|
10550
|
-
else if (block.type === "tool_result") parts.push(`[tool result]
|
|
10551
|
-
${typeof block.output === "string" ? block.output : JSON.stringify(block.output, null, 2)}`);
|
|
10552
|
-
else if (block.type === "compact-summary") parts.push(`[compaction summary: ${block.replacesTurnIds.length} turn${block.replacesTurnIds.length === 1 ? "" : "s"}]
|
|
10553
|
-
${block.summary}`);
|
|
10554
|
-
return parts.join("\n\n");
|
|
10555
|
-
}
|
|
10556
|
-
function editableTurnText(turn) {
|
|
10557
|
-
return mergeReplyText(turn).filter((block) => block.type === "text" && !block.systemNote).map((block) => block.text).join("\n\n");
|
|
10558
|
-
}
|
|
10559
|
-
function stringifyArgs(input) {
|
|
10560
|
-
try {
|
|
10561
|
-
return JSON.stringify(input, null, 2);
|
|
10562
|
-
} catch {
|
|
10563
|
-
return String(input);
|
|
11225
|
+
const kept = [...state.samples, point];
|
|
11226
|
+
let start = 0;
|
|
11227
|
+
while (start < kept.length - 2 && kept[start + 1].t <= point.t - WINDOW_MS) start++;
|
|
11228
|
+
const samples = kept.slice(start);
|
|
11229
|
+
const base = samples[0];
|
|
11230
|
+
const span = point.t - base.t;
|
|
11231
|
+
let rate = state.rate;
|
|
11232
|
+
if (span >= MIN_SPAN_MS) {
|
|
11233
|
+
const reading = (point.n - base.n) / span * 1e3;
|
|
11234
|
+
if (reading >= 0 && reading <= 6e3) rate = rate === null ? reading : rate + SMOOTHING * (reading - rate);
|
|
10564
11235
|
}
|
|
10565
|
-
}
|
|
10566
|
-
function countNeighbors(turnIds, turnId) {
|
|
10567
|
-
const idx = turnIds.indexOf(turnId);
|
|
10568
|
-
if (idx === -1) return null;
|
|
10569
11236
|
return {
|
|
10570
|
-
|
|
10571
|
-
|
|
11237
|
+
turnId: state.turnId,
|
|
11238
|
+
samples,
|
|
11239
|
+
estimated: sample.estimated,
|
|
11240
|
+
rate
|
|
10572
11241
|
};
|
|
10573
11242
|
}
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
const
|
|
10577
|
-
|
|
10578
|
-
const text = input.trim();
|
|
10579
|
-
if (!text) return null;
|
|
10580
|
-
const port = PORT_ONLY.exec(text);
|
|
10581
|
-
if (port) return canonical(`http://localhost:${port[1]}${port[2] ?? ""}`);
|
|
10582
|
-
if (/^[a-z][a-z\d+.-]*:\/\//i.test(text)) return isAllowedBrowserUrl(text) ? canonical(text) : null;
|
|
10583
|
-
if (/\s/.test(text)) return null;
|
|
10584
|
-
if (LOCAL_HOST.test(text)) return canonical(`http://${text}`);
|
|
10585
|
-
if (HOST_LIKE.test(text)) return canonical(`https://${text}`);
|
|
10586
|
-
return null;
|
|
10587
|
-
}
|
|
10588
|
-
function isAllowedBrowserUrl(url) {
|
|
10589
|
-
if (url === "about:blank") return true;
|
|
10590
|
-
try {
|
|
10591
|
-
const { protocol } = new URL(url);
|
|
10592
|
-
return protocol === "http:" || protocol === "https:";
|
|
10593
|
-
} catch {
|
|
10594
|
-
return false;
|
|
10595
|
-
}
|
|
11243
|
+
function streamRateValue(state) {
|
|
11244
|
+
if (state.rate === null) return null;
|
|
11245
|
+
const rounded = Math.round(state.rate);
|
|
11246
|
+
return rounded > 0 ? rounded : null;
|
|
10596
11247
|
}
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
11248
|
+
const SESSION_SCOPE = "session";
|
|
11249
|
+
function planProgress(plan) {
|
|
11250
|
+
const out = {
|
|
11251
|
+
completed: 0,
|
|
11252
|
+
cancelled: 0,
|
|
11253
|
+
inProgress: 0,
|
|
11254
|
+
pending: 0,
|
|
11255
|
+
total: plan.steps.length,
|
|
11256
|
+
activeIndex: -1
|
|
11257
|
+
};
|
|
11258
|
+
for (const s of plan.steps) if (s.status === "completed") out.completed++;
|
|
11259
|
+
else if (s.status === "cancelled") out.cancelled++;
|
|
11260
|
+
else if (s.status === "in_progress") out.inProgress++;
|
|
11261
|
+
else out.pending++;
|
|
11262
|
+
out.activeIndex = plan.steps.findIndex((s) => s.status === "in_progress");
|
|
11263
|
+
if (out.activeIndex < 0) out.activeIndex = plan.steps.findIndex((s) => s.status === "pending");
|
|
11264
|
+
return out;
|
|
10603
11265
|
}
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
return
|
|
11266
|
+
function planProgressLabel(progress) {
|
|
11267
|
+
if (progress.total === 0) return null;
|
|
11268
|
+
return `${progress.inProgress > 0 ? progress.activeIndex + 1 : progress.completed + progress.cancelled}/${progress.total}`;
|
|
10607
11269
|
}
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
...first,
|
|
10621
|
-
text: notes.map((n) => n.text).join(", ")
|
|
10622
|
-
};
|
|
10623
|
-
merged.set(first, {
|
|
10624
|
-
key,
|
|
10625
|
-
event
|
|
10626
|
-
});
|
|
10627
|
-
}
|
|
10628
|
-
let at = out.length;
|
|
10629
|
-
while (at > 0 && out[at - 1].kind === "separator") at--;
|
|
10630
|
-
out.splice(at, 0, event);
|
|
10631
|
-
notes = [];
|
|
10632
|
-
};
|
|
10633
|
-
for (const event of events) {
|
|
10634
|
-
if (isTopPrompt(event)) flush();
|
|
10635
|
-
if (event.kind === "command-note" && !event.childId) {
|
|
10636
|
-
notes.push(event);
|
|
10637
|
-
continue;
|
|
10638
|
-
}
|
|
10639
|
-
out.push(event);
|
|
11270
|
+
const MARKS = {
|
|
11271
|
+
pending: "[ ]",
|
|
11272
|
+
in_progress: "[>]",
|
|
11273
|
+
completed: "[x]",
|
|
11274
|
+
cancelled: "[-]"
|
|
11275
|
+
};
|
|
11276
|
+
function formatPlanForModel(plan) {
|
|
11277
|
+
const p = planProgress(plan);
|
|
11278
|
+
const lines = [`${plan.title ? `Plan "${plan.title}"` : "Task list"} (${plan.state}${plan.stopReason ? `: ${plan.stopReason.replace("_", " ")}` : ""}) · ${p.completed}/${p.total} completed`];
|
|
11279
|
+
for (const s of plan.steps) {
|
|
11280
|
+
const extra = s.status === "cancelled" && s.cancelledBy === "user" ? " (cancelled by user)" : s.added ? " (added)" : "";
|
|
11281
|
+
lines.push(`${MARKS[s.status]} ${s.id}: ${s.title}${extra}`);
|
|
10640
11282
|
}
|
|
10641
|
-
|
|
10642
|
-
return out.length === events.length && out.every((e, i) => e === events[i]) ? events : out;
|
|
11283
|
+
return lines.join("\n");
|
|
10643
11284
|
}
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
const STRING = 3;
|
|
10649
|
-
const STRING_ESC = 4;
|
|
10650
|
-
function hasAnsi(text) {
|
|
10651
|
-
for (let i = 0; i < text.length; i++) {
|
|
10652
|
-
const code = text.charCodeAt(i);
|
|
10653
|
-
if (code === ESC || code === 155 || code === 157 || code === 13 || code === 8) return true;
|
|
10654
|
-
}
|
|
10655
|
-
return false;
|
|
11285
|
+
function buildPlanResumeMessage(plan) {
|
|
11286
|
+
return `Resume ${plan.title ? `the plan "${plan.title}"` : "your task list"}${plan.stoppedAt ? ` from step ${plan.stoppedAt}` : ""}. Call todowrite with its step ids as you continue.
|
|
11287
|
+
|
|
11288
|
+
${formatPlanForModel(plan)}`;
|
|
10656
11289
|
}
|
|
10657
|
-
function
|
|
10658
|
-
|
|
10659
|
-
if (!a || !b) return false;
|
|
10660
|
-
return a.fg === b.fg && a.bg === b.bg && a.bold === b.bold && a.dim === b.dim && a.italic === b.italic && a.underline === b.underline && a.inverse === b.inverse;
|
|
11290
|
+
function buildStepRetryMessage(step) {
|
|
11291
|
+
return `Retry step ${step.id} (currently ${step.status}): "${step.title}"`;
|
|
10661
11292
|
}
|
|
10662
|
-
|
|
10663
|
-
|
|
11293
|
+
const SECRET_TTLS = [
|
|
11294
|
+
"1h",
|
|
11295
|
+
"24h",
|
|
11296
|
+
"7d",
|
|
11297
|
+
"never"
|
|
11298
|
+
];
|
|
11299
|
+
const DEFAULT_SECRET_TTL = "24h";
|
|
11300
|
+
const SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
11301
|
+
function isSecretName(name) {
|
|
11302
|
+
return typeof name === "string" && SECRET_NAME_PATTERN.test(name);
|
|
11303
|
+
}
|
|
11304
|
+
function isSecretAnswer(value) {
|
|
11305
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
11306
|
+
const kind = value.kind;
|
|
11307
|
+
return kind === "secret-value" || kind === "secret-declined";
|
|
11308
|
+
}
|
|
11309
|
+
function isSecretReference(value) {
|
|
11310
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
11311
|
+
const cast = value;
|
|
11312
|
+
if (typeof cast.secret !== "string" || "value" in cast) return false;
|
|
11313
|
+
return cast.declined === true || typeof cast.path === "string";
|
|
10664
11314
|
}
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
11315
|
+
const RESET_UNITS = [
|
|
11316
|
+
["d", 86400],
|
|
11317
|
+
["h", 3600],
|
|
11318
|
+
["min", 60],
|
|
11319
|
+
["s", 1]
|
|
11320
|
+
];
|
|
11321
|
+
function formatResetDelay(ms) {
|
|
11322
|
+
const largest = (seconds2) => RESET_UNITS.findIndex(([, size2]) => seconds2 >= size2);
|
|
11323
|
+
const seconds = Math.max(1, Math.ceil(ms / 1e3));
|
|
11324
|
+
const grain = RESET_UNITS[Math.min(largest(seconds) + 1, RESET_UNITS.length - 1)][1];
|
|
11325
|
+
const rounded = Math.ceil(seconds / grain) * grain;
|
|
11326
|
+
const index = largest(rounded);
|
|
11327
|
+
const [unit, size] = RESET_UNITS[index];
|
|
11328
|
+
const next = RESET_UNITS[index + 1];
|
|
11329
|
+
const rest = next ? rounded % size / next[1] : 0;
|
|
11330
|
+
return rest > 0 ? `${Math.floor(rounded / size)} ${unit} ${rest} ${next[0]}` : `${Math.floor(rounded / size)} ${unit}`;
|
|
10669
11331
|
}
|
|
10670
|
-
function
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
else if (p === 7) next.inverse = true;
|
|
10681
|
-
else if (p === 22) {
|
|
10682
|
-
delete next.bold;
|
|
10683
|
-
delete next.dim;
|
|
10684
|
-
} else if (p === 23) delete next.italic;
|
|
10685
|
-
else if (p === 24) delete next.underline;
|
|
10686
|
-
else if (p === 27) delete next.inverse;
|
|
10687
|
-
else if (p >= 30 && p <= 37) next.fg = p - 30;
|
|
10688
|
-
else if (p >= 90 && p <= 97) next.fg = p - 90 + 8;
|
|
10689
|
-
else if (p === 39) delete next.fg;
|
|
10690
|
-
else if (p >= 40 && p <= 47) next.bg = p - 40;
|
|
10691
|
-
else if (p >= 100 && p <= 107) next.bg = p - 100 + 8;
|
|
10692
|
-
else if (p === 49) delete next.bg;
|
|
10693
|
-
else if (p === 38 || p === 48) {
|
|
10694
|
-
const [color, after] = extendedColor(params, i + 1);
|
|
10695
|
-
if (color !== void 0) {
|
|
10696
|
-
if (p === 38) next.fg = color;
|
|
10697
|
-
else next.bg = color;
|
|
10698
|
-
}
|
|
10699
|
-
i = after - 1;
|
|
10700
|
-
}
|
|
11332
|
+
function accentColor(accent, COLOR) {
|
|
11333
|
+
switch (accent) {
|
|
11334
|
+
case "brand":
|
|
11335
|
+
return COLOR.brand;
|
|
11336
|
+
case "warn":
|
|
11337
|
+
return COLOR.warn;
|
|
11338
|
+
case "model":
|
|
11339
|
+
return COLOR.model;
|
|
11340
|
+
default:
|
|
11341
|
+
return COLOR.accent;
|
|
10701
11342
|
}
|
|
10702
|
-
if (Object.keys(next).length === 0) return void 0;
|
|
10703
|
-
return sameStyle(style, next) ? style : next;
|
|
10704
11343
|
}
|
|
10705
|
-
function
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
return;
|
|
10720
|
-
}
|
|
10721
|
-
line.push(style ? {
|
|
10722
|
-
text,
|
|
10723
|
-
style
|
|
10724
|
-
} : { text });
|
|
10725
|
-
};
|
|
10726
|
-
const backspace = () => {
|
|
10727
|
-
const last = line[line.length - 1];
|
|
10728
|
-
if (!last) return;
|
|
10729
|
-
last.text = last.text.slice(0, -1);
|
|
10730
|
-
if (last.text === "") line.pop();
|
|
10731
|
-
};
|
|
10732
|
-
return {
|
|
10733
|
-
push(chunk) {
|
|
10734
|
-
const done = [];
|
|
10735
|
-
let i = 0;
|
|
10736
|
-
while (i < chunk.length) {
|
|
10737
|
-
const code = chunk.charCodeAt(i);
|
|
10738
|
-
if (state === TEXT) {
|
|
10739
|
-
if (code === ESC) state = AFTER_ESC;
|
|
10740
|
-
else if (code === 10) {
|
|
10741
|
-
done.push(line);
|
|
10742
|
-
line = [];
|
|
10743
|
-
pendingCr = false;
|
|
10744
|
-
} else if (code === 13) pendingCr = true;
|
|
10745
|
-
else if (code === 8) backspace();
|
|
10746
|
-
else if (code === 155) {
|
|
10747
|
-
state = CSI;
|
|
10748
|
-
params = "";
|
|
10749
|
-
} else if (code === 157) state = STRING;
|
|
10750
|
-
else if (code === 9 || code >= 32 && !(code >= 127 && code < 160)) {
|
|
10751
|
-
let end = i + 1;
|
|
10752
|
-
while (end < chunk.length) {
|
|
10753
|
-
const c2 = chunk.charCodeAt(end);
|
|
10754
|
-
if (c2 === ESC || c2 === 10 || c2 === 13 || c2 === 8 || c2 < 32 && c2 !== 9 || c2 >= 127 && c2 < 160) break;
|
|
10755
|
-
end++;
|
|
10756
|
-
}
|
|
10757
|
-
append(chunk.slice(i, end));
|
|
10758
|
-
i = end;
|
|
10759
|
-
continue;
|
|
10760
|
-
}
|
|
10761
|
-
} else if (state === AFTER_ESC) {
|
|
10762
|
-
if (code === 91) {
|
|
10763
|
-
state = CSI;
|
|
10764
|
-
params = "";
|
|
10765
|
-
} else if (code === 93 || code === 80 || code === 88 || code === 94 || code === 95) state = STRING;
|
|
10766
|
-
else if (code < 32 || code > 47) state = TEXT;
|
|
10767
|
-
} else if (state === CSI) {
|
|
10768
|
-
if (code >= 64 && code <= 126) {
|
|
10769
|
-
if (code === 109) style = applySgr(style, params);
|
|
10770
|
-
state = TEXT;
|
|
10771
|
-
} else if (params.length < 64) params += chunk[i];
|
|
10772
|
-
} else if (state === STRING) {
|
|
10773
|
-
if (code === 7 || code === 156) state = TEXT;
|
|
10774
|
-
else if (code === ESC) state = STRING_ESC;
|
|
10775
|
-
} else state = code === 92 ? TEXT : STRING;
|
|
10776
|
-
i++;
|
|
10777
|
-
}
|
|
10778
|
-
return done;
|
|
10779
|
-
},
|
|
10780
|
-
partial: () => pendingCr ? [] : line
|
|
10781
|
-
};
|
|
11344
|
+
function showsAccount(snapshot, all) {
|
|
11345
|
+
return snapshot.account !== null && all.some((s) => s !== snapshot && s.providerKey === snapshot.providerKey);
|
|
11346
|
+
}
|
|
11347
|
+
function activeSnapshotFor(all, providerKey, account) {
|
|
11348
|
+
const mine = all.filter((s) => s.providerKey === providerKey);
|
|
11349
|
+
return (account ? mine.find((s) => s.credentialId === account) : void 0) ?? mine.find((s) => s.activeCredential) ?? mine[0] ?? null;
|
|
11350
|
+
}
|
|
11351
|
+
function mostConstrainedWindow(snapshot) {
|
|
11352
|
+
let worst = null;
|
|
11353
|
+
for (const win of snapshot.windows) if (!worst || win.usedPercent > worst.usedPercent) worst = win;
|
|
11354
|
+
return worst;
|
|
11355
|
+
}
|
|
11356
|
+
function formatUsagePercent(usedPercent) {
|
|
11357
|
+
return Number.isInteger(usedPercent) ? String(usedPercent) : usedPercent.toFixed(1);
|
|
10782
11358
|
}
|
|
10783
|
-
function
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
return lines;
|
|
11359
|
+
function usageTone(usedPercent) {
|
|
11360
|
+
if (usedPercent >= 85) return "error";
|
|
11361
|
+
if (usedPercent >= 60) return "warn";
|
|
11362
|
+
return "ok";
|
|
10788
11363
|
}
|
|
10789
|
-
function
|
|
10790
|
-
|
|
11364
|
+
function resetLabel(resetsAt, now = Date.now()) {
|
|
11365
|
+
if (resetsAt === null) return null;
|
|
11366
|
+
const remaining = resetsAt - now;
|
|
11367
|
+
return remaining > 0 ? `resets in ${formatResetDelay(remaining)}` : "resetting";
|
|
10791
11368
|
}
|
|
10792
|
-
function
|
|
10793
|
-
|
|
10794
|
-
|
|
11369
|
+
function updatedLabel(snapshots, now = Date.now()) {
|
|
11370
|
+
let newest = -Infinity;
|
|
11371
|
+
for (const s of snapshots) newest = Math.max(newest, s.fetchedAt);
|
|
11372
|
+
if (!Number.isFinite(newest)) return null;
|
|
11373
|
+
const seconds = Math.max(0, Math.floor((now - newest) / 1e3));
|
|
11374
|
+
if (seconds < 60) return `updated ${seconds}s ago`;
|
|
11375
|
+
return `updated ${Math.floor(seconds / 60)}m ago`;
|
|
10795
11376
|
}
|
|
10796
|
-
function
|
|
10797
|
-
|
|
10798
|
-
const out = [];
|
|
10799
|
-
let room = max - 1;
|
|
10800
|
-
for (const span of spans) {
|
|
10801
|
-
if (room <= 0) break;
|
|
10802
|
-
const text = span.text.slice(0, room);
|
|
10803
|
-
out.push(span.style ? {
|
|
10804
|
-
text,
|
|
10805
|
-
style: span.style
|
|
10806
|
-
} : { text });
|
|
10807
|
-
room -= text.length;
|
|
10808
|
-
}
|
|
10809
|
-
out.push({ text: "…" });
|
|
10810
|
-
return out;
|
|
11377
|
+
function formatCredits(value) {
|
|
11378
|
+
return value >= 100 ? value.toFixed(0) : value.toFixed(2);
|
|
10811
11379
|
}
|
|
10812
|
-
function
|
|
10813
|
-
const
|
|
10814
|
-
|
|
10815
|
-
let nextId = 0;
|
|
10816
|
-
const shape = (spans) => {
|
|
10817
|
-
const clipped = clipAnsiLine(spans, lineChars);
|
|
10818
|
-
const text = ansiLineText(clipped);
|
|
10819
|
-
return clipped.some((span) => span.style) ? {
|
|
10820
|
-
text,
|
|
10821
|
-
spans: clipped
|
|
10822
|
-
} : { text };
|
|
10823
|
-
};
|
|
10824
|
-
const push = (entry) => {
|
|
10825
|
-
tail.push(entry);
|
|
10826
|
-
if (tail.length > maxLines) tail.splice(0, tail.length - maxLines);
|
|
10827
|
-
};
|
|
10828
|
-
return {
|
|
10829
|
-
item(stream, text, line) {
|
|
10830
|
-
const at = line !== void 0 ? { line } : {};
|
|
10831
|
-
for (const spans of createAnsiLines().push(`${text}
|
|
10832
|
-
`)) push({
|
|
10833
|
-
id: nextId++,
|
|
10834
|
-
stream,
|
|
10835
|
-
...shape(spans),
|
|
10836
|
-
...at
|
|
10837
|
-
});
|
|
10838
|
-
},
|
|
10839
|
-
chunk(stream, text, line) {
|
|
10840
|
-
const key = `${stream}\0${line ?? ""}`;
|
|
10841
|
-
let command = commands.get(key);
|
|
10842
|
-
if (!command) {
|
|
10843
|
-
command = {
|
|
10844
|
-
reader: createAnsiLines(),
|
|
10845
|
-
stream,
|
|
10846
|
-
...line !== void 0 ? { line } : {}
|
|
10847
|
-
};
|
|
10848
|
-
commands.set(key, command);
|
|
10849
|
-
}
|
|
10850
|
-
const at = line !== void 0 ? { line } : {};
|
|
10851
|
-
for (const spans of command.reader.push(text)) {
|
|
10852
|
-
push({
|
|
10853
|
-
id: command.openId ?? nextId++,
|
|
10854
|
-
stream,
|
|
10855
|
-
...shape(spans),
|
|
10856
|
-
...at
|
|
10857
|
-
});
|
|
10858
|
-
command.openId = void 0;
|
|
10859
|
-
}
|
|
10860
|
-
if (command.reader.partial().length > 0 && command.openId === void 0) command.openId = nextId++;
|
|
10861
|
-
},
|
|
10862
|
-
lines() {
|
|
10863
|
-
const open = [...commands.values()].flatMap(({ reader, stream, line, openId }) => {
|
|
10864
|
-
const spans = reader.partial();
|
|
10865
|
-
return spans.length === 0 || openId === void 0 ? [] : [{
|
|
10866
|
-
id: openId,
|
|
10867
|
-
stream,
|
|
10868
|
-
...shape(spans),
|
|
10869
|
-
...line !== void 0 ? { line } : {}
|
|
10870
|
-
}];
|
|
10871
|
-
});
|
|
10872
|
-
return [...tail, ...open].slice(-maxLines);
|
|
10873
|
-
}
|
|
10874
|
-
};
|
|
11380
|
+
function formatBalance(credits) {
|
|
11381
|
+
const remaining = formatCredits(credits.remaining);
|
|
11382
|
+
return credits.total === null ? remaining : `${remaining} / ${formatCredits(credits.total)}`;
|
|
10875
11383
|
}
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
if (
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
11384
|
+
function mergeReplyText(turn) {
|
|
11385
|
+
const { content } = turn;
|
|
11386
|
+
if (!isClaudeReply(turn)) return content;
|
|
11387
|
+
let merged2;
|
|
11388
|
+
for (let i = 0; i < content.length; i++) {
|
|
11389
|
+
const block = content[i];
|
|
11390
|
+
const prev = merged2 ? merged2.at(-1) : content[i - 1];
|
|
11391
|
+
if (block.type === "text" && prev?.type === "text") {
|
|
11392
|
+
merged2 ??= content.slice(0, i);
|
|
11393
|
+
merged2[merged2.length - 1] = {
|
|
11394
|
+
type: "text",
|
|
11395
|
+
text: prev.text + block.text
|
|
11396
|
+
};
|
|
11397
|
+
} else merged2?.push(block);
|
|
10885
11398
|
}
|
|
10886
|
-
return
|
|
11399
|
+
return merged2 ?? content;
|
|
10887
11400
|
}
|
|
10888
|
-
function
|
|
10889
|
-
|
|
10890
|
-
for (const event of events) if (event.kind === "tool-progress" && event.callId && event.scriptProgress) found.set(scriptProgressKey(event.callId, event.childId), event.scriptProgress);
|
|
10891
|
-
return found;
|
|
11401
|
+
function isClaudeReply(turn) {
|
|
11402
|
+
return turn.role === "assistant" && turn.usage?.modelId?.startsWith("claude") === true;
|
|
10892
11403
|
}
|
|
10893
|
-
function
|
|
10894
|
-
return `${
|
|
11404
|
+
function modelPickKey(provider, model, account) {
|
|
11405
|
+
return account ? `${provider}\0${model}\0${account}` : `${provider}\0${model}`;
|
|
10895
11406
|
}
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
11407
|
+
function toggleKeyed(chain, entry, keyOf2) {
|
|
11408
|
+
const key = keyOf2(entry);
|
|
11409
|
+
const idx = chain.findIndex((e) => keyOf2(e) === key);
|
|
11410
|
+
if (idx === -1) return [...chain, entry];
|
|
11411
|
+
return [...chain.slice(0, idx), ...chain.slice(idx + 1)];
|
|
11412
|
+
}
|
|
11413
|
+
function pickPrimaryKeyed(chain, entry, keyOf2) {
|
|
11414
|
+
const key = keyOf2(entry);
|
|
11415
|
+
return [entry, ...chain.filter((e) => keyOf2(e) !== key)];
|
|
11416
|
+
}
|
|
11417
|
+
function positionKeyed(chain, key, keyOf2) {
|
|
11418
|
+
const idx = chain.findIndex((e) => keyOf2(e) === key);
|
|
11419
|
+
return idx === -1 ? null : idx + 1;
|
|
11420
|
+
}
|
|
11421
|
+
function chainsEqualKeyed(a, b, keyOf2) {
|
|
11422
|
+
return a.length === b.length && a.every((e, i) => keyOf2(e) === keyOf2(b[i]));
|
|
11423
|
+
}
|
|
11424
|
+
function reorderKeyed(chain, key, delta, keyOf2) {
|
|
11425
|
+
const from = chain.findIndex((e) => keyOf2(e) === key);
|
|
11426
|
+
const to = from + delta;
|
|
11427
|
+
if (from < 0 || to < 0 || to >= chain.length) return chain;
|
|
11428
|
+
const next = [...chain];
|
|
11429
|
+
const [entry] = next.splice(from, 1);
|
|
11430
|
+
next.splice(to, 0, entry);
|
|
11431
|
+
return next;
|
|
11432
|
+
}
|
|
11433
|
+
function chainAccountConflict(chain, entry) {
|
|
11434
|
+
return chain.some((e) => e.provider === entry.provider && (e.account ?? void 0) !== (entry.account ?? void 0));
|
|
11435
|
+
}
|
|
11436
|
+
function rememberableChain(chain, providerOf, scope) {
|
|
11437
|
+
const primary = chain[0];
|
|
11438
|
+
if (primary === void 0) return null;
|
|
11439
|
+
if (!scope.onServer) return [...chain];
|
|
11440
|
+
if (!scope.canRunHere(providerOf(primary))) return null;
|
|
11441
|
+
return chain.filter((entry) => scope.canRunHere(providerOf(entry)));
|
|
11442
|
+
}
|
|
11443
|
+
function turnAsText(turn) {
|
|
11444
|
+
const parts = [];
|
|
11445
|
+
for (const block of mergeReplyText(turn)) if (block.type === "text" && !block.systemNote && block.text.trim()) parts.push(block.text);
|
|
11446
|
+
else if (block.type === "thinking" && block.text.trim()) parts.push(`[thinking]
|
|
11447
|
+
${block.text}`);
|
|
11448
|
+
else if (block.type === "tool_call") parts.push(`[tool call: ${block.name}]
|
|
11449
|
+
${stringifyArgs(block.input)}`);
|
|
11450
|
+
else if (block.type === "tool_result") parts.push(`[tool result]
|
|
11451
|
+
${typeof block.output === "string" ? block.output : JSON.stringify(block.output, null, 2)}`);
|
|
11452
|
+
else if (block.type === "compact-summary") parts.push(`[compaction summary: ${block.replacesTurnIds.length} turn${block.replacesTurnIds.length === 1 ? "" : "s"}]
|
|
11453
|
+
${block.summary}`);
|
|
11454
|
+
return parts.join("\n\n");
|
|
11455
|
+
}
|
|
11456
|
+
function editableTurnText(turn) {
|
|
11457
|
+
return mergeReplyText(turn).filter((block) => block.type === "text" && !block.systemNote).map((block) => block.text).join("\n\n");
|
|
11458
|
+
}
|
|
11459
|
+
function stringifyArgs(input) {
|
|
10899
11460
|
try {
|
|
10900
|
-
|
|
11461
|
+
return JSON.stringify(input, null, 2);
|
|
10901
11462
|
} catch {
|
|
10902
|
-
return
|
|
10903
|
-
other: [],
|
|
10904
|
-
raw: json
|
|
10905
|
-
};
|
|
11463
|
+
return String(input);
|
|
10906
11464
|
}
|
|
10907
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return {
|
|
10908
|
-
other: [],
|
|
10909
|
-
raw: json
|
|
10910
|
-
};
|
|
10911
|
-
const options = { other: [] };
|
|
10912
|
-
for (const [key, field] of Object.entries(value)) if (key === "timeout_ms" && typeof field === "number") options.timeoutMs = field;
|
|
10913
|
-
else if (key === "max_output_tokens" && typeof field === "number") options.maxOutputTokens = field;
|
|
10914
|
-
else options.other.push({
|
|
10915
|
-
key,
|
|
10916
|
-
value: JSON.stringify(field)
|
|
10917
|
-
});
|
|
10918
|
-
return options;
|
|
10919
11465
|
}
|
|
10920
|
-
function
|
|
10921
|
-
const
|
|
10922
|
-
|
|
10923
|
-
const error = ended && !endedOk && result ? scriptErrorOf(result) : void 0;
|
|
10924
|
-
const source = code.split("\n").map((line) => line.replace(/\r$/, ""));
|
|
10925
|
-
const optionsMatch = source[0] !== void 0 ? OPTIONS_LINE.exec(source[0]) : null;
|
|
10926
|
-
const options = optionsMatch ? readOptions(optionsMatch[1].trim()) : void 0;
|
|
10927
|
-
let first = optionsMatch ? 1 : 0;
|
|
10928
|
-
while (first < source.length && source[first].trim() === "") first++;
|
|
10929
|
-
let last = source.length - 1;
|
|
10930
|
-
while (last >= first && source[last].trim() === "") last--;
|
|
10931
|
-
const byLine = new Map(progress?.lines.map((entry) => [entry.line, entry]));
|
|
10932
|
-
const furthest = progress?.lines.length ? progress.lines[progress.lines.length - 1].line : 0;
|
|
10933
|
-
const reached = ended && endedOk ? Number.POSITIVE_INFINITY : furthest;
|
|
10934
|
-
const lines = [];
|
|
10935
|
-
for (let i = first; i <= last; i++) {
|
|
10936
|
-
const number = i + 1;
|
|
10937
|
-
const entry = byLine.get(number);
|
|
10938
|
-
const state = error?.line === number ? "failed" : !progress ? "passed" : entry ? entry.status === "running" ? "running" : entry.status === "ok" ? "done" : "failed" : number <= reached ? "passed" : "idle";
|
|
10939
|
-
lines.push({
|
|
10940
|
-
number,
|
|
10941
|
-
label: number - first,
|
|
10942
|
-
text: source[i],
|
|
10943
|
-
state,
|
|
10944
|
-
calls: entry?.calls ?? 0
|
|
10945
|
-
});
|
|
10946
|
-
}
|
|
10947
|
-
const lastLine = lines.at(-1);
|
|
10948
|
-
if (progress && ended && endedOk && lastLine?.state === "passed") lastLine.state = "done";
|
|
10949
|
-
const done = progress?.done ?? 0;
|
|
10950
|
-
const total = progress ? countOnceCallSites(code) : void 0;
|
|
10951
|
-
const exact = total !== void 0 && done + (progress?.running ?? 0) <= total;
|
|
10952
|
-
const running = progress?.lines.find((entry) => entry.status === "running")?.line;
|
|
11466
|
+
function countNeighbors(turnIds, turnId) {
|
|
11467
|
+
const idx = turnIds.indexOf(turnId);
|
|
11468
|
+
if (idx === -1) return null;
|
|
10953
11469
|
return {
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
tracked: progress !== void 0,
|
|
10957
|
-
done,
|
|
10958
|
-
running: progress?.running ?? 0,
|
|
10959
|
-
failed: progress?.failed ?? 0,
|
|
10960
|
-
...exact ? {
|
|
10961
|
-
total,
|
|
10962
|
-
percent: ended && endedOk ? 100 : Math.min(100, Math.round(done / total * 100))
|
|
10963
|
-
} : {},
|
|
10964
|
-
...!ended && progress ? { active: running ?? (furthest || void 0) } : {},
|
|
10965
|
-
output: progress?.output ?? [],
|
|
10966
|
-
...error && lines.some((line) => line.number === error.line) ? { error } : {}
|
|
11470
|
+
before: idx,
|
|
11471
|
+
after: turnIds.length - 1 - idx
|
|
10967
11472
|
};
|
|
10968
11473
|
}
|
|
10969
|
-
const
|
|
10970
|
-
const
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
const
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
11474
|
+
const LOCAL_HOST = /^(?:localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|\[::1\]|[\w-]+\.localhost)(?::\d+)?(?:[/?#]|$)/i;
|
|
11475
|
+
const HOST_LIKE = /^(?:[\w-]+\.)+[a-z]{2,}(?::\d+)?(?:[/?#]|$)/i;
|
|
11476
|
+
const PORT_ONLY = /^:?(\d{2,5})([/?#].*)?$/;
|
|
11477
|
+
function normalizeBrowserUrl(input) {
|
|
11478
|
+
const text = input.trim();
|
|
11479
|
+
if (!text) return null;
|
|
11480
|
+
const port = PORT_ONLY.exec(text);
|
|
11481
|
+
if (port) return canonical(`http://localhost:${port[1]}${port[2] ?? ""}`);
|
|
11482
|
+
if (/^[a-z][a-z\d+.-]*:\/\//i.test(text)) return isAllowedBrowserUrl(text) ? canonical(text) : null;
|
|
11483
|
+
if (/\s/.test(text)) return null;
|
|
11484
|
+
if (LOCAL_HOST.test(text)) return canonical(`http://${text}`);
|
|
11485
|
+
if (HOST_LIKE.test(text)) return canonical(`https://${text}`);
|
|
11486
|
+
return null;
|
|
10978
11487
|
}
|
|
10979
|
-
function
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
10986
|
-
let prev = "";
|
|
10987
|
-
let i = 0;
|
|
10988
|
-
const n = code.length;
|
|
10989
|
-
const templateText = () => {
|
|
10990
|
-
const start = i;
|
|
10991
|
-
while (i < n) {
|
|
10992
|
-
const c2 = code[i];
|
|
10993
|
-
if (c2 === "\\") {
|
|
10994
|
-
i += 2;
|
|
10995
|
-
continue;
|
|
10996
|
-
}
|
|
10997
|
-
if (c2 === "`") {
|
|
10998
|
-
blank(start, i);
|
|
10999
|
-
i++;
|
|
11000
|
-
prev = "`";
|
|
11001
|
-
return;
|
|
11002
|
-
}
|
|
11003
|
-
if (c2 === "$" && code[i + 1] === "{") {
|
|
11004
|
-
blank(start, i);
|
|
11005
|
-
templates.push(braces);
|
|
11006
|
-
i += 2;
|
|
11007
|
-
prev = "{";
|
|
11008
|
-
return;
|
|
11009
|
-
}
|
|
11010
|
-
i++;
|
|
11011
|
-
}
|
|
11012
|
-
blank(start, n);
|
|
11013
|
-
};
|
|
11014
|
-
while (i < n) {
|
|
11015
|
-
const c2 = code[i];
|
|
11016
|
-
if (c2 === "/" && code[i + 1] === "/") {
|
|
11017
|
-
const end = code.indexOf("\n", i);
|
|
11018
|
-
blank(i, end === -1 ? n : end);
|
|
11019
|
-
i = end === -1 ? n : end;
|
|
11020
|
-
continue;
|
|
11021
|
-
}
|
|
11022
|
-
if (c2 === "/" && code[i + 1] === "*") {
|
|
11023
|
-
const end = code.indexOf("*/", i + 2);
|
|
11024
|
-
blank(i, end === -1 ? n : end + 2);
|
|
11025
|
-
i = end === -1 ? n : end + 2;
|
|
11026
|
-
continue;
|
|
11027
|
-
}
|
|
11028
|
-
if (c2 === '"' || c2 === "'") {
|
|
11029
|
-
let j = i + 1;
|
|
11030
|
-
while (j < n && code[j] !== c2 && code[j] !== "\n") j += code[j] === "\\" ? 2 : 1;
|
|
11031
|
-
blank(i + 1, Math.min(j, n));
|
|
11032
|
-
i = j + 1;
|
|
11033
|
-
prev = c2;
|
|
11034
|
-
continue;
|
|
11035
|
-
}
|
|
11036
|
-
if (c2 === "`") {
|
|
11037
|
-
i++;
|
|
11038
|
-
templateText();
|
|
11039
|
-
continue;
|
|
11040
|
-
}
|
|
11041
|
-
if (c2 === "/" && (prev === "" || "(,=:[!&|?{};+-*%<>~^".includes(prev))) {
|
|
11042
|
-
let j = i + 1;
|
|
11043
|
-
let inClass = false;
|
|
11044
|
-
while (j < n && code[j] !== "\n") {
|
|
11045
|
-
const d = code[j];
|
|
11046
|
-
if (d === "\\") {
|
|
11047
|
-
j += 2;
|
|
11048
|
-
continue;
|
|
11049
|
-
}
|
|
11050
|
-
if (d === "[") inClass = true;
|
|
11051
|
-
else if (d === "]") inClass = false;
|
|
11052
|
-
else if (d === "/" && !inClass) break;
|
|
11053
|
-
j++;
|
|
11054
|
-
}
|
|
11055
|
-
blank(i + 1, Math.min(j, n));
|
|
11056
|
-
i = j + 1;
|
|
11057
|
-
prev = ")";
|
|
11058
|
-
continue;
|
|
11059
|
-
}
|
|
11060
|
-
if (c2 === "{") braces++;
|
|
11061
|
-
else if (c2 === "}") {
|
|
11062
|
-
if (templates.length > 0 && templates[templates.length - 1] === braces) {
|
|
11063
|
-
templates.pop();
|
|
11064
|
-
i++;
|
|
11065
|
-
templateText();
|
|
11066
|
-
continue;
|
|
11067
|
-
}
|
|
11068
|
-
braces--;
|
|
11069
|
-
}
|
|
11070
|
-
if (!/\s/.test(c2)) prev = /[\w$]/.test(c2) ? "w" : c2;
|
|
11071
|
-
i++;
|
|
11488
|
+
function isAllowedBrowserUrl(url) {
|
|
11489
|
+
if (url === "about:blank") return true;
|
|
11490
|
+
try {
|
|
11491
|
+
const { protocol } = new URL(url);
|
|
11492
|
+
return protocol === "http:" || protocol === "https:";
|
|
11493
|
+
} catch {
|
|
11494
|
+
return false;
|
|
11072
11495
|
}
|
|
11073
|
-
return out.join("");
|
|
11074
11496
|
}
|
|
11075
|
-
|
|
11076
|
-
|
|
11077
|
-
|
|
11078
|
-
|
|
11079
|
-
|
|
11080
|
-
function countOnceCallSites(code) {
|
|
11081
|
-
const masked = maskScriptSource(code);
|
|
11082
|
-
const sites = /* @__PURE__ */ new Set();
|
|
11083
|
-
for (const match of masked.matchAll(TOOL_CALL)) sites.add(match.index);
|
|
11084
|
-
if ((masked.match(TOOL_REF)?.length ?? 0) !== sites.size) return void 0;
|
|
11085
|
-
const shCalls = [...masked.matchAll(SH_CALL)];
|
|
11086
|
-
if ((masked.match(SH_REF)?.length ?? 0) !== shCalls.length) return void 0;
|
|
11087
|
-
for (const match of shCalls) sites.add(match.index);
|
|
11088
|
-
if (sites.size === 0) return void 0;
|
|
11089
|
-
const stack = [];
|
|
11090
|
-
let pending = null;
|
|
11091
|
-
let nextParen = null;
|
|
11092
|
-
const repeating = () => stack.some((scope) => scope.repeats);
|
|
11093
|
-
const openBody = () => {
|
|
11094
|
-
if (pending === "loopBody") stack.push({
|
|
11095
|
-
close: "stmt",
|
|
11096
|
-
repeats: true
|
|
11097
|
-
});
|
|
11098
|
-
else if (pending === "arrowBody") stack.push({
|
|
11099
|
-
close: "expr",
|
|
11100
|
-
repeats: true
|
|
11101
|
-
});
|
|
11102
|
-
pending = null;
|
|
11103
|
-
};
|
|
11104
|
-
const closeTo = (close) => {
|
|
11105
|
-
while (stack.length > 0) {
|
|
11106
|
-
const scope = stack.pop();
|
|
11107
|
-
if (scope.close === close) return scope;
|
|
11108
|
-
}
|
|
11109
|
-
};
|
|
11110
|
-
const popWhile = (closes) => {
|
|
11111
|
-
while (stack.length > 0 && closes.includes(stack[stack.length - 1].close)) stack.pop();
|
|
11112
|
-
};
|
|
11113
|
-
let i = 0;
|
|
11114
|
-
const n = masked.length;
|
|
11115
|
-
while (i < n) {
|
|
11116
|
-
const c2 = masked[i];
|
|
11117
|
-
if (/\s/.test(c2)) {
|
|
11118
|
-
i++;
|
|
11119
|
-
continue;
|
|
11120
|
-
}
|
|
11121
|
-
if (WORD.test(c2)) {
|
|
11122
|
-
let j = i;
|
|
11123
|
-
while (j < n && WORD.test(masked[j])) j++;
|
|
11124
|
-
const word = masked.slice(i, j);
|
|
11125
|
-
openBody();
|
|
11126
|
-
if (sites.has(i) && repeating()) return void 0;
|
|
11127
|
-
if (word === "for" || word === "while") nextParen = "loop";
|
|
11128
|
-
else if (word === "if" || word === "switch" || word === "catch" || word === "with") nextParen = "cond";
|
|
11129
|
-
else if (word === "function") nextParen = "fn";
|
|
11130
|
-
else if (word === "do") pending = "loopBody";
|
|
11131
|
-
i = j;
|
|
11132
|
-
continue;
|
|
11133
|
-
}
|
|
11134
|
-
if (c2 === "=" && masked[i + 1] === ">") {
|
|
11135
|
-
pending = "arrowBody";
|
|
11136
|
-
i += 2;
|
|
11137
|
-
continue;
|
|
11138
|
-
}
|
|
11139
|
-
if (c2 === "{") {
|
|
11140
|
-
const repeats = pending === "loopBody" || pending === "fnBody" || pending === "braceIsFn" || pending === "arrowBody";
|
|
11141
|
-
stack.push({
|
|
11142
|
-
close: "}",
|
|
11143
|
-
repeats
|
|
11144
|
-
});
|
|
11145
|
-
pending = null;
|
|
11146
|
-
i++;
|
|
11147
|
-
continue;
|
|
11148
|
-
}
|
|
11149
|
-
if (c2 === ";") {
|
|
11150
|
-
popWhile(["stmt", "expr"]);
|
|
11151
|
-
pending = null;
|
|
11152
|
-
i++;
|
|
11153
|
-
continue;
|
|
11154
|
-
}
|
|
11155
|
-
if (c2 === ",") {
|
|
11156
|
-
popWhile(["expr"]);
|
|
11157
|
-
pending = null;
|
|
11158
|
-
i++;
|
|
11159
|
-
continue;
|
|
11160
|
-
}
|
|
11161
|
-
if (c2 === ")" || c2 === "]" || c2 === "}") {
|
|
11162
|
-
const scope = closeTo(c2);
|
|
11163
|
-
pending = null;
|
|
11164
|
-
if (c2 === ")" && scope) {
|
|
11165
|
-
if (scope.kind === "loop") pending = "loopBody";
|
|
11166
|
-
else if (scope.kind === "fn") pending = "fnBody";
|
|
11167
|
-
else if (scope.kind === "other") pending = "braceIsFn";
|
|
11168
|
-
}
|
|
11169
|
-
i++;
|
|
11170
|
-
continue;
|
|
11171
|
-
}
|
|
11172
|
-
openBody();
|
|
11173
|
-
if (c2 === "(") {
|
|
11174
|
-
stack.push({
|
|
11175
|
-
close: ")",
|
|
11176
|
-
repeats: false,
|
|
11177
|
-
kind: nextParen ?? "other"
|
|
11178
|
-
});
|
|
11179
|
-
nextParen = null;
|
|
11180
|
-
} else if (c2 === "[") stack.push({
|
|
11181
|
-
close: "]",
|
|
11182
|
-
repeats: false
|
|
11183
|
-
});
|
|
11184
|
-
i++;
|
|
11497
|
+
function canonical(url) {
|
|
11498
|
+
try {
|
|
11499
|
+
return new URL(url).toString();
|
|
11500
|
+
} catch {
|
|
11501
|
+
return null;
|
|
11185
11502
|
}
|
|
11186
|
-
|
|
11503
|
+
}
|
|
11504
|
+
function scheduleLabel(schedule) {
|
|
11505
|
+
if (schedule.name) return schedule.name;
|
|
11506
|
+
if (schedule.action.kind === "extension") return `${schedule.action.extensionId}: ${schedule.action.handler}`;
|
|
11507
|
+
const text = schedule.action.text.replace(/\s+/g, " ").trim();
|
|
11508
|
+
return text.length > 48 ? `${text.slice(0, 47)}…` : text;
|
|
11509
|
+
}
|
|
11510
|
+
function scheduleTargetSession(action) {
|
|
11511
|
+
return action.kind === "prompt" && "sessionId" in action ? action.sessionId : void 0;
|
|
11187
11512
|
}
|
|
11188
11513
|
const SYNC_CATEGORIES = [
|
|
11189
11514
|
"settings",
|
|
@@ -11259,9 +11584,10 @@ function extensionMark(input) {
|
|
|
11259
11584
|
kind: "icon",
|
|
11260
11585
|
gui: own
|
|
11261
11586
|
};
|
|
11262
|
-
|
|
11587
|
+
const brand = input.brand?.trim() || native?.brand;
|
|
11588
|
+
if (brand) return {
|
|
11263
11589
|
kind: "brand",
|
|
11264
|
-
brand
|
|
11590
|
+
brand
|
|
11265
11591
|
};
|
|
11266
11592
|
const nativeIcon = native?.icon?.gui?.trim();
|
|
11267
11593
|
if (nativeIcon) return {
|
|
@@ -11589,318 +11915,335 @@ async function runBlockOnHost(client, sessionId, request, options = {}) {
|
|
|
11589
11915
|
}
|
|
11590
11916
|
}
|
|
11591
11917
|
export {
|
|
11592
|
-
|
|
11918
|
+
heatmapLevel as $,
|
|
11593
11919
|
APPROVAL_MODE_OPTIONS as A,
|
|
11594
|
-
|
|
11595
|
-
|
|
11920
|
+
ageStep as B,
|
|
11921
|
+
fmtTokens as C,
|
|
11596
11922
|
DURABILITY_OPTIONS as D,
|
|
11597
|
-
|
|
11598
|
-
|
|
11923
|
+
parseCommandInvocation as E,
|
|
11924
|
+
findReferences as F,
|
|
11599
11925
|
GITHUB_PULL_PROVIDER_ID as G,
|
|
11600
|
-
|
|
11601
|
-
|
|
11602
|
-
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
|
|
11926
|
+
GITHUB_ISSUE_PROVIDER_ID as H,
|
|
11927
|
+
githubRefKey as I,
|
|
11928
|
+
isFenceClose as J,
|
|
11929
|
+
parseFenceOpen as K,
|
|
11930
|
+
isShellFence as L,
|
|
11931
|
+
nameFromModelId as M,
|
|
11932
|
+
hasAnsi as N,
|
|
11607
11933
|
ONBOARDING_WORDS as O,
|
|
11608
|
-
|
|
11609
|
-
|
|
11934
|
+
parseAnsi as P,
|
|
11935
|
+
scriptProgressView as Q,
|
|
11610
11936
|
RUN_WAITING_LABEL as R,
|
|
11611
11937
|
SYNC_CATEGORY_INFO as S,
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11938
|
+
SCRIPT_OUTPUT_TAIL_LINES as T,
|
|
11939
|
+
formatRunDuration as U,
|
|
11940
|
+
toolInputCode as V,
|
|
11941
|
+
summarizeOutcomes as W,
|
|
11942
|
+
computeLineDiff as X,
|
|
11943
|
+
heatmapThresholds as Y,
|
|
11944
|
+
daysEndingAt as Z,
|
|
11619
11945
|
__vitePreload as _,
|
|
11620
11946
|
parseBindingSpecs as a,
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11947
|
+
settingKeywords as a$,
|
|
11948
|
+
DIFFS_PANEL_ID as a0,
|
|
11949
|
+
FILES_PANEL_ID as a1,
|
|
11950
|
+
blockRunKey as a2,
|
|
11951
|
+
createOutputTail as a3,
|
|
11952
|
+
smoothCharsForTick as a4,
|
|
11953
|
+
takeChars as a5,
|
|
11954
|
+
scriptProgressByCall as a6,
|
|
11955
|
+
isUserBashEvent as a7,
|
|
11956
|
+
scriptProgressKey as a8,
|
|
11957
|
+
formatToolCall as a9,
|
|
11958
|
+
inferPromptRefs as aA,
|
|
11959
|
+
titleFromText as aB,
|
|
11960
|
+
groupRows as aC,
|
|
11961
|
+
estimateViewAt as aD,
|
|
11962
|
+
DEFAULT_SPACE_ID as aE,
|
|
11963
|
+
resolveSessionSpace as aF,
|
|
11964
|
+
isExtensionSpaceId as aG,
|
|
11965
|
+
compileQuery as aH,
|
|
11966
|
+
renderTemplate as aI,
|
|
11967
|
+
readField as aJ,
|
|
11968
|
+
validateQuery as aK,
|
|
11969
|
+
validateGroupBy as aL,
|
|
11970
|
+
validateSort as aM,
|
|
11971
|
+
viewQuery as aN,
|
|
11972
|
+
SessionQueryError as aO,
|
|
11973
|
+
normalizeSpaces as aP,
|
|
11974
|
+
activeSpaceOf as aQ,
|
|
11975
|
+
sessionDirLabel as aR,
|
|
11976
|
+
projectNameOf as aS,
|
|
11977
|
+
formatCostLabel as aT,
|
|
11978
|
+
rememberableChain as aU,
|
|
11979
|
+
QUEUE_PANEL_ID as aV,
|
|
11980
|
+
describeTime as aW,
|
|
11981
|
+
REMINDERS_PANEL_ID as aX,
|
|
11982
|
+
INBOX_PANEL_ID as aY,
|
|
11983
|
+
planProgressLabel as aZ,
|
|
11984
|
+
modelDisplayName as a_,
|
|
11985
|
+
displayNameFor as aa,
|
|
11986
|
+
spawnParents as ab,
|
|
11987
|
+
summarizeTools as ac,
|
|
11988
|
+
planFold as ad,
|
|
11989
|
+
noteLabel as ae,
|
|
11990
|
+
thoughtLabel as af,
|
|
11991
|
+
toolOverview as ag,
|
|
11992
|
+
foldSummary as ah,
|
|
11993
|
+
foldsInCompactShape as ai,
|
|
11994
|
+
nestedCallShown as aj,
|
|
11995
|
+
createRunStopMarker as ak,
|
|
11996
|
+
authProviderKeys as al,
|
|
11997
|
+
sameAuthTarget as am,
|
|
11998
|
+
mergeTargetIndex as an,
|
|
11999
|
+
finalizeStreamingMarkdown as ao,
|
|
12000
|
+
upsertToolProgress as ap,
|
|
12001
|
+
ownerOf as aq,
|
|
12002
|
+
appendThinkingLines as ar,
|
|
12003
|
+
appendMarkdownDelta as as,
|
|
12004
|
+
reconcileEvents as at,
|
|
12005
|
+
retagUserPromptEventsFromRefs as au,
|
|
12006
|
+
finalizeStreamingMarkdownForOwner as av,
|
|
12007
|
+
discardThinking as aw,
|
|
12008
|
+
parseMachineKind as ax,
|
|
12009
|
+
orderByMachine as ay,
|
|
12010
|
+
machineBlockedReason as az,
|
|
12011
|
+
authFailureHeadline as b,
|
|
12012
|
+
planAttachment as b$,
|
|
12013
|
+
toggleApplies as b0,
|
|
12014
|
+
requirementMet as b1,
|
|
12015
|
+
toggleHeldOn as b2,
|
|
12016
|
+
bindingAlternatives as b3,
|
|
12017
|
+
nativeExtensionByName as b4,
|
|
12018
|
+
extensionMark as b5,
|
|
12019
|
+
NATIVE_EXTENSIONS as b6,
|
|
12020
|
+
DEFAULT_EXTENSION_SOURCE_UNREACHABLE as b7,
|
|
12021
|
+
skillCategory as b8,
|
|
12022
|
+
skillPickOf as b9,
|
|
12023
|
+
chainAccountConflict as bA,
|
|
12024
|
+
positionKeyed as bB,
|
|
12025
|
+
toggleKeyed as bC,
|
|
12026
|
+
reorderKeyed as bD,
|
|
12027
|
+
cacheHintText as bE,
|
|
12028
|
+
CACHE_HINT_MIN_TOKENS as bF,
|
|
12029
|
+
formatModelSetting as bG,
|
|
12030
|
+
parseModelSetting as bH,
|
|
12031
|
+
DEFAULT_MODEL_PICK as bI,
|
|
12032
|
+
isRunEstimated as bJ,
|
|
12033
|
+
estimateReadout as bK,
|
|
12034
|
+
formatEstimate as bL,
|
|
12035
|
+
previewLine as bM,
|
|
12036
|
+
spawnStartParts as bN,
|
|
12037
|
+
runStatusKey as bO,
|
|
12038
|
+
runFoldStatus as bP,
|
|
12039
|
+
RUN_STATUS_TIME_MS as bQ,
|
|
12040
|
+
formatElapsed as bR,
|
|
12041
|
+
CONTINUE_PROMPT as bS,
|
|
12042
|
+
authPrimaryAction as bT,
|
|
12043
|
+
authOffersSignInFallback as bU,
|
|
12044
|
+
SESSION_EVENT_STATUS_STYLE as bV,
|
|
12045
|
+
sessionEventMeta as bW,
|
|
12046
|
+
sessionEventExcerpt as bX,
|
|
12047
|
+
shortSessionId as bY,
|
|
12048
|
+
describeSpawnEnd as bZ,
|
|
12049
|
+
ATTACHMENT_SNIFF_BYTES as b_,
|
|
12050
|
+
RECOMMENDED_SKILL_SOURCES as ba,
|
|
12051
|
+
githubPreviewImageUrl as bb,
|
|
12052
|
+
githubAvatarUrl as bc,
|
|
12053
|
+
DEFAULT_EXTENSION_SOURCE as bd,
|
|
12054
|
+
skillTokenWeights as be,
|
|
12055
|
+
formatTokens as bf,
|
|
12056
|
+
instructionPreviewLines as bg,
|
|
12057
|
+
instructionOriginBadge as bh,
|
|
12058
|
+
filterLogRecords as bi,
|
|
12059
|
+
formatLogLine as bj,
|
|
12060
|
+
LOG_LEVEL_CYCLE as bk,
|
|
12061
|
+
groupSkillPicks as bl,
|
|
12062
|
+
enabledMcpsWith as bm,
|
|
12063
|
+
MCP_KEY_REFUSED_HINT as bn,
|
|
12064
|
+
MCP_STATUS_LABEL as bo,
|
|
12065
|
+
MCP_TRANSPORTS as bp,
|
|
12066
|
+
CONNECTORS as bq,
|
|
12067
|
+
connectorInstalled as br,
|
|
12068
|
+
ageString as bs,
|
|
12069
|
+
validateMcpForm as bt,
|
|
12070
|
+
DEFAULT_OAUTH_ACCOUNT_LABEL as bu,
|
|
12071
|
+
providerBrand as bv,
|
|
12072
|
+
currentModelKeys as bw,
|
|
12073
|
+
customModelTargets as bx,
|
|
12074
|
+
modelPickKey as by,
|
|
12075
|
+
pickPrimaryKeyed as bz,
|
|
11750
12076
|
canonicalKeyName as c,
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11793
|
-
|
|
11794
|
-
|
|
11795
|
-
|
|
11796
|
-
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
|
|
11808
|
-
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
-
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
|
|
11822
|
-
|
|
11823
|
-
|
|
11824
|
-
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
11832
|
-
|
|
11833
|
-
|
|
11834
|
-
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
|
|
11838
|
-
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
|
|
11844
|
-
|
|
11845
|
-
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
|
|
11850
|
-
|
|
11851
|
-
|
|
11852
|
-
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
|
|
11873
|
-
|
|
11874
|
-
|
|
11875
|
-
|
|
11876
|
-
|
|
11877
|
-
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
12077
|
+
SECRET_TTLS as c$,
|
|
12078
|
+
formatBytes as c0,
|
|
12079
|
+
MAX_IMAGE_ATTACHMENT_BYTES as c1,
|
|
12080
|
+
formatCostUsd as c2,
|
|
12081
|
+
formatTokenCount as c3,
|
|
12082
|
+
formatRunReceiptCells as c4,
|
|
12083
|
+
RUN_RECEIPT_SWITCH_GLYPH as c5,
|
|
12084
|
+
RUN_RECEIPT_TURN_GLYPH as c6,
|
|
12085
|
+
shellBlockPlan as c7,
|
|
12086
|
+
blockTerminalInput as c8,
|
|
12087
|
+
stripAnsi as c9,
|
|
12088
|
+
streamRateValue as cA,
|
|
12089
|
+
parseWhen as cB,
|
|
12090
|
+
scheduleTargetSession as cC,
|
|
12091
|
+
retryLabel as cD,
|
|
12092
|
+
parseRepoInput as cE,
|
|
12093
|
+
LOCAL_HOST_KEY as cF,
|
|
12094
|
+
defaultSessionModel as cG,
|
|
12095
|
+
defaultSessionKnobs as cH,
|
|
12096
|
+
defaultSessionAgent as cI,
|
|
12097
|
+
MACHINE_LINK_STATE_TEXT as cJ,
|
|
12098
|
+
DAEMON_HEALTH_STYLE as cK,
|
|
12099
|
+
isValidMachineName as cL,
|
|
12100
|
+
machineSetupCommand as cM,
|
|
12101
|
+
clockText as cN,
|
|
12102
|
+
machineVersionDiffers as cO,
|
|
12103
|
+
clockOrDateText as cP,
|
|
12104
|
+
lastSeenText as cQ,
|
|
12105
|
+
HOST_TOOLS as cR,
|
|
12106
|
+
capabilityTags as cS,
|
|
12107
|
+
hasTool as cT,
|
|
12108
|
+
syncAgo as cU,
|
|
12109
|
+
SYNC_MODES as cV,
|
|
12110
|
+
SYNC_CATEGORIES as cW,
|
|
12111
|
+
syncMarkerOf as cX,
|
|
12112
|
+
settingField as cY,
|
|
12113
|
+
panelBadgeText as cZ,
|
|
12114
|
+
TERMINAL_PANEL_ID as c_,
|
|
12115
|
+
isCacheNotice as ca,
|
|
12116
|
+
gatherCommandNotes as cb,
|
|
12117
|
+
turnSelectionOwnership as cc,
|
|
12118
|
+
runTailActivity as cd,
|
|
12119
|
+
transcriptPresetOf as ce,
|
|
12120
|
+
transcriptPreset as cf,
|
|
12121
|
+
TRANSCRIPT_PRESETS as cg,
|
|
12122
|
+
ONBOARDING_PREVIEW_EVENTS as ch,
|
|
12123
|
+
autoTextModelId as ci,
|
|
12124
|
+
newSpaceId as cj,
|
|
12125
|
+
sessionBadgeTarget as ck,
|
|
12126
|
+
highlightSegments as cl,
|
|
12127
|
+
searchHighlightRanges as cm,
|
|
12128
|
+
sortRows as cn,
|
|
12129
|
+
blendHsl as co,
|
|
12130
|
+
activeSnapshotFor as cp,
|
|
12131
|
+
mostConstrainedWindow as cq,
|
|
12132
|
+
usageTone as cr,
|
|
12133
|
+
formatUsagePercent as cs,
|
|
12134
|
+
resetLabel as ct,
|
|
12135
|
+
compactingParts as cu,
|
|
12136
|
+
chainsEqualKeyed as cv,
|
|
12137
|
+
accentColor as cw,
|
|
12138
|
+
parseSessionKey as cx,
|
|
12139
|
+
EMPTY_RATE as cy,
|
|
12140
|
+
stepStreamRate as cz,
|
|
12141
|
+
SYNC_MODE_LABEL as d,
|
|
12142
|
+
transcriptPresetNotice as d$,
|
|
12143
|
+
DEFAULT_SECRET_TTL as d0,
|
|
12144
|
+
isSecretAnswer as d1,
|
|
12145
|
+
isSecretReference as d2,
|
|
12146
|
+
tidyPromptText as d3,
|
|
12147
|
+
splitPromptSegments as d4,
|
|
12148
|
+
SECRETS_PANEL_ID as d5,
|
|
12149
|
+
turnAsText as d6,
|
|
12150
|
+
modePrefixLength as d7,
|
|
12151
|
+
sliceEnd as d8,
|
|
12152
|
+
OutputHistory as d9,
|
|
12153
|
+
APPROVAL_MODE_TRADEOFFS as dA,
|
|
12154
|
+
SETTING_TRADEOFFS as dB,
|
|
12155
|
+
connectorsFromImport as dC,
|
|
12156
|
+
connectorInputError as dD,
|
|
12157
|
+
CONNECTOR_CATEGORIES as dE,
|
|
12158
|
+
connectorAuthText as dF,
|
|
12159
|
+
NATIVE_EXTENSION_GROUPS as dG,
|
|
12160
|
+
nativeExtensionNeedText as dH,
|
|
12161
|
+
onboardingFeatures as dI,
|
|
12162
|
+
ONBOARDING_FEATURE_GROUPS as dJ,
|
|
12163
|
+
defaultImportSelection as dK,
|
|
12164
|
+
ONBOARDING_AGENT_BRANDS as dL,
|
|
12165
|
+
onboardingSwitchedFeatures as dM,
|
|
12166
|
+
onboardingImportParts as dN,
|
|
12167
|
+
mergeSuggestions as dO,
|
|
12168
|
+
createCommandsCompletionProvider as dP,
|
|
12169
|
+
createFilesCompletionProvider as dQ,
|
|
12170
|
+
createChatsCompletionProvider as dR,
|
|
12171
|
+
patchInlineGhost as dS,
|
|
12172
|
+
createSkillsCompletionProvider as dT,
|
|
12173
|
+
uniqueSkillNamesFromReferences as dU,
|
|
12174
|
+
buildUnifiedDiff as dV,
|
|
12175
|
+
rankPaletteItems as dW,
|
|
12176
|
+
groupPaletteRows as dX,
|
|
12177
|
+
TRANSCRIPT_PRESET_PALETTE_ID as dY,
|
|
12178
|
+
transcriptPresetPalettePicker as dZ,
|
|
12179
|
+
transcriptPresetOfPaletteItem as d_,
|
|
12180
|
+
TERMINAL_HISTORY_MAX_CHARS as da,
|
|
12181
|
+
TERMINAL_VIEW_MAX_LINES as db,
|
|
12182
|
+
TERMINAL_VIEW_SCROLLBACK as dc,
|
|
12183
|
+
moveTab as dd,
|
|
12184
|
+
SESSION_SCOPE as de,
|
|
12185
|
+
planProgress as df,
|
|
12186
|
+
buildStepRetryMessage as dg,
|
|
12187
|
+
buildPlanResumeMessage as dh,
|
|
12188
|
+
isSecretName as di,
|
|
12189
|
+
scheduleLabel as dj,
|
|
12190
|
+
describeTrigger as dk,
|
|
12191
|
+
formatCount as dl,
|
|
12192
|
+
editableTurnText as dm,
|
|
12193
|
+
updatedLabel as dn,
|
|
12194
|
+
showsAccount as dp,
|
|
12195
|
+
formatBalance as dq,
|
|
12196
|
+
usageBlockView as dr,
|
|
12197
|
+
usageBlockContent as ds,
|
|
12198
|
+
settingsSidebar as dt,
|
|
12199
|
+
settingsSearchIndex as du,
|
|
12200
|
+
isolationLabel as dv,
|
|
12201
|
+
LOCAL_SERVER_BRANDS as dw,
|
|
12202
|
+
connectorById as dx,
|
|
12203
|
+
onboardingFeatureCopy as dy,
|
|
12204
|
+
SETTINGS_CHOICES as dz,
|
|
12205
|
+
createOnboardingRun as e,
|
|
12206
|
+
transcriptPresetPaletteItem as e0,
|
|
12207
|
+
spaceOfSwitchItem as e1,
|
|
12208
|
+
spaceSwitchItems as e2,
|
|
12209
|
+
SETUP_PALETTE_ITEM as e3,
|
|
12210
|
+
sessionKey as e4,
|
|
12211
|
+
LOCAL_HOST_NAME as e5,
|
|
12212
|
+
ARTIFACT_BADGES_MAX as e6,
|
|
12213
|
+
spacesEnabled as e7,
|
|
12214
|
+
ARTIFACTS_PANEL_ID as e8,
|
|
12215
|
+
buildPanelCatalog as e9,
|
|
12216
|
+
MEDIA_BY_EXTENSION as ea,
|
|
12217
|
+
USAGE_BLOCK_ID as eb,
|
|
12218
|
+
nativeExtensionSource as ec,
|
|
12219
|
+
connectorServerConfig as ed,
|
|
12220
|
+
machineWaiting as ee,
|
|
12221
|
+
SIDE_PANEL_ID as ef,
|
|
12222
|
+
normalizeBrowserUrl as eg,
|
|
12223
|
+
BROWSER_PANEL_ID as eh,
|
|
12224
|
+
decisionsEnabled as ei,
|
|
12225
|
+
countNeighbors as ej,
|
|
12226
|
+
selectableTurnIds as ek,
|
|
12227
|
+
runBlockOnHost as el,
|
|
12228
|
+
ONBOARDING_STEPS as f,
|
|
12229
|
+
canSkipOnboardingStep as g,
|
|
12230
|
+
currentOnboardingStep as h,
|
|
12231
|
+
pushPaletteRecent as i,
|
|
11889
12232
|
joinNames as j,
|
|
11890
|
-
|
|
12233
|
+
SETTINGS_TOGGLES as k,
|
|
11891
12234
|
lentServerMachines as l,
|
|
11892
12235
|
modelConcern as m,
|
|
11893
|
-
|
|
11894
|
-
|
|
12236
|
+
DEFAULT_SETTINGS as n,
|
|
12237
|
+
pickTab as o,
|
|
11895
12238
|
parseBindingSpec as p,
|
|
11896
|
-
|
|
12239
|
+
openForAttention as q,
|
|
11897
12240
|
runRetryingLabel as r,
|
|
11898
|
-
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
|
|
12241
|
+
openProactive as s,
|
|
12242
|
+
cycleTab as t,
|
|
12243
|
+
closePanel as u,
|
|
12244
|
+
togglePanel as v,
|
|
12245
|
+
mergeBadgeMenu as w,
|
|
12246
|
+
builtinBadgeActions as x,
|
|
12247
|
+
builtinBadgeEffect as y,
|
|
12248
|
+
isBadgeColor as z
|
|
11906
12249
|
};
|