samagotchi 0.165.0 → 0.167.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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +99 -1
  3. data/docs/architecture.md +1 -0
  4. data/docs/cli.md +16 -7
  5. data/docs/configuration.md +4 -1
  6. data/docs/guardrails.md +8 -3
  7. data/docs/hooks.md +4 -6
  8. data/docs/internals/bridge.md +6 -0
  9. data/docs/internals/bundles.md +2 -4
  10. data/docs/internals/engine.md +4 -5
  11. data/docs/internals/objectives.md +141 -9
  12. data/docs/internals/remote-sessions.md +6 -7
  13. data/docs/internals/web-frontend.md +62 -24
  14. data/docs/memory.md +1 -2
  15. data/docs/releasing.md +12 -3
  16. data/docs/sessions.md +24 -6
  17. data/docs/testing.md +14 -4
  18. data/lib/samagotchi/bridge.rb +1 -1
  19. data/lib/samagotchi/bundle_command/installed_check.rb +2 -14
  20. data/lib/samagotchi/bundle_command.rb +19 -11
  21. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  22. data/lib/samagotchi/cli/command.rb +10 -0
  23. data/lib/samagotchi/compat.rb +4 -14
  24. data/lib/samagotchi/config.rb +3 -0
  25. data/lib/samagotchi/context_command.rb +2 -1
  26. data/lib/samagotchi/engine/objectives.rb +20 -1
  27. data/lib/samagotchi/engine/side_requests.rb +3 -2
  28. data/lib/samagotchi/engine/turn_end.rb +4 -1
  29. data/lib/samagotchi/engine.rb +3 -0
  30. data/lib/samagotchi/extension_load.rb +2 -26
  31. data/lib/samagotchi/guardrails/approvals.rb +59 -9
  32. data/lib/samagotchi/jsonl_store.rb +61 -0
  33. data/lib/samagotchi/memory_bundle/status.rb +3 -15
  34. data/lib/samagotchi/memory_bundle/system_bundle.rb +16 -10
  35. data/lib/samagotchi/memory_command.rb +4 -2
  36. data/lib/samagotchi/objectives.rb +43 -14
  37. data/lib/samagotchi/objectives_backing.rb +124 -0
  38. data/lib/samagotchi/objectives_check.rb +19 -126
  39. data/lib/samagotchi/objectives_command.rb +14 -7
  40. data/lib/samagotchi/objectives_record.rb +104 -0
  41. data/lib/samagotchi/objectives_track.rb +353 -0
  42. data/lib/samagotchi/plugin/sessions.rb +4 -1
  43. data/lib/samagotchi/push_command.rb +2 -1
  44. data/lib/samagotchi/remote_command.rb +2 -1
  45. data/lib/samagotchi/reply_wait/poll.rb +10 -21
  46. data/lib/samagotchi/reply_wait.rb +4 -47
  47. data/lib/samagotchi/run_options.rb +1 -1
  48. data/lib/samagotchi/schedule_command.rb +6 -0
  49. data/lib/samagotchi/schedules.rb +1 -1
  50. data/lib/samagotchi/session_access/remote.rb +7 -24
  51. data/lib/samagotchi/session_commands.rb +1 -1
  52. data/lib/samagotchi/session_inbox.rb +1 -1
  53. data/lib/samagotchi/sessions_command.rb +12 -6
  54. data/lib/samagotchi/share_command.rb +2 -1
  55. data/lib/samagotchi/tool_activity.rb +11 -1
  56. data/lib/samagotchi/tool_declarations.rb +5 -1
  57. data/lib/samagotchi/tools/delegate.rb +2 -4
  58. data/lib/samagotchi/tools/objectives_tool.rb +19 -2
  59. data/lib/samagotchi/turn_stages/objectives.rb +46 -3
  60. data/lib/samagotchi/version.rb +1 -1
  61. data/lib/samagotchi/web/participant_access.rb +1 -1
  62. data/lib/samagotchi/web/public/app.js +55 -420
  63. data/lib/samagotchi/web/public/auth_lost.js +3 -1
  64. data/lib/samagotchi/web/public/bar_fold.js +1 -1
  65. data/lib/samagotchi/web/public/chip_popover.js +5 -1
  66. data/lib/samagotchi/web/public/copy.js +2 -1
  67. data/lib/samagotchi/web/public/delivery_line.js +19 -4
  68. data/lib/samagotchi/web/public/index.html +156 -49
  69. data/lib/samagotchi/web/public/info_bar.js +1 -1
  70. data/lib/samagotchi/web/public/info_bar_model.js +8 -1
  71. data/lib/samagotchi/web/public/live_timing.js +3 -0
  72. data/lib/samagotchi/web/public/no_contact_fill.js +29 -0
  73. data/lib/samagotchi/web/public/objectives.css +14 -0
  74. data/lib/samagotchi/web/public/objectives_moves.js +82 -9
  75. data/lib/samagotchi/web/public/objectives_state.js +42 -0
  76. data/lib/samagotchi/web/public/objectives_strip.js +33 -9
  77. data/lib/samagotchi/web/public/objectives_track.js +52 -0
  78. data/lib/samagotchi/web/public/objectives_wiring.js +16 -1
  79. data/lib/samagotchi/web/public/participant.html +1 -1
  80. data/lib/samagotchi/web/public/participants_panel.js +14 -7
  81. data/lib/samagotchi/web/public/question_cards.js +7 -12
  82. data/lib/samagotchi/web/public/resync_reach.js +63 -0
  83. data/lib/samagotchi/web/public/scope.js +3 -3
  84. data/lib/samagotchi/web/public/session_fields.js +1 -0
  85. data/lib/samagotchi/web/public/session_rename.js +6 -2
  86. data/lib/samagotchi/web/public/session_state.js +6 -1
  87. data/lib/samagotchi/web/public/session_sync.js +249 -0
  88. data/lib/samagotchi/web/public/session_view.js +279 -0
  89. data/lib/samagotchi/web/public/stage_frame.js +4 -2
  90. data/lib/samagotchi/web/public/stage_stall.js +134 -0
  91. data/lib/samagotchi/web/public/stage_view.js +75 -6
  92. data/lib/samagotchi/web/public/stream_handlers.js +1 -1
  93. data/lib/samagotchi/web/public/tokens.css +2 -2
  94. data/lib/samagotchi/web/public/turn_block.js +8 -0
  95. data/lib/samagotchi/web/public/turn_html.js +1 -1
  96. data/lib/samagotchi/web/public/widget_picks.js +3 -0
  97. data/lib/samagotchi/web/public/working_set_view.js +1 -1
  98. data/lib/samagotchi/web/session_access_routes.rb +4 -15
  99. data/lib/samagotchi/web/token.rb +2 -2
  100. metadata +12 -1
@@ -0,0 +1,134 @@
1
+ // The stage's quiet signal (stage_view.js): a running turn that has sent no
2
+ // event for a while says so, since the dot blinks the same whether the
3
+ // model works or the line went dead (the Bridge's idle `: ping` never
4
+ // reaches EventSource's JS, and a running tool sends nothing between its
5
+ // start and end). The code says "stall" (stallOf, .ts-stall, data-stall);
6
+ // the user reads "quiet" (liveSlots' `quiet` and stage_model's QUIET_MS are
7
+ // other things). The rule is pure (stallOf, stallState); createStageStall
8
+ // draws it: a right-aligned span in the now row, its short text in the
9
+ // status row for a collapsed or plain stage, and the running call's clock.
10
+ // Its own module: new exports go in new modules (web-frontend.md).
11
+ import { clockText, genAge } from "./delivery_line.js";
12
+ import { node } from "./stage_slots.js";
13
+
14
+ // The levels' thresholds (ms) per kind: A, streamed or between steps; B,
15
+ // no first token yet in the step (a long prompt read, hidden reasoning).
16
+ export const STALL_MS = { A: [30000, 90000], B: [45000, 180000] };
17
+ // The stream down this long reads "reconnecting…" (a resync's own blink
18
+ // between workerGone and the new stream stays unsaid).
19
+ export const NET_MS = 1000;
20
+ // After the page shows again (visibilitychange): a background tab's
21
+ // stream may still be catching up.
22
+ export const GRACE_MS = 5000;
23
+ // The running call's clock shows from this far into it.
24
+ export const TOOL_CLOCK_MS = 10000;
25
+
26
+ const NONE = Object.freeze({ level: 0, long: "", short: "" });
27
+ const NET = Object.freeze({ level: "net", long: "reconnecting… · events paused", short: "reconnecting…" });
28
+
29
+ // The signal for a running turn: level 0 (nothing to say), 1, 2 or "net",
30
+ // and its texts (+long+ the stage's, +short+ a phone's and the status
31
+ // row's). A stream not live wins (no count: the events, not the model, are
32
+ // what paused); an explained silence says nothing: a running tool (its
33
+ // clock speaks), a blocking card, a timing note (a retry, plugins' setup),
34
+ // the end, the grace after a return.
35
+ export function stallOf({ kind = "A", silentMs = 0, toolRunning = false, blocked = false, note = "", streamLive = true, ended = false, graceUntil = 0, nowMs = 0 } = {}) {
36
+ if (ended) return NONE;
37
+ if (!streamLive) return NET;
38
+ if (toolRunning || blocked || note || nowMs < graceUntil) return NONE;
39
+ const b = kind === "B";
40
+ const [l1, l2] = STALL_MS[b ? "B" : "A"];
41
+ if (!(silentMs >= l1)) return NONE;
42
+ const clock = clockText(silentMs / 1000);
43
+ const short = b ? `thinking quietly ${clock}` : `quiet ${clock}`;
44
+ return { level: silentMs >= l2 ? 2 : 1, long: `${short} · ${b ? "no tokens yet" : "no new events"}`, short };
45
+ }
46
+
47
+ // B while the step has had no token (no gen yet, or an open one with no
48
+ // text, thinking or call); else A (a closed step: between steps).
49
+ export function stallKind(gen) {
50
+ if (!gen) return "B";
51
+ return !gen.closed && !gen.text && !gen.thinking && !gen.tools?.length ? "B" : "A";
52
+ }
53
+
54
+ // The running call's clock ("0:12") from TOOL_CLOCK_MS on; "" before, or
55
+ // without a start (a replayed call the page didn't time).
56
+ export function toolClockText(startedAt, nowMs) {
57
+ if (startedAt == null) return "";
58
+ const ms = nowMs - startedAt;
59
+ return ms >= TOOL_CLOCK_MS ? clockText(ms / 1000) : "";
60
+ }
61
+
62
+ // What a tick shows for +turn+ (turn_model.js's): the stall (stallOf) and
63
+ // the running call's clock (+toolClock+). +lastEventAt+: the page's clock
64
+ // at the turn's last event; +streamDownMs+: how long the stream hasn't been
65
+ // live (null: it is); +serverGen+: the snapshot's generation (a joiner's
66
+ // step clock, delivery_line.js genAge): before the first token a joiner
67
+ // counts from it, not from its own replay.
68
+ export function stallState({ turn, lastEventAt, nowMs, blocked = false, note = "", streamDownMs = null, ended = false, graceUntil = 0, serverGen = null }) {
69
+ const gens = turn?.gens || [];
70
+ const gen = gens[gens.length - 1];
71
+ const running = gens.flatMap((g) => g.tools || []).reverse().find((row) => row.status === "running") || null;
72
+ const kind = stallKind(gen);
73
+ let silentMs = nowMs - lastEventAt;
74
+ if (kind === "B") {
75
+ const age = genAge(gen, serverGen, nowMs);
76
+ if (age !== null) silentMs = Math.max(silentMs, age * 1000);
77
+ }
78
+ const streamLive = streamDownMs == null || streamDownMs < NET_MS;
79
+ const stall = stallOf({ kind, silentMs, toolRunning: !!running, blocked, note, streamLive, ended, graceUntil, nowMs });
80
+ return { ...stall, toolClock: running && !ended ? toolClockText(running.startedAt, nowMs) : "" };
81
+ }
82
+
83
+ // The drawer. +stage+: the stage's root (.stalled, data-stall: the hooks);
84
+ // +nowEl+: the now row (stage_slots.js drawNow rebuilds it: each draw puts
85
+ // its spans back when they were taken out); +timingSlot+: the status row's
86
+ // timing line, the head goes after it. A draw writes only when a text
87
+ // changes, so the 1 Hz tick under the threshold writes nothing.
88
+ export function createStageStall({ stage, nowEl, timingSlot }) {
89
+ const stallEl = node("span", "ts-stall");
90
+ const longEl = node("span", "long", stallEl);
91
+ const shortEl = node("span", "short", stallEl);
92
+ const clockEl = node("span", "ts-tool-clock");
93
+ const head = node("span", "ts-stall-head");
94
+ timingSlot.after(head);
95
+ let shown = { key: null, clock: null, level: 0 };
96
+
97
+ function drawLevel({ level, long, short }) {
98
+ const key = `${level}|${long}`;
99
+ if (shown.key === key) return;
100
+ shown.key = key;
101
+ shown.level = level;
102
+ stage.classList.toggle("stalled", !!level);
103
+ if (level) {
104
+ stage.dataset.stall = String(level);
105
+ nowEl.dataset.stall = String(level);
106
+ } else {
107
+ delete stage.dataset.stall;
108
+ delete nowEl.dataset.stall;
109
+ }
110
+ longEl.textContent = long;
111
+ shortEl.textContent = short;
112
+ head.textContent = short;
113
+ }
114
+
115
+ function draw(state) {
116
+ drawLevel(state);
117
+ if (state.level && stallEl.parentNode !== nowEl) nowEl.appendChild(stallEl);
118
+ else if (!state.level && stallEl.parentNode) stallEl.remove();
119
+ const clock = state.toolClock || "";
120
+ if (shown.clock !== clock) {
121
+ shown.clock = clock;
122
+ clockEl.textContent = clock;
123
+ }
124
+ if (clock && clockEl.parentNode !== nowEl) nowEl.insertBefore(clockEl, nowEl.querySelector(":scope > .task-stop"));
125
+ else if (!clock && clockEl.parentNode) clockEl.remove();
126
+ }
127
+
128
+ function reset() {
129
+ draw({ ...NONE, toolClock: "" });
130
+ shown = { key: null, clock: null, level: 0 };
131
+ }
132
+
133
+ return { draw, reset, level: () => shown.level };
134
+ }
@@ -20,6 +20,7 @@ import { chipLabelText, flashOf, handOffDue, handOffOrder, headlineOf, isPlain,
20
20
  import { createStageSlots, node } from "./stage_slots.js";
21
21
  import { createStageFrame, reducedMotion } from "./stage_frame.js";
22
22
  import { createInUseWatch } from "./stage_watch.js";
23
+ import { createStageStall, GRACE_MS, stallState } from "./stage_stall.js";
23
24
  import { formatDuration } from "./timing.js";
24
25
  import { easeScrollTo } from "./scroll.js";
25
26
  import { readStored, writeStored } from "./storage.js";
@@ -69,9 +70,13 @@ function readCollapsed() {
69
70
  // status row's Stop turn (a promise of the cancel request; the button is
70
71
  // disabled until it settles); null: no Stop turn. +onHandedOff+({pieces,
71
72
  // immediate}): a turn's pieces reached the history (reload_check.js).
73
+ // The quiet signal's inputs (stage_stall.js): +clock+() the page's time,
74
+ // +streamLive+() the session's stream is open, +timingNote+() what the turn
75
+ // waits on (live_timing.js note), +serverGen+() a joiner's generation.
72
76
  export function createStageView({
73
77
  historyEl, isNearBottom: historyNearBottom, sawText, sessionId, dockEl, centerEl, taskStop = null,
74
78
  renderMarkdown, linkRefs, workingSet = null, onCancel = null, onHandedOff = null,
79
+ clock = () => Date.now(), streamLive = () => true, timingNote = () => "", serverGen = () => null,
75
80
  }) {
76
81
  // The dock becomes a clear column: the stage's card, then the composer's
77
82
  // (its rows moved into .dock-card, which wears the glass and the focus ring).
@@ -168,6 +173,8 @@ export function createStageView({
168
173
  // Below the turn's card: the lines queued for after it (placeKind
169
174
  // "queued"), each to run as a turn of its own; they hand off last.
170
175
  const queuedSlot = node("div", "ts-queued", stage);
176
+ // The quiet signal: its span in the now row, its head after the timing line.
177
+ const stall = createStageStall({ stage, nowEl: now, timingSlot });
171
178
  const slotsView = createStageSlots({
172
179
  headline, asking, now, trail, ticks, taskStop, renderMarkdown, linkRefs,
173
180
  gens: () => view.current().turn?.gens,
@@ -212,6 +219,11 @@ export function createStageView({
212
219
  // grows to it), and whether the room's card is in the stage's view.
213
220
  let arrived = null;
214
221
  let cardInSight = true;
222
+ // The quiet signal's clocks: the turn's last event, since when the stream
223
+ // isn't live (null: it is), the grace after the page shows again.
224
+ let lastEventAt = 0;
225
+ let downSince = null;
226
+ let graceUntil = 0;
215
227
 
216
228
  const view = createTurnBlock({
217
229
  historyEl,
@@ -378,6 +390,7 @@ export function createStageView({
378
390
  raiseForApproval(blocked);
379
391
  drawPill();
380
392
  slotsView.drawNow(slots.tool, slots.quiet);
393
+ drawStall(clock(), blocked);
381
394
  slotsView.drawTrail(slots.trail, flash);
382
395
  slotsView.drawTicks(slots.ticks);
383
396
  if (rail) {
@@ -446,6 +459,31 @@ export function createStageView({
446
459
  frame.forgetContent();
447
460
  }
448
461
 
462
+ // ── the quiet signal (stage_stall.js) ─────────────────────────────────────
463
+
464
+ // At +nowMs+ (the tick's, a refresh's): what the turn's silence says.
465
+ function drawStall(nowMs, blocked = pendingCard()) {
466
+ const { turn } = view.current();
467
+ if (!holding || !turn) return;
468
+ if (streamLive()) downSince = null;
469
+ else downSince ??= nowMs;
470
+ stall.draw(stallState({
471
+ turn, lastEventAt, nowMs, blocked, note: timingNote() || "", ended: !!endKind, graceUntil, serverGen: serverGen(),
472
+ streamDownMs: downSince === null ? null : nowMs - downSince,
473
+ }));
474
+ }
475
+
476
+ // A turn event arrived (a replay's too): the silence starts over, and a
477
+ // stall shown clears at once.
478
+ function alive() {
479
+ lastEventAt = clock();
480
+ if (stall.level()) drawStall(lastEventAt);
481
+ }
482
+
483
+ document.addEventListener("visibilitychange", () => {
484
+ if (!document.hidden) graceUntil = clock() + GRACE_MS;
485
+ });
486
+
449
487
  // One line in the trail for FLASH_MS, ahead of the calls (a newer flash
450
488
  // takes its place).
451
489
  function flashTrail(what) {
@@ -631,6 +669,8 @@ export function createStageView({
631
669
  cancel.hidden = true;
632
670
  chipLabel.textContent = "";
633
671
  slotsView.reset();
672
+ stall.reset();
673
+ downSince = null;
634
674
  rail?.reset();
635
675
  promptSlot.classList.remove("full");
636
676
  thinkingLine = null;
@@ -771,6 +811,7 @@ export function createStageView({
771
811
  settled = true;
772
812
  startedAt = Date.parse(data?.started_at) || Date.now();
773
813
  emptySlots();
814
+ lastEventAt = clock();
774
815
  // The turn's prompt bubble (app.js found or drew it) sits in the prompt
775
816
  // line until the hand-off takes it back first.
776
817
  if (data?.promptBubble) promptSlot.appendChild(data.promptBubble);
@@ -784,14 +825,30 @@ export function createStageView({
784
825
  refresh();
785
826
  },
786
827
  generationStarted(data, now = null) {
828
+ alive();
787
829
  releaseHeldWait();
788
830
  view.generationStarted(data, now);
789
831
  },
790
- chunk: (data) => view.chunk(data),
791
- generationRestarted: (data) => view.generationRestarted(data),
792
- generationCompleted: () => view.generationCompleted(),
793
- toolStarted: (data) => view.toolStarted(data),
794
- toolCompleted: (data) => view.toolCompleted(data),
832
+ chunk(data) {
833
+ alive();
834
+ return view.chunk(data);
835
+ },
836
+ generationRestarted(data) {
837
+ alive();
838
+ return view.generationRestarted(data);
839
+ },
840
+ generationCompleted() {
841
+ alive();
842
+ return view.generationCompleted();
843
+ },
844
+ toolStarted(data) {
845
+ alive();
846
+ return view.toolStarted(data);
847
+ },
848
+ toolCompleted(data) {
849
+ alive();
850
+ return view.toolCompleted(data);
851
+ },
795
852
  turnEnded(args) {
796
853
  const kept = view.turnEnded(args) || [];
797
854
  if (!holding) return kept;
@@ -816,18 +873,23 @@ export function createStageView({
816
873
  // A hook's notice and a plugin's nudge go into their step inside the
817
874
  // closed cloud; they flash in the trail meanwhile (flashOf).
818
875
  notice(data) {
876
+ alive();
819
877
  const placed = view.notice(data);
820
878
  if (placed) flashTrail(flashOf("notice", data));
821
879
  return placed;
822
880
  },
823
881
  steer(data) {
882
+ alive();
824
883
  const placed = view.steer(data);
825
884
  if (placed) flashTrail(flashOf("steer", data));
826
885
  return placed;
827
886
  },
828
887
  // A warn card (a plugin's warning) stays in sight: false puts it in the
829
888
  // extras (place), not in its step inside the closed cloud.
830
- card: (el) => !el.classList.contains("warn") && view.card(el),
889
+ card(el) {
890
+ alive();
891
+ return !el.classList.contains("warn") && view.card(el);
892
+ },
831
893
  flush: () => view.flush(),
832
894
  answerReady() {
833
895
  settled = true;
@@ -837,6 +899,7 @@ export function createStageView({
837
899
  askingText: () => view.askingText(),
838
900
  // The asking slot pairs them on its next draw.
839
901
  questionRefs(refs) {
902
+ alive();
840
903
  view.questionRefs(refs);
841
904
  scheduleRefresh();
842
905
  },
@@ -860,6 +923,7 @@ export function createStageView({
860
923
  if (folding) finishFold();
861
924
  const where = placeFor({ live: holding, handingOff: false, kind: placeKind(el) });
862
925
  if (where === "history") return false;
926
+ alive();
863
927
  if (where === "queued") {
864
928
  ensureQueuedSlot();
865
929
  queuedSlot.appendChild(el);
@@ -917,6 +981,11 @@ export function createStageView({
917
981
  cancel.hidden = !onCancel;
918
982
  show();
919
983
  },
984
+ // The page's clock ticks (app.js, the live timing's 200 ms / 1 s): the
985
+ // quiet signal and the running call's clock.
986
+ tick(nowMs = clock()) {
987
+ drawStall(nowMs);
988
+ },
920
989
  handOff,
921
990
  root: stage,
922
991
  scrollEl: scroller,
@@ -4,7 +4,7 @@
4
4
  //
5
5
  // Everything that changes while the page runs is read through deps at the
6
6
  // event, never captured at creation: the open session (selected()), its
7
- // fields (store.current: app.js forgetSession replaces the object), the page's
7
+ // fields (store.current: session_view.js forgetSession replaces the object), the page's
8
8
  // capabilities, the composer's text. A session switch mid-stream is handled
9
9
  // as before: the handlers act on whatever is open when the event comes.
10
10
  //
@@ -1,12 +1,12 @@
1
1
  /* The web UI's colour tokens, shared by the owner's page (index.html) and the participant page (participant.html): the dark :root (the default) and the light set under prefers-color-scheme: light. Everything else reads them through var(). */
2
- :root{color-scheme:dark;--bg:#0b0d11;--bg-panel:#151821;--bg-inset:#0f1115;--bg-raised:#22262f;--bg-hover:#1b1f27;--border:#1f232b;--border-strong:#2d333f;--text:#e6e8eb;--text-bright:#f0f3f6;--text-2:#c9d1d9;--text-3:#9aa4b2;--text-muted:#8b949e;--text-faint:#6e7681;--accent:#5aa9ff;--accent-strong:#0071e3;--accent-bg:#0f2340;--accent-ring:rgba(90,169,255,.18);--primary:#0071e3;--ok:#3fb950;--ok-text:#7ee787;--ok-bg:#1a2e1a;--warn:#d29922;--warn-text:#e3b341;--warn-bright:#f2cc60;--warn-bg:#2b2108;--warn-border:#6b5416;--danger:#f85149;--danger-bg:#da3633;--danger-text:#ff7b72;--danger-bg-dim:#3d1f1f;--think:#8957e5;--think-text:#d2a8ff;--accent-border:#1a3458;--pick-border:#79c0ff;--accent-tint:color-mix(in srgb,var(--accent) 7%,transparent);--narr:color-mix(in srgb,var(--accent) 38%,var(--text-muted));
2
+ :root{color-scheme:dark;--bg:#0b0d11;--bg-top:#131d29;--bg-panel:#151821;--bg-inset:#0f1115;--bg-raised:#22262f;--bg-hover:#1b1f27;--border:#1f232b;--border-strong:#2d333f;--text:#e6e8eb;--text-bright:#f0f3f6;--text-2:#c9d1d9;--text-3:#9aa4b2;--text-muted:#8b949e;--text-faint:#6e7681;--accent:#5aa9ff;--accent-strong:#0071e3;--accent-bg:#0f2340;--accent-ring:rgba(90,169,255,.18);--primary:#0071e3;--ok:#3fb950;--ok-text:#7ee787;--ok-bg:#1a2e1a;--warn:#d29922;--warn-text:#e3b341;--warn-bright:#f2cc60;--warn-bg:#2b2108;--warn-border:#6b5416;--danger:#f85149;--danger-bg:#da3633;--danger-text:#ff7b72;--danger-bg-dim:#3d1f1f;--think:#8957e5;--think-text:#d2a8ff;--accent-border:#1a3458;--pick-border:#79c0ff;--accent-tint:color-mix(in srgb,var(--accent) 7%,transparent);--narr:color-mix(in srgb,var(--accent) 38%,var(--text-muted));
3
3
  --glass-bg:color-mix(in srgb,var(--bg-panel) 70%,transparent);--glass-border:rgba(255,255,255,.08);--glass-highlight:rgba(255,255,255,.05);--glass-shadow:0 8px 30px rgba(0,0,0,.35);
4
4
  --diff-add-bg:rgba(63,185,80,.14);--diff-add-text:#aff5b4;--diff-del-bg:rgba(248,81,73,.14);--diff-del-text:#ffc1bc;
5
5
  --code-text:#c9d1d9;--code-keyword:#ff7b72;--code-string:#a5d6ff;--code-comment:#8b949e;--code-constant:#79c0ff;--code-func:#d2a8ff;--code-type:#ffa657;
6
6
  --card-hover-border:rgba(255,255,255,.14);--on-solid:#fff;--on-warn:#fff;--text-hover:#fff;--badge-bg:rgba(255,255,255,.08);--badge-ring:rgba(255,255,255,.18);--shadow-strong:rgba(0,0,0,.5);--backdrop:rgba(0,0,0,.85);--toast-shadow:0 6px 24px rgba(0,0,0,.25);--ws-stale-opacity:.4;--ws-rule:var(--border-strong);--ws-muted:var(--text-3);--ws-faint:var(--text-muted);--ws-act-border:#444c56;--author-1:#79c0ff;--author-2:#d2a8ff;--author-3:#7ee787;--author-4:#ffa657;--author-5:#ff7b72;--author-6:#f2cc60;--author-owner:var(--text-3);--time-gap:var(--text-faint);
7
7
  --claim-mark:color-mix(in srgb,var(--warn-bright) 32%,transparent);--claim-ring:var(--warn)}
8
8
  /* Light palette: follows the system setting. :not([data-theme="dark"]) leaves room for a later in-page toggle (data-theme on <html>); there is none yet. Each palette sets color-scheme, so native radios, inputs and scrollbars follow it. */
9
- @media (prefers-color-scheme:light){:root:not([data-theme="dark"]){color-scheme:light;--bg:#f5f6f8;--bg-panel:#ffffff;--bg-inset:#f1f3f6;--bg-raised:#e8ebf0;--bg-hover:#eceff4;--border:#dde1e7;--border-strong:#c3c9d2;--text:#1f2328;--text-bright:#0d1117;--text-2:#2f363d;--text-3:#475160;--text-muted:#57606a;--text-faint:#636c76;--accent:#0066cc;--accent-strong:#0058b0;--accent-bg:#e3f0ff;--accent-ring:rgba(0,102,204,.2);--primary:#0071e3;--ok:#1a7f37;--ok-text:#116329;--ok-bg:#dafbe1;--warn:#9a6700;--warn-text:#7d4e00;--warn-bright:#875c00;--warn-bg:#fff6cc;--warn-border:#d4a72c;--danger:#cf222e;--danger-bg:#cf222e;--danger-text:#a40e26;--danger-bg-dim:#ffebe9;--think:#8250df;--think-text:#6639ba;--accent-border:#b3d4f7;--pick-border:#0969da;
9
+ @media (prefers-color-scheme:light){:root:not([data-theme="dark"]){color-scheme:light;--bg:#f5f6f8;--bg-top:#dde8f4;--bg-panel:#ffffff;--bg-inset:#f1f3f6;--bg-raised:#e8ebf0;--bg-hover:#eceff4;--border:#dde1e7;--border-strong:#c3c9d2;--text:#1f2328;--text-bright:#0d1117;--text-2:#2f363d;--text-3:#475160;--text-muted:#57606a;--text-faint:#636c76;--accent:#0066cc;--accent-strong:#0058b0;--accent-bg:#e3f0ff;--accent-ring:rgba(0,102,204,.2);--primary:#0071e3;--ok:#1a7f37;--ok-text:#116329;--ok-bg:#dafbe1;--warn:#9a6700;--warn-text:#7d4e00;--warn-bright:#875c00;--warn-bg:#fff6cc;--warn-border:#d4a72c;--danger:#cf222e;--danger-bg:#cf222e;--danger-text:#a40e26;--danger-bg-dim:#ffebe9;--think:#8250df;--think-text:#6639ba;--accent-border:#b3d4f7;--pick-border:#0969da;
10
10
  --glass-border:rgba(31,35,40,.10);--glass-highlight:rgba(255,255,255,.7);--glass-shadow:0 8px 30px rgba(31,35,40,.10);
11
11
  --diff-add-bg:rgba(26,127,55,.12);--diff-add-text:#116329;--diff-del-bg:rgba(207,34,46,.10);--diff-del-text:#82071e;
12
12
  --code-text:#1f2328;--code-keyword:#cf222e;--code-string:#0a3069;--code-comment:#57606a;--code-constant:#0550ae;--code-func:#8250df;--code-type:#953800;
@@ -23,6 +23,7 @@
23
23
  // closed with text keeps its chrome: a line steered in after it left it alone
24
24
  // in the block when the answer went, and its summary is the way to its text.
25
25
  import { authorBadge, PAIR } from "./participant_names.js";
26
+ import { isParticipantAuthor } from "./participant_model.js";
26
27
  import { applyRowTemplate } from "./review_apply.js";
27
28
  import { html, nothing, render } from "./vendor/lit-html.js";
28
29
  import { answerRefsOf, setAnswerRefs } from "./answer_refs.js";
@@ -502,6 +503,8 @@ export function createTurnBlock({
502
503
  el = document.createElement("div");
503
504
  el.className = "activity-row";
504
505
  el.dataset.key = r.row.key;
506
+ // What the row ran, for what reads a finished block (objectives_moves.js).
507
+ if (r.row.tool) el.dataset.tool = r.row.tool;
505
508
  entry.rows.set(r.row.key, el);
506
509
  drawRow(el, r.row);
507
510
  addItem(entry, el);
@@ -653,6 +656,8 @@ export function createTurnBlock({
653
656
  if (blockEl) {
654
657
  updateBlockSummary();
655
658
  blockEl.classList.add("done");
659
+ // How it ended (completed, canceled, failed), live and reloaded alike.
660
+ blockEl.dataset.end = kind;
656
661
  // The outline (turn_model.js outlineRuns), for when it is opened. Closed
657
662
  // as a reload draws it, unless the turn was cut short (block_open.js).
658
663
  // The stage decides again as the block reaches the history.
@@ -701,6 +706,8 @@ export function createTurnBlock({
701
706
  reset();
702
707
  turn = model.newTurn();
703
708
  createBlock();
709
+ // A participant's turn says so on its block (a reload's: drawnGroupPieces).
710
+ if (isParticipantAuthor(data.author || data.origin?.author)) blockEl.dataset.participant = "1";
704
711
  const r = model.turnStarted(turn);
705
712
  apply(r);
706
713
  if (data.prompt) {
@@ -1002,6 +1009,7 @@ export function turnHistoryNodes(items, timing, { thumbs, workingSet = false, no
1002
1009
  const prompt = group.user != null ? items[group.user] : null;
1003
1010
  const drawn = drawnTurnNodes(group, items, { thumbs, capabilities, cards });
1004
1011
  if (drawn.block) {
1012
+ if (isParticipantAuthor(prompt?.author)) drawn.block.dataset.participant = "1";
1005
1013
  if (workingSet) drawn.block.querySelector(":scope > summary > .tw-sum")?.prepend(nodesOf(footprintTemplate(groupItems(group, ordinal), ordinal)));
1006
1014
  blockTurns.push(ordinal);
1007
1015
  }
@@ -149,7 +149,7 @@ function tailClip(text) {
149
149
  // +stop+: the live row's stop-task button (a node), after the title.
150
150
  export function toolRowTemplate(row, opts = {}) {
151
151
  const wrong = row.guardrail?.should_have_asked ? " guardrail-wrong" : "";
152
- return html`<div class=${`activity-row${wrong}`} data-key=${row.key}>${toolRowInnerTemplate(row, opts)}</div>`;
152
+ return html`<div class=${`activity-row${wrong}`} data-key=${row.key} data-tool=${row.tool || nothing}>${toolRowInnerTemplate(row, opts)}</div>`;
153
153
  }
154
154
 
155
155
  export function toolRowInnerTemplate(row, { thumbs = () => nothing, stop = nothing } = {}) {
@@ -11,6 +11,8 @@
11
11
  //
12
12
  // A module of its own: static JS is cached at unversioned URLs.
13
13
 
14
+ import { noContactFill } from "./no_contact_fill.js";
15
+
14
16
  // What a row starts with: its recommended option picked, no note.
15
17
  export function initialPicks(rows) {
16
18
  return (rows || []).map((r) => ({ pick: r.recommended != null ? String(r.recommended) : null, note: "" }));
@@ -91,6 +93,7 @@ export function drawPicks(picks, { fill, doc = document }) {
91
93
  add.addEventListener("click", () => {
92
94
  const input = el(doc, "input", "wp-note");
93
95
  input.type = "text";
96
+ noContactFill(input, "chi-pick-note", { prose: true });
94
97
  input.placeholder = "a word for this row";
95
98
  input.setAttribute("aria-label", `Note for ${id}`);
96
99
  input.addEventListener("input", () => { state[k].note = input.value; });
@@ -344,7 +344,7 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
344
344
  ${urls.length ? html`<div class="ctx-pop-meta">urls · ${urls.length}</div>${labelsTemplate(fold(urls, POP_BUDGET).labels, opts)}` : nothing}
345
345
  ${added.length ? html`<div class="ctx-pop-meta">adding · ${added.length}</div>${added.map((it) => rowTemplate(it, opts))}` : nothing}
346
346
  ${pend.size ? html`<div class="ws-pending" role="status"><span class="ws-pending-t">${pend.size} change${pend.size === 1 ? "" : "s"} pending<span class="ws-pending-when"> · apply at the next turn's start</span></span><button type="button" class="ws-act-b" data-ws="undo-all">undo all</button></div>` : nothing}
347
- ${sendLine ? html`<form class="ws-add" data-ws="add-form"><input class="ws-add-in" type="text" name="key" placeholder="+ path, memory:NAME or URL" aria-label="Add to the working set: a path, memory:NAME or a URL" autocomplete="off" autocapitalize="off" spellcheck="false" enterkeyhint="go"><button type="submit" class="ws-act-b">add</button></form>` : nothing}
347
+ ${sendLine ? html`<form class="ws-add" data-ws="add-form"><input class="ws-add-in" type="text" name="key" placeholder="+ path, memory:ENTRY or URL" aria-label="Add to the working set: a path, memory:ENTRY or a URL" autocomplete="off" autocapitalize="off" spellcheck="false" enterkeyhint="go"><button type="submit" class="ws-act-b">add</button></form>` : nothing}
348
348
  <div class="ctx-pop-meta ws-hint">A file opens its ref; a step tag goes to the call.${sendLine ? " Drop sends stubs instead of an item's reads from the next turn; add asks the model to read one first." : ""}${sendLine && forget ? " Pin keeps an item from the model's forget." : ""} Esc closes.</div>`;
349
349
  render(tpl, popover.pop);
350
350
  }
@@ -188,16 +188,13 @@ module Samagotchi
188
188
  # (SessionAccess::Local#wait_reply). Body: cursor, baseline
189
189
  # ({messages, question_id, last_turn}, as the prepare route gave it),
190
190
  # turn, queued, ended_before, owner_grace (seconds, null: wait for
191
- # whatever wakes a worker), timeout (seconds, capped), running_look
192
- # (the last timeout's, as it came). 200: the ReplyWait::Result's
191
+ # whatever wakes a worker), timeout (seconds, capped); a 0.165
192
+ # client's running_look is ignored. 200: the ReplyWait::Result's
193
193
  # fields (status: done, waiting_for_answer, no_reply, error, stopped,
194
194
  # timeout or worker_gone; text, file, question, outcome, …; never the
195
195
  # Session) and parent_strategy, what a parent may pick on the
196
196
  # session's questions here (ParentReport.strategy_for). A timeout
197
- # status: ask again, with its running_look ({last_end, claimed}, or
198
- # null: the running turn this slice saw, so a settle between two
199
- # slices still ends the wait). 503 server_stopping when chi web stops
200
- # mid-wait.
197
+ # status: ask again. 503 server_stopping when chi web stops mid-wait.
201
198
  def handle_wait(req, id)
202
199
  body = body_hash(req) or return error_response(400, "invalid_json", "invalid JSON body")
203
200
  options, error = wait_options(body)
@@ -229,15 +226,8 @@ module Samagotchi
229
226
  end
230
227
 
231
228
  timeout = [numbers["timeout"] || WAIT_MAX_SECONDS, WAIT_MAX_SECONDS].min
232
- look = body["running_look"]
233
- running_look = look.nil? ? nil : ReplyWait::RunningLook.from_h(look)
234
- if !look.nil? && running_look.nil?
235
- return [nil, error_response(400, "invalid_wait", "running_look is {last_end, claimed: [file names]}")]
236
- end
237
-
238
229
  [{ cursor: strings["cursor"], turn: strings["turn"], baseline: baseline, timeout: timeout,
239
- owner_grace: numbers["owner_grace"], queued: body["queued"] == true, ended_before: body["ended_before"] == true,
240
- running_look: running_look }, nil]
230
+ owner_grace: numbers["owner_grace"], queued: body["queued"] == true, ended_before: body["ended_before"] == true }, nil]
241
231
  end
242
232
 
243
233
  def wait_baseline(raw)
@@ -258,7 +248,6 @@ module Samagotchi
258
248
  RESULT_FIELDS.each { |key| json[key] = result[key] }
259
249
  json[:text] = json[:text]&.dup&.force_encoding(Encoding::UTF_8)&.scrub
260
250
  json[:question] = result.question&.to_file
261
- json[:running_look] = result.running_look&.to_h
262
251
  json[:parent_strategy] = strategy_json(strategy)
263
252
  json
264
253
  end
@@ -10,10 +10,10 @@ require_relative "../redacted_inspect"
10
10
 
11
11
  module Samagotchi
12
12
  module Web
13
- # The access token of `chi web` on the LAN (web.host: lan): anyone
13
+ # The one access token of `chi web` (LAN link, --tunnel, public_url/proxy): anyone
14
14
  # who has it can run commands as you, so it lives in one file only you
15
15
  # can read, $XDG_STATE_HOME/samagotchi/web-token (0600). It is made on
16
- # the first LAN start and kept, so a phone's bookmark survives
16
+ # the first start that needs it and kept, so a phone's bookmark survives
17
17
  # restarts; `chi web --new-token` replaces it. A loopback-only chi web
18
18
  # never reads it. The owner's cookie for this machine's 127.0.0.1
19
19
  # holds #loopback_cookie, never the token: a server on any other local
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.165.0
4
+ version: 0.167.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dedov
@@ -460,6 +460,7 @@ files:
460
460
  - lib/samagotchi/installed_versions.rb
461
461
  - lib/samagotchi/interrupted_turn.rb
462
462
  - lib/samagotchi/iteration_limit.rb
463
+ - lib/samagotchi/jsonl_store.rb
463
464
  - lib/samagotchi/judgments_command.rb
464
465
  - lib/samagotchi/kernel_loop.rb
465
466
  - lib/samagotchi/last_turn.rb
@@ -563,9 +564,12 @@ files:
563
564
  - lib/samagotchi/note_move.rb
564
565
  - lib/samagotchi/objectives.rb
565
566
  - lib/samagotchi/objectives_audit.rb
567
+ - lib/samagotchi/objectives_backing.rb
566
568
  - lib/samagotchi/objectives_check.rb
567
569
  - lib/samagotchi/objectives_command.rb
568
570
  - lib/samagotchi/objectives_edit.rb
571
+ - lib/samagotchi/objectives_record.rb
572
+ - lib/samagotchi/objectives_track.rb
569
573
  - lib/samagotchi/output_formatter.rb
570
574
  - lib/samagotchi/owner_lock.rb
571
575
  - lib/samagotchi/owner_prompt.rb
@@ -978,6 +982,7 @@ files:
978
982
  - lib/samagotchi/web/public/model_pick.js
979
983
  - lib/samagotchi/web/public/model_picker.js
980
984
  - lib/samagotchi/web/public/more_sheet.js
985
+ - lib/samagotchi/web/public/no_contact_fill.js
981
986
  - lib/samagotchi/web/public/notice_links.js
982
987
  - lib/samagotchi/web/public/notifications.js
983
988
  - lib/samagotchi/web/public/notify.js
@@ -985,7 +990,9 @@ files:
985
990
  - lib/samagotchi/web/public/objectives_entry.js
986
991
  - lib/samagotchi/web/public/objectives_model.js
987
992
  - lib/samagotchi/web/public/objectives_moves.js
993
+ - lib/samagotchi/web/public/objectives_state.js
988
994
  - lib/samagotchi/web/public/objectives_strip.js
995
+ - lib/samagotchi/web/public/objectives_track.js
989
996
  - lib/samagotchi/web/public/objectives_wiring.js
990
997
  - lib/samagotchi/web/public/owner_claim.js
991
998
  - lib/samagotchi/web/public/owner_verify.js
@@ -1011,6 +1018,7 @@ files:
1011
1018
  - lib/samagotchi/web/public/refs.js
1012
1019
  - lib/samagotchi/web/public/reload_check.js
1013
1020
  - lib/samagotchi/web/public/restore.js
1021
+ - lib/samagotchi/web/public/resync_reach.js
1014
1022
  - lib/samagotchi/web/public/review_apply.js
1015
1023
  - lib/samagotchi/web/public/review_history.js
1016
1024
  - lib/samagotchi/web/public/review_start.js
@@ -1027,7 +1035,9 @@ files:
1027
1035
  - lib/samagotchi/web/public/session_rename.js
1028
1036
  - lib/samagotchi/web/public/session_state.js
1029
1037
  - lib/samagotchi/web/public/session_store.js
1038
+ - lib/samagotchi/web/public/session_sync.js
1030
1039
  - lib/samagotchi/web/public/session_title.js
1040
+ - lib/samagotchi/web/public/session_view.js
1031
1041
  - lib/samagotchi/web/public/sessions_list.js
1032
1042
  - lib/samagotchi/web/public/settings_chip.js
1033
1043
  - lib/samagotchi/web/public/settings_panel.js
@@ -1036,6 +1046,7 @@ files:
1036
1046
  - lib/samagotchi/web/public/stage_frame.js
1037
1047
  - lib/samagotchi/web/public/stage_model.js
1038
1048
  - lib/samagotchi/web/public/stage_slots.js
1049
+ - lib/samagotchi/web/public/stage_stall.js
1039
1050
  - lib/samagotchi/web/public/stage_view.js
1040
1051
  - lib/samagotchi/web/public/stage_watch.js
1041
1052
  - lib/samagotchi/web/public/stale_params.js