diff --git a/packages/remote-protocol/README.md b/packages/remote-protocol/README.md index 1eeb79e97..127f1e65b 100644 --- a/packages/remote-protocol/README.md +++ b/packages/remote-protocol/README.md @@ -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. diff --git a/packages/remote-protocol/src/commands.ts b/packages/remote-protocol/src/commands.ts new file mode 100644 index 000000000..df98f943b --- /dev/null +++ b/packages/remote-protocol/src/commands.ts @@ -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: "compact" }, + { name: "review", argumentHint: "[instructions]" }, + { name: "init" }, + { name: "goal", argumentHint: "[|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 = new Set([ + "new", + "compact", + "fast", + "plan", + "default", + "review", + "init", + "goal", + "status", + "rename", + "fork", + "export", + "mcp", + "skills", +]); diff --git a/packages/remote-protocol/src/index.ts b/packages/remote-protocol/src/index.ts index 1f4e4c143..0f88669f8 100644 --- a/packages/remote-protocol/src/index.ts +++ b/packages/remote-protocol/src/index.ts @@ -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"; diff --git a/src/renderer/services/chat/codex/commands.ts b/src/renderer/services/chat/codex/commands.ts index a10452ee5..cb55450ad 100644 --- a/src/renderer/services/chat/codex/commands.ts +++ b/src/renderer/services/chat/codex/commands.ts @@ -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: "compact" }, - { name: "review", argumentHint: "[instructions]" }, - { name: "init" }, - { name: "goal", argumentHint: "[|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 = 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 ?? [])];