@wrongstack/cli 0.299.0 → 0.301.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/{acp-S4LZQB66.js → acp-DATHHPNT.js} +36 -17
  2. package/dist/acp-server-agent.d.ts +1 -1
  3. package/dist/{audit-2ZSFGNIF.js → audit-QRCLEHHW.js} +5 -1
  4. package/dist/{auth-G5YKKSRH.js → auth-JASC4K3F.js} +151 -38
  5. package/dist/auth-menu/loopback-server.d.ts +41 -55
  6. package/dist/auth-menu/openai-codex-oauth.d.ts +36 -123
  7. package/dist/auto-discover-providers-DRW4OZHG.js +8 -0
  8. package/dist/boot/dispatch-webui.d.ts +3 -0
  9. package/dist/boot/launch-menu.d.ts +2 -4
  10. package/dist/boot/tool-registry.d.ts +3 -0
  11. package/dist/chimera-reviewer-policy.d.ts +10 -3
  12. package/dist/chimera-work-registry.d.ts +19 -0
  13. package/dist/{chronicle-QQEQFSSE.js → chronicle-63MFCZN6.js} +26 -5
  14. package/dist/{chunk-YWUPHRGB.js → chunk-263G3FMB.js} +33 -10
  15. package/dist/{chunk-2SLSUDYS.js → chunk-2KDOFTTM.js} +312 -211
  16. package/dist/{chunk-TGDHN4LM.js → chunk-4GVH7V3S.js} +4 -24
  17. package/dist/chunk-CSAPOCBP.js +24 -0
  18. package/dist/{chunk-66T43Q4Y.js → chunk-ETOEGL3V.js} +6 -9
  19. package/dist/{chunk-PEKUKUCH.js → chunk-GUHQQG63.js} +32 -14
  20. package/dist/chunk-KE7E7DPX.js +38 -0
  21. package/dist/{chunk-ZNZJ34RF.js → chunk-MHF2IJDE.js} +21 -4
  22. package/dist/{chunk-4HH3YGG4.js → chunk-MRLYDHQ7.js} +8 -5
  23. package/dist/{chunk-L5CE52XW.js → chunk-O7XNGCRT.js} +317 -309
  24. package/dist/chunk-PYTFS4MC.js +238 -0
  25. package/dist/{chunk-DPJZQCVP.js → chunk-YMXXOOFN.js} +1 -1
  26. package/dist/{chunk-4U3DMA2Y.js → chunk-ZECLGUTF.js} +28 -21
  27. package/dist/{cli-main-3MQDFSYK.js → cli-main-XWC57MGE.js} +849 -242
  28. package/dist/{execution-ANOYMWPO.js → execution-LHMSMDHB.js} +174 -55
  29. package/dist/execution-chimera-cascade.d.ts +3 -4
  30. package/dist/execution-chimera-review.d.ts +2 -3
  31. package/dist/execution-cleanup.d.ts +3 -2
  32. package/dist/execution.d.ts +1 -1
  33. package/dist/{export-TPORYVRZ.js → export-DOBGPY23.js} +12 -1
  34. package/dist/fleet/budget-source.d.ts +18 -0
  35. package/dist/fleet/host-context.d.ts +1 -1
  36. package/dist/fleet/host-helpers.d.ts +14 -0
  37. package/dist/fleet/host-status.d.ts +31 -0
  38. package/dist/fleet/host-types.d.ts +8 -0
  39. package/dist/fleet/host.d.ts +5 -0
  40. package/dist/fleet/status-broadcast.d.ts +1 -1
  41. package/dist/{hq-BDO56CX6.js → hq-LN5CJHCM.js} +22 -3
  42. package/dist/hq-server/auth-state.d.ts +29 -1
  43. package/dist/hq-server/auth.d.ts +16 -0
  44. package/dist/hq-server/client-address.d.ts +56 -0
  45. package/dist/hq-server/login-attempt-store.d.ts +30 -10
  46. package/dist/hq-server/routes/auth-handlers.d.ts +66 -26
  47. package/dist/hq-server/routes.d.ts +23 -1
  48. package/dist/hq-server/types.d.ts +10 -0
  49. package/dist/hq-server/ws.d.ts +17 -6
  50. package/dist/{hq-server-RJLJJZU7.js → hq-server-S7HZG3PA.js} +3 -2
  51. package/dist/hq-server.d.ts +19 -0
  52. package/dist/index.js +69 -104
  53. package/dist/live-settings-input.d.ts +5 -0
  54. package/dist/{mcp-CYLPUEHC.js → mcp-OHPJH73U.js} +6 -2
  55. package/dist/{modeldiag-HENYJ4N7.js → modeldiag-3DOK4BWW.js} +3 -3
  56. package/dist/{plugin-usage-VTL7ZTVC.js → plugin-usage-YEVLOR33.js} +7 -3
  57. package/dist/{plugins-ETY6W3DC.js → plugins-K3BAUP4D.js} +3 -3
  58. package/dist/profile-config-path.d.ts +0 -2
  59. package/dist/provider-helpers.d.ts +0 -5
  60. package/dist/{providers-models-GDELBHZK.js → providers-models-WEZ4EGLL.js} +38 -12
  61. package/dist/{replay-KCTXNMZQ.js → replay-FCBNHW3K.js} +5 -1
  62. package/dist/{rewind-EJMVFVLS.js → rewind-AOD3JIYX.js} +5 -1
  63. package/dist/{sessions-config-NLCMK3BY.js → sessions-config-XXN7267N.js} +8 -3
  64. package/dist/slash-commands/command-context.d.ts +19 -0
  65. package/dist/subcommands/flags.d.ts +23 -0
  66. package/dist/terminal-format.d.ts +15 -0
  67. package/dist/webui-server/setup-events.d.ts +17 -0
  68. package/dist/webui-server/terminal-log-view.d.ts +29 -12
  69. package/dist/{webui-server-PCLSXX6L.js → webui-server-DD35QFNO.js} +113 -50
  70. package/dist/webui-server-options.d.ts +16 -0
  71. package/dist/wiring/brain-and-orchestration.d.ts +4 -1
  72. package/dist/wiring/director-setup.d.ts +4 -0
  73. package/dist/wiring/fallback-gate.d.ts +31 -0
  74. package/dist/wiring/fleet-command-handlers.d.ts +1 -1
  75. package/dist/wiring/mailbox-bridge-bootstrap.d.ts +3 -1
  76. package/dist/wiring/management-tools.d.ts +9 -1
  77. package/dist/wiring/pipeline.d.ts +5 -5
  78. package/dist/wiring/plugins.d.ts +3 -10
  79. package/dist/wiring/provider-utility-tools.d.ts +27 -1
  80. package/dist/wiring/tools.d.ts +4 -5
  81. package/package.json +23 -23
  82. package/dist/chunk-GO3TJICK.js +0 -489
@@ -0,0 +1,238 @@
1
+ import {
2
+ mutateConfigProviders,
3
+ normalizeKeys,
4
+ nowIso,
5
+ writeKeysBack
6
+ } from "./chunk-PJHET45A.js";
7
+
8
+ // src/auth-menu/openai-codex-oauth.ts
9
+ import { color } from "@wrongstack/core/utils";
10
+ import {
11
+ buildCodexAuthorizeUrl,
12
+ CODEX_BASE_URL,
13
+ CODEX_FALLBACK_REDIRECT_PORT,
14
+ CODEX_PROVIDER_ID,
15
+ CODEX_REDIRECT_HOST,
16
+ CODEX_REDIRECT_PATH,
17
+ CODEX_REDIRECT_PORT,
18
+ CODEX_SCOPE,
19
+ codexRedirectUri,
20
+ createState,
21
+ exchangeCodexAuthorizationCode,
22
+ extractAccountId,
23
+ generatePkce,
24
+ parseAuthorizationInput,
25
+ refreshCodexTokens,
26
+ resolveCodexModels
27
+ } from "@wrongstack/providers/oauth";
28
+
29
+ // src/auth-menu/loopback-server.ts
30
+ import { spawn } from "node:child_process";
31
+ import {
32
+ startLoopbackServer as startSharedLoopbackServer
33
+ } from "@wrongstack/providers/oauth";
34
+ import { callbackHtml } from "@wrongstack/providers/oauth";
35
+ function openBrowser(url) {
36
+ try {
37
+ const platform = process.platform;
38
+ const { command, args } = platform === "win32" ? { command: "cmd", args: ["/c", "start", "", url] } : platform === "darwin" ? { command: "open", args: [url] } : { command: "xdg-open", args: [url] };
39
+ const child = spawn(command, args, { stdio: "ignore", windowsHide: true });
40
+ child.on("error", () => {
41
+ });
42
+ child.unref();
43
+ } catch {
44
+ }
45
+ }
46
+ function startLoopbackServer(expectedState, ports, signal, callbackPath = "/auth/callback", redirectHost = "127.0.0.1") {
47
+ const [primary = 1455, ...fallbackPorts] = ports;
48
+ return startSharedLoopbackServer({
49
+ port: primary,
50
+ fallbackPorts: [...fallbackPorts],
51
+ host: redirectHost,
52
+ path: callbackPath,
53
+ expectedState,
54
+ ...signal ? { signal } : {}
55
+ });
56
+ }
57
+
58
+ // src/auth-menu/openai-codex-oauth.ts
59
+ import {
60
+ CODEX_BASE_URL as CODEX_BASE_URL2,
61
+ CODEX_CATALOG_FAMILIES,
62
+ CODEX_PROVIDER_ID as CODEX_PROVIDER_ID2,
63
+ extractAccountId as extractAccountId2,
64
+ FALLBACK_CODEX_MODELS,
65
+ fallbackCodexModelIds,
66
+ fallbackCodexProviderModels,
67
+ fetchCodexModels,
68
+ filterCurrentCodexModelIds,
69
+ generatePkce as generatePkce2,
70
+ isCodexCatalogModel,
71
+ parseAuthorizationInput as parseAuthorizationInput2,
72
+ resolveCodexModels as resolveCodexModels2
73
+ } from "@wrongstack/providers/oauth";
74
+ var buildAuthorizeUrl = buildCodexAuthorizeUrl;
75
+ var exchangeAuthorizationCode = exchangeCodexAuthorizationCode;
76
+ function startLoopbackServer2(expectedState, signal) {
77
+ return startLoopbackServer(
78
+ expectedState,
79
+ [CODEX_REDIRECT_PORT, CODEX_FALLBACK_REDIRECT_PORT],
80
+ signal,
81
+ CODEX_REDIRECT_PATH,
82
+ CODEX_REDIRECT_HOST
83
+ );
84
+ }
85
+ var redirectUri = codexRedirectUri;
86
+ async function runCodexOAuthLogin(deps, opts = {}) {
87
+ const providerId = opts.providerId ?? CODEX_PROVIDER_ID;
88
+ const pkce = generatePkce();
89
+ const state = createState();
90
+ const ac = new AbortController();
91
+ let sigintCount = 0;
92
+ const onSig = () => {
93
+ sigintCount += 1;
94
+ if (sigintCount === 1) {
95
+ deps.renderer.write(color.dim("\n Cancelling sign-in\u2026 (press Ctrl+C again to force-quit)\n"));
96
+ ac.abort();
97
+ } else {
98
+ process.exit(130);
99
+ }
100
+ };
101
+ const external = opts.signal;
102
+ const onExternalAbort = () => ac.abort();
103
+ if (external) {
104
+ if (external.aborted) ac.abort();
105
+ else external.addEventListener("abort", onExternalAbort, { once: true });
106
+ } else {
107
+ process.on("SIGINT", onSig);
108
+ }
109
+ const server = await startLoopbackServer2(state, ac.signal);
110
+ const authorizeUrl = buildAuthorizeUrl(pkce.challenge, state, server.port);
111
+ const osc8 = (url) => `\x1B]8;;${url}\x1B\\${url}\x1B]8;;\x1B\\`;
112
+ deps.renderer.write(
113
+ color.bold(`
114
+ Sign in with ChatGPT \u2014 ${color.cyan(providerId)}
115
+ `) + color.dim(" Uses your ChatGPT Plus/Pro/Team subscription (not an API key).\n") + color.amber(" \u26A0 Using a subscription outside the official Codex client may violate\n") + color.amber(" OpenAI\u2019s Terms \u2014 your account could be rate-limited or banned.\n") + color.dim(" Sanctioned programmatic use = an API key: ") + color.bold("wstack auth openai") + color.dim("\n\n") + color.bold(` ${"\u2500".repeat(56)}
116
+ `) + color.bold(" Open this URL in your browser to sign in:\n") + color.cyan(` ${osc8(authorizeUrl)}
117
+ `) + color.bold(` ${"\u2500".repeat(56)}
118
+
119
+ `)
120
+ );
121
+ if (server.bound) {
122
+ openBrowser(authorizeUrl);
123
+ deps.renderer.write(
124
+ color.dim(" A browser window should open. Waiting for you to finish signing in...\n") + color.dim(` (Listening on ${redirectUri(server.port)} \u2014 press Ctrl+C to cancel.)
125
+ `)
126
+ );
127
+ } else {
128
+ deps.renderer.write(
129
+ color.amber(" \u26A0 Could not start the local callback listener (ports 1455 and 1457 in use).\n") + color.dim(" After signing in, copy the full redirect URL from your browser\n") + color.dim(" (it starts with http://localhost:1455/auth/callback or :1457) and paste it below.\n")
130
+ );
131
+ }
132
+ let code;
133
+ try {
134
+ if (server.bound) {
135
+ const callback = await server.waitForCode();
136
+ if (ac.signal.aborted) {
137
+ deps.renderer.write(color.dim(" Cancelled.\n"));
138
+ return 1;
139
+ }
140
+ if (callback) code = callback.code;
141
+ }
142
+ if (!code) {
143
+ const input = (await deps.reader.readLine(
144
+ `
145
+ ${color.amber("?")} Paste the redirect URL or code ${color.dim("(or q to cancel)")}: `
146
+ )).trim();
147
+ if (input.toLowerCase() === "q" || input === "") {
148
+ deps.renderer.write(color.dim(" Cancelled.\n"));
149
+ return 1;
150
+ }
151
+ const parsed = parseAuthorizationInput(input);
152
+ if (parsed.state && parsed.state !== state) {
153
+ deps.renderer.writeError(" State mismatch \u2014 please restart the login flow.");
154
+ return 1;
155
+ }
156
+ code = parsed.code;
157
+ }
158
+ if (!code) {
159
+ deps.renderer.writeError(" No authorization code received.");
160
+ return 1;
161
+ }
162
+ deps.renderer.write(color.dim("\n Exchanging authorization code for tokens...\n"));
163
+ const tokens = await exchangeAuthorizationCode(code, pkce.verifier, ac.signal, server.port);
164
+ const accountId = extractAccountId(tokens.access) ?? (tokens.idToken ? extractAccountId(tokens.idToken) : null);
165
+ if (!accountId) {
166
+ deps.renderer.writeError(
167
+ " Signed in, but the token has no ChatGPT account id.\n This account may not have Codex/ChatGPT subscription access."
168
+ );
169
+ return 1;
170
+ }
171
+ deps.renderer.write(color.dim(" Fetching available models...\n"));
172
+ const models = await resolveCodexModels(
173
+ deps.modelsRegistry,
174
+ tokens.access,
175
+ CODEX_BASE_URL,
176
+ ac.signal
177
+ );
178
+ const saved = await saveCodexTokens(deps, providerId, tokens, accountId, models);
179
+ if (!saved) return 1;
180
+ const modelHint = models[0] ?? "gpt-5.5";
181
+ deps.renderer.write(color.green("\n \u2713 Signed in with ChatGPT!\n"));
182
+ deps.renderer.writeInfo(
183
+ ` Saved as provider ${color.bold(providerId)}${models.length > 0 ? ` (${models.length} models)` : ""}.
184
+ Use: ${color.bold(`wstack --provider ${providerId} --model ${modelHint}`)} "<task>"
185
+ ` + color.dim(" Tokens refresh automatically before they expire.\n")
186
+ );
187
+ return 0;
188
+ } catch (err) {
189
+ const msg = err instanceof DOMException && err.name === "AbortError" ? "Login cancelled." : err.message;
190
+ deps.renderer.writeError(` Login failed: ${msg}`);
191
+ return 1;
192
+ } finally {
193
+ server.close();
194
+ if (external) external.removeEventListener("abort", onExternalAbort);
195
+ else process.off("SIGINT", onSig);
196
+ }
197
+ }
198
+ async function saveCodexTokens(deps, providerId, tokens, accountId, models) {
199
+ const entry = {
200
+ label: "oauth-default",
201
+ apiKey: tokens.access,
202
+ createdAt: nowIso(),
203
+ authMethod: "oauth",
204
+ expiresAt: new Date(tokens.expires).toISOString(),
205
+ refreshToken: tokens.refresh,
206
+ tokenType: "bearer",
207
+ scope: CODEX_SCOPE,
208
+ accountId
209
+ };
210
+ try {
211
+ await mutateConfigProviders(deps.profileConfigPath, deps.vault, (all) => {
212
+ const existing = all[providerId];
213
+ const p = existing ? { ...existing } : { type: providerId };
214
+ p.family = "openai-codex";
215
+ if (!p.baseUrl) p.baseUrl = CODEX_BASE_URL;
216
+ p.models = [...models];
217
+ const keys = normalizeKeys(p).filter((k) => k.label !== entry.label);
218
+ keys.push(entry);
219
+ writeKeysBack(p, keys);
220
+ p.activeKey = entry.label;
221
+ all[providerId] = p;
222
+ }, deps.profileConfigPath);
223
+ return true;
224
+ } catch (err) {
225
+ deps.renderer.writeError(` Failed to save tokens: ${err.message}`);
226
+ return false;
227
+ }
228
+ }
229
+
230
+ export {
231
+ openBrowser,
232
+ startLoopbackServer,
233
+ runCodexOAuthLogin,
234
+ fallbackCodexProviderModels,
235
+ filterCurrentCodexModelIds,
236
+ isCodexCatalogModel
237
+ };
238
+ //# sourceMappingURL=chunk-PYTFS4MC.js.map
@@ -10,4 +10,4 @@ function activeProfileConfigPath(paths, config) {
10
10
  export {
11
11
  activeProfileConfigPath
12
12
  };
13
- //# sourceMappingURL=chunk-DPJZQCVP.js.map
13
+ //# sourceMappingURL=chunk-YMXXOOFN.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  PLUGIN_AUDIT_ENTRIES
3
- } from "./chunk-PEKUKUCH.js";
3
+ } from "./chunk-GUHQQG63.js";
4
4
  import {
5
5
  patchConfig
6
6
  } from "./chunk-TYO2OVAD.js";
7
7
 
8
8
  // src/wiring/plugins.ts
9
9
  import { join } from "node:path";
10
- import { loadPlugins, resolvePluginConfig } from "@wrongstack/core/plugin";
10
+ import { loadPlugins, resolvePluginConfig, resolvePluginEnablement } from "@wrongstack/core/plugin";
11
11
  import { OFFICIAL_PLUGIN_FACTORIES } from "@wrongstack/plugins/factories";
12
12
 
13
13
  // src/plugin-api-factory.ts
@@ -67,6 +67,10 @@ var BUILTIN_PLUGIN_FACTORIES = [
67
67
  const { createSyncPlugin } = await import("@wrongstack/core/plugin");
68
68
  return createSyncPlugin();
69
69
  },
70
+ async () => {
71
+ const { createCloudConfigSyncPlugin } = await import("@wrongstack/core/plugin");
72
+ return createCloudConfigSyncPlugin();
73
+ },
70
74
  async () => {
71
75
  const { createChimeraPlugin } = await import("@wrongstack/core/plugin");
72
76
  return createChimeraPlugin();
@@ -112,30 +116,25 @@ async function setupPlugins(params) {
112
116
  hookRegistry
113
117
  } = params;
114
118
  const builtinPlugins = [];
115
- const disabledBuiltins = new Set(
116
- (config.plugins ?? []).filter(
117
- (p) => typeof p === "object" && p.enabled === false
118
- ).flatMap((p) => {
119
- const builtinName = builtinPluginNameFromSpec(p.name);
120
- return builtinName && builtinName !== p.name ? [p.name, builtinName] : [p.name];
121
- })
122
- );
123
119
  if (paths && config.features?.plugins !== false) {
124
120
  for (const factory of BUILTIN_PLUGIN_FACTORIES) {
125
121
  try {
126
122
  const plugin = await factory();
127
123
  if (!plugin) continue;
128
124
  const auditEntry = PLUGIN_AUDIT_ENTRIES.find((entry) => entry.name === plugin.name);
129
- const explicitlyEnabled = (config.plugins ?? []).some((entry) => {
130
- const spec = typeof entry === "string" ? entry : entry.name;
131
- if (typeof entry === "object" && entry.enabled === false) return false;
132
- return (builtinPluginNameFromSpec(spec) ?? spec) === plugin.name;
125
+ const { enabled, source } = resolvePluginEnablement({
126
+ name: plugin.name,
127
+ aliases: plugin.configAliases,
128
+ // Built-ins outside the audit catalog (prompts, sync, skills, …)
129
+ // are infrastructure — they run unless explicitly turned off.
130
+ defaultState: auditEntry?.defaultState ?? "active",
131
+ config,
132
+ matches: (spec) => (builtinPluginNameFromSpec(spec) ?? spec) === plugin.name
133
133
  });
134
- if (auditEntry?.defaultState === "inactive" && !explicitlyEnabled) {
135
- continue;
136
- }
137
- if (disabledBuiltins.has(plugin.name)) {
138
- log.info(`[setupPlugins] built-in plugin "${plugin.name}" disabled by config`);
134
+ if (!enabled) {
135
+ if (source !== "default") {
136
+ log.info(`[setupPlugins] built-in plugin "${plugin.name}" disabled by ${source}`);
137
+ }
139
138
  continue;
140
139
  }
141
140
  if (warnIfDeprecatedPluginName(plugin.name, log)) continue;
@@ -148,8 +147,16 @@ async function setupPlugins(params) {
148
147
  const userPlugins = [];
149
148
  if (config.features?.plugins !== false) {
150
149
  for (const p of config.plugins ?? []) {
151
- if (typeof p === "object" && p.enabled === false) continue;
152
150
  const spec = typeof p === "string" ? p : p.name;
151
+ const { enabled } = resolvePluginEnablement({
152
+ name: pluginNameFromSpec(spec) ?? spec,
153
+ aliases: [spec],
154
+ defaultState: "active",
155
+ config,
156
+ // The resolver already extracts an entry's name before calling this.
157
+ matches: (configuredName) => configuredName === spec
158
+ });
159
+ if (!enabled) continue;
153
160
  const bareName = pluginNameFromSpec(spec);
154
161
  if (bareName && warnIfDeprecatedPluginName(bareName, log)) {
155
162
  continue;
@@ -255,4 +262,4 @@ export {
255
262
  BUILTIN_PLUGIN_FACTORIES,
256
263
  setupPlugins
257
264
  };
258
- //# sourceMappingURL=chunk-4U3DMA2Y.js.map
265
+ //# sourceMappingURL=chunk-ZECLGUTF.js.map