@tonyclaw/agent-inspector 3.0.43 → 3.0.45

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.
Files changed (80) hide show
  1. package/.output/cli.js +20744 -16945
  2. package/.output/nitro.json +1 -1
  3. package/.output/public/assets/{CompareDrawer-BAXxwTwT.js → CompareDrawer-B3_TLTJh.js} +1 -1
  4. package/.output/public/assets/{InspectorPet-xYuGV4Qz.js → InspectorPet-Cpn6hv4P.js} +1 -1
  5. package/.output/public/assets/{ProxyViewerContainer-B6GZnUWi.js → ProxyViewerContainer-BEAhuGOJ.js} +27 -27
  6. package/.output/public/assets/{ReplayDialog-D73pyIg3.js → ReplayDialog-B3EKVdJk.js} +1 -1
  7. package/.output/public/assets/{RequestAnatomy-CSDta_nu.js → RequestAnatomy-COOQjyUC.js} +1 -1
  8. package/.output/public/assets/{ResponseView-C4aIUPby.js → ResponseView-DBCjkwye.js} +1 -1
  9. package/.output/public/assets/{StreamingChunkSequence-D4xxosLx.js → StreamingChunkSequence-CuXhDgMo.js} +1 -1
  10. package/.output/public/assets/{_sessionId-CZHbJyWO.js → _sessionId-BJlM3nmt.js} +1 -1
  11. package/.output/public/assets/{_sessionId-DvuNLzSE.js → _sessionId-zbgYl7ZJ.js} +1 -1
  12. package/.output/public/assets/{index-DZ_wpqQM.js → index-BIK4bPTv.js} +1 -1
  13. package/.output/public/assets/{index-B17u7JMC.js → index-BZo_8koU.js} +15 -15
  14. package/.output/public/assets/{index-C0g79BAs.js → index-D2Qw6Ri2.js} +1 -1
  15. package/.output/public/assets/{index-BWjeqxbk.css → index-ZWschkCh.css} +1 -1
  16. package/.output/public/assets/{index-CmEO8ykj.js → index-xF_NY8Yb.js} +5 -5
  17. package/.output/public/assets/{json-viewer-CuWU-H6K.js → json-viewer-B-Ao6pwW.js} +1 -1
  18. package/.output/public/assets/{jszip.min-DPJI_UKW.js → jszip.min-B_rfAUCe.js} +1 -1
  19. package/.output/server/_libs/modelcontextprotocol__core.mjs +25 -25
  20. package/.output/server/_libs/modelcontextprotocol__server.mjs +2 -2
  21. package/.output/server/_libs/zod.mjs +6 -6
  22. package/.output/server/{_sessionId-Cun21KZF.mjs → _sessionId-CJ99gZFV.mjs} +3 -1
  23. package/.output/server/{_sessionId-CoFyeOti.mjs → _sessionId-DEjScBpK.mjs} +5 -3
  24. package/.output/server/_ssr/{CompareDrawer-Bgc2TZh_.mjs → CompareDrawer-DtOIMeQB.mjs} +4 -2
  25. package/.output/server/_ssr/{InspectorPet-DyK2ojeh.mjs → InspectorPet-CXc4oCBQ.mjs} +3 -1
  26. package/.output/server/_ssr/{ProxyViewerContainer-hvn6oVWD.mjs → ProxyViewerContainer-DVPlwfkt.mjs} +52 -27
  27. package/.output/server/_ssr/{ReplayDialog-KpnrGtZ-.mjs → ReplayDialog-BQEA95qC.mjs} +6 -4
  28. package/.output/server/_ssr/{RequestAnatomy-uCsfucn8.mjs → RequestAnatomy-BMyd8B7Q.mjs} +4 -2
  29. package/.output/server/_ssr/{ResponseView-C8UPqoPO.mjs → ResponseView-qrTaEIM8.mjs} +4 -2
  30. package/.output/server/_ssr/{StreamingChunkSequence-BP28I9sh.mjs → StreamingChunkSequence-BFTL8mIy.mjs} +5 -3
  31. package/.output/server/_ssr/{index-Du3YNDKx.mjs → index-Bcj1Hcy4.mjs} +4 -2
  32. package/.output/server/_ssr/{index-BVwVoQlZ.mjs → index-DW-M7XUG.mjs} +3 -1
  33. package/.output/server/_ssr/index.mjs +4 -3
  34. package/.output/server/_ssr/{json-viewer-DrE0vtlB.mjs → json-viewer-DiI0Yjsn.mjs} +4 -2
  35. package/.output/server/_ssr/publicBasePathContext-5264L3rX.mjs +148 -0
  36. package/.output/server/_ssr/{router-C6nWUZHK.mjs → router-BJ_ltLim.mjs} +2432 -475
  37. package/.output/server/_ssr/start-C6MjPjxp.mjs +57 -0
  38. package/.output/server/_tanstack-start-manifest_v-C6pXXX9R.mjs +4 -0
  39. package/.output/server/index.mjs +99 -99
  40. package/.output/workers/logFinalizer.worker.js +4 -0
  41. package/.output/workers/sessionWorkerEntry.js +4 -0
  42. package/README.md +221 -25
  43. package/docs/instance-control.openapi.yaml +306 -0
  44. package/package.json +4 -1
  45. package/src/cli/alias.ts +440 -0
  46. package/src/cli/instance.ts +1037 -0
  47. package/src/cli/instanceArgs.ts +266 -0
  48. package/src/cli/instanceControl.ts +183 -0
  49. package/src/cli/instanceModel.ts +275 -0
  50. package/src/cli/instanceRegistry.ts +740 -0
  51. package/src/cli/onboard.ts +123 -35
  52. package/src/cli/onboardTarget.ts +179 -0
  53. package/src/cli/templates/codex-skill-onboard.ts +76 -28
  54. package/src/cli/templates/skill-onboard.ts +93 -59
  55. package/src/cli.ts +154 -16
  56. package/src/components/ProxyViewer.tsx +13 -5
  57. package/src/components/providers/SettingsDialog.tsx +13 -8
  58. package/src/lib/basePath.ts +8 -2
  59. package/src/lib/codingAgentEndpoints.ts +16 -0
  60. package/src/lib/instanceContract.ts +220 -0
  61. package/src/lib/managedInstance.ts +104 -0
  62. package/src/lib/publicBasePathContext.ts +107 -0
  63. package/src/mcp/instanceHandlers.ts +149 -0
  64. package/src/mcp/loopback.ts +16 -5
  65. package/src/mcp/mode.ts +25 -0
  66. package/src/mcp/server.ts +258 -18
  67. package/src/mcp/toolHandlers.ts +2 -2
  68. package/src/proxy/identityProxy.ts +656 -36
  69. package/src/proxy/runtimeShutdown.ts +73 -1
  70. package/src/proxy/sessionInfo.ts +5 -4
  71. package/src/routes/api/-instances.ts +109 -0
  72. package/src/routes/api/instances.$name.connection.ts +12 -0
  73. package/src/routes/api/instances.$name.restart.ts +23 -0
  74. package/src/routes/api/instances.$name.start.ts +18 -0
  75. package/src/routes/api/instances.$name.stop.ts +23 -0
  76. package/src/routes/api/instances.$name.ts +12 -0
  77. package/src/routes/api/instances.ts +16 -0
  78. package/src/start.ts +10 -0
  79. package/.output/server/_ssr/start-HYkvq4Ni.mjs +0 -4
  80. package/.output/server/_tanstack-start-manifest_v-rshlRaiN.mjs +0 -4
@@ -11,6 +11,16 @@ export type CodexSkillOnboardContext = {
11
11
  readonly version: string;
12
12
  /** The default proxy port (mirrors `DEFAULT_PORT` in `src/cli.ts`). */
13
13
  readonly port: number;
14
+ /** Public UI base URL, including the configured base path. */
15
+ readonly baseUrl: string;
16
+ /** MCP config key selected by onboarding. */
17
+ readonly mcpName?: string;
18
+ /** Selected onboarding target type. */
19
+ readonly targetKind?: "default" | "instance" | "base-url";
20
+ /** Normalized registry name for a named target. */
21
+ readonly instanceName?: string | null;
22
+ /** CLI arguments that reproduce the selected target. */
23
+ readonly onboardTargetArguments?: string;
14
24
  };
15
25
 
16
26
  export const REQUIRED_CODEX_PHASE_HEADINGS = [
@@ -23,7 +33,35 @@ export const REQUIRED_CODEX_PHASE_HEADINGS = [
23
33
  ] as const;
24
34
 
25
35
  export function renderCodexSkillOnboard(ctx: CodexSkillOnboardContext): string {
26
- const { version, port } = ctx;
36
+ const { version, baseUrl } = ctx;
37
+ const mcpName = ctx.mcpName ?? "agent-inspector";
38
+ const targetKind = ctx.targetKind ?? "default";
39
+ const targetArguments = ctx.onboardTargetArguments ?? "";
40
+ const instanceName = ctx.instanceName ?? null;
41
+ const healthUrl = `${baseUrl}/api/health`;
42
+ const configUrl = `${baseUrl}/api/config`;
43
+ const anthropicProxyUrl = `${baseUrl}/proxy`;
44
+ const openAiProxyUrl = `${baseUrl}/proxy/v1`;
45
+ const mcpUrl = `${baseUrl}/api/mcp`;
46
+ const mcpTomlKey = /^[A-Za-z0-9_-]+$/u.test(mcpName) ? mcpName : JSON.stringify(mcpName);
47
+ const statusCommand = `agent-inspector onboard --status${targetArguments}`;
48
+ const refreshCommand = `agent-inspector onboard --force${targetArguments}`;
49
+ const startCommand =
50
+ targetKind === "instance" && instanceName !== null
51
+ ? `agent-inspector instance start ${instanceName}`
52
+ : targetKind === "base-url"
53
+ ? `# Explicit target ${baseUrl}: do not start a replacement local runtime.`
54
+ : "agent-inspector --mode simple --background --no-open";
55
+ const fullModeCommand =
56
+ targetKind === "instance" && instanceName !== null
57
+ ? `agent-inspector instance restart ${instanceName} --mode full`
58
+ : targetKind === "base-url"
59
+ ? "ask the target operator to enable Full capture mode"
60
+ : "agent-inspector --mode full --force-restart";
61
+ const startExplanation =
62
+ targetKind === "base-url"
63
+ ? `The selected Inspector target is the explicit Base URL \`${baseUrl}\`. Do not start the default local runtime as a substitute; verify the selected target and ask its operator for help if it is unavailable.`
64
+ : `Start or reuse the selected Agent Inspector runtime before wiring MCP. Prefer the installed binary so Windows users get the branded runtime in Task Manager. Use \`${fullModeCommand}\` only when the user needs raw headers, raw response, or SSE chunks.`;
27
65
  return `---
28
66
  name: agent-inspector-onboard
29
67
  description: Guide Codex users through connecting Agent Inspector v${version} as a local MCP server.
@@ -39,7 +77,7 @@ Use this skill when the user wants to set up Agent Inspector inside Codex, conne
39
77
  Agent Inspector runs a local web UI, proxy, REST API, and MCP endpoint on the same port. The default MCP endpoint is:
40
78
 
41
79
  \`\`\`text
42
- http://localhost:${port}/api/mcp
80
+ ${mcpUrl}
43
81
  \`\`\`
44
82
 
45
83
  This skill is installed at \`~/.codex/skills/agent-inspector-onboard/SKILL.md\`.
@@ -47,8 +85,8 @@ Codex user-level configuration lives in \`~/.codex/config.toml\`. Codex supports
47
85
 
48
86
  Use exactly one MCP transport for the same Inspector instance:
49
87
 
50
- - Streamable HTTP MCP: configure \`url = "http://localhost:${port}/api/mcp"\`.
51
- - Stdio-only MCP clients: configure \`agent-inspector-mcp stdio --url http://localhost:${port}/api/mcp\`.
88
+ - Streamable HTTP MCP: configure \`url = "${mcpUrl}"\`.
89
+ - Stdio-only MCP clients: configure \`agent-inspector-mcp stdio --url ${mcpUrl}\`.
52
90
 
53
91
  Do not configure both transports in the same MCP client, or the client may show duplicate Inspector tools.
54
92
 
@@ -64,14 +102,14 @@ Check that the package and Codex home exist without printing secrets.
64
102
 
65
103
  \`\`\`powershell
66
104
  Get-Command agent-inspector -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source
67
- agent-inspector onboard --status
105
+ ${statusCommand}
68
106
  Test-Path (Join-Path $env:USERPROFILE ".codex")
69
107
  Test-Path (Join-Path $env:USERPROFILE ".codex\\config.toml")
70
108
  \`\`\`
71
109
 
72
110
  \`\`\`bash
73
111
  node -e "const fs=require('node:fs'),p=require('node:path');const names=process.platform==='win32'?['agent-inspector.cmd','agent-inspector.exe','agent-inspector']:['agent-inspector'];const found=(process.env.PATH||'').split(p.delimiter).some(d=>names.some(n=>fs.existsSync(p.join(d,n))));console.log(found?'agent-inspector: present':'agent-inspector: missing')"
74
- agent-inspector onboard --status
112
+ ${statusCommand}
75
113
  test -d "$HOME/.codex" && echo "codex home: present" || echo "codex home: missing"
76
114
  test -f "$HOME/.codex/config.toml" && echo "config: present" || echo "config: missing"
77
115
  \`\`\`
@@ -82,8 +120,8 @@ If \`agent-inspector\` is missing, ask the user to install it first:
82
120
  npm install -g @tonyclaw/agent-inspector
83
121
  \`\`\`
84
122
 
85
- If \`agent-inspector onboard --status\` reports \`outdated\` or \`missing\`, ask the user to run
86
- \`agent-inspector onboard --force\` and restart this skill before continuing.
123
+ If \`${statusCommand}\` reports \`outdated\` or \`missing\`, ask the user to run
124
+ \`${refreshCommand}\` and restart this skill before continuing.
87
125
 
88
126
  Do not read \`~/.codex/auth.json\`, token files, or unrelated Codex state files.
89
127
 
@@ -91,33 +129,33 @@ Do not read \`~/.codex/auth.json\`, token files, or unrelated Codex state files.
91
129
 
92
130
  ## Phase 1: Start Agent Inspector
93
131
 
94
- Start or reuse Agent Inspector before wiring MCP. Prefer the installed binary so Windows users get the branded runtime in Task Manager. Start onboarding in Simple mode; if the user needs raw headers, raw response, or SSE chunks later, restart with \`agent-inspector --mode full\`.
132
+ ${startExplanation}
95
133
 
96
134
  \`\`\`powershell
97
- agent-inspector --mode simple --background --no-open
98
- Invoke-RestMethod -Uri "http://localhost:${port}/api/health" -TimeoutSec 3
99
- Invoke-RestMethod -Uri "http://localhost:${port}/api/config" -TimeoutSec 3 | Select-Object captureMode
135
+ ${startCommand}
136
+ Invoke-RestMethod -Uri "${healthUrl}" -TimeoutSec 3
137
+ Invoke-RestMethod -Uri "${configUrl}" -TimeoutSec 3 | Select-Object captureMode
100
138
  \`\`\`
101
139
 
102
140
  \`\`\`bash
103
- agent-inspector --mode simple --background --no-open
104
- curl -fsS "http://localhost:${port}/api/health"
105
- curl -fsS "http://localhost:${port}/api/config" | grep -o '"captureMode":"[^"]*"'
141
+ ${startCommand}
142
+ curl -fsS "${healthUrl}"
143
+ curl -fsS "${configUrl}" | grep -o '"captureMode":"[^"]*"'
106
144
  \`\`\`
107
145
 
108
- If the health check fails, show only the relevant error and ask whether to diagnose startup before editing Codex config. If the active capture mode is not \`simple\`, explain that an existing process is already running and offer to restart with \`agent-inspector --mode simple --force-restart\`.
146
+ If the health check fails, show only the relevant error and ask whether to diagnose the selected target before editing Codex config. If deeper capture is required, offer \`${fullModeCommand}\`.
109
147
 
110
148
  ---
111
149
 
112
150
  ## Phase 2: Wire Codex MCP
113
151
 
114
- Add an \`agent-inspector\` MCP server to \`~/.codex/config.toml\`. Preserve the user's existing config and merge the table instead of replacing the file.
152
+ Add the \`${mcpName}\` MCP server to \`~/.codex/config.toml\`. Preserve the user's existing config and merge the table instead of replacing the file.
115
153
 
116
154
  Recommended user-level config for Codex builds that support Streamable HTTP MCP:
117
155
 
118
156
  \`\`\`toml
119
- [mcp_servers.agent-inspector]
120
- url = "http://localhost:${port}/api/mcp"
157
+ [mcp_servers.${mcpTomlKey}]
158
+ url = "${mcpUrl}"
121
159
  startup_timeout_sec = 30
122
160
  tool_timeout_sec = 60
123
161
  \`\`\`
@@ -125,9 +163,9 @@ tool_timeout_sec = 60
125
163
  Fallback config for a stdio-only MCP client:
126
164
 
127
165
  \`\`\`toml
128
- [mcp_servers.agent-inspector]
166
+ [mcp_servers.${mcpTomlKey}]
129
167
  command = "agent-inspector-mcp"
130
- args = ["stdio", "--url", "http://localhost:${port}/api/mcp"]
168
+ args = ["stdio", "--url", "${mcpUrl}"]
131
169
  \`\`\`
132
170
 
133
171
  The stdio command is only a bridge to the same HTTP MCP endpoint. It does not start a second Inspector server.
@@ -135,8 +173,8 @@ The stdio command is only a bridge to the same HTTP MCP endpoint. It does not st
135
173
  If the user's Codex environment is managed by an admin allowlist, they may also need a matching identity rule in the managed requirements layer:
136
174
 
137
175
  \`\`\`toml
138
- [mcp_servers.agent-inspector.identity]
139
- url = "http://localhost:${port}/api/mcp"
176
+ [mcp_servers.${mcpTomlKey}.identity]
177
+ url = "${mcpUrl}"
140
178
  \`\`\`
141
179
 
142
180
  When editing:
@@ -156,7 +194,7 @@ Tell the user that Codex loads MCP servers at session startup. After saving \`co
156
194
  Before restart, verify the HTTP endpoint itself:
157
195
 
158
196
  \`\`\`bash
159
- curl -sS -X POST "http://localhost:${port}/api/mcp" \\
197
+ curl -sS -X POST "${mcpUrl}" \\
160
198
  -H "Content-Type: application/json" \\
161
199
  -H "Accept: application/json, text/event-stream" \\
162
200
  -d '{
@@ -203,13 +241,23 @@ Provider mutation tools expose and modify local provider configuration. Ask for
203
241
 
204
242
  ## Phase 5: Capture and memory review
205
243
 
206
- To capture Codex traffic through Agent Inspector, route a model client through:
244
+ To capture traffic through Agent Inspector, use the protocol-correct base URL:
207
245
 
208
246
  \`\`\`text
209
- http://localhost:${port}/proxy
247
+ Anthropic: ${anthropicProxyUrl}
248
+ OpenAI Responses / Codex: ${openAiProxyUrl}
210
249
  \`\`\`
211
250
 
212
- For Anthropic-compatible tools, set \`ANTHROPIC_BASE_URL=http://localhost:${port}/proxy\`. For OpenAI-compatible tools, set \`OPENAI_BASE_URL=http://localhost:${port}/proxy\`.
251
+ For Anthropic-compatible tools, set \`ANTHROPIC_BASE_URL=${anthropicProxyUrl}\`. For OpenAI-compatible tools and Codex Responses providers, set \`OPENAI_BASE_URL=${openAiProxyUrl}\`.
252
+
253
+ Example Codex Responses provider snippet:
254
+
255
+ \`\`\`toml
256
+ [model_providers.agent-inspector]
257
+ name = "Agent Inspector"
258
+ base_url = "${openAiProxyUrl}"
259
+ wire_api = "responses"
260
+ \`\`\`
213
261
 
214
262
  If Codex or another AI tool runs in a different container, VM, WSL distro, or host than Agent
215
263
  Inspector, \`localhost\` points at the tool's own environment. Replace \`localhost\` with an Inspector
@@ -218,7 +266,7 @@ provider credentials.
218
266
 
219
267
  For a Provider Test memory probe, run a provider test in the Agent Inspector UI:
220
268
 
221
- 1. Open \`http://localhost:${port}\`.
269
+ 1. Open \`${baseUrl}\`.
222
270
  2. Go to Settings -> Providers.
223
271
  3. Add or edit a Provider.
224
272
  4. Run Test.
@@ -24,6 +24,16 @@ export type SkillOnboardContext = {
24
24
  readonly version: string;
25
25
  /** The default proxy port (mirrors `DEFAULT_PORT` in `src/cli.ts`). */
26
26
  readonly port: number;
27
+ /** Public UI base URL, including the configured base path. */
28
+ readonly baseUrl: string;
29
+ /** MCP config key selected by onboarding. */
30
+ readonly mcpName?: string;
31
+ /** Selected onboarding target type. */
32
+ readonly targetKind?: "default" | "instance" | "base-url";
33
+ /** Normalized registry name for a named target. */
34
+ readonly instanceName?: string | null;
35
+ /** CLI arguments that reproduce the selected target. */
36
+ readonly onboardTargetArguments?: string;
27
37
  /**
28
38
  * One-line "detected tools" summary written into the Preflight phase so the
29
39
  * skill's instructions match the user's actual environment. Empty string
@@ -46,7 +56,53 @@ export const REQUIRED_PHASE_HEADINGS = [
46
56
  ] as const;
47
57
 
48
58
  export function renderSkillOnboard(ctx: SkillOnboardContext): string {
49
- const { version, port, detectedSummary } = ctx;
59
+ const { version, port, baseUrl, detectedSummary } = ctx;
60
+ const mcpName = ctx.mcpName ?? "agent-inspector";
61
+ const targetKind = ctx.targetKind ?? "default";
62
+ const targetArguments = ctx.onboardTargetArguments ?? "";
63
+ const instanceName = ctx.instanceName ?? null;
64
+ const healthUrl = `${baseUrl}/api/health`;
65
+ const configUrl = `${baseUrl}/api/config`;
66
+ const anthropicProxyUrl = `${baseUrl}/proxy`;
67
+ const openAiProxyUrl = `${baseUrl}/proxy/v1`;
68
+ const mcpUrl = `${baseUrl}/api/mcp`;
69
+ const logsUrl = `${baseUrl}/api/logs`;
70
+ const statusCommand = `agent-inspector onboard --status${targetArguments}`;
71
+ const refreshCommand = `agent-inspector onboard --force${targetArguments}`;
72
+ const startCommand =
73
+ targetKind === "instance" && instanceName !== null
74
+ ? `agent-inspector instance start ${instanceName}`
75
+ : targetKind === "base-url"
76
+ ? `# Explicit target ${baseUrl}: do not start a replacement local runtime.`
77
+ : "agent-inspector --mode simple --background --no-open";
78
+ const fullModeCommand =
79
+ targetKind === "instance" && instanceName !== null
80
+ ? `agent-inspector instance restart ${instanceName} --mode full`
81
+ : targetKind === "base-url"
82
+ ? "ask the target operator to enable Full capture mode"
83
+ : "agent-inspector --mode full --force-restart";
84
+ const bashStartSnippet =
85
+ targetKind === "base-url" ? startCommand : `${startCommand} > /tmp/agent-inspector.log 2>&1`;
86
+ const windowsStartArguments =
87
+ targetKind === "instance" && instanceName !== null
88
+ ? `instance start ${instanceName}`
89
+ : "--mode simple --background --no-open";
90
+ const powershellStartSnippet =
91
+ targetKind === "base-url"
92
+ ? startCommand
93
+ : `$found = Get-Command agent-inspector -ErrorAction SilentlyContinue
94
+ if (-not $found) { throw 'agent-inspector is not on PATH' }
95
+ & $found.Source ${windowsStartArguments}`;
96
+ const startExplanation =
97
+ targetKind === "base-url"
98
+ ? `The selected Inspector target is the explicit Base URL \`${baseUrl}\`. Do not launch a default local runtime as a substitute; verify the selected target and ask its operator for help if it is unavailable.`
99
+ : `Start or reuse the selected Inspector runtime. It listens on port ${String(port)} and preserves the selected Base Path. Use \`${fullModeCommand}\` only when the user needs raw headers, raw response, or SSE chunks.`;
100
+ const stopSnippet =
101
+ targetKind === "instance" && instanceName !== null
102
+ ? `agent-inspector instance stop ${instanceName}`
103
+ : targetKind === "base-url"
104
+ ? `# Ask the operator of ${baseUrl} to stop the selected runtime.`
105
+ : `# Unix / macOS\n lsof -ti:${String(port)} | xargs -r kill -9\n\n # Windows PowerShell\n Get-NetTCPConnection -LocalPort ${String(port)} | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force }`;
50
106
  return `---
51
107
  name: agent-inspector-onboard
52
108
  description: Guided setup for Agent Inspector v${version}: start the proxy, wire your AI coding tool, capture your first request, and learn the Web UI.
@@ -62,7 +118,7 @@ Guide the user from "I just installed Agent Inspector" to "I can see my AI tool'
62
118
  Environment detected by the installer:
63
119
  ${detectedSummary || " (no known AI tool detected — the user can still use the generic curl example in Phase 4)"}
64
120
 
65
- Default proxy port: \`${port}\` (override with \`PORT=<n> agent-inspector\` or \`--port <n>\`).
121
+ Selected Inspector target: \`${baseUrl}\` (MCP key: \`${mcpName}\`).
66
122
 
67
123
  > **PAUSE protocol.** Every \`**PAUSE**\` marker in this skill is a real stop.
68
124
  > Use the \`AskUserQuestion\` tool to actually wait for the user before
@@ -77,22 +133,22 @@ Default proxy port: \`${port}\` (override with \`PORT=<n> agent-inspector\` or \
77
133
  **EXPLAIN:** "Before we do anything, let me see what's already set up. If some of the steps are already done, we can skip them."
78
134
 
79
135
  **DO:** First check whether the generated onboarding files match the installed npm package. If any
80
- entry is \`outdated\` or \`missing\`, tell the user to run \`agent-inspector onboard --force\` before
136
+ entry is \`outdated\` or \`missing\`, tell the user to run \`${refreshCommand}\` before
81
137
  continuing so they are not guided by stale instructions.
82
138
 
83
139
  \`\`\`bash
84
- agent-inspector onboard --status
140
+ ${statusCommand}
85
141
  \`\`\`
86
142
 
87
143
  \`\`\`powershell
88
- agent-inspector onboard --status
144
+ ${statusCommand}
89
145
  \`\`\`
90
146
 
91
147
  **DO:** Then probe the three pieces of state this skill touches. Use targeted checks — do **not** read large JSON files into the conversation.
92
148
 
93
149
  \`\`\`bash
94
150
  # 1. Is the proxy already up?
95
- curl -fsS "http://localhost:${port}/api/health" 2>/dev/null && echo "PROXY: up" || echo "PROXY: down"
151
+ curl -fsS "${healthUrl}" 2>/dev/null && echo "PROXY: up" || echo "PROXY: down"
96
152
 
97
153
  # 2. Does the provider config have a real provider key?
98
154
  agent_inspector_data_dir() {
@@ -123,9 +179,9 @@ fi
123
179
  # 3. Is the MCP server already wired? (project .mcp.json wins)
124
180
  PROJ_MCP=".mcp.json"
125
181
  HOME_MCP="$HOME/.claude.json"
126
- if [ -f "$PROJ_MCP" ] && grep -q '"agent-inspector"' "$PROJ_MCP"; then
182
+ if [ -f "$PROJ_MCP" ] && grep -q '"${mcpName}"' "$PROJ_MCP"; then
127
183
  echo "MCP: wired in $PROJ_MCP"
128
- elif [ -f "$HOME_MCP" ] && grep -q '"agent-inspector"' "$HOME_MCP"; then
184
+ elif [ -f "$HOME_MCP" ] && grep -q '"${mcpName}"' "$HOME_MCP"; then
129
185
  echo "MCP: wired in $HOME_MCP"
130
186
  else
131
187
  echo "MCP: not wired"
@@ -155,7 +211,7 @@ $legacyConfig = Join-Path $dataDir 'config.json'
155
211
 
156
212
  # 1. Is the proxy already up?
157
213
  try {
158
- $null = Invoke-RestMethod -Uri "http://localhost:$port/api/health" -TimeoutSec 2 -ErrorAction Stop
214
+ $null = Invoke-RestMethod -Uri "${healthUrl}" -TimeoutSec 2 -ErrorAction Stop
159
215
  Write-Host 'PROXY: up'
160
216
  } catch {
161
217
  Write-Host 'PROXY: down'
@@ -180,9 +236,9 @@ if ((Test-Path $providers) -or (Test-Path $legacyConfig)) {
180
236
  # 3. Is the MCP server already wired? (project .mcp.json wins)
181
237
  $projMcp = Join-Path (Get-Location) '.mcp.json'
182
238
  $homeMcp = Join-Path $env:USERPROFILE '.claude.json'
183
- if ((Test-Path $projMcp) -and (Select-String -Path $projMcp -Pattern 'agent-inspector' -Quiet)) {
239
+ if ((Test-Path $projMcp) -and (Select-String -Path $projMcp -SimpleMatch '${mcpName}' -Quiet)) {
184
240
  Write-Host "MCP: wired in $projMcp"
185
- } elseif ((Test-Path $homeMcp) -and (Select-String -Path $homeMcp -Pattern 'agent-inspector' -Quiet)) {
241
+ } elseif ((Test-Path $homeMcp) -and (Select-String -Path $homeMcp -SimpleMatch '${mcpName}' -Quiet)) {
186
242
  Write-Host "MCP: wired in $homeMcp"
187
243
  } else {
188
244
  Write-Host 'MCP: not wired'
@@ -341,44 +397,26 @@ $json | Set-Content -Path $file -Encoding UTF8
341
397
 
342
398
  ## Phase 3: Start proxy
343
399
 
344
- **EXPLAIN:** "Time to start the proxy. It binds to port ${port} by default, starts in Simple mode for lower overhead, reuses an already-running healthy agent-inspector, and prints the URL. Use \`--force-restart\` only when you intentionally want to replace the existing process. If the user is diagnosing raw headers, raw response, or SSE chunks, restart with \`agent-inspector --mode full\`."
400
+ **EXPLAIN:** "${startExplanation}"
345
401
 
346
402
  **DO:** Skip this phase entirely if the Phase 0 health check already reported \`PROXY: up\` and the user opted to skip done phases.
347
403
 
348
- **DO:** Otherwise, start the proxy with the explicit \`--background --no-open\` flags. On Windows, resolve the npm shim first and launch it through \`Start-Process -WindowStyle Hidden\` so setup does not flash a command window.
404
+ **DO:** Otherwise, use the selected target command below. An explicit wrapper Base URL is connection-only and must not cause a replacement local runtime to start.
349
405
 
350
406
  \`\`\`bash
351
- # Unix / macOS / WSL
352
- agent-inspector --mode simple --background --no-open > /tmp/agent-inspector.log 2>&1
407
+ ${bashStartSnippet}
353
408
  \`\`\`
354
409
 
355
410
  \`\`\`powershell
356
- # Windows PowerShell — single-quoted so $env: expands correctly.
357
- # Locate the binary on PATH first (works for npm, pnpm, yarn, volta, fnm).
358
- # If not on PATH, fall back to the common npm global shim at $env:APPDATA.
359
- # As a last resort, let cmd /c resolve it through PATHEXT.
360
- $log = Join-Path $env:TEMP 'agent-inspector.log'
361
- $err = Join-Path $env:TEMP 'agent-inspector.err.log'
362
- $found = Get-Command agent-inspector -ErrorAction SilentlyContinue
363
- if ($found) {
364
- $shim = $found.Source
365
- $args = '--mode','simple','--background','--no-open'
366
- } elseif (Test-Path (Join-Path $env:APPDATA 'npm/agent-inspector.cmd')) {
367
- $shim = Join-Path $env:APPDATA 'npm/agent-inspector.cmd'
368
- $args = '--mode','simple','--background','--no-open'
369
- } else {
370
- # bin not on PATH and not at the default npm prefix — let cmd resolve it
371
- $shim = 'cmd.exe'
372
- $args = '/c','agent-inspector','--mode','simple','--background','--no-open'
373
- }
374
- Start-Process -FilePath $shim -ArgumentList $args -RedirectStandardOutput $log -RedirectStandardError $err -WindowStyle Hidden
411
+ # Windows PowerShell
412
+ ${powershellStartSnippet}
375
413
  \`\`\`
376
414
 
377
415
  Then wait for the port to be ready:
378
416
 
379
417
  \`\`\`bash
380
418
  for i in $(seq 1 20); do
381
- curl -fsS "http://localhost:${port}/api/health" >/dev/null 2>&1 && echo "ready" && break
419
+ curl -fsS "${healthUrl}" >/dev/null 2>&1 && echo "ready" && break
382
420
  sleep 0.5
383
421
  done
384
422
  \`\`\`
@@ -386,13 +424,13 @@ done
386
424
  **DO:** Hit the health endpoint to confirm the proxy is alive:
387
425
 
388
426
  \`\`\`bash
389
- curl -sS "http://localhost:${port}/api/health"
427
+ curl -sS "${healthUrl}"
390
428
  \`\`\`
391
429
 
392
- **DO:** Read \`/api/config\` and tell the user which capture mode is active. If it is not \`simple\` during onboarding, explain that an existing process is already running and offer to restart with \`agent-inspector --mode simple --force-restart\`.
430
+ **DO:** Read \`/api/config\` and tell the user which capture mode is active. If deeper capture is required, offer \`${fullModeCommand}\`.
393
431
 
394
432
  \`\`\`bash
395
- curl -sS "http://localhost:${port}/api/config" | grep -o '"captureMode":"[^"]*"'
433
+ curl -sS "${configUrl}" | grep -o '"captureMode":"[^"]*"'
396
434
  \`\`\`
397
435
 
398
436
  > **PAUSE** — if the health check fails, show the user the log file (\`/tmp/agent-inspector.log\` or \`%TEMP%\\agent-inspector.log\`) and diagnose. Common issues: another process on the port, firewall, missing providers. Use \`AskUserQuestion\` with header \`Proxy up?\` and options \`["Yes, proxy is up", "No, I see an error in the log"]\`. Wait for the answer.
@@ -407,18 +445,18 @@ curl -sS "http://localhost:${port}/api/config" | grep -o '"captureMode":"[^"]*"'
407
445
 
408
446
  \`\`\`bash
409
447
  # Claude Code
410
- export ANTHROPIC_BASE_URL=http://localhost:${port}/proxy
448
+ export ANTHROPIC_BASE_URL=${anthropicProxyUrl}
411
449
  claude
412
450
 
413
451
  # OpenCode
414
- export LLM_BASE_URL=http://localhost:${port}/proxy
452
+ export LLM_BASE_URL=${openAiProxyUrl}
415
453
  opencode
416
454
 
417
455
  # MiMo Code
418
- export OPENAI_BASE_URL=http://localhost:${port}/proxy
456
+ export OPENAI_BASE_URL=${openAiProxyUrl}
419
457
  mimo
420
458
 
421
- # Cursor / Cody — set the OpenAI base URL in each tool's settings panel to http://localhost:${port}/proxy
459
+ # Cursor / Cody — set the OpenAI base URL in each tool's settings panel to ${openAiProxyUrl}
422
460
  \`\`\`
423
461
 
424
462
  **Container/network note:** If the AI tool runs in a different container, VM, WSL distro, or host
@@ -434,32 +472,32 @@ For a tool that wasn't auto-detected, fall through to the generic curl test in t
434
472
 
435
473
  ## Phase 4.5: Wire MCP server
436
474
 
437
- **EXPLAIN:** "The proxy also exposes an MCP server at \`http://localhost:${port}/api/mcp\`. Your AI agent can query logs, replay requests, and test providers through it — no need to leave the editor."
475
+ **EXPLAIN:** "The proxy also exposes an MCP server at \`${mcpUrl}\`. Your AI agent can query logs, replay requests, and test providers through it — no need to leave the editor."
438
476
 
439
477
  **DO:** Skip this phase if Phase 0 reported \`MCP: wired in <path>\` and the user opted to skip done phases.
440
478
 
441
479
  **DO:** Otherwise, check the project-level \`.mcp.json\` first (preferred — modern Claude Code convention), then fall back to \`~/.claude.json\`. Use the \`Read\` tool to inspect; do **not** \`cat\` a 40 KB file into the conversation.
442
480
 
443
- If neither has an \`agent-inspector\` entry, add one. The simplest path is to write to project \`.mcp.json\` (create it if missing):
481
+ If neither has a \`${mcpName}\` entry, add one. The simplest path is to write to project \`.mcp.json\` (create it if missing):
444
482
 
445
483
  \`\`\`json
446
484
  // .mcp.json (project root)
447
485
  {
448
486
  "mcpServers": {
449
- "agent-inspector": {
487
+ "${mcpName}": {
450
488
  "type": "http",
451
- "url": "http://localhost:${port}/api/mcp"
489
+ "url": "${mcpUrl}"
452
490
  }
453
491
  }
454
492
  }
455
493
  \`\`\`
456
494
 
457
- If \`mcpServers\` already exists in \`.mcp.json\`, merge the \`agent-inspector\` key into it via the \`Edit\` tool — do not overwrite other entries. If you can't create a project \`.mcp.json\` (no project root, permission, etc.), fall back to merging into \`~/.claude.json\` using the same \`Read\`/\`Edit\` pattern.
495
+ If \`mcpServers\` already exists in \`.mcp.json\`, merge only the \`${mcpName}\` key into it via the \`Edit\` tool — do not overwrite other entries. If you can't create a project \`.mcp.json\` (no project root, permission, etc.), fall back to merging into \`~/.claude.json\` using the same \`Read\`/\`Edit\` pattern.
458
496
 
459
497
  **DO:** Verify the handshake. The MCP \`initialize\` request should return 200 with a \`serverInfo\` payload — that proves the server is mounted and reachable:
460
498
 
461
499
  \`\`\`bash
462
- curl -sS -X POST "http://localhost:${port}/api/mcp" \\
500
+ curl -sS -X POST "${mcpUrl}" \\
463
501
  -H "Content-Type: application/json" \\
464
502
  -H "Accept: application/json, text/event-stream" \\
465
503
  -d '{
@@ -489,7 +527,7 @@ The \`grep -o '"name":"agent-inspector"'\` extracts only the serverInfo name —
489
527
  Fire a minimal Anthropic-format request through the proxy:
490
528
 
491
529
  \`\`\`bash
492
- curl -sS -X POST "http://localhost:${port}/proxy/v1/messages" \\
530
+ curl -sS -X POST "${anthropicProxyUrl}/v1/messages" \\
493
531
  -H "Content-Type: application/json" \\
494
532
  -H "anthropic-version: 2023-06-01" \\
495
533
  -H "x-api-key: \${AGENT_INSPECTOR_API_KEY:-sk-no-key-needed-for-routing}" \\
@@ -501,7 +539,7 @@ curl -sS -X POST "http://localhost:${port}/proxy/v1/messages" \\
501
539
 
502
540
  \`\`\`bash
503
541
  for i in $(seq 1 10); do
504
- resp=$(curl -sS "http://localhost:${port}/api/logs?limit=1")
542
+ resp=$(curl -sS "${logsUrl}?limit=1")
505
543
  count=$(echo "$resp" | grep -o '"total":[0-9]*' | head -1 | grep -o '[0-9]*$')
506
544
  if [ "\${count:-0}" -ge 1 ]; then
507
545
  echo "captured"
@@ -530,21 +568,17 @@ done
530
568
 
531
569
  **EXPLAIN:** "Everything's working. Here's the cheat sheet for the Web UI and the supporting surfaces:"
532
570
 
533
- - **Web UI**: \`http://localhost:${port}/\` — collapsible log rows, per-tab Copy/Expand in the log header, Diff with Raw (request body), Diff with Previous (compare adjacent requests), Replay (re-send a request), Export (JSON ZIP).
534
- - **MCP server**: \`http://localhost:${port}/api/mcp\` — connect from your coding agent to query logs, replay, and test providers without leaving the editor. Look for the "MCP Ready" badge in the Web UI header.
571
+ - **Web UI**: \`${baseUrl}\` — collapsible log rows, per-tab Copy/Expand in the log header, Diff with Raw (request body), Diff with Previous (compare adjacent requests), Replay (re-send a request), Export (JSON ZIP).
572
+ - **MCP server**: \`${mcpUrl}\` — connect from your coding agent to query logs, replay, and test providers without leaving the editor. Look for the "MCP Ready" badge in the Web UI header.
535
573
  - **REST API**: \`/api/logs\`, \`/api/sessions\`, \`/api/providers\` — for scripting and shell-based inspection.
536
574
  - **Stop the proxy**:
537
575
 
538
576
  \`\`\`bash
539
- # Unix / macOS
540
- lsof -ti:${port} | xargs -r kill -9
541
-
542
- # Windows PowerShell — single-quoted so $env: expands correctly
543
- Get-NetTCPConnection -LocalPort $port | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force }
577
+ ${stopSnippet}
544
578
  \`\`\`
545
579
 
546
- - **Re-run onboard**: \`agent-inspector onboard --force\` refreshes this skill.
547
- - **Check onboard files**: \`agent-inspector onboard --status\` shows whether generated skills are
580
+ - **Re-run onboard**: \`${refreshCommand}\` refreshes this skill.
581
+ - **Check onboard files**: \`${statusCommand}\` shows whether generated skills are
548
582
  current, outdated, missing, newer, or custom.
549
583
  - **Full docs**: see the project README (linked from the Web UI footer).
550
584