@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,239 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { abortAgentHarnessRun, type EmbeddedRunAttemptParams } from "klaw/plugin-sdk/agent-harness";
|
|
5
|
+
import { AUTH_PROFILE_RUNTIME_CONTRACT } from "klaw/plugin-sdk/agent-runtime-test-contracts";
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
import type { CodexAppServerClientFactory } from "./client-factory.js";
|
|
8
|
+
import { runCodexAppServerAttempt as runCodexAppServerAttemptImpl } from "./run-attempt.js";
|
|
9
|
+
import { readCodexAppServerBinding, writeCodexAppServerBinding } from "./session-binding.js";
|
|
10
|
+
import { createCodexTestModel } from "./test-support.js";
|
|
11
|
+
|
|
12
|
+
let codexAppServerClientFactoryForTest: CodexAppServerClientFactory | undefined;
|
|
13
|
+
|
|
14
|
+
type RunCodexAppServerAttemptOptions = NonNullable<
|
|
15
|
+
Parameters<typeof runCodexAppServerAttemptImpl>[1]
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
function setCodexAppServerClientFactoryForTest(factory: CodexAppServerClientFactory): void {
|
|
19
|
+
codexAppServerClientFactoryForTest = factory;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function resetCodexAppServerClientFactoryForTest(): void {
|
|
23
|
+
codexAppServerClientFactoryForTest = undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function runCodexAppServerAttempt(
|
|
27
|
+
params: EmbeddedRunAttemptParams,
|
|
28
|
+
options: RunCodexAppServerAttemptOptions = {},
|
|
29
|
+
) {
|
|
30
|
+
const clientFactory = options.clientFactory ?? codexAppServerClientFactoryForTest;
|
|
31
|
+
return runCodexAppServerAttemptImpl(
|
|
32
|
+
params,
|
|
33
|
+
clientFactory ? { ...options, clientFactory } : options,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function createParams(sessionFile: string, workspaceDir: string): EmbeddedRunAttemptParams {
|
|
38
|
+
return {
|
|
39
|
+
prompt: AUTH_PROFILE_RUNTIME_CONTRACT.workspacePrompt,
|
|
40
|
+
sessionId: AUTH_PROFILE_RUNTIME_CONTRACT.sessionId,
|
|
41
|
+
sessionKey: AUTH_PROFILE_RUNTIME_CONTRACT.sessionKey,
|
|
42
|
+
sessionFile,
|
|
43
|
+
workspaceDir,
|
|
44
|
+
runId: AUTH_PROFILE_RUNTIME_CONTRACT.runId,
|
|
45
|
+
provider: AUTH_PROFILE_RUNTIME_CONTRACT.codexHarnessProvider,
|
|
46
|
+
modelId: "gpt-5.4-codex",
|
|
47
|
+
model: createCodexTestModel(AUTH_PROFILE_RUNTIME_CONTRACT.codexHarnessProvider),
|
|
48
|
+
thinkLevel: "medium",
|
|
49
|
+
disableTools: true,
|
|
50
|
+
timeoutMs: 5_000,
|
|
51
|
+
authStorage: {} as never,
|
|
52
|
+
authProfileStore: { version: 1, profiles: {} },
|
|
53
|
+
modelRegistry: {} as never,
|
|
54
|
+
} as EmbeddedRunAttemptParams;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function threadStartResult(threadId = "thread-auth-contract") {
|
|
58
|
+
return {
|
|
59
|
+
thread: {
|
|
60
|
+
id: threadId,
|
|
61
|
+
sessionId: "session-1",
|
|
62
|
+
forkedFromId: null,
|
|
63
|
+
preview: "",
|
|
64
|
+
ephemeral: false,
|
|
65
|
+
modelProvider: "openai",
|
|
66
|
+
createdAt: 1,
|
|
67
|
+
updatedAt: 1,
|
|
68
|
+
status: { type: "idle" },
|
|
69
|
+
path: null,
|
|
70
|
+
cwd: "",
|
|
71
|
+
cliVersion: "0.125.0",
|
|
72
|
+
source: "unknown",
|
|
73
|
+
agentNickname: null,
|
|
74
|
+
agentRole: null,
|
|
75
|
+
gitInfo: null,
|
|
76
|
+
name: null,
|
|
77
|
+
turns: [],
|
|
78
|
+
},
|
|
79
|
+
model: "gpt-5.4-codex",
|
|
80
|
+
modelProvider: "openai",
|
|
81
|
+
serviceTier: null,
|
|
82
|
+
cwd: "",
|
|
83
|
+
instructionSources: [],
|
|
84
|
+
approvalPolicy: "never",
|
|
85
|
+
approvalsReviewer: "user",
|
|
86
|
+
sandbox: { type: "dangerFullAccess" },
|
|
87
|
+
permissionProfile: null,
|
|
88
|
+
reasoningEffort: null,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function turnStartResult(turnId = "turn-auth-contract") {
|
|
93
|
+
return {
|
|
94
|
+
turn: {
|
|
95
|
+
id: turnId,
|
|
96
|
+
status: "inProgress",
|
|
97
|
+
items: [],
|
|
98
|
+
error: null,
|
|
99
|
+
startedAt: null,
|
|
100
|
+
completedAt: null,
|
|
101
|
+
durationMs: null,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function createCodexAuthProfileHarness(params: { startMethod: "thread/start" | "thread/resume" }) {
|
|
107
|
+
const seenAuthProfileIds: Array<string | undefined> = [];
|
|
108
|
+
const seenAgentDirs: Array<string | undefined> = [];
|
|
109
|
+
const requests: Array<{ method: string; params: unknown }> = [];
|
|
110
|
+
let notify: (notification: unknown) => Promise<void> = async () => undefined;
|
|
111
|
+
setCodexAppServerClientFactoryForTest(async (_startOptions, authProfileId, agentDir) => {
|
|
112
|
+
seenAuthProfileIds.push(authProfileId);
|
|
113
|
+
seenAgentDirs.push(agentDir);
|
|
114
|
+
return {
|
|
115
|
+
request: vi.fn(async (method: string, requestParams?: unknown) => {
|
|
116
|
+
requests.push({ method, params: requestParams });
|
|
117
|
+
if (method === params.startMethod) {
|
|
118
|
+
return threadStartResult();
|
|
119
|
+
}
|
|
120
|
+
if (method === "turn/start") {
|
|
121
|
+
return turnStartResult();
|
|
122
|
+
}
|
|
123
|
+
throw new Error(`unexpected method: ${method}`);
|
|
124
|
+
}),
|
|
125
|
+
addNotificationHandler: (handler: (notification: unknown) => Promise<void>) => {
|
|
126
|
+
notify = handler;
|
|
127
|
+
return () => undefined;
|
|
128
|
+
},
|
|
129
|
+
addRequestHandler: () => () => undefined,
|
|
130
|
+
} as never;
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
seenAuthProfileIds,
|
|
134
|
+
seenAgentDirs,
|
|
135
|
+
async waitForMethod(method: string) {
|
|
136
|
+
await vi.waitFor(() => expect(requests.map((entry) => entry.method)).toContain(method), {
|
|
137
|
+
interval: 1,
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
async completeTurn() {
|
|
141
|
+
await notify({
|
|
142
|
+
method: "turn/completed",
|
|
143
|
+
params: {
|
|
144
|
+
threadId: "thread-auth-contract",
|
|
145
|
+
turnId: "turn-auth-contract",
|
|
146
|
+
turn: { id: "turn-auth-contract", status: "completed" },
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
describe("Auth profile runtime contract - Codex app-server adapter", () => {
|
|
154
|
+
let tmpDir: string;
|
|
155
|
+
|
|
156
|
+
beforeEach(async () => {
|
|
157
|
+
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "klaw-codex-auth-contract-"));
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
afterEach(async () => {
|
|
161
|
+
abortAgentHarnessRun(AUTH_PROFILE_RUNTIME_CONTRACT.sessionId);
|
|
162
|
+
resetCodexAppServerClientFactoryForTest();
|
|
163
|
+
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("passes the exact OpenAI Codex auth profile into app-server startup", async () => {
|
|
167
|
+
const harness = createCodexAuthProfileHarness({ startMethod: "thread/start" });
|
|
168
|
+
const sessionFile = path.join(tmpDir, "session.jsonl");
|
|
169
|
+
const params = createParams(sessionFile, tmpDir);
|
|
170
|
+
params.authProfileId = AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId;
|
|
171
|
+
params.agentDir = tmpDir;
|
|
172
|
+
|
|
173
|
+
const run = runCodexAppServerAttempt(params);
|
|
174
|
+
await vi.waitFor(
|
|
175
|
+
() =>
|
|
176
|
+
expect(harness.seenAuthProfileIds).toEqual([
|
|
177
|
+
AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
|
|
178
|
+
]),
|
|
179
|
+
{ interval: 1 },
|
|
180
|
+
);
|
|
181
|
+
expect(harness.seenAgentDirs).toEqual([tmpDir]);
|
|
182
|
+
await harness.waitForMethod("turn/start");
|
|
183
|
+
await harness.completeTurn();
|
|
184
|
+
await run;
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("reuses a bound OpenAI Codex auth profile when resume params omit authProfileId", async () => {
|
|
188
|
+
const harness = createCodexAuthProfileHarness({ startMethod: "thread/resume" });
|
|
189
|
+
const sessionFile = path.join(tmpDir, "session.jsonl");
|
|
190
|
+
await writeCodexAppServerBinding(sessionFile, {
|
|
191
|
+
threadId: "thread-auth-contract",
|
|
192
|
+
cwd: tmpDir,
|
|
193
|
+
authProfileId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
|
|
194
|
+
dynamicToolsFingerprint: "[]",
|
|
195
|
+
});
|
|
196
|
+
// authProfileId is intentionally omitted to exercise the resume-bound profile path.
|
|
197
|
+
const params = createParams(sessionFile, tmpDir);
|
|
198
|
+
|
|
199
|
+
const run = runCodexAppServerAttempt(params);
|
|
200
|
+
await vi.waitFor(
|
|
201
|
+
() =>
|
|
202
|
+
expect(harness.seenAuthProfileIds).toEqual([
|
|
203
|
+
AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
|
|
204
|
+
]),
|
|
205
|
+
{ interval: 1 },
|
|
206
|
+
);
|
|
207
|
+
await harness.waitForMethod("turn/start");
|
|
208
|
+
await harness.completeTurn();
|
|
209
|
+
await run;
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("prefers an explicit runtime auth profile over a stale persisted binding", async () => {
|
|
213
|
+
const harness = createCodexAuthProfileHarness({ startMethod: "thread/resume" });
|
|
214
|
+
const sessionFile = path.join(tmpDir, "session.jsonl");
|
|
215
|
+
await writeCodexAppServerBinding(sessionFile, {
|
|
216
|
+
threadId: "thread-auth-contract",
|
|
217
|
+
cwd: tmpDir,
|
|
218
|
+
authProfileId: "openai-codex:stale",
|
|
219
|
+
dynamicToolsFingerprint: "[]",
|
|
220
|
+
});
|
|
221
|
+
const params = createParams(sessionFile, tmpDir);
|
|
222
|
+
params.authProfileId = AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId;
|
|
223
|
+
|
|
224
|
+
const run = runCodexAppServerAttempt(params);
|
|
225
|
+
await vi.waitFor(
|
|
226
|
+
() =>
|
|
227
|
+
expect(harness.seenAuthProfileIds).toEqual([
|
|
228
|
+
AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
|
|
229
|
+
]),
|
|
230
|
+
{ interval: 1 },
|
|
231
|
+
);
|
|
232
|
+
await harness.waitForMethod("turn/start");
|
|
233
|
+
await harness.completeTurn();
|
|
234
|
+
await run;
|
|
235
|
+
|
|
236
|
+
const binding = await readCodexAppServerBinding(sessionFile);
|
|
237
|
+
expect(binding?.authProfileId).toBe(AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CodexAppServerRpcError } from "./client.js";
|
|
2
|
+
|
|
3
|
+
export const CODEX_CONTROL_METHODS = {
|
|
4
|
+
account: "account/read",
|
|
5
|
+
compact: "thread/compact/start",
|
|
6
|
+
feedback: "feedback/upload",
|
|
7
|
+
listMcpServers: "mcpServerStatus/list",
|
|
8
|
+
listSkills: "skills/list",
|
|
9
|
+
listThreads: "thread/list",
|
|
10
|
+
rateLimits: "account/rateLimits/read",
|
|
11
|
+
resumeThread: "thread/resume",
|
|
12
|
+
review: "review/start",
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
type CodexControlName = keyof typeof CODEX_CONTROL_METHODS;
|
|
16
|
+
export type CodexControlMethod = (typeof CODEX_CONTROL_METHODS)[CodexControlName];
|
|
17
|
+
|
|
18
|
+
export function describeControlFailure(error: unknown): string {
|
|
19
|
+
if (isUnsupportedControlError(error)) {
|
|
20
|
+
return "unsupported by this Codex app-server";
|
|
21
|
+
}
|
|
22
|
+
return error instanceof Error ? error.message : String(error);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isUnsupportedControlError(error: unknown): error is CodexAppServerRpcError {
|
|
26
|
+
return error instanceof CodexAppServerRpcError && error.code === -32601;
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { resolveCodexAppServerAuthProfileIdForAgent } from "./auth-bridge.js";
|
|
2
|
+
import type { CodexAppServerClient } from "./client.js";
|
|
3
|
+
import type { CodexAppServerStartOptions } from "./config.js";
|
|
4
|
+
|
|
5
|
+
type AuthProfileOrderConfig = Parameters<
|
|
6
|
+
typeof resolveCodexAppServerAuthProfileIdForAgent
|
|
7
|
+
>[0]["config"];
|
|
8
|
+
|
|
9
|
+
export type CodexAppServerClientFactory = (
|
|
10
|
+
startOptions?: CodexAppServerStartOptions,
|
|
11
|
+
authProfileId?: string,
|
|
12
|
+
agentDir?: string,
|
|
13
|
+
config?: AuthProfileOrderConfig,
|
|
14
|
+
) => Promise<CodexAppServerClient>;
|
|
15
|
+
|
|
16
|
+
export const defaultCodexAppServerClientFactory: CodexAppServerClientFactory = (
|
|
17
|
+
startOptions,
|
|
18
|
+
authProfileId,
|
|
19
|
+
agentDir,
|
|
20
|
+
config,
|
|
21
|
+
) =>
|
|
22
|
+
import("./shared-client.js").then(({ getSharedCodexAppServerClient }) =>
|
|
23
|
+
getSharedCodexAppServerClient({ startOptions, authProfileId, agentDir, config }),
|
|
24
|
+
);
|