mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
fix: tighten codex runtime config ownership
This commit is contained in:
parent
074c9c3d97
commit
f07f3f320b
4 changed files with 11 additions and 19 deletions
|
|
@ -12,18 +12,14 @@ export interface BuildCodexRuntimeConfigInput {
|
|||
|
||||
export interface CodexRuntimeConfig {
|
||||
configOverrides: Record<string, unknown>;
|
||||
env: NodeJS.ProcessEnv;
|
||||
env: Record<string, string>;
|
||||
}
|
||||
|
||||
export function buildCodexRuntimeConfig(input: BuildCodexRuntimeConfigInput): CodexRuntimeConfig {
|
||||
const configOverrides: Record<string, unknown> = {
|
||||
model: input.model,
|
||||
approval_policy: 'never',
|
||||
sandbox_mode: 'read-only',
|
||||
web_search: 'disabled',
|
||||
history: { persistence: 'none' },
|
||||
};
|
||||
const env: NodeJS.ProcessEnv = {};
|
||||
const env: Record<string, string> = {};
|
||||
|
||||
if (input.mcp) {
|
||||
configOverrides.mcp_servers = {
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@ async function mcpForTools(input: {
|
|||
});
|
||||
}
|
||||
|
||||
function runtimeToolNames(toolSet: KtxRuntimeToolSet | undefined): string[] {
|
||||
return Object.values(toolSet ?? {}).map((descriptor) => descriptor.name);
|
||||
}
|
||||
|
||||
export class CodexKtxLlmRuntime implements KtxLlmRuntimePort {
|
||||
private readonly runner: CodexSdkRunner;
|
||||
private readonly logger: KtxLogger;
|
||||
|
|
@ -105,7 +109,7 @@ export class CodexKtxLlmRuntime implements KtxLlmRuntimePort {
|
|||
url: mcp.url,
|
||||
bearerTokenEnvVar: mcp.bearerTokenEnvVar,
|
||||
bearerToken: mcp.bearerToken,
|
||||
toolNames: Object.keys(input.tools ?? {}),
|
||||
toolNames: runtimeToolNames(input.tools),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
|
|
@ -146,7 +150,7 @@ export class CodexKtxLlmRuntime implements KtxLlmRuntimePort {
|
|||
url: mcp.url,
|
||||
bearerTokenEnvVar: mcp.bearerTokenEnvVar,
|
||||
bearerToken: mcp.bearerToken,
|
||||
toolNames: Object.keys(input.tools ?? {}),
|
||||
toolNames: runtimeToolNames(input.tools),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
|
|
@ -187,7 +191,7 @@ export class CodexKtxLlmRuntime implements KtxLlmRuntimePort {
|
|||
url: mcp.url,
|
||||
bearerTokenEnvVar: mcp.bearerTokenEnvVar,
|
||||
bearerToken: mcp.bearerToken,
|
||||
toolNames: Object.keys(params.toolSet),
|
||||
toolNames: runtimeToolNames(params.toolSet),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
|
|
|
|||
|
|
@ -2,13 +2,9 @@ import { describe, expect, it } from 'vitest';
|
|||
import { buildCodexRuntimeConfig } from '../../../src/context/llm/codex-runtime-config.js';
|
||||
|
||||
describe('buildCodexRuntimeConfig', () => {
|
||||
it('builds deny-by-default config without MCP tools', () => {
|
||||
it('builds generic config without SDK thread-option fields', () => {
|
||||
expect(buildCodexRuntimeConfig({ model: 'gpt-5.3-codex' })).toEqual({
|
||||
configOverrides: {
|
||||
model: 'gpt-5.3-codex',
|
||||
approval_policy: 'never',
|
||||
sandbox_mode: 'read-only',
|
||||
web_search: 'disabled',
|
||||
history: { persistence: 'none' },
|
||||
},
|
||||
env: {},
|
||||
|
|
@ -28,10 +24,6 @@ describe('buildCodexRuntimeConfig', () => {
|
|||
}),
|
||||
).toEqual({
|
||||
configOverrides: {
|
||||
model: 'gpt-5.3-codex',
|
||||
approval_policy: 'never',
|
||||
sandbox_mode: 'read-only',
|
||||
web_search: 'disabled',
|
||||
history: { persistence: 'none' },
|
||||
mcp_servers: {
|
||||
ktx: {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ describe('CodexKtxLlmRuntime', () => {
|
|||
telemetryTags: {},
|
||||
onStepFinish,
|
||||
toolSet: {
|
||||
wiki_search: {
|
||||
aliased_wiki_tool: {
|
||||
name: 'wiki_search',
|
||||
description: 'Search wiki',
|
||||
inputSchema: z.object({ query: z.string() }),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue