@devries-cameron20 / t3code Mirror · read-only / commits / 1e6a251871
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 18:30 UTC

fix(acp): preserve OMP single-choice questions and custom answers (#24012)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Yukun Shan committed Nov 13, 2026 at 07:15 UTC 1e6a2518717fd707a482c85c8842d1ca6e59e975
3 files changed +127 -4
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+53 -1
@@ -102,6 +102,11 @@ import {
102
103 const DEFAULT_GROK_SETTINGS = Schema.decodeSync(GrokSettings)({});
104 const DROID_SETTINGS = Schema.decodeSync(AcpRegistrySettings)({ agentId: "factory-droid" });
105 +const OMP_SETTINGS = Schema.decodeSync(AcpRegistrySettings)({
106 + source: "local",
107 + commandPath: "/usr/local/bin/omp",
108 + commandArgs: ["acp"],
109 +});
110 const OPENCODE_SETTINGS = Schema.decodeSync(AcpRegistrySettings)({
111 source: "local",
112 commandPath: "/usr/local/bin/opencode",
@@ -1698,8 +1703,55 @@ describe("AcpAdapterV2", () => {
1703 },
1704 ];
1705
1701 - // regression: #20417 Droid AskUser answers were sent as a cancel
1706 + // regression: #20417 Droid answers were sent as a cancel; #23505 OMP header and question were swapped
1707 it.live.each([
1708 + ...[
1709 + { scenario: "OMP selected option", answers: { q0: "Approve" }, content: { q0: "Approve" } },
1710 + {
1711 + scenario: "OMP custom answer",
1712 + answers: { q0: "Please wait" },
1713 + content: { q0__other: "Please wait" },
1714 + },
1715 + ].map((fixture) => ({
1716 + ...fixture,
1717 + settings: OMP_SETTINGS,
1718 + schema: {
1719 + type: "object",
1720 + properties: {
1721 + q0: {
1722 + type: "string",
1723 + title: "Approve this exact code-only commit?",
1724 + description: "Safety-hook false positive",
1725 + oneOf: [
1726 + { const: "Approve", title: "Approve", description: "Commit the verified fix." },
1727 + { const: "Hold", title: "Hold" },
1728 + ],
1729 + default: "Approve",
1730 + },
1731 + q0__other: { type: "string", title: "Other (type your own)" },
1732 + },
1733 + },
1734 + questions: [
1735 + {
1736 + id: "q0",
1737 + header: "Safety-hook false positive",
1738 + question: "Approve this exact code-only commit?",
1739 + options: [
1740 + { label: "Approve", value: "Approve", description: "Commit the verified fix." },
1741 + { label: "Hold", value: "Hold", description: "Hold" },
1742 + ],
1743 + },
1744 + ],
1745 + result: { action: "accept", content: fixture.content },
1746 + })),
1747 + {
1748 + scenario: "OMP unrelated form uses generic mapping",
1749 + settings: OMP_SETTINGS,
1750 + schema: { type: "object", properties: { name: { type: "string" } } },
1751 + questions: [{ id: "name", header: "Question 1", question: "Your answer?", options: [] }],
1752 + answers: { name: "Ada" },
1753 + result: { action: "accept", content: { name: "Ada" } },
1754 + },
1755 {
1756 scenario: "preserves selected IDs and encodes custom answers",
1757 schema: droidSchema,
packages/provider-acp-registry/src/server/adapter.ts
+9 -3
@@ -9,6 +9,7 @@ import {
9 extractDevinSubagentUpdate,
10 } from "./devinAcp.ts";
11 import { extractDroidElicitationForm } from "./droidAcp.ts";
12 +import { extractOmpElicitationForm } from "./ompAcp.ts";
13 import { extractOpenCodeElicitationForm } from "./opencodeAcp.ts";
14 import {
15 copilotClientCapabilitiesMeta,
@@ -188,6 +189,9 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
189 const startupKey =
190 options.settings.source === "local" ? `local:${options.instanceId}` : registryAgentId;
191 const isDevin = registryAgentId === "devin";
192 + const isOmp =
193 + options.settings.source === "local" &&
194 + /^omp(\.exe|\.cmd)?$/i.test(options.settings.commandPath.split(/[\\/]/).pop() ?? "");
195 const isOpenCode =
196 registryAgentId === "opencode" ||
197 registryAgentId === "opencode-v2" ||
@@ -231,9 +235,11 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
235 promptFailure: (cause) => acpRegistryPromptFailure(registryAgentId, cause),
236 ...(registryAgentId === "factory-droid"
237 ? { extractElicitationForm: extractDroidElicitationForm }
234 - : isOpenCode
235 - ? { extractElicitationForm: extractOpenCodeElicitationForm }
236 - : {}),
238 + : isOmp
239 + ? { extractElicitationForm: extractOmpElicitationForm }
240 + : isOpenCode
241 + ? { extractElicitationForm: extractOpenCodeElicitationForm }
242 + : {}),
243 // glm-acp-agent is the one agent whose per-turn usage a live probe has verified.
244 ...(registryAgentId === "glm-acp-agent" ? { reportsPerTurnPromptUsage: true } : {}),
245 ...(registryAgentId === "mistral-vibe"
packages/provider-acp-registry/src/server/ompAcp.ts new
+65
@@ -0,0 +1,65 @@
1 +import { type OrchestrationV2UserInputQuestion, TrimmedNonEmptyString } from "@t3tools/contracts";
2 +import type { AcpAdapterV2Flavor } from "@t3tools/provider-acp/server/adapter";
3 +import * as Schema from "effect/Schema";
4 +
5 +const isForm = Schema.is(
6 + Schema.Struct({ properties: Schema.Record(Schema.String, Schema.Unknown) }),
7 +);
8 +const choice = Schema.Struct({
9 + const: TrimmedNonEmptyString,
10 + title: TrimmedNonEmptyString,
11 + description: Schema.optional(Schema.String),
12 +});
13 +const isQuestion = Schema.is(
14 + Schema.Struct({
15 + title: TrimmedNonEmptyString,
16 + description: Schema.optional(Schema.String),
17 + type: Schema.Literal("string"),
18 + oneOf: Schema.Array(choice),
19 + }),
20 +);
21 +const isCompanion = Schema.is(
22 + Schema.Struct({ type: Schema.Literal("string"), title: Schema.Literal("Other (type your own)") }),
23 +);
24 +
25 +/** OMP askDialog pairs qN choices with qN__other and puts the question in title. */
26 +export const extractOmpElicitationForm: NonNullable<
27 + AcpAdapterV2Flavor["extractElicitationForm"]
28 +> = (request) => {
29 + if (request.mode !== "form" || !isForm(request.requestedSchema)) return undefined;
30 + const { properties } = request.requestedSchema;
31 + const questions: OrchestrationV2UserInputQuestion[] = [];
32 + for (const [id, field] of Object.entries(properties)) {
33 + if (!/^q\d+$/.test(id)) continue;
34 + if (!isQuestion(field) || !isCompanion(properties[`${id}__other`])) return undefined;
35 + const choices = field.oneOf;
36 + if (choices.length === 0) return undefined;
37 + questions.push({
38 + id,
39 + header: field.description?.trim() || `Question ${questions.length + 1}`,
40 + question: field.title,
41 + options: choices.map((option) => ({
42 + label: option.title,
43 + value: option.const,
44 + description: option.description?.trim() || option.title,
45 + })),
46 + });
47 + }
48 + // Do not hide unknown fields or partially reinterpret a different form.
49 + if (questions.length === 0 || Object.keys(properties).length !== questions.length * 2)
50 + return undefined;
51 + return {
52 + questions,
53 + respond: (answers) => {
54 + const content: Record<string, string> = {};
55 + for (const question of questions) {
56 + const answer = Object.hasOwn(answers, question.id) ? answers[question.id] : undefined;
57 + if (typeof answer !== "string" || !answer.trim()) return { action: "cancel" };
58 + if (question.options.some((option) => option.value === answer))
59 + content[question.id] = answer;
60 + else content[`${question.id}__other`] = answer;
61 + }
62 + return { action: "accept", content };
63 + },
64 + };
65 +};