From 9f40131017448290176b4e18e1d121835f3da1bb Mon Sep 17 00:00:00 2001 From: xli-oai Date: Mon, 13 Apr 2026 13:33:17 -0700 Subject: [PATCH] app-server: add marketplace list API --- .../schema/json/ClientRequest.json | 43 +++++ .../codex_app_server_protocol.schemas.json | 123 ++++++++++++++ .../codex_app_server_protocol.v2.schemas.json | 123 ++++++++++++++ .../schema/json/v2/MarketplaceListParams.json | 21 +++ .../json/v2/MarketplaceListResponse.json | 84 ++++++++++ .../schema/typescript/ClientRequest.ts | 3 +- .../typescript/v2/MarketplaceListEntry.ts | 7 + .../typescript/v2/MarketplaceListParams.ts | 5 + .../typescript/v2/MarketplaceListResponse.ts | 6 + .../typescript/v2/MarketplaceSourceType.ts | 5 + .../schema/typescript/v2/index.ts | 4 + .../src/protocol/common.rs | 4 + .../app-server-protocol/src/protocol/v2.rs | 40 +++++ codex-rs/app-server/README.md | 1 + .../app-server/src/codex_message_processor.rs | 158 ++++++++++++++++++ .../app-server/tests/common/mcp_process.rs | 10 ++ .../tests/suite/v2/marketplace_list.rs | 145 ++++++++++++++++ codex-rs/app-server/tests/suite/v2/mod.rs | 1 + 18 files changed, 782 insertions(+), 1 deletion(-) create mode 100644 codex-rs/app-server-protocol/schema/json/v2/MarketplaceListParams.json create mode 100644 codex-rs/app-server-protocol/schema/json/v2/MarketplaceListResponse.json create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListEntry.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListParams.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListResponse.ts create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceSourceType.ts create mode 100644 codex-rs/app-server/tests/suite/v2/marketplace_list.rs diff --git a/codex-rs/app-server-protocol/schema/json/ClientRequest.json b/codex-rs/app-server-protocol/schema/json/ClientRequest.json index a6044bba18..c494254e82 100644 --- a/codex-rs/app-server-protocol/schema/json/ClientRequest.json +++ b/codex-rs/app-server-protocol/schema/json/ClientRequest.json @@ -1233,6 +1233,25 @@ } ] }, + "MarketplaceListParams": { + "properties": { + "cursor": { + "type": [ + "string", + "null" + ] + }, + "limit": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "type": "object" + }, "McpResourceReadParams": { "properties": { "server": { @@ -3983,6 +4002,30 @@ "title": "Skills/listRequest", "type": "object" }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "marketplace/list" + ], + "title": "Marketplace/listRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/MarketplaceListParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "Marketplace/listRequest", + "type": "object" + }, { "properties": { "id": { diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json index 1f20720701..5b97c75e54 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json @@ -602,6 +602,30 @@ "title": "Skills/listRequest", "type": "object" }, + { + "properties": { + "id": { + "$ref": "#/definitions/v2/RequestId" + }, + "method": { + "enum": [ + "marketplace/list" + ], + "title": "Marketplace/listRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/v2/MarketplaceListParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "Marketplace/listRequest", + "type": "object" + }, { "properties": { "id": { @@ -9041,6 +9065,99 @@ }, "type": "object" }, + "MarketplaceListEntry": { + "properties": { + "lastUpdated": { + "type": [ + "string", + "null" + ] + }, + "name": { + "type": "string" + }, + "path": { + "$ref": "#/definitions/v2/AbsolutePathBuf" + }, + "refName": { + "type": [ + "string", + "null" + ] + }, + "source": { + "type": [ + "string", + "null" + ] + }, + "sourceType": { + "anyOf": [ + { + "$ref": "#/definitions/v2/MarketplaceSourceType" + }, + { + "type": "null" + } + ] + }, + "sparsePaths": { + "default": [], + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "name", + "path" + ], + "type": "object" + }, + "MarketplaceListParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "cursor": { + "type": [ + "string", + "null" + ] + }, + "limit": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "title": "MarketplaceListParams", + "type": "object" + }, + "MarketplaceListResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "data": { + "items": { + "$ref": "#/definitions/v2/MarketplaceListEntry" + }, + "type": "array" + }, + "nextCursor": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "data" + ], + "title": "MarketplaceListResponse", + "type": "object" + }, "MarketplaceLoadErrorInfo": { "properties": { "marketplacePath": { @@ -9056,6 +9173,12 @@ ], "type": "object" }, + "MarketplaceSourceType": { + "enum": [ + "git" + ], + "type": "string" + }, "McpAuthStatus": { "enum": [ "unsupported", diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json index d4d76de9f0..08844a07cb 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json @@ -1184,6 +1184,30 @@ "title": "Skills/listRequest", "type": "object" }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "marketplace/list" + ], + "title": "Marketplace/listRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/MarketplaceListParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "Marketplace/listRequest", + "type": "object" + }, { "properties": { "id": { @@ -5837,6 +5861,99 @@ }, "type": "object" }, + "MarketplaceListEntry": { + "properties": { + "lastUpdated": { + "type": [ + "string", + "null" + ] + }, + "name": { + "type": "string" + }, + "path": { + "$ref": "#/definitions/AbsolutePathBuf" + }, + "refName": { + "type": [ + "string", + "null" + ] + }, + "source": { + "type": [ + "string", + "null" + ] + }, + "sourceType": { + "anyOf": [ + { + "$ref": "#/definitions/MarketplaceSourceType" + }, + { + "type": "null" + } + ] + }, + "sparsePaths": { + "default": [], + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "name", + "path" + ], + "type": "object" + }, + "MarketplaceListParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "cursor": { + "type": [ + "string", + "null" + ] + }, + "limit": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "title": "MarketplaceListParams", + "type": "object" + }, + "MarketplaceListResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "data": { + "items": { + "$ref": "#/definitions/MarketplaceListEntry" + }, + "type": "array" + }, + "nextCursor": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "data" + ], + "title": "MarketplaceListResponse", + "type": "object" + }, "MarketplaceLoadErrorInfo": { "properties": { "marketplacePath": { @@ -5852,6 +5969,12 @@ ], "type": "object" }, + "MarketplaceSourceType": { + "enum": [ + "git" + ], + "type": "string" + }, "McpAuthStatus": { "enum": [ "unsupported", diff --git a/codex-rs/app-server-protocol/schema/json/v2/MarketplaceListParams.json b/codex-rs/app-server-protocol/schema/json/v2/MarketplaceListParams.json new file mode 100644 index 0000000000..90f36dae80 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/MarketplaceListParams.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "cursor": { + "type": [ + "string", + "null" + ] + }, + "limit": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "title": "MarketplaceListParams", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/MarketplaceListResponse.json b/codex-rs/app-server-protocol/schema/json/v2/MarketplaceListResponse.json new file mode 100644 index 0000000000..d55964246b --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/MarketplaceListResponse.json @@ -0,0 +1,84 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "AbsolutePathBuf": { + "description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.", + "type": "string" + }, + "MarketplaceListEntry": { + "properties": { + "lastUpdated": { + "type": [ + "string", + "null" + ] + }, + "name": { + "type": "string" + }, + "path": { + "$ref": "#/definitions/AbsolutePathBuf" + }, + "refName": { + "type": [ + "string", + "null" + ] + }, + "source": { + "type": [ + "string", + "null" + ] + }, + "sourceType": { + "anyOf": [ + { + "$ref": "#/definitions/MarketplaceSourceType" + }, + { + "type": "null" + } + ] + }, + "sparsePaths": { + "default": [], + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "name", + "path" + ], + "type": "object" + }, + "MarketplaceSourceType": { + "enum": [ + "git" + ], + "type": "string" + } + }, + "properties": { + "data": { + "items": { + "$ref": "#/definitions/MarketplaceListEntry" + }, + "type": "array" + }, + "nextCursor": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "data" + ], + "title": "MarketplaceListResponse", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts b/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts index 1bbc9b7ac9..a99a910140 100644 --- a/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts +++ b/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts @@ -33,6 +33,7 @@ import type { FsWriteFileParams } from "./v2/FsWriteFileParams"; import type { GetAccountParams } from "./v2/GetAccountParams"; import type { ListMcpServerStatusParams } from "./v2/ListMcpServerStatusParams"; import type { LoginAccountParams } from "./v2/LoginAccountParams"; +import type { MarketplaceListParams } from "./v2/MarketplaceListParams"; import type { McpResourceReadParams } from "./v2/McpResourceReadParams"; import type { McpServerOauthLoginParams } from "./v2/McpServerOauthLoginParams"; import type { McpServerToolCallParams } from "./v2/McpServerToolCallParams"; @@ -66,4 +67,4 @@ import type { WindowsSandboxSetupStartParams } from "./v2/WindowsSandboxSetupSta /** * Request from the client to the server. */ -export type ClientRequest ={ "method": "initialize", id: RequestId, params: InitializeParams, } | { "method": "thread/start", id: RequestId, params: ThreadStartParams, } | { "method": "thread/resume", id: RequestId, params: ThreadResumeParams, } | { "method": "thread/fork", id: RequestId, params: ThreadForkParams, } | { "method": "thread/archive", id: RequestId, params: ThreadArchiveParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/metadata/update", id: RequestId, params: ThreadMetadataUpdateParams, } | { "method": "thread/unarchive", id: RequestId, params: ThreadUnarchiveParams, } | { "method": "thread/compact/start", id: RequestId, params: ThreadCompactStartParams, } | { "method": "thread/shellCommand", id: RequestId, params: ThreadShellCommandParams, } | { "method": "thread/rollback", id: RequestId, params: ThreadRollbackParams, } | { "method": "thread/list", id: RequestId, params: ThreadListParams, } | { "method": "thread/loaded/list", id: RequestId, params: ThreadLoadedListParams, } | { "method": "thread/read", id: RequestId, params: ThreadReadParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "app/list", id: RequestId, params: AppsListParams, } | { "method": "fs/readFile", id: RequestId, params: FsReadFileParams, } | { "method": "fs/writeFile", id: RequestId, params: FsWriteFileParams, } | { "method": "fs/createDirectory", id: RequestId, params: FsCreateDirectoryParams, } | { "method": "fs/getMetadata", id: RequestId, params: FsGetMetadataParams, } | { "method": "fs/readDirectory", id: RequestId, params: FsReadDirectoryParams, } | { "method": "fs/remove", id: RequestId, params: FsRemoveParams, } | { "method": "fs/copy", id: RequestId, params: FsCopyParams, } | { "method": "fs/watch", id: RequestId, params: FsWatchParams, } | { "method": "fs/unwatch", id: RequestId, params: FsUnwatchParams, } | { "method": "skills/config/write", id: RequestId, params: SkillsConfigWriteParams, } | { "method": "plugin/install", id: RequestId, params: PluginInstallParams, } | { "method": "plugin/uninstall", id: RequestId, params: PluginUninstallParams, } | { "method": "turn/start", id: RequestId, params: TurnStartParams, } | { "method": "turn/steer", id: RequestId, params: TurnSteerParams, } | { "method": "turn/interrupt", id: RequestId, params: TurnInterruptParams, } | { "method": "review/start", id: RequestId, params: ReviewStartParams, } | { "method": "model/list", id: RequestId, params: ModelListParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "experimentalFeature/enablement/set", id: RequestId, params: ExperimentalFeatureEnablementSetParams, } | { "method": "mcpServer/oauth/login", id: RequestId, params: McpServerOauthLoginParams, } | { "method": "config/mcpServer/reload", id: RequestId, params: undefined, } | { "method": "mcpServerStatus/list", id: RequestId, params: ListMcpServerStatusParams, } | { "method": "mcpServer/resource/read", id: RequestId, params: McpResourceReadParams, } | { "method": "mcpServer/tool/call", id: RequestId, params: McpServerToolCallParams, } | { "method": "windowsSandbox/setupStart", id: RequestId, params: WindowsSandboxSetupStartParams, } | { "method": "account/login/start", id: RequestId, params: LoginAccountParams, } | { "method": "account/login/cancel", id: RequestId, params: CancelLoginAccountParams, } | { "method": "account/logout", id: RequestId, params: undefined, } | { "method": "account/rateLimits/read", id: RequestId, params: undefined, } | { "method": "feedback/upload", id: RequestId, params: FeedbackUploadParams, } | { "method": "command/exec", id: RequestId, params: CommandExecParams, } | { "method": "command/exec/write", id: RequestId, params: CommandExecWriteParams, } | { "method": "command/exec/terminate", id: RequestId, params: CommandExecTerminateParams, } | { "method": "command/exec/resize", id: RequestId, params: CommandExecResizeParams, } | { "method": "config/read", id: RequestId, params: ConfigReadParams, } | { "method": "externalAgentConfig/detect", id: RequestId, params: ExternalAgentConfigDetectParams, } | { "method": "externalAgentConfig/import", id: RequestId, params: ExternalAgentConfigImportParams, } | { "method": "config/value/write", id: RequestId, params: ConfigValueWriteParams, } | { "method": "config/batchWrite", id: RequestId, params: ConfigBatchWriteParams, } | { "method": "configRequirements/read", id: RequestId, params: undefined, } | { "method": "account/read", id: RequestId, params: GetAccountParams, } | { "method": "getConversationSummary", id: RequestId, params: GetConversationSummaryParams, } | { "method": "gitDiffToRemote", id: RequestId, params: GitDiffToRemoteParams, } | { "method": "getAuthStatus", id: RequestId, params: GetAuthStatusParams, } | { "method": "fuzzyFileSearch", id: RequestId, params: FuzzyFileSearchParams, }; +export type ClientRequest ={ "method": "initialize", id: RequestId, params: InitializeParams, } | { "method": "thread/start", id: RequestId, params: ThreadStartParams, } | { "method": "thread/resume", id: RequestId, params: ThreadResumeParams, } | { "method": "thread/fork", id: RequestId, params: ThreadForkParams, } | { "method": "thread/archive", id: RequestId, params: ThreadArchiveParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/metadata/update", id: RequestId, params: ThreadMetadataUpdateParams, } | { "method": "thread/unarchive", id: RequestId, params: ThreadUnarchiveParams, } | { "method": "thread/compact/start", id: RequestId, params: ThreadCompactStartParams, } | { "method": "thread/shellCommand", id: RequestId, params: ThreadShellCommandParams, } | { "method": "thread/rollback", id: RequestId, params: ThreadRollbackParams, } | { "method": "thread/list", id: RequestId, params: ThreadListParams, } | { "method": "thread/loaded/list", id: RequestId, params: ThreadLoadedListParams, } | { "method": "thread/read", id: RequestId, params: ThreadReadParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "marketplace/list", id: RequestId, params: MarketplaceListParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "app/list", id: RequestId, params: AppsListParams, } | { "method": "fs/readFile", id: RequestId, params: FsReadFileParams, } | { "method": "fs/writeFile", id: RequestId, params: FsWriteFileParams, } | { "method": "fs/createDirectory", id: RequestId, params: FsCreateDirectoryParams, } | { "method": "fs/getMetadata", id: RequestId, params: FsGetMetadataParams, } | { "method": "fs/readDirectory", id: RequestId, params: FsReadDirectoryParams, } | { "method": "fs/remove", id: RequestId, params: FsRemoveParams, } | { "method": "fs/copy", id: RequestId, params: FsCopyParams, } | { "method": "fs/watch", id: RequestId, params: FsWatchParams, } | { "method": "fs/unwatch", id: RequestId, params: FsUnwatchParams, } | { "method": "skills/config/write", id: RequestId, params: SkillsConfigWriteParams, } | { "method": "plugin/install", id: RequestId, params: PluginInstallParams, } | { "method": "plugin/uninstall", id: RequestId, params: PluginUninstallParams, } | { "method": "turn/start", id: RequestId, params: TurnStartParams, } | { "method": "turn/steer", id: RequestId, params: TurnSteerParams, } | { "method": "turn/interrupt", id: RequestId, params: TurnInterruptParams, } | { "method": "review/start", id: RequestId, params: ReviewStartParams, } | { "method": "model/list", id: RequestId, params: ModelListParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "experimentalFeature/enablement/set", id: RequestId, params: ExperimentalFeatureEnablementSetParams, } | { "method": "mcpServer/oauth/login", id: RequestId, params: McpServerOauthLoginParams, } | { "method": "config/mcpServer/reload", id: RequestId, params: undefined, } | { "method": "mcpServerStatus/list", id: RequestId, params: ListMcpServerStatusParams, } | { "method": "mcpServer/resource/read", id: RequestId, params: McpResourceReadParams, } | { "method": "mcpServer/tool/call", id: RequestId, params: McpServerToolCallParams, } | { "method": "windowsSandbox/setupStart", id: RequestId, params: WindowsSandboxSetupStartParams, } | { "method": "account/login/start", id: RequestId, params: LoginAccountParams, } | { "method": "account/login/cancel", id: RequestId, params: CancelLoginAccountParams, } | { "method": "account/logout", id: RequestId, params: undefined, } | { "method": "account/rateLimits/read", id: RequestId, params: undefined, } | { "method": "feedback/upload", id: RequestId, params: FeedbackUploadParams, } | { "method": "command/exec", id: RequestId, params: CommandExecParams, } | { "method": "command/exec/write", id: RequestId, params: CommandExecWriteParams, } | { "method": "command/exec/terminate", id: RequestId, params: CommandExecTerminateParams, } | { "method": "command/exec/resize", id: RequestId, params: CommandExecResizeParams, } | { "method": "config/read", id: RequestId, params: ConfigReadParams, } | { "method": "externalAgentConfig/detect", id: RequestId, params: ExternalAgentConfigDetectParams, } | { "method": "externalAgentConfig/import", id: RequestId, params: ExternalAgentConfigImportParams, } | { "method": "config/value/write", id: RequestId, params: ConfigValueWriteParams, } | { "method": "config/batchWrite", id: RequestId, params: ConfigBatchWriteParams, } | { "method": "configRequirements/read", id: RequestId, params: undefined, } | { "method": "account/read", id: RequestId, params: GetAccountParams, } | { "method": "getConversationSummary", id: RequestId, params: GetConversationSummaryParams, } | { "method": "gitDiffToRemote", id: RequestId, params: GitDiffToRemoteParams, } | { "method": "getAuthStatus", id: RequestId, params: GetAuthStatusParams, } | { "method": "fuzzyFileSearch", id: RequestId, params: FuzzyFileSearchParams, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListEntry.ts b/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListEntry.ts new file mode 100644 index 0000000000..294b92641a --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListEntry.ts @@ -0,0 +1,7 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AbsolutePathBuf } from "../AbsolutePathBuf"; +import type { MarketplaceSourceType } from "./MarketplaceSourceType"; + +export type MarketplaceListEntry = { name: string, path: AbsolutePathBuf, lastUpdated: string | null, sourceType: MarketplaceSourceType | null, source: string | null, refName: string | null, sparsePaths: Array, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListParams.ts new file mode 100644 index 0000000000..4e7d0bc30e --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListParams.ts @@ -0,0 +1,5 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type MarketplaceListParams = { cursor?: string | null, limit?: number | null, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListResponse.ts b/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListResponse.ts new file mode 100644 index 0000000000..7f14f3f189 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceListResponse.ts @@ -0,0 +1,6 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { MarketplaceListEntry } from "./MarketplaceListEntry"; + +export type MarketplaceListResponse = { data: Array, nextCursor: string | null, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceSourceType.ts b/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceSourceType.ts new file mode 100644 index 0000000000..9564b90529 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/MarketplaceSourceType.ts @@ -0,0 +1,5 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type MarketplaceSourceType = "git"; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts index f815fee3e9..357ffc68df 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts @@ -150,7 +150,11 @@ export type { LoginAccountParams } from "./LoginAccountParams"; export type { LoginAccountResponse } from "./LoginAccountResponse"; export type { LogoutAccountResponse } from "./LogoutAccountResponse"; export type { MarketplaceInterface } from "./MarketplaceInterface"; +export type { MarketplaceListEntry } from "./MarketplaceListEntry"; +export type { MarketplaceListParams } from "./MarketplaceListParams"; +export type { MarketplaceListResponse } from "./MarketplaceListResponse"; export type { MarketplaceLoadErrorInfo } from "./MarketplaceLoadErrorInfo"; +export type { MarketplaceSourceType } from "./MarketplaceSourceType"; export type { McpAuthStatus } from "./McpAuthStatus"; export type { McpElicitationArrayType } from "./McpElicitationArrayType"; export type { McpElicitationBooleanSchema } from "./McpElicitationBooleanSchema"; diff --git a/codex-rs/app-server-protocol/src/protocol/common.rs b/codex-rs/app-server-protocol/src/protocol/common.rs index f26f8366f0..8f768947eb 100644 --- a/codex-rs/app-server-protocol/src/protocol/common.rs +++ b/codex-rs/app-server-protocol/src/protocol/common.rs @@ -326,6 +326,10 @@ client_request_definitions! { params: v2::SkillsListParams, response: v2::SkillsListResponse, }, + MarketplaceList => "marketplace/list" { + params: v2::MarketplaceListParams, + response: v2::MarketplaceListResponse, + }, PluginList => "plugin/list" { params: v2::PluginListParams, response: v2::PluginListResponse, diff --git a/codex-rs/app-server-protocol/src/protocol/v2.rs b/codex-rs/app-server-protocol/src/protocol/v2.rs index 8a6a6e57b3..a259651d02 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2.rs @@ -3324,6 +3324,46 @@ pub struct SkillsListResponse { pub data: Vec, } +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct MarketplaceListParams { + #[ts(optional = nullable)] + pub cursor: Option, + #[ts(optional = nullable)] + pub limit: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct MarketplaceListResponse { + pub data: Vec, + pub next_cursor: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct MarketplaceListEntry { + pub name: String, + pub path: AbsolutePathBuf, + pub last_updated: Option, + pub source_type: Option, + pub source: Option, + pub ref_name: Option, + #[serde(default)] + pub sparse_paths: Vec, +} + +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "snake_case")] +#[ts(rename_all = "snake_case")] +#[ts(export_to = "v2/")] +pub enum MarketplaceSourceType { + Git, +} + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.md index b0a16616aa..b8aa5a19f7 100644 --- a/codex-rs/app-server/README.md +++ b/codex-rs/app-server/README.md @@ -178,6 +178,7 @@ Example with notification opt-out: - `experimentalFeature/enablement/set` — patch the in-memory process-wide runtime feature enablement for the currently supported feature keys (`apps`, `plugins`). For each feature, precedence is: cloud requirements > --enable > config.toml > experimentalFeature/enablement/set (new) > code default. - `collaborationMode/list` — list available collaboration mode presets (experimental, no pagination). This response omits built-in developer instructions; clients should either pass `settings.developer_instructions: null` when setting a mode to use Codex's built-in instructions, or provide their own instructions explicitly. - `skills/list` — list skills for one or more `cwd` values (optional `forceReload`). +- `marketplace/list` — list configured marketplaces from `config.toml`, returning paginated marketplace records with the derived installed `marketplace.json` path plus stored source metadata (`lastUpdated`, `sourceType`, `source`, `refName`, `sparsePaths`). - `plugin/list` — list discovered plugin marketplaces and plugin state, including effective marketplace install/auth policy metadata, fail-open `marketplaceLoadErrors` entries for marketplace files that could not be parsed or loaded, and best-effort `featuredPluginIds` for the official curated marketplace. `interface.category` uses the marketplace category when present; otherwise it falls back to the plugin manifest category. Pass `forceRemoteSync: true` to refresh curated plugin state before listing (**under development; do not call from production clients yet**). - `plugin/read` — read one plugin by `marketplacePath` plus `pluginName`, returning marketplace info, a list-style `summary`, manifest descriptions/interface metadata, and bundled skills/apps/MCP server names. Returned plugin skills include their current `enabled` state after local config filtering. Plugin app summaries also include `needsAuth` when the server can determine connector accessibility (**under development; do not call from production clients yet**). - `skills/changed` — notification emitted when watched local skill files change. diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs index 3decc83f4a..f961ad5b85 100644 --- a/codex-rs/app-server/src/codex_message_processor.rs +++ b/codex-rs/app-server/src/codex_message_processor.rs @@ -77,6 +77,10 @@ use codex_app_server_protocol::LoginAccountResponse; use codex_app_server_protocol::LoginApiKeyParams; use codex_app_server_protocol::LogoutAccountResponse; use codex_app_server_protocol::MarketplaceInterface; +use codex_app_server_protocol::MarketplaceListEntry; +use codex_app_server_protocol::MarketplaceListParams; +use codex_app_server_protocol::MarketplaceListResponse; +use codex_app_server_protocol::MarketplaceSourceType as ApiMarketplaceSourceType; use codex_app_server_protocol::McpResourceReadParams; use codex_app_server_protocol::McpResourceReadResponse; use codex_app_server_protocol::McpServerOauthLoginCompletedNotification; @@ -193,6 +197,8 @@ use codex_arg0::Arg0DispatchPaths; use codex_backend_client::Client as BackendClient; use codex_chatgpt::connectors; use codex_cloud_requirements::cloud_requirements_loader; +use codex_config::types::MarketplaceConfig; +use codex_config::types::MarketplaceSourceType as ConfigMarketplaceSourceType; use codex_config::types::McpServerTransportConfig; use codex_core::CodexThread; use codex_core::Cursor as RolloutCursor; @@ -235,6 +241,8 @@ use codex_core::plugins::PluginReadRequest; use codex_core::plugins::PluginUninstallError as CorePluginUninstallError; use codex_core::plugins::load_plugin_apps; use codex_core::plugins::load_plugin_mcp_servers; +use codex_core::plugins::marketplace_install_root; +use codex_core::plugins::validate_plugin_segment; use codex_core::read_head_for_summary; use codex_core::read_session_meta_line; use codex_core::rollout_date_parts; @@ -925,6 +933,10 @@ impl CodexMessageProcessor { self.skills_list(to_connection_request_id(request_id), params) .await; } + ClientRequest::MarketplaceList { request_id, params } => { + self.marketplace_list(to_connection_request_id(request_id), params) + .await; + } ClientRequest::PluginList { request_id, params } => { self.plugin_list(to_connection_request_id(request_id), params) .await; @@ -6327,6 +6339,75 @@ impl CodexMessageProcessor { .await; } + async fn marketplace_list( + &self, + request_id: ConnectionRequestId, + params: MarketplaceListParams, + ) { + let MarketplaceListParams { cursor, limit } = params; + let config = match self.load_latest_config(/*fallback_cwd*/ None).await { + Ok(config) => config, + Err(err) => { + self.outgoing.send_error(request_id, err).await; + return; + } + }; + + let data = + configured_marketplace_entries_from_config(&config, self.config.codex_home.as_path()); + let total = data.len(); + if total == 0 { + self.outgoing + .send_response( + request_id, + MarketplaceListResponse { + data: Vec::new(), + next_cursor: None, + }, + ) + .await; + return; + } + + let effective_limit = limit.unwrap_or(total as u32).max(1) as usize; + let effective_limit = effective_limit.min(total); + let start = match cursor { + Some(cursor) => match cursor.parse::() { + Ok(idx) => idx, + Err(_) => { + self.send_invalid_request_error( + request_id, + format!("invalid cursor: {cursor}"), + ) + .await; + return; + } + }, + None => 0, + }; + + if start > total { + self.send_invalid_request_error( + request_id, + format!("cursor {start} exceeds total marketplaces {total}"), + ) + .await; + return; + } + + let end = start.saturating_add(effective_limit).min(total); + let data = data[start..end].to_vec(); + let next_cursor = if end < total { + Some(end.to_string()) + } else { + None + }; + + self.outgoing + .send_response(request_id, MarketplaceListResponse { data, next_cursor }) + .await; + } + async fn plugin_list(&self, request_id: ConnectionRequestId, params: PluginListParams) { let plugins_manager = self.thread_manager.plugins_manager(); let PluginListParams { @@ -8862,6 +8943,83 @@ fn marketplace_plugin_source_to_info(source: MarketplacePluginSource) -> PluginS } } +fn configured_marketplace_entries_from_config( + config: &Config, + codex_home: &Path, +) -> Vec { + let Some(user_layer) = config.config_layer_stack.get_user_layer() else { + return Vec::new(); + }; + let Some(marketplaces_value) = user_layer.config.get("marketplaces") else { + return Vec::new(); + }; + let Some(marketplaces) = marketplaces_value.as_table() else { + warn!("invalid marketplaces config: expected table"); + return Vec::new(); + }; + + let install_root = marketplace_install_root(codex_home); + let mut data = marketplaces + .iter() + .filter_map(|(marketplace_name, marketplace_value)| { + if let Err(err) = validate_plugin_segment(marketplace_name, "marketplace name") { + warn!( + marketplace_name, + error = %err, + "ignoring invalid configured marketplace name" + ); + return None; + } + if !marketplace_value.is_table() { + warn!( + marketplace_name, + "ignoring invalid configured marketplace entry" + ); + return None; + } + + let marketplace = match marketplace_value.clone().try_into::() { + Ok(marketplace) => marketplace, + Err(err) => { + warn!( + marketplace_name, + error = %err, + "ignoring invalid configured marketplace entry" + ); + return None; + } + }; + + let path = AbsolutePathBuf::try_from( + install_root + .join(marketplace_name) + .join(".agents/plugins/marketplace.json"), + ) + .ok()?; + + Some(MarketplaceListEntry { + name: marketplace_name.clone(), + path, + last_updated: marketplace.last_updated, + source_type: marketplace.source_type.map(marketplace_source_type_to_info), + source: marketplace.source, + ref_name: marketplace.ref_name, + sparse_paths: marketplace.sparse_paths.unwrap_or_default(), + }) + }) + .collect::>(); + data.sort_unstable_by(|left, right| left.name.cmp(&right.name)); + data +} + +fn marketplace_source_type_to_info( + source_type: ConfigMarketplaceSourceType, +) -> ApiMarketplaceSourceType { + match source_type { + ConfigMarketplaceSourceType::Git => ApiMarketplaceSourceType::Git, + } +} + fn errors_to_info( errors: &[codex_core::skills::SkillError], ) -> Vec { diff --git a/codex-rs/app-server/tests/common/mcp_process.rs b/codex-rs/app-server/tests/common/mcp_process.rs index 5ef7273def..1f369744bd 100644 --- a/codex-rs/app-server/tests/common/mcp_process.rs +++ b/codex-rs/app-server/tests/common/mcp_process.rs @@ -47,6 +47,7 @@ use codex_app_server_protocol::JSONRPCRequest; use codex_app_server_protocol::JSONRPCResponse; use codex_app_server_protocol::ListMcpServerStatusParams; use codex_app_server_protocol::LoginAccountParams; +use codex_app_server_protocol::MarketplaceListParams; use codex_app_server_protocol::McpResourceReadParams; use codex_app_server_protocol::McpServerToolCallParams; use codex_app_server_protocol::MockExperimentalMethodParams; @@ -540,6 +541,15 @@ impl McpProcess { self.send_request("plugin/list", params).await } + /// Send a `marketplace/list` JSON-RPC request. + pub async fn send_marketplace_list_request( + &mut self, + params: MarketplaceListParams, + ) -> anyhow::Result { + let params = Some(serde_json::to_value(params)?); + self.send_request("marketplace/list", params).await + } + /// Send a `plugin/read` JSON-RPC request. pub async fn send_plugin_read_request( &mut self, diff --git a/codex-rs/app-server/tests/suite/v2/marketplace_list.rs b/codex-rs/app-server/tests/suite/v2/marketplace_list.rs new file mode 100644 index 0000000000..64601cbb31 --- /dev/null +++ b/codex-rs/app-server/tests/suite/v2/marketplace_list.rs @@ -0,0 +1,145 @@ +use std::time::Duration; + +use anyhow::Result; +use app_test_support::McpProcess; +use app_test_support::to_response; +use codex_app_server_protocol::JSONRPCResponse; +use codex_app_server_protocol::MarketplaceListParams; +use codex_app_server_protocol::MarketplaceListResponse; +use codex_app_server_protocol::MarketplaceSourceType; +use codex_app_server_protocol::RequestId; +use codex_core::plugins::marketplace_install_root; +use codex_utils_absolute_path::AbsolutePathBuf; +use pretty_assertions::assert_eq; +use tempfile::TempDir; +use tokio::time::timeout; + +const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10); + +#[tokio::test] +async fn marketplace_list_returns_paginated_configured_marketplaces() -> Result<()> { + let codex_home = TempDir::new()?; + std::fs::write( + codex_home.path().join("config.toml"), + r#"[marketplaces.beta] +last_updated = "2026-04-11T08:00:00Z" +source_type = "git" +source = "git@github.com:acme/beta.git" + +[marketplaces.alpha] +last_updated = "2026-04-10T12:34:56Z" +source_type = "git" +source = "https://github.com/acme/alpha.git" +ref = "main" +sparse_paths = ["plugins/alpha"] +"#, + )?; + + let mut mcp = McpProcess::new(codex_home.path()).await?; + timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??; + + let request_id = mcp + .send_marketplace_list_request(MarketplaceListParams { + cursor: None, + limit: Some(1), + }) + .await?; + let response: JSONRPCResponse = timeout( + DEFAULT_TIMEOUT, + mcp.read_stream_until_response_message(RequestId::Integer(request_id)), + ) + .await??; + let response: MarketplaceListResponse = to_response(response)?; + + assert_eq!(response.data.len(), 1); + assert_eq!(response.next_cursor.as_deref(), Some("1")); + assert_eq!(response.data[0].name, "alpha"); + assert_eq!( + response.data[0].path, + AbsolutePathBuf::try_from( + marketplace_install_root(std::fs::canonicalize(codex_home.path())?.as_path()) + .join("alpha") + .join(".agents/plugins/marketplace.json") + )? + ); + assert_eq!( + response.data[0].last_updated.as_deref(), + Some("2026-04-10T12:34:56Z") + ); + assert_eq!( + response.data[0].source_type, + Some(MarketplaceSourceType::Git) + ); + assert_eq!( + response.data[0].source.as_deref(), + Some("https://github.com/acme/alpha.git") + ); + assert_eq!(response.data[0].ref_name.as_deref(), Some("main")); + assert_eq!( + response.data[0].sparse_paths, + vec!["plugins/alpha".to_string()] + ); + + let request_id = mcp + .send_marketplace_list_request(MarketplaceListParams { + cursor: response.next_cursor, + limit: Some(1), + }) + .await?; + let response: JSONRPCResponse = timeout( + DEFAULT_TIMEOUT, + mcp.read_stream_until_response_message(RequestId::Integer(request_id)), + ) + .await??; + let response: MarketplaceListResponse = to_response(response)?; + + assert_eq!(response.data.len(), 1); + assert_eq!(response.next_cursor, None); + assert_eq!(response.data[0].name, "beta"); + assert_eq!( + response.data[0].last_updated.as_deref(), + Some("2026-04-11T08:00:00Z") + ); + assert_eq!( + response.data[0].source_type, + Some(MarketplaceSourceType::Git) + ); + assert_eq!( + response.data[0].source.as_deref(), + Some("git@github.com:acme/beta.git") + ); + assert_eq!(response.data[0].ref_name, None); + assert_eq!(response.data[0].sparse_paths, Vec::::new()); + Ok(()) +} + +#[tokio::test] +async fn marketplace_list_rejects_invalid_cursor() -> Result<()> { + let codex_home = TempDir::new()?; + std::fs::write( + codex_home.path().join("config.toml"), + r#"[marketplaces.alpha] +source_type = "git" +source = "https://github.com/acme/alpha.git" +"#, + )?; + + let mut mcp = McpProcess::new(codex_home.path()).await?; + timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??; + + let request_id = mcp + .send_marketplace_list_request(MarketplaceListParams { + cursor: Some("bad-cursor".to_string()), + limit: Some(1), + }) + .await?; + let err = timeout( + DEFAULT_TIMEOUT, + mcp.read_stream_until_error_message(RequestId::Integer(request_id)), + ) + .await??; + + assert_eq!(err.error.code, -32600); + assert!(err.error.message.contains("invalid cursor")); + Ok(()) +} diff --git a/codex-rs/app-server/tests/suite/v2/mod.rs b/codex-rs/app-server/tests/suite/v2/mod.rs index 56c4fea905..c542210381 100644 --- a/codex-rs/app-server/tests/suite/v2/mod.rs +++ b/codex-rs/app-server/tests/suite/v2/mod.rs @@ -15,6 +15,7 @@ mod experimental_api; mod experimental_feature_list; mod fs; mod initialize; +mod marketplace_list; mod mcp_resource; mod mcp_server_elicitation; mod mcp_server_status;