Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/ide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ The IDE opens in the **Agent** layout: chats with the person's own coding agents
- **Metric delta per turn (AF9, #274):** when the window has a project scene open, its metrics are read before each message and compared after the turn, once the scene has caught up with the files the turn changed; a short line under the turn ("Complexity max 9 -> 1, LOC -6") unfolds into the per-file detail. Without a scene, or when nothing moved, nothing is shown.
- **Installing agents (AF2, #267):** a missing preset shows *Install*, one the IDE installed shows its version with *Update* and *Remove* (Agents section of the Chats view, and the first-run guide). *Install* reads the npm registry, only then, and shows inline what would be installed: package and version, licence, unpacked size plus the dependencies' size for this platform, repository, publication date, the platform-specific native binaries npm will pick (Claude Code's SDK and Codex each bring one of roughly 400 MB) and which packages run install scripts. A native dialog in the main process, which the page cannot answer, repeats it with the exact npm command; only that starts the download. `src/main/agentSessions/agentInstaller.ts` (Electron-free, tested against a local fake registry and a fake npm) runs the **system npm** (`npm install --prefix <userData>/agent-packages --no-audit --no-fund --omit=dev --save-exact --ignore-scripts=false <pkg>@<version>`, Windows through the `node.exe` + `npm-cli.js` beside `npm.cmd`, never a shell) into a private package.json: nothing global, the person's own npm configuration, proxy and CA apply, and its output streams to a progress notification. Why npm rather than an own downloader: only npm resolves the dependency tree, optional platform packages and lifecycle scripts faithfully, and bundling it would add a large dependency; a missing npm gets a message pointing to nodejs.org. Once installed, the adapter runs on the IDE's own Electron as Node, so chats need no system Node. The registry is read through Electron's `net.fetch` (system proxy settings); the smoke run has no installer and checks that the call is refused.
- **First run (AF13, #278):** until the person skips it or has a chat, the editor area's welcome view carries a three-step guide (open a folder, pick an agent and install it or sign in, start the first chat), each step drawn from the window's real state and redrawn as it changes (`gettingStartedView.ts`, its model in `agentSetupModel.ts`). *Skip* or the first chat sets `codexr.agentFirst.onboarded` and it never opens on its own again; *Chat: Show Getting Started* reopens it as a tab (`guide:getting-started`).
- **Signing in (AF14, #297):** a terminal sign-in method runs the agent's login program directly, with no shell, in a terminal tab of its own (`TerminalHost.runProgram`, shown through `TerminalPanel.runTask`), so nothing is typed into the person's shell; the agent is checked again when it ends. *Check* asks the agent who is signed in with `auth/status` (an ACP draft that Claude Code's and Codex's adapters answer) and reports *Needs login* or *Signed in as ...*, because Claude Code opens sessions while signed out and only refuses the first prompt. Agents that cannot say are judged by `session/new`.
- **Importing an agent's chats (AF15, #298):** *Import chats* on a ready agent lists the chats it keeps for the open folder (`session/list`, newest first, at most 200, none already in the IDE) and adds the chosen ones; each reads its messages from the agent's `session/load` replay the first time it opens (`historyPending`), then continues the same agent session. The agent reads its own history files; the IDE never opens them.

## VS Code extensions (stream `ide-extensions`, epic #251)

Expand Down
24 changes: 24 additions & 0 deletions apps/ide/src/main/agentSessions/acpConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
type CreateTerminalRequest,
type CreateTerminalResponse,
type InitializeResponse,
type ListSessionsResponse,
type KillTerminalRequest,
type LoadSessionResponse,
type McpServer,
Expand Down Expand Up @@ -225,6 +226,24 @@ export class AcpConnection {
}));
}

/**
* #297: `auth/status` (an ACP draft that Claude Code and Codex answer when
* they advertise `agentCapabilities.auth.status`): whether the agent is
* signed in, and as whom. Unknown when the answer has another shape.
*/
async authStatus(): Promise<{ readonly state: 'authenticated' | 'unauthenticated' | 'unknown'; readonly account?: string }> {
const response = await this.explain(this.connection.agent.request<unknown>('auth/status', {}));
const record = response && typeof response === 'object' ? (response as Record<string, unknown>) : {};
const state = record['state'];
if (state !== 'authenticated' && state !== 'unauthenticated') {
return { state: 'unknown' };
}
const accounts = Array.isArray(record['accounts']) ? (record['accounts'] as unknown[]) : [];
const first = accounts.find((item): item is Record<string, unknown> => !!item && typeof item === 'object');
const label = first ? [first['email'], first['label']].find((value): value is string => typeof value === 'string' && value.trim() !== '') : undefined;
return label ? { state, account: label.slice(0, 200) } : { state };
}

authenticate(methodId: string): Promise<unknown> {
return this.explain(this.connection.agent.request(methods.agent.authenticate, { methodId }));
}
Expand All @@ -233,6 +252,11 @@ export class AcpConnection {
return this.explain(this.connection.agent.request(methods.agent.session.new, { cwd, mcpServers: [...mcpServers] }));
}

/** #298: one page of the agent's own history for `cwd` (ACP `session/list`). */
listSessions(cwd: string, cursor?: string): Promise<ListSessionsResponse> {
return this.explain(this.connection.agent.request(methods.agent.session.list, { cwd, ...(cursor ? { cursor } : {}) }));
}

loadSession(sessionId: string, cwd: string, mcpServers: readonly McpServer[]): Promise<LoadSessionResponse> {
return this.explain(this.connection.agent.request(methods.agent.session.load, { sessionId, cwd, mcpServers: [...mcpServers] }));
}
Expand Down
19 changes: 19 additions & 0 deletions apps/ide/src/main/agentSessions/agentCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,25 @@ function cmdQuote(part: string): string {
return /[\s&|<>^()]/.test(part) || part === '' ? `"${part}"` : part;
}

/**
* #297: the program a terminal login method runs, started directly in a
* terminal with no shell between. The `terminal-auth` hint names its own
* command; otherwise the agent's own launch runs with the method's arguments.
* A `cmd.exe /d /s /c "..."` launch (a custom agent's .cmd shim on Windows)
* cannot be passed to a terminal unchanged, so its login is refused with how
* to run it by hand.
*/
export function loginProgram(launch: AgentLaunch, spec: Pick<AuthMethodSpec, 'args' | 'command'>): { command: string; args: string[] } {
const extra = spec.args ?? [];
if (spec.command) {
return { command: spec.command, args: [...extra] };
}
if (launch.verbatimArguments) {
throw new Error(`Run this agent's login yourself in a terminal: its command with ${extra.join(' ') || 'its login arguments'}.`);
}
return { command: launch.command, args: [...launch.args, ...extra] };
}

export class AgentCatalog {
private readonly options: CatalogOptions;
private readonly probe: FileProbe;
Expand Down
Loading
Loading