Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
import { describe, expect, it } from 'vitest';
import { execPath } from 'node:process';
import {
applyCapabilityMatrix,
BUNDLED_CODEX_COMMIT,
BUNDLED_CODEX_VERSION,
collectCodexCapabilityMatrix,
createUnknownCapabilityMatrix,
isResumeExecutionSupported,
normalizeCodexVersionOutput,
parseCodexCapabilityMatrix,
parseCodexExecHelp,
probeCodexVersionAsync,
resolveBundledCodexStartupSnapshot
} from '../../src/codex/capabilities.js';
const EXEC_HELP_01425 = `
Usage: codex exec [OPTIONS] [PROMPT]
--json
-p, --profile <PROFILE>
-C, --cd <DIR>
--sandbox <MODE>
--image <PATH>
--skip-git-repo-check
`;
const RESUME_HELP_01425 = `
Usage: codex exec resume [OPTIONS] [SESSION_ID] [PROMPT]
--last
--all
-i, --image <FILE>
-c, --config <key=value>
-m, --model <MODEL>
--skip-git-repo-check
--ephemeral
--ignore-user-config
--ignore-rules
--output-schema <FILE>
--json
`;
const MCP_HELP_01425 = `
Usage: codex mcp [OPTIONS] <COMMAND>
Commands:
list
get <NAME>
add [OPTIONS] <NAME> <COMMAND>...
remove <NAME>
login <NAME>
logout <NAME>
`;
const MCP_ADD_HELP_01425 = `
Usage: codex mcp add [OPTIONS] <NAME> <COMMAND>...
--env <KEY=VALUE>
--url <URL>
--bearer-token-env-var <ENV_VAR>
--oauth-client-id <CLIENT_ID>
--oauth-resource <RESOURCE>
`;
const APP_SERVER_HELP_0144 = `
Run the app server
Commands:
generate-json-schema
generate-ts
`;
describe('codex capability parsing', () => {
it('uses the verified bundled runtime snapshot without launching Codex', () => {
const snapshot = resolveBundledCodexStartupSnapshot({
mode: 'bundled',
version: BUNDLED_CODEX_VERSION,
commit: BUNDLED_CODEX_COMMIT,
checkedAt: '2026-09-21T00:00:00.000Z'
});
expect(snapshot).toMatchObject({
version: 'codex-cli 0.149.0',
capabilities: {
codexVersion: 'codex-cli 0.149.0',
checkedAt: '2026-09-21T00:00:00.000Z',
execJson: true,
resumeJson: true,
appServer: true,
appServerApprovals: true,
mcpList: true,
warnings: []
}
});
expect(resolveBundledCodexStartupSnapshot({
mode: 'external',
version: BUNDLED_CODEX_VERSION,
commit: BUNDLED_CODEX_COMMIT
})).toBeUndefined();
expect(resolveBundledCodexStartupSnapshot({
mode: 'bundled',
version: BUNDLED_CODEX_VERSION,
commit: 'different-commit'
})).toBeUndefined();
});
it('extracts the Codex version line when startup warnings are present', () => {
expect(normalizeCodexVersionOutput([
'WARNING: CODEX_HOME does not exist',
'codex-cli 0.149.0'
].join('\n'))).toBe('codex-cli 0.149.0');
});
it('accepts a null sync spawn error from successful process creation', () => {
expect(() => collectCodexCapabilityMatrix({
codexBin: execPath,
timeoutMs: 1_000
})).not.toThrow();
});
it('uses a fast local version probe as the executable startup gate', async () => {
await expect(probeCodexVersionAsync({
codexBin: execPath,
timeoutMs: 1_000
})).resolves.toMatchObject({
ready: true,
version: expect.stringContaining('v')
});
await expect(probeCodexVersionAsync({
codexBin: '/path/that/does/not/exist/codex',
timeoutMs: 100
})).resolves.toMatchObject({
ready: false,
warning: expect.stringContaining('failed')
});
});
it('detects supported exec flags', () => {
const parsed = parseCodexExecHelp(EXEC_HELP_01425);
expect(parsed.supportsJson).toBe(true);
expect(parsed.supportsProfiles).toBe(true);
expect(parsed.supportsCd).toBe(true);
expect(parsed.supportsSandbox).toBe(true);
expect(parsed.supportsImages).toBe(true);
expect(parsed.supportsSkipGitRepoCheck).toBe(true);
});
it('detects resume support and unsupported resume cwd profile sandbox overrides', () => {
const matrix = parseCodexCapabilityMatrix({
versionOutput: 'codex-cli 0.142.5',
execHelp: EXEC_HELP_01425,
resumeHelp: RESUME_HELP_01425,
mcpHelp: MCP_HELP_01425,
mcpAddHelp: MCP_ADD_HELP_01425
});
expect(matrix.resumeJson).toBe(true);
expect(matrix.resumeByThreadId).toBe(true);
expect(matrix.resumeLast).toBe(true);
expect(matrix.resumeModelOverride).toBe(true);
expect(matrix.resumeConfigOverride).toBe(true);
expect(matrix.resumeCwdOverride).toBe(false);
expect(matrix.resumeProfileOverride).toBe(false);
expect(matrix.resumeSandboxOverride).toBe(false);
expect(matrix.execImages).toBe(true);
expect(matrix.resumeImages).toBe(true);
expect(isResumeExecutionSupported(matrix)).toBe(true);
});
it('detects mcp management support from help output', () => {
const matrix = parseCodexCapabilityMatrix({
versionOutput: 'codex-cli 0.142.5',
execHelp: EXEC_HELP_01425,
resumeHelp: RESUME_HELP_01425,
mcpHelp: MCP_HELP_01425,
mcpAddHelp: MCP_ADD_HELP_01425
});
expect(matrix).toMatchObject({
mcpList: true,
mcpGet: true,
mcpAdd: true,
mcpRemove: true,
mcpLogin: true,
mcpLogout: true,
mcpAddEnv: true,
mcpAddUrl: true,
mcpAddBearerTokenEnvVar: true,
mcpAddOAuth: true,
mcpRuntimeDiscoveryVerified: false,
mcpRuntimeBehaviorVerified: false
});
});
it('detects app-server approval protocol support only when schemas are available', () => {
const supported = parseCodexCapabilityMatrix({
versionOutput: 'codex-cli 0.144.1',
execHelp: EXEC_HELP_01425,
resumeHelp: RESUME_HELP_01425,
mcpHelp: MCP_HELP_01425,
mcpAddHelp: MCP_ADD_HELP_01425,
appServerHelp: APP_SERVER_HELP_0144
});
const unsupported = parseCodexCapabilityMatrix({
versionOutput: 'codex-cli 0.142.5',
execHelp: EXEC_HELP_01425,
resumeHelp: RESUME_HELP_01425,
mcpHelp: MCP_HELP_01425,
mcpAddHelp: MCP_ADD_HELP_01425,
appServerHelp: 'Run the app server'
});
expect(supported).toMatchObject({
appServer: true,
appServerApprovals: true
});
expect(unsupported).toMatchObject({
appServer: true,
appServerApprovals: false
});
});
it('does not detect mcp commands from descriptive help text alone', () => {
const matrix = parseCodexCapabilityMatrix({
versionOutput: 'codex-cli 0.142.5',
execHelp: EXEC_HELP_01425,
resumeHelp: RESUME_HELP_01425,
mcpHelp: `
Usage: codex mcp [OPTIONS] <COMMAND>
Manage MCP servers. You can list, get, add, remove, login, and logout servers.
Commands:
list
add [OPTIONS] <NAME> <COMMAND>...
`,
mcpAddHelp: MCP_ADD_HELP_01425
});
expect(matrix).toMatchObject({
mcpList: true,
mcpGet: false,
mcpAdd: true,
mcpRemove: false,
mcpLogin: false,
mcpLogout: false
});
});
it('defaults skill capability flags to false when capability help is unknown', () => {
const matrix = parseCodexCapabilityMatrix({
versionOutput: 'codex-cli 0.142.5',
execHelp: '',
resumeHelp: '',
mcpHelp: '',
mcpAddHelp: '',
checkedAt: '2026-07-05T00:00:00.000Z'
});
expect(matrix).toMatchObject({
mcpList: false,
mcpGet: false,
mcpAdd: false,
mcpRemove: false,
mcpLogin: false,
mcpLogout: false,
mcpAddEnv: false,
mcpAddUrl: false,
mcpAddBearerTokenEnvVar: false,
mcpAddOAuth: false,
mcpRuntimeDiscoveryVerified: false,
mcpRuntimeBehaviorVerified: false,
skillsScan: false,
skillsInstall: false,
skillsDelete: false,
skillsGlobalWrite: false,
skillsRuntimeDiscoveryVerified: false,
skillsRuntimeBehaviorVerified: false
});
});
it('updates one shared capability object in place', () => {
const shared = createUnknownCapabilityMatrix('2026-07-01T00:00:00.000Z');
const updated = parseCodexCapabilityMatrix({
versionOutput: 'codex-cli 0.144.1',
execHelp: EXEC_HELP_01425,
resumeHelp: RESUME_HELP_01425,
mcpHelp: MCP_HELP_01425,
mcpAddHelp: MCP_ADD_HELP_01425,
appServerHelp: APP_SERVER_HELP_0144
});
expect(applyCapabilityMatrix(shared, updated)).toBe(shared);
expect(shared).toMatchObject({
codexVersion: 'codex-cli 0.144.1',
appServerApprovals: true,
mcpAdd: true
});
});
});