ruby_llm-ag_ui 1.0.0 → 1.0.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 +9 -0
- data/CONTRIBUTING.md +1 -3
- data/README.md +3 -4
- data/docs/_getting_started/getting-started.md +1 -1
- data/docs/_getting_started/whats-new-in-1-0.md +1 -1
- data/docs/_reference/compatibility.md +33 -3
- data/docs/_reference/release-history.md +1 -0
- data/docs/_reference/releasing.md +1 -4
- data/docs/_reference/upgrading.md +6 -0
- data/lib/ruby_llm/ag_ui/chat_approvals.rb +51 -0
- data/lib/ruby_llm/ag_ui/error_sanitizer.rb +3 -0
- data/lib/ruby_llm/ag_ui/mapper.rb +1 -1
- data/lib/ruby_llm/ag_ui/resume.rb +7 -2
- data/lib/ruby_llm/ag_ui/run.rb +3 -19
- data/lib/ruby_llm/ag_ui/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5d6d14a4cdc042f1a68d5ddd65e4f2483da6b09570d0b1e8987d8c24c707ef6f
|
|
4
|
+
data.tar.gz: 5d46bc1aa18df9d72dd5414e9f9095a7b012600db32dcb472c0889dcedcc2eb4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: acfd1ba767662677dd91fbc91a2cbccae75b21656b5b7caefc10486d70869edeb88fd34a9c4d2eb77178697fca3db3d75d2afe01d4464359eedf8dbf2f61c413
|
|
7
|
+
data.tar.gz: dd47bde0daeca4bf8f3990a2c88d213f836d72b8307aa5e91d94d278636217052cc4e1b96439beeaa1b445c936c2966b9c81db29b4d81935d1c92b4f6f3245d7
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,15 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.0.1] - 2026-12-03
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Stream tool arguments on RubyLLM 2.2.3 and associate the result with the same RubyLLM invocation ID across approval, denial, and reconnect.
|
|
14
|
+
- Read pending approvals from RubyLLM 2.2 questions. Other pauses still return `unsupported_run_state`. RubyLLM 2.1 keeps its existing approval path.
|
|
15
|
+
- Resume Rails approvals saved before RubyLLM 2.2 introduced its pending marker. Check the stored call and its arguments against the authorized chat after reload.
|
|
16
|
+
- Preserve the public transport error code when RubyLLM wraps a Faraday timeout or connection failure.
|
|
17
|
+
|
|
9
18
|
## [1.0.0] - 2026-11-02
|
|
10
19
|
|
|
11
20
|
The stable integration contract. The public API, configuration, and store
|
data/CONTRIBUTING.md
CHANGED
|
@@ -41,9 +41,7 @@ The package probe installs the artifact outside the checkout using available
|
|
|
41
41
|
development dependencies; `bin/verify-package` separately tests clean dependency
|
|
42
42
|
resolution. Shut down all task-owned processes when the check finishes.
|
|
43
43
|
|
|
44
|
-
Before a release, build the gem and run `bundle exec ruby bin/verify-upgrade`
|
|
45
|
-
with the downloaded previous release's gem path. It checks installed artifacts in
|
|
46
|
-
separate processes against one temporary SQLite database, without a provider.
|
|
44
|
+
Before a release, build the gem and run `bundle exec ruby bin/verify-upgrade` with the downloaded previous release's gem path. For the 1.0.1 check, install RubyLLM 2.1.1 alongside the candidate bundle's 2.2.3 so each subprocess can activate its own version. The offline probe uses a shared temporary SQLite database.
|
|
47
45
|
|
|
48
46
|
Every behavior change needs a test, and lifecycle, identity and security changes
|
|
49
47
|
need their negative case too. The acceptance IDs (FR-01..FR-08) are referenced
|
data/README.md
CHANGED
|
@@ -19,11 +19,10 @@ RubyLLM and AG-UI maintainers.
|
|
|
19
19
|
## Install
|
|
20
20
|
|
|
21
21
|
```ruby
|
|
22
|
-
gem 'ruby_llm-ag_ui', '~> 1.0'
|
|
22
|
+
gem 'ruby_llm-ag_ui', '~> 1.0', '>= 1.0.1'
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
Run `bundle install` after adding the gem.
|
|
25
|
+
Run `bundle install` after adding the gems. Version 1.0.1 supports RubyLLM 2.1.0, 2.1.1, and 2.2.3. It requires Ruby >= 3.3 and `ag-ui-protocol` 0.2.x.
|
|
27
26
|
|
|
28
27
|
## Stream a run
|
|
29
28
|
|
|
@@ -60,7 +59,7 @@ bundle exec rake example # offline approval and resume demo, no API key needed
|
|
|
60
59
|
The default suite is offline. Real client and provider verification is tracked
|
|
61
60
|
in the [compatibility guide](https://rubyllm-ag-ui.wangyaodi.com/compatibility/).
|
|
62
61
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for development and documentation rules,
|
|
63
|
-
[ROADMAP.md](ROADMAP.md) for the proposed
|
|
62
|
+
[ROADMAP.md](ROADMAP.md) for the proposed releases after 1.0, and
|
|
64
63
|
[CHANGELOG.md](CHANGELOG.md) for shipped changes.
|
|
65
64
|
|
|
66
65
|
## License and security
|
|
@@ -22,7 +22,7 @@ After reading this guide, you will know:
|
|
|
22
22
|
{% if site.docs_unreleased %}bundle add ruby_llm-ag_ui --git https://github.com/yorzi/ruby_llm-ag-ui --branch main{% else %}bundle add ruby_llm-ag_ui --version {{ site.version }}{% endif %}
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Use Ruby 3.3 or newer and `ag-ui-protocol` 0.2.x. The 1.0.1 adapter supports RubyLLM 2.1.0, 2.1.1, and 2.2.3. If you install 1.0.0, pin RubyLLM to 2.1.1. The Rails adapter is optional. You can run the parser example below without provider credentials. See [Compatibility]({% link _reference/compatibility.md %}) for the tested versions.
|
|
26
26
|
|
|
27
27
|
The runtime dependencies select patched `cgi`, `resolv`, `uri`, and `zlib` gems. An older Ruby installation's default library versions do not override those dependency requirements.
|
|
28
28
|
|
|
@@ -32,7 +32,7 @@ Report a problem with the versions from `RubyLLM::AgUI.config.to_h`, as
|
|
|
32
32
|
## Use Ruby 3.3 or Newer
|
|
33
33
|
|
|
34
34
|
Ruby 3.2 reached end of life in March 2026, and 1.0 requires Ruby 3.3 or newer.
|
|
35
|
-
CI
|
|
35
|
+
The 1.0.0 CI matrix covered Ruby 3.3, 3.4, and 4.0 with RubyLLM 2.1.0 and 2.1.1. Patch 1.0.1 adds RubyLLM 2.2.3 and restores tool streaming, approval, and transport error handling on that version. See [Upgrading]({% link _reference/upgrading.md %}).
|
|
36
36
|
|
|
37
37
|
## Stream Tool Calls Correctly Across Protocols
|
|
38
38
|
|
|
@@ -24,7 +24,7 @@ dependency does.
|
|
|
24
24
|
| Component | Range | Evidence |
|
|
25
25
|
|---|---|---|
|
|
26
26
|
| Ruby | `>= 3.3` | Recorded 0.4 CI passes on 3.3.12 and 3.4.11; 4.0.9 passes locally, and CI now includes 4.0. Ruby 3.2 is no longer supported |
|
|
27
|
-
| RubyLLM | `>= 2.1`, `< 3.0` | 2.1.0 and 2.1.1
|
|
27
|
+
| RubyLLM | `>= 2.1`, `< 3.0` | 2.1.0 and 2.1.1 passed 1.0.0 release CI. The 1.0.1 local checks include 2.2.3. |
|
|
28
28
|
| `ag-ui-protocol` | `~> 0.2.0` | 0.2.0 |
|
|
29
29
|
| JSON | `>= 2.0`, `< 3` | 2.21.2 passes both Rails lines; JSON 3 removes the `quirks_mode` option used by Rails 8.0 |
|
|
30
30
|
| Rails (adapter only) | `railties`, `actionpack`, `activerecord` `>= 8.0` | Recorded 0.4 CI passes on 8.0.5.1 and 8.1.4 with Ruby 3.3/3.4; both pass locally on Ruby 4.0.9 |
|
|
@@ -35,6 +35,20 @@ standard-library gems required by the gemspec. Rails,
|
|
|
35
35
|
`ToolViews`, `OpenUI` and `OddlyDock` are not runtime dependencies, and the Rails
|
|
36
36
|
adapter is only loaded when `Rails::Railtie` is already defined.
|
|
37
37
|
|
|
38
|
+
## RubyLLM 2.2.3 in 1.0.1
|
|
39
|
+
|
|
40
|
+
On Ruby 3.3.5, the local 1.0.1 suite reports 322 examples on each of RubyLLM 2.1.0 and 2.1.1, and 323 on 2.2.3. Each run has zero failures and skips two opt-in provider checks. The pinned browser client passes 18 workflows against scripted chats, with all 242 received events schema-valid.
|
|
41
|
+
|
|
42
|
+
The 1.0.1 integration suite covers Chat Completions, Responses, Anthropic, and Gemini tool streams with intercepted HTTP. It matches browser-facing call IDs to the RubyLLM invocation, handles approval questions through the 2.2 API, and preserves timeout and connection error codes. Ordinary questions and background task pauses without a pending approval still end with `unsupported_run_state`.
|
|
43
|
+
|
|
44
|
+
A separate upgrade probe starts with the published 1.0.0 gem and RubyLLM 2.1.1. It persists two interrupts in SQLite and saves the assistant tool calls. A fresh process running the installed 1.0.1 gem and RubyLLM 2.2.3 restores the calls, approves one and declines the other. An exact retry returns the recorded result. The fixture records one tool execution for approval and zero for denial. The installed Rails host separately exercises a reloaded Active Record chat with the old empty approval marker, including refusal after its saved arguments change. These are local, offline checks using intercepted HTTP. See [Upgrading]({% link _reference/upgrading.md %}).
|
|
45
|
+
|
|
46
|
+
## Using gem version 1.0.0 with RubyLLM
|
|
47
|
+
|
|
48
|
+
Pin `gem "ruby_llm", "2.1.1"` in your Gemfile when using 1.0.0. Bundler also permits 2.2.3. On 2026-12-03 the same checkout on Ruby 3.3.5 ran 321 examples with zero failures on 2.1.1 and 36 failures on 2.2.3. Both runs skipped the two opt-in live checks. On 2.1.1 the pinned browser client also passed 18 scripted workflows and all 242 consumed events passed schema validation.
|
|
49
|
+
|
|
50
|
+
With 2.2.3 the mapper expects key/value pairs while the tool-call collection yields call objects. The intercepted approval and denial flows both fail before they present an interrupt. A provider timeout also reaches the client as `provider_error` instead of `transport_timeout`. The focused reproduction is `bundle exec rspec spec/integration/live_harness_spec.rb` with `RUBY_LLM_VERSION=2.2.3` resolved in a separate bundle. These checks use a real RubyLLM chat and intercepted HTTP.
|
|
51
|
+
|
|
38
52
|
## What is asserted, and how
|
|
39
53
|
|
|
40
54
|
| Claim | How it is checked |
|
|
@@ -62,6 +76,22 @@ Version 1.0.0 was rehearsed as the local, unpublished candidate 1.0.0.rc.1 and
|
|
|
62
76
|
published after the maintainer's acceptance. The dated reviews below record that
|
|
63
77
|
candidate. The 2026-10-21 evidence records the earlier rehearsal.
|
|
64
78
|
|
|
79
|
+
### Published 1.0.0 Artifact
|
|
80
|
+
|
|
81
|
+
The [release CI](https://github.com/yorzi/ruby_llm-ag-ui/actions/runs/41449302653) passes all 21 jobs at `e80dfdd`:
|
|
82
|
+
Ruby 3.3, 3.4, and 4.0 with RubyLLM 2.1.0 and 2.1.1; Rails 8.0 and 8.1 on each
|
|
83
|
+
Ruby; lint, installed-host checks, and the browser suite. The
|
|
84
|
+
[release workflow](https://github.com/yorzi/ruby_llm-ag-ui/actions/runs/41449675749) verifies the tagged package and
|
|
85
|
+
publishes it through trusted publishing.
|
|
86
|
+
|
|
87
|
+
The RubyGems and GitHub Release downloads have the same SHA-256,
|
|
88
|
+
`28a223ca6f668f077f677e72c6040da7ae9387d828be86e3f11cd35c8909a762`, which matches
|
|
89
|
+
`SHA256SUMS` and the RubyGems metadata. All 67 packaged files match `v1.0.0`
|
|
90
|
+
byte for byte. The downloaded gem passes both installed endpoints, clean core
|
|
91
|
+
and Rails installation, and the activated-dependency advisory check without
|
|
92
|
+
being rebuilt. The stable documentation, the 0.4 archive at `/v0/`, and `/next/`
|
|
93
|
+
serve the expected versions.
|
|
94
|
+
|
|
65
95
|
### Release Verification on 2026-11-02
|
|
66
96
|
|
|
67
97
|
The 1.0.0 release commit passes 321 offline examples with zero failures and two
|
|
@@ -333,7 +363,7 @@ checks after download.
|
|
|
333
363
|
providers, cancellation timing, timeouts, and network-loss recovery need
|
|
334
364
|
separate evidence.
|
|
335
365
|
- **Every RubyLLM patch release in the `>= 2.1, < 3.0` range.** The upper bound
|
|
336
|
-
is a dependency resolver bound; verified versions
|
|
366
|
+
is a dependency resolver bound; verified versions for 1.0.1 include 2.1.0, 2.1.1, and 2.2.3. Future
|
|
337
367
|
2.x releases need the same checks before a compatibility claim.
|
|
338
368
|
- **Rails versions before 8.0.** The adapter uses `Rails.setup!` and an
|
|
339
369
|
initializer, and its specs run on 8.0/8.1. It may work on 7.2 and it is not
|
|
@@ -379,7 +409,7 @@ the local subclasses should be removed rather than kept.
|
|
|
379
409
|
|
|
380
410
|
**A new RubyLLM 2.x minor** can change the callback contract (`before_tool_call`,
|
|
381
411
|
`after_message`, `complete`'s streaming block), approval state (`waiting?`,
|
|
382
|
-
|
|
412
|
+
the 2.1 approval methods, or 2.2 questions and decisions) or the shape of
|
|
383
413
|
chunks and messages. The mapper and run specs pin all of it, so an upgrade fails
|
|
384
414
|
loudly instead of silently dropping content. A 3.0 would need a new adapter
|
|
385
415
|
layer; the gemspec refuses it.
|
|
@@ -17,6 +17,7 @@ description: Review RubyLLM AG-UI releases, newest first, with highlights and up
|
|
|
17
17
|
|
|
18
18
|
| Release | Date | Highlights |
|
|
19
19
|
| --- | --- | --- |
|
|
20
|
+
| [1.0.1](https://github.com/yorzi/ruby_llm-ag-ui/releases/tag/v1.0.1) | 2026-12-03 | RubyLLM 2.2.3 tool streaming and approval, Rails approval recovery after upgrade, and transport error classification. See [Upgrading]({% link _reference/upgrading.md %}). |
|
|
20
21
|
| [1.0.0](https://github.com/yorzi/ruby_llm-ag-ui/releases/tag/v1.0.0) | 2026-11-02 | [Stable integration contract]({% link _getting_started/whats-new-in-1-0.md %}): streamed tool calls fixed across provider protocols, Ruby 3.3 or newer, and a rehearsed upgrade from 0.4 |
|
|
21
22
|
| [0.4.0](https://github.com/yorzi/ruby_llm-ag-ui/releases/tag/v0.4.0) | 2026-10-21 | [API and compatibility]({% link _reference/whats-new-in-0-4.md %}): effective configuration, immutable records, and real-chat approval verification |
|
|
22
23
|
| [0.3.0](https://github.com/yorzi/ruby_llm-ag-ui/releases/tag/v0.3.0) | 2026-10-20 | [Lifecycle and worker recovery]({% link _reference/whats-new-in-0-3.md %}): disconnect handling, scoped cancellation, and conditional durable writes |
|
|
@@ -45,10 +45,7 @@ the public contract or its upgrade path, build the artifact, run
|
|
|
45
45
|
`bundle exec ruby bin/verify-upgrade` with the previous published gem, and
|
|
46
46
|
install it in a real application before you tag.
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
for proposed iterations and the 1.0 release conditions. Guides describe available
|
|
50
|
-
behavior; the roadmap describes planned work. Check the release's conditions
|
|
51
|
-
before preparing its tag.
|
|
48
|
+
Check the proposed release and its acceptance criteria before preparing its tag. See the [roadmap](https://github.com/yorzi/ruby_llm-ag-ui/blob/main/ROADMAP.md).
|
|
52
49
|
|
|
53
50
|
## Configure Trusted Publishing
|
|
54
51
|
|
|
@@ -15,6 +15,12 @@ After reading this guide, you will know:
|
|
|
15
15
|
* How to move between versioned releases.
|
|
16
16
|
* Where to find changes that need code updates.
|
|
17
17
|
|
|
18
|
+
## Move from 1.0.0 to 1.0.1
|
|
19
|
+
|
|
20
|
+
Upgrade the adapter before updating RubyLLM to 2.2.3. You can keep RubyLLM 2.1.0 or 2.1.1. The adapter uses the existing run table and initializer.
|
|
21
|
+
|
|
22
|
+
Treat `toolCallId` as opaque. RubyLLM 2.2.3 assigns its own invocation ID. The tool events, approval interrupt, and resumed result use the same ID, which can differ from the provider's. When restoring a chat with a pending approval, keep the original RubyLLM call ID and arguments. Answer the stored interrupt using its `interruptId`. The adapter upgrade test reloads a 1.0.0 completed run and both approval decisions from SQLite. On Rails, load the authorized chat with its registered tools before passing it to the adapter. RubyLLM 2.2 leaves pre-upgrade approvals out of the record’s `pending_questions`. For an existing interrupt, the adapter checks the undecided database row, the host chat’s pending call, and the original arguments before applying the decision. Follow RubyLLM’s database upgrade instructions for its own models.
|
|
23
|
+
|
|
18
24
|
## Move from 0.4 to 1.0
|
|
19
25
|
|
|
20
26
|
Update your Gemfile and dependency:
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RubyLLM
|
|
4
|
+
module AgUI
|
|
5
|
+
# Internal adapter for RubyLLM's approval APIs across the 2.1 and 2.2 lines.
|
|
6
|
+
module ChatApprovals # :nodoc:
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
def pending(chat, previous_ids: [])
|
|
10
|
+
return chat.pending_approvals unless chat.respond_to?(:pending_questions)
|
|
11
|
+
|
|
12
|
+
calls = approval_calls(chat)
|
|
13
|
+
return calls unless chat.respond_to?(:find_tool_call) && chat.respond_to?(:to_llm)
|
|
14
|
+
|
|
15
|
+
missing = previous_ids - calls.map(&:id)
|
|
16
|
+
calls + missing.filter_map { |id| unmarked_call(chat, id) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def approval_calls(chat)
|
|
20
|
+
chat.pending_questions.filter_map { |question| question.tool_call if question.approval? }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# RubyLLM 2.1 left persisted approval markers nil. Confirm the old
|
|
24
|
+
# interrupt against both the scoped database row and the host's tools.
|
|
25
|
+
def unmarked_call(chat, id)
|
|
26
|
+
row = chat.find_tool_call(id)
|
|
27
|
+
return unless row && row.approval.nil? && row.result_id.nil?
|
|
28
|
+
|
|
29
|
+
call = approval_calls(chat.to_llm).find { |pending| pending.id == id }
|
|
30
|
+
call if call && Canonical.digest(call.arguments) == Canonical.digest(row.arguments)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def interrupts(calls, expires_at:)
|
|
34
|
+
raise UnsupportedRunStateError if calls.empty?
|
|
35
|
+
|
|
36
|
+
calls.map do |call|
|
|
37
|
+
Interrupt.create(tool_call_id: call.id, arguments_digest: Canonical.digest(call.arguments),
|
|
38
|
+
expires_at: expires_at, message: "Approve the #{call.name} tool call?")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def deny(chat, call_id)
|
|
43
|
+
if chat.respond_to?(:pending_questions)
|
|
44
|
+
chat.decline(call_id)
|
|
45
|
+
else
|
|
46
|
+
chat.deny(call_id)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -52,6 +52,9 @@ module RubyLLM
|
|
|
52
52
|
|
|
53
53
|
# Returns a [message, code] pair safe to put on the wire.
|
|
54
54
|
def sanitize(error)
|
|
55
|
+
if defined?(RubyLLM::ConnectionError) && error.is_a?(RubyLLM::ConnectionError) && error.cause.is_a?(Faraday::Error)
|
|
56
|
+
error = error.cause
|
|
57
|
+
end
|
|
55
58
|
match = classify(error)
|
|
56
59
|
match || FALLBACK
|
|
57
60
|
end
|
|
@@ -191,7 +191,7 @@ module RubyLLM
|
|
|
191
191
|
def tool_call_events(tool_calls, streamed:)
|
|
192
192
|
return [] if tool_calls.nil? || tool_calls.empty?
|
|
193
193
|
|
|
194
|
-
tool_calls.flat_map do |key, tool_call|
|
|
194
|
+
tool_calls.to_h.flat_map do |key, tool_call|
|
|
195
195
|
next [] if @continued_tool_call_ids&.include?(tool_call.id)
|
|
196
196
|
|
|
197
197
|
record = track(key, tool_call, streamed: streamed)
|
|
@@ -19,12 +19,15 @@ module RubyLLM
|
|
|
19
19
|
# One entry's effect: the interrupt it answers and the decision to record.
|
|
20
20
|
Decision = Struct.new(:interrupt, :decision, keyword_init: true)
|
|
21
21
|
|
|
22
|
+
attr_reader :previous_call_ids
|
|
23
|
+
|
|
22
24
|
def initialize(input:, store:, scope:, chat:)
|
|
23
25
|
@input = input
|
|
24
26
|
@store = store
|
|
25
27
|
@scope = scope
|
|
26
28
|
@chat = chat
|
|
27
29
|
@plan = []
|
|
30
|
+
@previous_call_ids = []
|
|
28
31
|
end
|
|
29
32
|
|
|
30
33
|
# Whether the input answers anything at all.
|
|
@@ -40,6 +43,7 @@ module RubyLLM
|
|
|
40
43
|
return self if existing
|
|
41
44
|
|
|
42
45
|
source = interrupted_run
|
|
46
|
+
@previous_call_ids = source.pending_interrupts.map(&:tool_call_id)
|
|
43
47
|
@plan = @input.resume.map { |entry| plan_entry(source, entry, now) }
|
|
44
48
|
self
|
|
45
49
|
end
|
|
@@ -91,7 +95,8 @@ module RubyLLM
|
|
|
91
95
|
redemption = persist_decision(planned, now: now)
|
|
92
96
|
raise ResumeRejectedError, "interrupt #{planned.interrupt.id} was already answered" if redemption.replayed?
|
|
93
97
|
|
|
94
|
-
|
|
98
|
+
id = redemption.tool_call_id
|
|
99
|
+
redemption.approved? ? @chat.approve(id) : ChatApprovals.deny(@chat, id)
|
|
95
100
|
end
|
|
96
101
|
|
|
97
102
|
def persist_decision(planned, now:)
|
|
@@ -109,7 +114,7 @@ module RubyLLM
|
|
|
109
114
|
end
|
|
110
115
|
|
|
111
116
|
def pending_approval(tool_call_id)
|
|
112
|
-
@chat.
|
|
117
|
+
ChatApprovals.pending(@chat, previous_ids: [tool_call_id]).find { |tool_call| tool_call.id == tool_call_id }
|
|
113
118
|
end
|
|
114
119
|
end
|
|
115
120
|
end
|
data/lib/ruby_llm/ag_ui/run.rb
CHANGED
|
@@ -102,7 +102,7 @@ module RubyLLM
|
|
|
102
102
|
|
|
103
103
|
def start_execution(record, to)
|
|
104
104
|
@mapper = build_mapper(record)
|
|
105
|
-
@mapper.continue_tool_calls(
|
|
105
|
+
@mapper.continue_tool_calls(resume.previous_call_ids) if resume.needed?
|
|
106
106
|
@emitter = build_emitter(record, to, mapper: @mapper)
|
|
107
107
|
@emitter.start(run_started_event(record), state: @state)
|
|
108
108
|
end
|
|
@@ -149,25 +149,9 @@ module RubyLLM
|
|
|
149
149
|
# finished.
|
|
150
150
|
def finish
|
|
151
151
|
return @emitter.succeed unless @chat.waiting?
|
|
152
|
-
raise UnsupportedRunStateError unless @chat.awaiting_approval?
|
|
153
152
|
|
|
154
|
-
@
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# One interrupt per pending approval, carrying the tool call, the digest of
|
|
158
|
-
# the arguments RubyLLM asked to run, and a host-owned expiry. The host
|
|
159
|
-
# still re-authorizes before the tool executes: an approval answers an
|
|
160
|
-
# interrupt, it never grants a permission.
|
|
161
|
-
def build_interrupts
|
|
162
|
-
expires_at = @clock.call + @expires_in
|
|
163
|
-
@chat.pending_approvals.map do |tool_call|
|
|
164
|
-
Interrupt.create(
|
|
165
|
-
tool_call_id: tool_call.id,
|
|
166
|
-
arguments_digest: Canonical.digest(tool_call.arguments),
|
|
167
|
-
expires_at: expires_at,
|
|
168
|
-
message: "Approve the #{tool_call.name} tool call?"
|
|
169
|
-
)
|
|
170
|
-
end
|
|
153
|
+
calls = ChatApprovals.pending(@chat, previous_ids: resume.previous_call_ids)
|
|
154
|
+
@emitter.interrupt(ChatApprovals.interrupts(calls, expires_at: @clock.call + @expires_in))
|
|
171
155
|
end
|
|
172
156
|
|
|
173
157
|
def build_mapper(record)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_llm-ag_ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Wang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-12-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ag-ui-protocol
|
|
@@ -195,6 +195,7 @@ files:
|
|
|
195
195
|
- lib/generators/ruby_llm/ag_ui/templates/initializer.rb.tt
|
|
196
196
|
- lib/ruby_llm/ag_ui.rb
|
|
197
197
|
- lib/ruby_llm/ag_ui/canonical.rb
|
|
198
|
+
- lib/ruby_llm/ag_ui/chat_approvals.rb
|
|
198
199
|
- lib/ruby_llm/ag_ui/configuration.rb
|
|
199
200
|
- lib/ruby_llm/ag_ui/coverage.rb
|
|
200
201
|
- lib/ruby_llm/ag_ui/emitter.rb
|