agent-inspect 3.5.4 → 4.0.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.
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Internal workspace manifest types (v4.0).
3
+ *
4
+ * @remarks
5
+ * Experimental and internal to `@agent-inspect/core`. This module is not part
6
+ * of any published entry point. Adding a public `agent-inspect/workspace`
7
+ * export is a separate, maintainer-gated step (see
8
+ * `docs/proposals/LOCAL-TRACE-WORKSPACE.md`).
9
+ */
10
+ /** Fixed manifest schema version for the v4.0 workspace model. */
11
+ declare const WORKSPACE_SCHEMA_VERSION: "1.0";
12
+ /** Standard workspace directory name at a project root. */
13
+ declare const WORKSPACE_DIR_NAME: ".agent-inspect";
14
+ /** Standard manifest filename inside {@link WORKSPACE_DIR_NAME}. */
15
+ declare const WORKSPACE_MANIFEST_FILENAME: "workspace.json";
16
+ /** Default share-safety posture applied to a workspace. */
17
+ type WorkspaceRedactionProfile = "local" | "share" | "strict";
18
+ /** Optional local index kind (SQLite index arrives as an opt-in package in v4.1). */
19
+ type WorkspaceIndexType = "none" | "sqlite" | "custom";
20
+ /** Optional local index descriptor. */
21
+ interface WorkspaceIndexConfig {
22
+ enabled: boolean;
23
+ type: WorkspaceIndexType;
24
+ path?: string;
25
+ }
26
+ /**
27
+ * The `.agent-inspect/workspace.json` manifest.
28
+ *
29
+ * @remarks
30
+ * All directory fields are paths relative to the workspace root and must
31
+ * resolve inside it (no absolute paths, no `..` traversal).
32
+ */
33
+ interface AgentInspectWorkspaceManifest {
34
+ schemaVersion: typeof WORKSPACE_SCHEMA_VERSION;
35
+ project: string;
36
+ createdAt: string;
37
+ traceDirs: string[];
38
+ reportsDir: string;
39
+ artifactsDir: string;
40
+ bundlesDir: string;
41
+ notesDir: string;
42
+ redactionProfile: WorkspaceRedactionProfile;
43
+ index: WorkspaceIndexConfig;
44
+ }
45
+ /** Result of validating unknown input against the manifest contract. */
46
+ interface WorkspaceManifestValidationResult {
47
+ ok: boolean;
48
+ manifest?: AgentInspectWorkspaceManifest;
49
+ errors: string[];
50
+ warnings: string[];
51
+ }
52
+
53
+ /**
54
+ * Internal workspace manifest validation + default generation (v4.0).
55
+ *
56
+ * @remarks
57
+ * Pure, non-throwing helpers. Validation is conservative: unknown or malformed
58
+ * input is rejected with clear messages rather than coerced. No filesystem or
59
+ * network access happens here (filesystem helpers arrive in a later chunk).
60
+ */
61
+ /** Default relative layout used when generating a fresh manifest. */
62
+ declare const DEFAULT_WORKSPACE_LAYOUT: {
63
+ readonly traceDirs: readonly ["runs"];
64
+ readonly reportsDir: "reports";
65
+ readonly artifactsDir: "artifacts";
66
+ readonly bundlesDir: "bundles";
67
+ readonly notesDir: "notes";
68
+ };
69
+ /** Upper bound on serialized manifest input accepted by {@link parseWorkspaceManifest}. */
70
+ declare const MAX_WORKSPACE_MANIFEST_BYTES: number;
71
+ /** Options for {@link createDefaultWorkspaceManifest}. */
72
+ interface CreateWorkspaceManifestOptions {
73
+ project: string;
74
+ createdAt?: string;
75
+ traceDirs?: string[];
76
+ reportsDir?: string;
77
+ artifactsDir?: string;
78
+ bundlesDir?: string;
79
+ notesDir?: string;
80
+ redactionProfile?: WorkspaceRedactionProfile;
81
+ index?: Partial<WorkspaceIndexConfig>;
82
+ }
83
+ /**
84
+ * Generates a default workspace manifest for a project using the standard
85
+ * layout. The returned object is always shape-valid.
86
+ */
87
+ declare function createDefaultWorkspaceManifest(options: CreateWorkspaceManifestOptions): AgentInspectWorkspaceManifest;
88
+ /**
89
+ * Returns true when `p` is a non-empty relative path that stays within the
90
+ * workspace root: no absolute paths, no `..` traversal, no Windows drive roots.
91
+ */
92
+ declare function isSafeRelativeWorkspacePath(p: unknown): p is string;
93
+ /**
94
+ * Conservatively validates unknown input against the workspace manifest
95
+ * contract. Never throws; returns a result with `ok`, the normalized
96
+ * `manifest` (when valid), `errors`, and non-fatal `warnings`.
97
+ */
98
+ declare function validateWorkspaceManifest(input: unknown): WorkspaceManifestValidationResult;
99
+ /**
100
+ * Safely parses a serialized manifest string and validates it. Bounds input
101
+ * size and rejects invalid JSON without throwing.
102
+ */
103
+ declare function parseWorkspaceManifest(json: string): WorkspaceManifestValidationResult;
104
+ /** Serializes a manifest to deterministic, pretty-printed JSON with a trailing newline. */
105
+ declare function serializeWorkspaceManifest(manifest: AgentInspectWorkspaceManifest): string;
106
+
107
+ /**
108
+ * Internal workspace filesystem helpers (v4.0).
109
+ *
110
+ * @remarks
111
+ * Local-only. Never deletes trace files. All manifest-derived paths are
112
+ * resolved and confirmed to stay within the workspace directory
113
+ * (path-traversal guarded). No network access.
114
+ */
115
+ /** Resolved on-disk location of a workspace. */
116
+ interface WorkspaceLocation {
117
+ /** Project directory that contains the `.agent-inspect` folder. */
118
+ projectRoot: string;
119
+ /** The `.agent-inspect` workspace directory (root for relative manifest paths). */
120
+ workspaceDir: string;
121
+ /** Absolute path to `workspace.json`. */
122
+ manifestPath: string;
123
+ }
124
+ /** Resolves the workspace location for a given project directory. */
125
+ declare function resolveWorkspaceLocation(cwd?: string): WorkspaceLocation;
126
+ /**
127
+ * Resolves a manifest-relative path against the workspace directory, rejecting
128
+ * any path that escapes it.
129
+ */
130
+ declare function resolveInsideWorkspace(workspaceDir: string, relative: string): string;
131
+ /** Result of reading a workspace manifest from disk. */
132
+ interface ReadWorkspaceManifestResult {
133
+ exists: boolean;
134
+ ok: boolean;
135
+ manifest?: AgentInspectWorkspaceManifest;
136
+ errors: string[];
137
+ warnings: string[];
138
+ }
139
+ /** Reads and validates `workspace.json` at the given location. Never throws. */
140
+ declare function readWorkspaceManifestFile(location: WorkspaceLocation): Promise<ReadWorkspaceManifestResult>;
141
+ /** Options for {@link createWorkspace}. */
142
+ interface CreateWorkspaceOptions {
143
+ cwd?: string;
144
+ project?: string;
145
+ redactionProfile?: WorkspaceRedactionProfile;
146
+ /** Preview only: do not write anything to disk. */
147
+ dryRun?: boolean;
148
+ }
149
+ /** Outcome of {@link createWorkspace}. */
150
+ interface CreateWorkspaceResult {
151
+ location: WorkspaceLocation;
152
+ manifest: AgentInspectWorkspaceManifest;
153
+ /** True when a fresh manifest was written. */
154
+ created: boolean;
155
+ /** True when an existing workspace/trace directory was adopted without rewrite. */
156
+ adopted: boolean;
157
+ /** Relative directories created (or that would be created in dry-run). */
158
+ createdDirs: string[];
159
+ /** True when top-level `.jsonl` traces were detected and preserved. */
160
+ detectedExistingTraces: boolean;
161
+ dryRun: boolean;
162
+ }
163
+ /**
164
+ * Creates or adopts a workspace. Never deletes or rewrites existing traces.
165
+ * When a manifest already exists it is adopted (missing folders are created,
166
+ * the manifest is left untouched).
167
+ */
168
+ declare function createWorkspace(options?: CreateWorkspaceOptions): Promise<CreateWorkspaceResult>;
169
+ /** Index presence/status for {@link getWorkspaceStatus}. */
170
+ interface WorkspaceIndexStatus {
171
+ enabled: boolean;
172
+ type: string;
173
+ exists: boolean;
174
+ }
175
+ /** Aggregate, read-only workspace status. */
176
+ interface WorkspaceStatus {
177
+ project: string;
178
+ traceFiles: number;
179
+ reports: number;
180
+ artifacts: number;
181
+ bundles: number;
182
+ notes: number;
183
+ index: WorkspaceIndexStatus;
184
+ }
185
+ /** Computes read-only counts for a workspace. Requires a valid manifest. */
186
+ declare function getWorkspaceStatus(location: WorkspaceLocation, manifest: AgentInspectWorkspaceManifest): Promise<WorkspaceStatus>;
187
+ /** A single workspace doctor check. */
188
+ interface WorkspaceDoctorCheck {
189
+ id: string;
190
+ status: "pass" | "warn" | "fail";
191
+ message: string;
192
+ }
193
+ /** Result of {@link doctorWorkspace}. */
194
+ interface WorkspaceDoctorResult {
195
+ ok: boolean;
196
+ checks: WorkspaceDoctorCheck[];
197
+ }
198
+ /**
199
+ * Validates a workspace: manifest presence/shape, folder permissions, trace
200
+ * readability, and index staleness. Read-only; never throws.
201
+ */
202
+ declare function doctorWorkspace(location: WorkspaceLocation): Promise<WorkspaceDoctorResult>;
203
+ /** Options for {@link cleanWorkspace}. */
204
+ interface CleanWorkspaceOptions {
205
+ /** Actually delete. When false (default), the operation is a dry-run. */
206
+ confirm?: boolean;
207
+ }
208
+ /** Result of {@link cleanWorkspace}. */
209
+ interface CleanWorkspaceResult {
210
+ dryRun: boolean;
211
+ /** Relative paths removed (or that would be removed in dry-run). */
212
+ removed: string[];
213
+ }
214
+ /**
215
+ * Removes generated workspace content (reports, artifacts, bundles, index).
216
+ * Dry-run by default; trace directories are never touched.
217
+ */
218
+ declare function cleanWorkspace(location: WorkspaceLocation, manifest: AgentInspectWorkspaceManifest, options?: CleanWorkspaceOptions): Promise<CleanWorkspaceResult>;
219
+
220
+ export { type AgentInspectWorkspaceManifest, type CleanWorkspaceOptions, type CleanWorkspaceResult, type CreateWorkspaceManifestOptions, type CreateWorkspaceOptions, type CreateWorkspaceResult, DEFAULT_WORKSPACE_LAYOUT, MAX_WORKSPACE_MANIFEST_BYTES, type ReadWorkspaceManifestResult, WORKSPACE_DIR_NAME, WORKSPACE_MANIFEST_FILENAME, WORKSPACE_SCHEMA_VERSION, type WorkspaceDoctorCheck, type WorkspaceDoctorResult, type WorkspaceIndexConfig, type WorkspaceIndexStatus, type WorkspaceIndexType, type WorkspaceLocation, type WorkspaceManifestValidationResult, type WorkspaceRedactionProfile, type WorkspaceStatus, cleanWorkspace, createDefaultWorkspaceManifest, createWorkspace, doctorWorkspace, getWorkspaceStatus, isSafeRelativeWorkspacePath, parseWorkspaceManifest, readWorkspaceManifestFile, resolveInsideWorkspace, resolveWorkspaceLocation, serializeWorkspaceManifest, validateWorkspaceManifest };
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Internal workspace manifest types (v4.0).
3
+ *
4
+ * @remarks
5
+ * Experimental and internal to `@agent-inspect/core`. This module is not part
6
+ * of any published entry point. Adding a public `agent-inspect/workspace`
7
+ * export is a separate, maintainer-gated step (see
8
+ * `docs/proposals/LOCAL-TRACE-WORKSPACE.md`).
9
+ */
10
+ /** Fixed manifest schema version for the v4.0 workspace model. */
11
+ declare const WORKSPACE_SCHEMA_VERSION: "1.0";
12
+ /** Standard workspace directory name at a project root. */
13
+ declare const WORKSPACE_DIR_NAME: ".agent-inspect";
14
+ /** Standard manifest filename inside {@link WORKSPACE_DIR_NAME}. */
15
+ declare const WORKSPACE_MANIFEST_FILENAME: "workspace.json";
16
+ /** Default share-safety posture applied to a workspace. */
17
+ type WorkspaceRedactionProfile = "local" | "share" | "strict";
18
+ /** Optional local index kind (SQLite index arrives as an opt-in package in v4.1). */
19
+ type WorkspaceIndexType = "none" | "sqlite" | "custom";
20
+ /** Optional local index descriptor. */
21
+ interface WorkspaceIndexConfig {
22
+ enabled: boolean;
23
+ type: WorkspaceIndexType;
24
+ path?: string;
25
+ }
26
+ /**
27
+ * The `.agent-inspect/workspace.json` manifest.
28
+ *
29
+ * @remarks
30
+ * All directory fields are paths relative to the workspace root and must
31
+ * resolve inside it (no absolute paths, no `..` traversal).
32
+ */
33
+ interface AgentInspectWorkspaceManifest {
34
+ schemaVersion: typeof WORKSPACE_SCHEMA_VERSION;
35
+ project: string;
36
+ createdAt: string;
37
+ traceDirs: string[];
38
+ reportsDir: string;
39
+ artifactsDir: string;
40
+ bundlesDir: string;
41
+ notesDir: string;
42
+ redactionProfile: WorkspaceRedactionProfile;
43
+ index: WorkspaceIndexConfig;
44
+ }
45
+ /** Result of validating unknown input against the manifest contract. */
46
+ interface WorkspaceManifestValidationResult {
47
+ ok: boolean;
48
+ manifest?: AgentInspectWorkspaceManifest;
49
+ errors: string[];
50
+ warnings: string[];
51
+ }
52
+
53
+ /**
54
+ * Internal workspace manifest validation + default generation (v4.0).
55
+ *
56
+ * @remarks
57
+ * Pure, non-throwing helpers. Validation is conservative: unknown or malformed
58
+ * input is rejected with clear messages rather than coerced. No filesystem or
59
+ * network access happens here (filesystem helpers arrive in a later chunk).
60
+ */
61
+ /** Default relative layout used when generating a fresh manifest. */
62
+ declare const DEFAULT_WORKSPACE_LAYOUT: {
63
+ readonly traceDirs: readonly ["runs"];
64
+ readonly reportsDir: "reports";
65
+ readonly artifactsDir: "artifacts";
66
+ readonly bundlesDir: "bundles";
67
+ readonly notesDir: "notes";
68
+ };
69
+ /** Upper bound on serialized manifest input accepted by {@link parseWorkspaceManifest}. */
70
+ declare const MAX_WORKSPACE_MANIFEST_BYTES: number;
71
+ /** Options for {@link createDefaultWorkspaceManifest}. */
72
+ interface CreateWorkspaceManifestOptions {
73
+ project: string;
74
+ createdAt?: string;
75
+ traceDirs?: string[];
76
+ reportsDir?: string;
77
+ artifactsDir?: string;
78
+ bundlesDir?: string;
79
+ notesDir?: string;
80
+ redactionProfile?: WorkspaceRedactionProfile;
81
+ index?: Partial<WorkspaceIndexConfig>;
82
+ }
83
+ /**
84
+ * Generates a default workspace manifest for a project using the standard
85
+ * layout. The returned object is always shape-valid.
86
+ */
87
+ declare function createDefaultWorkspaceManifest(options: CreateWorkspaceManifestOptions): AgentInspectWorkspaceManifest;
88
+ /**
89
+ * Returns true when `p` is a non-empty relative path that stays within the
90
+ * workspace root: no absolute paths, no `..` traversal, no Windows drive roots.
91
+ */
92
+ declare function isSafeRelativeWorkspacePath(p: unknown): p is string;
93
+ /**
94
+ * Conservatively validates unknown input against the workspace manifest
95
+ * contract. Never throws; returns a result with `ok`, the normalized
96
+ * `manifest` (when valid), `errors`, and non-fatal `warnings`.
97
+ */
98
+ declare function validateWorkspaceManifest(input: unknown): WorkspaceManifestValidationResult;
99
+ /**
100
+ * Safely parses a serialized manifest string and validates it. Bounds input
101
+ * size and rejects invalid JSON without throwing.
102
+ */
103
+ declare function parseWorkspaceManifest(json: string): WorkspaceManifestValidationResult;
104
+ /** Serializes a manifest to deterministic, pretty-printed JSON with a trailing newline. */
105
+ declare function serializeWorkspaceManifest(manifest: AgentInspectWorkspaceManifest): string;
106
+
107
+ /**
108
+ * Internal workspace filesystem helpers (v4.0).
109
+ *
110
+ * @remarks
111
+ * Local-only. Never deletes trace files. All manifest-derived paths are
112
+ * resolved and confirmed to stay within the workspace directory
113
+ * (path-traversal guarded). No network access.
114
+ */
115
+ /** Resolved on-disk location of a workspace. */
116
+ interface WorkspaceLocation {
117
+ /** Project directory that contains the `.agent-inspect` folder. */
118
+ projectRoot: string;
119
+ /** The `.agent-inspect` workspace directory (root for relative manifest paths). */
120
+ workspaceDir: string;
121
+ /** Absolute path to `workspace.json`. */
122
+ manifestPath: string;
123
+ }
124
+ /** Resolves the workspace location for a given project directory. */
125
+ declare function resolveWorkspaceLocation(cwd?: string): WorkspaceLocation;
126
+ /**
127
+ * Resolves a manifest-relative path against the workspace directory, rejecting
128
+ * any path that escapes it.
129
+ */
130
+ declare function resolveInsideWorkspace(workspaceDir: string, relative: string): string;
131
+ /** Result of reading a workspace manifest from disk. */
132
+ interface ReadWorkspaceManifestResult {
133
+ exists: boolean;
134
+ ok: boolean;
135
+ manifest?: AgentInspectWorkspaceManifest;
136
+ errors: string[];
137
+ warnings: string[];
138
+ }
139
+ /** Reads and validates `workspace.json` at the given location. Never throws. */
140
+ declare function readWorkspaceManifestFile(location: WorkspaceLocation): Promise<ReadWorkspaceManifestResult>;
141
+ /** Options for {@link createWorkspace}. */
142
+ interface CreateWorkspaceOptions {
143
+ cwd?: string;
144
+ project?: string;
145
+ redactionProfile?: WorkspaceRedactionProfile;
146
+ /** Preview only: do not write anything to disk. */
147
+ dryRun?: boolean;
148
+ }
149
+ /** Outcome of {@link createWorkspace}. */
150
+ interface CreateWorkspaceResult {
151
+ location: WorkspaceLocation;
152
+ manifest: AgentInspectWorkspaceManifest;
153
+ /** True when a fresh manifest was written. */
154
+ created: boolean;
155
+ /** True when an existing workspace/trace directory was adopted without rewrite. */
156
+ adopted: boolean;
157
+ /** Relative directories created (or that would be created in dry-run). */
158
+ createdDirs: string[];
159
+ /** True when top-level `.jsonl` traces were detected and preserved. */
160
+ detectedExistingTraces: boolean;
161
+ dryRun: boolean;
162
+ }
163
+ /**
164
+ * Creates or adopts a workspace. Never deletes or rewrites existing traces.
165
+ * When a manifest already exists it is adopted (missing folders are created,
166
+ * the manifest is left untouched).
167
+ */
168
+ declare function createWorkspace(options?: CreateWorkspaceOptions): Promise<CreateWorkspaceResult>;
169
+ /** Index presence/status for {@link getWorkspaceStatus}. */
170
+ interface WorkspaceIndexStatus {
171
+ enabled: boolean;
172
+ type: string;
173
+ exists: boolean;
174
+ }
175
+ /** Aggregate, read-only workspace status. */
176
+ interface WorkspaceStatus {
177
+ project: string;
178
+ traceFiles: number;
179
+ reports: number;
180
+ artifacts: number;
181
+ bundles: number;
182
+ notes: number;
183
+ index: WorkspaceIndexStatus;
184
+ }
185
+ /** Computes read-only counts for a workspace. Requires a valid manifest. */
186
+ declare function getWorkspaceStatus(location: WorkspaceLocation, manifest: AgentInspectWorkspaceManifest): Promise<WorkspaceStatus>;
187
+ /** A single workspace doctor check. */
188
+ interface WorkspaceDoctorCheck {
189
+ id: string;
190
+ status: "pass" | "warn" | "fail";
191
+ message: string;
192
+ }
193
+ /** Result of {@link doctorWorkspace}. */
194
+ interface WorkspaceDoctorResult {
195
+ ok: boolean;
196
+ checks: WorkspaceDoctorCheck[];
197
+ }
198
+ /**
199
+ * Validates a workspace: manifest presence/shape, folder permissions, trace
200
+ * readability, and index staleness. Read-only; never throws.
201
+ */
202
+ declare function doctorWorkspace(location: WorkspaceLocation): Promise<WorkspaceDoctorResult>;
203
+ /** Options for {@link cleanWorkspace}. */
204
+ interface CleanWorkspaceOptions {
205
+ /** Actually delete. When false (default), the operation is a dry-run. */
206
+ confirm?: boolean;
207
+ }
208
+ /** Result of {@link cleanWorkspace}. */
209
+ interface CleanWorkspaceResult {
210
+ dryRun: boolean;
211
+ /** Relative paths removed (or that would be removed in dry-run). */
212
+ removed: string[];
213
+ }
214
+ /**
215
+ * Removes generated workspace content (reports, artifacts, bundles, index).
216
+ * Dry-run by default; trace directories are never touched.
217
+ */
218
+ declare function cleanWorkspace(location: WorkspaceLocation, manifest: AgentInspectWorkspaceManifest, options?: CleanWorkspaceOptions): Promise<CleanWorkspaceResult>;
219
+
220
+ export { type AgentInspectWorkspaceManifest, type CleanWorkspaceOptions, type CleanWorkspaceResult, type CreateWorkspaceManifestOptions, type CreateWorkspaceOptions, type CreateWorkspaceResult, DEFAULT_WORKSPACE_LAYOUT, MAX_WORKSPACE_MANIFEST_BYTES, type ReadWorkspaceManifestResult, WORKSPACE_DIR_NAME, WORKSPACE_MANIFEST_FILENAME, WORKSPACE_SCHEMA_VERSION, type WorkspaceDoctorCheck, type WorkspaceDoctorResult, type WorkspaceIndexConfig, type WorkspaceIndexStatus, type WorkspaceIndexType, type WorkspaceLocation, type WorkspaceManifestValidationResult, type WorkspaceRedactionProfile, type WorkspaceStatus, cleanWorkspace, createDefaultWorkspaceManifest, createWorkspace, doctorWorkspace, getWorkspaceStatus, isSafeRelativeWorkspacePath, parseWorkspaceManifest, readWorkspaceManifestFile, resolveInsideWorkspace, resolveWorkspaceLocation, serializeWorkspaceManifest, validateWorkspaceManifest };