From 762e7f7e8aa374849b64c9dd131082ee5063adb3 Mon Sep 17 00:00:00 2001 From: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Date: Sun, 21 Jun 2026 23:42:51 -0700 Subject: [PATCH] fix(cli): align run app --conversation mode list with runtime gate (#37733) --- .../commands/run/app/_strategies/streaming-structured.ts | 4 +--- cli/src/commands/run/app/guide.ts | 6 +++--- cli/src/commands/run/app/handlers.ts | 6 ++++++ cli/src/commands/run/app/index.ts | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cli/src/commands/run/app/_strategies/streaming-structured.ts b/cli/src/commands/run/app/_strategies/streaming-structured.ts index c6f02292528..b6fedae2c41 100644 --- a/cli/src/commands/run/app/_strategies/streaming-structured.ts +++ b/cli/src/commands/run/app/_strategies/streaming-structured.ts @@ -1,7 +1,7 @@ import type { RunContext, RunStrategy } from './index' import type { SseEvent } from '@/http/sse' import { buildRunBody } from '@/api/app-run' -import { chatConversationHint, newAppRunObject, RUN_MODES } from '@/commands/run/app/handlers' +import { CHAT_MODES, chatConversationHint, newAppRunObject } from '@/commands/run/app/handlers' import { renderHitlHint, renderHitlOutput } from '@/commands/run/app/hitl-render' import { collect, HitlPauseError } from '@/commands/run/app/sse-collector' import { formatted, stringifyOutput } from '@/framework/output' @@ -10,8 +10,6 @@ import { colorEnabled, colorScheme } from '@/sys/io/color' import { startSpinner } from '@/sys/io/spinner' import { extractThinkBlocks, stripThinkBlocks } from '@/sys/io/think-filter' -const CHAT_MODES: ReadonlySet = new Set([RUN_MODES.Chat, RUN_MODES.AgentChat, RUN_MODES.AdvancedChat]) - async function* captureTaskId( iter: AsyncIterable, onCapture: (id: string) => void, diff --git a/cli/src/commands/run/app/guide.ts b/cli/src/commands/run/app/guide.ts index 2c58e01edd9..66403c0cbf1 100644 --- a/cli/src/commands/run/app/guide.ts +++ b/cli/src/commands/run/app/guide.ts @@ -9,12 +9,12 @@ WORKFLOW difyctl run app --inputs '{"key":"value"}' -o json APP MODES - chat / advanced-chat Conversational. Accepts --conversation to - resume an existing thread. + chat / agent-chat / Conversational. Accept --conversation to + advanced-chat resume an existing thread. agent-chat adds + autonomous tool use. completion Single-turn. Ignores --conversation. workflow Multi-step graph. Pass all input variables as a JSON object via --inputs. - agent-chat Conversational with autonomous tool use. HITL PAUSE (exit code 0 — success-with-pending) When a workflow pauses for human input, stdout receives a JSON object diff --git a/cli/src/commands/run/app/handlers.ts b/cli/src/commands/run/app/handlers.ts index 3d3d75ec082..9536c4fe2a9 100644 --- a/cli/src/commands/run/app/handlers.ts +++ b/cli/src/commands/run/app/handlers.ts @@ -11,6 +11,12 @@ export const RUN_MODES = { export type RunMode = typeof RUN_MODES[keyof typeof RUN_MODES] +export const CHAT_MODES: ReadonlySet = new Set([ + RUN_MODES.Chat, + RUN_MODES.AgentChat, + RUN_MODES.AdvancedChat, +]) + export type AppRunObject = FormattedPrintable export function newAppRunObject(mode: string, resp: Record): AppRunObject { diff --git a/cli/src/commands/run/app/index.ts b/cli/src/commands/run/app/index.ts index 44ea93c542b..815d708d9d8 100644 --- a/cli/src/commands/run/app/index.ts +++ b/cli/src/commands/run/app/index.ts @@ -4,6 +4,7 @@ import { httpRetryFlag } from '@/commands/_shared/global-flags' import { Args, Flags } from '@/framework/flags' import { OutputFormat } from '@/framework/output' import { agentGuide } from './guide' +import { CHAT_MODES } from './handlers' import { runApp } from './run' export default class RunApp extends DifyCommand { @@ -30,7 +31,7 @@ export default class RunApp extends DifyCommand { 'inputs': Flags.string({ description: 'Input variables as a JSON object, e.g. --inputs \'{"key":"value"}\'. Mutually exclusive with --inputs-file.' }), 'inputs-file': Flags.string({ description: 'Path to a JSON file containing the inputs object. Mutually exclusive with --inputs.' }), 'file': Flags.stringArray({ description: 'Named file input: --file key=@path for a local file or --file key=https://url for a remote URL. Repeatable.', default: [] }), - 'conversation': Flags.string({ description: 'Resume a chat conversation by id (chat/advanced-chat only)' }), + 'conversation': Flags.string({ description: `Resume a chat conversation by id (${[...CHAT_MODES].join('/')} only)` }), 'workflow-id': Flags.string({ description: 'Pin to a specific published workflow version' }), 'workspace': Flags.string({ description: 'Workspace id (overrides DIFY_WORKSPACE_ID and stored default)' }), 'stream': Flags.boolean({ description: 'Print output live as tokens/events arrive (default: collect and print at end)', default: false }),