@agent-inspect/studio 6.31.35 → 6.31.37

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/dist/index.cjs DELETED
@@ -1,2341 +0,0 @@
1
- 'use strict';
2
-
3
- var promises = require('fs/promises');
4
- var path10 = require('path');
5
- var advanced = require('agent-inspect/advanced');
6
- var workspace = require('agent-inspect/workspace');
7
- var fs = require('fs');
8
- var module$1 = require('module');
9
- var crypto = require('crypto');
10
- var http = require('http');
11
- var checks = require('agent-inspect/checks');
12
- var diff = require('agent-inspect/diff');
13
- var persisted = require('agent-inspect/persisted');
14
- var readers = require('agent-inspect/readers');
15
-
16
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
17
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
18
-
19
- var path10__default = /*#__PURE__*/_interopDefault(path10);
20
-
21
- // packages/studio/src/registry.ts
22
- function isSafeRelativePath(p) {
23
- const trimmed = p.trim();
24
- if (trimmed === "" || trimmed.startsWith("/") || trimmed.startsWith("\\")) return false;
25
- if (/^[a-zA-Z]:/.test(trimmed)) return false;
26
- return !trimmed.split(/[/\\]+/).some((seg) => seg === "..");
27
- }
28
- function resolveUnderRoot(root, ...segments) {
29
- const resolvedRoot = path10__default.default.resolve(root);
30
- const resolved = path10__default.default.resolve(resolvedRoot, ...segments);
31
- assertPathUnderRoot(resolved, resolvedRoot);
32
- return resolved;
33
- }
34
- function assertPathUnderRoot(resolved, root) {
35
- const rel = path10__default.default.relative(path10__default.default.resolve(root), path10__default.default.resolve(resolved));
36
- if (rel.startsWith("..") || path10__default.default.isAbsolute(rel)) {
37
- throw new Error("path escapes allowed registry root");
38
- }
39
- }
40
-
41
- // packages/studio/src/registry.ts
42
- var STUDIO_REGISTRY_SCHEMA_VERSION = "1.0";
43
- var STUDIO_REGISTRY_FILENAMES = [
44
- "studio-registry.json",
45
- ".agent-inspect/studio-registry.json"
46
- ];
47
- var MAX_REGISTRY_BYTES = 256 * 1024;
48
- function isPlainObject(value) {
49
- return typeof value === "object" && value !== null && !Array.isArray(value);
50
- }
51
- function parseStudioRegistry(input) {
52
- const errors = [];
53
- if (!isPlainObject(input)) {
54
- return { ok: false, errors: ["registry must be a JSON object"], warnings: [] };
55
- }
56
- if (input.schemaVersion !== STUDIO_REGISTRY_SCHEMA_VERSION) {
57
- errors.push(`schemaVersion must be "${STUDIO_REGISTRY_SCHEMA_VERSION}"`);
58
- }
59
- if (typeof input.name !== "string" || input.name.trim() === "") {
60
- errors.push("name must be a non-empty string");
61
- }
62
- if (!Array.isArray(input.projects) || input.projects.length === 0) {
63
- errors.push("projects must be a non-empty array");
64
- }
65
- const projects = [];
66
- if (Array.isArray(input.projects)) {
67
- for (const [index, item] of input.projects.entries()) {
68
- if (!isPlainObject(item)) {
69
- errors.push(`projects[${index}] must be an object`);
70
- continue;
71
- }
72
- const id = typeof item.id === "string" ? item.id.trim() : "";
73
- const projectPath = typeof item.path === "string" ? item.path.trim() : "";
74
- if (!id) errors.push(`projects[${index}].id must be a non-empty string`);
75
- if (!projectPath) errors.push(`projects[${index}].path must be a non-empty string`);
76
- const label = typeof item.label === "string" ? item.label.trim() : void 0;
77
- const suiteConfigs = Array.isArray(item.suiteConfigs) ? item.suiteConfigs.filter((value) => typeof value === "string") : void 0;
78
- projects.push({
79
- id,
80
- path: projectPath,
81
- ...label ? { label } : {},
82
- ...suiteConfigs && suiteConfigs.length > 0 ? { suiteConfigs } : {}
83
- });
84
- }
85
- }
86
- let importConfig;
87
- if (input.import !== void 0) {
88
- if (!isPlainObject(input.import)) {
89
- errors.push("import must be an object");
90
- } else {
91
- importConfig = {};
92
- if (input.import.ciArtifactsDir !== void 0) {
93
- const dir = String(input.import.ciArtifactsDir).trim();
94
- if (!isSafeRelativePath(dir)) {
95
- errors.push("import.ciArtifactsDir must be a safe relative path");
96
- } else {
97
- importConfig.ciArtifactsDir = dir;
98
- }
99
- }
100
- if (input.import.bundlesDir !== void 0) {
101
- const dir = String(input.import.bundlesDir).trim();
102
- if (!isSafeRelativePath(dir)) {
103
- errors.push("import.bundlesDir must be a safe relative path");
104
- } else {
105
- importConfig.bundlesDir = dir;
106
- }
107
- }
108
- if (input.import.fileDropDir !== void 0) {
109
- const dir = String(input.import.fileDropDir).trim();
110
- if (!isSafeRelativePath(dir)) {
111
- errors.push("import.fileDropDir must be a safe relative path");
112
- } else {
113
- importConfig.fileDropDir = dir;
114
- }
115
- }
116
- if (input.import.enabled !== void 0) {
117
- if (typeof input.import.enabled !== "boolean") {
118
- errors.push("import.enabled must be a boolean");
119
- } else {
120
- importConfig.enabled = input.import.enabled;
121
- }
122
- }
123
- }
124
- }
125
- let ingestConfig;
126
- const ingestWarnings = [];
127
- if (input.ingest !== void 0) {
128
- if (!isPlainObject(input.ingest)) {
129
- errors.push("ingest must be an object");
130
- } else {
131
- ingestConfig = {};
132
- if (input.ingest.github !== void 0) {
133
- if (!isPlainObject(input.ingest.github)) {
134
- errors.push("ingest.github must be an object");
135
- } else {
136
- const github = {};
137
- if (input.ingest.github.enabled !== void 0) {
138
- if (typeof input.ingest.github.enabled !== "boolean") {
139
- errors.push("ingest.github.enabled must be a boolean");
140
- } else {
141
- github.enabled = input.ingest.github.enabled;
142
- }
143
- }
144
- if (input.ingest.github.tokenEnv !== void 0) {
145
- const tokenEnv = String(input.ingest.github.tokenEnv).trim();
146
- if (!/^[A-Z][A-Z0-9_]*$/.test(tokenEnv)) {
147
- errors.push("ingest.github.tokenEnv must be an uppercase env var name");
148
- } else {
149
- github.tokenEnv = tokenEnv;
150
- }
151
- }
152
- ingestConfig.github = github;
153
- }
154
- }
155
- if (input.ingest.http !== void 0) {
156
- if (!isPlainObject(input.ingest.http)) {
157
- errors.push("ingest.http must be an object");
158
- } else {
159
- const http = {};
160
- if (input.ingest.http.enabled !== void 0) {
161
- if (typeof input.ingest.http.enabled !== "boolean") {
162
- errors.push("ingest.http.enabled must be a boolean");
163
- } else {
164
- http.enabled = input.ingest.http.enabled;
165
- }
166
- }
167
- if (input.ingest.http.path !== void 0) {
168
- const ingestPath = String(input.ingest.http.path).trim();
169
- if (!ingestPath.startsWith("/") || ingestPath.includes("..")) {
170
- errors.push("ingest.http.path must be an absolute safe path");
171
- } else {
172
- http.path = ingestPath;
173
- }
174
- }
175
- if (input.ingest.http.tokenEnv !== void 0) {
176
- const tokenEnv = String(input.ingest.http.tokenEnv).trim();
177
- if (!/^[A-Z][A-Z0-9_]*$/.test(tokenEnv)) {
178
- errors.push("ingest.http.tokenEnv must be an uppercase env var name");
179
- } else {
180
- http.tokenEnv = tokenEnv;
181
- }
182
- }
183
- if (input.ingest.http.maxBytes !== void 0) {
184
- const maxBytes = Number(input.ingest.http.maxBytes);
185
- if (!Number.isInteger(maxBytes) || maxBytes <= 0) {
186
- errors.push("ingest.http.maxBytes must be a positive integer");
187
- } else {
188
- http.maxBytes = maxBytes;
189
- }
190
- }
191
- ingestConfig.http = http;
192
- }
193
- }
194
- if (input.ingest.bundleUpload !== void 0) {
195
- if (!isPlainObject(input.ingest.bundleUpload)) {
196
- errors.push("ingest.bundleUpload must be an object");
197
- } else {
198
- const bundleUpload = {};
199
- if (input.ingest.bundleUpload.enabled !== void 0) {
200
- if (typeof input.ingest.bundleUpload.enabled !== "boolean") {
201
- errors.push("ingest.bundleUpload.enabled must be a boolean");
202
- } else {
203
- bundleUpload.enabled = input.ingest.bundleUpload.enabled;
204
- }
205
- }
206
- if (input.ingest.bundleUpload.maxBytes !== void 0) {
207
- const maxBytes = Number(input.ingest.bundleUpload.maxBytes);
208
- if (!Number.isInteger(maxBytes) || maxBytes <= 0) {
209
- errors.push("ingest.bundleUpload.maxBytes must be a positive integer");
210
- } else {
211
- bundleUpload.maxBytes = maxBytes;
212
- }
213
- }
214
- ingestConfig.bundleUpload = bundleUpload;
215
- }
216
- }
217
- if (input.ingest.fileDrop !== void 0) {
218
- if (!isPlainObject(input.ingest.fileDrop)) {
219
- errors.push("ingest.fileDrop must be an object");
220
- } else {
221
- const fileDrop = {};
222
- if (input.ingest.fileDrop.maxBytes !== void 0) {
223
- const maxBytes = Number(input.ingest.fileDrop.maxBytes);
224
- if (!Number.isInteger(maxBytes) || maxBytes <= 0) {
225
- errors.push("ingest.fileDrop.maxBytes must be a positive integer");
226
- } else {
227
- fileDrop.maxBytes = maxBytes;
228
- }
229
- }
230
- ingestConfig.fileDrop = fileDrop;
231
- }
232
- }
233
- const knownIngestKeys = /* @__PURE__ */ new Set(["github", "http", "bundleUpload", "fileDrop"]);
234
- for (const key of Object.keys(input.ingest)) {
235
- if (!knownIngestKeys.has(key)) {
236
- ingestWarnings.push(`ignored unknown ingest key: ${key}`);
237
- }
238
- }
239
- }
240
- }
241
- if (errors.length > 0) return { ok: false, errors, warnings: ingestWarnings };
242
- return {
243
- ok: true,
244
- registry: {
245
- schemaVersion: STUDIO_REGISTRY_SCHEMA_VERSION,
246
- name: String(input.name).trim(),
247
- projects,
248
- ...importConfig ? { import: importConfig } : {},
249
- ...ingestConfig ? { ingest: ingestConfig } : {}
250
- },
251
- errors: [],
252
- warnings: ingestWarnings
253
- };
254
- }
255
- async function readStudioRegistryFile(filePath) {
256
- try {
257
- const raw = await promises.readFile(filePath, "utf8");
258
- if (raw.length > MAX_REGISTRY_BYTES) {
259
- return {
260
- ok: false,
261
- path: filePath,
262
- errors: ["registry file exceeds size limit"],
263
- warnings: []
264
- };
265
- }
266
- const parsed = parseStudioRegistry(JSON.parse(raw));
267
- return { ...parsed, path: filePath };
268
- } catch (error) {
269
- const message = error instanceof Error ? error.message : String(error);
270
- return { ok: false, path: filePath, errors: [message], warnings: [] };
271
- }
272
- }
273
- function resolveRegistryProjectPath(registryDir, projectPath) {
274
- return path10__default.default.isAbsolute(projectPath) ? path10__default.default.resolve(projectPath) : path10__default.default.resolve(registryDir, projectPath);
275
- }
276
- var cached;
277
- function loadBetterSqlite3() {
278
- if (cached !== void 0) return cached;
279
- try {
280
- const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
281
- cached = require2("better-sqlite3");
282
- return cached;
283
- } catch (error) {
284
- const detail = error instanceof Error ? error.message : String(error);
285
- throw new Error(
286
- `better-sqlite3 native driver is unavailable (${detail}). Install a prebuild for your Node/OS (see better-sqlite3 docs) or use filesystem-only AgentInspect paths without Studio persistence. Core agent-inspect remains usable without this optional package.`
287
- );
288
- }
289
- }
290
-
291
- // packages/studio/src/db.ts
292
- var STUDIO_DB_SCHEMA_VERSION = "1.0";
293
- var DEFAULT_STUDIO_DB_FILENAME = "studio.db";
294
- var SCHEMA_SQL = `
295
- CREATE TABLE IF NOT EXISTS meta (
296
- key TEXT PRIMARY KEY,
297
- value TEXT NOT NULL
298
- );
299
- CREATE TABLE IF NOT EXISTS projects (
300
- id TEXT PRIMARY KEY,
301
- label TEXT,
302
- path TEXT NOT NULL,
303
- workspace_dir TEXT NOT NULL,
304
- project_name TEXT,
305
- redaction_profile TEXT,
306
- trace_count INTEGER NOT NULL DEFAULT 0,
307
- imported_at TEXT NOT NULL
308
- );
309
- CREATE TABLE IF NOT EXISTS runs (
310
- id INTEGER PRIMARY KEY AUTOINCREMENT,
311
- project_id TEXT NOT NULL,
312
- run_id TEXT NOT NULL,
313
- name TEXT,
314
- status TEXT,
315
- file TEXT,
316
- started_at REAL,
317
- duration_ms REAL,
318
- session_id TEXT,
319
- UNIQUE(project_id, run_id)
320
- );
321
- CREATE INDEX IF NOT EXISTS idx_runs_project ON runs(project_id);
322
- CREATE INDEX IF NOT EXISTS idx_runs_status ON runs(status);
323
- CREATE TABLE IF NOT EXISTS ingest_files (
324
- source_key TEXT PRIMARY KEY,
325
- source_name TEXT NOT NULL,
326
- dest_path TEXT NOT NULL,
327
- kind TEXT NOT NULL CHECK(kind IN ('ci', 'bundle')),
328
- content_hash TEXT NOT NULL,
329
- imported_at TEXT NOT NULL
330
- );
331
- CREATE INDEX IF NOT EXISTS idx_ingest_files_kind ON ingest_files(kind);
332
- `;
333
- function resolveStudioDbPath(options) {
334
- if (options.dbPath && options.dbPath.trim() !== "") {
335
- const raw = options.dbPath.trim();
336
- if (raw.startsWith("postgres://") || raw.startsWith("postgresql://")) {
337
- return raw;
338
- }
339
- return path10__default.default.resolve(options.cwd ?? process.cwd(), raw);
340
- }
341
- return path10__default.default.resolve(
342
- options.cwd ?? process.cwd(),
343
- ".agent-inspect",
344
- DEFAULT_STUDIO_DB_FILENAME
345
- );
346
- }
347
- function isPostgresDbPath(dbPath) {
348
- return dbPath.startsWith("postgres://") || dbPath.startsWith("postgresql://");
349
- }
350
- function openStudioDb(dbPath) {
351
- if (isPostgresDbPath(dbPath)) {
352
- throw new Error(
353
- "Postgres studio databases are not supported; use a SQLite file path (preview only)."
354
- );
355
- }
356
- const dir = path10__default.default.dirname(dbPath);
357
- try {
358
- fs.mkdirSync(dir, { recursive: true });
359
- } catch (error) {
360
- const message = error instanceof Error ? error.message : String(error);
361
- throw new Error(`Failed to create studio database directory: ${message}`);
362
- }
363
- const Sqlite = loadBetterSqlite3();
364
- const db = new Sqlite(dbPath);
365
- db.pragma("journal_mode = WAL");
366
- db.exec(SCHEMA_SQL);
367
- const insertMeta = db.prepare(
368
- "INSERT INTO meta(key, value) VALUES(?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value"
369
- );
370
- insertMeta.run("schemaVersion", STUDIO_DB_SCHEMA_VERSION);
371
- insertMeta.run("driver", "better-sqlite3");
372
- return db;
373
- }
374
- function upsertStudioProject(db, row) {
375
- db.prepare(
376
- `INSERT INTO projects(id, label, path, workspace_dir, project_name, redaction_profile, trace_count, imported_at)
377
- VALUES (@id, @label, @path, @workspaceDir, @projectName, @redactionProfile, @traceCount, @importedAt)
378
- ON CONFLICT(id) DO UPDATE SET
379
- label = excluded.label,
380
- path = excluded.path,
381
- workspace_dir = excluded.workspace_dir,
382
- project_name = excluded.project_name,
383
- redaction_profile = excluded.redaction_profile,
384
- trace_count = excluded.trace_count,
385
- imported_at = excluded.imported_at`
386
- ).run({
387
- id: row.id,
388
- label: row.label,
389
- path: row.path,
390
- workspaceDir: row.workspaceDir,
391
- projectName: row.projectName,
392
- redactionProfile: row.redactionProfile,
393
- traceCount: row.traceCount,
394
- importedAt: row.importedAt
395
- });
396
- }
397
- function replaceProjectRuns(db, projectId, runs) {
398
- const tx = db.transaction(() => {
399
- db.prepare("DELETE FROM runs WHERE project_id = ?").run(projectId);
400
- const insert = db.prepare(
401
- `INSERT INTO runs(project_id, run_id, name, status, file, started_at, duration_ms, session_id)
402
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
403
- );
404
- for (const run of runs) {
405
- insert.run(
406
- projectId,
407
- run.runId,
408
- run.name ?? null,
409
- run.status ?? null,
410
- run.file ?? null,
411
- run.startedAt ?? null,
412
- run.durationMs ?? null,
413
- run.sessionId ?? null
414
- );
415
- }
416
- });
417
- tx();
418
- }
419
- function getStudioProject(db, projectId) {
420
- return db.prepare(
421
- `SELECT id, label, path, workspace_dir AS workspaceDir, project_name AS projectName,
422
- redaction_profile AS redactionProfile, trace_count AS traceCount, imported_at AS importedAt
423
- FROM projects WHERE id = ?`
424
- ).get(projectId);
425
- }
426
- function listProjectRuns(db, projectId, limit = 200) {
427
- const rows = db.prepare(
428
- `SELECT project_id AS projectId, run_id AS runId, name, status, file,
429
- started_at AS startedAt, duration_ms AS durationMs, session_id AS sessionId
430
- FROM runs WHERE project_id = ? ORDER BY started_at DESC LIMIT ?`
431
- ).all(projectId, limit);
432
- return rows;
433
- }
434
- function searchProjectRuns(db, projectId, query, limit = 50) {
435
- const pattern = `%${query}%`;
436
- return db.prepare(
437
- `SELECT project_id AS projectId, run_id AS runId, name, status, file,
438
- started_at AS startedAt, duration_ms AS durationMs, session_id AS sessionId
439
- FROM runs
440
- WHERE project_id = ?
441
- AND (run_id LIKE ? OR IFNULL(name, '') LIKE ? OR IFNULL(status, '') LIKE ?)
442
- ORDER BY started_at DESC
443
- LIMIT ?`
444
- ).all(projectId, pattern, pattern, pattern, limit);
445
- }
446
- function findIngestFileBySourceKey(db, sourceKey) {
447
- return db.prepare(
448
- `SELECT source_key AS sourceKey, source_name AS sourceName, dest_path AS destPath,
449
- kind, content_hash AS contentHash, imported_at AS importedAt
450
- FROM ingest_files WHERE source_key = ?`
451
- ).get(sourceKey);
452
- }
453
- function insertIngestFile(db, row) {
454
- db.prepare(
455
- `INSERT INTO ingest_files(source_key, source_name, dest_path, kind, content_hash, imported_at)
456
- VALUES (@sourceKey, @sourceName, @destPath, @kind, @contentHash, @importedAt)
457
- ON CONFLICT(source_key) DO UPDATE SET
458
- source_name = excluded.source_name,
459
- dest_path = excluded.dest_path,
460
- kind = excluded.kind,
461
- content_hash = excluded.content_hash,
462
- imported_at = excluded.imported_at`
463
- ).run(row);
464
- }
465
-
466
- // packages/studio/src/import.ts
467
- async function discoverSuiteConfigs(projectRoot, configured) {
468
- if (configured && configured.length > 0) {
469
- return configured.map((rel) => path10__default.default.resolve(projectRoot, rel));
470
- }
471
- const found = [];
472
- try {
473
- const entries = await promises.readdir(projectRoot);
474
- for (const entry of entries) {
475
- if (entry.endsWith(".suite.json")) {
476
- found.push(path10__default.default.join(projectRoot, entry));
477
- }
478
- }
479
- } catch {
480
- }
481
- return found.sort();
482
- }
483
- async function loadProjectRuns(workspaceDir, traceDirs) {
484
- const runs = [];
485
- for (const rel of traceDirs) {
486
- const traceDir = advanced.resolveTraceDir({ dir: path10__default.default.join(workspaceDir, rel) });
487
- const td = new advanced.TraceDirectory({ dir: traceDir });
488
- const files = await td.list();
489
- const metas = await advanced.loadTraceMetadataList(
490
- traceDir,
491
- files,
492
- (fileName) => td.getPath(fileName)
493
- );
494
- for (const meta of metas) {
495
- runs.push({
496
- projectId: "",
497
- runId: meta.runId,
498
- ...meta.name !== void 0 ? { name: meta.name } : {},
499
- status: meta.status,
500
- file: path10__default.default.basename(meta.filePath),
501
- ...meta.startedAt !== void 0 ? { startedAt: meta.startedAt } : {},
502
- ...meta.durationMs !== void 0 ? { durationMs: meta.durationMs } : {}
503
- });
504
- }
505
- }
506
- return runs.sort((a, b) => (b.startedAt ?? 0) - (a.startedAt ?? 0));
507
- }
508
- async function importStudioRegistry(options) {
509
- const registryDir = path10__default.default.dirname(options.registryPath);
510
- const warnings = [];
511
- const projects = [];
512
- const importedAt = (/* @__PURE__ */ new Date()).toISOString();
513
- for (const project of options.registry.projects) {
514
- const imported = await importStudioProject({
515
- db: options.db,
516
- registryDir,
517
- project,
518
- importedAt,
519
- warnings
520
- });
521
- if (imported) projects.push(imported);
522
- }
523
- return {
524
- registryName: options.registry.name,
525
- projects,
526
- warnings
527
- };
528
- }
529
- async function importStudioProject(options) {
530
- const projectRoot = resolveRegistryProjectPath(
531
- options.registryDir,
532
- options.project.path
533
- );
534
- const location = workspace.resolveWorkspaceLocation(projectRoot);
535
- const manifestRead = await workspace.readWorkspaceManifestFile(location);
536
- if (!manifestRead.ok || manifestRead.manifest === void 0) {
537
- options.warnings.push(
538
- `project "${options.project.id}": ${manifestRead.errors.join("; ") || "workspace.json missing"}`
539
- );
540
- return void 0;
541
- }
542
- const runs = await loadProjectRuns(
543
- location.workspaceDir,
544
- manifestRead.manifest.traceDirs
545
- );
546
- const suiteConfigPaths = await discoverSuiteConfigs(
547
- projectRoot,
548
- options.project.suiteConfigs
549
- );
550
- const row = {
551
- id: options.project.id,
552
- label: options.project.label ?? options.project.id,
553
- path: projectRoot,
554
- workspaceDir: location.workspaceDir,
555
- projectName: manifestRead.manifest.project,
556
- redactionProfile: manifestRead.manifest.redactionProfile,
557
- traceCount: runs.length,
558
- importedAt: options.importedAt
559
- };
560
- upsertStudioProject(options.db, row);
561
- replaceProjectRuns(
562
- options.db,
563
- options.project.id,
564
- runs.map((run) => ({ ...run, projectId: options.project.id }))
565
- );
566
- return { ...row, suiteConfigPaths };
567
- }
568
- async function resolveStudioRegistryPath(options) {
569
- if (options.workspacePath && options.workspacePath.trim() !== "") {
570
- return path10__default.default.resolve(options.cwd ?? process.cwd(), options.workspacePath);
571
- }
572
- const cwd = path10__default.default.resolve(options.cwd ?? process.cwd());
573
- for (const rel of STUDIO_REGISTRY_FILENAMES) {
574
- const candidate = path10__default.default.join(cwd, rel);
575
- try {
576
- await promises.access(candidate);
577
- return candidate;
578
- } catch {
579
- }
580
- }
581
- return path10__default.default.join(cwd, STUDIO_REGISTRY_FILENAMES[0]);
582
- }
583
- function resolveImportDirs(registryPath, registry) {
584
- const registryDir = path10__default.default.dirname(registryPath);
585
- const importConfig = registry.import ?? {};
586
- const fileDropDir = importConfig.fileDropDir ?? "imports/drop";
587
- const ciArtifactsDir = importConfig.ciArtifactsDir ?? "imports/ci";
588
- const bundlesDir = importConfig.bundlesDir ?? "imports/bundles";
589
- return {
590
- registryDir,
591
- fileDropDir: resolveUnderRoot(registryDir, fileDropDir),
592
- ciArtifactsDir: resolveUnderRoot(registryDir, ciArtifactsDir),
593
- bundlesDir: resolveUnderRoot(registryDir, bundlesDir)
594
- };
595
- }
596
- function uniqueDestPath(destDir, fileName, contentHash) {
597
- const ext = path10__default.default.extname(fileName);
598
- const base = path10__default.default.basename(fileName, ext);
599
- const shortHash = contentHash.slice(0, 8);
600
- return path10__default.default.join(destDir, `${base}-${shortHash}${ext}`);
601
- }
602
- function sanitizeSafeErrorMessage(message, secret) {
603
- if (!secret || secret.length < 4) return message;
604
- return message.split(secret).join("[redacted]");
605
- }
606
- function parseGitHubRepo(repo) {
607
- const trimmed = repo.trim();
608
- const match = /^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)$/.exec(trimmed);
609
- if (!match) {
610
- throw new Error("repo must be in owner/name format");
611
- }
612
- return { owner: match[1], name: match[2] };
613
- }
614
- function buildGitHubArtifactSourceKey(options) {
615
- return `github:${options.owner}/${options.repo}/runs/${options.runId}/${options.artifactName}`;
616
- }
617
- var DEFAULT_MAX_INGEST_BYTES = 52428800;
618
- var IngestLimitError = class extends Error {
619
- code;
620
- constructor(code, message) {
621
- super(message);
622
- this.name = "IngestLimitError";
623
- this.code = code;
624
- }
625
- };
626
- function resolveIngestMaxBytes(configured) {
627
- if (configured === void 0) return DEFAULT_MAX_INGEST_BYTES;
628
- if (!Number.isInteger(configured) || configured <= 0) {
629
- throw new IngestLimitError(
630
- "INGEST_SIZE_LIMIT",
631
- "maxBytes must be a positive integer"
632
- );
633
- }
634
- return configured;
635
- }
636
- async function lstatRegularFile(filePath) {
637
- const info = await promises.lstat(filePath);
638
- if (info.isSymbolicLink()) {
639
- throw new IngestLimitError(
640
- "INGEST_SYMLINK_REJECTED",
641
- "symbolic links are not allowed for ingest"
642
- );
643
- }
644
- if (!info.isFile()) {
645
- throw new IngestLimitError("INGEST_NOT_A_FILE", "ingest path must be a regular file");
646
- }
647
- return info;
648
- }
649
- async function lstatRegularDirectory(dirPath) {
650
- const info = await promises.lstat(dirPath);
651
- if (info.isSymbolicLink()) {
652
- throw new IngestLimitError(
653
- "INGEST_SYMLINK_REJECTED",
654
- "symbolic links are not allowed for ingest"
655
- );
656
- }
657
- if (!info.isDirectory()) {
658
- throw new IngestLimitError(
659
- "INGEST_NOT_A_DIRECTORY",
660
- "ingest path must be a directory"
661
- );
662
- }
663
- return info;
664
- }
665
- async function assertFileWithinByteLimit(filePath, maxBytes) {
666
- const info = await lstatRegularFile(filePath);
667
- if (info.size > maxBytes) {
668
- throw new IngestLimitError("INGEST_SIZE_LIMIT", "file exceeds size limit");
669
- }
670
- return info;
671
- }
672
- async function measureDirectoryBytes(dirPath, maxBytes) {
673
- await lstatRegularDirectory(dirPath);
674
- let total = 0;
675
- const walk = async (current) => {
676
- const entries = await promises.readdir(current, { withFileTypes: true });
677
- for (const entry of entries) {
678
- const abs = path10__default.default.join(current, entry.name);
679
- const info = await promises.lstat(abs);
680
- if (info.isSymbolicLink()) {
681
- throw new IngestLimitError(
682
- "INGEST_SYMLINK_REJECTED",
683
- "symbolic links are not allowed for ingest"
684
- );
685
- }
686
- if (info.isDirectory()) {
687
- await walk(abs);
688
- continue;
689
- }
690
- if (!info.isFile()) continue;
691
- total += info.size;
692
- if (total > maxBytes) {
693
- throw new IngestLimitError("INGEST_SIZE_LIMIT", "directory exceeds size limit");
694
- }
695
- }
696
- };
697
- await walk(dirPath);
698
- return total;
699
- }
700
- async function readBoundedResponseBody(response, maxBytes) {
701
- const lengthHeader = response.headers.get("content-length");
702
- if (lengthHeader) {
703
- const length = Number(lengthHeader);
704
- if (Number.isFinite(length) && length > maxBytes) {
705
- throw new IngestLimitError("INGEST_SIZE_LIMIT", "response exceeds size limit");
706
- }
707
- }
708
- if (!response.body) {
709
- const arrayBuffer = await response.arrayBuffer();
710
- if (arrayBuffer.byteLength > maxBytes) {
711
- throw new IngestLimitError("INGEST_SIZE_LIMIT", "response exceeds size limit");
712
- }
713
- return Buffer.from(arrayBuffer);
714
- }
715
- const reader = response.body.getReader();
716
- const chunks = [];
717
- let total = 0;
718
- for (; ; ) {
719
- const { done, value } = await reader.read();
720
- if (done) break;
721
- if (!value || value.byteLength === 0) continue;
722
- total += value.byteLength;
723
- if (total > maxBytes) {
724
- try {
725
- await reader.cancel();
726
- } catch {
727
- }
728
- throw new IngestLimitError("INGEST_SIZE_LIMIT", "response exceeds size limit");
729
- }
730
- chunks.push(Buffer.from(value));
731
- }
732
- return Buffer.concat(chunks);
733
- }
734
- async function withAtomicStagingDir(parentDir, work) {
735
- await promises.mkdir(parentDir, { recursive: true });
736
- const stagingDir = await promises.mkdtemp(path10__default.default.join(parentDir, ".ingest-staging-"));
737
- try {
738
- return await work(stagingDir);
739
- } finally {
740
- await promises.rm(stagingDir, { recursive: true, force: true });
741
- }
742
- }
743
- async function promoteStagingPath(stagingPath, finalPath) {
744
- await promises.mkdir(path10__default.default.dirname(finalPath), { recursive: true });
745
- await promises.rename(stagingPath, finalPath);
746
- }
747
-
748
- // packages/studio/src/ingest/file-drop.ts
749
- var FILE_DROP_ARCHIVE_DIR = ".imported";
750
- var CI_EXTENSIONS = [".jsonl", ".suite.json"];
751
- var BUNDLE_EXTENSIONS = [".tgz", ".zip"];
752
- function classifyFile(fileName) {
753
- const lower = fileName.toLowerCase();
754
- if (CI_EXTENSIONS.some((ext) => lower.endsWith(ext))) return "ci";
755
- if (BUNDLE_EXTENSIONS.some((ext) => lower.endsWith(ext))) return "bundle";
756
- return void 0;
757
- }
758
- async function hashFile(filePath) {
759
- const hash = crypto.createHash("sha256");
760
- const stream = fs.createReadStream(filePath);
761
- for await (const chunk of stream) {
762
- hash.update(chunk);
763
- }
764
- return hash.digest("hex");
765
- }
766
- async function importOneFile(options) {
767
- const destPath = uniqueDestPath(options.destDir, options.fileName, options.contentHash);
768
- assertPathUnderRoot(destPath, path10__default.default.dirname(options.destDir));
769
- try {
770
- await withAtomicStagingDir(options.destDir, async (stagingDir) => {
771
- const stagedPath = path10__default.default.join(stagingDir, options.fileName);
772
- await promises.copyFile(options.sourcePath, stagedPath);
773
- await promoteStagingPath(stagedPath, destPath);
774
- });
775
- insertIngestFile(options.db, {
776
- sourceKey: options.sourceKey,
777
- sourceName: options.fileName,
778
- destPath,
779
- kind: options.kind,
780
- contentHash: options.contentHash,
781
- importedAt: options.importedAt
782
- });
783
- } catch (error) {
784
- await promises.rm(destPath, { force: true }).catch(() => void 0);
785
- throw error;
786
- }
787
- let archived = false;
788
- if (options.archiveAfterImport) {
789
- await promises.mkdir(options.archiveDir, { recursive: true });
790
- const archiveTarget = path10__default.default.join(options.archiveDir, options.fileName);
791
- await promises.rename(options.sourcePath, archiveTarget);
792
- archived = true;
793
- }
794
- return {
795
- sourceKey: options.sourceKey,
796
- sourceName: options.fileName,
797
- destPath,
798
- kind: options.kind,
799
- contentHash: options.contentHash,
800
- archived
801
- };
802
- }
803
- async function importFileDrop(options) {
804
- const warnings = [];
805
- const errors = [];
806
- const files = [];
807
- if (!options.enabled) {
808
- return {
809
- skipped: true,
810
- reason: "file-drop ingest is disabled; pass --ingest file-drop or use studio import drop",
811
- scanned: 0,
812
- imported: 0,
813
- skippedFiles: 0,
814
- errors,
815
- warnings,
816
- files
817
- };
818
- }
819
- let maxBytes;
820
- try {
821
- maxBytes = resolveIngestMaxBytes(
822
- options.maxBytes ?? options.registry.ingest?.fileDrop?.maxBytes
823
- );
824
- } catch (error) {
825
- const message = error instanceof Error ? error.message : String(error);
826
- return {
827
- skipped: false,
828
- scanned: 0,
829
- imported: 0,
830
- skippedFiles: 0,
831
- errors: [message],
832
- warnings,
833
- files
834
- };
835
- }
836
- const dirs = resolveImportDirs(options.registryPath, options.registry);
837
- let dropDir;
838
- try {
839
- dropDir = options.dropDir ? path10__default.default.isAbsolute(options.dropDir) ? (assertPathUnderRoot(options.dropDir, dirs.registryDir), options.dropDir) : resolveUnderRoot(dirs.registryDir, options.dropDir) : dirs.fileDropDir;
840
- assertPathUnderRoot(dropDir, dirs.registryDir);
841
- } catch (error) {
842
- const message = error instanceof Error ? error.message : String(error);
843
- return {
844
- skipped: false,
845
- scanned: 0,
846
- imported: 0,
847
- skippedFiles: 0,
848
- errors: [message],
849
- warnings,
850
- files
851
- };
852
- }
853
- let entries;
854
- try {
855
- entries = await promises.readdir(dropDir);
856
- } catch (error) {
857
- const message = error instanceof Error ? error.message : String(error);
858
- return {
859
- skipped: false,
860
- scanned: 0,
861
- imported: 0,
862
- skippedFiles: 0,
863
- errors: [`unable to read file-drop directory: ${message}`],
864
- warnings,
865
- files
866
- };
867
- }
868
- const importedAt = (/* @__PURE__ */ new Date()).toISOString();
869
- const archiveDir = path10__default.default.join(dropDir, FILE_DROP_ARCHIVE_DIR);
870
- let scanned = 0;
871
- let imported = 0;
872
- let skippedFiles = 0;
873
- for (const entry of entries.sort()) {
874
- if (entry === FILE_DROP_ARCHIVE_DIR || entry.startsWith(".")) continue;
875
- const sourcePath = path10__default.default.join(dropDir, entry);
876
- const kind = classifyFile(entry);
877
- if (!kind) continue;
878
- scanned += 1;
879
- try {
880
- await assertFileWithinByteLimit(sourcePath, maxBytes);
881
- } catch (error) {
882
- if (error instanceof IngestLimitError && error.code === "INGEST_NOT_A_FILE") {
883
- scanned -= 1;
884
- continue;
885
- }
886
- if (error instanceof IngestLimitError && error.code === "INGEST_SYMLINK_REJECTED") {
887
- errors.push(`failed to import ${entry}: ${error.message}`);
888
- continue;
889
- }
890
- if (error instanceof IngestLimitError && error.code === "INGEST_SIZE_LIMIT") {
891
- errors.push(`failed to import ${entry}: ${error.message}`);
892
- continue;
893
- }
894
- warnings.push(`skipped unreadable entry: ${entry}`);
895
- scanned -= 1;
896
- continue;
897
- }
898
- const sourceKey = entry;
899
- let contentHash;
900
- try {
901
- contentHash = await hashFile(sourcePath);
902
- } catch (error) {
903
- const message = error instanceof Error ? error.message : String(error);
904
- errors.push(`failed to read ${entry}: ${message}`);
905
- continue;
906
- }
907
- const existing = findIngestFileBySourceKey(options.db, sourceKey);
908
- if (existing && existing.contentHash === contentHash) {
909
- skippedFiles += 1;
910
- continue;
911
- }
912
- const destDir = kind === "ci" ? dirs.ciArtifactsDir : dirs.bundlesDir;
913
- try {
914
- const importedFile = await importOneFile({
915
- db: options.db,
916
- sourcePath,
917
- sourceKey,
918
- fileName: entry,
919
- kind,
920
- destDir,
921
- archiveAfterImport: options.archiveAfterImport === true,
922
- archiveDir,
923
- importedAt,
924
- contentHash
925
- });
926
- files.push(importedFile);
927
- imported += 1;
928
- } catch (error) {
929
- const message = error instanceof Error ? error.message : String(error);
930
- errors.push(`failed to import ${entry}: ${message}`);
931
- }
932
- }
933
- return {
934
- skipped: false,
935
- scanned,
936
- imported,
937
- skippedFiles,
938
- errors,
939
- warnings,
940
- files
941
- };
942
- }
943
- async function importFileDropFromRegistry(options) {
944
- return importFileDrop({
945
- db: options.db,
946
- registryPath: options.registryPath,
947
- registry: options.registry,
948
- enabled: options.enabled,
949
- ...options.dropDir !== void 0 ? { dropDir: options.dropDir } : {},
950
- ...options.archiveAfterImport !== void 0 ? { archiveAfterImport: options.archiveAfterImport } : {},
951
- ...options.maxBytes !== void 0 ? { maxBytes: options.maxBytes } : {}
952
- });
953
- }
954
- async function runStudioFileDropImport(options) {
955
- const cwd = options.cwd ?? process.cwd();
956
- const registryPath = await resolveStudioRegistryPath({
957
- ...options.workspacePath !== void 0 ? { workspacePath: options.workspacePath } : {},
958
- cwd
959
- });
960
- const registryRead = await readStudioRegistryFile(registryPath);
961
- if (!registryRead.ok || registryRead.registry === void 0) {
962
- throw new Error(registryRead.errors.join("; ") || "invalid studio registry");
963
- }
964
- const dbPath = resolveStudioDbPath({
965
- ...options.dbPath !== void 0 ? { dbPath: options.dbPath } : {},
966
- cwd
967
- });
968
- const db = openStudioDb(dbPath);
969
- return importFileDropFromRegistry({
970
- db,
971
- registryPath,
972
- registry: registryRead.registry,
973
- enabled: true,
974
- ...options.dropDir !== void 0 ? { dropDir: options.dropDir } : {},
975
- ...options.archiveAfterImport !== void 0 ? { archiveAfterImport: options.archiveAfterImport } : {}
976
- });
977
- }
978
-
979
- // packages/studio/src/context.ts
980
- async function createStudioContext(options = {}) {
981
- const cwd = options.cwd ?? process.cwd();
982
- const registryPath = await resolveStudioRegistryPath({
983
- ...options.workspacePath !== void 0 ? { workspacePath: options.workspacePath } : {},
984
- cwd
985
- });
986
- const registryRead = await readStudioRegistryFile(registryPath);
987
- if (!registryRead.ok || registryRead.registry === void 0) {
988
- throw new Error(registryRead.errors.join("; ") || "invalid studio registry");
989
- }
990
- const dbPath = resolveStudioDbPath({
991
- ...options.dbPath !== void 0 ? { dbPath: options.dbPath } : {},
992
- cwd
993
- });
994
- const db = openStudioDb(dbPath);
995
- const importResult = await importStudioRegistry({
996
- db,
997
- registry: registryRead.registry,
998
- registryPath
999
- });
1000
- let fileDropResult;
1001
- if (options.ingestFileDrop === true) {
1002
- fileDropResult = await importFileDropFromRegistry({
1003
- db,
1004
- registryPath,
1005
- registry: registryRead.registry,
1006
- enabled: true,
1007
- ...options.archiveFileDrop === true ? { archiveAfterImport: true } : {}
1008
- });
1009
- }
1010
- return {
1011
- db,
1012
- dbPath,
1013
- registryPath,
1014
- registry: registryRead.registry,
1015
- importResult,
1016
- ...fileDropResult !== void 0 ? { fileDropResult } : {},
1017
- projects: importResult.projects
1018
- };
1019
- }
1020
- function summarizeProjects(projects) {
1021
- return projects.map((project) => ({
1022
- id: project.id,
1023
- label: project.label ?? project.id,
1024
- projectName: project.projectName,
1025
- traceCount: project.traceCount,
1026
- redactionProfile: project.redactionProfile,
1027
- importedAt: project.importedAt
1028
- }));
1029
- }
1030
- var DEFAULT_INGEST_TOKEN_ENV = "STUDIO_INGEST_TOKEN";
1031
- function resolveIngestTokenEnv(options) {
1032
- const envName = options.tokenEnv?.trim() || options.registryTokenEnv?.trim() || DEFAULT_INGEST_TOKEN_ENV;
1033
- if (!/^[A-Z][A-Z0-9_]*$/.test(envName)) {
1034
- throw new Error("ingest token env name must be an uppercase identifier");
1035
- }
1036
- return envName;
1037
- }
1038
- function resolveIngestToken(envName) {
1039
- const token = process.env[envName]?.trim();
1040
- return token && token.length > 0 ? token : void 0;
1041
- }
1042
- function extractIngestTokenFromRequest(headers) {
1043
- const headerToken = firstHeader(headers["x-agentinspect-token"]) ?? firstHeader(headers["x-agent-inspect-token"]);
1044
- if (headerToken) return headerToken;
1045
- const auth = firstHeader(headers.authorization);
1046
- if (auth?.startsWith("Bearer ")) {
1047
- const token = auth.slice("Bearer ".length).trim();
1048
- return token.length > 0 ? token : void 0;
1049
- }
1050
- return void 0;
1051
- }
1052
- function firstHeader(value) {
1053
- if (Array.isArray(value)) return value[0]?.trim();
1054
- return value?.trim();
1055
- }
1056
- function isIngestTokenValid(provided, expected) {
1057
- if (!provided || !expected) return false;
1058
- const providedBuf = Buffer.from(provided);
1059
- const expectedBuf = Buffer.from(expected);
1060
- if (providedBuf.length !== expectedBuf.length) return false;
1061
- return crypto.timingSafeEqual(providedBuf, expectedBuf);
1062
- }
1063
-
1064
- // packages/studio/src/ingest/http.ts
1065
- var DEFAULT_HTTP_INGEST_BASE_PATH = "/api/ingest";
1066
- var HTTP_INGEST_BUNDLE_PATH = "/api/ingest/bundle";
1067
- var HTTP_INGEST_ARTIFACT_PATH = "/api/ingest/artifact";
1068
- function resolveHttpIngestConfig(options, registryHttp) {
1069
- const http = registryHttp ?? options.context?.registry.ingest?.http;
1070
- const enabled = options.ingestHttp === true || http?.enabled === true;
1071
- const basePath = (http?.path ?? DEFAULT_HTTP_INGEST_BASE_PATH).trim() || DEFAULT_HTTP_INGEST_BASE_PATH;
1072
- const tokenEnv = resolveIngestTokenEnv({
1073
- ...options.ingestTokenEnv !== void 0 ? { tokenEnv: options.ingestTokenEnv } : {},
1074
- ...http?.tokenEnv !== void 0 ? { registryTokenEnv: http.tokenEnv } : {}
1075
- });
1076
- const maxBytes = resolveIngestMaxBytes(http?.maxBytes);
1077
- return { enabled, basePath, tokenEnv, maxBytes };
1078
- }
1079
- function sendJson(res, status, body) {
1080
- res.writeHead(status, {
1081
- "content-type": "application/json; charset=utf-8",
1082
- "cache-control": "no-store"
1083
- });
1084
- res.end(JSON.stringify(body));
1085
- }
1086
- async function readBoundedRequestBody(req, maxBytes) {
1087
- const chunks = [];
1088
- let total = 0;
1089
- for await (const chunk of req) {
1090
- const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
1091
- total += buf.length;
1092
- if (total > maxBytes) {
1093
- throw new Error("request body exceeds size limit");
1094
- }
1095
- chunks.push(buf);
1096
- }
1097
- return Buffer.concat(chunks);
1098
- }
1099
- function isHttpIngestRoute(pathname, config) {
1100
- return pathname === HTTP_INGEST_BUNDLE_PATH || pathname === HTTP_INGEST_ARTIFACT_PATH || pathname === `${config.basePath}/bundle` || pathname === `${config.basePath}/artifact`;
1101
- }
1102
- async function handleHttpIngestRequest(req, res, ctx, options, pathname) {
1103
- const config = resolveHttpIngestConfig(options, ctx.registry.ingest?.http);
1104
- if (!isHttpIngestRoute(pathname, config)) return false;
1105
- if (!config.enabled) {
1106
- sendJson(res, 404, { error: "HTTP ingest is disabled" });
1107
- return true;
1108
- }
1109
- if (req.method !== "POST") {
1110
- sendJson(res, 405, { error: "Method not allowed" });
1111
- return true;
1112
- }
1113
- const expectedToken = resolveIngestToken(config.tokenEnv);
1114
- const providedToken = extractIngestTokenFromRequest(req.headers);
1115
- if (!isIngestTokenValid(providedToken, expectedToken)) {
1116
- sendJson(res, 403, { error: "Invalid or missing ingest token" });
1117
- return true;
1118
- }
1119
- let body;
1120
- try {
1121
- body = await readBoundedRequestBody(req, config.maxBytes);
1122
- } catch (error) {
1123
- const message = error instanceof Error ? error.message : String(error);
1124
- const status = message.includes("size limit") ? 413 : 400;
1125
- sendJson(res, status, { error: sanitizeSafeErrorMessage(message, expectedToken) });
1126
- return true;
1127
- }
1128
- if (body.length === 0) {
1129
- sendJson(res, 400, { error: "Empty request body" });
1130
- return true;
1131
- }
1132
- try {
1133
- const isBundle = pathname === HTTP_INGEST_BUNDLE_PATH || pathname === `${config.basePath}/bundle`;
1134
- const isArtifact = pathname === HTTP_INGEST_ARTIFACT_PATH || pathname === `${config.basePath}/artifact`;
1135
- if (!isBundle && !isArtifact) {
1136
- sendJson(res, 404, { error: "Unknown ingest route" });
1137
- return true;
1138
- }
1139
- const dirs = resolveImportDirs(ctx.registryPath, ctx.registry);
1140
- const contentHash = crypto.createHash("sha256").update(body).digest("hex");
1141
- const importedAt = (/* @__PURE__ */ new Date()).toISOString();
1142
- const fileName = isBundle ? `http-bundle-${contentHash.slice(0, 8)}.bin` : `http-artifact-${contentHash.slice(0, 8)}.zip`;
1143
- const destDir = isBundle ? dirs.bundlesDir : dirs.ciArtifactsDir;
1144
- const destPath = uniqueDestPath(destDir, fileName, contentHash);
1145
- assertPathUnderRoot(destPath, dirs.registryDir);
1146
- try {
1147
- await withAtomicStagingDir(destDir, async (stagingDir) => {
1148
- const stagedPath = path10__default.default.join(stagingDir, fileName);
1149
- await promises.writeFile(stagedPath, body);
1150
- await promoteStagingPath(stagedPath, destPath);
1151
- });
1152
- const sourceKey = isBundle ? `http:bundle:${contentHash}` : buildGitHubArtifactSourceKey({
1153
- owner: "http",
1154
- repo: "ingest",
1155
- runId: importedAt,
1156
- artifactName: fileName
1157
- });
1158
- insertIngestFile(ctx.db, {
1159
- sourceKey,
1160
- sourceName: fileName,
1161
- destPath,
1162
- kind: isBundle ? "bundle" : "ci",
1163
- contentHash,
1164
- importedAt
1165
- });
1166
- } catch (error) {
1167
- await promises.rm(destPath, { force: true }).catch(() => void 0);
1168
- throw error;
1169
- }
1170
- const registryImport = await importStudioRegistry({
1171
- db: ctx.db,
1172
- registry: ctx.registry,
1173
- registryPath: ctx.registryPath
1174
- });
1175
- sendJson(res, 200, {
1176
- ok: true,
1177
- imported: true,
1178
- kind: isBundle ? "bundle" : "artifact",
1179
- destPath,
1180
- warnings: registryImport.warnings
1181
- });
1182
- return true;
1183
- } catch (error) {
1184
- const message = error instanceof Error ? error.message : String(error);
1185
- sendJson(res, 500, { error: sanitizeSafeErrorMessage(message, expectedToken) });
1186
- return true;
1187
- }
1188
- }
1189
-
1190
- // packages/studio/src/html.ts
1191
- var studioIndexHtml = `<!DOCTYPE html>
1192
- <html lang="en">
1193
- <head>
1194
- <meta charset="utf-8" />
1195
- <meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'unsafe-inline'; script-src 'unsafe-inline'" />
1196
- <title>AgentInspect Studio</title>
1197
- <style>
1198
- body { font-family: system-ui, sans-serif; margin: 0; line-height: 1.4; color: #111; }
1199
- header { padding: 1rem 1.5rem; border-bottom: 1px solid #ddd; background: #fafafa; }
1200
- nav a { margin-right: 1rem; color: #0b57d0; text-decoration: none; }
1201
- nav a.active { font-weight: 600; text-decoration: underline; }
1202
- main { padding: 1.5rem; max-width: 1100px; }
1203
- .muted { color: #666; }
1204
- table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
1205
- th, td { border: 1px solid #ddd; padding: 0.5rem; text-align: left; vertical-align: top; }
1206
- th { background: #f6f6f6; }
1207
- pre { background: #f4f4f5; padding: 1rem; overflow: auto; max-height: 60vh; }
1208
- .error { color: #b42318; }
1209
- </style>
1210
- </head>
1211
- <body>
1212
- <header>
1213
- <h1>AgentInspect Studio</h1>
1214
- <p class="muted">Self-hosted, read-only. SQLite only. JSONL remains canonical.</p>
1215
- <nav id="nav">
1216
- <a href="#projects" data-page="projects">Projects</a>
1217
- <a href="#runs" data-page="runs">Runs</a>
1218
- <a href="#sessions" data-page="sessions">Sessions</a>
1219
- <a href="#suites" data-page="suites">Suites</a>
1220
- <a href="#safety" data-page="safety">Safety</a>
1221
- <a href="#imports" data-page="imports">Imports</a>
1222
- <a href="#search" data-page="search">Search</a>
1223
- </nav>
1224
- </header>
1225
- <main id="content"><p class="muted">Loading\u2026</p></main>
1226
- <script>
1227
- function escapeHtml(value) {
1228
- return String(value ?? "")
1229
- .replaceAll("&", "&amp;")
1230
- .replaceAll("<", "&lt;")
1231
- .replaceAll(">", "&gt;")
1232
- .replaceAll('"', "&quot;")
1233
- .replaceAll("'", "&#39;");
1234
- }
1235
-
1236
- let state = { projects: [], projectId: null };
1237
-
1238
- async function api(path) {
1239
- const res = await fetch(path);
1240
- const data = await res.json();
1241
- if (!res.ok) throw new Error(data.error || res.statusText);
1242
- return data;
1243
- }
1244
-
1245
- function setPage(page) {
1246
- document.querySelectorAll("#nav a").forEach((a) => {
1247
- a.classList.toggle("active", a.dataset.page === page);
1248
- });
1249
- }
1250
-
1251
- function renderProjects() {
1252
- setPage("projects");
1253
- const rows = state.projects.map((p) =>
1254
- '<tr><td><a href="#runs" data-select-project="' + escapeHtml(p.id) + '">' +
1255
- escapeHtml(p.label || p.id) + '</a></td><td>' + escapeHtml(p.traceCount) +
1256
- '</td><td>' + escapeHtml(p.path) + '</td></tr>'
1257
- ).join("");
1258
- document.getElementById("content").innerHTML =
1259
- '<h2>Projects</h2><table><thead><tr><th>Project</th><th>Runs</th><th>Path</th></tr></thead><tbody>' +
1260
- (rows || '<tr><td colspan="3">No projects imported</td></tr>') + '</tbody></table>';
1261
- document.querySelectorAll("[data-select-project]").forEach((el) => {
1262
- el.addEventListener("click", (ev) => {
1263
- ev.preventDefault();
1264
- state.projectId = el.getAttribute("data-select-project");
1265
- location.hash = "runs";
1266
- renderRuns();
1267
- });
1268
- });
1269
- }
1270
-
1271
- async function renderRuns() {
1272
- setPage("runs");
1273
- if (!state.projectId && state.projects[0]) state.projectId = state.projects[0].id;
1274
- if (!state.projectId) {
1275
- document.getElementById("content").innerHTML = '<p>Select a project first.</p>';
1276
- return;
1277
- }
1278
- const data = await api("/api/projects/" + encodeURIComponent(state.projectId) + "/runs");
1279
- const rows = (data.runs || []).map((r) =>
1280
- '<tr><td>' + escapeHtml(r.runId) + '</td><td>' + escapeHtml(r.status) +
1281
- '</td><td>' + escapeHtml(r.name) + '</td><td>' + escapeHtml(r.durationMs) + '</td></tr>'
1282
- ).join("");
1283
- document.getElementById("content").innerHTML =
1284
- '<h2>Runs \u2014 ' + escapeHtml(state.projectId) + '</h2>' +
1285
- '<table><thead><tr><th>Run ID</th><th>Status</th><th>Name</th><th>Duration ms</th></tr></thead><tbody>' +
1286
- rows + '</tbody></table>';
1287
- }
1288
-
1289
- async function renderSimple(title, path) {
1290
- setPage(title.toLowerCase());
1291
- if (!state.projectId && state.projects[0]) state.projectId = state.projects[0].id;
1292
- const data = await api("/api/projects/" + encodeURIComponent(state.projectId) + "/" + path);
1293
- document.getElementById("content").innerHTML =
1294
- '<h2>' + escapeHtml(title) + '</h2><pre>' + escapeHtml(JSON.stringify(data, null, 2)) + '</pre>';
1295
- }
1296
-
1297
- async function renderImports() {
1298
- setPage("imports");
1299
- const health = await api("/api/health");
1300
- document.getElementById("content").innerHTML =
1301
- '<h2>Imports</h2><p>Registry: ' + escapeHtml(health.registryName) + '</p>' +
1302
- '<pre>' + escapeHtml(JSON.stringify(health.warnings || [], null, 2)) + '</pre>';
1303
- }
1304
-
1305
- async function renderSearch() {
1306
- setPage("search");
1307
- if (!state.projectId && state.projects[0]) state.projectId = state.projects[0].id;
1308
- document.getElementById("content").innerHTML =
1309
- '<h2>Search</h2><p><input id="q" placeholder="run id or name" /> <button id="go">Search</button></p><pre id="out"></pre>';
1310
- document.getElementById("go").onclick = async () => {
1311
- const q = document.getElementById("q").value;
1312
- const data = await api("/api/search?projectId=" + encodeURIComponent(state.projectId) + "&q=" + encodeURIComponent(q));
1313
- document.getElementById("out").textContent = JSON.stringify(data, null, 2);
1314
- };
1315
- }
1316
-
1317
- async function boot() {
1318
- const health = await api("/api/health");
1319
- const projects = await api("/api/projects");
1320
- state.projects = projects.projects || health.projects || [];
1321
- const page = (location.hash || "#projects").slice(1);
1322
- if (page === "runs") return renderRuns();
1323
- if (page === "sessions") return renderSimple("Sessions", "sessions");
1324
- if (page === "suites") return renderSimple("Suites", "suites");
1325
- if (page === "safety") return renderSimple("Safety", "redaction");
1326
- if (page === "imports") return renderImports();
1327
- if (page === "search") return renderSearch();
1328
- return renderProjects();
1329
- }
1330
-
1331
- window.addEventListener("hashchange", () => boot().catch(showError));
1332
- function showError(err) {
1333
- document.getElementById("content").innerHTML = '<p class="error">' + escapeHtml(String(err)) + '</p>';
1334
- }
1335
- boot().catch(showError);
1336
- </script>
1337
- </body>
1338
- </html>`;
1339
- function getImportedProject(db, projects, projectId) {
1340
- const cached2 = projects.find((item) => item.id === projectId);
1341
- if (cached2) return { project: cached2 };
1342
- const row = getStudioProject(db, projectId);
1343
- if (!row) return void 0;
1344
- return {
1345
- project: {
1346
- ...row,
1347
- suiteConfigPaths: []
1348
- }
1349
- };
1350
- }
1351
- async function loadTraceDirMetas(workspaceDir, traceDirs) {
1352
- const metas = [];
1353
- for (const rel of traceDirs) {
1354
- const traceDir = advanced.resolveTraceDir({ dir: path10__default.default.join(workspaceDir, rel) });
1355
- const td = new advanced.TraceDirectory({ dir: traceDir });
1356
- const files = await td.list();
1357
- const listed = await advanced.loadTraceMetadataList(
1358
- traceDir,
1359
- files,
1360
- (fileName) => td.getPath(fileName)
1361
- );
1362
- metas.push(...listed);
1363
- }
1364
- return metas;
1365
- }
1366
- async function loadProjectRunsView(ctx, db, limit = 200) {
1367
- return listProjectRuns(db, ctx.project.id, limit);
1368
- }
1369
- async function loadProjectSessionsView(ctx) {
1370
- const location = workspace.resolveWorkspaceLocation(ctx.project.path);
1371
- const manifestRead = await workspace.readWorkspaceManifestFile(location);
1372
- const traceDirs = manifestRead.manifest?.traceDirs ?? ["runs"];
1373
- const metas = await loadTraceDirMetas(ctx.project.workspaceDir, traceDirs);
1374
- const runs = await advanced.loadSessionRunRecords(metas);
1375
- return advanced.buildSessionIndex(runs, { correlateByGroupId: true });
1376
- }
1377
- async function loadProjectSuitesView(ctx) {
1378
- const suites = [];
1379
- for (const configPath of ctx.project.suiteConfigPaths) {
1380
- try {
1381
- const result = await advanced.runSuite({
1382
- configPath,
1383
- cwd: path10__default.default.dirname(configPath)
1384
- });
1385
- suites.push({
1386
- suiteName: result.suiteName,
1387
- configPath: result.configPath,
1388
- ok: result.ok,
1389
- status: result.status,
1390
- summary: result.summary,
1391
- cases: result.cases.map((item) => ({
1392
- id: item.id,
1393
- status: item.status,
1394
- ...item.runId !== void 0 ? { runId: item.runId } : {},
1395
- ...item.message !== void 0 ? { message: item.message } : {}
1396
- }))
1397
- });
1398
- } catch (error) {
1399
- const message = error instanceof Error ? error.message : String(error);
1400
- suites.push({
1401
- suiteName: path10__default.default.basename(configPath),
1402
- configPath,
1403
- ok: false,
1404
- status: "error",
1405
- summary: { total: 0, passed: 0, failed: 0, skipped: 0 },
1406
- cases: [],
1407
- error: message
1408
- });
1409
- }
1410
- }
1411
- return { suites };
1412
- }
1413
- async function loadProjectChecksView(ctx) {
1414
- const metas = await loadTraceDirMetas(ctx.project.workspaceDir, ["runs"]);
1415
- const results = [];
1416
- for (const meta of metas.slice(0, 20)) {
1417
- try {
1418
- const read = await readers.openTrace({ type: "file", path: meta.filePath });
1419
- const result = checks.runTraceChecks(
1420
- { read },
1421
- { rules: [checks.createRunStatusRule()], select: ["run.status"], runId: meta.runId }
1422
- );
1423
- results.push({
1424
- runId: meta.runId,
1425
- ok: result.ok,
1426
- summary: result.summary
1427
- });
1428
- } catch (error) {
1429
- const message = error instanceof Error ? error.message : String(error);
1430
- results.push({ runId: meta.runId, ok: false, error: message });
1431
- }
1432
- }
1433
- return { checks: results };
1434
- }
1435
- async function loadProjectSearchView(ctx, db, params) {
1436
- const q = params.get("q")?.trim() ?? "";
1437
- if (q) {
1438
- return {
1439
- query: q,
1440
- results: searchProjectRuns(
1441
- db,
1442
- ctx.project.id,
1443
- q,
1444
- Number(params.get("limit") ?? 50)
1445
- )
1446
- };
1447
- }
1448
- const metas = await loadTraceDirMetas(ctx.project.workspaceDir, ["runs"]);
1449
- const traceDir = advanced.resolveTraceDir({
1450
- dir: path10__default.default.join(ctx.project.workspaceDir, "runs")
1451
- });
1452
- const results = await advanced.searchTraces(metas, {
1453
- traceDir,
1454
- ...params.get("status") ? { status: params.get("status") } : {},
1455
- ...params.get("name") ? { name: params.get("name") ?? void 0 } : {},
1456
- ...params.get("tool") ? { tool: params.get("tool") ?? void 0 } : {},
1457
- limit: Number(params.get("limit") ?? 50)
1458
- });
1459
- return { query: q, results };
1460
- }
1461
- async function loadProjectDiffView(ctx, params) {
1462
- const leftRunId = params.get("left");
1463
- const rightRunId = params.get("right");
1464
- if (!leftRunId || !rightRunId) {
1465
- throw new Error("left and right run ids are required.");
1466
- }
1467
- const metas = await loadTraceDirMetas(ctx.project.workspaceDir, ["runs"]);
1468
- const leftMeta = metas.find((item) => item.runId === leftRunId);
1469
- const rightMeta = metas.find((item) => item.runId === rightRunId);
1470
- if (!leftMeta || !rightMeta) {
1471
- throw new Error("One or both runs were not found in the project workspace.");
1472
- }
1473
- const leftRead = await readers.openTrace({ type: "file", path: leftMeta.filePath });
1474
- const rightRead = await readers.openTrace({ type: "file", path: rightMeta.filePath });
1475
- const diff$1 = diff.diffRuns(
1476
- diff.manualTraceEventsToComparableRun(
1477
- persisted.persistedInspectEventsToTraceEvents(leftRead.events)
1478
- ),
1479
- diff.manualTraceEventsToComparableRun(
1480
- persisted.persistedInspectEventsToTraceEvents(rightRead.events)
1481
- )
1482
- );
1483
- return {
1484
- leftRunId,
1485
- rightRunId,
1486
- summary: diff$1.summary,
1487
- differences: diff$1.differences.slice(0, 50).map((item) => ({
1488
- kind: item.kind,
1489
- message: item.message
1490
- }))
1491
- };
1492
- }
1493
- async function loadProjectReportsView(ctx) {
1494
- const reportsDir = path10__default.default.join(ctx.project.workspaceDir, "reports");
1495
- const reports = [];
1496
- try {
1497
- const files = await promises.readdir(reportsDir);
1498
- for (const file of files) {
1499
- const filePath = path10__default.default.join(reportsDir, file);
1500
- const info = await promises.stat(filePath);
1501
- if (!info.isFile()) continue;
1502
- reports.push({ name: file, path: filePath, sizeBytes: info.size });
1503
- }
1504
- } catch {
1505
- }
1506
- return { reports: reports.sort((a, b) => a.name.localeCompare(b.name)) };
1507
- }
1508
- async function loadProjectObservationsView(ctx) {
1509
- const metas = await loadTraceDirMetas(ctx.project.workspaceDir, ["runs"]);
1510
- const observations = [];
1511
- for (const meta of metas.slice(0, 20)) {
1512
- try {
1513
- const read = await readers.openTrace({ type: "file", path: meta.filePath });
1514
- const legacy = persisted.persistedInspectEventsToTraceEvents(read.events);
1515
- observations.push({
1516
- runId: meta.runId,
1517
- items: advanced.extractOutcomesFromTraceEvents(legacy),
1518
- timeline: advanced.buildRunTimeline(legacy, { focus: "all" }).entries.filter((entry) => entry.type === "tool").map((entry) => entry.name)
1519
- });
1520
- } catch {
1521
- observations.push({ runId: meta.runId, items: [], timeline: [] });
1522
- }
1523
- }
1524
- return { observations };
1525
- }
1526
- async function loadProjectGuardrailsView(ctx) {
1527
- return {
1528
- guardrails: {
1529
- message: "Guardrail evaluation is available via CLI (`agent-inspect scan`). Studio surfaces structural status only in v6.0.",
1530
- redactionProfile: ctx.project.redactionProfile ?? "share",
1531
- circuitWarnings: []
1532
- }
1533
- };
1534
- }
1535
- async function loadProjectRedactionView(ctx) {
1536
- return {
1537
- redaction: {
1538
- profile: ctx.project.redactionProfile ?? "share",
1539
- hint: "Structural share-safety posture from workspace.json \u2014 not certification.",
1540
- bundleCommand: `npx agent-inspect bundle <runId> --profile ${ctx.project.redactionProfile ?? "share"}`
1541
- }
1542
- };
1543
- }
1544
- async function loadBundleExportView(ctx, params) {
1545
- const runId = params.get("runId");
1546
- if (!runId) {
1547
- throw new Error("runId query parameter is required.");
1548
- }
1549
- return {
1550
- projectId: ctx.project.id,
1551
- runId,
1552
- readOnly: true,
1553
- redactionProfile: ctx.project.redactionProfile ?? "share",
1554
- cliHint: `npx agent-inspect bundle ${runId} --profile ${ctx.project.redactionProfile ?? "share"} --dir ${path10__default.default.join(ctx.project.workspaceDir, "runs")}`,
1555
- note: "Studio does not mutate traces or upload bundles. Run the CLI locally to assemble a share-safe bundle."
1556
- };
1557
- }
1558
- function resolveStudioAuthMode(options) {
1559
- return options.auth === "basic" ? "basic" : "none";
1560
- }
1561
- function resolveStudioPassword(options) {
1562
- if (!options.passwordEnv) return void 0;
1563
- const value = process.env[options.passwordEnv]?.trim();
1564
- return value && value.length > 0 ? value : void 0;
1565
- }
1566
- function parseBasicAuth(header) {
1567
- if (!header || !header.startsWith("Basic ")) return void 0;
1568
- try {
1569
- const decoded = Buffer.from(header.slice(6), "base64").toString("utf8");
1570
- const separator = decoded.indexOf(":");
1571
- if (separator < 0) return void 0;
1572
- return decoded.slice(separator + 1);
1573
- } catch {
1574
- return void 0;
1575
- }
1576
- }
1577
- function timingSafePasswordEqual(provided, expected) {
1578
- const providedDigest = crypto.createHash("sha256").update(provided, "utf8").digest();
1579
- const expectedDigest = crypto.createHash("sha256").update(expected, "utf8").digest();
1580
- return crypto.timingSafeEqual(providedDigest, expectedDigest);
1581
- }
1582
- function isStudioRequestAuthorized(req, options) {
1583
- const mode = resolveStudioAuthMode(options);
1584
- if (mode === "none") return true;
1585
- const expected = resolveStudioPassword(options);
1586
- if (!expected) return false;
1587
- const provided = parseBasicAuth(req.headers.authorization);
1588
- if (provided === void 0) return false;
1589
- return timingSafePasswordEqual(provided, expected);
1590
- }
1591
- function studioAuthRequiredResponse() {
1592
- return {
1593
- status: 401,
1594
- body: { error: "Unauthorized" },
1595
- headers: {
1596
- "www-authenticate": 'Basic realm="AgentInspect Studio"'
1597
- }
1598
- };
1599
- }
1600
-
1601
- // packages/studio/src/routes.ts
1602
- function sendJson2(res, status, body, headers = {}) {
1603
- const payload = JSON.stringify(body);
1604
- res.writeHead(status, {
1605
- "content-type": "application/json; charset=utf-8",
1606
- "cache-control": "no-store",
1607
- ...headers
1608
- });
1609
- res.end(payload);
1610
- }
1611
- function notFound(res, message) {
1612
- sendJson2(res, 404, { error: message });
1613
- }
1614
- function decodeSegment(segment) {
1615
- if (!segment) return "";
1616
- try {
1617
- return decodeURIComponent(segment);
1618
- } catch {
1619
- return segment;
1620
- }
1621
- }
1622
- async function handleStudioRoute(req, res, ctx, options, pathname, url) {
1623
- if (!isStudioRequestAuthorized(req, options)) {
1624
- const auth = studioAuthRequiredResponse();
1625
- sendJson2(res, auth.status, auth.body, auth.headers);
1626
- return true;
1627
- }
1628
- if (pathname === "/api/health") {
1629
- sendJson2(res, 200, {
1630
- ok: true,
1631
- readOnly: true,
1632
- mode: "studio",
1633
- registryName: ctx.registry.name,
1634
- registryPath: ctx.registryPath,
1635
- dbPath: ctx.dbPath,
1636
- projects: summarizeProjects(ctx.projects),
1637
- warnings: ctx.importResult.warnings
1638
- });
1639
- return true;
1640
- }
1641
- if (pathname === "/api/projects") {
1642
- sendJson2(res, 200, {
1643
- registryName: ctx.registry.name,
1644
- projects: summarizeProjects(ctx.projects),
1645
- warnings: ctx.importResult.warnings
1646
- });
1647
- return true;
1648
- }
1649
- const projectMatch = pathname.match(/^\/api\/projects\/([^/]+)(?:\/(.*))?$/);
1650
- if (projectMatch) {
1651
- const projectId = decodeSegment(projectMatch[1]);
1652
- const subpath = projectMatch[2] ?? "";
1653
- const projectCtx = getImportedProject(ctx.db, ctx.projects, projectId);
1654
- if (!projectCtx) {
1655
- notFound(res, `Project not found: ${projectId}`);
1656
- return true;
1657
- }
1658
- if (subpath === "runs" || subpath === "") {
1659
- sendJson2(res, 200, {
1660
- projectId,
1661
- runs: await loadProjectRunsView(projectCtx, ctx.db)
1662
- });
1663
- return true;
1664
- }
1665
- if (subpath === "sessions") {
1666
- sendJson2(res, 200, {
1667
- projectId,
1668
- ...await loadProjectSessionsView(projectCtx)
1669
- });
1670
- return true;
1671
- }
1672
- if (subpath === "suites") {
1673
- sendJson2(res, 200, {
1674
- projectId,
1675
- ...await loadProjectSuitesView(projectCtx)
1676
- });
1677
- return true;
1678
- }
1679
- if (subpath === "checks") {
1680
- sendJson2(res, 200, {
1681
- projectId,
1682
- ...await loadProjectChecksView(projectCtx)
1683
- });
1684
- return true;
1685
- }
1686
- if (subpath === "observations") {
1687
- sendJson2(res, 200, {
1688
- projectId,
1689
- ...await loadProjectObservationsView(projectCtx)
1690
- });
1691
- return true;
1692
- }
1693
- if (subpath === "guardrails") {
1694
- sendJson2(res, 200, {
1695
- projectId,
1696
- ...await loadProjectGuardrailsView(projectCtx)
1697
- });
1698
- return true;
1699
- }
1700
- if (subpath === "redaction") {
1701
- sendJson2(res, 200, {
1702
- projectId,
1703
- ...await loadProjectRedactionView(projectCtx)
1704
- });
1705
- return true;
1706
- }
1707
- if (subpath === "reports") {
1708
- sendJson2(res, 200, {
1709
- projectId,
1710
- ...await loadProjectReportsView(projectCtx)
1711
- });
1712
- return true;
1713
- }
1714
- notFound(res, `Unknown project route: /${subpath}`);
1715
- return true;
1716
- }
1717
- if (pathname === "/api/search") {
1718
- const projectId = url.searchParams.get("projectId");
1719
- if (!projectId) {
1720
- sendJson2(res, 400, { error: "projectId query parameter is required." });
1721
- return true;
1722
- }
1723
- const projectCtx = getImportedProject(ctx.db, ctx.projects, projectId);
1724
- if (!projectCtx) {
1725
- notFound(res, `Project not found: ${projectId}`);
1726
- return true;
1727
- }
1728
- sendJson2(res, 200, {
1729
- projectId,
1730
- ...await loadProjectSearchView(projectCtx, ctx.db, url.searchParams)
1731
- });
1732
- return true;
1733
- }
1734
- if (pathname === "/api/diff") {
1735
- const projectId = url.searchParams.get("projectId");
1736
- if (!projectId) {
1737
- sendJson2(res, 400, { error: "projectId query parameter is required." });
1738
- return true;
1739
- }
1740
- const projectCtx = getImportedProject(ctx.db, ctx.projects, projectId);
1741
- if (!projectCtx) {
1742
- notFound(res, `Project not found: ${projectId}`);
1743
- return true;
1744
- }
1745
- try {
1746
- sendJson2(res, 200, {
1747
- projectId,
1748
- ...await loadProjectDiffView(projectCtx, url.searchParams)
1749
- });
1750
- } catch (error) {
1751
- const message = error instanceof Error ? error.message : String(error);
1752
- sendJson2(res, 400, { error: message });
1753
- }
1754
- return true;
1755
- }
1756
- if (pathname === "/api/reports") {
1757
- const projectId = url.searchParams.get("projectId");
1758
- if (!projectId) {
1759
- sendJson2(res, 400, { error: "projectId query parameter is required." });
1760
- return true;
1761
- }
1762
- const projectCtx = getImportedProject(ctx.db, ctx.projects, projectId);
1763
- if (!projectCtx) {
1764
- notFound(res, `Project not found: ${projectId}`);
1765
- return true;
1766
- }
1767
- sendJson2(res, 200, {
1768
- projectId,
1769
- ...await loadProjectReportsView(projectCtx)
1770
- });
1771
- return true;
1772
- }
1773
- if (pathname === "/api/bundles/export") {
1774
- const projectId = url.searchParams.get("projectId");
1775
- if (!projectId) {
1776
- sendJson2(res, 400, { error: "projectId query parameter is required." });
1777
- return true;
1778
- }
1779
- const projectCtx = getImportedProject(ctx.db, ctx.projects, projectId);
1780
- if (!projectCtx) {
1781
- notFound(res, `Project not found: ${projectId}`);
1782
- return true;
1783
- }
1784
- try {
1785
- sendJson2(res, 200, await loadBundleExportView(projectCtx, url.searchParams));
1786
- } catch (error) {
1787
- const message = error instanceof Error ? error.message : String(error);
1788
- sendJson2(res, 400, { error: message });
1789
- }
1790
- return true;
1791
- }
1792
- return false;
1793
- }
1794
-
1795
- // packages/studio/src/server.ts
1796
- var DEFAULT_HOST = "127.0.0.1";
1797
- var DEFAULT_PORT = 7340;
1798
- function badRequest(res, message) {
1799
- res.writeHead(400, {
1800
- "content-type": "application/json; charset=utf-8",
1801
- "cache-control": "no-store"
1802
- });
1803
- res.end(JSON.stringify({ error: message }));
1804
- }
1805
- function resolveHost(options) {
1806
- if (options.server === true) {
1807
- return options.host ?? "0.0.0.0";
1808
- }
1809
- return options.host ?? DEFAULT_HOST;
1810
- }
1811
- function createStudioServer(options = {}) {
1812
- const host = resolveHost(options);
1813
- const port = options.port ?? DEFAULT_PORT;
1814
- let contextPromise = options.context ? Promise.resolve(options.context) : void 0;
1815
- if (host === "0.0.0.0") {
1816
- console.warn(
1817
- "[AgentInspect studio] Binding to 0.0.0.0 exposes workspace evidence on the network. Use 127.0.0.1 unless you accept that risk."
1818
- );
1819
- if (options.auth !== "basic") {
1820
- console.warn(
1821
- "[AgentInspect studio] Non-localhost binding without --auth basic is discouraged for production use."
1822
- );
1823
- }
1824
- }
1825
- const server = http.createServer(async (req, res) => {
1826
- try {
1827
- const method = req.method ?? "GET";
1828
- const url = new URL(req.url ?? "/", `http://${host}:${port}`);
1829
- const pathname = url.pathname;
1830
- if (!contextPromise) {
1831
- contextPromise = createStudioContext(options);
1832
- }
1833
- const ctx = await contextPromise;
1834
- const httpConfig = resolveHttpIngestConfig(options, ctx.registry.ingest?.http);
1835
- if (isHttpIngestRoute(pathname, httpConfig)) {
1836
- const handled2 = await handleHttpIngestRequest(req, res, ctx, options, pathname);
1837
- if (handled2) return;
1838
- }
1839
- if (method !== "GET" && method !== "HEAD") {
1840
- return badRequest(res, "Only GET is supported.");
1841
- }
1842
- if (pathname === "/" || pathname === "/index.html") {
1843
- if (req.method === "HEAD") {
1844
- res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
1845
- res.end();
1846
- return;
1847
- }
1848
- res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
1849
- res.end(studioIndexHtml);
1850
- return;
1851
- }
1852
- const handled = await handleStudioRoute(req, res, ctx, options, pathname, url);
1853
- if (!handled) {
1854
- res.writeHead(404, {
1855
- "content-type": "application/json; charset=utf-8",
1856
- "cache-control": "no-store"
1857
- });
1858
- res.end(JSON.stringify({ error: `Unknown route: ${pathname}` }));
1859
- }
1860
- } catch (error) {
1861
- const message = error instanceof Error ? error.message : String(error);
1862
- res.writeHead(500, {
1863
- "content-type": "application/json; charset=utf-8",
1864
- "cache-control": "no-store"
1865
- });
1866
- res.end(JSON.stringify({ error: message }));
1867
- }
1868
- });
1869
- return server;
1870
- }
1871
- async function startStudioServer(options = {}) {
1872
- const host = resolveHost(options);
1873
- const port = options.port ?? DEFAULT_PORT;
1874
- const ctx = options.context ?? await createStudioContext(options);
1875
- const server = createStudioServer({ ...options, context: ctx });
1876
- return new Promise((resolve, reject) => {
1877
- server.once("error", reject);
1878
- server.listen(port, host, () => {
1879
- const address = server.address();
1880
- const resolvedPort = typeof address === "object" && address ? address.port : port;
1881
- resolve({
1882
- host,
1883
- port: resolvedPort,
1884
- url: `http://${host === "0.0.0.0" ? "127.0.0.1" : host}:${resolvedPort}/`,
1885
- mode: "studio",
1886
- ...options.workspacePath !== void 0 ? { workspacePath: options.workspacePath } : {},
1887
- dbPath: ctx.dbPath,
1888
- registryName: ctx.registry.name,
1889
- projectCount: ctx.projects.length
1890
- });
1891
- });
1892
- });
1893
- }
1894
- var DEFAULT_GITHUB_TOKEN_ENV = "GITHUB_TOKEN";
1895
- var GITHUB_API_BASE = "https://api.github.com";
1896
- function resolveTokenEnv(registry, override) {
1897
- const fromRegistry = registry.ingest?.github?.tokenEnv?.trim();
1898
- const envName = override?.trim() || fromRegistry || DEFAULT_GITHUB_TOKEN_ENV;
1899
- if (!/^[A-Z][A-Z0-9_]*$/.test(envName)) {
1900
- throw new Error("token env name must be an uppercase identifier");
1901
- }
1902
- return envName;
1903
- }
1904
- function resolveToken(envName) {
1905
- const token = process.env[envName]?.trim();
1906
- if (!token) {
1907
- throw new Error(`missing GitHub token in environment variable ${envName}`);
1908
- }
1909
- return token;
1910
- }
1911
- function githubHeaders(token) {
1912
- return {
1913
- Authorization: `Bearer ${token}`,
1914
- Accept: "application/vnd.github+json",
1915
- "X-GitHub-Api-Version": "2022-11-28",
1916
- "User-Agent": "agent-inspect-studio-ingest"
1917
- };
1918
- }
1919
- async function readResponseBody(response, maxBytes) {
1920
- try {
1921
- return await readBoundedResponseBody(response, maxBytes);
1922
- } catch (error) {
1923
- if (error instanceof IngestLimitError && error.code === "INGEST_SIZE_LIMIT") {
1924
- throw new Error("artifact exceeds size limit");
1925
- }
1926
- throw error;
1927
- }
1928
- }
1929
- async function downloadGitHubArtifactArchive(options) {
1930
- const maxBytes = resolveIngestMaxBytes(options.maxBytes);
1931
- const fetchFn = options.fetchImpl ?? fetch;
1932
- const { owner, name } = parseGitHubRepo(options.repo);
1933
- const runId = options.runId.trim();
1934
- const artifactName = options.artifactName.trim();
1935
- if (!/^\d+$/.test(runId)) {
1936
- throw new Error("run-id must be a numeric workflow run id");
1937
- }
1938
- if (artifactName === "") {
1939
- throw new Error("artifact name must be non-empty");
1940
- }
1941
- const listUrl = `${GITHUB_API_BASE}/repos/${owner}/${name}/actions/runs/${runId}/artifacts`;
1942
- const listResponse = await fetchFn(listUrl, {
1943
- headers: githubHeaders(options.token)
1944
- });
1945
- if (!listResponse.ok) {
1946
- throw new Error(`GitHub artifact lookup failed (${listResponse.status})`);
1947
- }
1948
- const payload = await listResponse.json();
1949
- const artifact = payload.artifacts?.find((item) => item.name === artifactName);
1950
- if (!artifact?.archive_download_url) {
1951
- throw new Error(`artifact not found for run ${runId}: ${artifactName}`);
1952
- }
1953
- if (artifact.expired === true) {
1954
- throw new Error(`artifact expired for run ${runId}: ${artifactName}`);
1955
- }
1956
- if (typeof artifact.size_in_bytes === "number" && artifact.size_in_bytes > maxBytes) {
1957
- throw new Error("artifact exceeds size limit");
1958
- }
1959
- const downloadResponse = await fetchFn(artifact.archive_download_url, {
1960
- headers: githubHeaders(options.token),
1961
- redirect: "follow"
1962
- });
1963
- if (!downloadResponse.ok) {
1964
- throw new Error(`GitHub artifact download failed (${downloadResponse.status})`);
1965
- }
1966
- return readResponseBody(downloadResponse, maxBytes);
1967
- }
1968
- async function importGitHubArtifact(options) {
1969
- const registryImportWarnings = [];
1970
- const errors = [];
1971
- if (!options.enabled) {
1972
- return {
1973
- skipped: true,
1974
- reason: "GitHub artifact ingest is disabled; use studio import github explicitly",
1975
- imported: false,
1976
- registryImportWarnings,
1977
- errors
1978
- };
1979
- }
1980
- let token;
1981
- let tokenEnv;
1982
- try {
1983
- const { owner, name } = parseGitHubRepo(options.repo);
1984
- tokenEnv = resolveTokenEnv(options.registry, options.tokenEnv);
1985
- token = resolveToken(tokenEnv);
1986
- const sourceKey = buildGitHubArtifactSourceKey({
1987
- owner,
1988
- repo: name,
1989
- runId: options.runId,
1990
- artifactName: options.artifactName
1991
- });
1992
- const archive = await downloadGitHubArtifactArchive({
1993
- repo: options.repo,
1994
- runId: options.runId,
1995
- artifactName: options.artifactName,
1996
- token,
1997
- ...options.fetchImpl !== void 0 ? { fetchImpl: options.fetchImpl } : {}
1998
- });
1999
- const contentHash = crypto.createHash("sha256").update(archive).digest("hex");
2000
- const existing = findIngestFileBySourceKey(options.db, sourceKey);
2001
- if (existing && existing.contentHash === contentHash) {
2002
- return {
2003
- skipped: false,
2004
- imported: false,
2005
- sourceKey,
2006
- contentHash,
2007
- destPath: existing.destPath,
2008
- registryImportWarnings,
2009
- errors
2010
- };
2011
- }
2012
- const dirs = resolveImportDirs(options.registryPath, options.registry);
2013
- const fileName = `${options.artifactName}.zip`;
2014
- const destPath = uniqueDestPath(dirs.bundlesDir, fileName, contentHash);
2015
- assertPathUnderRoot(destPath, dirs.registryDir);
2016
- try {
2017
- await withAtomicStagingDir(dirs.bundlesDir, async (stagingDir) => {
2018
- const stagedPath = path10__default.default.join(stagingDir, fileName);
2019
- await promises.writeFile(stagedPath, archive);
2020
- await promoteStagingPath(stagedPath, destPath);
2021
- });
2022
- const importedAt = (/* @__PURE__ */ new Date()).toISOString();
2023
- insertIngestFile(options.db, {
2024
- sourceKey,
2025
- sourceName: fileName,
2026
- destPath,
2027
- kind: "bundle",
2028
- contentHash,
2029
- importedAt
2030
- });
2031
- } catch (error) {
2032
- await promises.rm(destPath, { force: true }).catch(() => void 0);
2033
- throw error;
2034
- }
2035
- const registryImport = await importStudioRegistry({
2036
- db: options.db,
2037
- registry: options.registry,
2038
- registryPath: options.registryPath
2039
- });
2040
- registryImportWarnings.push(...registryImport.warnings);
2041
- return {
2042
- skipped: false,
2043
- imported: true,
2044
- sourceKey,
2045
- contentHash,
2046
- destPath,
2047
- registryImportWarnings,
2048
- errors
2049
- };
2050
- } catch (error) {
2051
- const message = error instanceof Error ? error.message : String(error);
2052
- errors.push(sanitizeSafeErrorMessage(message, token));
2053
- return {
2054
- skipped: false,
2055
- imported: false,
2056
- registryImportWarnings,
2057
- errors
2058
- };
2059
- }
2060
- }
2061
- async function runStudioGitHubArtifactImport(options) {
2062
- const cwd = options.cwd ?? process.cwd();
2063
- const registryPath = await resolveStudioRegistryPath({
2064
- ...options.workspacePath !== void 0 ? { workspacePath: options.workspacePath } : {},
2065
- cwd
2066
- });
2067
- const registryRead = await readStudioRegistryFile(registryPath);
2068
- if (!registryRead.ok || registryRead.registry === void 0) {
2069
- throw new Error(registryRead.errors.join("; ") || "invalid studio registry");
2070
- }
2071
- const dbPath = resolveStudioDbPath({
2072
- ...options.dbPath !== void 0 ? { dbPath: options.dbPath } : {},
2073
- cwd
2074
- });
2075
- const db = openStudioDb(dbPath);
2076
- return importGitHubArtifact({
2077
- db,
2078
- registryPath,
2079
- registry: registryRead.registry,
2080
- repo: options.repo,
2081
- runId: options.runId,
2082
- artifactName: options.artifact,
2083
- enabled: true,
2084
- ...options.tokenEnv !== void 0 ? { tokenEnv: options.tokenEnv } : {},
2085
- ...options.fetchImpl !== void 0 ? { fetchImpl: options.fetchImpl } : {}
2086
- });
2087
- }
2088
- async function pathExists(filePath) {
2089
- try {
2090
- await promises.access(filePath);
2091
- return true;
2092
- } catch {
2093
- return false;
2094
- }
2095
- }
2096
- async function validateBundleDirectory(bundleDir) {
2097
- const errors = [];
2098
- const metadataPath = path10__default.default.join(bundleDir, "metadata.json");
2099
- if (!await pathExists(metadataPath)) {
2100
- errors.push("bundle missing metadata.json");
2101
- return errors;
2102
- }
2103
- try {
2104
- const raw = await promises.readFile(metadataPath, "utf8");
2105
- const parsed = JSON.parse(raw);
2106
- if (typeof parsed.agentInspectVersion !== "string") {
2107
- errors.push("bundle metadata.json missing agentInspectVersion");
2108
- }
2109
- if (!Array.isArray(parsed.runIds) || parsed.runIds.length === 0) {
2110
- errors.push("bundle metadata.json missing runIds");
2111
- }
2112
- } catch {
2113
- errors.push("bundle metadata.json is invalid JSON");
2114
- }
2115
- return errors;
2116
- }
2117
- async function hashBundleContents(bundleDir) {
2118
- const hash = crypto.createHash("sha256");
2119
- const walk = async (dir, relPrefix) => {
2120
- const entries = (await promises.readdir(dir, { withFileTypes: true })).sort(
2121
- (a, b) => a.name.localeCompare(b.name)
2122
- );
2123
- for (const entry of entries) {
2124
- const abs = path10__default.default.join(dir, entry.name);
2125
- const rel = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
2126
- const info = await promises.lstat(abs);
2127
- if (info.isSymbolicLink()) {
2128
- throw new IngestLimitError(
2129
- "INGEST_SYMLINK_REJECTED",
2130
- "symbolic links are not allowed for ingest"
2131
- );
2132
- }
2133
- if (info.isDirectory()) {
2134
- await walk(abs, rel);
2135
- } else if (info.isFile()) {
2136
- hash.update(rel);
2137
- hash.update("\0");
2138
- hash.update(await promises.readFile(abs));
2139
- hash.update("\0");
2140
- }
2141
- }
2142
- };
2143
- await walk(bundleDir, "");
2144
- return hash.digest("hex");
2145
- }
2146
- async function copyDirectoryRecursive(sourceDir, destDir) {
2147
- await promises.mkdir(destDir, { recursive: true });
2148
- const entries = await promises.readdir(sourceDir, { withFileTypes: true });
2149
- for (const entry of entries) {
2150
- const from = path10__default.default.join(sourceDir, entry.name);
2151
- const to = path10__default.default.join(destDir, entry.name);
2152
- const info = await promises.lstat(from);
2153
- if (info.isSymbolicLink()) {
2154
- throw new IngestLimitError(
2155
- "INGEST_SYMLINK_REJECTED",
2156
- "symbolic links are not allowed for ingest"
2157
- );
2158
- }
2159
- if (info.isDirectory()) {
2160
- await copyDirectoryRecursive(from, to);
2161
- } else if (info.isFile()) {
2162
- await promises.copyFile(from, to);
2163
- }
2164
- }
2165
- }
2166
- async function importBundleUpload(options) {
2167
- const registryImportWarnings = [];
2168
- const errors = [];
2169
- if (!options.enabled) {
2170
- return {
2171
- skipped: true,
2172
- reason: "bundle upload ingest is disabled; use studio import bundle explicitly",
2173
- imported: false,
2174
- errors,
2175
- registryImportWarnings
2176
- };
2177
- }
2178
- const bundlePath = path10__default.default.resolve(options.bundlePath);
2179
- try {
2180
- await lstatRegularDirectory(bundlePath);
2181
- } catch (error) {
2182
- if (error instanceof IngestLimitError) {
2183
- return {
2184
- skipped: false,
2185
- imported: false,
2186
- errors: [error.message],
2187
- registryImportWarnings
2188
- };
2189
- }
2190
- return {
2191
- skipped: false,
2192
- imported: false,
2193
- errors: ["bundle path does not exist"],
2194
- registryImportWarnings
2195
- };
2196
- }
2197
- const validationErrors = await validateBundleDirectory(bundlePath);
2198
- if (validationErrors.length > 0) {
2199
- return {
2200
- skipped: false,
2201
- imported: false,
2202
- errors: validationErrors,
2203
- registryImportWarnings
2204
- };
2205
- }
2206
- let maxBytes;
2207
- try {
2208
- maxBytes = resolveIngestMaxBytes(
2209
- options.maxBytes ?? options.registry.ingest?.bundleUpload?.maxBytes
2210
- );
2211
- await measureDirectoryBytes(bundlePath, maxBytes);
2212
- } catch (error) {
2213
- const message = error instanceof Error ? error.message : String(error);
2214
- return {
2215
- skipped: false,
2216
- imported: false,
2217
- errors: [message],
2218
- registryImportWarnings
2219
- };
2220
- }
2221
- let contentHash;
2222
- try {
2223
- contentHash = await hashBundleContents(bundlePath);
2224
- } catch (error) {
2225
- const message = error instanceof Error ? error.message : String(error);
2226
- return {
2227
- skipped: false,
2228
- imported: false,
2229
- errors: [message],
2230
- registryImportWarnings
2231
- };
2232
- }
2233
- const sourceKey = `bundle:${bundlePath}`;
2234
- const existing = findIngestFileBySourceKey(options.db, sourceKey);
2235
- if (existing && existing.contentHash === contentHash) {
2236
- return {
2237
- skipped: false,
2238
- imported: false,
2239
- destPath: existing.destPath,
2240
- sourceKey,
2241
- errors,
2242
- registryImportWarnings
2243
- };
2244
- }
2245
- const dirs = resolveImportDirs(options.registryPath, options.registry);
2246
- const folderName = path10__default.default.basename(bundlePath);
2247
- const destPath = uniqueDestPath(dirs.bundlesDir, folderName, contentHash);
2248
- assertPathUnderRoot(destPath, dirs.registryDir);
2249
- try {
2250
- await withAtomicStagingDir(dirs.bundlesDir, async (stagingDir) => {
2251
- const stagedDest = path10__default.default.join(stagingDir, folderName);
2252
- await copyDirectoryRecursive(bundlePath, stagedDest);
2253
- await promoteStagingPath(stagedDest, destPath);
2254
- });
2255
- insertIngestFile(options.db, {
2256
- sourceKey,
2257
- sourceName: folderName,
2258
- destPath,
2259
- kind: "bundle",
2260
- contentHash,
2261
- importedAt: (/* @__PURE__ */ new Date()).toISOString()
2262
- });
2263
- const registryImport = await importStudioRegistry({
2264
- db: options.db,
2265
- registry: options.registry,
2266
- registryPath: options.registryPath
2267
- });
2268
- registryImportWarnings.push(...registryImport.warnings);
2269
- return {
2270
- skipped: false,
2271
- imported: true,
2272
- destPath,
2273
- sourceKey,
2274
- errors,
2275
- registryImportWarnings
2276
- };
2277
- } catch (error) {
2278
- await promises.rm(destPath, { recursive: true, force: true }).catch(() => void 0);
2279
- const message = error instanceof Error ? error.message : String(error);
2280
- return {
2281
- skipped: false,
2282
- imported: false,
2283
- errors: [message],
2284
- registryImportWarnings
2285
- };
2286
- }
2287
- }
2288
- async function runStudioBundleUploadImport(options) {
2289
- const cwd = options.cwd ?? process.cwd();
2290
- const registryPath = await resolveStudioRegistryPath({
2291
- ...options.workspacePath !== void 0 ? { workspacePath: options.workspacePath } : {},
2292
- cwd
2293
- });
2294
- const registryRead = await readStudioRegistryFile(registryPath);
2295
- if (!registryRead.ok || registryRead.registry === void 0) {
2296
- throw new Error(registryRead.errors.join("; ") || "invalid studio registry");
2297
- }
2298
- const dbPath = resolveStudioDbPath({
2299
- ...options.dbPath !== void 0 ? { dbPath: options.dbPath } : {},
2300
- cwd
2301
- });
2302
- const db = openStudioDb(dbPath);
2303
- return importBundleUpload({
2304
- db,
2305
- registryPath,
2306
- registry: registryRead.registry,
2307
- bundlePath: options.bundlePath,
2308
- enabled: true
2309
- });
2310
- }
2311
-
2312
- exports.HTTP_INGEST_ARTIFACT_PATH = HTTP_INGEST_ARTIFACT_PATH;
2313
- exports.HTTP_INGEST_BUNDLE_PATH = HTTP_INGEST_BUNDLE_PATH;
2314
- exports.createStudioContext = createStudioContext;
2315
- exports.createStudioServer = createStudioServer;
2316
- exports.downloadGitHubArtifactArchive = downloadGitHubArtifactArchive;
2317
- exports.extractIngestTokenFromRequest = extractIngestTokenFromRequest;
2318
- exports.handleHttpIngestRequest = handleHttpIngestRequest;
2319
- exports.importBundleUpload = importBundleUpload;
2320
- exports.importFileDrop = importFileDrop;
2321
- exports.importFileDropFromRegistry = importFileDropFromRegistry;
2322
- exports.importGitHubArtifact = importGitHubArtifact;
2323
- exports.isHttpIngestRoute = isHttpIngestRoute;
2324
- exports.isIngestTokenValid = isIngestTokenValid;
2325
- exports.openStudioDb = openStudioDb;
2326
- exports.parseStudioRegistry = parseStudioRegistry;
2327
- exports.readStudioRegistryFile = readStudioRegistryFile;
2328
- exports.resolveHttpIngestConfig = resolveHttpIngestConfig;
2329
- exports.resolveIngestToken = resolveIngestToken;
2330
- exports.resolveIngestTokenEnv = resolveIngestTokenEnv;
2331
- exports.resolveStudioDbPath = resolveStudioDbPath;
2332
- exports.resolveStudioRegistryPath = resolveStudioRegistryPath;
2333
- exports.runStudioBundleUploadImport = runStudioBundleUploadImport;
2334
- exports.runStudioFileDropImport = runStudioFileDropImport;
2335
- exports.runStudioGitHubArtifactImport = runStudioGitHubArtifactImport;
2336
- exports.startStudioServer = startStudioServer;
2337
- exports.studioIndexHtml = studioIndexHtml;
2338
- exports.summarizeProjects = summarizeProjects;
2339
- exports.validateBundleDirectory = validateBundleDirectory;
2340
- //# sourceMappingURL=index.cjs.map
2341
- //# sourceMappingURL=index.cjs.map