Skip to content

Commit 0091115

Browse files
author
Mark Pollack
committed
Remove raw handler overloads to fix lambda ambiguity
- Delete SyncRequestHandler overloads for readTextFile, writeTextFile, requestPermission - Keep only typed Function<Request, Response> handlers - Add debug logging for raw params in typed handlers - Update javadoc to remove "preferred method" wording - Keep generic requestHandler(String, SyncRequestHandler) for custom methods
1 parent 25fb914 commit 0091115

File tree

1 file changed

+6
-69
lines changed
  • acp-core/src/main/java/com/agentclientprotocol/sdk/client

1 file changed

+6
-69
lines changed

acp-core/src/main/java/com/agentclientprotocol/sdk/client/AcpClient.java

Lines changed: 6 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -469,34 +469,9 @@ public SyncSpec clientCapabilities(AcpSchema.ClientCapabilities clientCapabiliti
469469
return this;
470470
}
471471

472-
/**
473-
* Adds a synchronous handler for file system read requests from the agent.
474-
* This is the preferred method for sync clients as it allows writing blocking
475-
* I/O code without reactive wrappers.
476-
*
477-
* <p>Example usage:
478-
* <pre>{@code
479-
* .readTextFileHandler(params -> {
480-
* ReadTextFileRequest req = transport.unmarshalFrom(params, new TypeRef<>() {});
481-
* String content = Files.readString(Path.of(req.path()));
482-
* return new ReadTextFileResponse(content);
483-
* })
484-
* }</pre>
485-
*
486-
* @param handler The synchronous handler that processes read requests
487-
* @return This builder instance for method chaining
488-
* @throws IllegalArgumentException if handler is null
489-
*/
490-
public SyncSpec readTextFileHandler(SyncRequestHandler<AcpSchema.ReadTextFileResponse> handler) {
491-
Assert.notNull(handler, "Read text file handler must not be null");
492-
this.requestHandlers.put(AcpSchema.METHOD_FS_READ_TEXT_FILE, fromSync(handler));
493-
return this;
494-
}
495-
496472
/**
497473
* Adds a typed handler for file system read requests from the agent.
498-
* This is the preferred method as it provides type-safe request handling
499-
* without manual unmarshalling.
474+
* Provides type-safe request handling with automatic unmarshalling.
500475
*
501476
* <p>Example usage:
502477
* <pre>{@code
@@ -512,6 +487,7 @@ public SyncSpec readTextFileHandler(
512487
Function<AcpSchema.ReadTextFileRequest, AcpSchema.ReadTextFileResponse> handler) {
513488
Assert.notNull(handler, "Read text file handler must not be null");
514489
SyncRequestHandler<AcpSchema.ReadTextFileResponse> rawHandler = params -> {
490+
logger.debug("readTextFile request params: {}", params);
515491
AcpSchema.ReadTextFileRequest request = transport.unmarshalFrom(params,
516492
new TypeRef<AcpSchema.ReadTextFileRequest>() {});
517493
return handler.apply(request);
@@ -520,34 +496,9 @@ public SyncSpec readTextFileHandler(
520496
return this;
521497
}
522498

523-
/**
524-
* Adds a synchronous handler for file system write requests from the agent.
525-
* This is the preferred method for sync clients as it allows writing blocking
526-
* I/O code without reactive wrappers.
527-
*
528-
* <p>Example usage:
529-
* <pre>{@code
530-
* .writeTextFileHandler(params -> {
531-
* WriteTextFileRequest req = transport.unmarshalFrom(params, new TypeRef<>() {});
532-
* Files.writeString(Path.of(req.path()), req.content());
533-
* return new WriteTextFileResponse();
534-
* })
535-
* }</pre>
536-
*
537-
* @param handler The synchronous handler that processes write requests
538-
* @return This builder instance for method chaining
539-
* @throws IllegalArgumentException if handler is null
540-
*/
541-
public SyncSpec writeTextFileHandler(SyncRequestHandler<AcpSchema.WriteTextFileResponse> handler) {
542-
Assert.notNull(handler, "Write text file handler must not be null");
543-
this.requestHandlers.put(AcpSchema.METHOD_FS_WRITE_TEXT_FILE, fromSync(handler));
544-
return this;
545-
}
546-
547499
/**
548500
* Adds a typed handler for file system write requests from the agent.
549-
* This is the preferred method as it provides type-safe request handling
550-
* without manual unmarshalling.
501+
* Provides type-safe request handling with automatic unmarshalling.
551502
*
552503
* <p>Example usage:
553504
* <pre>{@code
@@ -565,6 +516,7 @@ public SyncSpec writeTextFileHandler(
565516
Function<AcpSchema.WriteTextFileRequest, AcpSchema.WriteTextFileResponse> handler) {
566517
Assert.notNull(handler, "Write text file handler must not be null");
567518
SyncRequestHandler<AcpSchema.WriteTextFileResponse> rawHandler = params -> {
519+
logger.debug("writeTextFile request params: {}", params);
568520
AcpSchema.WriteTextFileRequest request = transport.unmarshalFrom(params,
569521
new TypeRef<AcpSchema.WriteTextFileRequest>() {});
570522
return handler.apply(request);
@@ -573,25 +525,9 @@ public SyncSpec writeTextFileHandler(
573525
return this;
574526
}
575527

576-
/**
577-
* Adds a synchronous handler for permission requests from the agent.
578-
* This is the preferred method for sync clients as it allows writing blocking
579-
* I/O code (like Console.readLine()) without reactive wrappers.
580-
*
581-
* @param handler The synchronous handler that processes permission requests
582-
* @return This builder instance for method chaining
583-
* @throws IllegalArgumentException if handler is null
584-
*/
585-
public SyncSpec requestPermissionHandler(SyncRequestHandler<AcpSchema.RequestPermissionResponse> handler) {
586-
Assert.notNull(handler, "Request permission handler must not be null");
587-
this.requestHandlers.put(AcpSchema.METHOD_SESSION_REQUEST_PERMISSION, fromSync(handler));
588-
return this;
589-
}
590-
591528
/**
592529
* Adds a typed handler for permission requests from the agent.
593-
* This is the preferred method as it provides type-safe request handling
594-
* without manual unmarshalling.
530+
* Provides type-safe request handling with automatic unmarshalling.
595531
*
596532
* <p>Example usage:
597533
* <pre>{@code
@@ -611,6 +547,7 @@ public SyncSpec requestPermissionHandler(
611547
Function<AcpSchema.RequestPermissionRequest, AcpSchema.RequestPermissionResponse> handler) {
612548
Assert.notNull(handler, "Request permission handler must not be null");
613549
SyncRequestHandler<AcpSchema.RequestPermissionResponse> rawHandler = params -> {
550+
logger.debug("requestPermission request params: {}", params);
614551
AcpSchema.RequestPermissionRequest request = transport.unmarshalFrom(params,
615552
new TypeRef<AcpSchema.RequestPermissionRequest>() {});
616553
return handler.apply(request);

0 commit comments

Comments
 (0)