samagotchi 0.54.0 → 0.56.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 +50 -1
- data/bin/chi +3 -2
- data/docs/architecture.md +6 -2
- data/docs/cli.md +29 -7
- data/docs/configuration.md +113 -8
- data/docs/internals/background-tasks.md +1 -1
- data/docs/internals/context-telemetry.md +23 -5
- data/docs/internals/engine.md +54 -18
- data/docs/internals/prompt-caching.md +8 -0
- data/docs/sessions.md +2 -2
- data/docs/testing.md +23 -3
- data/lib/samagotchi/bridge/turn_accumulator.rb +6 -6
- data/lib/samagotchi/bundles/system/config_modification_protocol.md +1 -1
- data/lib/samagotchi/bundles/system/manifest.yml +2 -2
- data/lib/samagotchi/cache_confirm.rb +51 -0
- data/lib/samagotchi/client_id.rb +12 -0
- data/lib/samagotchi/config.rb +9 -3
- data/lib/samagotchi/engine.rb +102 -8
- data/lib/samagotchi/engine_peers.rb +1 -0
- data/lib/samagotchi/file_ref.rb +59 -0
- data/lib/samagotchi/host_config.rb +6 -3
- data/lib/samagotchi/host_registry.rb +4 -3
- data/lib/samagotchi/kernel_loop.rb +99 -16
- data/lib/samagotchi/llm/chat_loop.rb +122 -71
- data/lib/samagotchi/llm/openai_chat.rb +2 -1
- data/lib/samagotchi/llm/stream_drops.rb +63 -0
- data/lib/samagotchi/llm/turn_settings.rb +9 -5
- data/lib/samagotchi/model_settings.rb +5 -2
- data/lib/samagotchi/reasoning_history.rb +132 -0
- data/lib/samagotchi/reasoning_history_command.rb +107 -0
- data/lib/samagotchi/self_report.rb +21 -0
- data/lib/samagotchi/session.rb +23 -2
- data/lib/samagotchi/session_commands.rb +55 -15
- data/lib/samagotchi/session_manager.rb +2 -1
- data/lib/samagotchi/session_setup.rb +7 -5
- data/lib/samagotchi/setting_explained.rb +20 -0
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +2 -1
- data/lib/samagotchi/terminal_ui/attached_loop.rb +11 -0
- data/lib/samagotchi/terminal_ui/formatting.rb +8 -5
- data/lib/samagotchi/terminal_ui.rb +13 -6
- data/lib/samagotchi/thinking.rb +20 -25
- data/lib/samagotchi/thinking_command.rb +33 -11
- data/lib/samagotchi/tool_row_fields.rb +46 -0
- data/lib/samagotchi/tool_runner.rb +7 -11
- data/lib/samagotchi/tools/builtins.rb +6 -2
- data/lib/samagotchi/tools/peers.rb +4 -2
- data/lib/samagotchi/tools/task_runtime.rb +2 -1
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +48 -4
- data/lib/samagotchi/web/capabilities.rb +13 -9
- data/lib/samagotchi/web/editor.rb +38 -0
- data/lib/samagotchi/web/message_parts.rb +5 -10
- data/lib/samagotchi/web/public/activity.js +33 -18
- data/lib/samagotchi/web/public/app.js +256 -1133
- data/lib/samagotchi/web/public/commands.js +269 -0
- data/lib/samagotchi/web/public/composer.js +105 -0
- data/lib/samagotchi/web/public/diff_view.js +30 -4
- data/lib/samagotchi/web/public/index.html +11 -3
- data/lib/samagotchi/web/public/info_bar.js +80 -0
- data/lib/samagotchi/web/public/level_chip.js +174 -0
- data/lib/samagotchi/web/public/lists_view.js +725 -0
- data/lib/samagotchi/web/public/llm_context_chip.js +9 -6
- data/lib/samagotchi/web/public/model_pick.js +1 -1
- data/lib/samagotchi/web/public/question_cards.js +2 -1
- data/lib/samagotchi/web/public/reasoning_history_chip.js +49 -0
- data/lib/samagotchi/web/public/refs.js +134 -0
- data/lib/samagotchi/web/public/restore.js +81 -0
- data/lib/samagotchi/web/public/session_state.js +57 -0
- data/lib/samagotchi/web/public/stream_handlers.js +332 -0
- data/lib/samagotchi/web/public/thinking_chip.js +38 -144
- data/lib/samagotchi/web/public/turn_events.js +17 -258
- data/lib/samagotchi/web/public/turn_html.js +5 -1
- data/lib/samagotchi/web/server.rb +4 -4
- data/lib/samagotchi/worker.rb +17 -5
- metadata +18 -2
- data/lib/samagotchi/web/public/stable_html.js +0 -18
|
@@ -30,6 +30,32 @@ export function newActivity() {
|
|
|
30
30
|
return { rows: [] };
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// A row's fields beyond its params, as the server's ToolRowFields lists
|
|
34
|
+
// them; each list is copied in one place per path (addStarted, addCompleted's
|
|
35
|
+
// synthesized row, turn_events.js snapshotEvents), so a new field is added
|
|
36
|
+
// here. ACTIVITY_FIELDS: top-level on tool_call_started, inside `activity`
|
|
37
|
+
// on tool_call_completed. EVENT_FIELDS: top-level on both.
|
|
38
|
+
// title: what the call did in a few words (the server's tool title: a
|
|
39
|
+
// project-relative path, a command without its "cd … &&"); rows show
|
|
40
|
+
// it in place of the params when there is one.
|
|
41
|
+
// called_as: the name the model called the tool by when it was an
|
|
42
|
+
// alias's ("bash" run as execute); the row says so.
|
|
43
|
+
// view: the call's full arguments for the expanded row and the hovers
|
|
44
|
+
// (the server's ToolView: an execute/task_create's command, its cwd).
|
|
45
|
+
// ref: what the row traces to (the server's FileRef: {kind: "file",
|
|
46
|
+
// path, line?, end_line?}, the file a file tool touched), which
|
|
47
|
+
// refs.js makes the row's title and diff lines open.
|
|
48
|
+
export const ACTIVITY_FIELDS = Object.freeze(["title", "called_as"]);
|
|
49
|
+
export const EVENT_FIELDS = Object.freeze(["view", "ref"]);
|
|
50
|
+
const ROW_FIELDS = Object.freeze([...ACTIVITY_FIELDS, ...EVENT_FIELDS]);
|
|
51
|
+
|
|
52
|
+
// The +fields+ of +source+ that are set, as an object (for a spread).
|
|
53
|
+
export function pickFields(source, fields) {
|
|
54
|
+
const picked = {};
|
|
55
|
+
for (const field of fields) if (source?.[field]) picked[field] = source[field];
|
|
56
|
+
return picked;
|
|
57
|
+
}
|
|
58
|
+
|
|
33
59
|
// Stable key for a call within a turn. iteration + call_index are both present
|
|
34
60
|
// on :tool_call_started and :tool_call_completed, so the same key links a
|
|
35
61
|
// "running" row to its completion.
|
|
@@ -52,9 +78,7 @@ export function addStarted(model, event = {}, now = null) {
|
|
|
52
78
|
row.tool = event.tool || row.tool;
|
|
53
79
|
row.label = event.label || row.label;
|
|
54
80
|
row.params = event.params || row.params;
|
|
55
|
-
row
|
|
56
|
-
row.called_as = event.called_as || row.called_as;
|
|
57
|
-
row.view = event.view || row.view;
|
|
81
|
+
for (const field of ROW_FIELDS) row[field] = event[field] || row[field];
|
|
58
82
|
markStart(row, event, now);
|
|
59
83
|
return { row, created: false };
|
|
60
84
|
}
|
|
@@ -65,16 +89,8 @@ export function addStarted(model, event = {}, now = null) {
|
|
|
65
89
|
tool: event.tool || "tool",
|
|
66
90
|
label: event.label || null,
|
|
67
91
|
params: event.params || "",
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
// in place of the params when there is one.
|
|
71
|
-
title: event.title || null,
|
|
72
|
-
// The name the model called the tool by when it was an alias's ("bash"
|
|
73
|
-
// run as execute); the row says so.
|
|
74
|
-
called_as: event.called_as || null,
|
|
75
|
-
// The call's full arguments for the expanded row and the hovers (the
|
|
76
|
-
// server's ToolView: an execute/task_create's command, its cwd).
|
|
77
|
-
view: event.view || null,
|
|
92
|
+
// ACTIVITY_FIELDS and EVENT_FIELDS (above), null when unset.
|
|
93
|
+
...Object.fromEntries(ROW_FIELDS.map((field) => [field, event[field] || null])),
|
|
78
94
|
status: ROW_STATUS.RUNNING,
|
|
79
95
|
output: "",
|
|
80
96
|
output_truncated: false,
|
|
@@ -107,9 +123,8 @@ export function addCompleted(model, event = {}, now = null) {
|
|
|
107
123
|
tool: event.tool,
|
|
108
124
|
label: event.label,
|
|
109
125
|
params: event.activity?.params || "",
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
view: event.view,
|
|
126
|
+
...pickFields(event.activity, ACTIVITY_FIELDS),
|
|
127
|
+
...pickFields(event, EVENT_FIELDS),
|
|
113
128
|
});
|
|
114
129
|
row = synthesized.row;
|
|
115
130
|
}
|
|
@@ -117,8 +132,8 @@ export function addCompleted(model, event = {}, now = null) {
|
|
|
117
132
|
row.output = event.output || "";
|
|
118
133
|
row.output_truncated = !!event.output_truncated;
|
|
119
134
|
if (event.activity?.params) row.params = event.activity.params;
|
|
120
|
-
|
|
121
|
-
|
|
135
|
+
// The completed event carries the title (ACTIVITY_FIELDS) in its activity.
|
|
136
|
+
Object.assign(row, pickFields(event.activity, ACTIVITY_FIELDS));
|
|
122
137
|
// A grep that found nothing (status ok): the row says "no match".
|
|
123
138
|
if (event.activity?.no_match) row.no_match = true;
|
|
124
139
|
// The images the tool returned (a reload in the turn view draws them from
|