vouchington-tooling 0.59.0 → 0.61.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 +108 -0
- package/dist/cli/commands/hook.d.mts +2 -0
- package/dist/cli/commands/hook.mjs +19 -0
- package/dist/cli/commands/sandbox-command-audit.d.mts +7 -0
- package/dist/cli/commands/sandbox-command-audit.mjs +27 -0
- package/dist/cli/index.mjs +8 -0
- package/dist/cli/parse-forwarded-commands.d.mts +9 -0
- package/dist/cli/parse-forwarded-commands.mjs +6 -0
- package/dist/cli/parse.d.mts +9 -0
- package/dist/cli/usage-text.d.mts +1 -0
- package/dist/cli/usage-text.mjs +179 -0
- package/dist/cli/usage.d.mts +2 -1
- package/dist/cli/usage.mjs +2 -156
- package/dist/command-policy/engine.d.mts +7 -0
- package/dist/command-policy/engine.mjs +58 -0
- package/dist/command-policy/git-patterns.d.mts +20 -0
- package/dist/command-policy/git-patterns.mjs +82 -0
- package/dist/command-policy/git-process.d.mts +4 -0
- package/dist/command-policy/git-process.mjs +54 -0
- package/dist/command-policy/github-checkout-owners.d.mts +22 -0
- package/dist/command-policy/github-checkout-owners.mjs +122 -0
- package/dist/command-policy/github-command-context.d.mts +6 -0
- package/dist/command-policy/github-command-context.mjs +19 -0
- package/dist/command-policy/github-command-cwd.d.mts +8 -0
- package/dist/command-policy/github-command-cwd.mjs +130 -0
- package/dist/command-policy/github-command-position.d.mts +7 -0
- package/dist/command-policy/github-command-position.mjs +12 -0
- package/dist/command-policy/github-configured-base.d.mts +25 -0
- package/dist/command-policy/github-configured-base.mjs +59 -0
- package/dist/command-policy/github-invocation.d.mts +9 -0
- package/dist/command-policy/github-invocation.mjs +80 -0
- package/dist/command-policy/github-merge-authority.d.mts +21 -0
- package/dist/command-policy/github-merge-authority.mjs +86 -0
- package/dist/command-policy/github-option-flags.d.mts +3 -0
- package/dist/command-policy/github-option-flags.mjs +67 -0
- package/dist/command-policy/github-options.d.mts +12 -0
- package/dist/command-policy/github-options.mjs +73 -0
- package/dist/command-policy/github-stack-workflow.d.mts +9 -0
- package/dist/command-policy/github-stack-workflow.mjs +94 -0
- package/dist/command-policy/github-workflow.d.mts +7 -0
- package/dist/command-policy/github-workflow.mjs +50 -0
- package/dist/command-policy/hook/args.d.mts +11 -0
- package/dist/command-policy/hook/args.mjs +49 -0
- package/dist/command-policy/hook/harness.d.mts +26 -0
- package/dist/command-policy/hook/harness.mjs +119 -0
- package/dist/command-policy/hook/policy-module.d.mts +7 -0
- package/dist/command-policy/hook/policy-module.mjs +48 -0
- package/dist/command-policy/hook/post-tool-use.d.mts +9 -0
- package/dist/command-policy/hook/post-tool-use.mjs +51 -0
- package/dist/command-policy/hook/pre-tool-use.d.mts +21 -0
- package/dist/command-policy/hook/pre-tool-use.mjs +45 -0
- package/dist/command-policy/hook/run.d.mts +17 -0
- package/dist/command-policy/hook/run.mjs +69 -0
- package/dist/command-policy/hook/types.d.mts +33 -0
- package/dist/command-policy/hook/types.mjs +5 -0
- package/dist/command-policy/index.d.mts +29 -0
- package/dist/command-policy/index.mjs +23 -0
- package/dist/command-policy/path-references.d.mts +14 -0
- package/dist/command-policy/path-references.mjs +68 -0
- package/dist/command-policy/path-rules.d.mts +11 -0
- package/dist/command-policy/path-rules.mjs +37 -0
- package/dist/command-policy/payload.d.mts +8 -0
- package/dist/command-policy/payload.mjs +54 -0
- package/dist/command-policy/types.d.mts +77 -0
- package/dist/command-policy/types.mjs +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/sandbox-command-audit/args.d.mts +20 -0
- package/dist/sandbox-command-audit/args.mjs +64 -0
- package/dist/sandbox-command-audit/classify-prefixes.d.mts +23 -0
- package/dist/sandbox-command-audit/classify-prefixes.mjs +50 -0
- package/dist/sandbox-command-audit/classify.d.mts +46 -0
- package/dist/sandbox-command-audit/classify.mjs +74 -0
- package/dist/sandbox-command-audit/claude-extract.d.mts +23 -0
- package/dist/sandbox-command-audit/claude-extract.mjs +76 -0
- package/dist/sandbox-command-audit/claude-tool-uses.d.mts +15 -0
- package/dist/sandbox-command-audit/claude-tool-uses.mjs +53 -0
- package/dist/sandbox-command-audit/codex-extract.d.mts +21 -0
- package/dist/sandbox-command-audit/codex-extract.mjs +77 -0
- package/dist/sandbox-command-audit/codex-scan.d.mts +11 -0
- package/dist/sandbox-command-audit/codex-scan.mjs +98 -0
- package/dist/sandbox-command-audit/codex-spool.d.mts +14 -0
- package/dist/sandbox-command-audit/codex-spool.mjs +46 -0
- package/dist/sandbox-command-audit/discover-files.d.mts +44 -0
- package/dist/sandbox-command-audit/discover-files.mjs +85 -0
- package/dist/sandbox-command-audit/failure-text.d.mts +7 -0
- package/dist/sandbox-command-audit/failure-text.mjs +34 -0
- package/dist/sandbox-command-audit/fixtures.test-helpers.d.mts +34 -0
- package/dist/sandbox-command-audit/fixtures.test-helpers.mjs +41 -0
- package/dist/sandbox-command-audit/index.d.mts +26 -0
- package/dist/sandbox-command-audit/index.mjs +15 -0
- package/dist/sandbox-command-audit/json-record.d.mts +6 -0
- package/dist/sandbox-command-audit/json-record.mjs +16 -0
- package/dist/sandbox-command-audit/limits.d.mts +30 -0
- package/dist/sandbox-command-audit/limits.mjs +66 -0
- package/dist/sandbox-command-audit/repo-scope.d.mts +25 -0
- package/dist/sandbox-command-audit/repo-scope.mjs +79 -0
- package/dist/sandbox-command-audit/report-raw.d.mts +16 -0
- package/dist/sandbox-command-audit/report-raw.mjs +55 -0
- package/dist/sandbox-command-audit/report.d.mts +10 -0
- package/dist/sandbox-command-audit/report.mjs +61 -0
- package/dist/sandbox-command-audit/run.d.mts +36 -0
- package/dist/sandbox-command-audit/run.mjs +70 -0
- package/dist/sandbox-command-audit/scan.d.mts +10 -0
- package/dist/sandbox-command-audit/scan.mjs +79 -0
- package/dist/sandbox-command-audit/transcript-cwd.d.mts +14 -0
- package/dist/sandbox-command-audit/transcript-cwd.mjs +153 -0
- package/dist/sandbox-command-audit/types.d.mts +59 -0
- package/dist/sandbox-command-audit/types.mjs +23 -0
- package/dist/tmux/cli-shared.d.mts +18 -0
- package/dist/tmux/cli-shared.mjs +8 -0
- package/dist/tmux/cli.d.mts +3 -0
- package/dist/tmux/cli.mjs +34 -0
- package/dist/tmux/config.d.mts +24 -0
- package/dist/tmux/config.mjs +91 -0
- package/dist/tmux/fake-tmux.test-helpers.d.mts +46 -0
- package/dist/tmux/fake-tmux.test-helpers.mjs +105 -0
- package/dist/tmux/hook-payload.d.mts +8 -0
- package/dist/tmux/hook-payload.mjs +39 -0
- package/dist/tmux/index.d.mts +9 -0
- package/dist/tmux/index.mjs +7 -0
- package/dist/tmux/launcher.d.mts +11 -0
- package/dist/tmux/launcher.mjs +127 -0
- package/dist/tmux/reminder-post-tool.d.mts +21 -0
- package/dist/tmux/reminder-post-tool.mjs +88 -0
- package/dist/tmux/runner.d.mts +11 -0
- package/dist/tmux/runner.mjs +26 -0
- package/dist/tmux/session-name.d.mts +5 -0
- package/dist/tmux/session-name.mjs +10 -0
- package/dist/tmux/shell-quote.d.mts +9 -0
- package/dist/tmux/shell-quote.mjs +16 -0
- package/dist/tmux/up.d.mts +2 -0
- package/dist/tmux/up.mjs +73 -0
- package/dist/tmux/windows.d.mts +18 -0
- package/dist/tmux/windows.mjs +50 -0
- package/package.json +16 -1
- package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
- package/scripts/tmux/tmux-agent-reminder.sh +68 -0
- package/scripts/tmux/tmux-name.sh +34 -0
- package/scripts/tmux/tmux-read-title.sh +13 -0
- package/scripts/tmux/tmux-target.sh +130 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { coverageByPrefix, groupByPrefix, splitByCoverage, toSortedPrefixCounts, unresolvedCount, } from "./classify-prefixes.mjs";
|
|
2
|
+
const BUILT_IN_KINDS = new Set(['genuine', 'e2big']);
|
|
3
|
+
function classifyGenuine(scan, policy) {
|
|
4
|
+
const commands = scan.claudeSandboxFailures
|
|
5
|
+
.filter((record) => record.kind === 'genuine')
|
|
6
|
+
.map((record) => record.command);
|
|
7
|
+
const counts = groupByPrefix(commands);
|
|
8
|
+
const candidates = toSortedPrefixCounts(counts).map((entry) => ({
|
|
9
|
+
...entry,
|
|
10
|
+
alreadyInAllowList: policy.covers('allow', entry.prefix),
|
|
11
|
+
}));
|
|
12
|
+
return { candidates, unresolvedCount: unresolvedCount(counts) };
|
|
13
|
+
}
|
|
14
|
+
function classifyBlocks(scan, policy) {
|
|
15
|
+
const commands = scan.claudeDenials
|
|
16
|
+
.filter((record) => record.kind === 'user-rejected')
|
|
17
|
+
.map((record) => record.command);
|
|
18
|
+
const counts = groupByPrefix(commands);
|
|
19
|
+
const denied = coverageByPrefix(commands, 'deny', policy);
|
|
20
|
+
const candidates = toSortedPrefixCounts(counts).map((entry) => ({
|
|
21
|
+
...entry,
|
|
22
|
+
alreadyDenied: denied.get(entry.prefix) === true,
|
|
23
|
+
}));
|
|
24
|
+
return { candidates, unresolvedCount: unresolvedCount(counts) };
|
|
25
|
+
}
|
|
26
|
+
function classifyEscalations(scan, policy) {
|
|
27
|
+
const counts = groupByPrefix(scan.claudeEscalations.map((record) => record.command));
|
|
28
|
+
const split = splitByCoverage(counts, 'excluded', policy);
|
|
29
|
+
return {
|
|
30
|
+
claudeCovered: split.covered,
|
|
31
|
+
claudeUncovered: split.uncovered,
|
|
32
|
+
claudeUnresolvedCount: split.unresolvedCount,
|
|
33
|
+
e2bigCount: scan.claudeSandboxFailures.filter((record) => record.kind === 'e2big').length,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function otherFailureCounts(scan) {
|
|
37
|
+
const counts = new Map();
|
|
38
|
+
// Built-in kinds feed the bypass and E2BIG sections, which read Claude failures only; a Codex
|
|
39
|
+
// failure of any kind has no other section, so it is always counted here.
|
|
40
|
+
const failures = [
|
|
41
|
+
...scan.claudeSandboxFailures.filter(({ kind }) => !BUILT_IN_KINDS.has(kind)),
|
|
42
|
+
...scan.codexSandboxFailures,
|
|
43
|
+
];
|
|
44
|
+
for (const { kind } of failures)
|
|
45
|
+
counts.set(kind, (counts.get(kind) ?? 0) + 1);
|
|
46
|
+
return [...counts]
|
|
47
|
+
.map(([kind, count]) => ({ kind, count }))
|
|
48
|
+
.toSorted((a, b) => b.count - a.count || a.kind.localeCompare(b.kind));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sorts a scan into report buckets against the caller's policy. Bypass candidates come from
|
|
52
|
+
* Claude's real permission failures; Codex escalations are not scanned here because Codex agents
|
|
53
|
+
* journal them separately.
|
|
54
|
+
*/
|
|
55
|
+
export function classifyAudit(scan, policy) {
|
|
56
|
+
const genuine = classifyGenuine(scan, policy);
|
|
57
|
+
const block = classifyBlocks(scan, policy);
|
|
58
|
+
return {
|
|
59
|
+
genuineBypassCandidates: genuine.candidates,
|
|
60
|
+
genuineBypassUnresolvedCount: genuine.unresolvedCount,
|
|
61
|
+
blockCandidates: block.candidates,
|
|
62
|
+
blockCandidateUnresolvedCount: block.unresolvedCount,
|
|
63
|
+
escalationPressure: classifyEscalations(scan, policy),
|
|
64
|
+
policyBlockCount: scan.claudeDenials.filter((record) => record.kind === 'permission-rule' || record.kind === 'automode-blocked').length,
|
|
65
|
+
otherFailures: otherFailureCounts(scan),
|
|
66
|
+
claudeFilesScanned: scan.claudeFilesScanned,
|
|
67
|
+
codexFilesScanned: scan.codexFilesScanned,
|
|
68
|
+
readErrorCount: scan.readErrors.length,
|
|
69
|
+
repoRoots: scan.repoRoots,
|
|
70
|
+
skippedOtherRepo: scan.skippedOtherRepo,
|
|
71
|
+
skippedUnknownCwd: scan.skippedUnknownCwd,
|
|
72
|
+
rawRetention: scan.rawRetention,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type AuditLimits, type RawRetention } from './limits.mts';
|
|
2
|
+
import type { ClassifyFailure, ClaudeDenialRecord, ClaudeEscalationRecord, ClaudeSandboxFailureRecord } from './types.mts';
|
|
3
|
+
export type ClaudeExtraction = {
|
|
4
|
+
escalations: ClaudeEscalationRecord[];
|
|
5
|
+
denials: ClaudeDenialRecord[];
|
|
6
|
+
sandboxFailures: ClaudeSandboxFailureRecord[];
|
|
7
|
+
rawRetention: RawRetention;
|
|
8
|
+
};
|
|
9
|
+
export type ClaudeRecordExtractor = {
|
|
10
|
+
pushLine: (line: string) => void;
|
|
11
|
+
result: () => ClaudeExtraction;
|
|
12
|
+
};
|
|
13
|
+
export type ClaudeExtractOptions = {
|
|
14
|
+
classifyFailure?: ClassifyFailure | undefined;
|
|
15
|
+
limits: AuditLimits;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Streams Claude transcript lines into escalation, denial and sandbox-failure records. A
|
|
19
|
+
* tool_use always precedes its tool_result in file order, so one forward pass correlates every
|
|
20
|
+
* result with its command. A malformed or partially written line never hides earlier records.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createClaudeRecordExtractor(options: ClaudeExtractOptions): ClaudeRecordExtractor;
|
|
23
|
+
export declare function extractClaudeRecords(lines: string[], options: ClaudeExtractOptions): ClaudeExtraction;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { asArray, asRecord } from "../retrospective-transcript/index.mjs";
|
|
2
|
+
import { recordClaudeToolUse } from "./claude-tool-uses.mjs";
|
|
3
|
+
import { classifyFailureText } from "./failure-text.mjs";
|
|
4
|
+
import { parseJsonRecord } from "./json-record.mjs";
|
|
5
|
+
import { appendBounded, emptyRawRetention, extractToolResultText, truncateRawText, } from "./limits.mjs";
|
|
6
|
+
const DENIAL_KINDS = ['user-rejected', 'permission-rule', 'automode-blocked'];
|
|
7
|
+
function isDenialKind(value) {
|
|
8
|
+
return typeof value === 'string' && DENIAL_KINDS.includes(value);
|
|
9
|
+
}
|
|
10
|
+
function recordToolResult(record, pending, out, options) {
|
|
11
|
+
const denialKind = isDenialKind(record.toolDenialKind) ? record.toolDenialKind : undefined;
|
|
12
|
+
for (const block of asArray(asRecord(record.message)?.content)) {
|
|
13
|
+
const value = asRecord(block);
|
|
14
|
+
if (!value || value.type !== 'tool_result')
|
|
15
|
+
continue;
|
|
16
|
+
const toolUseId = typeof value.tool_use_id === 'string' ? value.tool_use_id : undefined;
|
|
17
|
+
const toolUse = toolUseId ? pending.toolUses.get(toolUseId) : undefined;
|
|
18
|
+
if (toolUseId && toolUse) {
|
|
19
|
+
pending.toolUses.delete(toolUseId);
|
|
20
|
+
pending.bytes.value -= toolUse.bytes;
|
|
21
|
+
}
|
|
22
|
+
if (value.is_error !== true || toolUse?.name !== 'Bash')
|
|
23
|
+
continue;
|
|
24
|
+
const { rawRetention, denials, sandboxFailures } = out;
|
|
25
|
+
if (denialKind) {
|
|
26
|
+
const denial = { source: 'claude', kind: denialKind, command: toolUse.command };
|
|
27
|
+
appendBounded(denials, denial, rawRetention, options.limits);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const text = extractToolResultText(value.content);
|
|
31
|
+
const kind = classifyFailureText(toolUse.command, text, 'claude', options.classifyFailure);
|
|
32
|
+
if (!kind)
|
|
33
|
+
continue;
|
|
34
|
+
const errorText = truncateRawText(text, rawRetention, 'error', options.limits);
|
|
35
|
+
const failure = { source: 'claude', kind, command: toolUse.command, errorText };
|
|
36
|
+
appendBounded(sandboxFailures, failure, rawRetention, options.limits);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Streams Claude transcript lines into escalation, denial and sandbox-failure records. A
|
|
41
|
+
* tool_use always precedes its tool_result in file order, so one forward pass correlates every
|
|
42
|
+
* result with its command. A malformed or partially written line never hides earlier records.
|
|
43
|
+
*/
|
|
44
|
+
export function createClaudeRecordExtractor(options) {
|
|
45
|
+
const rawRetention = emptyRawRetention();
|
|
46
|
+
const out = { escalations: [], denials: [], sandboxFailures: [], rawRetention };
|
|
47
|
+
const pending = { toolUses: new Map(), bytes: { value: 0 } };
|
|
48
|
+
return {
|
|
49
|
+
pushLine(line) {
|
|
50
|
+
const record = parseJsonRecord(line);
|
|
51
|
+
if (record?.type === 'assistant') {
|
|
52
|
+
for (const block of asArray(asRecord(record.message)?.content)) {
|
|
53
|
+
const { toolUses, bytes } = pending;
|
|
54
|
+
const { escalations } = out;
|
|
55
|
+
recordClaudeToolUse(block, toolUses, escalations, rawRetention, bytes, options.limits);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (record?.type === 'user') {
|
|
59
|
+
recordToolResult(record, pending, out, options);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
result: () => {
|
|
63
|
+
const { escalations, denials, sandboxFailures } = out;
|
|
64
|
+
const result = { escalations, denials, sandboxFailures, rawRetention };
|
|
65
|
+
// Keep the enumerable JSON contract stable; the scanner reads this accounting field directly.
|
|
66
|
+
Object.defineProperty(result, 'rawRetention', { enumerable: false, value: rawRetention });
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export function extractClaudeRecords(lines, options) {
|
|
72
|
+
const extractor = createClaudeRecordExtractor(options);
|
|
73
|
+
for (const line of lines)
|
|
74
|
+
extractor.pushLine(line);
|
|
75
|
+
return extractor.result();
|
|
76
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AuditLimits, type RawRetention } from './limits.mts';
|
|
2
|
+
import type { ClaudeEscalationRecord } from './types.mts';
|
|
3
|
+
export type ToolUseInfo = {
|
|
4
|
+
name: string;
|
|
5
|
+
command?: string | undefined;
|
|
6
|
+
bytes: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Remembers a Claude tool_use so its later tool_result can be correlated to the command, and
|
|
10
|
+
* records an escalation when a Bash call asked to leave the sandbox. Pending state is bounded by
|
|
11
|
+
* `limits`; a block too large to hold is dropped (its escalation is still recorded).
|
|
12
|
+
*/
|
|
13
|
+
export declare function recordClaudeToolUse(block: unknown, toolUses: Map<string, ToolUseInfo>, escalations: ClaudeEscalationRecord[], retention: RawRetention, pendingBytes: {
|
|
14
|
+
value: number;
|
|
15
|
+
}, limits: AuditLimits): void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { asRecord } from "../retrospective-transcript/index.mjs";
|
|
2
|
+
import { appendBounded, truncateRawText } from "./limits.mjs";
|
|
3
|
+
function evict(toolUses, bytes, retention, pendingBytes, limits) {
|
|
4
|
+
while (toolUses.size >= limits.maxPendingToolUses ||
|
|
5
|
+
pendingBytes.value + bytes > limits.maxPendingToolUseBytes) {
|
|
6
|
+
const oldest = toolUses.keys().next().value;
|
|
7
|
+
if (oldest === undefined)
|
|
8
|
+
break;
|
|
9
|
+
const evicted = toolUses.get(oldest);
|
|
10
|
+
toolUses.delete(oldest);
|
|
11
|
+
pendingBytes.value -= evicted.bytes;
|
|
12
|
+
retention.pendingToolUsesDropped++;
|
|
13
|
+
retention.pendingToolUseBytesDropped += evicted.bytes;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Remembers a Claude tool_use so its later tool_result can be correlated to the command, and
|
|
18
|
+
* records an escalation when a Bash call asked to leave the sandbox. Pending state is bounded by
|
|
19
|
+
* `limits`; a block too large to hold is dropped (its escalation is still recorded).
|
|
20
|
+
*/
|
|
21
|
+
export function recordClaudeToolUse(block, toolUses, escalations, retention, pendingBytes, limits) {
|
|
22
|
+
const value = asRecord(block);
|
|
23
|
+
if (!value || (value.type !== 'tool_use' && value.type !== 'server_tool_use'))
|
|
24
|
+
return;
|
|
25
|
+
const id = typeof value.id === 'string' ? value.id : undefined;
|
|
26
|
+
const name = typeof value.name === 'string' ? value.name : undefined;
|
|
27
|
+
if (!id || !name)
|
|
28
|
+
return;
|
|
29
|
+
const input = asRecord(value.input);
|
|
30
|
+
const command = typeof input?.command === 'string' ? input.command : undefined;
|
|
31
|
+
const retainedCommand = command
|
|
32
|
+
? truncateRawText(command, retention, 'command', limits)
|
|
33
|
+
: undefined;
|
|
34
|
+
const bytes = Buffer.byteLength(id) + Buffer.byteLength(name) + Buffer.byteLength(retainedCommand ?? '');
|
|
35
|
+
const existing = toolUses.get(id);
|
|
36
|
+
if (existing) {
|
|
37
|
+
toolUses.delete(id);
|
|
38
|
+
pendingBytes.value -= existing.bytes;
|
|
39
|
+
}
|
|
40
|
+
const escalated = name === 'Bash' && command && input?.dangerouslyDisableSandbox === true;
|
|
41
|
+
if (bytes > limits.maxPendingToolUseBytes) {
|
|
42
|
+
retention.pendingToolUsesDropped++;
|
|
43
|
+
retention.pendingToolUseBytesDropped += bytes;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
evict(toolUses, bytes, retention, pendingBytes, limits);
|
|
47
|
+
toolUses.set(id, { name, command: retainedCommand, bytes });
|
|
48
|
+
pendingBytes.value += bytes;
|
|
49
|
+
}
|
|
50
|
+
if (escalated) {
|
|
51
|
+
appendBounded(escalations, { source: 'claude', command: retainedCommand }, retention, limits);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AuditLimits, type RawRetention } from './limits.mts';
|
|
2
|
+
import type { ClassifyFailure, CodexSandboxFailureRecord } from './types.mts';
|
|
3
|
+
export type CodexExtraction = {
|
|
4
|
+
sandboxFailures: CodexSandboxFailureRecord[];
|
|
5
|
+
rawRetention: RawRetention;
|
|
6
|
+
};
|
|
7
|
+
export type CodexRecordExtractor = {
|
|
8
|
+
pushLine: (line: string) => void;
|
|
9
|
+
result: () => CodexExtraction;
|
|
10
|
+
};
|
|
11
|
+
export type CodexExtractOptions = {
|
|
12
|
+
classifyFailure?: ClassifyFailure | undefined;
|
|
13
|
+
limits: AuditLimits;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Streams Codex transcript lines. Only completed CommandExecution items that the caller's
|
|
17
|
+
* `classifyFailure` rule claims are recorded: the generic permission signatures are not applied to
|
|
18
|
+
* Codex output.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createCodexRecordExtractor(options: CodexExtractOptions): CodexRecordExtractor;
|
|
21
|
+
export declare function extractCodexRecords(lines: string[], options: CodexExtractOptions): CodexExtraction;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { asRecord } from "../retrospective-transcript/index.mjs";
|
|
2
|
+
import { parseJsonRecord } from "./json-record.mjs";
|
|
3
|
+
import { appendBounded, emptyRawRetention, truncateRawText, } from "./limits.mjs";
|
|
4
|
+
// A CommandExecution item carries `command` as a string or as an argv array such as
|
|
5
|
+
// `["bash", "-lc", "<script>"]`; the command text is the last string.
|
|
6
|
+
function commandFromArguments(command) {
|
|
7
|
+
if (typeof command === 'string')
|
|
8
|
+
return command;
|
|
9
|
+
if (!Array.isArray(command))
|
|
10
|
+
return undefined;
|
|
11
|
+
return command.findLast((entry) => typeof entry === 'string');
|
|
12
|
+
}
|
|
13
|
+
function commandFromExecution(item) {
|
|
14
|
+
const direct = commandFromArguments(item.command);
|
|
15
|
+
if (direct !== undefined || !Array.isArray(item.parsed_cmd))
|
|
16
|
+
return direct;
|
|
17
|
+
for (const parsed of item.parsed_cmd) {
|
|
18
|
+
const record = asRecord(parsed);
|
|
19
|
+
if (typeof record?.cmd === 'string')
|
|
20
|
+
return record.cmd;
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
function outputFromExecution(item) {
|
|
25
|
+
if (typeof item.aggregated_output === 'string' && item.aggregated_output.length > 0) {
|
|
26
|
+
return item.aggregated_output;
|
|
27
|
+
}
|
|
28
|
+
return [item.stdout, item.stderr]
|
|
29
|
+
.filter((value) => typeof value === 'string' && value.length > 0)
|
|
30
|
+
.join('\n');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Streams Codex transcript lines. Only completed CommandExecution items that the caller's
|
|
34
|
+
* `classifyFailure` rule claims are recorded: the generic permission signatures are not applied to
|
|
35
|
+
* Codex output.
|
|
36
|
+
*/
|
|
37
|
+
export function createCodexRecordExtractor(options) {
|
|
38
|
+
const rawRetention = emptyRawRetention();
|
|
39
|
+
const sandboxFailures = [];
|
|
40
|
+
const { classifyFailure, limits } = options;
|
|
41
|
+
return {
|
|
42
|
+
pushLine(line) {
|
|
43
|
+
if (!classifyFailure)
|
|
44
|
+
return;
|
|
45
|
+
const record = parseJsonRecord(line);
|
|
46
|
+
const payload = asRecord(record?.payload);
|
|
47
|
+
const item = asRecord(payload?.item);
|
|
48
|
+
if (record?.type !== 'event_msg' || payload?.type !== 'item_completed')
|
|
49
|
+
return;
|
|
50
|
+
if (item?.type !== 'CommandExecution')
|
|
51
|
+
return;
|
|
52
|
+
const command = commandFromExecution(item);
|
|
53
|
+
const errorText = outputFromExecution(item);
|
|
54
|
+
const kind = classifyFailure(command, errorText, 'codex');
|
|
55
|
+
if (kind === undefined)
|
|
56
|
+
return;
|
|
57
|
+
const failure = {
|
|
58
|
+
source: 'codex',
|
|
59
|
+
kind,
|
|
60
|
+
command: command ? truncateRawText(command, rawRetention, 'command', limits) : undefined,
|
|
61
|
+
errorText: truncateRawText(errorText, rawRetention, 'error', limits),
|
|
62
|
+
};
|
|
63
|
+
appendBounded(sandboxFailures, failure, rawRetention, limits);
|
|
64
|
+
},
|
|
65
|
+
result: () => {
|
|
66
|
+
const result = { sandboxFailures, rawRetention };
|
|
67
|
+
Object.defineProperty(result, 'rawRetention', { enumerable: false, value: rawRetention });
|
|
68
|
+
return result;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function extractCodexRecords(lines, options) {
|
|
73
|
+
const extractor = createCodexRecordExtractor(options);
|
|
74
|
+
for (const line of lines)
|
|
75
|
+
extractor.pushLine(line);
|
|
76
|
+
return extractor.result();
|
|
77
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type CodexExtractOptions, type CodexExtraction } from './codex-extract.mts';
|
|
2
|
+
export type CodexFileResult = CodexExtraction | {
|
|
3
|
+
error: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Extracts records from one Codex transcript. A forked child repeats its parent's history before
|
|
7
|
+
* its first owned `task_started`; that prefix is spooled under `tempRoot` and dropped once the
|
|
8
|
+
* owned task starts. When no owned task is ever found the whole spool is replayed, deliberately
|
|
9
|
+
* over-counting rather than losing activity.
|
|
10
|
+
*/
|
|
11
|
+
export declare function scanCodexFile(file: string, tempRoot: string, options: CodexExtractOptions): Promise<CodexFileResult>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { asRecord, openTranscriptLines } from "../retrospective-transcript/index.mjs";
|
|
2
|
+
import { createCodexRecordExtractor, } from "./codex-extract.mjs";
|
|
3
|
+
import { createSpool } from "./codex-spool.mjs";
|
|
4
|
+
function inheritedSession(record) {
|
|
5
|
+
const payload = asRecord(record.payload);
|
|
6
|
+
return (asRecord(asRecord(payload?.source)?.subagent) !== undefined ||
|
|
7
|
+
typeof payload?.forked_from_id === 'string' ||
|
|
8
|
+
typeof payload?.parent_thread_id === 'string' ||
|
|
9
|
+
(typeof payload?.id === 'string' &&
|
|
10
|
+
typeof payload.session_id === 'string' &&
|
|
11
|
+
payload.id !== payload.session_id));
|
|
12
|
+
}
|
|
13
|
+
// started_at is epoch seconds or milliseconds. A millisecond value is compared against the exact
|
|
14
|
+
// session creation time, so an inherited task from earlier in the same second is not mistaken for
|
|
15
|
+
// an owned one; a seconds value can only be compared at second precision.
|
|
16
|
+
function ownedTaskStarted(line, sessionMs) {
|
|
17
|
+
try {
|
|
18
|
+
const record = asRecord(JSON.parse(line));
|
|
19
|
+
const payload = asRecord(record?.payload);
|
|
20
|
+
if (record?.type !== 'event_msg' || payload?.type !== 'task_started')
|
|
21
|
+
return false;
|
|
22
|
+
if (typeof payload.started_at !== 'number')
|
|
23
|
+
return false;
|
|
24
|
+
const inMillis = payload.started_at >= 1_000_000_000_000;
|
|
25
|
+
if (inMillis)
|
|
26
|
+
return payload.started_at >= sessionMs;
|
|
27
|
+
return payload.started_at >= Math.floor(sessionMs / 1000);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// The creation time of a forked child's session when its first record marks it inherited, else
|
|
34
|
+
// undefined (including for malformed metadata, which falls back to scanning the whole file).
|
|
35
|
+
function inheritedSessionMs(line) {
|
|
36
|
+
try {
|
|
37
|
+
const record = asRecord(JSON.parse(line));
|
|
38
|
+
if (record?.type !== 'session_meta' || !inheritedSession(record))
|
|
39
|
+
return undefined;
|
|
40
|
+
const timestamp = asRecord(record.payload)?.timestamp;
|
|
41
|
+
const timestampMs = typeof timestamp === 'string' ? Date.parse(timestamp) : Number.NaN;
|
|
42
|
+
return Number.isFinite(timestampMs) ? timestampMs : undefined;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Extracts records from one Codex transcript. A forked child repeats its parent's history before
|
|
50
|
+
* its first owned `task_started`; that prefix is spooled under `tempRoot` and dropped once the
|
|
51
|
+
* owned task starts. When no owned task is ever found the whole spool is replayed, deliberately
|
|
52
|
+
* over-counting rather than losing activity.
|
|
53
|
+
*/
|
|
54
|
+
export async function scanCodexFile(file, tempRoot, options) {
|
|
55
|
+
const opened = await openTranscriptLines(file);
|
|
56
|
+
if ('error' in opened)
|
|
57
|
+
return { error: opened.error };
|
|
58
|
+
const extractor = createCodexRecordExtractor(options);
|
|
59
|
+
let spool;
|
|
60
|
+
let sessionMs;
|
|
61
|
+
let first = true;
|
|
62
|
+
try {
|
|
63
|
+
for await (const line of opened.lines) {
|
|
64
|
+
if (first && line.trim()) {
|
|
65
|
+
first = false;
|
|
66
|
+
sessionMs = inheritedSessionMs(line);
|
|
67
|
+
if (sessionMs !== undefined) {
|
|
68
|
+
spool = await createSpool(tempRoot, options.limits.maxInheritedCodexSpoolBytes);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (spool === undefined || sessionMs === undefined) {
|
|
72
|
+
extractor.pushLine(line);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
await spool.write(line);
|
|
76
|
+
if (!ownedTaskStarted(line, sessionMs))
|
|
77
|
+
continue;
|
|
78
|
+
await spool.discard();
|
|
79
|
+
spool = undefined;
|
|
80
|
+
extractor.pushLine(line);
|
|
81
|
+
}
|
|
82
|
+
if (spool) {
|
|
83
|
+
await spool.close();
|
|
84
|
+
const replay = await openTranscriptLines(spool.path);
|
|
85
|
+
if ('error' in replay)
|
|
86
|
+
return { error: replay.error };
|
|
87
|
+
for await (const line of replay.lines)
|
|
88
|
+
extractor.pushLine(line);
|
|
89
|
+
}
|
|
90
|
+
return extractor.result();
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
return { error: err.message };
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
await spool?.discard();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Spool = {
|
|
2
|
+
path: string;
|
|
3
|
+
/** Appends one line; rejects once the byte limit is passed or the stream has failed. */
|
|
4
|
+
write: (line: string) => Promise<void>;
|
|
5
|
+
/** Flushes and closes the file, keeping it on disk for a replay. */
|
|
6
|
+
close: () => Promise<void>;
|
|
7
|
+
/** Closes the stream if open and deletes the spool directory. */
|
|
8
|
+
discard: () => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A temporary line spool for the history a forked Codex child inherits before its first owned
|
|
12
|
+
* task. It lives under `tempRoot` so a large inherited prefix never sits in memory.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createSpool(tempRoot: string, limitBytes: number): Promise<Spool>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createWriteStream } from 'node:fs';
|
|
2
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
3
|
+
import { once } from 'node:events';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { finished } from 'node:stream/promises';
|
|
6
|
+
function assertHealthy(writer) {
|
|
7
|
+
if (writer.errored)
|
|
8
|
+
throw writer.errored;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A temporary line spool for the history a forked Codex child inherits before its first owned
|
|
12
|
+
* task. It lives under `tempRoot` so a large inherited prefix never sits in memory.
|
|
13
|
+
*/
|
|
14
|
+
export async function createSpool(tempRoot, limitBytes) {
|
|
15
|
+
const dir = await mkdtemp(join(tempRoot, 'sandbox-audit-codex-'));
|
|
16
|
+
const path = join(dir, 'inherited.jsonl');
|
|
17
|
+
const writer = createWriteStream(path, { encoding: 'utf8' });
|
|
18
|
+
let bytes = 0;
|
|
19
|
+
let closed = false;
|
|
20
|
+
// An open failure surfaces from the first write or from close, through the stream's error.
|
|
21
|
+
writer.on('error', () => undefined);
|
|
22
|
+
return {
|
|
23
|
+
path,
|
|
24
|
+
async write(line) {
|
|
25
|
+
assertHealthy(writer);
|
|
26
|
+
bytes += Buffer.byteLength(line) + 1;
|
|
27
|
+
if (bytes > limitBytes) {
|
|
28
|
+
throw new Error(`inherited Codex spool exceeds ${limitBytes} byte limit`);
|
|
29
|
+
}
|
|
30
|
+
if (!writer.write(`${line}\n`))
|
|
31
|
+
await once(writer, 'drain');
|
|
32
|
+
},
|
|
33
|
+
async close() {
|
|
34
|
+
assertHealthy(writer);
|
|
35
|
+
writer.end();
|
|
36
|
+
await finished(writer);
|
|
37
|
+
closed = true;
|
|
38
|
+
assertHealthy(writer);
|
|
39
|
+
},
|
|
40
|
+
async discard() {
|
|
41
|
+
if (!closed)
|
|
42
|
+
writer.destroy();
|
|
43
|
+
await rm(dir, { recursive: true, force: true });
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { SkipCounts } from './types.mts';
|
|
2
|
+
export type DiscoverOptions = {
|
|
3
|
+
/** Root holding Claude project transcripts (`<root>/<project>/<session>.jsonl`). */
|
|
4
|
+
projectsDir: string;
|
|
5
|
+
/** Root holding Codex rollouts (`<root>/**\/rollout-*-<session>.jsonl`). */
|
|
6
|
+
codexSessionsDir: string;
|
|
7
|
+
/** Most-recent files kept per root, applied after repo scoping. */
|
|
8
|
+
maxFilesPerRoot: number;
|
|
9
|
+
/** Drops files last modified before `now - sinceDays`, before the cap. */
|
|
10
|
+
sinceDays?: number;
|
|
11
|
+
/** Clock for `sinceDays`; injected so tests use a fixed one. */
|
|
12
|
+
now?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Narrows discovery to one session's transcripts. An explicit session is already an exact
|
|
15
|
+
* target, so it bypasses repo scoping: it must never be lost to an unresolved cwd.
|
|
16
|
+
*/
|
|
17
|
+
sessionId?: string;
|
|
18
|
+
/** Roots to scope discovery to. Empty means unscoped (purely mtime-ordered). */
|
|
19
|
+
repoRoots: string[];
|
|
20
|
+
};
|
|
21
|
+
export type DiscoveredFiles = {
|
|
22
|
+
claudeFiles: string[];
|
|
23
|
+
codexFiles: string[];
|
|
24
|
+
skippedOtherRepo: SkipCounts;
|
|
25
|
+
skippedUnknownCwd: SkipCounts;
|
|
26
|
+
};
|
|
27
|
+
type StatEntry = {
|
|
28
|
+
path: string;
|
|
29
|
+
mtimeMs: number;
|
|
30
|
+
};
|
|
31
|
+
type ResolveCwd = (path: string) => Promise<string | undefined>;
|
|
32
|
+
type SelectResult = {
|
|
33
|
+
files: string[];
|
|
34
|
+
skippedOtherRepo: number;
|
|
35
|
+
skippedUnknownCwd: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Walks the newest-first list resolving each file's cwd and keeping in-repo files until `limit`.
|
|
39
|
+
* The skip counts are lower bounds, because the walk stops at `limit`. A file whose cwd cannot be
|
|
40
|
+
* resolved is excluded (fail closed) but always counted.
|
|
41
|
+
*/
|
|
42
|
+
export declare function selectInRepo(entries: StatEntry[], limit: number, repoRoots: string[], resolveCwd: ResolveCwd): Promise<SelectResult>;
|
|
43
|
+
export declare function discoverTranscriptFiles(options: DiscoverOptions): Promise<DiscoveredFiles>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { statSync } from 'node:fs';
|
|
2
|
+
import { globFrom } from "../retrospective-transcript/resolve-transcript-file.mjs";
|
|
3
|
+
import { isWithinRepoRoots } from "./repo-scope.mjs";
|
|
4
|
+
import { claudeSessionCwdResolver, readTranscriptCwd } from "./transcript-cwd.mjs";
|
|
5
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
6
|
+
// Stats every candidate, drops anything outside the window, and sorts newest first. The cap is
|
|
7
|
+
// applied later, after repo scoping: capping first would fill a small limit with other
|
|
8
|
+
// repositories' files.
|
|
9
|
+
function statAndSort(paths, cutoffMs) {
|
|
10
|
+
const entries = [];
|
|
11
|
+
for (const path of paths) {
|
|
12
|
+
try {
|
|
13
|
+
entries.push({ path, mtimeMs: statSync(path).mtimeMs });
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
// A file removed between glob and stat, or unreadable, is skipped: discovery is best-effort.
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const inWindow = entries.filter((entry) => cutoffMs === undefined || entry.mtimeMs >= cutoffMs);
|
|
20
|
+
return inWindow.toSorted((a, b) => b.mtimeMs - a.mtimeMs);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Walks the newest-first list resolving each file's cwd and keeping in-repo files until `limit`.
|
|
24
|
+
* The skip counts are lower bounds, because the walk stops at `limit`. A file whose cwd cannot be
|
|
25
|
+
* resolved is excluded (fail closed) but always counted.
|
|
26
|
+
*/
|
|
27
|
+
export async function selectInRepo(entries, limit, repoRoots, resolveCwd) {
|
|
28
|
+
const files = [];
|
|
29
|
+
let skippedOtherRepo = 0;
|
|
30
|
+
let skippedUnknownCwd = 0;
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
if (files.length >= limit)
|
|
33
|
+
break;
|
|
34
|
+
const cwd = await resolveCwd(entry.path).catch(() => undefined);
|
|
35
|
+
if (cwd === undefined) {
|
|
36
|
+
skippedUnknownCwd++;
|
|
37
|
+
}
|
|
38
|
+
else if (await isWithinRepoRoots(cwd, repoRoots)) {
|
|
39
|
+
files.push(entry.path);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
skippedOtherRepo++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { files, skippedOtherRepo, skippedUnknownCwd };
|
|
46
|
+
}
|
|
47
|
+
async function discoverForRoot(paths, options, resolveCwd) {
|
|
48
|
+
const cutoffMs = options.sinceDays === undefined
|
|
49
|
+
? undefined
|
|
50
|
+
: (options.now ?? Date.now()) - options.sinceDays * DAY_MS;
|
|
51
|
+
const sorted = statAndSort(paths, cutoffMs);
|
|
52
|
+
if (options.sessionId !== undefined || options.repoRoots.length === 0) {
|
|
53
|
+
const files = sorted.slice(0, options.maxFilesPerRoot).map((entry) => entry.path);
|
|
54
|
+
return { files, skippedOtherRepo: 0, skippedUnknownCwd: 0 };
|
|
55
|
+
}
|
|
56
|
+
return selectInRepo(sorted, options.maxFilesPerRoot, options.repoRoots, resolveCwd);
|
|
57
|
+
}
|
|
58
|
+
// Top-level session files and subagent transcripts share one JSONL schema, so one recursive glob
|
|
59
|
+
// finds both. A session id needs two precise patterns: `**/<id>*.jsonl` would also match
|
|
60
|
+
// unrelated sessions that share a prefix.
|
|
61
|
+
function claudePaths(options) {
|
|
62
|
+
const { projectsDir, sessionId } = options;
|
|
63
|
+
if (sessionId === undefined)
|
|
64
|
+
return globFrom(projectsDir, '**/*.jsonl');
|
|
65
|
+
return [
|
|
66
|
+
...globFrom(projectsDir, `**/${sessionId}.jsonl`),
|
|
67
|
+
...globFrom(projectsDir, `**/${sessionId}/subagents/*.jsonl`),
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
function codexPaths(options) {
|
|
71
|
+
const { codexSessionsDir, sessionId } = options;
|
|
72
|
+
return globFrom(codexSessionsDir, sessionId === undefined ? '**/*.jsonl' : `**/rollout-*-${sessionId}.jsonl`);
|
|
73
|
+
}
|
|
74
|
+
export async function discoverTranscriptFiles(options) {
|
|
75
|
+
const [claude, codex] = await Promise.all([
|
|
76
|
+
discoverForRoot(claudePaths(options), options, claudeSessionCwdResolver(options.projectsDir)),
|
|
77
|
+
discoverForRoot(codexPaths(options), options, readTranscriptCwd),
|
|
78
|
+
]);
|
|
79
|
+
return {
|
|
80
|
+
claudeFiles: claude.files,
|
|
81
|
+
codexFiles: codex.files,
|
|
82
|
+
skippedOtherRepo: { claude: claude.skippedOtherRepo, codex: codex.skippedOtherRepo },
|
|
83
|
+
skippedUnknownCwd: { claude: claude.skippedUnknownCwd, codex: codex.skippedUnknownCwd },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClassifyFailure, FailureKind } from './types.mts';
|
|
2
|
+
/**
|
|
3
|
+
* Sorts a failed Bash result into `e2big`, a caller-defined kind, `genuine`, or nothing. The
|
|
4
|
+
* caller's rule sits between the E2BIG check and the generic signatures, so it can claim a failure
|
|
5
|
+
* that would otherwise count as a genuine bypass candidate.
|
|
6
|
+
*/
|
|
7
|
+
export declare function classifyFailureText(command: string | undefined, text: string, source: 'claude' | 'codex', classify?: ClassifyFailure): FailureKind | undefined;
|