@kodelyth/codex 2026.5.40 → 2026.5.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-ChMX13_o.js +642 -0
- package/dist/client-factory-D3dIsp4Y.js +9 -0
- package/dist/command-formatters-BRW7_Nu7.js +519 -0
- package/dist/command-handlers-P2IqtXaZ.js +1462 -0
- package/dist/compact-baos5flR.js +329 -0
- package/dist/computer-use-VfLvTMaa.js +367 -0
- package/dist/config-CezENx_E.js +510 -0
- package/dist/doctor-contract-api.js +53 -0
- package/dist/harness.js +51 -0
- package/dist/index.js +1133 -0
- package/dist/media-understanding-provider.js +335 -0
- package/dist/models-B9DhrIwD.js +110 -0
- package/dist/node-cli-sessions-De4_DuFw.js +1216 -0
- package/dist/plugin-activation-BlMuJeXz.js +452 -0
- package/dist/prompt-overlay.js +12 -0
- package/dist/protocol-C9UWI98H.js +9 -0
- package/dist/protocol-validators-BGBspNmF.js +5988 -0
- package/dist/provider-catalog.js +84 -0
- package/dist/provider-discovery.js +33 -0
- package/dist/provider.js +150 -0
- package/dist/rate-limit-cache-CHuacE27.js +24 -0
- package/dist/request-CTQKUxaa.js +89 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/run-attempt-DqV2OU1R.js +5366 -0
- package/dist/session-binding-3PzU7ZTW.js +222 -0
- package/dist/shared-client-Cnyr9dyT.js +631 -0
- package/dist/side-question-CP5XlA0U.js +667 -0
- package/dist/test-api.js +45 -0
- package/dist/thread-lifecycle-DBJetBuV.js +1561 -0
- package/dist/vision-tools-Cl_5a93K.js +1379 -0
- package/doctor-contract-api.test.ts +44 -0
- package/doctor-contract-api.ts +68 -0
- package/harness.ts +72 -0
- package/index.test.ts +230 -0
- package/index.ts +66 -0
- package/klaw.plugin.json +24 -85
- package/media-understanding-provider.test.ts +486 -0
- package/media-understanding-provider.ts +521 -0
- package/package.json +3 -3
- package/prompt-overlay-runtime-contract.test.ts +48 -0
- package/prompt-overlay.ts +21 -0
- package/provider-catalog.ts +83 -0
- package/provider-discovery.ts +45 -0
- package/provider.test.ts +384 -0
- package/provider.ts +243 -0
- package/src/app-server/app-inventory-cache.test.ts +176 -0
- package/src/app-server/app-inventory-cache.ts +324 -0
- package/src/app-server/approval-bridge.test.ts +1471 -0
- package/src/app-server/approval-bridge.ts +1211 -0
- package/src/app-server/auth-bridge.test.ts +1449 -0
- package/src/app-server/auth-bridge.ts +614 -0
- package/src/app-server/auth-profile-runtime-contract.test.ts +239 -0
- package/src/app-server/capabilities.ts +27 -0
- package/src/app-server/client-factory.ts +24 -0
- package/src/app-server/client.test.ts +563 -0
- package/src/app-server/client.ts +715 -0
- package/src/app-server/compact.test.ts +710 -0
- package/src/app-server/compact.ts +500 -0
- package/src/app-server/computer-use.test.ts +788 -0
- package/src/app-server/computer-use.ts +683 -0
- package/src/app-server/config.test.ts +879 -0
- package/src/app-server/config.ts +1038 -0
- package/src/app-server/context-engine-projection.test.ts +252 -0
- package/src/app-server/context-engine-projection.ts +403 -0
- package/src/app-server/delivery-no-reply-runtime-contract.test.ts +80 -0
- package/src/app-server/dynamic-tool-diagnostics.ts +73 -0
- package/src/app-server/dynamic-tool-profile.ts +69 -0
- package/src/app-server/dynamic-tools.test.ts +1302 -0
- package/src/app-server/dynamic-tools.ts +623 -0
- package/src/app-server/elicitation-bridge.test.ts +1056 -0
- package/src/app-server/elicitation-bridge.ts +783 -0
- package/src/app-server/event-projector.test.ts +2668 -0
- package/src/app-server/event-projector.ts +2057 -0
- package/src/app-server/image-payload-sanitizer.test.ts +49 -0
- package/src/app-server/image-payload-sanitizer.ts +167 -0
- package/src/app-server/klaw-owned-tool-runtime-contract.test.ts +456 -0
- package/src/app-server/local-runtime-attribution.ts +39 -0
- package/src/app-server/managed-binary.test.ts +139 -0
- package/src/app-server/managed-binary.ts +193 -0
- package/src/app-server/models.test.ts +246 -0
- package/src/app-server/models.ts +172 -0
- package/src/app-server/native-hook-relay.test.ts +271 -0
- package/src/app-server/native-hook-relay.ts +150 -0
- package/src/app-server/native-subagent-task-mirror.test.ts +573 -0
- package/src/app-server/native-subagent-task-mirror.ts +497 -0
- package/src/app-server/outcome-fallback-runtime-contract.test.ts +404 -0
- package/src/app-server/plugin-activation.test.ts +336 -0
- package/src/app-server/plugin-activation.ts +283 -0
- package/src/app-server/plugin-app-cache-key.ts +74 -0
- package/src/app-server/plugin-approval-roundtrip.ts +122 -0
- package/src/app-server/plugin-inventory.test.ts +355 -0
- package/src/app-server/plugin-inventory.ts +357 -0
- package/src/app-server/plugin-thread-config.test.ts +865 -0
- package/src/app-server/plugin-thread-config.ts +455 -0
- package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +33 -0
- package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +199 -0
- package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +102 -0
- package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +227 -0
- package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +2630 -0
- package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +2630 -0
- package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +1659 -0
- package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +1655 -0
- package/src/app-server/protocol-validators.test.ts +75 -0
- package/src/app-server/protocol-validators.ts +203 -0
- package/src/app-server/protocol.ts +520 -0
- package/src/app-server/rate-limit-cache.ts +48 -0
- package/src/app-server/rate-limits.test.ts +202 -0
- package/src/app-server/rate-limits.ts +583 -0
- package/src/app-server/request.ts +73 -0
- package/src/app-server/run-attempt.context-engine.test.ts +1004 -0
- package/src/app-server/run-attempt.test.ts +9477 -0
- package/src/app-server/run-attempt.ts +4683 -0
- package/src/app-server/run-attempt.vision-tools.test.ts +35 -0
- package/src/app-server/schema-normalization-runtime-contract.test.ts +206 -0
- package/src/app-server/session-binding.test.ts +303 -0
- package/src/app-server/session-binding.ts +398 -0
- package/src/app-server/session-history.ts +44 -0
- package/src/app-server/shared-client.test.ts +589 -0
- package/src/app-server/shared-client.ts +289 -0
- package/src/app-server/side-question.test.ts +1175 -0
- package/src/app-server/side-question.ts +1007 -0
- package/src/app-server/test-support.ts +48 -0
- package/src/app-server/thread-lifecycle.test.ts +447 -0
- package/src/app-server/thread-lifecycle.ts +939 -0
- package/src/app-server/thread-lifecycle.user-mcp-servers.test.ts +442 -0
- package/src/app-server/timeout.ts +9 -0
- package/src/app-server/tool-progress-normalization.ts +77 -0
- package/src/app-server/trajectory.test.ts +205 -0
- package/src/app-server/trajectory.ts +365 -0
- package/src/app-server/transcript-mirror.test.ts +524 -0
- package/src/app-server/transcript-mirror.ts +208 -0
- package/src/app-server/transcript-repair-runtime-contract.test.ts +44 -0
- package/src/app-server/transport-stdio.test.ts +171 -0
- package/src/app-server/transport-stdio.ts +107 -0
- package/src/app-server/transport-websocket.test.ts +69 -0
- package/src/app-server/transport-websocket.ts +90 -0
- package/src/app-server/transport.ts +117 -0
- package/src/app-server/user-input-bridge.test.ts +249 -0
- package/src/app-server/user-input-bridge.ts +316 -0
- package/src/app-server/version.ts +4 -0
- package/src/app-server/vision-tools.ts +12 -0
- package/src/command-account.ts +544 -0
- package/src/command-formatters.ts +425 -0
- package/src/command-handlers.ts +2004 -0
- package/src/command-rpc.test.ts +16 -0
- package/src/command-rpc.ts +142 -0
- package/src/commands.test.ts +3312 -0
- package/src/commands.ts +65 -0
- package/src/conversation-binding-data.ts +124 -0
- package/src/conversation-binding.test.ts +599 -0
- package/src/conversation-binding.ts +561 -0
- package/src/conversation-control.test.ts +126 -0
- package/src/conversation-control.ts +303 -0
- package/src/conversation-turn-collector.test.ts +191 -0
- package/src/conversation-turn-collector.ts +186 -0
- package/src/conversation-turn-input.test.ts +141 -0
- package/src/conversation-turn-input.ts +106 -0
- package/src/manifest.test.ts +20 -0
- package/src/migration/apply.ts +501 -0
- package/src/migration/helpers.ts +55 -0
- package/src/migration/plan.ts +461 -0
- package/src/migration/provider.test.ts +1741 -0
- package/src/migration/provider.ts +41 -0
- package/src/migration/source.ts +643 -0
- package/src/migration/targets.ts +25 -0
- package/src/node-cli-sessions.test.ts +180 -0
- package/src/node-cli-sessions.ts +711 -0
- package/test-api.ts +82 -0
- package/tsconfig.json +16 -0
- package/doctor-contract-api.js +0 -7
- package/harness.js +0 -7
- package/index.js +0 -7
- package/media-understanding-provider.js +0 -7
- package/prompt-overlay.js +0 -7
- package/provider-catalog.js +0 -7
- package/provider-discovery.js +0 -7
- package/provider.js +0 -7
- package/test-api.js +0 -7
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { PassThrough, Writable } from "node:stream";
|
|
3
|
+
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
4
|
+
import { vi } from "vitest";
|
|
5
|
+
import { CodexAppServerClient } from "./client.js";
|
|
6
|
+
|
|
7
|
+
export function createCodexTestModel(provider = "openai-codex", input = ["text"]): Model<Api> {
|
|
8
|
+
return {
|
|
9
|
+
id: "gpt-5.4-codex",
|
|
10
|
+
name: "gpt-5.4-codex",
|
|
11
|
+
provider,
|
|
12
|
+
api: "openai-codex-responses",
|
|
13
|
+
input,
|
|
14
|
+
reasoning: true,
|
|
15
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
16
|
+
contextWindow: 128_000,
|
|
17
|
+
maxTokens: 8_000,
|
|
18
|
+
} as Model<Api>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createClientHarness() {
|
|
22
|
+
const stdout = new PassThrough();
|
|
23
|
+
const writes: string[] = [];
|
|
24
|
+
const stdin = new Writable({
|
|
25
|
+
write(chunk, _encoding, callback) {
|
|
26
|
+
writes.push(chunk.toString());
|
|
27
|
+
callback();
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const process = Object.assign(new EventEmitter(), {
|
|
31
|
+
stdin,
|
|
32
|
+
stdout,
|
|
33
|
+
stderr: new PassThrough(),
|
|
34
|
+
killed: false,
|
|
35
|
+
kill: vi.fn(() => {
|
|
36
|
+
process.killed = true;
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
const client = CodexAppServerClient.fromTransportForTests(process);
|
|
40
|
+
return {
|
|
41
|
+
client,
|
|
42
|
+
process,
|
|
43
|
+
writes,
|
|
44
|
+
send(message: unknown) {
|
|
45
|
+
stdout.write(`${JSON.stringify(message)}\n`);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import type { EmbeddedRunAttemptParams } from "klaw/plugin-sdk/agent-harness-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
buildDeveloperInstructions,
|
|
5
|
+
buildTurnStartParams,
|
|
6
|
+
buildThreadResumeParams,
|
|
7
|
+
buildThreadStartParams,
|
|
8
|
+
resolveReasoningEffort,
|
|
9
|
+
} from "./thread-lifecycle.js";
|
|
10
|
+
|
|
11
|
+
function createAttemptParams(params: {
|
|
12
|
+
provider: string;
|
|
13
|
+
authProfileId?: string;
|
|
14
|
+
authProfileProvider?: string;
|
|
15
|
+
authProfileProviders?: Record<string, string>;
|
|
16
|
+
bootstrapContextMode?: "full" | "lightweight";
|
|
17
|
+
bootstrapContextRunKind?: "default" | "heartbeat" | "cron";
|
|
18
|
+
images?: EmbeddedRunAttemptParams["images"];
|
|
19
|
+
}): EmbeddedRunAttemptParams {
|
|
20
|
+
const authProfileProviders =
|
|
21
|
+
params.authProfileProviders ??
|
|
22
|
+
(params.authProfileId
|
|
23
|
+
? { [params.authProfileId]: params.authProfileProvider ?? "openai-codex" }
|
|
24
|
+
: {});
|
|
25
|
+
return {
|
|
26
|
+
provider: params.provider,
|
|
27
|
+
modelId: "gpt-5.4",
|
|
28
|
+
prompt: "test prompt",
|
|
29
|
+
authProfileId: params.authProfileId,
|
|
30
|
+
...(params.bootstrapContextMode ? { bootstrapContextMode: params.bootstrapContextMode } : {}),
|
|
31
|
+
...(params.bootstrapContextRunKind
|
|
32
|
+
? { bootstrapContextRunKind: params.bootstrapContextRunKind }
|
|
33
|
+
: {}),
|
|
34
|
+
...(params.images ? { images: params.images } : {}),
|
|
35
|
+
authProfileStore: {
|
|
36
|
+
version: 1,
|
|
37
|
+
profiles: Object.fromEntries(
|
|
38
|
+
Object.entries(authProfileProviders).map(([profileId, provider]) => [
|
|
39
|
+
profileId,
|
|
40
|
+
{
|
|
41
|
+
type: "oauth" as const,
|
|
42
|
+
provider,
|
|
43
|
+
access: "access-token",
|
|
44
|
+
refresh: "refresh-token",
|
|
45
|
+
expires: Date.now() + 60_000,
|
|
46
|
+
},
|
|
47
|
+
]),
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
} as EmbeddedRunAttemptParams;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function createAppServerOptions() {
|
|
54
|
+
return {
|
|
55
|
+
approvalPolicy: "on-request",
|
|
56
|
+
approvalsReviewer: "user",
|
|
57
|
+
sandbox: "workspace-write",
|
|
58
|
+
} as const;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
describe("Codex app-server native code mode config", () => {
|
|
62
|
+
it("keeps Codex-native subagents primary while routing Klaw spawn through dynamic search", () => {
|
|
63
|
+
const instructions = buildDeveloperInstructions(createAttemptParams({ provider: "openai" }));
|
|
64
|
+
|
|
65
|
+
expect(instructions).toContain("Use Codex native `spawn_agent` for Codex subagents");
|
|
66
|
+
expect(instructions).toContain(
|
|
67
|
+
"search for `sessions_spawn` in the `klaw` dynamic tool namespace",
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("summarizes deferred dynamic tool names in developer instructions", () => {
|
|
72
|
+
const instructions = buildDeveloperInstructions(createAttemptParams({ provider: "openai" }), {
|
|
73
|
+
dynamicTools: [
|
|
74
|
+
{
|
|
75
|
+
name: "message",
|
|
76
|
+
description: "Send a message",
|
|
77
|
+
inputSchema: { type: "object" },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "music_generate",
|
|
81
|
+
description: "Create music",
|
|
82
|
+
inputSchema: { type: "object" },
|
|
83
|
+
namespace: "klaw",
|
|
84
|
+
deferLoading: true,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "image_generate",
|
|
88
|
+
description: "Create images",
|
|
89
|
+
inputSchema: { type: "object" },
|
|
90
|
+
namespace: "klaw",
|
|
91
|
+
deferLoading: true,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
expect(instructions).toContain(
|
|
97
|
+
"Deferred searchable Klaw dynamic tools available: image_generate, music_generate.",
|
|
98
|
+
);
|
|
99
|
+
expect(instructions).toContain("Use `tool_search` to load exact callable specs before use.");
|
|
100
|
+
expect(instructions).not.toContain("message,");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("keeps developer instructions compact when no dynamic tools are deferred", () => {
|
|
104
|
+
const instructions = buildDeveloperInstructions(createAttemptParams({ provider: "openai" }), {
|
|
105
|
+
dynamicTools: [
|
|
106
|
+
{
|
|
107
|
+
name: "message",
|
|
108
|
+
description: "Send a message",
|
|
109
|
+
inputSchema: { type: "object" },
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(instructions).not.toContain("Deferred searchable Klaw dynamic tools available");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("keeps Klaw skill catalogs out of developer instructions", () => {
|
|
118
|
+
const params = createAttemptParams({ provider: "openai" });
|
|
119
|
+
params.skillsSnapshot = {
|
|
120
|
+
prompt: "<available_skills><skill><name>demo</name></skill></available_skills>",
|
|
121
|
+
skills: [],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const instructions = buildDeveloperInstructions(params);
|
|
125
|
+
|
|
126
|
+
expect(instructions).not.toContain("<available_skills>");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("enables Codex code mode on thread/start without clobbering other config", () => {
|
|
130
|
+
const request = buildThreadStartParams(createAttemptParams({ provider: "openai" }), {
|
|
131
|
+
cwd: "/repo",
|
|
132
|
+
dynamicTools: [],
|
|
133
|
+
appServer: createAppServerOptions() as never,
|
|
134
|
+
developerInstructions: "test instructions",
|
|
135
|
+
config: {
|
|
136
|
+
"features.hooks": true,
|
|
137
|
+
apps: { _default: { enabled: false } },
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
expect(request.config).toEqual({
|
|
142
|
+
"features.hooks": true,
|
|
143
|
+
apps: { _default: { enabled: false } },
|
|
144
|
+
"features.code_mode": true,
|
|
145
|
+
"features.code_mode_only": false,
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("allows thread config to opt into Codex code-mode-only", () => {
|
|
150
|
+
const request = buildThreadStartParams(createAttemptParams({ provider: "openai" }), {
|
|
151
|
+
cwd: "/repo",
|
|
152
|
+
dynamicTools: [],
|
|
153
|
+
appServer: createAppServerOptions() as never,
|
|
154
|
+
developerInstructions: "test instructions",
|
|
155
|
+
config: {
|
|
156
|
+
"features.code_mode_only": true,
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
expect(request.config).toEqual({
|
|
161
|
+
"features.code_mode": true,
|
|
162
|
+
"features.code_mode_only": true,
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("forces Codex code-mode-only when app-server policy opts in", () => {
|
|
167
|
+
const request = buildThreadStartParams(createAttemptParams({ provider: "openai" }), {
|
|
168
|
+
cwd: "/repo",
|
|
169
|
+
dynamicTools: [],
|
|
170
|
+
appServer: createAppServerOptions() as never,
|
|
171
|
+
developerInstructions: "test instructions",
|
|
172
|
+
nativeCodeModeOnlyEnabled: true,
|
|
173
|
+
config: {
|
|
174
|
+
"features.code_mode_only": false,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
expect(request.config).toEqual({
|
|
179
|
+
"features.code_mode": true,
|
|
180
|
+
"features.code_mode_only": true,
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("enables Codex code mode on thread/resume", () => {
|
|
185
|
+
const request = buildThreadResumeParams(createAttemptParams({ provider: "openai" }), {
|
|
186
|
+
threadId: "thread-1",
|
|
187
|
+
appServer: createAppServerOptions() as never,
|
|
188
|
+
developerInstructions: "test instructions",
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
expect(request.config).toEqual({
|
|
192
|
+
"features.code_mode": true,
|
|
193
|
+
"features.code_mode_only": false,
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("disables Codex native code mode on thread/start when runtime policy denies it", () => {
|
|
198
|
+
const request = buildThreadStartParams(createAttemptParams({ provider: "openai" }), {
|
|
199
|
+
cwd: "/repo",
|
|
200
|
+
dynamicTools: [],
|
|
201
|
+
appServer: createAppServerOptions() as never,
|
|
202
|
+
developerInstructions: "test instructions",
|
|
203
|
+
nativeCodeModeEnabled: false,
|
|
204
|
+
nativeCodeModeOnlyEnabled: true,
|
|
205
|
+
config: {
|
|
206
|
+
"features.code_mode": true,
|
|
207
|
+
"features.code_mode_only": true,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(request.config).toEqual({
|
|
212
|
+
"features.code_mode": false,
|
|
213
|
+
"features.code_mode_only": false,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("disables Codex native code mode on thread/resume when runtime policy denies it", () => {
|
|
218
|
+
const request = buildThreadResumeParams(createAttemptParams({ provider: "openai" }), {
|
|
219
|
+
threadId: "thread-1",
|
|
220
|
+
appServer: createAppServerOptions() as never,
|
|
221
|
+
developerInstructions: "test instructions",
|
|
222
|
+
nativeCodeModeEnabled: false,
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
expect(request.config).toEqual({
|
|
226
|
+
"features.code_mode": false,
|
|
227
|
+
"features.code_mode_only": false,
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("disables native Codex project docs for lightweight context threads", () => {
|
|
232
|
+
const request = buildThreadStartParams(
|
|
233
|
+
createAttemptParams({
|
|
234
|
+
provider: "openai",
|
|
235
|
+
bootstrapContextMode: "lightweight",
|
|
236
|
+
bootstrapContextRunKind: "cron",
|
|
237
|
+
}),
|
|
238
|
+
{
|
|
239
|
+
cwd: "/repo",
|
|
240
|
+
dynamicTools: [],
|
|
241
|
+
appServer: createAppServerOptions() as never,
|
|
242
|
+
developerInstructions: "test instructions",
|
|
243
|
+
config: {
|
|
244
|
+
project_doc_max_bytes: 64_000,
|
|
245
|
+
"features.hooks": true,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
expect(request.config).toEqual({
|
|
251
|
+
project_doc_max_bytes: 0,
|
|
252
|
+
"features.hooks": true,
|
|
253
|
+
"features.code_mode": true,
|
|
254
|
+
"features.code_mode_only": false,
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it("keeps native Codex project docs enabled when context is not lightweight", () => {
|
|
259
|
+
const request = buildThreadResumeParams(
|
|
260
|
+
createAttemptParams({ provider: "openai", bootstrapContextRunKind: "cron" }),
|
|
261
|
+
{
|
|
262
|
+
threadId: "thread-1",
|
|
263
|
+
appServer: createAppServerOptions() as never,
|
|
264
|
+
developerInstructions: "test instructions",
|
|
265
|
+
config: {
|
|
266
|
+
project_doc_max_bytes: 64_000,
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
expect(request.config).toEqual({
|
|
272
|
+
project_doc_max_bytes: 64_000,
|
|
273
|
+
"features.code_mode": true,
|
|
274
|
+
"features.code_mode_only": false,
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
describe("Codex app-server turn input image sanitizing", () => {
|
|
280
|
+
it("uses an explicit turn sandbox policy override when provided", () => {
|
|
281
|
+
const request = buildTurnStartParams(createAttemptParams({ provider: "openai" }), {
|
|
282
|
+
threadId: "thread-1",
|
|
283
|
+
cwd: "/repo",
|
|
284
|
+
appServer: createAppServerOptions() as never,
|
|
285
|
+
sandboxPolicy: {
|
|
286
|
+
type: "workspaceWrite",
|
|
287
|
+
writableRoots: ["/repo"],
|
|
288
|
+
networkAccess: true,
|
|
289
|
+
excludeTmpdirEnvVar: false,
|
|
290
|
+
excludeSlashTmp: false,
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
expect(request.sandboxPolicy).toEqual({
|
|
295
|
+
type: "workspaceWrite",
|
|
296
|
+
writableRoots: ["/repo"],
|
|
297
|
+
networkAccess: true,
|
|
298
|
+
excludeTmpdirEnvVar: false,
|
|
299
|
+
excludeSlashTmp: false,
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("replaces malformed inline images before turn/start", () => {
|
|
304
|
+
const request = buildTurnStartParams(
|
|
305
|
+
createAttemptParams({
|
|
306
|
+
provider: "openai",
|
|
307
|
+
images: [{ type: "image", mimeType: "image/jpeg", data: "not base64!" }] as never,
|
|
308
|
+
}),
|
|
309
|
+
{
|
|
310
|
+
threadId: "thread-1",
|
|
311
|
+
cwd: "/repo",
|
|
312
|
+
appServer: createAppServerOptions() as never,
|
|
313
|
+
},
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
expect(request.input).toEqual([
|
|
317
|
+
{ type: "text", text: "test prompt", text_elements: [] },
|
|
318
|
+
{
|
|
319
|
+
type: "text",
|
|
320
|
+
text: "[codex user input] omitted image payload: invalid inline image data",
|
|
321
|
+
text_elements: [],
|
|
322
|
+
},
|
|
323
|
+
]);
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
describe("Codex app-server model provider selection", () => {
|
|
328
|
+
it.each(["openai", "openai-codex"])(
|
|
329
|
+
"omits public %s modelProvider when forwarding native Codex auth on thread/start",
|
|
330
|
+
(provider) => {
|
|
331
|
+
const request = buildThreadStartParams(
|
|
332
|
+
createAttemptParams({ provider, authProfileId: "work" }),
|
|
333
|
+
{
|
|
334
|
+
cwd: "/repo",
|
|
335
|
+
dynamicTools: [],
|
|
336
|
+
appServer: createAppServerOptions() as never,
|
|
337
|
+
developerInstructions: "test instructions",
|
|
338
|
+
},
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
expect(request).not.toHaveProperty("modelProvider");
|
|
342
|
+
},
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
it("uses the bound native Codex auth profile when deciding thread/resume modelProvider", () => {
|
|
346
|
+
const request = buildThreadResumeParams(
|
|
347
|
+
createAttemptParams({
|
|
348
|
+
provider: "openai",
|
|
349
|
+
authProfileProviders: { bound: "openai-codex" },
|
|
350
|
+
}),
|
|
351
|
+
{
|
|
352
|
+
threadId: "thread-1",
|
|
353
|
+
authProfileId: "bound",
|
|
354
|
+
appServer: createAppServerOptions() as never,
|
|
355
|
+
developerInstructions: "test instructions",
|
|
356
|
+
},
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
expect(request).not.toHaveProperty("modelProvider");
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it("does not infer native Codex auth from the profile id prefix", () => {
|
|
363
|
+
const request = buildThreadStartParams(
|
|
364
|
+
createAttemptParams({
|
|
365
|
+
provider: "openai",
|
|
366
|
+
authProfileId: "openai-codex:work",
|
|
367
|
+
authProfileProvider: "openai",
|
|
368
|
+
}),
|
|
369
|
+
{
|
|
370
|
+
cwd: "/repo",
|
|
371
|
+
dynamicTools: [],
|
|
372
|
+
appServer: createAppServerOptions() as never,
|
|
373
|
+
developerInstructions: "test instructions",
|
|
374
|
+
},
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
expect(request.modelProvider).toBe("openai");
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it("keeps public OpenAI modelProvider when no native Codex auth profile is selected", () => {
|
|
381
|
+
const request = buildThreadStartParams(createAttemptParams({ provider: "openai" }), {
|
|
382
|
+
cwd: "/repo",
|
|
383
|
+
dynamicTools: [],
|
|
384
|
+
appServer: createAppServerOptions() as never,
|
|
385
|
+
developerInstructions: "test instructions",
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
expect(request.modelProvider).toBe("openai");
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
describe("resolveReasoningEffort (#71946)", () => {
|
|
393
|
+
describe("modern Codex models (none/low/medium/high/xhigh enum)", () => {
|
|
394
|
+
it.each(["gpt-5.5", "gpt-5.4", "gpt-5.4-mini", "gpt-5.2"] as const)(
|
|
395
|
+
"translates 'minimal' -> 'low' for %s so the first request is accepted",
|
|
396
|
+
(modelId) => {
|
|
397
|
+
expect(resolveReasoningEffort("minimal", modelId)).toBe("low");
|
|
398
|
+
},
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
it.each(["gpt-5.5", "gpt-5.4", "gpt-5.4-mini", "gpt-5.2"] as const)(
|
|
402
|
+
"passes 'low' / 'medium' / 'high' / 'xhigh' through unchanged for %s",
|
|
403
|
+
(modelId) => {
|
|
404
|
+
expect(resolveReasoningEffort("low", modelId)).toBe("low");
|
|
405
|
+
expect(resolveReasoningEffort("medium", modelId)).toBe("medium");
|
|
406
|
+
expect(resolveReasoningEffort("high", modelId)).toBe("high");
|
|
407
|
+
expect(resolveReasoningEffort("xhigh", modelId)).toBe("xhigh");
|
|
408
|
+
},
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
it("normalizes case-variant model ids", () => {
|
|
412
|
+
expect(resolveReasoningEffort("minimal", "GPT-5.5")).toBe("low");
|
|
413
|
+
expect(resolveReasoningEffort("minimal", " gpt-5.4-mini ")).toBe("low");
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
describe("legacy / non-modern Codex models", () => {
|
|
418
|
+
it.each(["gpt-5", "gpt-4o", "o3-mini", "codex-mini-latest"] as const)(
|
|
419
|
+
"preserves 'minimal' for %s — pre-modern enum still supports it",
|
|
420
|
+
(modelId) => {
|
|
421
|
+
expect(resolveReasoningEffort("minimal", modelId)).toBe("minimal");
|
|
422
|
+
},
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
it("preserves 'minimal' for empty / unknown model ids (conservative default)", () => {
|
|
426
|
+
expect(resolveReasoningEffort("minimal", "")).toBe("minimal");
|
|
427
|
+
expect(resolveReasoningEffort("minimal", "unknown-model-xyz")).toBe("minimal");
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
describe("non-effort thinkLevel values", () => {
|
|
432
|
+
it("returns null for 'off'", () => {
|
|
433
|
+
expect(resolveReasoningEffort("off", "gpt-5.5")).toBeNull();
|
|
434
|
+
expect(resolveReasoningEffort("off", "gpt-4o")).toBeNull();
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it("returns null for 'adaptive' (non-effort enum value)", () => {
|
|
438
|
+
expect(resolveReasoningEffort("adaptive", "gpt-5.5")).toBeNull();
|
|
439
|
+
expect(resolveReasoningEffort("adaptive", "gpt-4o")).toBeNull();
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it("returns null for 'max' (non-effort enum value)", () => {
|
|
443
|
+
expect(resolveReasoningEffort("max", "gpt-5.5")).toBeNull();
|
|
444
|
+
expect(resolveReasoningEffort("max", "gpt-4o")).toBeNull();
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
});
|