@openclaw/codex 2026.9.1 → 2026.9.2
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 +6 -6
- package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-Bp1ZOnk2.js} +76 -32
- package/dist/{attempt-context-DmQUNWwT.js → attempt-context-CSazkWns.js} +6 -6
- package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-DxGJRYbY.js} +46 -45
- package/dist/{capabilities-dIjNVCYH.js → capabilities-B1mgvpP8.js} +2 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DSbGMXA0.js} +2 -2
- package/dist/{command-handlers-CTGb2csu.js → command-handlers-DOJvGv6-.js} +146 -74
- package/dist/{compact-_t0HQrUS.js → compact-Y_xBqrHN.js} +83 -48
- package/dist/{config-BhmfC1s6.js → config-CyapYSji.js} +47 -105
- package/dist/config-utils-C57JiJrU.js +69 -0
- package/dist/doctor-contract-api.js +4 -5
- package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-BwpvTxaX.js} +678 -638
- package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-CY9Jn4bA.js} +4 -3
- package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-B9kp6iGC.js} +11 -2
- package/dist/{event-projector-usage-C5mcrGjp.js → event-projector-usage-ZqEVbAEY.js} +30 -13
- package/dist/{harness-DXVZ5II5.js → harness-Czh2Sdoc.js} +36 -13
- package/dist/harness.js +1 -1
- package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
- package/dist/index.js +68 -84
- package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-CRh-51AK.js} +9 -21
- package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DcpnJF9x.js} +105 -73
- package/dist/media-understanding-provider.js +1 -1
- package/dist/{model-catalog-CUM68Hkl.js → model-catalog-DT5vo6qo.js} +5 -5
- package/dist/{models-sYnEc0gd.js → models-CcrgSMQR.js} +4 -4
- package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-B3bvQGcg.js} +12 -11
- package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-nfbUOtUB.js} +3 -3
- package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-aQVdyL5g.js} +1 -1
- package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → plugin-marketplace-discovery-B7gHXJ3d.js} +35 -22
- package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-BwCLTY_U.js} +5 -5
- package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-BpG9Ltc5.js} +2 -2
- package/dist/{rate-limits-CawQJfUS.js → rate-limits-Fx_l4eNa.js} +1 -1
- package/dist/{request-DYAI5FQE.js → request-C8H22rPi.js} +2 -2
- package/dist/{run-attempt-D1hJO4fX.js → run-attempt-BzthFQSM.js} +977 -723
- package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-Bh_gf6-t.js} +3 -3
- package/dist/{session-binding-BHuTCRZQ.js → session-binding-4Ki04sW-.js} +94 -282
- package/dist/session-binding-record-CyaXZvTe.js +270 -0
- package/dist/{session-catalog-yyvTWFOw.js → session-catalog-B47uwekb.js} +266 -114
- package/dist/{session-cli-CmFEXMAM.js → session-cli-BjLhpmS1.js} +1 -1
- package/dist/session-history-DWmMqiqW.js +93 -0
- package/dist/session-history-read-LHldwvyh.js +36 -0
- package/dist/session-history-worker-runtime.js +48 -0
- package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-zZVcx0ME.js} +30 -31
- package/dist/session-history.worker.js +2 -0
- package/dist/{session-initialization-BeWzjGiR.js → session-initialization-BCFVnLL4.js} +2 -1
- package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-BaueHmSj.js} +1 -1
- package/dist/{session-retirement-BujDjXVF.js → session-retirement-DNdmYdFc.js} +7 -7
- package/dist/{session-upstream-marker-C351-5Qw.js → session-upstream-marker-DReTpGz6.js} +4 -3
- package/dist/settled-turn-context-BOM3Y1pl.js +45 -0
- package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BI-b1sry.js} +53 -42
- package/dist/{shared-client-DxcfF9KX.js → shared-client-CKhX2kFt.js} +279 -268
- package/dist/{side-question-BTZAII4l.js → side-question-B6DWAw1A.js} +85 -36
- package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-DPK30jad.js} +382 -388
- package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-CbucAmmp.js} +5 -5
- package/dist/thread-policy-CTalhWFy.js +105 -0
- package/dist/{thread-resume-C7pyVKeW.js → thread-resume-BLgqkUc1.js} +7 -7
- package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-_njEB84z.js} +67 -125
- package/dist/transcript-mirror-attestation-Byl34PC-.js +76 -0
- package/dist/{transport-stdio-CyPldczm.js → transport-stdio-CzTngV0j.js} +10 -8
- package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-1fwbNKzQ.js} +85 -165
- package/dist/{usage-Bj-rrzkR.js → usage-i9fv5-4m.js} +3 -3
- package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-DKQn67A7.js} +3 -3
- package/package.json +6 -6
- package/dist/binding-connection-E6uDsPlx.js +0 -45
- package/dist/launch-args-RXQwn8zV.js +0 -90
- package/dist/session-history-C5J1AKzG.js +0 -87
- package/dist/thread-policy-g4KbJPzp.js +0 -54
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { l as sessionBindingIdentity } from "./session-binding-record-CyaXZvTe.js";
|
|
2
|
+
import { B as isJsonObject } from "./config-CyapYSji.js";
|
|
3
|
+
import { Mt as retainCodexAppServerLiveThread, U as isCodexAppServerPrewriteRequestCancellationError, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, q as CodexAppServerRpcError, wt as consumeCodexAppServerLiveThread } from "./shared-client-CKhX2kFt.js";
|
|
4
|
+
import { l as resolveCodexSessionBinding, t as CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS } from "./session-binding-4Ki04sW-.js";
|
|
5
|
+
import { _ as readCodexNotificationTurnId, a as closeCodexStartupClientBestEffort, c as isCodexNoActiveTurnInterruptError, d as unsubscribeCodexThreadBestEffort, g as readCodexNotificationThreadId, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-Bp1ZOnk2.js";
|
|
6
|
+
import { n as readCodexThreadContextSnapshot, u as readCodexNotificationItem } from "./event-projector-usage-ZqEVbAEY.js";
|
|
7
|
+
import { t as resumeCodexAppServerThread } from "./thread-resume-BLgqkUc1.js";
|
|
8
|
+
import { l as isIncognitoSessionKey, o as withCodexAppServerThreadMutation, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-CbucAmmp.js";
|
|
9
|
+
import { r as assertCodexSupervisionThreadLineage, s as resolveCodexBindingAppServerConnection } from "./thread-policy-CTalhWFy.js";
|
|
10
|
+
import { s as resolveCodexNativeExecutionBlock } from "./request-C8H22rPi.js";
|
|
10
11
|
import { t as persistCodexContextCompactionActivity } from "./context-compaction-activity-CMla5FPJ.js";
|
|
11
12
|
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
13
|
+
import { resolveDefaultAgentId } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
12
14
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
13
15
|
import { embeddedAgentLog, resolveCompactionTimeoutMs } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
14
|
-
import { resolveAgentDir as resolveAgentDir$
|
|
15
|
-
import { resolveDefaultAgentId as resolveDefaultAgentId$1 } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
16
|
+
import { resolveAgentDir as resolveAgentDir$2 } from "openclaw/plugin-sdk/agent-runtime";
|
|
16
17
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
18
|
import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
18
19
|
import { createDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
|
|
@@ -77,7 +78,7 @@ function watchCodexNativeCompactionCompletion(params) {
|
|
|
77
78
|
threadId: params.threadId,
|
|
78
79
|
turnId: compactionTurnId
|
|
79
80
|
}, { timeoutMs: Math.max(1, params.interruptGraceMs) }).catch((error) => {
|
|
80
|
-
if (
|
|
81
|
+
if (isCodexNoActiveTurnInterruptError(error)) {
|
|
81
82
|
if (compactionItemCompleted) {
|
|
82
83
|
complete();
|
|
83
84
|
return;
|
|
@@ -292,7 +293,33 @@ async function compactCodexNativeThread(params, options) {
|
|
|
292
293
|
agentId: params.agentId,
|
|
293
294
|
config: params.config
|
|
294
295
|
});
|
|
295
|
-
const
|
|
296
|
+
const abortedResult = (expectedThreadId, currentThreadId = expectedThreadId) => options.allowNonManualNativeRequest ? skippedCodexNativeCompactionResult(params, {
|
|
297
|
+
reason: "codex app-server compaction aborted before native compaction",
|
|
298
|
+
code: "aborted_before_native_compaction",
|
|
299
|
+
request: options.nativeCompactionRequest ?? "after_context_engine",
|
|
300
|
+
...expectedThreadId ? {
|
|
301
|
+
expectedThreadId,
|
|
302
|
+
currentThreadId
|
|
303
|
+
} : {}
|
|
304
|
+
}) : {
|
|
305
|
+
ok: false,
|
|
306
|
+
compacted: false,
|
|
307
|
+
reason: "codex app-server compaction aborted while waiting to start"
|
|
308
|
+
};
|
|
309
|
+
let resolvedBinding;
|
|
310
|
+
try {
|
|
311
|
+
resolvedBinding = await resolveCodexSessionBinding({
|
|
312
|
+
bindingStore: options.bindingStore,
|
|
313
|
+
identity: bindingIdentity,
|
|
314
|
+
config: params.config,
|
|
315
|
+
storePath: params.sessionTarget?.storePath,
|
|
316
|
+
signal: params.abortSignal
|
|
317
|
+
});
|
|
318
|
+
} catch (error) {
|
|
319
|
+
if (!params.abortSignal?.aborted) throw error;
|
|
320
|
+
return abortedResult(options.bindingStore.read(bindingIdentity)?.threadId);
|
|
321
|
+
}
|
|
322
|
+
const { binding: initialBinding, assertCurrent } = resolvedBinding;
|
|
296
323
|
if (!initialBinding?.threadId) return failedCodexThreadBindingCompactionResult(params, {
|
|
297
324
|
reason: "no codex app-server thread binding",
|
|
298
325
|
recovery: "missing_thread_binding"
|
|
@@ -312,13 +339,13 @@ async function compactCodexNativeThread(params, options) {
|
|
|
312
339
|
let connection;
|
|
313
340
|
try {
|
|
314
341
|
const config = params.config ?? {};
|
|
315
|
-
const agentId = params.agentId ?? readAgentIdFromSessionKey(params.sessionKey) ?? resolveDefaultAgentId
|
|
342
|
+
const agentId = params.agentId ?? readAgentIdFromSessionKey(params.sessionKey) ?? resolveDefaultAgentId(config);
|
|
316
343
|
connection = resolveCodexBindingAppServerConnection({
|
|
317
344
|
binding,
|
|
318
345
|
authProfileId: requestedAuthProfileId ?? binding.authProfileId,
|
|
319
346
|
pluginConfig: options.pluginConfig,
|
|
320
347
|
config,
|
|
321
|
-
agentDir: resolveAgentDir$
|
|
348
|
+
agentDir: resolveAgentDir$2(config, agentId)
|
|
322
349
|
});
|
|
323
350
|
} catch (error) {
|
|
324
351
|
return {
|
|
@@ -345,6 +372,7 @@ async function compactCodexNativeThread(params, options) {
|
|
|
345
372
|
};
|
|
346
373
|
try {
|
|
347
374
|
return await runExclusiveCodexNativeCompaction(binding.threadId, params.abortSignal, async () => {
|
|
375
|
+
assertCurrent();
|
|
348
376
|
const client = await clientFactory({
|
|
349
377
|
startOptions: appServer.start,
|
|
350
378
|
...preparedApiKey ? { preparedAuth: {
|
|
@@ -352,7 +380,8 @@ async function compactCodexNativeThread(params, options) {
|
|
|
352
380
|
apiKey: preparedApiKey
|
|
353
381
|
} } : { authProfileId: connection.clientAuthProfileId },
|
|
354
382
|
agentDir: params.agentDir,
|
|
355
|
-
config: params.config
|
|
383
|
+
config: params.config,
|
|
384
|
+
assertCurrent
|
|
356
385
|
});
|
|
357
386
|
let releaseThreadSubscription;
|
|
358
387
|
let retainedThreadOwnership;
|
|
@@ -387,8 +416,8 @@ async function compactCodexNativeThread(params, options) {
|
|
|
387
416
|
if (await options.bindingStore.mutate(bindingIdentity, {
|
|
388
417
|
kind: "clear",
|
|
389
418
|
threadId: binding.threadId
|
|
390
|
-
})) return;
|
|
391
|
-
if (
|
|
419
|
+
}, assertCurrent)) return;
|
|
420
|
+
if (options.bindingStore.read(bindingIdentity)?.threadId !== binding.threadId) return;
|
|
392
421
|
throw new Error("failed to detach unconfirmed codex app-server thread binding");
|
|
393
422
|
}
|
|
394
423
|
});
|
|
@@ -404,6 +433,7 @@ async function compactCodexNativeThread(params, options) {
|
|
|
404
433
|
excludeTurns: true
|
|
405
434
|
},
|
|
406
435
|
timeoutMs: timeoutMs ?? appServer.requestTimeoutMs,
|
|
436
|
+
assertCurrent,
|
|
407
437
|
...params.abortSignal ? { signal: params.abortSignal } : {}
|
|
408
438
|
});
|
|
409
439
|
releaseThreadSubscription = async () => releaseCompactionThread(binding.threadId);
|
|
@@ -413,7 +443,8 @@ async function compactCodexNativeThread(params, options) {
|
|
|
413
443
|
const { thread } = await client.request("thread/read", {
|
|
414
444
|
threadId: binding.threadId,
|
|
415
445
|
includeTurns: false
|
|
416
|
-
});
|
|
446
|
+
}, { assertCurrent });
|
|
447
|
+
assertCurrent();
|
|
417
448
|
retainedThreadOwnership.assertCurrent();
|
|
418
449
|
assertCodexSupervisionThreadLineage(binding, thread);
|
|
419
450
|
}
|
|
@@ -422,7 +453,7 @@ async function compactCodexNativeThread(params, options) {
|
|
|
422
453
|
};
|
|
423
454
|
try {
|
|
424
455
|
const guardedResult = await options.bindingStore.withLease(bindingIdentity, async () => {
|
|
425
|
-
const currentBinding =
|
|
456
|
+
const currentBinding = options.bindingStore.read(bindingIdentity);
|
|
426
457
|
if (params.abortSignal?.aborted) {
|
|
427
458
|
if (!options.allowNonManualNativeRequest) params.abortSignal.throwIfAborted();
|
|
428
459
|
return {
|
|
@@ -436,6 +467,7 @@ async function compactCodexNativeThread(params, options) {
|
|
|
436
467
|
})
|
|
437
468
|
};
|
|
438
469
|
}
|
|
470
|
+
assertCurrent();
|
|
439
471
|
if (!currentBinding || !isSameNativeCompactionBinding(currentBinding, binding)) {
|
|
440
472
|
embeddedAgentLog.warn("codex app-server compaction could not use the thread binding because it changed", {
|
|
441
473
|
sessionId: params.sessionId,
|
|
@@ -466,23 +498,38 @@ async function compactCodexNativeThread(params, options) {
|
|
|
466
498
|
sessionId: params.sessionId,
|
|
467
499
|
bindingStore: options.bindingStore,
|
|
468
500
|
identity: bindingIdentity,
|
|
469
|
-
binding
|
|
501
|
+
binding,
|
|
502
|
+
assertCurrent
|
|
470
503
|
});
|
|
504
|
+
assertCurrent();
|
|
471
505
|
try {
|
|
472
506
|
completionWatch.beginRequest();
|
|
473
|
-
|
|
474
|
-
|
|
507
|
+
await client.request("thread/compact/start", { threadId: binding.threadId }, {
|
|
508
|
+
...guardedRequestTimeoutMs === void 0 ? {} : { timeoutMs: guardedRequestTimeoutMs },
|
|
509
|
+
assertCurrent: () => {
|
|
510
|
+
try {
|
|
511
|
+
assertCurrent();
|
|
512
|
+
} catch (error) {
|
|
513
|
+
compactionRequestDefinitelyRejected = true;
|
|
514
|
+
throw error;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
});
|
|
475
518
|
return {
|
|
476
519
|
started: true,
|
|
477
520
|
accepted: true
|
|
478
521
|
};
|
|
479
522
|
} catch (error) {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
523
|
+
compactionRequestDefinitelyRejected ||= isCodexAppServerPrewriteRequestCancellationError(error);
|
|
524
|
+
if (compactionRequestDefinitelyRejected || error instanceof CodexAppServerRpcError) {
|
|
525
|
+
completionWatch.confirmRequestRejected();
|
|
526
|
+
if (!compactionRequestDefinitelyRejected) {
|
|
527
|
+
await options.bindingStore.mutate(bindingIdentity, {
|
|
528
|
+
kind: "set",
|
|
529
|
+
binding
|
|
530
|
+
}, assertCurrent);
|
|
531
|
+
compactionRequestDefinitelyRejected = !isCodexThreadNotFoundError(error);
|
|
532
|
+
}
|
|
486
533
|
}
|
|
487
534
|
return {
|
|
488
535
|
started: true,
|
|
@@ -493,8 +540,7 @@ async function compactCodexNativeThread(params, options) {
|
|
|
493
540
|
});
|
|
494
541
|
if (!guardedResult.started) return guardedResult.result;
|
|
495
542
|
if (!guardedResult.accepted) {
|
|
496
|
-
if (guardedResult.error instanceof CodexAppServerRpcError) completionWatch.
|
|
497
|
-
else await completionWatch.retireUnconfirmedRequest(`codex app-server compaction start was unconfirmed: ${coerceErrorMessage(guardedResult.error)}`);
|
|
543
|
+
if (!compactionRequestDefinitelyRejected && !(guardedResult.error instanceof CodexAppServerRpcError)) await completionWatch.retireUnconfirmedRequest(`codex app-server compaction start was unconfirmed: ${coerceErrorMessage(guardedResult.error)}`);
|
|
498
544
|
throw guardedResult.error;
|
|
499
545
|
}
|
|
500
546
|
embeddedAgentLog.info("started codex app-server compaction", {
|
|
@@ -502,6 +548,7 @@ async function compactCodexNativeThread(params, options) {
|
|
|
502
548
|
threadId: binding.threadId
|
|
503
549
|
});
|
|
504
550
|
const completion = await completionWatch.completion;
|
|
551
|
+
assertCurrent();
|
|
505
552
|
if (!completion.completed) throw new Error(completion.reason);
|
|
506
553
|
tokensAfter = completion.tokensAfter;
|
|
507
554
|
if (completion.turnId && completion.itemId) await persistCodexContextCompactionActivity({
|
|
@@ -514,6 +561,7 @@ async function compactCodexNativeThread(params, options) {
|
|
|
514
561
|
itemId: completion.itemId,
|
|
515
562
|
timestamp: Date.now()
|
|
516
563
|
});
|
|
564
|
+
assertCurrent();
|
|
517
565
|
embeddedAgentLog.info("completed codex app-server compaction", {
|
|
518
566
|
sessionId: params.sessionId,
|
|
519
567
|
threadId: binding.threadId
|
|
@@ -541,9 +589,9 @@ async function compactCodexNativeThread(params, options) {
|
|
|
541
589
|
try {
|
|
542
590
|
if ((compactionSucceeded || compactionRequestDefinitelyRejected) && retainedThreadOwnership) {
|
|
543
591
|
const ownership = retainedThreadOwnership;
|
|
544
|
-
const currentBinding =
|
|
592
|
+
const currentBinding = options.bindingStore.read(bindingIdentity);
|
|
545
593
|
if (!(isSameCodexAppServerThreadOwner(currentBinding, binding) && await options.bindingStore.withLease(bindingIdentity, async () => {
|
|
546
|
-
const leasedBinding =
|
|
594
|
+
const leasedBinding = options.bindingStore.read(bindingIdentity);
|
|
547
595
|
if (!isSameCodexAppServerThreadOwner(leasedBinding, binding)) return false;
|
|
548
596
|
return await retainCodexAppServerLiveThread(client, binding.threadId, ownership.release, ownership.configFingerprint, ownership.serviceTier);
|
|
549
597
|
}))) await releaseThreadSubscription?.();
|
|
@@ -570,20 +618,7 @@ async function compactCodexNativeThread(params, options) {
|
|
|
570
618
|
});
|
|
571
619
|
});
|
|
572
620
|
} catch (error) {
|
|
573
|
-
if (params.abortSignal?.aborted)
|
|
574
|
-
if (options.allowNonManualNativeRequest) return skippedCodexNativeCompactionResult(params, {
|
|
575
|
-
reason: "codex app-server compaction aborted before native compaction",
|
|
576
|
-
code: "aborted_before_native_compaction",
|
|
577
|
-
request: options.nativeCompactionRequest ?? "after_context_engine",
|
|
578
|
-
expectedThreadId: initialBinding.threadId,
|
|
579
|
-
currentThreadId: binding.threadId
|
|
580
|
-
});
|
|
581
|
-
return {
|
|
582
|
-
ok: false,
|
|
583
|
-
compacted: false,
|
|
584
|
-
reason: "codex app-server compaction aborted while waiting to start"
|
|
585
|
-
};
|
|
586
|
-
}
|
|
621
|
+
if (params.abortSignal?.aborted) return abortedResult(initialBinding.threadId, binding.threadId);
|
|
587
622
|
throw error;
|
|
588
623
|
}
|
|
589
624
|
}
|
|
@@ -644,7 +679,7 @@ async function clearContextEngineProjectionBeforeNativeCompaction(params) {
|
|
|
644
679
|
...contextEngineBinding,
|
|
645
680
|
projection: void 0
|
|
646
681
|
} }
|
|
647
|
-
});
|
|
682
|
+
}, params.assertCurrent);
|
|
648
683
|
embeddedAgentLog.info("cleared codex context-engine projection before native compaction", {
|
|
649
684
|
sessionId: params.sessionId,
|
|
650
685
|
threadId: params.binding.threadId,
|
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as normalizeHeaders, c as readExecAsk, d as readNumberEnv, f as readRecord, g as CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN, i as normalizeCodexServiceTier, l as readExecSecurity, o as normalizePositiveNumber, p as resolveArgs, r as normalizeCodexAppServerSecretInput, s as readBooleanEnv, t as hashSecretForKey, u as readNonEmptyString } from "./config-utils-C57JiJrU.js";
|
|
2
|
+
import { m as readCodexAppServerConfigOptions, p as normalizeCodexAppServerArgs } from "./managed-binary-DcpnJF9x.js";
|
|
3
|
+
import { asNullableRecord, isRecord, normalizeOptionalString, normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { buildSecretInputSchema } from "openclaw/plugin-sdk/secret-input";
|
|
3
8
|
import path from "node:path";
|
|
4
|
-
import { resolvePositiveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
5
9
|
import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
6
|
-
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
7
10
|
import { readFileSync } from "node:fs";
|
|
8
11
|
import { homedir, hostname } from "node:os";
|
|
9
12
|
import { resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
|
|
10
|
-
import { resolveAgentConfig as resolveAgentConfig$1 } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
11
13
|
import { resolveExecApprovalsFromFile } from "openclaw/plugin-sdk/exec-approvals-runtime";
|
|
12
|
-
import { buildSecretInputSchema, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
13
14
|
import { detectWindowsSpawnCommandInlineArgs } from "openclaw/plugin-sdk/windows-spawn";
|
|
14
|
-
import { z } from "zod";
|
|
15
15
|
import { parse } from "smol-toml";
|
|
16
16
|
import { isLoopbackHost } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
17
|
+
//#region extensions/codex/src/app-server/protocol.ts
|
|
18
|
+
/** Namespace Codex keeps directly model-visible without exposing it to Code Mode guests. */
|
|
19
|
+
const CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE = "openclaw_direct";
|
|
20
|
+
function flattenCodexDynamicToolFunctions(tools) {
|
|
21
|
+
return (tools ?? []).flatMap((tool) => tool.type === "namespace" ? tool.tools : [tool]);
|
|
22
|
+
}
|
|
23
|
+
const CODEX_INTERACTIVE_THREAD_SOURCE_KINDS = ["cli", "vscode"];
|
|
24
|
+
const CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES = ["atlas", "chatgpt"];
|
|
25
|
+
function isJsonObject(value) {
|
|
26
|
+
return isRecord(value);
|
|
27
|
+
}
|
|
28
|
+
function isRpcResponse(message) {
|
|
29
|
+
return "id" in message && !("method" in message);
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
17
32
|
//#region extensions/codex/src/app-server/auth-start-options.ts
|
|
18
33
|
const CODEX_APP_SERVER_HOME_DIRNAME = "codex-home";
|
|
19
34
|
const CODEX_EPHEMERAL_AUTH_STORE_OVERRIDE = "cli_auth_credentials_store=\"ephemeral\"";
|
|
@@ -42,96 +57,6 @@ function withEphemeralCodexAuthStore(params) {
|
|
|
42
57
|
};
|
|
43
58
|
}
|
|
44
59
|
//#endregion
|
|
45
|
-
//#region extensions/codex/src/app-server/config-contracts.ts
|
|
46
|
-
const CODEX_PLUGINS_MARKETPLACE_NAME = "openai-curated";
|
|
47
|
-
const CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME = "workspace-directory";
|
|
48
|
-
const CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region extensions/codex/src/app-server/config-utils.ts
|
|
51
|
-
const START_OPTIONS_KEY_SECRET_SYMBOL = Symbol.for("openclaw.codexAppServerStartOptionsKeySecret");
|
|
52
|
-
const START_OPTIONS_KEY_SECRET = getStartOptionsKeySecret();
|
|
53
|
-
const PLAIN_DECIMAL_NUMBER_RE = /^[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))$/;
|
|
54
|
-
function normalizeCodexServiceTier(value) {
|
|
55
|
-
if (typeof value !== "string") return;
|
|
56
|
-
const trimmed = value.trim();
|
|
57
|
-
if (!trimmed) return;
|
|
58
|
-
const normalized = trimmed.toLowerCase();
|
|
59
|
-
if (normalized === "fast" || normalized === "priority") return "priority";
|
|
60
|
-
if (normalized === "flex") return "flex";
|
|
61
|
-
return trimmed;
|
|
62
|
-
}
|
|
63
|
-
function isCodexFastServiceTier(value) {
|
|
64
|
-
return normalizeCodexServiceTier(value) === "priority";
|
|
65
|
-
}
|
|
66
|
-
function normalizePositiveNumber(value, fallback) {
|
|
67
|
-
return resolvePositiveTimerTimeoutMs(value, fallback);
|
|
68
|
-
}
|
|
69
|
-
function normalizeHeaders(value) {
|
|
70
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
71
|
-
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key.trim(), normalizeCodexAppServerSecretInput({
|
|
72
|
-
value: child,
|
|
73
|
-
path: `plugins.entries.codex.config.appServer.headers.${key}`
|
|
74
|
-
})]).filter((entry) => Boolean(entry[0] && entry[1])));
|
|
75
|
-
}
|
|
76
|
-
function normalizeCodexAppServerSecretInput(params) {
|
|
77
|
-
return normalizeResolvedSecretInputString(params);
|
|
78
|
-
}
|
|
79
|
-
function readBooleanEnv(value) {
|
|
80
|
-
return parseBooleanValue(value);
|
|
81
|
-
}
|
|
82
|
-
function readExecSecurity(value) {
|
|
83
|
-
return value === "deny" || value === "allowlist" || value === "full" ? value : void 0;
|
|
84
|
-
}
|
|
85
|
-
function readExecAsk(value) {
|
|
86
|
-
return value === "off" || value === "on-miss" || value === "always" ? value : void 0;
|
|
87
|
-
}
|
|
88
|
-
function readNumberEnv(value) {
|
|
89
|
-
const trimmed = value?.trim();
|
|
90
|
-
if (!trimmed || !PLAIN_DECIMAL_NUMBER_RE.test(trimmed)) return;
|
|
91
|
-
const parsed = Number(trimmed);
|
|
92
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
93
|
-
}
|
|
94
|
-
function resolveArgs(configArgs, envArgs) {
|
|
95
|
-
if (Array.isArray(configArgs)) return configArgs.map((entry) => readNonEmptyString(entry)).filter((entry) => entry !== void 0);
|
|
96
|
-
if (typeof configArgs === "string") return splitShellWords(configArgs);
|
|
97
|
-
return splitShellWords(envArgs ?? "");
|
|
98
|
-
}
|
|
99
|
-
function hashSecretForKey(value, label) {
|
|
100
|
-
if (!value) return null;
|
|
101
|
-
return createHmac("sha256", START_OPTIONS_KEY_SECRET).update(label).update("\0").update(value).digest("hex");
|
|
102
|
-
}
|
|
103
|
-
function getStartOptionsKeySecret() {
|
|
104
|
-
const globalState = globalThis;
|
|
105
|
-
globalState[START_OPTIONS_KEY_SECRET_SYMBOL] ??= randomBytes(32);
|
|
106
|
-
return globalState[START_OPTIONS_KEY_SECRET_SYMBOL];
|
|
107
|
-
}
|
|
108
|
-
function splitShellWords(value) {
|
|
109
|
-
const words = [];
|
|
110
|
-
let current = "";
|
|
111
|
-
let quote = null;
|
|
112
|
-
for (const char of value) {
|
|
113
|
-
if (quote) {
|
|
114
|
-
if (char === quote) quote = null;
|
|
115
|
-
else current += char;
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (char === "\"" || char === "'") {
|
|
119
|
-
quote = char;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (/\s/.test(char)) {
|
|
123
|
-
if (current) {
|
|
124
|
-
words.push(current);
|
|
125
|
-
current = "";
|
|
126
|
-
}
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
current += char;
|
|
130
|
-
}
|
|
131
|
-
if (current) words.push(current);
|
|
132
|
-
return words;
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
60
|
//#region extensions/codex/src/app-server/config-exec-policy.ts
|
|
136
61
|
function selectForcedPromptingSandbox(params) {
|
|
137
62
|
if (params.configuredSandbox === "read-only" || params.defaultSandbox === "read-only") return "read-only";
|
|
@@ -166,7 +91,7 @@ function resolveOpenClawExecPolicyFromConfig(params) {
|
|
|
166
91
|
const globalExec = readRecord(params.config?.tools?.exec);
|
|
167
92
|
const globalPolicy = applyOpenClawExecPolicyLayer(createDefaultOpenClawExecPolicy(), globalExec);
|
|
168
93
|
const agentId = params.agentId?.trim();
|
|
169
|
-
return applyOpenClawExecPolicyLayer(globalPolicy, agentId ? readRecord(resolveAgentConfig
|
|
94
|
+
return applyOpenClawExecPolicyLayer(globalPolicy, agentId ? readRecord(resolveAgentConfig(params.config ?? {}, agentId)?.tools?.exec) : void 0);
|
|
170
95
|
}
|
|
171
96
|
function resolveOpenClawExecPolicyForCodexAppServer(params) {
|
|
172
97
|
if (params.permissionMode === "full") return {
|
|
@@ -520,6 +445,26 @@ function resolveCodexPluginDestructivePolicy(policy) {
|
|
|
520
445
|
};
|
|
521
446
|
}
|
|
522
447
|
//#endregion
|
|
448
|
+
//#region extensions/codex/src/app-server/config-layer-policy.ts
|
|
449
|
+
const CODEX_SESSION_OVERRIDABLE_LAYER_TYPES = /* @__PURE__ */ new Set([
|
|
450
|
+
"packagedDefaults",
|
|
451
|
+
"mdm",
|
|
452
|
+
"system",
|
|
453
|
+
"enterpriseManaged",
|
|
454
|
+
"user",
|
|
455
|
+
"project",
|
|
456
|
+
"sessionFlags"
|
|
457
|
+
]);
|
|
458
|
+
/** Read one effective snapshot for the current boundary's reviewer and tool-policy checks. */
|
|
459
|
+
async function readCodexEffectiveConfig(client, cwd, signal) {
|
|
460
|
+
const response = await client.request("config/read", {
|
|
461
|
+
cwd: path.resolve(cwd),
|
|
462
|
+
includeLayers: true
|
|
463
|
+
}, { signal });
|
|
464
|
+
if (!isJsonObject(response) || !isJsonObject(response.config)) throw new Error("Codex config/read returned an invalid effective config");
|
|
465
|
+
return response;
|
|
466
|
+
}
|
|
467
|
+
//#endregion
|
|
523
468
|
//#region extensions/codex/src/app-server/config-requirements.ts
|
|
524
469
|
const UNIX_CODEX_REQUIREMENTS_PATH = "/etc/codex/requirements.toml";
|
|
525
470
|
const WINDOWS_CODEX_REQUIREMENTS_SUFFIX = "\\OpenAI\\Codex\\requirements.toml";
|
|
@@ -719,18 +664,15 @@ const CODEX_CONFIG_TOML_FILENAME = "config.toml";
|
|
|
719
664
|
/** Cloud/system config can redirect reviews after local home/profile checks have passed. */
|
|
720
665
|
async function assertCodexModelBackedReviewerEffectiveConfig(params) {
|
|
721
666
|
if (params.approvalsReviewer !== "auto_review" && params.approvalsReviewer !== "guardian_subagent") return;
|
|
722
|
-
const response = await params.client.
|
|
723
|
-
|
|
724
|
-
includeLayers: false
|
|
725
|
-
}, { signal: params.signal });
|
|
726
|
-
const effectiveConfig = readRecord(readRecord(response)?.config);
|
|
727
|
-
if (!effectiveConfig) throw new Error("Codex config/read returned an invalid model-backed reviewer config");
|
|
667
|
+
const response = await readCodexEffectiveConfig(params.client, params.cwd, params.signal);
|
|
668
|
+
const effectiveConfig = response.config;
|
|
728
669
|
const modelProvider = effectiveConfig.model_provider;
|
|
729
670
|
const providers = effectiveConfig.model_providers;
|
|
730
671
|
const providerRecords = providers == null ? void 0 : readRecord(providers);
|
|
731
672
|
const provider = providerRecords?.openai;
|
|
732
673
|
const openAIProvider = provider == null ? void 0 : readRecord(provider);
|
|
733
674
|
if (modelProvider != null && modelProvider !== "openai" || providers != null && !providerRecords || provider != null && !openAIProvider || !isTrustedOptionalReviewerEndpoint(effectiveConfig.openai_base_url, isNativeOpenAIBaseUrl) || !isTrustedOptionalReviewerEndpoint(effectiveConfig.chatgpt_base_url, isNativeChatGPTBaseUrl) || !isTrustedOptionalReviewerEndpoint(openAIProvider?.base_url, isNativeOpenAIBaseUrl)) throw new Error("Codex model-backed approval reviewer requires the running server to use a trusted OpenAI endpoint");
|
|
675
|
+
return response;
|
|
734
676
|
}
|
|
735
677
|
function isTrustedOptionalReviewerEndpoint(value, isTrusted) {
|
|
736
678
|
return value == null || typeof value === "string" && isTrusted(value);
|
|
@@ -1398,4 +1340,4 @@ function resolveCodexSupervisionAppServerRuntimeOptions(params = {}) {
|
|
|
1398
1340
|
});
|
|
1399
1341
|
}
|
|
1400
1342
|
//#endregion
|
|
1401
|
-
export {
|
|
1343
|
+
export { resolveOpenClawExecPolicyForCodexAppServer as A, isJsonObject as B, CODEX_SESSION_OVERRIDABLE_LAYER_TYPES as C, isCodexSandboxExecServerEnabled as D, isCodexRemoteExecPlacementSandbox as E, withEphemeralCodexAuthStore as F, CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES as I, CODEX_INTERACTIVE_THREAD_SOURCE_KINDS as L, resolveCodexAppServerHomeDir as M, resolveCodexAppServerLocalHomeDir as N, readCodexPluginConfig as O, resolveCodexAppServerUserHomeDir as P, CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE as R, selectUserApprovalsReviewer as S, isCodexPairedNodeRemoteExecPlacementSandbox as T, isRpcResponse as V, parseAllowedApprovalsReviewersFromCodexRequirements as _, resolveCodexAppServerStartOptionsForAgent as a, selectGuardianApprovalPolicy as b, assertCodexAppServerConnectionSecurity as c, shouldAutoApproveCodexAppServerApprovals as d, withMcpElicitationsApprovalPolicy as f, parseAllowedApprovalPoliciesFromCodexRequirements as g, resolveCodexModelBackedReviewerPolicyContext as h, resolveCodexAppServerRuntimeOptions as i, selectGuardianSandbox as j, resolveCodexPluginsPolicy as k, hasCodexMcpToolApprovalOverrides as l, canUseCodexModelBackedApprovalsReviewerForModel as m, codexSandboxPolicyForTurn as n, resolveCodexComputerUseConfig as o, assertCodexModelBackedReviewerEffectiveConfig as p, resolveCodexAppServerHomeScope as r, resolveCodexSupervisionAppServerRuntimeOptions as s, codexAppServerStartOptionsKey as t, resolveCodexAppServerNetworkProxy as u, parseAllowedSandboxModesFromCodexRequirements as v, readCodexEffectiveConfig as w, selectGuardianApprovalsReviewer as x, readCodexRequirementsToml as y, flattenCodexDynamicToolFunctions as z };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { asOptionalRecord as readRecord, normalizeOptionalString as readNonEmptyString, parseBooleanValue } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
+
import { createHmac, randomBytes } from "node:crypto";
|
|
3
|
+
import { resolvePositiveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
4
|
+
import { splitCommandArgs } from "openclaw/plugin-sdk/process-runtime";
|
|
5
|
+
import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
6
|
+
//#region extensions/codex/src/app-server/config-contracts.ts
|
|
7
|
+
const CODEX_PLUGINS_MARKETPLACE_NAME = "openai-curated";
|
|
8
|
+
const CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME = "workspace-directory";
|
|
9
|
+
const CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region extensions/codex/src/app-server/config-utils.ts
|
|
12
|
+
const START_OPTIONS_KEY_SECRET_SYMBOL = Symbol.for("openclaw.codexAppServerStartOptionsKeySecret");
|
|
13
|
+
const START_OPTIONS_KEY_SECRET = getStartOptionsKeySecret();
|
|
14
|
+
const PLAIN_DECIMAL_NUMBER_RE = /^[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))$/;
|
|
15
|
+
function normalizeCodexServiceTier(value) {
|
|
16
|
+
if (typeof value !== "string") return;
|
|
17
|
+
const trimmed = value.trim();
|
|
18
|
+
if (!trimmed) return;
|
|
19
|
+
const normalized = trimmed.toLowerCase();
|
|
20
|
+
if (normalized === "fast" || normalized === "priority") return "priority";
|
|
21
|
+
if (normalized === "flex") return "flex";
|
|
22
|
+
return trimmed;
|
|
23
|
+
}
|
|
24
|
+
function isCodexFastServiceTier(value) {
|
|
25
|
+
return normalizeCodexServiceTier(value) === "priority";
|
|
26
|
+
}
|
|
27
|
+
function normalizePositiveNumber(value, fallback) {
|
|
28
|
+
return resolvePositiveTimerTimeoutMs(value, fallback);
|
|
29
|
+
}
|
|
30
|
+
function normalizeHeaders(value) {
|
|
31
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
32
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key.trim(), normalizeCodexAppServerSecretInput({
|
|
33
|
+
value: child,
|
|
34
|
+
path: `plugins.entries.codex.config.appServer.headers.${key}`
|
|
35
|
+
})]).filter((entry) => Boolean(entry[0] && entry[1])));
|
|
36
|
+
}
|
|
37
|
+
function normalizeCodexAppServerSecretInput(params) {
|
|
38
|
+
return normalizeResolvedSecretInputString(params);
|
|
39
|
+
}
|
|
40
|
+
function readBooleanEnv(value) {
|
|
41
|
+
return parseBooleanValue(value);
|
|
42
|
+
}
|
|
43
|
+
function readExecSecurity(value) {
|
|
44
|
+
return value === "deny" || value === "allowlist" || value === "full" ? value : void 0;
|
|
45
|
+
}
|
|
46
|
+
function readExecAsk(value) {
|
|
47
|
+
return value === "off" || value === "on-miss" || value === "always" ? value : void 0;
|
|
48
|
+
}
|
|
49
|
+
function readNumberEnv(value) {
|
|
50
|
+
const trimmed = value?.trim();
|
|
51
|
+
if (!trimmed || !PLAIN_DECIMAL_NUMBER_RE.test(trimmed)) return;
|
|
52
|
+
const parsed = Number(trimmed);
|
|
53
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
54
|
+
}
|
|
55
|
+
function resolveArgs(configArgs, envArgs) {
|
|
56
|
+
if (Array.isArray(configArgs)) return configArgs.map((entry) => readNonEmptyString(entry)).filter((entry) => entry !== void 0);
|
|
57
|
+
return splitCommandArgs(typeof configArgs === "string" ? configArgs : envArgs ?? "", { allowUnclosedQuotes: true });
|
|
58
|
+
}
|
|
59
|
+
function hashSecretForKey(value, label) {
|
|
60
|
+
if (!value) return null;
|
|
61
|
+
return createHmac("sha256", START_OPTIONS_KEY_SECRET).update(label).update("\0").update(value).digest("hex");
|
|
62
|
+
}
|
|
63
|
+
function getStartOptionsKeySecret() {
|
|
64
|
+
const globalState = globalThis;
|
|
65
|
+
globalState[START_OPTIONS_KEY_SECRET_SYMBOL] ??= randomBytes(32);
|
|
66
|
+
return globalState[START_OPTIONS_KEY_SECRET_SYMBOL];
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { normalizeHeaders as a, readExecAsk as c, readNumberEnv as d, readRecord as f, CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN as g, CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME as h, normalizeCodexServiceTier as i, readExecSecurity as l, CODEX_PLUGINS_MARKETPLACE_NAME as m, isCodexFastServiceTier as n, normalizePositiveNumber as o, resolveArgs as p, normalizeCodexAppServerSecretInput as r, readBooleanEnv as s, hashSecretForKey as t, readNonEmptyString as u };
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { n as CODEX_APP_SERVER_BINDING_NAMESPACE, t as CODEX_APP_SERVER_BINDING_MAX_ENTRIES } from "./session-binding-meta-B7aEMU7g.js";
|
|
2
2
|
import { asNullableRecord, asOptionalRecord, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { listAgentIds, resolveAgentDir, resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
3
5
|
import fs from "node:fs/promises";
|
|
4
6
|
import path from "node:path";
|
|
5
7
|
import { canonicalPathFromExistingAncestor, isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
|
|
6
|
-
import { createHash } from "node:crypto";
|
|
7
8
|
import { isDeepStrictEqual } from "node:util";
|
|
8
9
|
import { pathExists } from "openclaw/plugin-sdk/security-runtime";
|
|
9
|
-
import { listAgentIds, resolveAgentDir, resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
10
10
|
import { setImmediate } from "node:timers/promises";
|
|
11
11
|
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
|
|
12
12
|
import { withFileLock } from "openclaw/plugin-sdk/file-lock";
|
|
13
13
|
import { archiveLegacyStateSource, legacyStateFileExists } from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
14
|
+
import { resolveStorePath } from "openclaw/plugin-sdk/session-store-paths";
|
|
14
15
|
//#region extensions/codex/src/migration/session-binding-orphans.ts
|
|
15
16
|
const PAGE_SIZE = 512;
|
|
16
17
|
const KEY_PREFIXES = ["session-key:", "session:"];
|
|
@@ -122,7 +123,6 @@ const LEGACY_BINDING_LOCK_OPTIONS = {
|
|
|
122
123
|
stale: 12e4
|
|
123
124
|
};
|
|
124
125
|
async function collectSessionSurfaces(params) {
|
|
125
|
-
const { resolveStorePath } = await import("openclaw/plugin-sdk/session-store-runtime");
|
|
126
126
|
const surfaces = /* @__PURE__ */ new Map();
|
|
127
127
|
const stateRoot = await canonicalPathFromExistingAncestor(params.stateDir);
|
|
128
128
|
const add = async (root, storePath, agentId, scan) => {
|
|
@@ -268,7 +268,6 @@ async function* walkSidecars(root) {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
async function collectBindingOwners(sources, surfaces, params) {
|
|
271
|
-
const { resolveStorePath } = await import("openclaw/plugin-sdk/session-store-runtime");
|
|
272
271
|
const sourcePaths = new Set(await Promise.all(sources.map((source) => canonicalPathFromExistingAncestor(source.transcriptPath))));
|
|
273
272
|
const owners = /* @__PURE__ */ new Map();
|
|
274
273
|
const storePaths = new Set(surfaces.flatMap((surface) => [...surface.storePaths]));
|
|
@@ -392,7 +391,7 @@ async function migrateSource(source, candidates, params, store) {
|
|
|
392
391
|
return await withFileLock(source.sidecarPath, LEGACY_BINDING_LOCK_OPTIONS, async () => {
|
|
393
392
|
const [contents, stat] = await Promise.all([fs.readFile(source.sidecarPath, "utf8"), fs.stat(source.sidecarPath)]);
|
|
394
393
|
const raw = JSON.parse(contents);
|
|
395
|
-
const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-
|
|
394
|
+
const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-4Ki04sW-.js").then((n) => n.d), import("./conversation-binding-data-BiodpIzq.js").then((n) => n.t)]);
|
|
396
395
|
const agentId = owner?.agentId ?? (source.agentIds.size === 1 ? [...source.agentIds][0] : void 0);
|
|
397
396
|
const baseStored = createStoredCodexAppServerBinding(raw, {
|
|
398
397
|
now: stat.mtime.toISOString(),
|