samagotchi 0.171.0 → 0.172.1
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 +46 -1
- data/bin/chi +6 -4
- data/docs/architecture.md +24 -7
- data/docs/bundles.md +4 -21
- data/docs/cli.md +50 -80
- data/docs/configuration.md +11 -13
- data/docs/context.md +5 -6
- data/docs/guardrails.md +57 -96
- data/docs/hooks.md +3 -4
- data/docs/internals/attached-context.md +6 -7
- data/docs/internals/background-tasks.md +4 -3
- data/docs/internals/bridge.md +29 -3
- data/docs/internals/engine.md +21 -9
- data/docs/internals/objectives.md +3 -5
- data/docs/internals/participants.md +118 -143
- data/docs/internals/prompt-caching.md +4 -5
- data/docs/internals/web-frontend.md +70 -27
- data/docs/internals/working-set.md +7 -5
- data/docs/memory.md +1 -1
- data/docs/plugins.md +2 -16
- data/docs/scheduling.md +1 -1
- data/docs/sessions.md +15 -49
- data/docs/sub-agent.md +2 -2
- data/docs/system-one.md +2 -2
- data/docs/testing.md +81 -8
- data/lib/samagotchi/bridge/card_store.rb +1 -0
- data/lib/samagotchi/bridge/sse_writer.rb +1 -0
- data/lib/samagotchi/bridge/turn_accumulator.rb +0 -1
- data/lib/samagotchi/bridge.rb +26 -9
- data/lib/samagotchi/bridge_client/event_stream.rb +2 -0
- data/lib/samagotchi/bundle_command/test_run.rb +1 -0
- data/lib/samagotchi/bundle_command/try/run.rb +1 -0
- data/lib/samagotchi/bundles/coordinator/manifest.yml +4 -5
- data/lib/samagotchi/bundles/coordinator/plugin.rb +6 -79
- data/lib/samagotchi/bundles/coordinator/skill_coordinator.md +1 -16
- data/lib/samagotchi/bundles/github-pr/manifest.yml +2 -2
- data/lib/samagotchi/bundles/github-pr/plugin.rb +0 -1
- data/lib/samagotchi/bundles/inline-widgets/manifest.yml +2 -2
- data/lib/samagotchi/bundles/inline-widgets/plugin.rb +4 -5
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/client_id.rb +126 -67
- data/lib/samagotchi/command_intake.rb +15 -3
- data/lib/samagotchi/compat.rb +6 -1
- data/lib/samagotchi/context_candidate_choice.rb +1 -3
- data/lib/samagotchi/context_candidates.rb +3 -4
- data/lib/samagotchi/continue_offer.rb +9 -2
- data/lib/samagotchi/delivery.rb +23 -12
- data/lib/samagotchi/empty_answer_error.rb +5 -0
- data/lib/samagotchi/engine/cards.rb +3 -0
- data/lib/samagotchi/engine/context_judge.rb +5 -3
- data/lib/samagotchi/engine/events.rb +4 -0
- data/lib/samagotchi/engine/hooks.rb +3 -0
- data/lib/samagotchi/engine/messages.rb +5 -0
- data/lib/samagotchi/engine/model_settings.rb +2 -0
- data/lib/samagotchi/engine/models.rb +10 -0
- data/lib/samagotchi/engine/objectives.rb +6 -0
- data/lib/samagotchi/engine/participants.rb +18 -14
- data/lib/samagotchi/engine/plugins.rb +8 -0
- data/lib/samagotchi/engine/questions.rb +3 -0
- data/lib/samagotchi/engine/recap.rb +1 -0
- data/lib/samagotchi/engine/session.rb +4 -0
- data/lib/samagotchi/engine/side_requests.rb +9 -0
- data/lib/samagotchi/engine/steering.rb +2 -0
- data/lib/samagotchi/engine/toolkit.rb +5 -0
- data/lib/samagotchi/engine/turn_end.rb +7 -0
- data/lib/samagotchi/engine/turn_helpers.rb +8 -0
- data/lib/samagotchi/engine/verify.rb +2 -0
- data/lib/samagotchi/engine.rb +3 -2
- data/lib/samagotchi/grants.rb +28 -22
- data/lib/samagotchi/guardrail_wiring.rb +23 -18
- data/lib/samagotchi/guardrails/approval_use.rb +59 -0
- data/lib/samagotchi/guardrails/approvals.rb +9 -11
- data/lib/samagotchi/guardrails/child_boundary.rb +1 -0
- data/lib/samagotchi/guardrails/gate.rb +10 -5
- data/lib/samagotchi/guardrails/implicit_writers.rb +1 -0
- data/lib/samagotchi/guardrails/pair_boundary.rb +6 -6
- data/lib/samagotchi/guardrails/participant_refusal.rb +33 -0
- data/lib/samagotchi/guardrails/review_paths.rb +2 -3
- data/lib/samagotchi/guardrails.rb +1 -1
- data/lib/samagotchi/llm_context_strategy.rb +2 -0
- data/lib/samagotchi/objectives.rb +1 -4
- data/lib/samagotchi/objectives_audit.rb +1 -1
- data/lib/samagotchi/objectives_track.rb +1 -1
- data/lib/samagotchi/owner_prompt.rb +3 -6
- data/lib/samagotchi/parent_report.rb +1 -0
- data/lib/samagotchi/participant_messages.rb +9 -4
- data/lib/samagotchi/participant_turn_mode.rb +50 -0
- data/lib/samagotchi/participants.rb +21 -12
- data/lib/samagotchi/participants_watch.rb +2 -2
- data/lib/samagotchi/plugin/api.rb +2 -2
- data/lib/samagotchi/plugin/attached_context.rb +1 -1
- data/lib/samagotchi/plugin/context.rb +0 -4
- data/lib/samagotchi/plugin/sessions.rb +1 -25
- data/lib/samagotchi/run_options.rb +2 -3
- data/lib/samagotchi/send_command.rb +10 -10
- data/lib/samagotchi/session.rb +0 -3
- data/lib/samagotchi/session_access/contract.rb +1 -10
- data/lib/samagotchi/session_access/local.rb +10 -23
- data/lib/samagotchi/session_access/remote.rb +9 -20
- data/lib/samagotchi/session_access.rb +12 -16
- data/lib/samagotchi/session_chain.rb +4 -6
- data/lib/samagotchi/session_commands.rb +6 -3
- data/lib/samagotchi/session_continue.rb +1 -2
- data/lib/samagotchi/session_manager/delivery.rb +25 -5
- data/lib/samagotchi/session_manager/lifecycle.rb +12 -0
- data/lib/samagotchi/session_manager/listing.rb +5 -0
- data/lib/samagotchi/session_manager/spawn.rb +2 -2
- data/lib/samagotchi/session_manager/worker_command.rb +9 -0
- data/lib/samagotchi/session_participants.rb +12 -8
- data/lib/samagotchi/session_review.rb +5 -7
- data/lib/samagotchi/session_stores.rb +3 -3
- data/lib/samagotchi/share_command.rb +10 -12
- data/lib/samagotchi/share_terms.rb +41 -0
- data/lib/samagotchi/steer.rb +8 -14
- data/lib/samagotchi/system_prompt.rb +16 -25
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +2 -1
- data/lib/samagotchi/terminal_ui/attached_loop/exit_commands.rb +1 -0
- data/lib/samagotchi/terminal_ui/attached_loop/queueing.rb +1 -0
- data/lib/samagotchi/terminal_ui/attached_loop/sending.rb +2 -0
- data/lib/samagotchi/terminal_ui/formatting.rb +15 -17
- data/lib/samagotchi/terminal_ui/participant_commands.rb +2 -2
- data/lib/samagotchi/terminal_ui/status_row.rb +2 -2
- data/lib/samagotchi/terminal_ui.rb +1 -2
- data/lib/samagotchi/testing/sessions.rb +2 -10
- data/lib/samagotchi/tool_runner.rb +8 -9
- data/lib/samagotchi/toolkit.rb +4 -22
- data/lib/samagotchi/toolkit_suggest.rb +3 -3
- data/lib/samagotchi/tools/deferred_tools.rb +1 -0
- data/lib/samagotchi/tools/execute.rb +11 -45
- data/lib/samagotchi/tools/leftovers.rb +126 -0
- data/lib/samagotchi/tools/memory.rb +70 -26
- data/lib/samagotchi/tools/task_get.rb +1 -0
- data/lib/samagotchi/tools/task_list.rb +3 -2
- data/lib/samagotchi/tools/task_record.rb +6 -4
- data/lib/samagotchi/tools/task_runtime.rb +199 -20
- data/lib/samagotchi/tools/task_wait.rb +4 -3
- data/lib/samagotchi/turn_context.rb +1 -1
- data/lib/samagotchi/turn_origin.rb +1 -1
- data/lib/samagotchi/turn_stages/context_judge.rb +4 -4
- data/lib/samagotchi/turn_stages/objectives.rb +2 -2
- data/lib/samagotchi/turn_stages/toolkit_suggestion.rb +2 -2
- data/lib/samagotchi/update_hint.rb +3 -1
- data/lib/samagotchi/verify_fresh.rb +1 -1
- data/lib/samagotchi/verify_fresh_origin.rb +13 -11
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +3 -5
- data/lib/samagotchi/web/participant_access.rb +14 -18
- data/lib/samagotchi/web/participant_review.rb +3 -4
- data/lib/samagotchi/web/participant_show.rb +4 -3
- data/lib/samagotchi/web/participant_view.rb +3 -3
- data/lib/samagotchi/web/participants_admin.rb +21 -40
- data/lib/samagotchi/web/public/app.js +7 -48
- data/lib/samagotchi/web/public/card_kinds.js +51 -0
- data/lib/samagotchi/web/public/cards_place.js +13 -2
- data/lib/samagotchi/web/public/data.js +2 -10
- data/lib/samagotchi/web/public/delivery_line.js +17 -60
- data/lib/samagotchi/web/public/index.html +10 -30
- data/lib/samagotchi/web/public/live_turn.js +1 -1
- data/lib/samagotchi/web/public/owner_claim.js +2 -2
- data/lib/samagotchi/web/public/participant_bar.js +4 -5
- data/lib/samagotchi/web/public/participant_names.js +14 -10
- data/lib/samagotchi/web/public/participants_panel.js +29 -62
- data/lib/samagotchi/web/public/question_cards.js +29 -14
- data/lib/samagotchi/web/public/reload_check.js +2 -3
- data/lib/samagotchi/web/public/send_turn.js +4 -23
- data/lib/samagotchi/web/public/session_actions.js +4 -45
- data/lib/samagotchi/web/public/session_fields.js +0 -1
- data/lib/samagotchi/web/public/session_state.js +0 -3
- data/lib/samagotchi/web/public/session_sync.js +4 -2
- data/lib/samagotchi/web/public/session_view.js +2 -3
- data/lib/samagotchi/web/public/settings_panel.js +4 -18
- data/lib/samagotchi/web/public/stage_answer.js +56 -0
- data/lib/samagotchi/web/public/stage_asking.js +30 -11
- data/lib/samagotchi/web/public/stage_cloud.js +93 -0
- data/lib/samagotchi/web/public/stage_dom.js +100 -0
- data/lib/samagotchi/web/public/stage_handoff.js +154 -0
- data/lib/samagotchi/web/public/stage_pager.js +59 -0
- data/lib/samagotchi/web/public/stage_place.js +144 -0
- data/lib/samagotchi/web/public/stage_probe.js +64 -0
- data/lib/samagotchi/web/public/stage_quiet_clock.js +52 -0
- data/lib/samagotchi/web/public/stage_view.js +133 -506
- data/lib/samagotchi/web/public/stage_waiting.js +30 -13
- data/lib/samagotchi/web/public/start_page.js +12 -33
- data/lib/samagotchi/web/public/start_settings.js +24 -78
- data/lib/samagotchi/web/public/start_toolkit.js +6 -10
- data/lib/samagotchi/web/public/stream_handlers.js +1 -9
- data/lib/samagotchi/web/public/turn_block.js +3 -7
- data/lib/samagotchi/web/public/turn_events.js +15 -6
- data/lib/samagotchi/web/public/turn_pieces.js +3 -4
- data/lib/samagotchi/web/public/viewer_self.js +8 -2
- data/lib/samagotchi/web/qr.rb +1 -1
- data/lib/samagotchi/web/session_control.rb +3 -1
- data/lib/samagotchi/web/session_create.rb +5 -71
- data/lib/samagotchi/web/session_summary.rb +1 -4
- data/lib/samagotchi/web/verify_fresh_routes.rb +8 -7
- data/lib/samagotchi/web/viewer.rb +3 -3
- data/lib/samagotchi/worker.rb +16 -14
- data/lib/samagotchi/worker_inbound.rb +4 -3
- data/lib/samagotchi/worker_link.rb +17 -0
- data/lib/samagotchi/working_set.rb +87 -28
- metadata +16 -8
- data/lib/samagotchi/guardrails/review_boundary.rb +0 -99
- data/lib/samagotchi/participant_mode.rb +0 -86
- data/lib/samagotchi/review_apply.rb +0 -131
- data/lib/samagotchi/review_command.rb +0 -123
- data/lib/samagotchi/review_start.rb +0 -196
- data/lib/samagotchi/web/public/review_apply.js +0 -34
- data/lib/samagotchi/web/public/review_start.js +0 -55
|
@@ -11,7 +11,7 @@ require_relative "../session_inbox"
|
|
|
11
11
|
require_relative "../session_metrics"
|
|
12
12
|
require_relative "../parent_report"
|
|
13
13
|
require_relative "../participant_messages"
|
|
14
|
-
require_relative "../
|
|
14
|
+
require_relative "../worker_link"
|
|
15
15
|
require_relative "../participant_revise"
|
|
16
16
|
require_relative "../participants"
|
|
17
17
|
require_relative "../session"
|
|
@@ -19,12 +19,13 @@ require_relative "../turn_checkpoint"
|
|
|
19
19
|
require_relative "../turn_origin"
|
|
20
20
|
require_relative "../verify_fresh"
|
|
21
21
|
require_relative "../log"
|
|
22
|
+
require_relative "proxy_gate"
|
|
22
23
|
|
|
23
24
|
module Samagotchi
|
|
24
25
|
module Web
|
|
25
26
|
# What a participant (a Grants token) may do in chi web, mixed into
|
|
26
27
|
# App: the gate's lookup of their grant, the refusals that are theirs
|
|
27
|
-
# (token_revoked, token_expired with its ended page, token_bound for a
|
|
28
|
+
# (token_revoked, token_expired, token_outdated with its ended page, token_bound for a
|
|
28
29
|
# link bound to another account, another session's
|
|
29
30
|
# 404, not_permitted by role), the trimmed answers of their own routes
|
|
30
31
|
# (info, the session, resolve, a wait on their turn), their turns, and
|
|
@@ -44,7 +45,8 @@ module Samagotchi
|
|
|
44
45
|
|
|
45
46
|
ENDED = {
|
|
46
47
|
revoked: ["token_revoked", ParticipantMessages::TOKEN_REVOKED],
|
|
47
|
-
expired: ["token_expired", ParticipantMessages::TOKEN_EXPIRED]
|
|
48
|
+
expired: ["token_expired", ParticipantMessages::TOKEN_EXPIRED],
|
|
49
|
+
outdated: ["token_outdated", ParticipantMessages::TOKEN_OUTDATED]
|
|
48
50
|
}.freeze
|
|
49
51
|
NOT_PERMITTED = ParticipantMessages::NOT_PERMITTED
|
|
50
52
|
|
|
@@ -139,7 +141,7 @@ module Samagotchi
|
|
|
139
141
|
grant.with(revoked_at: @grants.now.utc.iso8601, revoked_by: by)
|
|
140
142
|
end
|
|
141
143
|
|
|
142
|
-
# 401 token_revoked / token_expired for an ended grant's token (the
|
|
144
|
+
# 401 token_revoked / token_expired / token_outdated for an ended grant's token (the
|
|
143
145
|
# page's HTML says the same words), nil when none was presented.
|
|
144
146
|
def grant_ended_response(req)
|
|
145
147
|
grant, state = req.env[ENDED_GRANT_ENV]
|
|
@@ -240,13 +242,7 @@ module Samagotchi
|
|
|
240
242
|
# first prompt's opening words: the conversation).
|
|
241
243
|
def participant_title(session)
|
|
242
244
|
title = session.title.to_s.strip
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
# A review session's subjects are what participants read anyway.
|
|
246
|
-
subjects = session.review&.subjects || []
|
|
247
|
-
return UNTITLED if subjects.empty?
|
|
248
|
-
|
|
249
|
-
"review of #{subjects.first}#{" +#{subjects.size - 1}" if subjects.size > 1}"
|
|
245
|
+
title.empty? ? UNTITLED : title
|
|
250
246
|
end
|
|
251
247
|
|
|
252
248
|
UNTITLED = "an untitled session"
|
|
@@ -254,7 +250,7 @@ module Samagotchi
|
|
|
254
250
|
def participant_names(id)
|
|
255
251
|
now = @grants.now
|
|
256
252
|
Participants.read(id, state_dir: default_state_dir).select { |entry| entry.active?(now) }
|
|
257
|
-
.map { |entry| { id: entry.id, name: entry.name,
|
|
253
|
+
.map { |entry| { id: entry.id, name: entry.name, role: entry.role } }
|
|
258
254
|
end
|
|
259
255
|
|
|
260
256
|
# POST …/cancel from a participant: only their own running turn, named
|
|
@@ -287,7 +283,7 @@ module Samagotchi
|
|
|
287
283
|
# would stop whatever runs, the owner's next turn too.
|
|
288
284
|
def cancels_by_turn_id?(id)
|
|
289
285
|
session = @session_class.load(id, state_dir: default_state_dir)
|
|
290
|
-
Array(
|
|
286
|
+
Array(WorkerLink.live_features(session.id, state_dir: default_state_dir)).include?(Delivery::CANCEL_TURN_ID_FEATURE)
|
|
291
287
|
end
|
|
292
288
|
|
|
293
289
|
# 409 cancel_unavailable, audited; nothing is relayed.
|
|
@@ -310,7 +306,7 @@ module Samagotchi
|
|
|
310
306
|
# POST /api/sessions/:id/turn from a participant: their turn (D6,
|
|
311
307
|
# D10). Of the body only the prompt, the delivery and images they
|
|
312
308
|
# uploaded count: the author and client id are the grant's
|
|
313
|
-
# (
|
|
309
|
+
# (participant:<id>), no no_interrupt; the owner's prompt history never
|
|
314
310
|
# sees it. The delivery
|
|
315
311
|
# is queue or next step (none: next step): the worker puts a next-step
|
|
316
312
|
# message into a running turn only when that turn is theirs, else it
|
|
@@ -337,7 +333,7 @@ module Samagotchi
|
|
|
337
333
|
|
|
338
334
|
# A Verify turn's claim, a Revise turn's draft of their own answer.
|
|
339
335
|
delivery = Delivery.queue?(body["delivery"]) ? Delivery::QUEUE : Delivery::NEXT_STEP
|
|
340
|
-
result = SessionManager.deliver_turn(id, prompt: prompt, client_id: ClientId.
|
|
336
|
+
result = SessionManager.deliver_turn(id, prompt: prompt, client_id: ClientId.participant(grant.id),
|
|
341
337
|
delivery: delivery, author: grant.author,
|
|
342
338
|
**(images.empty? ? {} : { images: images }),
|
|
343
339
|
anchors: anchors,
|
|
@@ -369,7 +365,7 @@ module Samagotchi
|
|
|
369
365
|
return nil unless anchors.revises
|
|
370
366
|
|
|
371
367
|
session = @session_class.load(id, state_dir: default_state_dir)
|
|
372
|
-
features =
|
|
368
|
+
features = WorkerLink.live_features(session.id, state_dir: default_state_dir)
|
|
373
369
|
if features && !features.include?(ReviseAnchor::PARTICIPANT_FEATURE)
|
|
374
370
|
return [409, "revise_unavailable", ParticipantMessages::REVISE_UNAVAILABLE]
|
|
375
371
|
end
|
|
@@ -589,7 +585,7 @@ module Samagotchi
|
|
|
589
585
|
<!doctype html>
|
|
590
586
|
<html lang="en"><head><meta charset="utf-8">
|
|
591
587
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
592
|
-
<title>chi:
|
|
588
|
+
<title>chi: link ended</title>
|
|
593
589
|
<style>#{PAGE_STYLE}</style></head>
|
|
594
590
|
<body>
|
|
595
591
|
<h1>chi</h1>
|
|
@@ -611,7 +607,7 @@ module Samagotchi
|
|
|
611
607
|
</script>
|
|
612
608
|
</body></html>
|
|
613
609
|
HTML
|
|
614
|
-
BOUND_PAGE = ENDED_PAGE.sub("<title>chi:
|
|
610
|
+
BOUND_PAGE = ENDED_PAGE.sub("<title>chi: link ended</title>", "<title>chi: link for another account</title>")
|
|
615
611
|
end
|
|
616
612
|
end
|
|
617
613
|
end
|
|
@@ -5,7 +5,6 @@ require_relative "token"
|
|
|
5
5
|
require_relative "participant_stream_filter"
|
|
6
6
|
require_relative "../participant_exposure"
|
|
7
7
|
require_relative "../session_metrics"
|
|
8
|
-
require_relative "../participant_mode"
|
|
9
8
|
require_relative "../verify_fresh"
|
|
10
9
|
|
|
11
10
|
module Samagotchi
|
|
@@ -80,9 +79,9 @@ module Samagotchi
|
|
|
80
79
|
def review_viewer(req, id, session:, state:, queued:, viewer:)
|
|
81
80
|
grant = principal(req).grant
|
|
82
81
|
capped = !participant_cap_refusal(grant).nil?
|
|
83
|
-
#
|
|
84
|
-
mode =
|
|
85
|
-
{ kind: "participant", id: grant.id, name: grant.name,
|
|
82
|
+
# Their turns act under the owner's rules (every active grant is pair).
|
|
83
|
+
mode = Grants::PAIR_MODE
|
|
84
|
+
{ kind: "participant", id: grant.id, name: grant.name, mode: mode, can_comment: !capped,
|
|
86
85
|
cap_reached: capped, session_id: id,
|
|
87
86
|
usage: review_usage(grant, session: session, state: state, queued: queued, viewer: viewer) }
|
|
88
87
|
end
|
|
@@ -4,9 +4,10 @@ require "json"
|
|
|
4
4
|
require_relative "participant_view"
|
|
5
5
|
require_relative "viewer"
|
|
6
6
|
require_relative "../bridge/turn_accumulator"
|
|
7
|
-
require_relative "../
|
|
7
|
+
require_relative "../worker_link"
|
|
8
8
|
require_relative "../verify_anchor"
|
|
9
9
|
require_relative "../verify_fresh"
|
|
10
|
+
require_relative "capabilities"
|
|
10
11
|
|
|
11
12
|
module Samagotchi
|
|
12
13
|
module Web
|
|
@@ -40,7 +41,7 @@ module Samagotchi
|
|
|
40
41
|
session = reads.session
|
|
41
42
|
viewer = participant_viewer(req, session)
|
|
42
43
|
turn_snapshot = reads.turn_snapshot
|
|
43
|
-
features =
|
|
44
|
+
features = WorkerLink.live_features(session.id, state_dir: default_state_dir)
|
|
44
45
|
timing = participant_timing(reads.id, live_metrics: reads.state && reads.state["metrics"])
|
|
45
46
|
raw = visible_replies(reads.raw_messages)
|
|
46
47
|
drawn = drawn_lines(reads.id, raw, timing: {}, entries: [], cwd: session.working_directory,
|
|
@@ -110,7 +111,7 @@ module Samagotchi
|
|
|
110
111
|
session = reads.session
|
|
111
112
|
review = review_viewer(req, reads.id, session: session, state: reads.state, queued: queued, viewer: viewer)
|
|
112
113
|
Viewer.for(principal(req)).to_h.merge(
|
|
113
|
-
review.slice(:
|
|
114
|
+
review.slice(:mode, :cap_reached, :usage),
|
|
114
115
|
session_stopped: session.status == Session::STATUS_STOPPED,
|
|
115
116
|
waiting_for_owner: participant_waiting(reads.turn_snapshot)
|
|
116
117
|
)
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
require_relative "../output_formatter"
|
|
4
4
|
require_relative "../steer"
|
|
5
5
|
require_relative "../turn_origin"
|
|
6
|
-
require_relative "../participant_mode"
|
|
7
6
|
require_relative "../revise_anchor"
|
|
8
7
|
require_relative "../verify_anchor"
|
|
9
8
|
require_relative "../redact"
|
|
@@ -33,8 +32,9 @@ module Samagotchi
|
|
|
33
32
|
# home folder), defence in depth only: the allowlist is the control.
|
|
34
33
|
# Pure: no I/O; keys of what comes in may be strings (JSON) or symbols.
|
|
35
34
|
module ParticipantView
|
|
36
|
-
# A turn's participant_mode values the view passes on
|
|
37
|
-
|
|
35
|
+
# A turn's participant_mode values the view passes on: "pair", and an
|
|
36
|
+
# older chi's "review" (its saved turns keep their stamp).
|
|
37
|
+
PARTICIPANT_MODES = %w[review pair].freeze
|
|
38
38
|
|
|
39
39
|
# The stream's event types a participant gets, each rebuilt by the
|
|
40
40
|
# method named. Every other type is dropped.
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "../grants"
|
|
4
4
|
require_relative "qr"
|
|
5
|
-
require_relative "../
|
|
6
|
-
require_relative "../review_apply"
|
|
5
|
+
require_relative "../share_terms"
|
|
7
6
|
require_relative "../session_metrics"
|
|
8
7
|
require_relative "../participants"
|
|
9
8
|
require_relative "../session"
|
|
9
|
+
require_relative "link_codes"
|
|
10
10
|
|
|
11
11
|
module Samagotchi
|
|
12
12
|
module Web
|
|
13
13
|
# The owner's routes for a session's participants, mixed into App:
|
|
14
|
-
# invite, list, revoke
|
|
15
|
-
# owner's turn quoting a review turn's proposal). What a participant
|
|
14
|
+
# invite, list, revoke and a participant's cap. What a participant
|
|
16
15
|
# may do themselves is ParticipantAccess's. See
|
|
17
16
|
# docs/internals/participants.md.
|
|
18
17
|
module ParticipantsAdmin
|
|
@@ -21,12 +20,11 @@ module Samagotchi
|
|
|
21
20
|
# GET /api/sessions/:id/participants, GET /api/participants: the
|
|
22
21
|
# grants (one session's, or every one), in every state, never a token
|
|
23
22
|
# or digest. One session's also carries +warning+: the share warning
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
# +identity_header+: the header this chi web's auth
|
|
27
|
-
# signed-in user in (null without one), for the
|
|
28
|
-
#
|
|
29
|
-
# (ReviewStart.share_terms), for the panel's words; +link_base+: where
|
|
23
|
+
# (ShareTerms#warning: what a participant's turns do there, or why no
|
|
24
|
+
# one can be invited until the session restarts), which the panel shows
|
|
25
|
+
# before its Invite; +identity_header+: the header this chi web's auth
|
|
26
|
+
# proxy names the signed-in user in (null without one), for the
|
|
27
|
+
# Invite's email field; and +link_base+: where
|
|
30
28
|
# a participant's link opens (participant_base), for a claim link
|
|
31
29
|
# (claim_link.js) the participant's browser opens with its cookie.
|
|
32
30
|
def handle_participants_list(req, id = nil)
|
|
@@ -34,8 +32,8 @@ module Samagotchi
|
|
|
34
32
|
grants = @grants.list(session_id: id).map { |grant| grant.public_h(now) }
|
|
35
33
|
return json_response(200, { participants: grants }) unless id
|
|
36
34
|
|
|
37
|
-
terms =
|
|
38
|
-
json_response(200, { participants: with_spend(id, grants), warning: terms.warning,
|
|
35
|
+
terms = ShareTerms.of(Session.load(id, state_dir: default_state_dir), state_dir: default_state_dir)
|
|
36
|
+
json_response(200, { participants: with_spend(id, grants), warning: terms.warning,
|
|
39
37
|
identity_header: @public_url&.identity_header, link_base: participant_base(req) })
|
|
40
38
|
rescue Grants::Unwritable => e
|
|
41
39
|
grants_unwritable(e)
|
|
@@ -57,12 +55,12 @@ module Samagotchi
|
|
|
57
55
|
end
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
# POST /api/sessions/:id/participants {name,
|
|
58
|
+
# POST /api/sessions/:id/participants {name, ttl? (seconds),
|
|
61
59
|
# cap? (dollars), identity? (an email: the grant is bound to it, only
|
|
62
60
|
# behind an auth proxy with an identity header)}: a new grant. The
|
|
63
61
|
# answer carries the token and the link once (chi keeps only its
|
|
64
|
-
# digest), and +warning+
|
|
65
|
-
#
|
|
62
|
+
# digest), and +warning+ (ShareTerms#warning); 409 worker_too_old
|
|
63
|
+
# while the session's live worker would refuse their turns.
|
|
66
64
|
def handle_participants_invite(req, id)
|
|
67
65
|
body = body_hash(req) or return error_response(400, "invalid_json", "invalid JSON body")
|
|
68
66
|
ttl = body["ttl"]
|
|
@@ -71,12 +69,14 @@ module Samagotchi
|
|
|
71
69
|
cap = body["cap"]
|
|
72
70
|
return error_response(400, "invalid_participant", Grants::CAP_RANGE) unless cap.nil? || Grants.cap?(cap)
|
|
73
71
|
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
terms =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
# No link while the live worker would refuse every turn of theirs
|
|
73
|
+
# (one read: ShareTerms.of, the warning that comes back).
|
|
74
|
+
terms = ShareTerms.of(Session.load(id, state_dir: default_state_dir), state_dir: default_state_dir)
|
|
75
|
+
return error_response(409, "worker_too_old", terms.refusal) if terms.refusal
|
|
76
|
+
|
|
77
|
+
# An older chi --remote share --agent's kind is ignored.
|
|
78
|
+
issued = Participants.invite(@grants, session_id: id, name: body["name"], ttl: ttl, cap: cap, identity: body["identity"], public_url: @public_url,
|
|
79
|
+
state_dir: default_state_dir)
|
|
80
80
|
link = participant_link(req, id, issued.token, expires_at: issued.grant.expires_at)
|
|
81
81
|
json_response(201, { participant: issued.grant.public_h(@grants.now), token: issued.token,
|
|
82
82
|
link: link, lan: !@lan.nil? || !@public_url.nil?, qr_svg: QR.svg(link), warning: terms.warning })
|
|
@@ -86,25 +86,6 @@ module Samagotchi
|
|
|
86
86
|
grants_unwritable(e)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
# GET /api/sessions/:id/apply[?turn=T] (owner): the owner's turn that
|
|
90
|
-
# applies review turn T's proposal (ReviewApply: the reply quoted
|
|
91
|
-
# under one line of the owner's), for the composer: never sent from
|
|
92
|
-
# here. Without turn, the latest review turn with a reply. Read from
|
|
93
|
-
# the live worker's messages, else the saved ones.
|
|
94
|
-
# @return 200 {text, turn_id, author, author_name}; 404 not_found (no
|
|
95
|
-
# such turn, or no review turn); 400 not_review_turn; 409 no_reply
|
|
96
|
-
def handle_apply(req, id)
|
|
97
|
-
session = @session_class.load(id, state_dir: default_state_dir)
|
|
98
|
-
live = bridge_get_json(id, "snapshot")
|
|
99
|
-
messages = live_or_saved(live && live["snapshot"], "messages") { session.messages }
|
|
100
|
-
proposal = ReviewApply.find(messages, req.params["turn"])
|
|
101
|
-
json_response(200, { text: ReviewApply.compose(proposal), turn_id: proposal.turn_id, author: proposal.author,
|
|
102
|
-
author_name: proposal.author_name })
|
|
103
|
-
rescue ReviewApply::Refused => e
|
|
104
|
-
status = { not_found: 404, not_review_turn: 400, no_reply: 409 }.fetch(e.code)
|
|
105
|
-
error_response(status, e.code.to_s, e.message)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
89
|
# DELETE /api/sessions/:id/participants[?id=p_…], DELETE
|
|
109
90
|
# /api/participants: revokes one participant, a session's or every
|
|
110
91
|
# one's; their open streams end within a poll.
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
openEvents,
|
|
16
16
|
createIdleSession,
|
|
17
17
|
continueSession,
|
|
18
|
-
startReview,
|
|
19
18
|
uploadImage,
|
|
20
19
|
listModels,
|
|
21
20
|
fetchHistory,
|
|
@@ -47,7 +46,6 @@ import { createSessionStore } from "./session_store.js";
|
|
|
47
46
|
import { createFeatureGates } from "./feature_gates.js";
|
|
48
47
|
import { stillOn } from "./latest.js";
|
|
49
48
|
import { normalize, cantText } from "./format.js";
|
|
50
|
-
import { elementOf } from "./turn_html.js";
|
|
51
49
|
import { createBubbles } from "./bubbles.js";
|
|
52
50
|
import { createCardsPlace } from "./cards_place.js";
|
|
53
51
|
import { createStageView } from "./stage_view.js";
|
|
@@ -63,7 +61,6 @@ import { openerFill, openTitle, restoredComposer } from "./chains.js";
|
|
|
63
61
|
import { createTaskStopper } from "./task_stop.js";
|
|
64
62
|
import { createSystemOneWrongAction } from "./system_one_wrong.js";
|
|
65
63
|
import { appendQuote } from "./annotations.js";
|
|
66
|
-
import { applyComposerText, applyRowTemplate, fetchApply } from "./review_apply.js";
|
|
67
64
|
import { nameVerdictCards } from "./verdict_card.js";
|
|
68
65
|
import { redrawFresh } from "./verdict_fresh.js";
|
|
69
66
|
import { authorBadge, nameUnnamedBadges } from "./participant_names.js";
|
|
@@ -192,8 +189,6 @@ const participantsControl = viewer.can("participants_admin") ? createParticipant
|
|
|
192
189
|
el: infoTextEl,
|
|
193
190
|
session: () => store.selected,
|
|
194
191
|
api: { list: listParticipants, invite: inviteParticipant, revoke: revokeParticipant, cap: setParticipantCap },
|
|
195
|
-
startReview: (opts) => sessionActions.reviewSelected(opts),
|
|
196
|
-
reviewing: () => sessionActions.reviewing.has(store.selected),
|
|
197
192
|
// An older prompt drawn before the list came says "a participant": named now.
|
|
198
193
|
onNames: () => {
|
|
199
194
|
nameUnnamedBadges(document);
|
|
@@ -217,7 +212,6 @@ const startPage = createStartPage({
|
|
|
217
212
|
settingsEl: $("#settingsNew"),
|
|
218
213
|
llmContextEl: $("#llmContextNew"),
|
|
219
214
|
thinkingEl: $("#thinkingNew"),
|
|
220
|
-
reviewEl: $("#reviewNew"),
|
|
221
215
|
toolkitBtnEl: $("#toolkitBtn"),
|
|
222
216
|
toolkitEl: $("#toolkitNew"),
|
|
223
217
|
selected: () => store.selected,
|
|
@@ -451,7 +445,6 @@ const deliveryControl = createDeliveryControl({
|
|
|
451
445
|
composerEmpty: () => !composer.hasDraft(),
|
|
452
446
|
history: viewer.can("prompt_history"),
|
|
453
447
|
send: (delivery) => handleSendTurn({ delivery }),
|
|
454
|
-
session: () => store.selected,
|
|
455
448
|
});
|
|
456
449
|
|
|
457
450
|
// This tab's id in the session's events: tells its own prompts from the
|
|
@@ -478,7 +471,8 @@ const questionCards = createQuestionCards({
|
|
|
478
471
|
// The bar's chip reads questionCards.pendingQuestion() (sessionWaits).
|
|
479
472
|
onPending: () => store.touch("infoBar"),
|
|
480
473
|
// The stage's waiting cards as data (stage_waiting.js).
|
|
481
|
-
|
|
474
|
+
onArrive: (key, info) => turnDom.expectWaiting?.(key, info),
|
|
475
|
+
onSettled: (key, opts) => turnDom.settleWaiting?.(key, opts),
|
|
482
476
|
});
|
|
483
477
|
// The history's bubbles (bubbles.js): output, end lines, every client's
|
|
484
478
|
// prompts, the recap, warnings and notices, command and note bubbles.
|
|
@@ -523,7 +517,6 @@ const sessionView = createSessionView({
|
|
|
523
517
|
liveTurn, turnDom, questionCards, shownTexts, objectives, featureGates, markdownTip, workingSet, wsPreview, gapClock,
|
|
524
518
|
bubbles, cards, markdown: markdownPlace,
|
|
525
519
|
capabilities: () => pageCapabilities,
|
|
526
|
-
can: viewer.can,
|
|
527
520
|
page: {
|
|
528
521
|
setReviseAnchor, renderInitRow, setMarkdownWarning, setCapabilities, findInTurnRoots, appendToHistory,
|
|
529
522
|
setTurnRunning, mergeTurnTiming, applySessionPayload, turnEndStatus, replaceSelectedCard,
|
|
@@ -703,7 +696,7 @@ const sessionActions = createSessionActions({
|
|
|
703
696
|
store,
|
|
704
697
|
sessions: () => store.sessions,
|
|
705
698
|
setSessions: (list) => store.update({ sessions: list }),
|
|
706
|
-
api: { continueSession,
|
|
699
|
+
api: { continueSession, archiveSession, unarchiveSession, deleteSession, stopSession,
|
|
707
700
|
sessionHolds, stopSessionHolds },
|
|
708
701
|
eventsLive: () => !!eventsControl,
|
|
709
702
|
refresh,
|
|
@@ -910,11 +903,9 @@ function clearNotice() {
|
|
|
910
903
|
}
|
|
911
904
|
promptEl.addEventListener("input", clearNotice);
|
|
912
905
|
promptEl.addEventListener("input", () => noteDraft());
|
|
913
|
-
// An emptied composer lets go of its
|
|
914
|
-
// Revise.
|
|
906
|
+
// An emptied composer lets go of its Verify claim and its Revise.
|
|
915
907
|
promptEl.addEventListener("input", () => {
|
|
916
908
|
if (promptEl.value.trim()) return;
|
|
917
|
-
deliveryControl.release();
|
|
918
909
|
ownerVerify.clear();
|
|
919
910
|
setReviseAnchor(null);
|
|
920
911
|
});
|
|
@@ -979,41 +970,11 @@ infoTextEl.addEventListener("click", async (e) => {
|
|
|
979
970
|
showToast((await copyText(store.selected)) ? "Session id copied" : "Couldn't copy the session id");
|
|
980
971
|
});
|
|
981
972
|
|
|
982
|
-
// Apply (review_apply.js) under a participant's review turn that just
|
|
983
|
-
// ended live ({turn_id, author, author_name}, from its turn_started), once:
|
|
984
|
-
// a reload draws it from the history (turn_block.js).
|
|
985
|
-
function placeApply(data) {
|
|
986
|
-
const badge = authorBadge(data.author, data.author_name);
|
|
987
|
-
if (!badge || historyEl.querySelector(`.review-apply[data-apply-turn="${CSS.escape(data.turn_id)}"]`)) return;
|
|
988
|
-
appendToHistory(elementOf(applyRowTemplate(data.turn_id, badge)));
|
|
989
|
-
}
|
|
990
|
-
|
|
991
973
|
// The owner's Verify (owner_verify.js): verdict cards, Verify fresh, the claim.
|
|
992
974
|
const ownerVerify = createOwnerVerify({
|
|
993
975
|
historyEl, store, api, claim: ownerClaim, liveTurn, toast: (text) => showToast(text),
|
|
994
976
|
});
|
|
995
977
|
|
|
996
|
-
// Apply: the owner's Apply turn into the composer, after what is typed
|
|
997
|
-
// there; never sent from here.
|
|
998
|
-
if (viewer.can("apply")) historyEl.addEventListener("click", async (e) => {
|
|
999
|
-
const button = e.target.closest(".review-apply-btn");
|
|
1000
|
-
if (!button || !store.selected) return;
|
|
1001
|
-
const id = store.selected;
|
|
1002
|
-
button.disabled = true;
|
|
1003
|
-
try {
|
|
1004
|
-
const text = await fetchApply(id, button.dataset.applyTurn);
|
|
1005
|
-
if (id === store.selected) {
|
|
1006
|
-
fillComposer(applyComposerText(promptEl.value, text));
|
|
1007
|
-
// The owner's own turn: queued after a running one, never steered in.
|
|
1008
|
-
deliveryControl.hold();
|
|
1009
|
-
}
|
|
1010
|
-
} catch (err) {
|
|
1011
|
-
showToast(err.message);
|
|
1012
|
-
} finally {
|
|
1013
|
-
button.disabled = false;
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
1016
|
-
|
|
1017
978
|
// The session bar (info_bar_model.js sessionBar): its buttons, and the
|
|
1018
979
|
// info line rendered by info_bar.js.
|
|
1019
980
|
// The open session waits on the user: its card is up, or its summary says so
|
|
@@ -1185,7 +1146,6 @@ const streamHandlers = (participant ? participant.wrapHandlers : (handlers) => h
|
|
|
1185
1146
|
contextChips,
|
|
1186
1147
|
workingSet,
|
|
1187
1148
|
participantsControl,
|
|
1188
|
-
placeApply: viewer.can("apply") ? placeApply : null,
|
|
1189
1149
|
placeVerdict: ownerVerify.placeVerdict,
|
|
1190
1150
|
restoreVerify: (anchor) => ownerVerify.set(anchor),
|
|
1191
1151
|
restoreRevise,
|
|
@@ -1332,15 +1292,14 @@ function runSessionCommand(line) {
|
|
|
1332
1292
|
|
|
1333
1293
|
function clearComposer() {
|
|
1334
1294
|
promptEl.value = "";
|
|
1335
|
-
deliveryControl.release();
|
|
1336
1295
|
fitPrompt();
|
|
1337
1296
|
}
|
|
1338
1297
|
|
|
1339
|
-
// A queue (Alt+Enter
|
|
1340
|
-
//
|
|
1298
|
+
// A queue (Alt+Enter) to a worker that can't queue (it would steer): not
|
|
1299
|
+
// sent, the text kept, a note says why.
|
|
1341
1300
|
function queueRefused(altKey) {
|
|
1342
1301
|
if (!store.selected || !liveTurn.running || store.current.workerFeatures.includes("delivery")) return false;
|
|
1343
|
-
if (!altKey
|
|
1302
|
+
if (!altKey) return false;
|
|
1344
1303
|
addCommandBubble({ label: null, line: promptEl.value.trim(), text: QUEUE_NEEDS_WORKER, failed: true });
|
|
1345
1304
|
return true;
|
|
1346
1305
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// What a card waits as, from its data (stage_waiting.js KINDS): the kind,
|
|
2
|
+
// whether it is an approval, and the folded row's text (stage_asking.js
|
|
3
|
+
// foldedText), read from the pending question, the continue offer or the
|
|
4
|
+
// plugin card before its node is drawn. question_cards.js and cards_place.js
|
|
5
|
+
// hand it to the stage (onArrive / expectWaiting) right before the card is
|
|
6
|
+
// placed; the stage still reads the node (waitingKind, foldedText) as a
|
|
7
|
+
// cross-check, and as the fallback for a card that came without it.
|
|
8
|
+
// Pure: no DOM. The same rules question_cards.js and card.js draw by:
|
|
9
|
+
// data-kind, data-relay and the step-limit class; the question text and the
|
|
10
|
+
// approval's summary line; a plugin card's actions and level.
|
|
11
|
+
import { approvalView, isContinue, relayView, summaryText } from "./question_card.js";
|
|
12
|
+
|
|
13
|
+
// The question a card shows (its .question-text): a delegate's relayed
|
|
14
|
+
// question's own words, else the question.
|
|
15
|
+
export function questionText(pq) {
|
|
16
|
+
return String((relayView(pq) && pq.relay.asked) || pq?.question || "");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// A pending question's wait: the step limit is "continue", a delegate's
|
|
20
|
+
// relayed card "relay", else its kind (approval, hook, question).
|
|
21
|
+
export function questionWait(pq) {
|
|
22
|
+
const approval = pq?.kind === "approval";
|
|
23
|
+
const kind = isContinue(pq) ? "continue" : relayView(pq) ? "relay" : ["approval", "hook"].includes(pq?.kind) ? pq.kind : "question";
|
|
24
|
+
if (!approval) return { kind, approval, summary: questionText(pq) };
|
|
25
|
+
// The summary's own words and the command's (or the tool's) first line.
|
|
26
|
+
const view = approvalView(pq);
|
|
27
|
+
const what = String(view.what || view.tool || "").trim().split("\n")[0].trim();
|
|
28
|
+
return { kind, approval, summary: [summaryText(pq).trim(), what].filter(Boolean).join(" ") };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// The old continue card: no question text.
|
|
32
|
+
export function continueWait() {
|
|
33
|
+
return { kind: "continue", approval: false, summary: "" };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// A plugin card's wait: a running turn's card with an action asks (as
|
|
37
|
+
// check-in's), a warning stays in sight; null: it doesn't wait.
|
|
38
|
+
export function cardWait(card) {
|
|
39
|
+
const asks = !!card?.in_turn && (card.actions || []).some((a) => a && a.command);
|
|
40
|
+
return { kind: asks ? "asks" : card?.level === "warn" ? "warn" : null, approval: false, summary: String(card?.title || "") };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// The cross-check: the data and the node disagree about +key+'s +what+
|
|
44
|
+
// ("kind", "summary"). Said once per key and field.
|
|
45
|
+
const said = new Set();
|
|
46
|
+
export function warnDiffers(what, key, data, dom) {
|
|
47
|
+
const id = `${what}:${key}`;
|
|
48
|
+
if (said.has(id)) return;
|
|
49
|
+
said.add(id);
|
|
50
|
+
console.warn(`stage: waiting ${what} differs`, key, data, dom);
|
|
51
|
+
}
|
|
@@ -16,6 +16,7 @@ import { llmContextNotice, noticeLine } from "./turn_events.js";
|
|
|
16
16
|
import { hookNoticeTemplate, TURN_PROMPT, turnPromptBubbles } from "./bubbles.js";
|
|
17
17
|
import { stillOn } from "./latest.js";
|
|
18
18
|
import { pluginCardKey } from "./stage_waiting.js";
|
|
19
|
+
import { cardWait } from "./card_kinds.js";
|
|
19
20
|
|
|
20
21
|
// The elements of the reloaded turn that ends before +before+ (the next
|
|
21
22
|
// turn's prompt, or null for the last turn), its prompt first.
|
|
@@ -74,17 +75,27 @@ export function createCardsPlace({
|
|
|
74
75
|
const existing = cardElement(card.id);
|
|
75
76
|
const asks = (card.actions || []).some((a) => a && a.command);
|
|
76
77
|
if (existing) {
|
|
78
|
+
const wasWarn = existing.classList.contains("warn");
|
|
77
79
|
const drawn = drawCard(existing, card);
|
|
78
80
|
drawn.classList.add("card-updated");
|
|
79
81
|
setTimeout(() => drawn.classList.remove("card-updated"), 900);
|
|
80
82
|
// Redrawn without its actions (check-in's card turned into its notice
|
|
81
|
-
// row): it no longer asks
|
|
82
|
-
|
|
83
|
+
// row): it no longer asks; redrawn neither asking nor a warning: it no
|
|
84
|
+
// longer stays in sight. Then, still waiting (check-in's new title, an
|
|
85
|
+
// asking card now a warning: in sight, not docked), the stage's entry
|
|
86
|
+
// says what it waits as now (stage_waiting.js).
|
|
87
|
+
const key = pluginCardKey(card.id);
|
|
88
|
+
const wait = cardWait(card);
|
|
89
|
+
if (!asks) turnDom.settleWaiting?.(key, { only: "asks" });
|
|
90
|
+
if (wasWarn && !asks && card.level !== "warn") turnDom.settleWaiting?.(key, { only: "warn" });
|
|
91
|
+
if (wait.kind) turnDom.updateWaiting?.(key, wait);
|
|
83
92
|
return;
|
|
84
93
|
}
|
|
85
94
|
bubbles.removeHintIfEmpty();
|
|
86
95
|
const el = drawCard(document.createElement(isNoticeCard(card) ? "details" : "div"), card);
|
|
87
96
|
if (card.in_turn && !before && !asks && turnDom.card(el)) return;
|
|
97
|
+
// What it waits as, for the stage's place (stage_place.js).
|
|
98
|
+
if (!before) turnDom.expectWaiting?.(pluginCardKey(card.id), cardWait(card));
|
|
88
99
|
bubbles.placeFollowing(el, before);
|
|
89
100
|
}
|
|
90
101
|
|
|
@@ -60,11 +60,9 @@ export function listSessions(sort, order, { dir, ...opts } = {}) {
|
|
|
60
60
|
// start page's ⚙ panel set some; thinking: its own level ("low"), when the
|
|
61
61
|
// start page's ⚙ panel set one; toolkit: the kit it starts on, when the
|
|
62
62
|
// start page's 🧰 list picked one (none: config's default, maybe suggested).
|
|
63
|
-
// review: {subjects} makes it a review session (it starts idle; no preview).
|
|
64
63
|
// The other fields are api()'s fetch options.
|
|
65
|
-
export function createIdleSession({ dir, model, preview, llm_context: llmContext, thinking, toolkit,
|
|
66
|
-
|
|
67
|
-
const start = review ? { review } : { idle: true, ...(preview ? { preview } : {}) };
|
|
64
|
+
export function createIdleSession({ dir, model, preview, llm_context: llmContext, thinking, toolkit, ...opts } = {}) {
|
|
65
|
+
const start = { idle: true, ...(preview ? { preview } : {}) };
|
|
68
66
|
const body = { ...start, ...(dir ? { dir } : {}), ...(model ? { model } : {}),
|
|
69
67
|
...(llmContext ? { llm_context: llmContext } : {}), ...(thinking ? { thinking } : {}),
|
|
70
68
|
...(toolkit ? { toolkit } : {}) };
|
|
@@ -80,12 +78,6 @@ export function continueSession(id, opts = {}) {
|
|
|
80
78
|
return api("/api/sessions", { method: "POST", body: JSON.stringify({ continues: id, idle: true }), ...opts });
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
// A review fork of +id+ (docs/sessions.md, Review sessions): a new session in
|
|
84
|
-
// its folder, seeded with its recap, not its transcript; +id+ keeps running.
|
|
85
|
-
export function startReview(id, opts = {}) {
|
|
86
|
-
return api("/api/sessions", { method: "POST", body: JSON.stringify({ review: { from: id } }), ...opts });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
81
|
// The models a new session can start on: {default, models: [{name, host, id}],
|
|
90
82
|
// warning?} (a host that failed is in the warning, the list has the rest).
|
|
91
83
|
export function listModels(opts = {}) {
|