@openai/codex-security 0.3.0 → 0.5.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.
- package/README.md +45 -9
- package/_bundled_plugin/.codex-plugin/plugin.json +5 -5
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +13 -20
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/references/core-scan.md +2 -0
- package/_bundled_plugin/references/final-report.md +5 -1
- package/_bundled_plugin/references/investigation-time-budget.md +11 -0
- package/_bundled_plugin/references/sarif-adapter.md +1 -0
- package/_bundled_plugin/references/scan-prologue.md +2 -6
- package/_bundled_plugin/references/scan-runtime.md +15 -0
- package/_bundled_plugin/references/threat-model.md +2 -0
- package/_bundled_plugin/schemas/coverage.schema.json +45 -126
- package/_bundled_plugin/schemas/definitions/artifact-common.schema.json +5 -1
- package/_bundled_plugin/schemas/findings.schema.json +140 -427
- package/_bundled_plugin/schemas/patch-risk-assessment.schema.json +106 -119
- package/_bundled_plugin/schemas/scan-manifest.schema.json +73 -188
- package/_bundled_plugin/scripts/deep_scan_workbench.py +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +87 -49
- package/_bundled_plugin/scripts/finding_preview.py +5 -3
- package/_bundled_plugin/scripts/generate_rank_input.py +26 -106
- package/_bundled_plugin/scripts/launch_codex_security_mcp +39 -4
- package/_bundled_plugin/scripts/report_projection.py +35 -13
- package/_bundled_plugin/scripts/snapshot_sqlite.py +7 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +43 -1
- package/_bundled_plugin/scripts/workbench_cli.py +9 -9
- package/_bundled_plugin/scripts/workbench_constants.py +4 -0
- package/_bundled_plugin/scripts/workbench_db.py +103 -45
- package/_bundled_plugin/scripts/workbench_progress.py +0 -50
- package/_bundled_plugin/scripts/workbench_publication.py +216 -247
- package/_bundled_plugin/scripts/workbench_scan_history.py +3 -2
- package/_bundled_plugin/scripts/workbench_scan_start.py +12 -4
- package/_bundled_plugin/scripts/workbench_scan_usage.py +360 -37
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +74 -51
- package/_bundled_plugin/scripts/workbench_source_scopes.py +388 -0
- package/_bundled_plugin/scripts/workbench_target.py +7 -5
- package/_bundled_plugin/scripts/workbench_validation.py +52 -2
- package/_bundled_plugin/shared/workbench-history-repairs.json +19 -0
- package/_bundled_plugin/shared/workbench-migrations.json +22 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +4 -2
- package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/SKILL.md +4 -2
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -3
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +2 -0
- package/_bundled_plugin/skills/track-findings/SKILL.md +8 -4
- package/_bundled_plugin/skills/track-findings/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +1 -1
- package/dist/api.d.ts +6 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +266 -39
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +2 -1
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +38 -23
- package/dist/artifact-export.js.map +1 -1
- package/dist/classify-severity-records.d.ts +76 -0
- package/dist/classify-severity-records.d.ts.map +1 -0
- package/dist/classify-severity-records.js +141 -0
- package/dist/classify-severity-records.js.map +1 -0
- package/dist/classify-severity.d.ts +1 -23
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +3 -24
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +2 -0
- package/dist/cli-help.js.map +1 -1
- package/dist/cli.d.ts +4 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +148 -149
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +1 -1
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-sdk-environment.js +1 -1
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/component-plan.js +1 -1
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +5 -4
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -4
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +6 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +69 -20
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +7 -2
- package/dist/cost-model.js.map +1 -1
- package/dist/custom-validation-prompt.js +3 -3
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +1 -5
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +2 -2
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +1 -1
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/records-protocol.d.ts +3 -8
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +11 -171
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.js +1 -1
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +10 -9
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +4 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +21 -1
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-progress.d.ts +15 -1
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-progress.js +15 -16
- package/dist/deep-progress.js.map +1 -1
- package/dist/executable-path.d.ts +2 -0
- package/dist/executable-path.d.ts.map +1 -0
- package/dist/executable-path.js +12 -0
- package/dist/executable-path.js.map +1 -0
- package/dist/feedback.d.ts +1 -4
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +1 -1
- package/dist/feedback.js.map +1 -1
- package/dist/findings-import.d.ts +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +3 -3
- package/dist/findings-import.js.map +1 -1
- package/dist/git-remote.d.ts +10 -0
- package/dist/git-remote.d.ts.map +1 -0
- package/dist/git-remote.js +24 -0
- package/dist/git-remote.js.map +1 -0
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +5 -7
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +19 -0
- package/dist/host-protocol.d.ts.map +1 -0
- package/dist/host-protocol.js +270 -0
- package/dist/host-protocol.js.map +1 -0
- package/dist/host-records-protocol.d.ts +15 -0
- package/dist/host-records-protocol.d.ts.map +1 -0
- package/dist/host-records-protocol.js +15 -0
- package/dist/host-records-protocol.js.map +1 -0
- package/dist/hosted-scan-protocol.d.ts +4 -0
- package/dist/hosted-scan-protocol.d.ts.map +1 -0
- package/dist/hosted-scan-protocol.js +25 -0
- package/dist/hosted-scan-protocol.js.map +1 -0
- package/dist/hosted-scan.d.ts +112 -0
- package/dist/hosted-scan.d.ts.map +1 -0
- package/dist/hosted-scan.js +260 -0
- package/dist/hosted-scan.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +87 -7
- package/dist/knowledge-base.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +108 -36
- package/dist/multiscan.js.map +1 -1
- package/dist/patch-publication.d.ts +26 -0
- package/dist/patch-publication.d.ts.map +1 -0
- package/dist/patch-publication.js +105 -0
- package/dist/patch-publication.js.map +1 -0
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +4 -1
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +2 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +16 -6
- package/dist/project-config.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +73 -63
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts +0 -2
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +135 -24
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +39 -25
- package/dist/publish.js.map +1 -1
- package/dist/runtime.d.ts +5 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +86 -58
- package/dist/runtime.js.map +1 -1
- package/dist/scan-executor.d.ts +104 -0
- package/dist/scan-executor.d.ts.map +1 -0
- package/dist/scan-executor.js +62 -0
- package/dist/scan-executor.js.map +1 -0
- package/dist/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +7 -1
- package/dist/scan-settings.js.map +1 -1
- package/dist/scan-time-budget.d.ts +9 -0
- package/dist/scan-time-budget.d.ts.map +1 -0
- package/dist/scan-time-budget.js +16 -0
- package/dist/scan-time-budget.js.map +1 -0
- package/dist/severity-review.d.ts +29 -0
- package/dist/severity-review.d.ts.map +1 -0
- package/dist/severity-review.js +47 -0
- package/dist/severity-review.js.map +1 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +17 -25
- package/dist/targets.js.map +1 -1
- package/dist/validation-records.d.ts +38 -0
- package/dist/validation-records.d.ts.map +1 -0
- package/dist/validation-records.js +76 -0
- package/dist/validation-records.js.map +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +4 -2
- package/dist/version.js.map +1 -1
- package/dist/worker-progress.d.ts +43 -15
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +22 -80
- package/dist/worker-progress.js.map +1 -1
- package/docs/classify-severity-records.md +89 -0
- package/docs/cli.md +281 -35
- package/docs/hosted-scans.md +242 -0
- package/docs/validate-records.md +69 -0
- package/package.json +18 -14
- package/schemas/hosted-scan-v2.fixture.json +145 -0
- package/schemas/project-config.schema.json +7 -1
- package/_bundled_plugin/preflight/capability-profiles.toml +0 -76
- package/_bundled_plugin/references/config-preflight.md +0 -93
- package/_bundled_plugin/references/desktop-config-preflight.md +0 -11
- package/_bundled_plugin/scripts/config_preflight.py +0 -911
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
2
|
+
import { Writable } from "node:stream";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
const rpcId = z.union([z.string(), z.number().int()]);
|
|
5
|
+
const envelope = z.strictObject({ jsonrpc: z.literal("2.0") });
|
|
6
|
+
const request = envelope.extend({
|
|
7
|
+
id: rpcId,
|
|
8
|
+
method: z.literal("run"),
|
|
9
|
+
params: z.unknown(),
|
|
10
|
+
});
|
|
11
|
+
const cancellation = envelope.extend({
|
|
12
|
+
method: z.literal("cancel"),
|
|
13
|
+
params: z.strictObject({ id: rpcId }),
|
|
14
|
+
});
|
|
15
|
+
const progress = envelope.extend({
|
|
16
|
+
method: z.literal("execution.progress"),
|
|
17
|
+
params: z.strictObject({ requestId: z.string(), event: z.unknown() }),
|
|
18
|
+
});
|
|
19
|
+
const response = z.union([
|
|
20
|
+
envelope.extend({ id: rpcId, result: z.unknown() }),
|
|
21
|
+
envelope.extend({
|
|
22
|
+
id: rpcId,
|
|
23
|
+
error: z.strictObject({
|
|
24
|
+
code: z.number().int(),
|
|
25
|
+
message: z.string(),
|
|
26
|
+
data: z.unknown().optional(),
|
|
27
|
+
}),
|
|
28
|
+
}),
|
|
29
|
+
]);
|
|
30
|
+
/** One bidirectional run, shared with dedupe. This transport never replays. */
|
|
31
|
+
export async function runHostProtocol(input, output, operation, signal) {
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
let runId;
|
|
34
|
+
let terminalCode;
|
|
35
|
+
let completed = false;
|
|
36
|
+
let pending;
|
|
37
|
+
const { promise: completion, resolve: resolveCompletion } = Promise.withResolvers();
|
|
38
|
+
const complete = (code) => {
|
|
39
|
+
if (completed)
|
|
40
|
+
return;
|
|
41
|
+
completed = true;
|
|
42
|
+
resolveCompletion(code);
|
|
43
|
+
};
|
|
44
|
+
const stopOutput = (code) => {
|
|
45
|
+
if (completed)
|
|
46
|
+
return;
|
|
47
|
+
complete(code);
|
|
48
|
+
if (output instanceof Writable) {
|
|
49
|
+
// Native stdout can emit close repeatedly when destroy() is called from
|
|
50
|
+
// its close listener. Detach before destroying, even before cleanup runs.
|
|
51
|
+
output.off("close", outputClosed);
|
|
52
|
+
output.destroy();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const lines = createInterface({
|
|
56
|
+
input,
|
|
57
|
+
crlfDelay: Infinity,
|
|
58
|
+
terminal: false,
|
|
59
|
+
});
|
|
60
|
+
const send = async (message, onFlushed) => {
|
|
61
|
+
const line = `${JSON.stringify(message)}\n`;
|
|
62
|
+
if (output instanceof Writable) {
|
|
63
|
+
if (output.destroyed)
|
|
64
|
+
throw new Error("Host output is closed.");
|
|
65
|
+
await new Promise((resolve, reject) => {
|
|
66
|
+
let settled = false;
|
|
67
|
+
const settle = (error) => {
|
|
68
|
+
if (settled)
|
|
69
|
+
return;
|
|
70
|
+
settled = true;
|
|
71
|
+
output.off("close", closed);
|
|
72
|
+
// Node can emit error/close before the rejected Promise is observed.
|
|
73
|
+
// Record the failed write now, so the selected result cannot win.
|
|
74
|
+
if (error)
|
|
75
|
+
outputError(error);
|
|
76
|
+
else
|
|
77
|
+
onFlushed?.();
|
|
78
|
+
error ? reject(error) : resolve();
|
|
79
|
+
};
|
|
80
|
+
const closed = () => settle(new Error("Host output closed during write."));
|
|
81
|
+
output.once("close", closed);
|
|
82
|
+
output.write(line, settle);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
output.write(line);
|
|
87
|
+
onFlushed?.();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const fail = (code, message, canWrite = true, data) => {
|
|
91
|
+
if (completed)
|
|
92
|
+
return;
|
|
93
|
+
if (terminalCode !== undefined) {
|
|
94
|
+
if (!canWrite)
|
|
95
|
+
stopOutput(2);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
terminalCode = 2;
|
|
99
|
+
controller.abort(new Error(message));
|
|
100
|
+
pending?.reject(new Error(message));
|
|
101
|
+
pending = undefined;
|
|
102
|
+
// A peer that stopped reading cannot receive an error. Unblock both the
|
|
103
|
+
// request write and completion instead of waiting for a write callback.
|
|
104
|
+
if (!canWrite ||
|
|
105
|
+
(output instanceof Writable &&
|
|
106
|
+
(output.writableLength > 0 || output.writableNeedDrain))) {
|
|
107
|
+
stopOutput(2);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
void send({
|
|
111
|
+
jsonrpc: "2.0",
|
|
112
|
+
id: runId ?? null,
|
|
113
|
+
error: { code, message, ...(data === undefined ? {} : { data }) },
|
|
114
|
+
})
|
|
115
|
+
.catch(() => undefined)
|
|
116
|
+
.then(() => complete(2));
|
|
117
|
+
};
|
|
118
|
+
const disconnected = () => {
|
|
119
|
+
// Stdin EOF does not close stdout. If a terminal response is already being
|
|
120
|
+
// written, its callback decides whether delivery succeeded.
|
|
121
|
+
if (terminalCode === undefined)
|
|
122
|
+
fail(-32000, "Host disconnected before the run completed.");
|
|
123
|
+
};
|
|
124
|
+
const inputError = (error) => fail(-32000, error.message);
|
|
125
|
+
const outputError = (error) => fail(-32000, error.message, false);
|
|
126
|
+
const outputClosed = () => outputError(new Error("Host output is closed."));
|
|
127
|
+
const interrupted = () => {
|
|
128
|
+
if (terminalCode !== undefined)
|
|
129
|
+
stopOutput(2);
|
|
130
|
+
else
|
|
131
|
+
fail(-32800, `${operation.label} canceled.`);
|
|
132
|
+
};
|
|
133
|
+
const canceled = () => {
|
|
134
|
+
if (!operation.awaitCancellationReceipt ||
|
|
135
|
+
terminalCode !== undefined ||
|
|
136
|
+
(output instanceof Writable &&
|
|
137
|
+
(output.writableLength > 0 || output.writableNeedDrain))) {
|
|
138
|
+
interrupted();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (controller.signal.aborted)
|
|
142
|
+
return;
|
|
143
|
+
controller.abort(new Error(`${operation.label} canceled.`));
|
|
144
|
+
if (pending)
|
|
145
|
+
void send({
|
|
146
|
+
jsonrpc: "2.0",
|
|
147
|
+
method: "execution.cancel",
|
|
148
|
+
params: { requestId: pending.id },
|
|
149
|
+
}).catch(outputError);
|
|
150
|
+
};
|
|
151
|
+
input.on("error", inputError);
|
|
152
|
+
input.on("close", disconnected);
|
|
153
|
+
if (output instanceof Writable)
|
|
154
|
+
output.on("close", outputClosed);
|
|
155
|
+
lines.on("close", disconnected);
|
|
156
|
+
lines.on("error", inputError);
|
|
157
|
+
output.on?.("error", outputError);
|
|
158
|
+
signal?.addEventListener("abort", interrupted, { once: true });
|
|
159
|
+
lines.on("line", (line) => {
|
|
160
|
+
let message;
|
|
161
|
+
try {
|
|
162
|
+
message = JSON.parse(line);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
fail(-32700, "Invalid JSON.");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const cancel = cancellation.safeParse(message);
|
|
169
|
+
if (cancel.success) {
|
|
170
|
+
if (runId === undefined || cancel.data.params.id !== runId)
|
|
171
|
+
fail(-32600, "Cancellation does not match the active run.");
|
|
172
|
+
else
|
|
173
|
+
canceled();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (terminalCode !== undefined)
|
|
177
|
+
return;
|
|
178
|
+
const run = request.safeParse(message);
|
|
179
|
+
if (run.success) {
|
|
180
|
+
if (runId !== undefined) {
|
|
181
|
+
fail(-32600, "Only one run request is allowed.");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
runId = run.data.id;
|
|
185
|
+
void operation
|
|
186
|
+
.run(run.data.params, (id, params, onProgress) => {
|
|
187
|
+
if (terminalCode !== undefined || controller.signal.aborted)
|
|
188
|
+
return Promise.reject(controller.signal.reason);
|
|
189
|
+
if (pending)
|
|
190
|
+
return Promise.reject(new Error("Execution is already pending."));
|
|
191
|
+
return new Promise((resolve, reject) => {
|
|
192
|
+
pending = { id, resolve, reject, onProgress };
|
|
193
|
+
void send({
|
|
194
|
+
jsonrpc: "2.0",
|
|
195
|
+
id,
|
|
196
|
+
method: operation.requestMethod,
|
|
197
|
+
params,
|
|
198
|
+
}).catch(outputError);
|
|
199
|
+
});
|
|
200
|
+
}, controller.signal, (event) => {
|
|
201
|
+
if (terminalCode === undefined)
|
|
202
|
+
void send({
|
|
203
|
+
jsonrpc: "2.0",
|
|
204
|
+
method: "scan.progress",
|
|
205
|
+
params: { id: runId, event },
|
|
206
|
+
}).catch(outputError);
|
|
207
|
+
})
|
|
208
|
+
.then(async (result) => {
|
|
209
|
+
if (terminalCode !== undefined)
|
|
210
|
+
return;
|
|
211
|
+
const code = result.status === "completed" ? 0 : 1;
|
|
212
|
+
terminalCode = code;
|
|
213
|
+
try {
|
|
214
|
+
await send({ jsonrpc: "2.0", id: runId, result }, () => complete(code));
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
complete(2);
|
|
218
|
+
}
|
|
219
|
+
}, (error) => fail(-32602, error instanceof Error
|
|
220
|
+
? error.message
|
|
221
|
+
: "Invalid run parameters.", true, operation.errorData?.(error)));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const event = progress.safeParse(message);
|
|
225
|
+
if (event.success &&
|
|
226
|
+
operation.awaitCancellationReceipt &&
|
|
227
|
+
pending &&
|
|
228
|
+
event.data.params.requestId === pending.id) {
|
|
229
|
+
// Optional progress must never interrupt execution, including bad events
|
|
230
|
+
// or host observer exceptions. Correlation still rejects stale messages.
|
|
231
|
+
try {
|
|
232
|
+
pending.onProgress?.(event.data.params.event);
|
|
233
|
+
}
|
|
234
|
+
catch { }
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const reply = response.safeParse(message);
|
|
238
|
+
if (!reply.success || !pending || reply.data.id !== pending.id) {
|
|
239
|
+
fail(-32600, `Malformed, unexpected, or mismatched ${operation.requestMethod === "review.run" ? "review" : "execution"} response.`);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const execution = pending;
|
|
243
|
+
pending = undefined;
|
|
244
|
+
if ("error" in reply.data)
|
|
245
|
+
execution.reject(new Error(reply.data.error.message));
|
|
246
|
+
else
|
|
247
|
+
execution.resolve(reply.data.result);
|
|
248
|
+
});
|
|
249
|
+
if (signal?.aborted)
|
|
250
|
+
interrupted();
|
|
251
|
+
if (input.readableEnded || input.destroyed)
|
|
252
|
+
disconnected();
|
|
253
|
+
try {
|
|
254
|
+
return await completion;
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
lines.removeAllListeners("line");
|
|
258
|
+
lines.removeListener("close", disconnected);
|
|
259
|
+
lines.removeListener("error", inputError);
|
|
260
|
+
lines.close();
|
|
261
|
+
input.pause();
|
|
262
|
+
input.removeListener("error", inputError);
|
|
263
|
+
input.removeListener("close", disconnected);
|
|
264
|
+
if (output instanceof Writable)
|
|
265
|
+
output.removeListener("close", outputClosed);
|
|
266
|
+
output.off?.("error", outputError);
|
|
267
|
+
signal?.removeEventListener("abort", interrupted);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=host-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-protocol.js","sourceRoot":"","sources":["../src/host-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACtD,MAAM,QAAQ,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC/D,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC9B,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACxB,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;CACpB,CAAC,CAAC;AACH,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC3B,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;CACtC,CA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,EAAE,UAAU,CAAC,CAAC;QAC1C,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC1C,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAC5C,IAAI,MAAM,YAAY,QAAQ;YAC5B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAC/C,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACpD,CAAC;AACH,CAAC","sourcesContent":["import { createInterface } from \"node:readline\";\nimport { type Readable, Writable } from \"node:stream\";\nimport { z } from \"zod\";\n\nconst rpcId = z.union([z.string(), z.number().int()]);\nconst envelope = z.strictObject({ jsonrpc: z.literal(\"2.0\") });\nconst request = envelope.extend({\n id: rpcId,\n method: z.literal(\"run\"),\n params: z.unknown(),\n});\nconst cancellation = envelope.extend({\n method: z.literal(\"cancel\"),\n params: z.strictObject({ id: rpcId }),\n});\nconst progress = envelope.extend({\n method: z.literal(\"execution.progress\"),\n params: z.strictObject({ requestId: z.string(), event: z.unknown() }),\n});\nconst response = z.union([\n envelope.extend({ id: rpcId, result: z.unknown() }),\n envelope.extend({\n id: rpcId,\n error: z.strictObject({\n code: z.number().int(),\n message: z.string(),\n data: z.unknown().optional(),\n }),\n }),\n]);\ntype Output = Pick<NodeJS.WriteStream, \"write\"> & {\n on?(event: \"error\", listener: (error: Error) => void): unknown;\n off?(event: \"error\", listener: (error: Error) => void): unknown;\n};\ntype Execute = (\n id: string,\n request: unknown,\n onProgress?: (event: unknown) => void,\n) => Promise<unknown>;\n\n/** One bidirectional run, shared with dedupe. This transport never replays. */\nexport async function runHostProtocol(\n input: Readable,\n output: Output,\n operation: {\n label: string;\n requestMethod: string;\n /** Scan cancellation must retain the host's eventual receipt and usage. */\n awaitCancellationReceipt?: boolean;\n errorData?: (error: unknown) => object | undefined;\n run(\n params: unknown,\n execute: Execute,\n signal: AbortSignal,\n onProgress: (event: unknown) => void,\n ): Promise<{ status: string }>;\n },\n signal?: AbortSignal,\n): Promise<number> {\n const controller = new AbortController();\n let runId: string | number | undefined;\n let terminalCode: number | undefined;\n let completed = false;\n let pending:\n | {\n id: string;\n resolve(value: unknown): void;\n reject(error: Error): void;\n onProgress?: (event: unknown) => void;\n }\n | undefined;\n const { promise: completion, resolve: resolveCompletion } =\n Promise.withResolvers<number>();\n const complete = (code: number) => {\n if (completed) return;\n completed = true;\n resolveCompletion(code);\n };\n const stopOutput = (code: number) => {\n if (completed) return;\n complete(code);\n if (output instanceof Writable) {\n // Native stdout can emit close repeatedly when destroy() is called from\n // its close listener. Detach before destroying, even before cleanup runs.\n output.off(\"close\", outputClosed);\n output.destroy();\n }\n };\n const lines = createInterface({\n input,\n crlfDelay: Infinity,\n terminal: false,\n });\n const send = async (message: object, onFlushed?: () => void) => {\n const line = `${JSON.stringify(message)}\\n`;\n if (output instanceof Writable) {\n if (output.destroyed) throw new Error(\"Host output is closed.\");\n await new Promise<void>((resolve, reject) => {\n let settled = false;\n const settle = (error?: Error | null) => {\n if (settled) return;\n settled = true;\n output.off(\"close\", closed);\n // Node can emit error/close before the rejected Promise is observed.\n // Record the failed write now, so the selected result cannot win.\n if (error) outputError(error);\n else onFlushed?.();\n error ? reject(error) : resolve();\n };\n const closed = () =>\n settle(new Error(\"Host output closed during write.\"));\n output.once(\"close\", closed);\n output.write(line, settle);\n });\n } else {\n output.write(line);\n onFlushed?.();\n }\n };\n const fail = (\n code: number,\n message: string,\n canWrite = true,\n data?: object,\n ) => {\n if (completed) return;\n if (terminalCode !== undefined) {\n if (!canWrite) stopOutput(2);\n return;\n }\n terminalCode = 2;\n controller.abort(new Error(message));\n pending?.reject(new Error(message));\n pending = undefined;\n // A peer that stopped reading cannot receive an error. Unblock both the\n // request write and completion instead of waiting for a write callback.\n if (\n !canWrite ||\n (output instanceof Writable &&\n (output.writableLength > 0 || output.writableNeedDrain))\n ) {\n stopOutput(2);\n return;\n }\n void send({\n jsonrpc: \"2.0\",\n id: runId ?? null,\n error: { code, message, ...(data === undefined ? {} : { data }) },\n })\n .catch(() => undefined)\n .then(() => complete(2));\n };\n const disconnected = () => {\n // Stdin EOF does not close stdout. If a terminal response is already being\n // written, its callback decides whether delivery succeeded.\n if (terminalCode === undefined)\n fail(-32000, \"Host disconnected before the run completed.\");\n };\n const inputError = (error: Error) => fail(-32000, error.message);\n const outputError = (error: Error) => fail(-32000, error.message, false);\n const outputClosed = () => outputError(new Error(\"Host output is closed.\"));\n const interrupted = () => {\n if (terminalCode !== undefined) stopOutput(2);\n else fail(-32800, `${operation.label} canceled.`);\n };\n const canceled = () => {\n if (\n !operation.awaitCancellationReceipt ||\n terminalCode !== undefined ||\n (output instanceof Writable &&\n (output.writableLength > 0 || output.writableNeedDrain))\n ) {\n interrupted();\n return;\n }\n if (controller.signal.aborted) return;\n controller.abort(new Error(`${operation.label} canceled.`));\n if (pending)\n void send({\n jsonrpc: \"2.0\",\n method: \"execution.cancel\",\n params: { requestId: pending.id },\n }).catch(outputError);\n };\n input.on(\"error\", inputError);\n input.on(\"close\", disconnected);\n if (output instanceof Writable) output.on(\"close\", outputClosed);\n lines.on(\"close\", disconnected);\n lines.on(\"error\", inputError);\n output.on?.(\"error\", outputError);\n signal?.addEventListener(\"abort\", interrupted, { once: true });\n lines.on(\"line\", (line) => {\n let message: unknown;\n try {\n message = JSON.parse(line);\n } catch {\n fail(-32700, \"Invalid JSON.\");\n return;\n }\n const cancel = cancellation.safeParse(message);\n if (cancel.success) {\n if (runId === undefined || cancel.data.params.id !== runId)\n fail(-32600, \"Cancellation does not match the active run.\");\n else canceled();\n return;\n }\n if (terminalCode !== undefined) return;\n const run = request.safeParse(message);\n if (run.success) {\n if (runId !== undefined) {\n fail(-32600, \"Only one run request is allowed.\");\n return;\n }\n runId = run.data.id;\n void operation\n .run(\n run.data.params,\n (id, params, onProgress) => {\n if (terminalCode !== undefined || controller.signal.aborted)\n return Promise.reject(controller.signal.reason);\n if (pending)\n return Promise.reject(new Error(\"Execution is already pending.\"));\n return new Promise((resolve, reject) => {\n pending = { id, resolve, reject, onProgress };\n void send({\n jsonrpc: \"2.0\",\n id,\n method: operation.requestMethod,\n params,\n }).catch(outputError);\n });\n },\n controller.signal,\n (event) => {\n if (terminalCode === undefined)\n void send({\n jsonrpc: \"2.0\",\n method: \"scan.progress\",\n params: { id: runId, event },\n }).catch(outputError);\n },\n )\n .then(\n async (result) => {\n if (terminalCode !== undefined) return;\n const code = result.status === \"completed\" ? 0 : 1;\n terminalCode = code;\n try {\n await send({ jsonrpc: \"2.0\", id: runId, result }, () =>\n complete(code),\n );\n } catch {\n complete(2);\n }\n },\n (error: unknown) =>\n fail(\n -32602,\n error instanceof Error\n ? error.message\n : \"Invalid run parameters.\",\n true,\n operation.errorData?.(error),\n ),\n );\n return;\n }\n const event = progress.safeParse(message);\n if (\n event.success &&\n operation.awaitCancellationReceipt &&\n pending &&\n event.data.params.requestId === pending.id\n ) {\n // Optional progress must never interrupt execution, including bad events\n // or host observer exceptions. Correlation still rejects stale messages.\n try {\n pending.onProgress?.(event.data.params.event);\n } catch {}\n return;\n }\n const reply = response.safeParse(message);\n if (!reply.success || !pending || reply.data.id !== pending.id) {\n fail(\n -32600,\n `Malformed, unexpected, or mismatched ${operation.requestMethod === \"review.run\" ? \"review\" : \"execution\"} response.`,\n );\n return;\n }\n const execution = pending;\n pending = undefined;\n if (\"error\" in reply.data)\n execution.reject(new Error(reply.data.error.message));\n else execution.resolve(reply.data.result);\n });\n if (signal?.aborted) interrupted();\n if (input.readableEnded || input.destroyed) disconnected();\n try {\n return await completion;\n } finally {\n lines.removeAllListeners(\"line\");\n lines.removeListener(\"close\", disconnected);\n lines.removeListener(\"error\", inputError);\n lines.close();\n input.pause();\n input.removeListener(\"error\", inputError);\n input.removeListener(\"close\", disconnected);\n if (output instanceof Writable)\n output.removeListener(\"close\", outputClosed);\n output.off?.(\"error\", outputError);\n signal?.removeEventListener(\"abort\", interrupted);\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
import { runHostProtocol } from "./host-protocol.js";
|
|
3
|
+
export type RecordsProtocolOutput = Parameters<typeof runHostProtocol>[1];
|
|
4
|
+
/** Adapt record reviews to the shared host transport without replaying work. */
|
|
5
|
+
export declare function runHostRecordsProtocol<Review extends {
|
|
6
|
+
requestId: string;
|
|
7
|
+
}, Result extends {
|
|
8
|
+
status: "completed" | "unresolved";
|
|
9
|
+
}>(input: Readable, output: RecordsProtocolOutput, run: (input: unknown, options: {
|
|
10
|
+
signal: AbortSignal;
|
|
11
|
+
reviewRunner: {
|
|
12
|
+
run(review: Review): Promise<unknown>;
|
|
13
|
+
};
|
|
14
|
+
}) => Promise<Result>, signal?: AbortSignal): Promise<number>;
|
|
15
|
+
//# sourceMappingURL=host-records-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-records-protocol.d.ts","sourceRoot":"","sources":["../src/host-records-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1E,gFAAgF;AAChF,wBAAgB,sBAAsB,CACpC,MAAM,SAAS;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EACpC,MAAM,SAAS;IAAE,MAAM,EAAE,WAAW,GAAG,YAAY,CAAA;CAAE,EAErD,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,qBAAqB,EAC7B,GAAG,EAAE,CACH,KAAK,EAAE,OAAO,EACd,OAAO,EAAE;IACP,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE;QAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;CACzD,KACE,OAAO,CAAC,MAAM,CAAC,EACpB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,CAiBjB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { runHostProtocol } from "./host-protocol.js";
|
|
2
|
+
/** Adapt record reviews to the shared host transport without replaying work. */
|
|
3
|
+
export function runHostRecordsProtocol(input, output, run, signal) {
|
|
4
|
+
return runHostProtocol(input, output, {
|
|
5
|
+
label: "Records processing",
|
|
6
|
+
requestMethod: "review.run",
|
|
7
|
+
run: (params, execute, signal) => run(params, {
|
|
8
|
+
signal,
|
|
9
|
+
reviewRunner: {
|
|
10
|
+
run: (review) => execute(review.requestId, review),
|
|
11
|
+
},
|
|
12
|
+
}),
|
|
13
|
+
}, signal);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=host-records-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-records-protocol.js","sourceRoot":"","sources":["../src/host-records-protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD,gFAAgF;AAChF,MAAM,UAAU,sBAAsB,CAIpC,KAAe,EACf,MAA6B,EAC7B,GAMoB,EACpB,MAAoB;IAEpB,OAAO,eAAe,CACpB,KAAK,EACL,MAAM,EACN;QACE,KAAK,EAAE,oBAAoB;QAC3B,aAAa,EAAE,YAAY;QAC3B,GAAG,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAC/B,GAAG,CAAC,MAAM,EAAE;YACV,MAAM;YACN,YAAY,EAAE;gBACZ,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC;aACnD;SACF,CAAC;KACL,EACD,MAAM,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { Readable } from \"node:stream\";\nimport { runHostProtocol } from \"./host-protocol.js\";\n\nexport type RecordsProtocolOutput = Parameters<typeof runHostProtocol>[1];\n\n/** Adapt record reviews to the shared host transport without replaying work. */\nexport function runHostRecordsProtocol<\n Review extends { requestId: string },\n Result extends { status: \"completed\" | \"unresolved\" },\n>(\n input: Readable,\n output: RecordsProtocolOutput,\n run: (\n input: unknown,\n options: {\n signal: AbortSignal;\n reviewRunner: { run(review: Review): Promise<unknown> };\n },\n ) => Promise<Result>,\n signal?: AbortSignal,\n): Promise<number> {\n return runHostProtocol(\n input,\n output,\n {\n label: \"Records processing\",\n requestMethod: \"review.run\",\n run: (params, execute, signal) =>\n run(params, {\n signal,\n reviewRunner: {\n run: (review) => execute(review.requestId, review),\n },\n }),\n },\n signal,\n );\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
import { runHostProtocol } from "./host-protocol.js";
|
|
3
|
+
export declare function runHostedScanProtocol(input: Readable, output: Parameters<typeof runHostProtocol>[1], signal?: AbortSignal): Promise<number>;
|
|
4
|
+
//# sourceMappingURL=hosted-scan-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-scan-protocol.d.ts","sourceRoot":"","sources":["../src/hosted-scan-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAWrD,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,EAC7C,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,CA6BjB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { runHostProtocol } from "./host-protocol.js";
|
|
2
|
+
import { HostedScanPreparationError, runHostedScan, } from "./hosted-scan.js";
|
|
3
|
+
import { ScanExecutionEventSchema, ScanExecutionResultSchema, } from "./scan-executor.js";
|
|
4
|
+
export async function runHostedScanProtocol(input, output, signal) {
|
|
5
|
+
return await runHostProtocol(input, output, {
|
|
6
|
+
label: "Scan",
|
|
7
|
+
requestMethod: "execution.run",
|
|
8
|
+
awaitCancellationReceipt: true,
|
|
9
|
+
errorData: (error) => error instanceof HostedScanPreparationError
|
|
10
|
+
? { reason: error.reason }
|
|
11
|
+
: undefined,
|
|
12
|
+
run: async (params, execute, signal, onEvent) => await runHostedScan(params, {
|
|
13
|
+
signal,
|
|
14
|
+
onEvent,
|
|
15
|
+
executor: {
|
|
16
|
+
run: async (request, options) => ScanExecutionResultSchema.parse(await execute(request.requestId, request, (event) => {
|
|
17
|
+
const parsed = ScanExecutionEventSchema.safeParse(event);
|
|
18
|
+
if (parsed.success)
|
|
19
|
+
options.onEvent?.(parsed.data);
|
|
20
|
+
})),
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
}, signal);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=hosted-scan-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-scan-protocol.js","sourceRoot":"","sources":["../src/hosted-scan-protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAEL,0BAA0B,EAC1B,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAAe,EACf,MAA6C,EAC7C,MAAoB;IAEpB,OAAO,MAAM,eAAe,CAC1B,KAAK,EACL,MAAM,EACN;QACE,KAAK,EAAE,MAAM;QACb,aAAa,EAAE,eAAe;QAC9B,wBAAwB,EAAE,IAAI;QAC9B,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CACnB,KAAK,YAAY,0BAA0B;YACzC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;YAC1B,CAAC,CAAC,SAAS;QACf,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAC9C,MAAM,aAAa,CAAC,MAAyB,EAAE;YAC7C,MAAM;YACN,OAAO;YACP,QAAQ,EAAE;gBACR,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAC9B,yBAAyB,CAAC,KAAK,CAC7B,MAAM,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;oBAClD,MAAM,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;oBACzD,IAAI,MAAM,CAAC,OAAO;wBAAE,OAAO,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACrD,CAAC,CAAC,CACH;aACJ;SACF,CAAC;KACL,EACD,MAAM,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { Readable } from \"node:stream\";\nimport { runHostProtocol } from \"./host-protocol.js\";\nimport {\n type HostedScanInput,\n HostedScanPreparationError,\n runHostedScan,\n} from \"./hosted-scan.js\";\nimport {\n ScanExecutionEventSchema,\n ScanExecutionResultSchema,\n} from \"./scan-executor.js\";\n\nexport async function runHostedScanProtocol(\n input: Readable,\n output: Parameters<typeof runHostProtocol>[1],\n signal?: AbortSignal,\n): Promise<number> {\n return await runHostProtocol(\n input,\n output,\n {\n label: \"Scan\",\n requestMethod: \"execution.run\",\n awaitCancellationReceipt: true,\n errorData: (error) =>\n error instanceof HostedScanPreparationError\n ? { reason: error.reason }\n : undefined,\n run: async (params, execute, signal, onEvent) =>\n await runHostedScan(params as HostedScanInput, {\n signal,\n onEvent,\n executor: {\n run: async (request, options) =>\n ScanExecutionResultSchema.parse(\n await execute(request.requestId, request, (event) => {\n const parsed = ScanExecutionEventSchema.safeParse(event);\n if (parsed.success) options.onEvent?.(parsed.data);\n }),\n ),\n },\n }),\n },\n signal,\n );\n}\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { type ScanExecutor, type ScanExecutionEvent } from "./scan-executor.js";
|
|
2
|
+
export type { ScanExecutor, ScanExecutionRequest } from "./scan-executor.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
/** Hosted v2 mirrors repository/paths targets; only Standard scans are supported. */
|
|
5
|
+
export declare const HostedScanInputSchema: z.ZodObject<{
|
|
6
|
+
version: z.ZodLiteral<2>;
|
|
7
|
+
repository: z.ZodString;
|
|
8
|
+
revision: z.ZodString;
|
|
9
|
+
scope: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
paths: z.ZodArray<z.ZodString>;
|
|
11
|
+
}, z.core.$strict>>;
|
|
12
|
+
outputDirectory: z.ZodString;
|
|
13
|
+
stateDirectory: z.ZodString;
|
|
14
|
+
model: z.ZodString;
|
|
15
|
+
reasoningEffort: z.ZodString;
|
|
16
|
+
identity: z.ZodObject<{
|
|
17
|
+
runId: z.ZodString;
|
|
18
|
+
attemptId: z.ZodString;
|
|
19
|
+
buildId: z.ZodString;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
export type HostedScanInput = z.infer<typeof HostedScanInputSchema>;
|
|
23
|
+
export declare class HostedScanPreparationError extends Error {
|
|
24
|
+
readonly reason: "scope_syntax" | "scope_missing" | "scope_outside_repository" | "scope_alias" | "revision_mismatch";
|
|
25
|
+
constructor(reason: "scope_syntax" | "scope_missing" | "scope_outside_repository" | "scope_alias" | "revision_mismatch", message: string);
|
|
26
|
+
}
|
|
27
|
+
export declare function normalizeHostedScope(path: string): string;
|
|
28
|
+
export declare function normalizeHostedPaths(paths?: readonly string[]): string[];
|
|
29
|
+
export interface HostedScanOptions {
|
|
30
|
+
executor: ScanExecutor;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
onEvent?: (event: ScanExecutionEvent) => void;
|
|
33
|
+
}
|
|
34
|
+
/** One invocation, with only scan-domain state. The host decides retry/reconciliation. */
|
|
35
|
+
export declare function runHostedScan(value: HostedScanInput, options: HostedScanOptions): Promise<{
|
|
36
|
+
repository: string;
|
|
37
|
+
revision: string;
|
|
38
|
+
scope: {
|
|
39
|
+
paths: string[];
|
|
40
|
+
};
|
|
41
|
+
identity: {
|
|
42
|
+
runId: string;
|
|
43
|
+
attemptId: string;
|
|
44
|
+
buildId: string;
|
|
45
|
+
};
|
|
46
|
+
version: 2;
|
|
47
|
+
outputDirectory: string;
|
|
48
|
+
scanId?: string | undefined;
|
|
49
|
+
pluginVersion?: string | undefined;
|
|
50
|
+
provenance: {
|
|
51
|
+
cliVersion: string;
|
|
52
|
+
buildId: string;
|
|
53
|
+
pluginVersion?: string | undefined;
|
|
54
|
+
};
|
|
55
|
+
execution?: {
|
|
56
|
+
requestId: string;
|
|
57
|
+
status: "acceptance_unknown" | "canceled" | "completed" | "failed";
|
|
58
|
+
sessionId?: string | undefined;
|
|
59
|
+
finalResponse?: string | undefined;
|
|
60
|
+
usage?: unknown;
|
|
61
|
+
message?: string | undefined;
|
|
62
|
+
error?: {
|
|
63
|
+
code: number;
|
|
64
|
+
message: string;
|
|
65
|
+
data?: unknown;
|
|
66
|
+
} | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
status: "completed";
|
|
69
|
+
artifacts: {
|
|
70
|
+
path: string;
|
|
71
|
+
sha256: string;
|
|
72
|
+
bytes: number;
|
|
73
|
+
}[];
|
|
74
|
+
} | {
|
|
75
|
+
repository: string;
|
|
76
|
+
revision: string;
|
|
77
|
+
scope: {
|
|
78
|
+
paths: string[];
|
|
79
|
+
};
|
|
80
|
+
identity: {
|
|
81
|
+
runId: string;
|
|
82
|
+
attemptId: string;
|
|
83
|
+
buildId: string;
|
|
84
|
+
};
|
|
85
|
+
version: 2;
|
|
86
|
+
outputDirectory: string;
|
|
87
|
+
scanId?: string | undefined;
|
|
88
|
+
pluginVersion?: string | undefined;
|
|
89
|
+
provenance: {
|
|
90
|
+
cliVersion: string;
|
|
91
|
+
buildId: string;
|
|
92
|
+
pluginVersion?: string | undefined;
|
|
93
|
+
};
|
|
94
|
+
execution?: {
|
|
95
|
+
requestId: string;
|
|
96
|
+
status: "acceptance_unknown" | "canceled" | "completed" | "failed";
|
|
97
|
+
sessionId?: string | undefined;
|
|
98
|
+
finalResponse?: string | undefined;
|
|
99
|
+
usage?: unknown;
|
|
100
|
+
message?: string | undefined;
|
|
101
|
+
error?: {
|
|
102
|
+
code: number;
|
|
103
|
+
message: string;
|
|
104
|
+
data?: unknown;
|
|
105
|
+
} | undefined;
|
|
106
|
+
} | undefined;
|
|
107
|
+
status: "acceptance_unknown" | "canceled" | "failed";
|
|
108
|
+
error: string;
|
|
109
|
+
artifacts: never[];
|
|
110
|
+
}>;
|
|
111
|
+
export type HostedScanResult = Awaited<ReturnType<typeof runHostedScan>>;
|
|
112
|
+
//# sourceMappingURL=hosted-scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-scan.d.ts","sourceRoot":"","sources":["../src/hosted-scan.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,qFAAqF;AACrF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;kBAgBhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAA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