@openclaw/codex 2026.10.5-beta.4 → 2026.10.10-beta.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/README.md +10 -3
- package/dist/.setup/{account-usage-runtime-CoVpNIlD.mjs → account-usage-runtime-DDCDkvtl.mjs} +15 -9
- package/dist/.setup/{app-server-policy-D_zv8J7V.mjs → app-server-policy-Cog6mm2i.mjs} +1 -1
- package/dist/.setup/{apply-BXDMd05l.mjs → apply-BVSXYkTV.mjs} +11 -11
- package/dist/.setup/{attempt-client-cleanup-zNuNTKVr.mjs → attempt-client-cleanup-6OcbMH46.mjs} +14 -8
- package/dist/.setup/attempt-terminal-sZutF0WY.mjs +1 -0
- package/dist/.setup/{attempt-workspace-context-CcwP3DA3.mjs → attempt-workspace-context-GYPLawX6.mjs} +2 -2
- package/dist/.setup/{auth-binding-BaxlhaNx.mjs → auth-binding-830RLAJW.mjs} +2 -2
- package/dist/.setup/{auth-cache-key-f8ODJ_OX.mjs → auth-cache-key-CVcYw8HD.mjs} +92 -80
- package/dist/.setup/{auth-profile-CgHQ8Vot.mjs → auth-profile-auwzSwwy.mjs} +14 -8
- package/dist/.setup/{auth-profile-health-oHizqgye.mjs → auth-profile-health-BVPZU9I8.mjs} +15 -8
- package/dist/.setup/{auth-profile-selection-hr8ocLtz.mjs → auth-profile-selection-Bp5PDk3W.mjs} +24 -7
- package/dist/.setup/{binding-connection-B7HAAZSI.mjs → binding-connection-GTgUj9pi.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-DAXn7iFl.mjs → binding-connection.runtime-RcWR3vQu.mjs} +4 -3
- package/dist/.setup/{bounded-turn-isolation-BfDAo-qZ.mjs → bounded-turn-isolation-D8CDrAVX.mjs} +3 -3
- package/dist/.setup/{bounded-turn-DfIJtRlv.mjs → bounded-turn-mN_ekXYW.mjs} +18 -22
- package/dist/.setup/{build-state-Ds14X10-.mjs → build-state-VcujMRqP.mjs} +1 -1
- package/dist/.setup/{capabilities-DbOzOglY.mjs → capabilities-DAS-JX1z.mjs} +1 -1
- package/dist/.setup/{client-D93nbdB8.mjs → client-BS8X7HmG.mjs} +47 -317
- package/dist/.setup/{client-catalog-response-CuVLp4I0.mjs → client-catalog-response-jM38o5w1.mjs} +2 -2
- package/dist/.setup/client-initialize-CjgZcX61.mjs +165 -0
- package/dist/.setup/{command-dispatch-DxdH5a9-.mjs → command-dispatch-DzXbHqCn.mjs} +3 -3
- package/dist/.setup/{command-formatters-xW9KpoSZ.mjs → command-formatters-B_7-QZ1c.mjs} +2 -2
- package/dist/.setup/{command-handlers-fiYvYYq0.mjs → command-handlers-tfb5Uq-O.mjs} +539 -406
- package/dist/.setup/command-rpc-SXqLQukR.mjs +296 -0
- package/dist/.setup/compact-M-JxLcbZ.mjs +823 -0
- package/dist/.setup/{computer-use-DL2v3Kxq.mjs → computer-use-FqQ-Flbl.mjs} +21 -68
- package/dist/.setup/{config-C1YVVLEA.mjs → config-BfrAlTMT.mjs} +3 -3
- package/dist/.setup/{config-options-DDzeNQ8m.mjs → config-options-DMFZkd3X.mjs} +1 -1
- package/dist/.setup/{config-runtime-DWzK-k0n.mjs → config-runtime-BZRizyuG.mjs} +2 -2
- package/dist/.setup/{context-engine-projection-ps-yn_ci.mjs → context-engine-projection-PIeLSnR-.mjs} +16 -30
- package/dist/.setup/{conversation-binding-BieJZRRV.mjs → conversation-binding-C7MZy-Cx.mjs} +228 -116
- package/dist/.setup/{conversation-binding-data-UgLuTSQT.mjs → conversation-binding-data-khgW0n-o.mjs} +4 -2
- package/dist/.setup/{conversation-control-GXM3unE4.mjs → conversation-control-B2EpVZEb.mjs} +53 -23
- package/dist/.setup/{cyber-failover-D4dgNfFf.mjs → cyber-failover-CqEZoQsj.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-ljgGGL0s.mjs → cyber-failover-notice-poL3Advd.mjs} +1 -1
- package/dist/.setup/{doctor-start-options-JjTAl-q_.mjs → doctor-start-options-8uIBXIzR.mjs} +8 -5
- package/dist/.setup/{dynamic-tool-build-DcaPmBlE.mjs → dynamic-tool-build-BjFAIG-f.mjs} +208 -218
- package/dist/.setup/{dynamic-tools-CnQFnNKH.mjs → dynamic-tools-XqWsVjcC.mjs} +344 -118
- package/dist/.setup/{effective-mcp-catalog-B5HKFZNK.mjs → effective-mcp-catalog-C3ta5hHc.mjs} +11 -9
- package/dist/.setup/{ephemeral-turn-De3qb8EQ.mjs → ephemeral-turn-1ZF17fUR.mjs} +5 -4
- package/dist/.setup/{event-projector-assistant-message-CLMKN4x-.mjs → event-projector-assistant-message-ChOAY7rW.mjs} +16 -11
- package/dist/.setup/{event-projector-usage-BpKfdoTm.mjs → event-projector-usage-CBY0Hkga.mjs} +2 -2
- package/dist/.setup/{event-projector-values-CLvG1Hil.mjs → event-projector-values-yf4us9Pf.mjs} +1 -1
- package/dist/.setup/experimental-features-uGnVDtp-.mjs +19 -0
- package/dist/.setup/inference-context-mv_dBpAL.mjs +209 -0
- package/dist/.setup/{inference-dispatch-CO6tTs4q.mjs → inference-dispatch-C2zVSnrr.mjs} +2 -2
- package/dist/.setup/{inference-metadata-DCvcG_N_.mjs → inference-metadata-CYFWLHVk.mjs} +3 -1
- package/dist/.setup/{inference-proxy-BDWV0djM.mjs → inference-proxy-yd3hr2dr.mjs} +8 -8
- package/dist/.setup/installed-probe-lVC1X5ve.mjs +185 -0
- package/dist/.setup/{isolated-completion-BPJdvk5F.mjs → isolated-completion-P-r8NRE4.mjs} +7 -7
- package/dist/.setup/managed-binary-DbKvGXKl.mjs +395 -0
- package/dist/.setup/{mcp-app-session-preparation-Dz2GOwyE.mjs → mcp-app-session-preparation-fnsnCovu.mjs} +18 -14
- package/dist/.setup/{model-catalog-ZNwltCKl.mjs → model-catalog-Y_esgRPY.mjs} +28 -17
- package/dist/.setup/{models-BHpbAuz8.mjs → models-BWLEUo2E.mjs} +3 -3
- package/dist/.setup/{native-auth-esN5MdIv.mjs → native-auth-DpZIaY8N.mjs} +7 -4
- package/dist/.setup/native-execution-policy-D09tLP-u.mjs +152 -0
- package/dist/.setup/{native-hook-relay-wq7jrNLk.mjs → native-hook-relay-C7aaLJaP.mjs} +45 -10
- package/dist/.setup/{native-mcp-app-DX3nyTtc.mjs → native-mcp-app-CsWj-v_x.mjs} +5 -5
- package/dist/.setup/{native-skill-isolation-DSBeF-Yy.mjs → native-skill-isolation-CMimsKYy.mjs} +7 -7
- package/dist/.setup/{native-subagent-monitor-DOLEIf9r.mjs → native-subagent-monitor-CFE7b4oC.mjs} +485 -239
- package/dist/.setup/{native-subagent-pending-assignments-DmVhedNs.mjs → native-subagent-pending-assignments-CTinVtjo.mjs} +1 -1
- package/dist/.setup/{native-task-assignments-DimsQ9Qa.mjs → native-task-assignments-YJopbaVO.mjs} +9 -5
- package/dist/.setup/{node-cli-sessions-CzKg2nGq.mjs → node-cli-sessions-BuJnBnEq.mjs} +7 -4
- package/dist/.setup/{node-exec-server.runtime-BWkULhBM.mjs → node-exec-server.runtime-CP7RC1Nd.mjs} +3 -3
- package/dist/.setup/{plan-41-YOBMq.mjs → plan-B4cHgqNv.mjs} +7 -20
- package/dist/.setup/{plugin-activation-D7WkJMvU.mjs → plugin-activation-CXPWe-hl.mjs} +4 -4
- package/dist/.setup/{plugin-app-cache-key-Bg9DbDI6.mjs → plugin-app-cache-key-DRb-niJc.mjs} +17 -55
- package/dist/.setup/{plugin-approval-roundtrip-CD88q3yx.mjs → plugin-approval-roundtrip-DIZHLbAM.mjs} +1 -1
- package/dist/.setup/{plugin-inventory-CYgdo14P.mjs → plugin-inventory-DE9wcaeH.mjs} +2 -2
- package/dist/.setup/{plugin-metadata-cache-Bi8TAPwX.mjs → plugin-metadata-cache-BqC-a6Fb.mjs} +2 -15
- package/dist/.setup/{project-doc-thread-config-BVcvnps8.mjs → project-doc-thread-config-B0UI3f1D.mjs} +6 -6
- package/dist/.setup/protocol-CaPAVwe9.mjs +12 -0
- package/dist/.setup/{provider-capabilities-Dn2WwH4P.mjs → provider-capabilities-DjcKunHS.mjs} +1 -1
- package/dist/.setup/{provider-LWKll6dV.mjs → provider-wj_LFJH3.mjs} +4 -4
- package/dist/.setup/{rate-limits-CI8pTPqL.mjs → rate-limits-BpfURnuy.mjs} +1 -1
- package/dist/.setup/{request-Bo0kKABI.mjs → request-ePeNJrOd.mjs} +132 -136
- package/dist/.setup/{responses-oauth-twnuTaAa.mjs → responses-oauth-CCV7aVYF.mjs} +6 -6
- package/dist/.setup/{rpc-error-C98SHchT.mjs → rpc-error-DemqqaxE.mjs} +7 -3
- package/dist/.setup/{run-attempt-ClU8MxhZ.mjs → run-attempt-BcWArowv.mjs} +595 -426
- package/dist/.setup/{run-attempt-lifecycle-KN4oh-7O.mjs → run-attempt-lifecycle-DN-ATDp9.mjs} +1 -1
- package/dist/.setup/{runtime-artifact-C13pR7tD.mjs → runtime-artifact-CmLWeyJB.mjs} +3 -3
- package/dist/.setup/{runtime-artifact-connection-jS5DeCok.mjs → runtime-artifact-connection-DpWlZ02e.mjs} +3 -3
- package/dist/.setup/{sandbox-guard-DIImwCy1.mjs → sandbox-guard-DneAfNye.mjs} +70 -30
- package/dist/.setup/{session-binding-JEHNMPsr.mjs → session-binding-BgsWcbdY.mjs} +25 -23
- package/dist/.setup/{session-binding-record-DU_0biMD.mjs → session-binding-record-C_THntMe.mjs} +27 -12
- package/dist/.setup/{session-binding-record-codec-BpH8u_G9.mjs → session-binding-record-codec-DvmOI7g_.mjs} +1 -0
- package/dist/.setup/{session-binding-sidecars-DD-enC8w.mjs → session-binding-sidecars-BNSS6WL4.mjs} +55 -63
- package/dist/.setup/session-cancellation-DLBSJO5n.mjs +43 -0
- package/dist/.setup/{session-catalog-adoption-Ca3OYGYM.mjs → session-catalog-adoption-ppsLlVLB.mjs} +24 -38
- package/dist/.setup/{session-catalog-archive-Bv6gV7x9.mjs → session-catalog-archive-CqLRHJ6z.mjs} +11 -13
- package/dist/.setup/{session-catalog-events-kR2Ot6nX.mjs → session-catalog-events-DK0opVp3.mjs} +5 -5
- package/dist/.setup/{session-catalog-index-CrnfVEnT.mjs → session-catalog-index-BfzfdtH7.mjs} +96 -271
- package/dist/.setup/{session-catalog-index-order-CTfoefow.mjs → session-catalog-index-order-0Zqng2u8.mjs} +1 -1
- package/dist/.setup/{session-catalog-limits-BynIoOYm.mjs → session-catalog-limits-Dc6E0BZz.mjs} +1 -1
- package/dist/.setup/{session-catalog-list-request-D4MYNgDB.mjs → session-catalog-list-request-CAjoWjaH.mjs} +3 -4
- package/dist/.setup/{session-catalog-native-projection-CWqCU1I_.mjs → session-catalog-native-projection-G3lSDYYG.mjs} +5 -5
- package/dist/.setup/{session-catalog-node-adoption-BdP9Zjqo.mjs → session-catalog-node-adoption-e9v8mGgx.mjs} +5 -5
- package/dist/.setup/{session-catalog-node-continue-CNJibO4_.mjs → session-catalog-node-continue-H7nrzcUD.mjs} +5 -5
- package/dist/.setup/{session-catalog-node-lookup-BH_DBGa9.mjs → session-catalog-node-lookup-BrZfDkA8.mjs} +2 -2
- package/dist/.setup/{session-catalog-parsing-DkeoVn60.mjs → session-catalog-parsing-V6jyFg9g.mjs} +2 -2
- package/dist/.setup/{session-catalog-projection-BzHiV818.mjs → session-catalog-projection-BjWE414G.mjs} +8 -7
- package/dist/.setup/{session-catalog-provenance-CmsOE5mh.mjs → session-catalog-provenance-Dg9s12z-.mjs} +50 -30
- package/dist/.setup/{session-catalog-source-DGuRdGvM.mjs → session-catalog-source-DqyuNxCe.mjs} +2 -6
- package/dist/.setup/{session-cli-GwU0izn-.mjs → session-cli-CBGKiqdv.mjs} +1 -1
- package/dist/.setup/{session-history-BO6i_pfk.mjs → session-history-7W0cgTXF.mjs} +11 -9
- package/dist/.setup/{session-history-import-CaO8s6ta.mjs → session-history-import-BwPKwcNi.mjs} +4 -4
- package/dist/.setup/{session-initialization-Bi_2DKhc.mjs → session-initialization-Dn3vveGv.mjs} +2 -2
- package/dist/.setup/{session-retirement-B3U5hpGJ.mjs → session-retirement-Ci_JvOfH.mjs} +8 -8
- package/dist/.setup/{session-history.worker-DJQfek5p.mjs → settled-turn-evidence--tRW6fSm.mjs} +2 -18
- package/dist/.setup/{settled-turn-finalizer-CYCVpTv2.mjs → settled-turn-finalizer-D3-KXsbP.mjs} +8 -8
- package/dist/.setup/{shared-client-BCx1wbyA.mjs → shared-client-CE_uY0A1.mjs} +380 -557
- package/dist/.setup/side-question-OM18H9WJ.mjs +998 -0
- package/dist/.setup/{source-DipMO9hL.mjs → source-uGKgKWm8.mjs} +5 -5
- package/dist/.setup/{thread-archive-guard-LKdwQKyr.mjs → thread-archive-guard-BWjSsA92.mjs} +1 -1
- package/dist/.setup/{thread-lifecycle-run-C_aYiYqk.mjs → thread-lifecycle-run-mLueY6pH.mjs} +172 -75
- package/dist/.setup/{thread-model-selection-DcVebr8N.mjs → thread-model-selection-DxposL4X.mjs} +9 -9
- package/dist/.setup/{thread-ownership-BoUd0i6L.mjs → thread-ownership-t6Y9fLQS.mjs} +7 -7
- package/dist/.setup/{thread-policy-B3wBRNph.mjs → thread-policy-Cy301Or8.mjs} +6 -6
- package/dist/.setup/{thread-requests-BgzJwJtS.mjs → thread-requests-BjawdIVV.mjs} +14 -14
- package/dist/.setup/{thread-resume-D-3bsr1j.mjs → thread-resume-BUbsUfgF.mjs} +6 -6
- package/dist/.setup/{transcript-history-projection-DfKcoZCB.mjs → transcript-history-projection-i-FVpyha.mjs} +1 -1
- package/dist/.setup/{transcript-mirror-Bee2o6jj.mjs → transcript-mirror-CEQJZlF3.mjs} +6 -9
- package/dist/.setup/{transport-stdio-CRWTkKOn.mjs → transport-stdio-Bq160Dhv.mjs} +63 -64
- package/dist/.setup/{transport-websocket-DIyPfkHo.mjs → transport-websocket-0YqiI_MH.mjs} +1 -1
- package/dist/.setup/{turn-router-DBVMToGo.mjs → turn-router-Dbw17k3K.mjs} +2 -2
- package/dist/.setup/{upstream-session-fork-p5fwKi7w.mjs → upstream-session-fork-_LYkh0nZ.mjs} +46 -219
- package/dist/.setup/{usage-limit-error-BQX8RHAd.mjs → usage-limit-error-DcOSH3J4.mjs} +4 -4
- package/dist/.setup/{usage-C2Kq7oej.mjs → usage-w_93wnnR.mjs} +4 -4
- package/dist/.setup/{web-search-item-CvokaZOo.mjs → web-search-item-DHVuNSqk.mjs} +1 -1
- package/dist/.setup/{web-search-provider.runtime-D89djc7e.mjs → web-search-provider.runtime-DMHxve5v.mjs} +3 -3
- package/dist/.setup/{workspace-write-sandbox-probe-BDWO2Qkh.mjs → workspace-write-sandbox-probe-DJxOXcF3.mjs} +2 -2
- package/dist/api.js +7 -28
- package/dist/catalog-page.worker.js +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-version-api.js +25 -0
- package/dist/doctor-contract-api.js +5 -5
- package/dist/harness.js +59 -36
- package/dist/index.js +259 -295
- package/dist/media-understanding-provider.js +2 -2
- package/dist/migration-provider-api.js +1 -2
- package/dist/native-session-binding-api.js +1 -2
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-entrypoint.js +12 -0
- package/dist/session-history-worker-runtime.js +7 -18
- package/dist/session-history.worker.js +18 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +6 -6
- package/dist/.setup/attempt-terminal-jO5IMj9K.mjs +0 -2
- package/dist/.setup/command-rpc-HIvsy3wS.mjs +0 -247
- package/dist/.setup/compact-ClZ7Ar7L.mjs +0 -808
- package/dist/.setup/inference-context-DNlGwzwy.mjs +0 -91
- package/dist/.setup/managed-binary-BtIjV7yN.mjs +0 -175
- package/dist/.setup/native-execution-policy-MXEe7PB3.mjs +0 -75
- package/dist/.setup/protocol-CANUwXJ3.mjs +0 -17
- package/dist/.setup/side-question-Bz2UQW0l.mjs +0 -826
package/dist/.setup/{effective-mcp-catalog-B5HKFZNK.mjs → effective-mcp-catalog-C3ta5hHc.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "./session-binding-
|
|
1
|
+
import { g as sessionBindingIdentity } from "./session-binding-record-C_THntMe.mjs";
|
|
2
|
+
import { T as retainSharedCodexAppServerClientByInstanceId } from "./auth-cache-key-CVcYw8HD.mjs";
|
|
3
|
+
import { I as protectCodexAppServerLiveThread } from "./shared-client-CE_uY0A1.mjs";
|
|
4
|
+
import "./session-binding-BgsWcbdY.mjs";
|
|
5
5
|
import { n as projectCodexMcpToolMetadata, t as projectCodexMcpServerMetadata } from "./mcp-tool-metadata-DW41snf3.mjs";
|
|
6
6
|
import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
7
|
import { assignMcpCatalogSafeServerNames } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
@@ -83,7 +83,7 @@ async function listCodexMcpServerStatuses(client, threadId) {
|
|
|
83
83
|
}
|
|
84
84
|
/** Loads MCP inventory from the bound Codex client while retaining its lease through all pages. */
|
|
85
85
|
async function loadCodexEffectiveMcpCatalog(params, options) {
|
|
86
|
-
const binding = options.bindingStore.
|
|
86
|
+
const binding = await options.bindingStore.readAsync(sessionBindingIdentity({
|
|
87
87
|
agentId: params.agentId,
|
|
88
88
|
sessionId: params.sessionId,
|
|
89
89
|
sessionKey: params.sessionKey,
|
|
@@ -102,12 +102,13 @@ async function loadCodexEffectiveMcpCatalog(params, options) {
|
|
|
102
102
|
/** Explicit App requests retain the thread owner, never start a second MCP client. */
|
|
103
103
|
async function acquireCodexMcpAppRuntime(params, options) {
|
|
104
104
|
const identity = sessionBindingIdentity(params);
|
|
105
|
-
let binding = options.bindingStore.
|
|
105
|
+
let binding = await options.bindingStore.readAsync(identity);
|
|
106
|
+
params.assertCurrent();
|
|
106
107
|
let retained = await retainSharedCodexAppServerClientByInstanceId(binding?.clientId);
|
|
107
108
|
if (!retained && params.prepareSession) {
|
|
108
109
|
const preparation = await params.prepareSession();
|
|
109
110
|
params.assertCurrent();
|
|
110
|
-
const { prepareCodexMcpAppSession } = await import("./mcp-app-session-preparation-
|
|
111
|
+
const { prepareCodexMcpAppSession } = await import("./mcp-app-session-preparation-fnsnCovu.mjs");
|
|
111
112
|
await prepareCodexMcpAppSession({
|
|
112
113
|
preparation,
|
|
113
114
|
bindingStore: options.bindingStore,
|
|
@@ -115,7 +116,8 @@ async function acquireCodexMcpAppRuntime(params, options) {
|
|
|
115
116
|
assertCurrent: params.assertCurrent
|
|
116
117
|
});
|
|
117
118
|
params.assertCurrent();
|
|
118
|
-
binding = options.bindingStore.
|
|
119
|
+
binding = await options.bindingStore.readAsync(identity);
|
|
120
|
+
params.assertCurrent();
|
|
119
121
|
retained = await retainSharedCodexAppServerClientByInstanceId(binding?.clientId);
|
|
120
122
|
}
|
|
121
123
|
if (!binding?.clientId || !retained) return;
|
|
@@ -128,7 +130,7 @@ async function acquireCodexMcpAppRuntime(params, options) {
|
|
|
128
130
|
};
|
|
129
131
|
params.assertCurrent();
|
|
130
132
|
assertBinding();
|
|
131
|
-
const { createNativeMcpRuntime } = await import("./native-mcp-app-
|
|
133
|
+
const { createNativeMcpRuntime } = await import("./native-mcp-app-CsWj-v_x.mjs").then((n) => n.n);
|
|
132
134
|
params.assertCurrent();
|
|
133
135
|
const runtime = createNativeMcpRuntime({
|
|
134
136
|
client: retained.client,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as getCodexAppServerTurnRouter } from "./turn-router-
|
|
4
|
-
import { o as isTerminalTurnStatus, s as readCodexNotificationItem, t as CodexUsageProjection } from "./event-projector-usage-
|
|
1
|
+
import { r as isJsonObject } from "./protocol-CaPAVwe9.mjs";
|
|
2
|
+
import { b as readCodexTurnCompletedNotification } from "./client-BS8X7HmG.mjs";
|
|
3
|
+
import { n as getCodexAppServerTurnRouter } from "./turn-router-Dbw17k3K.mjs";
|
|
4
|
+
import { o as isTerminalTurnStatus, s as readCodexNotificationItem, t as CodexUsageProjection } from "./event-projector-usage-CBY0Hkga.mjs";
|
|
5
5
|
import { readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
6
|
import { toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
|
|
7
7
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
@@ -35,6 +35,7 @@ var CodexEphemeralTurn = class {
|
|
|
35
35
|
if (delta && options.textMode === "all") this.assistantItems.set(itemId, `${this.assistantItems.get(itemId) ?? ""}${delta}`);
|
|
36
36
|
if (firstDelta) await options.onAssistantMessageStart?.();
|
|
37
37
|
} else if (notification.method === "rawResponse/completed") this.usage.record(params);
|
|
38
|
+
else if (notification.method === "thread/tokenUsage/updated") this.usage.recordThread(params);
|
|
38
39
|
else if (notification.method === "turn/completed") {
|
|
39
40
|
const completed = readCodexTurnCompletedNotification(params);
|
|
40
41
|
if (completed) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as codexProviderRefusalDiagnostics } from "./event-projector-values-
|
|
1
|
+
import { t as codexProviderRefusalDiagnostics } from "./event-projector-values-yf4us9Pf.mjs";
|
|
2
2
|
import { t as resolveCodexLocalRuntimeAttribution } from "./local-runtime-attribution-CZz2DJ4q.mjs";
|
|
3
3
|
import { createAgentHarnessAssistantMessage } from "openclaw/plugin-sdk/agent-harness-attempt-runtime";
|
|
4
4
|
//#region extensions/codex/src/app-server/event-projector-assistant-message.ts
|
|
@@ -35,16 +35,21 @@ function createAssistantCommentaryMessage(params, text, itemId, timestamp) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function createAssistantAsyncDelivery(params, text, itemId, timestamp, questions) {
|
|
39
|
+
if (!text?.trim() || timestamp === void 0) return;
|
|
39
40
|
return {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
itemId,
|
|
42
|
+
message: {
|
|
43
|
+
...createNonterminalAssistantMessage(params, [{
|
|
44
|
+
type: "text",
|
|
45
|
+
text
|
|
46
|
+
}], timestamp),
|
|
47
|
+
openclawAsyncDelivery: {
|
|
48
|
+
itemId,
|
|
49
|
+
...questions ? { questions } : {}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
text
|
|
48
53
|
};
|
|
49
54
|
}
|
|
50
55
|
function createAssistantReasoningMessage(params, text) {
|
|
@@ -66,4 +71,4 @@ function createNonterminalAssistantMessage(params, content, timestamp) {
|
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
//#endregion
|
|
69
|
-
export { createAttributedCodexAssistantMessage as a, createAssistantReasoningMessage as i, createAssistantCommentaryMessage as n, createAssistantMessage as r,
|
|
74
|
+
export { createAttributedCodexAssistantMessage as a, createAssistantReasoningMessage as i, createAssistantCommentaryMessage as n, createAssistantMessage as r, createAssistantAsyncDelivery as t };
|
package/dist/.setup/{event-projector-usage-BpKfdoTm.mjs → event-projector-usage-CBY0Hkga.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as extractRawResponseItemText } from "./event-projector-values-
|
|
1
|
+
import { r as isJsonObject } from "./protocol-CaPAVwe9.mjs";
|
|
2
|
+
import { n as extractRawResponseItemText } from "./event-projector-values-yf4us9Pf.mjs";
|
|
3
3
|
import { asSafeIntegerInRange, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { normalizeUsage } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
5
5
|
//#region extensions/codex/src/app-server/attempt-notifications.ts
|
package/dist/.setup/{event-projector-values-CLvG1Hil.mjs → event-projector-values-yf4us9Pf.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as isJsonObject } from "./protocol-CaPAVwe9.mjs";
|
|
2
2
|
import { readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
4
|
//#region extensions/codex/src/app-server/event-projector-values.ts
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region extensions/codex/src/app-server/experimental-features.ts
|
|
2
|
+
async function readCodexExperimentalFeature(request, featureName, threadId) {
|
|
3
|
+
let cursor;
|
|
4
|
+
const visited = /* @__PURE__ */ new Set();
|
|
5
|
+
do {
|
|
6
|
+
const response = await request({
|
|
7
|
+
...threadId ? { threadId } : {},
|
|
8
|
+
...cursor ? { cursor } : {},
|
|
9
|
+
limit: 100
|
|
10
|
+
});
|
|
11
|
+
const feature = response.data.find((entry) => entry.name === featureName);
|
|
12
|
+
if (feature) return feature.enabled;
|
|
13
|
+
cursor = response.nextCursor ?? void 0;
|
|
14
|
+
if (cursor && visited.has(cursor)) return;
|
|
15
|
+
if (cursor) visited.add(cursor);
|
|
16
|
+
} while (cursor);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { readCodexExperimentalFeature as t };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { r as isJsonObject } from "./protocol-CaPAVwe9.mjs";
|
|
2
|
+
import { n as defineCodexBuildState } from "./build-state-VcujMRqP.mjs";
|
|
3
|
+
import { n as readCodexInferenceMetadata } from "./inference-metadata-CYFWLHVk.mjs";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
//#region extensions/codex/src/app-server/inference-context.ts
|
|
6
|
+
const MAX_CONTEXT_BYTES = 262144;
|
|
7
|
+
const MAX_ACTIVE_ROOTS = 64;
|
|
8
|
+
const MAX_PREPARED_PREFIXES = 256;
|
|
9
|
+
const MAX_RETAINED_REQUEST_BYTES = 33554432;
|
|
10
|
+
const retained = defineCodexBuildState("openclaw.codexPreparedRequests", () => ({
|
|
11
|
+
requests: /* @__PURE__ */ new Map(),
|
|
12
|
+
bytes: 0
|
|
13
|
+
}))();
|
|
14
|
+
function forgetRequest(prefix) {
|
|
15
|
+
if (!prefix) return;
|
|
16
|
+
const request = retained.requests.get(prefix);
|
|
17
|
+
if (request) {
|
|
18
|
+
retained.bytes -= request.bytes;
|
|
19
|
+
retained.requests.delete(prefix);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function retainRequest(prefix, body) {
|
|
23
|
+
const previous = retained.requests.get(prefix)?.body;
|
|
24
|
+
forgetRequest(prefix);
|
|
25
|
+
const continuation = body.previous_response_id != null;
|
|
26
|
+
const snapshot = {};
|
|
27
|
+
for (const key of [
|
|
28
|
+
"instructions",
|
|
29
|
+
"tools",
|
|
30
|
+
"input",
|
|
31
|
+
"prompt_cache_key"
|
|
32
|
+
]) {
|
|
33
|
+
if (continuation && key === "input") continue;
|
|
34
|
+
const value = body[key] ?? (continuation ? previous?.[key] : void 0);
|
|
35
|
+
if (value !== void 0) snapshot[key] = value;
|
|
36
|
+
}
|
|
37
|
+
if (continuation) {
|
|
38
|
+
const inputTools = Array.isArray(previous?.input) ? previous.input.find((item) => isJsonObject(item) && item.type === "additional_tools") : previous?.inputTools;
|
|
39
|
+
if (inputTools !== void 0) snapshot.inputTools = inputTools;
|
|
40
|
+
}
|
|
41
|
+
const bytes = Buffer.byteLength(JSON.stringify(snapshot));
|
|
42
|
+
if (bytes > MAX_RETAINED_REQUEST_BYTES) return;
|
|
43
|
+
while (retained.bytes + bytes > MAX_RETAINED_REQUEST_BYTES) forgetRequest(retained.requests.keys().next().value);
|
|
44
|
+
retained.requests.set(prefix, {
|
|
45
|
+
body: snapshot,
|
|
46
|
+
bytes
|
|
47
|
+
});
|
|
48
|
+
retained.bytes += bytes;
|
|
49
|
+
}
|
|
50
|
+
/** One physical inference transport owns these confidential, nonpersistent snapshots. */
|
|
51
|
+
function createCodexInferenceContext(assertClientCurrent) {
|
|
52
|
+
const roots = /* @__PURE__ */ new Map();
|
|
53
|
+
const prefixes = /* @__PURE__ */ new Map();
|
|
54
|
+
let closed = false;
|
|
55
|
+
const assertOpen = () => {
|
|
56
|
+
if (closed) throw new Error("Codex parent-local inference transport is closed");
|
|
57
|
+
assertClientCurrent();
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
register(params) {
|
|
61
|
+
assertOpen();
|
|
62
|
+
params.signal.throwIfAborted();
|
|
63
|
+
params.assertCurrent();
|
|
64
|
+
if (Buffer.byteLength(params.text) > MAX_CONTEXT_BYTES) throw new Error("Codex parent-local context exceeds the 256 KiB inference limit");
|
|
65
|
+
if (!roots.has(params.threadId) && roots.size >= MAX_ACTIVE_ROOTS) throw new Error("Codex parent-local inference root limit reached");
|
|
66
|
+
if (params.retainPrefix !== false && !prefixes.has(params.threadId) && prefixes.size >= MAX_PREPARED_PREFIXES) throw new Error("Codex prepared inference prefix limit reached; reconnect before retrying");
|
|
67
|
+
roots.get(params.threadId)?.release();
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
const registration = {
|
|
70
|
+
generation: randomUUID(),
|
|
71
|
+
text: params.text,
|
|
72
|
+
forkPrefix: params.forkPrefix,
|
|
73
|
+
denyToolCalls: params.denyToolCalls === true,
|
|
74
|
+
controller,
|
|
75
|
+
assertCurrent: () => {
|
|
76
|
+
assertOpen();
|
|
77
|
+
controller.signal.throwIfAborted();
|
|
78
|
+
params.signal.throwIfAborted();
|
|
79
|
+
params.assertCurrent();
|
|
80
|
+
if (roots.get(params.threadId) !== registration) throw new Error("Codex parent-local inference generation was replaced");
|
|
81
|
+
},
|
|
82
|
+
release: () => {
|
|
83
|
+
if (roots.get(params.threadId) === registration) roots.delete(params.threadId);
|
|
84
|
+
registration.text = "";
|
|
85
|
+
controller.abort();
|
|
86
|
+
params.signal.removeEventListener("abort", registration.release);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
roots.set(params.threadId, registration);
|
|
90
|
+
if (params.retainPrefix !== false) {
|
|
91
|
+
const prefix = prefixes.get(params.threadId);
|
|
92
|
+
if (prefix) prefix.text = params.text;
|
|
93
|
+
else prefixes.set(params.threadId, { text: params.text });
|
|
94
|
+
}
|
|
95
|
+
params.signal.addEventListener("abort", registration.release, { once: true });
|
|
96
|
+
return {
|
|
97
|
+
generation: registration.generation,
|
|
98
|
+
release: registration.release
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
/** A retained prefix is data; only the new root's caller grants model authority. */
|
|
102
|
+
fork(params) {
|
|
103
|
+
assertOpen();
|
|
104
|
+
const prefix = prefixes.get(params.sourceThreadId);
|
|
105
|
+
if (!prefix) throw new Error("Cache-parity fork has no prepared parent inference context.");
|
|
106
|
+
const request = retained.requests.get(prefix);
|
|
107
|
+
if (request) {
|
|
108
|
+
retained.requests.delete(prefix);
|
|
109
|
+
retained.requests.set(prefix, request);
|
|
110
|
+
}
|
|
111
|
+
return this.register({
|
|
112
|
+
threadId: params.threadId,
|
|
113
|
+
text: prefix.text,
|
|
114
|
+
forkPrefix: request?.body,
|
|
115
|
+
retainPrefix: false,
|
|
116
|
+
denyToolCalls: true,
|
|
117
|
+
signal: params.signal,
|
|
118
|
+
assertCurrent: params.assertCurrent
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
forget(threadId) {
|
|
122
|
+
forgetRequest(prefixes.get(threadId));
|
|
123
|
+
prefixes.delete(threadId);
|
|
124
|
+
roots.get(threadId)?.release();
|
|
125
|
+
},
|
|
126
|
+
/** Caller must authenticate its private transport before parsing any model request. */
|
|
127
|
+
prepare(body, preparedMetadata, requireAdmission = false) {
|
|
128
|
+
assertOpen();
|
|
129
|
+
const metadata = preparedMetadata ?? readCodexInferenceMetadata(body);
|
|
130
|
+
const child = Boolean(metadata.parentThreadId || metadata.subagentKind || metadata.subagent);
|
|
131
|
+
const kind = metadata.requestKind;
|
|
132
|
+
if (!requireAdmission && (child || kind === "compaction" || kind === "memory")) return {
|
|
133
|
+
body,
|
|
134
|
+
assertCurrent: assertOpen,
|
|
135
|
+
signal: void 0
|
|
136
|
+
};
|
|
137
|
+
if (child || kind !== "turn" && kind !== "prewarm" && !(requireAdmission && kind === "compaction")) throw new Error("Codex inference request has an unsupported native purpose");
|
|
138
|
+
const registration = metadata.threadId ? roots.get(metadata.threadId) : void 0;
|
|
139
|
+
const generation = metadata.generation;
|
|
140
|
+
if (!requireAdmission && kind === "prewarm" && body.generate === false && generation == null) return {
|
|
141
|
+
body,
|
|
142
|
+
assertCurrent: assertOpen,
|
|
143
|
+
signal: void 0
|
|
144
|
+
};
|
|
145
|
+
if (!registration || generation !== registration.generation) throw new Error("Codex inference has no current admitted parent generation");
|
|
146
|
+
registration.assertCurrent();
|
|
147
|
+
let preparedBody = body;
|
|
148
|
+
if (kind !== "compaction") {
|
|
149
|
+
const instructions = body.instructions;
|
|
150
|
+
if (instructions !== void 0 && typeof instructions !== "string") throw new Error("Codex inference request has invalid top-level instructions");
|
|
151
|
+
if (registration.text) preparedBody = {
|
|
152
|
+
...body,
|
|
153
|
+
instructions: instructions === void 0 ? registration.text : instructions + "\n\n" + registration.text
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (kind === "turn") {
|
|
157
|
+
const prefix = registration.forkPrefix;
|
|
158
|
+
const inputTools = Array.isArray(prefix?.input) ? prefix.input.find((item) => isJsonObject(item) && item.type === "additional_tools") : prefix?.inputTools;
|
|
159
|
+
const input = prefix && Array.isArray(body.input) ? body.input.map((item) => isJsonObject(inputTools) && isJsonObject(item) && item.type === "additional_tools" ? inputTools : item) : void 0;
|
|
160
|
+
if (prefix && Array.isArray(prefix.input) && input && prefix.input.length <= input.length && prefix.input.every((item, index) => JSON.stringify(item) === JSON.stringify(input[index]))) {
|
|
161
|
+
preparedBody = { ...body };
|
|
162
|
+
delete preparedBody.previous_response_id;
|
|
163
|
+
for (const key of [
|
|
164
|
+
"instructions",
|
|
165
|
+
"tools",
|
|
166
|
+
"input"
|
|
167
|
+
]) delete preparedBody[key];
|
|
168
|
+
for (const key of [
|
|
169
|
+
"instructions",
|
|
170
|
+
"tools",
|
|
171
|
+
"input",
|
|
172
|
+
"prompt_cache_key"
|
|
173
|
+
]) {
|
|
174
|
+
const value = prefix[key];
|
|
175
|
+
if (value !== void 0) preparedBody[key] = value;
|
|
176
|
+
}
|
|
177
|
+
preparedBody.input = [...prefix.input, ...input.slice(prefix.input.length)];
|
|
178
|
+
} else if (prefix) {
|
|
179
|
+
preparedBody = {
|
|
180
|
+
...preparedBody,
|
|
181
|
+
...prefix.tools !== void 0 ? { tools: prefix.tools } : {},
|
|
182
|
+
...input ? { input } : {}
|
|
183
|
+
};
|
|
184
|
+
delete preparedBody.instructions;
|
|
185
|
+
if (prefix.instructions !== void 0) preparedBody.instructions = prefix.instructions;
|
|
186
|
+
}
|
|
187
|
+
if (registration.denyToolCalls) preparedBody = {
|
|
188
|
+
...preparedBody,
|
|
189
|
+
tool_choice: "none"
|
|
190
|
+
};
|
|
191
|
+
const retainedPrefix = metadata.threadId ? prefixes.get(metadata.threadId) : void 0;
|
|
192
|
+
if (retainedPrefix) retainRequest(retainedPrefix, preparedBody);
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
body: preparedBody,
|
|
196
|
+
assertCurrent: registration.assertCurrent,
|
|
197
|
+
signal: registration.controller.signal
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
close() {
|
|
201
|
+
closed = true;
|
|
202
|
+
for (const prefix of prefixes.values()) forgetRequest(prefix);
|
|
203
|
+
prefixes.clear();
|
|
204
|
+
for (const registration of roots.values()) registration.release();
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
export { createCodexInferenceContext as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as readCodexInferenceMetadata } from "./inference-metadata-
|
|
1
|
+
import { r as isJsonObject } from "./protocol-CaPAVwe9.mjs";
|
|
2
|
+
import { n as readCodexInferenceMetadata } from "./inference-metadata-CYFWLHVk.mjs";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
4
|
import { isUtf8 } from "node:buffer";
|
|
5
5
|
import { zstdCompress, zstdDecompress } from "node:zlib";
|
|
@@ -22,8 +22,10 @@ function readCodexInferenceMetadata(body, headers, transport = "http", path) {
|
|
|
22
22
|
const nativeThreadId = readId("thread", ...nativeField("thread_id"));
|
|
23
23
|
if (!nativeThreadId && (requestKind === "turn" || requestKind === "prewarm" && !(body.generate === false && generation === void 0))) throw new Error("Codex inference request has no native thread metadata");
|
|
24
24
|
const readTurnId = (field, key) => readId(field, flat?.[key], ...nativeField(key));
|
|
25
|
+
const sessionId = readId("session", flat?.session_id, ...nativeField("session_id"));
|
|
26
|
+
const routingSessionId = readId("routing session", httpHeaders?.["session-id"]);
|
|
25
27
|
return Object.freeze({
|
|
26
|
-
sessionId:
|
|
28
|
+
sessionId: sessionId ?? routingSessionId,
|
|
27
29
|
threadId: readId("thread", flat?.thread_id, nativeThreadId, httpHeaders?.["thread-id"]),
|
|
28
30
|
turnId: readTurnId("turn", "turn_id"),
|
|
29
31
|
parentThreadId: readId("parent thread", flat?.["x-codex-parent-thread-id"], ...nativeField("parent_thread_id"), httpHeaders?.["x-codex-parent-thread-id"]),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as codexWebSocketDataToBuffer } from "./websocket-data-XlRvt8Ys.mjs";
|
|
2
|
-
import { CODEX_INFERENCE_TRANSPORT_FAILURE, authorizationFailure, createCodexInferenceDispatch, isTerminalResponse, n as createUploadAdmission, readProxyBody, t as MAX_BODY_BYTES } from "./inference-dispatch-
|
|
3
|
-
import { t as createCodexInferenceContext } from "./inference-context-
|
|
2
|
+
import { CODEX_INFERENCE_TRANSPORT_FAILURE, authorizationFailure, createCodexInferenceDispatch, isTerminalResponse, n as createUploadAdmission, readProxyBody, t as MAX_BODY_BYTES } from "./inference-dispatch-C2zVSnrr.mjs";
|
|
3
|
+
import { t as createCodexInferenceContext } from "./inference-context-mv_dBpAL.mjs";
|
|
4
4
|
import { createDeferred, createPermitPool } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
5
5
|
import { Writable } from "node:stream";
|
|
6
6
|
import { WebSocket, WebSocketServer, rejectWebSocketUpgrade } from "openclaw/plugin-sdk/websocket-runtime";
|
|
@@ -61,7 +61,7 @@ const MAX_RESIDENTS = 80;
|
|
|
61
61
|
const REQUEST_TIMEOUT_MS = 3e4;
|
|
62
62
|
const HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
63
63
|
const IDLE_WEBSOCKET_MS = 6e4;
|
|
64
|
-
/** Private, fixed-destination relay.
|
|
64
|
+
/** Private, fixed-destination relay. Upstream credentials are never retained. */
|
|
65
65
|
async function createCodexInferenceProxy(params) {
|
|
66
66
|
const upstream = new URL(params.upstream);
|
|
67
67
|
if (upstream.protocol !== "https:" || upstream.username || upstream.password || upstream.hash) throw new Error("Codex inference requires a credential-free HTTPS upstream URL");
|
|
@@ -213,7 +213,6 @@ async function createCodexInferenceProxy(params) {
|
|
|
213
213
|
preparedUpload.assertCurrent();
|
|
214
214
|
auth?.assertCurrent();
|
|
215
215
|
};
|
|
216
|
-
assertAuthorized();
|
|
217
216
|
if (auth) {
|
|
218
217
|
for (const key of [
|
|
219
218
|
"authorization",
|
|
@@ -289,6 +288,7 @@ async function createCodexInferenceProxy(params) {
|
|
|
289
288
|
let resident = null;
|
|
290
289
|
const controller = new AbortController();
|
|
291
290
|
const deadlineAtMs = Date.now() + HANDSHAKE_TIMEOUT_MS;
|
|
291
|
+
const deadlineAtMonotonicMs = performance.now() + HANDSHAKE_TIMEOUT_MS;
|
|
292
292
|
let releasePermit = null;
|
|
293
293
|
let framePending = false;
|
|
294
294
|
let idleTimer;
|
|
@@ -322,7 +322,7 @@ async function createCodexInferenceProxy(params) {
|
|
|
322
322
|
});
|
|
323
323
|
};
|
|
324
324
|
const close = () => finish();
|
|
325
|
-
const failHandshake = () => finish(
|
|
325
|
+
const failHandshake = () => finish(performance.now() >= deadlineAtMonotonicMs ? 504 : 502);
|
|
326
326
|
try {
|
|
327
327
|
const { target, path } = resolveTarget(req);
|
|
328
328
|
if (params.oauth) throw new Error(CODEX_INFERENCE_TRANSPORT_FAILURE);
|
|
@@ -352,12 +352,12 @@ async function createCodexInferenceProxy(params) {
|
|
|
352
352
|
rejectBusyUpgrade(socket);
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
|
-
handshakeTimer = setTimeout(() => finish(504), Math.max(1,
|
|
355
|
+
handshakeTimer = setTimeout(() => finish(504), Math.max(1, deadlineAtMonotonicMs - performance.now()));
|
|
356
356
|
handshakeTimer.unref();
|
|
357
357
|
const assertHandshakeCurrent = () => {
|
|
358
358
|
assertCurrent();
|
|
359
359
|
signal.throwIfAborted();
|
|
360
|
-
if (
|
|
360
|
+
if (performance.now() >= deadlineAtMonotonicMs) throw new Error(CODEX_INFERENCE_TRANSPORT_FAILURE);
|
|
361
361
|
};
|
|
362
362
|
proxyAgent = createNodeProxyAgent({
|
|
363
363
|
mode: "env",
|
|
@@ -374,7 +374,7 @@ async function createCodexInferenceProxy(params) {
|
|
|
374
374
|
followRedirects: false,
|
|
375
375
|
perMessageDeflate: false,
|
|
376
376
|
maxPayload: MAX_BODY_BYTES,
|
|
377
|
-
handshakeTimeout: Math.max(1,
|
|
377
|
+
handshakeTimeout: Math.max(1, deadlineAtMonotonicMs - performance.now()),
|
|
378
378
|
finishRequest(request) {
|
|
379
379
|
let socketClosed = Promise.resolve();
|
|
380
380
|
request.once("socket", (upstreamSocket) => {
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { n as INSTALLED_CODEX_PROBE_TIMEOUT_MS } from "./managed-binary-DbKvGXKl.mjs";
|
|
2
|
+
import { n as resolveCodexAppServerSpawnEnv, r as resolveCodexAppServerSpawnInvocation } from "./transport-stdio-Bq160Dhv.mjs";
|
|
3
|
+
import { n as buildCodexAppServerInitializeParams, o as readCodexVersionFromUserAgent } from "./client-initialize-CjgZcX61.mjs";
|
|
4
|
+
import { runUtf8CommandWithTimeout, signalProcessTree } from "openclaw/plugin-sdk/process-runtime";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { access, mkdtemp, rm } from "node:fs/promises";
|
|
7
|
+
import { once } from "node:events";
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
10
|
+
import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
|
|
11
|
+
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
12
|
+
//#region extensions/codex/src/app-server/installed-probe.ts
|
|
13
|
+
/**
|
|
14
|
+
* Bounded initialize handshake that qualifies a user-installed Codex before
|
|
15
|
+
* selection. The candidate runs privately against a throwaway CODEX_HOME: it is
|
|
16
|
+
* never registered as a Gateway app-server and never opens OpenClaw state.
|
|
17
|
+
*/
|
|
18
|
+
const HANDSHAKE_MAX_OUTPUT_CHARS = 1048576;
|
|
19
|
+
const HANDSHAKE_EXIT_TIMEOUT_MS = 2e3;
|
|
20
|
+
const INITIALIZE_REQUEST_ID = 1;
|
|
21
|
+
async function assertProbeCanOverrideStorage(timeoutMs) {
|
|
22
|
+
const metadataOptions = {
|
|
23
|
+
baseEnv: {
|
|
24
|
+
...process.env,
|
|
25
|
+
LC_ALL: "C"
|
|
26
|
+
},
|
|
27
|
+
input: "",
|
|
28
|
+
timeoutMs: Math.min(1e3, timeoutMs),
|
|
29
|
+
maxOutputBytes: 4096,
|
|
30
|
+
killProcessTree: true,
|
|
31
|
+
killSignal: "SIGKILL",
|
|
32
|
+
killGraceMs: 0
|
|
33
|
+
};
|
|
34
|
+
let managedPaths = ["/etc/codex/managed_config.toml", "/etc/codex/requirements.toml"];
|
|
35
|
+
if (process.platform === "win32") {
|
|
36
|
+
const result = await runUtf8CommandWithTimeout([
|
|
37
|
+
"powershell.exe",
|
|
38
|
+
"-NoProfile",
|
|
39
|
+
"-NonInteractive",
|
|
40
|
+
"-Command",
|
|
41
|
+
"[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false); [Environment]::GetFolderPath('CommonApplicationData')"
|
|
42
|
+
], metadataOptions);
|
|
43
|
+
const programData = result.stdout.trim();
|
|
44
|
+
if (result.termination !== "exit" || result.code !== 0 || result.outputLimitExceeded || !path.win32.isAbsolute(programData)) throw new Error("cannot locate managed Codex requirements for an isolated selection probe");
|
|
45
|
+
managedPaths = [path.win32.join(programData, "OpenAI", "Codex", "requirements.toml")];
|
|
46
|
+
}
|
|
47
|
+
for (const managedPath of managedPaths) if (await access(managedPath).then(() => true, (error) => {
|
|
48
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
|
|
49
|
+
throw error;
|
|
50
|
+
})) throw new Error("managed Codex configuration prevents an isolated selection probe");
|
|
51
|
+
if (process.platform === "darwin") for (const key of ["config_toml_base64", "requirements_toml_base64"]) {
|
|
52
|
+
const result = await runUtf8CommandWithTimeout([
|
|
53
|
+
"/usr/bin/defaults",
|
|
54
|
+
"read-type",
|
|
55
|
+
"com.openai.codex",
|
|
56
|
+
key
|
|
57
|
+
], metadataOptions);
|
|
58
|
+
const missing = result.stderr.includes("does not exist") || result.stderr.includes(`Could not find key '${key}'`) || result.stderr.includes("Domain 'com.openai.codex' not found.");
|
|
59
|
+
if (result.termination !== "exit" || result.code !== 1 || result.outputLimitExceeded || !missing) throw new Error("managed Codex preferences cannot be excluded from the selection probe");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Sends one initialize request and returns the Codex version from its reply. */
|
|
63
|
+
async function probeCodexAppServerHandshake(command, timeoutMs = INSTALLED_CODEX_PROBE_TIMEOUT_MS) {
|
|
64
|
+
const deadline = performance.now() + timeoutMs;
|
|
65
|
+
await assertProbeCanOverrideStorage(timeoutMs);
|
|
66
|
+
const codexHome = await mkdtemp(path.join(resolvePreferredOpenClawTmpDir(), "openclaw-codex-probe-"));
|
|
67
|
+
try {
|
|
68
|
+
const remainingMs = deadline - performance.now();
|
|
69
|
+
if (remainingMs <= 0) throw new Error("selection probe timed out before initialize");
|
|
70
|
+
return await exchangeInitialize(command, codexHome, remainingMs);
|
|
71
|
+
} finally {
|
|
72
|
+
await rm(codexHome, {
|
|
73
|
+
recursive: true,
|
|
74
|
+
force: true
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function exchangeInitialize(command, codexHome, timeoutMs) {
|
|
79
|
+
const options = {
|
|
80
|
+
transport: "stdio",
|
|
81
|
+
command,
|
|
82
|
+
commandSource: "resolved-managed",
|
|
83
|
+
args: [
|
|
84
|
+
"-c",
|
|
85
|
+
`sqlite_home=${JSON.stringify(codexHome)}`,
|
|
86
|
+
"app-server",
|
|
87
|
+
"--listen",
|
|
88
|
+
"stdio://"
|
|
89
|
+
],
|
|
90
|
+
headers: {},
|
|
91
|
+
env: {
|
|
92
|
+
CODEX_HOME: codexHome,
|
|
93
|
+
CODEX_SQLITE_HOME: codexHome
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const env = resolveCodexAppServerSpawnEnv(options);
|
|
97
|
+
const invocation = resolveCodexAppServerSpawnInvocation(options, env);
|
|
98
|
+
const detached = process.platform !== "win32";
|
|
99
|
+
const child = spawn(invocation.command, invocation.argv, {
|
|
100
|
+
env,
|
|
101
|
+
detached,
|
|
102
|
+
shell: invocation.shell,
|
|
103
|
+
stdio: [
|
|
104
|
+
"pipe",
|
|
105
|
+
"pipe",
|
|
106
|
+
"pipe"
|
|
107
|
+
],
|
|
108
|
+
windowsHide: invocation.windowsHide
|
|
109
|
+
});
|
|
110
|
+
const closed = once(child, "close").then(() => void 0, () => void 0);
|
|
111
|
+
try {
|
|
112
|
+
return await readInitializeReply(child, timeoutMs);
|
|
113
|
+
} finally {
|
|
114
|
+
if (child.pid !== void 0 && child.exitCode === null && child.signalCode === null) signalProcessTree(child.pid, "SIGKILL", { detached });
|
|
115
|
+
await Promise.race([closed, setTimeout$1(HANDSHAKE_EXIT_TIMEOUT_MS, void 0, { ref: false })]);
|
|
116
|
+
child.stdin.destroy();
|
|
117
|
+
child.stdout.destroy();
|
|
118
|
+
child.stderr.destroy();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function readInitializeReply(child, timeoutMs) {
|
|
122
|
+
const { promise, resolve, reject } = createDeferred();
|
|
123
|
+
let pending = "";
|
|
124
|
+
let received = 0;
|
|
125
|
+
let stderrTail = "";
|
|
126
|
+
const timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`timed out after ${timeoutMs} ms`)), timeoutMs);
|
|
127
|
+
child.once("error", reject);
|
|
128
|
+
child.once("exit", (code, signal) => {
|
|
129
|
+
const stderr = stderrTail.trim();
|
|
130
|
+
reject(/* @__PURE__ */ new Error(`exited (${signal ?? code}) before answering initialize${stderr ? `: ${stderr}` : ""}`));
|
|
131
|
+
});
|
|
132
|
+
child.stderr.setEncoding("utf8");
|
|
133
|
+
child.stderr.on("data", (chunk) => {
|
|
134
|
+
stderrTail = `${stderrTail}${chunk}`.slice(-1024);
|
|
135
|
+
});
|
|
136
|
+
child.stdout.setEncoding("utf8");
|
|
137
|
+
child.stdout.on("data", (chunk) => {
|
|
138
|
+
received += chunk.length;
|
|
139
|
+
if (received > HANDSHAKE_MAX_OUTPUT_CHARS) {
|
|
140
|
+
reject(/* @__PURE__ */ new Error("output exceeded its capture limit before initialize"));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
pending += chunk;
|
|
144
|
+
for (let newline = pending.indexOf("\n"); newline >= 0; newline = pending.indexOf("\n")) {
|
|
145
|
+
const reply = parseInitializeReply(pending.slice(0, newline));
|
|
146
|
+
pending = pending.slice(newline + 1);
|
|
147
|
+
if (reply && "error" in reply) {
|
|
148
|
+
reject(/* @__PURE__ */ new Error(`initialize failed: ${JSON.stringify(reply.error).slice(0, 512)}`));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (reply) {
|
|
152
|
+
resolve(readCodexVersionFromUserAgent(reply.userAgent));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
child.stdin.on("error", () => void 0);
|
|
158
|
+
child.stdin.write(`${JSON.stringify({
|
|
159
|
+
id: INITIALIZE_REQUEST_ID,
|
|
160
|
+
method: "initialize",
|
|
161
|
+
params: buildCodexAppServerInitializeParams()
|
|
162
|
+
})}\n`);
|
|
163
|
+
try {
|
|
164
|
+
return await promise;
|
|
165
|
+
} finally {
|
|
166
|
+
clearTimeout(timer);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Codex frames JSON-RPC as one JSON object per line, without a `jsonrpc` field. */
|
|
170
|
+
function parseInitializeReply(line) {
|
|
171
|
+
let message;
|
|
172
|
+
try {
|
|
173
|
+
message = JSON.parse(line);
|
|
174
|
+
} catch {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (typeof message !== "object" || message === null || !("id" in message)) return;
|
|
178
|
+
if (message.id !== INITIALIZE_REQUEST_ID) return;
|
|
179
|
+
if ("error" in message) return { error: message.error };
|
|
180
|
+
const result = "result" in message ? message.result : void 0;
|
|
181
|
+
const userAgent = typeof result === "object" && result !== null && "userAgent" in result ? result.userAgent : void 0;
|
|
182
|
+
return { userAgent: typeof userAgent === "string" ? userAgent : void 0 };
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
export { probeCodexAppServerHandshake };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { d as readCodexPluginConfig } from "./config-parsing-DsWSCPHO.mjs";
|
|
2
|
-
import { i as resolveCodexAppServerHomeScope } from "./config-options-
|
|
3
|
-
import "./config-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { runBoundedCodexAppServerTurn } from "./bounded-turn-
|
|
7
|
-
import { t as resolveCodexBoundedTurnIsolation } from "./bounded-turn-isolation-
|
|
8
|
-
import { a as createAttributedCodexAssistantMessage } from "./event-projector-assistant-message-
|
|
2
|
+
import { i as resolveCodexAppServerHomeScope } from "./config-options-DMFZkd3X.mjs";
|
|
3
|
+
import "./config-BfrAlTMT.mjs";
|
|
4
|
+
import { Q as resolveCodexAppServerPreparedAuthHandoff } from "./shared-client-CE_uY0A1.mjs";
|
|
5
|
+
import { d as assertCodexPassiveTurnItems } from "./client-BS8X7HmG.mjs";
|
|
6
|
+
import { runBoundedCodexAppServerTurn } from "./bounded-turn-mN_ekXYW.mjs";
|
|
7
|
+
import { t as resolveCodexBoundedTurnIsolation } from "./bounded-turn-isolation-D8CDrAVX.mjs";
|
|
8
|
+
import { a as createAttributedCodexAssistantMessage } from "./event-projector-assistant-message-ChOAY7rW.mjs";
|
|
9
9
|
//#region extensions/codex/src/app-server/isolated-completion.ts
|
|
10
10
|
/** Runs prompt-only Codex inference on an ephemeral, ring-zero native thread. */
|
|
11
11
|
async function runCodexIsolatedCompletion(params, options) {
|