riffer-rig 0.19.2 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 236682f64ed1ee5eff4153fb4d50c780cc51dd8a11485783d1354bb8baa686eb
4
- data.tar.gz: 3e18d4be27c46a96dabcaeac08231aacfe711efa4ceafca88d8eacef34ed7305
3
+ metadata.gz: df8d46ca722362add1e17a90bc9cbc7c04a3c630488c1fe8a3246dc8749c6398
4
+ data.tar.gz: 975a9aa14c2e5b49fe6b09f624b646c79cf90f3c1ebd672496f1de5f06c669df
5
5
  SHA512:
6
- metadata.gz: fd6c3a161cbc46fd6cb60402dde7b2f6b21288807f4a602598e9e34597cbd6f9eba4686457fffd28965309b0bb4190200ca07305990884ce6276002f1ef145b4
7
- data.tar.gz: 90af8115b0bf07660f9c31ca16f5d63e8378a70e16348b8efd335f433277993d29be872f74dd288b9731a6d3f8fcc59e35075a387fd407bb61257bd753093b3a
6
+ metadata.gz: 28e7dc1c6d92cf47334d70fa6f8c62b252d4803150fc2484fae13c5e6f82df4fde2f6f925445a490d6741bbb817785c7d2f1f9b8b4e7938830b40c30bc2e133d
7
+ data.tar.gz: ad7bffc1e5f71fa58a387f53c398f0dfd82c076d899f0c53252b5537c5da0141dbfebd04b316dfbf0e76a1ab1fa2ba16ed9e125bb5121b50196c61af1dfa38a0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.20.0](https://github.com/bottrall/riffer-rig/compare/v0.19.2...v0.20.0) (2026-11-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * add an explicit public API document ([#656](https://github.com/bottrall/riffer-rig/issues/656)) ([413f8e3](https://github.com/bottrall/riffer-rig/commit/413f8e3fb9d1b6ff1f1fea1915285e43f78b4623)), closes [#652](https://github.com/bottrall/riffer-rig/issues/652)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * keep a session's system prompt fixed and append context changes ([#661](https://github.com/bottrall/riffer-rig/issues/661)) ([8e81b94](https://github.com/bottrall/riffer-rig/commit/8e81b94e597f9b33856b4436f0144eb0940e1359))
14
+
3
15
  ## [0.19.2](https://github.com/bottrall/riffer-rig/compare/v0.19.1...v0.19.2) (2026-11-15)
4
16
 
5
17
 
data/README.md CHANGED
@@ -36,7 +36,7 @@ Riffer::Rig.extension('git') do |rig|
36
36
  end
37
37
  ```
38
38
 
39
- That adds a `/log` command and puts the current branch in the system prompt on every turn. Extensions can also add tools, hooks, skills, MCP servers, settings and providers — [Extensions](docs/EXTENSIONS.md) starts with a complete tool.
39
+ That adds a `/log` command and puts the current branch in the system prompt, telling the model whenever it changes. Extensions can also add tools, hooks, skills, MCP servers, settings and providers — [Extensions](docs/EXTENSIONS.md) starts with a complete tool.
40
40
 
41
41
  ## Embed it
42
42
 
@@ -57,6 +57,7 @@ The guides are at **<https://riffer.bottrall.dev>**, and their sources are in [`
57
57
  - [Headless mode](docs/HEADLESS.md) — one prompt from a script or CI job, with exit codes and an NDJSON stream
58
58
  - [ACP](docs/ACP.md) — riffer-rig in your editor, with `riffer acp`
59
59
  - [Extensions](docs/EXTENSIONS.md) — your own tools, commands and hooks
60
+ - [Public API](docs/PUBLIC_API.md) — every public constant and method, with its signature
60
61
 
61
62
  ## Contributing
62
63
 
@@ -0,0 +1,744 @@
1
+ # Public API
2
+
3
+ riffer-rig's public API is exactly what this page lists: each constant below, and the methods shown under it. Anything not listed is internal, even when Ruby lets you call it or a signature here names it, and may change or disappear in any release.
4
+
5
+ While riffer-rig is 0.x, a change to anything listed ships in:
6
+
7
+ | Change | Release |
8
+ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9
+ | Breaking change | A minor release, where possible after a release that deprecates it, with its upgrade steps in the [changelog](https://github.com/bottrall/riffer-rig/blob/main/CHANGELOG.md) |
10
+ | New feature | A minor release |
11
+ | Bug fix | A patch release |
12
+
13
+ The signatures are [RBS](https://github.com/ruby/rbs).
14
+
15
+ ## `Riffer::Rig`
16
+
17
+ ```rbs
18
+ module Riffer::Rig
19
+ def self.extension: (String name, ?requires: String?) { (::Riffer::Rig::Registrar) -> void } -> ::Riffer::Rig::Extension
20
+
21
+ def self.credentials: (String | Symbol identifier) -> Hash[Symbol, String]?
22
+
23
+ def self.bundled: (?Symbol? name) -> (::Riffer::Rig::Extension | Array[::Riffer::Rig::Extension])
24
+ end
25
+ ```
26
+
27
+ ## `Riffer::Rig::ACP`
28
+
29
+ ```rbs
30
+ class Riffer::Rig::ACP
31
+ def self.for: (input: IO, output: IO, env: ::Riffer::Rig::Env | ::Riffer::Rig::Env::Invalid, home: String, cwd: String, ?build: (^(String, ::Riffer::Rig::Hosts::_Host, Hash[String, ::Riffer::Rig::Mcp::Declaration]) -> ::Riffer::Rig::Runtime)?, ?adopt: (^(String) -> ::Riffer::Rig::Runtime?)?) -> ::Riffer::Rig::ACP
32
+
33
+ def self.build_runtime: (String cwd, ::Riffer::Rig::Hosts::_Host host, Hash[String, ::Riffer::Rig::Mcp::Declaration] servers, env: ::Riffer::Rig::Env | ::Riffer::Rig::Env::Invalid, home: String) -> ::Riffer::Rig::Runtime
34
+
35
+ def run: () ?{ (::ACP::AgentConnection) -> void } -> Integer
36
+ end
37
+ ```
38
+
39
+ ## `Riffer::Rig::Command`
40
+
41
+ ```rbs
42
+ class Riffer::Rig::Command
43
+ attr_reader name: String
44
+
45
+ attr_reader description: String
46
+ end
47
+ ```
48
+
49
+ ## `Riffer::Rig::Command::Context`
50
+
51
+ ```rbs
52
+ class Riffer::Rig::Command::Context
53
+ attr_reader args: String
54
+
55
+ attr_reader runtime: ::Riffer::Rig::Runtime
56
+
57
+ attr_reader host: ::Riffer::Rig::Hosts::_Host
58
+
59
+ attr_reader settings: Hash[Symbol, untyped]
60
+
61
+ def say: (String text) -> nil
62
+
63
+ def emit: (::Riffer::Rig::Events::_Event event) -> nil
64
+
65
+ def prompt: (String text) -> nil
66
+
67
+ def ask: (?String? question, ?options: Array[String]?, ?secret: bool) -> String?
68
+
69
+ def confirm: (?String? question) -> bool
70
+ end
71
+ ```
72
+
73
+ ## `Riffer::Rig::Command::INVOCATION`
74
+
75
+ ```rbs
76
+ Riffer::Rig::Command::INVOCATION: Regexp
77
+ ```
78
+
79
+ ## `Riffer::Rig::Credentials`
80
+
81
+ ```rbs
82
+ module Riffer::Rig::Credentials
83
+ extend ::Riffer::Rig::Credentials
84
+
85
+ def install: (String | Symbol identifier, host: ::Riffer::Rig::Hosts::_Host, ?setup: ::Riffer::Rig::ProviderSetup, ?env: ::Riffer::Rig::Env, ?config: Riffer::Config?, ?auth_path: String, ?settings_path: String, ?known: Hash[Symbol, String]) -> (::Riffer::Rig::Credentials::Resolution | String)
86
+
87
+ def apply: (String | Symbol identifier, Hash[Symbol, String] values, ?config: Riffer::Config) -> void
88
+
89
+ def store: (String | Symbol identifier, Hash[Symbol, String] values, ?setup: ::Riffer::Rig::ProviderSetup, ?auth_path: String, ?settings_path: String) -> String?
90
+
91
+ def remove: (String | Symbol identifier, ?auth_path: String, ?settings_path: String) -> String?
92
+
93
+ def status: (String | Symbol identifier, ?setup: ::Riffer::Rig::ProviderSetup, ?env: ::Riffer::Rig::Env, ?auth_path: String) -> (:env | :stored | :chain | :missing | String)
94
+ end
95
+ ```
96
+
97
+ ## `Riffer::Rig::Credentials::Resolution`
98
+
99
+ ```rbs
100
+ class Riffer::Rig::Credentials::Resolution
101
+ attr_reader values: Hash[Symbol, String]
102
+
103
+ attr_reader missing: Array[Symbol]
104
+ end
105
+ ```
106
+
107
+ ## `Riffer::Rig::Env`
108
+
109
+ ```rbs
110
+ class Riffer::Rig::Env
111
+ def self.load: (?Hash[String, String] source) -> (::Riffer::Rig::Env | ::Riffer::Rig::Env::Invalid)
112
+
113
+ def initialize: (?Hash[String, String] source) -> void
114
+ end
115
+ ```
116
+
117
+ ## `Riffer::Rig::Env::Invalid`
118
+
119
+ ```rbs
120
+ class Riffer::Rig::Env::Invalid < Data
121
+ end
122
+ ```
123
+
124
+ ## `Riffer::Rig::Events::AfterResponse`
125
+
126
+ ```rbs
127
+ class Riffer::Rig::Events::AfterResponse
128
+ attr_reader message: ::Riffer::Messages::Assistant
129
+
130
+ def type: () -> Symbol
131
+
132
+ def to_h: () -> Hash[Symbol, untyped]
133
+ end
134
+ ```
135
+
136
+ ## `Riffer::Rig::Events::AfterToolCall`
137
+
138
+ ```rbs
139
+ class Riffer::Rig::Events::AfterToolCall
140
+ attr_reader call_id: String
141
+
142
+ attr_reader tool: String
143
+
144
+ attr_reader args: Hash[Symbol, untyped]
145
+
146
+ attr_reader result: ::Riffer::Tools::Response
147
+
148
+ attr_reader at: Float
149
+
150
+ attr_reader duration: Float
151
+
152
+ def type: () -> Symbol
153
+
154
+ def to_h: () -> Hash[Symbol, untyped]
155
+ end
156
+ ```
157
+
158
+ ## `Riffer::Rig::Events::BeforePrompt`
159
+
160
+ ```rbs
161
+ class Riffer::Rig::Events::BeforePrompt
162
+ attr_reader text: String
163
+
164
+ def type: () -> Symbol
165
+
166
+ def to_h: () -> Hash[Symbol, untyped]
167
+ end
168
+ ```
169
+
170
+ ## `Riffer::Rig::Events::BeforeRequest`
171
+
172
+ ```rbs
173
+ class Riffer::Rig::Events::BeforeRequest
174
+ attr_reader messages: Array[::Riffer::Messages::Base]
175
+
176
+ def type: () -> Symbol
177
+
178
+ def to_h: () -> Hash[Symbol, untyped]
179
+ end
180
+ ```
181
+
182
+ ## `Riffer::Rig::Events::BeforeToolCall`
183
+
184
+ ```rbs
185
+ class Riffer::Rig::Events::BeforeToolCall
186
+ attr_reader call_id: String
187
+
188
+ attr_reader tool: String
189
+
190
+ attr_reader args: Hash[Symbol, untyped]
191
+
192
+ attr_reader at: Float
193
+
194
+ def type: () -> Symbol
195
+
196
+ def to_h: () -> Hash[Symbol, untyped]
197
+ end
198
+ ```
199
+
200
+ ## `Riffer::Rig::Events::CommandOutput`
201
+
202
+ ```rbs
203
+ class Riffer::Rig::Events::CommandOutput
204
+ attr_reader command: String
205
+
206
+ attr_reader text: String
207
+
208
+ def type: () -> Symbol
209
+
210
+ def to_h: () -> Hash[Symbol, untyped]
211
+ end
212
+ ```
213
+
214
+ ## `Riffer::Rig::Events::JobExit`
215
+
216
+ ```rbs
217
+ class Riffer::Rig::Events::JobExit
218
+ attr_reader job_id: String
219
+
220
+ attr_reader command: String
221
+
222
+ attr_reader exit_status: Integer?
223
+
224
+ attr_reader signal: String?
225
+
226
+ attr_reader duration: Float
227
+
228
+ attr_reader output_path: String
229
+
230
+ def type: () -> Symbol
231
+
232
+ def to_h: () -> Hash[Symbol, untyped]
233
+ end
234
+ ```
235
+
236
+ ## `Riffer::Rig::Events::Notify`
237
+
238
+ ```rbs
239
+ class Riffer::Rig::Events::Notify
240
+ attr_reader message: String?
241
+
242
+ attr_reader level: Symbol
243
+
244
+ def type: () -> Symbol
245
+
246
+ def to_h: () -> Hash[Symbol, untyped]
247
+ end
248
+ ```
249
+
250
+ ## `Riffer::Rig::Events::SessionEnd`
251
+
252
+ ```rbs
253
+ class Riffer::Rig::Events::SessionEnd
254
+ attr_reader reason: Symbol
255
+
256
+ def type: () -> Symbol
257
+
258
+ def to_h: () -> Hash[Symbol, untyped]
259
+ end
260
+ ```
261
+
262
+ ## `Riffer::Rig::Events::SessionStart`
263
+
264
+ ```rbs
265
+ class Riffer::Rig::Events::SessionStart
266
+ attr_reader id: String
267
+
268
+ attr_reader reason: Symbol
269
+
270
+ def type: () -> Symbol
271
+
272
+ def to_h: () -> Hash[Symbol, untyped]
273
+ end
274
+ ```
275
+
276
+ ## `Riffer::Rig::Events::SkillActivated`
277
+
278
+ ```rbs
279
+ class Riffer::Rig::Events::SkillActivated
280
+ attr_reader name: String
281
+
282
+ def type: () -> Symbol
283
+
284
+ def to_h: () -> Hash[Symbol, untyped]
285
+ end
286
+ ```
287
+
288
+ ## `Riffer::Rig::Events::TurnEnd`
289
+
290
+ ```rbs
291
+ class Riffer::Rig::Events::TurnEnd
292
+ attr_reader stop_reason: Symbol
293
+
294
+ attr_reader usage: ::Riffer::Providers::TokenUsage?
295
+
296
+ def cost: () -> Float?
297
+
298
+ def type: () -> Symbol
299
+
300
+ def to_h: () -> Hash[Symbol, untyped]
301
+ end
302
+ ```
303
+
304
+ ## `Riffer::Rig::Events::_Event`
305
+
306
+ ```rbs
307
+ interface Riffer::Rig::Events::_Event
308
+ def class: () -> ::Class
309
+
310
+ def type: () -> Symbol
311
+
312
+ def to_h: () -> Hash[Symbol, untyped]
313
+ end
314
+ ```
315
+
316
+ ## `Riffer::Rig::Extension`
317
+
318
+ ```rbs
319
+ class Riffer::Rig::Extension
320
+ attr_reader name: String
321
+ end
322
+ ```
323
+
324
+ ## `Riffer::Rig::Extension::Failure`
325
+
326
+ ```rbs
327
+ class Riffer::Rig::Extension::Failure < Data
328
+ attr_reader extension(): ::Riffer::Rig::Extension
329
+
330
+ attr_reader error(): StandardError
331
+
332
+ def self.new: (::Riffer::Rig::Extension extension, StandardError error) -> instance
333
+ | (extension: ::Riffer::Rig::Extension, error: StandardError) -> instance
334
+
335
+ def self.members: () -> [ :extension, :error ]
336
+
337
+ def members: () -> [ :extension, :error ]
338
+ end
339
+ ```
340
+
341
+ ## `Riffer::Rig::Hosts::Mirror`
342
+
343
+ ```rbs
344
+ class Riffer::Rig::Hosts::Mirror
345
+ attr_reader host: ::Riffer::Rig::Hosts::_Host
346
+
347
+ def capabilities: () -> Set[Symbol]
348
+
349
+ def ask: (?String? question, ?options: Array[String]?, ?secret: bool) -> String?
350
+
351
+ def confirm: (?String? question) -> bool?
352
+
353
+ def notify: (?String? message, ?level: Symbol) -> void
354
+
355
+ def progress: (?String? label) ?{ () -> void } -> void
356
+ end
357
+ ```
358
+
359
+ ## `Riffer::Rig::Hosts::NonInteractive`
360
+
361
+ ```rbs
362
+ module Riffer::Rig::Hosts::NonInteractive
363
+ def ask: (?String? question, ?options: Array[String]?, ?secret: bool) -> String?
364
+
365
+ def confirm: (?String? question) -> bool
366
+
367
+ def progress: (?String? label) ?{ () -> void } -> void
368
+ end
369
+ ```
370
+
371
+ ## `Riffer::Rig::Hosts::Null`
372
+
373
+ ```rbs
374
+ class Riffer::Rig::Hosts::Null
375
+ include ::Riffer::Rig::Hosts::NonInteractive
376
+
377
+ def capabilities: () -> Set[Symbol]
378
+
379
+ def notify: (?String? message, ?level: Symbol) -> void
380
+ end
381
+ ```
382
+
383
+ ## `Riffer::Rig::Hosts::_Host`
384
+
385
+ ```rbs
386
+ interface Riffer::Rig::Hosts::_Host
387
+ def capabilities: () -> Set[Symbol]
388
+
389
+ def ask: (?String?, ?options: Array[String]?, ?secret: bool) -> String?
390
+
391
+ def confirm: (?String?) -> bool?
392
+
393
+ def notify: (?String?, ?level: Symbol) -> void
394
+
395
+ def progress: (?String?) ?{ () -> void } -> void
396
+ end
397
+ ```
398
+
399
+ ## `Riffer::Rig::Loader`
400
+
401
+ ```rbs
402
+ class Riffer::Rig::Loader
403
+ def self.runtime: (cwd: String, host: ::Riffer::Rig::Hosts::_Host, ?env: ::Riffer::Rig::Env | ::Riffer::Rig::Env::Invalid, ?home: String, ?riffer_config: Riffer::Config, ?store: ::Riffer::Rig::Stores::_Store | nil, ?options: ::Riffer::Rig::Loader::Options, ?reload: :auto | :manual | nil, ?extra_extensions: Array[::Riffer::Rig::Extension], ?snapshot: (::Riffer::Rig::Runtime::Snapshot | Hash[Symbol, untyped])?) -> ::Riffer::Rig::Runtime
404
+
405
+ def initialize: (cwd: String, host: ::Riffer::Rig::Hosts::_Host, ?env: ::Riffer::Rig::Env | ::Riffer::Rig::Env::Invalid, ?home: String, ?riffer_config: Riffer::Config, ?store: ::Riffer::Rig::Stores::_Store | nil, ?sdk: singleton(::Riffer::Rig::SDK)) -> void
406
+
407
+ def runtime: (?::Riffer::Rig::Loader::Options options, ?reload: :auto | :manual | nil, ?extra_extensions: Array[::Riffer::Rig::Extension], ?snapshot: (::Riffer::Rig::Runtime::Snapshot | Hash[Symbol, untyped])?) -> ::Riffer::Rig::Runtime
408
+
409
+ def continue: (?::Riffer::Rig::Loader::Options options) -> ::Riffer::Rig::Runtime?
410
+
411
+ def resume: (String id, ?::Riffer::Rig::Loader::Options options, ?extra_extensions: Array[::Riffer::Rig::Extension]) -> ::Riffer::Rig::Runtime?
412
+
413
+ def list: (?all: bool) -> Array[::Riffer::Rig::Stores::Header]
414
+
415
+ def delete: (String id) -> void
416
+
417
+ def reload: (::Riffer::Rig::Runtime runtime, ?force: bool) -> (::Riffer::Rig::Runtime | String)
418
+ end
419
+ ```
420
+
421
+ ## `Riffer::Rig::Loader::ConfigurationError`
422
+
423
+ ```rbs
424
+ class Riffer::Rig::Loader::ConfigurationError < StandardError
425
+ end
426
+ ```
427
+
428
+ ## `Riffer::Rig::Loader::Options`
429
+
430
+ ```rbs
431
+ class Riffer::Rig::Loader::Options
432
+ attr_reader model: String?
433
+
434
+ attr_reader reasoning: String?
435
+
436
+ attr_reader extensions: bool
437
+
438
+ attr_reader skills: bool
439
+
440
+ attr_reader agents_md: bool
441
+
442
+ attr_reader tools: Array[String]?
443
+
444
+ attr_reader max_steps: Integer?
445
+
446
+ def initialize: (?model: String?, ?reasoning: String?, ?extensions: bool, ?skills: bool, ?agents_md: bool, ?tools: Array[String]?, ?max_steps: Integer?) -> void
447
+ end
448
+ ```
449
+
450
+ ## `Riffer::Rig::Registrar`
451
+
452
+ ```rbs
453
+ class Riffer::Rig::Registrar
454
+ def tool: (singleton(Riffer::Tool) klass) -> void
455
+
456
+ def prompt: (Symbol name) { (::Riffer::Rig::Runtime) -> String? } -> void
457
+
458
+ def command: (String name, description: String) { (::Riffer::Rig::Command::Context) -> void } -> void
459
+
460
+ def skills: () { (::Riffer::Rig::Runtime) -> Riffer::Skills::Backend } -> void
461
+
462
+ def setting: (Symbol key, default: untyped) -> void
463
+
464
+ def mcp: (String name, ?url: String?, ?headers: Hash[String, String], ?auth: Hash[Symbol, String | Array[String]], ?command: String?, ?args: Array[String], ?env: Hash[String, String]) -> void
465
+
466
+ def provider: (String | Symbol prefix, ?setup: ::Riffer::Rig::ProviderSetup | Hash[Symbol, untyped]?) { () -> singleton(::Riffer::Providers::Base) } -> void
467
+
468
+ def on: (Symbol event) { (::Riffer::Rig::Events::_Event | ::Riffer::StreamEvents::Base) -> untyped } -> void
469
+
470
+ def settings: () -> Hash[Symbol, untyped]
471
+ end
472
+ ```
473
+
474
+ ## `Riffer::Rig::Runtime`
475
+
476
+ ```rbs
477
+ class Riffer::Rig::Runtime
478
+ attr_reader cwd: String
479
+
480
+ attr_reader host: ::Riffer::Rig::Hosts::Mirror
481
+
482
+ attr_reader id: String
483
+
484
+ def initialize: (String model, ?extensions: Array[::Riffer::Rig::Extension], ?tools: Array[String]?, ?settings: Hash[Symbol, untyped], ?host: ::Riffer::Rig::Hosts::_Host, ?cwd: String?, ?name: String, ?instructions: String?, ?credentials: Hash[Symbol, Hash[Symbol, String]], ?env: ::Riffer::Rig::Env, ?auth_path: String, ?settings_path: String, ?reasoning: String?, ?riffer_config: Riffer::Config, ?mcp_registry: ::Riffer::Rig::Mcp::_Registry, ?max_steps: Integer?, ?model_options: Hash[Symbol, untyped], ?native_tools: Hash[Symbol, untyped], ?max_tokens: Integer?, ?clock: ^() -> Float, ?snapshot: (::Riffer::Rig::Runtime::Snapshot | Hash[Symbol, untyped])?) -> void
485
+
486
+ def prompt: (String text) ?{ (::Riffer::StreamEvents::Base | ::Riffer::Rig::Events::_Event) -> void } -> (nil | Enumerator[::Riffer::StreamEvents::Base | ::Riffer::Rig::Events::_Event, Riffer::Agent::Response])
487
+
488
+ def follow_up: () ?{ (::Riffer::StreamEvents::Base | ::Riffer::Rig::Events::_Event) -> void } -> (nil | Enumerator[::Riffer::StreamEvents::Base | ::Riffer::Rig::Events::_Event, Riffer::Agent::Response])
489
+
490
+ def ask: (String text) -> Riffer::Agent::Response
491
+
492
+ def commands: () -> Array[::Riffer::Rig::Command]
493
+
494
+ def run_command: (String name, ?String args) ?{ (::Riffer::StreamEvents::Base | ::Riffer::Rig::Events::_Event) -> void } -> nil
495
+
496
+ def errors: () -> Array[::Riffer::Rig::Extension::Failure]
497
+
498
+ def settings: () -> Hash[Symbol, untyped]
499
+
500
+ def declared_settings: () -> Hash[Symbol, Hash[Symbol, untyped]]
501
+
502
+ def model=: (String model) -> void
503
+
504
+ def reasoning=: (String level) -> void
505
+
506
+ def rebuild: (extensions: Array[::Riffer::Rig::Extension], settings: Hash[Symbol, untyped]) -> nil
507
+
508
+ def to_h: () -> Hash[Symbol, untyped]
509
+
510
+ def on_message: () { (Riffer::Messages::Base) -> void } -> nil
511
+
512
+ def on_job_exit: () { (::Riffer::Rig::Runtime::JobCompletion) -> void } -> nil
513
+
514
+ def running_job_count: () -> Integer
515
+
516
+ def busy?: () -> bool
517
+
518
+ def pending_jobs?: () -> bool
519
+
520
+ def await_job_exit: (?timeout: Numeric?) -> bool
521
+
522
+ def pending_job_exit_count: () -> Integer
523
+
524
+ def cancel: () -> nil
525
+
526
+ def tally: () -> Riffer::Providers::TokenUsage?
527
+
528
+ def close: () -> void
529
+ end
530
+ ```
531
+
532
+ ## `Riffer::Rig::Runtime::BusyError`
533
+
534
+ ```rbs
535
+ class Riffer::Rig::Runtime::BusyError < StandardError
536
+ end
537
+ ```
538
+
539
+ ## `Riffer::Rig::Runtime::CancelFlag`
540
+
541
+ ```rbs
542
+ class Riffer::Rig::Runtime::CancelFlag
543
+ def set?: () -> bool
544
+ end
545
+ ```
546
+
547
+ ## `Riffer::Rig::Runtime::ContextUpdate`
548
+
549
+ ```rbs
550
+ class Riffer::Rig::Runtime::ContextUpdate < Riffer::Messages::User
551
+ attr_reader sections: Hash[Symbol, String?]
552
+
553
+ def to_h: () -> Hash[Symbol, untyped]
554
+ end
555
+ ```
556
+
557
+ ## `Riffer::Rig::Runtime::ErrorMessage`
558
+
559
+ ```rbs
560
+ module Riffer::Rig::Runtime::ErrorMessage
561
+ extend ::Riffer::Rig::Runtime::ErrorMessage
562
+
563
+ def of: (StandardError error) -> String
564
+ end
565
+ ```
566
+
567
+ ## `Riffer::Rig::Runtime::Job`
568
+
569
+ ```rbs
570
+ class Riffer::Rig::Runtime::Job
571
+ attr_reader id: String
572
+
573
+ attr_reader output_path: String
574
+ end
575
+ ```
576
+
577
+ ## `Riffer::Rig::Runtime::JobCompletion`
578
+
579
+ ```rbs
580
+ class Riffer::Rig::Runtime::JobCompletion < Data
581
+ attr_reader job_id(): String
582
+
583
+ attr_reader command(): String
584
+
585
+ attr_reader exit_status(): Integer?
586
+
587
+ attr_reader signal(): String?
588
+
589
+ attr_reader duration(): Float
590
+
591
+ attr_reader output_path(): String
592
+
593
+ attr_reader tail(): String
594
+
595
+ def self.new: (String job_id, String command, Integer? exit_status, String? signal, Float duration, String output_path, String tail) -> instance
596
+ | (job_id: String, command: String, exit_status: Integer?, signal: String?, duration: Float, output_path: String, tail: String) -> instance
597
+
598
+ def self.members: () -> [ :job_id, :command, :exit_status, :signal, :duration, :output_path, :tail ]
599
+
600
+ def members: () -> [ :job_id, :command, :exit_status, :signal, :duration, :output_path, :tail ]
601
+ end
602
+ ```
603
+
604
+ ## `Riffer::Rig::Runtime::JobNotification`
605
+
606
+ ```rbs
607
+ class Riffer::Rig::Runtime::JobNotification < Riffer::Messages::User
608
+ attr_reader follow_up_exits: Integer?
609
+
610
+ def to_h: () -> Hash[Symbol, untyped]
611
+ end
612
+ ```
613
+
614
+ ## `Riffer::Rig::Runtime::Jobs`
615
+
616
+ ```rbs
617
+ class Riffer::Rig::Runtime::Jobs
618
+ def register: (Integer pid, String command, IO output) -> ::Riffer::Rig::Runtime::Job
619
+ end
620
+ ```
621
+
622
+ ## `Riffer::Rig::Stores::Header`
623
+
624
+ ```rbs
625
+ class Riffer::Rig::Stores::Header
626
+ attr_reader schema_version: Integer
627
+
628
+ attr_reader id: String
629
+
630
+ attr_reader cwd: String
631
+
632
+ attr_reader created_at: String
633
+
634
+ attr_reader model: String
635
+
636
+ attr_reader riffer_rig_version: String
637
+
638
+ attr_reader riffer_version: String
639
+
640
+ attr_reader title: String
641
+
642
+ attr_reader updated: Time?
643
+
644
+ def initialize: (schema_version: Integer, id: String, cwd: String, created_at: String, model: String, riffer_rig_version: String, riffer_version: String, title: String, ?updated: Time?) -> void
645
+ end
646
+ ```
647
+
648
+ ## `Riffer::Rig::Stores::JSONL`
649
+
650
+ ```rbs
651
+ class Riffer::Rig::Stores::JSONL
652
+ def initialize: (?home: String) -> void
653
+
654
+ def append: (String id, ::Riffer::Rig::Stores::entry entry) -> void
655
+
656
+ def read: (String id) -> Array[::Riffer::Rig::Stores::entry]
657
+
658
+ def list: (?cwd: String?) -> Array[::Riffer::Rig::Stores::Header]
659
+
660
+ def delete: (String id) -> void
661
+ end
662
+ ```
663
+
664
+ ## `Riffer::Rig::Stores::MessageEntry`
665
+
666
+ ```rbs
667
+ class Riffer::Rig::Stores::MessageEntry
668
+ attr_reader message: Hash[Symbol, untyped]
669
+
670
+ attr_reader recorded_at: String?
671
+
672
+ def initialize: (message: Hash[Symbol, untyped], ?recorded_at: String?) -> void
673
+
674
+ def recorded_time: () -> Time?
675
+ end
676
+ ```
677
+
678
+ ## `Riffer::Rig::Stores::ModelEntry`
679
+
680
+ ```rbs
681
+ class Riffer::Rig::Stores::ModelEntry
682
+ attr_reader model: String
683
+
684
+ attr_reader recorded_at: String?
685
+
686
+ def initialize: (model: String, ?recorded_at: String?) -> void
687
+
688
+ def recorded_time: () -> Time?
689
+ end
690
+ ```
691
+
692
+ ## `Riffer::Rig::Stores::ReasoningEntry`
693
+
694
+ ```rbs
695
+ class Riffer::Rig::Stores::ReasoningEntry
696
+ attr_reader reasoning: String
697
+
698
+ attr_reader recorded_at: String?
699
+
700
+ def initialize: (reasoning: String, ?recorded_at: String?) -> void
701
+
702
+ def recorded_time: () -> Time?
703
+ end
704
+ ```
705
+
706
+ ## `Riffer::Rig::Stores::SkillEntry`
707
+
708
+ ```rbs
709
+ class Riffer::Rig::Stores::SkillEntry
710
+ attr_reader skill: String
711
+
712
+ attr_reader recorded_at: String?
713
+
714
+ def initialize: (skill: String, ?recorded_at: String?) -> void
715
+
716
+ def recorded_time: () -> Time?
717
+ end
718
+ ```
719
+
720
+ ## `Riffer::Rig::Stores::_Store`
721
+
722
+ ```rbs
723
+ interface Riffer::Rig::Stores::_Store
724
+ def append: (String id, ::Riffer::Rig::Stores::entry entry) -> void
725
+
726
+ def read: (String id) -> Array[::Riffer::Rig::Stores::entry]
727
+
728
+ def list: (?cwd: String?) -> Array[::Riffer::Rig::Stores::Header]
729
+
730
+ def delete: (String id) -> void
731
+ end
732
+ ```
733
+
734
+ ## `Riffer::Rig::Stores::entry`
735
+
736
+ ```rbs
737
+ type Riffer::Rig::Stores::entry = ::Riffer::Rig::Stores::Header | ::Riffer::Rig::Stores::MessageEntry | ::Riffer::Rig::Stores::ModelEntry | ::Riffer::Rig::Stores::ReasoningEntry | ::Riffer::Rig::Stores::SkillEntry
738
+ ```
739
+
740
+ ## `Riffer::Rig::VERSION`
741
+
742
+ ```rbs
743
+ Riffer::Rig::VERSION: ::String
744
+ ```
@@ -69,6 +69,7 @@ module Riffer::Rig::ACP::Mapper
69
69
  # @rbs message: Hash[Symbol, untyped]
70
70
  # @rbs return: ::ACP::Types::SessionUpdate::t?
71
71
  def replay_of(message)
72
+ return if message[Riffer::Rig::Runtime::ContextUpdate::MARKER]
72
73
  return job_exit if message[Riffer::Rig::Runtime::JobNotification::MARKER]
73
74
 
74
75
  case message[:role]
@@ -58,6 +58,8 @@ module Riffer::Rig::Commands::Trace::Replay
58
58
  [line(time, 'finish', message.error? ? "#{message.name} (#{message.error_type})" : message.name)]
59
59
  when Riffer::Rig::Runtime::JobNotification
60
60
  [line(time, 'notice', first_line(message.content))]
61
+ when Riffer::Rig::Runtime::ContextUpdate, Riffer::Messages::System
62
+ []
61
63
  else
62
64
  [line(time, 'prompt', first_line(message.content))]
63
65
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Riffer::Rig::Runtime::ContextUpdate < Riffer::Messages::User
4
+ MARKER = :context_update #: Symbol
5
+
6
+ PREAMBLE = 'Your context changed since you last saw it. Each section below replaces its earlier version ' \
7
+ 'in full; a section marked removed no longer applies.'
8
+
9
+ # @dynamic sections
10
+ attr_reader :sections #: Hash[Symbol, String?]
11
+
12
+ # @rbs changes: Hash[Symbol, String?]
13
+ # @rbs return: Riffer::Rig::Runtime::ContextUpdate
14
+ def self.of(changes)
15
+ blocks = changes.map do |name, text|
16
+ text ? Riffer::Rig::Runtime::SystemPrompt.section(name, text) : %(<section name="#{name}" removed="true"/>)
17
+ end
18
+ new(["<context-update>\n#{PREAMBLE}", *blocks, '</context-update>'].join("\n\n"), sections: changes)
19
+ end
20
+
21
+ # @rbs hash: Hash[Symbol, untyped]
22
+ # @rbs return: Riffer::Rig::Runtime::ContextUpdate
23
+ def self.from_hash(hash)
24
+ new(hash[:content], id: hash[:id], sections: hash.fetch(:sections))
25
+ end
26
+
27
+ # @rbs content: String
28
+ # @rbs id: String?
29
+ # @rbs files: Array[Riffer::Messages::User::FilePart]
30
+ # @rbs sections: Hash[Symbol, String?]
31
+ # @rbs return: void
32
+ def initialize(content, id: nil, files: [], sections: {})
33
+ # riffer's User#+ rebuilds a message of the same class with its files.
34
+ super(content, id: id, files: files)
35
+ @sections = sections
36
+ end
37
+
38
+ # @rbs return: Hash[Symbol, untyped]
39
+ def to_h
40
+ super.merge(MARKER => true, sections: sections)
41
+ end
42
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Riffer::Rig::Runtime::Head
4
+ extend self
5
+
6
+ # @rbs messages: Array[Riffer::Messages::Base]
7
+ # @rbs return: Hash[Symbol, String]?
8
+ def sections(messages)
9
+ head = messages.first
10
+ return unless head.is_a?(Riffer::Messages::System)
11
+
12
+ sections = Riffer::Rig::Runtime::SystemPrompt.sections(head.content)
13
+ # Rig renders the environment into every head it opens; a system message
14
+ # without one is riffer's skills catalog or an older version's prompt.
15
+ sections if sections.key?(Riffer::Rig::Runtime::SystemPrompt::ENVIRONMENT)
16
+ end
17
+
18
+ # @rbs messages: Array[Riffer::Messages::Base]
19
+ # @rbs return: Hash[Symbol, String]?
20
+ def seen(messages)
21
+ opened = sections(messages)
22
+ return unless opened
23
+
24
+ updates = messages.grep(Riffer::Rig::Runtime::ContextUpdate) #: Array[Riffer::Rig::Runtime::ContextUpdate]
25
+ updates.reduce(opened) { |folded, update| folded.merge(update.sections).compact }
26
+ end
27
+
28
+ # @rbs seen: Hash[Symbol, String]
29
+ # @rbs current: Hash[Symbol, String]
30
+ # @rbs return: Hash[Symbol, String?]
31
+ def changes(seen, current)
32
+ (seen.keys | current.keys).reject { |name| seen[name] == current[name] }.to_h { |name| [name, current[name]] }
33
+ end
34
+ end
@@ -19,12 +19,16 @@ class Riffer::Rig::Runtime::Snapshot
19
19
  # @rbs hash: Hash[Symbol, untyped]
20
20
  # @rbs return: Riffer::Rig::Runtime::Snapshot
21
21
  def self.from_h(hash)
22
+ saved = hash.fetch(:messages) #: Array[Hash[Symbol, untyped]]
23
+ # Reasoning is signed under the head it was produced with, which a
24
+ # snapshot without an opened head no longer holds.
25
+ signed = Riffer::Rig::Runtime::Head.sections(saved.take(1).map { |head| message(head) })
22
26
  new(
23
27
  id: hash.fetch(:id),
24
28
  # Upstream candidate: riffer's Serializer carries an agent's config, never
25
29
  # its history, so this and to_h round-trip the session message by message;
26
30
  # a Session.from_h could also heal orphaned tool calls on load.
27
- messages: hash.fetch(:messages).map { |stored| message(stored) },
31
+ messages: saved.map { |stored| message(signed ? stored : stored.except(:reasoning)) },
28
32
  model: hash.fetch(:model),
29
33
  reasoning: hash[:reasoning].is_a?(String) ? hash[:reasoning] : nil,
30
34
  skills: hash.fetch(:skills)
@@ -37,6 +41,7 @@ class Riffer::Rig::Runtime::Snapshot
37
41
  # riffer rebuilds a message from its role alone, which would bring a job
38
42
  # notification back as typed input.
39
43
  return Riffer::Rig::Runtime::JobNotification.from_hash(hash) if hash[Riffer::Rig::Runtime::JobNotification::MARKER]
44
+ return Riffer::Rig::Runtime::ContextUpdate.from_hash(hash) if hash[Riffer::Rig::Runtime::ContextUpdate::MARKER]
40
45
 
41
46
  Riffer::Messages::Base.from_hash(hash)
42
47
  end
@@ -3,10 +3,28 @@
3
3
  require 'date'
4
4
 
5
5
  class Riffer::Rig::Runtime::SystemPrompt
6
+ ENVIRONMENT = :environment #: Symbol
7
+
8
+ SECTION = %r{^<section name="([^"]+)">\n(.*?)\n</section>$}m #: Regexp
9
+
6
10
  # @rbs @base: String
7
11
  # @rbs @cwd: String
8
12
  # @rbs @sections: Hash[Symbol, ^(Riffer::Rig::Runtime) -> String?]
9
13
 
14
+ # @rbs name: Symbol
15
+ # @rbs text: String
16
+ # @rbs return: String
17
+ def self.section(name, text)
18
+ %(<section name="#{name}">\n#{text}\n</section>)
19
+ end
20
+
21
+ # @rbs rendered: String
22
+ # @rbs return: Hash[Symbol, String]
23
+ def self.sections(rendered)
24
+ matches = rendered.scan(SECTION) #: Array[[String, String]]
25
+ matches.to_h { |name, text| [name.to_sym, text] }
26
+ end
27
+
10
28
  # @rbs base: String
11
29
  # @rbs cwd: String
12
30
  # @rbs sections: Hash[Symbol, ^(Riffer::Rig::Runtime) -> String?]
@@ -24,33 +42,23 @@ class Riffer::Rig::Runtime::SystemPrompt
24
42
  self.class.new(@base, @cwd, sections)
25
43
  end
26
44
 
27
- # @rbs return: String
28
- def bare
29
- compose([])
30
- end
31
-
32
45
  # @rbs runtime: Riffer::Rig::Runtime
33
- # @rbs return: String
34
- def render(runtime)
35
- compose(@sections.each_value.map { |section| section.call(runtime).to_s }.reject(&:empty?))
46
+ # @rbs return: Hash[Symbol, String]
47
+ def values(runtime)
48
+ rendered = @sections.transform_values { |section| section.call(runtime).to_s }.reject { |_name, text| text.empty? }
49
+ rendered.merge(ENVIRONMENT => environment)
36
50
  end
37
51
 
38
- # @rbs session: Riffer::Agent::Session
39
- # @rbs runtime: Riffer::Rig::Runtime
40
- # @rbs return: void
41
- def refresh(session, runtime)
42
- # Upstream candidate: riffer resolves `instructions` once, in Agent.new, so
43
- # a per-turn system message has to be swapped into the session by hand.
44
- history = session.messages
45
- kept = history.first.is_a?(Riffer::Messages::System) ? history.drop(1) : history
46
- session.set([Riffer::Messages::System.new(render(runtime)), *kept])
52
+ # @rbs values: Hash[Symbol, String]
53
+ # @rbs return: String
54
+ def render(values)
55
+ [@base, *values.map { |name, text| self.class.section(name, text) }].join("\n\n")
47
56
  end
48
57
 
49
58
  private
50
59
 
51
- # @rbs sections: Array[String]
52
60
  # @rbs return: String
53
- def compose(sections)
54
- [@base, *sections, "Current date: #{Date.today}\nCurrent working directory: #{@cwd}"].join("\n\n")
61
+ def environment
62
+ "Current date: #{Date.today}\nCurrent working directory: #{@cwd}"
55
63
  end
56
64
  end
@@ -464,7 +464,6 @@ class Riffer::Rig::Runtime
464
464
  config = Riffer::Agent::Config.new(
465
465
  model: ->(context) { context[:model] },
466
466
  model_options: @model_options,
467
- instructions: @system_prompt.bare,
468
467
  reasoning: reasoning_over(assembly.settings),
469
468
  tools_config: assembly.tools,
470
469
  max_steps: max_steps,
@@ -560,7 +559,30 @@ class Riffer::Rig::Runtime
560
559
  def open_turn
561
560
  @cancel_flag.clear
562
561
  @reload_check&.call(self)
563
- @system_prompt.refresh(@agent.session, self)
562
+ values = @system_prompt.values(self)
563
+ seen = Riffer::Rig::Runtime::Head.seen(@agent.session.messages)
564
+ # Providers bind signed reasoning to everything before it, system messages
565
+ # included, so the head a session opens with is never rewritten.
566
+ seen ? update_context(Riffer::Rig::Runtime::Head.changes(seen, values)) : open_head(values)
567
+ end
568
+
569
+ # @rbs values: Hash[Symbol, String]
570
+ # @rbs return: void
571
+ def open_head(values)
572
+ system = [Riffer::Messages::System.new(@system_prompt.render(values)), @agent.skills_message].compact
573
+ conversation = @agent.session.messages.drop_while { |message| message.is_a?(Riffer::Messages::System) }
574
+ @agent.session.set([*system, *conversation])
575
+ system.each { |message| deliver(message) }
576
+ end
577
+
578
+ # @rbs changes: Hash[Symbol, String?]
579
+ # @rbs return: void
580
+ def update_context(changes)
581
+ return if changes.empty?
582
+
583
+ # Silent, then delivered by hand: the on_message observer interrupts a
584
+ # cancelled turn with a throw, and no riffer run is there to catch it.
585
+ deliver(@agent.session.add(Riffer::Rig::Runtime::ContextUpdate.of(changes), silent: true))
564
586
  end
565
587
 
566
588
  # @rbs outcome: Riffer::Agent::Outcome
@@ -15,7 +15,7 @@ module Riffer::Rig::Stores::Entries
15
15
  def snapshot(entries, id)
16
16
  Riffer::Rig::Runtime::Snapshot.new(
17
17
  id: id,
18
- messages: messages(entries).map { |message| Riffer::Rig::Runtime::Snapshot.message(message) },
18
+ messages: replayed(entries),
19
19
  model: entries.filter_map { |entry| entry.model if entry.is_a?(Riffer::Rig::Stores::ModelEntry) }.last,
20
20
  reasoning: entries.filter_map do |entry|
21
21
  entry.reasoning if entry.is_a?(Riffer::Rig::Stores::ReasoningEntry)
@@ -23,4 +23,22 @@ module Riffer::Rig::Stores::Entries
23
23
  skills: entries.filter_map { |entry| entry.skill if entry.is_a?(Riffer::Rig::Stores::SkillEntry) }
24
24
  )
25
25
  end
26
+
27
+ private
28
+
29
+ # @rbs entries: Array[Riffer::Rig::Stores::entry]
30
+ # @rbs return: Array[Riffer::Messages::Base]
31
+ def replayed(entries)
32
+ recorded = entries.grep(Riffer::Rig::Stores::MessageEntry) #: Array[Riffer::Rig::Stores::MessageEntry]
33
+ # A session saved before rig recorded its head records one on resume, after
34
+ # the messages produced under an earlier head: their reasoning, signed
35
+ # under that head, is dropped, and the head moves back to the front.
36
+ opened_at = recorded.index { |entry| entry.message[:role].to_s == 'system' }
37
+ messages = recorded.each_with_index.map do |entry, index|
38
+ signed = opened_at && index > opened_at
39
+ Riffer::Rig::Runtime::Snapshot.message(signed ? entry.message : entry.message.except(:reasoning))
40
+ end
41
+ system, conversation = messages.partition { |message| message.is_a?(Riffer::Messages::System) }
42
+ [*system, *conversation]
43
+ end
26
44
  end
@@ -46,9 +46,9 @@ class Riffer::Rig::Stores::Recorder
46
46
  # @rbs message: Riffer::Messages::Base
47
47
  # @rbs return: void
48
48
  def message(message)
49
- # A job notification is no prompt to title the session from, so it waits
50
- # for the header like any other entry that lands before one.
51
- write_header(message) unless @header_written || message.is_a?(Riffer::Rig::Runtime::JobNotification)
49
+ # A harness message is no prompt to title the session from, so it waits for
50
+ # the header like any other entry that lands before one.
51
+ write_header(message) unless @header_written || harness?(message)
52
52
  record(Riffer::Rig::Stores::MessageEntry.new(message: message.to_h, recorded_at: stamp))
53
53
  end
54
54
 
@@ -81,6 +81,13 @@ class Riffer::Rig::Stores::Recorder
81
81
 
82
82
  private
83
83
 
84
+ # @rbs message: Riffer::Messages::Base
85
+ # @rbs return: bool
86
+ def harness?(message)
87
+ message.is_a?(Riffer::Messages::System) || message.is_a?(Riffer::Rig::Runtime::JobNotification) ||
88
+ message.is_a?(Riffer::Rig::Runtime::ContextUpdate)
89
+ end
90
+
84
91
  # @rbs entry: Riffer::Rig::Stores::entry
85
92
  # @rbs return: void
86
93
  def record(entry)
@@ -17,10 +17,13 @@ module Riffer::Rig::Terminal::Replay
17
17
  # @rbs width: Integer?
18
18
  # @rbs return: String
19
19
  def call(recorded, theme:, width:)
20
- # A notification without a follow-up count was delivered within the turn
21
- # of a prompt, so it opens no turn of its own.
20
+ # A system message, a context update, and a notification without a
21
+ # follow-up count are delivered within the turn of a prompt, so they open no
22
+ # turn of their own.
22
23
  kept = recorded.reject do |entry|
23
- entry.message[Riffer::Rig::Runtime::JobNotification::MARKER] && !entry.message[:follow_up_exits]
24
+ message = entry.message
25
+ message[:role].to_s == 'system' || message[Riffer::Rig::Runtime::ContextUpdate::MARKER] ||
26
+ (message[Riffer::Rig::Runtime::JobNotification::MARKER] && !message[:follow_up_exits])
24
27
  end
25
28
  turns = kept.slice_before { |entry| entry.message[:role].to_s == 'user' }.map { |chunk| turn(chunk, theme, width) }
26
29
  replayed = turns.compact.map do |past|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Riffer
4
4
  module Rig
5
- VERSION = '0.19.2'
5
+ VERSION = '0.20.0'
6
6
  end
7
7
  end
@@ -0,0 +1,28 @@
1
+ # Generated from lib/riffer/rig/runtime/context_update.rb with RBS::Inline
2
+
3
+ class Riffer::Rig::Runtime::ContextUpdate < Riffer::Messages::User
4
+ MARKER: Symbol
5
+
6
+ PREAMBLE: ::String
7
+
8
+ # @dynamic sections
9
+ attr_reader sections: Hash[Symbol, String?]
10
+
11
+ # @rbs changes: Hash[Symbol, String?]
12
+ # @rbs return: Riffer::Rig::Runtime::ContextUpdate
13
+ def self.of: (Hash[Symbol, String?] changes) -> Riffer::Rig::Runtime::ContextUpdate
14
+
15
+ # @rbs hash: Hash[Symbol, untyped]
16
+ # @rbs return: Riffer::Rig::Runtime::ContextUpdate
17
+ def self.from_hash: (Hash[Symbol, untyped] hash) -> Riffer::Rig::Runtime::ContextUpdate
18
+
19
+ # @rbs content: String
20
+ # @rbs id: String?
21
+ # @rbs files: Array[Riffer::Messages::User::FilePart]
22
+ # @rbs sections: Hash[Symbol, String?]
23
+ # @rbs return: void
24
+ def initialize: (String content, ?id: String?, ?files: Array[Riffer::Messages::User::FilePart], ?sections: Hash[Symbol, String?]) -> void
25
+
26
+ # @rbs return: Hash[Symbol, untyped]
27
+ def to_h: () -> Hash[Symbol, untyped]
28
+ end
@@ -0,0 +1,16 @@
1
+ # Generated from lib/riffer/rig/runtime/head.rb with RBS::Inline
2
+
3
+ module Riffer::Rig::Runtime::Head
4
+ # @rbs messages: Array[Riffer::Messages::Base]
5
+ # @rbs return: Hash[Symbol, String]?
6
+ def sections: (Array[Riffer::Messages::Base] messages) -> Hash[Symbol, String]?
7
+
8
+ # @rbs messages: Array[Riffer::Messages::Base]
9
+ # @rbs return: Hash[Symbol, String]?
10
+ def seen: (Array[Riffer::Messages::Base] messages) -> Hash[Symbol, String]?
11
+
12
+ # @rbs seen: Hash[Symbol, String]
13
+ # @rbs current: Hash[Symbol, String]
14
+ # @rbs return: Hash[Symbol, String?]
15
+ def changes: (Hash[Symbol, String] seen, Hash[Symbol, String] current) -> Hash[Symbol, String?]
16
+ end
@@ -1,12 +1,25 @@
1
1
  # Generated from lib/riffer/rig/runtime/system_prompt.rb with RBS::Inline
2
2
 
3
3
  class Riffer::Rig::Runtime::SystemPrompt
4
+ ENVIRONMENT: Symbol
5
+
6
+ SECTION: Regexp
7
+
4
8
  @base: String
5
9
 
6
10
  @cwd: String
7
11
 
8
12
  @sections: Hash[Symbol, ^(Riffer::Rig::Runtime) -> String?]
9
13
 
14
+ # @rbs name: Symbol
15
+ # @rbs text: String
16
+ # @rbs return: String
17
+ def self.section: (Symbol name, String text) -> String
18
+
19
+ # @rbs rendered: String
20
+ # @rbs return: Hash[Symbol, String]
21
+ def self.sections: (String rendered) -> Hash[Symbol, String]
22
+
10
23
  # @rbs base: String
11
24
  # @rbs cwd: String
12
25
  # @rbs sections: Hash[Symbol, ^(Riffer::Rig::Runtime) -> String?]
@@ -17,21 +30,16 @@ class Riffer::Rig::Runtime::SystemPrompt
17
30
  # @rbs return: Riffer::Rig::Runtime::SystemPrompt
18
31
  def with_sections: (Hash[Symbol, ^(Riffer::Rig::Runtime) -> String?] sections) -> Riffer::Rig::Runtime::SystemPrompt
19
32
 
20
- # @rbs return: String
21
- def bare: () -> String
22
-
23
33
  # @rbs runtime: Riffer::Rig::Runtime
24
- # @rbs return: String
25
- def render: (Riffer::Rig::Runtime runtime) -> String
34
+ # @rbs return: Hash[Symbol, String]
35
+ def values: (Riffer::Rig::Runtime runtime) -> Hash[Symbol, String]
26
36
 
27
- # @rbs session: Riffer::Agent::Session
28
- # @rbs runtime: Riffer::Rig::Runtime
29
- # @rbs return: void
30
- def refresh: (Riffer::Agent::Session session, Riffer::Rig::Runtime runtime) -> void
37
+ # @rbs values: Hash[Symbol, String]
38
+ # @rbs return: String
39
+ def render: (Hash[Symbol, String] values) -> String
31
40
 
32
41
  private
33
42
 
34
- # @rbs sections: Array[String]
35
43
  # @rbs return: String
36
- def compose: (Array[String] sections) -> String
44
+ def environment: () -> String
37
45
  end
@@ -328,6 +328,14 @@ class Riffer::Rig::Runtime
328
328
  # @rbs return: void
329
329
  def open_turn: () -> void
330
330
 
331
+ # @rbs values: Hash[Symbol, String]
332
+ # @rbs return: void
333
+ def open_head: (Hash[Symbol, String] values) -> void
334
+
335
+ # @rbs changes: Hash[Symbol, String?]
336
+ # @rbs return: void
337
+ def update_context: (Hash[Symbol, String?] changes) -> void
338
+
331
339
  # @rbs outcome: Riffer::Agent::Outcome
332
340
  # @rbs return: Enumerator[Riffer::StreamEvents::Base, Riffer::Agent::Response]
333
341
  def ended_turn: (Riffer::Agent::Outcome outcome) -> Enumerator[Riffer::StreamEvents::Base, Riffer::Agent::Response]
@@ -9,4 +9,10 @@ module Riffer::Rig::Stores::Entries
9
9
  # @rbs id: String
10
10
  # @rbs return: Riffer::Rig::Runtime::Snapshot
11
11
  def snapshot: (Array[Riffer::Rig::Stores::entry] entries, String id) -> Riffer::Rig::Runtime::Snapshot
12
+
13
+ private
14
+
15
+ # @rbs entries: Array[Riffer::Rig::Stores::entry]
16
+ # @rbs return: Array[Riffer::Messages::Base]
17
+ def replayed: (Array[Riffer::Rig::Stores::entry] entries) -> Array[Riffer::Messages::Base]
12
18
  end
@@ -52,6 +52,10 @@ class Riffer::Rig::Stores::Recorder
52
52
 
53
53
  private
54
54
 
55
+ # @rbs message: Riffer::Messages::Base
56
+ # @rbs return: bool
57
+ def harness?: (Riffer::Messages::Base message) -> bool
58
+
55
59
  # @rbs entry: Riffer::Rig::Stores::entry
56
60
  # @rbs return: void
57
61
  def record: (Riffer::Rig::Stores::entry entry) -> void
@@ -0,0 +1,6 @@
1
+ # rbs-inline does not emit `extend self`, so without this reopen the module's
2
+ # methods aren't visible as singleton methods.
3
+
4
+ module Riffer::Rig::Runtime::Head
5
+ extend ::Riffer::Rig::Runtime::Head
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riffer-rig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.2
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Bottrall
@@ -119,6 +119,7 @@ files:
119
119
  - CHANGELOG.md
120
120
  - LICENSE
121
121
  - README.md
122
+ - docs/PUBLIC_API.md
122
123
  - exe/riffer
123
124
  - lib/riffer/rig.rb
124
125
  - lib/riffer/rig/acp.rb
@@ -191,7 +192,9 @@ files:
191
192
  - lib/riffer/rig/runtime/assembly.rb
192
193
  - lib/riffer/rig/runtime/cancel_flag.rb
193
194
  - lib/riffer/rig/runtime/concurrency.rb
195
+ - lib/riffer/rig/runtime/context_update.rb
194
196
  - lib/riffer/rig/runtime/error_message.rb
197
+ - lib/riffer/rig/runtime/head.rb
195
198
  - lib/riffer/rig/runtime/hooks.rb
196
199
  - lib/riffer/rig/runtime/job.rb
197
200
  - lib/riffer/rig/runtime/job_envelope.rb
@@ -358,7 +361,9 @@ files:
358
361
  - sig/generated/riffer/rig/runtime/assembly.rbs
359
362
  - sig/generated/riffer/rig/runtime/cancel_flag.rbs
360
363
  - sig/generated/riffer/rig/runtime/concurrency.rbs
364
+ - sig/generated/riffer/rig/runtime/context_update.rbs
361
365
  - sig/generated/riffer/rig/runtime/error_message.rbs
366
+ - sig/generated/riffer/rig/runtime/head.rbs
362
367
  - sig/generated/riffer/rig/runtime/hooks.rbs
363
368
  - sig/generated/riffer/rig/runtime/job.rbs
364
369
  - sig/generated/riffer/rig/runtime/job_envelope.rbs
@@ -475,6 +480,7 @@ files:
475
480
  - sig/manual/riffer/rig/prompts/agents_md.rbs
476
481
  - sig/manual/riffer/rig/providers.rbs
477
482
  - sig/manual/riffer/rig/runtime/error_message.rbs
483
+ - sig/manual/riffer/rig/runtime/head.rbs
478
484
  - sig/manual/riffer/rig/runtime/job_envelope.rbs
479
485
  - sig/manual/riffer/rig/runtime/stop_reason.rbs
480
486
  - sig/manual/riffer/rig/runtime/usage.rbs