Files
orca/src/shared/tui-agent-launch-command-override.ts
T
Brennan Benson 0a26f3ec90 fix(native-chat): honor saved agent Command and Arguments (#25721)
* fix(native-chat): honor saved agent launch commands and arguments

* fix(test): retain provider import after syncing main

* fix(native-chat): preserve launch arguments and explain invalid settings

* refactor(native-chat): require the current launch arguments source

* fix(native-chat): require saved arguments when installing the runtime

* fix(native-chat): show saved argument refusals beside launch retry

* fix: ship saved-argument error messages in every locale

* test: align model discovery with executable overrides

* chore: drop the local pnpm install lockfile block
2026-10-06 14:17:22 -07:00

31 lines
1.1 KiB
TypeScript

import type { GlobalSettings } from './global-settings-types'
import type { TuiAgent } from './tui-agent'
import { tokenizeCustomCommandTemplate } from './commit-message-prompt'
/** A single literal executable; the execution host verifies that the file is runnable. */
export function structuredAgentCommandToken(command: string): string | null {
const input = command.trim()
if (!input || /[\0\r\n$`]/.test(input)) {
return null
}
const windowsPath = /^(?:["']?)(?:[A-Za-z]:[\\/]|\\\\)/.test(input)
const parsed = tokenizeCustomCommandTemplate(input, windowsPath ? 'literal' : 'escape')
if (
!parsed.ok ||
parsed.tokens.length !== 1 ||
parsed.spans.some((span) => span.divergesFromShell)
) {
return null
}
const token = parsed.tokens[0]
return token && !/[|&;<>(){}[\]*?!]/.test(token) ? token : null
}
/** Terminal-backed chat skips the structured catalog when its launch command is customized. */
export function hasExplicitTuiLaunchCommand(
settings: Partial<Pick<GlobalSettings, 'agentCmdOverrides'>> | null | undefined,
agent: TuiAgent
): boolean {
return Boolean(settings?.agentCmdOverrides?.[agent]?.trim())
}