@openclaw/codex 2026.9.4 → 2026.9.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/assets/activity.svg +30 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/account-usage-runtime-C2MOIvfq.mjs +75 -0
- package/dist/{apply-CvT8tW5i.js → .setup/apply-CJ0ZfmBG.mjs} +11 -11
- package/dist/.setup/async-questions-DdhOCwGi.mjs +27 -0
- package/dist/{attempt-client-cleanup-DKHzbwt5.js → .setup/attempt-client-cleanup-BpYKdTA0.mjs} +29 -14
- package/dist/{attempt-context-D44yeDII.js → .setup/attempt-context-VXVwTCfS.mjs} +5 -5
- package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +5 -0
- package/dist/{auth-binding-CWlKVccJ.js → .setup/auth-binding-DhLWa_7K.mjs} +1 -1
- package/dist/{auth-cache-key-7orQae_j.js → .setup/auth-cache-key-QirmgiCo.mjs} +3 -3
- package/dist/{auth-profile-CwzO4_RG.js → .setup/auth-profile-WqZtZfXN.mjs} +1 -1
- package/dist/.setup/binding-connection-Bm38niE8.mjs +50 -0
- package/dist/.setup/binding-connection.runtime-CnRMC0ta.mjs +48 -0
- package/dist/{bounded-turn-C_Hneydj.js → .setup/bounded-turn-BtlZcivC.mjs} +16 -11
- package/dist/{build-state-BCmg9-5p.js → .setup/build-state-Xx9ybZqa.mjs} +1 -1
- package/dist/{capabilities-8vx68WLH.js → .setup/capabilities-_vXcZGSx.mjs} +1 -1
- package/dist/{client-B57KWPQx.js → .setup/client-vXs2929Q.mjs} +332 -163
- package/dist/{command-dispatch-BpduNGVf.js → .setup/command-dispatch-naHIZwwF.mjs} +3 -3
- package/dist/{command-formatters-lxlkNZgU.js → .setup/command-formatters-CGEkdawF.mjs} +2 -2
- package/dist/{command-handlers-tiL9iWj7.js → .setup/command-handlers-BtAJEW1X.mjs} +59 -42
- package/dist/{command-rpc-CR5EOEZX.js → .setup/command-rpc-DHFpn4le.mjs} +22 -13
- package/dist/{compact-B_H3AOd7.js → .setup/compact-C3i3qlzj.mjs} +28 -43
- package/dist/{config-oIORaQ5T.js → .setup/config-CedDWjM-.mjs} +5 -4
- package/dist/{config-options-CXMq1T-C.js → .setup/config-options-BsanJ8QG.mjs} +6 -418
- package/dist/{protocol-5bh1G-H7.js → .setup/config-parsing-CcB9iPoq.mjs} +9 -51
- package/dist/{config-runtime-D0zGNIHu.js → .setup/config-runtime-CeAhl_h4.mjs} +2 -2
- package/dist/.setup/config-security-BRQ2mgW9.mjs +465 -0
- package/dist/{conversation-binding-DsB4-O7U.js → .setup/conversation-binding-DhzrpTM6.mjs} +23 -21
- package/dist/{conversation-binding-data-BiodpIzq.js → .setup/conversation-binding-data-CrcyZk6O.mjs} +1 -1
- package/dist/{conversation-control-CtUu1b3m.js → .setup/conversation-control-DN53ns41.mjs} +17 -13
- package/dist/.setup/cyber-failover-DYwbmf1o.mjs +123 -0
- package/dist/.setup/cyber-failover-notice-e9G3J9-e.mjs +17 -0
- package/dist/{dynamic-tools-CmN5RAip.js → .setup/dynamic-tools-D16lOp67.mjs} +101 -55
- package/dist/{effective-mcp-catalog-Bd73bqA8.js → .setup/effective-mcp-catalog-K6kLCN8X.mjs} +3 -3
- package/dist/{ephemeral-turn-D78_VmzO.js → .setup/ephemeral-turn-R1gA8Sn6.mjs} +4 -5
- package/dist/{event-projector-assistant-message-BmBM4qBV.js → .setup/event-projector-assistant-message-DNUR1s0A.mjs} +6 -3
- package/dist/{event-projector-items-5VhsECCO.js → .setup/event-projector-items-DyTQ_XqL.mjs} +1 -1
- package/dist/{attempt-notifications-C9XufG6l.js → .setup/event-projector-usage-C7Ntzs-f.mjs} +102 -9
- package/dist/{harness-C7rRa7bm.js → .setup/harness-rxaaoN-o.mjs} +74 -20
- package/dist/{inference-context-Dr_mzvk4.js → .setup/inference-context-fulhZuz8.mjs} +1 -1
- package/dist/{inference-proxy-HGXKUIre.js → .setup/inference-proxy-CC15HuSi.mjs} +4 -4
- package/dist/{isolated-completion-DWVb5U2J.js → .setup/isolated-completion-B6srt48J.mjs} +7 -7
- package/dist/{launch-args-RXQwn8zV.js → .setup/launch-args-DnMak49W.mjs} +22 -1
- package/dist/{managed-binary-D22rNEcR.js → .setup/managed-binary-DP6Rib3P.mjs} +2 -2
- package/dist/{managed-thread-store-D1t5jh3G.js → .setup/managed-thread-store-BMqgThVL.mjs} +48 -14
- package/dist/{model-catalog-Dq2n8f_p.js → .setup/model-catalog-DkvUuBey.mjs} +35 -10
- package/dist/{models-PCKOim-h.js → .setup/models-BDFgm_G-.mjs} +3 -3
- package/dist/.setup/native-auth-BLZGqFjw.mjs +57 -0
- package/dist/{native-subagent-history-DjtPloaU.js → .setup/native-subagent-history-YXaL6dMd.mjs} +24 -29
- package/dist/.setup/native-subagent-monitor-B1hxzIOy.mjs +5031 -0
- package/dist/{native-subagent-task-ids-BzTdT0Uw.js → .setup/native-subagent-task-ids-DsuOonKv.mjs} +32 -8
- package/dist/{node-cli-sessions-DKaOmVUh.js → .setup/node-cli-sessions-Cl8b2ZF3.mjs} +1 -1
- package/dist/{node-exec-server.runtime-Cl2vapEi.js → .setup/node-exec-server.runtime-BaViBKNz.mjs} +3 -3
- package/dist/{plan-7uG-Fp36.js → .setup/plan-xD7WKYTM.mjs} +64 -48
- package/dist/{plugin-activation-BYQculil.js → .setup/plugin-activation-r8nq5Jzp.mjs} +3 -3
- package/dist/{plugin-app-cache-key-d0eKxy7b.js → .setup/plugin-app-cache-key-BOxKP7db.mjs} +29 -25
- package/dist/{plugin-approval-roundtrip-Bz3FT8W5.js → .setup/plugin-approval-roundtrip-CjfzafAZ.mjs} +1 -1
- package/dist/{plugin-inventory-oL4Na1ZG.js → .setup/plugin-inventory-DUle8DLz.mjs} +7 -6
- package/dist/{plugin-metadata-cache-ClPJpRio.js → .setup/plugin-metadata-cache-DsS5buNa.mjs} +29 -14
- package/dist/{provider-capabilities-BvCUL69A.js → .setup/provider-capabilities-B8J4Dy-O.mjs} +2 -2
- package/dist/{provider-MQ8PVkuE.js → .setup/provider-fFh_-VR3.mjs} +4 -4
- package/dist/{rate-limits-CBMmWBr9.js → .setup/rate-limits-DOEGYRNs.mjs} +90 -46
- package/dist/{request-B7hEkBGq.js → .setup/request-BioXJLYa.mjs} +113 -33
- package/dist/.setup/run-attempt-lifecycle-B7JbY4-F.mjs +71 -0
- package/dist/{run-attempt-CvsAAGa0.js → .setup/run-attempt-rlA07pUv.mjs} +580 -498
- package/dist/{runtime-artifact-BJ0rXBZ_.js → .setup/runtime-artifact-Dy38Z5iU.mjs} +2 -2
- package/dist/{sandbox-guard-BxgyoM8M.js → .setup/sandbox-guard-BBP-RbTf.mjs} +3 -3
- package/dist/{session-binding-CI8UuilT.js → .setup/session-binding-_0W_fHRr.mjs} +46 -64
- package/dist/{session-binding-record-Bcvslnhf.js → .setup/session-binding-record-TH3xA0zj.mjs} +181 -3
- package/dist/.setup/session-binding-sidecars-CKYEcfNn.mjs +543 -0
- package/dist/{session-catalog-adoption-tcZi1IfX.js → .setup/session-catalog-adoption-CR_whkEW.mjs} +6 -6
- package/dist/{session-catalog-archive-CwKg8Xz2.js → .setup/session-catalog-archive-CwZaPacf.mjs} +6 -6
- package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +250 -0
- package/dist/.setup/session-catalog-fUdWDx-U.mjs +2464 -0
- package/dist/.setup/session-catalog-index-B141u15s.mjs +1070 -0
- package/dist/.setup/session-catalog-index-order-Cc5BzlQr.mjs +48 -0
- package/dist/.setup/session-catalog-index-state-BAuDztHN.mjs +180 -0
- package/dist/{thread-history-page-D0JIp48V.js → .setup/session-catalog-native-projection-ChV3cCtm.mjs} +206 -95
- package/dist/{session-catalog-node-adoption-B1tgDW-m.js → .setup/session-catalog-node-adoption-BVRsYOSh.mjs} +3 -3
- package/dist/{session-catalog-node-continue-Ci-DXyJP.js → .setup/session-catalog-node-continue-Dowv8osw.mjs} +7 -7
- package/dist/.setup/session-catalog-projection-C1Bj9Jl-.mjs +414 -0
- package/dist/{session-cli-DNN_jhGc.js → .setup/session-cli-DIj-IE-E.mjs} +4 -4
- package/dist/{session-history-Cz-tOOYj.js → .setup/session-history-C--SrLI8.mjs} +10 -5
- package/dist/{session-history-import-DwyijFI6.js → .setup/session-history-import-JHXT5Xfi.mjs} +4 -4
- package/dist/{session-history-read-cxPUxyVV.js → .setup/session-history-read-B3ZfSUbF.mjs} +2 -2
- package/dist/{session-history.worker-BeK1YOyT.js → .setup/session-history.worker-CpNj7H_P.mjs} +5 -6
- package/dist/{session-initialization-Ct0_Hzmg.js → .setup/session-initialization-DH1z6fXn.mjs} +2 -2
- package/dist/{session-permission-policy-BBmXA8Eg.js → .setup/session-permission-policy-DhurXY0l.mjs} +2 -2
- package/dist/{session-retirement-B2YfbAAT.js → .setup/session-retirement-CU87AOg9.mjs} +6 -6
- package/dist/{settled-turn-context-Du6gdUDd.js → .setup/settled-turn-context-fmwouT5I.mjs} +2 -2
- package/dist/{settled-turn-finalizer-Dn91stmc.js → .setup/settled-turn-finalizer-CiY2bLFK.mjs} +9 -9
- package/dist/{shared-client-CscigXXL.js → .setup/shared-client-BpTtuLQ5.mjs} +286 -145
- package/dist/{side-question-BGMJQf4U.js → .setup/side-question-DSCZyoBD.mjs} +64 -47
- package/dist/{source-CElXU0Oy.js → .setup/source-Bjp4UQij.mjs} +7 -6
- package/dist/{thread-archive-guard-DfpBr-Sz.js → .setup/thread-archive-guard-jmecf6OJ.mjs} +1 -1
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +83 -0
- package/dist/{thread-lifecycle-DXl1-I6b.js → .setup/thread-lifecycle-Cik28qWn.mjs} +256 -128
- package/dist/{thread-ownership-BsDRTsyp.js → .setup/thread-ownership-skomxnIt.mjs} +4 -4
- package/dist/{thread-policy-BuEQfE0g.js → .setup/thread-policy-Cjs4B8xf.mjs} +2 -2
- package/dist/{thread-resume-DsDOZpFg.js → .setup/thread-resume-BkNpj9Pz.mjs} +8 -5
- package/dist/.setup/timeout-DZF05XrR.mjs +63 -0
- package/dist/{transcript-history-projection-v17wXgdK.js → .setup/transcript-history-projection-DHNBDhCU.mjs} +8 -3
- package/dist/{transcript-mirror-C5CKgNy6.js → .setup/transcript-mirror-D4qp_leP.mjs} +15 -6
- package/dist/{transcript-mirror-attestation-DibE0krH.js → .setup/transcript-mirror-attestation-CzM-94NC.mjs} +4 -1
- package/dist/{transport-stdio-BGjHoYLr.js → .setup/transport-stdio-Cmx94Oiy.mjs} +149 -44
- package/dist/{upstream-session-fork-BZerMte_.js → .setup/upstream-session-fork-D3UKxgVD.mjs} +27 -26
- package/dist/{usage-tCk-mg_x.js → .setup/usage-BOgBEKso.mjs} +4 -4
- package/dist/.setup/usage-limit-error-C0ow7DOc.mjs +166 -0
- package/dist/{version-omm6IPI3.js → .setup/version-CoqzXPgK.mjs} +1 -1
- package/dist/{web-search-provider.runtime-B7bGbGWq.js → .setup/web-search-provider.runtime-CTGuJt6i.mjs} +3 -3
- package/dist/api.js +6 -6
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +8 -528
- package/dist/harness.js +1 -1
- package/dist/index.js +123 -83
- package/dist/media-understanding-provider.js +3 -3
- package/dist/migration-provider-api.js +1 -1
- package/dist/native-tool-policy.js +12 -0
- package/dist/provider-discovery.js +18 -0
- package/dist/session-history-worker-runtime.js +23 -5
- package/dist/session-history.worker.js +2 -2
- package/dist/web-search-contract-api.js +1 -1
- package/openclaw.plugin.json +354 -69
- package/package.json +11 -8
- package/dist/binding-connection-D3udKbIE.js +0 -60
- package/dist/event-projector-usage-BfXmpOec.js +0 -102
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +0 -34
- package/dist/native-subagent-monitor-fQ7eIXEf.js +0 -2978
- package/dist/rpc-error-ttN_QjEm.js +0 -30
- package/dist/session-catalog-ct-AH01I.js +0 -1477
- package/dist/session-catalog-home-id-CwhLdC03.js +0 -18
- package/dist/session-catalog-provenance-D-dIfRAH.js +0 -96
- package/dist/timeout-BVw8aaM1.js +0 -33
- package/dist/{auth-profile-selection-DFu9e167.js → .setup/auth-profile-selection-DFu9e167.mjs} +0 -0
- package/dist/{config-utils-DujwEnhg.js → .setup/config-utils-DujwEnhg.mjs} +0 -0
- package/dist/{context-compaction-activity-CMla5FPJ.js → .setup/context-compaction-activity-CMla5FPJ.mjs} +0 -0
- package/dist/{elicitation-input-DPoK8F7w.js → .setup/elicitation-input-DPoK8F7w.mjs} +0 -0
- package/dist/{history-rejection-B4nOXNXF.js → .setup/history-rejection-B4nOXNXF.mjs} +0 -0
- package/dist/{image-payload-sanitizer-tupAr-2o.js → .setup/image-payload-sanitizer-tupAr-2o.mjs} +0 -0
- package/dist/{incognito-session-uhrBF6wJ.js → .setup/incognito-session-uhrBF6wJ.mjs} +0 -0
- package/dist/{local-runtime-attribution-B_2mnqhb.js → .setup/local-runtime-attribution-B_2mnqhb.mjs} +0 -0
- package/dist/{native-execution-policy-umd0tgh4.js → .setup/native-execution-policy-YBMHSzC4.mjs} +1 -1
- /package/dist/{plugin-marketplace-discovery-P-Vndfqq.js → .setup/plugin-marketplace-discovery-P-Vndfqq.mjs} +0 -0
- /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
- /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
- /package/dist/{session-upstream-marker-D15C9NHp.js → .setup/session-upstream-marker-D15C9NHp.mjs} +0 -0
- /package/dist/{upstream-prompt-provenance-LphB8slG.js → .setup/upstream-prompt-provenance-LphB8slG.mjs} +0 -0
- /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
package/dist/{attempt-notifications-C9XufG6l.js → .setup/event-projector-usage-C7Ntzs-f.mjs}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
1
|
+
import { m as isJsonObject } from "./config-security-BRQ2mgW9.mjs";
|
|
2
|
+
import { asSafeIntegerInRange, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { normalizeUsage } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
3
4
|
//#region extensions/codex/src/app-server/attempt-notifications.ts
|
|
4
5
|
const CODEX_TURN_ABORT_MARKER_START = "<turn_aborted>";
|
|
5
6
|
const CODEX_TURN_ABORT_MARKER_END = "</turn_aborted>";
|
|
@@ -34,12 +35,6 @@ function isRawFunctionToolOutputCompletionNotification(notification) {
|
|
|
34
35
|
const item = isJsonObject(notification.params.item) ? notification.params.item : void 0;
|
|
35
36
|
return item ? readStringField(item, "type") === "function_call_output" : false;
|
|
36
37
|
}
|
|
37
|
-
/** Distinguishes progress-only assistant items from conversation answers. */
|
|
38
|
-
function isAssistantCommentaryCompletionNotification(notification) {
|
|
39
|
-
if (!isJsonObject(notification.params) || notification.method !== "item/completed") return false;
|
|
40
|
-
const item = isJsonObject(notification.params.item) ? notification.params.item : void 0;
|
|
41
|
-
return Boolean(item && readStringField(item, "type") === "agentMessage" && (readStringField(item, "phase") === "commentary" || readStringField(item, "delivery") === "async"));
|
|
42
|
-
}
|
|
43
38
|
/** Returns true for terminal app-server thread status strings. */
|
|
44
39
|
function isTerminalTurnStatus(status) {
|
|
45
40
|
return status === "completed" || status === "interrupted" || status === "failed";
|
|
@@ -106,4 +101,102 @@ function isNonEmptyString(value) {
|
|
|
106
101
|
return typeof value === "string" && value.length > 0;
|
|
107
102
|
}
|
|
108
103
|
//#endregion
|
|
109
|
-
|
|
104
|
+
//#region extensions/codex/src/app-server/event-projector-usage.ts
|
|
105
|
+
function readTokenCount(record, key) {
|
|
106
|
+
return asSafeIntegerInRange(record[key], { min: 0 });
|
|
107
|
+
}
|
|
108
|
+
function readCodexThreadTokenUsage(params) {
|
|
109
|
+
const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
|
|
110
|
+
const last = tokenUsage && isJsonObject(tokenUsage.last) ? tokenUsage.last : void 0;
|
|
111
|
+
return last ? normalizeCodexResponseTokenUsage(last) : void 0;
|
|
112
|
+
}
|
|
113
|
+
function readCodexThreadContextSnapshot(params) {
|
|
114
|
+
const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
|
|
115
|
+
const last = tokenUsage && isJsonObject(tokenUsage.last) ? tokenUsage.last : void 0;
|
|
116
|
+
const modelContextWindow = tokenUsage ? readTokenCount(tokenUsage, "modelContextWindow") : void 0;
|
|
117
|
+
const activeContextTokens = last ? readTokenCount(last, "totalTokens") : void 0;
|
|
118
|
+
const inputTokens = last ? readTokenCount(last, "inputTokens") : void 0;
|
|
119
|
+
const cachedInputTokens = last ? readTokenCount(last, "cachedInputTokens") : void 0;
|
|
120
|
+
const cacheWriteInputTokens = last ? readTokenCount(last, "cacheWriteInputTokens") : void 0;
|
|
121
|
+
const reasoningOutputTokens = last ? readTokenCount(last, "reasoningOutputTokens") : void 0;
|
|
122
|
+
return {
|
|
123
|
+
...activeContextTokens !== void 0 ? { activeContextTokens } : {},
|
|
124
|
+
...cachedInputTokens !== void 0 ? { cachedInputTokens } : {},
|
|
125
|
+
...cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens } : {},
|
|
126
|
+
...inputTokens !== void 0 ? { inputTokens } : {},
|
|
127
|
+
...modelContextWindow && modelContextWindow > 0 ? { modelContextWindow } : {},
|
|
128
|
+
...inputTokens !== void 0 ? { promptTokens: inputTokens } : {},
|
|
129
|
+
...reasoningOutputTokens !== void 0 ? { reasoningOutputTokens } : {}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function normalizeCodexResponseTokenUsage(record) {
|
|
133
|
+
const totalTokens = readTokenCount(record, "totalTokens");
|
|
134
|
+
const inputTokens = readTokenCount(record, "inputTokens");
|
|
135
|
+
const cacheRead = readTokenCount(record, "cachedInputTokens");
|
|
136
|
+
const output = readTokenCount(record, "outputTokens");
|
|
137
|
+
const reasoningTokens = readTokenCount(record, "reasoningOutputTokens");
|
|
138
|
+
const cacheWrite = record.cacheWriteInputTokens === void 0 ? 0 : readTokenCount(record, "cacheWriteInputTokens");
|
|
139
|
+
const hasCoherentInput = inputTokens !== void 0 && cacheRead !== void 0 && cacheWrite !== void 0 && cacheRead + cacheWrite <= inputTokens;
|
|
140
|
+
const hasCoherentContext = hasCoherentInput && totalTokens !== void 0 && output !== void 0 && totalTokens === inputTokens + output;
|
|
141
|
+
const usage = normalizeUsage({
|
|
142
|
+
input: hasCoherentInput ? inputTokens - cacheRead - cacheWrite : void 0,
|
|
143
|
+
output,
|
|
144
|
+
cacheRead,
|
|
145
|
+
cacheWrite,
|
|
146
|
+
reasoningTokens,
|
|
147
|
+
total: totalTokens
|
|
148
|
+
});
|
|
149
|
+
if (!usage) return;
|
|
150
|
+
return {
|
|
151
|
+
...usage,
|
|
152
|
+
contextUsage: hasCoherentContext ? {
|
|
153
|
+
state: "available",
|
|
154
|
+
promptTokens: inputTokens,
|
|
155
|
+
totalTokens
|
|
156
|
+
} : { state: "unavailable" }
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
var CodexUsageProjection = class {
|
|
160
|
+
constructor() {
|
|
161
|
+
this.responseIds = /* @__PURE__ */ new Set();
|
|
162
|
+
}
|
|
163
|
+
get usage() {
|
|
164
|
+
const usage = this.responseUsage ?? this.threadUsage;
|
|
165
|
+
return usage ? {
|
|
166
|
+
...usage,
|
|
167
|
+
contextUsage: this.contextUsage
|
|
168
|
+
} : void 0;
|
|
169
|
+
}
|
|
170
|
+
get modelIterations() {
|
|
171
|
+
return this.responseIds.size;
|
|
172
|
+
}
|
|
173
|
+
invalidateContext() {
|
|
174
|
+
this.contextUsage = { state: "unavailable" };
|
|
175
|
+
}
|
|
176
|
+
recordThread(params) {
|
|
177
|
+
const usage = readCodexThreadTokenUsage(params);
|
|
178
|
+
this.threadUsage = usage ?? this.threadUsage;
|
|
179
|
+
if (!this.responseUsage && usage) this.contextUsage = usage.contextUsage;
|
|
180
|
+
return readCodexThreadContextSnapshot(params);
|
|
181
|
+
}
|
|
182
|
+
record(params, reportOutputTokens) {
|
|
183
|
+
const responseId = readStringField(params, "responseId");
|
|
184
|
+
if (!responseId || this.responseIds.has(responseId)) return;
|
|
185
|
+
this.responseIds.add(responseId);
|
|
186
|
+
const usage = isJsonObject(params.usage) ? normalizeCodexResponseTokenUsage(params.usage) : void 0;
|
|
187
|
+
this.contextUsage = usage?.contextUsage ?? { state: "unavailable" };
|
|
188
|
+
this.responseUsage ??= {};
|
|
189
|
+
for (const field of [
|
|
190
|
+
"input",
|
|
191
|
+
"output",
|
|
192
|
+
"cacheRead",
|
|
193
|
+
"cacheWrite",
|
|
194
|
+
"reasoningTokens",
|
|
195
|
+
"total"
|
|
196
|
+
]) if (usage?.[field] !== void 0) this.responseUsage[field] = (this.responseUsage[field] ?? 0) + usage[field];
|
|
197
|
+
const outputTokens = usage?.output;
|
|
198
|
+
if (outputTokens !== void 0) reportOutputTokens?.(outputTokens);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
//#endregion
|
|
202
|
+
export { isPendingOpenClawDynamicToolCompletionNotification as a, readCodexNotificationItem as c, updateActiveTurnItemIds as d, isCodexTurnAbortMarkerNotification as i, readNotificationItemId as l, readCodexThreadContextSnapshot as n, isRawFunctionToolOutputCompletionNotification as o, codexExecutionToolName as r, isTerminalTurnStatus as s, CodexUsageProjection as t, readRawResponseToolCallId as u };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CODEX_NATIVE_TOOL_REQUIREMENTS } from "../native-tool-policy.js";
|
|
2
|
+
import { p as sessionBindingIdentity } from "./session-binding-record-TH3xA0zj.mjs";
|
|
3
|
+
import { t as codexBuildSymbol } from "./build-state-Xx9ybZqa.mjs";
|
|
3
4
|
import { resolvePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
4
5
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
6
|
//#region extensions/codex/src/app-server/model-runtime.ts
|
|
@@ -73,6 +74,7 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
73
74
|
contextEngineHostCapabilities: CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES,
|
|
74
75
|
conversationToolPolicySupport: "exact",
|
|
75
76
|
conversationToolPolicySafeDenyTools: CODEX_TOOL_POLICY_SAFE_DENY_NAMES,
|
|
77
|
+
conversationToolPolicyNativeTools: CODEX_NATIVE_TOOL_REQUIREMENTS,
|
|
76
78
|
deliveryDefaults: { visibleReplies: "message_tool" },
|
|
77
79
|
authBootstrap: "harness",
|
|
78
80
|
resolveSessionRuntimeOwnership: (params) => {
|
|
@@ -103,7 +105,7 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
103
105
|
...sessionCatalogControlFactory && sessionRuntime ? { sessionFork: {
|
|
104
106
|
upstreamKinds: ["codex-app-server"],
|
|
105
107
|
fork: async (params) => {
|
|
106
|
-
const { forkCodexUpstreamSession } = await import("./upstream-session-fork-
|
|
108
|
+
const { forkCodexUpstreamSession } = await import("./upstream-session-fork-D3UKxgVD.mjs");
|
|
107
109
|
return await forkCodexUpstreamSession(params, {
|
|
108
110
|
bindingStore: options.bindingStore,
|
|
109
111
|
controlFactory: sessionCatalogControlFactory,
|
|
@@ -116,7 +118,7 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
116
118
|
taskHistory: {
|
|
117
119
|
taskKinds: ["codex-native"],
|
|
118
120
|
read: async (params) => {
|
|
119
|
-
const { readCodexNativeSubagentHistory } = await import("./native-subagent-history-
|
|
121
|
+
const { readCodexNativeSubagentHistory } = await import("./native-subagent-history-YXaL6dMd.mjs");
|
|
120
122
|
const assertCurrent = () => {
|
|
121
123
|
params.assertCurrent();
|
|
122
124
|
if (disposed) throw new Error("Agent harness is disposed");
|
|
@@ -131,26 +133,26 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
131
133
|
}
|
|
132
134
|
},
|
|
133
135
|
authBinding: { fingerprint: async (params) => {
|
|
134
|
-
const { fingerprintCodexAppServerAuthBinding } = await import("./auth-binding-
|
|
136
|
+
const { fingerprintCodexAppServerAuthBinding } = await import("./auth-binding-DhLWa_7K.mjs").then((n) => n.t);
|
|
135
137
|
return fingerprintCodexAppServerAuthBinding(params);
|
|
136
138
|
} },
|
|
137
139
|
runtimeArtifact: { validate: async (binding) => {
|
|
138
|
-
const { validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-
|
|
140
|
+
const { validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-Dy38Z5iU.mjs");
|
|
139
141
|
return validateCodexAppServerRuntimeArtifact(binding);
|
|
140
142
|
} },
|
|
141
143
|
fetchUsageSnapshot: async (ctx) => {
|
|
142
|
-
const { fetchCodexAppServerUsageSnapshot } = await import("./usage-
|
|
144
|
+
const { fetchCodexAppServerUsageSnapshot } = await import("./usage-BOgBEKso.mjs");
|
|
143
145
|
return await fetchCodexAppServerUsageSnapshot(ctx, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
|
|
144
146
|
},
|
|
145
147
|
loadModelCatalog: async (params) => {
|
|
146
|
-
const { createCodexAppServerModelCatalog } = await import("./model-catalog-
|
|
148
|
+
const { createCodexAppServerModelCatalog } = await import("./model-catalog-DkvUuBey.mjs");
|
|
147
149
|
if (disposed) return [];
|
|
148
150
|
modelCatalog ??= createCodexAppServerModelCatalog(harnessRuntimeId);
|
|
149
151
|
return await modelCatalog.load(params, resolveAttemptPluginConfig(params.config));
|
|
150
152
|
},
|
|
151
153
|
readModelCatalogReadiness: (params) => modelCatalog?.read(params, resolveAttemptPluginConfig(params.config)),
|
|
152
154
|
loadMcpToolCatalog: async (params) => {
|
|
153
|
-
const { loadCodexEffectiveMcpCatalog } = await import("./effective-mcp-catalog-
|
|
155
|
+
const { loadCodexEffectiveMcpCatalog } = await import("./effective-mcp-catalog-K6kLCN8X.mjs");
|
|
154
156
|
return await loadCodexEffectiveMcpCatalog(params, { bindingStore: options.bindingStore });
|
|
155
157
|
},
|
|
156
158
|
supports: (ctx) => {
|
|
@@ -193,21 +195,73 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
193
195
|
};
|
|
194
196
|
},
|
|
195
197
|
runAttempt: async (params) => {
|
|
196
|
-
const { runCodexAppServerAttempt } = await import("./run-attempt-
|
|
197
|
-
|
|
198
|
+
const { runCodexAppServerAttempt } = await import("./run-attempt-rlA07pUv.mjs");
|
|
199
|
+
const { planCodexCyberEscalation, readCodexCyberAttemptVerdict, recordCodexCyberTargetUnavailable, reserveCodexCyberProbe, resolveCodexCyberFailoverConfig } = await import("./cyber-failover-DYwbmf1o.mjs");
|
|
200
|
+
const { emitCodexCyberNotice } = await import("./cyber-failover-notice-e9G3J9-e.mjs");
|
|
201
|
+
const pluginConfig = resolveAttemptPluginConfig(params.config);
|
|
202
|
+
const attemptModel = readCodexRuntimeModelId(params.model, params.modelId);
|
|
203
|
+
const runAttemptOnModel = (model, isRetry = false) => runCodexAppServerAttempt(isRetry ? {
|
|
204
|
+
...params,
|
|
205
|
+
suppressNextUserMessagePersistence: true
|
|
206
|
+
} : params, {
|
|
198
207
|
bindingStore: options.bindingStore,
|
|
199
|
-
pluginConfig
|
|
208
|
+
pluginConfig,
|
|
200
209
|
runtime: sessionRuntime,
|
|
201
|
-
runtimeModelId:
|
|
210
|
+
runtimeModelId: model,
|
|
202
211
|
nativeHookRelay: { enabled: true }
|
|
203
212
|
});
|
|
213
|
+
const cyberFailover = resolveCodexCyberFailoverConfig(pluginConfig);
|
|
214
|
+
const workspace = {
|
|
215
|
+
agentId: params.agentId,
|
|
216
|
+
authProfileId: params.authProfileId
|
|
217
|
+
};
|
|
218
|
+
const result = await runAttemptOnModel(attemptModel);
|
|
219
|
+
const refusal = readCodexCyberAttemptVerdict(result);
|
|
220
|
+
if (!refusal.cyberRefused) return result;
|
|
221
|
+
const plan = planCodexCyberEscalation({
|
|
222
|
+
config: cyberFailover,
|
|
223
|
+
currentModel: attemptModel,
|
|
224
|
+
replaySafe: refusal.replaySafe,
|
|
225
|
+
workspace
|
|
226
|
+
});
|
|
227
|
+
if (plan.kind !== "escalate") {
|
|
228
|
+
if (plan.reason === "target_unavailable") await emitCodexCyberNotice(params, {
|
|
229
|
+
state: "unavailable",
|
|
230
|
+
model: attemptModel,
|
|
231
|
+
fallbackModel: cyberFailover.model
|
|
232
|
+
});
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
const releaseProbe = reserveCodexCyberProbe({
|
|
236
|
+
model: plan.model,
|
|
237
|
+
workspace
|
|
238
|
+
});
|
|
239
|
+
let escalated;
|
|
240
|
+
try {
|
|
241
|
+
escalated = await runAttemptOnModel(plan.model, true);
|
|
242
|
+
} finally {
|
|
243
|
+
releaseProbe();
|
|
244
|
+
}
|
|
245
|
+
const outcome = readCodexCyberAttemptVerdict(escalated);
|
|
246
|
+
if (outcome.unavailable) recordCodexCyberTargetUnavailable({
|
|
247
|
+
model: plan.model,
|
|
248
|
+
workspace,
|
|
249
|
+
cooloffMs: cyberFailover.cooloffMs
|
|
250
|
+
});
|
|
251
|
+
if (outcome.answered || outcome.unavailable) await emitCodexCyberNotice(params, {
|
|
252
|
+
state: outcome.answered ? "escalated" : "unavailable",
|
|
253
|
+
model: attemptModel,
|
|
254
|
+
fallbackModel: plan.model
|
|
255
|
+
});
|
|
256
|
+
if (outcome.unavailable && outcome.replaySafe && escalated.terminal.kind === "failed" && escalated.toolMetas.length === 0) return result;
|
|
257
|
+
return escalated;
|
|
204
258
|
},
|
|
205
259
|
runIsolatedCompletionV2: async (params) => {
|
|
206
260
|
if (params.authorization.owner === "host") {
|
|
207
261
|
const { runHostPreparedIsolatedCompletion } = await import("openclaw/plugin-sdk/simple-completion-runtime");
|
|
208
262
|
return runHostPreparedIsolatedCompletion(params);
|
|
209
263
|
}
|
|
210
|
-
const { runCodexIsolatedCompletion } = await import("./isolated-completion-
|
|
264
|
+
const { runCodexIsolatedCompletion } = await import("./isolated-completion-B6srt48J.mjs");
|
|
211
265
|
return runCodexIsolatedCompletion(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
|
|
212
266
|
},
|
|
213
267
|
runIsolatedCompletion: async (params) => {
|
|
@@ -223,11 +277,11 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
223
277
|
});
|
|
224
278
|
},
|
|
225
279
|
finalizeSettledTurn: async (params) => {
|
|
226
|
-
const { runCodexSettledTurnFinalization } = await import("./settled-turn-finalizer-
|
|
280
|
+
const { runCodexSettledTurnFinalization } = await import("./settled-turn-finalizer-CiY2bLFK.mjs");
|
|
227
281
|
return runCodexSettledTurnFinalization(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
|
|
228
282
|
},
|
|
229
283
|
runSideQuestion: async (params) => {
|
|
230
|
-
const { runCodexAppServerSideQuestion } = await import("./side-question-
|
|
284
|
+
const { runCodexAppServerSideQuestion } = await import("./side-question-DSCZyoBD.mjs");
|
|
231
285
|
return runCodexAppServerSideQuestion(params, {
|
|
232
286
|
bindingStore: options.bindingStore,
|
|
233
287
|
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
|
|
@@ -237,20 +291,20 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
237
291
|
});
|
|
238
292
|
},
|
|
239
293
|
compact: async (params) => {
|
|
240
|
-
const { maybeCompactCodexAppServerSession } = await import("./compact-
|
|
294
|
+
const { maybeCompactCodexAppServerSession } = await import("./compact-C3i3qlzj.mjs");
|
|
241
295
|
return maybeCompactCodexAppServerSession(params, {
|
|
242
296
|
bindingStore: options.bindingStore,
|
|
243
297
|
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig
|
|
244
298
|
});
|
|
245
299
|
},
|
|
246
300
|
withSessionDeletion: async (params, run) => {
|
|
247
|
-
const { withCodexAppServerSessionDeletion } = await import("./session-retirement-
|
|
301
|
+
const { withCodexAppServerSessionDeletion } = await import("./session-retirement-CU87AOg9.mjs");
|
|
248
302
|
params.assertCurrent();
|
|
249
303
|
return withCodexAppServerSessionDeletion(options.bindingStore, params, run);
|
|
250
304
|
},
|
|
251
305
|
reset: async (params) => {
|
|
252
306
|
if (params.sessionId && params.reason !== "deleted") {
|
|
253
|
-
const [{ reclaimCurrentCodexSessionGeneration }, { retireCodexAppServerSessionGeneration }] = await Promise.all([import("./session-binding-
|
|
307
|
+
const [{ reclaimCurrentCodexSessionGeneration }, { retireCodexAppServerSessionGeneration }] = await Promise.all([import("./session-binding-_0W_fHRr.mjs").then((n) => n.c), import("./session-retirement-CU87AOg9.mjs")]);
|
|
254
308
|
const identity = sessionBindingIdentity({
|
|
255
309
|
agentId: params.agentId,
|
|
256
310
|
sessionId: params.sessionId,
|
|
@@ -282,7 +336,7 @@ function createCodexAppServerAgentHarness(options) {
|
|
|
282
336
|
/** Creates the private native-compaction bridge registered in host-owned capability state. */
|
|
283
337
|
function createCodexAppServerNativeCompaction(options) {
|
|
284
338
|
return async (params) => {
|
|
285
|
-
const { maybeCompactCodexAppServerSession } = await import("./compact-
|
|
339
|
+
const { maybeCompactCodexAppServerSession } = await import("./compact-C3i3qlzj.mjs");
|
|
286
340
|
return maybeCompactCodexAppServerSession(params, {
|
|
287
341
|
bindingStore: options.bindingStore,
|
|
288
342
|
pluginConfig: options.resolvePluginConfig?.() ?? options.pluginConfig,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as isJsonObject } from "./config-security-BRQ2mgW9.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
//#region extensions/codex/src/app-server/inference-context.ts
|
|
4
4
|
const MAX_CONTEXT_BYTES = 262144;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as createCodexInferenceContext } from "./inference-context-
|
|
3
|
-
import { zstdCompress, zstdDecompress } from "node:zlib";
|
|
1
|
+
import { m as isJsonObject } from "./config-security-BRQ2mgW9.mjs";
|
|
2
|
+
import { n as createCodexInferenceContext } from "./inference-context-fulhZuz8.mjs";
|
|
4
3
|
import { promisify } from "node:util";
|
|
4
|
+
import { zstdCompress, zstdDecompress } from "node:zlib";
|
|
5
5
|
import { Writable } from "node:stream";
|
|
6
|
-
import WebSocket,
|
|
6
|
+
import { WebSocket, WebSocketServer } from "openclaw/plugin-sdk/websocket-runtime";
|
|
7
7
|
import { createServer } from "node:http";
|
|
8
8
|
import { createNodeProxyAgent } from "openclaw/plugin-sdk/fetch-runtime";
|
|
9
9
|
import { generateSecureToken } from "openclaw/plugin-sdk/secure-random-runtime";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "./config-
|
|
5
|
-
import {
|
|
6
|
-
import { runBoundedCodexAppServerTurn } from "./bounded-turn-
|
|
7
|
-
import { a as createAttributedCodexAssistantMessage } from "./event-projector-assistant-message-
|
|
1
|
+
import { d as readCodexPluginConfig } from "./config-parsing-CcB9iPoq.mjs";
|
|
2
|
+
import { g as assertCodexPassiveTurnItems } from "./client-vXs2929Q.mjs";
|
|
3
|
+
import { i as resolveCodexAppServerHomeScope } from "./config-options-BsanJ8QG.mjs";
|
|
4
|
+
import "./config-CedDWjM-.mjs";
|
|
5
|
+
import { Z as resolveCodexAppServerPreparedAuthHandoff } from "./shared-client-BpTtuLQ5.mjs";
|
|
6
|
+
import { runBoundedCodexAppServerTurn } from "./bounded-turn-BtlZcivC.mjs";
|
|
7
|
+
import { a as createAttributedCodexAssistantMessage } from "./event-projector-assistant-message-DNUR1s0A.mjs";
|
|
8
8
|
//#region extensions/codex/src/app-server/isolated-completion.ts
|
|
9
9
|
/** Runs prompt-only Codex inference on an ephemeral, ring-zero native thread. */
|
|
10
10
|
async function runCodexIsolatedCompletion(params, options) {
|
|
@@ -55,6 +55,27 @@ function readCodexArgs(args) {
|
|
|
55
55
|
}
|
|
56
56
|
return tokens;
|
|
57
57
|
}
|
|
58
|
+
/** Uses the native CLI configuration for status without starting its transport. */
|
|
59
|
+
function buildCodexLoginStatusArgs(args) {
|
|
60
|
+
const options = /* @__PURE__ */ new Set([
|
|
61
|
+
"-c",
|
|
62
|
+
"--config",
|
|
63
|
+
"-p",
|
|
64
|
+
"--profile",
|
|
65
|
+
"--enable",
|
|
66
|
+
"--disable"
|
|
67
|
+
]);
|
|
68
|
+
const tokens = readCodexArgs(args);
|
|
69
|
+
const subcommandIndex = tokens.findLast(({ name }) => name === "app-server")?.index ?? -1;
|
|
70
|
+
const prefix = subcommandIndex < 0 ? [] : args.slice(0, subcommandIndex);
|
|
71
|
+
const configArgs = tokens.filter(({ index, name }) => index > subcommandIndex && options.has(name)).flatMap(({ index, end }) => args.slice(index, end));
|
|
72
|
+
return [
|
|
73
|
+
...prefix,
|
|
74
|
+
...configArgs,
|
|
75
|
+
"login",
|
|
76
|
+
"status"
|
|
77
|
+
];
|
|
78
|
+
}
|
|
58
79
|
function readCodexAppServerConfigOptions(args) {
|
|
59
80
|
return readCodexArgs(args).filter(({ name }) => name === "-c" || name === "--config" || name === "-p" || name === "--profile");
|
|
60
81
|
}
|
|
@@ -87,4 +108,4 @@ function normalizeCodexAppServerArgs(rawArgs, enforcedOverride) {
|
|
|
87
108
|
return normalized.length === rawArgs.length && normalized.every((arg, index) => arg === rawArgs[index]) ? rawArgs : normalized;
|
|
88
109
|
}
|
|
89
110
|
//#endregion
|
|
90
|
-
export {
|
|
111
|
+
export { readCodexAppServerConfigOptions as i, isCodexAppServerProxyLaunch as n, normalizeCodexAppServerArgs as r, buildCodexLoginStatusArgs as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.
|
|
2
|
-
import { n as MANAGED_CODEX_APP_SERVER_PACKAGE } from "./version-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { n as MANAGED_CODEX_APP_SERVER_PACKAGE } from "./version-CoqzXPgK.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { constants, existsSync, realpathSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
@@ -28,10 +28,53 @@ function managedThreadStoreKey(sourceHomeId, threadId) {
|
|
|
28
28
|
}
|
|
29
29
|
/** Durable ownership index for Codex threads created by OpenClaw. */
|
|
30
30
|
function createCodexManagedThreadStore(state) {
|
|
31
|
+
const byHome = /* @__PURE__ */ new Map();
|
|
32
|
+
const memberships = /* @__PURE__ */ new Map();
|
|
33
|
+
let hydration;
|
|
34
|
+
const remember = ({ sourceHomeId, threadId }) => {
|
|
35
|
+
const key = managedThreadStoreKey(sourceHomeId, threadId);
|
|
36
|
+
if (memberships.has(key)) return key;
|
|
37
|
+
memberships.set(key, {
|
|
38
|
+
sourceHomeId,
|
|
39
|
+
threadId
|
|
40
|
+
});
|
|
41
|
+
let ids = byHome.get(sourceHomeId);
|
|
42
|
+
if (!ids) {
|
|
43
|
+
ids = /* @__PURE__ */ new Set();
|
|
44
|
+
byHome.set(sourceHomeId, ids);
|
|
45
|
+
}
|
|
46
|
+
ids.add(threadId);
|
|
47
|
+
if (memberships.size > 2e4) {
|
|
48
|
+
const oldest = memberships.entries().next().value;
|
|
49
|
+
if (oldest) {
|
|
50
|
+
memberships.delete(oldest[0]);
|
|
51
|
+
const oldestHome = byHome.get(oldest[1].sourceHomeId);
|
|
52
|
+
oldestHome?.delete(oldest[1].threadId);
|
|
53
|
+
if (oldestHome?.size === 0) byHome.delete(oldest[1].sourceHomeId);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return key;
|
|
57
|
+
};
|
|
58
|
+
const snapshot = async () => {
|
|
59
|
+
hydration ??= state.entries().then((entries) => {
|
|
60
|
+
const marked = new Map(memberships);
|
|
61
|
+
memberships.clear();
|
|
62
|
+
byHome.clear();
|
|
63
|
+
for (const entry of entries.toSorted((a, b) => a.createdAt - b.createdAt)) {
|
|
64
|
+
const parsed = managedThreadSchema.safeParse(entry.value);
|
|
65
|
+
if (parsed.success) marked.delete(remember(parsed.data));
|
|
66
|
+
}
|
|
67
|
+
for (const membership of marked.values()) remember(membership);
|
|
68
|
+
}).catch((error) => {
|
|
69
|
+
hydration = void 0;
|
|
70
|
+
throw error;
|
|
71
|
+
});
|
|
72
|
+
await hydration;
|
|
73
|
+
return byHome;
|
|
74
|
+
};
|
|
31
75
|
return {
|
|
32
76
|
async has(sourceHomeId, threadId) {
|
|
33
|
-
|
|
34
|
-
return parsed.success && parsed.data.sourceHomeId === sourceHomeId && parsed.data.threadId === threadId;
|
|
77
|
+
return (await snapshot()).get(sourceHomeId)?.has(threadId) ?? false;
|
|
35
78
|
},
|
|
36
79
|
async mark(params) {
|
|
37
80
|
try {
|
|
@@ -42,24 +85,15 @@ function createCodexManagedThreadStore(state) {
|
|
|
42
85
|
threadId: params.threadId.trim(),
|
|
43
86
|
...params.rolloutPath?.trim() ? { rolloutPath: params.rolloutPath.trim() } : {}
|
|
44
87
|
});
|
|
45
|
-
state.registerIfAbsent(managedThreadStoreKey(value.sourceHomeId, value.threadId), value);
|
|
88
|
+
await state.registerIfAbsent(managedThreadStoreKey(value.sourceHomeId, value.threadId), value);
|
|
89
|
+
remember(value);
|
|
46
90
|
return true;
|
|
47
91
|
} catch (error) {
|
|
48
92
|
embeddedAgentLog.warn("failed to record Codex managed thread ownership", { error });
|
|
49
93
|
return false;
|
|
50
94
|
}
|
|
51
95
|
},
|
|
52
|
-
|
|
53
|
-
const byHome = /* @__PURE__ */ new Map();
|
|
54
|
-
for (const entry of state.entries()) {
|
|
55
|
-
const parsed = managedThreadSchema.safeParse(entry.value);
|
|
56
|
-
if (!parsed.success) continue;
|
|
57
|
-
const ids = byHome.get(parsed.data.sourceHomeId) ?? /* @__PURE__ */ new Set();
|
|
58
|
-
ids.add(parsed.data.threadId);
|
|
59
|
-
byHome.set(parsed.data.sourceHomeId, ids);
|
|
60
|
-
}
|
|
61
|
-
return byHome;
|
|
62
|
-
}
|
|
96
|
+
snapshot
|
|
63
97
|
};
|
|
64
98
|
}
|
|
65
99
|
//#endregion
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { r as buildCodexRuntimeModelParams } from "./harness-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { r as buildCodexRuntimeModelParams } from "./harness-rxaaoN-o.mjs";
|
|
2
|
+
import { m as isJsonObject } from "./config-security-BRQ2mgW9.mjs";
|
|
3
|
+
import { d as readCodexPluginConfig } from "./config-parsing-CcB9iPoq.mjs";
|
|
4
|
+
import { n as isCodexAppServerProxyLaunch } from "./launch-args-DnMak49W.mjs";
|
|
5
|
+
import { o as withCodexAppServerJsonClient } from "./request-BioXJLYa.mjs";
|
|
6
|
+
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-CeAhl_h4.mjs";
|
|
7
|
+
import { a as resolveCodexAppServerAuthProfileStore, r as resolveCodexAppServerAuthProfileId } from "./auth-profile-WqZtZfXN.mjs";
|
|
8
|
+
import { r as captureSharedCodexAppServerCatalogLifetime } from "./shared-client-BpTtuLQ5.mjs";
|
|
9
|
+
import { t as listAllCodexAppServerModels } from "./models-BDFgm_G-.mjs";
|
|
10
|
+
import { probeCodexNativeAuth } from "./native-auth-BLZGqFjw.mjs";
|
|
7
11
|
//#region extensions/codex/src/app-server/model-catalog.ts
|
|
8
12
|
const DEFAULT_MODEL_DISCOVERY_TIMEOUT_MS = 2500;
|
|
9
13
|
const INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -51,7 +55,10 @@ function createCodexAppServerModelCatalog(runtime) {
|
|
|
51
55
|
},
|
|
52
56
|
read(params, pluginConfig) {
|
|
53
57
|
const observation = scopes.get(params.config)?.get(scopeKey(params));
|
|
54
|
-
return !disposed && params.provider === "openai" && observation !== void 0 && observation.pluginConfig === pluginConfig && observation.models?.has(params.modelId) && observation.accountType && observation.isCurrent?.() ? {
|
|
58
|
+
return !disposed && params.provider === "openai" && observation !== void 0 && observation.pluginConfig === pluginConfig && observation.models?.has(params.modelId) && observation.accountType && observation.isCurrent?.() ? {
|
|
59
|
+
accountType: observation.accountType,
|
|
60
|
+
...observation.authMode ? { authMode: observation.authMode } : {}
|
|
61
|
+
} : void 0;
|
|
55
62
|
},
|
|
56
63
|
async load(params, pluginConfig) {
|
|
57
64
|
if (disposed) return [];
|
|
@@ -65,13 +72,30 @@ function createCodexAppServerModelCatalog(runtime) {
|
|
|
65
72
|
observations.set(key, observation);
|
|
66
73
|
const discovery = readCodexPluginConfig(pluginConfig).discovery;
|
|
67
74
|
if (discovery?.enabled === false) return [];
|
|
68
|
-
const
|
|
75
|
+
const options = resolveCodexAppServerRuntimeOptions({ pluginConfig });
|
|
76
|
+
const ownsLocalProcess = options.start.transport === "stdio" && !isCodexAppServerProxyLaunch(options.start.args);
|
|
77
|
+
const authProfileStore = ownsLocalProcess && options.start.homeScope === "agent" ? resolveCodexAppServerAuthProfileStore({
|
|
78
|
+
agentDir: params.agentDir,
|
|
79
|
+
config: params.config
|
|
80
|
+
}) : void 0;
|
|
81
|
+
const authProfileId = authProfileStore ? resolveCodexAppServerAuthProfileId({
|
|
82
|
+
store: authProfileStore,
|
|
83
|
+
config: params.config
|
|
84
|
+
}) : void 0;
|
|
85
|
+
const usesNativeHome = ownsLocalProcess && options.start.homeScope === "user";
|
|
86
|
+
const native = usesNativeHome ? await probeCodexNativeAuth({ pluginConfig }) : void 0;
|
|
87
|
+
if (usesNativeHome && !native || disposed || observations.get(key) !== observation) return [];
|
|
88
|
+
const { start } = options;
|
|
69
89
|
const timeoutMs = discovery?.timeoutMs ?? DEFAULT_MODEL_DISCOVERY_TIMEOUT_MS;
|
|
70
90
|
const result = await withCodexAppServerJsonClient({
|
|
71
91
|
startOptions: start,
|
|
72
92
|
config: params.config,
|
|
73
93
|
agentDir: params.agentDir,
|
|
74
|
-
timeoutMs
|
|
94
|
+
timeoutMs,
|
|
95
|
+
...authProfileStore ? {
|
|
96
|
+
authProfileStore,
|
|
97
|
+
authProfileId
|
|
98
|
+
} : {}
|
|
75
99
|
}, async (request, client) => {
|
|
76
100
|
const isCurrent = captureSharedCodexAppServerCatalogLifetime(client);
|
|
77
101
|
const models = (await listAllCodexAppServerModels({
|
|
@@ -92,8 +116,9 @@ function createCodexAppServerModelCatalog(runtime) {
|
|
|
92
116
|
});
|
|
93
117
|
if (disposed || observations.get(key) !== observation || !result.isCurrent()) return [];
|
|
94
118
|
observation.models = new Set(result.models.map((model) => model.id));
|
|
95
|
-
observation.accountType = result.accountType;
|
|
119
|
+
observation.accountType = !usesNativeHome || native?.mode === "api-key" && result.accountType === "apiKey" || (native?.mode === "oauth" || native?.mode === "token") && result.accountType === "chatgpt" ? result.accountType : void 0;
|
|
96
120
|
observation.isCurrent = result.isCurrent;
|
|
121
|
+
observation.authMode = observation.accountType === "apiKey" ? "api_key" : observation.accountType === "chatgpt" && (native?.mode === "oauth" || native?.mode === "token") ? native.mode : void 0;
|
|
97
122
|
return codexAppServerModelsToCatalogEntries(result.models, runtime);
|
|
98
123
|
}
|
|
99
124
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as assertCodexModelListResponse } from "./client-
|
|
1
|
+
import { h as assertCodexModelListResponse } from "./client-vXs2929Q.mjs";
|
|
2
2
|
import { normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
//#region extensions/codex/src/app-server/models.ts
|
|
4
4
|
/**
|
|
@@ -37,8 +37,8 @@ async function withCodexAppServerModelRequest(options, run) {
|
|
|
37
37
|
if (options.request) return await run(options.request);
|
|
38
38
|
const timeoutMs = options.timeoutMs ?? 2500;
|
|
39
39
|
const useSharedClient = options.sharedClient !== false;
|
|
40
|
-
const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-
|
|
41
|
-
const { requestCodexAppServerClientJson } = await import("./request-
|
|
40
|
+
const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-BpTtuLQ5.mjs").then((n) => n.y);
|
|
41
|
+
const { requestCodexAppServerClientJson } = await import("./request-BioXJLYa.mjs").then((n) => n.a);
|
|
42
42
|
const client = await (useSharedClient ? getLeasedSharedCodexAppServerClient : createIsolatedCodexAppServerClient)({
|
|
43
43
|
startOptions: options.startOptions,
|
|
44
44
|
timeoutMs,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { d as readCodexPluginConfig } from "./config-parsing-CcB9iPoq.mjs";
|
|
2
|
+
import { n as isCodexAppServerProxyLaunch, t as buildCodexLoginStatusArgs } from "./launch-args-DnMak49W.mjs";
|
|
3
|
+
import { r as resolveManagedCodexAppServerStartOptions } from "./managed-binary-DP6Rib3P.mjs";
|
|
4
|
+
import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-Cmx94Oiy.mjs";
|
|
5
|
+
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-CeAhl_h4.mjs";
|
|
6
|
+
import { runUtf8CommandWithTimeout } from "openclaw/plugin-sdk/process-runtime";
|
|
7
|
+
import { materializeWindowsSpawnProgram, resolveWindowsSpawnProgram } from "openclaw/plugin-sdk/windows-spawn";
|
|
8
|
+
//#region extensions/codex/src/app-server/native-auth.ts
|
|
9
|
+
const OPENAI_LOGIN_MODES = {
|
|
10
|
+
"Logged in using ChatGPT": "oauth",
|
|
11
|
+
"Logged in using access token": "token",
|
|
12
|
+
"Logged in using personal access token": "token"
|
|
13
|
+
};
|
|
14
|
+
/** Ask the selected native binary about its own store; retain no credential material. */
|
|
15
|
+
async function probeCodexNativeAuth(params) {
|
|
16
|
+
params.signal?.throwIfAborted();
|
|
17
|
+
try {
|
|
18
|
+
const pluginConfig = readCodexPluginConfig(params.pluginConfig ?? params.config?.plugins?.entries?.codex?.config);
|
|
19
|
+
const options = resolveCodexAppServerRuntimeOptions({
|
|
20
|
+
pluginConfig,
|
|
21
|
+
env: params.env
|
|
22
|
+
});
|
|
23
|
+
if (options.start.transport !== "stdio" || options.start.homeScope !== "user" || isCodexAppServerProxyLaunch(options.start.args)) return;
|
|
24
|
+
const start = await resolveManagedCodexAppServerStartOptions(options.start, { pluginRoot: params.pluginRoot });
|
|
25
|
+
if (start.transport !== "stdio") return;
|
|
26
|
+
const env = resolveCodexAppServerSpawnEnv(start, params.env ?? process.env);
|
|
27
|
+
const invocation = materializeWindowsSpawnProgram(resolveWindowsSpawnProgram({
|
|
28
|
+
command: start.command,
|
|
29
|
+
env,
|
|
30
|
+
packageName: "@openai/codex"
|
|
31
|
+
}), buildCodexLoginStatusArgs(start.args));
|
|
32
|
+
const result = await runUtf8CommandWithTimeout([invocation.command, ...invocation.argv], {
|
|
33
|
+
baseEnv: env,
|
|
34
|
+
timeoutMs: 3e3,
|
|
35
|
+
signal: params.signal,
|
|
36
|
+
killProcessTree: true
|
|
37
|
+
});
|
|
38
|
+
params.signal?.throwIfAborted();
|
|
39
|
+
if (result.termination !== "exit" || result.code !== 0) return;
|
|
40
|
+
const line = `${result.stdout}\n${result.stderr}`.split("\n").map((value) => value.trim()).find((value) => value.startsWith("Logged in using "));
|
|
41
|
+
const mode = line?.startsWith("Logged in using an API key - ") ? "api-key" : line ? OPENAI_LOGIN_MODES[line] : void 0;
|
|
42
|
+
return mode ? {
|
|
43
|
+
apiKey: "codex-app-server",
|
|
44
|
+
source: "Codex native login",
|
|
45
|
+
mode,
|
|
46
|
+
nativeAuth: {
|
|
47
|
+
runtime: "codex",
|
|
48
|
+
mode
|
|
49
|
+
}
|
|
50
|
+
} : void 0;
|
|
51
|
+
} catch {
|
|
52
|
+
params.signal?.throwIfAborted();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { probeCodexNativeAuth };
|