@tonyclaw/agent-inspector 3.0.44 → 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.
- package/.output/cli.js +20743 -16945
- package/.output/nitro.json +1 -1
- package/.output/public/assets/{CompareDrawer-DQHjxFO6.js → CompareDrawer-B3_TLTJh.js} +1 -1
- package/.output/public/assets/{InspectorPet-D1A4505B.js → InspectorPet-Cpn6hv4P.js} +1 -1
- package/.output/public/assets/{ProxyViewerContainer-BhpIgfBi.js → ProxyViewerContainer-BEAhuGOJ.js} +27 -27
- package/.output/public/assets/{ReplayDialog-C5vmbecv.js → ReplayDialog-B3EKVdJk.js} +1 -1
- package/.output/public/assets/{RequestAnatomy-CPGNB8lk.js → RequestAnatomy-COOQjyUC.js} +1 -1
- package/.output/public/assets/{ResponseView-DUfrajCm.js → ResponseView-DBCjkwye.js} +1 -1
- package/.output/public/assets/{StreamingChunkSequence-nbeCQqOz.js → StreamingChunkSequence-CuXhDgMo.js} +1 -1
- package/.output/public/assets/{_sessionId-mw3aA8Bp.js → _sessionId-BJlM3nmt.js} +1 -1
- package/.output/public/assets/{_sessionId-CDhRgzf6.js → _sessionId-zbgYl7ZJ.js} +1 -1
- package/.output/public/assets/{index-B2eoeT-Z.js → index-BIK4bPTv.js} +1 -1
- package/.output/public/assets/{index-C6qZwYlR.js → index-BZo_8koU.js} +15 -15
- package/.output/public/assets/{index-CX7_rf7o.js → index-D2Qw6Ri2.js} +1 -1
- package/.output/public/assets/{index-BWjeqxbk.css → index-ZWschkCh.css} +1 -1
- package/.output/public/assets/{index-BfRhTvOd.js → index-xF_NY8Yb.js} +5 -5
- package/.output/public/assets/{json-viewer-BLmF1sOZ.js → json-viewer-B-Ao6pwW.js} +1 -1
- package/.output/public/assets/{jszip.min-C9rCFoU3.js → jszip.min-B_rfAUCe.js} +1 -1
- package/.output/server/_libs/modelcontextprotocol__core.mjs +25 -25
- package/.output/server/_libs/modelcontextprotocol__server.mjs +2 -2
- package/.output/server/_libs/zod.mjs +6 -6
- package/.output/server/{_sessionId-U54BAqdp.mjs → _sessionId-CJ99gZFV.mjs} +3 -1
- package/.output/server/{_sessionId-E_Dmopc-.mjs → _sessionId-DEjScBpK.mjs} +5 -3
- package/.output/server/_ssr/{CompareDrawer-CksatPed.mjs → CompareDrawer-DtOIMeQB.mjs} +4 -2
- package/.output/server/_ssr/{InspectorPet-DNc4GQ7z.mjs → InspectorPet-CXc4oCBQ.mjs} +3 -1
- package/.output/server/_ssr/{ProxyViewerContainer-B02Ey0p_.mjs → ProxyViewerContainer-DVPlwfkt.mjs} +52 -27
- package/.output/server/_ssr/{ReplayDialog-DdMvHJF1.mjs → ReplayDialog-BQEA95qC.mjs} +6 -4
- package/.output/server/_ssr/{RequestAnatomy--vh2Z8__.mjs → RequestAnatomy-BMyd8B7Q.mjs} +4 -2
- package/.output/server/_ssr/{ResponseView-Dhxc-cKC.mjs → ResponseView-qrTaEIM8.mjs} +4 -2
- package/.output/server/_ssr/{StreamingChunkSequence-BG0EQmaD.mjs → StreamingChunkSequence-BFTL8mIy.mjs} +5 -3
- package/.output/server/_ssr/{index-lcfulIXa.mjs → index-Bcj1Hcy4.mjs} +4 -2
- package/.output/server/_ssr/{index-D0At9nfd.mjs → index-DW-M7XUG.mjs} +3 -1
- package/.output/server/_ssr/index.mjs +4 -3
- package/.output/server/_ssr/{json-viewer-My1J1_5R.mjs → json-viewer-DiI0Yjsn.mjs} +4 -2
- package/.output/server/_ssr/publicBasePathContext-5264L3rX.mjs +148 -0
- package/.output/server/_ssr/{router-DWcUFPR3.mjs → router-BJ_ltLim.mjs} +2432 -475
- package/.output/server/_ssr/start-C6MjPjxp.mjs +57 -0
- package/.output/server/_tanstack-start-manifest_v-C6pXXX9R.mjs +4 -0
- package/.output/server/index.mjs +92 -92
- package/.output/workers/logFinalizer.worker.js +4 -0
- package/.output/workers/sessionWorkerEntry.js +4 -0
- package/README.md +221 -25
- package/docs/instance-control.openapi.yaml +306 -0
- package/package.json +4 -1
- package/src/cli/alias.ts +440 -0
- package/src/cli/instance.ts +1037 -0
- package/src/cli/instanceArgs.ts +266 -0
- package/src/cli/instanceControl.ts +183 -0
- package/src/cli/instanceModel.ts +275 -0
- package/src/cli/instanceRegistry.ts +740 -0
- package/src/cli/onboard.ts +123 -35
- package/src/cli/onboardTarget.ts +179 -0
- package/src/cli/templates/codex-skill-onboard.ts +76 -28
- package/src/cli/templates/skill-onboard.ts +93 -59
- package/src/cli.ts +154 -16
- package/src/components/ProxyViewer.tsx +13 -5
- package/src/components/providers/SettingsDialog.tsx +13 -8
- package/src/lib/basePath.ts +8 -2
- package/src/lib/codingAgentEndpoints.ts +16 -0
- package/src/lib/instanceContract.ts +220 -0
- package/src/lib/managedInstance.ts +104 -0
- package/src/lib/publicBasePathContext.ts +107 -0
- package/src/mcp/instanceHandlers.ts +149 -0
- package/src/mcp/loopback.ts +16 -5
- package/src/mcp/mode.ts +25 -0
- package/src/mcp/server.ts +258 -18
- package/src/mcp/toolHandlers.ts +2 -2
- package/src/proxy/identityProxy.ts +655 -36
- package/src/proxy/runtimeShutdown.ts +73 -1
- package/src/proxy/sessionInfo.ts +5 -4
- package/src/routes/api/-instances.ts +109 -0
- package/src/routes/api/instances.$name.connection.ts +12 -0
- package/src/routes/api/instances.$name.restart.ts +23 -0
- package/src/routes/api/instances.$name.start.ts +18 -0
- package/src/routes/api/instances.$name.stop.ts +23 -0
- package/src/routes/api/instances.$name.ts +12 -0
- package/src/routes/api/instances.ts +16 -0
- package/src/start.ts +10 -0
- package/.output/server/_ssr/start-HYkvq4Ni.mjs +0 -4
- package/.output/server/_tanstack-start-manifest_v-B2chR8ef.mjs +0 -4
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
parseManagedInstanceShutdownMessage,
|
|
4
|
+
readManagedInstanceLaunch,
|
|
5
|
+
} from "../lib/managedInstance";
|
|
1
6
|
import { closeLogFinalizerWorkers, forceCloseLogFinalizerWorkers } from "./logFinalizer";
|
|
2
7
|
import { flushIndex } from "./logIndex";
|
|
3
8
|
import { flushApplicationLog, flushLogBuffer } from "./logger";
|
|
4
9
|
import { flushAllRawStreamCaptures } from "./rawStreamCapture";
|
|
5
10
|
import { setRuntimeShuttingDown } from "./runtimeHealth";
|
|
6
11
|
import { stopRuntimeAdmission, waitForRuntimeTrafficDrain } from "./runtimeAdmission";
|
|
7
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
createShutdownCoordinator,
|
|
14
|
+
createShutdownSignalHandler,
|
|
15
|
+
type ShutdownResult,
|
|
16
|
+
} from "./shutdownCoordinator";
|
|
8
17
|
import { destroyAllSessionProcesses } from "./sessionProcess";
|
|
9
18
|
import { flushSessionTasks } from "./sessionRuntime";
|
|
10
19
|
import { closeSqliteLogIndex } from "./sqliteLogIndex";
|
|
@@ -62,9 +71,72 @@ const runtimeShutdownCoordinator = createShutdownCoordinator(
|
|
|
62
71
|
);
|
|
63
72
|
|
|
64
73
|
let signalHandlersInstalled = false;
|
|
74
|
+
let managedInstanceHandlersInstalled = false;
|
|
75
|
+
|
|
76
|
+
export type ManagedRuntimeShutdownController = {
|
|
77
|
+
handleDisconnect: () => void;
|
|
78
|
+
handleMessage: (message: unknown) => void;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type ManagedRuntimeShutdownControllerOptions = {
|
|
82
|
+
controlToken: string;
|
|
83
|
+
shutdown: () => Promise<ShutdownResult>;
|
|
84
|
+
exit: (code: number) => void;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
function managedControlTokensMatch(received: string, expected: string): boolean {
|
|
88
|
+
if (received.length === 0 || expected.length === 0) return false;
|
|
89
|
+
const receivedDigest = createHash("sha256").update(received).digest();
|
|
90
|
+
const expectedDigest = createHash("sha256").update(expected).digest();
|
|
91
|
+
return timingSafeEqual(receivedDigest, expectedDigest);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function createManagedRuntimeShutdownController(
|
|
95
|
+
options: ManagedRuntimeShutdownControllerOptions,
|
|
96
|
+
): ManagedRuntimeShutdownController {
|
|
97
|
+
let shutdownRequested = false;
|
|
98
|
+
const requestShutdown = (): void => {
|
|
99
|
+
if (shutdownRequested) return;
|
|
100
|
+
shutdownRequested = true;
|
|
101
|
+
void options.shutdown().then(
|
|
102
|
+
(result) => options.exit(result.forced ? 1 : 0),
|
|
103
|
+
() => options.exit(1),
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
handleDisconnect: requestShutdown,
|
|
108
|
+
handleMessage: (message) => {
|
|
109
|
+
const parsed = parseManagedInstanceShutdownMessage(message);
|
|
110
|
+
if (
|
|
111
|
+
parsed === null ||
|
|
112
|
+
!managedControlTokensMatch(parsed.controlToken, options.controlToken)
|
|
113
|
+
) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
requestShutdown();
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Install lifecycle cleanup for the private supervisor/runtime IPC channel. */
|
|
122
|
+
export function installRuntimeManagedInstanceShutdownHandlers(): void {
|
|
123
|
+
if (managedInstanceHandlersInstalled) return;
|
|
124
|
+
const launchResult = readManagedInstanceLaunch(process.env);
|
|
125
|
+
if (launchResult.kind !== "managed") return;
|
|
126
|
+
managedInstanceHandlersInstalled = true;
|
|
127
|
+
const controller = createManagedRuntimeShutdownController({
|
|
128
|
+
controlToken: launchResult.launch.controlToken,
|
|
129
|
+
shutdown: async () => await runtimeShutdownCoordinator.shutdown("manual"),
|
|
130
|
+
exit: (code) => process.exit(code),
|
|
131
|
+
});
|
|
132
|
+
process.on("message", controller.handleMessage);
|
|
133
|
+
process.once("disconnect", controller.handleDisconnect);
|
|
134
|
+
if (process.connected === false) process.nextTick(controller.handleDisconnect);
|
|
135
|
+
}
|
|
65
136
|
|
|
66
137
|
/** Install once in the server runtime; the CLI supervisor owns its own public-ingress signals. */
|
|
67
138
|
export function installRuntimeShutdownSignalHandlers(): void {
|
|
139
|
+
installRuntimeManagedInstanceShutdownHandlers();
|
|
68
140
|
if (signalHandlersInstalled) return;
|
|
69
141
|
signalHandlersInstalled = true;
|
|
70
142
|
const handleSignal = createShutdownSignalHandler(runtimeShutdownCoordinator, (result) => {
|
package/src/proxy/sessionInfo.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SessionInfo, SessionLogSummary, SessionTokenUsage } from "../lib/sessionInfoContract";
|
|
2
|
-
import {
|
|
2
|
+
import { withBasePath } from "../lib/basePath";
|
|
3
|
+
import { getPublicBasePath } from "../lib/publicBasePathContext";
|
|
3
4
|
import { getSessionPath } from "../lib/sessionUrl";
|
|
4
5
|
import type { CapturedLog } from "./schemas";
|
|
5
6
|
import type { SessionSnapshot } from "./sessionSupervisor";
|
|
@@ -106,14 +107,14 @@ function buildAbsoluteUrl(baseUrl: string, path: string): string {
|
|
|
106
107
|
|
|
107
108
|
function buildApiPath(sessionId: string): string {
|
|
108
109
|
return buildRelativePath(
|
|
109
|
-
withBasePath("/api/sessions",
|
|
110
|
+
withBasePath("/api/sessions", getPublicBasePath()),
|
|
110
111
|
new URLSearchParams({ sessionId }),
|
|
111
112
|
);
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
function buildCompactLogsPath(sessionId: string): string {
|
|
115
116
|
return buildRelativePath(
|
|
116
|
-
withBasePath("/api/logs",
|
|
117
|
+
withBasePath("/api/logs", getPublicBasePath()),
|
|
117
118
|
new URLSearchParams({ compact: "1", sessionId }),
|
|
118
119
|
);
|
|
119
120
|
}
|
|
@@ -211,7 +212,7 @@ export function buildSessionInfo(input: BuildSessionInfoInput): SessionInfo {
|
|
|
211
212
|
const queuedTasks = input.snapshot?.queuedTasks ?? 0;
|
|
212
213
|
const runningTasks = input.snapshot?.runningTasks ?? 0;
|
|
213
214
|
const lastTaskError = normalizeString(input.snapshot?.lastTaskError);
|
|
214
|
-
const inspectorPath = getSessionPath(input.sessionId,
|
|
215
|
+
const inspectorPath = getSessionPath(input.sessionId, getPublicBasePath());
|
|
215
216
|
const apiPath = buildApiPath(input.sessionId);
|
|
216
217
|
const compactLogsPath = buildCompactLogsPath(input.sessionId);
|
|
217
218
|
const latestLogs = summaries.slice(0, latestLogLimit).map((summary, index) => ({
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type z } from "zod";
|
|
2
|
+
import type { InstanceLifecycleError, InstanceLifecycleResult } from "../../cli/instance";
|
|
3
|
+
import {
|
|
4
|
+
type InstancePublicErrorCode,
|
|
5
|
+
INSTANCE_API_SCHEMA_VERSION,
|
|
6
|
+
instanceErrorOutput,
|
|
7
|
+
} from "../../lib/instanceContract";
|
|
8
|
+
import { readManagedInstanceLaunch } from "../../lib/managedInstance";
|
|
9
|
+
|
|
10
|
+
const NO_STORE_HEADERS = { "cache-control": "no-store" };
|
|
11
|
+
|
|
12
|
+
type ParsedBody<T> = { ok: true; value: T } | { ok: false; response: Response };
|
|
13
|
+
|
|
14
|
+
function errorStatus(code: InstancePublicErrorCode): number {
|
|
15
|
+
switch (code) {
|
|
16
|
+
case "argument_invalid":
|
|
17
|
+
case "data_dir_invalid":
|
|
18
|
+
case "name_invalid":
|
|
19
|
+
case "port_invalid":
|
|
20
|
+
case "record_invalid":
|
|
21
|
+
return 400;
|
|
22
|
+
case "instance_not_found":
|
|
23
|
+
return 404;
|
|
24
|
+
case "config_mismatch":
|
|
25
|
+
case "data_dir_conflict":
|
|
26
|
+
case "identity_mismatch":
|
|
27
|
+
case "port_conflict":
|
|
28
|
+
case "self_lifecycle_unsupported":
|
|
29
|
+
return 409;
|
|
30
|
+
case "lock_not_owned":
|
|
31
|
+
case "lock_timeout":
|
|
32
|
+
return 423;
|
|
33
|
+
case "launch_failed":
|
|
34
|
+
case "launch_unavailable":
|
|
35
|
+
case "port_exhausted":
|
|
36
|
+
case "registry_io":
|
|
37
|
+
case "restart_failed_degraded":
|
|
38
|
+
case "restart_failed_rolled_back":
|
|
39
|
+
case "shutdown_failed":
|
|
40
|
+
return 503;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function instanceErrorResponse(error: InstanceLifecycleError): Response {
|
|
45
|
+
return Response.json(instanceErrorOutput(error), {
|
|
46
|
+
status: errorStatus(error.code),
|
|
47
|
+
headers: NO_STORE_HEADERS,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function instanceResultResponse<T>(
|
|
52
|
+
result: InstanceLifecycleResult<T>,
|
|
53
|
+
successStatus = 200,
|
|
54
|
+
): Response {
|
|
55
|
+
return result.kind === "error"
|
|
56
|
+
? instanceErrorResponse(result.error)
|
|
57
|
+
: Response.json(result.value, { status: successStatus, headers: NO_STORE_HEADERS });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function parseInstanceBody<T extends z.ZodType>(
|
|
61
|
+
request: Request,
|
|
62
|
+
schema: T,
|
|
63
|
+
): Promise<ParsedBody<z.output<T>>> {
|
|
64
|
+
let value: unknown;
|
|
65
|
+
try {
|
|
66
|
+
const text = await request.text();
|
|
67
|
+
value = text.trim().length === 0 ? {} : JSON.parse(text);
|
|
68
|
+
} catch {
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
response: instanceErrorResponse({
|
|
72
|
+
code: "argument_invalid",
|
|
73
|
+
message: "Request body must be valid JSON.",
|
|
74
|
+
retryable: false,
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const parsed = schema.safeParse(value);
|
|
79
|
+
if (!parsed.success) {
|
|
80
|
+
return {
|
|
81
|
+
ok: false,
|
|
82
|
+
response: instanceErrorResponse({
|
|
83
|
+
code: "argument_invalid",
|
|
84
|
+
message: `Invalid instance request: ${parsed.error.issues[0]?.message ?? "invalid body"}`,
|
|
85
|
+
retryable: false,
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return { ok: true, value: parsed.data };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function selfLifecycleError(rawName: string): InstanceLifecycleError | null {
|
|
93
|
+
const current = readManagedInstanceLaunch(process.env);
|
|
94
|
+
return current.kind === "managed" && current.launch.name.toLowerCase() === rawName.toLowerCase()
|
|
95
|
+
? {
|
|
96
|
+
code: "self_lifecycle_unsupported",
|
|
97
|
+
message:
|
|
98
|
+
"A managed runtime cannot stop or restart itself through its own REST/MCP transport; use the CLI or a different controller instance.",
|
|
99
|
+
retryable: false,
|
|
100
|
+
}
|
|
101
|
+
: null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function instanceListResponse(instances: readonly unknown[]): Response {
|
|
105
|
+
return Response.json(
|
|
106
|
+
{ schemaVersion: INSTANCE_API_SCHEMA_VERSION, instances },
|
|
107
|
+
{ headers: NO_STORE_HEADERS },
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import { getNamedInstanceConnection } from "../../cli/instance";
|
|
3
|
+
import { instanceResultResponse } from "./-instances";
|
|
4
|
+
|
|
5
|
+
export const Route = createFileRoute("/api/instances/$name/connection")({
|
|
6
|
+
server: {
|
|
7
|
+
handlers: {
|
|
8
|
+
GET: async ({ params }: { params: { name: string } }) =>
|
|
9
|
+
instanceResultResponse(await getNamedInstanceConnection(params.name)),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import { restartNamedInstance } from "../../cli/instance";
|
|
3
|
+
import { InstanceStartRequestSchema } from "../../lib/instanceContract";
|
|
4
|
+
import {
|
|
5
|
+
instanceErrorResponse,
|
|
6
|
+
instanceResultResponse,
|
|
7
|
+
parseInstanceBody,
|
|
8
|
+
selfLifecycleError,
|
|
9
|
+
} from "./-instances";
|
|
10
|
+
|
|
11
|
+
export const Route = createFileRoute("/api/instances/$name/restart")({
|
|
12
|
+
server: {
|
|
13
|
+
handlers: {
|
|
14
|
+
POST: async ({ params, request }: { params: { name: string }; request: Request }) => {
|
|
15
|
+
const body = await parseInstanceBody(request, InstanceStartRequestSchema);
|
|
16
|
+
if (!body.ok) return body.response;
|
|
17
|
+
const selfError = selfLifecycleError(params.name);
|
|
18
|
+
if (selfError !== null) return instanceErrorResponse(selfError);
|
|
19
|
+
return instanceResultResponse(await restartNamedInstance(params.name, body.value));
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import { startNamedInstance } from "../../cli/instance";
|
|
3
|
+
import { InstanceStartRequestSchema } from "../../lib/instanceContract";
|
|
4
|
+
import { instanceResultResponse, parseInstanceBody } from "./-instances";
|
|
5
|
+
|
|
6
|
+
export const Route = createFileRoute("/api/instances/$name/start")({
|
|
7
|
+
server: {
|
|
8
|
+
handlers: {
|
|
9
|
+
POST: async ({ params, request }: { params: { name: string }; request: Request }) => {
|
|
10
|
+
const body = await parseInstanceBody(request, InstanceStartRequestSchema);
|
|
11
|
+
if (!body.ok) return body.response;
|
|
12
|
+
const result = await startNamedInstance(params.name, body.value);
|
|
13
|
+
const status = result.kind === "success" && result.value.outcome === "created" ? 201 : 200;
|
|
14
|
+
return instanceResultResponse(result, status);
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import { stopNamedInstance } from "../../cli/instance";
|
|
3
|
+
import { InstanceEmptyRequestSchema } from "../../lib/instanceContract";
|
|
4
|
+
import {
|
|
5
|
+
instanceErrorResponse,
|
|
6
|
+
instanceResultResponse,
|
|
7
|
+
parseInstanceBody,
|
|
8
|
+
selfLifecycleError,
|
|
9
|
+
} from "./-instances";
|
|
10
|
+
|
|
11
|
+
export const Route = createFileRoute("/api/instances/$name/stop")({
|
|
12
|
+
server: {
|
|
13
|
+
handlers: {
|
|
14
|
+
POST: async ({ params, request }: { params: { name: string }; request: Request }) => {
|
|
15
|
+
const body = await parseInstanceBody(request, InstanceEmptyRequestSchema);
|
|
16
|
+
if (!body.ok) return body.response;
|
|
17
|
+
const selfError = selfLifecycleError(params.name);
|
|
18
|
+
if (selfError !== null) return instanceErrorResponse(selfError);
|
|
19
|
+
return instanceResultResponse(await stopNamedInstance(params.name));
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import { getNamedInstance } from "../../cli/instance";
|
|
3
|
+
import { instanceResultResponse } from "./-instances";
|
|
4
|
+
|
|
5
|
+
export const Route = createFileRoute("/api/instances/$name")({
|
|
6
|
+
server: {
|
|
7
|
+
handlers: {
|
|
8
|
+
GET: async ({ params }: { params: { name: string } }) =>
|
|
9
|
+
instanceResultResponse(await getNamedInstance(params.name)),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import { listNamedInstances } from "../../cli/instance";
|
|
3
|
+
import { instanceListResponse, instanceResultResponse } from "./-instances";
|
|
4
|
+
|
|
5
|
+
export const Route = createFileRoute("/api/instances")({
|
|
6
|
+
server: {
|
|
7
|
+
handlers: {
|
|
8
|
+
GET: async () => {
|
|
9
|
+
const result = await listNamedInstances();
|
|
10
|
+
return result.kind === "error"
|
|
11
|
+
? instanceResultResponse(result)
|
|
12
|
+
: instanceListResponse(result.value);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
package/src/start.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createMiddleware, createStart } from "@tanstack/react-start";
|
|
2
|
+
|
|
3
|
+
const publicBasePathMiddleware = createMiddleware().server(async ({ next, request }) => {
|
|
4
|
+
const { runWithRequestPublicBasePath } = await import("./lib/publicBasePathContext");
|
|
5
|
+
return runWithRequestPublicBasePath(request, () => next());
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const startInstance = createStart(() => ({
|
|
9
|
+
requestMiddleware: [publicBasePathMiddleware],
|
|
10
|
+
}));
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const tsrStartManifest = () => ({ routes: { __root__: { filePath: "C:/Users/claw/workspace/agent-inspector/src/routes/__root.tsx", children: ["/", "/livez", "/readyz", "/api/alerts", "/api/config", "/api/groups", "/api/health", "/api/logs", "/api/mcp", "/api/models", "/api/pi-agent", "/api/providers", "/api/runs", "/api/sessions", "/proxy/$", "/session/$sessionId", "/api/ecosystem/packages", "/api/ecosystem/tasks", "/api/knowledge/candidates", "/api/knowledge/project-context", "/api/knowledge/search", "/api/ecosystem/recipes/$recipeId/run", "/api/knowledge/sessions/$sessionId/candidates"], preloads: ["/assets/index-C6qZwYlR.js"], scripts: [{ attrs: { type: "module", async: true, src: "/assets/index-C6qZwYlR.js" } }] }, "/": { filePath: "C:/Users/claw/workspace/agent-inspector/src/routes/index.tsx", children: void 0, preloads: ["/assets/index-B2eoeT-Z.js", "/assets/index-CX7_rf7o.js", "/assets/ProxyViewerContainer-BhpIgfBi.js"] }, "/session/$sessionId": { filePath: "C:/Users/claw/workspace/agent-inspector/src/routes/session/$sessionId.tsx", children: void 0, preloads: ["/assets/_sessionId-CDhRgzf6.js", "/assets/_sessionId-mw3aA8Bp.js", "/assets/ProxyViewerContainer-BhpIgfBi.js"] } } });
|
|
2
|
-
export {
|
|
3
|
-
tsrStartManifest
|
|
4
|
-
};
|