@gakr-gakr/codex 0.1.0 → 0.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.
Files changed (115) hide show
  1. package/dist/client-DNN2uyJW.js +642 -0
  2. package/dist/client-factory-Bu9OClHJ.js +9 -0
  3. package/dist/command-formatters-BpPOTePl.js +520 -0
  4. package/dist/command-handlers-BBs7Vws9.js +1533 -0
  5. package/dist/compact-CDboBy7o.js +329 -0
  6. package/dist/computer-use-DCZB46Sw.js +367 -0
  7. package/dist/config-CLMSw0p2.js +510 -0
  8. package/dist/doctor-contract-api.js +53 -0
  9. package/dist/harness.js +51 -0
  10. package/dist/index.js +1171 -0
  11. package/dist/media-understanding-provider.js +335 -0
  12. package/dist/models-jLA2SIvd.js +110 -0
  13. package/dist/node-cli-sessions-BLRDs_US.js +1216 -0
  14. package/dist/plugin-activation-CEy_oYpx.js +452 -0
  15. package/dist/prompt-overlay.js +12 -0
  16. package/dist/protocol-C9UWI98H.js +9 -0
  17. package/dist/protocol-validators-BGBspNmF.js +5988 -0
  18. package/dist/provider-catalog.js +84 -0
  19. package/dist/provider-discovery.js +33 -0
  20. package/dist/provider.js +150 -0
  21. package/dist/rate-limit-cache-9LxQdE0K.js +24 -0
  22. package/dist/request-DbSPeTcV.js +89 -0
  23. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  24. package/dist/run-attempt-BoEwzQCv.js +5463 -0
  25. package/dist/session-binding-e2GFp9VH.js +222 -0
  26. package/dist/shared-client-D7Vy0glq.js +631 -0
  27. package/dist/side-question-BDLuEzFP.js +668 -0
  28. package/dist/test-api.js +49 -0
  29. package/dist/thread-lifecycle-Clo0EHMk.js +1565 -0
  30. package/dist/vision-tools-Cofrv35p.js +1379 -0
  31. package/package.json +16 -1
  32. package/doctor-contract-api.ts +0 -68
  33. package/harness.ts +0 -72
  34. package/index.ts +0 -124
  35. package/media-understanding-provider.ts +0 -521
  36. package/prompt-overlay.ts +0 -21
  37. package/provider-catalog.ts +0 -83
  38. package/provider-discovery.ts +0 -45
  39. package/provider.ts +0 -243
  40. package/src/app-server/app-inventory-cache.ts +0 -324
  41. package/src/app-server/approval-bridge.ts +0 -1211
  42. package/src/app-server/auth-bridge.ts +0 -614
  43. package/src/app-server/capabilities.ts +0 -27
  44. package/src/app-server/client-factory.ts +0 -24
  45. package/src/app-server/client.ts +0 -715
  46. package/src/app-server/compact.ts +0 -512
  47. package/src/app-server/computer-use.ts +0 -683
  48. package/src/app-server/config.ts +0 -1038
  49. package/src/app-server/context-engine-projection.ts +0 -403
  50. package/src/app-server/dynamic-tool-diagnostics.ts +0 -73
  51. package/src/app-server/dynamic-tool-profile.ts +0 -70
  52. package/src/app-server/dynamic-tools.ts +0 -623
  53. package/src/app-server/elicitation-bridge.ts +0 -783
  54. package/src/app-server/event-projector.ts +0 -2065
  55. package/src/app-server/image-payload-sanitizer.ts +0 -167
  56. package/src/app-server/local-runtime-attribution.ts +0 -39
  57. package/src/app-server/managed-binary.ts +0 -193
  58. package/src/app-server/models.ts +0 -172
  59. package/src/app-server/native-hook-relay.ts +0 -150
  60. package/src/app-server/native-subagent-task-mirror.ts +0 -497
  61. package/src/app-server/plugin-activation.ts +0 -283
  62. package/src/app-server/plugin-app-cache-key.ts +0 -74
  63. package/src/app-server/plugin-approval-roundtrip.ts +0 -122
  64. package/src/app-server/plugin-inventory.ts +0 -357
  65. package/src/app-server/plugin-thread-config.ts +0 -455
  66. package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +0 -33
  67. package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +0 -199
  68. package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +0 -102
  69. package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +0 -227
  70. package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +0 -2630
  71. package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +0 -2630
  72. package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +0 -1659
  73. package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +0 -1655
  74. package/src/app-server/protocol-validators.ts +0 -203
  75. package/src/app-server/protocol.ts +0 -520
  76. package/src/app-server/rate-limit-cache.ts +0 -48
  77. package/src/app-server/rate-limits.ts +0 -583
  78. package/src/app-server/request.ts +0 -73
  79. package/src/app-server/run-attempt.ts +0 -4862
  80. package/src/app-server/session-binding.ts +0 -398
  81. package/src/app-server/session-history.ts +0 -44
  82. package/src/app-server/shared-client.ts +0 -289
  83. package/src/app-server/side-question.ts +0 -1009
  84. package/src/app-server/test-support.ts +0 -48
  85. package/src/app-server/thread-lifecycle.ts +0 -959
  86. package/src/app-server/timeout.ts +0 -9
  87. package/src/app-server/tool-progress-normalization.ts +0 -77
  88. package/src/app-server/trajectory.ts +0 -368
  89. package/src/app-server/transcript-mirror.ts +0 -208
  90. package/src/app-server/transport-stdio.ts +0 -107
  91. package/src/app-server/transport-websocket.ts +0 -90
  92. package/src/app-server/transport.ts +0 -117
  93. package/src/app-server/user-input-bridge.ts +0 -316
  94. package/src/app-server/version.ts +0 -4
  95. package/src/app-server/vision-tools.ts +0 -12
  96. package/src/command-account.ts +0 -544
  97. package/src/command-formatters.ts +0 -426
  98. package/src/command-handlers.ts +0 -2021
  99. package/src/command-plugins-management.ts +0 -137
  100. package/src/command-rpc.ts +0 -142
  101. package/src/commands.ts +0 -65
  102. package/src/conversation-binding-data.ts +0 -124
  103. package/src/conversation-binding.ts +0 -561
  104. package/src/conversation-control.ts +0 -303
  105. package/src/conversation-turn-collector.ts +0 -186
  106. package/src/conversation-turn-input.ts +0 -106
  107. package/src/migration/apply.ts +0 -501
  108. package/src/migration/helpers.ts +0 -55
  109. package/src/migration/plan.ts +0 -461
  110. package/src/migration/provider.ts +0 -41
  111. package/src/migration/source.ts +0 -643
  112. package/src/migration/targets.ts +0 -25
  113. package/src/node-cli-sessions.ts +0 -711
  114. package/test-api.ts +0 -95
  115. package/tsconfig.json +0 -16
@@ -1,398 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import { embeddedAgentLog } from "autobot/plugin-sdk/agent-harness-runtime";
3
- import {
4
- ensureAuthProfileStore,
5
- resolveDefaultAgentDir,
6
- resolveProviderIdForAuth,
7
- type AuthProfileStore,
8
- } from "autobot/plugin-sdk/agent-runtime";
9
- import {
10
- CODEX_PLUGINS_MARKETPLACE_NAME,
11
- normalizeCodexServiceTier,
12
- type CodexAppServerApprovalPolicy,
13
- type CodexAppServerSandboxMode,
14
- } from "./config.js";
15
- import type { PluginAppPolicyContext } from "./plugin-thread-config.js";
16
- import type { CodexServiceTier } from "./protocol.js";
17
-
18
- const CODEX_APP_SERVER_NATIVE_AUTH_PROVIDER = "openai-codex";
19
- const PUBLIC_OPENAI_MODEL_PROVIDER = "openai";
20
-
21
- type ProviderAuthAliasLookupParams = Parameters<typeof resolveProviderIdForAuth>[1];
22
- type ProviderAuthAliasConfig = NonNullable<ProviderAuthAliasLookupParams>["config"];
23
-
24
- export type CodexAppServerAuthProfileLookup = {
25
- authProfileId?: string;
26
- authProfileStore?: AuthProfileStore;
27
- agentDir?: string;
28
- config?: ProviderAuthAliasConfig;
29
- };
30
-
31
- export type CodexAppServerThreadBinding = {
32
- schemaVersion: 1;
33
- threadId: string;
34
- sessionFile: string;
35
- cwd: string;
36
- authProfileId?: string;
37
- model?: string;
38
- modelProvider?: string;
39
- approvalPolicy?: CodexAppServerApprovalPolicy;
40
- sandbox?: CodexAppServerSandboxMode;
41
- serviceTier?: CodexServiceTier;
42
- dynamicToolsFingerprint?: string;
43
- userMcpServersFingerprint?: string;
44
- mcpServersFingerprint?: string;
45
- pluginAppsFingerprint?: string;
46
- pluginAppsInputFingerprint?: string;
47
- pluginAppPolicyContext?: PluginAppPolicyContext;
48
- contextEngine?: CodexAppServerContextEngineBinding;
49
- createdAt: string;
50
- updatedAt: string;
51
- };
52
-
53
- export type CodexAppServerContextEngineBinding = {
54
- schemaVersion: 1;
55
- engineId: string;
56
- policyFingerprint: string;
57
- projection?: CodexAppServerContextEngineProjectionBinding;
58
- };
59
-
60
- export type CodexAppServerContextEngineProjectionBinding = {
61
- schemaVersion: 1;
62
- mode: "thread_bootstrap";
63
- epoch: string;
64
- fingerprint?: string;
65
- };
66
-
67
- export function resolveCodexAppServerBindingPath(sessionFile: string): string {
68
- return `${sessionFile}.codex-app-server.json`;
69
- }
70
-
71
- export async function readCodexAppServerBinding(
72
- sessionFile: string,
73
- lookup: Omit<CodexAppServerAuthProfileLookup, "authProfileId"> = {},
74
- ): Promise<CodexAppServerThreadBinding | undefined> {
75
- const path = resolveCodexAppServerBindingPath(sessionFile);
76
- let raw: string;
77
- try {
78
- raw = await fs.readFile(path, "utf8");
79
- } catch (error) {
80
- if (isNotFound(error)) {
81
- return undefined;
82
- }
83
- embeddedAgentLog.warn("failed to read codex app-server binding", { path, error });
84
- return undefined;
85
- }
86
- try {
87
- const parsed = JSON.parse(raw) as Partial<CodexAppServerThreadBinding>;
88
- if (parsed.schemaVersion !== 1 || typeof parsed.threadId !== "string") {
89
- return undefined;
90
- }
91
- const authProfileId =
92
- typeof parsed.authProfileId === "string" ? parsed.authProfileId : undefined;
93
- return {
94
- schemaVersion: 1,
95
- threadId: parsed.threadId,
96
- sessionFile,
97
- cwd: typeof parsed.cwd === "string" ? parsed.cwd : "",
98
- authProfileId,
99
- model: typeof parsed.model === "string" ? parsed.model : undefined,
100
- modelProvider: normalizeCodexAppServerBindingModelProvider({
101
- ...lookup,
102
- authProfileId,
103
- modelProvider: typeof parsed.modelProvider === "string" ? parsed.modelProvider : undefined,
104
- }),
105
- approvalPolicy: readApprovalPolicy(parsed.approvalPolicy),
106
- sandbox: readSandboxMode(parsed.sandbox),
107
- serviceTier: readServiceTier(parsed.serviceTier),
108
- dynamicToolsFingerprint:
109
- typeof parsed.dynamicToolsFingerprint === "string"
110
- ? parsed.dynamicToolsFingerprint
111
- : undefined,
112
- userMcpServersFingerprint:
113
- typeof parsed.userMcpServersFingerprint === "string"
114
- ? parsed.userMcpServersFingerprint
115
- : undefined,
116
- mcpServersFingerprint:
117
- typeof parsed.mcpServersFingerprint === "string" ? parsed.mcpServersFingerprint : undefined,
118
- pluginAppsFingerprint:
119
- typeof parsed.pluginAppsFingerprint === "string" ? parsed.pluginAppsFingerprint : undefined,
120
- pluginAppsInputFingerprint:
121
- typeof parsed.pluginAppsInputFingerprint === "string"
122
- ? parsed.pluginAppsInputFingerprint
123
- : undefined,
124
- pluginAppPolicyContext: readPluginAppPolicyContext(parsed.pluginAppPolicyContext),
125
- contextEngine: readContextEngineBinding(parsed.contextEngine),
126
- createdAt: typeof parsed.createdAt === "string" ? parsed.createdAt : new Date().toISOString(),
127
- updatedAt: typeof parsed.updatedAt === "string" ? parsed.updatedAt : new Date().toISOString(),
128
- };
129
- } catch (error) {
130
- embeddedAgentLog.warn("failed to parse codex app-server binding", { path, error });
131
- return undefined;
132
- }
133
- }
134
-
135
- export async function writeCodexAppServerBinding(
136
- sessionFile: string,
137
- binding: Omit<
138
- CodexAppServerThreadBinding,
139
- "schemaVersion" | "sessionFile" | "createdAt" | "updatedAt"
140
- > & {
141
- createdAt?: string;
142
- },
143
- lookup: Omit<CodexAppServerAuthProfileLookup, "authProfileId"> = {},
144
- ): Promise<void> {
145
- const now = new Date().toISOString();
146
- const payload: CodexAppServerThreadBinding = {
147
- schemaVersion: 1,
148
- sessionFile,
149
- threadId: binding.threadId,
150
- cwd: binding.cwd,
151
- authProfileId: binding.authProfileId,
152
- model: binding.model,
153
- modelProvider: normalizeCodexAppServerBindingModelProvider({
154
- ...lookup,
155
- authProfileId: binding.authProfileId,
156
- modelProvider: binding.modelProvider,
157
- }),
158
- approvalPolicy: binding.approvalPolicy,
159
- sandbox: binding.sandbox,
160
- serviceTier: binding.serviceTier,
161
- dynamicToolsFingerprint: binding.dynamicToolsFingerprint,
162
- userMcpServersFingerprint: binding.userMcpServersFingerprint,
163
- mcpServersFingerprint: binding.mcpServersFingerprint,
164
- pluginAppsFingerprint: binding.pluginAppsFingerprint,
165
- pluginAppsInputFingerprint: binding.pluginAppsInputFingerprint,
166
- pluginAppPolicyContext: binding.pluginAppPolicyContext,
167
- contextEngine: binding.contextEngine,
168
- createdAt: binding.createdAt ?? now,
169
- updatedAt: now,
170
- };
171
- await fs.writeFile(
172
- resolveCodexAppServerBindingPath(sessionFile),
173
- `${JSON.stringify(payload, null, 2)}\n`,
174
- );
175
- }
176
-
177
- function readContextEngineBinding(value: unknown): CodexAppServerContextEngineBinding | undefined {
178
- if (!value || typeof value !== "object" || Array.isArray(value)) {
179
- return undefined;
180
- }
181
- const record = value as Record<string, unknown>;
182
- if (
183
- record.schemaVersion !== 1 ||
184
- typeof record.engineId !== "string" ||
185
- typeof record.policyFingerprint !== "string"
186
- ) {
187
- return undefined;
188
- }
189
- return {
190
- schemaVersion: 1,
191
- engineId: record.engineId,
192
- policyFingerprint: record.policyFingerprint,
193
- projection: readContextEngineProjectionBinding(record.projection),
194
- };
195
- }
196
-
197
- function readContextEngineProjectionBinding(
198
- value: unknown,
199
- ): CodexAppServerContextEngineProjectionBinding | undefined {
200
- if (!value || typeof value !== "object" || Array.isArray(value)) {
201
- return undefined;
202
- }
203
- const record = value as Record<string, unknown>;
204
- if (
205
- record.schemaVersion !== 1 ||
206
- record.mode !== "thread_bootstrap" ||
207
- typeof record.epoch !== "string" ||
208
- !record.epoch.trim()
209
- ) {
210
- return undefined;
211
- }
212
- return {
213
- schemaVersion: 1,
214
- mode: "thread_bootstrap",
215
- epoch: record.epoch,
216
- fingerprint: typeof record.fingerprint === "string" ? record.fingerprint : undefined,
217
- };
218
- }
219
-
220
- function readPluginAppPolicyContext(value: unknown): PluginAppPolicyContext | undefined {
221
- if (!value || typeof value !== "object" || Array.isArray(value)) {
222
- return undefined;
223
- }
224
- const record = value as Record<string, unknown>;
225
- if (typeof record.fingerprint !== "string") {
226
- return undefined;
227
- }
228
- const apps = record.apps;
229
- if (!apps || typeof apps !== "object" || Array.isArray(apps)) {
230
- return undefined;
231
- }
232
- const parsedApps: PluginAppPolicyContext["apps"] = {};
233
- for (const [appId, rawEntry] of Object.entries(apps)) {
234
- if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) {
235
- return undefined;
236
- }
237
- const entry = rawEntry as Record<string, unknown>;
238
- if (
239
- "appId" in entry ||
240
- typeof entry.configKey !== "string" ||
241
- entry.marketplaceName !== CODEX_PLUGINS_MARKETPLACE_NAME ||
242
- typeof entry.pluginName !== "string" ||
243
- typeof entry.allowDestructiveActions !== "boolean" ||
244
- !Array.isArray(entry.mcpServerNames) ||
245
- entry.mcpServerNames.some((serverName) => typeof serverName !== "string")
246
- ) {
247
- return undefined;
248
- }
249
- parsedApps[appId] = {
250
- configKey: entry.configKey,
251
- marketplaceName: entry.marketplaceName,
252
- pluginName: entry.pluginName,
253
- allowDestructiveActions: entry.allowDestructiveActions,
254
- mcpServerNames: entry.mcpServerNames,
255
- };
256
- }
257
- const parsedPluginAppIds: PluginAppPolicyContext["pluginAppIds"] = {};
258
- const rawPluginAppIds = record.pluginAppIds;
259
- if (rawPluginAppIds && (typeof rawPluginAppIds !== "object" || Array.isArray(rawPluginAppIds))) {
260
- return undefined;
261
- }
262
- if (rawPluginAppIds && typeof rawPluginAppIds === "object") {
263
- for (const [configKey, appIds] of Object.entries(rawPluginAppIds)) {
264
- if (!Array.isArray(appIds) || appIds.some((appId) => typeof appId !== "string")) {
265
- return undefined;
266
- }
267
- parsedPluginAppIds[configKey] = appIds;
268
- }
269
- }
270
- return {
271
- fingerprint: record.fingerprint,
272
- apps: parsedApps,
273
- pluginAppIds: parsedPluginAppIds,
274
- };
275
- }
276
-
277
- export async function clearCodexAppServerBinding(sessionFile: string): Promise<void> {
278
- try {
279
- await fs.unlink(resolveCodexAppServerBindingPath(sessionFile));
280
- } catch (error) {
281
- if (!isNotFound(error)) {
282
- embeddedAgentLog.warn("failed to clear codex app-server binding", { sessionFile, error });
283
- }
284
- }
285
- }
286
-
287
- function isNotFound(error: unknown): boolean {
288
- return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
289
- }
290
-
291
- export function isCodexAppServerNativeAuthProfile(
292
- lookup: CodexAppServerAuthProfileLookup,
293
- ): boolean {
294
- const authProfileId = lookup.authProfileId?.trim();
295
- if (!authProfileId) {
296
- return false;
297
- }
298
- try {
299
- const credential = resolveCodexAppServerAuthProfileCredential({
300
- ...lookup,
301
- authProfileId,
302
- });
303
- return isCodexAppServerNativeAuthProvider({
304
- provider: credential?.provider,
305
- config: lookup.config,
306
- });
307
- } catch (error) {
308
- embeddedAgentLog.debug("failed to resolve codex app-server auth profile provider", {
309
- authProfileId,
310
- error,
311
- });
312
- return false;
313
- }
314
- }
315
-
316
- export function normalizeCodexAppServerBindingModelProvider(params: {
317
- authProfileId?: string;
318
- modelProvider?: string;
319
- authProfileStore?: AuthProfileStore;
320
- agentDir?: string;
321
- config?: ProviderAuthAliasConfig;
322
- }): string | undefined {
323
- const modelProvider = params.modelProvider?.trim();
324
- if (!modelProvider) {
325
- return undefined;
326
- }
327
- if (
328
- isCodexAppServerNativeAuthProfile(params) &&
329
- modelProvider.toLowerCase() === PUBLIC_OPENAI_MODEL_PROVIDER
330
- ) {
331
- return undefined;
332
- }
333
- return modelProvider;
334
- }
335
-
336
- function resolveCodexAppServerAuthProfileCredential(
337
- lookup: CodexAppServerAuthProfileLookup,
338
- ): AuthProfileStore["profiles"][string] | undefined {
339
- const authProfileId = lookup.authProfileId?.trim();
340
- if (!authProfileId) {
341
- return undefined;
342
- }
343
- const store =
344
- lookup.authProfileStore ??
345
- loadCodexAppServerAuthProfileStore({
346
- agentDir: lookup.agentDir,
347
- authProfileId,
348
- config: lookup.config,
349
- });
350
- return store.profiles[authProfileId];
351
- }
352
-
353
- function loadCodexAppServerAuthProfileStore(params: {
354
- agentDir: string | undefined;
355
- authProfileId: string;
356
- config?: ProviderAuthAliasConfig;
357
- }): AuthProfileStore {
358
- return ensureAuthProfileStore(
359
- params.agentDir?.trim() || resolveDefaultAgentDir(params.config ?? {}),
360
- {
361
- allowKeychainPrompt: false,
362
- config: params.config,
363
- externalCliProviderIds: [CODEX_APP_SERVER_NATIVE_AUTH_PROVIDER],
364
- externalCliProfileIds: [params.authProfileId],
365
- },
366
- );
367
- }
368
-
369
- function isCodexAppServerNativeAuthProvider(params: {
370
- provider?: string;
371
- config?: ProviderAuthAliasConfig;
372
- }): boolean {
373
- const provider = params.provider?.trim();
374
- return Boolean(
375
- provider &&
376
- resolveProviderIdForAuth(provider, { config: params.config }) ===
377
- CODEX_APP_SERVER_NATIVE_AUTH_PROVIDER,
378
- );
379
- }
380
-
381
- function readApprovalPolicy(value: unknown): CodexAppServerApprovalPolicy | undefined {
382
- return value === "never" ||
383
- value === "on-request" ||
384
- value === "on-failure" ||
385
- value === "untrusted"
386
- ? value
387
- : undefined;
388
- }
389
-
390
- function readSandboxMode(value: unknown): CodexAppServerSandboxMode | undefined {
391
- return value === "read-only" || value === "workspace-write" || value === "danger-full-access"
392
- ? value
393
- : undefined;
394
- }
395
-
396
- function readServiceTier(value: unknown): CodexServiceTier | undefined {
397
- return normalizeCodexServiceTier(value);
398
- }
@@ -1,44 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import type { SessionEntry } from "@earendil-works/pi-coding-agent";
3
- import {
4
- buildSessionContext,
5
- migrateSessionEntries,
6
- parseSessionEntries,
7
- } from "@earendil-works/pi-coding-agent";
8
- import type { AgentMessage } from "autobot/plugin-sdk/agent-harness-runtime";
9
- import { sanitizeCodexHistoryImagePayloads } from "./image-payload-sanitizer.js";
10
-
11
- function isMissingFileError(error: unknown): boolean {
12
- return Boolean(
13
- error &&
14
- typeof error === "object" &&
15
- "code" in error &&
16
- (error as { code?: unknown }).code === "ENOENT",
17
- );
18
- }
19
-
20
- export async function readCodexMirroredSessionHistoryMessages(
21
- sessionFile: string,
22
- ): Promise<AgentMessage[] | undefined> {
23
- try {
24
- const raw = await fs.readFile(sessionFile, "utf-8");
25
- const entries = parseSessionEntries(raw);
26
- const firstEntry = entries[0] as { type?: unknown; id?: unknown } | undefined;
27
- if (firstEntry?.type !== "session" || typeof firstEntry.id !== "string") {
28
- return undefined;
29
- }
30
- migrateSessionEntries(entries);
31
- const sessionEntries = entries.filter(
32
- (entry): entry is SessionEntry => entry.type !== "session",
33
- );
34
- return sanitizeCodexHistoryImagePayloads(
35
- buildSessionContext(sessionEntries).messages,
36
- "codex mirrored history",
37
- );
38
- } catch (error) {
39
- if (isMissingFileError(error)) {
40
- return [];
41
- }
42
- return undefined;
43
- }
44
- }