samagotchi 0.162.0 → 0.164.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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -1
  3. data/docs/architecture.md +2 -2
  4. data/docs/bundles.md +4 -2
  5. data/docs/cli.md +7 -2
  6. data/docs/configuration.md +1 -1
  7. data/docs/internals/block-renderers.md +3 -1
  8. data/docs/internals/bridge.md +37 -24
  9. data/docs/internals/inline-widgets.md +5 -2
  10. data/docs/internals/remote-sessions.md +7 -2
  11. data/docs/internals/web-frontend.md +1 -1
  12. data/docs/memory.md +8 -2
  13. data/docs/sessions.md +3 -2
  14. data/docs/sub-agent.md +11 -0
  15. data/docs/testing.md +8 -2
  16. data/lib/samagotchi/block_renderers.rb +14 -4
  17. data/lib/samagotchi/bridge/turn_drawings/synth.rb +7 -3
  18. data/lib/samagotchi/bridge/turn_drawings.rb +45 -30
  19. data/lib/samagotchi/bundles/inline-widgets/manifest.yml +2 -2
  20. data/lib/samagotchi/bundles/inline-widgets/plugin.rb +8 -4
  21. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  22. data/lib/samagotchi/cli/parent_wait.rb +5 -1
  23. data/lib/samagotchi/continue_intent.rb +48 -0
  24. data/lib/samagotchi/message_parts.rb +13 -0
  25. data/lib/samagotchi/note_command.rb +3 -6
  26. data/lib/samagotchi/parent_report.rb +3 -2
  27. data/lib/samagotchi/project_command.rb +74 -6
  28. data/lib/samagotchi/project_subfolders.rb +188 -0
  29. data/lib/samagotchi/send_command/parent_gate.rb +8 -5
  30. data/lib/samagotchi/send_command.rb +139 -34
  31. data/lib/samagotchi/session_access/local.rb +6 -0
  32. data/lib/samagotchi/session_access/remote.rb +25 -0
  33. data/lib/samagotchi/session_continue.rb +5 -3
  34. data/lib/samagotchi/session_inbox_delivery.rb +54 -7
  35. data/lib/samagotchi/session_manager/delivery.rb +3 -1
  36. data/lib/samagotchi/terminal_ui/join_replay.rb +2 -2
  37. data/lib/samagotchi/version.rb +1 -1
  38. data/lib/samagotchi/web/message_display.rb +45 -36
  39. data/lib/samagotchi/web/public/app.js +8 -7
  40. data/lib/samagotchi/web/public/apple-touch-icon.png +0 -0
  41. data/lib/samagotchi/web/public/data.js +4 -6
  42. data/lib/samagotchi/web/public/favicon.svg +1 -1
  43. data/lib/samagotchi/web/public/icons/chi-180.png +0 -0
  44. data/lib/samagotchi/web/public/icons/chi-192.png +0 -0
  45. data/lib/samagotchi/web/public/icons/chi-512.png +0 -0
  46. data/lib/samagotchi/web/public/inline_widgets.js +4 -1
  47. data/lib/samagotchi/web/public/reload_check.js +7 -4
  48. data/lib/samagotchi/web/public/time_gaps.js +1 -2
  49. data/lib/samagotchi/web/public/timing.js +49 -224
  50. data/lib/samagotchi/web/public/turn_block.js +40 -122
  51. data/lib/samagotchi/web/public/turn_html.js +3 -2
  52. data/lib/samagotchi/web/public/widget_walk.js +14 -4
  53. data/lib/samagotchi/web/reload_check_route.rb +6 -3
  54. data/lib/samagotchi/web/session_access_routes.rb +8 -1
  55. data/lib/samagotchi/web/session_show.rb +8 -24
  56. metadata +3 -1
@@ -76,12 +76,19 @@ module Samagotchi
76
76
  # GET /api/sessions/resolve?id=PREFIX: the full id of the session an id
77
77
  # or a unique prefix names (SessionAccess::Local#resolve). 200 {id};
78
78
  # 404 not_found; 400 ambiguous_id with ids (the sessions it names).
79
+ # With head=1 (the owner's alone: a participant's answer stays {id}),
80
+ # where input for it goes (SessionAccess::Local#head): 200 {id, asked,
81
+ # via}, id the chain's newest link of a continued one.
79
82
  def handle_resolve(req)
80
83
  given = req.params["id"].to_s
81
84
  return session_not_found(given) unless Session.valid_id?(given)
82
85
  return participant_resolve(principal(req).grant, given) unless principal(req).owner?
83
86
 
84
- json_response(200, { id: session_access.resolve(given) })
87
+ id = session_access.resolve(given)
88
+ return json_response(200, { id: id }) unless truthy_param?(req.params["head"])
89
+
90
+ head = session_access.head(id)
91
+ json_response(200, { id: head.id, asked: head.asked, via: head.via.to_s })
85
92
  rescue Session::AmbiguousId => e
86
93
  refusal_response(400, "ambiguous_id", e, ids: e.ids)
87
94
  rescue ArgumentError # NotFound, a file that won't load
@@ -69,22 +69,13 @@ module Samagotchi
69
69
  session_json = shown_session_json(session, snapshot, owner, persisted)
70
70
  raw_messages = live_or_saved(turn_snapshot, "messages") { session.messages }
71
71
  timing = timing_payload(id, live_metrics: snapshot && snapshot["metrics"], persisted: persisted)
72
- parts = req.params["parts"] == "1"
73
- # A page that draws finished turns from their drawings (drawings=1,
74
- # with parts=1): the valid lines stamp their items, which lose their
75
- # parts. An older page (no drawings=1) reads what it always did.
76
- # A live worker from before turn drawings lists no of_turn on its
77
- # cards: its turns all draw as before.
78
- drawings = parts && req.params["drawings"] == "1" && (!live || worker_draws?(id))
72
+ # Every finished turn is drawn from a line (a real one, else one
73
+ # made from its messages): its items are stamped, and its drawing
74
+ # goes in turn_drawings. The running turn has none yet.
79
75
  raw_cards = live_or_saved(turn_snapshot, "cards") { saved_cards(id, messages: raw_messages) }
80
- drawn = if drawings
81
- drawn_lines(id, raw_messages, timing: timing, entries: raw_cards, cwd: session.working_directory,
82
- skip_turn_id: current_turn.is_a?(Hash) ? current_turn["turn_id"] : nil)
83
- else
84
- []
85
- end
86
- messages = messages_for_display(raw_messages, parts: parts, cwd: session.working_directory,
87
- drawings: drawn, strip_drawn: true)
76
+ drawn = drawn_lines(id, raw_messages, timing: timing, entries: raw_cards, cwd: session.working_directory,
77
+ skip_turn_id: current_turn.is_a?(Hash) ? current_turn["turn_id"] : nil)
78
+ messages = messages_for_display(raw_messages, cwd: session.working_directory, drawings: drawn)
88
79
  json_response(200, {
89
80
  session: session_json,
90
81
  history: read_history(id),
@@ -145,21 +136,14 @@ module Samagotchi
145
136
  started_at: active.is_a?(Hash) ? active["started_at"] : nil)
146
137
  end
147
138
 
148
- # Whether the session's live worker names turn drawings in its
149
- # sidecar's features (Bridge::TurnDrawings::FEATURE); false when its
150
- # link can't be read as live.
151
- def worker_draws?(id)
152
- link = worker_link(id)
153
- link.live? && Array(link.sidecar.features).include?(Bridge::TurnDrawings::FEATURE)
154
- end
155
-
156
139
  # The lines the show draws +messages+' turns from (the live snapshot's
157
140
  # messages, else the file's), one per finished turn:
158
141
  # Bridge::TurnDrawings.cover over the session's file (.read, cached by
159
142
  # its size and mtime), the turns no line covers made from their
160
143
  # messages with the show's +timing+ records and CardStore +entries+.
161
144
  # A file that can't be read gives no lines: every turn is made. Should
162
- # the cover itself fail, the show draws its turns as before (no line).
145
+ # the cover itself fail, no turn has a line: the page draws each item
146
+ # as a plain row (turn_block.js, the fallback).
163
147
  def drawn_lines(id, messages, timing:, entries:, cwd:, skip_turn_id:)
164
148
  dir = @session_class.session_dir(id, state_dir: default_state_dir)
165
149
  lines = Degrade.call(:web, "turn_drawings_unreadable", fallback: []) { Bridge::TurnDrawings.read(dir) }
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.162.0
4
+ version: 0.164.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dedov
@@ -341,6 +341,7 @@ files:
341
341
  - lib/samagotchi/context_status.rb
342
342
  - lib/samagotchi/context_usage.rb
343
343
  - lib/samagotchi/context_window.rb
344
+ - lib/samagotchi/continue_intent.rb
344
345
  - lib/samagotchi/continue_offer.rb
345
346
  - lib/samagotchi/cut.rb
346
347
  - lib/samagotchi/cut_policy.rb
@@ -604,6 +605,7 @@ files:
604
605
  - lib/samagotchi/project_id_clash.rb
605
606
  - lib/samagotchi/project_init.rb
606
607
  - lib/samagotchi/project_scope.rb
608
+ - lib/samagotchi/project_subfolders.rb
607
609
  - lib/samagotchi/prompt.rb
608
610
  - lib/samagotchi/prompt_files.rb
609
611
  - lib/samagotchi/prompt_history.rb