@kodelyth/codex 2026.5.42 → 2026.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/package.json +16 -1
  2. package/doctor-contract-api.test.ts +0 -44
  3. package/doctor-contract-api.ts +0 -68
  4. package/harness.ts +0 -72
  5. package/index.test.ts +0 -230
  6. package/index.ts +0 -66
  7. package/media-understanding-provider.test.ts +0 -486
  8. package/media-understanding-provider.ts +0 -521
  9. package/prompt-overlay-runtime-contract.test.ts +0 -48
  10. package/prompt-overlay.ts +0 -21
  11. package/provider-catalog.ts +0 -83
  12. package/provider-discovery.ts +0 -45
  13. package/provider.test.ts +0 -384
  14. package/provider.ts +0 -243
  15. package/src/app-server/app-inventory-cache.test.ts +0 -176
  16. package/src/app-server/app-inventory-cache.ts +0 -324
  17. package/src/app-server/approval-bridge.test.ts +0 -1471
  18. package/src/app-server/approval-bridge.ts +0 -1211
  19. package/src/app-server/auth-bridge.test.ts +0 -1449
  20. package/src/app-server/auth-bridge.ts +0 -614
  21. package/src/app-server/auth-profile-runtime-contract.test.ts +0 -239
  22. package/src/app-server/capabilities.ts +0 -27
  23. package/src/app-server/client-factory.ts +0 -24
  24. package/src/app-server/client.test.ts +0 -563
  25. package/src/app-server/client.ts +0 -715
  26. package/src/app-server/compact.test.ts +0 -710
  27. package/src/app-server/compact.ts +0 -500
  28. package/src/app-server/computer-use.test.ts +0 -788
  29. package/src/app-server/computer-use.ts +0 -683
  30. package/src/app-server/config.test.ts +0 -879
  31. package/src/app-server/config.ts +0 -1038
  32. package/src/app-server/context-engine-projection.test.ts +0 -252
  33. package/src/app-server/context-engine-projection.ts +0 -403
  34. package/src/app-server/delivery-no-reply-runtime-contract.test.ts +0 -80
  35. package/src/app-server/dynamic-tool-diagnostics.ts +0 -73
  36. package/src/app-server/dynamic-tool-profile.ts +0 -69
  37. package/src/app-server/dynamic-tools.test.ts +0 -1302
  38. package/src/app-server/dynamic-tools.ts +0 -623
  39. package/src/app-server/elicitation-bridge.test.ts +0 -1056
  40. package/src/app-server/elicitation-bridge.ts +0 -783
  41. package/src/app-server/event-projector.test.ts +0 -2668
  42. package/src/app-server/event-projector.ts +0 -2057
  43. package/src/app-server/image-payload-sanitizer.test.ts +0 -49
  44. package/src/app-server/image-payload-sanitizer.ts +0 -167
  45. package/src/app-server/klaw-owned-tool-runtime-contract.test.ts +0 -456
  46. package/src/app-server/local-runtime-attribution.ts +0 -39
  47. package/src/app-server/managed-binary.test.ts +0 -139
  48. package/src/app-server/managed-binary.ts +0 -193
  49. package/src/app-server/models.test.ts +0 -246
  50. package/src/app-server/models.ts +0 -172
  51. package/src/app-server/native-hook-relay.test.ts +0 -271
  52. package/src/app-server/native-hook-relay.ts +0 -150
  53. package/src/app-server/native-subagent-task-mirror.test.ts +0 -573
  54. package/src/app-server/native-subagent-task-mirror.ts +0 -497
  55. package/src/app-server/outcome-fallback-runtime-contract.test.ts +0 -404
  56. package/src/app-server/plugin-activation.test.ts +0 -336
  57. package/src/app-server/plugin-activation.ts +0 -283
  58. package/src/app-server/plugin-app-cache-key.ts +0 -74
  59. package/src/app-server/plugin-approval-roundtrip.ts +0 -122
  60. package/src/app-server/plugin-inventory.test.ts +0 -355
  61. package/src/app-server/plugin-inventory.ts +0 -357
  62. package/src/app-server/plugin-thread-config.test.ts +0 -865
  63. package/src/app-server/plugin-thread-config.ts +0 -455
  64. package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +0 -33
  65. package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +0 -199
  66. package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +0 -102
  67. package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +0 -227
  68. package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +0 -2630
  69. package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +0 -2630
  70. package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +0 -1659
  71. package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +0 -1655
  72. package/src/app-server/protocol-validators.test.ts +0 -75
  73. package/src/app-server/protocol-validators.ts +0 -203
  74. package/src/app-server/protocol.ts +0 -520
  75. package/src/app-server/rate-limit-cache.ts +0 -48
  76. package/src/app-server/rate-limits.test.ts +0 -202
  77. package/src/app-server/rate-limits.ts +0 -583
  78. package/src/app-server/request.ts +0 -73
  79. package/src/app-server/run-attempt.context-engine.test.ts +0 -1004
  80. package/src/app-server/run-attempt.test.ts +0 -9477
  81. package/src/app-server/run-attempt.ts +0 -4683
  82. package/src/app-server/run-attempt.vision-tools.test.ts +0 -35
  83. package/src/app-server/schema-normalization-runtime-contract.test.ts +0 -206
  84. package/src/app-server/session-binding.test.ts +0 -303
  85. package/src/app-server/session-binding.ts +0 -398
  86. package/src/app-server/session-history.ts +0 -44
  87. package/src/app-server/shared-client.test.ts +0 -589
  88. package/src/app-server/shared-client.ts +0 -289
  89. package/src/app-server/side-question.test.ts +0 -1175
  90. package/src/app-server/side-question.ts +0 -1007
  91. package/src/app-server/test-support.ts +0 -48
  92. package/src/app-server/thread-lifecycle.test.ts +0 -447
  93. package/src/app-server/thread-lifecycle.ts +0 -939
  94. package/src/app-server/thread-lifecycle.user-mcp-servers.test.ts +0 -442
  95. package/src/app-server/timeout.ts +0 -9
  96. package/src/app-server/tool-progress-normalization.ts +0 -77
  97. package/src/app-server/trajectory.test.ts +0 -205
  98. package/src/app-server/trajectory.ts +0 -365
  99. package/src/app-server/transcript-mirror.test.ts +0 -524
  100. package/src/app-server/transcript-mirror.ts +0 -208
  101. package/src/app-server/transcript-repair-runtime-contract.test.ts +0 -44
  102. package/src/app-server/transport-stdio.test.ts +0 -171
  103. package/src/app-server/transport-stdio.ts +0 -107
  104. package/src/app-server/transport-websocket.test.ts +0 -69
  105. package/src/app-server/transport-websocket.ts +0 -90
  106. package/src/app-server/transport.ts +0 -117
  107. package/src/app-server/user-input-bridge.test.ts +0 -249
  108. package/src/app-server/user-input-bridge.ts +0 -316
  109. package/src/app-server/version.ts +0 -4
  110. package/src/app-server/vision-tools.ts +0 -12
  111. package/src/command-account.ts +0 -544
  112. package/src/command-formatters.ts +0 -425
  113. package/src/command-handlers.ts +0 -2004
  114. package/src/command-rpc.test.ts +0 -16
  115. package/src/command-rpc.ts +0 -142
  116. package/src/commands.test.ts +0 -3312
  117. package/src/commands.ts +0 -65
  118. package/src/conversation-binding-data.ts +0 -124
  119. package/src/conversation-binding.test.ts +0 -599
  120. package/src/conversation-binding.ts +0 -561
  121. package/src/conversation-control.test.ts +0 -126
  122. package/src/conversation-control.ts +0 -303
  123. package/src/conversation-turn-collector.test.ts +0 -191
  124. package/src/conversation-turn-collector.ts +0 -186
  125. package/src/conversation-turn-input.test.ts +0 -141
  126. package/src/conversation-turn-input.ts +0 -106
  127. package/src/manifest.test.ts +0 -20
  128. package/src/migration/apply.ts +0 -501
  129. package/src/migration/helpers.ts +0 -55
  130. package/src/migration/plan.ts +0 -461
  131. package/src/migration/provider.test.ts +0 -1741
  132. package/src/migration/provider.ts +0 -41
  133. package/src/migration/source.ts +0 -643
  134. package/src/migration/targets.ts +0 -25
  135. package/src/node-cli-sessions.test.ts +0 -180
  136. package/src/node-cli-sessions.ts +0 -711
  137. package/test-api.ts +0 -82
  138. package/tsconfig.json +0 -16
@@ -1,788 +0,0 @@
1
- import fs from "node:fs";
2
- import os from "node:os";
3
- import path from "node:path";
4
- import { afterEach, describe, expect, it, vi } from "vitest";
5
- import {
6
- ensureCodexComputerUse,
7
- installCodexComputerUse,
8
- readCodexComputerUseStatus,
9
- type CodexComputerUseStatus,
10
- type CodexComputerUseRequest,
11
- } from "./computer-use.js";
12
-
13
- function expectStatusFields(
14
- status: CodexComputerUseStatus,
15
- fields: Partial<CodexComputerUseStatus>,
16
- ): void {
17
- for (const key of Object.keys(fields) as Array<keyof CodexComputerUseStatus>) {
18
- expect(status[key]).toEqual(fields[key]);
19
- }
20
- }
21
-
22
- async function expectSetupErrorStatus(
23
- promise: Promise<CodexComputerUseStatus>,
24
- fields: Partial<CodexComputerUseStatus>,
25
- ): Promise<void> {
26
- let caught: unknown;
27
- try {
28
- await promise;
29
- } catch (error) {
30
- caught = error;
31
- }
32
- const error = requireRecord(caught, "setup error");
33
- const status = requireRecord(error.status, "setup error status") as CodexComputerUseStatus;
34
- expectStatusFields(status, fields);
35
- }
36
-
37
- function requireRecord(value: unknown, label: string): Record<string, unknown> {
38
- if (typeof value !== "object" || value === null) {
39
- throw new Error(`${label} was not an object`);
40
- }
41
- return value as Record<string, unknown>;
42
- }
43
-
44
- function requestCalls(
45
- request: CodexComputerUseRequest,
46
- ): ReadonlyArray<readonly [method: string, params?: unknown]> {
47
- return vi.mocked(request).mock.calls as ReadonlyArray<readonly [string, unknown?]>;
48
- }
49
-
50
- function expectRequestMethodNotCalled(request: CodexComputerUseRequest, method: string): void {
51
- expect(requestCalls(request).map(([calledMethod]) => calledMethod)).not.toContain(method);
52
- }
53
-
54
- describe("Codex Computer Use setup", () => {
55
- const cleanupPaths: string[] = [];
56
-
57
- afterEach(() => {
58
- vi.useRealTimers();
59
- for (const cleanupPath of cleanupPaths.splice(0)) {
60
- fs.rmSync(cleanupPath, { recursive: true, force: true });
61
- }
62
- });
63
-
64
- it("stays disabled until configured", async () => {
65
- const status = await readCodexComputerUseStatus({ pluginConfig: {}, request: vi.fn() });
66
- expectStatusFields(status, {
67
- enabled: false,
68
- ready: false,
69
- reason: "disabled",
70
- message: "Computer Use is disabled.",
71
- });
72
- });
73
-
74
- it("reports an installed Computer Use MCP server from a registered marketplace", async () => {
75
- const request = createComputerUseRequest({ installed: true });
76
-
77
- const status = await readCodexComputerUseStatus({
78
- pluginConfig: { computerUse: { enabled: true, marketplaceName: "desktop-tools" } },
79
- request,
80
- });
81
-
82
- expectStatusFields(status, {
83
- enabled: true,
84
- ready: true,
85
- reason: "ready",
86
- installed: true,
87
- pluginEnabled: true,
88
- mcpServerAvailable: true,
89
- marketplaceName: "desktop-tools",
90
- tools: ["list_apps"],
91
- message: "Computer Use is ready.",
92
- });
93
- expectRequestMethodNotCalled(request, "marketplace/add");
94
- expectRequestMethodNotCalled(request, "experimentalFeature/enablement/set");
95
- expectRequestMethodNotCalled(request, "plugin/install");
96
- });
97
-
98
- it("reports an installed but disabled Computer Use plugin separately", async () => {
99
- const request = createComputerUseRequest({ installed: true, enabled: false });
100
-
101
- const status = await readCodexComputerUseStatus({
102
- pluginConfig: { computerUse: { enabled: true, marketplaceName: "desktop-tools" } },
103
- request,
104
- });
105
-
106
- expectStatusFields(status, {
107
- ready: false,
108
- reason: "plugin_disabled",
109
- installed: true,
110
- pluginEnabled: false,
111
- mcpServerAvailable: false,
112
- message:
113
- "Computer Use is installed, but the computer-use plugin is disabled. Run /codex computer-use install or enable computerUse.autoInstall to re-enable it.",
114
- });
115
- expectRequestMethodNotCalled(request, "plugin/install");
116
- });
117
-
118
- it("does not register marketplace sources during status checks", async () => {
119
- const request = createComputerUseRequest({ installed: true });
120
-
121
- const status = await readCodexComputerUseStatus({
122
- pluginConfig: {
123
- computerUse: {
124
- enabled: true,
125
- marketplaceSource: "github:example/desktop-tools",
126
- },
127
- },
128
- request,
129
- });
130
-
131
- expectStatusFields(status, {
132
- ready: true,
133
- reason: "ready",
134
- message: "Computer Use is ready.",
135
- });
136
- expectRequestMethodNotCalled(request, "marketplace/add");
137
- expectRequestMethodNotCalled(request, "experimentalFeature/enablement/set");
138
- });
139
-
140
- it("fails closed when multiple marketplaces contain Computer Use", async () => {
141
- const request = createAmbiguousComputerUseRequest();
142
-
143
- const status = await readCodexComputerUseStatus({
144
- pluginConfig: { computerUse: { enabled: true } },
145
- request,
146
- });
147
-
148
- expectStatusFields(status, {
149
- ready: false,
150
- reason: "marketplace_missing",
151
- message:
152
- "Multiple Codex marketplaces contain computer-use. Configure computerUse.marketplaceName or computerUse.marketplacePath to choose one.",
153
- });
154
- expectRequestMethodNotCalled(request, "plugin/read");
155
- });
156
-
157
- it("installs Computer Use from a configured marketplace source", async () => {
158
- const request = createComputerUseRequest({ installed: false });
159
-
160
- const status = await installCodexComputerUse({
161
- pluginConfig: {
162
- computerUse: {
163
- marketplaceSource: "github:example/desktop-tools",
164
- },
165
- },
166
- request,
167
- });
168
-
169
- expectStatusFields(status, {
170
- ready: true,
171
- reason: "ready",
172
- installed: true,
173
- pluginEnabled: true,
174
- tools: ["list_apps"],
175
- });
176
- expect(request).toHaveBeenCalledWith("experimentalFeature/enablement/set", {
177
- enablement: { plugins: true },
178
- });
179
- expect(request).toHaveBeenCalledWith("marketplace/add", {
180
- source: "github:example/desktop-tools",
181
- });
182
- expect(request).toHaveBeenCalledWith("plugin/install", {
183
- marketplacePath: "/marketplaces/desktop-tools/.agents/plugins/marketplace.json",
184
- pluginName: "computer-use",
185
- });
186
- expect(request).toHaveBeenCalledWith("config/mcpServer/reload", undefined);
187
- });
188
-
189
- it("re-enables an installed but disabled Computer Use plugin during install", async () => {
190
- const request = createComputerUseRequest({ installed: true, enabled: false });
191
-
192
- const status = await installCodexComputerUse({
193
- pluginConfig: { computerUse: { marketplaceName: "desktop-tools" } },
194
- request,
195
- });
196
-
197
- expectStatusFields(status, {
198
- ready: true,
199
- reason: "ready",
200
- installed: true,
201
- pluginEnabled: true,
202
- message: "Computer Use is ready.",
203
- });
204
- expect(request).toHaveBeenCalledWith("plugin/install", {
205
- marketplacePath: "/marketplaces/desktop-tools/.agents/plugins/marketplace.json",
206
- pluginName: "computer-use",
207
- });
208
- });
209
-
210
- it("fails closed when Computer Use is required but not installed", async () => {
211
- const request = createComputerUseRequest({ installed: false });
212
-
213
- await expectSetupErrorStatus(
214
- ensureCodexComputerUse({
215
- pluginConfig: { computerUse: { enabled: true, marketplaceName: "desktop-tools" } },
216
- request,
217
- }),
218
- {
219
- reason: "plugin_not_installed",
220
- },
221
- );
222
- expectRequestMethodNotCalled(request, "plugin/install");
223
- });
224
-
225
- it("skips setup writes when auto-install is already ready", async () => {
226
- const request = createComputerUseRequest({ installed: true });
227
-
228
- const status = await ensureCodexComputerUse({
229
- pluginConfig: {
230
- computerUse: {
231
- enabled: true,
232
- autoInstall: true,
233
- marketplaceName: "desktop-tools",
234
- },
235
- },
236
- request,
237
- });
238
-
239
- expectStatusFields(status, {
240
- ready: true,
241
- reason: "ready",
242
- message: "Computer Use is ready.",
243
- });
244
- expectRequestMethodNotCalled(request, "marketplace/add");
245
- expectRequestMethodNotCalled(request, "experimentalFeature/enablement/set");
246
- expectRequestMethodNotCalled(request, "plugin/install");
247
- });
248
-
249
- it("uses setup writes when auto-install needs to install", async () => {
250
- const request = createComputerUseRequest({ installed: false });
251
-
252
- const status = await ensureCodexComputerUse({
253
- pluginConfig: {
254
- computerUse: {
255
- enabled: true,
256
- autoInstall: true,
257
- },
258
- },
259
- request,
260
- });
261
-
262
- expectStatusFields(status, {
263
- ready: true,
264
- reason: "ready",
265
- message: "Computer Use is ready.",
266
- });
267
- expect(request).toHaveBeenCalledWith("experimentalFeature/enablement/set", {
268
- enablement: { plugins: true },
269
- });
270
- expectRequestMethodNotCalled(request, "marketplace/add");
271
- expect(request).toHaveBeenCalledWith("plugin/install", {
272
- marketplacePath: "/marketplaces/desktop-tools/.agents/plugins/marketplace.json",
273
- pluginName: "computer-use",
274
- });
275
- });
276
-
277
- it("auto-registers the bundled Codex app marketplace during auto-install", async () => {
278
- const bundledMarketplacePath = fs.mkdtempSync(
279
- path.join(os.tmpdir(), "klaw-codex-bundled-marketplace-"),
280
- );
281
- cleanupPaths.push(bundledMarketplacePath);
282
- const request = createBundledMarketplaceComputerUseRequest(bundledMarketplacePath);
283
-
284
- const status = await ensureCodexComputerUse({
285
- pluginConfig: {
286
- computerUse: {
287
- enabled: true,
288
- autoInstall: true,
289
- },
290
- },
291
- request,
292
- defaultBundledMarketplacePath: bundledMarketplacePath,
293
- });
294
-
295
- expectStatusFields(status, {
296
- ready: true,
297
- reason: "ready",
298
- marketplaceName: "openai-bundled",
299
- message: "Computer Use is ready.",
300
- });
301
- expect(request).toHaveBeenCalledWith("marketplace/add", {
302
- source: bundledMarketplacePath,
303
- });
304
- expect(request).toHaveBeenCalledWith("plugin/install", {
305
- marketplacePath: `${bundledMarketplacePath}/.agents/plugins/marketplace.json`,
306
- pluginName: "computer-use",
307
- });
308
- });
309
-
310
- it("allows auto-install from a configured local marketplace path", async () => {
311
- const request = createComputerUseRequest({ installed: false });
312
-
313
- const status = await ensureCodexComputerUse({
314
- pluginConfig: {
315
- computerUse: {
316
- enabled: true,
317
- autoInstall: true,
318
- marketplacePath: "/marketplaces/desktop-tools/.agents/plugins/marketplace.json",
319
- },
320
- },
321
- request,
322
- });
323
-
324
- expectStatusFields(status, {
325
- ready: true,
326
- reason: "ready",
327
- message: "Computer Use is ready.",
328
- });
329
- expectRequestMethodNotCalled(request, "marketplace/add");
330
- expect(request).toHaveBeenCalledWith("plugin/install", {
331
- marketplacePath: "/marketplaces/desktop-tools/.agents/plugins/marketplace.json",
332
- pluginName: "computer-use",
333
- });
334
- });
335
-
336
- it("requires an explicit install command for configured marketplace sources", async () => {
337
- const request = createComputerUseRequest({ installed: false });
338
-
339
- await expectSetupErrorStatus(
340
- ensureCodexComputerUse({
341
- pluginConfig: {
342
- computerUse: {
343
- enabled: true,
344
- autoInstall: true,
345
- marketplaceSource: "github:example/desktop-tools",
346
- },
347
- },
348
- request,
349
- }),
350
- {
351
- reason: "auto_install_blocked",
352
- },
353
- );
354
- expectRequestMethodNotCalled(request, "marketplace/add");
355
- expectRequestMethodNotCalled(request, "plugin/install");
356
- });
357
-
358
- it("fails closed when a configured marketplace name is not discovered", async () => {
359
- const request = createEmptyMarketplaceComputerUseRequest();
360
-
361
- const status = await readCodexComputerUseStatus({
362
- pluginConfig: {
363
- computerUse: {
364
- enabled: true,
365
- marketplaceName: "missing-marketplace",
366
- },
367
- },
368
- request,
369
- });
370
-
371
- expectStatusFields(status, {
372
- ready: false,
373
- reason: "marketplace_missing",
374
- message:
375
- "Configured Codex marketplace missing-marketplace was not found or does not contain computer-use. Run /codex computer-use install with a source or path to install from a new marketplace.",
376
- });
377
- expectRequestMethodNotCalled(request, "plugin/read");
378
- });
379
-
380
- it("fails closed instead of installing from a remote-only Codex marketplace", async () => {
381
- const request = createRemoteOnlyComputerUseRequest();
382
-
383
- await expectSetupErrorStatus(
384
- installCodexComputerUse({
385
- pluginConfig: { computerUse: { marketplaceName: "openai-curated" } },
386
- request,
387
- }),
388
- {
389
- ready: false,
390
- reason: "remote_install_unsupported",
391
- installed: false,
392
- pluginEnabled: false,
393
- marketplaceName: "openai-curated",
394
- message:
395
- "Computer Use is available in remote Codex marketplace openai-curated, but Codex app-server does not support remote plugin install yet. Configure computerUse.marketplaceSource or computerUse.marketplacePath for a local marketplace, then run /codex computer-use install.",
396
- },
397
- );
398
- expectRequestMethodNotCalled(request, "plugin/install");
399
- });
400
-
401
- it("waits for the default Codex marketplace during install", async () => {
402
- vi.useFakeTimers();
403
- const request = createComputerUseRequest({
404
- installed: false,
405
- marketplaceAvailableAfterListCalls: 3,
406
- });
407
- const installed = installCodexComputerUse({
408
- pluginConfig: { computerUse: {} },
409
- request,
410
- });
411
-
412
- await vi.advanceTimersByTimeAsync(4_000);
413
-
414
- const status = await installed;
415
- expectStatusFields(status, {
416
- ready: true,
417
- reason: "ready",
418
- message: "Computer Use is ready.",
419
- });
420
- expect(request).toHaveBeenCalledWith("plugin/install", {
421
- marketplacePath: "/marketplaces/desktop-tools/.agents/plugins/marketplace.json",
422
- pluginName: "computer-use",
423
- });
424
- expect(
425
- vi.mocked(request).mock.calls.filter(([method]) => method === "plugin/list"),
426
- ).toHaveLength(3);
427
- });
428
-
429
- it("prefers the official Computer Use marketplace when multiple matches are present", async () => {
430
- const request = createMultiMarketplaceComputerUseRequest();
431
-
432
- const status = await installCodexComputerUse({
433
- pluginConfig: { computerUse: {} },
434
- request,
435
- });
436
-
437
- expectStatusFields(status, {
438
- ready: true,
439
- reason: "ready",
440
- marketplaceName: "openai-curated",
441
- });
442
- expect(request).toHaveBeenCalledWith("plugin/install", {
443
- marketplacePath: "/marketplaces/openai-curated/.agents/plugins/marketplace.json",
444
- pluginName: "computer-use",
445
- });
446
- });
447
- });
448
-
449
- function createComputerUseRequest(params: {
450
- installed: boolean;
451
- enabled?: boolean;
452
- marketplaceAvailableAfterListCalls?: number;
453
- }): CodexComputerUseRequest {
454
- let installed = params.installed;
455
- let enabled = params.enabled ?? installed;
456
- let pluginListCalls = 0;
457
- return vi.fn(async (method: string, requestParams?: unknown) => {
458
- if (method === "experimentalFeature/enablement/set") {
459
- return { enablement: { plugins: true } };
460
- }
461
- if (method === "marketplace/add") {
462
- return {
463
- marketplaceName: "desktop-tools",
464
- installedRoot: "/marketplaces/desktop-tools",
465
- alreadyAdded: false,
466
- };
467
- }
468
- if (method === "plugin/list") {
469
- pluginListCalls += 1;
470
- const marketplaceAvailable =
471
- pluginListCalls >= (params.marketplaceAvailableAfterListCalls ?? 1);
472
- return {
473
- marketplaces: marketplaceAvailable
474
- ? [
475
- {
476
- name: "desktop-tools",
477
- path: "/marketplaces/desktop-tools/.agents/plugins/marketplace.json",
478
- interface: null,
479
- plugins: [pluginSummary(installed, "desktop-tools", enabled)],
480
- },
481
- ]
482
- : [],
483
- marketplaceLoadErrors: [],
484
- featuredPluginIds: [],
485
- };
486
- }
487
- if (method === "plugin/read") {
488
- expect(requireRecord(requestParams, "plugin read params").pluginName).toBe("computer-use");
489
- return {
490
- plugin: {
491
- marketplaceName: "desktop-tools",
492
- marketplacePath: "/marketplaces/desktop-tools/.agents/plugins/marketplace.json",
493
- summary: pluginSummary(installed, "desktop-tools", enabled),
494
- description: "Control desktop apps.",
495
- skills: [],
496
- apps: [],
497
- mcpServers: ["computer-use"],
498
- },
499
- };
500
- }
501
- if (method === "plugin/install") {
502
- installed = true;
503
- enabled = true;
504
- return { authPolicy: "ON_INSTALL", appsNeedingAuth: [] };
505
- }
506
- if (method === "config/mcpServer/reload") {
507
- return undefined;
508
- }
509
- if (method === "mcpServerStatus/list") {
510
- return {
511
- data:
512
- installed && enabled
513
- ? [
514
- {
515
- name: "computer-use",
516
- tools: {
517
- list_apps: {
518
- name: "list_apps",
519
- inputSchema: { type: "object" },
520
- },
521
- },
522
- resources: [],
523
- resourceTemplates: [],
524
- authStatus: "unsupported",
525
- },
526
- ]
527
- : [],
528
- nextCursor: null,
529
- };
530
- }
531
- throw new Error(`unexpected request ${method}`);
532
- }) as CodexComputerUseRequest;
533
- }
534
-
535
- function createRemoteOnlyComputerUseRequest(): CodexComputerUseRequest {
536
- return vi.fn(async (method: string, requestParams?: unknown) => {
537
- if (method === "experimentalFeature/enablement/set") {
538
- return { enablement: { plugins: true } };
539
- }
540
- if (method === "plugin/list") {
541
- return {
542
- marketplaces: [
543
- {
544
- name: "openai-curated",
545
- path: null,
546
- interface: null,
547
- plugins: [pluginSummary(false, "openai-curated", false, "remote")],
548
- },
549
- ],
550
- marketplaceLoadErrors: [],
551
- featuredPluginIds: [],
552
- };
553
- }
554
- if (method === "plugin/read") {
555
- expect(requestParams).toEqual({
556
- remoteMarketplaceName: "openai-curated",
557
- pluginName: "computer-use",
558
- });
559
- return {
560
- plugin: {
561
- marketplaceName: "openai-curated",
562
- marketplacePath: null,
563
- summary: pluginSummary(false, "openai-curated", false, "remote"),
564
- description: "Control desktop apps.",
565
- skills: [],
566
- apps: [],
567
- mcpServers: ["computer-use"],
568
- },
569
- };
570
- }
571
- throw new Error(`unexpected request ${method}`);
572
- }) as CodexComputerUseRequest;
573
- }
574
-
575
- function createAmbiguousComputerUseRequest(): CodexComputerUseRequest {
576
- return vi.fn(async (method: string) => {
577
- if (method === "plugin/list") {
578
- return {
579
- marketplaces: [
580
- {
581
- name: "desktop-tools",
582
- path: "/marketplaces/desktop-tools/.agents/plugins/marketplace.json",
583
- interface: null,
584
- plugins: [pluginSummary(true, "desktop-tools")],
585
- },
586
- {
587
- name: "other-tools",
588
- path: "/marketplaces/other-tools/.agents/plugins/marketplace.json",
589
- interface: null,
590
- plugins: [pluginSummary(true, "other-tools")],
591
- },
592
- ],
593
- marketplaceLoadErrors: [],
594
- featuredPluginIds: [],
595
- };
596
- }
597
- throw new Error(`unexpected request ${method}`);
598
- }) as CodexComputerUseRequest;
599
- }
600
-
601
- function createEmptyMarketplaceComputerUseRequest(): CodexComputerUseRequest {
602
- return vi.fn(async (method: string) => {
603
- if (method === "plugin/list") {
604
- return {
605
- marketplaces: [],
606
- marketplaceLoadErrors: [],
607
- featuredPluginIds: [],
608
- };
609
- }
610
- throw new Error(`unexpected request ${method}`);
611
- }) as CodexComputerUseRequest;
612
- }
613
-
614
- function createMultiMarketplaceComputerUseRequest(): CodexComputerUseRequest {
615
- let installed = false;
616
- return vi.fn(async (method: string, requestParams?: unknown) => {
617
- if (method === "experimentalFeature/enablement/set") {
618
- return { enablement: { plugins: true } };
619
- }
620
- if (method === "plugin/list") {
621
- return {
622
- marketplaces: [
623
- marketplaceEntry("workspace-tools", false),
624
- marketplaceEntry("openai-curated", installed),
625
- ],
626
- marketplaceLoadErrors: [],
627
- featuredPluginIds: [],
628
- };
629
- }
630
- if (method === "plugin/read") {
631
- return {
632
- plugin: {
633
- marketplaceName: "openai-curated",
634
- marketplacePath: "/marketplaces/openai-curated/.agents/plugins/marketplace.json",
635
- summary: pluginSummary(installed, "openai-curated"),
636
- description: "Control desktop apps.",
637
- skills: [],
638
- apps: [],
639
- mcpServers: ["computer-use"],
640
- },
641
- };
642
- }
643
- if (method === "plugin/install") {
644
- expect(requestParams).toEqual({
645
- marketplacePath: "/marketplaces/openai-curated/.agents/plugins/marketplace.json",
646
- pluginName: "computer-use",
647
- });
648
- installed = true;
649
- return { authPolicy: "ON_INSTALL", appsNeedingAuth: [] };
650
- }
651
- if (method === "config/mcpServer/reload") {
652
- return undefined;
653
- }
654
- if (method === "mcpServerStatus/list") {
655
- return {
656
- data: installed
657
- ? [
658
- {
659
- name: "computer-use",
660
- tools: {
661
- list_apps: {
662
- name: "list_apps",
663
- inputSchema: { type: "object" },
664
- },
665
- },
666
- resources: [],
667
- resourceTemplates: [],
668
- authStatus: "unsupported",
669
- },
670
- ]
671
- : [],
672
- nextCursor: null,
673
- };
674
- }
675
- throw new Error(`unexpected request ${method}`);
676
- }) as CodexComputerUseRequest;
677
- }
678
-
679
- function createBundledMarketplaceComputerUseRequest(
680
- bundledMarketplacePath: string,
681
- ): CodexComputerUseRequest {
682
- let registered = false;
683
- let installed = false;
684
- return vi.fn(async (method: string, requestParams?: unknown) => {
685
- if (method === "experimentalFeature/enablement/set") {
686
- return { enablement: { plugins: true } };
687
- }
688
- if (method === "marketplace/add") {
689
- expect(requestParams).toEqual({
690
- source: bundledMarketplacePath,
691
- });
692
- registered = true;
693
- return {
694
- marketplaceName: "openai-bundled",
695
- installedRoot: bundledMarketplacePath,
696
- alreadyAdded: false,
697
- };
698
- }
699
- if (method === "plugin/list") {
700
- return {
701
- marketplaces: registered
702
- ? [
703
- {
704
- name: "openai-bundled",
705
- path: `${bundledMarketplacePath}/.agents/plugins/marketplace.json`,
706
- interface: null,
707
- plugins: [pluginSummary(installed, "openai-bundled")],
708
- },
709
- ]
710
- : [],
711
- marketplaceLoadErrors: [],
712
- featuredPluginIds: [],
713
- };
714
- }
715
- if (method === "plugin/read") {
716
- return {
717
- plugin: {
718
- marketplaceName: "openai-bundled",
719
- marketplacePath: `${bundledMarketplacePath}/.agents/plugins/marketplace.json`,
720
- summary: pluginSummary(installed, "openai-bundled"),
721
- description: "Control desktop apps.",
722
- skills: [],
723
- apps: [],
724
- mcpServers: ["computer-use"],
725
- },
726
- };
727
- }
728
- if (method === "plugin/install") {
729
- installed = true;
730
- return { authPolicy: "ON_INSTALL", appsNeedingAuth: [] };
731
- }
732
- if (method === "config/mcpServer/reload") {
733
- return undefined;
734
- }
735
- if (method === "mcpServerStatus/list") {
736
- return {
737
- data: installed
738
- ? [
739
- {
740
- name: "computer-use",
741
- tools: {
742
- list_apps: {
743
- name: "list_apps",
744
- inputSchema: { type: "object" },
745
- },
746
- },
747
- resources: [],
748
- resourceTemplates: [],
749
- authStatus: "unsupported",
750
- },
751
- ]
752
- : [],
753
- nextCursor: null,
754
- };
755
- }
756
- throw new Error(`unexpected request ${method}`);
757
- }) as CodexComputerUseRequest;
758
- }
759
-
760
- function marketplaceEntry(marketplaceName: string, installed: boolean) {
761
- return {
762
- name: marketplaceName,
763
- path: `/marketplaces/${marketplaceName}/.agents/plugins/marketplace.json`,
764
- interface: null,
765
- plugins: [pluginSummary(installed, marketplaceName)],
766
- };
767
- }
768
-
769
- function pluginSummary(
770
- installed: boolean,
771
- marketplaceName = "desktop-tools",
772
- enabled = installed,
773
- source: "local" | "remote" = "local",
774
- ) {
775
- return {
776
- id: `computer-use@${marketplaceName}`,
777
- name: "computer-use",
778
- source:
779
- source === "local"
780
- ? { type: "local", path: `/marketplaces/${marketplaceName}/plugins/computer-use` }
781
- : { type: "remote" },
782
- installed,
783
- enabled,
784
- installPolicy: "AVAILABLE",
785
- authPolicy: "ON_INSTALL",
786
- interface: null,
787
- };
788
- }