diff --git a/src/cli-core.ts b/src/cli-core.ts index 244cba4..4bc9a01 100644 --- a/src/cli-core.ts +++ b/src/cli-core.ts @@ -294,6 +294,7 @@ async function handlePrompt( maxQueueDepth: config.queueMaxDepth, verbose: globalFlags.verbose, waitForCompletion: flags.wait !== false, + terminal: globalFlags.terminal, }); if ("queued" in result) { @@ -364,6 +365,7 @@ async function handleExec( suppressSdkConsoleErrors: outputPolicy.suppressSdkConsoleErrors, timeoutMs: globalFlags.timeout, verbose: globalFlags.verbose, + terminal: globalFlags.terminal, sessionOptions: { model: globalFlags.model, allowedTools: globalFlags.allowedTools, @@ -518,6 +520,7 @@ async function handleSetMode( authPolicy: globalFlags.authPolicy, timeoutMs: globalFlags.timeout, verbose: globalFlags.verbose, + terminal: globalFlags.terminal, }); if (globalFlags.verbose && result.loadError) { @@ -555,6 +558,7 @@ async function handleSetConfigOption( authPolicy: globalFlags.authPolicy, timeoutMs: globalFlags.timeout, verbose: globalFlags.verbose, + terminal: globalFlags.terminal, }); if (globalFlags.verbose && result.loadError) { @@ -649,6 +653,7 @@ async function handleSessionsNew( authPolicy: globalFlags.authPolicy, timeoutMs: globalFlags.timeout, verbose: globalFlags.verbose, + terminal: globalFlags.terminal, sessionOptions: { model: globalFlags.model, allowedTools: globalFlags.allowedTools, @@ -689,6 +694,7 @@ async function handleSessionsEnsure( authPolicy: globalFlags.authPolicy, timeoutMs: globalFlags.timeout, verbose: globalFlags.verbose, + terminal: globalFlags.terminal, sessionOptions: { model: globalFlags.model, allowedTools: globalFlags.allowedTools, diff --git a/src/cli/flags.ts b/src/cli/flags.ts index 6c7771b..b2734a9 100644 --- a/src/cli/flags.ts +++ b/src/cli/flags.ts @@ -37,6 +37,7 @@ export type GlobalFlags = PermissionFlags & { model?: string; allowedTools?: string[]; maxTurns?: number; + terminal?: boolean; }; export type PromptFlags = { @@ -210,7 +211,8 @@ export function addGlobalFlags(command: Command): Command { "Queue owner idle TTL before shutdown (0 = keep alive forever) (default: 300)", parseTtlSeconds, ) - .option("--verbose", "Enable verbose debug logs"); + .option("--verbose", "Enable verbose debug logs") + .option("--terminal", "Enable terminal capability (default: true)", true); } export function addSessionOption(command: Command): Command { @@ -285,6 +287,7 @@ export function resolveGlobalFlags(command: Command, config: ResolvedAcpxConfig) model: typeof opts.model === "string" ? parseNonEmptyValue("Model", opts.model) : undefined, allowedTools: Array.isArray(opts.allowedTools) ? opts.allowedTools : undefined, maxTurns: typeof opts.maxTurns === "number" ? opts.maxTurns : undefined, + terminal: opts.terminal !== false, approveAll: opts.approveAll ? true : undefined, approveReads: opts.approveReads ? true : undefined, denyAll: opts.denyAll ? true : undefined, diff --git a/src/client.ts b/src/client.ts index 74edcea..fdc197c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1023,7 +1023,7 @@ export class AcpClient { readTextFile: true, writeTextFile: true, }, - terminal: true, + terminal: this.options.terminal !== false, }, clientInfo: { name: "acpx", diff --git a/src/session-runtime.ts b/src/session-runtime.ts index 63cf455..85fb312 100644 --- a/src/session-runtime.ts +++ b/src/session-runtime.ts @@ -116,6 +116,7 @@ export type RunOnceOptions = { suppressSdkConsoleErrors?: boolean; verbose?: boolean; sessionOptions?: SessionAgentOptions; + terminal?: boolean; } & TimedRunOptions; export type SessionCreateOptions = { @@ -130,6 +131,7 @@ export type SessionCreateOptions = { authPolicy?: AuthPolicy; verbose?: boolean; sessionOptions?: SessionAgentOptions; + terminal?: boolean; } & TimedRunOptions; export type SessionSendOptions = { @@ -147,6 +149,7 @@ export type SessionSendOptions = { waitForCompletion?: boolean; ttlMs?: number; maxQueueDepth?: number; + terminal?: boolean; } & TimedRunOptions; export type SessionEnsureOptions = { @@ -162,6 +165,7 @@ export type SessionEnsureOptions = { verbose?: boolean; walkBoundary?: string; sessionOptions?: SessionAgentOptions; + terminal?: boolean; } & TimedRunOptions; export type SessionCancelOptions = { @@ -182,6 +186,7 @@ export type SessionSetModeOptions = { authCredentials?: Record; authPolicy?: AuthPolicy; verbose?: boolean; + terminal?: boolean; } & TimedRunOptions; export type SessionSetConfigOptionOptions = { @@ -193,6 +198,7 @@ export type SessionSetConfigOptionOptions = { authCredentials?: Record; authPolicy?: AuthPolicy; verbose?: boolean; + terminal?: boolean; } & TimedRunOptions; function toPromptResult( @@ -219,6 +225,7 @@ type RunSessionPromptOptions = { timeoutMs?: number; suppressSdkConsoleErrors?: boolean; verbose?: boolean; + terminal?: boolean; onClientAvailable?: (controller: ActiveSessionController) => void; onClientClosed?: () => void; onPromptActive?: () => Promise | void; @@ -519,6 +526,7 @@ async function runSessionPrompt(options: RunSessionPromptOptions): Promise verbose: options.verbose, onAcpOutputMessage: (_direction, message) => output.onAcpMessage(message), sessionOptions: options.sessionOptions, + terminal: options.terminal, }); try { @@ -796,6 +805,7 @@ export async function createSession(options: SessionCreateOptions): Promise = { authPolicy?: AuthPolicy; timeoutMs?: number; verbose?: boolean; + terminal?: boolean; onClientAvailable?: (controller: ActiveSessionController) => void; onClientClosed?: () => void; run: (client: AcpClient, sessionId: string, record: SessionRecord) => Promise; @@ -56,6 +57,7 @@ async function withConnectedSession( authCredentials: options.authCredentials, authPolicy: options.authPolicy, verbose: options.verbose, + terminal: options.terminal, }); let activeSessionIdForControl = record.acpSessionId; let notifiedClientAvailable = false; diff --git a/src/session-runtime/queue-owner-process.ts b/src/session-runtime/queue-owner-process.ts index 0e67693..1637f25 100644 --- a/src/session-runtime/queue-owner-process.ts +++ b/src/session-runtime/queue-owner-process.ts @@ -18,6 +18,7 @@ export type QueueOwnerRuntimeOptions = { verbose?: boolean; ttlMs?: number; maxQueueDepth?: number; + terminal?: boolean; }; type SessionSendLike = { @@ -31,6 +32,7 @@ type SessionSendLike = { verbose?: boolean; ttlMs?: number; maxQueueDepth?: number; + terminal?: boolean; }; export function resolveQueueOwnerSpawnArgs(argv: readonly string[] = process.argv): string[] { @@ -56,6 +58,7 @@ export function queueOwnerRuntimeOptionsFromSend( verbose: options.verbose, ttlMs: options.ttlMs, maxQueueDepth: options.maxQueueDepth, + terminal: options.terminal, }; } diff --git a/src/types.ts b/src/types.ts index 415a18d..c546b9d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -174,6 +174,7 @@ export type AcpClientOptions = { onAcpOutputMessage?: (direction: AcpMessageDirection, message: AcpJsonRpcMessage) => void; onSessionUpdate?: (notification: SessionNotification) => void; onClientOperation?: (operation: ClientOperation) => void; + terminal?: boolean; }; export const SESSION_RECORD_SCHEMA = "acpx.session.v1" as const;