agent-inspect 5.4.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,7 +11,7 @@ import { createServer } from 'http';
|
|
|
11
11
|
import { createRequire } from 'module';
|
|
12
12
|
|
|
13
13
|
// package.json
|
|
14
|
-
var version = "
|
|
14
|
+
var version = "6.1.0";
|
|
15
15
|
|
|
16
16
|
// packages/cli/src/trace-dir-scale.ts
|
|
17
17
|
var TRACE_COUNT_WARN = 1e3;
|
|
@@ -7075,6 +7075,167 @@ async function serveCommand(options = {}) {
|
|
|
7075
7075
|
});
|
|
7076
7076
|
}
|
|
7077
7077
|
|
|
7078
|
+
// packages/cli/src/studio-cmd.ts
|
|
7079
|
+
var PACKAGE = "@agent-inspect/studio";
|
|
7080
|
+
function isModuleNotFound3(e) {
|
|
7081
|
+
return e !== null && typeof e === "object" && "code" in e && (e.code === "ERR_MODULE_NOT_FOUND" || e.code === "MODULE_NOT_FOUND");
|
|
7082
|
+
}
|
|
7083
|
+
async function loadStudio() {
|
|
7084
|
+
try {
|
|
7085
|
+
return await import('@agent-inspect/studio');
|
|
7086
|
+
} catch (e) {
|
|
7087
|
+
if (isModuleNotFound3(e)) {
|
|
7088
|
+
console.error(
|
|
7089
|
+
`The optional Studio analyzer is not installed. Run: npm install ${PACKAGE}`
|
|
7090
|
+
);
|
|
7091
|
+
process.exitCode = 1;
|
|
7092
|
+
return null;
|
|
7093
|
+
}
|
|
7094
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
7095
|
+
console.error(`[AgentInspect] failed to load ${PACKAGE}: ${msg}`);
|
|
7096
|
+
process.exitCode = 1;
|
|
7097
|
+
return null;
|
|
7098
|
+
}
|
|
7099
|
+
}
|
|
7100
|
+
function parsePort2(value) {
|
|
7101
|
+
if (value === void 0) return void 0;
|
|
7102
|
+
const parsed = Number(value);
|
|
7103
|
+
if (!Number.isInteger(parsed) || parsed <= 0 || parsed > 65535) {
|
|
7104
|
+
throw new Error("--port must be an integer between 1 and 65535.");
|
|
7105
|
+
}
|
|
7106
|
+
return parsed;
|
|
7107
|
+
}
|
|
7108
|
+
function summarizeFileDropResult(result) {
|
|
7109
|
+
if (result.skipped) {
|
|
7110
|
+
console.log(`[AgentInspect studio] file-drop skipped: ${result.reason ?? "disabled"}`);
|
|
7111
|
+
return;
|
|
7112
|
+
}
|
|
7113
|
+
console.log(
|
|
7114
|
+
`[AgentInspect studio] file-drop scanned=${result.scanned} imported=${result.imported} skipped=${result.skippedFiles}`
|
|
7115
|
+
);
|
|
7116
|
+
for (const warning of result.warnings) {
|
|
7117
|
+
console.warn(`[AgentInspect studio] ${warning}`);
|
|
7118
|
+
}
|
|
7119
|
+
for (const error of result.errors) {
|
|
7120
|
+
console.error(`[AgentInspect studio] ${error}`);
|
|
7121
|
+
}
|
|
7122
|
+
}
|
|
7123
|
+
function summarizeGitHubResult(result) {
|
|
7124
|
+
if (result.skipped) {
|
|
7125
|
+
console.log(`[AgentInspect studio] github import skipped: ${result.reason ?? "disabled"}`);
|
|
7126
|
+
return;
|
|
7127
|
+
}
|
|
7128
|
+
if (result.imported) {
|
|
7129
|
+
console.log(
|
|
7130
|
+
`[AgentInspect studio] github artifact imported to ${result.destPath ?? "(unknown)"}`
|
|
7131
|
+
);
|
|
7132
|
+
} else if (result.destPath) {
|
|
7133
|
+
console.log(`[AgentInspect studio] github artifact unchanged: ${result.destPath}`);
|
|
7134
|
+
}
|
|
7135
|
+
for (const warning of result.registryImportWarnings) {
|
|
7136
|
+
console.warn(`[AgentInspect studio] ${warning}`);
|
|
7137
|
+
}
|
|
7138
|
+
for (const error of result.errors) {
|
|
7139
|
+
console.error(`[AgentInspect studio] ${error}`);
|
|
7140
|
+
}
|
|
7141
|
+
}
|
|
7142
|
+
async function studioImportBundleCommand(options) {
|
|
7143
|
+
const mod = await loadStudio();
|
|
7144
|
+
if (!mod) return;
|
|
7145
|
+
const result = await mod.runStudioBundleUploadImport({
|
|
7146
|
+
...options.workspace !== void 0 ? { workspacePath: options.workspace } : {},
|
|
7147
|
+
...options.db !== void 0 ? { dbPath: options.db } : {},
|
|
7148
|
+
bundlePath: options.path,
|
|
7149
|
+
...options.cwd !== void 0 ? { cwd: options.cwd } : {}
|
|
7150
|
+
});
|
|
7151
|
+
if (result.skipped) {
|
|
7152
|
+
console.log(`[AgentInspect studio] bundle import skipped: ${result.reason ?? "disabled"}`);
|
|
7153
|
+
} else if (result.imported) {
|
|
7154
|
+
console.log(`[AgentInspect studio] bundle imported to ${result.destPath ?? "(unknown)"}`);
|
|
7155
|
+
} else if (result.destPath) {
|
|
7156
|
+
console.log(`[AgentInspect studio] bundle unchanged: ${result.destPath}`);
|
|
7157
|
+
}
|
|
7158
|
+
for (const warning of result.registryImportWarnings) {
|
|
7159
|
+
console.warn(`[AgentInspect studio] ${warning}`);
|
|
7160
|
+
}
|
|
7161
|
+
for (const error of result.errors) {
|
|
7162
|
+
console.error(`[AgentInspect studio] ${error}`);
|
|
7163
|
+
}
|
|
7164
|
+
if (result.errors.length > 0) process.exitCode = 1;
|
|
7165
|
+
}
|
|
7166
|
+
async function studioImportGitHubCommand(options) {
|
|
7167
|
+
const mod = await loadStudio();
|
|
7168
|
+
if (!mod) return;
|
|
7169
|
+
const result = await mod.runStudioGitHubArtifactImport({
|
|
7170
|
+
...options.workspace !== void 0 ? { workspacePath: options.workspace } : {},
|
|
7171
|
+
...options.db !== void 0 ? { dbPath: options.db } : {},
|
|
7172
|
+
repo: options.repo,
|
|
7173
|
+
runId: options.runId,
|
|
7174
|
+
artifact: options.artifact,
|
|
7175
|
+
...options.tokenEnv !== void 0 ? { tokenEnv: options.tokenEnv } : {},
|
|
7176
|
+
...options.cwd !== void 0 ? { cwd: options.cwd } : {}
|
|
7177
|
+
});
|
|
7178
|
+
summarizeGitHubResult(result);
|
|
7179
|
+
if (result.errors.length > 0) {
|
|
7180
|
+
process.exitCode = 1;
|
|
7181
|
+
}
|
|
7182
|
+
}
|
|
7183
|
+
async function studioImportDropCommand(options = {}) {
|
|
7184
|
+
const mod = await loadStudio();
|
|
7185
|
+
if (!mod) return;
|
|
7186
|
+
const result = await mod.runStudioFileDropImport({
|
|
7187
|
+
...options.workspace !== void 0 ? { workspacePath: options.workspace } : {},
|
|
7188
|
+
...options.db !== void 0 ? { dbPath: options.db } : {},
|
|
7189
|
+
...options.dir !== void 0 ? { dropDir: options.dir } : {},
|
|
7190
|
+
...options.archive === true ? { archiveAfterImport: true } : {},
|
|
7191
|
+
...options.cwd !== void 0 ? { cwd: options.cwd } : {}
|
|
7192
|
+
});
|
|
7193
|
+
summarizeFileDropResult(result);
|
|
7194
|
+
if (result.errors.length > 0) {
|
|
7195
|
+
process.exitCode = 1;
|
|
7196
|
+
}
|
|
7197
|
+
}
|
|
7198
|
+
async function studioCommand(options = {}) {
|
|
7199
|
+
const mod = await loadStudio();
|
|
7200
|
+
if (!mod) return;
|
|
7201
|
+
const ingest = options.ingest?.trim();
|
|
7202
|
+
if (ingest && ingest !== "file-drop" && ingest !== "http") {
|
|
7203
|
+
throw new Error(`Unsupported --ingest channel: ${ingest}. Supported: file-drop, http`);
|
|
7204
|
+
}
|
|
7205
|
+
const port = parsePort2(options.port);
|
|
7206
|
+
const host = options.host?.trim();
|
|
7207
|
+
const info = await mod.startStudioServer({
|
|
7208
|
+
...host !== void 0 && host.length > 0 ? { host } : {},
|
|
7209
|
+
...port !== void 0 ? { port } : {},
|
|
7210
|
+
...options.workspace !== void 0 ? { workspacePath: options.workspace } : {},
|
|
7211
|
+
...options.db !== void 0 ? { dbPath: options.db } : {},
|
|
7212
|
+
...options.server === true ? { server: true } : {},
|
|
7213
|
+
...options.cwd !== void 0 ? { cwd: options.cwd } : {},
|
|
7214
|
+
...options.auth === "basic" ? { auth: "basic" } : {},
|
|
7215
|
+
...options.passwordEnv !== void 0 ? { passwordEnv: options.passwordEnv } : {},
|
|
7216
|
+
...ingest === "file-drop" ? { ingestFileDrop: true } : {},
|
|
7217
|
+
...ingest === "http" ? { ingestHttp: true } : {},
|
|
7218
|
+
...options.ingestTokenEnv !== void 0 ? { ingestTokenEnv: options.ingestTokenEnv } : {},
|
|
7219
|
+
...options.archiveFileDrop === true ? { archiveFileDrop: true } : {}
|
|
7220
|
+
});
|
|
7221
|
+
if (ingest === "file-drop") {
|
|
7222
|
+
console.log(`[AgentInspect studio] file-drop ingest enabled for startup scan`);
|
|
7223
|
+
}
|
|
7224
|
+
if (ingest === "http") {
|
|
7225
|
+
console.log(`[AgentInspect studio] HTTP ingest enabled (token required on POST routes)`);
|
|
7226
|
+
}
|
|
7227
|
+
console.log(`AgentInspect studio (read-only): ${info.url}`);
|
|
7228
|
+
if (options.open === true && info.host !== "127.0.0.1" && info.host !== "localhost") {
|
|
7229
|
+
console.warn("Skipping browser open for non-local host binding.");
|
|
7230
|
+
} else if (options.open === true) {
|
|
7231
|
+
const openMod = await import('child_process');
|
|
7232
|
+
openMod.exec(`open ${info.url}`, () => {
|
|
7233
|
+
});
|
|
7234
|
+
}
|
|
7235
|
+
await new Promise(() => {
|
|
7236
|
+
});
|
|
7237
|
+
}
|
|
7238
|
+
|
|
7078
7239
|
// packages/eval/src/index.ts
|
|
7079
7240
|
function isTraceReadResult(value) {
|
|
7080
7241
|
return value !== null && typeof value === "object" && "runs" in value && "events" in value && "format" in value;
|
|
@@ -9869,23 +10030,23 @@ async function indexCleanCommand(options = {}) {
|
|
|
9869
10030
|
process.exitCode = 1;
|
|
9870
10031
|
}
|
|
9871
10032
|
}
|
|
9872
|
-
var
|
|
9873
|
-
function
|
|
10033
|
+
var PACKAGE2 = "@agent-inspect/index-sqlite";
|
|
10034
|
+
function isModuleNotFound4(e) {
|
|
9874
10035
|
return e !== null && typeof e === "object" && "code" in e && (e.code === "ERR_MODULE_NOT_FOUND" || e.code === "MODULE_NOT_FOUND");
|
|
9875
10036
|
}
|
|
9876
10037
|
async function loadIndexSqlite() {
|
|
9877
10038
|
try {
|
|
9878
10039
|
return await import('./src-FVNE44UA.mjs');
|
|
9879
10040
|
} catch (e) {
|
|
9880
|
-
if (
|
|
10041
|
+
if (isModuleNotFound4(e)) {
|
|
9881
10042
|
console.error(
|
|
9882
|
-
`The optional SQLite index is not installed. Run: npm install ${
|
|
10043
|
+
`The optional SQLite index is not installed. Run: npm install ${PACKAGE2}`
|
|
9883
10044
|
);
|
|
9884
10045
|
process.exitCode = 1;
|
|
9885
10046
|
return null;
|
|
9886
10047
|
}
|
|
9887
10048
|
const msg = e instanceof Error ? e.message : String(e);
|
|
9888
|
-
console.error(`[AgentInspect] failed to load ${
|
|
10049
|
+
console.error(`[AgentInspect] failed to load ${PACKAGE2}: ${msg}`);
|
|
9889
10050
|
process.exitCode = 1;
|
|
9890
10051
|
return null;
|
|
9891
10052
|
}
|
|
@@ -10724,6 +10885,21 @@ function createCliProgram() {
|
|
|
10724
10885
|
program.command("viewer").description("Start localhost read-only viewer (traces, suite, or workspace) (v5.3+)").option("--dir <path>", "trace directory (trace mode)").option("--suite", "suite evidence mode").option("--workspace", "workspace mode").option("--config <path>", "suite config path (suite mode)").option("--host <host>", "bind host (default 127.0.0.1)", "127.0.0.1").option("--port <number>", "bind port (default 7337)", "7337").option("--open", "open browser locally when host is localhost").action((opts) => {
|
|
10725
10886
|
runCommand(() => serveCommand(opts));
|
|
10726
10887
|
});
|
|
10888
|
+
const studioCmd = program.command("studio").description(
|
|
10889
|
+
"Start self-hosted read-only Studio analyzer (requires @agent-inspect/studio) (v6.0+)"
|
|
10890
|
+
).option("--workspace <path>", "studio registry manifest path").option("--db <path>", "studio database path (sqlite file or postgres URL)").option("--host <host>", "bind host (default 127.0.0.1)", "127.0.0.1").option("--port <number>", "bind port (default 7340)", "7340").option("--server", "bind for network access (0.0.0.0; requires explicit opt-in)").option("--auth <mode>", "auth mode: none or basic", "none").option("--password-env <name>", "env var for basic-auth password").option("--ingest <channel>", "enable ingest channel on startup (file-drop, http)").option("--ingest-token-env <name>", "env var for HTTP ingest token (default STUDIO_INGEST_TOKEN)").option("--archive-file-drop", "archive file-drop sources after successful import").option("--open", "open browser locally when host is localhost").action((opts) => {
|
|
10891
|
+
runCommand(() => studioCommand(opts));
|
|
10892
|
+
});
|
|
10893
|
+
const studioImportCmd = studioCmd.command("import").description("Import external evidence into Studio (v6.1+)");
|
|
10894
|
+
studioImportCmd.command("drop").description("Import allowlisted files from a file-drop directory").option("--workspace <path>", "studio registry manifest path").option("--db <path>", "studio database path (sqlite file or postgres URL)").option("--dir <path>", "file-drop directory (defaults to registry import.fileDropDir)").option("--archive", "move imported files into .imported/ under the drop dir").action((opts) => {
|
|
10895
|
+
runCommand(() => studioImportDropCommand(opts));
|
|
10896
|
+
});
|
|
10897
|
+
studioImportCmd.command("github").description("Download a GitHub Actions artifact into the studio import dirs").requiredOption("--repo <owner/name>", "GitHub repository").requiredOption("--run-id <id>", "workflow run id").requiredOption("--artifact <name>", "artifact name").option("--workspace <path>", "studio registry manifest path").option("--db <path>", "studio database path (sqlite file or postgres URL)").option("--token-env <name>", "env var for GitHub token (default GITHUB_TOKEN)").action((opts) => {
|
|
10898
|
+
runCommand(() => studioImportGitHubCommand(opts));
|
|
10899
|
+
});
|
|
10900
|
+
studioImportCmd.command("bundle").description("Import a local share-safe bundle directory into Studio").requiredOption("--path <dir>", "bundle directory path").option("--workspace <path>", "studio registry manifest path").option("--db <path>", "studio database path (sqlite file or postgres URL)").action((opts) => {
|
|
10901
|
+
runCommand(() => studioImportBundleCommand(opts));
|
|
10902
|
+
});
|
|
10727
10903
|
program.command("eval").description("Run deterministic local evals against a trace").argument("<trace-path-or-run-id>", "trace file, directory, stdin -, or run id").option("--dir <path>", "trace directory for run-id lookup").addOption(
|
|
10728
10904
|
new Option("--format <format>", "trace input format").choices([
|
|
10729
10905
|
"agent-inspect-jsonl",
|