From c66ea1479075ad9cfe8c08ee2b3f83ad2282f07b Mon Sep 17 00:00:00 2001 From: Pal Lakatos-Toth Date: Wed, 1 Jul 2026 13:24:36 +0200 Subject: [PATCH] fix(cli): accept canonical `langgraph` --runtime flag (keep `lang-graph` alias) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CLI flag parser only accepted the hyphenated `lang-graph`, so `kars add x --runtime langgraph` failed with "Unknown --runtime value" — even though the `--runtime` help text, docs, controller (`plan_langgraph`), runtime images (`kars-runtime-langgraph`) and Helm values all use the unhyphenated `langgraph`. Make `langgraph` canonical in FLAG_TO_KIND and the operator picker; keep `lang-graph` working via a dedicated FLAG_ALIASES map that is not surfaced in pickers or the valid-values error text. Adds tests for both spellings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 14 ++++++++++++++ cli/src/commands/operator/dialogs/spawn.ts | 2 +- cli/src/runtime.test.ts | 22 +++++++++++++++++++++- cli/src/runtime.ts | 22 +++++++++++++++++++--- 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b389fe637..f7a57844c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] — `crd-well-oiled-machine` +### Fixed — `--runtime langgraph` accepted (canonical spelling) + +`kars add --runtime langgraph` previously failed with +`Unknown --runtime value: langgraph` because the CLI flag parser only +accepted the hyphenated `lang-graph`, even though the `--runtime` help +text, the docs (`cli-reference.md`, `runtimes.md`, `README.md`), the +controller (`plan_langgraph`), the runtime images +(`kars-runtime-langgraph`) and the Helm values all use the unhyphenated +`langgraph`. `langgraph` is now the canonical CLI flag; `lang-graph` +continues to work as a back-compat alias (accepted by `flagToKind`, +but not surfaced in pickers or the "Valid values" error text). Fixes +the `--runtime langgraph` example shown in the getting-started guide and +launch materials. (`cli/src/runtime.ts`, `cli/src/commands/operator/dialogs/spawn.ts`) + ### Upstream alignment — AGT mesh-identity hardening merged [microsoft/agent-governance-toolkit#2719](https://github.com/microsoft/agent-governance-toolkit/pull/2719) diff --git a/cli/src/commands/operator/dialogs/spawn.ts b/cli/src/commands/operator/dialogs/spawn.ts index 5e5a2185d..63b72024a 100644 --- a/cli/src/commands/operator/dialogs/spawn.ts +++ b/cli/src/commands/operator/dialogs/spawn.ts @@ -73,7 +73,7 @@ export function openSpawnDialog(ctx: SpawnDialogContext): void { "openclaw": "OpenClaw", "openai-agents": "OpenAI Agents", "microsoft-agent-framework": "Microsoft Agent Framework", - "lang-graph": "LangGraph", + "langgraph": "LangGraph", "anthropic": "Anthropic Claude SDK", "pydantic-ai": "Pydantic AI", "hermes": "Hermes", diff --git a/cli/src/runtime.test.ts b/cli/src/runtime.test.ts index a19260cd9..8f62da3f3 100644 --- a/cli/src/runtime.test.ts +++ b/cli/src/runtime.test.ts @@ -27,10 +27,30 @@ describe("flagToKind", () => { expect(flagToKind("OPENAI-AGENTS")).toBe("OpenAIAgents"); }); + it("resolves LangGraph via the canonical `langgraph` flag", () => { + expect(flagToKind("langgraph")).toBe("LangGraph"); + expect(flagToKind("LangGraph")).toBe("LangGraph"); + }); + + it("accepts the legacy hyphenated `lang-graph` as a back-compat alias", () => { + // `lang-graph` was the original flag spelling; `langgraph` is now + // canonical (matches images/controller/docs/help text). The alias + // must keep resolving so existing scripts don't break. + expect(flagToKind("lang-graph")).toBe("LangGraph"); + expect(flagToKind("LANG-GRAPH")).toBe("LangGraph"); + }); + it("throws with a helpful error on unknown flags", () => { expect(() => flagToKind("autogen")).toThrow(/Unknown --runtime value: autogen/); expect(() => flagToKind("")).toThrow(/Unknown --runtime value/); }); + + it("does not advertise the `lang-graph` alias in the canonical valid-values list", () => { + // The alias is accepted but must stay out of the error text and + // pickers — only the canonical `langgraph` should surface. + expect(() => flagToKind("autogen")).toThrow(/langgraph/); + expect(() => flagToKind("autogen")).not.toThrow(/lang-graph/); + }); }); describe("assertRuntimeWired", () => { @@ -213,7 +233,7 @@ describe("wiredRuntimeFlags", () => { "openclaw", "openai-agents", "microsoft-agent-framework", - "lang-graph", + "langgraph", "anthropic", "pydantic-ai", "hermes", diff --git a/cli/src/runtime.ts b/cli/src/runtime.ts index 9d91a633d..1beff6d88 100644 --- a/cli/src/runtime.ts +++ b/cli/src/runtime.ts @@ -33,7 +33,7 @@ export type RuntimeFlag = | "openai-agents" | "microsoft-agent-framework" | "semantic-kernel" - | "lang-graph" + | "langgraph" | "anthropic" | "pydantic-ai" | "hermes" @@ -44,7 +44,7 @@ const FLAG_TO_KIND: Record = { "openai-agents": "OpenAIAgents", "microsoft-agent-framework": "MicrosoftAgentFramework", "semantic-kernel": "SemanticKernel", - "lang-graph": "LangGraph", + "langgraph": "LangGraph", "anthropic": "Anthropic", "pydantic-ai": "PydanticAi", "hermes": "Hermes", @@ -96,8 +96,24 @@ export function wiredRuntimeFlags(): RuntimeFlag[] { }); } +/** + * Back-compat aliases accepted by `flagToKind` but intentionally NOT + * listed in `FLAG_TO_KIND`, so they never leak into pickers + * (`wiredRuntimeFlags`), the reverse `KIND_TO_FLAG` map, or the + * canonical "Valid values" error text. `lang-graph` was the original + * hyphenated flag; `langgraph` is now canonical and matches the + * runtime images, controller (`plan_langgraph`), Helm values, docs, + * and the `--runtime` help text. Old scripts using `lang-graph` keep + * working. + */ +const FLAG_ALIASES: Record = { + "lang-graph": "langgraph", +}; + export function flagToKind(flag: string): RuntimeKind { - const k = FLAG_TO_KIND[flag.toLowerCase() as RuntimeFlag]; + const normalized = flag.toLowerCase(); + const canonical = (FLAG_ALIASES[normalized] ?? normalized) as RuntimeFlag; + const k = FLAG_TO_KIND[canonical]; if (!k) { throw new Error( `Unknown --runtime value: ${flag}. ` +