-
Notifications
You must be signed in to change notification settings - Fork 105
feat: Implement ServerCallContext #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package io.a2a.server.apps.quarkus; | ||
|
|
||
| import io.a2a.server.ServerCallContext; | ||
| import io.vertx.ext.web.RoutingContext; | ||
|
|
||
| public interface CallContextFactory { | ||
| ServerCallContext build(RoutingContext rc); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,26 @@ | ||||||||||||||||||
| package io.a2a.server; | ||||||||||||||||||
|
|
||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||
| import java.util.concurrent.ConcurrentHashMap; | ||||||||||||||||||
|
|
||||||||||||||||||
| import io.a2a.server.auth.User; | ||||||||||||||||||
|
|
||||||||||||||||||
| public class ServerCallContext { | ||||||||||||||||||
| // TODO port the fields | ||||||||||||||||||
| // TODO Not totally sure yet about these field types | ||||||||||||||||||
| private final Map<Object, Object> modelConfig = new ConcurrentHashMap<>(); | ||||||||||||||||||
| private final Map<String, Object> state; | ||||||||||||||||||
| private final User user; | ||||||||||||||||||
|
|
||||||||||||||||||
| public ServerCallContext(User user, Map<String, Object> state) { | ||||||||||||||||||
| this.user = user; | ||||||||||||||||||
| this.state = state; | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+14
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure at this point whether the intent for this state map is to be mutable or not. |
||||||||||||||||||
|
|
||||||||||||||||||
| public Map<String, Object> getState() { | ||||||||||||||||||
| return state; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| public User getUser() { | ||||||||||||||||||
| return user; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,13 +22,21 @@ public class RequestContext { | |
| private String contextId; | ||
| private Task task; | ||
| private List<Task> relatedTasks; | ||
|
|
||
| public RequestContext(MessageSendParams params, String taskId, String contextId, Task task, List<Task> relatedTasks) throws InvalidParamsError { | ||
| private final ServerCallContext callContext; | ||
|
|
||
| public RequestContext( | ||
| MessageSendParams params, | ||
| String taskId, | ||
| String contextId, | ||
| Task task, | ||
| List<Task> relatedTasks, | ||
| ServerCallContext callContext) throws InvalidParamsError { | ||
| this.params = params; | ||
| this.taskId = taskId; | ||
| this.contextId = contextId; | ||
| this.task = task; | ||
| this.relatedTasks = relatedTasks == null ? new ArrayList<>() : relatedTasks; | ||
| this.callContext = callContext; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // if the taskId and contextId were specified, they must match the params | ||
| if (params != null) { | ||
|
|
@@ -73,6 +81,10 @@ public MessageSendConfiguration getConfiguration() { | |
| return params != null ? params.configuration() : null; | ||
| } | ||
|
|
||
| public ServerCallContext getCallContext() { | ||
| return callContext; | ||
| } | ||
|
|
||
| public String getUserInput(String delimiter) { | ||
| if (params == null) { | ||
| return ""; | ||
|
|
@@ -187,7 +199,7 @@ public ServerCallContext getServerCallContext() { | |
| } | ||
|
|
||
| public RequestContext build() { | ||
| return new RequestContext(params, taskId, contextId, task, relatedTasks); | ||
| return new RequestContext(params, taskId, contextId, task, relatedTasks, serverCallContext); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a
TODOcomment here about mappingrequest.authfrom the Python implementation. It's important to investigate what this maps to in Vert.x to ensure the authentication information is correctly propagated. Neglecting this could lead to security issues or incorrect user context.