@wrongstack/cli 1.0.29 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/data/providers.json +8 -199
  2. package/dist/{acp-QWCBMQSO.js → acp-EDGUWU7N.js} +3 -6
  3. package/dist/{audit-46YK5DSC.js → audit-KCBTHUQI.js} +1 -1
  4. package/dist/{auth-TE55JF4Z.js → auth-SUHKFFO4.js} +136 -59
  5. package/dist/auth-menu/github-copilot-oauth.d.ts +1 -35
  6. package/dist/auth-menu/index-input.d.ts +3 -0
  7. package/dist/auth-menu/panel-flow-bridge.d.ts +29 -0
  8. package/dist/auth-menu/panel-service.d.ts +3 -34
  9. package/dist/auth-menu/provider-auth-login.d.ts +1 -1
  10. package/dist/auto-discover-providers-QIL34K3U.js +7 -0
  11. package/dist/automation-MCDFCIMV.js +369 -0
  12. package/dist/{bench-GTLPM22B.js → bench-MMZHFHDL.js} +152 -43
  13. package/dist/boot/brain-decision-log.d.ts +1 -1
  14. package/dist/boot/system-prompt-builder.d.ts +1 -1
  15. package/dist/boot/system-prompt-menu.d.ts +11 -2
  16. package/dist/boot/tui-coordinator-setup.d.ts +2 -0
  17. package/dist/boot/tui-startup-output.d.ts +11 -0
  18. package/dist/{boot-auto-thin-6Q56FY3F.js → boot-auto-thin-K2DHHYIW.js} +3 -3
  19. package/dist/{chronicle-UTFETHP6.js → chronicle-PBJS7BN6.js} +5 -3
  20. package/dist/{chunk-WRYZLEXP.js → chunk-2EZ2DHOW.js} +41 -7
  21. package/dist/{chunk-7IQWQCBH.js → chunk-3LEFXLAW.js} +39 -39
  22. package/dist/{chunk-WSTVGC2C.js → chunk-4BX2YDTQ.js} +13 -6
  23. package/dist/{chunk-SFBFYIOW.js → chunk-4MDRHMX4.js} +3 -2
  24. package/dist/{chunk-RDGGWMTI.js → chunk-65VNCAF6.js} +2 -22
  25. package/dist/{chunk-WQZW3RDP.js → chunk-7BNBD4PE.js} +2 -2
  26. package/dist/chunk-CFHWIFXL.js +123 -0
  27. package/dist/{chunk-RZ4ZDRYA.js → chunk-DIOODAYM.js} +2 -2
  28. package/dist/{chunk-L2RVEQWO.js → chunk-HHRYIDOW.js} +2 -2
  29. package/dist/{chunk-KT34LWIS.js → chunk-LIZXJHZQ.js} +28 -26
  30. package/dist/{chunk-YHYINL47.js → chunk-LKFKO4JW.js} +2 -2
  31. package/dist/{chunk-Q4INH2DG.js → chunk-MPQCHBDJ.js} +2 -1
  32. package/dist/{chunk-2ERX3RPN.js → chunk-P3GRLV47.js} +30 -17
  33. package/dist/{chunk-ZMX5HRLI.js → chunk-P3Q3KMFH.js} +6 -4
  34. package/dist/{chunk-KOEO4CJG.js → chunk-PGNERAZL.js} +4 -4
  35. package/dist/{chunk-6A7URMWN.js → chunk-RQ4UBKYH.js} +3 -3
  36. package/dist/{chunk-X756ZS72.js → chunk-SUDNPYWD.js} +2 -2
  37. package/dist/{chunk-LDCGZJTC.js → chunk-TWSQTQKR.js} +12 -4
  38. package/dist/chunk-TXAFIERF.js +37 -0
  39. package/dist/{chunk-BZHT5GPF.js → chunk-WHEYHDIE.js} +2 -2
  40. package/dist/{chunk-LBPLTTZ6.js → chunk-WTJDSTYD.js} +4 -4
  41. package/dist/{chunk-IFQ6NQPL.js → chunk-WXJH4F6K.js} +7 -7
  42. package/dist/{chunk-IS2PPBQV.js → chunk-X4LW5CZM.js} +8 -4
  43. package/dist/{chunk-BBHWW6LR.js → chunk-YL4KCHZG.js} +18 -6
  44. package/dist/{chunk-LUMETJFO.js → chunk-ZYACRPLN.js} +2 -2
  45. package/dist/{cli-context-6RONY47P.js → cli-context-ITHGP2CE.js} +83 -76
  46. package/dist/cli-context.d.ts +3 -1
  47. package/dist/cli-infrastructure.d.ts +33 -0
  48. package/dist/{cli-main-YS3HIOSD.js → cli-main-TQGLKB6D.js} +3768 -2748
  49. package/dist/config-doctor.d.ts +1 -1
  50. package/dist/{config-transfer-RUWLDCNK.js → config-transfer-UE37X4B5.js} +2 -2
  51. package/dist/{execution-JEYF2L7O.js → execution-C2IECWF7.js} +4981 -4836
  52. package/dist/execution-chimera-handlers.d.ts +6 -0
  53. package/dist/execution-session-callbacks.d.ts +36 -0
  54. package/dist/execution-webui.d.ts +3 -0
  55. package/dist/execution.d.ts +1 -1
  56. package/dist/fleet/host-acp-runner.d.ts +15 -0
  57. package/dist/fleet/host-budget.d.ts +13 -0
  58. package/dist/fleet/host-context.d.ts +5 -0
  59. package/dist/fleet/host-explore-companion.d.ts +6 -15
  60. package/dist/fleet/host.d.ts +2 -0
  61. package/dist/fleet/status-broadcast.d.ts +1 -1
  62. package/dist/{hq-BNK67HOE.js → hq-KBFDKTDD.js} +13 -7
  63. package/dist/{hq-server-PCQACV7Y.js → hq-server-AVNKZ2PV.js} +2 -2
  64. package/dist/{hq-service-BMMJAHRT.js → hq-service-FGB7BY2D.js} +3 -3
  65. package/dist/index.js +126 -10
  66. package/dist/{mailbox-serve-FW3JCCPK.js → mailbox-serve-S536N66F.js} +3 -2
  67. package/dist/{modeldiag-W7XAE625.js → modeldiag-PQILD7TN.js} +26 -8
  68. package/dist/{per-subcommand-help-MWQWFIAV.js → per-subcommand-help-VKPV3OEY.js} +2 -2
  69. package/dist/{plugin-usage-CIGOOTX3.js → plugin-usage-3TZGROK7.js} +3 -3
  70. package/dist/{plugins-HQTXUD6A.js → plugins-ITH4SLO6.js} +4 -4
  71. package/dist/pre-launch/project-check.d.ts +2 -8
  72. package/dist/pre-launch.d.ts +1 -1
  73. package/dist/{project-manifest-7NSFVBM3.js → project-manifest-FTFDCCTZ.js} +2 -2
  74. package/dist/{project-picker-SVBXMPKX.js → project-picker-NZYJKQQC.js} +3 -3
  75. package/dist/provider-cloud-config.d.ts +4 -0
  76. package/dist/provider-config-utils.d.ts +1 -1
  77. package/dist/{providers-models-5Z2PJTEW.js → providers-models-W57I3QOA.js} +3 -3
  78. package/dist/{remote-GB5VXCCT.js → remote-C74BCNND.js} +5 -5
  79. package/dist/{rewind-JA3ZLCNM.js → rewind-7AULJS7F.js} +7 -5
  80. package/dist/sandbox-TYGD6FI2.js +131 -0
  81. package/dist/services/sdd/project-context.d.ts +1 -1
  82. package/dist/{sessions-config-JGIZRNT6.js → sessions-config-VE26SB56.js} +5 -5
  83. package/dist/short-circuit-flags-6LB3EGF7.js +10 -0
  84. package/dist/slash-commands/openai-quota.d.ts +12 -6
  85. package/dist/slash-commands/sandbox.d.ts +5 -0
  86. package/dist/slash-commands/scout-stats.d.ts +46 -0
  87. package/dist/slash-commands/sdd-inspect-commands.d.ts +9 -0
  88. package/dist/slash-commands/sdd-session-commands.d.ts +19 -0
  89. package/dist/slash-commands/sdd.d.ts +1 -1
  90. package/dist/slash-commands/zai-plan.d.ts +26 -0
  91. package/dist/{standalone-auto-update-TOTRGCSA.js → standalone-auto-update-VQC4GYCM.js} +3 -3
  92. package/dist/{standalone-update-LZO3MNLH.js → standalone-update-HZHDZZOR.js} +2 -2
  93. package/dist/subcommands/handlers/automation-credentials.d.ts +8 -0
  94. package/dist/subcommands/handlers/automation.d.ts +3 -0
  95. package/dist/subcommands/handlers/bench-experiments.d.ts +5 -0
  96. package/dist/subcommands/handlers/sandbox.d.ts +5 -0
  97. package/dist/{subcommands-WX4GDMWB.js → subcommands-QO7VYTSS.js} +2 -2
  98. package/dist/{tools-skills-GH24UCBY.js → tools-skills-33AI6K6S.js} +2 -2
  99. package/dist/tui-provider-quota-menu.d.ts +5 -0
  100. package/dist/{typesafe-WA5O3KVS.js → typesafe-NHC322W5.js} +27 -8
  101. package/dist/{typesafe-topic-replay-ZILIU3WS.js → typesafe-topic-replay-DB2AYL7V.js} +2 -2
  102. package/dist/{typesafe-triage-replay-FGAW7QM7.js → typesafe-triage-replay-27NDAZ3V.js} +2 -2
  103. package/dist/{update-TDZX4IL2.js → update-J5WHAFPE.js} +3 -3
  104. package/dist/{update-check-J5ZVKS73.js → update-check-VLVT4IV2.js} +2 -2
  105. package/dist/{version-help-HN32QYQN.js → version-help-ATOKGMTK.js} +2 -2
  106. package/dist/webui-server/prefs-seeding.d.ts +1 -0
  107. package/dist/webui-server/route-contexts.d.ts +1 -0
  108. package/dist/{webui-server-EXJWLB3X.js → webui-server-GQOVLQS3.js} +71 -34
  109. package/dist/webui-session-retirement.d.ts +10 -0
  110. package/dist/wiring/command-host-state.d.ts +2 -0
  111. package/dist/wiring/director-announcement.d.ts +3 -1
  112. package/dist/wiring/session-establishment.d.ts +10 -8
  113. package/dist/wiring/session-runtime.d.ts +1 -1
  114. package/dist/wiring/session.d.ts +3 -0
  115. package/package.json +30 -30
  116. package/dist/auto-discover-providers-DXR25GTG.js +0 -7
  117. package/dist/chunk-D5GB5MHA.js +0 -87
  118. package/dist/chunk-SIGUWXAA.js +0 -43
  119. package/dist/short-circuit-flags-5N2LPK4R.js +0 -10
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mutateConfigProviders
3
- } from "./chunk-LUMETJFO.js";
3
+ } from "./chunk-ZYACRPLN.js";
4
4
  import {
5
5
  activeProfileConfigPath
6
6
  } from "./chunk-YMXXOOFN.js";
@@ -8,13 +8,22 @@ import {
8
8
  // src/wiring/provider-persisters.ts
9
9
  import {
10
10
  applyProviderOAuthRefresh,
11
+ createSubscriptionRefreshTransaction,
11
12
  matchesActiveProviderCredential,
13
+ setAccountQuotaReporting,
12
14
  setOAuthTokenPersister,
13
- setProviderModelPersister
15
+ setProviderModelPersister,
16
+ setSubscriptionRefreshTransaction
14
17
  } from "@wrongstack/providers";
15
18
  import { applyProviderOAuthRefresh as applyProviderOAuthRefresh2 } from "@wrongstack/providers";
16
19
  function installProviderPersisters(args) {
17
20
  const profileConfigPath = activeProfileConfigPath(args.paths, args.config);
21
+ setAccountQuotaReporting(true);
22
+ setSubscriptionRefreshTransaction(
23
+ createSubscriptionRefreshTransaction(
24
+ (mutator) => mutateConfigProviders(profileConfigPath, args.vault, mutator)
25
+ )
26
+ );
18
27
  setOAuthTokenPersister((providerId, creds, source) => {
19
28
  void mutateConfigProviders(profileConfigPath, args.vault, (all) => {
20
29
  const p = all[providerId];
@@ -27,7 +36,6 @@ function installProviderPersisters(args) {
27
36
  );
28
37
  });
29
38
  setProviderModelPersister((providerId, models, source) => {
30
- if (models.length === 0) return;
31
39
  void mutateConfigProviders(profileConfigPath, args.vault, (all) => {
32
40
  const p = all[providerId];
33
41
  if (!p) return;
@@ -43,4 +51,4 @@ export {
43
51
  installProviderPersisters,
44
52
  applyProviderOAuthRefresh2 as applyProviderOAuthRefresh
45
53
  };
46
- //# sourceMappingURL=chunk-LDCGZJTC.js.map
54
+ //# sourceMappingURL=chunk-TWSQTQKR.js.map
@@ -0,0 +1,37 @@
1
+ import {
2
+ loadConfigProviders,
3
+ mutateConfigProviders
4
+ } from "./chunk-ZYACRPLN.js";
5
+
6
+ // src/provider-cloud-config.ts
7
+ import {
8
+ cloudFieldsForProvider,
9
+ parseNativeCloudSettings
10
+ } from "@wrongstack/core/cloud-provider";
11
+ async function providerCloudConfig(id, updates, configPath, vault) {
12
+ if (!/^[\w.-]{1,128}$/.test(id) || ["__proto__", "constructor", "prototype"].includes(id))
13
+ throw new Error("Invalid provider id");
14
+ if (updates === void 0) {
15
+ const providers = await loadConfigProviders(configPath, vault);
16
+ if (!Object.hasOwn(providers, id)) throw new Error("Saved provider not found");
17
+ return parseNativeCloudSettings(providers[id]?.cloud ?? {});
18
+ }
19
+ let saved = {};
20
+ await mutateConfigProviders(configPath, vault, (providers) => {
21
+ if (!Object.hasOwn(providers, id)) throw new Error("Saved provider not found");
22
+ const provider = providers[id];
23
+ const fields = cloudFieldsForProvider(provider.type || id);
24
+ if (!fields.length) throw new Error("This provider has no native cloud routing settings");
25
+ const parsed = updates === null ? {} : parseNativeCloudSettings(updates);
26
+ if (Object.keys(parsed).some((field) => !fields.includes(field)))
27
+ throw new Error("Cloud setting does not apply to this provider");
28
+ saved = updates === null ? {} : parseNativeCloudSettings({ ...provider.cloud, ...updates });
29
+ provider.cloud = saved;
30
+ });
31
+ return saved;
32
+ }
33
+
34
+ export {
35
+ providerCloudConfig
36
+ };
37
+ //# sourceMappingURL=chunk-TXAFIERF.js.map
@@ -83,7 +83,7 @@ var helpCmd = async (_args, deps) => {
83
83
  ["--provider <id> --model <id>", "Provider and model for this run"],
84
84
  ["--fallback-model <a,b,...>", "Models to fall back to when the primary is unavailable"],
85
85
  ["--effort <level>", "Reasoning effort: none|minimal|low|medium|high|xhigh|max"],
86
- ["--system-prompt lite|pro|default", "Bundled system-prompt variant"],
86
+ ["--system-prompt lite|pro|scout|default", "Bundled system-prompt variant"],
87
87
  [
88
88
  "--append-system-prompt <text> | --append-system-prompt-file <path>",
89
89
  "Add instructions to the host agent prompt for this run"
@@ -156,4 +156,4 @@ export {
156
156
  versionCmd,
157
157
  helpCmd
158
158
  };
159
- //# sourceMappingURL=chunk-BZHT5GPF.js.map
159
+ //# sourceMappingURL=chunk-WHEYHDIE.js.map
@@ -23,8 +23,8 @@ var APPLIED_FMT = `
23
23
  `;
24
24
  async function printStandaloneUpdateNotice(info, config) {
25
25
  const [{ autoUpdateEnabled, standaloneUpdater, takeAppliedUpdate }, { isNewer }, version] = await Promise.all([
26
- import("./standalone-auto-update-TOTRGCSA.js"),
27
- import("./update-check-J5ZVKS73.js"),
26
+ import("./standalone-auto-update-VQC4GYCM.js"),
27
+ import("./update-check-VLVT4IV2.js"),
28
28
  import("./version-JB2UAV2A.js")
29
29
  ]);
30
30
  const applied = takeAppliedUpdate();
@@ -47,7 +47,7 @@ async function printUpdateNotice(initialUpdateInfo, config) {
47
47
  const ac = new AbortController();
48
48
  const timer = setTimeout(() => ac.abort(), 2e3);
49
49
  try {
50
- const { checkForUpdate } = await import("./update-check-J5ZVKS73.js");
50
+ const { checkForUpdate } = await import("./update-check-VLVT4IV2.js");
51
51
  info = await checkForUpdate(ac.signal);
52
52
  } catch {
53
53
  } finally {
@@ -102,4 +102,4 @@ export {
102
102
  applySessionShellDefault,
103
103
  runPreflight
104
104
  };
105
- //# sourceMappingURL=chunk-LBPLTTZ6.js.map
105
+ //# sourceMappingURL=chunk-WTJDSTYD.js.map
@@ -1,10 +1,10 @@
1
+ import {
2
+ parseArgs
3
+ } from "./chunk-MPQCHBDJ.js";
1
4
  import {
2
5
  helpCmd,
3
6
  versionCmd
4
- } from "./chunk-BZHT5GPF.js";
5
- import {
6
- parseArgs
7
- } from "./chunk-Q4INH2DG.js";
7
+ } from "./chunk-WHEYHDIE.js";
8
8
 
9
9
  // src/boot/short-circuit-flags.ts
10
10
  async function handleHelpVersionShortCircuit(argv) {
@@ -22,11 +22,11 @@ async function handleHelpVersionShortCircuit(argv) {
22
22
  }
23
23
  if (earlyFlags["help"] === true) {
24
24
  if (positional.length > 0) {
25
- const { subcommandNames } = await import("./subcommands-WX4GDMWB.js");
25
+ const { subcommandNames } = await import("./subcommands-QO7VYTSS.js");
26
26
  if (subcommandNames.includes(positional[0])) {
27
27
  const first = positional[0];
28
28
  const deep = positional[1];
29
- const { renderDeepHelp, renderFocusedHelp } = await import("./per-subcommand-help-MWQWFIAV.js");
29
+ const { renderDeepHelp, renderFocusedHelp } = await import("./per-subcommand-help-VKPV3OEY.js");
30
30
  if (deep && renderDeepHelp(`${first}:${deep}`, stubRenderer)) {
31
31
  return 0;
32
32
  }
@@ -43,4 +43,4 @@ async function handleHelpVersionShortCircuit(argv) {
43
43
  export {
44
44
  handleHelpVersionShortCircuit
45
45
  };
46
- //# sourceMappingURL=chunk-IFQ6NQPL.js.map
46
+ //# sourceMappingURL=chunk-WXJH4F6K.js.map
@@ -4,7 +4,12 @@ import { createHash } from "node:crypto";
4
4
  import * as fs from "node:fs/promises";
5
5
  import * as path from "node:path";
6
6
  import { ConfigError } from "@wrongstack/core/types";
7
- import { readProjectIdentity, withFileLock, wstackGlobalRoot } from "@wrongstack/core/utils";
7
+ import {
8
+ atomicWrite,
9
+ readProjectIdentity,
10
+ withFileLock,
11
+ wstackGlobalRoot
12
+ } from "@wrongstack/core/utils";
8
13
  function projectsJsonPath(globalConfigPath) {
9
14
  const base = globalConfigPath ? path.dirname(globalConfigPath) : wstackGlobalRoot();
10
15
  return path.join(base, "projects.json");
@@ -44,8 +49,7 @@ async function loadManifest(globalConfigPath) {
44
49
  }
45
50
  async function saveManifest(manifest, globalConfigPath) {
46
51
  const file = projectsJsonPath(globalConfigPath);
47
- await fs.mkdir(path.dirname(file), { recursive: true });
48
- await fs.writeFile(file, JSON.stringify(manifest, null, 2), "utf8");
52
+ await atomicWrite(file, JSON.stringify(manifest, null, 2), { encoding: "utf8" });
49
53
  }
50
54
  function generateSlug(root) {
51
55
  const base = path.basename(root).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "project";
@@ -116,4 +120,4 @@ export {
116
120
  ensureProjectDataDir,
117
121
  touchProjectInManifest
118
122
  };
119
- //# sourceMappingURL=chunk-IS2PPBQV.js.map
123
+ //# sourceMappingURL=chunk-X4LW5CZM.js.map
@@ -83,7 +83,10 @@ var MODEL_PROFILES = [
83
83
  ];
84
84
  function fmtTokens(n) {
85
85
  if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
86
- if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
86
+ if (n >= 1e3) {
87
+ const k = (n / 1e3).toFixed(1);
88
+ return Number(k) < 1e3 ? `${k}k` : `${(n / 1e6).toFixed(1)}M`;
89
+ }
87
90
  return String(n);
88
91
  }
89
92
  function fmtMs(ms) {
@@ -322,7 +325,16 @@ async function runModeldiagEval(args, deps, providers, config, hasKey) {
322
325
  const providerFilter = providersValue ? providersValue.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
323
326
  const maxEq = evalArgs.find((a) => a.startsWith("--max="));
324
327
  const maxValue = maxEq?.replace("--max=", "") ?? (typeof deps.flags?.["max"] === "string" ? deps.flags["max"] : void 0);
325
- const maxModels = maxValue ? Math.max(1, parseInt(maxValue, 10) || 2) : 2;
328
+ let maxModels = 2;
329
+ if (maxValue !== void 0) {
330
+ const rawMax = maxValue.trim();
331
+ const parsedMax = /^\d+$/.test(rawMax) ? Number(rawMax) : Number.NaN;
332
+ if (!Number.isSafeInteger(parsedMax) || parsedMax < 1) {
333
+ writeLine(`${color2.amber(`Invalid --max value "${maxValue}". Use a positive integer.`)}`);
334
+ return 1;
335
+ }
336
+ maxModels = parsedMax;
337
+ }
326
338
  const quick = evalArgs.includes("--quick") || deps.flags?.["quick"] === true || deps.flags?.["quick"] === "true";
327
339
  const modelsPerCat = quick ? 1 : maxModels;
328
340
  const roleFilter = evalArgs.find((a) => !a.startsWith("--"));
@@ -369,9 +381,9 @@ ${color2.dim('Enter numbers or provider IDs (comma-separated, or "all"):')}
369
381
  } else {
370
382
  targetProviderIds = [];
371
383
  for (const part of selected.split(",").map((s) => s.trim())) {
372
- const idx = parseInt(part, 10);
373
- if (idx >= 1 && idx <= keyedProviderIds.length) {
374
- const pid = keyedProviderIds[idx - 1];
384
+ const index = /^\d+$/.test(part) ? Number(part) : Number.NaN;
385
+ if (Number.isSafeInteger(index) && index >= 1 && index <= keyedProviderIds.length) {
386
+ const pid = keyedProviderIds[index - 1];
375
387
  if (!targetProviderIds.includes(pid)) targetProviderIds.push(pid);
376
388
  } else if (keyedProviderIds.includes(part)) {
377
389
  if (!targetProviderIds.includes(part)) targetProviderIds.push(part);
@@ -546,4 +558,4 @@ export {
546
558
  createProviderForId,
547
559
  runModeldiagEval
548
560
  };
549
- //# sourceMappingURL=chunk-BBHWW6LR.js.map
561
+ //# sourceMappingURL=chunk-YL4KCHZG.js.map
@@ -140,7 +140,7 @@ async function mutateConfigProviders(configPath, vault, mutator, profileConfigPa
140
140
  decrypted["model"],
141
141
  typeof decrypted["provider"] === "string" ? providers[decrypted["provider"]] : void 0
142
142
  ]);
143
- mutator(providers, decrypted);
143
+ await mutator(providers, decrypted);
144
144
  for (const id of previousProviderIds) {
145
145
  if (!Object.hasOwn(providers, id)) removeProviderFallbackReferences(decrypted, id);
146
146
  }
@@ -168,4 +168,4 @@ export {
168
168
  mutateConfigProviders,
169
169
  nowIso
170
170
  };
171
- //# sourceMappingURL=chunk-LUMETJFO.js.map
171
+ //# sourceMappingURL=chunk-ZYACRPLN.js.map
@@ -2,6 +2,10 @@ import {
2
2
  parseOutputFormat,
3
3
  resolveJsonSchemaFlag
4
4
  } from "./chunk-LKPEBZBE.js";
5
+ import {
6
+ parseWebuiSessionChildOptions,
7
+ writeWebuiSessionChildError
8
+ } from "./chunk-P3Q3KMFH.js";
5
9
  import {
6
10
  activateRestrictedMode,
7
11
  announceSafeMode,
@@ -21,26 +25,22 @@ import {
21
25
  fmtTok,
22
26
  patchConfig
23
27
  } from "./chunk-EWKESL4L.js";
24
- import {
25
- parseWebuiSessionChildOptions,
26
- writeWebuiSessionChildError
27
- } from "./chunk-ZMX5HRLI.js";
28
28
  import {
29
29
  resolveLaunchMcpServers
30
30
  } from "./chunk-HLSHFXTO.js";
31
31
  import {
32
32
  subcommands
33
- } from "./chunk-KT34LWIS.js";
33
+ } from "./chunk-LIZXJHZQ.js";
34
34
  import {
35
35
  renderDeepHelp,
36
36
  renderFocusedHelp
37
- } from "./chunk-WRYZLEXP.js";
37
+ } from "./chunk-2EZ2DHOW.js";
38
38
  import {
39
39
  handleHelpVersionShortCircuit
40
- } from "./chunk-IFQ6NQPL.js";
40
+ } from "./chunk-WXJH4F6K.js";
41
41
  import {
42
42
  DEFAULT_PORT
43
- } from "./chunk-6A7URMWN.js";
43
+ } from "./chunk-RQ4UBKYH.js";
44
44
  import "./chunk-HXJYHAR4.js";
45
45
  import {
46
46
  resolveHqPasswordInput
@@ -48,44 +48,28 @@ import {
48
48
  import {
49
49
  normalizeHqPublicOrigin
50
50
  } from "./chunk-5EA6OTLJ.js";
51
- import {
52
- installProviderPersisters
53
- } from "./chunk-LDCGZJTC.js";
54
51
  import {
55
52
  parseHqIpAllowlist
56
53
  } from "./chunk-Q7E3BPDU.js";
57
54
  import {
58
- discoverAndMergeProviders
59
- } from "./chunk-D5GB5MHA.js";
60
- import {
61
- runUpdateCommand
62
- } from "./chunk-KOEO4CJG.js";
63
- import "./chunk-U3SS4NRH.js";
64
- import {
65
- applyNodeEnvDefault,
66
- applySessionShellDefault,
67
- runPreflight
68
- } from "./chunk-LBPLTTZ6.js";
69
- import "./chunk-RZ4ZDRYA.js";
70
- import {
71
- applyAsciiMode
72
- } from "./chunk-PZQBGUVZ.js";
73
- import "./chunk-BZHT5GPF.js";
55
+ installProviderPersisters
56
+ } from "./chunk-TWSQTQKR.js";
74
57
  import {
75
- CLI_VERSION
76
- } from "./chunk-F5DCFAKI.js";
58
+ discoverAndMergeProviders
59
+ } from "./chunk-CFHWIFXL.js";
77
60
  import {
78
61
  addFromCatalog,
79
62
  boxBottom,
80
63
  boxDivider,
81
64
  boxRow,
82
65
  boxTop,
66
+ parseAuthMenuIndex,
83
67
  runAuthLocal,
84
68
  runOAuthLoginMenu,
85
69
  runPicker,
86
70
  saveToGlobalConfig,
87
71
  theme
88
- } from "./chunk-2ERX3RPN.js";
72
+ } from "./chunk-P3GRLV47.js";
89
73
  import "./chunk-YTEOAWOJ.js";
90
74
  import {
91
75
  isKeylessLocalProvider,
@@ -93,15 +77,32 @@ import {
93
77
  } from "./chunk-5UZBUV2H.js";
94
78
  import {
95
79
  resolveActiveApiKey
96
- } from "./chunk-LUMETJFO.js";
97
- import "./chunk-DAKVBMD4.js";
80
+ } from "./chunk-ZYACRPLN.js";
98
81
  import {
99
82
  activeProfileConfigPath
100
83
  } from "./chunk-YMXXOOFN.js";
101
- import "./chunk-WSTVGC2C.js";
84
+ import "./chunk-4BX2YDTQ.js";
85
+ import {
86
+ runUpdateCommand
87
+ } from "./chunk-PGNERAZL.js";
88
+ import "./chunk-U3SS4NRH.js";
89
+ import "./chunk-DAKVBMD4.js";
90
+ import {
91
+ applyNodeEnvDefault,
92
+ applySessionShellDefault,
93
+ runPreflight
94
+ } from "./chunk-WTJDSTYD.js";
102
95
  import {
103
96
  parseArgs
104
- } from "./chunk-Q4INH2DG.js";
97
+ } from "./chunk-MPQCHBDJ.js";
98
+ import "./chunk-DIOODAYM.js";
99
+ import {
100
+ applyAsciiMode
101
+ } from "./chunk-PZQBGUVZ.js";
102
+ import "./chunk-WHEYHDIE.js";
103
+ import {
104
+ CLI_VERSION
105
+ } from "./chunk-F5DCFAKI.js";
105
106
 
106
107
  // src/cli-context.ts
107
108
  import { TOKENS as TOKENS3 } from "@wrongstack/core/kernel";
@@ -657,7 +658,7 @@ async function promptPort(deps, defaultPort) {
657
658
  )).trim();
658
659
  if (answer === "" || answer === "\n") return defaultPort;
659
660
  if (answer === "q" || answer === "quit") return defaultPort;
660
- const parsed = Number.parseInt(answer, 10);
661
+ const parsed = /^\d+$/.test(answer) ? Number(answer) : Number.NaN;
661
662
  if (Number.isFinite(parsed) && parsed > 0 && parsed < 65536) {
662
663
  return parsed;
663
664
  }
@@ -928,7 +929,7 @@ async function isPortInUse(host, port) {
928
929
  }
929
930
  async function handleHqShortCircuit(flags) {
930
931
  if (flags["hq"] !== true) return null;
931
- const { startHqServer } = await import("./hq-server-PCQACV7Y.js");
932
+ const { startHqServer } = await import("./hq-server-AVNKZ2PV.js");
932
933
  const tunnelRequested = flags["tunnel"] === true;
933
934
  const rawPublicUrl = typeof flags["hq-public-url"] === "string" ? flags["hq-public-url"] : process.env.WRONGSTACK_HQ_PUBLIC_URL;
934
935
  let publicOrigin;
@@ -959,7 +960,8 @@ async function handleHqShortCircuit(flags) {
959
960
  }
960
961
  let port;
961
962
  if (typeof flags["port"] === "string" && flags["port"].trim() !== "") {
962
- const parsed = Number.parseInt(flags["port"], 10);
963
+ const rawPort = flags["port"].trim();
964
+ const parsed = /^\d+$/.test(rawPort) ? Number(rawPort) : Number.NaN;
963
965
  if (Number.isFinite(parsed) && parsed > 0 && parsed < 65536) {
964
966
  port = parsed;
965
967
  } else {
@@ -1759,34 +1761,12 @@ async function persistLaunchChoices(configPath, choices) {
1759
1761
  // src/pre-launch/project-check.ts
1760
1762
  import * as fs6 from "node:fs/promises";
1761
1763
  import * as path7 from "node:path";
1762
- import { color as color8, toErrorMessage as toErrorMessage4 } from "@wrongstack/core/utils";
1763
- var MANIFESTS = [
1764
- "package.json",
1765
- "pyproject.toml",
1766
- "Cargo.toml",
1767
- "go.mod",
1768
- "Makefile",
1769
- "pom.xml",
1770
- "build.gradle",
1771
- "build.gradle.kts",
1772
- "composer.json",
1773
- "Gemfile"
1774
- ];
1775
- async function detectProjectKind(projectRoot) {
1776
- try {
1777
- await fs6.access(path7.join(projectRoot, ".wrongstack", "AGENTS.md"));
1778
- return "initialized";
1779
- } catch {
1780
- }
1781
- for (const m of MANIFESTS) {
1782
- try {
1783
- await fs6.access(path7.join(projectRoot, m));
1784
- return "project";
1785
- } catch {
1786
- }
1787
- }
1788
- return "empty";
1789
- }
1764
+ import {
1765
+ color as color8,
1766
+ detectProjectKind,
1767
+ isOutsideProject,
1768
+ toErrorMessage as toErrorMessage4
1769
+ } from "@wrongstack/core/utils";
1790
1770
  async function scaffoldAgentsMd(projectRoot) {
1791
1771
  const dir = path7.join(projectRoot, ".wrongstack");
1792
1772
  const file = path7.join(dir, "AGENTS.md");
@@ -1898,7 +1878,7 @@ function flagOn(value) {
1898
1878
  return normalized === "true" || normalized === "1" || normalized === "yes" || normalized === "on";
1899
1879
  }
1900
1880
  function isSystemPromptPinned(flags) {
1901
- return flagOn(flags["system-pro"]) || flagOn(flags["system-lite"]) || typeof flags["system-prompt"] === "string";
1881
+ return flagOn(flags["system-pro"]) || flagOn(flags["system-lite"]) || flagOn(flags["system-scout"]) || typeof flags["system-prompt"] === "string";
1902
1882
  }
1903
1883
  function shouldSkipSystemPromptMenu(flags) {
1904
1884
  if (isSystemPromptPinned(flags)) return true;
@@ -1912,10 +1892,17 @@ function labelFor(variant) {
1912
1892
  return SYSTEM_PROMPT_OPTIONS.find((o) => o.variant === variant)?.label ?? variant;
1913
1893
  }
1914
1894
  async function runSystemPromptMenu(deps) {
1915
- const { renderer, reader, paths, lastVariant } = deps;
1895
+ const { renderer, reader, paths, lastVariant, suggestScout } = deps;
1916
1896
  const tokens = await countSystemPromptTokens(paths);
1917
- const defaultVariant = lastVariant ?? "default";
1897
+ const defaultVariant = suggestScout ? "scout" : lastVariant ?? "default";
1918
1898
  if (lastVariant) {
1899
+ if (suggestScout && lastVariant !== "scout") {
1900
+ renderer.write(
1901
+ `
1902
+ ${color9.dim("\u25CB")} ${color9.dim(`Not a project folder \u2014 ${labelFor("scout")} (general-purpose) may fit better; answer n to choose it.`)}
1903
+ `
1904
+ );
1905
+ }
1919
1906
  const answer2 = (await reader.readLine(
1920
1907
  ` ${color9.amber("?")} Continue with ${color9.bold(labelFor(lastVariant))} system prompt ${color9.dim(`(~${fmtTok(tokens[lastVariant])} tokens)`)}? ${color9.dim("[Y/n/q]")} ${color9.dim("(auto Y in 5s)")} `,
1921
1908
  { timeoutMs: SUMMARY_TIMEOUT_MS2, defaultAnswer: "y" }
@@ -1926,6 +1913,12 @@ async function runSystemPromptMenu(deps) {
1926
1913
  renderer.write(`
1927
1914
  ${color9.amber("?")} System prompt:
1928
1915
  `);
1916
+ if (suggestScout) {
1917
+ renderer.write(
1918
+ ` ${color9.dim(`Not a project folder \u2014 ${labelFor("scout")} is preselected.`)}
1919
+ `
1920
+ );
1921
+ }
1929
1922
  for (const [index, opt] of SYSTEM_PROMPT_OPTIONS.entries()) {
1930
1923
  const num2 = index + 1;
1931
1924
  const isDefault = opt.variant === defaultVariant;
@@ -1942,8 +1935,8 @@ async function runSystemPromptMenu(deps) {
1942
1935
  )).trim().toLowerCase();
1943
1936
  if (answer === "q" || answer === "quit") throw new LaunchAbortedError();
1944
1937
  if (!answer) return defaultVariant;
1945
- const num = Number.parseInt(answer, 10);
1946
- if (!Number.isNaN(num) && num >= 1 && num <= SYSTEM_PROMPT_OPTIONS.length) {
1938
+ const num = parseAuthMenuIndex(answer);
1939
+ if (num !== void 0 && num <= SYSTEM_PROMPT_OPTIONS.length) {
1947
1940
  return SYSTEM_PROMPT_OPTIONS[num - 1].variant;
1948
1941
  }
1949
1942
  const byName = SYSTEM_PROMPT_OPTIONS.find(
@@ -1962,9 +1955,17 @@ async function maybeRunSystemPromptMenu(opts) {
1962
1955
  renderer: opts.renderer,
1963
1956
  reader: opts.reader,
1964
1957
  lastVariant: savedVariant,
1965
- paths: opts.paths
1958
+ paths: opts.paths,
1959
+ suggestScout: opts.outsideProject
1966
1960
  });
1967
1961
  if (chosen === savedVariant) return { variant: chosen, aborted: false, changed: false };
1962
+ if (opts.outsideProject && chosen === "scout") {
1963
+ opts.renderer.write(
1964
+ ` ${color9.dim(`${labelFor("scout")} for this launch only; the saved default stays ${labelFor(savedVariant ?? "default")}.`)}
1965
+ `
1966
+ );
1967
+ return { variant: chosen, aborted: false, changed: true };
1968
+ }
1968
1969
  try {
1969
1970
  await (opts.persist ?? persistSystemPromptVariant)(opts.profileConfigPath, chosen);
1970
1971
  } catch (err) {
@@ -2787,6 +2788,10 @@ function compactSingleLine(text) {
2787
2788
  var GITHUB_PROVIDERS_OVERLAY_URL = "https://raw.githubusercontent.com/WrongStack/WrongStack/main/packages/cli/data/providers.json";
2788
2789
  async function boot(argv) {
2789
2790
  const { flags, positional } = parseArgs(argv);
2791
+ if (positional[0] === "sandbox") {
2792
+ const { runSandboxCommand } = await import("./sandbox-TYGD6FI2.js");
2793
+ return runSandboxCommand(positional.slice(1), flags, new TerminalRenderer());
2794
+ }
2790
2795
  if (positional[0] === "update") {
2791
2796
  const renderer2 = new TerminalRenderer();
2792
2797
  return runUpdateCommand(positional.slice(1), {
@@ -2797,7 +2802,7 @@ async function boot(argv) {
2797
2802
  });
2798
2803
  }
2799
2804
  if (positional[0] === "remote" || typeof flags["remote"] === "string") {
2800
- const { runRemoteCommand } = await import("./remote-GB5VXCCT.js");
2805
+ const { runRemoteCommand } = await import("./remote-C74BCNND.js");
2801
2806
  return runRemoteCommand(
2802
2807
  positional[0] === "remote" ? positional.slice(1) : positional,
2803
2808
  flags,
@@ -2906,9 +2911,9 @@ async function boot(argv) {
2906
2911
  overlayFile: resolveBundledOverlayFile(),
2907
2912
  overlayCacheFile: wpaths.modelsOverlayCache
2908
2913
  });
2914
+ installProviderPersisters({ config, paths: wpaths, vault, logger });
2909
2915
  const subcommandHandler = first ? subcommands[first] : void 0;
2910
2916
  if (first && subcommandHandler) {
2911
- installProviderPersisters({ config, paths: wpaths, vault, logger });
2912
2917
  if (flags["help"] === true || flags["h"] === true) {
2913
2918
  const deepSub = positional[1];
2914
2919
  if (deepSub && renderDeepHelp(`${first}:${deepSub}`, renderer)) {
@@ -3162,7 +3167,8 @@ To start the app with no model connected, pass --provider ${SETUP_PROVIDER_ID} -
3162
3167
  paths: {
3163
3168
  globalDir: wpaths.globalInstructions,
3164
3169
  projectDir: wpaths.inProjectInstructions
3165
- }
3170
+ },
3171
+ outsideProject: await isOutsideProject(projectRoot)
3166
3172
  });
3167
3173
  if (promptMenu.aborted) {
3168
3174
  await reader.close();
@@ -3280,7 +3286,7 @@ To start the app with no model connected, pass --provider ${SETUP_PROVIDER_ID} -
3280
3286
  }
3281
3287
 
3282
3288
  // src/cli-context.ts
3283
- async function initializeCli(argv) {
3289
+ async function initializeCli(argv, options = {}) {
3284
3290
  applyNodeEnvDefault();
3285
3291
  applySessionShellDefault();
3286
3292
  const earlyFlags = parseArgs(argv).flags;
@@ -3339,6 +3345,7 @@ async function initializeCli(argv) {
3339
3345
  return 0;
3340
3346
  }
3341
3347
  effectiveArgv = applyLaunchMenuToArgv(argv, menuResult);
3348
+ if (menuResult.mode !== "tui-repl") options.onNonTuiLaunch?.();
3342
3349
  const augmentedFlags = parseArgs(effectiveArgv).flags;
3343
3350
  if (menuResult.mode === "hq") {
3344
3351
  const hqAfterMenu = await handleHqShortCircuit(augmentedFlags);
@@ -3442,4 +3449,4 @@ async function initializeCli(argv) {
3442
3449
  export {
3443
3450
  initializeCli
3444
3451
  };
3445
- //# sourceMappingURL=cli-context-6RONY47P.js.map
3452
+ //# sourceMappingURL=cli-context-ITHGP2CE.js.map
@@ -32,5 +32,7 @@ export interface CliContext extends BootContext {
32
32
  * or a numeric exit code when a short-circuit flag (--help, --desktop, --hq)
33
33
  * fires. When the return is a number the caller must return it immediately.
34
34
  */
35
- export declare function initializeCli(argv: string[]): Promise<CliContext | number>;
35
+ export declare function initializeCli(argv: string[], options?: {
36
+ onNonTuiLaunch?: () => void;
37
+ }): Promise<CliContext | number>;
36
38
  //# sourceMappingURL=cli-context.d.ts.map
@@ -0,0 +1,33 @@
1
+ import type { SystemPromptBuilder } from '@wrongstack/core/types';
2
+ export declare function setupCliInfrastructure(inputs: {
3
+ flags: Record<string, string | boolean>;
4
+ wpaths: import('@wrongstack/core/utils').WstackPaths;
5
+ events: import('@wrongstack/core/kernel').EventBus;
6
+ logger: import('@wrongstack/core/infrastructure').DefaultLogger;
7
+ getConfig: () => import('@wrongstack/core/types').Config;
8
+ teardownHandlers: (() => void)[];
9
+ vectorMemoryStore: import('@wrongstack/vector-memory').VectorMemoryStore | undefined;
10
+ renderer: import('./renderer.js').TerminalRenderer;
11
+ sessionRef: {
12
+ current: import('@wrongstack/core/types').SessionWriter | undefined;
13
+ };
14
+ activeMode: import('@wrongstack/core/types').Mode | null;
15
+ toolRegistry: import('@wrongstack/core/registry').ToolRegistry;
16
+ configStore: import('@wrongstack/core/types').ConfigStore;
17
+ container: import('@wrongstack/core/kernel').Container;
18
+ cwd: string;
19
+ projectRoot: string;
20
+ provider: import('@wrongstack/core/types').Provider;
21
+ }): Promise<{
22
+ metricsSink: import("@wrongstack/core/types").MetricsSink | undefined;
23
+ healthRegistry: import("@wrongstack/core/types").HealthRegistry | undefined;
24
+ metricsStatus: import("@wrongstack/core/types").MetricsRuntimeStatus;
25
+ tracer: import("@wrongstack/core/types").Tracer | undefined;
26
+ tuiOwnsScreen: boolean;
27
+ evOn: (event: string, handler: (...args: unknown[]) => void) => void;
28
+ eventWiring: import("./boot/event-wiring.js").EventWiring;
29
+ promptBuilder: SystemPromptBuilder;
30
+ onlineAgents: import("@wrongstack/core/coordination").MailboxAgentStatus[];
31
+ systemPrompt: import("@wrongstack/core/types").TextBlock[];
32
+ }>;
33
+ //# sourceMappingURL=cli-infrastructure.d.ts.map