You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deprecate CLI standalone experience and adopt full client/server model for this client (#2199)
**Deprecate standalone CLI experience**
This PR removes the standalone (in-process) CLI mode and makes the CLI
exclusively a thin client over the agent server via WebSocket RPC.
Starting the CLI alone will automatically trigger agent-server startup
in a new window (or connect to an existing one if it exists). It also
adds server lifecycle management features to make the server-first model
ergonomic.
**Key changes**
**Remove standalone interactive command**
- Deleted
[ts/packages/cli/src/commands/interactive.ts](vscode-webview://1o48rp7rdr60cpilngp5dms8tvlq1h8f0158a5o23usnfvp78ej7/ts/packages/cli/src/commands/interactive.ts)
(231 lines), which created a full in-process dispatcher. Users now
always go through the agent server via connect.
**Improve server spawn behavior (connect command)**
- --hidden: spawns the agent server without a visible window (background
mode on Windows via windowsHide; visible window is now the default so
users can see server output).
- --idle-timeout <seconds>: instructs the server to shut itself down
after N seconds with no connected clients, enabling ephemeral/scripted
use cases.
- --memory: starts an ephemeral session that is automatically deleted on
exit.
**Server-side idle shutdown**
-
[ts/packages/agentServer/server/src/server.ts](vscode-webview://1o48rp7rdr60cpilngp5dms8tvlq1h8f0158a5o23usnfvp78ej7/ts/packages/agentServer/server/src/server.ts):
tracks active connection count and schedules a setTimeout shutdown when
it drops to zero (if --idle-timeout is set).
**New CLI server subcommands**
- server status
([ts/packages/cli/src/commands/server/status.ts](vscode-webview://1o48rp7rdr60cpilngp5dms8tvlq1h8f0158a5o23usnfvp78ej7/ts/packages/cli/src/commands/server/status.ts)):
checks whether the agent server is running on a given port.
- server stop
([ts/packages/cli/src/commands/server/stop.ts](vscode-webview://1o48rp7rdr60cpilngp5dms8tvlq1h8f0158a5o23usnfvp78ej7/ts/packages/cli/src/commands/server/stop.ts)):
gracefully stops the running agent server.
**Client API improvements**
- isServerRunning is now exported from the client package for use by CLI
subcommands.
- ensureAgentServer / spawnAgentServer accept hidden and idleTimeout
parameters.
- Windows spawn path now tries PowerShell 7 (pwsh.exe at full path)
before falling back to powershell.exe.
<img width="399" height="195" alt="image"
src="https://github.com/user-attachments/assets/57bd6537-127b-4266-a6f6-d45345ee8cd9"
/>
<img width="449" height="143" alt="image"
src="https://github.com/user-attachments/assets/83009f20-cf91-4e58-ac52-5469a9015fa0"
/>
Copy file name to clipboardExpand all lines: ts/README.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,7 @@ Also, you can go to the shell directory `./packages/shell` and start from there.
175
175
[TypeAgent CLI](./packages/cli) provides a console based _interactive agents_ with _natural language interfaces_ experience. Additional console command is available to explore different part of TypeAgent functionalities.
176
176
177
177
- Run `pnpm run cli` to get the available command
178
-
- Run `pnpm run cli -- interactive` will start the interactive prompt
178
+
- Run `pnpm run cli -- connect` will start the interactive prompt (connecting to the agent server via WebSocket RPC)
179
179
180
180
Also, you can go to the CLI directory `./packages/cli` and start from there. Please see instruction in TypeAgent CLI's [README.md](./packages/cli/README.md) for more options and detail.
181
181
@@ -277,13 +277,13 @@ If you open this directory as a workspace in VSCode, multiple launch task is def
- CLI (dev) connect - `./package/cli/bin/dev.js connect` with a new command prompt
282
+
- CLI (dev) connect[Integrated Terminal] - `./bin/dev.js connect` using VSCode terminal (needed for WSL)
283
283
284
284
#### Attaching to running sessions
285
285
286
-
To attaching to an existing session with TypeAgent CLI's interactive mode or TypeAgent Shell, you can start inspector by issuing the command `@debug` and use the VSCode `Attach` debugger launch task to attach.
286
+
To attaching to an existing session with TypeAgent CLI's connect mode or TypeAgent Shell, you can start inspector by issuing the command `@debug` and use the VSCode `Attach` debugger launch task to attach.
287
287
288
288
#### TypeAgent Shell Browser Process
289
289
@@ -298,7 +298,7 @@ The project uses [debug](https://www.npmjs.com/package/debug) package to enable
298
298
For example (in Linux), to trace the GPT prompt that get sent when running the interactive CLI.
**Option 2**: In the shell or CLI's interactive mode, you can issue the command `@trace <pattern>` to add to the list of namespace. Use "-" or "-\*" to disable all the trace.
Copy file name to clipboardExpand all lines: ts/docs/architecture/agentServerSessions.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -357,6 +357,7 @@ agent-cli connect # connect to the 'CLI' session (created
357
357
agent-cli connect --resume # resume the last used session
358
358
agent-cli connect --session <id># connect to a specific session by ID
359
359
agent-cli connect --port <port># connect to a server on a non-default port (default: 8999)
360
+
agent-cli connect --hidden # start the server hidden (no visible window)
360
361
```
361
362
362
363
By default (no flags), `connect` targets a session named `"CLI"`. It calls `listSessions("CLI")` and joins the first match, or calls `createSession("CLI")` if none exists.
@@ -365,8 +366,21 @@ Pass `--resume` / `-r` to instead resume the last used session, whose ID is pers
365
366
366
367
Pass `--session` / `-s <id>` to connect to a specific session by UUID. This takes priority over `--resume` if both are provided; errors propagate as-is without the recovery prompt.
367
368
369
+
Pass `--hidden` to start the agent server without a visible window. Default is a visible window for interactive use.
370
+
368
371
On every successful connection the connected session ID is written to `~/.typeagent/cli-state.json` for use by future `--resume` invocations.
369
372
373
+
#### `run` — non-interactive commands
374
+
375
+
`agent-cli run request`, `run translate`, and `run explain` each accept `--session <id>` / `-s` to target a specific session. If omitted, they use the find-or-create `"CLI"` session. The server is started hidden by default for non-interactive commands; use `--show` to get a visible window.
376
+
377
+
#### `server` — manage the server process
378
+
379
+
```bash
380
+
agent-cli server status # show whether the server is running
381
+
agent-cli server stop # send a graceful shutdown to the running server
├─ Send joinSession({ clientType, filter }) on agent-server channel
118
+
├─ Send joinSession({ sessionId, clientType, filter }) on agent-server channel
116
119
│ └─ Server assigns connectionId, returns { connectionId, sessionId }
117
120
│
118
-
└─ Return Dispatcher RPC proxy to caller
121
+
└─ Return AgentServerConnection (call .joinSession() to get a Dispatcher proxy)
119
122
```
120
123
121
124
On disconnect, the server removes all of that connection's sessions from its routing table.
@@ -142,10 +145,29 @@ Chat UI (renderer) ↔ IPC ↔ Main process ↔ WebSocket ↔ agentServer
142
145
143
146
## CLI integration
144
147
145
-
The CLI ([`packages/cli/src/commands/connect.ts`](../cli/src/commands/connect.ts)) always uses remote connection. It calls `ensureAndConnectDispatcher()`, which auto-spawns the server if not already running, then enters an interactive readline loop.
148
+
The CLI ([`packages/cli/`](../cli/)) always uses remote connection via WebSocket.
`connect` calls `ensureAgentServer(port, hidden, idleTimeout)` to auto-spawn the server if needed, then calls `connectAgentServer()` and `joinSession()` directly. By default the spawned server window is visible; pass `--hidden` to suppress it. Pass `--idle-timeout <seconds>` to enable idle shutdown when spawning (default: `0`, server stays alive indefinitely).
157
+
158
+
### `agent-cli run` (non-interactive)
159
+
160
+
The `run request`, `run translate`, and `run explain` subcommands also call `ensureAgentServer()` — but default to **hidden** (no window), with `--show` to opt into a visible window. All three support `--session <id>` to target a specific session instead of the default `"CLI"` session. When spawning, passes `--idle-timeout 600` so the server exits 10 minutes after the last client disconnects.
161
+
162
+
### `agent-cli replay`
163
+
164
+
`replay` always creates an ephemeral session (`cli-replay-<uuid>`) and deletes it on exit. Defaults to hidden; `--show` to opt in. Also passes `--idle-timeout 600` when spawning.
165
+
166
+
### `agent-cli server`
167
+
168
+
```bash
169
+
agent-cli server status # check whether the server is running
170
+
agent-cli server stop # send a graceful shutdown via RPC
149
171
```
150
172
151
173
---
@@ -161,17 +183,18 @@ Shell launches → createDispatcher() in-process → no server involved
Convenience wrapper that auto-spawns the server if needed and joins a session, returning a `Dispatcher` directly. Prefer calling `ensureAgentServer()` + `connectAgentServer()` + `joinSession()` separately for full control.
Backward-compatible wrapper: connects and immediately joins a session, returning a `Dispatcher`. Use `connectAgentServer()` for full multi-session support.
0 commit comments