@openclaw/codex 2026.9.3 → 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-B6el6hdO.js → .setup/apply-CJ0ZfmBG.mjs} +12 -13
- package/dist/.setup/async-questions-DdhOCwGi.mjs +27 -0
- package/dist/{attempt-client-cleanup-D6cR54TV.js → .setup/attempt-client-cleanup-BpYKdTA0.mjs} +30 -211
- package/dist/{attempt-context-AO4DSjE0.js → .setup/attempt-context-VXVwTCfS.mjs} +6 -6
- package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +5 -0
- package/dist/{auth-binding-Co2Vfcf_.js → .setup/auth-binding-DhLWa_7K.mjs} +2 -2
- package/dist/{auth-cache-key-Kq6oerr6.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-lRpmZHFv.js → .setup/bounded-turn-BtlZcivC.mjs} +19 -14
- package/dist/{build-state-6RL6qohz.js → .setup/build-state-Xx9ybZqa.mjs} +1 -1
- package/dist/{capabilities-BeqLPbtM.js → .setup/capabilities-_vXcZGSx.mjs} +1 -1
- package/dist/{client-BEKu4yDx.js → .setup/client-vXs2929Q.mjs} +355 -164
- package/dist/{command-dispatch-CisT9Jqq.js → .setup/command-dispatch-naHIZwwF.mjs} +3 -3
- package/dist/{command-formatters-DeTfrapr.js → .setup/command-formatters-CGEkdawF.mjs} +4 -3
- package/dist/{command-handlers-BfIsJEuA.js → .setup/command-handlers-BtAJEW1X.mjs} +812 -152
- package/dist/{command-rpc-BMqRQOFX.js → .setup/command-rpc-DHFpn4le.mjs} +37 -21
- package/dist/{compact-CGJZ2rlb.js → .setup/compact-C3i3qlzj.mjs} +28 -43
- package/dist/{config-JDfTI4VI.js → .setup/config-CedDWjM-.mjs} +5 -4
- package/dist/{config-options-jnIFvwxD.js → .setup/config-options-BsanJ8QG.mjs} +9 -421
- package/dist/{protocol-CAAcVIKF.js → .setup/config-parsing-CcB9iPoq.mjs} +9 -51
- package/dist/{config-runtime-BWf6JLWG.js → .setup/config-runtime-CeAhl_h4.mjs} +2 -2
- package/dist/.setup/config-security-BRQ2mgW9.mjs +465 -0
- package/dist/{config-utils-C57JiJrU.js → .setup/config-utils-DujwEnhg.mjs} +2 -4
- package/dist/{conversation-binding-CxOlHiix.js → .setup/conversation-binding-DhzrpTM6.mjs} +60 -47
- package/dist/{conversation-binding-data-BiodpIzq.js → .setup/conversation-binding-data-CrcyZk6O.mjs} +1 -1
- package/dist/{conversation-control-CUCrSIQI.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-D-JBoaLt.js → .setup/dynamic-tools-D16lOp67.mjs} +168 -61
- package/dist/{effective-mcp-catalog-J_5Ep5Um.js → .setup/effective-mcp-catalog-K6kLCN8X.mjs} +3 -3
- package/dist/{ephemeral-turn-DSwzP8YY.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/.setup/event-projector-items-DyTQ_XqL.mjs +200 -0
- package/dist/{attempt-notifications--H8zXR5-.js → .setup/event-projector-usage-C7Ntzs-f.mjs} +102 -9
- package/dist/{harness-FR6eQgyO.js → .setup/harness-rxaaoN-o.mjs} +90 -19
- package/dist/.setup/inference-context-fulhZuz8.mjs +94 -0
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +311 -0
- package/dist/{isolated-completion-DHBefrzg.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-DrjjRRUD.js → .setup/managed-binary-DP6Rib3P.mjs} +11 -2
- package/dist/{managed-thread-store-D1t5jh3G.js → .setup/managed-thread-store-BMqgThVL.mjs} +48 -14
- package/dist/{model-catalog-B_6M04Wo.js → .setup/model-catalog-DkvUuBey.mjs} +35 -10
- package/dist/{models-P9k2qAof.js → .setup/models-BDFgm_G-.mjs} +3 -3
- package/dist/.setup/native-auth-BLZGqFjw.mjs +57 -0
- package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +135 -0
- package/dist/.setup/native-subagent-monitor-B1hxzIOy.mjs +5031 -0
- package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +411 -0
- package/dist/{node-cli-sessions-rj0ysJwM.js → .setup/node-cli-sessions-Cl8b2ZF3.mjs} +1 -1
- package/dist/{node-exec-server.runtime-BY_ctYnT.js → .setup/node-exec-server.runtime-BaViBKNz.mjs} +5 -5
- package/dist/{plan-BMJdMOEF.js → .setup/plan-xD7WKYTM.mjs} +331 -79
- package/dist/{plugin-activation-BQK-f5sV.js → .setup/plugin-activation-r8nq5Jzp.mjs} +24 -19
- package/dist/{plugin-app-cache-key-CdSQzWyX.js → .setup/plugin-app-cache-key-BOxKP7db.mjs} +29 -25
- package/dist/{plugin-approval-roundtrip-DeW95wB5.js → .setup/plugin-approval-roundtrip-CjfzafAZ.mjs} +1 -1
- package/dist/{plugin-inventory-CoRCzWW4.js → .setup/plugin-inventory-DUle8DLz.mjs} +12 -8
- package/dist/{plugin-marketplace-discovery-3akBizzF.js → .setup/plugin-marketplace-discovery-P-Vndfqq.mjs} +18 -15
- package/dist/{plugin-metadata-cache-DgNfRAGA.js → .setup/plugin-metadata-cache-DsS5buNa.mjs} +33 -14
- package/dist/{provider-capabilities-W4tfK5Y5.js → .setup/provider-capabilities-B8J4Dy-O.mjs} +2 -2
- package/dist/.setup/provider-fFh_-VR3.mjs +50 -0
- package/dist/{rate-limits-Bqnx1N4z.js → .setup/rate-limits-DOEGYRNs.mjs} +90 -46
- package/dist/.setup/request-BioXJLYa.mjs +292 -0
- package/dist/.setup/run-attempt-lifecycle-B7JbY4-F.mjs +71 -0
- package/dist/{run-attempt-DwKds3DN.js → .setup/run-attempt-rlA07pUv.mjs} +644 -491
- package/dist/{runtime-artifact-T-NwqeSH.js → .setup/runtime-artifact-Dy38Z5iU.mjs} +2 -2
- package/dist/{sandbox-guard-BcT66fWy.js → .setup/sandbox-guard-BBP-RbTf.mjs} +4 -3
- package/dist/{session-binding-CKSepwIC.js → .setup/session-binding-_0W_fHRr.mjs} +45 -63
- package/dist/{session-binding-record-CaZjYwNS.js → .setup/session-binding-record-TH3xA0zj.mjs} +181 -3
- package/dist/.setup/session-binding-sidecars-CKYEcfNn.mjs +543 -0
- package/dist/{session-catalog-adoption-BKLtSrwi.js → .setup/session-catalog-adoption-CR_whkEW.mjs} +6 -6
- package/dist/{session-catalog-archive-D0i2pGj2.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/{session-catalog-parsing-CdD3JhdM.js → .setup/session-catalog-native-projection-ChV3cCtm.mjs} +213 -21
- package/dist/{session-catalog-node-adoption-BUuDYY8R.js → .setup/session-catalog-node-adoption-BVRsYOSh.mjs} +3 -3
- package/dist/{session-catalog-node-continue-CBtc4wkI.js → .setup/session-catalog-node-continue-Dowv8osw.mjs} +7 -7
- package/dist/.setup/session-catalog-projection-C1Bj9Jl-.mjs +414 -0
- package/dist/{session-cli-CbgaHh0f.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-DFN7sWRU.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-CNEvGaU5.js → .setup/session-history.worker-CpNj7H_P.mjs} +192 -89
- package/dist/{session-initialization-Jo86C60I.js → .setup/session-initialization-DH1z6fXn.mjs} +2 -2
- package/dist/{session-permission-policy-B22InTp_.js → .setup/session-permission-policy-DhurXY0l.mjs} +2 -2
- package/dist/{session-retirement-BSNG_mhf.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-BuLUrZl2.js → .setup/settled-turn-finalizer-CiY2bLFK.mjs} +10 -10
- package/dist/{shared-client-CVhez2Uo.js → .setup/shared-client-BpTtuLQ5.mjs} +495 -156
- package/dist/{side-question-DLbr2vUU.js → .setup/side-question-DSCZyoBD.mjs} +64 -47
- package/dist/{source-Da-h6f7e.js → .setup/source-Bjp4UQij.mjs} +15 -14
- package/dist/{thread-archive-guard-D1bP04Tf.js → .setup/thread-archive-guard-jmecf6OJ.mjs} +1 -1
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +83 -0
- package/dist/{thread-lifecycle-D1pzRwHB.js → .setup/thread-lifecycle-Cik28qWn.mjs} +330 -150
- package/dist/{thread-ownership-D6oASVRu.js → .setup/thread-ownership-skomxnIt.mjs} +4 -4
- package/dist/{thread-policy-D8kI7yAO.js → .setup/thread-policy-Cjs4B8xf.mjs} +3 -3
- package/dist/{thread-resume-T5cveyxA.js → .setup/thread-resume-BkNpj9Pz.mjs} +8 -5
- package/dist/.setup/timeout-DZF05XrR.mjs +63 -0
- package/dist/{session-catalog-home-id-D7-aLiNt.js → .setup/transcript-history-projection-DHNBDhCU.mjs} +73 -20
- package/dist/{transcript-mirror-t5TOccct.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-De-sLJ2r.js → .setup/upstream-session-fork-D3UKxgVD.mjs} +27 -26
- package/dist/{usage-CPPTmBvZ.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-CSVgQL0w.js → .setup/web-search-provider.runtime-CTGuJt6i.mjs} +3 -3
- package/dist/api.js +28 -20
- 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 +130 -135
- package/dist/media-understanding-provider.js +3 -3
- package/dist/migration-provider-api.js +2 -0
- 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 -68
- package/package.json +11 -8
- package/dist/binding-connection-QqgcPCgk.js +0 -60
- package/dist/event-projector-usage-CIyrYYid.js +0 -102
- package/dist/native-subagent-monitor-BbCUKRwC.js +0 -3350
- package/dist/request-CGvGOpeR.js +0 -198
- package/dist/session-catalog-HaDcp7Sv.js +0 -1533
- package/dist/session-catalog-provenance-DkJHo735.js +0 -124
- package/dist/timeout-BVw8aaM1.js +0 -33
- package/dist/{auth-profile-selection-DFu9e167.js → .setup/auth-profile-selection-DFu9e167.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/{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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.
|
|
2
|
-
import { n as withCodexAppServerThreadMutation } from "./incognito-session-uhrBF6wJ.
|
|
3
|
-
import { U as releaseCodexAppServerLiveThread, W as retainCodexAppServerLiveThread, _ as retainSharedCodexAppServerClientByInstanceId, z as isCodexAppServerLiveThreadClaimed } from "./shared-client-
|
|
4
|
-
import { a as closeCodexStartupClientBestEffort,
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { n as withCodexAppServerThreadMutation } from "./incognito-session-uhrBF6wJ.mjs";
|
|
3
|
+
import { U as releaseCodexAppServerLiveThread, W as retainCodexAppServerLiveThread, _ as retainSharedCodexAppServerClientByInstanceId, z as isCodexAppServerLiveThreadClaimed } from "./shared-client-BpTtuLQ5.mjs";
|
|
4
|
+
import { a as closeCodexStartupClientBestEffort, f as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-BpYKdTA0.mjs";
|
|
5
5
|
//#region extensions/codex/src/app-server/thread-ownership.ts
|
|
6
6
|
var thread_ownership_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
isSameCodexAppServerThreadOwner: () => isSameCodexAppServerThreadOwner,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError } from "./client-
|
|
2
|
-
import { r as requestCodexAppServerClientJson, t as CodexAppServerScopedRequestRejectedError } from "./request-
|
|
1
|
+
import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError } from "./client-vXs2929Q.mjs";
|
|
2
|
+
import { r as requestCodexAppServerClientJson, t as CodexAppServerScopedRequestRejectedError } from "./request-BioXJLYa.mjs";
|
|
3
3
|
import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
4
4
|
//#region extensions/codex/src/app-server/thread-policy.ts
|
|
5
5
|
/** A refusal, not a failed native write: the ephemeral conversation must stay alive. */
|
|
@@ -19,7 +19,7 @@ var CodexThreadPolicyHandoffError = class extends AgentHarnessPreflightError {
|
|
|
19
19
|
};
|
|
20
20
|
/** The complete body remains generic configuration for compaction and native child inheritance. */
|
|
21
21
|
async function refreshCodexThreadPolicy(params) {
|
|
22
|
-
const text = "The following is the complete current OpenClaw-supplied generic instruction policy. It replaces earlier OpenClaw-supplied generic policy, including
|
|
22
|
+
const text = "The following is the complete current OpenClaw-supplied generic instruction policy. It replaces earlier OpenClaw-supplied generic policy, including sections removed from that generic policy. Parent-local instructions supplied for the current inference request are outside this policy replacement. Independently supplied native managed, guardian, security, collaboration, and project instructions retain their authority. User requests retain their own authority.\n\n" + (params.developerInstructions === "" ? "The current OpenClaw generic policy is empty; earlier OpenClaw generic policy is withdrawn." : params.developerInstructions);
|
|
23
23
|
let outcome = "unknown";
|
|
24
24
|
try {
|
|
25
25
|
await requestCodexAppServerClientJson({
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError, y as assertCodexThreadResumeResponse } from "./client-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError, y as assertCodexThreadResumeResponse } from "./client-vXs2929Q.mjs";
|
|
2
|
+
import { i as CodexAppServerRpcError } from "./timeout-DZF05XrR.mjs";
|
|
3
|
+
import { r as publishCodexCatalogResume } from "./session-catalog-events-jMcYfQyd.mjs";
|
|
4
|
+
import { t as CodexAppServerScopedRequestRejectedError } from "./request-BioXJLYa.mjs";
|
|
5
|
+
import { F as forgetCodexWorkspaceReferences, rt as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-BpTtuLQ5.mjs";
|
|
6
|
+
import { f as unsubscribeCodexThreadBestEffort, i as assertCodexThreadResumeSubscription, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-BpYKdTA0.mjs";
|
|
7
|
+
import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
|
|
6
8
|
//#region extensions/codex/src/app-server/thread-resume.ts
|
|
7
9
|
/** Owns Codex thread/resume subscription safety. */
|
|
8
10
|
/** Resumes one thread, releasing or isolating every possible native subscription. */
|
|
@@ -46,6 +48,7 @@ async function resumeCodexAppServerThread(params) {
|
|
|
46
48
|
if (error instanceof CodexAppServerUnsafeSubscriptionError) throw error;
|
|
47
49
|
throw new CodexAppServerUnsafeSubscriptionError(error instanceof Error ? error.message : `Codex thread/resume outcome is indeterminate for ${threadId}`, { cause: error });
|
|
48
50
|
}
|
|
51
|
+
await publishCodexCatalogResume(params.client, response, sanitizeTerminalText);
|
|
49
52
|
return response;
|
|
50
53
|
}
|
|
51
54
|
//#endregion
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { m as isJsonObject } from "./config-security-BRQ2mgW9.mjs";
|
|
2
|
+
import { withTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
3
|
+
//#region extensions/codex/src/app-server/rpc-error.ts
|
|
4
|
+
const CODEX_APP_SERVER_OVERLOADED_ERROR_CODE = -32001;
|
|
5
|
+
/** RPC error wrapper that preserves app-server error code and data. */
|
|
6
|
+
var CodexAppServerRpcError = class extends Error {
|
|
7
|
+
constructor(error, method) {
|
|
8
|
+
super(formatCodexAppServerRpcErrorMessage(error, method));
|
|
9
|
+
this.name = "CodexAppServerRpcError";
|
|
10
|
+
this.code = error.code;
|
|
11
|
+
this.data = error.data;
|
|
12
|
+
this.method = method;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function isCodexThreadReadMissingError(error, threadId) {
|
|
16
|
+
return error instanceof CodexAppServerRpcError && error.method === "thread/read" && error.code === -32600 && error.message === `thread not loaded: ${threadId}`;
|
|
17
|
+
}
|
|
18
|
+
function formatCodexAppServerRpcErrorMessage(error, method) {
|
|
19
|
+
const message = error.message || `${method} failed`;
|
|
20
|
+
const detail = readCodexAppServerRpcReloginDetail(error.data);
|
|
21
|
+
return detail && !message.includes(detail) ? `${message}: ${detail}` : message;
|
|
22
|
+
}
|
|
23
|
+
function readCodexAppServerRpcReloginDetail(data) {
|
|
24
|
+
const record = isJsonObject(data) ? data : void 0;
|
|
25
|
+
const nested = isJsonObject(record?.error) ? record.error : record;
|
|
26
|
+
if (!nested) return;
|
|
27
|
+
const isRelogin = nested.action === "relogin" || nested.reason === "cloudRequirements" && nested.errorCode === "Auth";
|
|
28
|
+
const detail = typeof nested.detail === "string" ? nested.detail.trim() : "";
|
|
29
|
+
return isRelogin && detail ? detail : void 0;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region extensions/codex/src/app-server/timeout.ts
|
|
33
|
+
/**
|
|
34
|
+
* Thin Codex app-server timeout adapter around OpenClaw's shared timeout helper.
|
|
35
|
+
*/
|
|
36
|
+
function resolveAbortError(signal) {
|
|
37
|
+
return signal.reason instanceof Error ? signal.reason : new Error("Codex app-server operation aborted", { cause: signal.reason });
|
|
38
|
+
}
|
|
39
|
+
/** Awaits a promise with a Codex-specific timeout error message. */
|
|
40
|
+
async function withTimeout$1(promise, timeoutMs, timeoutMessage, createError) {
|
|
41
|
+
return await withTimeout(promise, timeoutMs, {
|
|
42
|
+
message: timeoutMessage,
|
|
43
|
+
...createError ? { createError } : {}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** Bounds an operation by both its owner lifecycle and one total wall-clock budget. */
|
|
47
|
+
async function withAbortableTimeout(params) {
|
|
48
|
+
const signal = params.signal;
|
|
49
|
+
if (signal?.aborted) throw resolveAbortError(signal);
|
|
50
|
+
let removeAbortListener;
|
|
51
|
+
const operation = signal ? Promise.race([params.promise, new Promise((_, reject) => {
|
|
52
|
+
const onAbort = () => reject(resolveAbortError(signal));
|
|
53
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
54
|
+
removeAbortListener = () => signal.removeEventListener("abort", onAbort);
|
|
55
|
+
})]) : params.promise;
|
|
56
|
+
try {
|
|
57
|
+
return await withTimeout$1(operation, params.timeoutMs, params.timeoutMessage, params.createTimeoutError);
|
|
58
|
+
} finally {
|
|
59
|
+
removeAbortListener?.();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { isCodexThreadReadMissingError as a, CodexAppServerRpcError as i, withTimeout$1 as n, CODEX_APP_SERVER_OVERLOADED_ERROR_CODE as r, withAbortableTimeout as t };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
2
|
+
import { c as itemName, l as itemStatus, t as auditNativeToolName } from "./event-projector-items-DyTQ_XqL.mjs";
|
|
3
|
+
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.mjs";
|
|
2
4
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
import fs from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
5
|
import { truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
7
6
|
import { Buffer } from "node:buffer";
|
|
8
7
|
//#region extensions/codex/src/app-server/transcript-history-projection.ts
|
|
@@ -72,7 +71,7 @@ function projectCodexThreadHistory(params) {
|
|
|
72
71
|
const projected = [];
|
|
73
72
|
const threadTimestamp = typeof params.thread.createdAt === "number" && Number.isFinite(params.thread.createdAt) ? params.thread.createdAt * 1e3 : params.importedAt;
|
|
74
73
|
let itemOffset = 0;
|
|
75
|
-
for (const turn of
|
|
74
|
+
for (const turn of params.turns) for (const value of turn.items) {
|
|
76
75
|
const item = value;
|
|
77
76
|
const itemId = normalizeOptionalString(item.id);
|
|
78
77
|
const identity = `${turn.id}:${itemId ?? itemOffset}`;
|
|
@@ -84,6 +83,7 @@ function projectCodexThreadHistory(params) {
|
|
|
84
83
|
if (!text || !role) continue;
|
|
85
84
|
const phase = item.phase === "commentary" || item.phase === "final_answer" ? item.phase : void 0;
|
|
86
85
|
const asyncDelivery = item.delivery === "async";
|
|
86
|
+
const questions = asyncDelivery ? readCodexAsyncQuestions(item.questions) : void 0;
|
|
87
87
|
const message = role === "assistant" ? attachCodexMirrorIdentity({
|
|
88
88
|
role,
|
|
89
89
|
content: [{
|
|
@@ -97,7 +97,10 @@ function projectCodexThreadHistory(params) {
|
|
|
97
97
|
stopReason: turn.status === "interrupted" ? "aborted" : turn.status === "failed" ? "error" : "stop",
|
|
98
98
|
...turn.status === "failed" && turn.error?.message ? { errorMessage: turn.error.message } : {},
|
|
99
99
|
...phase ? { phase } : {},
|
|
100
|
-
...asyncDelivery && itemId ? { openclawAsyncDelivery: {
|
|
100
|
+
...asyncDelivery && itemId ? { openclawAsyncDelivery: {
|
|
101
|
+
itemId,
|
|
102
|
+
...questions ? { questions } : {}
|
|
103
|
+
} } : {},
|
|
101
104
|
timestamp
|
|
102
105
|
}, identity) : attachCodexMirrorIdentity({
|
|
103
106
|
role,
|
|
@@ -136,7 +139,7 @@ function selectBoundedCodexHistoryTail(projected) {
|
|
|
136
139
|
function projectBoundedCodexThreadHistory(params) {
|
|
137
140
|
const projected = projectCodexThreadHistory({
|
|
138
141
|
thread: params.thread,
|
|
139
|
-
|
|
142
|
+
turns: selectTurnsThroughBoundary(params.thread, params.throughTurnId),
|
|
140
143
|
importedAt: params.importedAt,
|
|
141
144
|
...params.modelProvider ? { modelProvider: params.modelProvider } : {}
|
|
142
145
|
});
|
|
@@ -172,19 +175,69 @@ function projectBoundedCodexVisibleSessionHistory(entries) {
|
|
|
172
175
|
}
|
|
173
176
|
return selectBoundedCodexHistoryTail(projected).map(({ responseItem }) => responseItem);
|
|
174
177
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
178
|
+
/** Displays native items through the shared transcript roles, including an unfinished turn. */
|
|
179
|
+
function projectCodexThreadHistoryItem(thread, entry, toolItems) {
|
|
180
|
+
const { item } = entry;
|
|
181
|
+
const timestamp = (entry.turn?.startedAt ?? thread.createdAt ?? 0) * 1e3;
|
|
182
|
+
if (item.type === "userMessage" || item.type === "agentMessage") return projectCodexThreadHistory({
|
|
183
|
+
thread,
|
|
184
|
+
turns: [{
|
|
185
|
+
...entry.turn,
|
|
186
|
+
id: entry.turnId,
|
|
187
|
+
items: [item]
|
|
188
|
+
}],
|
|
189
|
+
importedAt: timestamp
|
|
190
|
+
}).map(({ message }) => message);
|
|
191
|
+
const identity = `${entry.turnId}:${item.id}`;
|
|
192
|
+
const assistant = (content, toolUse = false) => attachCodexMirrorIdentity({
|
|
193
|
+
role: "assistant",
|
|
194
|
+
content,
|
|
195
|
+
api: CODEX_HISTORY_ASSISTANT_API,
|
|
196
|
+
provider: normalizeOptionalString(thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER,
|
|
197
|
+
model: CODEX_HISTORY_ASSISTANT_MODEL,
|
|
198
|
+
usage: CODEX_HISTORY_ZERO_USAGE,
|
|
199
|
+
stopReason: toolUse ? "toolUse" : "stop",
|
|
200
|
+
timestamp
|
|
201
|
+
}, identity);
|
|
202
|
+
if (item.type === "reasoning") {
|
|
203
|
+
const parts = Array.isArray(item.summary) && item.summary.length > 0 ? item.summary : item.content;
|
|
204
|
+
const thinking = normalizeImportedHistoryText(Array.isArray(parts) ? parts.filter((part) => typeof part === "string").join("\n") : item.text);
|
|
205
|
+
return thinking ? [assistant([{
|
|
206
|
+
type: "thinking",
|
|
207
|
+
thinking
|
|
208
|
+
}])] : [];
|
|
183
209
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
210
|
+
if (item.type === "contextCompaction") return [assistant([{
|
|
211
|
+
type: "text",
|
|
212
|
+
text: "Context compacted."
|
|
213
|
+
}])];
|
|
214
|
+
const toolName = itemName(item) ?? auditNativeToolName(item);
|
|
215
|
+
if (!toolName) {
|
|
216
|
+
const text = normalizeImportedHistoryText(item.text ?? item.title);
|
|
217
|
+
return text ? [assistant([{
|
|
218
|
+
type: "text",
|
|
219
|
+
text
|
|
220
|
+
}])] : [];
|
|
221
|
+
}
|
|
222
|
+
const messages = [assistant([{
|
|
223
|
+
type: "toolCall",
|
|
224
|
+
id: item.id,
|
|
225
|
+
name: toolName,
|
|
226
|
+
arguments: toolItems.itemToolArgs(item) ?? {}
|
|
227
|
+
}], true)];
|
|
228
|
+
const status = itemStatus(item);
|
|
229
|
+
if (status !== "running") messages.push(attachCodexMirrorIdentity({
|
|
230
|
+
role: "toolResult",
|
|
231
|
+
toolCallId: item.id,
|
|
232
|
+
toolName,
|
|
233
|
+
content: [{
|
|
234
|
+
type: "text",
|
|
235
|
+
text: toolItems.itemTranscriptResultText(item) ?? status
|
|
236
|
+
}],
|
|
237
|
+
isError: status === "failed" || status === "blocked",
|
|
238
|
+
timestamp
|
|
239
|
+
}, `${identity}:result`));
|
|
240
|
+
return messages;
|
|
188
241
|
}
|
|
189
242
|
//#endregion
|
|
190
|
-
export { projectCodexUserItemText as
|
|
243
|
+
export { projectCodexUserItemText as i, projectBoundedCodexVisibleSessionHistory as n, projectCodexThreadHistoryItem as r, projectBoundedCodexThreadHistory as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.
|
|
2
|
-
import {
|
|
3
|
-
import { r as
|
|
4
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
3
|
+
import { i as readUpstreamUserText, n as attachUpstreamUserText, r as readMirrorIdentity, t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.mjs";
|
|
4
|
+
import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-DHNBDhCU.mjs";
|
|
5
|
+
import { a as fingerprintCodexMirrorSourceMessage, c as readCodexMirrorSourceFingerprint, i as buildCodexMirrorDedupeIdentity, n as attachCodexMirrorAttestation, r as attachCodexMirrorRunId, s as isMirroredAgentMessage, t as applyCodexTranscriptTaint } from "./transcript-mirror-attestation-CzM-94NC.mjs";
|
|
5
6
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
7
|
import { deliverAgentHarnessUserInputPrompt, embeddedAgentLog, formatErrorMessage, projectAgentHarnessTranscriptMessageForDisplay, restorePreparedUserTurnOperationalMetaForRuntime, runAgentHarnessBeforeMessageWriteHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
7
8
|
import { withCodexSessionTranscriptMirrorWriteLock } from "openclaw/plugin-sdk/codex-session-transcript-runtime";
|
|
@@ -187,6 +188,7 @@ async function mirrorPromptAtTurnStartBestEffort(params) {
|
|
|
187
188
|
const mirrorPromise = (async () => {
|
|
188
189
|
const userPromptMessage = projectAgentHarnessTranscriptMessageForDisplay({
|
|
189
190
|
hidden: params.params.trigger === "memory",
|
|
191
|
+
inputProvenance: params.params.inputProvenance,
|
|
190
192
|
message: attachUpstreamUserText(attachCodexMirrorIdentity(await buildResolvedCodexUserPromptMessage(params.params), `${params.turnId}:prompt`), params.upstreamUserText)
|
|
191
193
|
});
|
|
192
194
|
const recorder = params.params.userTurnTranscriptRecorder;
|
|
@@ -298,6 +300,7 @@ async function mirror(params) {
|
|
|
298
300
|
preparedUserMessage.content = structuredClone(preparedUserMessage.content);
|
|
299
301
|
preparedUserMessage["__openclaw"].humanMentions = structuredClone(preparedUserMessage["__openclaw"].humanMentions);
|
|
300
302
|
}
|
|
303
|
+
const asyncSourceText = message.role === "assistant" && message.openclawAsyncDelivery ? readMirroredAssistantText(message) : void 0;
|
|
301
304
|
const nextMessage = runAgentHarnessBeforeMessageWriteHook({
|
|
302
305
|
message: transcriptMessage,
|
|
303
306
|
agentId: params.agentId,
|
|
@@ -319,7 +322,13 @@ async function mirror(params) {
|
|
|
319
322
|
} : attachCodexMirrorAttestation(restoredMessage, sourceFingerprint);
|
|
320
323
|
if (mirrorIdentity) messageToAppend = attachCodexMirrorIdentity(messageToAppend, mirrorIdentity);
|
|
321
324
|
if (ownsRun && params.runId) messageToAppend = attachCodexMirrorRunId(messageToAppend, params.runId, ownsTerminal, terminalOwner?.settlementWarning);
|
|
322
|
-
if (message.role === "assistant" && message.openclawAsyncDelivery)
|
|
325
|
+
if (message.role === "assistant" && message.openclawAsyncDelivery) {
|
|
326
|
+
const questions = isMirroredAgentMessage(messageToAppend) && readMirroredAssistantText(messageToAppend) === asyncSourceText ? readCodexAsyncQuestions(messageToAppend.openclawAsyncDelivery?.questions) : void 0;
|
|
327
|
+
messageToAppend = Object.assign(messageToAppend, { openclawAsyncDelivery: {
|
|
328
|
+
itemId: message.openclawAsyncDelivery.itemId,
|
|
329
|
+
...questions ? { questions } : {}
|
|
330
|
+
} });
|
|
331
|
+
}
|
|
323
332
|
messageToAppend = applyCodexTranscriptTaint(messageToAppend, taint);
|
|
324
333
|
messageToAppend = projectAgentHarnessTranscriptMessageForDisplay({
|
|
325
334
|
hidden: message.display === false,
|
|
@@ -460,4 +469,4 @@ function resolveCodexMirrorTranscriptTarget(params) {
|
|
|
460
469
|
};
|
|
461
470
|
}
|
|
462
471
|
//#endregion
|
|
463
|
-
export { transcript_mirror_exports as a, mirrorPromptAtTurnStartBestEffort as i, createCodexAppServerUserMessagePersistenceNotifier as n, buildCodexUserPromptMessage as o, importCodexThreadHistoryToTranscript as r,
|
|
472
|
+
export { transcript_mirror_exports as a, promptSnapshot as c, mirrorPromptAtTurnStartBestEffort as i, createCodexAppServerUserMessagePersistenceNotifier as n, buildCodexUserPromptMessage as o, importCodexThreadHistoryToTranscript as r, buildResolvedCodexUserPromptMessage as s, codexTranscriptMirrorRuntime as t };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
2
|
+
import { i as readUpstreamUserText, r as readMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.mjs";
|
|
2
3
|
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
4
|
import { createHash } from "node:crypto";
|
|
4
5
|
//#region extensions/codex/src/app-server/transcript-mirror-attestation.ts
|
|
@@ -71,9 +72,11 @@ function readCodexMirrorSourceFingerprint(message) {
|
|
|
71
72
|
}
|
|
72
73
|
function serializeCodexMirrorSourceEvidence(message) {
|
|
73
74
|
const content = "content" in message ? message.content : void 0;
|
|
75
|
+
const questions = isMirroredAgentMessage(message) ? readCodexAsyncQuestions(message.openclawAsyncDelivery?.questions) : void 0;
|
|
74
76
|
return JSON.stringify({
|
|
75
77
|
role: message.role,
|
|
76
78
|
content,
|
|
79
|
+
...questions ? { questions } : {},
|
|
77
80
|
...message.role === "user" ? { upstreamUserText: readUpstreamUserText(message) } : {},
|
|
78
81
|
...message.role === "toolResult" ? {
|
|
79
82
|
toolCallId: message.toolCallId,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as normalizeCodexAppServerArgs } from "./launch-args-DnMak49W.mjs";
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { materializeWindowsSpawnProgram, resolveWindowsSpawnProgram } from "openclaw/plugin-sdk/windows-spawn";
|
|
5
|
+
import { closeSync, constants, openSync, readSync } from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
5
7
|
import { readFile, readdir } from "node:fs/promises";
|
|
6
8
|
import { once } from "node:events";
|
|
7
9
|
import { execFile, spawn } from "node:child_process";
|
|
@@ -15,6 +17,32 @@ function isDeadProcessState(state) {
|
|
|
15
17
|
const PROCESS_COLUMNS = "pid=,ppid=,pgid=,stat=,lstart=";
|
|
16
18
|
const MAX_PROCESS_CONTAINMENT_MS$1 = 2e3;
|
|
17
19
|
const PROCESS_INSPECTION_MAX_BYTES = 8388608;
|
|
20
|
+
const PROCFS_COMMAND_PERMISSION_EXIT = 77;
|
|
21
|
+
const PROCFS_COMMAND_READER = `
|
|
22
|
+
const fs = require("node:fs");
|
|
23
|
+
const [pid, maxBytes] = process.argv.slice(-2).map(Number);
|
|
24
|
+
try {
|
|
25
|
+
const fd = fs.openSync("/proc/" + pid + "/cmdline", "r");
|
|
26
|
+
const buffer = Buffer.alloc(4096);
|
|
27
|
+
const chunks = [];
|
|
28
|
+
let bytes = 0;
|
|
29
|
+
try {
|
|
30
|
+
for (;;) {
|
|
31
|
+
const count = fs.readSync(fd, buffer, 0, Math.min(buffer.length, maxBytes - bytes + 1), null);
|
|
32
|
+
if (count === 0) break;
|
|
33
|
+
bytes += count;
|
|
34
|
+
if (bytes > maxBytes) throw new Error("Command byte limit exceeded");
|
|
35
|
+
chunks.push(Buffer.from(buffer.subarray(0, count)));
|
|
36
|
+
}
|
|
37
|
+
} finally {
|
|
38
|
+
fs.closeSync(fd);
|
|
39
|
+
}
|
|
40
|
+
process.stdout.end(Buffer.concat(chunks, bytes));
|
|
41
|
+
} catch (error) {
|
|
42
|
+
process.exitCode = ["EACCES", "EPERM", "ERR_ACCESS_DENIED"].includes(error?.code)
|
|
43
|
+
? ${PROCFS_COMMAND_PERMISSION_EXIT} : 1;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
18
46
|
var ProcessInspectionError = class extends Error {
|
|
19
47
|
constructor(reason) {
|
|
20
48
|
const detail = {
|
|
@@ -56,17 +84,11 @@ async function readCodexAppServerProcessCommand(observed, deadline) {
|
|
|
56
84
|
if (process.platform === "linux") {
|
|
57
85
|
let pending = false;
|
|
58
86
|
do {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
encoding: "utf8",
|
|
65
|
-
signal: AbortSignal.timeout(remainingMs)
|
|
66
|
-
});
|
|
67
|
-
} catch (error) {
|
|
68
|
-
throw inspectionFailure(error);
|
|
69
|
-
}
|
|
87
|
+
if (deadline - Date.now() <= 0) throw new ProcessInspectionError("deadline");
|
|
88
|
+
const command = await readProcessOutput({
|
|
89
|
+
kind: "procfs-command",
|
|
90
|
+
pid: observed.pid
|
|
91
|
+
}, deadline);
|
|
70
92
|
if (!command || pending) {
|
|
71
93
|
const current = await readCodexAppServerProcess(observed.pid, deadline);
|
|
72
94
|
if (!current || current.startedAt !== observed.startedAt || current.ppid !== observed.ppid || current.pgid !== observed.pgid || current.state.startsWith("Z")) throw new ProcessInspectionError("unavailable");
|
|
@@ -75,20 +97,26 @@ async function readCodexAppServerProcessCommand(observed, deadline) {
|
|
|
75
97
|
pending = command.length === 0;
|
|
76
98
|
if (pending) await setImmediate();
|
|
77
99
|
} while (pending);
|
|
78
|
-
} else output = (await readProcessOutput(
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
} else output = (await readProcessOutput({
|
|
101
|
+
kind: "ps",
|
|
102
|
+
args: [
|
|
103
|
+
"-o",
|
|
104
|
+
"command=",
|
|
105
|
+
"-p",
|
|
106
|
+
String(observed.pid)
|
|
107
|
+
]
|
|
108
|
+
}, deadline)).split("\n")[0]?.trim() ?? "";
|
|
84
109
|
if (Date.now() >= deadline) throw new ProcessInspectionError("deadline");
|
|
85
110
|
if (!output) throw new ProcessInspectionError("unavailable");
|
|
86
111
|
return output;
|
|
87
112
|
}
|
|
88
113
|
async function readProcesses(args, deadline, selected = false) {
|
|
89
|
-
return parseProcesses(await readProcessOutput(
|
|
114
|
+
return parseProcesses(await readProcessOutput({
|
|
115
|
+
kind: "ps",
|
|
116
|
+
args
|
|
117
|
+
}, deadline), selected);
|
|
90
118
|
}
|
|
91
|
-
async function readProcessOutput(
|
|
119
|
+
async function readProcessOutput(command, deadline) {
|
|
92
120
|
const remainingMs = deadline - Date.now();
|
|
93
121
|
if (remainingMs <= 0) throw new ProcessInspectionError("deadline");
|
|
94
122
|
return await new Promise((resolve, reject) => {
|
|
@@ -100,16 +128,24 @@ async function readProcessOutput(args, deadline) {
|
|
|
100
128
|
if (output instanceof ProcessInspectionError) reject(output);
|
|
101
129
|
else resolve(output);
|
|
102
130
|
};
|
|
103
|
-
const
|
|
131
|
+
const procfs = command.kind === "procfs-command";
|
|
132
|
+
const inspector = execFile(procfs ? process.execPath : "ps", procfs ? [
|
|
133
|
+
...process.versions.bun ? ["--no-env-file", "--config=/dev/null"] : [],
|
|
134
|
+
"-e",
|
|
135
|
+
PROCFS_COMMAND_READER,
|
|
136
|
+
String(command.pid),
|
|
137
|
+
String(PROCESS_INSPECTION_MAX_BYTES)
|
|
138
|
+
] : command.args, {
|
|
104
139
|
encoding: "utf8",
|
|
105
140
|
maxBuffer: PROCESS_INSPECTION_MAX_BYTES,
|
|
106
|
-
|
|
141
|
+
cwd: procfs ? "/" : void 0,
|
|
142
|
+
env: procfs ? {} : {
|
|
107
143
|
...process.env,
|
|
108
144
|
LC_ALL: "C",
|
|
109
145
|
TZ: "UTC"
|
|
110
146
|
}
|
|
111
147
|
}, (error, stdout) => {
|
|
112
|
-
settle(Date.now() >= deadline ? new ProcessInspectionError("deadline") : error ? inspectionFailure(error) : stdout);
|
|
148
|
+
settle(Date.now() >= deadline ? new ProcessInspectionError("deadline") : error ? procfs && error.code === PROCFS_COMMAND_PERMISSION_EXIT ? new ProcessInspectionError("permission") : inspectionFailure(error) : stdout);
|
|
113
149
|
});
|
|
114
150
|
const timer = setTimeout(() => {
|
|
115
151
|
settle(new ProcessInspectionError("deadline"));
|
|
@@ -154,6 +190,7 @@ function parseProcesses(output, selected) {
|
|
|
154
190
|
return rows;
|
|
155
191
|
}
|
|
156
192
|
async function readLinuxProcesses(selected, deadline) {
|
|
193
|
+
if (selected !== void 0) return readSelectedLinuxProcesses(selected, deadline);
|
|
157
194
|
const remainingMs = deadline - Date.now();
|
|
158
195
|
if (remainingMs <= 0) throw new ProcessInspectionError("deadline");
|
|
159
196
|
const options = {
|
|
@@ -161,9 +198,8 @@ async function readLinuxProcesses(selected, deadline) {
|
|
|
161
198
|
signal: AbortSignal.timeout(remainingMs)
|
|
162
199
|
};
|
|
163
200
|
try {
|
|
164
|
-
const bootId = (await readFile("/proc/sys/kernel/random/boot_id", options))
|
|
165
|
-
|
|
166
|
-
const pids = selected === void 0 ? await readdir("/proc") : selected.map(String);
|
|
201
|
+
const bootId = parseLinuxBootId(await readFile("/proc/sys/kernel/random/boot_id", options));
|
|
202
|
+
const pids = await readdir("/proc");
|
|
167
203
|
const rows = [];
|
|
168
204
|
let bytes = 0;
|
|
169
205
|
for (const entry of pids) {
|
|
@@ -176,23 +212,81 @@ async function readLinuxProcesses(selected, deadline) {
|
|
|
176
212
|
if (stat === void 0) continue;
|
|
177
213
|
bytes += stat.length;
|
|
178
214
|
if (bytes > PROCESS_INSPECTION_MAX_BYTES) throw new ProcessInspectionError("unavailable");
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
215
|
+
const row = parseLinuxProcess(stat, entry, bootId, false);
|
|
216
|
+
if (row) rows.push(row);
|
|
217
|
+
}
|
|
218
|
+
if (Date.now() >= deadline) throw new ProcessInspectionError("deadline");
|
|
219
|
+
return rows;
|
|
220
|
+
} catch (error) {
|
|
221
|
+
throw inspectionFailure(error);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function parseLinuxBootId(value) {
|
|
225
|
+
const bootId = value.trim();
|
|
226
|
+
if (!/^[a-f0-9-]{36}$/.test(bootId)) throw new ProcessInspectionError("unavailable");
|
|
227
|
+
return bootId;
|
|
228
|
+
}
|
|
229
|
+
function parseLinuxProcess(stat, entry, bootId, selected) {
|
|
230
|
+
const commEnd = stat.lastIndexOf(")");
|
|
231
|
+
const fields = stat.slice(commEnd + 1).trim().split(/\s+/);
|
|
232
|
+
const ppid = Number(fields[1]);
|
|
233
|
+
const pgid = Number(fields[2]);
|
|
234
|
+
const startTicks = fields[19];
|
|
235
|
+
if (commEnd < 0 || ![ppid, pgid].every(Number.isSafeInteger) || selected && (pgid <= 0 || ppid < 0) || !/^\d+$/.test(startTicks ?? "")) throw new ProcessInspectionError("unavailable");
|
|
236
|
+
if (pgid > 0) {
|
|
237
|
+
const threads = Number(fields[17]);
|
|
238
|
+
if (!/^[1-9]\d*$/.test(fields[17] ?? "") || !Number.isSafeInteger(threads)) throw new ProcessInspectionError("unavailable");
|
|
239
|
+
return {
|
|
240
|
+
pid: Number(entry),
|
|
241
|
+
ppid,
|
|
242
|
+
pgid,
|
|
243
|
+
state: `${fields[0]}${threads > 1 ? "l" : ""}`,
|
|
244
|
+
startedAt: `${bootId}:${startTicks}`
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/** Known procfs identities must not queue behind unrelated libuv filesystem work. */
|
|
249
|
+
function readSelectedProcFile(file, deadline, maxBytes = PROCESS_INSPECTION_MAX_BYTES) {
|
|
250
|
+
if (Date.now() >= deadline) throw new ProcessInspectionError("deadline");
|
|
251
|
+
const fd = openSync(file, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
252
|
+
const chunks = [];
|
|
253
|
+
const buffer = Buffer.alloc(Math.min(4096, maxBytes + 1));
|
|
254
|
+
let bytes = 0;
|
|
255
|
+
try {
|
|
256
|
+
for (;;) {
|
|
257
|
+
if (Date.now() >= deadline) throw new ProcessInspectionError("deadline");
|
|
258
|
+
const count = readSync(fd, buffer, {
|
|
259
|
+
offset: 0,
|
|
260
|
+
length: Math.min(buffer.length, maxBytes - bytes + 1),
|
|
261
|
+
position: null
|
|
262
|
+
});
|
|
263
|
+
if (Date.now() >= deadline) throw new ProcessInspectionError("deadline");
|
|
264
|
+
if (count === 0) return Buffer.concat(chunks, bytes);
|
|
265
|
+
bytes += count;
|
|
266
|
+
if (bytes > maxBytes) throw new ProcessInspectionError("unavailable");
|
|
267
|
+
chunks.push(Buffer.from(buffer.subarray(0, count)));
|
|
268
|
+
}
|
|
269
|
+
} finally {
|
|
270
|
+
closeSync(fd);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function readSelectedLinuxProcesses(selected, deadline) {
|
|
274
|
+
try {
|
|
275
|
+
const bootId = parseLinuxBootId(readSelectedProcFile("/proc/sys/kernel/random/boot_id", deadline).toString("utf8"));
|
|
276
|
+
const rows = [];
|
|
277
|
+
let bytes = 0;
|
|
278
|
+
for (const entry of selected.map(String)) {
|
|
279
|
+
if (!/^\d+$/.test(entry)) continue;
|
|
280
|
+
let stat;
|
|
281
|
+
try {
|
|
282
|
+
stat = readSelectedProcFile(`/proc/${entry}/stat`, deadline, PROCESS_INSPECTION_MAX_BYTES - bytes);
|
|
283
|
+
} catch (error) {
|
|
284
|
+
if (error && typeof error === "object" && "code" in error && (error.code === "ENOENT" || error.code === "ESRCH")) continue;
|
|
285
|
+
throw error;
|
|
195
286
|
}
|
|
287
|
+
bytes += stat.length;
|
|
288
|
+
const row = parseLinuxProcess(stat.toString("utf8"), entry, bootId, true);
|
|
289
|
+
if (row) rows.push(row);
|
|
196
290
|
}
|
|
197
291
|
if (Date.now() >= deadline) throw new ProcessInspectionError("deadline");
|
|
198
292
|
return rows;
|
|
@@ -665,7 +759,8 @@ const QA_PARENT_PID_ENV = "OPENCLAW_QA_PARENT_PID";
|
|
|
665
759
|
const DEFAULT_SPAWN_RUNTIME = {
|
|
666
760
|
platform: process.platform,
|
|
667
761
|
env: process.env,
|
|
668
|
-
execPath: process.execPath
|
|
762
|
+
execPath: process.execPath,
|
|
763
|
+
isBun: typeof process.versions.bun === "string"
|
|
669
764
|
};
|
|
670
765
|
/** Resolves the concrete command/argv/shell settings used to spawn Codex app-server. */
|
|
671
766
|
function resolveCodexAppServerSpawnInvocation(options, runtime = DEFAULT_SPAWN_RUNTIME) {
|
|
@@ -679,6 +774,15 @@ function resolveCodexAppServerSpawnInvocation(options, runtime = DEFAULT_SPAWN_R
|
|
|
679
774
|
});
|
|
680
775
|
const args = normalizeCodexAppServerArgs(options.args);
|
|
681
776
|
const resolved = materializeWindowsSpawnProgram(program, args);
|
|
777
|
+
if (runtime.isBun && options.commandSource === "resolved-managed" && resolved.resolution === "direct" && [
|
|
778
|
+
".cjs",
|
|
779
|
+
".js",
|
|
780
|
+
".mjs"
|
|
781
|
+
].includes(path.extname(resolved.command).toLowerCase())) return {
|
|
782
|
+
command: runtime.execPath,
|
|
783
|
+
args: [resolved.command, ...resolved.argv],
|
|
784
|
+
windowsHide: resolved.windowsHide
|
|
785
|
+
};
|
|
682
786
|
return {
|
|
683
787
|
command: resolved.command,
|
|
684
788
|
args: resolved.argv,
|
|
@@ -727,7 +831,8 @@ async function createStdioTransport(options, baseEnv = process.env, assertCurren
|
|
|
727
831
|
const invocation = resolveCodexAppServerSpawnInvocation(options, {
|
|
728
832
|
platform: process.platform,
|
|
729
833
|
env,
|
|
730
|
-
execPath: process.execPath
|
|
834
|
+
execPath: process.execPath,
|
|
835
|
+
isBun: typeof process.versions.bun === "string"
|
|
731
836
|
});
|
|
732
837
|
const register = await prepareCodexAppServerProcessRegistration();
|
|
733
838
|
assertCurrent?.();
|