@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.
- package/dist/client-DNN2uyJW.js +642 -0
- package/dist/client-factory-Bu9OClHJ.js +9 -0
- package/dist/command-formatters-BpPOTePl.js +520 -0
- package/dist/command-handlers-BBs7Vws9.js +1533 -0
- package/dist/compact-CDboBy7o.js +329 -0
- package/dist/computer-use-DCZB46Sw.js +367 -0
- package/dist/config-CLMSw0p2.js +510 -0
- package/dist/doctor-contract-api.js +53 -0
- package/dist/harness.js +51 -0
- package/dist/index.js +1171 -0
- package/dist/media-understanding-provider.js +335 -0
- package/dist/models-jLA2SIvd.js +110 -0
- package/dist/node-cli-sessions-BLRDs_US.js +1216 -0
- package/dist/plugin-activation-CEy_oYpx.js +452 -0
- package/dist/prompt-overlay.js +12 -0
- package/dist/protocol-C9UWI98H.js +9 -0
- package/dist/protocol-validators-BGBspNmF.js +5988 -0
- package/dist/provider-catalog.js +84 -0
- package/dist/provider-discovery.js +33 -0
- package/dist/provider.js +150 -0
- package/dist/rate-limit-cache-9LxQdE0K.js +24 -0
- package/dist/request-DbSPeTcV.js +89 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/run-attempt-BoEwzQCv.js +5463 -0
- package/dist/session-binding-e2GFp9VH.js +222 -0
- package/dist/shared-client-D7Vy0glq.js +631 -0
- package/dist/side-question-BDLuEzFP.js +668 -0
- package/dist/test-api.js +49 -0
- package/dist/thread-lifecycle-Clo0EHMk.js +1565 -0
- package/dist/vision-tools-Cofrv35p.js +1379 -0
- package/package.json +16 -1
- package/doctor-contract-api.ts +0 -68
- package/harness.ts +0 -72
- package/index.ts +0 -124
- package/media-understanding-provider.ts +0 -521
- package/prompt-overlay.ts +0 -21
- package/provider-catalog.ts +0 -83
- package/provider-discovery.ts +0 -45
- package/provider.ts +0 -243
- package/src/app-server/app-inventory-cache.ts +0 -324
- package/src/app-server/approval-bridge.ts +0 -1211
- package/src/app-server/auth-bridge.ts +0 -614
- package/src/app-server/capabilities.ts +0 -27
- package/src/app-server/client-factory.ts +0 -24
- package/src/app-server/client.ts +0 -715
- package/src/app-server/compact.ts +0 -512
- package/src/app-server/computer-use.ts +0 -683
- package/src/app-server/config.ts +0 -1038
- package/src/app-server/context-engine-projection.ts +0 -403
- package/src/app-server/dynamic-tool-diagnostics.ts +0 -73
- package/src/app-server/dynamic-tool-profile.ts +0 -70
- package/src/app-server/dynamic-tools.ts +0 -623
- package/src/app-server/elicitation-bridge.ts +0 -783
- package/src/app-server/event-projector.ts +0 -2065
- package/src/app-server/image-payload-sanitizer.ts +0 -167
- package/src/app-server/local-runtime-attribution.ts +0 -39
- package/src/app-server/managed-binary.ts +0 -193
- package/src/app-server/models.ts +0 -172
- package/src/app-server/native-hook-relay.ts +0 -150
- package/src/app-server/native-subagent-task-mirror.ts +0 -497
- package/src/app-server/plugin-activation.ts +0 -283
- package/src/app-server/plugin-app-cache-key.ts +0 -74
- package/src/app-server/plugin-approval-roundtrip.ts +0 -122
- package/src/app-server/plugin-inventory.ts +0 -357
- package/src/app-server/plugin-thread-config.ts +0 -455
- package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +0 -33
- package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +0 -199
- package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +0 -102
- package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +0 -227
- package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +0 -2630
- package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +0 -2630
- package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +0 -1659
- package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +0 -1655
- package/src/app-server/protocol-validators.ts +0 -203
- package/src/app-server/protocol.ts +0 -520
- package/src/app-server/rate-limit-cache.ts +0 -48
- package/src/app-server/rate-limits.ts +0 -583
- package/src/app-server/request.ts +0 -73
- package/src/app-server/run-attempt.ts +0 -4862
- package/src/app-server/session-binding.ts +0 -398
- package/src/app-server/session-history.ts +0 -44
- package/src/app-server/shared-client.ts +0 -289
- package/src/app-server/side-question.ts +0 -1009
- package/src/app-server/test-support.ts +0 -48
- package/src/app-server/thread-lifecycle.ts +0 -959
- package/src/app-server/timeout.ts +0 -9
- package/src/app-server/tool-progress-normalization.ts +0 -77
- package/src/app-server/trajectory.ts +0 -368
- package/src/app-server/transcript-mirror.ts +0 -208
- package/src/app-server/transport-stdio.ts +0 -107
- package/src/app-server/transport-websocket.ts +0 -90
- package/src/app-server/transport.ts +0 -117
- package/src/app-server/user-input-bridge.ts +0 -316
- package/src/app-server/version.ts +0 -4
- package/src/app-server/vision-tools.ts +0 -12
- package/src/command-account.ts +0 -544
- package/src/command-formatters.ts +0 -426
- package/src/command-handlers.ts +0 -2021
- package/src/command-plugins-management.ts +0 -137
- package/src/command-rpc.ts +0 -142
- package/src/commands.ts +0 -65
- package/src/conversation-binding-data.ts +0 -124
- package/src/conversation-binding.ts +0 -561
- package/src/conversation-control.ts +0 -303
- package/src/conversation-turn-collector.ts +0 -186
- package/src/conversation-turn-input.ts +0 -106
- package/src/migration/apply.ts +0 -501
- package/src/migration/helpers.ts +0 -55
- package/src/migration/plan.ts +0 -461
- package/src/migration/provider.ts +0 -41
- package/src/migration/source.ts +0 -643
- package/src/migration/targets.ts +0 -25
- package/src/node-cli-sessions.ts +0 -711
- package/test-api.ts +0 -95
- package/tsconfig.json +0 -16
package/src/migration/plan.ts
DELETED
|
@@ -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 "autobot/plugin-sdk/migration";
|
|
10
|
-
import type {
|
|
11
|
-
MigrationItem,
|
|
12
|
-
MigrationPlan,
|
|
13
|
-
MigrationProviderContext,
|
|
14
|
-
} from "autobot/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 AutoBot 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 AutoBot-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 autobot 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 AutoBot'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 autobot doctor after applying the migration.",
|
|
452
|
-
"Review skipped or auth-required Codex plugin/config/hook items before exposing them in AutoBot sessions.",
|
|
453
|
-
],
|
|
454
|
-
metadata: {
|
|
455
|
-
agentDir: targets.agentDir,
|
|
456
|
-
codexHome: source.codexHome,
|
|
457
|
-
codexSkillsDir: source.codexSkillsDir,
|
|
458
|
-
personalAgentsSkillsDir: source.personalAgentsSkillsDir,
|
|
459
|
-
},
|
|
460
|
-
};
|
|
461
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MigrationPlan,
|
|
3
|
-
MigrationProviderContext,
|
|
4
|
-
MigrationProviderPlugin,
|
|
5
|
-
} from "autobot/plugin-sdk/plugin-entry";
|
|
6
|
-
import { applyCodexMigrationPlan, prepareTargetCodexAppServer } from "./apply.js";
|
|
7
|
-
import { buildCodexMigrationPlan } from "./plan.js";
|
|
8
|
-
import { discoverCodexSource, hasCodexSource } from "./source.js";
|
|
9
|
-
|
|
10
|
-
export function buildCodexMigrationProvider(
|
|
11
|
-
params: {
|
|
12
|
-
runtime?: MigrationProviderContext["runtime"];
|
|
13
|
-
} = {},
|
|
14
|
-
): MigrationProviderPlugin {
|
|
15
|
-
return {
|
|
16
|
-
id: "codex",
|
|
17
|
-
label: "Codex",
|
|
18
|
-
description:
|
|
19
|
-
"Inventory and promote Codex CLI skills while keeping Codex native plugins and hooks explicit.",
|
|
20
|
-
async detect(ctx) {
|
|
21
|
-
const source = await discoverCodexSource({
|
|
22
|
-
input: ctx.source,
|
|
23
|
-
});
|
|
24
|
-
const found = hasCodexSource(source);
|
|
25
|
-
return {
|
|
26
|
-
found,
|
|
27
|
-
source: source.root,
|
|
28
|
-
label: "Codex",
|
|
29
|
-
confidence: found ? source.confidence : "low",
|
|
30
|
-
message: found ? "Codex state found." : "Codex state not found.",
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
plan: buildCodexMigrationPlan,
|
|
34
|
-
prepareApply(ctx) {
|
|
35
|
-
return prepareTargetCodexAppServer(ctx);
|
|
36
|
-
},
|
|
37
|
-
async apply(ctx, plan?: MigrationPlan) {
|
|
38
|
-
return await applyCodexMigrationPlan({ ctx, plan, runtime: params.runtime });
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|