samagotchi 0.23.0 → 0.25.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 +93 -1
- data/docs/architecture.md +16 -9
- data/docs/cli.md +10 -4
- data/docs/configuration.md +30 -13
- data/docs/hooks.md +21 -7
- data/docs/internals/background-tasks.md +1 -0
- data/docs/internals/prompt-caching.md +94 -0
- data/docs/plugins.md +17 -3
- data/docs/sub-agent.md +4 -3
- data/docs/testing.md +12 -0
- data/lib/samagotchi/bridge/card_store.rb +4 -3
- data/lib/samagotchi/bridge/turn_accumulator.rb +4 -1
- data/lib/samagotchi/bridge/turn_notice.rb +1 -0
- data/lib/samagotchi/bridge.rb +7 -0
- data/lib/samagotchi/bundles/check-in/manifest.yml +2 -2
- data/lib/samagotchi/bundles/check-in/plugin.rb +2 -1
- data/lib/samagotchi/bundles/loop-guard/manifest.yml +2 -2
- data/lib/samagotchi/bundles/loop-guard/plugin.rb +43 -7
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/command_steps.rb +233 -0
- data/lib/samagotchi/config.rb +9 -2
- data/lib/samagotchi/empty_answer_retry.rb +2 -2
- data/lib/samagotchi/engine.rb +103 -5
- data/lib/samagotchi/generation_phase.rb +83 -0
- data/lib/samagotchi/guardrails/shell_lex.rb +158 -6
- data/lib/samagotchi/guardrails/shell_paths.rb +1 -1
- data/lib/samagotchi/idle_client.rb +14 -2
- data/lib/samagotchi/idle_recap.rb +4 -2
- data/lib/samagotchi/kernel_loop.rb +40 -12
- data/lib/samagotchi/llm/chat_loop.rb +37 -13
- data/lib/samagotchi/llm/errors.rb +26 -1
- data/lib/samagotchi/llm/openai_chat.rb +8 -4
- data/lib/samagotchi/llm/prompt_cache.rb +34 -9
- data/lib/samagotchi/llm/usage.rb +18 -3
- data/lib/samagotchi/log_subscriber.rb +5 -3
- data/lib/samagotchi/plugin/api.rb +3 -2
- data/lib/samagotchi/prompt.rb +4 -1
- data/lib/samagotchi/session_metrics.rb +38 -4
- data/lib/samagotchi/steer.rb +103 -8
- data/lib/samagotchi/system_prompt.rb +30 -9
- data/lib/samagotchi/terminal_ui/attached_loop.rb +6 -3
- data/lib/samagotchi/terminal_ui/attached_view.rb +6 -2
- data/lib/samagotchi/terminal_ui/event_renderer.rb +17 -2
- data/lib/samagotchi/terminal_ui/formatting.rb +40 -9
- data/lib/samagotchi/terminal_ui/one_shot_sink.rb +1 -0
- data/lib/samagotchi/terminal_ui.rb +5 -0
- data/lib/samagotchi/thinking_tails.rb +103 -0
- data/lib/samagotchi/thought_stream_splitter.rb +9 -3
- data/lib/samagotchi/token_usage.rb +18 -6
- data/lib/samagotchi/tool_activity.rb +37 -3
- data/lib/samagotchi/tool_declarations.rb +14 -0
- data/lib/samagotchi/tool_runner.rb +7 -0
- data/lib/samagotchi/tool_view.rb +76 -0
- data/lib/samagotchi/tools/builtins.rb +4 -1
- data/lib/samagotchi/tools/execute.rb +2 -1
- data/lib/samagotchi/tools/registry.rb +11 -4
- data/lib/samagotchi/tools/shell.rb +32 -0
- data/lib/samagotchi/tools/task_runtime.rb +3 -3
- data/lib/samagotchi/turn_tally.rb +17 -6
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/waiting_steer.rb +64 -0
- data/lib/samagotchi/web/message_parts.rb +5 -0
- data/lib/samagotchi/web/public/activity.js +5 -0
- data/lib/samagotchi/web/public/app.js +2 -1
- data/lib/samagotchi/web/public/command_view.js +96 -0
- data/lib/samagotchi/web/public/copy.js +7 -0
- data/lib/samagotchi/web/public/format.js +11 -1
- data/lib/samagotchi/web/public/index.html +33 -0
- data/lib/samagotchi/web/public/stage_model.js +16 -5
- data/lib/samagotchi/web/public/stage_view.js +5 -2
- data/lib/samagotchi/web/public/turn_events.js +15 -1
- data/lib/samagotchi/web/public/turn_view.js +15 -6
- data/lib/samagotchi/worker.rb +4 -1
- metadata +9 -1
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { toolName } from "./activity.js";
|
|
13
13
|
import { leavesBlock } from "./card.js";
|
|
14
14
|
import { copySourceAttr } from "./copy.js";
|
|
15
|
+
import { commandBlockHtml, rowHover } from "./command_view.js";
|
|
15
16
|
import { activityDiffHtml } from "./diff_view.js";
|
|
16
17
|
import { escapeHtml, messageBodyHtml, noteHtml, normalize, steerRowHtml } from "./format.js";
|
|
17
18
|
import { thumbsHtml } from "./images.js";
|
|
@@ -45,11 +46,17 @@ function fillActivityRow(el, row, sessionId) {
|
|
|
45
46
|
if (toolEl) toolEl.textContent = toolName(row);
|
|
46
47
|
const paramsEl = el.querySelector(".activity-params");
|
|
47
48
|
if (paramsEl) {
|
|
48
|
-
// The title in place of the params; the full
|
|
49
|
+
// The title in place of the params; the full command (else the full
|
|
50
|
+
// params line) on hover.
|
|
49
51
|
paramsEl.textContent = row.title || row.params || "";
|
|
50
|
-
paramsEl.title = row
|
|
52
|
+
paramsEl.title = rowHover(row);
|
|
51
53
|
}
|
|
52
54
|
const outEl = el.querySelector(".activity-output");
|
|
55
|
+
// The call's full command, above its output (running too).
|
|
56
|
+
if (row.view?.command && !el.querySelector(".activity-command")) {
|
|
57
|
+
if (outEl) outEl.insertAdjacentHTML("beforebegin", commandBlockHtml(row.view, row.title));
|
|
58
|
+
else el.insertAdjacentHTML("beforeend", commandBlockHtml(row.view, row.title));
|
|
59
|
+
}
|
|
53
60
|
if (outEl) {
|
|
54
61
|
if (row.status === "running") {
|
|
55
62
|
outEl.style.display = "none";
|
|
@@ -667,14 +674,15 @@ function defaultPlaceAnswer(appendToHistory) {
|
|
|
667
674
|
};
|
|
668
675
|
}
|
|
669
676
|
|
|
670
|
-
// A reloaded tool row, the live row's markup (fillActivityRow): status, tool, params,
|
|
671
|
-
// 300 chars, the rest on hover), plus the call's
|
|
677
|
+
// A reloaded tool row, the live row's markup (fillActivityRow): status, tool, params, the full command (an
|
|
678
|
+
// execute/task_create's view), output (its "[tool]" tag dropped, 300 chars, the rest on hover), plus the call's
|
|
679
|
+
// duration from its record.
|
|
672
680
|
// Params, output and the call's images come from the saved messages'
|
|
673
681
|
// parts; without them the row has the record's name, status and duration
|
|
674
682
|
// only. +thumbs(images)+ draws the images, as the live row does.
|
|
675
683
|
function reloadRowHtml(r, thumbs) {
|
|
676
684
|
const shown = r.title || r.params;
|
|
677
|
-
const hover = r
|
|
685
|
+
const hover = rowHover(r) ? ` title="${escapeHtml(rowHover(r))}"` : "";
|
|
678
686
|
const params = shown ? `<span class="activity-params"${hover}>${escapeHtml(shown)}</span>` : "";
|
|
679
687
|
const duration = formatDuration(r.duration_ms);
|
|
680
688
|
const full = String(r.output || "").replace(/^\[[^\]]*\]\s*/, "");
|
|
@@ -682,7 +690,8 @@ function reloadRowHtml(r, thumbs) {
|
|
|
682
690
|
? `<div class="activity-output" title="${escapeHtml(full)}">${escapeHtml(full.length > 300 ? `${full.slice(0, 300)}…` : full)}</div>`
|
|
683
691
|
: "";
|
|
684
692
|
return `<div class="activity-row" data-key="${escapeHtml(r.key)}"><span class="activity-status ${activityStatusClass(r.status)}">${activityStatusLabel(r.status)}</span>` +
|
|
685
|
-
`<span class="activity-tool">${escapeHtml(toolName(r))}</span>${params}${duration ? `<span class="activity-duration">${escapeHtml(duration)}</span>` : ""}
|
|
693
|
+
`<span class="activity-tool">${escapeHtml(toolName(r))}</span>${params}${duration ? `<span class="activity-duration">${escapeHtml(duration)}</span>` : ""}` +
|
|
694
|
+
`${commandBlockHtml(r.view, r.title)}${output}` +
|
|
686
695
|
`${r.images?.length ? thumbs(r.images) : ""}${r.diff ? activityDiffHtml(r.diff) : ""}</div>`;
|
|
687
696
|
}
|
|
688
697
|
|
data/lib/samagotchi/worker.rb
CHANGED
|
@@ -7,6 +7,7 @@ require_relative "session"
|
|
|
7
7
|
require_relative "session_inbox"
|
|
8
8
|
require_relative "turn_note"
|
|
9
9
|
require_relative "context_note"
|
|
10
|
+
require_relative "steer"
|
|
10
11
|
require_relative "worker_idle_exit"
|
|
11
12
|
require_relative "session_manager"
|
|
12
13
|
require_relative "archive_store"
|
|
@@ -571,7 +572,9 @@ module Samagotchi
|
|
|
571
572
|
@engine.announce(type: :input_merged, count: merged.size, origins: merged.filter_map(&:last))
|
|
572
573
|
@merged_this_turn.concat(merged)
|
|
573
574
|
end
|
|
574
|
-
|
|
575
|
+
# Each line keeps its sender (Steer.source_for_client): a chi send or
|
|
576
|
+
# a delegating parent's line is saved and shown to the model as theirs.
|
|
577
|
+
merged.map { |prompt, origin| Steer::Line.new(text: prompt, source: Steer.source_for_client(origin&.dig(:client_id))) }
|
|
575
578
|
end
|
|
576
579
|
end
|
|
577
580
|
|
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.25.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Dedov
|
|
@@ -131,6 +131,7 @@ files:
|
|
|
131
131
|
- docs/internals/background-tasks.md
|
|
132
132
|
- docs/internals/context-telemetry.md
|
|
133
133
|
- docs/internals/gemma4-contract.md
|
|
134
|
+
- docs/internals/prompt-caching.md
|
|
134
135
|
- docs/internals/tool-guardrails.md
|
|
135
136
|
- docs/memory.md
|
|
136
137
|
- docs/plugins.md
|
|
@@ -196,6 +197,7 @@ files:
|
|
|
196
197
|
- lib/samagotchi/cli/flags.rb
|
|
197
198
|
- lib/samagotchi/cli/parent_wait.rb
|
|
198
199
|
- lib/samagotchi/client.rb
|
|
200
|
+
- lib/samagotchi/command_steps.rb
|
|
199
201
|
- lib/samagotchi/commands/registry.rb
|
|
200
202
|
- lib/samagotchi/config.rb
|
|
201
203
|
- lib/samagotchi/config_text_edit.rb
|
|
@@ -223,6 +225,7 @@ files:
|
|
|
223
225
|
- lib/samagotchi/engine.rb
|
|
224
226
|
- lib/samagotchi/events.rb
|
|
225
227
|
- lib/samagotchi/gem_update.rb
|
|
228
|
+
- lib/samagotchi/generation_phase.rb
|
|
226
229
|
- lib/samagotchi/guardrail_wiring.rb
|
|
227
230
|
- lib/samagotchi/guardrails.rb
|
|
228
231
|
- lib/samagotchi/guardrails/approval.rb
|
|
@@ -372,6 +375,7 @@ files:
|
|
|
372
375
|
- lib/samagotchi/terminal_ui/version_lines.rb
|
|
373
376
|
- lib/samagotchi/text_diff.rb
|
|
374
377
|
- lib/samagotchi/thinking.rb
|
|
378
|
+
- lib/samagotchi/thinking_tails.rb
|
|
375
379
|
- lib/samagotchi/thinking_ticker.rb
|
|
376
380
|
- lib/samagotchi/thought_stream_splitter.rb
|
|
377
381
|
- lib/samagotchi/token_usage.rb
|
|
@@ -380,6 +384,7 @@ files:
|
|
|
380
384
|
- lib/samagotchi/tool_declarations.rb
|
|
381
385
|
- lib/samagotchi/tool_response.rb
|
|
382
386
|
- lib/samagotchi/tool_runner.rb
|
|
387
|
+
- lib/samagotchi/tool_view.rb
|
|
383
388
|
- lib/samagotchi/tools/args.rb
|
|
384
389
|
- lib/samagotchi/tools/ask_user_question.rb
|
|
385
390
|
- lib/samagotchi/tools/builtin_calls.rb
|
|
@@ -400,6 +405,7 @@ files:
|
|
|
400
405
|
- lib/samagotchi/tools/register_reminder.rb
|
|
401
406
|
- lib/samagotchi/tools/registry.rb
|
|
402
407
|
- lib/samagotchi/tools/send_note.rb
|
|
408
|
+
- lib/samagotchi/tools/shell.rb
|
|
403
409
|
- lib/samagotchi/tools/task_create.rb
|
|
404
410
|
- lib/samagotchi/tools/task_get.rb
|
|
405
411
|
- lib/samagotchi/tools/task_list.rb
|
|
@@ -420,6 +426,7 @@ files:
|
|
|
420
426
|
- lib/samagotchi/version.rb
|
|
421
427
|
- lib/samagotchi/vision_context.rb
|
|
422
428
|
- lib/samagotchi/vision_support.rb
|
|
429
|
+
- lib/samagotchi/waiting_steer.rb
|
|
423
430
|
- lib/samagotchi/web/app.rb
|
|
424
431
|
- lib/samagotchi/web/info_probe.rb
|
|
425
432
|
- lib/samagotchi/web/lan.rb
|
|
@@ -434,6 +441,7 @@ files:
|
|
|
434
441
|
- lib/samagotchi/web/public/chunk_router.js
|
|
435
442
|
- lib/samagotchi/web/public/command_complete.js
|
|
436
443
|
- lib/samagotchi/web/public/command_list.js
|
|
444
|
+
- lib/samagotchi/web/public/command_view.js
|
|
437
445
|
- lib/samagotchi/web/public/composer_size.js
|
|
438
446
|
- lib/samagotchi/web/public/copy.js
|
|
439
447
|
- lib/samagotchi/web/public/ctx.js
|