riffer 0.47.2 → 0.49.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 (267) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/rules/comments.md +2 -4
  3. data/.claude/rules/rbs-inline.md +2 -12
  4. data/.release-please-manifest.json +1 -1
  5. data/.rubocop.yml +5 -0
  6. data/CHANGELOG.md +42 -0
  7. data/docs/AGENTS.md +39 -7
  8. data/docs/AGENT_LIFECYCLE.md +14 -16
  9. data/docs/CONFIGURATION.md +23 -34
  10. data/docs/EVALS.md +2 -1
  11. data/docs/MCP.md +0 -4
  12. data/docs/MESSAGES.md +85 -17
  13. data/docs/STREAM_EVENTS.md +8 -4
  14. data/docs/TOOL_ADVANCED.md +1 -3
  15. data/docs/TRACING.md +2 -2
  16. data/docs/providers/AMAZON_BEDROCK.md +32 -1
  17. data/docs/providers/CUSTOM_PROVIDERS.md +56 -4
  18. data/docs/providers/GEMINI.md +1 -1
  19. data/docs/providers/MOCK_PROVIDER.md +17 -0
  20. data/docs/providers/OPENROUTER.md +18 -1
  21. data/docs-site/build.rb +0 -6
  22. data/docs-site/check.rb +1 -5
  23. data/lib/riffer/agent/config.rb +27 -44
  24. data/lib/riffer/agent/context.rb +2 -26
  25. data/lib/riffer/agent/outcome.rb +0 -20
  26. data/lib/riffer/agent/response.rb +4 -35
  27. data/lib/riffer/agent/run.rb +32 -48
  28. data/lib/riffer/agent/serializer.rb +10 -39
  29. data/lib/riffer/agent/session/repair.rb +3 -15
  30. data/lib/riffer/agent/session.rb +26 -38
  31. data/lib/riffer/agent/structured_output/result.rb +0 -8
  32. data/lib/riffer/agent/structured_output.rb +0 -7
  33. data/lib/riffer/agent.rb +31 -127
  34. data/lib/riffer/config/amazon_bedrock.rb +30 -0
  35. data/lib/riffer/config/anthropic.rb +21 -0
  36. data/lib/riffer/config/azure_open_ai.rb +30 -0
  37. data/lib/riffer/config/evals.rb +18 -0
  38. data/lib/riffer/config/files.rb +61 -0
  39. data/lib/riffer/config/gemini.rb +21 -0
  40. data/lib/riffer/config/mcp.rb +31 -0
  41. data/lib/riffer/config/open_ai.rb +30 -0
  42. data/lib/riffer/config/open_router.rb +21 -0
  43. data/lib/riffer/config/pricing/rates.rb +36 -0
  44. data/lib/riffer/config/pricing.rb +64 -0
  45. data/lib/riffer/config/skills.rb +38 -0
  46. data/lib/riffer/config/tracing.rb +43 -0
  47. data/lib/riffer/config.rb +3 -362
  48. data/lib/riffer/evals/evaluator.rb +22 -23
  49. data/lib/riffer/evals/evaluator_runner.rb +0 -15
  50. data/lib/riffer/evals/judge.rb +9 -11
  51. data/lib/riffer/evals/result.rb +1 -11
  52. data/lib/riffer/evals/run_result.rb +0 -12
  53. data/lib/riffer/evals/scenario_result.rb +0 -19
  54. data/lib/riffer/files/downloader.rb +2 -3
  55. data/lib/riffer/files/resolver.rb +5 -10
  56. data/lib/riffer/guardrail.rb +2 -22
  57. data/lib/riffer/guardrails/modification.rb +0 -8
  58. data/lib/riffer/guardrails/result.rb +0 -17
  59. data/lib/riffer/guardrails/runner.rb +2 -11
  60. data/lib/riffer/guardrails/tripwire.rb +0 -8
  61. data/lib/riffer/guardrails.rb +0 -2
  62. data/lib/riffer/helpers/boolean.rb +0 -4
  63. data/lib/riffer/helpers/call_or_value.rb +0 -3
  64. data/lib/riffer/helpers/deep_dup.rb +37 -0
  65. data/lib/riffer/helpers/dependencies.rb +0 -4
  66. data/lib/riffer/helpers/identifier.rb +3 -12
  67. data/lib/riffer/helpers/validate.rb +42 -0
  68. data/lib/riffer/mcp/authenticated_tool.rb +4 -12
  69. data/lib/riffer/mcp/client.rb +0 -7
  70. data/lib/riffer/mcp/manifest.rb +3 -7
  71. data/lib/riffer/mcp/registration.rb +0 -10
  72. data/lib/riffer/mcp/registry.rb +0 -9
  73. data/lib/riffer/mcp/search_tool.rb +0 -4
  74. data/lib/riffer/mcp/tool.rb +1 -4
  75. data/lib/riffer/mcp/tool_factory.rb +3 -6
  76. data/lib/riffer/mcp.rb +2 -23
  77. data/lib/riffer/messages/assistant/reasoning_part.rb +73 -0
  78. data/lib/riffer/messages/assistant/tool_call.rb +55 -0
  79. data/lib/riffer/messages/assistant.rb +43 -15
  80. data/lib/riffer/messages/base.rb +5 -33
  81. data/lib/riffer/messages/system.rb +8 -1
  82. data/lib/riffer/messages/tool.rb +15 -13
  83. data/lib/riffer/messages/{file_part.rb → user/file_part.rb} +16 -40
  84. data/lib/riffer/messages/user.rb +11 -4
  85. data/lib/riffer/params/boolean.rb +1 -5
  86. data/lib/riffer/params/param.rb +15 -31
  87. data/lib/riffer/params.rb +15 -39
  88. data/lib/riffer/providers/amazon_bedrock.rb +104 -44
  89. data/lib/riffer/providers/anthropic.rb +11 -26
  90. data/lib/riffer/providers/azure_open_ai.rb +3 -8
  91. data/lib/riffer/providers/base.rb +30 -32
  92. data/lib/riffer/providers/finish_reason.rb +0 -6
  93. data/lib/riffer/providers/gemini/client.rb +4 -17
  94. data/lib/riffer/providers/gemini.rb +6 -12
  95. data/lib/riffer/providers/mock.rb +18 -27
  96. data/lib/riffer/providers/open_ai.rb +12 -21
  97. data/lib/riffer/providers/open_router.rb +109 -33
  98. data/lib/riffer/providers/repository.rb +2 -14
  99. data/lib/riffer/providers/token_usage.rb +19 -12
  100. data/lib/riffer/registrable.rb +11 -45
  101. data/lib/riffer/runner/fibers.rb +1 -6
  102. data/lib/riffer/runner/sequential.rb +0 -1
  103. data/lib/riffer/runner/threaded.rb +0 -3
  104. data/lib/riffer/runner.rb +0 -3
  105. data/lib/riffer/skills/activate_tool.rb +0 -3
  106. data/lib/riffer/skills/adapter.rb +0 -8
  107. data/lib/riffer/skills/backend.rb +2 -7
  108. data/lib/riffer/skills/config.rb +13 -17
  109. data/lib/riffer/skills/context.rb +0 -29
  110. data/lib/riffer/skills/filesystem_backend.rb +0 -7
  111. data/lib/riffer/skills/frontmatter.rb +2 -16
  112. data/lib/riffer/skills/markdown_adapter.rb +3 -6
  113. data/lib/riffer/skills/xml_adapter.rb +0 -3
  114. data/lib/riffer/stream_events/base.rb +0 -3
  115. data/lib/riffer/stream_events/finish_reason_done.rb +1 -6
  116. data/lib/riffer/stream_events/guardrail_modification.rb +0 -10
  117. data/lib/riffer/stream_events/guardrail_tripwire.rb +0 -10
  118. data/lib/riffer/stream_events/interrupt.rb +2 -12
  119. data/lib/riffer/stream_events/reasoning_delta.rb +0 -3
  120. data/lib/riffer/stream_events/reasoning_done.rb +6 -8
  121. data/lib/riffer/stream_events/skill_activation.rb +0 -3
  122. data/lib/riffer/stream_events/text_delta.rb +0 -2
  123. data/lib/riffer/stream_events/text_done.rb +0 -2
  124. data/lib/riffer/stream_events/token_usage_done.rb +0 -2
  125. data/lib/riffer/stream_events/tool_call_delta.rb +1 -5
  126. data/lib/riffer/stream_events/tool_call_done.rb +0 -5
  127. data/lib/riffer/stream_events/web_search_done.rb +0 -3
  128. data/lib/riffer/stream_events/web_search_status.rb +1 -5
  129. data/lib/riffer/testing/minitest.rb +4 -5
  130. data/lib/riffer/testing.rb +5 -38
  131. data/lib/riffer/tool.rb +2 -28
  132. data/lib/riffer/tools/response.rb +3 -32
  133. data/lib/riffer/tools/runtime/fibers.rb +0 -6
  134. data/lib/riffer/tools/runtime/inline.rb +0 -1
  135. data/lib/riffer/tools/runtime/threaded.rb +0 -6
  136. data/lib/riffer/tools/runtime.rb +8 -30
  137. data/lib/riffer/tools/toolable.rb +0 -37
  138. data/lib/riffer/tracing/capture.rb +5 -9
  139. data/lib/riffer/tracing/no_op.rb +0 -7
  140. data/lib/riffer/tracing/otel.rb +7 -16
  141. data/lib/riffer/tracing/stream_recorder.rb +0 -7
  142. data/lib/riffer/tracing.rb +4 -27
  143. data/lib/riffer/version.rb +1 -1
  144. data/lib/riffer.rb +2 -30
  145. data/sig/generated/riffer/agent/config.rbs +24 -46
  146. data/sig/generated/riffer/agent/context.rbs +2 -26
  147. data/sig/generated/riffer/agent/outcome.rbs +0 -20
  148. data/sig/generated/riffer/agent/response.rbs +4 -27
  149. data/sig/generated/riffer/agent/run.rbs +12 -31
  150. data/sig/generated/riffer/agent/serializer.rbs +2 -27
  151. data/sig/generated/riffer/agent/session/repair.rbs +2 -10
  152. data/sig/generated/riffer/agent/session.rbs +10 -36
  153. data/sig/generated/riffer/agent/structured_output/result.rbs +0 -7
  154. data/sig/generated/riffer/agent/structured_output.rbs +0 -7
  155. data/sig/generated/riffer/agent.rbs +25 -125
  156. data/sig/generated/riffer/config/amazon_bedrock.rbs +21 -0
  157. data/sig/generated/riffer/config/anthropic.rbs +15 -0
  158. data/sig/generated/riffer/config/azure_open_ai.rbs +21 -0
  159. data/sig/generated/riffer/config/evals.rbs +13 -0
  160. data/sig/generated/riffer/config/files.rbs +43 -0
  161. data/sig/generated/riffer/config/gemini.rbs +15 -0
  162. data/sig/generated/riffer/config/mcp.rbs +19 -0
  163. data/sig/generated/riffer/config/open_ai.rbs +21 -0
  164. data/sig/generated/riffer/config/open_router.rbs +15 -0
  165. data/sig/generated/riffer/config/pricing/rates.rbs +19 -0
  166. data/sig/generated/riffer/config/pricing.rbs +31 -0
  167. data/sig/generated/riffer/config/skills.rbs +19 -0
  168. data/sig/generated/riffer/config/tracing.rbs +25 -0
  169. data/sig/generated/riffer/config.rbs +2 -307
  170. data/sig/generated/riffer/evals/evaluator.rbs +12 -21
  171. data/sig/generated/riffer/evals/evaluator_runner.rbs +0 -14
  172. data/sig/generated/riffer/evals/judge.rbs +4 -8
  173. data/sig/generated/riffer/evals/result.rbs +1 -11
  174. data/sig/generated/riffer/evals/run_result.rbs +0 -12
  175. data/sig/generated/riffer/evals/scenario_result.rbs +0 -14
  176. data/sig/generated/riffer/files/resolver.rbs +6 -13
  177. data/sig/generated/riffer/guardrail.rbs +2 -22
  178. data/sig/generated/riffer/guardrails/modification.rbs +0 -6
  179. data/sig/generated/riffer/guardrails/result.rbs +0 -15
  180. data/sig/generated/riffer/guardrails/runner.rbs +0 -11
  181. data/sig/generated/riffer/guardrails/tripwire.rbs +0 -8
  182. data/sig/generated/riffer/guardrails.rbs +0 -2
  183. data/sig/generated/riffer/helpers/boolean.rbs +0 -4
  184. data/sig/generated/riffer/helpers/call_or_value.rbs +0 -3
  185. data/sig/generated/riffer/helpers/deep_dup.rbs +13 -0
  186. data/sig/generated/riffer/helpers/dependencies.rbs +0 -4
  187. data/sig/generated/riffer/helpers/identifier.rbs +0 -12
  188. data/sig/generated/riffer/helpers/validate.rbs +21 -0
  189. data/sig/generated/riffer/mcp/authenticated_tool.rbs +0 -5
  190. data/sig/generated/riffer/mcp/client.rbs +0 -7
  191. data/sig/generated/riffer/mcp/manifest.rbs +3 -7
  192. data/sig/generated/riffer/mcp/registration.rbs +0 -10
  193. data/sig/generated/riffer/mcp/registry.rbs +0 -9
  194. data/sig/generated/riffer/mcp/search_tool.rbs +0 -4
  195. data/sig/generated/riffer/mcp/tool.rbs +0 -4
  196. data/sig/generated/riffer/mcp/tool_factory.rbs +0 -6
  197. data/sig/generated/riffer/mcp.rbs +2 -22
  198. data/sig/generated/riffer/messages/assistant/reasoning_part.rbs +45 -0
  199. data/sig/generated/riffer/messages/assistant/tool_call.rbs +34 -0
  200. data/sig/generated/riffer/messages/assistant.rbs +25 -31
  201. data/sig/generated/riffer/messages/base.rbs +0 -12
  202. data/sig/generated/riffer/messages/system.rbs +4 -1
  203. data/sig/generated/riffer/messages/tool.rbs +4 -10
  204. data/sig/generated/riffer/messages/user/file_part.rbs +76 -0
  205. data/sig/generated/riffer/messages/user.rbs +7 -5
  206. data/sig/generated/riffer/params/boolean.rbs +1 -4
  207. data/sig/generated/riffer/params/param.rbs +7 -31
  208. data/sig/generated/riffer/params.rbs +8 -38
  209. data/sig/generated/riffer/providers/amazon_bedrock.rbs +33 -29
  210. data/sig/generated/riffer/providers/anthropic.rbs +2 -12
  211. data/sig/generated/riffer/providers/azure_open_ai.rbs +0 -8
  212. data/sig/generated/riffer/providers/base.rbs +18 -34
  213. data/sig/generated/riffer/providers/finish_reason.rbs +0 -6
  214. data/sig/generated/riffer/providers/gemini/client.rbs +4 -17
  215. data/sig/generated/riffer/providers/gemini.rbs +4 -10
  216. data/sig/generated/riffer/providers/mock.rbs +6 -27
  217. data/sig/generated/riffer/providers/open_ai.rbs +6 -13
  218. data/sig/generated/riffer/providers/open_router.rbs +37 -18
  219. data/sig/generated/riffer/providers/repository.rbs +2 -14
  220. data/sig/generated/riffer/providers/token_usage.rbs +9 -12
  221. data/sig/generated/riffer/registrable.rbs +0 -45
  222. data/sig/generated/riffer/runner/fibers.rbs +0 -6
  223. data/sig/generated/riffer/runner/sequential.rbs +0 -1
  224. data/sig/generated/riffer/runner/threaded.rbs +0 -3
  225. data/sig/generated/riffer/runner.rbs +0 -3
  226. data/sig/generated/riffer/skills/activate_tool.rbs +0 -3
  227. data/sig/generated/riffer/skills/adapter.rbs +0 -8
  228. data/sig/generated/riffer/skills/backend.rbs +2 -7
  229. data/sig/generated/riffer/skills/config.rbs +6 -17
  230. data/sig/generated/riffer/skills/context.rbs +0 -29
  231. data/sig/generated/riffer/skills/filesystem_backend.rbs +0 -7
  232. data/sig/generated/riffer/skills/frontmatter.rbs +2 -16
  233. data/sig/generated/riffer/skills/markdown_adapter.rbs +0 -6
  234. data/sig/generated/riffer/skills/xml_adapter.rbs +0 -3
  235. data/sig/generated/riffer/stream_events/base.rbs +0 -3
  236. data/sig/generated/riffer/stream_events/finish_reason_done.rbs +1 -6
  237. data/sig/generated/riffer/stream_events/guardrail_modification.rbs +0 -10
  238. data/sig/generated/riffer/stream_events/guardrail_tripwire.rbs +0 -10
  239. data/sig/generated/riffer/stream_events/interrupt.rbs +2 -10
  240. data/sig/generated/riffer/stream_events/reasoning_delta.rbs +0 -3
  241. data/sig/generated/riffer/stream_events/reasoning_done.rbs +4 -6
  242. data/sig/generated/riffer/stream_events/skill_activation.rbs +0 -3
  243. data/sig/generated/riffer/stream_events/text_delta.rbs +0 -2
  244. data/sig/generated/riffer/stream_events/text_done.rbs +0 -2
  245. data/sig/generated/riffer/stream_events/token_usage_done.rbs +0 -2
  246. data/sig/generated/riffer/stream_events/tool_call_delta.rbs +1 -5
  247. data/sig/generated/riffer/stream_events/tool_call_done.rbs +0 -5
  248. data/sig/generated/riffer/stream_events/web_search_done.rbs +0 -3
  249. data/sig/generated/riffer/stream_events/web_search_status.rbs +1 -5
  250. data/sig/generated/riffer/testing.rbs +0 -38
  251. data/sig/generated/riffer/tool.rbs +0 -27
  252. data/sig/generated/riffer/tools/response.rbs +3 -29
  253. data/sig/generated/riffer/tools/runtime/fibers.rbs +0 -5
  254. data/sig/generated/riffer/tools/runtime/inline.rbs +0 -1
  255. data/sig/generated/riffer/tools/runtime/threaded.rbs +0 -5
  256. data/sig/generated/riffer/tools/runtime.rbs +4 -26
  257. data/sig/generated/riffer/tools/toolable.rbs +0 -37
  258. data/sig/generated/riffer/tracing/capture.rbs +6 -9
  259. data/sig/generated/riffer/tracing/no_op.rbs +0 -7
  260. data/sig/generated/riffer/tracing/otel.rbs +7 -16
  261. data/sig/generated/riffer/tracing/stream_recorder.rbs +0 -2
  262. data/sig/generated/riffer/tracing.rbs +4 -23
  263. data/sig/generated/riffer.rbs +2 -29
  264. data/sig/manual/riffer/helpers/deep_dup.rbs +5 -0
  265. data/sig/manual/riffer/helpers/validate.rbs +5 -0
  266. metadata +39 -3
  267. data/sig/generated/riffer/messages/file_part.rbs +0 -101
@@ -1,110 +1,88 @@
1
1
  # Generated from lib/riffer/agent/config.rb with RBS::Inline
2
2
 
3
- # Typed configuration object holding every class-level DSL setting on a
4
- # Riffer::Agent subclass. Procs are stored unresolved and resolved per-instance
5
- # later.
6
3
  class Riffer::Agent::Config
7
4
  DEFAULT_MAX_STEPS: Integer
8
5
 
9
- # The configured agent identifier.
6
+ @tool_runtime: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)?
7
+
10
8
  attr_reader identifier: String?
11
9
 
12
- # The configured model.
13
10
  attr_reader model: (String | Proc)?
14
11
 
15
- # The configured instructions.
16
12
  attr_reader instructions: (String | Proc)?
17
13
 
18
- # Options passed to generate_text/stream_text.
19
14
  attr_accessor model_options: Hash[Symbol, untyped]
20
15
 
21
- # The configured structured-output schema.
22
16
  attr_reader structured_output: Riffer::Params?
23
17
 
24
- # The maximum number of LLM call steps in the tool-use loop.
25
18
  attr_accessor max_steps: Numeric?
26
19
 
27
- # The configured tools.
28
20
  attr_accessor tools_config: (Array[singleton(Riffer::Tool)] | Proc)?
29
21
 
30
- # The accumulated +use_mcp+ tag configurations.
31
22
  attr_reader mcp_configs: Array[Hash[Symbol, untyped]]
32
23
 
33
- # The configured tool runtime.
34
- attr_reader tool_runtime: singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc
35
-
36
- # The configured skills.
37
24
  attr_accessor skills_config: Riffer::Skills::Config?
38
25
 
39
- # Registered guardrail entries keyed by phase.
40
26
  attr_reader guardrails: Hash[Symbol, Array[Hash[Symbol, untyped]]]
41
27
 
42
- # Builds a new Config. Raises Riffer::ArgumentError if +model+ or
43
- # +instructions+ is invalid (e.g. an empty string).
44
28
  # --
45
29
  # : (
46
- # ?identifier: String?,
47
- # ?model: (String | Proc)?,
48
- # ?instructions: (String | Proc)?,
49
- # ?model_options: Hash[Symbol, untyped],
50
- # ?structured_output: Riffer::Params?,
51
- # ?max_steps: Numeric?,
52
- # ?tools_config: (Array[singleton(Riffer::Tool)] | Proc)?,
53
- # ?mcp_configs: Array[Hash[Symbol, untyped]],
54
- # ?tool_runtime: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc),
55
- # ?skills_config: Riffer::Skills::Config?,
56
- # ?guardrails: Hash[Symbol, Array[Hash[Symbol, untyped]]]
57
- # ) -> void
58
- def initialize: (?identifier: String?, ?model: (String | Proc)?, ?instructions: (String | Proc)?, ?model_options: Hash[Symbol, untyped], ?structured_output: Riffer::Params?, ?max_steps: Numeric?, ?tools_config: (Array[singleton(Riffer::Tool)] | Proc)?, ?mcp_configs: Array[Hash[Symbol, untyped]], ?tool_runtime: singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc, ?skills_config: Riffer::Skills::Config?, ?guardrails: Hash[Symbol, Array[Hash[Symbol, untyped]]]) -> void
59
-
60
- # Sets +identifier+, coercing the value to String.
30
+ # ?identifier: String?,
31
+ # ?model: (String | Proc)?,
32
+ # ?instructions: (String | Proc)?,
33
+ # ?model_options: Hash[Symbol, untyped],
34
+ # ?structured_output: Riffer::Params?,
35
+ # ?max_steps: Numeric?,
36
+ # ?tools_config: (Array[singleton(Riffer::Tool)] | Proc)?,
37
+ # ?mcp_configs: Array[Hash[Symbol, untyped]],
38
+ # ?tool_runtime: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)?,
39
+ # ?skills_config: Riffer::Skills::Config?,
40
+ # ?guardrails: Hash[Symbol, Array[Hash[Symbol, untyped]]]
41
+ # ) -> void
42
+ def initialize: (?identifier: String?, ?model: (String | Proc)?, ?instructions: (String | Proc)?, ?model_options: Hash[Symbol, untyped], ?structured_output: Riffer::Params?, ?max_steps: Numeric?, ?tools_config: (Array[singleton(Riffer::Tool)] | Proc)?, ?mcp_configs: Array[Hash[Symbol, untyped]], ?tool_runtime: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)?, ?skills_config: Riffer::Skills::Config?, ?guardrails: Hash[Symbol, Array[Hash[Symbol, untyped]]]) -> void
43
+
61
44
  # --
62
45
  # : (untyped) -> String?
63
46
  def identifier=: (untyped) -> String?
64
47
 
65
- # Sets +structured_output+. Raises Riffer::ArgumentError on an invalid value.
66
48
  # --
67
49
  # : (Riffer::Params?) -> Riffer::Params?
68
50
  def structured_output=: (Riffer::Params?) -> Riffer::Params?
69
51
 
70
- # Sets +tool_runtime+. Raises Riffer::ArgumentError on an invalid value.
52
+ # --
53
+ # : () -> (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)
54
+ def tool_runtime: () -> (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)
55
+
71
56
  # --
72
57
  # : ((singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)) -> (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)
73
58
  def tool_runtime=: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc) -> (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)
74
59
 
75
- # Sets +model+. Raises Riffer::ArgumentError on an invalid value (e.g. an
76
- # empty string).
77
60
  # --
78
61
  # : ((String | Proc)?) -> (String | Proc)?
79
62
  def model=: ((String | Proc)?) -> (String | Proc)?
80
63
 
81
- # Sets +instructions+. Raises Riffer::ArgumentError on an invalid value (e.g.
82
- # an empty string).
83
64
  # --
84
65
  # : ((String | Proc)?) -> (String | Proc)?
85
66
  def instructions=: ((String | Proc)?) -> (String | Proc)?
86
67
 
87
- # Appends an MCP tag entry to +mcp_configs+.
88
- #
89
68
  # --
90
69
  # : (String | Symbol, ?progressive: bool) -> Array[Hash[Symbol, untyped]]
91
70
  def add_mcp: (String | Symbol, ?progressive: bool) -> Array[Hash[Symbol, untyped]]
92
71
 
93
- # Appends a guardrail entry to +guardrails+ for the given phase; +:around+
94
- # appends to both +:before+ and +:after+. Raises Riffer::ArgumentError unless
95
- # +phase+ is :before, :after, or :around.
96
72
  # --
97
73
  # : (Symbol, klass: singleton(Riffer::Guardrail), ?options: Hash[Symbol, untyped]) -> void
98
74
  def add_guardrail: (Symbol, klass: singleton(Riffer::Guardrail), ?options: Hash[Symbol, untyped]) -> void
99
75
 
100
- # Returns the guardrail entries for the given phase, or +[]+ if none.
101
- #
102
76
  # --
103
77
  # : (Symbol) -> Array[Hash[Symbol, untyped]]
104
78
  def guardrails_for: (Symbol) -> Array[Hash[Symbol, untyped]]
105
79
 
106
80
  private
107
81
 
82
+ # --
83
+ # : (Riffer::Agent::Config) -> void
84
+ def initialize_copy: (Riffer::Agent::Config) -> void
85
+
108
86
  # --
109
87
  # : (untyped, String) -> void
110
88
  def validate_string_or_proc!: (untyped, String) -> void
@@ -1,74 +1,52 @@
1
1
  # Generated from lib/riffer/agent/context.rb with RBS::Inline
2
2
 
3
- # Typed value object wrapping the runtime context Hash held by a Riffer::Agent.
4
- # Exposes typed +skills+, +token_usage+, +mcp_progressive_tools+, and
5
- # +discovered_tools+ accessors while preserving +#[]+ / +#dig+ for caller-provided keys.
6
3
  class Riffer::Agent::Context
7
4
  @data: Hash[Symbol, untyped]
8
5
 
9
6
  RESERVED_KEYS: Array[Symbol]
10
7
 
11
- # Builds a new context. The caller Hash is duped so later caller mutations
12
- # don't leak in. Raises Riffer::ArgumentError if it contains a reserved key.
8
+ # Raises Riffer::ArgumentError if +data+ contains a reserved key.
13
9
  # --
14
10
  # : (?Hash[Symbol, untyped]) -> void
15
11
  def initialize: (?Hash[Symbol, untyped]) -> void
16
12
 
17
- # The agent's resolved +Riffer::Skills::Context+, or +nil+ when skills
18
- # are not configured.
19
- #
20
13
  # --
21
14
  # : () -> Riffer::Skills::Context?
22
15
  def skills: () -> Riffer::Skills::Context?
23
16
 
24
- # Sets the resolved skills context. Raises Riffer::ArgumentError on an
25
- # invalid value.
26
17
  # --
27
18
  # : (Riffer::Skills::Context?) -> Riffer::Skills::Context?
28
19
  def skills=: (Riffer::Skills::Context?) -> Riffer::Skills::Context?
29
20
 
30
- # The cumulative +Riffer::Providers::TokenUsage+ across every Run on this agent,
31
- # or +nil+ before the first response is recorded.
32
- #
21
+ # Cumulative across every run on this agent.
33
22
  # --
34
23
  # : () -> Riffer::Providers::TokenUsage?
35
24
  def token_usage: () -> Riffer::Providers::TokenUsage?
36
25
 
37
- # Sets the cumulative token usage. Raises Riffer::ArgumentError on an invalid
38
- # value.
39
26
  # --
40
27
  # : (Riffer::Providers::TokenUsage?) -> Riffer::Providers::TokenUsage?
41
28
  def token_usage=: (Riffer::Providers::TokenUsage?) -> Riffer::Providers::TokenUsage?
42
29
 
43
- # Hash-style read, preserved so tools can pull caller-provided keys via
44
- # <tt>context[:agent]</tt>.
45
30
  # --
46
31
  # : (Symbol) -> untyped
47
32
  def []: (Symbol) -> untyped
48
33
 
49
- # Auth-wrapped MCP tool classes for progressive discovery, or +nil+.
50
34
  # --
51
35
  # : () -> Array[singleton(Riffer::Tool)]?
52
36
  def mcp_progressive_tools: () -> Array[singleton(Riffer::Tool)]?
53
37
 
54
- # Sets progressive MCP tools. Raises Riffer::ArgumentError on an invalid value.
55
38
  # --
56
39
  # : (Array[singleton(Riffer::Tool)]?) -> Array[singleton(Riffer::Tool)]?
57
40
  def mcp_progressive_tools=: (Array[singleton(Riffer::Tool)]?) -> Array[singleton(Riffer::Tool)]?
58
41
 
59
- # MCP tool classes discovered during progressive search. Accumulates across
60
- # +generate+ calls and is merged into the active tool list on every LLM call.
61
42
  # --
62
43
  # : () -> Array[singleton(Riffer::Tool)]?
63
44
  def discovered_tools: () -> Array[singleton(Riffer::Tool)]?
64
45
 
65
- # Sets the discovered tools array. Raises Riffer::ArgumentError on an invalid value.
66
46
  # --
67
47
  # : (Array[singleton(Riffer::Tool)]?) -> Array[singleton(Riffer::Tool)]?
68
48
  def discovered_tools=: (Array[singleton(Riffer::Tool)]?) -> Array[singleton(Riffer::Tool)]?
69
49
 
70
- # Accumulates newly discovered MCP tool classes, deduplicating by name.
71
- # Each call extends the existing set; calling multiple times is safe.
72
50
  # --
73
51
  # : (Array[singleton(Riffer::Tool)]) -> Array[singleton(Riffer::Tool)]
74
52
  def discover_tools: (Array[singleton(Riffer::Tool)]) -> Array[singleton(Riffer::Tool)]
@@ -77,8 +55,6 @@ class Riffer::Agent::Context
77
55
  # : (*Symbol) -> untyped
78
56
  def dig: (*Symbol) -> untyped
79
57
 
80
- # Returns a copy of the underlying Hash; mutating it does not affect this
81
- # context.
82
58
  # --
83
59
  # : () -> Hash[Symbol, untyped]
84
60
  def to_h: () -> Hash[Symbol, untyped]
@@ -1,40 +1,20 @@
1
1
  # Generated from lib/riffer/agent/outcome.rb with RBS::Inline
2
2
 
3
- # How a run ended — the single place to read whether the agent completed
4
- # normally and, if not, why. +detail+ carries the specifics when there are any:
5
- # the tripwire reason, the interrupt reason, the provider's raw finish value,
6
- # or the structured output parse/validation error.
7
- #
8
- # response = agent.generate("Analyze this")
9
- # case response.outcome.reason
10
- # when :completed then puts response.structured_output
11
- # when :invalid_structured_output then warn response.outcome.detail
12
- # end
13
3
  class Riffer::Agent::Outcome
14
- # Finish reasons that end a turn normally; every other finish reason means the
15
- # provider cut the turn short and surfaces as the run's outcome verbatim.
16
4
  NORMAL_FINISH_REASONS: Array[Symbol]
17
5
 
18
- # Derived from the provider vocabulary so a new finish reason becomes an
19
- # outcome without a second list to update.
20
6
  PROVIDER_STOP_REASONS: Array[Symbol]
21
7
 
22
- # The vocabulary every run ends in.
23
8
  VALUES: Array[Symbol]
24
9
 
25
- # Why the run ended.
26
10
  attr_reader reason: Symbol
27
11
 
28
- # Human-readable specifics for +reason+, when there are any.
29
12
  attr_reader detail: String?
30
13
 
31
- # Raises Riffer::ArgumentError when +reason+ is outside VALUES.
32
14
  # --
33
15
  # : (reason: Symbol, ?detail: String?) -> void
34
16
  def initialize: (reason: Symbol, ?detail: String?) -> void
35
17
 
36
- # Returns true when the run completed normally.
37
- #
38
18
  # --
39
19
  # : () -> bool
40
20
  def success?: () -> bool
@@ -1,61 +1,38 @@
1
1
  # Generated from lib/riffer/agent/response.rb with RBS::Inline
2
2
 
3
- # Wraps an agent generation response. +outcome+ says how the run ended; when a
4
- # guardrail blocks execution, +content+ is empty and +tripwire+ carries the
5
- # block details.
6
- #
7
- # response = agent.generate("Hello")
8
- # if response.outcome.success?
9
- # puts response.content
10
- # else
11
- # puts "#{response.outcome.reason}: #{response.outcome.detail}"
12
- # end
13
3
  class Riffer::Agent::Response
14
- # The response content.
15
4
  attr_reader content: String
16
5
 
17
- # How the run ended.
18
6
  attr_reader outcome: Riffer::Agent::Outcome
19
7
 
20
- # The tripwire if execution was blocked.
21
8
  attr_reader tripwire: Riffer::Guardrails::Tripwire?
22
9
 
23
- # The modifications made by guardrails during processing.
24
10
  attr_reader modifications: Array[Riffer::Guardrails::Modification]
25
11
 
26
- # The parsed structured output, if structured output was configured.
12
+ attr_reader reasoning: Array[Riffer::Messages::Assistant::ReasoningPart]
13
+
27
14
  attr_reader structured_output: Hash[Symbol, untyped]?
28
15
 
29
- # The aggregate token usage across this run's LLM calls, if any was reported.
30
16
  attr_reader token_usage: Riffer::Providers::TokenUsage?
31
17
 
32
- # The number of LLM calls made during this run (0 when a before-guardrail
33
- # blocks before any call). Distinct from the session's cumulative step count.
34
18
  attr_reader steps: Integer
35
19
 
36
- # The full message history from the agent conversation.
37
20
  attr_reader messages: Array[Riffer::Messages::Base]
38
21
 
39
- # Call ids of tool_use blocks riffer filled with placeholder results this
40
- # turn (when an interrupt left them unanswered and history healing is on).
41
- attr_reader healed_tool_call_ids: Array[String]
42
-
43
22
  # --
44
23
  # : (
45
24
  # String,
46
25
  # outcome: Riffer::Agent::Outcome,
47
26
  # ?tripwire: Riffer::Guardrails::Tripwire?,
48
27
  # ?modifications: Array[Riffer::Guardrails::Modification],
28
+ # ?reasoning: Array[Riffer::Messages::Assistant::ReasoningPart],
49
29
  # ?structured_output: Hash[Symbol, untyped]?,
50
30
  # ?messages: Array[Riffer::Messages::Base],
51
- # ?healed_tool_call_ids: Array[String],
52
31
  # ?token_usage: Riffer::Providers::TokenUsage?,
53
32
  # ?steps: Integer
54
33
  # ) -> void
55
- def initialize: (String, outcome: Riffer::Agent::Outcome, ?tripwire: Riffer::Guardrails::Tripwire?, ?modifications: Array[Riffer::Guardrails::Modification], ?structured_output: Hash[Symbol, untyped]?, ?messages: Array[Riffer::Messages::Base], ?healed_tool_call_ids: Array[String], ?token_usage: Riffer::Providers::TokenUsage?, ?steps: Integer) -> void
34
+ def initialize: (String, outcome: Riffer::Agent::Outcome, ?tripwire: Riffer::Guardrails::Tripwire?, ?modifications: Array[Riffer::Guardrails::Modification], ?reasoning: Array[Riffer::Messages::Assistant::ReasoningPart], ?structured_output: Hash[Symbol, untyped]?, ?messages: Array[Riffer::Messages::Base], ?token_usage: Riffer::Providers::TokenUsage?, ?steps: Integer) -> void
56
35
 
57
- # Returns true if any guardrail modified data during processing.
58
- #
59
36
  # --
60
37
  # : () -> bool
61
38
  def modified?: () -> bool
@@ -1,29 +1,16 @@
1
1
  # Generated from lib/riffer/agent/run.rb with RBS::Inline
2
2
 
3
- # The generation loop — a pure module of functions over an +agent+, which owns
4
- # every per-call value; Run just orchestrates.
5
3
  module Riffer::Agent::Run
6
- # Runs the generate loop for the given agent. See Riffer::Agent#generate
7
- # for prompt/files semantics.
8
- #
9
4
  # --
10
- # : (agent: Riffer::Agent, ?prompt: String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::FilePart]?, ?tags: Hash[(String | Symbol), untyped]) -> Riffer::Agent::Response
11
- def generate: (agent: Riffer::Agent, ?prompt: String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::FilePart]?, ?tags: Hash[String | Symbol, untyped]) -> Riffer::Agent::Response
5
+ # : (agent: Riffer::Agent, ?prompt: String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::User::FilePart]?, ?tags: Hash[(String | Symbol), untyped]) -> Riffer::Agent::Response
6
+ def generate: (agent: Riffer::Agent, ?prompt: String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::User::FilePart]?, ?tags: Hash[String | Symbol, untyped]) -> Riffer::Agent::Response
12
7
 
13
- # Runs the streaming loop for the given agent. See Riffer::Agent#stream
14
- # for prompt/files semantics.
15
- #
16
8
  # --
17
- # : (agent: Riffer::Agent, ?prompt: String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::FilePart]?, ?tags: Hash[(String | Symbol), untyped]) -> Enumerator[Riffer::StreamEvents::Base, Riffer::Agent::Response]
18
- def stream: (agent: Riffer::Agent, ?prompt: String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::FilePart]?, ?tags: Hash[String | Symbol, untyped]) -> Enumerator[Riffer::StreamEvents::Base, Riffer::Agent::Response]
9
+ # : (agent: Riffer::Agent, ?prompt: String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::User::FilePart]?, ?tags: Hash[(String | Symbol), untyped]) -> Enumerator[Riffer::StreamEvents::Base, Riffer::Agent::Response]
10
+ def stream: (agent: Riffer::Agent, ?prompt: String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::User::FilePart]?, ?tags: Hash[String | Symbol, untyped]) -> Enumerator[Riffer::StreamEvents::Base, Riffer::Agent::Response]
19
11
 
20
12
  private
21
13
 
22
- # Both +generate+ and +stream+ funnel here, so this is the single place raw
23
- # +tags+ are normalized. The clean <tt>String => String</tt> map is then
24
- # threaded to every span builder in the run as +riffer.tag.*+ and to each
25
- # provider call (via +merged_model_options+) for native request-metadata
26
- # mapping.
27
14
  # --
28
15
  # : (Riffer::Agent, ?tags: Hash[(String | Symbol), untyped]?, ?stream_yielder: Enumerator::Yielder?) -> Riffer::Agent::Response
29
16
  def run_loop: (Riffer::Agent, ?tags: Hash[String | Symbol, untyped]?, ?stream_yielder: Enumerator::Yielder?) -> Riffer::Agent::Response
@@ -48,10 +35,6 @@ module Riffer::Agent::Run
48
35
  # : (Riffer::Agent, Array[Riffer::Guardrails::Modification], ?interrupted: bool, ?interrupt_reason: (String | Symbol)?, **untyped) -> Riffer::Agent::Response
49
36
  def final_response: (Riffer::Agent, Array[Riffer::Guardrails::Modification], ?interrupted: bool, ?interrupt_reason: (String | Symbol)?, **untyped) -> Riffer::Agent::Response
50
37
 
51
- # Checked in the order things happened. The loop being stopped (max_steps or
52
- # an interrupt) beats the provider's finish reason, which beats riffer's own
53
- # validation of the content. A truncated response that also fails the schema
54
- # therefore reports :length, not :invalid_structured_output.
55
38
  # --
56
39
  # : (Riffer::Messages::Assistant?, Riffer::Agent::StructuredOutput::Result?, interrupted: bool, interrupt_reason: (String | Symbol)?) -> Riffer::Agent::Outcome
57
40
  def final_outcome: (Riffer::Messages::Assistant?, Riffer::Agent::StructuredOutput::Result?, interrupted: bool, interrupt_reason: (String | Symbol)?) -> Riffer::Agent::Outcome
@@ -92,14 +75,14 @@ module Riffer::Agent::Run
92
75
  # : (Riffer::Agent) -> Array[singleton(Riffer::Tool)]
93
76
  def effective_tools: (Riffer::Agent) -> Array[singleton(Riffer::Tool)]
94
77
 
95
- # +tags+ rides in the options hash as a curated key the providers extract for
96
- # native request-metadata mapping (alongside +:structured_output+); it never
97
- # reaches an SDK call verbatim. Span tagging is threaded separately to each
98
- # builder.
99
78
  # --
100
79
  # : (Riffer::Agent, ?Hash[String, String]) -> Hash[Symbol, untyped]
101
80
  def merged_model_options: (Riffer::Agent, ?Hash[String, String]) -> Hash[Symbol, untyped]
102
81
 
82
+ # --
83
+ # : (Riffer::Agent) -> Hash[String, String]
84
+ def default_tags: (Riffer::Agent) -> Hash[String, String]
85
+
103
86
  # --
104
87
  # : (
105
88
  # Riffer::Agent,
@@ -107,18 +90,16 @@ module Riffer::Agent::Run
107
90
  # outcome: Riffer::Agent::Outcome,
108
91
  # ?tripwire: Riffer::Guardrails::Tripwire?,
109
92
  # ?modifications: Array[Riffer::Guardrails::Modification],
93
+ # ?reasoning: Array[Riffer::Messages::Assistant::ReasoningPart],
110
94
  # ?structured_output: Hash[Symbol, untyped]?,
111
- # ?healed_tool_call_ids: Array[String],
112
95
  # ?token_usage: Riffer::Providers::TokenUsage?,
113
96
  # ?steps: Integer
114
97
  # ) -> Riffer::Agent::Response
115
- def build_response: (Riffer::Agent, String, outcome: Riffer::Agent::Outcome, ?tripwire: Riffer::Guardrails::Tripwire?, ?modifications: Array[Riffer::Guardrails::Modification], ?structured_output: Hash[Symbol, untyped]?, ?healed_tool_call_ids: Array[String], ?token_usage: Riffer::Providers::TokenUsage?, ?steps: Integer) -> Riffer::Agent::Response
98
+ def build_response: (Riffer::Agent, String, outcome: Riffer::Agent::Outcome, ?tripwire: Riffer::Guardrails::Tripwire?, ?modifications: Array[Riffer::Guardrails::Modification], ?reasoning: Array[Riffer::Messages::Assistant::ReasoningPart], ?structured_output: Hash[Symbol, untyped]?, ?token_usage: Riffer::Providers::TokenUsage?, ?steps: Integer) -> Riffer::Agent::Response
116
99
 
117
- # Raises when +files+ are supplied without a +prompt+ — the provider needs
118
- # text to anchor the attachments.
119
100
  # --
120
- # : (Riffer::Agent, String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::FilePart]?) -> void
121
- def append_user_message: (Riffer::Agent, String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::FilePart]?) -> void
101
+ # : (Riffer::Agent, String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::User::FilePart]?) -> void
102
+ def append_user_message: (Riffer::Agent, String?, ?files: Array[Hash[Symbol, untyped] | Riffer::Messages::User::FilePart]?) -> void
122
103
 
123
104
  # --
124
105
  # : (Riffer::Agent, Riffer::Providers::TokenUsage?) -> void
@@ -1,48 +1,27 @@
1
1
  # Generated from lib/riffer/agent/serializer.rb with RBS::Inline
2
2
 
3
- # Turns a resolved agent into a self-contained, provider-neutral data hash and
4
- # back into a runnable agent, behind the +Riffer::Agent#to_h+ /
5
- # +Riffer::Agent.from_h+ delegators.
6
- #
7
- # hash = Riffer::Agent::Serializer.to_h(agent: agent)
8
- # rebuilt = Riffer::Agent::Serializer.from_h(hash, context: {tenant: "acme"})
9
3
  module Riffer::Agent::Serializer
10
- # The wire format version, bumped only on an incompatible change to the hash
11
- # shape; +from_h+ refuses any other version.
4
+ # Bump only on an incompatible change to the hash shape.
12
5
  SCHEMA_VERSION: Integer
13
6
 
14
- # Raised by +from_h+ when the hash's +schema_version+ is unsupported.
15
7
  class VersionError < Riffer::ArgumentError
16
8
  end
17
9
 
18
- # The default +tool_resolver+: synthesizes a body-less tool shell from a
19
- # descriptor. Its +#call+ raises — route shells through a remote runtime.
20
10
  DEFAULT_TOOL_RESOLVER: ^(Hash[Symbol, untyped]) -> singleton(Riffer::Tool)
21
11
 
22
- # Snapshots a resolved agent into a self-contained wire hash. Proc-based
23
- # settings are already evaluated against the agent's context, so the hash
24
- # carries plain data, never Procs.
25
12
  # --
26
13
  # : (agent: Riffer::Agent) -> Hash[Symbol, untyped]
27
14
  def to_h: (agent: Riffer::Agent) -> Hash[Symbol, untyped]
28
15
 
29
- # Reconstructs a runnable agent from a wire hash. +context+ is threaded into
30
- # tool dispatch (not used to re-resolve the already-resolved config);
31
- # +session+ seeds conversation history (the hash carries the agent definition,
32
- # not its history). Raises Riffer::Agent::Serializer::VersionError on an
33
- # unsupported +schema_version+.
34
- #
16
+ # Raises Riffer::Agent::Serializer::VersionError on an unsupported +schema_version+.
35
17
  # --
36
18
  # : (Hash[Symbol, untyped], ?context: Hash[Symbol, untyped]?, ?session: Riffer::Agent::Session?, ?tool_resolver: ^(Hash[Symbol, untyped]) -> singleton(Riffer::Tool), ?tool_runtime: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)?) -> Riffer::Agent
37
19
  def from_h: (Hash[Symbol, untyped], ?context: Hash[Symbol, untyped]?, ?session: Riffer::Agent::Session?, ?tool_resolver: ^(Hash[Symbol, untyped]) -> singleton(Riffer::Tool), ?tool_runtime: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)?) -> Riffer::Agent
38
20
 
39
- # Snapshots a resolved agent to a JSON string.
40
21
  # --
41
22
  # : (agent: Riffer::Agent) -> String
42
23
  def to_json: (agent: Riffer::Agent) -> String
43
24
 
44
- # Reconstructs a runnable agent from a JSON string produced by +to_json+. See
45
- # +from_h+ for the arguments.
46
25
  # --
47
26
  # : (String, ?context: Hash[Symbol, untyped]?, ?session: Riffer::Agent::Session?, ?tool_resolver: ^(Hash[Symbol, untyped]) -> singleton(Riffer::Tool), ?tool_runtime: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)?) -> Riffer::Agent
48
27
  def from_json: (String, ?context: Hash[Symbol, untyped]?, ?session: Riffer::Agent::Session?, ?tool_resolver: ^(Hash[Symbol, untyped]) -> singleton(Riffer::Tool), ?tool_runtime: (singleton(Riffer::Tools::Runtime) | Riffer::Tools::Runtime | Proc)?) -> Riffer::Agent
@@ -57,14 +36,10 @@ module Riffer::Agent::Serializer
57
36
  # : (Hash[Symbol, untyped]?) -> Riffer::Params?
58
37
  def decode_structured_output: (Hash[Symbol, untyped]?) -> Riffer::Params?
59
38
 
60
- # Encodes unlimited steps (+nil+ in the DSL) as +-1+ on the wire, where a
61
- # JSON +null+ is awkward across transports (e.g. proto3).
62
39
  # --
63
40
  # : (Numeric?) -> Numeric
64
41
  def encode_max_steps: (Numeric?) -> Numeric
65
42
 
66
- # Reverses +encode_max_steps+; a missing key falls back to the default so a
67
- # partial hash can't become an unbounded loop.
68
43
  # --
69
44
  # : (Hash[Symbol, untyped]) -> Numeric?
70
45
  def decode_max_steps: (Hash[Symbol, untyped]) -> Numeric?
@@ -1,22 +1,14 @@
1
1
  # Generated from lib/riffer/agent/session/repair.rb with RBS::Inline
2
2
 
3
- # Pure, stateless transformations keeping the +tool_use+ ↔ +tool_result+
4
- # invariant on a message array. Each entry point no-ops when
5
- # +Riffer.config.experimental_history_healing+ is off.
3
+ # Maintains the invariant that every +tool_use+ has a matching +tool_result+
4
+ # and every +tool_result+ has a parent +tool_use+.
6
5
  module Riffer::Agent::Session::Repair
7
- # Placeholder response filled in for an orphaned +tool_use+ on interrupt.
8
6
  ORPHAN_PLACEHOLDER: ^(Riffer::Messages::Assistant::ToolCall) -> Riffer::Tools::Response
9
7
 
10
- # Fills each orphaned +tool_use+ in +messages+ with an +ORPHAN_PLACEHOLDER+
11
- # result inserted after its parent. Returns +[new_messages, filled_call_ids]+.
12
8
  # --
13
9
  # : (Array[Riffer::Messages::Base]) -> [Array[Riffer::Messages::Base], Array[String]]
14
10
  def fill_orphans: (Array[Riffer::Messages::Base]) -> [ Array[Riffer::Messages::Base], Array[String] ]
15
11
 
16
- # Prunes a seeded message array to the invariant — dropping orphaned tool
17
- # exchanges and parentless Tool messages, but preserving the pending
18
- # tool_calls on the resume boundary (the last assistant) for
19
- # +execute_pending_tool_calls+. Returns a new array.
20
12
  # --
21
13
  # : (Array[Riffer::Messages::Base]) -> Array[Riffer::Messages::Base]
22
14
  def prune_orphans: (Array[Riffer::Messages::Base]) -> Array[Riffer::Messages::Base]
@@ -1,100 +1,74 @@
1
1
  # Generated from lib/riffer/agent/session.rb with RBS::Inline
2
2
 
3
- # Owns the conversation handle for an agent: the message array, the
4
- # +on_message+ callbacks, and the +tool_use+ ↔ +tool_result+ invariant that
5
- # keeps tool calls and their results consistent.
6
- #
7
- # agent.session.add(msg) # append + fire callbacks
8
- # agent.session.set([msg1, msg2]) # bulk replace (silent)
9
- # agent.session.unset # clear (silent)
10
- # agent.session.remove(id: "a_1")
11
- # agent.session.update(id: "a_1", content: "...")
12
- # agent.session.find { |m| m.id == "a_1" }
13
3
  class Riffer::Agent::Session
14
4
  include Enumerable[Riffer::Messages::Base]
15
5
 
16
6
  @callbacks: Array[^(Riffer::Messages::Base) -> void]
17
7
 
18
- # The message history.
19
8
  attr_reader messages: Array[Riffer::Messages::Base]
20
9
 
21
10
  # --
22
11
  # : (?messages: Array[Riffer::Messages::Base]) -> void
23
12
  def initialize: (?messages: Array[Riffer::Messages::Base]) -> void
24
13
 
25
- # Registers a callback invoked once per message appended via +#add+.
26
14
  # --
27
15
  # : () { (Riffer::Messages::Base) -> void } -> self
28
16
  def on_message: () { (Riffer::Messages::Base) -> void } -> self
29
17
 
30
- # Appends +message+ and fires every registered callback once with it. Pass
31
- # +silent: true+ to skip callbacks — used for non-inference inputs like user
32
- # messages that subscribers don't expect on the callback channel.
33
18
  # --
34
19
  # : (Riffer::Messages::Base, ?silent: bool) -> Riffer::Messages::Base
35
20
  def add: (Riffer::Messages::Base, ?silent: bool) -> Riffer::Messages::Base
36
21
 
37
- # Replaces the message history wholesale
38
22
  # --
39
23
  # : (Array[Riffer::Messages::Base]) -> self
40
24
  def set: (Array[Riffer::Messages::Base]) -> self
41
25
 
42
- # Clears the session.
43
26
  # --
44
27
  # : () -> self
45
28
  def unset: () -> self
46
29
 
47
- # Removes a message by id, cascading to drop the +Tool+ results of a removed
48
- # assistant's +tool_calls+ so the +tool_use+ ↔ +tool_result+ invariant holds.
49
- # Raises on a +Tool+ message — that would orphan its parent; use +#update+
50
- # instead. Returns +nil+ if no message matches.
51
30
  # --
52
31
  # : (id: String) -> Riffer::Messages::Base?
53
32
  def remove: (id: String) -> Riffer::Messages::Base?
54
33
 
55
- # Partial in-place update: looks up a message by +id:+ or +tool_call_id:+
56
- # (exactly one), overlays +attrs+ onto a same-type replacement, and swaps it
57
- # in. Dropping +tool_calls+ from an assistant cascades to remove their +Tool+
58
- # results, preserving the invariant. Raises on neither/both keys or no match.
59
34
  # --
60
35
  # : (?id: String?, ?tool_call_id: String?, **untyped) -> Riffer::Messages::Base
61
36
  def update: (?id: String?, ?tool_call_id: String?, **untyped) -> Riffer::Messages::Base
62
37
 
63
- # Returns the call_ids of every +tool_call+ with no matching
64
- # +Riffer::Messages::Tool+ result anywhere in history — a hook for checking
65
- # the +tool_use+ ↔ +tool_result+ invariant before mutating or persisting.
66
38
  # --
67
39
  # : () -> Array[String]
68
40
  def orphaned_tool_call_ids: () -> Array[String]
69
41
 
70
- # Returns +[last_assistant, pending_tool_calls]+; the second element is empty
71
- # when there's no assistant message or no pending calls.
72
42
  # --
73
43
  # : () -> [Riffer::Messages::Assistant?, Array[Riffer::Messages::Assistant::ToolCall]]
74
44
  def pending_tool_calls: () -> [ Riffer::Messages::Assistant?, Array[Riffer::Messages::Assistant::ToolCall] ]
75
45
 
76
- # Yields each message in order, or returns an Enumerator without a block.
46
+ # --
47
+ # : () -> Array[String]
48
+ def discard_pending_tool_calls: () -> Array[String]
49
+
77
50
  # --
78
51
  # : () -> Enumerator[Riffer::Messages::Base, self]
79
52
  # : () { (Riffer::Messages::Base) -> void } -> untyped
80
53
  def each: () -> Enumerator[Riffer::Messages::Base, self]
81
54
  | () { (Riffer::Messages::Base) -> void } -> untyped
82
55
 
83
- # The number of LLM steps completed, used by the agent loop to enforce
84
- # +max_steps+ on resume.
85
56
  # --
86
57
  # : () -> Integer
87
58
  def steps: () -> Integer
88
59
 
89
- # The most recent +Riffer::Messages::Assistant+ in the session, or +nil+
90
- # when none exists.
91
- #
92
60
  # --
93
61
  # : () -> Riffer::Messages::Assistant?
94
62
  def final_assistant_message: () -> Riffer::Messages::Assistant?
95
63
 
96
64
  private
97
65
 
66
+ # Providers require tool results to directly follow their tool_use, but a
67
+ # resumed turn appends the new user message before pending calls execute.
68
+ # --
69
+ # : (Riffer::Messages::Base) -> Integer
70
+ def insertion_index: (Riffer::Messages::Base) -> Integer
71
+
98
72
  # --
99
73
  # : (Riffer::Messages::Base, Riffer::Messages::Base) -> void
100
74
  def cascade_dropped_tool_calls: (Riffer::Messages::Base, Riffer::Messages::Base) -> void
@@ -1,25 +1,18 @@
1
1
  # Generated from lib/riffer/agent/structured_output/result.rb with RBS::Inline
2
2
 
3
- # Wraps the result of structured output parsing and validation.
4
3
  class Riffer::Agent::StructuredOutput::Result
5
- # The validated object, or +nil+ on failure.
6
4
  attr_reader object: Hash[Symbol, untyped]?
7
5
 
8
- # The error message, or +nil+ on success.
9
6
  attr_reader error: String?
10
7
 
11
8
  # --
12
9
  # : (?object: Hash[Symbol, untyped]?, ?error: String?) -> void
13
10
  def initialize: (?object: Hash[Symbol, untyped]?, ?error: String?) -> void
14
11
 
15
- # Returns true when parsing and validation succeeded.
16
- #
17
12
  # --
18
13
  # : () -> bool
19
14
  def success?: () -> bool
20
15
 
21
- # Returns true when parsing or validation failed.
22
- #
23
16
  # --
24
17
  # : () -> bool
25
18
  def failure?: () -> bool