samagotchi 0.120.0 → 0.121.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 +116 -1
- data/bin/chi +3 -2
- data/docs/architecture.md +36 -11
- data/docs/bundle-authoring.md +2 -1
- data/docs/cli.md +10 -4
- data/docs/configuration.md +34 -11
- data/docs/guardrails.md +48 -19
- data/docs/internals/anthropic.md +1 -1
- data/docs/internals/background-tasks.md +1 -1
- data/docs/internals/participants.md +6 -2
- data/docs/internals/prompt-caching.md +7 -6
- data/docs/internals/remote-sessions.md +15 -11
- data/docs/internals/web-push.md +22 -11
- data/docs/plugins.md +28 -8
- data/docs/sessions.md +15 -0
- data/docs/testing.md +44 -2
- data/lib/samagotchi/answer_command.rb +1 -1
- data/lib/samagotchi/bridge.rb +8 -8
- data/lib/samagotchi/bridge_client/event_stream.rb +11 -27
- data/lib/samagotchi/bridge_client/stream_open.rb +79 -0
- data/lib/samagotchi/bridge_client/stream_request.rb +8 -2
- data/lib/samagotchi/bridge_client.rb +52 -65
- data/lib/samagotchi/bridge_secret.rb +9 -7
- data/lib/samagotchi/bundle_command/check.rb +27 -2
- data/lib/samagotchi/bundles/claude-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/claude-peer/scripts/pair +21 -7
- data/lib/samagotchi/bundles/codex-peer/manifest.yml +2 -2
- data/lib/samagotchi/bundles/codex-peer/scripts/pair +14 -3
- data/lib/samagotchi/bundles/dev/manifest.yml +2 -2
- data/lib/samagotchi/bundles/github-pr/manifest.yml +2 -2
- data/lib/samagotchi/bundles/github-pr/plugin.rb +2 -6
- data/lib/samagotchi/bundles/mcp/manifest.yml +3 -3
- data/lib/samagotchi/bundles/mcp/plugin.rb +5 -1
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/child_move.rb +5 -7
- data/lib/samagotchi/children_status.rb +2 -1
- data/lib/samagotchi/engine.rb +1 -0
- data/lib/samagotchi/guardrail_wiring.rb +19 -2
- data/lib/samagotchi/guardrails/parent_approvals.rb +9 -0
- data/lib/samagotchi/guardrails_command.rb +41 -6
- data/lib/samagotchi/image_store.rb +6 -3
- data/lib/samagotchi/interrupted_turn.rb +6 -3
- data/lib/samagotchi/kernel_loop.rb +5 -0
- data/lib/samagotchi/live_versions.rb +6 -7
- data/lib/samagotchi/memory_bundle/profile.rb +1 -1
- data/lib/samagotchi/memory_bundle/uninstaller.rb +6 -2
- data/lib/samagotchi/plugin/api.rb +14 -8
- data/lib/samagotchi/plugin/sessions.rb +13 -4
- data/lib/samagotchi/push_command.rb +1 -1
- data/lib/samagotchi/relay_verifier.rb +2 -3
- data/lib/samagotchi/relay_watcher.rb +2 -2
- data/lib/samagotchi/remote_attach_command.rb +1 -1
- data/lib/samagotchi/reply_wait/poll.rb +8 -2
- data/lib/samagotchi/reply_wait.rb +4 -3
- data/lib/samagotchi/review_command.rb +1 -1
- data/lib/samagotchi/run_options.rb +1 -0
- data/lib/samagotchi/session.rb +4 -0
- data/lib/samagotchi/session_access/local.rb +18 -8
- data/lib/samagotchi/session_access/remote.rb +5 -0
- data/lib/samagotchi/session_access/web_bridge_client.rb +31 -19
- data/lib/samagotchi/session_access.rb +21 -9
- data/lib/samagotchi/session_continue.rb +2 -3
- data/lib/samagotchi/session_manager.rb +118 -28
- data/lib/samagotchi/sessions_command.rb +10 -5
- data/lib/samagotchi/system_one/client.rb +6 -1
- data/lib/samagotchi/system_one/fake_backend.rb +0 -2
- data/lib/samagotchi/system_one/log.rb +21 -6
- data/lib/samagotchi/system_one/self_protect.rb +39 -43
- data/lib/samagotchi/terminal_ui/attach_launcher.rb +8 -3
- data/lib/samagotchi/terminal_ui/attached_loop.rb +4 -2
- data/lib/samagotchi/terminal_ui/local_link.rb +28 -19
- data/lib/samagotchi/terminal_ui/question_slot.rb +19 -8
- data/lib/samagotchi/tool_declarations.rb +1 -1
- data/lib/samagotchi/tool_runner.rb +37 -1
- data/lib/samagotchi/toolkit.rb +117 -27
- data/lib/samagotchi/toolkit_binding.rb +32 -0
- data/lib/samagotchi/toolkit_command.rb +23 -0
- data/lib/samagotchi/tools/deferred_tools.rb +10 -2
- data/lib/samagotchi/tools/delegate.rb +1 -1
- data/lib/samagotchi/tools/delegate_relay.rb +9 -7
- data/lib/samagotchi/tools/registry.rb +20 -6
- data/lib/samagotchi/tools/tool_index.rb +103 -20
- data/lib/samagotchi/turn_checkpoint.rb +15 -9
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +123 -65
- data/lib/samagotchi/web/participant_access.rb +26 -7
- data/lib/samagotchi/web/participant_review.rb +11 -6
- data/lib/samagotchi/web/participant_view.rb +7 -3
- data/lib/samagotchi/web/participants_admin.rb +13 -0
- data/lib/samagotchi/web/public/app.js +1 -1
- data/lib/samagotchi/web/public/forms.css +12 -0
- data/lib/samagotchi/web/public/index.html +7 -5
- data/lib/samagotchi/web/public/level_chip.js +2 -2
- data/lib/samagotchi/web/public/llm_context_chip.js +4 -4
- data/lib/samagotchi/web/public/notifications.js +21 -1
- data/lib/samagotchi/web/public/participant.html +4 -2
- data/lib/samagotchi/web/public/participant.js +34 -11
- data/lib/samagotchi/web/public/participants_panel.js +49 -14
- data/lib/samagotchi/web/public/push.js +4 -3
- data/lib/samagotchi/web/public/push_devices.js +17 -3
- data/lib/samagotchi/web/public/question_card.js +15 -1
- data/lib/samagotchi/web/public/question_cards.js +11 -2
- data/lib/samagotchi/web/public/review_history.js +24 -4
- data/lib/samagotchi/web/public/review_start.js +1 -3
- data/lib/samagotchi/web/public/session_actions.js +14 -2
- data/lib/samagotchi/web/public/storage.js +16 -0
- data/lib/samagotchi/web/public/toolkit_chip.js +3 -0
- data/lib/samagotchi/web/push/client.rb +5 -0
- data/lib/samagotchi/web/push/store.rb +16 -3
- data/lib/samagotchi/web/push_routes.rb +3 -2
- data/lib/samagotchi/web/session_access_routes.rb +25 -17
- data/lib/samagotchi/web/session_create.rb +4 -4
- data/lib/samagotchi/web/session_hub.rb +6 -4
- data/lib/samagotchi/web/session_summary.rb +8 -16
- data/lib/samagotchi/web/tunnel.rb +10 -1
- data/lib/samagotchi/worker.rb +1 -1
- data/lib/samagotchi/worker_link.rb +213 -0
- data/lib/samagotchi/worker_sidecar.rb +15 -37
- metadata +4 -1
data/lib/samagotchi/web/app.rb
CHANGED
|
@@ -16,6 +16,7 @@ require_relative "../answer_tail"
|
|
|
16
16
|
require_relative "../answer_refs"
|
|
17
17
|
require_relative "../question_asked"
|
|
18
18
|
require_relative "../bridge_client"
|
|
19
|
+
require_relative "../worker_link"
|
|
19
20
|
require_relative "../bridge/bounded_queue"
|
|
20
21
|
require_relative "../bridge/card_store"
|
|
21
22
|
require_relative "../session"
|
|
@@ -54,6 +55,7 @@ require_relative "markdown_renderer"
|
|
|
54
55
|
require_relative "capabilities"
|
|
55
56
|
require_relative "editor"
|
|
56
57
|
require_relative "../message_parts"
|
|
58
|
+
require_relative "../launch_mode"
|
|
57
59
|
require_relative "session_summary"
|
|
58
60
|
require_relative "session_access_routes"
|
|
59
61
|
require_relative "principal"
|
|
@@ -321,6 +323,11 @@ module Samagotchi
|
|
|
321
323
|
# Anything else is a file under public_dir (/assets/*, /public/* or
|
|
322
324
|
# a bare path such as /style.css), or 404.
|
|
323
325
|
serve_static(req)
|
|
326
|
+
rescue Toolkit::Refused => e
|
|
327
|
+
# A new session (create, continue, fork, review) on a config kit
|
|
328
|
+
# with an invalid groups: (Toolkit.check_new!), whichever handler
|
|
329
|
+
# spawned it.
|
|
330
|
+
error_response(400, "toolkit_refused", e.message)
|
|
324
331
|
rescue StandardError => e
|
|
325
332
|
Log.exception(:web, "request_failed", e, method: env["REQUEST_METHOD"], path: env["PATH_INFO"])
|
|
326
333
|
# A participant never reads an exception's words (they may name a
|
|
@@ -1086,7 +1093,7 @@ module Samagotchi
|
|
|
1086
1093
|
reply = request.call(client)
|
|
1087
1094
|
# Not the route's own 403 (a parent's option refused): the worker
|
|
1088
1095
|
# asked for a secret this chi web didn't send.
|
|
1089
|
-
return error_response(502, BridgeSecret::ERROR, BridgeSecret
|
|
1096
|
+
return error_response(502, BridgeSecret::ERROR, BridgeSecret.refused(id)) if reply.secret_refused?
|
|
1090
1097
|
|
|
1091
1098
|
mapped = yield(reply)
|
|
1092
1099
|
return mapped if mapped
|
|
@@ -1106,7 +1113,7 @@ module Samagotchi
|
|
|
1106
1113
|
end
|
|
1107
1114
|
|
|
1108
1115
|
def not_live(id)
|
|
1109
|
-
error_response(503, "not_live",
|
|
1116
|
+
error_response(503, "not_live", WorkerLink.not_live(id))
|
|
1110
1117
|
end
|
|
1111
1118
|
|
|
1112
1119
|
# A live worker refused or failed the request (a 500 in its handler, a
|
|
@@ -1134,8 +1141,9 @@ module Samagotchi
|
|
|
1134
1141
|
# The session's Bridge, waiting briefly for one a resume just spawned.
|
|
1135
1142
|
# @return [BridgeClient, nil]
|
|
1136
1143
|
def live_bridge_client(id)
|
|
1137
|
-
|
|
1138
|
-
|
|
1144
|
+
link = worker_link(id)
|
|
1145
|
+
link = await_worker_link(id, timeout: [@bridge_wait_timeout.to_f, 5.0].min) unless link.live?
|
|
1146
|
+
link_client(id, link)
|
|
1139
1147
|
end
|
|
1140
1148
|
|
|
1141
1149
|
# The process holding the session (an OwnerLock::Owner), or nil. A worker always runs a Bridge; a TUI (plain `chi`) doesn't share.
|
|
@@ -1355,47 +1363,55 @@ module Samagotchi
|
|
|
1355
1363
|
return error_response(404, "not_found", "Session not found: #{id}")
|
|
1356
1364
|
end
|
|
1357
1365
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
# Wait briefly for it so the first SSE connect lands on a live bridge
|
|
1364
|
-
# instead of an instantly-closed empty 200 / 503 during startup.
|
|
1365
|
-
if sidecar.nil? && @bridge_wait_timeout.to_i.positive?
|
|
1366
|
-
sidecar = await_bridge_sidecar(id, timeout: [@bridge_wait_timeout.to_f, 2.0].min)
|
|
1366
|
+
link = worker_link(id)
|
|
1367
|
+
if link.is_a?(WorkerLink::Starting)
|
|
1368
|
+
return error_response(503, "not_live", format(LaunchMode::BRIDGE_LATE, id)) if link.stuck
|
|
1369
|
+
|
|
1370
|
+
link = await_worker_link(id, timeout: [@bridge_wait_timeout.to_f, 2.0].min)
|
|
1367
1371
|
end
|
|
1368
|
-
return
|
|
1372
|
+
return stream_link_error(id, link) unless link.live?
|
|
1369
1373
|
|
|
1370
|
-
client =
|
|
1374
|
+
client = link_client(id, link)
|
|
1375
|
+
filter = stream_filter(req, id)
|
|
1376
|
+
query = participant_view?(req) ? participant_stream_query(req) : stream_query(req)
|
|
1377
|
+
opened = client.open_stream(query: query, last_event_id: req.env["HTTP_LAST_EVENT_ID"])
|
|
1378
|
+
return stream_open_error(id, opened) unless opened.is_a?(BridgeClient::StreamOpen::Opened)
|
|
1371
1379
|
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1380
|
+
handed_off = false
|
|
1381
|
+
begin
|
|
1382
|
+
headers = {
|
|
1383
|
+
"Content-Type" => "text/event-stream",
|
|
1384
|
+
"Cache-Control" => "no-cache",
|
|
1385
|
+
"Connection" => "keep-alive",
|
|
1386
|
+
"X-Accel-Buffering" => "no"
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
# Handlers that buffer enumerable bodies before responding (rackup's
|
|
1390
|
+
# WEBrick does `body.each` to completion) hang forever on an unbounded
|
|
1391
|
+
# SSE body — the browser never even receives the status line. When the
|
|
1392
|
+
# handler supports hijacking, stream frames straight to the socket
|
|
1393
|
+
# instead of returning an enumerable.
|
|
1394
|
+
if req.env["rack.hijack?"]
|
|
1395
|
+
hijack = sse_hijack(id, req, client, opened, filter)
|
|
1396
|
+
handed_off = true
|
|
1397
|
+
return [200, headers.merge("rack.hijack" => hijack), []]
|
|
1398
|
+
end
|
|
1378
1399
|
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
if req.env["rack.hijack?"]
|
|
1385
|
-
hijack = sse_hijack(id, req, client)
|
|
1386
|
-
return [200, headers.merge("rack.hijack" => hijack), []]
|
|
1400
|
+
body = proxy_stream_body(id, req, client, opened, filter)
|
|
1401
|
+
handed_off = true
|
|
1402
|
+
[200, headers, body]
|
|
1403
|
+
ensure
|
|
1404
|
+
opened.sock.close unless handed_off
|
|
1387
1405
|
end
|
|
1388
|
-
|
|
1389
|
-
[200, headers, proxy_stream_body(id, req, client)]
|
|
1390
1406
|
end
|
|
1391
1407
|
|
|
1392
1408
|
# The one ProxyStreamBody both of #handle_stream's transports send:
|
|
1393
1409
|
# the session's Bridge stream, through the request principal's frame
|
|
1394
1410
|
# filter (#stream_filter).
|
|
1395
|
-
def proxy_stream_body(
|
|
1411
|
+
def proxy_stream_body(_id, req, client, opened, filter)
|
|
1396
1412
|
query = participant_view?(req) ? participant_stream_query(req) : stream_query(req)
|
|
1397
|
-
ProxyStreamBody.new(client: client, query: query, headers: req.env,
|
|
1398
|
-
server_running: stream_running(principal(req)), filter:
|
|
1413
|
+
ProxyStreamBody.new(client: client, opened: opened, query: query, headers: req.env,
|
|
1414
|
+
server_running: stream_running(principal(req)), filter: filter)
|
|
1399
1415
|
end
|
|
1400
1416
|
|
|
1401
1417
|
# What a request's stream goes through on its way from the Bridge:
|
|
@@ -1465,10 +1481,10 @@ module Samagotchi
|
|
|
1465
1481
|
# frames directly to the client socket until it disconnects. The handler
|
|
1466
1482
|
# (WEBrick via rackup) has already sent the status line + headers, so
|
|
1467
1483
|
# only body bytes go to the socket here.
|
|
1468
|
-
def sse_hijack(id, req, client)
|
|
1484
|
+
def sse_hijack(id, req, client, opened, filter)
|
|
1469
1485
|
# Made before the status line goes out: a principal with no filter
|
|
1470
1486
|
# is refused (#stream_filter), never streamed.
|
|
1471
|
-
body = proxy_stream_body(id, req, client)
|
|
1487
|
+
body = proxy_stream_body(id, req, client, opened, filter)
|
|
1472
1488
|
lambda do |io|
|
|
1473
1489
|
body.each { |chunk| io.write(chunk) }
|
|
1474
1490
|
rescue Errno::EPIPE, Errno::ECONNRESET, IOError
|
|
@@ -1476,36 +1492,67 @@ module Samagotchi
|
|
|
1476
1492
|
rescue StandardError => e
|
|
1477
1493
|
Log.warn(:web, "proxy_failed", sid: id, port: client.port, error: e.class.name, msg: e.message)
|
|
1478
1494
|
nil
|
|
1495
|
+
ensure
|
|
1496
|
+
body.close
|
|
1479
1497
|
end
|
|
1480
1498
|
end
|
|
1481
1499
|
|
|
1482
|
-
# Bounded wait for a freshly-spawned worker's
|
|
1483
|
-
#
|
|
1484
|
-
#
|
|
1485
|
-
#
|
|
1486
|
-
|
|
1487
|
-
|
|
1500
|
+
# Bounded wait for a freshly-spawned worker's Bridge so the response
|
|
1501
|
+
# hands the client a live transport without client-side polling (the
|
|
1502
|
+
# web's WorkerLink.await: #worker_link polled). Returns the first Live,
|
|
1503
|
+
# else the last outcome (None when +timeout+ allows no wait): the
|
|
1504
|
+
# session still exists; EventSource auto-reconnect covers late binders.
|
|
1505
|
+
# @return [WorkerLink::Live, WorkerLink::None, WorkerLink::Stale]
|
|
1506
|
+
def await_worker_link(session_id, timeout: @bridge_wait_timeout)
|
|
1507
|
+
return WorkerLink::None.new if timeout.nil? || timeout <= 0
|
|
1508
|
+
|
|
1509
|
+
WorkerLink.await(session_id, session_dir: @session_class.session_dir(session_id, state_dir: default_state_dir),
|
|
1510
|
+
timeout: timeout, interval: BridgeClient::SPAWN_POLL_INTERVAL,
|
|
1511
|
+
give_up: lambda do |outcome|
|
|
1512
|
+
outcome.is_a?(WorkerLink::Leaving) || outcome.is_a?(WorkerLink::Stale) ||
|
|
1513
|
+
outcome.is_a?(WorkerLink::Skew) ||
|
|
1514
|
+
(outcome.is_a?(WorkerLink::Starting) && outcome.stuck)
|
|
1515
|
+
end,
|
|
1516
|
+
host: DEFAULT_HOST)
|
|
1517
|
+
end
|
|
1518
|
+
|
|
1519
|
+
def stream_link_error(id, link)
|
|
1520
|
+
return error_response(502, "worker_newer", link.message(id)) if link.is_a?(WorkerLink::Skew)
|
|
1521
|
+
if link.is_a?(WorkerLink::Starting) && link.stuck
|
|
1522
|
+
return error_response(503, "not_live", format(LaunchMode::BRIDGE_LATE, id))
|
|
1523
|
+
end
|
|
1524
|
+
if link.is_a?(WorkerLink::Leaving)
|
|
1525
|
+
return json_response(503, { error: "not_live", detail: WorkerLink.not_live(id),
|
|
1526
|
+
leaving: true, leave_seconds: link.left.round(1) })
|
|
1527
|
+
end
|
|
1488
1528
|
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1529
|
+
error_response(503, "not_live", WorkerLink.not_live(id))
|
|
1530
|
+
end
|
|
1531
|
+
|
|
1532
|
+
def stream_open_error(id, outcome)
|
|
1533
|
+
return error_response(503, "not_live", WorkerLink.not_live(id)) if outcome.is_a?(BridgeClient::StreamOpen::Unreachable)
|
|
1534
|
+
return error_response(503, "not_live", WorkerLink.not_live(id)) if outcome.reason == :unknown_session
|
|
1535
|
+
return error_response(502, "bridge_secret", BridgeSecret.refused(id)) if outcome.reason == :bridge_secret
|
|
1536
|
+
|
|
1537
|
+
error_response(502, "bridge_error", outcome.detail || "the session's worker answered #{outcome.status}")
|
|
1492
1538
|
end
|
|
1493
1539
|
|
|
1494
|
-
# The session's
|
|
1495
|
-
# read again for every request, so a respawned worker's port
|
|
1496
|
-
# are the ones used.
|
|
1497
|
-
# @return [
|
|
1498
|
-
def
|
|
1540
|
+
# The session's worker link (WorkerLink.resolve; stale sidecars are
|
|
1541
|
+
# removed): read again for every request, so a respawned worker's port
|
|
1542
|
+
# and secret are the ones used.
|
|
1543
|
+
# @return [WorkerLink::Live, WorkerLink::None, WorkerLink::Stale]
|
|
1544
|
+
def worker_link(session_id)
|
|
1499
1545
|
dir = @session_class.session_dir(session_id, state_dir: default_state_dir)
|
|
1500
|
-
|
|
1546
|
+
WorkerLink.resolve(dir, unlink: true, host: DEFAULT_HOST)
|
|
1501
1547
|
rescue StandardError
|
|
1502
|
-
|
|
1548
|
+
WorkerLink::None.new
|
|
1503
1549
|
end
|
|
1504
1550
|
|
|
1505
1551
|
# @return [BridgeClient, nil] a client for the session's live Bridge
|
|
1506
|
-
def bridge_client(session_id) =
|
|
1552
|
+
def bridge_client(session_id) = link_client(session_id, worker_link(session_id))
|
|
1507
1553
|
|
|
1508
|
-
|
|
1554
|
+
# @return [BridgeClient, nil] +link+'s client when it is Live
|
|
1555
|
+
def link_client(session_id, link) = link.live? ? link.client(session_id, host: DEFAULT_HOST) : nil
|
|
1509
1556
|
|
|
1510
1557
|
# GET a read path of the session's live Bridge (+path+: "state",
|
|
1511
1558
|
# "snapshot", "stats", ...).
|
|
@@ -1533,7 +1580,8 @@ module Samagotchi
|
|
|
1533
1580
|
|
|
1534
1581
|
path = File.join(@public_dir, "index.html")
|
|
1535
1582
|
if File.file?(path)
|
|
1536
|
-
|
|
1583
|
+
# A block: a preset's \& or \' is text, never a backreference.
|
|
1584
|
+
body = File.read(path).sub("<body>") { "<body #{index_data_attributes(req)}>" }
|
|
1537
1585
|
[200, {
|
|
1538
1586
|
"Content-Type" => "text/html; charset=utf-8",
|
|
1539
1587
|
"Content-Length" => body.bytesize.to_s,
|
|
@@ -1823,9 +1871,12 @@ module Samagotchi
|
|
|
1823
1871
|
# is kept (the env carries the token cookie, never held or inspected)
|
|
1824
1872
|
# @param filter [#call, nil] chunk -> String (nil or "": nothing sent);
|
|
1825
1873
|
# it sees the Bridge's reads as they come, not whole frames
|
|
1826
|
-
# @param client [BridgeClient] the session's Bridge (App#
|
|
1827
|
-
|
|
1874
|
+
# @param client [BridgeClient] the session's Bridge (App#link_client)
|
|
1875
|
+
# @param opened [BridgeClient::StreamOpen::Opened] the socket whose
|
|
1876
|
+
# 200 was answered to the caller
|
|
1877
|
+
def initialize(client:, opened:, query:, headers:, server_running: -> { true }, filter: nil)
|
|
1828
1878
|
@client = client
|
|
1879
|
+
@opened = opened
|
|
1829
1880
|
@query = query
|
|
1830
1881
|
@last_event_id = headers["HTTP_LAST_EVENT_ID"]
|
|
1831
1882
|
@server_running = server_running
|
|
@@ -1833,16 +1884,23 @@ module Samagotchi
|
|
|
1833
1884
|
end
|
|
1834
1885
|
|
|
1835
1886
|
def each(&)
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
@client.stream(query: @query, last_event_id: @last_event_id, running: @server_running) do |chunk|
|
|
1843
|
-
out = @filter.call(chunk)
|
|
1887
|
+
opened = @opened
|
|
1888
|
+
return unless opened
|
|
1889
|
+
|
|
1890
|
+
@client.read_stream(opened, running: @server_running) do |chunk|
|
|
1891
|
+
out = @filter ? @filter.call(chunk) : chunk
|
|
1844
1892
|
yield(out) unless out.nil? || out.empty?
|
|
1845
1893
|
end
|
|
1894
|
+
ensure
|
|
1895
|
+
@opened = nil
|
|
1896
|
+
end
|
|
1897
|
+
|
|
1898
|
+
def close
|
|
1899
|
+
opened = @opened
|
|
1900
|
+
@opened = nil
|
|
1901
|
+
opened&.sock&.close
|
|
1902
|
+
rescue IOError, SystemCallError
|
|
1903
|
+
nil
|
|
1846
1904
|
end
|
|
1847
1905
|
end
|
|
1848
1906
|
end
|
|
@@ -13,6 +13,7 @@ require_relative "../parent_report"
|
|
|
13
13
|
require_relative "../participant_messages"
|
|
14
14
|
require_relative "../participants"
|
|
15
15
|
require_relative "../session"
|
|
16
|
+
require_relative "../turn_checkpoint"
|
|
16
17
|
require_relative "../log"
|
|
17
18
|
|
|
18
19
|
module Samagotchi
|
|
@@ -116,7 +117,7 @@ module Samagotchi
|
|
|
116
117
|
detail = ParticipantMessages::TOKEN_BOUND
|
|
117
118
|
return error_response(401, "token_bound", detail) if req.path_info.start_with?("/api/")
|
|
118
119
|
|
|
119
|
-
html_response(401, BOUND_PAGE.sub(ENDED_SENTENCE
|
|
120
|
+
html_response(401, BOUND_PAGE.sub(ENDED_SENTENCE) { "#{detail[0].upcase}#{detail[1..]}." })
|
|
120
121
|
end
|
|
121
122
|
|
|
122
123
|
def settle_grant(grant)
|
|
@@ -144,7 +145,7 @@ module Samagotchi
|
|
|
144
145
|
code, detail = ENDED.fetch(state)
|
|
145
146
|
return error_response(401, code, detail) if req.path_info.start_with?("/api/")
|
|
146
147
|
|
|
147
|
-
html_response(401, ENDED_PAGE.sub(ENDED_SENTENCE
|
|
148
|
+
html_response(401, ENDED_PAGE.sub(ENDED_SENTENCE) { "#{detail[0].upcase}#{detail[1..]}." })
|
|
148
149
|
end
|
|
149
150
|
|
|
150
151
|
def audit_expired(grant)
|
|
@@ -336,20 +337,38 @@ module Samagotchi
|
|
|
336
337
|
end
|
|
337
338
|
|
|
338
339
|
# Whether the turn +enqueued_id+ of session +id+ is +grant+'s: chi
|
|
339
|
-
# web's record of who sent it, else (a chi web restarted since)
|
|
340
|
-
#
|
|
340
|
+
# web's record of who sent it, else (a chi web restarted since) the
|
|
341
|
+
# author the session's files keep for it (#turn_author), which only a
|
|
342
|
+
# principal stamps.
|
|
341
343
|
def own_turn?(grant, id, enqueued_id)
|
|
342
344
|
return false unless enqueued_id.is_a?(String) && !enqueued_id.empty?
|
|
343
345
|
|
|
344
346
|
sender = @participant_mutex.synchronize { @participant_turns[enqueued_id] }
|
|
345
347
|
return sender == grant.id if sender
|
|
346
348
|
|
|
347
|
-
|
|
349
|
+
turn_author(id, enqueued_id) == grant.author
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# Who queued the turn +enqueued_id+, as the session's files say: its
|
|
353
|
+
# input file's author while it waits or runs (the claimed
|
|
354
|
+
# *.json.processing stays until the turn ends), then the turn's end:
|
|
355
|
+
# last_turn's author, or its settled record's (a refused turn's).
|
|
356
|
+
# nil for the owner's turn, or one nothing names.
|
|
357
|
+
def turn_author(id, enqueued_id)
|
|
358
|
+
dir = Session.session_dir(id, state_dir: default_state_dir)
|
|
359
|
+
files = SessionInbox.find_new_input_files(dir) + SessionInbox.claimed_input_files(dir)
|
|
360
|
+
files.each do |file|
|
|
348
361
|
data = JSON.parse(File.read(file))
|
|
349
|
-
data.is_a?(Hash) && data["enqueued_id"] == enqueued_id
|
|
362
|
+
return data["author"] if data.is_a?(Hash) && data["enqueued_id"] == enqueued_id
|
|
350
363
|
rescue JSON::ParserError, SystemCallError
|
|
351
|
-
|
|
364
|
+
next
|
|
352
365
|
end
|
|
366
|
+
last = session_access.show(id).last_turn
|
|
367
|
+
return last.author if last&.enqueued_id == enqueued_id
|
|
368
|
+
|
|
369
|
+
TurnCheckpoint.settled_turn(dir, enqueued_id)&.author
|
|
370
|
+
rescue ArgumentError, JSON::ParserError, SystemCallError
|
|
371
|
+
nil
|
|
353
372
|
end
|
|
354
373
|
|
|
355
374
|
# GET /api/sessions/resolve?id= for a participant: their grant's
|
|
@@ -59,16 +59,18 @@ module Samagotchi
|
|
|
59
59
|
automatic = automatic_turn_ids(id, session, shown, current, state)
|
|
60
60
|
waiting = !!(current&.dig("waiting_for_owner") || turn_snapshot&.dig("continue_offer") ||
|
|
61
61
|
(turn_snapshot && !turn_snapshot["current_turn"] && turn_snapshot["pending_question"]))
|
|
62
|
-
queued = snapshot_list(turn_snapshot, "queued")
|
|
62
|
+
queued = turn_snapshot && snapshot_list(turn_snapshot, "queued")
|
|
63
|
+
status = displayed_status(session, state)
|
|
64
|
+
status = Session::STATUS_IDLE if status == Session::STATUS_RUNNING && current.nil?
|
|
63
65
|
json_response(200, {
|
|
64
66
|
viewer: review_viewer(req, id, session: session, state: state, queued: queued, viewer: viewer),
|
|
65
|
-
session: { id: session.id, title: participant_title(session), status:
|
|
67
|
+
session: { id: session.id, title: participant_title(session), status: status },
|
|
66
68
|
subjects: review_subjects(session, viewer),
|
|
67
69
|
participants: participant_names(id).map { |entry| entry.slice(:id, :name, :kind) },
|
|
68
70
|
messages: with_reply_html(ParticipantView.messages(shown, viewer, automatic: automatic)),
|
|
69
71
|
current_turn: current,
|
|
70
72
|
waiting_for_owner: waiting,
|
|
71
|
-
queued: review_queue(queued, viewer),
|
|
73
|
+
queued: review_queue(queued || [], viewer),
|
|
72
74
|
last_event_id: turn_snapshot && turn_snapshot["event_id"]
|
|
73
75
|
})
|
|
74
76
|
end
|
|
@@ -162,14 +164,16 @@ module Samagotchi
|
|
|
162
164
|
# source reads the grant's own author: never another participant's or
|
|
163
165
|
# the owner's.
|
|
164
166
|
def review_usage(grant, session:, state:, queued:, viewer:)
|
|
165
|
-
ParticipantExposure.usage(grant.exposure, {
|
|
167
|
+
usage = ParticipantExposure.usage(grant.exposure, {
|
|
166
168
|
spent: -> { participant_spent(grant, state) },
|
|
167
169
|
cap: -> { grant.spend_cap },
|
|
168
|
-
queued: -> { queued
|
|
170
|
+
queued: -> { queued&.count { |entry| entry.is_a?(Hash) && viewer.own?(entry["author"]) } },
|
|
169
171
|
queue_limit: -> { grant.queue_limit },
|
|
170
172
|
expires_at: -> { grant.expires_at },
|
|
171
173
|
model: -> { participant_model(session, state, viewer) }
|
|
172
174
|
})
|
|
175
|
+
usage.delete(:queued) unless queued
|
|
176
|
+
usage
|
|
173
177
|
end
|
|
174
178
|
|
|
175
179
|
# What the participant has cost so far, in dollars: the saved
|
|
@@ -244,7 +248,8 @@ module Samagotchi
|
|
|
244
248
|
# The owner's participant view has no composer; a participant's
|
|
245
249
|
# selection quotes with the same presets as the owner's page.
|
|
246
250
|
attrs.merge!(annotate_presets_data) unless principal(req).owner?
|
|
247
|
-
|
|
251
|
+
# A block: a name's \& or \' is text, never a backreference.
|
|
252
|
+
html_response(200, File.read(path).sub("<body>") { "<body #{body_data(attrs)}>" })
|
|
248
253
|
end
|
|
249
254
|
|
|
250
255
|
# A filtered stream's frame filter (App#stream_filter), for the
|
|
@@ -374,14 +374,18 @@ module Samagotchi
|
|
|
374
374
|
/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,
|
|
375
375
|
/\bxox[abprs]-[A-Za-z0-9-]{10,}/,
|
|
376
376
|
/\bchp_[A-Za-z0-9_-]{20,}/,
|
|
377
|
+
# A one-time link code (LinkCodes::CODE_RE): a bearer credential
|
|
378
|
+
# until its grant expires (an owner's, 10 minutes).
|
|
379
|
+
/\bchc_[A-Za-z0-9_-]{43}/,
|
|
377
380
|
/\bAIza[0-9A-Za-z_-]{30,}/,
|
|
378
381
|
/\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}/,
|
|
379
382
|
/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/,
|
|
380
383
|
%r{https://hooks\.slack\.com/services/[A-Za-z0-9/_-]+}
|
|
381
384
|
].freeze
|
|
382
|
-
# The value after an Authorization
|
|
385
|
+
# The value after an Authorization (or a Bridge's secret,
|
|
386
|
+
# BridgeSecret::HEADER) header or a token=/key= pair.
|
|
383
387
|
VALUES = [
|
|
384
|
-
/(\
|
|
388
|
+
/(\b(?:Authorization|X-Chi-Bridge):\s*(?:Bearer\s+|Basic\s+|Token\s+)?)[^\s"'`]+/i,
|
|
385
389
|
/((?<![A-Za-z0-9])[A-Za-z0-9_-]*?(?:token|api[_-]?key|access[_-]?key|secret|password|passwd)["']?\s*[=:]\s*["']?)[^\s"'&`,;}]+/i,
|
|
386
390
|
# A URL's password: scheme://user:PASSWORD@host.
|
|
387
391
|
%r{(\b[a-z][a-z0-9+.-]*://[^/\s:@]+:)[^@\s/]+(?=@)}i
|
|
@@ -389,7 +393,7 @@ module Samagotchi
|
|
|
389
393
|
# A text that ends where one of VALUES' values (or a private key's
|
|
390
394
|
# BEGIN line) would go on: a stream cut there would send the value
|
|
391
395
|
# on its own, unredacted (ParticipantStreamFilter never cuts there).
|
|
392
|
-
OPEN_VALUE = /(?:\
|
|
396
|
+
OPEN_VALUE = /(?:\b(?:Authorization|X-Chi-Bridge):\s*(?:(?:Bearer|Basic|Token)\s*)?|[A-Za-z0-9_-]*?(?:token|api[_-]?key|access[_-]?key|secret|password|passwd)["']?\s*(?:[=:]\s*["']?)?|-----BEGIN [A-Z0-9 ]*)\z/i
|
|
393
397
|
|
|
394
398
|
module_function
|
|
395
399
|
|
|
@@ -33,8 +33,15 @@ module Samagotchi
|
|
|
33
33
|
warning = ReviewStart.share_warning(Session.load(id, state_dir: default_state_dir))
|
|
34
34
|
json_response(200, { participants: with_spend(id, grants), warning: warning,
|
|
35
35
|
identity_header: @public_url&.identity_header })
|
|
36
|
+
rescue Grants::Unwritable => e
|
|
37
|
+
grants_unwritable(e)
|
|
36
38
|
end
|
|
37
39
|
|
|
40
|
+
# 409 grants_unwritable for a store chi won't read or write over
|
|
41
|
+
# (Grants::Corrupt, Grants::Newer), in the store's own words: a
|
|
42
|
+
# refusal the panel shows, not a 500 with a backtrace per refresh.
|
|
43
|
+
def grants_unwritable(error) = error_response(409, "grants_unwritable", error.message)
|
|
44
|
+
|
|
38
45
|
# One session's grants with what each spent and how many turns they
|
|
39
46
|
# ran (its saved analytics: SessionMetrics.saved_by_author), for the
|
|
40
47
|
# owner's participants panel.
|
|
@@ -69,6 +76,8 @@ module Samagotchi
|
|
|
69
76
|
link: link, lan: !@lan.nil? || !@public_url.nil?, qr_svg: QR.svg(link), warning: warning })
|
|
70
77
|
rescue Grants::Invalid => e
|
|
71
78
|
error_response(400, "invalid_participant", e.message)
|
|
79
|
+
rescue Grants::Unwritable => e
|
|
80
|
+
grants_unwritable(e)
|
|
72
81
|
end
|
|
73
82
|
|
|
74
83
|
# GET /api/sessions/:id/apply[?turn=T] (owner): the owner's turn that
|
|
@@ -102,6 +111,8 @@ module Samagotchi
|
|
|
102
111
|
revoked = Participants.revoke(@grants, session_id: id, id: grant_id, by: "owner", state_dir: default_state_dir)
|
|
103
112
|
now = @grants.now
|
|
104
113
|
json_response(200, { revoked: revoked.map { |grant| grant.public_h(now) } })
|
|
114
|
+
rescue Grants::Unwritable => e
|
|
115
|
+
grants_unwritable(e)
|
|
105
116
|
end
|
|
106
117
|
|
|
107
118
|
# POST /api/sessions/:id/participants/:participant/cap {cap}: the
|
|
@@ -119,6 +130,8 @@ module Samagotchi
|
|
|
119
130
|
json_response(200, { participant: grant.public_h(@grants.now) })
|
|
120
131
|
rescue Grants::Invalid => e
|
|
121
132
|
error_response(400, "invalid_participant", e.message)
|
|
133
|
+
rescue Grants::Unwritable => e
|
|
134
|
+
grants_unwritable(e)
|
|
122
135
|
end
|
|
123
136
|
|
|
124
137
|
# The link a participant opens: web.public_url's with a one-time code
|
|
@@ -173,7 +173,7 @@ const participantsControl = createParticipantsControl({
|
|
|
173
173
|
// An older prompt drawn before the list came says "a participant": named now.
|
|
174
174
|
onNames: () => nameUnnamedBadges(document),
|
|
175
175
|
onChange: () => updateInfoBar(),
|
|
176
|
-
toast: (text) => showToast(text),
|
|
176
|
+
toast: (text, action, options) => showToast(text, action, options),
|
|
177
177
|
});
|
|
178
178
|
// The start page's model picker and its LLM context and thinking chips
|
|
179
179
|
// (start_page.js); a fresh chain link's picker too.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* A form's select box (participants_panel.js' Invite, level_chip.js' Level, llm_context_chip.js' Strategy / Apply):
|
|
2
|
+
one shape in every dialog. Each browser draws its own closed box (macOS a pill with a double chevron), so a select
|
|
3
|
+
in a .select-wrap drops it and keeps its dialog's text-field box (the dialog's own `input, select` rule: height,
|
|
4
|
+
radius, border, background, padding, font); the wrapper draws one thin caret at the right. The open list stays the
|
|
5
|
+
OS menu. Both pages link it, after tokens.css and before their own <style>: span.select-wrap>select outweighs a
|
|
6
|
+
dialog's `… select` rule, so its padding shorthand keeps room for the caret. Colours are tokens.css's. */
|
|
7
|
+
.select-wrap{position:relative;display:inline-flex;min-width:0}
|
|
8
|
+
span.select-wrap>select{appearance:none;-webkit-appearance:none;flex:1;min-width:0;padding-right:26px;cursor:pointer}
|
|
9
|
+
.select-wrap::after{content:"";position:absolute;right:11px;top:50%;width:5px;height:5px;border-right:1.5px solid var(--text-muted);border-bottom:1.5px solid var(--text-muted);transform:translateY(-70%) rotate(45deg);pointer-events:none}
|
|
10
|
+
.select-wrap select option{background:var(--bg-raised);color:var(--text)}
|
|
11
|
+
span.select-wrap>select:disabled{opacity:.6;cursor:default}
|
|
12
|
+
.select-wrap:has(select:disabled)::after{opacity:.6}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
<link rel="stylesheet" href="/assets/tokens.css">
|
|
13
13
|
<link rel="stylesheet" href="/assets/annotate_bar.css">
|
|
14
14
|
<link rel="stylesheet" href="/assets/composer.css">
|
|
15
|
+
<link rel="stylesheet" href="/assets/forms.css">
|
|
15
16
|
<style>
|
|
16
17
|
/* Icon masks shared by the phone info bar and the all view's cards (the stroke only shapes the mask; the icon takes currentColor); the image icon is composer.css's. */
|
|
17
18
|
:root{--icon-archive:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='2.75' width='12' height='3.5' rx='1'/%3E%3Cpath d='M3.25 6.25v6a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1v-6M6.5 9h3'/%3E%3C/svg%3E");--icon-unarchive:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='2.75' width='12' height='3.5' rx='1'/%3E%3Cpath d='M3.25 6.25v6a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1v-6M8 11.5V8.25M6.5 9.75 8 8.25l1.5 1.5'/%3E%3C/svg%3E")}
|
|
@@ -425,6 +426,10 @@ button.system-one-wrong:hover:not(:disabled){background:var(--bg-hover);color:va
|
|
|
425
426
|
.question-option:hover{background:var(--bg-hover)}
|
|
426
427
|
.question-option.selected{border-color:var(--ok);color:var(--text)}
|
|
427
428
|
.question-option input{margin:0;accent-color:var(--warn)}
|
|
429
|
+
/* The model's recommended option (a label ending in "(Recommended)"): an accent row and a small tag. */
|
|
430
|
+
.question-option.recommended{border-color:var(--accent-border);background:var(--accent-bg);color:var(--text)}
|
|
431
|
+
.question-option.recommended.selected{border-color:var(--ok)}
|
|
432
|
+
.question-option-tag{margin-left:auto;flex:none;font-size:11px;color:var(--accent);border:1px solid var(--accent-border);border-radius:999px;padding:0 6px}
|
|
428
433
|
.question-freeform{width:100%;box-sizing:border-box;background:var(--bg-inset);border:1px solid var(--border);color:var(--text);padding:8px 10px;border-radius:8px;font-size:13px;margin-bottom:8px}
|
|
429
434
|
.question-error{color:var(--danger);font-size:12px;margin-bottom:8px}
|
|
430
435
|
.question-error.hidden{display:none}
|
|
@@ -1055,12 +1060,9 @@ body.has-session.composer-folded #infoBar{border-top-color:transparent}
|
|
|
1055
1060
|
.llmctx-field>span{flex:0 0 58px;font-size:12px;color:var(--text-muted)}
|
|
1056
1061
|
.llmctx-field select,.llmctx-field input{flex:1;min-width:0;box-sizing:border-box;padding:5px 8px;border-radius:7px;border:1px solid var(--border-strong);background:var(--bg-inset);color:var(--text);font:inherit;font-size:13px;line-height:1.4}
|
|
1057
1062
|
.llmctx-field select:focus,.llmctx-field input:focus{outline:none;border-color:var(--accent-border)}
|
|
1058
|
-
/*
|
|
1059
|
-
.llmctx-field
|
|
1060
|
-
.llmctx-field select option{background:var(--bg-raised);color:var(--text)}
|
|
1063
|
+
/* A select's closed box and caret: forms.css (.select-wrap); here the wrapper takes the field's width. */
|
|
1064
|
+
.llmctx-field>.select-wrap{flex:1}
|
|
1061
1065
|
.llmctx-field input::placeholder{color:var(--text-faint);opacity:1}
|
|
1062
|
-
.llmctx-field:has(select){position:relative}
|
|
1063
|
-
.llmctx-field:has(select)::after{content:"";position:absolute;right:11px;top:50%;width:5px;height:5px;border-right:1.5px solid var(--text-muted);border-bottom:1.5px solid var(--text-muted);transform:translateY(-70%) rotate(45deg);pointer-events:none}
|
|
1064
1066
|
.llmctx-form .llmctx-set{background:var(--accent-bg);color:var(--accent);border-color:var(--accent-border)}
|
|
1065
1067
|
.llmctx-form .llmctx-set:disabled{opacity:.6;cursor:default}
|
|
1066
1068
|
/* Attached context (context_chips.js): a row of its own under the meta; not the composer's #chips/.chip. */
|
|
@@ -69,8 +69,8 @@ export function formTemplate(cfg, summary, { running = false, kind = SESSION, ch
|
|
|
69
69
|
><span class="ctx-pop-kind">${fresh ? NEW_SESSION : "this session"}</span
|
|
70
70
|
><button type="button" class="ctx-pop-close" data-act="close" aria-label="Close">×</button></div
|
|
71
71
|
><div class=${`ctx-pop-meta ${cfg.nowClass}`}>${nowText(now)}</div
|
|
72
|
-
><label class="llmctx-field"><span>Level</span><select name="level">${option(DEFAULT, follow, chosen)}${
|
|
73
|
-
cfg.levels.map((level) => option(level, level, chosen))}</select></label
|
|
72
|
+
><label class="llmctx-field"><span>Level</span><span class="select-wrap"><select name="level">${option(DEFAULT, follow, chosen)}${
|
|
73
|
+
cfg.levels.map((level) => option(level, level, chosen))}</select></span></label
|
|
74
74
|
><div class="ctx-pop-meta">${cfg.when(fresh)}${running ? " A turn is running: it applies after this turn." : ""}</div
|
|
75
75
|
><div class="ctx-pop-actions"><button type="submit" class="llmctx-set">Set</button></div></form>`;
|
|
76
76
|
}
|
|
@@ -179,10 +179,10 @@ export function formTemplate(summary, { running = false, kind = SESSION, choice
|
|
|
179
179
|
><span class="ctx-pop-kind">${fresh ? NEW_SESSION : "this session"}</span
|
|
180
180
|
><button type="button" class="ctx-pop-close" data-act="close" aria-label="Close">×</button></div
|
|
181
181
|
><div class="ctx-pop-meta llmctx-now">${nowText(now)}</div
|
|
182
|
-
><label class="llmctx-field"><span>Strategy</span><select name="strategy" .value=${chosen(own.strategy)}>${
|
|
183
|
-
option(DEFAULT, follow("strategy"))}${strategyOptions(own.strategy).map((s) => option(s.value, s.label))}</select></label
|
|
184
|
-
><label class="llmctx-field"><span>Apply</span><select name="apply" .value=${chosen(own.apply)}>${
|
|
185
|
-
option(DEFAULT, follow("apply"))}${APPLIES.map((a) => option(a, a))}</select></label
|
|
182
|
+
><label class="llmctx-field"><span>Strategy</span><span class="select-wrap"><select name="strategy" .value=${chosen(own.strategy)}>${
|
|
183
|
+
option(DEFAULT, follow("strategy"))}${strategyOptions(own.strategy).map((s) => option(s.value, s.label))}</select></span></label
|
|
184
|
+
><label class="llmctx-field"><span>Apply</span><span class="select-wrap"><select name="apply" .value=${chosen(own.apply)}>${
|
|
185
|
+
option(DEFAULT, follow("apply"))}${APPLIES.map((a) => option(a, a))}</select></span></label
|
|
186
186
|
><label class="llmctx-field"><span>Budget</span><input name="budget" type="text" inputmode="numeric" autocomplete="off"
|
|
187
187
|
placeholder="follow the model (64000, 64k or off)" .value=${own.budget}></label
|
|
188
188
|
><div class="ctx-pop-error llmctx-error" ?hidden=${!error}>${error || ""}</div
|