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.

1.6 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { EnsureAgentSessionParams } from './agent-session-params'
import { TerminalCreateParams } from './terminal-unary-params'

const explicitResume = {
  kind: 'explicit',
  worktree: 'id:repo::/tmp/wt',
  agent: 'claude',
  providerSession: { key: 'session_id', id: 'provider-session-1' }
} as const

describe('spawnIntent on terminal-creating RPCs', () => {
  it('accepts a declared intent on an explicit resume and keeps it', () => {
    const parsed = EnsureAgentSessionParams.parse({
      ...explicitResume,
      spawnIntent: 'automatic-restore'
    })
    expect(parsed).toMatchObject({ spawnIntent: 'automatic-restore' })
  })

  it('still accepts an explicit resume without one (older clients)', () => {
    expect(EnsureAgentSessionParams.safeParse(explicitResume).success).toBe(true)
  })

  it('never accepts interactive, which a daemon kept across an update would let skip the gate', () => {
    expect(
      EnsureAgentSessionParams.safeParse({ ...explicitResume, spawnIntent: 'interactive' }).success
    ).toBe(false)
    expect(TerminalCreateParams.safeParse({ spawnIntent: 'interactive' }).success).toBe(false)
  })

  it('rejects an unknown intent instead of treating it as undeclared', () => {
    expect(
      EnsureAgentSessionParams.safeParse({
        ...explicitResume,
        spawnIntent: 'urgent'
      }).success
    ).toBe(false)
  })

  it('keeps a declared intent on terminal.create', () => {
    expect(TerminalCreateParams.parse({ spawnIntent: 'user-resume' })).toMatchObject({
      spawnIntent: 'user-resume'
    })
  })
})