@moxxy/cli 0.48.2 → 0.48.3

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.
Files changed (2) hide show
  1. package/dist/bin.js +557 -75
  2. package/package.json +2 -2
package/dist/bin.js CHANGED
@@ -5,8 +5,8 @@ import * as fs43 from 'fs';
5
5
  import fs43__default, { promises, readFileSync, existsSync, statSync, readdirSync, mkdirSync, writeFileSync, realpathSync, unlinkSync, lstatSync, constants as constants$1, watch as watch$1 } from 'fs';
6
6
  import * as path3 from 'path';
7
7
  import path3__default, { dirname, join, posix, resolve, relative, sep, isAbsolute } from 'path';
8
- import { utf8Locale, ensurePrivateDir, moxxyHome, pruneStaleTempFiles, moxxyPath, hasProxy, installEgressProxy, readProxyEnv, writeFileAtomic, ensurePrivateFile, killTree as killTree$1, liveChannelStatus, spawnDedicatedChannel, stopDedicatedChannel, clearChannelStatus, findExecutable, PRIVATE_FILE_MODE, resolveOsPrincipal, redactProxyUrl, resolveExecutableTarget, spawnExecutableTarget, listLiveChannelStatuses, rotateChannelToken, writeSignedNetworkCacheAtomic, CrossProcessFireLock, fetchNpmLatest, writeChannelStatus, writeBoundedNetworkCacheAtomicSync, writeBoundedDataCacheAtomic, readRequestBody, bearerTokenMatches } from '@moxxy/sdk/server';
9
- import { spawn, spawnSync } from 'child_process';
8
+ import { utf8Locale, ensurePrivateDir, moxxyHome, pruneStaleTempFiles, moxxyPath, hasProxy, installEgressProxy, readProxyEnv, writeFileAtomic, ensurePrivateFile, killTree as killTree$1, liveChannelStatus, spawnDedicatedChannel, stopDedicatedChannel, clearChannelStatus, findExecutable, PRIVATE_FILE_MODE, resolveOsPrincipal, redactProxyUrl, resolveExecutableTarget, spawnExecutableTarget, listLiveChannelStatuses, rotateChannelToken, writeSignedNetworkCacheAtomic, CrossProcessFireLock, fetchNpmLatest, writeChannelStatus, withFileLock, writeBoundedNetworkCacheAtomicSync, writeBoundedDataCacheAtomic, readRequestBody, bearerTokenMatches } from '@moxxy/sdk/server';
9
+ import { spawn, spawnSync, execFile } from 'child_process';
10
10
  import { fileURLToPath, pathToFileURL } from 'url';
11
11
  import { MoxxyError, createMutex, defineChannel, definePlugin, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, withAgentConduct, questionAnswersSchema, defineTool, defineEmbedder, defineMode, asPluginId, computerControlSnapshotSchema, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, questionAnswerDisplay, describeQuestionAnswers, searchConversation, conversationTurns, asTurnId, waitFor, unfinishedWorkCheckpoint, unfinishedStepCheckpoint, runReactLoop, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isAgentNoReplyEvent, AGENT_NO_REPLY_TEXT, accountLimitOfEvent, isFileDiffDisplay, questionAnswerLines, stepListProgress, startingModel, fileDiffFromText, findAttachment, listAttachments, summarizeWithProvider, toolResultBytes, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, openQuestionsFromEvents, emptyDraft, questionAnswersProblem, draftAnswers, computeElisionState, toolResultStubbed, toolResultStubText, conversationalStubbed, conversationalStub, chooseOption, typeOwnAnswer, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, denyByDefaultResolver, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, verifyEd25519, mentionedSkills, skillAttachment, withoutTools, toolsForMode, moxxyPackageSchema, auditActionOf, asToolCallId, dispatchToolCall, matchLoadableTools, defineSecretProvider, encodeLoginAuthUrl, redactSecretText, encodeLoginPrompt, defineCommand, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, autoApproveFromEvents, AUTO_APPROVE_SUBTYPE, AUTO_APPROVE_PLUGIN_ID, autoApproveFromAgent, autoApproveRecorded, agentActivityRecord, withRecordedContextWindows, recordedContextWindows, parseFrontmatterFile, createJsonFileStore, autoApproveSwitch, eventForClient, computerControlCommandSchema, historyPageForClient, readAttachmentChunk, computerApprovalFocusSchema, workflowApprovalItemsSchema, evaluateToolRule, asEventId, QUESTION_ASKED, questionCloseNote, QUESTION_RESOLVED, QUESTION_CLOSED_NEW_MESSAGE as QUESTION_CLOSED_NEW_MESSAGE$1, questionRecord as questionRecord$1, QUESTION_PLUGIN_ID } from '@moxxy/sdk';
12
12
  import { createRequire as createRequire$1 } from 'module';
@@ -20129,7 +20129,7 @@ var init_scope = __esm({
20129
20129
 
20130
20130
  // ../core/dist/agent-cli-watch.js
20131
20131
  function differs(a2, b3) {
20132
- return a2.state !== b3.state || a2.installed !== b3.installed || a2.latest !== b3.latest || a2.signedIn !== b3.signedIn || a2.account !== b3.account;
20132
+ return a2.state !== b3.state || a2.installed !== b3.installed || a2.latest !== b3.latest || a2.signedIn !== b3.signedIn || a2.account !== b3.account || a2.knownIssue?.version !== b3.knownIssue?.version || a2.knownIssue?.reason !== b3.knownIssue?.reason;
20133
20133
  }
20134
20134
  var HOUR_MS, AgentCliWatch;
20135
20135
  var init_agent_cli_watch = __esm({
@@ -34281,7 +34281,7 @@ var init_provider = __esm({
34281
34281
  scheduleReconnect() {
34282
34282
  if (this.closed || this.reconnectTimer || this.targets.size === 0)
34283
34283
  return;
34284
- const delay4 = this.reconnectMs;
34284
+ const delay5 = this.reconnectMs;
34285
34285
  this.reconnectMs = Math.min(this.reconnectMs * 2, RECONNECT_MAX_MS);
34286
34286
  this.reconnectTimer = setTimeout(() => {
34287
34287
  this.reconnectTimer = null;
@@ -34289,7 +34289,7 @@ var init_provider = __esm({
34289
34289
  return;
34290
34290
  this.connectControl().then(() => this.logger?.info?.("proxy: control reconnected")).catch(() => {
34291
34291
  });
34292
- }, delay4);
34292
+ }, delay5);
34293
34293
  this.reconnectTimer.unref?.();
34294
34294
  }
34295
34295
  /** Pipe one inbound peer (raw bytes over a `/data` WS) to its target's port. */
@@ -44718,9 +44718,9 @@ var require_scheduler_development = __commonJS({
44718
44718
  var currentTime = exports.unstable_now();
44719
44719
  var startTime2;
44720
44720
  if (typeof options === "object" && options !== null) {
44721
- var delay4 = options.delay;
44722
- if (typeof delay4 === "number" && delay4 > 0) {
44723
- startTime2 = currentTime + delay4;
44721
+ var delay5 = options.delay;
44722
+ if (typeof delay5 === "number" && delay5 > 0) {
44723
+ startTime2 = currentTime + delay5;
44724
44724
  } else {
44725
44725
  startTime2 = currentTime;
44726
44726
  }
@@ -72817,19 +72817,39 @@ function agentCliNotice(connection) {
72817
72817
  const file = agentCliFile(report2);
72818
72818
  const where = file ? ` at ${file}` : "";
72819
72819
  const app = agentCliApp(report2);
72820
+ const heldBack = agentCliHeldBack(report2, agent);
72820
72821
  switch (report2.state) {
72821
72822
  case "missing":
72822
72823
  return { ...base, severity: "required", action: "install", text: `${agent} is not installed` };
72823
72824
  case "update-required": {
72824
72825
  const old = `${agent} ${report2.installed ?? ""}`.trim() + `${where} is older than Moxxy works with`;
72825
- return app ? { ...base, severity: "required", action: null, text: `${old} \u2014 it is part of ${app}, which updates it` } : { ...base, severity: "required", action: "update", text: `${old} \u2014 update it to ${report2.minimum} or newer` };
72826
+ return app ? { ...base, severity: "required", action: null, text: `${old} \u2014 it is part of ${app}, which updates it` } : heldBack ? { ...base, severity: "required", action: null, text: `${old} \u2014 ${heldBack}` } : report2.manualUpdate ? { ...base, severity: "required", action: null, text: `${old} \u2014 ${report2.manualUpdate}` } : { ...base, severity: "required", action: "update", text: `${old} \u2014 update it to ${report2.minimum} or newer` };
72827
+ }
72828
+ case "update-available": {
72829
+ return report2.latest && !app ? { ...base, severity: "available", action: report2.manualUpdate ? null : "update", text: `${agent} ${report2.latest} is out \u2014 you have ${report2.installed ?? "an older one"}${where}${report2.manualUpdate ? ` \u2014 ${report2.manualUpdate}` : ""}` } : null;
72830
+ }
72831
+ case "current": {
72832
+ const text3 = agentCliKnownIssue(report2, agent);
72833
+ return text3 ? { ...base, severity: "issue", action: null, text: text3 } : null;
72826
72834
  }
72827
- case "update-available":
72828
- return report2.latest && !app ? { ...base, severity: "available", action: "update", text: `${agent} ${report2.latest} is out \u2014 you have ${report2.installed ?? "an older one"}${where}` } : null;
72829
72835
  default:
72830
72836
  return null;
72831
72837
  }
72832
72838
  }
72839
+ function agentCliKnownIssue(report2, agent) {
72840
+ const issue2 = report2.knownIssue;
72841
+ if (!issue2 || issue2.version !== report2.installed)
72842
+ return null;
72843
+ const which = agent ? `${agent} ${issue2.version}` : issue2.version;
72844
+ return `${which} may not work well with Moxxy: ${issue2.reason}. A fixed version is on the way`;
72845
+ }
72846
+ function agentCliHeldBack(report2, agent) {
72847
+ const issue2 = report2.knownIssue;
72848
+ if (!issue2 || issue2.version === report2.installed)
72849
+ return null;
72850
+ const which = agent ? `${agent} ${issue2.version}` : issue2.version;
72851
+ return `${which} is out, but Moxxy holds it back: ${issue2.reason}`;
72852
+ }
72833
72853
  function agentCliFile(report2) {
72834
72854
  if (!report2.path)
72835
72855
  return null;
@@ -72851,7 +72871,7 @@ function activeAgentCliNotice(providers, activeProvider) {
72851
72871
  var ORIGIN_LABEL;
72852
72872
  var init_agent_cli = __esm({
72853
72873
  "../chat-model/dist/agent-cli.js"() {
72854
- ORIGIN_LABEL = { installer: "", homebrew: "Homebrew", npm: "npm", app: "", unknown: "" };
72874
+ ORIGIN_LABEL = { installer: "", homebrew: "Homebrew", winget: "winget", npm: "npm", bun: "bun", pnpm: "pnpm", yarn: "yarn", volta: "Volta", "vite-plus": "Vite+", mise: "mise", app: "", unknown: "" };
72855
72875
  }
72856
72876
  });
72857
72877
 
@@ -94534,7 +94554,7 @@ async function readCliVersion(target, timeoutMs = 1e4) {
94534
94554
  }
94535
94555
  function printedVersion(target, timeoutMs) {
94536
94556
  return new Promise((resolve20) => {
94537
- const child = spawnExecutableTarget(target, ["--version"], { stdio: ["ignore", "pipe", "ignore"] });
94557
+ const child = spawnExecutableTarget(target, ["--version"], { stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
94538
94558
  let out = "";
94539
94559
  const timer = setTimeout(() => child.kill(), timeoutMs);
94540
94560
  child.stdout?.on("data", (chunk) => {
@@ -94558,6 +94578,87 @@ var init_cli_version = __esm({
94558
94578
  isPreRelease = (char) => isDigit2(char) || isLetter(char) || char === "." || char === "-";
94559
94579
  }
94560
94580
  });
94581
+
94582
+ // ../agent-connection-kit/dist/agent-versions-blocked.json
94583
+ var agent_versions_blocked_default;
94584
+ var init_agent_versions_blocked = __esm({
94585
+ "../agent-connection-kit/dist/agent-versions-blocked.json"() {
94586
+ agent_versions_blocked_default = {
94587
+ $comment: 'Versions of the agent CLIs that break with Moxxy, by command. Moxxy does not offer them as an update and says what is wrong when one is installed. Read from the development branch at most once an hour; how to add or remove one: AGENTS.md, "Holding back a broken agent version".',
94588
+ claude: [],
94589
+ codex: [],
94590
+ opencode: []
94591
+ };
94592
+ }
94593
+ });
94594
+ function parseBlockedAgentVersions(value2) {
94595
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2))
94596
+ return null;
94597
+ const out = {};
94598
+ for (const [command, entries] of Object.entries(value2)) {
94599
+ if (!Array.isArray(entries))
94600
+ continue;
94601
+ out[command] = entries.flatMap((entry) => {
94602
+ const { version, reason } = entry && typeof entry === "object" ? entry : {};
94603
+ if (typeof version !== "string" || !VERSION.test(version) || typeof reason !== "string")
94604
+ return [];
94605
+ const said = reason.trim();
94606
+ return said && said.length <= MAX_REASON ? [{ version, reason: said }] : [];
94607
+ });
94608
+ }
94609
+ return out;
94610
+ }
94611
+ function blockedAgentVersion(list, command, version) {
94612
+ return list[command]?.find((entry) => compareVersions(entry.version, version.replace(/^v/, "")) === 0);
94613
+ }
94614
+ function defaultBlockedCacheFile() {
94615
+ return moxxyPath("cache", "agent-cli-blocked.json");
94616
+ }
94617
+ async function blockedAgentVersions(opts = {}) {
94618
+ const cacheFile = opts.cacheFile ?? defaultBlockedCacheFile();
94619
+ const now = (opts.now ?? Date.now)();
94620
+ const known = await readCache2(cacheFile);
94621
+ if (known && !opts.refresh && now - known.at < (opts.ttlMs ?? HOUR_MS2))
94622
+ return known.list;
94623
+ const fetched = await fetchList(opts.url ?? BLOCKED_AGENT_VERSIONS_URL, opts.fetchImpl ?? fetch);
94624
+ if (!fetched)
94625
+ return known?.list ?? BUNDLED_BLOCKED_AGENT_VERSIONS;
94626
+ await writeFileAtomic(cacheFile, JSON.stringify({ at: now, list: fetched })).catch(() => void 0);
94627
+ return fetched;
94628
+ }
94629
+ async function cachedBlockedAgentVersions(cacheFile = defaultBlockedCacheFile()) {
94630
+ return (await readCache2(cacheFile))?.list ?? BUNDLED_BLOCKED_AGENT_VERSIONS;
94631
+ }
94632
+ async function fetchList(url, fetchImpl) {
94633
+ try {
94634
+ const res = await fetchImpl(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS2) });
94635
+ return res.ok ? parseBlockedAgentVersions(JSON.parse(await res.text())) : null;
94636
+ } catch {
94637
+ return null;
94638
+ }
94639
+ }
94640
+ async function readCache2(file) {
94641
+ try {
94642
+ const { at, list } = JSON.parse(await readFile(file, "utf8"));
94643
+ const parsed = parseBlockedAgentVersions(list);
94644
+ return typeof at === "number" && parsed ? { at, list: parsed } : null;
94645
+ } catch {
94646
+ return null;
94647
+ }
94648
+ }
94649
+ var BLOCKED_AGENT_VERSIONS_URL, VERSION, MAX_REASON, HOUR_MS2, FETCH_TIMEOUT_MS2, BUNDLED_BLOCKED_AGENT_VERSIONS;
94650
+ var init_agent_versions_blocked2 = __esm({
94651
+ "../agent-connection-kit/dist/agent-versions-blocked.js"() {
94652
+ init_agent_versions_blocked();
94653
+ init_cli_version();
94654
+ BLOCKED_AGENT_VERSIONS_URL = "https://raw.githubusercontent.com/moxxy-ai/moxxy/development/packages/agent-connection-kit/src/agent-versions-blocked.json";
94655
+ VERSION = /^\d+(\.\d+)+$/;
94656
+ MAX_REASON = 300;
94657
+ HOUR_MS2 = 60 * 6e4;
94658
+ FETCH_TIMEOUT_MS2 = 1e4;
94659
+ BUNDLED_BLOCKED_AGENT_VERSIONS = parseBlockedAgentVersions(agent_versions_blocked_default) ?? {};
94660
+ }
94661
+ });
94561
94662
  function codexWindowsPrograms(arch) {
94562
94663
  const build2 = CODEX_WINDOWS_BUILDS[arch];
94563
94664
  if (!build2)
@@ -94567,11 +94668,17 @@ function codexWindowsPrograms(arch) {
94567
94668
  CODEX_MANAGED_BY_NPM: "1",
94568
94669
  CODEX_MANAGED_PACKAGE_ROOT: path3__default.win32.join(shimDir, "node_modules", "@openai", "codex")
94569
94670
  });
94570
- return [
94671
+ const shimRelative = [
94571
94672
  `node_modules/@openai/codex/node_modules/@openai/${build2.pkg}/${program}`,
94572
94673
  `node_modules/@openai/${build2.pkg}/${program}`,
94573
94674
  `node_modules/@openai/codex/${program}`
94574
94675
  ].map((relative9) => ({ path: relative9, env: env3 }));
94676
+ const pnpm = {
94677
+ path: `../${build2.pkg}/${program}`,
94678
+ fromRealPackage: true,
94679
+ env: (packageRoot) => ({ CODEX_MANAGED_BY_PNPM: "1", CODEX_MANAGED_PACKAGE_ROOT: packageRoot })
94680
+ };
94681
+ return [...shimRelative, pnpm];
94575
94682
  }
94576
94683
  function searchOptions(desc, opts) {
94577
94684
  const platform2 = opts.platform ?? process.platform;
@@ -94618,6 +94725,18 @@ function agentCliOrigin(desc, file, opts = {}) {
94618
94725
  }
94619
94726
  }
94620
94727
  const slashed = real.replaceAll("\\", "/");
94728
+ const seen = [file.replaceAll("\\", "/").toLowerCase(), slashed.toLowerCase()];
94729
+ const shimmed = platform2 === "win32" ? windowsToolShim(desc, file, opts.read ?? ((f2) => readFileSync(f2, "utf8"))) : null;
94730
+ if (shimmed)
94731
+ return shimmed;
94732
+ const manager = PACKAGE_TOOLS.find((tool) => seen.some((p3) => tool.owns.test(p3)));
94733
+ if (manager)
94734
+ return { origin: manager.origin };
94735
+ const npmPrefix = npmGlobalPrefix(real, desc.npmPackage, platform2) ?? (platform2 === "win32" ? npmWindowsShimPrefix(file, desc.npmPackage, opts.exists ?? existsSync) : null);
94736
+ if (npmPrefix)
94737
+ return { origin: "npm", npmPrefix };
94738
+ if (seen.some((p3) => MISE_PATH.test(p3)))
94739
+ return { origin: "mise" };
94621
94740
  for (const [folder2, cask] of [["Caskroom", true], ["Cellar", false]]) {
94622
94741
  const marker = `/${folder2}/`;
94623
94742
  const at = slashed.lastIndexOf(marker);
@@ -94625,6 +94744,9 @@ function agentCliOrigin(desc, file, opts = {}) {
94625
94744
  if (name)
94626
94745
  return { origin: "homebrew", homebrew: { prefix: real.slice(0, at), name, cask } };
94627
94746
  }
94747
+ const winget = /\/Microsoft\/WinGet\/Packages\/([^/_]+)_/i.exec(slashed);
94748
+ if (winget?.[1])
94749
+ return { origin: "winget", winget: { id: winget[1] } };
94628
94750
  if (comparable(slashed).includes(comparable(`/node_modules/${desc.npmPackage}/`)))
94629
94751
  return { origin: "npm" };
94630
94752
  const home = opts.home ?? homedir();
@@ -94633,6 +94755,113 @@ function agentCliOrigin(desc, file, opts = {}) {
94633
94755
  return { origin: "installer" };
94634
94756
  return { origin: "unknown" };
94635
94757
  }
94758
+ function windowsToolShim(desc, file, read) {
94759
+ if (!WINDOWS_SHIMS.has(path3__default.win32.extname(file).toLowerCase()))
94760
+ return null;
94761
+ let text3;
94762
+ try {
94763
+ text3 = read(file);
94764
+ } catch {
94765
+ return null;
94766
+ }
94767
+ const dir = path3__default.win32.dirname(file);
94768
+ const home = path3__default.win32.dirname(dir);
94769
+ if (/\bvolta run\b/i.test(text3))
94770
+ return { origin: "volta", toolFolders: { env: { VOLTA_HOME: home } } };
94771
+ const targets = [...text3.matchAll(SHIM_TARGET)].map((match) => match[1] ?? "");
94772
+ const yarnGlobal = targets.map((target) => /^(.*\\global)\\node_modules\\\.bin\\[^\\]+\.cmd$/i.exec(target)?.[1]).find(Boolean);
94773
+ if (yarnGlobal)
94774
+ return { origin: "yarn", toolFolders: { args: ["--global-folder", path3__default.win32.resolve(dir, yarnGlobal), "--prefix", home] } };
94775
+ const pkg = `\\node_modules\\${desc.npmPackage.replaceAll("/", "\\").toLowerCase()}\\`;
94776
+ if (targets.some((target) => target.toLowerCase().includes(pkg) && /(?:^|\\)global\\/i.test(target))) {
94777
+ const pnpmHome = path3__default.win32.basename(dir).toLowerCase() === "bin" ? home : dir;
94778
+ return { origin: "pnpm", toolFolders: { env: { PNPM_HOME: pnpmHome } } };
94779
+ }
94780
+ return null;
94781
+ }
94782
+ function npmGlobalPrefix(real, pkg, platform2) {
94783
+ const lower2 = real.replaceAll("\\", "/").toLowerCase();
94784
+ const layout = platform2 === "win32" ? `/node_modules/${pkg.toLowerCase()}/` : `/lib/node_modules/${pkg.toLowerCase()}/`;
94785
+ const at = lower2.lastIndexOf(layout);
94786
+ if (at < 0 || lower2.slice(0, at).includes("/node_modules/"))
94787
+ return null;
94788
+ const mise = /\/mise\/installs\/([^/]+)\/[^/]+$/.exec(lower2.slice(0, at))?.[1];
94789
+ if (mise && mise !== "node")
94790
+ return null;
94791
+ return at === 0 ? "/" : real.slice(0, at);
94792
+ }
94793
+ function npmWindowsShimPrefix(file, pkg, exists3) {
94794
+ const dir = path3__default.win32.dirname(file);
94795
+ if (dir.replaceAll("\\", "/").toLowerCase().includes("/node_modules/"))
94796
+ return null;
94797
+ return exists3(path3__default.win32.join(dir, "node_modules", ...pkg.split("/"), "package.json")) ? dir : null;
94798
+ }
94799
+ function agentCliUpdatePlan(desc, file, source) {
94800
+ const tool = PACKAGE_TOOLS.find((candidate) => candidate.origin === source.origin);
94801
+ if (tool) {
94802
+ const args = [...tool.args(desc.npmPackage), ...source.toolFolders?.args ?? []];
94803
+ return { kind: "run", command: tool.command, args, ...source.toolFolders?.env ? { env: source.toolFolders.env } : {} };
94804
+ }
94805
+ if (source.origin === "mise")
94806
+ return { kind: "manual", hint: "update it with mise" };
94807
+ if (source.npmPrefix) {
94808
+ const args = ["install", "-g", "--prefix", source.npmPrefix, `--allow-scripts=${desc.npmPackage}`, `${desc.npmPackage}@latest`];
94809
+ return { kind: "run", command: "npm", args };
94810
+ }
94811
+ const slashed = file.replaceAll("\\", "/").toLowerCase();
94812
+ if (desc.legacyNpmPackages?.some((pkg) => slashed.includes(`/node_modules/${pkg.toLowerCase()}/`)))
94813
+ return { kind: "own" };
94814
+ if (source.origin === "unknown" && slashed.includes("/node_modules/")) {
94815
+ return { kind: "manual", hint: `update the project or tool that installed it (${desc.npmPackage})` };
94816
+ }
94817
+ if (source.origin === "npm")
94818
+ return { kind: "manual", hint: `update it with npm (npm install -g ${desc.npmPackage}@latest)` };
94819
+ return { kind: "own" };
94820
+ }
94821
+ function agentCliToolTarget(plan, file, opts = {}) {
94822
+ const dirs = (opts.pathEnv ?? process.env.PATH ?? "").split(path3__default.delimiter).filter(Boolean);
94823
+ try {
94824
+ return resolveExecutableTarget(plan.command, {
94825
+ platform: opts.platform ?? process.platform,
94826
+ pathEnv: "",
94827
+ extraPaths: [path3__default.dirname(file), ...dirs],
94828
+ ...opts.electron !== void 0 ? { electron: opts.electron } : {}
94829
+ });
94830
+ } catch {
94831
+ return null;
94832
+ }
94833
+ }
94834
+ function manualUpdateOf(plan, file, opts) {
94835
+ if (plan.kind === "manual")
94836
+ return plan.hint;
94837
+ if (plan.kind === "run" && !agentCliToolTarget(plan, file, opts))
94838
+ return `run ${[plan.command, ...plan.args].join(" ")}`;
94839
+ return null;
94840
+ }
94841
+ function windowsShimRoot(desc, found, read) {
94842
+ const pkg = `${desc.npmPackage.replaceAll("/", "\\")}\\`.toLowerCase();
94843
+ let file = found;
94844
+ for (let hop = 0; hop < 2; hop++) {
94845
+ const dir = path3__default.win32.dirname(file);
94846
+ let text3;
94847
+ try {
94848
+ text3 = read(file);
94849
+ } catch {
94850
+ break;
94851
+ }
94852
+ if (/\bvolta run\b/i.test(text3))
94853
+ return path3__default.win32.join(dir, "..", "tools", "image", "packages", ...desc.npmPackage.split("/"));
94854
+ const targets = [...text3.matchAll(SHIM_TARGET)].map((match) => match[1] ?? "");
94855
+ const script = targets.find((target) => target.toLowerCase().includes(pkg));
94856
+ if (script)
94857
+ return path3__default.win32.dirname(path3__default.win32.join(dir, script.slice(0, script.toLowerCase().indexOf(pkg))));
94858
+ const next = targets.find((target) => target.toLowerCase().endsWith(".cmd"));
94859
+ if (!next)
94860
+ break;
94861
+ file = path3__default.win32.join(dir, next);
94862
+ }
94863
+ return path3__default.win32.dirname(found);
94864
+ }
94636
94865
  function agentCliTargetAt(desc, found, opts = {}) {
94637
94866
  const platform2 = opts.platform ?? process.platform;
94638
94867
  if (platform2 !== "win32")
@@ -94642,13 +94871,23 @@ function agentCliTargetAt(desc, found, opts = {}) {
94642
94871
  return { kind: "direct", command: found };
94643
94872
  if (!WINDOWS_SHIMS.has(extension2))
94644
94873
  throw new Error(`Cannot run ${desc.name} from ${found}; install it again or point at ${desc.command}.exe.`);
94645
- const dir = path3__default.win32.dirname(found);
94874
+ const dir = windowsShimRoot(desc, found, opts.read ?? ((file) => readFileSync(file, "utf8")));
94646
94875
  const at = (relative9) => path3__default.win32.join(dir, ...relative9.split("/"));
94647
94876
  const exists3 = opts.exists ?? existsSync;
94877
+ const realPackage = () => {
94878
+ try {
94879
+ return (opts.realpath ?? realpathSync.native)(at(`node_modules/${desc.npmPackage}`));
94880
+ } catch {
94881
+ return null;
94882
+ }
94883
+ };
94648
94884
  for (const program of desc.windowsShim.native?.(opts.arch ?? process.arch) ?? []) {
94649
- const command = at(program.path);
94885
+ const root = program.fromRealPackage ? realPackage() : dir;
94886
+ if (!root)
94887
+ continue;
94888
+ const command = path3__default.win32.join(root, ...program.path.split("/"));
94650
94889
  if (exists3(command))
94651
- return program.env ? { kind: "direct", command, env: program.env(dir) } : { kind: "direct", command };
94890
+ return program.env ? { kind: "direct", command, env: program.env(root) } : { kind: "direct", command };
94652
94891
  }
94653
94892
  const entry = at(desc.windowsShim.entry);
94654
94893
  if (!exists3(entry))
@@ -94658,17 +94897,96 @@ function agentCliTargetAt(desc, found, opts = {}) {
94658
94897
  const electron = opts.electron ?? Boolean(process.versions.electron);
94659
94898
  return { kind: "node", command: process.execPath, entry, env: electron ? { ELECTRON_RUN_AS_NODE: "1" } : {} };
94660
94899
  }
94900
+ function agentVersionSource(desc, source, opts = {}) {
94901
+ const fetchImpl = opts.fetchImpl ?? fetch;
94902
+ if (source.origin === "homebrew" && source.homebrew) {
94903
+ const { name, cask } = source.homebrew;
94904
+ const url = `https://formulae.brew.sh/api/${cask ? "cask" : "formula"}/${encodeURIComponent(name)}.json`;
94905
+ return {
94906
+ key: `homebrew:${cask ? "cask" : "formula"}:${name}`,
94907
+ fetch: async () => {
94908
+ const json = await readUrl(url, fetchImpl).then((text3) => JSON.parse(text3 ?? "null")).catch(() => null);
94909
+ const version = cask ? json?.version : json?.versions?.stable;
94910
+ return typeof version === "string" ? version.split(",")[0] ?? null : null;
94911
+ }
94912
+ };
94913
+ }
94914
+ if (source.origin === "winget" && source.winget) {
94915
+ const { id } = source.winget;
94916
+ const run2 = opts.run ?? runForOutput;
94917
+ return {
94918
+ key: `winget:${id}`,
94919
+ fetch: async () => {
94920
+ const output = await run2("winget", wingetArgs("show", id)).catch(() => "");
94921
+ return /^[^:\r\n]+:\s*v?(\d+(?:\.\d+)+)\s*$/m.exec(output)?.[1] ?? null;
94922
+ }
94923
+ };
94924
+ }
94925
+ const channel = desc.releaseChannel;
94926
+ if (source.origin === "installer" && channel) {
94927
+ return {
94928
+ key: `channel:${desc.command}`,
94929
+ fetch: async () => {
94930
+ const url = channel.url(await chosenChannel(channel, opts.home ?? homedir()));
94931
+ const text3 = await readUrl(url, fetchImpl).catch(() => null);
94932
+ return text3 && /^\d+(\.\d+)+/.test(text3.trim()) ? text3.trim() : null;
94933
+ }
94934
+ };
94935
+ }
94936
+ return { key: desc.npmPackage, fetch: () => fetchNpmLatest(desc.npmPackage, { fetchImpl }) };
94937
+ }
94938
+ function wingetArgs(command, id) {
94939
+ return [command, "--id", id, "--exact", "--disable-interactivity", "--accept-source-agreements"];
94940
+ }
94941
+ async function chosenChannel(channel, home) {
94942
+ try {
94943
+ const settings2 = JSON.parse(await readFile(path3__default.join(home, ...channel.settingsFile.split("/")), "utf8"));
94944
+ const chosen = settings2?.[channel.setting];
94945
+ return typeof chosen === "string" && chosen ? chosen : channel.fallback;
94946
+ } catch {
94947
+ return channel.fallback;
94948
+ }
94949
+ }
94950
+ async function readUrl(url, fetchImpl) {
94951
+ const res = await fetchImpl(url, { signal: AbortSignal.timeout(SOURCE_TIMEOUT_MS) });
94952
+ return res.ok ? res.text() : null;
94953
+ }
94954
+ function runForOutput(command, args) {
94955
+ return new Promise((resolve20, reject) => {
94956
+ execFile(command, [...args], { timeout: SOURCE_TIMEOUT_MS, windowsHide: true }, (err, stdout2) => err ? reject(err) : resolve20(stdout2));
94957
+ });
94958
+ }
94959
+ function rememberNotBrought(cacheFile, key) {
94960
+ return changeLatestCache(cacheFile, (cache4) => {
94961
+ const known = cache4[key];
94962
+ return known ? { ...cache4, [key]: { ...known, notBrought: known.version } } : null;
94963
+ });
94964
+ }
94965
+ function changeLatestCache(file, change) {
94966
+ const run2 = (cacheChanges.get(file) ?? Promise.resolve()).then(() => withFileLock(file, async () => {
94967
+ const next = change(await readLatestCache(file));
94968
+ if (next)
94969
+ await writeFileAtomic(file, JSON.stringify(next));
94970
+ }).catch(() => void 0));
94971
+ const settled = run2.catch(() => void 0);
94972
+ cacheChanges.set(file, settled);
94973
+ void settled.then(() => {
94974
+ if (cacheChanges.get(file) === settled)
94975
+ cacheChanges.delete(file);
94976
+ });
94977
+ return run2;
94978
+ }
94661
94979
  async function latestAgentVersion(pkg, opts = {}) {
94662
- const cacheFile = opts.cacheFile ?? moxxyPath("cache", "agent-cli-latest.json");
94980
+ const cacheFile = opts.cacheFile ?? defaultCacheFile2();
94663
94981
  const now = (opts.now ?? Date.now)();
94664
94982
  const cache4 = await readLatestCache(cacheFile);
94665
94983
  const known = cache4[pkg];
94666
- if (known && !opts.refresh && now - known.at < (opts.ttlMs ?? HOUR_MS2))
94984
+ if (known && !opts.refresh && now - known.at < (opts.ttlMs ?? HOUR_MS3))
94667
94985
  return known.version;
94668
94986
  const fetched = await (opts.fetchLatest ?? ((name) => fetchNpmLatest(name)))(pkg);
94669
94987
  if (!fetched)
94670
94988
  return known ? known.version : null;
94671
- await writeFileAtomic(cacheFile, JSON.stringify({ ...cache4, [pkg]: { version: fetched, at: now } })).catch(() => void 0);
94989
+ await changeLatestCache(cacheFile, (latest) => ({ ...latest, [pkg]: { ...latest[pkg], version: fetched, at: now } }));
94672
94990
  return fetched;
94673
94991
  }
94674
94992
  async function readLatestCache(file) {
@@ -94678,9 +94996,10 @@ async function readLatestCache(file) {
94678
94996
  return {};
94679
94997
  const out = {};
94680
94998
  for (const [pkg, entry] of Object.entries(parsed)) {
94681
- const { version, at } = entry ?? {};
94682
- if (typeof version === "string" && typeof at === "number")
94683
- out[pkg] = { version, at };
94999
+ const { version, at, notBrought } = entry ?? {};
95000
+ if (typeof version === "string" && typeof at === "number") {
95001
+ out[pkg] = { version, at, ...typeof notBrought === "string" ? { notBrought } : {} };
95002
+ }
94684
95003
  }
94685
95004
  return out;
94686
95005
  } catch {
@@ -94689,14 +95008,22 @@ async function readLatestCache(file) {
94689
95008
  }
94690
95009
  async function checkAgentCli(desc, opts = {}, deps = {}) {
94691
95010
  const refresh = opts.refresh === true;
94692
- const [found, latest] = await Promise.all([
94693
- installedVersion(desc, opts),
94694
- (deps.latest ?? ((pkg, o2) => latestAgentVersion(pkg, o2)))(desc.npmPackage, { refresh })
94695
- ]);
95011
+ const found = await installedVersion(desc, opts);
95012
+ const source = versionSourceOf(desc, found.file, opts);
95013
+ const offered = deps.latest ? await deps.latest(desc.npmPackage, { refresh }) : await latestAgentVersion(source.key, { refresh, fetchLatest: source.fetch, ...cacheOption(opts) });
95014
+ const notBrought = (await readLatestCache(opts.cacheFile ?? defaultCacheFile2()))[source.key]?.notBrought;
95015
+ const blocked = deps.blocked ? await deps.blocked({ refresh }) : deps.latest ? BUNDLED_BLOCKED_AGENT_VERSIONS : await blockedAgentVersions({ refresh, cacheFile: blockedCacheFileFor(opts), ...opts.fetchImpl ? { fetchImpl: opts.fetchImpl } : {} });
95016
+ const heldBack = offered ? blockedAgentVersion(blocked, desc.command, offered) : void 0;
95017
+ const latest = offered && (offered === notBrought || heldBack) ? found.version : offered;
95018
+ const brokenInstalled = found.version ? blockedAgentVersion(blocked, desc.command, found.version) : void 0;
95019
+ const knownIssue = brokenInstalled ?? heldBack;
95020
+ const origin = found.file ? agentCliOrigin(desc, found.file, originOptions(opts)) : null;
95021
+ const manualUpdate = found.file && origin ? manualUpdateOf(agentCliUpdatePlan(desc, found.file, origin), found.file, opts) : null;
94696
95022
  const base = {
94697
95023
  command: desc.command,
94698
95024
  installed: found.version,
94699
- ...found.file ? { path: found.file, origin: agentCliOrigin(desc, found.file, originOptions(opts)).origin } : {},
95025
+ ...found.file && origin ? { path: found.file, origin: origin.origin } : {},
95026
+ ...manualUpdate ? { manualUpdate } : {},
94700
95027
  latest,
94701
95028
  minimum: desc.minimumVersion,
94702
95029
  checkedAt: (deps.now ?? Date.now)()
@@ -94704,7 +95031,11 @@ async function checkAgentCli(desc, opts = {}, deps = {}) {
94704
95031
  if (!found.present)
94705
95032
  return { state: "missing", ...base };
94706
95033
  const signIn = deps.signIn ? await deps.signIn() : void 0;
94707
- const known = { ...base, ...signIn ? { signedIn: signIn.signedIn, account: signIn.account ?? null } : {} };
95034
+ const known = {
95035
+ ...base,
95036
+ ...signIn ? { signedIn: signIn.signedIn, account: signIn.account ?? null } : {},
95037
+ ...knownIssue ? { knownIssue } : {}
95038
+ };
94708
95039
  if (!found.version)
94709
95040
  return { state: "unknown", ...known };
94710
95041
  if (compareVersions(found.version, desc.minimumVersion) < 0)
@@ -94713,6 +95044,26 @@ async function checkAgentCli(desc, opts = {}, deps = {}) {
94713
95044
  return { state: "update-available", ...known };
94714
95045
  return { state: "current", ...known };
94715
95046
  }
95047
+ function defaultCacheFile2() {
95048
+ return moxxyPath("cache", "agent-cli-latest.json");
95049
+ }
95050
+ function cacheOption(opts) {
95051
+ return opts.cacheFile ? { cacheFile: opts.cacheFile } : {};
95052
+ }
95053
+ function blockedCacheFileFor(opts) {
95054
+ return opts.cacheFile ? path3__default.join(path3__default.dirname(opts.cacheFile), "agent-cli-blocked.json") : defaultBlockedCacheFile();
95055
+ }
95056
+ async function heldBackUpdate(desc, file, opts) {
95057
+ const latest = (await readLatestCache(opts.cacheFile ?? defaultCacheFile2()))[versionSourceOf(desc, file, opts).key]?.version;
95058
+ return latest ? blockedAgentVersion(await cachedBlockedAgentVersions(blockedCacheFileFor(opts)), desc.command, latest) : void 0;
95059
+ }
95060
+ function versionSourceOf(desc, file, opts) {
95061
+ const source = file ? agentCliOrigin(desc, file, originOptions(opts)) : { origin: "unknown" };
95062
+ return agentVersionSource(desc, source, {
95063
+ ...opts.home !== void 0 ? { home: opts.home } : {},
95064
+ ...opts.fetchImpl ? { fetchImpl: opts.fetchImpl } : {}
95065
+ });
95066
+ }
94716
95067
  function originOptions(opts) {
94717
95068
  return { ...opts.home !== void 0 ? { home: opts.home } : {}, ...opts.platform !== void 0 ? { platform: opts.platform } : {} };
94718
95069
  }
@@ -94757,44 +95108,111 @@ function installInvocation(desc, platform2 = process.platform) {
94757
95108
  }
94758
95109
  async function runAgentCliAction(desc, action, opts = {}) {
94759
95110
  const platform2 = opts.platform ?? process.platform;
94760
- let child;
94761
- if (action === "install") {
94762
- const { command, args } = installInvocation(desc, platform2);
94763
- child = spawn(command, [...args], {
94764
- env: { ...process.env, ...desc.installEnv },
94765
- stdio: ["ignore", "pipe", "pipe"],
95111
+ if (action === "update")
95112
+ return updateAgentCli(desc, opts, platform2);
95113
+ const { command, args } = installInvocation(desc, platform2);
95114
+ const child = spawn(command, [...args], {
95115
+ env: { ...process.env, ...desc.installEnv },
95116
+ stdio: UPDATER_STDIO,
95117
+ detached: platform2 !== "win32",
95118
+ windowsHide: true
95119
+ });
95120
+ return watch(child, opts, "the installer");
95121
+ }
95122
+ async function updateAgentCli(desc, opts, platform2) {
95123
+ const found = findAgentCli(desc, opts);
95124
+ if (!found)
95125
+ return { ok: false, message: `${desc.name} is not installed.` };
95126
+ const source = agentCliOrigin(desc, found, originOptions(opts));
95127
+ if (source.origin === "app")
95128
+ return { ok: false, message: `The ${desc.name} at ${found} is part of ${source.app ?? "an app"} and updates with it.` };
95129
+ const plan = agentCliUpdatePlan(desc, found, source);
95130
+ if (plan.kind === "manual")
95131
+ return { ok: false, message: `Moxxy cannot update the ${desc.name} at ${found}: ${plan.hint}.` };
95132
+ const held = opts.cacheFile ? await heldBackUpdate(desc, found, opts) : void 0;
95133
+ if (held) {
95134
+ return {
95135
+ ok: false,
95136
+ message: `${desc.name} ${held.version}, the newest, has a known problem with Moxxy: ${held.reason}. Moxxy holds the update back until a fixed version is out.`
95137
+ };
95138
+ }
95139
+ const before = opts.cacheFile ? (await installedVersion(desc, opts)).version : null;
95140
+ const updater = await startUpdater(desc, found, source, plan, opts, platform2);
95141
+ if ("refused" in updater)
95142
+ return updater.refused;
95143
+ const result = await watch(updater.child, opts, `"${updater.command}"`);
95144
+ return result.ok && before ? whatTheUpdateLeft(desc, found, before, result, opts) : result;
95145
+ }
95146
+ async function startUpdater(desc, found, source, plan, opts, platform2) {
95147
+ if (source.winget && platform2 === "win32") {
95148
+ const args2 = [...wingetArgs("upgrade", source.winget.id), "--silent", "--accept-package-agreements"];
95149
+ return { child: spawn("winget", args2, { stdio: UPDATER_STDIO, windowsHide: true }), command: ["winget", ...args2].join(" ") };
95150
+ }
95151
+ if (plan.kind === "run") {
95152
+ const command = [plan.command, ...plan.args].join(" ");
95153
+ const tool = agentCliToolTarget(plan, found, opts);
95154
+ if (!tool)
95155
+ return { refused: { ok: false, message: `Moxxy cannot update the ${desc.name} at ${found}: run ${command}.` } };
95156
+ const child2 = spawnExecutableTarget(tool, plan.args, {
95157
+ cwd: path3__default.dirname(found),
95158
+ ...plan.env ? { env: plan.env } : {},
95159
+ stdio: UPDATER_STDIO,
94766
95160
  detached: platform2 !== "win32",
94767
95161
  windowsHide: true
94768
95162
  });
94769
- } else {
94770
- const found = findAgentCli(desc, opts);
94771
- if (!found)
94772
- return { ok: false, message: `${desc.name} is not installed.` };
94773
- const source = agentCliOrigin(desc, found, originOptions(opts));
94774
- if (source.origin === "app")
94775
- return { ok: false, message: `The ${desc.name} at ${found} is part of ${source.app ?? "an app"} and updates with it.` };
94776
- const brew = source.homebrew && platform2 !== "win32" ? path3__default.posix.join(source.homebrew.prefix, "bin", "brew") : null;
94777
- if (brew && source.homebrew && existsSync(brew)) {
94778
- child = spawn(brew, ["upgrade", ...source.homebrew.cask ? ["--cask"] : [], source.homebrew.name], {
94779
- stdio: ["ignore", "pipe", "pipe"],
94780
- detached: true
94781
- });
94782
- } else {
94783
- let target;
95163
+ return { child: child2, command };
95164
+ }
95165
+ const brew = source.homebrew && platform2 !== "win32" ? path3__default.posix.join(source.homebrew.prefix, "bin", "brew") : null;
95166
+ if (brew && source.homebrew && existsSync(brew)) {
95167
+ const args2 = ["upgrade", ...source.homebrew.cask ? ["--cask"] : [], source.homebrew.name];
95168
+ return { child: spawn(brew, args2, { stdio: UPDATER_STDIO, detached: true }), command: ["brew", ...args2].join(" ") };
95169
+ }
95170
+ let target;
95171
+ try {
95172
+ target = agentCliTargetAt(desc, found, { platform: platform2 });
95173
+ } catch (err) {
95174
+ return { refused: { ok: false, message: err instanceof Error ? err.message : String(err) } };
95175
+ }
95176
+ const args = await updateArgsFor(desc, target, opts);
95177
+ const child = spawnExecutableTarget(target, args, {
95178
+ env: updaterEnv(found, opts.hostPathDirs ?? [], process.env, platform2),
95179
+ stdio: UPDATER_STDIO,
95180
+ detached: platform2 !== "win32",
95181
+ windowsHide: true
95182
+ });
95183
+ return { child, command: [desc.command, ...args].join(" ") };
95184
+ }
95185
+ async function versionAfterUpdate(desc, opts) {
95186
+ for (let attempt = 1; ; attempt += 1) {
95187
+ const file = findAgentCli(desc, opts);
95188
+ let runs = false;
95189
+ if (file) {
94784
95190
  try {
94785
- target = agentCliTargetAt(desc, found, { platform: platform2 });
94786
- } catch (err) {
94787
- return { ok: false, message: err instanceof Error ? err.message : String(err) };
95191
+ const target = agentCliTargetAt(desc, file, { platform: opts.platform ?? process.platform });
95192
+ runs = true;
95193
+ const version = await readCliVersion(target);
95194
+ if (version)
95195
+ return version;
95196
+ } catch {
95197
+ runs = false;
94788
95198
  }
94789
- child = spawnExecutableTarget(target, await updateArgsFor(desc, target, opts), {
94790
- env: updaterEnv(found, opts.hostPathDirs ?? [], process.env, platform2),
94791
- stdio: ["ignore", "pipe", "pipe"],
94792
- detached: platform2 !== "win32",
94793
- windowsHide: true
94794
- });
94795
95199
  }
95200
+ if (attempt === VERSION_TRIES)
95201
+ return runs ? "silent" : "gone";
95202
+ await setTimeout$1(opts.versionRetryMs ?? VERSION_RETRY_MS);
94796
95203
  }
94797
- return watch(child, opts);
95204
+ }
95205
+ async function whatTheUpdateLeft(desc, found, before, result, opts) {
95206
+ const after = await versionAfterUpdate(desc, opts);
95207
+ if (after === "gone")
95208
+ return { ok: false, outcome: "gone", message: `${desc.name} no longer runs after the update; install it again.` };
95209
+ if (after === "silent")
95210
+ return { ok: true, outcome: "unverified", message: `The update ended, but ${desc.name} did not say its version. It may need a restart.` };
95211
+ if (after !== before)
95212
+ return { ...result, outcome: "updated" };
95213
+ if (opts.cacheFile)
95214
+ await rememberNotBrought(opts.cacheFile, versionSourceOf(desc, found, opts).key);
95215
+ return { ok: true, outcome: "unchanged", message: `${desc.name} is still ${before}. A new version may show after a restart.` };
94798
95216
  }
94799
95217
  async function updateArgsFor(desc, target, opts) {
94800
95218
  if (!desc.majorUpdateArgs)
@@ -94803,12 +95221,18 @@ async function updateArgsFor(desc, target, opts) {
94803
95221
  readCliVersion(target),
94804
95222
  (opts.latest ?? ((pkg) => latestAgentVersion(pkg)))(desc.npmPackage).catch(() => null)
94805
95223
  ]);
94806
- return installed && latest && majorOf(installed) < majorOf(latest) ? desc.majorUpdateArgs : desc.updateArgs;
95224
+ const canMove = installed && compareVersions(installed, desc.minimumVersion) >= 0;
95225
+ return canMove && latest && majorOf(installed) < majorOf(latest) ? desc.majorUpdateArgs : desc.updateArgs;
94807
95226
  }
94808
95227
  function majorOf(version) {
94809
95228
  return Number.parseInt(version, 10);
94810
95229
  }
94811
- function watch(child, opts) {
95230
+ function askedQuestion(text3) {
95231
+ const line = text3.split(/\r\n|\r|\n/).find((candidate) => ASKS_TO_CONFIRM.test(candidate)) ?? "";
95232
+ return line.replace(/^[^\p{L}\p{N}(]+/u, "").trim();
95233
+ }
95234
+ function watch(child, opts, runIt) {
95235
+ const limitMs = opts.silenceLimitMs ?? SILENCE_LIMIT_MS;
94812
95236
  return new Promise((resolve20) => {
94813
95237
  let settled = false;
94814
95238
  const last = { stdout: "", stderr: "" };
@@ -94816,13 +95240,22 @@ function watch(child, opts) {
94816
95240
  if (settled)
94817
95241
  return;
94818
95242
  settled = true;
95243
+ clearTimeout(silence);
94819
95244
  opts.signal?.removeEventListener("abort", stop);
94820
95245
  resolve20(result);
94821
95246
  };
94822
- const stop = () => {
95247
+ const end = (message) => {
94823
95248
  killTree$1(child, "SIGTERM");
94824
- finish({ ok: false, message: "Stopped." });
95249
+ finish({ ok: false, message });
95250
+ };
95251
+ const stop = () => end("Stopped.");
95252
+ let silence;
95253
+ const heard = () => {
95254
+ clearTimeout(silence);
95255
+ silence = setTimeout(() => end(`Stopped: nothing printed for ${Math.round(limitMs / 6e4)} minutes.`), limitMs);
95256
+ silence.unref();
94825
95257
  };
95258
+ heard();
94826
95259
  if (opts.signal?.aborted) {
94827
95260
  stop();
94828
95261
  return;
@@ -94841,6 +95274,12 @@ function watch(child, opts) {
94841
95274
  for (const stream2 of ["stdout", "stderr"]) {
94842
95275
  let pending = "";
94843
95276
  child[stream2]?.on("data", (chunk) => {
95277
+ heard();
95278
+ const text3 = (pending + chunk.toString("utf8")).replace(ANSI, "");
95279
+ if (ASKS_TO_CONFIRM.test(text3)) {
95280
+ end(`It asked to confirm, and Moxxy cannot answer: "${askedQuestion(text3)}" Run ${runIt} in a terminal.`);
95281
+ return;
95282
+ }
94844
95283
  const parts = (pending + chunk.toString("utf8")).split(/\r\n|\r|\n/);
94845
95284
  pending = parts.pop() ?? "";
94846
95285
  for (const part of parts)
@@ -94857,10 +95296,11 @@ function watch(child, opts) {
94857
95296
  });
94858
95297
  });
94859
95298
  }
94860
- var CLAUDE_CLI, CODEX_WINDOWS_BUILDS, CODEX_CLI, OPENCODE_CLI, AGENT_CLIS, PATH_FALLBACK_ENV, WINDOWS_NATIVE, WINDOWS_SHIMS, HOUR_MS2, ANSI, PERCENT;
95299
+ var CLAUDE_CLI, CODEX_WINDOWS_BUILDS, CODEX_CLI, OPENCODE_CLI, AGENT_CLIS, PATH_FALLBACK_ENV, PACKAGE_TOOLS, MISE_PATH, WINDOWS_NATIVE, WINDOWS_SHIMS, SHIM_TARGET, HOUR_MS3, SOURCE_TIMEOUT_MS, cacheChanges, UPDATER_STDIO, VERSION_TRIES, VERSION_RETRY_MS, SILENCE_LIMIT_MS, ASKS_TO_CONFIRM, ANSI, PERCENT;
94861
95300
  var init_agent_cli2 = __esm({
94862
95301
  "../agent-connection-kit/dist/agent-cli.js"() {
94863
95302
  init_cli_version();
95303
+ init_agent_versions_blocked2();
94864
95304
  CLAUDE_CLI = {
94865
95305
  name: "Claude Code",
94866
95306
  command: "claude",
@@ -94868,6 +95308,12 @@ var init_agent_cli2 = __esm({
94868
95308
  npmPackage: "@anthropic-ai/claude-code",
94869
95309
  minimumVersion: "2.1.296",
94870
95310
  updateArgs: ["update"],
95311
+ releaseChannel: {
95312
+ url: (channel) => `https://downloads.claude.ai/claude-code-releases/${encodeURIComponent(channel)}`,
95313
+ settingsFile: ".claude/settings.json",
95314
+ setting: "autoUpdatesChannel",
95315
+ fallback: "latest"
95316
+ },
94871
95317
  install: { posix: "curl -fsSL https://claude.ai/install.sh | bash", windows: "irm https://claude.ai/install.ps1 | iex" },
94872
95318
  installDirs: [".local/bin"],
94873
95319
  windowsShim: { entry: "node_modules/@anthropic-ai/claude-code/cli.js", runs: "node" }
@@ -94898,6 +95344,7 @@ var init_agent_cli2 = __esm({
94898
95344
  command: "opencode",
94899
95345
  executableEnv: "OPENCODE_EXECUTABLE",
94900
95346
  npmPackage: "@opencode/cli",
95347
+ legacyNpmPackages: ["opencode-ai"],
94901
95348
  minimumVersion: "1.19.0",
94902
95349
  updateArgs: ["upgrade"],
94903
95350
  // OpenCode 1's `upgrade` stays on 1; `--major` replaces it with OpenCode 2 the way it was installed.
@@ -94918,9 +95365,35 @@ var init_agent_cli2 = __esm({
94918
95365
  opencode: OPENCODE_CLI
94919
95366
  };
94920
95367
  PATH_FALLBACK_ENV = "MOXXY_PATH_FALLBACK";
95368
+ PACKAGE_TOOLS = [
95369
+ {
95370
+ origin: "vite-plus",
95371
+ owns: /\/(?:\.vite-plus|\.local\/share\/vite-plus|appdata\/local\/vite-plus)\/bin\//,
95372
+ command: "vp",
95373
+ args: (pkg) => ["i", "-g", pkg]
95374
+ },
95375
+ { origin: "bun", owns: /\/\.bun\/bin\//, command: "bun", args: (pkg) => ["i", "-g", `${pkg}@latest`] },
95376
+ {
95377
+ origin: "pnpm",
95378
+ owns: /\/(?:\.local\/share\/pnpm|library\/pnpm|local\/share\/pnpm|appdata\/local\/pnpm|pnpm\/global)\//,
95379
+ command: "pnpm",
95380
+ args: (pkg) => ["add", "-g", `${pkg}@latest`]
95381
+ },
95382
+ { origin: "yarn", owns: /\/(?:\.yarn|local\/yarn)\/bin\/|\/yarn\/(?:data\/)?global\/node_modules\//, command: "yarn", args: (pkg) => ["global", "add", `${pkg}@latest`] },
95383
+ { origin: "volta", owns: /\/(?:\.volta|local\/volta)\/bin\//, command: "volta", args: (pkg) => ["install", `${pkg}@latest`] }
95384
+ ];
95385
+ MISE_PATH = /\/mise\/(?:installs|shims)\//;
94921
95386
  WINDOWS_NATIVE = /* @__PURE__ */ new Set([".exe", ".com"]);
94922
95387
  WINDOWS_SHIMS = /* @__PURE__ */ new Set([".cmd", ".bat", ".ps1"]);
94923
- HOUR_MS2 = 60 * 6e4;
95388
+ SHIM_TARGET = /"%(?:~dp0|dp0%)\\?([^"]+)"/g;
95389
+ HOUR_MS3 = 60 * 6e4;
95390
+ SOURCE_TIMEOUT_MS = 2e4;
95391
+ cacheChanges = /* @__PURE__ */ new Map();
95392
+ UPDATER_STDIO = ["ignore", "pipe", "pipe"];
95393
+ VERSION_TRIES = 3;
95394
+ VERSION_RETRY_MS = 2e3;
95395
+ SILENCE_LIMIT_MS = 10 * 6e4;
95396
+ ASKS_TO_CONFIRM = /\b(?:install anyways|continue anyway|proceed)\?|\(y\/n\)|\[y\/n\]/i;
94924
95397
  ANSI = /\x1b\[[0-9;?]*[A-Za-z]/g;
94925
95398
  PERCENT = /(\d{1,3}(?:\.\d+)?)%/;
94926
95399
  }
@@ -94959,6 +95432,7 @@ var init_dist34 = __esm({
94959
95432
  init_modes3();
94960
95433
  init_cli_version();
94961
95434
  init_agent_cli2();
95435
+ init_agent_versions_blocked2();
94962
95436
  init_inbox();
94963
95437
  init_one_off_prompt();
94964
95438
  init_resume();
@@ -94987,7 +95461,10 @@ async function runAgentsCommand(argv, deps = {}) {
94987
95461
  if (action === "status") {
94988
95462
  const reports = await Promise.all(
94989
95463
  Object.entries(agents).map(
94990
- async ([connection, desc2]) => [connection, desc2, await checkAgentCli(desc2, { ...search, refresh: true }, deps.latest ? { latest: deps.latest } : {})]
95464
+ async ([connection, desc2]) => [connection, desc2, await checkAgentCli(desc2, { ...search, refresh: true }, {
95465
+ ...deps.latest ? { latest: deps.latest } : {},
95466
+ ...deps.blocked ? { blocked: deps.blocked } : {}
95467
+ })]
94991
95468
  )
94992
95469
  );
94993
95470
  if (hasBoolFlag(argv, "json")) {
@@ -95018,6 +95495,7 @@ async function runAgentsCommand(argv, deps = {}) {
95018
95495
  }
95019
95496
  const result = await runAgentCliAction(desc, action, {
95020
95497
  ...search,
95498
+ cacheFile: defaultCacheFile2(),
95021
95499
  onLine: (line) => out(`${colors.dim(line)}
95022
95500
  `)
95023
95501
  });
@@ -95039,17 +95517,19 @@ function agentNames(agents) {
95039
95517
  function describe2(desc, report2) {
95040
95518
  const app = agentCliApp(report2);
95041
95519
  const fix = app ? `part of ${app}, which updates it` : `moxxy agents update ${desc.command}`;
95520
+ const issue2 = agentCliKnownIssue(report2);
95521
+ const heldBack = agentCliHeldBack(report2);
95042
95522
  switch (report2.state) {
95043
95523
  case "missing":
95044
95524
  return `not installed \xB7 moxxy agents install ${desc.command}`;
95045
95525
  case "update-required":
95046
- return colors.yellow(`update required \u2014 Moxxy works with ${report2.minimum} or newer \xB7 ${fix}`);
95526
+ return colors.yellow(`update required \u2014 Moxxy works with ${report2.minimum} or newer \xB7 ${heldBack ?? fix}`);
95047
95527
  case "update-available":
95048
95528
  return `${report2.latest ?? "a newer version"} is out \xB7 ${fix}`;
95049
95529
  case "unknown":
95050
95530
  return colors.yellow("installed, but its version could not be read");
95051
95531
  case "current":
95052
- return colors.green("up to date");
95532
+ return issue2 ? colors.yellow(issue2) : colors.green("up to date");
95053
95533
  }
95054
95534
  }
95055
95535
  var HELP7;
@@ -98060,9 +98540,11 @@ function buildAgentCliDoctorChecks(entries, configured) {
98060
98540
  const found = `${agentName} ${report2.installed ?? ""}`.trim() + (file ? ` at ${file}` : "");
98061
98541
  const app = agentCliApp(report2);
98062
98542
  const fix = app ? `it is part of ${app}, which updates it` : `moxxy agents update ${command}`;
98543
+ const issue2 = agentCliKnownIssue(report2);
98544
+ const heldBack = agentCliHeldBack(report2);
98063
98545
  switch (report2.state) {
98064
98546
  case "current":
98065
- return { id, status: "ok", message: `${found}, the latest` };
98547
+ return issue2 ? { id, status: "warn", message: `${found}; ${issue2}` } : { id, status: "ok", message: `${found}, the latest` };
98066
98548
  case "update-available":
98067
98549
  return {
98068
98550
  id,
@@ -98073,7 +98555,7 @@ function buildAgentCliDoctorChecks(entries, configured) {
98073
98555
  return {
98074
98556
  id,
98075
98557
  status: used ? "fail" : "warn",
98076
- message: `${found} is older than ${report2.minimum}, the oldest Moxxy works with \u2014 ${fix}`
98558
+ message: `${found} is older than ${report2.minimum}, the oldest Moxxy works with \u2014 ${heldBack ?? fix}`
98077
98559
  };
98078
98560
  case "missing":
98079
98561
  return used ? { id, status: "fail", message: `${agentName} is not installed \u2014 moxxy agents install ${command}` } : { id, status: "ok", message: `${agentName} is not installed \u2014 moxxy agents install ${command} to use it` };
@@ -100877,7 +101359,7 @@ async function waitForChannelStatus(name, def) {
100877
101359
  while (Date.now() < deadline) {
100878
101360
  const status = liveChannelStatus(name);
100879
101361
  if (status && (!needsUrl || status.requestUrl)) return status;
100880
- await delay3(POLL_MS);
101362
+ await delay4(POLL_MS);
100881
101363
  }
100882
101364
  return liveChannelStatus(name);
100883
101365
  }
@@ -100885,7 +101367,7 @@ async function waitForChannelGone(name) {
100885
101367
  const deadline = Date.now() + STOP_GRACE_MS2;
100886
101368
  while (Date.now() < deadline) {
100887
101369
  if (!liveChannelStatus(name)) return true;
100888
- await delay3(POLL_MS);
101370
+ await delay4(POLL_MS);
100889
101371
  }
100890
101372
  return liveChannelStatus(name) === null;
100891
101373
  }
@@ -100928,7 +101410,7 @@ function formatSubcommandHelp(channelName, subName, sub) {
100928
101410
  lines.push(` ${colors.dim(sub.description)}`);
100929
101411
  return lines.join("\n") + "\n";
100930
101412
  }
100931
- var HELP22, START_TIMEOUT_MS2, STOP_GRACE_MS2, POLL_MS, delay3;
101413
+ var HELP22, START_TIMEOUT_MS2, STOP_GRACE_MS2, POLL_MS, delay4;
100932
101414
  var init_channels2 = __esm({
100933
101415
  async "src/commands/channels.ts"() {
100934
101416
  await init_argv_helpers();
@@ -100958,7 +101440,7 @@ var init_channels2 = __esm({
100958
101440
  START_TIMEOUT_MS2 = 15e3;
100959
101441
  STOP_GRACE_MS2 = 4e3;
100960
101442
  POLL_MS = 300;
100961
- delay3 = (ms) => new Promise((r2) => setTimeout(r2, ms));
101443
+ delay4 = (ms) => new Promise((r2) => setTimeout(r2, ms));
100962
101444
  }
100963
101445
  });
100964
101446
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxxy/cli",
3
- "version": "0.48.2",
3
+ "version": "0.48.3",
4
4
  "description": "moxxy command-line agent: TUI, one-shot prompts, setup, services, and API-key or installed-CLI subscription providers.",
5
5
  "keywords": [
6
6
  "moxxy",
@@ -49,7 +49,7 @@
49
49
  "dependencies": {
50
50
  "undici": "^8.12.2",
51
51
  "zod": "^4.6.7",
52
- "@moxxy/sdk": "0.48.2"
52
+ "@moxxy/sdk": "0.48.3"
53
53
  },
54
54
  "optionalDependencies": {
55
55
  "@napi-rs/keyring": "^2.1.2"