diff --git a/codex-rs/app-server-protocol/schema/json/ClientRequest.json b/codex-rs/app-server-protocol/schema/json/ClientRequest.json index 6bdf195361..307f2ee0bf 100644 --- a/codex-rs/app-server-protocol/schema/json/ClientRequest.json +++ b/codex-rs/app-server-protocol/schema/json/ClientRequest.json @@ -800,6 +800,23 @@ ], "type": "object" }, + "FsCanonicalizeParams": { + "description": "Resolve an absolute path to its canonical filesystem path.", + "properties": { + "path": { + "allOf": [ + { + "$ref": "#/definitions/AbsolutePathBuf" + } + ], + "description": "Absolute path to canonicalize. The path must exist." + } + }, + "required": [ + "path" + ], + "type": "object" + }, "FsCopyParams": { "description": "Copy a file or directory tree on the host filesystem.", "properties": { @@ -5366,6 +5383,30 @@ "title": "Fs/createDirectoryRequest", "type": "object" }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "fs/canonicalize" + ], + "title": "Fs/canonicalizeRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/FsCanonicalizeParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "Fs/canonicalizeRequest", + "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 82646d0ec6..45b6f92b50 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 @@ -1165,6 +1165,30 @@ "title": "Fs/createDirectoryRequest", "type": "object" }, + { + "properties": { + "id": { + "$ref": "#/definitions/v2/RequestId" + }, + "method": { + "enum": [ + "fs/canonicalize" + ], + "title": "Fs/canonicalizeRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/v2/FsCanonicalizeParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "Fs/canonicalizeRequest", + "type": "object" + }, { "properties": { "id": { @@ -9269,6 +9293,44 @@ ], "type": "string" }, + "FsCanonicalizeParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Resolve an absolute path to its canonical filesystem path.", + "properties": { + "path": { + "allOf": [ + { + "$ref": "#/definitions/v2/AbsolutePathBuf" + } + ], + "description": "Absolute path to canonicalize. The path must exist." + } + }, + "required": [ + "path" + ], + "title": "FsCanonicalizeParams", + "type": "object" + }, + "FsCanonicalizeResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Canonical path returned by `fs/canonicalize`.", + "properties": { + "path": { + "allOf": [ + { + "$ref": "#/definitions/v2/AbsolutePathBuf" + } + ], + "description": "Canonical absolute path with symbolic links resolved." + } + }, + "required": [ + "path" + ], + "title": "FsCanonicalizeResponse", + "type": "object" + }, "FsChangedNotification": { "$schema": "http://json-schema.org/draft-07/schema#", "description": "Filesystem watch notification emitted for `fs/watch` subscribers.", 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 6be7e76eb7..d0b6e8f2c2 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 @@ -2107,6 +2107,30 @@ "title": "Fs/createDirectoryRequest", "type": "object" }, + { + "properties": { + "id": { + "$ref": "#/definitions/RequestId" + }, + "method": { + "enum": [ + "fs/canonicalize" + ], + "title": "Fs/canonicalizeRequestMethod", + "type": "string" + }, + "params": { + "$ref": "#/definitions/FsCanonicalizeParams" + } + }, + "required": [ + "id", + "method", + "params" + ], + "title": "Fs/canonicalizeRequest", + "type": "object" + }, { "properties": { "id": { @@ -5591,6 +5615,44 @@ ], "type": "string" }, + "FsCanonicalizeParams": { + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Resolve an absolute path to its canonical filesystem path.", + "properties": { + "path": { + "allOf": [ + { + "$ref": "#/definitions/AbsolutePathBuf" + } + ], + "description": "Absolute path to canonicalize. The path must exist." + } + }, + "required": [ + "path" + ], + "title": "FsCanonicalizeParams", + "type": "object" + }, + "FsCanonicalizeResponse": { + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Canonical path returned by `fs/canonicalize`.", + "properties": { + "path": { + "allOf": [ + { + "$ref": "#/definitions/AbsolutePathBuf" + } + ], + "description": "Canonical absolute path with symbolic links resolved." + } + }, + "required": [ + "path" + ], + "title": "FsCanonicalizeResponse", + "type": "object" + }, "FsChangedNotification": { "$schema": "http://json-schema.org/draft-07/schema#", "description": "Filesystem watch notification emitted for `fs/watch` subscribers.", diff --git a/codex-rs/app-server-protocol/schema/json/v2/FsCanonicalizeParams.json b/codex-rs/app-server-protocol/schema/json/v2/FsCanonicalizeParams.json new file mode 100644 index 0000000000..91dc068a4d --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/FsCanonicalizeParams.json @@ -0,0 +1,25 @@ +{ + "$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" + } + }, + "description": "Resolve an absolute path to its canonical filesystem path.", + "properties": { + "path": { + "allOf": [ + { + "$ref": "#/definitions/AbsolutePathBuf" + } + ], + "description": "Absolute path to canonicalize. The path must exist." + } + }, + "required": [ + "path" + ], + "title": "FsCanonicalizeParams", + "type": "object" +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/FsCanonicalizeResponse.json b/codex-rs/app-server-protocol/schema/json/v2/FsCanonicalizeResponse.json new file mode 100644 index 0000000000..2a25da5316 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/json/v2/FsCanonicalizeResponse.json @@ -0,0 +1,25 @@ +{ + "$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" + } + }, + "description": "Canonical path returned by `fs/canonicalize`.", + "properties": { + "path": { + "allOf": [ + { + "$ref": "#/definitions/AbsolutePathBuf" + } + ], + "description": "Canonical absolute path with symbolic links resolved." + } + }, + "required": [ + "path" + ], + "title": "FsCanonicalizeResponse", + "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 b6a13fe307..0cafb1536e 100644 --- a/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts +++ b/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts @@ -21,6 +21,7 @@ import type { ExperimentalFeatureListParams } from "./v2/ExperimentalFeatureList import type { ExternalAgentConfigDetectParams } from "./v2/ExternalAgentConfigDetectParams"; import type { ExternalAgentConfigImportParams } from "./v2/ExternalAgentConfigImportParams"; import type { FeedbackUploadParams } from "./v2/FeedbackUploadParams"; +import type { FsCanonicalizeParams } from "./v2/FsCanonicalizeParams"; import type { FsCopyParams } from "./v2/FsCopyParams"; import type { FsCreateDirectoryParams } from "./v2/FsCreateDirectoryParams"; import type { FsGetMetadataParams } from "./v2/FsGetMetadataParams"; @@ -87,4 +88,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/delete", id: RequestId, params: ThreadDeleteParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/goal/set", id: RequestId, params: ThreadGoalSetParams, } | { "method": "thread/goal/get", id: RequestId, params: ThreadGoalGetParams, } | { "method": "thread/goal/clear", id: RequestId, params: ThreadGoalClearParams, } | { "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/approveGuardianDeniedAction", id: RequestId, params: ThreadApproveGuardianDeniedActionParams, } | { "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": "thread/inject_items", id: RequestId, params: ThreadInjectItemsParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "skills/extraRoots/set", id: RequestId, params: SkillsExtraRootsSetParams, } | { "method": "hooks/list", id: RequestId, params: HooksListParams, } | { "method": "marketplace/add", id: RequestId, params: MarketplaceAddParams, } | { "method": "marketplace/remove", id: RequestId, params: MarketplaceRemoveParams, } | { "method": "marketplace/upgrade", id: RequestId, params: MarketplaceUpgradeParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/installed", id: RequestId, params: PluginInstalledParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "plugin/skill/read", id: RequestId, params: PluginSkillReadParams, } | { "method": "plugin/share/save", id: RequestId, params: PluginShareSaveParams, } | { "method": "plugin/share/updateTargets", id: RequestId, params: PluginShareUpdateTargetsParams, } | { "method": "plugin/share/list", id: RequestId, params: PluginShareListParams, } | { "method": "plugin/share/checkout", id: RequestId, params: PluginShareCheckoutParams, } | { "method": "plugin/share/delete", id: RequestId, params: PluginShareDeleteParams, } | { "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": "modelProvider/capabilities/read", id: RequestId, params: ModelProviderCapabilitiesReadParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "permissionProfile/list", id: RequestId, params: PermissionProfileListParams, } | { "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": "windowsSandbox/readiness", id: RequestId, params: undefined, } | { "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": "account/usage/read", id: RequestId, params: undefined, } | { "method": "account/sendAddCreditsNudgeEmail", id: RequestId, params: SendAddCreditsNudgeEmailParams, } | { "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/delete", id: RequestId, params: ThreadDeleteParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/goal/set", id: RequestId, params: ThreadGoalSetParams, } | { "method": "thread/goal/get", id: RequestId, params: ThreadGoalGetParams, } | { "method": "thread/goal/clear", id: RequestId, params: ThreadGoalClearParams, } | { "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/approveGuardianDeniedAction", id: RequestId, params: ThreadApproveGuardianDeniedActionParams, } | { "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": "thread/inject_items", id: RequestId, params: ThreadInjectItemsParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "skills/extraRoots/set", id: RequestId, params: SkillsExtraRootsSetParams, } | { "method": "hooks/list", id: RequestId, params: HooksListParams, } | { "method": "marketplace/add", id: RequestId, params: MarketplaceAddParams, } | { "method": "marketplace/remove", id: RequestId, params: MarketplaceRemoveParams, } | { "method": "marketplace/upgrade", id: RequestId, params: MarketplaceUpgradeParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/installed", id: RequestId, params: PluginInstalledParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "plugin/skill/read", id: RequestId, params: PluginSkillReadParams, } | { "method": "plugin/share/save", id: RequestId, params: PluginShareSaveParams, } | { "method": "plugin/share/updateTargets", id: RequestId, params: PluginShareUpdateTargetsParams, } | { "method": "plugin/share/list", id: RequestId, params: PluginShareListParams, } | { "method": "plugin/share/checkout", id: RequestId, params: PluginShareCheckoutParams, } | { "method": "plugin/share/delete", id: RequestId, params: PluginShareDeleteParams, } | { "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/canonicalize", id: RequestId, params: FsCanonicalizeParams, } | { "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": "modelProvider/capabilities/read", id: RequestId, params: ModelProviderCapabilitiesReadParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "permissionProfile/list", id: RequestId, params: PermissionProfileListParams, } | { "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": "windowsSandbox/readiness", id: RequestId, params: undefined, } | { "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": "account/usage/read", id: RequestId, params: undefined, } | { "method": "account/sendAddCreditsNudgeEmail", id: RequestId, params: SendAddCreditsNudgeEmailParams, } | { "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/FsCanonicalizeParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/FsCanonicalizeParams.ts new file mode 100644 index 0000000000..a5e305bd7f --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/FsCanonicalizeParams.ts @@ -0,0 +1,13 @@ +// 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"; + +/** + * Resolve an absolute path to its canonical filesystem path. + */ +export type FsCanonicalizeParams = { +/** + * Absolute path to canonicalize. The path must exist. + */ +path: AbsolutePathBuf, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/FsCanonicalizeResponse.ts b/codex-rs/app-server-protocol/schema/typescript/v2/FsCanonicalizeResponse.ts new file mode 100644 index 0000000000..6c0a761ccc --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/FsCanonicalizeResponse.ts @@ -0,0 +1,13 @@ +// 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"; + +/** + * Canonical path returned by `fs/canonicalize`. + */ +export type FsCanonicalizeResponse = { +/** + * Canonical absolute path with symbolic links resolved. + */ +path: AbsolutePathBuf, }; 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 b4cd88aadf..3abbe44444 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts @@ -121,6 +121,8 @@ export type { FileSystemSandboxEntry } from "./FileSystemSandboxEntry"; export type { FileSystemSpecialPath } from "./FileSystemSpecialPath"; export type { FileUpdateChange } from "./FileUpdateChange"; export type { ForcedChatgptWorkspaceIds } from "./ForcedChatgptWorkspaceIds"; +export type { FsCanonicalizeParams } from "./FsCanonicalizeParams"; +export type { FsCanonicalizeResponse } from "./FsCanonicalizeResponse"; export type { FsChangedNotification } from "./FsChangedNotification"; export type { FsCopyParams } from "./FsCopyParams"; export type { FsCopyResponse } from "./FsCopyResponse"; diff --git a/codex-rs/app-server-protocol/src/protocol/common.rs b/codex-rs/app-server-protocol/src/protocol/common.rs index 9311fe9058..79f93d9878 100644 --- a/codex-rs/app-server-protocol/src/protocol/common.rs +++ b/codex-rs/app-server-protocol/src/protocol/common.rs @@ -739,6 +739,11 @@ client_request_definitions! { serialization: None, response: v2::FsCreateDirectoryResponse, }, + FsCanonicalize => "fs/canonicalize" { + params: v2::FsCanonicalizeParams, + serialization: None, + response: v2::FsCanonicalizeResponse, + }, FsGetMetadata => "fs/getMetadata" { params: v2::FsGetMetadataParams, serialization: None, @@ -2848,6 +2853,27 @@ mod tests { Ok(()) } + #[test] + fn serialize_fs_canonicalize() -> Result<()> { + let request = ClientRequest::FsCanonicalize { + request_id: RequestId::Integer(10), + params: v2::FsCanonicalizeParams { + path: absolute_path("tmp/example"), + }, + }; + assert_eq!( + json!({ + "method": "fs/canonicalize", + "id": 10, + "params": { + "path": absolute_path_string("tmp/example") + } + }), + serde_json::to_value(&request)?, + ); + Ok(()) + } + #[test] fn serialize_fs_get_metadata() -> Result<()> { let request = ClientRequest::FsGetMetadata { diff --git a/codex-rs/app-server-protocol/src/protocol/v2/fs.rs b/codex-rs/app-server-protocol/src/protocol/v2/fs.rs index 0132c6b284..19fd6c2b6d 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2/fs.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2/fs.rs @@ -57,6 +57,24 @@ pub struct FsCreateDirectoryParams { #[ts(export_to = "v2/")] pub struct FsCreateDirectoryResponse {} +/// Resolve an absolute path to its canonical filesystem path. +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct FsCanonicalizeParams { + /// Absolute path to canonicalize. The path must exist. + pub path: AbsolutePathBuf, +} + +/// Canonical path returned by `fs/canonicalize`. +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub struct FsCanonicalizeResponse { + /// Canonical absolute path with symbolic links resolved. + pub path: AbsolutePathBuf, +} + /// Request metadata for an absolute path. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.md index 42ac510a8a..aa37dcfd7d 100644 --- a/codex-rs/app-server/README.md +++ b/codex-rs/app-server/README.md @@ -184,6 +184,7 @@ Example with notification opt-out: - `fs/readFile` — read an absolute file path and return `{ dataBase64 }`. - `fs/writeFile` — write an absolute file path from base64-encoded `{ dataBase64 }`; returns `{}`. - `fs/createDirectory` — create an absolute directory path; `recursive` defaults to `true`. +- `fs/canonicalize` — resolve an existing absolute path to its canonical absolute path, including symbolic links. - `fs/getMetadata` — return metadata for an absolute path: `isDirectory`, `isFile`, `isSymlink`, `createdAtMs`, and `modifiedAtMs`. - `fs/readDirectory` — list direct child entries for an absolute directory path; each entry contains `fileName`, `isDirectory`, and `isFile`, and `fileName` is just the child name, not a path. - `fs/remove` — remove an absolute file or directory tree; `recursive` and `force` default to `true`. @@ -1189,20 +1190,26 @@ All filesystem paths in this section must be absolute. "dataBase64": "aGVsbG8=" } } { "id": 41, "result": {} } -{ "method": "fs/getMetadata", "id": 42, "params": { - "path": "/tmp/example/nested/note.txt" +{ "method": "fs/canonicalize", "id": 42, "params": { + "path": "/tmp/example/nested/../nested/note.txt" } } { "id": 42, "result": { + "path": "/tmp/example/nested/note.txt" +} } +{ "method": "fs/getMetadata", "id": 43, "params": { + "path": "/tmp/example/nested/note.txt" +} } +{ "id": 43, "result": { "isDirectory": false, "isFile": true, "isSymlink": false, "createdAtMs": 1730910000000, "modifiedAtMs": 1730910000000 } } -{ "method": "fs/readFile", "id": 43, "params": { +{ "method": "fs/readFile", "id": 44, "params": { "path": "/tmp/example/nested/note.txt" } } -{ "id": 43, "result": { +{ "id": 44, "result": { "dataBase64": "aGVsbG8=" } } ``` diff --git a/codex-rs/app-server/src/message_processor.rs b/codex-rs/app-server/src/message_processor.rs index 6ba59e733f..e5c626ee21 100644 --- a/codex-rs/app-server/src/message_processor.rs +++ b/codex-rs/app-server/src/message_processor.rs @@ -997,6 +997,11 @@ impl MessageProcessor { .create_directory(params) .await .map(|response| Some(response.into())), + ClientRequest::FsCanonicalize { params, .. } => self + .fs_processor + .canonicalize(params) + .await + .map(|response| Some(response.into())), ClientRequest::FsGetMetadata { params, .. } => self .fs_processor .get_metadata(params) diff --git a/codex-rs/app-server/src/request_processors/fs_processor.rs b/codex-rs/app-server/src/request_processors/fs_processor.rs index 99a8620b4f..0f288fad92 100644 --- a/codex-rs/app-server/src/request_processors/fs_processor.rs +++ b/codex-rs/app-server/src/request_processors/fs_processor.rs @@ -4,6 +4,8 @@ use crate::fs_watch::FsWatchManager; use crate::outgoing_message::ConnectionId; use base64::Engine; use base64::engine::general_purpose::STANDARD; +use codex_app_server_protocol::FsCanonicalizeParams; +use codex_app_server_protocol::FsCanonicalizeResponse; use codex_app_server_protocol::FsCopyParams; use codex_app_server_protocol::FsCopyResponse; use codex_app_server_protocol::FsCreateDirectoryParams; @@ -107,6 +109,18 @@ impl FsRequestProcessor { Ok(FsCreateDirectoryResponse {}) } + pub(crate) async fn canonicalize( + &self, + params: FsCanonicalizeParams, + ) -> Result { + let path = self + .file_system()? + .canonicalize(¶ms.path, /*sandbox*/ None) + .await + .map_err(map_fs_error)?; + Ok(FsCanonicalizeResponse { path }) + } + pub(crate) async fn get_metadata( &self, params: FsGetMetadataParams, diff --git a/codex-rs/app-server/tests/common/test_app_server.rs b/codex-rs/app-server/tests/common/test_app_server.rs index 91c42e2fe4..5c5fd3ba87 100644 --- a/codex-rs/app-server/tests/common/test_app_server.rs +++ b/codex-rs/app-server/tests/common/test_app_server.rs @@ -25,6 +25,7 @@ use codex_app_server_protocol::ConfigReadParams; use codex_app_server_protocol::ConfigValueWriteParams; use codex_app_server_protocol::ExperimentalFeatureListParams; use codex_app_server_protocol::FeedbackUploadParams; +use codex_app_server_protocol::FsCanonicalizeParams; use codex_app_server_protocol::FsCopyParams; use codex_app_server_protocol::FsCreateDirectoryParams; use codex_app_server_protocol::FsGetMetadataParams; @@ -1150,6 +1151,14 @@ impl TestAppServer { self.send_request("fs/createDirectory", params).await } + pub async fn send_fs_canonicalize_request( + &mut self, + params: FsCanonicalizeParams, + ) -> anyhow::Result { + let params = Some(serde_json::to_value(params)?); + self.send_request("fs/canonicalize", params).await + } + pub async fn send_fs_get_metadata_request( &mut self, params: FsGetMetadataParams, diff --git a/codex-rs/app-server/tests/suite/v2/fs.rs b/codex-rs/app-server/tests/suite/v2/fs.rs index 1f04c847d2..0afe63d205 100644 --- a/codex-rs/app-server/tests/suite/v2/fs.rs +++ b/codex-rs/app-server/tests/suite/v2/fs.rs @@ -4,6 +4,8 @@ use app_test_support::TestAppServer; use app_test_support::to_response; use base64::Engine; use base64::engine::general_purpose::STANDARD; +use codex_app_server_protocol::FsCanonicalizeParams; +use codex_app_server_protocol::FsCanonicalizeResponse; use codex_app_server_protocol::FsChangedNotification; use codex_app_server_protocol::FsCopyParams; use codex_app_server_protocol::FsGetMetadataResponse; @@ -120,6 +122,64 @@ async fn fs_get_metadata_returns_only_used_fields() -> Result<()> { Ok(()) } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn fs_canonicalize_resolves_an_existing_path() -> Result<()> { + let codex_home = TempDir::new()?; + let directory = codex_home.path().join("parent"); + let child = directory.join("child"); + std::fs::create_dir_all(&child)?; + let path = child.join(".."); + + let mut mcp = initialized_mcp(&codex_home).await?; + let request_id = mcp + .send_fs_canonicalize_request(FsCanonicalizeParams { + path: absolute_path(path), + }) + .await?; + let response: FsCanonicalizeResponse = to_response( + timeout( + DEFAULT_READ_TIMEOUT, + mcp.read_stream_until_response_message(RequestId::Integer(request_id)), + ) + .await??, + )?; + + assert_eq!( + response.path, + absolute_path(std::fs::canonicalize(directory)?) + ); + + Ok(()) +} + +#[cfg(unix)] +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn fs_canonicalize_resolves_a_symlink() -> Result<()> { + let codex_home = TempDir::new()?; + let target = codex_home.path().join("target"); + let alias = codex_home.path().join("alias"); + std::fs::create_dir(&target)?; + symlink(&target, &alias)?; + + let mut mcp = initialized_mcp(&codex_home).await?; + let request_id = mcp + .send_fs_canonicalize_request(FsCanonicalizeParams { + path: absolute_path(alias), + }) + .await?; + let response: FsCanonicalizeResponse = to_response( + timeout( + DEFAULT_READ_TIMEOUT, + mcp.read_stream_until_response_message(RequestId::Integer(request_id)), + ) + .await??, + )?; + + assert_eq!(response.path.as_path(), std::fs::canonicalize(target)?); + + Ok(()) +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn fs_methods_return_error_when_local_environment_is_disabled() -> Result<()> { let codex_home = TempDir::new()?; @@ -139,6 +199,18 @@ async fn fs_methods_return_error_when_local_environment_is_disabled() -> Result< .await?; expect_error_message(&mut mcp, read_id, "local filesystem is not configured").await?; + let canonicalize_id = mcp + .send_fs_canonicalize_request(FsCanonicalizeParams { + path: absolute_path(codex_home.path().to_path_buf()), + }) + .await?; + expect_error_message( + &mut mcp, + canonicalize_id, + "local filesystem is not configured", + ) + .await?; + Ok(()) } @@ -443,6 +515,16 @@ async fn fs_methods_reject_relative_paths() -> Result<()> { ) .await?; + let canonicalize_id = mcp + .send_raw_request("fs/canonicalize", Some(json!({ "path": "relative-dir" }))) + .await?; + expect_error_message( + &mut mcp, + canonicalize_id, + "Invalid request: AbsolutePathBuf deserialized without a base path", + ) + .await?; + let get_metadata_id = mcp .send_raw_request("fs/getMetadata", Some(json!({ "path": "relative.txt" }))) .await?;