@tonyclaw/agent-inspector 3.0.47 → 3.0.48
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/.output/backend/nitro.json +1 -1
- package/.output/cli.js +991 -963
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-BwZEsYfS.mjs → router-Cj10mv-Z.mjs} +304 -2
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-V-8lPASC.js → CompareDrawer-uRiXFOCp.js} +1 -1
- package/.output/ui/assets/{InspectorPet-D4CVnfdf.js → InspectorPet-j-r6xk0V.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-CO3ZVHLX.js → ProxyViewerContainer-DnUrkMJF.js} +23 -23
- package/.output/ui/assets/{ReplayDialog-CpGyTLtt.js → ReplayDialog-B2URyHMv.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-BLuJL9dZ.js → RequestAnatomy-CK0M0CJO.js} +1 -1
- package/.output/ui/assets/{ResponseView-BuSC-CH7.js → ResponseView-CYSVA4lT.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-DeA-JJKa.js → StreamingChunkSequence-CHf54ZUV.js} +1 -1
- package/.output/ui/assets/{_sessionId-Chp67th6.js → _sessionId-BXULpTNP.js} +1 -1
- package/.output/ui/assets/{_sessionId-8HuHFhjo.js → _sessionId-E4lbj5-I.js} +1 -1
- package/.output/ui/assets/{index-nl9-dpZn.js → index-B4ixI3kG.js} +1 -1
- package/.output/ui/assets/{index-atoQrlb8.js → index-BJ-71WLq.js} +1 -1
- package/.output/ui/assets/{index-nY3E1vxV.js → index-CW0ab9r3.js} +2 -2
- package/.output/ui/assets/{index-DPmKK_5d.js → index-Ce-lO51c.js} +1 -1
- package/.output/ui/assets/{json-viewer-B9kIzqeX.js → json-viewer-C6E8aLaV.js} +1 -1
- package/.output/ui/assets/{jszip.min-B7tfyE-I.js → jszip.min-DjWdTBbp.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/README.md +46 -0
- package/package.json +4 -4
- package/src/cli/instance.ts +12 -1
- package/src/cli/instanceArgs.ts +1 -1
- package/src/cli/rustBackendPackage.ts +8 -0
- package/src/cli.ts +18 -4
- package/src/components/ProxyViewer.tsx +4 -13
- package/src/components/proxy-viewer/proxyViewerLogic.ts +9 -0
package/.output/cli.js
CHANGED
|
@@ -14,6 +14,206 @@ var __export = (target, all) => {
|
|
|
14
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// package.json
|
|
18
|
+
var package_default;
|
|
19
|
+
var init_package = __esm({
|
|
20
|
+
"package.json"() {
|
|
21
|
+
package_default = {
|
|
22
|
+
name: "@tonyclaw/agent-inspector",
|
|
23
|
+
version: "3.0.48",
|
|
24
|
+
type: "module",
|
|
25
|
+
description: "Agent observability and knowledge capture layer for AI coding tools.",
|
|
26
|
+
license: "MIT",
|
|
27
|
+
engines: {
|
|
28
|
+
node: ">=22.0.0"
|
|
29
|
+
},
|
|
30
|
+
author: "TonyClaw",
|
|
31
|
+
repository: {
|
|
32
|
+
type: "git",
|
|
33
|
+
url: "git+https://gitcode.com/TonyClaw/agent-inspector.git"
|
|
34
|
+
},
|
|
35
|
+
homepage: "https://gitcode.com/TonyClaw/agent-inspector#readme",
|
|
36
|
+
workspaces: [
|
|
37
|
+
"packages/*"
|
|
38
|
+
],
|
|
39
|
+
bugs: {
|
|
40
|
+
url: "https://gitcode.com/TonyClaw/agent-inspector/issues"
|
|
41
|
+
},
|
|
42
|
+
publishConfig: {
|
|
43
|
+
access: "public",
|
|
44
|
+
registry: "https://registry.npmjs.org/"
|
|
45
|
+
},
|
|
46
|
+
keywords: [
|
|
47
|
+
"claude",
|
|
48
|
+
"anthropic",
|
|
49
|
+
"openai",
|
|
50
|
+
"proxy",
|
|
51
|
+
"api-inspector",
|
|
52
|
+
"agent-observability",
|
|
53
|
+
"agent-memory",
|
|
54
|
+
"debugging",
|
|
55
|
+
"llm",
|
|
56
|
+
"ai-coding-tools"
|
|
57
|
+
],
|
|
58
|
+
bin: {
|
|
59
|
+
"agent-inspector": "bin/agent-inspector.js"
|
|
60
|
+
},
|
|
61
|
+
files: [
|
|
62
|
+
"bin",
|
|
63
|
+
"src",
|
|
64
|
+
"!src/**/*.test.ts",
|
|
65
|
+
"!src/**/*.stories.tsx",
|
|
66
|
+
"!src/**/__fixtures__",
|
|
67
|
+
"!src/ui/routeTree.gen.ts",
|
|
68
|
+
"!src/backend/routeTree.gen.ts",
|
|
69
|
+
"scripts/setup-windows-runtime.mjs",
|
|
70
|
+
"scripts/setup-agent-skills.mjs",
|
|
71
|
+
"scripts/generate-theme-scales.mjs",
|
|
72
|
+
"docs/instance-control.openapi.yaml",
|
|
73
|
+
"styles",
|
|
74
|
+
".output",
|
|
75
|
+
"!.output/*.exe"
|
|
76
|
+
],
|
|
77
|
+
scripts: {
|
|
78
|
+
dev: "node scripts/dev-decoupled.mjs",
|
|
79
|
+
"dev:ui": "vite dev --config vite.ui.config.ts",
|
|
80
|
+
"dev:backend": "node scripts/dev-backend.mjs",
|
|
81
|
+
"test:smoke": "bun scripts/run-test-suite.mjs smoke",
|
|
82
|
+
"test:fast": "bun scripts/run-test-suite.mjs smoke",
|
|
83
|
+
"test:unit": "bun scripts/run-test-suite.mjs unit",
|
|
84
|
+
"test:integration": "bun scripts/run-test-suite.mjs integration",
|
|
85
|
+
"test:changed": "bun scripts/run-test-suite.mjs changed",
|
|
86
|
+
"test:all": "bun scripts/run-test-suite.mjs all",
|
|
87
|
+
"test:compatibility-tooling": "node --test scripts/compatibility/*.test.mjs",
|
|
88
|
+
start: "node .output/cli.js",
|
|
89
|
+
"start:backend": "node .output/cli.js --backend-only --no-open",
|
|
90
|
+
"preview:ui": "vite preview --config vite.ui.config.ts",
|
|
91
|
+
"clean:output": "node scripts/clean-output.mjs",
|
|
92
|
+
build: "bun clean:output && bun build:backend && bun build:ui && bun smoke:ui-preview && bun build:workers && bun build:cli && bun build:mcp && bun check:bundle && bun check:boundaries",
|
|
93
|
+
"build:backend": "vite build --config vite.backend.config.ts",
|
|
94
|
+
"build:ui": "vite build --config vite.ui.config.ts",
|
|
95
|
+
"build:workers": "npx esbuild src/proxy/logFinalizer.worker.ts src/proxy/sessionWorkerEntry.ts --bundle --platform=node --target=node22 --format=esm --outdir=.output/workers --external:better-sqlite3",
|
|
96
|
+
"smoke:workers": "node scripts/smoke-production-workers.mjs",
|
|
97
|
+
"smoke:packed-workers": "node scripts/smoke-packed-workers.mjs",
|
|
98
|
+
"smoke:instances": "node scripts/smoke-windows-instances.mjs",
|
|
99
|
+
"smoke:coding-agent-instances": "node scripts/smoke-coding-agent-instances.mjs",
|
|
100
|
+
"smoke:ui-preview": "node scripts/smoke-decoupled-ui-preview.mjs",
|
|
101
|
+
"check:bundle": "node scripts/check-client-bundle.mjs",
|
|
102
|
+
"check:boundaries": "node scripts/check-runtime-boundaries.mjs",
|
|
103
|
+
"compatibility:bdd": "node scripts/lint-bdd-catalog.mjs",
|
|
104
|
+
"compatibility:compare": "node scripts/compatibility/cli.mjs compare",
|
|
105
|
+
"compatibility:drift": "node scripts/check-backend-compatibility.mjs",
|
|
106
|
+
"compatibility:fixtures": "bun scripts/validate-compatibility-fixtures.ts",
|
|
107
|
+
"compatibility:freeze": "node scripts/freeze-backend-baseline.mjs",
|
|
108
|
+
"compatibility:run": "node scripts/compatibility/cli.mjs run",
|
|
109
|
+
"compatibility:performance": "node scripts/compatibility/performance-cli.mjs",
|
|
110
|
+
"compatibility:performance:verify": "node scripts/compatibility/performance-cli.mjs verify",
|
|
111
|
+
"build:cli": "npx esbuild src/cli.ts --bundle --platform=node --target=node22 --format=esm --outfile=.output/cli.js",
|
|
112
|
+
"build:mcp": "npx esbuild packages/agent-inspector-mcp/src/cli.ts --bundle --platform=node --target=node22 --format=esm --outfile=packages/agent-inspector-mcp/dist/cli.js",
|
|
113
|
+
"rust:build-package": "node scripts/rust/build-platform.mjs",
|
|
114
|
+
"rust:stage-package": "node scripts/rust/stage-platform.mjs",
|
|
115
|
+
"rust:verify-package": "node scripts/rust/verify-platform.mjs",
|
|
116
|
+
"rust:pack-package": "node scripts/rust/pack-platform.mjs",
|
|
117
|
+
"rust:native-artifact": "node scripts/rust/create-native-artifact.mjs",
|
|
118
|
+
"rust:native:aggregate": "node scripts/rust/aggregate-native-artifacts.mjs",
|
|
119
|
+
"test:rust-packaging": "bun test scripts/rust/npmPackaging.test.ts scripts/rust/nativeReleaseContract.test.ts scripts/rust/nativeStartupSmoke.test.ts scripts/releaseCore.test.ts",
|
|
120
|
+
"rust:packages:check": "node scripts/rust/sync-package-versions.mjs",
|
|
121
|
+
"rust:packages:sync": "node scripts/rust/sync-package-versions.mjs --write",
|
|
122
|
+
"themes:generate": "node scripts/generate-theme-scales.mjs",
|
|
123
|
+
postinstall: "node scripts/setup-windows-runtime.mjs && node scripts/setup-agent-skills.mjs",
|
|
124
|
+
prepublishOnly: "node scripts/rust/require-release-orchestrator.mjs",
|
|
125
|
+
typecheck: "tsc --noEmit --incremental --tsBuildInfoFile .cache/tsconfig.tsbuildinfo",
|
|
126
|
+
lint: "eslint . --cache --cache-location .cache/eslintcache",
|
|
127
|
+
format: "biome format --write .",
|
|
128
|
+
"format:check": "biome format .",
|
|
129
|
+
"verify:fast": "bun scripts/run-static-checks.mjs --format && bun test:changed",
|
|
130
|
+
"extension:zip": "node scripts/pack-chrome-extension.mjs",
|
|
131
|
+
"extension:release": "node scripts/release-chrome-extension.mjs",
|
|
132
|
+
release: "node scripts/release.mjs",
|
|
133
|
+
knip: "knip",
|
|
134
|
+
check: "bun scripts/run-static-checks.mjs --format && bun check:boundaries && bun compatibility:bdd && bun rust:packages:check",
|
|
135
|
+
prepare: "husky",
|
|
136
|
+
ladle: "ladle serve",
|
|
137
|
+
"ladle:build": "ladle build"
|
|
138
|
+
},
|
|
139
|
+
dependencies: {
|
|
140
|
+
"@mariozechner/pi-agent-core": "^0.73.1",
|
|
141
|
+
"@mariozechner/pi-ai": "^0.73.1",
|
|
142
|
+
"@modelcontextprotocol/server": "^2.0.0-beta.4",
|
|
143
|
+
"@tailwindcss/typography": "^0.5.20",
|
|
144
|
+
"@tanstack/react-router": "^1.170.18",
|
|
145
|
+
"@tanstack/react-start": "^1.168.28",
|
|
146
|
+
"@tanstack/react-virtual": "^3.14.6",
|
|
147
|
+
"class-variance-authority": "^0.7.1",
|
|
148
|
+
clsx: "^2.1.1",
|
|
149
|
+
conf: "^15.1.0",
|
|
150
|
+
diff: "^9.0.0",
|
|
151
|
+
jszip: "^3.10.1",
|
|
152
|
+
"lucide-react": "^0.563.0",
|
|
153
|
+
"radix-ui": "^1.6.2",
|
|
154
|
+
react: "^19.2.7",
|
|
155
|
+
"react-dom": "^19.2.7",
|
|
156
|
+
"react-markdown": "^10.1.0",
|
|
157
|
+
swr: "^2.4.2",
|
|
158
|
+
"tailwind-merge": "^3.6.0",
|
|
159
|
+
three: "0.185.1",
|
|
160
|
+
"tw-animate-css": "^1.4.0",
|
|
161
|
+
zod: "^4.4.3"
|
|
162
|
+
},
|
|
163
|
+
optionalDependencies: {
|
|
164
|
+
"@tonyclaw/agent-inspector-backend-darwin-arm64": "3.0.48",
|
|
165
|
+
"@tonyclaw/agent-inspector-backend-linux-x64-gnu": "3.0.48",
|
|
166
|
+
"@tonyclaw/agent-inspector-backend-win32-x64-msvc": "3.0.48",
|
|
167
|
+
"better-sqlite3": "^12.11.1",
|
|
168
|
+
rcedit: "4.0.1"
|
|
169
|
+
},
|
|
170
|
+
devDependencies: {
|
|
171
|
+
"@biomejs/biome": "^2.5.3",
|
|
172
|
+
"@eslint/js": "^10.0.1",
|
|
173
|
+
"@ladle/react": "^5.1.1",
|
|
174
|
+
"@radix-ui/colors": "^3.0.0",
|
|
175
|
+
"@tailwindcss/vite": "^4.3.2",
|
|
176
|
+
"@tanstack/router-plugin": "^1.168.20",
|
|
177
|
+
"@types/bun": "^1.3.14",
|
|
178
|
+
"@types/react": "^19.2.17",
|
|
179
|
+
"@types/react-dom": "^19.2.3",
|
|
180
|
+
"@types/three": "0.185.1",
|
|
181
|
+
"@typescript-eslint/eslint-plugin": "^8.64.0",
|
|
182
|
+
"@typescript-eslint/parser": "^8.64.0",
|
|
183
|
+
"@vitejs/plugin-react": "^5.2.0",
|
|
184
|
+
ajv: "8.20.0",
|
|
185
|
+
"ajv-formats": "3.0.1",
|
|
186
|
+
"colorjs.io": "^0.7.0",
|
|
187
|
+
esbuild: "^0.28.1",
|
|
188
|
+
eslint: "^9.39.5",
|
|
189
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
190
|
+
"eslint-plugin-functional": "^9.0.5",
|
|
191
|
+
"eslint-plugin-unicorn": "^63.0.0",
|
|
192
|
+
husky: "^9.1.7",
|
|
193
|
+
knip: "^5.88.1",
|
|
194
|
+
nitro: "^3.0.260610-beta",
|
|
195
|
+
playwright: "^1.61.1",
|
|
196
|
+
tailwindcss: "^4.3.2",
|
|
197
|
+
typescript: "^5.9.3",
|
|
198
|
+
vite: "^7.3.6",
|
|
199
|
+
"vite-tsconfig-paths": "^6.1.1"
|
|
200
|
+
},
|
|
201
|
+
overrides: {
|
|
202
|
+
undici: ">=7.24.0 <8.0.0",
|
|
203
|
+
rollup: ">=4.59.0 <5.0.0",
|
|
204
|
+
postcss: ">=8.5.10 <9.0.0",
|
|
205
|
+
"js-yaml": ">=4.1.2 <5.0.0",
|
|
206
|
+
flatted: ">=3.4.0 <4.0.0",
|
|
207
|
+
"smol-toml": ">=1.6.1 <2.0.0",
|
|
208
|
+
koa: ">=2.16.4 <3.0.0",
|
|
209
|
+
"@babel/core": ">=7.29.1 <8.0.0",
|
|
210
|
+
"@typescript-eslint/typescript-estree": "^8.63.0",
|
|
211
|
+
vite: "^7.3.6"
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
17
217
|
// node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
|
|
18
218
|
// @__NO_SIDE_EFFECTS__
|
|
19
219
|
function $constructor(name, initializer3, params) {
|
|
@@ -15374,229 +15574,542 @@ var init_networkHints = __esm({
|
|
|
15374
15574
|
}
|
|
15375
15575
|
});
|
|
15376
15576
|
|
|
15377
|
-
// src/
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
}
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15385
|
-
|
|
15386
|
-
case "lock_timeout":
|
|
15387
|
-
case "port_exhausted":
|
|
15388
|
-
case "registry_io":
|
|
15389
|
-
case "restart_failed_degraded":
|
|
15390
|
-
case "restart_failed_rolled_back":
|
|
15391
|
-
case "shutdown_failed":
|
|
15392
|
-
return true;
|
|
15393
|
-
case "argument_invalid":
|
|
15394
|
-
case "config_mismatch":
|
|
15395
|
-
case "data_dir_conflict":
|
|
15396
|
-
case "data_dir_invalid":
|
|
15397
|
-
case "identity_mismatch":
|
|
15398
|
-
case "instance_not_found":
|
|
15399
|
-
case "lock_not_owned":
|
|
15400
|
-
case "name_invalid":
|
|
15401
|
-
case "port_conflict":
|
|
15402
|
-
case "port_invalid":
|
|
15403
|
-
case "record_invalid":
|
|
15404
|
-
case "self_lifecycle_unsupported":
|
|
15405
|
-
return false;
|
|
15406
|
-
}
|
|
15577
|
+
// src/cli/rustBackendPackage.ts
|
|
15578
|
+
import { spawnSync } from "node:child_process";
|
|
15579
|
+
import { createHash } from "node:crypto";
|
|
15580
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
15581
|
+
import { createRequire } from "node:module";
|
|
15582
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
15583
|
+
import { fileURLToPath } from "node:url";
|
|
15584
|
+
function packageFailure(code, message) {
|
|
15585
|
+
return { kind: "error", error: { code, message } };
|
|
15407
15586
|
}
|
|
15408
|
-
function
|
|
15409
|
-
return {
|
|
15587
|
+
function targetFailure(message) {
|
|
15588
|
+
return { kind: "error", error: { code: "unsupported_platform", message } };
|
|
15410
15589
|
}
|
|
15411
|
-
|
|
15412
|
-
|
|
15413
|
-
|
|
15414
|
-
|
|
15415
|
-
|
|
15416
|
-
|
|
15417
|
-
|
|
15418
|
-
INSTANCE_API_SCHEMA_VERSION = 1;
|
|
15419
|
-
InstanceStateSchema = external_exports.enum(["running", "stopped", "conflict"]);
|
|
15420
|
-
InstanceStateReasonSchema = external_exports.enum(["identity_mismatch", "port_conflict"]);
|
|
15421
|
-
InstanceUrlsSchema = external_exports.object({
|
|
15422
|
-
ui: external_exports.url(),
|
|
15423
|
-
api: external_exports.url(),
|
|
15424
|
-
health: external_exports.url(),
|
|
15425
|
-
proxy: external_exports.url(),
|
|
15426
|
-
openai: external_exports.url(),
|
|
15427
|
-
mcp: external_exports.url()
|
|
15428
|
-
}).strict();
|
|
15429
|
-
InstanceStatusOutputSchema = external_exports.object({
|
|
15430
|
-
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
15431
|
-
name: external_exports.string().min(1),
|
|
15432
|
-
instanceId: external_exports.string().min(1),
|
|
15433
|
-
state: InstanceStateSchema,
|
|
15434
|
-
stateReason: InstanceStateReasonSchema.nullable(),
|
|
15435
|
-
checkedAt: external_exports.iso.datetime(),
|
|
15436
|
-
createdAt: external_exports.iso.datetime(),
|
|
15437
|
-
updatedAt: external_exports.iso.datetime(),
|
|
15438
|
-
launch: external_exports.object({
|
|
15439
|
-
launchId: external_exports.string().min(1),
|
|
15440
|
-
startedAt: external_exports.iso.datetime()
|
|
15441
|
-
}).strict(),
|
|
15442
|
-
host: external_exports.string().min(1),
|
|
15443
|
-
publicPort: external_exports.number().int().min(1).max(65535),
|
|
15444
|
-
upstreamPort: external_exports.number().int().min(1).max(65535),
|
|
15445
|
-
basePath: external_exports.string().refine(isCanonicalPublicBasePath, "Invalid public Base Path"),
|
|
15446
|
-
captureMode: external_exports.enum(["simple", "full"]),
|
|
15447
|
-
backend: BackendImplementationSchema.default("typescript"),
|
|
15448
|
-
uiEnabled: external_exports.boolean(),
|
|
15449
|
-
dataDir: external_exports.string().min(1),
|
|
15450
|
-
supervisorPid: external_exports.number().int().positive().nullable(),
|
|
15451
|
-
urls: InstanceUrlsSchema
|
|
15452
|
-
}).strict();
|
|
15453
|
-
InstanceConnectionSurfacesSchema = external_exports.object({
|
|
15454
|
-
ui: external_exports.object({
|
|
15455
|
-
enabled: external_exports.boolean(),
|
|
15456
|
-
baseUrl: external_exports.url().nullable()
|
|
15457
|
-
}).strict(),
|
|
15458
|
-
control: external_exports.object({ baseUrl: external_exports.url() }).strict(),
|
|
15459
|
-
agent: external_exports.object({ baseUrl: external_exports.url() }).strict()
|
|
15460
|
-
}).strict();
|
|
15461
|
-
InstanceConnectionOutputSchema = external_exports.object({
|
|
15462
|
-
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
15463
|
-
uiEnabled: external_exports.boolean(),
|
|
15464
|
-
instance: InstanceStatusOutputSchema,
|
|
15465
|
-
surfaces: InstanceConnectionSurfacesSchema,
|
|
15466
|
-
/** @deprecated Use surfaces.control.baseUrl or surfaces.agent.baseUrl. */
|
|
15467
|
-
baseUrl: external_exports.url(),
|
|
15468
|
-
endpoints: InstanceUrlsSchema,
|
|
15469
|
-
environment: external_exports.object({
|
|
15470
|
-
ANTHROPIC_BASE_URL: external_exports.url(),
|
|
15471
|
-
LLM_BASE_URL: external_exports.url(),
|
|
15472
|
-
OPENAI_BASE_URL: external_exports.url(),
|
|
15473
|
-
AGENT_INSPECTOR_MCP_URL: external_exports.url()
|
|
15474
|
-
}).strict(),
|
|
15475
|
-
mcp: external_exports.object({
|
|
15476
|
-
serverName: external_exports.string().min(1),
|
|
15477
|
-
transport: external_exports.literal("streamable-http"),
|
|
15478
|
-
url: external_exports.url()
|
|
15479
|
-
}).strict(),
|
|
15480
|
-
codex: external_exports.object({
|
|
15481
|
-
providerName: external_exports.string().min(1),
|
|
15482
|
-
baseUrl: external_exports.url(),
|
|
15483
|
-
wireApi: external_exports.literal("responses")
|
|
15484
|
-
}).strict()
|
|
15485
|
-
}).strict();
|
|
15486
|
-
InstanceStartRequestSchema = external_exports.object({
|
|
15487
|
-
port: external_exports.number().int().min(1).max(65535).optional(),
|
|
15488
|
-
basePath: external_exports.string().min(1).max(2048).refine(
|
|
15489
|
-
(value) => normalizePublicBasePath(value) !== null,
|
|
15490
|
-
"Base Path must use URL-safe path segments without traversal, encoded separators, or markup characters"
|
|
15491
|
-
).optional(),
|
|
15492
|
-
host: external_exports.string().min(1).max(253).refine(
|
|
15493
|
-
(value) => value.trim() === value && !value.includes("://") && !value.includes("/") && !value.includes("\\") && !/\s/u.test(value),
|
|
15494
|
-
"Host must be a hostname or IP address without protocol, path, or whitespace"
|
|
15495
|
-
).optional(),
|
|
15496
|
-
captureMode: external_exports.enum(["simple", "full"]).optional(),
|
|
15497
|
-
backend: BackendImplementationSchema.optional(),
|
|
15498
|
-
uiEnabled: external_exports.boolean().optional(),
|
|
15499
|
-
dataDir: external_exports.string().trim().min(1).max(32767).optional()
|
|
15500
|
-
}).strict();
|
|
15501
|
-
InstanceEmptyRequestSchema = external_exports.object({}).strict();
|
|
15502
|
-
InstanceOperationSchema = external_exports.enum(["start", "stop", "restart"]);
|
|
15503
|
-
InstanceOperationOutcomeSchema = external_exports.enum([
|
|
15504
|
-
"created",
|
|
15505
|
-
"started",
|
|
15506
|
-
"already_running",
|
|
15507
|
-
"stopped",
|
|
15508
|
-
"already_stopped",
|
|
15509
|
-
"restarted"
|
|
15510
|
-
]);
|
|
15511
|
-
InstanceOperationOutputSchema = external_exports.object({
|
|
15512
|
-
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
15513
|
-
operation: InstanceOperationSchema,
|
|
15514
|
-
outcome: InstanceOperationOutcomeSchema,
|
|
15515
|
-
instance: InstanceStatusOutputSchema
|
|
15516
|
-
}).strict();
|
|
15517
|
-
InstanceListOutputSchema = external_exports.object({
|
|
15518
|
-
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
15519
|
-
instances: external_exports.array(InstanceStatusOutputSchema)
|
|
15520
|
-
}).strict();
|
|
15521
|
-
InstancePublicErrorCodeSchema = external_exports.enum([
|
|
15522
|
-
"argument_invalid",
|
|
15523
|
-
"config_mismatch",
|
|
15524
|
-
"data_dir_conflict",
|
|
15525
|
-
"data_dir_invalid",
|
|
15526
|
-
"identity_mismatch",
|
|
15527
|
-
"instance_not_found",
|
|
15528
|
-
"launch_failed",
|
|
15529
|
-
"launch_unavailable",
|
|
15530
|
-
"lock_not_owned",
|
|
15531
|
-
"lock_timeout",
|
|
15532
|
-
"name_invalid",
|
|
15533
|
-
"port_conflict",
|
|
15534
|
-
"port_exhausted",
|
|
15535
|
-
"port_invalid",
|
|
15536
|
-
"record_invalid",
|
|
15537
|
-
"registry_io",
|
|
15538
|
-
"restart_failed_degraded",
|
|
15539
|
-
"restart_failed_rolled_back",
|
|
15540
|
-
"self_lifecycle_unsupported",
|
|
15541
|
-
"shutdown_failed"
|
|
15542
|
-
]);
|
|
15543
|
-
InstancePublicErrorSchema = external_exports.object({
|
|
15544
|
-
code: InstancePublicErrorCodeSchema,
|
|
15545
|
-
message: external_exports.string().min(1),
|
|
15546
|
-
retryable: external_exports.boolean()
|
|
15547
|
-
}).strict();
|
|
15548
|
-
InstanceErrorOutputSchema = external_exports.object({
|
|
15549
|
-
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
15550
|
-
error: InstancePublicErrorSchema
|
|
15551
|
-
}).strict();
|
|
15590
|
+
function detectLinuxLibc() {
|
|
15591
|
+
if (process.platform !== "linux") return "not-applicable";
|
|
15592
|
+
const report = process.report.getReport();
|
|
15593
|
+
const header = objectProperty(report, "header");
|
|
15594
|
+
const glibcVersion = objectProperty(header, "glibcVersionRuntime");
|
|
15595
|
+
if (typeof glibcVersion === "string" && glibcVersion.length > 0) {
|
|
15596
|
+
return "glibc";
|
|
15552
15597
|
}
|
|
15553
|
-
|
|
15554
|
-
|
|
15555
|
-
// src/proxy/privateDataPath.ts
|
|
15556
|
-
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
15557
|
-
import {
|
|
15558
|
-
closeSync,
|
|
15559
|
-
constants,
|
|
15560
|
-
fchmodSync,
|
|
15561
|
-
fstatSync,
|
|
15562
|
-
lstatSync,
|
|
15563
|
-
mkdirSync,
|
|
15564
|
-
openSync,
|
|
15565
|
-
readdirSync,
|
|
15566
|
-
realpathSync
|
|
15567
|
-
} from "node:fs";
|
|
15568
|
-
import { join, parse as parse3, resolve as resolve2, sep } from "node:path";
|
|
15569
|
-
function windowsSystemPath(executable) {
|
|
15570
|
-
const systemRoot = process.env["SystemRoot"] ?? "C:\\Windows";
|
|
15571
|
-
return `${systemRoot}\\System32\\${executable}`;
|
|
15572
|
-
}
|
|
15573
|
-
function runWindowsCommand(executable, args) {
|
|
15574
|
-
const resolved = process.platform === "win32" && /^(whoami|icacls)\.exe$/iu.test(executable) ? windowsSystemPath(executable) : executable;
|
|
15575
|
-
const result = spawnSync2(resolved, [...args], {
|
|
15576
|
-
encoding: "utf8",
|
|
15577
|
-
shell: false,
|
|
15578
|
-
windowsHide: true
|
|
15579
|
-
});
|
|
15580
|
-
return { status: result.status, stdout: result.stdout };
|
|
15581
|
-
}
|
|
15582
|
-
function windowsUserSid(output) {
|
|
15583
|
-
const match = /S-\d+(?:-\d+)+/.exec(output);
|
|
15584
|
-
return match?.[0] ?? null;
|
|
15585
|
-
}
|
|
15586
|
-
function resolveWindowsUserSid(run) {
|
|
15587
|
-
if (run === runWindowsCommand && cachedWindowsSid !== null) return cachedWindowsSid;
|
|
15588
|
-
const identity = run("whoami.exe", ["/user", "/fo", "csv", "/nh"]);
|
|
15589
|
-
if (identity.status !== 0) return null;
|
|
15590
|
-
const sid = windowsUserSid(identity.stdout);
|
|
15591
|
-
if (run === runWindowsCommand) cachedWindowsSid = sid;
|
|
15592
|
-
return sid;
|
|
15598
|
+
const sharedObjects = objectProperty(report, "sharedObjects");
|
|
15599
|
+
return Array.isArray(sharedObjects) && sharedObjects.some((path2) => typeof path2 === "string" && path2.toLowerCase().includes("musl")) ? "musl" : "unknown";
|
|
15593
15600
|
}
|
|
15594
|
-
function
|
|
15595
|
-
|
|
15601
|
+
function objectProperty(value, name) {
|
|
15602
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
15603
|
+
return Object.getOwnPropertyDescriptor(value, name)?.value;
|
|
15596
15604
|
}
|
|
15597
|
-
function
|
|
15598
|
-
|
|
15599
|
-
|
|
15605
|
+
function resolveRustBackendTarget(platform = process.platform, arch = process.arch, libc = platform === "linux" ? detectLinuxLibc() : "not-applicable") {
|
|
15606
|
+
switch (platform) {
|
|
15607
|
+
case "win32":
|
|
15608
|
+
return arch === "x64" ? {
|
|
15609
|
+
kind: "success",
|
|
15610
|
+
value: {
|
|
15611
|
+
packageName: "@tonyclaw/agent-inspector-backend-win32-x64-msvc",
|
|
15612
|
+
target: "x86_64-pc-windows-msvc",
|
|
15613
|
+
binary: "bin/agent-inspector-backend.exe",
|
|
15614
|
+
os: "win32",
|
|
15615
|
+
cpu: "x64",
|
|
15616
|
+
libc: null
|
|
15617
|
+
}
|
|
15618
|
+
} : targetFailure(`Rust backend packages do not support Windows ${arch}.`);
|
|
15619
|
+
case "linux":
|
|
15620
|
+
if (arch !== "x64")
|
|
15621
|
+
return targetFailure(`Rust backend packages do not support Linux ${arch}.`);
|
|
15622
|
+
if (libc !== "glibc") {
|
|
15623
|
+
return targetFailure(
|
|
15624
|
+
`The Linux Rust backend package requires glibc; detected ${libc}. No binary was started.`
|
|
15625
|
+
);
|
|
15626
|
+
}
|
|
15627
|
+
return {
|
|
15628
|
+
kind: "success",
|
|
15629
|
+
value: {
|
|
15630
|
+
packageName: "@tonyclaw/agent-inspector-backend-linux-x64-gnu",
|
|
15631
|
+
target: "x86_64-unknown-linux-gnu",
|
|
15632
|
+
binary: "bin/agent-inspector-backend",
|
|
15633
|
+
os: "linux",
|
|
15634
|
+
cpu: "x64",
|
|
15635
|
+
libc: "glibc"
|
|
15636
|
+
}
|
|
15637
|
+
};
|
|
15638
|
+
case "darwin":
|
|
15639
|
+
return arch === "arm64" ? {
|
|
15640
|
+
kind: "success",
|
|
15641
|
+
value: {
|
|
15642
|
+
packageName: "@tonyclaw/agent-inspector-backend-darwin-arm64",
|
|
15643
|
+
target: "aarch64-apple-darwin",
|
|
15644
|
+
binary: "bin/agent-inspector-backend",
|
|
15645
|
+
os: "darwin",
|
|
15646
|
+
cpu: "arm64",
|
|
15647
|
+
libc: null
|
|
15648
|
+
}
|
|
15649
|
+
} : targetFailure(`Rust backend packages do not support macOS ${arch}.`);
|
|
15650
|
+
default:
|
|
15651
|
+
return targetFailure(`Rust backend packages do not support ${platform} ${arch}.`);
|
|
15652
|
+
}
|
|
15653
|
+
}
|
|
15654
|
+
function readJson(path2) {
|
|
15655
|
+
try {
|
|
15656
|
+
const value = JSON.parse(readFileSync(path2, "utf8"));
|
|
15657
|
+
return { kind: "success", value };
|
|
15658
|
+
} catch {
|
|
15659
|
+
return { kind: "error" };
|
|
15660
|
+
}
|
|
15661
|
+
}
|
|
15662
|
+
function isConfinedPath(root, candidate) {
|
|
15663
|
+
const child = relative(root, candidate);
|
|
15664
|
+
return child.length > 0 && !child.startsWith("..") && !isAbsolute(child);
|
|
15665
|
+
}
|
|
15666
|
+
function identitiesMatch(left, right) {
|
|
15667
|
+
return left.schemaVersion === right.schemaVersion && left.name === right.name && left.packageVersion === right.packageVersion && left.target === right.target && left.binary === right.binary && left.cliProtocol === right.cliProtocol && left.productionReady === right.productionReady && left.capabilities.nodeProtectedIngress === right.capabilities.nodeProtectedIngress && left.capabilities.basePath === right.capabilities.basePath && left.capabilities.namedInstances === right.capabilities.namedInstances && left.capabilities.gracefulShutdown === right.capabilities.gracefulShutdown;
|
|
15668
|
+
}
|
|
15669
|
+
function probeBinaryIdentity(binaryPath, identityFlag) {
|
|
15670
|
+
const result = spawnSync(binaryPath, [identityFlag], {
|
|
15671
|
+
encoding: "utf8",
|
|
15672
|
+
windowsHide: true,
|
|
15673
|
+
timeout: RUST_BACKEND_IDENTITY_TIMEOUT_MS,
|
|
15674
|
+
maxBuffer: 64 * 1024
|
|
15675
|
+
});
|
|
15676
|
+
if (result.error !== void 0) {
|
|
15677
|
+
return { kind: "error", message: result.error.message };
|
|
15678
|
+
}
|
|
15679
|
+
if (result.status !== 0) {
|
|
15680
|
+
return {
|
|
15681
|
+
kind: "error",
|
|
15682
|
+
message: `identity command exited with status ${String(result.status)}`
|
|
15683
|
+
};
|
|
15684
|
+
}
|
|
15685
|
+
let raw;
|
|
15686
|
+
try {
|
|
15687
|
+
raw = JSON.parse(result.stdout);
|
|
15688
|
+
} catch {
|
|
15689
|
+
return { kind: "error", message: "identity command did not return JSON" };
|
|
15690
|
+
}
|
|
15691
|
+
const parsed = RustBackendIdentitySchema.safeParse(raw);
|
|
15692
|
+
return parsed.success ? { kind: "success", value: parsed.data } : { kind: "error", message: "identity command returned an unsupported contract" };
|
|
15693
|
+
}
|
|
15694
|
+
function defaultResolvePackageJson(specifier) {
|
|
15695
|
+
try {
|
|
15696
|
+
return packageRequire.resolve(specifier);
|
|
15697
|
+
} catch {
|
|
15698
|
+
const suffix = "/package.json";
|
|
15699
|
+
const packageName = specifier.endsWith(suffix) ? specifier.slice(0, -suffix.length) : "";
|
|
15700
|
+
const directoryName = packageName.split("/").at(-1);
|
|
15701
|
+
if (directoryName !== void 0 && directoryName.length > 0) {
|
|
15702
|
+
const localPackageJson = resolve(
|
|
15703
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
15704
|
+
"../packages",
|
|
15705
|
+
directoryName,
|
|
15706
|
+
"package.json"
|
|
15707
|
+
);
|
|
15708
|
+
if (existsSync(localPackageJson)) return localPackageJson;
|
|
15709
|
+
}
|
|
15710
|
+
return packageRequire.resolve(specifier);
|
|
15711
|
+
}
|
|
15712
|
+
}
|
|
15713
|
+
function resolveRustBackendPackage(options) {
|
|
15714
|
+
const target = resolveRustBackendTarget(options.platform, options.arch, options.libc);
|
|
15715
|
+
if (target.kind === "error") return { kind: "error", error: target.error };
|
|
15716
|
+
const packageJsonSpecifier = `${target.value.packageName}/package.json`;
|
|
15717
|
+
let packageJsonPath;
|
|
15718
|
+
try {
|
|
15719
|
+
packageJsonPath = (options.resolvePackageJson ?? defaultResolvePackageJson)(
|
|
15720
|
+
packageJsonSpecifier
|
|
15721
|
+
);
|
|
15722
|
+
} catch {
|
|
15723
|
+
return packageFailure(
|
|
15724
|
+
"package_missing",
|
|
15725
|
+
`Rust backend ${target.value.target} was requested, but optional package ${target.value.packageName}@${options.rootVersion} is not installed. Reinstall without omitting optional dependencies; no TypeScript fallback was used.`
|
|
15726
|
+
);
|
|
15727
|
+
}
|
|
15728
|
+
const rawPackage = readJson(packageJsonPath);
|
|
15729
|
+
if (rawPackage.kind === "error") {
|
|
15730
|
+
return packageFailure("package_invalid", `Cannot read ${packageJsonSpecifier}.`);
|
|
15731
|
+
}
|
|
15732
|
+
const packageJson = RustBackendPackageJsonSchema.safeParse(rawPackage.value);
|
|
15733
|
+
if (!packageJson.success) {
|
|
15734
|
+
return packageFailure(
|
|
15735
|
+
"package_invalid",
|
|
15736
|
+
`Package ${target.value.packageName} does not contain the Rust backend package contract.`
|
|
15737
|
+
);
|
|
15738
|
+
}
|
|
15739
|
+
if (packageJson.data.name !== target.value.packageName || packageJson.data.version !== options.rootVersion) {
|
|
15740
|
+
return packageFailure(
|
|
15741
|
+
"version_mismatch",
|
|
15742
|
+
`Rust backend package must exactly match @tonyclaw/agent-inspector@${options.rootVersion}; found ${packageJson.data.name}@${packageJson.data.version}.`
|
|
15743
|
+
);
|
|
15744
|
+
}
|
|
15745
|
+
const metadata = packageJson.data.agentInspectorRustBackend;
|
|
15746
|
+
const expectedLibc = target.value.libc === null ? void 0 : [target.value.libc];
|
|
15747
|
+
if (metadata.target !== target.value.target || metadata.binary !== target.value.binary || metadata.manifest !== "binary-manifest.json" || packageJson.data.os.length !== 1 || packageJson.data.os[0] !== target.value.os || packageJson.data.cpu.length !== 1 || packageJson.data.cpu[0] !== target.value.cpu || JSON.stringify(packageJson.data.libc) !== JSON.stringify(expectedLibc)) {
|
|
15748
|
+
return packageFailure(
|
|
15749
|
+
"target_mismatch",
|
|
15750
|
+
`Package ${target.value.packageName} does not match target ${target.value.target}.`
|
|
15751
|
+
);
|
|
15752
|
+
}
|
|
15753
|
+
const packageRoot = dirname(packageJsonPath);
|
|
15754
|
+
const manifestPath = resolve(packageRoot, metadata.manifest);
|
|
15755
|
+
const binaryPath = resolve(packageRoot, metadata.binary);
|
|
15756
|
+
if (!isConfinedPath(packageRoot, manifestPath) || !isConfinedPath(packageRoot, binaryPath)) {
|
|
15757
|
+
return packageFailure(
|
|
15758
|
+
"package_invalid",
|
|
15759
|
+
`Package ${target.value.packageName} contains an unsafe artifact path.`
|
|
15760
|
+
);
|
|
15761
|
+
}
|
|
15762
|
+
const rawManifest = readJson(manifestPath);
|
|
15763
|
+
if (rawManifest.kind === "error") {
|
|
15764
|
+
return packageFailure(
|
|
15765
|
+
"manifest_invalid",
|
|
15766
|
+
`Rust backend package ${target.value.packageName} is incomplete: binary-manifest.json is missing or invalid.`
|
|
15767
|
+
);
|
|
15768
|
+
}
|
|
15769
|
+
const manifest = RustBackendBinaryManifestSchema.safeParse(rawManifest.value);
|
|
15770
|
+
if (!manifest.success) {
|
|
15771
|
+
return packageFailure(
|
|
15772
|
+
"manifest_invalid",
|
|
15773
|
+
`Rust backend package ${target.value.packageName} has an invalid target manifest.`
|
|
15774
|
+
);
|
|
15775
|
+
}
|
|
15776
|
+
if (manifest.data.packageName !== target.value.packageName || manifest.data.packageVersion !== options.rootVersion || manifest.data.identity.packageVersion !== options.rootVersion) {
|
|
15777
|
+
return packageFailure(
|
|
15778
|
+
"version_mismatch",
|
|
15779
|
+
`Rust backend manifest must exactly match @tonyclaw/agent-inspector@${options.rootVersion}.`
|
|
15780
|
+
);
|
|
15781
|
+
}
|
|
15782
|
+
if (manifest.data.target !== target.value.target || manifest.data.binary !== target.value.binary || manifest.data.identity.target !== target.value.target || manifest.data.identity.binary !== target.value.binary) {
|
|
15783
|
+
return packageFailure(
|
|
15784
|
+
"target_mismatch",
|
|
15785
|
+
`Rust backend manifest identity does not match target ${target.value.target}.`
|
|
15786
|
+
);
|
|
15787
|
+
}
|
|
15788
|
+
let binaryBytes;
|
|
15789
|
+
try {
|
|
15790
|
+
const stats = statSync(binaryPath);
|
|
15791
|
+
if (!stats.isFile()) {
|
|
15792
|
+
return packageFailure("binary_invalid", `Rust backend artifact is not a regular file.`);
|
|
15793
|
+
}
|
|
15794
|
+
if (target.value.os !== "win32" && (stats.mode & 73) === 0) {
|
|
15795
|
+
return packageFailure("binary_invalid", `Rust backend artifact is not executable.`);
|
|
15796
|
+
}
|
|
15797
|
+
binaryBytes = readFileSync(binaryPath);
|
|
15798
|
+
} catch {
|
|
15799
|
+
return packageFailure(
|
|
15800
|
+
"binary_missing",
|
|
15801
|
+
`Rust backend binary ${target.value.binary} is missing from ${target.value.packageName}.`
|
|
15802
|
+
);
|
|
15803
|
+
}
|
|
15804
|
+
const sha256 = createHash("sha256").update(binaryBytes).digest("hex");
|
|
15805
|
+
if (sha256 !== manifest.data.sha256) {
|
|
15806
|
+
return packageFailure(
|
|
15807
|
+
"hash_mismatch",
|
|
15808
|
+
`Rust backend binary integrity check failed for ${target.value.packageName}; no binary was started.`
|
|
15809
|
+
);
|
|
15810
|
+
}
|
|
15811
|
+
const probed = (options.identityProbe ?? probeBinaryIdentity)(binaryPath, metadata.identityFlag);
|
|
15812
|
+
if (probed.kind === "error") {
|
|
15813
|
+
return packageFailure(
|
|
15814
|
+
"identity_failed",
|
|
15815
|
+
`Rust backend binary did not pass the production identity gate: ${probed.message}. No TypeScript fallback was used.`
|
|
15816
|
+
);
|
|
15817
|
+
}
|
|
15818
|
+
if (!identitiesMatch(probed.value, manifest.data.identity)) {
|
|
15819
|
+
return packageFailure(
|
|
15820
|
+
"identity_mismatch",
|
|
15821
|
+
`Rust backend binary identity differs from its signed package manifest; no binary was started.`
|
|
15822
|
+
);
|
|
15823
|
+
}
|
|
15824
|
+
return {
|
|
15825
|
+
kind: "success",
|
|
15826
|
+
value: {
|
|
15827
|
+
command: binaryPath,
|
|
15828
|
+
args: [],
|
|
15829
|
+
packageName: target.value.packageName,
|
|
15830
|
+
packageVersion: options.rootVersion,
|
|
15831
|
+
target: target.value.target,
|
|
15832
|
+
sha256
|
|
15833
|
+
}
|
|
15834
|
+
};
|
|
15835
|
+
}
|
|
15836
|
+
function resolvePreferredBackendImplementation(options) {
|
|
15837
|
+
return resolveRustBackendPackage(options).kind === "success" ? "rust" : "typescript";
|
|
15838
|
+
}
|
|
15839
|
+
var RUST_BACKEND_IDENTITY_FLAG, RUST_BACKEND_CLI_PROTOCOL, RUST_BACKEND_IDENTITY_TIMEOUT_MS, RustBackendIdentitySchema, RustBackendPackageJsonSchema, RustBackendBinaryManifestSchema, packageRequire;
|
|
15840
|
+
var init_rustBackendPackage = __esm({
|
|
15841
|
+
"src/cli/rustBackendPackage.ts"() {
|
|
15842
|
+
"use strict";
|
|
15843
|
+
init_zod();
|
|
15844
|
+
RUST_BACKEND_IDENTITY_FLAG = "--agent-inspector-package-identity";
|
|
15845
|
+
RUST_BACKEND_CLI_PROTOCOL = "agent-inspector-cli-backend-v1";
|
|
15846
|
+
RUST_BACKEND_IDENTITY_TIMEOUT_MS = 2e3;
|
|
15847
|
+
RustBackendIdentitySchema = external_exports.object({
|
|
15848
|
+
schemaVersion: external_exports.literal(1),
|
|
15849
|
+
name: external_exports.literal("agent-inspector-backend"),
|
|
15850
|
+
packageVersion: external_exports.string().min(1),
|
|
15851
|
+
target: external_exports.string().min(1),
|
|
15852
|
+
binary: external_exports.string().min(1),
|
|
15853
|
+
cliProtocol: external_exports.literal(RUST_BACKEND_CLI_PROTOCOL),
|
|
15854
|
+
productionReady: external_exports.literal(true),
|
|
15855
|
+
capabilities: external_exports.object({
|
|
15856
|
+
nodeProtectedIngress: external_exports.literal(true),
|
|
15857
|
+
basePath: external_exports.literal(true),
|
|
15858
|
+
namedInstances: external_exports.literal(true),
|
|
15859
|
+
gracefulShutdown: external_exports.literal(true)
|
|
15860
|
+
}).strict()
|
|
15861
|
+
}).strict();
|
|
15862
|
+
RustBackendPackageJsonSchema = external_exports.object({
|
|
15863
|
+
name: external_exports.string().min(1),
|
|
15864
|
+
version: external_exports.string().min(1),
|
|
15865
|
+
os: external_exports.array(external_exports.string()).min(1),
|
|
15866
|
+
cpu: external_exports.array(external_exports.string()).min(1),
|
|
15867
|
+
libc: external_exports.array(external_exports.string()).optional(),
|
|
15868
|
+
agentInspectorRustBackend: external_exports.object({
|
|
15869
|
+
schemaVersion: external_exports.literal(1),
|
|
15870
|
+
target: external_exports.string().min(1),
|
|
15871
|
+
binary: external_exports.string().min(1),
|
|
15872
|
+
manifest: external_exports.string().min(1),
|
|
15873
|
+
identityFlag: external_exports.literal(RUST_BACKEND_IDENTITY_FLAG),
|
|
15874
|
+
cliProtocol: external_exports.literal(RUST_BACKEND_CLI_PROTOCOL)
|
|
15875
|
+
}).strict()
|
|
15876
|
+
}).passthrough();
|
|
15877
|
+
RustBackendBinaryManifestSchema = external_exports.object({
|
|
15878
|
+
schemaVersion: external_exports.literal(1),
|
|
15879
|
+
packageName: external_exports.string().min(1),
|
|
15880
|
+
packageVersion: external_exports.string().min(1),
|
|
15881
|
+
target: external_exports.string().min(1),
|
|
15882
|
+
binary: external_exports.string().min(1),
|
|
15883
|
+
sha256: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
15884
|
+
identity: RustBackendIdentitySchema
|
|
15885
|
+
}).strict();
|
|
15886
|
+
packageRequire = createRequire(import.meta.url);
|
|
15887
|
+
}
|
|
15888
|
+
});
|
|
15889
|
+
|
|
15890
|
+
// src/lib/instanceContract.ts
|
|
15891
|
+
function isCanonicalPublicBasePath(value) {
|
|
15892
|
+
const normalized = normalizePublicBasePath(value);
|
|
15893
|
+
return normalized !== null && (normalized.length === 0 ? "/" : normalized) === value;
|
|
15894
|
+
}
|
|
15895
|
+
function isRetryableInstanceError(code) {
|
|
15896
|
+
switch (code) {
|
|
15897
|
+
case "launch_failed":
|
|
15898
|
+
case "launch_unavailable":
|
|
15899
|
+
case "lock_timeout":
|
|
15900
|
+
case "port_exhausted":
|
|
15901
|
+
case "registry_io":
|
|
15902
|
+
case "restart_failed_degraded":
|
|
15903
|
+
case "restart_failed_rolled_back":
|
|
15904
|
+
case "shutdown_failed":
|
|
15905
|
+
return true;
|
|
15906
|
+
case "argument_invalid":
|
|
15907
|
+
case "config_mismatch":
|
|
15908
|
+
case "data_dir_conflict":
|
|
15909
|
+
case "data_dir_invalid":
|
|
15910
|
+
case "identity_mismatch":
|
|
15911
|
+
case "instance_not_found":
|
|
15912
|
+
case "lock_not_owned":
|
|
15913
|
+
case "name_invalid":
|
|
15914
|
+
case "port_conflict":
|
|
15915
|
+
case "port_invalid":
|
|
15916
|
+
case "record_invalid":
|
|
15917
|
+
case "self_lifecycle_unsupported":
|
|
15918
|
+
return false;
|
|
15919
|
+
}
|
|
15920
|
+
}
|
|
15921
|
+
function instanceErrorOutput(error51) {
|
|
15922
|
+
return { schemaVersion: INSTANCE_API_SCHEMA_VERSION, error: error51 };
|
|
15923
|
+
}
|
|
15924
|
+
var INSTANCE_API_SCHEMA_VERSION, InstanceStateSchema, InstanceStateReasonSchema, InstanceUrlsSchema, InstanceStatusOutputSchema, InstanceConnectionSurfacesSchema, InstanceConnectionOutputSchema, InstanceStartRequestSchema, InstanceEmptyRequestSchema, InstanceOperationSchema, InstanceOperationOutcomeSchema, InstanceOperationOutputSchema, InstanceListOutputSchema, InstancePublicErrorCodeSchema, InstancePublicErrorSchema, InstanceErrorOutputSchema;
|
|
15925
|
+
var init_instanceContract = __esm({
|
|
15926
|
+
"src/lib/instanceContract.ts"() {
|
|
15927
|
+
"use strict";
|
|
15928
|
+
init_zod();
|
|
15929
|
+
init_backendImplementation();
|
|
15930
|
+
init_basePath();
|
|
15931
|
+
INSTANCE_API_SCHEMA_VERSION = 1;
|
|
15932
|
+
InstanceStateSchema = external_exports.enum(["running", "stopped", "conflict"]);
|
|
15933
|
+
InstanceStateReasonSchema = external_exports.enum(["identity_mismatch", "port_conflict"]);
|
|
15934
|
+
InstanceUrlsSchema = external_exports.object({
|
|
15935
|
+
ui: external_exports.url(),
|
|
15936
|
+
api: external_exports.url(),
|
|
15937
|
+
health: external_exports.url(),
|
|
15938
|
+
proxy: external_exports.url(),
|
|
15939
|
+
openai: external_exports.url(),
|
|
15940
|
+
mcp: external_exports.url()
|
|
15941
|
+
}).strict();
|
|
15942
|
+
InstanceStatusOutputSchema = external_exports.object({
|
|
15943
|
+
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
15944
|
+
name: external_exports.string().min(1),
|
|
15945
|
+
instanceId: external_exports.string().min(1),
|
|
15946
|
+
state: InstanceStateSchema,
|
|
15947
|
+
stateReason: InstanceStateReasonSchema.nullable(),
|
|
15948
|
+
checkedAt: external_exports.iso.datetime(),
|
|
15949
|
+
createdAt: external_exports.iso.datetime(),
|
|
15950
|
+
updatedAt: external_exports.iso.datetime(),
|
|
15951
|
+
launch: external_exports.object({
|
|
15952
|
+
launchId: external_exports.string().min(1),
|
|
15953
|
+
startedAt: external_exports.iso.datetime()
|
|
15954
|
+
}).strict(),
|
|
15955
|
+
host: external_exports.string().min(1),
|
|
15956
|
+
publicPort: external_exports.number().int().min(1).max(65535),
|
|
15957
|
+
upstreamPort: external_exports.number().int().min(1).max(65535),
|
|
15958
|
+
basePath: external_exports.string().refine(isCanonicalPublicBasePath, "Invalid public Base Path"),
|
|
15959
|
+
captureMode: external_exports.enum(["simple", "full"]),
|
|
15960
|
+
backend: BackendImplementationSchema.default("typescript"),
|
|
15961
|
+
uiEnabled: external_exports.boolean(),
|
|
15962
|
+
dataDir: external_exports.string().min(1),
|
|
15963
|
+
supervisorPid: external_exports.number().int().positive().nullable(),
|
|
15964
|
+
urls: InstanceUrlsSchema
|
|
15965
|
+
}).strict();
|
|
15966
|
+
InstanceConnectionSurfacesSchema = external_exports.object({
|
|
15967
|
+
ui: external_exports.object({
|
|
15968
|
+
enabled: external_exports.boolean(),
|
|
15969
|
+
baseUrl: external_exports.url().nullable()
|
|
15970
|
+
}).strict(),
|
|
15971
|
+
control: external_exports.object({ baseUrl: external_exports.url() }).strict(),
|
|
15972
|
+
agent: external_exports.object({ baseUrl: external_exports.url() }).strict()
|
|
15973
|
+
}).strict();
|
|
15974
|
+
InstanceConnectionOutputSchema = external_exports.object({
|
|
15975
|
+
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
15976
|
+
uiEnabled: external_exports.boolean(),
|
|
15977
|
+
instance: InstanceStatusOutputSchema,
|
|
15978
|
+
surfaces: InstanceConnectionSurfacesSchema,
|
|
15979
|
+
/** @deprecated Use surfaces.control.baseUrl or surfaces.agent.baseUrl. */
|
|
15980
|
+
baseUrl: external_exports.url(),
|
|
15981
|
+
endpoints: InstanceUrlsSchema,
|
|
15982
|
+
environment: external_exports.object({
|
|
15983
|
+
ANTHROPIC_BASE_URL: external_exports.url(),
|
|
15984
|
+
LLM_BASE_URL: external_exports.url(),
|
|
15985
|
+
OPENAI_BASE_URL: external_exports.url(),
|
|
15986
|
+
AGENT_INSPECTOR_MCP_URL: external_exports.url()
|
|
15987
|
+
}).strict(),
|
|
15988
|
+
mcp: external_exports.object({
|
|
15989
|
+
serverName: external_exports.string().min(1),
|
|
15990
|
+
transport: external_exports.literal("streamable-http"),
|
|
15991
|
+
url: external_exports.url()
|
|
15992
|
+
}).strict(),
|
|
15993
|
+
codex: external_exports.object({
|
|
15994
|
+
providerName: external_exports.string().min(1),
|
|
15995
|
+
baseUrl: external_exports.url(),
|
|
15996
|
+
wireApi: external_exports.literal("responses")
|
|
15997
|
+
}).strict()
|
|
15998
|
+
}).strict();
|
|
15999
|
+
InstanceStartRequestSchema = external_exports.object({
|
|
16000
|
+
port: external_exports.number().int().min(1).max(65535).optional(),
|
|
16001
|
+
basePath: external_exports.string().min(1).max(2048).refine(
|
|
16002
|
+
(value) => normalizePublicBasePath(value) !== null,
|
|
16003
|
+
"Base Path must use URL-safe path segments without traversal, encoded separators, or markup characters"
|
|
16004
|
+
).optional(),
|
|
16005
|
+
host: external_exports.string().min(1).max(253).refine(
|
|
16006
|
+
(value) => value.trim() === value && !value.includes("://") && !value.includes("/") && !value.includes("\\") && !/\s/u.test(value),
|
|
16007
|
+
"Host must be a hostname or IP address without protocol, path, or whitespace"
|
|
16008
|
+
).optional(),
|
|
16009
|
+
captureMode: external_exports.enum(["simple", "full"]).optional(),
|
|
16010
|
+
backend: BackendImplementationSchema.optional(),
|
|
16011
|
+
uiEnabled: external_exports.boolean().optional(),
|
|
16012
|
+
dataDir: external_exports.string().trim().min(1).max(32767).optional()
|
|
16013
|
+
}).strict();
|
|
16014
|
+
InstanceEmptyRequestSchema = external_exports.object({}).strict();
|
|
16015
|
+
InstanceOperationSchema = external_exports.enum(["start", "stop", "restart"]);
|
|
16016
|
+
InstanceOperationOutcomeSchema = external_exports.enum([
|
|
16017
|
+
"created",
|
|
16018
|
+
"started",
|
|
16019
|
+
"already_running",
|
|
16020
|
+
"stopped",
|
|
16021
|
+
"already_stopped",
|
|
16022
|
+
"restarted"
|
|
16023
|
+
]);
|
|
16024
|
+
InstanceOperationOutputSchema = external_exports.object({
|
|
16025
|
+
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
16026
|
+
operation: InstanceOperationSchema,
|
|
16027
|
+
outcome: InstanceOperationOutcomeSchema,
|
|
16028
|
+
instance: InstanceStatusOutputSchema
|
|
16029
|
+
}).strict();
|
|
16030
|
+
InstanceListOutputSchema = external_exports.object({
|
|
16031
|
+
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
16032
|
+
instances: external_exports.array(InstanceStatusOutputSchema)
|
|
16033
|
+
}).strict();
|
|
16034
|
+
InstancePublicErrorCodeSchema = external_exports.enum([
|
|
16035
|
+
"argument_invalid",
|
|
16036
|
+
"config_mismatch",
|
|
16037
|
+
"data_dir_conflict",
|
|
16038
|
+
"data_dir_invalid",
|
|
16039
|
+
"identity_mismatch",
|
|
16040
|
+
"instance_not_found",
|
|
16041
|
+
"launch_failed",
|
|
16042
|
+
"launch_unavailable",
|
|
16043
|
+
"lock_not_owned",
|
|
16044
|
+
"lock_timeout",
|
|
16045
|
+
"name_invalid",
|
|
16046
|
+
"port_conflict",
|
|
16047
|
+
"port_exhausted",
|
|
16048
|
+
"port_invalid",
|
|
16049
|
+
"record_invalid",
|
|
16050
|
+
"registry_io",
|
|
16051
|
+
"restart_failed_degraded",
|
|
16052
|
+
"restart_failed_rolled_back",
|
|
16053
|
+
"self_lifecycle_unsupported",
|
|
16054
|
+
"shutdown_failed"
|
|
16055
|
+
]);
|
|
16056
|
+
InstancePublicErrorSchema = external_exports.object({
|
|
16057
|
+
code: InstancePublicErrorCodeSchema,
|
|
16058
|
+
message: external_exports.string().min(1),
|
|
16059
|
+
retryable: external_exports.boolean()
|
|
16060
|
+
}).strict();
|
|
16061
|
+
InstanceErrorOutputSchema = external_exports.object({
|
|
16062
|
+
schemaVersion: external_exports.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
16063
|
+
error: InstancePublicErrorSchema
|
|
16064
|
+
}).strict();
|
|
16065
|
+
}
|
|
16066
|
+
});
|
|
16067
|
+
|
|
16068
|
+
// src/proxy/privateDataPath.ts
|
|
16069
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
16070
|
+
import {
|
|
16071
|
+
closeSync,
|
|
16072
|
+
constants,
|
|
16073
|
+
fchmodSync,
|
|
16074
|
+
fstatSync,
|
|
16075
|
+
lstatSync,
|
|
16076
|
+
mkdirSync,
|
|
16077
|
+
openSync,
|
|
16078
|
+
readdirSync,
|
|
16079
|
+
realpathSync
|
|
16080
|
+
} from "node:fs";
|
|
16081
|
+
import { join, parse as parse3, resolve as resolve2, sep } from "node:path";
|
|
16082
|
+
function windowsSystemPath(executable) {
|
|
16083
|
+
const systemRoot = process.env["SystemRoot"] ?? "C:\\Windows";
|
|
16084
|
+
return `${systemRoot}\\System32\\${executable}`;
|
|
16085
|
+
}
|
|
16086
|
+
function runWindowsCommand(executable, args) {
|
|
16087
|
+
const resolved = process.platform === "win32" && /^(whoami|icacls)\.exe$/iu.test(executable) ? windowsSystemPath(executable) : executable;
|
|
16088
|
+
const result = spawnSync2(resolved, [...args], {
|
|
16089
|
+
encoding: "utf8",
|
|
16090
|
+
shell: false,
|
|
16091
|
+
windowsHide: true
|
|
16092
|
+
});
|
|
16093
|
+
return { status: result.status, stdout: result.stdout };
|
|
16094
|
+
}
|
|
16095
|
+
function windowsUserSid(output) {
|
|
16096
|
+
const match = /S-\d+(?:-\d+)+/.exec(output);
|
|
16097
|
+
return match?.[0] ?? null;
|
|
16098
|
+
}
|
|
16099
|
+
function resolveWindowsUserSid(run) {
|
|
16100
|
+
if (run === runWindowsCommand && cachedWindowsSid !== null) return cachedWindowsSid;
|
|
16101
|
+
const identity = run("whoami.exe", ["/user", "/fo", "csv", "/nh"]);
|
|
16102
|
+
if (identity.status !== 0) return null;
|
|
16103
|
+
const sid = windowsUserSid(identity.stdout);
|
|
16104
|
+
if (run === runWindowsCommand) cachedWindowsSid = sid;
|
|
16105
|
+
return sid;
|
|
16106
|
+
}
|
|
16107
|
+
function windowsBroadGroupRemovalArgs() {
|
|
16108
|
+
return ["/remove:g", "*S-1-1-0", "*S-1-5-11", "*S-1-5-32-545"];
|
|
16109
|
+
}
|
|
16110
|
+
function applyWindowsAclWithSid(path2, kind, sid, run) {
|
|
16111
|
+
const access = kind === "directory" ? `(OI)(CI)F` : "F";
|
|
16112
|
+
const result = run("icacls.exe", [
|
|
15600
16113
|
path2,
|
|
15601
16114
|
"/inheritance:r",
|
|
15602
16115
|
"/grant:r",
|
|
@@ -16277,7 +16790,7 @@ Usage:
|
|
|
16277
16790
|
agent-inspector instance restart <name> [options]
|
|
16278
16791
|
|
|
16279
16792
|
Start/restart options:
|
|
16280
|
-
--backend <typescript|rust> Persist the backend implementation (default:
|
|
16793
|
+
--backend <typescript|rust> Persist the backend implementation (default: rust when native package is available)
|
|
16281
16794
|
--port, -p <port> Public ingress port (auto-allocated on first start)
|
|
16282
16795
|
--base-path <path> Public Base Path (default: /inspector; use / for root)
|
|
16283
16796
|
--host, -H <host> Bind host (default: 127.0.0.1)
|
|
@@ -17427,6 +17940,9 @@ function validateInstanceDataDirectory(rawPath, records, excludeName) {
|
|
|
17427
17940
|
}
|
|
17428
17941
|
return success2(assigned.value.path);
|
|
17429
17942
|
}
|
|
17943
|
+
function resolveDefaultInstanceBackend(deps) {
|
|
17944
|
+
return deps.resolveDefaultBackend?.() ?? resolvePreferredBackendImplementation({ rootVersion: package_default.version });
|
|
17945
|
+
}
|
|
17430
17946
|
async function createNewRecord(root, action, deps) {
|
|
17431
17947
|
const recordsResult = listInstanceRecords(root);
|
|
17432
17948
|
if (recordsResult.kind === "error") return fromRegistry(recordsResult);
|
|
@@ -17450,7 +17966,7 @@ async function createNewRecord(root, action, deps) {
|
|
|
17450
17966
|
upstreamPort: pairResult.value.upstreamPort,
|
|
17451
17967
|
basePath: action.overrides.basePath ?? getConfiguredBasePath(process.env),
|
|
17452
17968
|
captureMode: action.overrides.captureMode ?? DEFAULT_INSTANCE_CAPTURE_MODE,
|
|
17453
|
-
backend: action.overrides.backend ??
|
|
17969
|
+
backend: action.overrides.backend ?? resolveDefaultInstanceBackend(deps),
|
|
17454
17970
|
uiEnabled: action.overrides.uiEnabled ?? true,
|
|
17455
17971
|
dataDir: dataDirResult.value
|
|
17456
17972
|
});
|
|
@@ -17827,6 +18343,7 @@ var DEFAULT_INSTANCE_HOST, DEFAULT_INSTANCE_CAPTURE_MODE, INSTANCE_READY_TIMEOUT
|
|
|
17827
18343
|
var init_instance = __esm({
|
|
17828
18344
|
"src/cli/instance.ts"() {
|
|
17829
18345
|
"use strict";
|
|
18346
|
+
init_package();
|
|
17830
18347
|
init_basePath();
|
|
17831
18348
|
init_instanceContract();
|
|
17832
18349
|
init_managedInstance();
|
|
@@ -17836,6 +18353,7 @@ var init_instance = __esm({
|
|
|
17836
18353
|
init_instanceControl();
|
|
17837
18354
|
init_instanceRegistry();
|
|
17838
18355
|
init_networkHints();
|
|
18356
|
+
init_rustBackendPackage();
|
|
17839
18357
|
DEFAULT_INSTANCE_HOST = "127.0.0.1";
|
|
17840
18358
|
DEFAULT_INSTANCE_CAPTURE_MODE = "simple";
|
|
17841
18359
|
INSTANCE_READY_TIMEOUT_MS = 15e3;
|
|
@@ -21101,777 +21619,280 @@ function parseAliasArgs(argv) {
|
|
|
21101
21619
|
if (rawBasePath === void 0 || positional.length !== 2) {
|
|
21102
21620
|
return { kind: "error", message: `alias: ${command} requires exactly one base path` };
|
|
21103
21621
|
}
|
|
21104
|
-
const basePath = normalizeAliasPath(rawBasePath);
|
|
21105
|
-
if (basePath === null) {
|
|
21106
|
-
return {
|
|
21107
|
-
kind: "error",
|
|
21108
|
-
message: `alias: ${command} base path must be an absolute URL path without a query or hash`
|
|
21109
|
-
};
|
|
21110
|
-
}
|
|
21111
|
-
const action = { kind: command, basePath };
|
|
21112
|
-
return { kind: "ok", options: { action, host, port, json: json2 } };
|
|
21113
|
-
}
|
|
21114
|
-
case void 0:
|
|
21115
|
-
return { kind: "error", message: "alias: expected add <path>, list, or remove <path>" };
|
|
21116
|
-
default:
|
|
21117
|
-
return { kind: "error", message: `alias: unknown command ${command}` };
|
|
21118
|
-
}
|
|
21119
|
-
}
|
|
21120
|
-
function aliasHelp() {
|
|
21121
|
-
return `agent-inspector alias - mount additional base paths on a running runtime
|
|
21122
|
-
|
|
21123
|
-
Usage:
|
|
21124
|
-
agent-inspector alias add <path> [--host <host>] [--port <port>] [--json]
|
|
21125
|
-
agent-inspector alias list [--host <host>] [--port <port>] [--json]
|
|
21126
|
-
agent-inspector alias remove <path> [--host <host>] [--port <port>] [--json]
|
|
21127
|
-
|
|
21128
|
-
Options:
|
|
21129
|
-
--host <host> Running instance host (default: localhost)
|
|
21130
|
-
--port <port> Running instance port (default: 9527)
|
|
21131
|
-
--json Emit machine-readable output
|
|
21132
|
-
--help, -h Show this help
|
|
21133
|
-
|
|
21134
|
-
Aliases are runtime-scoped. This command never starts another Agent Inspector runtime.
|
|
21135
|
-
`;
|
|
21136
|
-
}
|
|
21137
|
-
function isObject4(value) {
|
|
21138
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21139
|
-
}
|
|
21140
|
-
function parseAliasSnapshot(value) {
|
|
21141
|
-
if (!isObject4(value)) return null;
|
|
21142
|
-
const canonicalBasePath = value["canonicalBasePath"];
|
|
21143
|
-
const aliases = value["aliases"];
|
|
21144
|
-
const runtimeScoped = value["runtimeScoped"];
|
|
21145
|
-
if (typeof canonicalBasePath !== "string" || !Array.isArray(aliases) || !aliases.every((alias) => typeof alias === "string") || runtimeScoped !== true) {
|
|
21146
|
-
return null;
|
|
21147
|
-
}
|
|
21148
|
-
return {
|
|
21149
|
-
canonicalBasePath: normalizeBasePath(canonicalBasePath),
|
|
21150
|
-
aliases: aliases.map((alias) => normalizeBasePath(alias)),
|
|
21151
|
-
runtimeScoped: true
|
|
21152
|
-
};
|
|
21153
|
-
}
|
|
21154
|
-
function readErrorDetail(value) {
|
|
21155
|
-
if (!isObject4(value)) return null;
|
|
21156
|
-
const error51 = value["error"];
|
|
21157
|
-
if (typeof error51 === "string" && error51.trim() !== "") return error51;
|
|
21158
|
-
const message = value["message"];
|
|
21159
|
-
return typeof message === "string" && message.trim() !== "" ? message : null;
|
|
21160
|
-
}
|
|
21161
|
-
async function readJson2(response) {
|
|
21162
|
-
try {
|
|
21163
|
-
const value = await response.json();
|
|
21164
|
-
return value;
|
|
21165
|
-
} catch {
|
|
21166
|
-
return null;
|
|
21167
|
-
}
|
|
21168
|
-
}
|
|
21169
|
-
async function requestAliases(endpoint2, action, fetchImpl) {
|
|
21170
|
-
const controller = new AbortController();
|
|
21171
|
-
const timeout = setTimeout(() => {
|
|
21172
|
-
controller.abort();
|
|
21173
|
-
}, REQUEST_TIMEOUT_MS);
|
|
21174
|
-
const method = action.kind === "list" ? "GET" : action.kind === "add" ? "POST" : "DELETE";
|
|
21175
|
-
const basePath = action.kind === "list" ? null : action.basePath;
|
|
21176
|
-
const init = {
|
|
21177
|
-
method,
|
|
21178
|
-
headers: action.kind === "list" ? { accept: "application/json" } : {
|
|
21179
|
-
accept: "application/json",
|
|
21180
|
-
"content-type": "application/json",
|
|
21181
|
-
"x-agent-inspector-csrf": "1"
|
|
21182
|
-
},
|
|
21183
|
-
signal: controller.signal
|
|
21184
|
-
};
|
|
21185
|
-
if (basePath !== null) init.body = JSON.stringify({ basePath });
|
|
21186
|
-
try {
|
|
21187
|
-
const response = await fetchImpl(endpoint2, init);
|
|
21188
|
-
const value = await readJson2(response);
|
|
21189
|
-
if (!response.ok) {
|
|
21190
|
-
return { kind: "http-error", status: response.status, detail: readErrorDetail(value) };
|
|
21191
|
-
}
|
|
21192
|
-
const snapshot = parseAliasSnapshot(value);
|
|
21193
|
-
return snapshot === null ? { kind: "invalid-response" } : { kind: "success", snapshot };
|
|
21194
|
-
} catch (error51) {
|
|
21195
|
-
const timedOut = controller.signal.aborted || error51 instanceof Error && error51.name === "AbortError";
|
|
21196
|
-
return { kind: "network-error", timedOut };
|
|
21197
|
-
} finally {
|
|
21198
|
-
clearTimeout(timeout);
|
|
21199
|
-
}
|
|
21200
|
-
}
|
|
21201
|
-
function displayBasePath2(basePath) {
|
|
21202
|
-
const normalized = normalizeBasePath(basePath);
|
|
21203
|
-
return normalized === "" ? "/" : normalized;
|
|
21204
|
-
}
|
|
21205
|
-
function fullUrl(origin, basePath) {
|
|
21206
|
-
return `${origin}${normalizeBasePath(basePath)}`;
|
|
21207
|
-
}
|
|
21208
|
-
function buildOutput(origin, action, snapshot) {
|
|
21209
|
-
return {
|
|
21210
|
-
action: action.kind,
|
|
21211
|
-
canonicalBasePath: displayBasePath2(snapshot.canonicalBasePath),
|
|
21212
|
-
canonicalUrl: fullUrl(origin, snapshot.canonicalBasePath),
|
|
21213
|
-
aliases: snapshot.aliases.map(displayBasePath2),
|
|
21214
|
-
aliasUrls: snapshot.aliases.map((alias) => fullUrl(origin, alias)),
|
|
21215
|
-
runtimeScoped: true
|
|
21216
|
-
};
|
|
21217
|
-
}
|
|
21218
|
-
function formatHumanOutput(output) {
|
|
21219
|
-
const heading = output.action === "add" ? "Base-path alias added." : output.action === "remove" ? "Base-path alias removed." : "Base-path aliases for the running runtime:";
|
|
21220
|
-
const aliasPaths = output.aliases.length === 0 ? "(none)" : output.aliases.join(", ");
|
|
21221
|
-
const aliasUrls = output.aliasUrls.length === 0 ? " (none)" : output.aliasUrls.map((url2) => ` - ${url2}`).join("\n");
|
|
21222
|
-
return `${heading}
|
|
21223
|
-
Canonical base path: ${output.canonicalBasePath}
|
|
21224
|
-
Canonical URL: ${output.canonicalUrl}
|
|
21225
|
-
Alias base paths: ${aliasPaths}
|
|
21226
|
-
Alias URLs:
|
|
21227
|
-
${aliasUrls}
|
|
21228
|
-
Scope: current runtime only; no second runtime was started and aliases are not persisted.
|
|
21229
|
-
`;
|
|
21230
|
-
}
|
|
21231
|
-
function writeError2(io, json2, code, message) {
|
|
21232
|
-
if (json2) {
|
|
21233
|
-
io.stderr(`${JSON.stringify({ error: code, message, runtimeStarted: false })}
|
|
21234
|
-
`);
|
|
21235
|
-
return;
|
|
21236
|
-
}
|
|
21237
|
-
io.stderr(`agent-inspector alias: ${message}
|
|
21238
|
-
`);
|
|
21239
|
-
}
|
|
21240
|
-
function oldRuntimeMessage(origin) {
|
|
21241
|
-
return `the runtime at ${origin} does not support base-path aliases. Upgrade Agent Inspector and restart that instance, then retry; this command did not start a runtime.`;
|
|
21242
|
-
}
|
|
21243
|
-
async function handleHttpError(options, endpoint2, origin, result, fetchImpl, io) {
|
|
21244
|
-
if (result.status === 404 && options.action.kind === "remove") {
|
|
21245
|
-
const probe = await requestAliases(endpoint2, { kind: "list" }, fetchImpl);
|
|
21246
|
-
if (probe.kind === "success") {
|
|
21247
|
-
writeError2(
|
|
21248
|
-
io,
|
|
21249
|
-
options.json,
|
|
21250
|
-
"alias_not_found",
|
|
21251
|
-
`base path ${displayBasePath2(options.action.basePath)} is not mounted. Run "agent-inspector alias list --host ${options.host} --port ${options.port}" to inspect the current runtime.`
|
|
21252
|
-
);
|
|
21253
|
-
return 1;
|
|
21254
|
-
}
|
|
21255
|
-
if (probe.kind === "network-error") {
|
|
21256
|
-
writeError2(
|
|
21257
|
-
io,
|
|
21258
|
-
options.json,
|
|
21259
|
-
probe.timedOut ? "request_timeout" : "runtime_unreachable",
|
|
21260
|
-
`${probe.timedOut ? "timed out contacting" : "cannot reach"} ${origin}. Confirm the existing runtime is running and the --host/--port values are correct; no runtime was started.`
|
|
21261
|
-
);
|
|
21262
|
-
return 1;
|
|
21263
|
-
}
|
|
21264
|
-
if (probe.kind === "http-error" && (probe.status === 404 || probe.status === 405)) {
|
|
21265
|
-
writeError2(io, options.json, "unsupported_runtime", oldRuntimeMessage(origin));
|
|
21266
|
-
return 1;
|
|
21267
|
-
}
|
|
21268
|
-
}
|
|
21269
|
-
if (result.status === 404 || result.status === 405) {
|
|
21270
|
-
writeError2(io, options.json, "unsupported_runtime", oldRuntimeMessage(origin));
|
|
21271
|
-
return 1;
|
|
21272
|
-
}
|
|
21273
|
-
if (result.status === 409) {
|
|
21274
|
-
writeError2(
|
|
21275
|
-
io,
|
|
21276
|
-
options.json,
|
|
21277
|
-
"alias_conflict",
|
|
21278
|
-
`${result.detail ?? "the base path is already mounted or conflicts with another mount"}. Run "agent-inspector alias list --host ${options.host} --port ${options.port}" to inspect the current runtime.`
|
|
21279
|
-
);
|
|
21280
|
-
return 1;
|
|
21281
|
-
}
|
|
21282
|
-
const detail = result.detail === null ? "the runtime rejected the request" : result.detail;
|
|
21283
|
-
writeError2(
|
|
21284
|
-
io,
|
|
21285
|
-
options.json,
|
|
21286
|
-
"runtime_rejected_request",
|
|
21287
|
-
`${detail} (HTTP ${result.status}). Check the running instance and retry; no runtime was started.`
|
|
21288
|
-
);
|
|
21289
|
-
return 1;
|
|
21290
|
-
}
|
|
21291
|
-
async function runAlias(argv, fetchImpl = fetch, io = processIo2) {
|
|
21292
|
-
const parsed = parseAliasArgs(argv);
|
|
21293
|
-
if (parsed.kind === "help") {
|
|
21294
|
-
io.stdout(aliasHelp());
|
|
21295
|
-
return 0;
|
|
21296
|
-
}
|
|
21297
|
-
if (parsed.kind === "error") {
|
|
21298
|
-
io.stderr(`${parsed.message}
|
|
21299
|
-
|
|
21300
|
-
${aliasHelp()}`);
|
|
21301
|
-
return 2;
|
|
21302
|
-
}
|
|
21303
|
-
const { options } = parsed;
|
|
21304
|
-
const origin = `http://${formatHostForUrl(options.host)}:${options.port}`;
|
|
21305
|
-
const endpoint2 = `${origin}${ALIAS_CONTROL_PATH}`;
|
|
21306
|
-
const result = await requestAliases(endpoint2, options.action, fetchImpl);
|
|
21307
|
-
switch (result.kind) {
|
|
21308
|
-
case "success": {
|
|
21309
|
-
const output = buildOutput(origin, options.action, result.snapshot);
|
|
21310
|
-
io.stdout(options.json ? `${JSON.stringify(output, null, 2)}
|
|
21311
|
-
` : formatHumanOutput(output));
|
|
21312
|
-
return 0;
|
|
21313
|
-
}
|
|
21314
|
-
case "network-error":
|
|
21315
|
-
writeError2(
|
|
21316
|
-
io,
|
|
21317
|
-
options.json,
|
|
21318
|
-
result.timedOut ? "request_timeout" : "runtime_unreachable",
|
|
21319
|
-
`${result.timedOut ? "timed out contacting" : "cannot reach"} ${origin}. Confirm the existing runtime is running and the --host/--port values are correct; no runtime was started.`
|
|
21320
|
-
);
|
|
21321
|
-
return 1;
|
|
21322
|
-
case "invalid-response":
|
|
21323
|
-
writeError2(
|
|
21324
|
-
io,
|
|
21325
|
-
options.json,
|
|
21326
|
-
"invalid_runtime_response",
|
|
21327
|
-
`the runtime at ${origin} returned an invalid alias response. Upgrade and restart that instance, then retry; no runtime was started.`
|
|
21328
|
-
);
|
|
21329
|
-
return 1;
|
|
21330
|
-
case "http-error":
|
|
21331
|
-
return handleHttpError(options, endpoint2, origin, result, fetchImpl, io);
|
|
21332
|
-
}
|
|
21333
|
-
}
|
|
21334
|
-
var DEFAULT_ALIAS_HOST, DEFAULT_ALIAS_PORT, ALIAS_CONTROL_PATH, REQUEST_TIMEOUT_MS, processIo2;
|
|
21335
|
-
var init_alias = __esm({
|
|
21336
|
-
"src/cli/alias.ts"() {
|
|
21337
|
-
"use strict";
|
|
21338
|
-
init_basePath();
|
|
21339
|
-
DEFAULT_ALIAS_HOST = "localhost";
|
|
21340
|
-
DEFAULT_ALIAS_PORT = 9527;
|
|
21341
|
-
ALIAS_CONTROL_PATH = "/.agent-inspector/base-path-aliases";
|
|
21342
|
-
REQUEST_TIMEOUT_MS = 5e3;
|
|
21343
|
-
processIo2 = {
|
|
21344
|
-
stdout: (text) => {
|
|
21345
|
-
process.stdout.write(text);
|
|
21346
|
-
},
|
|
21347
|
-
stderr: (text) => {
|
|
21348
|
-
process.stderr.write(text);
|
|
21349
|
-
}
|
|
21350
|
-
};
|
|
21351
|
-
}
|
|
21352
|
-
});
|
|
21353
|
-
|
|
21354
|
-
// src/cli.ts
|
|
21355
|
-
import { Buffer as Buffer5 } from "node:buffer";
|
|
21356
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
21357
|
-
import { createConnection as createConnection2 } from "node:net";
|
|
21358
|
-
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
21359
|
-
import { dirname as dirname3, join as join9, resolve as resolvePath2 } from "node:path";
|
|
21360
|
-
import { existsSync as existsSync8 } from "node:fs";
|
|
21361
|
-
|
|
21362
|
-
// package.json
|
|
21363
|
-
var package_default = {
|
|
21364
|
-
name: "@tonyclaw/agent-inspector",
|
|
21365
|
-
version: "3.0.47",
|
|
21366
|
-
type: "module",
|
|
21367
|
-
description: "Agent observability and knowledge capture layer for AI coding tools.",
|
|
21368
|
-
license: "MIT",
|
|
21369
|
-
engines: {
|
|
21370
|
-
node: ">=22.0.0"
|
|
21371
|
-
},
|
|
21372
|
-
author: "TonyClaw",
|
|
21373
|
-
repository: {
|
|
21374
|
-
type: "git",
|
|
21375
|
-
url: "git+https://gitcode.com/TonyClaw/agent-inspector.git"
|
|
21376
|
-
},
|
|
21377
|
-
homepage: "https://gitcode.com/TonyClaw/agent-inspector#readme",
|
|
21378
|
-
workspaces: [
|
|
21379
|
-
"packages/*"
|
|
21380
|
-
],
|
|
21381
|
-
bugs: {
|
|
21382
|
-
url: "https://gitcode.com/TonyClaw/agent-inspector/issues"
|
|
21383
|
-
},
|
|
21384
|
-
publishConfig: {
|
|
21385
|
-
access: "public",
|
|
21386
|
-
registry: "https://registry.npmjs.org/"
|
|
21387
|
-
},
|
|
21388
|
-
keywords: [
|
|
21389
|
-
"claude",
|
|
21390
|
-
"anthropic",
|
|
21391
|
-
"openai",
|
|
21392
|
-
"proxy",
|
|
21393
|
-
"api-inspector",
|
|
21394
|
-
"agent-observability",
|
|
21395
|
-
"agent-memory",
|
|
21396
|
-
"debugging",
|
|
21397
|
-
"llm",
|
|
21398
|
-
"ai-coding-tools"
|
|
21399
|
-
],
|
|
21400
|
-
bin: {
|
|
21401
|
-
"agent-inspector": "bin/agent-inspector.js"
|
|
21402
|
-
},
|
|
21403
|
-
files: [
|
|
21404
|
-
"bin",
|
|
21405
|
-
"src",
|
|
21406
|
-
"!src/**/*.test.ts",
|
|
21407
|
-
"!src/**/*.stories.tsx",
|
|
21408
|
-
"!src/**/__fixtures__",
|
|
21409
|
-
"!src/ui/routeTree.gen.ts",
|
|
21410
|
-
"!src/backend/routeTree.gen.ts",
|
|
21411
|
-
"scripts/setup-windows-runtime.mjs",
|
|
21412
|
-
"scripts/setup-agent-skills.mjs",
|
|
21413
|
-
"scripts/generate-theme-scales.mjs",
|
|
21414
|
-
"docs/instance-control.openapi.yaml",
|
|
21415
|
-
"styles",
|
|
21416
|
-
".output",
|
|
21417
|
-
"!.output/*.exe"
|
|
21418
|
-
],
|
|
21419
|
-
scripts: {
|
|
21420
|
-
dev: "node scripts/dev-decoupled.mjs",
|
|
21421
|
-
"dev:ui": "vite dev --config vite.ui.config.ts",
|
|
21422
|
-
"dev:backend": "node scripts/dev-backend.mjs",
|
|
21423
|
-
"test:smoke": "bun scripts/run-test-suite.mjs smoke",
|
|
21424
|
-
"test:fast": "bun scripts/run-test-suite.mjs smoke",
|
|
21425
|
-
"test:unit": "bun scripts/run-test-suite.mjs unit",
|
|
21426
|
-
"test:integration": "bun scripts/run-test-suite.mjs integration",
|
|
21427
|
-
"test:changed": "bun scripts/run-test-suite.mjs changed",
|
|
21428
|
-
"test:all": "bun scripts/run-test-suite.mjs all",
|
|
21429
|
-
"test:compatibility-tooling": "node --test scripts/compatibility/*.test.mjs",
|
|
21430
|
-
start: "node .output/cli.js",
|
|
21431
|
-
"start:backend": "node .output/cli.js --backend-only --no-open",
|
|
21432
|
-
"preview:ui": "vite preview --config vite.ui.config.ts",
|
|
21433
|
-
"clean:output": "node scripts/clean-output.mjs",
|
|
21434
|
-
build: "bun clean:output && bun build:backend && bun build:ui && bun smoke:ui-preview && bun build:workers && bun build:cli && bun build:mcp && bun check:bundle && bun check:boundaries",
|
|
21435
|
-
"build:backend": "vite build --config vite.backend.config.ts",
|
|
21436
|
-
"build:ui": "vite build --config vite.ui.config.ts",
|
|
21437
|
-
"build:workers": "npx esbuild src/proxy/logFinalizer.worker.ts src/proxy/sessionWorkerEntry.ts --bundle --platform=node --target=node22 --format=esm --outdir=.output/workers --external:better-sqlite3",
|
|
21438
|
-
"smoke:workers": "node scripts/smoke-production-workers.mjs",
|
|
21439
|
-
"smoke:packed-workers": "node scripts/smoke-packed-workers.mjs",
|
|
21440
|
-
"smoke:instances": "node scripts/smoke-windows-instances.mjs",
|
|
21441
|
-
"smoke:coding-agent-instances": "node scripts/smoke-coding-agent-instances.mjs",
|
|
21442
|
-
"smoke:ui-preview": "node scripts/smoke-decoupled-ui-preview.mjs",
|
|
21443
|
-
"check:bundle": "node scripts/check-client-bundle.mjs",
|
|
21444
|
-
"check:boundaries": "node scripts/check-runtime-boundaries.mjs",
|
|
21445
|
-
"compatibility:bdd": "node scripts/lint-bdd-catalog.mjs",
|
|
21446
|
-
"compatibility:compare": "node scripts/compatibility/cli.mjs compare",
|
|
21447
|
-
"compatibility:drift": "node scripts/check-backend-compatibility.mjs",
|
|
21448
|
-
"compatibility:fixtures": "bun scripts/validate-compatibility-fixtures.ts",
|
|
21449
|
-
"compatibility:freeze": "node scripts/freeze-backend-baseline.mjs",
|
|
21450
|
-
"compatibility:run": "node scripts/compatibility/cli.mjs run",
|
|
21451
|
-
"compatibility:performance": "node scripts/compatibility/performance-cli.mjs",
|
|
21452
|
-
"compatibility:performance:verify": "node scripts/compatibility/performance-cli.mjs verify",
|
|
21453
|
-
"build:cli": "npx esbuild src/cli.ts --bundle --platform=node --target=node22 --format=esm --outfile=.output/cli.js",
|
|
21454
|
-
"build:mcp": "npx esbuild packages/agent-inspector-mcp/src/cli.ts --bundle --platform=node --target=node22 --format=esm --outfile=packages/agent-inspector-mcp/dist/cli.js",
|
|
21455
|
-
"rust:build-package": "node scripts/rust/build-platform.mjs",
|
|
21456
|
-
"rust:stage-package": "node scripts/rust/stage-platform.mjs",
|
|
21457
|
-
"rust:verify-package": "node scripts/rust/verify-platform.mjs",
|
|
21458
|
-
"rust:pack-package": "node scripts/rust/pack-platform.mjs",
|
|
21459
|
-
"rust:native-artifact": "node scripts/rust/create-native-artifact.mjs",
|
|
21460
|
-
"rust:native:aggregate": "node scripts/rust/aggregate-native-artifacts.mjs",
|
|
21461
|
-
"test:rust-packaging": "bun test scripts/rust/npmPackaging.test.ts scripts/rust/nativeReleaseContract.test.ts scripts/rust/nativeStartupSmoke.test.ts scripts/releaseCore.test.ts",
|
|
21462
|
-
"rust:packages:check": "node scripts/rust/sync-package-versions.mjs",
|
|
21463
|
-
"rust:packages:sync": "node scripts/rust/sync-package-versions.mjs --write",
|
|
21464
|
-
"themes:generate": "node scripts/generate-theme-scales.mjs",
|
|
21465
|
-
postinstall: "node scripts/setup-windows-runtime.mjs && node scripts/setup-agent-skills.mjs",
|
|
21466
|
-
prepublishOnly: "node scripts/rust/require-release-orchestrator.mjs",
|
|
21467
|
-
typecheck: "tsc --noEmit --incremental --tsBuildInfoFile .cache/tsconfig.tsbuildinfo",
|
|
21468
|
-
lint: "eslint . --cache --cache-location .cache/eslintcache",
|
|
21469
|
-
format: "biome format --write .",
|
|
21470
|
-
"format:check": "biome format .",
|
|
21471
|
-
"verify:fast": "bun scripts/run-static-checks.mjs --format && bun test:changed",
|
|
21472
|
-
"extension:zip": "node scripts/pack-chrome-extension.mjs",
|
|
21473
|
-
"extension:release": "node scripts/release-chrome-extension.mjs",
|
|
21474
|
-
release: "node scripts/release.mjs",
|
|
21475
|
-
knip: "knip",
|
|
21476
|
-
check: "bun scripts/run-static-checks.mjs --format && bun check:boundaries && bun compatibility:bdd && bun rust:packages:check",
|
|
21477
|
-
prepare: "husky",
|
|
21478
|
-
ladle: "ladle serve",
|
|
21479
|
-
"ladle:build": "ladle build"
|
|
21480
|
-
},
|
|
21481
|
-
dependencies: {
|
|
21482
|
-
"@mariozechner/pi-agent-core": "^0.73.1",
|
|
21483
|
-
"@mariozechner/pi-ai": "^0.73.1",
|
|
21484
|
-
"@modelcontextprotocol/server": "^2.0.0-beta.4",
|
|
21485
|
-
"@tailwindcss/typography": "^0.5.20",
|
|
21486
|
-
"@tanstack/react-router": "^1.170.18",
|
|
21487
|
-
"@tanstack/react-start": "^1.168.28",
|
|
21488
|
-
"@tanstack/react-virtual": "^3.14.6",
|
|
21489
|
-
"class-variance-authority": "^0.7.1",
|
|
21490
|
-
clsx: "^2.1.1",
|
|
21491
|
-
conf: "^15.1.0",
|
|
21492
|
-
diff: "^9.0.0",
|
|
21493
|
-
jszip: "^3.10.1",
|
|
21494
|
-
"lucide-react": "^0.563.0",
|
|
21495
|
-
"radix-ui": "^1.6.2",
|
|
21496
|
-
react: "^19.2.7",
|
|
21497
|
-
"react-dom": "^19.2.7",
|
|
21498
|
-
"react-markdown": "^10.1.0",
|
|
21499
|
-
swr: "^2.4.2",
|
|
21500
|
-
"tailwind-merge": "^3.6.0",
|
|
21501
|
-
three: "0.185.1",
|
|
21502
|
-
"tw-animate-css": "^1.4.0",
|
|
21503
|
-
zod: "^4.4.3"
|
|
21504
|
-
},
|
|
21505
|
-
optionalDependencies: {
|
|
21506
|
-
"@tonyclaw/agent-inspector-backend-darwin-arm64": "3.0.47",
|
|
21507
|
-
"@tonyclaw/agent-inspector-backend-linux-x64-gnu": "3.0.47",
|
|
21508
|
-
"@tonyclaw/agent-inspector-backend-win32-x64-msvc": "3.0.47",
|
|
21509
|
-
"better-sqlite3": "^12.11.1",
|
|
21510
|
-
rcedit: "4.0.1"
|
|
21511
|
-
},
|
|
21512
|
-
devDependencies: {
|
|
21513
|
-
"@biomejs/biome": "^2.5.3",
|
|
21514
|
-
"@eslint/js": "^10.0.1",
|
|
21515
|
-
"@ladle/react": "^5.1.1",
|
|
21516
|
-
"@radix-ui/colors": "^3.0.0",
|
|
21517
|
-
"@tailwindcss/vite": "^4.3.2",
|
|
21518
|
-
"@tanstack/router-plugin": "^1.168.20",
|
|
21519
|
-
"@types/bun": "^1.3.14",
|
|
21520
|
-
"@types/react": "^19.2.17",
|
|
21521
|
-
"@types/react-dom": "^19.2.3",
|
|
21522
|
-
"@types/three": "0.185.1",
|
|
21523
|
-
"@typescript-eslint/eslint-plugin": "^8.64.0",
|
|
21524
|
-
"@typescript-eslint/parser": "^8.64.0",
|
|
21525
|
-
"@vitejs/plugin-react": "^5.2.0",
|
|
21526
|
-
ajv: "8.20.0",
|
|
21527
|
-
"ajv-formats": "3.0.1",
|
|
21528
|
-
"colorjs.io": "^0.7.0",
|
|
21529
|
-
esbuild: "^0.28.1",
|
|
21530
|
-
eslint: "^9.39.5",
|
|
21531
|
-
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
21532
|
-
"eslint-plugin-functional": "^9.0.5",
|
|
21533
|
-
"eslint-plugin-unicorn": "^63.0.0",
|
|
21534
|
-
husky: "^9.1.7",
|
|
21535
|
-
knip: "^5.88.1",
|
|
21536
|
-
nitro: "^3.0.260610-beta",
|
|
21537
|
-
playwright: "^1.61.1",
|
|
21538
|
-
tailwindcss: "^4.3.2",
|
|
21539
|
-
typescript: "^5.9.3",
|
|
21540
|
-
vite: "^7.3.6",
|
|
21541
|
-
"vite-tsconfig-paths": "^6.1.1"
|
|
21542
|
-
},
|
|
21543
|
-
overrides: {
|
|
21544
|
-
undici: ">=7.24.0 <8.0.0",
|
|
21545
|
-
rollup: ">=4.59.0 <5.0.0",
|
|
21546
|
-
postcss: ">=8.5.10 <9.0.0",
|
|
21547
|
-
"js-yaml": ">=4.1.2 <5.0.0",
|
|
21548
|
-
flatted: ">=3.4.0 <4.0.0",
|
|
21549
|
-
"smol-toml": ">=1.6.1 <2.0.0",
|
|
21550
|
-
koa: ">=2.16.4 <3.0.0",
|
|
21551
|
-
"@babel/core": ">=7.29.1 <8.0.0",
|
|
21552
|
-
"@typescript-eslint/typescript-estree": "^8.63.0",
|
|
21553
|
-
vite: "^7.3.6"
|
|
21622
|
+
const basePath = normalizeAliasPath(rawBasePath);
|
|
21623
|
+
if (basePath === null) {
|
|
21624
|
+
return {
|
|
21625
|
+
kind: "error",
|
|
21626
|
+
message: `alias: ${command} base path must be an absolute URL path without a query or hash`
|
|
21627
|
+
};
|
|
21628
|
+
}
|
|
21629
|
+
const action = { kind: command, basePath };
|
|
21630
|
+
return { kind: "ok", options: { action, host, port, json: json2 } };
|
|
21631
|
+
}
|
|
21632
|
+
case void 0:
|
|
21633
|
+
return { kind: "error", message: "alias: expected add <path>, list, or remove <path>" };
|
|
21634
|
+
default:
|
|
21635
|
+
return { kind: "error", message: `alias: unknown command ${command}` };
|
|
21554
21636
|
}
|
|
21555
|
-
}
|
|
21637
|
+
}
|
|
21638
|
+
function aliasHelp() {
|
|
21639
|
+
return `agent-inspector alias - mount additional base paths on a running runtime
|
|
21556
21640
|
|
|
21557
|
-
|
|
21558
|
-
|
|
21559
|
-
|
|
21560
|
-
|
|
21561
|
-
init_networkHints();
|
|
21641
|
+
Usage:
|
|
21642
|
+
agent-inspector alias add <path> [--host <host>] [--port <port>] [--json]
|
|
21643
|
+
agent-inspector alias list [--host <host>] [--port <port>] [--json]
|
|
21644
|
+
agent-inspector alias remove <path> [--host <host>] [--port <port>] [--json]
|
|
21562
21645
|
|
|
21563
|
-
|
|
21564
|
-
|
|
21565
|
-
|
|
21566
|
-
|
|
21567
|
-
|
|
21568
|
-
return lowerLine.includes("listening on") && lowerLine.includes(`:${context.upstreamPort}`);
|
|
21569
|
-
}
|
|
21646
|
+
Options:
|
|
21647
|
+
--host <host> Running instance host (default: localhost)
|
|
21648
|
+
--port <port> Running instance port (default: 9527)
|
|
21649
|
+
--json Emit machine-readable output
|
|
21650
|
+
--help, -h Show this help
|
|
21570
21651
|
|
|
21571
|
-
|
|
21572
|
-
|
|
21573
|
-
init_zod();
|
|
21574
|
-
import { createHash } from "node:crypto";
|
|
21575
|
-
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
21576
|
-
import { createRequire } from "node:module";
|
|
21577
|
-
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
21578
|
-
import { fileURLToPath } from "node:url";
|
|
21579
|
-
var RUST_BACKEND_IDENTITY_FLAG = "--agent-inspector-package-identity";
|
|
21580
|
-
var RUST_BACKEND_CLI_PROTOCOL = "agent-inspector-cli-backend-v1";
|
|
21581
|
-
var RUST_BACKEND_IDENTITY_TIMEOUT_MS = 2e3;
|
|
21582
|
-
var RustBackendIdentitySchema = external_exports.object({
|
|
21583
|
-
schemaVersion: external_exports.literal(1),
|
|
21584
|
-
name: external_exports.literal("agent-inspector-backend"),
|
|
21585
|
-
packageVersion: external_exports.string().min(1),
|
|
21586
|
-
target: external_exports.string().min(1),
|
|
21587
|
-
binary: external_exports.string().min(1),
|
|
21588
|
-
cliProtocol: external_exports.literal(RUST_BACKEND_CLI_PROTOCOL),
|
|
21589
|
-
productionReady: external_exports.literal(true),
|
|
21590
|
-
capabilities: external_exports.object({
|
|
21591
|
-
nodeProtectedIngress: external_exports.literal(true),
|
|
21592
|
-
basePath: external_exports.literal(true),
|
|
21593
|
-
namedInstances: external_exports.literal(true),
|
|
21594
|
-
gracefulShutdown: external_exports.literal(true)
|
|
21595
|
-
}).strict()
|
|
21596
|
-
}).strict();
|
|
21597
|
-
var RustBackendPackageJsonSchema = external_exports.object({
|
|
21598
|
-
name: external_exports.string().min(1),
|
|
21599
|
-
version: external_exports.string().min(1),
|
|
21600
|
-
os: external_exports.array(external_exports.string()).min(1),
|
|
21601
|
-
cpu: external_exports.array(external_exports.string()).min(1),
|
|
21602
|
-
libc: external_exports.array(external_exports.string()).optional(),
|
|
21603
|
-
agentInspectorRustBackend: external_exports.object({
|
|
21604
|
-
schemaVersion: external_exports.literal(1),
|
|
21605
|
-
target: external_exports.string().min(1),
|
|
21606
|
-
binary: external_exports.string().min(1),
|
|
21607
|
-
manifest: external_exports.string().min(1),
|
|
21608
|
-
identityFlag: external_exports.literal(RUST_BACKEND_IDENTITY_FLAG),
|
|
21609
|
-
cliProtocol: external_exports.literal(RUST_BACKEND_CLI_PROTOCOL)
|
|
21610
|
-
}).strict()
|
|
21611
|
-
}).passthrough();
|
|
21612
|
-
var RustBackendBinaryManifestSchema = external_exports.object({
|
|
21613
|
-
schemaVersion: external_exports.literal(1),
|
|
21614
|
-
packageName: external_exports.string().min(1),
|
|
21615
|
-
packageVersion: external_exports.string().min(1),
|
|
21616
|
-
target: external_exports.string().min(1),
|
|
21617
|
-
binary: external_exports.string().min(1),
|
|
21618
|
-
sha256: external_exports.string().regex(/^[a-f0-9]{64}$/u),
|
|
21619
|
-
identity: RustBackendIdentitySchema
|
|
21620
|
-
}).strict();
|
|
21621
|
-
function packageFailure(code, message) {
|
|
21622
|
-
return { kind: "error", error: { code, message } };
|
|
21652
|
+
Aliases are runtime-scoped. This command never starts another Agent Inspector runtime.
|
|
21653
|
+
`;
|
|
21623
21654
|
}
|
|
21624
|
-
function
|
|
21625
|
-
return
|
|
21655
|
+
function isObject4(value) {
|
|
21656
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21626
21657
|
}
|
|
21627
|
-
function
|
|
21628
|
-
if (
|
|
21629
|
-
const
|
|
21630
|
-
const
|
|
21631
|
-
const
|
|
21632
|
-
if (typeof
|
|
21633
|
-
return
|
|
21658
|
+
function parseAliasSnapshot(value) {
|
|
21659
|
+
if (!isObject4(value)) return null;
|
|
21660
|
+
const canonicalBasePath = value["canonicalBasePath"];
|
|
21661
|
+
const aliases = value["aliases"];
|
|
21662
|
+
const runtimeScoped = value["runtimeScoped"];
|
|
21663
|
+
if (typeof canonicalBasePath !== "string" || !Array.isArray(aliases) || !aliases.every((alias) => typeof alias === "string") || runtimeScoped !== true) {
|
|
21664
|
+
return null;
|
|
21634
21665
|
}
|
|
21635
|
-
|
|
21636
|
-
|
|
21666
|
+
return {
|
|
21667
|
+
canonicalBasePath: normalizeBasePath(canonicalBasePath),
|
|
21668
|
+
aliases: aliases.map((alias) => normalizeBasePath(alias)),
|
|
21669
|
+
runtimeScoped: true
|
|
21670
|
+
};
|
|
21637
21671
|
}
|
|
21638
|
-
function
|
|
21639
|
-
if (
|
|
21640
|
-
|
|
21672
|
+
function readErrorDetail(value) {
|
|
21673
|
+
if (!isObject4(value)) return null;
|
|
21674
|
+
const error51 = value["error"];
|
|
21675
|
+
if (typeof error51 === "string" && error51.trim() !== "") return error51;
|
|
21676
|
+
const message = value["message"];
|
|
21677
|
+
return typeof message === "string" && message.trim() !== "" ? message : null;
|
|
21641
21678
|
}
|
|
21642
|
-
function
|
|
21643
|
-
|
|
21644
|
-
|
|
21645
|
-
|
|
21646
|
-
|
|
21647
|
-
|
|
21648
|
-
packageName: "@tonyclaw/agent-inspector-backend-win32-x64-msvc",
|
|
21649
|
-
target: "x86_64-pc-windows-msvc",
|
|
21650
|
-
binary: "bin/agent-inspector-backend.exe",
|
|
21651
|
-
os: "win32",
|
|
21652
|
-
cpu: "x64",
|
|
21653
|
-
libc: null
|
|
21654
|
-
}
|
|
21655
|
-
} : targetFailure(`Rust backend packages do not support Windows ${arch}.`);
|
|
21656
|
-
case "linux":
|
|
21657
|
-
if (arch !== "x64")
|
|
21658
|
-
return targetFailure(`Rust backend packages do not support Linux ${arch}.`);
|
|
21659
|
-
if (libc !== "glibc") {
|
|
21660
|
-
return targetFailure(
|
|
21661
|
-
`The Linux Rust backend package requires glibc; detected ${libc}. No binary was started.`
|
|
21662
|
-
);
|
|
21663
|
-
}
|
|
21664
|
-
return {
|
|
21665
|
-
kind: "success",
|
|
21666
|
-
value: {
|
|
21667
|
-
packageName: "@tonyclaw/agent-inspector-backend-linux-x64-gnu",
|
|
21668
|
-
target: "x86_64-unknown-linux-gnu",
|
|
21669
|
-
binary: "bin/agent-inspector-backend",
|
|
21670
|
-
os: "linux",
|
|
21671
|
-
cpu: "x64",
|
|
21672
|
-
libc: "glibc"
|
|
21673
|
-
}
|
|
21674
|
-
};
|
|
21675
|
-
case "darwin":
|
|
21676
|
-
return arch === "arm64" ? {
|
|
21677
|
-
kind: "success",
|
|
21678
|
-
value: {
|
|
21679
|
-
packageName: "@tonyclaw/agent-inspector-backend-darwin-arm64",
|
|
21680
|
-
target: "aarch64-apple-darwin",
|
|
21681
|
-
binary: "bin/agent-inspector-backend",
|
|
21682
|
-
os: "darwin",
|
|
21683
|
-
cpu: "arm64",
|
|
21684
|
-
libc: null
|
|
21685
|
-
}
|
|
21686
|
-
} : targetFailure(`Rust backend packages do not support macOS ${arch}.`);
|
|
21687
|
-
default:
|
|
21688
|
-
return targetFailure(`Rust backend packages do not support ${platform} ${arch}.`);
|
|
21679
|
+
async function readJson2(response) {
|
|
21680
|
+
try {
|
|
21681
|
+
const value = await response.json();
|
|
21682
|
+
return value;
|
|
21683
|
+
} catch {
|
|
21684
|
+
return null;
|
|
21689
21685
|
}
|
|
21690
21686
|
}
|
|
21691
|
-
function
|
|
21687
|
+
async function requestAliases(endpoint2, action, fetchImpl) {
|
|
21688
|
+
const controller = new AbortController();
|
|
21689
|
+
const timeout = setTimeout(() => {
|
|
21690
|
+
controller.abort();
|
|
21691
|
+
}, REQUEST_TIMEOUT_MS);
|
|
21692
|
+
const method = action.kind === "list" ? "GET" : action.kind === "add" ? "POST" : "DELETE";
|
|
21693
|
+
const basePath = action.kind === "list" ? null : action.basePath;
|
|
21694
|
+
const init = {
|
|
21695
|
+
method,
|
|
21696
|
+
headers: action.kind === "list" ? { accept: "application/json" } : {
|
|
21697
|
+
accept: "application/json",
|
|
21698
|
+
"content-type": "application/json",
|
|
21699
|
+
"x-agent-inspector-csrf": "1"
|
|
21700
|
+
},
|
|
21701
|
+
signal: controller.signal
|
|
21702
|
+
};
|
|
21703
|
+
if (basePath !== null) init.body = JSON.stringify({ basePath });
|
|
21692
21704
|
try {
|
|
21693
|
-
const
|
|
21694
|
-
|
|
21695
|
-
|
|
21696
|
-
|
|
21705
|
+
const response = await fetchImpl(endpoint2, init);
|
|
21706
|
+
const value = await readJson2(response);
|
|
21707
|
+
if (!response.ok) {
|
|
21708
|
+
return { kind: "http-error", status: response.status, detail: readErrorDetail(value) };
|
|
21709
|
+
}
|
|
21710
|
+
const snapshot = parseAliasSnapshot(value);
|
|
21711
|
+
return snapshot === null ? { kind: "invalid-response" } : { kind: "success", snapshot };
|
|
21712
|
+
} catch (error51) {
|
|
21713
|
+
const timedOut = controller.signal.aborted || error51 instanceof Error && error51.name === "AbortError";
|
|
21714
|
+
return { kind: "network-error", timedOut };
|
|
21715
|
+
} finally {
|
|
21716
|
+
clearTimeout(timeout);
|
|
21697
21717
|
}
|
|
21698
21718
|
}
|
|
21699
|
-
function
|
|
21700
|
-
const
|
|
21701
|
-
return
|
|
21719
|
+
function displayBasePath2(basePath) {
|
|
21720
|
+
const normalized = normalizeBasePath(basePath);
|
|
21721
|
+
return normalized === "" ? "/" : normalized;
|
|
21702
21722
|
}
|
|
21703
|
-
function
|
|
21704
|
-
return
|
|
21723
|
+
function fullUrl(origin, basePath) {
|
|
21724
|
+
return `${origin}${normalizeBasePath(basePath)}`;
|
|
21705
21725
|
}
|
|
21706
|
-
function
|
|
21707
|
-
|
|
21708
|
-
|
|
21709
|
-
|
|
21710
|
-
|
|
21711
|
-
|
|
21712
|
-
|
|
21713
|
-
|
|
21714
|
-
|
|
21715
|
-
|
|
21716
|
-
|
|
21717
|
-
|
|
21718
|
-
|
|
21719
|
-
|
|
21720
|
-
|
|
21721
|
-
|
|
21722
|
-
|
|
21723
|
-
|
|
21724
|
-
|
|
21725
|
-
|
|
21726
|
-
|
|
21726
|
+
function buildOutput(origin, action, snapshot) {
|
|
21727
|
+
return {
|
|
21728
|
+
action: action.kind,
|
|
21729
|
+
canonicalBasePath: displayBasePath2(snapshot.canonicalBasePath),
|
|
21730
|
+
canonicalUrl: fullUrl(origin, snapshot.canonicalBasePath),
|
|
21731
|
+
aliases: snapshot.aliases.map(displayBasePath2),
|
|
21732
|
+
aliasUrls: snapshot.aliases.map((alias) => fullUrl(origin, alias)),
|
|
21733
|
+
runtimeScoped: true
|
|
21734
|
+
};
|
|
21735
|
+
}
|
|
21736
|
+
function formatHumanOutput(output) {
|
|
21737
|
+
const heading = output.action === "add" ? "Base-path alias added." : output.action === "remove" ? "Base-path alias removed." : "Base-path aliases for the running runtime:";
|
|
21738
|
+
const aliasPaths = output.aliases.length === 0 ? "(none)" : output.aliases.join(", ");
|
|
21739
|
+
const aliasUrls = output.aliasUrls.length === 0 ? " (none)" : output.aliasUrls.map((url2) => ` - ${url2}`).join("\n");
|
|
21740
|
+
return `${heading}
|
|
21741
|
+
Canonical base path: ${output.canonicalBasePath}
|
|
21742
|
+
Canonical URL: ${output.canonicalUrl}
|
|
21743
|
+
Alias base paths: ${aliasPaths}
|
|
21744
|
+
Alias URLs:
|
|
21745
|
+
${aliasUrls}
|
|
21746
|
+
Scope: current runtime only; no second runtime was started and aliases are not persisted.
|
|
21747
|
+
`;
|
|
21748
|
+
}
|
|
21749
|
+
function writeError2(io, json2, code, message) {
|
|
21750
|
+
if (json2) {
|
|
21751
|
+
io.stderr(`${JSON.stringify({ error: code, message, runtimeStarted: false })}
|
|
21752
|
+
`);
|
|
21753
|
+
return;
|
|
21727
21754
|
}
|
|
21728
|
-
|
|
21729
|
-
|
|
21755
|
+
io.stderr(`agent-inspector alias: ${message}
|
|
21756
|
+
`);
|
|
21730
21757
|
}
|
|
21731
|
-
|
|
21732
|
-
|
|
21733
|
-
|
|
21734
|
-
|
|
21735
|
-
|
|
21736
|
-
const
|
|
21737
|
-
|
|
21738
|
-
|
|
21739
|
-
|
|
21740
|
-
|
|
21741
|
-
|
|
21742
|
-
"
|
|
21743
|
-
directoryName,
|
|
21744
|
-
"package.json"
|
|
21758
|
+
function oldRuntimeMessage(origin) {
|
|
21759
|
+
return `the runtime at ${origin} does not support base-path aliases. Upgrade Agent Inspector and restart that instance, then retry; this command did not start a runtime.`;
|
|
21760
|
+
}
|
|
21761
|
+
async function handleHttpError(options, endpoint2, origin, result, fetchImpl, io) {
|
|
21762
|
+
if (result.status === 404 && options.action.kind === "remove") {
|
|
21763
|
+
const probe = await requestAliases(endpoint2, { kind: "list" }, fetchImpl);
|
|
21764
|
+
if (probe.kind === "success") {
|
|
21765
|
+
writeError2(
|
|
21766
|
+
io,
|
|
21767
|
+
options.json,
|
|
21768
|
+
"alias_not_found",
|
|
21769
|
+
`base path ${displayBasePath2(options.action.basePath)} is not mounted. Run "agent-inspector alias list --host ${options.host} --port ${options.port}" to inspect the current runtime.`
|
|
21745
21770
|
);
|
|
21746
|
-
|
|
21771
|
+
return 1;
|
|
21772
|
+
}
|
|
21773
|
+
if (probe.kind === "network-error") {
|
|
21774
|
+
writeError2(
|
|
21775
|
+
io,
|
|
21776
|
+
options.json,
|
|
21777
|
+
probe.timedOut ? "request_timeout" : "runtime_unreachable",
|
|
21778
|
+
`${probe.timedOut ? "timed out contacting" : "cannot reach"} ${origin}. Confirm the existing runtime is running and the --host/--port values are correct; no runtime was started.`
|
|
21779
|
+
);
|
|
21780
|
+
return 1;
|
|
21781
|
+
}
|
|
21782
|
+
if (probe.kind === "http-error" && (probe.status === 404 || probe.status === 405)) {
|
|
21783
|
+
writeError2(io, options.json, "unsupported_runtime", oldRuntimeMessage(origin));
|
|
21784
|
+
return 1;
|
|
21747
21785
|
}
|
|
21748
|
-
return packageRequire.resolve(specifier);
|
|
21749
|
-
}
|
|
21750
|
-
}
|
|
21751
|
-
function resolveRustBackendPackage(options) {
|
|
21752
|
-
const target = resolveRustBackendTarget(options.platform, options.arch, options.libc);
|
|
21753
|
-
if (target.kind === "error") return { kind: "error", error: target.error };
|
|
21754
|
-
const packageJsonSpecifier = `${target.value.packageName}/package.json`;
|
|
21755
|
-
let packageJsonPath;
|
|
21756
|
-
try {
|
|
21757
|
-
packageJsonPath = (options.resolvePackageJson ?? defaultResolvePackageJson)(
|
|
21758
|
-
packageJsonSpecifier
|
|
21759
|
-
);
|
|
21760
|
-
} catch {
|
|
21761
|
-
return packageFailure(
|
|
21762
|
-
"package_missing",
|
|
21763
|
-
`Rust backend ${target.value.target} was requested, but optional package ${target.value.packageName}@${options.rootVersion} is not installed. Reinstall without omitting optional dependencies; no TypeScript fallback was used.`
|
|
21764
|
-
);
|
|
21765
|
-
}
|
|
21766
|
-
const rawPackage = readJson(packageJsonPath);
|
|
21767
|
-
if (rawPackage.kind === "error") {
|
|
21768
|
-
return packageFailure("package_invalid", `Cannot read ${packageJsonSpecifier}.`);
|
|
21769
|
-
}
|
|
21770
|
-
const packageJson = RustBackendPackageJsonSchema.safeParse(rawPackage.value);
|
|
21771
|
-
if (!packageJson.success) {
|
|
21772
|
-
return packageFailure(
|
|
21773
|
-
"package_invalid",
|
|
21774
|
-
`Package ${target.value.packageName} does not contain the Rust backend package contract.`
|
|
21775
|
-
);
|
|
21776
|
-
}
|
|
21777
|
-
if (packageJson.data.name !== target.value.packageName || packageJson.data.version !== options.rootVersion) {
|
|
21778
|
-
return packageFailure(
|
|
21779
|
-
"version_mismatch",
|
|
21780
|
-
`Rust backend package must exactly match @tonyclaw/agent-inspector@${options.rootVersion}; found ${packageJson.data.name}@${packageJson.data.version}.`
|
|
21781
|
-
);
|
|
21782
|
-
}
|
|
21783
|
-
const metadata = packageJson.data.agentInspectorRustBackend;
|
|
21784
|
-
const expectedLibc = target.value.libc === null ? void 0 : [target.value.libc];
|
|
21785
|
-
if (metadata.target !== target.value.target || metadata.binary !== target.value.binary || metadata.manifest !== "binary-manifest.json" || packageJson.data.os.length !== 1 || packageJson.data.os[0] !== target.value.os || packageJson.data.cpu.length !== 1 || packageJson.data.cpu[0] !== target.value.cpu || JSON.stringify(packageJson.data.libc) !== JSON.stringify(expectedLibc)) {
|
|
21786
|
-
return packageFailure(
|
|
21787
|
-
"target_mismatch",
|
|
21788
|
-
`Package ${target.value.packageName} does not match target ${target.value.target}.`
|
|
21789
|
-
);
|
|
21790
|
-
}
|
|
21791
|
-
const packageRoot = dirname(packageJsonPath);
|
|
21792
|
-
const manifestPath = resolve(packageRoot, metadata.manifest);
|
|
21793
|
-
const binaryPath = resolve(packageRoot, metadata.binary);
|
|
21794
|
-
if (!isConfinedPath(packageRoot, manifestPath) || !isConfinedPath(packageRoot, binaryPath)) {
|
|
21795
|
-
return packageFailure(
|
|
21796
|
-
"package_invalid",
|
|
21797
|
-
`Package ${target.value.packageName} contains an unsafe artifact path.`
|
|
21798
|
-
);
|
|
21799
21786
|
}
|
|
21800
|
-
|
|
21801
|
-
|
|
21802
|
-
return
|
|
21803
|
-
"manifest_invalid",
|
|
21804
|
-
`Rust backend package ${target.value.packageName} is incomplete: binary-manifest.json is missing or invalid.`
|
|
21805
|
-
);
|
|
21787
|
+
if (result.status === 404 || result.status === 405) {
|
|
21788
|
+
writeError2(io, options.json, "unsupported_runtime", oldRuntimeMessage(origin));
|
|
21789
|
+
return 1;
|
|
21806
21790
|
}
|
|
21807
|
-
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
21791
|
+
if (result.status === 409) {
|
|
21792
|
+
writeError2(
|
|
21793
|
+
io,
|
|
21794
|
+
options.json,
|
|
21795
|
+
"alias_conflict",
|
|
21796
|
+
`${result.detail ?? "the base path is already mounted or conflicts with another mount"}. Run "agent-inspector alias list --host ${options.host} --port ${options.port}" to inspect the current runtime.`
|
|
21812
21797
|
);
|
|
21798
|
+
return 1;
|
|
21813
21799
|
}
|
|
21814
|
-
|
|
21815
|
-
|
|
21816
|
-
|
|
21817
|
-
|
|
21818
|
-
|
|
21800
|
+
const detail = result.detail === null ? "the runtime rejected the request" : result.detail;
|
|
21801
|
+
writeError2(
|
|
21802
|
+
io,
|
|
21803
|
+
options.json,
|
|
21804
|
+
"runtime_rejected_request",
|
|
21805
|
+
`${detail} (HTTP ${result.status}). Check the running instance and retry; no runtime was started.`
|
|
21806
|
+
);
|
|
21807
|
+
return 1;
|
|
21808
|
+
}
|
|
21809
|
+
async function runAlias(argv, fetchImpl = fetch, io = processIo2) {
|
|
21810
|
+
const parsed = parseAliasArgs(argv);
|
|
21811
|
+
if (parsed.kind === "help") {
|
|
21812
|
+
io.stdout(aliasHelp());
|
|
21813
|
+
return 0;
|
|
21819
21814
|
}
|
|
21820
|
-
if (
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
|
|
21815
|
+
if (parsed.kind === "error") {
|
|
21816
|
+
io.stderr(`${parsed.message}
|
|
21817
|
+
|
|
21818
|
+
${aliasHelp()}`);
|
|
21819
|
+
return 2;
|
|
21825
21820
|
}
|
|
21826
|
-
|
|
21827
|
-
|
|
21828
|
-
|
|
21829
|
-
|
|
21830
|
-
|
|
21831
|
-
|
|
21832
|
-
|
|
21833
|
-
|
|
21821
|
+
const { options } = parsed;
|
|
21822
|
+
const origin = `http://${formatHostForUrl(options.host)}:${options.port}`;
|
|
21823
|
+
const endpoint2 = `${origin}${ALIAS_CONTROL_PATH}`;
|
|
21824
|
+
const result = await requestAliases(endpoint2, options.action, fetchImpl);
|
|
21825
|
+
switch (result.kind) {
|
|
21826
|
+
case "success": {
|
|
21827
|
+
const output = buildOutput(origin, options.action, result.snapshot);
|
|
21828
|
+
io.stdout(options.json ? `${JSON.stringify(output, null, 2)}
|
|
21829
|
+
` : formatHumanOutput(output));
|
|
21830
|
+
return 0;
|
|
21834
21831
|
}
|
|
21835
|
-
|
|
21836
|
-
|
|
21837
|
-
|
|
21838
|
-
|
|
21839
|
-
|
|
21840
|
-
|
|
21841
|
-
|
|
21842
|
-
|
|
21843
|
-
|
|
21844
|
-
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
|
|
21848
|
-
|
|
21849
|
-
|
|
21850
|
-
|
|
21851
|
-
|
|
21852
|
-
|
|
21853
|
-
`Rust backend binary did not pass the production identity gate: ${probed.message}. No TypeScript fallback was used.`
|
|
21854
|
-
);
|
|
21832
|
+
case "network-error":
|
|
21833
|
+
writeError2(
|
|
21834
|
+
io,
|
|
21835
|
+
options.json,
|
|
21836
|
+
result.timedOut ? "request_timeout" : "runtime_unreachable",
|
|
21837
|
+
`${result.timedOut ? "timed out contacting" : "cannot reach"} ${origin}. Confirm the existing runtime is running and the --host/--port values are correct; no runtime was started.`
|
|
21838
|
+
);
|
|
21839
|
+
return 1;
|
|
21840
|
+
case "invalid-response":
|
|
21841
|
+
writeError2(
|
|
21842
|
+
io,
|
|
21843
|
+
options.json,
|
|
21844
|
+
"invalid_runtime_response",
|
|
21845
|
+
`the runtime at ${origin} returned an invalid alias response. Upgrade and restart that instance, then retry; no runtime was started.`
|
|
21846
|
+
);
|
|
21847
|
+
return 1;
|
|
21848
|
+
case "http-error":
|
|
21849
|
+
return handleHttpError(options, endpoint2, origin, result, fetchImpl, io);
|
|
21855
21850
|
}
|
|
21856
|
-
|
|
21857
|
-
|
|
21858
|
-
|
|
21859
|
-
|
|
21860
|
-
|
|
21851
|
+
}
|
|
21852
|
+
var DEFAULT_ALIAS_HOST, DEFAULT_ALIAS_PORT, ALIAS_CONTROL_PATH, REQUEST_TIMEOUT_MS, processIo2;
|
|
21853
|
+
var init_alias = __esm({
|
|
21854
|
+
"src/cli/alias.ts"() {
|
|
21855
|
+
"use strict";
|
|
21856
|
+
init_basePath();
|
|
21857
|
+
DEFAULT_ALIAS_HOST = "localhost";
|
|
21858
|
+
DEFAULT_ALIAS_PORT = 9527;
|
|
21859
|
+
ALIAS_CONTROL_PATH = "/.agent-inspector/base-path-aliases";
|
|
21860
|
+
REQUEST_TIMEOUT_MS = 5e3;
|
|
21861
|
+
processIo2 = {
|
|
21862
|
+
stdout: (text) => {
|
|
21863
|
+
process.stdout.write(text);
|
|
21864
|
+
},
|
|
21865
|
+
stderr: (text) => {
|
|
21866
|
+
process.stderr.write(text);
|
|
21867
|
+
}
|
|
21868
|
+
};
|
|
21861
21869
|
}
|
|
21862
|
-
|
|
21863
|
-
|
|
21864
|
-
|
|
21865
|
-
|
|
21866
|
-
|
|
21867
|
-
|
|
21868
|
-
|
|
21869
|
-
|
|
21870
|
-
|
|
21871
|
-
|
|
21872
|
-
|
|
21870
|
+
});
|
|
21871
|
+
|
|
21872
|
+
// src/cli.ts
|
|
21873
|
+
init_package();
|
|
21874
|
+
init_backendImplementation();
|
|
21875
|
+
init_basePath();
|
|
21876
|
+
init_managedInstance();
|
|
21877
|
+
init_networkHints();
|
|
21878
|
+
import { Buffer as Buffer5 } from "node:buffer";
|
|
21879
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
21880
|
+
import { createConnection as createConnection2 } from "node:net";
|
|
21881
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
21882
|
+
import { dirname as dirname3, join as join9, resolve as resolvePath2 } from "node:path";
|
|
21883
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
21884
|
+
|
|
21885
|
+
// src/cli/startupOutput.ts
|
|
21886
|
+
function shouldSuppressServerOutputLine(line, context) {
|
|
21887
|
+
if (!context.enableIdentityProxy) return false;
|
|
21888
|
+
if (context.publicPort === context.upstreamPort) return false;
|
|
21889
|
+
const lowerLine = line.toLowerCase();
|
|
21890
|
+
return lowerLine.includes("listening on") && lowerLine.includes(`:${context.upstreamPort}`);
|
|
21873
21891
|
}
|
|
21874
21892
|
|
|
21893
|
+
// src/cli.ts
|
|
21894
|
+
init_rustBackendPackage();
|
|
21895
|
+
|
|
21875
21896
|
// src/cli/instanceApi.ts
|
|
21876
21897
|
init_instance();
|
|
21877
21898
|
init_instanceContract();
|
|
@@ -24781,7 +24802,7 @@ Global options:
|
|
|
24781
24802
|
-v, --version Print the package version
|
|
24782
24803
|
|
|
24783
24804
|
Start options:
|
|
24784
|
-
--backend <typescript|rust> Select the backend implementation (default:
|
|
24805
|
+
--backend <typescript|rust> Select the backend implementation (default: rust when native package is available)
|
|
24785
24806
|
--backend-only, --headless Start the API, proxy, and MCP runtime without serving the UI
|
|
24786
24807
|
--with-ui Serve the independently built UI through the protected ingress
|
|
24787
24808
|
--port, -p <port> Public ingress port (default: 9527)
|
|
@@ -25144,7 +25165,8 @@ async function runStart(args) {
|
|
|
25144
25165
|
const portDefault = envPort !== void 0 ? Number(envPort) : DEFAULT_PORT4;
|
|
25145
25166
|
const envHost = process.env["NITRO_HOST"] ?? process.env["HOST"];
|
|
25146
25167
|
const envMode = process.env["AGENT_INSPECTOR_CAPTURE_MODE"] ?? process.env["AGENT_INSPECTOR_MODE"];
|
|
25147
|
-
const
|
|
25168
|
+
const rawEnvBackend = process.env[AGENT_INSPECTOR_BACKEND_ENV];
|
|
25169
|
+
const envBackend = rawEnvBackend === void 0 ? void 0 : parseBackendImplementation(rawEnvBackend);
|
|
25148
25170
|
if (envBackend === null) {
|
|
25149
25171
|
console.error(
|
|
25150
25172
|
`Invalid ${AGENT_INSPECTOR_BACKEND_ENV}. Use typescript or rust; no backend was started.`
|
|
@@ -25165,7 +25187,8 @@ async function runStart(args) {
|
|
|
25165
25187
|
let enableIdentityProxy = true;
|
|
25166
25188
|
let legacyAliasEnabled = false;
|
|
25167
25189
|
let serveUi = process.env["AGENT_INSPECTOR_BACKEND_ONLY"] !== "1";
|
|
25168
|
-
let backend = envBackend;
|
|
25190
|
+
let backend = envBackend ?? "typescript";
|
|
25191
|
+
let backendWasSpecified = envBackend !== void 0;
|
|
25169
25192
|
if (envMode !== void 0 && envMode !== "") {
|
|
25170
25193
|
const parsedMode = parseCaptureMode(envMode);
|
|
25171
25194
|
if (parsedMode === null) {
|
|
@@ -25219,6 +25242,7 @@ async function runStart(args) {
|
|
|
25219
25242
|
return;
|
|
25220
25243
|
}
|
|
25221
25244
|
backend = parsedBackend.data;
|
|
25245
|
+
backendWasSpecified = true;
|
|
25222
25246
|
continue;
|
|
25223
25247
|
}
|
|
25224
25248
|
switch (arg) {
|
|
@@ -25249,6 +25273,7 @@ async function runStart(args) {
|
|
|
25249
25273
|
return;
|
|
25250
25274
|
}
|
|
25251
25275
|
backend = parsedBackend.data;
|
|
25276
|
+
backendWasSpecified = true;
|
|
25252
25277
|
i++;
|
|
25253
25278
|
break;
|
|
25254
25279
|
}
|
|
@@ -25338,6 +25363,9 @@ async function runStart(args) {
|
|
|
25338
25363
|
process.exitCode = 1;
|
|
25339
25364
|
return;
|
|
25340
25365
|
}
|
|
25366
|
+
if (!backendWasSpecified) {
|
|
25367
|
+
backend = managedLaunch?.backend ?? resolvePreferredBackendImplementation({ rootVersion: package_default.version });
|
|
25368
|
+
}
|
|
25341
25369
|
if (managedLaunch !== null && managedLaunch.backend !== backend) {
|
|
25342
25370
|
console.error(
|
|
25343
25371
|
`Managed instance backend mismatch: launch identity requires ${managedLaunch.backend}, but ${backend} was selected.`
|