silas 0.5.0 → 0.6.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.
data/docs/vs-eve.md ADDED
@@ -0,0 +1,93 @@
1
+ # Silas vs eve
2
+
3
+ > Written **2026-07-26** against **eve 0.27.6** and Silas 0.5.x, from eve's
4
+ > published docs and source. Both projects move fast — if you're reading this
5
+ > much later, re-verify before deciding.
6
+
7
+ Silas and eve share the same organising idea: **an agent is a directory of
8
+ conventional files** — instructions, one file per tool, skills, schedules,
9
+ channels, connections — running on a durable loop. You can build the same
10
+ things with either: support desks, scheduled analysts, Slack copilots,
11
+ back-office automations. eve is TypeScript-native, built by Vercel on the AI
12
+ SDK, and fully self-hostable. Silas is Rails-native, a gem inside your
13
+ existing app.
14
+
15
+ So the honest first cut is simply your stack: **a TypeScript team should use
16
+ eve; a Rails team should use Silas.** The rest of this page is for people near
17
+ the boundary — and for the differences that go deeper than language.
18
+
19
+ ---
20
+
21
+ ## The comparison
22
+
23
+ | | Silas | eve (0.27.6) |
24
+ |---|---|---|
25
+ | **Shape** | A gem in your Rails app — your database, your job queue, your auth, one deploy. | A TypeScript service beside your app, with its own workflow store and deploy. |
26
+ | **Authoring** | A directory of plain files. | A directory of plain files — genuinely the same idea. |
27
+ | **Durable loop** | Survives `kill -9`, resumes from the last completed step. Chaos-gated every release: zero duplicate effects, byte-identical replay, SQLite + Postgres. | Workflow-engine replay; interrupted steps re-run. |
28
+ | **Tool-effect semantics** | **Exactly-once** for DB-recorded effects (`transactional!` — effect + ledger in one transaction). Default at-most-once: an ambiguous crash **parks for a human**. | **At-least-once, documented as such** — "make non-idempotent side effects like charges or emails idempotent, or gate them with approval." Dedup is the tool author's job. |
29
+ | **Human-in-the-loop** | Parks at zero compute; cleared from inbox, Slack, signed email, or API; parks expire; `ask_question` for the reverse direction. | `needsApproval` on tools. |
30
+ | **Operator surface** | A production inbox mounted in your app: live traces, approval cards, audit trail, cost accounting, web chat. | A dev TUI ("not a production chat UI or customer-facing dashboard"); production UIs are assembled from templates. |
31
+ | **Memory** | Shipped: approval-gated triples with provenance and supersession. | Deliberately out of scope. |
32
+ | **Ecosystem** | Ruby/Rails. | TypeScript + the AI SDK — a much larger ecosystem, with Vercel's distribution behind it. |
33
+ | **Channels & integrations** | Slack + email built in; a generator scaffolds any transport. | More first-party surfaces, growing quickly. |
34
+ | **Maturity** | Early (0.5.x); the durability contract is chaos-verified on every release. | Weeks old publicly; backed by a platform company, shipping at platform speed. |
35
+
36
+ ---
37
+
38
+ ## Where Silas goes further
39
+
40
+ **The transaction boundary.** When an agent's consequential action is a row in
41
+ your own database — a refund, a balance move, a ledger entry — Silas commits
42
+ the effect and the ledger's dedup record **in the same transaction**. Crash
43
+ before commit: both roll back. Crash after: the step is skipped on resume.
44
+ No idempotency keys, no reconciliation. This isn't about hosting — it's about
45
+ *whose transaction it is*: any runtime outside your application database,
46
+ self-hosted or not, keeps its "this step ran" record in its own store, and two
47
+ stores can't commit atomically. eve's docs draw the same conclusion from the
48
+ other side: make your side effects idempotent, or gate them. Silas is the
49
+ framework where you don't have to.
50
+
51
+ **Ambiguity parks.** At-least-once means a crash can re-fire a side effect.
52
+ Silas's default is at-most-once with **in-doubt → human**: it never
53
+ double-fires, and an ambiguous call waits for a person.
54
+
55
+ **The operator surface ships.** `mount Silas::Engine` and the inbox exists —
56
+ held/working/filed rail, live traces, approval cards, audit trail, cost, web
57
+ chat — behind your app's own auth.
58
+
59
+ **Memory ships.** Approval-gated, with provenance and supersession. eve
60
+ reasonably says "bring your own"; Silas ships the batteries.
61
+
62
+ ## Where eve goes further
63
+
64
+ - **The ecosystem.** TypeScript and the AI SDK are where most of the agent
65
+ world lives — more examples, more integrations, a bigger hiring pool, and
66
+ Vercel's reach.
67
+ - **Surface breadth and velocity.** More first-party channels and
68
+ integrations today, with a platform company's release cadence.
69
+ - **Sandboxing posture.** Container sandboxes are integral to eve's design.
70
+ Silas ships an interim Docker seam and reaches microVM-class isolation via
71
+ the [hermetic](https://github.com/danielstpaul/hermetic) gem.
72
+
73
+ ---
74
+
75
+ ## Choosing
76
+
77
+ **Pick Silas** if you're on Rails — your agent's tools are ordinary Ruby
78
+ against your own models, the inbox lives behind your auth, and effects your
79
+ app records in its own database get exactly-once semantics no external
80
+ runtime can match. Especially if your agents move money.
81
+
82
+ **Pick eve** if you're in TypeScript — it's an excellent framework with the
83
+ same authoring model, the ecosystem's momentum, and Vercel behind it.
84
+
85
+ Near the boundary (a Rails shop with a TS front-of-house, say): decide by
86
+ where your consequential side effects live. If they're rows in the Rails
87
+ app's database, that's where the agent belongs.
88
+
89
+ ---
90
+
91
+ *Claims about eve come from its docs and source at 0.27.6, quoted or
92
+ paraphrased in good faith; corrections welcome. Silas's numbers are
93
+ reproducible from `chaos_host/results/`.*
data/docs/why-silas.md ADDED
@@ -0,0 +1,87 @@
1
+ # Why Silas
2
+
3
+ ## Build agents the way you build Rails apps
4
+
5
+ Silas is for the same things every modern agent framework is for: a support
6
+ desk that actually resolves tickets, an analyst that posts the Monday digest,
7
+ an ops copilot in Slack, a back-office agent that chases invoices. An agent is
8
+ a directory of plain files — a persona, a data-only config, one file per tool
9
+ — and the framework supplies the durable loop, the scheduling, the channels,
10
+ the memory, and the operator surface. If you've looked at eve, the authoring
11
+ model will feel immediately familiar; that shape is the category's best idea,
12
+ and Silas embraces it.
13
+
14
+ What's different is *where it runs*. Silas isn't a second runtime you stand
15
+ beside your app — it's a gem inside the Rails app you already deploy:
16
+
17
+ - **Your tools are your app.** `Order.find_by!`, `refunds.create!`, your
18
+ service objects, your validations — no RPC layer between the agent and the
19
+ domain, because the agent lives where the domain lives.
20
+ - **Your auth is the agent's auth.** The operator inbox mounts as an engine
21
+ and hides behind whatever `current_user` already means. No second dashboard,
22
+ no second login, no second audit domain.
23
+ - **Your deploy is the agent's deploy.** One repo, one CI, one Kamal push.
24
+ The durable substrate — a database, Solid Queue, Active Job Continuations —
25
+ is already booted.
26
+
27
+ ## The guarantees go further
28
+
29
+ Every serious framework makes the loop durable. Silas draws the line a step
30
+ past that, and verifies it with a chaos harness that `kill -9`s live agents
31
+ hundreds of times per release (zero duplicate effects, byte-identical replay
32
+ — [guarantees](guarantees.md)):
33
+
34
+ - **Exactly-once tool effects.** A `transactional!` tool's database write and
35
+ the ledger's record of it commit in **one transaction**. A crash mid-refund
36
+ leaves exactly one refund row — never two, never zero — with no idempotency
37
+ key required. Only a framework *inside* your app can offer this: an external
38
+ runtime's ledger can never join your database transaction.
39
+ - **Ambiguity waits for a person.** The default mode is at-most-once: a crash
40
+ that makes "did it send?" unanswerable parks the call **in doubt** for a
41
+ human verdict instead of re-firing blind. Never double-pay; sometimes ask.
42
+ - **Holds cost nothing.** An approval, a question, or a budget breach parks
43
+ the turn at zero compute — the job exits, and clearing it resumes from
44
+ durable rows without re-calling the model.
45
+
46
+ If your agents only ever read, any durable loop will do. The moment one
47
+ touches money, inventory, or anything you'd hate to see happen twice, this is
48
+ the difference you'll feel.
49
+
50
+ ## Batteries included
51
+
52
+ A production operator inbox (live traces, approval cards, audit trail, cost
53
+ accounting), approval-gated memory with provenance, deterministic evals as a
54
+ deploy gate, Slack and email channels plus a generator for any transport, a
55
+ JSON API with SSE, per-turn budgets, replay-safe compaction — shipped in the
56
+ gem, not assembled from templates. And one command builds a working agent app
57
+ from nothing:
58
+
59
+ ```bash
60
+ rails new desk -m https://raw.githubusercontent.com/danielstpaul/silas/main/templates/desk.rb
61
+ ```
62
+
63
+ ## The honest notes
64
+
65
+ - **Silas is early** — 0.5.x, and the guarantees are proven by a reproducible
66
+ chaos harness rather than years of production traffic. The contract is
67
+ measured on every release, and it's stated precisely so you know exactly
68
+ what's promised.
69
+ - **Rails-only, on purpose.** If your team lives in TypeScript, eve is
70
+ excellent and closer to home — the [comparison](vs-eve.md) is honest about
71
+ that in both directions.
72
+ - **Exactly-once applies to effects in your database.** A raw external call
73
+ with no idempotency key of its own gets at-most-once + in-doubt parking —
74
+ strong, but not transactional. Model money as rows (your app probably
75
+ already does) and you get the full guarantee.
76
+ - **Inference goes to your configured provider.** Agent state stays in your
77
+ database; prompts still travel to the model you choose.
78
+ - **Untrusted code needs a real sandbox.** The built-in Docker seam is
79
+ interim; configure [hermetic](https://github.com/danielstpaul/hermetic) for
80
+ microVM-class isolation before running code you didn't write.
81
+
82
+ ## Try the claim
83
+
84
+ Run the template, ask for the £64 refund, clear it from the inbox — and while
85
+ the turn is resuming, `kill -9` the worker. Restart it. The turn completes
86
+ from its last checkpoint, and `Refund.count` is exactly 1. That's the pitch,
87
+ reproduced on your laptop in five minutes.
@@ -34,6 +34,15 @@ module Silas
34
34
  template "channel_email.rb", "app/agent/channels/email.rb"
35
35
  end
36
36
 
37
+ # A Claude Code / coding-agent skill: the app/agent/ conventions, the
38
+ # effect-mode and approval decision rules, and the ledger rules an agent
39
+ # must never violate — so a coding agent driving this app builds Silas
40
+ # agents correctly without the human learning the framework first.
41
+ # Delete the file if you don't use coding agents.
42
+ def create_claude_skill
43
+ template "claude_skill.md", ".claude/skills/silas/SKILL.md"
44
+ end
45
+
37
46
  def mount_engine
38
47
  route 'mount Silas::Engine => "/silas"'
39
48
  end
@@ -0,0 +1,136 @@
1
+ ---
2
+ name: silas
3
+ description: Build and modify AI agents in this Rails app with the Silas gem — tools, approvals, effect modes, schedules, channels, evals. Use whenever a task touches app/agent/, app/agents/, a Silas tool, an agent's instructions or limits, or agent durability/approval behaviour.
4
+ ---
5
+
6
+ # Building Silas agents
7
+
8
+ Silas runs durable AI agents inside this Rails app: every turn survives
9
+ `kill -9` and resumes from its last completed step, tool effects are
10
+ exactly-once, and risky calls park for a human at zero compute. The agent is
11
+ the `app/agent/` directory — you build agents by writing ordinary Ruby files
12
+ there, not by calling a framework API.
13
+
14
+ **Deep reference lives in the installed gem** — read it from the bundle when
15
+ you need more than this file:
16
+
17
+ ```sh
18
+ bundle show silas # then read README.md, docs/*.md, DEPLOY.md there
19
+ ```
20
+
21
+ ## The directory is the agent
22
+
23
+ ```
24
+ app/agent/
25
+ instructions.md # persona (ERB; snapshotted once per turn)
26
+ agent.yml # model + limits — data only, no code
27
+ tools/ # one file per tool; TOOL IDENTITY IS THE FILENAME
28
+ skills/ # markdown playbooks, loaded on demand (description: frontmatter)
29
+ schedules/ # cron.md (frontmatter) or .rb handlers -> silas:schedules compiles them
30
+ channels/ # transports (slack.rb, email.rb; generate more, see below)
31
+ app/agents/<name>/ # NAMED agents: same tree per agent, own tools/skills/schedules
32
+ ```
33
+
34
+ Files register at boot — restart the server after adding one.
35
+
36
+ ## Writing a tool (the part to get right)
37
+
38
+ ```ruby
39
+ # app/agent/tools/issue_refund.rb -> tool "issue_refund"
40
+ class Agent::Tools::IssueRefund < Silas::Tool
41
+ description "Refund part or all of an order."
42
+ param :amount_pence, :integer, desc: "Amount in pence"
43
+ approval ->(session:, input:) { input[:amount_pence] > 2000 ? :user_approval : :approved }
44
+ transactional!
45
+
46
+ def call(order_id:, amount_pence:, reason:)
47
+ Refund.create!(order_id:, amount_pence:, reason:)
48
+ end
49
+ end
50
+ ```
51
+
52
+ - **The keyword signature of `#call` IS the schema** the model sees. Keywords
53
+ only — never positional. `param` refines types/descriptions.
54
+ - **Return a Hash** (anything else is wrapped as `{"value" => ...}`). Raising
55
+ records a failed invocation the model sees — don't rescue-and-swallow.
56
+ - `session` is available inside `call` (the `Silas::Session` row).
57
+
58
+ ### Effect mode — decide by where the side effect lives
59
+
60
+ | The tool… | Declare | Why |
61
+ |---|---|---|
62
+ | writes this app's database | `transactional!` | effect + ledger row commit atomically: **exactly-once**, even through `kill -9` |
63
+ | calls an external API / sends anything | `at_most_once!` (the default) | a crash mid-call leaves it IN DOUBT → parks for a human verdict, never re-fires blind |
64
+ | only reads, safe to repeat | `idempotent!` | replays re-run it freely |
65
+
66
+ Never mark an external call `transactional!` — the ledger cannot roll back a
67
+ sent email. Model money as rows in this app's own DB whenever possible; that
68
+ is what upgrades the guarantee to exactly-once.
69
+
70
+ ### Approval — who holds the lever
71
+
72
+ `approval :never` (default) · `:always` · `:once` (one approval per identical
73
+ (tool, arguments) pair per session) · or a lambda returning `:user_approval`,
74
+ `:approved`, `:not_applicable`, or `{denied: "reason"}`. Approval parks the
75
+ turn at zero compute; a human settles it in the inbox (`/silas/inbox`), Slack,
76
+ email, or the JSON API. Gate anything that moves money or is hard to reverse.
77
+
78
+ The built-in `ask_question` tool is the reverse direction: the agent parks to
79
+ ask the operator something and resumes with their text as the tool result.
80
+
81
+ ## agent.yml
82
+
83
+ ```yaml
84
+ model: claude-sonnet-4-5 # must exist in ruby_llm's registry
85
+ description: One line, shown in rosters.
86
+ limits:
87
+ max_steps: 10 # model calls per turn
88
+ max_cost: 0.25 # dollars per turn
89
+ timeout: 300 # seconds of ACTIVE work — approval waits don't count
90
+ final_answer: # optional JSON schema -> Turn#answer_data
91
+ type: object
92
+ properties: { verdict: { type: string } }
93
+ ```
94
+
95
+ Budget breaches PARK the turn (a human can top up in the inbox); they don't
96
+ destroy work.
97
+
98
+ ## Rules that protect the durability contract
99
+
100
+ 1. **Solid Queue (or `:inline` for scripts) — never the Async adapter.** Async
101
+ double-executes continuation steps and silently voids exactly-once. Boot
102
+ raises in production if misconfigured.
103
+ 2. **Don't deploy tool/skill changes while turns are parked.** The definitions
104
+ digest fails a parked turn loudly on resume rather than running it against
105
+ a different agent (`NondeterminismError`). Settle parked turns first —
106
+ the same applies to toggling built-ins like `config.ask_question`.
107
+ 3. **Keep `Silas::DeadJobRescuerJob` in `config/recurring.yml`** — it is part
108
+ of the crash-recovery contract, and monitor worker liveness: the rescuer
109
+ can requeue work, it cannot conjure a consumer.
110
+ 4. **Never hand-delete `solid_queue_processes` rows** — a claimed job whose
111
+ process row is gone is invisible to every reaper.
112
+ 5. Tools must not spawn threads or run work outside `call` — everything the
113
+ ledger can't see is outside the guarantee.
114
+
115
+ ## Verify your work
116
+
117
+ ```sh
118
+ bin/rails silas:doctor # key, queue adapter, model, migrations, tools, rescuer
119
+ bin/rails silas:chat # talk to the agent from the terminal
120
+ bin/rails silas:eval # run test/agent_evals/*_eval.rb (deploy gate)
121
+ ```
122
+
123
+ Write an eval per behaviour you care about (`Silas::Eval.scenario` — see the
124
+ generated `test/agent_evals/example_eval.rb`). The inbox at `/silas/inbox` is
125
+ deny-by-default: wire `config.inbox_auth` in `config/initializers/silas.rb`
126
+ before expecting to see it.
127
+
128
+ ## More surface, same pattern
129
+
130
+ - **Another transport**: `bin/rails g silas:channel whatsapp` scaffolds the
131
+ signature-verifying webhook AND the outbound half (docs/channels.md in the gem).
132
+ - **A staff of agents**: `app/agents/<name>/` with its own tree;
133
+ `Silas.agent("name").start(input: ...)`; schedules in that directory tick
134
+ that agent.
135
+ - **Subagents / handoffs / memory / connections (MCP)**: see the gem README —
136
+ each is a directory or YAML file, never an orchestration graph.
@@ -11,9 +11,12 @@ RubyLLM.configure do |c|
11
11
  # hasn't migrated yet — see https://rubyllm.com/upgrading-to-1-7/
12
12
  c.use_new_acts_as = true if c.respond_to?(:use_new_acts_as=)
13
13
 
14
+ # A nil key is inert (Silas's boot check reports "no provider configured"),
15
+ # so this needs no ENV guard — and the acts_as opt-in above must run even
16
+ # on keyless boots, or the deprecation warning returns.
14
17
  c.anthropic_api_key = ENV["ANTHROPIC_API_KEY"]
15
18
  # The per-request timeout (seconds; RubyLLM default 300). Under streaming
16
19
  # this is an idle-between-chunks timeout — the hang protection for a stuck
17
20
  # provider connection.
18
21
  # c.request_timeout = 120
19
- end if ENV["ANTHROPIC_API_KEY"].present?
22
+ end
@@ -19,13 +19,18 @@ module Silas
19
19
  def max_steps(n) = (@max_steps = n)
20
20
  def approve(tool:) = (@approvals << tool.to_s)
21
21
 
22
- # on_step(0, text:, call: {name:, arguments:}, calls: [ {…}, … ])
23
- def on_step(index, text: nil, call: nil, calls: [])
22
+ # on_step(0, text:, call: {name:, arguments:}, calls: [ {…}, … ], data: {…})
23
+ # `data:` scripts a STRUCTURED answer (the final_answer schema case)
24
+ # it becomes the same {"type"=>"structured"} block the real adapter
25
+ # persists, so assert_answer_data reads it back through Turn#answer_data.
26
+ # Keys are stringified exactly as a JSON-parsed model response would be.
27
+ def on_step(index, text: nil, call: nil, calls: [], data: nil)
24
28
  tcs = (calls + [ call ].compact).each_with_index.map do |c, n|
25
29
  Silas::Adapters::ToolCall.new(id: "eval_s#{index}_#{n}", name: c[:name].to_s,
26
30
  arguments: (c[:arguments] || {}).stringify_keys)
27
31
  end
28
32
  blocks = []
33
+ blocks << { "type" => "structured", "data" => data.deep_stringify_keys } if data
29
34
  blocks << { "type" => "text", "text" => text } if text
30
35
  @steps[index] = { blocks: blocks, tool_calls: tcs }
31
36
  end
data/lib/silas/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Silas
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: silas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel St Paul
@@ -109,6 +109,7 @@ extensions: []
109
109
  extra_rdoc_files: []
110
110
  files:
111
111
  - CHANGELOG.md
112
+ - DEPLOY.md
112
113
  - LICENSE
113
114
  - README.md
114
115
  - app/controllers/concerns/silas/api/serialization.rb
@@ -147,6 +148,7 @@ files:
147
148
  - app/views/silas/inbox/invocations/_approval_card.html.erb
148
149
  - app/views/silas/inbox/invocations/_invocation.html.erb
149
150
  - app/views/silas/inbox/sessions/_cost.html.erb
151
+ - app/views/silas/inbox/sessions/_row.html.erb
150
152
  - app/views/silas/inbox/sessions/index.html.erb
151
153
  - app/views/silas/inbox/sessions/show.html.erb
152
154
  - app/views/silas/inbox/steps/_step.html.erb
@@ -164,6 +166,22 @@ files:
164
166
  - db/migrate/20260724000001_drop_agent_sdk_columns_from_silas_turns.rb
165
167
  - db/migrate/20260725000001_add_provider_to_silas_steps.rb
166
168
  - db/migrate/20260725000002_create_silas_compactions.rb
169
+ - docs/agents.md
170
+ - docs/budgets.md
171
+ - docs/cancellation.md
172
+ - docs/channels.md
173
+ - docs/configuration.md
174
+ - docs/connections.md
175
+ - docs/conventions.md
176
+ - docs/evals.md
177
+ - docs/guarantees.md
178
+ - docs/inbox-and-api.md
179
+ - docs/memory.md
180
+ - docs/sandbox.md
181
+ - docs/tools.md
182
+ - docs/tutorial.md
183
+ - docs/vs-eve.md
184
+ - docs/why-silas.md
167
185
  - lib/generators/silas/channel/channel_generator.rb
168
186
  - lib/generators/silas/channel/templates/channel.rb.tt
169
187
  - lib/generators/silas/channel/templates/controller.rb.tt
@@ -172,6 +190,7 @@ files:
172
190
  - lib/generators/silas/install/templates/bin_ci
173
191
  - lib/generators/silas/install/templates/channel_email.rb
174
192
  - lib/generators/silas/install/templates/channel_slack.rb
193
+ - lib/generators/silas/install/templates/claude_skill.md
175
194
  - lib/generators/silas/install/templates/example_eval.rb
176
195
  - lib/generators/silas/install/templates/example_schedule.md
177
196
  - lib/generators/silas/install/templates/example_skill.md
@@ -248,6 +267,8 @@ metadata:
248
267
  homepage_uri: https://github.com/danielstpaul/silas
249
268
  source_code_uri: https://github.com/danielstpaul/silas
250
269
  changelog_uri: https://github.com/danielstpaul/silas/blob/main/CHANGELOG.md
270
+ documentation_uri: https://github.com/danielstpaul/silas/tree/main/docs
271
+ bug_tracker_uri: https://github.com/danielstpaul/silas/issues
251
272
  rubygems_mfa_required: 'true'
252
273
  rdoc_options: []
253
274
  require_paths: