@openclaw/codex 2026.6.11 → 2026.7.1-1
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/{app-server-policy-BPTiVNsW.js → app-server-policy-C968Kgin.js} +5 -5
- package/dist/{attempt-notifications-BYnndyFl.js → attempt-notifications-BGsEIIDI.js} +29 -40
- package/dist/{command-handlers-DEPTJYk0.js → command-handlers-Dv-pzAmg.js} +278 -237
- package/dist/command-rpc-eLM_mtC7.js +784 -0
- package/dist/compact-4mVBriKT.js +603 -0
- package/dist/{computer-use-ClrJwoFp.js → computer-use-Bmaz333N.js} +3 -3
- package/dist/{config-CszD0vP3.js → config-CYEDnLJ2.js} +44 -18
- package/dist/conversation-binding-data-BHRpYbX3.js +121 -0
- package/dist/doctor-contract-api.js +590 -22
- package/dist/harness.js +29 -10
- package/dist/index.js +1134 -35
- package/dist/{media-understanding-provider-ZUQHN7gT.js → media-understanding-provider-BHOu9-Gg.js} +13 -8
- package/dist/media-understanding-provider.js +1 -1
- package/dist/{models-CAmfBWRl.js → models-DDmO1zwd.js} +2 -2
- package/dist/notification-correlation-Bo7KB3ks.js +35 -0
- package/dist/{plugin-app-cache-key-C9ILt7bl.js → plugin-app-cache-key-BrhVdeEf.js} +13 -5
- package/dist/{protocol-dh-ETiNd.js → protocol-2POPqAY4.js} +2 -1
- package/dist/{protocol-validators-B19q5BIX.js → protocol-validators-dZQ-UTOa.js} +205 -56
- package/dist/provider-capabilities-DzI8fgEu.js +6172 -0
- package/dist/provider-catalog.js +4 -2
- package/dist/{provider-B-OHpbD3.js → provider-zjPfx5Fs.js} +94 -23
- package/dist/provider.js +2 -2
- package/dist/{request-Dcd452Nk.js → request-BcJyl8KL.js} +2 -2
- package/dist/{run-attempt-CXxtFC9d.js → run-attempt-DNSNk_G8.js} +1250 -2992
- package/dist/{sandbox-guard-3tnjhjFb.js → sandbox-guard-DA2TQfZW.js} +5 -3
- package/dist/session-binding-C1ZXdP-x.js +627 -0
- package/dist/session-binding-meta-B7aEMU7g.js +6 -0
- package/dist/shared-client-4ICy3U6d.js +1853 -0
- package/dist/{side-question-C-DhgJOd.js → side-question-CMOpEhvY.js} +134 -142
- package/dist/{thread-lifecycle-DtT3-ehU.js → thread-lifecycle-qWE88Dn2.js} +803 -481
- package/dist/{web-search-provider.runtime-CkwxrXQj.js → web-search-provider.runtime-BSlriav6.js} +3 -3
- package/npm-shrinkwrap.json +34 -34
- package/openclaw.plugin.json +23 -3
- package/package.json +9 -6
- package/dist/client-CLrtWgrD.js +0 -729
- package/dist/client-factory-Bm6HsGob.js +0 -18
- package/dist/compact-aQJ0ZKhe.js +0 -278
- package/dist/conversation-binding-t0XMLz-j.js +0 -1557
- package/dist/provider-capabilities-D7hnTO76.js +0 -3201
- package/dist/rate-limit-cache-C7qmZ0Jh.js +0 -26
- package/dist/session-binding-HOuPt-E0.js +0 -338
- package/dist/shared-client-Dtx5i7Ez.js +0 -1013
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//#region extensions/codex/src/app-server/rate-limit-cache.ts
|
|
2
|
-
const DEFAULT_CODEX_RATE_LIMIT_CACHE_MAX_AGE_MS = 10 * 6e4;
|
|
3
|
-
const CODEX_RATE_LIMIT_CACHE_STATE = Symbol.for("openclaw.codexRateLimitCacheState");
|
|
4
|
-
function getCodexRateLimitCacheState() {
|
|
5
|
-
const globalState = globalThis;
|
|
6
|
-
globalState[CODEX_RATE_LIMIT_CACHE_STATE] ??= {};
|
|
7
|
-
return globalState[CODEX_RATE_LIMIT_CACHE_STATE];
|
|
8
|
-
}
|
|
9
|
-
/** Stores a non-empty Codex rate-limit payload with its observation time. */
|
|
10
|
-
function rememberCodexRateLimits(value, nowMs = Date.now()) {
|
|
11
|
-
if (value === void 0) return;
|
|
12
|
-
const state = getCodexRateLimitCacheState();
|
|
13
|
-
state.value = value;
|
|
14
|
-
state.updatedAtMs = nowMs;
|
|
15
|
-
}
|
|
16
|
-
/** Reads the cached Codex rate-limit payload when it is still within the max-age window. */
|
|
17
|
-
function readRecentCodexRateLimits(options) {
|
|
18
|
-
const state = getCodexRateLimitCacheState();
|
|
19
|
-
if (state.value === void 0 || state.updatedAtMs === void 0) return;
|
|
20
|
-
const nowMs = options?.nowMs ?? Date.now();
|
|
21
|
-
const maxAgeMs = options?.maxAgeMs ?? DEFAULT_CODEX_RATE_LIMIT_CACHE_MAX_AGE_MS;
|
|
22
|
-
if (maxAgeMs >= 0 && nowMs - state.updatedAtMs > maxAgeMs) return;
|
|
23
|
-
return state.value;
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
export { rememberCodexRateLimits as n, readRecentCodexRateLimits as t };
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { l as normalizeCodexServiceTier } from "./config-CszD0vP3.js";
|
|
3
|
-
import fs from "node:fs/promises";
|
|
4
|
-
import { ensureAuthProfileStore, resolveDefaultAgentDir, resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
|
|
5
|
-
import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
6
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
|
-
import { withFileLock } from "openclaw/plugin-sdk/file-lock";
|
|
8
|
-
//#region extensions/codex/src/app-server/session-binding.ts
|
|
9
|
-
/**
|
|
10
|
-
* Persists and normalizes the Codex app-server thread binding associated with
|
|
11
|
-
* an OpenClaw session file.
|
|
12
|
-
*/
|
|
13
|
-
var session_binding_exports = /* @__PURE__ */ __exportAll({
|
|
14
|
-
CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS: () => CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS,
|
|
15
|
-
clearCodexAppServerBinding: () => clearCodexAppServerBinding,
|
|
16
|
-
clearCodexAppServerBindingForThread: () => clearCodexAppServerBindingForThread,
|
|
17
|
-
isCodexAppServerNativeAuthProfile: () => isCodexAppServerNativeAuthProfile,
|
|
18
|
-
normalizeCodexAppServerBindingModelProvider: () => normalizeCodexAppServerBindingModelProvider,
|
|
19
|
-
readCodexAppServerBinding: () => readCodexAppServerBinding,
|
|
20
|
-
resolveCodexAppServerBindingPath: () => resolveCodexAppServerBindingPath,
|
|
21
|
-
withCodexAppServerBindingLock: () => withCodexAppServerBindingLock,
|
|
22
|
-
writeCodexAppServerBinding: () => writeCodexAppServerBinding
|
|
23
|
-
});
|
|
24
|
-
const CODEX_APP_SERVER_NATIVE_AUTH_PROVIDER = "openai";
|
|
25
|
-
const PUBLIC_OPENAI_MODEL_PROVIDER = "openai";
|
|
26
|
-
const CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS = 6e4;
|
|
27
|
-
const CODEX_APP_SERVER_BINDING_LOCK_RETRY_INTERVAL_MS = 1e3;
|
|
28
|
-
const CODEX_APP_SERVER_BINDING_LOCK_OPTIONS = {
|
|
29
|
-
retries: {
|
|
30
|
-
retries: Math.ceil(75e3 / CODEX_APP_SERVER_BINDING_LOCK_RETRY_INTERVAL_MS),
|
|
31
|
-
factor: 1,
|
|
32
|
-
minTimeout: CODEX_APP_SERVER_BINDING_LOCK_RETRY_INTERVAL_MS,
|
|
33
|
-
maxTimeout: CODEX_APP_SERVER_BINDING_LOCK_RETRY_INTERVAL_MS
|
|
34
|
-
},
|
|
35
|
-
stale: CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS * 2
|
|
36
|
-
};
|
|
37
|
-
const bindingMutationQueues = /* @__PURE__ */ new Map();
|
|
38
|
-
const bindingMutationContext = new AsyncLocalStorage();
|
|
39
|
-
/** Returns the JSON sidecar path for the Codex app-server binding beside a session file. */
|
|
40
|
-
function resolveCodexAppServerBindingPath(sessionFile) {
|
|
41
|
-
return `${sessionFile}.codex-app-server.json`;
|
|
42
|
-
}
|
|
43
|
-
/** Serializes mutation of the Codex app-server binding sidecar for a session file. */
|
|
44
|
-
async function withCodexAppServerBindingLock(sessionFile, run) {
|
|
45
|
-
const bindingPath = resolveCodexAppServerBindingPath(sessionFile);
|
|
46
|
-
const ownedBindings = bindingMutationContext.getStore();
|
|
47
|
-
if (ownedBindings?.has(bindingPath)) return await withFileLock(bindingPath, CODEX_APP_SERVER_BINDING_LOCK_OPTIONS, run);
|
|
48
|
-
const previous = bindingMutationQueues.get(bindingPath) ?? Promise.resolve();
|
|
49
|
-
let releaseCurrent;
|
|
50
|
-
const current = new Promise((resolve) => {
|
|
51
|
-
releaseCurrent = resolve;
|
|
52
|
-
});
|
|
53
|
-
const queued = previous.then(() => current, () => current);
|
|
54
|
-
bindingMutationQueues.set(bindingPath, queued);
|
|
55
|
-
await previous.catch(() => void 0);
|
|
56
|
-
const nestedOwnedBindings = new Set(ownedBindings);
|
|
57
|
-
nestedOwnedBindings.add(bindingPath);
|
|
58
|
-
try {
|
|
59
|
-
return await bindingMutationContext.run(nestedOwnedBindings, () => withFileLock(bindingPath, CODEX_APP_SERVER_BINDING_LOCK_OPTIONS, run));
|
|
60
|
-
} finally {
|
|
61
|
-
releaseCurrent();
|
|
62
|
-
if (bindingMutationQueues.get(bindingPath) === queued) bindingMutationQueues.delete(bindingPath);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/** Reads and normalizes a Codex app-server binding sidecar, returning undefined on stale data. */
|
|
66
|
-
async function readCodexAppServerBinding(sessionFile, lookup = {}) {
|
|
67
|
-
const path = resolveCodexAppServerBindingPath(sessionFile);
|
|
68
|
-
let raw;
|
|
69
|
-
try {
|
|
70
|
-
raw = await fs.readFile(path, "utf8");
|
|
71
|
-
} catch (error) {
|
|
72
|
-
if (isNotFound(error)) return;
|
|
73
|
-
embeddedAgentLog.warn("failed to read codex app-server binding", {
|
|
74
|
-
path,
|
|
75
|
-
error
|
|
76
|
-
});
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
const parsed = JSON.parse(raw);
|
|
81
|
-
const schemaVersion = parsed.schemaVersion === 1 || parsed.schemaVersion === 2 ? parsed.schemaVersion : void 0;
|
|
82
|
-
if (schemaVersion === void 0 || typeof parsed.threadId !== "string") return;
|
|
83
|
-
const authProfileId = typeof parsed.authProfileId === "string" ? parsed.authProfileId : void 0;
|
|
84
|
-
return {
|
|
85
|
-
schemaVersion: 2,
|
|
86
|
-
threadId: parsed.threadId,
|
|
87
|
-
sessionFile,
|
|
88
|
-
cwd: typeof parsed.cwd === "string" ? parsed.cwd : "",
|
|
89
|
-
authProfileId,
|
|
90
|
-
model: typeof parsed.model === "string" ? parsed.model : void 0,
|
|
91
|
-
modelProvider: normalizeCodexAppServerBindingModelProvider({
|
|
92
|
-
...lookup,
|
|
93
|
-
authProfileId,
|
|
94
|
-
modelProvider: typeof parsed.modelProvider === "string" ? parsed.modelProvider : void 0
|
|
95
|
-
}),
|
|
96
|
-
approvalPolicy: readApprovalPolicy(parsed.approvalPolicy),
|
|
97
|
-
sandbox: readSandboxMode(parsed.sandbox),
|
|
98
|
-
serviceTier: readServiceTier(parsed.serviceTier),
|
|
99
|
-
networkProxyProfileName: typeof parsed.networkProxyProfileName === "string" ? parsed.networkProxyProfileName : void 0,
|
|
100
|
-
networkProxyConfigFingerprint: typeof parsed.networkProxyConfigFingerprint === "string" ? parsed.networkProxyConfigFingerprint : void 0,
|
|
101
|
-
dynamicToolsFingerprint: typeof parsed.dynamicToolsFingerprint === "string" ? parsed.dynamicToolsFingerprint : void 0,
|
|
102
|
-
dynamicToolsContainDeferred: typeof parsed.dynamicToolsContainDeferred === "boolean" ? parsed.dynamicToolsContainDeferred : void 0,
|
|
103
|
-
webSearchThreadConfigFingerprint: typeof parsed.webSearchThreadConfigFingerprint === "string" ? parsed.webSearchThreadConfigFingerprint : void 0,
|
|
104
|
-
userMcpServersFingerprint: typeof parsed.userMcpServersFingerprint === "string" ? parsed.userMcpServersFingerprint : void 0,
|
|
105
|
-
mcpServersFingerprint: typeof parsed.mcpServersFingerprint === "string" ? parsed.mcpServersFingerprint : void 0,
|
|
106
|
-
nativeHookRelayGeneration: typeof parsed.nativeHookRelayGeneration === "string" && parsed.nativeHookRelayGeneration.trim() ? parsed.nativeHookRelayGeneration : void 0,
|
|
107
|
-
appServerRuntimeFingerprint: typeof parsed.appServerRuntimeFingerprint === "string" && parsed.appServerRuntimeFingerprint.trim() ? parsed.appServerRuntimeFingerprint : void 0,
|
|
108
|
-
pluginAppsFingerprint: typeof parsed.pluginAppsFingerprint === "string" ? parsed.pluginAppsFingerprint : void 0,
|
|
109
|
-
pluginAppsInputFingerprint: typeof parsed.pluginAppsInputFingerprint === "string" ? parsed.pluginAppsInputFingerprint : void 0,
|
|
110
|
-
pluginAppPolicyContext: readPluginAppPolicyContext(parsed.pluginAppPolicyContext, schemaVersion),
|
|
111
|
-
contextEngine: readContextEngineBinding(parsed.contextEngine),
|
|
112
|
-
environmentSelectionFingerprint: typeof parsed.environmentSelectionFingerprint === "string" ? parsed.environmentSelectionFingerprint : void 0,
|
|
113
|
-
createdAt: typeof parsed.createdAt === "string" ? parsed.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
114
|
-
updatedAt: typeof parsed.updatedAt === "string" ? parsed.updatedAt : (/* @__PURE__ */ new Date()).toISOString()
|
|
115
|
-
};
|
|
116
|
-
} catch (error) {
|
|
117
|
-
embeddedAgentLog.warn("failed to parse codex app-server binding", {
|
|
118
|
-
path,
|
|
119
|
-
error
|
|
120
|
-
});
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/** Writes the Codex app-server binding sidecar with normalized provider/auth metadata. */
|
|
125
|
-
async function writeCodexAppServerBinding(sessionFile, binding, lookup = {}) {
|
|
126
|
-
await withCodexAppServerBindingLock(sessionFile, async () => {
|
|
127
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
128
|
-
const payload = {
|
|
129
|
-
schemaVersion: 2,
|
|
130
|
-
sessionFile,
|
|
131
|
-
threadId: binding.threadId,
|
|
132
|
-
cwd: binding.cwd,
|
|
133
|
-
authProfileId: binding.authProfileId,
|
|
134
|
-
model: binding.model,
|
|
135
|
-
modelProvider: normalizeCodexAppServerBindingModelProvider({
|
|
136
|
-
...lookup,
|
|
137
|
-
authProfileId: binding.authProfileId,
|
|
138
|
-
modelProvider: binding.modelProvider
|
|
139
|
-
}),
|
|
140
|
-
approvalPolicy: binding.approvalPolicy,
|
|
141
|
-
sandbox: binding.sandbox,
|
|
142
|
-
serviceTier: binding.serviceTier,
|
|
143
|
-
networkProxyProfileName: binding.networkProxyProfileName,
|
|
144
|
-
networkProxyConfigFingerprint: binding.networkProxyConfigFingerprint,
|
|
145
|
-
dynamicToolsFingerprint: binding.dynamicToolsFingerprint,
|
|
146
|
-
dynamicToolsContainDeferred: binding.dynamicToolsContainDeferred,
|
|
147
|
-
webSearchThreadConfigFingerprint: binding.webSearchThreadConfigFingerprint,
|
|
148
|
-
userMcpServersFingerprint: binding.userMcpServersFingerprint,
|
|
149
|
-
mcpServersFingerprint: binding.mcpServersFingerprint,
|
|
150
|
-
nativeHookRelayGeneration: binding.nativeHookRelayGeneration,
|
|
151
|
-
appServerRuntimeFingerprint: binding.appServerRuntimeFingerprint,
|
|
152
|
-
pluginAppsFingerprint: binding.pluginAppsFingerprint,
|
|
153
|
-
pluginAppsInputFingerprint: binding.pluginAppsInputFingerprint,
|
|
154
|
-
pluginAppPolicyContext: binding.pluginAppPolicyContext,
|
|
155
|
-
contextEngine: binding.contextEngine,
|
|
156
|
-
environmentSelectionFingerprint: binding.environmentSelectionFingerprint,
|
|
157
|
-
createdAt: binding.createdAt ?? now,
|
|
158
|
-
updatedAt: now
|
|
159
|
-
};
|
|
160
|
-
await fs.writeFile(resolveCodexAppServerBindingPath(sessionFile), `${JSON.stringify(payload, null, 2)}\n`);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function readContextEngineBinding(value) {
|
|
164
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
165
|
-
const record = value;
|
|
166
|
-
if (record.schemaVersion !== 1 || typeof record.engineId !== "string" || typeof record.policyFingerprint !== "string") return;
|
|
167
|
-
return {
|
|
168
|
-
schemaVersion: 1,
|
|
169
|
-
engineId: record.engineId,
|
|
170
|
-
policyFingerprint: record.policyFingerprint,
|
|
171
|
-
projection: readContextEngineProjectionBinding(record.projection)
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
function readContextEngineProjectionBinding(value) {
|
|
175
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
176
|
-
const record = value;
|
|
177
|
-
if (record.schemaVersion !== 1 || record.mode !== "thread_bootstrap" || typeof record.epoch !== "string" || !record.epoch.trim()) return;
|
|
178
|
-
return {
|
|
179
|
-
schemaVersion: 1,
|
|
180
|
-
mode: "thread_bootstrap",
|
|
181
|
-
epoch: record.epoch,
|
|
182
|
-
fingerprint: typeof record.fingerprint === "string" ? record.fingerprint : void 0
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
function readPluginAppPolicyContext(value, bindingSchemaVersion) {
|
|
186
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
187
|
-
const record = value;
|
|
188
|
-
if (typeof record.fingerprint !== "string") return;
|
|
189
|
-
const apps = record.apps;
|
|
190
|
-
if (!apps || typeof apps !== "object" || Array.isArray(apps)) return;
|
|
191
|
-
const parsedApps = {};
|
|
192
|
-
for (const [appId, rawEntry] of Object.entries(apps)) {
|
|
193
|
-
if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) return;
|
|
194
|
-
const entry = rawEntry;
|
|
195
|
-
const destructiveApprovalMode = readDestructiveApprovalMode(entry.destructiveApprovalMode, bindingSchemaVersion);
|
|
196
|
-
if ("appId" in entry || typeof entry.configKey !== "string" || entry.marketplaceName !== "openai-curated" || typeof entry.pluginName !== "string" || typeof entry.allowDestructiveActions !== "boolean" || destructiveApprovalMode === "invalid" || !Array.isArray(entry.mcpServerNames) || entry.mcpServerNames.some((serverName) => typeof serverName !== "string")) return;
|
|
197
|
-
parsedApps[appId] = {
|
|
198
|
-
configKey: entry.configKey,
|
|
199
|
-
marketplaceName: entry.marketplaceName,
|
|
200
|
-
pluginName: entry.pluginName,
|
|
201
|
-
allowDestructiveActions: entry.allowDestructiveActions,
|
|
202
|
-
...destructiveApprovalMode ? { destructiveApprovalMode } : {},
|
|
203
|
-
mcpServerNames: entry.mcpServerNames
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
const parsedPluginAppIds = {};
|
|
207
|
-
const rawPluginAppIds = record.pluginAppIds;
|
|
208
|
-
if (rawPluginAppIds && (typeof rawPluginAppIds !== "object" || Array.isArray(rawPluginAppIds))) return;
|
|
209
|
-
if (rawPluginAppIds && typeof rawPluginAppIds === "object") for (const [configKey, appIds] of Object.entries(rawPluginAppIds)) {
|
|
210
|
-
if (!Array.isArray(appIds) || appIds.some((appId) => typeof appId !== "string")) return;
|
|
211
|
-
parsedPluginAppIds[configKey] = appIds;
|
|
212
|
-
}
|
|
213
|
-
return {
|
|
214
|
-
fingerprint: record.fingerprint,
|
|
215
|
-
apps: parsedApps,
|
|
216
|
-
pluginAppIds: parsedPluginAppIds
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
function readDestructiveApprovalMode(value, bindingSchemaVersion) {
|
|
220
|
-
if (value === void 0) return;
|
|
221
|
-
if (value === "deny") return "deny";
|
|
222
|
-
if (value === "allow") return "allow";
|
|
223
|
-
if (value === "auto") return bindingSchemaVersion === 1 ? "allow" : "auto";
|
|
224
|
-
if (value === "on-request" && bindingSchemaVersion === 1) return "auto";
|
|
225
|
-
return "invalid";
|
|
226
|
-
}
|
|
227
|
-
/** Removes the Codex app-server binding sidecar if present. */
|
|
228
|
-
async function clearCodexAppServerBinding(sessionFile, _lookup = {}) {
|
|
229
|
-
if (!await codexAppServerBindingSidecarExists(sessionFile)) return;
|
|
230
|
-
await withCodexAppServerBindingLock(sessionFile, async () => {
|
|
231
|
-
await unlinkCodexAppServerBinding(sessionFile);
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
async function codexAppServerBindingSidecarExists(sessionFile) {
|
|
235
|
-
try {
|
|
236
|
-
await fs.access(resolveCodexAppServerBindingPath(sessionFile));
|
|
237
|
-
return true;
|
|
238
|
-
} catch (error) {
|
|
239
|
-
if (!isNotFound(error)) embeddedAgentLog.warn("failed to inspect codex app-server binding", {
|
|
240
|
-
sessionFile,
|
|
241
|
-
error
|
|
242
|
-
});
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
async function unlinkCodexAppServerBinding(sessionFile) {
|
|
247
|
-
try {
|
|
248
|
-
await fs.unlink(resolveCodexAppServerBindingPath(sessionFile));
|
|
249
|
-
return true;
|
|
250
|
-
} catch (error) {
|
|
251
|
-
if (!isNotFound(error)) embeddedAgentLog.warn("failed to clear codex app-server binding", {
|
|
252
|
-
sessionFile,
|
|
253
|
-
error
|
|
254
|
-
});
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
/** Clears a binding only when it still points at the expected Codex thread id. */
|
|
259
|
-
async function clearCodexAppServerBindingForThread(sessionFile, threadId, lookup = {}) {
|
|
260
|
-
if (!await readCodexAppServerBinding(sessionFile, lookup)) return false;
|
|
261
|
-
return await withCodexAppServerBindingLock(sessionFile, async () => {
|
|
262
|
-
const binding = await readCodexAppServerBinding(sessionFile, lookup);
|
|
263
|
-
if (!binding) return false;
|
|
264
|
-
if (binding.threadId !== threadId) {
|
|
265
|
-
embeddedAgentLog.debug("codex app-server binding points at a different thread; preserving", {
|
|
266
|
-
sessionFile,
|
|
267
|
-
threadId,
|
|
268
|
-
boundThreadId: binding.threadId
|
|
269
|
-
});
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
return await unlinkCodexAppServerBinding(sessionFile);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
function isNotFound(error) {
|
|
276
|
-
return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
|
|
277
|
-
}
|
|
278
|
-
/** Returns true when an auth profile uses native Codex/OpenAI app-server auth. */
|
|
279
|
-
function isCodexAppServerNativeAuthProfile(lookup) {
|
|
280
|
-
const authProfileId = lookup.authProfileId?.trim();
|
|
281
|
-
if (!authProfileId) return false;
|
|
282
|
-
try {
|
|
283
|
-
const credential = resolveCodexAppServerAuthProfileCredential({
|
|
284
|
-
...lookup,
|
|
285
|
-
authProfileId
|
|
286
|
-
});
|
|
287
|
-
if (!credential || credential.type === "api_key") return false;
|
|
288
|
-
return isOpenAiAuthProvider({
|
|
289
|
-
provider: credential.provider,
|
|
290
|
-
config: lookup.config
|
|
291
|
-
});
|
|
292
|
-
} catch (error) {
|
|
293
|
-
embeddedAgentLog.debug("failed to resolve codex app-server auth profile provider", {
|
|
294
|
-
authProfileId,
|
|
295
|
-
error
|
|
296
|
-
});
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
/** Hides redundant OpenAI provider attribution for native Codex auth bindings. */
|
|
301
|
-
function normalizeCodexAppServerBindingModelProvider(params) {
|
|
302
|
-
const modelProvider = params.modelProvider?.trim();
|
|
303
|
-
if (!modelProvider) return;
|
|
304
|
-
if (isCodexAppServerNativeAuthProfile(params) && modelProvider.toLowerCase() === PUBLIC_OPENAI_MODEL_PROVIDER) return;
|
|
305
|
-
return modelProvider;
|
|
306
|
-
}
|
|
307
|
-
function resolveCodexAppServerAuthProfileCredential(lookup) {
|
|
308
|
-
const authProfileId = lookup.authProfileId?.trim();
|
|
309
|
-
if (!authProfileId) return;
|
|
310
|
-
return (lookup.authProfileStore ?? loadCodexAppServerAuthProfileStore({
|
|
311
|
-
agentDir: lookup.agentDir,
|
|
312
|
-
authProfileId,
|
|
313
|
-
config: lookup.config
|
|
314
|
-
})).profiles[authProfileId];
|
|
315
|
-
}
|
|
316
|
-
function loadCodexAppServerAuthProfileStore(params) {
|
|
317
|
-
return ensureAuthProfileStore(params.agentDir?.trim() || resolveDefaultAgentDir(params.config ?? {}), {
|
|
318
|
-
allowKeychainPrompt: false,
|
|
319
|
-
config: params.config,
|
|
320
|
-
externalCliProviderIds: [CODEX_APP_SERVER_NATIVE_AUTH_PROVIDER],
|
|
321
|
-
externalCliProfileIds: [params.authProfileId]
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
function isOpenAiAuthProvider(params) {
|
|
325
|
-
const provider = params.provider?.trim();
|
|
326
|
-
return Boolean(provider && resolveProviderIdForAuth(provider, { config: params.config }) === CODEX_APP_SERVER_NATIVE_AUTH_PROVIDER);
|
|
327
|
-
}
|
|
328
|
-
function readApprovalPolicy(value) {
|
|
329
|
-
return value === "never" || value === "on-request" || value === "on-failure" || value === "untrusted" ? value : void 0;
|
|
330
|
-
}
|
|
331
|
-
function readSandboxMode(value) {
|
|
332
|
-
return value === "read-only" || value === "workspace-write" || value === "danger-full-access" ? value : void 0;
|
|
333
|
-
}
|
|
334
|
-
function readServiceTier(value) {
|
|
335
|
-
return normalizeCodexServiceTier(value);
|
|
336
|
-
}
|
|
337
|
-
//#endregion
|
|
338
|
-
export { normalizeCodexAppServerBindingModelProvider as a, withCodexAppServerBindingLock as c, isCodexAppServerNativeAuthProfile as i, writeCodexAppServerBinding as l, clearCodexAppServerBinding as n, readCodexAppServerBinding as o, clearCodexAppServerBindingForThread as r, session_binding_exports as s, CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS as t };
|