The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.
Desktop: share agent names and installation links (#97)
taavie-z6dd91c4f22fc
diff --git a/.changeset/desktop-agent-definitions.md b/.changeset/desktop-agent-definitions.mdnew file mode 100644index 0000000..3c0ac48--- /dev/null+++ b/.changeset/desktop-agent-definitions.md@@ -0,0 +1,5 @@+---+"@openfilm/desktop": patch+---++Keep desktop agent names and installation links in one list so Chat and installation discovery stay consistent, preserving existing agent behavior.diff --git a/apps/desktop/chat/src/components/ProjectConversation.tsx b/apps/desktop/chat/src/components/ProjectConversation.tsxindex 87d41f0..67cd4b1 100644--- a/apps/desktop/chat/src/components/ProjectConversation.tsx+++ b/apps/desktop/chat/src/components/ProjectConversation.tsx@@ -1,6 +1,7 @@'use client';import React from 'react';+import { AGENT_DEFINITIONS, isAgentId } from '../../../src/agent-definitions.mjs';import type { PublicProgressSnapshot, TurnAttachment } from '@openfilm/shared';import { BellRing, Check, ChevronRight, Copy } from 'lucide-react';import { AgentActivityList, formatWorkDuration, StatusLine, type AgentActivityItem } from './AgentActivityRow';@@ -618,11 +619,6 @@ function WorkSummary({ items, durationMs }: { items: AgentActivityItem[]; durati);}-const AGENT_NAMES: Record<string, string> = {- codex: 'Codex', claude: 'Claude Code', copilot: 'GitHub Copilot', cursor: 'Cursor', opencode: 'OpenCode',- codebuddy: 'CodeBuddy', qwen: 'Qwen Code', kimi: 'Kimi', minimax: 'MiniMax Code',-};-/** The hover-only line: transparent but keeping its space (nothing jumps as the mouse moves); always shown on devices without hover. *//* Kept visible by keyboard focus only (:focus-visible): after a click on copy the focus stays on the button,and with focus-within the line would never hide again. */@@ -689,7 +685,7 @@ function TurnFooter({ entry, items, running = false }: { entry: ProjectVersion;{entry.agent ? (<span className="flex min-w-0 items-center gap-1.5">{/* the icon says which agent (its name on hover); written out it would only repeat it */}- <span className="flex w-3.5 shrink-0 justify-center opacity-80" title={entry.agent === 'byok' ? t('composer.agentOwnKey') : AGENT_NAMES[entry.agent] ?? entry.agent}>+ <span className="flex w-3.5 shrink-0 justify-center opacity-80" title={entry.agent === 'byok' ? t('composer.agentOwnKey') : isAgentId(entry.agent) ? AGENT_DEFINITIONS[entry.agent].name : entry.agent}>{hasAgentIcon(entry.agent)? <AgentIcon id={entry.agent} size={12} />: <BrandLogo size={11} />}diff --git a/apps/desktop/chat/src/state/local-agent-store.ts b/apps/desktop/chat/src/state/local-agent-store.tsindex 0ae27bf..569aef9 100644--- a/apps/desktop/chat/src/state/local-agent-store.ts+++ b/apps/desktop/chat/src/state/local-agent-store.ts@@ -10,6 +10,7 @@* first message (the list only comes with a session).*/import { create } from 'zustand';+import { isAgentId as isAgent } from '../../../src/agent-definitions.mjs';import {desktopBridge,type LocalAgentId,@@ -22,9 +23,6 @@ export type AgentPick = LocalAgentId;type ConfigOptions = NonNullable<LocalAgentSessionInfo['configOptions']>;-const AGENT_IDS: readonly LocalAgentId[] = ['codex', 'claude', 'copilot', 'cursor', 'opencode', 'codebuddy', 'qwen', 'kimi', 'minimax', 'byok'];-const isAgent = (v: unknown): v is LocalAgentId => AGENT_IDS.includes(v as LocalAgentId);-interface Persisted {picked: LocalAgentId;prefs: Partial<Record<LocalAgentId, Record<string, unknown>>>;diff --git a/apps/desktop/chat/tsconfig.json b/apps/desktop/chat/tsconfig.jsonindex 74ccbb1..f3a24e8 100644--- a/apps/desktop/chat/tsconfig.json+++ b/apps/desktop/chat/tsconfig.json@@ -12,6 +12,7 @@"strict": true,"noEmit": true,"skipLibCheck": true,+ "allowJs": true,"noUnusedLocals": false,"noUnusedParameters": false,"types": [diff --git a/apps/desktop/src/agent-definitions.mjs b/apps/desktop/src/agent-definitions.mjsnew file mode 100644index 0000000..79efdc7--- /dev/null+++ b/apps/desktop/src/agent-definitions.mjs@@ -0,0 +1,30 @@+// @ts-check+/** Desktop metadata only; discovery, launch and sign-in behavior stay in their existing modules. */+/** @satisfies {Record<string, { name: string, install: `https://${string}` | null }>} */+const definitions = {+ codex: { name: 'Codex', install: 'https://developers.openai.com/codex' },+ claude: { name: 'Claude Code', install: 'https://claude.com/download' },+ copilot: { name: 'GitHub Copilot', install: 'https://github.com/features/copilot/cli' },+ cursor: { name: 'Cursor', install: 'https://cursor.com/cli' },+ opencode: { name: 'OpenCode', install: 'https://opencode.ai/download' },+ codebuddy: { name: 'CodeBuddy', install: 'https://www.codebuddy.cn/docs/cli/installation' },+ qwen: { name: 'Qwen Code', install: 'https://github.com/QwenLM/qwen-code' },+ kimi: { name: 'Kimi', install: 'https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html' },+ minimax: { name: 'MiniMax Code', install: 'https://www.npmjs.com/package/@minimax-ai/code' },+ byok: { name: 'Own key', install: null },+};++/** @type {Readonly<{ [Id in keyof typeof definitions]: Readonly<typeof definitions[Id]> }>} */+export const AGENT_DEFINITIONS = Object.freeze(definitions);+/** @typedef {keyof typeof AGENT_DEFINITIONS} AgentId */++export const AGENT_IDS = Object.freeze(/** @type {AgentId[]} */ (Object.keys(AGENT_DEFINITIONS)));+export const OWN_AGENT_IDS = Object.freeze(AGENT_IDS.filter((id) => id !== 'byok'));++/** All desktop choices, including own key; safe for persisted data and unknown historical ids.+ * @param {unknown} value+ * @returns {value is AgentId}+ */+export function isAgentId(value) {+ return typeof value === 'string' && Object.hasOwn(AGENT_DEFINITIONS, value);+}diff --git a/apps/desktop/src/agent-definitions.test.mjs b/apps/desktop/src/agent-definitions.test.mjsnew file mode 100644index 0000000..f6a9e8c--- /dev/null+++ b/apps/desktop/src/agent-definitions.test.mjs@@ -0,0 +1,34 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { AGENT_DEFINITIONS, AGENT_IDS, OWN_AGENT_IDS, isAgentId } from './agent-definitions.mjs';+import { AGENTS } from './agents.mjs';+import { AGENT_PROGRAMS, AGENT_DOWNLOADS } from './agent-installation.mjs';+import { AGENT_IDS as rosterIds, AGENT_NAMES as rosterNames } from './agent-roster.mjs';++test('the desktop definitions cover exactly the existing launchers and discovery programs', () => {+ const own = [...OWN_AGENT_IDS].sort();+ assert.deepEqual(own, Object.keys(AGENTS).sort());+ assert.deepEqual(own, Object.keys(AGENT_PROGRAMS).sort());+ assert.deepEqual(own, Object.keys(AGENT_DOWNLOADS).sort());+ assert.deepEqual(AGENT_IDS, [...OWN_AGENT_IDS, 'byok']);+ for (const id of OWN_AGENT_IDS) {+ assert.equal(AGENT_DEFINITIONS[id].name, AGENTS[id].label);+ assert.equal(AGENT_DEFINITIONS[id].name, rosterNames[id]);+ assert.equal(AGENT_DEFINITIONS[id].install, AGENT_DOWNLOADS[id]);+ assert.equal(new URL(AGENT_DOWNLOADS[id]).protocol, 'https:');+ }+ assert.equal(AGENT_DEFINITIONS.byok.install, null);+});++test('the roster and installation API keep their existing metadata exports', () => {+ assert.equal(rosterIds, AGENT_IDS);+ assert.deepEqual(Object.keys(rosterNames), AGENT_IDS);+ assert.equal(rosterNames.byok, 'Own key');+});++test('agent id validation accepts own key and rejects unknown ids and inherited properties', () => {+ for (const id of AGENT_IDS) assert.equal(isAgentId(id), true);+ for (const value of [null, undefined, 0, {}, [], new String('codex'), '', 'unknown', 'Codex', '__proto__', 'constructor', 'toString']) {+ assert.equal(isAgentId(value), false);+ }+});diff --git a/apps/desktop/src/agent-installation.mjs b/apps/desktop/src/agent-installation.mjsindex 8c799de..15312d5 100644--- a/apps/desktop/src/agent-installation.mjs+++ b/apps/desktop/src/agent-installation.mjs@@ -10,17 +10,8 @@ import { accessSync, closeSync, constants, lstatSync, openSync, readFileSync, reimport { homedir } from 'node:os';import { delimiter, dirname, isAbsolute, join } from 'node:path';-export const AGENT_DOWNLOADS = Object.freeze({- claude: 'https://claude.com/download',- codex: 'https://developers.openai.com/codex',- copilot: 'https://github.com/features/copilot/cli',- cursor: 'https://cursor.com/cli',- opencode: 'https://opencode.ai/download',- codebuddy: 'https://www.codebuddy.cn/docs/cli/installation',- qwen: 'https://github.com/QwenLM/qwen-code',- kimi: 'https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html',- minimax: 'https://www.npmjs.com/package/@minimax-ai/code',-});+import { AGENT_DEFINITIONS, OWN_AGENT_IDS } from './agent-definitions.mjs';+export const AGENT_DOWNLOADS = Object.freeze(Object.fromEntries(OWN_AGENT_IDS.map((id) => [id, AGENT_DEFINITIONS[id].install])));/*** Each agent's program, by the names it installs (the first found counts), and the folders its own installer puts itdiff --git a/apps/desktop/src/agent-roster.mjs b/apps/desktop/src/agent-roster.mjsindex 4f05b3a..a452cd8 100644--- a/apps/desktop/src/agent-roster.mjs+++ b/apps/desktop/src/agent-roster.mjs@@ -36,13 +36,9 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';import { join } from 'node:path';import { PI_APIS, contextLength, modelEffort } from './pi-config.mjs';-/** The person's own agents, as agents.mjs AGENTS has them. */-export const OWN_AGENT_IDS = Object.freeze(['codex', 'claude', 'copilot', 'cursor', 'opencode', 'codebuddy', 'qwen', 'kimi', 'minimax']);-export const AGENT_IDS = Object.freeze([...OWN_AGENT_IDS, 'byok']);-export const AGENT_NAMES = Object.freeze({- codex: 'Codex', claude: 'Claude Code', copilot: 'GitHub Copilot', cursor: 'Cursor', opencode: 'OpenCode', codebuddy: 'CodeBuddy',- qwen: 'Qwen Code', kimi: 'Kimi', minimax: 'MiniMax Code', byok: 'Own key',-});+import { AGENT_DEFINITIONS, AGENT_IDS, OWN_AGENT_IDS, isAgentId } from './agent-definitions.mjs';+export { AGENT_IDS, OWN_AGENT_IDS } from './agent-definitions.mjs';+export const AGENT_NAMES = Object.freeze(Object.fromEntries(AGENT_IDS.map((id) => [id, AGENT_DEFINITIONS[id].name])));const isOwn = (id) => OWN_AGENT_IDS.includes(id);/** The API formats a key can be for, and the address each starts with. */@@ -83,7 +79,7 @@ export function readChoices(dataDir) {for (const id of OWN_AGENT_IDS) if (typeof raw.paths?.[id] === 'string' && raw.paths[id]) paths[id] = raw.paths[id];return {shown,- disconnected: Array.isArray(raw.disconnected) ? raw.disconnected.filter((id) => AGENT_IDS.includes(id)) : [...DEFAULT_DISCONNECTED],+ disconnected: Array.isArray(raw.disconnected) ? raw.disconnected.filter((id) => isAgentId(id)) : [...DEFAULT_DISCONNECTED],byok,paths,};@@ -247,7 +243,7 @@ export function createRoster(deps) {function list() {return AGENT_IDS.map((id) => ({id,- name: AGENT_NAMES[id],+ name: AGENT_DEFINITIONS[id].name,shown: choices.shown[id] ?? false,...stateOf(id),...(live.errors[id] ? { error: live.errors[id] } : {}),@@ -294,7 +290,7 @@ export function createRoster(deps) {/** Connect: back on here; its own sign-in when it needs one. */async connect(id) {- if (!AGENT_IDS.includes(id)) return { ok: false, error: `No agent ${id}` };+ if (!isAgentId(id)) return { ok: false, error: `No agent ${id}` };delete live.errors[id];/* connecting one is choosing it: it is shown in the chat (and among the person's agents in Settings) */save({ ...choices, shown: { ...choices.shown, [id]: true }, disconnected: choices.disconnected.filter((a) => a !== id) });@@ -319,7 +315,7 @@ export function createRoster(deps) {/** Disconnect here only: its sessions close; its own sign-in stays as it is (connecting again uses it as it is then). */disconnect(id) {- if (!AGENT_IDS.includes(id)) return;+ if (!isAgentId(id)) return;delete live.waiting[id];deps.closeSessions(id);save({ ...choices, disconnected: [...new Set([...choices.disconnected, id])] });@@ -366,7 +362,7 @@ export function createRoster(deps) {},setShown(id, shown) {- if (!AGENT_IDS.includes(id)) return;+ if (!isAgentId(id)) return;save({ ...choices, shown: { ...choices.shown, [id]: shown === true } });},diff --git a/apps/desktop/src/agents.mjs b/apps/desktop/src/agents.mjsindex c2d7371..7902727 100644--- a/apps/desktop/src/agents.mjs+++ b/apps/desktop/src/agents.mjs@@ -38,6 +38,7 @@ import { logSwitches } from './agent-logs.mjs';import { mergeConfig, sessionSkills } from './agent-skills.mjs';import { nodeBinary } from './node-runtime.mjs';import { outOfBalance } from './pi-config.mjs';+import { AGENT_DEFINITIONS } from './agent-definitions.mjs';const require = createRequire(import.meta.url);@@ -53,7 +54,7 @@ const require = createRequire(import.meta.url);*/export const AGENTS = Object.freeze({claude: {- label: 'Claude Code',+ label: AGENT_DEFINITIONS.claude.name,adapter: '@agentclientprotocol/claude-agent-acp',env: (path) => ({ CLAUDE_CODE_EXECUTABLE: path }),auth: ['auth', 'status'],@@ -66,7 +67,7 @@ export const AGENTS = Object.freeze({systemPrompt: true,},codex: {- label: 'Codex',+ label: AGENT_DEFINITIONS.codex.name,adapter: '@agentclientprotocol/codex-acp',env: (path) => codexLaunchEnv(path),/* asked only for whose account it is: Codex is signed in in Codex (its app, or `codex login`) */@@ -74,16 +75,16 @@ export const AGENTS = Object.freeze({login: null,systemPrompt: true,},- copilot: { label: 'GitHub Copilot', args: ['--acp', '--allow-all'], login: ['login'], approve: true },- cursor: { label: 'Cursor', args: ['--force', 'acp'], auth: ['status'], login: ['login'], authenticate: 'cursor_login', approve: true },- opencode: { label: 'OpenCode', args: ['acp'], login: ['auth', 'login'], approve: true },+ copilot: { label: AGENT_DEFINITIONS.copilot.name, args: ['--acp', '--allow-all'], login: ['login'], approve: true },+ cursor: { label: AGENT_DEFINITIONS.cursor.name, args: ['--force', 'acp'], auth: ['status'], login: ['login'], authenticate: 'cursor_login', approve: true },+ opencode: { label: AGENT_DEFINITIONS.opencode.name, args: ['acp'], login: ['auth', 'login'], approve: true },/* CodeBuddy is the China edition unless the person's shell says otherwise: the program itself defaults to theinternational site (www.codebuddy.ai) whichever site it was signed in on, out of reach from China */- codebuddy: { label: 'CodeBuddy', args: ['--acp', '--permission-mode', 'bypassPermissions'], login: [], approve: true,+ codebuddy: { label: AGENT_DEFINITIONS.codebuddy.name, args: ['--acp', '--permission-mode', 'bypassPermissions'], login: [], approve: true,defaults: { CODEBUDDY_INTERNET_ENVIRONMENT: 'internal' } },- qwen: { label: 'Qwen Code', args: ['--acp', '--approval-mode', 'yolo'], login: [], approve: true },- kimi: { label: 'Kimi', args: ['acp'], login: ['login'], approve: true },- minimax: { label: 'MiniMax Code', args: ['acp'], login: ['login'], approve: true },+ qwen: { label: AGENT_DEFINITIONS.qwen.name, args: ['--acp', '--approval-mode', 'yolo'], login: [], approve: true },+ kimi: { label: AGENT_DEFINITIONS.kimi.name, args: ['acp'], login: ['login'], approve: true },+ minimax: { label: AGENT_DEFINITIONS.minimax.name, args: ['acp'], login: ['login'], approve: true },});export const isAgentId = (id) => typeof id === 'string' && Object.hasOwn(AGENTS, id);