- permission_mode を readonly/edit/full に統一(プロバイダー非依存) - Claude SDK: readonly→default, edit→acceptEdits, full→bypassPermissions とマッピング - Codex SDK: readonly→read-only, edit→workspace-write, full→danger-full-access とマッピング - Legacy値(default/acceptEdits/bypassPermissions)のサポートを削除 - 全ビルトインワークフローを新しい permission_mode 値に更新 - AgentRunner の ProviderCallOptions 生成ロジックをリファクタリング(DRY化)
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
/**
|
|
* Tests for permission mode mapping functions
|
|
*/
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
import { SdkOptionsBuilder } from '../infra/claude/options-builder.js';
|
|
import { mapToCodexSandboxMode } from '../infra/codex/types.js';
|
|
import type { PermissionMode } from '../core/models/index.js';
|
|
|
|
describe('SdkOptionsBuilder.mapToSdkPermissionMode', () => {
|
|
it('should map readonly to SDK default', () => {
|
|
expect(SdkOptionsBuilder.mapToSdkPermissionMode('readonly')).toBe('default');
|
|
});
|
|
|
|
it('should map edit to SDK acceptEdits', () => {
|
|
expect(SdkOptionsBuilder.mapToSdkPermissionMode('edit')).toBe('acceptEdits');
|
|
});
|
|
|
|
it('should map full to SDK bypassPermissions', () => {
|
|
expect(SdkOptionsBuilder.mapToSdkPermissionMode('full')).toBe('bypassPermissions');
|
|
});
|
|
|
|
it('should map all PermissionMode values exhaustively', () => {
|
|
const modes: PermissionMode[] = ['readonly', 'edit', 'full'];
|
|
for (const mode of modes) {
|
|
const result = SdkOptionsBuilder.mapToSdkPermissionMode(mode);
|
|
expect(result).toBeDefined();
|
|
expect(typeof result).toBe('string');
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('mapToCodexSandboxMode', () => {
|
|
it('should map readonly to read-only', () => {
|
|
expect(mapToCodexSandboxMode('readonly')).toBe('read-only');
|
|
});
|
|
|
|
it('should map edit to workspace-write', () => {
|
|
expect(mapToCodexSandboxMode('edit')).toBe('workspace-write');
|
|
});
|
|
|
|
it('should map full to danger-full-access', () => {
|
|
expect(mapToCodexSandboxMode('full')).toBe('danger-full-access');
|
|
});
|
|
|
|
it('should map all PermissionMode values exhaustively', () => {
|
|
const modes: PermissionMode[] = ['readonly', 'edit', 'full'];
|
|
for (const mode of modes) {
|
|
const result = mapToCodexSandboxMode(mode);
|
|
expect(result).toBeDefined();
|
|
expect(typeof result).toBe('string');
|
|
}
|
|
});
|
|
});
|