riffer 0.27.2 → 0.29.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/.agents/architecture.md +18 -11
- data/.agents/code-style.md +1 -1
- data/.agents/rbs-inline.md +2 -2
- data/.agents/testing.md +9 -5
- data/.release-please-manifest.json +1 -1
- data/AGENTS.md +17 -10
- data/CHANGELOG.md +31 -0
- data/README.md +17 -18
- data/Steepfile +7 -1
- data/docs/03_AGENTS.md +34 -3
- data/docs/04_AGENT_LIFECYCLE.md +134 -86
- data/docs/05_AGENT_LOOP.md +2 -2
- data/docs/06_TOOLS.md +9 -4
- data/docs/07_TOOL_ADVANCED.md +23 -19
- data/docs/08_MESSAGES.md +28 -31
- data/docs/09_STREAM_EVENTS.md +1 -1
- data/docs/10_CONFIGURATION.md +25 -15
- data/docs/providers/01_PROVIDERS.md +6 -0
- data/docs/providers/06_MOCK_PROVIDER.md +2 -1
- data/docs/providers/07_CUSTOM_PROVIDERS.md +4 -4
- data/docs/providers/08_GEMINI.md +2 -2
- data/docs/providers/09_OPENROUTER.md +242 -0
- data/lib/riffer/agent/config.rb +173 -0
- data/lib/riffer/agent/context.rb +125 -0
- data/lib/riffer/agent/response.rb +11 -2
- data/lib/riffer/agent/run.rb +308 -0
- data/lib/riffer/agent/session/repair.rb +112 -0
- data/lib/riffer/agent/session.rb +268 -0
- data/lib/riffer/{structured_output → agent/structured_output}/result.rb +1 -1
- data/lib/riffer/{structured_output.rb → agent/structured_output.rb} +4 -4
- data/lib/riffer/agent.rb +246 -684
- data/lib/riffer/config.rb +56 -7
- data/lib/riffer/evals/evaluator.rb +13 -3
- data/lib/riffer/evals/judge.rb +2 -2
- data/lib/riffer/evals/run_result.rb +2 -1
- data/lib/riffer/evals/scenario_result.rb +2 -1
- data/lib/riffer/guardrails/runner.rb +3 -2
- data/lib/riffer/helpers/call_or_value.rb +16 -0
- data/lib/riffer/helpers.rb +0 -1
- data/lib/riffer/mcp/authenticated_tool.rb +4 -0
- data/lib/riffer/mcp/client.rb +1 -1
- data/lib/riffer/mcp/registration.rb +2 -3
- data/lib/riffer/mcp/registry.rb +3 -1
- data/lib/riffer/mcp/tool_factory.rb +5 -0
- data/lib/riffer/messages/assistant.rb +9 -3
- data/lib/riffer/messages/base.rb +22 -0
- data/lib/riffer/messages/converter.rb +6 -6
- data/lib/riffer/{file_part.rb → messages/file_part.rb} +5 -5
- data/lib/riffer/messages/tool.rb +1 -1
- data/lib/riffer/messages/user.rb +4 -4
- data/lib/riffer/{boolean.rb → params/boolean.rb} +3 -3
- data/lib/riffer/{param.rb → params/param.rb} +6 -6
- data/lib/riffer/params.rb +27 -21
- data/lib/riffer/providers/amazon_bedrock.rb +19 -20
- data/lib/riffer/providers/anthropic.rb +27 -28
- data/lib/riffer/providers/base.rb +10 -9
- data/lib/riffer/providers/gemini.rb +15 -12
- data/lib/riffer/providers/mock.rb +41 -13
- data/lib/riffer/providers/open_ai.rb +24 -22
- data/lib/riffer/providers/open_router.rb +318 -0
- data/lib/riffer/providers/repository.rb +1 -0
- data/lib/riffer/{token_usage.rb → providers/token_usage.rb} +4 -4
- data/lib/riffer/providers.rb +1 -0
- data/lib/riffer/runner/fibers.rb +4 -3
- data/lib/riffer/runner/sequential.rb +1 -1
- data/lib/riffer/runner/threaded.rb +1 -1
- data/lib/riffer/runner.rb +1 -1
- data/lib/riffer/skills/activate_tool.rb +4 -3
- data/lib/riffer/skills/config.rb +1 -1
- data/lib/riffer/skills/context.rb +3 -3
- data/lib/riffer/skills/filesystem_backend.rb +7 -5
- data/lib/riffer/skills/markdown_adapter.rb +1 -1
- data/lib/riffer/skills/xml_adapter.rb +1 -1
- data/lib/riffer/stream_events/interrupt.rb +10 -3
- data/lib/riffer/stream_events/token_usage_done.rb +2 -2
- data/lib/riffer/stream_events/web_search_status.rb +1 -1
- data/lib/riffer/tool.rb +3 -3
- data/lib/riffer/{tool_runtime → tools/runtime}/fibers.rb +2 -2
- data/lib/riffer/{tool_runtime → tools/runtime}/inline.rb +1 -1
- data/lib/riffer/{tool_runtime → tools/runtime}/threaded.rb +2 -2
- data/lib/riffer/{tool_runtime.rb → tools/runtime.rb} +21 -15
- data/lib/riffer/{toolable.rb → tools/toolable.rb} +12 -9
- data/lib/riffer/version.rb +1 -1
- data/lib/riffer.rb +2 -1
- data/sig/generated/riffer/agent/config.rbs +119 -0
- data/sig/generated/riffer/agent/context.rbs +91 -0
- data/sig/generated/riffer/agent/response.rbs +10 -2
- data/sig/generated/riffer/agent/run.rbs +144 -0
- data/sig/generated/riffer/agent/session/repair.rbs +51 -0
- data/sig/generated/riffer/agent/session.rbs +145 -0
- data/sig/generated/riffer/{structured_output → agent/structured_output}/result.rbs +2 -2
- data/sig/generated/riffer/{structured_output.rbs → agent/structured_output.rbs} +6 -6
- data/sig/generated/riffer/agent.rbs +154 -225
- data/sig/generated/riffer/config.rbs +50 -5
- data/sig/generated/riffer/evals/judge.rbs +2 -2
- data/sig/generated/riffer/helpers/call_or_value.rbs +9 -0
- data/sig/generated/riffer/helpers.rbs +0 -1
- data/sig/generated/riffer/messages/assistant.rbs +7 -3
- data/sig/generated/riffer/messages/base.rbs +18 -0
- data/sig/generated/riffer/messages/converter.rbs +4 -4
- data/sig/generated/riffer/{file_part.rbs → messages/file_part.rbs} +5 -5
- data/sig/generated/riffer/messages/user.rbs +4 -4
- data/sig/generated/riffer/params/boolean.rbs +10 -0
- data/sig/generated/riffer/{param.rbs → params/param.rbs} +3 -3
- data/sig/generated/riffer/params.rbs +15 -15
- data/sig/generated/riffer/providers/amazon_bedrock.rbs +22 -22
- data/sig/generated/riffer/providers/anthropic.rbs +4 -4
- data/sig/generated/riffer/providers/base.rbs +10 -10
- data/sig/generated/riffer/providers/gemini.rbs +4 -4
- data/sig/generated/riffer/providers/mock.rbs +25 -5
- data/sig/generated/riffer/providers/open_ai.rbs +4 -4
- data/sig/generated/riffer/providers/open_router.rbs +85 -0
- data/sig/generated/riffer/{token_usage.rbs → providers/token_usage.rbs} +5 -5
- data/sig/generated/riffer/providers.rbs +1 -0
- data/sig/generated/riffer/runner/fibers.rbs +2 -2
- data/sig/generated/riffer/runner/sequential.rbs +2 -2
- data/sig/generated/riffer/runner/threaded.rbs +2 -2
- data/sig/generated/riffer/runner.rbs +2 -2
- data/sig/generated/riffer/skills/activate_tool.rbs +4 -3
- data/sig/generated/riffer/skills/config.rbs +1 -1
- data/sig/generated/riffer/skills/context.rbs +2 -2
- data/sig/generated/riffer/stream_events/interrupt.rbs +7 -2
- data/sig/generated/riffer/stream_events/token_usage_done.rbs +3 -3
- data/sig/generated/riffer/tool.rbs +5 -5
- data/sig/generated/riffer/{tool_runtime → tools/runtime}/fibers.rbs +3 -3
- data/sig/generated/riffer/{tool_runtime → tools/runtime}/inline.rbs +2 -2
- data/sig/generated/riffer/{tool_runtime → tools/runtime}/threaded.rbs +3 -3
- data/sig/generated/riffer/{tool_runtime.rbs → tools/runtime.rbs} +19 -13
- data/sig/generated/riffer/{toolable.rbs → tools/toolable.rbs} +6 -6
- data/sig/stubs/agent_ivars.rbs +7 -0
- data/sig/stubs/async.rbs +24 -0
- data/sig/stubs/aws-sdk-core/seahorse_request_context.rbs +7 -0
- data/sig/stubs/aws-sdk-core/static_token_provider.rbs +5 -0
- data/sig/stubs/extend_self.rbs +11 -0
- data/sig/stubs/lib_ivars.rbs +101 -0
- data/sig/stubs/mcp_sdk.rbs +22 -0
- data/sig/stubs/provider_ivars.rbs +36 -0
- data/sig/stubs/provider_sdk_methods.rbs +50 -0
- data/sig/stubs/zeitwerk.rbs +12 -0
- metadata +54 -33
- data/lib/riffer/core.rb +0 -28
- data/lib/riffer/helpers/validations.rb +0 -18
- data/sig/generated/riffer/boolean.rbs +0 -10
- data/sig/generated/riffer/core.rbs +0 -19
- data/sig/generated/riffer/helpers/validations.rbs +0 -12
|
@@ -51,7 +51,7 @@ class Riffer::Skills::Config
|
|
|
51
51
|
# Returns the configured override when set, or +nil+ when unset. The
|
|
52
52
|
# global fallback to <tt>Riffer.config.skills.default_activate_tool</tt>
|
|
53
53
|
# is applied by the agent at resolution time (see
|
|
54
|
-
# Riffer::Agent
|
|
54
|
+
# Riffer::Agent#resolve_tools), not by this getter.
|
|
55
55
|
#
|
|
56
56
|
# The override must be a subclass of Riffer::Tool.
|
|
57
57
|
#
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
# Coordinates skill discovery, activation, and prompt rendering.
|
|
6
6
|
# Tracks activations with caching to avoid redundant backend reads.
|
|
7
7
|
#
|
|
8
|
-
# Built by the agent
|
|
9
|
-
#
|
|
8
|
+
# Built by the agent during +Agent.new+ and exposed to tools via
|
|
9
|
+
# <tt>context.skills</tt> on the agent's +Riffer::Agent::Context+.
|
|
10
10
|
#
|
|
11
11
|
# See Riffer::Skills::Backend, Riffer::Skills::Frontmatter.
|
|
12
12
|
class Riffer::Skills::Context
|
|
@@ -7,9 +7,14 @@ class Riffer::StreamEvents::Interrupt < Riffer::StreamEvents::Base
|
|
|
7
7
|
# The reason provided with the interrupt, if any.
|
|
8
8
|
attr_reader reason: (String | Symbol)?
|
|
9
9
|
|
|
10
|
+
# Call ids of tool_use blocks that riffer filled with placeholder
|
|
11
|
+
# results when the interrupt fired. Populated only when
|
|
12
|
+
# +Riffer.config.experimental_history_healing+ is on.
|
|
13
|
+
attr_reader healed_tool_call_ids: Array[String]
|
|
14
|
+
|
|
10
15
|
# --
|
|
11
|
-
# : (?reason: (String | Symbol)?) -> void
|
|
12
|
-
def initialize: (?reason: (String | Symbol)?) -> void
|
|
16
|
+
# : (?reason: (String | Symbol)?, ?healed_tool_call_ids: Array[String]) -> void
|
|
17
|
+
def initialize: (?reason: (String | Symbol)?, ?healed_tool_call_ids: Array[String]) -> void
|
|
13
18
|
|
|
14
19
|
# Converts the event to a hash.
|
|
15
20
|
#
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
# event.token_usage.total_tokens # => 150
|
|
10
10
|
class Riffer::StreamEvents::TokenUsageDone < Riffer::StreamEvents::Base
|
|
11
11
|
# The token usage data for this response.
|
|
12
|
-
attr_reader token_usage: Riffer::TokenUsage
|
|
12
|
+
attr_reader token_usage: Riffer::Providers::TokenUsage
|
|
13
13
|
|
|
14
14
|
# --
|
|
15
|
-
# : (token_usage: Riffer::TokenUsage, ?role: Symbol) -> void
|
|
16
|
-
def initialize: (token_usage: Riffer::TokenUsage, ?role: Symbol) -> void
|
|
15
|
+
# : (token_usage: Riffer::Providers::TokenUsage, ?role: Symbol) -> void
|
|
16
|
+
def initialize: (token_usage: Riffer::Providers::TokenUsage, ?role: Symbol) -> void
|
|
17
17
|
|
|
18
18
|
# --
|
|
19
19
|
# : () -> Hash[Symbol, untyped]
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
# end
|
|
21
21
|
# end
|
|
22
22
|
class Riffer::Tool
|
|
23
|
-
extend Riffer::Toolable
|
|
23
|
+
extend Riffer::Tools::Toolable
|
|
24
24
|
|
|
25
25
|
# Executes the tool with the given arguments.
|
|
26
26
|
#
|
|
27
27
|
# Raises NotImplementedError if not implemented by subclass.
|
|
28
28
|
#
|
|
29
29
|
# --
|
|
30
|
-
# : (context:
|
|
31
|
-
def call: (context:
|
|
30
|
+
# : (context: Riffer::Agent::Context?, **untyped) -> Riffer::Tools::Response
|
|
31
|
+
def call: (context: Riffer::Agent::Context?, **untyped) -> Riffer::Tools::Response
|
|
32
32
|
|
|
33
33
|
# Creates a text response. Shorthand for Riffer::Tools::Response.text.
|
|
34
34
|
#
|
|
@@ -55,6 +55,6 @@ class Riffer::Tool
|
|
|
55
55
|
# Raises Riffer::Error if the tool does not return a Response object.
|
|
56
56
|
#
|
|
57
57
|
# --
|
|
58
|
-
# : (context:
|
|
59
|
-
def call_with_validation: (context:
|
|
58
|
+
# : (context: Riffer::Agent::Context?, **untyped) -> Riffer::Tools::Response
|
|
59
|
+
def call_with_validation: (context: Riffer::Agent::Context?, **untyped) -> Riffer::Tools::Response
|
|
60
60
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Generated from lib/riffer/
|
|
1
|
+
# Generated from lib/riffer/tools/runtime/fibers.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
# Executes tool calls concurrently using fibers via the +async+ gem.
|
|
4
4
|
#
|
|
5
5
|
# class MyAgent < Riffer::Agent
|
|
6
|
-
# tool_runtime Riffer::
|
|
6
|
+
# tool_runtime Riffer::Tools::Runtime::Fibers
|
|
7
7
|
# end
|
|
8
|
-
class Riffer::
|
|
8
|
+
class Riffer::Tools::Runtime::Fibers < Riffer::Tools::Runtime
|
|
9
9
|
# [max_concurrency] maximum number of tool calls to execute simultaneously.
|
|
10
10
|
# When +nil+, all tool calls run as fibers without limit.
|
|
11
11
|
#
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# Generated from lib/riffer/
|
|
1
|
+
# Generated from lib/riffer/tools/runtime/inline.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
# Executes tool calls sequentially in the current thread.
|
|
4
4
|
#
|
|
5
5
|
# This is the default tool runtime used when no runtime is configured.
|
|
6
|
-
class Riffer::
|
|
6
|
+
class Riffer::Tools::Runtime::Inline < Riffer::Tools::Runtime
|
|
7
7
|
# --
|
|
8
8
|
# : () -> void
|
|
9
9
|
def initialize: () -> void
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Generated from lib/riffer/
|
|
1
|
+
# Generated from lib/riffer/tools/runtime/threaded.rb with RBS::Inline
|
|
2
2
|
|
|
3
3
|
# Executes tool calls concurrently using threads.
|
|
4
4
|
#
|
|
5
5
|
# class MyAgent < Riffer::Agent
|
|
6
|
-
# tool_runtime Riffer::
|
|
6
|
+
# tool_runtime Riffer::Tools::Runtime::Threaded
|
|
7
7
|
# end
|
|
8
|
-
class Riffer::
|
|
8
|
+
class Riffer::Tools::Runtime::Threaded < Riffer::Tools::Runtime
|
|
9
9
|
DEFAULT_MAX_CONCURRENCY: Integer
|
|
10
10
|
|
|
11
11
|
# [max_concurrency] maximum number of tool calls to execute simultaneously.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Generated from lib/riffer/
|
|
1
|
+
# Generated from lib/riffer/tools/runtime.rb with RBS::Inline
|
|
2
2
|
|
|
3
|
-
# Riffer::
|
|
3
|
+
# Riffer::Tools::Runtime handles tool call execution for an agent.
|
|
4
4
|
#
|
|
5
5
|
# Composes with a Riffer::Runner for concurrency control and provides
|
|
6
6
|
# +execute+ as the sole public entry point.
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
# Subclass and override +dispatch_tool_call+ to customize how individual
|
|
9
9
|
# tool calls are dispatched (e.g., HTTP, gRPC).
|
|
10
10
|
#
|
|
11
|
-
# runtime = Riffer::
|
|
11
|
+
# runtime = Riffer::Tools::Runtime::Inline.new
|
|
12
12
|
# results = runtime.execute(tool_calls, tools: tools, context: context)
|
|
13
|
-
class Riffer::
|
|
13
|
+
class Riffer::Tools::Runtime
|
|
14
14
|
# [runner] the concurrency runner to use for batch execution.
|
|
15
15
|
#
|
|
16
|
-
# Subclasses must provide a runner; instantiating
|
|
16
|
+
# Subclasses must provide a runner; instantiating Riffer::Tools::Runtime directly
|
|
17
17
|
# raises +NotImplementedError+.
|
|
18
18
|
#
|
|
19
19
|
# --
|
|
@@ -25,20 +25,24 @@ class Riffer::ToolRuntime
|
|
|
25
25
|
# [tool_calls] the tool calls to execute.
|
|
26
26
|
# [tools] the resolved tool classes.
|
|
27
27
|
# [context] the context hash.
|
|
28
|
+
# [assistant_message] the assistant message that produced these tool
|
|
29
|
+
# calls, when known. Forwarded to +around_tool_call+ and
|
|
30
|
+
# +dispatch_tool_call+ so subclasses can access it (e.g. for
|
|
31
|
+
# instrumentation that needs the accompanying assistant text).
|
|
28
32
|
#
|
|
29
33
|
# --
|
|
30
|
-
# : (Array[Riffer::Messages::Assistant::ToolCall], tools: Array[singleton(Riffer::Tool)], context:
|
|
31
|
-
def execute: (Array[Riffer::Messages::Assistant::ToolCall], tools: Array[singleton(Riffer::Tool)], context:
|
|
34
|
+
# : (Array[Riffer::Messages::Assistant::ToolCall], tools: Array[singleton(Riffer::Tool)], context: Riffer::Agent::Context?, ?assistant_message: Riffer::Messages::Assistant?) -> Array[[Riffer::Messages::Assistant::ToolCall, Riffer::Tools::Response]]
|
|
35
|
+
def execute: (Array[Riffer::Messages::Assistant::ToolCall], tools: Array[singleton(Riffer::Tool)], context: Riffer::Agent::Context?, ?assistant_message: Riffer::Messages::Assistant?) -> Array[[ Riffer::Messages::Assistant::ToolCall, Riffer::Tools::Response ]]
|
|
32
36
|
|
|
33
37
|
# Hook that wraps each tool call execution. Override in subclasses
|
|
34
38
|
# to customize. Must +yield+ to continue execution.
|
|
35
39
|
#
|
|
36
40
|
# The default implementation simply yields.
|
|
37
41
|
#
|
|
38
|
-
# class InstrumentedRuntime < Riffer::
|
|
42
|
+
# class InstrumentedRuntime < Riffer::Tools::Runtime::Inline
|
|
39
43
|
# private
|
|
40
44
|
#
|
|
41
|
-
# def around_tool_call(tool_call, context:)
|
|
45
|
+
# def around_tool_call(tool_call, context:, assistant_message: nil)
|
|
42
46
|
# start = Time.now
|
|
43
47
|
# result = yield
|
|
44
48
|
# Rails.logger.info("Tool #{tool_call.name} took #{Time.now - start}s")
|
|
@@ -47,8 +51,8 @@ class Riffer::ToolRuntime
|
|
|
47
51
|
# end
|
|
48
52
|
#
|
|
49
53
|
# --
|
|
50
|
-
# : (Riffer::Messages::Assistant::ToolCall, context:
|
|
51
|
-
def around_tool_call: (Riffer::Messages::Assistant::ToolCall, context:
|
|
54
|
+
# : (Riffer::Messages::Assistant::ToolCall, context: Riffer::Agent::Context?, ?assistant_message: Riffer::Messages::Assistant?) { () -> Riffer::Tools::Response } -> Riffer::Tools::Response
|
|
55
|
+
def around_tool_call: (Riffer::Messages::Assistant::ToolCall, context: Riffer::Agent::Context?, ?assistant_message: Riffer::Messages::Assistant?) { () -> Riffer::Tools::Response } -> Riffer::Tools::Response
|
|
52
56
|
|
|
53
57
|
private
|
|
54
58
|
|
|
@@ -58,10 +62,12 @@ class Riffer::ToolRuntime
|
|
|
58
62
|
# [tool_call] the tool call to execute.
|
|
59
63
|
# [tools] the resolved tool classes.
|
|
60
64
|
# [context] the context hash.
|
|
65
|
+
# [assistant_message] the assistant message that produced this tool
|
|
66
|
+
# call, when known.
|
|
61
67
|
#
|
|
62
68
|
# --
|
|
63
|
-
# : (Riffer::Messages::Assistant::ToolCall, tools: Array[singleton(Riffer::Tool)], context:
|
|
64
|
-
def dispatch_tool_call: (Riffer::Messages::Assistant::ToolCall, tools: Array[singleton(Riffer::Tool)], context:
|
|
69
|
+
# : (Riffer::Messages::Assistant::ToolCall, tools: Array[singleton(Riffer::Tool)], context: Riffer::Agent::Context?, ?assistant_message: Riffer::Messages::Assistant?) -> Riffer::Tools::Response
|
|
70
|
+
def dispatch_tool_call: (Riffer::Messages::Assistant::ToolCall, tools: Array[singleton(Riffer::Tool)], context: Riffer::Agent::Context?, ?assistant_message: Riffer::Messages::Assistant?) -> Riffer::Tools::Response
|
|
65
71
|
|
|
66
72
|
# --
|
|
67
73
|
# : (String?) -> Hash[Symbol, untyped]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Generated from lib/riffer/toolable.rb with RBS::Inline
|
|
1
|
+
# Generated from lib/riffer/tools/toolable.rb with RBS::Inline
|
|
2
2
|
|
|
3
|
-
# Riffer::Toolable provides the shared class-level DSL for anything that can
|
|
3
|
+
# Riffer::Tools::Toolable provides the shared class-level DSL for anything that can
|
|
4
4
|
# present as a tool to an LLM — tools today, and subagents/workflows in the
|
|
5
5
|
# future.
|
|
6
6
|
#
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# are NOT part of Toolable — those belong on Riffer::Tool.
|
|
13
13
|
#
|
|
14
14
|
# class MyTool
|
|
15
|
-
# extend Riffer::Toolable
|
|
15
|
+
# extend Riffer::Tools::Toolable
|
|
16
16
|
#
|
|
17
17
|
# description "Does something useful"
|
|
18
18
|
#
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
# required :input, String
|
|
21
21
|
# end
|
|
22
22
|
# end
|
|
23
|
-
module Riffer::Toolable
|
|
23
|
+
module Riffer::Tools::Toolable
|
|
24
24
|
DEFAULT_TIMEOUT: Integer
|
|
25
25
|
|
|
26
26
|
# Tracks all classes that extend Toolable.
|
|
@@ -62,8 +62,8 @@ module Riffer::Toolable
|
|
|
62
62
|
# Defines parameters using the Params DSL.
|
|
63
63
|
#
|
|
64
64
|
# --
|
|
65
|
-
# : () ?{ () -> void } -> Riffer::Params?
|
|
66
|
-
def params: () ?{ () -> void } -> Riffer::Params?
|
|
65
|
+
# : () ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> Riffer::Params?
|
|
66
|
+
def params: () ?{ (Riffer::Params) [self: Riffer::Params] -> void } -> Riffer::Params?
|
|
67
67
|
|
|
68
68
|
# Returns the JSON Schema for the tool's parameters.
|
|
69
69
|
#
|
data/sig/stubs/async.rbs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Minimal signatures for the optional `async` gem, which ships no RBS.
|
|
2
|
+
#
|
|
3
|
+
# Only the surface used by Riffer::Runner::Fibers is declared; the gem is
|
|
4
|
+
# loaded lazily via depends_on, so this stub keeps Steep aware of the
|
|
5
|
+
# constants without adding a hard `library` dependency.
|
|
6
|
+
module Async
|
|
7
|
+
class Barrier
|
|
8
|
+
def initialize: () -> void
|
|
9
|
+
|
|
10
|
+
def async: () { () -> void } -> untyped
|
|
11
|
+
|
|
12
|
+
def wait: () -> void
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Semaphore
|
|
16
|
+
def initialize: (Integer, ?parent: untyped) -> void
|
|
17
|
+
|
|
18
|
+
def async: () { () -> void } -> untyped
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
module Kernel
|
|
23
|
+
def Async: () { () -> void } -> untyped
|
|
24
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# rbs-inline does not emit `extend self` for modules that use it, so their
|
|
2
|
+
# instance methods aren't visible as singleton methods. Reopening each module
|
|
3
|
+
# here to `extend` itself restores that, matching the runtime behaviour.
|
|
4
|
+
|
|
5
|
+
module Riffer::Helpers::CallOrValue
|
|
6
|
+
extend ::Riffer::Helpers::CallOrValue
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
module Riffer::Agent::Run
|
|
10
|
+
extend ::Riffer::Agent::Run
|
|
11
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Instance/module variable declarations for non-provider lib/ classes.
|
|
2
|
+
#
|
|
3
|
+
# rbs-inline's `#:` syntax types an assignment expression (a Steep assertion)
|
|
4
|
+
# but doesn't declare the instance variable itself, so we stub the ivar types
|
|
5
|
+
# here instead (mirrors sig/stubs/agent_ivars.rbs and provider_ivars.rbs).
|
|
6
|
+
|
|
7
|
+
class Riffer::Mcp::Registration
|
|
8
|
+
@cancelled: bool
|
|
9
|
+
@tools: Array[singleton(Riffer::Tool)]
|
|
10
|
+
@mutex: Thread::Mutex
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module Riffer::Mcp::Registry
|
|
14
|
+
self.@mutex: Thread::Mutex
|
|
15
|
+
self.@store: Hash[String, Riffer::Mcp::Registration]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Riffer::Mcp::Client
|
|
19
|
+
@client: untyped
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Toolable is extended onto tool classes; its instance methods run as class
|
|
23
|
+
# methods on the extender, which is also extended with ClassNameConverter
|
|
24
|
+
# (see Toolable.extended). The include models that method availability for Steep.
|
|
25
|
+
module Riffer::Tools::Toolable
|
|
26
|
+
include Riffer::Helpers::ClassNameConverter
|
|
27
|
+
|
|
28
|
+
self.@extenders: Array[Module]?
|
|
29
|
+
@description: String?
|
|
30
|
+
@identifier: String?
|
|
31
|
+
@timeout: (Integer | Float)?
|
|
32
|
+
@params_builder: Riffer::Params?
|
|
33
|
+
@kind: Symbol?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class Riffer::Evals::Judge
|
|
37
|
+
@provider_options: Hash[Symbol, untyped]
|
|
38
|
+
@provider_instance: Riffer::Providers::Base?
|
|
39
|
+
@provider_name: String?
|
|
40
|
+
@model_name: String?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class Riffer::Evals::Evaluator
|
|
44
|
+
self.@instructions: String?
|
|
45
|
+
self.@higher_is_better: bool?
|
|
46
|
+
self.@judge_model: String?
|
|
47
|
+
@judge: Riffer::Evals::Judge?
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class Riffer::Skills::Context
|
|
51
|
+
@backend: Riffer::Skills::Backend
|
|
52
|
+
@activated: Hash[String, String]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class Riffer::Skills::Config
|
|
56
|
+
@backend: (Riffer::Skills::Backend | Proc)?
|
|
57
|
+
@adapter: singleton(Riffer::Skills::Adapter)?
|
|
58
|
+
@activate: (Array[String] | Proc)?
|
|
59
|
+
@activate_tool: singleton(Riffer::Tool)?
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class Riffer::Skills::FilesystemBackend
|
|
63
|
+
@paths: Array[String]
|
|
64
|
+
@skills_cache: Hash[String, String]?
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
module Riffer
|
|
68
|
+
self.@config: Riffer::Config?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
class Riffer::Agent::Session
|
|
72
|
+
@callbacks: Array[^(Riffer::Messages::Base) -> void]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class Riffer::Agent::Context
|
|
76
|
+
@data: Hash[Symbol, untyped]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
class Riffer::Agent::Response
|
|
80
|
+
@interrupted: bool
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
class Riffer::Tools::Response
|
|
84
|
+
@success: bool
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
class Riffer::Tools::Runtime
|
|
88
|
+
@runner: Riffer::Runner
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class Riffer::Runner::Threaded
|
|
92
|
+
@max_concurrency: Integer
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class Riffer::Runner::Fibers
|
|
96
|
+
@max_concurrency: Integer?
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
class Riffer::Messages::FilePart
|
|
100
|
+
@url_string: String?
|
|
101
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Minimal signatures for the optional `mcp` gem (v0.8+), which ships no RBS.
|
|
2
|
+
#
|
|
3
|
+
# Only the surface used by Riffer::Mcp::Client is declared; the gem is loaded
|
|
4
|
+
# lazily via depends_on, so this stub keeps Steep aware of the constants
|
|
5
|
+
# without adding a hard `library` dependency (mirrors provider_sdk_methods.rbs).
|
|
6
|
+
module MCP
|
|
7
|
+
class Client
|
|
8
|
+
class HTTP
|
|
9
|
+
def initialize: (url: untyped, headers: untyped) -> void
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Tool
|
|
13
|
+
def initialize: (name: untyped, ?description: untyped, ?input_schema: untyped) -> void
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def initialize: (transport: untyped) -> void
|
|
17
|
+
|
|
18
|
+
def tools: () -> untyped
|
|
19
|
+
|
|
20
|
+
def call_tool: (tool: untyped, arguments: untyped) -> untyped
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Instance variable declarations for the provider adapters.
|
|
2
|
+
#
|
|
3
|
+
# rbs-inline's `#:` syntax types an assignment expression (a Steep assertion)
|
|
4
|
+
# but doesn't declare the instance variable itself, so we stub the ivar types
|
|
5
|
+
# here instead.
|
|
6
|
+
class Riffer::Providers::Base
|
|
7
|
+
@current_tools: Array[singleton(Riffer::Tool)]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Riffer::Providers::Anthropic
|
|
11
|
+
@client: ::Anthropic::Client
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class Riffer::Providers::OpenAI
|
|
15
|
+
@client: ::OpenAI::Client
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Riffer::Providers::OpenRouter
|
|
19
|
+
@client: ::OpenAI::Client
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class Riffer::Providers::AmazonBedrock
|
|
23
|
+
@client: ::Aws::BedrockRuntime::Client
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class Riffer::Providers::Gemini
|
|
27
|
+
@api_key: String?
|
|
28
|
+
@open_timeout: Integer
|
|
29
|
+
@read_timeout: Integer
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class Riffer::Providers::Mock
|
|
33
|
+
@responses: Array[Hash[Symbol, untyped]]
|
|
34
|
+
@current_index: Integer
|
|
35
|
+
@stubbed_responses: Array[Hash[Symbol, untyped]]
|
|
36
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Accurate signatures for SDK resource methods whose shipped RBS doesn't match
|
|
2
|
+
# the real API.
|
|
3
|
+
#
|
|
4
|
+
# The OpenAI and Anthropic gems implement these as positional `def x(params)`
|
|
5
|
+
# methods (a single options hash), but their generated RBS advertises
|
|
6
|
+
# keyword-only signatures — and the Anthropic gem omits `Messages#stream`
|
|
7
|
+
# altogether. The providers call them with a positional hash (`x(params)`) or a
|
|
8
|
+
# keyword splat (`x(**params)`); both reach the same positional parameter at
|
|
9
|
+
# runtime, so we accept either here (`| ...` extends the gem's existing
|
|
10
|
+
# overloads). Streaming methods are typed to return `untyped`: the event
|
|
11
|
+
# objects are a ~60-member union dispatched dynamically on `#type`, which the
|
|
12
|
+
# providers (and their `untyped` event handlers) already treat as dynamic.
|
|
13
|
+
module OpenAI
|
|
14
|
+
module Resources
|
|
15
|
+
class Responses
|
|
16
|
+
def create: (Hash[Symbol, untyped] params) -> OpenAI::Models::Responses::Response
|
|
17
|
+
| (**untyped) -> OpenAI::Models::Responses::Response
|
|
18
|
+
| ...
|
|
19
|
+
def stream: (Hash[Symbol, untyped] params) -> untyped
|
|
20
|
+
| (**untyped) -> untyped
|
|
21
|
+
| ...
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Chat
|
|
25
|
+
class Completions
|
|
26
|
+
def create: (Hash[Symbol, untyped] params) -> OpenAI::Models::Chat::ChatCompletion
|
|
27
|
+
| (**untyped) -> OpenAI::Models::Chat::ChatCompletion
|
|
28
|
+
| ...
|
|
29
|
+
def stream_raw: (Hash[Symbol, untyped] params) -> untyped
|
|
30
|
+
| (**untyped) -> untyped
|
|
31
|
+
| ...
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
module Anthropic
|
|
38
|
+
module Resources
|
|
39
|
+
class Messages
|
|
40
|
+
def create: (Hash[Symbol, untyped] params) -> Anthropic::Models::Message
|
|
41
|
+
| (**untyped) -> Anthropic::Models::Message
|
|
42
|
+
| ...
|
|
43
|
+
|
|
44
|
+
# Omitted from the gem's RBS; present at runtime (returns a MessageStream
|
|
45
|
+
# helper iterated with `#each` / `#accumulated_message` / `#close`).
|
|
46
|
+
def stream: (Hash[Symbol, untyped] params) -> untyped
|
|
47
|
+
| (**untyped) -> untyped
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Minimal signatures for the `zeitwerk` gem (autoloader), which ships no RBS.
|
|
2
|
+
#
|
|
3
|
+
# Only the surface used in lib/riffer.rb to set up the loader is declared.
|
|
4
|
+
module Zeitwerk
|
|
5
|
+
class Loader
|
|
6
|
+
def self.for_gem: (*untyped) -> Zeitwerk::Loader
|
|
7
|
+
|
|
8
|
+
def inflector: () -> untyped
|
|
9
|
+
|
|
10
|
+
def setup: () -> void
|
|
11
|
+
end
|
|
12
|
+
end
|