mistri 0.6.1 → 0.8.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 +4 -4
- data/CHANGELOG.md +355 -2
- data/CONTRIBUTING.md +17 -3
- data/NOTICE +11 -0
- data/README.md +145 -226
- data/UPGRADING.md +810 -0
- data/assets/vendors/README.md +12 -0
- data/assets/vendors/claude-mark.svg +3 -0
- data/assets/vendors/gemini-mark.svg +10 -0
- data/assets/vendors/openai-mark-dark.svg +1 -0
- data/assets/vendors/openai-mark.svg +1 -0
- data/docs/README.md +2 -1
- data/docs/context-and-workspaces.md +84 -13
- data/docs/logging.md +90 -0
- data/docs/mcp.md +762 -21
- data/docs/reliability.md +210 -24
- data/docs/sessions.md +415 -36
- data/docs/sub-agents.md +85 -7
- data/docs/tool-contracts.md +528 -13
- data/examples/approval.rb +7 -7
- data/examples/browser.rb +1 -1
- data/examples/page_editor.rb +2 -2
- data/examples/quickstart.rb +1 -1
- data/lib/generators/mistri/install/templates/migration.rb.tt +4 -2
- data/lib/generators/mistri/mcp/mcp_generator.rb +2 -2
- data/lib/generators/mistri/mcp/templates/model.rb.tt +21 -8
- data/lib/mistri/agent.rb +839 -141
- data/lib/mistri/call_order.rb +137 -0
- data/lib/mistri/child.rb +69 -13
- data/lib/mistri/compaction.rb +200 -35
- data/lib/mistri/compactor/text.rb +91 -0
- data/lib/mistri/compactor.rb +474 -117
- data/lib/mistri/console.rb +44 -11
- data/lib/mistri/content.rb +70 -3
- data/lib/mistri/definition.rb +2 -2
- data/lib/mistri/edit.rb +13 -7
- data/lib/mistri/errors.rb +37 -0
- data/lib/mistri/event.rb +20 -9
- data/lib/mistri/locks/rails_cache.rb +16 -2
- data/lib/mistri/locks.rb +12 -3
- data/lib/mistri/mcp/client.rb +247 -61
- data/lib/mistri/mcp/conversation.rb +161 -0
- data/lib/mistri/mcp/egress.rb +5 -4
- data/lib/mistri/mcp/mirror.rb +90 -0
- data/lib/mistri/mcp/negotiation.rb +222 -0
- data/lib/mistri/mcp/oauth/client_identity.rb +53 -0
- data/lib/mistri/mcp/oauth/tolerance.rb +61 -0
- data/lib/mistri/mcp/oauth.rb +303 -82
- data/lib/mistri/mcp/results.rb +97 -0
- data/lib/mistri/mcp/sdk_client.rb +47 -0
- data/lib/mistri/mcp/wires.rb +325 -52
- data/lib/mistri/mcp.rb +304 -55
- data/lib/mistri/memory.rb +1 -1
- data/lib/mistri/message.rb +45 -8
- data/lib/mistri/models.rb +146 -24
- data/lib/mistri/partial_json.rb +5 -5
- data/lib/mistri/providers/anthropic/assembler.rb +40 -3
- data/lib/mistri/providers/anthropic/serializer.rb +154 -22
- data/lib/mistri/providers/anthropic.rb +77 -12
- data/lib/mistri/providers/fake.rb +4 -1
- data/lib/mistri/providers/gemini/assembler.rb +63 -3
- data/lib/mistri/providers/gemini/serializer.rb +27 -16
- data/lib/mistri/providers/gemini.rb +56 -11
- data/lib/mistri/providers/openai/assembler.rb +36 -5
- data/lib/mistri/providers/openai/serializer.rb +76 -22
- data/lib/mistri/providers/openai.rb +91 -14
- data/lib/mistri/reminder.rb +35 -3
- data/lib/mistri/result.rb +6 -4
- data/lib/mistri/result_limit.rb +164 -0
- data/lib/mistri/sandbox/quickjs.rb +345 -0
- data/lib/mistri/sandbox.rb +18 -0
- data/lib/mistri/schema.rb +26 -2
- data/lib/mistri/scratchpad.rb +107 -0
- data/lib/mistri/session/log.rb +137 -0
- data/lib/mistri/session.rb +405 -75
- data/lib/mistri/sinks/logger.rb +407 -0
- data/lib/mistri/skills.rb +10 -4
- data/lib/mistri/spawner.rb +43 -12
- data/lib/mistri/sse.rb +3 -2
- data/lib/mistri/stores/active_record.rb +30 -6
- data/lib/mistri/stores/jsonl.rb +26 -7
- data/lib/mistri/stores/memory.rb +6 -2
- data/lib/mistri/sub_agent/execution.rb +11 -3
- data/lib/mistri/sub_agent/runtime.rb +11 -1
- data/lib/mistri/sub_agent.rb +13 -4
- data/lib/mistri/tool.rb +71 -7
- data/lib/mistri/tool_arguments.rb +10 -11
- data/lib/mistri/tool_context.rb +15 -3
- data/lib/mistri/tool_executor.rb +49 -26
- data/lib/mistri/tool_result.rb +8 -2
- data/lib/mistri/tool_search/index.rb +193 -0
- data/lib/mistri/tool_search.rb +200 -0
- data/lib/mistri/tools/delete_file.rb +22 -0
- data/lib/mistri/tools/edit_file.rb +24 -14
- data/lib/mistri/tools/find_in_file.rb +1 -0
- data/lib/mistri/tools/grep.rb +212 -0
- data/lib/mistri/tools/list_files.rb +38 -5
- data/lib/mistri/tools/read_file.rb +83 -21
- data/lib/mistri/tools/read_memory.rb +2 -1
- data/lib/mistri/tools/run_code.rb +167 -0
- data/lib/mistri/tools/write_file.rb +66 -9
- data/lib/mistri/tools.rb +72 -1
- data/lib/mistri/transport/streamable_http.rb +140 -0
- data/lib/mistri/transport.rb +53 -63
- data/lib/mistri/usage.rb +33 -4
- data/lib/mistri/version.rb +1 -1
- data/lib/mistri/workspace/active_record.rb +22 -10
- data/lib/mistri/workspace/directory.rb +5 -1
- data/lib/mistri/workspace/memory.rb +4 -0
- data/lib/mistri/workspace/path_space.rb +56 -0
- data/lib/mistri/workspace/single.rb +6 -1
- data/lib/mistri.rb +28 -4
- metadata +30 -2
data/README.md
CHANGED
|
@@ -18,15 +18,25 @@
|
|
|
18
18
|
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
|
|
19
19
|
</p>
|
|
20
20
|
|
|
21
|
+
Mistri runs AI agents inside your own Ruby application, on your models, your
|
|
22
|
+
database, your authorization, and your queue. A run can stop and wait for a
|
|
23
|
+
human to approve a tool call, then finish hours later in a different process.
|
|
24
|
+
The gem declares zero runtime dependencies.
|
|
25
|
+
|
|
21
26
|
A mistri (Urdu: مستری) is the fixer: the skilled tradesperson who actually
|
|
22
|
-
gets it done. Mistri
|
|
23
|
-
|
|
24
|
-
record. Your application owns authorization, policy, presentation, and the
|
|
25
|
-
semantics of its side effects.
|
|
27
|
+
gets it done. Mistri works in plain Ruby, Rails, Sinatra, Hanami, jobs, and
|
|
28
|
+
services.
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
<p align="center">
|
|
31
|
+
<img src="assets/vendors/claude-mark.svg" height="30" alt="Claude">
|
|
32
|
+
<picture>
|
|
33
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/vendors/openai-mark-dark.svg">
|
|
34
|
+
<img src="assets/vendors/openai-mark.svg" height="30" alt="OpenAI">
|
|
35
|
+
</picture>
|
|
36
|
+
<img src="assets/vendors/gemini-mark.svg" height="30" alt="Gemini">
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p align="center">Anthropic, OpenAI, and Gemini, each through its own native protocol.</p>
|
|
30
40
|
|
|
31
41
|
## Start in sixty seconds
|
|
32
42
|
|
|
@@ -48,7 +58,7 @@ weather = Mistri::Tool.define(
|
|
|
48
58
|
{ city: args.fetch("city"), forecast: "34 C and clear" }
|
|
49
59
|
end
|
|
50
60
|
|
|
51
|
-
agent = Mistri.agent("claude-opus-
|
|
61
|
+
agent = Mistri.agent("claude-opus-5-5", tools: [weather])
|
|
52
62
|
|
|
53
63
|
result = agent.run("What should I wear in Lahore today? One sentence.") do |event|
|
|
54
64
|
print event.delta if event.type == :text_delta
|
|
@@ -57,163 +67,117 @@ puts
|
|
|
57
67
|
```
|
|
58
68
|
|
|
59
69
|
`Mistri.agent` infers the provider from the model ID and reads
|
|
60
|
-
`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, or `GEMINI_API_KEY`.
|
|
61
|
-
|
|
62
|
-
completed invocation returns a `Mistri::Result` with status
|
|
63
|
-
predicates, final text, usage, and structured task output when requested.
|
|
64
|
-
Host-contract failures raise as documented in [Reliability](docs/reliability.md).
|
|
65
|
-
|
|
66
|
-
Runnable examples live in [`examples/`](examples).
|
|
67
|
-
|
|
68
|
-
## Why Mistri
|
|
69
|
-
|
|
70
|
-
- **One session model.** The same append-only log runs over memory, JSONL,
|
|
71
|
-
Active Record, or a host store. With a persistent store, runs can suspend,
|
|
72
|
-
reload, resume, steer, and compact without inventing a second state model. See
|
|
73
|
-
[Sessions and control](docs/sessions.md).
|
|
74
|
-
- **Human approval does not hold a thread.** A gated tool parks the request and
|
|
75
|
-
returns. With a shared store, another process can record the decision later;
|
|
76
|
-
`resume` revalidates the exact call before execution.
|
|
77
|
-
- **Provider semantics survive the abstraction.** Anthropic, OpenAI, and
|
|
78
|
-
Gemini stream through direct implementations that retain each provider's
|
|
79
|
-
reasoning, tool-pairing, and replay requirements. Unknown model IDs still
|
|
80
|
-
pass through when their provider can be inferred.
|
|
81
|
-
- **Tool input crosses a real boundary.** Completed model arguments are owned,
|
|
82
|
-
bounded, validated, and deeply frozen before hooks, approval predicates, MCP,
|
|
83
|
-
or handlers see them. See [Tool contracts](docs/tool-contracts.md).
|
|
84
|
-
- **The runtime stays small.** The [gemspec](mistri.gemspec) declares no runtime
|
|
85
|
-
gem dependencies. Optional Rails adapters load only when required.
|
|
86
|
-
- **Real APIs are part of the test strategy.** The
|
|
87
|
-
[live integration suite](CONTRIBUTING.md#setup)
|
|
88
|
-
exercises critical control, persistence, delegation, MCP, and
|
|
89
|
-
structured-output paths across all three providers when their keys are
|
|
90
|
-
present. The default CI suite remains hermetic.
|
|
70
|
+
`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, or `GEMINI_API_KEY`. Runnable examples
|
|
71
|
+
live in [`examples/`](examples).
|
|
91
72
|
|
|
92
|
-
##
|
|
73
|
+
## Watch a run happen
|
|
93
74
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
| --- | --- |
|
|
98
|
-
| A durable tool loop inside any Ruby application, with append-only sessions, approval, steering, compaction, linked workers, and provider-neutral MCP | **Mistri** |
|
|
99
|
-
| Broad model access plus media, embeddings, image generation, and Rails-backed chat | [RubyLLM](https://github.com/crmne/ruby_llm) |
|
|
100
|
-
| Agents expressed through Rails controllers, actions, callbacks, views, and Active Job | [Active Agent](https://github.com/activeagents/activeagent) |
|
|
101
|
-
|
|
102
|
-
Mistri is deliberately not a terminal UI, hosted agent service, broad media
|
|
103
|
-
client, policy engine, or exactly-once job system. The host application keeps
|
|
104
|
-
its users, authorization rules, queues, database, UI, idempotency keys, and
|
|
105
|
-
reconciliation policy. Mistri supplies the execution mechanism that connects
|
|
106
|
-
them.
|
|
107
|
-
|
|
108
|
-
## How the loop works
|
|
75
|
+
```ruby
|
|
76
|
+
Mistri.logger = Rails.logger # or any Logger-compatible object
|
|
77
|
+
```
|
|
109
78
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
79
|
+
```text
|
|
80
|
+
[mistri 0a1b2c3d] run "What is 2 plus 3?" (gpt-6.1-sol, 3 tools)
|
|
81
|
+
[mistri 0a1b2c3d] turn 1 done tool_use (312 in / 48 out)
|
|
82
|
+
[mistri 0a1b2c3d] tool add#7f3a {"a":2,"b":3}
|
|
83
|
+
[mistri 0a1b2c3d] tool add#7f3a ok 12ms "5"
|
|
84
|
+
[mistri 0a1b2c3d] text "The sum is 5."
|
|
85
|
+
[mistri 0a1b2c3d] turn 2 done stop (410 in / 22 out)
|
|
86
|
+
[mistri 0a1b2c3d] done completed in 1.2s, 2 turns, 722 in / 70 out, $0.0042
|
|
87
|
+
```
|
|
117
88
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
89
|
+
One assignment, and every run tells its story in your ordinary log: inputs,
|
|
90
|
+
tools, durations, tokens, and dollar cost whenever pricing is known. Ship
|
|
91
|
+
those lines to your log platform and you have agent observability without a
|
|
92
|
+
dashboard. `content: false` keeps the story as metadata when payloads must
|
|
93
|
+
stay out. See [Logging](docs/logging.md).
|
|
121
94
|
|
|
122
|
-
##
|
|
95
|
+
## Pause for a human
|
|
123
96
|
|
|
124
|
-
A tool
|
|
125
|
-
|
|
97
|
+
A tool can require approval. The run parks the call and returns immediately;
|
|
98
|
+
no thread waits for the decision.
|
|
126
99
|
|
|
127
100
|
```ruby
|
|
128
|
-
|
|
129
|
-
"
|
|
130
|
-
schema:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
},
|
|
134
|
-
needs_approval: ->(args) { args.fetch("total_usd") > 500 },
|
|
135
|
-
) do |args, context|
|
|
136
|
-
Bookings.create!(
|
|
137
|
-
hotel_id: args.fetch("hotel_id"),
|
|
138
|
-
traveler: context.app.fetch(:traveler),
|
|
139
|
-
)
|
|
140
|
-
end
|
|
101
|
+
issue_refund = Mistri::Tool.define(
|
|
102
|
+
"issue_refund", "Refunds an order.",
|
|
103
|
+
schema: -> { number :amount_usd, "Refund amount", required: true },
|
|
104
|
+
needs_approval: ->(args) { args.fetch("amount_usd") > 500 },
|
|
105
|
+
) { |args| Refunds.issue!(args) }
|
|
141
106
|
|
|
142
|
-
agent = Mistri.agent(
|
|
143
|
-
"claude-opus-4-8",
|
|
144
|
-
tools: [book_hotel],
|
|
145
|
-
context: { traveler: current_traveler },
|
|
146
|
-
)
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Validation runs before the approval predicate, so policy never receives a
|
|
150
|
-
string where the schema promised a number. Invalid calls return a bounded,
|
|
151
|
-
model-readable error and valid siblings still run. Mistri never coerces model
|
|
152
|
-
input implicitly.
|
|
107
|
+
agent = Mistri.agent("claude-opus-5-5", tools: [issue_refund])
|
|
153
108
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
```ruby
|
|
157
|
-
result = agent.run("Book the corner suite for the Lisbon trip")
|
|
109
|
+
result = agent.run("Refund all 640 dollars of order 1042.")
|
|
158
110
|
result.awaiting_approval? # => true; the handler did not run
|
|
159
111
|
|
|
160
112
|
call = result.pending.fetch(0)
|
|
161
113
|
agent.session.approve(call.id, note: "Approved by finance")
|
|
162
|
-
|
|
114
|
+
agent.resume
|
|
163
115
|
```
|
|
164
116
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
117
|
+
With a durable store, the decision can come from a controller, a job, or a
|
|
118
|
+
console in a different process, days later, using only the session ID and the
|
|
119
|
+
call ID. A later process builds a fresh Agent with its current tools and
|
|
120
|
+
policy; `resume` then revalidates the exact call and carries on. See
|
|
121
|
+
[Sessions and control](docs/sessions.md#human-approval).
|
|
169
122
|
|
|
170
|
-
|
|
171
|
-
[Tool contracts](docs/tool-contracts.md) for schemas, validators, normalizers,
|
|
172
|
-
`Mistri::ToolResult`, hooks, and `ends_turn`.
|
|
123
|
+
## Why Mistri
|
|
173
124
|
|
|
174
|
-
|
|
125
|
+
- **Pause for a human, resume days later.** A gated call parks and the run
|
|
126
|
+
returns; any process can record the decision and resume.
|
|
127
|
+
- **One durable session model.** The same append-only log runs over memory,
|
|
128
|
+
JSONL, Active Record, or your own store: reload, resume, steer, and
|
|
129
|
+
compact without a second state model.
|
|
130
|
+
- **Three providers, no lowest common denominator.** Anthropic, OpenAI, and
|
|
131
|
+
Gemini keep their own reasoning, tool-pairing, and replay rules.
|
|
132
|
+
- **Tools cross a real boundary.** Model arguments are validated and frozen
|
|
133
|
+
before your policy or handlers see them; invalid calls fail loudly.
|
|
134
|
+
- **Your Gemfile.lock grows by one line.** Zero runtime gem dependencies;
|
|
135
|
+
Rails adapters load only when required.
|
|
136
|
+
- **Tested against the real APIs.** The live suite runs the control,
|
|
137
|
+
persistence, delegation, MCP, and structured-output paths against actual
|
|
138
|
+
Anthropic, OpenAI, and Gemini endpoints; the default CI suite is hermetic.
|
|
175
139
|
|
|
176
|
-
|
|
177
|
-
append-only record on local disk without a database:
|
|
140
|
+
## Choose the right layer
|
|
178
141
|
|
|
179
|
-
|
|
180
|
-
store = Mistri::Stores::JSONL.new("tmp/mistri-sessions")
|
|
181
|
-
session = Mistri::Session.new(store: store)
|
|
142
|
+
These projects solve different problems:
|
|
182
143
|
|
|
183
|
-
|
|
184
|
-
|
|
144
|
+
| Need | Start with |
|
|
145
|
+
| --- | --- |
|
|
146
|
+
| A durable, approvable agent loop in any Ruby application, on a session store you own, with no runtime dependencies | **Mistri** |
|
|
147
|
+
| A full AI framework: many providers, media, embeddings, and agents persisted through Rails | [RubyLLM](https://github.com/crmne/ruby_llm) |
|
|
148
|
+
| Agents expressed through Rails controllers, actions, callbacks, views, and Active Job | [Active Agent](https://github.com/activeagents/activeagent) |
|
|
185
149
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
150
|
+
Mistri is deliberately not a terminal UI, hosted agent service, media client,
|
|
151
|
+
or job system. It owns the model loop, the tool boundary, the event stream,
|
|
152
|
+
and the session record; your application owns authorization, policy,
|
|
153
|
+
presentation, and the meaning of its side effects.
|
|
190
154
|
|
|
191
|
-
|
|
192
|
-
use the optional Active Record adapter:
|
|
155
|
+
## Sessions, steering, and stores
|
|
193
156
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
157
|
+
Sessions persist every message as it completes, so a crash or an abort leaves
|
|
158
|
+
a resumable record with no repair step. Any process can append to a live
|
|
159
|
+
session:
|
|
197
160
|
|
|
198
161
|
```ruby
|
|
199
|
-
|
|
162
|
+
store = Mistri::Stores::JSONL.new("tmp/mistri-sessions")
|
|
163
|
+
session = Mistri::Session.new(store: store)
|
|
200
164
|
|
|
201
|
-
|
|
202
|
-
```
|
|
165
|
+
Mistri.agent("claude-opus-5-5", session: session).run("Start a haiku about the sea.")
|
|
203
166
|
|
|
204
|
-
|
|
205
|
-
|
|
167
|
+
# A later process reloads the same session by ID and continues it.
|
|
168
|
+
reloaded = Mistri::Session.new(store: store, id: session.id)
|
|
169
|
+
Mistri.agent("claude-opus-5-5", session: reloaded).run("Now finish it.")
|
|
206
170
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
)
|
|
171
|
+
# Steering queues a redirect from anywhere, without the Agent object; a
|
|
172
|
+
# run in flight folds it at its next turn.
|
|
173
|
+
reloaded.steer("Make it about the mountains instead.")
|
|
211
174
|
```
|
|
212
175
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
176
|
+
For a database-backed store, run `bin/rails generate mistri:install AgentEntry`
|
|
177
|
+
and use the Active Record adapter, or implement `append(id, entry)` and
|
|
178
|
+
`load(id)` on anything. Only one Agent may run a session at a time; approvals,
|
|
179
|
+
steering, and worker reports may append concurrently. See
|
|
180
|
+
[Sessions and control](docs/sessions.md).
|
|
217
181
|
|
|
218
182
|
## Streaming into any Ruby application
|
|
219
183
|
|
|
@@ -226,35 +190,27 @@ sink = Mistri::Sinks::Coalesced.new(sse) # merge token bursts to UI speed
|
|
|
226
190
|
agent.run(input, &sink)
|
|
227
191
|
```
|
|
228
192
|
|
|
229
|
-
`Mistri::Sinks::ActionCable` is available for Rails, but no Railtie is
|
|
230
|
-
The same event stream works in Sinatra, Rack, a WebSocket server, a
|
|
231
|
-
job, or a test.
|
|
232
|
-
the types they use and ignore the rest.
|
|
193
|
+
`Mistri::Sinks::ActionCable` is available for Rails, but no Railtie is
|
|
194
|
+
required. The same event stream works in Sinatra, Rack, a WebSocket server, a
|
|
195
|
+
background job, or a test.
|
|
233
196
|
|
|
234
197
|
## Long conversations and structured tasks
|
|
235
198
|
|
|
236
|
-
Compaction is on by default for
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
199
|
+
Compaction is on by default for models with a known context window: near the
|
|
200
|
+
limit, a summary takes the place of the earlier turns and the run continues
|
|
201
|
+
from it, while the exact history stays in the store. On Claude and GPT the
|
|
202
|
+
provider's own compaction writes it, and elsewhere Mistri asks for it. Task
|
|
203
|
+
mode requires a final JSON value matching a schema, validated locally whenever
|
|
204
|
+
the run completes normally.
|
|
240
205
|
|
|
241
206
|
```ruby
|
|
242
207
|
agent.context_usage
|
|
243
|
-
# => { tokens: 141_000, window: 1_000_000, fraction: 0.141
|
|
244
|
-
|
|
245
|
-
agent.compact # explicit checkpoint; returns nil when nothing should compact
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Task mode requires a final JSON value matching a schema. Providers use native
|
|
249
|
-
constraints only when they can represent the contract; Mistri validates the
|
|
250
|
-
answer locally in every case.
|
|
208
|
+
# => { tokens: 141_000, window: 1_000_000, fraction: 0.141, estimated: 0,
|
|
209
|
+
# threshold: 867_904, remaining: 726_904 }
|
|
251
210
|
|
|
252
|
-
```ruby
|
|
253
211
|
schema = {
|
|
254
212
|
type: "object",
|
|
255
|
-
properties: {
|
|
256
|
-
"tiers" => { type: "array", items: { type: "string" } },
|
|
257
|
-
},
|
|
213
|
+
properties: { "tiers" => { type: "array", items: { type: "string" } } },
|
|
258
214
|
required: ["tiers"],
|
|
259
215
|
}
|
|
260
216
|
|
|
@@ -262,41 +218,34 @@ result = agent.task("Extract the pricing tiers.", schema: schema)
|
|
|
262
218
|
result.output # parsed and validated
|
|
263
219
|
```
|
|
264
220
|
|
|
265
|
-
Task validation applies when that invocation completes normally. An approval
|
|
266
|
-
suspension or `ends_turn` handoff returns with `output` nil; after settlement or
|
|
267
|
-
the human answer, call `task` again if structured output is still required.
|
|
268
|
-
|
|
269
221
|
See [Sessions and control](docs/sessions.md) for compaction boundaries,
|
|
270
|
-
cross-provider replay,
|
|
222
|
+
cross-provider replay, and transcripts.
|
|
271
223
|
|
|
272
224
|
## Sub-agents
|
|
273
225
|
|
|
274
|
-
Delegate work into a child session so exploration does not consume the
|
|
275
|
-
context. Only the report returns
|
|
276
|
-
|
|
226
|
+
Delegate work into a child session so exploration does not consume the
|
|
227
|
+
parent's context. Only the report returns; the full child transcript stays
|
|
228
|
+
linked and inspectable.
|
|
277
229
|
|
|
278
230
|
```ruby
|
|
279
231
|
researcher = Mistri::SubAgent.new(
|
|
280
232
|
name: "researcher",
|
|
281
233
|
description: "Reads pages and answers factual questions.",
|
|
282
|
-
provider: Mistri.provider("claude-haiku-
|
|
283
|
-
system: "Research the question. Return findings and sources.",
|
|
234
|
+
provider: Mistri.provider("claude-haiku-5-5"),
|
|
284
235
|
tools: [fetch_page],
|
|
285
236
|
)
|
|
286
237
|
|
|
287
|
-
agent = Mistri.agent("claude-opus-
|
|
238
|
+
agent = Mistri.agent("claude-opus-5-5", tools: [researcher.tool])
|
|
288
239
|
```
|
|
289
240
|
|
|
290
|
-
Mistri also provides
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
[Sub-agents](docs/sub-agents.md), including the runtime, concurrency, and lease
|
|
294
|
-
limits a production dispatcher must understand.
|
|
241
|
+
Mistri also provides an open spawn tool, background dispatch through your own
|
|
242
|
+
queue, worker reports, steering, stopping, and a management console. See
|
|
243
|
+
[Sub-agents](docs/sub-agents.md).
|
|
295
244
|
|
|
296
245
|
## Model Context Protocol
|
|
297
246
|
|
|
298
|
-
Bridge tools over Streamable HTTP or stdio, then apply the same local
|
|
299
|
-
and validation boundary:
|
|
247
|
+
Bridge tools over Streamable HTTP or stdio, then apply the same local
|
|
248
|
+
approval and validation boundary:
|
|
300
249
|
|
|
301
250
|
```ruby
|
|
302
251
|
client = Mistri::MCP::Client.new(
|
|
@@ -304,58 +253,33 @@ client = Mistri::MCP::Client.new(
|
|
|
304
253
|
token: -> { connection.bearer_token },
|
|
305
254
|
)
|
|
306
255
|
|
|
307
|
-
tools = Mistri::MCP.tools(
|
|
308
|
-
client,
|
|
309
|
-
prefix: "linear",
|
|
310
|
-
gates: { "create_issue" => true },
|
|
311
|
-
)
|
|
256
|
+
tools = Mistri::MCP.tools(client, prefix: "linear", gates: { "create_issue" => true })
|
|
312
257
|
```
|
|
313
258
|
|
|
314
|
-
Remote URLs default to public HTTPS with validated, pinned DNS answers
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
optional host adapter.
|
|
319
|
-
|
|
320
|
-
Read [MCP](docs/mcp.md) for stdio, OAuth, private-network policy, schema
|
|
321
|
-
authority, response limits, and large-result resource links.
|
|
259
|
+
Remote URLs default to public HTTPS with validated, pinned DNS answers, and
|
|
260
|
+
an unconfirmed tool call is never replayed automatically. A server with a long
|
|
261
|
+
tool list can be bridged with `deferred: true`, and the model then finds and
|
|
262
|
+
loads the tools it needs. See [MCP](docs/mcp.md).
|
|
322
263
|
|
|
323
264
|
## Skills, definitions, and workspaces
|
|
324
265
|
|
|
325
|
-
- **Skills** expose one-line descriptions until the model
|
|
266
|
+
- **Skills** expose one-line descriptions until the model asks for the full
|
|
326
267
|
`SKILL.md`, keeping the system prompt small.
|
|
327
|
-
- **Definitions** load an agent's model,
|
|
328
|
-
|
|
268
|
+
- **Definitions** load an agent's model, tools, and prompt from Markdown with
|
|
269
|
+
YAML frontmatter.
|
|
329
270
|
- **Workspaces** give the built-in read, write, edit, find, and list tools a
|
|
330
|
-
directory, memory value, Active Record table, or single host-owned
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
changes. A Directory workspace rejects lexical escape and traversal through
|
|
335
|
-
existing symlinks in a stable, host-controlled tree; it is not an
|
|
336
|
-
operating-system sandbox. See
|
|
337
|
-
[Context and workspaces](docs/context-and-workspaces.md) and the runnable
|
|
271
|
+
directory, a memory value, an Active Record table, or a single host-owned
|
|
272
|
+
value; the edit engine refuses ambiguous matches.
|
|
273
|
+
|
|
274
|
+
See [Context and workspaces](docs/context-and-workspaces.md) and the runnable
|
|
338
275
|
[`page_editor.rb`](examples/page_editor.rb) example.
|
|
339
276
|
|
|
340
277
|
## Reliability contract
|
|
341
278
|
|
|
342
279
|
Mistri makes failures explicit, but it does not pretend distributed side
|
|
343
|
-
effects are exactly once:
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
replays an ambiguous tool call; the Agent bridge returns the uncertainty as
|
|
347
|
-
an error-marked tool result.
|
|
348
|
-
- A process can crash after a handler commits an external write but before the
|
|
349
|
-
result reaches the session. Tools with side effects must be idempotent or
|
|
350
|
-
reconcilable.
|
|
351
|
-
- Budgets are checked between model-visible turns, so they are soft ceilings.
|
|
352
|
-
- Provider and MCP records default to an 8 MiB per-record limit; streaming has
|
|
353
|
-
no total-size limit while each record remains safe.
|
|
354
|
-
- `Mistri::AbortSignal` is an in-process cooperative signal. Cross-process
|
|
355
|
-
worker control uses the configured lock adapter and is also cooperative.
|
|
356
|
-
|
|
357
|
-
The complete operational contract, event lifecycle, retry behavior, pricing
|
|
358
|
-
rules, and sink guidance live in [Reliability](docs/reliability.md).
|
|
280
|
+
effects are exactly once: tools with external side effects must be idempotent
|
|
281
|
+
or reconcilable, and budgets are soft ceilings checked between turns. The
|
|
282
|
+
complete operational contract lives in [Reliability](docs/reliability.md).
|
|
359
283
|
|
|
360
284
|
## Documentation
|
|
361
285
|
|
|
@@ -367,6 +291,7 @@ GitHub:
|
|
|
367
291
|
| [Documentation index](docs/README.md) | The complete task-oriented map |
|
|
368
292
|
| [Tool contracts](docs/tool-contracts.md) | Schemas, validation, approval, hooks, results, and handoff |
|
|
369
293
|
| [Sessions and control](docs/sessions.md) | Stores, replay, approvals, steering, compaction, and transcripts |
|
|
294
|
+
| [Logging](docs/logging.md) | The run log, its options, and its operational guarantees |
|
|
370
295
|
| [Context and workspaces](docs/context-and-workspaces.md) | Skills, definitions, context transforms, host-owned memory, and editable documents |
|
|
371
296
|
| [Sub-agents](docs/sub-agents.md) | Specialists, spawning, dispatch, locks, reports, and control |
|
|
372
297
|
| [MCP](docs/mcp.md) | HTTP and stdio, OAuth, egress policy, limits, and schema handling |
|
|
@@ -383,29 +308,23 @@ $ bundle exec rake test
|
|
|
383
308
|
$ bundle exec rubocop
|
|
384
309
|
```
|
|
385
310
|
|
|
386
|
-
Live tests read provider keys from the gitignored
|
|
387
|
-
`.env.development.local` file:
|
|
311
|
+
Live tests read provider keys from the gitignored `.env.development.local`:
|
|
388
312
|
|
|
389
313
|
```console
|
|
390
|
-
$
|
|
314
|
+
$ bundle exec rake live
|
|
391
315
|
$ bundle exec rake integration
|
|
392
|
-
$ MISTRI_INTEGRATION_MODELS=claude-opus-4-8 bundle exec rake integration
|
|
393
316
|
```
|
|
394
317
|
|
|
395
|
-
|
|
396
|
-
Anthropic, OpenAI, and Gemini model by default when the corresponding keys are
|
|
397
|
-
present. See
|
|
398
|
-
[CONTRIBUTING.md](CONTRIBUTING.md) for the project contract.
|
|
318
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the project contract.
|
|
399
319
|
|
|
400
320
|
## Compatibility and support
|
|
401
321
|
|
|
402
322
|
Mistri supports Ruby 3.2 and newer. It is pre-1.0: minor releases may include
|
|
403
|
-
intentional contract changes with an explicit migration path
|
|
404
|
-
[UPGRADING.md](UPGRADING.md)
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
described in [SECURITY.md](SECURITY.md).
|
|
323
|
+
intentional contract changes with an explicit migration path; read
|
|
324
|
+
[UPGRADING.md](UPGRADING.md) before upgrading. Use
|
|
325
|
+
[GitHub issues](https://github.com/mcheemaa/mistri/issues) for reproducible
|
|
326
|
+
bugs and focused proposals, and report vulnerabilities privately as described
|
|
327
|
+
in [SECURITY.md](SECURITY.md).
|
|
409
328
|
|
|
410
329
|
## Credits
|
|
411
330
|
|