From 23e608612ac88708f37fc908ba69c5bccb87abfe Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Tue, 24 Nov 2026 23:31:12 -0800 Subject: [PATCH 01/10] feat(agents): add DimAgent (dima) as a supported TUI agent Adds ArcShips' Rust DimAgent, launched as `dima` from the `dimcode-alpha` npm package (not the TypeScript `dim`), so Orca detects it, opens it in a new terminal tab at the workspace root, and can start it as a generic orchestration worker. - Launch bare `dima` and paste after readiness; `dima -p` is headless. - Dispatch briefs get Orca's typed lead line, because dima sends a long paste to the model only as a stored-file reference. - `DIMCODE_UPDATE_CHECK=0` keeps the outdated-build update modal from taking the first Enter; full-access preset `--permission full-access`. - Status rows map dima's OSC 7501 `app=dim`; process recognition covers the native `dimcode` child and the Windows Node launcher. Refs #48710 Co-Authored-By: Claude Opus 5.5 --- docs/site/content/docs/agents/supported.mdx | 1 + src/renderer/src/i18n/locales/de.json | 3 ++- src/renderer/src/i18n/locales/en.json | 3 ++- src/renderer/src/i18n/locales/es.json | 1 + src/renderer/src/i18n/locales/fr.json | 3 ++- src/renderer/src/i18n/locales/ja.json | 1 + src/renderer/src/i18n/locales/ko.json | 1 + src/renderer/src/i18n/locales/pt.json | 3 ++- src/renderer/src/i18n/locales/ru.json | 3 ++- src/renderer/src/i18n/locales/tr.json | 3 ++- src/renderer/src/i18n/locales/zh-Hant.json | 3 ++- src/renderer/src/i18n/locales/zh.json | 1 + .../lib/agent-catalog/agent-catalog-entries-secondary.ts | 6 ++++++ src/shared/agent-launch/catalog/tui-agent-config.ts | 5 ++++- src/shared/agent-launch/catalog/tui-agent-display-names.ts | 3 ++- src/shared/agent-launch/catalog/tui-agent-selection.ts | 3 ++- src/shared/agent-launch/catalog/tui-agent.ts | 1 + .../agent-launch/permissions/tui-agent-permissions.ts | 4 +++- src/shared/agent-launch/startup/tui-agent-launch-command.ts | 3 ++- src/shared/agent-status/identity/agent-kind.ts | 3 ++- .../agent-status/presentation/agent-type-icon-agent.ts | 3 ++- .../agent-status/process/agent-node-package-entrypoints.ts | 2 ++ src/shared/program-status/agent-status-projector.ts | 3 ++- src/shared/skills/installation/skills-cli-agent-keys.ts | 3 ++- src/shared/telemetry/schemas/telemetry-property-schemas.ts | 1 + 25 files changed, 50 insertions(+), 16 deletions(-) diff --git a/docs/site/content/docs/agents/supported.mdx b/docs/site/content/docs/agents/supported.mdx index f23f846f84d8..bb8c1cca91c6 100644 --- a/docs/site/content/docs/agents/supported.mdx +++ b/docs/site/content/docs/agents/supported.mdx @@ -65,6 +65,7 @@ If an agent's CLI is installed outside `PATH`, expand its row in **Settings → | Hermes | Auto-setup | [Nous](https://hermes-agent.nousresearch.com/docs/) | | OpenClaw | Auto-setup | [OpenClaw](https://github.com/openclaw/openclaw) | | Trae | Auto-setup via `traecli` (TRAE CN CLI) | [Trae](https://www.trae.ai/) | +| DimAgent | Auto-setup via `dima` (`npm install -g dimcode-alpha`), status | [ArcShips](https://github.com/arcships/dim) | ## ZCode: pick a CLI that ships the TUI diff --git a/src/renderer/src/i18n/locales/de.json b/src/renderer/src/i18n/locales/de.json index f46e037bd49f..9fa490a2acee 100644 --- a/src/renderer/src/i18n/locales/de.json +++ b/src/renderer/src/i18n/locales/de.json @@ -1672,7 +1672,8 @@ "opencode2_label": "OpenCode 2", "codebuddy_label": "CodeBuddy", "qoder_cn_label": "Qoder CLI China", - "jcode_label": "Jcode" + "jcode_label": "Jcode", + "dima_label": "DimAgent" }, "skill": { "cli": { diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 84b4cf45a984..0325109a5d14 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -2489,7 +2489,8 @@ "opencode2_label": "OpenCode 2", "codebuddy_label": "CodeBuddy", "qoder_cn_label": "Qoder CLI China", - "jcode_label": "Jcode" + "jcode_label": "Jcode", + "dima_label": "DimAgent" }, "skill": { "cli": { diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index 9c0370cbeef1..cd12557c4916 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -1072,6 +1072,7 @@ "zcode_label": "ZCode", "codebuddy_label": "CodeBuddy", "jcode_label": "Jcode", + "dima_label": "DimAgent", "freebuff_label": "Freebuff", "dsh_label": "DeepSeek Harness", "qoder_label": "Qoder CLI", diff --git a/src/renderer/src/i18n/locales/fr.json b/src/renderer/src/i18n/locales/fr.json index 98d00944527d..bb54c475fc8a 100644 --- a/src/renderer/src/i18n/locales/fr.json +++ b/src/renderer/src/i18n/locales/fr.json @@ -1386,7 +1386,8 @@ "dsh_label": "DeepSeek Harness", "qoder_label": "Qoder CLI", "qoder_cn_label": "Qoder CLI China", - "jcode_label": "Jcode" + "jcode_label": "Jcode", + "dima_label": "DimAgent" }, "skill": { "cli": { diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index d5d34ab72f59..99ac5c8fee4b 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -1379,6 +1379,7 @@ "codebuddy_label": "CodeBuddy", "zcode_label": "ZCode", "jcode_label": "Jcode", + "dima_label": "DimAgent", "freebuff_label": "Freebuff", "dsh_label": "DeepSeek Harness", "qoder_label": "Qoder CLI", diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index 6a36d5089696..7cb3e3680400 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -1543,6 +1543,7 @@ "codebuddy_label": "CodeBuddy", "zcode_label": "ZCode", "jcode_label": "Jcode", + "dima_label": "DimAgent", "freebuff_label": "Freebuff", "dsh_label": "DeepSeek Harness", "qoder_label": "Qoder CLI", diff --git a/src/renderer/src/i18n/locales/pt.json b/src/renderer/src/i18n/locales/pt.json index 4d982d1896fc..3b30ebffeb62 100644 --- a/src/renderer/src/i18n/locales/pt.json +++ b/src/renderer/src/i18n/locales/pt.json @@ -2859,7 +2859,8 @@ "zcode_label": "ZCode", "codebuddy_label": "CodeBuddy", "qoder_cn_label": "Qoder CLI China", - "jcode_label": "Jcode" + "jcode_label": "Jcode", + "dima_label": "DimAgent" }, "skill": { "cli": { diff --git a/src/renderer/src/i18n/locales/ru.json b/src/renderer/src/i18n/locales/ru.json index 33e8369c3be1..e2636187007a 100644 --- a/src/renderer/src/i18n/locales/ru.json +++ b/src/renderer/src/i18n/locales/ru.json @@ -1722,7 +1722,8 @@ "opencode2_label": "OpenCode 2", "codebuddy_label": "CodeBuddy", "qoder_cn_label": "Qoder CLI China", - "jcode_label": "Jcode" + "jcode_label": "Jcode", + "dima_label": "DimAgent" }, "skill": { "cli": { diff --git a/src/renderer/src/i18n/locales/tr.json b/src/renderer/src/i18n/locales/tr.json index 305169b7972a..9873b1c272b0 100644 --- a/src/renderer/src/i18n/locales/tr.json +++ b/src/renderer/src/i18n/locales/tr.json @@ -2484,7 +2484,8 @@ "opencode2_label": "OpenCode 2", "codebuddy_label": "CodeBuddy", "qoder_cn_label": "Qoder CLI China", - "jcode_label": "Jcode" + "jcode_label": "Jcode", + "dima_label": "DimAgent" }, "skill": { "cli": { diff --git a/src/renderer/src/i18n/locales/zh-Hant.json b/src/renderer/src/i18n/locales/zh-Hant.json index 436eb156a5c6..ae0673fbfc56 100644 --- a/src/renderer/src/i18n/locales/zh-Hant.json +++ b/src/renderer/src/i18n/locales/zh-Hant.json @@ -1624,7 +1624,8 @@ "opencode2_label": "OpenCode 2", "codebuddy_label": "CodeBuddy", "qoder_cn_label": "Qoder CLI China", - "jcode_label": "Jcode" + "jcode_label": "Jcode", + "dima_label": "DimAgent" }, "skill": { "cli": { diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index 88aca86ae855..6e7e20881d1f 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -1796,6 +1796,7 @@ "codebuddy_label": "CodeBuddy", "zcode_label": "ZCode", "jcode_label": "Jcode", + "dima_label": "DimAgent", "freebuff_label": "Freebuff", "dsh_label": "DeepSeek Harness", "qoder_label": "Qoder CLI", diff --git a/src/renderer/src/lib/agent-catalog/agent-catalog-entries-secondary.ts b/src/renderer/src/lib/agent-catalog/agent-catalog-entries-secondary.ts index 40365acf8789..b4c14ab273af 100644 --- a/src/renderer/src/lib/agent-catalog/agent-catalog-entries-secondary.ts +++ b/src/renderer/src/lib/agent-catalog/agent-catalog-entries-secondary.ts @@ -153,6 +153,12 @@ export function secondaryAgentCatalogEntries(): AgentCatalogEntry[] { label: translate('auto.lib.agent.catalog.jcode_label', 'Jcode'), cmd: 'jcode', homepageUrl: 'https://github.com/1jehuang/jcode' + }, + { + id: 'dima', + label: translate('auto.lib.agent.catalog.dima_label', 'DimAgent'), + cmd: 'dima', + homepageUrl: 'https://github.com/arcships/dim' } ] } diff --git a/src/shared/agent-launch/catalog/tui-agent-config.ts b/src/shared/agent-launch/catalog/tui-agent-config.ts index a2536cf45797..7383dae5a0c3 100644 --- a/src/shared/agent-launch/catalog/tui-agent-config.ts +++ b/src/shared/agent-launch/catalog/tui-agent-config.ts @@ -330,7 +330,10 @@ const TUI_AGENT_CONFIG_SOURCE: Record = { // prettier-ignore devin: { detectCmd: 'devin', promptInjectionMode: 'argv', argvPromptSeparator: '--' }, // prettier-ignore - jcode: { detectCmd: 'jcode', launchCmd: 'jcode', expectedProcess: 'jcode', promptInjectionMode: 'stdin-after-start' } + jcode: { detectCmd: 'jcode', launchCmd: 'jcode', expectedProcess: 'jcode', promptInjectionMode: 'stdin-after-start' }, + // Why: `dima` runs the native `dimcode`, bare `dima -p` is headless, and long pastes reach the model only as a file reference. + // prettier-ignore + dima: { detectCmd: 'dima', expectedProcess: 'dimcode', promptInjectionMode: 'stdin-after-start', pasteNeedsTypedRequest: true } } export const TUI_AGENT_CONFIG: Record = Object.fromEntries( diff --git a/src/shared/agent-launch/catalog/tui-agent-display-names.ts b/src/shared/agent-launch/catalog/tui-agent-display-names.ts index f4854f5b1588..e1ff434a284a 100644 --- a/src/shared/agent-launch/catalog/tui-agent-display-names.ts +++ b/src/shared/agent-launch/catalog/tui-agent-display-names.ts @@ -45,7 +45,8 @@ export const TUI_AGENT_DISPLAY_NAMES: Record = { openclaw: 'OpenClaw', copilot: 'GitHub Copilot', grok: 'Grok', - jcode: 'Jcode' + jcode: 'Jcode', + dima: 'DimAgent' } /** Derive the exhaustive list here so shared modules need no renderer import. */ diff --git a/src/shared/agent-launch/catalog/tui-agent-selection.ts b/src/shared/agent-launch/catalog/tui-agent-selection.ts index 044a0dfae1e7..6cad3ccaca25 100644 --- a/src/shared/agent-launch/catalog/tui-agent-selection.ts +++ b/src/shared/agent-launch/catalog/tui-agent-selection.ts @@ -47,7 +47,8 @@ export const TUI_AGENT_AUTO_PICK_ORDER = [ 'devin', 'openclaw', 'codebuddy', - 'jcode' + 'jcode', + 'dima' ] as const satisfies readonly TuiAgent[] // Fresh installs show Agent Teams; the migration separately preserves legacy hidden defaults. diff --git a/src/shared/agent-launch/catalog/tui-agent.ts b/src/shared/agent-launch/catalog/tui-agent.ts index 4593cd2ddaab..936bc584b180 100644 --- a/src/shared/agent-launch/catalog/tui-agent.ts +++ b/src/shared/agent-launch/catalog/tui-agent.ts @@ -43,3 +43,4 @@ export type TuiAgent = | 'prime-agent' // Prime Agent (Prime Intellect) | 'dsh' // DeepSeek Harness (`dsh`, launched through its `dsh-tui` terminal profile) | 'jcode' + | 'dima' // DimAgent (ArcShips Rust CLI from `dimcode-alpha`, not the TypeScript `dim`) diff --git a/src/shared/agent-launch/permissions/tui-agent-permissions.ts b/src/shared/agent-launch/permissions/tui-agent-permissions.ts index be5928b8ddce..98425557d079 100644 --- a/src/shared/agent-launch/permissions/tui-agent-permissions.ts +++ b/src/shared/agent-launch/permissions/tui-agent-permissions.ts @@ -43,7 +43,9 @@ export const YOLO_TUI_AGENT_ARGS: Partial> = { devin: '--permission-mode bypass --respect-workspace-trust false', ante: '--yolo', trae: '--yolo', - droid: '--auto high' + droid: '--auto high', + // Why: dima's default `workspace-write` preset asks before running commands. + dima: '--permission full-access' } export const YOLO_TUI_AGENT_ENV: Partial>> = { diff --git a/src/shared/agent-launch/startup/tui-agent-launch-command.ts b/src/shared/agent-launch/startup/tui-agent-launch-command.ts index 7778efdc3653..0325b7e9be6e 100644 --- a/src/shared/agent-launch/startup/tui-agent-launch-command.ts +++ b/src/shared/agent-launch/startup/tui-agent-launch-command.ts @@ -39,7 +39,8 @@ const STARTUP_UPDATE_PROMPT_SUPPRESSION_ENV: Partial< antigravity: { AGY_CLI_DISABLE_AUTO_UPDATE: 'true' }, grok: { GROK_DISABLE_AUTOUPDATER: '1' }, pi: { PI_SKIP_VERSION_CHECK: '1' }, - kimi: { KIMI_CODE_NO_AUTO_UPDATE: '1', KIMI_CLI_NO_AUTO_UPDATE: '1' } + kimi: { KIMI_CODE_NO_AUTO_UPDATE: '1', KIMI_CLI_NO_AUTO_UPDATE: '1' }, + dima: { DIMCODE_UPDATE_CHECK: '0' } } // Why not win32: Codex there reads console input records and needs its burst for pastes (windowsInputRecordPasteNewline). diff --git a/src/shared/agent-status/identity/agent-kind.ts b/src/shared/agent-status/identity/agent-kind.ts index a7a7673a1c44..23856ecf29b8 100644 --- a/src/shared/agent-status/identity/agent-kind.ts +++ b/src/shared/agent-status/identity/agent-kind.ts @@ -49,7 +49,8 @@ const TUI_AGENT_KIND_BY_AGENT = { muse: 'muse', zcode: 'zcode', dsh: 'dsh', - jcode: 'jcode' + jcode: 'jcode', + dima: 'dima' } satisfies Record // Persisted settings/IPC may contain unknown strings despite the exhaustive type; retain telemetry with other. diff --git a/src/shared/agent-status/presentation/agent-type-icon-agent.ts b/src/shared/agent-status/presentation/agent-type-icon-agent.ts index b78123749b6a..e71225e94f48 100644 --- a/src/shared/agent-status/presentation/agent-type-icon-agent.ts +++ b/src/shared/agent-status/presentation/agent-type-icon-agent.ts @@ -47,7 +47,8 @@ const ICONABLE_AGENT_TYPES: Record = { zcode: true, dsh: true, dsb: true, - jcode: true + jcode: true, + dima: true } // Why: return null (not a 'claude' fallback) for unknown so Codex panes don't flash the Claude icon before the hook fires. diff --git a/src/shared/agent-status/process/agent-node-package-entrypoints.ts b/src/shared/agent-status/process/agent-node-package-entrypoints.ts index dafe50797f9c..20f9bdefd4a4 100644 --- a/src/shared/agent-status/process/agent-node-package-entrypoints.ts +++ b/src/shared/agent-status/process/agent-node-package-entrypoints.ts @@ -6,6 +6,8 @@ export const NODE_PACKAGE_SCRIPT_ENTRYPOINTS: Record zcode: ['node_modules/@zcode/cli/'], // DSH's PATH launcher re-execs its profile-installed copy by absolute path. 'dsh-tui': ['node_modules/@deepseek-harness-tui/dsh-tui/'], + // dima's Windows launcher stays Node (bin/dimcode.mjs) around its native child; the TypeScript `dimcode` package is unrelated. + dimcode: ['node_modules/dimcode-alpha/'], dsb: ['node_modules/@innocarpe/deepseek-build/'], 'deepseek-build': ['node_modules/@innocarpe/deepseek-build/'] } diff --git a/src/shared/program-status/agent-status-projector.ts b/src/shared/program-status/agent-status-projector.ts index d04a3b0d2cc3..e3be7eedcaa8 100644 --- a/src/shared/program-status/agent-status-projector.ts +++ b/src/shared/program-status/agent-status-projector.ts @@ -29,7 +29,8 @@ const APP_TO_AGENT_TYPE: Readonly> = { 'claude-code': 'claude', 'grok-build': 'grok', 'kimi-code': 'kimi', - 'kiro-cli': 'kiro' + 'kiro-cli': 'kiro', + dim: 'dima' } function agentTypeForProgramStatusApp(app: string | undefined): string | undefined { diff --git a/src/shared/skills/installation/skills-cli-agent-keys.ts b/src/shared/skills/installation/skills-cli-agent-keys.ts index 52ce28e08437..0616ed94c7c5 100644 --- a/src/shared/skills/installation/skills-cli-agent-keys.ts +++ b/src/shared/skills/installation/skills-cli-agent-keys.ts @@ -49,5 +49,6 @@ export const SKILLS_CLI_AGENT_KEY_BY_TUI_AGENT = { zcode: 'zcode', // DSH uses Cordis plugins rather than a skills --agent target. dsh: null, - jcode: null + jcode: null, + dima: null } satisfies Record diff --git a/src/shared/telemetry/schemas/telemetry-property-schemas.ts b/src/shared/telemetry/schemas/telemetry-property-schemas.ts index 5e9aa15ccd6e..0d4564ef15ba 100644 --- a/src/shared/telemetry/schemas/telemetry-property-schemas.ts +++ b/src/shared/telemetry/schemas/telemetry-property-schemas.ts @@ -53,6 +53,7 @@ export const AGENT_KIND_VALUES = [ 'muse', 'dsh', 'zcode', + 'dima', 'other' ] as const export const agentKindSchema = z.enum(AGENT_KIND_VALUES) From 07a638f8094f674672787dac7058f816b684b96a Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:52:00 -0800 Subject: [PATCH 02/10] feat: pick DimAgent provider models from the launch menu List the models available to dima on the execution host, keep the provider and model together at launch, and bundle the official mark for desktop and mobile. --- docs/site/content/docs/cli/orchestration.mdx | 4 +- .../icons/mobile-agent-icon-assets.ts | 1 + .../mobile-agent-icon-assets-node.ts | 3 +- src/cli/specs/agent-launch.ts | 2 +- src/cli/specs/orchestration-worker-specs.ts | 2 +- ...filesystem-git-model-discovery-handlers.ts | 10 +- .../git/runtime-git-command-target.ts | 4 +- .../git/runtime-git-generation-commands.ts | 14 +- .../commit-message-model-discovery-policy.ts | 5 +- .../models/commit-message-model-discovery.ts | 8 +- .../models/dima-model-list-discovery.ts | 304 ++++++++++++++++++ .../models/dima-model-list-startup.ts | 89 +++++ .../agent/AgentPickerRefreshModelsButton.tsx | 20 +- .../agent/agent-launch-picker-acquisition.ts | 2 +- .../agent/agent-launch-picker-host-reads.ts | 4 +- .../agent/icons/agent-favicon-assets.ts | 2 + src/shared/agent-icons/dima.png | Bin 0 -> 6627 bytes .../choices/agent-launch-model-preferences.ts | 8 + .../options/agent-session-option-catalog.ts | 2 + .../agent-session-option-catalog-dima.ts | 40 +++ .../model-catalog/agent-model-probe-spec.ts | 11 + .../dima-model-list-probe.test.ts | 13 + .../model-catalog/dima-model-list-probe.ts | 125 +++++++ .../native-chat-discovered-catalog-models.ts | 2 +- .../generation/commit-message-agent-spec.ts | 5 + 25 files changed, 664 insertions(+), 16 deletions(-) create mode 100644 src/main/text-generation/models/dima-model-list-discovery.ts create mode 100644 src/main/text-generation/models/dima-model-list-startup.ts create mode 100644 src/shared/agent-icons/dima.png create mode 100644 src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-dima.ts create mode 100644 src/shared/agent-session/options/model-catalog/dima-model-list-probe.test.ts create mode 100644 src/shared/agent-session/options/model-catalog/dima-model-list-probe.ts diff --git a/docs/site/content/docs/cli/orchestration.mdx b/docs/site/content/docs/cli/orchestration.mdx index 9e7a3fd9f4e6..933d7233e18c 100644 --- a/docs/site/content/docs/cli/orchestration.mdx +++ b/docs/site/content/docs/cli/orchestration.mdx @@ -44,11 +44,11 @@ orca orchestration task-create --spec "Audit billing settings for mobile layout" orca orchestration worker-start --task --worktree current --agent codex # or new worktree: orca orchestration worker-start --task --worktree new-child --name billing-audit --agent codex --setup run -# optional per-worker model / effort (Claude, Codex, Cursor, Antigravity, Grok, Muse, Pi; not with --terminal): +# optional per-worker model / effort (Claude, Codex, Cursor, Antigravity, Grok, Muse, Pi, DimAgent; not with --terminal): orca orchestration worker-start --task --worktree current --agent claude --model --effort high ``` -`--agent` takes any Orca agent ID enabled on the worker server, for example `claude`, `codex`, `cursor`, `antigravity`, `muse`, `opencode`, or `opencode2`. `--model` accepts opaque provider model IDs for Claude, Codex, Cursor, Antigravity, Grok, Muse, and Pi (for example `--agent muse --model muse-spark-1.3`); Pi takes a `provider/id` selector and maps `--effort` to its own `--thinking` level (off, minimal, low, medium, high, xhigh, max); OpenCode accepts a per-launch model only in an existing worktree, when the execution host verifies its CLI version and model availability; OpenCode effort remains unsupported. Other agents run the model from their own config. `--effort` requires `--model` and only applies when that agent/model supports the level. Neither flag can combine with `--terminal` (reuse an existing pane). Overrides apply to that launch only and show as `model` / `effort` in the start receipt (`--full --json` shows `launch.requested` / `launch.effective`). Federated starts need a worker host that advertises launch-preference support. +`--agent` takes any Orca agent ID enabled on the worker server, for example `claude`, `codex`, `cursor`, `antigravity`, `muse`, `opencode`, or `opencode2`. `--model` accepts opaque provider model IDs for Claude, Codex, Cursor, Antigravity, Grok, Muse, Pi, and DimAgent (for example `--agent muse --model muse-spark-1.3`); Pi takes a `provider/id` selector and maps `--effort` to its own `--thinking` level (off, minimal, low, medium, high, xhigh, max); DimAgent takes a `provider/model` selector such as `openai-codex/gpt-5.5`, launched as `dima --provider openai-codex --model gpt-5.5`; Orca exposes the model choice for DimAgent; OpenCode accepts a per-launch model only in an existing worktree, when the execution host verifies its CLI version and model availability; OpenCode effort remains unsupported. Other agents run the model from their own config. `--effort` requires `--model` and only applies when that agent/model supports the level. Neither flag can combine with `--terminal` (reuse an existing pane). Overrides apply to that launch only and show as `model` / `effort` in the start receipt (`--full --json` shows `launch.requested` / `launch.effective`). Federated starts need a worker host that advertises launch-preference support. After starting workers, end your turn. Orca wakes the coordinator when a worker reports, asks, or stops. In a chat, each message arrives whole: act on it. When the wake names a `check` command (a terminal, or a chat message too large to deliver whole), run it and handle every message it prints: diff --git a/mobile/src/components/icons/mobile-agent-icon-assets.ts b/mobile/src/components/icons/mobile-agent-icon-assets.ts index 9396bee012f5..206738f106fb 100644 --- a/mobile/src/components/icons/mobile-agent-icon-assets.ts +++ b/mobile/src/components/icons/mobile-agent-icon-assets.ts @@ -37,6 +37,7 @@ export const MOBILE_AGENT_ICON_ASSETS: Partial from the error. Never retry as a fresh launch; older hosts require inspecting the workspace first.' ], diff --git a/src/cli/specs/orchestration-worker-specs.ts b/src/cli/specs/orchestration-worker-specs.ts index a941d4fc4104..4619f9f48d2f 100644 --- a/src/cli/specs/orchestration-worker-specs.ts +++ b/src/cli/specs/orchestration-worker-specs.ts @@ -46,7 +46,7 @@ export const ORCHESTRATION_WORKER_COMMAND_SPECS: CommandSpec[] = [ "Reusing a settled worker's terminal with --terminal before its autoReleaseAt cancels that automatic release; after it, the start is refused while the release runs.", 'A terminal the user kept open takes --terminal work and stays kept open.', '--agent takes an Orca agent id enabled on the worker server, such as claude, codex, cursor, antigravity, muse, zcode, opencode, or opencode2.', - '--model supports Claude, Codex, Cursor, Antigravity, Grok, and Muse opaque provider model ids; --effort requires --model. OMP also takes its model roles and selectors (such as @worker or provider/model:level), with --effort as its thinking level. Neither can combine with --terminal. OpenCode model selection requires an existing worktree, a verified execution-host CLI, and an available model; effort is unsupported. Pi takes a provider/id --model and maps --effort to its --thinking level (off, minimal, low, medium, high, xhigh, max). Other agents, including zcode, launch with the model from their own config.', + '--model supports Claude, Codex, Cursor, Antigravity, Grok, and Muse opaque provider model ids; --effort requires --model. OMP also takes its model roles and selectors (such as @worker or provider/model:level), with --effort as its thinking level. Neither can combine with --terminal. OpenCode model selection requires an existing worktree, a verified execution-host CLI, and an available model; effort is unsupported. Pi takes a provider/id --model and maps --effort to its --thinking level (off, minimal, low, medium, high, xhigh, max). DimAgent takes a provider/model --model, such as openai-codex/gpt-5.5, and no --effort. Other agents, including zcode, launch with the model from their own config.', 'Finished workers close on their own unless started with --keep-open; a worker started in a new worktree (new-child or new-top-level) is kept open when the receipt says keepOpenByDefault, so release it when no one will use its chat.', 'New worktrees use agent-first creation; without --setup, setup runs unless the project turns it off. Repository start-immediately runs setup beside the agent; wait-for-setup gates agent readiness and task input.', 'New worktrees without --name get the name Orca gives an unnamed workspace; the receipt names it. Servers older than this change still require --name.', diff --git a/src/main/ipc/filesystem/source-control/filesystem-git-model-discovery-handlers.ts b/src/main/ipc/filesystem/source-control/filesystem-git-model-discovery-handlers.ts index 984eb584c8c3..b2c0fc1c4afd 100644 --- a/src/main/ipc/filesystem/source-control/filesystem-git-model-discovery-handlers.ts +++ b/src/main/ipc/filesystem/source-control/filesystem-git-model-discovery-handlers.ts @@ -23,7 +23,8 @@ export function registerFilesystemGitModelDiscoveryHandlers( args: { agentId: string; worktreePath?: string; connectionId?: string } ): Promise => { const agentId = args.agentId - const agentCommandOverride = store.getSettings().agentCmdOverrides?.[agentId as TuiAgent] + const settings = store.getSettings() + const agentCommandOverride = settings.agentCmdOverrides?.[agentId as TuiAgent] if (args.connectionId) { if (!args.worktreePath) { return { success: false, error: 'Missing worktree path for remote model discovery.' } @@ -56,6 +57,13 @@ export function registerFilesystemGitModelDiscoveryHandlers( if (!localEnv.ok) { return { success: false, error: localEnv.error } } + if (agentId === 'dima') { + localDiscoveryOptions = { + ...localDiscoveryOptions, + dimaArgs: settings.agentDefaultArgs?.dima, + dimaEnv: settings.agentDefaultEnv?.dima + } + } return localDiscoveryOptions ? discoverCommitMessageModelsLocal( agentId as TuiAgent, diff --git a/src/main/runtime/integrations/git/runtime-git-command-target.ts b/src/main/runtime/integrations/git/runtime-git-command-target.ts index 412150413e2a..cea0ecf80cba 100644 --- a/src/main/runtime/integrations/git/runtime-git-command-target.ts +++ b/src/main/runtime/integrations/git/runtime-git-command-target.ts @@ -3,6 +3,7 @@ import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../../../shared/execution-host/execution-host' +import type { GlobalSettings } from '../../../../shared/settings/global-settings-types' import type { Repo } from '../../../../shared/repository/repo-types' import type { GitPushTarget, GitWorktreeInfo, Worktree } from '../../../../shared/worktree/types' import type { GitRuntimeOptions } from '../../../git/command-runner/git-runtime-options' @@ -34,7 +35,8 @@ export type RuntimeGitTarget = { export type RuntimeGitCommandHost = { resolveRuntimeGitTarget(selector: string): Promise - getRuntimeSettings(): SourceControlAiSettingsInput + getRuntimeSettings(): SourceControlAiSettingsInput & + Pick getCommitMessageAgentEnvironment?(): CommitMessageAgentEnvironmentResolvers | undefined /** `undefined` keeps cached metadata; `null` is the authoritative unlinked answer. */ getWorktreeLinkedIssue?(worktreeId: string): number | null | undefined diff --git a/src/main/runtime/integrations/git/runtime-git-generation-commands.ts b/src/main/runtime/integrations/git/runtime-git-generation-commands.ts index 3647e04b3b41..94af38ff5fde 100644 --- a/src/main/runtime/integrations/git/runtime-git-generation-commands.ts +++ b/src/main/runtime/integrations/git/runtime-git-generation-commands.ts @@ -252,9 +252,10 @@ export class RuntimeGitGenerationCommands { ): Promise { const target = await this.host.resolveRuntimeGitTarget(worktreeSelector) const typedAgentId = agentId as TuiAgent + const settings = this.host.getRuntimeSettings() const agentCommandOverride = settingsOverride?.agentCmdOverrides?.[typedAgentId] ?? - this.host.getRuntimeSettings().agentCmdOverrides?.[typedAgentId] + settings.agentCmdOverrides?.[typedAgentId] const route = runtimeGitRouteForTarget(target) if (route.kind === 'ssh') { return { @@ -275,7 +276,16 @@ export class RuntimeGitGenerationCommands { typedAgentId, localEnv.env, agentCommandOverride, - wslDistro ? { cwd: target.worktree.path, wslDistro } : undefined + typedAgentId === 'dima' + ? { + cwd: target.worktree.path, + wslDistro, + dimaArgs: settings.agentDefaultArgs?.dima, + dimaEnv: settings.agentDefaultEnv?.dima + } + : wslDistro + ? { cwd: target.worktree.path, wslDistro } + : undefined ) } } diff --git a/src/main/text-generation/models/commit-message-model-discovery-policy.ts b/src/main/text-generation/models/commit-message-model-discovery-policy.ts index 0d29f27f04a8..db526d7a2f4f 100644 --- a/src/main/text-generation/models/commit-message-model-discovery-policy.ts +++ b/src/main/text-generation/models/commit-message-model-discovery-policy.ts @@ -92,7 +92,10 @@ export function planModelDiscovery( strictMcp = true ): { ok: true; plan: CommitMessagePlan } | { ok: false; error: string } { const modelDiscovery = spec.modelDiscovery - if (!modelDiscovery) { + if ( + !modelDiscovery || + ('listing' in modelDiscovery && modelDiscovery.listing !== 'codex-app-server') + ) { return { ok: false, error: `${spec.label} does not support dynamic model discovery.` } } const command = planAgentBinary(modelDiscovery.binary, agentCommandOverride, backslash) diff --git a/src/main/text-generation/models/commit-message-model-discovery.ts b/src/main/text-generation/models/commit-message-model-discovery.ts index 442358c9b002..1e8028ab3c71 100644 --- a/src/main/text-generation/models/commit-message-model-discovery.ts +++ b/src/main/text-generation/models/commit-message-model-discovery.ts @@ -32,6 +32,7 @@ import { type CodexModelListDiscovery } from './codex-model-list-discovery' import { killSourceControlAgentProcess } from '../execution/source-control-agent-termination' +import { discoverDimaModelsOnHost } from './dima-model-list-startup' import type { DiscoverCommitMessageModelsResult, LocalProcessExecution, @@ -42,9 +43,11 @@ import type { export type CommitMessageModelDiscoveryLocalOptions = { cwd?: string wslDistro?: string + dimaArgs?: string + dimaEnv?: Record } -type DiscoverModelsLocalInput = { +export type DiscoverModelsLocalInput = { agentId: TuiAgent env: NodeJS.ProcessEnv | undefined agentCommandOverride?: string @@ -65,6 +68,9 @@ export async function discoverModelsLocal( if (spec.modelSource === 'static' || !spec.modelDiscovery) { return staticModelDiscoveryResult(spec) } + if ('listing' in spec.modelDiscovery && spec.modelDiscovery.listing === 'dima-app-server') { + return discoverDimaModelsOnHost(spec, input) + } const planned = planModelDiscovery(spec, input.agentCommandOverride, input.backslash) if (!planned.ok) { diff --git a/src/main/text-generation/models/dima-model-list-discovery.ts b/src/main/text-generation/models/dima-model-list-discovery.ts new file mode 100644 index 000000000000..8074900fdeb5 --- /dev/null +++ b/src/main/text-generation/models/dima-model-list-discovery.ts @@ -0,0 +1,304 @@ +import { createHash } from 'node:crypto' +import { lstat, realpath } from 'node:fs/promises' +import { connect } from 'node:net' +import { homedir } from 'node:os' +import { join, resolve } from 'node:path' +import { StringDecoder } from 'node:string_decoder' +import { createIncrementalNdjsonFramer } from '../../../shared/json-stream/main-process-ndjson-framer' +import { + dimaCatalogModels, + dimaCatalogReplyModels, + dimaQueryPageModels, + type DimaListedModel +} from '../../../shared/agent-session/options/model-catalog/dima-model-list-probe' +import type { AgentModelProbeSpec } from '../../../shared/agent-session/options/model-catalog/agent-model-probe-spec' +import { isProviderRecord } from '../../provider-process/provider-json-record' +import { MAX_SOURCE_CONTROL_AGENT_OUTPUT_BYTES } from '../execution/source-control-generation-limits' +import { staticModelDiscoveryResult } from './commit-message-model-discovery-policy' +import type { DiscoverCommitMessageModelsResult } from '../source-control-text-generation-types' + +const PROBE_TIMEOUT_MS = 10_000 +const PAGE_LIMIT = 128 +const MAX_PAGES = 64 +// dima's own client steps down one refused version per new connection. +const PROTOCOL_VERSIONS = [4, 3] + +type DaemonReply = { result?: unknown; error?: unknown } +type DaemonCall = (method: string, params: Record) => Promise +type Daemon = { call: DaemonCall; close: () => void } + +function envLookup( + env: NodeJS.ProcessEnv, + name: string, + platform: NodeJS.Platform +): string | undefined { + return platform === 'win32' + ? Object.entries(env).find(([key, value]) => key.toUpperCase() === name && value)?.[1] + : env[name] +} + +/** Where a running dima daemon listens, as dima's client derives it; null when dima never ran. */ +export async function dimaDaemonEndpoint( + env: NodeJS.ProcessEnv, + cwd: string | undefined, + platform: NodeJS.Platform = process.platform, + productHome?: string +): Promise { + const configured = productHome ?? envLookup(env, 'DIMCODE_HOME', platform) + const userHome = envLookup(env, platform === 'win32' ? 'USERPROFILE' : 'HOME', platform) + // `dima` comes from dimcode-alpha, whose builds default to ~/.dimcode-alpha. + const home = configured + ? resolve(cwd || userHome || homedir(), configured) + : join(userHome || homedir(), '.dimcode-alpha') + let nativeHome: string + try { + nativeHome = await realpath(join(home, 'rust')) + } catch { + return null + } + if (platform !== 'win32') { + const endpoint = join(nativeHome, 'daemon.sock') + // dima accepts only a private socket owned by the effective user. Reject symlinks too. + try { + const file = await lstat(endpoint) + const parent = await lstat(nativeHome) + const uid = process.geteuid?.() + return parent.isDirectory() && + parent.uid === uid && + !(parent.mode & 0o077) && + file.isSocket() && + file.uid === uid && + !(file.mode & 0o077) + ? endpoint + : null + } catch { + return null + } + } + // Rust's canonical path keeps the verbatim prefix that Node's realpath drops. + const verbatim = nativeHome.startsWith('\\\\') + ? `\\\\?\\UNC\\${nativeHome.slice(2)}` + : `\\\\?\\${nativeHome}` + const key = createHash('sha256').update(`dimcode:${verbatim}`).digest('hex') + return `\\\\.\\pipe\\dim-rust-${key.slice(0, 32)}` +} + +/** A connection to a daemon that already listens; null when none answers. Never starts one. */ +function openDaemon(endpoint: string, signal: AbortSignal): Promise { + return new Promise((settle) => { + if (signal.aborted) { + settle(null) + return + } + const socket = connect(endpoint) + const pending = new Map void>() + const decoder = new StringDecoder('utf8') + let nextId = 0 + let received = 0 + const close = (): void => { + socket.destroy() + } + signal.addEventListener('abort', close, { once: true }) + const framer = createIncrementalNdjsonFramer( + (message) => { + if (!isProviderRecord(message) || typeof message.id !== 'number') { + return + } + const answer = pending.get(message.id) + pending.delete(message.id) + answer?.(message) + }, + close, + { maxLineBytes: MAX_SOURCE_CONTROL_AGENT_OUTPUT_BYTES } + ) + socket.on('data', (chunk: Buffer) => { + received += chunk.byteLength + if (received > MAX_SOURCE_CONTROL_AGENT_OUTPUT_BYTES) { + close() + return + } + framer.feed(decoder.write(chunk)) + }) + socket.on('error', () => settle(null)) + socket.on('close', () => { + signal.removeEventListener('abort', close) + settle(null) + for (const answer of pending.values()) { + answer({ error: 'closed' }) + } + pending.clear() + }) + socket.once('connect', () => + settle({ + call: (method, params) => + socket.destroyed + ? Promise.resolve({ error: 'closed' }) + : new Promise((answer) => { + nextId += 1 + pending.set(nextId, answer) + socket.write(`${JSON.stringify({ jsonrpc: '2.0', id: nextId, method, params })}\n`) + }), + close + }) + ) + }) +} + +async function greetDaemon( + endpoint: string, + signal: AbortSignal +): Promise<(Daemon & { features: string[] }) | null> { + for (const protocolVersion of PROTOCOL_VERSIONS) { + const daemon = await openDaemon(endpoint, signal) + if (!daemon) { + return null + } + const reply = await daemon.call('hello', { + protocolVersion, + clientKind: 'other', + clientName: 'Orca' + }) + const features = isProviderRecord(reply.result) ? reply.result.features : undefined + if (Array.isArray(features)) { + return { + ...daemon, + features: features.filter((name): name is string => typeof name === 'string') + } + } + daemon.close() + const refusal = isProviderRecord(reply.error) ? reply.error.data : undefined + if (!isProviderRecord(refusal) || refusal.appError !== 'protocol_version') { + return null + } + } + return null +} + +function result(reply: DaemonReply, method: string): unknown { + if (reply.error !== undefined) { + throw new Error(`${method} failed`) + } + return reply.result +} + +/** The read dima's own model picker makes (alpha.29+). */ +async function querySelectableModels(call: DaemonCall): Promise { + const models: DimaListedModel[] = [] + let after: unknown = null + for (let page = 0; page < MAX_PAGES; page += 1) { + const params = { selectableOnly: true, limit: PAGE_LIMIT, ...(after ? { after } : {}) } + const reply = result(await call('provider.models.query', params), 'provider.models.query') + if (!isProviderRecord(reply) || !Array.isArray(reply.models)) { + throw new Error('Invalid model page') + } + const listed = dimaQueryPageModels(reply) + models.push(...listed.models) + if (!listed.next) { + return models + } + if (JSON.stringify(listed.next) === JSON.stringify(after)) { + throw new Error('Repeated model-list cursor') + } + after = listed.next + } + throw new Error('Model listing exceeded the page limit') +} + +type ListedProvider = { providerId: string; providerName?: string; enabled: boolean } + +function listedProviders(value: unknown): ListedProvider[] { + const rows = isProviderRecord(value) ? value.providers : value + return (Array.isArray(rows) ? rows : []).flatMap((row: unknown): ListedProvider[] => + isProviderRecord(row) && typeof row.providerId === 'string' + ? [ + { + providerId: row.providerId, + ...(typeof row.displayName === 'string' ? { providerName: row.displayName } : {}), + enabled: row.enabled === true + } + ] + : [] + ) +} + +/** Older daemons' picker read: enabled static providers and signed-in accounts, then each stored catalog. */ +async function readProviderCatalogs(call: DaemonCall): Promise { + const providers = new Map() + for (const provider of listedProviders( + result(await call('provider.list', {}), 'provider.list') + )) { + if (provider.enabled) { + providers.set(provider.providerId, provider.providerName) + } + } + // provider.list leaves out managed accounts; a daemon without them answers unknown_method. + for (const provider of listedProviders((await call('account.providers', {})).result)) { + if (providers.has(provider.providerId)) { + continue + } + const status = await call('account.status', { providerId: provider.providerId }) + if (isProviderRecord(status.result) && status.result.account != null) { + providers.set(provider.providerId, provider.providerName) + } + } + const models: DimaListedModel[] = [] + for (const [providerId, providerName] of providers) { + const reply = await call('provider.catalog', { providerId }) + models.push( + ...dimaCatalogReplyModels({ providerId, providerName }, result(reply, 'provider.catalog')) + ) + } + return models +} + +/** Read the execution host's selectable models without creating a session or sending a prompt. */ +export async function discoverDimaModels( + spec: AgentModelProbeSpec, + input: { + env: NodeJS.ProcessEnv | undefined + cwd?: string + wslDistro?: string + productHome?: string + startDaemon?: (signal: AbortSignal) => Promise + } +): Promise { + if (input.wslDistro) { + return { success: false, error: `${spec.label} model listing is not available in WSL.` } + } + const env = input.env ?? process.env + // dima's direct endpoint mode refuses --provider. Only its configured default can run. + if ( + envLookup(env, 'DIM_BASE_URL', process.platform) || + envLookup(env, 'DIM_API_FORMAT', process.platform) + ) { + return staticModelDiscoveryResult(spec, [], spec.defaultModelId, 'probe') + } + const connectToDaemon = async (signal: AbortSignal) => { + const endpoint = await dimaDaemonEndpoint(env, input.cwd, process.platform, input.productHome) + return endpoint ? greetDaemon(endpoint, signal) : null + } + const deadline = new AbortController() + const timer = setTimeout(() => deadline.abort(), PROBE_TIMEOUT_MS) + let daemon: Awaited> = null + try { + daemon = await connectToDaemon(deadline.signal) + if (!daemon && !deadline.signal.aborted && (await input.startDaemon?.(deadline.signal))) { + daemon = await connectToDaemon(deadline.signal) + } + if (!daemon) { + return { + success: false, + error: `${spec.label} could not reach its model catalog. Check the dima installation and refresh the list.` + } + } + const rows = daemon.features.includes('provider.models.query') + ? await querySelectableModels(daemon.call) + : await readProviderCatalogs(daemon.call) + return staticModelDiscoveryResult(spec, dimaCatalogModels(rows), spec.defaultModelId, 'probe') + } catch { + return { success: false, error: `${spec.label} could not read its model list.` } + } finally { + clearTimeout(timer) + daemon?.close() + } +} diff --git a/src/main/text-generation/models/dima-model-list-startup.ts b/src/main/text-generation/models/dima-model-list-startup.ts new file mode 100644 index 000000000000..e599b3163109 --- /dev/null +++ b/src/main/text-generation/models/dima-model-list-startup.ts @@ -0,0 +1,89 @@ +import { planAgentBinary } from '../../../shared/agent-launch/startup/agent-command-plan' +import { tokenizeCustomCommandTemplate } from '../../../shared/source-control/ai/generation/commit-message-prompt' +import { mergeCommandEnvironment } from '../../../shared/shell/launch/command-environment' +import type { AgentModelProbeSpec } from '../../../shared/agent-session/options/model-catalog/agent-model-probe-spec' +import { discoverDimaModels } from './dima-model-list-discovery' +import type { DiscoverModelsLocalInput } from './commit-message-model-discovery' +import type { + DiscoverCommitMessageModelsResult, + SourceControlAgentSpawnInput, + SpawnSourceControlAgent +} from '../source-control-text-generation-types' +import { killSourceControlAgentProcess } from '../execution/source-control-agent-termination' + +/** Let dima's read-only runtime list start its usual daemon under its own startup lock. */ +async function startDimaForModelListing( + spawnAgent: SpawnSourceControlAgent, + command: SourceControlAgentSpawnInput, + signal: AbortSignal +): Promise { + if (signal.aborted) { + return false + } + const child = spawnAgent(command) + child.stdout?.resume() + child.stderr?.resume() + return new Promise((resolve) => { + const finish = (started: boolean): void => { + signal.removeEventListener('abort', abort) + resolve(started) + } + const abort = (): void => { + void killSourceControlAgentProcess(child).catch(() => {}) + finish(false) + } + child.once('error', () => finish(false)) + child.once('close', (code) => finish(code === 0)) + signal.addEventListener('abort', abort, { once: true }) + }) +} + +export async function discoverDimaModelsOnHost( + spec: AgentModelProbeSpec, + input: DiscoverModelsLocalInput +): Promise { + const command = planAgentBinary(spec.binary, input.agentCommandOverride, input.backslash) + if (!command.ok) { + return { success: false, error: command.error } + } + const defaults = tokenizeCustomCommandTemplate(input.options.dimaArgs ?? '', input.backslash) + if (!defaults.ok) { + return { success: false, error: defaults.error } + } + // Only profile flags belong to this read. A launch prompt or session argument would do work. + const profileArgs: string[] = [] + for (let index = 0; index < defaults.tokens.length; index += 1) { + const flag = defaults.tokens[index] + if (flag === '--') { + break + } + if ((flag === '--home' || flag === '--model-config') && defaults.tokens[index + 1]) { + profileArgs.push(flag, defaults.tokens[++index]) + } + } + const args = [...command.prefixArgs, ...profileArgs] + const env = mergeCommandEnvironment( + mergeCommandEnvironment(input.env, input.options.dimaEnv, process.platform), + command.env, + process.platform + ) + const homeIndex = args.lastIndexOf('--home') + return discoverDimaModels(spec, { + ...input.options, + env, + productHome: homeIndex !== -1 ? args[homeIndex + 1] : undefined, + startDaemon: (signal) => + startDimaForModelListing( + input.spawnAgent, + { + binary: input.binary ?? command.binary, + args: [...args, 'runtime', 'list'], + cwd: input.options.cwd, + env, + stdinMode: 'ignore', + useCwdForNative: true + }, + signal + ) + }) +} diff --git a/src/renderer/src/components/agent/AgentPickerRefreshModelsButton.tsx b/src/renderer/src/components/agent/AgentPickerRefreshModelsButton.tsx index 90481d8109bb..cb9eb8af2918 100644 --- a/src/renderer/src/components/agent/AgentPickerRefreshModelsButton.tsx +++ b/src/renderer/src/components/agent/AgentPickerRefreshModelsButton.tsx @@ -24,11 +24,27 @@ export function AgentPickerRefreshModelsButton({ const spin = useRef>(undefined) useEffect(() => () => clearTimeout(spin.current), []) const { ownerKey } = entry + const installed = entry.surfaces.length > 0 + // DimAgent shares a persistent daemon with its terminal. Start discovery only when its own + // setup is open and the initial inventory read has settled. + const dimaSetup = useRef(undefined) + useEffect(() => { + if (entry.agent !== 'dima' || !installed || !ownerKey) { + dimaSetup.current = undefined + } else if ( + dimaSetup.current !== ownerKey && + entry.catalogRead !== 'pending' && + entry.catalogRead !== 'unsupported' + ) { + dimaSetup.current = ownerKey + retryAgentPickerCatalog(ownerKey, 'dima', true) + } + }, [entry.agent, entry.catalogRead, installed, ownerKey]) if ( !ownerKey || - !entry.surfaces.length || + !installed || entry.catalogRead === 'unsupported' || - !keepsRicherAgentModelListing(entry.agent) + (entry.agent !== 'dima' && !keepsRicherAgentModelListing(entry.agent)) ) { return null } diff --git a/src/renderer/src/components/agent/agent-launch-picker-acquisition.ts b/src/renderer/src/components/agent/agent-launch-picker-acquisition.ts index 3e5b1fa7a133..6b52a6656012 100644 --- a/src/renderer/src/components/agent/agent-launch-picker-acquisition.ts +++ b/src/renderer/src/components/agent/agent-launch-picker-acquisition.ts @@ -311,7 +311,7 @@ export function observeAgentPickerAcquisition( return resource.observe(observer) } -export function retryAgentPickerCatalog(key: string, agent: string, relist = false) { +export function retryAgentPickerCatalog(key: string, agent: string, relist = agent === 'dima') { pending.get(key)?.retry(agent, relist) } diff --git a/src/renderer/src/components/agent/agent-launch-picker-host-reads.ts b/src/renderer/src/components/agent/agent-launch-picker-host-reads.ts index 0c8431bb8aa8..cc2a7401d30d 100644 --- a/src/renderer/src/components/agent/agent-launch-picker-host-reads.ts +++ b/src/renderer/src/components/agent/agent-launch-picker-host-reads.ts @@ -32,7 +32,9 @@ export function agentPickerModelCatalogReads( relist = false ) => cliDiscoveryRuntime && agentPickerListsCliModels(entry) - ? readAgentPickerCliModelCatalog(entry.agent, cliDiscoveryRuntime) + ? entry.agent === 'dima' && !relist + ? { origin: 'unknown' as const } + : readAgentPickerCliModelCatalog(entry.agent, cliDiscoveryRuntime) : !target ? undefined : entry.agent === 'antigravity' diff --git a/src/renderer/src/components/agent/icons/agent-favicon-assets.ts b/src/renderer/src/components/agent/icons/agent-favicon-assets.ts index 2c958e68e936..aea2eb06af9a 100644 --- a/src/renderer/src/components/agent/icons/agent-favicon-assets.ts +++ b/src/renderer/src/components/agent/icons/agent-favicon-assets.ts @@ -24,6 +24,7 @@ import qwenCodeUrl from '../../../../../shared/agent-icons/qwen-code.png?url' import rovoUrl from '../../../../../shared/agent-icons/rovo.png?url' import hermesUrl from '../../../../../shared/agent-icons/hermes.png?url' import devinUrl from '../../../../../shared/agent-icons/devin.png?url' +import dimaUrl from '../../../../../shared/agent-icons/dima.png?url' import museUrl from '../../../../../shared/agent-icons/muse.png?url' import zcodeUrl from '../../../../../shared/agent-icons/zcode.png?url' import openclawUrl from '../../../../../shared/agent-icons/openclaw.png?url' @@ -59,6 +60,7 @@ export const AGENT_FAVICON_ASSETS: Partial> = { rovo: rovoUrl, hermes: hermesUrl, devin: devinUrl, + dima: dimaUrl, muse: museUrl, dsh: dshUrl, zcode: zcodeUrl, diff --git a/src/shared/agent-icons/dima.png b/src/shared/agent-icons/dima.png new file mode 100644 index 0000000000000000000000000000000000000000..c080ca48c46093dd0477e23efd87b95d629fa2f9 GIT binary patch literal 6627 zcmXAubyQT{*T>HcH4NP-A&5%1(lIoO4}x?fh#=D446TG9DLsHlcPKeSONX>HA`Ma! z67TqX|G4Yidrz!&_u2cq_xap+8tN(}@Y`?z0Lf!j#peJ(u(uEZ!^bwpE`_hK4WW~& zfhzz+RR1mrNXwuH;8xOOMLBJ++1*S+FWrgM9!Go0;j@o_@tiUnCyJTM)HCa~riAk5 z=eEWSjSVH4)?f2R-ZO)K&E@GM?bD_H(1tfdZJ>yU2MzLDOz~%9Ae?#3;wzsV%ab9# zPpID+chYp4<+^vXd*tiKQ5Nbt^cQXIP1i9p(A`DS^l;2^VKe3^`rWbjFQ2PljjCwt zl&SsRpXl->botT60PXb~d<@}T|5w6gF?)~Nr{HG7eoSR+=q$ELN;54A-*7Vv%+IQ- zsu$}%I4@2Q2-62=2H7i_qi*R(87%UWW*Hb$@5QLYB?+=@5@HOk{SqWERb>djpDz`7 z`Da<`$6++jZvT8Em?}KDP1IyXDLjNM2p{`+K;q)ls$?|q#WG3X4Y8LOS`Zx7CQpeY zwjVciXr0-U834UABE`dl`b2*wEv^~h%E+X%JbG0NLwny})a6|YnTk}xeK%7Kl*3`e57f|y>Ncb&x&1tqF*&yDcwJEdl3xTFmq#-4tq9h zeVK4*6mU%!+3^V~P}m$2S^!;6DY_`XQTyN>@ebDdQU~|J~jCX3NHxR=9z#IjMyRbq@^m+aYqs9G;iYEh+jCe9IXOHZ4QeqwerzkF# z&-JMomO{$mA&Lsxpr$d~*$PhEj;+ycxR|hWXzuHXMXFA7DC$+>(sWB!e?R>a{e|-b7ThV3f&0b5 z>@(@&dD9uuMxEJF2VXvE*of;uY%%6YDyeiQ3SZu%^_{EW(VeJ6Z=MzpsuG)Ci?*Rx zzdk*3s`^&6IOM^YF&tQru4=f&Hgk67Drl`hL{OebiYTLpc^*C=JMEgf{63ZvmN$hP zmHK3Il!jU|Vz}>fP1xT(^Hu1&xha7Mu1$^_Mx8kPTJb!hYR2#HwcHD8wNlf(jGEJ) z_a1fCbK#kGS_g_E_t$O@_%6ELrpNX77GI07+YN#x8`cD6H*A0WQCj^d!r%CiGClFK zLZ7Sv0!2|!tqjxAS+{m@W4%7Ht+8xdpS|BP+KT(=PLCkApN{{YY4;?fSL7lpkf$C~ zxlmTs67T<9LMNJGk_;E|I7_YhqiljSYt};Jdv{C;!HZpE9{-5NSHj=RBLFzhDcg>0 zR+(vSeAcxq%JWd!8BVCPU(?&GCkK#z15cZR>}Ahxla&?)e=%%kLpgsIgTa7PV!^r9 zLK=>xfr0C7sqe4Ya;{JUX-Wj)3IN&C9DlLD!aY8xN%YKZIx_ZN}kh~Nkm!v&!-LXHM|3M*`&06k-3gK~)E|15}xfw!wfv!ZK%@nUf^3<2aX-Ul-Em;S}gTE3e% zVwWUL%nDc|=YAN9g!F8DX=5|C;e2$5i-8+J=F6 z^gE%NtU53xk;7>bR~dtvU7LRPtuR-i0DQroh6bUIuZrWeHjIi|mwPiecO0 z2sJI;_1w}X7O+*Yxp040PcWskL9cd)>V0dgO|z=z=O}gdu$0hOmIp_7x5~?EJ{0N1 zOBsa*DFEtw5(2@p+XFOfpWN#{|532;#m<1HqxVzpCd>U1&)Jhbo>SIL<{DSmV0DH; zo#0dnd~~~?-Q3PPwFpPFve|9_R8^hfRlWHzv5~(q6H3GiiUs&r(Y1tIIrBs& zjhZBWwx5bzbr@`4JsI`N?3v9^{})hlKpV;TMVo9b-(@*5s#55tVug6OUOXfI5Jz*{ z>;WrEZQPo&6$cV0ZYEoQND`LWx~o=@;@|Yz+F8fvzqqcA=QL0j)=vZ4`~N9%+pAM# z1{A50XS7-`^!bOuy_K zabdS!%jy*S@)6R^Yi?)+br)U6*ss+vW_Em4=w}5&2*=*z`#P)w>}4K#XWq-5IYEsa zTKtFt`Oj9w#4bsIr{7=WB0Zq7chPr)Hz3cSBx4dMdo%`7fhMeaa z{+pLbVNpwx?>1A!In~a|1ixJ^c|X;|yLukSh8J)jGAE6lA9r_j>}f&btrd59Z3I znef%=;>dy8u*Z}t#kKcg*YM79`jTDzq3tjGfjwp@IUp+e#%MceRjvK@s&M1AeVXbP z!+o)6g3a--f9_*Oimp6fB$%ZsW^TT|fe>hg4m9%CKfsp*JjnQ$FU7VUWzW*aT2|)1 z4MpPBmwjN{)gcGmk=|nV+K=DbZnx!(hl~~P5?=;`(Btl#2R&~Fv`E_M63UUnoPAiO zw>RQGenZxw3+Lmh zhGLhPO}3RT+a~K2yUbWXh)hXY{rvf6K4hrk=zMYEk)x)vF)ejjzTXx*5=B z>*X5j(*dc?57!|uj5#(VIczIx_OOVd7fQeVP1u!uvSmvQp=VL6-mh|xFT9b8^z@_g zx%fmh9jo@B>SLr*ZpP#+4n?!@K7ZnW-ZCRUYurtGlVP7ifrcKPq>8I|Z zL=LTmj8SWIY7>W|L^8P`V-JR13s!*hGxO@EV`sZXFGA`%!Ita!NFSmjPc)_Zo;}+@ z!sC+pmrY<~8UgTC&CIejejV};H4NW@-VO8$DZQ$2tFCRmAhP>w*=<7!<5@4_#)vwp&s)_R_4Oa?AV zI%F;MC&I0r!=4c;03NWL4SvbV9C&YdrTuh#`@+M3P2N-^X+`9vZKzyNe42R`8x+xG z0KkmPdBI7n98g{kQ+K{dRGzN5@m+XW{W1 zn&os&l~T4jP+a_YJmOjS#f`@fhwu9vGoIaMHBLbE=c+HfEbtcDpL04fG`cA@GU>~T zdJkHbDKMyv6J3xt5cA>_HGp$f%_gtO;I7LK`JM+>xs`4jjP#<-{3f3CWT1blR*$># z=L3z0SrfMcoGt?^8-6OO^)yv-E=3}$v!d^EV$Ec3xE1@cF3GQneAg2$NJCWThf_fO zJW}1QZ&rd~riPGC9^kh}gss*tyzhgxXbMNAf1bYb^by>AV#F8kTf^VC{zUe4j1Y(y zCb?f)`J{vc{SMsgg=clAA3FwLus<*%h0t@<>X%lRUf4T%4dNl&V>4Bc#V4>u6PMuW zb3$PMqqJ7kC4eAeN*@&R1!dlE^(7L>E6~9jm6f2buaH2B>vDq|P)pSp9RBwpWLNq) zS;&0+HHK^Za18DYIvgxXu1y>ZjZ( zPeAq77sJVKT9b2bFwBS$Jyo&p~k#fiABMM~dYthQB zdikP^f3n`_bMpj_P|-`jPgM(}LmI*`*z!=(uf^{3A%QX%g#O9>*@b9ZOvmU14S@g7 zQNE|HeP{*Ok$P?lO1G{=rFYq#+?4RlEyhkm6MAjNH?5x^>X0Kf1pW0@=Dl& zo7)>PL)QGG?>$>sZ%@khEy6`rwT#90%HyL9p$OI=Kl-f2bvr6#m1VO@{~1lYZp}!@ zz;R6ms^X~u@W-eV8rKs=3WQR5(So|^7@;CuB>p7a$m}8H{T>R8teKcK9Q@Qsk7PIe zLrL8?Pi$4TC4}8Hg#5(csYekvt7ICgF;RvWOgr zk3`gM;Nn8eLpbl{9UW*k=A!Uoe0kHKHd=*uD1eJM?daep6)!QPq33ZWal}Q|+6qz+VDgy4zew2X1>6FZJ`3%^g~c$>5?? zqAGlbb=Fpi#p!-hMiGgPziX#-3V>mHl}(D~Y5DJBqpdb+ViFS)Vyb>F3In(Z`g!RF z=RFdGKmkcg`NG=7;`|I2!1L0?PxlV}>TE-bE-0*!sJY*;%95TgNC{n%&oc~&s@d~6 znN#Bi+Gd#<-%0a`Ym?3c!@$>Xw!unw565?#WEFnhaWHvtuco5CUvTt$45c;;@G&w~ zi00sZ|MyNW9#W`hhY#|f&O6`5`@183H*le2Qi&S?b;{>@4e2C4i z%~DbhbNKg?2Y@=tUMC-Q?I$>9D_UicMibh70%pQ^4q)L#Qq4v0)VoISP6CM)UlKgTJhkZ&3e4BCE z`l43e4M|kqTbMf0y%3=$al^Hq`!QqZ;bw!pgf%IKnvij^TvmFhsmYs)QKP)shpg$ z8o6jj2DgaS2or4lj;ak83$=VifP3MsjZ?h!U}n~NSXbSCg;P(uaY61Vpx zy`wR|a!{XnVNjdH14Z=e-KtCXKAebgQpai;ig|BSD&ZNs@1r9TUOZ&$88yLy?XNPY zCoqJK!G}}!5A?YqEvdp!xFM)1hOL%}G8tUVbDQnvd^aJoL3?dOfXyI<1#QkK zRYEHPdnlMDn17&k6!E?s6%RF^n3?8-pwdXw)l4m@sE0B_fsM1Q6W$M98Ka`mG7@9NMVM}cX9lak zoTG`uF*t#mtEl`cy(rVSBnOXB_J52TV&5_baNTr$+R$$r8$%0QF^PDN8~!DPM=_4<7Dj=#G!m>F!S&O%JRgS zwIqPSm+!#B=-NR`tGw=~`%C{(uTmx$a)=+UcPM0bS{2hZd?Xd>IepzdpPN3au|>`3 zFwegQpS@c9R4$%V8^W7fuP2JFH($ReOGv1oOz~86WhN(WX|)N4Az4*^I6Ji#a`-`u z9gbcsi<$EO_E9ma3M(cga$isyC4Gd8qQZe(Q}CRaIPYV^wTbIAn|aKo@(aGdJ@z#e zBwrdodz+YcVpmBM?dF*OnM9_h>+NwW2|e)$RidBvX#B)5Z(!zEMy5M~%-!m@1|;}E z7MvJ&W0%izxm8mCX_x#pbsA42>!>Toi4>~84}1Rk2N|AtD!Xv|otmk8g4BPAgagP3 z4=$}E>51_{xfIlHT@tu5;X{F*DYQIC5-I*~3?~pKam=tL#&b!lUN82!yv&@@or#@bGsJ;!}pKZL_(&$tHD4!3fn=4)KjMf zN2b{K4saZi{mbVdH=%uK**e&go*v9qUY)v0SF!tjb*^?+Qf*rTOOZqvq;s(|e z&=~FHaIfC@7o{$p3x1cb(p^v_Fln;5M7EG@Q5-%_A#QaXz zyR9GyXZlC@em30@TNcvZqLPVT#AED6LQ&&WXp8oRn*Z3SY1fV}At7+2JZ^iSW9ZnK zra2WpEx6x$Z4|BXV;b`|sxVm$pB@wyT~sft6#iFBp>Uu9KKUQTMjy>N=)b-sON(j4 zNA!8!ybhlb;p{%64WyZlf)F5zD*}1WKfj1zdPZB^jlp5*NWEFQ^dD;|A%J@Ky1>4|Et?VMv04l#7Ut5b`^GK{>v>c`W8}Dtr%cs zqu(UDV^#R_Qp|}vJ_6ADxWroSU$XYG%!NG0HP_gAf0*f=lT+=!PWmx{Q;U!ajzCMC zG3V*k^&~_)GBoNd8lUlhg=t%03G<_(g0!(c5~i4X;qgy^iUbimgdVN7V0Ix4S|=@c zIsfPe8i~BZo5Qnrl-C*HjFdA^^>Hzo)>j@9+eiH_vCF#K4sx%`yY90(X>IatO)I=v zL^7f8{k-ZwTe3rvgEFS<#UQ25Om|+X)-N6}6ZL-z8&%pMWj^?2d9q!-(Cg^)xEMTKYUx$$gFnU#{~YW0MouWr{v*c~xJ0%YeX`{XNN>$a-La9T|J&z9du~X9{!d$XXg$NvKPE5KW}$b4t-(x|%Q*+C{AH zyz_alu5AidM&sgQDCtLXP;+VHh&g(*M&;^Lc|+jE`%3hQfX!X(UmNgPNnNpA-aPpK E09s&InE(I) literal 0 HcmV?d00001 diff --git a/src/shared/agent-launch/choices/agent-launch-model-preferences.ts b/src/shared/agent-launch/choices/agent-launch-model-preferences.ts index 4bdfed3d9abd..6318f40b910f 100644 --- a/src/shared/agent-launch/choices/agent-launch-model-preferences.ts +++ b/src/shared/agent-launch/choices/agent-launch-model-preferences.ts @@ -7,6 +7,7 @@ import { getAgentSessionOptionLaunchCatalog } from '../../agent-session/options/agent-session-option-catalog' import { isPiModelOptionId } from '../../agent-session/options/catalog-providers/agent-session-option-catalog-pi' +import { parseDimaModelSelector } from '../../agent-session/options/model-catalog/dima-model-list-probe' import { resolveAgentSessionOptionLaunch } from '../../agent-session/options/launch/agent-session-option-launch' import type { TuiAgent } from '../catalog/tui-agent' @@ -67,6 +68,13 @@ export function checkAgentLaunchModelPreferences(args: { `Agent pi needs a provider/id model, such as anthropic/claude-sonnet-4-5; got ${args.model}.` ) } + // A bare id would run on whichever provider dima resolves; the picker always names one. + if (args.agent === 'dima' && !parseDimaModelSelector(args.model)) { + return refuse( + 'invalid_argument', + `Agent dima needs a provider/model selector, such as openai-codex/gpt-5.5; got ${args.model}.` + ) + } if (args.effort) { const model = findCatalogModel(catalog, args.model) diff --git a/src/shared/agent-session/options/agent-session-option-catalog.ts b/src/shared/agent-session/options/agent-session-option-catalog.ts index e787937f10fd..8899a6520d9c 100644 --- a/src/shared/agent-session/options/agent-session-option-catalog.ts +++ b/src/shared/agent-session/options/agent-session-option-catalog.ts @@ -7,6 +7,7 @@ import { CODEX_SESSION_OPTION_CATALOG } from './catalog-providers/agent-session-option-catalog-claude-codex' import { CURSOR_SESSION_OPTION_CATALOG } from './catalog-providers/agent-session-option-catalog-cursor' +import { DIMA_SESSION_OPTION_CATALOG } from './catalog-providers/agent-session-option-catalog-dima' import { GROK_SESSION_OPTION_CATALOG } from './catalog-providers/agent-session-option-catalog-grok' import { MUSE_SESSION_OPTION_CATALOG } from './catalog-providers/agent-session-option-catalog-muse' import { OMP_SESSION_OPTION_CATALOG } from './catalog-providers/agent-session-option-catalog-omp' @@ -25,6 +26,7 @@ const CATALOGS: AgentSessionOptionCatalogMap = { codebuddy: CODEBUDDY_SESSION_OPTION_CATALOG, codex: CODEX_SESSION_OPTION_CATALOG, cursor: CURSOR_SESSION_OPTION_CATALOG, + dima: DIMA_SESSION_OPTION_CATALOG, grok: GROK_SESSION_OPTION_CATALOG, muse: MUSE_SESSION_OPTION_CATALOG, omp: OMP_SESSION_OPTION_CATALOG diff --git a/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-dima.ts b/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-dima.ts new file mode 100644 index 000000000000..80319d8f6122 --- /dev/null +++ b/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-dima.ts @@ -0,0 +1,40 @@ +import { agentChoiceCliApply } from '../../../agent-launch/choices/agent-choice-cli-apply' +import type { AgentSessionOptionCatalog, CatalogModel } from './agent-session-option-catalog-types' +import { dimaModelLaunchArgs, parseDimaModelList } from '../model-catalog/dima-model-list-probe' + +/** Private enrichment-gate parser with option-free rows; actual probes run in main (agent-model-probe-spec.ts). */ +function parseDimaCatalogModels(stdout: string): CatalogModel[] { + return parseDimaModelList(stdout).map((model) => ({ ...model, options: [] })) +} + +export const DIMA_SESSION_OPTION_CATALOG: AgentSessionOptionCatalog = { + supportsWorkerLaunchPreferences: true, + // Models come from the providers dima is signed in to or holds keys for; ids are `provider/model` selectors. + models: [], + modelApply: { + ...agentChoiceCliApply( + 'dima', + [ + // Arguments never become a choice: a raw --model leans on a --provider or dima's own default. + { + kind: 'value', + names: ['--model'], + lift: 'separate-and-long-equals', + recognizes: () => false + }, + { + kind: 'value', + names: ['--provider'], + lift: 'separate-and-long-equals', + recognizes: () => false + } + ], + '--model' + ), + launchArgs: (value) => dimaModelLaunchArgs(String(value)) + }, + // Only a listing proves a selector; with no daemon to ask, saved picks stay and Default runs bare `dima`. + discoveredModelsAreAuthoritative: true, + // No dima command lists every provider's models; the gate names the App Server read main makes. + listModels: { command: 'provider.models.query', parse: parseDimaCatalogModels } +} diff --git a/src/shared/agent-session/options/model-catalog/agent-model-probe-spec.ts b/src/shared/agent-session/options/model-catalog/agent-model-probe-spec.ts index 3ffabe01ac3f..5e2b4c4b779b 100644 --- a/src/shared/agent-session/options/model-catalog/agent-model-probe-spec.ts +++ b/src/shared/agent-session/options/model-catalog/agent-model-probe-spec.ts @@ -41,6 +41,17 @@ const MODEL_DISCOVERY_ONLY_SPECS: Partial> // No OMP model is universal; use discovered first row when a default is required. models: [], defaultModelId: '' + }, + dima: { + id: 'dima', + label: 'DimAgent', + binary: 'dima', + modelSource: 'dynamic', + // No dima command lists every provider's models; its App Server does. + modelDiscovery: { binary: 'dima', listing: 'dima-app-server' }, + // No static list: dima's own default (a bare `dima`) is the only built-in choice. + models: [], + defaultModelId: '' } } diff --git a/src/shared/agent-session/options/model-catalog/dima-model-list-probe.test.ts b/src/shared/agent-session/options/model-catalog/dima-model-list-probe.test.ts new file mode 100644 index 000000000000..e2b651f314b9 --- /dev/null +++ b/src/shared/agent-session/options/model-catalog/dima-model-list-probe.test.ts @@ -0,0 +1,13 @@ +import { expect, it } from 'vitest' +import { dimaCatalogModels, dimaModelLaunchArgs } from './dima-model-list-probe' + +it('keeps the provider and full model id through a picker selection', () => { + const rows = dimaCatalogModels([ + { providerId: 'one', providerName: 'First', modelId: 'vendor/model', modelName: 'Chat' }, + { providerId: 'two', providerName: 'Second', modelId: 'vendor/model', modelName: 'Chat' } + ]) + expect(rows.map(({ id, label }) => [label, dimaModelLaunchArgs(id)])).toEqual([ + ['Chat · First', ['--provider', 'one', '--model', 'vendor/model']], + ['Chat · Second', ['--provider', 'two', '--model', 'vendor/model']] + ]) +}) diff --git a/src/shared/agent-session/options/model-catalog/dima-model-list-probe.ts b/src/shared/agent-session/options/model-catalog/dima-model-list-probe.ts new file mode 100644 index 000000000000..55ba1d7d80ce --- /dev/null +++ b/src/shared/agent-session/options/model-catalog/dima-model-list-probe.ts @@ -0,0 +1,125 @@ +import type { CommitMessageModel } from '../../../source-control/ai/generation/commit-message-agent-spec' +import { labelFromModelId } from './model-id-label' + +/** One selectable model as dima's App Server lists it. */ +export type DimaListedModel = { + providerId: string + providerName?: string + modelId: string + modelName?: string +} + +// oxlint-disable-next-line no-control-regex -- a control character would break the launch line +const CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/ +// A provider id ends at the first `/`. +const PROVIDER_ID = /^[^\s/]+$/ + +/** dim's own `PROVIDER/MODEL` reference: the provider ends at the first `/`, so model ids keep theirs. */ +export function dimaModelSelector(providerId: string, modelId: string): string | null { + return PROVIDER_ID.test(providerId) && + modelId !== '' && + !CONTROL_CHARACTER.test(providerId + modelId) + ? `${providerId}/${modelId}` + : null +} + +export function parseDimaModelSelector( + value: string +): { providerId: string; modelId: string } | null { + const slash = value.indexOf('/') + const providerId = value.slice(0, slash) + const modelId = value.slice(slash + 1) + return slash > 0 && dimaModelSelector(providerId, modelId) ? { providerId, modelId } : null +} + +/** `--provider` scopes `--model`; a bare id runs on dima's effective provider. */ +export function dimaModelLaunchArgs(value: string): string[] { + const selector = parseDimaModelSelector(value) + return selector + ? ['--provider', selector.providerId, '--model', selector.modelId] + : ['--model', value] +} + +function isRecord(value: unknown): value is Record { + return typeof value === 'object' && value !== null && !Array.isArray(value) +} + +function text(value: unknown): string | undefined { + return typeof value === 'string' ? value : undefined +} + +/** Selectable rows of one `provider.models.query` page and its cursor; disabled and unavailable rows stay out. */ +export function dimaQueryPageModels(page: unknown): { models: DimaListedModel[]; next: unknown } { + const reply = isRecord(page) ? page : null + const rows = Array.isArray(reply?.models) ? reply.models : [] + const models = rows.flatMap((value: unknown): DimaListedModel[] => { + const row = isRecord(value) ? value : null + const model = isRecord(row?.model) ? row.model : null + const providerId = text(row?.providerId) + const modelId = text(model?.id) + // selectableOnly already omits them; dim's own picker checks again. + if (!providerId || !modelId || row?.disabled === true || model?.unavailableReason != null) { + return [] + } + return [ + { providerId, providerName: text(row?.providerName), modelId, modelName: text(model?.name) } + ] + }) + return { models, next: reply?.next ?? null } +} + +/** Selectable models of one provider's `provider.catalog` reply, for daemons without provider.models.query. */ +export function dimaCatalogReplyModels( + provider: { providerId: string; providerName?: string }, + reply: unknown +): DimaListedModel[] { + const catalog = isRecord(reply) && isRecord(reply.catalog) ? reply.catalog : null + const disabled = new Set( + Array.isArray(catalog?.disabledModelIds) + ? catalog.disabledModelIds.filter((id): id is string => typeof id === 'string') + : [] + ) + const rows = Array.isArray(catalog?.models) ? catalog.models : [] + return rows.flatMap((value: unknown): DimaListedModel[] => { + const model = isRecord(value) ? value : null + const modelId = text(model?.id) + return !modelId || disabled.has(modelId) || model?.unavailableReason != null + ? [] + : [{ ...provider, modelId, modelName: text(model?.name) }] + }) +} + +/** Picker rows keyed by provider; the provider's name tells one model id apart across providers. */ +export function dimaCatalogModels(rows: readonly DimaListedModel[]): CommitMessageModel[] { + const byId = new Map() + for (const row of rows) { + const id = dimaModelSelector(row.providerId, row.modelId) + if (!id || byId.has(id)) { + continue + } + const name = row.modelName?.trim() || labelFromModelId(row.modelId) + const provider = row.providerName?.trim() || row.providerId + byId.set(id, { + id, + label: `${name} · ${provider}`, + description: row.providerId + }) + } + const models = [...byId.values()] + const labelCounts = new Map() + for (const model of models) { + labelCounts.set(model.label, (labelCounts.get(model.label) ?? 0) + 1) + } + return models.map((model) => + labelCounts.get(model.label) === 1 ? model : { ...model, label: `${model.label} (${model.id})` } + ) +} + +/** One `provider.models.query` page (JSON) as picker rows. */ +export function parseDimaModelList(stdout: string): CommitMessageModel[] { + try { + return dimaCatalogModels(dimaQueryPageModels(JSON.parse(stdout)).models) + } catch { + return [] + } +} diff --git a/src/shared/native-chat/input/session-options/native-chat-discovered-catalog-models.ts b/src/shared/native-chat/input/session-options/native-chat-discovered-catalog-models.ts index 40d66d942afe..56e4ffbd9bcd 100644 --- a/src/shared/native-chat/input/session-options/native-chat-discovered-catalog-models.ts +++ b/src/shared/native-chat/input/session-options/native-chat-discovered-catalog-models.ts @@ -27,7 +27,7 @@ export function catalogModelsFromModelDiscovery( ): CatalogModel[] | null { if ( !result.success || - result.models.length === 0 || + (result.models.length === 0 && agent !== 'dima') || // Static fallback lists cannot stand in for the host's authoritative inventory. ((agent === 'claude' || getAgentSessionOptionCatalog(agent)?.discoveredModelsAreAuthoritative) && diff --git a/src/shared/source-control/ai/generation/commit-message-agent-spec.ts b/src/shared/source-control/ai/generation/commit-message-agent-spec.ts index 8953462a67d9..5e178a7b9f01 100644 --- a/src/shared/source-control/ai/generation/commit-message-agent-spec.ts +++ b/src/shared/source-control/ai/generation/commit-message-agent-spec.ts @@ -87,6 +87,11 @@ export type CommitMessageAgentSpec = { /** Listed over the CLI's app-server `model/list`; main owns the app-server arguments. */ listing: 'codex-app-server' } + | { + binary: string + /** Read from the dima daemon already running; main never starts one. */ + listing: 'dima-app-server' + } models: CommitMessageModel[] defaultModelId: string } From dee4969394371ca880973d9b39faf5484aef2ae4 Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Wed, 25 Nov 2026 02:11:33 -0800 Subject: [PATCH 03/10] fix: load DimAgent models when the launch picker opens Request the listing after the local inventory is ready. Use the shell's DimAgent home and keep selectable models from readable providers on alpha.25. Apply dima's per-frame protocol limit and retain saved choices when only part of the catalog responds. --- .../commit-message-agent-environment.ts | 12 ++-- .../models/dima-model-list-discovery.ts | 50 ++++++++++------ .../source-control-text-generation-types.ts | 2 + .../api/source-control/git-inspection-api.ts | 2 + .../agent/AgentLaunchSetupPanel.tsx | 10 +--- .../agent/AgentPickerRefreshModelsButton.tsx | 18 +----- .../agent-launch-picker-cli-model-catalog.ts | 7 ++- .../agent/agent-launch-setup-option-rows.ts | 3 +- .../agent/use-setup-model-listing.test.tsx | 59 +++++++++++++++++++ .../agent/use-setup-model-listing.ts | 26 ++++++++ .../git/runtime-git-client-context.ts | 2 + .../picker/agent-launch-picker-authority.ts | 1 + .../picker/agent-launch-picker.ts | 2 +- 13 files changed, 142 insertions(+), 52 deletions(-) create mode 100644 src/renderer/src/components/agent/use-setup-model-listing.test.tsx create mode 100644 src/renderer/src/components/agent/use-setup-model-listing.ts diff --git a/src/main/text-generation/execution/commit-message-agent-environment.ts b/src/main/text-generation/execution/commit-message-agent-environment.ts index 0dbbf2ef1566..06bbee643f35 100644 --- a/src/main/text-generation/execution/commit-message-agent-environment.ts +++ b/src/main/text-generation/execution/commit-message-agent-environment.ts @@ -64,11 +64,13 @@ function prepareShellConfigDirEnv( const configVar = agentId === 'opencode' || agentId === 'opencode2' ? 'OPENCODE_CONFIG_DIR' - : agentId === 'pi' || agentId === 'omp' - ? 'PI_CODING_AGENT_DIR' - : agentId === 'grok' - ? 'GROK_HOME' - : null + : agentId === 'dima' + ? 'DIMCODE_HOME' + : agentId === 'pi' || agentId === 'omp' + ? 'PI_CODING_AGENT_DIR' + : agentId === 'grok' + ? 'GROK_HOME' + : null if (!configVar) { return null } diff --git a/src/main/text-generation/models/dima-model-list-discovery.ts b/src/main/text-generation/models/dima-model-list-discovery.ts index 8074900fdeb5..1032b4b9d084 100644 --- a/src/main/text-generation/models/dima-model-list-discovery.ts +++ b/src/main/text-generation/models/dima-model-list-discovery.ts @@ -13,10 +13,11 @@ import { } from '../../../shared/agent-session/options/model-catalog/dima-model-list-probe' import type { AgentModelProbeSpec } from '../../../shared/agent-session/options/model-catalog/agent-model-probe-spec' import { isProviderRecord } from '../../provider-process/provider-json-record' -import { MAX_SOURCE_CONTROL_AGENT_OUTPUT_BYTES } from '../execution/source-control-generation-limits' import { staticModelDiscoveryResult } from './commit-message-model-discovery-policy' import type { DiscoverCommitMessageModelsResult } from '../source-control-text-generation-types' +// dima's native client accepts up to 16 MiB per JSON frame, including a full provider catalog. +const DIMA_FRAME_BYTES = 16 * 1024 * 1024 const PROBE_TIMEOUT_MS = 10_000 const PAGE_LIMIT = 128 const MAX_PAGES = 64 @@ -94,7 +95,6 @@ function openDaemon(endpoint: string, signal: AbortSignal): Promise void>() const decoder = new StringDecoder('utf8') let nextId = 0 - let received = 0 const close = (): void => { socket.destroy() } @@ -109,14 +109,9 @@ function openDaemon(endpoint: string, signal: AbortSignal): Promise { - received += chunk.byteLength - if (received > MAX_SOURCE_CONTROL_AGENT_OUTPUT_BYTES) { - close() - return - } framer.feed(decoder.write(chunk)) }) socket.on('error', () => settle(null)) @@ -222,7 +217,8 @@ function listedProviders(value: unknown): ListedProvider[] { } /** Older daemons' picker read: enabled static providers and signed-in accounts, then each stored catalog. */ -async function readProviderCatalogs(call: DaemonCall): Promise { +async function readProviderCatalogs(call: DaemonCall) { + let partial = false const providers = new Map() for (const provider of listedProviders( result(await call('provider.list', {}), 'provider.list') @@ -231,24 +227,37 @@ async function readProviderCatalogs(call: DaemonCall): Promise diff --git a/src/renderer/src/components/agent/AgentLaunchSetupPanel.tsx b/src/renderer/src/components/agent/AgentLaunchSetupPanel.tsx index 1e2023b784e6..dcef1d8f3683 100644 --- a/src/renderer/src/components/agent/AgentLaunchSetupPanel.tsx +++ b/src/renderer/src/components/agent/AgentLaunchSetupPanel.tsx @@ -8,7 +8,7 @@ import { AgentPickerLegacyModelsToggle } from './AgentPickerLegacyModelsToggle' import { useLegacyModelsExpanded } from './use-legacy-models-expanded' import { AgentLaunchInstallPrompt } from './AgentLaunchInstallPrompt' import { AgentPickerRefreshModelsButton } from './AgentPickerRefreshModelsButton' -import { retryAgentPickerCatalog } from './agent-launch-picker-acquisition' +import { useSetupModelListing } from './use-setup-model-listing' import { AgentPickerChoiceRows, AgentPickerSearchResults, @@ -85,6 +85,7 @@ export function AgentLaunchSetupPanel({ search, children }: AgentLaunchSetupPanelProps) { + const retryModels = useSetupModelListing(entry) const t = useTranslate() const footer = useRef(null) // Why: cmdk runs a row's onSelect for both Enter and a click; only Enter also closes. @@ -292,12 +293,7 @@ export function AgentLaunchSetupPanel({ > {catalogMessage} {state.catalogRetryable && ownerKey ? ( - ) : null} diff --git a/src/renderer/src/components/agent/AgentPickerRefreshModelsButton.tsx b/src/renderer/src/components/agent/AgentPickerRefreshModelsButton.tsx index cb9eb8af2918..d5090e94016f 100644 --- a/src/renderer/src/components/agent/AgentPickerRefreshModelsButton.tsx +++ b/src/renderer/src/components/agent/AgentPickerRefreshModelsButton.tsx @@ -24,25 +24,9 @@ export function AgentPickerRefreshModelsButton({ const spin = useRef>(undefined) useEffect(() => () => clearTimeout(spin.current), []) const { ownerKey } = entry - const installed = entry.surfaces.length > 0 - // DimAgent shares a persistent daemon with its terminal. Start discovery only when its own - // setup is open and the initial inventory read has settled. - const dimaSetup = useRef(undefined) - useEffect(() => { - if (entry.agent !== 'dima' || !installed || !ownerKey) { - dimaSetup.current = undefined - } else if ( - dimaSetup.current !== ownerKey && - entry.catalogRead !== 'pending' && - entry.catalogRead !== 'unsupported' - ) { - dimaSetup.current = ownerKey - retryAgentPickerCatalog(ownerKey, 'dima', true) - } - }, [entry.agent, entry.catalogRead, installed, ownerKey]) if ( !ownerKey || - !installed || + !entry.surfaces.length || entry.catalogRead === 'unsupported' || (entry.agent !== 'dima' && !keepsRicherAgentModelListing(entry.agent)) ) { diff --git a/src/renderer/src/components/agent/agent-launch-picker-cli-model-catalog.ts b/src/renderer/src/components/agent/agent-launch-picker-cli-model-catalog.ts index 104f0904fbc4..ca00b5df5b0a 100644 --- a/src/renderer/src/components/agent/agent-launch-picker-cli-model-catalog.ts +++ b/src/renderer/src/components/agent/agent-launch-picker-cli-model-catalog.ts @@ -1,4 +1,3 @@ -import type { AgentSessionModelCatalogResult } from '../../../../shared/agent-session/agent-session-wire' import { getAgentSessionOptionCatalog } from '../../../../shared/agent-session/options/agent-session-option-catalog' import type { AgentPickerEntry } from '../../../../shared/agent-launch/picker/agent-launch-picker' import { agentPickerModelFromCatalogModel } from '../../../../shared/agent-launch/picker/agent-launch-picker-catalog' @@ -21,12 +20,15 @@ export function agentPickerListsCliModels(entry: Pick export async function readAgentPickerCliModelCatalog( agent: AgentPickerEntry['agent'], runtime: RuntimeGitContext -): Promise { +): Promise { const catalog = getAgentSessionOptionCatalog(agent) if (!catalog) { return { origin: 'unknown' } } const result = await discoverRuntimeCommitMessageModels(runtime, agent) + if (!result.success && agent === 'dima') { + return { origin: 'unknown', discoveryError: result.error } + } // Only a real listing may replace the seed: the picker retires saved picks missing from it. const discovered = result.success && result.catalogOrigin === 'probe' @@ -36,6 +38,7 @@ export async function readAgentPickerCliModelCatalog( ? { origin: 'probe', fetchedAt: Date.now(), + ...(result.success && result.partial ? { partial: true as const } : {}), models: mergeDiscoveredCatalogModels(agent, catalog, discovered).map( agentPickerModelFromCatalogModel ) diff --git a/src/renderer/src/components/agent/agent-launch-setup-option-rows.ts b/src/renderer/src/components/agent/agent-launch-setup-option-rows.ts index 59561d19a460..51f9b231ef3f 100644 --- a/src/renderer/src/components/agent/agent-launch-setup-option-rows.ts +++ b/src/renderer/src/components/agent/agent-launch-setup-option-rows.ts @@ -245,7 +245,8 @@ export function agentLaunchSetupCatalogState( '{{agent}} models are unavailable on this host. Your current choices still apply.', { agent: entry.label } ) - : (missing ?? + : (entry.catalog.discoveryError ?? + missing ?? (settled && !hasModels ? t('agentPicker.catalogEmpty', '{{agent}} has no available models.', { agent: entry.label diff --git a/src/renderer/src/components/agent/use-setup-model-listing.test.tsx b/src/renderer/src/components/agent/use-setup-model-listing.test.tsx new file mode 100644 index 000000000000..db33abaa76d9 --- /dev/null +++ b/src/renderer/src/components/agent/use-setup-model-listing.test.tsx @@ -0,0 +1,59 @@ +// @vitest-environment happy-dom +import { useEffect, useState } from 'react' +import { cleanup, render, waitFor } from '@testing-library/react' +import { afterEach, expect, it } from 'vitest' +import type { AgentPickerEntry } from '../../../../shared/agent-launch/picker/agent-launch-picker' +import { observeAgentPickerAcquisition } from './agent-launch-picker-acquisition' +import { useSetupModelListing } from './use-setup-model-listing' + +afterEach(cleanup) + +it('delivers a cold DimAgent read when the setup mounts before its acquisition', async () => { + const key = 'dim-local-workspace' + const seed: AgentPickerEntry = { + agent: 'dima', + label: 'DimAgent', + rows: [], + surfaces: ['terminal'], + defaultSurface: 'terminal', + terminal: {}, + structured: {}, + catalog: { origin: 'unknown' }, + ownerKey: key + } + const model = { id: 'provider/model', label: 'Model', isDefault: false, efforts: [] } + let observed: AgentPickerEntry = seed + + function Setup({ entry }: { entry: AgentPickerEntry }) { + useSetupModelListing(entry) + return null + } + + function Workspace() { + const [entry, setEntry] = useState(seed) + useEffect( + () => + observeAgentPickerAcquisition( + key, + [seed], + { + catalog: async (_entry, _wait, _signal, relist) => + relist ? { origin: 'probe', fetchedAt: 1, models: [model] } : { origin: 'unknown' }, + support: async () => undefined + }, + { + publish: ([next]) => { + observed = next + setEntry(next) + }, + selected: () => 'dima' + } + ), + [] + ) + return + } + + render() + await waitFor(() => expect(observed.catalog).toMatchObject({ origin: 'probe', models: [model] })) +}) diff --git a/src/renderer/src/components/agent/use-setup-model-listing.ts b/src/renderer/src/components/agent/use-setup-model-listing.ts new file mode 100644 index 000000000000..c626dd20544c --- /dev/null +++ b/src/renderer/src/components/agent/use-setup-model-listing.ts @@ -0,0 +1,26 @@ +import { useEffect, useRef } from 'react' +import type { AgentPickerEntry } from '../../../../shared/agent-launch/picker/agent-launch-picker' +import { retryAgentPickerCatalog } from './agent-launch-picker-acquisition' + +/** Only the visible setup may start dima's persistent daemon on a cold read. */ +export function useSetupModelListing(entry: AgentPickerEntry): () => void { + const requested = useRef(undefined) + const { agent, ownerKey, catalogRead } = entry + useEffect(() => { + if (agent !== 'dima' || !ownerKey || catalogRead === undefined) { + requested.current = undefined + return + } + // A seed has no acquisition yet. Its first settled publication proves where to send the read. + if (catalogRead === 'settled' && requested.current !== ownerKey) { + requested.current = ownerKey + retryAgentPickerCatalog(ownerKey, agent, true) + } + }, [agent, ownerKey, catalogRead]) + + return () => { + if (ownerKey) { + retryAgentPickerCatalog(ownerKey, agent) + } + } +} diff --git a/src/renderer/src/runtime/source-control/git/runtime-git-client-context.ts b/src/renderer/src/runtime/source-control/git/runtime-git-client-context.ts index a07590a9cf5b..00c5dbfb7836 100644 --- a/src/renderer/src/runtime/source-control/git/runtime-git-client-context.ts +++ b/src/renderer/src/runtime/source-control/git/runtime-git-client-context.ts @@ -54,6 +54,8 @@ export type RuntimeDiscoverCommitMessageModelsResult = defaultModelId: string /** Missing only when an older remote runtime produced the response. */ catalogOrigin?: 'probe' | 'spec' + /** Some providers could not be read. Their saved choices are still valid. */ + partial?: true } | { success: false; error: string } diff --git a/src/shared/agent-launch/picker/agent-launch-picker-authority.ts b/src/shared/agent-launch/picker/agent-launch-picker-authority.ts index 701cfed11e83..f908fd3ac246 100644 --- a/src/shared/agent-launch/picker/agent-launch-picker-authority.ts +++ b/src/shared/agent-launch/picker/agent-launch-picker-authority.ts @@ -10,6 +10,7 @@ export function agentPickerCatalogAuthoritative( (entry.catalogRead === undefined || entry.catalogRead === 'settled') && entry.catalog.origin !== 'unknown' && !entry.catalog.listingInProgress && + !entry.catalog.partial && // A refused Command does not make the account's listed models any less current. (unavailable === undefined || unavailable.reason === 'agentCommandNotRunnable') ) diff --git a/src/shared/agent-launch/picker/agent-launch-picker.ts b/src/shared/agent-launch/picker/agent-launch-picker.ts index a90dae087932..83c3f969fa55 100644 --- a/src/shared/agent-launch/picker/agent-launch-picker.ts +++ b/src/shared/agent-launch/picker/agent-launch-picker.ts @@ -42,7 +42,7 @@ export type AgentPickerEntry = { terminal: AgentDedicatedChoices structured: AgentDedicatedChoices arguments?: string | null - catalog: AgentSessionModelCatalogResult + catalog: AgentSessionModelCatalogResult & { partial?: true; discoveryError?: string } coherentCatalog?: boolean catalogRead?: 'pending' | 'settled' | 'failed' | 'unsupported' ownerKey?: string From d42dd692cb5e324b754944fbd865606030b325a7 Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Wed, 25 Nov 2026 03:35:31 -0800 Subject: [PATCH 04/10] feat(dima): chat with DimAgent natively over ACP Register `dima acp` (0.1.0-alpha.25 and later) as a native Chat agent on the generic ACP runtime: streaming, tool approvals, cancel, session load and reopen, and the session's own model, effort and mode options. Orca never forwards the terminal's --provider/--model. Ask, Accept edits and Full access map to dima's read-only, workspace-write and full-access presets, and the Ask description says read-only refuses edits and commands instead of asking. The launch form keeps listing dima's terminal provider/model selectors, including one model id offered by two providers. Launch chat runs a selector under that provider's own model id when the complete listing shows only that provider offering it. Otherwise it explains why and keeps the form open. A host's chat catalog never fills the form, and the terminal Settings default no longer seeds chats. Co-Authored-By: Claude Opus 5.5 --- .../protected-copy-keys.mjs | 1 + src/main/acp/acp-dialects/dima-dialect.ts | 24 +++++++++ src/main/acp/launch/acp-launch-registry.ts | 4 +- ...ot-session-instructions-each-start.test.ts | 3 +- src/main/dima/dima-acp-launch-spec.ts | 49 +++++++++++++++++++ .../naming/structured-chat-naming-runtime.ts | 3 +- .../AgentSessionContinuationDialog.tsx | 15 +++++- .../agent-launch-picker-chat-model-refusal.ts | 43 ++++++++++++++++ .../agent-launch-picker-cli-model-catalog.ts | 8 ++- .../agent/agent-launch-picker-host-reads.ts | 7 ++- .../agent/launch-menu/AgentMenuItems.tsx | 10 ++++ .../use-agent-launch-picker-inventory.ts | 3 +- .../native-chat-permission-mode-labels.ts | 9 +++- src/renderer/src/i18n/locales/en.json | 4 ++ .../agent-chat-permission-support.ts | 7 ++- .../picker/agent-launch-picker-chat-model.ts | 25 ++++++++++ .../picker/agent-launch-picker.ts | 17 ++++++- .../launch/agent-session-setup-commands.ts | 7 +++ .../agent-session-option-catalog-dima.ts | 12 ++++- .../agent-session-option-catalog-types.ts | 3 ++ .../dima-model-list-probe.test.ts | 14 ++++++ .../presentation/agent-type-label.ts | 1 + .../commands/native-chat-agent-profiles.ts | 4 +- .../native-chat-session-option-defaults.ts | 7 ++- .../languages/protected-copy-keys.json | 1 + 25 files changed, 265 insertions(+), 16 deletions(-) create mode 100644 src/main/acp/acp-dialects/dima-dialect.ts create mode 100644 src/main/dima/dima-acp-launch-spec.ts create mode 100644 src/renderer/src/components/agent/agent-launch-picker-chat-model-refusal.ts create mode 100644 src/shared/agent-launch/picker/agent-launch-picker-chat-model.ts diff --git a/config/scripts/localization/catalog-validation/protected-copy-keys.mjs b/config/scripts/localization/catalog-validation/protected-copy-keys.mjs index 1e2f7670e43b..63ca44c10477 100644 --- a/config/scripts/localization/catalog-validation/protected-copy-keys.mjs +++ b/config/scripts/localization/catalog-validation/protected-copy-keys.mjs @@ -59,6 +59,7 @@ export const PINNED_PROTECTED_COPY = [ 'components.native-chat.composer.permissionAppliesNextMessage', 'components.native-chat.composer.permissionAsk', 'components.native-chat.composer.permissionAskDescription', + 'components.native-chat.composer.permissionAskReadOnlyDescription', 'components.native-chat.composer.permissionAskSharedDescription', 'components.native-chat.composer.permissionAuto', 'components.native-chat.composer.permissionAutoDescription', diff --git a/src/main/acp/acp-dialects/dima-dialect.ts b/src/main/acp/acp-dialects/dima-dialect.ts new file mode 100644 index 000000000000..4026d360ef9c --- /dev/null +++ b/src/main/acp/acp-dialects/dima-dialect.ts @@ -0,0 +1,24 @@ +import { z } from 'zod' +import { readAcpPermissionRequest } from '../protocol/acp-permission-requests' +import { acpPermissionPresentation } from '../requests/acp-timeline-requests' +import type { AcpDialect, AcpRequestPresentation } from './acp-dialect' + +const approvalInputSchema = z.looseObject({ + command: z.string().optional(), + path: z.string().optional(), + url: z.string().optional() +}) +const ACTION_MAX_CHARS = 512 + +// An approval is titled with the preset's reason; what it would run or touch is only in its input. +function approvalRequest(method: string, params: unknown): AcpRequestPresentation | undefined { + const request = + method === 'session/request_permission' ? readAcpPermissionRequest(params, () => {}) : null + const input = approvalInputSchema.safeParse(request?.toolCall.rawInput).data + const action = input?.command ?? input?.path ?? input?.url + return action ? acpPermissionPresentation(params, action.slice(0, ACTION_MAX_CHARS)) : undefined +} + +export const DIMA_ACP_DIALECT: AcpDialect = { + request: approvalRequest +} diff --git a/src/main/acp/launch/acp-launch-registry.ts b/src/main/acp/launch/acp-launch-registry.ts index 4de238f3edd2..e5e9b5b4edc8 100644 --- a/src/main/acp/launch/acp-launch-registry.ts +++ b/src/main/acp/launch/acp-launch-registry.ts @@ -43,6 +43,7 @@ import { QWEN_CODE_LAUNCH_SPEC } from '../../qwen-code/qwen-code-acp-launch-spec import { CLINE_LAUNCH_SPEC } from '../../cline/cline-acp-launch-spec' import { DEVIN_LAUNCH_SPEC } from '../../devin/devin-acp-launch-spec' import { CODEBUDDY_LAUNCH_SPEC } from '../../codebuddy/codebuddy-acp-launch-spec' +import { DIMA_LAUNCH_SPEC } from '../../dima/dima-acp-launch-spec' import type { AcpLaunchSpec } from './acp-launch-contract' import { OPENCODE_MINIMUM_VERSIONS, OPENCODE2_MINIMUM_VERSIONS } from './acp-minimum-versions' @@ -186,7 +187,8 @@ export const ACP_LAUNCH_SPECS: readonly AcpLaunchSpec[] = [ QWEN_CODE_LAUNCH_SPEC, CLINE_LAUNCH_SPEC, DEVIN_LAUNCH_SPEC, - CODEBUDDY_LAUNCH_SPEC + CODEBUDDY_LAUNCH_SPEC, + DIMA_LAUNCH_SPEC ] export function acpLaunchSpecFor(agent: string): AcpLaunchSpec | null { diff --git a/src/main/bots/bot-session-instructions-each-start.test.ts b/src/main/bots/bot-session-instructions-each-start.test.ts index 5f036db59ecd..58473f62c0e7 100644 --- a/src/main/bots/bot-session-instructions-each-start.test.ts +++ b/src/main/bots/bot-session-instructions-each-start.test.ts @@ -41,7 +41,8 @@ describe('standing instructions on every start', () => { 'qwen-code': true, cline: true, devin: false, - codebuddy: true + codebuddy: true, + dima: false }) }) diff --git a/src/main/dima/dima-acp-launch-spec.ts b/src/main/dima/dima-acp-launch-spec.ts new file mode 100644 index 000000000000..1f163076f209 --- /dev/null +++ b/src/main/dima/dima-acp-launch-spec.ts @@ -0,0 +1,49 @@ +import { join } from 'node:path' +import type { AcpLaunchSpec } from '../acp/launch/acp-launch-contract' +import { DIMA_ACP_DIALECT } from '../acp/acp-dialects/dima-dialect' +import { directoryAccountBinding } from '../acp/launch/acp-account-binding' +import { agentSessionSetupFor } from '../../shared/agent-session/lifecycle/launch/agent-session-setup-commands' +import type { StructuredAgentSessionHistory } from '../native-chat/conversation-adoption/structured-agent-cli-conversations' +import type { PublishSharedToolProcessSessionEnv } from '../runtime/agent-session/environment/shared-tool-process-session-env' + +// Orca lists no dima sessions in Session History, and its terminals reopen them from dima's picker. +const DIMA_SESSION_HISTORY: StructuredAgentSessionHistory = { + rowAgents: [], + rowSessionId: (link) => link.handle.nativeId, + parseResumeArgs: () => null +} + +// Every session's tools run in dima's one daemon, and 0.1.0-alpha.25 has no per-session environment, +// so they keep no chat's identity rather than the one the daemon started with. +const publishDimaSessionToolEnv: PublishSharedToolProcessSessionEnv = async ({ mustReach }) => { + if (mustReach) { + throw new Error("dima's shared daemon cannot give one session's tools their own identity") + } + return async () => undefined +} + +export const DIMA_LAUNCH_SPEC: AcpLaunchSpec = { + agent: 'dima', + command: 'dima', + // No --provider/--model: the chat picks from its session's own model option. + args: () => ['acp'], + env: {}, + dialect: DIMA_ACP_DIALECT, + loginCommand: agentSessionSetupFor('dima')?.loginCommand ?? [], + // dimcode-alpha keeps sign-in, providers, settings and sessions under ~/.dimcode-alpha. + account: directoryAccountBinding('DIMCODE_HOME', (homePath) => join(homePath, '.dimcode-alpha')), + installDirectories: () => [], + // The oldest release checked to serve ACP chats. + minimumVersions: ['0.1.0-alpha.25'], + // dima enforces its session presets: read-only refuses edits and commands instead of asking, and + // workspace-write allows workspace edits but asks before commands. + permissionModeConfig: { + values: { ask: 'read-only', 'accept-edits': 'workspace-write', 'full-access': 'full-access' } + }, + // A listing session is deleted afterwards. Its ids are native, and dima omits ids two providers share. + modelDiscovery: { kind: 'session', listingNamesConfiguredModel: false, listsOnDemand: true }, + compaction: true, + transcriptImport: null, + sessionHistory: DIMA_SESSION_HISTORY, + sharedToolProcess: { publishSessionEnv: publishDimaSessionToolEnv } +} diff --git a/src/main/runtime/agent-session/naming/structured-chat-naming-runtime.ts b/src/main/runtime/agent-session/naming/structured-chat-naming-runtime.ts index f2dc5135c2da..e42c5f1680f4 100644 --- a/src/main/runtime/agent-session/naming/structured-chat-naming-runtime.ts +++ b/src/main/runtime/agent-session/naming/structured-chat-naming-runtime.ts @@ -91,7 +91,8 @@ export function structuredChatNamingDeps( 'qwen-code', 'cline', 'devin', - 'codebuddy' + 'codebuddy', + 'dima' ].includes(record.provider) ) { return null diff --git a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx index 012230e94a09..da2970dd6d04 100644 --- a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx +++ b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx @@ -4,6 +4,7 @@ import { worktreeLaunchWorkspace } from '@/lib/agent-session/launch/routing/agen import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react' import { Loader2 } from 'lucide-react' import { AgentLaunchPicker } from '@/components/agent/AgentLaunchPicker' +import { agentPickerChatLaunchRefusal } from '@/components/agent/agent-launch-picker-chat-model-refusal' import { agentPickerFreshLaunchInputs, type AgentPickerDraft, @@ -178,6 +179,10 @@ export function AgentSessionContinuationDialog({ defaultAgent: settings?.defaultTuiAgent }) const selection = observation.selectionFor(selectedAgent, currentPick?.surface) + const chatModelRefusal = + currentPick?.draft && currentPick.entry && selection.choice?.route !== 'terminal-tui' + ? agentPickerChatLaunchRefusal(currentPick.entry, currentPick.draft) + : null useEffect(() => { if (!starting) { @@ -196,7 +201,8 @@ export function AgentSessionContinuationDialog({ !selectedAgent || starting || !selection.ready || - !selection.choice + !selection.choice || + chatModelRefusal ) { return } @@ -241,7 +247,11 @@ export function AgentSessionContinuationDialog({ ? getAgentLabel(request.source.sourceAgent) : null const startDisabled = - controlsDisabled || agents.length === 0 || !selectedAgent || !selection.ready + controlsDisabled || + agents.length === 0 || + !selectedAgent || + !selection.ready || + Boolean(chatModelRefusal) const sourceLabel = sourceName || t('components.agentSessionContinuation.untitledSession', 'Current session') @@ -320,6 +330,7 @@ export function AgentSessionContinuationDialog({ } /> {agentStatus ?

{agentStatus}

: null} + {chatModelRefusal ? {chatModelRefusal} : null} {detectionFailed && !preparing && !detecting ? ( {t( diff --git a/src/renderer/src/components/agent/agent-launch-picker-chat-model-refusal.ts b/src/renderer/src/components/agent/agent-launch-picker-chat-model-refusal.ts new file mode 100644 index 000000000000..b80bfbf5e019 --- /dev/null +++ b/src/renderer/src/components/agent/agent-launch-picker-chat-model-refusal.ts @@ -0,0 +1,43 @@ +import { translate } from '@/i18n/i18n' +import { agentPickerChatLaunchModel } from '../../../../shared/agent-launch/picker/agent-launch-picker-chat-model' +import type { + AgentPickerDraft, + AgentPickerEntry +} from '../../../../shared/agent-launch/picker/agent-launch-picker' + +/** Why a chat launch can't run the form's model pick, or null when it can. */ +export function agentPickerChatLaunchRefusal( + entry: AgentPickerEntry, + draft: Pick +): string | null { + const picked = draft.choices.model + const result = agentPickerChatLaunchModel(entry, picked) + if (!('refusal' in result)) { + return null + } + const listed = + entry.catalog.origin === 'unknown' + ? undefined + : entry.catalog.models.find((model) => model.id === picked) + const values = { agent: entry.label, model: listed?.label ?? picked } + switch (result.refusal) { + case 'shared': + return translate( + 'agentPicker.chatModelShared', + "A {{agent}} chat can't pick {{model}} because another provider offers the same model. Launch it in a terminal, or pick another model.", + values + ) + case 'unlisted': + return translate( + 'agentPicker.chatModelUnlisted', + "{{model}} isn't in {{agent}}'s model list, so a chat can't run it. Pick another model.", + values + ) + case 'unproven': + return translate( + 'agentPicker.chatModelUnproven', + "{{agent}}'s model list hasn't finished loading, so a chat can't confirm {{model}} yet. Try again in a moment, or launch it in a terminal.", + values + ) + } +} diff --git a/src/renderer/src/components/agent/agent-launch-picker-cli-model-catalog.ts b/src/renderer/src/components/agent/agent-launch-picker-cli-model-catalog.ts index ca00b5df5b0a..3e9c7c92d01f 100644 --- a/src/renderer/src/components/agent/agent-launch-picker-cli-model-catalog.ts +++ b/src/renderer/src/components/agent/agent-launch-picker-cli-model-catalog.ts @@ -12,11 +12,17 @@ import { discoverRuntimeCommitMessageModels } from '@/runtime/source-control/git /** Agents with no structured chat have no host model catalog, so they list models through their CLI. */ export function agentPickerListsCliModels(entry: Pick): boolean { return ( - !isNativeChatAgent(entry.agent) && + (!isNativeChatAgent(entry.agent) || agentPickerListsOnlyCliModels(entry)) && getAgentSessionOptionCatalog(entry.agent)?.listModels !== undefined ) } +/** Its picker names terminal selectors that a chat launch translates, so its chat's host catalog, + * whose ids a terminal would misread, never stands in for them. */ +export function agentPickerListsOnlyCliModels(entry: Pick): boolean { + return getAgentSessionOptionCatalog(entry.agent)?.chatModelId !== undefined +} + export async function readAgentPickerCliModelCatalog( agent: AgentPickerEntry['agent'], runtime: RuntimeGitContext diff --git a/src/renderer/src/components/agent/agent-launch-picker-host-reads.ts b/src/renderer/src/components/agent/agent-launch-picker-host-reads.ts index cc2a7401d30d..49e42b0a9244 100644 --- a/src/renderer/src/components/agent/agent-launch-picker-host-reads.ts +++ b/src/renderer/src/components/agent/agent-launch-picker-host-reads.ts @@ -2,6 +2,7 @@ import type { AgentSessionModelCatalogResult } from '../../../../shared/agent-se import type { RuntimeGitContext } from '@/runtime/source-control/git/runtime-git-client-context' import { agentPickerListsCliModels, + agentPickerListsOnlyCliModels, readAgentPickerCliModelCatalog } from './agent-launch-picker-cli-model-catalog' import { structuredAgentSessionHostSupports } from '@/runtime/native-chat/host-capabilities/structured-agent-session-host-support' @@ -35,7 +36,7 @@ export function agentPickerModelCatalogReads( ? entry.agent === 'dima' && !relist ? { origin: 'unknown' as const } : readAgentPickerCliModelCatalog(entry.agent, cliDiscoveryRuntime) - : !target + : !target || agentPickerListsOnlyCliModels(entry) ? undefined : entry.agent === 'antigravity' ? callStructuredAgentSession( @@ -60,9 +61,13 @@ export function agentPickerModelCatalogReads( waitForListing, signal ), + readsCatalog: (entry: Pick) => + Boolean(cliDiscoveryRuntime && agentPickerListsCliModels(entry)) || + (!!target && !agentPickerListsOnlyCliModels(entry)), refreshOnInvalidation: (entry: Pick) => !!target && !(cliDiscoveryRuntime && agentPickerListsCliModels(entry)) && + !agentPickerListsOnlyCliModels(entry) && entry.agent !== 'antigravity', subscribeInvalidation: target ? (listener: () => void) => subscribeModelMenuInvalidation(target, listener) diff --git a/src/renderer/src/components/agent/launch-menu/AgentMenuItems.tsx b/src/renderer/src/components/agent/launch-menu/AgentMenuItems.tsx index b09ec6033a33..a5892b640a56 100644 --- a/src/renderer/src/components/agent/launch-menu/AgentMenuItems.tsx +++ b/src/renderer/src/components/agent/launch-menu/AgentMenuItems.tsx @@ -11,6 +11,7 @@ import { } from '../../../../../shared/agent-launch/picker/agent-launch-picker' import React, { useCallback } from 'react' import { toast } from 'sonner' +import { agentPickerChatLaunchRefusal } from '@/components/agent/agent-launch-picker-chat-model-refusal' import { launchAgentInNewTabWithOutcome } from '@/lib/agent-session/launch/new-tab/launch-agent-in-new-tab' import { createNonSecureContextUuid } from '../../../../../shared/identifiers/non-secure-context-uuid' @@ -104,6 +105,15 @@ export function useTabAgentMenuLaunch({ ) { return false } + // The form stays open on a pick its chat can't run, so the person can choose another. + const refusal = + row.kind === 'chat' && draft && pickerEntry + ? agentPickerChatLaunchRefusal(pickerEntry, draft) + : null + if (refusal) { + toast.error(refusal) + return false + } const { agent } = row const entry = getCatalogEntry(agent) const label = entry?.label ?? agent diff --git a/src/renderer/src/components/agent/use-agent-launch-picker-inventory.ts b/src/renderer/src/components/agent/use-agent-launch-picker-inventory.ts index de28ee23b032..4a0ca2e34fef 100644 --- a/src/renderer/src/components/agent/use-agent-launch-picker-inventory.ts +++ b/src/renderer/src/components/agent/use-agent-launch-picker-inventory.ts @@ -32,7 +32,6 @@ import { structuredAgentSessionTargetForHost } from '@/runtime/native-chat/sessi import { readHostStructuredAgentsForRuntime } from '@/runtime/native-chat/agent-catalogs/host-structured-agents' import type { RuntimeGitContext } from '@/runtime/source-control/git/runtime-git-client-context' import { resolveWorktreeModelDiscoveryRuntime } from '../native-chat/session/options/catalog/native-chat-session-option-discovery' -import { agentPickerListsCliModels } from './agent-launch-picker-cli-model-catalog' import { agentPickerModelCatalogReads, readAgentPickerLaunchSupport @@ -218,7 +217,7 @@ export function useAgentLaunchPickerInventorySource( ).map((entry) => ({ ...entry, coherentCatalog, - ...((!target && !(cliDiscoveryRuntime && agentPickerListsCliModels(entry))) || + ...(!reads.readsCatalog(entry) || !entry.surfaces.length || (registeredAgents && !registeredAgents.some(({ agent }) => agent === entry.agent) && diff --git a/src/renderer/src/components/native-chat/session/options/controls/native-chat-permission-mode-labels.ts b/src/renderer/src/components/native-chat/session/options/controls/native-chat-permission-mode-labels.ts index 8c489ff3f8e5..23642ef026ff 100644 --- a/src/renderer/src/components/native-chat/session/options/controls/native-chat-permission-mode-labels.ts +++ b/src/renderer/src/components/native-chat/session/options/controls/native-chat-permission-mode-labels.ts @@ -48,6 +48,13 @@ export function nativeChatPermissionModeDescription( ): string { switch (mode) { case 'ask': + // dima's read-only preset refuses what Ask would ask about. + if (agent === 'dima') { + return t( + 'components.native-chat.composer.permissionAskReadOnlyDescription', + 'Only reads; refuses edits and commands instead of asking' + ) + } if (agent !== 'claude') { return t( 'components.native-chat.composer.permissionAskSharedDescription', @@ -59,7 +66,7 @@ export function nativeChatPermissionModeDescription( "Asks before edits and commands your settings don't allow" ) case 'accept-edits': - if (agent === 'antigravity') { + if (agent === 'antigravity' || agent === 'dima') { return t( 'components.native-chat.composer.permissionAcceptEditsAntigravityDescription', 'Approves file edits; asks for the rest' diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 0325109a5d14..b378a801e6f9 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -21464,6 +21464,7 @@ "permissionAsk": "Ask for approval", "permissionAskDescription": "Asks before edits and commands your settings don't allow", "permissionAskSharedDescription": "Asks before edits or commands it isn't already allowed to make", + "permissionAskReadOnlyDescription": "Only reads; refuses edits and commands instead of asking", "permissionAcceptEdits": "Accept edits", "permissionAcceptEditsDescription": "Approves file edits and file commands; asks for the rest", "permissionAcceptEditsAntigravityDescription": "Approves file edits; asks for the rest", @@ -26956,6 +26957,9 @@ "catalogNotLoaded": "{{agent}} models have not loaded.", "retryModels": "Retry", "catalogEmpty": "{{agent}} has no available models.", + "chatModelShared": "A {{agent}} chat can't pick {{model}} because another provider offers the same model. Launch it in a terminal, or pick another model.", + "chatModelUnlisted": "{{model}} isn't in {{agent}}'s model list, so a chat can't run it. Pick another model.", + "chatModelUnproven": "{{agent}}'s model list hasn't finished loading, so a chat can't confirm {{model}} yet. Try again in a moment, or launch it in a terminal.", "workspaceStartupFailed": "Could not start {{agent}}. Check Arguments in this setup and try again.", "search": "Search, e.g. Opus 5.5…", "searchAgents": "Search agents…", diff --git a/src/shared/agent-launch/permissions/agent-chat-permission-support.ts b/src/shared/agent-launch/permissions/agent-chat-permission-support.ts index f781081a6f77..f394cfe20ee7 100644 --- a/src/shared/agent-launch/permissions/agent-chat-permission-support.ts +++ b/src/shared/agent-launch/permissions/agent-chat-permission-support.ts @@ -53,7 +53,8 @@ export const NATIVE_CHAT_AGENTS = [ 'qwen-code', 'cline', 'devin', - 'codebuddy' + 'codebuddy', + 'dima' ] as const export type NativeChatAgent = (typeof NATIVE_CHAT_AGENTS)[number] @@ -88,7 +89,9 @@ const AGENT_CHAT_PERMISSION_MODES_BY_AGENT: Record< // Devin's own modes: Code approves edits, and Smart has a model approve what is safe. devin: CLAUDE_CHAT_PERMISSION_MODES, // CodeBuddy's own modes, as Claude Code's: Accept Edits, and Auto has a model review each action. - codebuddy: CLAUDE_CHAT_PERMISSION_MODES + codebuddy: CLAUDE_CHAT_PERMISSION_MODES, + // dima's presets: workspace-write approves workspace edits, and nothing reviews approvals for the person. + dima: EDIT_ACCEPTING_CHAT_PERMISSION_MODES } export function isNativeChatAgent(agent: string): agent is NativeChatAgent { diff --git a/src/shared/agent-launch/picker/agent-launch-picker-chat-model.ts b/src/shared/agent-launch/picker/agent-launch-picker-chat-model.ts new file mode 100644 index 000000000000..20635acfd87d --- /dev/null +++ b/src/shared/agent-launch/picker/agent-launch-picker-chat-model.ts @@ -0,0 +1,25 @@ +import { getAgentSessionOptionCatalog } from '../../agent-session/options/agent-session-option-catalog' +import { agentPickerCatalogAuthoritative } from './agent-launch-picker-authority' +import type { AgentPickerEntry } from './agent-launch-picker' + +export type AgentPickerChatModelRefusal = 'unproven' | 'unlisted' | 'shared' + +/** The model a chat launch runs for the form's pick, where the form lists terminal selectors. */ +export function agentPickerChatLaunchModel( + entry: AgentPickerEntry, + model: string | undefined +): { model: string | undefined } | { refusal: AgentPickerChatModelRefusal } { + const chatModelId = getAgentSessionOptionCatalog(entry.agent)?.chatModelId + if (!chatModelId || model === undefined) { + return { model } + } + if (!agentPickerCatalogAuthoritative(entry)) { + return { refusal: 'unproven' } + } + const listed = entry.catalog.models.map((row) => row.id) + if (!listed.includes(model)) { + return { refusal: 'unlisted' } + } + const id = chatModelId(model, listed) + return id === null ? { refusal: 'shared' } : { model: id } +} diff --git a/src/shared/agent-launch/picker/agent-launch-picker.ts b/src/shared/agent-launch/picker/agent-launch-picker.ts index 83c3f969fa55..e4445f685ead 100644 --- a/src/shared/agent-launch/picker/agent-launch-picker.ts +++ b/src/shared/agent-launch/picker/agent-launch-picker.ts @@ -3,6 +3,7 @@ import type { TextActionPickerCatalog } from './agent-launch-picker-text-action' import { agentPickerLaunchChoices } from './agent-launch-picker-effective-choices' import { agentPickerPanelArguments } from './agent-launch-picker-arguments' import { agentPickerArgumentsKnown } from './agent-launch-picker-authority' +import { agentPickerChatLaunchModel } from './agent-launch-picker-chat-model' import { agentPickerOptions } from './agent-launch-picker-catalog' import { projectAgentLaunchInputViews } from '../choices/agent-launch-profile' @@ -173,7 +174,21 @@ export function agentPickerFreshLaunchInputs( // Why: choosing a control can materialize settings text without authoring Arguments. return agentPickerLaunchInputs({ ...draft, arguments: undefined }) } - return agentPickerLaunchInputs(draft, entry) + const inputs = agentPickerLaunchInputs(draft, entry) + // A chat runs a listed terminal selector by its own id; launchers refuse an unproven one first. + const chat = + destination.surface === 'chat' && entry + ? agentPickerChatLaunchModel(entry, draft.choices.model) + : undefined + return chat && 'model' in chat && chat.model !== undefined && chat.model !== draft.choices.model + ? { + ...inputs, + chatSessionOptions: { + ...(inputs.chatSessionOptions ?? inputs.sessionOptions), + model: chat.model + } + } + : inputs } export function agentPickerButtonOrder(entry: AgentPickerEntry): AgentPickerSurface[] { diff --git a/src/shared/agent-session/lifecycle/launch/agent-session-setup-commands.ts b/src/shared/agent-session/lifecycle/launch/agent-session-setup-commands.ts index 585877929210..bedf123ab5cd 100644 --- a/src/shared/agent-session/lifecycle/launch/agent-session-setup-commands.ts +++ b/src/shared/agent-session/lifecycle/launch/agent-session-setup-commands.ts @@ -120,6 +120,13 @@ export const AGENT_SESSION_SETUP_COMMANDS = [ slashCommand: '/login', installCommand: 'npm install -g @tencent-ai/codebuddy-code' }, + // dima's /connect signs in to an account or adds a provider's key. + { + agent: 'dima', + loginCommand: ['dima'], + slashCommand: '/connect', + installCommand: 'npm install -g dimcode-alpha' + }, // An `agy` login signs in only chats on agy (`system`); chats on Orca's server keep their own. { agent: 'antigravity', diff --git a/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-dima.ts b/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-dima.ts index 80319d8f6122..59904b09fe86 100644 --- a/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-dima.ts +++ b/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-dima.ts @@ -1,6 +1,10 @@ import { agentChoiceCliApply } from '../../../agent-launch/choices/agent-choice-cli-apply' import type { AgentSessionOptionCatalog, CatalogModel } from './agent-session-option-catalog-types' -import { dimaModelLaunchArgs, parseDimaModelList } from '../model-catalog/dima-model-list-probe' +import { + dimaModelLaunchArgs, + parseDimaModelList, + parseDimaModelSelector +} from '../model-catalog/dima-model-list-probe' /** Private enrichment-gate parser with option-free rows; actual probes run in main (agent-model-probe-spec.ts). */ function parseDimaCatalogModels(stdout: string): CatalogModel[] { @@ -35,6 +39,12 @@ export const DIMA_SESSION_OPTION_CATALOG: AgentSessionOptionCatalog = { }, // Only a listing proves a selector; with no daemon to ask, saved picks stay and Default runs bare `dima`. discoveredModelsAreAuthoritative: true, + // A chat's model option takes the provider's own model id, and lists none two providers share. + chatModelId: (model, listed) => { + const modelId = parseDimaModelSelector(model)?.modelId + const sharing = listed.filter((id) => parseDimaModelSelector(id)?.modelId === modelId) + return modelId !== undefined && sharing.length === 1 && sharing[0] === model ? modelId : null + }, // No dima command lists every provider's models; the gate names the App Server read main makes. listModels: { command: 'provider.models.query', parse: parseDimaCatalogModels } } diff --git a/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-types.ts b/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-types.ts index 2f36161564ef..8ed0b7a5f894 100644 --- a/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-types.ts +++ b/src/shared/agent-session/options/catalog-providers/agent-session-option-catalog-types.ts @@ -77,6 +77,9 @@ export type AgentSessionOptionCatalog = { /** For a host too old to say so itself: its model listing names the model the account is * configured to run, so a new chat may run the listed default. */ hostListingNamesConfiguredModel?: true + /** Its ids are terminal launch selectors its structured chat can't take: the chat's own id for + * `model`, or null unless `listed` (a complete listing) proves exactly one. */ + chatModelId?: (model: string, listed: readonly string[]) => string | null listModels?: { command: string parse: (stdout: string) => CatalogModel[] diff --git a/src/shared/agent-session/options/model-catalog/dima-model-list-probe.test.ts b/src/shared/agent-session/options/model-catalog/dima-model-list-probe.test.ts index e2b651f314b9..4c488bfd7b15 100644 --- a/src/shared/agent-session/options/model-catalog/dima-model-list-probe.test.ts +++ b/src/shared/agent-session/options/model-catalog/dima-model-list-probe.test.ts @@ -1,5 +1,6 @@ import { expect, it } from 'vitest' import { dimaCatalogModels, dimaModelLaunchArgs } from './dima-model-list-probe' +import { DIMA_SESSION_OPTION_CATALOG } from '../catalog-providers/agent-session-option-catalog-dima' it('keeps the provider and full model id through a picker selection', () => { const rows = dimaCatalogModels([ @@ -11,3 +12,16 @@ it('keeps the provider and full model id through a picker selection', () => { ['Chat · Second', ['--provider', 'two', '--model', 'vendor/model']] ]) }) + +it('gives a chat the full model id only when one provider lists it', () => { + const listed = dimaCatalogModels([ + { providerId: 'one', modelId: 'vendor/model' }, + { providerId: 'two', modelId: 'vendor/model' }, + { providerId: 'two', modelId: 'vendor/only' } + ]).map(({ id }) => id) + expect(listed.map((id) => DIMA_SESSION_OPTION_CATALOG.chatModelId?.(id, listed))).toEqual([ + null, + null, + 'vendor/only' + ]) +}) diff --git a/src/shared/agent-status/presentation/agent-type-label.ts b/src/shared/agent-status/presentation/agent-type-label.ts index ffb3b45542e8..a65e7ebb9c1d 100644 --- a/src/shared/agent-status/presentation/agent-type-label.ts +++ b/src/shared/agent-status/presentation/agent-type-label.ts @@ -27,6 +27,7 @@ const WELL_KNOWN_LABELS: Record = { hermes: 'Hermes', goose: 'Goose', devin: 'Devin', + dima: 'DimAgent', ante: 'Ante', trae: 'Trae', kimi: 'Kimi', diff --git a/src/shared/native-chat/input/commands/native-chat-agent-profiles.ts b/src/shared/native-chat/input/commands/native-chat-agent-profiles.ts index dddb7446d404..2a1c83d1088b 100644 --- a/src/shared/native-chat/input/commands/native-chat-agent-profiles.ts +++ b/src/shared/native-chat/input/commands/native-chat-agent-profiles.ts @@ -130,7 +130,9 @@ const NATIVE_CHAT_AGENT_PROFILES: Record | undefined { const remembered = resolveStructuredLaunchSeedOptions(settings?.nativeChatSessionOptions, agent) + const launchDefaults = settings?.agentLaunchChoices?.[agent] const choices = isTuiAgent(agent) ? resolveAgentChoiceLayers({ agent, argumentOwner: 'defaults', - defaults: settings?.agentLaunchChoices?.[agent], + // A terminal selector names no model the chat's own option offers. + defaults: + launchDefaults && getAgentSessionOptionCatalog(agent)?.chatModelId + ? { options: launchDefaults.options } + : launchDefaults, remembered: { model: remembered?.model, options: Object.fromEntries( diff --git a/src/shared/plugins/languages/protected-copy-keys.json b/src/shared/plugins/languages/protected-copy-keys.json index f464b3f55164..3062662ba391 100644 --- a/src/shared/plugins/languages/protected-copy-keys.json +++ b/src/shared/plugins/languages/protected-copy-keys.json @@ -1223,6 +1223,7 @@ "components.native-chat.composer.permissionAppliesNextMessage", "components.native-chat.composer.permissionAsk", "components.native-chat.composer.permissionAskDescription", + "components.native-chat.composer.permissionAskReadOnlyDescription", "components.native-chat.composer.permissionAskSharedDescription", "components.native-chat.composer.permissionAuto", "components.native-chat.composer.permissionAutoDescription", From 9bd060f894192c8a675523ece523350d1ce9cf13 Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Wed, 25 Nov 2026 03:44:09 -0800 Subject: [PATCH 05/10] fix(dima): validate quick workspace chat picks and label read-only mode --- .../catalog-validation/protected-copy-keys.mjs | 1 + .../agent/launch-settings/AgentPermissionChoiceItems.tsx | 4 +++- .../agent/launch-settings/AgentPermissionMenu.tsx | 5 +++-- .../options/controls/NativeChatPermissionModePicker.tsx | 9 +++++---- .../controls/native-chat-permission-mode-labels.ts | 9 ++++++--- .../new-workspace/composer/NewWorkspaceComposerModal.tsx | 9 +++++++++ src/renderer/src/i18n/locales/en.json | 3 ++- src/renderer/src/i18n/locales/zh.json | 5 +++++ src/shared/plugins/languages/protected-copy-keys.json | 1 + 9 files changed, 35 insertions(+), 11 deletions(-) diff --git a/config/scripts/localization/catalog-validation/protected-copy-keys.mjs b/config/scripts/localization/catalog-validation/protected-copy-keys.mjs index 63ca44c10477..cffa83e1adc9 100644 --- a/config/scripts/localization/catalog-validation/protected-copy-keys.mjs +++ b/config/scripts/localization/catalog-validation/protected-copy-keys.mjs @@ -60,6 +60,7 @@ export const PINNED_PROTECTED_COPY = [ 'components.native-chat.composer.permissionAsk', 'components.native-chat.composer.permissionAskDescription', 'components.native-chat.composer.permissionAskReadOnlyDescription', + 'components.native-chat.composer.permissionReadOnly', 'components.native-chat.composer.permissionAskSharedDescription', 'components.native-chat.composer.permissionAuto', 'components.native-chat.composer.permissionAutoDescription', diff --git a/src/renderer/src/components/agent/launch-settings/AgentPermissionChoiceItems.tsx b/src/renderer/src/components/agent/launch-settings/AgentPermissionChoiceItems.tsx index 2c20dbf97807..bbb3c19d6441 100644 --- a/src/renderer/src/components/agent/launch-settings/AgentPermissionChoiceItems.tsx +++ b/src/renderer/src/components/agent/launch-settings/AgentPermissionChoiceItems.tsx @@ -27,15 +27,17 @@ function ownDescription(chatOwnSupported: boolean, t: Translate = translate): st /** A choice's name as the chat picker shows it; own gets a terminal icon. */ export function AgentPermissionChoiceName({ choice, + agent, ownLabel, truncate }: { choice: AgentPermissionChoice + agent?: string ownLabel: string truncate?: boolean }): React.JSX.Element { if (choice !== 'own') { - return + return } return ( diff --git a/src/renderer/src/components/agent/launch-settings/AgentPermissionMenu.tsx b/src/renderer/src/components/agent/launch-settings/AgentPermissionMenu.tsx index 73f91270e240..23110e1eab88 100644 --- a/src/renderer/src/components/agent/launch-settings/AgentPermissionMenu.tsx +++ b/src/renderer/src/components/agent/launch-settings/AgentPermissionMenu.tsx @@ -76,6 +76,7 @@ export function AgentPermissionMenu({ {permission.source === 'all' ? {followAll} · : null} @@ -104,7 +105,7 @@ export function AgentPermissionMenu({ {t( 'settings.agents.permissionSurfaceDifference', 'Terminals use the agent’s own settings; new chats use {{mode}}.', - { mode: nativeChatPermissionModeLabel(permission.chatChoice, t) } + { mode: nativeChatPermissionModeLabel(permission.chatChoice, t, agentId) } )} ) : !permission.argsSetPermission && @@ -118,7 +119,7 @@ export function AgentPermissionMenu({ 'Terminals use {{terminal}}; new chats use {{mode}}.', { terminal: nativeChatPermissionModeLabel(permission.terminalChoice, t), - mode: nativeChatPermissionModeLabel(permission.chatChoice, t) + mode: nativeChatPermissionModeLabel(permission.chatChoice, t, agentId) } )} diff --git a/src/renderer/src/components/native-chat/session/options/controls/NativeChatPermissionModePicker.tsx b/src/renderer/src/components/native-chat/session/options/controls/NativeChatPermissionModePicker.tsx index e3dfbc23c40b..bcbd93a850ed 100644 --- a/src/renderer/src/components/native-chat/session/options/controls/NativeChatPermissionModePicker.tsx +++ b/src/renderer/src/components/native-chat/session/options/controls/NativeChatPermissionModePicker.tsx @@ -35,12 +35,13 @@ import { PermissionChoiceRadioItem } from './PermissionChoiceRadioItem' export function NativeChatPermissionModeName(props: { mode: AgentChatPermissionMode + agent?: string | null truncate?: boolean label?: string }): React.JSX.Element { const t = useTranslate() const Icon = NATIVE_CHAT_PERMISSION_MODE_ICONS[props.mode] - const label = props.label ?? nativeChatPermissionModeLabel(props.mode, t) + const label = props.label ?? nativeChatPermissionModeLabel(props.mode, t, props.agent) const body = ( <> @@ -80,7 +81,7 @@ export function NativeChatPermissionModeItems({ disabled={disabled} onSelect={() => onSelect(mode)} > - + ))} @@ -134,7 +135,7 @@ function NativeChatPermissionModePickerInner({ } ) const selectedLabel = isAgentChatPermissionMode(shown) - ? nativeChatPermissionModeLabel(shown, t) + ? nativeChatPermissionModeLabel(shown, t, agent) : ownPlan ? t('components.native-chat.composer.planMode', 'Plan') : own @@ -142,7 +143,7 @@ function NativeChatPermissionModePickerInner({ : (currentLabel ?? inherit?.label ?? title) const Icon = ownPlan ? PencilRuler : Settings2 const activeLabel = isAgentChatPermissionMode(activeValue) - ? nativeChatPermissionModeLabel(activeValue, t) + ? nativeChatPermissionModeLabel(activeValue, t, agent) : activeValue === 'own' ? ownSettings : null diff --git a/src/renderer/src/components/native-chat/session/options/controls/native-chat-permission-mode-labels.ts b/src/renderer/src/components/native-chat/session/options/controls/native-chat-permission-mode-labels.ts index 23642ef026ff..49371f7c5577 100644 --- a/src/renderer/src/components/native-chat/session/options/controls/native-chat-permission-mode-labels.ts +++ b/src/renderer/src/components/native-chat/session/options/controls/native-chat-permission-mode-labels.ts @@ -26,11 +26,14 @@ export const NATIVE_CHAT_PERMISSION_MODE_ICONS = { export function nativeChatPermissionModeLabel( mode: AgentChatPermissionMode, - t: Translate = translate + t: Translate = translate, + agent?: string | null ): string { switch (mode) { case 'ask': - return t('components.native-chat.composer.permissionAsk', 'Ask for approval') + return agent === 'dima' + ? t('components.native-chat.composer.permissionReadOnly', 'Read-only') + : t('components.native-chat.composer.permissionAsk', 'Ask for approval') case 'accept-edits': return t('components.native-chat.composer.permissionAcceptEdits', 'Accept edits') case 'auto': @@ -52,7 +55,7 @@ export function nativeChatPermissionModeDescription( if (agent === 'dima') { return t( 'components.native-chat.composer.permissionAskReadOnlyDescription', - 'Only reads; refuses edits and commands instead of asking' + 'Allows reads. Declines edits and commands.' ) } if (agent !== 'claude') { diff --git a/src/renderer/src/components/new-workspace/composer/NewWorkspaceComposerModal.tsx b/src/renderer/src/components/new-workspace/composer/NewWorkspaceComposerModal.tsx index 00a634f1a171..300804618ea0 100644 --- a/src/renderer/src/components/new-workspace/composer/NewWorkspaceComposerModal.tsx +++ b/src/renderer/src/components/new-workspace/composer/NewWorkspaceComposerModal.tsx @@ -1,5 +1,6 @@ import type { ComposerModalData } from './composer-modal-data' import { toast } from 'sonner' +import { agentPickerChatLaunchRefusal } from '@/components/agent/agent-launch-picker-chat-model-refusal' import { formatWorkspaceCreateError, getWorkspaceCreateErrorToastMessage @@ -235,6 +236,14 @@ function QuickTabBody({ if (createDisabled) { return } + const refusal = + pickerDraft?.surface === 'chat' && quickAgentPick.entry + ? agentPickerChatLaunchRefusal(quickAgentPick.entry, pickerDraft) + : null + if (refusal) { + toast.error(refusal) + return + } await submitQuick(quickAgent, { // Blank Terminal is the setup-only create: no agent, and no extra shell beside setup. setupOnly: quickAgent === null, diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index b378a801e6f9..4e497d5621c2 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -21462,9 +21462,10 @@ "tooManyAttachments": "Attach {{value0}} or fewer files at a time.", "permissions": "Permissions", "permissionAsk": "Ask for approval", + "permissionReadOnly": "Read-only", "permissionAskDescription": "Asks before edits and commands your settings don't allow", "permissionAskSharedDescription": "Asks before edits or commands it isn't already allowed to make", - "permissionAskReadOnlyDescription": "Only reads; refuses edits and commands instead of asking", + "permissionAskReadOnlyDescription": "Allows reads. Declines edits and commands.", "permissionAcceptEdits": "Accept edits", "permissionAcceptEditsDescription": "Approves file edits and file commands; asks for the rest", "permissionAcceptEditsAntigravityDescription": "Approves file edits; asks for the rest", diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index 6e7e20881d1f..b8340ff43327 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -20334,6 +20334,8 @@ "tooManyAttachments": "每次最多附加 {{value0}} 个文件", "permissions": "权限", "permissionAsk": "请求批准", + "permissionReadOnly": "只读", + "permissionAskReadOnlyDescription": "允许读取,拒绝编辑和执行命令。", "permissionAskDescription": "在设置未允许的编辑和命令前询问", "permissionAskSharedDescription": "在执行尚未获准的编辑或命令前询问", "permissionAcceptEdits": "接受编辑", @@ -26242,6 +26244,9 @@ "waitForImageUploads": "请等待图片上传完成,然后重试创建 PR" }, "agentPicker": { + "chatModelShared": "多个提供商都提供 {{model}},{{agent}} 的聊天无法区分它们。请选择其他模型,或在终端启动。", + "chatModelUnlisted": "{{agent}} 的模型列表中找不到 {{model}}。请选择其他模型。", + "chatModelUnproven": "{{agent}} 的模型列表仍在加载,暂时无法确认 {{model}}。请稍后重试,或在终端启动。", "refreshModels": "刷新模型", "catalogUnsupportedLaunch": "此主机上无法使用 {{agent}} 模型。当前选择仍会生效。", "catalogLoadFailed": "无法加载 {{agent}} 模型", diff --git a/src/shared/plugins/languages/protected-copy-keys.json b/src/shared/plugins/languages/protected-copy-keys.json index 3062662ba391..62ddab63ed74 100644 --- a/src/shared/plugins/languages/protected-copy-keys.json +++ b/src/shared/plugins/languages/protected-copy-keys.json @@ -1232,6 +1232,7 @@ "components.native-chat.composer.permissionFullAccessCodexDescription", "components.native-chat.composer.permissionFullAccessDescription", "components.native-chat.composer.permissionFullAccessSharedDescription", + "components.native-chat.composer.permissionReadOnly", "components.native-chat.composer.permissions", "components.native-chat.composer.pillAccessibleName", "components.native-chat.composer.planMode", From c23bffc69d9e868e29dafffe87b96da208722b31 Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Wed, 25 Nov 2026 03:57:07 -0800 Subject: [PATCH 06/10] fix(dima): take native chat model ids from `agent launch --surface chat` `orca agent launch --surface chat --model` now passes the model id DimAgent's chats list, slashes included, as-is. dima checks it at the first send, and a refusal fails that send visibly. A terminal, or a launch without --surface, still needs a provider/model selector; workers and other agents are unchanged. - A terminal opened in place of a requested chat leaves out the chat's model id instead of reading its first segment as a provider, and the launch warning says so. - When dima hides its model option (its current model is an id two providers share), a requested model is written through config id `model` instead of being skipped silently. Co-Authored-By: Claude Opus 5.5 --- src/cli/agents/agent-launch-request.ts | 3 +- src/cli/specs/agent-launch.ts | 2 +- src/main/acp/acp-dialects/acp-dialect.ts | 3 ++ src/main/acp/acp-dialects/dima-dialect.ts | 4 ++- .../acp/options/acp-structured-options.ts | 23 ++++++------- .../agent-launch/agent-launch-executor.ts | 5 +-- .../agent-launch-surface-factories.test.ts | 24 ++++++++++++++ .../agent-launch-surface-factories.ts | 32 +++++++++++++++++-- .../agent-launch/agent-launch-warnings.ts | 18 +++++++++++ .../choices/agent-launch-model-preferences.ts | 8 +++-- 10 files changed, 101 insertions(+), 21 deletions(-) create mode 100644 src/main/agent-launch/agent-launch-surface-factories.test.ts diff --git a/src/cli/agents/agent-launch-request.ts b/src/cli/agents/agent-launch-request.ts index 89009a17d519..86624920aed6 100644 --- a/src/cli/agents/agent-launch-request.ts +++ b/src/cli/agents/agent-launch-request.ts @@ -73,8 +73,10 @@ export function readCliAgentLaunch( agent: TuiAgent, target: { createsWorktree: boolean } ): CliAgentLaunch { + const surface = readSurfaceFlag(flags) const checked = checkAgentLaunchModelPreferences({ agent, + ...(surface ? { surface } : {}), model: getOptionalStringFlag(flags, 'model'), effort: getOptionalStringFlag(flags, 'effort'), createsWorktree: target.createsWorktree, @@ -92,7 +94,6 @@ export function readCliAgentLaunch( if (operationId !== undefined && parseAgentSessionOperationTimestamp(operationId) === null) { throw new RuntimeClientError('invalid_argument', 'Malformed --retry-launch operation ID') } - const surface = readSurfaceFlag(flags) return { agent, ...(surface ? { surface } : {}), diff --git a/src/cli/specs/agent-launch.ts b/src/cli/specs/agent-launch.ts index 815f85b02403..74eb7b9b3e46 100644 --- a/src/cli/specs/agent-launch.ts +++ b/src/cli/specs/agent-launch.ts @@ -22,7 +22,7 @@ export const AGENT_LAUNCH_COMMAND_SPECS: CommandSpec[] = [ 'Starts the agent the way a new agent tab does: as a chat when your Chat | CLI choice for the agent is Chat and the agent and host support it, otherwise as a terminal. The result says which (`outcome.kind`) and why (`receipt.detail`).', '--surface chat|terminal picks for this launch instead of your setting. --surface terminal always runs the agent CLI; --surface chat is refused when Orca can establish before starting anything that this agent cannot open as a chat there. If support cannot be checked, the launch can fall back to a terminal. If chat becomes unavailable after creating a workspace, Orca keeps the workspace, setup and default tabs, then opens a terminal; the receipt explains the fallback.', '--worktree defaults to the native folder workspace or worktree containing the current directory. For a new checkout with its agent, use `orca worktree create --agent`.', - '--model takes a provider model id (OMP also takes its model roles and selectors) and --effort a reasoning effort for that model; --effort requires --model. Pi takes a `provider/id` model and maps --effort to `--thinking` (off, minimal, low, medium, high, xhigh, max). DimAgent takes a `provider/model` model, such as `openai-codex/gpt-5.5`, and no --effort. They apply to either surface.', + "--model takes a provider model id (OMP also takes its model roles and selectors) and --effort a reasoning effort for that model; --effort requires --model. Pi takes a `provider/id` model and maps --effort to `--thinking` (off, minimal, low, medium, high, xhigh, max). They apply to either surface, except DimAgent, which takes no --effort: its terminal, and a launch without --surface, takes a `provider/model` selector such as `openai-codex/gpt-5.5`, while --surface chat takes the whole model id DimAgent's chats list, such as `gpt-5.5` or `vendor/chat-two`. A chat model DimAgent does not offer, including a selector or an id two providers share, fails the chat's first message instead of running another model.", 'The tab opens without switching focus; pass --focus to switch to it.', 'If the launch reply is lost, re-issue the same command from the same directory on the same host with --retry-launch from the error. Never retry as a fresh launch; older hosts require inspecting the workspace first.' ], diff --git a/src/main/acp/acp-dialects/acp-dialect.ts b/src/main/acp/acp-dialects/acp-dialect.ts index 8e978843a889..5d1ec6d24d44 100644 --- a/src/main/acp/acp-dialects/acp-dialect.ts +++ b/src/main/acp/acp-dialects/acp-dialect.ts @@ -245,6 +245,9 @@ export type AcpDialect = { compactCommand?: string /** Orca's catalog ids (the agent CLI's) its chat server names differently, as the server's ids. */ chatModelIds?: ReadonlyMap + /** Its model option's id, which still sets a model it lists while it leaves the option out + * because its current model is not listed. */ + unpublishedModelConfigId?: string /** Resolves a CLI model id the chat server does not list to a listed model plus its effort, * thinking and Fast; null if none. */ unlistedChatModel?(value: string, listed: readonly string[]): AcpListedChatModel | null diff --git a/src/main/acp/acp-dialects/dima-dialect.ts b/src/main/acp/acp-dialects/dima-dialect.ts index 4026d360ef9c..39901f25ec73 100644 --- a/src/main/acp/acp-dialects/dima-dialect.ts +++ b/src/main/acp/acp-dialects/dima-dialect.ts @@ -20,5 +20,7 @@ function approvalRequest(method: string, params: unknown): AcpRequestPresentatio } export const DIMA_ACP_DIALECT: AcpDialect = { - request: approvalRequest + request: approvalRequest, + // A current model two providers share hides the option, so a requested one is written, not skipped. + unpublishedModelConfigId: 'model' } diff --git a/src/main/acp/options/acp-structured-options.ts b/src/main/acp/options/acp-structured-options.ts index 8fe5eb3a2354..f7225f9a6775 100644 --- a/src/main/acp/options/acp-structured-options.ts +++ b/src/main/acp/options/acp-structured-options.ts @@ -30,6 +30,10 @@ function isSelect(option: SessionConfigOption): option is SelectOption { return option.type === 'select' } +function configWrite(configId: string | undefined, value: string): AcpOptionWrite | null { + return configId === undefined ? null : { method: 'config', configId, value } +} + export class AcpStructuredOptions { constructor( private readonly dialect: Pick< @@ -38,6 +42,7 @@ export class AcpStructuredOptions { | 'familyEfforts' | 'withheldCommands' | 'chatModelIds' + | 'unpublishedModelConfigId' | 'effortChangesModel' | 'clampsUnlistedEffort' | 'builtinCommands' @@ -224,27 +229,23 @@ export class AcpStructuredOptions { write(key: string, value: string): AcpOptionWrite | null { if (key === 'fastMode' || key === 'thinking') { - const option = this.idSelect( - key === 'fastMode' ? this.dialect.fastConfigId : this.dialect.thinkingConfigId - ) - return option ? { method: 'config', configId: option.id, value } : null + const id = key === 'fastMode' ? this.dialect.fastConfigId : this.dialect.thinkingConfigId + return configWrite(this.idSelect(id)?.id, value) } if (key === 'model') { const option = this.select('model') const model = this.dialect.chatModelIds?.get(value) ?? value - if (option) { - return { method: 'config', configId: option.id, value: model } - } - return this.models ? { method: 'model', modelId: model } : null + return !option && this.models + ? { method: 'model', modelId: model } + : configWrite(option?.id ?? this.dialect.unpublishedModelConfigId, model) } if (key === 'effort') { - const option = this.effortOption() - return option ? { method: 'config', configId: option.id, value } : null + return configWrite(this.effortOption()?.id, value) } if (key === 'interactionMode') { const option = this.select('mode') const native = acpInteractionModeValue(this.dialect.interactionModes, option, value) - return option && native ? { method: 'config', configId: option.id, value: native } : null + return native ? configWrite(option?.id, native) : null } return null } diff --git a/src/main/agent-launch/agent-launch-executor.ts b/src/main/agent-launch/agent-launch-executor.ts index c4873f7363c4..9b6672591149 100644 --- a/src/main/agent-launch/agent-launch-executor.ts +++ b/src/main/agent-launch/agent-launch-executor.ts @@ -12,7 +12,8 @@ import { } from '../../shared/agent-launch/contracts/agent-launch-intent' import { combineLaunchWarnings, - ignoredStructuredLaunchInputsWarning + ignoredStructuredLaunchInputsWarning, + terminalLaunchWarning } from './agent-launch-warnings' import { argvLaunchPrompt, @@ -319,7 +320,7 @@ async function createTerminalSurface( ...(terminal.paneKey ? { paneKey: terminal.paneKey } : {}) }, terminalCreation: terminal.terminalCreation, - ...(terminal.warning ? { warning: terminal.warning } : {}), + ...terminalLaunchWarning(intent, terminal.warning), ...(startupPrompt && terminal.promptRodeLaunchCommand ? { promptRodeLaunchCommand: true } : {}) } } diff --git a/src/main/agent-launch/agent-launch-surface-factories.test.ts b/src/main/agent-launch/agent-launch-surface-factories.test.ts new file mode 100644 index 000000000000..d36d22a8292f --- /dev/null +++ b/src/main/agent-launch/agent-launch-surface-factories.test.ts @@ -0,0 +1,24 @@ +import { expect, it } from 'vitest' +import { terminalLaunchInputs } from './agent-launch-surface-factories' + +it("keeps a dima chat's model id out of a terminal, which would read it as a provider", () => { + const target = { kind: 'existing' as const, worktree: 'id:w' } + const terminalModel = (intent: Parameters[0]) => + terminalLaunchInputs(intent).options?.model + expect([ + terminalModel({ + agent: 'dima', + target, + surface: 'chat', + sessionOptions: { model: 'vendor/chat-two' } + }), + terminalModel({ + agent: 'dima', + target, + surface: 'chat', + sessionOptions: { model: 'p2/vendor/chat-two' }, + chatOptions: { model: 'vendor/chat-two' } + }), + terminalModel({ agent: 'dima', target, sessionOptions: { model: 'p2/vendor/chat-two' } }) + ]).toEqual([undefined, 'p2/vendor/chat-two', 'p2/vendor/chat-two']) +}) diff --git a/src/main/agent-launch/agent-launch-surface-factories.ts b/src/main/agent-launch/agent-launch-surface-factories.ts index 7051b815b9a1..5bd8fba7a298 100644 --- a/src/main/agent-launch/agent-launch-surface-factories.ts +++ b/src/main/agent-launch/agent-launch-surface-factories.ts @@ -16,6 +16,7 @@ import type { TuiAgent } from '../../shared/agent-launch/catalog/tui-agent' import type { SetupTrustMismatch } from '../../shared/worktree/create-types' import type { AgentLaunchParams } from '../../shared/rpc-contract/agent-launch/agent-launch-params' import { toAgentLaunchPreferences } from '../../shared/agent-launch/choices/agent-launch-preferences' +import { getAgentSessionOptionCatalog } from '../../shared/agent-session/options/agent-session-option-catalog' import { assertOpenCodeModelLaunchPreferencesAbsent } from '../opencode/model-launch/opencode-model-startup-plan' /** Inject creation so orchestration can add subscriptions without duplicating launch sequencing. */ @@ -128,9 +129,34 @@ export type AgentLaunchWorkspaceFactory = { createFolderWorkspace?: AgentLaunchWorkspaceFactory['createWorktree'] } -/** The options a terminal leg starts with: a caller's saved chat choice applies to it too. */ -function terminalLaunchOptions(intent: Pick) { - return intent.sessionOptions ?? intent.chatOptions +type TerminalOptionsIntent = Pick< + AgentLaunchIntent, + 'agent' | 'surface' | 'sessionOptions' | 'chatOptions' +> + +/** A model the launch names in its chat's own ids, which this agent's terminal would misread as a + * provider selector: the chat's options, or the only options of a launch that asked for a chat. */ +export function terminalLaunchChatModel(intent: TerminalOptionsIntent): string | undefined { + const chatNamed = + intent.sessionOptions === undefined || + (intent.surface === 'chat' && intent.chatOptions === undefined) + const model = (intent.sessionOptions ?? intent.chatOptions)?.model + return chatNamed && + typeof model === 'string' && + getAgentSessionOptionCatalog(intent.agent)?.chatModelId + ? model + : undefined +} + +/** The options a terminal leg starts with: a caller's saved chat choice applies to it too, except + * a chat model id the terminal can't take. */ +function terminalLaunchOptions(intent: TerminalOptionsIntent) { + const options = intent.sessionOptions ?? intent.chatOptions + if (!options || terminalLaunchChatModel(intent) === undefined) { + return options + } + const { model: _chatModel, ...terminalOptions } = options + return terminalOptions } /** Refuses, before anything exists, an OpenCode terminal its host cannot verify, read as that diff --git a/src/main/agent-launch/agent-launch-warnings.ts b/src/main/agent-launch/agent-launch-warnings.ts index 57b814398d22..f17c4830556f 100644 --- a/src/main/agent-launch/agent-launch-warnings.ts +++ b/src/main/agent-launch/agent-launch-warnings.ts @@ -1,5 +1,7 @@ import type { AgentLaunchIntent } from '../../shared/agent-launch/contracts/agent-launch-intent' import { STRUCTURED_ACCOUNT_ENV_IGNORED_WARNING } from '../../shared/agent-launch/startup/agent-launch-account-env' +import { TUI_AGENT_DISPLAY_NAMES } from '../../shared/agent-launch/catalog/tui-agent-display-names' +import { terminalLaunchChatModel } from './agent-launch-surface-factories' export function combineLaunchWarnings( create: string | undefined, @@ -23,3 +25,19 @@ export function ignoredStructuredLaunchInputsWarning( ) return warning ? { warning } : undefined } + +/** A terminal's create warning, plus the chat model id it leaves out because it can't take it. */ +export function terminalLaunchWarning( + intent: AgentLaunchIntent, + create: string | undefined +): { warning: string } | undefined { + const model = terminalLaunchChatModel(intent) + const name = TUI_AGENT_DISPLAY_NAMES[intent.agent] + const warning = combineLaunchWarnings( + create, + model === undefined + ? undefined + : `Started ${name} in a terminal, which can't run the chat model ${model}, so ${name} uses its own default model.` + ) + return warning ? { warning } : undefined +} diff --git a/src/shared/agent-launch/choices/agent-launch-model-preferences.ts b/src/shared/agent-launch/choices/agent-launch-model-preferences.ts index 6318f40b910f..fc2c235a85bc 100644 --- a/src/shared/agent-launch/choices/agent-launch-model-preferences.ts +++ b/src/shared/agent-launch/choices/agent-launch-model-preferences.ts @@ -10,6 +10,7 @@ import { isPiModelOptionId } from '../../agent-session/options/catalog-providers import { parseDimaModelSelector } from '../../agent-session/options/model-catalog/dima-model-list-probe' import { resolveAgentSessionOptionLaunch } from '../../agent-session/options/launch/agent-session-option-launch' import type { TuiAgent } from '../catalog/tui-agent' +import type { AgentLaunchSurface } from '../contracts/agent-launch-surface' export const OPENCODE_MODEL_VERSION_REFUSAL = 'OpenCode cannot safely start with a chosen model on this version. Update OpenCode to a supported release, or omit the model choice.' @@ -29,6 +30,8 @@ export type AgentLaunchModelPreferenceCheck = export function checkAgentLaunchModelPreferences(args: { agent: TuiAgent + /** The surface the caller asked for; absent may open either. */ + surface?: AgentLaunchSurface /** OpenCode model choices need a fresh terminal on a supported execution host. */ openCodeModelLaunchSupported?: boolean createsWorktree?: boolean @@ -68,8 +71,9 @@ export function checkAgentLaunchModelPreferences(args: { `Agent pi needs a provider/id model, such as anthropic/claude-sonnet-4-5; got ${args.model}.` ) } - // A bare id would run on whichever provider dima resolves; the picker always names one. - if (args.agent === 'dima' && !parseDimaModelSelector(args.model)) { + // A terminal's bare id would run on whichever provider dima resolves; a chat's model option + // takes dima's own model id, which dima itself checks. + if (args.agent === 'dima' && args.surface !== 'chat' && !parseDimaModelSelector(args.model)) { return refuse( 'invalid_argument', `Agent dima needs a provider/model selector, such as openai-codex/gpt-5.5; got ${args.model}.` From 99e399cacb885d216297162e6143d4d16c2fef13 Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Wed, 25 Nov 2026 06:06:45 -0800 Subject: [PATCH 07/10] fix(dima): list a running daemon's models only for its own profile A dima daemon serves one model profile, product or a --model-config file, and its hello names it (alpha.25 and .29: daemonProfile with the file's sha256). dima refuses to launch against a daemon of another profile, so the catalog probe now makes the same check: it reuses a daemon whose profile matches the launch's Arguments and otherwise reports the mismatch, leaving that daemon running. A --model-config daemon lists no provider catalog, so its launch offers the file's default model. Co-Authored-By: Claude Opus 5.5 --- .../models/dima-daemon-connection.ts | 141 ++++++++++++++++++ .../models/dima-model-list-discovery.ts | 123 ++++----------- .../models/dima-model-list-startup.ts | 2 + 3 files changed, 169 insertions(+), 97 deletions(-) create mode 100644 src/main/text-generation/models/dima-daemon-connection.ts diff --git a/src/main/text-generation/models/dima-daemon-connection.ts b/src/main/text-generation/models/dima-daemon-connection.ts new file mode 100644 index 000000000000..8f625c909019 --- /dev/null +++ b/src/main/text-generation/models/dima-daemon-connection.ts @@ -0,0 +1,141 @@ +import { createHash } from 'node:crypto' +import { readFile } from 'node:fs/promises' +import { connect } from 'node:net' +import { resolve } from 'node:path' +import { StringDecoder } from 'node:string_decoder' +import { createIncrementalNdjsonFramer } from '../../../shared/json-stream/main-process-ndjson-framer' +import { isProviderRecord } from '../../provider-process/provider-json-record' + +// dima's native client accepts up to 16 MiB per JSON frame, including a full provider catalog. +const DIMA_FRAME_BYTES = 16 * 1024 * 1024 +// dima's own client steps down one refused version per new connection. +const PROTOCOL_VERSIONS = [4, 3] + +export type DaemonReply = { result?: unknown; error?: unknown } +export type DaemonCall = (method: string, params: Record) => Promise +type Daemon = { call: DaemonCall; close: () => void } + +/** The model profile a home's daemon reports in `hello`: dima's own provider catalog, or the + * --model-config file it started with, by the SHA-256 of that file's bytes. */ +export type DimaDaemonProfile = + | { kind: 'product' } + | { kind: 'configured'; modelConfigSha256: string } + +/** The profile `dima [--model-config PATH]` run in `cwd` requires of the daemon it would use; + * rejects when the file can't be read, as dima itself then refuses to start. */ +export async function dimaLaunchProfile( + modelConfig: string | undefined, + cwd: string | undefined +): Promise { + if (modelConfig === undefined) { + return { kind: 'product' } + } + const bytes = await readFile(resolve(cwd ?? process.cwd(), modelConfig)) + return { kind: 'configured', modelConfigSha256: createHash('sha256').update(bytes).digest('hex') } +} + +function servesProfile(reported: unknown, expected: DimaDaemonProfile): boolean { + return ( + isProviderRecord(reported) && + reported.kind === expected.kind && + (expected.kind === 'product' || reported.modelConfigSha256 === expected.modelConfigSha256) + ) +} + +/** Why a launch can't use its home's running daemon: dima refuses another profile's daemon and + * never replaces it, so its models would not be the ones the launch runs. */ +export function dimaDaemonProfileError(label: string, expected: DimaDaemonProfile): string { + const asked = + expected.kind === 'configured' + ? "uses a different model profile than the --model-config in its Arguments, so dima won't launch with them" + : "was started with a --model-config that its Arguments don't name, so dima won't launch without it" + return `${label}'s running daemon for this home ${asked}. Use a separate --home for each --model-config, or stop that daemon once nothing uses it.` +} + +/** A connection to a daemon that already listens; null when none answers. Never starts one. */ +function openDaemon(endpoint: string, signal: AbortSignal): Promise { + return new Promise((settle) => { + if (signal.aborted) { + settle(null) + return + } + const socket = connect(endpoint) + const pending = new Map void>() + const decoder = new StringDecoder('utf8') + let nextId = 0 + const close = (): void => { + socket.destroy() + } + signal.addEventListener('abort', close, { once: true }) + const framer = createIncrementalNdjsonFramer( + (message) => { + if (!isProviderRecord(message) || typeof message.id !== 'number') { + return + } + const answer = pending.get(message.id) + pending.delete(message.id) + answer?.(message) + }, + close, + { maxLineBytes: DIMA_FRAME_BYTES } + ) + socket.on('data', (chunk: Buffer) => { + framer.feed(decoder.write(chunk)) + }) + socket.on('error', () => settle(null)) + socket.on('close', () => { + signal.removeEventListener('abort', close) + settle(null) + for (const answer of pending.values()) { + answer({ error: 'closed' }) + } + pending.clear() + }) + socket.once('connect', () => + settle({ + call: (method, params) => + socket.destroyed + ? Promise.resolve({ error: 'closed' }) + : new Promise((answer) => { + nextId += 1 + pending.set(nextId, answer) + socket.write(`${JSON.stringify({ jsonrpc: '2.0', id: nextId, method, params })}\n`) + }), + close + }) + ) + }) +} + +/** Greets the daemon as dima's client does, including its model profile check. */ +export async function greetDaemon( + endpoint: string, + signal: AbortSignal, + profile: DimaDaemonProfile +): Promise<(Daemon & { features: string[]; servesProfile: boolean }) | null> { + for (const protocolVersion of PROTOCOL_VERSIONS) { + const daemon = await openDaemon(endpoint, signal) + if (!daemon) { + return null + } + const reply = await daemon.call('hello', { + protocolVersion, + clientKind: 'other', + clientName: 'Orca' + }) + const hello = isProviderRecord(reply.result) ? reply.result : undefined + if (hello && Array.isArray(hello.features)) { + return { + ...daemon, + features: hello.features.filter((name): name is string => typeof name === 'string'), + servesProfile: servesProfile(hello.daemonProfile, profile) + } + } + daemon.close() + const refusal = isProviderRecord(reply.error) ? reply.error.data : undefined + if (!isProviderRecord(refusal) || refusal.appError !== 'protocol_version') { + return null + } + } + return null +} diff --git a/src/main/text-generation/models/dima-model-list-discovery.ts b/src/main/text-generation/models/dima-model-list-discovery.ts index 1032b4b9d084..c29bb9c88969 100644 --- a/src/main/text-generation/models/dima-model-list-discovery.ts +++ b/src/main/text-generation/models/dima-model-list-discovery.ts @@ -1,10 +1,7 @@ import { createHash } from 'node:crypto' import { lstat, realpath } from 'node:fs/promises' -import { connect } from 'node:net' import { homedir } from 'node:os' import { join, resolve } from 'node:path' -import { StringDecoder } from 'node:string_decoder' -import { createIncrementalNdjsonFramer } from '../../../shared/json-stream/main-process-ndjson-framer' import { dimaCatalogModels, dimaCatalogReplyModels, @@ -15,18 +12,17 @@ import type { AgentModelProbeSpec } from '../../../shared/agent-session/options/ import { isProviderRecord } from '../../provider-process/provider-json-record' import { staticModelDiscoveryResult } from './commit-message-model-discovery-policy' import type { DiscoverCommitMessageModelsResult } from '../source-control-text-generation-types' +import { + dimaDaemonProfileError, + dimaLaunchProfile, + greetDaemon, + type DaemonCall, + type DaemonReply +} from './dima-daemon-connection' -// dima's native client accepts up to 16 MiB per JSON frame, including a full provider catalog. -const DIMA_FRAME_BYTES = 16 * 1024 * 1024 const PROBE_TIMEOUT_MS = 10_000 const PAGE_LIMIT = 128 const MAX_PAGES = 64 -// dima's own client steps down one refused version per new connection. -const PROTOCOL_VERSIONS = [4, 3] - -type DaemonReply = { result?: unknown; error?: unknown } -type DaemonCall = (method: string, params: Record) => Promise -type Daemon = { call: DaemonCall; close: () => void } function envLookup( env: NodeJS.ProcessEnv, @@ -84,91 +80,6 @@ export async function dimaDaemonEndpoint( return `\\\\.\\pipe\\dim-rust-${key.slice(0, 32)}` } -/** A connection to a daemon that already listens; null when none answers. Never starts one. */ -function openDaemon(endpoint: string, signal: AbortSignal): Promise { - return new Promise((settle) => { - if (signal.aborted) { - settle(null) - return - } - const socket = connect(endpoint) - const pending = new Map void>() - const decoder = new StringDecoder('utf8') - let nextId = 0 - const close = (): void => { - socket.destroy() - } - signal.addEventListener('abort', close, { once: true }) - const framer = createIncrementalNdjsonFramer( - (message) => { - if (!isProviderRecord(message) || typeof message.id !== 'number') { - return - } - const answer = pending.get(message.id) - pending.delete(message.id) - answer?.(message) - }, - close, - { maxLineBytes: DIMA_FRAME_BYTES } - ) - socket.on('data', (chunk: Buffer) => { - framer.feed(decoder.write(chunk)) - }) - socket.on('error', () => settle(null)) - socket.on('close', () => { - signal.removeEventListener('abort', close) - settle(null) - for (const answer of pending.values()) { - answer({ error: 'closed' }) - } - pending.clear() - }) - socket.once('connect', () => - settle({ - call: (method, params) => - socket.destroyed - ? Promise.resolve({ error: 'closed' }) - : new Promise((answer) => { - nextId += 1 - pending.set(nextId, answer) - socket.write(`${JSON.stringify({ jsonrpc: '2.0', id: nextId, method, params })}\n`) - }), - close - }) - ) - }) -} - -async function greetDaemon( - endpoint: string, - signal: AbortSignal -): Promise<(Daemon & { features: string[] }) | null> { - for (const protocolVersion of PROTOCOL_VERSIONS) { - const daemon = await openDaemon(endpoint, signal) - if (!daemon) { - return null - } - const reply = await daemon.call('hello', { - protocolVersion, - clientKind: 'other', - clientName: 'Orca' - }) - const features = isProviderRecord(reply.result) ? reply.result.features : undefined - if (Array.isArray(features)) { - return { - ...daemon, - features: features.filter((name): name is string => typeof name === 'string') - } - } - daemon.close() - const refusal = isProviderRecord(reply.error) ? reply.error.data : undefined - if (!isProviderRecord(refusal) || refusal.appError !== 'protocol_version') { - return null - } - } - return null -} - function result(reply: DaemonReply, method: string): unknown { if (reply.error !== undefined) { throw new Error(`${method} failed`) @@ -268,6 +179,8 @@ export async function discoverDimaModels( cwd?: string wslDistro?: string productHome?: string + /** The --model-config path of the launch the models are for, as its Arguments name it. */ + modelConfig?: string startDaemon?: (signal: AbortSignal) => Promise } ): Promise { @@ -282,9 +195,16 @@ export async function discoverDimaModels( ) { return staticModelDiscoveryResult(spec, [], spec.defaultModelId, 'probe') } + const profile = await dimaLaunchProfile(input.modelConfig, input.cwd).catch(() => null) + if (!profile) { + return { + success: false, + error: `${spec.label} can't read the --model-config file in its Arguments, ${input.modelConfig}.` + } + } const connectToDaemon = async (signal: AbortSignal) => { const endpoint = await dimaDaemonEndpoint(env, input.cwd, process.platform, input.productHome) - return endpoint ? greetDaemon(endpoint, signal) : null + return endpoint ? greetDaemon(endpoint, signal, profile) : null } const deadline = new AbortController() const timer = setTimeout(() => deadline.abort(), PROBE_TIMEOUT_MS) @@ -300,6 +220,15 @@ export async function discoverDimaModels( error: `${spec.label} could not reach its model catalog. Check the dima installation and refresh the list.` } } + // Reused only when it serves this launch's profile; another profile's daemon is left running. + if (!daemon.servesProfile) { + return { success: false, error: dimaDaemonProfileError(spec.label, profile) } + } + // A --model-config daemon lists no provider catalog (alpha.25 and .29); a launch runs the + // file's default model unless its Arguments name --provider and --model. + if (profile.kind === 'configured' && !daemon.features.includes('provider.models.query')) { + return staticModelDiscoveryResult(spec, [], spec.defaultModelId, 'probe') + } const { models, partial } = daemon.features.includes('provider.models.query') ? { models: await querySelectableModels(daemon.call), partial: false } : await readProviderCatalogs(daemon.call) diff --git a/src/main/text-generation/models/dima-model-list-startup.ts b/src/main/text-generation/models/dima-model-list-startup.ts index e599b3163109..a59397b9dd96 100644 --- a/src/main/text-generation/models/dima-model-list-startup.ts +++ b/src/main/text-generation/models/dima-model-list-startup.ts @@ -68,10 +68,12 @@ export async function discoverDimaModelsOnHost( process.platform ) const homeIndex = args.lastIndexOf('--home') + const configIndex = args.lastIndexOf('--model-config') return discoverDimaModels(spec, { ...input.options, env, productHome: homeIndex !== -1 ? args[homeIndex + 1] : undefined, + modelConfig: configIndex !== -1 ? args[configIndex + 1] : undefined, startDaemon: (signal) => startDimaForModelListing( input.spawnAgent, From 7c1c93ca48e7decf38f7cd099f2c515658de5a07 Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Wed, 25 Nov 2026 06:06:53 -0800 Subject: [PATCH 08/10] fix(dima): check a chat model picked mid-listing again once the list settles The continuation dialog and the quick workspace composer kept the picker entry from the moment of the pick. A DimAgent chat model picked while its list was still loading or refreshing stayed refused as unproven after the list settled, so Start stayed disabled and Create kept refusing. Such a pick now watches the form's model list and is checked again once it settles; a model another provider also offers is still refused. Co-Authored-By: Claude Opus 5.5 --- .../AgentSessionContinuationDialog.tsx | 15 +++++---- .../agent/use-agent-picker-chat-pick.ts | 33 +++++++++++++++++++ .../composer/NewWorkspaceComposerModal.tsx | 18 +++++----- 3 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 src/renderer/src/components/agent/use-agent-picker-chat-pick.ts diff --git a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx index da2970dd6d04..502c8634355e 100644 --- a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx +++ b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx @@ -4,7 +4,7 @@ import { worktreeLaunchWorkspace } from '@/lib/agent-session/launch/routing/agen import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react' import { Loader2 } from 'lucide-react' import { AgentLaunchPicker } from '@/components/agent/AgentLaunchPicker' -import { agentPickerChatLaunchRefusal } from '@/components/agent/agent-launch-picker-chat-model-refusal' +import { useAgentPickerChatPick } from '@/components/agent/use-agent-picker-chat-pick' import { agentPickerFreshLaunchInputs, type AgentPickerDraft, @@ -179,10 +179,13 @@ export function AgentSessionContinuationDialog({ defaultAgent: settings?.defaultTuiAgent }) const selection = observation.selectionFor(selectedAgent, currentPick?.surface) - const chatModelRefusal = - currentPick?.draft && currentPick.entry && selection.choice?.route !== 'terminal-tui' - ? agentPickerChatLaunchRefusal(currentPick.entry, currentPick.draft) - : null + const chatPick = useAgentPickerChatPick( + destinationModel, + currentPick, + open && selection.choice?.route !== 'terminal-tui', + request?.worktreeId + ) + const chatModelRefusal = chatPick.refusal useEffect(() => { if (!starting) { @@ -228,7 +231,7 @@ export function AgentSessionContinuationDialog({ surface: selection.choice.route === 'terminal-tui' ? 'terminal' : 'chat', executionHostId: selection.choice.executionHostId }, - currentPick.entry + chatPick.entry ) : {}), launchSource: request.launchSource, diff --git a/src/renderer/src/components/agent/use-agent-picker-chat-pick.ts b/src/renderer/src/components/agent/use-agent-picker-chat-pick.ts new file mode 100644 index 000000000000..686611d6e91b --- /dev/null +++ b/src/renderer/src/components/agent/use-agent-picker-chat-pick.ts @@ -0,0 +1,33 @@ +import { useMemo } from 'react' +import { agentPickerCatalogAuthoritative } from '../../../../shared/agent-launch/picker/agent-launch-picker-authority' +import { agentPickerChatLaunchModel } from '../../../../shared/agent-launch/picker/agent-launch-picker-chat-model' +import type { + AgentPickerDraft, + AgentPickerEntry +} from '../../../../shared/agent-launch/picker/agent-launch-picker' +import type { NewTabAgentMenuModel } from './launch-menu/new-tab-agent-menu-model' +import { agentPickerChatLaunchRefusal } from './agent-launch-picker-chat-model-refusal' +import { useAgentLaunchPickerInventory } from './use-agent-launch-picker-inventory' + +/** A form's agent pick as the picker's model list now reads, and why a chat can't run its model. + * The picker hands over its entry only when picked, so a chat pick made while the list loaded + * keeps watching the form's list and is checked again once it settles, without a new pick. */ +export function useAgentPickerChatPick( + model: NewTabAgentMenuModel, + pick: { entry?: AgentPickerEntry; draft?: AgentPickerDraft } | null | undefined, + chat: boolean, + worktreeId?: string +): { entry: AgentPickerEntry | undefined; refusal: string | null } { + const picked = pick?.entry + const draft = pick?.draft + const checked = + chat && picked && draft ? agentPickerChatLaunchModel(picked, draft.choices.model) : undefined + const watched = + checked && 'refusal' in checked && checked.refusal === 'unproven' ? picked : undefined + const entries = useAgentLaunchPickerInventory(worktreeId, model, !!watched, watched?.agent) + const live = watched && entries.find((candidate) => candidate.agent === watched.agent) + // Only a settled list replaces the pick's own; until then the pick stands as it was checked. + const entry = live && agentPickerCatalogAuthoritative(live) ? live : picked + const refusal = chat && entry && draft ? agentPickerChatLaunchRefusal(entry, draft) : null + return useMemo(() => ({ entry, refusal }), [entry, refusal]) +} diff --git a/src/renderer/src/components/new-workspace/composer/NewWorkspaceComposerModal.tsx b/src/renderer/src/components/new-workspace/composer/NewWorkspaceComposerModal.tsx index 300804618ea0..f40d9340797b 100644 --- a/src/renderer/src/components/new-workspace/composer/NewWorkspaceComposerModal.tsx +++ b/src/renderer/src/components/new-workspace/composer/NewWorkspaceComposerModal.tsx @@ -1,6 +1,6 @@ import type { ComposerModalData } from './composer-modal-data' import { toast } from 'sonner' -import { agentPickerChatLaunchRefusal } from '@/components/agent/agent-launch-picker-chat-model-refusal' +import { useAgentPickerChatPick } from '@/components/agent/use-agent-picker-chat-pick' import { formatWorkspaceCreateError, getWorkspaceCreateErrorToastMessage @@ -218,6 +218,11 @@ function QuickTabBody({ const quickAgentSurface = quickAgentPick.agent === quickAgent ? quickAgentPick.surface : undefined const launchSelection = observation.selectionFor(quickAgent, quickAgentSurface) const createDisabled = formDisabled || !launchSelection.ready + const chatPick = useAgentPickerChatPick( + observation.model, + { entry: quickAgentPick.entry, draft: pickerDraft }, + active && pickerDraft?.surface === 'chat' + ) const handleQuickAgentChange = useCallback( ( @@ -236,12 +241,8 @@ function QuickTabBody({ if (createDisabled) { return } - const refusal = - pickerDraft?.surface === 'chat' && quickAgentPick.entry - ? agentPickerChatLaunchRefusal(quickAgentPick.entry, pickerDraft) - : null - if (refusal) { - toast.error(refusal) + if (chatPick.refusal) { + toast.error(chatPick.refusal) return } await submitQuick(quickAgent, { @@ -281,7 +282,7 @@ function QuickTabBody({ }, ...quickWorkspacePickerInputs( pickerDraft, - quickAgentPick.entry, + chatPick.entry, launchSelection.choice?.executionHostId ) }) @@ -292,6 +293,7 @@ function QuickTabBody({ submitQuick, pickerDraft, quickAgentPick, + chatPick, isSubmissionCancelled, modalData, cardProps From f892e20f9fc44e309130460217c3aa2691b10f78 Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Wed, 25 Nov 2026 06:11:19 -0800 Subject: [PATCH 09/10] docs(dima): say that a cold model listing starts dima's daemon Co-Authored-By: Claude Opus 5.5 --- .../source-control/ai/generation/commit-message-agent-spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/source-control/ai/generation/commit-message-agent-spec.ts b/src/shared/source-control/ai/generation/commit-message-agent-spec.ts index 5e178a7b9f01..7e4ffc81abc2 100644 --- a/src/shared/source-control/ai/generation/commit-message-agent-spec.ts +++ b/src/shared/source-control/ai/generation/commit-message-agent-spec.ts @@ -89,7 +89,7 @@ export type CommitMessageAgentSpec = { } | { binary: string - /** Read from the dima daemon already running; main never starts one. */ + /** Read from dima's daemon; a cold read starts it with dima's own `runtime list`. */ listing: 'dima-app-server' } models: CommitMessageModel[] From 0ac424f77d2c29eaeb23c70d8036d0e409af3009 Mon Sep 17 00:00:00 2001 From: ZinkLu <38710123+ZinkLu@users.noreply.github.com> Date: Wed, 25 Nov 2026 19:35:37 -0800 Subject: [PATCH 10/10] fix(dima): keep the daemon a cold model listing starts alive Since #48089 a one-shot's orca-provider-exec stops every process the command leaves behind, so the daemon `dima runtime list` starts for a cold listing died with it and every cold DimAgent model listing failed. That start now runs unsupervised in its own session (on Linux through orca-provider-exec --exec-without-inherited-fds, like Orca's daemon). Co-Authored-By: Claude Opus 5.5 --- .../source-control-daemon-starter-spawn.ts | 25 +++++++++++++++++++ .../source-control-supervised-agent-spawn.ts | 10 +++++++- .../models/dima-model-list-startup.ts | 3 ++- .../source-control-text-generation-types.ts | 2 ++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/main/text-generation/execution/source-control-daemon-starter-spawn.ts diff --git a/src/main/text-generation/execution/source-control-daemon-starter-spawn.ts b/src/main/text-generation/execution/source-control-daemon-starter-spawn.ts new file mode 100644 index 000000000000..fe6f0468a561 --- /dev/null +++ b/src/main/text-generation/execution/source-control-daemon-starter-spawn.ts @@ -0,0 +1,25 @@ +import { spawnProcess } from '@orca/process-host' +import { FD_CLOSING_EXEC_ARGS } from '../../daemon/launch/daemon-fd-closing-exec' +import { resolveProviderExecPath } from '../../provider-process/provider-process-supervisor' +import type { + SourceControlAgentSpawnInput, + SpawnedSourceControlAgentProcess +} from '../source-control-text-generation-types' + +/** Unsupervised, since a one-shot's supervisor stops the daemon this command leaves running. */ +export function spawnDaemonStarterAgent( + launch: { binary: string; args: readonly string[]; cwd?: string; env: NodeJS.ProcessEnv }, + stdinMode: SourceControlAgentSpawnInput['stdinMode'] +): SpawnedSourceControlAgentProcess { + // Linux: like Orca's own daemon, it must not keep main's Chromium IPC sockets open. + const fdClosingExec = process.platform === 'linux' ? resolveProviderExecPath('linux') : undefined + return spawnProcess({ + program: fdClosingExec ?? launch.binary, + args: fdClosingExec ? [...FD_CLOSING_EXEC_ARGS, launch.binary, ...launch.args] : launch.args, + env: launch.env, + ...(launch.cwd !== undefined ? { cwd: launch.cwd } : {}), + // Its own session, as the supervisor gave it, so signals to Orca's group miss the daemon. + detached: true, + stdio: [stdinMode, 'pipe', 'pipe'] + }) +} diff --git a/src/main/text-generation/execution/source-control-supervised-agent-spawn.ts b/src/main/text-generation/execution/source-control-supervised-agent-spawn.ts index 69cfb5368dda..64064e3a8c2c 100644 --- a/src/main/text-generation/execution/source-control-supervised-agent-spawn.ts +++ b/src/main/text-generation/execution/source-control-supervised-agent-spawn.ts @@ -6,6 +6,7 @@ import { resolveGuestNativeAgentCommand } from '../../codex-cli/command' import { createProviderSpawnSpec } from '../../provider-process/provider-process-supervisor' import { spawnProviderProcess } from '../../provider-process/provider-process-spawn' import { guestNativeSpawnEnv } from '../../wsl/filesystem/wsl-guest-windows-drive-path' +import { spawnDaemonStarterAgent } from './source-control-daemon-starter-spawn' import type { SourceControlAgentSpawnInput, SpawnedSourceControlAgentProcess @@ -26,9 +27,16 @@ export function spawnSupervisedAgent( pathEnv: pathEnvRelativeTo(env.PATH, cwd ?? process.cwd()), homePath: env.HOME }) + const childEnv = withCliRuntimeOnPath(binary, env) + if (input.startsSharedDaemon) { + return spawnDaemonStarterAgent( + { binary, args: input.args, cwd, env: childEnv }, + input.stdinMode + ) + } const spec = createProviderSpawnSpec( { command: binary, args: input.args, ...(cwd !== undefined ? { cwd } : {}) }, - withCliRuntimeOnPath(binary, env), + childEnv, process.platform, { lifetime: 'one-shot' } ) diff --git a/src/main/text-generation/models/dima-model-list-startup.ts b/src/main/text-generation/models/dima-model-list-startup.ts index a59397b9dd96..a218afbe14a1 100644 --- a/src/main/text-generation/models/dima-model-list-startup.ts +++ b/src/main/text-generation/models/dima-model-list-startup.ts @@ -83,7 +83,8 @@ export async function discoverDimaModelsOnHost( cwd: input.options.cwd, env, stdinMode: 'ignore', - useCwdForNative: true + useCwdForNative: true, + startsSharedDaemon: true }, signal ) diff --git a/src/main/text-generation/source-control-text-generation-types.ts b/src/main/text-generation/source-control-text-generation-types.ts index e03985a23e9e..0051261c5143 100644 --- a/src/main/text-generation/source-control-text-generation-types.ts +++ b/src/main/text-generation/source-control-text-generation-types.ts @@ -128,6 +128,8 @@ export type SourceControlAgentSpawnInput = { literalArgIndices?: number[] stdinMode: 'ignore' | 'pipe' useCwdForNative: boolean + /** The command starts a daemon other clients share, so it must outlive the command. */ + startsSharedDaemon?: true } export type SpawnSourceControlAgent = (