agent2agent 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/a2a/agent.rb +98 -241
- data/lib/a2a/{faraday → client}/middleware/json_rpc/request.rb +10 -8
- data/lib/a2a/{faraday → client}/middleware/json_rpc/response.rb +10 -9
- data/lib/a2a/{faraday → client}/middleware/rest/request.rb +30 -20
- data/lib/a2a/{faraday → client}/middleware/rest/response.rb +12 -8
- data/lib/a2a/{faraday → client}/middleware/schema_request.rb +9 -8
- data/lib/a2a/client.rb +40 -40
- data/lib/a2a/errors/json_rpc_error.rb +1 -2
- data/lib/a2a/errors/rest_error.rb +1 -2
- data/lib/a2a/errors.rb +1 -2
- data/lib/a2a/protocol/json_schema/definition.rb +276 -0
- data/lib/a2a/protocol/json_schema/validation_error.rb +132 -0
- data/lib/a2a/{schema.rb → protocol/json_schema.rb} +211 -208
- data/lib/a2a/protocol/protobuf.rb +447 -0
- data/lib/a2a/protocol.rb +31 -0
- data/lib/a2a/server/bindings/grpc.rb +37 -0
- data/lib/a2a/server/bindings/json_rpc.rb +29 -9
- data/lib/a2a/server/bindings/rest.rb +26 -13
- data/lib/a2a/server/middleware/extract_message.rb +145 -0
- data/lib/a2a/{middleware → server/middleware}/fetch_task.rb +82 -89
- data/lib/a2a/{middleware → server/middleware}/limit_history_length.rb +40 -49
- data/lib/a2a/{middleware → server/middleware}/limit_pagination_size.rb +36 -42
- data/lib/a2a/server/middleware/sse_stream.rb +236 -0
- data/lib/a2a/{sse → server/sse}/event_parser.rb +70 -69
- data/lib/a2a/server/sse/json_rpc_stream.rb +89 -0
- data/lib/a2a/server/sse/rest_stream.rb +63 -0
- data/lib/a2a/server/sse/stream.rb +261 -0
- data/lib/a2a/server/triage.rb +35 -4
- data/lib/a2a/server/well_known.rb +27 -0
- data/lib/a2a/server.rb +44 -58
- data/lib/a2a/test_helpers.rb +34 -75
- data/lib/a2a/version.rb +1 -1
- data/lib/a2a.rb +7 -11
- data/lib/traces/provider/a2a/agent.rb +25 -0
- data/lib/traces/provider/a2a.rb +1 -1
- metadata +39 -37
- data/lib/a2a/middleware/extract_message.rb +0 -120
- data/lib/a2a/middleware/sse_stream.rb +0 -235
- data/lib/a2a/proto.rb +0 -444
- data/lib/a2a/schema/definition.rb +0 -148
- data/lib/a2a/schema/validation_error.rb +0 -129
- data/lib/a2a/server/dispatcher.rb +0 -127
- data/lib/a2a/sse/json_rpc_stream.rb +0 -88
- data/lib/a2a/sse/rest_stream.rb +0 -62
- data/lib/a2a/sse/stream.rb +0 -257
- data/lib/traces/provider/a2a/server/dispatcher.rb +0 -26
- /data/lib/a2a/{middleware.rb → server/middleware.rb} +0 -0
- /data/lib/a2a/{sse.rb → server/sse.rb} +0 -0
|
@@ -6,7 +6,7 @@ require "faraday"
|
|
|
6
6
|
require "json"
|
|
7
7
|
|
|
8
8
|
module A2A
|
|
9
|
-
|
|
9
|
+
class Client
|
|
10
10
|
module Middleware
|
|
11
11
|
module REST
|
|
12
12
|
# Faraday response middleware for the A2A HTTP+JSON/REST binding.
|
|
@@ -32,6 +32,9 @@ module A2A
|
|
|
32
32
|
message = parsed.to_s
|
|
33
33
|
data = nil
|
|
34
34
|
end
|
|
35
|
+
# Streaming requests consume the body via on_data, leaving
|
|
36
|
+
# nothing here — fall back to the HTTP status.
|
|
37
|
+
message = "HTTP #{env.status}" if message.to_s.empty?
|
|
35
38
|
raise A2A::RestError.new(message, http_status: env.status, data: data)
|
|
36
39
|
end
|
|
37
40
|
|
|
@@ -59,11 +62,12 @@ module A2A
|
|
|
59
62
|
end
|
|
60
63
|
end
|
|
61
64
|
|
|
62
|
-
::Faraday::Response.register_middleware(a2a_rest: A2A::
|
|
65
|
+
::Faraday::Response.register_middleware(a2a_rest: A2A::Client::Middleware::REST::Response)
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
__END__
|
|
68
|
+
describe "A2A::Client::Middleware::REST::Response" do
|
|
69
|
+
middleware = A2A::Client::Middleware::REST::Response
|
|
70
|
+
operation = A2A::Protocol::Protobuf.operation("GetTask")
|
|
67
71
|
|
|
68
72
|
it "wraps response body in Schema object directly (no envelope)" do
|
|
69
73
|
env = ::Faraday::Env.new
|
|
@@ -77,13 +81,13 @@ test do
|
|
|
77
81
|
|
|
78
82
|
middleware.new(nil).on_complete(env)
|
|
79
83
|
|
|
80
|
-
env.body.should.be.kind_of(A2A::
|
|
84
|
+
env.body.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
81
85
|
env.body.id.should == "task-123"
|
|
82
86
|
env.body.context_id.should == "ctx-456"
|
|
83
87
|
end
|
|
84
88
|
|
|
85
89
|
it "returns raw hash when response_schema is nil" do
|
|
86
|
-
op = A2A::
|
|
90
|
+
op = A2A::Protocol::Protobuf.operation("DeleteTaskPushNotificationConfig")
|
|
87
91
|
env = ::Faraday::Env.new
|
|
88
92
|
env.status = 200
|
|
89
93
|
env.body = {}
|
|
@@ -138,7 +142,7 @@ test do
|
|
|
138
142
|
|
|
139
143
|
middleware.new(nil).on_complete(env)
|
|
140
144
|
|
|
141
|
-
env.body.should.be.kind_of(A2A::
|
|
145
|
+
env.body.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
142
146
|
env.body.id.should == "task-1"
|
|
143
147
|
end
|
|
144
148
|
end
|
|
@@ -6,9 +6,9 @@ require "faraday"
|
|
|
6
6
|
require "json"
|
|
7
7
|
|
|
8
8
|
module A2A
|
|
9
|
-
|
|
9
|
+
class Client
|
|
10
10
|
module Middleware
|
|
11
|
-
# Faraday request middleware that converts A2A::
|
|
11
|
+
# Faraday request middleware that converts A2A::Protocol::JsonSchema::Definition
|
|
12
12
|
# objects into their hash representation for JSON serialization.
|
|
13
13
|
#
|
|
14
14
|
# Place this before the :json request middleware in the stack so
|
|
@@ -18,7 +18,7 @@ module A2A
|
|
|
18
18
|
class SchemaRequest < ::Faraday::Middleware
|
|
19
19
|
def on_request(env)
|
|
20
20
|
body = env.body
|
|
21
|
-
return unless body.is_a?(A2A::
|
|
21
|
+
return unless body.is_a?(A2A::Protocol::JsonSchema::Definition)
|
|
22
22
|
|
|
23
23
|
env.body = body.to_h
|
|
24
24
|
env.request_headers["content-type"] ||= "application/json"
|
|
@@ -28,13 +28,14 @@ module A2A
|
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
::Faraday::Request.register_middleware(a2a_schema: A2A::
|
|
31
|
+
::Faraday::Request.register_middleware(a2a_schema: A2A::Client::Middleware::SchemaRequest)
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
__END__
|
|
34
|
+
describe "A2A::Client::Middleware::SchemaRequest" do
|
|
35
|
+
middleware = A2A::Client::Middleware::SchemaRequest
|
|
35
36
|
|
|
36
37
|
it "converts Schema::Definition to hash" do
|
|
37
|
-
schema_obj = A2A::
|
|
38
|
+
schema_obj = A2A::Protocol::JsonSchema["Agent Capabilities"].new(streaming: true)
|
|
38
39
|
env = ::Faraday::Env.new
|
|
39
40
|
env.body = schema_obj
|
|
40
41
|
env.request_headers = {}
|
|
@@ -57,7 +58,7 @@ test do
|
|
|
57
58
|
end
|
|
58
59
|
|
|
59
60
|
it "does not overwrite existing content-type" do
|
|
60
|
-
schema_obj = A2A::
|
|
61
|
+
schema_obj = A2A::Protocol::JsonSchema["Agent Capabilities"].new(streaming: true)
|
|
61
62
|
env = ::Faraday::Env.new
|
|
62
63
|
env.body = schema_obj
|
|
63
64
|
env.request_headers = { "content-type" => "application/a2a+json" }
|
data/lib/a2a/client.rb
CHANGED
|
@@ -31,15 +31,15 @@ module A2A
|
|
|
31
31
|
|
|
32
32
|
# GET /.well-known/agent-card.json
|
|
33
33
|
#
|
|
34
|
-
# Returns an A2A::
|
|
34
|
+
# Returns an A2A::Protocol::JsonSchema["Agent Card"] instance.
|
|
35
35
|
def agent_card
|
|
36
|
-
response = @conn.get("
|
|
36
|
+
response = @conn.get(".well-known/agent-card.json")
|
|
37
37
|
parsed = response.body
|
|
38
|
-
A2A::
|
|
38
|
+
A2A::Protocol::JsonSchema["Agent Card"].new(parsed)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# Operations — each maps to a Proto operation name.
|
|
42
|
-
|
|
42
|
+
Protocol::Protobuf.operations.each do |op|
|
|
43
43
|
method_name = op.name.gsub(/([A-Z])/) { "_#{$1.downcase}" }.sub(/^_/, "")
|
|
44
44
|
|
|
45
45
|
if op.server_streaming?
|
|
@@ -84,7 +84,6 @@ module A2A
|
|
|
84
84
|
::Faraday.new(url: @url) do |f|
|
|
85
85
|
f.request :a2a_schema
|
|
86
86
|
f.request :a2a_rest
|
|
87
|
-
f.request :json
|
|
88
87
|
|
|
89
88
|
f.response :a2a_rest
|
|
90
89
|
f.response :json
|
|
@@ -99,7 +98,7 @@ module A2A
|
|
|
99
98
|
request = operation.request_schema.new(params)
|
|
100
99
|
request.valid!
|
|
101
100
|
|
|
102
|
-
response = @conn.post
|
|
101
|
+
response = @conn.post do |req|
|
|
103
102
|
req.options.context = { a2a_operation: operation }
|
|
104
103
|
req.body = request
|
|
105
104
|
end
|
|
@@ -111,9 +110,9 @@ module A2A
|
|
|
111
110
|
request = operation.request_schema.new(params)
|
|
112
111
|
request.valid!
|
|
113
112
|
|
|
114
|
-
parser = A2A::SSE::EventParser.new(binding: @binding)
|
|
113
|
+
parser = A2A::Server::SSE::EventParser.new(binding: @binding)
|
|
115
114
|
|
|
116
|
-
@conn.post
|
|
115
|
+
@conn.post do |req|
|
|
117
116
|
req.options.context = { a2a_operation: operation }
|
|
118
117
|
req.body = request
|
|
119
118
|
req.headers["Accept"] = "text/event-stream"
|
|
@@ -128,13 +127,14 @@ module A2A
|
|
|
128
127
|
end
|
|
129
128
|
end
|
|
130
129
|
|
|
131
|
-
|
|
130
|
+
__END__
|
|
131
|
+
describe "A2A::Client" do
|
|
132
132
|
# --- JSON-RPC binding (default) ---
|
|
133
133
|
|
|
134
134
|
it "generates methods for all Proto operations" do
|
|
135
135
|
client = A2A::Client.new("http://localhost:9292") do |f|
|
|
136
136
|
f.adapter :test do |stub|
|
|
137
|
-
stub.post("/
|
|
137
|
+
stub.post("/") { |env|
|
|
138
138
|
[200, { "content-type" => "application/json" }, JSON.generate({ "jsonrpc" => "2.0", "id" => 1, "result" => {} })]
|
|
139
139
|
}
|
|
140
140
|
end
|
|
@@ -173,7 +173,7 @@ test do
|
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
card = client.agent_card
|
|
176
|
-
card.should.be.kind_of(A2A::
|
|
176
|
+
card.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
177
177
|
card.name.should == "Test Agent"
|
|
178
178
|
card.version.should == "1.0.0"
|
|
179
179
|
end
|
|
@@ -181,7 +181,7 @@ test do
|
|
|
181
181
|
it "json_rpc: send_message validates, wraps in JSON-RPC, returns Schema" do
|
|
182
182
|
client = A2A::Client.new("http://localhost:9292") do |f|
|
|
183
183
|
f.adapter :test do |stub|
|
|
184
|
-
stub.post("/
|
|
184
|
+
stub.post("/") { |env|
|
|
185
185
|
parsed = JSON.parse(env.body)
|
|
186
186
|
parsed["method"].should == "SendMessage"
|
|
187
187
|
parsed["params"]["message"]["role"].should == "ROLE_USER"
|
|
@@ -211,13 +211,13 @@ test do
|
|
|
211
211
|
parts: [{ text: "Hello" }]
|
|
212
212
|
}
|
|
213
213
|
)
|
|
214
|
-
result.should.be.kind_of(A2A::
|
|
214
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
215
215
|
end
|
|
216
216
|
|
|
217
217
|
it "json_rpc: get_task returns a Task" do
|
|
218
218
|
client = A2A::Client.new("http://localhost:9292") do |f|
|
|
219
219
|
f.adapter :test do |stub|
|
|
220
|
-
stub.post("/
|
|
220
|
+
stub.post("/") { |env|
|
|
221
221
|
parsed = JSON.parse(env.body)
|
|
222
222
|
parsed["method"].should == "GetTask"
|
|
223
223
|
parsed["params"]["id"].should == "task-123"
|
|
@@ -237,7 +237,7 @@ test do
|
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
result = client.get_task(id: "task-123")
|
|
240
|
-
result.should.be.kind_of(A2A::
|
|
240
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
241
241
|
result.id.should == "task-123"
|
|
242
242
|
result.context_id.should == "ctx-456"
|
|
243
243
|
end
|
|
@@ -245,7 +245,7 @@ test do
|
|
|
245
245
|
it "json_rpc: raises on JSON-RPC error" do
|
|
246
246
|
client = A2A::Client.new("http://localhost:9292") do |f|
|
|
247
247
|
f.adapter :test do |stub|
|
|
248
|
-
stub.post("/
|
|
248
|
+
stub.post("/") { |env|
|
|
249
249
|
[200, { "content-type" => "application/json" }, JSON.generate({
|
|
250
250
|
"jsonrpc" => "2.0",
|
|
251
251
|
"id" => 1,
|
|
@@ -264,18 +264,18 @@ test do
|
|
|
264
264
|
it "json_rpc: raises ValidationError on invalid params" do
|
|
265
265
|
client = A2A::Client.new("http://localhost:9292") do |f|
|
|
266
266
|
f.adapter :test do |stub|
|
|
267
|
-
stub.post("/
|
|
267
|
+
stub.post("/") { |env| [200, { "content-type" => "application/json" }, "{}"] }
|
|
268
268
|
end
|
|
269
269
|
end
|
|
270
270
|
|
|
271
|
-
lambda { client.send_message(message: "not_a_hash") }.should.raise(A2A::
|
|
271
|
+
lambda { client.send_message(message: "not_a_hash") }.should.raise(A2A::Protocol::JsonSchema::ValidationError)
|
|
272
272
|
end
|
|
273
273
|
|
|
274
274
|
it "json_rpc: send_streaming_message sends correct method and Accept header" do
|
|
275
275
|
captured_env = nil
|
|
276
276
|
client = A2A::Client.new("http://localhost:9292") do |f|
|
|
277
277
|
f.adapter :test do |stub|
|
|
278
|
-
stub.post("/
|
|
278
|
+
stub.post("/") { |env|
|
|
279
279
|
captured_env = env
|
|
280
280
|
[200, { "content-type" => "text/event-stream" }, ""]
|
|
281
281
|
}
|
|
@@ -302,7 +302,7 @@ test do
|
|
|
302
302
|
captured_env = nil
|
|
303
303
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
304
304
|
f.adapter :test do |stub|
|
|
305
|
-
stub.post("/message:send") { |env|
|
|
305
|
+
stub.post("/rest/message:send") { |env|
|
|
306
306
|
captured_env = env
|
|
307
307
|
[200, { "content-type" => "application/a2a+json" }, JSON.generate({
|
|
308
308
|
"task" => {
|
|
@@ -324,14 +324,14 @@ test do
|
|
|
324
324
|
parts: [{ text: "Hello" }]
|
|
325
325
|
}
|
|
326
326
|
)
|
|
327
|
-
result.should.be.kind_of(A2A::
|
|
327
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
328
328
|
captured_env.request_headers["content-type"].should == "application/a2a+json"
|
|
329
329
|
end
|
|
330
330
|
|
|
331
331
|
it "rest: get_task uses GET /tasks/{id}" do
|
|
332
332
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
333
333
|
f.adapter :test do |stub|
|
|
334
|
-
stub.get("/tasks/task-123") { |env|
|
|
334
|
+
stub.get("/rest/tasks/task-123") { |env|
|
|
335
335
|
[200, { "content-type" => "application/a2a+json" }, JSON.generate({
|
|
336
336
|
"id" => "task-123",
|
|
337
337
|
"contextId" => "ctx-456",
|
|
@@ -344,14 +344,14 @@ test do
|
|
|
344
344
|
end
|
|
345
345
|
|
|
346
346
|
result = client.get_task(id: "task-123")
|
|
347
|
-
result.should.be.kind_of(A2A::
|
|
347
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
348
348
|
result.id.should == "task-123"
|
|
349
349
|
end
|
|
350
350
|
|
|
351
351
|
it "rest: list_tasks uses GET /tasks" do
|
|
352
352
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
353
353
|
f.adapter :test do |stub|
|
|
354
|
-
stub.get("/tasks") { |env|
|
|
354
|
+
stub.get("/rest/tasks") { |env|
|
|
355
355
|
[200, { "content-type" => "application/a2a+json" }, JSON.generate({
|
|
356
356
|
"tasks" => [
|
|
357
357
|
{ "id" => "t-1", "contextId" => "c-1", "status" => { "state" => "TASK_STATE_COMPLETED" } }
|
|
@@ -362,13 +362,13 @@ test do
|
|
|
362
362
|
end
|
|
363
363
|
|
|
364
364
|
result = client.list_tasks
|
|
365
|
-
result.should.be.kind_of(A2A::
|
|
365
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
366
366
|
end
|
|
367
367
|
|
|
368
368
|
it "rest: cancel_task uses POST /tasks/{id}:cancel" do
|
|
369
369
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
370
370
|
f.adapter :test do |stub|
|
|
371
|
-
stub.post("/tasks/task-123:cancel") { |env|
|
|
371
|
+
stub.post("/rest/tasks/task-123:cancel") { |env|
|
|
372
372
|
[200, { "content-type" => "application/a2a+json" }, JSON.generate({
|
|
373
373
|
"id" => "task-123", "contextId" => "ctx-456",
|
|
374
374
|
"status" => { "state" => "TASK_STATE_CANCELED" }
|
|
@@ -378,14 +378,14 @@ test do
|
|
|
378
378
|
end
|
|
379
379
|
|
|
380
380
|
result = client.cancel_task(id: "task-123")
|
|
381
|
-
result.should.be.kind_of(A2A::
|
|
381
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
382
382
|
result.id.should == "task-123"
|
|
383
383
|
end
|
|
384
384
|
|
|
385
385
|
it "rest: create_task_push_notification_config uses POST /tasks/{task_id}/pushNotificationConfigs" do
|
|
386
386
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
387
387
|
f.adapter :test do |stub|
|
|
388
|
-
stub.post("/tasks/task-123/pushNotificationConfigs") { |env|
|
|
388
|
+
stub.post("/rest/tasks/task-123/pushNotificationConfigs") { |env|
|
|
389
389
|
[200, { "content-type" => "application/a2a+json" }, JSON.generate({
|
|
390
390
|
"id" => "config-1", "taskId" => "task-123",
|
|
391
391
|
"url" => "https://example.com/webhook"
|
|
@@ -397,13 +397,13 @@ test do
|
|
|
397
397
|
result = client.create_task_push_notification_config(
|
|
398
398
|
task_id: "task-123", url: "https://example.com/webhook"
|
|
399
399
|
)
|
|
400
|
-
result.should.be.kind_of(A2A::
|
|
400
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
401
401
|
end
|
|
402
402
|
|
|
403
403
|
it "rest: get_task_push_notification_config uses GET /tasks/{task_id}/pushNotificationConfigs/{id}" do
|
|
404
404
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
405
405
|
f.adapter :test do |stub|
|
|
406
|
-
stub.get("/tasks/task-123/pushNotificationConfigs/config-1") { |env|
|
|
406
|
+
stub.get("/rest/tasks/task-123/pushNotificationConfigs/config-1") { |env|
|
|
407
407
|
[200, { "content-type" => "application/a2a+json" }, JSON.generate({
|
|
408
408
|
"id" => "config-1", "taskId" => "task-123",
|
|
409
409
|
"url" => "https://example.com/webhook"
|
|
@@ -413,13 +413,13 @@ test do
|
|
|
413
413
|
end
|
|
414
414
|
|
|
415
415
|
result = client.get_task_push_notification_config(id: "config-1", task_id: "task-123")
|
|
416
|
-
result.should.be.kind_of(A2A::
|
|
416
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
417
417
|
end
|
|
418
418
|
|
|
419
419
|
it "rest: list_task_push_notification_configs uses GET /tasks/{task_id}/pushNotificationConfigs" do
|
|
420
420
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
421
421
|
f.adapter :test do |stub|
|
|
422
|
-
stub.get("/tasks/task-123/pushNotificationConfigs") { |env|
|
|
422
|
+
stub.get("/rest/tasks/task-123/pushNotificationConfigs") { |env|
|
|
423
423
|
[200, { "content-type" => "application/a2a+json" }, JSON.generate({
|
|
424
424
|
"pushNotificationConfigs" => []
|
|
425
425
|
})]
|
|
@@ -428,13 +428,13 @@ test do
|
|
|
428
428
|
end
|
|
429
429
|
|
|
430
430
|
result = client.list_task_push_notification_configs(task_id: "task-123")
|
|
431
|
-
result.should.be.kind_of(A2A::
|
|
431
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
432
432
|
end
|
|
433
433
|
|
|
434
434
|
it "rest: delete_task_push_notification_config uses DELETE /tasks/{task_id}/pushNotificationConfigs/{id}" do
|
|
435
435
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
436
436
|
f.adapter :test do |stub|
|
|
437
|
-
stub.delete("/tasks/task-123/pushNotificationConfigs/config-1") { |env|
|
|
437
|
+
stub.delete("/rest/tasks/task-123/pushNotificationConfigs/config-1") { |env|
|
|
438
438
|
[200, { "content-type" => "application/a2a+json" }, JSON.generate({})]
|
|
439
439
|
}
|
|
440
440
|
end
|
|
@@ -447,7 +447,7 @@ test do
|
|
|
447
447
|
it "rest: get_extended_agent_card uses GET /extendedAgentCard" do
|
|
448
448
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
449
449
|
f.adapter :test do |stub|
|
|
450
|
-
stub.get("/extendedAgentCard") { |env|
|
|
450
|
+
stub.get("/rest/extendedAgentCard") { |env|
|
|
451
451
|
[200, { "content-type" => "application/a2a+json" }, JSON.generate({
|
|
452
452
|
"name" => "Extended Agent",
|
|
453
453
|
"version" => "2.0.0",
|
|
@@ -461,7 +461,7 @@ test do
|
|
|
461
461
|
end
|
|
462
462
|
|
|
463
463
|
result = client.get_extended_agent_card
|
|
464
|
-
result.should.be.kind_of(A2A::
|
|
464
|
+
result.should.be.kind_of(A2A::Protocol::JsonSchema::Definition)
|
|
465
465
|
result.name.should == "Extended Agent"
|
|
466
466
|
end
|
|
467
467
|
|
|
@@ -469,7 +469,7 @@ test do
|
|
|
469
469
|
captured_env = nil
|
|
470
470
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
471
471
|
f.adapter :test do |stub|
|
|
472
|
-
stub.get("/tasks/task-1:subscribe") { |env|
|
|
472
|
+
stub.get("/rest/tasks/task-1:subscribe") { |env|
|
|
473
473
|
captured_env = env
|
|
474
474
|
[200, { "content-type" => "text/event-stream" }, ""]
|
|
475
475
|
}
|
|
@@ -485,7 +485,7 @@ test do
|
|
|
485
485
|
it "rest: raises on HTTP 400 error" do
|
|
486
486
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
487
487
|
f.adapter :test do |stub|
|
|
488
|
-
stub.get("/tasks/bad-id") { |env|
|
|
488
|
+
stub.get("/rest/tasks/bad-id") { |env|
|
|
489
489
|
[400, { "content-type" => "application/problem+json" }, JSON.generate({
|
|
490
490
|
"type" => "error",
|
|
491
491
|
"title" => "Bad Request","status" => 400
|
|
@@ -500,10 +500,10 @@ test do
|
|
|
500
500
|
it "rest: raises ValidationError on invalid params" do
|
|
501
501
|
client = A2A::Client.new("http://localhost:9292", binding: :rest) do |f|
|
|
502
502
|
f.adapter :test do |stub|
|
|
503
|
-
stub.post("/message:send") { |env| [200, { "content-type" => "application/a2a+json" }, "{}"] }
|
|
503
|
+
stub.post("/rest/message:send") { |env| [200, { "content-type" => "application/a2a+json" }, "{}"] }
|
|
504
504
|
end
|
|
505
505
|
end
|
|
506
506
|
|
|
507
|
-
lambda { client.send_message(message: "not_a_hash") }.should.raise(A2A::
|
|
507
|
+
lambda { client.send_message(message: "not_a_hash") }.should.raise(A2A::Protocol::JsonSchema::ValidationError)
|
|
508
508
|
end
|
|
509
509
|
end
|
|
@@ -23,7 +23,7 @@ module A2A
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
__END__
|
|
27
27
|
describe "A2A::JsonRpcError" do
|
|
28
28
|
it "has correct code and message" do
|
|
29
29
|
err = A2A::JsonRpcError.new("Task not found", code: -32001)
|
|
@@ -68,4 +68,3 @@ test do
|
|
|
68
68
|
h[:data].should == data
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
|
-
end
|
|
@@ -20,7 +20,7 @@ module A2A
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
__END__
|
|
24
24
|
describe "A2A::RestError" do
|
|
25
25
|
it "has correct http_status and message" do
|
|
26
26
|
err = A2A::RestError.new("Not Found", http_status: 404)
|
|
@@ -65,4 +65,3 @@ test do
|
|
|
65
65
|
h[:data].should == data
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
|
-
end
|
data/lib/a2a/errors.rb
CHANGED
|
@@ -337,7 +337,7 @@ require "a2a/errors/rest_error"
|
|
|
337
337
|
# | ExtendedAgentCardNotConfiguredError | The agent lacks a configured extended agent card when required.
|
|
338
338
|
# | ExtensionSupportRequiredError | A required extension was not declared as supported by the client.
|
|
339
339
|
# | VersionNotSupportedError | The requested A2A-Version is not supported by the agent.
|
|
340
|
-
|
|
340
|
+
__END__
|
|
341
341
|
describe "A2A::Error" do
|
|
342
342
|
it "has code, http_status, and message" do
|
|
343
343
|
err = A2A::Error.new("boom", code: -32000, http_status: 500)
|
|
@@ -532,4 +532,3 @@ test do
|
|
|
532
532
|
err.is_a?(A2A::Error).should == true
|
|
533
533
|
end
|
|
534
534
|
end
|
|
535
|
-
end
|