From fa297ba585c30aca93c28f072bf1ec13d884d498 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Mon, 23 Nov 2026 16:02:37 -0800 Subject: [PATCH] resources: add optional isSymlink flag to DirectoryEntry Adds an optional boolean flag to DirectoryEntry so resourceList can indicate when an entry is a symbolic link without changing the existing type union. - Adds optional `isSymlink?: boolean` to `DirectoryEntry` and documents `type` fallback behavior for symbolic links and `resourceResolve` for target resolution. - Regenerates JSON schemas and .NET, Go, Kotlin, Rust, Swift, and TypeScript client bindings. - Adds shared round-trip fixture `100-resource-list-symlink-result.json` and registers `ResourceListResult` in all six client test runners. - Adds a changelog fragment under `docs/.changes/`. Fixes https://github.com/microsoft/agent-host-protocol/issues/624 (Commit message generated by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Generated/Commands.generated.cs | 12 +++++++++- .../TypesRoundTripFixtures.cs | 2 ++ clients/go/ahptypes/commands.generated.go | 10 +++++++- clients/go/ahptypes/roundtrip_fixture_test.go | 4 ++++ .../generated/Commands.generated.kt | 14 +++++++++-- .../agenthostprotocol/RoundTripCorpusTest.kt | 2 ++ clients/rust/crates/ahp-types/src/commands.rs | 11 ++++++++- .../ahp-types/tests/roundtrip_corpus.rs | 4 +++- .../Generated/Commands.generated.swift | 14 +++++++++-- .../TypesRoundTripFixtureTests.swift | 2 ++ .../typescript/test/types-round-trip.test.ts | 3 ++- .../20261123-directory-entry-is-symlink.json | 5 ++++ schema/commands.schema.json | 6 ++++- schema/errors.schema.json | 6 ++++- types/common/commands.ts | 14 ++++++++++- .../100-resource-list-symlink-result.json | 24 +++++++++++++++++++ 16 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 docs/.changes/20261123-directory-entry-is-symlink.json create mode 100644 types/test-cases/round-trips/100-resource-list-symlink-result.json diff --git a/clients/dotnet/src/AgentHostProtocol.Abstractions/Generated/Commands.generated.cs b/clients/dotnet/src/AgentHostProtocol.Abstractions/Generated/Commands.generated.cs index 1b015b8cc..547d4eec3 100644 --- a/clients/dotnet/src/AgentHostProtocol.Abstractions/Generated/Commands.generated.cs +++ b/clients/dotnet/src/AgentHostProtocol.Abstractions/Generated/Commands.generated.cs @@ -1488,8 +1488,18 @@ public sealed record DirectoryEntry /// Base name of the entry public required string Name { get; init; } - /// Whether the entry is a file or directory + /// Whether the entry is a file or directory. + /// + /// For a symbolic link (`isSymlink: true`), this reports the resolved target + /// kind when known and permitted by the receiver's access policy, or `'file'` + /// as a non-expandable fallback when the target was not inspected or could + /// not be resolved or accessed. public required string Type { get; init; } + + /// Whether the entry is a symbolic link. Callers that need target resolution + /// or canonical URIs SHOULD use `resourceResolve`. + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public bool? IsSymlink { get; init; } } /// Copies a resource from one URI to another on the server's filesystem. diff --git a/clients/dotnet/tests/AgentHostProtocol.Tests/TypesRoundTripFixtures.cs b/clients/dotnet/tests/AgentHostProtocol.Tests/TypesRoundTripFixtures.cs index 447313763..9db249efb 100644 --- a/clients/dotnet/tests/AgentHostProtocol.Tests/TypesRoundTripFixtures.cs +++ b/clients/dotnet/tests/AgentHostProtocol.Tests/TypesRoundTripFixtures.cs @@ -192,6 +192,8 @@ private static (object decoded, string reencoded) DecodeAndReencode(string type, return Wrap(Ser.Deserialize(inputJson)); case "ResourceReadResult": return Wrap(Ser.Deserialize(inputJson)); + case "ResourceListResult": + return Wrap(Ser.Deserialize(inputJson)); case "AuthenticateParams": return Wrap(Ser.Deserialize(inputJson)); default: diff --git a/clients/go/ahptypes/commands.generated.go b/clients/go/ahptypes/commands.generated.go index 94be6ada1..9a7d84bdb 100644 --- a/clients/go/ahptypes/commands.generated.go +++ b/clients/go/ahptypes/commands.generated.go @@ -1037,8 +1037,16 @@ type ResourceListResult struct { type DirectoryEntry struct { // Base name of the entry Name string `json:"name"` - // Whether the entry is a file or directory + // Whether the entry is a file or directory. + // + // For a symbolic link (`isSymlink: true`), this reports the resolved target + // kind when known and permitted by the receiver's access policy, or `'file'` + // as a non-expandable fallback when the target was not inspected or could + // not be resolved or accessed. Type string `json:"type"` + // Whether the entry is a symbolic link. Callers that need target resolution + // or canonical URIs SHOULD use `resourceResolve`. + IsSymlink *bool `json:"isSymlink,omitempty"` } // Copies a resource from one URI to another on the server's filesystem. diff --git a/clients/go/ahptypes/roundtrip_fixture_test.go b/clients/go/ahptypes/roundtrip_fixture_test.go index c8442d822..e37500115 100644 --- a/clients/go/ahptypes/roundtrip_fixture_test.go +++ b/clients/go/ahptypes/roundtrip_fixture_test.go @@ -318,6 +318,10 @@ func decodeAndReencode(t *testing.T, name, typ, inputJSON string) string { var v ResourceReadResult dec(&v) return enc(&v) + case "ResourceListResult": + var v ResourceListResult + dec(&v) + return enc(&v) case "AuthenticateParams": var v AuthenticateParams dec(&v) diff --git a/clients/kotlin/src/main/kotlin/com/microsoft/agenthostprotocol/generated/Commands.generated.kt b/clients/kotlin/src/main/kotlin/com/microsoft/agenthostprotocol/generated/Commands.generated.kt index 80e23fac8..6f995dbba 100644 --- a/clients/kotlin/src/main/kotlin/com/microsoft/agenthostprotocol/generated/Commands.generated.kt +++ b/clients/kotlin/src/main/kotlin/com/microsoft/agenthostprotocol/generated/Commands.generated.kt @@ -1290,9 +1290,19 @@ data class DirectoryEntry( */ val name: String, /** - * Whether the entry is a file or directory + * Whether the entry is a file or directory. + * + * For a symbolic link (`isSymlink: true`), this reports the resolved target + * kind when known and permitted by the receiver's access policy, or `'file'` + * as a non-expandable fallback when the target was not inspected or could + * not be resolved or accessed. + */ + val type: String, + /** + * Whether the entry is a symbolic link. Callers that need target resolution + * or canonical URIs SHOULD use `resourceResolve`. */ - val type: String + val isSymlink: Boolean? = null ) @Serializable diff --git a/clients/kotlin/src/test/kotlin/com/microsoft/agenthostprotocol/RoundTripCorpusTest.kt b/clients/kotlin/src/test/kotlin/com/microsoft/agenthostprotocol/RoundTripCorpusTest.kt index 38b1b7f3c..2dc575ba9 100644 --- a/clients/kotlin/src/test/kotlin/com/microsoft/agenthostprotocol/RoundTripCorpusTest.kt +++ b/clients/kotlin/src/test/kotlin/com/microsoft/agenthostprotocol/RoundTripCorpusTest.kt @@ -48,6 +48,7 @@ import com.microsoft.agenthostprotocol.generated.TcpResetParams import com.microsoft.agenthostprotocol.generated.CreateTcpConnectionParams import com.microsoft.agenthostprotocol.generated.ResourceReadParams import com.microsoft.agenthostprotocol.generated.ResourceReadResult +import com.microsoft.agenthostprotocol.generated.ResourceListResult import com.microsoft.agenthostprotocol.generated.JsonRpcErrorResponse import com.microsoft.agenthostprotocol.generated.JsonRpcNotification import com.microsoft.agenthostprotocol.generated.JsonRpcRequest @@ -282,6 +283,7 @@ class RoundTripCorpusTest { "CreateTcpConnectionParams" -> rt(CreateTcpConnectionParams.serializer()) "ResourceReadParams" -> rt(ResourceReadParams.serializer()) "ResourceReadResult" -> rt(ResourceReadResult.serializer()) + "ResourceListResult" -> rt(ResourceListResult.serializer()) "AuthenticateParams" -> rt(AuthenticateParams.serializer()) else -> fail( "$file: unknown wire type \"$typeName\". " + diff --git a/clients/rust/crates/ahp-types/src/commands.rs b/clients/rust/crates/ahp-types/src/commands.rs index 6764fd470..b130797bc 100644 --- a/clients/rust/crates/ahp-types/src/commands.rs +++ b/clients/rust/crates/ahp-types/src/commands.rs @@ -1377,8 +1377,17 @@ pub struct ResourceListResult { pub struct DirectoryEntry { /// Base name of the entry pub name: String, - /// Whether the entry is a file or directory + /// Whether the entry is a file or directory. + /// + /// For a symbolic link (`isSymlink: true`), this reports the resolved target + /// kind when known and permitted by the receiver's access policy, or `'file'` + /// as a non-expandable fallback when the target was not inspected or could + /// not be resolved or accessed. pub r#type: String, + /// Whether the entry is a symbolic link. Callers that need target resolution + /// or canonical URIs SHOULD use `resourceResolve`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub is_symlink: Option, } /// Copies a resource from one URI to another on the server's filesystem. diff --git a/clients/rust/crates/ahp-types/tests/roundtrip_corpus.rs b/clients/rust/crates/ahp-types/tests/roundtrip_corpus.rs index 330f28625..84294c80e 100644 --- a/clients/rust/crates/ahp-types/tests/roundtrip_corpus.rs +++ b/clients/rust/crates/ahp-types/tests/roundtrip_corpus.rs @@ -31,7 +31,8 @@ use ahp_types::{ commands::{ AuthenticateParams, ChangesetOperationTarget, ChatSource, CreateChatParams, CreateTcpConnectionParams, Implementation, InitializeResult, ReconnectParams, - ReconnectResult, ResourceReadParams, ResourceReadResult, SubscribeParams, SubscribeResult, + ReconnectResult, ResourceListResult, ResourceReadParams, ResourceReadResult, + SubscribeParams, SubscribeResult, }, common::StringOrMarkdown, messages::JsonRpcMessage, @@ -245,6 +246,7 @@ fn decode_and_reencode(file: &str, type_name: &str, input_json: &str) -> Result< "CreateTcpConnectionParams" => round_trip!(CreateTcpConnectionParams), "ResourceReadParams" => round_trip!(ResourceReadParams), "ResourceReadResult" => round_trip!(ResourceReadResult), + "ResourceListResult" => round_trip!(ResourceListResult), "AuthenticateParams" => round_trip!(AuthenticateParams), other => Err(format!( "{}: unknown wire type {:?}. Add a decode entry to decode_and_reencode.", diff --git a/clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/Generated/Commands.generated.swift b/clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/Generated/Commands.generated.swift index 0f4e6dda7..72b7d6a9c 100644 --- a/clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/Generated/Commands.generated.swift +++ b/clients/swift/AgentHostProtocol/Sources/AgentHostProtocol/Generated/Commands.generated.swift @@ -1514,15 +1514,25 @@ public struct ResourceListResult: Codable, Sendable, Equatable { public struct DirectoryEntry: Codable, Sendable, Equatable { /// Base name of the entry public var name: String - /// Whether the entry is a file or directory + /// Whether the entry is a file or directory. + /// + /// For a symbolic link (`isSymlink: true`), this reports the resolved target + /// kind when known and permitted by the receiver's access policy, or `'file'` + /// as a non-expandable fallback when the target was not inspected or could + /// not be resolved or accessed. public var type: String + /// Whether the entry is a symbolic link. Callers that need target resolution + /// or canonical URIs SHOULD use `resourceResolve`. + public var isSymlink: Bool? public init( name: String, - type: String + type: String, + isSymlink: Bool? = nil ) { self.name = name self.type = type + self.isSymlink = isSymlink } } diff --git a/clients/swift/AgentHostProtocol/Tests/AgentHostProtocolClientTests/TypesRoundTripFixtureTests.swift b/clients/swift/AgentHostProtocol/Tests/AgentHostProtocolClientTests/TypesRoundTripFixtureTests.swift index 225d8d0ea..1212167fb 100644 --- a/clients/swift/AgentHostProtocol/Tests/AgentHostProtocolClientTests/TypesRoundTripFixtureTests.swift +++ b/clients/swift/AgentHostProtocol/Tests/AgentHostProtocolClientTests/TypesRoundTripFixtureTests.swift @@ -218,6 +218,8 @@ final class TypesRoundTripFixtureTests: XCTestCase { return try reencode(dec.decode(ResourceReadParams.self, from: inputData)) case "ResourceReadResult": return try reencode(dec.decode(ResourceReadResult.self, from: inputData)) + case "ResourceListResult": + return try reencode(dec.decode(ResourceListResult.self, from: inputData)) case "AuthenticateParams": return try reencode(dec.decode(AuthenticateParams.self, from: inputData)) default: diff --git a/clients/typescript/test/types-round-trip.test.ts b/clients/typescript/test/types-round-trip.test.ts index 086c8bf6a..878b763c6 100644 --- a/clients/typescript/test/types-round-trip.test.ts +++ b/clients/typescript/test/types-round-trip.test.ts @@ -61,7 +61,7 @@ import type { import type { SessionAddedParams } from '../src/types/channels-root/notifications.js'; import type { Implementation, InitializeResult, SubscribeParams, SubscribeResult, ReconnectParams, ReconnectResult, - ResourceReadParams, ResourceReadResult, AuthenticateParams, + ResourceListResult, ResourceReadParams, ResourceReadResult, AuthenticateParams, } from '../src/types/common/commands.js'; import type { ChannelFrameParams, ChannelCreditParams } from '../src/types/common/notifications.js'; import type { TcpDataParams, TcpEofParams, TcpResetParams } from '../src/types/channels-tcp/notifications.js'; @@ -264,6 +264,7 @@ function bindToType(file: string, type: string, parsed: unknown): void { case 'CreateTcpConnectionParams': void (parsed as CreateTcpConnectionParams); break; case 'ResourceReadParams': void (parsed as ResourceReadParams); break; case 'ResourceReadResult': void (parsed as ResourceReadResult); break; + case 'ResourceListResult': void (parsed as ResourceListResult); break; case 'AuthenticateParams': void (parsed as AuthenticateParams); break; default: throw new Error( diff --git a/docs/.changes/20261123-directory-entry-is-symlink.json b/docs/.changes/20261123-directory-entry-is-symlink.json new file mode 100644 index 000000000..aa2fb6c03 --- /dev/null +++ b/docs/.changes/20261123-directory-entry-is-symlink.json @@ -0,0 +1,5 @@ +{ + "type": "added", + "message": "Optional `isSymlink` boolean flag on `DirectoryEntry` in `resourceList` results.", + "issues": [624] +} diff --git a/schema/commands.schema.json b/schema/commands.schema.json index 1f16c1696..c4c9f5fc6 100644 --- a/schema/commands.schema.json +++ b/schema/commands.schema.json @@ -756,7 +756,11 @@ "file", "directory" ], - "description": "Whether the entry is a file or directory" + "description": "Whether the entry is a file or directory.\n\nFor a symbolic link (`isSymlink: true`), this reports the resolved target\nkind when known and permitted by the receiver's access policy, or `'file'`\nas a non-expandable fallback when the target was not inspected or could\nnot be resolved or accessed." + }, + "isSymlink": { + "type": "boolean", + "description": "Whether the entry is a symbolic link. Callers that need target resolution\nor canonical URIs SHOULD use `resourceResolve`." } }, "required": [ diff --git a/schema/errors.schema.json b/schema/errors.schema.json index b2edbe1f0..373b41d43 100644 --- a/schema/errors.schema.json +++ b/schema/errors.schema.json @@ -6973,7 +6973,11 @@ "file", "directory" ], - "description": "Whether the entry is a file or directory" + "description": "Whether the entry is a file or directory.\n\nFor a symbolic link (`isSymlink: true`), this reports the resolved target\nkind when known and permitted by the receiver's access policy, or `'file'`\nas a non-expandable fallback when the target was not inspected or could\nnot be resolved or accessed." + }, + "isSymlink": { + "type": "boolean", + "description": "Whether the entry is a symbolic link. Callers that need target resolution\nor canonical URIs SHOULD use `resourceResolve`." } }, "required": [ diff --git a/types/common/commands.ts b/types/common/commands.ts index 90ffe9d6d..fad16c117 100644 --- a/types/common/commands.ts +++ b/types/common/commands.ts @@ -1125,8 +1125,20 @@ export interface ResourceListParams extends BaseParams { export interface DirectoryEntry { /** Base name of the entry */ name: string; - /** Whether the entry is a file or directory */ + /** + * Whether the entry is a file or directory. + * + * For a symbolic link (`isSymlink: true`), this reports the resolved target + * kind when known and permitted by the receiver's access policy, or `'file'` + * as a non-expandable fallback when the target was not inspected or could + * not be resolved or accessed. + */ type: 'file' | 'directory'; + /** + * Whether the entry is a symbolic link. Callers that need target resolution + * or canonical URIs SHOULD use `resourceResolve`. + */ + isSymlink?: boolean; } /** diff --git a/types/test-cases/round-trips/100-resource-list-symlink-result.json b/types/test-cases/round-trips/100-resource-list-symlink-result.json new file mode 100644 index 000000000..897f553c1 --- /dev/null +++ b/types/test-cases/round-trips/100-resource-list-symlink-result.json @@ -0,0 +1,24 @@ +{ + "name": "resource-list-symlink-result", + "group": "A", + "description": "DirectoryEntry carries optional isSymlink: omitted stays absent on re-encode, while explicit true and false values are preserved alongside file and directory types.", + "type": "ResourceListResult", + "input": { + "entries": [ + { "name": "src", "type": "directory" }, + { "name": "shared", "type": "directory", "isSymlink": true }, + { "name": "broken-link", "type": "file", "isSymlink": true }, + { "name": "README.md", "type": "file", "isSymlink": false } + ] + }, + "acceptableOutputs": [ + { + "entries": [ + { "name": "src", "type": "directory" }, + { "name": "shared", "type": "directory", "isSymlink": true }, + { "name": "broken-link", "type": "file", "isSymlink": true }, + { "name": "README.md", "type": "file", "isSymlink": false } + ] + } + ] +}