@wrongstack/cli 0.310.0 → 0.313.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 (37) hide show
  1. package/dist/{acp-EA57GUFB.js → acp-LQMSMV32.js} +2 -2
  2. package/dist/chunk-4JRIWVJ4.js +13 -0
  3. package/dist/{chunk-63GFD62R.js → chunk-4S52MIIM.js} +2 -2
  4. package/dist/chunk-7CECQDNH.js +24 -0
  5. package/dist/chunk-AOAIPYFB.js +58 -0
  6. package/dist/{chunk-CHZZEEIP.js → chunk-CNQZ4HG4.js} +40 -9
  7. package/dist/{chunk-KQNYSZG2.js → chunk-E3X4KM7T.js} +6 -3
  8. package/dist/chunk-GWVLRUVH.js +120 -0
  9. package/dist/{cli-main-RFEZAJ4U.js → cli-main-BFUSCWXE.js} +228 -50
  10. package/dist/{diag-doctor-HJKFUY6B.js → diag-doctor-OPTB2NWY.js} +61 -3
  11. package/dist/{execution-WA2UCXNM.js → execution-TOBPK6MD.js} +109 -19
  12. package/dist/execution-chimera-cascade.d.ts +4 -1
  13. package/dist/execution-chimera-review.d.ts +4 -1
  14. package/dist/fleet/host-types.d.ts +9 -0
  15. package/dist/fleet/subagent-hook-runner.d.ts +22 -0
  16. package/dist/{hq-AG4VW4XO.js → hq-2XIXGAER.js} +2 -2
  17. package/dist/{hq-server-GZGM4BHA.js → hq-server-DBT3OOYD.js} +2 -2
  18. package/dist/index.js +16 -15
  19. package/dist/live-settings-input.d.ts +15 -1
  20. package/dist/proxy-wiring-G26YGP7S.js +15 -0
  21. package/dist/subcommands/contracts.d.ts +7 -0
  22. package/dist/subcommands/handlers/diag-doctor.d.ts +14 -0
  23. package/dist/{update-RATFF63M.js → update-ZXNC6I6G.js} +2 -2
  24. package/dist/webui-server/prefs-seeding.d.ts +4 -0
  25. package/dist/{webui-server-3DU6BVTB.js → webui-server-I53IYBW4.js} +8 -1
  26. package/dist/webui-server-options.d.ts +8 -0
  27. package/dist/wiring/provider-runtime.d.ts +25 -0
  28. package/dist/wiring/proxy-probe.d.ts +62 -0
  29. package/dist/wiring/proxy-wiring.d.ts +59 -0
  30. package/dist/wiring/wrongtrace-gate-counters.d.ts +18 -0
  31. package/dist/wiring/wrongtrace-gate.d.ts +13 -0
  32. package/dist/wiring/wrongtrace-hooks.d.ts +8 -0
  33. package/dist/wiring/wrongtrace-prompt-contributor.d.ts +23 -0
  34. package/dist/wiring/wrongtrace-telemetry.d.ts +53 -0
  35. package/dist/wrongtrace-gate-counters-P5BCBXQN.js +22 -0
  36. package/dist/wrongtrace-telemetry-6M2CCBX5.js +34 -0
  37. package/package.json +28 -27
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Periodic health probe for the local WrongProxy / WrongTrace daemon.
3
+ *
4
+ * The daemon exposes `GET <base>/api/health` returning JSON like:
5
+ * { "repo": "WrongTrace", "status": "ok", "timestamp": "...", ... }
6
+ *
7
+ * The probe:
8
+ * 1. Runs once on boot so the first request doesn't hit a dead proxy.
9
+ * 2. Re-runs every `intervalMs` (default 30s) while the toggle is on.
10
+ * 3. Aborts in-flight probes on every state change so we never accumulate
11
+ * a backlog when the user toggles the proxy on/off rapidly.
12
+ * 4. Uses a small per-call AbortController + timeout (2s) so a hung
13
+ * `localhost:3444` cannot stall the loop.
14
+ *
15
+ * The probe is intentionally minimal: the daemon's `/api/health` response
16
+ * shape is small and stable, so we don't try to parse it — a 2xx is
17
+ * enough to mark the proxy active. Failures (timeout, non-2xx, ECONNREFUSED)
18
+ * are treated as SOFT signals: a single transient failure (daemon mid-
19
+ * restart, one dropped 2xx) must not flip `active` to false and silently
20
+ * disable rewrites for every subsequent request. `active` flips to false
21
+ * only after `deactivateAfterFailures` consecutive failures; the periodic
22
+ * loop keeps retrying, so a recovered daemon re-activates on the next
23
+ * successful probe. Toggle-off (`enabled: false` / no URL) still deactivates
24
+ * immediately.
25
+ */
26
+ interface ProbeRunnerOptions {
27
+ /** Override the default interval (30s). Useful for tests. */
28
+ intervalMs?: number;
29
+ /** Override the default per-request timeout (2s). Useful for tests. */
30
+ timeoutMs?: number;
31
+ /** Override `fetch` for tests. */
32
+ fetchImpl?: typeof fetch;
33
+ /** Override `setInterval` / `clearInterval` for tests. */
34
+ setIntervalImpl?: typeof setInterval;
35
+ clearIntervalImpl?: typeof clearInterval;
36
+ /**
37
+ * Number of CONSECUTIVE failed probes required before `active` flips to
38
+ * false. A single transient failure is a soft signal and leaves `active`
39
+ * untouched. Defaults to 2. Useful for tests wanting to exercise the
40
+ * threshold without waiting two ticks.
41
+ */
42
+ deactivateAfterFailures?: number;
43
+ }
44
+ export interface ProbeRunner {
45
+ /** Stop the periodic probe and abort any in-flight request. */
46
+ stop(): void;
47
+ /** Force an immediate probe (next tick). Resolves with whether the health check succeeded. */
48
+ poke(): Promise<boolean>;
49
+ }
50
+ /**
51
+ * Start the probe loop. Idempotent — repeated calls reuse the existing
52
+ * runner unless `stop()` was called in between.
53
+ */
54
+ export declare function startProxyProbe(opts?: ProbeRunnerOptions): ProbeRunner;
55
+ /**
56
+ * Stop any running probe. Safe to call when nothing is running.
57
+ */
58
+ export declare function stopProxyProbe(): void;
59
+ /** Test-only: clear module state without touching timers. */
60
+ export declare function __resetProxyProbeForTests(): void;
61
+ export {};
62
+ //# sourceMappingURL=proxy-probe.d.ts.map
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Bridge between the WS prefs pipeline and the proxy-rewrite runtime.
3
+ *
4
+ * Lives in `@wrongstack/cli/wiring/proxy-wiring.ts` because it owns the
5
+ * side-effectful boot of the probe loop — `proxy-rewrite` is pure logic
6
+ * and `proxy-probe` is the periodic side-effect loop, but neither knows
7
+ * about WS prefs. This module is the single owner of:
8
+ *
9
+ * - the singleton probe runner
10
+ * - pushing user prefs into the proxy-rewrite config
11
+ * - kicking off the periodic /api/health probe when the toggle goes on
12
+ *
13
+ * Re-exported so `handlePrefsUpdate` in `@wrongstack/webui-server` can
14
+ * call `applyWrongProxyPrefs(payload)` without taking a direct dependency
15
+ * on `proxy-probe` (the WS server is intentionally provider-agnostic).
16
+ */
17
+ /**
18
+ * Apply the `wrongProxyEnabled` + `wrongProxyUrl` portion of a prefs
19
+ * payload. Idempotent — safe to call on every `prefs.update`. Boots the
20
+ * probe on first call so the rewrite can be marked active before the
21
+ * next request hits the provider factory.
22
+ */
23
+ export declare function applyWrongProxyPrefs(payload: Record<string, unknown>): void;
24
+ /**
25
+ * Await one probe pass so the `ProxyConfig` singleton's `active` flag is
26
+ * settled before the caller reads it. Returns immediately when no probe
27
+ * runner exists (toggle never enabled). Each call triggers a fresh
28
+ * `runOnce()` probe — there is no memoization — so call it once per
29
+ * decision point, not per request.
30
+ *
31
+ * This closes the cli-main boot race: `bootstrapWrongProxy()` seeds
32
+ * `enabled` / `url` synchronously, but `startProxyProbe()` only schedules
33
+ * a 30 s `setInterval` and the first `poke()` resolves on the next
34
+ * macrotask. `setupProviderRuntime()` runs synchronously on the very
35
+ * next line, so without this gate providers are constructed with the raw
36
+ * base URL even when the toggle is on.
37
+ */
38
+ export declare function awaitFirstWrongProxyProbe(): Promise<void>;
39
+ /**
40
+ * Apply the initial prefs snapshot at boot. Same as `applyWrongProxyPrefs`
41
+ * but explicitly named for the boot site so future readers can find it.
42
+ *
43
+ * Accepts the canonical persisted shape (`config.tools.wrongProxy` —
44
+ * `{ enabled?, url? }`) directly. The `enabled` / `url` keys are mapped
45
+ * to the flat `wrongProxyEnabled` / `wrongProxyUrl` keys the proxy
46
+ * rewriter reads; any other keys in the snapshot are ignored. Callers
47
+ * that hold a `WrongProxyToolConfig` (the typed schema in
48
+ * `@wrongstack/core/types/config/tools.ts`) can pass it through without
49
+ * casting — the function never reads anything beyond `enabled` / `url`.
50
+ */
51
+ export declare function bootstrapWrongProxy(snapshot: {
52
+ enabled?: boolean | undefined;
53
+ url?: string | undefined;
54
+ } | Record<string, unknown> | undefined): void;
55
+ /**
56
+ * Stop the probe. Intended for graceful shutdown / test cleanup.
57
+ */
58
+ export declare function shutdownWrongProxy(): void;
59
+ //# sourceMappingURL=proxy-wiring.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * WrongTrace gate-decision counter — CLI re-export shim.
3
+ *
4
+ * The implementation lives in `@wrongstack/wrongtrace/src/gate-counters.ts`
5
+ * so EVERY process that runs the gate (CLI leader + fleet, standalone WebUI
6
+ * server) tallies against the same contract and the same counters file.
7
+ * This file exists only to keep the historical import path alive:
8
+ * - `execution-cleanup.ts` (dynamic import for session-end persist)
9
+ * - `brain-and-orchestration.ts` (fleet-runner emit-site recording)
10
+ * - `subcommands/handlers/diag-doctor.ts` (proxy-status readout)
11
+ * - `lifecycle-plugins.ts` (leader emit-site recording)
12
+ * - `tests/wrongtrace-gate-counters.test.ts`
13
+ * All five resolve through this shim; nothing imports the adapter
14
+ * implementation directly from CLI source.
15
+ */
16
+ export { createWrongTraceGateCounter, countersFilePath, formatGateCounterReport, loadWrongTraceGateCounters, persistWrongTraceGateCounters, recordGateDecision, resetGateDecisions, snapshotGateDecisions, } from '@wrongstack/wrongtrace';
17
+ export type { WrongTraceGateCounter, WrongTraceGateCounterSnapshot, } from '@wrongstack/wrongtrace';
18
+ //# sourceMappingURL=wrongtrace-gate-counters.d.ts.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Re-export shim — the implementation moved into `@wrongstack/wrongtrace`
3
+ * so the CLI leader, fleet subagents, and the standalone WebUI server all
4
+ * share one gate without any of them importing `@wrongstack/cli` (the
5
+ * dependency direction cli → webui-server forbids the reverse edge).
6
+ *
7
+ * Every historical import path (`../wiring/wrongtrace-gate.js`) keeps
8
+ * working unchanged through this shim. NOTE: this is NOT core/utils'
9
+ * `withFileLock` (a local file lock) — same name, different mechanism.
10
+ */
11
+ export { getWrongTrace, preflightFileEdit, resetWrongTraceGate, withFileLock, } from "@wrongstack/wrongtrace";
12
+ export type { PreflightOptions, PreflightVerdict } from "@wrongstack/wrongtrace";
13
+ //# sourceMappingURL=wrongtrace-gate.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Re-export shim — the implementation moved into `@wrongstack/wrongtrace`
3
+ * (see wrongtrace-gate.ts for why). Same factories, same behaviour, now
4
+ * shared by every host process that executes tools.
5
+ */
6
+ export { createWrongTraceHookPair, createWrongTracePostToolUseHook, createWrongTracePreToolUseHook, } from "@wrongstack/wrongtrace";
7
+ export type { WrongTraceGateDecisionEvent, WrongTraceHookInput, WrongTraceHookOptions, WrongTraceHookPair, WrongTracePreToolUseOutcome, } from "@wrongstack/wrongtrace";
8
+ //# sourceMappingURL=wrongtrace-hooks.d.ts.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WrongTrace boot-prompt contributor — consumes the previously-unused
3
+ * `digestAtlas` and `summarizeFriction` helpers so the leader's system
4
+ * prompt, not just the executor gate, sees the daemon's observability.
5
+ *
6
+ * Contract:
7
+ * - Fail-open: daemon offline / any throw → `[]` (no prompt block).
8
+ * - Bounded: the gate singleton is warmed fire-and-forget at boot; this
9
+ * contributor races discovery + atlas/friction fetches against short
10
+ * deadlines so a cold/absent daemon can never stall the first build.
11
+ * Each race is capped at CONTRIBUTOR_DEADLINE_MS; discovery + fetch is
12
+ * at most ~2 × the deadline cold, far less once the singleton resolves
13
+ * (a live local daemon answers in single-digit ms).
14
+ * - Registered in `bindSystemPromptBuilder`'s contributors array, after
15
+ * the ETERNAL AUTONOMY contributor (registration order is preserved).
16
+ */
17
+ import type { SystemPromptContributor } from '@wrongstack/core/types';
18
+ /**
19
+ * Build the contributor. Fresh instance per `bindSystemPromptBuilder` call
20
+ * (i.e. per process); cheap since the gate singleton is process-shared.
21
+ */
22
+ export declare function createWrongTracePromptContributor(): SystemPromptContributor;
23
+ //# sourceMappingURL=wrongtrace-prompt-contributor.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * WrongTrace session telemetry — the session-completion reporting hook.
3
+ *
4
+ * The daemon's /api/telemetry endpoint exists and answers 200 {ok:true}
5
+ * (verified live 2026-08-24), so WrongStack reports one summary per
6
+ * finished session: run id, agent/model/provider identity, token usage,
7
+ * and cost. This is what lets the daemon attribute activity (friction
8
+ * matrices, file lineage) to WrongStack sessions.
9
+ *
10
+ * Fail-open by construction: daemon offline → reportTelemetry returns
11
+ * null and this helper resolves without side effects; any throw is
12
+ * swallowed so session cleanup is never delayed or blocked by it.
13
+ */
14
+ import type { WrongTraceTelemetryReport } from '@wrongstack/wrongtrace';
15
+ /** Inputs the session-completion path already has in hand. */
16
+ export interface WrongTraceTelemetryInput {
17
+ sessionId: string;
18
+ /** Stable agent identity, e.g. 'wrongstack-cli'. */
19
+ agentName: string;
20
+ model: string;
21
+ provider: string;
22
+ /** Cumulative session usage from tokenCounter.total(). */
23
+ usage: {
24
+ input: number;
25
+ output: number;
26
+ cacheRead?: number | undefined;
27
+ cacheWrite?: number | undefined;
28
+ };
29
+ /** Session cost in USD from tokenCounter.estimateCost().total. */
30
+ costUsd: number;
31
+ }
32
+ /**
33
+ * Pure mapping to the daemon's POST /api/telemetry contract. Cache fields
34
+ * ride along as extras (the payload allows free-form pass-through), so
35
+ * downstream attribution keeps the full token picture.
36
+ */
37
+ export declare function buildWrongTraceTelemetryReport(input: WrongTraceTelemetryInput): WrongTraceTelemetryReport;
38
+ /**
39
+ * Report session telemetry, best-effort. Never throws: an offline daemon,
40
+ * transport failure, or malformed response resolves silently — telemetry
41
+ * must never delay or fail session cleanup.
42
+ *
43
+ * Optional client injection is a test seam; production uses the singleton.
44
+ */
45
+ export declare function reportWrongTraceSessionTelemetry(input: WrongTraceTelemetryInput, opts?: {
46
+ client?: {
47
+ isAvailable: boolean;
48
+ reportTelemetry: (r: WrongTraceTelemetryReport) => Promise<{
49
+ ok: boolean;
50
+ } | null>;
51
+ };
52
+ }): Promise<void>;
53
+ //# sourceMappingURL=wrongtrace-telemetry.d.ts.map
@@ -0,0 +1,22 @@
1
+ import {
2
+ countersFilePath,
3
+ createWrongTraceGateCounter,
4
+ formatGateCounterReport,
5
+ loadWrongTraceGateCounters,
6
+ persistWrongTraceGateCounters,
7
+ recordGateDecision,
8
+ resetGateDecisions,
9
+ snapshotGateDecisions
10
+ } from "./chunk-7CECQDNH.js";
11
+ import "./chunk-7OCVIDC7.js";
12
+ export {
13
+ countersFilePath,
14
+ createWrongTraceGateCounter,
15
+ formatGateCounterReport,
16
+ loadWrongTraceGateCounters,
17
+ persistWrongTraceGateCounters,
18
+ recordGateDecision,
19
+ resetGateDecisions,
20
+ snapshotGateDecisions
21
+ };
22
+ //# sourceMappingURL=wrongtrace-gate-counters-P5BCBXQN.js.map
@@ -0,0 +1,34 @@
1
+ import {
2
+ getWrongTrace
3
+ } from "./chunk-4JRIWVJ4.js";
4
+ import "./chunk-7OCVIDC7.js";
5
+
6
+ // src/wiring/wrongtrace-telemetry.ts
7
+ function buildWrongTraceTelemetryReport(input) {
8
+ return {
9
+ run_id: input.sessionId,
10
+ agent_name: input.agentName,
11
+ model_name: input.model,
12
+ provider: input.provider,
13
+ prompt_tokens: input.usage.input,
14
+ completion_tokens: input.usage.output,
15
+ cost_usd: input.costUsd,
16
+ intent: "session_complete",
17
+ cache_read_tokens: input.usage.cacheRead ?? 0,
18
+ cache_write_tokens: input.usage.cacheWrite ?? 0,
19
+ source: "wrongstack"
20
+ };
21
+ }
22
+ async function reportWrongTraceSessionTelemetry(input, opts = {}) {
23
+ try {
24
+ const wt = opts.client ?? await getWrongTrace();
25
+ if (!wt.isAvailable) return;
26
+ await wt.reportTelemetry(buildWrongTraceTelemetryReport(input));
27
+ } catch {
28
+ }
29
+ }
30
+ export {
31
+ buildWrongTraceTelemetryReport,
32
+ reportWrongTraceSessionTelemetry
33
+ };
34
+ //# sourceMappingURL=wrongtrace-telemetry-6M2CCBX5.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/cli",
3
- "version": "0.310.0",
3
+ "version": "0.313.0",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack CLI — terminal AI coding agent with provider catalog from models.dev. Provides `wrongstack` and `wstack` binaries.",
6
6
  "keywords": [
@@ -42,34 +42,35 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "ws": "^8.21.3",
45
- "@wrongstack/acp": "0.310.0",
46
- "@wrongstack/bench": "0.310.0",
47
- "@wrongstack/core": "0.310.0",
48
- "@wrongstack/persistence": "0.310.0",
49
- "@wrongstack/kanban": "0.310.0",
50
- "@wrongstack/plugins": "0.310.0",
51
- "@wrongstack/plug-lsp": "0.310.0",
52
- "@wrongstack/primitives": "0.310.0",
53
- "@wrongstack/providers": "0.310.0",
54
- "@wrongstack/runtime": "0.310.0",
55
- "@wrongstack/sdd": "0.310.0",
56
- "@wrongstack/mcp": "0.310.0",
57
- "@wrongstack/requirement-intake": "0.310.0",
58
- "@wrongstack/sage": "0.310.0",
59
- "@wrongstack/security-scanner": "0.310.0",
60
- "@wrongstack/techstack": "0.310.0",
61
- "@wrongstack/telegram": "0.310.0",
62
- "@wrongstack/simpleui": "0.310.0",
63
- "@wrongstack/vector-memory": "0.310.0",
64
- "@wrongstack/tools": "0.310.0",
65
- "@wrongstack/webui": "0.310.0",
66
- "@wrongstack/webui-server": "0.310.0",
67
- "@wrongstack/webui-hq": "0.310.0",
68
- "@wrongstack/tui": "0.310.0",
69
- "@wrongstack/webui-protocol": "0.310.0"
45
+ "@wrongstack/acp": "0.313.0",
46
+ "@wrongstack/mcp": "0.313.0",
47
+ "@wrongstack/bench": "0.313.0",
48
+ "@wrongstack/primitives": "0.313.0",
49
+ "@wrongstack/plugins": "0.313.0",
50
+ "@wrongstack/core": "0.313.0",
51
+ "@wrongstack/kanban": "0.313.0",
52
+ "@wrongstack/plug-lsp": "0.313.0",
53
+ "@wrongstack/persistence": "0.313.0",
54
+ "@wrongstack/providers": "0.313.0",
55
+ "@wrongstack/requirement-intake": "0.313.0",
56
+ "@wrongstack/runtime": "0.313.0",
57
+ "@wrongstack/sage": "0.313.0",
58
+ "@wrongstack/simpleui": "0.313.0",
59
+ "@wrongstack/sdd": "0.313.0",
60
+ "@wrongstack/security-scanner": "0.313.0",
61
+ "@wrongstack/techstack": "0.313.0",
62
+ "@wrongstack/telegram": "0.313.0",
63
+ "@wrongstack/tui": "0.313.0",
64
+ "@wrongstack/tools": "0.313.0",
65
+ "@wrongstack/vector-memory": "0.313.0",
66
+ "@wrongstack/webui-protocol": "0.313.0",
67
+ "@wrongstack/webui": "0.313.0",
68
+ "@wrongstack/webui-hq": "0.313.0",
69
+ "@wrongstack/wrongtrace": "0.313.0",
70
+ "@wrongstack/webui-server": "0.313.0"
70
71
  },
71
72
  "optionalDependencies": {
72
- "@wrongstack/desktop": "0.310.0"
73
+ "@wrongstack/desktop": "0.313.0"
73
74
  },
74
75
  "devDependencies": {
75
76
  "@types/node": "^26.2.0",