Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/cli/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func newTaskCmd(cfg *globalConfig) *cobra.Command {
newTaskListCmd(cfg),
newTaskCancelCmd(cfg),
newTaskSubscribeCmd(cfg),
newTaskPushConfigCmd(cfg),
)
return cmd
}
34 changes: 34 additions & 0 deletions internal/cli/task_push_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2026 The A2A Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cli

import (
"github.com/spf13/cobra"
)

func newTaskPushConfigCmd(cfg *globalConfig) *cobra.Command {
cmd := &cobra.Command{
Use: "push-config",
Aliases: []string{"push"},
Short: "Manage task push-notification configurations",
}
cmd.AddCommand(
newPushConfigCreateCmd(cfg),
newPushConfigGetCmd(cfg),
newPushConfigListCmd(cfg),
newPushConfigDeleteCmd(cfg),
)
return cmd
}
99 changes: 99 additions & 0 deletions internal/cli/task_push_config_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright 2026 The A2A Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cli

import (
"context"
"fmt"

"github.com/spf13/cobra"

"github.com/a2aproject/a2a-go/v2/a2a"
)

type pushConfigCreateFlags struct {
taskID string
tenant string
url string
id string
token string
authScheme string
authCredentials string
}

func newPushConfigCreateCmd(cfg *globalConfig) *cobra.Command {
var f pushConfigCreateFlags

cmd := &cobra.Command{
Use: "create <task-id>",
Short: "Create a push-notification configuration for a task",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
f.taskID = args[0]
f.tenant = cfg.tenant
pc, err := buildPushConfig(f)
if err != nil {
return err
}

ctx, cancel := context.WithTimeout(cmd.Context(), cfg.timeout)
defer cancel()
ctx = withServiceParams(ctx, cfg)

client, err := newAgentClient(ctx, cfg)
if err != nil {
return fmt.Errorf("failed to create a client: %w", err)
}
defer destroyClient(cfg, client)

result, err := client.CreateTaskPushConfig(ctx, pc)
if err != nil {
return fmt.Errorf("failed to create push config: %w", err)
}
if err := cfg.PrintPushConfig(result); err != nil {
return fmt.Errorf("failed to print push config: %w", err)
}
return nil
},
}

fl := cmd.Flags()
fl.StringVar(&f.url, "url", "", "Webhook callback URL the agent posts updates to (required)")
fl.StringVar(&f.id, "id", "", "Optional client-set configuration ID (allows multiple callbacks)")
fl.StringVar(&f.token, "token", "", "Optional token the agent echoes back so the receiver can validate calls")
fl.StringVar(&f.authScheme, "auth-scheme", "", "Optional auth scheme the agent uses when calling the webhook (e.g. Bearer)")
fl.StringVar(&f.authCredentials, "auth-credentials", "", "Optional credentials the agent presents to the webhook")
return cmd
}

func buildPushConfig(f pushConfigCreateFlags) (*a2a.PushConfig, error) {
if f.url == "" {
return nil, fmt.Errorf("--url is required")
}
pc := &a2a.PushConfig{
Tenant: f.tenant,
TaskID: a2a.TaskID(f.taskID),
ID: f.id,
Token: f.token,
URL: f.url,
}
if f.authScheme != "" || f.authCredentials != "" {
if f.authScheme == "" {
return nil, fmt.Errorf("--auth-scheme is required when --auth-credentials is set")
}
pc.Auth = &a2a.PushAuthInfo{Scheme: f.authScheme, Credentials: f.authCredentials}
}
return pc, nil
}
52 changes: 52 additions & 0 deletions internal/cli/task_push_config_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2026 The A2A Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cli

import (
"context"
"fmt"

"github.com/spf13/cobra"

"github.com/a2aproject/a2a-go/v2/a2a"
)

func newPushConfigDeleteCmd(cfg *globalConfig) *cobra.Command {
return &cobra.Command{
Use: "delete <task-id> <config-id>",
Short: "Delete a task's push-notification configuration",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(cmd.Context(), cfg.timeout)
defer cancel()
ctx = withServiceParams(ctx, cfg)

client, err := newAgentClient(ctx, cfg)
if err != nil {
return fmt.Errorf("failed to create a client: %w", err)
}
defer destroyClient(cfg, client)

if err := client.DeleteTaskPushConfig(ctx, &a2a.DeleteTaskPushConfigRequest{
Tenant: cfg.tenant,
TaskID: a2a.TaskID(args[0]),
ID: args[1],
}); err != nil {
return fmt.Errorf("failed to delete push config %s: %w", args[1], err)
}
return cfg.PrintPushConfigDeleted(args[0], args[1])
},
}
}
56 changes: 56 additions & 0 deletions internal/cli/task_push_config_get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2026 The A2A Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cli

import (
"context"
"fmt"

"github.com/spf13/cobra"

"github.com/a2aproject/a2a-go/v2/a2a"
)

func newPushConfigGetCmd(cfg *globalConfig) *cobra.Command {
return &cobra.Command{
Use: "get <task-id> <config-id>",
Short: "Get a task's push-notification configuration",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(cmd.Context(), cfg.timeout)
defer cancel()
ctx = withServiceParams(ctx, cfg)

client, err := newAgentClient(ctx, cfg)
if err != nil {
return fmt.Errorf("failed to create a client: %w", err)
}
defer destroyClient(cfg, client)

result, err := client.GetTaskPushConfig(ctx, &a2a.GetTaskPushConfigRequest{
Tenant: cfg.tenant,
TaskID: a2a.TaskID(args[0]),
ID: args[1],
})
if err != nil {
return fmt.Errorf("failed to get push config %s: %w", args[1], err)
}
if err := cfg.PrintPushConfig(result); err != nil {
return fmt.Errorf("failed to print push config: %w", err)
}
return nil
},
}
}
67 changes: 67 additions & 0 deletions internal/cli/task_push_config_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2026 The A2A Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cli

import (
"context"
"fmt"

"github.com/spf13/cobra"

"github.com/a2aproject/a2a-go/v2/a2a"
)

func newPushConfigListCmd(cfg *globalConfig) *cobra.Command {
var (
limit int
pageToken string
)

cmd := &cobra.Command{
Use: "list <task-id>",
Short: "List a task's push-notification configurations",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(cmd.Context(), cfg.timeout)
defer cancel()
ctx = withServiceParams(ctx, cfg)

client, err := newAgentClient(ctx, cfg)
if err != nil {
return fmt.Errorf("failed to create a client: %w", err)
}
defer destroyClient(cfg, client)

configs, err := client.ListTaskPushConfigs(ctx, &a2a.ListTaskPushConfigRequest{
Tenant: cfg.tenant,
TaskID: a2a.TaskID(args[0]),
PageSize: limit,
PageToken: pageToken,
})
if err != nil {
return fmt.Errorf("failed to list push configs: %w", err)
}
if err := cfg.PrintPushConfigList(configs); err != nil {
return fmt.Errorf("failed to print push configs: %w", err)
}
return nil
},
}

f := cmd.Flags()
f.IntVar(&limit, "limit", 0, "Page size")
f.StringVar(&pageToken, "page-token", "", "Pagination token")
return cmd
}
Loading