samagotchi 0.2.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 +7 -0
- data/CHANGELOG.md +43 -0
- data/LICENSE +21 -0
- data/README.md +126 -0
- data/bin/chi +1140 -0
- data/docs/architecture.md +299 -0
- data/docs/cli.md +490 -0
- data/docs/configuration.md +494 -0
- data/docs/desktop.md +97 -0
- data/docs/guardrails.md +218 -0
- data/docs/hooks.md +309 -0
- data/docs/internals/background-tasks.md +26 -0
- data/docs/internals/context-telemetry.md +36 -0
- data/docs/internals/gemma4-contract.md +23 -0
- data/docs/internals/tool-guardrails.md +45 -0
- data/docs/memory.md +85 -0
- data/docs/plugins.md +819 -0
- data/docs/releasing.md +135 -0
- data/docs/sessions.md +155 -0
- data/lib/samagotchi/bridge/bounded_queue.rb +70 -0
- data/lib/samagotchi/bridge/card_store.rb +126 -0
- data/lib/samagotchi/bridge/event_id.rb +25 -0
- data/lib/samagotchi/bridge/ring_buffer.rb +63 -0
- data/lib/samagotchi/bridge/sse_writer.rb +248 -0
- data/lib/samagotchi/bridge/turn_accumulator.rb +189 -0
- data/lib/samagotchi/bridge.rb +993 -0
- data/lib/samagotchi/bridge_client/event_stream.rb +158 -0
- data/lib/samagotchi/bridge_client/sse_parser.rb +51 -0
- data/lib/samagotchi/bridge_client.rb +330 -0
- data/lib/samagotchi/bundle_needs.rb +97 -0
- data/lib/samagotchi/bundles/btw/manifest.yml +10 -0
- data/lib/samagotchi/bundles/btw/plugin.rb +100 -0
- data/lib/samagotchi/bundles/guardrails/guardrails/rules.yml +82 -0
- data/lib/samagotchi/bundles/guardrails/guardrails.md +14 -0
- data/lib/samagotchi/bundles/guardrails/manifest.yml +8 -0
- data/lib/samagotchi/bundles/known-names/hooks/known_names.rb +210 -0
- data/lib/samagotchi/bundles/known-names/known_names.md +3 -0
- data/lib/samagotchi/bundles/known-names/manifest.yml +14 -0
- data/lib/samagotchi/bundles/loop-guard/manifest.yml +10 -0
- data/lib/samagotchi/bundles/loop-guard/plugin.rb +158 -0
- data/lib/samagotchi/bundles/mcp/manifest.yml +11 -0
- data/lib/samagotchi/bundles/mcp/plugin.rb +631 -0
- data/lib/samagotchi/bundles/system/config_modification_protocol.md +149 -0
- data/lib/samagotchi/bundles/system/delegated.md +10 -0
- data/lib/samagotchi/bundles/system/identity.md +7 -0
- data/lib/samagotchi/bundles/system/manifest.yml +11 -0
- data/lib/samagotchi/bundles/system/memory_guide.md +107 -0
- data/lib/samagotchi/bundles/system/self_map.md +55 -0
- data/lib/samagotchi/cancellation_controller.rb +78 -0
- data/lib/samagotchi/client.rb +429 -0
- data/lib/samagotchi/commands/registry.rb +112 -0
- data/lib/samagotchi/config.rb +910 -0
- data/lib/samagotchi/context_note.rb +77 -0
- data/lib/samagotchi/context_quote.rb +21 -0
- data/lib/samagotchi/context_usage.rb +66 -0
- data/lib/samagotchi/context_window.rb +76 -0
- data/lib/samagotchi/debug_log.rb +110 -0
- data/lib/samagotchi/desktop/macos/App.swift +102 -0
- data/lib/samagotchi/desktop/macos/ChiRunner.swift +201 -0
- data/lib/samagotchi/desktop/macos/Hotkey.swift +42 -0
- data/lib/samagotchi/desktop/macos/Info.plist.erb +42 -0
- data/lib/samagotchi/desktop/macos/Panel.swift +383 -0
- data/lib/samagotchi/desktop/macos.rb +255 -0
- data/lib/samagotchi/desktop.rb +21 -0
- data/lib/samagotchi/desktop_command.rb +143 -0
- data/lib/samagotchi/engine.rb +2807 -0
- data/lib/samagotchi/guardrails/approval.rb +125 -0
- data/lib/samagotchi/guardrails/approvals.rb +177 -0
- data/lib/samagotchi/guardrails/context.rb +71 -0
- data/lib/samagotchi/guardrails/gate.rb +125 -0
- data/lib/samagotchi/guardrails/load_failures.rb +46 -0
- data/lib/samagotchi/guardrails/protected_paths.rb +77 -0
- data/lib/samagotchi/guardrails/rules.rb +199 -0
- data/lib/samagotchi/guardrails/targets.rb +119 -0
- data/lib/samagotchi/guardrails/verdict.rb +134 -0
- data/lib/samagotchi/guardrails.rb +18 -0
- data/lib/samagotchi/hooks/bundle_loader.rb +158 -0
- data/lib/samagotchi/hooks/loader.rb +162 -0
- data/lib/samagotchi/hooks/registry.rb +261 -0
- data/lib/samagotchi/hooks.rb +30 -0
- data/lib/samagotchi/host_registry.rb +315 -0
- data/lib/samagotchi/idle_client.rb +147 -0
- data/lib/samagotchi/idle_recap.rb +549 -0
- data/lib/samagotchi/idle_reminders.rb +101 -0
- data/lib/samagotchi/idle_scheduler.rb +76 -0
- data/lib/samagotchi/image_store.rb +393 -0
- data/lib/samagotchi/installed_gem.rb +38 -0
- data/lib/samagotchi/kernel_loop.rb +1017 -0
- data/lib/samagotchi/launch_mode.rb +34 -0
- data/lib/samagotchi/llm/backend.rb +28 -0
- data/lib/samagotchi/llm/chat_loop.rb +450 -0
- data/lib/samagotchi/llm/errors.rb +329 -0
- data/lib/samagotchi/llm/http.rb +412 -0
- data/lib/samagotchi/llm/model_result.rb +72 -0
- data/lib/samagotchi/llm/native_backend.rb +50 -0
- data/lib/samagotchi/llm/native_tool_normalizer.rb +277 -0
- data/lib/samagotchi/llm/openai_chat.rb +403 -0
- data/lib/samagotchi/llm/usage.rb +79 -0
- data/lib/samagotchi/log.rb +200 -0
- data/lib/samagotchi/log_line.rb +127 -0
- data/lib/samagotchi/log_path.rb +31 -0
- data/lib/samagotchi/log_subscriber.rb +163 -0
- data/lib/samagotchi/memory_bundle/builder.rb +364 -0
- data/lib/samagotchi/memory_bundle/index_updater.rb +123 -0
- data/lib/samagotchi/memory_bundle/installer.rb +528 -0
- data/lib/samagotchi/memory_bundle/listing.rb +72 -0
- data/lib/samagotchi/memory_bundle/manifest.rb +225 -0
- data/lib/samagotchi/memory_bundle/merger.rb +52 -0
- data/lib/samagotchi/memory_bundle/placeholder.rb +37 -0
- data/lib/samagotchi/memory_bundle/provenance.rb +257 -0
- data/lib/samagotchi/memory_bundle/source.rb +153 -0
- data/lib/samagotchi/memory_bundle/status.rb +107 -0
- data/lib/samagotchi/memory_bundle/system_bundle.rb +161 -0
- data/lib/samagotchi/memory_bundle/uninstaller.rb +128 -0
- data/lib/samagotchi/memory_bundle.rb +17 -0
- data/lib/samagotchi/memory_paths.rb +101 -0
- data/lib/samagotchi/model_overlay.rb +53 -0
- data/lib/samagotchi/model_profile.rb +309 -0
- data/lib/samagotchi/muted_memories.rb +66 -0
- data/lib/samagotchi/note_command.rb +163 -0
- data/lib/samagotchi/output_formatter.rb +100 -0
- data/lib/samagotchi/owner_lock.rb +110 -0
- data/lib/samagotchi/pending_input_queue.rb +48 -0
- data/lib/samagotchi/plugin/api.rb +362 -0
- data/lib/samagotchi/plugin/context.rb +193 -0
- data/lib/samagotchi/plugin/loader.rb +126 -0
- data/lib/samagotchi/plugin/service.rb +117 -0
- data/lib/samagotchi/plugin/sessions.rb +150 -0
- data/lib/samagotchi/plugin/side_question.rb +60 -0
- data/lib/samagotchi/plugin/tool_result.rb +24 -0
- data/lib/samagotchi/project_scope.rb +25 -0
- data/lib/samagotchi/prompt.rb +119 -0
- data/lib/samagotchi/prompt_literal_guard.rb +70 -0
- data/lib/samagotchi/recap_store.rb +92 -0
- data/lib/samagotchi/reminder_store.rb +165 -0
- data/lib/samagotchi/self_report.rb +195 -0
- data/lib/samagotchi/send_command.rb +170 -0
- data/lib/samagotchi/served_model.rb +32 -0
- data/lib/samagotchi/session.rb +508 -0
- data/lib/samagotchi/session_commands.rb +527 -0
- data/lib/samagotchi/session_delete_command.rb +105 -0
- data/lib/samagotchi/session_manager.rb +1049 -0
- data/lib/samagotchi/session_metrics.rb +466 -0
- data/lib/samagotchi/session_observer.rb +117 -0
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +118 -0
- data/lib/samagotchi/terminal_ui/attached_loop.rb +1037 -0
- data/lib/samagotchi/terminal_ui/attached_view.rb +264 -0
- data/lib/samagotchi/terminal_ui/event_renderer.rb +192 -0
- data/lib/samagotchi/terminal_ui/formatting.rb +291 -0
- data/lib/samagotchi/terminal_ui/image_input.rb +36 -0
- data/lib/samagotchi/terminal_ui/input_support.rb +324 -0
- data/lib/samagotchi/terminal_ui/legacy_surface.rb +111 -0
- data/lib/samagotchi/terminal_ui/line_reader.rb +113 -0
- data/lib/samagotchi/terminal_ui/live_region.rb +36 -0
- data/lib/samagotchi/terminal_ui/plain_surface.rb +51 -0
- data/lib/samagotchi/terminal_ui/question_prompt.rb +153 -0
- data/lib/samagotchi/terminal_ui/question_slot.rb +131 -0
- data/lib/samagotchi/terminal_ui/reline_seam.rb +216 -0
- data/lib/samagotchi/terminal_ui/repl_input.rb +138 -0
- data/lib/samagotchi/terminal_ui/screen.rb +316 -0
- data/lib/samagotchi/terminal_ui/surface.rb +47 -0
- data/lib/samagotchi/terminal_ui/thinking_line.rb +101 -0
- data/lib/samagotchi/terminal_ui.rb +1992 -0
- data/lib/samagotchi/thinking_ticker.rb +110 -0
- data/lib/samagotchi/thought_stream_splitter.rb +149 -0
- data/lib/samagotchi/token_usage.rb +88 -0
- data/lib/samagotchi/tool_activity.rb +216 -0
- data/lib/samagotchi/tool_call_parser.rb +637 -0
- data/lib/samagotchi/tool_declarations.rb +561 -0
- data/lib/samagotchi/tool_runner.rb +211 -0
- data/lib/samagotchi/tools/args.rb +259 -0
- data/lib/samagotchi/tools/ask_user_question.rb +152 -0
- data/lib/samagotchi/tools/builtins.rb +122 -0
- data/lib/samagotchi/tools/cancel_reminder.rb +21 -0
- data/lib/samagotchi/tools/delegate.rb +167 -0
- data/lib/samagotchi/tools/delegate_result.rb +53 -0
- data/lib/samagotchi/tools/delegate_wait.rb +153 -0
- data/lib/samagotchi/tools/edit.rb +155 -0
- data/lib/samagotchi/tools/execute.rb +214 -0
- data/lib/samagotchi/tools/list_reminders.rb +20 -0
- data/lib/samagotchi/tools/list_sessions.rb +74 -0
- data/lib/samagotchi/tools/memory.rb +256 -0
- data/lib/samagotchi/tools/output_guardrails.rb +93 -0
- data/lib/samagotchi/tools/peers.rb +18 -0
- data/lib/samagotchi/tools/read.rb +182 -0
- data/lib/samagotchi/tools/register_reminder.rb +53 -0
- data/lib/samagotchi/tools/registry.rb +60 -0
- data/lib/samagotchi/tools/send_note.rb +49 -0
- data/lib/samagotchi/tools/task_create.rb +29 -0
- data/lib/samagotchi/tools/task_get.rb +39 -0
- data/lib/samagotchi/tools/task_list.rb +43 -0
- data/lib/samagotchi/tools/task_runtime.rb +311 -0
- data/lib/samagotchi/tools/task_stop.rb +29 -0
- data/lib/samagotchi/tools/task_wait.rb +104 -0
- data/lib/samagotchi/tools/tool_path.rb +18 -0
- data/lib/samagotchi/tools/web_fetch.rb +163 -0
- data/lib/samagotchi/tools/write.rb +26 -0
- data/lib/samagotchi/turn_flow.rb +242 -0
- data/lib/samagotchi/turn_note.rb +76 -0
- data/lib/samagotchi/turn_tally.rb +101 -0
- data/lib/samagotchi/version.rb +7 -0
- data/lib/samagotchi/vision_context.rb +132 -0
- data/lib/samagotchi/vision_support.rb +109 -0
- data/lib/samagotchi/web/app.rb +1349 -0
- data/lib/samagotchi/web/markdown_renderer.rb +107 -0
- data/lib/samagotchi/web/message_parts.rb +169 -0
- data/lib/samagotchi/web/public/activity.js +100 -0
- data/lib/samagotchi/web/public/annotations.js +67 -0
- data/lib/samagotchi/web/public/app.js +2382 -0
- data/lib/samagotchi/web/public/card.js +74 -0
- data/lib/samagotchi/web/public/chat_view.js +360 -0
- data/lib/samagotchi/web/public/chunk_router.js +25 -0
- data/lib/samagotchi/web/public/command_complete.js +39 -0
- data/lib/samagotchi/web/public/composer_size.js +19 -0
- data/lib/samagotchi/web/public/copy.js +142 -0
- data/lib/samagotchi/web/public/ctx.js +35 -0
- data/lib/samagotchi/web/public/data.js +256 -0
- data/lib/samagotchi/web/public/format.js +232 -0
- data/lib/samagotchi/web/public/hold.js +78 -0
- data/lib/samagotchi/web/public/images.js +77 -0
- data/lib/samagotchi/web/public/index.html +568 -0
- data/lib/samagotchi/web/public/init_row.js +60 -0
- data/lib/samagotchi/web/public/model_pick.js +23 -0
- data/lib/samagotchi/web/public/question_card.js +100 -0
- data/lib/samagotchi/web/public/route.js +17 -0
- data/lib/samagotchi/web/public/scope.js +36 -0
- data/lib/samagotchi/web/public/scroll.js +24 -0
- data/lib/samagotchi/web/public/sentences.js +88 -0
- data/lib/samagotchi/web/public/sessions_list.js +60 -0
- data/lib/samagotchi/web/public/strip.js +25 -0
- data/lib/samagotchi/web/public/tally.js +37 -0
- data/lib/samagotchi/web/public/thinking_ticker.js +79 -0
- data/lib/samagotchi/web/public/timing.js +185 -0
- data/lib/samagotchi/web/public/turn_events.js +209 -0
- data/lib/samagotchi/web/public/turn_model.js +204 -0
- data/lib/samagotchi/web/public/turn_view.js +587 -0
- data/lib/samagotchi/web/server.rb +183 -0
- data/lib/samagotchi/web/session_hub.rb +329 -0
- data/lib/samagotchi/web/session_summary.rb +85 -0
- data/lib/samagotchi/worker.rb +635 -0
- data/lib/samagotchi/worker_idle_exit.rb +87 -0
- data/lib/samagotchi.rb +12 -0
- metadata +374 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Samagotchi
|
|
4
|
+
# When a background session worker nobody uses should exit. The session is
|
|
5
|
+
# saved after every turn, so the next send wakes a new worker with the
|
|
6
|
+
# conversation intact; what lives only in memory (metrics, the Bridge's
|
|
7
|
+
# event ring, the last recap) is lost.
|
|
8
|
+
#
|
|
9
|
+
# The worker stays up while any of these holds:
|
|
10
|
+
# * a turn runs, or input is queued for one;
|
|
11
|
+
# * a client holds the Bridge's stream (an attached TUI, even an idle one,
|
|
12
|
+
# or a web tab);
|
|
13
|
+
# * a reminder is registered. Reminders live only in the Engine and repeat
|
|
14
|
+
# until the agent cancels them, so an exit would drop them for good;
|
|
15
|
+
# * a continue offer waits for an answer; it too lives only in memory;
|
|
16
|
+
# * less than the timeout has passed since the worker started, the Engine's
|
|
17
|
+
# last activity, or the last client request or disconnect.
|
|
18
|
+
#
|
|
19
|
+
# A client can also ask the worker to exit now (`/exit` in the attached
|
|
20
|
+
# TUI, Bridge POST /exit): #hold_for_request applies the same rules without
|
|
21
|
+
# the timeout and leaves out the asking client's own stream.
|
|
22
|
+
class WorkerIdleExit
|
|
23
|
+
# @param engine [Engine] #turn_running?, #last_activity_at, #reminder_store
|
|
24
|
+
# @param bridge [Bridge, nil] #open_streams, #last_client_activity_at; nil
|
|
25
|
+
# when the worker's Bridge failed to start
|
|
26
|
+
# @param timeout_minutes [Numeric, nil] 0 or nil: never exit
|
|
27
|
+
# @param input_pending [#call] true while input files wait
|
|
28
|
+
# @param awaiting_continue [#call] true while a continue offer waits
|
|
29
|
+
# @param clock [#call] monotonic seconds, the Engine's and Bridge's clock
|
|
30
|
+
def initialize(engine:, bridge:, timeout_minutes:, input_pending:, awaiting_continue: -> { false },
|
|
31
|
+
clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) })
|
|
32
|
+
@engine = engine
|
|
33
|
+
@bridge = bridge
|
|
34
|
+
@timeout = timeout_minutes.to_f * 60
|
|
35
|
+
@input_pending = input_pending
|
|
36
|
+
@awaiting_continue = awaiting_continue
|
|
37
|
+
@clock = clock
|
|
38
|
+
@started_at = clock.call
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @return [Boolean] whether the worker should exit now
|
|
42
|
+
def due?
|
|
43
|
+
hold.nil?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# What keeps the worker up, or nil when nothing does.
|
|
47
|
+
# @return [Symbol, nil] :disabled, :turn_running, :input_queued,
|
|
48
|
+
# :continue_offered, :client_connected, :reminders or :recent_activity
|
|
49
|
+
def hold
|
|
50
|
+
return :disabled unless @timeout.positive?
|
|
51
|
+
return :turn_running if @engine.turn_running?
|
|
52
|
+
return :input_queued if @input_pending.call
|
|
53
|
+
return :continue_offered if @awaiting_continue.call
|
|
54
|
+
return :client_connected if @bridge && @bridge.open_streams.positive?
|
|
55
|
+
return :reminders if @engine.reminder_store&.any?
|
|
56
|
+
return :recent_activity if idle_seconds < @timeout
|
|
57
|
+
|
|
58
|
+
nil
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# What keeps the worker up when a client asks it to exit now, or nil
|
|
62
|
+
# when nothing does. The timeout doesn't apply, even 0 ("never idle
|
|
63
|
+
# out"): the request is explicit.
|
|
64
|
+
# @param requester [String, nil] the asking client's id; its own streams
|
|
65
|
+
# don't hold
|
|
66
|
+
# @param streams [Boolean] false: other clients' streams don't hold
|
|
67
|
+
# either (the last check before leaving, when the asker's stream may
|
|
68
|
+
# still be open, untagged)
|
|
69
|
+
# @return [Symbol, nil] :turn_running, :input_queued, :continue_offered,
|
|
70
|
+
# :client_connected or :reminders
|
|
71
|
+
def hold_for_request(requester:, streams: true)
|
|
72
|
+
return :turn_running if @engine.turn_running?
|
|
73
|
+
return :input_queued if @input_pending.call
|
|
74
|
+
return :continue_offered if @awaiting_continue.call
|
|
75
|
+
return :client_connected if streams && @bridge && @bridge.open_streams_except(requester).positive?
|
|
76
|
+
return :reminders if @engine.reminder_store&.any?
|
|
77
|
+
|
|
78
|
+
nil
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# @return [Float] seconds since the latest activity of any kind
|
|
82
|
+
def idle_seconds
|
|
83
|
+
last = [@started_at, @engine.last_activity_at, @bridge&.last_client_activity_at].compact.max
|
|
84
|
+
@clock.call - last
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
data/lib/samagotchi.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "samagotchi/config"
|
|
4
|
+
require_relative "samagotchi/context_usage"
|
|
5
|
+
require_relative "samagotchi/model_profile"
|
|
6
|
+
require_relative "samagotchi/prompt"
|
|
7
|
+
require_relative "samagotchi/client"
|
|
8
|
+
require_relative "samagotchi/debug_log"
|
|
9
|
+
require_relative "samagotchi/pending_input_queue"
|
|
10
|
+
require_relative "samagotchi/kernel_loop"
|
|
11
|
+
require_relative "samagotchi/session"
|
|
12
|
+
require_relative "samagotchi/terminal_ui"
|
metadata
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: samagotchi
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Dmitry Dedov
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: reline
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.6.3
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 0.6.3
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: json
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.9'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '2.9'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: nokogiri
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rack
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '2.0'
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '2.0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: rackup
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
type: :runtime
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: webrick
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
type: :runtime
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
description: chi is an agent harness for local and OpenAI-compatible models (llama.cpp,
|
|
97
|
+
mlx, oMLX, hosted APIs). It runs sessions in a terminal REPL or in background workers
|
|
98
|
+
you can attach to from the terminal and a web UI, keeps memories in plain files
|
|
99
|
+
shared as bundles, and extends through hooks, guardrails, plugins and MCP servers.
|
|
100
|
+
email:
|
|
101
|
+
- me@dmitry.it
|
|
102
|
+
executables:
|
|
103
|
+
- chi
|
|
104
|
+
extensions: []
|
|
105
|
+
extra_rdoc_files: []
|
|
106
|
+
files:
|
|
107
|
+
- CHANGELOG.md
|
|
108
|
+
- LICENSE
|
|
109
|
+
- README.md
|
|
110
|
+
- bin/chi
|
|
111
|
+
- docs/architecture.md
|
|
112
|
+
- docs/cli.md
|
|
113
|
+
- docs/configuration.md
|
|
114
|
+
- docs/desktop.md
|
|
115
|
+
- docs/guardrails.md
|
|
116
|
+
- docs/hooks.md
|
|
117
|
+
- docs/internals/background-tasks.md
|
|
118
|
+
- docs/internals/context-telemetry.md
|
|
119
|
+
- docs/internals/gemma4-contract.md
|
|
120
|
+
- docs/internals/tool-guardrails.md
|
|
121
|
+
- docs/memory.md
|
|
122
|
+
- docs/plugins.md
|
|
123
|
+
- docs/releasing.md
|
|
124
|
+
- docs/sessions.md
|
|
125
|
+
- lib/samagotchi.rb
|
|
126
|
+
- lib/samagotchi/bridge.rb
|
|
127
|
+
- lib/samagotchi/bridge/bounded_queue.rb
|
|
128
|
+
- lib/samagotchi/bridge/card_store.rb
|
|
129
|
+
- lib/samagotchi/bridge/event_id.rb
|
|
130
|
+
- lib/samagotchi/bridge/ring_buffer.rb
|
|
131
|
+
- lib/samagotchi/bridge/sse_writer.rb
|
|
132
|
+
- lib/samagotchi/bridge/turn_accumulator.rb
|
|
133
|
+
- lib/samagotchi/bridge_client.rb
|
|
134
|
+
- lib/samagotchi/bridge_client/event_stream.rb
|
|
135
|
+
- lib/samagotchi/bridge_client/sse_parser.rb
|
|
136
|
+
- lib/samagotchi/bundle_needs.rb
|
|
137
|
+
- lib/samagotchi/bundles/btw/manifest.yml
|
|
138
|
+
- lib/samagotchi/bundles/btw/plugin.rb
|
|
139
|
+
- lib/samagotchi/bundles/guardrails/guardrails.md
|
|
140
|
+
- lib/samagotchi/bundles/guardrails/guardrails/rules.yml
|
|
141
|
+
- lib/samagotchi/bundles/guardrails/manifest.yml
|
|
142
|
+
- lib/samagotchi/bundles/known-names/hooks/known_names.rb
|
|
143
|
+
- lib/samagotchi/bundles/known-names/known_names.md
|
|
144
|
+
- lib/samagotchi/bundles/known-names/manifest.yml
|
|
145
|
+
- lib/samagotchi/bundles/loop-guard/manifest.yml
|
|
146
|
+
- lib/samagotchi/bundles/loop-guard/plugin.rb
|
|
147
|
+
- lib/samagotchi/bundles/mcp/manifest.yml
|
|
148
|
+
- lib/samagotchi/bundles/mcp/plugin.rb
|
|
149
|
+
- lib/samagotchi/bundles/system/config_modification_protocol.md
|
|
150
|
+
- lib/samagotchi/bundles/system/delegated.md
|
|
151
|
+
- lib/samagotchi/bundles/system/identity.md
|
|
152
|
+
- lib/samagotchi/bundles/system/manifest.yml
|
|
153
|
+
- lib/samagotchi/bundles/system/memory_guide.md
|
|
154
|
+
- lib/samagotchi/bundles/system/self_map.md
|
|
155
|
+
- lib/samagotchi/cancellation_controller.rb
|
|
156
|
+
- lib/samagotchi/client.rb
|
|
157
|
+
- lib/samagotchi/commands/registry.rb
|
|
158
|
+
- lib/samagotchi/config.rb
|
|
159
|
+
- lib/samagotchi/context_note.rb
|
|
160
|
+
- lib/samagotchi/context_quote.rb
|
|
161
|
+
- lib/samagotchi/context_usage.rb
|
|
162
|
+
- lib/samagotchi/context_window.rb
|
|
163
|
+
- lib/samagotchi/debug_log.rb
|
|
164
|
+
- lib/samagotchi/desktop.rb
|
|
165
|
+
- lib/samagotchi/desktop/macos.rb
|
|
166
|
+
- lib/samagotchi/desktop/macos/App.swift
|
|
167
|
+
- lib/samagotchi/desktop/macos/ChiRunner.swift
|
|
168
|
+
- lib/samagotchi/desktop/macos/Hotkey.swift
|
|
169
|
+
- lib/samagotchi/desktop/macos/Info.plist.erb
|
|
170
|
+
- lib/samagotchi/desktop/macos/Panel.swift
|
|
171
|
+
- lib/samagotchi/desktop_command.rb
|
|
172
|
+
- lib/samagotchi/engine.rb
|
|
173
|
+
- lib/samagotchi/guardrails.rb
|
|
174
|
+
- lib/samagotchi/guardrails/approval.rb
|
|
175
|
+
- lib/samagotchi/guardrails/approvals.rb
|
|
176
|
+
- lib/samagotchi/guardrails/context.rb
|
|
177
|
+
- lib/samagotchi/guardrails/gate.rb
|
|
178
|
+
- lib/samagotchi/guardrails/load_failures.rb
|
|
179
|
+
- lib/samagotchi/guardrails/protected_paths.rb
|
|
180
|
+
- lib/samagotchi/guardrails/rules.rb
|
|
181
|
+
- lib/samagotchi/guardrails/targets.rb
|
|
182
|
+
- lib/samagotchi/guardrails/verdict.rb
|
|
183
|
+
- lib/samagotchi/hooks.rb
|
|
184
|
+
- lib/samagotchi/hooks/bundle_loader.rb
|
|
185
|
+
- lib/samagotchi/hooks/loader.rb
|
|
186
|
+
- lib/samagotchi/hooks/registry.rb
|
|
187
|
+
- lib/samagotchi/host_registry.rb
|
|
188
|
+
- lib/samagotchi/idle_client.rb
|
|
189
|
+
- lib/samagotchi/idle_recap.rb
|
|
190
|
+
- lib/samagotchi/idle_reminders.rb
|
|
191
|
+
- lib/samagotchi/idle_scheduler.rb
|
|
192
|
+
- lib/samagotchi/image_store.rb
|
|
193
|
+
- lib/samagotchi/installed_gem.rb
|
|
194
|
+
- lib/samagotchi/kernel_loop.rb
|
|
195
|
+
- lib/samagotchi/launch_mode.rb
|
|
196
|
+
- lib/samagotchi/llm/backend.rb
|
|
197
|
+
- lib/samagotchi/llm/chat_loop.rb
|
|
198
|
+
- lib/samagotchi/llm/errors.rb
|
|
199
|
+
- lib/samagotchi/llm/http.rb
|
|
200
|
+
- lib/samagotchi/llm/model_result.rb
|
|
201
|
+
- lib/samagotchi/llm/native_backend.rb
|
|
202
|
+
- lib/samagotchi/llm/native_tool_normalizer.rb
|
|
203
|
+
- lib/samagotchi/llm/openai_chat.rb
|
|
204
|
+
- lib/samagotchi/llm/usage.rb
|
|
205
|
+
- lib/samagotchi/log.rb
|
|
206
|
+
- lib/samagotchi/log_line.rb
|
|
207
|
+
- lib/samagotchi/log_path.rb
|
|
208
|
+
- lib/samagotchi/log_subscriber.rb
|
|
209
|
+
- lib/samagotchi/memory_bundle.rb
|
|
210
|
+
- lib/samagotchi/memory_bundle/builder.rb
|
|
211
|
+
- lib/samagotchi/memory_bundle/index_updater.rb
|
|
212
|
+
- lib/samagotchi/memory_bundle/installer.rb
|
|
213
|
+
- lib/samagotchi/memory_bundle/listing.rb
|
|
214
|
+
- lib/samagotchi/memory_bundle/manifest.rb
|
|
215
|
+
- lib/samagotchi/memory_bundle/merger.rb
|
|
216
|
+
- lib/samagotchi/memory_bundle/placeholder.rb
|
|
217
|
+
- lib/samagotchi/memory_bundle/provenance.rb
|
|
218
|
+
- lib/samagotchi/memory_bundle/source.rb
|
|
219
|
+
- lib/samagotchi/memory_bundle/status.rb
|
|
220
|
+
- lib/samagotchi/memory_bundle/system_bundle.rb
|
|
221
|
+
- lib/samagotchi/memory_bundle/uninstaller.rb
|
|
222
|
+
- lib/samagotchi/memory_paths.rb
|
|
223
|
+
- lib/samagotchi/model_overlay.rb
|
|
224
|
+
- lib/samagotchi/model_profile.rb
|
|
225
|
+
- lib/samagotchi/muted_memories.rb
|
|
226
|
+
- lib/samagotchi/note_command.rb
|
|
227
|
+
- lib/samagotchi/output_formatter.rb
|
|
228
|
+
- lib/samagotchi/owner_lock.rb
|
|
229
|
+
- lib/samagotchi/pending_input_queue.rb
|
|
230
|
+
- lib/samagotchi/plugin/api.rb
|
|
231
|
+
- lib/samagotchi/plugin/context.rb
|
|
232
|
+
- lib/samagotchi/plugin/loader.rb
|
|
233
|
+
- lib/samagotchi/plugin/service.rb
|
|
234
|
+
- lib/samagotchi/plugin/sessions.rb
|
|
235
|
+
- lib/samagotchi/plugin/side_question.rb
|
|
236
|
+
- lib/samagotchi/plugin/tool_result.rb
|
|
237
|
+
- lib/samagotchi/project_scope.rb
|
|
238
|
+
- lib/samagotchi/prompt.rb
|
|
239
|
+
- lib/samagotchi/prompt_literal_guard.rb
|
|
240
|
+
- lib/samagotchi/recap_store.rb
|
|
241
|
+
- lib/samagotchi/reminder_store.rb
|
|
242
|
+
- lib/samagotchi/self_report.rb
|
|
243
|
+
- lib/samagotchi/send_command.rb
|
|
244
|
+
- lib/samagotchi/served_model.rb
|
|
245
|
+
- lib/samagotchi/session.rb
|
|
246
|
+
- lib/samagotchi/session_commands.rb
|
|
247
|
+
- lib/samagotchi/session_delete_command.rb
|
|
248
|
+
- lib/samagotchi/session_manager.rb
|
|
249
|
+
- lib/samagotchi/session_metrics.rb
|
|
250
|
+
- lib/samagotchi/session_observer.rb
|
|
251
|
+
- lib/samagotchi/terminal_ui.rb
|
|
252
|
+
- lib/samagotchi/terminal_ui/attach_launcher.rb
|
|
253
|
+
- lib/samagotchi/terminal_ui/attached_loop.rb
|
|
254
|
+
- lib/samagotchi/terminal_ui/attached_view.rb
|
|
255
|
+
- lib/samagotchi/terminal_ui/event_renderer.rb
|
|
256
|
+
- lib/samagotchi/terminal_ui/formatting.rb
|
|
257
|
+
- lib/samagotchi/terminal_ui/image_input.rb
|
|
258
|
+
- lib/samagotchi/terminal_ui/input_support.rb
|
|
259
|
+
- lib/samagotchi/terminal_ui/legacy_surface.rb
|
|
260
|
+
- lib/samagotchi/terminal_ui/line_reader.rb
|
|
261
|
+
- lib/samagotchi/terminal_ui/live_region.rb
|
|
262
|
+
- lib/samagotchi/terminal_ui/plain_surface.rb
|
|
263
|
+
- lib/samagotchi/terminal_ui/question_prompt.rb
|
|
264
|
+
- lib/samagotchi/terminal_ui/question_slot.rb
|
|
265
|
+
- lib/samagotchi/terminal_ui/reline_seam.rb
|
|
266
|
+
- lib/samagotchi/terminal_ui/repl_input.rb
|
|
267
|
+
- lib/samagotchi/terminal_ui/screen.rb
|
|
268
|
+
- lib/samagotchi/terminal_ui/surface.rb
|
|
269
|
+
- lib/samagotchi/terminal_ui/thinking_line.rb
|
|
270
|
+
- lib/samagotchi/thinking_ticker.rb
|
|
271
|
+
- lib/samagotchi/thought_stream_splitter.rb
|
|
272
|
+
- lib/samagotchi/token_usage.rb
|
|
273
|
+
- lib/samagotchi/tool_activity.rb
|
|
274
|
+
- lib/samagotchi/tool_call_parser.rb
|
|
275
|
+
- lib/samagotchi/tool_declarations.rb
|
|
276
|
+
- lib/samagotchi/tool_runner.rb
|
|
277
|
+
- lib/samagotchi/tools/args.rb
|
|
278
|
+
- lib/samagotchi/tools/ask_user_question.rb
|
|
279
|
+
- lib/samagotchi/tools/builtins.rb
|
|
280
|
+
- lib/samagotchi/tools/cancel_reminder.rb
|
|
281
|
+
- lib/samagotchi/tools/delegate.rb
|
|
282
|
+
- lib/samagotchi/tools/delegate_result.rb
|
|
283
|
+
- lib/samagotchi/tools/delegate_wait.rb
|
|
284
|
+
- lib/samagotchi/tools/edit.rb
|
|
285
|
+
- lib/samagotchi/tools/execute.rb
|
|
286
|
+
- lib/samagotchi/tools/list_reminders.rb
|
|
287
|
+
- lib/samagotchi/tools/list_sessions.rb
|
|
288
|
+
- lib/samagotchi/tools/memory.rb
|
|
289
|
+
- lib/samagotchi/tools/output_guardrails.rb
|
|
290
|
+
- lib/samagotchi/tools/peers.rb
|
|
291
|
+
- lib/samagotchi/tools/read.rb
|
|
292
|
+
- lib/samagotchi/tools/register_reminder.rb
|
|
293
|
+
- lib/samagotchi/tools/registry.rb
|
|
294
|
+
- lib/samagotchi/tools/send_note.rb
|
|
295
|
+
- lib/samagotchi/tools/task_create.rb
|
|
296
|
+
- lib/samagotchi/tools/task_get.rb
|
|
297
|
+
- lib/samagotchi/tools/task_list.rb
|
|
298
|
+
- lib/samagotchi/tools/task_runtime.rb
|
|
299
|
+
- lib/samagotchi/tools/task_stop.rb
|
|
300
|
+
- lib/samagotchi/tools/task_wait.rb
|
|
301
|
+
- lib/samagotchi/tools/tool_path.rb
|
|
302
|
+
- lib/samagotchi/tools/web_fetch.rb
|
|
303
|
+
- lib/samagotchi/tools/write.rb
|
|
304
|
+
- lib/samagotchi/turn_flow.rb
|
|
305
|
+
- lib/samagotchi/turn_note.rb
|
|
306
|
+
- lib/samagotchi/turn_tally.rb
|
|
307
|
+
- lib/samagotchi/version.rb
|
|
308
|
+
- lib/samagotchi/vision_context.rb
|
|
309
|
+
- lib/samagotchi/vision_support.rb
|
|
310
|
+
- lib/samagotchi/web/app.rb
|
|
311
|
+
- lib/samagotchi/web/markdown_renderer.rb
|
|
312
|
+
- lib/samagotchi/web/message_parts.rb
|
|
313
|
+
- lib/samagotchi/web/public/activity.js
|
|
314
|
+
- lib/samagotchi/web/public/annotations.js
|
|
315
|
+
- lib/samagotchi/web/public/app.js
|
|
316
|
+
- lib/samagotchi/web/public/card.js
|
|
317
|
+
- lib/samagotchi/web/public/chat_view.js
|
|
318
|
+
- lib/samagotchi/web/public/chunk_router.js
|
|
319
|
+
- lib/samagotchi/web/public/command_complete.js
|
|
320
|
+
- lib/samagotchi/web/public/composer_size.js
|
|
321
|
+
- lib/samagotchi/web/public/copy.js
|
|
322
|
+
- lib/samagotchi/web/public/ctx.js
|
|
323
|
+
- lib/samagotchi/web/public/data.js
|
|
324
|
+
- lib/samagotchi/web/public/format.js
|
|
325
|
+
- lib/samagotchi/web/public/hold.js
|
|
326
|
+
- lib/samagotchi/web/public/images.js
|
|
327
|
+
- lib/samagotchi/web/public/index.html
|
|
328
|
+
- lib/samagotchi/web/public/init_row.js
|
|
329
|
+
- lib/samagotchi/web/public/model_pick.js
|
|
330
|
+
- lib/samagotchi/web/public/question_card.js
|
|
331
|
+
- lib/samagotchi/web/public/route.js
|
|
332
|
+
- lib/samagotchi/web/public/scope.js
|
|
333
|
+
- lib/samagotchi/web/public/scroll.js
|
|
334
|
+
- lib/samagotchi/web/public/sentences.js
|
|
335
|
+
- lib/samagotchi/web/public/sessions_list.js
|
|
336
|
+
- lib/samagotchi/web/public/strip.js
|
|
337
|
+
- lib/samagotchi/web/public/tally.js
|
|
338
|
+
- lib/samagotchi/web/public/thinking_ticker.js
|
|
339
|
+
- lib/samagotchi/web/public/timing.js
|
|
340
|
+
- lib/samagotchi/web/public/turn_events.js
|
|
341
|
+
- lib/samagotchi/web/public/turn_model.js
|
|
342
|
+
- lib/samagotchi/web/public/turn_view.js
|
|
343
|
+
- lib/samagotchi/web/server.rb
|
|
344
|
+
- lib/samagotchi/web/session_hub.rb
|
|
345
|
+
- lib/samagotchi/web/session_summary.rb
|
|
346
|
+
- lib/samagotchi/worker.rb
|
|
347
|
+
- lib/samagotchi/worker_idle_exit.rb
|
|
348
|
+
homepage: https://github.com/dm1try/samagotchi
|
|
349
|
+
licenses:
|
|
350
|
+
- MIT
|
|
351
|
+
metadata:
|
|
352
|
+
source_code_uri: https://github.com/dm1try/samagotchi
|
|
353
|
+
changelog_uri: https://github.com/dm1try/samagotchi/blob/main/CHANGELOG.md
|
|
354
|
+
bug_tracker_uri: https://github.com/dm1try/samagotchi/issues
|
|
355
|
+
allowed_push_host: https://rubygems.org
|
|
356
|
+
rubygems_mfa_required: 'true'
|
|
357
|
+
rdoc_options: []
|
|
358
|
+
require_paths:
|
|
359
|
+
- lib
|
|
360
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
361
|
+
requirements:
|
|
362
|
+
- - ">="
|
|
363
|
+
- !ruby/object:Gem::Version
|
|
364
|
+
version: '3.3'
|
|
365
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
366
|
+
requirements:
|
|
367
|
+
- - ">="
|
|
368
|
+
- !ruby/object:Gem::Version
|
|
369
|
+
version: '0'
|
|
370
|
+
requirements: []
|
|
371
|
+
rubygems_version: 3.6.9
|
|
372
|
+
specification_version: 4
|
|
373
|
+
summary: 'chi: a local-first coding agent with memory, sessions and a web UI'
|
|
374
|
+
test_files: []
|