@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/source.ts
DELETED
|
@@ -1,643 +0,0 @@
|
|
|
1
|
-
import type { Dirent } from "node:fs";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
defaultCodexAppInventoryCache,
|
|
6
|
-
type CodexAppInventoryRequest,
|
|
7
|
-
} from "../app-server/app-inventory-cache.js";
|
|
8
|
-
import { CODEX_PLUGINS_MARKETPLACE_NAME } from "../app-server/config.js";
|
|
9
|
-
import type { CodexAppServerStartOptions } from "../app-server/config.js";
|
|
10
|
-
import { buildCodexPluginAppCacheKey } from "../app-server/plugin-app-cache-key.js";
|
|
11
|
-
import {
|
|
12
|
-
pluginReadParams,
|
|
13
|
-
type CodexPluginMarketplaceRef,
|
|
14
|
-
} from "../app-server/plugin-inventory.js";
|
|
15
|
-
import type { CodexGetAccountResponse, v2 } from "../app-server/protocol.js";
|
|
16
|
-
import { requestCodexAppServerJson } from "../app-server/request.js";
|
|
17
|
-
import {
|
|
18
|
-
exists,
|
|
19
|
-
isDirectory,
|
|
20
|
-
readJsonObject,
|
|
21
|
-
resolveHomePath,
|
|
22
|
-
resolveUserHomeDir,
|
|
23
|
-
} from "./helpers.js";
|
|
24
|
-
|
|
25
|
-
const SKILL_FILENAME = "SKILL.md";
|
|
26
|
-
const MAX_SCAN_DEPTH = 6;
|
|
27
|
-
const MAX_DISCOVERED_DIRS = 2000;
|
|
28
|
-
|
|
29
|
-
export type CodexSkillSource = {
|
|
30
|
-
name: string;
|
|
31
|
-
source: string;
|
|
32
|
-
sourceLabel: string;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type CodexPluginSource = {
|
|
36
|
-
name: string;
|
|
37
|
-
source: string;
|
|
38
|
-
sourceKind: "app-server" | "cache";
|
|
39
|
-
migratable: boolean;
|
|
40
|
-
manifestPath?: string;
|
|
41
|
-
marketplaceName?: typeof CODEX_PLUGINS_MARKETPLACE_NAME;
|
|
42
|
-
pluginName?: string;
|
|
43
|
-
installed?: boolean;
|
|
44
|
-
enabled?: boolean;
|
|
45
|
-
apps?: CodexPluginMigrationAppFact[];
|
|
46
|
-
migrationBlock?: CodexPluginMigrationBlock;
|
|
47
|
-
message?: string;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export type CodexPluginMigrationBlockCode =
|
|
51
|
-
| "plugin_disabled"
|
|
52
|
-
| "codex_subscription_required"
|
|
53
|
-
| "codex_account_unavailable"
|
|
54
|
-
| "plugin_read_unavailable"
|
|
55
|
-
| "app_inventory_unavailable"
|
|
56
|
-
| "app_inaccessible"
|
|
57
|
-
| "app_disabled"
|
|
58
|
-
| "app_missing";
|
|
59
|
-
|
|
60
|
-
export type CodexPluginMigrationAppFact = {
|
|
61
|
-
id: string;
|
|
62
|
-
name: string;
|
|
63
|
-
needsAuth?: boolean;
|
|
64
|
-
isAccessible?: boolean;
|
|
65
|
-
isEnabled?: boolean;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type CodexPluginMigrationBlock = {
|
|
69
|
-
code: CodexPluginMigrationBlockCode;
|
|
70
|
-
apps?: CodexPluginMigrationAppFact[];
|
|
71
|
-
error?: string;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
type CodexArchiveSource = {
|
|
75
|
-
id: string;
|
|
76
|
-
path: string;
|
|
77
|
-
relativePath: string;
|
|
78
|
-
message?: string;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
type CodexSource = {
|
|
82
|
-
root: string;
|
|
83
|
-
confidence: "low" | "medium" | "high";
|
|
84
|
-
codexHome: string;
|
|
85
|
-
codexSkillsDir?: string;
|
|
86
|
-
personalAgentsSkillsDir?: string;
|
|
87
|
-
configPath?: string;
|
|
88
|
-
hooksPath?: string;
|
|
89
|
-
skills: CodexSkillSource[];
|
|
90
|
-
plugins: CodexPluginSource[];
|
|
91
|
-
pluginDiscoveryError?: string;
|
|
92
|
-
archivePaths: CodexArchiveSource[];
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
type CodexSourceDiscoveryOptions = {
|
|
96
|
-
input?: string;
|
|
97
|
-
evaluatePluginMigrationEligibility?: boolean;
|
|
98
|
-
verifyPluginApps?: boolean;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
type SourceAppServerRequestOptions = {
|
|
102
|
-
startOptions: CodexAppServerStartOptions;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
type PluginReadResult =
|
|
106
|
-
| {
|
|
107
|
-
ok: true;
|
|
108
|
-
detail: v2.PluginDetail;
|
|
109
|
-
}
|
|
110
|
-
| {
|
|
111
|
-
ok: false;
|
|
112
|
-
error: string;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
function defaultCodexHome(): string {
|
|
116
|
-
return resolveHomePath(process.env.CODEX_HOME?.trim() || "~/.codex");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function personalAgentsSkillsDir(): string {
|
|
120
|
-
return path.join(resolveUserHomeDir(), ".agents", "skills");
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async function safeReadDir(dir: string): Promise<Dirent[]> {
|
|
124
|
-
return await fs.readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async function discoverSkillDirs(params: {
|
|
128
|
-
root: string | undefined;
|
|
129
|
-
sourceLabel: string;
|
|
130
|
-
excludeSystem?: boolean;
|
|
131
|
-
}): Promise<CodexSkillSource[]> {
|
|
132
|
-
if (!params.root || !(await isDirectory(params.root))) {
|
|
133
|
-
return [];
|
|
134
|
-
}
|
|
135
|
-
const discovered: CodexSkillSource[] = [];
|
|
136
|
-
async function visit(dir: string, depth: number): Promise<void> {
|
|
137
|
-
if (discovered.length >= MAX_DISCOVERED_DIRS || depth > MAX_SCAN_DEPTH) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const name = path.basename(dir);
|
|
141
|
-
if (params.excludeSystem && depth === 1 && name === ".system") {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (await exists(path.join(dir, SKILL_FILENAME))) {
|
|
145
|
-
discovered.push({ name, source: dir, sourceLabel: params.sourceLabel });
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
for (const entry of await safeReadDir(dir)) {
|
|
149
|
-
if (!entry.isDirectory()) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
await visit(path.join(dir, entry.name), depth + 1);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
await visit(params.root, 0);
|
|
156
|
-
return discovered;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
async function discoverPluginDirs(codexHome: string): Promise<CodexPluginSource[]> {
|
|
160
|
-
const root = path.join(codexHome, "plugins", "cache");
|
|
161
|
-
if (!(await isDirectory(root))) {
|
|
162
|
-
return [];
|
|
163
|
-
}
|
|
164
|
-
const discovered = new Map<string, CodexPluginSource>();
|
|
165
|
-
async function visit(dir: string, depth: number): Promise<void> {
|
|
166
|
-
if (discovered.size >= MAX_DISCOVERED_DIRS || depth > MAX_SCAN_DEPTH) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
const manifestPath = path.join(dir, ".codex-plugin", "plugin.json");
|
|
170
|
-
if (await exists(manifestPath)) {
|
|
171
|
-
const manifest = await readJsonObject(manifestPath);
|
|
172
|
-
const manifestName = typeof manifest.name === "string" ? manifest.name.trim() : "";
|
|
173
|
-
const name = manifestName || path.basename(dir);
|
|
174
|
-
discovered.set(dir, {
|
|
175
|
-
name,
|
|
176
|
-
source: dir,
|
|
177
|
-
manifestPath,
|
|
178
|
-
sourceKind: "cache",
|
|
179
|
-
migratable: false,
|
|
180
|
-
message:
|
|
181
|
-
"Cached Codex plugin bundle found. Review manually unless the plugin is also installed in the source Codex app-server inventory",
|
|
182
|
-
});
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
for (const entry of await safeReadDir(dir)) {
|
|
186
|
-
if (!entry.isDirectory()) {
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
await visit(path.join(dir, entry.name), depth + 1);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
await visit(root, 0);
|
|
193
|
-
return [...discovered.values()].toSorted((a, b) => a.source.localeCompare(b.source));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
async function discoverInstalledCuratedPlugins(
|
|
197
|
-
codexHome: string,
|
|
198
|
-
options: CodexSourceDiscoveryOptions = {},
|
|
199
|
-
): Promise<{
|
|
200
|
-
plugins: CodexPluginSource[];
|
|
201
|
-
error?: string;
|
|
202
|
-
}> {
|
|
203
|
-
const startOptions = sourceCodexAppServerStartOptions(codexHome);
|
|
204
|
-
const requestOptions = { startOptions };
|
|
205
|
-
try {
|
|
206
|
-
const response = await requestSourceCodexAppServerJson<v2.PluginListResponse>(requestOptions, {
|
|
207
|
-
method: "plugin/list",
|
|
208
|
-
requestParams: { cwds: [] } satisfies v2.PluginListParams,
|
|
209
|
-
});
|
|
210
|
-
const marketplace = response.marketplaces.find(
|
|
211
|
-
(entry) => entry.name === CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
212
|
-
);
|
|
213
|
-
if (!marketplace) {
|
|
214
|
-
return {
|
|
215
|
-
plugins: [],
|
|
216
|
-
error: `Codex marketplace ${CODEX_PLUGINS_MARKETPLACE_NAME} was not found in source plugin inventory.`,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
const plugins = marketplace.plugins
|
|
220
|
-
.filter((plugin) => plugin.installed)
|
|
221
|
-
.map((plugin) => buildInstalledPluginSource(plugin))
|
|
222
|
-
.filter((plugin): plugin is CodexPluginSource => plugin !== undefined);
|
|
223
|
-
const withEligibility =
|
|
224
|
-
options.evaluatePluginMigrationEligibility === true
|
|
225
|
-
? await withPluginMigrationEligibility({
|
|
226
|
-
plugins,
|
|
227
|
-
marketplace: marketplaceRef(marketplace),
|
|
228
|
-
requestOptions,
|
|
229
|
-
verifyPluginApps: options.verifyPluginApps === true,
|
|
230
|
-
})
|
|
231
|
-
: plugins;
|
|
232
|
-
const sorted = withEligibility.toSorted((a, b) =>
|
|
233
|
-
(a.pluginName ?? a.name).localeCompare(b.pluginName ?? b.name),
|
|
234
|
-
);
|
|
235
|
-
return { plugins: sorted };
|
|
236
|
-
} catch (error) {
|
|
237
|
-
return {
|
|
238
|
-
plugins: [],
|
|
239
|
-
error: error instanceof Error ? error.message : String(error),
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function sourceCodexAppServerStartOptions(codexHome: string): CodexAppServerStartOptions {
|
|
245
|
-
return {
|
|
246
|
-
transport: "stdio",
|
|
247
|
-
command: "codex",
|
|
248
|
-
commandSource: "managed",
|
|
249
|
-
args: ["app-server", "--listen", "stdio://"],
|
|
250
|
-
headers: {},
|
|
251
|
-
env: {
|
|
252
|
-
CODEX_HOME: codexHome,
|
|
253
|
-
HOME: path.dirname(codexHome),
|
|
254
|
-
},
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
async function requestSourceCodexAppServerJson<T>(
|
|
259
|
-
options: SourceAppServerRequestOptions,
|
|
260
|
-
params: {
|
|
261
|
-
method: string;
|
|
262
|
-
requestParams?: unknown;
|
|
263
|
-
},
|
|
264
|
-
): Promise<T> {
|
|
265
|
-
return await requestCodexAppServerJson<T>({
|
|
266
|
-
method: params.method,
|
|
267
|
-
requestParams: params.requestParams,
|
|
268
|
-
timeoutMs: 60_000,
|
|
269
|
-
startOptions: options.startOptions,
|
|
270
|
-
authProfileId: null,
|
|
271
|
-
isolated: true,
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function buildInstalledPluginSource(plugin: v2.PluginSummary): CodexPluginSource | undefined {
|
|
276
|
-
const pluginName = pluginNameFromSummary(plugin);
|
|
277
|
-
if (!pluginName) {
|
|
278
|
-
return undefined;
|
|
279
|
-
}
|
|
280
|
-
return {
|
|
281
|
-
name: plugin.name,
|
|
282
|
-
pluginName,
|
|
283
|
-
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
284
|
-
source: `${CODEX_PLUGINS_MARKETPLACE_NAME}/${pluginName}`,
|
|
285
|
-
sourceKind: "app-server",
|
|
286
|
-
migratable: true,
|
|
287
|
-
installed: plugin.installed,
|
|
288
|
-
enabled: plugin.enabled,
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function marketplaceRef(marketplace: v2.PluginMarketplaceEntry): CodexPluginMarketplaceRef {
|
|
293
|
-
return {
|
|
294
|
-
name: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
295
|
-
...(marketplace.path ? { path: marketplace.path } : {}),
|
|
296
|
-
...(!marketplace.path ? { remoteMarketplaceName: marketplace.name } : {}),
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
async function withPluginMigrationEligibility(params: {
|
|
301
|
-
plugins: CodexPluginSource[];
|
|
302
|
-
marketplace: CodexPluginMarketplaceRef;
|
|
303
|
-
requestOptions: SourceAppServerRequestOptions;
|
|
304
|
-
verifyPluginApps: boolean;
|
|
305
|
-
}): Promise<CodexPluginSource[]> {
|
|
306
|
-
const pending: Array<{ plugin: CodexPluginSource; apps: CodexPluginMigrationAppFact[] }> = [];
|
|
307
|
-
const evaluated: CodexPluginSource[] = [];
|
|
308
|
-
|
|
309
|
-
for (const plugin of params.plugins) {
|
|
310
|
-
if (plugin.enabled !== true) {
|
|
311
|
-
evaluated.push({
|
|
312
|
-
...plugin,
|
|
313
|
-
migratable: false,
|
|
314
|
-
migrationBlock: { code: "plugin_disabled" },
|
|
315
|
-
message: `Codex plugin "${plugin.pluginName ?? plugin.name}" is installed in Codex but disabled; enable it in Codex before migrating it to AutoBot.`,
|
|
316
|
-
});
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const detail = await readPluginDetail(params.requestOptions, params.marketplace, plugin);
|
|
321
|
-
if (!detail.ok) {
|
|
322
|
-
evaluated.push({
|
|
323
|
-
...plugin,
|
|
324
|
-
migratable: false,
|
|
325
|
-
migrationBlock: { code: "plugin_read_unavailable", error: detail.error },
|
|
326
|
-
message: `Codex plugin "${plugin.pluginName ?? plugin.name}" detail could not be read: ${detail.error}`,
|
|
327
|
-
});
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if (detail.detail.apps.length === 0) {
|
|
332
|
-
evaluated.push({
|
|
333
|
-
...plugin,
|
|
334
|
-
migratable: true,
|
|
335
|
-
});
|
|
336
|
-
continue;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const apps = detail.detail.apps
|
|
340
|
-
.map(sourcePluginAppFact)
|
|
341
|
-
.toSorted((left, right) => left.id.localeCompare(right.id));
|
|
342
|
-
pending.push({ plugin, apps });
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (pending.length === 0) {
|
|
346
|
-
return evaluated;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
let sourceAccount: Awaited<ReturnType<typeof readSourceCodexAccount>> | undefined;
|
|
350
|
-
try {
|
|
351
|
-
sourceAccount = await readSourceCodexAccount(params.requestOptions);
|
|
352
|
-
} catch (error) {
|
|
353
|
-
if (!params.verifyPluginApps) {
|
|
354
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
355
|
-
for (const { plugin, apps } of pending) {
|
|
356
|
-
evaluated.push({
|
|
357
|
-
...plugin,
|
|
358
|
-
migratable: false,
|
|
359
|
-
migrationBlock: { code: "codex_account_unavailable", apps, error: message },
|
|
360
|
-
message: `Codex plugin "${plugin.pluginName ?? plugin.name}" owns apps, but the source Codex app-server account could not be read: ${message}`,
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
return evaluated;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
if (sourceAccount && sourceAccount !== "chatgpt") {
|
|
367
|
-
for (const { plugin, apps } of pending) {
|
|
368
|
-
evaluated.push({
|
|
369
|
-
...plugin,
|
|
370
|
-
migratable: false,
|
|
371
|
-
migrationBlock: { code: "codex_subscription_required", apps },
|
|
372
|
-
message: codexSubscriptionRequiredMessage(plugin),
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
return evaluated;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (!params.verifyPluginApps) {
|
|
379
|
-
for (const { plugin, apps } of pending) {
|
|
380
|
-
evaluated.push({
|
|
381
|
-
...plugin,
|
|
382
|
-
apps,
|
|
383
|
-
migratable: true,
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
return evaluated;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const snapshot = await refreshSourceAppInventory(params.requestOptions).catch((error) => {
|
|
390
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
391
|
-
for (const { plugin, apps } of pending) {
|
|
392
|
-
evaluated.push({
|
|
393
|
-
...plugin,
|
|
394
|
-
migratable: false,
|
|
395
|
-
migrationBlock: {
|
|
396
|
-
code: "app_inventory_unavailable",
|
|
397
|
-
apps,
|
|
398
|
-
error: message,
|
|
399
|
-
},
|
|
400
|
-
message: `Codex plugin "${plugin.pluginName ?? plugin.name}" owns apps, but source app inventory could not be read: ${message}`,
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
return undefined;
|
|
404
|
-
});
|
|
405
|
-
if (!snapshot) {
|
|
406
|
-
return evaluated;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
const appInfoById = new Map(snapshot.apps.map((app) => [app.id, app] as const));
|
|
410
|
-
for (const { plugin, apps: declaredApps } of pending) {
|
|
411
|
-
const apps = declaredApps
|
|
412
|
-
.map((app) => sourcePluginAppFactWithInventory(app, appInfoById.get(app.id)))
|
|
413
|
-
.toSorted((left, right) => left.id.localeCompare(right.id));
|
|
414
|
-
const blockCode = migrationBlockCodeForApps(apps);
|
|
415
|
-
if (!blockCode) {
|
|
416
|
-
evaluated.push({ ...plugin, apps, migratable: true });
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
evaluated.push({
|
|
420
|
-
...plugin,
|
|
421
|
-
migratable: false,
|
|
422
|
-
migrationBlock: { code: blockCode, apps },
|
|
423
|
-
message: appInventoryBlockMessage(plugin, apps, blockCode),
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
return evaluated;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
async function readSourceCodexAccount(
|
|
431
|
-
options: SourceAppServerRequestOptions,
|
|
432
|
-
): Promise<"chatgpt" | "non_chatgpt" | "missing"> {
|
|
433
|
-
const response = await requestSourceCodexAppServerJson<CodexGetAccountResponse>(options, {
|
|
434
|
-
method: "account/read",
|
|
435
|
-
requestParams: { refreshToken: false },
|
|
436
|
-
});
|
|
437
|
-
if (
|
|
438
|
-
!response.account ||
|
|
439
|
-
typeof response.account !== "object" ||
|
|
440
|
-
Array.isArray(response.account)
|
|
441
|
-
) {
|
|
442
|
-
return "missing";
|
|
443
|
-
}
|
|
444
|
-
const type = response.account.type;
|
|
445
|
-
return type === "chatgpt" ? "chatgpt" : "non_chatgpt";
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
async function readPluginDetail(
|
|
449
|
-
options: SourceAppServerRequestOptions,
|
|
450
|
-
marketplace: CodexPluginMarketplaceRef,
|
|
451
|
-
plugin: CodexPluginSource,
|
|
452
|
-
): Promise<PluginReadResult> {
|
|
453
|
-
try {
|
|
454
|
-
const response = await requestSourceCodexAppServerJson<v2.PluginReadResponse>(options, {
|
|
455
|
-
method: "plugin/read",
|
|
456
|
-
requestParams: pluginReadParams(marketplace, plugin.pluginName ?? plugin.name),
|
|
457
|
-
});
|
|
458
|
-
return { ok: true, detail: response.plugin };
|
|
459
|
-
} catch (error) {
|
|
460
|
-
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
async function refreshSourceAppInventory(
|
|
465
|
-
options: SourceAppServerRequestOptions,
|
|
466
|
-
): Promise<Awaited<ReturnType<typeof defaultCodexAppInventoryCache.refreshNow>>> {
|
|
467
|
-
const key = buildCodexPluginAppCacheKey({
|
|
468
|
-
appServer: { start: options.startOptions },
|
|
469
|
-
});
|
|
470
|
-
const request: CodexAppInventoryRequest = async (method, requestParams) =>
|
|
471
|
-
await requestSourceCodexAppServerJson<v2.AppsListResponse>(options, {
|
|
472
|
-
method,
|
|
473
|
-
requestParams,
|
|
474
|
-
});
|
|
475
|
-
return await defaultCodexAppInventoryCache.refreshNow({
|
|
476
|
-
key,
|
|
477
|
-
request,
|
|
478
|
-
forceRefetch: true,
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
function sourcePluginAppFact(app: v2.AppSummary): CodexPluginMigrationAppFact {
|
|
483
|
-
return {
|
|
484
|
-
id: app.id,
|
|
485
|
-
name: app.name,
|
|
486
|
-
needsAuth: app.needsAuth,
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
function sourcePluginAppFactWithInventory(
|
|
491
|
-
app: CodexPluginMigrationAppFact,
|
|
492
|
-
info: v2.AppInfo | undefined,
|
|
493
|
-
): CodexPluginMigrationAppFact {
|
|
494
|
-
if (!info) {
|
|
495
|
-
return app;
|
|
496
|
-
}
|
|
497
|
-
return {
|
|
498
|
-
...app,
|
|
499
|
-
isAccessible: info.isAccessible,
|
|
500
|
-
isEnabled: info.isEnabled,
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
function migrationBlockCodeForApps(
|
|
505
|
-
apps: readonly CodexPluginMigrationAppFact[],
|
|
506
|
-
): CodexPluginMigrationBlockCode | undefined {
|
|
507
|
-
if (apps.some((app) => app.isAccessible === false)) {
|
|
508
|
-
return "app_inaccessible";
|
|
509
|
-
}
|
|
510
|
-
if (apps.some((app) => app.isEnabled === false)) {
|
|
511
|
-
return "app_disabled";
|
|
512
|
-
}
|
|
513
|
-
if (apps.some((app) => app.isAccessible === undefined || app.isEnabled === undefined)) {
|
|
514
|
-
return "app_missing";
|
|
515
|
-
}
|
|
516
|
-
return undefined;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
function appInventoryBlockMessage(
|
|
520
|
-
plugin: CodexPluginSource,
|
|
521
|
-
apps: readonly CodexPluginMigrationAppFact[],
|
|
522
|
-
code: CodexPluginMigrationBlockCode,
|
|
523
|
-
): string {
|
|
524
|
-
const status =
|
|
525
|
-
code === "app_inaccessible" ? "inaccessible" : code === "app_disabled" ? "disabled" : "missing";
|
|
526
|
-
const blocking =
|
|
527
|
-
apps.find((app) =>
|
|
528
|
-
code === "app_inaccessible"
|
|
529
|
-
? app.isAccessible === false
|
|
530
|
-
: code === "app_disabled"
|
|
531
|
-
? app.isEnabled === false
|
|
532
|
-
: app.isAccessible === undefined || app.isEnabled === undefined,
|
|
533
|
-
) ?? apps[0];
|
|
534
|
-
const appLabel = blocking ? ` app "${blocking.name}"` : " an owned app";
|
|
535
|
-
return `Codex plugin "${plugin.pluginName ?? plugin.name}" owns${appLabel} but the source app inventory reports it is ${status}; authenticate or enable the app in Codex before migrating it to AutoBot.`;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
export function codexPluginMigrationSubscriptionWarning(): string {
|
|
539
|
-
return "Codex app-backed plugin migration requires the Codex app-server source account to be logged in with a ChatGPT subscription account. Log in to the Codex app with subscription auth; AutoBot auth or API-key auth does not satisfy Codex app connector access.";
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
function codexSubscriptionRequiredMessage(plugin: CodexPluginSource): string {
|
|
543
|
-
return `Codex plugin "${plugin.pluginName ?? plugin.name}" owns apps, but ${codexPluginMigrationSubscriptionWarning()}`;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
function pluginNameFromSummary(summary: v2.PluginSummary): string | undefined {
|
|
547
|
-
const candidates = [summary.id, summary.name];
|
|
548
|
-
for (const candidate of candidates) {
|
|
549
|
-
const trimmed = candidate.trim();
|
|
550
|
-
if (!trimmed) {
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
|
-
const withoutMarketplaceSuffix = trimmed.endsWith(`@${CODEX_PLUGINS_MARKETPLACE_NAME}`)
|
|
554
|
-
? trimmed.slice(0, -`@${CODEX_PLUGINS_MARKETPLACE_NAME}`.length)
|
|
555
|
-
: trimmed;
|
|
556
|
-
const pathSegment = withoutMarketplaceSuffix.split("/").at(-1)?.trim();
|
|
557
|
-
const normalized = pathSegment?.toLowerCase().replaceAll(/\s+/gu, "-");
|
|
558
|
-
if (normalized) {
|
|
559
|
-
return normalized;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
return undefined;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
export async function discoverCodexSource(
|
|
566
|
-
inputOrOptions?: string | CodexSourceDiscoveryOptions,
|
|
567
|
-
): Promise<CodexSource> {
|
|
568
|
-
const options =
|
|
569
|
-
typeof inputOrOptions === "string" || inputOrOptions === undefined
|
|
570
|
-
? { input: inputOrOptions }
|
|
571
|
-
: inputOrOptions;
|
|
572
|
-
const codexHome = resolveHomePath(options.input?.trim() || defaultCodexHome());
|
|
573
|
-
const codexSkillsDir = path.join(codexHome, "skills");
|
|
574
|
-
const agentsSkillsDir = personalAgentsSkillsDir();
|
|
575
|
-
const configPath = path.join(codexHome, "config.toml");
|
|
576
|
-
const hooksPath = path.join(codexHome, "hooks", "hooks.json");
|
|
577
|
-
const codexSkills = await discoverSkillDirs({
|
|
578
|
-
root: codexSkillsDir,
|
|
579
|
-
sourceLabel: "Codex skill",
|
|
580
|
-
excludeSystem: true,
|
|
581
|
-
});
|
|
582
|
-
const personalAgentSkills = await discoverSkillDirs({
|
|
583
|
-
root: agentsSkillsDir,
|
|
584
|
-
sourceLabel: "personal AgentSkill",
|
|
585
|
-
});
|
|
586
|
-
const sourcePluginDiscovery = await discoverInstalledCuratedPlugins(codexHome, options);
|
|
587
|
-
const sourcePluginNames = new Set(
|
|
588
|
-
sourcePluginDiscovery.plugins.flatMap((plugin) =>
|
|
589
|
-
plugin.pluginName ? [plugin.pluginName] : [],
|
|
590
|
-
),
|
|
591
|
-
);
|
|
592
|
-
const cachedPlugins = (await discoverPluginDirs(codexHome)).filter((plugin) => {
|
|
593
|
-
const normalizedName = sanitizePluginName(plugin.name);
|
|
594
|
-
return !sourcePluginNames.has(normalizedName);
|
|
595
|
-
});
|
|
596
|
-
const plugins = [...sourcePluginDiscovery.plugins, ...cachedPlugins].toSorted((a, b) =>
|
|
597
|
-
a.source.localeCompare(b.source),
|
|
598
|
-
);
|
|
599
|
-
const archivePaths: CodexArchiveSource[] = [];
|
|
600
|
-
if (await exists(configPath)) {
|
|
601
|
-
archivePaths.push({
|
|
602
|
-
id: "archive:config.toml",
|
|
603
|
-
path: configPath,
|
|
604
|
-
relativePath: "config.toml",
|
|
605
|
-
message: "Codex config is archived for manual review; it is not activated automatically",
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
if (await exists(hooksPath)) {
|
|
609
|
-
archivePaths.push({
|
|
610
|
-
id: "archive:hooks/hooks.json",
|
|
611
|
-
path: hooksPath,
|
|
612
|
-
relativePath: "hooks/hooks.json",
|
|
613
|
-
message:
|
|
614
|
-
"Codex native hooks are archived for manual review because they can execute commands",
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
const skills = [...codexSkills, ...personalAgentSkills].toSorted((a, b) =>
|
|
618
|
-
a.source.localeCompare(b.source),
|
|
619
|
-
);
|
|
620
|
-
const high = Boolean(codexSkills.length || plugins.length || archivePaths.length);
|
|
621
|
-
const medium = personalAgentSkills.length > 0;
|
|
622
|
-
return {
|
|
623
|
-
root: codexHome,
|
|
624
|
-
confidence: high ? "high" : medium ? "medium" : "low",
|
|
625
|
-
codexHome,
|
|
626
|
-
...((await isDirectory(codexSkillsDir)) ? { codexSkillsDir } : {}),
|
|
627
|
-
...((await isDirectory(agentsSkillsDir)) ? { personalAgentsSkillsDir: agentsSkillsDir } : {}),
|
|
628
|
-
...((await exists(configPath)) ? { configPath } : {}),
|
|
629
|
-
...((await exists(hooksPath)) ? { hooksPath } : {}),
|
|
630
|
-
skills,
|
|
631
|
-
plugins,
|
|
632
|
-
...(sourcePluginDiscovery.error ? { pluginDiscoveryError: sourcePluginDiscovery.error } : {}),
|
|
633
|
-
archivePaths,
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
export function hasCodexSource(source: CodexSource): boolean {
|
|
638
|
-
return source.confidence !== "low";
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
function sanitizePluginName(value: string): string {
|
|
642
|
-
return value.trim().toLowerCase().replaceAll(/\s+/gu, "-");
|
|
643
|
-
}
|
package/src/migration/targets.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import {
|
|
3
|
-
resolveAgentConfig,
|
|
4
|
-
resolveAgentWorkspaceDir,
|
|
5
|
-
resolveDefaultAgentId,
|
|
6
|
-
} from "autobot/plugin-sdk/agent-runtime";
|
|
7
|
-
import type { MigrationProviderContext } from "autobot/plugin-sdk/plugin-entry";
|
|
8
|
-
import { resolveHomePath } from "./helpers.js";
|
|
9
|
-
|
|
10
|
-
type CodexMigrationTargets = {
|
|
11
|
-
workspaceDir: string;
|
|
12
|
-
agentDir: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export function resolveCodexMigrationTargets(ctx: MigrationProviderContext): CodexMigrationTargets {
|
|
16
|
-
const cfg = ctx.config;
|
|
17
|
-
const agentId = resolveDefaultAgentId(cfg);
|
|
18
|
-
const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);
|
|
19
|
-
const configuredAgentDir = resolveAgentConfig(cfg, agentId)?.agentDir?.trim();
|
|
20
|
-
const agentDir =
|
|
21
|
-
ctx.runtime?.agent?.resolveAgentDir(cfg, agentId) ??
|
|
22
|
-
(configuredAgentDir ? resolveHomePath(configuredAgentDir) : undefined) ??
|
|
23
|
-
path.join(ctx.stateDir, "agents", agentId, "agent");
|
|
24
|
-
return { workspaceDir, agentDir };
|
|
25
|
-
}
|