nexo_ai 0.11.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.rdoc_options +5 -0
  3. data/CHANGELOG.md +95 -0
  4. data/README.md +13 -14
  5. data/Rakefile +5 -0
  6. data/docs/concurrency.md +1 -2
  7. data/docs/durable-workflows.md +5 -3
  8. data/docs/getting-started.md +1 -1
  9. data/docs/loops.md +62 -89
  10. data/docs/mcp.md +57 -51
  11. data/docs/rails.md +1 -1
  12. data/docs/sessions.md +7 -3
  13. data/docs/skills.md +20 -11
  14. data/docs/workflows.md +2 -2
  15. data/examples/mcp_filesystem.rb +1 -1
  16. data/lib/generators/nexo/artifacts/artifacts_generator.rb +9 -7
  17. data/lib/generators/nexo/artifacts/templates/add_artifacts_to_nexo_workflow_runs.rb +1 -1
  18. data/lib/generators/nexo/install/install_generator.rb +7 -5
  19. data/lib/generators/nexo/skill/skill_generator.rb +10 -8
  20. data/lib/generators/nexo/state/state_generator.rb +9 -7
  21. data/lib/generators/nexo/state/templates/add_state_to_nexo_workflow_runs.rb +1 -1
  22. data/lib/generators/nexo/workflows/templates/create_nexo_workflow_runs.rb +3 -3
  23. data/lib/generators/nexo/workflows/workflows_generator.rb +7 -5
  24. data/lib/nexo/agent.rb +159 -169
  25. data/lib/nexo/concurrent.rb +18 -16
  26. data/lib/nexo/configuration.rb +21 -21
  27. data/lib/nexo/engine.rb +1 -1
  28. data/lib/nexo/loop.rb +12 -14
  29. data/lib/nexo/loops/ruby_llm.rb +43 -34
  30. data/lib/nexo/mcp/gated_tool.rb +31 -27
  31. data/lib/nexo/mcp.rb +73 -68
  32. data/lib/nexo/output_truncator.rb +9 -9
  33. data/lib/nexo/permissions.rb +44 -46
  34. data/lib/nexo/read_tracker.rb +4 -4
  35. data/lib/nexo/run_store.rb +30 -28
  36. data/lib/nexo/sandbox.rb +29 -27
  37. data/lib/nexo/sandboxes/container.rb +75 -75
  38. data/lib/nexo/sandboxes/local.rb +15 -15
  39. data/lib/nexo/sandboxes/remote.rb +25 -23
  40. data/lib/nexo/sandboxes/virtual.rb +2 -2
  41. data/lib/nexo/sandboxes.rb +9 -9
  42. data/lib/nexo/session.rb +31 -29
  43. data/lib/nexo/skills/skill.rb +89 -0
  44. data/lib/nexo/skills.rb +33 -58
  45. data/lib/nexo/tools/fetch.rb +21 -21
  46. data/lib/nexo/tools/glob.rb +6 -6
  47. data/lib/nexo/tools/read_file.rb +8 -8
  48. data/lib/nexo/tools/shell.rb +7 -7
  49. data/lib/nexo/tools/web_search.rb +16 -16
  50. data/lib/nexo/tools/write_file.rb +11 -11
  51. data/lib/nexo/turbo_broadcaster.rb +1 -1
  52. data/lib/nexo/version.rb +2 -2
  53. data/lib/nexo/workflow.rb +207 -193
  54. data/lib/nexo/workflow_job.rb +6 -6
  55. data/lib/nexo/workflow_run.rb +10 -10
  56. data/lib/nexo.rb +28 -26
  57. data/sig/nexo/agent.rbs +1 -1
  58. metadata +7 -34
  59. data/lib/nexo/loops/agent_sdk.rb +0 -68
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
data/docs/workflows.md CHANGED
@@ -176,7 +176,7 @@ artifact("digest.md", from: "app/templates/digest.md.erb",
176
176
  > or uploaded template is remote code execution. If a body is untrusted, pass it
177
177
  > as `content:` (inert data), not as a `from:` template.
178
178
 
179
- See [`examples/artifact_from_template.rb`](../examples/artifact_from_template.rb) for
179
+ See [`examples/artifact_from_template.rb`](https://github.com/maquina-app/nexo/blob/main/examples/artifact_from_template.rb) for
180
180
  the full offline flow (`ruby -Ilib examples/artifact_from_template.rb`).
181
181
  ### Agent output — `produces`
182
182
 
@@ -307,7 +307,7 @@ end
307
307
  > *how* (skills/instructions). Driving an agent never widens its authority — its
308
308
  > safe default (`:read_only`) is untouched.
309
309
 
310
- See [`examples/inbox_digest_task.rb`](../examples/inbox_digest_task.rb) for a live
310
+ See [`examples/inbox_digest_task.rb`](https://github.com/maquina-app/nexo/blob/main/examples/inbox_digest_task.rb) for a live
311
311
  example that wraps the MCP-backed `InboxTriage` agent in a workflow and captures
312
312
  the digest as an artifact.
313
313
 
@@ -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
  #
@@ -5,15 +5,17 @@ require "rails/generators/migration"
5
5
 
6
6
  module Nexo
7
7
  module Generators
8
- # Adds the +artifacts+ column to an already-installed +nexo_workflow_runs+
8
+ # Adds the `artifacts` column to an already-installed `nexo_workflow_runs`
9
9
  # table (Spec 7):
10
10
  #
11
- # rails g nexo:artifacts
11
+ # ```sh
12
+ # rails g nexo:artifacts
13
+ # ```
12
14
  #
13
- # copies a timestamped, additive migration adding a +json+ +artifacts+ column
14
- # (default +[]+), after which +rails db:migrate+ lets Nexo::Workflow runs
15
+ # copies a timestamped, additive migration adding a `json` `artifacts` column
16
+ # (default `[]`), after which `rails db:migrate` lets Nexo::Workflow runs
15
17
  # record named artifacts. Fresh installs get the column from
16
- # +nexo:workflows+ directly; this generator is for apps installed before
18
+ # `nexo:workflows` directly; this generator is for apps installed before
17
19
  # Spec 7. Modeled on WorkflowsGenerator.
18
20
  class ArtifactsGenerator < Rails::Generators::Base
19
21
  include Rails::Generators::Migration
@@ -27,8 +29,8 @@ module Nexo
27
29
  ::ActiveRecord::Migration.next_migration_number(next_migration_number)
28
30
  end
29
31
 
30
- # Generation step: copy the timestamped +artifacts+-column migration into
31
- # +db/migrate+.
32
+ # Generation step: copy the timestamped `artifacts`-column migration into
33
+ # `db/migrate`.
32
34
  def create_migration_file
33
35
  migration_template "add_artifacts_to_nexo_workflow_runs.rb", "db/migrate/add_artifacts_to_nexo_workflow_runs.rb"
34
36
  end
@@ -4,7 +4,7 @@
4
4
  # column from create_nexo_workflow_runs directly). Portable json column, default
5
5
  # [], matching the events column shape.
6
6
  class AddArtifactsToNexoWorkflowRuns < ActiveRecord::Migration[8.0]
7
- # Adds the +artifacts+ json column (default +[]+) to +nexo_workflow_runs+.
7
+ # Adds the `artifacts` json column (default `[]`) to `nexo_workflow_runs`.
8
8
  def change
9
9
  add_column :nexo_workflow_runs, :artifacts, :json, null: false, default: []
10
10
  end
@@ -3,13 +3,15 @@
3
3
  require "rails/generators"
4
4
 
5
5
  module Nexo
6
- # Namespace for Nexo's Rails generators (+rails g nexo:install+,
7
- # +nexo:workflows+, +nexo:artifacts+, +nexo:state+, +nexo:skill+). Each is
6
+ # Namespace for Nexo's Rails generators (`rails g nexo:install`,
7
+ # `nexo:workflows`, `nexo:artifacts`, `nexo:state`, `nexo:skill`). Each is
8
8
  # Rails-coupled and never autoloaded by the plain-Ruby core.
9
9
  module Generators
10
10
  # Sets up the conventional Nexo layout in a host Rails app:
11
11
  #
12
- # rails g nexo:install
12
+ # ```sh
13
+ # rails g nexo:install
14
+ # ```
13
15
  #
14
16
  # creates the app/agents, app/workflows and app/skills directories (each
15
17
  # with a committable .keep) and a provider-neutral config/initializers/nexo.rb.
@@ -17,7 +19,7 @@ module Nexo
17
19
  source_root File.expand_path("templates", __dir__)
18
20
 
19
21
  # Generation step: create the app/agents, app/workflows, and app/skills
20
- # directories, each with a committable +.keep+.
22
+ # directories, each with a committable `.keep`.
21
23
  def create_directories
22
24
  %w[app/agents app/workflows app/skills].each do |dir|
23
25
  empty_directory dir
@@ -26,7 +28,7 @@ module Nexo
26
28
  end
27
29
 
28
30
  # Generation step: copy the provider-neutral
29
- # +config/initializers/nexo.rb+ into the host app.
31
+ # `config/initializers/nexo.rb` into the host app.
30
32
  def copy_initializer
31
33
  copy_file "nexo.rb", "config/initializers/nexo.rb"
32
34
  end
@@ -7,21 +7,23 @@ module Nexo
7
7
  module Generators
8
8
  # Scaffolds an Agent Skills package in a host Rails app:
9
9
  #
10
- # rails g nexo:skill triage
10
+ # ```sh
11
+ # rails g nexo:skill triage
12
+ # ```
11
13
  #
12
- # creates +app/skills/triage/SKILL.md+ (valid frontmatter + placeholder
14
+ # creates `app/skills/triage/SKILL.md` (valid frontmatter + placeholder
13
15
  # process steps, per agentskills.io/specification) and a kept
14
- # +app/skills/triage/references/+ directory for supporting docs the skill can
15
- # cite. Reference it from an agent with the +skills :triage+ macro.
16
+ # `app/skills/triage/references/` directory for supporting docs the skill can
17
+ # cite. Reference it from an agent with the `skills :triage` macro.
16
18
  #
17
- # Rails-coupled, like Nexo's other generators: it requires +rails/generators+
19
+ # Rails-coupled, like Nexo's other generators: it requires `rails/generators`
18
20
  # at load time and is never autoloaded by the plain-Ruby core, so
19
- # +require "nexo"+ with no Rails present neither defines nor fails on it.
21
+ # `require "nexo"` with no Rails present neither defines nor fails on it.
20
22
  class SkillGenerator < Rails::Generators::NamedBase
21
23
  source_root File.expand_path("templates", __dir__)
22
24
 
23
- # Generation step: scaffold +app/skills/<name>/+ with a kept +references/+
24
- # directory and a valid +SKILL.md+ rendered from the template.
25
+ # Generation step: scaffold `app/skills/<name>/` with a kept `references/`
26
+ # directory and a valid `SKILL.md` rendered from the template.
25
27
  def create_skill_package
26
28
  empty_directory File.join(skill_root, "references")
27
29
  # An empty references/ would not survive git; .keep keeps it tracked.
@@ -5,15 +5,17 @@ require "rails/generators/migration"
5
5
 
6
6
  module Nexo
7
7
  module Generators
8
- # Adds the +state+ column to an already-installed +nexo_workflow_runs+ table
8
+ # Adds the `state` column to an already-installed `nexo_workflow_runs` table
9
9
  # (Spec 13):
10
10
  #
11
- # rails g nexo:state
11
+ # ```sh
12
+ # rails g nexo:state
13
+ # ```
12
14
  #
13
- # copies a timestamped, additive migration adding a +json+ +state+ column
14
- # (default +{}+), after which +rails db:migrate+ lets Nexo::Workflow runs
15
+ # copies a timestamped, additive migration adding a `json` `state` column
16
+ # (default `{}`), after which `rails db:migrate` lets Nexo::Workflow runs
15
17
  # store checkpoint results and suspend metadata (durable suspend/resume).
16
- # Fresh installs get the column from +nexo:workflows+ directly; this generator
18
+ # Fresh installs get the column from `nexo:workflows` directly; this generator
17
19
  # is for apps installed before Spec 13. Modeled on ArtifactsGenerator.
18
20
  class StateGenerator < Rails::Generators::Base
19
21
  include Rails::Generators::Migration
@@ -27,8 +29,8 @@ module Nexo
27
29
  ::ActiveRecord::Migration.next_migration_number(next_migration_number)
28
30
  end
29
31
 
30
- # Generation step: copy the timestamped +state+-column migration into
31
- # +db/migrate+.
32
+ # Generation step: copy the timestamped `state`-column migration into
33
+ # `db/migrate`.
32
34
  def create_migration_file
33
35
  migration_template "add_state_to_nexo_workflow_runs.rb", "db/migrate/add_state_to_nexo_workflow_runs.rb"
34
36
  end
@@ -6,7 +6,7 @@
6
6
  # "__suspend__" suspend metadata. The migration version is resolved from the host
7
7
  # app's ActiveRecord rather than hardcoded, so it tracks whatever Rails is installed.
8
8
  class AddStateToNexoWorkflowRuns < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
9
- # Adds the +state+ json object column (default +{}+) to +nexo_workflow_runs+.
9
+ # Adds the `state` json object column (default `{}`) to `nexo_workflow_runs`.
10
10
  def change
11
11
  add_column :nexo_workflow_runs, :state, :json, null: false, default: {}
12
12
  end
@@ -4,9 +4,9 @@
4
4
  # SQLite and PostgreSQL without an adapter-aware path. The primary key is the
5
5
  # UUID string id assigned by Nexo::WorkflowRun before_create.
6
6
  class CreateNexoWorkflowRuns < ActiveRecord::Migration[8.0]
7
- # Creates the +nexo_workflow_runs+ table (UUID string primary key, portable
8
- # +json+ columns for payload/result/events/artifacts/state) plus indexes on
9
- # +workflow_class+ and +status+.
7
+ # Creates the `nexo_workflow_runs` table (UUID string primary key, portable
8
+ # `json` columns for payload/result/events/artifacts/state) plus indexes on
9
+ # `workflow_class` and `status`.
10
10
  def change
11
11
  create_table :nexo_workflow_runs, id: false do |t|
12
12
  t.string :id, null: false, primary_key: true
@@ -7,10 +7,12 @@ module Nexo
7
7
  module Generators
8
8
  # Installs the WorkflowRun persistence schema into a host Rails app:
9
9
  #
10
- # rails g nexo:workflows
10
+ # ```sh
11
+ # rails g nexo:workflows
12
+ # ```
11
13
  #
12
- # copies a timestamped migration that creates the +nexo_workflow_runs+
13
- # table, after which +rails db:migrate+ makes Nexo::Workflow runs persist
14
+ # copies a timestamped migration that creates the `nexo_workflow_runs`
15
+ # table, after which `rails db:migrate` makes Nexo::Workflow runs persist
14
16
  # to ActiveRecord instead of the in-memory store.
15
17
  class WorkflowsGenerator < Rails::Generators::Base
16
18
  include Rails::Generators::Migration
@@ -24,8 +26,8 @@ module Nexo
24
26
  ::ActiveRecord::Migration.next_migration_number(next_migration_number)
25
27
  end
26
28
 
27
- # Generation step: copy the timestamped +create_nexo_workflow_runs+
28
- # migration into +db/migrate+.
29
+ # Generation step: copy the timestamped `create_nexo_workflow_runs`
30
+ # migration into `db/migrate`.
29
31
  def create_migration_file
30
32
  migration_template "create_nexo_workflow_runs.rb", "db/migrate/create_nexo_workflow_runs.rb"
31
33
  end