samagotchi 0.34.0 → 0.35.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 +45 -1
- data/README.md +2 -0
- data/bin/chi +3 -0
- data/docs/broadcast.md +129 -0
- data/docs/cli.md +8 -0
- data/docs/configuration.md +2 -0
- data/docs/guardrails.md +4 -2
- data/docs/hooks.md +24 -3
- data/docs/plugins.md +1 -1
- data/docs/sessions.md +6 -6
- data/lib/samagotchi/bridge/card_store.rb +1 -1
- data/lib/samagotchi/bridge/turn_notice.rb +1 -1
- data/lib/samagotchi/broadcast/recipients.rb +63 -0
- data/lib/samagotchi/broadcast/scope_card.rb +94 -0
- data/lib/samagotchi/broadcast/tags.rb +154 -0
- data/lib/samagotchi/broadcast_command.rb +228 -0
- data/lib/samagotchi/bundles/guardrails/guardrails/rules.yml +11 -0
- data/lib/samagotchi/bundles/guardrails/manifest.yml +2 -2
- data/lib/samagotchi/bundles/source-links/hooks/source_links.rb +32 -12
- data/lib/samagotchi/bundles/source-links/manifest.yml +4 -3
- data/lib/samagotchi/bundles/source-links/source_links.md +1 -1
- data/lib/samagotchi/bundles/system/manifest.yml +2 -2
- data/lib/samagotchi/bundles/system/self_map.md +4 -0
- data/lib/samagotchi/children_status.rb +2 -16
- data/lib/samagotchi/config.rb +6 -0
- data/lib/samagotchi/engine.rb +29 -5
- data/lib/samagotchi/git_head.rb +24 -0
- data/lib/samagotchi/guardrails/verdict.rb +4 -3
- data/lib/samagotchi/hooks/registry.rb +11 -5
- data/lib/samagotchi/log_subscriber.rb +1 -1
- data/lib/samagotchi/note_command.rb +13 -13
- data/lib/samagotchi/note_delivery.rb +42 -0
- data/lib/samagotchi/plugin/context.rb +4 -4
- data/lib/samagotchi/session_manager.rb +4 -3
- data/lib/samagotchi/sessions_command.rb +3 -2
- data/lib/samagotchi/system_prompt.rb +1 -0
- data/lib/samagotchi/terminal_ui/attached_loop.rb +25 -2
- data/lib/samagotchi/terminal_ui/status_row.rb +23 -2
- data/lib/samagotchi/terminal_ui.rb +14 -0
- data/lib/samagotchi/tools/send_note.rb +5 -11
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +3 -0
- data/lib/samagotchi/web/capabilities.rb +19 -0
- data/lib/samagotchi/web/public/activity.js +26 -6
- data/lib/samagotchi/web/public/app.js +515 -288
- data/lib/samagotchi/web/public/card.js +12 -3
- data/lib/samagotchi/web/public/command_view.js +2 -3
- data/lib/samagotchi/web/public/families_view.js +171 -0
- data/lib/samagotchi/web/public/format.js +52 -0
- data/lib/samagotchi/web/public/index.html +94 -21
- data/lib/samagotchi/web/public/live_timing.js +154 -0
- data/lib/samagotchi/web/public/live_turn.js +44 -0
- data/lib/samagotchi/web/public/sessions_list.js +228 -32
- data/lib/samagotchi/web/public/strip.js +5 -2
- data/lib/samagotchi/web/public/turn_html.js +107 -0
- data/lib/samagotchi/web/public/turn_model.js +5 -4
- data/lib/samagotchi/web/public/turn_view.js +43 -129
- data/lib/samagotchi/web/session_summary.rb +4 -0
- data/lib/samagotchi/worker.rb +166 -307
- data/lib/samagotchi/worker_inbound.rb +251 -0
- data/lib/samagotchi/worker_wakes.rb +120 -0
- metadata +15 -1
|
@@ -39,8 +39,10 @@ export function rowKey(iteration, callIndex) {
|
|
|
39
39
|
|
|
40
40
|
// Upsert a row from a :tool_call_started event. Returns { row, created }.
|
|
41
41
|
// If a row with the same key already exists (duplicate start), it is reset to
|
|
42
|
-
// running and updated rather than duplicated.
|
|
43
|
-
|
|
42
|
+
// running and updated rather than duplicated. +now+ (ms): when the page saw
|
|
43
|
+
// the call start, for its duration; none for an event a re-render replays
|
|
44
|
+
// (`replayed`: the call started before the page looked).
|
|
45
|
+
export function addStarted(model, event = {}, now = null) {
|
|
44
46
|
const iteration = event.iteration ?? 0;
|
|
45
47
|
const callIndex = event.call_index ?? 0;
|
|
46
48
|
const key = rowKey(iteration, callIndex);
|
|
@@ -52,6 +54,7 @@ export function addStarted(model, event = {}) {
|
|
|
52
54
|
row.params = event.params || row.params;
|
|
53
55
|
row.title = event.title || row.title;
|
|
54
56
|
row.view = event.view || row.view;
|
|
57
|
+
markStart(row, event, now);
|
|
55
58
|
return { row, created: false };
|
|
56
59
|
}
|
|
57
60
|
row = {
|
|
@@ -72,14 +75,23 @@ export function addStarted(model, event = {}) {
|
|
|
72
75
|
output: "",
|
|
73
76
|
output_truncated: false,
|
|
74
77
|
};
|
|
78
|
+
markStart(row, event, now);
|
|
75
79
|
model.rows.push(row);
|
|
76
80
|
return { row, created: true };
|
|
77
81
|
}
|
|
78
82
|
|
|
83
|
+
function markStart(row, event, now) {
|
|
84
|
+
if (now !== null && !event.replayed) row.startedAt = now;
|
|
85
|
+
else delete row.startedAt;
|
|
86
|
+
}
|
|
87
|
+
|
|
79
88
|
// Update (or synthesize) a row from a :tool_call_completed event. Returns the row.
|
|
80
89
|
// If no matching :tool_call_started was seen (e.g. a replay gap), a row is
|
|
81
|
-
// created on the fly so the completion is never lost.
|
|
82
|
-
|
|
90
|
+
// created on the fly so the completion is never lost. Its duration
|
|
91
|
+
// (duration_ms, as a reloaded row has it from the tool record): a
|
|
92
|
+
// snapshot's own, else from the start the page saw to +now+, less the time
|
|
93
|
+
// the call waited for an approval (waited_ms), as the worker times it.
|
|
94
|
+
export function addCompleted(model, event = {}, now = null) {
|
|
83
95
|
const iteration = event.iteration ?? 0;
|
|
84
96
|
const callIndex = event.call_index ?? 0;
|
|
85
97
|
const key = rowKey(iteration, callIndex);
|
|
@@ -102,14 +114,22 @@ export function addCompleted(model, event = {}) {
|
|
|
102
114
|
if (event.activity?.params) row.params = event.activity.params;
|
|
103
115
|
if (event.activity?.title) row.title = event.activity.title;
|
|
104
116
|
// The images the tool returned (a reload in the turn view draws them from
|
|
105
|
-
// the saved parts,
|
|
117
|
+
// the saved parts, turn_html.js toolRowHtml).
|
|
106
118
|
if (event.images?.length) row.images = event.images;
|
|
107
119
|
// What an edit/write changed in its file (a reload draws it from the
|
|
108
|
-
// saved parts,
|
|
120
|
+
// saved parts, turn_html.js toolRowHtml).
|
|
109
121
|
if (event.diff) row.diff = event.diff;
|
|
122
|
+
const duration = callDuration(row, event, now);
|
|
123
|
+
if (duration !== null) row.duration_ms = duration;
|
|
110
124
|
return row;
|
|
111
125
|
}
|
|
112
126
|
|
|
127
|
+
function callDuration(row, event, now) {
|
|
128
|
+
if (event.duration_ms != null) return event.duration_ms;
|
|
129
|
+
if (row.startedAt == null || now === null || event.replayed) return null;
|
|
130
|
+
return Math.max(0, now - row.startedAt - (Number(event.waited_ms) || 0));
|
|
131
|
+
}
|
|
132
|
+
|
|
113
133
|
// A completed call's row status from the server's: error, stopped,
|
|
114
134
|
// blocked, else ok.
|
|
115
135
|
export function completedStatus(status) {
|