samagotchi 0.148.0 → 0.149.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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -1
  3. data/docs/architecture.md +1 -1
  4. data/docs/bundles.md +38 -1
  5. data/docs/cli.md +17 -0
  6. data/docs/configuration.md +4 -2
  7. data/docs/guardrails.md +2 -1
  8. data/docs/hooks.md +2 -1
  9. data/docs/internals/objectives.md +264 -0
  10. data/docs/internals/web-frontend.md +4 -1
  11. data/docs/plugins.md +4 -2
  12. data/docs/releasing.md +1 -1
  13. data/docs/sessions.md +42 -0
  14. data/docs/system-one.md +17 -1
  15. data/lib/samagotchi/bundles/coordinator/manifest.yml +6 -4
  16. data/lib/samagotchi/bundles/coordinator/plugin.rb +3 -2
  17. data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +9 -0
  18. data/lib/samagotchi/bundles/decision-card/manifest.yml +13 -0
  19. data/lib/samagotchi/bundles/decision-card/plugin.rb +280 -0
  20. data/lib/samagotchi/bundles/dev/manifest.yml +3 -2
  21. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  22. data/lib/samagotchi/config.rb +7 -1
  23. data/lib/samagotchi/context_note.rb +17 -5
  24. data/lib/samagotchi/engine.rb +113 -6
  25. data/lib/samagotchi/engine_peers.rb +11 -0
  26. data/lib/samagotchi/guardrails/pair_boundary.rb +3 -2
  27. data/lib/samagotchi/llm/chat_loop.rb +1 -1
  28. data/lib/samagotchi/note_command.rb +1 -1
  29. data/lib/samagotchi/note_delivery.rb +6 -2
  30. data/lib/samagotchi/objectives.rb +395 -0
  31. data/lib/samagotchi/objectives_audit.rb +115 -0
  32. data/lib/samagotchi/objectives_check.rb +335 -0
  33. data/lib/samagotchi/objectives_command.rb +192 -0
  34. data/lib/samagotchi/plugin/api.rb +2 -1
  35. data/lib/samagotchi/plugin/context.rb +21 -1
  36. data/lib/samagotchi/session_commands.rb +15 -0
  37. data/lib/samagotchi/session_continue.rb +3 -0
  38. data/lib/samagotchi/session_inbox.rb +14 -6
  39. data/lib/samagotchi/session_manager.rb +1 -1
  40. data/lib/samagotchi/steer.rb +24 -4
  41. data/lib/samagotchi/testing/boundary.rb +1 -0
  42. data/lib/samagotchi/testing/host.rb +1 -0
  43. data/lib/samagotchi/tool_activity.rb +17 -0
  44. data/lib/samagotchi/tool_declarations.rb +34 -0
  45. data/lib/samagotchi/tools/builtin_calls.rb +2 -1
  46. data/lib/samagotchi/tools/builtins.rb +4 -1
  47. data/lib/samagotchi/tools/objectives_tool.rb +75 -0
  48. data/lib/samagotchi/tools/peers.rb +3 -0
  49. data/lib/samagotchi/version.rb +1 -1
  50. data/lib/samagotchi/web/message_display.rb +9 -0
  51. data/lib/samagotchi/web/participant_view.rb +1 -1
  52. data/lib/samagotchi/web/public/app.js +10 -0
  53. data/lib/samagotchi/web/public/cards_place.js +20 -4
  54. data/lib/samagotchi/web/public/commands.js +4 -1
  55. data/lib/samagotchi/web/public/index.html +2 -0
  56. data/lib/samagotchi/web/public/objectives.css +80 -0
  57. data/lib/samagotchi/web/public/objectives_entry.js +22 -0
  58. data/lib/samagotchi/web/public/objectives_model.js +100 -0
  59. data/lib/samagotchi/web/public/objectives_moves.js +145 -0
  60. data/lib/samagotchi/web/public/objectives_strip.js +242 -0
  61. data/lib/samagotchi/web/public/objectives_wiring.js +62 -0
  62. data/lib/samagotchi/web/public/stream_handlers.js +6 -1
  63. data/lib/samagotchi/web/public/turn_html.js +4 -1
  64. data/lib/samagotchi/web/session_show.rb +12 -1
  65. data/lib/samagotchi/worker.rb +3 -0
  66. data/lib/samagotchi/worker_inbound.rb +16 -8
  67. metadata +15 -1
@@ -9,6 +9,7 @@ require_relative "client_id"
9
9
  require_relative "config"
10
10
  require_relative "context_note"
11
11
  require_relative "log"
12
+ require_relative "objectives"
12
13
  require_relative "session"
13
14
  require_relative "session_inbox"
14
15
  require_relative "steer"
@@ -113,19 +114,26 @@ module Samagotchi
113
114
  # note the saved conversation already holds. A failed save keeps the
114
115
  # files too: the next pass claims them again, finds them in the
115
116
  # conversation and saves again. Not activity: a note alone neither
116
- # starts a turn nor keeps an idle worker up.
117
+ # starts a turn nor keeps an idle worker up. Of the objectives notes in
118
+ # a batch only the newest goes in: each is a whole list, so the older
119
+ # ones (edits made during a turn) would only be sent for nothing.
117
120
  def absorb_notes
118
121
  files = SessionInbox.find_new_note_files(@session_dir)
119
122
  return if files.empty? || @stopped.call
120
123
 
121
- claimed = files.filter_map { |file| SessionInbox.claim_note_file(file) }
122
- claimed.each do |file|
123
- note = SessionInbox.read_note(file)
124
- @engine.add_context_note(@session, note) if note
124
+ # Under the objectives' lock: an edit reads the conversation and then the
125
+ # pending file, so it must see this whole step or none of it.
126
+ Objectives.with_lock(@session_dir) do
127
+ claimed = files.filter_map { |file| SessionInbox.claim_note_file(file) }
128
+ notes = claimed.filter_map { |file| SessionInbox.read_note(file) }
129
+ newest_list = notes.reverse.find { |note| note[:objectives] }
130
+ notes.each do |note|
131
+ @engine.add_context_note(@session, note) if !note[:objectives] || note.equal?(newest_list)
132
+ end
133
+ next unless save(:notes)
134
+
135
+ claimed.each { |file| FileUtils.rm_f(file) }
125
136
  end
126
- return unless save(:notes)
127
-
128
- claimed.each { |file| FileUtils.rm_f(file) }
129
137
  end
130
138
 
131
139
  # The attached context's notes (ContextAbsorber), between turns. Not
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.148.0
4
+ version: 0.149.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Dedov
@@ -163,6 +163,7 @@ files:
163
163
  - docs/internals/llm-context-bench.md
164
164
  - docs/internals/llm-context-forget.md
165
165
  - docs/internals/llm-context-live.md
166
+ - docs/internals/objectives.md
166
167
  - docs/internals/participants.md
167
168
  - docs/internals/prompt-caching.md
168
169
  - docs/internals/remote-sessions.md
@@ -248,6 +249,8 @@ files:
248
249
  - lib/samagotchi/bundles/core/manifest.yml
249
250
  - lib/samagotchi/bundles/cost-cap/manifest.yml
250
251
  - lib/samagotchi/bundles/cost-cap/plugin.rb
252
+ - lib/samagotchi/bundles/decision-card/manifest.yml
253
+ - lib/samagotchi/bundles/decision-card/plugin.rb
251
254
  - lib/samagotchi/bundles/dev/manifest.yml
252
255
  - lib/samagotchi/bundles/github-pr/manifest.yml
253
256
  - lib/samagotchi/bundles/github-pr/plugin.rb
@@ -505,6 +508,10 @@ files:
505
508
  - lib/samagotchi/muted_memories.rb
506
509
  - lib/samagotchi/note_command.rb
507
510
  - lib/samagotchi/note_delivery.rb
511
+ - lib/samagotchi/objectives.rb
512
+ - lib/samagotchi/objectives_audit.rb
513
+ - lib/samagotchi/objectives_check.rb
514
+ - lib/samagotchi/objectives_command.rb
508
515
  - lib/samagotchi/output_formatter.rb
509
516
  - lib/samagotchi/owner_lock.rb
510
517
  - lib/samagotchi/owner_prompt.rb
@@ -743,6 +750,7 @@ files:
743
750
  - lib/samagotchi/tools/list_reminders.rb
744
751
  - lib/samagotchi/tools/list_sessions.rb
745
752
  - lib/samagotchi/tools/memory.rb
753
+ - lib/samagotchi/tools/objectives_tool.rb
746
754
  - lib/samagotchi/tools/output_guardrails.rb
747
755
  - lib/samagotchi/tools/peers.rb
748
756
  - lib/samagotchi/tools/read.rb
@@ -872,6 +880,12 @@ files:
872
880
  - lib/samagotchi/web/public/notice_links.js
873
881
  - lib/samagotchi/web/public/notifications.js
874
882
  - lib/samagotchi/web/public/notify.js
883
+ - lib/samagotchi/web/public/objectives.css
884
+ - lib/samagotchi/web/public/objectives_entry.js
885
+ - lib/samagotchi/web/public/objectives_model.js
886
+ - lib/samagotchi/web/public/objectives_moves.js
887
+ - lib/samagotchi/web/public/objectives_strip.js
888
+ - lib/samagotchi/web/public/objectives_wiring.js
875
889
  - lib/samagotchi/web/public/participant.html
876
890
  - lib/samagotchi/web/public/participant.js
877
891
  - lib/samagotchi/web/public/participant_annotate.js