@openclaw/codex 2026.9.1 → 2026.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/api.js +18 -23
- package/dist/apply-B6el6hdO.js +357 -0
- package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-D6cR54TV.js} +113 -49
- package/dist/{attempt-context-DmQUNWwT.js → attempt-context-AO4DSjE0.js} +11 -9
- package/dist/{event-projector-usage-C5mcrGjp.js → attempt-notifications--H8zXR5-.js} +3 -89
- package/dist/auth-cache-key-Kq6oerr6.js +498 -0
- package/dist/auth-profile-CwzO4_RG.js +43 -0
- package/dist/auth-profile-selection-DFu9e167.js +45 -0
- package/dist/{binding-connection-E6uDsPlx.js → binding-connection-QqgcPCgk.js} +18 -3
- package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-lRpmZHFv.js} +54 -150
- package/dist/build-state-6RL6qohz.js +19 -0
- package/dist/{capabilities-dIjNVCYH.js → capabilities-BeqLPbtM.js} +2 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-BEKu4yDx.js +3983 -0
- package/dist/command-dispatch-CisT9Jqq.js +21 -0
- package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DeTfrapr.js} +2 -2
- package/dist/{command-handlers-CTGb2csu.js → command-handlers-BfIsJEuA.js} +158 -76
- package/dist/command-rpc-BMqRQOFX.js +226 -0
- package/dist/{compact-_t0HQrUS.js → compact-CGJZ2rlb.js} +89 -49
- package/dist/config-JDfTI4VI.js +106 -0
- package/dist/{config-BhmfC1s6.js → config-options-jnIFvwxD.js} +208 -654
- package/dist/config-runtime-BWf6JLWG.js +11 -0
- package/dist/config-utils-C57JiJrU.js +69 -0
- package/dist/conversation-binding-CxOlHiix.js +889 -0
- package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → conversation-control-CUCrSIQI.js} +36 -155
- package/dist/doctor-contract-api.js +8 -9
- package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-D-JBoaLt.js} +734 -698
- package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-J_5Ep5Um.js} +4 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
- package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-BmBM4qBV.js} +23 -27
- package/dist/event-projector-usage-CIyrYYid.js +102 -0
- package/dist/{harness-DXVZ5II5.js → harness-FR6eQgyO.js} +47 -17
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +413 -2893
- package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-DHBefrzg.js} +12 -21
- package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DrjjRRUD.js} +17 -84
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/{model-catalog-CUM68Hkl.js → model-catalog-B_6M04Wo.js} +6 -5
- package/dist/{models-sYnEc0gd.js → models-P9k2qAof.js} +4 -4
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-BbCUKRwC.js} +76 -48
- package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
- package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-BY_ctYnT.js} +54 -23
- package/dist/plan-BMJdMOEF.js +711 -0
- package/dist/plugin-activation-BQK-f5sV.js +133 -0
- package/dist/{thread-resume-C7pyVKeW.js → plugin-app-cache-key-CdSQzWyX.js} +5 -53
- package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
- package/dist/plugin-inventory-CoRCzWW4.js +325 -0
- package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
- package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
- package/dist/protocol-CAAcVIKF.js +275 -0
- package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-W4tfK5Y5.js} +2 -2
- package/dist/{rate-limits-CawQJfUS.js → rate-limits-Bqnx1N4z.js} +1 -1
- package/dist/request-CGvGOpeR.js +198 -0
- package/dist/{run-attempt-D1hJO4fX.js → run-attempt-DwKds3DN.js} +1498 -1028
- package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-T-NwqeSH.js} +28 -28
- package/dist/sandbox-guard-BcT66fWy.js +165 -0
- package/dist/{session-binding-BHuTCRZQ.js → session-binding-CKSepwIC.js} +118 -324
- package/dist/session-binding-record-CaZjYwNS.js +256 -0
- package/dist/session-catalog-HaDcp7Sv.js +1533 -0
- package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
- package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
- package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
- package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
- package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
- package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
- package/dist/session-catalog-provenance-DkJHo735.js +124 -0
- package/dist/{session-cli-CmFEXMAM.js → session-cli-CbgaHh0f.js} +3 -2
- package/dist/session-history-Cz-tOOYj.js +96 -0
- package/dist/{session-upstream-marker-C351-5Qw.js → session-history-import-DFN7sWRU.js} +5 -49
- package/dist/session-history-read-cxPUxyVV.js +50 -0
- package/dist/session-history-worker-runtime.js +60 -0
- package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-CNEvGaU5.js} +75 -69
- package/dist/session-history.worker.js +2 -0
- package/dist/{session-initialization-BeWzjGiR.js → session-initialization-Jo86C60I.js} +2 -1
- package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-B22InTp_.js} +4 -7
- package/dist/{session-retirement-BujDjXVF.js → session-retirement-BSNG_mhf.js} +8 -7
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/settled-turn-context-Du6gdUDd.js +45 -0
- package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BuLUrZl2.js} +54 -42
- package/dist/shared-client-CVhez2Uo.js +2911 -0
- package/dist/{side-question-BTZAII4l.js → side-question-DLbr2vUU.js} +135 -191
- package/dist/source-Da-h6f7e.js +518 -0
- package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
- package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-D1pzRwHB.js} +467 -977
- package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-D6oASVRu.js} +15 -17
- package/dist/{thread-policy-g4KbJPzp.js → thread-policy-D8kI7yAO.js} +2 -2
- package/dist/thread-resume-T5cveyxA.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/transcript-mirror-attestation-DibE0krH.js +89 -0
- package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-t5TOccct.js} +111 -379
- package/dist/{transport-stdio-CyPldczm.js → transport-stdio-BGjHoYLr.js} +80 -48
- package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-De-sLJ2r.js} +94 -166
- package/dist/{usage-Bj-rrzkR.js → usage-CPPTmBvZ.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
- package/openclaw.plugin.json +22 -1
- package/package.json +6 -6
- package/dist/request-DYAI5FQE.js +0 -475
- package/dist/session-catalog-yyvTWFOw.js +0 -3120
- package/dist/session-history-C5J1AKzG.js +0 -87
- package/dist/shared-client-DxcfF9KX.js +0 -7494
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { g as CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN, i as normalizeCodexServiceTier } from "./config-utils-C57JiJrU.js";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-registration";
|
|
4
|
+
import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region extensions/codex/src/app-server/session-binding-record.ts
|
|
7
|
+
/** Canonical binding codec and synchronous generation-aware reads; no lifecycle or auth loading. */
|
|
8
|
+
/** Resolves the same agent scope OpenClaw uses for transcript/session ownership. */
|
|
9
|
+
function sessionBindingIdentity(params) {
|
|
10
|
+
const { sessionAgentId } = resolveSessionAgentIdsStrict(params);
|
|
11
|
+
const sessionKey = params.sessionKey?.trim();
|
|
12
|
+
return {
|
|
13
|
+
kind: "session",
|
|
14
|
+
agentId: sessionAgentId,
|
|
15
|
+
sessionId: params.sessionId,
|
|
16
|
+
...sessionKey ? { sessionKey } : {}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const optionalStringSchema = z.string().optional().catch(void 0);
|
|
20
|
+
const optionalBooleanSchema = z.boolean().optional().catch(void 0);
|
|
21
|
+
const optionalNonBlankStringSchema = z.string().refine((value) => Boolean(value.trim())).optional().catch(void 0);
|
|
22
|
+
const optionalTimestampSchema = z.string().refine((value) => Number.isFinite(Date.parse(value))).optional().catch(void 0);
|
|
23
|
+
const pendingSupervisionBranchSchema = z.object({
|
|
24
|
+
sourceThreadId: z.string().trim().min(1),
|
|
25
|
+
connectionFingerprint: z.string().trim().min(1).optional(),
|
|
26
|
+
lastTurnId: z.string().trim().min(1).optional(),
|
|
27
|
+
cleanupThreadIds: z.array(z.string().trim().min(1)).max(2).optional()
|
|
28
|
+
}).strict().superRefine((pending, context) => {
|
|
29
|
+
const cleanupThreadIds = pending.cleanupThreadIds ?? [];
|
|
30
|
+
if (new Set(cleanupThreadIds).size !== cleanupThreadIds.length) context.addIssue({
|
|
31
|
+
code: "custom",
|
|
32
|
+
message: "pending supervision cleanup thread ids must be unique"
|
|
33
|
+
});
|
|
34
|
+
if (cleanupThreadIds.includes(pending.sourceThreadId)) context.addIssue({
|
|
35
|
+
code: "custom",
|
|
36
|
+
message: "pending supervision cleanup cannot target its source"
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const contextEngineProjectionSchema = z.object({
|
|
40
|
+
schemaVersion: z.literal(1),
|
|
41
|
+
mode: z.literal("thread_bootstrap"),
|
|
42
|
+
epoch: z.string().refine((value) => Boolean(value.trim())),
|
|
43
|
+
fingerprint: optionalStringSchema
|
|
44
|
+
}).strict();
|
|
45
|
+
const contextEngineSchema = z.object({
|
|
46
|
+
schemaVersion: z.literal(1),
|
|
47
|
+
engineId: z.string(),
|
|
48
|
+
policyFingerprint: z.string(),
|
|
49
|
+
projection: contextEngineProjectionSchema.optional().catch(void 0)
|
|
50
|
+
}).strict();
|
|
51
|
+
const destructiveApprovalModeSchema = z.enum([
|
|
52
|
+
"allow",
|
|
53
|
+
"deny",
|
|
54
|
+
"auto",
|
|
55
|
+
"ask"
|
|
56
|
+
]).optional().catch(void 0);
|
|
57
|
+
const accountAppPolicyEntrySchema = z.object({
|
|
58
|
+
source: z.literal("account"),
|
|
59
|
+
appName: z.string(),
|
|
60
|
+
allowDestructiveActions: z.boolean(),
|
|
61
|
+
allowOpenWorld: z.boolean().optional(),
|
|
62
|
+
destructiveApprovalMode: destructiveApprovalModeSchema,
|
|
63
|
+
mcpServerNames: z.array(z.string())
|
|
64
|
+
}).strict();
|
|
65
|
+
const pluginAppPolicyEntrySchema = z.object({
|
|
66
|
+
source: z.literal("plugin").optional(),
|
|
67
|
+
configKey: z.string(),
|
|
68
|
+
marketplaceName: z.string().regex(CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN),
|
|
69
|
+
pluginName: z.string(),
|
|
70
|
+
allowDestructiveActions: z.boolean(),
|
|
71
|
+
allowOpenWorld: z.boolean().optional(),
|
|
72
|
+
destructiveApprovalMode: destructiveApprovalModeSchema,
|
|
73
|
+
mcpServerNames: z.array(z.string())
|
|
74
|
+
}).strict();
|
|
75
|
+
const pluginAppPolicyContextSchema = z.object({
|
|
76
|
+
fingerprint: z.string(),
|
|
77
|
+
apps: z.record(z.string(), z.union([accountAppPolicyEntrySchema, pluginAppPolicyEntrySchema])),
|
|
78
|
+
pluginAppIds: z.record(z.string(), z.array(z.string())).default({})
|
|
79
|
+
}).strict();
|
|
80
|
+
const threadBindingSchema = z.object({
|
|
81
|
+
threadId: z.string().refine((value) => Boolean(value.trim())),
|
|
82
|
+
clientId: optionalStringSchema,
|
|
83
|
+
cwd: z.string(),
|
|
84
|
+
rolloutPath: optionalNonBlankStringSchema,
|
|
85
|
+
connectionScope: z.literal("supervision").optional(),
|
|
86
|
+
supervisionSourceThreadId: z.string().trim().min(1).optional(),
|
|
87
|
+
authProfileId: optionalStringSchema,
|
|
88
|
+
agentWorkspaceDeveloperInstructions: optionalNonBlankStringSchema,
|
|
89
|
+
model: optionalStringSchema,
|
|
90
|
+
preserveNativeModel: z.literal(true).optional().catch(void 0),
|
|
91
|
+
pendingSupervisionBranch: pendingSupervisionBranchSchema.optional(),
|
|
92
|
+
pendingResumeConfiguration: z.literal(true).optional(),
|
|
93
|
+
modelProvider: z.string().transform((value) => value.trim()).pipe(z.string().min(1)).optional().catch(void 0),
|
|
94
|
+
approvalPolicy: z.preprocess((value) => value === "on-failure" ? "on-request" : value, z.enum([
|
|
95
|
+
"never",
|
|
96
|
+
"on-request",
|
|
97
|
+
"untrusted"
|
|
98
|
+
]).optional()).catch(void 0),
|
|
99
|
+
sandbox: z.enum([
|
|
100
|
+
"read-only",
|
|
101
|
+
"workspace-write",
|
|
102
|
+
"danger-full-access"
|
|
103
|
+
]).optional().catch(void 0),
|
|
104
|
+
serviceTier: z.preprocess(normalizeCodexServiceTier, z.custom((value) => typeof value === "string").optional()).optional().catch(void 0),
|
|
105
|
+
networkProxyProfileName: optionalStringSchema,
|
|
106
|
+
networkProxyConfigFingerprint: optionalStringSchema,
|
|
107
|
+
dynamicToolsFingerprint: optionalStringSchema,
|
|
108
|
+
dynamicToolsContainDeferred: optionalBooleanSchema,
|
|
109
|
+
webSearchThreadConfigFingerprint: optionalStringSchema,
|
|
110
|
+
nativeSkillIsolationFingerprint: optionalStringSchema,
|
|
111
|
+
userMcpServersFingerprint: optionalStringSchema,
|
|
112
|
+
mcpServersFingerprint: optionalStringSchema,
|
|
113
|
+
configuredMcpOwnershipVersion: z.literal(1).optional().catch(void 0),
|
|
114
|
+
ringZeroConfigFingerprint: optionalStringSchema,
|
|
115
|
+
ringZeroClientInstanceId: optionalStringSchema,
|
|
116
|
+
/** Durable fact preventing a later unrestricted turn from widening this thread. */
|
|
117
|
+
nativeToolPolicyRestricted: z.literal(true).optional().catch(void 0),
|
|
118
|
+
nativeHookRelayGeneration: optionalNonBlankStringSchema,
|
|
119
|
+
appServerRuntimeFingerprint: optionalStringSchema,
|
|
120
|
+
pluginAppsFingerprint: optionalStringSchema,
|
|
121
|
+
pluginAppsInputFingerprint: optionalStringSchema,
|
|
122
|
+
pluginAppPolicyContext: pluginAppPolicyContextSchema.optional().catch(void 0),
|
|
123
|
+
contextEngine: contextEngineSchema.optional().catch(void 0),
|
|
124
|
+
environmentSelectionFingerprint: optionalStringSchema,
|
|
125
|
+
conversationStartId: optionalStringSchema,
|
|
126
|
+
conversationSourceTransferComplete: z.literal(true).optional().catch(void 0),
|
|
127
|
+
historyCoveredThrough: optionalTimestampSchema,
|
|
128
|
+
continuityCalibration: z.object({
|
|
129
|
+
promptChars: z.number().int().positive(),
|
|
130
|
+
inputTokens: z.number().int().positive()
|
|
131
|
+
}).optional().catch(void 0)
|
|
132
|
+
}).superRefine((binding, context) => {
|
|
133
|
+
if (binding.connectionScope === "supervision") {
|
|
134
|
+
if (!binding.supervisionSourceThreadId) context.addIssue({
|
|
135
|
+
code: "custom",
|
|
136
|
+
message: "supervision connection ownership requires its native source thread id"
|
|
137
|
+
});
|
|
138
|
+
if (binding.preserveNativeModel !== true) context.addIssue({
|
|
139
|
+
code: "custom",
|
|
140
|
+
message: "supervision connection ownership requires native model ownership"
|
|
141
|
+
});
|
|
142
|
+
if (binding.conversationSourceTransferComplete !== true) context.addIssue({
|
|
143
|
+
code: "custom",
|
|
144
|
+
message: "supervision connection ownership requires a completed source transfer"
|
|
145
|
+
});
|
|
146
|
+
if (!binding.pendingSupervisionBranch && (!binding.model?.trim() || !binding.modelProvider)) context.addIssue({
|
|
147
|
+
code: "custom",
|
|
148
|
+
message: "materialized supervision bindings require a native model and provider"
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (binding.supervisionSourceThreadId && binding.connectionScope !== "supervision") context.addIssue({
|
|
152
|
+
code: "custom",
|
|
153
|
+
message: "a supervision source thread id requires supervision connection ownership"
|
|
154
|
+
});
|
|
155
|
+
if (!binding.pendingSupervisionBranch) return;
|
|
156
|
+
if (binding.threadId !== binding.pendingSupervisionBranch.sourceThreadId) context.addIssue({
|
|
157
|
+
code: "custom",
|
|
158
|
+
message: "pending supervision source must match the provisional thread binding"
|
|
159
|
+
});
|
|
160
|
+
if (binding.supervisionSourceThreadId !== binding.pendingSupervisionBranch.sourceThreadId) context.addIssue({
|
|
161
|
+
code: "custom",
|
|
162
|
+
message: "pending supervision source must match its durable source identity"
|
|
163
|
+
});
|
|
164
|
+
if (binding.preserveNativeModel !== true) context.addIssue({
|
|
165
|
+
code: "custom",
|
|
166
|
+
message: "pending supervision bindings must defer model selection to Codex App Server"
|
|
167
|
+
});
|
|
168
|
+
if (binding.connectionScope !== "supervision") context.addIssue({
|
|
169
|
+
code: "custom",
|
|
170
|
+
message: "pending supervision bindings require supervision connection ownership"
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
const bindingLeaseSchema = z.object({
|
|
174
|
+
token: z.string().refine((value) => Boolean(value.trim())),
|
|
175
|
+
expiresAt: z.number().finite()
|
|
176
|
+
});
|
|
177
|
+
const storedSessionIdSchema = z.string().transform((value) => value.trim()).pipe(z.string().min(1)).optional().catch(void 0);
|
|
178
|
+
const storedBindingSchema = z.discriminatedUnion("state", [z.object({
|
|
179
|
+
version: z.literal(1),
|
|
180
|
+
state: z.literal("active"),
|
|
181
|
+
binding: threadBindingSchema,
|
|
182
|
+
sessionId: storedSessionIdSchema,
|
|
183
|
+
lease: bindingLeaseSchema.optional().catch(void 0)
|
|
184
|
+
}), z.object({
|
|
185
|
+
version: z.literal(1),
|
|
186
|
+
state: z.literal("cleared"),
|
|
187
|
+
sessionId: storedSessionIdSchema,
|
|
188
|
+
lease: bindingLeaseSchema.optional().catch(void 0),
|
|
189
|
+
retired: z.literal(true).optional().catch(void 0)
|
|
190
|
+
})]);
|
|
191
|
+
/** Stable plugin-state key for one current binding owner. */
|
|
192
|
+
function bindingStoreKey(identity) {
|
|
193
|
+
if (identity.kind === "session") {
|
|
194
|
+
const rawAgentId = identity.agentId.trim();
|
|
195
|
+
const sessionId = identity.sessionId.trim();
|
|
196
|
+
if (!rawAgentId) throw new Error("Codex app-server binding requires an agent id");
|
|
197
|
+
if (!sessionId) throw new Error("Codex app-server binding requires a session id");
|
|
198
|
+
const agentId = resolveSessionAgentIdsStrict({ agentId: rawAgentId }).sessionAgentId;
|
|
199
|
+
const sessionKey = identity.sessionKey?.trim();
|
|
200
|
+
if (sessionKey) return `session-key:${agentId}:${createHash("sha256").update(sessionKey).digest("base64url")}`;
|
|
201
|
+
return `session:${agentId}:${sessionId}`;
|
|
202
|
+
}
|
|
203
|
+
const bindingId = identity.bindingId.trim();
|
|
204
|
+
if (!bindingId) throw new Error("Codex app-server conversation binding requires a binding id");
|
|
205
|
+
return `conversation:${bindingId}`;
|
|
206
|
+
}
|
|
207
|
+
function readStoredCodexAppServerBinding(value) {
|
|
208
|
+
const result = storedBindingSchema.safeParse(value);
|
|
209
|
+
if (!result.success) return;
|
|
210
|
+
return stripUndefinedValue(result.data);
|
|
211
|
+
}
|
|
212
|
+
function ownsStoredSessionGeneration(identity, current) {
|
|
213
|
+
return identity.kind !== "session" || !current?.sessionId || current.sessionId === identity.sessionId;
|
|
214
|
+
}
|
|
215
|
+
function validateBindingForWrite(binding) {
|
|
216
|
+
const validated = readCodexAppServerThreadBinding(binding);
|
|
217
|
+
if (!validated) throw new Error("Invalid Codex app-server thread binding");
|
|
218
|
+
return stripUndefinedBinding(validated);
|
|
219
|
+
}
|
|
220
|
+
/** Parses stored or shipped sidecar data into the current domain value. */
|
|
221
|
+
function readCodexAppServerThreadBinding(value) {
|
|
222
|
+
const result = threadBindingSchema.safeParse(value);
|
|
223
|
+
if (!result.success) return;
|
|
224
|
+
return result.data;
|
|
225
|
+
}
|
|
226
|
+
function stripUndefinedBinding(binding) {
|
|
227
|
+
return stripUndefinedValue(binding);
|
|
228
|
+
}
|
|
229
|
+
function stripUndefinedValue(value) {
|
|
230
|
+
if (Array.isArray(value)) return value.map(stripUndefinedValue);
|
|
231
|
+
if (!value || typeof value !== "object") return value;
|
|
232
|
+
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0).map(([key, entry]) => [key, stripUndefinedValue(entry)]));
|
|
233
|
+
}
|
|
234
|
+
function readCodexBindingTimestamp(value) {
|
|
235
|
+
return optionalTimestampSchema.parse(value);
|
|
236
|
+
}
|
|
237
|
+
/** The same physical-generation check serves execution and read-only projections. */
|
|
238
|
+
function readCurrentCodexAppServerBinding(state, identity) {
|
|
239
|
+
const key = bindingStoreKey(identity);
|
|
240
|
+
const raw = state.lookup(key);
|
|
241
|
+
const stored = readStoredCodexAppServerBinding(raw);
|
|
242
|
+
if (raw !== void 0 && !stored) throw new Error(`Invalid Codex app-server binding row: ${key}`);
|
|
243
|
+
return stored?.state === "active" && ownsStoredSessionGeneration(identity, stored) ? stored.binding : void 0;
|
|
244
|
+
}
|
|
245
|
+
var CodexSupervisionBindingReplacementError = class extends Error {
|
|
246
|
+
constructor(threadId, operation) {
|
|
247
|
+
super(`Refusing to replace supervised Codex thread ${threadId} while ${operation}; its native user-home connection and model ownership must be preserved`);
|
|
248
|
+
this.name = "CodexSupervisionBindingReplacementError";
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
function assertCodexBindingMayBeReplaced(binding, operation, expected) {
|
|
252
|
+
if (expected) throw new AgentHarnessPreflightError(`Codex native model ownership prevents ${operation}. Continue or compact the original session in its native runtime, or create a new chat with a concrete model; the original binding was preserved.`);
|
|
253
|
+
if (binding?.connectionScope === "supervision") throw new CodexSupervisionBindingReplacementError(binding.threadId, operation);
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
export { readCodexAppServerThreadBinding as a, readStoredCodexAppServerBinding as c, validateBindingForWrite as d, ownsStoredSessionGeneration as i, sessionBindingIdentity as l, assertCodexBindingMayBeReplaced as n, readCodexBindingTimestamp as o, bindingStoreKey as r, readCurrentCodexAppServerBinding as s, CodexSupervisionBindingReplacementError as t, stripUndefinedBinding as u };
|