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 { RUNTIME_CAPABILITIES } from './protocol-version'
import {
  AGENT_STATUS_RUNS_RUNTIME_CAPABILITY,
  deserializeAgentStatusCapabilities,
  hasAgentStatusRunCapability,
  serializeAgentStatusCapabilities
} from './agent-status-run-capability'

describe('agent status run capability codec', () => {
  it('round-trips the run-aware capability', () => {
    const encoded = serializeAgentStatusCapabilities(
      new Set([AGENT_STATUS_RUNS_RUNTIME_CAPABILITY])
    )

    expect(deserializeAgentStatusCapabilities(encoded)).toEqual(
      new Set([AGENT_STATUS_RUNS_RUNTIME_CAPABILITY])
    )
    expect(hasAgentStatusRunCapability(encoded)).toBe(true)
  })

  it('ignores unknown capabilities from newer peers', () => {
    expect(
      deserializeAgentStatusCapabilities([
        'agent-status.future.v2',
        AGENT_STATUS_RUNS_RUNTIME_CAPABILITY
      ])
    ).toEqual(new Set([AGENT_STATUS_RUNS_RUNTIME_CAPABILITY]))
  })

  it.each([null, {}, 'agent-status.runs.v1', [null], ['']])(
    'rejects malformed capability envelope %#',
    (value) => {
      expect(deserializeAgentStatusCapabilities(value)).toBeNull()
      expect(hasAgentStatusRunCapability(value)).toBe(false)
    }
  )

  it('rejects an excessive capability envelope', () => {
    expect(
      deserializeAgentStatusCapabilities(
        Array.from({ length: 257 }, (_, index) => `agent-status.future-${index}`)
      )
    ).toBeNull()
  })

  it('defines the codec without advertising incomplete run-aware behavior', () => {
    expect(RUNTIME_CAPABILITIES).not.toContain(AGENT_STATUS_RUNS_RUNTIME_CAPABILITY)
  })
})