mistri 0.7.0 → 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 +321 -2
- data/CONTRIBUTING.md +17 -3
- data/NOTICE +11 -0
- data/README.md +145 -284
- 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 +815 -180
- 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 +17 -11
- 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 +10 -2
- 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 +10 -4
- metadata +29 -2
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
class Create<%= table_name.camelize %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
|
|
2
2
|
def change
|
|
3
3
|
create_table :<%= table_name %> do |t|
|
|
4
|
-
t.string :session_id, null: false
|
|
4
|
+
t.string :session_id, null: false
|
|
5
5
|
t.integer :position, null: false
|
|
6
6
|
t.text :payload<%= payload_size %>, null: false
|
|
7
7
|
t.timestamps
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
# The unique position is the optimistic concurrency boundary for
|
|
11
|
-
# independent appenders; a collision retries at the next position.
|
|
11
|
+
# independent appenders; a collision retries at the next position. It
|
|
12
|
+
# also serves every read and delete by session, so the store needs no
|
|
13
|
+
# other index.
|
|
12
14
|
add_index :<%= table_name %>, [:session_id, :position], unique: true
|
|
13
15
|
end
|
|
14
16
|
end
|
|
@@ -41,11 +41,11 @@ module Mistri
|
|
|
41
41
|
|
|
42
42
|
Callback:
|
|
43
43
|
|
|
44
|
-
connection = #{class_name}.complete(state: params[:state], code: params[:code])
|
|
44
|
+
connection = #{class_name}.complete(state: params[:state], code: params[:code], iss: params[:iss])
|
|
45
45
|
|
|
46
46
|
Then hand its tools to an agent:
|
|
47
47
|
|
|
48
|
-
agent = Mistri.agent("claude-opus-
|
|
48
|
+
agent = Mistri.agent("claude-opus-5-5", tools: connection.tools(prefix: "linear"))
|
|
49
49
|
|
|
50
50
|
Tokens are encrypted; run bin/rails db:encryption:init if you have
|
|
51
51
|
not set up Active Record encryption.
|
|
@@ -22,10 +22,11 @@ class <%= class_name %> < ApplicationRecord
|
|
|
22
22
|
[connection, flow["authorize_url"]]
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# Finish the flow from the OAuth callback.
|
|
26
|
-
|
|
25
|
+
# Finish the flow from the OAuth callback. iss is the callback's iss
|
|
26
|
+
# parameter, nil when it had none: pass params[:iss].
|
|
27
|
+
def self.complete(state:, code:, iss:)
|
|
27
28
|
connection = find_by!(state: state)
|
|
28
|
-
tokens = Mistri::MCP::OAuth.complete(code: code,
|
|
29
|
+
tokens = Mistri::MCP::OAuth.complete(code: code, iss: iss,
|
|
29
30
|
code_verifier: connection.code_verifier,
|
|
30
31
|
client_id: connection.client_id,
|
|
31
32
|
client_secret: connection.client_secret,
|
|
@@ -42,7 +43,7 @@ class <%= class_name %> < ApplicationRecord
|
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def client
|
|
45
|
-
Mistri::MCP::Client.new(url: url, token: -> { bearer_token },
|
|
46
|
+
Mistri::MCP::Client.new(url: url, token: ->(refused: nil) { bearer_token(refused: refused) },
|
|
46
47
|
allow_non_public: self.class.mcp_allow_non_public)
|
|
47
48
|
end
|
|
48
49
|
|
|
@@ -50,13 +51,25 @@ class <%= class_name %> < ApplicationRecord
|
|
|
50
51
|
Mistri::MCP.tools(client, **options)
|
|
51
52
|
end
|
|
52
53
|
|
|
53
|
-
# A fresh bearer for every request; refreshes ahead of expiry
|
|
54
|
-
# the rotated refresh token.
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
# A fresh bearer for every request; refreshes ahead of expiry, or when the
|
|
55
|
+
# server refused the stored token, and persists the rotated refresh token.
|
|
56
|
+
# A server retires a refresh token when it is used, so two refreshes at once
|
|
57
|
+
# would lose the sign-in: the row is locked, and the second process finds
|
|
58
|
+
# the first one's token there.
|
|
59
|
+
def bearer_token(refused: nil)
|
|
60
|
+
return access_token unless stale?(refused)
|
|
61
|
+
|
|
62
|
+
with_lock { refresh! if stale?(refused) }
|
|
57
63
|
access_token
|
|
58
64
|
end
|
|
59
65
|
|
|
66
|
+
def stale?(refused)
|
|
67
|
+
return false if refresh_token.blank?
|
|
68
|
+
return access_token == refused if refused
|
|
69
|
+
|
|
70
|
+
expires_at.present? && expires_at <= 1.minute.from_now
|
|
71
|
+
end
|
|
72
|
+
|
|
60
73
|
def refresh!
|
|
61
74
|
tokens = Mistri::MCP::OAuth.refresh(refresh_token: refresh_token,
|
|
62
75
|
client_id: client_id, client_secret: client_secret,
|