a2aproject / a2aproject/a2a-java

[Feat]: Simplification of the client API?

Aperta
#517 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
490
Fork
172
Merge medio
1g 6h
PR unite (30g)
55

Descrizione

### Is your feature request related to a problem? Please describe.

The `client` API is a thin wrapper around the domain objects in the `spec` module.

I wonder if we could not make the API a bit simpler while retaining all the capabilities it exposes.

### Describe the solution you'd like

For example, a lot of calls wrap their parameters in `XXXParams` object:

```
public Task cancelTask(TaskIdParams request)
```

but TaskIdParams is composed of a `taskId` and a `metadata` map.
Could the call simply be:

```
public Task cancelTask(String taskId, Map metadata) {
return clientTransport.cancelTask(new TaskIdParams(taskId, metadata), request, context);
}
```

and a default method:

```
public default Task cancelTask(String taskId) {
return cancelTask(taskId, emptyMap();
}
```

This way, the `TaskIdParams` does not leak to the `Client` API (making it bigger than it needs to be.

The API is already to that for its `sendMessage` methods that hides the internal `MessageSendParams`.
This is a pattern that should be applied to other methods as well

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.