@openclaw/codex 2026.6.11-beta.2 → 2026.7.1-1
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/{app-server-policy-BPTiVNsW.js → app-server-policy-C968Kgin.js} +5 -5
- package/dist/{attempt-notifications-BYnndyFl.js → attempt-notifications-BGsEIIDI.js} +29 -40
- package/dist/{command-handlers-DEPTJYk0.js → command-handlers-Dv-pzAmg.js} +278 -237
- package/dist/command-rpc-eLM_mtC7.js +784 -0
- package/dist/compact-4mVBriKT.js +603 -0
- package/dist/{computer-use-ClrJwoFp.js → computer-use-Bmaz333N.js} +3 -3
- package/dist/{config-CszD0vP3.js → config-CYEDnLJ2.js} +44 -18
- package/dist/conversation-binding-data-BHRpYbX3.js +121 -0
- package/dist/doctor-contract-api.js +590 -22
- package/dist/harness.js +29 -10
- package/dist/index.js +1134 -35
- package/dist/{media-understanding-provider-ZUQHN7gT.js → media-understanding-provider-BHOu9-Gg.js} +13 -8
- package/dist/media-understanding-provider.js +1 -1
- package/dist/{models-CAmfBWRl.js → models-DDmO1zwd.js} +2 -2
- package/dist/notification-correlation-Bo7KB3ks.js +35 -0
- package/dist/{plugin-app-cache-key-C9ILt7bl.js → plugin-app-cache-key-BrhVdeEf.js} +13 -5
- package/dist/{protocol-dh-ETiNd.js → protocol-2POPqAY4.js} +2 -1
- package/dist/{protocol-validators-B19q5BIX.js → protocol-validators-dZQ-UTOa.js} +205 -56
- package/dist/provider-capabilities-DzI8fgEu.js +6172 -0
- package/dist/provider-catalog.js +4 -2
- package/dist/{provider-B-OHpbD3.js → provider-zjPfx5Fs.js} +94 -23
- package/dist/provider.js +2 -2
- package/dist/{request-Dcd452Nk.js → request-BcJyl8KL.js} +2 -2
- package/dist/{run-attempt-CXxtFC9d.js → run-attempt-DNSNk_G8.js} +1250 -2992
- package/dist/{sandbox-guard-3tnjhjFb.js → sandbox-guard-DA2TQfZW.js} +5 -3
- package/dist/session-binding-C1ZXdP-x.js +627 -0
- package/dist/session-binding-meta-B7aEMU7g.js +6 -0
- package/dist/shared-client-4ICy3U6d.js +1853 -0
- package/dist/{side-question-C-DhgJOd.js → side-question-CMOpEhvY.js} +134 -142
- package/dist/{thread-lifecycle-DtT3-ehU.js → thread-lifecycle-qWE88Dn2.js} +803 -481
- package/dist/{web-search-provider.runtime-CkwxrXQj.js → web-search-provider.runtime-BSlriav6.js} +3 -3
- package/npm-shrinkwrap.json +34 -34
- package/openclaw.plugin.json +23 -3
- package/package.json +9 -6
- package/dist/client-CLrtWgrD.js +0 -729
- package/dist/client-factory-Bm6HsGob.js +0 -18
- package/dist/compact-aQJ0ZKhe.js +0 -278
- package/dist/conversation-binding-t0XMLz-j.js +0 -1557
- package/dist/provider-capabilities-D7hnTO76.js +0 -3201
- package/dist/rate-limit-cache-C7qmZ0Jh.js +0 -26
- package/dist/session-binding-HOuPt-E0.js +0 -338
- package/dist/shared-client-Dtx5i7Ez.js +0 -1013
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { resolvePositiveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
3
|
-
import { normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
3
|
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
5
4
|
import { readFileSync } from "node:fs";
|
|
6
|
-
import { hostname } from "node:os";
|
|
5
|
+
import { homedir, hostname } from "node:os";
|
|
7
6
|
import { resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
|
|
8
7
|
import { resolveExecApprovalsFromFile } from "openclaw/plugin-sdk/exec-approvals-runtime";
|
|
9
8
|
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
|
|
10
9
|
import { buildSecretInputSchema, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
10
|
+
import { normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
11
|
import { detectWindowsSpawnCommandInlineArgs } from "openclaw/plugin-sdk/windows-spawn";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
//#region extensions/codex/src/app-server/config.ts
|
|
@@ -27,14 +27,14 @@ const DEFAULT_CODEX_COMPUTER_USE_MCP_SERVER_NAME = "computer-use";
|
|
|
27
27
|
const DEFAULT_CODEX_COMPUTER_USE_MARKETPLACE_DISCOVERY_TIMEOUT_MS = 6e4;
|
|
28
28
|
const DEFAULT_CODEX_APP_SERVER_NETWORK_PROXY_PROFILE_PREFIX = "openclaw-network";
|
|
29
29
|
const codexAppServerTransportSchema = z.enum(["stdio", "websocket"]);
|
|
30
|
+
const codexAppServerHomeScopeSchema = z.enum(["agent", "user"]);
|
|
30
31
|
const SecretInputSchema = buildSecretInputSchema();
|
|
31
32
|
const codexAppServerPolicyModeSchema = z.enum(["yolo", "guardian"]);
|
|
32
|
-
const codexAppServerApprovalPolicySchema = z.enum([
|
|
33
|
+
const codexAppServerApprovalPolicySchema = z.preprocess((value) => value === "on-failure" ? "on-request" : value, z.enum([
|
|
33
34
|
"never",
|
|
34
35
|
"on-request",
|
|
35
|
-
"on-failure",
|
|
36
36
|
"untrusted"
|
|
37
|
-
]);
|
|
37
|
+
]));
|
|
38
38
|
const codexAppServerSandboxSchema = z.enum([
|
|
39
39
|
"read-only",
|
|
40
40
|
"workspace-write",
|
|
@@ -46,7 +46,11 @@ const codexAppServerApprovalsReviewerSchema = z.enum([
|
|
|
46
46
|
"guardian_subagent"
|
|
47
47
|
]);
|
|
48
48
|
const codexDynamicToolsLoadingSchema = z.enum(["searchable", "direct"]);
|
|
49
|
-
const codexPluginDestructivePolicySchema = z.union([
|
|
49
|
+
const codexPluginDestructivePolicySchema = z.union([
|
|
50
|
+
z.boolean(),
|
|
51
|
+
z.literal("auto"),
|
|
52
|
+
z.literal("ask")
|
|
53
|
+
]);
|
|
50
54
|
const codexAppServerServiceTierSchema = z.preprocess((value) => value === null ? null : normalizeCodexServiceTier(value), z.string().trim().min(1).nullable().optional()).optional();
|
|
51
55
|
const codexAppServerExperimentalSchema = z.object({ sandboxExecServer: z.boolean().optional() }).strict();
|
|
52
56
|
const codexAppServerRemoteWorkspaceRootSchema = z.string().trim().min(1);
|
|
@@ -76,6 +80,7 @@ const codexPluginEntryConfigSchema = z.object({
|
|
|
76
80
|
}).strict();
|
|
77
81
|
const codexPluginsConfigSchema = z.object({
|
|
78
82
|
enabled: z.boolean().optional(),
|
|
83
|
+
allow_all_plugins: z.boolean().optional(),
|
|
79
84
|
allow_destructive_actions: codexPluginDestructivePolicySchema.optional(),
|
|
80
85
|
plugins: z.record(z.string(), codexPluginEntryConfigSchema).optional()
|
|
81
86
|
}).strict();
|
|
@@ -100,6 +105,7 @@ const codexPluginConfigSchema = z.object({
|
|
|
100
105
|
appServer: z.object({
|
|
101
106
|
mode: codexAppServerPolicyModeSchema.optional(),
|
|
102
107
|
transport: codexAppServerTransportSchema.optional(),
|
|
108
|
+
homeScope: codexAppServerHomeScopeSchema.optional(),
|
|
103
109
|
command: z.string().optional(),
|
|
104
110
|
args: z.union([z.array(z.string()), z.string()]).optional(),
|
|
105
111
|
url: z.string().optional(),
|
|
@@ -161,15 +167,16 @@ function resolveCodexPluginsPolicy(pluginConfig) {
|
|
|
161
167
|
return {
|
|
162
168
|
configured,
|
|
163
169
|
enabled,
|
|
170
|
+
allowAllPlugins: enabled && config?.allow_all_plugins === true,
|
|
164
171
|
allowDestructiveActions: destructivePolicy.allowDestructiveActions,
|
|
165
172
|
destructiveApprovalMode: destructivePolicy.destructiveApprovalMode,
|
|
166
173
|
pluginPolicies
|
|
167
174
|
};
|
|
168
175
|
}
|
|
169
176
|
function resolveCodexPluginDestructivePolicy(policy) {
|
|
170
|
-
if (policy === "auto") return {
|
|
177
|
+
if (policy === "auto" || policy === "ask") return {
|
|
171
178
|
allowDestructiveActions: true,
|
|
172
|
-
destructiveApprovalMode:
|
|
179
|
+
destructiveApprovalMode: policy
|
|
173
180
|
};
|
|
174
181
|
return {
|
|
175
182
|
allowDestructiveActions: policy,
|
|
@@ -180,6 +187,7 @@ function resolveCodexAppServerRuntimeOptions(params = {}) {
|
|
|
180
187
|
const env = params.env ?? process.env;
|
|
181
188
|
const config = readCodexPluginConfig(params.pluginConfig).appServer ?? {};
|
|
182
189
|
const transport = resolveTransport(config.transport);
|
|
190
|
+
const homeScope = config.homeScope === "user" ? "user" : "agent";
|
|
183
191
|
const configCommand = readNonEmptyString(config.command);
|
|
184
192
|
const envCommand = readNonEmptyString(env.OPENCLAW_CODEX_APP_SERVER_BIN);
|
|
185
193
|
const command = configCommand ?? envCommand ?? "codex";
|
|
@@ -218,7 +226,8 @@ function resolveCodexAppServerRuntimeOptions(params = {}) {
|
|
|
218
226
|
config: params.config,
|
|
219
227
|
env,
|
|
220
228
|
agentDir: params.agentDir,
|
|
221
|
-
codexConfigToml: params.codexConfigToml
|
|
229
|
+
codexConfigToml: params.codexConfigToml,
|
|
230
|
+
homeScope
|
|
222
231
|
});
|
|
223
232
|
const forceUserReviewer = !canUseModelBackedReviewer && (explicitApprovalsReviewer === "auto_review" || explicitApprovalsReviewer === "guardian_subagent" || explicitPolicyMode === "guardian" && explicitApprovalsReviewer !== "user") || execMode !== void 0 && execMode !== "full" && (execMode !== "auto" || !canUseModelBackedReviewer);
|
|
224
233
|
const forceGuardianReviewer = execMode === "auto" && canUseModelBackedReviewer;
|
|
@@ -255,6 +264,7 @@ function resolveCodexAppServerRuntimeOptions(params = {}) {
|
|
|
255
264
|
const serviceTier = normalizeCodexServiceTier(config.serviceTier);
|
|
256
265
|
const resolvedSandbox = forcedPolicy?.sandbox ?? configuredSandbox ?? defaultPolicy?.sandbox ?? (policyMode === "guardian" ? "workspace-write" : "danger-full-access");
|
|
257
266
|
if (transport === "websocket" && !url) throw new Error("plugins.entries.codex.config.appServer.url is required when appServer.transport is websocket");
|
|
267
|
+
if (transport === "websocket" && homeScope === "user") throw new Error("plugins.entries.codex.config.appServer.homeScope=user requires appServer.transport=stdio");
|
|
258
268
|
assertCodexAppServerConnectionClassConfig({
|
|
259
269
|
connectionClass,
|
|
260
270
|
authToken,
|
|
@@ -267,6 +277,7 @@ function resolveCodexAppServerRuntimeOptions(params = {}) {
|
|
|
267
277
|
return {
|
|
268
278
|
start: {
|
|
269
279
|
transport,
|
|
280
|
+
homeScope,
|
|
270
281
|
command,
|
|
271
282
|
commandSource,
|
|
272
283
|
args: args.length > 0 ? args : [
|
|
@@ -366,6 +377,7 @@ function codexAppServerStartOptionsKey(options, params = {}) {
|
|
|
366
377
|
transport: options.transport,
|
|
367
378
|
command: options.command,
|
|
368
379
|
commandSource: options.commandSource ?? null,
|
|
380
|
+
managedFallbackCommandPaths: [...options.managedFallbackCommandPaths ?? []],
|
|
369
381
|
args: options.args,
|
|
370
382
|
url: options.url ?? null,
|
|
371
383
|
authToken: hashSecretForKey(options.authToken, "authToken"),
|
|
@@ -430,10 +442,11 @@ function resolveCodexAppServerNetworkProxy(config, sandbox) {
|
|
|
430
442
|
function resolveNetworkProxyPermissionProfileName(config, profile) {
|
|
431
443
|
const explicitProfileName = readNonEmptyString(config.profileName);
|
|
432
444
|
if (explicitProfileName) return explicitProfileName;
|
|
433
|
-
|
|
445
|
+
const suffix = createHash("sha256").update(stableStringifyJson({
|
|
434
446
|
version: 1,
|
|
435
447
|
profile
|
|
436
|
-
})).digest("hex").slice(0, 16)
|
|
448
|
+
})).digest("hex").slice(0, 16);
|
|
449
|
+
return `${DEFAULT_CODEX_APP_SERVER_NETWORK_PROXY_PROFILE_PREFIX}-${suffix}`;
|
|
437
450
|
}
|
|
438
451
|
function fingerprintCodexAppServerNetworkProxyConfigPatch(configPatch) {
|
|
439
452
|
return createHash("sha256").update(stableStringifyJson(configPatch)).digest("hex");
|
|
@@ -458,12 +471,16 @@ function withMcpElicitationsApprovalPolicy(policy) {
|
|
|
458
471
|
if (policy === "never") return { granular: {
|
|
459
472
|
mcp_elicitations: true,
|
|
460
473
|
rules: false,
|
|
461
|
-
sandbox_approval: false
|
|
474
|
+
sandbox_approval: false,
|
|
475
|
+
request_permissions: false,
|
|
476
|
+
skill_approval: false
|
|
462
477
|
} };
|
|
463
478
|
return { granular: {
|
|
464
479
|
mcp_elicitations: true,
|
|
465
480
|
rules: true,
|
|
466
|
-
sandbox_approval: true
|
|
481
|
+
sandbox_approval: true,
|
|
482
|
+
request_permissions: true,
|
|
483
|
+
skill_approval: true
|
|
467
484
|
} };
|
|
468
485
|
}
|
|
469
486
|
function resolveTransport(value) {
|
|
@@ -695,7 +712,9 @@ function globPatternMatches(value, pattern) {
|
|
|
695
712
|
return new RegExp(regex).test(value);
|
|
696
713
|
}
|
|
697
714
|
function normalizeRequirementsApprovalPolicy(value) {
|
|
698
|
-
|
|
715
|
+
const normalized = value.trim().toLowerCase();
|
|
716
|
+
if (normalized === "on-failure") return "on-request";
|
|
717
|
+
return resolveApprovalPolicy(normalized);
|
|
699
718
|
}
|
|
700
719
|
function normalizeRequirementsApprovalsReviewer(value) {
|
|
701
720
|
return resolveApprovalsReviewer(value.trim().toLowerCase());
|
|
@@ -703,7 +722,6 @@ function normalizeRequirementsApprovalsReviewer(value) {
|
|
|
703
722
|
function selectGuardianApprovalPolicy(allowedApprovalPolicies, execModeRequiringPromptingApprovals) {
|
|
704
723
|
if (allowedApprovalPolicies === void 0 || allowedApprovalPolicies.has("on-request")) return "on-request";
|
|
705
724
|
if (execModeRequiringPromptingApprovals) throw new Error(`tools.exec.mode=${execModeRequiringPromptingApprovals} requires Codex app-server prompting approvals`);
|
|
706
|
-
if (allowedApprovalPolicies.has("on-failure")) return "on-failure";
|
|
707
725
|
if (allowedApprovalPolicies.has("untrusted")) return "untrusted";
|
|
708
726
|
if (allowedApprovalPolicies.has("never")) return "never";
|
|
709
727
|
return "on-request";
|
|
@@ -728,7 +746,8 @@ function isTrustedCodexModelBackedApprovalsReviewerProvider(provider, params) {
|
|
|
728
746
|
env: params.env,
|
|
729
747
|
model: params.model,
|
|
730
748
|
agentDir: params.agentDir,
|
|
731
|
-
codexConfigToml: params.codexConfigToml
|
|
749
|
+
codexConfigToml: params.codexConfigToml,
|
|
750
|
+
homeScope: params.homeScope
|
|
732
751
|
});
|
|
733
752
|
}
|
|
734
753
|
function readCodexBaseUrlOverridesForModelBackedReview(params) {
|
|
@@ -761,10 +780,16 @@ function readCodexAppServerConfigToml(params) {
|
|
|
761
780
|
}
|
|
762
781
|
}
|
|
763
782
|
function resolveCodexAppServerConfigPath(params) {
|
|
783
|
+
if (params.homeScope === "user") return path.join(resolveCodexAppServerUserHomeDir(params.env), CODEX_CONFIG_TOML_FILENAME);
|
|
764
784
|
const agentDir = readNonEmptyString(params.agentDir);
|
|
765
785
|
const codexHome = agentDir ? path.join(path.resolve(agentDir), CODEX_APP_SERVER_HOME_DIRNAME) : void 0;
|
|
766
786
|
return codexHome ? path.join(codexHome, CODEX_CONFIG_TOML_FILENAME) : void 0;
|
|
767
787
|
}
|
|
788
|
+
/** Resolves the native user Codex home used by Desktop and the CLI. */
|
|
789
|
+
function resolveCodexAppServerUserHomeDir(env = process.env, homedir$1 = homedir) {
|
|
790
|
+
const configured = readNonEmptyString(env.CODEX_HOME);
|
|
791
|
+
return path.resolve(configured ?? path.join(homedir$1(), ".codex"));
|
|
792
|
+
}
|
|
768
793
|
function readErrorCode(error) {
|
|
769
794
|
return error && typeof error === "object" && "code" in error ? String(error.code) : void 0;
|
|
770
795
|
}
|
|
@@ -855,7 +880,8 @@ function selectGuardianSandbox(allowedSandboxModes) {
|
|
|
855
880
|
return "workspace-write";
|
|
856
881
|
}
|
|
857
882
|
function resolveApprovalPolicy(value) {
|
|
858
|
-
|
|
883
|
+
if (value === "on-failure") return "on-request";
|
|
884
|
+
return value === "on-request" || value === "untrusted" || value === "never" ? value : void 0;
|
|
859
885
|
}
|
|
860
886
|
function resolveSandbox(value) {
|
|
861
887
|
return value === "read-only" || value === "workspace-write" || value === "danger-full-access" ? value : void 0;
|
|
@@ -1109,4 +1135,4 @@ function splitShellWords(value) {
|
|
|
1109
1135
|
return words;
|
|
1110
1136
|
}
|
|
1111
1137
|
//#endregion
|
|
1112
|
-
export {
|
|
1138
|
+
export { shouldAutoApproveCodexAppServerApprovals as _, isCodexAppServerApprovalPolicyAllowedByRequirements as a, isTrustedCodexModelBackedOpenAIProvider as c, resolveCodexAppServerRuntimeOptions as d, resolveCodexAppServerUserHomeDir as f, resolveOpenClawExecPolicyForCodexAppServer as g, resolveCodexPluginsPolicy as h, codexSandboxPolicyForTurn as i, normalizeCodexServiceTier as l, resolveCodexModelBackedReviewerPolicyContext as m, canUseCodexModelBackedApprovalsReviewerForModel as n, isCodexFastServiceTier as o, resolveCodexComputerUseConfig as p, codexAppServerStartOptionsKey as r, isCodexSandboxExecServerEnabled as s, CODEX_PLUGINS_MARKETPLACE_NAME as t, readCodexPluginConfig as u, withMcpElicitationsApprovalPolicy as v };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
//#region extensions/codex/src/conversation-binding-data.ts
|
|
6
|
+
var conversation_binding_data_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
createCodexCliNodeConversationBindingData: () => createCodexCliNodeConversationBindingData,
|
|
8
|
+
createCodexConversationBindingData: () => createCodexConversationBindingData,
|
|
9
|
+
legacyCodexConversationBindingId: () => legacyCodexConversationBindingId,
|
|
10
|
+
readCodexConversationBindingData: () => readCodexConversationBindingData,
|
|
11
|
+
readCodexConversationBindingDataRecord: () => readCodexConversationBindingDataRecord,
|
|
12
|
+
resolveCodexDefaultWorkspaceDir: () => resolveCodexDefaultWorkspaceDir
|
|
13
|
+
});
|
|
14
|
+
const APP_SERVER_BINDING_DATA_VERSION = 2;
|
|
15
|
+
const CLI_BINDING_DATA_VERSION = 1;
|
|
16
|
+
function createCodexConversationBindingData(params) {
|
|
17
|
+
const agentId = params.agentId?.trim();
|
|
18
|
+
const agentDir = params.agentDir?.trim();
|
|
19
|
+
const source = readConversationSource(params.source);
|
|
20
|
+
const start = readConversationStart(params.start);
|
|
21
|
+
return {
|
|
22
|
+
kind: "codex-app-server-session",
|
|
23
|
+
version: APP_SERVER_BINDING_DATA_VERSION,
|
|
24
|
+
bindingId: params.bindingId?.trim() || randomUUID(),
|
|
25
|
+
workspaceDir: params.workspaceDir,
|
|
26
|
+
...agentId ? { agentId } : {},
|
|
27
|
+
...agentDir ? { agentDir } : {},
|
|
28
|
+
...source ? { source } : {},
|
|
29
|
+
...start ? { start } : {}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function createCodexCliNodeConversationBindingData(params) {
|
|
33
|
+
const agentId = params.agentId?.trim();
|
|
34
|
+
const cwd = params.cwd?.trim();
|
|
35
|
+
return {
|
|
36
|
+
kind: "codex-cli-node-session",
|
|
37
|
+
version: CLI_BINDING_DATA_VERSION,
|
|
38
|
+
nodeId: params.nodeId,
|
|
39
|
+
sessionId: params.sessionId,
|
|
40
|
+
...agentId ? { agentId } : {},
|
|
41
|
+
...cwd ? { cwd } : {}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function readCodexConversationBindingData(binding) {
|
|
45
|
+
const data = binding?.data;
|
|
46
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) return;
|
|
47
|
+
return readCodexConversationBindingDataRecord(data);
|
|
48
|
+
}
|
|
49
|
+
function readCodexConversationBindingDataRecord(data) {
|
|
50
|
+
if (data.kind === "codex-cli-node-session") {
|
|
51
|
+
if (data.version !== CLI_BINDING_DATA_VERSION || typeof data.nodeId !== "string" || !data.nodeId.trim() || typeof data.sessionId !== "string" || !data.sessionId.trim()) return;
|
|
52
|
+
return {
|
|
53
|
+
kind: "codex-cli-node-session",
|
|
54
|
+
version: CLI_BINDING_DATA_VERSION,
|
|
55
|
+
nodeId: data.nodeId.trim(),
|
|
56
|
+
sessionId: data.sessionId.trim(),
|
|
57
|
+
agentId: typeof data.agentId === "string" && data.agentId.trim() ? data.agentId.trim() : void 0,
|
|
58
|
+
cwd: typeof data.cwd === "string" && data.cwd.trim() ? data.cwd.trim() : void 0
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (data.kind !== "codex-app-server-session") return;
|
|
62
|
+
const bindingId = data.version === APP_SERVER_BINDING_DATA_VERSION && typeof data.bindingId === "string" && data.bindingId.trim() ? data.bindingId.trim() : data.version === 1 && typeof data.sessionFile === "string" && data.sessionFile.trim() ? legacyCodexConversationBindingId(data.sessionFile) : void 0;
|
|
63
|
+
if (!bindingId) return;
|
|
64
|
+
const start = readConversationStart(asOptionalRecord(data.start));
|
|
65
|
+
const source = readConversationSource(asOptionalRecord(data.source));
|
|
66
|
+
const legacyBinding = data.version === 1;
|
|
67
|
+
return {
|
|
68
|
+
kind: "codex-app-server-session",
|
|
69
|
+
version: APP_SERVER_BINDING_DATA_VERSION,
|
|
70
|
+
bindingId,
|
|
71
|
+
workspaceDir: typeof data.workspaceDir === "string" && data.workspaceDir.trim() ? data.workspaceDir : process.cwd(),
|
|
72
|
+
agentId: typeof data.agentId === "string" && data.agentId.trim() ? data.agentId.trim() : void 0,
|
|
73
|
+
agentDir: typeof data.agentDir === "string" && data.agentDir.trim() ? data.agentDir.trim() : void 0,
|
|
74
|
+
...source ? { source } : {},
|
|
75
|
+
...start ? { start } : {},
|
|
76
|
+
...legacyBinding ? { legacyBinding: true } : {}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function readConversationSource(value) {
|
|
80
|
+
const agentId = readString(value, "agentId");
|
|
81
|
+
const sessionId = readString(value, "sessionId");
|
|
82
|
+
const threadId = readString(value, "threadId");
|
|
83
|
+
const sessionKey = readString(value, "sessionKey");
|
|
84
|
+
if (!agentId || !sessionId || !threadId) return;
|
|
85
|
+
return {
|
|
86
|
+
agentId,
|
|
87
|
+
sessionId,
|
|
88
|
+
threadId,
|
|
89
|
+
...sessionKey ? { sessionKey } : {}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Doctor/runtime v1 decoder key for shipped conversation bindings that stored a file locator. */
|
|
93
|
+
function legacyCodexConversationBindingId(sessionFile) {
|
|
94
|
+
return `legacy-${createHash("sha256").update(sessionFile).digest("base64url")}`;
|
|
95
|
+
}
|
|
96
|
+
function resolveCodexDefaultWorkspaceDir(pluginConfig) {
|
|
97
|
+
return readString(asOptionalRecord(asOptionalRecord(pluginConfig)?.appServer), "defaultWorkspaceDir") ?? process.cwd();
|
|
98
|
+
}
|
|
99
|
+
function readString(record, key) {
|
|
100
|
+
const value = record?.[key];
|
|
101
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
102
|
+
}
|
|
103
|
+
function readConversationStart(value) {
|
|
104
|
+
const read = (key) => {
|
|
105
|
+
const candidate = value?.[key];
|
|
106
|
+
return typeof candidate === "string" && candidate.trim() ? candidate.trim() : void 0;
|
|
107
|
+
};
|
|
108
|
+
const start = {
|
|
109
|
+
id: read("id"),
|
|
110
|
+
threadId: read("threadId"),
|
|
111
|
+
model: read("model"),
|
|
112
|
+
modelProvider: read("modelProvider"),
|
|
113
|
+
authProfileId: read("authProfileId")
|
|
114
|
+
};
|
|
115
|
+
return start.id ? {
|
|
116
|
+
...start,
|
|
117
|
+
id: start.id
|
|
118
|
+
} : void 0;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { readCodexConversationBindingDataRecord as a, readCodexConversationBindingData as i, createCodexCliNodeConversationBindingData as n, resolveCodexDefaultWorkspaceDir as o, createCodexConversationBindingData as r, conversation_binding_data_exports as t };
|