@maximtop/opencode-debug-mode 0.1.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/ATTRIBUTION.md +5 -0
- package/CONTRIBUTING.md +48 -0
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/SECURITY.md +17 -0
- package/assets/debug-agent.md +71 -0
- package/dist/chunk-2PCBVVWX.js +20 -0
- package/dist/chunk-2PCBVVWX.js.map +1 -0
- package/dist/cleanup/export.d.ts +23 -0
- package/dist/cleanup/service.d.ts +33 -0
- package/dist/cleanup/types.d.ts +235 -0
- package/dist/collector/auth.d.ts +3 -0
- package/dist/collector/body.d.ts +7 -0
- package/dist/collector/ingest.d.ts +8 -0
- package/dist/collector/router.d.ts +8 -0
- package/dist/collector/server.d.ts +25 -0
- package/dist/core/clock.d.ts +5 -0
- package/dist/core/constants.d.ts +20 -0
- package/dist/core/errors.d.ts +12 -0
- package/dist/core/result.d.ts +24 -0
- package/dist/core/schemas.d.ts +9 -0
- package/dist/errors-IQTPGK5R.js +7 -0
- package/dist/errors-IQTPGK5R.js.map +1 -0
- package/dist/evidence/read.d.ts +8 -0
- package/dist/evidence/sanitize.d.ts +9 -0
- package/dist/evidence/store.d.ts +65 -0
- package/dist/evidence/types.d.ts +83 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3652 -0
- package/dist/index.js.map +1 -0
- package/dist/investigation/schema.d.ts +184 -0
- package/dist/investigation/store.d.ts +30 -0
- package/dist/plugin.d.ts +8 -0
- package/dist/probes/extension-permissions.d.ts +8 -0
- package/dist/probes/helper.d.ts +22 -0
- package/dist/probes/registry.d.ts +18 -0
- package/dist/probes/remove.d.ts +16 -0
- package/dist/probes/template.d.ts +21 -0
- package/dist/probes/types.d.ts +24 -0
- package/dist/process/line-decoder.d.ts +26 -0
- package/dist/process/protocol.d.ts +40 -0
- package/dist/process/service.d.ts +46 -0
- package/dist/process/tree.d.ts +16 -0
- package/dist/process-supervisor.js +276 -0
- package/dist/process-supervisor.js.map +1 -0
- package/dist/run/service.d.ts +21 -0
- package/dist/session/atomic-json.d.ts +1 -0
- package/dist/session/manifest-store.d.ts +22 -0
- package/dist/session/orphan-recovery.d.ts +16 -0
- package/dist/session/paths.d.ts +11 -0
- package/dist/session/registry.d.ts +48 -0
- package/dist/session/secret-store.d.ts +7 -0
- package/dist/session/types.d.ts +296 -0
- package/dist/tools/cleanup-tool.d.ts +4 -0
- package/dist/tools/collector-tools.d.ts +17 -0
- package/dist/tools/common.d.ts +4 -0
- package/dist/tools/evidence-tools.d.ts +4 -0
- package/dist/tools/index.d.ts +30 -0
- package/dist/tools/probe-tools.d.ts +5 -0
- package/dist/tools/run-tools.d.ts +12 -0
- package/dist/tools/session-tools.d.ts +4 -0
- package/dist/tools/state-tools.d.ts +4 -0
- package/docs/architecture.md +15 -0
- package/docs/lifecycle.md +11 -0
- package/examples/chrome-extension/background.js +5 -0
- package/examples/chrome-extension/content.js +3 -0
- package/examples/cli/run.mjs +3 -0
- package/examples/firefox-extension/background.js +4 -0
- package/examples/firefox-extension/content.js +3 -0
- package/examples/web/app.js +5 -0
- package/package.json +80 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const HypothesisSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
rank: z.ZodNumber;
|
|
5
|
+
statement: z.ZodString;
|
|
6
|
+
confirmationSignals: z.ZodArray<z.ZodString>;
|
|
7
|
+
eliminationSignals: z.ZodArray<z.ZodString>;
|
|
8
|
+
status: z.ZodEnum<{
|
|
9
|
+
confirmed: "confirmed";
|
|
10
|
+
eliminated: "eliminated";
|
|
11
|
+
open: "open";
|
|
12
|
+
}>;
|
|
13
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
14
|
+
invalidatedBy: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export declare const CompletedCheckSchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
summary: z.ZodString;
|
|
19
|
+
interpretation: z.ZodString;
|
|
20
|
+
conclusive: z.ZodBoolean;
|
|
21
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
22
|
+
completedAt: z.ZodString;
|
|
23
|
+
invalidatedBy: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export declare const RunReferenceSchema: z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
label: z.ZodEnum<{
|
|
28
|
+
"post-fix": "post-fix";
|
|
29
|
+
"pre-fix": "pre-fix";
|
|
30
|
+
}>;
|
|
31
|
+
status: z.ZodEnum<{
|
|
32
|
+
cancelled: "cancelled";
|
|
33
|
+
completed: "completed";
|
|
34
|
+
failed: "failed";
|
|
35
|
+
planned: "planned";
|
|
36
|
+
running: "running";
|
|
37
|
+
timed_out: "timed_out";
|
|
38
|
+
waiting: "waiting";
|
|
39
|
+
}>;
|
|
40
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
export declare const ProbeReferenceSchema: z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
runId: z.ZodString;
|
|
45
|
+
hypothesisId: z.ZodString;
|
|
46
|
+
sourceFile: z.ZodString;
|
|
47
|
+
status: z.ZodEnum<{
|
|
48
|
+
active: "active";
|
|
49
|
+
ambiguous: "ambiguous";
|
|
50
|
+
planned: "planned";
|
|
51
|
+
registered: "registered";
|
|
52
|
+
removed: "removed";
|
|
53
|
+
validated: "validated";
|
|
54
|
+
}>;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
export declare const DeveloperConfirmationSchema: z.ZodObject<{
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
statement: z.ZodString;
|
|
59
|
+
confirmedAt: z.ZodString;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
export declare const DecisionSchema: z.ZodObject<{
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
summary: z.ZodString;
|
|
64
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
65
|
+
decidedAt: z.ZodString;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
export declare const InvestigationStateSchema: z.ZodObject<{
|
|
68
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
69
|
+
revision: z.ZodNumber;
|
|
70
|
+
updatedAt: z.ZodString;
|
|
71
|
+
problemSummary: z.ZodString;
|
|
72
|
+
expectedBehavior: z.ZodString;
|
|
73
|
+
actualBehavior: z.ZodString;
|
|
74
|
+
runtimeContext: z.ZodObject<{
|
|
75
|
+
kind: z.ZodEnum<{
|
|
76
|
+
cli: "cli";
|
|
77
|
+
extension: "extension";
|
|
78
|
+
other: "other";
|
|
79
|
+
web: "web";
|
|
80
|
+
}>;
|
|
81
|
+
target: z.ZodString;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
reproduction: z.ZodObject<{
|
|
84
|
+
method: z.ZodString;
|
|
85
|
+
requiresUser: z.ZodBoolean;
|
|
86
|
+
confirmed: z.ZodNullable<z.ZodBoolean>;
|
|
87
|
+
}, z.core.$strict>;
|
|
88
|
+
successCriteria: z.ZodArray<z.ZodString>;
|
|
89
|
+
phase: z.ZodEnum<{
|
|
90
|
+
abandoned: "abandoned";
|
|
91
|
+
analyzing: "analyzing";
|
|
92
|
+
baseline: "baseline";
|
|
93
|
+
cleaning: "cleaning";
|
|
94
|
+
completed: "completed";
|
|
95
|
+
escalated: "escalated";
|
|
96
|
+
fixing: "fixing";
|
|
97
|
+
hypotheses: "hypotheses";
|
|
98
|
+
instrumenting: "instrumenting";
|
|
99
|
+
intake: "intake";
|
|
100
|
+
verifying: "verifying";
|
|
101
|
+
waiting_for_reproduction: "waiting_for_reproduction";
|
|
102
|
+
}>;
|
|
103
|
+
loopIteration: z.ZodNumber;
|
|
104
|
+
singleCauseEvidenceRef: z.ZodNullable<z.ZodString>;
|
|
105
|
+
hypotheses: z.ZodArray<z.ZodObject<{
|
|
106
|
+
id: z.ZodString;
|
|
107
|
+
rank: z.ZodNumber;
|
|
108
|
+
statement: z.ZodString;
|
|
109
|
+
confirmationSignals: z.ZodArray<z.ZodString>;
|
|
110
|
+
eliminationSignals: z.ZodArray<z.ZodString>;
|
|
111
|
+
status: z.ZodEnum<{
|
|
112
|
+
confirmed: "confirmed";
|
|
113
|
+
eliminated: "eliminated";
|
|
114
|
+
open: "open";
|
|
115
|
+
}>;
|
|
116
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
117
|
+
invalidatedBy: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, z.core.$strict>>;
|
|
119
|
+
completedChecks: z.ZodArray<z.ZodObject<{
|
|
120
|
+
id: z.ZodString;
|
|
121
|
+
summary: z.ZodString;
|
|
122
|
+
interpretation: z.ZodString;
|
|
123
|
+
conclusive: z.ZodBoolean;
|
|
124
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
125
|
+
completedAt: z.ZodString;
|
|
126
|
+
invalidatedBy: z.ZodOptional<z.ZodString>;
|
|
127
|
+
}, z.core.$strict>>;
|
|
128
|
+
runs: z.ZodArray<z.ZodObject<{
|
|
129
|
+
id: z.ZodString;
|
|
130
|
+
label: z.ZodEnum<{
|
|
131
|
+
"post-fix": "post-fix";
|
|
132
|
+
"pre-fix": "pre-fix";
|
|
133
|
+
}>;
|
|
134
|
+
status: z.ZodEnum<{
|
|
135
|
+
cancelled: "cancelled";
|
|
136
|
+
completed: "completed";
|
|
137
|
+
failed: "failed";
|
|
138
|
+
planned: "planned";
|
|
139
|
+
running: "running";
|
|
140
|
+
timed_out: "timed_out";
|
|
141
|
+
waiting: "waiting";
|
|
142
|
+
}>;
|
|
143
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
144
|
+
}, z.core.$strict>>;
|
|
145
|
+
probeRefs: z.ZodArray<z.ZodObject<{
|
|
146
|
+
id: z.ZodString;
|
|
147
|
+
runId: z.ZodString;
|
|
148
|
+
hypothesisId: z.ZodString;
|
|
149
|
+
sourceFile: z.ZodString;
|
|
150
|
+
status: z.ZodEnum<{
|
|
151
|
+
active: "active";
|
|
152
|
+
ambiguous: "ambiguous";
|
|
153
|
+
planned: "planned";
|
|
154
|
+
registered: "registered";
|
|
155
|
+
removed: "removed";
|
|
156
|
+
validated: "validated";
|
|
157
|
+
}>;
|
|
158
|
+
}, z.core.$strict>>;
|
|
159
|
+
decidingEvidenceIds: z.ZodArray<z.ZodString>;
|
|
160
|
+
developerConfirmations: z.ZodArray<z.ZodObject<{
|
|
161
|
+
id: z.ZodString;
|
|
162
|
+
statement: z.ZodString;
|
|
163
|
+
confirmedAt: z.ZodString;
|
|
164
|
+
}, z.core.$strict>>;
|
|
165
|
+
decisions: z.ZodArray<z.ZodObject<{
|
|
166
|
+
id: z.ZodString;
|
|
167
|
+
summary: z.ZodString;
|
|
168
|
+
evidenceRefs: z.ZodArray<z.ZodString>;
|
|
169
|
+
decidedAt: z.ZodString;
|
|
170
|
+
}, z.core.$strict>>;
|
|
171
|
+
nextAction: z.ZodString;
|
|
172
|
+
instrumentedFiles: z.ZodArray<z.ZodString>;
|
|
173
|
+
fixedFiles: z.ZodArray<z.ZodString>;
|
|
174
|
+
cleanup: z.ZodObject<{
|
|
175
|
+
status: z.ZodEnum<{
|
|
176
|
+
complete: "complete";
|
|
177
|
+
not_started: "not_started";
|
|
178
|
+
partial: "partial";
|
|
179
|
+
running: "running";
|
|
180
|
+
}>;
|
|
181
|
+
completedResources: z.ZodArray<z.ZodString>;
|
|
182
|
+
}, z.core.$strict>;
|
|
183
|
+
}, z.core.$strict>;
|
|
184
|
+
export type InvestigationState = z.infer<typeof InvestigationStateSchema>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Clock } from "../core/clock.js";
|
|
2
|
+
import { type InvestigationState } from "./schema.js";
|
|
3
|
+
export type StateRecoveryResult = {
|
|
4
|
+
ok: true;
|
|
5
|
+
state: InvestigationState;
|
|
6
|
+
warnings: string[];
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
error: {
|
|
10
|
+
code: "STATE_MISSING" | "STATE_INVALID" | "STATE_VERSION_UNSUPPORTED";
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function initialInvestigationState(now: string): InvestigationState;
|
|
15
|
+
export declare class InvestigationStore {
|
|
16
|
+
private readonly filename;
|
|
17
|
+
private readonly clock;
|
|
18
|
+
private tail;
|
|
19
|
+
constructor(filename: string, clock?: Clock);
|
|
20
|
+
create(state: InvestigationState): Promise<number>;
|
|
21
|
+
read(): Promise<InvestigationState>;
|
|
22
|
+
readRecovery(): Promise<StateRecoveryResult>;
|
|
23
|
+
checkpoint(expectedRevision: number, state: InvestigationState): Promise<{
|
|
24
|
+
state: InvestigationState;
|
|
25
|
+
bytes: number;
|
|
26
|
+
}>;
|
|
27
|
+
private validate;
|
|
28
|
+
private write;
|
|
29
|
+
private exclusive;
|
|
30
|
+
}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Plugin } from "@opencode-ai/plugin";
|
|
2
|
+
import type { Clock } from "./core/clock.js";
|
|
3
|
+
export type DebugModePluginOptions = Readonly<{
|
|
4
|
+
clock?: Clock;
|
|
5
|
+
tempBase?: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function createDebugModePlugin(options?: DebugModePluginOptions): Plugin;
|
|
8
|
+
export declare const DebugModePlugin: Plugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { PermissionChangeSchema } from "../session/types.js";
|
|
3
|
+
export type PermissionChange = z.infer<typeof PermissionChangeSchema>;
|
|
4
|
+
export declare function addLoopbackPermission(manifestPath: string, matchPattern: string): Promise<PermissionChange>;
|
|
5
|
+
export declare function removeLoopbackPermission(manifestPath: string, change: PermissionChange): Promise<{
|
|
6
|
+
status: "success" | "already-clean" | "failed";
|
|
7
|
+
reason?: string;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type TransportHelperResult = Readonly<{
|
|
2
|
+
relativePath: string;
|
|
3
|
+
requiredImport: string;
|
|
4
|
+
sha256: string;
|
|
5
|
+
bytes: number;
|
|
6
|
+
}>;
|
|
7
|
+
export declare class TransportHelper {
|
|
8
|
+
private readonly projectRoot;
|
|
9
|
+
private readonly recordOwnedFile?;
|
|
10
|
+
constructor(projectRoot: string, recordOwnedFile?: ((value: {
|
|
11
|
+
path: string;
|
|
12
|
+
sha256: string;
|
|
13
|
+
bytes: number;
|
|
14
|
+
}) => void | Promise<void>) | undefined);
|
|
15
|
+
create(options: {
|
|
16
|
+
targetPath: string;
|
|
17
|
+
host: "127.0.0.1" | "::1";
|
|
18
|
+
port: number;
|
|
19
|
+
token: string;
|
|
20
|
+
runtime: "web" | "extension-background";
|
|
21
|
+
}): Promise<TransportHelperResult>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EventInput } from "../evidence/types.js";
|
|
2
|
+
import type { ManifestStore } from "../session/manifest-store.js";
|
|
3
|
+
import type { ManifestProbe } from "../session/types.js";
|
|
4
|
+
import { type ProbePlanInput } from "./types.js";
|
|
5
|
+
export declare class ProbeRegistry {
|
|
6
|
+
private readonly store;
|
|
7
|
+
private readonly projectRoot;
|
|
8
|
+
private readonly hasHypothesis;
|
|
9
|
+
constructor(store: ManifestStore, projectRoot: string, hasHypothesis: (id: string) => Promise<boolean>);
|
|
10
|
+
plan(input: ProbePlanInput): Promise<ManifestProbe & {
|
|
11
|
+
markerBlock: string;
|
|
12
|
+
}>;
|
|
13
|
+
register(id: string): Promise<ManifestProbe>;
|
|
14
|
+
validate(probeIds: string[]): Promise<void>;
|
|
15
|
+
requireValidatedForRun(runId: string): Promise<void>;
|
|
16
|
+
validateEvent(input: EventInput): Promise<EventInput>;
|
|
17
|
+
private update;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ManifestProbe } from "../session/types.js";
|
|
2
|
+
export type ProbeRemovalResult = {
|
|
3
|
+
status: "success";
|
|
4
|
+
file: string;
|
|
5
|
+
reason?: never;
|
|
6
|
+
} | {
|
|
7
|
+
status: "already-clean";
|
|
8
|
+
file: string;
|
|
9
|
+
reason?: never;
|
|
10
|
+
} | {
|
|
11
|
+
status: "failed";
|
|
12
|
+
file: string;
|
|
13
|
+
reason: string;
|
|
14
|
+
line?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare function removeOwnedProbe(probe: ManifestProbe): Promise<ProbeRemovalResult>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ProbeSampling, type ProbeTransport } from "./types.js";
|
|
2
|
+
export type ProbeTemplateInput = Readonly<{
|
|
3
|
+
sessionId: string;
|
|
4
|
+
runId: string;
|
|
5
|
+
runLabel: "pre-fix" | "post-fix";
|
|
6
|
+
hypothesisId: string;
|
|
7
|
+
probeId: string;
|
|
8
|
+
sourceFile: string;
|
|
9
|
+
sourceLine: number;
|
|
10
|
+
message: string;
|
|
11
|
+
captures: Array<{
|
|
12
|
+
label: string;
|
|
13
|
+
path: string;
|
|
14
|
+
}>;
|
|
15
|
+
transport: ProbeTransport;
|
|
16
|
+
sampling: ProbeSampling;
|
|
17
|
+
contentAdapter?: "chrome.runtime.sendMessage" | "browser.runtime.sendMessage" | "wrapper.sendMessage";
|
|
18
|
+
}>;
|
|
19
|
+
export declare function createProbeTemplate(input: ProbeTemplateInput): {
|
|
20
|
+
markerBlock: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const SAFE_CAPTURE: RegExp;
|
|
2
|
+
export type ProbeTransport = "process" | "http-web" | "extension-background" | "extension-content";
|
|
3
|
+
export type ProbeSampling = {
|
|
4
|
+
mode: "every";
|
|
5
|
+
n: number;
|
|
6
|
+
} | {
|
|
7
|
+
mode: "aggregate";
|
|
8
|
+
windowMs: number;
|
|
9
|
+
};
|
|
10
|
+
export type ProbePlanInput = Readonly<{
|
|
11
|
+
runId: string;
|
|
12
|
+
hypothesisId: string;
|
|
13
|
+
sourceFile: string;
|
|
14
|
+
sourceLine: number;
|
|
15
|
+
sourceColumn?: number;
|
|
16
|
+
message: string;
|
|
17
|
+
captures: Array<{
|
|
18
|
+
label: string;
|
|
19
|
+
path: string;
|
|
20
|
+
}>;
|
|
21
|
+
transport: ProbeTransport;
|
|
22
|
+
sampling: ProbeSampling;
|
|
23
|
+
markerBlock?: string;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ProcessStream = "stdout" | "stderr";
|
|
2
|
+
export type DecodedProcessRecord = {
|
|
3
|
+
kind: "output";
|
|
4
|
+
stream: ProcessStream;
|
|
5
|
+
text: string;
|
|
6
|
+
rejectedProbe?: boolean;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "probe-candidate";
|
|
9
|
+
stream: ProcessStream;
|
|
10
|
+
value: unknown;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "truncated";
|
|
13
|
+
stream: ProcessStream;
|
|
14
|
+
maximumBytes: number;
|
|
15
|
+
};
|
|
16
|
+
export declare class ProcessLineDecoder {
|
|
17
|
+
private readonly options;
|
|
18
|
+
private readonly streams;
|
|
19
|
+
constructor(options: {
|
|
20
|
+
maxLineBytes: number;
|
|
21
|
+
});
|
|
22
|
+
push(stream: ProcessStream, chunk: Buffer): DecodedProcessRecord[];
|
|
23
|
+
flush(stream: ProcessStream): DecodedProcessRecord[];
|
|
24
|
+
private consume;
|
|
25
|
+
private decodeLine;
|
|
26
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ParentMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"start">;
|
|
4
|
+
executable: z.ZodString;
|
|
5
|
+
args: z.ZodArray<z.ZodString>;
|
|
6
|
+
cwd: z.ZodString;
|
|
7
|
+
env: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
8
|
+
timeoutMs: z.ZodNumber;
|
|
9
|
+
ownerNonce: z.ZodString;
|
|
10
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11
|
+
type: z.ZodLiteral<"terminate">;
|
|
12
|
+
reason: z.ZodString;
|
|
13
|
+
}, z.core.$strict>], "type">;
|
|
14
|
+
export declare const ChildMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
15
|
+
type: z.ZodLiteral<"ready">;
|
|
16
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
17
|
+
type: z.ZodLiteral<"started">;
|
|
18
|
+
targetPid: z.ZodNumber;
|
|
19
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<"result">;
|
|
21
|
+
targetPid: z.ZodNumber;
|
|
22
|
+
exitCode: z.ZodNullable<z.ZodNumber>;
|
|
23
|
+
signal: z.ZodNullable<z.ZodString>;
|
|
24
|
+
timedOut: z.ZodBoolean;
|
|
25
|
+
termination: z.ZodOptional<z.ZodObject<{
|
|
26
|
+
graceful: z.ZodBoolean;
|
|
27
|
+
forced: z.ZodBoolean;
|
|
28
|
+
remaining: z.ZodBoolean;
|
|
29
|
+
durationMs: z.ZodNumber;
|
|
30
|
+
errors: z.ZodArray<z.ZodString>;
|
|
31
|
+
}, z.core.$strict>>;
|
|
32
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"failure">;
|
|
34
|
+
code: z.ZodString;
|
|
35
|
+
message: z.ZodString;
|
|
36
|
+
}, z.core.$strict>], "type">;
|
|
37
|
+
export type ParentMessage = z.infer<typeof ParentMessageSchema>;
|
|
38
|
+
export type ChildMessage = z.infer<typeof ChildMessageSchema>;
|
|
39
|
+
export declare function parseParentMessage(value: unknown): ParentMessage;
|
|
40
|
+
export declare function parseChildMessage(value: unknown): ChildMessage;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Clock } from "../core/clock.js";
|
|
2
|
+
import type { EvidenceStore } from "../evidence/store.js";
|
|
3
|
+
import type { ProbeRegistry } from "../probes/registry.js";
|
|
4
|
+
import type { RunService } from "../run/service.js";
|
|
5
|
+
import type { DebugSession } from "../session/registry.js";
|
|
6
|
+
export type ProcessCaptureInput = Readonly<{
|
|
7
|
+
runId: string;
|
|
8
|
+
executable: string;
|
|
9
|
+
args: string[];
|
|
10
|
+
cwd: string;
|
|
11
|
+
env: Record<string, string>;
|
|
12
|
+
timeoutMs: number;
|
|
13
|
+
probeIds?: string[];
|
|
14
|
+
purpose?: "instrumentation-check" | "reproduction" | "verification";
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}>;
|
|
17
|
+
export type ProcessCaptureResult = Readonly<{
|
|
18
|
+
processId: string;
|
|
19
|
+
runId: string;
|
|
20
|
+
exitCode: number | null;
|
|
21
|
+
signal: string | null;
|
|
22
|
+
timedOut: boolean;
|
|
23
|
+
durationMs: number;
|
|
24
|
+
stdoutEvents: number;
|
|
25
|
+
stderrEvents: number;
|
|
26
|
+
probeEvents: number;
|
|
27
|
+
}>;
|
|
28
|
+
export declare class ProcessService {
|
|
29
|
+
private readonly dependencies;
|
|
30
|
+
constructor(dependencies: {
|
|
31
|
+
session: DebugSession;
|
|
32
|
+
runs: RunService;
|
|
33
|
+
evidence: EvidenceStore;
|
|
34
|
+
acquireLease: () => Promise<() => void>;
|
|
35
|
+
probes?: ProbeRegistry;
|
|
36
|
+
supervisorPath?: string;
|
|
37
|
+
clock?: Clock;
|
|
38
|
+
});
|
|
39
|
+
capture(input: ProcessCaptureInput): Promise<ProcessCaptureResult>;
|
|
40
|
+
private persistRecord;
|
|
41
|
+
private addOwnedProcess;
|
|
42
|
+
private markStarted;
|
|
43
|
+
private markCompleted;
|
|
44
|
+
private updateManifest;
|
|
45
|
+
private waitForMessage;
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Execute = (executable: string, args: string[]) => Promise<{
|
|
2
|
+
exitCode: number | null;
|
|
3
|
+
}>;
|
|
4
|
+
export type TerminationResult = Readonly<{
|
|
5
|
+
graceful: boolean;
|
|
6
|
+
forced: boolean;
|
|
7
|
+
remaining: boolean;
|
|
8
|
+
durationMs: number;
|
|
9
|
+
errors: string[];
|
|
10
|
+
}>;
|
|
11
|
+
export declare function terminateTree(targetPid: number, options?: {
|
|
12
|
+
platform?: NodeJS.Platform;
|
|
13
|
+
execute?: Execute;
|
|
14
|
+
gracefulMs?: number;
|
|
15
|
+
forceMs?: number;
|
|
16
|
+
}): Promise<TerminationResult>;
|