@moxxy/cli 0.37.1 → 0.38.0

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/bin.js CHANGED
@@ -5,7 +5,7 @@ import * as fs35 from 'fs';
5
5
  import fs35__default, { promises, readFileSync, existsSync, mkdirSync, writeFileSync, rmSync, openSync, closeSync, unlinkSync, renameSync, statSync, readdirSync, realpathSync, constants as constants$1, lstatSync, watch } from 'fs';
6
6
  import * as path3 from 'path';
7
7
  import path3__default, { join, dirname, resolve, relative, isAbsolute, posix, sep } from 'path';
8
- import { ensurePrivateDir, moxxyHome, pruneStaleTempFiles, moxxyPath, hasProxy, installEgressProxy, readProxyEnv, writeFileAtomic, ensurePrivateFile, resolveChannelToken, rotateChannelToken, liveChannelStatus, spawnDedicatedChannel, stopDedicatedChannel, clearChannelStatus, MOXXY_WS_SUBPROTOCOL, bearerTokenMatches, PRIVATE_FILE_MODE, bearerGuard, tokenFromWsProtocolHeader, resolveOsPrincipal, redactProxyUrl, listLiveChannelStatuses, CrossProcessFireLock, writeChannelStatus, writeFileAtomicSync, readRequestBody } from '@moxxy/sdk/server';
8
+ import { ensurePrivateDir, moxxyHome, pruneStaleTempFiles, moxxyPath, hasProxy, installEgressProxy, readProxyEnv, writeFileAtomic, ensurePrivateFile, resolveChannelToken, rotateChannelToken, liveChannelStatus, spawnDedicatedChannel, stopDedicatedChannel, clearChannelStatus, MOXXY_WS_SUBPROTOCOL, bearerTokenMatches, PRIVATE_FILE_MODE, bearerGuard, tokenFromWsProtocolHeader, resolveOsPrincipal, redactProxyUrl, listLiveChannelStatuses, writeSignedNetworkCacheAtomic, CrossProcessFireLock, writeChannelStatus, writeBoundedNetworkCacheAtomicSync, writeBoundedDataCacheAtomic, readRequestBody } from '@moxxy/sdk/server';
9
9
  import { spawn, execFile, spawnSync } from 'child_process';
10
10
  import { fileURLToPath, pathToFileURL } from 'url';
11
11
  import { MoxxyError, createMutex, defineMode, definePlugin, defineChannel, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, defineTool, defineCommand, defineEmbedder, asPluginId, runReactLoop, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, asTurnId, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, denyByDefaultResolver, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, summarizeWithProvider, toolResultBytes, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, computeElisionState, toolResultStubbed, toolResultStub, conversationalStubbed, conversationalStub, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, moxxyPackageSchema, auditActionOf, verifyEd25519, defineSecretProvider, redactSecretText, encodeLoginPrompt, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, asToolCallId, parseFrontmatterFile, createJsonFileStore, evaluateToolRule, asEventId } from '@moxxy/sdk';
@@ -13221,25 +13221,26 @@ function hasPath(obj, segments) {
13221
13221
  }
13222
13222
  return true;
13223
13223
  }
13224
- function deletePath(obj, segments) {
13224
+ function withoutPath(obj, segments) {
13225
13225
  const [head2, ...rest] = segments;
13226
13226
  if (head2 === void 0)
13227
- return;
13228
- if (rest.length === 0) {
13229
- delete obj[head2];
13230
- return;
13231
- }
13232
- const child = obj[head2];
13233
- if (child === null || typeof child !== "object" || Array.isArray(child))
13234
- return;
13235
- deletePath(child, rest);
13236
- if (Object.keys(child).length === 0)
13237
- delete obj[head2];
13227
+ return { ...obj };
13228
+ return Object.fromEntries(Object.entries(obj).flatMap(([key, value2]) => {
13229
+ if (key !== head2)
13230
+ return [[key, value2]];
13231
+ if (rest.length === 0)
13232
+ return [];
13233
+ if (value2 === null || typeof value2 !== "object" || Array.isArray(value2)) {
13234
+ return [[key, value2]];
13235
+ }
13236
+ const child = withoutPath(value2, rest);
13237
+ return Object.keys(child).length === 0 ? [] : [[key, child]];
13238
+ }));
13238
13239
  }
13239
13240
  function stripLockedKeys(config, locked, scope) {
13240
13241
  if (locked.length === 0)
13241
13242
  return { config, overrides: [] };
13242
- const clone = structuredClone(config);
13243
+ let clone = structuredClone(config);
13243
13244
  const overrides = [];
13244
13245
  for (const key of locked) {
13245
13246
  const segments = key.split(".").filter((s) => s.length > 0);
@@ -13248,7 +13249,7 @@ function stripLockedKeys(config, locked, scope) {
13248
13249
  if (!hasPath(clone, segments))
13249
13250
  continue;
13250
13251
  overrides.push({ key, scope });
13251
- deletePath(clone, segments);
13252
+ clone = withoutPath(clone, segments);
13252
13253
  }
13253
13254
  return { config: clone, overrides };
13254
13255
  }
@@ -21279,15 +21280,16 @@ async function loadPolicyBundles(refs, opts = {}) {
21279
21280
  for (const ref of refs) {
21280
21281
  const cachePath = cacheFileFor(cacheDir, ref.url);
21281
21282
  const remote = await fetchBundle(ref, opts);
21282
- let bundle = remote.bundle;
21283
+ let bundle;
21283
21284
  let from = "remote";
21284
21285
  let staleReason;
21285
- if (bundle) {
21286
- await writeCache(cachePath, remote.bytes, remote.sig);
21286
+ if (remote.kind === "verified") {
21287
+ bundle = remote.bundle;
21288
+ await writeSignedNetworkCacheAtomic(cachePath, remote.bytes, remote.sig, ref.publicKey).catch(() => void 0);
21287
21289
  } else {
21288
21290
  const cached = await readVerifiedCache(cachePath, ref);
21289
21291
  if (!cached)
21290
- throw new PolicyLoadError(ref.url, remote.reason ?? "unavailable");
21292
+ throw new PolicyLoadError(ref.url, remote.reason);
21291
21293
  bundle = cached;
21292
21294
  from = "cache";
21293
21295
  staleReason = remote.reason;
@@ -21307,7 +21309,7 @@ async function loadPolicyBundles(refs, opts = {}) {
21307
21309
  async function fetchBundle(ref, opts) {
21308
21310
  const fetchImpl = opts.fetch ?? globalThis.fetch;
21309
21311
  if (!fetchImpl)
21310
- return { reason: "no fetch implementation available" };
21312
+ return { kind: "unavailable", reason: "no fetch implementation available" };
21311
21313
  const deadline = AbortSignal.timeout(FETCH_TIMEOUT_MS);
21312
21314
  let bytes;
21313
21315
  let sig;
@@ -21317,31 +21319,30 @@ async function fetchBundle(ref, opts) {
21317
21319
  fetchImpl(`${ref.url}.sig`, { signal: deadline })
21318
21320
  ]);
21319
21321
  if (!bodyRes.ok || !sigRes.ok) {
21320
- return { reason: `http ${bodyRes.status} / sig ${sigRes.status}` };
21322
+ return { kind: "unavailable", reason: `http ${bodyRes.status} / sig ${sigRes.status}` };
21321
21323
  }
21322
21324
  bytes = new Uint8Array(await bodyRes.arrayBuffer());
21323
21325
  sig = (await sigRes.text()).trim();
21324
21326
  } catch (err) {
21325
- if (deadline.aborted)
21326
- return { reason: `fetch exceeded ${FETCH_TIMEOUT_MS}ms` };
21327
- return { reason: err instanceof Error ? err.message : String(err) };
21327
+ if (deadline.aborted) {
21328
+ return { kind: "unavailable", reason: `fetch exceeded ${FETCH_TIMEOUT_MS}ms` };
21329
+ }
21330
+ return { kind: "unavailable", reason: err instanceof Error ? err.message : String(err) };
21328
21331
  }
21329
21332
  const result = verifyPolicyBundle(bytes, sig, ref.publicKey, ref.id);
21330
21333
  if (!result.ok || !result.bundle) {
21331
21334
  throw new PolicyLoadError(ref.url, `${result.failure}: ${result.detail ?? ""}`.trim());
21332
21335
  }
21333
- return { bundle: result.bundle, bytes, sig };
21334
- }
21335
- async function writeCache(cachePath, bytes, sig) {
21336
- const payload2 = JSON.stringify({ bytes: Buffer.from(bytes).toString("base64"), sig });
21337
- await promises.writeFile(cachePath, payload2, { mode: 384 }).catch(() => void 0);
21336
+ return { kind: "verified", bundle: result.bundle, bytes, sig };
21338
21337
  }
21339
21338
  async function readVerifiedCache(cachePath, ref) {
21340
21339
  try {
21341
21340
  const raw = JSON.parse(await promises.readFile(cachePath, "utf8"));
21342
- if (typeof raw.bytes !== "string" || typeof raw.sig !== "string")
21341
+ const payloadB64 = raw.payloadB64 ?? raw.bytes;
21342
+ const signature = raw.signature ?? raw.sig;
21343
+ if (typeof payloadB64 !== "string" || typeof signature !== "string")
21343
21344
  return void 0;
21344
- const result = verifyPolicyBundle(new Uint8Array(Buffer.from(raw.bytes, "base64")), raw.sig, ref.publicKey, ref.id);
21345
+ const result = verifyPolicyBundle(new Uint8Array(Buffer.from(payloadB64, "base64")), signature, ref.publicKey, ref.id);
21345
21346
  return result.ok ? result.bundle : void 0;
21346
21347
  } catch {
21347
21348
  return void 0;
@@ -22929,12 +22930,9 @@ async function fetchSignedRegistry(opts = {}) {
22929
22930
  return fallback("invalid-schema", "signed index failed schema validation");
22930
22931
  }
22931
22932
  try {
22932
- const cacheBody = {
22933
- fetchedAtMs: now(),
22934
- indexB64: Buffer.from(bytes).toString("base64"),
22935
- sig
22936
- };
22937
- await writeFileAtomic(cachePath, JSON.stringify(cacheBody));
22933
+ await writeSignedNetworkCacheAtomic(cachePath, bytes, sig, publicKeyPem, {
22934
+ writtenAtMs: now()
22935
+ });
22938
22936
  } catch {
22939
22937
  }
22940
22938
  return { source: "remote", entries: index.entries };
@@ -22962,13 +22960,13 @@ async function readVerifiedCache2(cachePath, publicKeyPem) {
22962
22960
  const parsed = cacheFileSchema.safeParse(raw);
22963
22961
  if (!parsed.success)
22964
22962
  return void 0;
22965
- const bytes = Buffer.from(parsed.data.indexB64, "base64");
22966
- if (!verifyRegistryIndex(bytes, parsed.data.sig, publicKeyPem))
22963
+ const bytes = Buffer.from(parsed.data.payloadB64, "base64");
22964
+ if (!verifyRegistryIndex(bytes, parsed.data.signature, publicKeyPem))
22967
22965
  return void 0;
22968
22966
  const index = parseRegistryIndex(bytes);
22969
22967
  if (!index)
22970
22968
  return void 0;
22971
- return { fetchedAtMs: parsed.data.fetchedAtMs, index };
22969
+ return { fetchedAtMs: parsed.data.writtenAtMs, index };
22972
22970
  }
22973
22971
  async function resolveInstallSource(idOrSpec, opts = {}) {
22974
22972
  const registry = await fetchSignedRegistry(opts);
@@ -23098,11 +23096,24 @@ var init_registry2 = __esm({
23098
23096
  // over entry-by-entry.
23099
23097
  entries: z$1.array(registryEntrySchema).max(5e3)
23100
23098
  });
23101
- cacheFileSchema = z$1.object({
23102
- fetchedAtMs: z$1.number().int().nonnegative(),
23103
- indexB64: z$1.string().min(1),
23104
- sig: z$1.string().min(1)
23105
- });
23099
+ cacheFileSchema = z$1.union([
23100
+ z$1.object({
23101
+ writtenAtMs: z$1.number().int().nonnegative(),
23102
+ payloadB64: z$1.string().min(1),
23103
+ signature: z$1.string().min(1)
23104
+ }),
23105
+ // Read the pre-0.38 cache shape during a rolling upgrade. New writes always
23106
+ // use the shared signed-cache envelope above.
23107
+ z$1.object({
23108
+ fetchedAtMs: z$1.number().int().nonnegative(),
23109
+ indexB64: z$1.string().min(1),
23110
+ sig: z$1.string().min(1)
23111
+ }).transform((legacy) => ({
23112
+ writtenAtMs: legacy.fetchedAtMs,
23113
+ payloadB64: legacy.indexB64,
23114
+ signature: legacy.sig
23115
+ }))
23116
+ ]);
23106
23117
  NET_RANK = { none: 0, allowlist: 1, any: 2 };
23107
23118
  }
23108
23119
  });
@@ -25579,10 +25590,11 @@ function defaultWebhookQueueDir() {
25579
25590
  function safeId(id) {
25580
25591
  return id.replace(/[^A-Za-z0-9._-]/g, "_");
25581
25592
  }
25582
- var WebhookDeliveryQueue;
25593
+ var MAX_QUEUED_DELIVERY_BYTES, WebhookDeliveryQueue;
25583
25594
  var init_queue = __esm({
25584
25595
  "../plugin-webhooks/dist/queue.js"() {
25585
25596
  init_node();
25597
+ MAX_QUEUED_DELIVERY_BYTES = 8 * 1024 * 1024;
25586
25598
  WebhookDeliveryQueue = class {
25587
25599
  dir;
25588
25600
  constructor(dir = defaultWebhookQueueDir()) {
@@ -25600,7 +25612,7 @@ var init_queue = __esm({
25600
25612
  deliveryId: rec.deliveryId,
25601
25613
  enqueuedAt: rec.enqueuedAt ?? Date.now()
25602
25614
  };
25603
- await writeFileAtomic(path3__default.join(this.dir, `${id}.json`), JSON.stringify(record));
25615
+ await writeBoundedDataCacheAtomic(path3__default.join(this.dir, `${id}.json`), JSON.stringify(record), { maxBytes: MAX_QUEUED_DELIVERY_BYTES });
25604
25616
  return id;
25605
25617
  }
25606
25618
  /** Every queued delivery for `ownerSessionId`, oldest first. Corrupt records
@@ -83574,12 +83586,7 @@ var init_BootShell = __esm({
83574
83586
  if (!session || showWelcome) {
83575
83587
  return (0, import_jsx_runtime41.jsxs)(Box_default, { flexDirection: "column", children: [(0, import_jsx_runtime41.jsx)(BootScreen, { events: bootEvents, startedAt, ...session ? { workspace: session.cwd } : {}, ...bootError ? { error: bootError } : {}, welcome: firstRun }), session ? (0, import_jsx_runtime41.jsx)(BootInputArea, { session, ready: bootError == null, bootError, onSubmit: (text2) => setInitialPrompt(text2) }) : (0, import_jsx_runtime41.jsx)(DisabledBootInput, { placeholder: bootError ? "Start failed \u2014 run `moxxy doctor --check-keys`" : "Initializing\u2026" })] });
83576
83588
  }
83577
- return (
83578
- // Key by session id so switching fully re-mounts the view — every
83579
- // session-keyed hook (event stream, turn runner, permission queue) resets to
83580
- // the new session instead of carrying the prior one's state across.
83581
- (0, import_jsx_runtime41.jsx)(SessionView, { session, registerInteractiveResolver, ...getVault ? { getVault } : {}, ...getChannels ? { getChannels } : {}, ...initialPrompt ? { initialPrompt } : {}, ...switchNotice ? { initialNotice: switchNotice } : {}, ...model ? { model } : {}, ...version ? { version } : {}, ...updateAvailable ? { updateAvailable } : {}, canSwitchSession: Boolean(switchSession), onSwitchSession: handleSwitchSession }, session.id)
83582
- );
83589
+ return (0, import_jsx_runtime41.jsx)(SessionView, { session, registerInteractiveResolver, ...getVault ? { getVault } : {}, ...getChannels ? { getChannels } : {}, ...initialPrompt ? { initialPrompt } : {}, ...switchNotice ? { initialNotice: switchNotice } : {}, ...model ? { model } : {}, ...version ? { version } : {}, ...updateAvailable ? { updateAvailable } : {}, canSwitchSession: Boolean(switchSession), onSwitchSession: handleSwitchSession }, session.id);
83583
83590
  };
83584
83591
  BootInputArea = ({ session, ready, bootError, onSubmit }) => {
83585
83592
  const [systemNotice, setSystemNotice] = (0, import_react70.useState)(null);
@@ -84220,6 +84227,7 @@ var init_focus_layout = __esm({
84220
84227
  "../desktop-ipc-contract/dist/focus-layout.js"() {
84221
84228
  FOCUS_PET_LAYOUT = Object.freeze({
84222
84229
  collapsedWidth: 84,
84230
+ voiceActiveCollapsedWidth: 136,
84223
84231
  collapsedHeight: 104,
84224
84232
  activeAvatarWidth: 72,
84225
84233
  activeHeight: 90,
@@ -84251,6 +84259,7 @@ var init_remote = __esm({
84251
84259
  "desks.setActive",
84252
84260
  // The conversation itself.
84253
84261
  "session.info",
84262
+ "session.activeTurn",
84254
84263
  "session.runTurn",
84255
84264
  "session.abortTurn",
84256
84265
  "session.setProvider",
@@ -84468,6 +84477,7 @@ var init_validation = __esm({
84468
84477
  workspaceId: optionalWorkspace,
84469
84478
  prompt: z.string().max(1e6),
84470
84479
  model: z.string().min(1).max(256).optional(),
84480
+ visibility: z.enum(["foreground", "background"]).optional(),
84471
84481
  attachments: z.array(z.object({
84472
84482
  path: z.string().min(1).max(4096),
84473
84483
  name: z.string().min(1).max(1024)
@@ -84503,6 +84513,7 @@ var init_validation = __esm({
84503
84513
  }
84504
84514
  }).optional()
84505
84515
  }),
84516
+ "session.activeTurn": z.object({ workspaceId: optionalWorkspace }).optional(),
84506
84517
  "session.previewAttachment": z.object({
84507
84518
  workspaceId: optionalWorkspace,
84508
84519
  path: z.string().min(1).max(4096),
@@ -84696,7 +84707,41 @@ var init_validation = __esm({
84696
84707
  optionId: z.string().max(128).optional(),
84697
84708
  text: z.string().max(1e4).optional()
84698
84709
  }).strict()
84699
- }).strict()
84710
+ }).strict(),
84711
+ // Agent browser. `webContentsId` selects a live Electron view and `url` is
84712
+ // navigated for real, so both are validated at the boundary rather than
84713
+ // trusted from the renderer.
84714
+ "browser.registerTab": z.object({
84715
+ webContentsId: z.number().int().nonnegative(),
84716
+ requestId: z.string().min(1).max(64).optional()
84717
+ }),
84718
+ "browser.releaseTab": z.object({ tabId: z.string().min(1).max(64) }),
84719
+ "browser.selectTab": z.object({ tabId: z.string().min(1).max(64) }),
84720
+ "browser.navigate": z.object({
84721
+ url: z.string().url().refine((u) => /^https?:\/\//i.test(u), "only http(s) URLs allowed"),
84722
+ tabId: z.string().min(1).max(64).optional()
84723
+ }),
84724
+ "browser.capture": z.object({
84725
+ tabId: z.string().min(1).max(64).optional(),
84726
+ // Bounded: a rectangle from a drag on screen, not an arbitrary region of an
84727
+ // arbitrarily large page. Positive extents only — a zero-width crop is a
84728
+ // stray click, and the host would refuse it anyway.
84729
+ clip: z.object({
84730
+ x: z.number().min(0).max(1e5),
84731
+ y: z.number().min(0).max(1e5),
84732
+ width: z.number().positive().max(1e5),
84733
+ height: z.number().positive().max(1e5)
84734
+ }).optional()
84735
+ }),
84736
+ "browser.confirmFocus": z.object({ requestId: z.string().min(1).max(64) }),
84737
+ "browser.history": z.object({
84738
+ action: z.enum(["back", "forward", "reload"]),
84739
+ tabId: z.string().min(1).max(64).optional()
84740
+ }),
84741
+ "browser.resolveHandoff": z.object({
84742
+ requestId: z.string().min(1).max(64),
84743
+ completed: z.boolean()
84744
+ })
84700
84745
  };
84701
84746
  }
84702
84747
  });
@@ -85374,9 +85419,12 @@ var init_single_session_host = __esm({
85374
85419
  return renamed;
85375
85420
  });
85376
85421
  this.bus.handle("session.info", async () => this.session.getInfo());
85422
+ this.bus.handle("session.activeTurn", async (args) => ({
85423
+ turnId: this.activeForegroundTurnId(args?.workspaceId ?? this.selectedSessionId)
85424
+ }));
85377
85425
  this.bus.handle("session.runTurn", async (args) => this.runTurn(args));
85378
85426
  this.bus.handle("session.abortTurn", async ({ turnId }) => {
85379
- this.turns.get(turnId)?.abort();
85427
+ this.turns.get(turnId)?.controller.abort();
85380
85428
  });
85381
85429
  this.bus.handle("session.setAutoApprove", async ({ enabled }) => {
85382
85430
  this.autoApprove = enabled;
@@ -85507,8 +85555,8 @@ var init_single_session_host = __esm({
85507
85555
  /** Abort all in-flight turns and deny + clear all parked asks (clearing their
85508
85556
  * timeout timers). Shared by `dispose()` and `onAllClientsDisconnected()`. */
85509
85557
  abortAndDrain() {
85510
- for (const controller of this.turns.values())
85511
- controller.abort();
85558
+ for (const turn of this.turns.values())
85559
+ turn.controller.abort();
85512
85560
  this.turns.clear();
85513
85561
  for (const { resolve: resolve21, timer } of this.pendingAsks.values()) {
85514
85562
  if (timer)
@@ -85580,8 +85628,8 @@ var init_single_session_host = __esm({
85580
85628
  this.bus.broadcast("connection.changed", { workspaceId: id, phase: this.snapshot(id).phase });
85581
85629
  }
85582
85630
  async resetCurrentSession() {
85583
- for (const controller of this.turns.values())
85584
- controller.abort();
85631
+ for (const turn of this.turns.values())
85632
+ turn.controller.abort();
85585
85633
  this.autoApprove = false;
85586
85634
  if (this.session.reset)
85587
85635
  await this.session.reset();
@@ -85593,7 +85641,11 @@ var init_single_session_host = __esm({
85593
85641
  await this.selectRuntimeTarget(targetWorkspaceId);
85594
85642
  const turnId = randomUUID();
85595
85643
  const controller = new AbortController();
85596
- this.turns.set(turnId, controller);
85644
+ this.turns.set(turnId, {
85645
+ controller,
85646
+ visibility: args.visibility ?? "foreground",
85647
+ workspaceId: targetWorkspaceId
85648
+ });
85597
85649
  void (async () => {
85598
85650
  let error = null;
85599
85651
  try {
@@ -85615,6 +85667,14 @@ var init_single_session_host = __esm({
85615
85667
  });
85616
85668
  return { turnId };
85617
85669
  }
85670
+ activeForegroundTurnId(workspaceId) {
85671
+ let active2 = null;
85672
+ for (const [turnId, turn] of this.turns) {
85673
+ if (turn.visibility === "foreground" && turn.workspaceId === workspaceId)
85674
+ active2 = turnId;
85675
+ }
85676
+ return active2;
85677
+ }
85618
85678
  async selectRuntimeTarget(sessionId) {
85619
85679
  if (sessionId === this.selectedSessionId)
85620
85680
  return;
@@ -98930,6 +98990,14 @@ var init_client_mode = __esm({
98930
98990
  });
98931
98991
 
98932
98992
  // src/update/registry.ts
98993
+ function normalizeStableSemver(value2) {
98994
+ if (typeof value2 !== "string") return null;
98995
+ const match = STABLE_SEMVER_RE.exec(value2);
98996
+ if (!match) return null;
98997
+ const [, major, minor, patch] = match;
98998
+ if (major === void 0 || minor === void 0 || patch === void 0) return null;
98999
+ return `${Number(major)}.${Number(minor)}.${Number(patch)}`;
99000
+ }
98933
99001
  async function fetchLatest(pkg = DEFAULT_PKG, opts = {}) {
98934
99002
  const fetchImpl = opts.fetchImpl ?? fetch;
98935
99003
  const url = `${REGISTRY}/${encodeURIComponent(pkg)}/latest`;
@@ -98942,19 +99010,20 @@ async function fetchLatest(pkg = DEFAULT_PKG, opts = {}) {
98942
99010
  });
98943
99011
  if (!res.ok) return null;
98944
99012
  const json = await res.json();
98945
- return typeof json.version === "string" ? json.version : null;
99013
+ return normalizeStableSemver(json.version);
98946
99014
  } catch {
98947
99015
  return null;
98948
99016
  } finally {
98949
99017
  clearTimeout(timer);
98950
99018
  }
98951
99019
  }
98952
- var REGISTRY, DEFAULT_PKG, DEFAULT_TIMEOUT_MS;
99020
+ var REGISTRY, DEFAULT_PKG, DEFAULT_TIMEOUT_MS, STABLE_SEMVER_RE;
98953
99021
  var init_registry4 = __esm({
98954
99022
  "src/update/registry.ts"() {
98955
99023
  REGISTRY = "https://registry.npmjs.org";
98956
99024
  DEFAULT_PKG = "@moxxy/cli";
98957
99025
  DEFAULT_TIMEOUT_MS = 4e3;
99026
+ STABLE_SEMVER_RE = /^(0|[1-9]\d{0,8})\.(0|[1-9]\d{0,8})\.(0|[1-9]\d{0,8})$/;
98958
99027
  }
98959
99028
  });
98960
99029
  function defaultCacheFile() {
@@ -98987,9 +99056,11 @@ function readCache(file) {
98987
99056
  }
98988
99057
  return null;
98989
99058
  }
98990
- function writeCache2(file, value2) {
99059
+ function writeCache(file, value2) {
98991
99060
  try {
98992
- writeFileAtomicSync(file, JSON.stringify(value2, null, 2));
99061
+ writeBoundedNetworkCacheAtomicSync(file, JSON.stringify(value2, null, 2), {
99062
+ maxBytes: MAX_UPDATE_CACHE_BYTES
99063
+ });
98993
99064
  } catch {
98994
99065
  }
98995
99066
  }
@@ -99004,7 +99075,7 @@ function readCachedCheck(current, opts = {}) {
99004
99075
  async function refreshCheck(current, opts = {}) {
99005
99076
  const latest = await fetchLatest(PKG, opts);
99006
99077
  if (latest) {
99007
- writeCache2(opts.cacheFile ?? defaultCacheFile(), {
99078
+ writeCache(opts.cacheFile ?? defaultCacheFile(), {
99008
99079
  checkedAt: opts.now ?? Date.now(),
99009
99080
  latest
99010
99081
  });
@@ -99024,11 +99095,12 @@ async function checkForCliUpdate(current, opts = {}) {
99024
99095
  const refreshed = await refreshCheck(current, { ...opts, cacheFile: file, now });
99025
99096
  return refreshed ?? shape(current, readCache(file)?.latest ?? null);
99026
99097
  }
99027
- var CACHE_TTL_MS2, PKG;
99098
+ var CACHE_TTL_MS2, MAX_UPDATE_CACHE_BYTES, PKG;
99028
99099
  var init_check = __esm({
99029
99100
  "src/update/check.ts"() {
99030
99101
  init_registry4();
99031
99102
  CACHE_TTL_MS2 = 12 * 60 * 60 * 1e3;
99103
+ MAX_UPDATE_CACHE_BYTES = 1024;
99032
99104
  PKG = "@moxxy/cli";
99033
99105
  }
99034
99106
  });
@@ -1,32 +1,97 @@
1
1
  ---
2
2
  name: browser
3
- description: Open an in-window browser the user can watch, then navigate, click, and screenshot it for them.
4
- triggers: ["open the browser", "in the browser", "go to this site", "navigate to", "show me the page", "screenshot the page", "click the button on", "fill the form on", "browse to"]
5
- allowed-tools: [browser_session, web_fetch]
3
+ description: Drive the in-window browser the user is watching — read a page as an accessibility tree, click and type by uid, manage tabs, and hand over when a page needs a person.
4
+ triggers: ["open the browser", "in the browser", "go to this site", "navigate to", "show me the page", "screenshot the page", "click the button on", "fill the form on", "browse to", "search for", "on the website", "log in to", "sign in to", "book a", "order a", "design a"]
5
+ allowed-tools: [browser_snapshot, browser_click, browser_type, browser_key, browser_batch, browser_navigate, browser_tabs, browser_capture, browser_history, browser_await_human, browser_session, web_fetch]
6
6
  ---
7
7
 
8
- # In-window browser
8
+ # The in-window browser
9
9
 
10
- The desktop has a **Browser** pane that shows a live view of the SAME browser
11
- your `browser_session` tool drives. When you navigate or click via
12
- `browser_session`, the user sees it happen in that pane — and they can take over
13
- (click, type, scroll, change the URL) on the same page.
10
+ The desktop has a **Browser** pane showing a real Chromium view. It is the same
11
+ page you drive — not a picture of one — so the user watches you work and can take
12
+ over on the spot. It carries their signed-in profile, which is why you must never
13
+ treat it as a throwaway browser.
14
14
 
15
- ## When to use it
15
+ **Use these tools, not the computer.** Do not reach for macOS control, a
16
+ screenshot of the screen, or any other browser to visit a web page. This browser
17
+ is the one the user is looking at; anything else acts somewhere they cannot see.
16
18
 
17
- - The user asks you to open, browse, or act on a web page they want to watch.
18
- - You need to see a JS-heavy/interactive page (not just fetch HTML) — use
19
- `browser_session` (`goto`, `click`, `fill`, `screenshot`). For a plain GET,
20
- `web_fetch` is lighter.
21
- - You want to show the user a result visually rather than pasting text.
19
+ ## How to read a page
22
20
 
23
- ## How to use it well
21
+ `browser_snapshot` gives you the page as an accessibility tree — every element
22
+ that can be acted on, each with a `[uid]`. That is the form you act on: you name
23
+ a uid, not a CSS selector and not a coordinate.
24
24
 
25
- - Drive the page with `browser_session`; the Browser pane reflects it live, so
26
- you don't need to narrate every pixel — just say what you're doing.
27
- - Take a `screenshot` when a visual check matters (did the page load, did the
28
- form submit) or when the user asks to see it.
29
- - Navigation is restricted to public http(s) origins (loopback / private /
30
- metadata addresses are blocked); don't try to reach internal hosts.
31
- - The user and you share one page — if they've navigated somewhere, read the
32
- current state (`url`, `text`, `screenshot`) before acting.
25
+ - Read before acting, and again after anything that changes the page.
26
+ - After the first read of a tab you get **only what changed** since it. A uid
27
+ keeps meaning the same element, so everything not listed is still as you last
28
+ saw it. Ask for `full: true` when you have lost your bearings — it costs far
29
+ more, so not by default.
30
+ - After a navigation the uids are gone with the page they described, and the next
31
+ read is a whole tree again.
32
+ - If the answer is "unchanged since your last snapshot", the page really has not
33
+ moved. Do something, then look again; reading twice in a row tells you nothing
34
+ and is not free.
35
+
36
+ ## How to act
37
+
38
+ - `browser_click` — press something, by uid.
39
+ - `browser_type` — put text into a field, by uid.
40
+ - `browser_key` — the things a click and a string cannot do: `Enter` to submit,
41
+ `Escape` to dismiss, `Tab` to move on, and `Meta+a` then `Backspace` to empty a
42
+ field that already has something in it. The key lands wherever the page has
43
+ focus, so click the field first.
44
+ - `browser_navigate` — go to a URL. Public http(s) only; internal hosts are
45
+ refused.
46
+ - `browser_history` — back, forward, reload.
47
+
48
+ Every one of these takes a `tab_id`. Pass the one the snapshot gave you; omit it
49
+ only when you mean "whatever tab is in front".
50
+
51
+ ## Doing several things at once
52
+
53
+ `browser_batch` runs a sequence and reads the page **once**, at the end. Reading
54
+ a large page costs thousands of tokens, so filling a form as five separate calls
55
+ pays for five reads of it. Whenever you already know the next few steps — fill
56
+ these fields, press Enter, then look — put them in one batch.
57
+
58
+ Steps stop at the first failure, so a sequence never carries on against a page
59
+ that did not do what you expected, and the error names which step it was. One
60
+ approval covers the whole thing, and it shows every step.
61
+
62
+ ## Tabs
63
+
64
+ `browser_tabs` lists, opens, switches and closes them. Every snapshot already
65
+ names the open tabs, so you never have to ask which page you are on. The tab you
66
+ are working in is yours — the user switching tabs in the pane does not move your
67
+ aim.
68
+
69
+ ## When the page wants a person
70
+
71
+ A cookie banner, a CAPTCHA, a sign-in form: the snapshot says so under
72
+ **Needs you**. Do not click through any of them.
73
+
74
+ - The consent is the user's to give. Do not accept or reject it for them.
75
+ - The CAPTCHA is theirs to solve. Do not try, and do not look for a way around it.
76
+ - The password is theirs to type. Never type one, and **never ask them to tell
77
+ you a credential** — they enter it themselves.
78
+
79
+ Call `browser_await_human` with a plain sentence saying what the page wants. You
80
+ stop reading the page while they deal with it. Afterwards, take a fresh snapshot
81
+ and confirm from the page itself that it worked — "I clicked Done" is not
82
+ evidence of anything.
83
+
84
+ ## Seeing it
85
+
86
+ `browser_capture` takes a picture, and cropping to a uid is far cheaper than a
87
+ whole viewport. Reach for it when the accessibility tree is empty where something
88
+ is clearly visible — a `<canvas>` app, a chart, a rendered document — not as a
89
+ first look.
90
+
91
+ ## The escape hatch
92
+
93
+ `browser_session` still drives the same page by CSS selector and can run an
94
+ expression in it. Use it when the accessibility tree genuinely does not describe
95
+ what you need. It is below the tools above, not beside them.
96
+
97
+ For a plain GET with no page to watch, `web_fetch` is lighter than all of this.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxxy/cli",
3
- "version": "0.37.1",
3
+ "version": "0.38.0",
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": "^6.28.0",
51
51
  "zod": "^3.25.76",
52
- "@moxxy/sdk": "0.37.1"
52
+ "@moxxy/sdk": "0.38.0"
53
53
  },
54
54
  "optionalDependencies": {
55
55
  "@napi-rs/keyring": "^1.3.0"
@@ -63,7 +63,7 @@
63
63
  "react": "^18.3.0",
64
64
  "tsup": "^8.0.0",
65
65
  "tsx": "^4.23.12",
66
- "typescript": "^5.7.3",
66
+ "typescript": "^6.0.3",
67
67
  "vitest": "^3.2.6"
68
68
  },
69
69
  "scripts": {