samagotchi 0.166.0 → 0.168.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 +89 -1
- data/docs/architecture.md +1 -0
- data/docs/cli.md +24 -15
- data/docs/configuration.md +1 -0
- data/docs/guardrails.md +5 -5
- data/docs/hooks.md +4 -6
- data/docs/internals/bundles.md +2 -4
- data/docs/internals/engine.md +4 -5
- data/docs/internals/objectives.md +141 -9
- data/docs/internals/remote-sessions.md +5 -6
- data/docs/internals/web-frontend.md +85 -40
- data/docs/memory.md +1 -2
- data/docs/sessions.md +20 -2
- data/docs/testing.md +3 -3
- data/lib/samagotchi/bridge.rb +1 -1
- data/lib/samagotchi/bundle_command/installed_check.rb +2 -14
- data/lib/samagotchi/bundle_command.rb +35 -12
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/cli/command.rb +10 -0
- data/lib/samagotchi/compat.rb +1 -13
- data/lib/samagotchi/config.rb +3 -0
- data/lib/samagotchi/context_command.rb +2 -1
- data/lib/samagotchi/engine/objectives.rb +20 -1
- data/lib/samagotchi/engine/side_requests.rb +3 -2
- data/lib/samagotchi/engine/turn_end.rb +4 -1
- data/lib/samagotchi/engine.rb +3 -0
- data/lib/samagotchi/extension_load.rb +2 -26
- data/lib/samagotchi/guardrails/approvals.rb +15 -16
- data/lib/samagotchi/jsonl_store.rb +61 -0
- data/lib/samagotchi/memory_bundle/status.rb +3 -15
- data/lib/samagotchi/memory_bundle/system_bundle.rb +16 -10
- data/lib/samagotchi/memory_command.rb +4 -2
- data/lib/samagotchi/objectives.rb +43 -14
- data/lib/samagotchi/objectives_backing.rb +124 -0
- data/lib/samagotchi/objectives_check.rb +19 -126
- data/lib/samagotchi/objectives_command.rb +14 -7
- data/lib/samagotchi/objectives_record.rb +104 -0
- data/lib/samagotchi/objectives_track.rb +353 -0
- data/lib/samagotchi/push_command.rb +2 -1
- data/lib/samagotchi/remote_command.rb +2 -1
- data/lib/samagotchi/reply_wait/poll.rb +6 -6
- data/lib/samagotchi/reply_wait.rb +4 -24
- data/lib/samagotchi/schedule_command.rb +6 -0
- data/lib/samagotchi/schedules.rb +1 -1
- data/lib/samagotchi/session_access/remote.rb +3 -5
- data/lib/samagotchi/session_commands.rb +1 -1
- data/lib/samagotchi/sessions_command.rb +12 -6
- data/lib/samagotchi/share_command.rb +2 -1
- data/lib/samagotchi/tool_activity.rb +11 -1
- data/lib/samagotchi/tool_declarations.rb +5 -1
- data/lib/samagotchi/tools/objectives_tool.rb +19 -2
- data/lib/samagotchi/turn_stages/objectives.rb +46 -3
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/participant_access.rb +1 -1
- data/lib/samagotchi/web/public/app.js +52 -424
- data/lib/samagotchi/web/public/copy.js +2 -1
- data/lib/samagotchi/web/public/dock_reserve.js +12 -2
- data/lib/samagotchi/web/public/history_end.js +16 -0
- data/lib/samagotchi/web/public/index.html +74 -22
- data/lib/samagotchi/web/public/info_bar_model.js +3 -1
- data/lib/samagotchi/web/public/no_contact_fill.js +29 -0
- data/lib/samagotchi/web/public/objectives.css +14 -0
- data/lib/samagotchi/web/public/objectives_moves.js +82 -9
- data/lib/samagotchi/web/public/objectives_state.js +42 -0
- data/lib/samagotchi/web/public/objectives_strip.js +33 -9
- data/lib/samagotchi/web/public/objectives_track.js +52 -0
- data/lib/samagotchi/web/public/objectives_wiring.js +16 -1
- data/lib/samagotchi/web/public/participant.html +1 -1
- data/lib/samagotchi/web/public/participants_panel.js +14 -7
- data/lib/samagotchi/web/public/question_cards.js +8 -13
- data/lib/samagotchi/web/public/refs.js +4 -1
- data/lib/samagotchi/web/public/reload_check.js +5 -4
- data/lib/samagotchi/web/public/resync_reach.js +10 -6
- data/lib/samagotchi/web/public/scope.js +3 -3
- data/lib/samagotchi/web/public/session_rename.js +6 -2
- data/lib/samagotchi/web/public/session_state.js +1 -1
- data/lib/samagotchi/web/public/session_sync.js +249 -0
- data/lib/samagotchi/web/public/session_view.js +279 -0
- data/lib/samagotchi/web/public/stage_cards.js +20 -0
- data/lib/samagotchi/web/public/stage_frame.js +14 -16
- data/lib/samagotchi/web/public/stage_model.js +11 -4
- data/lib/samagotchi/web/public/stage_opened.js +229 -0
- data/lib/samagotchi/web/public/stage_slots.js +2 -3
- data/lib/samagotchi/web/public/stage_view.js +219 -147
- data/lib/samagotchi/web/public/stage_watch.js +8 -4
- data/lib/samagotchi/web/public/stream_handlers.js +1 -1
- data/lib/samagotchi/web/public/tokens.css +2 -2
- data/lib/samagotchi/web/public/turn_block.js +22 -2
- data/lib/samagotchi/web/public/turn_html.js +1 -1
- data/lib/samagotchi/web/public/widget_picks.js +3 -0
- data/lib/samagotchi/web/public/working_set_view.js +1 -1
- data/lib/samagotchi/web/session_access_routes.rb +4 -15
- metadata +13 -1
|
@@ -22,6 +22,12 @@ module Samagotchi
|
|
|
22
22
|
RECORDED = "Recorded a move on %s."
|
|
23
23
|
EDITED_BY_USER = "The user edits the list with /objectives."
|
|
24
24
|
NONE = "There are no objectives here, so nothing was recorded. #{EDITED_BY_USER}".freeze
|
|
25
|
+
# A move's state: where the objective stands in the agent's view. DONE is
|
|
26
|
+
# its claim, never a status change (the user marks done).
|
|
27
|
+
PROGRESS = "progress"
|
|
28
|
+
BLOCKED = "blocked"
|
|
29
|
+
DONE = "done"
|
|
30
|
+
STATES = [PROGRESS, BLOCKED, DONE].freeze
|
|
25
31
|
|
|
26
32
|
def self.name = NAME
|
|
27
33
|
|
|
@@ -32,8 +38,17 @@ module Samagotchi
|
|
|
32
38
|
output.to_s.sub(ToolResponse::LEAD, "").start_with?(RECORDED % id)
|
|
33
39
|
end
|
|
34
40
|
|
|
41
|
+
# A call's state as a move takes it: stripped and downcased, PROGRESS
|
|
42
|
+
# when it names none; nil for one that isn't a state.
|
|
43
|
+
def self.state_of(call)
|
|
44
|
+
state = call[:state].to_s.strip.downcase
|
|
45
|
+
return PROGRESS if state.empty?
|
|
46
|
+
|
|
47
|
+
STATES.include?(state) ? state : nil
|
|
48
|
+
end
|
|
49
|
+
|
|
35
50
|
# @param call [Hash] the internal call (BuiltinCalls: action:, id:,
|
|
36
|
-
# note:, evidence:)
|
|
51
|
+
# note:, evidence:, state:)
|
|
37
52
|
# @param peers [#objectives, nil] the session's list
|
|
38
53
|
# @return [String] the tool result
|
|
39
54
|
def self.call(call, peers:)
|
|
@@ -67,7 +82,9 @@ module Samagotchi
|
|
|
67
82
|
return "Error: #{Objectives.unknown(id, list)}. Nothing was recorded." unless item
|
|
68
83
|
return "Error: #{Objectives.dropped(id)}. Nothing was recorded." if item.status == Objectives::DROPPED
|
|
69
84
|
|
|
70
|
-
"Error: a move needs a note: what moved, in a line." if Objectives.clean(call[:note]).empty?
|
|
85
|
+
return "Error: a move needs a note: what moved, in a line." if Objectives.clean(call[:note]).empty?
|
|
86
|
+
|
|
87
|
+
"Error: a move's state must be #{STATES[0..-2].join(", ")} or #{STATES.last}. Nothing was recorded." unless state_of(call)
|
|
71
88
|
end
|
|
72
89
|
private_class_method :refusal
|
|
73
90
|
end
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "securerandom"
|
|
4
|
+
require_relative "../cancellation_controller"
|
|
4
5
|
require_relative "../log"
|
|
5
6
|
require_relative "../objectives"
|
|
6
7
|
require_relative "../objectives_audit"
|
|
8
|
+
require_relative "../objectives_track"
|
|
7
9
|
require_relative "../owner_prompt"
|
|
8
10
|
require_relative "../system_one/client"
|
|
9
11
|
|
|
@@ -13,9 +15,11 @@ module Samagotchi
|
|
|
13
15
|
# list itself; inside this class the bare name is this stage): System 1's
|
|
14
16
|
# audit of what comes in at a turn's start and what goes out at its end
|
|
15
17
|
# (ObjectivesAudit), the view announced when it changed, and the model's
|
|
16
|
-
# proposals kept as cards until the turn is over
|
|
17
|
-
#
|
|
18
|
-
#
|
|
18
|
+
# proposals kept as cards until the turn is over, and the tracker's
|
|
19
|
+
# automatic read after a turn (ObjectivesTrack). Its state is those
|
|
20
|
+
# proposals under their mutex, the automatic read's cancel under its own,
|
|
21
|
+
# and the last view announced (under the event lock); the audit is built
|
|
22
|
+
# per call.
|
|
19
23
|
class Objectives
|
|
20
24
|
# @param side_judgments [SideJudgments] the Engine's side asks (the audit's kinds)
|
|
21
25
|
# @param host_registry [HostRegistry] System 1's client resolves its host here
|
|
@@ -27,6 +31,9 @@ module Samagotchi
|
|
|
27
31
|
# The model's proposals until the turn is over (#finally).
|
|
28
32
|
@proposals = []
|
|
29
33
|
@proposals_mutex = Mutex.new
|
|
34
|
+
# The automatic read's cancel (#track), until the next turn's start.
|
|
35
|
+
@track_cancel = nil
|
|
36
|
+
@track_mutex = Mutex.new
|
|
30
37
|
end
|
|
31
38
|
|
|
32
39
|
# System 1 on the objectives, in audit (ObjectivesAudit), at a turn's
|
|
@@ -49,6 +56,42 @@ module Samagotchi
|
|
|
49
56
|
audit(turn.context.state_dir, recorder).outgoing(turn.session, result.text)
|
|
50
57
|
end
|
|
51
58
|
|
|
59
|
+
# After a completed turn (Engine#track_objectives_after), on the turn's
|
|
60
|
+
# thread: the tracker by itself when ObjectivesTrack.after_turn? says so,
|
|
61
|
+
# on a thread of its own kind (SideJudgments#start), so the turn's end
|
|
62
|
+
# never waits. The stored conversation is read here, on this thread. The
|
|
63
|
+
# next turn's start cancels it (#cancel_track); a typed track isn't.
|
|
64
|
+
# @param engine [Engine] what ObjectivesTrack reads and shows through
|
|
65
|
+
# @return [Thread, nil] the read's thread, nil when none started
|
|
66
|
+
def track(turn, engine:)
|
|
67
|
+
return nil unless ObjectivesTrack.after_turn?(engine, turn)
|
|
68
|
+
|
|
69
|
+
# Its last read still runs (a turn as short as a request): that one
|
|
70
|
+
# stays the one to cancel.
|
|
71
|
+
if @side_judgments.in_flight?(ObjectivesTrack::SOURCE)
|
|
72
|
+
Log.debug(:turn, "objectives_track_skipped", reason: "previous_read_running")
|
|
73
|
+
return nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
session = turn.session
|
|
77
|
+
conversation = session.messages.dup
|
|
78
|
+
cancel = CancellationController.new
|
|
79
|
+
thread = @side_judgments.start(ObjectivesTrack::SOURCE, warn: lambda { |e|
|
|
80
|
+
Log.warn(:turn, "objectives_track_failed", error: e.class.name, msg: e.message.to_s[0, 200])
|
|
81
|
+
}) { ObjectivesTrack.run_after_turn(engine, session, conversation, cancel) }
|
|
82
|
+
@track_mutex.synchronize { @track_cancel = cancel } if thread
|
|
83
|
+
thread
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# The automatic read's request cancelled (CancellationController#cancel!
|
|
87
|
+
# :new_turn); nothing when none runs. At the very start of every turn
|
|
88
|
+
# (Engine#begin_turn, before its own probes and waits), a wake's too, so
|
|
89
|
+
# a one-slot server is free for it.
|
|
90
|
+
def cancel_track
|
|
91
|
+
cancel = @track_mutex.synchronize { @track_cancel.tap { @track_cancel = nil } }
|
|
92
|
+
cancel&.cancel!(:new_turn)
|
|
93
|
+
end
|
|
94
|
+
|
|
52
95
|
# A note added between turns (Engine#add_context_note): incoming too.
|
|
53
96
|
# @param recorder [SystemOne::Recorder] the audit's runs (built for this call)
|
|
54
97
|
# @param state_dir [String] the sessions dir
|
data/lib/samagotchi/version.rb
CHANGED
|
@@ -426,7 +426,7 @@ module Samagotchi
|
|
|
426
426
|
grant = principal(req).grant
|
|
427
427
|
return not_permitted_for(req, principal(req)) unless own_turn?(grant, id, options[:turn])
|
|
428
428
|
|
|
429
|
-
options = options.merge(queued: true, cursor: nil
|
|
429
|
+
options = options.merge(queued: true, cursor: nil)
|
|
430
430
|
session = session_access.show(id)
|
|
431
431
|
result = session_access.wait_reply(id, **options, poll_interval: @wait_poll_interval,
|
|
432
432
|
cancelled: -> { !@server_running.call || !@grants.active?(grant.id) })
|