samagotchi 0.173.0 → 0.175.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 +48 -1
- data/docs/architecture.md +2 -2
- data/docs/cli.md +9 -2
- data/docs/internals/background-tasks.md +0 -3
- data/docs/internals/bridge.md +8 -1
- data/docs/internals/participants.md +3 -1
- data/docs/internals/remote-sessions.md +8 -0
- data/docs/internals/web-frontend.md +45 -5
- data/docs/plugins.md +1 -3
- data/docs/scheduling.md +9 -3
- data/docs/sessions.md +3 -1
- data/docs/testing.md +31 -3
- data/lib/samagotchi/answer_text.rb +4 -2
- data/lib/samagotchi/bridge.rb +1 -1
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/child_move.rb +11 -4
- data/lib/samagotchi/continued_from.rb +51 -0
- data/lib/samagotchi/engine.rb +1 -1
- data/lib/samagotchi/llm/stray_tool_call.rb +7 -4
- data/lib/samagotchi/llm_context_stale.rb +2 -1
- data/lib/samagotchi/message_parts.rb +5 -2
- data/lib/samagotchi/model_markup.rb +22 -0
- data/lib/samagotchi/model_profile.rb +8 -7
- data/lib/samagotchi/note_move.rb +11 -4
- data/lib/samagotchi/prompt_literal_guard.rb +7 -6
- data/lib/samagotchi/schedules.rb +13 -16
- data/lib/samagotchi/session_access/contract.rb +1 -0
- data/lib/samagotchi/session_access/local.rb +9 -1
- data/lib/samagotchi/session_access/remote.rb +26 -3
- data/lib/samagotchi/session_chain/delete.rb +405 -0
- data/lib/samagotchi/session_chain/delete_preview.rb +96 -0
- data/lib/samagotchi/session_chain/links.rb +38 -0
- data/lib/samagotchi/session_command_catalog.rb +2 -2
- data/lib/samagotchi/session_commands.rb +3 -13
- data/lib/samagotchi/session_continue.rb +51 -13
- data/lib/samagotchi/session_delete_command.rb +82 -17
- data/lib/samagotchi/session_manager/removal.rb +137 -31
- data/lib/samagotchi/session_stores.rb +2 -0
- data/lib/samagotchi/task_transcript.rb +10 -5
- data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +2 -2
- data/lib/samagotchi/terminal_ui/attached_loop.rb +1 -1
- data/lib/samagotchi/terminal_ui/exit_lines.rb +16 -0
- data/lib/samagotchi/terminal_ui/local_link.rb +7 -1
- data/lib/samagotchi/terminal_ui.rb +3 -3
- data/lib/samagotchi/testing/boundary.rb +0 -5
- data/lib/samagotchi/testing/bundle.rb +1 -1
- data/lib/samagotchi/tool_call_parser.rb +6 -5
- data/lib/samagotchi/tools/task_runtime.rb +0 -5
- data/lib/samagotchi/turn_note.rb +2 -1
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +7 -1
- data/lib/samagotchi/web/participant_show.rb +1 -0
- data/lib/samagotchi/web/participant_view.rb +4 -2
- data/lib/samagotchi/web/public/app.js +27 -5
- data/lib/samagotchi/web/public/chains.js +3 -3
- data/lib/samagotchi/web/public/data.js +12 -0
- data/lib/samagotchi/web/public/delete_sheet.js +344 -0
- data/lib/samagotchi/web/public/format.js +1 -1
- data/lib/samagotchi/web/public/index.html +27 -0
- data/lib/samagotchi/web/public/info_bar.js +3 -2
- data/lib/samagotchi/web/public/lists_view.js +2 -2
- data/lib/samagotchi/web/public/more_sheet.js +42 -5
- data/lib/samagotchi/web/public/reload_check.js +0 -3
- data/lib/samagotchi/web/public/session_actions.js +50 -6
- data/lib/samagotchi/web/public/session_view.js +9 -1
- data/lib/samagotchi/web/public/stage_asking.js +1 -7
- data/lib/samagotchi/web/public/stage_missing.js +150 -0
- data/lib/samagotchi/web/public/stage_view.js +8 -3
- data/lib/samagotchi/web/server.rb +13 -13
- data/lib/samagotchi/web/session_control.rb +58 -5
- data/lib/samagotchi/web/session_show.rb +42 -4
- metadata +7 -2
- data/lib/samagotchi/web/public/cards_offscreen.js +0 -69
|
@@ -26,8 +26,9 @@ module Samagotchi
|
|
|
26
26
|
# worker's turn snapshot and state snapshot (both nil without one), the
|
|
27
27
|
# messages shown (the snapshot's, else the file's) and the stream cursor
|
|
28
28
|
# the page goes on from (+event_seq+, and the snapshot's +event_id+
|
|
29
|
-
# `<seq>-<epoch>`)
|
|
30
|
-
|
|
29
|
+
# `<seq>-<epoch>`), and how the snapshot read went (+live_read+: "ok",
|
|
30
|
+
# "failed" or "none"). Each assembler makes its own payload from it.
|
|
31
|
+
ShowReads = Data.define(:id, :session, :turn_snapshot, :state, :event_seq, :event_id, :raw_messages, :live_read) do
|
|
31
32
|
# The turn in progress, as the worker's snapshot has it (nil: none).
|
|
32
33
|
def current_turn = turn_snapshot && turn_snapshot["current_turn"]
|
|
33
34
|
|
|
@@ -79,7 +80,7 @@ module Samagotchi
|
|
|
79
80
|
# behind it, all at one event_seq the client streams on from.
|
|
80
81
|
# @return [ShowReads]
|
|
81
82
|
def show_reads(id, session)
|
|
82
|
-
live =
|
|
83
|
+
live, live_read = live_snapshot(id)
|
|
83
84
|
turn_snapshot = live && live["snapshot"]
|
|
84
85
|
state = live && live["session_state_snapshot"]
|
|
85
86
|
ShowReads.new(
|
|
@@ -88,10 +89,42 @@ module Samagotchi
|
|
|
88
89
|
# The stream cursor `<seq>-<epoch>`: a later worker resets it
|
|
89
90
|
# instead of taking the seq as its own. Only the snapshot has it.
|
|
90
91
|
event_id: turn_snapshot && turn_snapshot["event_id"],
|
|
91
|
-
raw_messages: live_or_saved(turn_snapshot, "messages") { session.messages }
|
|
92
|
+
raw_messages: live_or_saved(turn_snapshot, "messages") { session.messages },
|
|
93
|
+
live_read: live_read
|
|
92
94
|
)
|
|
93
95
|
end
|
|
94
96
|
|
|
97
|
+
# The live worker's turn snapshot and what its read did: [snapshot,
|
|
98
|
+
# live_read] — "ok" when a snapshot came, "none" when no worker owns the
|
|
99
|
+
# session, "failed" when a live worker's Bridge answered with none. One
|
|
100
|
+
# GET of the Bridge, never two: a worker that is busy is hit once, not
|
|
101
|
+
# twice. The page's stage_missing.js reads live_read, so a running session
|
|
102
|
+
# whose stage shows no turn (this read had no current_turn, and so no
|
|
103
|
+
# replay and no stream cursor) is not mistaken for one whose stream
|
|
104
|
+
# replayed the turn's end. A failed read logs, at debug level, the why from
|
|
105
|
+
# that same request (no reply: a refused connect, a timeout, a cut reply;
|
|
106
|
+
# 200 with no JSON body; another status) and the elapsed ms.
|
|
107
|
+
# @return [Array(Hash, String)]
|
|
108
|
+
def live_snapshot(id)
|
|
109
|
+
return [nil, "none"] unless bridge_client(id)
|
|
110
|
+
|
|
111
|
+
started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
112
|
+
status, body = bridge_get(id, "snapshot")
|
|
113
|
+
live = status == 200 && body.is_a?(Hash) ? body : nil
|
|
114
|
+
return [live, "ok"] if live
|
|
115
|
+
|
|
116
|
+
ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - started) * 1000).round
|
|
117
|
+
why = if status.nil?
|
|
118
|
+
"no reply"
|
|
119
|
+
elsif status == 200
|
|
120
|
+
"no snapshot in the answer"
|
|
121
|
+
else
|
|
122
|
+
"status #{status}"
|
|
123
|
+
end
|
|
124
|
+
Log.debug(:web, "live_snapshot_failed", sid: id, why: why, ms: ms)
|
|
125
|
+
[nil, "failed"]
|
|
126
|
+
end
|
|
127
|
+
|
|
95
128
|
# Every finished turn of +reads+ drawn from a line (a real one, else
|
|
96
129
|
# one made from its messages, #drawn_lines): its items are stamped,
|
|
97
130
|
# and its drawing goes in turn_drawings. The running turn has none yet.
|
|
@@ -124,6 +157,11 @@ module Samagotchi
|
|
|
124
157
|
**turn_drawings_field(drawn, messages),
|
|
125
158
|
failed_turn: failed_turn_for(session, raw_messages),
|
|
126
159
|
current_turn: reads.current_turn,
|
|
160
|
+
# What the live snapshot read gave: "ok", "none" (no live worker) or
|
|
161
|
+
# "failed" (a live worker answered with no snapshot): the page's
|
|
162
|
+
# stage_missing.js tells a turn that never reached the stage from one
|
|
163
|
+
# whose stream replayed its end (docs/internals/bridge.md, The show).
|
|
164
|
+
live_read: reads.live_read,
|
|
127
165
|
# The page's join: the turn in progress and the queue behind it as
|
|
128
166
|
# the live events that draw them (TurnAccumulator.join_events, one
|
|
129
167
|
# unfold, here: any worker's snapshot works).
|
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.175.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Dedov
|
|
@@ -343,6 +343,7 @@ files:
|
|
|
343
343
|
- lib/samagotchi/context_window.rb
|
|
344
344
|
- lib/samagotchi/continue_intent.rb
|
|
345
345
|
- lib/samagotchi/continue_offer.rb
|
|
346
|
+
- lib/samagotchi/continued_from.rb
|
|
346
347
|
- lib/samagotchi/cut.rb
|
|
347
348
|
- lib/samagotchi/cut_policy.rb
|
|
348
349
|
- lib/samagotchi/debug_log.rb
|
|
@@ -552,6 +553,7 @@ files:
|
|
|
552
553
|
- lib/samagotchi/model_catalog.rb
|
|
553
554
|
- lib/samagotchi/model_list_store.rb
|
|
554
555
|
- lib/samagotchi/model_lookup.rb
|
|
556
|
+
- lib/samagotchi/model_markup.rb
|
|
555
557
|
- lib/samagotchi/model_match.rb
|
|
556
558
|
- lib/samagotchi/model_notes.rb
|
|
557
559
|
- lib/samagotchi/model_overlay.rb
|
|
@@ -674,6 +676,8 @@ files:
|
|
|
674
676
|
- lib/samagotchi/session_access/web_bridge_client.rb
|
|
675
677
|
- lib/samagotchi/session_archive_command.rb
|
|
676
678
|
- lib/samagotchi/session_chain.rb
|
|
679
|
+
- lib/samagotchi/session_chain/delete.rb
|
|
680
|
+
- lib/samagotchi/session_chain/delete_preview.rb
|
|
677
681
|
- lib/samagotchi/session_chain/links.rb
|
|
678
682
|
- lib/samagotchi/session_command_catalog.rb
|
|
679
683
|
- lib/samagotchi/session_commands.rb
|
|
@@ -941,7 +945,6 @@ files:
|
|
|
941
945
|
- lib/samagotchi/web/public/card_kinds.js
|
|
942
946
|
- lib/samagotchi/web/public/card_registry.js
|
|
943
947
|
- lib/samagotchi/web/public/card_stamps.js
|
|
944
|
-
- lib/samagotchi/web/public/cards_offscreen.js
|
|
945
948
|
- lib/samagotchi/web/public/cards_place.js
|
|
946
949
|
- lib/samagotchi/web/public/chains.js
|
|
947
950
|
- lib/samagotchi/web/public/chip_popover.js
|
|
@@ -962,6 +965,7 @@ files:
|
|
|
962
965
|
- lib/samagotchi/web/public/copy.js
|
|
963
966
|
- lib/samagotchi/web/public/ctx.js
|
|
964
967
|
- lib/samagotchi/web/public/data.js
|
|
968
|
+
- lib/samagotchi/web/public/delete_sheet.js
|
|
965
969
|
- lib/samagotchi/web/public/delivery_line.js
|
|
966
970
|
- lib/samagotchi/web/public/details_motion.js
|
|
967
971
|
- lib/samagotchi/web/public/diff_view.js
|
|
@@ -1065,6 +1069,7 @@ files:
|
|
|
1065
1069
|
- lib/samagotchi/web/public/stage_dom.js
|
|
1066
1070
|
- lib/samagotchi/web/public/stage_frame.js
|
|
1067
1071
|
- lib/samagotchi/web/public/stage_handoff.js
|
|
1072
|
+
- lib/samagotchi/web/public/stage_missing.js
|
|
1068
1073
|
- lib/samagotchi/web/public/stage_model.js
|
|
1069
1074
|
- lib/samagotchi/web/public/stage_opened.js
|
|
1070
1075
|
- lib/samagotchi/web/public/stage_owner_wait.js
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// A snapshot's cards placed into a holder that is not the page (cards_offscreen.js):
|
|
2
|
-
// the old reload check's placer. Nothing imports it now (reload_check.js compares
|
|
3
|
-
// the turn's cards as data, card_registry.js); it stays one release for a stale
|
|
4
|
-
// app.js that still imports it (a 404 would blank the page), then it goes.
|
|
5
|
-
//
|
|
6
|
-
// It is the real placer, not a copy: createCardsPlace, createBubbles and
|
|
7
|
-
// createQuestionCards over a detached holder, with every page hook made inert:
|
|
8
|
-
// no stage (turnDom answers "nothing holds it", and has no settleFold/settleWaiting
|
|
9
|
-
// — cards_place.js calls those with `?.`), no scroll, no hint, no info bar, no
|
|
10
|
-
// session id, no api. Nothing outside +holder+ is read or written; the page's
|
|
11
|
-
// questionCards, its turnDom and its appendToHistory are never touched.
|
|
12
|
-
import { createBubbles } from "./bubbles.js";
|
|
13
|
-
import { createCardsPlace } from "./cards_place.js";
|
|
14
|
-
import { createQuestionCards } from "./question_cards.js";
|
|
15
|
-
import { splitSnapshotCards } from "./card.js";
|
|
16
|
-
|
|
17
|
-
// +cards+ the read's snapshot (data.cards); +capabilities+ the page's, for the
|
|
18
|
-
// notices it shows elsewhere (splitSnapshotCards); +answers+ whether this viewer
|
|
19
|
-
// may answer cards at all (viewer.js answer_cards).
|
|
20
|
-
export function placeCardsOffscreen(holder, cards, { capabilities = null, answers = true, doc = globalThis.document } = {}) {
|
|
21
|
-
const shared = {
|
|
22
|
-
historyEl: holder,
|
|
23
|
-
findInTurnRoots: (selector) => [...holder.querySelectorAll(selector)],
|
|
24
|
-
isNearBottom: () => false,
|
|
25
|
-
selected: () => null,
|
|
26
|
-
clientId: null,
|
|
27
|
-
};
|
|
28
|
-
// No running turn here: nothing holds a piece, nothing takes a card or a steer.
|
|
29
|
-
const turnDom = { card: () => false, steer: () => false, holds: () => false };
|
|
30
|
-
const bubbles = createBubbles({
|
|
31
|
-
...shared,
|
|
32
|
-
appendToHistory: (el) => holder.appendChild(el),
|
|
33
|
-
turnDom,
|
|
34
|
-
shownTexts: { shows: () => false },
|
|
35
|
-
liveTurn: { timing: { el: null } },
|
|
36
|
-
});
|
|
37
|
-
const questionCards = createQuestionCards({
|
|
38
|
-
...shared,
|
|
39
|
-
sessionId: () => null,
|
|
40
|
-
place: (card) => { holder.appendChild(card); return false; },
|
|
41
|
-
scrollToEnd: () => {},
|
|
42
|
-
removeHintIfEmpty: () => {},
|
|
43
|
-
askingText: () => "",
|
|
44
|
-
renderMarkdown: () => Promise.resolve(null),
|
|
45
|
-
onPending: () => {},
|
|
46
|
-
onSettled: () => {},
|
|
47
|
-
answers,
|
|
48
|
-
doc,
|
|
49
|
-
// A card's button is inert here: a placed card is a comparison, not a live ask.
|
|
50
|
-
api: {
|
|
51
|
-
sendAnswer: () => Promise.reject(new Error("offscreen card")),
|
|
52
|
-
dismissQuestion: () => Promise.reject(new Error("offscreen card")),
|
|
53
|
-
sendCommand: () => Promise.reject(new Error("offscreen card")),
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
const place = createCardsPlace({
|
|
57
|
-
...shared,
|
|
58
|
-
turnDom,
|
|
59
|
-
questionCards,
|
|
60
|
-
bubbles,
|
|
61
|
-
followWokenWorker: () => {},
|
|
62
|
-
api: {
|
|
63
|
-
getSession: () => Promise.reject(new Error("offscreen card")),
|
|
64
|
-
sendCommand: () => Promise.reject(new Error("offscreen card")),
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
place.placeSnapshotCards(splitSnapshotCards(cards, capabilities).placed, { before: null });
|
|
68
|
-
return holder;
|
|
69
|
-
}
|