@gakr-gakr/codex 0.1.0
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/autobot.plugin.json +374 -0
- package/doctor-contract-api.ts +68 -0
- package/harness.ts +72 -0
- package/index.ts +124 -0
- package/media-understanding-provider.ts +521 -0
- package/package.json +40 -0
- package/prompt-overlay.ts +21 -0
- package/provider-catalog.ts +83 -0
- package/provider-discovery.ts +45 -0
- package/provider.ts +243 -0
- package/src/app-server/app-inventory-cache.ts +324 -0
- package/src/app-server/approval-bridge.ts +1211 -0
- package/src/app-server/auth-bridge.ts +614 -0
- package/src/app-server/capabilities.ts +27 -0
- package/src/app-server/client-factory.ts +24 -0
- package/src/app-server/client.ts +715 -0
- package/src/app-server/compact.ts +512 -0
- package/src/app-server/computer-use.ts +683 -0
- package/src/app-server/config.ts +1038 -0
- package/src/app-server/context-engine-projection.ts +403 -0
- package/src/app-server/dynamic-tool-diagnostics.ts +73 -0
- package/src/app-server/dynamic-tool-profile.ts +70 -0
- package/src/app-server/dynamic-tools.ts +623 -0
- package/src/app-server/elicitation-bridge.ts +783 -0
- package/src/app-server/event-projector.ts +2065 -0
- package/src/app-server/image-payload-sanitizer.ts +167 -0
- package/src/app-server/local-runtime-attribution.ts +39 -0
- package/src/app-server/managed-binary.ts +193 -0
- package/src/app-server/models.ts +172 -0
- package/src/app-server/native-hook-relay.ts +150 -0
- package/src/app-server/native-subagent-task-mirror.ts +497 -0
- package/src/app-server/plugin-activation.ts +283 -0
- package/src/app-server/plugin-app-cache-key.ts +74 -0
- package/src/app-server/plugin-approval-roundtrip.ts +122 -0
- package/src/app-server/plugin-inventory.ts +357 -0
- package/src/app-server/plugin-thread-config.ts +455 -0
- package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +33 -0
- package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +199 -0
- package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +102 -0
- package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +227 -0
- package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +2630 -0
- package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +2630 -0
- package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +1659 -0
- package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +1655 -0
- package/src/app-server/protocol-validators.ts +203 -0
- package/src/app-server/protocol.ts +520 -0
- package/src/app-server/rate-limit-cache.ts +48 -0
- package/src/app-server/rate-limits.ts +583 -0
- package/src/app-server/request.ts +73 -0
- package/src/app-server/run-attempt.ts +4862 -0
- package/src/app-server/session-binding.ts +398 -0
- package/src/app-server/session-history.ts +44 -0
- package/src/app-server/shared-client.ts +289 -0
- package/src/app-server/side-question.ts +1009 -0
- package/src/app-server/test-support.ts +48 -0
- package/src/app-server/thread-lifecycle.ts +959 -0
- package/src/app-server/timeout.ts +9 -0
- package/src/app-server/tool-progress-normalization.ts +77 -0
- package/src/app-server/trajectory.ts +368 -0
- package/src/app-server/transcript-mirror.ts +208 -0
- package/src/app-server/transport-stdio.ts +107 -0
- package/src/app-server/transport-websocket.ts +90 -0
- package/src/app-server/transport.ts +117 -0
- package/src/app-server/user-input-bridge.ts +316 -0
- package/src/app-server/version.ts +4 -0
- package/src/app-server/vision-tools.ts +12 -0
- package/src/command-account.ts +544 -0
- package/src/command-formatters.ts +426 -0
- package/src/command-handlers.ts +2021 -0
- package/src/command-plugins-management.ts +137 -0
- package/src/command-rpc.ts +142 -0
- package/src/commands.ts +65 -0
- package/src/conversation-binding-data.ts +124 -0
- package/src/conversation-binding.ts +561 -0
- package/src/conversation-control.ts +303 -0
- package/src/conversation-turn-collector.ts +186 -0
- package/src/conversation-turn-input.ts +106 -0
- package/src/migration/apply.ts +501 -0
- package/src/migration/helpers.ts +55 -0
- package/src/migration/plan.ts +461 -0
- package/src/migration/provider.ts +41 -0
- package/src/migration/source.ts +643 -0
- package/src/migration/targets.ts +25 -0
- package/src/node-cli-sessions.ts +711 -0
- package/test-api.ts +95 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { embeddedAgentLog } from "autobot/plugin-sdk/agent-harness-runtime";
|
|
2
|
+
import {
|
|
3
|
+
type CodexAppInventoryCache,
|
|
4
|
+
type CodexAppInventoryCacheRead,
|
|
5
|
+
type CodexAppInventoryRequest,
|
|
6
|
+
} from "./app-inventory-cache.js";
|
|
7
|
+
import {
|
|
8
|
+
CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
9
|
+
resolveCodexPluginsPolicy,
|
|
10
|
+
type ResolvedCodexPluginPolicy,
|
|
11
|
+
type ResolvedCodexPluginsPolicy,
|
|
12
|
+
} from "./config.js";
|
|
13
|
+
import type { v2 } from "./protocol.js";
|
|
14
|
+
|
|
15
|
+
export type CodexPluginRuntimeRequest = (method: string, params?: unknown) => Promise<unknown>;
|
|
16
|
+
|
|
17
|
+
export type CodexPluginMarketplaceRef = {
|
|
18
|
+
name: typeof CODEX_PLUGINS_MARKETPLACE_NAME;
|
|
19
|
+
path?: string;
|
|
20
|
+
remoteMarketplaceName?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type CodexPluginInventoryDiagnosticCode =
|
|
24
|
+
| "disabled"
|
|
25
|
+
| "marketplace_missing"
|
|
26
|
+
| "plugin_missing"
|
|
27
|
+
| "plugin_disabled"
|
|
28
|
+
| "plugin_detail_unavailable"
|
|
29
|
+
| "app_inventory_missing"
|
|
30
|
+
| "app_inventory_stale"
|
|
31
|
+
| "app_ownership_ambiguous";
|
|
32
|
+
|
|
33
|
+
export type CodexPluginInventoryDiagnostic = {
|
|
34
|
+
code: CodexPluginInventoryDiagnosticCode;
|
|
35
|
+
plugin?: ResolvedCodexPluginPolicy;
|
|
36
|
+
message: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type CodexPluginOwnedApp = {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
accessible: boolean;
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
needsAuth: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type CodexPluginInventoryRecord = {
|
|
48
|
+
policy: ResolvedCodexPluginPolicy;
|
|
49
|
+
summary: v2.PluginSummary;
|
|
50
|
+
detail?: v2.PluginDetail;
|
|
51
|
+
activationRequired: boolean;
|
|
52
|
+
authRequired: boolean;
|
|
53
|
+
appOwnership: "proven" | "ambiguous" | "none";
|
|
54
|
+
ownedAppIds: string[];
|
|
55
|
+
apps: CodexPluginOwnedApp[];
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type CodexPluginInventory = {
|
|
59
|
+
policy: ResolvedCodexPluginsPolicy;
|
|
60
|
+
marketplace?: CodexPluginMarketplaceRef;
|
|
61
|
+
records: CodexPluginInventoryRecord[];
|
|
62
|
+
diagnostics: CodexPluginInventoryDiagnostic[];
|
|
63
|
+
appInventory?: CodexAppInventoryCacheRead;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type ReadCodexPluginInventoryParams = {
|
|
67
|
+
pluginConfig?: unknown;
|
|
68
|
+
policy?: ResolvedCodexPluginsPolicy;
|
|
69
|
+
request: CodexPluginRuntimeRequest;
|
|
70
|
+
appCache?: CodexAppInventoryCache;
|
|
71
|
+
appCacheKey?: string;
|
|
72
|
+
nowMs?: number;
|
|
73
|
+
readPluginDetails?: boolean;
|
|
74
|
+
suppressAppInventoryRefresh?: boolean;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export async function readCodexPluginInventory(
|
|
78
|
+
params: ReadCodexPluginInventoryParams,
|
|
79
|
+
): Promise<CodexPluginInventory> {
|
|
80
|
+
const policy = params.policy ?? resolveCodexPluginsPolicy(params.pluginConfig);
|
|
81
|
+
if (!policy.enabled) {
|
|
82
|
+
return {
|
|
83
|
+
policy,
|
|
84
|
+
records: [],
|
|
85
|
+
diagnostics: [
|
|
86
|
+
{
|
|
87
|
+
code: "disabled",
|
|
88
|
+
message: "Native Codex plugin support is disabled.",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const appInventory = readCachedAppInventory(params);
|
|
95
|
+
const listed = (await params.request("plugin/list", {
|
|
96
|
+
cwds: [],
|
|
97
|
+
} satisfies v2.PluginListParams)) as v2.PluginListResponse;
|
|
98
|
+
const marketplaceEntry = listed.marketplaces.find(
|
|
99
|
+
(marketplace) => marketplace.name === CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
100
|
+
);
|
|
101
|
+
if (!marketplaceEntry) {
|
|
102
|
+
return {
|
|
103
|
+
policy,
|
|
104
|
+
records: [],
|
|
105
|
+
diagnostics: policy.pluginPolicies
|
|
106
|
+
.filter((pluginPolicy) => pluginPolicy.enabled)
|
|
107
|
+
.map((pluginPolicy) => ({
|
|
108
|
+
code: "marketplace_missing",
|
|
109
|
+
plugin: pluginPolicy,
|
|
110
|
+
message: `Codex marketplace ${CODEX_PLUGINS_MARKETPLACE_NAME} was not found.`,
|
|
111
|
+
})),
|
|
112
|
+
...(appInventory ? { appInventory } : {}),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const marketplace = marketplaceRef(marketplaceEntry);
|
|
117
|
+
const diagnostics: CodexPluginInventoryDiagnostic[] = [];
|
|
118
|
+
const records: CodexPluginInventoryRecord[] = [];
|
|
119
|
+
if (appInventory?.state === "missing") {
|
|
120
|
+
diagnostics.push({
|
|
121
|
+
code: "app_inventory_missing",
|
|
122
|
+
message: "Cached Codex app inventory is missing; plugin apps are excluded for this setup.",
|
|
123
|
+
});
|
|
124
|
+
} else if (appInventory?.state === "stale") {
|
|
125
|
+
diagnostics.push({
|
|
126
|
+
code: "app_inventory_stale",
|
|
127
|
+
message: "Cached Codex app inventory is stale; using stale app readiness and refreshing.",
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
for (const pluginPolicy of policy.pluginPolicies) {
|
|
132
|
+
if (!pluginPolicy.enabled) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const summary = findPluginSummary(marketplaceEntry, pluginPolicy.pluginName);
|
|
136
|
+
if (!summary) {
|
|
137
|
+
diagnostics.push({
|
|
138
|
+
code: "plugin_missing",
|
|
139
|
+
plugin: pluginPolicy,
|
|
140
|
+
message: `${pluginPolicy.pluginName} was not found in ${CODEX_PLUGINS_MARKETPLACE_NAME}.`,
|
|
141
|
+
});
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const detail = await readPluginDetail(params, marketplace, pluginPolicy, diagnostics);
|
|
146
|
+
const ownedAppIds =
|
|
147
|
+
detail?.apps
|
|
148
|
+
.map((app) => app.id)
|
|
149
|
+
.filter(Boolean)
|
|
150
|
+
.toSorted() ?? [];
|
|
151
|
+
const appOwnership = resolveAppOwnership({
|
|
152
|
+
detail,
|
|
153
|
+
appInventory,
|
|
154
|
+
summary,
|
|
155
|
+
});
|
|
156
|
+
if (appOwnership === "ambiguous") {
|
|
157
|
+
diagnostics.push({
|
|
158
|
+
code: "app_ownership_ambiguous",
|
|
159
|
+
plugin: pluginPolicy,
|
|
160
|
+
message: `${pluginPolicy.pluginName} has only display-name app matches; apps are not exposed until ownership is stable.`,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (summary.installed && !summary.enabled) {
|
|
164
|
+
diagnostics.push({
|
|
165
|
+
code: "plugin_disabled",
|
|
166
|
+
plugin: pluginPolicy,
|
|
167
|
+
message: `${pluginPolicy.pluginName} is installed in Codex but disabled.`,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const apps = resolveOwnedApps({
|
|
172
|
+
pluginPolicy,
|
|
173
|
+
detail,
|
|
174
|
+
appInventory,
|
|
175
|
+
});
|
|
176
|
+
records.push({
|
|
177
|
+
policy: pluginPolicy,
|
|
178
|
+
summary,
|
|
179
|
+
...(detail ? { detail } : {}),
|
|
180
|
+
activationRequired: !summary.installed || !summary.enabled,
|
|
181
|
+
authRequired: apps.some((app) => app.needsAuth || !app.accessible),
|
|
182
|
+
appOwnership,
|
|
183
|
+
ownedAppIds,
|
|
184
|
+
apps,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const inventory = {
|
|
189
|
+
policy,
|
|
190
|
+
marketplace,
|
|
191
|
+
records,
|
|
192
|
+
diagnostics,
|
|
193
|
+
...(appInventory ? { appInventory } : {}),
|
|
194
|
+
};
|
|
195
|
+
return inventory;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function findOpenAiCuratedPluginSummary(
|
|
199
|
+
listed: v2.PluginListResponse,
|
|
200
|
+
pluginName: string,
|
|
201
|
+
): { marketplace: CodexPluginMarketplaceRef; summary: v2.PluginSummary } | undefined {
|
|
202
|
+
const marketplaceEntry = listed.marketplaces.find(
|
|
203
|
+
(marketplace) => marketplace.name === CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
204
|
+
);
|
|
205
|
+
if (!marketplaceEntry) {
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
const summary = findPluginSummary(marketplaceEntry, pluginName);
|
|
209
|
+
return summary ? { marketplace: marketplaceRef(marketplaceEntry), summary } : undefined;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function pluginReadParams(
|
|
213
|
+
marketplace: CodexPluginMarketplaceRef,
|
|
214
|
+
pluginName: string,
|
|
215
|
+
): v2.PluginReadParams {
|
|
216
|
+
return {
|
|
217
|
+
...(marketplace.path ? { marketplacePath: marketplace.path } : {}),
|
|
218
|
+
...(marketplace.remoteMarketplaceName
|
|
219
|
+
? { remoteMarketplaceName: marketplace.remoteMarketplaceName }
|
|
220
|
+
: {}),
|
|
221
|
+
pluginName,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function readCachedAppInventory(
|
|
226
|
+
params: ReadCodexPluginInventoryParams,
|
|
227
|
+
): CodexAppInventoryCacheRead | undefined {
|
|
228
|
+
if (!params.appCache || !params.appCacheKey) {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
const request: CodexAppInventoryRequest = async (method, requestParams) =>
|
|
232
|
+
(await params.request(method, requestParams)) as v2.AppsListResponse;
|
|
233
|
+
return params.appCache.read({
|
|
234
|
+
key: params.appCacheKey,
|
|
235
|
+
request,
|
|
236
|
+
nowMs: params.nowMs,
|
|
237
|
+
suppressRefresh: params.suppressAppInventoryRefresh,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async function readPluginDetail(
|
|
242
|
+
params: ReadCodexPluginInventoryParams,
|
|
243
|
+
marketplace: CodexPluginMarketplaceRef,
|
|
244
|
+
pluginPolicy: ResolvedCodexPluginPolicy,
|
|
245
|
+
diagnostics: CodexPluginInventoryDiagnostic[],
|
|
246
|
+
): Promise<v2.PluginDetail | undefined> {
|
|
247
|
+
if (params.readPluginDetails === false) {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
const response = (await params.request(
|
|
252
|
+
"plugin/read",
|
|
253
|
+
pluginReadParams(marketplace, pluginPolicy.pluginName),
|
|
254
|
+
)) as v2.PluginReadResponse;
|
|
255
|
+
return response.plugin;
|
|
256
|
+
} catch (error) {
|
|
257
|
+
diagnostics.push({
|
|
258
|
+
code: "plugin_detail_unavailable",
|
|
259
|
+
plugin: pluginPolicy,
|
|
260
|
+
message: `${pluginPolicy.pluginName} detail unavailable: ${
|
|
261
|
+
error instanceof Error ? error.message : String(error)
|
|
262
|
+
}`,
|
|
263
|
+
});
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function resolveAppOwnership(params: {
|
|
269
|
+
detail?: v2.PluginDetail;
|
|
270
|
+
appInventory?: CodexAppInventoryCacheRead;
|
|
271
|
+
summary: v2.PluginSummary;
|
|
272
|
+
}): "proven" | "ambiguous" | "none" {
|
|
273
|
+
if (params.detail && params.detail.apps.length > 0) {
|
|
274
|
+
return "proven";
|
|
275
|
+
}
|
|
276
|
+
const apps = params.appInventory?.snapshot?.apps ?? [];
|
|
277
|
+
const displayMatches = apps.filter((app) =>
|
|
278
|
+
app.pluginDisplayNames.some((displayName) => displayName === params.summary.name),
|
|
279
|
+
);
|
|
280
|
+
return displayMatches.length > 0 ? "ambiguous" : "none";
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function resolveOwnedApps(params: {
|
|
284
|
+
pluginPolicy: ResolvedCodexPluginPolicy;
|
|
285
|
+
detail?: v2.PluginDetail;
|
|
286
|
+
appInventory?: CodexAppInventoryCacheRead;
|
|
287
|
+
}): CodexPluginOwnedApp[] {
|
|
288
|
+
const detailApps = params.detail?.apps ?? [];
|
|
289
|
+
if (detailApps.length === 0) {
|
|
290
|
+
return [];
|
|
291
|
+
}
|
|
292
|
+
if (params.appInventory?.state === "missing") {
|
|
293
|
+
embeddedAgentLog.warn("codex plugin inventory missing app inventory for detail apps", {
|
|
294
|
+
configKey: params.pluginPolicy.configKey,
|
|
295
|
+
pluginName: params.pluginPolicy.pluginName,
|
|
296
|
+
appIds: detailApps.map((app) => app.id).toSorted(),
|
|
297
|
+
});
|
|
298
|
+
return [];
|
|
299
|
+
}
|
|
300
|
+
const appInfoById = new Map(
|
|
301
|
+
(params.appInventory?.snapshot?.apps ?? []).map((app) => [app.id, app] as const),
|
|
302
|
+
);
|
|
303
|
+
return detailApps
|
|
304
|
+
.map((app) => {
|
|
305
|
+
const info = appInfoById.get(app.id);
|
|
306
|
+
if (!info) {
|
|
307
|
+
return {
|
|
308
|
+
id: app.id,
|
|
309
|
+
name: app.name,
|
|
310
|
+
accessible: false,
|
|
311
|
+
enabled: false,
|
|
312
|
+
needsAuth: true,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
id: app.id,
|
|
317
|
+
name: app.name,
|
|
318
|
+
accessible: info.isAccessible,
|
|
319
|
+
enabled: info.isEnabled,
|
|
320
|
+
needsAuth: app.needsAuth || !info.isAccessible,
|
|
321
|
+
};
|
|
322
|
+
})
|
|
323
|
+
.toSorted((left, right) => left.id.localeCompare(right.id));
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function findPluginSummary(
|
|
327
|
+
marketplace: v2.PluginMarketplaceEntry,
|
|
328
|
+
pluginName: string,
|
|
329
|
+
): v2.PluginSummary | undefined {
|
|
330
|
+
return marketplace.plugins.find(
|
|
331
|
+
(plugin) =>
|
|
332
|
+
plugin.name === pluginName ||
|
|
333
|
+
plugin.id === pluginName ||
|
|
334
|
+
plugin.id === `${pluginName}@${marketplace.name}` ||
|
|
335
|
+
pluginNameFromPluginId(plugin.id, marketplace.name) === pluginName,
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function pluginNameFromPluginId(pluginId: string, marketplaceName: string): string | undefined {
|
|
340
|
+
const trimmed = pluginId.trim();
|
|
341
|
+
if (!trimmed) {
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
const marketplaceSuffix = `@${marketplaceName}`;
|
|
345
|
+
const withoutMarketplaceSuffix = trimmed.endsWith(marketplaceSuffix)
|
|
346
|
+
? trimmed.slice(0, -marketplaceSuffix.length)
|
|
347
|
+
: trimmed;
|
|
348
|
+
return withoutMarketplaceSuffix.split("/").at(-1)?.trim() || undefined;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function marketplaceRef(marketplace: v2.PluginMarketplaceEntry): CodexPluginMarketplaceRef {
|
|
352
|
+
return {
|
|
353
|
+
name: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
354
|
+
...(marketplace.path ? { path: marketplace.path } : {}),
|
|
355
|
+
...(!marketplace.path ? { remoteMarketplaceName: marketplace.name } : {}),
|
|
356
|
+
};
|
|
357
|
+
}
|