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.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import { describe, expect, it } from 'vitest'
import {
taskLinearStatusSchema,
taskPreferenceWriteSchema,
taskPreflightSchema,
taskRuntimeStatusSchema,
taskUiStateSchema
} from './task-runtime-reply-schema'
describe('the runtime status', () => {
it('reads the representative capability lists', () => {
for (const capabilities of [['mobile.tasks.v1'], ['files.mutation-ownership.v1']]) {
const parsed = taskRuntimeStatusSchema.safeParse({ capabilities })
expect(parsed.success && parsed.data).toMatchObject({ capabilities })
}
})
it('requires the container main read `.capabilities` off', () => {
expect(taskRuntimeStatusSchema.safeParse(null).success).toBe(false)
expect(taskRuntimeStatusSchema.safeParse('ok').success).toBe(false)
expect(taskRuntimeStatusSchema.safeParse({}).success).toBe(true)
})
it('drops a non-string capability, which `includes` could never have matched', () => {
const parsed = taskRuntimeStatusSchema.safeParse({ capabilities: ['push.v1', 7] })
expect(parsed.success && parsed.data).toMatchObject({ capabilities: ['push.v1'] })
})
it('leaves worktreeCreateIdempotency untouched in all four states the probe triages', () => {
for (const advertised of [undefined, null, 'nonsense', { dedupeTtlMs: 45_000 }]) {
const parsed = taskRuntimeStatusSchema.safeParse({ worktreeCreateIdempotency: advertised })
expect(parsed.success).toBe(true)
expect(parsed.success ? parsed.data.worktreeCreateIdempotency : 'unparsed').toEqual(
advertised
)
}
})
})
describe('the persisted UI state', () => {
it('answers the `ui` member, which is what the member reader it replaces did', () => {
const parsed = taskUiStateSchema.safeParse({
ui: { sortBy: 'name', trustedOrcaHooks: { 'repo-1': { all: { approvedAt: 1 } } } }
})
expect(parsed.success && parsed.data).toMatchObject({
sortBy: 'name',
trustedOrcaHooks: { 'repo-1': { all: { approvedAt: 1 } } }
})
})
it('reads the representative empty ui as an empty record, not as absent', () => {
const parsed = taskUiStateSchema.safeParse({ ui: {} })
expect(parsed.success && parsed.data).toEqual({})
})
it('answers undefined for a payload with no ui, where main read undefined off the object', () => {
const parsed = taskUiStateSchema.safeParse({})
expect(parsed.success && parsed.data).toBeUndefined()
})
it.each([null, undefined, 'ok', 7, [], true])(
'answers undefined for %j, so the other hydration legs survive an unreadable ui reply',
(payload) => {
const parsed = taskUiStateSchema.safeParse(payload)
expect(parsed.success).toBe(true)
expect(parsed.success ? parsed.data : 'unparsed').toBeUndefined()
}
)
})
describe('the two advisory probes', () => {
it('reads the representative preflight and linear replies', () => {
expect(taskPreflightSchema.safeParse({ glab: { installed: false } }).success).toBe(true)
expect(taskLinearStatusSchema.safeParse({ connected: false }).success).toBe(true)
})
it('requires nothing, because every consumer compares the leaf to `true`', () => {
expect(taskPreflightSchema.safeParse({}).success).toBe(true)
expect(taskLinearStatusSchema.safeParse({}).success).toBe(true)
})
it('drops a malformed glab rather than reading it as installed', () => {
const parsed = taskPreflightSchema.safeParse({ glab: 'yes' })
expect(parsed.success ? parsed.data.glab : 'unparsed').toBeUndefined()
})
it('passes a host member no mobile consumer reads straight through', () => {
const parsed = taskPreflightSchema.safeParse({ gh: { installed: true, authenticated: true } })
expect(parsed.success && parsed.data).toMatchObject({
gh: { installed: true, authenticated: true }
})
})
// Advisory acceptance still decodes absent/null results; total readers must retain hydration defaults instead of throwing.
it.each([
['absent', undefined],
['null', null],
['a bare string', 'preflight'],
['an array', []]
])('reads a %s payload as "nothing advertised" rather than refusing it', (_label, reply) => {
const preflight = taskPreflightSchema.safeParse(reply)
expect(preflight.success).toBe(true)
expect(preflight.success && preflight.data.glab?.installed).toBeUndefined()
const linear = taskLinearStatusSchema.safeParse(reply)
expect(linear.success).toBe(true)
expect(linear.success && linear.data.connected).toBeUndefined()
})
})
describe('the three preference writes', () => {
it('accept every payload, because no call site reads their body', () => {
for (const reply of [null, undefined, 0, 'written', { ok: true }, []]) {
expect(taskPreferenceWriteSchema.safeParse(reply).success).toBe(true)
}
})
})