diff --git a/CHANGELOG.md b/CHANGELOG.md index d330d2f2675..60f3ca8bbfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Docs: https://docs.openclaw.ai - Gateway: add SecretRef support for gateway.auth.token with auth-mode guardrails. (#35094) Thanks @joshavant. - Plugins/hook policy: add `plugins.entries..hooks.allowPromptInjection`, validate unknown typed hook names at runtime, and preserve legacy `before_agent_start` model/provider overrides while stripping prompt-mutating fields when prompt injection is disabled. (#36567) thanks @gumadeiras. - Tools/Diffs guidance: restore a short system-prompt hint for enabled diffs while keeping the detailed instructions in the companion skill, so diffs usage guidance stays out of user-prompt space. (#36904) thanks @gumadeiras. +- Telegram/ACP topic bindings: accept Telegram Mac Unicode dash option prefixes in `/acp spawn`, support Telegram topic thread binding (`--thread here|auto`), route bound-topic follow-ups to ACP sessions, add actionable Telegram approval buttons with prefixed approval-id resolution, and pin successful bind confirmations in-topic. (#36683) Thanks @huntharo. ### Breaking diff --git a/docs/channels/telegram.md b/docs/channels/telegram.md index 58fbe8b9023..817ae1d51d4 100644 --- a/docs/channels/telegram.md +++ b/docs/channels/telegram.md @@ -524,6 +524,13 @@ curl "https://api.telegram.org/bot/getUpdates" This is currently scoped to forum topics in groups and supergroups. + **Thread-bound ACP spawn from chat**: + + - `/acp spawn --thread here|auto` can bind the current Telegram topic to a new ACP session. + - Follow-up topic messages route to the bound ACP session directly (no `/acp steer` required). + - OpenClaw pins the spawn confirmation message in-topic after a successful bind. + - Requires `channels.telegram.threadBindings.spawnAcpSessions=true`. + Template context includes: - `MessageThreadId` diff --git a/docs/tools/acp-agents.md b/docs/tools/acp-agents.md index 2003758cc1d..aa51e986552 100644 --- a/docs/tools/acp-agents.md +++ b/docs/tools/acp-agents.md @@ -79,11 +79,14 @@ Required feature flags for thread-bound ACP: - `acp.dispatch.enabled` is on by default (set `false` to pause ACP dispatch) - Channel-adapter ACP thread-spawn flag enabled (adapter-specific) - Discord: `channels.discord.threadBindings.spawnAcpSessions=true` + - Telegram: `channels.telegram.threadBindings.spawnAcpSessions=true` ### Thread supporting channels - Any channel adapter that exposes session/thread binding capability. -- Current built-in support: Discord. +- Current built-in support: + - Discord threads/channels + - Telegram topics (forum topics in groups/supergroups and DM topics) - Plugin channels can add support through the same binding interface. ## Channel specific settings @@ -303,7 +306,9 @@ If no target resolves, OpenClaw returns a clear error (`Unable to resolve sessio Notes: - On non-thread binding surfaces, default behavior is effectively `off`. -- Thread-bound spawn requires channel policy support (for Discord: `channels.discord.threadBindings.spawnAcpSessions=true`). +- Thread-bound spawn requires channel policy support: + - Discord: `channels.discord.threadBindings.spawnAcpSessions=true` + - Telegram: `channels.telegram.threadBindings.spawnAcpSessions=true` ## ACP controls diff --git a/extensions/acpx/src/runtime-internals/test-fixtures.ts b/extensions/acpx/src/runtime-internals/test-fixtures.ts index f5d79122546..5d333f709dd 100644 --- a/extensions/acpx/src/runtime-internals/test-fixtures.ts +++ b/extensions/acpx/src/runtime-internals/test-fixtures.ts @@ -223,6 +223,10 @@ if (command === "prompt") { process.exit(1); } + if (stdinText.includes("permission-denied")) { + process.exit(5); + } + if (stdinText.includes("split-spacing")) { emitUpdate(sessionFromOption, { sessionUpdate: "agent_message_chunk", diff --git a/extensions/acpx/src/runtime.test.ts b/extensions/acpx/src/runtime.test.ts index 5e4baf7f3cb..4fe92fc9090 100644 --- a/extensions/acpx/src/runtime.test.ts +++ b/extensions/acpx/src/runtime.test.ts @@ -224,6 +224,42 @@ describe("AcpxRuntime", () => { }); }); + it("maps acpx permission-denied exits to actionable guidance", async () => { + const runtime = sharedFixture?.runtime; + expect(runtime).toBeDefined(); + if (!runtime) { + throw new Error("shared runtime fixture missing"); + } + const handle = await runtime.ensureSession({ + sessionKey: "agent:codex:acp:permission-denied", + agent: "codex", + mode: "persistent", + }); + + const events = []; + for await (const event of runtime.runTurn({ + handle, + text: "permission-denied", + mode: "prompt", + requestId: "req-perm", + })) { + events.push(event); + } + + expect(events).toContainEqual( + expect.objectContaining({ + type: "error", + message: expect.stringContaining("Permission denied by ACP runtime (acpx)."), + }), + ); + expect(events).toContainEqual( + expect.objectContaining({ + type: "error", + message: expect.stringContaining("approve-reads, approve-all, deny-all"), + }), + ); + }); + it("supports cancel and close using encoded runtime handle state", async () => { const { runtime, logPath, config } = await createMockRuntimeFixture(); const handle = await runtime.ensureSession({ diff --git a/extensions/acpx/src/runtime.ts b/extensions/acpx/src/runtime.ts index 8a7783a704c..5fe3c36c70d 100644 --- a/extensions/acpx/src/runtime.ts +++ b/extensions/acpx/src/runtime.ts @@ -42,10 +42,30 @@ export const ACPX_BACKEND_ID = "acpx"; const ACPX_RUNTIME_HANDLE_PREFIX = "acpx:v1:"; const DEFAULT_AGENT_FALLBACK = "codex"; +const ACPX_EXIT_CODE_PERMISSION_DENIED = 5; const ACPX_CAPABILITIES: AcpRuntimeCapabilities = { controls: ["session/set_mode", "session/set_config_option", "session/status"], }; +function formatPermissionModeGuidance(): string { + return "Configure plugins.entries.acpx.config.permissionMode to one of: approve-reads, approve-all, deny-all."; +} + +function formatAcpxExitMessage(params: { + stderr: string; + exitCode: number | null | undefined; +}): string { + const stderr = params.stderr.trim(); + if (params.exitCode === ACPX_EXIT_CODE_PERMISSION_DENIED) { + return [ + stderr || "Permission denied by ACP runtime (acpx).", + "ACPX blocked a write/exec permission request in a non-interactive session.", + formatPermissionModeGuidance(), + ].join(" "); + } + return stderr || `acpx exited with code ${params.exitCode ?? "unknown"}`; +} + export function encodeAcpxRuntimeHandleState(state: AcpxHandleState): string { const payload = Buffer.from(JSON.stringify(state), "utf8").toString("base64url"); return `${ACPX_RUNTIME_HANDLE_PREFIX}${payload}`; @@ -333,7 +353,10 @@ export class AcpxRuntime implements AcpRuntime { if ((exit.code ?? 0) !== 0 && !sawError) { yield { type: "error", - message: stderr.trim() || `acpx exited with code ${exit.code ?? "unknown"}`, + message: formatAcpxExitMessage({ + stderr, + exitCode: exit.code, + }), }; return; } @@ -639,7 +662,10 @@ export class AcpxRuntime implements AcpRuntime { if ((result.code ?? 0) !== 0) { throw new AcpRuntimeError( params.fallbackCode, - result.stderr.trim() || `acpx exited with code ${result.code ?? "unknown"}`, + formatAcpxExitMessage({ + stderr: result.stderr, + exitCode: result.code, + }), ); } return events; diff --git a/src/auto-reply/commands-registry.data.ts b/src/auto-reply/commands-registry.data.ts index 19c1a7d3746..6a2bf205ffd 100644 --- a/src/auto-reply/commands-registry.data.ts +++ b/src/auto-reply/commands-registry.data.ts @@ -354,7 +354,8 @@ function buildChatCommands(): ChatCommandDefinition[] { defineChatCommand({ key: "focus", nativeName: "focus", - description: "Bind this Discord thread (or a new one) to a session target.", + description: + "Bind this thread (Discord) or topic/conversation (Telegram) to a session target.", textAlias: "/focus", category: "management", args: [ @@ -369,7 +370,7 @@ function buildChatCommands(): ChatCommandDefinition[] { defineChatCommand({ key: "unfocus", nativeName: "unfocus", - description: "Remove the current Discord thread binding.", + description: "Remove the current thread (Discord) or topic/conversation (Telegram) binding.", textAlias: "/unfocus", category: "management", }), diff --git a/src/auto-reply/reply/discord-context.ts b/src/auto-reply/reply/channel-context.ts similarity index 59% rename from src/auto-reply/reply/discord-context.ts rename to src/auto-reply/reply/channel-context.ts index 2eb810d5e1d..d8ffb261eb8 100644 --- a/src/auto-reply/reply/discord-context.ts +++ b/src/auto-reply/reply/channel-context.ts @@ -17,19 +17,29 @@ type DiscordAccountParams = { }; export function isDiscordSurface(params: DiscordSurfaceParams): boolean { + return resolveCommandSurfaceChannel(params) === "discord"; +} + +export function isTelegramSurface(params: DiscordSurfaceParams): boolean { + return resolveCommandSurfaceChannel(params) === "telegram"; +} + +export function resolveCommandSurfaceChannel(params: DiscordSurfaceParams): string { const channel = params.ctx.OriginatingChannel ?? params.command.channel ?? params.ctx.Surface ?? params.ctx.Provider; - return ( - String(channel ?? "") - .trim() - .toLowerCase() === "discord" - ); + return String(channel ?? "") + .trim() + .toLowerCase(); } export function resolveDiscordAccountId(params: DiscordAccountParams): string { + return resolveChannelAccountId(params); +} + +export function resolveChannelAccountId(params: DiscordAccountParams): string { const accountId = typeof params.ctx.AccountId === "string" ? params.ctx.AccountId.trim() : ""; return accountId || "default"; } diff --git a/src/auto-reply/reply/commands-acp.test.ts b/src/auto-reply/reply/commands-acp.test.ts index 444aec7f84c..5850e003b5a 100644 --- a/src/auto-reply/reply/commands-acp.test.ts +++ b/src/auto-reply/reply/commands-acp.test.ts @@ -118,7 +118,7 @@ type FakeBinding = { targetSessionKey: string; targetKind: "subagent" | "session"; conversation: { - channel: "discord"; + channel: "discord" | "telegram"; accountId: string; conversationId: string; parentConversationId?: string; @@ -242,7 +242,11 @@ function createSessionBindingCapabilities() { type AcpBindInput = { targetSessionKey: string; - conversation: { accountId: string; conversationId: string }; + conversation: { + channel?: "discord" | "telegram"; + accountId: string; + conversationId: string; + }; placement: "current" | "child"; metadata?: Record; }; @@ -251,14 +255,22 @@ function createAcpThreadBinding(input: AcpBindInput): FakeBinding { const nextConversationId = input.placement === "child" ? "thread-created" : input.conversation.conversationId; const boundBy = typeof input.metadata?.boundBy === "string" ? input.metadata.boundBy : "user-1"; + const channel = input.conversation.channel ?? "discord"; return createSessionBinding({ targetSessionKey: input.targetSessionKey, - conversation: { - channel: "discord", - accountId: input.conversation.accountId, - conversationId: nextConversationId, - parentConversationId: "parent-1", - }, + conversation: + channel === "discord" + ? { + channel: "discord", + accountId: input.conversation.accountId, + conversationId: nextConversationId, + parentConversationId: "parent-1", + } + : { + channel: "telegram", + accountId: input.conversation.accountId, + conversationId: nextConversationId, + }, metadata: { boundBy, webhookId: "wh-1" }, }); } @@ -297,6 +309,31 @@ function createThreadParams(commandBody: string, cfg: OpenClawConfig = baseCfg) return params; } +function createTelegramTopicParams(commandBody: string, cfg: OpenClawConfig = baseCfg) { + const params = buildCommandTestParams(commandBody, cfg, { + Provider: "telegram", + Surface: "telegram", + OriginatingChannel: "telegram", + OriginatingTo: "telegram:-1003841603622", + AccountId: "default", + MessageThreadId: "498", + }); + params.command.senderId = "user-1"; + return params; +} + +function createTelegramDmParams(commandBody: string, cfg: OpenClawConfig = baseCfg) { + const params = buildCommandTestParams(commandBody, cfg, { + Provider: "telegram", + Surface: "telegram", + OriginatingChannel: "telegram", + OriginatingTo: "telegram:123456789", + AccountId: "default", + }); + params.command.senderId = "user-1"; + return params; +} + async function runDiscordAcpCommand(commandBody: string, cfg: OpenClawConfig = baseCfg) { return handleAcpCommand(createDiscordParams(commandBody, cfg), true); } @@ -305,6 +342,14 @@ async function runThreadAcpCommand(commandBody: string, cfg: OpenClawConfig = ba return handleAcpCommand(createThreadParams(commandBody, cfg), true); } +async function runTelegramAcpCommand(commandBody: string, cfg: OpenClawConfig = baseCfg) { + return handleAcpCommand(createTelegramTopicParams(commandBody, cfg), true); +} + +async function runTelegramDmAcpCommand(commandBody: string, cfg: OpenClawConfig = baseCfg) { + return handleAcpCommand(createTelegramDmParams(commandBody, cfg), true); +} + describe("/acp command", () => { beforeEach(() => { acpManagerTesting.resetAcpSessionManagerForTests(); @@ -448,10 +493,70 @@ describe("/acp command", () => { expect(seededWithoutEntry?.runtimeSessionName).toContain(":runtime"); }); + it("accepts unicode dash option prefixes in /acp spawn args", async () => { + const result = await runThreadAcpCommand( + "/acp spawn codex \u2014mode oneshot \u2014thread here \u2014cwd /home/bob/clawd \u2014label jeerreview", + ); + + expect(result?.reply?.text).toContain("Spawned ACP session agent:codex:acp:"); + expect(result?.reply?.text).toContain("Bound this thread to"); + expect(hoisted.ensureSessionMock).toHaveBeenCalledWith( + expect.objectContaining({ + agent: "codex", + mode: "oneshot", + cwd: "/home/bob/clawd", + }), + ); + expect(hoisted.sessionBindingBindMock).toHaveBeenCalledWith( + expect.objectContaining({ + placement: "current", + metadata: expect.objectContaining({ + label: "jeerreview", + }), + }), + ); + }); + + it("binds Telegram topic ACP spawns to full conversation ids", async () => { + const result = await runTelegramAcpCommand("/acp spawn codex --thread here"); + + expect(result?.reply?.text).toContain("Spawned ACP session agent:codex:acp:"); + expect(result?.reply?.text).toContain("Bound this conversation to"); + expect(result?.reply?.channelData).toEqual({ telegram: { pin: true } }); + expect(hoisted.sessionBindingBindMock).toHaveBeenCalledWith( + expect.objectContaining({ + placement: "current", + conversation: expect.objectContaining({ + channel: "telegram", + accountId: "default", + conversationId: "-1003841603622:topic:498", + }), + }), + ); + }); + + it("binds Telegram DM ACP spawns to the DM conversation id", async () => { + const result = await runTelegramDmAcpCommand("/acp spawn codex --thread here"); + + expect(result?.reply?.text).toContain("Spawned ACP session agent:codex:acp:"); + expect(result?.reply?.text).toContain("Bound this conversation to"); + expect(result?.reply?.channelData).toBeUndefined(); + expect(hoisted.sessionBindingBindMock).toHaveBeenCalledWith( + expect.objectContaining({ + placement: "current", + conversation: expect.objectContaining({ + channel: "telegram", + accountId: "default", + conversationId: "123456789", + }), + }), + ); + }); + it("requires explicit ACP target when acp.defaultAgent is not configured", async () => { const result = await runDiscordAcpCommand("/acp spawn"); - expect(result?.reply?.text).toContain("ACP target agent is required"); + expect(result?.reply?.text).toContain("ACP target harness id is required"); expect(hoisted.ensureSessionMock).not.toHaveBeenCalled(); }); @@ -528,6 +633,42 @@ describe("/acp command", () => { expect(result?.reply?.text).toContain("Applied steering."); }); + it("resolves bound Telegram topic ACP sessions for /acp steer without explicit target", async () => { + hoisted.sessionBindingResolveByConversationMock.mockImplementation( + (ref: { channel?: string; accountId?: string; conversationId?: string }) => + ref.channel === "telegram" && + ref.accountId === "default" && + ref.conversationId === "-1003841603622:topic:498" + ? createSessionBinding({ + targetSessionKey: defaultAcpSessionKey, + conversation: { + channel: "telegram", + accountId: "default", + conversationId: "-1003841603622:topic:498", + }, + }) + : null, + ); + hoisted.readAcpSessionEntryMock.mockReturnValue(createAcpSessionEntry()); + hoisted.runTurnMock.mockImplementation(async function* () { + yield { type: "text_delta", text: "Viewed diver package." }; + yield { type: "done" }; + }); + + const result = await runTelegramAcpCommand("/acp steer use npm to view package diver"); + + expect(hoisted.runTurnMock).toHaveBeenCalledWith( + expect.objectContaining({ + handle: expect.objectContaining({ + sessionKey: defaultAcpSessionKey, + }), + mode: "steer", + text: "use npm to view package diver", + }), + ); + expect(result?.reply?.text).toContain("Viewed diver package."); + }); + it("blocks /acp steer when ACP dispatch is disabled by policy", async () => { const cfg = { ...baseCfg, diff --git a/src/auto-reply/reply/commands-acp/context.test.ts b/src/auto-reply/reply/commands-acp/context.test.ts index 9ba70225de6..18136b67b03 100644 --- a/src/auto-reply/reply/commands-acp/context.test.ts +++ b/src/auto-reply/reply/commands-acp/context.test.ts @@ -108,4 +108,22 @@ describe("commands-acp context", () => { }); expect(resolveAcpCommandConversationId(params)).toBe("-1001234567890:topic:42"); }); + + it("resolves Telegram DM conversation ids from telegram targets", () => { + const params = buildCommandTestParams("/acp status", baseCfg, { + Provider: "telegram", + Surface: "telegram", + OriginatingChannel: "telegram", + OriginatingTo: "telegram:123456789", + }); + + expect(resolveAcpCommandBindingContext(params)).toEqual({ + channel: "telegram", + accountId: "default", + threadId: undefined, + conversationId: "123456789", + parentConversationId: "123456789", + }); + expect(resolveAcpCommandConversationId(params)).toBe("123456789"); + }); }); diff --git a/src/auto-reply/reply/commands-acp/context.ts b/src/auto-reply/reply/commands-acp/context.ts index 78e2e7a32a9..16291713fda 100644 --- a/src/auto-reply/reply/commands-acp/context.ts +++ b/src/auto-reply/reply/commands-acp/context.ts @@ -6,6 +6,7 @@ import { DISCORD_THREAD_BINDING_CHANNEL } from "../../../channels/thread-binding import { resolveConversationIdFromTargets } from "../../../infra/outbound/conversation-id.js"; import { parseAgentSessionKey } from "../../../routing/session-key.js"; import type { HandleCommandsParams } from "../commands-types.js"; +import { resolveTelegramConversationId } from "../telegram-context.js"; function normalizeString(value: unknown): string { if (typeof value === "string") { @@ -40,19 +41,28 @@ export function resolveAcpCommandThreadId(params: HandleCommandsParams): string export function resolveAcpCommandConversationId(params: HandleCommandsParams): string | undefined { const channel = resolveAcpCommandChannel(params); if (channel === "telegram") { + const telegramConversationId = resolveTelegramConversationId({ + ctx: { + MessageThreadId: params.ctx.MessageThreadId, + OriginatingTo: params.ctx.OriginatingTo, + To: params.ctx.To, + }, + command: { + to: params.command.to, + }, + }); + if (telegramConversationId) { + return telegramConversationId; + } const threadId = resolveAcpCommandThreadId(params); const parentConversationId = resolveAcpCommandParentConversationId(params); if (threadId && parentConversationId) { - const canonical = buildTelegramTopicConversationId({ - chatId: parentConversationId, - topicId: threadId, - }); - if (canonical) { - return canonical; - } - } - if (threadId) { - return threadId; + return ( + buildTelegramTopicConversationId({ + chatId: parentConversationId, + topicId: threadId, + }) ?? threadId + ); } } return resolveConversationIdFromTargets({ diff --git a/src/auto-reply/reply/commands-acp/lifecycle.ts b/src/auto-reply/reply/commands-acp/lifecycle.ts index 3362cd237b0..feab0b60e24 100644 --- a/src/auto-reply/reply/commands-acp/lifecycle.ts +++ b/src/auto-reply/reply/commands-acp/lifecycle.ts @@ -37,7 +37,7 @@ import type { CommandHandlerResult, HandleCommandsParams } from "../commands-typ import { resolveAcpCommandAccountId, resolveAcpCommandBindingContext, - resolveAcpCommandThreadId, + resolveAcpCommandConversationId, } from "./context.js"; import { ACP_STEER_OUTPUT_LIMIT, @@ -123,25 +123,27 @@ async function bindSpawnedAcpSessionToThread(params: { } const currentThreadId = bindingContext.threadId ?? ""; - - if (threadMode === "here" && !currentThreadId) { + const currentConversationId = bindingContext.conversationId?.trim() || ""; + const requiresThreadIdForHere = channel !== "telegram"; + if ( + threadMode === "here" && + ((requiresThreadIdForHere && !currentThreadId) || + (!requiresThreadIdForHere && !currentConversationId)) + ) { return { ok: false, error: `--thread here requires running /acp spawn inside an active ${channel} thread/conversation.`, }; } - const threadId = currentThreadId || undefined; - const placement = threadId ? "current" : "child"; + const placement = channel === "telegram" ? "current" : currentThreadId ? "current" : "child"; if (!capabilities.placements.includes(placement)) { return { ok: false, error: `Thread bindings do not support ${placement} placement for ${channel}.`, }; } - const channelId = placement === "child" ? bindingContext.conversationId : undefined; - - if (placement === "child" && !channelId) { + if (!currentConversationId) { return { ok: false, error: `Could not resolve a ${channel} conversation for ACP thread spawn.`, @@ -149,11 +151,11 @@ async function bindSpawnedAcpSessionToThread(params: { } const senderId = commandParams.command.senderId?.trim() || ""; - if (threadId) { + if (placement === "current") { const existingBinding = bindingService.resolveByConversation({ channel: spawnPolicy.channel, accountId: spawnPolicy.accountId, - conversationId: threadId, + conversationId: currentConversationId, }); const boundBy = typeof existingBinding?.metadata?.boundBy === "string" @@ -162,19 +164,13 @@ async function bindSpawnedAcpSessionToThread(params: { if (existingBinding && boundBy && boundBy !== "system" && senderId && senderId !== boundBy) { return { ok: false, - error: `Only ${boundBy} can rebind this thread.`, + error: `Only ${boundBy} can rebind this ${channel === "telegram" ? "conversation" : "thread"}.`, }; } } const label = params.label || params.agentId; - const conversationId = threadId || channelId; - if (!conversationId) { - return { - ok: false, - error: `Could not resolve a ${channel} conversation for ACP thread spawn.`, - }; - } + const conversationId = currentConversationId; try { const binding = await bindingService.bind({ @@ -344,12 +340,13 @@ export async function handleAcpSpawnAction( `✅ Spawned ACP session ${sessionKey} (${spawn.mode}, backend ${initializedBackend}).`, ]; if (binding) { - const currentThreadId = resolveAcpCommandThreadId(params) ?? ""; + const currentConversationId = resolveAcpCommandConversationId(params)?.trim() || ""; const boundConversationId = binding.conversation.conversationId.trim(); - if (currentThreadId && boundConversationId === currentThreadId) { - parts.push(`Bound this thread to ${sessionKey}.`); + const placementLabel = binding.conversation.channel === "telegram" ? "conversation" : "thread"; + if (currentConversationId && boundConversationId === currentConversationId) { + parts.push(`Bound this ${placementLabel} to ${sessionKey}.`); } else { - parts.push(`Created thread ${boundConversationId} and bound it to ${sessionKey}.`); + parts.push(`Created ${placementLabel} ${boundConversationId} and bound it to ${sessionKey}.`); } } else { parts.push("Session is unbound (use /focus to bind this thread/conversation)."); @@ -360,6 +357,19 @@ export async function handleAcpSpawnAction( parts.push(`ℹ️ ${dispatchNote}`); } + const shouldPinBindingNotice = + binding?.conversation.channel === "telegram" && + binding.conversation.conversationId.includes(":topic:"); + if (shouldPinBindingNotice) { + return { + shouldContinue: false, + reply: { + text: parts.join(" "), + channelData: { telegram: { pin: true } }, + }, + }; + } + return stopWithText(parts.join(" ")); } diff --git a/src/auto-reply/reply/commands-acp/shared.test.ts b/src/auto-reply/reply/commands-acp/shared.test.ts new file mode 100644 index 00000000000..39d55744092 --- /dev/null +++ b/src/auto-reply/reply/commands-acp/shared.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, it } from "vitest"; +import { parseSteerInput } from "./shared.js"; + +describe("parseSteerInput", () => { + it("preserves non-option instruction tokens while normalizing unicode-dash flags", () => { + const parsed = parseSteerInput([ + "\u2014session", + "agent:codex:acp:s1", + "\u2014briefly", + "summarize", + "this", + ]); + + expect(parsed).toEqual({ + ok: true, + value: { + sessionToken: "agent:codex:acp:s1", + instruction: "\u2014briefly summarize this", + }, + }); + }); +}); diff --git a/src/auto-reply/reply/commands-acp/shared.ts b/src/auto-reply/reply/commands-acp/shared.ts index dfc88c4b9ec..2fe4710ce76 100644 --- a/src/auto-reply/reply/commands-acp/shared.ts +++ b/src/auto-reply/reply/commands-acp/shared.ts @@ -11,7 +11,7 @@ export { resolveAcpInstallCommandHint, resolveConfiguredAcpBackendId } from "./i export const COMMAND = "/acp"; export const ACP_SPAWN_USAGE = - "Usage: /acp spawn [agentId] [--mode persistent|oneshot] [--thread auto|here|off] [--cwd ] [--label