@wrongstack/cli 1.0.19 → 1.0.26

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 (195) hide show
  1. package/data/providers.json +44 -0
  2. package/dist/{acp-INCNOH42.js → acp-LI665LO2.js} +18 -7
  3. package/dist/arg-parser.d.ts +1 -0
  4. package/dist/ascii-mode-SG4PRNLP.js +7 -0
  5. package/dist/{auth-YXK3EDUL.js → auth-TE55JF4Z.js} +68 -22
  6. package/dist/auth-menu/direct.d.ts +1 -0
  7. package/dist/auth-menu/local.d.ts +2 -0
  8. package/dist/auth-menu/oauth-menu.d.ts +3 -1
  9. package/dist/auth-menu/panel-service.d.ts +20 -0
  10. package/dist/{bench-YBU6BVQP.js → bench-GTLPM22B.js} +2 -2
  11. package/dist/boot/append-system-prompt.d.ts +10 -0
  12. package/dist/boot/ascii-mode.d.ts +12 -0
  13. package/dist/boot/config-backup-recovery.d.ts +2 -1
  14. package/dist/boot/container-wiring.d.ts +4 -2
  15. package/dist/boot/dispatch-singleshot.d.ts +4 -1
  16. package/dist/boot/dispatch-webui.d.ts +11 -0
  17. package/dist/boot/mcp-config-flag.d.ts +22 -0
  18. package/dist/boot/piped-stdin.d.ts +40 -0
  19. package/dist/boot/restricted-mode.d.ts +15 -0
  20. package/dist/boot/safe-mode.d.ts +30 -0
  21. package/dist/boot/short-circuit-desktop.d.ts +1 -0
  22. package/dist/boot/single-shot-budget.d.ts +30 -0
  23. package/dist/boot/stream-json.d.ts +36 -0
  24. package/dist/boot/structured-output.d.ts +16 -0
  25. package/dist/boot/system-prompt-builder.d.ts +2 -0
  26. package/dist/boot/tool-restriction-flags.d.ts +36 -0
  27. package/dist/boot/tui-project-picker-callback.d.ts +1 -1
  28. package/dist/boot/tui-settings-adapter.d.ts +15 -2
  29. package/dist/boot/worktree-sessions.d.ts +21 -0
  30. package/dist/{boot-auto-thin-MANHOYHE.js → boot-auto-thin-6Q56FY3F.js} +3 -2
  31. package/dist/boot-provider-selection.d.ts +67 -0
  32. package/dist/boot.d.ts +1 -38
  33. package/dist/{chunk-JY52HWL6.js → chunk-2EBVTYJR.js} +2 -2
  34. package/dist/{chunk-RDHFXOJM.js → chunk-2ERX3RPN.js} +112 -65
  35. package/dist/chunk-4TVYGG6G.js +62 -0
  36. package/dist/chunk-5JYDKG5B.js +154 -0
  37. package/dist/{chunk-KEPABQYT.js → chunk-5SEYGOCH.js} +8 -82
  38. package/dist/{chunk-3VXYY5JC.js → chunk-5UZBUV2H.js} +3 -19
  39. package/dist/chunk-BBHWW6LR.js +549 -0
  40. package/dist/chunk-BEHGRNOQ.js +58 -0
  41. package/dist/chunk-CZTXF6HY.js +140 -0
  42. package/dist/{chunk-JX6KL7OF.js → chunk-EPR42SWM.js} +39 -8
  43. package/dist/chunk-F5DCFAKI.js +36 -0
  44. package/dist/chunk-HLSHFXTO.js +97 -0
  45. package/dist/{chunk-CJTBLTS4.js → chunk-KJS5543T.js} +4 -3
  46. package/dist/{chunk-DE7BZDNK.js → chunk-KOEO4CJG.js} +27 -4
  47. package/dist/{chunk-SIS37L3W.js → chunk-L2RVEQWO.js} +211 -193
  48. package/dist/chunk-LBPLTTZ6.js +105 -0
  49. package/dist/chunk-LDCGZJTC.js +46 -0
  50. package/dist/chunk-LKPEBZBE.js +143 -0
  51. package/dist/chunk-LUMETJFO.js +171 -0
  52. package/dist/{chunk-KK2LB3ZS.js → chunk-OAVBM55Q.js} +9 -5
  53. package/dist/chunk-PZQBGUVZ.js +18 -0
  54. package/dist/{chunk-C3Z4N6A6.js → chunk-Q4INH2DG.js} +51 -3
  55. package/dist/chunk-R4QGL6GB.js +10 -0
  56. package/dist/{chunk-YLQEGYV4.js → chunk-RZ4ZDRYA.js} +14 -4
  57. package/dist/chunk-S4FFHDJG.js +93 -0
  58. package/dist/chunk-SFBFYIOW.js +271 -0
  59. package/dist/{chunk-RMQNCHGO.js → chunk-TI7KLHYX.js} +136 -11
  60. package/dist/{chunk-2ENZU66X.js → chunk-WQV2NP57.js} +5 -5
  61. package/dist/{chunk-B4JLSXZB.js → chunk-WSTVGC2C.js} +73 -45
  62. package/dist/chunk-X756ZS72.js +329 -0
  63. package/dist/{chunk-XJ7K67PP.js → chunk-YHYINL47.js} +63 -24
  64. package/dist/{chunk-2VMJ3E5Z.js → chunk-YTEOAWOJ.js} +6 -2
  65. package/dist/{chunk-GPPRNAKW.js → chunk-ZMX5HRLI.js} +2 -2
  66. package/dist/{cli-context-33F74CSZ.js → cli-context-UVGAN3NO.js} +496 -384
  67. package/dist/cli-entry-point.d.ts +2 -0
  68. package/dist/{cli-main-FNGMKPBA.js → cli-main-TN3KZ2P6.js} +3561 -2724
  69. package/dist/cli-update-notice.d.ts +2 -1
  70. package/dist/config-doctor.d.ts +10 -2
  71. package/dist/{config-transfer-2YF3CRTN.js → config-transfer-RUWLDCNK.js} +34 -13
  72. package/dist/{diag-doctor-ANPRUYFM.js → diag-doctor-BIZAFIAT.js} +2 -2
  73. package/dist/execute-deps.d.ts +2 -1
  74. package/dist/{execution-A6WJLSOC.js → execution-7QIP6GRY.js} +2384 -2055
  75. package/dist/fleet/host-types.d.ts +3 -1
  76. package/dist/goal-commands.d.ts +47 -0
  77. package/dist/goal-host.d.ts +1 -14
  78. package/dist/{hq-XQWQTRDA.js → hq-GLZ7QESM.js} +277 -261
  79. package/dist/hq-command-controller.d.ts +1 -1
  80. package/dist/{hq-server-IIBZQZU4.js → hq-server-YTKDVQPY.js} +2 -2
  81. package/dist/{hq-service-L5INQFM4.js → hq-service-BMMJAHRT.js} +11 -4
  82. package/dist/import-claude-code-32PCSIQI.js +236 -0
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.js +19 -10
  85. package/dist/kanban-supervisor-67ECABTD.js +7 -0
  86. package/dist/live-settings-input.d.ts +7 -0
  87. package/dist/{mailbox-serve-3GFOK2I7.js → mailbox-serve-NW5VZG7R.js} +3 -3
  88. package/dist/{mcp-DC5WSBOO.js → mcp-LBS45HWZ.js} +4 -4
  89. package/dist/modeldiag-36VODVIH.js +828 -0
  90. package/dist/{per-subcommand-help-DHTYU524.js → per-subcommand-help-QDAQASPZ.js} +3 -3
  91. package/dist/permission-prompt-mirror.d.ts +1 -1
  92. package/dist/permission-prompt.d.ts +16 -2
  93. package/dist/permission-rules-view.d.ts +18 -0
  94. package/dist/{permissions-CFDLXETM.js → permissions-PL27UHYD.js} +67 -45
  95. package/dist/plugin-config.d.ts +12 -0
  96. package/dist/plugin-management-types.d.ts +31 -0
  97. package/dist/plugin-management.d.ts +2 -30
  98. package/dist/plugin-package-install.d.ts +3 -0
  99. package/dist/{plugin-usage-M6KET4OZ.js → plugin-usage-CIGOOTX3.js} +6 -5
  100. package/dist/{plugins-WJLW6ULV.js → plugins-HQTXUD6A.js} +6 -3
  101. package/dist/preflight.d.ts +1 -1
  102. package/dist/{projects-LMNAGGEU.js → projects-T4CZCA25.js} +3 -6
  103. package/dist/provider-config-utils.d.ts +1 -6
  104. package/dist/provider-helpers.d.ts +7 -11
  105. package/dist/{providers-models-LFNZ5WI7.js → providers-models-5Z2PJTEW.js} +44 -34
  106. package/dist/release-asset-download.d.ts +13 -0
  107. package/dist/release-attestation.d.ts +28 -0
  108. package/dist/remote/remote-session.d.ts +64 -0
  109. package/dist/remote/remote-target.d.ts +69 -0
  110. package/dist/remote-O5WXHLWV.js +561 -0
  111. package/dist/{replay-Z3FTJEMM.js → replay-DEI566CW.js} +2 -2
  112. package/dist/services/commit-message.d.ts +2 -1
  113. package/dist/services/dispatch-classifier.d.ts +39 -5
  114. package/dist/session-move-P2EC2COA.js +44 -0
  115. package/dist/session-move.d.ts +20 -0
  116. package/dist/session-stats.d.ts +10 -0
  117. package/dist/{sessions-config-UL45XKX7.js → sessions-config-SXTTLNXA.js} +47 -9
  118. package/dist/settings-menu.d.ts +2 -0
  119. package/dist/short-circuit-flags-74Y5N6CF.js +10 -0
  120. package/dist/{simpleui-dist-CXSIDAXZ.js → simpleui-dist-7BQISSEP.js} +7 -3
  121. package/dist/skill-suggest-L2EVWB6R.js +290 -0
  122. package/dist/slash-commands/command-context.d.ts +15 -5
  123. package/dist/slash-commands/effort.d.ts +1 -1
  124. package/dist/slash-commands/fallback.d.ts +1 -1
  125. package/dist/slash-commands/gitid.d.ts +1 -1
  126. package/dist/slash-commands/goal-refiner.d.ts +4 -49
  127. package/dist/slash-commands/jev.d.ts +4 -0
  128. package/dist/slash-commands/mcp.d.ts +2 -1
  129. package/dist/slash-commands/openai-quota.d.ts +15 -0
  130. package/dist/slash-commands/permissions.d.ts +4 -0
  131. package/dist/slash-commands/sdd-task-mutations.d.ts +4 -0
  132. package/dist/slash-commands/settings-context-mutations.d.ts +5 -0
  133. package/dist/slash-commands/settings-keys.d.ts +2 -0
  134. package/dist/slash-commands/settings-limits-mutations.d.ts +12 -0
  135. package/dist/slash-commands/settings-reset.d.ts +6 -0
  136. package/dist/standalone-auto-update-TOTRGCSA.js +249 -0
  137. package/dist/standalone-auto-update.d.ts +65 -0
  138. package/dist/standalone-update-LZO3MNLH.js +24 -0
  139. package/dist/standalone-update.d.ts +55 -0
  140. package/dist/subcommands/handlers/hq-alerts.d.ts +3 -0
  141. package/dist/subcommands/handlers/hq-audit.d.ts +46 -0
  142. package/dist/subcommands/handlers/hq-data-dir.d.ts +13 -0
  143. package/dist/subcommands/handlers/import-claude-code.d.ts +42 -0
  144. package/dist/subcommands/handlers/permissions.d.ts +9 -3
  145. package/dist/subcommands/handlers/remote.d.ts +6 -0
  146. package/dist/subcommands/handlers/skill-suggest.d.ts +21 -0
  147. package/dist/subcommands/handlers/typesafe-brain-replay.d.ts +26 -0
  148. package/dist/subcommands/handlers/typesafe-judgment-check.d.ts +3 -0
  149. package/dist/subcommands/handlers/typesafe-topic-replay.d.ts +19 -0
  150. package/dist/subcommands/handlers/typesafe-triage-replay.d.ts +18 -0
  151. package/dist/subcommands/handlers/typesafe.d.ts +23 -0
  152. package/dist/subcommands/handlers/version-help.d.ts +5 -0
  153. package/dist/{subcommands-XSLXMIDP.js → subcommands-Q6ORSB2E.js} +2 -2
  154. package/dist/tui-resume-callback.d.ts +18 -0
  155. package/dist/typesafe-U7YB2RRV.js +316 -0
  156. package/dist/typesafe-brain-replay-C5276FVR.js +222 -0
  157. package/dist/typesafe-judgment-check-GGYYV5UF.js +29 -0
  158. package/dist/typesafe-topic-replay-ZILIU3WS.js +234 -0
  159. package/dist/typesafe-triage-replay-FGAW7QM7.js +215 -0
  160. package/dist/{update-5DPB4YD4.js → update-TDZX4IL2.js} +4 -3
  161. package/dist/{update-check-BS3DHTSI.js → update-check-J5ZVKS73.js} +3 -2
  162. package/dist/update-check.d.ts +1 -1
  163. package/dist/version-JB2UAV2A.js +11 -0
  164. package/dist/version-help-XJJQ7YSH.js +10 -0
  165. package/dist/version.d.ts +3 -2
  166. package/dist/webui-client-observability.d.ts +7 -0
  167. package/dist/webui-server/route-contexts.d.ts +1 -1
  168. package/dist/webui-server/session-start-payload.d.ts +5 -1
  169. package/dist/{webui-server-MRPGTTKL.js → webui-server-YTHLRFD2.js} +577 -370
  170. package/dist/webui-server-lifecycle.d.ts +57 -0
  171. package/dist/webui-server-options.d.ts +11 -0
  172. package/dist/webui-server.d.ts +1 -1
  173. package/dist/wiring/brain-and-orchestration.d.ts +3 -1
  174. package/dist/wiring/cli-prompt-and-tools-setup.d.ts +9 -0
  175. package/dist/wiring/cli-slash-commands-setup.d.ts +1 -0
  176. package/dist/wiring/domain-glossary.d.ts +5 -4
  177. package/dist/wiring/lifecycle-plugins.d.ts +4 -2
  178. package/dist/wiring/metrics.d.ts +9 -1
  179. package/dist/wiring/pipeline.d.ts +2 -7
  180. package/dist/wiring/plugins.d.ts +4 -1
  181. package/dist/wiring/provider-persisters.d.ts +24 -0
  182. package/dist/wiring/provider-runtime.d.ts +9 -1
  183. package/dist/wiring/provider-status.d.ts +1 -0
  184. package/dist/wiring/provider-utility-tools.d.ts +3 -1
  185. package/dist/wiring/runtime-dispatch-state.d.ts +3 -1
  186. package/package.json +28 -28
  187. package/dist/chunk-2CZEORLV.js +0 -54
  188. package/dist/chunk-672UXYL3.js +0 -65
  189. package/dist/chunk-6WRKAACA.js +0 -96
  190. package/dist/chunk-DR2OXU46.js +0 -174
  191. package/dist/chunk-JACOMTIH.js +0 -275
  192. package/dist/chunk-XJXDOF63.js +0 -28
  193. package/dist/modeldiag-CJSFHZ3J.js +0 -1356
  194. package/dist/short-circuit-flags-7GQIGMVD.js +0 -10
  195. package/dist/version-help-WXI42PZ3.js +0 -10
@@ -0,0 +1,143 @@
1
+
2
+ // src/boot/stream-json.ts
3
+ function parseOutputFormat(value) {
4
+ if (value === void 0) return void 0;
5
+ if (value === "text" || value === "json" || value === "stream-json") return value;
6
+ throw new Error(
7
+ `--output-format must be text, json or stream-json (got ${value === true ? "nothing" : `"${value}"`})`
8
+ );
9
+ }
10
+ var LEADER = "leader";
11
+ function isLeader(agentId) {
12
+ return agentId === void 0 || agentId === LEADER;
13
+ }
14
+ function simplifyBlocks(content) {
15
+ const out = [];
16
+ for (const block of content ?? []) {
17
+ if (block.type === "text") out.push({ type: "text", text: block.text });
18
+ else if (block.type === "tool_use") {
19
+ out.push({ type: "tool_use", id: block.id, name: block.name, input: block.input });
20
+ }
21
+ }
22
+ return out;
23
+ }
24
+ function startStreamJson(opts) {
25
+ const emit = (payload) => {
26
+ opts.write(`${JSON.stringify(payload)}
27
+ `);
28
+ };
29
+ const offs = [];
30
+ if (opts.includePartialMessages) {
31
+ offs.push(
32
+ opts.events.on("provider.text_delta", (e) => {
33
+ if (isLeader(e.ctx?.agentId)) emit({ type: "text_delta", text: e.text });
34
+ })
35
+ );
36
+ }
37
+ offs.push(
38
+ opts.events.on("provider.response", (e) => {
39
+ if (!isLeader(e.ctx?.agentId)) return;
40
+ emit({
41
+ type: "assistant",
42
+ model: e.model,
43
+ content: simplifyBlocks(e.content),
44
+ stopReason: e.stopReason,
45
+ usage: e.usage
46
+ });
47
+ })
48
+ );
49
+ offs.push(
50
+ opts.events.on("tool.executed", (e) => {
51
+ if (!isLeader(e.agentId)) return;
52
+ emit({
53
+ type: "tool_result",
54
+ id: e.id ?? null,
55
+ name: e.name,
56
+ ok: e.ok,
57
+ durationMs: e.durationMs,
58
+ output: e.output ?? null,
59
+ outputBytes: e.outputBytes ?? null
60
+ });
61
+ })
62
+ );
63
+ return () => {
64
+ for (const off of offs) off();
65
+ };
66
+ }
67
+ function streamJsonInit(info) {
68
+ return `${JSON.stringify({ type: "init", ...info })}
69
+ `;
70
+ }
71
+
72
+ // src/boot/structured-output.ts
73
+ import * as fs from "node:fs/promises";
74
+ import * as path from "node:path";
75
+ import { validateAgainstSchema } from "@wrongstack/core/utils";
76
+ async function resolveJsonSchemaFlag(value, cwd) {
77
+ if (value === void 0) return void 0;
78
+ if (typeof value !== "string" || !value.trim()) {
79
+ throw new Error("--json-schema needs a JSON Schema file path or an inline JSON object");
80
+ }
81
+ const trimmed = value.trim();
82
+ let text = trimmed;
83
+ let source = "inline JSON";
84
+ if (!trimmed.startsWith("{")) {
85
+ const file = path.resolve(cwd, trimmed);
86
+ source = file;
87
+ try {
88
+ text = await fs.readFile(file, "utf8");
89
+ } catch (err) {
90
+ const reason = err.code ?? String(err);
91
+ throw new Error(`--json-schema: cannot read ${file} (${reason})`);
92
+ }
93
+ }
94
+ let schema;
95
+ try {
96
+ schema = JSON.parse(text);
97
+ } catch (err) {
98
+ throw new Error(`--json-schema: ${source} is not valid JSON (${err.message})`);
99
+ }
100
+ if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
101
+ throw new Error(`--json-schema: ${source} must be a JSON Schema object`);
102
+ }
103
+ return schema;
104
+ }
105
+ function withSchemaInstruction(query, schema) {
106
+ return `${query}
107
+
108
+ When you are done, reply with ONLY a JSON value that validates against this JSON Schema \u2014 no prose, no code fence:
109
+ ${JSON.stringify(schema)}`;
110
+ }
111
+ function checkStructuredAnswer(text, schema) {
112
+ if (!text?.trim()) return { ok: false, errors: ["the answer was empty"] };
113
+ const fenced = text.trim().match(/^```(?:json)?\s*\n([\s\S]*?)\n?```$/);
114
+ const body = (fenced?.[1] ?? text).trim();
115
+ let value;
116
+ try {
117
+ value = JSON.parse(body);
118
+ } catch (err) {
119
+ return { ok: false, errors: [`not valid JSON (${err.message})`] };
120
+ }
121
+ const result = validateAgainstSchema(value, schema);
122
+ if (result.ok) return { ok: true, value };
123
+ return {
124
+ ok: false,
125
+ errors: result.errors.map((e) => `${e.path || "(root)"}: ${e.message}`)
126
+ };
127
+ }
128
+ function repairPrompt(errors) {
129
+ return `Your last answer did not validate against the JSON Schema:
130
+ ${errors.map((e) => `- ${e}`).join("\n")}
131
+ Reply with ONLY the corrected JSON value.`;
132
+ }
133
+
134
+ export {
135
+ parseOutputFormat,
136
+ startStreamJson,
137
+ streamJsonInit,
138
+ resolveJsonSchemaFlag,
139
+ withSchemaInstruction,
140
+ checkStructuredAnswer,
141
+ repairPrompt
142
+ };
143
+ //# sourceMappingURL=chunk-LKPEBZBE.js.map
@@ -0,0 +1,171 @@
1
+
2
+ // src/provider-config-utils.ts
3
+ import { FsError } from "@wrongstack/core/types";
4
+ import { expectDefined } from "@wrongstack/core/utils";
5
+ import * as fs from "node:fs/promises";
6
+ import * as path from "node:path";
7
+ import {
8
+ decryptConfigSecrets,
9
+ decryptConfigSecretsForRewrite,
10
+ encryptConfigSecrets
11
+ } from "@wrongstack/core/security";
12
+ import { atomicWrite, backupConfigFile, color, withFileLock } from "@wrongstack/core/utils";
13
+ import {
14
+ clearStaleProviderDefaults,
15
+ removeProviderFallbackReferences,
16
+ validateProviderConfigShape
17
+ } from "@wrongstack/providers";
18
+ import { clearStaleProviderDefaults as clearStaleProviderDefaults2 } from "@wrongstack/providers";
19
+ import { nowIso } from "@wrongstack/primitives";
20
+ function normalizeKeys(cfg) {
21
+ if (Array.isArray(cfg.apiKeys) && cfg.apiKeys.length > 0) {
22
+ return cfg.apiKeys.map((k) => ({ ...k }));
23
+ }
24
+ if (typeof cfg.apiKey === "string" && cfg.apiKey.length > 0) {
25
+ return [{ label: "default", apiKey: cfg.apiKey, createdAt: "" }];
26
+ }
27
+ return [];
28
+ }
29
+ function writeKeysBack(cfg, keys) {
30
+ if (keys.length === 0) {
31
+ delete cfg.apiKeys;
32
+ delete cfg.apiKey;
33
+ delete cfg.activeKey;
34
+ return;
35
+ }
36
+ cfg.apiKeys = keys;
37
+ const active = keys.find((k) => k.label === cfg.activeKey) ?? expectDefined(keys[0]);
38
+ delete cfg.apiKey;
39
+ if (!cfg.activeKey || !keys.some((k) => k.label === cfg.activeKey)) {
40
+ cfg.activeKey = active.label;
41
+ }
42
+ }
43
+ function resolveActiveApiKey(cfg) {
44
+ if (Array.isArray(cfg.apiKeys) && cfg.apiKeys.length > 0) {
45
+ const active = cfg.activeKey ? cfg.apiKeys.find((k) => k.label === cfg.activeKey) : void 0;
46
+ return (active ?? cfg.apiKeys[0])?.apiKey;
47
+ }
48
+ return cfg.apiKey && cfg.apiKey.length > 0 ? cfg.apiKey : void 0;
49
+ }
50
+ function activeLabel(cfg, keys) {
51
+ if (cfg.activeKey && keys.some((k) => k.label === cfg.activeKey)) return cfg.activeKey;
52
+ return keys[0]?.label;
53
+ }
54
+ function maskedKey(key) {
55
+ if (!key) return color.dim("\u2014");
56
+ if (key.length <= 8) return color.dim("\u2022".repeat(key.length));
57
+ const head = key.slice(0, 4);
58
+ const tail = key.slice(-4);
59
+ return `${color.dim(head + "\u2026")}${tail}`;
60
+ }
61
+ async function loadConfigProviders(configPath, vault, opts) {
62
+ const warn = opts?.warn;
63
+ const targetPath = opts?.profileConfigPath ?? configPath;
64
+ let raw;
65
+ try {
66
+ raw = await fs.readFile(targetPath, "utf8");
67
+ } catch (err) {
68
+ if (err.code !== "ENOENT") {
69
+ warn?.(`Could not read ${targetPath}: ${err.message}. Treating as empty.`);
70
+ }
71
+ return {};
72
+ }
73
+ let parsed;
74
+ try {
75
+ parsed = JSON.parse(raw);
76
+ validateProviderConfigShape(parsed);
77
+ } catch (err) {
78
+ warn?.(`Config at ${targetPath} is not valid JSON: ${err.message}`);
79
+ return {};
80
+ }
81
+ const decrypted = decryptConfigSecrets(parsed, vault);
82
+ return decrypted.providers ?? {};
83
+ }
84
+ var configMutationChain = Promise.resolve();
85
+ function globalRootForConfigPath(configPath) {
86
+ const configDir = path.dirname(configPath);
87
+ const profilesDir = path.dirname(configDir);
88
+ return path.basename(profilesDir) === "profiles" ? path.dirname(profilesDir) : configDir;
89
+ }
90
+ function queueConfigMutation(mutate) {
91
+ const run = configMutationChain.then(mutate, mutate);
92
+ configMutationChain = run.then(
93
+ () => void 0,
94
+ () => void 0
95
+ );
96
+ return run;
97
+ }
98
+ async function mutateConfigProviders(configPath, vault, mutator, profileConfigPath) {
99
+ await queueConfigMutation(
100
+ () => withFileLock(profileConfigPath ?? configPath, async () => {
101
+ const targetPath = profileConfigPath ?? configPath;
102
+ let raw;
103
+ let fileExists = true;
104
+ try {
105
+ raw = await fs.readFile(targetPath, "utf8");
106
+ } catch (err) {
107
+ if (err.code !== "ENOENT") {
108
+ throw new FsError({
109
+ message: `Refusing to mutate ${configPath}: ${err.message}`,
110
+ code: "FS_READ_FAILED",
111
+ path: targetPath,
112
+ context: { operation: "mutateConfigProviders", phase: "read" },
113
+ cause: err
114
+ });
115
+ }
116
+ fileExists = false;
117
+ raw = "{}";
118
+ }
119
+ let parsed;
120
+ try {
121
+ parsed = JSON.parse(raw);
122
+ validateProviderConfigShape(parsed);
123
+ } catch (err) {
124
+ if (fileExists) {
125
+ throw new FsError({
126
+ message: `Refusing to overwrite corrupt config at ${targetPath} (${err.message}). Fix or move the file aside before retrying.`,
127
+ code: "FS_READ_FAILED",
128
+ path: targetPath,
129
+ context: { operation: "mutateConfigProviders", phase: "parse" },
130
+ cause: err
131
+ });
132
+ }
133
+ parsed = {};
134
+ }
135
+ const decrypted = decryptConfigSecretsForRewrite(parsed, vault);
136
+ const providers = decrypted.providers ?? {};
137
+ const previousProviderIds = Object.keys(providers);
138
+ const primaryBefore = JSON.stringify([
139
+ decrypted["provider"],
140
+ decrypted["model"],
141
+ typeof decrypted["provider"] === "string" ? providers[decrypted["provider"]] : void 0
142
+ ]);
143
+ mutator(providers, decrypted);
144
+ for (const id of previousProviderIds) {
145
+ if (!Object.hasOwn(providers, id)) removeProviderFallbackReferences(decrypted, id);
146
+ }
147
+ decrypted.providers = providers;
148
+ const primaryAfter = JSON.stringify([
149
+ decrypted["provider"],
150
+ decrypted["model"],
151
+ typeof decrypted["provider"] === "string" ? providers[decrypted["provider"]] : void 0
152
+ ]);
153
+ clearStaleProviderDefaults(decrypted, { preservePrimary: primaryBefore === primaryAfter });
154
+ const encrypted = encryptConfigSecrets(decrypted, vault);
155
+ await backupConfigFile(targetPath, { globalRoot: globalRootForConfigPath(targetPath) });
156
+ await atomicWrite(targetPath, JSON.stringify(encrypted, null, 2), { mode: 384 });
157
+ })
158
+ );
159
+ }
160
+
161
+ export {
162
+ normalizeKeys,
163
+ writeKeysBack,
164
+ resolveActiveApiKey,
165
+ activeLabel,
166
+ maskedKey,
167
+ loadConfigProviders,
168
+ mutateConfigProviders,
169
+ nowIso
170
+ };
171
+ //# sourceMappingURL=chunk-LUMETJFO.js.map
@@ -641,6 +641,7 @@ import * as path6 from "node:path";
641
641
  import * as fs2 from "node:fs";
642
642
  import { createRequire } from "node:module";
643
643
  import * as path2 from "node:path";
644
+ import { wrongstackPackageJsonPath } from "@wrongstack/core/utils";
644
645
  var requireFromHere = createRequire(import.meta.url);
645
646
  var MIME = {
646
647
  ".html": "text/html; charset=utf-8",
@@ -660,7 +661,10 @@ var cachedDistDir;
660
661
  function resolveHqDistDir() {
661
662
  if (cachedDistDir !== void 0) return cachedDistDir;
662
663
  try {
663
- const pkgJson = requireFromHere.resolve("@wrongstack/webui-hq/package.json");
664
+ const pkgJson = wrongstackPackageJsonPath(
665
+ "@wrongstack/webui-hq",
666
+ (id) => requireFromHere.resolve(id)
667
+ );
664
668
  const dist = path2.join(path2.dirname(pkgJson), "dist");
665
669
  if (fs2.existsSync(path2.join(dist, "index.html"))) {
666
670
  cachedDistDir = dist;
@@ -687,7 +691,7 @@ function resolveHqDistDir() {
687
691
  }
688
692
  function isInsideDist(filePath, distDir) {
689
693
  const rel = path2.relative(distDir, filePath);
690
- return rel !== "" && !rel.startsWith("..") && !path2.isAbsolute(rel);
694
+ return rel !== "" && rel !== ".." && !rel.startsWith(`..${path2.sep}`) && !path2.isAbsolute(rel);
691
695
  }
692
696
  function isMissingPath(error) {
693
697
  const code = error.code;
@@ -2843,8 +2847,8 @@ async function handleApiAgentMessages(req, res, match, agentMessages) {
2843
2847
  // src/hq-server/routes/system-handlers.ts
2844
2848
  async function handleApiSystemUpdate(res) {
2845
2849
  const [{ checkForUpdate }, { detectUpdatePackageName }] = await Promise.all([
2846
- import("./update-check-BS3DHTSI.js"),
2847
- import("./update-5DPB4YD4.js")
2850
+ import("./update-check-J5ZVKS73.js"),
2851
+ import("./update-TDZX4IL2.js")
2848
2852
  ]);
2849
2853
  const packageName = detectUpdatePackageName();
2850
2854
  const info = await checkForUpdate({ packageName });
@@ -5146,4 +5150,4 @@ export {
5146
5150
  startHqServer,
5147
5151
  HqInsecureExposureError2 as HqInsecureExposureError
5148
5152
  };
5149
- //# sourceMappingURL=chunk-KK2LB3ZS.js.map
5153
+ //# sourceMappingURL=chunk-OAVBM55Q.js.map
@@ -0,0 +1,18 @@
1
+
2
+ // src/boot/ascii-mode.ts
3
+ import { installAsciiOutput, isAsciiMode } from "@wrongstack/core/utils";
4
+ var installed = false;
5
+ function applyAsciiMode(flags, env = process.env, streams = [process.stdout, process.stderr]) {
6
+ if (flags["ascii"] === true) env["WRONGSTACK_TUI_ICON_STYLE"] = "ascii";
7
+ if (!isAsciiMode(env)) return false;
8
+ if (!installed) {
9
+ installed = true;
10
+ for (const stream of streams) installAsciiOutput(stream);
11
+ }
12
+ return true;
13
+ }
14
+
15
+ export {
16
+ applyAsciiMode
17
+ };
18
+ //# sourceMappingURL=chunk-PZQBGUVZ.js.map
@@ -20,6 +20,34 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
20
20
  // Both are boolean so they cannot swallow the next positional token.
21
21
  "no-recovery",
22
22
  "recover",
23
+ // `--continue` / `-c`: resume the most recent session (same pick as a bare
24
+ // `--resume`). Boolean so `wstack -c "next step"` keeps the prompt.
25
+ "continue",
26
+ // `--fork-session` (with --resume/--continue/--recover): branch instead of reopening.
27
+ "fork-session",
28
+ // `--strict-mcp-config`: start only the `--mcp-config` servers.
29
+ "strict-mcp-config",
30
+ // `--include-partial-messages`: add text_delta events to stream-json output.
31
+ "include-partial-messages",
32
+ // `--safe-mode`: start with plugins/hooks/MCP/skills/instruction overrides off.
33
+ "safe-mode",
34
+ // `--restricted`: no code-running/network tools, project-root lock, no YOLO.
35
+ "restricted",
36
+ // `--record` is read as `=== true`; as a value flag it swallowed the task
37
+ // (`wstack --record "fix it"` recorded nothing and ran nothing).
38
+ "record",
39
+ // Same class: switches read only as `=== true` that would otherwise take the
40
+ // next token (`--vector-sync "task"`, `typesafe lint-conventions --staged x`).
41
+ "vector-sync",
42
+ "allow-all",
43
+ "no-llm",
44
+ "staged",
45
+ "sweep",
46
+ "n",
47
+ // `wstack import-claude-code` switches.
48
+ "apply",
49
+ "overwrite",
50
+ "enable-project-servers",
23
51
  "output-json",
24
52
  "metrics",
25
53
  "webui",
@@ -28,6 +56,8 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
28
56
  "full-auto",
29
57
  "desktop",
30
58
  "open",
59
+ // `wstack remote --keep`: leave the remote host running after disconnecting.
60
+ "keep",
31
61
  "webui-require-token",
32
62
  "require-token",
33
63
  "no-check",
@@ -39,6 +69,7 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
39
69
  "skip",
40
70
  "skip-index",
41
71
  "mouse",
72
+ "ascii",
42
73
  "no-interactive",
43
74
  "token-saving-mode",
44
75
  "system-lite",
@@ -139,7 +170,13 @@ function parseArgs(argv) {
139
170
  }
140
171
  } else if (a.startsWith("-") && a.length === 2) {
141
172
  const short = a.slice(1);
142
- const expand = { v: "verbose", y: "yes", h: "help" };
173
+ const expand = {
174
+ v: "verbose",
175
+ y: "yes",
176
+ h: "help",
177
+ c: "continue",
178
+ r: "resume"
179
+ };
143
180
  const name = expand[short] ?? short;
144
181
  if (!BOOLEAN_FLAGS.has(name) && i + 1 < argv.length && !(argv[i + 1] ?? "").startsWith("-")) {
145
182
  flags[name] = argv[++i] ?? "";
@@ -151,6 +188,13 @@ function parseArgs(argv) {
151
188
  }
152
189
  }
153
190
  normalizeSurfaceAliases(flags, positional);
191
+ for (const [camel, kebab] of [
192
+ ["disallowedTools", "disallowed-tools"],
193
+ ["allowedTools", "allowed-tools"]
194
+ ]) {
195
+ if (flags[camel] !== void 0 && flags[kebab] === void 0) flags[kebab] = flags[camel];
196
+ delete flags[camel];
197
+ }
154
198
  return { flags, positional };
155
199
  }
156
200
  function normalizeSurfaceAliases(flags, positional) {
@@ -185,7 +229,11 @@ function parseAuthFlags(args) {
185
229
  key = a.slice(0, eq);
186
230
  inlineVal = a.slice(eq + 1);
187
231
  }
188
- if (key === "--label") {
232
+ if (key === "--alias") {
233
+ const next = args[i + 1];
234
+ const v = inlineVal !== void 0 ? inlineVal : next !== void 0 && !next.startsWith("-") ? args[++i] : "";
235
+ out.alias = v ?? "";
236
+ } else if (key === "--label") {
189
237
  const v = inlineVal !== void 0 ? inlineVal : args[++i];
190
238
  if (v) out.label = v;
191
239
  } else if (key === "--family") {
@@ -258,4 +306,4 @@ export {
258
306
  parseAuthFlags,
259
307
  parseSpawnFlags
260
308
  };
261
- //# sourceMappingURL=chunk-C3Z4N6A6.js.map
309
+ //# sourceMappingURL=chunk-Q4INH2DG.js.map
@@ -0,0 +1,10 @@
1
+
2
+ // src/webui-server/kanban-supervisor.ts
3
+ import {
4
+ createKanbanSupervisor
5
+ } from "@wrongstack/webui-server";
6
+
7
+ export {
8
+ createKanbanSupervisor
9
+ };
10
+ //# sourceMappingURL=chunk-R4QGL6GB.js.map
@@ -1,3 +1,6 @@
1
+ import {
2
+ CLI_VERSION
3
+ } from "./chunk-F5DCFAKI.js";
1
4
 
2
5
  // src/update-check.ts
3
6
  import * as fs from "node:fs/promises";
@@ -5,7 +8,12 @@ import { createRequire } from "node:module";
5
8
  import * as os from "node:os";
6
9
  import * as path from "node:path";
7
10
  import { FetchError } from "@wrongstack/core/types";
8
- import { atomicWrite, ensureDir, resolveWstackPaths } from "@wrongstack/core/utils";
11
+ import {
12
+ atomicWrite,
13
+ ensureDir,
14
+ isStandaloneBinary,
15
+ resolveWstackPaths
16
+ } from "@wrongstack/core/utils";
9
17
  var defaultHomeDir = () => os.homedir();
10
18
  function npmRegistryUrl(packageName) {
11
19
  return `https://registry.npmjs.org/${encodeURIComponent(packageName)}/latest`;
@@ -16,6 +24,7 @@ function cachePath(homeFn = defaultHomeDir) {
16
24
  }
17
25
  var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
18
26
  function currentVersion() {
27
+ if (isStandaloneBinary()) return CLI_VERSION;
19
28
  const req = createRequire(import.meta.url);
20
29
  const candidates = ["../package.json", "../../package.json"];
21
30
  for (const rel of candidates) {
@@ -118,7 +127,8 @@ async function checkForUpdate(signalOrOptions, legacyHomeFn) {
118
127
  const options = signalOrOptions instanceof AbortSignal ? { signal: signalOrOptions, homeFn: legacyHomeFn } : signalOrOptions ?? { homeFn: legacyHomeFn };
119
128
  const current = currentVersion();
120
129
  const signal = options.signal;
121
- const packageName = options.packageName ?? "wrongstack";
130
+ const standalone = isStandaloneBinary();
131
+ const packageName = standalone ? "standalone-binary" : options.packageName ?? "wrongstack";
122
132
  const aborted = () => signal?.aborted ?? false;
123
133
  const hf = options.homeFn ?? defaultHomeDir;
124
134
  if (aborted()) {
@@ -134,7 +144,7 @@ async function checkForUpdate(signalOrOptions, legacyHomeFn) {
134
144
  };
135
145
  }
136
146
  try {
137
- const latest = await fetchLatestFromNpm(packageName, 3e3, signal);
147
+ const latest = packageName === "standalone-binary" ? await (await import("./standalone-update-LZO3MNLH.js")).fetchLatestStandaloneVersion(3e3, signal) : await fetchLatestFromNpm(packageName, 3e3, signal);
138
148
  await writeCache({ timestamp: Date.now(), latestVersion: latest, packageName }, hf);
139
149
  return {
140
150
  current,
@@ -173,4 +183,4 @@ export {
173
183
  checkForUpdate,
174
184
  getUpdateNotification
175
185
  };
176
- //# sourceMappingURL=chunk-YLQEGYV4.js.map
186
+ //# sourceMappingURL=chunk-RZ4ZDRYA.js.map
@@ -0,0 +1,93 @@
1
+
2
+ // src/wiring/provider-runtime.ts
3
+ import {
4
+ getProxyConfig,
5
+ isProxyEligible,
6
+ rewriteBaseUrl,
7
+ sanitizeUrlForLog,
8
+ shouldRewriteFor
9
+ } from "@wrongstack/core/wiring/proxy-rewrite";
10
+ import { makeProviderFromConfig } from "@wrongstack/providers";
11
+ function resolveRawProviderConnection(config, providerId) {
12
+ const savedCfg = config.providers?.[providerId];
13
+ const isAccountAlias = savedCfg?.type !== void 0 && savedCfg.type !== providerId;
14
+ const inheritsPrimary = !isAccountAlias && (config.provider === void 0 || config.provider === providerId);
15
+ return {
16
+ apiKey: savedCfg?.apiKey ?? (inheritsPrimary ? config.apiKey : void 0),
17
+ baseUrl: savedCfg?.baseUrl ?? (inheritsPrimary ? config.baseUrl : void 0)
18
+ };
19
+ }
20
+ function resolveProviderCfg(config, providerId, opts) {
21
+ const savedCfg = config.providers?.[providerId];
22
+ const proxyProviderType = savedCfg?.family === "openai-codex" ? "openai-codex" : savedCfg?.type ?? providerId;
23
+ const connection = resolveRawProviderConnection(config, providerId);
24
+ const rawBaseUrl = connection.baseUrl;
25
+ let rewriteReason = "no-base-url";
26
+ let baseUrl = rawBaseUrl;
27
+ if (rawBaseUrl && shouldRewriteFor(proxyProviderType)) {
28
+ const rewritten = rewriteBaseUrl(rawBaseUrl, currentProxyBaseUrl());
29
+ if (rewritten !== rawBaseUrl) {
30
+ rewriteReason = "applied";
31
+ baseUrl = rewritten;
32
+ } else {
33
+ rewriteReason = passthroughReason(rawBaseUrl);
34
+ }
35
+ } else if (rawBaseUrl) {
36
+ rewriteReason = proxySkipReason(proxyProviderType);
37
+ }
38
+ opts?.logger?.info(
39
+ `WrongProxy rewrite ${rewriteReason} for provider '${providerId}': ${sanitizeUrlForLog(rawBaseUrl) || "<none>"} -> ${sanitizeUrlForLog(baseUrl) || "<none>"}`
40
+ );
41
+ const cfg = {
42
+ ...savedCfg,
43
+ apiKey: connection.apiKey,
44
+ baseUrl,
45
+ type: providerId
46
+ };
47
+ const factoryType = savedCfg?.type ?? providerId;
48
+ return { cfg, factoryType };
49
+ }
50
+ function passthroughReason(rawBaseUrl) {
51
+ if (!rawBaseUrl.includes("://")) return "no-scheme";
52
+ const proxyRoot = currentProxyBaseUrl().replace(/\/+$/, "");
53
+ if (proxyRoot && rawBaseUrl.startsWith(`${proxyRoot}/proxy/`)) {
54
+ return "already-rewritten";
55
+ }
56
+ try {
57
+ const parsed = new URL(rawBaseUrl);
58
+ const host = parsed.hostname;
59
+ const isLoopback = host === "localhost" || host === "127.0.0.1" || host === "[::1]";
60
+ if (isLoopback && parsed.port !== "") return "loopback";
61
+ } catch {
62
+ }
63
+ return "ineligible";
64
+ }
65
+ function proxySkipReason(providerId) {
66
+ const cfg = getProxyConfig();
67
+ if (!cfg.enabled) return "disabled";
68
+ if (!cfg.url) return "no-proxy-url";
69
+ if (!cfg.active) return "inactive";
70
+ if (!isProxyEligible(providerId)) return "excluded";
71
+ return "unknown";
72
+ }
73
+ function currentProxyBaseUrl() {
74
+ return getProxyConfig().url;
75
+ }
76
+ function resolveProviderCfgWithProxy(config, providerId, opts) {
77
+ return resolveProviderCfg(config, providerId, opts);
78
+ }
79
+ function buildProviderForId(args, providerId) {
80
+ const { cfg, factoryType } = resolveProviderCfg(args.config, providerId, {
81
+ logger: args.logger
82
+ });
83
+ const useRegistry = !!args.config.features.modelsRegistry && args.providerRegistry.has(factoryType);
84
+ return useRegistry ? args.providerRegistry.create(cfg, factoryType) : makeProviderFromConfig(providerId, { ...cfg, type: factoryType });
85
+ }
86
+
87
+ export {
88
+ resolveRawProviderConnection,
89
+ resolveProviderCfg,
90
+ resolveProviderCfgWithProxy,
91
+ buildProviderForId
92
+ };
93
+ //# sourceMappingURL=chunk-S4FFHDJG.js.map