Adds full QueryServer/MsgServer gRPC services, task lifecycle handlers (accept, checkpoint, complete, delegate), intent protocol, negotiation system, IBC agent discovery, rate limiting, reputation adapter, and comprehensive test coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
884 B
Go
36 lines
884 B
Go
package keeper
|
|
|
|
import (
|
|
"context"
|
|
|
|
"clawchain/x/agent/types"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
func (q queryServer) RecentActivity(ctx context.Context, req *types.QueryRecentActivityRequest) (*types.QueryRecentActivityResponse, error) {
|
|
if req == nil {
|
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
|
}
|
|
|
|
limit := req.Limit
|
|
if limit == 0 {
|
|
limit = defaultActivityLimit
|
|
}
|
|
|
|
all := make([]types.AgentActionRecord, 0)
|
|
err := q.k.AgentActions.Walk(ctx, nil, func(_ uint64, value types.AgentActionRecord) (bool, error) {
|
|
all = append(all, value)
|
|
return false, nil
|
|
})
|
|
if err != nil {
|
|
return nil, status.Error(codes.Internal, "failed to iterate agent actions")
|
|
}
|
|
|
|
start := 0
|
|
if uint64(len(all)) > limit {
|
|
start = len(all) - int(limit)
|
|
}
|
|
return &types.QueryRecentActivityResponse{Activities: all[start:]}, nil
|
|
}
|