Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

2.3 KB
Raw Blame
// Failed Stop and card Cancel persistence need distinct actionable wording.

import { describe, expect, it } from 'vitest'
import {
  agentSessionRefusalNotice,
  agentSessionWriteNoticeEnglish,
  agentSessionWriteNoticeParts
} from './agent-session-refusal-notice'
import { agentSessionRefusalFailure } from './agent-session-write-failure'

const HOST_TEXT = 'Expected runtime fence 1; the session is at 3.'

describe('a Stop the host could not save or carry out', () => {
  const stopFailed = (details: unknown) =>
    agentSessionRefusalFailure(
      JSON.parse(JSON.stringify({ code: 'agent_session_operation_invalid', details }))
    )

  it('names the agent and says to try again', () => {
    expect(
      agentSessionRefusalNotice(
        {
          code: 'agent_session_operation_invalid',
          message: HOST_TEXT,
          details: { reason: 'stopFailed', agent: 'codex' }
        },
        'stop'
      )
    ).toBe("Couldn't stop Codex. Try again.")
    expect(
      agentSessionWriteNoticeEnglish(
        agentSessionWriteNoticeParts(stopFailed({ reason: 'stopFailed' }), 'stop')
      )
    ).toBe("Couldn't stop the agent. Try again.")
    // A newer host's agent reads as none.
    expect(
      agentSessionWriteNoticeEnglish(
        agentSessionWriteNoticeParts(
          stopFailed({ reason: 'stopFailed', agent: 'fromTheFuture' }),
          'stop'
        )
      )
    ).toBe("Couldn't stop the agent. Try again.")
  })

  it("says a card's Cancel that could not be saved left the card, never that the agent didn't stop", () => {
    expect(
      agentSessionRefusalNotice(
        {
          code: 'agent_session_operation_invalid',
          message: HOST_TEXT,
          details: { reason: 'cancelNotSaved' }
        },
        'stop'
      )
    ).toBe("Couldn't cancel this question or approval. Try again.")
  })

  // A client from before the reason keeps only reasons it lists: it reads none, and the code's words.
  it('reads on a client that predates it as the Stop that did not happen', () => {
    const refusal = JSON.parse(
      JSON.stringify({
        code: 'agent_session_operation_invalid',
        message: HOST_TEXT,
        details: { reason: 'aReasonThisClientLacks', agent: 'codex' }
      })
    )
    expect(agentSessionRefusalNotice(refusal, 'stop')).toBe("The agent wasn't stopped.")
  })
})