Skip to content

πŸ™Œ OpenHands: AI-Driven Development

refactor(acp): source ACP model lists from typescript-client (closes #740) (#775)

simonrosenbergcc63f48a07ef
diff --git a/.github/workflows/acp-providers-sync.yml b/.github/workflows/acp-providers-sync.yml
deleted file mode 100644
index ffb780e1c6..0000000000
--- a/.github/workflows/acp-providers-sync.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-name: ACP Providers Sync
-
-# Catches drift between this repo's hand-mirrored ACP provider registry
-# (src/constants/acp-providers.ts) and the SDK's source of truth at
-# openhands-sdk/openhands/sdk/settings/acp_providers.py in
-# OpenHands/software-agent-sdk. See agent-canvas#587 for the failure mode
-# this exists to prevent.
-
-on:
- pull_request:
- paths:
- - "src/constants/acp-providers.ts"
- - "scripts/check-acp-providers-sync.mjs"
- - ".github/workflows/acp-providers-sync.yml"
- push:
- branches:
- - main
- paths:
- - "src/constants/acp-providers.ts"
- - "scripts/check-acp-providers-sync.mjs"
- - ".github/workflows/acp-providers-sync.yml"
-
- # SDK repo can trigger us when it changes acp_providers.py:
- # curl -X POST \
- # -H "Authorization: token $GITHUB_TOKEN" \
- # -H "Accept: application/vnd.github.v3+json" \
- # https://api.github.com/repos/OpenHands/agent-canvas/dispatches \
- # -d '{"event_type":"acp-providers-check","client_payload":{"sdk_ref":"main"}}'
- repository_dispatch:
- types: [acp-providers-check, sdk-release]
-
- workflow_dispatch:
- inputs:
- sdk_ref:
- description: "Git ref in OpenHands/software-agent-sdk to compare against (default: main)"
- required: false
- type: string
-
- # Daily run catches drift introduced by SDK changes that didn't ping us
- # (the repository_dispatch path requires the SDK side to opt in). 07:13 UTC
- # is off the hour to avoid contending with the SDK-version-sync cron.
- schedule:
- - cron: "13 7 * * *"
-
-concurrency:
- group: acp-providers-sync-${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
-permissions:
- contents: read
-
-jobs:
- check-acp-providers:
- name: Check ACP providers registry consistency
- runs-on: ubuntu-24.04
- timeout-minutes: 5
-
- steps:
- - name: Check out repository
- uses: actions/checkout@v6
-
- - name: Set up Node.js
- uses: actions/setup-node@v6
- with:
- node-version: "24"
-
- - name: Log trigger info
- run: |
- echo "Triggered by: ${{ github.event_name }}"
- if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
- echo "Event type: ${{ github.event.action }}"
- echo "Client payload: ${{ toJson(github.event.client_payload) }}"
- fi
- if [ -n "${{ inputs.sdk_ref }}" ]; then
- echo "SDK ref input: ${{ inputs.sdk_ref }}"
- fi
-
- - name: Check ACP providers sync
- env:
- # workflow_dispatch input wins; otherwise fall back to the
- # repository_dispatch payload; otherwise the script defaults to "main".
- ACP_SDK_REF: ${{ inputs.sdk_ref || github.event.client_payload.sdk_ref || '' }}
- run: node scripts/check-acp-providers-sync.mjs
diff --git a/__tests__/scripts/docs-version-sync.test.ts b/__tests__/scripts/docs-version-sync.test.ts
index 94252a7022..7a8d6959c6 100644
--- a/__tests__/scripts/docs-version-sync.test.ts
+++ b/__tests__/scripts/docs-version-sync.test.ts
@@ -55,9 +55,4 @@ describe("docs/example references stay in sync with config/defaults.json", () =>
`">=${v}", "==${v}", "(>=${v})", "~=${v}"`,
);
});
-
- it("scripts/check-acp-providers-sync.mjs --sdk-ref example matches the current default", () => {
- const src = read("scripts/check-acp-providers-sync.mjs");
- expect(src).toContain(`--sdk-ref v${v}`);
- });
});
diff --git a/package-lock.json b/package-lock.json
index 6d3a3e02e8..7206c1c89e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13,7 +13,7 @@
"@microlink/react-json-view": "1.31.20",
"@monaco-editor/react": "4.7.0",
"@openhands/extensions": "git+https://github.com/OpenHands/extensions.git#7b33f64ffccf95f7ccd2ec640aeae84ab1cc2c75",
- "@openhands/typescript-client": "git+https://github.com/OpenHands/typescript-client.git#v1.23.0",
+ "@openhands/typescript-client": "git+https://github.com/OpenHands/typescript-client.git#v1.23.2",
"@react-router/node": "7.14.2",
"@react-router/serve": "7.14.2",
"@tailwindcss/vite": "4.2.4",
@@ -3455,7 +3455,8 @@
},
"node_modules/@openhands/typescript-client": {
"version": "0.1.1",
- "resolved": "git+https://github.com/OpenHands/typescript-client.git#v1.23.0",
+ "resolved": "git+ssh://[email protected]/OpenHands/typescript-client.git#082d4d46d4ae16f383b94884c7f0924640432203",
+ "integrity": "sha512-0OIRjvaAIhg4+yH245BCXoSiB9SDFPqxQ+HNsnG3CtZrszYXQkl9+x6nL/hoKuUff1NMVeeaT9Wucm1PqweYMg==",
"license": "MIT",
"dependencies": {
"@openrouter/sdk": "^0.12.35",
diff --git a/package.json b/package.json
index 0dab534b1c..f3fd5b8d87 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
"@microlink/react-json-view": "1.31.20",
"@monaco-editor/react": "4.7.0",
"@openhands/extensions": "git+https://github.com/OpenHands/extensions.git#7b33f64ffccf95f7ccd2ec640aeae84ab1cc2c75",
- "@openhands/typescript-client": "git+https://github.com/OpenHands/typescript-client.git#v1.23.0",
+ "@openhands/typescript-client": "git+https://github.com/OpenHands/typescript-client.git#v1.23.2",
"@react-router/node": "7.14.2",
"@react-router/serve": "7.14.2",
"@tailwindcss/vite": "4.2.4",
diff --git a/scripts/check-acp-providers-sync.mjs b/scripts/check-acp-providers-sync.mjs
deleted file mode 100755
index 7ff56f57df..0000000000
--- a/scripts/check-acp-providers-sync.mjs
+++ /dev/null
@@ -1,560 +0,0 @@
-#!/usr/bin/env node
-
-/**
- * Check ACP Providers Sync
- *
- * Verifies the canvas TypeScript mirror in ``src/constants/acp-providers.ts``
- * stays in lockstep with the Python source of truth at
- * ``openhands-sdk/openhands/sdk/settings/acp_providers.py`` in
- * https://github.com/OpenHands/software-agent-sdk.
- *
- * Why this exists (#587): the registries can drift silently and the failure
- * mode is invisible β€” a stale ``default_command`` spawns a CLI that doesn't
- * speak ACP and the agent-server deadlocks on the handshake (we shipped
- * ``["npx","-y","@openai/codex","acp"]`` once and it took an E2E session to
- * find). This check fails CI before that ships.
- *
- * Compared fields (the subset the TS mirror actually carries):
- * - key
- * - display_name
- * - default_command
- *
- * The richer SDK record (api_key_env_var, base_url_env_var, session mode,
- * agent_name_patterns, supports_set_session_model, session_meta_key) is
- * intentionally NOT mirrored on the canvas side β€” canvas only uses this
- * registry in Settings β†’ Agent + onboarding tile rendering. Those fields
- * live in the SDK because ``ACPAgent`` reads them at spawn time inside
- * the agent-server, where canvas never runs.
- *
- * Usage:
- * node scripts/check-acp-providers-sync.mjs
- * node scripts/check-acp-providers-sync.mjs --sdk-ref v1.23.0
- * node scripts/check-acp-providers-sync.mjs --sdk-file /path/to/acp_providers.py
- *
- * Options:
- * --sdk-ref <ref> Git ref in OpenHands/software-agent-sdk to fetch
- * acp_providers.py from. Default: ``main``. Also
- * overridable via ``ACP_SDK_REF`` env var.
- * --sdk-repo <owner/name> Override the SDK repo (default
- * ``OpenHands/software-agent-sdk``).
- * --sdk-file <path> Read the Python source from a local file instead
- * of GitHub. Wins over --sdk-ref. Useful for testing
- * offline or against a local SDK checkout.
- * --ts-file <path> Override the TS mirror path (default
- * ``src/constants/acp-providers.ts``).
- * --json Emit a machine-readable summary on stdout
- * (the human-readable report still goes to stderr).
- * --help, -h Show help.
- *
- * Exit codes:
- * 0 β€” Registries match on the compared fields.
- * 1 β€” Drift detected, or parse/fetch error.
- */
-
-import { readFileSync } from "node:fs";
-import { dirname, join, resolve } from "node:path";
-import { fileURLToPath } from "node:url";
-import process from "node:process";
-
-const __dirname = dirname(fileURLToPath(import.meta.url));
-const projectRoot = join(__dirname, "..");
-
-const DEFAULT_SDK_REPO = "OpenHands/software-agent-sdk";
-const DEFAULT_SDK_PATH =
- "openhands-sdk/openhands/sdk/settings/acp_providers.py";
-const DEFAULT_TS_PATH = join(
- projectRoot,
- "src",
- "constants",
- "acp-providers.ts",
-);
-
-const colors = {
- reset: "\x1b[0m",
- red: "\x1b[31m",
- green: "\x1b[32m",
- yellow: "\x1b[33m",
- cyan: "\x1b[36m",
- dim: "\x1b[2m",
-};
-
-function parseArgs(argv) {
- const args = {
- help: false,
- sdkFile: null,
- sdkRef: process.env.ACP_SDK_REF || "main",
- sdkRepo: DEFAULT_SDK_REPO,
- tsFile: DEFAULT_TS_PATH,
- json: false,
- };
- for (let i = 0; i < argv.length; i++) {
- const a = argv[i];
- if (a === "--help" || a === "-h") args.help = true;
- else if (a === "--sdk-file") args.sdkFile = argv[++i];
- else if (a === "--sdk-ref") args.sdkRef = argv[++i];
- else if (a === "--sdk-repo") args.sdkRepo = argv[++i];
- else if (a === "--ts-file") args.tsFile = argv[++i];
- else if (a === "--json") args.json = true;
- else throw new Error(`Unknown argument: ${a}`);
- }
- return args;
-}
-
-function showHelp() {
- process.stdout.write(
- `\nACP Providers Sync Check\n\n` +
- `Verifies that src/constants/acp-providers.ts matches the SDK's\n` +
- `acp_providers.py on the fields canvas mirrors (key, display_name,\n` +
- `default_command).\n\n` +
- `Usage:\n` +
- ` node scripts/check-acp-providers-sync.mjs [options]\n\n` +
- `Options:\n` +
- ` --sdk-ref <ref> Git ref to fetch from (default: main, env ACP_SDK_REF)\n` +
- ` --sdk-repo <owner/name> Override SDK repo (default: ${DEFAULT_SDK_REPO})\n` +
- ` --sdk-file <path> Read Python source from a local path instead\n` +
- ` --ts-file <path> Override TS mirror path\n` +
- ` --json Emit JSON summary on stdout\n` +
- ` --help, -h Show this help\n\n` +
- `Exit codes: 0 = in sync, 1 = drift or error.\n\n`,
- );
-}
-
-/**
- * String-aware brace matcher. Skips characters inside ``"…"`` / ``'…'``
- * (with backslash escapes), Python triple-quoted strings, ``#`` line
- * comments, and JS ``//`` / ``/* … *\/`` comments β€” anywhere we know
- * the source file might legitimately contain the delimiter without
- * meaning a real depth change. Returns the index of the matching close
- * delimiter or -1 if none.
- */
-function findMatchingDelimiter(source, openIdx, open, close) {
- let depth = 0;
- let i = openIdx;
- while (i < source.length) {
- const c = source[i];
- // Python triple-quoted strings.
- if (
- (c === '"' || c === "'") &&
- source[i + 1] === c &&
- source[i + 2] === c
- ) {
- const q = c;
- i += 3;
- while (i < source.length - 2) {
- if (source[i] === q && source[i + 1] === q && source[i + 2] === q) {
- i += 3;
- break;
- }
- i++;
- }
- continue;
- }
- if (c === '"' || c === "'" || c === "`") {
- const q = c;
- i++;
- while (i < source.length) {
- if (source[i] === "\\") {
- i += 2;
- continue;
- }
- if (source[i] === q) {
- i++;
- break;
- }
- i++;
- }
- continue;
- }
- if (c === "#") {
- while (i < source.length && source[i] !== "\n") i++;
- continue;
- }
- if (c === "/" && source[i + 1] === "/") {
- while (i < source.length && source[i] !== "\n") i++;
- continue;
- }
- if (c === "/" && source[i + 1] === "*") {
- i += 2;
- while (
- i < source.length - 1 &&
- !(source[i] === "*" && source[i + 1] === "/")
- )
- i++;
- i += 2;
- continue;
- }
- if (c === open) depth++;
- else if (c === close) {
- depth--;
- if (depth === 0) return i;
- }
- i++;
- }
- return -1;
-}
-
-/** Extract the contents of every double-quoted string literal in ``s``, in order. */
-function extractStringList(s) {
- const out = [];
- const re = /"((?:\\.|[^"\\])*)"/g;
- let m;
- while ((m = re.exec(s)) !== null) {
- // Resolve the common escapes we might see in command tokens.
- out.push(m[1].replace(/\\(.)/g, "$1"));
- }
- return out;
-}
-
-/**
- * Parse the SDK Python source and return one record per provider entry:
- * { mapKey, key, display_name, default_command }
- *
- * ``mapKey`` is the outer mapping key (``"claude-code"`` in the example
- * below); ``key`` is the ``key=...`` argument inside ``ACPProviderInfo``.
- * They should always agree in practice, but we surface them separately
- * so a drift between them is caught as a field mismatch rather than
- * silently dropped.
- *
- * Expected shape:
- * ACP_PROVIDERS: Mapping[str, ACPProviderInfo] = MappingProxyType(
- * {
- * "claude-code": ACPProviderInfo(
- * key="claude-code",
- * display_name="Claude Code",
- * default_command=("npx", "-y", "@…"),
- * …
- * ),
- * …
- * }
- * )
- */
-export function parsePython(source) {
- const startMatch = source.match(
- /ACP_PROVIDERS\s*:\s*Mapping[^=]*=\s*MappingProxyType\s*\(\s*\{/,
- );
- if (!startMatch) {
- throw new Error(
- "Could not find `ACP_PROVIDERS: Mapping[...] = MappingProxyType({...})` in Python source",
- );
- }
- const braceIdx = startMatch.index + startMatch[0].length - 1;
- const mapEnd = findMatchingDelimiter(source, braceIdx, "{", "}");
- if (mapEnd === -1)
- throw new Error("Unclosed `ACP_PROVIDERS` mapping literal");
- const body = source.slice(braceIdx + 1, mapEnd);
-
- const records = [];
- const reEntry = /"([^"]+)"\s*:\s*ACPProviderInfo\s*\(/g;
- let m;
- while ((m = reEntry.exec(body)) !== null) {
- const mapKey = m[1];
- const parenStart = m.index + m[0].length - 1;
- const parenEnd = findMatchingDelimiter(body, parenStart, "(", ")");
- if (parenEnd === -1)
- throw new Error(`Unclosed ACPProviderInfo(...) for ${mapKey}`);
- const inner = body.slice(parenStart + 1, parenEnd);
-
- const keyMatch = inner.match(/\bkey\s*=\s*"([^"]+)"/);
- const dnMatch = inner.match(/\bdisplay_name\s*=\s*"([^"]+)"/);
- if (!keyMatch || !dnMatch) {
- throw new Error(
- `Failed to parse key/display_name for Python provider ${mapKey}`,
- );
- }
- // default_command is a tuple β€” match the keyword then balance the opening `(`.
- const dcKwMatch = inner.match(/\bdefault_command\s*=\s*\(/);
- if (!dcKwMatch) {
- throw new Error(
- `Failed to find default_command tuple for Python provider ${mapKey}`,
- );
- }
- const dcOpen = dcKwMatch.index + dcKwMatch[0].length - 1;
- const dcClose = findMatchingDelimiter(inner, dcOpen, "(", ")");
- if (dcClose === -1)
- throw new Error(`Unclosed default_command tuple for ${mapKey}`);
- const default_command = extractStringList(inner.slice(dcOpen + 1, dcClose));
-
- records.push({
- mapKey,
- key: keyMatch[1],
- display_name: dnMatch[1],
- default_command,
- });
- }
- if (records.length === 0) {
- throw new Error("No ACPProviderInfo entries found in Python source");
- }
- return records;
-}
-
-/**
- * Parse ``export const ACP_PROVIDERS: ACPProviderConfig[] = [...]`` and
- * return one record per object literal:
- * { key, display_name, default_command }
- */
-export function parseTypeScript(source) {
- const m = source.match(
- /export\s+const\s+ACP_PROVIDERS\s*:\s*ACPProviderConfig\[\]\s*=\s*\[/,
- );
- if (!m) {
- throw new Error(
- "Could not find `export const ACP_PROVIDERS: ACPProviderConfig[] = [...]` in TS mirror",
- );
- }
- const bracketIdx = m.index + m[0].length - 1;
- const arrEnd = findMatchingDelimiter(source, bracketIdx, "[", "]");
- if (arrEnd === -1) throw new Error("Unclosed ACP_PROVIDERS array literal");
- const body = source.slice(bracketIdx + 1, arrEnd);
-
- // Walk the array body and split out each top-level `{...}` literal.
- const objects = [];
- let i = 0;
- while (i < body.length) {
- const c = body[i];
- if (c === "{") {
- const close = findMatchingDelimiter(body, i, "{", "}");
- if (close === -1)
- throw new Error("Unclosed object literal in ACP_PROVIDERS");
- objects.push(body.slice(i + 1, close));
- i = close + 1;
- } else {
- i++;
- }
- }
-
- return objects.map((inner) => {
- const keyMatch = inner.match(/\bkey\s*:\s*"([^"]+)"/);
- const dnMatch = inner.match(/\bdisplay_name\s*:\s*"([^"]+)"/);
- const dcKwMatch = inner.match(/\bdefault_command\s*:\s*\[/);
- if (!keyMatch || !dnMatch || !dcKwMatch) {
- throw new Error(
- "Failed to parse key / display_name / default_command in TS provider entry",
- );
- }
- const dcOpen = dcKwMatch.index + dcKwMatch[0].length - 1;
- const dcClose = findMatchingDelimiter(inner, dcOpen, "[", "]");
- if (dcClose === -1)
- throw new Error("Unclosed default_command array in TS provider entry");
- const default_command = extractStringList(inner.slice(dcOpen + 1, dcClose));
- return { key: keyMatch[1], display_name: dnMatch[1], default_command };
- });
-}
-
-export function diffRegistries(pyRecs, tsRecs) {
- const pyByKey = new Map();
- for (const r of pyRecs) pyByKey.set(r.key, r);
- const tsByKey = new Map();
- for (const r of tsRecs) tsByKey.set(r.key, r);
-
- const issues = [];
-
- // Order-of-keys drift is worth flagging: the SDK iterates ACP_PROVIDERS in
- // insertion order for agent-name detection, and the onboarding tile list
- // surfaces providers in TS order. A reorder shouldn't break correctness,
- // but does mean the two files no longer mean exactly the same thing.
- const pyOrder = pyRecs.map((r) => r.key).join(",");
- const tsOrder = tsRecs.map((r) => r.key).join(",");
- if (pyOrder !== tsOrder) {
- issues.push({
- kind: "order-mismatch",
- py: pyRecs.map((r) => r.key),
- ts: tsRecs.map((r) => r.key),
- });
- }
-
- for (const r of pyRecs) {
- if (r.mapKey !== r.key) {
- issues.push({
- kind: "python-internal-mismatch",
- key: r.key,
- mapKey: r.mapKey,
- });
- }
- }
-
- for (const key of pyByKey.keys()) {
- if (!tsByKey.has(key)) {
- issues.push({ kind: "missing-in-ts", key, py: pyByKey.get(key) });
- }
- }
- for (const key of tsByKey.keys()) {
- if (!pyByKey.has(key)) {
- issues.push({ kind: "missing-in-py", key, ts: tsByKey.get(key) });
- }
- }
- for (const [key, py] of pyByKey) {
- const ts = tsByKey.get(key);
- if (!ts) continue;
- if (py.display_name !== ts.display_name) {
- issues.push({
- kind: "field-mismatch",
- key,
- field: "display_name",
- py: py.display_name,
- ts: ts.display_name,
- });
- }
- const pyCmd = JSON.stringify(py.default_command);
- const tsCmd = JSON.stringify(ts.default_command);
- if (pyCmd !== tsCmd) {
- issues.push({
- kind: "field-mismatch",
- key,
- field: "default_command",
- py: py.default_command,
- ts: ts.default_command,
- });
- }
- }
-
- return issues;
-}
-
-async function fetchSdkSource({ sdkFile, sdkRef, sdkRepo }) {
- if (sdkFile) {
- return {
- source: readFileSync(resolve(sdkFile), "utf8"),
- origin: `file:${sdkFile}`,
- };
- }
- const url = `https://raw.githubusercontent.com/${sdkRepo}/${sdkRef}/${DEFAULT_SDK_PATH}`;
- const res = await fetch(url);
- if (!res.ok) {
- throw new Error(
- `Failed to fetch ${url}: HTTP ${res.status} ${res.statusText}. ` +
- `Verify --sdk-ref names a branch or tag in ${sdkRepo}.`,
- );
- }
- return { source: await res.text(), origin: url };
-}
-
-function log(...parts) {
- process.stderr.write(parts.join(" ") + "\n");
-}
-
-function formatIssue(i) {
- if (i.kind === "missing-in-ts") {
- return (
- ` ${colors.red}+ ${i.key}${colors.reset} present in SDK, missing in TS mirror\n` +
- ` ${colors.dim}display_name: ${JSON.stringify(i.py.display_name)}${colors.reset}\n` +
- ` ${colors.dim}default_command: ${JSON.stringify(i.py.default_command)}${colors.reset}`
- );
- }
- if (i.kind === "missing-in-py") {
- return (
- ` ${colors.red}- ${i.key}${colors.reset} present in TS mirror, missing in SDK\n` +
- ` ${colors.dim}default_command: ${JSON.stringify(i.ts.default_command)}${colors.reset}`
- );
- }
- if (i.kind === "field-mismatch") {
- const pyStr =
- typeof i.py === "string" ? JSON.stringify(i.py) : JSON.stringify(i.py);
- const tsStr =
- typeof i.ts === "string" ? JSON.stringify(i.ts) : JSON.stringify(i.ts);
- return (
- ` ${colors.red}~ ${i.key}.${i.field}${colors.reset}\n` +
- ` SDK: ${colors.green}${pyStr}${colors.reset}\n` +
- ` TS: ${colors.yellow}${tsStr}${colors.reset}`
- );
- }
- if (i.kind === "order-mismatch") {
- return (
- ` ${colors.red}# provider order differs${colors.reset}\n` +
- ` SDK: ${colors.green}${i.py.join(", ")}${colors.reset}\n` +
- ` TS: ${colors.yellow}${i.ts.join(", ")}${colors.reset}`
- );
- }
- if (i.kind === "python-internal-mismatch") {
- return (
- ` ${colors.red}~ Python mapping key vs ACPProviderInfo.key disagree${colors.reset}\n` +
- ` mapping key: ${colors.yellow}${i.mapKey}${colors.reset}\n` +
- ` ACPProviderInfo.key: ${colors.green}${i.key}${colors.reset}\n` +
- ` (fix this in the SDK, not in canvas.)`
- );
- }
- return ` unknown issue ${JSON.stringify(i)}`;
-}
-
-async function main() {
- const args = parseArgs(process.argv.slice(2));
- if (args.help) {
- showHelp();
- return;
- }
-
- log("");
- log(`${colors.cyan}ACP Providers Sync Check${colors.reset}`);
- log("─".repeat(50));
- log("");
-
- const tsSource = readFileSync(args.tsFile, "utf8");
- const { source: pySource, origin: pyOrigin } = await fetchSdkSource(args);
-
- log(`SDK source: ${colors.dim}${pyOrigin}${colors.reset}`);
- log(`TS mirror: ${colors.dim}${args.tsFile}${colors.reset}`);
- log("");
-
- const pyRecs = parsePython(pySource);
- const tsRecs = parseTypeScript(tsSource);
-
- log(`Python providers: ${pyRecs.length}`);
- log(`TS providers: ${tsRecs.length}`);
- log("");
-
- const issues = diffRegistries(pyRecs, tsRecs);
-
- if (args.json) {
- process.stdout.write(
- JSON.stringify(
- {
- in_sync: issues.length === 0,
- sdk_origin: pyOrigin,
- ts_path: args.tsFile,
- python_providers: pyRecs,
- ts_providers: tsRecs,
- issues,
- },
- null,
- 2,
- ) + "\n",
- );
- }
-
- if (issues.length === 0) {
- log(
- `${colors.green}βœ“ Canvas ACP_PROVIDERS is in sync with the SDK on the mirrored fields.${colors.reset}`,
- );
- log("");
- return;
- }
-
- log(
- `${colors.red}βœ— Drift detected (${issues.length} issue${
- issues.length === 1 ? "" : "s"
- }):${colors.reset}`,
- );
- log("");
- for (const i of issues) log(formatIssue(i));
- log("");
- log(
- `Update ${colors.cyan}src/constants/acp-providers.ts${colors.reset} to match the SDK,`,
- );
- log(
- `or β€” if the SDK changed intentionally β€” bump ${colors.cyan}@openhands/typescript-client${colors.reset}`,
- );
- log(`and re-run this check before merging.`);
- log("");
- process.exit(1);
-}
-
-// Only run main() when invoked as the entry script β€” importing the module
-// (e.g. from tests) shouldn't hit the SDK or read the TS mirror.
-const invokedDirectly =
- process.argv[1] &&
- resolve(process.argv[1]) === fileURLToPath(import.meta.url);
-if (invokedDirectly) {
- main().catch((err) => {
- log(`${colors.red}Error: ${err.message}${colors.reset}`);
- process.exit(1);
- });
-}
diff --git a/src/constants/acp-providers.ts b/src/constants/acp-providers.ts
index e6766845f3..03f9267d6c 100644
--- a/src/constants/acp-providers.ts
+++ b/src/constants/acp-providers.ts
@@ -1,3 +1,4 @@
+import { getAcpProvider as getClientAcpProvider } from "@openhands/typescript-client";
import { I18nKey } from "#/i18n/declaration";
export type ACPProviderIcon =
@@ -67,21 +68,13 @@ export function resolveEffectiveAcpModel(inputs: {
}
/**
- * Built-in ACP (Agent Client Protocol) provider registry.
- *
- * **Source of truth:** ``openhands.sdk.settings.acp_providers.ACP_PROVIDERS``
- * in https://github.com/OpenHands/software-agent-sdk. This file is a
- * hand-kept TypeScript mirror β€” keep keys + commands in sync with the
- * Python source. The {@link OnboardingAgentId} and the
- * ``ACPAgentSettings.acp_server`` discriminator
- * (``"claude-code" | "codex" | "gemini-cli" | "custom"``) come from the
- * same Python module.
- *
- * Drift risk is tracked in agent-canvas#587. The richer SDK record
- * (api-key env var, session mode, set-session-model protocol, etc.)
- * is intentionally not mirrored here β€” canvas only renders this
- * registry in the Settings β†’ Agent and onboarding UIs, so it only
- * needs the fields below.
+ * Shape of a built-in ACP (Agent Client Protocol) provider as Canvas consumes
+ * it. The data fields (display name, launch command, model picker + default)
+ * are sourced at module load from ``@openhands/typescript-client``'s ACP
+ * registry β€” the generated mirror of the Python source of truth
+ * ``openhands.sdk.settings.acp_providers``. This config only adds the
+ * Canvas-specific UI fields ({@link ACPProviderConfig.icon} +
+ * {@link ACPProviderConfig.description_key}); see {@link ACP_PROVIDER_UI}.
*/
export interface ACPProviderConfig {
/** Stable registry key, also stored on conversations as ``tags.acpserver``. */
@@ -101,9 +94,9 @@ export interface ACPProviderConfig {
*/
default_command: string[];
/**
- * Canvas-local suggested ACP model IDs. These mirror the current runtime
- * picker values for the built-in harnesses, but are not authoritative access
- * checks; users can still enter a custom override in Settings -> Agent.
+ * Suggested ACP model IDs for the provider's picker, sourced from the
+ * typescript-client registry. Not authoritative access checks; users can
+ * still enter a custom override in Settings -> Agent.
*/
available_models?: ACPModelOption[];
/** Model ID preselected for built-in providers so Canvas never saves blank. */
@@ -130,123 +123,51 @@ export interface ACPModelOption {
label: string;
}
-// Canonical model IDs the Claude Code CLI binary's model registry recognises
-// (verified by string-scanning v2.1.146 of the bundled ``claude`` native
-// binary). ``[1m]`` is the SDK-documented 1M-context suffix; we use the
-// version-agnostic alias so the option auto-tracks the newest 1M-capable
-// model. ``opusplan`` routes planning to Opus and execution to Sonnet.
-// Availability for any of these ultimately depends on the user's Anthropic
-// plan tier β€” surfacing them here matches what the CLI *accepts*, not what
-// every account can actually invoke.
-const CLAUDE_MODELS: ACPModelOption[] = [
- { id: "claude-opus-4-7", label: "Claude Opus 4.7" },
- { id: "claude-opus-4-6", label: "Claude Opus 4.6" },
- // The 1M-context entries use the version-agnostic ``[1m]`` aliases, so the
- // label must stay version-less too β€” pinning a number here (e.g. "4.6")
- // would lie the moment the alias resolves to a newer model.
- { id: "opus[1m]", label: "Claude Opus (1M)" },
- { id: "claude-opus-4-5", label: "Claude Opus 4.5" },
- { id: "claude-opus-4-1-20250805", label: "Claude Opus 4.1" },
- { id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" },
- { id: "sonnet[1m]", label: "Claude Sonnet (1M)" },
- { id: "claude-sonnet-4-5", label: "Claude Sonnet 4.5" },
- { id: "claude-haiku-4-5", label: "Claude Haiku 4.5" },
- { id: "opusplan", label: "Opus (plan) + Sonnet (execute)" },
-];
-
-// Model IDs accepted by the ``@zed-industries/codex-acp`` wrapper, mirroring
-// the Codex CLI's own ``/model`` picker. Format is ``<base-model>/<effort>``
-// where the trailing tier (``low``/``medium``/``high``/``xhigh``) hints the
-// reasoning effort for that turn. Sourced from the Codex CLI's documented
-// runtime options as of 2026-05-22 β€” see ``acp_model`` registry tracker
-// in agent-canvas#740 for the long-term plan.
-const CODEX_MODELS: ACPModelOption[] = [
- { id: "gpt-5.5/low", label: "GPT-5.5 (low)" },
- { id: "gpt-5.5/medium", label: "GPT-5.5 (medium)" },
- { id: "gpt-5.5/high", label: "GPT-5.5 (high)" },
- { id: "gpt-5.5/xhigh", label: "GPT-5.5 (xhigh)" },
- { id: "gpt-5.4/low", label: "GPT-5.4 (low)" },
- { id: "gpt-5.4/medium", label: "GPT-5.4 (medium)" },
- { id: "gpt-5.4/high", label: "GPT-5.4 (high)" },
- { id: "gpt-5.4/xhigh", label: "GPT-5.4 (xhigh)" },
- { id: "gpt-5.4-mini/low", label: "GPT-5.4 Mini (low)" },
- { id: "gpt-5.4-mini/medium", label: "GPT-5.4 Mini (medium)" },
- { id: "gpt-5.4-mini/high", label: "GPT-5.4 Mini (high)" },
- { id: "gpt-5.4-mini/xhigh", label: "GPT-5.4 Mini (xhigh)" },
- { id: "gpt-5.3-codex/low", label: "GPT-5.3 Codex (low)" },
- { id: "gpt-5.3-codex/medium", label: "GPT-5.3 Codex (medium)" },
- { id: "gpt-5.3-codex/high", label: "GPT-5.3 Codex (high)" },
- { id: "gpt-5.3-codex/xhigh", label: "GPT-5.3 Codex (xhigh)" },
- { id: "gpt-5.2/low", label: "GPT-5.2 (low)" },
- { id: "gpt-5.2/medium", label: "GPT-5.2 (medium)" },
- { id: "gpt-5.2/high", label: "GPT-5.2 (high)" },
- { id: "gpt-5.2/xhigh", label: "GPT-5.2 (xhigh)" },
-];
-
-// Model IDs accepted by ``@google/gemini-cli --acp``. The ``auto-gemini-*``
-// entries delegate version selection to the CLI's router; the explicit
-// ``gemini-3.1-*`` / ``gemini-2.5-*`` entries pin to a specific snapshot.
-// Sourced from the Gemini CLI's documented model list as of 2026-05-22 β€”
-// see agent-canvas#740 for the long-term plan to move this registry
-// upstream.
-const GEMINI_MODELS: ACPModelOption[] = [
- { id: "auto-gemini-3", label: "Auto (Gemini 3)" },
- { id: "auto-gemini-2.5", label: "Auto (Gemini 2.5)" },
- { id: "gemini-3.1-pro-preview", label: "Gemini 3.1 Pro (preview)" },
- { id: "gemini-3-flash-preview", label: "Gemini 3 Flash (preview)" },
- {
- id: "gemini-3.1-flash-lite-preview",
- label: "Gemini 3.1 Flash Lite (preview)",
- },
- { id: "gemini-2.5-pro", label: "Gemini 2.5 Pro" },
- { id: "gemini-2.5-flash", label: "Gemini 2.5 Flash" },
- { id: "gemini-2.5-flash-lite", label: "Gemini 2.5 Flash Lite" },
-];
-
-// Each entry's ``default_command`` is the published-package npx
-// invocation that speaks the ACP JSON-RPC protocol on stdio. Verified
-// against the upstream npm registry on the date noted below β€” if a
-// package is renamed/unpublished, the agent-server spawn fails fast
-// with ``ENOENT`` and the user can switch to the "Custom" preset.
-export const ACP_PROVIDERS: ACPProviderConfig[] = [
- {
- key: "claude-code",
- display_name: "Claude Code",
- // https://www.npmjs.com/package/@agentclientprotocol/claude-agent-acp
- // Verified 2026-05-19. Official Anthropic-maintained ACP wrapper
- // around the Claude Code CLI.
- default_command: ["npx", "-y", "@agentclientprotocol/claude-agent-acp"],
- available_models: CLAUDE_MODELS,
- default_model: "claude-opus-4-7",
- description_key: I18nKey.ONBOARDING$AGENT_CLAUDE_CODE_DESCRIPTION,
+// Canvas-only UI metadata per built-in provider, keyed by the ACP registry
+// key. Everything else β€” display name, launch command, model picker list and
+// default β€” comes from the typescript-client registry below. Adding a model
+// or a provider happens upstream in the SDK; Canvas only owns the brand icon
+// and the onboarding-tile description here. A provider with no entry here is
+// intentionally not surfaced in the UI.
+const ACP_PROVIDER_UI: Record<
+ string,
+ { icon: ACPProviderIcon; description_key: I18nKey }
+> = {
+ "claude-code": {
icon: "claude-code",
+ description_key: I18nKey.ONBOARDING$AGENT_CLAUDE_CODE_DESCRIPTION,
},
- {
- key: "codex",
- display_name: "Codex",
- // https://www.npmjs.com/package/@zed-industries/codex-acp
- // Verified 2026-05-19. Zed-maintained ACP wrapper around the
- // OpenAI Codex CLI β€” NOT ``@openai/codex acp`` (no ``acp``
- // subcommand on that package).
- default_command: ["npx", "-y", "@zed-industries/codex-acp"],
- available_models: CODEX_MODELS,
- default_model: "gpt-5.5/medium",
- description_key: I18nKey.ONBOARDING$AGENT_CODEX_DESCRIPTION,
+ codex: {
icon: "codex",
+ description_key: I18nKey.ONBOARDING$AGENT_CODEX_DESCRIPTION,
},
- {
- key: "gemini-cli",
- display_name: "Gemini CLI",
- // https://www.npmjs.com/package/@google/gemini-cli
- // Verified 2026-05-19. Official Google CLI; ``--acp`` switches it
- // into ACP server mode on stdio.
- default_command: ["npx", "-y", "@google/gemini-cli", "--acp"],
- available_models: GEMINI_MODELS,
- default_model: "gemini-2.5-pro",
- description_key: I18nKey.ONBOARDING$AGENT_GEMINI_CLI_DESCRIPTION,
+ "gemini-cli": {
icon: "gemini",
+ description_key: I18nKey.ONBOARDING$AGENT_GEMINI_CLI_DESCRIPTION,
},
-];
+};
+
+// Built-in ACP providers Canvas surfaces, built by enriching each upstream
+// registry record (``@openhands/typescript-client`` β†’ Python SDK) with the
+// Canvas UI metadata above. Model lists + defaults are no longer hand-kept
+// here (closes agent-canvas#740) β€” they track the SDK via the pinned client.
+export const ACP_PROVIDERS: ACPProviderConfig[] = Object.entries(
+ ACP_PROVIDER_UI,
+).map(([key, ui]) => {
+ const info = getClientAcpProvider(key);
+ return {
+ key,
+ display_name: info?.display_name ?? key,
+ default_command: info ? [...info.default_command] : [],
+ available_models: info?.available_models?.map((model) => ({
+ id: model.id,
+ label: model.label,
+ })),
+ default_model: info?.default_model ?? undefined,
+ description_key: ui.description_key,
+ icon: ui.icon,
+ };
+});
export const ACP_CUSTOM_PRESET_KEY = "custom";