roast-ai 0.4.10 → 0.5.1

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 (175) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/commands/docs/write-comments.md +36 -0
  3. data/.github/CODEOWNERS +1 -1
  4. data/.github/workflows/ci.yaml +10 -6
  5. data/.gitignore +0 -1
  6. data/.rubocop.yml +7 -1
  7. data/.ruby-version +1 -1
  8. data/CLAUDE.md +2 -2
  9. data/CONTRIBUTING.md +2 -0
  10. data/Gemfile +19 -18
  11. data/Gemfile.lock +35 -58
  12. data/README.md +118 -1432
  13. data/README_LEGACY.md +1464 -0
  14. data/Rakefile +39 -4
  15. data/dev.yml +29 -0
  16. data/dsl/agent_sessions.rb +20 -0
  17. data/dsl/async_cogs.rb +49 -0
  18. data/dsl/async_cogs_complex.rb +67 -0
  19. data/dsl/call.rb +44 -0
  20. data/dsl/collect_from.rb +72 -0
  21. data/dsl/json_output.rb +28 -0
  22. data/dsl/map.rb +55 -0
  23. data/dsl/map_reduce.rb +37 -0
  24. data/dsl/map_with_index.rb +49 -0
  25. data/dsl/next_break.rb +45 -0
  26. data/dsl/next_break_parallel.rb +44 -0
  27. data/dsl/outputs.rb +39 -0
  28. data/dsl/outputs_bang.rb +36 -0
  29. data/dsl/parallel_map.rb +37 -0
  30. data/dsl/prompts/simple_prompt.md.erb +3 -0
  31. data/dsl/prototype.rb +5 -7
  32. data/dsl/repeat_loop_results.rb +53 -0
  33. data/dsl/ruby_cog.rb +72 -0
  34. data/dsl/simple_agent.rb +18 -0
  35. data/dsl/simple_chat.rb +15 -1
  36. data/dsl/simple_repeat.rb +29 -0
  37. data/dsl/skip.rb +36 -0
  38. data/dsl/step_communication.rb +2 -3
  39. data/dsl/targets_and_params.rb +57 -0
  40. data/dsl/temperature.rb +17 -0
  41. data/dsl/temporary_directory.rb +22 -0
  42. data/dsl/tutorial/01_your_first_workflow/README.md +179 -0
  43. data/dsl/tutorial/01_your_first_workflow/configured_chat.rb +33 -0
  44. data/dsl/tutorial/01_your_first_workflow/hello.rb +23 -0
  45. data/dsl/tutorial/02_chaining_cogs/README.md +310 -0
  46. data/dsl/tutorial/02_chaining_cogs/code_review.rb +104 -0
  47. data/dsl/tutorial/02_chaining_cogs/session_resumption.rb +92 -0
  48. data/dsl/tutorial/02_chaining_cogs/simple_chain.rb +84 -0
  49. data/dsl/tutorial/03_targets_and_params/README.md +230 -0
  50. data/dsl/tutorial/03_targets_and_params/multiple_targets.rb +65 -0
  51. data/dsl/tutorial/03_targets_and_params/single_target.rb +65 -0
  52. data/dsl/tutorial/04_configuration_options/README.md +209 -0
  53. data/dsl/tutorial/04_configuration_options/control_display_and_temperature.rb +104 -0
  54. data/dsl/tutorial/04_configuration_options/simple_config.rb +68 -0
  55. data/dsl/tutorial/05_control_flow/README.md +156 -0
  56. data/dsl/tutorial/05_control_flow/conditional_execution.rb +62 -0
  57. data/dsl/tutorial/05_control_flow/handling_failures.rb +77 -0
  58. data/dsl/tutorial/06_reusable_scopes/README.md +172 -0
  59. data/dsl/tutorial/06_reusable_scopes/accessing_scope_outputs.rb +126 -0
  60. data/dsl/tutorial/06_reusable_scopes/basic_scope.rb +63 -0
  61. data/dsl/tutorial/06_reusable_scopes/parameterized_scope.rb +78 -0
  62. data/dsl/tutorial/07_processing_collections/README.md +152 -0
  63. data/dsl/tutorial/07_processing_collections/basic_map.rb +70 -0
  64. data/dsl/tutorial/07_processing_collections/parallel_map.rb +74 -0
  65. data/dsl/tutorial/08_iterative_workflows/README.md +231 -0
  66. data/dsl/tutorial/08_iterative_workflows/basic_repeat.rb +57 -0
  67. data/dsl/tutorial/08_iterative_workflows/conditional_break.rb +57 -0
  68. data/dsl/tutorial/09_async_cogs/README.md +197 -0
  69. data/dsl/tutorial/09_async_cogs/basic_async.rb +38 -0
  70. data/dsl/tutorial/README.md +222 -0
  71. data/dsl/working_directory.rb +16 -0
  72. data/exe/roast +1 -1
  73. data/internal/documentation/architectural-notes.md +115 -0
  74. data/internal/documentation/doc-comments-external.md +686 -0
  75. data/internal/documentation/doc-comments-internal.md +342 -0
  76. data/internal/documentation/doc-comments.md +211 -0
  77. data/lib/roast/dsl/cog/config.rb +274 -3
  78. data/lib/roast/dsl/cog/input.rb +53 -10
  79. data/lib/roast/dsl/cog/output.rb +297 -8
  80. data/lib/roast/dsl/cog/registry.rb +35 -3
  81. data/lib/roast/dsl/cog/stack.rb +1 -1
  82. data/lib/roast/dsl/cog/store.rb +5 -5
  83. data/lib/roast/dsl/cog.rb +70 -14
  84. data/lib/roast/dsl/cog_input_context.rb +36 -1
  85. data/lib/roast/dsl/cog_input_manager.rb +116 -7
  86. data/lib/roast/dsl/cogs/agent/config.rb +465 -0
  87. data/lib/roast/dsl/cogs/agent/input.rb +81 -0
  88. data/lib/roast/dsl/cogs/agent/output.rb +59 -0
  89. data/lib/roast/dsl/cogs/agent/provider.rb +51 -0
  90. data/lib/roast/dsl/cogs/agent/providers/claude/claude_invocation.rb +185 -0
  91. data/lib/roast/dsl/cogs/agent/providers/claude/message.rb +73 -0
  92. data/lib/roast/dsl/cogs/agent/providers/claude/messages/assistant_message.rb +36 -0
  93. data/lib/roast/dsl/cogs/agent/providers/claude/messages/result_message.rb +61 -0
  94. data/lib/roast/dsl/cogs/agent/providers/claude/messages/system_message.rb +47 -0
  95. data/lib/roast/dsl/cogs/agent/providers/claude/messages/text_message.rb +36 -0
  96. data/lib/roast/dsl/cogs/agent/providers/claude/messages/tool_result_message.rb +47 -0
  97. data/lib/roast/dsl/cogs/agent/providers/claude/messages/tool_use_message.rb +46 -0
  98. data/lib/roast/dsl/cogs/agent/providers/claude/messages/unknown_message.rb +27 -0
  99. data/lib/roast/dsl/cogs/agent/providers/claude/messages/user_message.rb +37 -0
  100. data/lib/roast/dsl/cogs/agent/providers/claude/tool_result.rb +51 -0
  101. data/lib/roast/dsl/cogs/agent/providers/claude/tool_use.rb +48 -0
  102. data/lib/roast/dsl/cogs/agent/providers/claude.rb +31 -0
  103. data/lib/roast/dsl/cogs/agent/stats.rb +92 -0
  104. data/lib/roast/dsl/cogs/agent/usage.rb +62 -0
  105. data/lib/roast/dsl/cogs/agent.rb +75 -0
  106. data/lib/roast/dsl/cogs/chat/config.rb +453 -0
  107. data/lib/roast/dsl/cogs/chat/input.rb +92 -0
  108. data/lib/roast/dsl/cogs/chat/output.rb +64 -0
  109. data/lib/roast/dsl/cogs/chat/session.rb +68 -0
  110. data/lib/roast/dsl/cogs/chat.rb +59 -56
  111. data/lib/roast/dsl/cogs/cmd.rb +251 -61
  112. data/lib/roast/dsl/cogs/ruby.rb +171 -0
  113. data/lib/roast/dsl/command_runner.rb +191 -0
  114. data/lib/roast/dsl/config_manager.rb +58 -11
  115. data/lib/roast/dsl/control_flow.rb +41 -0
  116. data/lib/roast/dsl/execution_manager.rb +162 -32
  117. data/lib/roast/dsl/nil_assertions.rb +23 -0
  118. data/lib/roast/dsl/system_cog/params.rb +32 -0
  119. data/lib/roast/dsl/system_cog.rb +36 -0
  120. data/lib/roast/dsl/system_cogs/call.rb +163 -0
  121. data/lib/roast/dsl/system_cogs/map.rb +454 -0
  122. data/lib/roast/dsl/system_cogs/repeat.rb +242 -0
  123. data/lib/roast/dsl/workflow.rb +26 -16
  124. data/lib/roast/dsl/workflow_context.rb +20 -0
  125. data/lib/roast/dsl/workflow_params.rb +24 -0
  126. data/lib/roast/helpers/minitest_coverage_runner.rb +1 -1
  127. data/lib/roast/sorbet_runtime_stub.rb +154 -0
  128. data/lib/roast/tools/apply_diff.rb +1 -3
  129. data/lib/roast/tools/cmd.rb +4 -3
  130. data/lib/roast/tools/read_file.rb +1 -1
  131. data/lib/roast/tools/update_files.rb +1 -1
  132. data/lib/roast/tools/write_file.rb +1 -1
  133. data/lib/roast/version.rb +1 -1
  134. data/lib/roast/workflow/base_workflow.rb +4 -0
  135. data/lib/roast/workflow/step_loader.rb +14 -2
  136. data/lib/roast-ai.rb +4 -0
  137. data/lib/roast.rb +58 -21
  138. data/{roast.gemspec → roast-ai.gemspec} +9 -13
  139. data/sorbet/rbi/gems/async@2.34.0.rbi +1577 -0
  140. data/sorbet/rbi/gems/cli-kit@5.2.0.rbi +2063 -0
  141. data/sorbet/rbi/gems/{cli-ui@2.3.0.rbi → cli-ui@2.7.0-6bdefd1d06305e5d6ae312ac76f9c88f88658dda.rbi} +1418 -1013
  142. data/sorbet/rbi/gems/console@1.34.2.rbi +1193 -0
  143. data/sorbet/rbi/gems/fiber-annotation@0.2.0.rbi +50 -0
  144. data/sorbet/rbi/gems/fiber-local@1.1.0.rbi +35 -0
  145. data/sorbet/rbi/gems/fiber-storage@1.0.1.rbi +41 -0
  146. data/sorbet/rbi/gems/io-event@1.14.0.rbi +724 -0
  147. data/sorbet/rbi/gems/metrics@0.15.0.rbi +9 -0
  148. data/sorbet/rbi/gems/traces@0.18.2.rbi +9 -0
  149. data/sorbet/rbi/shims/lib/roast/dsl/cog_input_context.rbi +1185 -5
  150. data/sorbet/rbi/shims/lib/roast/dsl/config_context.rbi +311 -5
  151. data/sorbet/rbi/shims/lib/roast/dsl/execution_context.rbi +486 -5
  152. data/sorbet/tapioca/config.yml +6 -0
  153. data/sorbet/tapioca/require.rb +2 -0
  154. metadata +157 -30
  155. data/dsl/less_simple.rb +0 -112
  156. data/dsl/scoped_executors.rb +0 -28
  157. data/dsl/simple.rb +0 -8
  158. data/lib/roast/dsl/cogs/execute.rb +0 -46
  159. data/lib/roast/dsl/cogs/graph.rb +0 -53
  160. data/sorbet/rbi/gems/cgi@0.5.0.rbi +0 -2961
  161. data/sorbet/rbi/gems/claude_swarm@0.1.19.rbi +0 -568
  162. data/sorbet/rbi/gems/cli-kit@5.0.1.rbi +0 -1991
  163. data/sorbet/rbi/gems/dry-configurable@1.3.0.rbi +0 -672
  164. data/sorbet/rbi/gems/dry-core@1.1.0.rbi +0 -1894
  165. data/sorbet/rbi/gems/dry-inflector@1.2.0.rbi +0 -659
  166. data/sorbet/rbi/gems/dry-initializer@3.2.0.rbi +0 -781
  167. data/sorbet/rbi/gems/dry-logic@1.6.0.rbi +0 -1127
  168. data/sorbet/rbi/gems/dry-schema@1.14.1.rbi +0 -3727
  169. data/sorbet/rbi/gems/dry-types@1.8.3.rbi +0 -3969
  170. data/sorbet/rbi/gems/fast-mcp-annotations@1.5.3.rbi +0 -1588
  171. data/sorbet/rbi/gems/mime-types-data@3.2025.0617.rbi +0 -136
  172. data/sorbet/rbi/gems/mime-types@3.7.0.rbi +0 -1342
  173. data/sorbet/rbi/gems/rack@2.2.19.rbi +0 -5676
  174. data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +0 -435
  175. data/sorbet/rbi/gems/yard@0.9.37.rbi +0 -18492
@@ -4,14 +4,1194 @@
4
4
  module Roast
5
5
  module DSL
6
6
  class CogInputContext
7
- #: (Symbol) -> Roast::DSL::Cogs::Cmd::Output
8
- def cmd(name); end
9
7
 
10
- #: (Symbol) -> Roast::DSL::Cogs::Chat::Output
8
+ ########################################
9
+ # Workflow Methods
10
+ ########################################
11
+
12
+ # Get the single target value passed to the workflow
13
+ #
14
+ # Returns the target when exactly one target was provided to the workflow. Raises an
15
+ # `ArgumentError` if the workflow was invoked with zero or multiple targets.
16
+ #
17
+ # Targets are file paths, URLs, or other identifiers passed to the workflow when it is
18
+ # invoked. Use this method when your workflow expects exactly one target.
19
+ #
20
+ # ### Invocation
21
+ # Invoke a workflow with a single target like this:
22
+ # ```bash
23
+ # roast execute --executor=dsl my_workflow.rb my_target_file.txt
24
+ # ```
25
+ #
26
+ # ### Usage
27
+ # ```ruby
28
+ # execute do
29
+ # chat(:analyze) do |my|
30
+ # # Get the single target
31
+ # file_path = target!
32
+ # content = File.read(file_path)
33
+ # my.prompt = "Analyze this file: #{content}"
34
+ # end
35
+ # end
36
+ # ```
37
+ #
38
+ # #### See Also
39
+ # - `targets` - Get all targets as an array (works with any number of targets)
40
+ #
41
+ #: () -> String
42
+ def target!; end
43
+
44
+ # Get all targets passed to the workflow
45
+ #
46
+ # Returns an array of all targets provided to the workflow. Works with any number of targets
47
+ # (zero, one, or many). Targets are file paths, URLs, or other identifiers passed when the
48
+ # workflow is invoked.
49
+ #
50
+ # ### Invocation
51
+ # Invoke a workflow with multiple targets like this:
52
+ # ```bash
53
+ # roast execute --executor=dsl my_workflow.rb target_one.txt target_two.txt
54
+ # ```
55
+ # or using shell globs like this:
56
+ # ```bash
57
+ # roast execute --executor=dsl my_workflow.rb target_*.txt
58
+ # ```
59
+ #
60
+ # ### Usage
61
+ # ```ruby
62
+ # execute do
63
+ # map(:process_files, run: :analyze_file) do |my|
64
+ # # Get all targets to process
65
+ # my.items = targets
66
+ # end
67
+ # end
68
+ # ```
69
+ #
70
+ # #### See Also
71
+ # - `target!` - Get the single target (raises an error if there isn't exactly one)
72
+ #
73
+ #: () -> Array[String]
74
+ def targets; end
75
+
76
+ # Check if a flag argument was passed to the workflow
77
+ #
78
+ # Returns `true` if the specified flag argument symbol was provided when the workflow
79
+ # was invoked, `false` otherwise.
80
+ #
81
+ # Flag arguments are symbolic flags passed to the workflow (e.g., `retry`, `force`)
82
+ # that enable or modify behavior.
83
+ #
84
+ # ### Invocation
85
+ # Invoke a workflow with flag arguments like this:
86
+ # ```bash
87
+ # roast execute --executor=dsl my_workflow.rb [TARGETS] -- retry force
88
+ # ```
89
+ #
90
+ # ### Usage
91
+ # ```ruby
92
+ # execute do
93
+ # ruby do
94
+ # if arg?(:retry)
95
+ # puts "Retry mode enabled"
96
+ # end
97
+ # end
98
+ # end
99
+ # ```
100
+ #
101
+ # #### See Also
102
+ # - `args` - Get all flag arguments as an array
103
+ # - `kwarg?` - Check for keyword arguments (key-value pairs)
104
+ #
105
+ #: (Symbol) -> bool
106
+ def arg?(value); end
107
+
108
+ # Get all flag arguments passed to the workflow
109
+ #
110
+ # Returns an array of all flag argument symbols provided when the workflow was invoked.
111
+ # Flag arguments are symbolic flags (e.g., `retry`, `force`) that enable or modify
112
+ # workflow behavior.
113
+ #
114
+ # ### Invocation
115
+ # Invoke a workflow with flag arguments like this:
116
+ # ```bash
117
+ # roast execute --executor=dsl my_workflow.rb [TARGETS] -- retry force
118
+ # ```
119
+ #
120
+ # ### Usage
121
+ # ```ruby
122
+ # execute do
123
+ # ruby do
124
+ # puts "Arguments: #{args.join(", ")}"
125
+ # end
126
+ # end
127
+ # ```
128
+ #
129
+ # #### See Also
130
+ # - `arg?` - Check if a specific flag argument was provided
131
+ # - `kwargs` - Get all keyword arguments
132
+ #
133
+ #: () -> Array[Symbol]
134
+ def args; end
135
+
136
+ # Get a keyword argument value passed to the workflow
137
+ #
138
+ # Returns the string value for the specified keyword argument key, or `nil` if the key was
139
+ # not provided. Keyword arguments are key-value pairs passed to the workflow for configuration.
140
+ #
141
+ # ### Invocation
142
+ # Invoke a workflow with keyword arguments like this:
143
+ # ```bash
144
+ # roast execute --executor=dsl my_workflow.rb [TARGETS] -- name=Samantha project=Roast
145
+ # ```
146
+ #
147
+ # ### Usage
148
+ # ```ruby
149
+ # execute do
150
+ # chat(:greet) do |my|
151
+ # # Get keyword argument with nil fallback
152
+ # name = kwarg(:name) || "World"
153
+ # my.prompt = "Say hello to #{name}"
154
+ # end
155
+ # end
156
+ # ```
157
+ #
158
+ # #### See Also
159
+ # - `kwarg!` - Get a keyword argument value (raises an error if not provided)
160
+ # - `kwarg?` - Check if a keyword argument was provided
161
+ # - `kwargs` - Get all keyword arguments as a hash
162
+ #
163
+ #: (Symbol) -> String?
164
+ def kwarg(key); end
165
+
166
+ # Get a required keyword argument value passed to the workflow
167
+ #
168
+ # Returns the string value for the specified keyword argument key. Raises an `ArgumentError`
169
+ # if the key was not provided.
170
+ #
171
+ # Use this when your workflow requires a specific keyword argument to function correctly.
172
+ #
173
+ # ### Invocation
174
+ # Invoke a workflow with keyword arguments like this:
175
+ # ```bash
176
+ # roast execute --executor=dsl my_workflow.rb [TARGETS] -- name=Samantha project=Roast
177
+ # ```
178
+ #
179
+ # ### Usage
180
+ # ```ruby
181
+ # execute do
182
+ # chat(:greet) do |my|
183
+ # # Require the 'name' keyword argument
184
+ # name = kwarg!(:name)
185
+ # my.prompt = "Say hello to #{name}"
186
+ # end
187
+ # end
188
+ # ```
189
+ #
190
+ # #### See Also
191
+ # - `kwarg` - Get a keyword argument value (returns nil if not provided)
192
+ # - `kwarg?` - Check if a keyword argument was provided
193
+ # - `kwargs` - Get all keyword arguments as a hash
194
+ #
195
+ #: (Symbol) -> String
196
+ def kwarg!(key); end
197
+
198
+ # Check if a keyword argument was passed to the workflow
199
+ #
200
+ # Returns `true` if the specified keyword argument key was provided when the workflow was
201
+ # invoked, `false` otherwise.
202
+ #
203
+ # ### Invocation
204
+ # Invoke a workflow with keyword arguments like this:
205
+ # ```bash
206
+ # roast execute --executor=dsl my_workflow.rb [TARGETS] -- name=Samantha project=Roast
207
+ # ```
208
+ #
209
+ # ### Usage
210
+ # ```ruby
211
+ # execute do
212
+ # ruby do
213
+ # if kwarg?(:name)
214
+ # puts "Name was provided: #{kwarg(:name)}"
215
+ # end
216
+ # end
217
+ # end
218
+ # ```
219
+ #
220
+ # #### See Also
221
+ # - `kwarg` - Get a keyword argument value (returns nil if not provided)
222
+ # - `kwarg!` - Get a keyword argument value (raises an error if not provided)
223
+ # - `kwargs` - Get all keyword arguments as a hash
224
+ #
225
+ #: (Symbol) -> bool
226
+ def kwarg?(key); end
227
+
228
+ # Get all keyword arguments passed to the workflow
229
+ #
230
+ # Returns a hash of all keyword argument key-value pairs provided when the workflow was invoked.
231
+ # All keys are symbols and all values are strings.
232
+ #
233
+ # ### Invocation
234
+ # Invoke a workflow with keyword arguments like this:
235
+ # ```bash
236
+ # roast execute --executor=dsl my_workflow.rb [TARGETS] -- name=Samantha project=Roast
237
+ # ```
238
+ #
239
+ # ### Usage
240
+ # ```ruby
241
+ # execute do
242
+ # ruby do
243
+ # puts "Keyword arguments:"
244
+ # kwargs.each do |key, value|
245
+ # puts " #{key}: #{value}"
246
+ # end
247
+ # end
248
+ # end
249
+ # ```
250
+ #
251
+ # #### See Also
252
+ # - `kwarg` - Get a single keyword argument value
253
+ # - `kwarg!` - Get a required keyword argument value
254
+ # - `kwarg?` - Check if a keyword argument was provided
255
+ #
256
+ #: () -> Hash[Symbol, String]
257
+ def kwargs; end
258
+
259
+ # Get the temporary directory for this workflow execution
260
+ #
261
+ # Returns a `Pathname` object representing a temporary directory that is unique to this
262
+ # workflow execution. The directory is created automatically and will persist for the
263
+ # duration of the workflow, then be automatically removed.
264
+ #
265
+ # Use this for storing intermediate files, caching data, or other temporary artifacts
266
+ # that your workflow needs during execution.
267
+ #
268
+ # ### Usage
269
+ # ```ruby
270
+ # execute do
271
+ # ruby do
272
+ # temp_file = tmpdir / "data.json"
273
+ # File.write(temp_file, JSON.dump({ status: "processing" }))
274
+ # end
275
+ #
276
+ # cmd do |my|
277
+ # # Reference the temp directory in commands
278
+ # my.command = "ls"
279
+ # my.args = ["-la", tmpdir.to_s]
280
+ # end
281
+ # end
282
+ # ```
283
+ #
284
+ #: () -> Pathname
285
+ def tmpdir; end
286
+
287
+ ########################################
288
+ # System Cogs
289
+ ########################################
290
+
291
+ # Extract output from a single execution scope
292
+ #
293
+ # Retrieves output from the execution scope that was invoked by a `call` cog, or from a specific iteration
294
+ # of the scope invoked by a `map` or `repeat` cog.
295
+ #
296
+ # When called without a block, returns the scope's final output directly (from its `outputs!` or `outputs` block).
297
+ # When called with a block, executes the block in the context of the called scope, receiving the scope's final
298
+ # output, input value, and index as arguments. Inside this block, you can access the output of cogs from the
299
+ # specified scope, as opposed to the current scope.
300
+ #
301
+ # ### Usage
302
+ # ```ruby
303
+ # execute(:summarize_article) do
304
+ # chat(:summary) do |my, article_text|
305
+ # my.prompt = "Summarize this article: #{article_text}"
306
+ # end
307
+ #
308
+ # outputs! { chat!(:summary).lines[0..5].join("\n) }
309
+ # end
310
+ #
311
+ # execute do
312
+ # call(:process, run: :summarize_article) { "Long article text..." }
313
+ #
314
+ # # Get the final output directly
315
+ # short_summary = from(call!(:process))
316
+ #
317
+ # # Access other cog outputs from within the called scope
318
+ # full_response = from(call!(:process)) { chat!(:summary).response }
319
+ #
320
+ # # Access cog outputs and final output together
321
+ # lines_reduced = from(call!(:process)) do |_, article_text|
322
+ # article_text.lines.length - chat!(:summary).lines.length
323
+ # end
324
+ # end
325
+ # ```
326
+ #
327
+ # #### See Also
328
+ # - `call!` - Invoke a named execution scope
329
+ # - `collect` - Collect results from a `map` cog
330
+ # - `reduce` - Reduce results from a `map` cog
331
+ #
332
+ #: [T] (Roast::DSL::SystemCogs::Call::Output) {(untyped, untyped, Integer) -> T} -> T
333
+ #: (Roast::DSL::SystemCogs::Call::Output) -> untyped
334
+ def from(call_cog_output, &block); end
335
+
336
+ # Collect results from all `map` cog iterations into an array
337
+ #
338
+ # Retrieves output from the execution scopes that were invoked for each element in the iterable passed to a `map`,
339
+ # or from each iteration of a `repeat` loop. When called without a block, returns an array of the final outputs
340
+ # directly. When called with a block, executes the block in the context of each iteration's input context,
341
+ # receiving the final output, the original input value (e.g., element from the iterable passed to `map`), and
342
+ # the iteration index as arguments.
343
+ #
344
+ # Iterations that did not run (due to `break!` being called in a different iteration) are skipped.
345
+ # The block __will not__ be called for iterations that did not run. The block __will__ be called for the
346
+ # iteration in which `break!` was invoked.
347
+ #
348
+ # ### Usage
349
+ # ```ruby
350
+ # execute(:review_document) do
351
+ # agent(:review) do |my, document, idx|
352
+ # my.prompt = "Review document #{idx + 1}: #{document}"
353
+ # end
354
+ #
355
+ # outputs! { agent!(:review).text }
356
+ # end
357
+ #
358
+ # execute do
359
+ # map(:review_all, run: :review_document) { ["doc1.md", "doc2.md", "doc3.md"] }
360
+ #
361
+ # # Get all final outputs directly
362
+ # reviews = collect(map!(:review_all))
363
+ #
364
+ # # Access other cog outputs from within each iteration
365
+ # review_length = collect(map!(:review_all)) { chat!(:review).response.length }
366
+ #
367
+ # # Access final output along with the original item and index and all intermediate cog outputs
368
+ # results = collect(map!(:review_all)) do |review, document, index|
369
+ # { document:, review:, index:, lines: agent!(:review).lines.length }
370
+ # end
371
+ # end
372
+ # ```
373
+ #
374
+ # #### See Also
375
+ # - `map` - Execute a scope for each item in a collection
376
+ # - `reduce` - Reduce iteration results to a single value
377
+ # - `from` - Extract output from the execution scope corresponding to a single iteration
378
+ #
379
+ #: [T] (Roast::DSL::SystemCogs::Map::Output) {(untyped, untyped, Integer) -> T} -> Array[T]
380
+ #: (Roast::DSL::SystemCogs::Map::Output) -> Array[untyped]
381
+ def collect(map_cog_output, &block); end
382
+
383
+ # Reduce results from all `map` or `repeat` cog iterations to a single value
384
+ #
385
+ # Retrieves output from the execution scopes that were invoked for each element in the iterable passed to a `map`,
386
+ # or from each iteration of a `repeat` loop, and combines them into a single accumulator value. The block
387
+ # executes in the context of each iteration's input context, receiving the current accumulator value, the final
388
+ # output, the original input value (e.g., element from the iterable passed to `map`), and the iteration index
389
+ # as arguments. The block should return the new accumulator value.
390
+ #
391
+ # If the block returns `nil`, the accumulator will __not__ be updated (preserving any
392
+ # previous non-nil value). This prevents accidental overwrites with `nil` values.
393
+ #
394
+ # Iterations that did not run (due to `break!` being called in a different iteration) are skipped.
395
+ # The block __will not__ be called for iterations that did not run. The block __will__ be called for the
396
+ # iteration in which `break!` was invoked.
397
+ #
398
+ # ### Usage
399
+ # ```ruby
400
+ # execute(:calculate_score) do
401
+ # chat(:score) { |_, item| "Rate this item (1-10): #{item} -- Answer as a JSON: `{ rating: N }`" }
402
+ #
403
+ # outputs! { chat!(:score).json![:rating] }
404
+ # end
405
+ #
406
+ # execute do
407
+ # map(:score_items, run: :calculate_score) { ["item1", "item2", "item3"] }
408
+ #
409
+ # # Sum all outputs
410
+ # total = reduce(map!(:score_items), 0) do |sum, output|
411
+ # sum + output
412
+ # end
413
+ #
414
+ # # Build a hash from outputs
415
+ # results = reduce(map!(:score_items), {}) do |hash, output, item|
416
+ # hash.merge(item => output)
417
+ # end
418
+ #
419
+ # # Access intermediate cog outputs and combine with conditional accumulation
420
+ # high_scores = reduce(map!(:score_items), []) do |acc, output, item, index|
421
+ # # Can access cog outputs from within each iteration's scope
422
+ # output >= 8 ? acc + [{ item:, score: output, details: chat!(:score).response }] : acc
423
+ # end
424
+ # end
425
+ # ```
426
+ #
427
+ # #### See Also
428
+ # - `map` - Execute a scope for each item in a collection
429
+ # - `repeat` - Execute a scope multiple times in a loop
430
+ # - `collect` - Collect all iteration results into an array
431
+ # - `from` - Extract output from the execution scope corresponding to a single iteration
432
+ #
433
+ #: [A] (Roast::DSL::SystemCogs::Map::Output, ?NilClass) {(A?, untyped, untyped, Integer) -> A} -> A?
434
+ #: [A] (Roast::DSL::SystemCogs::Map::Output, ?A) {(A, untyped, untyped, Integer) -> A} -> A
435
+ def reduce(map_cog_output, initial_value = nil, &block); end
436
+
437
+ # Access the output of a `call` cog
438
+ #
439
+ # Returns the output of the `call` cog with the given name if it ran and completed successfully,
440
+ # or `nil` otherwise. This method will __not__ raise an exception if the cog did not run,
441
+ # was skipped, failed, or was stopped. This method __will__ raise an exception if the named cog does not exist.
442
+ #
443
+ # If the cog is currently running (if configured to run asynchronously), this method will block
444
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
445
+ # will return `nil` immediately.
446
+ #
447
+ # NOTE: The return value of `call(:cog_name)` is an opaque object, from which you must use `from`
448
+ # to extract values.
449
+ #
450
+ # ### Usage
451
+ # ```ruby
452
+ # execute do
453
+ # call(:optional_step, run: :process_data) { "input data" }
454
+ #
455
+ # ruby do
456
+ # result = call(:optional_step)
457
+ # if result
458
+ # puts "Step ran: #{from(result)}"
459
+ # else
460
+ # puts "Step did not run or did not complete successfully"
461
+ # end
462
+ # end
463
+ # end
464
+ # ```
465
+ #
466
+ # #### See Also
467
+ # - `call!` - Access the output (raises an exception if the cog did not run successfully)
468
+ # - `call?` - Check if the cog ran successfully (returns a boolean)
469
+ # - `from` - Extract the final output from the called scope
470
+ #
471
+ #: (Symbol) -> Roast::DSL::SystemCogs::Call::Output?
472
+ def call(name); end
473
+
474
+ # Access the output of a `call` cog
475
+ #
476
+ # Returns the output of the `call` cog with the given name. Raises an exception if the cog
477
+ # did not run, was skipped, failed, or was stopped. This is the recommended method for accessing cog outputs
478
+ # when you expect the cog to always have run successfully.
479
+ #
480
+ # If the cog is currently running (if configured to run asynchronously), this method will block
481
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
482
+ # will return `nil` immediately.
483
+ #
484
+ # ### Usage
485
+ # ```ruby
486
+ # execute do
487
+ # call(:process, run: :analyze_data) { "input data" }
488
+ #
489
+ # # Access the output with confidence it ran
490
+ # result = from(call!(:process))
491
+ # end
492
+ # ```
493
+ #
494
+ # #### See Also
495
+ # - `call` - Access the output (returns nil if the cog did not run successfully)
496
+ # - `call?` - Check if the cog ran successfully (returns a boolean)
497
+ # - `from` - Extract the final output from the called scope
498
+ #
499
+ #: (Symbol) -> Roast::DSL::SystemCogs::Call::Output
500
+ def call!(name); end
501
+
502
+ # Check if a `call` cog ran successfully
503
+ #
504
+ # Returns `true` if the `call` cog with the given name ran and completed successfully,
505
+ # `false` otherwise. Use this to check whether a cog ran before attempting to access
506
+ # its output.
507
+ #
508
+ # If `call?(:name)` returns `true`, then `call!(:name)` will not raise an exception.
509
+ # The inverse is also true.
510
+ #
511
+ # If the cog is currently running (if configured to run asynchronously), this method will block
512
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
513
+ # will return `false` immediately.
514
+ #
515
+ # ### Usage
516
+ # ```ruby
517
+ # execute do
518
+ # call(:optional_step, run: :process_data) { "input data" }
519
+ #
520
+ # ruby do
521
+ # if call?(:optional_step)
522
+ # result = from(call!(:optional_step))
523
+ # puts "Result: #{result}"
524
+ # else
525
+ # puts "Step did not run or did not complete successfully"
526
+ # end
527
+ # end
528
+ # end
529
+ # ```
530
+ #
531
+ # #### See Also
532
+ # - `call` - Access the output (returns nil if the cog did not run successfully)
533
+ # - `call!` - Access the output (raises an exception if the cog did not run successfully)
534
+ #
535
+ #: (Symbol) -> bool
536
+ def call?(name); end
537
+
538
+ # Access the output of a `map` cog
539
+ #
540
+ # Returns the output of the `map` cog with the given name if it ran and completed successfully,
541
+ # or `nil` otherwise. This method will __not__ raise an exception if the cog did not run,
542
+ # was skipped, failed or was stopped. This method __will__ raise an exception if the named cog does not exist.
543
+ #
544
+ # If the cog is currently running (if configured to run asynchronously), this method will block
545
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
546
+ # will return `nil` immediately.
547
+ #
548
+ # ### Usage
549
+ # ```ruby
550
+ # execute do
551
+ # map(:optional_map, run: :process_items) { ["item1", "item2"] }
552
+ #
553
+ # ruby do
554
+ # result = map(:optional_map)
555
+ # if result
556
+ # items = collect(result)
557
+ # puts "Processed #{items.length} items"
558
+ # else
559
+ # puts "Map did not run or did not complete successfully"
560
+ # end
561
+ # end
562
+ # end
563
+ # ```
564
+ #
565
+ # #### See Also
566
+ # - `map!` - Access the output (raises an exception if the cog did not run successfully)
567
+ # - `map?` - Check if the cog ran successfully (returns a boolean)
568
+ # - `collect` - Collect all iteration results into an array
569
+ # - `reduce` - Reduce iteration results to a single value
570
+ #
571
+ #: (Symbol) -> Roast::DSL::SystemCogs::Map::Output?
572
+ def map(name); end
573
+
574
+ # Access the output of a `map` cog
575
+ #
576
+ # Returns the output of the `map` cog with the given name. Raises an exception if the cog
577
+ # did not run, was skipped, failed or was stopped. This is the recommended method for accessing cog outputs
578
+ # when you expect the cog to have run successfully.
579
+ #
580
+ # If the cog is currently running (if configured to run asynchronously), this method will block
581
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
582
+ # will return `nil` immediately.
583
+ #
584
+ # ### Usage
585
+ # ```ruby
586
+ # execute do
587
+ # map(:process_items, run: :analyze_item) { ["item1", "item2", "item3"] }
588
+ #
589
+ # # Access all iteration results
590
+ # results = collect(map!(:process_items))
591
+ #
592
+ # # Or reduce to a single value
593
+ # total = reduce(map!(:process_items), 0) { |sum, output| sum + output }
594
+ # end
595
+ # ```
596
+ #
597
+ # #### See Also
598
+ # - `map` - Access the output (returns nil if the cog did not run successfully)
599
+ # - `map?` - Check if the cog ran successfully (returns a boolean)
600
+ # - `collect` - Collect all iteration results into an array
601
+ # - `reduce` - Reduce iteration results to a single value
602
+ #
603
+ #: (Symbol) -> Roast::DSL::SystemCogs::Map::Output
604
+ def map!(name); end
605
+
606
+ # Check if a `map` cog ran successfully
607
+ #
608
+ # Returns `true` if the `map` cog with the given name ran and completed successfully,
609
+ # `false` otherwise. Use this to check whether a cog ran before attempting to access
610
+ # its output.
611
+ #
612
+ # If `map?(name)` returns `true`, then `map!(name)` will not raise an exception.
613
+ # The inverse is also true.
614
+ #
615
+ # If the cog is currently running (if configured to run asynchronously), this method will block
616
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
617
+ # will return `false` immediately.
618
+ #
619
+ # ### Usage
620
+ # ```ruby
621
+ # execute do
622
+ # map(:optional_map, run: :process_items) { ["item1", "item2"] }
623
+ #
624
+ # ruby do
625
+ # if map?(:optional_map)
626
+ # results = collect(map!(:optional_map))
627
+ # puts "Processed #{results.length} items"
628
+ # else
629
+ # puts "Map did not run or did not complete successfully"
630
+ # end
631
+ # end
632
+ # end
633
+ # ```
634
+ #
635
+ # #### See Also
636
+ # - `map` - Access the output (returns nil if the cog did not run successfully)
637
+ # - `map!` - Access the output (raises an exception if the cog did not run successfully)
638
+ #
639
+ #: (Symbol) -> bool
640
+ def map?(name); end
641
+
642
+ # Access the output of a `repeat` cog
643
+ #
644
+ # Returns the output of the `repeat` cog with the given name if it ran and completed successfully,
645
+ # or `nil` otherwise. This method will __not__ raise an exception if the cog did not run,
646
+ # was skipped, failed, or was stopped. This method __will__ raise an exception if the named cog does not exist.
647
+ #
648
+ # If the cog is currently running (if configured to run asynchronously), this method will block
649
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
650
+ # will return `nil` immediately.
651
+ #
652
+ # ### Usage
653
+ # ```ruby
654
+ # execute do
655
+ # repeat(:optional_loop, run: :improve_content) { "initial content" }
656
+ #
657
+ # ruby do
658
+ # result = repeat(:optional_loop)
659
+ # if result
660
+ # final_value = result.value
661
+ # puts "Final result: #{final_value}"
662
+ # else
663
+ # puts "Loop did not run or did not complete successfully"
664
+ # end
665
+ # end
666
+ # end
667
+ # ```
668
+ #
669
+ # #### See Also
670
+ # - `repeat!` - Access the output (raises an exception if the cog did not run successfully)
671
+ # - `repeat?` - Check if the cog ran successfully (returns a boolean)
672
+ # - `collect` - Collect all iteration results via `.results`
673
+ # - `reduce` - Reduce iteration results to a single value via `.results`
674
+ #
675
+ #: (Symbol) -> Roast::DSL::SystemCogs::Repeat::Output?
676
+ def repeat(name); end
677
+
678
+ # Access the output of a `repeat` cog
679
+ #
680
+ # Returns the output of the `repeat` cog with the given name. Raises an exception if the cog
681
+ # did not run, was skipped, failed, or was stopped. This is the recommended method for accessing cog outputs
682
+ # when you expect the cog to have run successfully.
683
+ #
684
+ # If the cog is currently running (if configured to run asynchronously), this method will block
685
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
686
+ # will return `nil` immediately.
687
+ #
688
+ # ### Usage
689
+ # ```ruby
690
+ # execute do
691
+ # repeat(:refine, run: :improve_content) { "initial content" }
692
+ #
693
+ # # Access the final value from the last iteration
694
+ # final_result = repeat!(:refine).value
695
+ #
696
+ # # Or collect all iteration results
697
+ # all_iterations = collect(repeat!(:refine).results)
698
+ # end
699
+ # ```
700
+ #
701
+ # #### See Also
702
+ # - `repeat` - Access the output (returns nil if the cog did not run successfully)
703
+ # - `repeat?` - Check if the cog ran successfully (returns a boolean)
704
+ # - `collect` - Collect all iteration results via `.results`
705
+ # - `reduce` - Reduce iteration results to a single value via `.results`
706
+ #
707
+ #: (Symbol) -> Roast::DSL::SystemCogs::Repeat::Output
708
+ def repeat!(name); end
709
+
710
+ # Check if a `repeat` cog ran successfully
711
+ #
712
+ # Returns `true` if the `repeat` cog with the given name ran and completed successfully,
713
+ # `false` otherwise. Use this to check whether a cog ran before attempting to access
714
+ # its output.
715
+ #
716
+ # If `repeat?(name)` returns `true`, then `repeat!(name)` will not raise an exception.
717
+ # The inverse is also true.
718
+ #
719
+ # If the cog is currently running (if configured to run asynchronously), this method will block
720
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
721
+ # will return `nil` immediately.
722
+ #
723
+ # ### Usage
724
+ # ```ruby
725
+ # execute do
726
+ # repeat(:optional_loop, run: :improve_content) { "initial content" }
727
+ #
728
+ # ruby do
729
+ # if repeat?(:optional_loop)
730
+ # result = repeat!(:optional_loop).value
731
+ # puts "Final result: #{result}"
732
+ # else
733
+ # puts "Loop did not run or did not complete successfully"
734
+ # end
735
+ # end
736
+ # end
737
+ # ```
738
+ #
739
+ # #### See Also
740
+ # - `repeat` - Access the output (returns nil if the cog did not run successfully)
741
+ # - `repeat!` - Access the output (raises an exception if the cog did not run successfully)
742
+ #
743
+ #: (Symbol) -> bool
744
+ def repeat?(name); end
745
+
746
+ ########################################
747
+ # Standard Cogs
748
+ ########################################
749
+
750
+ # Access the output of an `agent` cog
751
+ #
752
+ # Returns the output of the `agent` cog with the given name if it ran and completed successfully,
753
+ # or `nil` otherwise. This method will __not__ raise an exception if the cog did not run,
754
+ # was skipped, failed, or was stopped. This method __will__ raise an exception if the named cog does not exist.
755
+ #
756
+ # If the cog is currently running (if configured to run asynchronously), this method will block
757
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
758
+ # will return `false` immediately.
759
+ #
760
+ # ### Usage
761
+ # ```ruby
762
+ # execute do
763
+ # agent(:optional_agent) { "Analyze the code in src/" }
764
+ #
765
+ # ruby do
766
+ # result = agent(:optional_agent)
767
+ # if result
768
+ # puts "Agent response: #{result.response}"
769
+ # else
770
+ # puts "Agent did not run or did not complete successfully"
771
+ # end
772
+ # end
773
+ # end
774
+ # ```
775
+ #
776
+ # #### See Also
777
+ # - `agent!` - Access the output (raises an exception if the cog did not run successfully)
778
+ # - `agent?` - Check if the cog ran successfully (returns a boolean)
779
+ #
780
+ #: (Symbol) -> Roast::DSL::Cogs::Agent::Output?
781
+ def agent(name); end
782
+
783
+ # Access the output of an `agent` cog
784
+ #
785
+ # Returns the output of the `agent` cog with the given name. Raises an exception if the cog
786
+ # did not run, was skipped, failed, or was stopped. This is the recommended method for accessing cog outputs
787
+ # when you expect the cog to have run successfully.
788
+ #
789
+ # If the cog is currently running (if configured to run asynchronously), this method will block
790
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
791
+ # will return `nil` immediately.
792
+ #
793
+ # ### Usage
794
+ # ```ruby
795
+ # execute do
796
+ # agent(:code_analyzer) { "Analyze the code in src/ and suggest improvements" }
797
+ #
798
+ # chat(:summarize) do |my|
799
+ # # Use the agent's response in subsequent steps
800
+ # my.prompt = "Summarize these suggestions: #{agent!(:code_analyzer).response}"
801
+ # end
802
+ #
803
+ # # Resume from a previous agent session
804
+ # agent(:continue) do |my|
805
+ # my.prompt = "Now apply those improvements"
806
+ # my.session = agent!(:code_analyzer).session
807
+ # end
808
+ # end
809
+ # ```
810
+ #
811
+ # #### See Also
812
+ # - `agent` - Access the output (returns nil if the cog did not run successfully)
813
+ # - `agent?` - Check if the cog ran successfully (returns a boolean)
814
+ #
815
+ #: (Symbol) -> Roast::DSL::Cogs::Agent::Output
816
+ def agent!(name); end
817
+
818
+ # Check if an `agent` cog ran successfully
819
+ #
820
+ # Returns `true` if the `agent` cog with the given name ran and completed successfully,
821
+ # `false` otherwise. Use this to check whether a cog ran before attempting to access
822
+ # its output.
823
+ #
824
+ # If `agent?(name)` returns `true`, then `agent!(name)` will not raise an exception.
825
+ # The inverse is also true.
826
+ #
827
+ # If the cog is currently running (if configured to run asynchronously), this method will block
828
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
829
+ # will return `false` immediately.
830
+ #
831
+ # ### Usage
832
+ # ```ruby
833
+ # execute do
834
+ # agent(:optional_agent) { "Analyze the code in src/" }
835
+ #
836
+ # ruby do
837
+ # if agent?(:optional_agent)
838
+ # response = agent!(:optional_agent).response
839
+ # puts "Agent completed: #{response}"
840
+ # else
841
+ # puts "Agent did not run or did not complete successfully"
842
+ # end
843
+ # end
844
+ # end
845
+ # ```
846
+ #
847
+ # #### See Also
848
+ # - `agent` - Access the output (returns nil if the cog did not run successfully)
849
+ # - `agent!` - Access the output (raises an exception if the cog did not run successfully)
850
+ #
851
+ #: (Symbol) -> bool
852
+ def agent?(name); end
853
+
854
+ # Access the output of a `chat` cog
855
+ #
856
+ # Returns the output of the `chat` cog with the given name if it ran and completed successfully,
857
+ # or `nil` otherwise. This method will __not__ raise an exception if the cog did not run,
858
+ # was skipped, failed, or was stopped. This method __will__ raise an exception if the named cog does not exist.
859
+ #
860
+ # If the cog is currently running (if configured to run asynchronously), this method will block
861
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
862
+ # will return `nil` immediately.
863
+ #
864
+ # ### Usage
865
+ # ```ruby
866
+ # execute do
867
+ # chat(:optional_chat) { "Analyze this data..." }
868
+ #
869
+ # ruby do
870
+ # result = chat(:optional_chat)
871
+ # if result
872
+ # puts "Chat response: #{result.response}"
873
+ # else
874
+ # puts "Chat did not run or did not complete successfully"
875
+ # end
876
+ # end
877
+ #
878
+ # # Resume from a previous chat session if it ran
879
+ # chat(:followup) do |my|
880
+ # previous = chat(:optional_chat)
881
+ # if previous
882
+ # my.prompt = "Can you elaborate on that?"
883
+ # my.session = previous.session
884
+ # else
885
+ # my.prompt = "Analyze this data from scratch..."
886
+ # end
887
+ # end
888
+ # end
889
+ # ```
890
+ #
891
+ # #### See Also
892
+ # - `chat!` - Access the output (raises an exception if the cog did not run successfully)
893
+ # - `chat?` - Check if the cog ran successfully (returns a boolean)
894
+ #
895
+ #: (Symbol) -> Roast::DSL::Cogs::Chat::Output?
11
896
  def chat(name); end
12
897
 
13
- #: (Symbol) -> Roast::DSL::Cog::Output
14
- def execute(name); end
898
+ # Access the output of a `chat` cog (raises an exception if it did not run successfully)
899
+ #
900
+ # Returns the output of the `chat` cog with the given name. Raises an exception if the cog
901
+ # did not run, was skipped, failed, or was stopped. This is the recommended method for accessing cog outputs
902
+ # when you expect the cog to have run successfully.
903
+ #
904
+ # If the cog is currently running (if configured to run asynchronously), this method will block
905
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
906
+ # will return `nil` immediately.
907
+ #
908
+ # ### Usage
909
+ # ```ruby
910
+ # execute do
911
+ # chat(:analyzer) do |my|
912
+ # data = JSON.parse(File.read("data.json"))
913
+ # my.prompt = "Analyze this data: #{data}"
914
+ # end
915
+ #
916
+ # chat(:summarizer) do |my|
917
+ # # Use the previous chat's response
918
+ # my.prompt = "Summarize this analysis: #{chat!(:analyzer).response}"
919
+ # end
920
+ #
921
+ # # Resume a conversation by passing the session
922
+ # chat(:continue) do |my|
923
+ # my.prompt = "Now provide more details about the first point"
924
+ # my.session = chat!(:analyzer).session
925
+ # end
926
+ #
927
+ # # Parse JSON responses
928
+ # ruby do
929
+ # insights = chat!(:analyzer).json!
930
+ # puts "Key insights: #{insights[:key_findings]}"
931
+ # end
932
+ # end
933
+ # ```
934
+ #
935
+ # #### See Also
936
+ # - `chat` - Access the output (returns nil if the cog did not run successfully)
937
+ # - `chat?` - Check if the cog ran successfully (returns a boolean)
938
+ #
939
+ #: (Symbol) -> Roast::DSL::Cogs::Chat::Output
940
+ def chat!(name); end
941
+
942
+ # Check if a `chat` cog ran successfully
943
+ #
944
+ # Returns `true` if the `chat` cog with the given name ran and completed successfully,
945
+ # `false` otherwise. Use this to check whether a cog ran before attempting to access
946
+ # its output.
947
+ #
948
+ # If `chat?(name)` returns `true`, then `chat!(name)` will not raise an exception.
949
+ # The inverse is also true.
950
+ #
951
+ # If the cog is currently running (if configured to run asynchronously), this method will block
952
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
953
+ # will return `false` immediately.
954
+ #
955
+ # ### Usage
956
+ # ```ruby
957
+ # execute do
958
+ # chat(:optional_chat) { "Analyze this data..." }
959
+ #
960
+ # ruby do
961
+ # if chat?(:optional_chat)
962
+ # response = chat!(:optional_chat).response
963
+ # puts "Chat completed: #{response}"
964
+ # else
965
+ # puts "Chat did not run or did not complete successfully"
966
+ # end
967
+ # end
968
+ # end
969
+ # ```
970
+ #
971
+ # #### See Also
972
+ # - `chat` - Access the output (returns nil if the cog did not run successfully)
973
+ # - `chat!` - Access the output (raises an exception if the cog did not run successfully)
974
+ #
975
+ #: (Symbol) -> bool
976
+ def chat?(name); end
977
+
978
+ # Access the output of a `cmd` cog
979
+ #
980
+ # Returns the output of the `cmd` cog with the given name if it ran and completed successfully,
981
+ # or `nil` otherwise. This method will __not__ raise an exception if the cog did not run,
982
+ # was skipped, failed, or was stopped. This method __will__ raise an exception if the named cog does not exist.
983
+ #
984
+ # If the cog is currently running (if configured to run asynchronously), this method will block
985
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
986
+ # will return `nil` immediately.
987
+ #
988
+ # ### Usage
989
+ # ```ruby
990
+ # execute do
991
+ # cmd(:optional_cmd) { "ls -la" }
992
+ #
993
+ # ruby do
994
+ # result = cmd(:optional_cmd)
995
+ # if result
996
+ # puts "Command output: #{result.out}"
997
+ # else
998
+ # puts "Command did not run or did not complete successfully"
999
+ # end
1000
+ # end
1001
+ # end
1002
+ # ```
1003
+ #
1004
+ # #### See Also
1005
+ # - `cmd!` - Access the output (raises an exception if the cog did not run successfully)
1006
+ # - `cmd?` - Check if the cog ran successfully (returns a boolean)
1007
+ #
1008
+ #: (Symbol) -> Roast::DSL::Cogs::Cmd::Output?
1009
+ def cmd(name); end
1010
+
1011
+ # Access the output of a `cmd` cog
1012
+ #
1013
+ # Returns the output of the `cmd` cog with the given name. Raises an exception if the cog
1014
+ # did not run, was skipped, failed, or was stopped. This is the recommended method for accessing cog outputs
1015
+ # when you expect the cog to have run successfully.
1016
+ #
1017
+ # If the cog is currently running (if configured to run asynchronously), this method will block
1018
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
1019
+ # will return `false` immediately.
1020
+ #
1021
+ # ### Usage
1022
+ # ```ruby
1023
+ # execute do
1024
+ # cmd(:git_status) { ["git", "status", "--short"] }
1025
+ #
1026
+ # chat(:analyze_changes) do |my|
1027
+ # # Use command output in subsequent steps
1028
+ # my.prompt = "Analyze these git changes: #{cmd!(:git_status).out}"
1029
+ # end
1030
+ #
1031
+ # # Parse JSON output from commands
1032
+ # cmd(:get_data) { "curl -s https://api.example.com/data" }
1033
+ # ruby do
1034
+ # data = cmd!(:get_data).json!
1035
+ # puts "Fetched #{data[:items].length} items"
1036
+ # end
1037
+ # end
1038
+ # ```
1039
+ #
1040
+ # #### See Also
1041
+ # - `cmd` - Access the output (returns nil if the cog did not run successfully)
1042
+ # - `cmd?` - Check if the cog ran successfully (returns a boolean)
1043
+ #
1044
+ #: (Symbol) -> Roast::DSL::Cogs::Cmd::Output
1045
+ def cmd!(name); end
1046
+
1047
+ # Check if a `cmd` cog ran successfully
1048
+ #
1049
+ # Returns `true` if the `cmd` cog with the given name ran and completed successfully,
1050
+ # `false` otherwise. Use this to check whether a cog ran before attempting to access
1051
+ # its output.
1052
+ #
1053
+ # If `cmd?(name)` returns `true`, then `cmd!(name)` will not raise an exception.
1054
+ # The inverse is also true.
1055
+ #
1056
+ # If the cog is currently running (if configured to run asynchronously), this method will block
1057
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
1058
+ # will return `false` immediately.
1059
+ #
1060
+ # ### Usage
1061
+ # ```ruby
1062
+ # execute do
1063
+ # cmd(:optional_cmd) { "ls -la" }
1064
+ #
1065
+ # ruby do
1066
+ # if cmd?(:optional_cmd)
1067
+ # output = cmd!(:optional_cmd).out
1068
+ # puts "Command completed: #{output}"
1069
+ # else
1070
+ # puts "Command did not run or did not complete successfully"
1071
+ # end
1072
+ # end
1073
+ # end
1074
+ # ```
1075
+ #
1076
+ # #### See Also
1077
+ # - `cmd` - Access the output (returns nil if the cog did not run successfully)
1078
+ # - `cmd!` - Access the output (raises an exception if the cog did not run successfully)
1079
+ #
1080
+ #: (Symbol) -> bool
1081
+ def cmd?(name); end
1082
+
1083
+ # Access the output of a `ruby` cog
1084
+ #
1085
+ # Returns the output of the `ruby` cog with the given name if it ran and completed successfully,
1086
+ # or `nil` otherwise. This method will __not__ raise an exception if the cog did not run,
1087
+ # was skipped, failed, or was stopped. This method __will__ raise an exception if the named cog does not exist.
1088
+ #
1089
+ # If the cog is currently running (if configured to run asynchronously), this method will block
1090
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
1091
+ # will return `nil` immediately.
1092
+ #
1093
+ # ### Usage
1094
+ # ```ruby
1095
+ # execute do
1096
+ # ruby(:optional_ruby) { { sum: 1 + 2 + 3, product: 4 * 5 } }
1097
+ #
1098
+ # ruby do
1099
+ # result = ruby(:optional_ruby)
1100
+ # if result
1101
+ # puts "Computed: #{result.value}"
1102
+ # else
1103
+ # puts "Ruby cog did not run or did not complete successfully"
1104
+ # end
1105
+ # end
1106
+ # end
1107
+ # ```
1108
+ #
1109
+ # #### See Also
1110
+ # - `ruby!` - Access the output (raises an exception if the cog did not run successfully)
1111
+ # - `ruby?` - Check if the cog ran successfully (returns a boolean)
1112
+ #
1113
+ #: (Symbol) -> untyped?
1114
+ def ruby(name); end
1115
+
1116
+ # Access the output of a `ruby` cog
1117
+ #
1118
+ # Returns the output of the `ruby` cog with the given name. Raises an exception if the cog
1119
+ # did not run, was skipped, failed, or was stopped. This is the recommended method for accessing cog outputs
1120
+ # when you expect the cog to have run successfully.
1121
+ #
1122
+ # If the cog is currently running (if configured to run asynchronously), this method will block
1123
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
1124
+ # will return `nil` immediately.
1125
+ #
1126
+ # ### Usage
1127
+ # ```ruby
1128
+ # execute do
1129
+ # ruby(:compute) do
1130
+ # {
1131
+ # sum: 1 + 2 + 3,
1132
+ # product: 4 * 5,
1133
+ # divide: proc { |a, b| a / b }
1134
+ # }
1135
+ # end
1136
+ #
1137
+ # ruby(:transform) do
1138
+ # # Access hash values via dynamic method dispatch
1139
+ # sum = ruby!(:compute).sum
1140
+ # product = ruby!(:compute).product
1141
+ # quotient = ruby!(:compute).divide(15, 3)
1142
+ # "Sum: #{sum}, Product: #{product}, Quotient: #{quotient}"
1143
+ # end
1144
+ #
1145
+ # # Access the raw value
1146
+ # ruby do
1147
+ # data = ruby!(:compute).value
1148
+ # puts "Computed: #{data.inspect}"
1149
+ # end
1150
+ # end
1151
+ # ```
1152
+ #
1153
+ # #### See Also
1154
+ # - `ruby` - Access the output (returns nil if the cog did not run successfully)
1155
+ # - `ruby?` - Check if the cog ran successfully (returns a boolean)
1156
+ #
1157
+ #: (Symbol) -> untyped
1158
+ def ruby!(name); end
1159
+
1160
+ # Check if a `ruby` cog ran successfully
1161
+ #
1162
+ # Returns `true` if the `ruby` cog with the given name ran and completed successfully,
1163
+ # `false` otherwise. Use this to check whether a cog ran before attempting to access
1164
+ # its output.
1165
+ #
1166
+ # If `ruby?(name)` returns `true`, then `ruby!(name)` will not raise an exception.
1167
+ # The inverse is also true.
1168
+ #
1169
+ # If the cog is currently running (if configured to run asynchronously), this method will block
1170
+ # and wait for the cog to complete before returning. If the cog has not yet started, this method
1171
+ # will return `false` immediately.
1172
+ #
1173
+ # ### Usage
1174
+ # ```ruby
1175
+ # execute do
1176
+ # ruby(:optional_ruby) { { sum: 1 + 2 + 3, product: 4 * 5 } }
1177
+ #
1178
+ # ruby do
1179
+ # if ruby?(:optional_ruby)
1180
+ # result = ruby!(:optional_ruby).value
1181
+ # puts "Ruby completed: #{result.inspect}"
1182
+ # else
1183
+ # puts "Ruby cog did not run or did not complete successfully"
1184
+ # end
1185
+ # end
1186
+ # end
1187
+ # ```
1188
+ #
1189
+ # #### See Also
1190
+ # - `ruby` - Access the output (returns nil if the cog did not run successfully)
1191
+ # - `ruby!` - Access the output (raises an exception if the cog did not run successfully)
1192
+ #
1193
+ #: (Symbol) -> bool
1194
+ def ruby?(name); end
15
1195
  end
16
1196
  end
17
1197
  end