|
1 | 1 | import { describe, expect, it } from 'vitest'; |
2 | 2 |
|
| 3 | +import { agentCapabilities } from '../../src/runtimes/capabilities.js'; |
3 | 4 | import { |
4 | 5 | BYOK_OPENCODE_API_KEY_ENV, |
5 | 6 | BYOK_OPENCODE_PROVIDER_ID, |
6 | 7 | buildOpenCodeByokProviderConfig, |
7 | 8 | opencodeByokModelId, |
8 | 9 | } from '../../src/runtimes/byok-opencode.js'; |
| 10 | +import { byokOpenCodeAgentDef } from '../../src/runtimes/defs/byok-opencode.js'; |
9 | 11 |
|
10 | 12 | describe('byok-opencode runtime config', () => { |
| 13 | + it('gates non-interactive permission bypass on the installed OpenCode capability', () => { |
| 14 | + agentCapabilities.delete('byok-opencode'); |
| 15 | + expect(byokOpenCodeAgentDef.helpArgs).toEqual(['run', '--help']); |
| 16 | + expect(byokOpenCodeAgentDef.capabilityFlags).toEqual({ |
| 17 | + '--dangerously-skip-permissions': 'skipPermissions', |
| 18 | + }); |
| 19 | + expect(byokOpenCodeAgentDef.buildArgs('', [], [], {})).toEqual([ |
| 20 | + 'run', |
| 21 | + '--format', |
| 22 | + 'json', |
| 23 | + ]); |
| 24 | + |
| 25 | + agentCapabilities.set('byok-opencode', { skipPermissions: true }); |
| 26 | + try { |
| 27 | + expect(byokOpenCodeAgentDef.buildArgs('', [], [], { model: 'gpt-5.5' })).toEqual([ |
| 28 | + 'run', |
| 29 | + '--format', |
| 30 | + 'json', |
| 31 | + '--dangerously-skip-permissions', |
| 32 | + '-m', |
| 33 | + 'open-design-byok/gpt-5.5', |
| 34 | + ]); |
| 35 | + } finally { |
| 36 | + agentCapabilities.delete('byok-opencode'); |
| 37 | + } |
| 38 | + }); |
| 39 | + |
11 | 40 | it('prefixes raw BYOK models with the run-scoped OpenCode provider id', () => { |
12 | 41 | expect(opencodeByokModelId('gpt-4o-mini')).toBe('open-design-byok/gpt-4o-mini'); |
13 | 42 | expect(opencodeByokModelId('open-design-byok/gpt-4o-mini')).toBe('open-design-byok/gpt-4o-mini'); |
|
0 commit comments