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 {
NESTED_WORKER_MAX_DEPTH_DEFAULT,
nestedWorkerDepthExceededMessage,
resolveNestedWorkerMaxDepth
} from './nested-worker-depth'
describe('resolveNestedWorkerMaxDepth', () => {
it('defaults to 1 when unset', () => {
expect(resolveNestedWorkerMaxDepth(undefined)).toBe(1)
expect(resolveNestedWorkerMaxDepth(null)).toBe(1)
expect(resolveNestedWorkerMaxDepth({})).toBe(1)
})
it('accepts whole numbers at or above 1', () => {
expect(resolveNestedWorkerMaxDepth({ nestedWorkerMaxDepth: 1 })).toBe(1)
expect(resolveNestedWorkerMaxDepth({ nestedWorkerMaxDepth: 3 })).toBe(3)
})
// Malformed settings must fall back to the cap, never disable nesting limits.
it.each([
['a numeric string', '2'],
['a boolean', true],
['zero', 0],
['negative', -1],
['fractional', 1.5],
['NaN', Number.NaN],
['Infinity', Number.POSITIVE_INFINITY],
['unsafe integer', Number.MAX_SAFE_INTEGER + 1],
['null', null]
])('falls back to the default for %s', (_label, value) => {
expect(resolveNestedWorkerMaxDepth({ nestedWorkerMaxDepth: value as unknown as number })).toBe(
NESTED_WORKER_MAX_DEPTH_DEFAULT
)
})
})
describe('depth-exceeded message', () => {
it('names both depths and tells the worker to finish the task itself', () => {
const message = nestedWorkerDepthExceededMessage(2, 1)
expect(message).toContain('depth 2 (max 1)')
expect(message).toContain('Complete this task yourself')
})
})