@gakr-gakr/codex 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/client-DNN2uyJW.js +642 -0
  2. package/dist/client-factory-Bu9OClHJ.js +9 -0
  3. package/dist/command-formatters-BpPOTePl.js +520 -0
  4. package/dist/command-handlers-BBs7Vws9.js +1533 -0
  5. package/dist/compact-CDboBy7o.js +329 -0
  6. package/dist/computer-use-DCZB46Sw.js +367 -0
  7. package/dist/config-CLMSw0p2.js +510 -0
  8. package/dist/doctor-contract-api.js +53 -0
  9. package/dist/harness.js +51 -0
  10. package/dist/index.js +1171 -0
  11. package/dist/media-understanding-provider.js +335 -0
  12. package/dist/models-jLA2SIvd.js +110 -0
  13. package/dist/node-cli-sessions-BLRDs_US.js +1216 -0
  14. package/dist/plugin-activation-CEy_oYpx.js +452 -0
  15. package/dist/prompt-overlay.js +12 -0
  16. package/dist/protocol-C9UWI98H.js +9 -0
  17. package/dist/protocol-validators-BGBspNmF.js +5988 -0
  18. package/dist/provider-catalog.js +84 -0
  19. package/dist/provider-discovery.js +33 -0
  20. package/dist/provider.js +150 -0
  21. package/dist/rate-limit-cache-9LxQdE0K.js +24 -0
  22. package/dist/request-DbSPeTcV.js +89 -0
  23. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  24. package/dist/run-attempt-BoEwzQCv.js +5463 -0
  25. package/dist/session-binding-e2GFp9VH.js +222 -0
  26. package/dist/shared-client-D7Vy0glq.js +631 -0
  27. package/dist/side-question-BDLuEzFP.js +668 -0
  28. package/dist/test-api.js +49 -0
  29. package/dist/thread-lifecycle-Clo0EHMk.js +1565 -0
  30. package/dist/vision-tools-Cofrv35p.js +1379 -0
  31. package/package.json +16 -1
  32. package/doctor-contract-api.ts +0 -68
  33. package/harness.ts +0 -72
  34. package/index.ts +0 -124
  35. package/media-understanding-provider.ts +0 -521
  36. package/prompt-overlay.ts +0 -21
  37. package/provider-catalog.ts +0 -83
  38. package/provider-discovery.ts +0 -45
  39. package/provider.ts +0 -243
  40. package/src/app-server/app-inventory-cache.ts +0 -324
  41. package/src/app-server/approval-bridge.ts +0 -1211
  42. package/src/app-server/auth-bridge.ts +0 -614
  43. package/src/app-server/capabilities.ts +0 -27
  44. package/src/app-server/client-factory.ts +0 -24
  45. package/src/app-server/client.ts +0 -715
  46. package/src/app-server/compact.ts +0 -512
  47. package/src/app-server/computer-use.ts +0 -683
  48. package/src/app-server/config.ts +0 -1038
  49. package/src/app-server/context-engine-projection.ts +0 -403
  50. package/src/app-server/dynamic-tool-diagnostics.ts +0 -73
  51. package/src/app-server/dynamic-tool-profile.ts +0 -70
  52. package/src/app-server/dynamic-tools.ts +0 -623
  53. package/src/app-server/elicitation-bridge.ts +0 -783
  54. package/src/app-server/event-projector.ts +0 -2065
  55. package/src/app-server/image-payload-sanitizer.ts +0 -167
  56. package/src/app-server/local-runtime-attribution.ts +0 -39
  57. package/src/app-server/managed-binary.ts +0 -193
  58. package/src/app-server/models.ts +0 -172
  59. package/src/app-server/native-hook-relay.ts +0 -150
  60. package/src/app-server/native-subagent-task-mirror.ts +0 -497
  61. package/src/app-server/plugin-activation.ts +0 -283
  62. package/src/app-server/plugin-app-cache-key.ts +0 -74
  63. package/src/app-server/plugin-approval-roundtrip.ts +0 -122
  64. package/src/app-server/plugin-inventory.ts +0 -357
  65. package/src/app-server/plugin-thread-config.ts +0 -455
  66. package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +0 -33
  67. package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +0 -199
  68. package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +0 -102
  69. package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +0 -227
  70. package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +0 -2630
  71. package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +0 -2630
  72. package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +0 -1659
  73. package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +0 -1655
  74. package/src/app-server/protocol-validators.ts +0 -203
  75. package/src/app-server/protocol.ts +0 -520
  76. package/src/app-server/rate-limit-cache.ts +0 -48
  77. package/src/app-server/rate-limits.ts +0 -583
  78. package/src/app-server/request.ts +0 -73
  79. package/src/app-server/run-attempt.ts +0 -4862
  80. package/src/app-server/session-binding.ts +0 -398
  81. package/src/app-server/session-history.ts +0 -44
  82. package/src/app-server/shared-client.ts +0 -289
  83. package/src/app-server/side-question.ts +0 -1009
  84. package/src/app-server/test-support.ts +0 -48
  85. package/src/app-server/thread-lifecycle.ts +0 -959
  86. package/src/app-server/timeout.ts +0 -9
  87. package/src/app-server/tool-progress-normalization.ts +0 -77
  88. package/src/app-server/trajectory.ts +0 -368
  89. package/src/app-server/transcript-mirror.ts +0 -208
  90. package/src/app-server/transport-stdio.ts +0 -107
  91. package/src/app-server/transport-websocket.ts +0 -90
  92. package/src/app-server/transport.ts +0 -117
  93. package/src/app-server/user-input-bridge.ts +0 -316
  94. package/src/app-server/version.ts +0 -4
  95. package/src/app-server/vision-tools.ts +0 -12
  96. package/src/command-account.ts +0 -544
  97. package/src/command-formatters.ts +0 -426
  98. package/src/command-handlers.ts +0 -2021
  99. package/src/command-plugins-management.ts +0 -137
  100. package/src/command-rpc.ts +0 -142
  101. package/src/commands.ts +0 -65
  102. package/src/conversation-binding-data.ts +0 -124
  103. package/src/conversation-binding.ts +0 -561
  104. package/src/conversation-control.ts +0 -303
  105. package/src/conversation-turn-collector.ts +0 -186
  106. package/src/conversation-turn-input.ts +0 -106
  107. package/src/migration/apply.ts +0 -501
  108. package/src/migration/helpers.ts +0 -55
  109. package/src/migration/plan.ts +0 -461
  110. package/src/migration/provider.ts +0 -41
  111. package/src/migration/source.ts +0 -643
  112. package/src/migration/targets.ts +0 -25
  113. package/src/node-cli-sessions.ts +0 -711
  114. package/test-api.ts +0 -95
  115. package/tsconfig.json +0 -16
@@ -0,0 +1,452 @@
1
+ import { t as CODEX_PLUGINS_MARKETPLACE_NAME, u as resolveCodexPluginsPolicy } from "./config-CLMSw0p2.js";
2
+ import { embeddedAgentLog } from "autobot/plugin-sdk/agent-harness-runtime";
3
+ import "node:fs/promises";
4
+ import "node:path";
5
+ const MAX_SERIALIZED_ERROR_MESSAGE_LENGTH = 500;
6
+ var CodexAppInventoryCache = class {
7
+ constructor(options = {}) {
8
+ this.entries = /* @__PURE__ */ new Map();
9
+ this.inFlight = /* @__PURE__ */ new Map();
10
+ this.refreshTokens = /* @__PURE__ */ new Map();
11
+ this.diagnostics = /* @__PURE__ */ new Map();
12
+ this.revision = 0;
13
+ this.ttlMs = options.ttlMs ?? 36e5;
14
+ }
15
+ read(params) {
16
+ const nowMs = params.nowMs ?? Date.now();
17
+ const entry = this.entries.get(params.key);
18
+ if (!entry) {
19
+ const refreshScheduled = params.suppressRefresh ? false : this.scheduleRefresh(params);
20
+ return {
21
+ state: "missing",
22
+ key: params.key,
23
+ revision: this.revision,
24
+ refreshScheduled,
25
+ ...this.diagnostics.get(params.key) ? { diagnostic: this.diagnostics.get(params.key) } : {}
26
+ };
27
+ }
28
+ const state = entry.invalidated || entry.expiresAtMs <= nowMs ? "stale" : "fresh";
29
+ const refreshScheduled = state === "fresh" && !params.forceRefetch ? false : this.scheduleRefresh(params);
30
+ return {
31
+ state,
32
+ key: params.key,
33
+ revision: entry.revision,
34
+ snapshot: stripEntryState(entry),
35
+ refreshScheduled,
36
+ ...entry.lastError ? { diagnostic: entry.lastError } : {}
37
+ };
38
+ }
39
+ refreshNow(params) {
40
+ return this.refresh(params);
41
+ }
42
+ invalidate(key, reason, nowMs = Date.now()) {
43
+ this.revision += 1;
44
+ const diagnostic = {
45
+ message: reason,
46
+ atMs: nowMs
47
+ };
48
+ const entry = this.entries.get(key);
49
+ if (entry) {
50
+ entry.invalidated = true;
51
+ entry.lastError = diagnostic;
52
+ entry.revision = this.revision;
53
+ } else this.diagnostics.set(key, diagnostic);
54
+ return this.revision;
55
+ }
56
+ clear() {
57
+ this.entries.clear();
58
+ this.inFlight.clear();
59
+ this.refreshTokens.clear();
60
+ this.diagnostics.clear();
61
+ this.revision = 0;
62
+ }
63
+ getRevision() {
64
+ return this.revision;
65
+ }
66
+ scheduleRefresh(params) {
67
+ if (this.inFlight.has(params.key) && !params.forceRefetch) return true;
68
+ const promise = this.refresh(params);
69
+ this.inFlight.set(params.key, promise);
70
+ promise.catch(() => void 0);
71
+ return true;
72
+ }
73
+ async refresh(params) {
74
+ const existing = this.inFlight.get(params.key);
75
+ if (existing && !params.forceRefetch) return existing;
76
+ const refreshToken = (this.refreshTokens.get(params.key) ?? 0) + 1;
77
+ this.refreshTokens.set(params.key, refreshToken);
78
+ const promise = this.refreshUncoalesced(params, refreshToken);
79
+ this.inFlight.set(params.key, promise);
80
+ try {
81
+ return await promise;
82
+ } finally {
83
+ if (this.inFlight.get(params.key) === promise) this.inFlight.delete(params.key);
84
+ }
85
+ }
86
+ async refreshUncoalesced(params, refreshToken) {
87
+ const nowMs = params.nowMs ?? Date.now();
88
+ try {
89
+ const apps = await listAllApps(params.request, params.forceRefetch ?? false);
90
+ this.revision += 1;
91
+ const snapshot = {
92
+ key: params.key,
93
+ apps,
94
+ fetchedAtMs: nowMs,
95
+ expiresAtMs: nowMs + this.ttlMs,
96
+ revision: this.revision
97
+ };
98
+ if (this.refreshTokens.get(params.key) === refreshToken) {
99
+ this.entries.set(params.key, {
100
+ ...snapshot,
101
+ invalidated: false
102
+ });
103
+ this.diagnostics.delete(params.key);
104
+ }
105
+ return snapshot;
106
+ } catch (error) {
107
+ const diagnostic = {
108
+ message: sanitizeErrorMessage(error instanceof Error ? error.message : String(error)),
109
+ atMs: nowMs
110
+ };
111
+ this.diagnostics.set(params.key, diagnostic);
112
+ const entry = this.entries.get(params.key);
113
+ if (entry) entry.lastError = diagnostic;
114
+ embeddedAgentLog.warn("codex app inventory refresh failed", {
115
+ forceRefetch: params.forceRefetch === true,
116
+ keyFingerprint: fingerprintInventoryCacheKey(params.key),
117
+ error: serializeCodexAppInventoryError(error)
118
+ });
119
+ throw error;
120
+ }
121
+ }
122
+ };
123
+ function serializeCodexAppInventoryError(error) {
124
+ const record = isRecord(error) ? error : void 0;
125
+ const data = record && "data" in record ? redactErrorData(record.data) : void 0;
126
+ return {
127
+ name: error instanceof Error ? error.name : typeof record?.name === "string" ? record.name : void 0,
128
+ message: sanitizeErrorMessage(error instanceof Error ? error.message : String(error)),
129
+ ...typeof record?.code === "number" ? { code: record.code } : {},
130
+ ...data !== void 0 ? { data } : {}
131
+ };
132
+ }
133
+ const defaultCodexAppInventoryCache = new CodexAppInventoryCache();
134
+ function buildCodexAppInventoryCacheKey(input) {
135
+ return JSON.stringify({
136
+ codexHome: input.codexHome ?? null,
137
+ endpoint: input.endpoint ?? null,
138
+ authProfileId: input.authProfileId ?? null,
139
+ accountId: input.accountId ?? null,
140
+ envApiKeyFingerprint: input.envApiKeyFingerprint ?? null,
141
+ appServerVersion: input.appServerVersion ?? null
142
+ });
143
+ }
144
+ async function listAllApps(request, forceRefetch) {
145
+ const apps = [];
146
+ let cursor;
147
+ do {
148
+ const response = await request("app/list", {
149
+ cursor,
150
+ limit: 100,
151
+ forceRefetch
152
+ });
153
+ apps.push(...response.data);
154
+ cursor = response.nextCursor;
155
+ } while (cursor);
156
+ return apps;
157
+ }
158
+ function stripEntryState(entry) {
159
+ const { invalidated: _invalidated, ...snapshot } = entry;
160
+ return snapshot;
161
+ }
162
+ function fingerprintInventoryCacheKey(key) {
163
+ let hash = 0;
164
+ for (let index = 0; index < key.length; index += 1) hash = hash * 31 + key.charCodeAt(index) >>> 0;
165
+ return hash.toString(16).padStart(8, "0");
166
+ }
167
+ function isRecord(value) {
168
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
169
+ }
170
+ function redactErrorData(value, depth = 0) {
171
+ if (value === void 0) return;
172
+ if (value === null || typeof value === "boolean" || typeof value === "number") return value;
173
+ if (depth > 6) return "[truncated]";
174
+ if (Array.isArray(value)) return value.map((entry) => redactErrorData(entry, depth + 1) ?? null);
175
+ if (isRecord(value)) {
176
+ const redacted = {};
177
+ for (const [key, entry] of Object.entries(value)) redacted[key] = isSensitiveErrorDataKey(key) ? "<redacted>" : redactErrorData(entry, depth + 1) ?? null;
178
+ return redacted;
179
+ }
180
+ if (typeof value === "string" && value.length > 500) return `${value.slice(0, 500)}...`;
181
+ if (typeof value === "string") return value;
182
+ if (typeof value === "bigint") return value.toString();
183
+ if (typeof value === "symbol") return value.description ? `Symbol(${value.description})` : "Symbol()";
184
+ if (typeof value === "function") return value.name ? `[function ${value.name}]` : "[function]";
185
+ return "[unserializable]";
186
+ }
187
+ function sanitizeErrorMessage(message) {
188
+ const htmlStart = message.search(/<html[\s>]/i);
189
+ const redacted = (htmlStart >= 0 ? `${message.slice(0, htmlStart).trimEnd()} [HTML response body omitted]` : message).replace(/([?&][^=\s"'<>]*(?:api[_-]?key|authorization|cookie|credential|password|secret|token|tk)[^=\s"'<>]*=)[^&\s"'<>]+/gi, "$1<redacted>");
190
+ return redacted.length > MAX_SERIALIZED_ERROR_MESSAGE_LENGTH ? `${redacted.slice(0, MAX_SERIALIZED_ERROR_MESSAGE_LENGTH)}...` : redacted;
191
+ }
192
+ function isSensitiveErrorDataKey(key) {
193
+ return /api[_-]?key|authorization|cookie|credential|password|secret|token/i.test(key);
194
+ }
195
+ //#endregion
196
+ //#region extensions/codex/src/app-server/plugin-inventory.ts
197
+ async function readCodexPluginInventory(params) {
198
+ const policy = params.policy ?? resolveCodexPluginsPolicy(params.pluginConfig);
199
+ if (!policy.enabled) return {
200
+ policy,
201
+ records: [],
202
+ diagnostics: [{
203
+ code: "disabled",
204
+ message: "Native Codex plugin support is disabled."
205
+ }]
206
+ };
207
+ const appInventory = readCachedAppInventory(params);
208
+ const marketplaceEntry = (await params.request("plugin/list", { cwds: [] })).marketplaces.find((marketplace) => marketplace.name === CODEX_PLUGINS_MARKETPLACE_NAME);
209
+ if (!marketplaceEntry) return {
210
+ policy,
211
+ records: [],
212
+ diagnostics: policy.pluginPolicies.filter((pluginPolicy) => pluginPolicy.enabled).map((pluginPolicy) => ({
213
+ code: "marketplace_missing",
214
+ plugin: pluginPolicy,
215
+ message: `Codex marketplace ${CODEX_PLUGINS_MARKETPLACE_NAME} was not found.`
216
+ })),
217
+ ...appInventory ? { appInventory } : {}
218
+ };
219
+ const marketplace = marketplaceRef(marketplaceEntry);
220
+ const diagnostics = [];
221
+ const records = [];
222
+ if (appInventory?.state === "missing") diagnostics.push({
223
+ code: "app_inventory_missing",
224
+ message: "Cached Codex app inventory is missing; plugin apps are excluded for this setup."
225
+ });
226
+ else if (appInventory?.state === "stale") diagnostics.push({
227
+ code: "app_inventory_stale",
228
+ message: "Cached Codex app inventory is stale; using stale app readiness and refreshing."
229
+ });
230
+ for (const pluginPolicy of policy.pluginPolicies) {
231
+ if (!pluginPolicy.enabled) continue;
232
+ const summary = findPluginSummary(marketplaceEntry, pluginPolicy.pluginName);
233
+ if (!summary) {
234
+ diagnostics.push({
235
+ code: "plugin_missing",
236
+ plugin: pluginPolicy,
237
+ message: `${pluginPolicy.pluginName} was not found in ${CODEX_PLUGINS_MARKETPLACE_NAME}.`
238
+ });
239
+ continue;
240
+ }
241
+ const detail = await readPluginDetail(params, marketplace, pluginPolicy, diagnostics);
242
+ const ownedAppIds = detail?.apps.map((app) => app.id).filter(Boolean).toSorted() ?? [];
243
+ const appOwnership = resolveAppOwnership({
244
+ detail,
245
+ appInventory,
246
+ summary
247
+ });
248
+ if (appOwnership === "ambiguous") diagnostics.push({
249
+ code: "app_ownership_ambiguous",
250
+ plugin: pluginPolicy,
251
+ message: `${pluginPolicy.pluginName} has only display-name app matches; apps are not exposed until ownership is stable.`
252
+ });
253
+ if (summary.installed && !summary.enabled) diagnostics.push({
254
+ code: "plugin_disabled",
255
+ plugin: pluginPolicy,
256
+ message: `${pluginPolicy.pluginName} is installed in Codex but disabled.`
257
+ });
258
+ const apps = resolveOwnedApps({
259
+ pluginPolicy,
260
+ detail,
261
+ appInventory
262
+ });
263
+ records.push({
264
+ policy: pluginPolicy,
265
+ summary,
266
+ ...detail ? { detail } : {},
267
+ activationRequired: !summary.installed || !summary.enabled,
268
+ authRequired: apps.some((app) => app.needsAuth || !app.accessible),
269
+ appOwnership,
270
+ ownedAppIds,
271
+ apps
272
+ });
273
+ }
274
+ return {
275
+ policy,
276
+ marketplace,
277
+ records,
278
+ diagnostics,
279
+ ...appInventory ? { appInventory } : {}
280
+ };
281
+ }
282
+ function findOpenAiCuratedPluginSummary(listed, pluginName) {
283
+ const marketplaceEntry = listed.marketplaces.find((marketplace) => marketplace.name === CODEX_PLUGINS_MARKETPLACE_NAME);
284
+ if (!marketplaceEntry) return;
285
+ const summary = findPluginSummary(marketplaceEntry, pluginName);
286
+ return summary ? {
287
+ marketplace: marketplaceRef(marketplaceEntry),
288
+ summary
289
+ } : void 0;
290
+ }
291
+ function pluginReadParams(marketplace, pluginName) {
292
+ return {
293
+ ...marketplace.path ? { marketplacePath: marketplace.path } : {},
294
+ ...marketplace.remoteMarketplaceName ? { remoteMarketplaceName: marketplace.remoteMarketplaceName } : {},
295
+ pluginName
296
+ };
297
+ }
298
+ function readCachedAppInventory(params) {
299
+ if (!params.appCache || !params.appCacheKey) return;
300
+ const request = async (method, requestParams) => await params.request(method, requestParams);
301
+ return params.appCache.read({
302
+ key: params.appCacheKey,
303
+ request,
304
+ nowMs: params.nowMs,
305
+ suppressRefresh: params.suppressAppInventoryRefresh
306
+ });
307
+ }
308
+ async function readPluginDetail(params, marketplace, pluginPolicy, diagnostics) {
309
+ if (params.readPluginDetails === false) return;
310
+ try {
311
+ return (await params.request("plugin/read", pluginReadParams(marketplace, pluginPolicy.pluginName))).plugin;
312
+ } catch (error) {
313
+ diagnostics.push({
314
+ code: "plugin_detail_unavailable",
315
+ plugin: pluginPolicy,
316
+ message: `${pluginPolicy.pluginName} detail unavailable: ${error instanceof Error ? error.message : String(error)}`
317
+ });
318
+ return;
319
+ }
320
+ }
321
+ function resolveAppOwnership(params) {
322
+ if (params.detail && params.detail.apps.length > 0) return "proven";
323
+ return (params.appInventory?.snapshot?.apps ?? []).filter((app) => app.pluginDisplayNames.some((displayName) => displayName === params.summary.name)).length > 0 ? "ambiguous" : "none";
324
+ }
325
+ function resolveOwnedApps(params) {
326
+ const detailApps = params.detail?.apps ?? [];
327
+ if (detailApps.length === 0) return [];
328
+ if (params.appInventory?.state === "missing") {
329
+ embeddedAgentLog.warn("codex plugin inventory missing app inventory for detail apps", {
330
+ configKey: params.pluginPolicy.configKey,
331
+ pluginName: params.pluginPolicy.pluginName,
332
+ appIds: detailApps.map((app) => app.id).toSorted()
333
+ });
334
+ return [];
335
+ }
336
+ const appInfoById = new Map((params.appInventory?.snapshot?.apps ?? []).map((app) => [app.id, app]));
337
+ return detailApps.map((app) => {
338
+ const info = appInfoById.get(app.id);
339
+ if (!info) return {
340
+ id: app.id,
341
+ name: app.name,
342
+ accessible: false,
343
+ enabled: false,
344
+ needsAuth: true
345
+ };
346
+ return {
347
+ id: app.id,
348
+ name: app.name,
349
+ accessible: info.isAccessible,
350
+ enabled: info.isEnabled,
351
+ needsAuth: app.needsAuth || !info.isAccessible
352
+ };
353
+ }).toSorted((left, right) => left.id.localeCompare(right.id));
354
+ }
355
+ function findPluginSummary(marketplace, pluginName) {
356
+ return marketplace.plugins.find((plugin) => plugin.name === pluginName || plugin.id === pluginName || plugin.id === `${pluginName}@${marketplace.name}` || pluginNameFromPluginId(plugin.id, marketplace.name) === pluginName);
357
+ }
358
+ function pluginNameFromPluginId(pluginId, marketplaceName) {
359
+ const trimmed = pluginId.trim();
360
+ if (!trimmed) return;
361
+ const marketplaceSuffix = `@${marketplaceName}`;
362
+ return (trimmed.endsWith(marketplaceSuffix) ? trimmed.slice(0, -marketplaceSuffix.length) : trimmed).split("/").at(-1)?.trim() || void 0;
363
+ }
364
+ function marketplaceRef(marketplace) {
365
+ return {
366
+ name: CODEX_PLUGINS_MARKETPLACE_NAME,
367
+ ...marketplace.path ? { path: marketplace.path } : {},
368
+ ...!marketplace.path ? { remoteMarketplaceName: marketplace.name } : {}
369
+ };
370
+ }
371
+ //#endregion
372
+ //#region extensions/codex/src/app-server/plugin-activation.ts
373
+ async function ensureCodexPluginActivation(params) {
374
+ if (params.identity.marketplaceName !== "openai-curated") return activationFailure(params.identity, "marketplace_missing", { message: "Only " + CODEX_PLUGINS_MARKETPLACE_NAME + " plugins can be activated." });
375
+ const listed = await params.request("plugin/list", { cwds: [] });
376
+ const resolved = findOpenAiCuratedPluginSummary(listed, params.identity.pluginName);
377
+ if (!resolved) {
378
+ if (!listed.marketplaces.some((marketplace) => marketplace.name === "openai-curated")) return activationFailure(params.identity, "marketplace_missing", { message: `Codex marketplace ${CODEX_PLUGINS_MARKETPLACE_NAME} was not found.` });
379
+ return activationFailure(params.identity, "plugin_missing", { message: `${params.identity.pluginName} was not found in ${CODEX_PLUGINS_MARKETPLACE_NAME}.` });
380
+ }
381
+ if (resolved.summary.installed && resolved.summary.enabled && !params.installEvenIfActive) return {
382
+ identity: params.identity,
383
+ ok: true,
384
+ reason: "already_active",
385
+ installAttempted: false,
386
+ marketplace: resolved.marketplace,
387
+ diagnostics: []
388
+ };
389
+ const installResponse = await params.request("plugin/install", pluginReadParams(resolved.marketplace, params.identity.pluginName));
390
+ const refreshDiagnostics = [];
391
+ let refreshFailed = false;
392
+ try {
393
+ const refreshResult = await refreshCodexPluginRuntimeState({
394
+ request: params.request,
395
+ appCache: params.appCache,
396
+ appCacheKey: params.appCacheKey
397
+ });
398
+ refreshDiagnostics.push(...refreshResult.diagnostics);
399
+ } catch (error) {
400
+ refreshFailed = true;
401
+ refreshDiagnostics.push({ message: `Codex plugin runtime refresh failed after install: ${error instanceof Error ? error.message : String(error)}` });
402
+ }
403
+ const authRequired = installResponse.appsNeedingAuth.length > 0;
404
+ return {
405
+ identity: params.identity,
406
+ ok: !authRequired && !refreshFailed,
407
+ reason: refreshFailed ? "refresh_failed" : authRequired ? "auth_required" : resolved.summary.installed && resolved.summary.enabled ? "already_active" : "installed",
408
+ installAttempted: true,
409
+ marketplace: resolved.marketplace,
410
+ installResponse,
411
+ diagnostics: [...refreshDiagnostics, ...installResponse.appsNeedingAuth.map((app) => ({ message: `${app.name} requires app authentication before plugin tools are exposed.` }))]
412
+ };
413
+ }
414
+ async function refreshCodexPluginRuntimeState(params) {
415
+ const diagnostics = [];
416
+ await params.request("plugin/list", { cwds: [] });
417
+ await params.request("skills/list", {
418
+ cwds: [],
419
+ forceReload: true
420
+ });
421
+ try {
422
+ await params.request("hooks/list", { cwds: [] });
423
+ } catch (error) {
424
+ diagnostics.push({ message: `Codex hooks refresh skipped: ${error instanceof Error ? error.message : String(error)}` });
425
+ }
426
+ await params.request("config/mcpServer/reload", void 0);
427
+ if (params.appCache && params.appCacheKey) {
428
+ params.appCache.invalidate(params.appCacheKey, "Codex plugin activation changed app inventory");
429
+ const request = async (method, requestParams) => await params.request(method, requestParams);
430
+ try {
431
+ await params.appCache.refreshNow({
432
+ key: params.appCacheKey,
433
+ request,
434
+ forceRefetch: true
435
+ });
436
+ } catch (error) {
437
+ diagnostics.push({ message: `Codex app inventory refresh skipped: ${error instanceof Error ? error.message : String(error)}` });
438
+ }
439
+ }
440
+ return { diagnostics };
441
+ }
442
+ function activationFailure(identity, reason, diagnostic) {
443
+ return {
444
+ identity,
445
+ ok: false,
446
+ reason,
447
+ installAttempted: false,
448
+ diagnostics: [diagnostic]
449
+ };
450
+ }
451
+ //#endregion
452
+ export { defaultCodexAppInventoryCache as a, buildCodexAppInventoryCacheKey as i, pluginReadParams as n, serializeCodexAppInventoryError as o, readCodexPluginInventory as r, ensureCodexPluginActivation as t };
@@ -0,0 +1,12 @@
1
+ import { GPT5_BEHAVIOR_CONTRACT, GPT5_HEARTBEAT_PROMPT_OVERLAY, renderGpt5PromptOverlay, resolveGpt5SystemPromptContribution } from "autobot/plugin-sdk/provider-model-shared";
2
+ //#region extensions/codex/prompt-overlay.ts
3
+ const CODEX_GPT5_BEHAVIOR_CONTRACT = GPT5_BEHAVIOR_CONTRACT;
4
+ const CODEX_GPT5_HEARTBEAT_PROMPT_OVERLAY = GPT5_HEARTBEAT_PROMPT_OVERLAY;
5
+ function resolveCodexSystemPromptContribution(params) {
6
+ return resolveGpt5SystemPromptContribution(params);
7
+ }
8
+ function renderCodexPromptOverlay(params) {
9
+ return renderGpt5PromptOverlay(params);
10
+ }
11
+ //#endregion
12
+ export { CODEX_GPT5_BEHAVIOR_CONTRACT, CODEX_GPT5_HEARTBEAT_PROMPT_OVERLAY, renderCodexPromptOverlay, resolveCodexSystemPromptContribution };
@@ -0,0 +1,9 @@
1
+ //#region extensions/codex/src/app-server/protocol.ts
2
+ function isJsonObject(value) {
3
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
4
+ }
5
+ function isRpcResponse(message) {
6
+ return "id" in message && !("method" in message);
7
+ }
8
+ //#endregion
9
+ export { isRpcResponse as n, isJsonObject as t };