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
1 change: 1 addition & 0 deletions packages/remote-protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Beside them:

- **The account key's bundle** (`account.ts`): the account key locked with the account password, as the server keeps it. See `ACCOUNT_KEYS.md`.
- **The voice socket** (`voice.ts`): audio to the server, text back while the user speaks.
- **Codex client commands** (`commands.ts`): the slash commands a Codex client runs itself (`CODEX_COMMANDS`: name, aliases, argument hint) and the ones another device may run (`CODEX_REMOTE_COMMANDS`).

Sealing is XChaCha20-Poly1305. The key is the room key, derived from the account key. The associated data comes from `aadOf()` and binds a message to its routing. What is sealed is an envelope (`SealedEnvelopeSchema`): the message, the sender's epoch and the receiver's. Each connection to the relay has a random epoch, which devices learn from each other's hellos in three steps. A device takes a message only when it names its epoch now, is addressed to it, and has a seq higher than the last it took from that sender's epoch, so the relay cannot send an old message again or pass one on to another device. `sealed.ts` has the rules. Protocol version 2 (0.7.0) brought these; devices of version 1 open nothing of version 2.

Expand Down
58 changes: 58 additions & 0 deletions packages/remote-protocol/src/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* The slash commands a Codex client runs itself. Codex's app-server leaves
* them to the client, so the desktop app and a remote device both need the
* same list: names, aliases and argument hints, nothing else.
*/

export interface CodexClientCommand {
name: string;
aliases?: string[];
argumentHint?: string;
}

/** Codex's slash commands the client handles, not the app-server. */
export const CODEX_COMMANDS: readonly CodexClientCommand[] = [
{ name: "model" },
{ name: "effort" },
{ name: "plan" },
{ name: "default" },
{ name: "fast", argumentHint: "[on|off|status]" },
{ name: "config", aliases: ["settings"] },
{ name: "new", aliases: ["clear"] },
{ name: "resume", argumentHint: "[search]" },
{ name: "fork" },
{ name: "rename", argumentHint: "<name>" },
{ name: "compact" },
{ name: "review", argumentHint: "[instructions]" },
{ name: "init" },
{ name: "goal", argumentHint: "[<objective>|clear|pause|resume]" },
{ name: "status" },
{ name: "context" },
{ name: "usage" },
{ name: "diff" },
{ name: "copy", argumentHint: "[N]" },
{ name: "export", argumentHint: "[filename]" },
{ name: "mcp" },
{ name: "skills" },
{ name: "logout" },
{ name: "help" },
{ name: "exit", aliases: ["quit"] },
];

/** Codex's client commands that another device may run, by name. */
export const CODEX_REMOTE_COMMANDS: ReadonlySet<string> = new Set([
"new",
"compact",
"fast",
"plan",
"default",
"review",
"init",
"goal",
"status",
"rename",
"fork",
"export",
"mcp",
"skills",
]);
4 changes: 3 additions & 1 deletion packages/remote-protocol/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
* - ./device-keys: each device's key, envelopes and rotation, pairing, and
* the password's proof (account keys v2);
* - ./voice: the voice socket, speech to text while the user speaks;
* - ./info: what the server offers (GET /info).
* - ./info: what the server offers (GET /info);
* - ./commands: the slash commands a Codex client runs itself.
*/
export * from "./account.js";
export * from "./commands.js";
export * from "./device-keys.js";
export * from "./info.js";
export * from "./relay.js";
Expand Down
51 changes: 6 additions & 45 deletions src/renderer/services/chat/codex/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,17 @@
// tab's own views. Codex's terminal-only ones (theme, keymap, vim, pets,
// statusline…) are left out. Pure, for the tab and its tests.

import {
CODEX_COMMANDS,
CODEX_REMOTE_COMMANDS,
} from "../../../../../packages/remote-protocol/src/commands";
import { type AppCommand, code, type Words } from "../app-commands";
import type { CommandInfo } from "../model";
import { collaborationModeOf } from "./collaboration";
import type { CodexModel } from "./model";

export const CODEX_COMMANDS: readonly AppCommand[] = [
{ name: "model" },
{ name: "effort" },
{ name: "plan" },
{ name: "default" },
{ name: "fast", argumentHint: "[on|off|status]" },
{ name: "config", aliases: ["settings"] },
{ name: "new", aliases: ["clear"] },
{ name: "resume", argumentHint: "[search]" },
{ name: "fork" },
{ name: "rename", argumentHint: "<name>" },
{ name: "compact" },
{ name: "review", argumentHint: "[instructions]" },
{ name: "init" },
{ name: "goal", argumentHint: "[<objective>|clear|pause|resume]" },
{ name: "status" },
{ name: "context" },
{ name: "usage" },
{ name: "diff" },
{ name: "copy", argumentHint: "[N]" },
{ name: "export", argumentHint: "[filename]" },
{ name: "mcp" },
{ name: "skills" },
{ name: "logout" },
{ name: "help" },
{ name: "exit", aliases: ["quit"] },
];

/** Codex's commands the app runs that another device may run. */
export const CODEX_REMOTE_COMMANDS: ReadonlySet<string> = new Set([
"new",
"compact",
"fast",
"plan",
"default",
"review",
"init",
"goal",
"status",
"rename",
"fork",
"export",
"mcp",
"skills",
]);
// The list lives in the protocol package, which the mobile app shares.
export { CODEX_COMMANDS, CODEX_REMOTE_COMMANDS };

function namesOf(command: AppCommand): string[] {
return [command.name, ...(command.aliases ?? [])];
Expand Down