prismalens 0.0.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/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +312 -0
- package/dist/bin/prismalens.d.ts +3 -0
- package/dist/bin/prismalens.d.ts.map +1 -0
- package/dist/bin/prismalens.js +32 -0
- package/dist/bin/prismalens.js.map +1 -0
- package/dist/src/cli/doctor.d.ts +3 -0
- package/dist/src/cli/doctor.d.ts.map +1 -0
- package/dist/src/cli/doctor.js +156 -0
- package/dist/src/cli/doctor.js.map +1 -0
- package/dist/src/cli/init.d.ts +3 -0
- package/dist/src/cli/init.d.ts.map +1 -0
- package/dist/src/cli/init.js +85 -0
- package/dist/src/cli/init.js.map +1 -0
- package/dist/src/cli/investigate.d.ts +101 -0
- package/dist/src/cli/investigate.d.ts.map +1 -0
- package/dist/src/cli/investigate.js +452 -0
- package/dist/src/cli/investigate.js.map +1 -0
- package/dist/src/cli/serve.d.ts +3 -0
- package/dist/src/cli/serve.d.ts.map +1 -0
- package/dist/src/cli/serve.js +26 -0
- package/dist/src/cli/serve.js.map +1 -0
- package/dist/src/config/loader.d.ts +22 -0
- package/dist/src/config/loader.d.ts.map +1 -0
- package/dist/src/config/loader.js +155 -0
- package/dist/src/config/loader.js.map +1 -0
- package/dist/src/config/schema.d.ts +336 -0
- package/dist/src/config/schema.d.ts.map +1 -0
- package/dist/src/config/schema.js +160 -0
- package/dist/src/config/schema.js.map +1 -0
- package/dist/src/core/detect-repo.d.ts +4 -0
- package/dist/src/core/detect-repo.d.ts.map +1 -0
- package/dist/src/core/detect-repo.js +28 -0
- package/dist/src/core/detect-repo.js.map +1 -0
- package/dist/src/core/file-session-store.d.ts +10 -0
- package/dist/src/core/file-session-store.d.ts.map +1 -0
- package/dist/src/core/file-session-store.js +34 -0
- package/dist/src/core/file-session-store.js.map +1 -0
- package/dist/src/core/parse-stdin.d.ts +2 -0
- package/dist/src/core/parse-stdin.d.ts.map +1 -0
- package/dist/src/core/parse-stdin.js +30 -0
- package/dist/src/core/parse-stdin.js.map +1 -0
- package/dist/src/core/run-investigation.d.ts +42 -0
- package/dist/src/core/run-investigation.d.ts.map +1 -0
- package/dist/src/core/run-investigation.js +144 -0
- package/dist/src/core/run-investigation.js.map +1 -0
- package/dist/src/core/session.d.ts +42 -0
- package/dist/src/core/session.d.ts.map +1 -0
- package/dist/src/core/session.js +168 -0
- package/dist/src/core/session.js.map +1 -0
- package/dist/src/jsonrpc/server.d.ts +15 -0
- package/dist/src/jsonrpc/server.d.ts.map +1 -0
- package/dist/src/jsonrpc/server.js +244 -0
- package/dist/src/jsonrpc/server.js.map +1 -0
- package/dist/src/jsonrpc/types.d.ts +12 -0
- package/dist/src/jsonrpc/types.d.ts.map +1 -0
- package/dist/src/jsonrpc/types.js +4 -0
- package/dist/src/jsonrpc/types.js.map +1 -0
- package/dist/src/version.d.ts +8 -0
- package/dist/src/version.d.ts.map +1 -0
- package/dist/src/version.js +27 -0
- package/dist/src/version.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Sumit Patel
|
|
3
|
+
/**
|
|
4
|
+
* `prismalens investigate` — the core investigation command (ADR-0008/0010).
|
|
5
|
+
*
|
|
6
|
+
* Seeds a read-only root-cause investigation from a firing alert (piped on stdin
|
|
7
|
+
* as a FiringAlert JSON, or synthesized from `--query`), rents a Tier-2 harness
|
|
8
|
+
* (deepagents over ACP, or Claude Code over the Agent SDK), drives the Tier-1
|
|
9
|
+
* supervisor LIVE via the shared conductor (`conductRun`, ADR-0018), and renders
|
|
10
|
+
* the ordered-evidence report (ADR-0002).
|
|
11
|
+
*
|
|
12
|
+
* BYO-key (ADR-0006): provider creds come from the environment
|
|
13
|
+
* (OLLAMA_ / OPENAI_ vars), never hard-bound here. The harness investigates
|
|
14
|
+
* READ-ONLY.
|
|
15
|
+
*
|
|
16
|
+
* LIVE (ADR-0007/0010): `conductRun` fans each CanonicalEvent to a file-session
|
|
17
|
+
* STORE (append) and a terminal-line SINK, then this command renders the
|
|
18
|
+
* synthesized report once the run resolves. The ~/.prismalens workspace stays as
|
|
19
|
+
* the durable record.
|
|
20
|
+
*/
|
|
21
|
+
import { randomUUID } from "node:crypto";
|
|
22
|
+
import { writeFile } from "node:fs/promises";
|
|
23
|
+
import { join, resolve } from "node:path";
|
|
24
|
+
import { HARNESS_REGISTRY } from "@prismalens/config/harness";
|
|
25
|
+
import { INVESTIGATION_DEFAULTS } from "@prismalens/config/investigation";
|
|
26
|
+
import { conductRun, resolveSandbox, SANDBOX_MODES, } from "@prismalens/engine";
|
|
27
|
+
import { defineCommand } from "citty";
|
|
28
|
+
import consola from "consola";
|
|
29
|
+
import { loadConfig } from "../config/loader.js";
|
|
30
|
+
import { resolveRepoSlug } from "../core/detect-repo.js";
|
|
31
|
+
import { createFileSessionStore } from "../core/file-session-store.js";
|
|
32
|
+
import { parseStdin } from "../core/parse-stdin.js";
|
|
33
|
+
import { resolveInvestigation, } from "../core/run-investigation.js";
|
|
34
|
+
import { createSessionManager } from "../core/session.js";
|
|
35
|
+
export default defineCommand({
|
|
36
|
+
meta: {
|
|
37
|
+
name: "investigate",
|
|
38
|
+
description: "Run a read-only root-cause investigation of a firing alert (two-tier engine, ADR-0008).",
|
|
39
|
+
},
|
|
40
|
+
args: {
|
|
41
|
+
repo: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "Path to the repository the harness investigates (its cwd). Defaults to the current directory.",
|
|
44
|
+
},
|
|
45
|
+
query: {
|
|
46
|
+
type: "string",
|
|
47
|
+
alias: "q",
|
|
48
|
+
description: "Investigate a synthesized alert from this one-line description (alternative to piping a FiringAlert JSON on stdin).",
|
|
49
|
+
},
|
|
50
|
+
config: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description: "Path to a prismalens.config.yaml (skips the upward config search).",
|
|
53
|
+
},
|
|
54
|
+
model: {
|
|
55
|
+
type: "string",
|
|
56
|
+
description: "Override agent.model — a bare model id, e.g. gpt-oss:120b.",
|
|
57
|
+
},
|
|
58
|
+
harness: {
|
|
59
|
+
type: "enum",
|
|
60
|
+
options: ["deepagents", "claude-code", "codex"],
|
|
61
|
+
description: "Tier-2 harness backend. Defaults to agent.default in config.",
|
|
62
|
+
},
|
|
63
|
+
mode: {
|
|
64
|
+
type: "enum",
|
|
65
|
+
options: ["read-only", "supervised", "auto", "dangerous"],
|
|
66
|
+
description: "Permission posture the harness runs under (ADR-0017). Defaults to agent.permissions.mode in config (read-only).",
|
|
67
|
+
},
|
|
68
|
+
dangerouslySkipPermissions: {
|
|
69
|
+
type: "boolean",
|
|
70
|
+
default: false,
|
|
71
|
+
description: "Alias for --mode dangerous.",
|
|
72
|
+
},
|
|
73
|
+
sandbox: {
|
|
74
|
+
type: "enum",
|
|
75
|
+
options: [...SANDBOX_MODES],
|
|
76
|
+
description: "Isolation boundary the harness runs in (ADR-0020): process (cooperative floor), srt (enforced), or auto. Defaults to agent.sandbox in config (auto — srt when its egress bridge is healthy, else the process floor).",
|
|
77
|
+
},
|
|
78
|
+
service: {
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "Select the service context by name from `services` in config (overrides the alert's service label).",
|
|
81
|
+
},
|
|
82
|
+
json: {
|
|
83
|
+
type: "boolean",
|
|
84
|
+
default: false,
|
|
85
|
+
description: "Print the InvestigationReport as JSON to stdout (suppresses the human renderer).",
|
|
86
|
+
},
|
|
87
|
+
output: {
|
|
88
|
+
type: "string",
|
|
89
|
+
description: "Write the InvestigationReport JSON to this file.",
|
|
90
|
+
},
|
|
91
|
+
quiet: {
|
|
92
|
+
type: "boolean",
|
|
93
|
+
default: false,
|
|
94
|
+
description: "Suppress progress + the human renderer (errors still go to stderr).",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
async run({ args }) {
|
|
98
|
+
const json = Boolean(args.json);
|
|
99
|
+
// In --json mode stdout must be machine-clean, so suppress all info-level
|
|
100
|
+
// chatter (consola routes info/log/success to stdout, warn/error to stderr).
|
|
101
|
+
// The AI SDK's stdout warning banner is disabled bin-wide (bin/prismalens.ts).
|
|
102
|
+
const quiet = Boolean(args.quiet) || json;
|
|
103
|
+
const info = (msg) => {
|
|
104
|
+
if (!quiet)
|
|
105
|
+
consola.info(msg);
|
|
106
|
+
};
|
|
107
|
+
const success = (msg) => {
|
|
108
|
+
if (!quiet)
|
|
109
|
+
consola.success(msg);
|
|
110
|
+
};
|
|
111
|
+
// One-line live timeline entries (no consola icon, so the stream reads cleanly).
|
|
112
|
+
const line = (msg) => {
|
|
113
|
+
if (!quiet)
|
|
114
|
+
consola.log(msg);
|
|
115
|
+
};
|
|
116
|
+
// (1) Resolve the seed alert + config + harness + reduce model. The seed is a
|
|
117
|
+
// piped FiringAlert JSON (the stdin channel) or, failing that, --query.
|
|
118
|
+
const piped = await parseStdin();
|
|
119
|
+
// cwd = --repo (a local repo path) else the current directory.
|
|
120
|
+
const cwd = args.repo ? resolve(args.repo) : process.cwd();
|
|
121
|
+
// Load + merge config (global → project → CLI overrides); --model overrides agent.model.
|
|
122
|
+
const config = await loadConfig({
|
|
123
|
+
...(args.config ? { configPath: args.config } : {}),
|
|
124
|
+
cwd,
|
|
125
|
+
cliOverrides: { ...(args.model ? { model: args.model } : {}) },
|
|
126
|
+
});
|
|
127
|
+
// Session label: config `repo` (owner/name) wins; else git auto-detect; else none.
|
|
128
|
+
const repoSlug = await resolveRepoSlug(config.repo, cwd);
|
|
129
|
+
// The single posture dial (ADR-0017): --dangerously-skip-permissions wins over
|
|
130
|
+
// --mode, aliasing straight to "dangerous".
|
|
131
|
+
const permissionMode = args.dangerouslySkipPermissions
|
|
132
|
+
? "dangerous"
|
|
133
|
+
: args.mode;
|
|
134
|
+
// Resolve the isolation boundary (ADR-0020): --sandbox wins over agent.sandbox.
|
|
135
|
+
// Only ACP-transport harnesses are spawned as a child the engine can place
|
|
136
|
+
// inside a boundary (the Agent SDK harness runs in-process). Fail fast ONLY when
|
|
137
|
+
// the mode DEMANDS an enforced boundary (`srt`/`e2b`) a non-ACP harness cannot
|
|
138
|
+
// honour (ADR-0017 — never claim an enforcement that would not apply). `auto` and
|
|
139
|
+
// `process` with a non-ACP harness run WITHOUT a sandbox silently: `auto` means
|
|
140
|
+
// best-effort, and the best available for an in-process harness is none — nothing
|
|
141
|
+
// is claimed, so nothing is dishonest. The sandbox is CALLER-OWNED — destroyed in
|
|
142
|
+
// the finally.
|
|
143
|
+
const harnessName = args.harness ?? config.agent.default;
|
|
144
|
+
const sandboxMode = args.sandbox ?? config.agent.sandbox;
|
|
145
|
+
let selection = null;
|
|
146
|
+
try {
|
|
147
|
+
const resolvedSandbox = await resolveRunSandbox(harnessName, sandboxMode, config);
|
|
148
|
+
selection = resolvedSandbox.selection;
|
|
149
|
+
// Honest fidelity (ADR-0017): a silent degrade would mislead — name it, with
|
|
150
|
+
// the self-check's reason (srt absent, or its egress bridge dead — B.1.1).
|
|
151
|
+
if (selection && resolvedSandbox.degradeReason) {
|
|
152
|
+
consola.warn(`Sandbox 'auto' degraded to the ${selection.actual} (cooperative, not an OS boundary): ${resolvedSandbox.degradeReason}.`);
|
|
153
|
+
}
|
|
154
|
+
else if (selection?.actual === "srt") {
|
|
155
|
+
info("Sandbox: srt (enforced OS boundary).");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
consola.error(err instanceof Error ? err.message : String(err));
|
|
160
|
+
process.exitCode = 1;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
let resolved;
|
|
165
|
+
try {
|
|
166
|
+
resolved = resolveInvestigation({
|
|
167
|
+
...(piped ? { alert: piped } : {}),
|
|
168
|
+
...(args.query ? { query: args.query } : {}),
|
|
169
|
+
...(args.repo ? { repo: args.repo } : {}),
|
|
170
|
+
...(args.harness ? { harness: args.harness } : {}),
|
|
171
|
+
...(args.service ? { service: args.service } : {}),
|
|
172
|
+
...(permissionMode ? { permissionMode } : {}),
|
|
173
|
+
...(selection
|
|
174
|
+
? {
|
|
175
|
+
sandbox: selection.sandbox,
|
|
176
|
+
requestedSandbox: selection.requested,
|
|
177
|
+
}
|
|
178
|
+
: {}),
|
|
179
|
+
}, config);
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
consola.error(err instanceof Error ? err.message : String(err));
|
|
183
|
+
process.exitCode = 1;
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const { context, harness, synth, harnessName, fidelity, maxBranches } = resolved;
|
|
187
|
+
const primaryAlert = context.alerts[0];
|
|
188
|
+
if (!synth.apiKey) {
|
|
189
|
+
consola.warn("No OLLAMA_API_KEY / OPENAI_API_KEY in the environment — the synthesis call will likely fail (BYO-key, ADR-0006).");
|
|
190
|
+
}
|
|
191
|
+
// (2) Create the run workspace + session under workspace.base_dir, wrapped as
|
|
192
|
+
// a conductRun store adapter (ADR-0018).
|
|
193
|
+
const runId = randomUUID();
|
|
194
|
+
const sessions = createSessionManager(config.workspace.base_dir);
|
|
195
|
+
const fileSession = createFileSessionStore(sessions, {
|
|
196
|
+
runId,
|
|
197
|
+
alertname: primaryAlert.alertname,
|
|
198
|
+
agent: harnessName,
|
|
199
|
+
...(repoSlug ? { repo: repoSlug } : {}),
|
|
200
|
+
});
|
|
201
|
+
info(`Investigating "${primaryAlert.alertname}" with ${harnessName} in ${cwd} (run ${runId})`);
|
|
202
|
+
// (3) Drive the supervisor LIVE via the shared conductor: print a one-line
|
|
203
|
+
// timeline entry per event; conductRun owns persistence + the terminal
|
|
204
|
+
// report/no-evidence/error outcome.
|
|
205
|
+
const outcome = await conductRun({
|
|
206
|
+
context,
|
|
207
|
+
harness,
|
|
208
|
+
synth,
|
|
209
|
+
fidelity,
|
|
210
|
+
runId,
|
|
211
|
+
...(maxBranches !== undefined ? { maxBranches } : {}),
|
|
212
|
+
}, {
|
|
213
|
+
sink: (event) => {
|
|
214
|
+
const entry = liveTimelineEntry(event);
|
|
215
|
+
if (entry)
|
|
216
|
+
line(entry);
|
|
217
|
+
},
|
|
218
|
+
store: fileSession.store,
|
|
219
|
+
});
|
|
220
|
+
if (!outcome.report) {
|
|
221
|
+
consola.error(outcome.error);
|
|
222
|
+
process.exitCode = 1;
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const report = outcome.report;
|
|
226
|
+
// (4) Output. --output writes report JSON to a file; --json prints it to
|
|
227
|
+
// stdout; otherwise render the ordered-evidence report for humans.
|
|
228
|
+
if (args.output) {
|
|
229
|
+
const outPath = resolve(args.output);
|
|
230
|
+
await writeFile(outPath, `${JSON.stringify(report, null, 2)}\n`, "utf-8");
|
|
231
|
+
success(`Report written to ${outPath}`);
|
|
232
|
+
}
|
|
233
|
+
if (json) {
|
|
234
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (!quiet) {
|
|
238
|
+
renderReport(report);
|
|
239
|
+
success(`Report saved to ${join(fileSession.workspacePath(), "report.json")}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
// The command owns the resolved boundary's lifecycle (ADR-0020) — tear it
|
|
244
|
+
// down whichever way the run exited (report, no-evidence, error, or throw).
|
|
245
|
+
if (selection)
|
|
246
|
+
await selection.sandbox.destroy();
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
/**
|
|
251
|
+
* The egress allowlist for an enforced sandbox (ADR-0020: allowlist, not closed) — the
|
|
252
|
+
* hostnames of every surface the harness will ACTUALLY contact: its own LLM endpoint
|
|
253
|
+
* (BYO-key baseURL, env override included) PLUS the read-only telemetry + log surfaces.
|
|
254
|
+
* The LLM + telemetry hosts carry the SAME `INVESTIGATION_DEFAULTS` fallback the request
|
|
255
|
+
* assembly applies (`run-investigation`), because an unset config field still resolves to
|
|
256
|
+
* a default the harness queries — omitting it hard-denied the model call and default
|
|
257
|
+
* telemetry, so every branch failed with no report. Mirrors the worker's
|
|
258
|
+
* `deriveWorkerAllowedHosts`. Non-URL values are skipped (no egress hole from a malformed
|
|
259
|
+
* endpoint); the `process` floor ignores this.
|
|
260
|
+
*/
|
|
261
|
+
export function collectAllowedDomains(config) {
|
|
262
|
+
// The LLM endpoint the harness itself calls (BYO-key, ADR-0006): env override wins,
|
|
263
|
+
// else the shared synth default — the SAME resolution as `run-investigation`.
|
|
264
|
+
const llmBaseUrl = process.env.OLLAMA_BASE_URL ??
|
|
265
|
+
process.env.OPENAI_BASE_URL ??
|
|
266
|
+
INVESTIGATION_DEFAULTS.synth.baseURL;
|
|
267
|
+
const urls = [
|
|
268
|
+
llmBaseUrl,
|
|
269
|
+
config.telemetry.prometheusUrl ??
|
|
270
|
+
INVESTIGATION_DEFAULTS.telemetry.prometheusUrl,
|
|
271
|
+
config.telemetry.alertmanagerUrl ??
|
|
272
|
+
INVESTIGATION_DEFAULTS.telemetry.alertmanagerUrl,
|
|
273
|
+
config.telemetry.apiUrl ?? INVESTIGATION_DEFAULTS.telemetry.apiUrl,
|
|
274
|
+
config.logs.url,
|
|
275
|
+
];
|
|
276
|
+
const hosts = new Set();
|
|
277
|
+
for (const url of urls) {
|
|
278
|
+
if (!url)
|
|
279
|
+
continue;
|
|
280
|
+
try {
|
|
281
|
+
hosts.add(new URL(url).hostname);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// not a parseable URL — skip; no egress hole from a malformed endpoint
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return [...hosts];
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Resolve the isolation boundary for a run (ADR-0020/0017) — the single sandbox-resolution
|
|
291
|
+
* path shared by the `investigate` command and the JSON-RPC `serve` handler, so both honour
|
|
292
|
+
* `agent.sandbox` (and `--sandbox`) with identical semantics. Guards first: a mode that
|
|
293
|
+
* DEMANDS enforcement (`srt`/`e2b`) on a non-ACP (in-process) harness THROWS — the caller
|
|
294
|
+
* maps it to its own channel (CLI stderr+exit, or a JSON-RPC error), never a silent floor.
|
|
295
|
+
* Then resolves a boundary ONLY for an ACP harness; an in-process harness returns a null
|
|
296
|
+
* selection (it runs on the cooperative floor, claiming nothing — nothing dishonest). The
|
|
297
|
+
* returned `selection` is CALLER-OWNED — destroy it after the run. `degradeReason` is the
|
|
298
|
+
* honest note when `auto` fell short of srt (present only on a degrade).
|
|
299
|
+
*/
|
|
300
|
+
export async function resolveRunSandbox(harness, mode, config) {
|
|
301
|
+
const guard = resolveSandboxGuard(harness, mode);
|
|
302
|
+
if (guard.blocked) {
|
|
303
|
+
throw new Error(`Harness "${harness}" cannot run inside an enforced sandbox (${mode}) yet ` +
|
|
304
|
+
`— it is not spawned as a child process. Use the auto or process sandbox ` +
|
|
305
|
+
`mode (no enforced boundary), or an ACP harness (deepagents).`);
|
|
306
|
+
}
|
|
307
|
+
if (!guard.takesSandbox)
|
|
308
|
+
return { selection: null, degradeReason: null };
|
|
309
|
+
const probeUrl = firstProbeUrl(config);
|
|
310
|
+
const selection = await resolveSandbox(mode, {
|
|
311
|
+
allowedDomains: collectAllowedDomains(config),
|
|
312
|
+
...(probeUrl ? { probeUrl } : {}),
|
|
313
|
+
});
|
|
314
|
+
const degradeReason = mode === "auto" && selection.actual !== "srt"
|
|
315
|
+
? (selection.degradeReason ?? "srt unavailable")
|
|
316
|
+
: null;
|
|
317
|
+
return { selection, degradeReason };
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* The egress SELF-CHECK target (ADR-0020 B.1.1): the FIRST configured, parseable FULL URL
|
|
321
|
+
* among the telemetry + log surfaces — handed to `auto` as `probeUrl` so its throwaway srt
|
|
322
|
+
* boundary curls a REAL endpoint (not a fabricated `https://<host>/`). Kept as a full URL
|
|
323
|
+
* on purpose (path/port matter for the probe); `undefined` when nothing is configured, in
|
|
324
|
+
* which case `auto` floors rather than standing up a zero-egress boundary (FIX 6).
|
|
325
|
+
*/
|
|
326
|
+
function firstProbeUrl(config) {
|
|
327
|
+
const urls = [
|
|
328
|
+
config.telemetry.prometheusUrl,
|
|
329
|
+
config.telemetry.alertmanagerUrl,
|
|
330
|
+
config.telemetry.apiUrl,
|
|
331
|
+
config.logs.url,
|
|
332
|
+
];
|
|
333
|
+
for (const url of urls) {
|
|
334
|
+
if (!url)
|
|
335
|
+
continue;
|
|
336
|
+
try {
|
|
337
|
+
return new URL(url).href;
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
// not a parseable URL — skip; a malformed endpoint is no probe target
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return undefined;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* The sandbox guard (ADR-0020/0017), mirrored in the worker's `harnessTakesSandbox`: only
|
|
347
|
+
* ACP-transport harnesses are spawned as a child the engine can place inside a boundary.
|
|
348
|
+
* Returns whether this harness `takesSandbox` and whether the request is `blocked` — the
|
|
349
|
+
* fail-fast case where a mode that DEMANDS an enforced boundary (`srt`/`e2b`) was asked of a
|
|
350
|
+
* non-ACP harness. `auto`/`process` are never blocked: they run WITHOUT a sandbox on an
|
|
351
|
+
* in-process harness, claiming nothing, so nothing is dishonest.
|
|
352
|
+
*/
|
|
353
|
+
export function resolveSandboxGuard(harness, mode) {
|
|
354
|
+
const takesSandbox = HARNESS_REGISTRY[harness]?.transport === "acp";
|
|
355
|
+
const demandsEnforcedBoundary = mode === "srt" || mode === "e2b";
|
|
356
|
+
return { takesSandbox, blocked: !takesSandbox && demandsEnforcedBoundary };
|
|
357
|
+
}
|
|
358
|
+
// ---------------------------------------------------------------------------
|
|
359
|
+
// Live timeline (one line per streamed canonical event)
|
|
360
|
+
// ---------------------------------------------------------------------------
|
|
361
|
+
/**
|
|
362
|
+
* Render one live-timeline line for a streamed canonical event, or null when the
|
|
363
|
+
* event carries nothing worth a line (an agent_step with neither text nor calls).
|
|
364
|
+
* The terminal `report` event is captured by the caller, not lined here.
|
|
365
|
+
*/
|
|
366
|
+
function liveTimelineEntry(event) {
|
|
367
|
+
switch (event.kind) {
|
|
368
|
+
case "agent_step": {
|
|
369
|
+
const firstLine = event.text.trim().split("\n", 1)[0]?.trim() ?? "";
|
|
370
|
+
const n = event.toolCalls.length;
|
|
371
|
+
if (!firstLine && n === 0)
|
|
372
|
+
return null;
|
|
373
|
+
const calls = n > 0 ? ` + ${n} tool call${n === 1 ? "" : "s"}` : "";
|
|
374
|
+
return `• ${firstLine}${calls}`;
|
|
375
|
+
}
|
|
376
|
+
case "tool_result":
|
|
377
|
+
return ` ${event.result.ok ? "ok" : "ERR"} ${event.result.source}`;
|
|
378
|
+
case "branch_done":
|
|
379
|
+
return ` [branch ${event.reason}]`;
|
|
380
|
+
case "error":
|
|
381
|
+
return ` [error] ${event.message}`;
|
|
382
|
+
default:
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
// ---------------------------------------------------------------------------
|
|
387
|
+
// Terminal renderer (ordered-evidence report, ADR-0002)
|
|
388
|
+
// ---------------------------------------------------------------------------
|
|
389
|
+
const HYPOTHESIS_MARK = {
|
|
390
|
+
confirmed: "[confirmed]",
|
|
391
|
+
supported: "[supported]",
|
|
392
|
+
speculative: "[speculative]",
|
|
393
|
+
refuted: "[refuted]",
|
|
394
|
+
};
|
|
395
|
+
function renderReport(report) {
|
|
396
|
+
consola.log("");
|
|
397
|
+
consola.log("=== Investigation Report ===");
|
|
398
|
+
consola.log(report.summary);
|
|
399
|
+
consola.log("");
|
|
400
|
+
if (report.rootCause) {
|
|
401
|
+
const cat = report.rootCauseCategory
|
|
402
|
+
? ` [${report.rootCauseCategory}]`
|
|
403
|
+
: "";
|
|
404
|
+
consola.log(`Root cause${cat}:`);
|
|
405
|
+
consola.log(` ${report.rootCause}`);
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
consola.log("Root cause: not determined");
|
|
409
|
+
}
|
|
410
|
+
if (report.hypotheses.length > 0) {
|
|
411
|
+
consola.log("");
|
|
412
|
+
consola.log("Hypotheses (most -> least plausible):");
|
|
413
|
+
report.hypotheses.forEach((h, i) => {
|
|
414
|
+
renderHypothesis(h, i + 1);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
if (report.ruledOut.length > 0) {
|
|
418
|
+
consola.log("");
|
|
419
|
+
consola.log("Ruled out:");
|
|
420
|
+
for (const r of report.ruledOut)
|
|
421
|
+
renderRuledOut(r);
|
|
422
|
+
}
|
|
423
|
+
const { queried, notQueried } = report.coverage;
|
|
424
|
+
if (queried.length > 0 || notQueried.length > 0) {
|
|
425
|
+
consola.log("");
|
|
426
|
+
consola.log(`Coverage: ${queried.length} source(s) queried, ${notQueried.length} not queried.`);
|
|
427
|
+
}
|
|
428
|
+
if (report.nextSteps.length > 0) {
|
|
429
|
+
consola.log("");
|
|
430
|
+
consola.log("Next steps:");
|
|
431
|
+
for (const s of report.nextSteps)
|
|
432
|
+
renderNextStep(s);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function renderHypothesis(h, n) {
|
|
436
|
+
consola.log(` ${n}. ${HYPOTHESIS_MARK[h.status]} ${h.statement}`);
|
|
437
|
+
for (const e of h.evidence) {
|
|
438
|
+
const sign = e.direction === "supports" ? "+" : "-";
|
|
439
|
+
consola.log(` ${sign} (${e.status}) ${e.observation} [${e.source}]`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function renderRuledOut(r) {
|
|
443
|
+
consola.log(` x ${r.statement} — ${r.why}`);
|
|
444
|
+
for (const e of r.evidence) {
|
|
445
|
+
consola.log(` - (${e.status}) ${e.observation} [${e.source}]`);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function renderNextStep(s) {
|
|
449
|
+
const prio = s.priority ? `[${s.priority}] ` : "";
|
|
450
|
+
consola.log(` * ${prio}${s.title}: ${s.detail}`);
|
|
451
|
+
}
|
|
452
|
+
//# sourceMappingURL=investigate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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,CAAC,CAAW;IAClC,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/cli/serve.ts"],"names":[],"mappings":";AAmBA,wBASG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Sumit Patel
|
|
3
|
+
/**
|
|
4
|
+
* `prismalens serve` — run the JSON-RPC 2.0 server over stdio (ADR-0007/0010).
|
|
5
|
+
*
|
|
6
|
+
* This is the LIVE channel (replacing file-read): the desktop app / API spawn
|
|
7
|
+
* `prismalens serve`, call `initialize` + `investigate`, and consume
|
|
8
|
+
* `investigate/event` notifications as the Tier-1 supervisor streams. The
|
|
9
|
+
* ~/.prismalens workspace stays the durable record (events.jsonl + report.json),
|
|
10
|
+
* written exactly as the `investigate` command writes it.
|
|
11
|
+
*/
|
|
12
|
+
import { defineCommand } from "citty";
|
|
13
|
+
import { runJsonRpcServer } from "../jsonrpc/server.js";
|
|
14
|
+
import { cliVersion } from "../version.js";
|
|
15
|
+
/** Reported as serverInfo.version by `initialize` (matches the CLI's meta.version). */
|
|
16
|
+
const SERVER_VERSION = cliVersion();
|
|
17
|
+
export default defineCommand({
|
|
18
|
+
meta: {
|
|
19
|
+
name: "serve",
|
|
20
|
+
description: "Run the JSON-RPC 2.0 server over stdio (the LIVE channel for the desktop app / API).",
|
|
21
|
+
},
|
|
22
|
+
async run() {
|
|
23
|
+
await runJsonRpcServer({ version: SERVER_VERSION });
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/cli/serve.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,6BAA6B;AAE7B;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,uFAAuF;AACvF,MAAM,cAAc,GAAG,UAAU,EAAE,CAAC;AAEpC,eAAe,aAAa,CAAC;IAC5B,IAAI,EAAE;QACL,IAAI,EAAE,OAAO;QACb,WAAW,EACV,sFAAsF;KACvF;IACD,KAAK,CAAC,GAAG;QACR,MAAM,gBAAgB,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;IACrD,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type PlConfig } from "./schema.js";
|
|
2
|
+
export interface CliOverrides {
|
|
3
|
+
/** agent.default — harness backend. */
|
|
4
|
+
agent?: string;
|
|
5
|
+
/** agent.model. */
|
|
6
|
+
model?: string;
|
|
7
|
+
prometheusUrl?: string;
|
|
8
|
+
alertmanagerUrl?: string;
|
|
9
|
+
apiUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface LoadConfigOptions {
|
|
12
|
+
/** Explicit config path (`--config`). Skips the upward search. */
|
|
13
|
+
configPath?: string;
|
|
14
|
+
/** Directory to start the upward search from. Default `process.cwd()`. */
|
|
15
|
+
cwd?: string;
|
|
16
|
+
cliOverrides?: CliOverrides;
|
|
17
|
+
}
|
|
18
|
+
/** Find the nearest project config by walking up from `cwd` to the filesystem root. */
|
|
19
|
+
export declare function findConfigFile(cwd?: string): string | undefined;
|
|
20
|
+
/** Load, merge, interpolate, and validate the config. Result is frozen. */
|
|
21
|
+
export declare function loadConfig(options?: LoadConfigOptions): Promise<PlConfig>;
|
|
22
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAM5D,MAAM,WAAW,YAAY;IAC5B,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IACjC,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAC7B,GAAG,GAAE,MAAsB,GACzB,MAAM,GAAG,SAAS,CASpB;AA+FD,2EAA2E;AAC3E,wBAAsB,UAAU,CAC/B,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,QAAQ,CAAC,CA8BnB"}
|