@kodelyth/codex 2026.5.42 → 2026.6.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 (138) hide show
  1. package/package.json +16 -1
  2. package/doctor-contract-api.test.ts +0 -44
  3. package/doctor-contract-api.ts +0 -68
  4. package/harness.ts +0 -72
  5. package/index.test.ts +0 -230
  6. package/index.ts +0 -66
  7. package/media-understanding-provider.test.ts +0 -486
  8. package/media-understanding-provider.ts +0 -521
  9. package/prompt-overlay-runtime-contract.test.ts +0 -48
  10. package/prompt-overlay.ts +0 -21
  11. package/provider-catalog.ts +0 -83
  12. package/provider-discovery.ts +0 -45
  13. package/provider.test.ts +0 -384
  14. package/provider.ts +0 -243
  15. package/src/app-server/app-inventory-cache.test.ts +0 -176
  16. package/src/app-server/app-inventory-cache.ts +0 -324
  17. package/src/app-server/approval-bridge.test.ts +0 -1471
  18. package/src/app-server/approval-bridge.ts +0 -1211
  19. package/src/app-server/auth-bridge.test.ts +0 -1449
  20. package/src/app-server/auth-bridge.ts +0 -614
  21. package/src/app-server/auth-profile-runtime-contract.test.ts +0 -239
  22. package/src/app-server/capabilities.ts +0 -27
  23. package/src/app-server/client-factory.ts +0 -24
  24. package/src/app-server/client.test.ts +0 -563
  25. package/src/app-server/client.ts +0 -715
  26. package/src/app-server/compact.test.ts +0 -710
  27. package/src/app-server/compact.ts +0 -500
  28. package/src/app-server/computer-use.test.ts +0 -788
  29. package/src/app-server/computer-use.ts +0 -683
  30. package/src/app-server/config.test.ts +0 -879
  31. package/src/app-server/config.ts +0 -1038
  32. package/src/app-server/context-engine-projection.test.ts +0 -252
  33. package/src/app-server/context-engine-projection.ts +0 -403
  34. package/src/app-server/delivery-no-reply-runtime-contract.test.ts +0 -80
  35. package/src/app-server/dynamic-tool-diagnostics.ts +0 -73
  36. package/src/app-server/dynamic-tool-profile.ts +0 -69
  37. package/src/app-server/dynamic-tools.test.ts +0 -1302
  38. package/src/app-server/dynamic-tools.ts +0 -623
  39. package/src/app-server/elicitation-bridge.test.ts +0 -1056
  40. package/src/app-server/elicitation-bridge.ts +0 -783
  41. package/src/app-server/event-projector.test.ts +0 -2668
  42. package/src/app-server/event-projector.ts +0 -2057
  43. package/src/app-server/image-payload-sanitizer.test.ts +0 -49
  44. package/src/app-server/image-payload-sanitizer.ts +0 -167
  45. package/src/app-server/klaw-owned-tool-runtime-contract.test.ts +0 -456
  46. package/src/app-server/local-runtime-attribution.ts +0 -39
  47. package/src/app-server/managed-binary.test.ts +0 -139
  48. package/src/app-server/managed-binary.ts +0 -193
  49. package/src/app-server/models.test.ts +0 -246
  50. package/src/app-server/models.ts +0 -172
  51. package/src/app-server/native-hook-relay.test.ts +0 -271
  52. package/src/app-server/native-hook-relay.ts +0 -150
  53. package/src/app-server/native-subagent-task-mirror.test.ts +0 -573
  54. package/src/app-server/native-subagent-task-mirror.ts +0 -497
  55. package/src/app-server/outcome-fallback-runtime-contract.test.ts +0 -404
  56. package/src/app-server/plugin-activation.test.ts +0 -336
  57. package/src/app-server/plugin-activation.ts +0 -283
  58. package/src/app-server/plugin-app-cache-key.ts +0 -74
  59. package/src/app-server/plugin-approval-roundtrip.ts +0 -122
  60. package/src/app-server/plugin-inventory.test.ts +0 -355
  61. package/src/app-server/plugin-inventory.ts +0 -357
  62. package/src/app-server/plugin-thread-config.test.ts +0 -865
  63. package/src/app-server/plugin-thread-config.ts +0 -455
  64. package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +0 -33
  65. package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +0 -199
  66. package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +0 -102
  67. package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +0 -227
  68. package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +0 -2630
  69. package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +0 -2630
  70. package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +0 -1659
  71. package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +0 -1655
  72. package/src/app-server/protocol-validators.test.ts +0 -75
  73. package/src/app-server/protocol-validators.ts +0 -203
  74. package/src/app-server/protocol.ts +0 -520
  75. package/src/app-server/rate-limit-cache.ts +0 -48
  76. package/src/app-server/rate-limits.test.ts +0 -202
  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.context-engine.test.ts +0 -1004
  80. package/src/app-server/run-attempt.test.ts +0 -9477
  81. package/src/app-server/run-attempt.ts +0 -4683
  82. package/src/app-server/run-attempt.vision-tools.test.ts +0 -35
  83. package/src/app-server/schema-normalization-runtime-contract.test.ts +0 -206
  84. package/src/app-server/session-binding.test.ts +0 -303
  85. package/src/app-server/session-binding.ts +0 -398
  86. package/src/app-server/session-history.ts +0 -44
  87. package/src/app-server/shared-client.test.ts +0 -589
  88. package/src/app-server/shared-client.ts +0 -289
  89. package/src/app-server/side-question.test.ts +0 -1175
  90. package/src/app-server/side-question.ts +0 -1007
  91. package/src/app-server/test-support.ts +0 -48
  92. package/src/app-server/thread-lifecycle.test.ts +0 -447
  93. package/src/app-server/thread-lifecycle.ts +0 -939
  94. package/src/app-server/thread-lifecycle.user-mcp-servers.test.ts +0 -442
  95. package/src/app-server/timeout.ts +0 -9
  96. package/src/app-server/tool-progress-normalization.ts +0 -77
  97. package/src/app-server/trajectory.test.ts +0 -205
  98. package/src/app-server/trajectory.ts +0 -365
  99. package/src/app-server/transcript-mirror.test.ts +0 -524
  100. package/src/app-server/transcript-mirror.ts +0 -208
  101. package/src/app-server/transcript-repair-runtime-contract.test.ts +0 -44
  102. package/src/app-server/transport-stdio.test.ts +0 -171
  103. package/src/app-server/transport-stdio.ts +0 -107
  104. package/src/app-server/transport-websocket.test.ts +0 -69
  105. package/src/app-server/transport-websocket.ts +0 -90
  106. package/src/app-server/transport.ts +0 -117
  107. package/src/app-server/user-input-bridge.test.ts +0 -249
  108. package/src/app-server/user-input-bridge.ts +0 -316
  109. package/src/app-server/version.ts +0 -4
  110. package/src/app-server/vision-tools.ts +0 -12
  111. package/src/command-account.ts +0 -544
  112. package/src/command-formatters.ts +0 -425
  113. package/src/command-handlers.ts +0 -2004
  114. package/src/command-rpc.test.ts +0 -16
  115. package/src/command-rpc.ts +0 -142
  116. package/src/commands.test.ts +0 -3312
  117. package/src/commands.ts +0 -65
  118. package/src/conversation-binding-data.ts +0 -124
  119. package/src/conversation-binding.test.ts +0 -599
  120. package/src/conversation-binding.ts +0 -561
  121. package/src/conversation-control.test.ts +0 -126
  122. package/src/conversation-control.ts +0 -303
  123. package/src/conversation-turn-collector.test.ts +0 -191
  124. package/src/conversation-turn-collector.ts +0 -186
  125. package/src/conversation-turn-input.test.ts +0 -141
  126. package/src/conversation-turn-input.ts +0 -106
  127. package/src/manifest.test.ts +0 -20
  128. package/src/migration/apply.ts +0 -501
  129. package/src/migration/helpers.ts +0 -55
  130. package/src/migration/plan.ts +0 -461
  131. package/src/migration/provider.test.ts +0 -1741
  132. package/src/migration/provider.ts +0 -41
  133. package/src/migration/source.ts +0 -643
  134. package/src/migration/targets.ts +0 -25
  135. package/src/node-cli-sessions.test.ts +0 -180
  136. package/src/node-cli-sessions.ts +0 -711
  137. package/test-api.ts +0 -82
  138. package/tsconfig.json +0 -16
@@ -1,461 +0,0 @@
1
- import path from "node:path";
2
- import {
3
- createMigrationItem,
4
- createMigrationManualItem,
5
- hasMigrationConfigPatchConflict,
6
- MIGRATION_REASON_TARGET_EXISTS,
7
- readMigrationConfigPath,
8
- summarizeMigrationItems,
9
- } from "klaw/plugin-sdk/migration";
10
- import type {
11
- MigrationItem,
12
- MigrationPlan,
13
- MigrationProviderContext,
14
- } from "klaw/plugin-sdk/plugin-entry";
15
- import { CODEX_PLUGINS_MARKETPLACE_NAME } from "../app-server/config.js";
16
- import { exists, sanitizeName } from "./helpers.js";
17
- import {
18
- codexPluginMigrationSubscriptionWarning,
19
- discoverCodexSource,
20
- hasCodexSource,
21
- type CodexPluginSource,
22
- type CodexSkillSource,
23
- } from "./source.js";
24
- import { resolveCodexMigrationTargets } from "./targets.js";
25
-
26
- export const CODEX_PLUGIN_CONFIG_ITEM_ID = "config:codex-plugins";
27
- export const CODEX_PLUGIN_CONFIG_PATH = ["plugins", "entries", "codex"] as const;
28
- const CODEX_PLUGIN_ENABLED_PATH = ["plugins", "entries", "codex", "enabled"] as const;
29
- const CODEX_PLUGIN_NATIVE_CONFIG_PATH = [
30
- "plugins",
31
- "entries",
32
- "codex",
33
- "config",
34
- "codexPlugins",
35
- ] as const;
36
- const MIGRATION_REASON_PLUGIN_EXISTS = "plugin exists";
37
- const CODEX_PLUGIN_SOURCE_APP_VERIFICATION_UNVERIFIED = "not_run";
38
-
39
- export type CodexPluginMigrationConfigEntry = {
40
- configKey: string;
41
- pluginName: string;
42
- enabled: boolean;
43
- };
44
-
45
- type CodexPluginMigrationBlockSkipDetails = {
46
- pluginName: string;
47
- marketplaceName: typeof CODEX_PLUGINS_MARKETPLACE_NAME;
48
- apps?: NonNullable<CodexPluginSource["migrationBlock"]>["apps"];
49
- error?: string;
50
- };
51
-
52
- function uniqueSkillName(skill: CodexSkillSource, counts: Map<string, number>): string {
53
- const base = sanitizeName(skill.name) || "codex-skill";
54
- if ((counts.get(base) ?? 0) <= 1) {
55
- return base;
56
- }
57
- const parent = sanitizeName(path.basename(path.dirname(skill.source)));
58
- return sanitizeName(["codex", parent, base].filter(Boolean).join("-")) || base;
59
- }
60
-
61
- async function buildSkillItems(params: {
62
- skills: CodexSkillSource[];
63
- workspaceDir: string;
64
- overwrite?: boolean;
65
- }): Promise<MigrationItem[]> {
66
- const baseCounts = new Map<string, number>();
67
- for (const skill of params.skills) {
68
- const base = sanitizeName(skill.name) || "codex-skill";
69
- baseCounts.set(base, (baseCounts.get(base) ?? 0) + 1);
70
- }
71
- const resolvedCounts = new Map<string, number>();
72
- const planned = params.skills.map((skill) => {
73
- const name = uniqueSkillName(skill, baseCounts);
74
- resolvedCounts.set(name, (resolvedCounts.get(name) ?? 0) + 1);
75
- return { skill, name, target: path.join(params.workspaceDir, "skills", name) };
76
- });
77
- const items: MigrationItem[] = [];
78
- for (const item of planned) {
79
- const collides = (resolvedCounts.get(item.name) ?? 0) > 1;
80
- const targetExists = await exists(item.target);
81
- items.push(
82
- createMigrationItem({
83
- id: `skill:${item.name}`,
84
- kind: "skill",
85
- action: "copy",
86
- source: item.skill.source,
87
- target: item.target,
88
- status: collides ? "conflict" : targetExists && !params.overwrite ? "conflict" : "planned",
89
- reason: collides
90
- ? `multiple Codex skills normalize to "${item.name}"`
91
- : targetExists && !params.overwrite
92
- ? MIGRATION_REASON_TARGET_EXISTS
93
- : undefined,
94
- message: `Copy ${item.skill.sourceLabel} into this Klaw agent workspace.`,
95
- details: {
96
- skillName: item.name,
97
- sourceLabel: item.skill.sourceLabel,
98
- },
99
- }),
100
- );
101
- }
102
- return items;
103
- }
104
-
105
- function uniquePluginConfigKey(
106
- plugin: CodexPluginSource,
107
- counts: Map<string, number>,
108
- usedCounts: Map<string, number>,
109
- ): string {
110
- const base = sanitizeName(plugin.pluginName ?? plugin.name) || "codex-plugin";
111
- const total = counts.get(base) ?? 0;
112
- if (total <= 1) {
113
- return base;
114
- }
115
- const next = (usedCounts.get(base) ?? 0) + 1;
116
- usedCounts.set(base, next);
117
- return sanitizeName(`${base}-${next}`) || base;
118
- }
119
-
120
- function readExistingCodexPluginEntries(
121
- config: MigrationProviderContext["config"],
122
- ): Record<string, unknown> {
123
- const entries = readMigrationConfigPath(config as Record<string, unknown>, [
124
- ...CODEX_PLUGIN_NATIVE_CONFIG_PATH,
125
- "plugins",
126
- ]);
127
- return isRecord(entries) ? entries : {};
128
- }
129
-
130
- function hasExistingCodexPluginEntry(
131
- existingEntries: Record<string, unknown>,
132
- configKey: string,
133
- pluginName: string,
134
- ): boolean {
135
- if (existingEntries[configKey] !== undefined) {
136
- return true;
137
- }
138
- return Object.values(existingEntries).some((entry) => {
139
- if (!isRecord(entry)) {
140
- return false;
141
- }
142
- return entry.pluginName === pluginName;
143
- });
144
- }
145
-
146
- function buildPluginItems(
147
- ctx: MigrationProviderContext,
148
- plugins: readonly CodexPluginSource[],
149
- ): MigrationItem[] {
150
- const baseCounts = new Map<string, number>();
151
- for (const plugin of plugins.filter((entry) => entry.migratable)) {
152
- const base = sanitizeName(plugin.pluginName ?? plugin.name) || "codex-plugin";
153
- baseCounts.set(base, (baseCounts.get(base) ?? 0) + 1);
154
- }
155
- const existingPluginEntries = readExistingCodexPluginEntries(ctx.config);
156
- const usedCounts = new Map<string, number>();
157
- let manualIndex = 0;
158
- const items: MigrationItem[] = [];
159
- for (const plugin of plugins) {
160
- if (
161
- plugin.migratable &&
162
- plugin.marketplaceName === CODEX_PLUGINS_MARKETPLACE_NAME &&
163
- plugin.pluginName
164
- ) {
165
- const configKey = uniquePluginConfigKey(plugin, baseCounts, usedCounts);
166
- const conflict =
167
- !ctx.overwrite &&
168
- hasExistingCodexPluginEntry(existingPluginEntries, configKey, plugin.pluginName);
169
- items.push(
170
- createMigrationItem({
171
- id: `plugin:${configKey}`,
172
- kind: "plugin",
173
- action: "install",
174
- status: conflict ? "conflict" : "planned",
175
- reason: conflict ? MIGRATION_REASON_PLUGIN_EXISTS : undefined,
176
- source: plugin.source,
177
- target: `plugins.entries.codex.config.codexPlugins.plugins.${configKey}`,
178
- message: `Install Codex plugin "${plugin.pluginName}" in the Klaw-managed Codex app-server runtime.`,
179
- details: {
180
- configKey,
181
- marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
182
- pluginName: plugin.pluginName,
183
- sourceInstalled: plugin.installed === true,
184
- sourceEnabled: plugin.enabled === true,
185
- ...(plugin.apps && plugin.apps.length > 0 && !shouldVerifyPluginApps(ctx)
186
- ? { sourceAppVerification: CODEX_PLUGIN_SOURCE_APP_VERIFICATION_UNVERIFIED }
187
- : {}),
188
- },
189
- }),
190
- );
191
- continue;
192
- }
193
-
194
- manualIndex += 1;
195
- if (plugin.migrationBlock && plugin.pluginName) {
196
- const details: CodexPluginMigrationBlockSkipDetails = {
197
- pluginName: plugin.pluginName,
198
- marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
199
- ...(plugin.migrationBlock.apps ? { apps: plugin.migrationBlock.apps } : {}),
200
- ...(plugin.migrationBlock.error ? { error: plugin.migrationBlock.error } : {}),
201
- };
202
- items.push(
203
- createMigrationItem({
204
- id: `plugin:${sanitizeName(plugin.name) || sanitizeName(path.basename(plugin.source))}:${manualIndex}`,
205
- kind: "manual",
206
- action: "manual",
207
- source: plugin.source,
208
- status: "skipped",
209
- reason: plugin.migrationBlock.code,
210
- message:
211
- plugin.message ??
212
- `Codex native plugin "${plugin.name}" was found but not activated automatically.`,
213
- details: { ...details },
214
- }),
215
- );
216
- continue;
217
- }
218
- items.push(
219
- createMigrationManualItem({
220
- id: `plugin:${sanitizeName(plugin.name) || sanitizeName(path.basename(plugin.source))}:${manualIndex}`,
221
- source: plugin.source,
222
- message:
223
- plugin.message ??
224
- `Codex native plugin "${plugin.name}" was found but not activated automatically.`,
225
- recommendation:
226
- "Review the plugin bundle first, then install trusted compatible plugins with klaw plugins install <path>.",
227
- }),
228
- );
229
- }
230
- return items;
231
- }
232
-
233
- function shouldVerifyPluginApps(ctx: MigrationProviderContext): boolean {
234
- return ctx.providerOptions?.verifyPluginApps === true;
235
- }
236
-
237
- export function readCodexPluginMigrationConfigEntry(
238
- item: MigrationItem,
239
- enabled: boolean,
240
- ): CodexPluginMigrationConfigEntry | undefined {
241
- const configKey = item.details?.configKey;
242
- const marketplaceName = item.details?.marketplaceName;
243
- const pluginName = item.details?.pluginName;
244
- if (
245
- item.kind !== "plugin" ||
246
- item.action !== "install" ||
247
- typeof configKey !== "string" ||
248
- marketplaceName !== CODEX_PLUGINS_MARKETPLACE_NAME ||
249
- typeof pluginName !== "string"
250
- ) {
251
- return undefined;
252
- }
253
- return { configKey, pluginName, enabled };
254
- }
255
-
256
- function readExistingAllowDestructiveActions(
257
- config: MigrationProviderContext["config"],
258
- ): boolean | undefined {
259
- const value = readMigrationConfigPath(config as Record<string, unknown>, [
260
- ...CODEX_PLUGIN_NATIVE_CONFIG_PATH,
261
- "allow_destructive_actions",
262
- ]);
263
- return typeof value === "boolean" ? value : undefined;
264
- }
265
-
266
- function isRecord(value: unknown): value is Record<string, unknown> {
267
- return Boolean(value && typeof value === "object" && !Array.isArray(value));
268
- }
269
-
270
- export function buildCodexPluginsConfigValue(
271
- entries: readonly CodexPluginMigrationConfigEntry[],
272
- params: {
273
- config?: MigrationProviderContext["config"];
274
- } = {},
275
- ): Record<string, unknown> {
276
- const plugins = Object.fromEntries(
277
- entries
278
- .toSorted((a, b) => a.configKey.localeCompare(b.configKey))
279
- .map((entry) => [
280
- entry.configKey,
281
- {
282
- enabled: entry.enabled,
283
- marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
284
- pluginName: entry.pluginName,
285
- },
286
- ]),
287
- );
288
- const config: Record<string, unknown> = {
289
- codexPlugins: {
290
- enabled: true,
291
- allow_destructive_actions:
292
- params.config === undefined
293
- ? true
294
- : (readExistingAllowDestructiveActions(params.config) ?? true),
295
- plugins,
296
- },
297
- };
298
- return {
299
- enabled: true,
300
- config,
301
- };
302
- }
303
-
304
- export function hasCodexPluginConfigConflict(
305
- config: MigrationProviderContext["config"],
306
- value: Record<string, unknown>,
307
- ): boolean {
308
- const enabled = readMigrationConfigPath(
309
- config as Record<string, unknown>,
310
- CODEX_PLUGIN_ENABLED_PATH,
311
- );
312
- if (enabled !== undefined && enabled !== true) {
313
- return true;
314
- }
315
- const nativeConfig = (value.config as Record<string, unknown> | undefined)?.codexPlugins;
316
- if (!isRecord(nativeConfig)) {
317
- return hasMigrationConfigPatchConflict(config, CODEX_PLUGIN_NATIVE_CONFIG_PATH, nativeConfig);
318
- }
319
- const existingNativeConfig = readMigrationConfigPath(
320
- config as Record<string, unknown>,
321
- CODEX_PLUGIN_NATIVE_CONFIG_PATH,
322
- );
323
- if (existingNativeConfig === undefined) {
324
- return false;
325
- }
326
- if (!isRecord(existingNativeConfig)) {
327
- return true;
328
- }
329
- if (existingNativeConfig.enabled !== undefined && existingNativeConfig.enabled !== true) {
330
- return true;
331
- }
332
- const allowDestructiveActions = nativeConfig.allow_destructive_actions;
333
- if (
334
- existingNativeConfig.allow_destructive_actions !== undefined &&
335
- existingNativeConfig.allow_destructive_actions !== allowDestructiveActions
336
- ) {
337
- return true;
338
- }
339
- const plugins = nativeConfig.plugins;
340
- if (!isRecord(plugins)) {
341
- return false;
342
- }
343
- return Object.entries(plugins).some(([configKey, plugin]) => {
344
- if (!isRecord(plugin)) {
345
- return existingNativeConfig[configKey] !== undefined;
346
- }
347
- return hasExistingCodexPluginEntry(
348
- readExistingCodexPluginEntries(config),
349
- configKey,
350
- typeof plugin.pluginName === "string" ? plugin.pluginName : configKey,
351
- );
352
- });
353
- }
354
-
355
- function buildPluginConfigItem(
356
- ctx: MigrationProviderContext,
357
- pluginItems: readonly MigrationItem[],
358
- ): MigrationItem | undefined {
359
- const entries = pluginItems
360
- .filter((item) => item.status === "planned")
361
- .map((item) => readCodexPluginMigrationConfigEntry(item, true))
362
- .filter((entry): entry is CodexPluginMigrationConfigEntry => entry !== undefined);
363
- if (entries.length === 0) {
364
- return undefined;
365
- }
366
- const value = buildCodexPluginsConfigValue(entries, { config: ctx.config });
367
- const conflict = !ctx.overwrite && hasCodexPluginConfigConflict(ctx.config, value);
368
- return createMigrationItem({
369
- id: CODEX_PLUGIN_CONFIG_ITEM_ID,
370
- kind: "config",
371
- action: "merge",
372
- target: "plugins.entries.codex.config.codexPlugins",
373
- status: conflict ? "conflict" : "planned",
374
- reason: conflict ? MIGRATION_REASON_TARGET_EXISTS : undefined,
375
- message:
376
- "Enable Klaw's Codex plugin integration and record migrated source-installed curated plugins.",
377
- details: {
378
- path: [...CODEX_PLUGIN_CONFIG_PATH],
379
- value,
380
- },
381
- });
382
- }
383
-
384
- export async function buildCodexMigrationPlan(
385
- ctx: MigrationProviderContext,
386
- ): Promise<MigrationPlan> {
387
- const targets = resolveCodexMigrationTargets(ctx);
388
- const source = await discoverCodexSource({
389
- input: ctx.source,
390
- evaluatePluginMigrationEligibility: true,
391
- verifyPluginApps: shouldVerifyPluginApps(ctx),
392
- });
393
- if (!hasCodexSource(source)) {
394
- throw new Error(
395
- `Codex state was not found at ${source.root}. Pass --from <path> if it lives elsewhere.`,
396
- );
397
- }
398
- const items: MigrationItem[] = [];
399
- items.push(
400
- ...(await buildSkillItems({
401
- skills: source.skills,
402
- workspaceDir: targets.workspaceDir,
403
- overwrite: ctx.overwrite,
404
- })),
405
- );
406
- const pluginItems = buildPluginItems(ctx, source.plugins);
407
- items.push(...pluginItems);
408
- const pluginConfigItem = buildPluginConfigItem(ctx, pluginItems);
409
- if (pluginConfigItem) {
410
- items.push(pluginConfigItem);
411
- }
412
- for (const archivePath of source.archivePaths) {
413
- items.push(
414
- createMigrationItem({
415
- id: archivePath.id,
416
- kind: "archive",
417
- action: "archive",
418
- source: archivePath.path,
419
- message:
420
- archivePath.message ??
421
- "Archived in the migration report for manual review; not imported into live config.",
422
- details: { archiveRelativePath: archivePath.relativePath },
423
- }),
424
- );
425
- }
426
- const warnings = [
427
- ...(items.some((item) => item.status === "conflict")
428
- ? [
429
- "Conflicts were found. Re-run with --overwrite to replace conflicting migration targets after item-level backups.",
430
- ]
431
- : []),
432
- ...(source.pluginDiscoveryError
433
- ? [
434
- `Codex app-server plugin inventory discovery failed: ${source.pluginDiscoveryError}. Cached plugin bundles, if any, are advisory only.`,
435
- ]
436
- : []),
437
- ...(source.plugins.some(
438
- (plugin) => plugin.migrationBlock?.code === "codex_subscription_required",
439
- )
440
- ? [codexPluginMigrationSubscriptionWarning()]
441
- : []),
442
- ];
443
- return {
444
- providerId: "codex",
445
- source: source.root,
446
- target: targets.workspaceDir,
447
- summary: summarizeMigrationItems(items),
448
- items,
449
- warnings,
450
- nextSteps: [
451
- "Run klaw doctor after applying the migration.",
452
- "Review skipped or auth-required Codex plugin/config/hook items before exposing them in Klaw sessions.",
453
- ],
454
- metadata: {
455
- agentDir: targets.agentDir,
456
- codexHome: source.codexHome,
457
- codexSkillsDir: source.codexSkillsDir,
458
- personalAgentsSkillsDir: source.personalAgentsSkillsDir,
459
- },
460
- };
461
- }