@wrongstack/cli 1.0.28 → 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 (135) hide show
  1. package/data/providers.json +8 -177
  2. package/dist/{acp-M4565YUW.js → acp-EDGUWU7N.js} +4 -7
  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-EPR42SWM.js → chunk-2EZ2DHOW.js} +60 -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-RGFWGUAB.js → chunk-4UWCMBPG.js} +159 -3
  25. package/dist/{chunk-RDGGWMTI.js → chunk-65VNCAF6.js} +2 -22
  26. package/dist/{chunk-WQZW3RDP.js → chunk-7BNBD4PE.js} +2 -2
  27. package/dist/chunk-CFHWIFXL.js +123 -0
  28. package/dist/{chunk-RZ4ZDRYA.js → chunk-DIOODAYM.js} +2 -2
  29. package/dist/{chunk-L2RVEQWO.js → chunk-HHRYIDOW.js} +2 -2
  30. package/dist/chunk-LIZXJHZQ.js +61 -0
  31. package/dist/{chunk-YHYINL47.js → chunk-LKFKO4JW.js} +2 -2
  32. package/dist/{chunk-Q4INH2DG.js → chunk-MPQCHBDJ.js} +2 -1
  33. package/dist/{chunk-2ERX3RPN.js → chunk-P3GRLV47.js} +30 -17
  34. package/dist/{chunk-ZMX5HRLI.js → chunk-P3Q3KMFH.js} +6 -4
  35. package/dist/{chunk-KOEO4CJG.js → chunk-PGNERAZL.js} +4 -4
  36. package/dist/{chunk-ENRYW73H.js → chunk-RQ4UBKYH.js} +81 -10
  37. package/dist/{chunk-X756ZS72.js → chunk-SUDNPYWD.js} +2 -2
  38. package/dist/{chunk-LDCGZJTC.js → chunk-TWSQTQKR.js} +12 -4
  39. package/dist/chunk-TXAFIERF.js +37 -0
  40. package/dist/{chunk-UZ2TMHNH.js → chunk-UKP7H2U4.js} +10 -2
  41. package/dist/{chunk-5JYDKG5B.js → chunk-WHEYHDIE.js} +7 -2
  42. package/dist/{chunk-LBPLTTZ6.js → chunk-WTJDSTYD.js} +4 -4
  43. package/dist/{chunk-L5TD7UIG.js → chunk-WXJH4F6K.js} +7 -7
  44. package/dist/{chunk-IS2PPBQV.js → chunk-X4LW5CZM.js} +8 -4
  45. package/dist/{chunk-BBHWW6LR.js → chunk-YL4KCHZG.js} +18 -6
  46. package/dist/{chunk-LUMETJFO.js → chunk-ZYACRPLN.js} +2 -2
  47. package/dist/{cli-context-O2SHBDFH.js → cli-context-ITHGP2CE.js} +91 -84
  48. package/dist/cli-context.d.ts +3 -1
  49. package/dist/cli-infrastructure.d.ts +33 -0
  50. package/dist/{cli-main-BKG4ZVLN.js → cli-main-TQGLKB6D.js} +3783 -2753
  51. package/dist/config-doctor.d.ts +1 -1
  52. package/dist/{config-transfer-RUWLDCNK.js → config-transfer-UE37X4B5.js} +2 -2
  53. package/dist/{execution-THXWTHYT.js → execution-C2IECWF7.js} +5271 -5118
  54. package/dist/execution-chimera-handlers.d.ts +6 -0
  55. package/dist/execution-session-callbacks.d.ts +36 -0
  56. package/dist/execution-webui.d.ts +3 -0
  57. package/dist/execution.d.ts +1 -1
  58. package/dist/fleet/host-acp-runner.d.ts +15 -0
  59. package/dist/fleet/host-budget.d.ts +13 -0
  60. package/dist/fleet/host-context.d.ts +5 -0
  61. package/dist/fleet/host-explore-companion.d.ts +7 -16
  62. package/dist/fleet/host.d.ts +2 -0
  63. package/dist/fleet/status-broadcast.d.ts +1 -1
  64. package/dist/{hq-44F4OQH2.js → hq-KBFDKTDD.js} +13 -7
  65. package/dist/hq-publisher.d.ts +4 -1
  66. package/dist/hq-server/sage-sync-send.d.ts +5 -0
  67. package/dist/hq-server/server-lifecycle.d.ts +1 -1
  68. package/dist/hq-server/snapshot.d.ts +1 -1
  69. package/dist/{hq-server-UIB24LU6.js → hq-server-AVNKZ2PV.js} +2 -2
  70. package/dist/{hq-service-BMMJAHRT.js → hq-service-FGB7BY2D.js} +3 -3
  71. package/dist/hq-ttl-N4DAIAVX.js +7 -0
  72. package/dist/index.js +126 -10
  73. package/dist/{mailbox-serve-GNGXEQ2R.js → mailbox-serve-S536N66F.js} +4 -3
  74. package/dist/{modeldiag-W7XAE625.js → modeldiag-PQILD7TN.js} +26 -8
  75. package/dist/{per-subcommand-help-QDAQASPZ.js → per-subcommand-help-VKPV3OEY.js} +2 -2
  76. package/dist/{plugin-usage-CIGOOTX3.js → plugin-usage-3TZGROK7.js} +3 -3
  77. package/dist/{plugins-HQTXUD6A.js → plugins-ITH4SLO6.js} +4 -4
  78. package/dist/pre-launch/project-check.d.ts +2 -8
  79. package/dist/pre-launch.d.ts +1 -1
  80. package/dist/{project-manifest-7NSFVBM3.js → project-manifest-FTFDCCTZ.js} +2 -2
  81. package/dist/{project-picker-SVBXMPKX.js → project-picker-NZYJKQQC.js} +3 -3
  82. package/dist/provider-cloud-config.d.ts +4 -0
  83. package/dist/provider-config-utils.d.ts +1 -1
  84. package/dist/{providers-models-5Z2PJTEW.js → providers-models-W57I3QOA.js} +3 -3
  85. package/dist/{remote-GB5VXCCT.js → remote-C74BCNND.js} +5 -5
  86. package/dist/{rewind-JA3ZLCNM.js → rewind-7AULJS7F.js} +7 -5
  87. package/dist/sage-FFKUOCQL.js +475 -0
  88. package/dist/sage-connect.d.ts +62 -0
  89. package/dist/sage-hq-sync.d.ts +8 -0
  90. package/dist/sage-sync-ZMTHB477.js +69 -0
  91. package/dist/sandbox-TYGD6FI2.js +131 -0
  92. package/dist/services/sdd/project-context.d.ts +1 -1
  93. package/dist/{sessions-config-XHLXJ5C3.js → sessions-config-VE26SB56.js} +19 -8
  94. package/dist/short-circuit-flags-6LB3EGF7.js +10 -0
  95. package/dist/slash-commands/openai-quota.d.ts +12 -6
  96. package/dist/slash-commands/sandbox.d.ts +5 -0
  97. package/dist/slash-commands/scout-stats.d.ts +46 -0
  98. package/dist/slash-commands/sdd-inspect-commands.d.ts +9 -0
  99. package/dist/slash-commands/sdd-session-commands.d.ts +19 -0
  100. package/dist/slash-commands/sdd.d.ts +1 -1
  101. package/dist/slash-commands/zai-plan.d.ts +26 -0
  102. package/dist/{standalone-auto-update-TOTRGCSA.js → standalone-auto-update-VQC4GYCM.js} +3 -3
  103. package/dist/{standalone-update-LZO3MNLH.js → standalone-update-HZHDZZOR.js} +2 -2
  104. package/dist/subcommands/handlers/automation-credentials.d.ts +8 -0
  105. package/dist/subcommands/handlers/automation.d.ts +3 -0
  106. package/dist/subcommands/handlers/bench-experiments.d.ts +5 -0
  107. package/dist/subcommands/handlers/helpers.d.ts +1 -1
  108. package/dist/subcommands/handlers/sage-sync.d.ts +4 -0
  109. package/dist/subcommands/handlers/sage.d.ts +5 -0
  110. package/dist/subcommands/handlers/sandbox.d.ts +5 -0
  111. package/dist/{subcommands-SRRB3RAS.js → subcommands-QO7VYTSS.js} +2 -2
  112. package/dist/{tools-skills-GH24UCBY.js → tools-skills-33AI6K6S.js} +2 -2
  113. package/dist/tui-provider-quota-menu.d.ts +5 -0
  114. package/dist/{typesafe-WA5O3KVS.js → typesafe-NHC322W5.js} +27 -8
  115. package/dist/{typesafe-topic-replay-ZILIU3WS.js → typesafe-topic-replay-DB2AYL7V.js} +2 -2
  116. package/dist/{typesafe-triage-replay-FGAW7QM7.js → typesafe-triage-replay-27NDAZ3V.js} +2 -2
  117. package/dist/{update-TDZX4IL2.js → update-J5WHAFPE.js} +3 -3
  118. package/dist/{update-check-J5ZVKS73.js → update-check-VLVT4IV2.js} +2 -2
  119. package/dist/{version-help-XJJQ7YSH.js → version-help-ATOKGMTK.js} +2 -2
  120. package/dist/webui-server/prefs-seeding.d.ts +1 -0
  121. package/dist/webui-server/route-contexts.d.ts +1 -0
  122. package/dist/{webui-server-GCXIO3JY.js → webui-server-GQOVLQS3.js} +79 -40
  123. package/dist/webui-session-retirement.d.ts +10 -0
  124. package/dist/wiring/command-host-state.d.ts +2 -0
  125. package/dist/wiring/director-announcement.d.ts +3 -1
  126. package/dist/wiring/session-establishment.d.ts +10 -8
  127. package/dist/wiring/session-runtime.d.ts +1 -1
  128. package/dist/wiring/session.d.ts +3 -0
  129. package/package.json +30 -29
  130. package/dist/auto-discover-providers-DXR25GTG.js +0 -7
  131. package/dist/chunk-3ZTLPNEQ.js +0 -58
  132. package/dist/chunk-D5GB5MHA.js +0 -87
  133. package/dist/chunk-SIGUWXAA.js +0 -43
  134. package/dist/hq-ttl-VJR65OBJ.js +0 -7
  135. package/dist/short-circuit-flags-BSIPTAPD.js +0 -10
@@ -9,6 +9,42 @@ function resolveExecutionMode(positional, flags) {
9
9
  return "repl";
10
10
  }
11
11
 
12
+ // src/services/suggestion-store.ts
13
+ var sharedSuggestions = [];
14
+ var sharedAutoSuggestions = [];
15
+ function setSuggestions(suggestions) {
16
+ sharedSuggestions = suggestions;
17
+ }
18
+ function setAutoSuggestions(suggestions) {
19
+ sharedAutoSuggestions = suggestions;
20
+ }
21
+ function getSuggestions() {
22
+ return sharedSuggestions;
23
+ }
24
+ function removeSuggestions(indices) {
25
+ if (indices.length === 0) return;
26
+ const set = new Set(indices);
27
+ sharedSuggestions = sharedSuggestions.filter((_, i) => !set.has(i));
28
+ sharedAutoSuggestions = [];
29
+ }
30
+ function clearSuggestions() {
31
+ sharedSuggestions = [];
32
+ sharedAutoSuggestions = [];
33
+ }
34
+
35
+ // src/tui-thinking-word.ts
36
+ var DEFAULT_TUI_THINKING_WORD = "thinking";
37
+ var MAX_TUI_THINKING_WORD_LENGTH = 16;
38
+ function normalizeTuiThinkingWord(value) {
39
+ if (typeof value !== "string") return DEFAULT_TUI_THINKING_WORD;
40
+ const word = value.trim();
41
+ if (word.length === 0 || word.length > MAX_TUI_THINKING_WORD_LENGTH) {
42
+ return DEFAULT_TUI_THINKING_WORD;
43
+ }
44
+ if (!/^[\p{L}\p{N}_-]+$/u.test(word)) return DEFAULT_TUI_THINKING_WORD;
45
+ return word;
46
+ }
47
+
12
48
  // src/hq-fleet-control.ts
13
49
  import {
14
50
  areSubagentsAllowedForSession,
@@ -73,42 +109,6 @@ function createHqFleetControl(getDirector, defaultSessionId, scope) {
73
109
  };
74
110
  }
75
111
 
76
- // src/services/suggestion-store.ts
77
- var sharedSuggestions = [];
78
- var sharedAutoSuggestions = [];
79
- function setSuggestions(suggestions) {
80
- sharedSuggestions = suggestions;
81
- }
82
- function setAutoSuggestions(suggestions) {
83
- sharedAutoSuggestions = suggestions;
84
- }
85
- function getSuggestions() {
86
- return sharedSuggestions;
87
- }
88
- function removeSuggestions(indices) {
89
- if (indices.length === 0) return;
90
- const set = new Set(indices);
91
- sharedSuggestions = sharedSuggestions.filter((_, i) => !set.has(i));
92
- sharedAutoSuggestions = [];
93
- }
94
- function clearSuggestions() {
95
- sharedSuggestions = [];
96
- sharedAutoSuggestions = [];
97
- }
98
-
99
- // src/tui-thinking-word.ts
100
- var DEFAULT_TUI_THINKING_WORD = "thinking";
101
- var MAX_TUI_THINKING_WORD_LENGTH = 16;
102
- function normalizeTuiThinkingWord(value) {
103
- if (typeof value !== "string") return DEFAULT_TUI_THINKING_WORD;
104
- const word = value.trim();
105
- if (word.length === 0 || word.length > MAX_TUI_THINKING_WORD_LENGTH) {
106
- return DEFAULT_TUI_THINKING_WORD;
107
- }
108
- if (!/^[\p{L}\p{N}_-]+$/u.test(word)) return DEFAULT_TUI_THINKING_WORD;
109
- return word;
110
- }
111
-
112
112
  // src/services/run-git.ts
113
113
  import { spawn } from "node:child_process";
114
114
  import { toErrorMessage } from "@wrongstack/core/utils";
@@ -149,12 +149,12 @@ export {
149
149
  getSuggestions,
150
150
  removeSuggestions,
151
151
  clearSuggestions,
152
+ MAX_TUI_THINKING_WORD_LENGTH,
153
+ normalizeTuiThinkingWord,
152
154
  killHqSessionFleet,
153
155
  terminateHqAgent,
154
156
  spawnHqAgent,
155
157
  createHqFleetControl,
156
- MAX_TUI_THINKING_WORD_LENGTH,
157
- normalizeTuiThinkingWord,
158
158
  runGit
159
159
  };
160
- //# sourceMappingURL=chunk-7IQWQCBH.js.map
160
+ //# sourceMappingURL=chunk-3LEFXLAW.js.map
@@ -187,7 +187,14 @@ async function ensureHistoryDir(homeFn = defaultHomeDir, targetConfigPath) {
187
187
  async function readIndex(homeFn = defaultHomeDir, targetConfigPath) {
188
188
  try {
189
189
  const raw = await fs.readFile(historyIndexPath(homeFn, targetConfigPath), "utf8");
190
- return JSON.parse(raw);
190
+ const parsed = JSON.parse(raw);
191
+ if (parsed && typeof parsed === "object" && Array.isArray(parsed.entries)) {
192
+ const entries = parsed.entries.filter(
193
+ (e) => e !== null && typeof e === "object" && typeof e.id === "string"
194
+ );
195
+ return { version: 1, entries };
196
+ }
197
+ return { version: 1, entries: [] };
191
198
  } catch {
192
199
  return { version: 1, entries: [] };
193
200
  }
@@ -301,11 +308,11 @@ async function listHistory(homeFn = defaultHomeDir, targetConfigPath) {
301
308
  return idx.entries;
302
309
  }
303
310
  async function getHistoryEntry(id, homeFn = defaultHomeDir, targetConfigPath) {
311
+ const dir = historyDir(homeFn, targetConfigPath);
312
+ const filePath = path.join(dir, `${id}.json`);
313
+ if (path.dirname(path.resolve(filePath)) !== path.resolve(dir)) return null;
304
314
  try {
305
- const raw = await fs.readFile(
306
- path.join(historyDir(homeFn, targetConfigPath), `${id}.json`),
307
- "utf8"
308
- );
315
+ const raw = await fs.readFile(filePath, "utf8");
309
316
  return JSON.parse(raw);
310
317
  } catch {
311
318
  return null;
@@ -391,4 +398,4 @@ export {
391
398
  restoreFromHistory,
392
399
  restoreLast
393
400
  };
394
- //# sourceMappingURL=chunk-WSTVGC2C.js.map
401
+ //# sourceMappingURL=chunk-4BX2YDTQ.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  appendHistory,
3
3
  backupCurrent
4
- } from "./chunk-WSTVGC2C.js";
4
+ } from "./chunk-4BX2YDTQ.js";
5
5
 
6
6
  // src/settings-menu.ts
7
7
  import * as fs from "node:fs/promises";
@@ -55,6 +55,7 @@ var PROJECT_SAFE_FIELDS = /* @__PURE__ */ new Set([
55
55
  "fallbackProfile",
56
56
  "favoriteModels",
57
57
  "disabledModels",
58
+ "disabledProviders",
58
59
  "favoriteModelsOnly",
59
60
  "modelAvailabilitySchedule",
60
61
  "fallbackAuto",
@@ -268,4 +269,4 @@ export {
268
269
  persistTelegramConfig,
269
270
  deriveFsAccessPair
270
271
  };
271
- //# sourceMappingURL=chunk-SFBFYIOW.js.map
272
+ //# sourceMappingURL=chunk-4MDRHMX4.js.map
@@ -426,6 +426,146 @@ async function writeState(projectRoot, state) {
426
426
  await writeKanbanMetadata(projectRoot, SYNC_STATE_KEY, JSON.stringify(state));
427
427
  }
428
428
 
429
+ // src/sage-hq-sync.ts
430
+ import {
431
+ chunkHqSageRecords,
432
+ compareHqSageRecords,
433
+ isHqSageRecord,
434
+ MAX_HQ_SAGE_RECORD_BYTES
435
+ } from "@wrongstack/core/hq";
436
+ import { toErrorMessage } from "@wrongstack/core/utils";
437
+ import { SageProjectServerConnection } from "@wrongstack/sage";
438
+ function createSageHqSync(projectRoot, publisher, directory) {
439
+ const connection = new SageProjectServerConnection(projectRoot, directory);
440
+ const acknowledged = /* @__PURE__ */ new Map();
441
+ const sent = /* @__PURE__ */ new Map();
442
+ const warned = /* @__PURE__ */ new Map();
443
+ const remote = /* @__PURE__ */ new Map();
444
+ const controller = new AbortController();
445
+ const callOptions = { meta: { clientId: "hq-sage-sync" }, signal: controller.signal };
446
+ let stopped = false;
447
+ let running;
448
+ let lastFailure;
449
+ let lastScanVersion;
450
+ let generation = 0;
451
+ const version = (r) => `${r.revision}:${r.changeId}`;
452
+ const synchronize = async () => {
453
+ const startedGeneration = generation;
454
+ while (remote.size && !stopped && startedGeneration === generation) {
455
+ const batch = chunkHqSageRecords(publisher.project.projectId, remote.values()).next();
456
+ if (batch.done) break;
457
+ const records = batch.value.records;
458
+ for (const r of records) remote.delete(r.id);
459
+ try {
460
+ await connection.call("applyHqSync", { records }, callOptions);
461
+ for (const r of records) {
462
+ if (startedGeneration !== generation) break;
463
+ acknowledged.set(r.id, version(r));
464
+ if (sent.get(r.id) === version(r)) sent.delete(r.id);
465
+ }
466
+ } catch (error) {
467
+ if (stopped || startedGeneration !== generation) return;
468
+ for (const r of records) {
469
+ const pending = remote.get(r.id);
470
+ if (!pending || compareHqSageRecords(r, pending) > 0) remote.set(r.id, r);
471
+ }
472
+ throw error;
473
+ }
474
+ }
475
+ const scanVersion = await connection.call("getHqSyncVersion", {}, callOptions);
476
+ if (stopped || startedGeneration !== generation || !publisher.connected) return;
477
+ if (scanVersion === lastScanVersion && sent.size === 0) return;
478
+ let after = "";
479
+ while (!stopped && publisher.connected) {
480
+ const page = await connection.call("listHqSync", { after }, callOptions);
481
+ if (stopped || startedGeneration !== generation || !publisher.connected) return;
482
+ if (!page.length) {
483
+ lastScanVersion = scanVersion;
484
+ return;
485
+ }
486
+ const outgoing = page.filter((r) => {
487
+ if (acknowledged.get(r.id) === version(r)) {
488
+ sent.delete(r.id);
489
+ return false;
490
+ }
491
+ if (isHqSageRecord(r)) {
492
+ warned.delete(r.id);
493
+ return true;
494
+ }
495
+ if (warned.get(r.id) !== version(r)) {
496
+ process.emitWarning(
497
+ `SAGE memory ${r.id} cannot sync: invalid record or exceeds ${MAX_HQ_SAGE_RECORD_BYTES} bytes. Other memories will continue syncing.`,
498
+ { code: "WRONGSTACK_HQ_SAGE_RECORD_REJECTED" }
499
+ );
500
+ warned.set(r.id, version(r));
501
+ }
502
+ return false;
503
+ });
504
+ for (const payload of chunkHqSageRecords(publisher.project.projectId, outgoing)) {
505
+ for (const r of payload.records) sent.set(r.id, version(r));
506
+ publisher.publishEvent({
507
+ type: "sage.snapshot",
508
+ payload,
509
+ maxSummaryLength: MAX_HQ_SAGE_RECORD_BYTES
510
+ });
511
+ }
512
+ after = page[page.length - 1].id;
513
+ }
514
+ };
515
+ const refresh = () => {
516
+ if (stopped || !publisher.connected) return Promise.resolve();
517
+ if (running) return running;
518
+ running = synchronize().then(() => {
519
+ lastFailure = void 0;
520
+ }).catch((error) => {
521
+ const message = toErrorMessage(error);
522
+ if (!stopped && lastFailure !== message) {
523
+ process.emitWarning(`SAGE HQ sync will retry: ${message}`, {
524
+ code: "WRONGSTACK_HQ_SAGE_SYNC_FAILED"
525
+ });
526
+ lastFailure = message;
527
+ }
528
+ }).finally(() => {
529
+ running = void 0;
530
+ });
531
+ return running;
532
+ };
533
+ const unsubscribe = publisher.onConnected(() => {
534
+ generation++;
535
+ remote.clear();
536
+ acknowledged.clear();
537
+ sent.clear();
538
+ lastScanVersion = void 0;
539
+ void refresh();
540
+ });
541
+ const timer = setInterval(() => void refresh(), 3e3);
542
+ timer.unref?.();
543
+ void refresh();
544
+ return {
545
+ async handleRemote(snapshot) {
546
+ if (stopped || snapshot.projectId !== publisher.project.projectId) return;
547
+ for (const r of snapshot.records) {
548
+ const pending = remote.get(r.id);
549
+ if (!pending || compareHqSageRecords(r, pending) > 0) remote.set(r.id, r);
550
+ }
551
+ await refresh();
552
+ },
553
+ refresh,
554
+ stop() {
555
+ stopped = true;
556
+ controller.abort();
557
+ clearInterval(timer);
558
+ unsubscribe();
559
+ remote.clear();
560
+ acknowledged.clear();
561
+ sent.clear();
562
+ warned.clear();
563
+ connection.close();
564
+ void running?.finally(() => connection.close());
565
+ }
566
+ };
567
+ }
568
+
429
569
  // src/hq-publisher.ts
430
570
  var HQ_DISCOVERY_CONNECTION_KEY = "<discover>";
431
571
  function nodeWsSocketFactory(url) {
@@ -450,15 +590,20 @@ function resolvedHqConnectionKey(options) {
450
590
  const endpoint = config.discover === true ? HQ_DISCOVERY_CONNECTION_KEY : `${config.url}
451
591
  ${config.token ?? ""}`;
452
592
  return `${endpoint}
453
- raw=${String(config.rawContent)}`;
593
+ raw=${String(config.rawContent)}
594
+ sage=${options.appConfig?.Sage?.storage?.directory ?? ""}`;
454
595
  }
455
596
  function startCliHqConnection(options) {
456
597
  const shouldOwnKanbanSync = options.ownKanbanSync !== false && options.onKanbanSnapshot === void 0;
457
598
  let kanbanSync;
599
+ let sageSync;
600
+ const shouldOwnSageSync = (options.ownSageSync ?? options.ownKanbanSync !== false) && options.onSageSnapshot === void 0;
458
601
  const publisherOptions = shouldOwnKanbanSync ? {
459
602
  ...options,
460
603
  onKanbanSnapshot: (snapshot) => kanbanSync?.handleRemote(snapshot)
461
- } : options;
604
+ } : { ...options };
605
+ if (shouldOwnSageSync)
606
+ publisherOptions.onSageSnapshot = (snapshot) => sageSync?.handleRemote(snapshot);
462
607
  let publisher;
463
608
  let publisherKey;
464
609
  let timer;
@@ -467,6 +612,8 @@ function startCliHqConnection(options) {
467
612
  if (publisher === void 0) return;
468
613
  kanbanSync?.stop();
469
614
  kanbanSync = void 0;
615
+ sageSync?.stop();
616
+ sageSync = void 0;
470
617
  publisher.close();
471
618
  publisher = void 0;
472
619
  publisherKey = void 0;
@@ -484,6 +631,8 @@ function startCliHqConnection(options) {
484
631
  `)) publisher.refreshEndpoint();
485
632
  return;
486
633
  }
634
+ sageSync?.stop();
635
+ sageSync = void 0;
487
636
  publisher?.close();
488
637
  publisher = void 0;
489
638
  publisherKey = void 0;
@@ -495,6 +644,12 @@ function startCliHqConnection(options) {
495
644
  kanbanSync?.stop();
496
645
  kanbanSync = createKanbanHqSync(options.projectRoot, next.project.projectId);
497
646
  }
647
+ if (shouldOwnSageSync)
648
+ sageSync = createSageHqSync(
649
+ options.projectRoot,
650
+ next,
651
+ current.appConfig?.Sage?.storage?.directory
652
+ );
498
653
  next.connect();
499
654
  if (kanbanSync !== void 0) {
500
655
  kanbanSync.attachPublisher(next).catch((error) => {
@@ -520,6 +675,7 @@ function startCliHqConnection(options) {
520
675
  timer = void 0;
521
676
  }
522
677
  kanbanSync?.stop();
678
+ sageSync?.stop();
523
679
  publisher?.close();
524
680
  publisher = void 0;
525
681
  publisherKey = void 0;
@@ -530,4 +686,4 @@ function startCliHqConnection(options) {
530
686
  export {
531
687
  startCliHqConnection
532
688
  };
533
- //# sourceMappingURL=chunk-RGFWGUAB.js.map
689
+ //# sourceMappingURL=chunk-4UWCMBPG.js.map
@@ -1,11 +1,6 @@
1
1
  import {
2
2
  resolveProviderCfgWithProxy
3
3
  } from "./chunk-SDJCLEK6.js";
4
- import {
5
- fallbackCodexProviderModels,
6
- filterCurrentCodexModelIds,
7
- isCodexCatalogModel
8
- } from "./chunk-SIGUWXAA.js";
9
4
 
10
5
  // src/acp-agent-list.ts
11
6
  import { REGISTRY_ID_ALIASES } from "@wrongstack/acp";
@@ -117,7 +112,7 @@ async function loadCachedAcpRegistry(paths) {
117
112
  const raw = await fs.readFile(acpRegistryCachePath(paths), "utf8");
118
113
  const env = JSON.parse(raw);
119
114
  if (!Array.isArray(env.agents)) return null;
120
- const byId = {};
115
+ const byId = /* @__PURE__ */ Object.create(null);
121
116
  for (const a of env.agents) {
122
117
  if (!a?.id || !a.acp?.command) continue;
123
118
  byId[a.id] = {
@@ -227,21 +222,6 @@ async function setupProvider(params) {
227
222
  let models;
228
223
  if (savedModels && savedModels.length > 0) {
229
224
  models = savedModels.map((m) => ({ id: m, name: m }));
230
- } else if (family === "openai-codex") {
231
- const openaiProvider = await modelsRegistry.getProvider("openai").catch(() => void 0);
232
- if (openaiProvider) {
233
- const catalogById = new Map(
234
- openaiProvider.models.filter(isCodexCatalogModel).map((m) => [m.id, { id: m.id, name: m.name }])
235
- );
236
- const catalogModels = filterCurrentCodexModelIds(catalogById.keys()).map((id) => catalogById.get(id)).filter((m) => Boolean(m));
237
- if (catalogModels.length > 0) {
238
- models = catalogModels;
239
- } else {
240
- models = fallbackCodexProviderModels();
241
- }
242
- } else {
243
- models = fallbackCodexProviderModels();
244
- }
245
225
  } else {
246
226
  models = [];
247
227
  }
@@ -336,4 +316,4 @@ export {
336
316
  setupProvider,
337
317
  createGracefulShutdown
338
318
  };
339
- //# sourceMappingURL=chunk-RDGGWMTI.js.map
319
+ //# sourceMappingURL=chunk-65VNCAF6.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadManifest
3
- } from "./chunk-IS2PPBQV.js";
3
+ } from "./chunk-X4LW5CZM.js";
4
4
 
5
5
  // src/project-picker.ts
6
6
  import { color } from "@wrongstack/core/utils";
@@ -415,4 +415,4 @@ export {
415
415
  skipDivider,
416
416
  runProjectPicker
417
417
  };
418
- //# sourceMappingURL=chunk-WQZW3RDP.js.map
418
+ //# sourceMappingURL=chunk-7BNBD4PE.js.map
@@ -0,0 +1,123 @@
1
+
2
+ // src/boot/auto-discover-providers.ts
3
+ import * as fs from "node:fs/promises";
4
+ import * as path from "node:path";
5
+ import { discoverOpenAICompatibleModels, resolveDiscoveryTargets } from "@wrongstack/providers";
6
+ async function readCache(file) {
7
+ try {
8
+ return JSON.parse(await fs.readFile(file, "utf8"));
9
+ } catch {
10
+ return {};
11
+ }
12
+ }
13
+ async function discoverAndMergeProviders(opts) {
14
+ const targets = resolveDiscoveryTargets(opts.config);
15
+ if (targets.length === 0) return;
16
+ const cacheFile = path.join(opts.cacheDir, "discovered-models-cache.json");
17
+ const cache = await readCache(cacheFile);
18
+ let cacheDirty = false;
19
+ await Promise.all(
20
+ targets.map(async (target) => {
21
+ const previousCacheKey = target.cacheKey;
22
+ const {
23
+ id,
24
+ cfg,
25
+ baseUrl,
26
+ apiKey,
27
+ modelDiscoveryPath,
28
+ modelDiscoveryAuthoritative,
29
+ accountCatalog,
30
+ copilotCatalog,
31
+ modelsUrl,
32
+ headers,
33
+ prepareApiKey
34
+ } = target;
35
+ let failureReason = "model catalog request failed";
36
+ const provider = await discoverOpenAICompatibleModels(id, {
37
+ baseUrl,
38
+ apiKey,
39
+ headers: { ...cfg.headers, ...headers },
40
+ accountCatalog,
41
+ copilotCatalog,
42
+ modelsUrl,
43
+ providerName: id,
44
+ modelDiscoveryPath,
45
+ fetchImpl: opts.fetchImpl,
46
+ prepareApiKey,
47
+ onFailure: (reason) => {
48
+ failureReason = reason;
49
+ }
50
+ });
51
+ if (target.isCurrent && !target.isCurrent()) return;
52
+ const { cacheKey } = target;
53
+ if (provider) {
54
+ if (accountCatalog) cfg.models = Object.keys(provider.models);
55
+ const fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
56
+ cache[cacheKey] = { fetchedAt, provider };
57
+ cacheDirty = true;
58
+ if (modelDiscoveryAuthoritative) {
59
+ opts.registry.mergeOverlay(
60
+ { [id]: provider },
61
+ { observedAt: fetchedAt, authoritativeProviderIds: [id] }
62
+ );
63
+ } else {
64
+ opts.registry.mergeOverlay({ [id]: provider });
65
+ }
66
+ opts.logger?.info(
67
+ `auto-discovered ${Object.keys(provider.models).length} models for "${id}" from ${baseUrl}`
68
+ );
69
+ return;
70
+ }
71
+ const cached = cache[cacheKey] ?? cache[previousCacheKey];
72
+ if (cached) {
73
+ if (cacheKey !== previousCacheKey) {
74
+ cache[cacheKey] = cached;
75
+ cacheDirty = true;
76
+ }
77
+ if (accountCatalog) cfg.models = Object.keys(cached.provider.models);
78
+ if (modelDiscoveryAuthoritative) {
79
+ opts.registry.mergeOverlay(
80
+ { [id]: cached.provider },
81
+ { observedAt: cached.fetchedAt, authoritativeProviderIds: [id] }
82
+ );
83
+ } else {
84
+ opts.registry.mergeOverlay({ [id]: cached.provider });
85
+ }
86
+ opts.logger?.warn(
87
+ `auto-discovery for "${id}" failed; using ${Object.keys(cached.provider.models).length} cached models from ${cached.fetchedAt} (${failureReason})`
88
+ );
89
+ } else {
90
+ if (accountCatalog) {
91
+ cfg.models = [];
92
+ opts.registry.mergeOverlay(
93
+ {
94
+ [id]: {
95
+ id,
96
+ name: id,
97
+ npm: "@ai-sdk/openai-compatible",
98
+ api: baseUrl,
99
+ env: [],
100
+ models: {}
101
+ }
102
+ },
103
+ { authoritativeProviderIds: [id] }
104
+ );
105
+ }
106
+ opts.logger?.warn(
107
+ `auto-discovery for "${id}" failed and no cache available (${failureReason}; catalog at ${baseUrl})`
108
+ );
109
+ }
110
+ })
111
+ );
112
+ if (cacheDirty) {
113
+ try {
114
+ await fs.writeFile(cacheFile, JSON.stringify(cache), "utf8");
115
+ } catch {
116
+ }
117
+ }
118
+ }
119
+
120
+ export {
121
+ discoverAndMergeProviders
122
+ };
123
+ //# sourceMappingURL=chunk-CFHWIFXL.js.map
@@ -144,7 +144,7 @@ async function checkForUpdate(signalOrOptions, legacyHomeFn) {
144
144
  };
145
145
  }
146
146
  try {
147
- const latest = packageName === "standalone-binary" ? await (await import("./standalone-update-LZO3MNLH.js")).fetchLatestStandaloneVersion(3e3, signal) : await fetchLatestFromNpm(packageName, 3e3, signal);
147
+ const latest = packageName === "standalone-binary" ? await (await import("./standalone-update-HZHDZZOR.js")).fetchLatestStandaloneVersion(3e3, signal) : await fetchLatestFromNpm(packageName, 3e3, signal);
148
148
  await writeCache({ timestamp: Date.now(), latestVersion: latest, packageName }, hf);
149
149
  return {
150
150
  current,
@@ -183,4 +183,4 @@ export {
183
183
  checkForUpdate,
184
184
  getUpdateNotification
185
185
  };
186
- //# sourceMappingURL=chunk-RZ4ZDRYA.js.map
186
+ //# sourceMappingURL=chunk-DIOODAYM.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  backupCurrent
3
- } from "./chunk-WSTVGC2C.js";
3
+ } from "./chunk-4BX2YDTQ.js";
4
4
 
5
5
  // src/wiring/external-plugins.ts
6
6
  import { isAbsolute, join, resolve } from "node:path";
@@ -1109,4 +1109,4 @@ export {
1109
1109
  PLUGIN_AUDIT_ENTRIES,
1110
1110
  runPluginManagementCommand
1111
1111
  };
1112
- //# sourceMappingURL=chunk-L2RVEQWO.js.map
1112
+ //# sourceMappingURL=chunk-HHRYIDOW.js.map
@@ -0,0 +1,61 @@
1
+
2
+ // src/subcommands/index.ts
3
+ var loaders = {
4
+ automation: async () => (await import("./automation-MCDFCIMV.js")).automationCmd,
5
+ sandbox: async () => (await import("./sandbox-TYGD6FI2.js")).sandboxCmd,
6
+ acp: async () => (await import("./acp-EDGUWU7N.js")).acpCmd,
7
+ init: async () => (await import("./init-DRMMFG2G.js")).initCmd,
8
+ auth: async () => (await import("./auth-SUHKFFO4.js")).authCmd,
9
+ update: async () => (await import("./update-J5WHAFPE.js")).updateCmd,
10
+ remote: async () => (await import("./remote-C74BCNND.js")).remoteCmd,
11
+ sessions: async () => (await import("./sessions-config-VE26SB56.js")).sessionsCmd,
12
+ config: async () => (await import("./sessions-config-VE26SB56.js")).configCmd,
13
+ "config-export": async () => (await import("./config-transfer-UE37X4B5.js")).configExportCmd,
14
+ "config-import": async () => (await import("./config-transfer-UE37X4B5.js")).configImportCmd,
15
+ rewind: async () => (await import("./rewind-7AULJS7F.js")).rewindCmd,
16
+ replay: async () => (await import("./replay-JJ2NOWD6.js")).replayCmd,
17
+ audit: async () => (await import("./audit-KCBTHUQI.js")).auditCmd,
18
+ tools: async () => (await import("./tools-skills-33AI6K6S.js")).toolsCmd,
19
+ skills: async () => (await import("./tools-skills-33AI6K6S.js")).skillsCmd,
20
+ "skill-suggest": async () => (await import("./skill-suggest-L2EVWB6R.js")).skillSuggestCmd,
21
+ typesafe: async () => (await import("./typesafe-NHC322W5.js")).typesafeCmd,
22
+ providers: async () => (await import("./providers-models-W57I3QOA.js")).providersCmd,
23
+ models: async () => (await import("./providers-models-W57I3QOA.js")).modelsCmd,
24
+ mcp: async () => (await import("./mcp-LBS45HWZ.js")).mcpCmd,
25
+ plugin: async () => (await import("./plugin-usage-3TZGROK7.js")).pluginCmd,
26
+ plugins: async () => (await import("./plugin-usage-3TZGROK7.js")).pluginCmd,
27
+ diag: async () => (await import("./diag-doctor-BIZAFIAT.js")).diagCmd,
28
+ doctor: async () => (await import("./diag-doctor-BIZAFIAT.js")).doctorCmd,
29
+ "proxy-status": async () => (await import("./diag-doctor-BIZAFIAT.js")).proxyCmd,
30
+ export: async () => (await import("./export-VVRIOWFV.js")).exportCmd,
31
+ usage: async () => (await import("./plugin-usage-3TZGROK7.js")).usageCmd,
32
+ version: async () => (await import("./version-help-ATOKGMTK.js")).versionCmd,
33
+ help: async () => (await import("./version-help-ATOKGMTK.js")).helpCmd,
34
+ projects: async () => (await import("./projects-T4CZCA25.js")).projectsCmd,
35
+ modeldiag: async () => (await import("./modeldiag-PQILD7TN.js")).modeldiagCmd,
36
+ quick: async () => (await import("./quick-CNB4Z3HS.js")).quickCmd,
37
+ bench: async () => (await import("./bench-MMZHFHDL.js")).benchCmd,
38
+ chronicle: async () => (await import("./chronicle-PBJS7BN6.js")).chronicleCmd,
39
+ hq: async () => (await import("./hq-KBFDKTDD.js")).hqCmd,
40
+ mailbox: async () => (await import("./mailbox-serve-S536N66F.js")).mailboxServeCmd,
41
+ permissions: async () => (await import("./permissions-PL27UHYD.js")).permissionsCmd,
42
+ project: async () => (await import("./project-AOQI5XTK.js")).projectCmd,
43
+ sage: async () => (await import("./sage-FFKUOCQL.js")).sageCmd,
44
+ governance: async () => (await import("./governance-RYSHV675.js")).governanceCmd,
45
+ "import-claude-code": async () => (await import("./import-claude-code-AYG24RG2.js")).importClaudeCodeCmd
46
+ };
47
+ var subcommands = Object.fromEntries(
48
+ Object.entries(loaders).map(
49
+ ([name, load]) => [
50
+ name,
51
+ async (args, deps) => (await load())(args, deps)
52
+ ]
53
+ )
54
+ );
55
+ var subcommandNames = Object.keys(loaders);
56
+
57
+ export {
58
+ subcommands,
59
+ subcommandNames
60
+ };
61
+ //# sourceMappingURL=chunk-LIZXJHZQ.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  PLUGIN_AUDIT_ENTRIES,
6
6
  loadExternalPlugins
7
- } from "./chunk-L2RVEQWO.js";
7
+ } from "./chunk-HHRYIDOW.js";
8
8
 
9
9
  // src/wiring/plugins.ts
10
10
  import { join } from "node:path";
@@ -306,4 +306,4 @@ export {
306
306
  BUILTIN_PLUGIN_NAME_HINTS,
307
307
  setupPlugins
308
308
  };
309
- //# sourceMappingURL=chunk-YHYINL47.js.map
309
+ //# sourceMappingURL=chunk-LKFKO4JW.js.map
@@ -74,6 +74,7 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
74
74
  "token-saving-mode",
75
75
  "system-lite",
76
76
  "system-pro",
77
+ "system-scout",
77
78
  "hq",
78
79
  "hq-allow-exec",
79
80
  "tunnel",
@@ -306,4 +307,4 @@ export {
306
307
  parseAuthFlags,
307
308
  parseSpawnFlags
308
309
  };
309
- //# sourceMappingURL=chunk-Q4INH2DG.js.map
310
+ //# sourceMappingURL=chunk-MPQCHBDJ.js.map