samagotchi 0.192.0 → 0.193.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 +52 -1
- data/docs/architecture.md +3 -3
- data/docs/bundles.md +45 -28
- data/docs/cli.md +22 -8
- data/docs/configuration.md +4 -3
- data/docs/context.md +8 -5
- data/docs/guardrails.md +9 -4
- data/docs/internals/bridge.md +3 -1
- data/docs/internals/bundles.md +2 -2
- data/docs/internals/pages.md +4 -4
- data/docs/internals/participants.md +5 -3
- data/docs/internals/peers.md +75 -22
- data/docs/internals/prompt-caching.md +2 -1
- data/docs/internals/remote-sessions.md +6 -0
- data/docs/internals/session-lifecycle.md +3 -2
- data/docs/internals/web-frontend.md +91 -19
- data/docs/internals/working-set.md +5 -1
- data/docs/peers.md +71 -22
- data/docs/plugins.md +7 -4
- data/docs/releasing.md +30 -2
- data/docs/scheduling.md +3 -2
- data/docs/sessions.md +1 -1
- data/docs/testing.md +35 -3
- data/docs/thin-clients.md +27 -11
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/claude-peer/scripts/chi-peer-SKILL.md +33 -17
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/codex-peer/scripts/chi-peer-SKILL.md +34 -17
- data/lib/samagotchi/bundles/coordinator/manifest.yml +2 -2
- data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +31 -0
- data/lib/samagotchi/bundles/mcp/manifest.yml +2 -2
- data/lib/samagotchi/bundles/mcp/plugin.rb +0 -7
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/compat.rb +8 -1
- data/lib/samagotchi/config.rb +4 -0
- data/lib/samagotchi/continue_offer.rb +13 -1
- data/lib/samagotchi/delivery.rb +2 -2
- data/lib/samagotchi/engine/models.rb +17 -0
- data/lib/samagotchi/engine/plugins.rb +2 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +49 -18
- data/lib/samagotchi/jsonl_store.rb +13 -2
- data/lib/samagotchi/llm/anthropic_messages.rb +11 -0
- data/lib/samagotchi/llm/openai_chat.rb +5 -0
- data/lib/samagotchi/llm/prompt_cache.rb +5 -0
- data/lib/samagotchi/pages/launch.rb +1 -1
- data/lib/samagotchi/peer_cold.rb +92 -0
- data/lib/samagotchi/peer_command.rb +24 -9
- data/lib/samagotchi/peer_continue.rb +32 -16
- data/lib/samagotchi/peer_exchanges.rb +7 -0
- data/lib/samagotchi/peer_mailbox.rb +21 -4
- data/lib/samagotchi/peer_receipts.rb +33 -6
- data/lib/samagotchi/peer_say.rb +34 -16
- data/lib/samagotchi/plugin/api.rb +2 -1
- data/lib/samagotchi/plugin/context.rb +13 -1
- data/lib/samagotchi/plugin/peer.rb +118 -53
- data/lib/samagotchi/plugin/peers.rb +13 -6
- data/lib/samagotchi/session_access/local.rb +98 -37
- data/lib/samagotchi/session_access/remote_peers.rb +3 -3
- data/lib/samagotchi/session_chain/links.rb +8 -3
- data/lib/samagotchi/session_continue.rb +7 -6
- data/lib/samagotchi/session_manager/spawn.rb +6 -1
- data/lib/samagotchi/session_stores.rb +16 -11
- data/lib/samagotchi/system_one/runs.rb +5 -2
- data/lib/samagotchi/testing/boundary.rb +0 -1
- data/lib/samagotchi/testing/host.rb +1 -0
- data/lib/samagotchi/testing/recorder.rb +3 -0
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/peer_routes.rb +10 -5
- data/lib/samagotchi/web/public/agent_rows.js +206 -0
- data/lib/samagotchi/web/public/agent_runs.js +595 -0
- data/lib/samagotchi/web/public/answer_fold.js +41 -44
- data/lib/samagotchi/web/public/app.js +3 -3
- data/lib/samagotchi/web/public/block_fix.js +1 -1
- data/lib/samagotchi/web/public/cards_place.js +6 -4
- data/lib/samagotchi/web/public/history_reveal.js +5 -2
- data/lib/samagotchi/web/public/index.html +38 -2
- data/lib/samagotchi/web/public/page_view.js +1 -1
- data/lib/samagotchi/web/public/pages.css +1 -7
- data/lib/samagotchi/web/public/peer_mailbox_api.js +2 -1
- data/lib/samagotchi/web/public/peer_note.js +4 -2
- data/lib/samagotchi/web/public/peer_row.js +37 -0
- data/lib/samagotchi/web/public/quiet_notes.js +12 -1
- data/lib/samagotchi/web/public/revise_stack.js +5 -2
- data/lib/samagotchi/web/public/send_turn.js +11 -3
- data/lib/samagotchi/web/public/turn_block.js +4 -0
- data/lib/samagotchi/worker/mail.rb +11 -1
- data/lib/samagotchi/worker.rb +7 -5
- data/lib/samagotchi/worker_inbound/mail.rb +34 -6
- data/lib/samagotchi/worker_inbound.rb +11 -3
- data/lib/samagotchi/worker_link.rb +13 -1
- data/lib/samagotchi/worker_wakes.rb +33 -5
- metadata +5 -2
- data/lib/samagotchi/web/public/pages_group.js +0 -67
|
@@ -9,12 +9,10 @@
|
|
|
9
9
|
// never changes shape, a click changes its height, animated
|
|
10
10
|
// (details_motion.js animateHeight) unless the viewer prefers no motion.
|
|
11
11
|
//
|
|
12
|
-
// A delegate report
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// lines". Its key: a merged one's data-line-key, a wake turn's opening
|
|
17
|
-
// "<turn id>:prompt". A live merged report has no key until a reload.
|
|
12
|
+
// A delegate report's and a peer answer's rows (closed by default) are
|
|
13
|
+
// agent_runs.js's, which owns everything agents write to each other: this
|
|
14
|
+
// module keeps their key (answerKey) and the store's `open` list they are
|
|
15
|
+
// kept in (readOpened / writeOpened), and skips their rows.
|
|
18
16
|
//
|
|
19
17
|
// A long prompt (a user bubble with no data-source: typed, not brought in)
|
|
20
18
|
// gets the same row over the same threshold, open by default as an answer
|
|
@@ -24,7 +22,7 @@
|
|
|
24
22
|
//
|
|
25
23
|
// Which answers are folded is this browser's choice (localStorage through
|
|
26
24
|
// storage.js): one key per session holding the folded answers' keys and
|
|
27
|
-
// the unfolded reports' keys, the last FOLD_KEEP of each. An answer's key is its turn's id
|
|
25
|
+
// the unfolded reports' and peer answers' keys, the last FOLD_KEEP of each. An answer's key is its turn's id
|
|
28
26
|
// (data-answer-turn), a delegate report's reply its own (data-reply-key);
|
|
29
27
|
// a bubble with neither (an answer before any prompt, a canceled turn's
|
|
30
28
|
// partial) gets no row. The keys of sessions gone from the session list go
|
|
@@ -52,11 +50,14 @@ export const FOLD_PREFIX = "chi_answer_fold:";
|
|
|
52
50
|
const LABEL_CHARS = 160;
|
|
53
51
|
|
|
54
52
|
const ROW_CLASS = "answer-fold";
|
|
55
|
-
// What gets a row: answers
|
|
56
|
-
// and
|
|
53
|
+
// What gets a row here: answers and the user's own prompts (no source).
|
|
54
|
+
// A delegate report's and a peer answer's keys are answerKey's too (their
|
|
55
|
+
// selectors are agent_rows.js's, kept apart here: this module's top level
|
|
56
|
+
// uses none of agent_rows.js's bindings, see there).
|
|
57
57
|
const REPORTS = '.bubble.user[data-source="delegate_report"]';
|
|
58
|
+
const PEERS = ".bubble.note.peer-answer";
|
|
58
59
|
const PROMPTS = ".bubble.user:not([data-source])";
|
|
59
|
-
const ANSWERS = `.bubble.output, ${
|
|
60
|
+
const ANSWERS = `.bubble.output, ${PROMPTS}`;
|
|
60
61
|
// Not done yet: still streaming.
|
|
61
62
|
const UNFINISHED = ".streaming";
|
|
62
63
|
|
|
@@ -184,12 +185,19 @@ export function sweepAnswerFolds(sessions, { scoped = false } = {}) {
|
|
|
184
185
|
|
|
185
186
|
const isReport = (bubble) => !!bubble?.matches?.(REPORTS);
|
|
186
187
|
const isPrompt = (bubble) => !!bubble?.matches?.(PROMPTS);
|
|
188
|
+
const isPeer = (bubble) => !!bubble?.matches?.(PEERS);
|
|
187
189
|
|
|
188
190
|
// The key an answer bubble is folded by, or null. A delegate report's: a
|
|
189
191
|
// merged one's line key (data-line-key, "<turn id>:input:<place>"), one
|
|
190
192
|
// that opened a wake turn its turn's id and ":prompt" (never the answer's
|
|
191
|
-
// key, the bare id). A prompt's: its turn's id and ":prompt".
|
|
193
|
+
// key, the bare id). A prompt's: its turn's id and ":prompt". A peer's
|
|
194
|
+
// answer's: "peer:<name>#<serial>", else "peer@<opening id>".
|
|
192
195
|
export function answerKey(bubble) {
|
|
196
|
+
if (isPeer(bubble)) {
|
|
197
|
+
const { peerName, peerSerial, openingId } = bubble.dataset;
|
|
198
|
+
if (peerName && peerSerial) return `peer:${peerName}#${peerSerial}`;
|
|
199
|
+
return openingId ? `peer@${openingId}` : null;
|
|
200
|
+
}
|
|
193
201
|
if (isReport(bubble)) {
|
|
194
202
|
const turn = bubble.getAttribute("data-turn-id");
|
|
195
203
|
return bubble.getAttribute("data-line-key") || (turn ? `${turn}:prompt` : null);
|
|
@@ -205,34 +213,22 @@ function answerText(bubble) {
|
|
|
205
213
|
return bubbleCopyText(bubble);
|
|
206
214
|
}
|
|
207
215
|
|
|
208
|
-
// A
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
// A report row's label: its origin label (the bubble's) and its first
|
|
213
|
-
// heading or first line after the header.
|
|
214
|
-
export function reportLabel(text, origin = "") {
|
|
215
|
-
const body = String(text ?? "").replace(/\r\n?/g, "\n").split("\n").filter((l) => !REPORT_HEADER.test(l.trim())).join("\n");
|
|
216
|
-
const first = foldLabel(body);
|
|
217
|
-
return clip([origin.trim(), first].filter(Boolean).join(" · "), LABEL_CHARS);
|
|
218
|
-
}
|
|
216
|
+
// A report row's label (agent_rows.js): kept here for an older cached
|
|
217
|
+
// module that imports it from this one.
|
|
218
|
+
export { reportLabel } from "./agent_rows.js";
|
|
219
219
|
|
|
220
220
|
function drawRow(row, bubble) {
|
|
221
221
|
const folded = bubble.classList.contains("folded");
|
|
222
222
|
const text = answerText(bubble);
|
|
223
|
-
const report = isReport(bubble);
|
|
224
223
|
const prompt = isPrompt(bubble);
|
|
225
|
-
const own = report ? { label: reportLabel(text, bubble.querySelector(":scope > .origin-label")?.textContent || "") } : {};
|
|
226
224
|
// A prompt's label is its first line as typed (no heading picked).
|
|
227
225
|
const display = prompt || bubble.hasAttribute("data-answer-display");
|
|
228
|
-
const { label, size } = foldRowText(text, { display, folded
|
|
229
|
-
const what =
|
|
226
|
+
const { label, size } = foldRowText(text, { display, folded });
|
|
227
|
+
const what = prompt ? "message" : "answer";
|
|
230
228
|
row.setAttribute("aria-expanded", folded ? "false" : "true");
|
|
231
229
|
row.title = folded ? `Show the ${what}` : `Fold the ${what}`;
|
|
232
230
|
row.classList.toggle("folded", folded);
|
|
233
|
-
row.classList.toggle("report", report);
|
|
234
231
|
row.classList.toggle("prompt", prompt);
|
|
235
|
-
row.classList.toggle("steered", report && bubble.classList.contains("steered"));
|
|
236
232
|
const [labelEl, sizeEl] = row.children;
|
|
237
233
|
if (labelEl.textContent !== label) labelEl.textContent = label;
|
|
238
234
|
if (sizeEl.textContent !== size) sizeEl.textContent = size;
|
|
@@ -242,11 +238,11 @@ function makeRow(doc) {
|
|
|
242
238
|
const row = doc.createElement("button");
|
|
243
239
|
row.type = "button";
|
|
244
240
|
row.className = ROW_CLASS;
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
241
|
+
for (const part of ["label", "size"]) {
|
|
242
|
+
const el = doc.createElement("span");
|
|
243
|
+
el.className = `answer-fold-${part}`;
|
|
244
|
+
row.append(el);
|
|
245
|
+
}
|
|
250
246
|
return row;
|
|
251
247
|
}
|
|
252
248
|
|
|
@@ -277,6 +273,7 @@ export function installAnswerFold({ historyEl, sessionId, projectRoot = () => nu
|
|
|
277
273
|
if (bubble.parentElement !== historyEl) return;
|
|
278
274
|
const key = answerKey(bubble);
|
|
279
275
|
let row = rows.get(bubble);
|
|
276
|
+
// An answer or a prompt over the threshold only.
|
|
280
277
|
if (!key || bubble.matches(UNFINISHED) || (!row && !foldable(answerText(bubble)))) return;
|
|
281
278
|
if (!row) {
|
|
282
279
|
row = makeRow(historyEl.ownerDocument);
|
|
@@ -284,28 +281,30 @@ export function installAnswerFold({ historyEl, sessionId, projectRoot = () => nu
|
|
|
284
281
|
bubbleOf.set(row, bubble);
|
|
285
282
|
// The stored choice, once: after that the bubble's class is the state
|
|
286
283
|
// (a jump that unfolds it, history_reveal.js, isn't saved). An answer
|
|
287
|
-
// is open unless folded by hand, a report
|
|
288
|
-
|
|
289
|
-
if (
|
|
284
|
+
// is open unless folded by hand, a report or a peer's answer folded
|
|
285
|
+
// unless opened.
|
|
286
|
+
if (stored().turns.includes(key)) bubble.classList.add("folded");
|
|
290
287
|
}
|
|
291
288
|
if (bubble.previousElementSibling !== row) historyEl.insertBefore(row, bubble);
|
|
292
289
|
drawRow(row, bubble);
|
|
293
290
|
}
|
|
294
291
|
|
|
295
|
-
// Rows whose bubble left (a re-render, a replaced bubble) go with it
|
|
296
|
-
//
|
|
297
|
-
//
|
|
292
|
+
// Rows whose bubble left (a re-render, a replaced bubble) go with it (only
|
|
293
|
+
// this module's: agent_runs.js's rows are its own); a row something was
|
|
294
|
+
// placed after (a card or a recap placed before a
|
|
295
|
+
// prompt that opens its turn) goes back just before its bubble.
|
|
298
296
|
function dropOrphans() {
|
|
299
297
|
for (const row of historyEl.querySelectorAll(`:scope > .${ROW_CLASS}`)) {
|
|
298
|
+
if (!bubbleOf.has(row)) continue;
|
|
300
299
|
const bubble = bubbleOf.get(row);
|
|
301
|
-
if (
|
|
300
|
+
if (bubble.parentElement !== historyEl) row.remove();
|
|
302
301
|
else if (row.nextElementSibling !== bubble) historyEl.insertBefore(row, bubble);
|
|
303
302
|
}
|
|
304
303
|
}
|
|
305
304
|
|
|
306
305
|
function decorate(root) {
|
|
307
306
|
let entry = null;
|
|
308
|
-
const stored = () => (entry ??= { turns: readFolded(sessionId())
|
|
307
|
+
const stored = () => (entry ??= { turns: readFolded(sessionId()) });
|
|
309
308
|
if (root.matches?.(ANSWERS)) decorateBubble(root, stored);
|
|
310
309
|
for (const bubble of root.querySelectorAll?.(ANSWERS) || []) decorateBubble(bubble, stored);
|
|
311
310
|
}
|
|
@@ -351,9 +350,7 @@ export function installAnswerFold({ historyEl, sessionId, projectRoot = () => nu
|
|
|
351
350
|
settle();
|
|
352
351
|
animateHeight(bubble, 0, bubble.offsetHeight, { fade: true });
|
|
353
352
|
}
|
|
354
|
-
|
|
355
|
-
if (isReport(bubble)) writeOpened(sessionId(), answerKey(bubble), !folded, { root: projectRoot() });
|
|
356
|
-
else writeFold(sessionId(), answerKey(bubble), folded, { root: projectRoot() });
|
|
353
|
+
writeFold(sessionId(), answerKey(bubble), folded, { root: projectRoot() });
|
|
357
354
|
});
|
|
358
355
|
|
|
359
356
|
return { decorate };
|
|
@@ -73,7 +73,7 @@ import { wireBlockFix } from "./block_fix.js";
|
|
|
73
73
|
import { createWidgetDrawer } from "./inline_widgets.js";
|
|
74
74
|
import { copyText, installCopy } from "./copy.js";
|
|
75
75
|
import { installAnswerFold, sweepAnswerFolds } from "./answer_fold.js";
|
|
76
|
-
import {
|
|
76
|
+
import { installAgentRuns } from "./agent_runs.js";
|
|
77
77
|
import { sweepSessionPrefs } from "./session_prefs.js";
|
|
78
78
|
import { installDetailsMotion } from "./details_motion.js";
|
|
79
79
|
import { answerLabel, installReviseStacks, reviseChipTemplate, reviseWorkerUnavailable } from "./revise_stack.js";
|
|
@@ -1458,10 +1458,10 @@ const blockFix = wireBlockFix({ viewer, roots: turnRoots(), store, getSession, c
|
|
|
1458
1458
|
// with their height animated (details_motion.js), in the history and on
|
|
1459
1459
|
// the stage.
|
|
1460
1460
|
installDetailsMotion({ root: document.body, selector: ".turn-work, .bubble.thinking, .bubble.recap" });
|
|
1461
|
-
// Long answers fold by hand (answer_fold.js), per viewer and session;
|
|
1461
|
+
// Long answers fold by hand (answer_fold.js), per viewer and session; reports, peer answers and background items (agent_runs.js) start closed.
|
|
1462
1462
|
const projectRoot = () => store.sessions.find((s) => s.id === store.selected)?.project_root ?? null;
|
|
1463
1463
|
installAnswerFold({ historyEl, sessionId: () => store.selected, projectRoot });
|
|
1464
|
-
|
|
1464
|
+
installAgentRuns({ historyEl, sessionId: () => store.selected, projectRoot });
|
|
1465
1465
|
// Revise stacks (revise_stack.js): the superseded versions fold to stubs,
|
|
1466
1466
|
// the top answer gets its version chip, a final answer its Revise button.
|
|
1467
1467
|
reviseStacks = viewer.can("revise") || viewer.can("revise_own_turn") ? installReviseStacks({
|
|
@@ -178,7 +178,7 @@ export function createBlockFix({ roots, sessionId, features, bridgeUp = () => tr
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
// The fixed answer, read again and written by
|
|
181
|
+
// The fixed answer, read again and written by answer_write.js's writeAnswer
|
|
182
182
|
// (which, unlike applyFinalAnswer, can't find the bubble by its old text).
|
|
183
183
|
// +pres+: the blocks this redraw settles when it can't (the session
|
|
184
184
|
// left behind mid-read is not one: leave that page alone).
|
|
@@ -133,16 +133,18 @@ export function createCardsPlace({
|
|
|
133
133
|
// for the end): right after the turn that just ended, as live (a notice
|
|
134
134
|
// draws no time divider of its own), so above the next opening's divider
|
|
135
135
|
// and the context notes that came between the turns. It walks back over
|
|
136
|
-
// those
|
|
137
|
-
//
|
|
138
|
-
//
|
|
136
|
+
// those, their notes rows (quiet_notes.js) and fold rows (answer_fold.js:
|
|
137
|
+
// a peer answer's, the next opening's own; an answer's or a report's
|
|
138
|
+
// bubble ends the walk before its row is reached), never over earlier
|
|
139
|
+
// lines, cards or questions (several lines keep their order), and returns
|
|
140
|
+
// the first one it walked over, else +before+.
|
|
139
141
|
// Assumes the line came right after a turn (an after_turn hook), not after
|
|
140
142
|
// a later note: an anytime command's line between turns moves above the
|
|
141
143
|
// notes before it too (rare; the e2e reload checks cover it).
|
|
142
144
|
function afterTurnEnd(before) {
|
|
143
145
|
let place = before;
|
|
144
146
|
for (let el = before ? before.previousElementSibling : historyEl.lastElementChild; el; el = el.previousElementSibling) {
|
|
145
|
-
if (!el.matches(".time-gap, .bubble.note:not(.turn-start), .quiet-notes")) break;
|
|
147
|
+
if (!el.matches(".time-gap, .bubble.note:not(.turn-start), .quiet-notes, .answer-fold")) break;
|
|
146
148
|
place = el;
|
|
147
149
|
}
|
|
148
150
|
return place;
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
// step, a diff), an answer or a delegate report folded (answer_fold.js: its row follows
|
|
4
4
|
// the bubble's class; the jump's unfold isn't saved), a superseded version
|
|
5
5
|
// of a Revise stack (revise_stack.js: its stub opens, not saved), a drawn
|
|
6
|
-
// block's source (block_source.js), a closed
|
|
7
|
-
// opens, never stored)
|
|
6
|
+
// block's source (block_source.js), a closed run line (agent_runs.js: the
|
|
7
|
+
// segment of what it hides opens, never stored), a closed notes row
|
|
8
|
+
// (quiet_notes.js: it opens, never stored). Every
|
|
8
9
|
// jump goes through it (claim_link.js showClaim, refs.js showRow and so the
|
|
9
10
|
// working set's step tags, verdict_card.js "View check"), so a new way to
|
|
10
11
|
// hide history is opened in one place.
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
import { revealBlockSource } from "./block_source.js";
|
|
17
18
|
import { openStubOver } from "./revise_stack.js";
|
|
18
19
|
import { revealQuiet } from "./quiet_notes.js";
|
|
20
|
+
import { revealRun } from "./agent_runs.js";
|
|
19
21
|
|
|
20
22
|
// Opens each closed <details> that holds +el+ (not +el+ itself: a fold the
|
|
21
23
|
// caller means to open it opens itself) and unfolds the folded answer that
|
|
@@ -23,6 +25,7 @@ import { revealQuiet } from "./quiet_notes.js";
|
|
|
23
25
|
export function revealInHistory(el) {
|
|
24
26
|
if (!el) return null;
|
|
25
27
|
openStubOver(el);
|
|
28
|
+
revealRun(el);
|
|
26
29
|
revealQuiet(el);
|
|
27
30
|
revealBlockSource(el);
|
|
28
31
|
el.closest?.(".bubble.folded")?.classList.remove("folded");
|
|
@@ -100,6 +100,29 @@ main{flex:1;display:flex;flex-direction:column;gap:16px;padding:max(16px,var(--s
|
|
|
100
100
|
.qn-names{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
101
101
|
.qn-warn{flex:none;margin-left:auto;white-space:nowrap;color:var(--warn-text)}
|
|
102
102
|
@media(max-width:600px){.quiet-notes{min-height:44px;align-items:center}}
|
|
103
|
+
/* The run line (agent_runs.js): a run of reports, peer answers, a finished turn's steps and notes as one line of
|
|
104
|
+
segments, one open at a time; that kind's rows under it (indented), the notes as they are. One line at every width:
|
|
105
|
+
the lowest rank truncates first (notes, then calls, then reports, then peers). The design: fold-levels mock-up. */
|
|
106
|
+
.quiet-notes.agent-line{gap:0;align-items:center;padding:2px 0 2px 9px;cursor:default;overflow:hidden;flex-wrap:nowrap}
|
|
107
|
+
@media(hover:hover){.quiet-notes.agent-line:hover{background:transparent;color:var(--text-muted)}}
|
|
108
|
+
.quiet-notes.agent-line::before{content:none}
|
|
109
|
+
.qn-seg{flex:0 1 auto;min-width:0;min-height:28px;margin:0;padding:4px 7px;font:inherit;color:inherit;text-align:left;background:transparent;border:0;border-radius:6px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
110
|
+
.qn-seg.seg-peer{flex-shrink:1}.qn-seg.seg-report{flex-shrink:1e5}.qn-seg.seg-calls{flex-shrink:1e10}.qn-seg.seg-notes{flex-shrink:1e15}
|
|
111
|
+
@media(hover:hover){.qn-seg:hover:not(:disabled){filter:none;background:var(--bg-hover);color:var(--text-2)}}
|
|
112
|
+
.qn-seg:focus-visible{outline:2px solid var(--accent-ring);outline-offset:-2px}
|
|
113
|
+
.qn-seg[aria-expanded="true"]{background:var(--bg-raised);color:var(--text-bright)}
|
|
114
|
+
.qn-seg+.qn-seg::before{content:"·";margin-right:11px;margin-left:-4px;color:var(--text-faint)}
|
|
115
|
+
.qn-seg .qn-warn{margin-left:6px}
|
|
116
|
+
/* A phone's line is 44px tall (the notes row's): a segment's tap area is the line's height, its look the mock-up's
|
|
117
|
+
size (drawn by ::after, 28px). */
|
|
118
|
+
@media(max-width:600px){.qn-seg{position:relative;z-index:0;min-height:40px;padding-inline:6px;background:transparent!important}.qn-seg::after{content:"";position:absolute;inset:6px 0;z-index:-1;border-radius:6px}.qn-seg[aria-expanded="true"]::after{background:var(--bg-raised)}}
|
|
119
|
+
@media(max-width:600px) and (hover:hover){.qn-seg:hover::after{background:var(--bg-hover)}.qn-seg[aria-expanded="true"]:hover::after{background:var(--bg-raised)}}
|
|
120
|
+
#history>.answer-fold.agent-row.in-line:not(.report),#history>.answer-fold.agent-row.in-line+.bubble{margin-left:12px;max-width:calc(100% - 12px)}
|
|
121
|
+
/* A steps block under its line ("N calls"): today's block, its summary row and footprint, indented as the rows are. */
|
|
122
|
+
#history>.turn-work.in-line{margin-left:12px;max-width:calc(100% - 12px)}
|
|
123
|
+
/* Opened under its compact row in a line, a report or a note is the row's box's rest, as a peer answer is (the mock-up's
|
|
124
|
+
level 3): the panel box, full width, its top edge the row's. */
|
|
125
|
+
#history>.answer-fold.compact.in-line:not(.peer):not(.folded)+.bubble{align-self:stretch;width:auto;opacity:1;background:var(--bg-panel);border:1px solid var(--border);border-top:0;border-radius:0 0 10px 10px;padding-top:8px}
|
|
103
126
|
.answer-fold:focus-visible{outline:2px solid var(--accent-ring);outline-offset:1px}
|
|
104
127
|
.answer-fold::before{content:"▾\00a0";color:var(--accent);flex:none}
|
|
105
128
|
.answer-fold.folded::before{content:"▸\00a0"}
|
|
@@ -114,6 +137,21 @@ main{flex:1;display:flex;flex-direction:column;gap:16px;padding:max(16px,var(--s
|
|
|
114
137
|
.answer-fold-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-2);font-size:13px}
|
|
115
138
|
.answer-fold-label:empty{display:none}
|
|
116
139
|
.answer-fold-size{flex:none;white-space:nowrap;font-variant-numeric:tabular-nums;transition:color .12s ease}
|
|
140
|
+
/* A peer's answer's row (answer_fold.js PEERS, closed by default): "<name> <verdict> <summary> N lines" in a plain panel
|
|
141
|
+
box, no chevron; the verdict in the text colour whatever it says; on a phone the summary truncates, the length stays.
|
|
142
|
+
Open, the same line is the box's top edge and the peer's bubble its rest. */
|
|
143
|
+
.answer-fold:is(.peer,.compact){gap:8px;padding:9px 12px;font-weight:400;color:var(--text);border-left-width:1px;border-left-color:var(--border);border-radius:10px}
|
|
144
|
+
.answer-fold:is(.peer,.compact)::before{content:none}
|
|
145
|
+
.answer-fold-name{flex:0 1 auto;min-width:0;max-width:45%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:var(--text-bright)}
|
|
146
|
+
.answer-fold-verdict{flex:none;white-space:nowrap;font-weight:600}
|
|
147
|
+
.answer-fold-summary{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-3)}
|
|
148
|
+
.answer-fold:is(.peer,.compact) .answer-fold-size{font-size:12px;color:var(--text-faint)}
|
|
149
|
+
.answer-fold:is(.peer,.compact)>:empty{display:none}
|
|
150
|
+
/* Under its row (answer_fold.js .under-row) the bubble is the peer's text and its foot: the row says who, the verdict
|
|
151
|
+
and the summary; the head stays only for the ↑ to the send. */
|
|
152
|
+
.bubble.note.peer-answer.under-row>.note-text,.bubble.note.peer-answer.under-row>.peer-head>:not(.peer-up-slot){display:none}
|
|
153
|
+
.bubble.note.peer-answer.under-row>.peer-head:not(:has(.peer-up)){display:none}
|
|
154
|
+
.answer-fold.peer:not(.folded)+.bubble.note.peer-answer{border-color:var(--border);border-top:0;border-top-left-radius:0;border-top-right-radius:0;padding-top:8px}
|
|
117
155
|
/* Revise stacks (revise_stack.js): a superseded version folds to its stub; the Revise row under a final answer
|
|
118
156
|
(zero height: its button sits on the bubble's bottom edge, clear of the copy button, shown on hover) and a stack
|
|
119
157
|
top's version chip. */
|
|
@@ -2337,8 +2375,6 @@ body.participant-view .bubble.user:not(.by-participant)>.origin-label{color:var(
|
|
|
2337
2375
|
<section id="pageView" aria-label="Page"></section>
|
|
2338
2376
|
<section id="pagesList" aria-label="Pages"></section>
|
|
2339
2377
|
<section id="allView" aria-label="All sessions">
|
|
2340
|
-
<!-- Inert: an older cached app.js draws All sessions' Pages group into it (pages_group.js). Remove after 0.189.0. -->
|
|
2341
|
-
<div id="pagesGroup" hidden></div>
|
|
2342
2378
|
<div id="allList"></div>
|
|
2343
2379
|
<div id="allPath" hidden>Stored in <code></code></div>
|
|
2344
2380
|
</section>
|
|
@@ -26,7 +26,7 @@ import { tableTemplate } from "./page_table.js";
|
|
|
26
26
|
import { nextSort } from "./page_table_model.js";
|
|
27
27
|
import { changedText, errorCopy, failureParts, keptAfterFailure, metaText } from "./page_model.js";
|
|
28
28
|
|
|
29
|
-
// Mirrors Pages::NAME (lib/samagotchi/pages.rb).
|
|
29
|
+
// Mirrors Pages::NAME (lib/samagotchi/pages.rb); pinned by spec/pages_name_sync_spec.rb.
|
|
30
30
|
const PAGE_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
31
31
|
|
|
32
32
|
export function createPageView({
|
|
@@ -70,13 +70,7 @@ button.pg-row-main:focus-visible{outline:2px solid var(--accent);outline-offset:
|
|
|
70
70
|
/* The meta wraps under the title, on a line of its own. */
|
|
71
71
|
.pg-meta{order:5;flex-basis:100%;white-space:normal}
|
|
72
72
|
}
|
|
73
|
-
/* A page card (the Pages list's)
|
|
74
|
-
remove the group's rules after 0.189.0): one row of cards that scrolls sideways. Their own card rules: the session
|
|
75
|
-
cards' are scoped to #allList .card. */
|
|
76
|
-
#pagesGroup{display:flex;flex-direction:column;gap:8px;flex:none;min-width:0}
|
|
77
|
-
#pagesGroup[hidden]{display:none}
|
|
78
|
-
.pg-group-label{font-size:11px;font-weight:600;line-height:1;letter-spacing:.06em;text-transform:uppercase;color:var(--text-faint)}
|
|
79
|
-
.pg-cards{display:flex;gap:8px;overflow-x:auto;padding-bottom:2px;scrollbar-width:thin}
|
|
73
|
+
/* A page card (the Pages list's). The session cards' rules are scoped to #allList .card. */
|
|
80
74
|
.pg-card{all:unset;box-sizing:border-box;flex:0 0 190px;display:flex;flex-direction:column;gap:2px;min-width:0;padding:9px 11px;border:1px solid var(--accent-border);border-radius:10px;background:var(--bg-panel);font-size:12.5px;color:var(--text-muted);cursor:pointer}
|
|
81
75
|
.pg-card b{display:block;font-size:13px;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
82
76
|
.pg-card:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
|
|
@@ -14,7 +14,8 @@ export function getPeerMessage(id, name, serial, box = null, opts = {}) {
|
|
|
14
14
|
return api(`${base(id, name)}/messages/${encodeURIComponent(serial)}${query}`, opts);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// DELETE …/peers/NAME (Unpair) → {unpaired}: the pairing ends, its messages stay
|
|
17
|
+
// DELETE …/peers/NAME (Unpair) → {unpaired, forwarded_to}: the pairing ends, its messages stay; forwarded_to names
|
|
18
|
+
// the chain's live link whose pairing ended too, when the session was continued (absent otherwise).
|
|
18
19
|
export function unpairPeer(id, name, opts = {}) {
|
|
19
20
|
return api(base(id, name), { ...opts, method: "DELETE" });
|
|
20
21
|
}
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
// (a live context_added, an older server) as plain text that peer_links.js
|
|
17
17
|
// swaps for its markdown; its source kept in data-peer-md. The fold shows
|
|
18
18
|
// the rest, and the bubble is marked data-peer-inline (no "Read the full
|
|
19
|
-
// answer").
|
|
19
|
+
// answer"). A summary the peer didn't send (`.note-text` is then the
|
|
20
|
+
// note's first line) is marked data-fallback (answer_fold.js's row reads the
|
|
21
|
+
// peer's text instead).
|
|
20
22
|
// Its own module: new exports go in new modules (web-frontend.md).
|
|
21
23
|
|
|
22
24
|
import { html, nothing } from "./vendor/lit-html.js";
|
|
@@ -65,5 +67,5 @@ export function peerNoteTemplate(note) {
|
|
|
65
67
|
: rendered ? html`<div class="peer-text markdown md-compact" data-peer-md=${block.text}>${unsafeHTML(rendered)}</div>`
|
|
66
68
|
: html`<div class="peer-text" data-peer-md=${block.text}>${block.text}</div>`;
|
|
67
69
|
const told = block ? block.rest : (note.content ?? "");
|
|
68
|
-
return html`<div class=${cls} title=${fullTime(note.at) || nothing} data-opening-id=${opening} data-peer-source=${attr(source)} data-peer-name=${attr(peer.peer)} data-peer-re=${attr(peer.re)} data-peer-serial=${attr(peer.serial)} data-peer-box=${attr(peer.box)} data-peer-inline=${block ? "1" : nothing}><div class="peer-head"><span class="peer-who">${name} answered</span><span class="peer-up-slot" data-peer-slot="up"></span>${verdictTemplate(peer)}</div><div class="note-text">${peerSummaryText(note)}</div>${body}<div class="peer-foot"><span class="peer-full-slot" data-peer-slot="full"></span><details class="peer-told"><summary>what chi told the agent</summary><div class="peer-told-text">${told}</div></details></div></div>`;
|
|
70
|
+
return html`<div class=${cls} title=${fullTime(note.at) || nothing} data-opening-id=${opening} data-peer-source=${attr(source)} data-peer-name=${attr(peer.peer)} data-peer-re=${attr(peer.re)} data-peer-serial=${attr(peer.serial)} data-peer-box=${attr(peer.box)} data-peer-inline=${block ? "1" : nothing}><div class="peer-head"><span class="peer-who">${name} answered</span><span class="peer-up-slot" data-peer-slot="up"></span>${verdictTemplate(peer)}</div><div class="note-text" data-fallback=${String(peer.summary ?? "").trim() ? nothing : "1"}>${peerSummaryText(note)}</div>${body}<div class="peer-foot"><span class="peer-full-slot" data-peer-slot="full"></span><details class="peer-told"><summary>what chi told the agent</summary><div class="peer-told-text">${told}</div></details></div></div>`;
|
|
69
71
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// A peer's answer as its closed row (answer_fold.js draws it): "<name> ·
|
|
2
|
+
// <verdict> · <summary> · N lines". Pure, no DOM. The summary is the one the
|
|
3
|
+
// peer sent without the verdict it wrote into it (PeerNote.payload parses
|
|
4
|
+
// the verdict out of the summary, so the row would say it twice); no summary,
|
|
5
|
+
// the first line of the peer's text. N counts the peer's own text only (the
|
|
6
|
+
// note's body), never the bubble's copy text; no body, no length.
|
|
7
|
+
// docs/internals/web-frontend.md, The peer exchange.
|
|
8
|
+
// Its own module: new exports go in new modules (web-frontend.md).
|
|
9
|
+
import { verdictWord } from "./peer_exchange.js";
|
|
10
|
+
|
|
11
|
+
// PeerNote::VERDICT, the Ruby side's: `VERDICT CHANGES`, `VERDICT: OK`; a
|
|
12
|
+
// copied template's `VERDICT OK|CHANGES` is none.
|
|
13
|
+
const VERDICT = /\bVERDICT:?\s*([A-Z]+)(?![A-Za-z|])/g;
|
|
14
|
+
|
|
15
|
+
const squash = (s) => s.replace(/\s+/g, " ").trim();
|
|
16
|
+
|
|
17
|
+
// +summary+ without its last verdict mark when that mark is +verdict+ (the
|
|
18
|
+
// server's word: the last mark it parsed), the punctuation it leaves tidied.
|
|
19
|
+
export function summaryWithoutVerdict(summary, verdict) {
|
|
20
|
+
const s = String(summary ?? "");
|
|
21
|
+
const last = [...s.matchAll(VERDICT)].at(-1);
|
|
22
|
+
if (!last || !verdict || last[1] !== verdict) return squash(s);
|
|
23
|
+
const before = s.slice(0, last.index).replace(/[\s([]+$/, "");
|
|
24
|
+
const after = s.slice(last.index + last[0].length).replace(/^[\s)\]]*[,;.:—–-]?\s*/, "");
|
|
25
|
+
const joined = squash(`${before} ${after}`).replace(/\(\s*\)|\[\s*\]/g, "");
|
|
26
|
+
return squash(joined.replace(/[\s,;:—–-]+$/, ""));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The row's words: {name, verdict, summary, size}. +verdict+: the server's
|
|
30
|
+
// word (OK, CHANGES, UNSURE) or none; +summary+: the summary the peer sent,
|
|
31
|
+
// or none; +first+: the first line of the peer's text (no summary);
|
|
32
|
+
// +lines+: the peer's text's lines, null with no text.
|
|
33
|
+
export function peerRowWords({ name = "", verdict = null, summary = "", first = "", lines = null } = {}) {
|
|
34
|
+
const said = summaryWithoutVerdict(summary, verdict);
|
|
35
|
+
const size = lines === null || lines === undefined ? "" : `${lines} line${lines === 1 ? "" : "s"}`;
|
|
36
|
+
return { name: squash(String(name ?? "")), verdict: verdictWord(verdict), summary: said || squash(String(first ?? "")), size };
|
|
37
|
+
}
|
|
@@ -90,6 +90,13 @@ export function rowLabel(items) {
|
|
|
90
90
|
return { count: items.length, names, warn };
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
// A stretch's segments: [{kind, items, ...its words}]. One kind today, the
|
|
94
|
+
// notes (rowLabel's words), drawn as the row. Not exported (the mixed-cache
|
|
95
|
+
// rule): agent_runs.js has the segment line.
|
|
96
|
+
function segments(items) {
|
|
97
|
+
return [{ kind: "notes", items, ...rowLabel(items) }];
|
|
98
|
+
}
|
|
99
|
+
|
|
93
100
|
export function rowTemplate({ count, names, warn }) {
|
|
94
101
|
return html`<span class="qn-count">${count} ${count === 1 ? "note" : "notes"}</span><span class="qn-names">· ${names.join(", ")}</span>${warn > 0 ? html`<span class="qn-warn">⚠ ${warn}</span>` : nothing}`;
|
|
95
102
|
}
|
|
@@ -104,6 +111,9 @@ export function revealQuiet(el) {
|
|
|
104
111
|
if (row && !row.classList.contains("open")) row.click();
|
|
105
112
|
}
|
|
106
113
|
|
|
114
|
+
// The page installs agent_runs.js (the one owner of the notes rows, reports
|
|
115
|
+
// and peer answers) instead; this one is kept for an older cached app.js
|
|
116
|
+
// until the next release's baseline refresh.
|
|
107
117
|
// @param historyEl the history (#history)
|
|
108
118
|
// @return {settle()} (the observer runs it; specs call it)
|
|
109
119
|
export function installQuietNotes({ historyEl }) {
|
|
@@ -139,7 +149,8 @@ export function installQuietNotes({ historyEl }) {
|
|
|
139
149
|
}
|
|
140
150
|
|
|
141
151
|
function drawRow(row, items) {
|
|
142
|
-
const
|
|
152
|
+
const [{ count, names, warn }] = segments(items);
|
|
153
|
+
const label = { count, names, warn };
|
|
143
154
|
const words = JSON.stringify(label);
|
|
144
155
|
if (drawn.get(row) !== words) {
|
|
145
156
|
render(rowTemplate(label), row);
|
|
@@ -165,7 +165,9 @@ export function historyTurns(historyEl) {
|
|
|
165
165
|
};
|
|
166
166
|
for (const el of historyEl.children) {
|
|
167
167
|
if ([STUB_CLASS, ROW_CLASS, VIEW_CLASS, QUIET_ROW].some((c) => el.classList.contains(c))) continue;
|
|
168
|
-
|
|
168
|
+
// An opening's row (a report's, a peer answer's that opens a wake turn
|
|
169
|
+
// or sits between turns) is its head, never the turn before's element.
|
|
170
|
+
if (el.classList.contains(FOLD_ROW) && el.nextElementSibling?.matches(`${OPENING}, ${NOTE_BOUNDARY}`)) continue;
|
|
169
171
|
const opening = el.matches(OPENING) ? el : el.querySelector(OPENING);
|
|
170
172
|
if (opening || el.matches(NOTE_BOUNDARY)) {
|
|
171
173
|
close();
|
|
@@ -326,7 +328,8 @@ export function installReviseStacks({
|
|
|
326
328
|
let gapText = "";
|
|
327
329
|
if (gap?.classList.contains("time-gap")) {
|
|
328
330
|
let before = gap.previousElementSibling;
|
|
329
|
-
|
|
331
|
+
// (A run's line or notes row hidden with its version, agent_runs.js, is hidden too.)
|
|
332
|
+
while (before?.matches(`.${HIDDEN_CLASS}, .quiet-hidden`)) before = before.previousElementSibling;
|
|
330
333
|
const fold = !turn.stub.classList.contains("open") && !!before?.matches(`.${STUB_CLASS}:not(.open)`);
|
|
331
334
|
gap.classList.toggle(GAP_HIDDEN_CLASS, fold);
|
|
332
335
|
if (fold) gapText = gap.textContent.replace(/[─\s]+$/u, "").replace(/^[─\s]+/u, "");
|
|
@@ -231,9 +231,17 @@ export function createSendTurn({
|
|
|
231
231
|
store.update({ current: { owner: "tui" } });
|
|
232
232
|
return;
|
|
233
233
|
}
|
|
234
|
-
// A stale tab sent into a session deleted meanwhile:
|
|
235
|
-
//
|
|
236
|
-
|
|
234
|
+
// A stale tab sent into a session deleted meanwhile: if this session
|
|
235
|
+
// is open, leave it as before; elsewhere, preserve the line in the
|
|
236
|
+
// start-page draft and say where it went.
|
|
237
|
+
if (e.code === "not_found") {
|
|
238
|
+
if (sentTo !== session()) {
|
|
239
|
+
composer.move?.(sentTo, "");
|
|
240
|
+
toast(`Session ${sentTo.slice(0, 8)} is gone; your message is in the new-session draft`, null, { sticky: true });
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
return leaveGoneSession(sentTo, "not_found");
|
|
244
|
+
}
|
|
237
245
|
if (sentTo === session() && closesOn?.(e)) return;
|
|
238
246
|
// A /queue to a worker that can't queue (it would steer): its words, the text kept.
|
|
239
247
|
if (e.code === "delivery_unavailable" && sentTo === session()) return addCommandBubble({ label: null, line, text: e.body?.detail || e.message, failed: true });
|
|
@@ -661,6 +661,10 @@ export function createTurnBlock({
|
|
|
661
661
|
const kept = [];
|
|
662
662
|
if (blockEl) {
|
|
663
663
|
updateBlockSummary();
|
|
664
|
+
// Its tool calls, counted (the run line's "N calls", agent_runs.js:
|
|
665
|
+
// never parsed from the summary's words); stamped before `done`, whose
|
|
666
|
+
// class change is what the history's observers settle on.
|
|
667
|
+
blockEl.dataset.calls = String(turn.gens.reduce((n, gen) => n + gen.tools.length, 0));
|
|
664
668
|
blockEl.classList.add("done");
|
|
665
669
|
// How it ended (completed, canceled, failed), live and reloaded alike.
|
|
666
670
|
blockEl.dataset.end = kind;
|
|
@@ -7,7 +7,8 @@ module Samagotchi
|
|
|
7
7
|
class Worker
|
|
8
8
|
# A peer's mail on the worker's side: the absorb and the mail wake turn
|
|
9
9
|
# it may start (WorkerInbound#absorb_mail), the hold a pass gives, and
|
|
10
|
-
# the receipts' end of every turn (PeerReceipts#turn_ended)
|
|
10
|
+
# the receipts' end of every turn (PeerReceipts#turn_ended), and the
|
|
11
|
+
# peer wake count's save (#save_peer_wakes). Reads
|
|
11
12
|
# @inbound, @exit_claim and @peer_receipts, and @unmarked_this_turn
|
|
12
13
|
# (#run_wake sets it). See docs/internals/peers.md.
|
|
13
14
|
module MailPart
|
|
@@ -48,6 +49,15 @@ module Samagotchi
|
|
|
48
49
|
Log.exception(:worker, "peer_receipts_failed", e)
|
|
49
50
|
end
|
|
50
51
|
|
|
52
|
+
# WorkerWakes' on_peer_count: the peer wake turns in a row, saved so
|
|
53
|
+
# the next worker starts from them (PeerReceipts#peer_wakes=). Logged,
|
|
54
|
+
# never raised: a lost save is a reset of the count.
|
|
55
|
+
def save_peer_wakes(count)
|
|
56
|
+
@peer_receipts.peer_wakes = count
|
|
57
|
+
rescue SystemCallError, IOError => e
|
|
58
|
+
Log.exception(:worker, "peer_wakes_not_saved", e)
|
|
59
|
+
end
|
|
60
|
+
|
|
51
61
|
def settle_peer_turn(id, result, error)
|
|
52
62
|
yielded = false
|
|
53
63
|
yield
|
data/lib/samagotchi/worker.rb
CHANGED
|
@@ -259,8 +259,12 @@ module Samagotchi
|
|
|
259
259
|
def start
|
|
260
260
|
# A scratch worker's grace for its terminal's first stream counts from here.
|
|
261
261
|
@started_at = monotonic_now
|
|
262
|
-
#
|
|
263
|
-
@
|
|
262
|
+
# What this worker did with each peer message (PeerReceipts, read once).
|
|
263
|
+
@peer_receipts = PeerReceipts.new(session_id: @session_id, state_dir: @state_dir)
|
|
264
|
+
# The wake turns' budget (delegate reports, attached context, peers), from
|
|
265
|
+
# now; the peer wakes in a row from where the last worker left them.
|
|
266
|
+
@wakes = WorkerWakes.new(grace: WAKE_START_GRACE, peer_in_a_row: @peer_receipts.peer_wakes,
|
|
267
|
+
on_peer_count: method(:save_peer_wakes))
|
|
264
268
|
# This worker holds the session now (a continue's starting marker held
|
|
265
269
|
# off any other until it did), and a continue that died moving
|
|
266
270
|
# delegates here left its intent: finish it.
|
|
@@ -293,8 +297,6 @@ module Samagotchi
|
|
|
293
297
|
@event_log.announce(type: :hook_notice, hook: "config", text: message, level: :warn, between_turns: true)
|
|
294
298
|
end
|
|
295
299
|
prune_tombstones
|
|
296
|
-
# What this worker did with each peer message (PeerReceipts, read once).
|
|
297
|
-
@peer_receipts = PeerReceipts.new(session_id: @session_id, state_dir: @state_dir)
|
|
298
300
|
settle_interrupted_turn
|
|
299
301
|
settle_stale_status
|
|
300
302
|
# Before the Bridge serves anything: a UI joining a resumed worker's
|
|
@@ -363,7 +365,7 @@ module Samagotchi
|
|
|
363
365
|
awaiting_continue: -> { @turn_flow.awaiting_continue? },
|
|
364
366
|
stopped: -> { stopped_on_disk? },
|
|
365
367
|
peer_registry: @engine.peer_registry, peer_receipts: @peer_receipts,
|
|
366
|
-
mail_cap: -> { ToolOutputCut.max_chars(nil) },
|
|
368
|
+
mail_cap: -> { ToolOutputCut.max_chars(nil) }, cache_ttl: -> { @engine.remote_cache_ttl },
|
|
367
369
|
queue_command: lambda { |line, client_id, after_file, enqueued_id, author: nil|
|
|
368
370
|
@bridge.queue_command(line, client_id: client_id, after_file: after_file,
|
|
369
371
|
enqueued_id: enqueued_id, author: author)
|