@openclaw/codex 2026.5.25-beta.1 → 2026.5.26-beta.2
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-SrtuTTVa.js → client-BVK_jmHW.js} +1 -1
- package/dist/client-factory-fW4Hh9q_.js +15 -0
- package/dist/{command-handlers-CLtPT37L.js → command-handlers-hYTtzAdy.js} +8 -8
- package/dist/{compact-acCua7zr.js → compact-C_1JAB4C.js} +26 -3
- package/dist/{computer-use-CVfE2Vfb.js → computer-use-DSdj1hJY.js} +2 -2
- package/dist/{config-D6TUuyo2.js → config-0-UN67Qg.js} +2 -1
- package/dist/{conversation-binding-B-GevkEb.js → conversation-binding-OjYqDwhw.js} +114 -88
- package/dist/{dynamic-tools-BXAE1U1-.js → dynamic-tools-DlEefKNQ.js} +61 -20
- package/dist/harness.js +5 -5
- package/dist/index.js +10 -9
- package/dist/media-understanding-provider.js +7 -7
- package/dist/{models-CC2IusQs.js → models-_XwpqjR8.js} +5 -4
- package/dist/{notification-correlation-D7tJW3FW.js → notification-correlation-YINts3PA.js} +1 -1
- package/dist/{protocol-validators-_gKDcd0x.js → protocol-validators-DtjYmUw_.js} +188 -441
- package/dist/provider.js +2 -2
- package/dist/{request-BO0z3vA8.js → request-OaxhR46w.js} +5 -4
- package/dist/{run-attempt-BjoI3hUJ.js → run-attempt-D8Vxo-Jm.js} +497 -176
- package/dist/{session-binding-CwNOIDP2.js → session-binding-UFjjws4k.js} +1 -1
- package/dist/{shared-client-CZP1DjaN.js → shared-client-8kIrP817.js} +167 -17
- package/dist/{side-question-Cb4COOQ9.js → side-question-DU7en3_R.js} +12 -11
- package/dist/test-api.js +3 -3
- package/dist/{thread-lifecycle-CXMd9UgJ.js → thread-lifecycle-CUXQezJL.js} +110 -22
- package/dist/{vision-tools-CETeQgze.js → vision-tools-DqpLmF5H.js} +5 -3
- package/npm-shrinkwrap.json +35 -105
- package/package.json +6 -6
- package/dist/client-factory-A7DQkSLq.js +0 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { s as normalizeCodexServiceTier } from "./config-
|
|
2
|
+
import { s as normalizeCodexServiceTier } from "./config-0-UN67Qg.js";
|
|
3
3
|
import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import { ensureAuthProfileStore, resolveDefaultAgentDir, resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { l as resolveCodexAppServerRuntimeOptions, n as codexAppServerStartOptionsKey } from "./config-
|
|
3
|
-
import { c as resolveCodexAppServerSpawnEnv, o as MANAGED_CODEX_APP_SERVER_PACKAGE, t as CodexAppServerClient } from "./client-
|
|
2
|
+
import { l as resolveCodexAppServerRuntimeOptions, n as codexAppServerStartOptionsKey } from "./config-0-UN67Qg.js";
|
|
3
|
+
import { c as resolveCodexAppServerSpawnEnv, o as MANAGED_CODEX_APP_SERVER_PACKAGE, t as CodexAppServerClient } from "./client-BVK_jmHW.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
|
-
import { constants, readFileSync } from "node:fs";
|
|
6
|
+
import fsSync, { constants, readFileSync } from "node:fs";
|
|
7
|
+
import os from "node:os";
|
|
7
8
|
import fs, { access } from "node:fs/promises";
|
|
8
9
|
import path from "node:path";
|
|
9
10
|
import { ensureAuthProfileStore, ensureAuthProfileStoreWithoutExternalProfiles, loadAuthProfileStoreForSecretsRuntime, refreshOAuthCredentialForRuntime, resolveApiKeyForProfile, resolveAuthProfileOrder, resolveDefaultAgentDir, resolvePersistedAuthProfileOwnerAgentDir, resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
|
|
@@ -18,6 +19,8 @@ const HOME_ENV_VAR = "HOME";
|
|
|
18
19
|
const CODEX_APP_SERVER_HOME_DIRNAME = "codex-home";
|
|
19
20
|
const CODEX_APP_SERVER_API_KEY_ENV_VARS = ["CODEX_API_KEY", "OPENAI_API_KEY"];
|
|
20
21
|
const CODEX_APP_SERVER_HOME_ENV_VARS = [CODEX_HOME_ENV_VAR, HOME_ENV_VAR];
|
|
22
|
+
const CODEX_AUTH_JSON_FILENAME = "auth.json";
|
|
23
|
+
const CODEX_HOME_DIRNAME = ".codex";
|
|
21
24
|
async function bridgeCodexAppServerStartOptions(params) {
|
|
22
25
|
if (params.startOptions.transport !== "stdio") return params.startOptions;
|
|
23
26
|
const isolatedStartOptions = await withAgentCodexHomeEnvironment(params.startOptions, params.agentDir);
|
|
@@ -67,6 +70,14 @@ function ensureCodexAppServerAuthProfileStore(params) {
|
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
function resolveCodexAppServerAuthProfileStore(params) {
|
|
73
|
+
if (params.authProfileStore) {
|
|
74
|
+
const providedProfileId = resolveCodexAppServerAuthProfileId({
|
|
75
|
+
authProfileId: params.authProfileId,
|
|
76
|
+
store: params.authProfileStore,
|
|
77
|
+
config: params.config
|
|
78
|
+
});
|
|
79
|
+
if (providedProfileId && params.authProfileStore.profiles[providedProfileId]) return params.authProfileStore;
|
|
80
|
+
}
|
|
70
81
|
const overlaidStore = ensureCodexAppServerAuthProfileStore({
|
|
71
82
|
agentDir: params.agentDir,
|
|
72
83
|
authProfileId: params.authProfileId,
|
|
@@ -132,6 +143,10 @@ function resolveCodexAppServerEnvApiKeyCacheKey(params) {
|
|
|
132
143
|
hash.update(apiKey.value);
|
|
133
144
|
return `${apiKey.key}:sha256:${hash.digest("hex")}`;
|
|
134
145
|
}
|
|
146
|
+
function resolveCodexAppServerFallbackApiKeyCacheKey(params) {
|
|
147
|
+
if (params.startOptions.transport !== "stdio") return;
|
|
148
|
+
return resolveCodexAppServerEnvApiKeyCacheKey(params) ?? resolveCodexCliAuthFileApiKeyCacheKey(params.baseEnv ?? process.env);
|
|
149
|
+
}
|
|
135
150
|
function fingerprintApiKeyAuthProfileCacheKey(apiKey) {
|
|
136
151
|
const hash = createHash("sha256");
|
|
137
152
|
hash.update("openclaw:codex:app-server-auth-profile-api-key:v1");
|
|
@@ -146,6 +161,13 @@ function fingerprintTokenAuthProfileCacheKey(accessToken) {
|
|
|
146
161
|
hash.update(accessToken);
|
|
147
162
|
return `token:sha256:${hash.digest("hex")}`;
|
|
148
163
|
}
|
|
164
|
+
function fingerprintCodexCliAuthFileApiKeyCacheKey(apiKey) {
|
|
165
|
+
const hash = createHash("sha256");
|
|
166
|
+
hash.update("openclaw:codex:app-server-cli-auth-json-api-key:v1");
|
|
167
|
+
hash.update("\0");
|
|
168
|
+
hash.update(apiKey);
|
|
169
|
+
return `CODEX_AUTH_JSON:sha256:${hash.digest("hex")}`;
|
|
170
|
+
}
|
|
149
171
|
function resolveCodexAppServerHomeDir(agentDir) {
|
|
150
172
|
return path.join(path.resolve(agentDir), CODEX_APP_SERVER_HOME_DIRNAME);
|
|
151
173
|
}
|
|
@@ -183,9 +205,10 @@ async function applyCodexAppServerAuthProfile(params) {
|
|
|
183
205
|
if (!loginParams) {
|
|
184
206
|
if (params.startOptions?.transport !== "stdio") return;
|
|
185
207
|
const env = resolveCodexAppServerSpawnEnv(params.startOptions, process.env);
|
|
186
|
-
const fallbackLoginParams = await
|
|
208
|
+
const fallbackLoginParams = await resolveCodexAppServerFallbackApiKeyLoginParams({
|
|
187
209
|
client: params.client,
|
|
188
|
-
env
|
|
210
|
+
env,
|
|
211
|
+
codexCliAuthEnv: process.env
|
|
189
212
|
});
|
|
190
213
|
if (fallbackLoginParams) await params.client.request("account/login/start", fallbackLoginParams);
|
|
191
214
|
return;
|
|
@@ -230,8 +253,8 @@ async function resolveCodexAppServerAuthProfileLoginParamsInternal(params) {
|
|
|
230
253
|
if (!loginParams) throw new Error(`Codex app-server auth profile "${profileId}" does not contain usable credentials.`);
|
|
231
254
|
return loginParams;
|
|
232
255
|
}
|
|
233
|
-
async function
|
|
234
|
-
const apiKey = readFirstNonEmptyEnv(params.env, CODEX_APP_SERVER_API_KEY_ENV_VARS);
|
|
256
|
+
async function resolveCodexAppServerFallbackApiKeyLoginParams(params) {
|
|
257
|
+
const apiKey = readFirstNonEmptyEnv(params.env, CODEX_APP_SERVER_API_KEY_ENV_VARS) ?? await readCodexCliAuthFileApiKey(params.codexCliAuthEnv);
|
|
235
258
|
if (!apiKey) return;
|
|
236
259
|
if ((await params.client.request("account/read", { refreshToken: false })).account) return;
|
|
237
260
|
return {
|
|
@@ -239,6 +262,45 @@ async function resolveCodexAppServerEnvApiKeyLoginParams(params) {
|
|
|
239
262
|
apiKey
|
|
240
263
|
};
|
|
241
264
|
}
|
|
265
|
+
function resolveCodexCliAuthFilePath(env) {
|
|
266
|
+
const configuredCodexHome = env[CODEX_HOME_ENV_VAR]?.trim();
|
|
267
|
+
if (configuredCodexHome) return path.join(resolveHomeRelativePath(configuredCodexHome, env), CODEX_AUTH_JSON_FILENAME);
|
|
268
|
+
const home = env[HOME_ENV_VAR]?.trim() || env.USERPROFILE?.trim() || os.homedir();
|
|
269
|
+
return path.join(home, CODEX_HOME_DIRNAME, CODEX_AUTH_JSON_FILENAME);
|
|
270
|
+
}
|
|
271
|
+
function resolveHomeRelativePath(value, env) {
|
|
272
|
+
if (value === "~" || value.startsWith("~/") || value.startsWith("~\\")) {
|
|
273
|
+
const home = env[HOME_ENV_VAR]?.trim() || env.USERPROFILE?.trim() || os.homedir();
|
|
274
|
+
return path.join(home, value.slice(value === "~" ? 1 : 2));
|
|
275
|
+
}
|
|
276
|
+
return value;
|
|
277
|
+
}
|
|
278
|
+
function parseCodexCliAuthFileApiKey(raw) {
|
|
279
|
+
let parsed;
|
|
280
|
+
try {
|
|
281
|
+
parsed = JSON.parse(raw);
|
|
282
|
+
} catch {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (!parsed || typeof parsed !== "object") return;
|
|
286
|
+
const apiKey = parsed.OPENAI_API_KEY;
|
|
287
|
+
return typeof apiKey === "string" && apiKey.trim() ? apiKey.trim() : void 0;
|
|
288
|
+
}
|
|
289
|
+
async function readCodexCliAuthFileApiKey(env) {
|
|
290
|
+
try {
|
|
291
|
+
return parseCodexCliAuthFileApiKey(await fs.readFile(resolveCodexCliAuthFilePath(env), "utf8"));
|
|
292
|
+
} catch {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function resolveCodexCliAuthFileApiKeyCacheKey(env) {
|
|
297
|
+
try {
|
|
298
|
+
const apiKey = parseCodexCliAuthFileApiKey(fsSync.readFileSync(resolveCodexCliAuthFilePath(env), "utf8"));
|
|
299
|
+
return apiKey ? fingerprintCodexCliAuthFileApiKeyCacheKey(apiKey) : void 0;
|
|
300
|
+
} catch {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
242
304
|
async function resolveLoginParamsForCredential(profileId, credential, params) {
|
|
243
305
|
if (credential.type === "api_key") {
|
|
244
306
|
const apiKey = (await resolveApiKeyForProfile({
|
|
@@ -470,35 +532,77 @@ var shared_client_exports = /* @__PURE__ */ __exportAll({
|
|
|
470
532
|
clearSharedCodexAppServerClientIfCurrent: () => clearSharedCodexAppServerClientIfCurrent,
|
|
471
533
|
clearSharedCodexAppServerClientIfCurrentAndWait: () => clearSharedCodexAppServerClientIfCurrentAndWait,
|
|
472
534
|
createIsolatedCodexAppServerClient: () => createIsolatedCodexAppServerClient,
|
|
473
|
-
|
|
535
|
+
getLeasedSharedCodexAppServerClient: () => getLeasedSharedCodexAppServerClient,
|
|
536
|
+
getSharedCodexAppServerClient: () => getSharedCodexAppServerClient,
|
|
537
|
+
releaseLeasedSharedCodexAppServerClient: () => releaseLeasedSharedCodexAppServerClient,
|
|
538
|
+
retireSharedCodexAppServerClientIfCurrent: () => retireSharedCodexAppServerClientIfCurrent
|
|
474
539
|
});
|
|
475
540
|
const SHARED_CODEX_APP_SERVER_CLIENT_STATE = Symbol.for("openclaw.codexAppServerClientState");
|
|
476
541
|
function getSharedCodexAppServerClientState() {
|
|
477
542
|
const globalState = globalThis;
|
|
478
543
|
const state = globalState[SHARED_CODEX_APP_SERVER_CLIENT_STATE];
|
|
479
|
-
|
|
544
|
+
const keyedState = readKeyedSharedCodexAppServerClientState(state);
|
|
545
|
+
if (keyedState) {
|
|
546
|
+
const clients = keyedState.clients;
|
|
547
|
+
for (const entry of clients.values()) {
|
|
548
|
+
entry.activeLeases ??= 0;
|
|
549
|
+
entry.closeWhenIdle ??= false;
|
|
550
|
+
}
|
|
551
|
+
const nextState = {
|
|
552
|
+
clients,
|
|
553
|
+
leasedReleases: keyedState.leasedReleases instanceof WeakMap ? keyedState.leasedReleases : /* @__PURE__ */ new WeakMap()
|
|
554
|
+
};
|
|
555
|
+
globalState[SHARED_CODEX_APP_SERVER_CLIENT_STATE] = nextState;
|
|
556
|
+
return nextState;
|
|
557
|
+
}
|
|
480
558
|
const legacyState = readLegacySharedCodexAppServerClientState(state);
|
|
481
559
|
const clients = /* @__PURE__ */ new Map();
|
|
482
560
|
if (legacyState?.key && (legacyState.client || legacyState.promise)) {
|
|
483
561
|
const legacyKey = legacyState.key;
|
|
484
562
|
clients.set(legacyKey, {
|
|
485
563
|
client: legacyState.client,
|
|
486
|
-
promise: legacyState.promise
|
|
564
|
+
promise: legacyState.promise,
|
|
565
|
+
activeLeases: 0,
|
|
566
|
+
closeWhenIdle: false
|
|
487
567
|
});
|
|
488
568
|
legacyState.client?.addCloseHandler((closedClient) => clearSharedClientEntryIfCurrent(legacyKey, closedClient));
|
|
489
569
|
}
|
|
490
|
-
const nextState = {
|
|
570
|
+
const nextState = {
|
|
571
|
+
clients,
|
|
572
|
+
leasedReleases: /* @__PURE__ */ new WeakMap()
|
|
573
|
+
};
|
|
491
574
|
globalState[SHARED_CODEX_APP_SERVER_CLIENT_STATE] = nextState;
|
|
492
575
|
return nextState;
|
|
493
576
|
}
|
|
494
|
-
function
|
|
495
|
-
return value !== null && typeof value === "object" && value.clients instanceof Map;
|
|
577
|
+
function readKeyedSharedCodexAppServerClientState(value) {
|
|
578
|
+
return value !== null && typeof value === "object" && value.clients instanceof Map ? value : void 0;
|
|
496
579
|
}
|
|
497
580
|
function readLegacySharedCodexAppServerClientState(value) {
|
|
498
581
|
if (value === null || typeof value !== "object") return;
|
|
499
582
|
return value;
|
|
500
583
|
}
|
|
501
584
|
async function getSharedCodexAppServerClient(options) {
|
|
585
|
+
return (await acquireSharedCodexAppServerClient(options)).client;
|
|
586
|
+
}
|
|
587
|
+
async function getLeasedSharedCodexAppServerClient(options) {
|
|
588
|
+
const acquired = await acquireSharedCodexAppServerClient(options, { leased: true });
|
|
589
|
+
const state = getSharedCodexAppServerClientState();
|
|
590
|
+
const releases = state.leasedReleases.get(acquired.client) ?? [];
|
|
591
|
+
releases.push(acquired.release);
|
|
592
|
+
state.leasedReleases.set(acquired.client, releases);
|
|
593
|
+
return acquired.client;
|
|
594
|
+
}
|
|
595
|
+
function releaseLeasedSharedCodexAppServerClient(client) {
|
|
596
|
+
const state = getSharedCodexAppServerClientState();
|
|
597
|
+
const releases = state.leasedReleases.get(client);
|
|
598
|
+
if (!releases) return false;
|
|
599
|
+
const release = releases.pop();
|
|
600
|
+
if (!release) return false;
|
|
601
|
+
if (releases.length === 0) state.leasedReleases.delete(client);
|
|
602
|
+
release();
|
|
603
|
+
return true;
|
|
604
|
+
}
|
|
605
|
+
async function acquireSharedCodexAppServerClient(options, leaseOptions) {
|
|
502
606
|
const agentDir = options?.agentDir ?? resolveDefaultAgentDir(options?.config ?? {});
|
|
503
607
|
const usesNativeAuth = options?.authProfileId === null;
|
|
504
608
|
const requestedAuthProfileId = options?.authProfileId === null ? void 0 : options?.authProfileId;
|
|
@@ -513,9 +617,11 @@ async function getSharedCodexAppServerClient(options) {
|
|
|
513
617
|
authProfileId: usesNativeAuth ? null : authProfileId,
|
|
514
618
|
config: options?.config
|
|
515
619
|
});
|
|
620
|
+
const fallbackApiKeyCacheKey = authProfileId ? void 0 : resolveCodexAppServerFallbackApiKeyCacheKey({ startOptions });
|
|
516
621
|
const key = codexAppServerStartOptionsKey(startOptions, {
|
|
517
622
|
authProfileId,
|
|
518
|
-
agentDir: usesNativeAuth ? void 0 : agentDir
|
|
623
|
+
agentDir: usesNativeAuth ? void 0 : agentDir,
|
|
624
|
+
fallbackApiKeyCacheKey
|
|
519
625
|
});
|
|
520
626
|
const state = getSharedCodexAppServerClientState();
|
|
521
627
|
const entry = getOrCreateSharedClientEntry(state, key);
|
|
@@ -539,7 +645,12 @@ async function getSharedCodexAppServerClient(options) {
|
|
|
539
645
|
}
|
|
540
646
|
})());
|
|
541
647
|
try {
|
|
542
|
-
|
|
648
|
+
const client = await withTimeout$1(sharedPromise, options?.timeoutMs ?? 0, "codex app-server initialize timed out");
|
|
649
|
+
const release = leaseOptions?.leased ? retainSharedClientEntry(entry) : void 0;
|
|
650
|
+
return release ? {
|
|
651
|
+
client,
|
|
652
|
+
release
|
|
653
|
+
} : { client };
|
|
543
654
|
} catch (error) {
|
|
544
655
|
const currentEntry = state.clients.get(key);
|
|
545
656
|
if (currentEntry?.promise === sharedPromise) clearSharedClientEntry(key, currentEntry);
|
|
@@ -589,6 +700,24 @@ function clearSharedCodexAppServerClientIfCurrent(client) {
|
|
|
589
700
|
}
|
|
590
701
|
return false;
|
|
591
702
|
}
|
|
703
|
+
function retireSharedCodexAppServerClientIfCurrent(client) {
|
|
704
|
+
if (!client) return;
|
|
705
|
+
const state = getSharedCodexAppServerClientState();
|
|
706
|
+
for (const [key, entry] of state.clients) if (entry.client === client) {
|
|
707
|
+
state.clients.delete(key);
|
|
708
|
+
entry.closeWhenIdle = true;
|
|
709
|
+
const closed = closeRetiredSharedClientEntryIfIdle(entry);
|
|
710
|
+
return {
|
|
711
|
+
activeLeases: entry.activeLeases,
|
|
712
|
+
closed
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
const activeLeases = state.leasedReleases.get(client)?.length ?? 0;
|
|
716
|
+
if (activeLeases > 0) return {
|
|
717
|
+
activeLeases,
|
|
718
|
+
closed: false
|
|
719
|
+
};
|
|
720
|
+
}
|
|
592
721
|
async function clearSharedCodexAppServerClientIfCurrentAndWait(client, options) {
|
|
593
722
|
if (!client) return false;
|
|
594
723
|
const state = getSharedCodexAppServerClientState();
|
|
@@ -608,7 +737,10 @@ async function clearSharedCodexAppServerClientAndWait(options) {
|
|
|
608
737
|
function getOrCreateSharedClientEntry(state, key) {
|
|
609
738
|
let entry = state.clients.get(key);
|
|
610
739
|
if (!entry) {
|
|
611
|
-
entry = {
|
|
740
|
+
entry = {
|
|
741
|
+
activeLeases: 0,
|
|
742
|
+
closeWhenIdle: false
|
|
743
|
+
};
|
|
612
744
|
state.clients.set(key, entry);
|
|
613
745
|
}
|
|
614
746
|
return entry;
|
|
@@ -623,8 +755,26 @@ function clearSharedClientEntryIfCurrent(key, client) {
|
|
|
623
755
|
const state = getSharedCodexAppServerClientState();
|
|
624
756
|
if (state.clients.get(key)?.client === client) state.clients.delete(key);
|
|
625
757
|
}
|
|
758
|
+
function retainSharedClientEntry(entry) {
|
|
759
|
+
let released = false;
|
|
760
|
+
entry.activeLeases += 1;
|
|
761
|
+
return () => {
|
|
762
|
+
if (released) return;
|
|
763
|
+
released = true;
|
|
764
|
+
entry.activeLeases = Math.max(0, entry.activeLeases - 1);
|
|
765
|
+
closeRetiredSharedClientEntryIfIdle(entry);
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
function closeRetiredSharedClientEntryIfIdle(entry) {
|
|
769
|
+
if (!entry.closeWhenIdle || entry.activeLeases > 0 || !entry.client) return false;
|
|
770
|
+
const client = entry.client;
|
|
771
|
+
entry.closeWhenIdle = false;
|
|
772
|
+
entry.client = void 0;
|
|
773
|
+
client.close();
|
|
774
|
+
return true;
|
|
775
|
+
}
|
|
626
776
|
function collectSharedClients(state) {
|
|
627
777
|
return [...new Set([...state.clients.values()].map((entry) => entry.client).filter((client) => Boolean(client)))];
|
|
628
778
|
}
|
|
629
779
|
//#endregion
|
|
630
|
-
export {
|
|
780
|
+
export { releaseLeasedSharedCodexAppServerClient as a, withTimeout$1 as c, resolveCodexAppServerAuthProfileId as d, resolveCodexAppServerAuthProfileIdForAgent as f, getLeasedSharedCodexAppServerClient as i, refreshCodexAppServerAuthTokens as l, resolveCodexAppServerHomeDir as m, clearSharedCodexAppServerClientIfCurrentAndWait as n, retireSharedCodexAppServerClientIfCurrent as o, resolveCodexAppServerFallbackApiKeyCacheKey as p, createIsolatedCodexAppServerClient as r, shared_client_exports as s, clearSharedCodexAppServerClientIfCurrent as t, resolveCodexAppServerAuthAccountCacheKey as u };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { c as readCodexPluginConfig, f as shouldAutoApproveCodexAppServerApprovals, l as resolveCodexAppServerRuntimeOptions } from "./config-
|
|
2
|
-
import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse, t as assertCodexThreadForkResponse } from "./protocol-validators-
|
|
3
|
-
import { i as isCodexAppServerApprovalRequest, l as isJsonObject } from "./client-
|
|
4
|
-
import {
|
|
5
|
-
import { i as readCodexAppServerBinding } from "./session-binding-
|
|
6
|
-
import { i as readCodexNotificationTurnId, m as formatCodexUsageLimitErrorMessage, r as readCodexNotificationThreadId } from "./notification-correlation-
|
|
7
|
-
import { i as
|
|
1
|
+
import { c as readCodexPluginConfig, f as shouldAutoApproveCodexAppServerApprovals, l as resolveCodexAppServerRuntimeOptions } from "./config-0-UN67Qg.js";
|
|
2
|
+
import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse, t as assertCodexThreadForkResponse } from "./protocol-validators-DtjYmUw_.js";
|
|
3
|
+
import { i as isCodexAppServerApprovalRequest, l as isJsonObject } from "./client-BVK_jmHW.js";
|
|
4
|
+
import { f as resolveCodexAppServerModelProvider, p as resolveReasoningEffort, r as buildCodexRuntimeThreadConfig, t as CODEX_NATIVE_PERSONALITY_NONE, v as mergeCodexThreadConfigs } from "./thread-lifecycle-CUXQezJL.js";
|
|
5
|
+
import { i as readCodexAppServerBinding } from "./session-binding-UFjjws4k.js";
|
|
6
|
+
import { i as readCodexNotificationTurnId, m as formatCodexUsageLimitErrorMessage, r as readCodexNotificationThreadId } from "./notification-correlation-YINts3PA.js";
|
|
7
|
+
import { a as releaseLeasedSharedCodexAppServerClient, i as getLeasedSharedCodexAppServerClient, l as refreshCodexAppServerAuthTokens } from "./shared-client-8kIrP817.js";
|
|
8
8
|
import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-CTnEWuor.js";
|
|
9
|
-
import { a as resolveCodexDynamicToolsLoading, n as filterCodexDynamicTools, t as createCodexDynamicToolBridge } from "./dynamic-tools-
|
|
10
|
-
import { a as handleCodexAppServerElicitationRequest, c as emitDynamicToolTerminalDiagnostic, i as buildCodexNativeHookRelayDisabledConfig, l as handleCodexAppServerApprovalRequest, n as CODEX_NATIVE_HOOK_RELAY_EVENTS, o as emitDynamicToolErrorDiagnostic, r as buildCodexNativeHookRelayConfig, s as emitDynamicToolStartedDiagnostic, t as filterToolsForVisionInputs } from "./vision-tools-
|
|
9
|
+
import { a as resolveCodexDynamicToolsLoading, n as filterCodexDynamicTools, t as createCodexDynamicToolBridge } from "./dynamic-tools-DlEefKNQ.js";
|
|
10
|
+
import { a as handleCodexAppServerElicitationRequest, c as emitDynamicToolTerminalDiagnostic, i as buildCodexNativeHookRelayDisabledConfig, l as handleCodexAppServerApprovalRequest, n as CODEX_NATIVE_HOOK_RELAY_EVENTS, o as emitDynamicToolErrorDiagnostic, r as buildCodexNativeHookRelayConfig, s as emitDynamicToolStartedDiagnostic, t as filterToolsForVisionInputs } from "./vision-tools-DqpLmF5H.js";
|
|
11
11
|
import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-N66I-Rd7.js";
|
|
12
12
|
import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage, registerNativeHookRelay, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
13
13
|
//#region extensions/codex/src/app-server/side-question.ts
|
|
14
|
-
const CODEX_SIDE_DYNAMIC_TOOL_TIMEOUT_MS =
|
|
14
|
+
const CODEX_SIDE_DYNAMIC_TOOL_TIMEOUT_MS = 9e4;
|
|
15
15
|
const CODEX_SIDE_DYNAMIC_TOOL_MAX_TIMEOUT_MS = 6e5;
|
|
16
16
|
const CODEX_SIDE_DYNAMIC_IMAGE_GENERATION_TOOL_TIMEOUT_MS = 12e4;
|
|
17
17
|
const CODEX_SIDE_DYNAMIC_IMAGE_TOOL_TIMEOUT_MS = 6e4;
|
|
@@ -60,7 +60,7 @@ async function runCodexAppServerSideQuestion(params, options = {}) {
|
|
|
60
60
|
const pluginConfig = readCodexPluginConfig(options.pluginConfig);
|
|
61
61
|
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig });
|
|
62
62
|
const authProfileId = params.authProfileId ?? binding.authProfileId;
|
|
63
|
-
const client = await
|
|
63
|
+
const client = await getLeasedSharedCodexAppServerClient({
|
|
64
64
|
startOptions: appServer.start,
|
|
65
65
|
timeoutMs: appServer.requestTimeoutMs,
|
|
66
66
|
authProfileId,
|
|
@@ -272,6 +272,7 @@ async function runCodexAppServerSideQuestion(params, options = {}) {
|
|
|
272
272
|
timeoutMs: appServer.requestTimeoutMs
|
|
273
273
|
});
|
|
274
274
|
} finally {
|
|
275
|
+
releaseLeasedSharedCodexAppServerClient(client);
|
|
275
276
|
nativeHookRelay?.unregister();
|
|
276
277
|
}
|
|
277
278
|
}
|
package/dist/test-api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as resolveCodexAppServerRuntimeOptions } from "./config-
|
|
2
|
-
import { a as buildDeveloperInstructions, l as buildTurnStartParams, o as buildThreadResumeParams, s as buildThreadStartParams } from "./thread-lifecycle-
|
|
3
|
-
import { n as filterCodexDynamicTools, t as createCodexDynamicToolBridge } from "./dynamic-tools-
|
|
1
|
+
import { l as resolveCodexAppServerRuntimeOptions } from "./config-0-UN67Qg.js";
|
|
2
|
+
import { a as buildDeveloperInstructions, l as buildTurnStartParams, o as buildThreadResumeParams, s as buildThreadStartParams } from "./thread-lifecycle-CUXQezJL.js";
|
|
3
|
+
import { n as filterCodexDynamicTools, t as createCodexDynamicToolBridge } from "./dynamic-tools-DlEefKNQ.js";
|
|
4
4
|
//#region extensions/codex/test-api.ts
|
|
5
5
|
function resolveCodexPromptSnapshotAppServerOptions(pluginConfig) {
|
|
6
6
|
return resolveCodexAppServerRuntimeOptions({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { d as resolveCodexPluginsPolicy, r as codexSandboxPolicyForTurn, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-
|
|
2
|
-
import { n as assertCodexThreadResumeResponse, r as assertCodexThreadStartResponse } from "./protocol-validators-
|
|
3
|
-
import { a as isCodexAppServerConnectionClosedError, l as isJsonObject } from "./client-
|
|
1
|
+
import { d as resolveCodexPluginsPolicy, r as codexSandboxPolicyForTurn, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-0-UN67Qg.js";
|
|
2
|
+
import { n as assertCodexThreadResumeResponse, r as assertCodexThreadStartResponse } from "./protocol-validators-DtjYmUw_.js";
|
|
3
|
+
import { a as isCodexAppServerConnectionClosedError, l as isJsonObject } from "./client-BVK_jmHW.js";
|
|
4
4
|
import { CODEX_GPT5_HEARTBEAT_PROMPT_OVERLAY } from "./prompt-overlay.js";
|
|
5
5
|
import { isModernCodexModel } from "./provider.js";
|
|
6
|
-
import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-
|
|
6
|
+
import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-UFjjws4k.js";
|
|
7
7
|
import crypto from "node:crypto";
|
|
8
8
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
9
|
import { embeddedAgentLog, isActiveHarnessContextEngine } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
@@ -12,6 +12,7 @@ import { listRegisteredPluginAgentPromptGuidance } from "openclaw/plugin-sdk/plu
|
|
|
12
12
|
import { redactSensitiveFieldValue, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
13
13
|
import "node:fs/promises";
|
|
14
14
|
import "node:path";
|
|
15
|
+
import { isDiagnosticFlagEnabled } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
15
16
|
//#region extensions/codex/src/app-server/context-engine-projection.ts
|
|
16
17
|
const CONTEXT_HEADER = "OpenClaw assembled context for this turn:";
|
|
17
18
|
const CONTEXT_OPEN = "<conversation_context>";
|
|
@@ -1067,6 +1068,12 @@ function stableStringify(value) {
|
|
|
1067
1068
|
return JSON.stringify(value);
|
|
1068
1069
|
}
|
|
1069
1070
|
//#endregion
|
|
1071
|
+
//#region extensions/codex/src/app-server/profiler-flag.ts
|
|
1072
|
+
const PROFILER_FLAGS = ["profiler", "codex.profiler"];
|
|
1073
|
+
function isCodexAppServerProfilerEnabled(config, env = process.env) {
|
|
1074
|
+
return PROFILER_FLAGS.some((flag) => isDiagnosticFlagEnabled(flag, config, env));
|
|
1075
|
+
}
|
|
1076
|
+
//#endregion
|
|
1070
1077
|
//#region extensions/codex/src/app-server/thread-lifecycle.ts
|
|
1071
1078
|
const CODEX_NATIVE_PERSONALITY_NONE = "none";
|
|
1072
1079
|
const CODEX_CODE_MODE_THREAD_CONFIG = {
|
|
@@ -1078,17 +1085,81 @@ const CODEX_CODE_MODE_DISABLED_THREAD_CONFIG = {
|
|
|
1078
1085
|
"features.code_mode_only": false
|
|
1079
1086
|
};
|
|
1080
1087
|
const CODEX_LIGHTWEIGHT_CONTEXT_THREAD_CONFIG = { project_doc_max_bytes: 0 };
|
|
1088
|
+
const CODEX_THREAD_LIFECYCLE_TIMING_WARN_TOTAL_MS = 1e3;
|
|
1089
|
+
const CODEX_THREAD_LIFECYCLE_TIMING_WARN_STAGE_MS = 500;
|
|
1090
|
+
function createCodexThreadLifecycleTimingTracker(options = {}) {
|
|
1091
|
+
if (!options.enabled) return {
|
|
1092
|
+
async measure(_name, run) {
|
|
1093
|
+
return await run();
|
|
1094
|
+
},
|
|
1095
|
+
measureSync(_name, run) {
|
|
1096
|
+
return run();
|
|
1097
|
+
},
|
|
1098
|
+
logIfSlow() {}
|
|
1099
|
+
};
|
|
1100
|
+
const startedAt = Date.now();
|
|
1101
|
+
let didLog = false;
|
|
1102
|
+
const spans = [];
|
|
1103
|
+
const toMs = (value) => Math.max(0, Math.round(value));
|
|
1104
|
+
const record = (name, spanStartedAt) => {
|
|
1105
|
+
spans.push({
|
|
1106
|
+
name,
|
|
1107
|
+
durationMs: toMs(Date.now() - spanStartedAt),
|
|
1108
|
+
elapsedMs: toMs(Date.now() - startedAt)
|
|
1109
|
+
});
|
|
1110
|
+
};
|
|
1111
|
+
const snapshot = () => ({
|
|
1112
|
+
totalMs: toMs(Date.now() - startedAt),
|
|
1113
|
+
spans: spans.slice()
|
|
1114
|
+
});
|
|
1115
|
+
const shouldLog = (summary) => summary.totalMs >= CODEX_THREAD_LIFECYCLE_TIMING_WARN_TOTAL_MS || summary.spans.some((span) => span.durationMs >= CODEX_THREAD_LIFECYCLE_TIMING_WARN_STAGE_MS);
|
|
1116
|
+
const formatSpans = (summary) => summary.spans.length > 0 ? summary.spans.map((span) => `${span.name}:${span.durationMs}ms@${span.elapsedMs}ms`).join(",") : "none";
|
|
1117
|
+
return {
|
|
1118
|
+
async measure(name, run) {
|
|
1119
|
+
const spanStartedAt = Date.now();
|
|
1120
|
+
try {
|
|
1121
|
+
return await run();
|
|
1122
|
+
} finally {
|
|
1123
|
+
record(name, spanStartedAt);
|
|
1124
|
+
}
|
|
1125
|
+
},
|
|
1126
|
+
measureSync(name, run) {
|
|
1127
|
+
const spanStartedAt = Date.now();
|
|
1128
|
+
try {
|
|
1129
|
+
return run();
|
|
1130
|
+
} finally {
|
|
1131
|
+
record(name, spanStartedAt);
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1134
|
+
logIfSlow(params) {
|
|
1135
|
+
if (didLog) return;
|
|
1136
|
+
const summary = snapshot();
|
|
1137
|
+
if (!shouldLog(summary)) return;
|
|
1138
|
+
didLog = true;
|
|
1139
|
+
embeddedAgentLog.warn(`codex app-server thread lifecycle timings runId=${params.runId} sessionId=${params.sessionId} sessionKey=${params.sessionKey ?? "unknown"} action=${params.action} totalMs=${summary.totalMs} stages=${formatSpans(summary)}`, {
|
|
1140
|
+
runId: params.runId,
|
|
1141
|
+
sessionId: params.sessionId,
|
|
1142
|
+
sessionKey: params.sessionKey,
|
|
1143
|
+
action: params.action,
|
|
1144
|
+
threadId: params.threadId,
|
|
1145
|
+
totalMs: summary.totalMs,
|
|
1146
|
+
spans: summary.spans
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1081
1151
|
async function startOrResumeThread(params) {
|
|
1082
|
-
const
|
|
1083
|
-
const
|
|
1152
|
+
const lifecycleTiming = createCodexThreadLifecycleTimingTracker({ enabled: isCodexAppServerProfilerEnabled(params.params.config) });
|
|
1153
|
+
const dynamicToolsFingerprint = lifecycleTiming.measureSync("fingerprint_dynamic_tools", () => fingerprintDynamicTools(params.dynamicTools));
|
|
1154
|
+
const contextEngineBinding = lifecycleTiming.measureSync("context_engine_binding", () => buildContextEngineBinding(params.params, params.contextEngineProjection));
|
|
1084
1155
|
const userMcpServersConfigPatch = params.userMcpServersEnabled === false ? void 0 : buildCodexUserMcpServersThreadConfigPatch(params.params.config, { agentId: params.agentId ?? params.params.agentId });
|
|
1085
1156
|
const userMcpServersFingerprint = fingerprintUserMcpServersConfigPatch(userMcpServersConfigPatch);
|
|
1086
1157
|
const environmentSelectionFingerprint = fingerprintEnvironmentSelection(params.environmentSelection);
|
|
1087
|
-
let binding = await readCodexAppServerBinding(params.params.sessionFile, {
|
|
1158
|
+
let binding = await lifecycleTiming.measure("read_binding", () => readCodexAppServerBinding(params.params.sessionFile, {
|
|
1088
1159
|
authProfileStore: params.params.authProfileStore,
|
|
1089
1160
|
agentDir: params.params.agentDir,
|
|
1090
1161
|
config: params.params.config
|
|
1091
|
-
});
|
|
1162
|
+
}));
|
|
1092
1163
|
let preserveExistingBinding = false;
|
|
1093
1164
|
let rotatedContextEngineBinding = false;
|
|
1094
1165
|
let prebuiltPluginThreadConfig;
|
|
@@ -1142,7 +1213,7 @@ async function startOrResumeThread(params) {
|
|
|
1142
1213
|
binding,
|
|
1143
1214
|
pluginThreadConfig: params.pluginThreadConfig
|
|
1144
1215
|
})) try {
|
|
1145
|
-
prebuiltPluginThreadConfig = await params.pluginThreadConfig?.build();
|
|
1216
|
+
prebuiltPluginThreadConfig = await lifecycleTiming.measure("plugin_config_recovery", () => params.pluginThreadConfig?.build());
|
|
1146
1217
|
pluginBindingStale = prebuiltPluginThreadConfig?.fingerprint !== binding.pluginAppsFingerprint;
|
|
1147
1218
|
} catch (error) {
|
|
1148
1219
|
embeddedAgentLog.warn("codex app-server plugin app config recovery check failed", {
|
|
@@ -1174,7 +1245,7 @@ async function startOrResumeThread(params) {
|
|
|
1174
1245
|
} else try {
|
|
1175
1246
|
const authProfileId = params.params.authProfileId ?? binding.authProfileId;
|
|
1176
1247
|
const resumeConfig = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, params.finalConfigPatch);
|
|
1177
|
-
const
|
|
1248
|
+
const resumeParams = lifecycleTiming.measureSync("thread_resume_params", () => buildThreadResumeParams(params.params, {
|
|
1178
1249
|
threadId: binding.threadId,
|
|
1179
1250
|
authProfileId,
|
|
1180
1251
|
appServer: params.appServer,
|
|
@@ -1183,7 +1254,8 @@ async function startOrResumeThread(params) {
|
|
|
1183
1254
|
config: resumeConfig,
|
|
1184
1255
|
nativeCodeModeEnabled: params.nativeCodeModeEnabled,
|
|
1185
1256
|
nativeCodeModeOnlyEnabled: params.nativeCodeModeOnlyEnabled
|
|
1186
|
-
}))
|
|
1257
|
+
}));
|
|
1258
|
+
const response = assertCodexThreadResumeResponse(await lifecycleTiming.measure("thread_resume_request", () => params.client.request("thread/resume", resumeParams)));
|
|
1187
1259
|
const boundAuthProfileId = authProfileId;
|
|
1188
1260
|
const fallbackModelProvider = resolveCodexAppServerModelProvider({
|
|
1189
1261
|
provider: params.params.provider,
|
|
@@ -1193,7 +1265,7 @@ async function startOrResumeThread(params) {
|
|
|
1193
1265
|
config: params.params.config
|
|
1194
1266
|
});
|
|
1195
1267
|
const nextMcpServersFingerprint = params.mcpServersFingerprintEvaluated === true ? params.mcpServersFingerprint : binding.mcpServersFingerprint;
|
|
1196
|
-
await writeCodexAppServerBinding(params.params.sessionFile, {
|
|
1268
|
+
await lifecycleTiming.measure("thread_resume_write_binding", () => writeCodexAppServerBinding(params.params.sessionFile, {
|
|
1197
1269
|
threadId: response.thread.id,
|
|
1198
1270
|
cwd: params.cwd,
|
|
1199
1271
|
authProfileId: boundAuthProfileId,
|
|
@@ -1212,7 +1284,7 @@ async function startOrResumeThread(params) {
|
|
|
1212
1284
|
authProfileStore: params.params.authProfileStore,
|
|
1213
1285
|
agentDir: params.params.agentDir,
|
|
1214
1286
|
config: params.params.config
|
|
1215
|
-
});
|
|
1287
|
+
}));
|
|
1216
1288
|
if (contextEngineBinding) embeddedAgentLog.info("codex app-server wrote context-engine thread binding", {
|
|
1217
1289
|
sessionId: params.params.sessionId,
|
|
1218
1290
|
sessionKey: params.params.sessionKey,
|
|
@@ -1222,6 +1294,13 @@ async function startOrResumeThread(params) {
|
|
|
1222
1294
|
fingerprint: contextEngineBinding.projection?.fingerprint,
|
|
1223
1295
|
action: "resumed"
|
|
1224
1296
|
});
|
|
1297
|
+
lifecycleTiming.logIfSlow({
|
|
1298
|
+
runId: params.params.runId,
|
|
1299
|
+
sessionId: params.params.sessionId,
|
|
1300
|
+
sessionKey: params.params.sessionKey,
|
|
1301
|
+
threadId: response.thread.id,
|
|
1302
|
+
action: "resumed"
|
|
1303
|
+
});
|
|
1225
1304
|
return {
|
|
1226
1305
|
...binding,
|
|
1227
1306
|
threadId: response.thread.id,
|
|
@@ -1244,9 +1323,9 @@ async function startOrResumeThread(params) {
|
|
|
1244
1323
|
embeddedAgentLog.warn("codex app-server thread resume failed; starting a new thread", { error });
|
|
1245
1324
|
await clearCodexAppServerBinding(params.params.sessionFile);
|
|
1246
1325
|
}
|
|
1247
|
-
const pluginThreadConfig = params.pluginThreadConfig?.enabled ? prebuiltPluginThreadConfig ?? await params.pluginThreadConfig
|
|
1248
|
-
const config = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, params.finalConfigPatch);
|
|
1249
|
-
const
|
|
1326
|
+
const pluginThreadConfig = params.pluginThreadConfig?.enabled ? prebuiltPluginThreadConfig ?? await lifecycleTiming.measure("plugin_config_build", () => params.pluginThreadConfig?.build()) : void 0;
|
|
1327
|
+
const config = lifecycleTiming.measureSync("merge_thread_config", () => mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, params.finalConfigPatch));
|
|
1328
|
+
const startParams = lifecycleTiming.measureSync("thread_start_params", () => buildThreadStartParams(params.params, {
|
|
1250
1329
|
cwd: params.cwd,
|
|
1251
1330
|
dynamicTools: params.dynamicTools,
|
|
1252
1331
|
appServer: params.appServer,
|
|
@@ -1255,7 +1334,8 @@ async function startOrResumeThread(params) {
|
|
|
1255
1334
|
nativeCodeModeEnabled: params.nativeCodeModeEnabled,
|
|
1256
1335
|
nativeCodeModeOnlyEnabled: params.nativeCodeModeOnlyEnabled,
|
|
1257
1336
|
environmentSelection: params.environmentSelection
|
|
1258
|
-
}))
|
|
1337
|
+
}));
|
|
1338
|
+
const response = assertCodexThreadStartResponse(await lifecycleTiming.measure("thread_start_request", () => params.client.request("thread/start", startParams)));
|
|
1259
1339
|
const modelProvider = resolveCodexAppServerModelProvider({
|
|
1260
1340
|
provider: params.params.provider,
|
|
1261
1341
|
authProfileId: params.params.authProfileId,
|
|
@@ -1266,7 +1346,7 @@ async function startOrResumeThread(params) {
|
|
|
1266
1346
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1267
1347
|
const nextMcpServersFingerprint = params.mcpServersFingerprintEvaluated === true ? params.mcpServersFingerprint : void 0;
|
|
1268
1348
|
if (!preserveExistingBinding) {
|
|
1269
|
-
await writeCodexAppServerBinding(params.params.sessionFile, {
|
|
1349
|
+
await lifecycleTiming.measure("thread_start_write_binding", () => writeCodexAppServerBinding(params.params.sessionFile, {
|
|
1270
1350
|
threadId: response.thread.id,
|
|
1271
1351
|
cwd: params.cwd,
|
|
1272
1352
|
authProfileId: params.params.authProfileId,
|
|
@@ -1285,7 +1365,7 @@ async function startOrResumeThread(params) {
|
|
|
1285
1365
|
authProfileStore: params.params.authProfileStore,
|
|
1286
1366
|
agentDir: params.params.agentDir,
|
|
1287
1367
|
config: params.params.config
|
|
1288
|
-
});
|
|
1368
|
+
}));
|
|
1289
1369
|
if (contextEngineBinding) embeddedAgentLog.info("codex app-server wrote context-engine thread binding", {
|
|
1290
1370
|
sessionId: params.params.sessionId,
|
|
1291
1371
|
sessionKey: params.params.sessionKey,
|
|
@@ -1296,6 +1376,13 @@ async function startOrResumeThread(params) {
|
|
|
1296
1376
|
action: rotatedContextEngineBinding ? "rotated" : "started"
|
|
1297
1377
|
});
|
|
1298
1378
|
}
|
|
1379
|
+
lifecycleTiming.logIfSlow({
|
|
1380
|
+
runId: params.params.runId,
|
|
1381
|
+
sessionId: params.params.sessionId,
|
|
1382
|
+
sessionKey: params.params.sessionKey,
|
|
1383
|
+
threadId: response.thread.id,
|
|
1384
|
+
action: rotatedContextEngineBinding ? "rotated" : "started"
|
|
1385
|
+
});
|
|
1299
1386
|
return {
|
|
1300
1387
|
schemaVersion: 1,
|
|
1301
1388
|
threadId: response.thread.id,
|
|
@@ -1589,8 +1676,9 @@ function buildDeferredDynamicToolManifest(dynamicTools) {
|
|
|
1589
1676
|
}
|
|
1590
1677
|
function buildVisibleReplyInstruction(params, dynamicTools) {
|
|
1591
1678
|
const messageToolAvailable = dynamicTools ? dynamicTools.some((tool) => tool.name.trim() === "message") : params.disableMessageTool !== true;
|
|
1592
|
-
if (params.sourceReplyDeliveryMode === "message_tool_only" && messageToolAvailable) return "
|
|
1593
|
-
return "
|
|
1679
|
+
if (params.sourceReplyDeliveryMode === "message_tool_only" && messageToolAvailable) return "Visible source replies are not automatically delivered for this run. Use `message(action=send)` for user-visible source-channel output. Do not repeat that visible content in your final answer.";
|
|
1680
|
+
if (messageToolAvailable) return "For the current source conversation, reply normally in your final assistant message; OpenClaw will deliver it through the active source conversation. Use `message` only for explicit out-of-band sends, media/file sends, or sends to a different target.";
|
|
1681
|
+
return "For the current source conversation, reply normally in your final assistant message; OpenClaw will deliver it through the active source conversation.";
|
|
1594
1682
|
}
|
|
1595
1683
|
function buildUserInput(params, promptText = params.prompt) {
|
|
1596
1684
|
const imageInputs = (params.images ?? []).map((image) => {
|
|
@@ -1623,4 +1711,4 @@ function resolveReasoningEffort(thinkLevel, modelId) {
|
|
|
1623
1711
|
return null;
|
|
1624
1712
|
}
|
|
1625
1713
|
//#endregion
|
|
1626
|
-
export {
|
|
1714
|
+
export { defaultCodexAppInventoryCache as C, projectContextEngineAssemblyForCodex as D, sanitizeInlineImageDataUrl as E, resolveCodexContextEngineProjectionMaxChars as O, buildCodexAppInventoryCacheKey as S, sanitizeCodexHistoryImagePayloads as T, buildCodexPluginThreadConfigInputFingerprint as _, buildDeveloperInstructions as a, ensureCodexPluginActivation as b, buildTurnCollaborationMode as c, isContextEngineBindingCompatible as d, resolveCodexAppServerModelProvider as f, buildCodexPluginThreadConfig as g, isCodexAppServerProfilerEnabled as h, buildContextEngineBinding as i, resolveCodexContextEngineProjectionReserveTokens as k, buildTurnStartParams as l, startOrResumeThread as m, areCodexDynamicToolFingerprintsCompatible as n, buildThreadResumeParams as o, resolveReasoningEffort as p, buildCodexRuntimeThreadConfig as r, buildThreadStartParams as s, CODEX_NATIVE_PERSONALITY_NONE as t, codexDynamicToolsFingerprint as u, mergeCodexThreadConfigs as v, invalidInlineImageText as w, pluginReadParams as x, shouldBuildCodexPluginThreadConfig as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as isJsonObject } from "./client-
|
|
2
|
-
import { s as formatCodexDisplayText } from "./notification-correlation-
|
|
1
|
+
import { l as isJsonObject } from "./client-BVK_jmHW.js";
|
|
2
|
+
import { s as formatCodexDisplayText } from "./notification-correlation-YINts3PA.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
import { buildAgentHookContextChannelFields, callGatewayTool, embeddedAgentLog, formatApprovalDisplayPath, hasNativeHookRelayInvocation, invokeNativeHookRelay, runBeforeToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
@@ -300,8 +300,10 @@ async function runNativeRelayToolPolicyForApprovalRequest(params) {
|
|
|
300
300
|
const decision = readNativeRelayPreToolUseDecision(await invokeNativeHookRelay({
|
|
301
301
|
provider: "codex",
|
|
302
302
|
relayId: params.nativeHookRelay.relayId,
|
|
303
|
+
generation: params.nativeHookRelay.generation,
|
|
303
304
|
event: "pre_tool_use",
|
|
304
|
-
rawPayload: payload
|
|
305
|
+
rawPayload: payload,
|
|
306
|
+
requireGeneration: true
|
|
305
307
|
}));
|
|
306
308
|
if (decision.blocked) return {
|
|
307
309
|
handled: true,
|