@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,12 @@
|
|
|
1
|
+
export type DebugErrorCode = "SESSION_EXISTS" | "DESTINATION_REQUIRED" | "NODE_UNSUPPORTED" | "STORAGE_UNAVAILABLE" | "NO_ACTIVE_SESSION" | "SESSION_OWNERSHIP_MISMATCH" | "STATE_MISSING" | "STATE_INVALID" | "STATE_VERSION_UNSUPPORTED" | "STALE_REVISION" | "STATE_TOO_LARGE" | "INVALID_PHASE" | "RUN_LIMIT" | "RUN_NOT_FOUND" | "PROBE_NOT_VALIDATED" | "COMMAND_REQUIRES_APPROVAL" | "PROCESS_START_FAILED" | "PROCESS_TIMEOUT" | "LOOPBACK_BIND_FAILED" | "COLLECTOR_EXISTS" | "HELPER_PATH_UNSAFE" | "UNSAFE_CAPTURE" | "UNSUPPORTED_LANGUAGE" | "COLLECTOR_REQUIRED" | "MARKER_MISSING" | "MARKER_MISMATCH" | "PERMISSION_MISMATCH" | "FILTER_INVALID" | "EVIDENCE_UNAVAILABLE" | "CLEANUP_PARTIAL" | "EXPORT_FAILED" | "INTERNAL_ERROR";
|
|
2
|
+
export type SafeErrorDetail = string | number | boolean;
|
|
3
|
+
export declare class DebugModeError extends Error {
|
|
4
|
+
readonly code: DebugErrorCode;
|
|
5
|
+
readonly retryable: boolean;
|
|
6
|
+
readonly action?: string;
|
|
7
|
+
readonly details?: Record<string, SafeErrorDetail>;
|
|
8
|
+
constructor(code: DebugErrorCode, message: string, retryable?: boolean, options?: {
|
|
9
|
+
action?: string;
|
|
10
|
+
details?: Record<string, SafeErrorDetail>;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DebugErrorCode, SafeErrorDetail } from "./errors.js";
|
|
2
|
+
export type ToolWarning = Readonly<{
|
|
3
|
+
code: string;
|
|
4
|
+
message: string;
|
|
5
|
+
}>;
|
|
6
|
+
export type ToolResultEnvelope<T> = {
|
|
7
|
+
ok: true;
|
|
8
|
+
data: T;
|
|
9
|
+
warnings: ToolWarning[];
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
error: {
|
|
13
|
+
code: DebugErrorCode;
|
|
14
|
+
message: string;
|
|
15
|
+
retryable: boolean;
|
|
16
|
+
action?: string;
|
|
17
|
+
details?: Record<string, SafeErrorDetail>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function success<T>(data: T, warnings?: ToolWarning[]): ToolResultEnvelope<T>;
|
|
21
|
+
export declare function failure(code: DebugErrorCode, message: string, retryable: boolean, options?: {
|
|
22
|
+
action?: string;
|
|
23
|
+
details?: Record<string, SafeErrorDetail>;
|
|
24
|
+
}): ToolResultEnvelope<never>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const OpaqueIdSchema: z.ZodString;
|
|
3
|
+
export declare const IsoTimestampSchema: z.ZodString;
|
|
4
|
+
export declare const HexSha256Schema: z.ZodString;
|
|
5
|
+
export declare const RunLabelSchema: z.ZodEnum<{
|
|
6
|
+
"post-fix": "post-fix";
|
|
7
|
+
"pre-fix": "pre-fix";
|
|
8
|
+
}>;
|
|
9
|
+
export type OpaqueId = z.infer<typeof OpaqueIdSchema>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type EvidenceEvent, type EvidenceFilter } from "./types.js";
|
|
2
|
+
export type EvidencePage = Readonly<{
|
|
3
|
+
events: EvidenceEvent[];
|
|
4
|
+
nextCursor: string | null;
|
|
5
|
+
trailingPartialLine: boolean;
|
|
6
|
+
invalidLines: number;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function readEvidence(filename: string, filter?: EvidenceFilter): Promise<EvidencePage>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsonValue, SanitizationFlag } from "./types.js";
|
|
2
|
+
export type SanitizeResult = Readonly<{
|
|
3
|
+
value: JsonValue;
|
|
4
|
+
flags: SanitizationFlag[];
|
|
5
|
+
droppedKeys: number;
|
|
6
|
+
originalBytes?: number;
|
|
7
|
+
storedBytes: number;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function sanitizeEvidenceData(input: unknown): SanitizeResult;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Clock } from "../core/clock.js";
|
|
3
|
+
import { type EvidenceCounters } from "../session/types.js";
|
|
4
|
+
import { type EvidenceEvent, type EvidenceFilter } from "./types.js";
|
|
5
|
+
declare const AppendEventSchema: z.ZodObject<{
|
|
6
|
+
eventId: z.ZodString;
|
|
7
|
+
timestamp: z.ZodString;
|
|
8
|
+
sessionId: z.ZodString;
|
|
9
|
+
runId: z.ZodString;
|
|
10
|
+
runLabel: z.ZodEnum<{
|
|
11
|
+
"post-fix": "post-fix";
|
|
12
|
+
"pre-fix": "pre-fix";
|
|
13
|
+
}>;
|
|
14
|
+
hypothesisId: z.ZodString;
|
|
15
|
+
probeId: z.ZodString;
|
|
16
|
+
kind: z.ZodString;
|
|
17
|
+
message: z.ZodString;
|
|
18
|
+
source: z.ZodObject<{
|
|
19
|
+
file: z.ZodString;
|
|
20
|
+
line: z.ZodNumber;
|
|
21
|
+
column: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
24
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export type EvidenceAppendInput = z.infer<typeof AppendEventSchema>;
|
|
27
|
+
export type CounterUpdate = (counters: EvidenceCounters) => void | Promise<void>;
|
|
28
|
+
export declare class EvidenceStore {
|
|
29
|
+
private readonly filename;
|
|
30
|
+
private readonly onCounters?;
|
|
31
|
+
private readonly clock;
|
|
32
|
+
private readonly loadCounters?;
|
|
33
|
+
private tail;
|
|
34
|
+
private currentBytes;
|
|
35
|
+
private initialized;
|
|
36
|
+
private readonly counters;
|
|
37
|
+
constructor(filename: string, onCounters?: CounterUpdate | undefined, clock?: Clock, loadCounters?: (() => Promise<EvidenceCounters>) | undefined);
|
|
38
|
+
append(input: EvidenceAppendInput, options?: {
|
|
39
|
+
sampled?: boolean;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
status: "accepted" | "sampled" | "dropped" | "rejected";
|
|
42
|
+
event?: EvidenceEvent;
|
|
43
|
+
}>;
|
|
44
|
+
read(filter?: EvidenceFilter): Promise<{
|
|
45
|
+
events: EvidenceEvent[];
|
|
46
|
+
nextCursor: string | null;
|
|
47
|
+
trailingPartialLine: boolean;
|
|
48
|
+
invalidLines: number;
|
|
49
|
+
counters: {
|
|
50
|
+
accepted: number;
|
|
51
|
+
rejected: number;
|
|
52
|
+
sampled: number;
|
|
53
|
+
truncated: number;
|
|
54
|
+
dropped: number;
|
|
55
|
+
requests: number;
|
|
56
|
+
};
|
|
57
|
+
}>;
|
|
58
|
+
snapshotCounters(): EvidenceCounters;
|
|
59
|
+
countRequest(): Promise<void>;
|
|
60
|
+
recordRejected(count?: number): Promise<void>;
|
|
61
|
+
private initialize;
|
|
62
|
+
private increment;
|
|
63
|
+
private exclusive;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
3
|
+
[key: string]: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
export declare const SourceLocationSchema: z.ZodObject<{
|
|
6
|
+
file: z.ZodString;
|
|
7
|
+
line: z.ZodNumber;
|
|
8
|
+
column: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
export declare const EventInputSchema: z.ZodObject<{
|
|
11
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
12
|
+
sessionId: z.ZodString;
|
|
13
|
+
runId: z.ZodString;
|
|
14
|
+
runLabel: z.ZodEnum<{
|
|
15
|
+
"post-fix": "post-fix";
|
|
16
|
+
"pre-fix": "pre-fix";
|
|
17
|
+
}>;
|
|
18
|
+
hypothesisId: z.ZodString;
|
|
19
|
+
probeId: z.ZodString;
|
|
20
|
+
timestamp: z.ZodString;
|
|
21
|
+
message: z.ZodString;
|
|
22
|
+
source: z.ZodObject<{
|
|
23
|
+
file: z.ZodString;
|
|
24
|
+
line: z.ZodNumber;
|
|
25
|
+
column: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
export declare const SanitizationFlagSchema: z.ZodEnum<{
|
|
30
|
+
binary: "binary";
|
|
31
|
+
cycle: "cycle";
|
|
32
|
+
redacted: "redacted";
|
|
33
|
+
truncated: "truncated";
|
|
34
|
+
unsupported: "unsupported";
|
|
35
|
+
}>;
|
|
36
|
+
export declare const EvidenceEventSchema: z.ZodObject<{
|
|
37
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
38
|
+
eventId: z.ZodString;
|
|
39
|
+
receivedAt: z.ZodString;
|
|
40
|
+
timestamp: z.ZodString;
|
|
41
|
+
sessionId: z.ZodString;
|
|
42
|
+
runId: z.ZodString;
|
|
43
|
+
runLabel: z.ZodEnum<{
|
|
44
|
+
"post-fix": "post-fix";
|
|
45
|
+
"pre-fix": "pre-fix";
|
|
46
|
+
}>;
|
|
47
|
+
hypothesisId: z.ZodString;
|
|
48
|
+
probeId: z.ZodString;
|
|
49
|
+
kind: z.ZodString;
|
|
50
|
+
message: z.ZodString;
|
|
51
|
+
data: z.ZodUnknown;
|
|
52
|
+
source: z.ZodObject<{
|
|
53
|
+
file: z.ZodString;
|
|
54
|
+
line: z.ZodNumber;
|
|
55
|
+
column: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
sanitization: z.ZodObject<{
|
|
58
|
+
flags: z.ZodArray<z.ZodEnum<{
|
|
59
|
+
binary: "binary";
|
|
60
|
+
cycle: "cycle";
|
|
61
|
+
redacted: "redacted";
|
|
62
|
+
truncated: "truncated";
|
|
63
|
+
unsupported: "unsupported";
|
|
64
|
+
}>>;
|
|
65
|
+
droppedKeys: z.ZodNumber;
|
|
66
|
+
originalBytes: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
storedBytes: z.ZodNumber;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
export type EventInput = z.infer<typeof EventInputSchema>;
|
|
71
|
+
export type EvidenceEvent = z.infer<typeof EvidenceEventSchema>;
|
|
72
|
+
export type SanitizationFlag = z.infer<typeof SanitizationFlagSchema>;
|
|
73
|
+
export type EvidenceFilter = Readonly<{
|
|
74
|
+
sessionId?: string;
|
|
75
|
+
runId?: string;
|
|
76
|
+
hypothesisId?: string;
|
|
77
|
+
probeId?: string;
|
|
78
|
+
from?: string;
|
|
79
|
+
to?: string;
|
|
80
|
+
keyword?: string;
|
|
81
|
+
cursor?: string;
|
|
82
|
+
limit?: number;
|
|
83
|
+
}>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDebugModePlugin, DebugModePlugin } from "./plugin.js";
|