@wrongstack/cli 0.82.6 → 0.84.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +111 -156
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { color, writeErr, renderProgress, SpecStore, TaskGraphStore, analyzeCriticalPath, getTemplate, listTemplates, templateToMarkdown, SpecParser, renderSpecAnalysis, AISpecBuilder, DefaultTaskStore, TaskTracker, renderTaskGraph, DefaultSecretScrubber,
|
|
2
|
+
import { color, writeErr, renderProgress, SpecStore, TaskGraphStore, analyzeCriticalPath, getTemplate, listTemplates, templateToMarkdown, SpecParser, renderSpecAnalysis, AISpecBuilder, DefaultTaskStore, TaskTracker, renderTaskGraph, DefaultSecretScrubber, DefaultPathResolver, TOKENS, mergeCustomModelDefs, DefaultSystemPromptBuilder, makeAutonomyPromptContributor, ToolRegistry, createContextManagerTool, EventBus, resolveSessionLoggingConfig, createSessionEventBridge, HookRegistry, HookRunner, SlashCommandRegistry, BrainDecisionQueue, ObservableBrainArbiter, HumanEscalatingBrainArbiter, DefaultBrainArbiter, createDelegateTool, FLEET_ROSTER, createMcpControlTool, SpecVersioning, atomicWrite, DefaultLogger, DefaultModelsRegistry, isStdinTTY, writeOut, runProviderWithRetry, ReplayLogStore, ReplayProviderRunner, ProviderRegistry, InMemoryMetricsSink, wireMetricsToEvents, DefaultHealthRegistry, startMetricsServer, RecoveryLock, DefaultAttachmentStore, QueueStore, Context, loadTodosCheckpoint, attachTodosCheckpoint, loadDirectorState, loadPlan, createDefaultPipelines, resolveContextWindowPolicy, resolveAuditLevel, AutoCompactionMiddleware, estimateRequestTokensCalibrated, Agent, loadPlugins, FleetManager, makeDirectorSessionFactory, Director, makeFleetEmitTool, makeFleetStatusTool, resolveModelMatrix, DEFAULT_SUBAGENT_BASELINE, AutoApprovePermissionPolicy, PhaseStore, AutoPhasePlanner, PhaseGraphBuilder, WorktreeManager, PhaseOrchestrator, makeLLMClassifier, ParallelEternalEngine, EternalAutonomyEngine, allServers as allServers$1, decryptConfigSecrets as decryptConfigSecrets$1, encryptConfigSecrets as encryptConfigSecrets$1, bootConfig as bootConfig$1, setOutputLineGuard, setRawMode, DefaultSessionReader, resolveWstackPaths, ToolAuditLog, DefaultSessionRewinder, DefaultSessionStore, DefaultPluginAPI, ProviderError, makeAgentSubagentRunner, NULL_FLEET_BUS, buildChildEnv, formatContextWindowModeList, repairToolUseAdjacency, getContextWindowMode, AGENTS_BY_PHASE, dispatchAgent, formatTodosList, SessionRecovery, loadGoal, goalFilePath, summarizeUsage, saveGoal, emptyGoal, buildGoalPreamble, formatGoal, pendingBtwCount, setBtwNote, MATRIX_PHASE_KEYS, AGENT_CATALOG, matrixKeyKind, onResize, ERROR_CODES, InputBuilder, FsError } from '@wrongstack/core';
|
|
3
3
|
import * as path8 from 'path';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import * as fsp4 from 'fs/promises';
|
|
6
|
+
import { DefaultSecretVault, decryptConfigSecrets, encryptConfigSecrets, isSecretField } from '@wrongstack/core/security';
|
|
6
7
|
import { createRequire } from 'module';
|
|
7
8
|
import * as os2 from 'os';
|
|
8
9
|
import os2__default from 'os';
|
|
9
10
|
import * as crypto2 from 'crypto';
|
|
10
11
|
import { randomUUID } from 'crypto';
|
|
11
12
|
import { findFreePort, createHttpServer, openBrowser, registerInstance, unregisterInstance } from '@wrongstack/webui/server';
|
|
12
|
-
import { DefaultSecretVault, decryptConfigSecrets, encryptConfigSecrets, isSecretField } from '@wrongstack/core/security';
|
|
13
13
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
14
14
|
import { MCPRegistry, MCPServer, serveHttp, serveStdio } from '@wrongstack/mcp';
|
|
15
15
|
import { capabilitiesFor, buildProviderFactoriesFromRegistry, makeProviderFromConfig } from '@wrongstack/providers';
|
|
@@ -1562,6 +1562,61 @@ function maskedKey(key) {
|
|
|
1562
1562
|
function nowIso() {
|
|
1563
1563
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
1564
1564
|
}
|
|
1565
|
+
async function loadConfigProviders(configPath2, vault, opts) {
|
|
1566
|
+
const warn = opts?.warn;
|
|
1567
|
+
let raw;
|
|
1568
|
+
try {
|
|
1569
|
+
raw = await fsp4.readFile(configPath2, "utf8");
|
|
1570
|
+
} catch (err) {
|
|
1571
|
+
if (err.code !== "ENOENT") {
|
|
1572
|
+
warn?.(`Could not read ${configPath2}: ${err.message}. Treating as empty.`);
|
|
1573
|
+
}
|
|
1574
|
+
return {};
|
|
1575
|
+
}
|
|
1576
|
+
let parsed;
|
|
1577
|
+
try {
|
|
1578
|
+
parsed = JSON.parse(raw);
|
|
1579
|
+
} catch (err) {
|
|
1580
|
+
warn?.(`Config at ${configPath2} is not valid JSON: ${err.message}`);
|
|
1581
|
+
return {};
|
|
1582
|
+
}
|
|
1583
|
+
const decrypted = decryptConfigSecrets(parsed, vault);
|
|
1584
|
+
return decrypted.providers ?? {};
|
|
1585
|
+
}
|
|
1586
|
+
async function mutateConfigProviders(configPath2, vault, mutator) {
|
|
1587
|
+
let raw;
|
|
1588
|
+
let fileExists = true;
|
|
1589
|
+
try {
|
|
1590
|
+
raw = await fsp4.readFile(configPath2, "utf8");
|
|
1591
|
+
} catch (err) {
|
|
1592
|
+
if (err.code !== "ENOENT") {
|
|
1593
|
+
throw new Error(
|
|
1594
|
+
`Refusing to mutate ${configPath2}: ${err.message}`,
|
|
1595
|
+
{ cause: err }
|
|
1596
|
+
);
|
|
1597
|
+
}
|
|
1598
|
+
fileExists = false;
|
|
1599
|
+
raw = "{}";
|
|
1600
|
+
}
|
|
1601
|
+
let parsed;
|
|
1602
|
+
try {
|
|
1603
|
+
parsed = JSON.parse(raw);
|
|
1604
|
+
} catch (err) {
|
|
1605
|
+
if (fileExists) {
|
|
1606
|
+
throw new Error(
|
|
1607
|
+
`Refusing to overwrite corrupt config at ${configPath2} (${err.message}). Fix or move the file aside before retrying.`,
|
|
1608
|
+
{ cause: err }
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1611
|
+
parsed = {};
|
|
1612
|
+
}
|
|
1613
|
+
const decrypted = decryptConfigSecrets(parsed, vault);
|
|
1614
|
+
const providers = decrypted.providers ?? {};
|
|
1615
|
+
mutator(providers);
|
|
1616
|
+
decrypted.providers = providers;
|
|
1617
|
+
const encrypted = encryptConfigSecrets(decrypted, vault);
|
|
1618
|
+
await atomicWrite(configPath2, JSON.stringify(encrypted, null, 2), { mode: 384 });
|
|
1619
|
+
}
|
|
1565
1620
|
var init_provider_config_utils = __esm({
|
|
1566
1621
|
"src/provider-config-utils.ts"() {
|
|
1567
1622
|
}
|
|
@@ -1696,12 +1751,6 @@ var webui_server_exports = {};
|
|
|
1696
1751
|
__export(webui_server_exports, {
|
|
1697
1752
|
runWebUI: () => runWebUI
|
|
1698
1753
|
});
|
|
1699
|
-
function expectDefined16(value) {
|
|
1700
|
-
if (value === null || value === void 0) {
|
|
1701
|
-
throw new Error("Expected value to be defined");
|
|
1702
|
-
}
|
|
1703
|
-
return value;
|
|
1704
|
-
}
|
|
1705
1754
|
async function runWebUI(opts) {
|
|
1706
1755
|
const host = "127.0.0.1";
|
|
1707
1756
|
const requestedWsPort = opts.port ?? 3457;
|
|
@@ -2288,7 +2337,7 @@ async function runWebUI(opts) {
|
|
|
2288
2337
|
const keys = normalizeKeys(existing);
|
|
2289
2338
|
const existingIdx = keys.findIndex((k) => k.label === label);
|
|
2290
2339
|
if (existingIdx >= 0) {
|
|
2291
|
-
keys[existingIdx] = { ...
|
|
2340
|
+
keys[existingIdx] = { ...expectDefined7(keys[existingIdx]), apiKey, createdAt: nowIso() };
|
|
2292
2341
|
} else {
|
|
2293
2342
|
keys.push({ label, apiKey, createdAt: nowIso() });
|
|
2294
2343
|
}
|
|
@@ -2379,58 +2428,20 @@ async function runWebUI(opts) {
|
|
|
2379
2428
|
sendResult(ws, false, err instanceof Error ? err.message : String(err));
|
|
2380
2429
|
}
|
|
2381
2430
|
}
|
|
2431
|
+
function getVault() {
|
|
2432
|
+
const keyFile = path8.join(path8.dirname(opts.globalConfigPath ?? ""), ".key");
|
|
2433
|
+
return new DefaultSecretVault({ keyFile });
|
|
2434
|
+
}
|
|
2382
2435
|
async function loadSavedProviders() {
|
|
2383
2436
|
if (!opts.globalConfigPath) return {};
|
|
2384
|
-
|
|
2385
|
-
try {
|
|
2386
|
-
raw = await fsp4.readFile(opts.globalConfigPath, "utf8");
|
|
2387
|
-
} catch {
|
|
2388
|
-
return {};
|
|
2389
|
-
}
|
|
2390
|
-
let parsed = {};
|
|
2391
|
-
try {
|
|
2392
|
-
parsed = JSON.parse(raw);
|
|
2393
|
-
} catch {
|
|
2394
|
-
return {};
|
|
2395
|
-
}
|
|
2396
|
-
if (!parsed.providers) return {};
|
|
2397
|
-
const keyFile = path8.join(path8.dirname(opts.globalConfigPath), ".key");
|
|
2398
|
-
const vault = new DefaultSecretVault({ keyFile });
|
|
2399
|
-
return decryptConfigSecrets(parsed.providers, vault);
|
|
2437
|
+
return loadConfigProviders(opts.globalConfigPath, getVault());
|
|
2400
2438
|
}
|
|
2401
2439
|
async function saveProviders(providers) {
|
|
2402
2440
|
if (!opts.globalConfigPath) return;
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
} catch (err) {
|
|
2408
|
-
if (err.code !== "ENOENT") {
|
|
2409
|
-
throw new Error(
|
|
2410
|
-
`Refusing to mutate ${opts.globalConfigPath}: ${err.message}`,
|
|
2411
|
-
{ cause: err }
|
|
2412
|
-
);
|
|
2413
|
-
}
|
|
2414
|
-
fileExists = false;
|
|
2415
|
-
raw = "{}";
|
|
2416
|
-
}
|
|
2417
|
-
let parsed;
|
|
2418
|
-
try {
|
|
2419
|
-
parsed = JSON.parse(raw);
|
|
2420
|
-
} catch (err) {
|
|
2421
|
-
if (fileExists) {
|
|
2422
|
-
throw new Error(
|
|
2423
|
-
`Refusing to overwrite corrupt config at ${opts.globalConfigPath} (${err.message}). Fix or move the file aside before retrying.`,
|
|
2424
|
-
{ cause: err }
|
|
2425
|
-
);
|
|
2426
|
-
}
|
|
2427
|
-
parsed = {};
|
|
2428
|
-
}
|
|
2429
|
-
parsed.providers = providers;
|
|
2430
|
-
const keyFile = path8.join(path8.dirname(opts.globalConfigPath), ".key");
|
|
2431
|
-
const vault = new DefaultSecretVault({ keyFile });
|
|
2432
|
-
const encrypted = encryptConfigSecrets(parsed, vault);
|
|
2433
|
-
await atomicWrite(opts.globalConfigPath, JSON.stringify(encrypted, null, 2), { mode: 384 });
|
|
2441
|
+
await mutateConfigProviders(opts.globalConfigPath, getVault(), (existing) => {
|
|
2442
|
+
for (const key of Object.keys(existing)) delete existing[key];
|
|
2443
|
+
Object.assign(existing, providers);
|
|
2444
|
+
});
|
|
2434
2445
|
}
|
|
2435
2446
|
function sendResult(ws, success, message) {
|
|
2436
2447
|
send(ws, { type: "key.operation_result", payload: { success, message } });
|
|
@@ -8137,11 +8148,11 @@ function expectDefined6(value) {
|
|
|
8137
8148
|
var theme = { primary: color.amber };
|
|
8138
8149
|
async function saveToGlobalConfig(configPath2, provider, model, homeFn = () => process.env.HOME ?? os2__default.homedir()) {
|
|
8139
8150
|
try {
|
|
8140
|
-
const { atomicWrite:
|
|
8141
|
-
const
|
|
8151
|
+
const { atomicWrite: atomicWrite14 } = await import('@wrongstack/core');
|
|
8152
|
+
const fs26 = await import('fs/promises');
|
|
8142
8153
|
let existing = {};
|
|
8143
8154
|
try {
|
|
8144
|
-
const raw = await
|
|
8155
|
+
const raw = await fs26.readFile(configPath2, "utf8");
|
|
8145
8156
|
existing = JSON.parse(raw);
|
|
8146
8157
|
} catch {
|
|
8147
8158
|
}
|
|
@@ -8153,7 +8164,7 @@ async function saveToGlobalConfig(configPath2, provider, model, homeFn = () => p
|
|
|
8153
8164
|
} catch (err) {
|
|
8154
8165
|
console.warn("[picker] backupCurrent failed:", err);
|
|
8155
8166
|
}
|
|
8156
|
-
await
|
|
8167
|
+
await atomicWrite14(configPath2, JSON.stringify(existing, null, 2), { mode: 384 });
|
|
8157
8168
|
try {
|
|
8158
8169
|
await appendHistory(
|
|
8159
8170
|
oldCfg,
|
|
@@ -8992,12 +9003,6 @@ async function spawnACPAgent(args, deps) {
|
|
|
8992
9003
|
|
|
8993
9004
|
// src/auth-menu.ts
|
|
8994
9005
|
init_provider_config_utils();
|
|
8995
|
-
function expectDefined8(value) {
|
|
8996
|
-
if (value === null || value === void 0) {
|
|
8997
|
-
throw new Error("Expected value to be defined");
|
|
8998
|
-
}
|
|
8999
|
-
return value;
|
|
9000
|
-
}
|
|
9001
9006
|
async function runAuthMenu(deps) {
|
|
9002
9007
|
for (; ; ) {
|
|
9003
9008
|
const providers = await loadProviders(deps);
|
|
@@ -9019,7 +9024,7 @@ ${color.amber("?")} Pick: `)).trim().toLowerCase();
|
|
|
9019
9024
|
}
|
|
9020
9025
|
const idx = Number.parseInt(choice, 10);
|
|
9021
9026
|
if (!Number.isNaN(idx) && idx >= 1 && idx <= ids.length) {
|
|
9022
|
-
const pid =
|
|
9027
|
+
const pid = expectDefined7(ids[idx - 1]);
|
|
9023
9028
|
await manageProvider(pid, deps);
|
|
9024
9029
|
continue;
|
|
9025
9030
|
}
|
|
@@ -9109,7 +9114,7 @@ ${color.bold(providerId)} ${cfg.family ? color.dim(`[${cfg.family}]`) : color.am
|
|
|
9109
9114
|
deps.renderer.write(color.dim(" (no keys saved)\n"));
|
|
9110
9115
|
} else {
|
|
9111
9116
|
for (let i = 0; i < keys.length; i++) {
|
|
9112
|
-
const k =
|
|
9117
|
+
const k = expectDefined7(keys[i]);
|
|
9113
9118
|
const marker = k.label === active ? color.green("\u25CF") : color.dim("\u25CB");
|
|
9114
9119
|
deps.renderer.write(
|
|
9115
9120
|
` ${color.dim(`${i + 1}.`.padStart(4))} ${marker} ${k.label.padEnd(20)} ${maskedKey(k.apiKey)} ${color.dim(k.createdAt)}
|
|
@@ -9171,7 +9176,7 @@ ${color.amber("?")} ${providerId} > `)).trim();
|
|
|
9171
9176
|
deps.renderer.writeError(`Usage: u <1-${keys.length}>`);
|
|
9172
9177
|
continue;
|
|
9173
9178
|
}
|
|
9174
|
-
const target =
|
|
9179
|
+
const target = expectDefined7(keys[arg - 1]);
|
|
9175
9180
|
const newKey = await readKeyInput(deps, `Updated key for ${target.label}`);
|
|
9176
9181
|
if (!newKey) continue;
|
|
9177
9182
|
await mutateProviders(deps, (all) => {
|
|
@@ -9191,7 +9196,7 @@ ${color.amber("?")} ${providerId} > `)).trim();
|
|
|
9191
9196
|
deps.renderer.writeError(`Usage: d <1-${keys.length}>`);
|
|
9192
9197
|
continue;
|
|
9193
9198
|
}
|
|
9194
|
-
const target =
|
|
9199
|
+
const target = expectDefined7(keys[arg - 1]);
|
|
9195
9200
|
const confirm = (await deps.reader.readLine(
|
|
9196
9201
|
` ${color.amber("?")} Delete key "${target.label}" (${maskedKey(target.apiKey)})? ${color.dim("[y/N/q]")} `
|
|
9197
9202
|
)).trim().toLowerCase();
|
|
@@ -9267,7 +9272,7 @@ ${color.amber("?")} ${providerId} > `)).trim();
|
|
|
9267
9272
|
deps.renderer.writeError(`Usage: s <1-${keys.length}>`);
|
|
9268
9273
|
continue;
|
|
9269
9274
|
}
|
|
9270
|
-
const target =
|
|
9275
|
+
const target = expectDefined7(keys[arg - 1]);
|
|
9271
9276
|
await mutateProviders(deps, (all) => {
|
|
9272
9277
|
const p = all[providerId];
|
|
9273
9278
|
if (!p) return;
|
|
@@ -9590,67 +9595,17 @@ async function readKeyInput(deps, intent) {
|
|
|
9590
9595
|
}
|
|
9591
9596
|
return key;
|
|
9592
9597
|
}
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
} catch (err) {
|
|
9598
|
-
if (err.code !== "ENOENT") {
|
|
9599
|
-
deps.renderer.writeWarning(
|
|
9600
|
-
`Could not read ${deps.globalConfigPath}: ${err.message}. Treating as empty.`
|
|
9601
|
-
);
|
|
9602
|
-
}
|
|
9603
|
-
return {};
|
|
9604
|
-
}
|
|
9605
|
-
let parsed = {};
|
|
9606
|
-
try {
|
|
9607
|
-
parsed = JSON.parse(raw);
|
|
9608
|
-
} catch (err) {
|
|
9609
|
-
deps.renderer.writeWarning(
|
|
9610
|
-
`Config at ${deps.globalConfigPath} is not valid JSON: ${err.message}`
|
|
9611
|
-
);
|
|
9612
|
-
return {};
|
|
9613
|
-
}
|
|
9614
|
-
const decrypted = decryptConfigSecrets$1(parsed, deps.vault);
|
|
9615
|
-
return decrypted.providers ?? {};
|
|
9598
|
+
function loadProviders(deps) {
|
|
9599
|
+
return loadConfigProviders(deps.globalConfigPath, deps.vault, {
|
|
9600
|
+
warn: (msg) => deps.renderer.writeWarning(msg)
|
|
9601
|
+
});
|
|
9616
9602
|
}
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
let fileExists = true;
|
|
9620
|
-
try {
|
|
9621
|
-
raw = await fsp4.readFile(deps.globalConfigPath, "utf8");
|
|
9622
|
-
} catch (err) {
|
|
9623
|
-
if (err.code !== "ENOENT") {
|
|
9624
|
-
throw new Error(
|
|
9625
|
-
`Refusing to mutate ${deps.globalConfigPath}: ${err.message}`,
|
|
9626
|
-
{ cause: err }
|
|
9627
|
-
);
|
|
9628
|
-
}
|
|
9629
|
-
fileExists = false;
|
|
9630
|
-
raw = "{}";
|
|
9631
|
-
}
|
|
9632
|
-
let parsed;
|
|
9633
|
-
try {
|
|
9634
|
-
parsed = JSON.parse(raw);
|
|
9635
|
-
} catch (err) {
|
|
9636
|
-
if (fileExists) {
|
|
9637
|
-
throw new Error(
|
|
9638
|
-
`Refusing to overwrite corrupt config at ${deps.globalConfigPath} (${err.message}). Fix or move the file aside before retrying.`,
|
|
9639
|
-
{ cause: err }
|
|
9640
|
-
);
|
|
9641
|
-
}
|
|
9642
|
-
parsed = {};
|
|
9643
|
-
}
|
|
9644
|
-
const decrypted = decryptConfigSecrets$1(parsed, deps.vault);
|
|
9645
|
-
const providers = decrypted.providers ?? {};
|
|
9646
|
-
mutator(providers);
|
|
9647
|
-
decrypted.providers = providers;
|
|
9648
|
-
const encrypted = encryptConfigSecrets$1(decrypted, deps.vault);
|
|
9649
|
-
await atomicWrite(deps.globalConfigPath, JSON.stringify(encrypted, null, 2), { mode: 384 });
|
|
9603
|
+
function mutateProviders(deps, mutator) {
|
|
9604
|
+
return mutateConfigProviders(deps.globalConfigPath, deps.vault, mutator);
|
|
9650
9605
|
}
|
|
9651
9606
|
|
|
9652
9607
|
// src/subcommands/handlers/auth.ts
|
|
9653
|
-
function
|
|
9608
|
+
function expectDefined8(value) {
|
|
9654
9609
|
if (value === null || value === void 0) {
|
|
9655
9610
|
throw new Error("Expected value to be defined");
|
|
9656
9611
|
}
|
|
@@ -9667,7 +9622,7 @@ var authCmd = async (args, deps) => {
|
|
|
9667
9622
|
};
|
|
9668
9623
|
if (flags.positional.length === 0) return runAuthMenu(menuDeps);
|
|
9669
9624
|
return runAuthDirect(menuDeps, {
|
|
9670
|
-
providerId:
|
|
9625
|
+
providerId: expectDefined8(flags.positional[0]),
|
|
9671
9626
|
label: flags.label,
|
|
9672
9627
|
family: flags.family,
|
|
9673
9628
|
baseUrl: flags.baseUrl,
|
|
@@ -9890,7 +9845,7 @@ var doctorCmd = async (_args, deps) => {
|
|
|
9890
9845
|
deps.renderer.write(color.green("All checks passed.\n"));
|
|
9891
9846
|
return 0;
|
|
9892
9847
|
};
|
|
9893
|
-
function
|
|
9848
|
+
function expectDefined9(value) {
|
|
9894
9849
|
if (value === null || value === void 0) {
|
|
9895
9850
|
throw new Error("Expected value to be defined");
|
|
9896
9851
|
}
|
|
@@ -9907,7 +9862,7 @@ var exportCmd = async (args, deps) => {
|
|
|
9907
9862
|
let includeDiagnostics = true;
|
|
9908
9863
|
let sessionId;
|
|
9909
9864
|
for (let i = 0; i < args.length; i++) {
|
|
9910
|
-
const a =
|
|
9865
|
+
const a = expectDefined9(args[i]);
|
|
9911
9866
|
if (a === "--format" || a === "-f") {
|
|
9912
9867
|
const v = args[++i];
|
|
9913
9868
|
if (v !== "markdown" && v !== "json" && v !== "text") {
|
|
@@ -10169,7 +10124,7 @@ async function serveMcpStdio(deps) {
|
|
|
10169
10124
|
}
|
|
10170
10125
|
|
|
10171
10126
|
// src/subcommands/handlers/mcp.ts
|
|
10172
|
-
function
|
|
10127
|
+
function expectDefined10(value) {
|
|
10173
10128
|
if (value === null || value === void 0) {
|
|
10174
10129
|
throw new Error("Expected value to be defined");
|
|
10175
10130
|
}
|
|
@@ -10225,7 +10180,7 @@ async function addMcpServer(args, deps) {
|
|
|
10225
10180
|
`);
|
|
10226
10181
|
if (Object.keys(deps.config.mcpServers ?? {}).length === 0)
|
|
10227
10182
|
for (const k of Object.keys(BUILT_IN_MCP)) {
|
|
10228
|
-
const s =
|
|
10183
|
+
const s = expectDefined10(BUILT_IN_MCP[k]);
|
|
10229
10184
|
deps.renderer.write(` ${k.padEnd(20)} ${s.description}
|
|
10230
10185
|
`);
|
|
10231
10186
|
}
|
|
@@ -10503,7 +10458,7 @@ var projectsCmd = async (_args, deps) => {
|
|
|
10503
10458
|
return 0;
|
|
10504
10459
|
}
|
|
10505
10460
|
};
|
|
10506
|
-
function
|
|
10461
|
+
function expectDefined11(value) {
|
|
10507
10462
|
if (value === null || value === void 0) {
|
|
10508
10463
|
throw new Error("Expected value to be defined");
|
|
10509
10464
|
}
|
|
@@ -10556,7 +10511,7 @@ ${color.dim(`Current: ${deps.config.provider ?? "<unset>"} / ${deps.config.model
|
|
|
10556
10511
|
function parseFlags2(args) {
|
|
10557
10512
|
const flags = {};
|
|
10558
10513
|
for (let i = 0; i < args.length; i++) {
|
|
10559
|
-
const a =
|
|
10514
|
+
const a = expectDefined11(args[i]);
|
|
10560
10515
|
if (a.startsWith("--")) {
|
|
10561
10516
|
const eq = a.indexOf("=");
|
|
10562
10517
|
if (eq !== -1) {
|
|
@@ -10576,7 +10531,7 @@ function parseFlags2(args) {
|
|
|
10576
10531
|
function positionals(args) {
|
|
10577
10532
|
const out = [];
|
|
10578
10533
|
for (let i = 0; i < args.length; i++) {
|
|
10579
|
-
const a =
|
|
10534
|
+
const a = expectDefined11(args[i]);
|
|
10580
10535
|
if (a.startsWith("--")) {
|
|
10581
10536
|
const eq = a.indexOf("=");
|
|
10582
10537
|
if (eq === -1) {
|
|
@@ -10731,7 +10686,7 @@ function parseSizeFlag(raw) {
|
|
|
10731
10686
|
const s = raw.trim().toLowerCase();
|
|
10732
10687
|
const match = /^(\d+(?:\.\d+)?)\s*(k|m|b)?$/.exec(s);
|
|
10733
10688
|
if (!match) return void 0;
|
|
10734
|
-
const num = Number.parseFloat(
|
|
10689
|
+
const num = Number.parseFloat(expectDefined11(match[1]));
|
|
10735
10690
|
const unit = match[2];
|
|
10736
10691
|
if (unit === "b") return Math.round(num * 1e9);
|
|
10737
10692
|
if (unit === "m") return Math.round(num * 1e6);
|
|
@@ -11052,7 +11007,7 @@ Fleet Run: ${runId}
|
|
|
11052
11007
|
}
|
|
11053
11008
|
|
|
11054
11009
|
// src/subcommands/handlers/sessions-config.ts
|
|
11055
|
-
function
|
|
11010
|
+
function expectDefined12(value) {
|
|
11056
11011
|
if (value === null || value === void 0) {
|
|
11057
11012
|
throw new Error("Expected value to be defined");
|
|
11058
11013
|
}
|
|
@@ -11103,7 +11058,7 @@ var configCmd = async (args, deps) => {
|
|
|
11103
11058
|
};
|
|
11104
11059
|
function extractArg(args, key) {
|
|
11105
11060
|
const idx = args.indexOf(key);
|
|
11106
|
-
if (idx !== -1 && args[idx + 1] !== void 0) return
|
|
11061
|
+
if (idx !== -1 && args[idx + 1] !== void 0) return expectDefined12(args[idx + 1]);
|
|
11107
11062
|
const eq = key.startsWith("--") ? args.find((a) => a.startsWith(`${key}=`)) : null;
|
|
11108
11063
|
if (eq) return eq.slice(eq.indexOf("=") + 1);
|
|
11109
11064
|
return null;
|
|
@@ -11179,7 +11134,7 @@ async function runRestore(args, deps) {
|
|
|
11179
11134
|
`);
|
|
11180
11135
|
return 0;
|
|
11181
11136
|
}
|
|
11182
|
-
function
|
|
11137
|
+
function expectDefined13(value) {
|
|
11183
11138
|
if (value === null || value === void 0) {
|
|
11184
11139
|
throw new Error("Expected value to be defined");
|
|
11185
11140
|
}
|
|
@@ -11199,7 +11154,7 @@ function parseRewindFlags(args) {
|
|
|
11199
11154
|
}
|
|
11200
11155
|
function findSessionId(args) {
|
|
11201
11156
|
for (let i = 0; i < args.length; i++) {
|
|
11202
|
-
const a =
|
|
11157
|
+
const a = expectDefined13(args[i]);
|
|
11203
11158
|
if (a === "--last" || a === "--to") {
|
|
11204
11159
|
i++;
|
|
11205
11160
|
continue;
|
|
@@ -11451,10 +11406,10 @@ var auditCmd = async (args, deps) => {
|
|
|
11451
11406
|
return verify.ok ? 0 : 1;
|
|
11452
11407
|
};
|
|
11453
11408
|
async function listAudits(log, dir, deps) {
|
|
11454
|
-
const
|
|
11409
|
+
const fs26 = await import('fs/promises');
|
|
11455
11410
|
let entries;
|
|
11456
11411
|
try {
|
|
11457
|
-
entries = await
|
|
11412
|
+
entries = await fs26.readdir(dir);
|
|
11458
11413
|
} catch {
|
|
11459
11414
|
deps.renderer.write(
|
|
11460
11415
|
color.dim(`No sessions dir found at ${dir}. Run a session first.`) + "\n"
|
|
@@ -12213,7 +12168,7 @@ async function predictNextTasks(input, opts) {
|
|
|
12213
12168
|
}
|
|
12214
12169
|
}
|
|
12215
12170
|
init_sdd();
|
|
12216
|
-
function
|
|
12171
|
+
function expectDefined14(value) {
|
|
12217
12172
|
if (value === null || value === void 0) {
|
|
12218
12173
|
throw new Error("Expected value to be defined");
|
|
12219
12174
|
}
|
|
@@ -12734,7 +12689,7 @@ async function renderGoalBanner(opts) {
|
|
|
12734
12689
|
color.dim("Goal: ") + stateColor(summary) + color.dim(` [${goal.goalState}] (iter ${goal.iterations})`) + "\n"
|
|
12735
12690
|
);
|
|
12736
12691
|
if (goal.journal.length > 0) {
|
|
12737
|
-
const lastEntry =
|
|
12692
|
+
const lastEntry = expectDefined14(goal.journal[goal.journal.length - 1]);
|
|
12738
12693
|
const statusIcon = lastEntry.status === "success" ? "\u2713" : lastEntry.status === "failure" ? "\u2717" : lastEntry.status === "aborted" ? "\u2298" : lastEntry.status === "skipped" ? "\u229D" : "\xB7";
|
|
12739
12694
|
opts.renderer.write(
|
|
12740
12695
|
color.dim(` Last: ${statusIcon} ${lastEntry.task} (${lastEntry.status})`) + "\n"
|
|
@@ -13336,7 +13291,7 @@ async function execute(deps) {
|
|
|
13336
13291
|
}
|
|
13337
13292
|
return code;
|
|
13338
13293
|
}
|
|
13339
|
-
function
|
|
13294
|
+
function expectDefined15(value) {
|
|
13340
13295
|
if (value === null || value === void 0) {
|
|
13341
13296
|
throw new Error("Expected value to be defined");
|
|
13342
13297
|
}
|
|
@@ -13350,7 +13305,7 @@ function buildRoutingRunner(config, host) {
|
|
|
13350
13305
|
return async (task, ctx) => {
|
|
13351
13306
|
const subCfg = ctx.config;
|
|
13352
13307
|
if (subCfg.provider === "acp") {
|
|
13353
|
-
const cacheKey = subCfg.role ?? subCfg.name ??
|
|
13308
|
+
const cacheKey = subCfg.role ?? subCfg.name ?? expectDefined15(subCfg.id);
|
|
13354
13309
|
return host.buildACPRunner(cacheKey).then((r) => r(task, ctx));
|
|
13355
13310
|
}
|
|
13356
13311
|
return standardRunner(task, ctx);
|
|
@@ -15239,7 +15194,7 @@ Try \`wstack models refresh\` once you have network access, or run with --no-fea
|
|
|
15239
15194
|
}
|
|
15240
15195
|
return { resolvedProvider, provider, providerRegistry };
|
|
15241
15196
|
}
|
|
15242
|
-
function
|
|
15197
|
+
function expectDefined16(value) {
|
|
15243
15198
|
if (value === null || value === void 0) {
|
|
15244
15199
|
throw new Error("Expected value to be defined");
|
|
15245
15200
|
}
|
|
@@ -15286,7 +15241,7 @@ async function setupSession(params) {
|
|
|
15286
15241
|
const attachments = new DefaultAttachmentStore({ spoolDir: path8.join(wpaths.projectSessions, session?.id, "attachments") });
|
|
15287
15242
|
const queueStore = new QueueStore({ dir: path8.join(wpaths.projectSessions, session?.id) });
|
|
15288
15243
|
const ctxSignal = new AbortController().signal;
|
|
15289
|
-
const context = new Context({ systemPrompt, provider, session:
|
|
15244
|
+
const context = new Context({ systemPrompt, provider, session: expectDefined16(session), signal: ctxSignal, tokenCounter, cwd, projectRoot, model: config.model });
|
|
15290
15245
|
if (restoredMessages.length > 0) context.state.replaceMessages(restoredMessages);
|
|
15291
15246
|
const todosCheckpointPath = path8.join(wpaths.projectSessions, `${session?.id}.todos.json`);
|
|
15292
15247
|
if (resumeId) {
|
|
@@ -15325,7 +15280,7 @@ async function setupSession(params) {
|
|
|
15325
15280
|
} catch {
|
|
15326
15281
|
}
|
|
15327
15282
|
}
|
|
15328
|
-
return { session:
|
|
15283
|
+
return { session: expectDefined16(session), sessionRef, context, restoredMessages, attachments, recoveryLock, queueStore, planPath, detachTodosCheckpoint, priorFleetState: dirState ?? void 0 };
|
|
15329
15284
|
}
|
|
15330
15285
|
function resolveBundledSkillsDir2() {
|
|
15331
15286
|
try {
|
|
@@ -15424,7 +15379,7 @@ async function launchEternalFromFlag(deps) {
|
|
|
15424
15379
|
}
|
|
15425
15380
|
|
|
15426
15381
|
// src/cli-main.ts
|
|
15427
|
-
function
|
|
15382
|
+
function expectDefined17(value) {
|
|
15428
15383
|
if (value === null || value === void 0) {
|
|
15429
15384
|
throw new Error("Expected value to be defined");
|
|
15430
15385
|
}
|
|
@@ -15910,10 +15865,10 @@ async function main(argv) {
|
|
|
15910
15865
|
}
|
|
15911
15866
|
};
|
|
15912
15867
|
const fleetRoot = directorMode ? path8.join(wpaths.projectSessions, session.id) : void 0;
|
|
15913
|
-
const manifestPath = directorMode ? typeof process.env["WRONGSTACK_FLEET_MANIFEST"] === "string" ? process.env["WRONGSTACK_FLEET_MANIFEST"] : path8.join(
|
|
15914
|
-
const sharedScratchpadPath = directorMode ? path8.join(
|
|
15915
|
-
const subagentSessionsRoot = directorMode ? path8.join(
|
|
15916
|
-
const stateCheckpointPath = directorMode ? path8.join(
|
|
15868
|
+
const manifestPath = directorMode ? typeof process.env["WRONGSTACK_FLEET_MANIFEST"] === "string" ? process.env["WRONGSTACK_FLEET_MANIFEST"] : path8.join(expectDefined17(fleetRoot), "fleet.json") : void 0;
|
|
15869
|
+
const sharedScratchpadPath = directorMode ? path8.join(expectDefined17(fleetRoot), "shared") : void 0;
|
|
15870
|
+
const subagentSessionsRoot = directorMode ? path8.join(expectDefined17(fleetRoot), "subagents") : void 0;
|
|
15871
|
+
const stateCheckpointPath = directorMode ? path8.join(expectDefined17(fleetRoot), "director-state.json") : void 0;
|
|
15917
15872
|
const fleetRootForPromotion = path8.join(wpaths.projectSessions, session.id);
|
|
15918
15873
|
const brainQueue = new BrainDecisionQueue(events);
|
|
15919
15874
|
const brain = new ObservableBrainArbiter(
|
|
@@ -16332,7 +16287,7 @@ async function main(argv) {
|
|
|
16332
16287
|
...matches.map((m) => ` ${m.subagentId} (${m.runId})`)
|
|
16333
16288
|
].join("\n");
|
|
16334
16289
|
}
|
|
16335
|
-
const t =
|
|
16290
|
+
const t = expectDefined17(matches[0]);
|
|
16336
16291
|
const raw = await fsp4.readFile(t.file, "utf8");
|
|
16337
16292
|
if (mode === "raw") return raw;
|
|
16338
16293
|
const lines = raw.split("\n").filter((l) => l.trim());
|