nexo_ai 0.12.0 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6739e4be2c75c08ffb553133324b96b29d13e0212e21cc23c4cd6287316b3249
4
- data.tar.gz: d051ce3a0916cd5fb9328df9b893e5aad15b6f60c8d5c23bb9be8b3126da7285
3
+ metadata.gz: 3ab3bc27263cfb9d2adc054a4579f983f8fa10ac2c94586116f3e6793d3d93b9
4
+ data.tar.gz: e967f788db7fce3e9205199b7cbe8628a60d5678e9daa0db8802852d6e87b7bf
5
5
  SHA512:
6
- metadata.gz: 94c1df2b9d56ab1c31aacd79a52473bf6ed3da9ba43d2e7403658fdee0e52bc31bded23181dbe7f60e82b4fd9b0f5e64c5d933de80cf99f546ca0982b883d878
7
- data.tar.gz: ca8829f2003854bd1c24e2e77739b0b4c62bd173ee0bd31297171ba017f2c1a02dd31f6fb9bb7ef938fc1c67a93229c407f5fbae06b29c4aee305552f6eba242
6
+ metadata.gz: 97a086e9d89990c89c0be4d9ba03de89ac2c77aa6e6d5fcd5086179c9d5c55845f2b08543984ea67b77eafa4b6e085e2c2d60d2d9c25020a80853c81bfab61bd
7
+ data.tar.gz: 57b9cf4b4ab598badaad5cc59fa57b691ca3c4f8c88caa927ed3ef9bf9637587a029db2037ae04ac97b7e17341a41ac4c5a0435edbfe9d13f00d135b92efb375
data/CHANGELOG.md CHANGED
@@ -1,5 +1,86 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.13.0] - 2026-11-26
4
+
5
+ Nexo now runs on ruby_llm 2.2. MCP comes from ruby_llm itself, skills need no extra gem,
6
+ and `max_turns` is a real cap.
7
+
8
+ ### Changed
9
+
10
+ - **`ruby_llm` is now pinned to the 2.2 line (`~> 2.2.0`, was `~> 1.16`).** Verified against
11
+ 2.2.3. ruby_llm 1.x is no longer supported; it ended at 1.16.0 and carries ReDoS
12
+ advisories that are fixed only in 2.0.
13
+
14
+ **Upgrading:** this is a breaking release for the host app's Gemfile and for any
15
+ `RubyLLM::Tool` you wrote yourself.
16
+
17
+ 1. Remove `gem "ruby_llm-mcp"` and `gem "ruby_llm-skills"`. `ruby_llm-mcp` defines the
18
+ same `RubyLLM::MCP` constant as ruby_llm 2.x and cannot be bundled with it; both gems
19
+ pin ruby_llm 1.x. Anything you were getting from them transitively (for example
20
+ `bigdecimal`) must now be declared by you.
21
+ 2. In your own tools, rename `param` to `parameter` and `desc:` to `description:`
22
+ (`params do` becomes `parameters do`). ruby_llm 2.0 removed the old names.
23
+ 3. A tool wrapper you wrote (for `wrap_mcp_tool`) must accept keywords:
24
+ `def call(**arguments)`. ruby_llm 2.x calls tools as `tool.call(**arguments)`, and the
25
+ schema reader is `parameters_schema`, not `params_schema`.
26
+ 4. If you use `Nexo::Session` on ActiveRecord, run ruby_llm's own schema upgrade
27
+ (`rails g ruby_llm:upgrade`, one minor at a time). ruby_llm 2.x keeps tool calls and
28
+ the model registry in its own `ruby_llm_*` tables; the host owns only `Chat` and
29
+ `Message`.
30
+ 5. Read ruby_llm's [upgrade guide](https://rubyllm.com/upgrading/) for everything outside
31
+ Nexo — notably that OpenAI now defaults to the Responses API.
32
+
33
+ - **`max_turns` is a hard cap.** `Agent#prompt`, `Session#prompt` and
34
+ `Workflow#run_agent` pass it to ruby_llm as `with_tool_options(rounds:)`. When a prompt
35
+ uses up its tool rounds, `RubyLLM::ToolRoundLimitError` is raised instead of the model
36
+ being asked again; inside a workflow that fails the run. It was telemetry only before.
37
+
38
+ **Upgrading:** a run that used to pass `max_turns` and keep going now stops. Raise the
39
+ number for runs that legitimately need more rounds, or pass `max_turns: nil` to run
40
+ uncapped. The `:turn_limit_exceeded` event is still emitted, once per prompt.
41
+
42
+ - **MCP uses ruby_llm's built-in client.** The `mcp` macro, `mcp_allow`, the fail-closed
43
+ gate, `wrap_mcp_tool` and `Nexo::MCP.build` are unchanged for callers. Three behaviours
44
+ differ, all inherited from ruby_llm:
45
+ - a callable `token:` is read again for **every request**, so a rotated token no longer
46
+ needs `agent.close` and a reconnect;
47
+ - a `:stdio` server starts with a short, safe environment — pass what it needs with
48
+ `env:`;
49
+ - a `:stdio` server's stderr is your process's stderr.
50
+
51
+ An unknown transport or a `:stdio` server with no `command:` now raises
52
+ `Nexo::ConfigurationError` when the server is built.
53
+
54
+ - **Skills are read by Nexo itself** (`Nexo::Skills::Skill`). `skills`, `Nexo::Skills.find`
55
+ and `Nexo::Skills.materialize` are unchanged. A `SKILL.md` without YAML front matter now
56
+ raises `Nexo::Error` naming the file. ruby_llm's own skills are not used: they reject
57
+ underscore names (`email_triage`) and work through a `load_skill` tool, where Nexo's rule
58
+ is that a skill adds instructions and nothing else.
59
+
60
+ - **Workflow events store tool arguments string-keyed** in both run stores. ruby_llm 2.x
61
+ hands them over with Symbol keys; the Memory store would otherwise have disagreed with
62
+ the ActiveRecord one.
63
+
64
+ ### Removed
65
+
66
+ - **`Nexo::Loops::AgentSDK`**, with `Agent#permission_mode`, `Agent#allowed_tools`,
67
+ `Agent::ALLOWED_TOOLS` and `Agent::PERMISSION_MODE_MAP`. The `ruby_llm-agent_sdk` gem it
68
+ wrapped was never published, so this path never ran against real code. Its one purpose,
69
+ a hard turn cap, is now `max_turns` on the default loop. `Nexo::Loop` remains as the seam
70
+ for a backend of your own.
71
+ - **`Nexo::MCP.load!` and `Nexo::Skills.load!`.** There is no optional gem left to load.
72
+ - The `ruby_llm-test`, `ruby_llm-skills` and `ruby_llm-mcp` development dependencies. The
73
+ suite scripts model replies with ruby_llm's own `RubyLLM::TestHelper`.
74
+
75
+ ### Added
76
+
77
+ - `test/real_loop_test.rb` drives ruby_llm's real conversation loop with scripted replies
78
+ and proves, end to end: a `:read_only` agent cannot reach the write tool, the MCP gate
79
+ denies a tool before it runs, `max_turns` stops a runaway loop, and an `:approve` gate
80
+ suspends a workflow and resumes it.
81
+ - `mcp` accepts `env:` and `directory:` for `:stdio` servers, and `command:` as an argv
82
+ Array.
83
+
3
84
  ## [0.12.0] - 2026-09-12
4
85
 
5
86
  The gem now says exactly which ruby_llm it supports, and its API docs are written in Markdown.
data/README.md CHANGED
@@ -9,10 +9,10 @@ build a working agent in five lines without wiring anything.
9
9
 
10
10
  ## Compose, don't reimplement
11
11
 
12
- Nexo does not rebuild skill loading, the tool-call loop, MCP, or structured output — those
13
- already live in the RubyLLM ecosystem (`ruby_llm` core, `ruby_llm-skills`, `ruby_llm-mcp`,
14
- `ruby_llm-schema`). Nexo **composes** them behind one front door and adds only the two pieces
15
- the ecosystem is missing:
12
+ Nexo does not rebuild the tool-call loop, the MCP client, tool approval plumbing, or
13
+ structured output — those live in [`ruby_llm`](https://github.com/crmne/ruby_llm) itself.
14
+ Nexo **composes** them behind one front door and adds only the two pieces `ruby_llm`
15
+ leaves to the application:
16
16
 
17
17
  - **Sandbox + Permissions seam** — pluggable execution environment (virtual / local /
18
18
  remote) with explicit authorization gating. Default: `:virtual` + `:read_only`.
@@ -81,7 +81,7 @@ access until you explicitly opt in.
81
81
  | [Sandboxes](docs/sandboxes.md) | Virtual / Local / Remote / Container + hardened defaults |
82
82
  | [Permissions](docs/permissions.md) | modes, the gate, MCP gate, :ask |
83
83
  | [Tools](docs/tools.md) | ReadFile / WriteFile / Shell / Glob |
84
- | [Loop backends](docs/loops.md) | RubyLLM vs AgentSDK, turn-cap caveat |
84
+ | [The loop](docs/loops.md) | the default loop, `max_turns` as a hard cap |
85
85
  | [Workflows](docs/workflows.md) | lifecycle, staging, artifacts, run_agent |
86
86
  | [Durable workflows](docs/durable-workflows.md) | checkpoint / suspend / resume |
87
87
  | [Skills](docs/skills.md) | SKILL.md packages, gated tools |
@@ -94,16 +94,14 @@ access until you explicitly opt in.
94
94
  ## Requirements
95
95
 
96
96
  - Ruby 3.3+
97
- - [ruby_llm](https://github.com/crmne/ruby_llm) 1.16.x (`~> 1.16`) — the supported version is
98
- **1.16.0**; the upcoming ruby_llm 2.0 is not supported yet
99
- - [ruby_llm-skills](https://github.com/kieranklaassen/ruby_llm-skills) — optional, only
100
- when you use the `skills` macro
101
- - [ruby_llm-mcp](https://github.com/patvice/ruby_llm-mcp) — optional, only when you attach
102
- an MCP server with the `mcp` macro
103
- - `ruby_llm-agent_sdk` — optional (not yet published), only when you choose the
104
- Anthropic-oriented `Loops::AgentSDK` backend. Its exact API is verified-on-install
105
- (see [Loops](docs/loops.md)); until it ships, `Loops::AgentSDK` raises a clear
106
- `Nexo::MissingDependencyError`.
97
+ - [ruby_llm](https://github.com/crmne/ruby_llm) 2.2.x (`~> 2.2.0`) — verified against
98
+ **2.2.3**. It is the only runtime dependency besides `zeitwerk`: MCP and the test helper
99
+ ship with it, and Nexo reads `SKILL.md` packages itself.
100
+
101
+ Coming from `nexo_ai` 0.12 (on `ruby_llm` 1.16)? Remove `ruby_llm-mcp` and
102
+ `ruby_llm-skills` from your Gemfile — `ruby_llm-mcp` defines the same `RubyLLM::MCP`
103
+ constant as `ruby_llm` 2.x and cannot be bundled alongside it — and read the 0.13.0
104
+ entry in the [changelog](CHANGELOG.md).
107
105
 
108
106
  ## Status
109
107
 
data/docs/concurrency.md CHANGED
@@ -114,8 +114,7 @@ Nexo.configure { |c| c.tool_concurrency = :fibers } # :fibers | :threads | fal
114
114
  - `nil` (**default**) — leave RubyLLM's own setting alone, so behaviour is unchanged
115
115
  until you opt in.
116
116
 
117
- It is applied to the chat after every tool is attached, because each `with_tools` call
118
- resets the chat's concurrency.
117
+ It is applied to the chat with `with_tool_options(concurrency:)`.
119
118
 
120
119
  This only matters when a model returns several tool calls in one turn. Tools that batch
121
120
  their own work — one call that reads twenty messages rather than twenty calls — make it
@@ -183,7 +183,9 @@ resumed.status # => "done" (the gate allowed the
183
183
  - **Cross-process approval needs the ActiveRecord store + ActiveJob** (like all durable resume).
184
184
  In-process `resume` works with the Memory store; a Memory run does not survive the process.
185
185
  - **Branch depends on upstream `ruby_llm`.** This works because `ruby_llm`'s tool loop lets a
186
- tool `execute` exception propagate out of `chat.ask` (verified, 1.16.0). If a future
186
+ tool `execute` exception propagate out of `chat.ask` (verified on 2.2.3 through the real
187
+ loop, `test/real_loop_test.rb`). A host that registers a catch-all
188
+ `RubyLLM::Tool.rescue_from StandardError` would swallow the approval signal. If a future
187
189
  `ruby_llm` swallows tool exceptions, tool-triggered approval would be constrained — a
188
190
  genuine upstream dependency, stated plainly.
189
191
 
data/docs/loops.md CHANGED
@@ -1,121 +1,93 @@
1
- # Loop backends — swap the engine, not the agent
2
- The loop is the engine that drives one prompt to completion; swap it by constructor injection without touching the agent class.
1
+ # The loop — one engine, a real turn cap
2
+ The loop is the engine that drives one prompt to completion; `max_turns` is a hard cap on its tool rounds.
3
3
 
4
- The **loop** is the engine that drives one prompt to completion. Swapping it is constructor
5
- injection (`loop:`) — the agent class never changes. Two backends ship:
6
-
7
- | | `Loops::RubyLLM` (default) | `Loops::AgentSDK` (opt-in) |
8
- | ------------------ | ---------------------------------- | ------------------------------------- |
9
- | Provider neutral | ✅ any `ruby_llm` model | ❌ Anthropic-oriented |
10
- | Tool source | your sandbox-backed tools | the SDK's own built-in/host tools |
11
- | Turn cap | observability only (see caveat) | native `max_turns` hard cap |
12
- | Execution location | your sandbox (virtual/local/remote)| the host process |
13
-
14
- The whole point: **same agent code, swapped backends**. Both examples are model-agnostic
15
- (`ENV.fetch("NEXO_MODEL")` — never a hardcoded `"claude-…"`):
4
+ The **loop** is the engine that drives one prompt to completion. Nexo ships one,
5
+ `Nexo::Loops::RubyLLM`, and it is the default: it builds the agent's chat with its
6
+ sandbox-backed tools and lets `ruby_llm` run the tool loop. It works identically on any
7
+ `ruby_llm`-supported model — Anthropic, OpenAI, Gemini, a local model through Ollama —
8
+ because every capability comes from the agent's own gated tools, not from anything
9
+ vendor-specific.
16
10
 
17
11
  ```ruby
18
- # Claude fast path — AgentSDK's own loop + host tools + native max_turns
19
- claude = Nexo::Agent.new(
20
- model: ENV.fetch("NEXO_MODEL"),
21
- sandbox: Nexo::Sandboxes::Local.new(cwd: "/srv/checkout"),
22
- permissions: Nexo::Permissions.new(mode: :auto),
23
- loop: Nexo::Loops::AgentSDK.new
24
- )
25
-
26
- # Any-provider path — your sandbox, your tools, human-in-the-loop
27
- gpt = Nexo::Agent.new(
12
+ agent = Nexo::Agent.new(
28
13
  model: ENV.fetch("NEXO_MODEL"), # gpt-5.5, gemini, gemma3:12b via Ollama…
29
14
  sandbox: Nexo::Sandboxes::Remote.new(client: my_container_client),
30
15
  permissions: Nexo::Permissions.new(mode: :ask, on_ask: ->(cap, detail) {
31
16
  SlackApproval.request!(capability: cap, detail: detail)
32
- }),
33
- loop: Nexo::Loops::RubyLLM.new
17
+ })
34
18
  )
35
19
  ```
36
20
 
37
- `Loops::AgentSDK` wraps `RubyLLM::AgentSDK.query` and requires the **optional**
38
- `ruby_llm-agent_sdk` gem (lazy `require`; a clear `Nexo::MissingDependencyError` if it's
39
- absent). It maps Nexo's permission modes onto the SDK's own vocabulary:
40
-
41
- | Nexo mode | AgentSDK `permission_mode` |
42
- | ------------ | -------------------------- |
43
- | `:read_only` | `:default` |
44
- | `:auto` | `:bypass_permissions` |
45
- | `:ask` | `:default` (human gating stays in Nexo's own `on_ask` path, not delegated to the SDK) |
46
- | `:approve` | `:default` (durable approval stays in Nexo's own gate; any unmapped mode also falls back to `:default`) |
47
-
48
- ## The turn-cap caveat (read before running untrusted/expensive workloads)
49
-
50
- `ruby_llm` runs the whole tool loop inside `ask`, so `Loops::RubyLLM` has **no clean public
51
- hard "stop after N turns" halt** — `before_tool_call` gives turn-count *observability*, not a
52
- hard stop. (Confirmed: `ruby_llm` 1.16.0's `Chat` exposes no public max-turns/max-iterations
53
- setting.) Your three real options:
54
-
55
- (a) use `Loops::AgentSDK` (native `max_turns`) for untrusted/expensive workloads;
56
- (b) have a tool return `{ error: "turn limit reached, stop and summarize" }` once a turn
57
- counter trips;
58
- (c) check whether the installed `ruby_llm` exposes a max-iterations config (in 1.16.0 it
59
- does not).
60
-
61
- Do **not** ship `Loops::RubyLLM` for untrusted workloads claiming a hard cap that isn't
62
- proven.
63
-
64
- ## Verified vs assumed
65
-
66
- Built against **`ruby_llm` 1.16.0** (the supported line — the gemspec pins `~> 1.16`, and the
67
- upcoming `ruby_llm` 2.0 is not supported yet) and **`ruby_llm-test` 0.2**. The tool body method is
68
- `#execute`, tools attach with `chat.with_tools(*instances)`, and instructions set with
69
- `chat.with_instructions`. `Open3.capture3` has no `timeout:` keyword on the target Ruby, so
70
- `Local#shell` bounds the command with `Timeout.timeout`. These may differ on other
71
- `ruby_llm` versions.
72
-
73
- `Loops::RubyLLM`'s turn-count observability uses `RubyLLM::Chat#before_tool_call` /
74
- `#after_tool_result`, confirmed present on `ruby_llm` 1.16.0 and guarded with `respond_to?`
75
- so a version lacking them degrades to no observability rather than crashing.
76
- `Loops::AgentSDK` targets `RubyLLM::AgentSDK.query`; `ruby_llm-agent_sdk` is **not** a
77
- dependency of this release, so that signature is **assumed** (per the gem's README) and
78
- verified-on-install — confirm it the moment you add the gem.
21
+ The loop is still a seam. A backend of your own subclasses `Nexo::Loop`, implements
22
+ `run(agent:, prompt:, max_turns:, chat:, &on_event)`, and is injected with `loop:` — the
23
+ agent class never changes.
79
24
 
80
- ## Live smoke (optional)
25
+ > `Loops::AgentSDK` was removed in 0.13. It wrapped a `ruby_llm-agent_sdk` gem that was
26
+ > never published, and its one purpose — a hard turn cap — is now native (below).
81
27
 
82
- The core suite is fully offline and deterministic (models stubbed with `ruby_llm-test`).
83
- A real end-to-end check is opt-in and env-gated — small local models like Gemma have weak
84
- tool-calling, so it may be flaky and is never a gating test:
28
+ ## `max_turns` is a hard cap
85
29
 
86
- ```sh
87
- ollama serve &
88
- NEXO_LIVE=1 NEXO_MODEL=gemma3:12b bundle exec rake test TEST=test/live_smoke_test.rb
30
+ `Agent#prompt`, `Session#prompt` and `Workflow#run_agent` all take `max_turns:` (default
31
+ `25`). It caps **tool rounds**: the number of model responses that ask for tools within
32
+ one prompt, however many calls each response holds. Nexo passes it to `ruby_llm` as
33
+ `with_tool_options(rounds:)`.
34
+
35
+ When the cap is reached, `ruby_llm` raises `RubyLLM::ToolRoundLimitError` instead of
36
+ asking the model again. Every tool call that ran has its result, so the conversation
37
+ stays valid. Nexo emits a `:turn_limit_exceeded` event and lets the error propagate:
38
+
39
+ ```ruby
40
+ begin
41
+ agent.prompt("Triage the inbox", max_turns: 10) do |type, payload|
42
+ warn "over budget: #{payload}" if type == :turn_limit_exceeded
43
+ end
44
+ rescue RubyLLM::ToolRoundLimitError
45
+ # the run used its 10 rounds — decide whether to retry with a larger budget
46
+ end
89
47
  ```
90
48
 
91
- If Gemma's tool-calling proves too weak, point `NEXO_MODEL` at a stronger model — the gem
92
- stays provider-neutral; only the smoke target changes.
49
+ Inside a workflow the error fails the run like any other (`status: "failed"`, re-raised),
50
+ so a runaway agent cannot keep spending.
93
51
 
52
+ Things to know:
94
53
 
95
- ## `max_turns` is a budget, not a hard stop
54
+ - **Upgrading from 0.12:** `max_turns` used to be telemetry only — a run that passed it
55
+ kept going. It now stops. If a legitimate run needs more rounds, raise the number.
56
+ - `max_turns: nil` runs uncapped. Use it only for trusted workloads.
57
+ - The event also fires, once per prompt, the first time the count of tool **calls** passes
58
+ `max_turns`. A round can hold several calls, so with concurrent tool calls this can
59
+ arrive before the round cap trips. It is a warning; the raise is the stop.
60
+ - The cap counts rounds, not time or tokens. Bound those inside your own tools (a read
61
+ tool that accepts at most N ids) or with your provider's limits.
96
62
 
97
- `Agent#prompt`, `Session#prompt` and `Workflow#run_agent` all take `max_turns:`. On the
98
- default `Loops::RubyLLM` it **cannot halt a run**: ruby_llm executes the entire tool loop
99
- inside `Chat#ask`, and the callbacks Nexo wires are observation-only.
63
+ ## Verified against
100
64
 
101
- What it does do is count tool calls and tell you when the budget is passed:
65
+ Built and tested against **`ruby_llm` 2.2.3** (the gemspec pins `~> 2.2.0`). The tool body
66
+ method is `#execute`; the chat calls a tool as `tool.call(**arguments)`; tools attach with
67
+ `chat.with_tools(*instances)`; execution settings go through `chat.with_tool_options`;
68
+ instructions set with `chat.with_instructions`. Tool activity is observed with
69
+ `Chat#before_tool_call` / `#after_tool_result`, which are additive.
102
70
 
103
- ```ruby
104
- agent.prompt("Triage the inbox", max_turns: 10) do |type, payload|
105
- warn "over budget: #{payload}" if type == :turn_limit_exceeded
106
- end
107
- # => :turn_limit_exceeded, { turns: 11, max_turns: 10 }
108
- ```
71
+ These facts are not taken on trust: `test/real_loop_test.rb` drives `ruby_llm`'s real
72
+ conversation loop with scripted model replies and asserts the permission gate, the MCP
73
+ gate, the turn cap, and approval suspension end to end.
74
+
75
+ `Open3.capture3` has no `timeout:` keyword on the target Ruby, so `Local#shell` bounds the
76
+ command with `Timeout.timeout`.
109
77
 
110
- Emitted once per prompt, not per call.
78
+ ## Live smoke (optional)
111
79
 
112
- If you need a **hard** ceiling, the options are:
80
+ The core suite is fully offline and deterministic (model replies are scripted with
81
+ `ruby_llm`'s own `RubyLLM::TestHelper`). A real end-to-end check is opt-in and env-gated —
82
+ small local models like Gemma have weak tool-calling, so it may be flaky and is never a
83
+ gating test:
113
84
 
114
- - bound the work inside your own tools (a read tool that accepts at most N ids);
115
- - use `Loops::AgentSDK`, whose engine enforces `max_turns` natively;
116
- - stop the run yourself from the event block.
85
+ ```sh
86
+ ollama serve &
87
+ NEXO_LIVE=1 NEXO_MODEL=gemma3:12b bundle exec rake test TEST=test/live_smoke_test.rb
88
+ ```
117
89
 
118
- Treat `max_turns` on the default loop as telemetry. It was previously accepted and never
119
- read, which made it look like a safety bound it has never been.
90
+ If Gemma's tool-calling proves too weak, point `NEXO_MODEL` at a stronger model — the gem
91
+ stays provider-neutral; only the smoke target changes.
120
92
 
121
93
  ← Back to the [README](../README.md)
data/docs/mcp.md CHANGED
@@ -3,9 +3,9 @@ Attach one or more MCP servers with a single `mcp` macro — every call gated by
3
3
 
4
4
  An **MCP server** exposes tools to a model over the [Model Context
5
5
  Protocol](https://modelcontextprotocol.io) — Gmail, a filesystem, a fetch endpoint,
6
- Drive, and so on. Nexo does not implement MCP; it composes the
7
- [`ruby_llm-mcp`](https://github.com/patvice/ruby_llm-mcp) gem so you attach one or more
8
- servers with a single `mcp` macro and no client wiring. Because a server is reached
6
+ Drive, and so on. Nexo does not implement MCP; it composes the MCP client built into
7
+ [`ruby_llm`](https://rubyllm.com/mcp/) (core since 2.1) so you attach one or more
8
+ servers with a single `mcp` macro and no client wiring — and no extra gem. Because a server is reached
9
9
  *through the protocol* (never a vendor SDK), the behavior is identical on Anthropic, a
10
10
  local model, or anything else `ruby_llm` supports.
11
11
 
@@ -56,10 +56,10 @@ no globs or regexes.
56
56
  constrain what that server does with a call it is authorized to make — attaching a write
57
57
  server and allowing a write tool means real writes happen. Gate deliberately, and prefer
58
58
  `:read_only` with a tight `mcp_allow`.
59
- 2. **Connection lifecycle.** Clients are built once and **memoized on the agent instance**,
60
- reused across prompts (the `ruby_llm-mcp` client connects on construction and stays
61
- connected). A long-lived agent holding stdio/SSE servers should call `Agent#close` when
62
- done to tear the connections down:
59
+ 2. **Connection lifecycle.** Servers are built once and **memoized on the agent instance**,
60
+ reused across prompts (a server connects on its first request and stays connected). A
61
+ long-lived agent holding stdio/HTTP servers should call `Agent#close` when done to tear
62
+ the connections down:
63
63
 
64
64
  ```ruby
65
65
  agent = InboxDigest.new
@@ -68,13 +68,32 @@ no globs or regexes.
68
68
  agent.close # stops every attached server
69
69
  ```
70
70
 
71
- ## HTTP-family servers + an OAuth `token:` provider
71
+ ## Stdio servers: environment and stderr
72
72
 
73
- Beyond `:stdio`, Nexo attaches a server over any HTTP-family transport `ruby_llm-mcp`
74
- supports — `transport: :http`, `:sse`, or `:streamable`. For an OAuth-authenticated
75
- hosted server (Gmail, Drive, …) add a `token:` — a static bearer `String`, or a
76
- **callable** re-read close to connection time. Nexo resolves it and injects an
77
- `Authorization: Bearer <token>` header per connection:
73
+ A `:stdio` server is a process Nexo's host starts. Two things about it come from
74
+ `ruby_llm` and are worth knowing:
75
+
76
+ - **It gets a short environment.** The process inherits only a small set of safe variables
77
+ (`PATH`, `HOME`, `LANG`, `TMPDIR`, `USER`, and a few more) — not your application's
78
+ secrets. Pass anything else the server needs with `env:`:
79
+
80
+ ```ruby
81
+ mcp :github, transport: :stdio, command: "github-mcp", env: {GITHUB_TOKEN: ENV.fetch("GITHUB_TOKEN")}
82
+ ```
83
+
84
+ - **Its stderr is your process's stderr.** A chatty server prints straight into your
85
+ terminal or log. To drop it, wrap the command:
86
+ `command: "sh", args: ["-c", 'exec "$0" 2>/dev/null', "apple-mail-mcp"]`.
87
+
88
+ `command:` takes a String or an argv Array, `args:` is appended to it, and `directory:`
89
+ sets the process's working directory.
90
+
91
+ ## HTTP servers + a bearer `token:`
92
+
93
+ Beyond `:stdio`, Nexo attaches a server over HTTP — `transport: :http`, `:sse`, or
94
+ `:streamable` (all three are "a URL"; `ruby_llm` speaks Streamable HTTP and falls back for
95
+ older servers by itself). For an authenticated hosted server (Gmail, Drive, …) add a
96
+ `token:` — a static bearer `String`, or a **callable** that returns one:
78
97
 
79
98
  ```ruby
80
99
  class InboxTriageHTTP < Nexo::Agent
@@ -85,7 +104,7 @@ class InboxTriageHTTP < Nexo::Agent
85
104
  mcp :gmail,
86
105
  transport: :http,
87
106
  url: ENV.fetch("GMAIL_MCP_URL"),
88
- token: -> { Current.user.gmail_access_token } # re-read at connection time
107
+ token: -> { Current.user.gmail_access_token } # read again for each request
89
108
 
90
109
  # READ tools only — the unchanged gate denies send/trash/modify.
91
110
  mcp_allow %w[search_threads get_thread list_messages get_message list_labels]
@@ -93,53 +112,39 @@ end
93
112
  ```
94
113
 
95
114
  A static token (`token: ENV.fetch("GMAIL_TOKEN")`) is equally valid. Under the hood
96
- Nexo strips `token:` and hands off:
115
+ Nexo hands the token to `ruby_llm` as the server's bearer token:
97
116
 
98
117
  ```ruby
99
- RubyLLM::MCP.client(
100
- name: "gmail", transport_type: :http,
101
- config: { url: "https://…", headers: { "Authorization" => "Bearer <resolved>" } }
102
- )
118
+ RubyLLM.mcp(name: "gmail", url: "https://…", bearer_token: -> { … })
103
119
  ```
104
120
 
105
- Any other `headers:` you pass are preserved; Nexo's `Authorization` wins. With no
106
- `token:`, `config:` passes through byte-for-byte (no `headers` key) — the `:stdio` path
107
- is untouched.
121
+ `ruby_llm` sends it as `Authorization: Bearer <token>`. Any `headers:` you pass are sent
122
+ too; the bearer token wins the `Authorization` header.
108
123
 
109
- **Nexo does not own the OAuth flow.** It performs no authorization-code exchange, no
110
- token refresh, and keeps no token store — that is your app or an OAuth library. Nexo's
111
- only job is to call the provider, inject the header, and hand off. The token is never
112
- logged, persisted, placed in a URL/query string, or emitted in an event (the event path
113
- carries only tool `name`/`args` and return values — never connection config).
114
-
115
- **Refresh / reconnect caveat.** `ruby_llm-mcp`'s HTTP-family transports snapshot the
116
- `headers` hash **at construction** — there is no per-request header callback for a plain
117
- `headers` Hash. A callable `token:` is therefore resolved **once**, when the client is
118
- built, and the client is memoized on the agent instance across prompts. So when a token
119
- **rotates**, tear the connection down and reconnect to pick up the new value:
124
+ **A callable token is read again for every request.** When a token rotates, the next
125
+ request carries the new value — no reconnect needed. (Under `ruby_llm` 1.x a callable was
126
+ resolved once per connection and a rotation needed `agent.close`; that caveat is gone.)
120
127
 
121
- ```ruby
122
- agent.close # stops the memoized MCP client
123
- agent.prompt("…") # a fresh prompt rebuilds the client → token: re-resolved
124
- ```
128
+ **Nexo does not own the OAuth flow.** It performs no authorization-code exchange, no
129
+ token refresh, and keeps no token store — that is your app or an OAuth library. The token
130
+ is never logged, persisted, placed in a URL/query string, or emitted in an event (the
131
+ event path carries only tool `name`/`args` and return values — never connection config).
125
132
 
126
- **The gate is unchanged.** An HTTP OAuth server's tools are gated exactly like `:stdio`
133
+ **The gate is unchanged.** An HTTP server's tools are gated exactly like `:stdio`
127
134
  tools: denied under `:read_only` until the exact name is in `mcp_allow` (default `[]` ⇒
128
135
  deny-all). Attaching an authenticated server adds no permission surface.
129
136
 
130
- **Two honest caveats — read before attaching a token:**
137
+ **The token is a live credential.** Even gated, an authorized MCP call runs its effect
138
+ server-side — a leaked bearer is a real compromise. Nexo keeps it out of logs, events,
139
+ persisted `WorkflowRun` records, and URLs; your host code must do the same. Nexo does
140
+ not police `ruby_llm`'s own debug logging (`RUBYLLM_DEBUG`) — that boundary is yours.
131
141
 
132
- 1. **Refresh may require a reconnect.** Because headers are construction-only,
133
- a rotated token needs `agent.close` + a fresh prompt (above), not just a new proc
134
- return. A static token stays constant for the client's life.
135
- 2. **The token is a live credential.** Even gated, an authorized MCP call runs its effect
136
- server-side — a leaked bearer is a real compromise. Nexo keeps it out of logs, events,
137
- persisted `WorkflowRun` records, and URLs; your host code must do the same. Nexo does
138
- not police `ruby_llm-mcp`'s own internal logging of headers — that boundary is yours.
142
+ `ruby_llm` can also run a full per-user OAuth flow for an MCP server
143
+ (`oauth owner:` on a `RubyLLM::MCP` class). Nexo's `mcp` macro does not expose it yet.
139
144
 
140
- `ruby_llm-mcp` is an **optional** dependency — required lazily only when you attach a
141
- server. Without it installed, `require "nexo"` still loads; building a server raises a clear
142
- `Nexo::MissingDependencyError` telling you to add `gem "ruby_llm-mcp"`.
145
+ > **Upgrading from 0.12:** remove `gem "ruby_llm-mcp"` from your Gemfile. It defines the
146
+ > same `RubyLLM::MCP` constant as `ruby_llm` 2.x and the two cannot be bundled together.
147
+ > The `mcp` macro and `mcp_allow` are unchanged.
143
148
 
144
149
 
145
150
  ## Decorating MCP tools
@@ -161,8 +166,9 @@ end
161
166
  ```
162
167
 
163
168
  A wrapper must keep the duck type the chat relies on — `#name`, `#description`,
164
- `#params_schema` and `#call`. `GatedTool` delegates the rest through `method_missing`, so
165
- wrappers compose.
169
+ `#parameters_schema` and `#call`. `ruby_llm` 2.x calls every tool with **keywords**, so
170
+ write `def call(**arguments) = …@tool.call(**arguments)`. Delegate everything else with
171
+ `method_missing`, as `GatedTool` does, so wrappers compose.
166
172
 
167
173
  Gating happens **underneath** the wrapper, so it only ever sees an already-authorized
168
174
  call. Wrapping cannot widen what an agent may do.
data/docs/sessions.md CHANGED
@@ -27,13 +27,17 @@ do. The persisted record supplies the *thread*; the agent supplies the
27
27
  ## Composition — `acts_as_chat`, owned by the host
28
28
 
29
29
  Message persistence is **RubyLLM's `acts_as_chat`** — Nexo defines no message table
30
- and serializes nothing. The host Rails app owns all four persistence models (`Chat`,
31
- `Message`, `ToolCall`, `Model`), generated by ruby_llm's own installer:
30
+ and serializes nothing. The host Rails app owns the `Chat` and `Message` models,
31
+ generated by ruby_llm's own installer (ruby_llm 2.x keeps the model registry, tool calls
32
+ and usage in its own `ruby_llm_*` tables):
32
33
 
33
34
  ```bash
34
- rails g ruby_llm:install # generates the Chat/Message/ToolCall/Model models + migrations
35
+ rails g ruby_llm:install # generates the Chat/Message models + migrations
35
36
  ```
36
37
 
38
+ Already on ruby_llm 1.x persistence? Run ruby_llm's own schema upgrade first
39
+ (`rails g ruby_llm:upgrade`, see its [upgrade guide](https://rubyllm.com/upgrading/)).
40
+
37
41
  **One setup step beyond the installer:** the session chat model must be addressable,
38
42
  so add two columns and a **unique composite index** to the generated `chats` table:
39
43
 
data/docs/skills.md CHANGED
@@ -3,9 +3,8 @@ A skill is a `SKILL.md` package that teaches the model *how you want a task done
3
3
 
4
4
  A **skill** is a `SKILL.md` package — frontmatter plus instructions — that teaches the
5
5
  model *how you want a task done*. Skills guide **reasoning**; the sandbox-backed tools
6
- above perform **execution**. Nexo does not implement skill loading; it composes the
7
- [`ruby_llm-skills`](https://github.com/kieranklaassen/ruby_llm-skills) gem so you attach a
8
- skill with one macro and no loader setup.
6
+ above perform **execution**. You attach a skill with one macro: Nexo reads the `SKILL.md`
7
+ itself, so there is no loader to set up and no extra gem to install.
9
8
 
10
9
  Drop a package under `app/skills/` (or scaffold one — see below):
11
10
 
@@ -52,10 +51,20 @@ rails g nexo:skill triage
52
51
  # create app/skills/triage/SKILL.md
53
52
  ```
54
53
 
55
- `ruby_llm-skills` is an **optional** dependency — required lazily only when you use a skill.
56
- Without it installed, `require "nexo"` still loads; touching a skill raises a clear
57
- `Nexo::MissingDependencyError` telling you to add `gem "ruby_llm-skills"`. Referencing a
58
- skill that does not exist raises `Nexo::Error` naming the missing `SKILL.md` path.
54
+ Referencing a skill that does not exist raises `Nexo::Error` naming the missing
55
+ `SKILL.md` path, as does a `SKILL.md` with no YAML front matter.
56
+
57
+ > **Upgrading from 0.12:** remove `gem "ruby_llm-skills"` from your Gemfile — it is no
58
+ > longer used (and it pins `ruby_llm` 1.x). The `skills` macro, `Nexo::Skills.find` and
59
+ > `Nexo::Skills.materialize` are unchanged.
60
+
61
+ ### Why not `ruby_llm`'s own skills?
62
+
63
+ `ruby_llm` 2.2 ships skills too (`chat.with_skills`). Nexo does not use them, for two
64
+ reasons. Its loader enforces the Agent Skills naming rule — lowercase words joined by
65
+ hyphens — and so rejects the underscore names Nexo resolves from a symbol (`skills
66
+ :email_triage`). And it works by giving the model a `load_skill` tool, where Nexo's rule is
67
+ that a skill adds instructions and nothing else.
59
68
 
60
69
  ## Say what a skill needs with `compatibility:`
61
70
 
@@ -82,15 +91,15 @@ exactly their body, unchanged.
82
91
  It is **free text, by design** — the spec does not make it machine-checkable, and Nexo does
83
92
  not try to. It is documentation aimed at a human or a model, not a dependency manifest:
84
93
  provisioning the sandbox (a gem, a library, a config) is the job of whoever wires the agent
85
- to it, not of the skill file. `license:` and `allowed-tools:` are parsed by
86
- `ruby_llm-skills` but deliberately **not** surfaced — the first is prompt noise, and the
94
+ to it, not of the skill file. `license:` and `allowed-tools:` are read from the front
95
+ matter but deliberately **not** surfaced — the first is prompt noise, and the
87
96
  second would compete with `Nexo::Permissions`, which is the real gate.
88
97
 
89
98
  ## Skill tools stay gated
90
99
 
91
100
  A skill contributes **instructions only**. A loaded skill ships no independent tools, and
92
- Nexo deliberately does not attach `ruby_llm-skills`' progressive-disclosure tool (which
93
- reads files outside the sandbox) — so **attaching a skill never widens what an agent can
101
+ Nexo deliberately does not attach `ruby_llm`'s `load_skill` tool (which reads skill
102
+ files from the host, outside the sandbox) — so **attaching a skill never widens what an agent can
94
103
  do** beyond its configured sandbox/permission mode.
95
104
 
96
105
  ## Bundled files are not reachable until you stage them
@@ -7,7 +7,7 @@
7
7
  # * read tools are on the mcp_allow list -> the model can use them
8
8
  # * write_file is NOT on the list -> the gate returns { error: ... } (denied)
9
9
  #
10
- # Requires: ruby_llm-mcp installed, `npx` on PATH, and a model.
10
+ # Requires: `npx` on PATH, and a model. MCP ships with ruby_llm — no extra gem.
11
11
  #
12
12
  # NEXO_LIVE=1 NEXO_MODEL=gemma3:12b ruby -Ilib examples/mcp_filesystem.rb /tmp
13
13
  #