a2a-rails 0.4.0 → 0.5.1
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/CHANGELOG.md +24 -2
- data/README.md +17 -8
- data/app/controllers/a2a/rails/requests_controller.rb +37 -6
- data/lib/a2a/rails/configuration.rb +8 -4
- data/lib/a2a/rails/dispatcher.rb +3 -0
- data/lib/a2a/rails/errors.rb +13 -0
- data/lib/a2a/rails/input_required.rb +50 -0
- data/lib/a2a/rails/protocol/agent2agent_adapter.rb +11 -0
- data/lib/a2a/rails/protocol/request_handler.rb +52 -22
- data/lib/a2a/rails/protocol/task_mapper.rb +15 -4
- data/lib/a2a/rails/task/active_record_store.rb +67 -10
- data/lib/a2a/rails/task/lifecycle.rb +32 -12
- data/lib/a2a/rails/task/memory_store.rb +42 -6
- data/lib/a2a/rails/task/store.rb +77 -0
- data/lib/a2a/rails/task.rb +1 -1
- data/lib/a2a/rails/task_execution_arguments.rb +8 -3
- data/lib/a2a/rails/task_execution_job.rb +47 -12
- data/lib/a2a/rails/version.rb +1 -1
- data/lib/a2a-rails.rb +1 -0
- data/lib/generators/a2a/rails/task_continuation_generator.rb +25 -0
- data/lib/generators/a2a/rails/task_store_generator.rb +7 -0
- data/lib/generators/a2a/rails/templates/add_execution_to_a2a_rails_tasks.rb.tt +7 -0
- metadata +24 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dca24947a78dcc9561d0460f59676c9dcef9ad3e5acc7cd1f22b1bad85e32baf
|
|
4
|
+
data.tar.gz: e0edacf3e4a54c947281d12332a29fd321e7bb2fab9558404b221bb69f1b3cf0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3664c0a5a19c67617478d6b8a169b8ec12841ee063e7868ea7a2c23410ea4d31f1a329b42b186d74567b704f192885ceb615dcae27474294f26e4c51fb06cc4f
|
|
7
|
+
data.tar.gz: 6f50be886cc4f09efc5a6c651c1c9ba89733ebf2b0f0075b83120b83eb741898f1ba231cf6ede2cfc0efdc796532b6ab12ec123bd12c82db081661f8edfd88c5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased — 0.5.1 compatibility preparation
|
|
4
|
+
|
|
5
|
+
- Add a temporary runtime dependency bound `regexp_parser ~> 2.0, < 2.13.2`
|
|
6
|
+
for the published agent2agent 2.0.0 / json_schemer 2.5.0 dependency chain.
|
|
7
|
+
Fresh installs select compatible 2.13.1; previously compatible lower 2.x
|
|
8
|
+
lockfiles remain allowed. No public API, protocol or persistence change.
|
|
9
|
+
- Not published. See [preparation and removal criteria](docs/release/v0.5.1-preparation.md).
|
|
10
|
+
|
|
11
|
+
## [0.5.0] - 2026-11-16 (published stable release)
|
|
12
|
+
|
|
13
|
+
> [RubyGems a2a-rails 0.5.0](https://rubygems.org/gems/a2a-rails/versions/0.5.0) · [verified package and source provenance](docs/release/v0.5.0-publication-record.md). This entry is a post-publication documentation update; released bytes retain the frozen source recorded there.
|
|
14
|
+
|
|
15
|
+
- Explicit SDK-independent `InputRequired` Handler result and same-Task continuation,
|
|
16
|
+
stable Agent/Skill routing, question history and current-turn context.
|
|
17
|
+
- Atomic reply acceptance and per-turn Job/outcome fencing in both built-in Stores;
|
|
18
|
+
bounded messageId deduplication and additive durable execution metadata.
|
|
19
|
+
- Upgrade/recovery guide, SDK boundary review policy and real multi-turn validation.
|
|
20
|
+
- Request-local Rails log redaction for A2A parameter bodies, including denied requests,
|
|
21
|
+
without changing host filter settings or real input.
|
|
22
|
+
- See [upgrade/recovery](docs/release/upgrading-v0.4.0-to-v0.5.md) for migration,
|
|
23
|
+
custom Store and worker rollout requirements; existing async/TCK limits remain.
|
|
24
|
+
|
|
3
25
|
All notable changes to this project will be documented in this file.
|
|
4
26
|
|
|
5
27
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
28
|
|
|
7
|
-
## [0.4.0]
|
|
29
|
+
## [0.4.0] - 2026-11-15 (published stable release)
|
|
8
30
|
|
|
9
|
-
>
|
|
31
|
+
> [RubyGems a2a-rails 0.4.0](https://rubygems.org/gems/a2a-rails/versions/0.4.0) · [verified package and source provenance](docs/release/v0.4.0-publication-record.md).
|
|
10
32
|
|
|
11
33
|
- Add opt-in inbound JSON object Data Parts on Skills declaring
|
|
12
34
|
`application/json`; the input contract is enforced after Routing and before
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Rails-native A2A v1.0 integration: expose Rails business logic as an Agent, call remote Agents, or do both. Application handlers use Ruby Hashes rather than SDK request objects.
|
|
4
4
|
|
|
5
|
-
> **Latest stable release (2026-
|
|
5
|
+
> **Latest stable release (2026-11-16): [a2a-rails 0.5.0 is published on RubyGems](https://rubygems.org/gems/a2a-rails/versions/0.5.0).** It adds explicit input-required questions and same-Task continuation while retaining existing text, structured Data and outbound Client flows. See the [continuation guide](docs/guides/task-continuation.md), [upgrade/recovery guide](docs/release/upgrading-v0.4.0-to-v0.5.md) and [publication & SHA-256 record](docs/release/v0.5.0-publication-record.md). **Gem publication is not approval to run an anonymous/public production Agent; deployment #11 remains separate.**
|
|
6
6
|
|
|
7
7
|
## Choose your starting point
|
|
8
8
|
|
|
@@ -37,7 +37,7 @@ The original v0.1.0 baseline was verified against:
|
|
|
37
37
|
In an existing Rails application, pin the published stable Gem:
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
bundle add a2a-rails --version '= 0.
|
|
40
|
+
bundle add a2a-rails --version '= 0.5.0'
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
If you need a fresh app first (with a supported Rails installed):
|
|
@@ -45,7 +45,7 @@ If you need a fresh app first (with a supported Rails installed):
|
|
|
45
45
|
```bash
|
|
46
46
|
rails new echo_app --minimal --skip-active-record
|
|
47
47
|
cd echo_app
|
|
48
|
-
bundle add a2a-rails --version '= 0.
|
|
48
|
+
bundle add a2a-rails --version '= 0.5.0'
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
Then choose Server or Client-only setup below. No explicit Engine mount is needed.
|
|
@@ -80,7 +80,7 @@ Replace the placeholder with a real approved HTTPS Agent. For an authenticated A
|
|
|
80
80
|
|
|
81
81
|
## Server Quick Start (local development)
|
|
82
82
|
|
|
83
|
-
Use the published `a2a-rails 0.
|
|
83
|
+
Use the published `a2a-rails 0.5.0` Gem installed above in development. The Echo flow uses synchronous execution and MemoryStore; no database or queue is required. If you previously selected Client-only mode, remove `server_enabled = false` and restart Rails.
|
|
84
84
|
|
|
85
85
|
### 1. Generate the setup
|
|
86
86
|
|
|
@@ -211,7 +211,7 @@ See the [historical v0.1 Quick Start design](docs/design/quick-start.md) for the
|
|
|
211
211
|
|
|
212
212
|
**[a2a-rails-demo — independent Rails 8 Echo Agent](https://github.com/cuichangquan/a2a-rails-demo)**
|
|
213
213
|
|
|
214
|
-
Run a complete standalone Rails Agent using the
|
|
214
|
+
Run a complete standalone Rails Agent using the published RubyGems package (not a Git source checkout). See the demo README for its exact pin. The separate Demo covers Agent Card discovery, JSON-RPC v1.0 SendMessage **Task and direct Message**, GetTask, ListTasks and error handling.
|
|
215
215
|
|
|
216
216
|
- [Demo Quick Start, code and example curl requests](https://github.com/cuichangquan/a2a-rails-demo#quick-start).
|
|
217
217
|
- [Demo GitHub Actions smoke](https://github.com/cuichangquan/a2a-rails-demo/actions/workflows/smoke.yml) — independent Rails 8.1.4 / Ruby 3.4.10 HTTP smoke against published stable Gem `0.3.0` ([Step 32 Server PR #3, merged](https://github.com/cuichangquan/a2a-rails-demo/pull/3), [passing CI](https://github.com/cuichangquan/a2a-rails-demo/actions/runs/38097407649)). Verifies the actual published Gem and dependency versions, Task/direct Message/GetTask/ListTasks/CancelTask and refusal to boot in production. The historical [Step 28 v0.2.0 smoke](https://github.com/cuichangquan/a2a-rails-demo/actions/runs/37736426834) is preserved separately.
|
|
@@ -221,7 +221,7 @@ Run a complete standalone Rails Agent using the **published RubyGems `a2a-rails
|
|
|
221
221
|
|
|
222
222
|
**[a2a-rails-client-demo — standalone Rails 8 Client](https://github.com/cuichangquan/a2a-rails-client-demo)**
|
|
223
223
|
|
|
224
|
-
Independent Client-only Rails application
|
|
224
|
+
Independent Client-only Rails application with `server_enabled = false`. See the demo README for its exact RubyGems pin. It discovers Agent Cards and calls SendMessage (Task/direct Message), GetTask and ListTasks using exact HTTPS origin allowlisting. [Stable Client CI PASS](https://github.com/cuichangquan/a2a-rails-client-demo/actions/runs/38097502077) and [independent Rails-to-Rails pinned-TLS CI PASS](https://github.com/cuichangquan/a2a-rails-client-demo/actions/runs/38097502218) use **published stable 0.3.0 on both Rails sides** and actual Server Echo business logic ([Step 32 Client PR #3](https://github.com/cuichangquan/a2a-rails-client-demo/pull/3)). The loopback-only bridge uses an ephemeral test CA and isolated test-only policy override; production Client SSRF/TLS protections are not relaxed. This is **not** a direct public-DNS/public-CA or production deployment test. Historical RC1 Client ↔ 0.2.0 Server evidence remains [in Step 30](https://github.com/cuichangquan/a2a-rails/issues/117).
|
|
225
225
|
|
|
226
226
|
## What is a2a-rails?
|
|
227
227
|
|
|
@@ -342,7 +342,7 @@ Behavior in v0.1:
|
|
|
342
342
|
- Streaming, Push Notifications, and Extended Agent Cards are disabled;
|
|
343
343
|
- generated Cards pass the `agent2agent 2.0.0` Agent Card schema.
|
|
344
344
|
|
|
345
|
-
### Structured Data input (
|
|
345
|
+
### Structured Data input (since 0.4.0)
|
|
346
346
|
|
|
347
347
|
Declare `input_modes: ["application/json"]` on each Skill that accepts Data.
|
|
348
348
|
The selected Skill receives a normal Ruby Hash containing the JSON object, with
|
|
@@ -569,7 +569,7 @@ Known warning-enabled output from upstream `agent2agent 2.0.0` can include circu
|
|
|
569
569
|
> **Release status (2026-10-08):** **`0.2.0` is published as a stable release** on [RubyGems](https://rubygems.org/gems/a2a-rails/versions/0.2.0) and [GitHub](https://github.com/cuichangquan/a2a-rails/releases/tag/v0.2.0). It includes the Rails/Zeitwerk and migration-generator fixes after rc2. The public Gem matches the verified artifact byte-for-byte; see the [publication record](docs/release/v0.2.0-publication-record.md).
|
|
570
570
|
|
|
571
571
|
- RubyGems: https://rubygems.org/gems/a2a-rails
|
|
572
|
-
- **
|
|
572
|
+
- **Previous stable `0.3.0`:** [GitHub Release](https://github.com/cuichangquan/a2a-rails/releases/tag/v0.3.0) · [RubyGems](https://rubygems.org/gems/a2a-rails/versions/0.3.0) · [exact public SHA256 and provenance](docs/release/v0.3.0-publication-record.md)
|
|
573
573
|
- Published version list: https://rubygems.org/gems/a2a-rails/versions
|
|
574
574
|
- Earlier stable release `0.2.0`: https://github.com/cuichangquan/a2a-rails/releases/tag/v0.2.0
|
|
575
575
|
- Previous stable release: https://github.com/cuichangquan/a2a-rails/releases/tag/v0.1.0
|
|
@@ -633,3 +633,12 @@ The Gem is available as open source under the terms of the MIT License. See [LIC
|
|
|
633
633
|
### Community submissions / コミュニティへの投稿
|
|
634
634
|
|
|
635
635
|
- [awesome-a2a: Resource suggestion #190 / 掲載提案](https://github.com/ai-boost/awesome-a2a/issues/190)
|
|
636
|
+
|
|
637
|
+
## 0.5.0 input-required continuation
|
|
638
|
+
|
|
639
|
+
Handlers can explicitly return `A2A::Rails::InputRequired.new("Which department?")`
|
|
640
|
+
to ask a question, then accept a reply through SendMessage on the same Task.
|
|
641
|
+
See [usage](docs/guides/task-continuation.md), [design](docs/design/task-continuation.md),
|
|
642
|
+
[SDK boundary rules](docs/design/sdk-boundary.md), and [upgrade/recovery](docs/release/upgrading-v0.4.0-to-v0.5.md).
|
|
643
|
+
See the [publication record](docs/release/v0.5.0-publication-record.md) for the
|
|
644
|
+
frozen source, exact package hash and verification limits.
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module A2A
|
|
4
4
|
module Rails
|
|
5
5
|
class RequestsController < ApplicationController
|
|
6
|
+
# JSON-RPC reads its raw envelope; Rails model parameter wrapping is unused
|
|
7
|
+
# and would eagerly parse/log malformed bodies before the SDK boundary.
|
|
8
|
+
wrap_parameters false
|
|
6
9
|
def create
|
|
7
10
|
response.set_header("Cache-Control", "no-store")
|
|
8
11
|
return unless validate_a2a_request_body
|
|
@@ -20,6 +23,34 @@ module A2A
|
|
|
20
23
|
|
|
21
24
|
private
|
|
22
25
|
|
|
26
|
+
# Run before Rails Instrumentation builds its start_processing payload.
|
|
27
|
+
# Host filter configuration is not mutated; only this A2A request is affected.
|
|
28
|
+
def process_action(*)
|
|
29
|
+
filters = Array(request.get_header("action_dispatch.parameter_filter"))
|
|
30
|
+
request.set_header("action_dispatch.parameter_filter", filters + [/\Aparams\z/])
|
|
31
|
+
# Earlier middleware may have memoized a filtered view. Invalidate only
|
|
32
|
+
# request-local Rails filter caches, never the actual parameters/body.
|
|
33
|
+
%i[@parameter_filter @filtered_env @filtered_path].each do |name|
|
|
34
|
+
request.instance_variable_set(name, nil)
|
|
35
|
+
end
|
|
36
|
+
# Do not ask Rails to parse the RPC body for logging: its malformed-JSON
|
|
37
|
+
# diagnostic can print raw_post before parameter filtering takes effect.
|
|
38
|
+
# Runtime/SDK still receive the original body after request validation.
|
|
39
|
+
request.instance_variable_set(:@filtered_parameters, { "params" => "[FILTERED]" })
|
|
40
|
+
# This endpoint is JSON-RPC only. Rails format negotiation otherwise
|
|
41
|
+
# parses body parameters again while constructing instrumentation data.
|
|
42
|
+
request.set_header("action_dispatch.request.formats", [::Mime[:json]])
|
|
43
|
+
super
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def render_a2a_error(message, status:)
|
|
47
|
+
# `render json:` negotiates Vary through parsed request parameters,
|
|
48
|
+
# which can log an invalid raw body even after RequestGuard rejects it.
|
|
49
|
+
self.status = status
|
|
50
|
+
self.content_type = "application/json"
|
|
51
|
+
self.response_body = JSON.generate(error: message)
|
|
52
|
+
end
|
|
53
|
+
|
|
23
54
|
def validate_a2a_request_body
|
|
24
55
|
RequestGuard.enforce!(
|
|
25
56
|
env: request.env,
|
|
@@ -27,7 +58,7 @@ module A2A
|
|
|
27
58
|
)
|
|
28
59
|
true
|
|
29
60
|
rescue RequestGuard::PayloadTooLarge
|
|
30
|
-
|
|
61
|
+
render_a2a_error("Payload too large", status: 413)
|
|
31
62
|
false
|
|
32
63
|
rescue RequestGuard::UnsupportedMediaType
|
|
33
64
|
# This is an HTTP boundary rejection before JSON-RPC parsing (and
|
|
@@ -37,11 +68,11 @@ module A2A
|
|
|
37
68
|
head :unsupported_media_type
|
|
38
69
|
false
|
|
39
70
|
rescue RequestGuard::InvalidBody
|
|
40
|
-
|
|
71
|
+
render_a2a_error("Invalid request body", status: 400)
|
|
41
72
|
false
|
|
42
73
|
rescue RequestGuard::InvalidConfiguration
|
|
43
74
|
A2A::Rails.configuration.logger&.error("[a2a-rails] invalid request size configuration")
|
|
44
|
-
|
|
75
|
+
render_a2a_error("Request validation unavailable", status: 500)
|
|
45
76
|
false
|
|
46
77
|
end
|
|
47
78
|
|
|
@@ -54,16 +85,16 @@ module A2A
|
|
|
54
85
|
true
|
|
55
86
|
rescue Authentication::Unauthorized
|
|
56
87
|
response.set_header("WWW-Authenticate", A2A::Rails.configuration.authentication_challenge)
|
|
57
|
-
|
|
88
|
+
render_a2a_error("Unauthorized", status: :unauthorized)
|
|
58
89
|
false
|
|
59
90
|
rescue Authentication::Forbidden
|
|
60
|
-
|
|
91
|
+
render_a2a_error("Forbidden", status: :forbidden)
|
|
61
92
|
false
|
|
62
93
|
rescue StandardError => error
|
|
63
94
|
# The exception message may contain credentials supplied by host code.
|
|
64
95
|
# Log the class only; never echo verifier failures into the response.
|
|
65
96
|
A2A::Rails.configuration.logger&.error("[a2a-rails] authentication unavailable: #{error.class}")
|
|
66
|
-
|
|
97
|
+
render_a2a_error("Authentication unavailable", status: :internal_server_error)
|
|
67
98
|
false
|
|
68
99
|
end
|
|
69
100
|
end
|
|
@@ -6,7 +6,7 @@ require "uri"
|
|
|
6
6
|
module A2A
|
|
7
7
|
module Rails
|
|
8
8
|
class Configuration
|
|
9
|
-
TASK_STORE_METHODS = %i[save find transition cancel list].freeze
|
|
9
|
+
TASK_STORE_METHODS = %i[save find transition cancel list claim_execution configure_execution resume].freeze
|
|
10
10
|
TASK_EXECUTION_MODES = %i[sync async].freeze
|
|
11
11
|
DEFAULT_TASK_RETENTION_SECONDS = 30 * 24 * 60 * 60
|
|
12
12
|
DEFAULT_TASK_PRUNE_BATCH_SIZE = 1_000
|
|
@@ -16,7 +16,7 @@ module A2A
|
|
|
16
16
|
|
|
17
17
|
attr_accessor :agent, :public_base_url, :authenticate_request, :authentication_challenge,
|
|
18
18
|
:max_request_bytes, :security_schemes, :security_requirements,
|
|
19
|
-
:task_store, :task_page_token_secret, :task_retention,
|
|
19
|
+
:task_store, :task_page_token_secret, :task_retention, :task_input_required_retention,
|
|
20
20
|
:task_prune_batch_size, :max_tasks_per_owner,
|
|
21
21
|
:max_task_history_entries, :max_task_artifacts,
|
|
22
22
|
:task_execution_mode, :server_enabled
|
|
@@ -32,6 +32,7 @@ module A2A
|
|
|
32
32
|
@task_store = :memory
|
|
33
33
|
@task_page_token_secret = nil
|
|
34
34
|
@task_retention = DEFAULT_TASK_RETENTION_SECONDS
|
|
35
|
+
@task_input_required_retention = nil
|
|
35
36
|
@task_prune_batch_size = DEFAULT_TASK_PRUNE_BATCH_SIZE
|
|
36
37
|
@max_tasks_per_owner = DEFAULT_MAX_TASKS_PER_OWNER
|
|
37
38
|
@max_task_history_entries = DEFAULT_MAX_TASK_HISTORY_ENTRIES
|
|
@@ -93,7 +94,7 @@ module A2A
|
|
|
93
94
|
def resolve_task_store
|
|
94
95
|
case @task_store
|
|
95
96
|
when nil, :memory
|
|
96
|
-
Task::MemoryStore.new
|
|
97
|
+
Task::MemoryStore.new(max_history_entries: @max_task_history_entries)
|
|
97
98
|
when :active_record
|
|
98
99
|
resolve_active_record_store
|
|
99
100
|
else
|
|
@@ -115,6 +116,7 @@ module A2A
|
|
|
115
116
|
Task::ActiveRecordStore.new(
|
|
116
117
|
cursor_secret: task_cursor_secret,
|
|
117
118
|
retention: @task_retention,
|
|
119
|
+
input_required_retention: @task_input_required_retention,
|
|
118
120
|
prune_batch_size: @task_prune_batch_size,
|
|
119
121
|
max_tasks_per_owner: @max_tasks_per_owner,
|
|
120
122
|
max_history_entries: @max_task_history_entries,
|
|
@@ -144,7 +146,9 @@ module A2A
|
|
|
144
146
|
end
|
|
145
147
|
|
|
146
148
|
def validate_task_store!(store)
|
|
147
|
-
missing = TASK_STORE_METHODS.reject
|
|
149
|
+
missing = TASK_STORE_METHODS.reject do |method_name|
|
|
150
|
+
store.respond_to?(method_name) && store.method(method_name).owner != Task::Store
|
|
151
|
+
end
|
|
148
152
|
unless missing.empty?
|
|
149
153
|
raise ConfigurationError, "config.task_store is missing methods: #{missing.join(", ")}"
|
|
150
154
|
end
|
data/lib/a2a/rails/dispatcher.rb
CHANGED
|
@@ -38,6 +38,9 @@ module A2A
|
|
|
38
38
|
|
|
39
39
|
def execute(plan:, message:, context:)
|
|
40
40
|
validate!
|
|
41
|
+
unless plan.agent_class_name.nil? || @agent.name == plan.agent_class_name
|
|
42
|
+
raise ConfigurationError, "Saved Agent no longer matches configured Agent"
|
|
43
|
+
end
|
|
41
44
|
skill = declared_skill(plan.skill_id)
|
|
42
45
|
verify_skill_input!(skill, message)
|
|
43
46
|
handler_context = context.merge(skill_id: skill.id)
|
data/lib/a2a/rails/errors.rb
CHANGED
|
@@ -13,6 +13,7 @@ module A2A
|
|
|
13
13
|
class ArtifactMappingError < Error; end
|
|
14
14
|
|
|
15
15
|
class ProtocolError < Error; end
|
|
16
|
+
class InvalidAgentResponseError < ProtocolError; end
|
|
16
17
|
class InvalidRequestError < ProtocolError; end
|
|
17
18
|
class ContentTypeNotSupportedError < ProtocolError; end
|
|
18
19
|
class TaskContinuationNotSupportedError < ProtocolError; end
|
|
@@ -37,6 +38,18 @@ module A2A
|
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
|
|
41
|
+
class TaskNotResumableError < TaskError
|
|
42
|
+
attr_reader :task_id, :state
|
|
43
|
+
|
|
44
|
+
def initialize(task_id, state:)
|
|
45
|
+
@task_id, @state = task_id, state
|
|
46
|
+
super("Task is not awaiting input")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
class TaskContextMismatchError < InvalidRequestError; end
|
|
50
|
+
class TaskMessageConflictError < InvalidRequestError; end
|
|
51
|
+
class TaskContinuationUnavailableError < ConfigurationError; end
|
|
52
|
+
|
|
40
53
|
class InvalidTaskQueryError < TaskError; end
|
|
41
54
|
class InvalidTaskStateError < TaskError; end
|
|
42
55
|
class TaskStoreUnavailableError < TaskError; end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module A2A
|
|
6
|
+
module Rails
|
|
7
|
+
# A normal, non-terminal Handler outcome. Never inferred from a Hash key.
|
|
8
|
+
class InputRequired
|
|
9
|
+
attr_reader :text
|
|
10
|
+
|
|
11
|
+
def initialize(text, data: nil)
|
|
12
|
+
unless text.is_a?(String) && !text.strip.empty?
|
|
13
|
+
raise ArgumentError, "InputRequired text must be a nonempty String"
|
|
14
|
+
end
|
|
15
|
+
unless data.nil? || data.is_a?(Hash)
|
|
16
|
+
raise ArgumentError, "InputRequired data must be a JSON object"
|
|
17
|
+
end
|
|
18
|
+
@text = text.dup.freeze
|
|
19
|
+
@data = data.nil? ? nil : copy_json(data)
|
|
20
|
+
freeze
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def parts
|
|
24
|
+
result = [{ text: @text.dup }]
|
|
25
|
+
result << { data: copy_json(@data), media_type: "application/json" } unless @data.nil?
|
|
26
|
+
result
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def copy_json(value)
|
|
32
|
+
case value
|
|
33
|
+
when Hash
|
|
34
|
+
value.each_with_object({}) do |(key, nested), result|
|
|
35
|
+
raise ArgumentError, "InputRequired JSON keys must be Strings" unless key.is_a?(String)
|
|
36
|
+
result[key.dup] = copy_json(nested)
|
|
37
|
+
end
|
|
38
|
+
when Array then value.map { |item| copy_json(item) }
|
|
39
|
+
when String then value.dup
|
|
40
|
+
when Integer, TrueClass, FalseClass, NilClass then value
|
|
41
|
+
when Float
|
|
42
|
+
raise ArgumentError, "InputRequired JSON numbers must be finite" unless value.finite?
|
|
43
|
+
value
|
|
44
|
+
else
|
|
45
|
+
raise ArgumentError, "InputRequired data must contain JSON values"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -100,6 +100,17 @@ module A2A
|
|
|
100
100
|
end
|
|
101
101
|
result = @request_handler.call(operation: operation, params: params)
|
|
102
102
|
schema(RESPONSE_SCHEMAS.fetch(operation), result)
|
|
103
|
+
rescue A2A::Rails::InvalidAgentResponseError
|
|
104
|
+
raise A2A::InvalidAgentResponseError.new
|
|
105
|
+
rescue A2A::Rails::TaskStorePayloadLimitError
|
|
106
|
+
raise A2A::InvalidParamsError.new("Task history or payload limit reached; cancel and start a new Task")
|
|
107
|
+
rescue A2A::Rails::TaskNotResumableError => error
|
|
108
|
+
if Task::TERMINAL_STATES.include?(error.state)
|
|
109
|
+
raise A2A::UnsupportedOperationError.new(message: "Terminal Task cannot accept new input")
|
|
110
|
+
end
|
|
111
|
+
raise A2A::InvalidParamsError.new("Task does not accept new input in its current state")
|
|
112
|
+
rescue A2A::Rails::TaskContinuationUnavailableError
|
|
113
|
+
raise A2A::UnsupportedOperationError.new(message: "Task has no resumable execution metadata")
|
|
103
114
|
rescue A2A::Rails::TaskNotFoundError => error
|
|
104
115
|
raise A2A::TaskNotFoundError.new(error.task_id)
|
|
105
116
|
rescue A2A::Rails::TaskNotCancelableError => error
|
|
@@ -34,8 +34,9 @@ module A2A
|
|
|
34
34
|
|
|
35
35
|
def send_message(params)
|
|
36
36
|
@dispatcher.validate!
|
|
37
|
-
history_length = history_length(params)
|
|
38
|
-
message, context_id = normalize_message(params)
|
|
37
|
+
history_length = history_length(params.fetch("configuration", {}))
|
|
38
|
+
message, context_id, task_id = normalize_message(params)
|
|
39
|
+
return resume_message(task_id, message, context_id, history_length) if task_id
|
|
39
40
|
|
|
40
41
|
# Direct Message is an explicit host-side choice, never inferred
|
|
41
42
|
# from an untrusted client flag or forced by the protocol adapter.
|
|
@@ -72,29 +73,59 @@ module A2A
|
|
|
72
73
|
nil
|
|
73
74
|
end
|
|
74
75
|
|
|
75
|
-
if plan
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
task = begin
|
|
80
|
-
result = @dispatcher.execute(plan: plan, message: message, context: context)
|
|
81
|
-
@lifecycle.complete(task.fetch(:id), result)
|
|
82
|
-
rescue RejectedTask => error
|
|
83
|
-
@lifecycle.reject(task.fetch(:id), error)
|
|
76
|
+
if plan
|
|
77
|
+
begin
|
|
78
|
+
task = @lifecycle.configure_execution(task.fetch(:id), plan: plan,
|
|
79
|
+
message_id: message.fetch(:message_id))
|
|
84
80
|
rescue StandardError => error
|
|
81
|
+
# A configuration/migration failure must not leave an initial
|
|
82
|
+
# submitted Task that nobody can execute. No turn exists yet.
|
|
85
83
|
@lifecycle.fail(task.fetch(:id), error)
|
|
84
|
+
raise
|
|
86
85
|
end
|
|
86
|
+
task = execute_task(task, plan, message)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
{ "task" => @task_mapper.dump(task, history_length: history_length, include_artifacts: true) }
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
+
def resume_message(task_id, message, context_id, history_length)
|
|
93
|
+
accepted = @lifecycle.resume(task_id, message: message, context_id: context_id)
|
|
94
|
+
task = accepted.fetch(:task)
|
|
95
|
+
if accepted.fetch(:accepted)
|
|
96
|
+
execution = task.fetch(:execution)
|
|
97
|
+
plan = ExecutionPlan.new(agent_class_name: execution[:agent_class_name],
|
|
98
|
+
skill_id: execution.fetch(:skill_id), execution_mode: execution.fetch(:execution_mode).to_sym)
|
|
99
|
+
task = execute_task(task, plan, message)
|
|
100
|
+
end
|
|
101
|
+
{ "task" => @task_mapper.dump(task, history_length: history_length, include_artifacts: true) }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def execute_task(task, plan, message)
|
|
105
|
+
return enqueue_async_task(task, plan) if plan.async?
|
|
106
|
+
|
|
107
|
+
task_id = task.fetch(:id)
|
|
108
|
+
turn_id = task.dig(:execution, :turn_id)
|
|
109
|
+
claimed = @lifecycle.claim_execution(task_id, turn_id: turn_id)
|
|
110
|
+
return @lifecycle.find(task_id) unless claimed
|
|
111
|
+
|
|
112
|
+
begin
|
|
113
|
+
result = @dispatcher.execute(plan: plan, message: message, context: execution_context(claimed))
|
|
114
|
+
@lifecycle.complete(task_id, result, turn_id: turn_id)
|
|
115
|
+
rescue RejectedTask => error
|
|
116
|
+
@lifecycle.reject(task_id, error, turn_id: turn_id)
|
|
117
|
+
rescue StandardError => error
|
|
118
|
+
@lifecycle.fail(task_id, error, turn_id: turn_id)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
92
122
|
def enqueue_async_task(task, plan)
|
|
93
123
|
arguments = TaskExecutionArguments.new(
|
|
94
124
|
task_id: task.fetch(:id),
|
|
95
125
|
principal_id: @lifecycle.principal_id,
|
|
96
126
|
agent_class_name: plan.agent_class_name,
|
|
97
|
-
skill_id: plan.skill_id
|
|
127
|
+
skill_id: plan.skill_id,
|
|
128
|
+
turn_id: task.dig(:execution, :turn_id)
|
|
98
129
|
)
|
|
99
130
|
job = @task_job.perform_later(**arguments.to_h)
|
|
100
131
|
enqueue_error = job.respond_to?(:enqueue_error) ? job.enqueue_error : nil
|
|
@@ -107,10 +138,11 @@ module A2A
|
|
|
107
138
|
|
|
108
139
|
@lifecycle.fail(
|
|
109
140
|
task.fetch(:id),
|
|
110
|
-
enqueue_error || ConfigurationError.new("Task execution job was not enqueued")
|
|
141
|
+
enqueue_error || ConfigurationError.new("Task execution job was not enqueued"),
|
|
142
|
+
turn_id: task.dig(:execution, :turn_id)
|
|
111
143
|
)
|
|
112
144
|
rescue StandardError => error
|
|
113
|
-
@lifecycle.fail(task.fetch(:id), error)
|
|
145
|
+
@lifecycle.fail(task.fetch(:id), error, turn_id: task.dig(:execution, :turn_id))
|
|
114
146
|
end
|
|
115
147
|
|
|
116
148
|
def execution_context(task)
|
|
@@ -118,7 +150,9 @@ module A2A
|
|
|
118
150
|
task_id: task.fetch(:id),
|
|
119
151
|
context_id: task.fetch(:context_id),
|
|
120
152
|
principal_id: @lifecycle.principal_id,
|
|
121
|
-
idempotency_key: task.fetch(:id)
|
|
153
|
+
idempotency_key: task.fetch(:id),
|
|
154
|
+
execution_turn_id: task.dig(:execution, :turn_id),
|
|
155
|
+
history: copy(task.fetch(:history, []))
|
|
122
156
|
}
|
|
123
157
|
end
|
|
124
158
|
|
|
@@ -127,7 +161,7 @@ module A2A
|
|
|
127
161
|
rescue StandardError
|
|
128
162
|
# The selector is host application code and may raise with secrets.
|
|
129
163
|
# No Task exists yet to record the failure as a Task status.
|
|
130
|
-
raise
|
|
164
|
+
raise InvalidAgentResponseError
|
|
131
165
|
end
|
|
132
166
|
|
|
133
167
|
def send_direct_message(message, context_id)
|
|
@@ -142,7 +176,7 @@ module A2A
|
|
|
142
176
|
rescue StandardError
|
|
143
177
|
# No Task exists to record a FAILED status. Never send application
|
|
144
178
|
# exception details or unsupported result values to A2A callers.
|
|
145
|
-
raise
|
|
179
|
+
raise InvalidAgentResponseError
|
|
146
180
|
end
|
|
147
181
|
|
|
148
182
|
def get_task(params)
|
|
@@ -212,10 +246,6 @@ module A2A
|
|
|
212
246
|
raise InvalidRequestError, "message metadata must be an object"
|
|
213
247
|
end
|
|
214
248
|
|
|
215
|
-
if task_id.is_a?(String) && !task_id.empty?
|
|
216
|
-
@lifecycle.find(task_id)
|
|
217
|
-
raise TaskContinuationNotSupportedError, "Task continuation is not supported in v0.1"
|
|
218
|
-
end
|
|
219
249
|
|
|
220
250
|
normalized_parts = parts.map { |part| normalize_part(part) }
|
|
221
251
|
if normalized_parts.any? { |part| part.key?(:data) } && normalized_parts.any? { |part| part.key?(:text) }
|
|
@@ -228,7 +258,7 @@ module A2A
|
|
|
228
258
|
metadata: copy(metadata || {})
|
|
229
259
|
}
|
|
230
260
|
|
|
231
|
-
[message, context_id]
|
|
261
|
+
[message, context_id, task_id.to_s.empty? ? nil : task_id]
|
|
232
262
|
end
|
|
233
263
|
|
|
234
264
|
def normalize_part(part)
|
|
@@ -9,6 +9,7 @@ module A2A
|
|
|
9
9
|
STATE_TO_WIRE = {
|
|
10
10
|
submitted: "TASK_STATE_SUBMITTED",
|
|
11
11
|
working: "TASK_STATE_WORKING",
|
|
12
|
+
input_required: "TASK_STATE_INPUT_REQUIRED",
|
|
12
13
|
completed: "TASK_STATE_COMPLETED",
|
|
13
14
|
failed: "TASK_STATE_FAILED",
|
|
14
15
|
rejected: "TASK_STATE_REJECTED",
|
|
@@ -25,7 +26,13 @@ module A2A
|
|
|
25
26
|
|
|
26
27
|
if task.key?(:history)
|
|
27
28
|
history = project_history(task[:history], history_length)
|
|
28
|
-
result["history"] = history.map
|
|
29
|
+
result["history"] = history.map do |message|
|
|
30
|
+
value = dump_message(message)
|
|
31
|
+
if message[:role].to_s == "agent"
|
|
32
|
+
value.merge!("taskId" => task.fetch(:id), "contextId" => task.fetch(:context_id))
|
|
33
|
+
end
|
|
34
|
+
value
|
|
35
|
+
end
|
|
29
36
|
end
|
|
30
37
|
|
|
31
38
|
if include_artifacts && task.key?(:artifacts)
|
|
@@ -70,11 +77,15 @@ module A2A
|
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
if status[:message]
|
|
73
|
-
result["message"] =
|
|
80
|
+
result["message"] = if status[:message].is_a?(Hash)
|
|
81
|
+
dump_message(status[:message]).merge("taskId" => task.fetch(:id), "contextId" => task.fetch(:context_id))
|
|
82
|
+
else
|
|
83
|
+
{
|
|
74
84
|
"messageId" => "status-#{task.fetch(:id)}-#{status.fetch(:state)}",
|
|
75
85
|
"role" => "ROLE_AGENT",
|
|
76
86
|
"parts" => [{ "text" => status[:message].to_s }]
|
|
77
|
-
|
|
87
|
+
}
|
|
88
|
+
end
|
|
78
89
|
end
|
|
79
90
|
|
|
80
91
|
result.compact
|
|
@@ -83,7 +94,7 @@ module A2A
|
|
|
83
94
|
def dump_message(message)
|
|
84
95
|
result = {
|
|
85
96
|
"messageId" => message.fetch(:message_id),
|
|
86
|
-
"role" => message.fetch(:role) ==
|
|
97
|
+
"role" => message.fetch(:role).to_s == "agent" ? "ROLE_AGENT" : "ROLE_USER",
|
|
87
98
|
"parts" => message.fetch(:parts).map { |part| dump_part(part) }
|
|
88
99
|
}
|
|
89
100
|
result["metadata"] = copy(message[:metadata]) if message.key?(:metadata)
|
|
@@ -23,13 +23,14 @@ module A2A
|
|
|
23
23
|
|
|
24
24
|
def initialize(cursor_secret:, clock: -> { Time.now.utc }, retention: nil,
|
|
25
25
|
prune_batch_size: 1_000, max_tasks_per_owner: nil,
|
|
26
|
-
max_history_entries: 100, max_artifacts: 50)
|
|
26
|
+
max_history_entries: 100, max_artifacts: 50, input_required_retention: nil)
|
|
27
27
|
unless cursor_secret.is_a?(String) && cursor_secret.bytesize >= 32
|
|
28
28
|
raise ArgumentError, "cursor_secret must be at least 32 bytes"
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
@clock = clock
|
|
32
32
|
@retention_seconds = normalize_retention(retention)
|
|
33
|
+
@input_required_retention = normalize_retention(input_required_retention)
|
|
33
34
|
@prune_batch_size = normalize_prune_batch_size(prune_batch_size)
|
|
34
35
|
@max_tasks_per_owner = normalize_optional_positive_integer(
|
|
35
36
|
max_tasks_per_owner,
|
|
@@ -56,7 +57,7 @@ module A2A
|
|
|
56
57
|
record = Record.transaction do
|
|
57
58
|
enforce_owner_quota!(task[:owner_id], at: now)
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
attributes = {
|
|
60
61
|
task_id: task.fetch(:id),
|
|
61
62
|
owner_id: task[:owner_id],
|
|
62
63
|
context_id: task.fetch(:context_id),
|
|
@@ -66,7 +67,12 @@ module A2A
|
|
|
66
67
|
history: task.key?(:history) ? deep_stringify(task[:history]) : nil,
|
|
67
68
|
artifacts: task.key?(:artifacts) ? deep_stringify(task[:artifacts]) : nil,
|
|
68
69
|
expires_at: terminal_state?(state) ? expiration_at(timestamp) : nil
|
|
69
|
-
|
|
70
|
+
}
|
|
71
|
+
if task[:execution]
|
|
72
|
+
require_execution_column!
|
|
73
|
+
attributes[:execution] = deep_stringify(task[:execution])
|
|
74
|
+
end
|
|
75
|
+
Record.create!(attributes)
|
|
70
76
|
end
|
|
71
77
|
|
|
72
78
|
deserialize(record)
|
|
@@ -76,12 +82,12 @@ module A2A
|
|
|
76
82
|
deserialize(find_record!(task_id, principal_id: principal_id))
|
|
77
83
|
end
|
|
78
84
|
|
|
79
|
-
def claim_execution(task_id, timestamp: Time.now.utc, principal_id: nil)
|
|
85
|
+
def claim_execution(task_id, timestamp: Time.now.utc, principal_id: nil, turn_id: nil)
|
|
80
86
|
timestamp = normalize_time(timestamp, field: "task status timestamp")
|
|
81
87
|
|
|
82
88
|
Record.transaction do
|
|
83
89
|
record = locked_record!(task_id, principal_id: principal_id)
|
|
84
|
-
if record.state == "submitted"
|
|
90
|
+
if record.state == "submitted" && turn_matches?(deserialize(record), turn_id)
|
|
85
91
|
record.update!(
|
|
86
92
|
state: "working",
|
|
87
93
|
status_timestamp: timestamp,
|
|
@@ -93,7 +99,7 @@ module A2A
|
|
|
93
99
|
end
|
|
94
100
|
|
|
95
101
|
def transition(task_id, state:, timestamp: Time.now.utc, artifacts: UNSET, message: UNSET,
|
|
96
|
-
principal_id: nil)
|
|
102
|
+
principal_id: nil, turn_id: nil)
|
|
97
103
|
state = normalized_state(state)
|
|
98
104
|
timestamp = normalize_time(timestamp, field: "task status timestamp")
|
|
99
105
|
validate_payload_collection!("artifacts", artifacts, @max_artifacts) unless artifacts.equal?(UNSET)
|
|
@@ -101,13 +107,23 @@ module A2A
|
|
|
101
107
|
Record.transaction do
|
|
102
108
|
record = locked_record!(task_id, principal_id: principal_id)
|
|
103
109
|
|
|
104
|
-
|
|
110
|
+
eligible = !terminal_record?(record) && turn_matches?(deserialize(record), turn_id)
|
|
111
|
+
eligible &&= %w[submitted working].include?(record.state) if turn_id
|
|
112
|
+
if eligible
|
|
105
113
|
attributes = {
|
|
106
114
|
state: state.to_s,
|
|
107
115
|
status_timestamp: timestamp,
|
|
108
116
|
status_message: message.equal?(UNSET) ? nil : deep_stringify(message)
|
|
109
117
|
}
|
|
110
118
|
attributes[:artifacts] = deep_stringify(artifacts) unless artifacts.equal?(UNSET)
|
|
119
|
+
if state == :input_required
|
|
120
|
+
if message.is_a?(Hash)
|
|
121
|
+
history = (record.history || []) + [deep_stringify(message)]
|
|
122
|
+
validate_payload_collection!("history", history, @max_history_entries)
|
|
123
|
+
attributes[:history] = history
|
|
124
|
+
end
|
|
125
|
+
attributes[:expires_at] = @input_required_retention && timestamp + @input_required_retention
|
|
126
|
+
end
|
|
111
127
|
if terminal_state?(state) && record.expires_at.nil?
|
|
112
128
|
attributes[:expires_at] = expiration_at(timestamp)
|
|
113
129
|
end
|
|
@@ -118,6 +134,35 @@ module A2A
|
|
|
118
134
|
end
|
|
119
135
|
end
|
|
120
136
|
|
|
137
|
+
def configure_execution(task_id, execution:, principal_id: nil)
|
|
138
|
+
require_execution_column!
|
|
139
|
+
Record.transaction do
|
|
140
|
+
record = locked_record!(task_id, principal_id: principal_id)
|
|
141
|
+
metadata = configured_execution(deserialize(record), execution)
|
|
142
|
+
record.update!(execution: deep_stringify(metadata))
|
|
143
|
+
deserialize(record)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def resume(task_id, message:, context_id: nil, turn_id:, timestamp: Time.now.utc, principal_id: nil)
|
|
148
|
+
timestamp = normalize_time(timestamp, field: "task status timestamp")
|
|
149
|
+
Record.transaction do
|
|
150
|
+
record = locked_record!(task_id, principal_id: principal_id)
|
|
151
|
+
task = deserialize(record)
|
|
152
|
+
validate_turn_id!(turn_id)
|
|
153
|
+
accepted = validate_resume!(task, message, context_id, @max_history_entries)
|
|
154
|
+
if accepted
|
|
155
|
+
metadata = task.fetch(:execution).merge(turn_id: turn_id, message_id: message.fetch(:message_id))
|
|
156
|
+
record.update!(
|
|
157
|
+
execution: deep_stringify(metadata),
|
|
158
|
+
history: (record.history || []) + [deep_stringify(message)],
|
|
159
|
+
state: "submitted", status_timestamp: timestamp, status_message: nil, expires_at: nil
|
|
160
|
+
)
|
|
161
|
+
end
|
|
162
|
+
{ task: deserialize(record), accepted: accepted }
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
121
166
|
def cancel(task_id, timestamp: Time.now.utc, principal_id: nil)
|
|
122
167
|
timestamp = normalize_time(timestamp, field: "task status timestamp")
|
|
123
168
|
|
|
@@ -130,7 +175,7 @@ module A2A
|
|
|
130
175
|
state: "canceled",
|
|
131
176
|
status_timestamp: timestamp,
|
|
132
177
|
status_message: nil,
|
|
133
|
-
expires_at:
|
|
178
|
+
expires_at: expiration_at(timestamp)
|
|
134
179
|
)
|
|
135
180
|
|
|
136
181
|
deserialize(record)
|
|
@@ -238,7 +283,7 @@ module A2A
|
|
|
238
283
|
|
|
239
284
|
return 0 if ids.empty?
|
|
240
285
|
|
|
241
|
-
Record.where(id: ids).delete_all
|
|
286
|
+
Record.where(id: ids).where.not(expires_at: nil).where("expires_at <= ?", at).delete_all
|
|
242
287
|
end
|
|
243
288
|
|
|
244
289
|
def maintenance_stats(at: now)
|
|
@@ -258,6 +303,13 @@ module A2A
|
|
|
258
303
|
|
|
259
304
|
private
|
|
260
305
|
|
|
306
|
+
def require_execution_column!
|
|
307
|
+
return if Record.column_names.include?("execution")
|
|
308
|
+
|
|
309
|
+
raise TaskContinuationUnavailableError,
|
|
310
|
+
"Run a2a:rails:task_continuation and db:migrate before using execution turns"
|
|
311
|
+
end
|
|
312
|
+
|
|
261
313
|
def find_record!(task_id, principal_id:)
|
|
262
314
|
record = Record.where(owner_id: principal_id, task_id: task_id).first
|
|
263
315
|
raise TaskNotFoundError, task_id unless record
|
|
@@ -412,7 +464,12 @@ module A2A
|
|
|
412
464
|
}
|
|
413
465
|
}
|
|
414
466
|
|
|
415
|
-
|
|
467
|
+
unless record.status_message.nil?
|
|
468
|
+
task[:status][:message] = deserialize_part_entries([record.status_message]).first
|
|
469
|
+
end
|
|
470
|
+
if record.has_attribute?(:execution) && record.execution
|
|
471
|
+
task[:execution] = deep_symbolize(record.execution)
|
|
472
|
+
end
|
|
416
473
|
task[:history] = deserialize_part_entries(record.history) unless record.history.nil?
|
|
417
474
|
task[:artifacts] = deserialize_part_entries(record.artifacts) unless record.artifacts.nil?
|
|
418
475
|
task
|
|
@@ -32,25 +32,45 @@ module A2A
|
|
|
32
32
|
@store.save(task)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def start(task_id)
|
|
36
|
-
@store.transition(task_id, state: :working, timestamp: now, principal_id: @principal_id)
|
|
35
|
+
def start(task_id, turn_id: nil)
|
|
36
|
+
@store.transition(task_id, state: :working, timestamp: now, principal_id: @principal_id, turn_id: turn_id)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
def claim_execution(task_id)
|
|
40
|
-
@store.claim_execution(task_id, timestamp: now, principal_id: @principal_id)
|
|
39
|
+
def claim_execution(task_id, turn_id: nil)
|
|
40
|
+
@store.claim_execution(task_id, timestamp: now, principal_id: @principal_id, turn_id: turn_id)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
def complete(task_id, result)
|
|
44
|
-
|
|
43
|
+
def complete(task_id, result, turn_id: nil)
|
|
44
|
+
if result.is_a?(InputRequired)
|
|
45
|
+
question = { message_id: next_id, role: :agent, parts: result.parts }
|
|
46
|
+
transition_from_outcome(task_id, { state: :input_required, message: question }, turn_id: turn_id)
|
|
47
|
+
else
|
|
48
|
+
transition_from_outcome(task_id, @result_mapper.completed(result), turn_id: turn_id)
|
|
49
|
+
end
|
|
45
50
|
end
|
|
46
51
|
|
|
47
|
-
def reject(task_id, error)
|
|
48
|
-
transition_from_outcome(task_id, @result_mapper.rejected(error))
|
|
52
|
+
def reject(task_id, error, turn_id: nil)
|
|
53
|
+
transition_from_outcome(task_id, @result_mapper.rejected(error), turn_id: turn_id)
|
|
49
54
|
end
|
|
50
55
|
|
|
51
|
-
def fail(task_id, error)
|
|
56
|
+
def fail(task_id, error, turn_id: nil)
|
|
52
57
|
log_failure(task_id, error)
|
|
53
|
-
transition_from_outcome(task_id, @result_mapper.failed(error))
|
|
58
|
+
transition_from_outcome(task_id, @result_mapper.failed(error), turn_id: turn_id)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def configure_execution(task_id, plan:, message_id:)
|
|
62
|
+
@store.configure_execution(task_id, principal_id: @principal_id, execution: {
|
|
63
|
+
agent_class_name: plan.agent_class_name,
|
|
64
|
+
skill_id: plan.skill_id.to_s,
|
|
65
|
+
execution_mode: plan.execution_mode.to_s,
|
|
66
|
+
turn_id: next_id,
|
|
67
|
+
message_id: message_id
|
|
68
|
+
})
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def resume(task_id, message:, context_id: nil)
|
|
72
|
+
@store.resume(task_id, message: message, context_id: context_id,
|
|
73
|
+
turn_id: next_id, timestamp: now, principal_id: @principal_id)
|
|
54
74
|
end
|
|
55
75
|
|
|
56
76
|
def cancel(task_id)
|
|
@@ -67,8 +87,8 @@ module A2A
|
|
|
67
87
|
|
|
68
88
|
private
|
|
69
89
|
|
|
70
|
-
def transition_from_outcome(task_id, outcome)
|
|
71
|
-
attributes = { state: outcome.fetch(:state), timestamp: now }
|
|
90
|
+
def transition_from_outcome(task_id, outcome, turn_id: nil)
|
|
91
|
+
attributes = { state: outcome.fetch(:state), timestamp: now, turn_id: turn_id }
|
|
72
92
|
attributes[:artifacts] = outcome[:artifacts] if outcome.key?(:artifacts)
|
|
73
93
|
attributes[:message] = outcome[:message] if outcome.key?(:message)
|
|
74
94
|
@store.transition(task_id, **attributes, principal_id: @principal_id)
|
|
@@ -14,7 +14,11 @@ module A2A
|
|
|
14
14
|
MAX_PAGE_SIZE = 100
|
|
15
15
|
MAX_CACHED_PAGES = 128
|
|
16
16
|
|
|
17
|
-
def initialize
|
|
17
|
+
def initialize(max_history_entries: 100)
|
|
18
|
+
unless max_history_entries.is_a?(Integer) && max_history_entries.positive?
|
|
19
|
+
raise ArgumentError, "max_history_entries must be a positive integer"
|
|
20
|
+
end
|
|
21
|
+
@max_history_entries = max_history_entries
|
|
18
22
|
@tasks = {}
|
|
19
23
|
@pages = {}
|
|
20
24
|
@mutex = Mutex.new
|
|
@@ -22,6 +26,10 @@ module A2A
|
|
|
22
26
|
|
|
23
27
|
def save(task)
|
|
24
28
|
id = task.fetch(:id)
|
|
29
|
+
history = task[:history]
|
|
30
|
+
if history && (!history.is_a?(Array) || history.size > @max_history_entries)
|
|
31
|
+
raise TaskStorePayloadLimitError, "Task history exceeds configured limit"
|
|
32
|
+
end
|
|
25
33
|
@mutex.synchronize do
|
|
26
34
|
@tasks[id] = copy(task)
|
|
27
35
|
copy(@tasks[id])
|
|
@@ -32,10 +40,10 @@ module A2A
|
|
|
32
40
|
@mutex.synchronize { copy(find!(task_id, principal_id: principal_id)) }
|
|
33
41
|
end
|
|
34
42
|
|
|
35
|
-
def claim_execution(task_id, timestamp: Time.now.utc, principal_id: nil)
|
|
43
|
+
def claim_execution(task_id, timestamp: Time.now.utc, principal_id: nil, turn_id: nil)
|
|
36
44
|
@mutex.synchronize do
|
|
37
45
|
task = find!(task_id, principal_id: principal_id)
|
|
38
|
-
return nil unless task.dig(:status, :state) == :submitted
|
|
46
|
+
return nil unless turn_matches?(task, turn_id) && task.dig(:status, :state) == :submitted
|
|
39
47
|
|
|
40
48
|
task[:status] = status_hash(:working, timestamp, UNSET)
|
|
41
49
|
copy(task)
|
|
@@ -43,19 +51,47 @@ module A2A
|
|
|
43
51
|
end
|
|
44
52
|
|
|
45
53
|
def transition(task_id, state:, timestamp: Time.now.utc, artifacts: UNSET, message: UNSET,
|
|
46
|
-
principal_id: nil)
|
|
54
|
+
principal_id: nil, turn_id: nil)
|
|
47
55
|
validate_state!(state)
|
|
48
56
|
|
|
49
57
|
@mutex.synchronize do
|
|
50
58
|
task = find!(task_id, principal_id: principal_id)
|
|
51
|
-
return copy(task) if terminal?(task)
|
|
59
|
+
return copy(task) if terminal?(task) || !turn_matches?(task, turn_id)
|
|
60
|
+
return copy(task) if turn_id && !%i[submitted working].include?(task.dig(:status, :state))
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
if state == :input_required && message.is_a?(Hash)
|
|
63
|
+
history = task[:history] || []
|
|
64
|
+
raise TaskStorePayloadLimitError, "Task history limit reached" if history.length >= @max_history_entries
|
|
65
|
+
task[:history] = history + [copy(message)]
|
|
66
|
+
end
|
|
67
|
+
task[:status] = status_hash(state, timestamp, message.equal?(UNSET) ? UNSET : copy(message))
|
|
54
68
|
task[:artifacts] = copy(artifacts) unless artifacts.equal?(UNSET)
|
|
55
69
|
copy(task)
|
|
56
70
|
end
|
|
57
71
|
end
|
|
58
72
|
|
|
73
|
+
def configure_execution(task_id, execution:, principal_id: nil)
|
|
74
|
+
@mutex.synchronize do
|
|
75
|
+
task = find!(task_id, principal_id: principal_id)
|
|
76
|
+
task[:execution] = copy(configured_execution(task, execution))
|
|
77
|
+
copy(task)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def resume(task_id, message:, context_id: nil, turn_id:, timestamp: Time.now.utc, principal_id: nil)
|
|
82
|
+
@mutex.synchronize do
|
|
83
|
+
task = find!(task_id, principal_id: principal_id)
|
|
84
|
+
validate_turn_id!(turn_id)
|
|
85
|
+
accepted = validate_resume!(task, message, context_id, @max_history_entries)
|
|
86
|
+
if accepted
|
|
87
|
+
task[:history] = (task[:history] || []) + [copy(message)]
|
|
88
|
+
task[:execution] = task.fetch(:execution).merge(turn_id: turn_id, message_id: message.fetch(:message_id))
|
|
89
|
+
task[:status] = status_hash(:submitted, timestamp, UNSET)
|
|
90
|
+
end
|
|
91
|
+
{ task: copy(task), accepted: accepted }
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
59
95
|
def cancel(task_id, timestamp: Time.now.utc, principal_id: nil)
|
|
60
96
|
@mutex.synchronize do
|
|
61
97
|
task = find!(task_id, principal_id: principal_id)
|
data/lib/a2a/rails/task/store.rb
CHANGED
|
@@ -28,6 +28,14 @@ module A2A
|
|
|
28
28
|
raise NotImplementedError, "Task stores must implement #list"
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
def configure_execution(_task_id, execution:, principal_id: nil)
|
|
32
|
+
raise TaskContinuationUnavailableError, "Task store must implement #configure_execution for execution turns"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def resume(_task_id, message:, context_id: nil, turn_id:, principal_id: nil, **_attributes)
|
|
36
|
+
raise TaskContinuationUnavailableError, "Task store must implement atomic #resume"
|
|
37
|
+
end
|
|
38
|
+
|
|
31
39
|
def prune_expired(**_options)
|
|
32
40
|
raise NotImplementedError, "Task store does not implement maintenance pruning"
|
|
33
41
|
end
|
|
@@ -35,6 +43,75 @@ module A2A
|
|
|
35
43
|
def maintenance_stats(**_options)
|
|
36
44
|
raise NotImplementedError, "Task store does not implement maintenance stats"
|
|
37
45
|
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def turn_matches?(task, turn_id)
|
|
50
|
+
task.dig(:execution, :turn_id) == turn_id
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def validate_turn_id!(turn_id)
|
|
54
|
+
unless turn_id.is_a?(String) && !turn_id.empty?
|
|
55
|
+
raise TaskContinuationUnavailableError, "Execution turn_id must be a nonempty String"
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def configured_execution(task, execution)
|
|
60
|
+
unless task.dig(:status, :state) == :submitted && task[:execution].nil?
|
|
61
|
+
raise TaskContinuationUnavailableError, "Execution can only be configured once on a submitted Task"
|
|
62
|
+
end
|
|
63
|
+
required = %i[skill_id execution_mode turn_id message_id]
|
|
64
|
+
unless execution.is_a?(Hash) && required.all? { |key| !execution[key].to_s.empty? }
|
|
65
|
+
raise TaskContinuationUnavailableError, "Execution metadata is incomplete"
|
|
66
|
+
end
|
|
67
|
+
validate_turn_id!(execution[:turn_id])
|
|
68
|
+
execution.merge(skill_id: execution[:skill_id].to_s, execution_mode: execution[:execution_mode].to_s)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Returns false for a previously accepted reply. The initial message is
|
|
72
|
+
# deliberately not a continuation receipt; new-Task dedupe is out of scope.
|
|
73
|
+
def validate_resume!(task, message, context_id, limit)
|
|
74
|
+
if !context_id.nil? && context_id != task.fetch(:context_id)
|
|
75
|
+
raise TaskContextMismatchError, "Message context does not match Task"
|
|
76
|
+
end
|
|
77
|
+
unless task[:execution].is_a?(Hash)
|
|
78
|
+
raise TaskContinuationUnavailableError, "Legacy Task has no continuation metadata"
|
|
79
|
+
end
|
|
80
|
+
unless message.is_a?(Hash) && !message[:message_id].to_s.empty?
|
|
81
|
+
raise InvalidRequestError, "Continuation message_id is required"
|
|
82
|
+
end
|
|
83
|
+
history = task[:history] || []
|
|
84
|
+
prior_index = history.index { |entry| entry[:message_id] == message[:message_id] }
|
|
85
|
+
if prior_index
|
|
86
|
+
prior = history.fetch(prior_index)
|
|
87
|
+
unless prior_index.positive? && prior[:role].to_s == "user" && canonical_message(prior) == canonical_message(message)
|
|
88
|
+
raise TaskMessageConflictError, "Message ID has already been used with a different request"
|
|
89
|
+
end
|
|
90
|
+
return false
|
|
91
|
+
end
|
|
92
|
+
unless task.dig(:status, :state) == :input_required
|
|
93
|
+
raise TaskNotResumableError.new(task.fetch(:id), state: task.dig(:status, :state))
|
|
94
|
+
end
|
|
95
|
+
# Reserve one slot for the handler's next question. Do not execute a
|
|
96
|
+
# reply whose question cannot be persisted without discarding input.
|
|
97
|
+
if history.length + 2 > limit
|
|
98
|
+
raise TaskStorePayloadLimitError, "Task history limit reached; cancel and start a new Task"
|
|
99
|
+
end
|
|
100
|
+
true
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def canonical_message(value)
|
|
104
|
+
case value
|
|
105
|
+
when Hash
|
|
106
|
+
value.to_h { |key, item| [key.to_s, canonical_message(item)] }
|
|
107
|
+
when Array
|
|
108
|
+
value.map { |item| canonical_message(item) }
|
|
109
|
+
when Symbol
|
|
110
|
+
value.to_s
|
|
111
|
+
else
|
|
112
|
+
value
|
|
113
|
+
end
|
|
114
|
+
end
|
|
38
115
|
end
|
|
39
116
|
end
|
|
40
117
|
end
|
data/lib/a2a/rails/task.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module A2A
|
|
4
4
|
module Rails
|
|
5
5
|
module Task
|
|
6
|
-
STATES = %i[submitted working completed failed rejected canceled].freeze
|
|
6
|
+
STATES = %i[submitted working input_required completed failed rejected canceled].freeze
|
|
7
7
|
TERMINAL_STATES = %i[completed failed rejected canceled].freeze
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -7,19 +7,24 @@ module A2A
|
|
|
7
7
|
MAX_CLASS_NAME_BYTES = 512
|
|
8
8
|
KEYS = %i[task_id principal_id agent_class_name skill_id].freeze
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
OPTIONAL_KEYS = %i[turn_id].freeze
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
attr_reader(*(KEYS + OPTIONAL_KEYS))
|
|
13
|
+
|
|
14
|
+
def initialize(task_id:, principal_id:, agent_class_name:, skill_id:, turn_id: nil)
|
|
13
15
|
@task_id = normalize_identifier(task_id, "task_id")
|
|
14
16
|
@principal_id = normalize_principal_id(principal_id)
|
|
15
17
|
@agent_class_name = normalize_agent_class_name(agent_class_name)
|
|
16
18
|
@skill_id = normalize_skill_id(skill_id)
|
|
19
|
+
@turn_id = turn_id.nil? ? nil : normalize_identifier(turn_id, "turn_id")
|
|
17
20
|
@payload = {
|
|
18
21
|
task_id: @task_id,
|
|
19
22
|
principal_id: @principal_id,
|
|
20
23
|
agent_class_name: @agent_class_name,
|
|
21
24
|
skill_id: @skill_id
|
|
22
|
-
}
|
|
25
|
+
}
|
|
26
|
+
@payload[:turn_id] = @turn_id unless @turn_id.nil?
|
|
27
|
+
@payload.freeze
|
|
23
28
|
freeze
|
|
24
29
|
end
|
|
25
30
|
|
|
@@ -10,17 +10,19 @@ module A2A
|
|
|
10
10
|
# immediate and independent from any surrounding host Active Record transaction.
|
|
11
11
|
self.enqueue_after_transaction_commit = false
|
|
12
12
|
|
|
13
|
-
def perform(task_id:, principal_id:, agent_class_name:, skill_id:)
|
|
13
|
+
def perform(task_id:, principal_id:, agent_class_name:, skill_id:, turn_id: nil)
|
|
14
14
|
arguments = TaskExecutionArguments.new(
|
|
15
15
|
task_id: task_id,
|
|
16
16
|
principal_id: principal_id,
|
|
17
17
|
agent_class_name: agent_class_name,
|
|
18
|
-
skill_id: skill_id
|
|
18
|
+
skill_id: skill_id,
|
|
19
|
+
turn_id: turn_id
|
|
19
20
|
)
|
|
20
21
|
task_id = arguments.task_id
|
|
21
22
|
principal_id = arguments.principal_id
|
|
22
23
|
agent_class_name = arguments.agent_class_name
|
|
23
24
|
skill_id = arguments.skill_id
|
|
25
|
+
turn_id = arguments.turn_id
|
|
24
26
|
|
|
25
27
|
configuration = A2A::Rails.configuration
|
|
26
28
|
lifecycle = Task::Lifecycle.new(
|
|
@@ -29,7 +31,7 @@ module A2A
|
|
|
29
31
|
principal_id: principal_id
|
|
30
32
|
)
|
|
31
33
|
|
|
32
|
-
claimed = lifecycle.claim_execution(task_id)
|
|
34
|
+
claimed = lifecycle.claim_execution(task_id, turn_id: turn_id)
|
|
33
35
|
return unless claimed
|
|
34
36
|
|
|
35
37
|
agent = configuration.resolve_agent
|
|
@@ -37,7 +39,9 @@ module A2A
|
|
|
37
39
|
raise ConfigurationError, "Queued Agent no longer matches configured Agent"
|
|
38
40
|
end
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
verify_execution!(claimed, agent_class_name: agent_class_name, skill_id: skill_id,
|
|
43
|
+
turn_id: turn_id)
|
|
44
|
+
message = execution_message(claimed)
|
|
41
45
|
plan = ExecutionPlan.new(
|
|
42
46
|
agent_class_name: agent_class_name,
|
|
43
47
|
skill_id: skill_id,
|
|
@@ -47,7 +51,9 @@ module A2A
|
|
|
47
51
|
task_id: task_id,
|
|
48
52
|
context_id: claimed.fetch(:context_id),
|
|
49
53
|
principal_id: principal_id,
|
|
50
|
-
idempotency_key: task_id
|
|
54
|
+
idempotency_key: task_id,
|
|
55
|
+
execution_turn_id: turn_id,
|
|
56
|
+
history: copy(claimed.fetch(:history))
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
result = Dispatcher.new(agent: agent, configuration: configuration).execute(
|
|
@@ -55,24 +61,53 @@ module A2A
|
|
|
55
61
|
message: message,
|
|
56
62
|
context: context
|
|
57
63
|
)
|
|
58
|
-
lifecycle.complete(task_id, result)
|
|
64
|
+
lifecycle.complete(task_id, result, turn_id: turn_id)
|
|
59
65
|
rescue RejectedTask => error
|
|
60
|
-
lifecycle
|
|
66
|
+
lifecycle.reject(task_id, error, turn_id: turn_id) if claimed
|
|
61
67
|
rescue TaskNotFoundError
|
|
62
68
|
nil
|
|
63
69
|
rescue StandardError => error
|
|
64
|
-
lifecycle
|
|
70
|
+
lifecycle.fail(task_id, error, turn_id: turn_id) if claimed
|
|
65
71
|
end
|
|
66
72
|
|
|
67
73
|
private
|
|
68
74
|
|
|
69
|
-
def
|
|
75
|
+
def verify_execution!(task, agent_class_name:, skill_id:, turn_id:)
|
|
76
|
+
execution = task[:execution]
|
|
77
|
+
return if execution.nil? && turn_id.nil?
|
|
78
|
+
|
|
79
|
+
unless execution.is_a?(Hash) && execution[:turn_id] == turn_id &&
|
|
80
|
+
execution[:agent_class_name] == agent_class_name &&
|
|
81
|
+
execution[:skill_id].to_s == skill_id && execution[:execution_mode].to_s == "async"
|
|
82
|
+
raise ConfigurationError, "Queued execution does not match saved Task execution"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def execution_message(task)
|
|
70
87
|
history = task[:history]
|
|
71
|
-
unless history.is_a?(Array)
|
|
72
|
-
raise ConfigurationError, "Queued Task does not contain
|
|
88
|
+
unless history.is_a?(Array)
|
|
89
|
+
raise ConfigurationError, "Queued Task does not contain Message history"
|
|
73
90
|
end
|
|
74
91
|
|
|
75
|
-
|
|
92
|
+
execution = task[:execution]
|
|
93
|
+
message = if execution
|
|
94
|
+
history.find do |entry|
|
|
95
|
+
entry.is_a?(Hash) && entry[:role].to_s == "user" &&
|
|
96
|
+
entry[:message_id] == execution.fetch(:message_id)
|
|
97
|
+
end
|
|
98
|
+
else
|
|
99
|
+
# Jobs serialized by 0.4.0 remain executable only for legacy Tasks.
|
|
100
|
+
history.first
|
|
101
|
+
end
|
|
102
|
+
unless message.is_a?(Hash)
|
|
103
|
+
raise ConfigurationError, "Queued Task does not contain its execution Message"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
copy(message)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def copy(value)
|
|
110
|
+
Marshal.load(Marshal.dump(value))
|
|
76
111
|
end
|
|
77
112
|
end
|
|
78
113
|
end
|
data/lib/a2a/rails/version.rb
CHANGED
data/lib/a2a-rails.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative "a2a/rails/version"
|
|
4
4
|
require_relative "a2a/rails/errors"
|
|
5
5
|
require_relative "a2a/rails/file_artifact"
|
|
6
|
+
require_relative "a2a/rails/input_required"
|
|
6
7
|
require_relative "a2a/rails/authentication"
|
|
7
8
|
require_relative "a2a/rails/request_guard"
|
|
8
9
|
require_relative "a2a/rails/configuration"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "task_store_generator"
|
|
4
|
+
|
|
5
|
+
module A2A
|
|
6
|
+
module Rails
|
|
7
|
+
class TaskContinuationGenerator < ::Rails::Generators::Base
|
|
8
|
+
include ::Rails::Generators::Migration
|
|
9
|
+
|
|
10
|
+
namespace "a2a:rails:task_continuation"
|
|
11
|
+
source_root File.expand_path("templates", __dir__)
|
|
12
|
+
|
|
13
|
+
def self.next_migration_number(dirname)
|
|
14
|
+
::ActiveRecord::Generators::Base.next_migration_number(dirname)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create_continuation_migration
|
|
18
|
+
migration_template(
|
|
19
|
+
"add_execution_to_a2a_rails_tasks.rb.tt",
|
|
20
|
+
"db/migrate/add_execution_to_a2a_rails_tasks.rb"
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: a2a-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- cuichangquan
|
|
@@ -23,6 +23,26 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: 2.0.0
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: regexp_parser
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.0'
|
|
33
|
+
- - "<"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: 2.13.2
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - "~>"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '2.0'
|
|
43
|
+
- - "<"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 2.13.2
|
|
26
46
|
- !ruby/object:Gem::Dependency
|
|
27
47
|
name: actionpack
|
|
28
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -242,6 +262,7 @@ files:
|
|
|
242
262
|
- lib/a2a/rails/errors.rb
|
|
243
263
|
- lib/a2a/rails/execution_plan.rb
|
|
244
264
|
- lib/a2a/rails/file_artifact.rb
|
|
265
|
+
- lib/a2a/rails/input_required.rb
|
|
245
266
|
- lib/a2a/rails/protocol/adapter.rb
|
|
246
267
|
- lib/a2a/rails/protocol/agent2agent_adapter.rb
|
|
247
268
|
- lib/a2a/rails/protocol/part_data.rb
|
|
@@ -262,7 +283,9 @@ files:
|
|
|
262
283
|
- lib/a2a/rails/version.rb
|
|
263
284
|
- lib/generators/a2a/rails/agent_generator.rb
|
|
264
285
|
- lib/generators/a2a/rails/install_generator.rb
|
|
286
|
+
- lib/generators/a2a/rails/task_continuation_generator.rb
|
|
265
287
|
- lib/generators/a2a/rails/task_store_generator.rb
|
|
288
|
+
- lib/generators/a2a/rails/templates/add_execution_to_a2a_rails_tasks.rb.tt
|
|
266
289
|
- lib/generators/a2a/rails/templates/agent.rb.tt
|
|
267
290
|
- lib/generators/a2a/rails/templates/create_a2a_rails_tasks.rb.tt
|
|
268
291
|
- lib/generators/a2a/rails/templates/initializer.rb.tt
|