mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 08:03:39 +00:00
fix(cli): fail refused terminal sends truthfully
This commit is contained in:
@@ -5,6 +5,8 @@ import { printHelp } from '../help'
|
||||
import { COMMAND_SPECS } from '../specs'
|
||||
import { TERMINAL_HANDLERS } from './terminal'
|
||||
|
||||
const ORIGINAL_EXIT_CODE = process.exitCode
|
||||
|
||||
describe('terminal close CLI', () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
@@ -65,6 +67,7 @@ describe('terminal close CLI', () => {
|
||||
describe('terminal send CLI', () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
process.exitCode = ORIGINAL_EXIT_CODE
|
||||
})
|
||||
|
||||
it('marks combined text and Enter as an agent prompt candidate', async () => {
|
||||
@@ -113,6 +116,7 @@ describe('terminal send CLI', () => {
|
||||
}
|
||||
})
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
process.exitCode = undefined
|
||||
|
||||
await TERMINAL_HANDLERS['terminal send']({
|
||||
flags: new Map<string, string | true>([
|
||||
@@ -128,6 +132,7 @@ describe('terminal send CLI', () => {
|
||||
expect(console.log).toHaveBeenCalledWith(
|
||||
expect.stringMatching(/Structured Chat.*Switch it to Terminal.*orca terminal send/s)
|
||||
)
|
||||
expect(process.exitCode).toBe(1)
|
||||
})
|
||||
|
||||
it('keeps text-only and bare Enter sends as direct terminal input', async () => {
|
||||
|
||||
@@ -115,6 +115,9 @@ export const TERMINAL_HANDLERS: Record<string, CommandHandler> = {
|
||||
client: { id: 'orca-cli', type: 'desktop' }
|
||||
})
|
||||
printResult(result, json, formatTerminalSend)
|
||||
if (!result.result.send.accepted) {
|
||||
process.exitCode = 1
|
||||
}
|
||||
},
|
||||
'terminal wait': async ({ flags, client, cwd, json }) => {
|
||||
const timeoutMs = getOptionalPositiveIntegerFlag(flags, 'timeout-ms')
|
||||
|
||||
@@ -287,10 +287,12 @@ describe('orchestration while Structured Chat owns an agent session', () => {
|
||||
expect(writes.mock.calls.filter(([ptyId]) => ptyId === WORKER.ptyId)).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('returns terminal.send typed refusal metadata without writing bytes', async () => {
|
||||
it('reports a real gate refusal with typed metadata and zero bytes written', async () => {
|
||||
const response = await rpc('terminal.send', {
|
||||
terminal: WORKER.handle,
|
||||
text: 'new prompt',
|
||||
enter: true,
|
||||
agentPrompt: true,
|
||||
client: { id: 'test-client', type: 'desktop' }
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user