-
Notifications
You must be signed in to change notification settings - Fork 22
feat: artifacts #52
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
Open
yarolegovich
wants to merge
21
commits into
main
Choose a base branch
from
yarolegovich/artifacts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+391
−46
Open
feat: artifacts #52
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
90d93c6
make core types gob-serializable
yarolegovich a70892e
in-memory task store
yarolegovich 043ba2e
task update logic
yarolegovich 80d3853
concurrent task execution and cancelation management
yarolegovich 14da9f8
taskexec integration with default request handler
yarolegovich 0df268e
prevent possibility of failed cancelation destroying the queue which …
yarolegovich 67290a0
comments and t.Helper() calls
yarolegovich efd6922
Merge branch 'main' into yarolegovich/result-aggregation-3
yarolegovich ef1170a
lint
yarolegovich a1971d9
Merge branch 'main' into yarolegovich/result-aggregation-3
yarolegovich 601aeda
Merge branch 'yarolegovich/result-aggregation-4' into yarolegovich/re…
yarolegovich 789dfb2
artifact update logic
yarolegovich 9e28fb2
OnSendMessageStream() and tests
yarolegovich 2a84c8b
test and fix
yarolegovich 2fa71f4
PR review improvements
yarolegovich eeba7ff
Merge branch 'main' into yarolegovich/result-aggregation-4
yarolegovich c5c9812
fix blocking on nil channel and empty yield(nil, nil) in defer
yarolegovich c7251a7
lint
yarolegovich d7fdefe
Merge branch 'yarolegovich/result-aggregation-4' into yarolegovich/ar…
yarolegovich 8dbd52b
Merge branch 'main' into yarolegovich/artifacts
yarolegovich 12bb659
refactor messages
yarolegovich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ package taskupdate | |
import ( | ||
"context" | ||
"fmt" | ||
"slices" | ||
|
||
"github.com/a2aproject/a2a-go/a2a" | ||
) | ||
|
@@ -75,8 +76,47 @@ func (mgr *Manager) Process(ctx context.Context, event a2a.Event) (*a2a.Task, er | |
} | ||
} | ||
|
||
func (mgr *Manager) updateArtifact(_ context.Context, _ *a2a.TaskArtifactUpdateEvent) (*a2a.Task, error) { | ||
return nil, fmt.Errorf("not implemented") | ||
func (mgr *Manager) updateArtifact(ctx context.Context, event *a2a.TaskArtifactUpdateEvent) (*a2a.Task, error) { | ||
task := mgr.task | ||
|
||
updateIdx := slices.IndexFunc(task.Artifacts, func(a *a2a.Artifact) bool { | ||
return a.ID == event.Artifact.ID | ||
}) | ||
|
||
if updateIdx < 0 { | ||
if event.Append { | ||
// TODO(yarolegovich): log "artifact for update not found" as Python does | ||
return task, nil | ||
} | ||
task.Artifacts = append(task.Artifacts, event.Artifact) | ||
if err := mgr.saver.Save(ctx, task); err != nil { | ||
return nil, err | ||
} | ||
return task, nil | ||
} | ||
|
||
if !event.Append { | ||
task.Artifacts[updateIdx] = event.Artifact | ||
if err := mgr.saver.Save(ctx, task); err != nil { | ||
return nil, err | ||
} | ||
return task, nil | ||
} | ||
|
||
toUpdate := task.Artifacts[updateIdx] | ||
toUpdate.Parts = append(toUpdate.Parts, event.Artifact.Parts...) | ||
if toUpdate.Metadata == nil && event.Artifact.Metadata != nil { | ||
toUpdate.Metadata = event.Artifact.Metadata | ||
} else { | ||
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. missing handling of |
||
for k, v := range event.Artifact.Metadata { | ||
toUpdate.Metadata[k] = v | ||
} | ||
} | ||
|
||
if err := mgr.saver.Save(ctx, task); err != nil { | ||
return nil, err | ||
} | ||
return task, nil | ||
} | ||
|
||
func (mgr *Manager) updateStatus(ctx context.Context, event *a2a.TaskStatusUpdateEvent) (*a2a.Task, error) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
these assertions are refactored in another PR