@agentdocumentformat/cli 0.7.3 → 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 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.3";
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-G6OQZER2.mjs"), -1;
143
+ return await import("./chunks/daemon-6RA2DIJ2.mjs"), -1;
144
144
  }
145
- let [{ runCli, tuiInvocation }, control] = await Promise.all([import("./chunks/cli-ZGVQRVSQ.mjs"), import("./chunks/daemon-control-HKFVSQTQ.mjs")]);
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, dirs) {
1264
- let trackedDirs = dirs;
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
- }, createFile = async (initialPath) => {
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-LAZIXV2F.mjs";
13
+ } from "./chunk-BNXUAOO4.mjs";
14
14
  import "./chunk-LFMB4PAA.mjs";
15
15
  import "./chunk-RIX34QHC.mjs";
16
16
  import "./chunk-M2RX3S2T.mjs";
@@ -27,7 +27,7 @@ async function convertToOggOpus(input) {
27
27
  "-vn",
28
28
  "-y",
29
29
  outPath
30
- ], (error) => {
30
+ ], { windowsHide: !0 }, (error) => {
31
31
  error ? reject(new Error(`ffmpeg conversion failed: ${error.message}. Is ffmpeg installed?`)) : resolve();
32
32
  });
33
33
  }), await fsp.readFile(outPath);
@@ -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.155.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-LWLJUXZ3.mjs");
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-LAZIXV2F.mjs";
54
+ } from "./chunk-BNXUAOO4.mjs";
55
55
  import {
56
56
  AISDKError,
57
57
  APICallError,
@@ -40138,7 +40138,7 @@ var require_light_my_request = __commonJS({
40138
40138
  var require_fastify = __commonJS({
40139
40139
  "node_modules/fastify/fastify.js"(exports, module) {
40140
40140
  "use strict";
40141
- var VERSION6 = "5.12.1", Avvio = require_boot(), http = __require("node:http"), diagnostics = __require("node:diagnostics_channel"), lightMyRequest, {
40141
+ var VERSION7 = "5.12.1", Avvio = require_boot(), http = __require("node:http"), diagnostics = __require("node:diagnostics_channel"), lightMyRequest, {
40142
40142
  kAvvioBoot,
40143
40143
  kChildren,
40144
40144
  kServerBindings,
@@ -40410,7 +40410,7 @@ var require_fastify = __commonJS({
40410
40410
  version: {
40411
40411
  configurable: !0,
40412
40412
  get() {
40413
- return VERSION6;
40413
+ return VERSION7;
40414
40414
  }
40415
40415
  },
40416
40416
  errorHandler: {
@@ -65081,6 +65081,17 @@ import {
65081
65081
  } from "fs";
65082
65082
  import { execFile } from "child_process";
65083
65083
  import { promisify as promisify2 } from "util";
65084
+
65085
+ // src/main/utils/npm-spec.ts
65086
+ var NAME = /^(@[\w.-]+\/)?[\w.-]+$/, VERSION = /^[\w.^~*+-]+$/;
65087
+ function assertNpmSpec(name21, version) {
65088
+ let at = name21.lastIndexOf("@"), bare = at > 0 ? name21.slice(0, at) : name21;
65089
+ if (!NAME.test(bare)) throw new Error(`Invalid npm package name: ${name21}`);
65090
+ for (let v of [at > 0 ? name21.slice(at + 1) : void 0, version])
65091
+ if (v !== void 0 && !VERSION.test(v)) throw new Error(`Invalid npm version: ${v}`);
65092
+ }
65093
+
65094
+ // src/main/services/sandbox-packages.service.ts
65084
65095
  var execFileAsync = promisify2(execFile), IS_WIN = process.platform === "win32", NPM_BIN = IS_WIN ? "npm.cmd" : "npm", MAX_PACKAGE_SIZE_MB = 50, MAX_TOTAL_SIZE_MB = 200, LOG_TAG = "[SandboxPackages]", SandboxPackagesService = class {
65085
65096
  getBaseDir() {
65086
65097
  return join10(getUserDataPath(), "sandbox-packages");
@@ -65113,7 +65124,9 @@ var execFileAsync = promisify2(execFile), IS_WIN = process.platform === "win32",
65113
65124
  * Returns the installed version and size.
65114
65125
  */
65115
65126
  async install(name21, version, onProgress, agentName) {
65116
- let manifest = this.loadManifest(), versionSpec = version ?? "latest", existing = manifest.packages[name21];
65127
+ let manifest = this.loadManifest(), versionSpec = version ?? "latest";
65128
+ assertNpmSpec(name21, versionSpec);
65129
+ let existing = manifest.packages[name21];
65117
65130
  if (existing && version && existing.version === version)
65118
65131
  return { name: name21, version: existing.version, size_mb: existing.size_mb, already_installed: !0 };
65119
65132
  this.ensureBaseDir();
@@ -65127,7 +65140,8 @@ var execFileAsync = promisify2(execFile), IS_WIN = process.platform === "win32",
65127
65140
  cwd: baseDir,
65128
65141
  env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" },
65129
65142
  timeout: 12e4,
65130
- shell: IS_WIN
65143
+ shell: IS_WIN,
65144
+ windowsHide: !0
65131
65145
  }
65132
65146
  );
65133
65147
  stderr && !stderr.includes("npm warn") && console.warn(`${LOG_TAG} npm stderr for ${name21}:`, stderr), console.log(`${LOG_TAG} npm output:`, stdout.slice(0, 500));
@@ -65301,7 +65315,8 @@ var execFileAsync = promisify2(execFile), IS_WIN = process.platform === "win32",
65301
65315
  cwd: this.getBaseDir(),
65302
65316
  env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" },
65303
65317
  timeout: 6e4,
65304
- shell: IS_WIN
65318
+ shell: IS_WIN,
65319
+ windowsHide: !0
65305
65320
  }
65306
65321
  );
65307
65322
  } catch (err) {
@@ -65781,7 +65796,7 @@ var EXTRA_SEARCH_PATHS = {
65781
65796
  };
65782
65797
  function exec(cmd, args) {
65783
65798
  return new Promise((resolve15) => {
65784
- execFile3(cmd, args, { timeout: 1e4 }, (error, stdout, stderr) => {
65799
+ execFile3(cmd, args, { timeout: 1e4, windowsHide: !0 }, (error, stdout, stderr) => {
65785
65800
  resolve15({ stdout: stdout?.trim() ?? "", stderr: stderr?.trim() ?? "", code: error ? error.code === "ENOENT" ? -1 : 1 : 0 });
65786
65801
  });
65787
65802
  });
@@ -66218,9 +66233,13 @@ function machineSize(cfg, host2 = hostCapacity()) {
66218
66233
  cpus: boundedInt(cfg.machineCpus, host2.cpus) ?? DEFAULT_SETTINGS.machineCpus
66219
66234
  };
66220
66235
  }
66221
- var PodmanService = class _PodmanService extends EventEmitter5 {
66236
+ var PODMAN_MISS_TTL_MS = 6e4, PodmanService = class _PodmanService extends EventEmitter5 {
66222
66237
  status = "stopped";
66223
66238
  podmanBin = null;
66239
+ /** Shared in-flight probe, so concurrent callers run one probe between them. */
66240
+ podmanProbe = null;
66241
+ /** When a probe last found no Podman; misses are cached for PODMAN_MISS_TTL_MS. */
66242
+ podmanMissAt = 0;
66224
66243
  activeAgentIds = /* @__PURE__ */ new Set();
66225
66244
  stopTimer = null;
66226
66245
  errorMessage;
@@ -66313,12 +66332,14 @@ var PodmanService = class _PodmanService extends EventEmitter5 {
66313
66332
  }
66314
66333
  /**
66315
66334
  * Resolve the podman binary path (cached after first call).
66316
- * Returns null if Podman is not installed.
66335
+ * Returns null if Podman is not installed. A miss is cached briefly: the
66336
+ * probe spawns wsl/where/podman, and without Podman every compute call
66337
+ * would re-run it. setup() clears the miss so a fresh install is seen.
66317
66338
  */
66318
66339
  async findPodman() {
66319
- if (this.podmanBin) return this.podmanBin;
66320
- let info = await checkPodmanAvailability();
66321
- return info.available && info.binPath && (this.podmanBin = info.binPath), this.podmanBin;
66340
+ return this.podmanBin ? this.podmanBin : Date.now() - this.podmanMissAt < PODMAN_MISS_TTL_MS ? null : (this.podmanProbe ??= checkPodmanAvailability().then((info) => (info.available && info.binPath ? this.podmanBin = info.binPath : this.podmanMissAt = Date.now(), this.podmanBin)).finally(() => {
66341
+ this.podmanProbe = null;
66342
+ }), this.podmanProbe);
66322
66343
  }
66323
66344
  /**
66324
66345
  * Ensure the shared container is running.
@@ -66717,8 +66738,9 @@ var PodmanService = class _PodmanService extends EventEmitter5 {
66717
66738
  */
66718
66739
  async setup(step, installCommand) {
66719
66740
  if (!SETUP_STEPS.has(step)) return { success: !1, error: `Unknown step: ${step}` };
66741
+ this.podmanMissAt = 0;
66720
66742
  let run2 = (cmd, cmdArgs, timeout = 3e5) => new Promise((resolve15) => {
66721
- execFile4(cmd, cmdArgs, { timeout }, (error, stdout, stderr) => {
66743
+ execFile4(cmd, cmdArgs, { timeout, windowsHide: !0 }, (error, stdout, stderr) => {
66722
66744
  resolve15({
66723
66745
  stdout: stdout?.trim() ?? "",
66724
66746
  stderr: stderr?.trim() ?? "",
@@ -66771,7 +66793,8 @@ var PodmanService = class _PodmanService extends EventEmitter5 {
66771
66793
  execArgs.push("-e", `${k}=${v}`);
66772
66794
  return execArgs.push(SHARED_CONTAINER, command, ...args), spawn2(this.podmanBin, execArgs, {
66773
66795
  stdio: ["pipe", "pipe", "pipe"],
66774
- shell: !1
66796
+ shell: !1,
66797
+ windowsHide: !0
66775
66798
  });
66776
66799
  }
66777
66800
  /**
@@ -66787,7 +66810,8 @@ var PodmanService = class _PodmanService extends EventEmitter5 {
66787
66810
  runArgs.push("-e", `${k}=${v}`);
66788
66811
  return runArgs.push(image, command, ...args), spawn2(bin, runArgs, {
66789
66812
  stdio: ["pipe", "pipe", "pipe"],
66790
- shell: !1
66813
+ shell: !1,
66814
+ windowsHide: !0
66791
66815
  });
66792
66816
  }
66793
66817
  /**
@@ -67447,7 +67471,7 @@ var PodmanService = class _PodmanService extends EventEmitter5 {
67447
67471
  }
67448
67472
  exec0(cmd, args, timeout = 3e4) {
67449
67473
  return new Promise((resolve15) => {
67450
- execFile4(cmd, args, { timeout }, (error, stdout, stderr) => {
67474
+ execFile4(cmd, args, { timeout, windowsHide: !0 }, (error, stdout, stderr) => {
67451
67475
  resolve15({
67452
67476
  stdout: stdout?.trim() ?? "",
67453
67477
  stderr: stderr?.trim() ?? "",
@@ -67662,7 +67686,7 @@ function sameContainerId(expected, actual) {
67662
67686
  }
67663
67687
  function run(command, args, timeout) {
67664
67688
  return new Promise((resolve15) => {
67665
- execFile5(command, args, { timeout, maxBuffer: 2 * 1024 * 1024 }, (error, stdout, stderr) => {
67689
+ execFile5(command, args, { timeout, maxBuffer: 2 * 1024 * 1024, windowsHide: !0 }, (error, stdout, stderr) => {
67666
67690
  let errorCode = error?.code, code = typeof errorCode == "number" ? errorCode : error ? 1 : 0;
67667
67691
  resolve15({ stdout: stdout?.trim() ?? "", stderr: stderr?.trim() ?? "", code });
67668
67692
  });
@@ -73862,7 +73886,8 @@ var DEFAULT_QUEUE_HIGH_WATER_BYTES = 4 * 1024 * 1024, DEFAULT_OPTIONS = {
73862
73886
  child = spawn3(endpoint.command[0], endpoint.command.slice(1), {
73863
73887
  cwd: endpoint.cwd,
73864
73888
  env: endpoint.env ? { ...process.env, ...endpoint.env } : process.env,
73865
- stdio: "pipe"
73889
+ stdio: "pipe",
73890
+ windowsHide: !0
73866
73891
  });
73867
73892
  } else if (endpoint.isolation === "container_shared") {
73868
73893
  if (!this.config?.container_shared_bind) throw new Error("Shared-container process stream binding is not enabled for this agent");
@@ -75391,7 +75416,7 @@ import { join as join19, dirname as dirname10, resolve as resolve10 } from "path
75391
75416
  import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync7, statSync as statSync6, writeFileSync as writeFileSync6, rmSync as rmSync4 } from "fs";
75392
75417
  import { execFile as execFile6 } from "child_process";
75393
75418
  import { promisify as promisify3 } from "util";
75394
- var execFileAsync2 = promisify3(execFile6);
75419
+ var execFileAsync2 = promisify3(execFile6), IS_WIN2 = process.platform === "win32", NPM_BIN2 = IS_WIN2 ? "npm.cmd" : "npm";
75395
75420
  function resolveEntryPoint(installDir, packageName) {
75396
75421
  let pkgJsonPath = join19(installDir, "node_modules", packageName, "package.json");
75397
75422
  if (!existsSync10(pkgJsonPath)) {
@@ -75468,13 +75493,14 @@ var PackageResolver = class {
75468
75493
  * Returns the installed package info on success.
75469
75494
  */
75470
75495
  async install(packageName, onProgress) {
75496
+ assertNpmSpec(packageName);
75471
75497
  let baseDir = this.getBaseDir(), safeName = packageName.replace(/[/@]/g, "_"), installDir = join19(baseDir, safeName);
75472
75498
  existsSync10(installDir) || mkdirSync7(installDir, { recursive: !0 });
75473
75499
  let pkgJsonPath = join19(installDir, "package.json");
75474
75500
  existsSync10(pkgJsonPath) || writeFileSync6(pkgJsonPath, JSON.stringify({ name: `pkg-${safeName}`, private: !0 }, null, 2)), onProgress?.(`Installing ${packageName}...`);
75475
75501
  try {
75476
75502
  let { stdout, stderr } = await execFileAsync2(
75477
- (process.execPath.includes("Electron"), "npm"),
75503
+ NPM_BIN2,
75478
75504
  ["install", "--save", "--no-audit", "--no-fund", packageName],
75479
75505
  {
75480
75506
  cwd: installDir,
@@ -75483,8 +75509,11 @@ var PackageResolver = class {
75483
75509
  // Avoid Electron's bundled Node interfering with npm
75484
75510
  ELECTRON_RUN_AS_NODE: "1"
75485
75511
  },
75486
- timeout: 12e4
75512
+ timeout: 12e4,
75487
75513
  // 2 minute timeout
75514
+ // npm is npm.cmd on Windows; Node only runs .cmd through a shell.
75515
+ shell: IS_WIN2,
75516
+ windowsHide: !0
75488
75517
  }
75489
75518
  );
75490
75519
  stderr && !stderr.includes("npm warn") && console.warn(`[PackageResolver] npm stderr for ${packageName}:`, stderr), onProgress?.(`Resolving entry point for ${packageName}...`);
@@ -76499,11 +76528,11 @@ var ChannelAdapterManager = class extends EventEmitter7 {
76499
76528
 
76500
76529
  // src/main/adapters/built-in-loaders.ts
76501
76530
  var BUILT_IN_ADAPTER_LOADERS = {
76502
- telegram: async () => (await import("./telegram-5ISVFBV3.mjs")).createAdapter,
76531
+ telegram: async () => (await import("./telegram-V4VH4PNE.mjs")).createAdapter,
76503
76532
  email: async () => (await import("./email-V4Q4VJON.mjs")).createAdapter,
76504
76533
  discord: async () => (await import("./discord-IWDQJA7A.mjs")).createAdapter,
76505
76534
  slack: async () => (await import("./slack-3L5QTDZX.mjs")).createAdapter,
76506
- whatsapp: async () => (await import("./whatsapp-XSAMNGPJ.mjs")).createAdapter
76535
+ whatsapp: async () => (await import("./whatsapp-RDOC54X5.mjs")).createAdapter
76507
76536
  };
76508
76537
  async function loadBuiltInAdapter(adapterType) {
76509
76538
  let loader = BUILT_IN_ADAPTER_LOADERS[adapterType];
@@ -76541,7 +76570,8 @@ function startLoopbackTunnel(opts) {
76541
76570
  let { podmanBin, containerName, hostPort } = opts, containerPort = opts.containerPort ?? hostPort, log = opts.log ?? (() => {
76542
76571
  }), bridges = /* @__PURE__ */ new Set(), sockets = /* @__PURE__ */ new Set(), server = createServer2((socket) => {
76543
76572
  let bridge = nodeSpawn(podmanBin, ["exec", "-i", containerName, "node", "-e", BRIDGE_SRC, String(containerPort)], {
76544
- stdio: ["pipe", "pipe", "ignore"]
76573
+ stdio: ["pipe", "pipe", "ignore"],
76574
+ windowsHide: !0
76545
76575
  });
76546
76576
  bridges.add(bridge), sockets.add(socket), socket.pipe(bridge.stdin), bridge.stdout.pipe(socket);
76547
76577
  let teardown = () => {
@@ -76776,7 +76806,7 @@ function createHeadlessMcpAuthPreflight(log) {
76776
76806
  let emit = log ?? ((msg) => console.log(msg)), openUrl = (url) => {
76777
76807
  emit(`[MCP] Auth preflight authorization URL: ${url}`);
76778
76808
  try {
76779
- let [cmd, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]] : ["xdg-open", [url]], child = nodeSpawn(cmd, [...args], { detached: !0, stdio: "ignore" });
76809
+ let [cmd, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]] : ["xdg-open", [url]], child = nodeSpawn(cmd, [...args], { detached: !0, stdio: "ignore", windowsHide: !0 });
76780
76810
  child.on("error", () => {
76781
76811
  }), child.unref();
76782
76812
  } catch {
@@ -81535,7 +81565,7 @@ var MeshManager = class extends EventEmitter10 {
81535
81565
  };
81536
81566
 
81537
81567
  // node_modules/@ai-sdk/anthropic/dist/index.mjs
81538
- var VERSION = "3.0.37", anthropicErrorDataSchema = lazySchema(
81568
+ var VERSION2 = "3.0.37", anthropicErrorDataSchema = lazySchema(
81539
81569
  () => zodSchema(
81540
81570
  external_exports2.object({
81541
81571
  type: external_exports2.literal("error"),
@@ -85410,7 +85440,7 @@ function createAnthropic(options = {}) {
85410
85440
  ...authHeaders,
85411
85441
  ...options.headers
85412
85442
  },
85413
- `ai-sdk/anthropic/${VERSION}`
85443
+ `ai-sdk/anthropic/${VERSION2}`
85414
85444
  );
85415
85445
  }, createChatModel = (modelId) => {
85416
85446
  var _a24;
@@ -85926,7 +85956,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
85926
85956
  [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" ")
85927
85957
  ), Object.fromEntries(normalizedHeaders.entries());
85928
85958
  }
85929
- var VERSION2 = "4.0.23", getOriginalFetch = () => globalThis.fetch, getFromApi2 = async ({
85959
+ var VERSION3 = "4.0.23", getOriginalFetch = () => globalThis.fetch, getFromApi2 = async ({
85930
85960
  url,
85931
85961
  headers = {},
85932
85962
  successfulResponseHandler,
@@ -85939,7 +85969,7 @@ var VERSION2 = "4.0.23", getOriginalFetch = () => globalThis.fetch, getFromApi2
85939
85969
  method: "GET",
85940
85970
  headers: withUserAgentSuffix2(
85941
85971
  headers,
85942
- `ai-sdk/provider-utils/${VERSION2}`,
85972
+ `ai-sdk/provider-utils/${VERSION3}`,
85943
85973
  getRuntimeEnvironmentUserAgent2()
85944
85974
  ),
85945
85975
  signal: abortSignal
@@ -87132,7 +87162,7 @@ var getOriginalFetch2 = () => globalThis.fetch, postJsonToApi2 = async ({
87132
87162
  method: "POST",
87133
87163
  headers: withUserAgentSuffix2(
87134
87164
  headers,
87135
- `ai-sdk/provider-utils/${VERSION2}`,
87165
+ `ai-sdk/provider-utils/${VERSION3}`,
87136
87166
  getRuntimeEnvironmentUserAgent2()
87137
87167
  ),
87138
87168
  body: body.content,
@@ -90529,7 +90559,7 @@ async function getVercelRequestId() {
90529
90559
  var _a83;
90530
90560
  return (_a83 = (0, import_oidc.getContext)().headers) == null ? void 0 : _a83["x-vercel-id"];
90531
90561
  }
90532
- var VERSION3 = "3.0.36", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
90562
+ var VERSION4 = "3.0.36", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
90533
90563
  function createGatewayProvider(options = {}) {
90534
90564
  var _a83, _b82;
90535
90565
  let pendingMetadata = null, metadataCache = null, cacheRefreshMillis = (_a83 = options.metadataCacheRefreshMillis) != null ? _a83 : 1e3 * 60 * 5, lastFetchTime = 0, baseURL = (_b82 = withoutTrailingSlash(options.baseURL)) != null ? _b82 : "https://ai-gateway.vercel.sh/v3/ai", getHeaders = async () => {
@@ -90542,7 +90572,7 @@ function createGatewayProvider(options = {}) {
90542
90572
  [GATEWAY_AUTH_METHOD_HEADER]: auth2.authMethod,
90543
90573
  ...options.headers
90544
90574
  },
90545
- `ai-sdk/gateway/${VERSION3}`
90575
+ `ai-sdk/gateway/${VERSION4}`
90546
90576
  );
90547
90577
  } catch (error) {
90548
90578
  throw GatewayAuthenticationError.createContextualError({
@@ -90648,7 +90678,7 @@ async function getGatewayAuthToken(options) {
90648
90678
  var _globalThis = typeof globalThis == "object" ? globalThis : global;
90649
90679
 
90650
90680
  // node_modules/@opentelemetry/api/build/esm/version.js
90651
- var VERSION4 = "1.9.0";
90681
+ var VERSION5 = "1.9.0";
90652
90682
 
90653
90683
  // node_modules/@opentelemetry/api/build/esm/internal/semver.js
90654
90684
  var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
@@ -90691,25 +90721,25 @@ function _makeCompatibilityCheck(ownVersion) {
90691
90721
  return globalVersionParsed.prerelease != null || ownVersionParsed.major !== globalVersionParsed.major ? _reject(globalVersion) : ownVersionParsed.major === 0 ? ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch ? _accept(globalVersion) : _reject(globalVersion) : ownVersionParsed.minor <= globalVersionParsed.minor ? _accept(globalVersion) : _reject(globalVersion);
90692
90722
  };
90693
90723
  }
90694
- var isCompatible = _makeCompatibilityCheck(VERSION4);
90724
+ var isCompatible = _makeCompatibilityCheck(VERSION5);
90695
90725
 
90696
90726
  // node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
90697
- var major = VERSION4.split(".")[0], GLOBAL_OPENTELEMETRY_API_KEY = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major), _global = _globalThis;
90727
+ var major = VERSION5.split(".")[0], GLOBAL_OPENTELEMETRY_API_KEY = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major), _global = _globalThis;
90698
90728
  function registerGlobal(type, instance6, diag, allowOverride) {
90699
90729
  var _a21;
90700
90730
  allowOverride === void 0 && (allowOverride = !1);
90701
90731
  var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a21 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a21 !== void 0 ? _a21 : {
90702
- version: VERSION4
90732
+ version: VERSION5
90703
90733
  };
90704
90734
  if (!allowOverride && api[type]) {
90705
90735
  var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
90706
90736
  return diag.error(err.stack || err.message), !1;
90707
90737
  }
90708
- if (api.version !== VERSION4) {
90709
- var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION4);
90738
+ if (api.version !== VERSION5) {
90739
+ var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION5);
90710
90740
  return diag.error(err.stack || err.message), !1;
90711
90741
  }
90712
- return api[type] = instance6, diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION4 + "."), !0;
90742
+ return api[type] = instance6, diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION5 + "."), !0;
90713
90743
  }
90714
90744
  function getGlobal(type) {
90715
90745
  var _a21, _b17, globalVersion = (_a21 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a21 === void 0 ? void 0 : _a21.version;
@@ -90717,7 +90747,7 @@ function getGlobal(type) {
90717
90747
  return (_b17 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b17 === void 0 ? void 0 : _b17[type];
90718
90748
  }
90719
90749
  function unregisterGlobal(type, diag) {
90720
- diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION4 + ".");
90750
+ diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION5 + ".");
90721
90751
  var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
90722
90752
  api && delete api[type];
90723
90753
  }
@@ -91617,14 +91647,14 @@ function detectMediaType({
91617
91647
  ))
91618
91648
  return signature.mediaType;
91619
91649
  }
91620
- var VERSION5 = "6.0.73", download = async ({ url }) => {
91650
+ var VERSION6 = "6.0.73", download = async ({ url }) => {
91621
91651
  var _a21;
91622
91652
  let urlText = url.toString();
91623
91653
  try {
91624
91654
  let response = await fetch(urlText, {
91625
91655
  headers: withUserAgentSuffix(
91626
91656
  {},
91627
- `ai-sdk/${VERSION5}`,
91657
+ `ai-sdk/${VERSION6}`,
91628
91658
  getRuntimeEnvironmentUserAgent()
91629
91659
  )
91630
91660
  });
@@ -93787,7 +93817,7 @@ async function generateText({
93787
93817
  abortSignal: mergedAbortSignal
93788
93818
  }), callSettings = prepareCallSettings(settings2), headersWithUserAgent = withUserAgentSuffix(
93789
93819
  headers ?? {},
93790
- `ai/${VERSION5}`
93820
+ `ai/${VERSION6}`
93791
93821
  ), baseTelemetryAttributes = getBaseTelemetryAttributes({
93792
93822
  model,
93793
93823
  telemetry,
@@ -97883,6 +97913,11 @@ function decodeJwtPayload(token) {
97883
97913
  return {};
97884
97914
  }
97885
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
+ }
97886
97921
  async function openExternal(url) {
97887
97922
  try {
97888
97923
  let electron = __require("electron");
@@ -97916,11 +97951,12 @@ var ChatGptAuthManager = class {
97916
97951
  this.syncFromDisk();
97917
97952
  }
97918
97953
  /**
97919
- * Re-read the token file, picking up writes from the other process.
97954
+ * Re-read the token file, picking up writes from other processes.
97920
97955
  *
97921
- * Studio and the daemon share one file, and OpenAI rotates the refresh token
97922
- * on every refresh — so acting on a cached copy can invalidate the other
97923
- * process's live session. Always reading is what prevents that; the file is
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
97924
97960
  * well under a kilobyte and this runs once per LLM request.
97925
97961
  */
97926
97962
  syncFromDisk() {
@@ -98018,16 +98054,10 @@ var ChatGptAuthManager = class {
98018
98054
  let body = await tokenResponse.text();
98019
98055
  throw new Error(`Token exchange failed (${tokenResponse.status}): ${body}`);
98020
98056
  }
98021
- let tokenData = await tokenResponse.json(), accountId = "";
98022
- if (tokenData.id_token) {
98023
- let claims = decodeJwtPayload(tokenData.id_token);
98024
- this.email = claims.email, accountId = claims.chatgpt_account_id ?? "", console.log(`[ChatGPT Auth] id_token claims: email=${this.email}, chatgpt_account_id=${accountId}, sub=${claims.sub}`);
98025
- }
98026
- if (!accountId) {
98027
- let accessClaims = decodeJwtPayload(tokenData.access_token);
98028
- accountId = accessClaims.chatgpt_account_id ?? accessClaims.sub ?? "", console.log(`[ChatGPT Auth] access_token fallback: chatgpt_account_id=${accountId}`);
98029
- }
98030
- 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({
98031
98061
  access_token: tokenData.access_token,
98032
98062
  refresh_token: tokenData.refresh_token,
98033
98063
  expires_at: Date.now() + tokenData.expires_in * 1e3,
@@ -98043,7 +98073,8 @@ var ChatGptAuthManager = class {
98043
98073
  }), this.refreshPromise);
98044
98074
  }
98045
98075
  getAccountId() {
98046
- return this.syncFromDisk()?.account_id;
98076
+ let tokens = this.syncFromDisk();
98077
+ return chatgptAccountIdFromJwt(tokens?.access_token) || tokens?.account_id || void 0;
98047
98078
  }
98048
98079
  /**
98049
98080
  * Re-check the file after winning the in-process refresh lock.
@@ -98057,7 +98088,7 @@ var ChatGptAuthManager = class {
98057
98088
  return fresh && Date.now() + REFRESH_BUFFER_MS < fresh.expires_at ? fresh.access_token : this.refreshTokens(fresh ?? tokens);
98058
98089
  }
98059
98090
  async refreshTokens(tokens) {
98060
- let data;
98091
+ let data, rejected = !1;
98061
98092
  try {
98062
98093
  let response = await fetch(TOKEN_URL, {
98063
98094
  method: "POST",
@@ -98069,13 +98100,13 @@ var ChatGptAuthManager = class {
98069
98100
  })
98070
98101
  });
98071
98102
  if (!response.ok)
98072
- throw new Error(`Token refresh failed (${response.status})`);
98103
+ throw rejected = response.status === 400 || response.status === 401, new Error(`Token refresh failed (${response.status})`);
98073
98104
  data = await response.json();
98074
- } catch {
98105
+ } catch (err) {
98075
98106
  let fresh = this.syncFromDisk();
98076
98107
  if (fresh && fresh.refresh_token !== tokens.refresh_token && Date.now() + REFRESH_BUFFER_MS < fresh.expires_at)
98077
98108
  return fresh.access_token;
98078
- 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`);
98079
98110
  }
98080
98111
  if (data.id_token) {
98081
98112
  let claims = decodeJwtPayload(data.id_token);
@@ -98085,7 +98116,7 @@ var ChatGptAuthManager = class {
98085
98116
  access_token: data.access_token,
98086
98117
  refresh_token: data.refresh_token,
98087
98118
  expires_at: Date.now() + data.expires_in * 1e3,
98088
- account_id: tokens.account_id
98119
+ account_id: chatgptAccountIdFromJwt(data.access_token) || chatgptAccountIdFromJwt(data.id_token) || tokens.account_id
98089
98120
  }), data.access_token;
98090
98121
  }
98091
98122
  getAuthStatus() {
@@ -98276,7 +98307,7 @@ var GrokAuthManager = class {
98276
98307
  return fresh && Date.now() + REFRESH_BUFFER_MS2 < fresh.expires_at ? fresh.access_token : this.refreshTokens(fresh ?? tokens);
98277
98308
  }
98278
98309
  async refreshTokens(tokens) {
98279
- let data;
98310
+ let data, rejected = !1;
98280
98311
  try {
98281
98312
  let response = await fetch(TOKEN_URL2, {
98282
98313
  method: "POST",
@@ -98288,13 +98319,13 @@ var GrokAuthManager = class {
98288
98319
  }).toString()
98289
98320
  });
98290
98321
  if (!response.ok)
98291
- throw new Error(`Token refresh failed (${response.status})`);
98322
+ throw rejected = response.status === 400 || response.status === 401, new Error(`Token refresh failed (${response.status})`);
98292
98323
  data = await response.json();
98293
- } catch {
98324
+ } catch (err) {
98294
98325
  let fresh = this.syncFromDisk();
98295
98326
  if (fresh && fresh.refresh_token !== tokens.refresh_token && Date.now() + REFRESH_BUFFER_MS2 < fresh.expires_at)
98296
98327
  return fresh.access_token;
98297
- 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`);
98298
98329
  }
98299
98330
  if (data.id_token) {
98300
98331
  let claims = decodeJwtPayload2(data.id_token);
@@ -98499,7 +98530,7 @@ import { join as join29 } from "path";
98499
98530
  import { existsSync as existsSync15, mkdirSync as mkdirSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync11, rmSync as rmSync7 } from "fs";
98500
98531
  import { execFile as execFile8 } from "child_process";
98501
98532
  import { promisify as promisify4 } from "util";
98502
- var execFileAsync3 = promisify4(execFile8), IS_WIN2 = process.platform === "win32", NPM_BIN2 = IS_WIN2 ? "npm.cmd" : "npm", STDLIB_PACKAGES = [
98533
+ var execFileAsync3 = promisify4(execFile8), IS_WIN3 = process.platform === "win32", NPM_BIN3 = IS_WIN3 ? "npm.cmd" : "npm", STDLIB_PACKAGES = [
98503
98534
  // Document
98504
98535
  { name: "xlsx", version: "0.18.5" },
98505
98536
  { name: "pdf-lib", version: "1.17.1" },
@@ -98569,13 +98600,14 @@ var execFileAsync3 = promisify4(execFile8), IS_WIN2 = process.platform === "win3
98569
98600
  ), onProgress?.(`Installing ${name21}@${version}...`);
98570
98601
  try {
98571
98602
  let { stdout, stderr } = await execFileAsync3(
98572
- NPM_BIN2,
98603
+ NPM_BIN3,
98573
98604
  ["install", "--save", "--no-audit", "--no-fund", `${name21}@${version}`],
98574
98605
  {
98575
98606
  cwd: installDir,
98576
98607
  env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" },
98577
98608
  timeout: 12e4,
98578
- shell: IS_WIN2
98609
+ shell: IS_WIN3,
98610
+ windowsHide: !0
98579
98611
  }
98580
98612
  );
98581
98613
  stderr && !stderr.includes("npm warn") && console.warn(`[SandboxStdlib] npm stderr for ${name21}:`, stderr);
@@ -99670,7 +99702,7 @@ var UvManager = class {
99670
99702
  }
99671
99703
  async _getVersion(uvBin) {
99672
99704
  try {
99673
- let { stdout } = await execFileAsync4(uvBin, ["--version"], { timeout: 1e4 }), match = stdout.trim().match(/^uv\s+(\d+\.\d+\.\d+)/);
99705
+ let { stdout } = await execFileAsync4(uvBin, ["--version"], { timeout: 1e4, windowsHide: !0 }), match = stdout.trim().match(/^uv\s+(\d+\.\d+\.\d+)/);
99674
99706
  return match ? match[1] : null;
99675
99707
  } catch {
99676
99708
  return null;
@@ -99689,14 +99721,14 @@ var UvManager = class {
99689
99721
  "-NoProfile",
99690
99722
  "-Command",
99691
99723
  `Expand-Archive -Path '${archivePath}' -DestinationPath '${tempDir}' -Force`
99692
- ], { timeout: 6e4 }) : await execFileAsync4("tar", ["xzf", archivePath, "-C", tempDir, "--strip-components=1"], { timeout: 6e4 });
99724
+ ], { timeout: 6e4, windowsHide: !0 }) : await execFileAsync4("tar", ["xzf", archivePath, "-C", tempDir, "--strip-components=1"], { timeout: 6e4, windowsHide: !0 });
99693
99725
  let extractedBinary = join30(tempDir, binaryName);
99694
99726
  if (!existsSync16(extractedBinary))
99695
99727
  throw new Error(`Binary ${binaryName} not found after extraction in ${tempDir}`);
99696
99728
  let tempTarget = `${targetPath}.tmp`;
99697
99729
  if (renameSync4(extractedBinary, tempTarget), renameSync4(tempTarget, targetPath), process.platform !== "win32" && chmodSync(targetPath, 493), process.platform === "darwin")
99698
99730
  try {
99699
- await execFileAsync4("xattr", ["-d", "com.apple.quarantine", targetPath], { timeout: 5e3 });
99731
+ await execFileAsync4("xattr", ["-d", "com.apple.quarantine", targetPath], { timeout: 5e3, windowsHide: !0 });
99700
99732
  } catch {
99701
99733
  }
99702
99734
  return console.log(`[UvManager] Installed uv to ${targetPath}`), targetPath;
@@ -99713,7 +99745,7 @@ var UvManager = class {
99713
99745
  // ---------------------------------------------------------------------------
99714
99746
  async ensurePython(minVersion = "3.12") {
99715
99747
  let uv = await this.ensureUv();
99716
- await this._hasPython(uv, minVersion) || (console.log(`[UvManager] Installing Python ${minVersion}...`), await execFileAsync4(uv, ["python", "install", minVersion], { timeout: 3e5 }), console.log(`[UvManager] Python ${minVersion} installed`));
99748
+ await this._hasPython(uv, minVersion) || (console.log(`[UvManager] Installing Python ${minVersion}...`), await execFileAsync4(uv, ["python", "install", minVersion], { timeout: 3e5, windowsHide: !0 }), console.log(`[UvManager] Python ${minVersion} installed`));
99717
99749
  }
99718
99750
  async isPythonAvailable(minVersion = "3.12") {
99719
99751
  try {
@@ -99725,7 +99757,7 @@ var UvManager = class {
99725
99757
  }
99726
99758
  async _hasPython(uv, minVersion) {
99727
99759
  try {
99728
- return await execFileAsync4(uv, ["python", "find", minVersion], { timeout: 1e4 }), !0;
99760
+ return await execFileAsync4(uv, ["python", "find", minVersion], { timeout: 1e4, windowsHide: !0 }), !0;
99729
99761
  } catch {
99730
99762
  return !1;
99731
99763
  }
@@ -99737,12 +99769,13 @@ var UvManager = class {
99737
99769
  let uv = await this.ensureUv(), spec = version ? `${pkg}@${version}` : pkg;
99738
99770
  onProgress?.(`Installing ${spec} via uv...`), console.log(`[UvManager] Installing tool: ${spec}`), await execFileAsync4(uv, ["tool", "install", spec], {
99739
99771
  timeout: 12e4,
99772
+ windowsHide: !0,
99740
99773
  env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" }
99741
99774
  }), onProgress?.(`Installed ${spec}`), console.log(`[UvManager] Installed tool: ${spec}`);
99742
99775
  }
99743
99776
  async toolUninstall(pkg) {
99744
99777
  let uv = await this.ensureUv();
99745
- console.log(`[UvManager] Uninstalling tool: ${pkg}`), await execFileAsync4(uv, ["tool", "uninstall", pkg], { timeout: 3e4 });
99778
+ console.log(`[UvManager] Uninstalling tool: ${pkg}`), await execFileAsync4(uv, ["tool", "uninstall", pkg], { timeout: 3e4, windowsHide: !0 });
99746
99779
  }
99747
99780
  /**
99748
99781
  * Absolute path to a tool's executable, or throw so callers fall back to
@@ -99764,13 +99797,13 @@ var UvManager = class {
99764
99797
  }
99765
99798
  }, exeName = (name21) => process.platform === "win32" ? `${name21}.exe` : name21, names = [.../* @__PURE__ */ new Set([...await this.listEntryPoints(pkg), pkg])], binDirs = [];
99766
99799
  try {
99767
- let { stdout } = await execFileAsync4(uv, ["tool", "dir", "--bin"], { timeout: 1e4 });
99800
+ let { stdout } = await execFileAsync4(uv, ["tool", "dir", "--bin"], { timeout: 1e4, windowsHide: !0 });
99768
99801
  stdout.trim() && binDirs.push(stdout.trim());
99769
99802
  } catch {
99770
99803
  }
99771
99804
  binDirs.push(join30(homedir4(), ".local", "bin"));
99772
99805
  try {
99773
- let { stdout } = await execFileAsync4(uv, ["tool", "dir"], { timeout: 1e4 }), toolDir = stdout.trim();
99806
+ let { stdout } = await execFileAsync4(uv, ["tool", "dir"], { timeout: 1e4, windowsHide: !0 }), toolDir = stdout.trim();
99774
99807
  toolDir && binDirs.push(join30(toolDir, pkg, process.platform === "win32" ? "Scripts" : "bin"));
99775
99808
  } catch {
99776
99809
  }
@@ -99785,7 +99818,7 @@ var UvManager = class {
99785
99818
  async listEntryPoints(pkg) {
99786
99819
  let uv = await this.ensureUv();
99787
99820
  try {
99788
- let { stdout } = await execFileAsync4(uv, ["tool", "list"], { timeout: 1e4 }), names = [], inPkg = !1;
99821
+ let { stdout } = await execFileAsync4(uv, ["tool", "list"], { timeout: 1e4, windowsHide: !0 }), names = [], inPkg = !1;
99789
99822
  for (let line of stdout.split(`
99790
99823
  `))
99791
99824
  line.startsWith("- ") ? inPkg && names.push(line.slice(2).trim()) : inPkg = line.match(/^(\S+)\s+v?\S+/)?.[1] === pkg;
@@ -99797,7 +99830,7 @@ var UvManager = class {
99797
99830
  async listTools() {
99798
99831
  let uv = await this.ensureUv();
99799
99832
  try {
99800
- let { stdout } = await execFileAsync4(uv, ["tool", "list"], { timeout: 1e4 }), tools = [];
99833
+ let { stdout } = await execFileAsync4(uv, ["tool", "list"], { timeout: 1e4, windowsHide: !0 }), tools = [];
99801
99834
  for (let line of stdout.split(`
99802
99835
  `)) {
99803
99836
  let match = line.match(/^(\S+)\s+v?(\S+)/);
@@ -123628,7 +123661,7 @@ async function listProviderModels(runtime2, settingsStore, providerId, agentId)
123628
123661
  let cfg = resolveModelListProviderConfig(runtime2, settingsStore, providerId, agentId);
123629
123662
  if (!cfg) return { provider: providerId, models: [], error: `Provider "${providerId}" not found.` };
123630
123663
  if (cfg.type === "chatgpt-subscription") {
123631
- let { CHATGPT_SUBSCRIPTION_MODELS } = await import("./chatgpt-subscription-BQGWYZXE.mjs");
123664
+ let { CHATGPT_SUBSCRIPTION_MODELS } = await import("./chatgpt-subscription-E4MXTIAT.mjs");
123632
123665
  return { provider: providerId, models: [...CHATGPT_SUBSCRIPTION_MODELS] };
123633
123666
  }
123634
123667
  if (cfg.type === "grok-subscription") {
@@ -6,7 +6,7 @@ const __filename = __adfFileURLToPath(import.meta.url);
6
6
  const __dirname = __adfDirname(__filename);
7
7
  import {
8
8
  convertToOggOpus
9
- } from "./chunk-776TSXEP.mjs";
9
+ } from "./chunk-BMNZ2VPS.mjs";
10
10
  import "./chunk-3GNIDM53.mjs";
11
11
  import {
12
12
  require_safer
@@ -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-QMFRLBPQ.mjs"),
122
+ import("./App-ZRQS3U7S.mjs"),
123
123
  import("./themes-F2FKU7CP.mjs"),
124
124
  import("./store-HUVDJPYN.mjs"),
125
125
  import("./theme-NORU4J74.mjs"),
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-F5ELW46V.mjs";
10
10
  import {
11
11
  convertToOggOpus
12
- } from "./chunk-776TSXEP.mjs";
12
+ } from "./chunk-BMNZ2VPS.mjs";
13
13
  import "./chunk-3GNIDM53.mjs";
14
14
  import {
15
15
  require_atomic_sleep,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentdocumentformat/cli",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "ADF CLI: the ADF (Agent Document Format) daemon, command line and terminal app. Run your agents headless: `adf daemon`, then `adf`.",
5
5
  "type": "module",
6
6
  "bin": {