Skip to content

Commit f3d9b64

Browse files
committed
fix: remove dead code
1 parent b5771e8 commit f3d9b64

11 files changed

Lines changed: 23 additions & 54 deletions

File tree

src/cli/operations/dev/web-ui/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ agent name and error message:
9191

9292
Errors are cleared when the agent is successfully started again via `POST /api/start`.
9393

94-
In invoke mode, all agents appear in `running` with `port: 0` (they're deployed remotely) and `errors` is always empty.
95-
9694
The agent list is kept in sync with `agentcore.json` via `fs.watch` — if you add or remove an agent in another terminal,
9795
the status endpoint reflects the change without restarting the dev server.
9896

@@ -171,8 +169,7 @@ Error:
171169
### `POST /invocations`
172170

173171
Proxies a chat invocation to the selected running agent. The `agentName` field routes to the correct agent; falls back
174-
to the first running agent if omitted. In invoke mode, delegates to the custom invocation handler (calls deployed
175-
runtime).
172+
to the first running agent if omitted.
176173

177174
Request:
178175

@@ -182,7 +179,7 @@ Request:
182179

183180
### `GET /api/traces?agentName=xxx[&startTime=ms&endTime=ms]`
184181

185-
Lists recent traces for a deployed agent. Only available in invoke mode.
182+
Lists recent traces for an agent. Available when the OTEL collector is active.
186183

187184
Query parameters:
188185

@@ -198,7 +195,7 @@ Response:
198195

199196
### `GET /api/traces/:traceId?agentName=xxx[&startTime=ms&endTime=ms]`
200197

201-
Returns full trace data (spans) for a specific trace. Only available in invoke mode.
198+
Returns full trace data (spans) for a specific trace. Available when the OTEL collector is active.
202199

203200
Query parameters:
204201

@@ -214,7 +211,7 @@ Response:
214211

215212
### `GET /api/memory?memoryName=xxx&namespace=yyy[&strategyId=zzz]`
216213

217-
Lists memory records for a given memory and namespace. Only available in invoke mode.
214+
Lists memory records for a given memory and namespace. Requires a deployed memory with `onListMemoryRecords` handler.
218215

219216
Response:
220217

@@ -224,7 +221,7 @@ Response:
224221

225222
### `POST /api/memory/search`
226223

227-
Performs semantic search across memory records. Only available in invoke mode.
224+
Performs semantic search across memory records. Requires a deployed memory with `onRetrieveMemoryRecords` handler.
228225

229226
Request:
230227

src/cli/operations/dev/web-ui/api-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface StatusAgent {
3232
/** Running agent entry in the status response */
3333
export interface StatusRunningAgent {
3434
name: string;
35-
/** Port the agent is listening on. 0 in invoke mode (agents are remote). */
35+
/** Port the agent is listening on. */
3636
port: number;
3737
}
3838

src/cli/operations/dev/web-ui/handlers/invocations.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ let a2aRequestId = 1;
88
/**
99
* POST /invocations — proxy to the selected agent.
1010
* Body must include agentName to route to the correct running agent.
11-
* When onInvoke is provided, delegates entirely to the custom handler (e.g. for deployed agent invocation).
1211
*/
1312
export async function handleInvocations(
1413
ctx: RouteContext,
@@ -18,14 +17,6 @@ export async function handleInvocations(
1817
): Promise<void> {
1918
const body = await ctx.readBody(req);
2019

21-
// Delegate to custom invocation handler if provided (e.g. invoke mode — calls deployed runtime)
22-
if (ctx.options.onInvoke) {
23-
const setCors = () => ctx.setCorsHeaders(res, origin);
24-
await ctx.options.onInvoke(body, res, setCors);
25-
return;
26-
}
27-
28-
// Default dev mode: proxy to local agent server
2920
let agentPort: number | undefined;
3021
let agentName: string | undefined;
3122
let agentProtocol: string | undefined;

src/cli/operations/dev/web-ui/handlers/memory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
44

55
/**
66
* GET /api/memory?memoryName=xxx&namespace=yyy[&strategyId=zzz]
7-
* Lists memory records. Requires onListMemoryRecords handler (invoke mode only).
7+
* Lists memory records. Requires onListMemoryRecords handler.
88
*/
99
export async function handleListMemoryRecords(
1010
ctx: RouteContext,
@@ -15,7 +15,7 @@ export async function handleListMemoryRecords(
1515
if (!ctx.options.onListMemoryRecords) {
1616
ctx.setCorsHeaders(res, origin);
1717
res.writeHead(404, { 'Content-Type': 'application/json' });
18-
res.end(JSON.stringify({ success: false, error: 'Memory browsing is only available in invoke mode' }));
18+
res.end(JSON.stringify({ success: false, error: 'Memory browsing is not available' }));
1919
return;
2020
}
2121

@@ -54,7 +54,7 @@ export async function handleListMemoryRecords(
5454
/**
5555
* POST /api/memory/search — semantic search across memory records.
5656
* Body: { memoryName, namespace, searchQuery, strategyId? }
57-
* Requires onRetrieveMemoryRecords handler (invoke mode only).
57+
* Requires onRetrieveMemoryRecords handler.
5858
*/
5959
export async function handleRetrieveMemoryRecords(
6060
ctx: RouteContext,
@@ -65,7 +65,7 @@ export async function handleRetrieveMemoryRecords(
6565
if (!ctx.options.onRetrieveMemoryRecords) {
6666
ctx.setCorsHeaders(res, origin);
6767
res.writeHead(404, { 'Content-Type': 'application/json' });
68-
res.end(JSON.stringify({ success: false, error: 'Memory search is only available in invoke mode' }));
68+
res.end(JSON.stringify({ success: false, error: 'Memory search is not available' }));
6969
return;
7070
}
7171

src/cli/operations/dev/web-ui/handlers/start.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function handleStart(
2929
return;
3030
}
3131

32-
// Delegate to custom start handler if provided (e.g. invoke mode — agents are already deployed)
32+
// Delegate to custom start handler if provided
3333
if (ctx.options.onStart) {
3434
const result = await ctx.options.onStart(agentName);
3535
ctx.setCorsHeaders(res, origin);

src/cli/operations/dev/web-ui/handlers/status.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,8 @@ export function handleStatus(ctx: RouteContext, res: ServerResponse, origin?: st
77
const { agents } = ctx.options;
88
const running: StatusRunningAgent[] = [];
99

10-
if (ctx.options.onInvoke) {
11-
// Invoke mode: all agents are always "running" (deployed remotely)
12-
for (const agent of agents) {
13-
running.push({ name: agent.name, port: 0 });
14-
}
15-
} else {
16-
// Dev mode: only locally started agents are running
17-
for (const [name, { port }] of ctx.runningAgents) {
18-
running.push({ name, port });
19-
}
10+
for (const [name, { port }] of ctx.runningAgents) {
11+
running.push({ name, port });
2012
}
2113

2214
// Collect per-agent errors

src/cli/operations/dev/web-ui/handlers/traces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
44

55
/**
66
* GET /api/traces?agentName=xxx — list recent traces.
7-
* In dev mode this returns local OTEL traces; in invoke mode it returns CloudWatch traces.
7+
* Returns local OTEL traces when the collector is active.
88
*/
99
export async function handleListTraces(
1010
ctx: RouteContext,
@@ -58,7 +58,7 @@ export async function handleListTraces(
5858

5959
/**
6060
* GET /api/traces/:traceId?agentName=xxx — get full trace data.
61-
* In dev mode this returns local OTEL traces; in invoke mode it returns CloudWatch traces.
61+
* Returns local OTEL trace spans and logs when the collector is active.
6262
*/
6363
export async function handleGetTrace(
6464
ctx: RouteContext,

src/cli/operations/dev/web-ui/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export {
22
WebUIServer,
33
type WebUIOptions,
44
type StartHandler,
5-
type InvocationHandler,
65
type ListTracesHandler,
76
type GetTraceHandler,
87
type ListMemoryRecordsHandler,

src/cli/operations/dev/web-ui/run-web-ui.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import { spawn } from 'child_process';
77
export interface RunWebUIOptions {
88
/** Options to pass to WebUIServer (minus uiPort, which is resolved automatically) */
99
serverOptions: Omit<WebUIOptions, 'uiPort' | 'onReady' | 'onLog'>;
10-
/** Logger command label (e.g. 'dev' or 'invoke') */
10+
/** Logger command label (e.g. 'dev') */
1111
logLabel: string;
1212
/** Optional log handler override. Defaults to console logging errors. */
1313
onLog?: (level: 'info' | 'warn' | 'error', message: string) => void;
1414
}
1515

1616
/**
17-
* Shared entry point for launching the web UI in both dev and invoke modes.
17+
* Shared entry point for launching the web UI.
1818
* Handles port discovery, logger setup, browser launch, SIGINT, and keep-alive.
1919
*/
2020
export async function runWebUI(opts: RunWebUIOptions): Promise<void> {

src/cli/operations/dev/web-ui/web-server.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ export type StartHandler = (
5656
agentName: string
5757
) => Promise<{ success: boolean; name: string; port: number; error?: string }>;
5858

59-
/**
60-
* Custom handler for POST /invocations.
61-
* Receives the parsed request body and the raw ServerResponse so it can stream.
62-
* Must write headers and end the response itself.
63-
*/
64-
export type InvocationHandler = (body: string, res: ServerResponse, setCors: () => void) => Promise<void>;
65-
6659
/**
6760
* Custom handler for GET /api/traces.
6861
* Returns a list of recent traces for the given agent.
@@ -106,8 +99,8 @@ export type RetrieveMemoryRecordsHandler = (
10699
) => Promise<{ success: boolean; records?: unknown[]; error?: string }>;
107100

108101
export interface WebUIOptions {
109-
/** Whether this server is running in dev or invoke mode */
110-
mode: 'dev' | 'invoke';
102+
/** Server mode identifier (currently only 'dev' is used) */
103+
mode: 'dev';
111104
/** Port for the web UI server (API proxy) */
112105
uiPort: number;
113106
/** Available agents (metadata only — servers are started on demand) */
@@ -126,15 +119,13 @@ export interface WebUIOptions {
126119
onLog?: (level: 'info' | 'warn' | 'error', message: string) => void;
127120
/** Custom start handler — overrides the default dev server start logic */
128121
onStart?: StartHandler;
129-
/** Custom invocation handler — overrides the default local proxy logic */
130-
onInvoke?: InvocationHandler;
131-
/** Custom handler for listing traces (local OTEL in dev mode, CloudWatch in invoke mode) */
122+
/** Custom handler for listing traces */
132123
onListTraces?: ListTracesHandler;
133-
/** Custom handler for getting a single trace (local OTEL in dev mode, CloudWatch in invoke mode) */
124+
/** Custom handler for getting a single trace */
134125
onGetTrace?: GetTraceHandler;
135-
/** Custom handler for listing memory records — only available in invoke mode */
126+
/** Custom handler for listing memory records */
136127
onListMemoryRecords?: ListMemoryRecordsHandler;
137-
/** Custom handler for searching memory records — only available in invoke mode */
128+
/** Custom handler for searching memory records */
138129
onRetrieveMemoryRecords?: RetrieveMemoryRecordsHandler;
139130
/** Agent to pre-select in the UI dropdown (set when --runtime is specified) */
140131
selectedAgent?: string;

0 commit comments

Comments
 (0)