@openai/codex-security 0.1.29 → 0.1.31

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 (69) hide show
  1. package/README.md +106 -5
  2. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  3. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  4. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  5. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  6. package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +19 -4
  7. package/_bundled_plugin/scripts/rank_preview.py +1 -0
  8. package/dist/auth.js +1 -1
  9. package/dist/auth.js.map +1 -1
  10. package/dist/cli.d.ts +4 -0
  11. package/dist/cli.d.ts.map +1 -1
  12. package/dist/cli.js +108 -8
  13. package/dist/cli.js.map +1 -1
  14. package/dist/deduplication/codex-review.d.ts +2 -7
  15. package/dist/deduplication/codex-review.d.ts.map +1 -1
  16. package/dist/deduplication/codex-review.js.map +1 -1
  17. package/dist/deduplication/deduplication-prompts.d.ts +2 -0
  18. package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
  19. package/dist/deduplication/deduplication-prompts.js +2 -2
  20. package/dist/deduplication/deduplication-prompts.js.map +1 -1
  21. package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
  22. package/dist/deduplication/deduplication-reviewer.js +4 -10
  23. package/dist/deduplication/deduplication-reviewer.js.map +1 -1
  24. package/dist/deduplication/finding-schema.d.ts +4 -0
  25. package/dist/deduplication/finding-schema.d.ts.map +1 -0
  26. package/dist/deduplication/finding-schema.js +14 -0
  27. package/dist/deduplication/finding-schema.js.map +1 -0
  28. package/dist/deduplication/records-protocol.d.ts +9 -0
  29. package/dist/deduplication/records-protocol.d.ts.map +1 -0
  30. package/dist/deduplication/records-protocol.js +191 -0
  31. package/dist/deduplication/records-protocol.js.map +1 -0
  32. package/dist/deduplication/records.d.ts +33 -0
  33. package/dist/deduplication/records.d.ts.map +1 -0
  34. package/dist/deduplication/records.js +134 -0
  35. package/dist/deduplication/records.js.map +1 -0
  36. package/dist/deduplication/review.d.ts +21 -0
  37. package/dist/deduplication/review.d.ts.map +1 -0
  38. package/dist/deduplication/review.js +2 -0
  39. package/dist/deduplication/review.js.map +1 -0
  40. package/dist/index.d.ts +5 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +2 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/knowledge-base.js +5 -1
  45. package/dist/knowledge-base.js.map +1 -1
  46. package/dist/owner-evidence.d.ts +29 -0
  47. package/dist/owner-evidence.d.ts.map +1 -0
  48. package/dist/owner-evidence.js +196 -0
  49. package/dist/owner-evidence.js.map +1 -0
  50. package/dist/runtime.d.ts.map +1 -1
  51. package/dist/runtime.js +27 -14
  52. package/dist/runtime.js.map +1 -1
  53. package/dist/scan-comparison.d.ts +1 -1
  54. package/dist/scan-comparison.d.ts.map +1 -1
  55. package/dist/scan-comparison.js.map +1 -1
  56. package/dist/suggest-owners.d.ts +38 -0
  57. package/dist/suggest-owners.d.ts.map +1 -0
  58. package/dist/suggest-owners.js +112 -0
  59. package/dist/suggest-owners.js.map +1 -0
  60. package/dist/targets.d.ts +6 -2
  61. package/dist/targets.d.ts.map +1 -1
  62. package/dist/targets.js +5 -4
  63. package/dist/targets.js.map +1 -1
  64. package/dist/thread-source.d.ts +1 -0
  65. package/dist/thread-source.d.ts.map +1 -1
  66. package/dist/thread-source.js +1 -0
  67. package/dist/thread-source.js.map +1 -1
  68. package/docs/dedupe-records.md +305 -0
  69. package/package.json +13 -11
@@ -0,0 +1,191 @@
1
+ import { createInterface } from "node:readline";
2
+ import { Writable } from "node:stream";
3
+ import { z } from "incur";
4
+ import { deduplicateRecords } from "./records.js";
5
+ const rpcId = z.union([z.string(), z.number().int()]);
6
+ const request = z
7
+ .object({
8
+ jsonrpc: z.literal("2.0"),
9
+ id: rpcId,
10
+ method: z.literal("run"),
11
+ params: z.unknown(),
12
+ })
13
+ .strict();
14
+ const cancellation = z
15
+ .object({
16
+ jsonrpc: z.literal("2.0"),
17
+ method: z.literal("cancel"),
18
+ params: z.object({ id: rpcId }).strict(),
19
+ })
20
+ .strict();
21
+ const response = z.union([
22
+ z
23
+ .object({ jsonrpc: z.literal("2.0"), id: rpcId, result: z.unknown() })
24
+ .strict()
25
+ .refine((value) => Object.hasOwn(value, "result")),
26
+ z
27
+ .object({
28
+ jsonrpc: z.literal("2.0"),
29
+ id: rpcId,
30
+ error: z
31
+ .object({
32
+ code: z.number().int(),
33
+ message: z.string(),
34
+ data: z.unknown().optional(),
35
+ })
36
+ .strict(),
37
+ })
38
+ .strict(),
39
+ ]);
40
+ /** One bidirectional run. Stdout contains JSON-RPC envelopes only. */
41
+ export async function runRecordsProtocol(input, output, signal) {
42
+ const controller = new AbortController();
43
+ let runId;
44
+ let finished = false;
45
+ let pending;
46
+ let complete;
47
+ const completion = new Promise((resolve) => {
48
+ complete = resolve;
49
+ });
50
+ const lines = createInterface({
51
+ input,
52
+ crlfDelay: Infinity,
53
+ terminal: false,
54
+ });
55
+ const send = async (message) => {
56
+ const line = `${JSON.stringify(message)}\n`;
57
+ if (output instanceof Writable) {
58
+ await new Promise((resolve, reject) => output.write(line, (error) => (error ? reject(error) : resolve())));
59
+ }
60
+ else {
61
+ output.write(line);
62
+ }
63
+ };
64
+ const fail = (code, message, canWrite = true) => {
65
+ if (finished)
66
+ return;
67
+ // Stop scheduling before notifying the host; a disconnect cannot become uniqueness.
68
+ finished = true;
69
+ controller.abort(new Error(message));
70
+ pending?.reject(new Error(message));
71
+ pending = undefined;
72
+ const flushed = canWrite
73
+ ? send({ jsonrpc: "2.0", id: runId ?? null, error: { code, message } })
74
+ : Promise.resolve();
75
+ void flushed.catch(() => undefined).then(() => complete(2));
76
+ };
77
+ const disconnected = () => fail(-32000, "Host disconnected before the run completed.");
78
+ const inputError = (error) => fail(-32000, error.message);
79
+ const outputError = (error) => fail(-32000, error.message, false);
80
+ const canceled = () => {
81
+ if (finished) {
82
+ // A terminal response may be blocked on a host that stopped reading.
83
+ if (output instanceof Writable)
84
+ output.destroy();
85
+ complete(2);
86
+ }
87
+ else {
88
+ fail(-32800, "Deduplication canceled.");
89
+ }
90
+ };
91
+ input.on("error", inputError);
92
+ input.on("close", disconnected);
93
+ if (output instanceof Writable)
94
+ output.on("close", disconnected);
95
+ lines.on("close", disconnected);
96
+ lines.on("error", inputError);
97
+ output.on?.("error", outputError);
98
+ signal?.addEventListener("abort", canceled, { once: true });
99
+ lines.on("line", (line) => {
100
+ let message;
101
+ try {
102
+ message = JSON.parse(line);
103
+ }
104
+ catch {
105
+ fail(-32700, "Invalid JSON.");
106
+ return;
107
+ }
108
+ const cancel = cancellation.safeParse(message);
109
+ if (cancel.success) {
110
+ if (runId === undefined || cancel.data.params.id !== runId)
111
+ fail(-32600, "Cancellation does not match the active run.");
112
+ else
113
+ canceled();
114
+ return;
115
+ }
116
+ if (finished)
117
+ return;
118
+ const run = request.safeParse(message);
119
+ if (run.success) {
120
+ if (runId !== undefined) {
121
+ fail(-32600, "Only one run request is allowed.");
122
+ return;
123
+ }
124
+ runId = run.data.id;
125
+ void deduplicateRecords(run.data.params, {
126
+ signal: controller.signal,
127
+ reviewRunner: {
128
+ run(review) {
129
+ if (finished)
130
+ return Promise.reject(controller.signal.reason);
131
+ return new Promise((resolve, reject) => {
132
+ pending = { id: review.requestId, resolve, reject };
133
+ void send({
134
+ jsonrpc: "2.0",
135
+ id: review.requestId,
136
+ method: "review.run",
137
+ params: review,
138
+ }).catch(outputError);
139
+ });
140
+ },
141
+ },
142
+ }).then(async (result) => {
143
+ if (finished)
144
+ return;
145
+ finished = true;
146
+ try {
147
+ await send({ jsonrpc: "2.0", id: runId, result });
148
+ complete(result.status === "completed" ? 0 : 1);
149
+ }
150
+ catch {
151
+ complete(2);
152
+ }
153
+ }, (error) => {
154
+ fail(-32602, error instanceof Error ? error.message : "Invalid run parameters.");
155
+ });
156
+ return;
157
+ }
158
+ const reply = response.safeParse(message);
159
+ if (!reply.success || !pending || reply.data.id !== pending.id) {
160
+ fail(-32600, "Malformed, unexpected, or mismatched review response.");
161
+ return;
162
+ }
163
+ const review = pending;
164
+ pending = undefined;
165
+ if ("error" in reply.data)
166
+ review.reject(new Error(reply.data.error.message));
167
+ else
168
+ review.resolve(reply.data.result);
169
+ });
170
+ if (signal?.aborted)
171
+ canceled();
172
+ if (input.readableEnded || input.destroyed)
173
+ disconnected();
174
+ try {
175
+ return await completion;
176
+ }
177
+ finally {
178
+ lines.removeAllListeners("line");
179
+ lines.removeListener("close", disconnected);
180
+ lines.removeListener("error", inputError);
181
+ lines.close();
182
+ input.pause();
183
+ input.removeListener("error", inputError);
184
+ input.removeListener("close", disconnected);
185
+ if (output instanceof Writable)
186
+ output.removeListener("close", disconnected);
187
+ output.off?.("error", outputError);
188
+ signal?.removeEventListener("abort", canceled);
189
+ }
190
+ }
191
+ //# sourceMappingURL=records-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records-protocol.js","sourceRoot":"","sources":["../../src/deduplication/records-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,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAgC,MAAM,cAAc,CAAC;AAEhF,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,OAAO,GAAG,CAAC;KACd,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACzB,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACxB,MAAM,EAA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AC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;AACH,CAAC","sourcesContent":["import { createInterface } from \"node:readline\";\nimport { type Readable, Writable } from \"node:stream\";\nimport { z } from \"incur\";\nimport { deduplicateRecords, type DeduplicateRecordsInput } from \"./records.js\";\n\nconst rpcId = z.union([z.string(), z.number().int()]);\nconst request = z\n .object({\n jsonrpc: z.literal(\"2.0\"),\n id: rpcId,\n method: z.literal(\"run\"),\n params: z.unknown(),\n })\n .strict();\nconst cancellation = z\n .object({\n jsonrpc: z.literal(\"2.0\"),\n method: z.literal(\"cancel\"),\n params: z.object({ id: rpcId }).strict(),\n })\n .strict();\nconst response = z.union([\n z\n .object({ jsonrpc: z.literal(\"2.0\"), id: rpcId, result: z.unknown() })\n .strict()\n .refine((value) => Object.hasOwn(value, \"result\")),\n z\n .object({\n jsonrpc: z.literal(\"2.0\"),\n id: rpcId,\n error: z\n .object({\n code: z.number().int(),\n message: z.string(),\n data: z.unknown().optional(),\n })\n .strict(),\n })\n .strict(),\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};\n\n/** One bidirectional run. Stdout contains JSON-RPC envelopes only. */\nexport async function runRecordsProtocol(\n input: Readable,\n output: Output,\n signal?: AbortSignal,\n): Promise<number> {\n const controller = new AbortController();\n let runId: string | number | undefined;\n let finished = false;\n let pending:\n | { id: string; resolve(value: unknown): void; reject(error: Error): void }\n | undefined;\n let complete!: (code: number) => void;\n const completion = new Promise<number>((resolve) => {\n complete = resolve;\n });\n const lines = createInterface({\n input,\n crlfDelay: Infinity,\n terminal: false,\n });\n const send = async (message: object) => {\n const line = `${JSON.stringify(message)}\\n`;\n if (output instanceof Writable) {\n await new Promise<void>((resolve, reject) =>\n output.write(line, (error) => (error ? reject(error) : resolve())),\n );\n } else {\n output.write(line);\n }\n };\n const fail = (code: number, message: string, canWrite = true) => {\n if (finished) return;\n // Stop scheduling before notifying the host; a disconnect cannot become uniqueness.\n finished = true;\n controller.abort(new Error(message));\n pending?.reject(new Error(message));\n pending = undefined;\n const flushed = canWrite\n ? send({ jsonrpc: \"2.0\", id: runId ?? null, error: { code, message } })\n : Promise.resolve();\n void flushed.catch(() => undefined).then(() => complete(2));\n };\n const disconnected = () =>\n fail(-32000, \"Host disconnected before the run completed.\");\n const inputError = (error: Error) => fail(-32000, error.message);\n const outputError = (error: Error) => fail(-32000, error.message, false);\n const canceled = () => {\n if (finished) {\n // A terminal response may be blocked on a host that stopped reading.\n if (output instanceof Writable) output.destroy();\n complete(2);\n } else {\n fail(-32800, \"Deduplication canceled.\");\n }\n };\n input.on(\"error\", inputError);\n input.on(\"close\", disconnected);\n if (output instanceof Writable) output.on(\"close\", disconnected);\n lines.on(\"close\", disconnected);\n lines.on(\"error\", inputError);\n output.on?.(\"error\", outputError);\n signal?.addEventListener(\"abort\", canceled, { 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 (finished) 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 deduplicateRecords(run.data.params as DeduplicateRecordsInput, {\n signal: controller.signal,\n reviewRunner: {\n run(review) {\n if (finished) return Promise.reject(controller.signal.reason);\n return new Promise((resolve, reject) => {\n pending = { id: review.requestId, resolve, reject };\n void send({\n jsonrpc: \"2.0\",\n id: review.requestId,\n method: \"review.run\",\n params: review,\n }).catch(outputError);\n });\n },\n },\n }).then(\n async (result) => {\n if (finished) return;\n finished = true;\n try {\n await send({ jsonrpc: \"2.0\", id: runId, result });\n complete(result.status === \"completed\" ? 0 : 1);\n } catch {\n complete(2);\n }\n },\n (error: unknown) => {\n fail(\n -32602,\n error instanceof Error ? error.message : \"Invalid run parameters.\",\n );\n },\n );\n return;\n }\n const reply = response.safeParse(message);\n if (!reply.success || !pending || reply.data.id !== pending.id) {\n fail(-32600, \"Malformed, unexpected, or mismatched review response.\");\n return;\n }\n const review = pending;\n pending = undefined;\n if (\"error\" in reply.data)\n review.reject(new Error(reply.data.error.message));\n else review.resolve(reply.data.result);\n });\n if (signal?.aborted) canceled();\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\", disconnected);\n output.off?.(\"error\", outputError);\n signal?.removeEventListener(\"abort\", canceled);\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import type { Finding } from "../models.js";
2
+ import type { DeduplicationReviewRunner } from "./review.js";
3
+ export interface DeduplicateRecordsInput {
4
+ version: 1;
5
+ observations: {
6
+ id: string;
7
+ finding: Finding;
8
+ }[];
9
+ candidateRelationships: {
10
+ observationId: string;
11
+ candidateObservationIds: string[];
12
+ }[];
13
+ }
14
+ export interface DeduplicateRecordsOptions {
15
+ reviewRunner: DeduplicationReviewRunner;
16
+ signal?: AbortSignal;
17
+ }
18
+ export interface DeduplicateRecordsResult {
19
+ version: 1;
20
+ status: "completed" | "unresolved";
21
+ groups: {
22
+ representativeObservationId: string;
23
+ observationIds: string[];
24
+ }[];
25
+ unresolved: {
26
+ observationId: string;
27
+ reason: "review_failed";
28
+ message: string;
29
+ }[];
30
+ }
31
+ /** Pure records workflow: no retrieval, local model execution, or persistence. */
32
+ export declare function deduplicateRecords(input: DeduplicateRecordsInput, options: DeduplicateRecordsOptions): Promise<DeduplicateRecordsResult>;
33
+ //# sourceMappingURL=records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/deduplication/records.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAa5C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAyB7D,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,CAAC;IACX,YAAY,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IACjD,sBAAsB,EAAE;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,uBAAuB,EAAE,MAAM,EAAE,CAAC;KACnC,EAAE,CAAC;CACL;AACD,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,yBAAyB,CAAC;IACxC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AACD,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC;IACnC,MAAM,EAAE;QACN,2BAA2B,EAAE,MAAM,CAAC;QACpC,cAAc,EAAE,MAAM,EAAE,CAAC;KAC1B,EAAE,CAAC;IACJ,UAAU,EAAE;QACV,aAAa,EAAE,MAAM,CAAC;QACtB,MAAM,EAAE,eAAe,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;CACL;AAED,kFAAkF;AAClF,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,uBAAuB,EAC9B,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAmInC"}
@@ -0,0 +1,134 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { z } from "incur";
3
+ import { DeduplicationReviewError } from "../errors.js";
4
+ import { abortable } from "../targets.js";
5
+ import { FindingDeduplicator } from "./deduplication.js";
6
+ import { CodexDeduplicationReviewer } from "./deduplication-reviewer.js";
7
+ import { findingSchema, requireFinding } from "./finding-schema.js";
8
+ import { sourceReviewInstructions, screeningInstructions, pairReviewInstructions, screeningFindingFormatInstructions, pairFindingFormatInstructions, } from "./deduplication-prompts.js";
9
+ const id = z.string().min(1);
10
+ const record = z
11
+ .object({
12
+ id,
13
+ finding: z.unknown().transform((value) => requireFinding(value)),
14
+ })
15
+ .strict();
16
+ const deduplicateRecordsInputSchema = z
17
+ .object({
18
+ version: z.literal(1),
19
+ observations: z.array(record),
20
+ candidateRelationships: z.array(z
21
+ .object({
22
+ observationId: id,
23
+ candidateObservationIds: z.array(id),
24
+ })
25
+ .strict()),
26
+ })
27
+ .strict();
28
+ /** Pure records workflow: no retrieval, local model execution, or persistence. */
29
+ export async function deduplicateRecords(input, options) {
30
+ options.signal?.throwIfAborted();
31
+ // Snapshot before yielding: a host cannot mutate evidence during the review.
32
+ const data = deduplicateRecordsInputSchema.parse(structuredClone(input));
33
+ const references = new Map();
34
+ const observations = new Map();
35
+ for (const entry of data.observations) {
36
+ if (observations.has(entry.id))
37
+ throw new Error(`Duplicate observation ID: ${entry.id}`);
38
+ // Original finding IDs can repeat across scans; host IDs identify observations.
39
+ const findingId = `csf_${createHash("sha256")
40
+ .update(entry.id)
41
+ .digest("hex")
42
+ .slice(0, 24)}`;
43
+ observations.set(entry.id, { ...entry.finding, findingId });
44
+ references.set(findingId, entry.id);
45
+ }
46
+ const relationships = new Map();
47
+ for (const relation of data.candidateRelationships) {
48
+ if (!observations.has(relation.observationId) ||
49
+ relationships.has(relation.observationId))
50
+ throw new Error("Each candidate relationship must name a different supplied observation.");
51
+ if (new Set(relation.candidateObservationIds).size !==
52
+ relation.candidateObservationIds.length ||
53
+ relation.candidateObservationIds.some((id) => id === relation.observationId || !observations.has(id)))
54
+ throw new Error("Candidates must name distinct supplied observations other than the anchor.");
55
+ relationships.set(relation.observationId, relation.candidateObservationIds);
56
+ }
57
+ const result = {
58
+ version: 1,
59
+ status: "completed",
60
+ groups: [],
61
+ unresolved: [],
62
+ };
63
+ const sourceFindings = [...relationships.keys()].map((id) => observations.get(id));
64
+ const reviewer = new CodexDeduplicationReviewer({
65
+ async run({ validate, ...review }) {
66
+ try {
67
+ return await abortable(async () => {
68
+ options.signal?.throwIfAborted();
69
+ return validate(await options.reviewRunner.run({
70
+ ...review,
71
+ requestId: randomUUID(),
72
+ trustedInstructions: [
73
+ sourceReviewInstructions,
74
+ review.stage === "screening"
75
+ ? screeningInstructions
76
+ : pairReviewInstructions,
77
+ review.stage === "screening"
78
+ ? screeningFindingFormatInstructions
79
+ : pairFindingFormatInstructions,
80
+ ].join("\n\n"),
81
+ findingSchema: findingSchema(),
82
+ }, { signal: options.signal }));
83
+ }, options.signal);
84
+ }
85
+ catch (error) {
86
+ // Records mode discards the batch after any failed review.
87
+ if (error instanceof DeduplicationReviewError &&
88
+ error.metadata.category === "refusal")
89
+ throw new Error(error.message, { cause: error });
90
+ throw error;
91
+ }
92
+ },
93
+ });
94
+ const algorithm = new FindingDeduplicator({
95
+ async potentialDuplicates(findingId) {
96
+ const observationId = references.get(findingId);
97
+ return {
98
+ finding: observations.get(observationId),
99
+ potentialDuplicates: relationships
100
+ .get(observationId)
101
+ .map((id) => observations.get(id)),
102
+ };
103
+ },
104
+ }, reviewer, options.signal, 1);
105
+ let groups;
106
+ try {
107
+ const decisions = await algorithm.run(sourceFindings.map((finding) => finding.findingId));
108
+ options.signal?.throwIfAborted();
109
+ groups = decisions.duplicateGroups;
110
+ }
111
+ catch (error) {
112
+ options.signal?.throwIfAborted();
113
+ result.status = "unresolved";
114
+ result.unresolved = [...relationships.keys()].map((id) => ({
115
+ observationId: id,
116
+ reason: "review_failed",
117
+ message: error instanceof Error ? error.message : "Review did not complete.",
118
+ }));
119
+ return result;
120
+ }
121
+ const grouped = new Set(groups.flat());
122
+ groups.push(...sourceFindings
123
+ .filter((finding) => !grouped.has(finding.findingId))
124
+ .map((finding) => [finding.findingId]));
125
+ for (const group of groups) {
126
+ const observationIds = group.map((id) => references.get(id));
127
+ result.groups.push({
128
+ representativeObservationId: observationIds[0],
129
+ observationIds,
130
+ });
131
+ }
132
+ return result;
133
+ }
134
+ //# sourceMappingURL=records.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/deduplication/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,CAAC,EAAE,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,kCAAkC,EAClC,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AAGpC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7B,MAAM,MAAM,GAAG,CAAC;KACb,MAAM,CAAC;IACN,EAAE;IACF,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;CACjE,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,6BAA6B,GAAuC,CAAC;KACxE,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;IAC7B,sBAAsB,EAAE,CAAC,CAAC,KAAK,CAC7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AC,CAAE;YAC/C,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { z } from \"incur\";\nimport { DeduplicationReviewError } from \"../errors.js\";\nimport type { Finding } from \"../models.js\";\nimport { abortable } from \"../targets.js\";\nimport type { CodexReview } from \"./codex-review.js\";\nimport { FindingDeduplicator } from \"./deduplication.js\";\nimport { CodexDeduplicationReviewer } from \"./deduplication-reviewer.js\";\nimport { findingSchema, requireFinding } from \"./finding-schema.js\";\nimport {\n sourceReviewInstructions,\n screeningInstructions,\n pairReviewInstructions,\n screeningFindingFormatInstructions,\n pairFindingFormatInstructions,\n} from \"./deduplication-prompts.js\";\nimport type { DeduplicationReviewRunner } from \"./review.js\";\n\nconst id = z.string().min(1);\nconst record = z\n .object({\n id,\n finding: z.unknown().transform((value) => requireFinding(value)),\n })\n .strict();\n\nconst deduplicateRecordsInputSchema: z.ZodType<DeduplicateRecordsInput> = z\n .object({\n version: z.literal(1),\n observations: z.array(record),\n candidateRelationships: z.array(\n z\n .object({\n observationId: id,\n candidateObservationIds: z.array(id),\n })\n .strict(),\n ),\n })\n .strict();\n\nexport interface DeduplicateRecordsInput {\n version: 1;\n observations: { id: string; finding: Finding }[];\n candidateRelationships: {\n observationId: string;\n candidateObservationIds: string[];\n }[];\n}\nexport interface DeduplicateRecordsOptions {\n reviewRunner: DeduplicationReviewRunner;\n signal?: AbortSignal;\n}\nexport interface DeduplicateRecordsResult {\n version: 1;\n status: \"completed\" | \"unresolved\";\n groups: {\n representativeObservationId: string;\n observationIds: string[];\n }[];\n unresolved: {\n observationId: string;\n reason: \"review_failed\";\n message: string;\n }[];\n}\n\n/** Pure records workflow: no retrieval, local model execution, or persistence. */\nexport async function deduplicateRecords(\n input: DeduplicateRecordsInput,\n options: DeduplicateRecordsOptions,\n): Promise<DeduplicateRecordsResult> {\n options.signal?.throwIfAborted();\n // Snapshot before yielding: a host cannot mutate evidence during the review.\n const data = deduplicateRecordsInputSchema.parse(structuredClone(input));\n const references = new Map<string, string>();\n const observations = new Map<string, Finding>();\n for (const entry of data.observations) {\n if (observations.has(entry.id))\n throw new Error(`Duplicate observation ID: ${entry.id}`);\n // Original finding IDs can repeat across scans; host IDs identify observations.\n const findingId = `csf_${createHash(\"sha256\")\n .update(entry.id)\n .digest(\"hex\")\n .slice(0, 24)}`;\n observations.set(entry.id, { ...entry.finding, findingId });\n references.set(findingId, entry.id);\n }\n const relationships = new Map<string, string[]>();\n for (const relation of data.candidateRelationships) {\n if (\n !observations.has(relation.observationId) ||\n relationships.has(relation.observationId)\n )\n throw new Error(\n \"Each candidate relationship must name a different supplied observation.\",\n );\n if (\n new Set(relation.candidateObservationIds).size !==\n relation.candidateObservationIds.length ||\n relation.candidateObservationIds.some(\n (id) => id === relation.observationId || !observations.has(id),\n )\n )\n throw new Error(\n \"Candidates must name distinct supplied observations other than the anchor.\",\n );\n relationships.set(relation.observationId, relation.candidateObservationIds);\n }\n const result: DeduplicateRecordsResult = {\n version: 1,\n status: \"completed\",\n groups: [],\n unresolved: [],\n };\n const sourceFindings = [...relationships.keys()].map((id) =>\n observations.get(id)!,\n );\n const reviewer = new CodexDeduplicationReviewer({\n async run<T>({ validate, ...review }: CodexReview<T>): Promise<T> {\n try {\n return await abortable(async () => {\n options.signal?.throwIfAborted();\n return validate(\n await options.reviewRunner.run(\n {\n ...review,\n requestId: randomUUID(),\n trustedInstructions: [\n sourceReviewInstructions,\n review.stage === \"screening\"\n ? screeningInstructions\n : pairReviewInstructions,\n review.stage === \"screening\"\n ? screeningFindingFormatInstructions\n : pairFindingFormatInstructions,\n ].join(\"\\n\\n\"),\n findingSchema: findingSchema(),\n },\n { signal: options.signal },\n ),\n );\n }, options.signal);\n } catch (error) {\n // Records mode discards the batch after any failed review.\n if (\n error instanceof DeduplicationReviewError &&\n error.metadata.category === \"refusal\"\n )\n throw new Error(error.message, { cause: error });\n throw error;\n }\n },\n });\n const algorithm = new FindingDeduplicator(\n {\n async potentialDuplicates(findingId) {\n const observationId = references.get(findingId)!;\n return {\n finding: observations.get(observationId)!,\n potentialDuplicates: relationships\n .get(observationId)!\n .map((id) => observations.get(id)!),\n };\n },\n },\n reviewer,\n options.signal,\n 1,\n );\n let groups: string[][];\n try {\n const decisions = await algorithm.run(\n sourceFindings.map((finding) => finding.findingId),\n );\n options.signal?.throwIfAborted();\n groups = decisions.duplicateGroups;\n } catch (error) {\n options.signal?.throwIfAborted();\n result.status = \"unresolved\";\n result.unresolved = [...relationships.keys()].map((id) => ({\n observationId: id,\n reason: \"review_failed\",\n message:\n error instanceof Error ? error.message : \"Review did not complete.\",\n }));\n return result;\n }\n const grouped = new Set(groups.flat());\n groups.push(\n ...sourceFindings\n .filter((finding) => !grouped.has(finding.findingId))\n .map((finding) => [finding.findingId]),\n );\n for (const group of groups) {\n const observationIds = group.map((id) => references.get(id)!);\n result.groups.push({\n representativeObservationId: observationIds[0]!,\n observationIds,\n });\n }\n return result;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { DeduplicationReviewStage } from "../errors.js";
2
+ /** Serializable review contract shared by local and host-provided execution. */
3
+ export interface DeduplicationReviewRequest {
4
+ requestId: string;
5
+ stage: DeduplicationReviewStage;
6
+ model: string;
7
+ effort: string;
8
+ prompt: string;
9
+ trustedInstructions: string;
10
+ /** Tool submission contract, not an OpenAI strict Structured Outputs schema. */
11
+ schema: unknown;
12
+ /** SAME.mergedFinding must satisfy this additional schema. */
13
+ findingSchema: unknown;
14
+ }
15
+ /** Execute one review. Codex Security validates the returned structured answer. */
16
+ export interface DeduplicationReviewRunner {
17
+ run(request: DeduplicationReviewRequest, options?: {
18
+ signal?: AbortSignal;
19
+ }): Promise<unknown>;
20
+ }
21
+ //# sourceMappingURL=review.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../src/deduplication/review.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAE7D,gFAAgF;AAChF,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,wBAAwB,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,MAAM,EAAE,OAAO,CAAC;IAChB,8DAA8D;IAC9D,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,mFAAmF;AACnF,MAAM,WAAW,yBAAyB;IACxC,GAAG,CACD,OAAO,EAAE,0BAA0B,EACnC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACjC,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/deduplication/review.ts"],"names":[],"mappings":"","sourcesContent":["import type { DeduplicationReviewStage } from \"../errors.js\";\n\n/** Serializable review contract shared by local and host-provided execution. */\nexport interface DeduplicationReviewRequest {\n requestId: string;\n stage: DeduplicationReviewStage;\n model: string;\n effort: string;\n prompt: string;\n trustedInstructions: string;\n /** Tool submission contract, not an OpenAI strict Structured Outputs schema. */\n schema: unknown;\n /** SAME.mergedFinding must satisfy this additional schema. */\n findingSchema: unknown;\n}\n\n/** Execute one review. Codex Security validates the returned structured answer. */\nexport interface DeduplicationReviewRunner {\n run(\n request: DeduplicationReviewRequest,\n options?: { signal?: AbortSignal },\n ): Promise<unknown>;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export type { ResolvedProjectConfig, ProjectConfigProvenance, } from "./project-
4
4
  export type { ProjectConfigInput, ProjectScope, } from "./project-config-schema.js";
5
5
  export type { ScanSettings } from "./scan-settings.js";
6
6
  export { classifySeverity } from "./classify-severity.js";
7
+ export { suggestOwners } from "./suggest-owners.js";
8
+ export type { OwnerFinding, OwnerIdentity, OwnerSuggestion, OwnerSuggestions, SuggestOwnersOptions, } from "./suggest-owners.js";
7
9
  export type { ClassifySeverityOptions, SeverityClassificationFinding, SeverityClassification, SeverityAssessment, } from "./classify-severity.js";
8
10
  export { classifyScanSeverity, classifyScanDirectorySeverity, } from "./classify-scan-severity.js";
9
11
  export type { ClassifyScanSeverityOptions, ScanSeverityClassification, } from "./classify-scan-severity.js";
@@ -34,6 +36,9 @@ export type { SecurityPolicyDraft, SecurityPolicyOptions, SecurityPolicyPrefligh
34
36
  export { checkScanPublication, publishScan } from "./publish.js";
35
37
  export { publishScanToCustom } from "./custom-publish.js";
36
38
  export type { PublishScanToCustomOptions, CustomPublicationResult, } from "./custom-publish.js";
39
+ export { deduplicateRecords } from "./deduplication/records.js";
40
+ export type { DeduplicateRecordsInput, DeduplicateRecordsOptions, DeduplicateRecordsResult, } from "./deduplication/records.js";
41
+ export type { DeduplicationReviewRequest, DeduplicationReviewRunner, } from "./deduplication/review.js";
37
42
  export { deduplicateScan, deduplicateScanDirectory, } from "./deduplication/scan.js";
38
43
  export type { DeduplicateScanDirectoryOptions, DeduplicateScanOptions, DeduplicateScanResult, } from "./deduplication/scan.js";
39
44
  export type { DeduplicationRefusal } from "./deduplication/deduplication.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,YAAY,EACV,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,kBAAkB,EAClB,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAA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BAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3E,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { CodexSecurity, createSecurity } from "./api.js";
2
2
  export { loadProjectConfig, resolveProjectConfig } from "./project-config.js";
3
3
  export { classifySeverity } from "./classify-severity.js";
4
+ export { suggestOwners } from "./suggest-owners.js";
4
5
  export { classifyScanSeverity, classifyScanDirectorySeverity, } from "./classify-scan-severity.js";
5
6
  export { runComponentScans } from "./component-scan.js";
6
7
  export { normalizeComponentPlan, planComponents } from "./component-plan.js";
@@ -13,6 +14,7 @@ export { loadContract, requireScanFile } from "./contract.js";
13
14
  export { resolveSecurityPolicyTarget, securityPolicyDiff, } from "./security-policy.js";
14
15
  export { checkScanPublication, publishScan } from "./publish.js";
15
16
  export { publishScanToCustom } from "./custom-publish.js";
17
+ export { deduplicateRecords } from "./deduplication/records.js";
16
18
  export { deduplicateScan, deduplicateScanDirectory, } from "./deduplication/scan.js";
17
19
  export { importGitHubCodeScanningAlerts } from "./github.js";
18
20
  export { ScanResult } from "./result.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources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Aa,CAAC;AAY7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { CodexSecurity, createSecurity } from \"./api.js\";\nexport { loadProjectConfig, resolveProjectConfig } from \"./project-config.js\";\nexport type {\n ResolvedProjectConfig,\n ProjectConfigProvenance,\n} from \"./project-config.js\";\nexport type {\n ProjectConfigInput,\n ProjectScope,\n} from \"./project-config-schema.js\";\nexport type { ScanSettings } from \"./scan-settings.js\";\nexport { classifySeverity } from \"./classify-severity.js\";\nexport type {\n ClassifySeverityOptions,\n SeverityClassificationFinding,\n SeverityClassification,\n SeverityAssessment,\n} from \"./classify-severity.js\";\nexport {\n classifyScanSeverity,\n classifyScanDirectorySeverity,\n} from \"./classify-scan-severity.js\";\nexport type {\n ClassifyScanSeverityOptions,\n ScanSeverityClassification,\n} from \"./classify-scan-severity.js\";\nexport { runComponentScans } from \"./component-scan.js\";\nexport type {\n ComponentDeduplicationSummary,\n ComponentReceipt,\n ComponentScanOptions,\n ComponentScanEvent,\n ComponentScanResult,\n} from \"./component-scan.js\";\nexport { normalizeComponentPlan, planComponents } from \"./component-plan.js\";\nexport type {\n ComponentPlan,\n ComponentPlanningOptions,\n} from \"./component-plan.js\";\nexport { estimateScanCost } from \"./cost.js\";\nexport type { ScanCost, ScanSessionEvent } from \"./cost.js\";\nexport type { DeepScanProgress } from \"./deep-progress.js\";\nexport type { CustomValidationResult } from \"./custom-validation.js\";\nexport type { ScanActivity, ScanActivityStatus } from \"./scan-activity.js\";\nexport { matchScanFindings } from \"./scan-comparison.js\";\nexport type {\n ScanComparisonInput,\n ScanComparisonOptions,\n ScanComparisonProgress,\n ScanComparisonResult,\n} from \"./scan-comparison.js\";\nexport type {\n CodexSecurityMetadata,\n DeepScanOptions,\n ScanAuthMode,\n ScanAuthentication,\n ScanBudget,\n ScanOptions,\n ScanPreflight,\n ScanReconnectDetails,\n ScanTrustedAccessStatus,\n ScanWarningDetails,\n ValidationOptions,\n ValidationResult,\n} from \"./api.js\";\nexport type {\n ScanPhase,\n ScanProgress,\n ScanWorkerPhase,\n ScanWorkerStatus,\n} from \"./worker-progress.js\";\nexport { CodexLoginHandle } from \"./auth.js\";\nexport type { AccountStatus, LoginResult } from \"./auth.js\";\n\nexport {\n AuthenticationRequiredError,\n CodexSecurityError,\n ConfigurationError,\n ContractValidationError,\n DeduplicationReviewError,\n IncompleteScanError,\n InvalidTargetError,\n OutputDirectoryError,\n OutputDirectoryNotEmptyError,\n OutputInsideProtectedRootError,\n PluginBootstrapError,\n PluginPythonUnavailableError,\n ScanCostLimitExceededError,\n ScanInterruptedError,\n} from \"./errors.js\";\nexport type {\n DeduplicationReviewFailureCategory,\n DeduplicationReviewFailureMetadata,\n DeduplicationReviewStage,\n ProtectedScanPathKind,\n} from \"./errors.js\";\nexport {\n DEFAULT_CODEX_CONFIG,\n mergedCodexConfig,\n writeCodexConfig,\n} from \"./config.js\";\nexport type { CodexSecurityConfig, JsonObject, JsonValue } from \"./config.js\";\nexport { loadContract, requireScanFile } from \"./contract.js\";\nexport type { LoadedContract, ScanExpectation } from \"./contract.js\";\nexport type * from \"./models.js\";\nexport {\n resolveSecurityPolicyTarget,\n securityPolicyDiff,\n} from \"./security-policy.js\";\nexport type {\n SecurityPolicyDraft,\n SecurityPolicyOptions,\n SecurityPolicyPreflight,\n SecurityPolicyStage,\n SecurityPolicyTarget,\n} from \"./security-policy.js\";\nexport { checkScanPublication, publishScan } from \"./publish.js\";\nexport { publishScanToCustom } from \"./custom-publish.js\";\nexport type {\n PublishScanToCustomOptions,\n CustomPublicationResult,\n} from \"./custom-publish.js\";\nexport {\n deduplicateScan,\n deduplicateScanDirectory,\n} from \"./deduplication/scan.js\";\nexport type {\n DeduplicateScanDirectoryOptions,\n DeduplicateScanOptions,\n DeduplicateScanResult,\n} from \"./deduplication/scan.js\";\nexport type { DeduplicationRefusal } from \"./deduplication/deduplication.js\";\nexport { importGitHubCodeScanningAlerts } from \"./github.js\";\nexport type {\n GitHubCodeScanningImportOptions,\n ImportedGitHubCodeScanningAlert,\n} from \"./github.js\";\nexport type {\n CheckScanPublicationOptions,\n CheckScanPublicationResult,\n PublishScanOptions,\n PublishScanProgress,\n PublishScanResult,\n} from \"./publish.js\";\nexport { ScanResult } from \"./result.js\";\nexport type {\n RepositoryFinding,\n ScanResultOptions,\n TurnResultMetadata,\n} from \"./result.js\";\nexport {\n bootstrapPlugin,\n bundledPluginRoot,\n cleanupSdkDirectory,\n createIsolatedHome,\n createMarketplace,\n extractPluginZip,\n importAmbientAuth,\n MARKETPLACE_NAME,\n pluginExecutionEnvironment,\n pluginMetadata,\n PLUGIN_NAME,\n prepareOutputDir,\n resolveCodexCommand,\n resolvePluginPath,\n resolvePluginPython,\n validateOutputDir,\n} from \"./runtime.js\";\nexport type {\n CodexCommand,\n PluginInstall,\n PluginPythonOptions,\n ProcessEnvironment,\n} from \"./runtime.js\";\nexport {\n DiffTarget,\n normalizeRepository,\n normalizeTarget,\n repositoryRevision,\n validateMode,\n} from \"./targets.js\";\nexport type { NormalizedTarget, ScanMode, ScanTarget } from \"./targets.js\";\nexport type { AbsolutePath } from \"./config-path.js\";\nexport { BUNDLED_PLUGIN_VERSION, VERSION } from \"./version.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAA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BAAwB,GACzB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAY7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { CodexSecurity, createSecurity } from \"./api.js\";\nexport { loadProjectConfig, resolveProjectConfig } from \"./project-config.js\";\nexport type {\n ResolvedProjectConfig,\n ProjectConfigProvenance,\n} from \"./project-config.js\";\nexport type {\n ProjectConfigInput,\n ProjectScope,\n} from \"./project-config-schema.js\";\nexport type { ScanSettings } from \"./scan-settings.js\";\nexport { classifySeverity } from \"./classify-severity.js\";\nexport { suggestOwners } from \"./suggest-owners.js\";\nexport type {\n OwnerFinding,\n OwnerIdentity,\n OwnerSuggestion,\n OwnerSuggestions,\n SuggestOwnersOptions,\n} from \"./suggest-owners.js\";\nexport type {\n ClassifySeverityOptions,\n SeverityClassificationFinding,\n SeverityClassification,\n SeverityAssessment,\n} from \"./classify-severity.js\";\nexport {\n classifyScanSeverity,\n classifyScanDirectorySeverity,\n} from \"./classify-scan-severity.js\";\nexport type {\n ClassifyScanSeverityOptions,\n ScanSeverityClassification,\n} from \"./classify-scan-severity.js\";\nexport { runComponentScans } from \"./component-scan.js\";\nexport type {\n ComponentDeduplicationSummary,\n ComponentReceipt,\n ComponentScanOptions,\n ComponentScanEvent,\n ComponentScanResult,\n} from \"./component-scan.js\";\nexport { normalizeComponentPlan, planComponents } from \"./component-plan.js\";\nexport type {\n ComponentPlan,\n ComponentPlanningOptions,\n} from \"./component-plan.js\";\nexport { estimateScanCost } from \"./cost.js\";\nexport type { ScanCost, ScanSessionEvent } from \"./cost.js\";\nexport type { DeepScanProgress } from \"./deep-progress.js\";\nexport type { CustomValidationResult } from \"./custom-validation.js\";\nexport type { ScanActivity, ScanActivityStatus } from \"./scan-activity.js\";\nexport { matchScanFindings } from \"./scan-comparison.js\";\nexport type {\n ScanComparisonInput,\n ScanComparisonOptions,\n ScanComparisonProgress,\n ScanComparisonResult,\n} from \"./scan-comparison.js\";\nexport type {\n CodexSecurityMetadata,\n DeepScanOptions,\n ScanAuthMode,\n ScanAuthentication,\n ScanBudget,\n ScanOptions,\n ScanPreflight,\n ScanReconnectDetails,\n ScanTrustedAccessStatus,\n ScanWarningDetails,\n ValidationOptions,\n ValidationResult,\n} from \"./api.js\";\nexport type {\n ScanPhase,\n ScanProgress,\n ScanWorkerPhase,\n ScanWorkerStatus,\n} from \"./worker-progress.js\";\nexport { CodexLoginHandle } from \"./auth.js\";\nexport type { AccountStatus, LoginResult } from \"./auth.js\";\n\nexport {\n AuthenticationRequiredError,\n CodexSecurityError,\n ConfigurationError,\n ContractValidationError,\n DeduplicationReviewError,\n IncompleteScanError,\n InvalidTargetError,\n OutputDirectoryError,\n OutputDirectoryNotEmptyError,\n OutputInsideProtectedRootError,\n PluginBootstrapError,\n PluginPythonUnavailableError,\n ScanCostLimitExceededError,\n ScanInterruptedError,\n} from \"./errors.js\";\nexport type {\n DeduplicationReviewFailureCategory,\n DeduplicationReviewFailureMetadata,\n DeduplicationReviewStage,\n ProtectedScanPathKind,\n} from \"./errors.js\";\nexport {\n DEFAULT_CODEX_CONFIG,\n mergedCodexConfig,\n writeCodexConfig,\n} from \"./config.js\";\nexport type { CodexSecurityConfig, JsonObject, JsonValue } from \"./config.js\";\nexport { loadContract, requireScanFile } from \"./contract.js\";\nexport type { LoadedContract, ScanExpectation } from \"./contract.js\";\nexport type * from \"./models.js\";\nexport {\n resolveSecurityPolicyTarget,\n securityPolicyDiff,\n} from \"./security-policy.js\";\nexport type {\n SecurityPolicyDraft,\n SecurityPolicyOptions,\n SecurityPolicyPreflight,\n SecurityPolicyStage,\n SecurityPolicyTarget,\n} from \"./security-policy.js\";\nexport { checkScanPublication, publishScan } from \"./publish.js\";\nexport { publishScanToCustom } from \"./custom-publish.js\";\nexport type {\n PublishScanToCustomOptions,\n CustomPublicationResult,\n} from \"./custom-publish.js\";\nexport { deduplicateRecords } from \"./deduplication/records.js\";\nexport type {\n DeduplicateRecordsInput,\n DeduplicateRecordsOptions,\n DeduplicateRecordsResult,\n} from \"./deduplication/records.js\";\nexport type {\n DeduplicationReviewRequest,\n DeduplicationReviewRunner,\n} from \"./deduplication/review.js\";\nexport {\n deduplicateScan,\n deduplicateScanDirectory,\n} from \"./deduplication/scan.js\";\nexport type {\n DeduplicateScanDirectoryOptions,\n DeduplicateScanOptions,\n DeduplicateScanResult,\n} from \"./deduplication/scan.js\";\nexport type { DeduplicationRefusal } from \"./deduplication/deduplication.js\";\nexport { importGitHubCodeScanningAlerts } from \"./github.js\";\nexport type {\n GitHubCodeScanningImportOptions,\n ImportedGitHubCodeScanningAlert,\n} from \"./github.js\";\nexport type {\n CheckScanPublicationOptions,\n CheckScanPublicationResult,\n PublishScanOptions,\n PublishScanProgress,\n PublishScanResult,\n} from \"./publish.js\";\nexport { ScanResult } from \"./result.js\";\nexport type {\n RepositoryFinding,\n ScanResultOptions,\n TurnResultMetadata,\n} from \"./result.js\";\nexport {\n bootstrapPlugin,\n bundledPluginRoot,\n cleanupSdkDirectory,\n createIsolatedHome,\n createMarketplace,\n extractPluginZip,\n importAmbientAuth,\n MARKETPLACE_NAME,\n pluginExecutionEnvironment,\n pluginMetadata,\n PLUGIN_NAME,\n prepareOutputDir,\n resolveCodexCommand,\n resolvePluginPath,\n resolvePluginPython,\n validateOutputDir,\n} from \"./runtime.js\";\nexport type {\n CodexCommand,\n PluginInstall,\n PluginPythonOptions,\n ProcessEnvironment,\n} from \"./runtime.js\";\nexport {\n DiffTarget,\n normalizeRepository,\n normalizeTarget,\n repositoryRevision,\n validateMode,\n} from \"./targets.js\";\nexport type { NormalizedTarget, ScanMode, ScanTarget } from \"./targets.js\";\nexport type { AbsolutePath } from \"./config-path.js\";\nexport { BUNDLED_PLUGIN_VERSION, VERSION } from \"./version.js\";\n"]}
@@ -60,11 +60,15 @@ export async function prepareKnowledgeBase(paths, signal, directory) {
60
60
  if ((extension === ".pdf" || extension === ".docx") && !text.trim()) {
61
61
  throw new Error(`Knowledge base document contains no extractable text: ${document}`);
62
62
  }
63
- await writeFile(join(path, `${index++}-${basename(document)}.txt`), text, {
63
+ const name = `${index}-${basename(document)}.txt`;
64
+ // The prefix and suffix can exceed the filesystem's 255-byte name limit.
65
+ const filename = Buffer.byteLength(name) > 255 ? `${index}.txt` : name;
66
+ await writeFile(join(path, filename), text, {
64
67
  encoding: "utf8",
65
68
  mode: 0o600,
66
69
  signal,
67
70
  });
71
+ index++;
68
72
  }
69
73
  }
70
74
  catch (error) {