/ src / lib / orchestrator-config.test.ts
orchestrator-config.test.ts
 1  import { describe, it } from 'node:test'
 2  import assert from 'node:assert/strict'
 3  import { isOrchestratorProviderEligible, normalizeOrchestratorConfig } from './orchestrator-config'
 4  
 5  describe('orchestrator-config', () => {
 6    it('marks CLI and OpenClaw providers as ineligible', () => {
 7      assert.equal(isOrchestratorProviderEligible('openai'), true)
 8      assert.equal(isOrchestratorProviderEligible('openclaw'), false)
 9      assert.equal(isOrchestratorProviderEligible('hermes'), false)
10      assert.equal(isOrchestratorProviderEligible('codex-cli'), false)
11    })
12  
13    it('normalizes persisted config and disables unsupported providers', () => {
14      const supported = normalizeOrchestratorConfig({
15        provider: 'openai',
16        orchestratorEnabled: true,
17        orchestratorMission: ' Keep things healthy ',
18        orchestratorWakeInterval: '15m',
19        orchestratorGovernance: 'approval-required',
20        orchestratorMaxCyclesPerDay: 8.9,
21      })
22      assert.deepEqual(supported, {
23        orchestratorEnabled: true,
24        orchestratorMission: 'Keep things healthy',
25        orchestratorWakeInterval: '15m',
26        orchestratorGovernance: 'approval-required',
27        orchestratorMaxCyclesPerDay: 8,
28      })
29  
30      const unsupported = normalizeOrchestratorConfig({
31        provider: 'openclaw',
32        orchestratorEnabled: true,
33        orchestratorMission: 'Will be preserved',
34        orchestratorWakeInterval: '',
35        orchestratorGovernance: 'notify-only',
36        orchestratorMaxCyclesPerDay: -2,
37      })
38      assert.deepEqual(unsupported, {
39        orchestratorEnabled: false,
40        orchestratorMission: 'Will be preserved',
41        orchestratorWakeInterval: null,
42        orchestratorGovernance: 'notify-only',
43        orchestratorMaxCyclesPerDay: null,
44      })
45    })
46  })