samagotchi 0.104.0 → 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -1
- data/docs/cli.md +13 -11
- data/docs/configuration.md +1 -1
- data/docs/guardrails.md +13 -0
- data/docs/internals/anthropic.md +2 -1
- data/docs/internals/engine.md +18 -0
- data/docs/internals/participants.md +30 -0
- data/docs/internals/prompt-caching.md +8 -0
- data/docs/internals/working-set.md +4 -3
- data/docs/testing.md +21 -0
- data/lib/samagotchi/bridge/turn_accumulator.rb +2 -1
- data/lib/samagotchi/bridge.rb +10 -7
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/config.rb +1 -1
- data/lib/samagotchi/engine.rb +36 -2
- data/lib/samagotchi/last_turn.rb +5 -2
- data/lib/samagotchi/llm/chat_loop.rb +1 -0
- data/lib/samagotchi/participant_name.rb +21 -0
- data/lib/samagotchi/queued_command.rb +9 -5
- data/lib/samagotchi/session_access/web_bridge_client.rb +4 -2
- data/lib/samagotchi/session_metrics.rb +7 -1
- data/lib/samagotchi/session_participants.rb +59 -0
- data/lib/samagotchi/sessions_command.rb +10 -7
- data/lib/samagotchi/steer.rb +83 -10
- data/lib/samagotchi/system_prompt.rb +21 -2
- data/lib/samagotchi/terminal_ui/attached_loop.rb +40 -15
- data/lib/samagotchi/terminal_ui/reline_seam.rb +21 -1
- data/lib/samagotchi/turn_checkpoint.rb +5 -2
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/grants.rb +4 -3
- data/lib/samagotchi/web/public/index.html +6 -5
- data/lib/samagotchi/web/public/working_set.js +6 -4
- data/lib/samagotchi/web/public/working_set_view.js +1 -1
- data/lib/samagotchi/worker.rb +18 -6
- data/lib/samagotchi/worker_inbound.rb +5 -2
- metadata +3 -1
data/lib/samagotchi/worker.rb
CHANGED
|
@@ -299,9 +299,9 @@ module Samagotchi
|
|
|
299
299
|
context_absorber: @context_absorber, wakes: @wakes,
|
|
300
300
|
awaiting_continue: -> { @turn_flow.awaiting_continue? },
|
|
301
301
|
stopped: -> { stopped_on_disk? },
|
|
302
|
-
queue_command: lambda { |line, client_id, after_file, enqueued_id|
|
|
302
|
+
queue_command: lambda { |line, client_id, after_file, enqueued_id, author: nil|
|
|
303
303
|
@bridge.queue_command(line, client_id: client_id, after_file: after_file,
|
|
304
|
-
enqueued_id: enqueued_id)
|
|
304
|
+
enqueued_id: enqueued_id, author: author)
|
|
305
305
|
})
|
|
306
306
|
# /model's default is the config's, as in the REPL; the Engine started
|
|
307
307
|
# on the session's model. nil when there is no default.model.
|
|
@@ -1006,7 +1006,8 @@ module Samagotchi
|
|
|
1006
1006
|
@reporting_turn = reports_to_parent?(turn_args[:origin])
|
|
1007
1007
|
restores = @turn_flow.restores
|
|
1008
1008
|
begin
|
|
1009
|
-
@checkpoint.begin_turn(prompt: prompt, enqueued_id: turn_args[:origin]&.dig(:enqueued_id)
|
|
1009
|
+
@checkpoint.begin_turn(prompt: prompt, enqueued_id: turn_args[:origin]&.dig(:enqueued_id),
|
|
1010
|
+
author: turn_author_fields(turn_args[:origin]))
|
|
1010
1011
|
@session.status = Session::STATUS_RUNNING
|
|
1011
1012
|
# A continue that moved this session to the chain's new link wrote
|
|
1012
1013
|
# the new parent beside it (Session::PARENT_FILE): this turn's
|
|
@@ -1186,9 +1187,9 @@ module Samagotchi
|
|
|
1186
1187
|
@merged_this_turn.concat(merged)
|
|
1187
1188
|
end
|
|
1188
1189
|
# Each line keeps its sender (Steer.source_for_client): a chi send or
|
|
1189
|
-
# a delegating parent's line is saved and shown to the model as theirs
|
|
1190
|
-
|
|
1191
|
-
|
|
1190
|
+
# a delegating parent's line is saved and shown to the model as theirs,
|
|
1191
|
+
# a participant's with its author (Engine#author_fields).
|
|
1192
|
+
lines = merged.map { |prompt, origin| merged_line(prompt, origin) } + reports.map(&:line)
|
|
1192
1193
|
# A wake turn starts with its first line, whoever sent it.
|
|
1193
1194
|
lines[0] = lines[0].with(mark: mark) if mark && lines.any?
|
|
1194
1195
|
# The turn so far, with what this boundary merges (its input files
|
|
@@ -1199,6 +1200,17 @@ module Samagotchi
|
|
|
1199
1200
|
end
|
|
1200
1201
|
end
|
|
1201
1202
|
|
|
1203
|
+
# A participant's author fields (Engine#author_fields), {} for the owner.
|
|
1204
|
+
def turn_author_fields(origin)
|
|
1205
|
+
Steer.participant_author?(origin&.dig(:author)) ? @engine.author_fields(origin[:author], session: @session) : {}
|
|
1206
|
+
end
|
|
1207
|
+
|
|
1208
|
+
def merged_line(prompt, origin)
|
|
1209
|
+
author = turn_author_fields(origin)
|
|
1210
|
+
Steer::Line.new(text: prompt, source: Steer.source_for_client(origin&.dig(:client_id)),
|
|
1211
|
+
author: author[:author], author_name: author[:author_name])
|
|
1212
|
+
end
|
|
1213
|
+
|
|
1202
1214
|
# The reports for rings that came in since the turn last looked. A
|
|
1203
1215
|
# failure to read them must not take the turn's steering with it.
|
|
1204
1216
|
# A wake turn's first call gets the reports it was started for (their
|
|
@@ -11,6 +11,7 @@ require_relative "context_note"
|
|
|
11
11
|
require_relative "log"
|
|
12
12
|
require_relative "session"
|
|
13
13
|
require_relative "session_inbox"
|
|
14
|
+
require_relative "steer"
|
|
14
15
|
require_relative "tools/task_record"
|
|
15
16
|
require_relative "worker_wakes"
|
|
16
17
|
|
|
@@ -237,12 +238,14 @@ module Samagotchi
|
|
|
237
238
|
# A session command sent as a message (chi send -m "/model x", a web
|
|
238
239
|
# page's first message) runs as the command, as the Bridge does for a
|
|
239
240
|
# POST /turn; an unknown /word stays a prompt. Queued: the loop's next
|
|
240
|
-
# pass runs it
|
|
241
|
+
# pass runs it, with its input's author (only a participant's: the
|
|
242
|
+
# owner's command is queued as it always was).
|
|
241
243
|
# @return [Boolean] whether +text+ was one
|
|
242
244
|
def queue_as_command(text, origin, after_file = nil)
|
|
243
245
|
return false unless @engine.command_registry.command?(text.to_s)
|
|
244
246
|
|
|
245
|
-
|
|
247
|
+
author = Steer.sender_author(origin&.dig(:author))
|
|
248
|
+
@queue_command.call(text, origin&.dig(:client_id), after_file, origin&.dig(:enqueued_id), **{ author: author }.compact)
|
|
246
249
|
true
|
|
247
250
|
end
|
|
248
251
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: samagotchi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.105.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Dedov
|
|
@@ -463,6 +463,7 @@ files:
|
|
|
463
463
|
- lib/samagotchi/owner_lock.rb
|
|
464
464
|
- lib/samagotchi/parent_answers_command.rb
|
|
465
465
|
- lib/samagotchi/parent_report.rb
|
|
466
|
+
- lib/samagotchi/participant_name.rb
|
|
466
467
|
- lib/samagotchi/participants.rb
|
|
467
468
|
- lib/samagotchi/paths.rb
|
|
468
469
|
- lib/samagotchi/peer_sources.rb
|
|
@@ -547,6 +548,7 @@ files:
|
|
|
547
548
|
- lib/samagotchi/session_metrics/usage.rb
|
|
548
549
|
- lib/samagotchi/session_model_settings.rb
|
|
549
550
|
- lib/samagotchi/session_observer.rb
|
|
551
|
+
- lib/samagotchi/session_participants.rb
|
|
550
552
|
- lib/samagotchi/session_retention.rb
|
|
551
553
|
- lib/samagotchi/session_setting.rb
|
|
552
554
|
- lib/samagotchi/session_setup.rb
|