@openclaw/codex 2026.9.1 → 2026.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/api.js +18 -23
- package/dist/apply-B6el6hdO.js +357 -0
- package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-D6cR54TV.js} +113 -49
- package/dist/{attempt-context-DmQUNWwT.js → attempt-context-AO4DSjE0.js} +11 -9
- package/dist/{event-projector-usage-C5mcrGjp.js → attempt-notifications--H8zXR5-.js} +3 -89
- package/dist/auth-cache-key-Kq6oerr6.js +498 -0
- package/dist/auth-profile-CwzO4_RG.js +43 -0
- package/dist/auth-profile-selection-DFu9e167.js +45 -0
- package/dist/{binding-connection-E6uDsPlx.js → binding-connection-QqgcPCgk.js} +18 -3
- package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-lRpmZHFv.js} +54 -150
- package/dist/build-state-6RL6qohz.js +19 -0
- package/dist/{capabilities-dIjNVCYH.js → capabilities-BeqLPbtM.js} +2 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-BEKu4yDx.js +3983 -0
- package/dist/command-dispatch-CisT9Jqq.js +21 -0
- package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DeTfrapr.js} +2 -2
- package/dist/{command-handlers-CTGb2csu.js → command-handlers-BfIsJEuA.js} +158 -76
- package/dist/command-rpc-BMqRQOFX.js +226 -0
- package/dist/{compact-_t0HQrUS.js → compact-CGJZ2rlb.js} +89 -49
- package/dist/config-JDfTI4VI.js +106 -0
- package/dist/{config-BhmfC1s6.js → config-options-jnIFvwxD.js} +208 -654
- package/dist/config-runtime-BWf6JLWG.js +11 -0
- package/dist/config-utils-C57JiJrU.js +69 -0
- package/dist/conversation-binding-CxOlHiix.js +889 -0
- package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → conversation-control-CUCrSIQI.js} +36 -155
- package/dist/doctor-contract-api.js +8 -9
- package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-D-JBoaLt.js} +734 -698
- package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-J_5Ep5Um.js} +4 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
- package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-BmBM4qBV.js} +23 -27
- package/dist/event-projector-usage-CIyrYYid.js +102 -0
- package/dist/{harness-DXVZ5II5.js → harness-FR6eQgyO.js} +47 -17
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +413 -2893
- package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-DHBefrzg.js} +12 -21
- package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DrjjRRUD.js} +17 -84
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/{model-catalog-CUM68Hkl.js → model-catalog-B_6M04Wo.js} +6 -5
- package/dist/{models-sYnEc0gd.js → models-P9k2qAof.js} +4 -4
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-BbCUKRwC.js} +76 -48
- package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
- package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-BY_ctYnT.js} +54 -23
- package/dist/plan-BMJdMOEF.js +711 -0
- package/dist/plugin-activation-BQK-f5sV.js +133 -0
- package/dist/{thread-resume-C7pyVKeW.js → plugin-app-cache-key-CdSQzWyX.js} +5 -53
- package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
- package/dist/plugin-inventory-CoRCzWW4.js +325 -0
- package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
- package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
- package/dist/protocol-CAAcVIKF.js +275 -0
- package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-W4tfK5Y5.js} +2 -2
- package/dist/{rate-limits-CawQJfUS.js → rate-limits-Bqnx1N4z.js} +1 -1
- package/dist/request-CGvGOpeR.js +198 -0
- package/dist/{run-attempt-D1hJO4fX.js → run-attempt-DwKds3DN.js} +1498 -1028
- package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-T-NwqeSH.js} +28 -28
- package/dist/sandbox-guard-BcT66fWy.js +165 -0
- package/dist/{session-binding-BHuTCRZQ.js → session-binding-CKSepwIC.js} +118 -324
- package/dist/session-binding-record-CaZjYwNS.js +256 -0
- package/dist/session-catalog-HaDcp7Sv.js +1533 -0
- package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
- package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
- package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
- package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
- package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
- package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
- package/dist/session-catalog-provenance-DkJHo735.js +124 -0
- package/dist/{session-cli-CmFEXMAM.js → session-cli-CbgaHh0f.js} +3 -2
- package/dist/session-history-Cz-tOOYj.js +96 -0
- package/dist/{session-upstream-marker-C351-5Qw.js → session-history-import-DFN7sWRU.js} +5 -49
- package/dist/session-history-read-cxPUxyVV.js +50 -0
- package/dist/session-history-worker-runtime.js +60 -0
- package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-CNEvGaU5.js} +75 -69
- package/dist/session-history.worker.js +2 -0
- package/dist/{session-initialization-BeWzjGiR.js → session-initialization-Jo86C60I.js} +2 -1
- package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-B22InTp_.js} +4 -7
- package/dist/{session-retirement-BujDjXVF.js → session-retirement-BSNG_mhf.js} +8 -7
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/settled-turn-context-Du6gdUDd.js +45 -0
- package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BuLUrZl2.js} +54 -42
- package/dist/shared-client-CVhez2Uo.js +2911 -0
- package/dist/{side-question-BTZAII4l.js → side-question-DLbr2vUU.js} +135 -191
- package/dist/source-Da-h6f7e.js +518 -0
- package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
- package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-D1pzRwHB.js} +467 -977
- package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-D6oASVRu.js} +15 -17
- package/dist/{thread-policy-g4KbJPzp.js → thread-policy-D8kI7yAO.js} +2 -2
- package/dist/thread-resume-T5cveyxA.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/transcript-mirror-attestation-DibE0krH.js +89 -0
- package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-t5TOccct.js} +111 -379
- package/dist/{transport-stdio-CyPldczm.js → transport-stdio-BGjHoYLr.js} +80 -48
- package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-De-sLJ2r.js} +94 -166
- package/dist/{usage-Bj-rrzkR.js → usage-CPPTmBvZ.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
- package/openclaw.plugin.json +22 -1
- package/package.json +6 -6
- package/dist/request-DYAI5FQE.js +0 -475
- package/dist/session-catalog-yyvTWFOw.js +0 -3120
- package/dist/session-history-C5J1AKzG.js +0 -87
- package/dist/shared-client-DxcfF9KX.js +0 -7494
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { n as withCodexAppServerThreadMutation } from "./incognito-session-uhrBF6wJ.js";
|
|
3
|
+
import { U as releaseCodexAppServerLiveThread, W as retainCodexAppServerLiveThread, _ as retainSharedCodexAppServerClientByInstanceId, z as isCodexAppServerLiveThreadClaimed } from "./shared-client-CVhez2Uo.js";
|
|
4
|
+
import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-D6cR54TV.js";
|
|
6
5
|
//#region extensions/codex/src/app-server/thread-ownership.ts
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
var thread_ownership_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
isSameCodexAppServerThreadOwner: () => isSameCodexAppServerThreadOwner,
|
|
8
|
+
releaseCodexAppServerBindingSubscription: () => releaseCodexAppServerBindingSubscription,
|
|
9
|
+
retainCodexAppServerBindingSubscription: () => retainCodexAppServerBindingSubscription,
|
|
10
|
+
retireCodexConversationThreadBinding: () => retireCodexConversationThreadBinding,
|
|
11
|
+
rollbackCodexAppServerBindingSubscription: () => rollbackCodexAppServerBindingSubscription,
|
|
12
|
+
withExclusiveCodexAppServerThread: () => withExclusiveCodexAppServerThread
|
|
13
|
+
});
|
|
12
14
|
/** Codex subscriptions belong to a physical connection, not the native thread ID alone. */
|
|
13
15
|
function isSameCodexAppServerThreadOwner(current, expected) {
|
|
14
16
|
return current !== void 0 && expected !== void 0 && current.threadId === expected.threadId && current.clientId === expected.clientId;
|
|
@@ -20,10 +22,6 @@ async function withExclusiveCodexAppServerThread(params) {
|
|
|
20
22
|
return await params.run();
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
|
-
/** Serializes bound turns and retirement so detach cannot unsubscribe an active turn. */
|
|
24
|
-
async function withCodexConversationThreadActivity(bindingId, run) {
|
|
25
|
-
return await nativeThreadOwners.enqueue(`conversation:${bindingId}`, run);
|
|
26
|
-
}
|
|
27
25
|
/** Publishes one owned subscription with its persistent or ephemeral retention lifetime. */
|
|
28
26
|
async function retainCodexAppServerBindingSubscription(client, threadId, ownership) {
|
|
29
27
|
return await retainCodexAppServerLiveThread(client, threadId, ownership?.release ?? (async (releasedThreadId, assertCurrent) => {
|
|
@@ -71,10 +69,10 @@ async function releaseCodexAppServerBindingSubscription(binding, options = {}) {
|
|
|
71
69
|
}
|
|
72
70
|
/** Clears and releases one exact conversation generation without touching its replacement. */
|
|
73
71
|
async function retireCodexConversationThreadBinding(params) {
|
|
74
|
-
const expected =
|
|
72
|
+
const expected = params.bindingStore.read(params.identity);
|
|
75
73
|
if (!expected || params.expectedThreadId && expected.threadId !== params.expectedThreadId) return false;
|
|
76
74
|
return await withCodexAppServerThreadMutation(expected.threadId, () => params.bindingStore.withLease(params.identity, async () => {
|
|
77
|
-
const current =
|
|
75
|
+
const current = params.bindingStore.read(params.identity);
|
|
78
76
|
if (!current || !isSameCodexAppServerThreadOwner(current, expected) || params.expectedStartId && current?.conversationStartId !== params.expectedStartId) return false;
|
|
79
77
|
await releaseCodexAppServerBindingSubscription(current, { allowUntracked: params.allowUntracked });
|
|
80
78
|
const cleared = await params.bindingStore.mutate(params.identity, {
|
|
@@ -100,4 +98,4 @@ async function retireCodexConversationThreadBinding(params) {
|
|
|
100
98
|
}));
|
|
101
99
|
}
|
|
102
100
|
//#endregion
|
|
103
|
-
export { rollbackCodexAppServerBindingSubscription as a,
|
|
101
|
+
export { rollbackCodexAppServerBindingSubscription as a, retireCodexConversationThreadBinding as i, releaseCodexAppServerBindingSubscription as n, thread_ownership_exports as o, retainCodexAppServerBindingSubscription as r, withExclusiveCodexAppServerThread as s, isSameCodexAppServerThreadOwner as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as requestCodexAppServerClientJson, t as CodexAppServerScopedRequestRejectedError } from "./request-
|
|
1
|
+
import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError } from "./client-BEKu4yDx.js";
|
|
2
|
+
import { r as requestCodexAppServerClientJson, t as CodexAppServerScopedRequestRejectedError } from "./request-CGvGOpeR.js";
|
|
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. */
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError, y as assertCodexThreadResumeResponse } from "./client-BEKu4yDx.js";
|
|
2
|
+
import { r as CodexAppServerRpcError } from "./session-catalog-provenance-DkJHo735.js";
|
|
3
|
+
import { t as CodexAppServerScopedRequestRejectedError } from "./request-CGvGOpeR.js";
|
|
4
|
+
import { I as forgetCodexWorkspaceReferences, k as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CVhez2Uo.js";
|
|
5
|
+
import { d as unsubscribeCodexThreadBestEffort, i as assertCodexThreadResumeSubscription, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-D6cR54TV.js";
|
|
6
|
+
//#region extensions/codex/src/app-server/thread-resume.ts
|
|
7
|
+
/** Owns Codex thread/resume subscription safety. */
|
|
8
|
+
/** Resumes one thread, releasing or isolating every possible native subscription. */
|
|
9
|
+
async function resumeCodexAppServerThread(params) {
|
|
10
|
+
const threadId = params.request.threadId;
|
|
11
|
+
let response;
|
|
12
|
+
let ownershipRejected = false;
|
|
13
|
+
const assertCurrent = params.assertCurrent && (() => {
|
|
14
|
+
try {
|
|
15
|
+
params.assertCurrent?.();
|
|
16
|
+
} catch (error) {
|
|
17
|
+
ownershipRejected = true;
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
try {
|
|
22
|
+
response = assertCodexThreadResumeResponse(await (params.requestResume ? params.requestResume(params.request) : params.client.request("thread/resume", params.request, {
|
|
23
|
+
...params.timeoutMs !== void 0 ? { timeoutMs: params.timeoutMs } : {},
|
|
24
|
+
...params.signal ? { signal: params.signal } : {},
|
|
25
|
+
assertCurrent
|
|
26
|
+
})));
|
|
27
|
+
assertCodexThreadResumeSubscription(threadId, response.thread.id);
|
|
28
|
+
forgetCodexWorkspaceReferences(params.client, threadId);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (ownershipRejected || isCodexAppServerStartSelectionChangedError(error) || isCodexAppServerStartupError(error) || error instanceof CodexAppServerScopedRequestRejectedError || isCodexAppServerPrewriteRequestCancellationError(error) || isCodexAppServerOverloadError(error)) throw error;
|
|
31
|
+
if (error instanceof CodexAppServerRpcError) {
|
|
32
|
+
if (await unsubscribeCodexThreadBestEffort(params.client, {
|
|
33
|
+
threadId,
|
|
34
|
+
timeoutMs: 5e3,
|
|
35
|
+
assertCurrent: params.assertCurrent
|
|
36
|
+
}).catch(() => false)) {
|
|
37
|
+
params.onSubscriptionReleased?.();
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
await params.abandonClient();
|
|
43
|
+
} catch (abandonError) {
|
|
44
|
+
throw new CodexAppServerUnsafeSubscriptionError(`Codex thread/resume client could not be retired for ${threadId}`, { cause: abandonError });
|
|
45
|
+
}
|
|
46
|
+
if (error instanceof CodexAppServerUnsafeSubscriptionError) throw error;
|
|
47
|
+
throw new CodexAppServerUnsafeSubscriptionError(error instanceof Error ? error.message : `Codex thread/resume outcome is indeterminate for ${threadId}`, { cause: error });
|
|
48
|
+
}
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { resumeCodexAppServerThread as t };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { withTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
2
|
+
//#region extensions/codex/src/app-server/timeout.ts
|
|
3
|
+
/**
|
|
4
|
+
* Thin Codex app-server timeout adapter around OpenClaw's shared timeout helper.
|
|
5
|
+
*/
|
|
6
|
+
function resolveAbortError(signal) {
|
|
7
|
+
return signal.reason instanceof Error ? signal.reason : new Error("Codex app-server operation aborted", { cause: signal.reason });
|
|
8
|
+
}
|
|
9
|
+
/** Awaits a promise with a Codex-specific timeout error message. */
|
|
10
|
+
async function withTimeout$1(promise, timeoutMs, timeoutMessage, createError) {
|
|
11
|
+
return await withTimeout(promise, timeoutMs, {
|
|
12
|
+
message: timeoutMessage,
|
|
13
|
+
...createError ? { createError } : {}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/** Bounds an operation by both its owner lifecycle and one total wall-clock budget. */
|
|
17
|
+
async function withAbortableTimeout(params) {
|
|
18
|
+
const signal = params.signal;
|
|
19
|
+
if (signal?.aborted) throw resolveAbortError(signal);
|
|
20
|
+
let removeAbortListener;
|
|
21
|
+
const operation = signal ? Promise.race([params.promise, new Promise((_, reject) => {
|
|
22
|
+
const onAbort = () => reject(resolveAbortError(signal));
|
|
23
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
24
|
+
removeAbortListener = () => signal.removeEventListener("abort", onAbort);
|
|
25
|
+
})]) : params.promise;
|
|
26
|
+
try {
|
|
27
|
+
return await withTimeout$1(operation, params.timeoutMs, params.timeoutMessage, params.createTimeoutError);
|
|
28
|
+
} finally {
|
|
29
|
+
removeAbortListener?.();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { withTimeout$1 as n, withAbortableTimeout as t };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { i as readUpstreamUserText, r as readMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
|
|
2
|
+
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
//#region extensions/codex/src/app-server/transcript-mirror-attestation.ts
|
|
5
|
+
function isMirroredAgentMessage(message) {
|
|
6
|
+
return message.role === "user" || message.role === "assistant" || message.role === "toolResult";
|
|
7
|
+
}
|
|
8
|
+
function buildCodexMirrorDedupeIdentity(message) {
|
|
9
|
+
const identity = readMirrorIdentity(message);
|
|
10
|
+
if (identity) return identity;
|
|
11
|
+
const payload = JSON.stringify({
|
|
12
|
+
role: message.role,
|
|
13
|
+
content: message.content
|
|
14
|
+
});
|
|
15
|
+
return `${message.role}:${createHash("sha256").update(payload).digest("hex").slice(0, 16)}`;
|
|
16
|
+
}
|
|
17
|
+
const MIRROR_ORIGIN_META_KEY = "mirrorOrigin";
|
|
18
|
+
const MIRROR_SOURCE_FINGERPRINT_META_KEY = "mirrorSourceFingerprint";
|
|
19
|
+
const CODEX_APP_SERVER_MIRROR_ORIGIN = "codex-app-server";
|
|
20
|
+
const CODEX_META_KEY = "__openclaw";
|
|
21
|
+
function applyCodexTranscriptTaint(message, state) {
|
|
22
|
+
if (message.role === "user") {
|
|
23
|
+
state.tainted = false;
|
|
24
|
+
return message;
|
|
25
|
+
}
|
|
26
|
+
const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
27
|
+
const metadata = asOptionalRecord(existing);
|
|
28
|
+
state.tainted ||= metadata?.turnTainted === true || metadata?.resultContentSource === "network";
|
|
29
|
+
return message.role === "assistant" && state.tainted ? {
|
|
30
|
+
...message,
|
|
31
|
+
__openclaw: {
|
|
32
|
+
...metadata,
|
|
33
|
+
turnTainted: true
|
|
34
|
+
}
|
|
35
|
+
} : message;
|
|
36
|
+
}
|
|
37
|
+
function attachCodexMirrorAttestation(message, sourceFingerprint) {
|
|
38
|
+
const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
39
|
+
const baseMeta = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
|
|
40
|
+
return {
|
|
41
|
+
...message,
|
|
42
|
+
[CODEX_META_KEY]: {
|
|
43
|
+
...baseMeta,
|
|
44
|
+
[MIRROR_ORIGIN_META_KEY]: CODEX_APP_SERVER_MIRROR_ORIGIN,
|
|
45
|
+
...sourceFingerprint ? { [MIRROR_SOURCE_FINGERPRINT_META_KEY]: sourceFingerprint } : {}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function attachCodexMirrorRunId(message, runId, terminal = false, settlementWarning) {
|
|
50
|
+
const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
51
|
+
const { runTerminal: _staleTerminal, ...current } = asOptionalRecord(existing) ?? {};
|
|
52
|
+
return {
|
|
53
|
+
...message,
|
|
54
|
+
[CODEX_META_KEY]: {
|
|
55
|
+
...current,
|
|
56
|
+
runId,
|
|
57
|
+
...terminal ? { runTerminal: true } : {},
|
|
58
|
+
...terminal && settlementWarning ? { settlementWarning } : {}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function hasCodexMirrorOrigin(message) {
|
|
63
|
+
const meta = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
64
|
+
return asOptionalRecord(meta)?.[MIRROR_ORIGIN_META_KEY] === CODEX_APP_SERVER_MIRROR_ORIGIN;
|
|
65
|
+
}
|
|
66
|
+
function readCodexMirrorSourceFingerprint(message) {
|
|
67
|
+
const meta = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
68
|
+
if (!meta || typeof meta !== "object" || Array.isArray(meta)) return;
|
|
69
|
+
const value = meta[MIRROR_SOURCE_FINGERPRINT_META_KEY];
|
|
70
|
+
return typeof value === "string" && value ? value : void 0;
|
|
71
|
+
}
|
|
72
|
+
function serializeCodexMirrorSourceEvidence(message) {
|
|
73
|
+
const content = "content" in message ? message.content : void 0;
|
|
74
|
+
return JSON.stringify({
|
|
75
|
+
role: message.role,
|
|
76
|
+
content,
|
|
77
|
+
...message.role === "user" ? { upstreamUserText: readUpstreamUserText(message) } : {},
|
|
78
|
+
...message.role === "toolResult" ? {
|
|
79
|
+
toolCallId: message.toolCallId,
|
|
80
|
+
toolName: message.toolName,
|
|
81
|
+
isError: message.isError
|
|
82
|
+
} : {}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function fingerprintCodexMirrorSourceMessage(message) {
|
|
86
|
+
return createHash("sha256").update(serializeCodexMirrorSourceEvidence(message)).digest("hex").slice(0, 32);
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { fingerprintCodexMirrorSourceMessage as a, readCodexMirrorSourceFingerprint as c, buildCodexMirrorDedupeIdentity as i, serializeCodexMirrorSourceEvidence as l, attachCodexMirrorAttestation as n, hasCodexMirrorOrigin as o, attachCodexMirrorRunId as r, isMirroredAgentMessage as s, applyCodexTranscriptTaint as t };
|