@agentdocumentformat/cli 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adf.mjs +3 -3
- package/dist/chunks/{App-QMFRLBPQ.mjs → App-ZRQS3U7S.mjs} +122 -12
- package/dist/chunks/{chatgpt-subscription-BQGWYZXE.mjs → chatgpt-subscription-E4MXTIAT.mjs} +1 -1
- package/dist/chunks/{chunk-LAZIXV2F.mjs → chunk-BNXUAOO4.mjs} +2 -1
- package/dist/chunks/{cli-ZGVQRVSQ.mjs → cli-JDBN7CBR.mjs} +1 -1
- package/dist/chunks/{daemon-YMIWVG5G.mjs → daemon-6RA2DIJ2.mjs} +27 -26
- package/dist/chunks/{tui-LWLJUXZ3.mjs → tui-I5LEARAV.mjs} +1 -1
- package/package.json +1 -1
package/dist/adf.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import "./chunks/chunk-M2RX3S2T.mjs";
|
|
|
9
9
|
|
|
10
10
|
// src/main/cli/bin.ts
|
|
11
11
|
function version() {
|
|
12
|
-
return "0.7.
|
|
12
|
+
return "0.7.5";
|
|
13
13
|
}
|
|
14
14
|
var DAEMON_HELP = `Usage: adf daemon [--port <n>] [--host <h>] [--settings <file>]
|
|
15
15
|
adf daemon start [--port <n>] [--force]
|
|
@@ -140,9 +140,9 @@ async function main(argv) {
|
|
|
140
140
|
let { daemonPaths } = await import("./chunks/daemon-control-HKFVSQTQ.mjs");
|
|
141
141
|
process.env.ADF_DAEMON_PIDFILE = daemonPaths(Number(process.env.ADF_DAEMON_PORT ?? 7385)).pidFile;
|
|
142
142
|
}
|
|
143
|
-
return await import("./chunks/daemon-
|
|
143
|
+
return await import("./chunks/daemon-6RA2DIJ2.mjs"), -1;
|
|
144
144
|
}
|
|
145
|
-
let [{ runCli, tuiInvocation }, control] = await Promise.all([import("./chunks/cli-
|
|
145
|
+
let [{ runCli, tuiInvocation }, control] = await Promise.all([import("./chunks/cli-JDBN7CBR.mjs"), import("./chunks/daemon-control-HKFVSQTQ.mjs")]);
|
|
146
146
|
return tuiInvocation(argv) && process.env.NODE_ENV === void 0 && (process.env.NODE_ENV = "production", process.env.ADF_NODE_ENV_DEFAULTED = "1"), await runCli(argv, {
|
|
147
147
|
fetch: globalThis.fetch.bind(globalThis),
|
|
148
148
|
stdout: (text) => process.stdout.write(text),
|
|
@@ -5,7 +5,8 @@ const require = __adfCreateRequire(import.meta.url);
|
|
|
5
5
|
const __filename = __adfFileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __adfDirname(__filename);
|
|
7
7
|
import {
|
|
8
|
-
auth_flow_exports
|
|
8
|
+
auth_flow_exports,
|
|
9
|
+
openBrowser
|
|
9
10
|
} from "./chunk-6VQEXLE2.mjs";
|
|
10
11
|
import {
|
|
11
12
|
createMouseController,
|
|
@@ -1260,8 +1261,8 @@ Accept the review and load it?`,
|
|
|
1260
1261
|
return failure(store, null, "Accept review", err), !1;
|
|
1261
1262
|
}
|
|
1262
1263
|
}
|
|
1263
|
-
async function runAutostart(store,
|
|
1264
|
-
let trackedDirs =
|
|
1264
|
+
async function runAutostart(store, dirs2) {
|
|
1265
|
+
let trackedDirs = dirs2;
|
|
1265
1266
|
if (!trackedDirs || trackedDirs.length === 0)
|
|
1266
1267
|
try {
|
|
1267
1268
|
trackedDirs = (await store.client.runtimeSettings()).trackedDirectories;
|
|
@@ -3829,7 +3830,7 @@ function wakesText(timers, now = Date.now(), sep4 = "\xB7") {
|
|
|
3829
3830
|
}
|
|
3830
3831
|
|
|
3831
3832
|
// src/main/tui/auth/flow.ts
|
|
3832
|
-
var { loginChatGpt, loginGrok, openBrowser } = cjs(auth_flow_exports), seams = { openBrowser };
|
|
3833
|
+
var { loginChatGpt, loginGrok, openBrowser: openBrowser2 } = cjs(auth_flow_exports), seams = { openBrowser: openBrowser2 };
|
|
3833
3834
|
function openUrl(url2) {
|
|
3834
3835
|
seams.openBrowser(url2);
|
|
3835
3836
|
}
|
|
@@ -11349,7 +11350,7 @@ function toneColor3(theme2, tone) {
|
|
|
11349
11350
|
}
|
|
11350
11351
|
}
|
|
11351
11352
|
function Viewer(props) {
|
|
11352
|
-
let { width, height, active, title, meta = [], notice, name, text, bytes, mime, loading, error, plain: plain2 = !1, resetKey, onBack, onEdit, emptyText } = props, theme2 = useTheme(), [top, setTop] = (0, import_react36.useState)(0), [query, setQuery] = (0, import_react36.useState)(""), [typing, setTyping] = (0, import_react36.useState)(!1), [current, setCurrent] = (0, import_react36.useState)(0);
|
|
11353
|
+
let { width, height, active, title, meta = [], notice, name, text, bytes, mime, loading, error, plain: plain2 = !1, resetKey, onBack, onEdit, onOpenExternal, onSaveBack, emptyText } = props, theme2 = useTheme(), [top, setTop] = (0, import_react36.useState)(0), [query, setQuery] = (0, import_react36.useState)(""), [typing, setTyping] = (0, import_react36.useState)(!1), [current, setCurrent] = (0, import_react36.useState)(0);
|
|
11353
11354
|
(0, import_react36.useEffect)(() => {
|
|
11354
11355
|
setTop(0), setQuery(""), setTyping(!1), setCurrent(0);
|
|
11355
11356
|
}, [resetKey]);
|
|
@@ -11380,7 +11381,7 @@ function Viewer(props) {
|
|
|
11380
11381
|
let firstVisible = matches.findIndex((m) => (lineStart2[m.line] ?? 0) >= clampedTop), index = firstVisible >= 0 ? firstVisible : 0;
|
|
11381
11382
|
setCurrent(index), reveal(index);
|
|
11382
11383
|
}
|
|
11383
|
-
}, [query]), useKeys((input, key) => typing ? key.escape ? (setTyping(!1), setQuery(""), !0) : key.return ? (setTyping(!1), !0) : key.backspace || key.delete ? (setQuery((q) => q.slice(0, -1)), !0) : (key.leftArrow || key.rightArrow) && !key.ctrl && !key.shift ? !0 : input && !key.ctrl && !key.meta && !/[\r\n\t]/.test(input) ? (setQuery((q) => q + input), !0) : !1 : (key.ctrl || key.shift) && (key.leftArrow || key.rightArrow) ? !1 : key.upArrow || input === "k" && !key.ctrl ? (scrollTo(clampedTop - 1), !0) : key.downArrow || input === "j" && !key.ctrl ? (scrollTo(clampedTop + 1), !0) : key.pageUp || key.ctrl && input === "u" ? (scrollTo(clampedTop - Math.max(1, bodyRows - 1)), !0) : key.pageDown || input === " " || key.ctrl && input === "d" ? (scrollTo(clampedTop + Math.max(1, bodyRows - 1)), !0) : key.home || input === "g" ? (scrollTo(0), !0) : key.end || input === "G" ? (scrollTo(maxTop), !0) : input === "/" ? (setTyping(!0), setQuery(""), !0) : input === "n" && query ? (jump(1), !0) : input === "N" && query ? (jump(-1), !0) : input === "e" && onEdit ? (onEdit(), !0) : key.escape && query ? (setQuery(""), !0) : (key.escape || key.backspace && !key.ctrl && !key.meta) && onBack ? (onBack(), !0) : !1, { layer: "main", active });
|
|
11384
|
+
}, [query]), useKeys((input, key) => typing ? key.escape ? (setTyping(!1), setQuery(""), !0) : key.return ? (setTyping(!1), !0) : key.backspace || key.delete ? (setQuery((q) => q.slice(0, -1)), !0) : (key.leftArrow || key.rightArrow) && !key.ctrl && !key.shift ? !0 : input && !key.ctrl && !key.meta && !/[\r\n\t]/.test(input) ? (setQuery((q) => q + input), !0) : !1 : (key.ctrl || key.shift) && (key.leftArrow || key.rightArrow) ? !1 : key.upArrow || input === "k" && !key.ctrl ? (scrollTo(clampedTop - 1), !0) : key.downArrow || input === "j" && !key.ctrl ? (scrollTo(clampedTop + 1), !0) : key.pageUp || key.ctrl && input === "u" ? (scrollTo(clampedTop - Math.max(1, bodyRows - 1)), !0) : key.pageDown || input === " " || key.ctrl && input === "d" ? (scrollTo(clampedTop + Math.max(1, bodyRows - 1)), !0) : key.home || input === "g" ? (scrollTo(0), !0) : key.end || input === "G" ? (scrollTo(maxTop), !0) : input === "/" ? (setTyping(!0), setQuery(""), !0) : input === "n" && query ? (jump(1), !0) : input === "N" && query ? (jump(-1), !0) : input === "e" && onEdit ? (onEdit(), !0) : input === "o" && onOpenExternal ? (onOpenExternal(), !0) : input === "s" && onSaveBack ? (onSaveBack(), !0) : key.escape && query ? (setQuery(""), !0) : (key.escape || key.backspace && !key.ctrl && !key.meta) && onBack ? (onBack(), !0) : !1, { layer: "main", active });
|
|
11384
11385
|
let boxRef = (0, import_react36.useRef)(null);
|
|
11385
11386
|
useWheel(boxRef, (delta) => scrollTo(clampedTop + delta * WHEEL_STEP));
|
|
11386
11387
|
let visible = rows.slice(clampedTop, clampedTop + bodyRows), lastLine = visible.length ? visible[visible.length - 1].line + 1 : 0, firstLine2 = visible.length ? visible[0].line + 1 : 0, position = rows.length === 0 ? "" : `L${firstLine2}-${lastLine}/${prepared.lines.length}${maxTop > 0 ? ` ${Math.round(clampedTop / maxTop * 100)}%` : ""}`, search = typing ? `/${query}` : query ? `/${query} ${matches.length ? `${currentIndex + 1}/${matches.length}` : "no match"} n/N` : "", header2 = /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Text, { wrap: "truncate-end", children: [
|
|
@@ -11423,11 +11424,12 @@ function Viewer(props) {
|
|
|
11423
11424
|
theme2.glyph.sep,
|
|
11424
11425
|
" hex dump of the first ",
|
|
11425
11426
|
Math.min(256, bytes.length),
|
|
11426
|
-
" bytes"
|
|
11427
|
+
" bytes",
|
|
11428
|
+
onOpenExternal ? ` ${theme2.glyph.sep} o opens it in the default app` : ""
|
|
11427
11429
|
] }) : null,
|
|
11428
11430
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Box_default, { flexDirection: "column", height: bodyRows, overflow: "hidden", children: body }),
|
|
11429
11431
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Box_default, { justifyContent: "space-between", width, children: [
|
|
11430
|
-
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Text, { color: typing ? theme2.color.accent : theme2.color.muted, wrap: "truncate-end", children: search || (active ? `/ search${onEdit ? " \xB7 e edit" : ""}${onBack ? " \xB7 Backspace back" : ""}` : "") }),
|
|
11432
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Text, { color: typing ? theme2.color.accent : theme2.color.muted, wrap: "truncate-end", children: search || (active ? `/ search${onEdit ? " \xB7 e edit" : ""}${onOpenExternal ? " \xB7 o open in app" : ""}${onBack ? " \xB7 Backspace back" : ""}` : "") }),
|
|
11431
11433
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Text, { color: theme2.color.dim, children: position })
|
|
11432
11434
|
] })
|
|
11433
11435
|
] });
|
|
@@ -11656,6 +11658,77 @@ function DataTab({ kind, width, height, focused, agentId, agentLabel: agentLabel
|
|
|
11656
11658
|
|
|
11657
11659
|
// src/main/tui/views/files/FilesTab.tsx
|
|
11658
11660
|
var import_react38 = __toESM(require_react(), 1);
|
|
11661
|
+
|
|
11662
|
+
// src/main/tui/views/files/external.ts
|
|
11663
|
+
import { promises as fs4, rmSync, statSync as statSync3 } from "node:fs";
|
|
11664
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
11665
|
+
import { join as join4 } from "node:path";
|
|
11666
|
+
var copies = /* @__PURE__ */ new Map(), dirs = /* @__PURE__ */ new Set(), exitHook = !1, copyKey = (agentId, target2) => `${agentId}\0${targetKey(target2)}`, errorText5 = (err) => err instanceof Error ? err.message : String(err), bytesOf = (loaded) => loaded.binary ? Buffer.from(loaded.bytes ?? new Uint8Array()) : Buffer.from(loaded.text ?? "", "utf-8");
|
|
11667
|
+
function externalCopy(agentId, target2) {
|
|
11668
|
+
return copies.get(copyKey(agentId, target2));
|
|
11669
|
+
}
|
|
11670
|
+
function externalChanged(copy) {
|
|
11671
|
+
try {
|
|
11672
|
+
return statSync3(copy.file).mtimeMs !== copy.mtimeMs;
|
|
11673
|
+
} catch {
|
|
11674
|
+
return !1;
|
|
11675
|
+
}
|
|
11676
|
+
}
|
|
11677
|
+
function cleanupExternalCopies() {
|
|
11678
|
+
for (let dir of dirs) rmSync(dir, { recursive: !0, force: !0 });
|
|
11679
|
+
dirs.clear(), copies.clear();
|
|
11680
|
+
}
|
|
11681
|
+
async function openExternal(deps, target2) {
|
|
11682
|
+
let { actions: actions4, agentId } = deps, label2 = targetLabel(target2), loaded = await actions4.run(`Open ${label2}`, (c) => loadTarget(c, agentId, target2));
|
|
11683
|
+
if (!loaded) return !1;
|
|
11684
|
+
let bytes = bytesOf(loaded), existing = externalCopy(agentId, target2), file = existing?.file;
|
|
11685
|
+
if (!existing || !externalChanged(existing)) {
|
|
11686
|
+
try {
|
|
11687
|
+
if (!file) {
|
|
11688
|
+
let dir = await fs4.mkdtemp(join4(tmpdir3(), "adf-tui-open-"));
|
|
11689
|
+
dirs.add(dir), exitHook || (exitHook = !0, process.once("exit", cleanupExternalCopies)), file = join4(dir, targetFileName(target2));
|
|
11690
|
+
}
|
|
11691
|
+
await fs4.writeFile(file, bytes);
|
|
11692
|
+
} catch (err) {
|
|
11693
|
+
return actions4.toast(`Cannot write a temp copy of ${label2} in ${tmpdir3()}: ${errorText5(err)}`, "error", 12e3), !1;
|
|
11694
|
+
}
|
|
11695
|
+
copies.set(copyKey(agentId, target2), { agentId, target: target2, file, original: bytes, binary: loaded.binary, mime: loaded.mime, mtimeMs: (await fs4.stat(file)).mtimeMs });
|
|
11696
|
+
}
|
|
11697
|
+
return (deps.open ?? openBrowser)(file), actions4.toast(`Opened ${label2} in the default app \u2014 after saving there, press s to save it back (${file})`, "info", 8e3), !0;
|
|
11698
|
+
}
|
|
11699
|
+
async function saveBackExternal(deps, target2) {
|
|
11700
|
+
let { client, actions: actions4, agentId, agentLabel: agentLabel5 } = deps, label2 = targetLabel(target2), copy = externalCopy(agentId, target2);
|
|
11701
|
+
if (!copy)
|
|
11702
|
+
return actions4.toast(`${label2} is not open in an app \u2014 press o to open it`, "warn"), "failed";
|
|
11703
|
+
let edited;
|
|
11704
|
+
try {
|
|
11705
|
+
edited = await fs4.readFile(copy.file);
|
|
11706
|
+
} catch (err) {
|
|
11707
|
+
return actions4.toast(`Cannot read ${copy.file}: ${errorText5(err)} \u2014 nothing written`, "error", 12e3), "failed";
|
|
11708
|
+
}
|
|
11709
|
+
if (edited.equals(copy.original))
|
|
11710
|
+
return copy.mtimeMs = (await fs4.stat(copy.file)).mtimeMs, actions4.toast(`No changes to ${label2}`, "info"), "unchanged";
|
|
11711
|
+
let concurrent = null;
|
|
11712
|
+
try {
|
|
11713
|
+
let current = await loadTarget(client, agentId, target2);
|
|
11714
|
+
bytesOf(current).equals(copy.original) || (concurrent = "changed in the agent since you opened it");
|
|
11715
|
+
} catch (err) {
|
|
11716
|
+
concurrent = err.status === 404 ? "was deleted since you opened it" : `could not be re-checked (${errorText5(err)})`;
|
|
11717
|
+
}
|
|
11718
|
+
return await actions4.confirm({
|
|
11719
|
+
title: concurrent ? `Concurrent change: ${label2}` : `Save ${label2}`,
|
|
11720
|
+
message: [
|
|
11721
|
+
concurrent ? `WARNING: ${label2} ${concurrent}. Writing replaces that version.` : null,
|
|
11722
|
+
`Write ${label2} in ${agentLabel5}: ${formatBytes(copy.original.length)} -> ${formatBytes(edited.length)}`
|
|
11723
|
+
].filter(Boolean).join(`
|
|
11724
|
+
`),
|
|
11725
|
+
confirmLabel: concurrent ? "Overwrite" : "Write",
|
|
11726
|
+
cancelLabel: "Cancel",
|
|
11727
|
+
danger: !!concurrent
|
|
11728
|
+
}) ? await actions4.run(`Write ${label2}`, (c) => (copy.binary && target2.kind === "file" ? c.writeFile(agentId, target2.path, { contentBase64: edited.toString("base64"), ...copy.mime ? { mimeType: copy.mime } : {} }) : writeTarget(c, agentId, target2, edited.toString("utf-8"))).then(() => !0)) ? (copy.original = edited, copy.mtimeMs = (await fs4.stat(copy.file)).mtimeMs, actions4.toast(`Saved ${label2} from the app`, "success"), "written") : (actions4.toast(`Write failed. Your copy is still at ${copy.file}`, "error", 12e3), "failed") : "discarded";
|
|
11729
|
+
}
|
|
11730
|
+
|
|
11731
|
+
// src/main/tui/views/files/FilesTab.tsx
|
|
11659
11732
|
var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1), recentWrites = /* @__PURE__ */ new Map(), RECENT_MS = 10 * 6e4;
|
|
11660
11733
|
function pinnedKeyForPath(path) {
|
|
11661
11734
|
return path === "mind.md" ? MIND_KEY : path === "README.md" || path === "document.md" ? DOCUMENT_KEY : null;
|
|
@@ -11763,7 +11836,30 @@ function FilesTab(props) {
|
|
|
11763
11836
|
} finally {
|
|
11764
11837
|
busy.current = !1;
|
|
11765
11838
|
}
|
|
11766
|
-
},
|
|
11839
|
+
}, externalDeps = () => ({ client, actions: actions4, agentId, agentLabel: agentLabel5 }), runOpenExternal = async (target2) => {
|
|
11840
|
+
await openExternal(externalDeps(), target2), setTick((t) => t + 1);
|
|
11841
|
+
}, runSaveBack = async (target2) => {
|
|
11842
|
+
if (busy.current) {
|
|
11843
|
+
actions4.toast("An edit is already in progress", "warn");
|
|
11844
|
+
return;
|
|
11845
|
+
}
|
|
11846
|
+
busy.current = !0;
|
|
11847
|
+
try {
|
|
11848
|
+
await saveBackExternal(externalDeps(), target2) === "written" && (invalidate(targetKey(target2)), await reloadList());
|
|
11849
|
+
} catch (err) {
|
|
11850
|
+
actions4.toast(`Save failed: ${err instanceof Error ? err.message : String(err)}`, "error", 12e3);
|
|
11851
|
+
} finally {
|
|
11852
|
+
busy.current = !1, setTick((t) => t + 1);
|
|
11853
|
+
}
|
|
11854
|
+
}, viewedCopy = viewerTarget ? externalCopy(agentId, viewerTarget) : void 0, copyChanged = viewedCopy ? externalChanged(viewedCopy) : !1;
|
|
11855
|
+
(0, import_react38.useEffect)(() => {
|
|
11856
|
+
if (!viewedCopy || copyChanged) return;
|
|
11857
|
+
let timer = setInterval(() => {
|
|
11858
|
+
externalChanged(viewedCopy) && setTick((t) => t + 1);
|
|
11859
|
+
}, 1500);
|
|
11860
|
+
return () => clearInterval(timer);
|
|
11861
|
+
}, [viewedCopy, copyChanged]);
|
|
11862
|
+
let createFile = async (initialPath) => {
|
|
11767
11863
|
let path = initialPath?.trim();
|
|
11768
11864
|
if (!path) {
|
|
11769
11865
|
let base2 = cursorRow?.kind === "dir" ? `${cursorRow.path}/` : cursorRow?.kind === "file" && parentDir(cursorRow.path) ? `${parentDir(cursorRow.path)}/` : "";
|
|
@@ -11862,6 +11958,10 @@ function FilesTab(props) {
|
|
|
11862
11958
|
let target2 = rowTarget(row4);
|
|
11863
11959
|
return target2 ? runEdit(target2) : actions4.toast("Pick a file to edit", "warn"), !0;
|
|
11864
11960
|
}
|
|
11961
|
+
if ((input === "o" || input === "s") && !key.ctrl) {
|
|
11962
|
+
let target2 = rowTarget(row4);
|
|
11963
|
+
return target2 ? input === "o" ? runOpenExternal(target2) : runSaveBack(target2) : actions4.toast("Pick a file", "warn"), !0;
|
|
11964
|
+
}
|
|
11865
11965
|
return input === "m" && !key.ctrl ? (rename(row4), !0) : input === "d" && !key.ctrl || key.delete && !key.backspace ? (remove2(row4), !0) : input === "p" && !key.ctrl ? (cycleProtection(row4), !0) : input === "a" && !key.ctrl ? (toggleAuthorized(row4), !0) : !1;
|
|
11866
11966
|
}, split = width >= 70, listWidth = split ? Math.max(24, Math.min(48, Math.floor(width * 0.38))) : width, viewerWidth = split ? width - listWidth - 2 : width, showList = split || pane === "list", showViewer = split || pane === "viewer", perAgent = recentWrites.get(agentId), renderRow = (row4, selected, w) => {
|
|
11867
11967
|
let indent3 = " ".repeat(row4.depth), glyph, color, right = "", suffix = "";
|
|
@@ -11964,7 +12064,7 @@ function FilesTab(props) {
|
|
|
11964
12064
|
active: focused && pane === "viewer",
|
|
11965
12065
|
title: viewerTitle,
|
|
11966
12066
|
meta: viewerMeta,
|
|
11967
|
-
notice: notice?.key === viewerKey ? notice.text : void 0,
|
|
12067
|
+
notice: copyChanged ? "Changed in the default app \u2014 s saves it back" : notice?.key === viewerKey ? notice.text : viewedCopy ? "Open in the default app (o reopens, s saves it back)" : void 0,
|
|
11968
12068
|
name: viewerTarget.kind === "file" ? viewerTarget.path : targetLabel(viewerTarget),
|
|
11969
12069
|
text: loadedOk?.text,
|
|
11970
12070
|
bytes: loadedOk?.binary ? loadedOk.bytes : void 0,
|
|
@@ -11975,6 +12075,12 @@ function FilesTab(props) {
|
|
|
11975
12075
|
onBack: () => setPane("list"),
|
|
11976
12076
|
onEdit: loadedOk?.binary ? void 0 : () => {
|
|
11977
12077
|
runEdit(viewerTarget);
|
|
12078
|
+
},
|
|
12079
|
+
onOpenExternal: () => {
|
|
12080
|
+
runOpenExternal(viewerTarget);
|
|
12081
|
+
},
|
|
12082
|
+
onSaveBack: () => {
|
|
12083
|
+
runSaveBack(viewerTarget);
|
|
11978
12084
|
}
|
|
11979
12085
|
}
|
|
11980
12086
|
) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Text, { color: theme2.color.muted, children: "Pick a file." })
|
|
@@ -12107,7 +12213,7 @@ function keyHints(scope) {
|
|
|
12107
12213
|
{ keys: "backspace", label: "back" },
|
|
12108
12214
|
{ keys: "up down", label: "scroll" },
|
|
12109
12215
|
{ keys: "/", label: "search" },
|
|
12110
|
-
...state.tab === "files" ? [{ keys: "e", label: "edit" }] : [],
|
|
12216
|
+
...state.tab === "files" ? [{ keys: "e", label: "edit" }, { keys: "o", label: "open in app" }] : [],
|
|
12111
12217
|
{ keys: "left right", label: "tabs" }
|
|
12112
12218
|
] : state.tab !== "files" ? [
|
|
12113
12219
|
{ keys: "enter", label: "read" },
|
|
@@ -12121,6 +12227,7 @@ function keyHints(scope) {
|
|
|
12121
12227
|
{ keys: "backspace", label: "up" },
|
|
12122
12228
|
{ keys: "left right", label: "tabs" },
|
|
12123
12229
|
{ keys: "e", label: "edit" },
|
|
12230
|
+
{ keys: "o", label: "open in app" },
|
|
12124
12231
|
{ keys: "n", label: "new" },
|
|
12125
12232
|
{ keys: "/", label: "filter" },
|
|
12126
12233
|
{ keys: "d", label: "delete" }
|
|
@@ -12144,6 +12251,8 @@ var files = {
|
|
|
12144
12251
|
{ keys: "space", label: "Toggle a folder" },
|
|
12145
12252
|
{ keys: "/", label: "Filter by path (fuzzy)" },
|
|
12146
12253
|
{ keys: "e", label: "Edit in $EDITOR, then confirm the write (diff shown)" },
|
|
12254
|
+
{ keys: "o", label: "Open in the default app (xlsx, images, pdf, \u2026)" },
|
|
12255
|
+
{ keys: "s", label: "Save the default-app copy back (asks)" },
|
|
12147
12256
|
{ keys: "n", label: "New file" },
|
|
12148
12257
|
{ keys: "m", label: "Rename / move (a folder moves with its files)" },
|
|
12149
12258
|
{ keys: "d delete", label: "Delete (asks)" },
|
|
@@ -12158,7 +12267,8 @@ var files = {
|
|
|
12158
12267
|
{ keys: "backspace esc", label: "Back to the list (the entry stays selected)" },
|
|
12159
12268
|
{ keys: "up down", label: "Scroll (j k; PgUp PgDn Space page; g G top/bottom)" },
|
|
12160
12269
|
{ keys: "/", label: "Search, then n N next / previous hit" },
|
|
12161
|
-
{ keys: "e", label: "Edit this file" }
|
|
12270
|
+
{ keys: "e", label: "Edit this file" },
|
|
12271
|
+
{ keys: "o s", label: "Open in the default app \xB7 save that copy back" }
|
|
12162
12272
|
]
|
|
12163
12273
|
},
|
|
12164
12274
|
{
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
createChatGPTSubscriptionProvider,
|
|
11
11
|
describeCodexRequest,
|
|
12
12
|
patchCodexRequestBody
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BNXUAOO4.mjs";
|
|
14
14
|
import "./chunk-LFMB4PAA.mjs";
|
|
15
15
|
import "./chunk-RIX34QHC.mjs";
|
|
16
16
|
import "./chunk-M2RX3S2T.mjs";
|
|
@@ -5177,7 +5177,7 @@ function createChatGPTSubscriptionProvider(authManager, extraParams) {
|
|
|
5177
5177
|
let pendingInstructions = requestId !== null ? requestsById.get(requestId)?.instructions : legacyInstructions;
|
|
5178
5178
|
headers.set("Authorization", `Bearer ${token}`);
|
|
5179
5179
|
let accountId = authManager.getAccountId();
|
|
5180
|
-
accountId && headers.set("ChatGPT-Account-ID", accountId), headers.set("originator", "codex_cli_rs"), headers.set("version", "0.
|
|
5180
|
+
accountId && headers.set("ChatGPT-Account-ID", accountId), headers.set("originator", "codex_cli_rs"), headers.set("version", "0.159.1");
|
|
5181
5181
|
let patchedInit = init, requestSummary;
|
|
5182
5182
|
if (init?.body && typeof init.body == "string")
|
|
5183
5183
|
try {
|
|
@@ -5269,6 +5269,7 @@ function createChatGPTSubscriptionProvider(authManager, extraParams) {
|
|
|
5269
5269
|
};
|
|
5270
5270
|
}
|
|
5271
5271
|
var CHATGPT_SUBSCRIPTION_MODELS = [
|
|
5272
|
+
"gpt-6.1-sol",
|
|
5272
5273
|
"gpt-6-astra",
|
|
5273
5274
|
"gpt-6-sol",
|
|
5274
5275
|
"gpt-6-luna",
|
|
@@ -44,7 +44,7 @@ function tuiInvocation(argv) {
|
|
|
44
44
|
return argv.filter((a) => a !== "--json");
|
|
45
45
|
}
|
|
46
46
|
async function defaultLaunchTui(argv) {
|
|
47
|
-
let { runTui } = await import("./tui-
|
|
47
|
+
let { runTui } = await import("./tui-I5LEARAV.mjs");
|
|
48
48
|
return await runTui(argv);
|
|
49
49
|
}
|
|
50
50
|
function urlFromArgv(argv) {
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
createOpenAI,
|
|
52
52
|
sliceWellFormed,
|
|
53
53
|
toWellFormed
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-BNXUAOO4.mjs";
|
|
55
55
|
import {
|
|
56
56
|
AISDKError,
|
|
57
57
|
APICallError,
|
|
@@ -97913,6 +97913,11 @@ function decodeJwtPayload(token) {
|
|
|
97913
97913
|
return {};
|
|
97914
97914
|
}
|
|
97915
97915
|
}
|
|
97916
|
+
function chatgptAccountIdFromJwt(token) {
|
|
97917
|
+
if (!token) return "";
|
|
97918
|
+
let claims = decodeJwtPayload(token), auth2 = claims["https://api.openai.com/auth"], id = (auth2 && typeof auth2 == "object" ? auth2.chatgpt_account_id : void 0) ?? claims.chatgpt_account_id;
|
|
97919
|
+
return typeof id == "string" ? id : "";
|
|
97920
|
+
}
|
|
97916
97921
|
async function openExternal(url) {
|
|
97917
97922
|
try {
|
|
97918
97923
|
let electron = __require("electron");
|
|
@@ -97946,11 +97951,12 @@ var ChatGptAuthManager = class {
|
|
|
97946
97951
|
this.syncFromDisk();
|
|
97947
97952
|
}
|
|
97948
97953
|
/**
|
|
97949
|
-
* Re-read the token file, picking up writes from
|
|
97954
|
+
* Re-read the token file, picking up writes from other processes.
|
|
97950
97955
|
*
|
|
97951
|
-
*
|
|
97952
|
-
*
|
|
97953
|
-
*
|
|
97956
|
+
* Each surface has its own file (see subscription-token-store), but several
|
|
97957
|
+
* processes can share one — e.g. an installed and a dev Studio, or a CLI
|
|
97958
|
+
* next to its daemon — and OpenAI rotates the refresh token on every
|
|
97959
|
+
* refresh, so acting on a cached copy can invalidate a sibling's session. Always reading is what prevents that; the file is
|
|
97954
97960
|
* well under a kilobyte and this runs once per LLM request.
|
|
97955
97961
|
*/
|
|
97956
97962
|
syncFromDisk() {
|
|
@@ -98048,16 +98054,10 @@ var ChatGptAuthManager = class {
|
|
|
98048
98054
|
let body = await tokenResponse.text();
|
|
98049
98055
|
throw new Error(`Token exchange failed (${tokenResponse.status}): ${body}`);
|
|
98050
98056
|
}
|
|
98051
|
-
let tokenData = await tokenResponse.json()
|
|
98052
|
-
|
|
98053
|
-
|
|
98054
|
-
|
|
98055
|
-
}
|
|
98056
|
-
if (!accountId) {
|
|
98057
|
-
let accessClaims = decodeJwtPayload(tokenData.access_token);
|
|
98058
|
-
accountId = accessClaims.chatgpt_account_id ?? accessClaims.sub ?? "", console.log(`[ChatGPT Auth] access_token fallback: chatgpt_account_id=${accountId}`);
|
|
98059
|
-
}
|
|
98060
|
-
this.persist({
|
|
98057
|
+
let tokenData = await tokenResponse.json();
|
|
98058
|
+
tokenData.id_token && (this.email = decodeJwtPayload(tokenData.id_token).email);
|
|
98059
|
+
let accountId = chatgptAccountIdFromJwt(tokenData.access_token) || chatgptAccountIdFromJwt(tokenData.id_token);
|
|
98060
|
+
console.log(`[ChatGPT Auth] signed in: email=${this.email}, chatgpt_account_id=${accountId || "(missing)"}`), this.persist({
|
|
98061
98061
|
access_token: tokenData.access_token,
|
|
98062
98062
|
refresh_token: tokenData.refresh_token,
|
|
98063
98063
|
expires_at: Date.now() + tokenData.expires_in * 1e3,
|
|
@@ -98073,7 +98073,8 @@ var ChatGptAuthManager = class {
|
|
|
98073
98073
|
}), this.refreshPromise);
|
|
98074
98074
|
}
|
|
98075
98075
|
getAccountId() {
|
|
98076
|
-
|
|
98076
|
+
let tokens = this.syncFromDisk();
|
|
98077
|
+
return chatgptAccountIdFromJwt(tokens?.access_token) || tokens?.account_id || void 0;
|
|
98077
98078
|
}
|
|
98078
98079
|
/**
|
|
98079
98080
|
* Re-check the file after winning the in-process refresh lock.
|
|
@@ -98087,7 +98088,7 @@ var ChatGptAuthManager = class {
|
|
|
98087
98088
|
return fresh && Date.now() + REFRESH_BUFFER_MS < fresh.expires_at ? fresh.access_token : this.refreshTokens(fresh ?? tokens);
|
|
98088
98089
|
}
|
|
98089
98090
|
async refreshTokens(tokens) {
|
|
98090
|
-
let data;
|
|
98091
|
+
let data, rejected = !1;
|
|
98091
98092
|
try {
|
|
98092
98093
|
let response = await fetch(TOKEN_URL, {
|
|
98093
98094
|
method: "POST",
|
|
@@ -98099,13 +98100,13 @@ var ChatGptAuthManager = class {
|
|
|
98099
98100
|
})
|
|
98100
98101
|
});
|
|
98101
98102
|
if (!response.ok)
|
|
98102
|
-
throw new Error(`Token refresh failed (${response.status})`);
|
|
98103
|
+
throw rejected = response.status === 400 || response.status === 401, new Error(`Token refresh failed (${response.status})`);
|
|
98103
98104
|
data = await response.json();
|
|
98104
|
-
} catch {
|
|
98105
|
+
} catch (err) {
|
|
98105
98106
|
let fresh = this.syncFromDisk();
|
|
98106
98107
|
if (fresh && fresh.refresh_token !== tokens.refresh_token && Date.now() + REFRESH_BUFFER_MS < fresh.expires_at)
|
|
98107
98108
|
return fresh.access_token;
|
|
98108
|
-
throw clearTokens(), this.cachedTokens = null, this.email = void 0, new Error("Session expired \u2014 please sign in again");
|
|
98109
|
+
throw rejected ? (clearTokens(), this.cachedTokens = null, this.email = void 0, new Error("Session expired \u2014 please sign in again")) : new Error(`Could not refresh the session (${err instanceof Error ? err.message : String(err)}) \u2014 still signed in, try again`);
|
|
98109
98110
|
}
|
|
98110
98111
|
if (data.id_token) {
|
|
98111
98112
|
let claims = decodeJwtPayload(data.id_token);
|
|
@@ -98115,7 +98116,7 @@ var ChatGptAuthManager = class {
|
|
|
98115
98116
|
access_token: data.access_token,
|
|
98116
98117
|
refresh_token: data.refresh_token,
|
|
98117
98118
|
expires_at: Date.now() + data.expires_in * 1e3,
|
|
98118
|
-
account_id: tokens.account_id
|
|
98119
|
+
account_id: chatgptAccountIdFromJwt(data.access_token) || chatgptAccountIdFromJwt(data.id_token) || tokens.account_id
|
|
98119
98120
|
}), data.access_token;
|
|
98120
98121
|
}
|
|
98121
98122
|
getAuthStatus() {
|
|
@@ -98306,7 +98307,7 @@ var GrokAuthManager = class {
|
|
|
98306
98307
|
return fresh && Date.now() + REFRESH_BUFFER_MS2 < fresh.expires_at ? fresh.access_token : this.refreshTokens(fresh ?? tokens);
|
|
98307
98308
|
}
|
|
98308
98309
|
async refreshTokens(tokens) {
|
|
98309
|
-
let data;
|
|
98310
|
+
let data, rejected = !1;
|
|
98310
98311
|
try {
|
|
98311
98312
|
let response = await fetch(TOKEN_URL2, {
|
|
98312
98313
|
method: "POST",
|
|
@@ -98318,13 +98319,13 @@ var GrokAuthManager = class {
|
|
|
98318
98319
|
}).toString()
|
|
98319
98320
|
});
|
|
98320
98321
|
if (!response.ok)
|
|
98321
|
-
throw new Error(`Token refresh failed (${response.status})`);
|
|
98322
|
+
throw rejected = response.status === 400 || response.status === 401, new Error(`Token refresh failed (${response.status})`);
|
|
98322
98323
|
data = await response.json();
|
|
98323
|
-
} catch {
|
|
98324
|
+
} catch (err) {
|
|
98324
98325
|
let fresh = this.syncFromDisk();
|
|
98325
98326
|
if (fresh && fresh.refresh_token !== tokens.refresh_token && Date.now() + REFRESH_BUFFER_MS2 < fresh.expires_at)
|
|
98326
98327
|
return fresh.access_token;
|
|
98327
|
-
throw clearTokens2(), this.cachedTokens = null, this.email = void 0, new Error("Session expired \u2014 please sign in again");
|
|
98328
|
+
throw rejected ? (clearTokens2(), this.cachedTokens = null, this.email = void 0, new Error("Session expired \u2014 please sign in again")) : new Error(`Could not refresh the session (${err instanceof Error ? err.message : String(err)}) \u2014 still signed in, try again`);
|
|
98328
98329
|
}
|
|
98329
98330
|
if (data.id_token) {
|
|
98330
98331
|
let claims = decodeJwtPayload2(data.id_token);
|
|
@@ -123660,7 +123661,7 @@ async function listProviderModels(runtime2, settingsStore, providerId, agentId)
|
|
|
123660
123661
|
let cfg = resolveModelListProviderConfig(runtime2, settingsStore, providerId, agentId);
|
|
123661
123662
|
if (!cfg) return { provider: providerId, models: [], error: `Provider "${providerId}" not found.` };
|
|
123662
123663
|
if (cfg.type === "chatgpt-subscription") {
|
|
123663
|
-
let { CHATGPT_SUBSCRIPTION_MODELS } = await import("./chatgpt-subscription-
|
|
123664
|
+
let { CHATGPT_SUBSCRIPTION_MODELS } = await import("./chatgpt-subscription-E4MXTIAT.mjs");
|
|
123664
123665
|
return { provider: providerId, models: [...CHATGPT_SUBSCRIPTION_MODELS] };
|
|
123665
123666
|
}
|
|
123666
123667
|
if (cfg.type === "grok-subscription") {
|
|
@@ -119,7 +119,7 @@ ${tuiUsage()}
|
|
|
119
119
|
] = await Promise.all([
|
|
120
120
|
import("./react-IUIDQ5LX.mjs"),
|
|
121
121
|
import("./build-QF5W473T.mjs"),
|
|
122
|
-
import("./App-
|
|
122
|
+
import("./App-ZRQS3U7S.mjs"),
|
|
123
123
|
import("./themes-F2FKU7CP.mjs"),
|
|
124
124
|
import("./store-HUVDJPYN.mjs"),
|
|
125
125
|
import("./theme-NORU4J74.mjs"),
|
package/package.json
CHANGED