samagotchi 0.101.0 → 0.103.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 +67 -1
- data/bin/chi +31 -196
- data/docs/architecture.md +62 -6
- data/docs/cli.md +154 -7
- data/docs/configuration.md +32 -5
- data/docs/guardrails.md +2 -1
- data/docs/internals/bundles.md +1 -1
- data/docs/internals/engine.md +1 -1
- data/docs/internals/llm-context-forget.md +25 -1
- data/docs/internals/prompt-caching.md +8 -1
- data/docs/internals/remote-sessions.md +303 -0
- data/docs/internals/working-set.md +174 -15
- data/docs/plugins.md +32 -5
- data/docs/sessions.md +38 -14
- data/docs/sub-agent.md +8 -0
- data/docs/testing.md +7 -0
- data/lib/samagotchi/answer_command.rb +27 -25
- data/lib/samagotchi/bridge/turn_accumulator.rb +16 -0
- data/lib/samagotchi/bridge.rb +33 -7
- data/lib/samagotchi/bridge_client/event_stream.rb +81 -12
- data/lib/samagotchi/bridge_client/stream_request.rb +77 -0
- data/lib/samagotchi/bridge_client.rb +22 -38
- data/lib/samagotchi/bundle_command/check.rb +5 -1
- data/lib/samagotchi/bundle_command/try/command.rb +6 -6
- data/lib/samagotchi/bundle_command/try/sandbox.rb +3 -3
- data/lib/samagotchi/bundle_command.rb +4 -4
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/claude-peer/scripts/pair +30 -1
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/codex-peer/scripts/pair +49 -4
- data/lib/samagotchi/bundles/guardrails/guardrails/rules.yml +7 -4
- data/lib/samagotchi/bundles/guardrails/manifest.yml +1 -1
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/chi_invocation.rb +43 -0
- data/lib/samagotchi/cli/command.rb +3 -2
- data/lib/samagotchi/cli/flags.rb +5 -0
- data/lib/samagotchi/cli/parent_wait.rb +22 -13
- data/lib/samagotchi/commands/registry.rb +12 -1
- data/lib/samagotchi/config.rb +89 -53
- data/lib/samagotchi/context_command.rb +80 -73
- data/lib/samagotchi/engine.rb +138 -15
- data/lib/samagotchi/idle_recap.rb +7 -1
- data/lib/samagotchi/idle_scheduler.rb +16 -1
- data/lib/samagotchi/kernel_loop.rb +13 -1
- data/lib/samagotchi/launch_mode.rb +22 -0
- data/lib/samagotchi/llm_context_edit.rb +32 -10
- data/lib/samagotchi/llm_context_forget.rb +24 -8
- data/lib/samagotchi/llm_context_view.rb +19 -7
- data/lib/samagotchi/memory_bundle/installer.rb +2 -0
- data/lib/samagotchi/memory_bundle/manifest.rb +13 -2
- data/lib/samagotchi/message_parts.rb +8 -3
- data/lib/samagotchi/note_command.rb +8 -7
- data/lib/samagotchi/parent_report.rb +55 -43
- data/lib/samagotchi/plugin/context.rb +2 -2
- data/lib/samagotchi/prompt.rb +1 -1
- data/lib/samagotchi/recap_command.rb +68 -0
- data/lib/samagotchi/recap_setup.rb +27 -14
- data/lib/samagotchi/remote_command.rb +170 -0
- data/lib/samagotchi/remotes.rb +130 -0
- data/lib/samagotchi/run_options.rb +233 -0
- data/lib/samagotchi/send_command/busy.rb +58 -0
- data/lib/samagotchi/send_command/parent_gate.rb +23 -10
- data/lib/samagotchi/send_command/wait_target.rb +16 -3
- data/lib/samagotchi/send_command.rb +186 -118
- data/lib/samagotchi/session.rb +48 -16
- data/lib/samagotchi/session_access/contract.rb +129 -0
- data/lib/samagotchi/session_access/dispatch.rb +133 -0
- data/lib/samagotchi/session_access/http_transport.rb +109 -0
- data/lib/samagotchi/session_access/local.rb +349 -0
- data/lib/samagotchi/session_access/remote.rb +638 -0
- data/lib/samagotchi/session_access/web_bridge_client.rb +181 -0
- data/lib/samagotchi/session_access.rb +141 -0
- data/lib/samagotchi/session_archive_command.rb +9 -5
- data/lib/samagotchi/session_commands.rb +53 -6
- data/lib/samagotchi/session_config.rb +411 -0
- data/lib/samagotchi/session_delete_command.rb +8 -4
- data/lib/samagotchi/session_manager.rb +7 -2
- data/lib/samagotchi/session_setup.rb +15 -10
- data/lib/samagotchi/sessions_command.rb +42 -16
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +54 -18
- data/lib/samagotchi/terminal_ui/attach_link.rb +104 -0
- data/lib/samagotchi/terminal_ui/attached_loop.rb +82 -76
- data/lib/samagotchi/terminal_ui/formatting.rb +10 -3
- data/lib/samagotchi/terminal_ui/local_link.rb +130 -0
- data/lib/samagotchi/terminal_ui/version_lines.rb +5 -3
- data/lib/samagotchi/terminal_ui.rb +8 -6
- data/lib/samagotchi/testing/bundle.rb +3 -2
- data/lib/samagotchi/title_command.rb +9 -11
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +387 -79
- data/lib/samagotchi/web/public/app.js +2 -0
- data/lib/samagotchi/web/public/commands.js +8 -2
- data/lib/samagotchi/web/public/data.js +6 -4
- data/lib/samagotchi/web/public/index.html +37 -3
- data/lib/samagotchi/web/public/stage_frame.js +7 -2
- data/lib/samagotchi/web/public/stage_view.js +3 -2
- data/lib/samagotchi/web/public/stream_handlers.js +7 -1
- data/lib/samagotchi/web/public/turn_html.js +5 -0
- data/lib/samagotchi/web/public/working_set.js +247 -24
- data/lib/samagotchi/web/public/working_set_rail.js +39 -12
- data/lib/samagotchi/web/public/working_set_view.js +198 -25
- data/lib/samagotchi/web/session_access_routes.rb +343 -0
- data/lib/samagotchi/worker.rb +9 -6
- data/lib/samagotchi/worker_sidecar.rb +12 -5
- data/lib/samagotchi/working_set.rb +132 -20
- data/lib/samagotchi/working_set_command.rb +222 -0
- data/lib/samagotchi/working_set_pin.rb +34 -0
- data/lib/samagotchi/working_set_steer.rb +414 -0
- metadata +23 -2
- data/lib/samagotchi/bundle_session_settings.rb +0 -251
|
@@ -102,7 +102,7 @@ module Samagotchi
|
|
|
102
102
|
# @param toolkit [Toolkit, nil] --toolkit/--tool/--no-tool: a new
|
|
103
103
|
# session's toolkit (config's toolkit.default without); a resumed one
|
|
104
104
|
# keeps its own, with a line naming +toolkit_flags+ (the flags given)
|
|
105
|
-
# @param
|
|
105
|
+
# @param settings [SessionConfig::Settings, nil] --set's values:
|
|
106
106
|
# a new session's own; a resumed one keeps its own (--set is in
|
|
107
107
|
# +toolkit_flags+ then)
|
|
108
108
|
# @param parent_answers [String, nil] --parent-answers: a new session's
|
|
@@ -110,12 +110,12 @@ module Samagotchi
|
|
|
110
110
|
# +toolkit_flags+ then)
|
|
111
111
|
def initialize(prompt: nil, client: nil, host_registry: nil, profile: nil, session_id: nil, no_interrupt: false, no_default_input: false, model_name: nil, memories: [], muted_memories: [], non_interactive: false, surface: nil,
|
|
112
112
|
spinner_tick_interval: AttachedView::TICK_INTERVAL, spinner_clock: nil, scratch: false, llm_context: {}, thinking: nil,
|
|
113
|
-
appended_prompt_files: [], toolkit: nil, toolkit_flags: [],
|
|
113
|
+
appended_prompt_files: [], toolkit: nil, toolkit_flags: [], settings: nil, parent_answers: nil)
|
|
114
114
|
@scratch = scratch
|
|
115
115
|
@parent_answers = parent_answers
|
|
116
116
|
@toolkit = toolkit
|
|
117
117
|
@toolkit_flags = toolkit_flags
|
|
118
|
-
@
|
|
118
|
+
@session_settings = settings
|
|
119
119
|
@thinking_word = thinking
|
|
120
120
|
@prompt = prompt
|
|
121
121
|
@llm_context_words = llm_context
|
|
@@ -227,7 +227,7 @@ module Samagotchi
|
|
|
227
227
|
@turn_flow = TurnFlow.new(engine: @engine)
|
|
228
228
|
# A recap written while a continue offer waits says the turn stopped
|
|
229
229
|
# unfinished. (Answering at the prompt is typing: activity already.)
|
|
230
|
-
@engine.
|
|
230
|
+
@engine.recap_awaiting_continue = -> { @turn_flow.awaiting_continue? }
|
|
231
231
|
@commands = SessionCommands.new(engine: @engine, turn_flow: @turn_flow, default_model: @default_model_name,
|
|
232
232
|
registry: @engine.command_registry)
|
|
233
233
|
# Runtime --model flag or resumed session: switch the Engine (client,
|
|
@@ -285,7 +285,7 @@ module Samagotchi
|
|
|
285
285
|
muted_memory_names: @muted_memory_names,
|
|
286
286
|
scratch: @scratch,
|
|
287
287
|
setup: SessionSetup.new(appended_prompt_files: @appended_prompt_files, toolkit: @toolkit || Toolkit.configured,
|
|
288
|
-
|
|
288
|
+
settings: @session_settings, parent_answers: @parent_answers)
|
|
289
289
|
))
|
|
290
290
|
# --llm-context*: the session's own values, over a resumed one's.
|
|
291
291
|
# Saved at once on a resumed one: leaving before a turn keeps them.
|
|
@@ -890,6 +890,8 @@ module Samagotchi
|
|
|
890
890
|
show_command_result(command)
|
|
891
891
|
refresh_status_row(clear_unknown_context: true) if command.changed.include?(:model)
|
|
892
892
|
refresh_status_row if command.changed.include?(:title)
|
|
893
|
+
# /recap and /title don't save themselves (a worker saves a changed command).
|
|
894
|
+
save_session(session) if command.changed.intersect?(%i[recap title])
|
|
893
895
|
persist_recent_history(input) if command.shell
|
|
894
896
|
return
|
|
895
897
|
end
|
|
@@ -1180,7 +1182,7 @@ module Samagotchi
|
|
|
1180
1182
|
# chat moved on (it prints when it arrives, BetweenTurns#flush_recap).
|
|
1181
1183
|
def handle_recap_command
|
|
1182
1184
|
recap = @engine.recap
|
|
1183
|
-
return recap_command_text(enabled: false) unless recap
|
|
1185
|
+
return recap_command_text(enabled: false, session_off: @engine.recap_override == false) unless recap
|
|
1184
1186
|
|
|
1185
1187
|
saved = @engine.saved_recap
|
|
1186
1188
|
request = @engine.turn_running? ? :busy : @engine.request_recap
|
|
@@ -429,9 +429,10 @@ module Samagotchi
|
|
|
429
429
|
# of another type than it gives the key
|
|
430
430
|
def setup_with(session_settings, setup)
|
|
431
431
|
values = { @name => stringify(session_settings) }
|
|
432
|
-
|
|
432
|
+
SessionConfig.check!(values, bundles: { @name => @manifest.session_settings },
|
|
433
433
|
types: { @name => @manifest.session_setting_types }, flag: "session_settings")
|
|
434
|
-
|
|
434
|
+
setup ||= SessionSetup.new
|
|
435
|
+
setup.with(settings: setup.settings.with(bundles: values))
|
|
435
436
|
end
|
|
436
437
|
|
|
437
438
|
def stringify(value) = Sandbox.stringify(value)
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
module Samagotchi
|
|
4
4
|
# /title, the session's own name (Session#title): with no argument, the
|
|
5
5
|
# title and what shows without one; `/title TEXT` names the session
|
|
6
|
-
# (whitespace collapsed, cut at 80 characters as a preview is)
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
6
|
+
# (whitespace collapsed, cut at 80 characters as a preview is);
|
|
7
|
+
# `/title --clear` drops it, and the lists show the first message again.
|
|
8
|
+
# Anyone who may send the session a command may name it (a parent agent
|
|
9
|
+
# its delegates too). It doesn't save: its host saves a changed result at
|
|
10
|
+
# once (Worker, the REPL). It runs mid-turn as well (anytime): the
|
|
11
|
+
# worker's save takes the session's lock and writes a running turn's
|
|
12
|
+
# checkpoint, as a turn's own saves do.
|
|
12
13
|
class TitleCommand
|
|
13
14
|
NAME = "/title"
|
|
14
15
|
CLEAR = "--clear"
|
|
@@ -17,10 +18,8 @@ module Samagotchi
|
|
|
17
18
|
LIMIT = 80
|
|
18
19
|
|
|
19
20
|
# @param engine [Engine] #session
|
|
20
|
-
|
|
21
|
-
def initialize(engine:, save:)
|
|
21
|
+
def initialize(engine:)
|
|
22
22
|
@engine = engine
|
|
23
|
-
@save = save
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
# @param args [String] what follows /title
|
|
@@ -42,9 +41,8 @@ module Samagotchi
|
|
|
42
41
|
session.title = title
|
|
43
42
|
# The command itself as the session's first line (chi send --new
|
|
44
43
|
# "/title X", a web first message) became its preview: it goes, and
|
|
45
|
-
# the save derives the preview from the first user message again.
|
|
44
|
+
# the host's save derives the preview from the first user message again.
|
|
46
45
|
session.first_preview = "" if session.first_preview.to_s.start_with?(NAME)
|
|
47
|
-
@save.call(session)
|
|
48
46
|
[listing(session), true, :ok]
|
|
49
47
|
end
|
|
50
48
|
|