@openclaw/codex 2026.7.2-beta.3 → 2026.7.2-beta.5
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-DUMF2Xyr.js → app-server-policy-BmDgseo_.js} +1 -1
- package/dist/attempt-client-cleanup-Ia52yRWc.js +127 -0
- package/dist/{attempt-notifications-Ecjyzufe.js → attempt-notifications-CMR2_fmR.js} +1 -1
- package/dist/{media-understanding-provider-IPNNQre6.js → bounded-turn-FEbUXoYT.js} +71 -188
- package/dist/capabilities-BHRSI6Cn.js +36 -0
- package/dist/cli-metadata.js +1 -1
- package/dist/{command-formatters-NCTL7A2q.js → command-formatters-ico4ZFnk.js} +3 -37
- package/dist/{command-handlers-DtFbZiba.js → command-handlers-CRmnwI2N.js} +1233 -1221
- package/dist/{compact-Kgy26gIM.js → compact-dEN49UH6.js} +8 -7
- package/dist/{computer-use-C7x4ZaqR.js → computer-use-BjGylO-E.js} +16 -6
- package/dist/{conversation-control-B0s3aIjT.js → conversation-control-DE7d9DOj.js} +6 -5
- package/dist/doctor-contract-api.js +24 -86
- package/dist/{dynamic-tools-D_vSVmv9.js → dynamic-tools-LIt9ojep.js} +135 -2696
- package/dist/event-projector-assistant-message-DTgnPPVF.js +101 -0
- package/dist/event-projector-usage-tvgb1NCX.js +69 -0
- package/dist/harness.js +31 -11
- package/dist/incognito-session-ET_ufDH-.js +2 -0
- package/dist/index.js +250 -275
- package/dist/media-understanding-provider.js +173 -1
- package/dist/{models-DD5zBdX5.js → models-BA01NEez.js} +2 -2
- package/dist/{notification-correlation-C8DVQ_Bq.js → notification-correlation-Bj_Ak_jI.js} +3 -3
- package/dist/{plugin-app-cache-key-DJbhLYSK.js → plugin-app-cache-key-DSXX-rXO.js} +5 -5
- package/dist/{transcript-mirror-D9rTxx2P.js → protocol-validators-Dm4eXZmt.js} +335 -595
- package/dist/{rate-limits-CqhWQ2R9.js → rate-limits-S_PXs0ul.js} +1 -1
- package/dist/realtime-voice-api-BPcA1uN9.js +494 -0
- package/dist/realtime-voice-api.js +2 -0
- package/dist/{request-9yf9pZjf.js → request-CXpPennK.js} +1 -1
- package/dist/{run-attempt-BIoO8ISr.js → run-attempt-C5GTPJOE.js} +3111 -387
- package/dist/{session-binding-Bmt20HfB.js → session-binding-DlVQ-Pxs.js} +957 -890
- package/dist/{session-catalog-CA7R-hX2.js → session-catalog-CP2oCcEb.js} +98 -87
- package/dist/{session-cli-Bxk3-Wqz.js → session-cli-CqZ0Fp2a.js} +2 -2
- package/dist/session-upstream-marker-QE-m5QFG.js +82 -0
- package/dist/settled-turn-finalizer-CA_2QXIE.js +303 -0
- package/dist/{shared-client-CSXLtCLE.js → shared-client-BVKE40c-.js} +1870 -1694
- package/dist/{side-question-DtzquMOb.js → side-question-CO12sHxo.js} +24 -16
- package/dist/{thread-lifecycle-CQ_9mAa1.js → thread-lifecycle-DRg_FdzC.js} +127 -153
- package/dist/transcript-mirror-uKA-A4tB.js +550 -0
- package/dist/upstream-session-fork-_Vrz4WJr.js +320 -0
- package/dist/{usage-CuPpFgTc.js → usage-UpVbdX5G.js} +3 -3
- package/dist/{web-search-provider.runtime-_x5XTeqh.js → web-search-provider.runtime-CaQMYDbp.js} +3 -3
- package/package.json +7 -8
- package/npm-shrinkwrap.json +0 -202
- package/dist/{auth-binding-C1czuHPA.js → auth-binding-B4FfbcCg.js} +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { D as resolveOpenClawExecPolicyForCodexAppServer,
|
|
3
|
-
import { f as
|
|
4
|
-
import {
|
|
5
|
-
import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-
|
|
6
|
-
import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-
|
|
1
|
+
import { D as ensureCodexAppServerClientRuntime, I as resolveCodexAppServerPreparedAuthHandoff, V as isJsonObject, a as getLeasedSharedCodexAppServerClient, c as releaseCodexAppServerClientLease, k as readRecentCodexRateLimits, m as withLeasedCodexAppServerClientStartSelectionRetry, y as isCodexAppServerApprovalRequest } from "./shared-client-BVKE40c-.js";
|
|
2
|
+
import { D as resolveOpenClawExecPolicyForCodexAppServer, S as resolveCodexModelBackedReviewerPolicyContext, T as readCodexPluginConfig, b as canUseCodexModelBackedApprovalsReviewerForModel, l as sessionBindingIdentity, v as shouldAutoApproveCodexAppServerApprovals } from "./session-binding-DlVQ-Pxs.js";
|
|
3
|
+
import { A as resolveCodexDynamicToolsLoading, C as readCodexSupportedReasoningEfforts, G as mergeCodexThreadConfigs, S as resolveReasoningEffort, T as filterCodexDynamicTools, V as buildCodexPluginAppsConfigPatchFromPolicyContext, _ as CODEX_NATIVE_PERSONALITY_NONE, f as buildCodexRuntimeThreadConfig, h as resolveCodexWebSearchPlan, v as resolveCodexAppServerModelProvider, x as resolveCodexBindingModelProviderFallback, y as resolveCodexAppServerRequestModelSelection } from "./thread-lifecycle-DRg_FdzC.js";
|
|
4
|
+
import { a as assertCodexTurnStartResponse, l as readCodexTurn, n as assertCodexThreadForkResponse, o as readCodexDynamicToolCallParams } from "./protocol-validators-Dm4eXZmt.js";
|
|
5
|
+
import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-S_PXs0ul.js";
|
|
6
|
+
import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-BmDgseo_.js";
|
|
7
7
|
import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-D1Wky__S.js";
|
|
8
|
-
import { a as resolveCodexBindingAppServerConnection, i as requireCodexSupervisionModelSelection, n as readCodexNotificationThreadId, r as readCodexNotificationTurnId } from "./notification-correlation-
|
|
9
|
-
import {
|
|
8
|
+
import { a as resolveCodexBindingAppServerConnection, i as requireCodexSupervisionModelSelection, n as readCodexNotificationThreadId, r as readCodexNotificationTurnId } from "./notification-correlation-Bj_Ak_jI.js";
|
|
9
|
+
import { C as CodexNativeToolLifecycleProjector, D as buildCodexNativeHookRelayDisabledConfig, E as buildCodexNativeHookRelayConfig, L as resolveDynamicToolCallTimeoutMs, N as handleDynamicToolCallWithTimeout, S as filterToolsForVisionInputs, U as resolveCodexToolAbortTerminalReason, _ as resolveCodexMessageToolProvider, a as emitDynamicToolStartedDiagnostic, c as resolveCodexProviderWebSearchSupportForClient, i as emitDynamicToolErrorDiagnostic, k as emitCodexNativePreToolUseFailureDiagnostic, n as handleCodexAppServerApprovalRequest, o as emitDynamicToolTerminalDiagnostic, r as handleCodexAppServerElicitationRequest, t as createCodexDynamicToolBridge, w as CODEX_NATIVE_HOOK_RELAY_EVENTS, y as shouldEnableCodexAppServerNativeToolSurface } from "./dynamic-tools-LIt9ojep.js";
|
|
10
|
+
import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage, registerNativeHookRelay, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
10
11
|
import { randomUUID } from "node:crypto";
|
|
11
12
|
import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
|
|
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
14
|
const SIDE_QUESTION_COMPLETION_TIMEOUT_MS = 6e5;
|
|
15
15
|
var CodexSideQuestionTimeoutError = class extends Error {
|
|
@@ -78,6 +78,7 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
78
78
|
authProfileId: preparedRuntimeAuth.plan.forwardedAuthProfileId,
|
|
79
79
|
authProfileStore: preparedRuntimeAuth.authProfileStore,
|
|
80
80
|
agentDir: params.agentDir,
|
|
81
|
+
...pluginConfig.appServer?.homeScope ? { homeScope: pluginConfig.appServer.homeScope } : {},
|
|
81
82
|
config: params.cfg,
|
|
82
83
|
subscriptionProfileRequiredError: "Prepared Codex subscription route requires a scoped native OAuth or token profile.",
|
|
83
84
|
subscriptionProfileUnusableError: `Prepared Codex auth profile "${preparedRuntimeAuth.plan.forwardedAuthProfileId}" is unusable.`
|
|
@@ -212,6 +213,7 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
212
213
|
let turnId;
|
|
213
214
|
let removeRequestHandler;
|
|
214
215
|
let nativeHookRelay;
|
|
216
|
+
const activeDynamicToolCalls = /* @__PURE__ */ new Set();
|
|
215
217
|
try {
|
|
216
218
|
const modelScopedAppServer = resolveCodexAppServerForModelProvider({
|
|
217
219
|
appServer,
|
|
@@ -299,14 +301,16 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
299
301
|
sessionKey: params.sessionKey
|
|
300
302
|
};
|
|
301
303
|
emitDynamicToolStartedDiagnostic(diagnosticContext);
|
|
304
|
+
const toolCall = handleDynamicToolCallWithTimeout({
|
|
305
|
+
call,
|
|
306
|
+
toolBridge,
|
|
307
|
+
signal: runAbortController.signal,
|
|
308
|
+
timeoutMs,
|
|
309
|
+
observeToolTerminal: sideRunParams.observeToolTerminal
|
|
310
|
+
});
|
|
311
|
+
activeDynamicToolCalls.add(toolCall);
|
|
302
312
|
try {
|
|
303
|
-
const response = await
|
|
304
|
-
call,
|
|
305
|
-
toolBridge,
|
|
306
|
-
signal: runAbortController.signal,
|
|
307
|
-
timeoutMs,
|
|
308
|
-
observeToolTerminal: sideRunParams.observeToolTerminal
|
|
309
|
-
});
|
|
313
|
+
const response = await toolCall;
|
|
310
314
|
emitDynamicToolTerminalDiagnostic({
|
|
311
315
|
...diagnosticContext,
|
|
312
316
|
response,
|
|
@@ -323,6 +327,8 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
323
327
|
terminalReason: runAbortController.signal.aborted ? resolveCodexToolAbortTerminalReason(runAbortController.signal) : "failed"
|
|
324
328
|
});
|
|
325
329
|
throw error;
|
|
330
|
+
} finally {
|
|
331
|
+
activeDynamicToolCalls.delete(toolCall);
|
|
326
332
|
}
|
|
327
333
|
});
|
|
328
334
|
removeRequestHandler = registerRequestHandler(client);
|
|
@@ -464,6 +470,7 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
464
470
|
params.opts?.abortSignal?.removeEventListener("abort", abortFromUpstream);
|
|
465
471
|
removeRequestHandler?.();
|
|
466
472
|
if (!runAbortController.signal.aborted) runAbortController.abort("codex_side_question_finished");
|
|
473
|
+
await Promise.allSettled(activeDynamicToolCalls);
|
|
467
474
|
try {
|
|
468
475
|
await cleanupCodexSideThread(client, {
|
|
469
476
|
threadId: childThreadId,
|
|
@@ -668,6 +675,7 @@ async function createCodexSideToolBridge(input) {
|
|
|
668
675
|
hookContext: {
|
|
669
676
|
agentId: input.sessionAgentId,
|
|
670
677
|
config: input.params.cfg,
|
|
678
|
+
contextWindowTokens: runtimeModel.contextWindow,
|
|
671
679
|
sessionId: input.params.sessionId,
|
|
672
680
|
sessionKey: input.params.sessionKey,
|
|
673
681
|
runId: input.runId,
|
|
@@ -1,18 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { B as flattenCodexDynamicToolFunctions, E as resolveCodexAppServerClientInstanceId, V as isJsonObject, _ as CodexAppServerRpcError, s as isCodexAppServerStartSelectionChangedError, v as getCodexAppServerClientInstanceId, w as isCodexAppServerPrewriteRequestCancellationError, x as isCodexAppServerConnectionClosedError } from "./shared-client-BVKE40c-.js";
|
|
2
|
+
import { A as CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME, E as resolveCodexPluginsPolicy, a as hashCodexAppServerBindingFingerprint, c as reclaimCurrentCodexSessionGeneration, f as codexSandboxPolicyForTurn, i as createCodexSessionGenerationSupersededError, k as CODEX_PLUGINS_MARKETPLACE_NAME, l as sessionBindingIdentity, n as assertCodexBindingMayBeReplaced, o as isCodexAppServerNativeAuthProfile, s as normalizeCodexAppServerBindingModelProvider } from "./session-binding-DlVQ-Pxs.js";
|
|
3
|
+
import { a as closeCodexStartupClientBestEffort, c as isCodexAppServerUnsafeSubscriptionError, i as assertCodexThreadResumeSubscription, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, r as CodexAppServerUnsafeSubscriptionError, u as unsubscribeCodexThreadBestEffort } from "./attempt-client-cleanup-Ia52yRWc.js";
|
|
4
|
+
import { i as assertCodexThreadStartResponse, n as assertCodexThreadForkResponse, r as assertCodexThreadResumeResponse } from "./protocol-validators-Dm4eXZmt.js";
|
|
5
|
+
import { a as serializeCodexAppInventoryError, i as defaultCodexAppInventoryCache, t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-DSXX-rXO.js";
|
|
6
|
+
import { t as isIncognitoSessionKey } from "./incognito-session-ET_ufDH-.js";
|
|
7
|
+
import { a as projectBoundedCodexThreadHistory } from "./transcript-mirror-uKA-A4tB.js";
|
|
8
|
+
import { SKILL_WORKSHOP_TOOL_NAME, buildSkillWorkshopPromptSection, embeddedAgentLog, formatErrorMessage, isActiveHarnessContextEngine, isHostScopedAgentToolActive } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
6
9
|
import * as crypto$1 from "node:crypto";
|
|
7
10
|
import crypto from "node:crypto";
|
|
8
11
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
-
import {
|
|
12
|
+
import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
10
13
|
import { redactSensitiveFieldValue, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
11
14
|
import { buildCodexUserMcpServersThreadConfigPatchForRuntime } from "openclaw/plugin-sdk/codex-mcp-projection";
|
|
12
15
|
import { isDiagnosticFlagEnabled } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
13
16
|
import { listRegisteredPluginAgentPromptGuidance } from "openclaw/plugin-sdk/plugin-runtime";
|
|
14
17
|
import { GPT5_HEARTBEAT_PROMPT_OVERLAY } from "openclaw/plugin-sdk/provider-model-shared";
|
|
15
18
|
import { INLINE_IMAGE_DATA_URL_PREFIX, sanitizeInlineImageDataUrl } from "openclaw/plugin-sdk/inline-image-data-url-runtime";
|
|
19
|
+
//#region extensions/codex/src/app-server/event-projector-values.ts
|
|
20
|
+
function readString(record, key) {
|
|
21
|
+
const value = record[key];
|
|
22
|
+
return typeof value === "string" ? value : void 0;
|
|
23
|
+
}
|
|
24
|
+
function normalizeNonEmptyString(value) {
|
|
25
|
+
if (typeof value !== "string") return;
|
|
26
|
+
return value.trim() || void 0;
|
|
27
|
+
}
|
|
28
|
+
function readNonEmptyString(record, key) {
|
|
29
|
+
return normalizeNonEmptyString(record[key]);
|
|
30
|
+
}
|
|
31
|
+
function readNonEmptyStringArray(record, key) {
|
|
32
|
+
const value = record[key];
|
|
33
|
+
if (!Array.isArray(value)) return [];
|
|
34
|
+
const entries = [];
|
|
35
|
+
for (const entry of value) {
|
|
36
|
+
const normalized = normalizeNonEmptyString(entry);
|
|
37
|
+
if (normalized) entries.push(normalized);
|
|
38
|
+
}
|
|
39
|
+
return entries;
|
|
40
|
+
}
|
|
41
|
+
function readNullableString(record, key) {
|
|
42
|
+
const value = record[key];
|
|
43
|
+
if (value === null) return null;
|
|
44
|
+
return typeof value === "string" ? value : void 0;
|
|
45
|
+
}
|
|
46
|
+
function readNumber(record, key) {
|
|
47
|
+
const value = record[key];
|
|
48
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
49
|
+
}
|
|
50
|
+
function readNonNegativeInteger(record, key) {
|
|
51
|
+
const value = readNumber(record, key);
|
|
52
|
+
return value !== void 0 && Number.isInteger(value) && value >= 0 ? value : void 0;
|
|
53
|
+
}
|
|
54
|
+
function readCodexErrorNotificationMessage(record) {
|
|
55
|
+
const error = record.error;
|
|
56
|
+
return isJsonObject(error) ? readString(error, "message") : void 0;
|
|
57
|
+
}
|
|
58
|
+
function readHookOutputEntries(value) {
|
|
59
|
+
if (!Array.isArray(value)) return [];
|
|
60
|
+
return value.flatMap((entry) => {
|
|
61
|
+
if (!isJsonObject(entry)) return [];
|
|
62
|
+
const text = readString(entry, "text");
|
|
63
|
+
if (!text) return [];
|
|
64
|
+
const kind = readString(entry, "kind");
|
|
65
|
+
return [{
|
|
66
|
+
...kind ? { kind } : {},
|
|
67
|
+
text
|
|
68
|
+
}];
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function splitPlanText(text) {
|
|
72
|
+
return text.split(/\r?\n/).map((line) => line.trim().replace(/^[-*]\s+/, "")).filter((line) => line.length > 0);
|
|
73
|
+
}
|
|
74
|
+
function extractRawAssistantText(item) {
|
|
75
|
+
return (Array.isArray(item.content) ? item.content : []).flatMap((entry) => {
|
|
76
|
+
if (!isJsonObject(entry)) return [];
|
|
77
|
+
const type = readString(entry, "type");
|
|
78
|
+
if (type !== "output_text" && type !== "text") return [];
|
|
79
|
+
const value = readString(entry, "text");
|
|
80
|
+
return value ? [value] : [];
|
|
81
|
+
}).join("").trim() || void 0;
|
|
82
|
+
}
|
|
83
|
+
function readItemString(item, key) {
|
|
84
|
+
const value = item[key];
|
|
85
|
+
return typeof value === "string" ? value : void 0;
|
|
86
|
+
}
|
|
87
|
+
function readItem(value) {
|
|
88
|
+
if (!isJsonObject(value)) return;
|
|
89
|
+
const type = typeof value.type === "string" ? value.type : void 0;
|
|
90
|
+
const id = typeof value.id === "string" ? value.id : void 0;
|
|
91
|
+
if (!type || !id) return;
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
16
95
|
//#region extensions/codex/src/app-server/plugin-inventory.ts
|
|
17
96
|
/**
|
|
18
97
|
* Reads Codex plugin marketplace state and app inventory to decide which
|
|
@@ -864,13 +943,9 @@ function resolveCodexContextEngineProjectionMaxChars(params) {
|
|
|
864
943
|
reserveTokens: params.reserveTokens
|
|
865
944
|
}) * APPROX_RENDERED_CHARS_PER_TOKEN);
|
|
866
945
|
}
|
|
867
|
-
/**
|
|
868
|
-
function resolveCodexContextEngineProjectionReserveTokens(
|
|
869
|
-
|
|
870
|
-
const configuredReserveTokens = toNonNegativeInt(asRecord(compaction)?.reserveTokens);
|
|
871
|
-
const configuredReserveTokensFloor = toNonNegativeInt(asRecord(compaction)?.reserveTokensFloor);
|
|
872
|
-
if (configuredReserveTokens !== void 0) return Math.max(configuredReserveTokens, configuredReserveTokensFloor ?? DEFAULT_CODEX_PROJECTION_RESERVE_TOKENS);
|
|
873
|
-
if (configuredReserveTokensFloor !== void 0) return configuredReserveTokensFloor;
|
|
946
|
+
/** Returns the fixed reserve used for Codex context-engine projections. */
|
|
947
|
+
function resolveCodexContextEngineProjectionReserveTokens() {
|
|
948
|
+
return DEFAULT_CODEX_PROJECTION_RESERVE_TOKENS;
|
|
874
949
|
}
|
|
875
950
|
/** Fits projected context prompts under Codex app-server turn/start text limits. */
|
|
876
951
|
function fitCodexProjectedContextForTurnStart(params) {
|
|
@@ -918,13 +993,6 @@ function resolveProjectionPromptBudgetTokens(params) {
|
|
|
918
993
|
const effectiveReserveTokens = Math.min(requestedReserveTokens, Math.max(0, params.contextTokenBudget - minPromptBudget));
|
|
919
994
|
return Math.max(1, params.contextTokenBudget - effectiveReserveTokens);
|
|
920
995
|
}
|
|
921
|
-
function asRecord(value) {
|
|
922
|
-
return value && typeof value === "object" ? value : void 0;
|
|
923
|
-
}
|
|
924
|
-
function toNonNegativeInt(value) {
|
|
925
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) return;
|
|
926
|
-
return Math.floor(value);
|
|
927
|
-
}
|
|
928
996
|
function dropDuplicateTrailingPrompt(messages, prompt) {
|
|
929
997
|
if (!prompt) return messages;
|
|
930
998
|
const trailing = messages.at(-1);
|
|
@@ -1086,7 +1154,7 @@ function buildContextEngineBinding(params, projection) {
|
|
|
1086
1154
|
contextTokenBudget: params.contextTokenBudget,
|
|
1087
1155
|
projectionMaxChars: resolveCodexContextEngineProjectionMaxChars({
|
|
1088
1156
|
contextTokenBudget: params.contextTokenBudget,
|
|
1089
|
-
reserveTokens: resolveCodexContextEngineProjectionReserveTokens(
|
|
1157
|
+
reserveTokens: resolveCodexContextEngineProjectionReserveTokens()
|
|
1090
1158
|
})
|
|
1091
1159
|
}),
|
|
1092
1160
|
projection: projection ? buildContextEngineProjectionBinding(projection) : void 0
|
|
@@ -1211,129 +1279,6 @@ function compareJsonFingerprint(left, right) {
|
|
|
1211
1279
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
1212
1280
|
}
|
|
1213
1281
|
//#endregion
|
|
1214
|
-
//#region extensions/codex/src/app-server/attempt-client-cleanup.ts
|
|
1215
|
-
/**
|
|
1216
|
-
* Best-effort cleanup helpers for Codex app-server startup attempts and turns.
|
|
1217
|
-
*/
|
|
1218
|
-
/** Timeout for best-effort app-server turn interruption during cleanup. */
|
|
1219
|
-
const CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS = 5e3;
|
|
1220
|
-
/** Timeout for best-effort thread unsubscribe during cleanup. */
|
|
1221
|
-
const CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS = 5e3;
|
|
1222
|
-
/** Raised when a thread subscription may be live on a client OpenClaw no longer controls. */
|
|
1223
|
-
var CodexAppServerUnsafeSubscriptionError = class extends Error {
|
|
1224
|
-
constructor(message, options) {
|
|
1225
|
-
super(message, options);
|
|
1226
|
-
this.name = "CodexAppServerUnsafeSubscriptionError";
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
function isCodexAppServerUnsafeSubscriptionError(error) {
|
|
1230
|
-
return error instanceof CodexAppServerUnsafeSubscriptionError;
|
|
1231
|
-
}
|
|
1232
|
-
/** Asserts Codex resumed the exact thread this attempt subscribed to. */
|
|
1233
|
-
function assertCodexThreadResumeSubscription(requestedThreadId, returnedThreadId) {
|
|
1234
|
-
if (returnedThreadId !== requestedThreadId) throw new CodexAppServerUnsafeSubscriptionError(`Codex thread/resume returned ${returnedThreadId} for ${requestedThreadId}`);
|
|
1235
|
-
}
|
|
1236
|
-
async function closeClientAndWaitIfAvailable(client) {
|
|
1237
|
-
const closeable = client;
|
|
1238
|
-
if (typeof closeable.closeAndWait === "function") {
|
|
1239
|
-
await closeable.closeAndWait();
|
|
1240
|
-
return;
|
|
1241
|
-
}
|
|
1242
|
-
closeable.close?.();
|
|
1243
|
-
}
|
|
1244
|
-
async function closeCodexStartupClientBestEffort(client) {
|
|
1245
|
-
if (!client) return;
|
|
1246
|
-
const unclaimedSharedClient = clearSharedCodexAppServerClientIfCurrentAndUnclaimed(client);
|
|
1247
|
-
if (unclaimedSharedClient.closed) {
|
|
1248
|
-
await closeClientAndWaitIfAvailable(client);
|
|
1249
|
-
return;
|
|
1250
|
-
}
|
|
1251
|
-
if (unclaimedSharedClient.found) {
|
|
1252
|
-
if (retireSharedCodexAppServerClientIfCurrent(client)?.closed) await closeClientAndWaitIfAvailable(client);
|
|
1253
|
-
return;
|
|
1254
|
-
}
|
|
1255
|
-
const retiredSharedClient = retireSharedCodexAppServerClientIfCurrent(client);
|
|
1256
|
-
if (retiredSharedClient) {
|
|
1257
|
-
if (retiredSharedClient.closed) await closeClientAndWaitIfAvailable(client);
|
|
1258
|
-
return;
|
|
1259
|
-
}
|
|
1260
|
-
if (clearSharedCodexAppServerClientIfCurrent(client)) {
|
|
1261
|
-
await closeClientAndWaitIfAvailable(client);
|
|
1262
|
-
return;
|
|
1263
|
-
}
|
|
1264
|
-
await closeClientAndWaitIfAvailable(client);
|
|
1265
|
-
}
|
|
1266
|
-
/** Sends a turn interrupt without blocking abort cleanup on app-server errors. */
|
|
1267
|
-
function interruptCodexTurnBestEffort(client, params) {
|
|
1268
|
-
const requestOptions = params.timeoutMs && Number.isFinite(params.timeoutMs) && params.timeoutMs > 0 ? { timeoutMs: params.timeoutMs } : void 0;
|
|
1269
|
-
const requestParams = {
|
|
1270
|
-
threadId: params.threadId,
|
|
1271
|
-
turnId: params.turnId
|
|
1272
|
-
};
|
|
1273
|
-
try {
|
|
1274
|
-
const interrupt = requestOptions ? client.request("turn/interrupt", requestParams, requestOptions) : client.request("turn/interrupt", requestParams);
|
|
1275
|
-
Promise.resolve(interrupt).catch((error) => {
|
|
1276
|
-
embeddedAgentLog.debug("codex app-server turn interrupt failed during abort", { error });
|
|
1277
|
-
});
|
|
1278
|
-
} catch (error) {
|
|
1279
|
-
embeddedAgentLog.debug("codex app-server turn interrupt failed during abort", { error });
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
/** Unsubscribes from a thread while swallowing cleanup-only failures. */
|
|
1283
|
-
async function unsubscribeCodexThreadBestEffort(client, params) {
|
|
1284
|
-
try {
|
|
1285
|
-
await client.request("thread/unsubscribe", { threadId: params.threadId }, { timeoutMs: params.timeoutMs });
|
|
1286
|
-
return true;
|
|
1287
|
-
} catch (error) {
|
|
1288
|
-
embeddedAgentLog.debug("codex app-server thread unsubscribe cleanup failed", {
|
|
1289
|
-
threadId: params.threadId,
|
|
1290
|
-
error
|
|
1291
|
-
});
|
|
1292
|
-
return false;
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
/**
|
|
1296
|
-
* Retires the shared client after a timed-out turn so later runs do not reuse a
|
|
1297
|
-
* potentially wedged app-server connection.
|
|
1298
|
-
*/
|
|
1299
|
-
async function retireCodexAppServerClientAfterTimedOutTurn(client, params) {
|
|
1300
|
-
const retiredSharedClient = retireSharedCodexAppServerClientIfCurrent(client, { failActiveLeases: params.suspectPhysicalClient });
|
|
1301
|
-
const detachedSharedClient = Boolean(retiredSharedClient);
|
|
1302
|
-
if (!(params.suspectPhysicalClient && (retiredSharedClient?.closed ?? false))) {
|
|
1303
|
-
interruptCodexTurnBestEffort(client, {
|
|
1304
|
-
threadId: params.threadId,
|
|
1305
|
-
turnId: params.turnId,
|
|
1306
|
-
timeoutMs: CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS
|
|
1307
|
-
});
|
|
1308
|
-
await unsubscribeCodexThreadBestEffort(client, {
|
|
1309
|
-
threadId: params.threadId,
|
|
1310
|
-
timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS
|
|
1311
|
-
});
|
|
1312
|
-
}
|
|
1313
|
-
let closedClient = retiredSharedClient?.closed ?? false;
|
|
1314
|
-
if (!detachedSharedClient) {
|
|
1315
|
-
const close = client.close;
|
|
1316
|
-
if (typeof close === "function") try {
|
|
1317
|
-
close.call(client);
|
|
1318
|
-
closedClient = true;
|
|
1319
|
-
} catch (error) {
|
|
1320
|
-
embeddedAgentLog.debug("codex app-server client close failed during timeout cleanup", {
|
|
1321
|
-
threadId: params.threadId,
|
|
1322
|
-
turnId: params.turnId,
|
|
1323
|
-
error
|
|
1324
|
-
});
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
embeddedAgentLog.warn("codex app-server client retired after timed-out turn", {
|
|
1328
|
-
threadId: params.threadId,
|
|
1329
|
-
turnId: params.turnId,
|
|
1330
|
-
reason: params.reason,
|
|
1331
|
-
detachedSharedClient,
|
|
1332
|
-
closedClient,
|
|
1333
|
-
activeSharedClientLeases: retiredSharedClient?.activeLeases ?? 0
|
|
1334
|
-
});
|
|
1335
|
-
}
|
|
1336
|
-
//#endregion
|
|
1337
1282
|
//#region extensions/codex/src/app-server/dynamic-tool-profile.ts
|
|
1338
1283
|
/** Tool names owned by Codex app-server and normally excluded from OpenClaw dynamic tools. */
|
|
1339
1284
|
const CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES = [
|
|
@@ -1410,7 +1355,8 @@ function filterCodexDynamicToolsWithOpenClawShell(tools, config, env = process.e
|
|
|
1410
1355
|
function filterCodexDynamicToolsWithOptions(tools, config, env, options) {
|
|
1411
1356
|
const excludes = /* @__PURE__ */ new Set();
|
|
1412
1357
|
for (const name of CODEX_NATIVE_GOAL_TOOL_EXCLUDES) excludes.add(name);
|
|
1413
|
-
if (
|
|
1358
|
+
if (isForcedPrivateQaCodexRuntime(env)) excludes.add("apply_patch");
|
|
1359
|
+
else for (const name of CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES) {
|
|
1414
1360
|
if (options.preserveOpenClawShell && CODEX_APP_SERVER_OWNED_SHELL_TOOL_EXCLUDES.has(name)) continue;
|
|
1415
1361
|
excludes.add(name);
|
|
1416
1362
|
}
|
|
@@ -1866,7 +1812,8 @@ function buildThreadStartParams(params, options) {
|
|
|
1866
1812
|
...resolveCodexThreadEnvironmentSelection(options),
|
|
1867
1813
|
developerInstructions: options.developerInstructions ?? buildDeveloperInstructions(params, { dynamicTools: options.dynamicTools }),
|
|
1868
1814
|
dynamicTools: [...options.dynamicTools],
|
|
1869
|
-
experimentalRawEvents: true
|
|
1815
|
+
experimentalRawEvents: true,
|
|
1816
|
+
...isIncognitoSessionKey(params.sessionKey) ? { ephemeral: true } : {}
|
|
1870
1817
|
};
|
|
1871
1818
|
}
|
|
1872
1819
|
function buildThreadResumeParams(params, options) {
|
|
@@ -2208,6 +2155,7 @@ async function resumeExistingCodexThread(params, context) {
|
|
|
2208
2155
|
}
|
|
2209
2156
|
}
|
|
2210
2157
|
async function startFreshCodexThread(params, context) {
|
|
2158
|
+
const clientId = resolveCodexAppServerClientInstanceId(params.client);
|
|
2211
2159
|
const { bindingIdentity, startModelSelection, startModelProvider, userMcpServersConfigPatch, dynamicToolsFingerprint, dynamicToolsContainDeferred, webSearchThreadConfigFingerprint, userMcpServersFingerprint, ringZeroConfigFingerprint, ringZeroClientInstanceId, networkProxyConfigFingerprint, contextEngineBinding, environmentSelectionFingerprint, hostSystemAgentActive, ringZeroActive, ringZeroInheritedMcpServerNames, lifecycleTiming, normalizeBindingModelProvider, throwIfAborted, prebuiltPluginThreadConfig, preserveExistingBinding, rotatedContextEngineBinding } = context;
|
|
2212
2160
|
const pluginThreadConfig = params.pluginThreadConfig?.enabled ? prebuiltPluginThreadConfig ?? await lifecycleTiming.measure("plugin-config-build", () => params.pluginThreadConfig?.build()) : void 0;
|
|
2213
2161
|
const finalConfigPatch = params.buildFinalConfigPatch?.({ action: "start" }) ?? {
|
|
@@ -2261,6 +2209,7 @@ async function startFreshCodexThread(params, context) {
|
|
|
2261
2209
|
if: { kind: "absent" },
|
|
2262
2210
|
binding: {
|
|
2263
2211
|
threadId: response.thread.id,
|
|
2212
|
+
...clientId ? { clientId } : {},
|
|
2264
2213
|
cwd: params.cwd,
|
|
2265
2214
|
authProfileId: params.params.authProfileId,
|
|
2266
2215
|
model: response.model ?? startParams.model ?? params.params.modelId,
|
|
@@ -2303,6 +2252,7 @@ async function startFreshCodexThread(params, context) {
|
|
|
2303
2252
|
});
|
|
2304
2253
|
return {
|
|
2305
2254
|
threadId: response.thread.id,
|
|
2255
|
+
...clientId ? { clientId } : {},
|
|
2306
2256
|
cwd: params.cwd,
|
|
2307
2257
|
authProfileId: params.params.authProfileId,
|
|
2308
2258
|
model: response.model ?? startParams.model ?? params.params.modelId,
|
|
@@ -2625,7 +2575,7 @@ function buildPendingSupervisionProbeForkParams(params, pending) {
|
|
|
2625
2575
|
...params.appServer.serviceTier !== void 0 ? { serviceTier: params.appServer.serviceTier } : {},
|
|
2626
2576
|
config: runtimeConfig,
|
|
2627
2577
|
developerInstructions: params.developerInstructions ?? buildDeveloperInstructions(params.attempt, { dynamicTools: params.dynamicTools }),
|
|
2628
|
-
ephemeral:
|
|
2578
|
+
ephemeral: isIncognitoSessionKey(params.attempt.sessionKey),
|
|
2629
2579
|
threadSource: "appServer",
|
|
2630
2580
|
excludeTurns: true
|
|
2631
2581
|
};
|
|
@@ -2741,6 +2691,8 @@ async function archiveSupervisionArtifact(client, threadId) {
|
|
|
2741
2691
|
//#endregion
|
|
2742
2692
|
//#region extensions/codex/src/app-server/thread-lifecycle-run.ts
|
|
2743
2693
|
async function startOrResumeThread(params) {
|
|
2694
|
+
const incognito = isIncognitoSessionKey(params.params.sessionKey);
|
|
2695
|
+
const clientId = resolveCodexAppServerClientInstanceId(params.client);
|
|
2744
2696
|
const bindingIdentity = sessionBindingIdentity({
|
|
2745
2697
|
sessionId: params.params.sessionId,
|
|
2746
2698
|
sessionKey: params.params.sessionKey,
|
|
@@ -2808,7 +2760,7 @@ async function startOrResumeThread(params) {
|
|
|
2808
2760
|
bindingStore: params.bindingStore,
|
|
2809
2761
|
identity: bindingIdentity,
|
|
2810
2762
|
config: params.params.config
|
|
2811
|
-
}))) throw
|
|
2763
|
+
}))) throw createCodexSessionGenerationSupersededError(bindingIdentity.sessionId);
|
|
2812
2764
|
}
|
|
2813
2765
|
if (binding?.pendingSupervisionBranch) {
|
|
2814
2766
|
const pendingBinding = binding;
|
|
@@ -2841,6 +2793,7 @@ async function startOrResumeThread(params) {
|
|
|
2841
2793
|
normalizeBindingModelProvider,
|
|
2842
2794
|
bindingPatch: {
|
|
2843
2795
|
cwd: params.cwd,
|
|
2796
|
+
...clientId ? { clientId } : {},
|
|
2844
2797
|
authProfileId: void 0,
|
|
2845
2798
|
preserveNativeModel: true,
|
|
2846
2799
|
dynamicToolsFingerprint,
|
|
@@ -3034,6 +2987,28 @@ async function startOrResumeThread(params) {
|
|
|
3034
2987
|
embeddedAgentLog.debug("codex app-server dynamic tool catalog changed; starting a new thread", { threadId: binding.threadId });
|
|
3035
2988
|
await clearCurrentBinding("rotating a stale thread binding");
|
|
3036
2989
|
}
|
|
2990
|
+
} else if (incognito) {
|
|
2991
|
+
if (binding.clientId && binding.clientId === clientId) {
|
|
2992
|
+
params.buildFinalConfigPatch?.({
|
|
2993
|
+
action: "resume",
|
|
2994
|
+
binding
|
|
2995
|
+
});
|
|
2996
|
+
throwIfAborted();
|
|
2997
|
+
lifecycleTiming.mark("thread-ready");
|
|
2998
|
+
lifecycleTiming.logSummary({
|
|
2999
|
+
runId: params.params.runId,
|
|
3000
|
+
sessionId: params.params.sessionId,
|
|
3001
|
+
sessionKey: params.params.sessionKey,
|
|
3002
|
+
threadId: binding.threadId,
|
|
3003
|
+
action: "resumed"
|
|
3004
|
+
});
|
|
3005
|
+
return {
|
|
3006
|
+
...binding,
|
|
3007
|
+
lifecycle: { action: "resumed" }
|
|
3008
|
+
};
|
|
3009
|
+
}
|
|
3010
|
+
await clearCurrentBinding("rotating an unavailable ephemeral thread binding");
|
|
3011
|
+
binding = void 0;
|
|
3037
3012
|
} else {
|
|
3038
3013
|
const resumed = await resumeExistingCodexThread(params, {
|
|
3039
3014
|
binding,
|
|
@@ -3187,7 +3162,7 @@ function buildTurnStartParams(params, options) {
|
|
|
3187
3162
|
cwd: options.cwd,
|
|
3188
3163
|
approvalPolicy: options.appServer.approvalPolicy,
|
|
3189
3164
|
approvalsReviewer: options.appServer.approvalsReviewer,
|
|
3190
|
-
...useThreadPermissionProfile ? {} : { sandboxPolicy: options.sandboxPolicy ?? codexSandboxPolicyForTurn(options.appServer.sandbox, options.cwd) },
|
|
3165
|
+
...useThreadPermissionProfile ? {} : { sandboxPolicy: options.sandboxPolicy ?? codexSandboxPolicyForTurn(options.appServer.sandbox, options.cwd, options.appServer.start?.args) },
|
|
3191
3166
|
...modelSelection ? {
|
|
3192
3167
|
model: modelSelection.model,
|
|
3193
3168
|
personality: CODEX_NATIVE_PERSONALITY_NONE
|
|
@@ -3199,8 +3174,7 @@ function buildTurnStartParams(params, options) {
|
|
|
3199
3174
|
model: modelSelection.model,
|
|
3200
3175
|
turnScopedDeveloperInstructions: options.turnScopedDeveloperInstructions,
|
|
3201
3176
|
skillsCollaborationInstructions: options.skillsCollaborationInstructions,
|
|
3202
|
-
memoryCollaborationInstructions: options.memoryCollaborationInstructions
|
|
3203
|
-
heartbeatCollaborationInstructions: options.heartbeatCollaborationInstructions
|
|
3177
|
+
memoryCollaborationInstructions: options.memoryCollaborationInstructions
|
|
3204
3178
|
}) } : {}
|
|
3205
3179
|
};
|
|
3206
3180
|
}
|
|
@@ -3218,7 +3192,7 @@ function buildTurnCollaborationMode(params, options = {}) {
|
|
|
3218
3192
|
function buildTurnScopedCollaborationInstructions(params, options = {}) {
|
|
3219
3193
|
const contextInstructions = joinPresentSections(options.turnScopedDeveloperInstructions, options.memoryCollaborationInstructions, options.skillsCollaborationInstructions);
|
|
3220
3194
|
if (params.trigger === "cron") return joinPresentSections(buildCronCollaborationInstructions(), contextInstructions);
|
|
3221
|
-
if (params.trigger === "heartbeat" && params.bootstrapContextRunKind !== "commitment-only") return joinPresentSections(buildHeartbeatCollaborationInstructions(), contextInstructions
|
|
3195
|
+
if (params.trigger === "heartbeat" && params.bootstrapContextRunKind !== "commitment-only") return joinPresentSections(buildHeartbeatCollaborationInstructions(), contextInstructions);
|
|
3222
3196
|
if (contextInstructions?.trim()) return joinPresentSections(buildDefaultCollaborationInstructions(), contextInstructions);
|
|
3223
3197
|
return null;
|
|
3224
3198
|
}
|
|
@@ -3256,4 +3230,4 @@ function joinPresentSections(...sections) {
|
|
|
3256
3230
|
return sections.filter((section) => Boolean(section?.trim())).join("\n\n");
|
|
3257
3231
|
}
|
|
3258
3232
|
//#endregion
|
|
3259
|
-
export {
|
|
3233
|
+
export { readHookOutputEntries as $, resolveCodexDynamicToolsLoading as A, resolveCodexContextEngineProjectionReserveTokens as B, readCodexSupportedReasoningEfforts as C, isForcedPrivateQaCodexRuntime as D, filterCodexDynamicToolsWithOpenClawShell as E, buildContextEngineBinding as F, mergeCodexThreadConfigs as G, buildCodexPluginThreadConfig as H, isContextEngineBindingCompatible as I, pluginReadParams as J, shouldBuildCodexPluginThreadConfig as K, fitCodexProjectedContextForTurnStart as L, areCodexDynamicToolFingerprintsCompatible as M, codexDynamicToolsFingerprint as N, isSystemAgentOnlyCodexDynamicToolAllowlist as O, codexLegacyDynamicToolsFingerprint as P, readCodexErrorNotificationMessage as Q, projectContextEngineAssemblyForCodex as R, resolveReasoningEffort as S, filterCodexDynamicTools as T, buildCodexPluginThreadConfigInputFingerprint as U, buildCodexPluginAppsConfigPatchFromPolicyContext as V, buildCodexPluginThreadConfigTimeoutFallback as W, extractRawAssistantText as X, resolveRecoverableCodexPluginConfigKeys as Y, normalizeNonEmptyString as Z, CODEX_NATIVE_PERSONALITY_NONE as _, sanitizeCodexHistoryImagePayloads as a, readNullableString as at, resolveCodexAppServerThreadModelSelection as b, resumeCodexAppServerThread as c, splitPlanText as ct, buildCodexRingZeroThreadConfigPatch as d, readItem as et, buildCodexRuntimeThreadConfig as f, buildDeveloperInstructions as g, resolveCodexWebSearchPlan as h, invalidInlineImageText as i, readNonNegativeInteger as it, resolveCodexDynamicToolsLoadingForRuntime as j, normalizeCodexDynamicToolName as k, assertCodexRingZeroHasNoManagedHooks as l, buildCodexNativeWebSearchThreadConfig as m, buildTurnStartParams as n, readNonEmptyString as nt, sanitizeInlineImageDataUrl$1 as o, readNumber as ot, readCodexInheritedMcpServerNames as p, ensureCodexPluginActivation as q, buildCodexUserInput as r, readNonEmptyStringArray as rt, startOrResumeThread as s, readString as st, buildTurnCollaborationMode as t, readItemString as tt, attestCodexRingZeroThreadHasNoMcpServers as u, resolveCodexAppServerModelProvider as v, isCodexAppServerProfilerEnabled as w, resolveCodexBindingModelProviderFallback as x, resolveCodexAppServerRequestModelSelection as y, resolveCodexContextEngineProjectionMaxChars as z };
|