@moxxy/cli 0.42.0 → 0.43.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
@@ -8,9 +8,7 @@ import path3__default, { join, dirname, resolve, relative, isAbsolute, posix, se
8
8
  import { utf8Locale, ensurePrivateDir, moxxyHome, pruneStaleTempFiles, moxxyPath, hasProxy, installEgressProxy, readProxyEnv, writeFileAtomic, ensurePrivateFile, resolveChannelToken, rotateChannelToken, liveChannelStatus, spawnDedicatedChannel, stopDedicatedChannel, clearChannelStatus, MOXXY_WS_SUBPROTOCOL, bearerTokenMatches, PRIVATE_FILE_MODE, findExecutable, bearerGuard, tokenFromWsProtocolHeader, resolveExecutableTarget, spawnExecutableTarget, 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
- import { MoxxyError, createMutex, defineMode, definePlugin, defineChannel, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, withAgentConduct, defineTool, defineCommand, defineEmbedder, asPluginId, computerControlSnapshotSchema, runReactLoop, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, asTurnId, waitFor, unfinishedWorkCheckpoint, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, denyByDefaultResolver, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, summarizeWithProvider, toolResultBytes, wakeAfter, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, computerControlCommandSchema, computeElisionState, toolResultStubbed, toolResultStubText, 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, mentionedSkills, skillAttachment, withoutTools, toolsForMode, moxxyPackageSchema, auditActionOf, asToolCallId, dispatchToolCall, matchLoadableTools, verifyEd25519, defineSecretProvider, encodeLoginAuthUrl, redactSecretText, encodeLoginPrompt, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, autoApproveFromEvents, AUTO_APPROVE_SUBTYPE, AUTO_APPROVE_PLUGIN_ID, parseFrontmatterFile, createJsonFileStore, autoApproveSwitch, computerApprovalFocusSchema, workflowApprovalItemsSchema, evaluateToolRule, asEventId } from '@moxxy/sdk';
12
- import * as os from 'os';
13
- import os__default, { homedir, tmpdir, userInfo } from 'os';
11
+ import { MoxxyError, createMutex, defineMode, definePlugin, defineChannel, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, withAgentConduct, defineTool, defineCommand, defineEmbedder, asPluginId, computerControlSnapshotSchema, runReactLoop, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, asTurnId, waitFor, unfinishedWorkCheckpoint, unfinishedStepCheckpoint, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, denyByDefaultResolver, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, summarizeWithProvider, toolResultBytes, wakeAfter, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, computerControlCommandSchema, computeElisionState, toolResultStubbed, toolResultStubText, 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, mentionedSkills, skillAttachment, withoutTools, toolsForMode, moxxyPackageSchema, auditActionOf, asToolCallId, dispatchToolCall, matchLoadableTools, verifyEd25519, defineSecretProvider, encodeLoginAuthUrl, redactSecretText, encodeLoginPrompt, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, autoApproveFromEvents, AUTO_APPROVE_SUBTYPE, AUTO_APPROVE_PLUGIN_ID, parseFrontmatterFile, createJsonFileStore, autoApproveSwitch, computerApprovalFocusSchema, workflowApprovalItemsSchema, evaluateToolRule, asEventId } from '@moxxy/sdk';
14
12
  import { createRequire as createRequire$1 } from 'module';
15
13
  import { z } from 'zod';
16
14
  import { AsyncLocalStorage } from 'async_hooks';
@@ -23,6 +21,8 @@ import net2, { createConnection, connect } from 'net';
23
21
  import { Worker } from 'worker_threads';
24
22
  import { Buffer as Buffer$1 } from 'buffer';
25
23
  import { StringDecoder } from 'string_decoder';
24
+ import * as os from 'os';
25
+ import os__default, { homedir, tmpdir, userInfo } from 'os';
26
26
  import process$1, { env, cwd, stdout, stdin } from 'process';
27
27
  import { Stream, PassThrough } from 'stream';
28
28
  import tty, { ReadStream } from 'tty';
@@ -92,17 +92,17 @@ function diffSnapshot(before, after) {
92
92
  function snapshotFilter(root) {
93
93
  return (src) => src === root || !SNAPSHOT_EXCLUDE.has(path3.basename(src));
94
94
  }
95
- function selfUpdateRoot(moxxyDir2) {
96
- return path3.join(moxxyDir2, "self-update", "txns");
95
+ function selfUpdateRoot(moxxyDir) {
96
+ return path3.join(moxxyDir, "self-update", "txns");
97
97
  }
98
- function txnDir(moxxyDir2, txnId) {
99
- return path3.join(selfUpdateRoot(moxxyDir2), txnId);
98
+ function txnDir(moxxyDir, txnId) {
99
+ return path3.join(selfUpdateRoot(moxxyDir), txnId);
100
100
  }
101
- function resolveTarget(moxxyDir2, kind, name) {
101
+ function resolveTarget(moxxyDir, kind, name) {
102
102
  if (!NAME_SEGMENT_RE.test(name)) {
103
103
  throw new Error(`invalid ${kind} name "${name}": only letters, digits, dot, dash and underscore are allowed`);
104
104
  }
105
- const p3 = kind === "plugin" ? path3.join(moxxyDir2, "plugins", name) : path3.join(moxxyDir2, "skills", `${name}.md`);
105
+ const p3 = kind === "plugin" ? path3.join(moxxyDir, "plugins", name) : path3.join(moxxyDir, "skills", `${name}.md`);
106
106
  return { kind, name, path: p3 };
107
107
  }
108
108
  function newTxnId(now = /* @__PURE__ */ new Date()) {
@@ -141,18 +141,18 @@ async function beginTransaction(opts) {
141
141
  await writeJournal(opts.moxxyDir, journal);
142
142
  return journal;
143
143
  }
144
- async function writeJournal(moxxyDir2, journal) {
144
+ async function writeJournal(moxxyDir, journal) {
145
145
  journal.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
146
- const file = path3.join(txnDir(moxxyDir2, journal.txnId), "journal.json");
146
+ const file = path3.join(txnDir(moxxyDir, journal.txnId), "journal.json");
147
147
  await writeFileAtomic(file, JSON.stringify(journal, null, 2) + "\n");
148
148
  }
149
- async function readJournal(moxxyDir2, txnId) {
150
- const file = path3.join(txnDir(moxxyDir2, txnId), "journal.json");
149
+ async function readJournal(moxxyDir, txnId) {
150
+ const file = path3.join(txnDir(moxxyDir, txnId), "journal.json");
151
151
  const raw = await promises.readFile(file, "utf8");
152
152
  return JSON.parse(raw);
153
153
  }
154
- async function listTransactions(moxxyDir2) {
155
- const root = selfUpdateRoot(moxxyDir2);
154
+ async function listTransactions(moxxyDir) {
155
+ const root = selfUpdateRoot(moxxyDir);
156
156
  let ids;
157
157
  try {
158
158
  ids = (await promises.readdir(root, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
@@ -162,7 +162,7 @@ async function listTransactions(moxxyDir2) {
162
162
  const out = [];
163
163
  for (const id of ids) {
164
164
  try {
165
- out.push(await readJournal(moxxyDir2, id));
165
+ out.push(await readJournal(moxxyDir, id));
166
166
  } catch {
167
167
  }
168
168
  }
@@ -174,13 +174,13 @@ function recordAttempt(journal, attempt) {
174
174
  function failedAttemptCount(journal) {
175
175
  return journal.attempts.filter((a2) => !a2.ok).length;
176
176
  }
177
- async function restoreSnapshot(moxxyDir2, journal) {
177
+ async function restoreSnapshot(moxxyDir, journal) {
178
178
  const { target, existedBefore } = journal;
179
179
  if (!existedBefore) {
180
180
  await promises.rm(target.path, { recursive: true, force: true });
181
181
  return;
182
182
  }
183
- const before = path3.join(txnDir(moxxyDir2, journal.txnId), "before");
183
+ const before = path3.join(txnDir(moxxyDir, journal.txnId), "before");
184
184
  if (target.kind !== "plugin") {
185
185
  await promises.rm(target.path, { recursive: true, force: true });
186
186
  await promises.cp(before, target.path, { recursive: true, filter: snapshotFilter(before) });
@@ -199,11 +199,11 @@ async function restoreSnapshot(moxxyDir2, journal) {
199
199
  await promises.mkdir(target.path, { recursive: true });
200
200
  await promises.cp(before, target.path, { recursive: true, filter: snapshotFilter(before) });
201
201
  }
202
- async function gcTransactions(moxxyDir2, keep) {
203
- const all = await listTransactions(moxxyDir2);
202
+ async function gcTransactions(moxxyDir, keep) {
203
+ const all = await listTransactions(moxxyDir);
204
204
  const terminal = all.filter((j2) => j2.state === "committed" || j2.state === "rolled_back" || j2.state === "escalated");
205
205
  for (const j2 of terminal.slice(keep)) {
206
- await promises.rm(txnDir(moxxyDir2, j2.txnId), { recursive: true, force: true });
206
+ await promises.rm(txnDir(moxxyDir, j2.txnId), { recursive: true, force: true });
207
207
  }
208
208
  }
209
209
  var MAX_FAILED_ATTEMPTS, NAME_SEGMENT_RE, SNAPSHOT_EXCLUDE;
@@ -613,49 +613,49 @@ async function corePreflight(install) {
613
613
  });
614
614
  return { ok: checks.every((c3) => c3.ok), checks };
615
615
  }
616
- function coreTxnRoot(moxxyDir2) {
617
- return path3.join(moxxyDir2, "self-update", "core-txns");
616
+ function coreTxnRoot(moxxyDir) {
617
+ return path3.join(moxxyDir, "self-update", "core-txns");
618
618
  }
619
- function coreTxnDir(moxxyDir2, txnId) {
620
- return path3.join(coreTxnRoot(moxxyDir2), txnId);
619
+ function coreTxnDir(moxxyDir, txnId) {
620
+ return path3.join(coreTxnRoot(moxxyDir), txnId);
621
621
  }
622
- function repoDir(moxxyDir2) {
623
- return path3.join(moxxyDir2, "self-update", "repo");
622
+ function repoDir(moxxyDir) {
623
+ return path3.join(moxxyDir, "self-update", "repo");
624
624
  }
625
- async function writeCoreJournal(moxxyDir2, j2) {
625
+ async function writeCoreJournal(moxxyDir, j2) {
626
626
  j2.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
627
- const file = path3.join(coreTxnDir(moxxyDir2, j2.txnId), "journal.json");
627
+ const file = path3.join(coreTxnDir(moxxyDir, j2.txnId), "journal.json");
628
628
  await writeFileAtomic(file, JSON.stringify(j2, null, 2) + "\n");
629
629
  }
630
- async function readCoreJournal(moxxyDir2, txnId) {
631
- return JSON.parse(await promises.readFile(path3.join(coreTxnDir(moxxyDir2, txnId), "journal.json"), "utf8"));
630
+ async function readCoreJournal(moxxyDir, txnId) {
631
+ return JSON.parse(await promises.readFile(path3.join(coreTxnDir(moxxyDir, txnId), "journal.json"), "utf8"));
632
632
  }
633
- async function listCoreTxns(moxxyDir2) {
633
+ async function listCoreTxns(moxxyDir) {
634
634
  let ids;
635
635
  try {
636
- ids = (await promises.readdir(coreTxnRoot(moxxyDir2), { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
636
+ ids = (await promises.readdir(coreTxnRoot(moxxyDir), { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
637
637
  } catch {
638
638
  return [];
639
639
  }
640
640
  const out = [];
641
641
  for (const id of ids) {
642
642
  try {
643
- out.push(await readCoreJournal(moxxyDir2, id));
643
+ out.push(await readCoreJournal(moxxyDir, id));
644
644
  } catch {
645
645
  }
646
646
  }
647
647
  return out.sort((a2, b3) => b3.createdAt.localeCompare(a2.createdAt));
648
648
  }
649
- async function countCorruptCoreTxns(moxxyDir2) {
649
+ async function countCorruptCoreTxns(moxxyDir) {
650
650
  let ids;
651
651
  try {
652
- ids = (await promises.readdir(coreTxnRoot(moxxyDir2), { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
652
+ ids = (await promises.readdir(coreTxnRoot(moxxyDir), { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name);
653
653
  } catch {
654
654
  return 0;
655
655
  }
656
656
  let corrupt = 0;
657
657
  for (const id of ids) {
658
- const file = path3.join(coreTxnDir(moxxyDir2, id), "journal.json");
658
+ const file = path3.join(coreTxnDir(moxxyDir, id), "journal.json");
659
659
  let raw;
660
660
  try {
661
661
  raw = await promises.readFile(file, "utf8");
@@ -858,12 +858,12 @@ async function overlayApplied(snapshotDir2, pkgNames) {
858
858
  return false;
859
859
  }
860
860
  }
861
- async function finalizeStagedCoreUpdate(moxxyDir2, install, keepTerminal = 5) {
861
+ async function finalizeStagedCoreUpdate(moxxyDir, install, keepTerminal = 5) {
862
862
  const committed = [];
863
- for (const j2 of await listCoreTxns(moxxyDir2)) {
863
+ for (const j2 of await listCoreTxns(moxxyDir)) {
864
864
  if (j2.state !== "staged_restart")
865
865
  continue;
866
- const snapDir = path3.join(coreTxnDir(moxxyDir2, j2.txnId), "snapshot");
866
+ const snapDir = path3.join(coreTxnDir(moxxyDir, j2.txnId), "snapshot");
867
867
  if (install) {
868
868
  const recon = await reconcileOverlay({
869
869
  install,
@@ -872,31 +872,31 @@ async function finalizeStagedCoreUpdate(moxxyDir2, install, keepTerminal = 5) {
872
872
  }).catch(() => ({ reconciled: false }));
873
873
  if (recon.reconciled) {
874
874
  j2.state = "rolled_back";
875
- await writeCoreJournal(moxxyDir2, j2).catch(() => void 0);
875
+ await writeCoreJournal(moxxyDir, j2).catch(() => void 0);
876
876
  continue;
877
877
  }
878
878
  if (!await overlayApplied(snapDir, j2.packages)) {
879
879
  await restoreOverlay({ install, pkgNames: j2.packages, snapshotDir: snapDir }).catch(() => void 0);
880
880
  j2.state = "rolled_back";
881
- await writeCoreJournal(moxxyDir2, j2).catch(() => void 0);
881
+ await writeCoreJournal(moxxyDir, j2).catch(() => void 0);
882
882
  continue;
883
883
  }
884
884
  }
885
885
  j2.state = "committed";
886
- await writeCoreJournal(moxxyDir2, j2).catch(() => void 0);
886
+ await writeCoreJournal(moxxyDir, j2).catch(() => void 0);
887
887
  committed.push(j2.txnId);
888
888
  }
889
- await gcCoreTxns(moxxyDir2, keepTerminal).catch(() => void 0);
889
+ await gcCoreTxns(moxxyDir, keepTerminal).catch(() => void 0);
890
890
  return committed;
891
891
  }
892
892
  function newCoreTxnId(now = /* @__PURE__ */ new Date()) {
893
893
  return `core-${newTxnId(now)}`;
894
894
  }
895
- async function gcCoreTxns(moxxyDir2, keep) {
896
- const all = await listCoreTxns(moxxyDir2);
895
+ async function gcCoreTxns(moxxyDir, keep) {
896
+ const all = await listCoreTxns(moxxyDir);
897
897
  const terminal = all.filter((j2) => j2.state === "committed" || j2.state === "rolled_back");
898
898
  for (const j2 of terminal.slice(Math.max(0, keep))) {
899
- await promises.rm(coreTxnDir(moxxyDir2, j2.txnId), { recursive: true, force: true }).catch(() => void 0);
899
+ await promises.rm(coreTxnDir(moxxyDir, j2.txnId), { recursive: true, force: true }).catch(() => void 0);
900
900
  }
901
901
  }
902
902
  function safeRepoPath(repo, rel) {
@@ -981,8 +981,8 @@ var init_deps = __esm({
981
981
  PLUGIN_ID = "@moxxy/plugin-self-update";
982
982
  }
983
983
  });
984
- function snapshotDir(moxxyDir2, txnId) {
985
- return path3.join(coreTxnDir(moxxyDir2, txnId), "snapshot");
984
+ function snapshotDir(moxxyDir, txnId) {
985
+ return path3.join(coreTxnDir(moxxyDir, txnId), "snapshot");
986
986
  }
987
987
  function resolveCore(c3) {
988
988
  return resolveCoreInstall(c3.deps, c3.fromUrl);
@@ -1743,7 +1743,7 @@ var init_dist = __esm({
1743
1743
  let appendEvent = null;
1744
1744
  let options = {};
1745
1745
  const deps = {
1746
- moxxyDir: path3.join(os.homedir(), ".moxxy"),
1746
+ moxxyDir: moxxyHome(),
1747
1747
  reload: () => host?.reload() ?? Promise.resolve(),
1748
1748
  unload: (name) => host?.unload(name) ?? Promise.resolve(),
1749
1749
  snapshot: () => snapshotFn ? snapshotFn() : {},
@@ -2939,6 +2939,16 @@ var init_subagents = __esm({
2939
2939
  init_registry();
2940
2940
  }
2941
2941
  });
2942
+
2943
+ // ../core/dist/turn-model.js
2944
+ function resolveTurnModel(session, provider, named) {
2945
+ const configured = session.defaultModels ? session.defaultModels[provider.name] : void 0;
2946
+ return named ?? session.lastResolvedModel ?? configured ?? provider.models[0]?.id;
2947
+ }
2948
+ var init_turn_model = __esm({
2949
+ "../core/dist/turn-model.js"() {
2950
+ }
2951
+ });
2942
2952
  async function* runTurn(session, prompt, opts = {}) {
2943
2953
  const turnId = opts.turnId ?? session.startTurn().turnId;
2944
2954
  const queue = [];
@@ -2974,7 +2984,7 @@ async function* runTurn(session, prompt, opts = {}) {
2974
2984
  let model;
2975
2985
  try {
2976
2986
  provider = session.providers.getActive();
2977
- const resolvedModel = opts.model ?? session.lastResolvedModel ?? provider.models[0]?.id;
2987
+ const resolvedModel = resolveTurnModel(session, provider, opts.model);
2978
2988
  if (!resolvedModel) {
2979
2989
  throw new Error(`Active provider '${provider.name}' has no models configured`);
2980
2990
  }
@@ -3015,6 +3025,7 @@ async function* runTurn(session, prompt, opts = {}) {
3015
3025
  cacheStrategy: session.cacheStrategies.getActive(),
3016
3026
  ...session.elisionSettings ? { elision: session.elisionSettings } : {},
3017
3027
  ...session.lazyTools !== void 0 ? { lazyTools: session.lazyTools } : {},
3028
+ ...session.unfinishedStepCheck !== void 0 ? { unfinishedStepCheck: session.unfinishedStepCheck } : {},
3018
3029
  // Reasoning preference (effort) — honored only by providers/models that
3019
3030
  // advertise `supportsReasoning` (gated in collectProviderStream).
3020
3031
  ...session.reasoning ? { reasoning: session.reasoning } : {},
@@ -3093,6 +3104,7 @@ async function collectTurn(session, prompt, opts = {}) {
3093
3104
  var init_run_turn = __esm({
3094
3105
  "../core/dist/run-turn.js"() {
3095
3106
  init_subagents();
3107
+ init_turn_model();
3096
3108
  }
3097
3109
  });
3098
3110
 
@@ -3324,7 +3336,7 @@ function toposortPluginManifests(manifests) {
3324
3336
  const order = [];
3325
3337
  const visited = /* @__PURE__ */ new Set();
3326
3338
  const onStack = /* @__PURE__ */ new Set();
3327
- const path77 = [];
3339
+ const path73 = [];
3328
3340
  const visitRoot = (root) => {
3329
3341
  if (visited.has(root))
3330
3342
  return;
@@ -3333,7 +3345,7 @@ function toposortPluginManifests(manifests) {
3333
3345
  return;
3334
3346
  const stack = [{ name: root, deps: pluginDeps(rootManifest.requirements), next: 0 }];
3335
3347
  onStack.add(root);
3336
- path77.push(root);
3348
+ path73.push(root);
3337
3349
  while (stack.length > 0) {
3338
3350
  const frame = stack[stack.length - 1];
3339
3351
  if (!frame)
@@ -3345,20 +3357,20 @@ function toposortPluginManifests(manifests) {
3345
3357
  if (visited.has(dep))
3346
3358
  continue;
3347
3359
  if (onStack.has(dep)) {
3348
- const startIdx = path77.indexOf(dep);
3349
- throw new PluginCycleError(path77.slice(startIdx).concat(dep));
3360
+ const startIdx = path73.indexOf(dep);
3361
+ throw new PluginCycleError(path73.slice(startIdx).concat(dep));
3350
3362
  }
3351
3363
  const depManifest = byPackage.get(dep);
3352
3364
  if (!depManifest)
3353
3365
  continue;
3354
3366
  onStack.add(dep);
3355
- path77.push(dep);
3367
+ path73.push(dep);
3356
3368
  stack.push({ name: dep, deps: pluginDeps(depManifest.requirements), next: 0 });
3357
3369
  continue;
3358
3370
  }
3359
3371
  const done = stack.pop();
3360
3372
  onStack.delete(done.name);
3361
- path77.pop();
3373
+ path73.pop();
3362
3374
  visited.add(done.name);
3363
3375
  const manifest = byPackage.get(done.name);
3364
3376
  if (manifest)
@@ -5150,8 +5162,8 @@ var init_skills = __esm({
5150
5162
  });
5151
5163
  function formatZodIssues(error) {
5152
5164
  return error.issues.map((iss) => {
5153
- const path77 = iss.path.length ? iss.path.join(".") : "(root)";
5154
- return `${path77}: ${iss.message}`;
5165
+ const path73 = iss.path.length ? iss.path.join(".") : "(root)";
5166
+ return `${path73}: ${iss.message}`;
5155
5167
  }).join("; ");
5156
5168
  }
5157
5169
  function emptyLog() {
@@ -6958,18 +6970,18 @@ var init_engine = __esm({
6958
6970
  // without serialization two overlapping calls both read the same snapshot,
6959
6971
  // each append one rule, and the second write clobbers the first's rule.
6960
6972
  mutex = createMutex();
6961
- constructor(policy = emptyPolicy, policyPath2 = null) {
6973
+ constructor(policy = emptyPolicy, policyPath = null) {
6962
6974
  this.policy = policy;
6963
- this.policyPath = policyPath2;
6975
+ this.policyPath = policyPath;
6964
6976
  }
6965
- static async load(policyPath2) {
6977
+ static async load(policyPath) {
6966
6978
  try {
6967
- const raw = await promises.readFile(policyPath2, "utf8");
6979
+ const raw = await promises.readFile(policyPath, "utf8");
6968
6980
  const parsed = permissionPolicySchema.parse(JSON.parse(raw));
6969
- return new _PermissionEngine(parsed, policyPath2);
6981
+ return new _PermissionEngine(parsed, policyPath);
6970
6982
  } catch (err) {
6971
6983
  if (isNodeError(err) && err.code === "ENOENT") {
6972
- return new _PermissionEngine(emptyPolicy, policyPath2);
6984
+ return new _PermissionEngine(emptyPolicy, policyPath);
6973
6985
  }
6974
6986
  throw err;
6975
6987
  }
@@ -7184,6 +7196,7 @@ var init_session = __esm({
7184
7196
  "../core/dist/session.js"() {
7185
7197
  init_factory();
7186
7198
  init_run_turn();
7199
+ init_turn_model();
7187
7200
  init_log();
7188
7201
  init_lifecycle();
7189
7202
  init_host();
@@ -7293,6 +7306,8 @@ var init_session = __esm({
7293
7306
  elisionSettings = null;
7294
7307
  /** Lazy tool loading, from `config.context.lazyTools`. Unset = automatic (on for a long tool list). */
7295
7308
  lazyTools = void 0;
7309
+ /** The end-of-turn reminder about a step that did not get done, from `config.context.unfinishedStepCheck`. Unset = on. */
7310
+ unfinishedStepCheck = void 0;
7296
7311
  /**
7297
7312
  * Reasoning/thinking preference, from `config.context.reasoning`. Forwarded
7298
7313
  * to each turn's ModeContext and on to the provider, which honors it only
@@ -7312,6 +7327,8 @@ var init_session = __esm({
7312
7327
  * Last-writer-wins for concurrent turns; null until the first turn runs.
7313
7328
  */
7314
7329
  lastResolvedModel = null;
7330
+ /** The model each provider is set to run when a turn names none, from `plugins.provider.items.<name>.model`. */
7331
+ defaultModels = {};
7315
7332
  /**
7316
7333
  * Live runtime capabilities the host installs on a local Session (see
7317
7334
  * SessionLike). A RemoteSession leaves them undefined. Declared here — rather
@@ -7620,6 +7637,8 @@ var init_session = __esm({
7620
7637
  } catch {
7621
7638
  }
7622
7639
  }
7640
+ const declared = this.providers.list().find((p3) => p3.name === active2);
7641
+ const defaultModel = active2 ? resolveTurnModel(this, { name: active2, models: activeProviderModels ?? (declared ? declared.models : []) }) : void 0;
7623
7642
  const ready = this.readyProviders;
7624
7643
  return {
7625
7644
  sessionId: this.id,
@@ -7670,7 +7689,8 @@ var init_session = __esm({
7670
7689
  activeSynthesizer: this.synthesizers.getActiveName(),
7671
7690
  autoApprove: this.autoApprove,
7672
7691
  reasoningEffort: reasoningEffortOf(this.reasoning),
7673
- fast: this.fast
7692
+ fast: this.fast,
7693
+ ...defaultModel !== void 0 ? { defaultModel } : {}
7674
7694
  };
7675
7695
  }
7676
7696
  };
@@ -8351,7 +8371,7 @@ function deriveTriggers(name) {
8351
8371
  return [...out];
8352
8372
  }
8353
8373
  function defaultUserSkillsDir() {
8354
- return path3.join(os.homedir(), ".moxxy", "skills");
8374
+ return moxxyPath("skills");
8355
8375
  }
8356
8376
  function defaultProjectSkillsDir(cwd2) {
8357
8377
  return path3.join(cwd2, ".moxxy", "skills");
@@ -8403,7 +8423,7 @@ The body is the instructions for future invocations. Keep it under 30 lines. Num
8403
8423
  });
8404
8424
  async function synthesizeSkill(session, intent, scope2, opts = {}, turnId) {
8405
8425
  const provider = session.providers.getActive();
8406
- const model = opts.model ?? session.lastResolvedModel ?? provider.models[0]?.id ?? "default";
8426
+ const model = resolveTurnModel(session, provider, opts.model) ?? "default";
8407
8427
  const draft = await draftSkill(provider, model, intent, session.signal);
8408
8428
  const baseDir = scope2 === "project" ? opts.projectDir ?? defaultProjectSkillsDir(session.cwd) : opts.userDir ?? defaultUserSkillsDir();
8409
8429
  await promises.mkdir(baseDir, { recursive: true });
@@ -8634,6 +8654,7 @@ var init_synthesize = __esm({
8634
8654
  "../core/dist/skills/synthesize.js"() {
8635
8655
  init_loader();
8636
8656
  init_synthesize_draft();
8657
+ init_turn_model();
8637
8658
  MAX_AUDIT_LINES = 2e3;
8638
8659
  }
8639
8660
  });
@@ -13070,6 +13091,7 @@ __export(dist_exports, {
13070
13091
  readSessionEventPage: () => readEventPage,
13071
13092
  readSessionIndex: () => readIndex,
13072
13093
  resetAuditHeadForTests: () => resetAuditHeadForTests,
13094
+ resolveTurnModel: () => resolveTurnModel,
13073
13095
  restoreSessionEvents: () => restoreEvents,
13074
13096
  runTurn: () => runTurn,
13075
13097
  seedSessionMeta: () => seedSessionMeta,
@@ -13094,6 +13116,7 @@ var init_dist2 = __esm({
13094
13116
  init_scope();
13095
13117
  init_workflow_lease();
13096
13118
  init_run_turn();
13119
+ init_turn_model();
13097
13120
  init_setup_agent();
13098
13121
  init_subagents();
13099
13122
  init_usage_stats();
@@ -13471,6 +13494,11 @@ var init_schema = __esm({
13471
13494
  elision: elisionConfigSchema.optional(),
13472
13495
  /** Lazy tool loading: send only core + loaded tool schemas, index the rest. Unset = on above 200 tools. */
13473
13496
  lazyTools: z.boolean().optional(),
13497
+ /**
13498
+ * The reminder at the end of a turn that ended on a step that did not get
13499
+ * done: take another way, or say what stops you. Asked once a turn. Unset = on.
13500
+ */
13501
+ unfinishedStepCheck: z.boolean().optional(),
13474
13502
  /**
13475
13503
  * Reasoning/thinking preview. `true` enables it at the model's default depth;
13476
13504
  * `{ effort }` sets the depth. Honored only by providers/models that support
@@ -13781,17 +13809,17 @@ var require_visit = __commonJS({
13781
13809
  visit.BREAK = BREAK;
13782
13810
  visit.SKIP = SKIP;
13783
13811
  visit.REMOVE = REMOVE;
13784
- function visit_(key, node, visitor, path77) {
13785
- const ctrl = callVisitor(key, node, visitor, path77);
13812
+ function visit_(key, node, visitor, path73) {
13813
+ const ctrl = callVisitor(key, node, visitor, path73);
13786
13814
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
13787
- replaceNode(key, path77, ctrl);
13788
- return visit_(key, ctrl, visitor, path77);
13815
+ replaceNode(key, path73, ctrl);
13816
+ return visit_(key, ctrl, visitor, path73);
13789
13817
  }
13790
13818
  if (typeof ctrl !== "symbol") {
13791
13819
  if (identity.isCollection(node)) {
13792
- path77 = Object.freeze(path77.concat(node));
13820
+ path73 = Object.freeze(path73.concat(node));
13793
13821
  for (let i2 = 0; i2 < node.items.length; ++i2) {
13794
- const ci = visit_(i2, node.items[i2], visitor, path77);
13822
+ const ci = visit_(i2, node.items[i2], visitor, path73);
13795
13823
  if (typeof ci === "number")
13796
13824
  i2 = ci - 1;
13797
13825
  else if (ci === BREAK)
@@ -13802,13 +13830,13 @@ var require_visit = __commonJS({
13802
13830
  }
13803
13831
  }
13804
13832
  } else if (identity.isPair(node)) {
13805
- path77 = Object.freeze(path77.concat(node));
13806
- const ck = visit_("key", node.key, visitor, path77);
13833
+ path73 = Object.freeze(path73.concat(node));
13834
+ const ck = visit_("key", node.key, visitor, path73);
13807
13835
  if (ck === BREAK)
13808
13836
  return BREAK;
13809
13837
  else if (ck === REMOVE)
13810
13838
  node.key = null;
13811
- const cv = visit_("value", node.value, visitor, path77);
13839
+ const cv = visit_("value", node.value, visitor, path73);
13812
13840
  if (cv === BREAK)
13813
13841
  return BREAK;
13814
13842
  else if (cv === REMOVE)
@@ -13829,17 +13857,17 @@ var require_visit = __commonJS({
13829
13857
  visitAsync.BREAK = BREAK;
13830
13858
  visitAsync.SKIP = SKIP;
13831
13859
  visitAsync.REMOVE = REMOVE;
13832
- async function visitAsync_(key, node, visitor, path77) {
13833
- const ctrl = await callVisitor(key, node, visitor, path77);
13860
+ async function visitAsync_(key, node, visitor, path73) {
13861
+ const ctrl = await callVisitor(key, node, visitor, path73);
13834
13862
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
13835
- replaceNode(key, path77, ctrl);
13836
- return visitAsync_(key, ctrl, visitor, path77);
13863
+ replaceNode(key, path73, ctrl);
13864
+ return visitAsync_(key, ctrl, visitor, path73);
13837
13865
  }
13838
13866
  if (typeof ctrl !== "symbol") {
13839
13867
  if (identity.isCollection(node)) {
13840
- path77 = Object.freeze(path77.concat(node));
13868
+ path73 = Object.freeze(path73.concat(node));
13841
13869
  for (let i2 = 0; i2 < node.items.length; ++i2) {
13842
- const ci = await visitAsync_(i2, node.items[i2], visitor, path77);
13870
+ const ci = await visitAsync_(i2, node.items[i2], visitor, path73);
13843
13871
  if (typeof ci === "number")
13844
13872
  i2 = ci - 1;
13845
13873
  else if (ci === BREAK)
@@ -13850,13 +13878,13 @@ var require_visit = __commonJS({
13850
13878
  }
13851
13879
  }
13852
13880
  } else if (identity.isPair(node)) {
13853
- path77 = Object.freeze(path77.concat(node));
13854
- const ck = await visitAsync_("key", node.key, visitor, path77);
13881
+ path73 = Object.freeze(path73.concat(node));
13882
+ const ck = await visitAsync_("key", node.key, visitor, path73);
13855
13883
  if (ck === BREAK)
13856
13884
  return BREAK;
13857
13885
  else if (ck === REMOVE)
13858
13886
  node.key = null;
13859
- const cv = await visitAsync_("value", node.value, visitor, path77);
13887
+ const cv = await visitAsync_("value", node.value, visitor, path73);
13860
13888
  if (cv === BREAK)
13861
13889
  return BREAK;
13862
13890
  else if (cv === REMOVE)
@@ -13883,23 +13911,23 @@ var require_visit = __commonJS({
13883
13911
  }
13884
13912
  return visitor;
13885
13913
  }
13886
- function callVisitor(key, node, visitor, path77) {
13914
+ function callVisitor(key, node, visitor, path73) {
13887
13915
  if (typeof visitor === "function")
13888
- return visitor(key, node, path77);
13916
+ return visitor(key, node, path73);
13889
13917
  if (identity.isMap(node))
13890
- return visitor.Map?.(key, node, path77);
13918
+ return visitor.Map?.(key, node, path73);
13891
13919
  if (identity.isSeq(node))
13892
- return visitor.Seq?.(key, node, path77);
13920
+ return visitor.Seq?.(key, node, path73);
13893
13921
  if (identity.isPair(node))
13894
- return visitor.Pair?.(key, node, path77);
13922
+ return visitor.Pair?.(key, node, path73);
13895
13923
  if (identity.isScalar(node))
13896
- return visitor.Scalar?.(key, node, path77);
13924
+ return visitor.Scalar?.(key, node, path73);
13897
13925
  if (identity.isAlias(node))
13898
- return visitor.Alias?.(key, node, path77);
13926
+ return visitor.Alias?.(key, node, path73);
13899
13927
  return void 0;
13900
13928
  }
13901
- function replaceNode(key, path77, node) {
13902
- const parent = path77[path77.length - 1];
13929
+ function replaceNode(key, path73, node) {
13930
+ const parent = path73[path73.length - 1];
13903
13931
  if (identity.isCollection(parent)) {
13904
13932
  parent.items[key] = node;
13905
13933
  } else if (identity.isPair(parent)) {
@@ -14502,10 +14530,10 @@ var require_Collection = __commonJS({
14502
14530
  var createNode2 = require_createNode();
14503
14531
  var identity = require_identity();
14504
14532
  var Node = require_Node();
14505
- function collectionFromPath(schema, path77, value2) {
14533
+ function collectionFromPath(schema, path73, value2) {
14506
14534
  let v = value2;
14507
- for (let i2 = path77.length - 1; i2 >= 0; --i2) {
14508
- const k = path77[i2];
14535
+ for (let i2 = path73.length - 1; i2 >= 0; --i2) {
14536
+ const k = path73[i2];
14509
14537
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
14510
14538
  const a2 = [];
14511
14539
  a2[k] = v;
@@ -14524,7 +14552,7 @@ var require_Collection = __commonJS({
14524
14552
  sourceObjects: /* @__PURE__ */ new Map()
14525
14553
  });
14526
14554
  }
14527
- var isEmptyPath = (path77) => path77 == null || typeof path77 === "object" && !!path77[Symbol.iterator]().next().done;
14555
+ var isEmptyPath = (path73) => path73 == null || typeof path73 === "object" && !!path73[Symbol.iterator]().next().done;
14528
14556
  var Collection = class extends Node.NodeBase {
14529
14557
  constructor(type, schema) {
14530
14558
  super(type);
@@ -14554,11 +14582,11 @@ var require_Collection = __commonJS({
14554
14582
  * be a Pair instance or a `{ key, value }` object, which may not have a key
14555
14583
  * that already exists in the map.
14556
14584
  */
14557
- addIn(path77, value2) {
14558
- if (isEmptyPath(path77))
14585
+ addIn(path73, value2) {
14586
+ if (isEmptyPath(path73))
14559
14587
  this.add(value2);
14560
14588
  else {
14561
- const [key, ...rest] = path77;
14589
+ const [key, ...rest] = path73;
14562
14590
  const node = this.get(key, true);
14563
14591
  if (identity.isCollection(node))
14564
14592
  node.addIn(rest, value2);
@@ -14572,8 +14600,8 @@ var require_Collection = __commonJS({
14572
14600
  * Removes a value from the collection.
14573
14601
  * @returns `true` if the item was found and removed.
14574
14602
  */
14575
- deleteIn(path77) {
14576
- const [key, ...rest] = path77;
14603
+ deleteIn(path73) {
14604
+ const [key, ...rest] = path73;
14577
14605
  if (rest.length === 0)
14578
14606
  return this.delete(key);
14579
14607
  const node = this.get(key, true);
@@ -14587,8 +14615,8 @@ var require_Collection = __commonJS({
14587
14615
  * scalar values from their surrounding node; to disable set `keepScalar` to
14588
14616
  * `true` (collections are always returned intact).
14589
14617
  */
14590
- getIn(path77, keepScalar) {
14591
- const [key, ...rest] = path77;
14618
+ getIn(path73, keepScalar) {
14619
+ const [key, ...rest] = path73;
14592
14620
  const node = this.get(key, true);
14593
14621
  if (rest.length === 0)
14594
14622
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -14606,8 +14634,8 @@ var require_Collection = __commonJS({
14606
14634
  /**
14607
14635
  * Checks if the collection includes a value with the key `key`.
14608
14636
  */
14609
- hasIn(path77) {
14610
- const [key, ...rest] = path77;
14637
+ hasIn(path73) {
14638
+ const [key, ...rest] = path73;
14611
14639
  if (rest.length === 0)
14612
14640
  return this.has(key);
14613
14641
  const node = this.get(key, true);
@@ -14617,8 +14645,8 @@ var require_Collection = __commonJS({
14617
14645
  * Sets a value in this collection. For `!!set`, `value` needs to be a
14618
14646
  * boolean to add/remove the item from the set.
14619
14647
  */
14620
- setIn(path77, value2) {
14621
- const [key, ...rest] = path77;
14648
+ setIn(path73, value2) {
14649
+ const [key, ...rest] = path73;
14622
14650
  if (rest.length === 0) {
14623
14651
  this.set(key, value2);
14624
14652
  } else {
@@ -17098,9 +17126,9 @@ var require_Document = __commonJS({
17098
17126
  this.contents.add(value2);
17099
17127
  }
17100
17128
  /** Adds a value to the document. */
17101
- addIn(path77, value2) {
17129
+ addIn(path73, value2) {
17102
17130
  if (assertCollection(this.contents))
17103
- this.contents.addIn(path77, value2);
17131
+ this.contents.addIn(path73, value2);
17104
17132
  }
17105
17133
  /**
17106
17134
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -17175,14 +17203,14 @@ var require_Document = __commonJS({
17175
17203
  * Removes a value from the document.
17176
17204
  * @returns `true` if the item was found and removed.
17177
17205
  */
17178
- deleteIn(path77) {
17179
- if (Collection.isEmptyPath(path77)) {
17206
+ deleteIn(path73) {
17207
+ if (Collection.isEmptyPath(path73)) {
17180
17208
  if (this.contents == null)
17181
17209
  return false;
17182
17210
  this.contents = null;
17183
17211
  return true;
17184
17212
  }
17185
- return assertCollection(this.contents) ? this.contents.deleteIn(path77) : false;
17213
+ return assertCollection(this.contents) ? this.contents.deleteIn(path73) : false;
17186
17214
  }
17187
17215
  /**
17188
17216
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -17197,10 +17225,10 @@ var require_Document = __commonJS({
17197
17225
  * scalar values from their surrounding node; to disable set `keepScalar` to
17198
17226
  * `true` (collections are always returned intact).
17199
17227
  */
17200
- getIn(path77, keepScalar) {
17201
- if (Collection.isEmptyPath(path77))
17228
+ getIn(path73, keepScalar) {
17229
+ if (Collection.isEmptyPath(path73))
17202
17230
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
17203
- return identity.isCollection(this.contents) ? this.contents.getIn(path77, keepScalar) : void 0;
17231
+ return identity.isCollection(this.contents) ? this.contents.getIn(path73, keepScalar) : void 0;
17204
17232
  }
17205
17233
  /**
17206
17234
  * Checks if the document includes a value with the key `key`.
@@ -17211,10 +17239,10 @@ var require_Document = __commonJS({
17211
17239
  /**
17212
17240
  * Checks if the document includes a value at `path`.
17213
17241
  */
17214
- hasIn(path77) {
17215
- if (Collection.isEmptyPath(path77))
17242
+ hasIn(path73) {
17243
+ if (Collection.isEmptyPath(path73))
17216
17244
  return this.contents !== void 0;
17217
- return identity.isCollection(this.contents) ? this.contents.hasIn(path77) : false;
17245
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path73) : false;
17218
17246
  }
17219
17247
  /**
17220
17248
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -17231,13 +17259,13 @@ var require_Document = __commonJS({
17231
17259
  * Sets a value in this document. For `!!set`, `value` needs to be a
17232
17260
  * boolean to add/remove the item from the set.
17233
17261
  */
17234
- setIn(path77, value2) {
17235
- if (Collection.isEmptyPath(path77)) {
17262
+ setIn(path73, value2) {
17263
+ if (Collection.isEmptyPath(path73)) {
17236
17264
  this.contents = value2;
17237
17265
  } else if (this.contents == null) {
17238
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path77), value2);
17266
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path73), value2);
17239
17267
  } else if (assertCollection(this.contents)) {
17240
- this.contents.setIn(path77, value2);
17268
+ this.contents.setIn(path73, value2);
17241
17269
  }
17242
17270
  }
17243
17271
  /**
@@ -19178,9 +19206,9 @@ var require_cst_visit = __commonJS({
19178
19206
  visit.BREAK = BREAK;
19179
19207
  visit.SKIP = SKIP;
19180
19208
  visit.REMOVE = REMOVE;
19181
- visit.itemAtPath = (cst, path77) => {
19209
+ visit.itemAtPath = (cst, path73) => {
19182
19210
  let item = cst;
19183
- for (const [field, index] of path77) {
19211
+ for (const [field, index] of path73) {
19184
19212
  const tok = item?.[field];
19185
19213
  if (tok && "items" in tok) {
19186
19214
  item = tok.items[index];
@@ -19189,23 +19217,23 @@ var require_cst_visit = __commonJS({
19189
19217
  }
19190
19218
  return item;
19191
19219
  };
19192
- visit.parentCollection = (cst, path77) => {
19193
- const parent = visit.itemAtPath(cst, path77.slice(0, -1));
19194
- const field = path77[path77.length - 1][0];
19220
+ visit.parentCollection = (cst, path73) => {
19221
+ const parent = visit.itemAtPath(cst, path73.slice(0, -1));
19222
+ const field = path73[path73.length - 1][0];
19195
19223
  const coll = parent?.[field];
19196
19224
  if (coll && "items" in coll)
19197
19225
  return coll;
19198
19226
  throw new Error("Parent collection not found");
19199
19227
  };
19200
- function _visit(path77, item, visitor) {
19201
- let ctrl = visitor(item, path77);
19228
+ function _visit(path73, item, visitor) {
19229
+ let ctrl = visitor(item, path73);
19202
19230
  if (typeof ctrl === "symbol")
19203
19231
  return ctrl;
19204
19232
  for (const field of ["key", "value"]) {
19205
19233
  const token = item[field];
19206
19234
  if (token && "items" in token) {
19207
19235
  for (let i2 = 0; i2 < token.items.length; ++i2) {
19208
- const ci = _visit(Object.freeze(path77.concat([[field, i2]])), token.items[i2], visitor);
19236
+ const ci = _visit(Object.freeze(path73.concat([[field, i2]])), token.items[i2], visitor);
19209
19237
  if (typeof ci === "number")
19210
19238
  i2 = ci - 1;
19211
19239
  else if (ci === BREAK)
@@ -19216,10 +19244,10 @@ var require_cst_visit = __commonJS({
19216
19244
  }
19217
19245
  }
19218
19246
  if (typeof ctrl === "function" && field === "key")
19219
- ctrl = ctrl(item, path77);
19247
+ ctrl = ctrl(item, path73);
19220
19248
  }
19221
19249
  }
19222
- return typeof ctrl === "function" ? ctrl(item, path77) : ctrl;
19250
+ return typeof ctrl === "function" ? ctrl(item, path73) : ctrl;
19223
19251
  }
19224
19252
  exports.visit = visit;
19225
19253
  }
@@ -21605,10 +21633,10 @@ async function removeProviderItem(providerName2, opts = {}) {
21605
21633
  const configPath = opts.configPath ?? defaultUserConfigPath();
21606
21634
  return configMutex.run(async () => {
21607
21635
  const doc = await readUserConfigDoc(configPath);
21608
- const path77 = ["plugins", "provider", "items", providerName2];
21609
- if (!doc.hasIn(path77))
21636
+ const path73 = ["plugins", "provider", "items", providerName2];
21637
+ if (!doc.hasIn(path73))
21610
21638
  return false;
21611
- doc.deleteIn(path77);
21639
+ doc.deleteIn(path73);
21612
21640
  await writeUserConfigDoc(configPath, doc);
21613
21641
  return true;
21614
21642
  });
@@ -21649,6 +21677,42 @@ async function loadActiveProvider(opts = {}) {
21649
21677
  const provider = doc.getIn(["plugins", "provider", "default"]);
21650
21678
  return typeof provider === "string" ? provider : null;
21651
21679
  }
21680
+ function storedEffort(reasoning) {
21681
+ if (reasoning === true)
21682
+ return "default";
21683
+ if (!reasoning || typeof reasoning !== "object")
21684
+ return "off";
21685
+ const effort = reasoning.effort;
21686
+ return typeof effort === "string" && MODEL_DEFAULT_EFFORTS.includes(effort) ? effort : "default";
21687
+ }
21688
+ async function loadModelDefaults(opts = {}) {
21689
+ const doc = await readUserConfigDoc(opts.configPath ?? defaultUserConfigPath());
21690
+ const provider = doc.getIn(["plugins", "provider", "default"]);
21691
+ const model = typeof provider === "string" ? doc.getIn(["plugins", "provider", "items", provider, "model"]) : void 0;
21692
+ const context = readRawEntry(doc, ["context"]);
21693
+ return {
21694
+ provider: typeof provider === "string" ? provider : null,
21695
+ model: typeof model === "string" ? model : null,
21696
+ effort: storedEffort(context.reasoning),
21697
+ fast: context.fast === true
21698
+ };
21699
+ }
21700
+ async function setModelDefaults(change, opts = {}) {
21701
+ const configPath = opts.configPath ?? defaultUserConfigPath();
21702
+ await configMutex.run(async () => {
21703
+ const doc = await readUserConfigDoc(configPath);
21704
+ if (change.model) {
21705
+ doc.setIn(["plugins", "provider", "default"], change.model.provider);
21706
+ doc.setIn(["plugins", "provider", "items", change.model.provider, "model"], change.model.model);
21707
+ }
21708
+ if (change.effort !== void 0) {
21709
+ doc.setIn(["context", "reasoning"], change.effort === "off" ? false : { effort: change.effort });
21710
+ }
21711
+ if (change.fast !== void 0)
21712
+ doc.setIn(["context", "fast"], change.fast);
21713
+ await writeUserConfigDoc(configPath, doc);
21714
+ });
21715
+ }
21652
21716
  async function loadDisabledProviders(opts = {}) {
21653
21717
  const doc = await readUserConfigDoc(opts.configPath ?? defaultUserConfigPath());
21654
21718
  const items = doc.getIn(["plugins", "provider", "items"]);
@@ -21694,28 +21758,29 @@ async function readPackagesMap(configPath) {
21694
21758
  }
21695
21759
  return out;
21696
21760
  }
21697
- function readRawEntry(doc, path77) {
21698
- const node = doc.getIn(path77, false);
21761
+ function readRawEntry(doc, path73) {
21762
+ const node = doc.getIn(path73, false);
21699
21763
  if (!(0, import_yaml.isMap)(node))
21700
21764
  return {};
21701
21765
  const raw = node.toJSON();
21702
21766
  return typeof raw === "object" && raw !== null && !Array.isArray(raw) ? raw : {};
21703
21767
  }
21704
- function pruneEmpty(doc, path77) {
21705
- const node = doc.getIn(path77);
21768
+ function pruneEmpty(doc, path73) {
21769
+ const node = doc.getIn(path73);
21706
21770
  if ((0, import_yaml.isMap)(node) && node.items.length === 0)
21707
- doc.deleteIn(path77);
21771
+ doc.deleteIn(path73);
21708
21772
  }
21709
21773
  function isNotFound(err) {
21710
21774
  return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
21711
21775
  }
21712
- var import_yaml, configMutex;
21776
+ var import_yaml, configMutex, MODEL_DEFAULT_EFFORTS;
21713
21777
  var init_user_config = __esm({
21714
21778
  "../config/dist/user-config.js"() {
21715
21779
  import_yaml = __toESM(require_dist());
21716
21780
  init_plugins_tree_schema();
21717
21781
  init_plugin_settings_schema();
21718
21782
  configMutex = createMutex();
21783
+ MODEL_DEFAULT_EFFORTS = ["low", "medium", "high", "xhigh"];
21719
21784
  }
21720
21785
  });
21721
21786
  function verifyPolicyBundle(bytes, signatureB64, publicKeyPem, expectedId) {
@@ -21771,7 +21836,7 @@ async function loadPolicyBundles(refs, opts = {}) {
21771
21836
  const sources = [];
21772
21837
  if (refs.length === 0)
21773
21838
  return { allow, deny, sources };
21774
- const cacheDir = opts.cacheDir ?? path3.join(os.homedir(), ".moxxy", "policy");
21839
+ const cacheDir = opts.cacheDir ?? moxxyPath("policy");
21775
21840
  await promises.mkdir(cacheDir, { recursive: true, mode: 448 }).catch(() => void 0);
21776
21841
  for (const ref of refs) {
21777
21842
  const cachePath = cacheFileFor(cacheDir, ref.url);
@@ -21888,6 +21953,7 @@ __export(dist_exports2, {
21888
21953
  loadConfig: () => loadConfig,
21889
21954
  loadDisabledPackageNames: () => loadDisabledPackageNames,
21890
21955
  loadDisabledProviders: () => loadDisabledProviders,
21956
+ loadModelDefaults: () => loadModelDefaults,
21891
21957
  loadPolicyBundles: () => loadPolicyBundles,
21892
21958
  loadProviderItems: () => loadProviderItems,
21893
21959
  lockedKeysOf: () => lockedKeysOf,
@@ -21906,6 +21972,7 @@ __export(dist_exports2, {
21906
21972
  setCategoryDefault: () => setCategoryDefault,
21907
21973
  setCategoryItemConfig: () => setCategoryItemConfig,
21908
21974
  setConfigValue: () => setConfigValue,
21975
+ setModelDefaults: () => setModelDefaults,
21909
21976
  setPluginEnabled: () => setPluginEnabled,
21910
21977
  setProviderEnabled: () => setProviderEnabled,
21911
21978
  setProviderItemConfig: () => setProviderItemConfig,
@@ -22896,9 +22963,9 @@ function setupFieldVaultKey(packageName, field) {
22896
22963
  return `${pkg}_${field.key}`.replace(/([a-z])([A-Z])/g, "$1_$2").toUpperCase();
22897
22964
  }
22898
22965
  async function applySetupValues(opts) {
22899
- const writeConfig = opts.writeConfig ?? (async (path77, value2) => {
22966
+ const writeConfig = opts.writeConfig ?? (async (path73, value2) => {
22900
22967
  const { setConfigValue: setConfigValue2 } = await Promise.resolve().then(() => (init_dist3(), dist_exports2));
22901
- await setConfigValue2({ scope: "user", cwd: opts.cwd, path: path77, value: value2 });
22968
+ await setConfigValue2({ scope: "user", cwd: opts.cwd, path: path73, value: value2 });
22902
22969
  });
22903
22970
  const missing = [];
22904
22971
  for (const field of opts.setup.fields) {
@@ -24264,6 +24331,18 @@ var init_dist6 = __esm({
24264
24331
  }
24265
24332
  });
24266
24333
 
24334
+ // src/setup/default-models.ts
24335
+ function configuredDefaultModels(config) {
24336
+ const items = config.plugins?.provider?.items ?? {};
24337
+ return Object.fromEntries(
24338
+ Object.entries(items).flatMap(([name, item]) => item?.model ? [[name, item.model]] : [])
24339
+ );
24340
+ }
24341
+ var init_default_models = __esm({
24342
+ "src/setup/default-models.ts"() {
24343
+ }
24344
+ });
24345
+
24267
24346
  // src/config-applier.ts
24268
24347
  function buildSessionConfigApplier(session, initial, builtins = [], disabledPackages) {
24269
24348
  let last = initial;
@@ -24309,6 +24388,10 @@ function buildSessionConfigApplier(session, initial, builtins = [], disabledPack
24309
24388
  session.lazyTools = next.context?.lazyTools;
24310
24389
  applied2.push("lazyTools");
24311
24390
  }
24391
+ if (next.context?.unfinishedStepCheck !== last.context?.unfinishedStepCheck) {
24392
+ session.unfinishedStepCheck = next.context?.unfinishedStepCheck;
24393
+ applied2.push("unfinishedStepCheck");
24394
+ }
24312
24395
  if (!deepEqual(next.context?.reasoning, last.context?.reasoning)) {
24313
24396
  session.reasoning = next.context?.reasoning;
24314
24397
  applied2.push("reasoning");
@@ -24324,6 +24407,11 @@ function buildSessionConfigApplier(session, initial, builtins = [], disabledPack
24324
24407
  if (next.hookTimeoutMs !== last.hookTimeoutMs) {
24325
24408
  pending.push("hookTimeoutMs (restart required)");
24326
24409
  }
24410
+ const defaultModels = configuredDefaultModels(next);
24411
+ if (!deepEqual(defaultModels, configuredDefaultModels(last))) {
24412
+ session.defaultModels = defaultModels;
24413
+ applied2.push("defaultModel");
24414
+ }
24327
24415
  if (providerChanged(last, next)) {
24328
24416
  pending.push("provider.* (restart required)");
24329
24417
  }
@@ -24440,6 +24528,7 @@ function arraysEqual(a2, b3) {
24440
24528
  var init_config_applier = __esm({
24441
24529
  "src/config-applier.ts"() {
24442
24530
  init_dist2();
24531
+ init_default_models();
24443
24532
  }
24444
24533
  });
24445
24534
 
@@ -24470,6 +24559,7 @@ function applyContextConfig(session, context) {
24470
24559
  if (!context) return;
24471
24560
  if (context.elision) session.elisionSettings = context.elision;
24472
24561
  if (context.lazyTools !== void 0) session.lazyTools = context.lazyTools;
24562
+ if (context.unfinishedStepCheck !== void 0) session.unfinishedStepCheck = context.unfinishedStepCheck;
24473
24563
  if (context.loopGuard) session.loopGuard = context.loopGuard;
24474
24564
  if (context.reasoning) session.reasoning = context.reasoning;
24475
24565
  if (context.fast !== void 0) session.fast = context.fast;
@@ -24606,10 +24696,10 @@ var init_apply_transcriber = __esm({
24606
24696
  });
24607
24697
  function interactiveConfigTrustPrompt() {
24608
24698
  if (!process.stdin.isTTY || !process.stderr.isTTY) return void 0;
24609
- return async ({ path: path77, sha256: sha2563 }) => {
24699
+ return async ({ path: path73, sha256: sha2563 }) => {
24610
24700
  process.stderr.write(
24611
24701
  "\n" + colors.bold("This project wants to run code before moxxy starts.") + `
24612
- ${path77}
24702
+ ${path73}
24613
24703
  ` + colors.dim(` sha256 ${sha2563.slice(0, 16)}\u2026
24614
24704
  `) + colors.dim(" Review it before approving. Approval is remembered for this exact\n") + colors.dim(" content, so an edit will ask again.\n")
24615
24705
  );
@@ -24686,9 +24776,16 @@ var init_embedder = __esm({
24686
24776
  };
24687
24777
  }
24688
24778
  });
24779
+ function userPolicyPath() {
24780
+ return moxxyPath("permissions.json");
24781
+ }
24782
+ var init_user_policy_path = __esm({
24783
+ "src/setup/user-policy-path.ts"() {
24784
+ }
24785
+ });
24689
24786
  async function buildSession(args) {
24690
- const userPolicyPath = args.config.permissions?.policyPath ?? path3.join(os.homedir(), ".moxxy", "permissions.json");
24691
- const permissionEngine = await PermissionEngine.load(userPolicyPath);
24787
+ const policyPath = args.config.permissions?.policyPath ?? userPolicyPath();
24788
+ const permissionEngine = await PermissionEngine.load(policyPath);
24692
24789
  permissionEngine.setImmutableRules({
24693
24790
  allow: [...args.config.permissions?.allow ?? [], ...args.bundledRules?.allow ?? []],
24694
24791
  deny: [...args.config.permissions?.deny ?? [], ...args.bundledRules?.deny ?? []]
@@ -24746,6 +24843,7 @@ async function buildSession(args) {
24746
24843
  }
24747
24844
  var init_build_session = __esm({
24748
24845
  "src/setup/build-session.ts"() {
24846
+ init_user_policy_path();
24749
24847
  init_dist2();
24750
24848
  }
24751
24849
  });
@@ -26552,11 +26650,11 @@ function parseBody(body) {
26552
26650
  return { ok: false, value: null };
26553
26651
  }
26554
26652
  }
26555
- function readJsonPath(parsed, path77) {
26653
+ function readJsonPath(parsed, path73) {
26556
26654
  if (!parsed.ok)
26557
26655
  return null;
26558
26656
  let cur = parsed.value;
26559
- for (const seg of path77.split(".")) {
26657
+ for (const seg of path73.split(".")) {
26560
26658
  if (cur === null || cur === void 0 || typeof cur !== "object")
26561
26659
  return null;
26562
26660
  cur = cur[seg];
@@ -31005,10 +31103,10 @@ var init_dist8 = __esm({
31005
31103
  function defaultIdentityPath() {
31006
31104
  return moxxyPath("proxy-identity.key");
31007
31105
  }
31008
- async function loadOrCreateIdentity(path77 = defaultIdentityPath()) {
31106
+ async function loadOrCreateIdentity(path73 = defaultIdentityPath()) {
31009
31107
  let hex = null;
31010
31108
  try {
31011
- hex = (await readFile(path77, "utf8")).trim();
31109
+ hex = (await readFile(path73, "utf8")).trim();
31012
31110
  } catch (err) {
31013
31111
  if (err.code !== "ENOENT")
31014
31112
  throw err;
@@ -31023,7 +31121,7 @@ async function loadOrCreateIdentity(path77 = defaultIdentityPath()) {
31023
31121
  }
31024
31122
  }
31025
31123
  const identity = generateIdentity();
31026
- await writeFileAtomic(path77, bytesToHex(identity.secretKey), { mode: 384 });
31124
+ await writeFileAtomic(path73, bytesToHex(identity.secretKey), { mode: 384 });
31027
31125
  return identity;
31028
31126
  }
31029
31127
  var init_node2 = __esm({
@@ -39516,7 +39614,7 @@ var DEFAULT_MODE_NAME, checkpoints;
39516
39614
  var init_turn_iterator = __esm({
39517
39615
  "../mode-default/dist/turn-iterator.js"() {
39518
39616
  DEFAULT_MODE_NAME = "default";
39519
- checkpoints = [unfinishedWorkCheckpoint()];
39617
+ checkpoints = [unfinishedWorkCheckpoint(), unfinishedStepCheckpoint()];
39520
39618
  }
39521
39619
  });
39522
39620
  var defaultMode, defaultModePlugin;
@@ -40428,7 +40526,7 @@ function surfaceInputWithinCap(m3) {
40428
40526
  var RUNNER_PROTOCOL_VERSION, MIN_COMPATIBLE_PROTOCOL_VERSION, RunnerMethod, RunnerNotification, attachmentSchema, principalSchema, attachParamsSchema, runTurnParamsSchema, abortParamsSchema, setResolverParamsSchema, modeSetActiveParamsSchema, sessionSetReasoningParamsSchema, sessionSetFastParamsSchema, MAX_HISTORY_PAGE_LIMIT, sessionLoadHistoryParamsSchema, MAX_RECORDED_EXCHANGE_CHARS, recordedText, sessionRecordExchangeParamsSchema, sessionSetAutoApproveParamsSchema, providerSetActiveParamsSchema, providerSetEnabledParamsSchema, providerConfigureParamsSchema, permissionAddAllowParamsSchema, commandRunParamsSchema, MAX_TRANSCRIBE_AUDIO_B64_BYTES, MAX_SYNTHESIZE_TEXT_BYTES, MEDIA_DESCRIPTOR_MAX, transcribeParamsSchema, synthesizeParamsSchema, cancelSynthesizeParamsSchema, mcpEnableAndAttachParamsSchema, mcpDetachParamsSchema, workflowSetEnabledParamsSchema, workflowRunParamsSchema, workflowValidateDraftParamsSchema, workflowSaveParamsSchema, workflowGetRunParamsSchema, workflowResumeParamsSchema, surfaceOpenParamsSchema, MAX_SURFACE_INPUT_BYTES, surfaceInputParamsSchema, surfaceResizeParamsSchema, surfaceCloseParamsSchema;
40429
40527
  var init_protocol2 = __esm({
40430
40528
  "../runner/dist/protocol.js"() {
40431
- RUNNER_PROTOCOL_VERSION = 24;
40529
+ RUNNER_PROTOCOL_VERSION = 25;
40432
40530
  MIN_COMPATIBLE_PROTOCOL_VERSION = 1;
40433
40531
  RunnerMethod = {
40434
40532
  /** client->server: handshake; returns the initial info snapshot. */
@@ -42749,8 +42847,8 @@ var init_client = __esm({
42749
42847
  peerFiles(agentId) {
42750
42848
  return this.peer.request(CollabHubMethod.PeerFiles, { agentId });
42751
42849
  }
42752
- peerRead(agentId, path77) {
42753
- return this.peer.request(CollabHubMethod.PeerRead, { agentId, path: path77 });
42850
+ peerRead(agentId, path73) {
42851
+ return this.peer.request(CollabHubMethod.PeerRead, { agentId, path: path73 });
42754
42852
  }
42755
42853
  peerDiff(agentId) {
42756
42854
  return this.peer.request(CollabHubMethod.PeerDiff, { agentId });
@@ -43089,11 +43187,11 @@ var init_tools7 = __esm({
43089
43187
  permission: { action: "allow" },
43090
43188
  isolation: HUB_RPC_PEER_ISOLATION,
43091
43189
  modes: COLLAB_AGENT_MODES,
43092
- handler: async ({ agentId, path: path77 }) => {
43190
+ handler: async ({ agentId, path: path73 }) => {
43093
43191
  const c3 = await getProcessHubClient();
43094
43192
  if (!c3)
43095
43193
  return NOT_IN_COLLAB;
43096
- return c3.peerRead(agentId, path77);
43194
+ return c3.peerRead(agentId, path73);
43097
43195
  }
43098
43196
  });
43099
43197
  collabPeerDiff = defineTool({
@@ -44137,14 +44235,14 @@ var init_summarize = __esm({
44137
44235
  Use terse bullet points. Do NOT restate the raw conversation, do NOT invent details, omit chit-chat and pleasantries. Output ONLY the brief text \u2014 no preamble, no sign-off. Keep it well under 400 words.`;
44138
44236
  }
44139
44237
  });
44140
- function moxxyHome2() {
44238
+ function moxxyHome3() {
44141
44239
  return process.env.MOXXY_HOME ?? join(homedir(), ".moxxy");
44142
44240
  }
44143
44241
  function collabLockPath() {
44144
- return process.env.MOXXY_COLLAB_LOCK || join(moxxyHome2(), "collab", "active.lock");
44242
+ return process.env.MOXXY_COLLAB_LOCK || join(moxxyHome3(), "collab", "active.lock");
44145
44243
  }
44146
44244
  function collabRunsDir() {
44147
- return join(moxxyHome2(), "collab", "runs");
44245
+ return join(moxxyHome3(), "collab", "runs");
44148
44246
  }
44149
44247
  function parseCollabLock(raw) {
44150
44248
  let info;
@@ -44317,8 +44415,8 @@ async function addWorktree(args) {
44317
44415
  if (r2.code !== 0)
44318
44416
  throw new Error(`git worktree add failed: ${r2.stderr.trim() || r2.stdout.trim()}`);
44319
44417
  }
44320
- async function removeWorktree(repoCwd, path77) {
44321
- await git(repoCwd, ["worktree", "remove", "--force", path77]);
44418
+ async function removeWorktree(repoCwd, path73) {
44419
+ await git(repoCwd, ["worktree", "remove", "--force", path73]);
44322
44420
  await git(repoCwd, ["worktree", "prune"]);
44323
44421
  }
44324
44422
  async function commitAll(worktreeCwd, message) {
@@ -44339,9 +44437,9 @@ async function changedFiles(worktreeCwd) {
44339
44437
  if (!rec)
44340
44438
  continue;
44341
44439
  const status = rec.slice(0, 2).trim();
44342
- const path77 = rec.slice(3);
44343
- if (path77)
44344
- out.push({ status, path: path77 });
44440
+ const path73 = rec.slice(3);
44441
+ if (path73)
44442
+ out.push({ status, path: path73 });
44345
44443
  if (status.startsWith("R") || status.startsWith("C"))
44346
44444
  i2++;
44347
44445
  }
@@ -44435,9 +44533,9 @@ function peerReaderFor(worktrees, baseSha) {
44435
44533
  async files(agentId) {
44436
44534
  return changedFiles(dirFor(agentId));
44437
44535
  },
44438
- async read(agentId, path77) {
44536
+ async read(agentId, path73) {
44439
44537
  const dir = dirFor(agentId);
44440
- return readFile(await resolveWithinReal(dir, path77), "utf8");
44538
+ return readFile(await resolveWithinReal(dir, path73), "utf8");
44441
44539
  },
44442
44540
  async diff(agentId) {
44443
44541
  return diffVsBase(dirFor(agentId), baseSha);
@@ -44449,8 +44547,8 @@ function cwdPeerReader(cwd2) {
44449
44547
  async files() {
44450
44548
  return await isGitRepo(cwd2) ? changedFiles(cwd2) : [];
44451
44549
  },
44452
- async read(_agentId, path77) {
44453
- return readFile(await resolveWithinReal(cwd2, path77), "utf8");
44550
+ async read(_agentId, path73) {
44551
+ return readFile(await resolveWithinReal(cwd2, path73), "utf8");
44454
44552
  },
44455
44553
  async diff() {
44456
44554
  return "";
@@ -44695,8 +44793,8 @@ function readActiveCollab() {
44695
44793
  return info;
44696
44794
  }
44697
44795
  function tryAcquireCollabLock(args) {
44698
- const path77 = collabLockPath();
44699
- mkdirSync(dirname(path77), { recursive: true });
44796
+ const path73 = collabLockPath();
44797
+ mkdirSync(dirname(path73), { recursive: true });
44700
44798
  const info = {
44701
44799
  pid: process.pid,
44702
44800
  sessionId: args.sessionId,
@@ -44707,7 +44805,7 @@ function tryAcquireCollabLock(args) {
44707
44805
  const payload2 = JSON.stringify(info);
44708
44806
  for (let attempt = 0; attempt < 5; attempt++) {
44709
44807
  try {
44710
- const fd = openSync(path77, "wx");
44808
+ const fd = openSync(path73, "wx");
44711
44809
  try {
44712
44810
  writeFileSync(fd, payload2);
44713
44811
  } finally {
@@ -44722,7 +44820,7 @@ function tryAcquireCollabLock(args) {
44722
44820
  return { ok: false, holder: existing };
44723
44821
  }
44724
44822
  try {
44725
- unlinkSync(path77);
44823
+ unlinkSync(path73);
44726
44824
  } catch {
44727
44825
  }
44728
44826
  }
@@ -45077,11 +45175,11 @@ function lastUserPromptText(ctx) {
45077
45175
  }
45078
45176
  return void 0;
45079
45177
  }
45080
- function readRoster(path77, maxAgents) {
45081
- if (!existsSync(path77))
45178
+ function readRoster(path73, maxAgents) {
45179
+ if (!existsSync(path73))
45082
45180
  return [];
45083
45181
  try {
45084
- const raw = JSON.parse(readFileSync(path77, "utf8"));
45182
+ const raw = JSON.parse(readFileSync(path73, "utf8"));
45085
45183
  if (!Array.isArray(raw))
45086
45184
  return [];
45087
45185
  const seen = /* @__PURE__ */ new Set();
@@ -45561,11 +45659,11 @@ var init_agent_loop = __esm({
45561
45659
  }
45562
45660
  });
45563
45661
  function peerSystemPrompt(env3) {
45564
- const path77 = env3[COLLAB_ENV.CharterFile]?.trim();
45565
- if (!path77)
45662
+ const path73 = env3[COLLAB_ENV.CharterFile]?.trim();
45663
+ if (!path73)
45566
45664
  return COLLAB_PEER_PROMPT;
45567
45665
  try {
45568
- return peerPromptWithCharter(readFileSync(path77, "utf8"));
45666
+ return peerPromptWithCharter(readFileSync(path73, "utf8"));
45569
45667
  } catch {
45570
45668
  return COLLAB_PEER_PROMPT;
45571
45669
  }
@@ -70980,10 +71078,10 @@ var require_react_reconciler_development = __commonJS({
70980
71078
  var setErrorHandler = null;
70981
71079
  var setSuspenseHandler = null;
70982
71080
  {
70983
- var copyWithDeleteImpl = function(obj, path77, index2) {
70984
- var key = path77[index2];
71081
+ var copyWithDeleteImpl = function(obj, path73, index2) {
71082
+ var key = path73[index2];
70985
71083
  var updated = isArray(obj) ? obj.slice() : assign({}, obj);
70986
- if (index2 + 1 === path77.length) {
71084
+ if (index2 + 1 === path73.length) {
70987
71085
  if (isArray(updated)) {
70988
71086
  updated.splice(key, 1);
70989
71087
  } else {
@@ -70991,11 +71089,11 @@ var require_react_reconciler_development = __commonJS({
70991
71089
  }
70992
71090
  return updated;
70993
71091
  }
70994
- updated[key] = copyWithDeleteImpl(obj[key], path77, index2 + 1);
71092
+ updated[key] = copyWithDeleteImpl(obj[key], path73, index2 + 1);
70995
71093
  return updated;
70996
71094
  };
70997
- var copyWithDelete = function(obj, path77) {
70998
- return copyWithDeleteImpl(obj, path77, 0);
71095
+ var copyWithDelete = function(obj, path73) {
71096
+ return copyWithDeleteImpl(obj, path73, 0);
70999
71097
  };
71000
71098
  var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
71001
71099
  var oldKey = oldPath[index2];
@@ -71033,17 +71131,17 @@ var require_react_reconciler_development = __commonJS({
71033
71131
  }
71034
71132
  return copyWithRenameImpl(obj, oldPath, newPath, 0);
71035
71133
  };
71036
- var copyWithSetImpl = function(obj, path77, index2, value2) {
71037
- if (index2 >= path77.length) {
71134
+ var copyWithSetImpl = function(obj, path73, index2, value2) {
71135
+ if (index2 >= path73.length) {
71038
71136
  return value2;
71039
71137
  }
71040
- var key = path77[index2];
71138
+ var key = path73[index2];
71041
71139
  var updated = isArray(obj) ? obj.slice() : assign({}, obj);
71042
- updated[key] = copyWithSetImpl(obj[key], path77, index2 + 1, value2);
71140
+ updated[key] = copyWithSetImpl(obj[key], path73, index2 + 1, value2);
71043
71141
  return updated;
71044
71142
  };
71045
- var copyWithSet = function(obj, path77, value2) {
71046
- return copyWithSetImpl(obj, path77, 0, value2);
71143
+ var copyWithSet = function(obj, path73, value2) {
71144
+ return copyWithSetImpl(obj, path73, 0, value2);
71047
71145
  };
71048
71146
  var findHook = function(fiber, id) {
71049
71147
  var currentHook2 = fiber.memoizedState;
@@ -71053,10 +71151,10 @@ var require_react_reconciler_development = __commonJS({
71053
71151
  }
71054
71152
  return currentHook2;
71055
71153
  };
71056
- overrideHookState = function(fiber, id, path77, value2) {
71154
+ overrideHookState = function(fiber, id, path73, value2) {
71057
71155
  var hook = findHook(fiber, id);
71058
71156
  if (hook !== null) {
71059
- var newState = copyWithSet(hook.memoizedState, path77, value2);
71157
+ var newState = copyWithSet(hook.memoizedState, path73, value2);
71060
71158
  hook.memoizedState = newState;
71061
71159
  hook.baseState = newState;
71062
71160
  fiber.memoizedProps = assign({}, fiber.memoizedProps);
@@ -71066,10 +71164,10 @@ var require_react_reconciler_development = __commonJS({
71066
71164
  }
71067
71165
  }
71068
71166
  };
71069
- overrideHookStateDeletePath = function(fiber, id, path77) {
71167
+ overrideHookStateDeletePath = function(fiber, id, path73) {
71070
71168
  var hook = findHook(fiber, id);
71071
71169
  if (hook !== null) {
71072
- var newState = copyWithDelete(hook.memoizedState, path77);
71170
+ var newState = copyWithDelete(hook.memoizedState, path73);
71073
71171
  hook.memoizedState = newState;
71074
71172
  hook.baseState = newState;
71075
71173
  fiber.memoizedProps = assign({}, fiber.memoizedProps);
@@ -71092,8 +71190,8 @@ var require_react_reconciler_development = __commonJS({
71092
71190
  }
71093
71191
  }
71094
71192
  };
71095
- overrideProps = function(fiber, path77, value2) {
71096
- fiber.pendingProps = copyWithSet(fiber.memoizedProps, path77, value2);
71193
+ overrideProps = function(fiber, path73, value2) {
71194
+ fiber.pendingProps = copyWithSet(fiber.memoizedProps, path73, value2);
71097
71195
  if (fiber.alternate) {
71098
71196
  fiber.alternate.pendingProps = fiber.pendingProps;
71099
71197
  }
@@ -71102,8 +71200,8 @@ var require_react_reconciler_development = __commonJS({
71102
71200
  scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
71103
71201
  }
71104
71202
  };
71105
- overridePropsDeletePath = function(fiber, path77) {
71106
- fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path77);
71203
+ overridePropsDeletePath = function(fiber, path73) {
71204
+ fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path73);
71107
71205
  if (fiber.alternate) {
71108
71206
  fiber.alternate.pendingProps = fiber.pendingProps;
71109
71207
  }
@@ -78608,8 +78706,8 @@ var init_ErrorOverview = __esm({
78608
78706
  init_dist26();
78609
78707
  init_Box();
78610
78708
  init_Text();
78611
- cleanupPath = (path77) => {
78612
- return path77?.replace(`file://${cwd()}/`, "");
78709
+ cleanupPath = (path73) => {
78710
+ return path73?.replace(`file://${cwd()}/`, "");
78613
78711
  };
78614
78712
  stackUtils = new import_stack_utils.default({
78615
78713
  cwd: cwd(),
@@ -89472,7 +89570,7 @@ var init_PermissionEditor = __esm({
89472
89570
  import_react72 = __toESM(require_react());
89473
89571
  await init_build2();
89474
89572
  init_dist2();
89475
- PermissionEditor = ({ policyPath: policyPath2 }) => {
89573
+ PermissionEditor = ({ policyPath }) => {
89476
89574
  const { exit } = use_app_default();
89477
89575
  const [engine, setEngine] = (0, import_react72.useState)(null);
89478
89576
  const [rows, setRows] = (0, import_react72.useState)([]);
@@ -89483,7 +89581,7 @@ var init_PermissionEditor = __esm({
89483
89581
  (0, import_react72.useEffect)(() => {
89484
89582
  let cancelled = false;
89485
89583
  (async () => {
89486
- const e = await PermissionEngine.load(policyPath2);
89584
+ const e = await PermissionEngine.load(policyPath);
89487
89585
  if (cancelled)
89488
89586
  return;
89489
89587
  setEngine(e);
@@ -89492,7 +89590,7 @@ var init_PermissionEditor = __esm({
89492
89590
  return () => {
89493
89591
  cancelled = true;
89494
89592
  };
89495
- }, [policyPath2]);
89593
+ }, [policyPath]);
89496
89594
  const refresh = (e) => {
89497
89595
  const next = toRows(e);
89498
89596
  setRows(next);
@@ -89607,7 +89705,7 @@ var init_PermissionEditor = __esm({
89607
89705
  exit();
89608
89706
  }
89609
89707
  });
89610
- return (0, import_jsx_runtime42.jsxs)(Box_default, { flexDirection: "column", padding: 1, children: [(0, import_jsx_runtime42.jsxs)(Box_default, { marginBottom: 1, children: [(0, import_jsx_runtime42.jsx)(Text, { bold: true, color: "magenta", children: "moxxy perms editor" }), (0, import_jsx_runtime42.jsxs)(Text, { dimColor: true, children: [" (", policyPath2, ")"] })] }), rows.length === 0 ? (0, import_jsx_runtime42.jsx)(Text, { dimColor: true, children: "(no rules \u2014 press `a` to add an allow rule, `D` for deny)" }) : rows.map((row, i2) => {
89708
+ return (0, import_jsx_runtime42.jsxs)(Box_default, { flexDirection: "column", padding: 1, children: [(0, import_jsx_runtime42.jsxs)(Box_default, { marginBottom: 1, children: [(0, import_jsx_runtime42.jsx)(Text, { bold: true, color: "magenta", children: "moxxy perms editor" }), (0, import_jsx_runtime42.jsxs)(Text, { dimColor: true, children: [" (", policyPath, ")"] })] }), rows.length === 0 ? (0, import_jsx_runtime42.jsx)(Text, { dimColor: true, children: "(no rules \u2014 press `a` to add an allow rule, `D` for deny)" }) : rows.map((row, i2) => {
89611
89709
  const focused = i2 === cursor3;
89612
89710
  return (0, import_jsx_runtime42.jsxs)(Box_default, { children: [(0, import_jsx_runtime42.jsx)(Text, { color: focused ? "cyan" : void 0, children: focused ? "\u203A " : " " }), (0, import_jsx_runtime42.jsx)(Text, { color: row.kind === "allow" ? "green" : "red", children: row.kind.padEnd(5) }), (0, import_jsx_runtime42.jsxs)(Text, { children: [" ", row.name] }), row.reason ? (0, import_jsx_runtime42.jsxs)(Text, { dimColor: true, children: [" \u2014 ", row.reason] }) : null] }, `${row.kind}:${row.name}:${i2}`);
89613
89711
  }), (0, import_jsx_runtime42.jsx)(Box_default, { marginTop: 1, children: mode.kind === "add" ? (0, import_jsx_runtime42.jsxs)(Text, { children: ["new ", mode.bucket, " rule: ", (0, import_jsx_runtime42.jsx)(Text, { color: "cyan", children: mode.buffer }), (0, import_jsx_runtime42.jsx)(Text, { dimColor: true, children: " (enter to confirm, esc to cancel)" })] }) : mode.kind === "confirm-delete" ? (0, import_jsx_runtime42.jsxs)(Text, { color: "yellow", children: ["delete `", mode.row.name, "` (", mode.row.kind, ")? [y/N]"] }) : mode.kind === "message" ? (0, import_jsx_runtime42.jsxs)(Text, { color: /FAILED/i.test(mode.text) ? "red" : "green", children: [mode.text, " (press any key)"] }) : (0, import_jsx_runtime42.jsxs)(Text, { dimColor: true, children: ["\u2191/\u2193 move \xB7 space/enter flip \xB7 a add allow \xB7 D add deny \xB7 d delete \xB7 q quit", dirty || /FAILED/i.test(status) ? (0, import_jsx_runtime42.jsx)(Text, { color: /FAILED/i.test(status) ? "red" : "green", children: ` \xB7 ${status}` }) : null] }) })] });
@@ -89989,6 +90087,20 @@ var init_ask = __esm({
89989
90087
  }
89990
90088
  });
89991
90089
 
90090
+ // ../desktop-ipc-contract/dist/attachment-limits.js
90091
+ var MB, ATTACHMENT_LIMITS;
90092
+ var init_attachment_limits = __esm({
90093
+ "../desktop-ipc-contract/dist/attachment-limits.js"() {
90094
+ MB = 1024 * 1024;
90095
+ ATTACHMENT_LIMITS = Object.freeze({
90096
+ /** An image goes to the model whole; this is what providers accept. */
90097
+ imageBytes: 8 * MB,
90098
+ /** A file handed over as bytes (dropped or pasted) crosses the IPC boundary in one piece. */
90099
+ fileBytes: 32 * MB
90100
+ });
90101
+ }
90102
+ });
90103
+
89992
90104
  // ../desktop-ipc-contract/dist/error-envelope.js
89993
90105
  var init_error_envelope = __esm({
89994
90106
  "../desktop-ipc-contract/dist/error-envelope.js"() {
@@ -90018,6 +90130,12 @@ var init_focus_layout = __esm({
90018
90130
  }
90019
90131
  });
90020
90132
 
90133
+ // ../desktop-ipc-contract/dist/app-update.js
90134
+ var init_app_update = __esm({
90135
+ "../desktop-ipc-contract/dist/app-update.js"() {
90136
+ }
90137
+ });
90138
+
90021
90139
  // ../desktop-ipc-contract/dist/remote.js
90022
90140
  var REMOTE_ALLOWED_COMMANDS;
90023
90141
  var init_remote = __esm({
@@ -90104,8 +90222,10 @@ var init_remote = __esm({
90104
90222
  var init_dist30 = __esm({
90105
90223
  "../desktop-ipc-contract/dist/index.js"() {
90106
90224
  init_ask();
90225
+ init_attachment_limits();
90107
90226
  init_error_envelope();
90108
90227
  init_focus_layout();
90228
+ init_app_update();
90109
90229
  init_remote();
90110
90230
  }
90111
90231
  });
@@ -90122,6 +90242,7 @@ function validateIpcInput(command, arg) {
90122
90242
  var USER_PROMPT_ATTACHMENT_KINDS, providerName, loginId, httpUrl, skillName, vaultKeyName, optionalWorkspace, MAX_VOICE_EXCHANGE_TEXT, MAX_AUDIO_BASE64, MAX_SYNTHESIZE_TEXT, speechLanguage, speechRate, MAX_INLINE_ATTACHMENT_CONTENT, MAX_INLINE_ATTACHMENTS_TOTAL, BASE64_RE, base64, BASE64_ATTACHMENT_KINDS, commandName, appId, channelId, workflowName, scheduleId, webhookId, sessionRef, focusDelta, focusScreenPoint, FOCUS_WINDOW_MAX_SIZE, FOCUS_MINI_TEXT_MIN_WIDTH, FOCUS_MINI_TEXT_MIN_HEIGHT, focusSize, focusMiniTextSize, ipcInputSchemas;
90123
90243
  var init_validation = __esm({
90124
90244
  "../desktop-ipc-contract/dist/validation.js"() {
90245
+ init_attachment_limits();
90125
90246
  USER_PROMPT_ATTACHMENT_KINDS = ["stdin", "file", "image", "document", "audio"];
90126
90247
  providerName = z.string().regex(/^[a-z][a-z0-9-]{0,63}$/, "invalid provider name");
90127
90248
  loginId = z.string().min(1).max(64).regex(/^[A-Za-z0-9-]+$/, "invalid login id");
@@ -90183,7 +90304,11 @@ var init_validation = __esm({
90183
90304
  "app.checkUpdate": z.undefined(),
90184
90305
  "app.updateDashboard": z.undefined(),
90185
90306
  "app.updateShell": z.undefined(),
90307
+ "app.updateAll": z.undefined(),
90308
+ "app.updatePlan": z.undefined(),
90309
+ "app.setup": z.undefined(),
90186
90310
  "app.relaunch": z.undefined(),
90311
+ "app.revertUpdate": z.undefined(),
90187
90312
  "app.appBooted": z.undefined(),
90188
90313
  "app.updateDiagnostics": z.undefined(),
90189
90314
  // Optional offline voice installation spawns the CLI and changes the active
@@ -90216,6 +90341,7 @@ var init_validation = __esm({
90216
90341
  // can't bloat the on-disk boot-log.
90217
90342
  "app.bootHeartbeatFailed": z.object({ error: z.string().max(2048) }),
90218
90343
  "focus.toggle": z.undefined(),
90344
+ "window.presence": z.undefined(),
90219
90345
  "focus.moveBy": z.object({ dx: focusDelta, dy: focusDelta }).strict(),
90220
90346
  "focus.dragStart": z.object({ screenX: focusScreenPoint, screenY: focusScreenPoint }).strict(),
90221
90347
  "focus.dragMove": z.object({ screenX: focusScreenPoint, screenY: focusScreenPoint }).strict(),
@@ -90333,6 +90459,17 @@ var init_validation = __esm({
90333
90459
  path: z.string().min(1).max(4096),
90334
90460
  name: z.string().min(1).max(1024)
90335
90461
  }).strict(),
90462
+ "session.checkAttachment": z.object({
90463
+ workspaceId: optionalWorkspace,
90464
+ path: z.string().min(1).max(4096),
90465
+ name: z.string().min(1).max(1024)
90466
+ }).strict(),
90467
+ // The bytes of a dropped or pasted file: bounded to the base64 of the largest
90468
+ // file allowed, so an oversized payload is refused before it is decoded.
90469
+ "session.saveAttachment": z.object({
90470
+ dataBase64: z.string().min(1).max(Math.ceil(ATTACHMENT_LIMITS.fileBytes / 3) * 4),
90471
+ name: z.string().min(1).max(1024)
90472
+ }).strict(),
90336
90473
  // Runs an arbitrary registered slash command — the audit flagged this as the
90337
90474
  // one mutating session command without a schema, so lock the name to a
90338
90475
  // registry slug and bound the free-text args.
@@ -90409,6 +90546,12 @@ var init_validation = __esm({
90409
90546
  effort: z.enum(["off", "low", "medium", "high", "xhigh"])
90410
90547
  }),
90411
90548
  "settings.setFast": z.object({ workspaceId: optionalWorkspace, enabled: z.boolean() }),
90549
+ // Written into the config file: a provider name that cannot leave its key, and a model id of sane length.
90550
+ "settings.setModelDefaults": z.object({
90551
+ model: z.object({ provider: providerName, model: z.string().min(1).max(256) }).strict().optional(),
90552
+ effort: z.enum(["off", "low", "medium", "high", "xhigh"]).optional(),
90553
+ fast: z.boolean().optional()
90554
+ }).strict().refine((change) => Object.keys(change).length > 0, "nothing to change"),
90412
90555
  "settings.writeSkill": z.object({ name: skillName, body: z.string().max(1e6) }),
90413
90556
  "settings.readSkill": z.object({ name: skillName }),
90414
90557
  "settings.deleteSkill": z.object({ name: skillName }),
@@ -90486,6 +90629,8 @@ var init_validation = __esm({
90486
90629
  mobileGatewayEnabled: z.boolean().optional(),
90487
90630
  theme: z.enum(["light", "dark", "system"]).optional(),
90488
90631
  voiceEngine: z.enum(["local", "gpt-live"]).optional(),
90632
+ replySound: z.boolean().optional(),
90633
+ systemNotifications: z.boolean().optional(),
90489
90634
  focusMiniTextSize: focusMiniTextSize.nullable().optional()
90490
90635
  }).strict(),
90491
90636
  // Mobile-gateway control. Both no-arg variants pin the payload to "nothing"
@@ -91665,8 +91810,8 @@ function buildConnectUrl(opts) {
91665
91810
  if (opts.tunnelUrl) {
91666
91811
  const u5 = new URL(opts.tunnelUrl);
91667
91812
  const scheme = u5.protocol === "https:" ? "wss" : "ws";
91668
- const path77 = u5.pathname === "/" ? "/" : `${u5.pathname.replace(/\/$/, "")}/`;
91669
- return `${scheme}://${u5.host}${path77}?t=${t2}${fp}`;
91813
+ const path73 = u5.pathname === "/" ? "/" : `${u5.pathname.replace(/\/$/, "")}/`;
91814
+ return `${scheme}://${u5.host}${path73}?t=${t2}${fp}`;
91670
91815
  }
91671
91816
  return `ws://${opts.localHost}:${opts.port}/?t=${t2}${fp}`;
91672
91817
  }
@@ -93409,10 +93554,10 @@ var require_segments = __commonJS({
93409
93554
  const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
93410
93555
  const nodes = buildNodes(segs);
93411
93556
  const graph = buildGraph(nodes, version);
93412
- const path77 = dijkstra.find_path(graph.map, "start", "end");
93557
+ const path73 = dijkstra.find_path(graph.map, "start", "end");
93413
93558
  const optimizedSegs = [];
93414
- for (let i2 = 1; i2 < path77.length - 1; i2++) {
93415
- optimizedSegs.push(graph.table[path77[i2]].node);
93559
+ for (let i2 = 1; i2 < path73.length - 1; i2++) {
93560
+ optimizedSegs.push(graph.table[path73[i2]].node);
93416
93561
  }
93417
93562
  return exports.fromArray(mergeSegments(optimizedSegs));
93418
93563
  };
@@ -95864,7 +96009,7 @@ var require_png2 = __commonJS({
95864
96009
  });
95865
96010
  png.pack();
95866
96011
  };
95867
- exports.renderToFile = function renderToFile(path77, qrData, options, cb) {
96012
+ exports.renderToFile = function renderToFile(path73, qrData, options, cb) {
95868
96013
  if (typeof cb === "undefined") {
95869
96014
  cb = options;
95870
96015
  options = void 0;
@@ -95875,7 +96020,7 @@ var require_png2 = __commonJS({
95875
96020
  called = true;
95876
96021
  cb.apply(null, args);
95877
96022
  };
95878
- const stream2 = fs52.createWriteStream(path77);
96023
+ const stream2 = fs52.createWriteStream(path73);
95879
96024
  stream2.on("error", done);
95880
96025
  stream2.on("close", done);
95881
96026
  exports.renderToFileStream(stream2, qrData, options);
@@ -95937,14 +96082,14 @@ var require_utf8 = __commonJS({
95937
96082
  }
95938
96083
  return output;
95939
96084
  };
95940
- exports.renderToFile = function renderToFile(path77, qrData, options, cb) {
96085
+ exports.renderToFile = function renderToFile(path73, qrData, options, cb) {
95941
96086
  if (typeof cb === "undefined") {
95942
96087
  cb = options;
95943
96088
  options = void 0;
95944
96089
  }
95945
96090
  const fs52 = __require("fs");
95946
96091
  const utf82 = exports.render(qrData, options);
95947
- fs52.writeFile(path77, utf82, cb);
96092
+ fs52.writeFile(path73, utf82, cb);
95948
96093
  };
95949
96094
  }
95950
96095
  });
@@ -96065,7 +96210,7 @@ var require_svg_tag = __commonJS({
96065
96210
  return str;
96066
96211
  }
96067
96212
  function qrToPath(data, size, margin) {
96068
- let path77 = "";
96213
+ let path73 = "";
96069
96214
  let moveBy = 0;
96070
96215
  let newRow = false;
96071
96216
  let lineLength = 0;
@@ -96076,19 +96221,19 @@ var require_svg_tag = __commonJS({
96076
96221
  if (data[i2]) {
96077
96222
  lineLength++;
96078
96223
  if (!(i2 > 0 && col > 0 && data[i2 - 1])) {
96079
- path77 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
96224
+ path73 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
96080
96225
  moveBy = 0;
96081
96226
  newRow = false;
96082
96227
  }
96083
96228
  if (!(col + 1 < size && data[i2 + 1])) {
96084
- path77 += svgCmd("h", lineLength);
96229
+ path73 += svgCmd("h", lineLength);
96085
96230
  lineLength = 0;
96086
96231
  }
96087
96232
  } else {
96088
96233
  moveBy++;
96089
96234
  }
96090
96235
  }
96091
- return path77;
96236
+ return path73;
96092
96237
  }
96093
96238
  exports.render = function render4(qrData, options, cb) {
96094
96239
  const opts = Utils.getOptions(options);
@@ -96096,10 +96241,10 @@ var require_svg_tag = __commonJS({
96096
96241
  const data = qrData.modules.data;
96097
96242
  const qrcodesize = size + opts.margin * 2;
96098
96243
  const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
96099
- const path77 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
96244
+ const path73 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
96100
96245
  const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
96101
96246
  const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
96102
- const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path77 + "</svg>\n";
96247
+ const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path73 + "</svg>\n";
96103
96248
  if (typeof cb === "function") {
96104
96249
  cb(null, svgTag);
96105
96250
  }
@@ -96113,7 +96258,7 @@ var require_svg = __commonJS({
96113
96258
  "../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(exports) {
96114
96259
  var svgTagRenderer = require_svg_tag();
96115
96260
  exports.render = svgTagRenderer.render;
96116
- exports.renderToFile = function renderToFile(path77, qrData, options, cb) {
96261
+ exports.renderToFile = function renderToFile(path73, qrData, options, cb) {
96117
96262
  if (typeof cb === "undefined") {
96118
96263
  cb = options;
96119
96264
  options = void 0;
@@ -96121,7 +96266,7 @@ var require_svg = __commonJS({
96121
96266
  const fs52 = __require("fs");
96122
96267
  const svgTag = exports.render(qrData, options);
96123
96268
  const xmlStr = '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' + svgTag;
96124
- fs52.writeFile(path77, xmlStr, cb);
96269
+ fs52.writeFile(path73, xmlStr, cb);
96125
96270
  };
96126
96271
  }
96127
96272
  });
@@ -96279,8 +96424,8 @@ var require_server = __commonJS({
96279
96424
  cb
96280
96425
  };
96281
96426
  }
96282
- function getTypeFromFilename(path77) {
96283
- return path77.slice((path77.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
96427
+ function getTypeFromFilename(path73) {
96428
+ return path73.slice((path73.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
96284
96429
  }
96285
96430
  function getRendererFromType(type) {
96286
96431
  switch (type) {
@@ -96344,17 +96489,17 @@ var require_server = __commonJS({
96344
96489
  const renderer2 = getRendererFromType(params.opts.type);
96345
96490
  return render4(renderer2.renderToBuffer, text3, params);
96346
96491
  };
96347
- exports.toFile = function toFile(path77, text3, opts, cb) {
96348
- if (typeof path77 !== "string" || !(typeof text3 === "string" || typeof text3 === "object")) {
96492
+ exports.toFile = function toFile(path73, text3, opts, cb) {
96493
+ if (typeof path73 !== "string" || !(typeof text3 === "string" || typeof text3 === "object")) {
96349
96494
  throw new Error("Invalid argument");
96350
96495
  }
96351
96496
  if (arguments.length < 3 && !canPromise()) {
96352
96497
  throw new Error("Too few arguments provided");
96353
96498
  }
96354
96499
  const params = checkParams(text3, opts, cb);
96355
- const type = params.opts.type || getTypeFromFilename(path77);
96500
+ const type = params.opts.type || getTypeFromFilename(path73);
96356
96501
  const renderer2 = getRendererFromType(type);
96357
- const renderToFile = renderer2.renderToFile.bind(null, path77);
96502
+ const renderToFile = renderer2.renderToFile.bind(null, path73);
96358
96503
  return render4(renderToFile, text3, params);
96359
96504
  };
96360
96505
  exports.toFileStream = function toFileStream(stream2, text3, opts) {
@@ -97461,8 +97606,8 @@ function formatIssues(error, raw) {
97461
97606
  const field = rest.join(".");
97462
97607
  return field ? `${where}: ${field} ${msg}` : `${where} ${msg}`;
97463
97608
  }
97464
- const path77 = iss.path.join(".");
97465
- return path77 ? `${path77} ${msg}` : `workflow ${msg}`;
97609
+ const path73 = iss.path.join(".");
97610
+ return path73 ? `${path73} ${msg}` : `workflow ${msg}`;
97466
97611
  });
97467
97612
  }
97468
97613
  function validateWorkflow(raw) {
@@ -97832,7 +97977,7 @@ var init_schema2 = __esm({
97832
97977
  }
97833
97978
  });
97834
97979
  function defaultUserWorkflowsDir() {
97835
- return path3.join(os.homedir(), ".moxxy", "workflows");
97980
+ return moxxyPath("workflows");
97836
97981
  }
97837
97982
  function defaultProjectWorkflowsDir(cwd2) {
97838
97983
  return path3.join(cwd2, ".moxxy", "workflows");
@@ -100140,7 +100285,8 @@ function buildWorkflowRunner(args) {
100140
100285
  return { runNow, resumeNow };
100141
100286
  }
100142
100287
  function activeModel(session) {
100143
- return session.lastResolvedModel ?? safeActiveProvider(session)?.models[0]?.id ?? "default";
100288
+ const provider = safeActiveProvider(session);
100289
+ return (provider ? resolveTurnModel(session, provider) : session.lastResolvedModel) ?? "default";
100144
100290
  }
100145
100291
  function safeActiveProvider(session) {
100146
100292
  try {
@@ -103069,7 +103215,7 @@ __export(dist_exports4, {
103069
103215
  note: () => note,
103070
103216
  outro: () => outro,
103071
103217
  password: () => password,
103072
- path: () => path59,
103218
+ path: () => path58,
103073
103219
  progress: () => progress,
103074
103220
  select: () => select,
103075
103221
  selectKey: () => selectKey,
@@ -103168,7 +103314,7 @@ function progress({
103168
103314
  message: (t2) => g2(0, t2)
103169
103315
  };
103170
103316
  }
103171
- var import_sisteransi2, unicode, isCI, isTTY, unicodeOr, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_BAR_START, S_BAR, S_BAR_END, S_BAR_START_RIGHT, S_BAR_END_RIGHT, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_CHECKBOX_ACTIVE, S_CHECKBOX_SELECTED, S_CHECKBOX_INACTIVE, S_PASSWORD_MASK, S_BAR_H, S_CORNER_TOP_RIGHT, S_CONNECT_LEFT, S_CORNER_BOTTOM_RIGHT, S_CORNER_BOTTOM_LEFT, S_CORNER_TOP_LEFT, S_INFO, S_SUCCESS, S_WARN, S_ERROR, symbol, symbolBar, I, limitOptions, autocomplete, autocompleteMultiselect, K, Q, U2, box, confirm, date, p2, group, MULTISELECT_INSTRUCTIONS, m2, multiselect, groupMultiselect, log, cancel, intro, outro, multiline, W$1, C2, note, password, path59, W, spinner, u4, SELECT_INSTRUCTIONS, c2, select, selectKey, i, stream, tasks, A, taskLog, text2;
103317
+ var import_sisteransi2, unicode, isCI, isTTY, unicodeOr, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_BAR_START, S_BAR, S_BAR_END, S_BAR_START_RIGHT, S_BAR_END_RIGHT, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_CHECKBOX_ACTIVE, S_CHECKBOX_SELECTED, S_CHECKBOX_INACTIVE, S_PASSWORD_MASK, S_BAR_H, S_CORNER_TOP_RIGHT, S_CONNECT_LEFT, S_CORNER_BOTTOM_RIGHT, S_CORNER_BOTTOM_LEFT, S_CORNER_TOP_LEFT, S_INFO, S_SUCCESS, S_WARN, S_ERROR, symbol, symbolBar, I, limitOptions, autocomplete, autocompleteMultiselect, K, Q, U2, box, confirm, date, p2, group, MULTISELECT_INSTRUCTIONS, m2, multiselect, groupMultiselect, log, cancel, intro, outro, multiline, W$1, C2, note, password, path58, W, spinner, u4, SELECT_INSTRUCTIONS, c2, select, selectKey, i, stream, tasks, A, taskLog, text2;
103172
103318
  var init_dist39 = __esm({
103173
103319
  "../../node_modules/.pnpm/@clack+prompts@1.8.1/node_modules/@clack/prompts/dist/index.mjs"() {
103174
103320
  init_dist38();
@@ -104049,7 +104195,7 @@ ${n3}
104049
104195
  }
104050
104196
  }
104051
104197
  }).prompt();
104052
- path59 = (e) => {
104198
+ path58 = (e) => {
104053
104199
  const a2 = e.validate;
104054
104200
  return autocomplete({
104055
104201
  ...e,
@@ -105048,6 +105194,7 @@ async function setupSessionWithConfig(opts) {
105048
105194
  applyPluginsTree(session, config, logger);
105049
105195
  assertCriticalFloors(session);
105050
105196
  applyContextConfig(session, config.context);
105197
+ session.defaultModels = configuredDefaultModels(config);
105051
105198
  await applySessionHeaderPreferences(session, opts.sessionId, credentialResolver, logger);
105052
105199
  progress2({ kind: "prefs-applied" });
105053
105200
  const discovered = await discoverSkills({
@@ -105108,6 +105255,7 @@ var init_setup = __esm({
105108
105255
  init_load_config();
105109
105256
  init_egress();
105110
105257
  init_context_config();
105258
+ init_default_models();
105111
105259
  init_secrets();
105112
105260
  init_apply_transcriber();
105113
105261
  init_config_trust_prompt();
@@ -106735,11 +106883,11 @@ function servicePlatform() {
106735
106883
  if (process.platform === "linux") return "linux";
106736
106884
  return "unsupported";
106737
106885
  }
106738
- function moxxyHome3() {
106886
+ function moxxyHome4() {
106739
106887
  return process.env.MOXXY_HOME ?? path3__default.join(homedir(), ".moxxy");
106740
106888
  }
106741
106889
  function serviceLogPath(spec) {
106742
- return path3__default.join(moxxyHome3(), "services", `${spec.id}.log`);
106890
+ return path3__default.join(moxxyHome4(), "services", `${spec.id}.log`);
106743
106891
  }
106744
106892
  function nodeBin() {
106745
106893
  return process.execPath;
@@ -108331,9 +108479,6 @@ var perms_exports = {};
108331
108479
  __export(perms_exports, {
108332
108480
  runPermsCommand: () => runPermsCommand
108333
108481
  });
108334
- function policyPath() {
108335
- return path3.join(os.homedir(), ".moxxy", "permissions.json");
108336
- }
108337
108482
  async function runPermsCommand(argv) {
108338
108483
  if (helpRequested(argv)) {
108339
108484
  process.stdout.write(HELP7);
@@ -108347,13 +108492,13 @@ async function runPermsCommand(argv) {
108347
108492
  init_dist29().then(() => dist_exports3)
108348
108493
  ]);
108349
108494
  const { waitUntilExit } = render4(
108350
- React56.createElement(PermissionEditor2, { policyPath: policyPath() })
108495
+ React56.createElement(PermissionEditor2, { policyPath: userPolicyPath() })
108351
108496
  );
108352
108497
  await waitUntilExit();
108353
108498
  return 0;
108354
108499
  }
108355
108500
  const cmd = sub ?? "list";
108356
- const engine = await PermissionEngine.load(policyPath());
108501
+ const engine = await PermissionEngine.load(userPolicyPath());
108357
108502
  switch (cmd) {
108358
108503
  case "list": {
108359
108504
  const policy = engine.policySnapshot;
@@ -108424,7 +108569,7 @@ ${HELP7}`);
108424
108569
  return 0;
108425
108570
  }
108426
108571
  case "path": {
108427
- process.stdout.write(policyPath() + "\n");
108572
+ process.stdout.write(userPolicyPath() + "\n");
108428
108573
  return 0;
108429
108574
  }
108430
108575
  default:
@@ -108437,6 +108582,7 @@ var HELP7;
108437
108582
  var init_perms = __esm({
108438
108583
  async "src/commands/perms.ts"() {
108439
108584
  init_dist2();
108585
+ init_user_policy_path();
108440
108586
  await init_argv_helpers();
108441
108587
  init_errors();
108442
108588
  init_colors();
@@ -110658,6 +110804,8 @@ var init_daemon = __esm({
110658
110804
  init_schedule_daemon_svc();
110659
110805
  }
110660
110806
  });
110807
+
110808
+ // src/commands/schedule/setup-cmd.ts
110661
110809
  async function runScheduleSetup(argv) {
110662
110810
  const allowFlag = argv.flags.allow;
110663
110811
  const tools = typeof allowFlag === "string" ? allowFlag.split(",").map((s) => s.trim()).filter(Boolean) : DEFAULT_HEADLESS_ALLOW_TOOLS;
@@ -110680,8 +110828,8 @@ async function stepAllowTools(tools) {
110680
110828
  `);
110681
110829
  return;
110682
110830
  }
110683
- const policyPath2 = path3.join(os.homedir(), ".moxxy", "permissions.json");
110684
- const engine = await PermissionEngine.load(policyPath2);
110831
+ const policyPath = userPolicyPath();
110832
+ const engine = await PermissionEngine.load(policyPath);
110685
110833
  const before = engine.policySnapshot;
110686
110834
  const existingAllowNames = new Set(before.allow.map((r2) => r2.name));
110687
110835
  const added = [];
@@ -110696,7 +110844,7 @@ async function stepAllowTools(tools) {
110696
110844
  }
110697
110845
  process.stdout.write(
110698
110846
  `${tag(true)} ${colors.bold("allow")} ` + (added.length > 0 ? colors.bold(added.join(", ")) : colors.dim("(none new)")) + (skipped.length > 0 ? colors.dim(` [already allowed: ${skipped.join(", ")}]`) : "") + `
110699
- ${colors.dim("\u2192 " + policyPath2)}
110847
+ ${colors.dim("\u2192 " + policyPath)}
110700
110848
  `
110701
110849
  );
110702
110850
  }
@@ -110762,6 +110910,7 @@ var init_setup_cmd = __esm({
110762
110910
  init_colors();
110763
110911
  await init_setup();
110764
110912
  init_schedule_daemon_svc();
110913
+ init_user_policy_path();
110765
110914
  DEFAULT_HEADLESS_ALLOW_TOOLS = ["telegram_send_message", "web_fetch"];
110766
110915
  tag = (ok) => ok ? colors.bold("ok ") : colors.red("fail");
110767
110916
  }
@@ -110991,6 +111140,7 @@ var doctor_exports = {};
110991
111140
  __export(doctor_exports, {
110992
111141
  buildAuditExportDoctorCheck: () => buildAuditExportDoctorCheck,
110993
111142
  buildEgressDoctorCheck: () => buildEgressDoctorCheck,
111143
+ buildMemoryDoctorCheck: () => buildMemoryDoctorCheck,
110994
111144
  buildPluginDoctorChecks: () => buildPluginDoctorChecks,
110995
111145
  buildPolicyDoctorCheck: () => buildPolicyDoctorCheck,
110996
111146
  buildSelfUpdateDoctorCheck: () => buildSelfUpdateDoctorCheck,
@@ -111123,34 +111273,7 @@ async function runDoctorChecks(deps) {
111123
111273
  }
111124
111274
  checks.push(buildVoiceDoctorCheck(session, await checkVoiceCaptureAvailable()));
111125
111275
  checks.push(...buildPluginDoctorChecks(pluginRegistration));
111126
- if (!memory) {
111127
- checks.push({
111128
- id: "memory",
111129
- status: "warn",
111130
- message: "memory extension not installed \u2014 long-term memory off (moxxy extensions install @moxxy/plugin-memory)"
111131
- });
111132
- } else {
111133
- const memDir = path3.join(os.homedir(), ".moxxy", "memory");
111134
- const memRes = await tryCatch(async () => {
111135
- await promises.mkdir(memDir, { recursive: true });
111136
- await promises.access(memDir, promises.constants.W_OK);
111137
- const entries = await memory.list();
111138
- return { count: entries.length };
111139
- });
111140
- if (memRes.ok) {
111141
- checks.push({
111142
- id: "memory",
111143
- status: "ok",
111144
- message: `${memDir} writable (${memRes.value.count} entries)`
111145
- });
111146
- } else {
111147
- checks.push({
111148
- id: "memory",
111149
- status: "fail",
111150
- message: `${memDir} not writable: ${memRes.error}`
111151
- });
111152
- }
111153
- }
111276
+ checks.push(await buildMemoryDoctorCheck(memory));
111154
111277
  const allSkills = session.skills.list();
111155
111278
  checks.push({
111156
111279
  id: "skills",
@@ -111251,6 +111374,26 @@ function buildEgressDoctorCheck(config) {
111251
111374
  const hint = ca ? "" : " (set NODE_EXTRA_CA_CERTS if the proxy terminates TLS)";
111252
111375
  return { id: "network", status, message: `${via}${bypass}${caNote}${hint}` };
111253
111376
  }
111377
+ async function buildMemoryDoctorCheck(memory) {
111378
+ if (!memory) {
111379
+ return {
111380
+ id: "memory",
111381
+ status: "warn",
111382
+ message: "memory extension not installed \u2014 long-term memory off (moxxy extensions install @moxxy/plugin-memory)"
111383
+ };
111384
+ }
111385
+ const memDir = moxxyPath("memory");
111386
+ const memRes = await tryCatch(async () => {
111387
+ await promises.mkdir(memDir, { recursive: true });
111388
+ await promises.access(memDir, promises.constants.W_OK);
111389
+ const entries = await memory.list();
111390
+ return { count: entries.length };
111391
+ });
111392
+ if (memRes.ok) {
111393
+ return { id: "memory", status: "ok", message: `${memDir} writable (${memRes.value.count} entries)` };
111394
+ }
111395
+ return { id: "memory", status: "fail", message: `${memDir} not writable: ${memRes.error}` };
111396
+ }
111254
111397
  async function buildSelfUpdateDoctorCheck(session) {
111255
111398
  if (!session.tools.has("self_update_begin")) {
111256
111399
  return { id: "self-update", status: "warn", message: "disabled (plugin not loaded)" };
@@ -112948,7 +113091,7 @@ var init_skills4 = __esm({
112948
113091
  }
112949
113092
  ]
112950
113093
  });
112951
- AUDIT_PATH = () => path3.join(os.homedir(), ".moxxy", "skills", ".meta", "created.jsonl");
113094
+ AUDIT_PATH = () => moxxyPath("skills", ".meta", "created.jsonl");
112952
113095
  auditMutex = createMutex();
112953
113096
  }
112954
113097
  });
@@ -112975,7 +113118,7 @@ async function runPluginNewCommand(argv) {
112975
113118
  }
112976
113119
  const here = hasBoolFlag(argv, "here");
112977
113120
  const force = hasBoolFlag(argv, "force");
112978
- const root = here ? path3.join(process.cwd(), name) : path3.join(os.homedir(), ".moxxy", "plugins", name);
113121
+ const root = here ? path3.join(process.cwd(), name) : moxxyPath("plugins", name);
112979
113122
  try {
112980
113123
  const stat2 = await promises.stat(root);
112981
113124
  if (stat2.isDirectory() && !force) {
@@ -114566,9 +114709,6 @@ var self_update_exports = {};
114566
114709
  __export(self_update_exports, {
114567
114710
  runSelfUpdateCommand: () => runSelfUpdateCommand
114568
114711
  });
114569
- function moxxyDir() {
114570
- return path3.join(os.homedir(), ".moxxy");
114571
- }
114572
114712
  async function runSelfUpdateCommand(argv) {
114573
114713
  const sub = argv.positional[0] ?? "status";
114574
114714
  if (sub === "help" || helpRequested(argv)) {
@@ -114576,7 +114716,7 @@ async function runSelfUpdateCommand(argv) {
114576
114716
  return 0;
114577
114717
  }
114578
114718
  if (sub === "status") {
114579
- const dir = moxxyDir();
114719
+ const dir = moxxyHome();
114580
114720
  const txns = await listTransactions(dir);
114581
114721
  const core = await listCoreTxns(dir);
114582
114722
  process.stdout.write(colors.bold("Tier 1 \u2014 plugins / skills\n"));
@@ -114599,7 +114739,7 @@ async function runSelfUpdateCommand(argv) {
114599
114739
  printError("usage: moxxy self-update rollback <coreTxnId>");
114600
114740
  return 2;
114601
114741
  }
114602
- const dir = moxxyDir();
114742
+ const dir = moxxyHome();
114603
114743
  const journal = await readCoreJournal(dir, txnId).catch(() => null);
114604
114744
  if (!journal) {
114605
114745
  printError(`no core transaction "${txnId}" (only Tier-2 core txns can be rolled back from the CLI)`);