@openclaw/codex 2026.9.3 → 2026.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +26 -18
- package/dist/{apply-B6el6hdO.js → apply-CvT8tW5i.js} +11 -12
- package/dist/{attempt-client-cleanup-D6cR54TV.js → attempt-client-cleanup-DKHzbwt5.js} +8 -204
- package/dist/{attempt-context-AO4DSjE0.js → attempt-context-D44yeDII.js} +3 -3
- package/dist/{attempt-notifications--H8zXR5-.js → attempt-notifications-C9XufG6l.js} +1 -1
- package/dist/{auth-binding-Co2Vfcf_.js → auth-binding-CWlKVccJ.js} +1 -1
- package/dist/{auth-cache-key-Kq6oerr6.js → auth-cache-key-7orQae_j.js} +2 -2
- package/dist/{binding-connection-QqgcPCgk.js → binding-connection-D3udKbIE.js} +3 -3
- package/dist/{bounded-turn-lRpmZHFv.js → bounded-turn-C_Hneydj.js} +12 -12
- package/dist/{build-state-6RL6qohz.js → build-state-BCmg9-5p.js} +1 -1
- package/dist/{capabilities-BeqLPbtM.js → capabilities-8vx68WLH.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-BEKu4yDx.js → client-B57KWPQx.js} +27 -5
- package/dist/{command-dispatch-CisT9Jqq.js → command-dispatch-BpduNGVf.js} +3 -3
- package/dist/{command-formatters-DeTfrapr.js → command-formatters-lxlkNZgU.js} +4 -3
- package/dist/{command-handlers-BfIsJEuA.js → command-handlers-tiL9iWj7.js} +783 -140
- package/dist/{command-rpc-BMqRQOFX.js → command-rpc-CR5EOEZX.js} +26 -19
- package/dist/{compact-CGJZ2rlb.js → compact-B_H3AOd7.js} +14 -14
- package/dist/{config-JDfTI4VI.js → config-oIORaQ5T.js} +4 -4
- package/dist/{config-options-jnIFvwxD.js → config-options-CXMq1T-C.js} +5 -5
- package/dist/{config-runtime-BWf6JLWG.js → config-runtime-D0zGNIHu.js} +1 -1
- package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
- package/dist/{conversation-binding-CxOlHiix.js → conversation-binding-DsB4-O7U.js} +53 -42
- package/dist/{conversation-control-CUCrSIQI.js → conversation-control-CtUu1b3m.js} +8 -8
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{dynamic-tools-D-JBoaLt.js → dynamic-tools-CmN5RAip.js} +76 -15
- package/dist/{effective-mcp-catalog-J_5Ep5Um.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
- package/dist/{ephemeral-turn-DSwzP8YY.js → ephemeral-turn-D78_VmzO.js} +5 -5
- package/dist/event-projector-items-5VhsECCO.js +200 -0
- package/dist/{event-projector-usage-CIyrYYid.js → event-projector-usage-BfXmpOec.js} +1 -1
- package/dist/{harness-FR6eQgyO.js → harness-C7rRa7bm.js} +33 -16
- package/dist/harness.js +1 -1
- package/dist/index.js +39 -84
- package/dist/inference-context-Dr_mzvk4.js +94 -0
- package/dist/inference-proxy-HGXKUIre.js +311 -0
- package/dist/{isolated-completion-DHBefrzg.js → isolated-completion-DWVb5U2J.js} +6 -6
- package/dist/{managed-binary-DrjjRRUD.js → managed-binary-D22rNEcR.js} +10 -1
- package/dist/media-understanding-provider.js +2 -2
- package/dist/migration-provider-api.js +2 -0
- package/dist/{model-catalog-B_6M04Wo.js → model-catalog-Dq2n8f_p.js} +6 -6
- package/dist/{models-P9k2qAof.js → models-PCKOim-h.js} +3 -3
- package/dist/native-subagent-history-DjtPloaU.js +140 -0
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
- package/dist/{native-subagent-monitor-BbCUKRwC.js → native-subagent-monitor-fQ7eIXEf.js} +52 -424
- package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
- package/dist/{node-cli-sessions-rj0ysJwM.js → node-cli-sessions-DKaOmVUh.js} +1 -1
- package/dist/{node-exec-server.runtime-BY_ctYnT.js → node-exec-server.runtime-Cl2vapEi.js} +3 -3
- package/dist/{plan-BMJdMOEF.js → plan-7uG-Fp36.js} +288 -52
- package/dist/{plugin-activation-BQK-f5sV.js → plugin-activation-BYQculil.js} +24 -19
- package/dist/{plugin-app-cache-key-CdSQzWyX.js → plugin-app-cache-key-d0eKxy7b.js} +1 -1
- package/dist/{plugin-approval-roundtrip-DeW95wB5.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
- package/dist/{plugin-inventory-CoRCzWW4.js → plugin-inventory-oL4Na1ZG.js} +7 -4
- package/dist/{plugin-marketplace-discovery-3akBizzF.js → plugin-marketplace-discovery-P-Vndfqq.js} +18 -15
- package/dist/{plugin-metadata-cache-DgNfRAGA.js → plugin-metadata-cache-ClPJpRio.js} +13 -9
- package/dist/{protocol-CAAcVIKF.js → protocol-5bh1G-H7.js} +1 -1
- package/dist/provider-MQ8PVkuE.js +50 -0
- package/dist/{provider-capabilities-W4tfK5Y5.js → provider-capabilities-BvCUL69A.js} +2 -2
- package/dist/{rate-limits-Bqnx1N4z.js → rate-limits-CBMmWBr9.js} +1 -1
- package/dist/{request-CGvGOpeR.js → request-B7hEkBGq.js} +72 -58
- package/dist/rpc-error-ttN_QjEm.js +30 -0
- package/dist/{run-attempt-DwKds3DN.js → run-attempt-CvsAAGa0.js} +108 -37
- package/dist/{runtime-artifact-T-NwqeSH.js → runtime-artifact-BJ0rXBZ_.js} +1 -1
- package/dist/{sandbox-guard-BcT66fWy.js → sandbox-guard-BxgyoM8M.js} +2 -1
- package/dist/{session-binding-CKSepwIC.js → session-binding-CI8UuilT.js} +3 -3
- package/dist/{session-binding-record-CaZjYwNS.js → session-binding-record-Bcvslnhf.js} +1 -1
- package/dist/{session-catalog-adoption-BKLtSrwi.js → session-catalog-adoption-tcZi1IfX.js} +5 -5
- package/dist/{session-catalog-archive-D0i2pGj2.js → session-catalog-archive-CwKg8Xz2.js} +6 -6
- package/dist/{session-catalog-HaDcp7Sv.js → session-catalog-ct-AH01I.js} +31 -87
- package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
- package/dist/{session-catalog-node-adoption-BUuDYY8R.js → session-catalog-node-adoption-B1tgDW-m.js} +2 -2
- package/dist/{session-catalog-node-continue-CBtc4wkI.js → session-catalog-node-continue-Ci-DXyJP.js} +4 -4
- package/dist/{session-catalog-provenance-DkJHo735.js → session-catalog-provenance-D-dIfRAH.js} +2 -30
- package/dist/{session-cli-CbgaHh0f.js → session-cli-DNN_jhGc.js} +2 -2
- package/dist/{session-history-import-DFN7sWRU.js → session-history-import-DwyijFI6.js} +4 -4
- package/dist/session-history-worker-runtime.js +1 -1
- package/dist/{session-history.worker-CNEvGaU5.js → session-history.worker-BeK1YOyT.js} +187 -83
- package/dist/session-history.worker.js +1 -1
- package/dist/{session-initialization-Jo86C60I.js → session-initialization-Ct0_Hzmg.js} +2 -2
- package/dist/{session-permission-policy-B22InTp_.js → session-permission-policy-BBmXA8Eg.js} +2 -2
- package/dist/{session-retirement-BSNG_mhf.js → session-retirement-B2YfbAAT.js} +5 -5
- package/dist/{settled-turn-finalizer-BuLUrZl2.js → settled-turn-finalizer-Dn91stmc.js} +5 -5
- package/dist/{shared-client-CVhez2Uo.js → shared-client-CscigXXL.js} +228 -30
- package/dist/{side-question-DLbr2vUU.js → side-question-BGMJQf4U.js} +18 -18
- package/dist/{source-Da-h6f7e.js → source-CElXU0Oy.js} +12 -12
- package/dist/{thread-archive-guard-D1bP04Tf.js → thread-archive-guard-DfpBr-Sz.js} +1 -1
- package/dist/{session-catalog-parsing-CdD3JhdM.js → thread-history-page-D0JIp48V.js} +83 -2
- package/dist/{thread-lifecycle-D1pzRwHB.js → thread-lifecycle-DXl1-I6b.js} +96 -44
- package/dist/{thread-ownership-D6oASVRu.js → thread-ownership-BsDRTsyp.js} +2 -2
- package/dist/{thread-policy-D8kI7yAO.js → thread-policy-BuEQfE0g.js} +3 -3
- package/dist/{thread-resume-T5cveyxA.js → thread-resume-DsDOZpFg.js} +5 -5
- package/dist/{session-catalog-home-id-D7-aLiNt.js → transcript-history-projection-v17wXgdK.js} +66 -18
- package/dist/{transcript-mirror-t5TOccct.js → transcript-mirror-C5CKgNy6.js} +1 -1
- package/dist/{upstream-session-fork-De-sLJ2r.js → upstream-session-fork-BZerMte_.js} +20 -20
- package/dist/{usage-CPPTmBvZ.js → usage-tCk-mg_x.js} +4 -4
- package/dist/{web-search-provider.runtime-CSVgQL0w.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
- package/openclaw.plugin.json +1 -0
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as CODEX_INTERACTIVE_THREAD_SOURCE_KINDS, t as CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES } from "./protocol-
|
|
1
|
+
import { n as CODEX_INTERACTIVE_THREAD_SOURCE_KINDS, t as CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES } from "./protocol-5bh1G-H7.js";
|
|
2
2
|
import { asFiniteNumber, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
4
4
|
//#region extensions/codex/src/session-catalog-parsing.ts
|
|
@@ -277,4 +277,85 @@ function requireBoundThread(entry) {
|
|
|
277
277
|
return entry.boundThreadId;
|
|
278
278
|
}
|
|
279
279
|
//#endregion
|
|
280
|
-
|
|
280
|
+
//#region extensions/codex/src/app-server/thread-history-page.ts
|
|
281
|
+
const TURN_ITEM_CURSOR_PREFIX = "turn-item:";
|
|
282
|
+
function encodeTurnItemCursor(turnCursor, itemId) {
|
|
283
|
+
return TURN_ITEM_CURSOR_PREFIX + Buffer.from(JSON.stringify([turnCursor, itemId])).toString("base64url");
|
|
284
|
+
}
|
|
285
|
+
function decodeTurnItemCursor(cursor) {
|
|
286
|
+
if (!cursor?.startsWith(TURN_ITEM_CURSOR_PREFIX)) return { turnCursor: cursor };
|
|
287
|
+
let value;
|
|
288
|
+
try {
|
|
289
|
+
value = JSON.parse(Buffer.from(cursor.slice(10), "base64url").toString());
|
|
290
|
+
} catch {
|
|
291
|
+
throw new CatalogParamsError("invalid Codex transcript item cursor");
|
|
292
|
+
}
|
|
293
|
+
if (!Array.isArray(value) || value.length !== 2 || typeof value[0] !== "string" || !value[0] || typeof value[1] !== "string" || !value[1]) throw new CatalogParamsError("invalid Codex transcript item cursor");
|
|
294
|
+
return {
|
|
295
|
+
turnCursor: value[0],
|
|
296
|
+
itemId: value[1]
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/** Legacy stores expose only turn cursors; an item identity preserves paging across appends. */
|
|
300
|
+
async function readLegacyCodexHistoryPage(readTurns, request, projection) {
|
|
301
|
+
const { turnCursor, itemId } = decodeTurnItemCursor(request.cursor);
|
|
302
|
+
const page = parseTranscriptPage(await readTurns({
|
|
303
|
+
threadId: request.threadId,
|
|
304
|
+
limit: 1,
|
|
305
|
+
sortDirection: "desc",
|
|
306
|
+
itemsView: "full",
|
|
307
|
+
...turnCursor ? { cursor: turnCursor } : {}
|
|
308
|
+
}));
|
|
309
|
+
const source = page.data.flatMap(({ items, ...turn }) => items.toReversed().map((item) => ({
|
|
310
|
+
turnId: turn.id,
|
|
311
|
+
item,
|
|
312
|
+
turn
|
|
313
|
+
})));
|
|
314
|
+
const anchorIndex = itemId ? source.findIndex(({ item }) => item.id === itemId) : -1;
|
|
315
|
+
if (itemId && anchorIndex < 0) throw new CatalogParamsError("Codex transcript changed; refresh the session before loading older items");
|
|
316
|
+
const remaining = source.slice(anchorIndex + 1);
|
|
317
|
+
const items = projection.project(remaining.slice(0, request.limit), request.limit);
|
|
318
|
+
const result = () => {
|
|
319
|
+
const lastSource = remaining[items.length - 1];
|
|
320
|
+
const partial = lastSource !== void 0 && items.length < remaining.length;
|
|
321
|
+
const nativeCursor = partial ? page.backwardsCursor : page.nextCursor;
|
|
322
|
+
const cursor = nativeCursor ? partial ? encodeTurnItemCursor(nativeCursor, lastSource.item.id) : nativeCursor : void 0;
|
|
323
|
+
if (partial && !cursor) throw new Error("Codex app-server did not provide a transcript continuation anchor");
|
|
324
|
+
return {
|
|
325
|
+
items,
|
|
326
|
+
...cursor ? { nextCursor: cursor } : {}
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
let bounded = result();
|
|
330
|
+
while (!projection.fits(bounded)) {
|
|
331
|
+
if (items.length <= 1) throw new Error("Codex transcript item exceeds the safe response size");
|
|
332
|
+
items.pop();
|
|
333
|
+
bounded = result();
|
|
334
|
+
}
|
|
335
|
+
return bounded;
|
|
336
|
+
}
|
|
337
|
+
/** Callers authorize the thread; this reader owns native cursor and response-size semantics. */
|
|
338
|
+
async function readCodexThreadHistoryPage(control, thread, request, projection) {
|
|
339
|
+
if (thread.historyMode !== "paginated") return readLegacyCodexHistoryPage((params) => control.listTurnPage(params), request, projection);
|
|
340
|
+
let limit = request.limit;
|
|
341
|
+
for (;;) {
|
|
342
|
+
const page = await control.listItemPage({
|
|
343
|
+
threadId: request.threadId,
|
|
344
|
+
limit,
|
|
345
|
+
sortDirection: "desc",
|
|
346
|
+
...request.cursor ? { cursor: request.cursor } : {}
|
|
347
|
+
});
|
|
348
|
+
const nextCursor = readControlCursor(page.nextCursor, "transcript next response");
|
|
349
|
+
const items = projection.project(page.data, limit);
|
|
350
|
+
const result = {
|
|
351
|
+
items,
|
|
352
|
+
...nextCursor ? { nextCursor } : {}
|
|
353
|
+
};
|
|
354
|
+
const fittingCount = items.length - (projection.fits(result) ? 0 : 1);
|
|
355
|
+
if (fittingCount === page.data.length) return result;
|
|
356
|
+
if (fittingCount < 1) throw new Error("Codex transcript item exceeds the safe response size");
|
|
357
|
+
limit = fittingCount;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
//#endregion
|
|
361
|
+
export { readPageParams as C, unwrapNodeInvokePayload as D, toCatalogSession as E, readGatewayParams as S, requireOnlyKeys as T, parseCatalogPage as _, CODEX_APP_SERVER_THREAD_TURNS_LIST_COMMAND as a, readBoundedOptionalString as b, CatalogParamsError as c, NODE_INVOKE_TIMEOUT_MS as d, boundedCatalogString as f, normalizeLimit as g, isInteractiveThreadSource as h, CODEX_APP_SERVER_THREADS_LIST_COMMAND as i, MAX_CURSOR_LENGTH as l, filterCatalogPageByTitle as m, readLegacyCodexHistoryPage as n, CODEX_CATALOG_TRANSCRIPT_READ_COMMAND as o, catalogError as p, CODEX_APP_SERVER_THREADS_CAPABILITY as r, CODEX_LOCAL_SESSION_HOST_ID as s, readCodexThreadHistoryPage as t, MAX_TRANSCRIPT_PAGE_BYTES as u, parseJsonParams as v, requireBoundThread as w, readControlCursor as x, parseTranscriptPage as y };
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { a as readCodexPluginInventory, o as resolveOwnedAppApprovalOverrideKeys } from "./plugin-inventory-oL4Na1ZG.js";
|
|
2
|
+
import { l as sessionBindingIdentity, n as assertCodexBindingMayBeReplaced } from "./session-binding-record-Bcvslnhf.js";
|
|
3
|
+
import { f as assertCodexModelBackedReviewerEffectiveConfig, g as readCodexEffectiveConfig, h as CODEX_SESSION_OVERRIDABLE_LAYER_TYPES, n as codexSandboxPolicyForTurn } from "./config-options-CXMq1T-C.js";
|
|
4
|
+
import { S as resolveCodexPluginsPolicy, a as flattenCodexDynamicToolFunctions, c as resolveCodexAppServerLocalHomeDir, o as isJsonObject, s as resolveCodexAppServerHomeDir } from "./protocol-5bh1G-H7.js";
|
|
5
|
+
import { L as resolveCodexToolAbortTerminalReason, _ as assertCodexThreadAcceptsDirectInput, b as assertCodexThreadStartResponse, d as isCodexAppServerRequestTimeoutError, l as isCodexAppServerOverloadError, p as resolveCodexAppServerClientInstanceId, r as getCodexAppServerClientInstanceId, v as assertCodexThreadForkResponse } from "./client-B57KWPQx.js";
|
|
5
6
|
import { i as markStartedCodexManagedThread } from "./managed-thread-store-D1t5jh3G.js";
|
|
6
7
|
import { n as withCodexAppServerThreadMutation, t as isIncognitoSessionKey } from "./incognito-session-uhrBF6wJ.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { c as serializeCodexAppInventoryError, o as CodexAppInventoryCache, s as defaultCodexAppInventoryCache, t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-
|
|
8
|
+
import { n as isCodexThreadReadMissingError, t as CodexAppServerRpcError } from "./rpc-error-ttN_QjEm.js";
|
|
9
|
+
import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-v17wXgdK.js";
|
|
10
|
+
import { c as serializeCodexAppInventoryError, o as CodexAppInventoryCache, s as defaultCodexAppInventoryCache, t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-d0eKxy7b.js";
|
|
10
11
|
import { t as withAbortableTimeout } from "./timeout-BVw8aaM1.js";
|
|
11
|
-
import "./
|
|
12
|
+
import { n as codexCatalogHomeId } from "./session-catalog-home-id-CwhLdC03.js";
|
|
13
|
+
import { n as readCodexSessionMeta } from "./session-catalog-provenance-D-dIfRAH.js";
|
|
14
|
+
import "./config-oIORaQ5T.js";
|
|
12
15
|
import { r as sanitizeInlineImageDataUrl, t as invalidInlineImageText } from "./image-payload-sanitizer-tupAr-2o.js";
|
|
13
|
-
import { t as assertCodexSessionRuntimeOwnership } from "./binding-connection-
|
|
16
|
+
import { t as assertCodexSessionRuntimeOwnership } from "./binding-connection-D3udKbIE.js";
|
|
14
17
|
import { n as normalizeCodexAppServerBindingModelProvider, t as isCodexAppServerNativeAuthProfile } from "./auth-profile-CwzO4_RG.js";
|
|
15
|
-
import { C as CodexThreadBindingConflictError,
|
|
16
|
-
import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, l as retireUnsafeCodexTurnClientBestEffort, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, r as CodexAppServerUnsafeSubscriptionError, s as isCodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import "./transcript-mirror-t5TOccct.js";
|
|
18
|
+
import { C as CodexThreadBindingConflictError, D as bindCodexInferenceThread, E as assertCodexInferenceRouteConfig, H as isCodexAppServerClientRuntimeLive, K as readCodexClientSessionMeta, R as consumeCodexAppServerLiveThread, S as CodexAdoptedThreadActiveError, U as isCodexAppServerLiveThreadClaimed, Y as unsubscribeCodexAppServerLiveThread, _ as retainSharedCodexAppServerClientByInstanceId, k as prepareCodexInferenceThreadConfig, n as captureCodexAppServerClientLifetime, q as releaseCodexAppServerLiveThread, w as CodexThreadStartRequestError } from "./shared-client-CscigXXL.js";
|
|
19
|
+
import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, l as retireUnsafeCodexTurnClientBestEffort, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, r as CodexAppServerUnsafeSubscriptionError, s as isCodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-DKHzbwt5.js";
|
|
20
|
+
import { t as ensureCodexPluginActivation } from "./plugin-activation-BYQculil.js";
|
|
21
|
+
import { o as resolveCodexSessionBinding, r as hashCodexAppServerBindingFingerprint } from "./session-binding-CI8UuilT.js";
|
|
22
|
+
import { i as refreshCodexThreadPolicy, n as CodexThreadPolicyHandoffError, r as assertCodexSupervisionThreadLineage, t as CodexIncognitoPolicyChangeError } from "./thread-policy-BuEQfE0g.js";
|
|
23
|
+
import { t as resumeCodexAppServerThread } from "./thread-resume-DsDOZpFg.js";
|
|
24
|
+
import { r as retainCodexAppServerBindingSubscription, s as withExclusiveCodexAppServerThread } from "./thread-ownership-BsDRTsyp.js";
|
|
25
|
+
import "./transcript-mirror-C5CKgNy6.js";
|
|
24
26
|
import { asOptionalRecord, isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
25
27
|
import * as crypto$1 from "node:crypto";
|
|
26
28
|
import crypto, { createHash } from "node:crypto";
|
|
@@ -34,9 +36,9 @@ import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-util
|
|
|
34
36
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
35
37
|
import { createStageTimingTracker, formatStageTimings } from "openclaw/plugin-sdk/time-runtime";
|
|
36
38
|
import { isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
|
|
37
|
-
import { isDeepStrictEqual } from "node:util";
|
|
38
39
|
import { resolveAgentDir as resolveAgentDir$1 } from "openclaw/plugin-sdk/agent-runtime";
|
|
39
40
|
import { AgentHarnessPreflightError, SKILL_WORKSHOP_TOOL_NAME, buildCredentialSafetyPrompt, buildDelegationGuidanceSection, buildHarnessVisibleReplyGuidance, buildSkillWorkshopPromptSection, buildTemporalContextText, buildUiPresentationPrompt, embeddedAgentLog, formatErrorMessage, isActiveHarnessContextEngine, isHostScopedAgentToolActive, isOpenClawRuntimeContextCustomMessage, resolveMainSessionDelegationMode } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
41
|
+
import { isDeepStrictEqual } from "node:util";
|
|
40
42
|
import { emitTrustedDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
41
43
|
import { redactSensitiveFieldValue, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
42
44
|
import { IMAGE_BLOCK_TOKENS } from "openclaw/plugin-sdk/agent-core";
|
|
@@ -1952,6 +1954,23 @@ function isCodexAppServerProfilerEnabled(config, env = process.env) {
|
|
|
1952
1954
|
return PROFILER_FLAGS.some((flag) => isDiagnosticFlagEnabled(flag, config, env));
|
|
1953
1955
|
}
|
|
1954
1956
|
//#endregion
|
|
1957
|
+
//#region extensions/codex/src/app-server/project-doc-thread-config.ts
|
|
1958
|
+
const CODEX_NATIVE_PROJECT_DOC_MAX_BYTES = 131072;
|
|
1959
|
+
function buildCodexProjectDocThreadConfig(config, effectiveNativeConfig) {
|
|
1960
|
+
const defaults = { project_doc_max_bytes: resolveCodexNativeProjectDocMaxBytes(effectiveNativeConfig) ?? CODEX_NATIVE_PROJECT_DOC_MAX_BYTES };
|
|
1961
|
+
return mergeCodexThreadConfigs(defaults, config) ?? defaults;
|
|
1962
|
+
}
|
|
1963
|
+
function resolveCodexNativeProjectDocMaxBytes(effectiveNativeConfig) {
|
|
1964
|
+
if (effectiveNativeConfig?.origins?.project_doc_max_bytes === void 0) return;
|
|
1965
|
+
const authoredMaxBytes = effectiveNativeConfig.config.project_doc_max_bytes;
|
|
1966
|
+
if (typeof authoredMaxBytes !== "number" || !Number.isSafeInteger(authoredMaxBytes) || authoredMaxBytes < 0) throw new Error("Codex config/read returned an invalid project_doc_max_bytes value");
|
|
1967
|
+
return authoredMaxBytes;
|
|
1968
|
+
}
|
|
1969
|
+
function mergeCodexNativeProjectDocThreadConfig(config, effectiveNativeConfig) {
|
|
1970
|
+
const authoredMaxBytes = resolveCodexNativeProjectDocMaxBytes(effectiveNativeConfig);
|
|
1971
|
+
return authoredMaxBytes === void 0 ? config : mergeCodexThreadConfigs({ project_doc_max_bytes: authoredMaxBytes }, config);
|
|
1972
|
+
}
|
|
1973
|
+
//#endregion
|
|
1955
1974
|
//#region extensions/codex/src/app-server/mcp-tool-metadata.ts
|
|
1956
1975
|
/** Hosted app ownership is authoritative only on metadata supplied by Codex. */
|
|
1957
1976
|
function readCodexMcpToolConnectorId(tool) {
|
|
@@ -1966,13 +1985,6 @@ function readCodexMcpToolUiVisibility(tool) {
|
|
|
1966
1985
|
return [...new Set(visibility.filter((value) => value === "app" || value === "model"))].toSorted();
|
|
1967
1986
|
}
|
|
1968
1987
|
//#endregion
|
|
1969
|
-
//#region extensions/codex/src/app-server/project-doc-thread-config.ts
|
|
1970
|
-
const CODEX_NATIVE_PROJECT_DOC_MAX_BYTES = 131072;
|
|
1971
|
-
function buildCodexProjectDocThreadConfig(config) {
|
|
1972
|
-
const defaults = { project_doc_max_bytes: CODEX_NATIVE_PROJECT_DOC_MAX_BYTES };
|
|
1973
|
-
return mergeCodexThreadConfigs(defaults, config) ?? defaults;
|
|
1974
|
-
}
|
|
1975
|
-
//#endregion
|
|
1976
1988
|
//#region extensions/codex/src/app-server/thread-model-selection.ts
|
|
1977
1989
|
const CODEX_NATIVE_PERSONALITY_NONE = "none";
|
|
1978
1990
|
function resolveCodexBindingModelProviderFallback(params) {
|
|
@@ -2044,15 +2056,16 @@ function resolveCodexAppServerModelProvider(params) {
|
|
|
2044
2056
|
//#region extensions/codex/src/app-server/thread-prompt.ts
|
|
2045
2057
|
function buildDeveloperInstructions(params, options = {}) {
|
|
2046
2058
|
const deferredToolNames = /* @__PURE__ */ new Set();
|
|
2047
|
-
let secretsToolName;
|
|
2048
2059
|
let showWidgetToolName;
|
|
2049
2060
|
let dashboardToolName;
|
|
2050
2061
|
let portalToolName;
|
|
2062
|
+
let messageTool;
|
|
2051
2063
|
let hasSkillWorkshop = false;
|
|
2052
2064
|
let hasSessionsSpawn = false;
|
|
2053
2065
|
let hasSessionsYield = false;
|
|
2054
2066
|
let hasSubagentsList = false;
|
|
2055
2067
|
let hasSessionsSend = false;
|
|
2068
|
+
let hasControlTools = false;
|
|
2056
2069
|
let hasSeenDirectNamespace = false;
|
|
2057
2070
|
for (const spec of options.dynamicTools ?? []) {
|
|
2058
2071
|
const isDirectNamespace = spec.type === "namespace" && !hasSeenDirectNamespace && spec.name.trim() === "openclaw_direct";
|
|
@@ -2061,15 +2074,19 @@ function buildDeveloperInstructions(params, options = {}) {
|
|
|
2061
2074
|
const name = tool.name.trim();
|
|
2062
2075
|
const qualifiedName = spec.type === "namespace" ? `${spec.name}.${name}` : name;
|
|
2063
2076
|
if (tool.deferLoading === true && name) deferredToolNames.add(name);
|
|
2064
|
-
if (name === "secrets" && params.disableTools !== true) secretsToolName ??= qualifiedName;
|
|
2065
2077
|
if (name === "show_widget") showWidgetToolName ??= qualifiedName;
|
|
2066
2078
|
if (name === "dashboard") dashboardToolName ??= qualifiedName;
|
|
2067
2079
|
if (name === "portal") portalToolName ??= qualifiedName;
|
|
2080
|
+
if (name === "message") messageTool ??= {
|
|
2081
|
+
name: qualifiedName,
|
|
2082
|
+
parameters: tool.inputSchema
|
|
2083
|
+
};
|
|
2068
2084
|
hasSkillWorkshop ||= name === SKILL_WORKSHOP_TOOL_NAME;
|
|
2069
2085
|
hasSessionsSpawn ||= name === "sessions_spawn";
|
|
2070
2086
|
hasSessionsYield ||= isDirectNamespace && name === "sessions_yield";
|
|
2071
2087
|
hasSubagentsList ||= name === "subagents";
|
|
2072
2088
|
hasSessionsSend ||= name === "sessions_send";
|
|
2089
|
+
hasControlTools ||= name === "openclaw" || name === "gateway";
|
|
2073
2090
|
}
|
|
2074
2091
|
}
|
|
2075
2092
|
const nativeCommandGuidance = listRegisteredPluginAgentPromptGuidance({
|
|
@@ -2102,10 +2119,12 @@ function buildDeveloperInstructions(params, options = {}) {
|
|
|
2102
2119
|
params.disableTools !== true && params.promptMode !== "minimal" && params.promptMode !== "none" ? buildUiPresentationPrompt({
|
|
2103
2120
|
showWidgetToolName,
|
|
2104
2121
|
dashboardToolName,
|
|
2105
|
-
portalToolName
|
|
2122
|
+
portalToolName,
|
|
2123
|
+
messageTool
|
|
2106
2124
|
}) : void 0,
|
|
2107
|
-
buildCredentialSafetyPrompt(
|
|
2125
|
+
buildCredentialSafetyPrompt({ controlToolsAvailable: params.disableTools !== true && hasControlTools }),
|
|
2108
2126
|
nativeCommandGuidance,
|
|
2127
|
+
params.gitCoauthorPrompt,
|
|
2109
2128
|
params.extraSystemPrompt
|
|
2110
2129
|
].filter((section) => typeof section === "string" && section.trim()).join("\n\n");
|
|
2111
2130
|
}
|
|
@@ -2445,7 +2464,7 @@ function buildRestrictedToolConfigPatch(inheritedMcpServerNames, scheduledAppAut
|
|
|
2445
2464
|
};
|
|
2446
2465
|
}
|
|
2447
2466
|
async function readCodexInheritedMcpServerNames(client, cwd, signal, effectiveConfig) {
|
|
2448
|
-
const response = effectiveConfig ?? await readCodexEffectiveConfig(client, cwd, signal);
|
|
2467
|
+
const response = effectiveConfig ?? await readCodexEffectiveConfig(client, cwd, { signal });
|
|
2449
2468
|
if (!Array.isArray(response.layers)) throw new Error("Codex config/read omitted effective config layers");
|
|
2450
2469
|
for (const layer of response.layers) {
|
|
2451
2470
|
if (!isJsonObject(layer) || !isJsonObject(layer.name) || typeof layer.name.type !== "string") throw new Error("Codex config/read returned invalid effective config layers");
|
|
@@ -3004,7 +3023,8 @@ async function prepareCodexThreadLifecyclePreflight(params) {
|
|
|
3004
3023
|
const allowConfiguredManagedHooks = params.params.pluginHarnessToolPolicyRestricted === true && !ringZeroActive && !messageOnlySourceReply && params.params.scheduledRuntimeAuthority === void 0;
|
|
3005
3024
|
const imageGenerationDenied = params.params.pluginHarnessToolPolicySafeDeniedTools?.includes("image_generate") === true;
|
|
3006
3025
|
if (restrictedToolSurface && params.nativeCodeModeEnabled !== false) throw new Error("Codex restricted tool surfaces require native code mode to be disabled");
|
|
3007
|
-
if (
|
|
3026
|
+
if (!effectiveConfig) effectiveConfig = await lifecycleTiming.measure("effective-config-read", () => readCodexEffectiveConfig(params.client, params.cwd, { signal: params.signal }));
|
|
3027
|
+
params.config = mergeCodexNativeProjectDocThreadConfig(params.config, effectiveConfig);
|
|
3008
3028
|
const restrictedToolSurfaceInheritedMcpServerNames = restrictedToolSurface ? await lifecycleTiming.measure("restricted-tool-surface-mcp-policy", () => readCodexInheritedMcpServerNames(params.client, params.cwd, params.signal, effectiveConfig)) : [];
|
|
3009
3029
|
if (restrictedToolSurface || imageGenerationDenied || params.nativeCodeModeEnabled !== false) await lifecycleTiming.measure("tool-policy-config-requirements-read", () => assertCodexManagedRequirementsDoNotOverrideToolPolicy(params.client, {
|
|
3010
3030
|
restrictedToolSurface,
|
|
@@ -3020,7 +3040,9 @@ async function prepareCodexThreadLifecyclePreflight(params) {
|
|
|
3020
3040
|
baseInstructions: "",
|
|
3021
3041
|
config: buildCodexRingZeroThreadConfigPatch(params.params, true, restrictedToolSurfaceInheritedMcpServerNames)
|
|
3022
3042
|
}) : void 0;
|
|
3043
|
+
const ringZeroClientInstanceId = ringZeroActive ? getCodexAppServerClientInstanceId(params.client) : void 0;
|
|
3023
3044
|
return {
|
|
3045
|
+
effectiveConfig,
|
|
3024
3046
|
contextEngineBinding,
|
|
3025
3047
|
dynamicToolsContainDeferred,
|
|
3026
3048
|
dynamicToolsFingerprint,
|
|
@@ -3033,7 +3055,7 @@ async function prepareCodexThreadLifecyclePreflight(params) {
|
|
|
3033
3055
|
nativeSkillIsolationFingerprint,
|
|
3034
3056
|
networkProxyConfigFingerprint,
|
|
3035
3057
|
ringZeroActive,
|
|
3036
|
-
ringZeroClientInstanceId
|
|
3058
|
+
ringZeroClientInstanceId,
|
|
3037
3059
|
ringZeroConfigFingerprint,
|
|
3038
3060
|
restrictedToolSurface,
|
|
3039
3061
|
restrictedToolSurfaceInheritedMcpServerNames,
|
|
@@ -3101,7 +3123,11 @@ async function resumeExistingCodexThread(params, context) {
|
|
|
3101
3123
|
abandonClient,
|
|
3102
3124
|
request: resumeParams,
|
|
3103
3125
|
signal: params.signal,
|
|
3104
|
-
assertCurrent:
|
|
3126
|
+
assertCurrent: () => {
|
|
3127
|
+
configuration.assertCurrent();
|
|
3128
|
+
assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, resumeParams.config);
|
|
3129
|
+
if (params.inferenceRoute && resumeParams.modelProvider != null && resumeParams.modelProvider !== "openai") throw new Error("Codex inference route requires the native OpenAI provider");
|
|
3130
|
+
}
|
|
3105
3131
|
}));
|
|
3106
3132
|
acceptedConfiguration = configuration;
|
|
3107
3133
|
assertCodexThreadAcceptsDirectInput(response.thread);
|
|
@@ -3264,12 +3290,17 @@ async function startFreshCodexThread(params, context) {
|
|
|
3264
3290
|
params.params.hostCapabilities.assertActive();
|
|
3265
3291
|
params.assertCurrent?.();
|
|
3266
3292
|
};
|
|
3293
|
+
const assertInferenceCurrent = () => {
|
|
3294
|
+
assertCurrent();
|
|
3295
|
+
assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, startParams.config);
|
|
3296
|
+
if (params.inferenceRoute && startParams.modelProvider != null && startParams.modelProvider !== "openai") throw new Error("Codex inference route requires the native OpenAI provider");
|
|
3297
|
+
};
|
|
3267
3298
|
const threadStartResponse = await lifecycleTiming.measure("thread-start-request", async () => {
|
|
3268
3299
|
try {
|
|
3269
3300
|
assertCurrent();
|
|
3270
3301
|
return await params.client.request("thread/start", startParams, {
|
|
3271
3302
|
signal: params.signal,
|
|
3272
|
-
assertCurrent
|
|
3303
|
+
assertCurrent: assertInferenceCurrent
|
|
3273
3304
|
});
|
|
3274
3305
|
} catch (error) {
|
|
3275
3306
|
if (error instanceof CodexAppServerRpcError) throw new CodexThreadStartRequestError(error);
|
|
@@ -4174,6 +4205,23 @@ async function startOrResumeThread(input) {
|
|
|
4174
4205
|
if (!isDeepStrictEqual(params.dynamicTools, nativeCatalog)) throw new Error("Canonical Codex declarations changed after tool preparation; retry the turn on its preserved native thread.");
|
|
4175
4206
|
}
|
|
4176
4207
|
const preflight = await prepareCodexThreadLifecyclePreflight(params);
|
|
4208
|
+
const inference = await prepareCodexInferenceThreadConfig({
|
|
4209
|
+
...params,
|
|
4210
|
+
binding: saved,
|
|
4211
|
+
clientId,
|
|
4212
|
+
effectiveConfig: preflight.effectiveConfig,
|
|
4213
|
+
assertCurrent: assert
|
|
4214
|
+
});
|
|
4215
|
+
if (inference) {
|
|
4216
|
+
params.config = inference.config;
|
|
4217
|
+
params.inferenceRoute = inference.route;
|
|
4218
|
+
}
|
|
4219
|
+
const publishInferenceBinding = (readyBinding) => {
|
|
4220
|
+
assert();
|
|
4221
|
+
params.signal?.throwIfAborted();
|
|
4222
|
+
bindCodexInferenceThread(params.client, readyBinding.threadId, inference?.route);
|
|
4223
|
+
return readyBinding;
|
|
4224
|
+
};
|
|
4177
4225
|
const { contextEngineBinding, dynamicToolsContainDeferred, dynamicToolsFingerprint, environmentSelectionFingerprint, hostSystemAgentActive, legacyDynamicToolsFingerprint, legacyUserMcpServersFingerprint, lifecycleTiming, nativeSkillIsolation, nativeSkillIsolationFingerprint, networkProxyConfigFingerprint, ringZeroActive, ringZeroClientInstanceId, ringZeroConfigFingerprint, restrictedToolSurface, restrictedToolSurfaceInheritedMcpServerNames, userMcpServersConfigPatch, userMcpServersFingerprint, webSearchThreadConfigFingerprint } = preflight;
|
|
4178
4226
|
let replacementPredecessor;
|
|
4179
4227
|
const initialBoundThreadId = binding?.threadId;
|
|
@@ -4293,13 +4341,13 @@ async function startOrResumeThread(input) {
|
|
|
4293
4341
|
const persistentWebSearchRestriction = params.webSearchAllowed === false && params.persistentWebSearchAllowed === false;
|
|
4294
4342
|
const transientNativeToolRestriction = params.nativeCodeModeEnabled === false && !persistentWebSearchRestriction;
|
|
4295
4343
|
const transientWebSearchRestriction = isTransientWebSearchRestriction(params);
|
|
4296
|
-
if (binding?.pendingResumeConfiguration) return await resumePendingCodexThread(params, {
|
|
4344
|
+
if (binding?.pendingResumeConfiguration) return publishInferenceBinding(await resumePendingCodexThread(params, {
|
|
4297
4345
|
...resolveRequestContext(),
|
|
4298
4346
|
binding,
|
|
4299
4347
|
clearCurrentBinding,
|
|
4300
4348
|
releaseRetainedThread: (threadId, assertCurrent) => releaseRetainedThread(threadId, initialBoundClientId, assertCurrent),
|
|
4301
4349
|
transientRestriction: transientDelegationRestriction || transientNativeToolRestriction || transientWebSearchRestriction
|
|
4302
|
-
});
|
|
4350
|
+
}));
|
|
4303
4351
|
if (binding?.threadId && !restrictedToolSurface && binding.nativeToolPolicyRestricted === true) await clearCurrentBinding("rotating a host-policy-restricted thread binding");
|
|
4304
4352
|
if (binding?.threadId && binding.nativeSkillIsolationFingerprint !== nativeSkillIsolationFingerprint) {
|
|
4305
4353
|
embeddedAgentLog.debug("codex app-server native skill isolation changed; starting a new thread", { threadId: binding.threadId });
|
|
@@ -4473,7 +4521,7 @@ async function startOrResumeThread(input) {
|
|
|
4473
4521
|
clientId,
|
|
4474
4522
|
buildLoadedPluginThreadConfig
|
|
4475
4523
|
});
|
|
4476
|
-
if (warmReuse.kind === "ready") return warmReuse.binding;
|
|
4524
|
+
if (warmReuse.kind === "ready") return publishInferenceBinding(warmReuse.binding);
|
|
4477
4525
|
if (incognito || warmReuse.kind === "rotate") {
|
|
4478
4526
|
throwIfAborted();
|
|
4479
4527
|
await clearCurrentBinding(incognito ? "rotating an unavailable ephemeral thread binding" : "rotating a stale plugin app binding");
|
|
@@ -4491,7 +4539,7 @@ async function startOrResumeThread(input) {
|
|
|
4491
4539
|
await releaseRetainedThread(resumeBinding.threadId, resumeBinding.clientId, assertCurrent);
|
|
4492
4540
|
}
|
|
4493
4541
|
});
|
|
4494
|
-
if (resumed) return resumed;
|
|
4542
|
+
if (resumed) return publishInferenceBinding(resumed);
|
|
4495
4543
|
}
|
|
4496
4544
|
}
|
|
4497
4545
|
}
|
|
@@ -4505,7 +4553,7 @@ async function startOrResumeThread(input) {
|
|
|
4505
4553
|
replacementPredecessor
|
|
4506
4554
|
});
|
|
4507
4555
|
if (replacementPredecessor) await releaseRetainedThread(replacementPredecessor.threadId, replacementPredecessor.clientId);
|
|
4508
|
-
return started;
|
|
4556
|
+
return publishInferenceBinding(started);
|
|
4509
4557
|
});
|
|
4510
4558
|
}
|
|
4511
4559
|
//#endregion
|
|
@@ -4615,6 +4663,7 @@ function buildTurnStartParams(params, options) {
|
|
|
4615
4663
|
skillsCollaborationInstructions: options.skillsCollaborationInstructions,
|
|
4616
4664
|
memoryCollaborationInstructions: options.memoryCollaborationInstructions
|
|
4617
4665
|
}) : void 0;
|
|
4666
|
+
if (collaborationMode && options.parentLocalEgress) collaborationMode.settings.developer_instructions = null;
|
|
4618
4667
|
const useThreadPermissionProfile = options.appServer.networkProxy && !options.sandboxPolicy;
|
|
4619
4668
|
const currentSenderContext = params.trigger === "user" ? buildCodexCurrentSenderContextValue(params) : void 0;
|
|
4620
4669
|
let additionalContext = buildCodexTemporalAdditionalContext(params, { sessionStatusAvailable: options.sessionStatusAvailable === true });
|
|
@@ -4688,11 +4737,14 @@ function buildTurnCollaborationMode(params, options = {}) {
|
|
|
4688
4737
|
}
|
|
4689
4738
|
};
|
|
4690
4739
|
}
|
|
4691
|
-
function
|
|
4740
|
+
function buildCodexParentLocalInstructions(params, options = {}) {
|
|
4692
4741
|
const contextInstructions = joinPresentSections(options.turnScopedDeveloperInstructions, options.memoryCollaborationInstructions, options.skillsCollaborationInstructions);
|
|
4693
4742
|
if (params.trigger === "cron") return joinPresentSections(buildCronCollaborationInstructions(), contextInstructions);
|
|
4694
|
-
|
|
4695
|
-
|
|
4743
|
+
return contextInstructions || null;
|
|
4744
|
+
}
|
|
4745
|
+
function buildTurnScopedCollaborationInstructions(params, options) {
|
|
4746
|
+
const instructions = buildCodexParentLocalInstructions(params, options);
|
|
4747
|
+
return instructions && params.trigger !== "cron" ? joinPresentSections(buildDefaultCollaborationInstructions(), instructions) : instructions;
|
|
4696
4748
|
}
|
|
4697
4749
|
function buildDefaultCollaborationInstructions() {
|
|
4698
4750
|
return [
|
|
@@ -4721,4 +4773,4 @@ function joinPresentSections(...sections) {
|
|
|
4721
4773
|
return sections.filter((section) => Boolean(section?.trim())).join("\n\n");
|
|
4722
4774
|
}
|
|
4723
4775
|
//#endregion
|
|
4724
|
-
export {
|
|
4776
|
+
export { codexDynamicToolsFingerprint as $, readCodexMcpToolConnectorId as A, createCodexNativeHookRelay as B, resolveCodexWebSearchPlan as C, buildCodexPluginThreadConfigInputFingerprint as Ct, resolveCodexAppServerRequestModelSelection as D, refreshCodexPluginAppApprovalPolicy as Dt, resolveCodexAppServerModelProvider as E, mergeCodexThreadConfigs as Et, CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS as F, checkCodexThreadAppAvailability as G, resolveCodexNativeHookRelayEvents as H, assertCodexNativeHookRelayAllowed as I, loadCodexNativeToolCatalog as J, attestCodexRestrictedToolSurfaceMcpServersDisabled as K, buildCodexNativeHookRelayConfig as L, buildCodexProjectDocThreadConfig as M, isCodexAppServerProfilerEnabled as N, resolveCodexAppServerThreadModelSelection as O, shouldBuildCodexPluginThreadConfig as Ot, CODEX_NATIVE_HOOK_RELAY_EVENTS as P, areCodexDynamicToolFingerprintsCompatible as Q, buildCodexNativeHookRelayDisabledConfig as R, buildCodexNativeWebSearchThreadConfig as S, buildCodexPluginThreadConfig as St, CODEX_NATIVE_PERSONALITY_NONE as T, buildDisabledAppsConfigPatch as Tt, resolveCodexNativeHookRelayTtlMs as U, emitCodexNativePreToolUseFailureDiagnostic as V, scheduleCodexNativeHookRelayUnregister as W, applyCodexNativeSkillIsolation as X, parseCodexNativeToolCatalog as Y, resolveCodexNativeSkillIsolation as Z, assertCodexManagedRequirementsDoNotOverrideToolPolicy as _, neutralizeCodexExplicitMentionSigils as _t, buildCodexUserInput as a, isForcedPrivateQaCodexRuntime as at, buildCodexThreadConfiguration as b, resolveCodexContextEngineProjectionReserveTokens as bt, startOrResumeThread as c, normalizeCodexDynamicToolName as ct, buildScheduledCodexAppAuthorityInputFingerprint as d, buildContextEngineBinding as dt, codexLegacyDynamicToolsFingerprint as et, buildScheduledCodexAppServerConnectionIdentity as f, isContextEngineBindingCompatible as ft, resolveScheduledCodexAppCreatorCaptureDecision as g, isCodexDurableCustomMessage as gt, readCurrentCodexScheduledAppPolicy as h, fitCodexProjectedContextForTurnStart as ht, buildTurnStartParams as i, filterCodexDynamicToolsForDisabledNativeSurface as it, readCodexMcpToolUiVisibility as j, resolveCodexBindingModelProviderFallback as k, assertScheduledCodexAppAuthorityRuntime as l, resolveCodexDynamicToolsLoading as lt, intersectCodexPluginThreadConfigWithScheduledAuthority as m, buildCodexContinuityCalibration as mt, buildCodexTemporalAdditionalContext as n, fingerprintUserMcpServersConfigPatch as nt, readCodexSupportedReasoningEfforts as o, isMessageOnlyCodexSourceReply as ot, captureScheduledCodexAppAuthority as p, CodexContextAttachmentError as pt, hasCodexNativeToolCatalog as q, buildTurnCollaborationMode as r, filterCodexDynamicTools as rt, resolveCodexAppServerReasoningEffort as s, isSystemAgentOnlyCodexDynamicToolAllowlist as st, buildCodexParentLocalInstructions as t, fingerprintJsonObject as tt, buildLegacyScheduledCodexAppRecoveryPrompt as u, resolveCodexDynamicToolsLoadingForRuntime as ut, buildCodexRingZeroThreadConfigPatch as v, projectContextEngineAssemblyForCodex as vt, buildDeveloperInstructions as w, buildCodexPluginThreadConfigTimeoutFallback as wt, readCodexInheritedMcpServerNames as x, resolveCodexContinuityProjectionMaxChars as xt, buildCodexRuntimeThreadConfig as y, resolveCodexContextEngineProjectionMaxChars as yt, buildCodexNativeHookRelayId as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
2
|
import { n as withCodexAppServerThreadMutation } from "./incognito-session-uhrBF6wJ.js";
|
|
3
|
-
import {
|
|
4
|
-
import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-
|
|
3
|
+
import { J as retainCodexAppServerLiveThread, U as isCodexAppServerLiveThreadClaimed, _ as retainSharedCodexAppServerClientByInstanceId, q as releaseCodexAppServerLiveThread } from "./shared-client-CscigXXL.js";
|
|
4
|
+
import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-DKHzbwt5.js";
|
|
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-B57KWPQx.js";
|
|
2
|
+
import { r as requestCodexAppServerClientJson, t as CodexAppServerScopedRequestRejectedError } from "./request-B7hEkBGq.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. */
|
|
@@ -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,8 @@
|
|
|
1
|
-
import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError, y as assertCodexThreadResumeResponse } from "./client-
|
|
2
|
-
import {
|
|
3
|
-
import { t as CodexAppServerScopedRequestRejectedError } from "./request-
|
|
4
|
-
import {
|
|
5
|
-
import { d as unsubscribeCodexThreadBestEffort, i as assertCodexThreadResumeSubscription, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-
|
|
1
|
+
import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError, y as assertCodexThreadResumeResponse } from "./client-B57KWPQx.js";
|
|
2
|
+
import { t as CodexAppServerRpcError } from "./rpc-error-ttN_QjEm.js";
|
|
3
|
+
import { t as CodexAppServerScopedRequestRejectedError } from "./request-B7hEkBGq.js";
|
|
4
|
+
import { B as forgetCodexWorkspaceReferences, N as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CscigXXL.js";
|
|
5
|
+
import { d as unsubscribeCodexThreadBestEffort, i as assertCodexThreadResumeSubscription, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-DKHzbwt5.js";
|
|
6
6
|
//#region extensions/codex/src/app-server/thread-resume.ts
|
|
7
7
|
/** Owns Codex thread/resume subscription safety. */
|
|
8
8
|
/** Resumes one thread, releasing or isolating every possible native subscription. */
|
package/dist/{session-catalog-home-id-D7-aLiNt.js → transcript-history-projection-v17wXgdK.js}
RENAMED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { c as itemName, l as itemStatus, t as auditNativeToolName } from "./event-projector-items-5VhsECCO.js";
|
|
1
2
|
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
|
|
2
3
|
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
4
|
import { truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
7
5
|
import { Buffer } from "node:buffer";
|
|
8
6
|
//#region extensions/codex/src/app-server/transcript-history-projection.ts
|
|
@@ -72,7 +70,7 @@ function projectCodexThreadHistory(params) {
|
|
|
72
70
|
const projected = [];
|
|
73
71
|
const threadTimestamp = typeof params.thread.createdAt === "number" && Number.isFinite(params.thread.createdAt) ? params.thread.createdAt * 1e3 : params.importedAt;
|
|
74
72
|
let itemOffset = 0;
|
|
75
|
-
for (const turn of
|
|
73
|
+
for (const turn of params.turns) for (const value of turn.items) {
|
|
76
74
|
const item = value;
|
|
77
75
|
const itemId = normalizeOptionalString(item.id);
|
|
78
76
|
const identity = `${turn.id}:${itemId ?? itemOffset}`;
|
|
@@ -136,7 +134,7 @@ function selectBoundedCodexHistoryTail(projected) {
|
|
|
136
134
|
function projectBoundedCodexThreadHistory(params) {
|
|
137
135
|
const projected = projectCodexThreadHistory({
|
|
138
136
|
thread: params.thread,
|
|
139
|
-
|
|
137
|
+
turns: selectTurnsThroughBoundary(params.thread, params.throughTurnId),
|
|
140
138
|
importedAt: params.importedAt,
|
|
141
139
|
...params.modelProvider ? { modelProvider: params.modelProvider } : {}
|
|
142
140
|
});
|
|
@@ -172,19 +170,69 @@ function projectBoundedCodexVisibleSessionHistory(entries) {
|
|
|
172
170
|
}
|
|
173
171
|
return selectBoundedCodexHistoryTail(projected).map(({ responseItem }) => responseItem);
|
|
174
172
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
173
|
+
/** Displays native items through the shared transcript roles, including an unfinished turn. */
|
|
174
|
+
function projectCodexThreadHistoryItem(thread, entry, toolItems) {
|
|
175
|
+
const { item } = entry;
|
|
176
|
+
const timestamp = (entry.turn?.startedAt ?? thread.createdAt ?? 0) * 1e3;
|
|
177
|
+
if (item.type === "userMessage" || item.type === "agentMessage") return projectCodexThreadHistory({
|
|
178
|
+
thread,
|
|
179
|
+
turns: [{
|
|
180
|
+
...entry.turn,
|
|
181
|
+
id: entry.turnId,
|
|
182
|
+
items: [item]
|
|
183
|
+
}],
|
|
184
|
+
importedAt: timestamp
|
|
185
|
+
}).map(({ message }) => message);
|
|
186
|
+
const identity = `${entry.turnId}:${item.id}`;
|
|
187
|
+
const assistant = (content, toolUse = false) => attachCodexMirrorIdentity({
|
|
188
|
+
role: "assistant",
|
|
189
|
+
content,
|
|
190
|
+
api: CODEX_HISTORY_ASSISTANT_API,
|
|
191
|
+
provider: normalizeOptionalString(thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER,
|
|
192
|
+
model: CODEX_HISTORY_ASSISTANT_MODEL,
|
|
193
|
+
usage: CODEX_HISTORY_ZERO_USAGE,
|
|
194
|
+
stopReason: toolUse ? "toolUse" : "stop",
|
|
195
|
+
timestamp
|
|
196
|
+
}, identity);
|
|
197
|
+
if (item.type === "reasoning") {
|
|
198
|
+
const parts = Array.isArray(item.summary) && item.summary.length > 0 ? item.summary : item.content;
|
|
199
|
+
const thinking = normalizeImportedHistoryText(Array.isArray(parts) ? parts.filter((part) => typeof part === "string").join("\n") : item.text);
|
|
200
|
+
return thinking ? [assistant([{
|
|
201
|
+
type: "thinking",
|
|
202
|
+
thinking
|
|
203
|
+
}])] : [];
|
|
183
204
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
205
|
+
if (item.type === "contextCompaction") return [assistant([{
|
|
206
|
+
type: "text",
|
|
207
|
+
text: "Context compacted."
|
|
208
|
+
}])];
|
|
209
|
+
const toolName = itemName(item) ?? auditNativeToolName(item);
|
|
210
|
+
if (!toolName) {
|
|
211
|
+
const text = normalizeImportedHistoryText(item.text ?? item.title);
|
|
212
|
+
return text ? [assistant([{
|
|
213
|
+
type: "text",
|
|
214
|
+
text
|
|
215
|
+
}])] : [];
|
|
216
|
+
}
|
|
217
|
+
const messages = [assistant([{
|
|
218
|
+
type: "toolCall",
|
|
219
|
+
id: item.id,
|
|
220
|
+
name: toolName,
|
|
221
|
+
arguments: toolItems.itemToolArgs(item) ?? {}
|
|
222
|
+
}], true)];
|
|
223
|
+
const status = itemStatus(item);
|
|
224
|
+
if (status !== "running") messages.push(attachCodexMirrorIdentity({
|
|
225
|
+
role: "toolResult",
|
|
226
|
+
toolCallId: item.id,
|
|
227
|
+
toolName,
|
|
228
|
+
content: [{
|
|
229
|
+
type: "text",
|
|
230
|
+
text: toolItems.itemTranscriptResultText(item) ?? status
|
|
231
|
+
}],
|
|
232
|
+
isError: status === "failed" || status === "blocked",
|
|
233
|
+
timestamp
|
|
234
|
+
}, `${identity}:result`));
|
|
235
|
+
return messages;
|
|
188
236
|
}
|
|
189
237
|
//#endregion
|
|
190
|
-
export { projectCodexUserItemText as
|
|
238
|
+
export { projectCodexUserItemText as i, projectBoundedCodexVisibleSessionHistory as n, projectCodexThreadHistoryItem as r, projectBoundedCodexThreadHistory as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
2
|
import { i as readUpstreamUserText, n as attachUpstreamUserText, r as readMirrorIdentity, t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
|
|
3
|
-
import {
|
|
3
|
+
import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-v17wXgdK.js";
|
|
4
4
|
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-DibE0krH.js";
|
|
5
5
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
6
|
import { deliverAgentHarnessUserInputPrompt, embeddedAgentLog, formatErrorMessage, projectAgentHarnessTranscriptMessageForDisplay, restorePreparedUserTurnOperationalMetaForRuntime, runAgentHarnessBeforeMessageWriteHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|