toolroll 0.9.115 → 0.9.116
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.
- package/CHANGELOG.md +19 -0
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +12 -12
- package/dist/contracts/console-api.js +1 -1
- package/dist/contracts/engine-api.js +13 -0
- package/dist/flexible-authority-end.js +2 -0
- package/dist/flexible-interactive-schema.js +133 -0
- package/dist/flexible-interactive.js +94 -0
- package/dist/flexible-session.js +26 -2
- package/dist/flexible-sign-in.js +10 -0
- package/dist/flexible-start.js +17 -2
- package/dist/flexible.js +13 -0
- package/dist/lead-tools.js +1 -0
- package/dist/server/console.css +9 -9
- package/dist/server/flows.js +4 -3
- package/dist/spend-report.js +2 -2
- package/dist/spend.js +3 -3
- package/dist/store.js +105 -7
- package/dist/subagent-admin.js +23 -10
- package/dist/subagent-backup-schema.js +36 -0
- package/dist/subagent-backup.js +92 -0
- package/dist/subagent-week.js +2 -2
- package/dist/subagent-work.js +70 -47
- package/dist/subagents-ui.js +6 -2
- package/dist/subagents.js +5 -2
- package/dist/subscription-chat.js +4 -0
- package/dist/terminal-safety.js +114 -0
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/package.json +2 -2
|
@@ -69,7 +69,7 @@ export const CONSOLE_FORMS = {
|
|
|
69
69
|
skillsRevise: formContract("POST /settings/skills/revise", ["run", "repo", "feedback", "nonce"]),
|
|
70
70
|
skillsChange: formContract("POST /settings/skills/import, /settings/skills/change", ["repo", "identity", "revision", "method", "content", "files", "url", "action", "sha", "sample", "nonce", "restore"]),
|
|
71
71
|
kit: formContract("POST /kits/<kit>/<act>", ["repo", "password"]),
|
|
72
|
-
subagents: formContract("POST /settings/lead/subagents/new, /settings/lead/subagents/<id>/<part>, /settings/lead/subagents/questions/<id>/answer", ["choice", "text", "repo", "template", "name", "soul", "op", "id", "schedule", "tool", "state", "note", "model", "dailyTurns", "manager", "password"], { prefixes: ["use.", "undo.", "field.", "over."] }),
|
|
72
|
+
subagents: formContract("POST /settings/lead/subagents/new, /settings/lead/subagents/<id>/<part>, /settings/lead/subagents/questions/<id>/answer", ["choice", "text", "repo", "template", "name", "soul", "op", "id", "schedule", "tool", "state", "note", "model", "dailyTurns", "manager", "password", "backupPresent", "codexBackupModel"], { prefixes: ["use.", "undo.", "field.", "over."] }),
|
|
73
73
|
galleryUse: formContract("POST /flows/new/<template>", ["repo", "send-result", "name", "intent", "previewed", "password"], { dynamic: true }),
|
|
74
74
|
flows: formContract("POST /flows/new, /flows/example, /flows/import, /flows/<id>/<act>, /flows/<id>/cards/<card>/<act>, /flows/<id>/triggers/<trigger>/<act>", ["repo", "document", "url", "confirm", "previewed", "template", "name", "answers", "password", "secret", "sender", "project", "team", "trigger", "approve", "remove", "about", "body", "timeoutMinutes", "language", "file", "address", "key", "definition", "owner", "revision", "value", "title", "description", "stage", "decision", "note", "draft", "choice", "entry", "label", "watching", "days", "budget", "runs", "include", "schedules", "digest", "version"], { prefixes: ["param."] }),
|
|
75
75
|
spendBudget: formContract("POST /spend/budget", ["password", "target", "action", "usd", "stop"]),
|
|
@@ -35,6 +35,17 @@ const threadQuestionSchema = z.object({
|
|
|
35
35
|
answerable: z.boolean(),
|
|
36
36
|
parts: z.array(z.object({ id: z.string(), question: z.string(), options: z.array(z.string()) })),
|
|
37
37
|
});
|
|
38
|
+
export const threadTerminalSchema = z.strictObject({
|
|
39
|
+
available: z.boolean(),
|
|
40
|
+
launch: hex32,
|
|
41
|
+
generation: z.number().int().positive(),
|
|
42
|
+
lifecycle: z.enum(["starting", "live", "stopping", "exited", "unresolved"]),
|
|
43
|
+
viewing: z.enum(["detached", "viewing"]),
|
|
44
|
+
control: z.enum(["none", "self", "other"]),
|
|
45
|
+
protocol: z.literal(1),
|
|
46
|
+
cols: z.number().int().min(2).max(500),
|
|
47
|
+
rows: z.number().int().min(2).max(500),
|
|
48
|
+
});
|
|
38
49
|
export const threadFactsSchema = z.object({
|
|
39
50
|
version: z.string().regex(/^[0-9a-f]{16}$/),
|
|
40
51
|
title: z.string(),
|
|
@@ -45,6 +56,8 @@ export const threadFactsSchema = z.object({
|
|
|
45
56
|
endWords: z.string().optional(),
|
|
46
57
|
billing: z.enum(["subscription", "api-key"]).optional() }).nullable(),
|
|
47
58
|
questions: z.array(threadQuestionSchema),
|
|
59
|
+
runtime: z.enum(["stream-json", "interactive"]).optional(),
|
|
60
|
+
terminal: threadTerminalSchema.optional(),
|
|
48
61
|
ended: z.object({ words: z.string(), stopPending: z.boolean() }).optional(),
|
|
49
62
|
ship: z.object({ seq: z.number().int(), state: z.string(), words: z.string() }).optional(),
|
|
50
63
|
});
|
|
@@ -60,6 +60,8 @@ export function endThreadAuthorityFor(store, input) {
|
|
|
60
60
|
.get(input.person, input.person) !== undefined);
|
|
61
61
|
if (hadSignIn)
|
|
62
62
|
handle.prepare("INSERT INTO flexible_sign_in_epoch (person, epoch) VALUES (?, 1) ON CONFLICT (person) DO UPDATE SET epoch = epoch + 1").run(input.person);
|
|
63
|
+
handle.prepare("UPDATE flexible_interactive_session SET state = 'ended', ended_at = ?, end_reason = ? WHERE owner = ? AND state <> 'ended'")
|
|
64
|
+
.run(input.at, input.cause, input.person);
|
|
63
65
|
let interrupted = 0, withdrawn = 0;
|
|
64
66
|
const cut = [];
|
|
65
67
|
for (const turn of handle.prepare("SELECT * FROM thread_turn WHERE owner = ? AND status IN ('admitted', 'running') ORDER BY admitted_at, id").all(input.person)) {
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export const V175_SCHEMA = `
|
|
2
|
+
CREATE TABLE IF NOT EXISTS flexible_thread_runtime (
|
|
3
|
+
thread TEXT PRIMARY KEY,
|
|
4
|
+
runtime TEXT NOT NULL CHECK (runtime IN ('stream-json', 'interactive')),
|
|
5
|
+
chosen INTEGER NOT NULL DEFAULT 0 CHECK (chosen IN (0, 1))
|
|
6
|
+
);
|
|
7
|
+
CREATE TRIGGER IF NOT EXISTS flexible_thread_runtime_creation BEFORE INSERT ON flexible_thread_runtime
|
|
8
|
+
WHEN NOT EXISTS (SELECT 1 FROM flexible_thread WHERE id = NEW.thread)
|
|
9
|
+
OR (NEW.runtime = 'interactive' AND NOT EXISTS (SELECT 1 FROM flexible_thread WHERE id = NEW.thread AND state = 'preparing'))
|
|
10
|
+
BEGIN
|
|
11
|
+
SELECT RAISE(ABORT, 'runtime is chosen at thread creation');
|
|
12
|
+
END;
|
|
13
|
+
CREATE TRIGGER IF NOT EXISTS flexible_thread_runtime_written_once BEFORE UPDATE ON flexible_thread_runtime
|
|
14
|
+
WHEN OLD.chosen = 1 OR NEW.thread IS NOT OLD.thread OR NEW.chosen <> 1
|
|
15
|
+
OR NOT EXISTS (SELECT 1 FROM flexible_thread WHERE id = OLD.thread AND state = 'preparing')
|
|
16
|
+
BEGIN
|
|
17
|
+
SELECT RAISE(ABORT, 'runtime is immutable');
|
|
18
|
+
END;
|
|
19
|
+
CREATE TRIGGER IF NOT EXISTS flexible_thread_runtime_kept BEFORE DELETE ON flexible_thread_runtime
|
|
20
|
+
BEGIN
|
|
21
|
+
SELECT RAISE(ABORT, 'runtime is kept');
|
|
22
|
+
END;
|
|
23
|
+
CREATE TRIGGER IF NOT EXISTS flexible_thread_runtime_default AFTER INSERT ON flexible_thread
|
|
24
|
+
BEGIN
|
|
25
|
+
INSERT INTO flexible_thread_runtime (thread, runtime) VALUES (NEW.id, 'stream-json');
|
|
26
|
+
END;
|
|
27
|
+
CREATE TABLE IF NOT EXISTS flexible_interactive_session (
|
|
28
|
+
id TEXT PRIMARY KEY CHECK (length(id) = 32 AND id NOT GLOB '*[^0-9a-f]*'),
|
|
29
|
+
thread TEXT NOT NULL CHECK (length(thread) = 32 AND thread NOT GLOB '*[^0-9a-f]*'),
|
|
30
|
+
launch TEXT NOT NULL UNIQUE CHECK (length(launch) = 32 AND launch NOT GLOB '*[^0-9a-f]*'),
|
|
31
|
+
holder TEXT NOT NULL CHECK (length(holder) BETWEEN 1 AND 128),
|
|
32
|
+
owner TEXT NOT NULL CHECK (length(owner) BETWEEN 1 AND 200),
|
|
33
|
+
account_generation INTEGER NOT NULL CHECK (account_generation >= 0),
|
|
34
|
+
runtime TEXT NOT NULL CHECK (runtime = 'interactive'),
|
|
35
|
+
provider TEXT NOT NULL CHECK (provider = 'claude'),
|
|
36
|
+
billing TEXT NOT NULL CHECK (billing = 'subscription'),
|
|
37
|
+
terms_id INTEGER NOT NULL CHECK (terms_id > 0),
|
|
38
|
+
terms_digest TEXT NOT NULL CHECK (length(terms_digest) = 32 AND terms_digest NOT GLOB '*[^0-9a-f]*'),
|
|
39
|
+
start_key TEXT NOT NULL CHECK (length(start_key) = 32 AND start_key NOT GLOB '*[^0-9a-f]*'),
|
|
40
|
+
message TEXT NOT NULL,
|
|
41
|
+
level TEXT NOT NULL CHECK (level = 'full'),
|
|
42
|
+
model TEXT NOT NULL CHECK (length(model) BETWEEN 1 AND 200),
|
|
43
|
+
helper_models TEXT NOT NULL CHECK (json_valid(helper_models) AND json_type(helper_models) = 'array'),
|
|
44
|
+
fence_digest TEXT NOT NULL CHECK (length(fence_digest) = 32 AND fence_digest NOT GLOB '*[^0-9a-f]*'),
|
|
45
|
+
network_digest TEXT NOT NULL CHECK (length(network_digest) = 32 AND network_digest NOT GLOB '*[^0-9a-f]*'),
|
|
46
|
+
sign_in_epoch INTEGER NOT NULL CHECK (sign_in_epoch >= 0),
|
|
47
|
+
state TEXT NOT NULL CHECK (state IN ('prepared', 'active', 'ended')),
|
|
48
|
+
prepared_at TEXT NOT NULL,
|
|
49
|
+
activated_at TEXT,
|
|
50
|
+
ended_at TEXT,
|
|
51
|
+
end_reason TEXT CHECK (end_reason IS NULL OR length(end_reason) BETWEEN 1 AND 200),
|
|
52
|
+
CHECK ((state = 'ended') = (ended_at IS NOT NULL)),
|
|
53
|
+
CHECK ((state = 'ended') = (end_reason IS NOT NULL)),
|
|
54
|
+
CHECK (state <> 'active' OR activated_at IS NOT NULL),
|
|
55
|
+
CHECK (state <> 'prepared' OR activated_at IS NULL)
|
|
56
|
+
);
|
|
57
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_session_creation BEFORE INSERT ON flexible_interactive_session
|
|
58
|
+
WHEN NEW.state <> 'prepared' OR NEW.activated_at IS NOT NULL
|
|
59
|
+
OR NOT EXISTS (SELECT 1 FROM flexible_thread_launch l JOIN flexible_thread t ON t.id = l.thread
|
|
60
|
+
JOIN flexible_thread_runtime r ON r.thread = t.id
|
|
61
|
+
WHERE l.id = NEW.launch AND l.thread = NEW.thread AND l.holder = NEW.holder AND l.turn IS NULL
|
|
62
|
+
AND l.provider = NEW.provider AND l.level = NEW.level AND l.fence_digest = NEW.fence_digest AND l.state = 'spawning'
|
|
63
|
+
AND t.created_by = NEW.owner AND t.state = 'ready' AND r.runtime = 'interactive')
|
|
64
|
+
BEGIN
|
|
65
|
+
SELECT RAISE(ABORT, 'interactive authority begins prepared');
|
|
66
|
+
END;
|
|
67
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_session_written_once BEFORE UPDATE ON flexible_interactive_session
|
|
68
|
+
WHEN OLD.state = 'ended' OR NEW.id IS NOT OLD.id OR NEW.thread IS NOT OLD.thread OR NEW.launch IS NOT OLD.launch
|
|
69
|
+
OR NEW.holder IS NOT OLD.holder OR NEW.owner IS NOT OLD.owner OR NEW.account_generation IS NOT OLD.account_generation
|
|
70
|
+
OR NEW.runtime IS NOT OLD.runtime OR NEW.provider IS NOT OLD.provider OR NEW.billing IS NOT OLD.billing
|
|
71
|
+
OR NEW.terms_id IS NOT OLD.terms_id OR NEW.terms_digest IS NOT OLD.terms_digest OR NEW.start_key IS NOT OLD.start_key
|
|
72
|
+
OR NEW.message IS NOT OLD.message OR NEW.level IS NOT OLD.level OR NEW.model IS NOT OLD.model OR NEW.helper_models IS NOT OLD.helper_models
|
|
73
|
+
OR NEW.fence_digest IS NOT OLD.fence_digest OR NEW.network_digest IS NOT OLD.network_digest OR NEW.sign_in_epoch IS NOT OLD.sign_in_epoch
|
|
74
|
+
OR NEW.prepared_at IS NOT OLD.prepared_at OR (OLD.activated_at IS NOT NULL AND NEW.activated_at IS NOT OLD.activated_at)
|
|
75
|
+
OR (OLD.state = 'active' AND NEW.state <> 'ended')
|
|
76
|
+
OR (OLD.state = 'prepared' AND NEW.state <> 'active' AND NEW.activated_at IS NOT OLD.activated_at)
|
|
77
|
+
BEGIN
|
|
78
|
+
SELECT RAISE(ABORT, 'interactive authority is written once and ends once');
|
|
79
|
+
END;
|
|
80
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_session_kept BEFORE DELETE ON flexible_interactive_session
|
|
81
|
+
BEGIN
|
|
82
|
+
SELECT RAISE(ABORT, 'interactive authority is kept');
|
|
83
|
+
END;
|
|
84
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_no_turn BEFORE INSERT ON thread_turn
|
|
85
|
+
WHEN EXISTS (SELECT 1 FROM flexible_thread_runtime WHERE thread = NEW.thread AND runtime = 'interactive')
|
|
86
|
+
BEGIN
|
|
87
|
+
SELECT RAISE(ABORT, 'interactive sessions do not admit structured turns');
|
|
88
|
+
END;
|
|
89
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_stop AFTER INSERT ON flexible_stop_request
|
|
90
|
+
BEGIN
|
|
91
|
+
UPDATE flexible_interactive_session SET state = 'ended', ended_at = NEW.requested_at, end_reason = NEW.reason WHERE launch = NEW.launch AND state <> 'ended';
|
|
92
|
+
END;
|
|
93
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_launch_end AFTER UPDATE OF state ON flexible_thread_launch
|
|
94
|
+
WHEN NEW.state IN ('stopping', 'unresolved', 'exited')
|
|
95
|
+
BEGIN
|
|
96
|
+
UPDATE flexible_interactive_session SET state = 'ended', ended_at = COALESCE(NEW.ended_at, strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
97
|
+
end_reason = COALESCE(NEW.stop_reason, NEW.state) WHERE launch = NEW.id AND state <> 'ended';
|
|
98
|
+
END;
|
|
99
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_threads_off AFTER UPDATE OF enabled ON flexible_setting
|
|
100
|
+
WHEN NEW.enabled = 0
|
|
101
|
+
BEGIN
|
|
102
|
+
UPDATE flexible_interactive_session SET state = 'ended', ended_at = NEW.updated_at, end_reason = 'threads-off' WHERE state <> 'ended';
|
|
103
|
+
END;
|
|
104
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_level_insert AFTER INSERT ON flexible_thread_level
|
|
105
|
+
WHEN NEW.level <> 'full'
|
|
106
|
+
BEGIN
|
|
107
|
+
UPDATE flexible_interactive_session SET state = 'ended', ended_at = NEW.set_at, end_reason = 'level-lowered' WHERE thread = NEW.thread AND state <> 'ended';
|
|
108
|
+
END;
|
|
109
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_level_update AFTER UPDATE OF level ON flexible_thread_level
|
|
110
|
+
WHEN NEW.level <> 'full'
|
|
111
|
+
BEGIN
|
|
112
|
+
UPDATE flexible_interactive_session SET state = 'ended', ended_at = NEW.set_at, end_reason = 'level-lowered' WHERE thread = NEW.thread AND state <> 'ended';
|
|
113
|
+
END;
|
|
114
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_network_insert AFTER INSERT ON project_network
|
|
115
|
+
BEGIN
|
|
116
|
+
UPDATE flexible_interactive_session SET state = 'ended', ended_at = NEW.updated_at, end_reason = 'network-changed'
|
|
117
|
+
WHERE thread IN (SELECT id FROM flexible_thread WHERE repo = NEW.repo) AND state <> 'ended';
|
|
118
|
+
END;
|
|
119
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_network_update AFTER UPDATE OF network_json ON project_network
|
|
120
|
+
WHEN NEW.network_json IS NOT OLD.network_json
|
|
121
|
+
BEGIN
|
|
122
|
+
UPDATE flexible_interactive_session SET state = 'ended', ended_at = NEW.updated_at, end_reason = 'network-changed'
|
|
123
|
+
WHERE thread IN (SELECT id FROM flexible_thread WHERE repo = NEW.repo) AND state <> 'ended';
|
|
124
|
+
END;
|
|
125
|
+
CREATE TRIGGER IF NOT EXISTS flexible_interactive_terms_end AFTER UPDATE OF ended_at ON flexible_terms
|
|
126
|
+
WHEN NEW.ended_at IS NOT NULL
|
|
127
|
+
BEGIN
|
|
128
|
+
UPDATE flexible_interactive_session SET state = 'ended', ended_at = NEW.ended_at, end_reason = 'terms-ended' WHERE terms_id = NEW.id AND state <> 'ended';
|
|
129
|
+
END;
|
|
130
|
+
`;
|
|
131
|
+
export const V175_STEPS = Object.freeze(['flexible-interactive']);
|
|
132
|
+
export const V175_TABLES = Object.freeze(['flexible_thread_runtime', 'flexible_interactive_session']);
|
|
133
|
+
export const V175_OBJECTS = Object.freeze([...V175_SCHEMA.matchAll(/CREATE (TABLE|TRIGGER|INDEX) IF NOT EXISTS (\w+)/g)].map(one => [one[1].toLowerCase(), one[2]]));
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { flexibleDelegationAtUse, flexibleRuntime } from "./flexible.js";
|
|
3
|
+
import { flexibleStartCard } from "./flexible-start.js";
|
|
4
|
+
import { threadLevelAllowed } from "./flexible-levels.js";
|
|
5
|
+
import { flexibleLaunch, reserveLaunchOpen } from "./flexible-launch.js";
|
|
6
|
+
import { signInForInteractiveStands, signInEpochOf } from "./flexible-sign-in.js";
|
|
7
|
+
export function interactiveSession(store, id) {
|
|
8
|
+
return store.handle.prepare("SELECT * FROM flexible_interactive_session WHERE id = ?").get(id) ?? null;
|
|
9
|
+
}
|
|
10
|
+
export function prepareInteractiveSession(store, input) {
|
|
11
|
+
return store.transact(() => {
|
|
12
|
+
const thread = store.handle.prepare("SELECT * FROM flexible_thread WHERE id = ?").get(input.thread);
|
|
13
|
+
const launch = flexibleLaunch(store, input.launch);
|
|
14
|
+
if (thread === undefined || thread["state"] !== "ready" || thread["created_by"] !== input.by.name
|
|
15
|
+
|| flexibleRuntime(store, input.thread) !== "interactive" || launch === null || launch.thread !== input.thread || launch.holder !== input.holder
|
|
16
|
+
|| launch.provider !== "claude" || launch.level !== "full" || launch.turn !== null || launch.state !== "spawning")
|
|
17
|
+
return null;
|
|
18
|
+
if (store.handle.prepare("SELECT 1 FROM flexible_thread_meta WHERE thread = ? AND ended_at IS NOT NULL").get(input.thread)
|
|
19
|
+
|| store.handle.prepare("SELECT 1 FROM flexible_interactive_session WHERE launch = ?").get(input.launch))
|
|
20
|
+
return null;
|
|
21
|
+
const made = flexibleStartCard(store, { repo: String(thread["repo"]), by: input.by, runtime: "interactive", model: input.model, helperModels: input.helperModels, message: input.message });
|
|
22
|
+
if (!made.ok || made.card.summary.key !== input.startKey)
|
|
23
|
+
return null;
|
|
24
|
+
const approved = flexibleDelegationAtUse(store, { repo: String(thread["repo"]), starter: input.by, digest: made.card.digest, level: "full", freshProof: false });
|
|
25
|
+
if (!approved.ok || !interactiveLaunchRoom(store, input.thread, String(thread["repo"]), approved.terms.caps.liveThreads))
|
|
26
|
+
return null;
|
|
27
|
+
const id = randomBytes(16).toString("hex");
|
|
28
|
+
store.handle.prepare(`INSERT INTO flexible_interactive_session
|
|
29
|
+
(id, thread, launch, holder, owner, account_generation, runtime, provider, billing, terms_id, terms_digest, start_key, message, level, model,
|
|
30
|
+
helper_models, fence_digest, network_digest, sign_in_epoch, state, prepared_at)
|
|
31
|
+
VALUES (?, ?, ?, ?, ?, ?, 'interactive', 'claude', 'subscription', ?, ?, ?, ?, 'full', ?, ?, ?, ?, ?, 'prepared', ?)`)
|
|
32
|
+
.run(id, input.thread, input.launch, input.holder, input.by.name, input.by.generation, approved.termsId, approved.digest, input.startKey, input.message, made.card.model, JSON.stringify(made.card.helperModels), launch.fenceDigest, made.card.network, signInEpochOf(store, input.by.name), input.now.toISOString());
|
|
33
|
+
return id;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function activateInteractiveSession(store, input) {
|
|
37
|
+
return store.transact(() => {
|
|
38
|
+
const session = interactiveSession(store, input.session);
|
|
39
|
+
if (session === null || session["state"] !== "prepared" || session["holder"] !== input.holder)
|
|
40
|
+
return false;
|
|
41
|
+
const threadId = String(session["thread"]), owner = String(session["owner"]);
|
|
42
|
+
const thread = store.handle.prepare("SELECT * FROM flexible_thread WHERE id = ?").get(threadId);
|
|
43
|
+
const launch = flexibleLaunch(store, String(session["launch"]));
|
|
44
|
+
if (thread === undefined || thread["state"] !== "ready" || thread["created_by"] !== owner || flexibleRuntime(store, threadId) !== "interactive"
|
|
45
|
+
|| launch === null || launch.thread !== threadId || launch.holder !== input.holder || launch.state !== "live" || launch.leaderPid === null || launch.leaderStart === null
|
|
46
|
+
|| launch.turn !== null || launch.provider !== "claude" || launch.level !== "full" || launch.fenceDigest !== session["fence_digest"]
|
|
47
|
+
|| thread["live_pid"] !== launch.leaderPid || signInEpochOf(store, owner) !== session["sign_in_epoch"]
|
|
48
|
+
|| store.handle.prepare("SELECT 1 FROM flexible_stop_request WHERE launch = ?").get(launch.id)
|
|
49
|
+
|| store.handle.prepare("SELECT 1 FROM flexible_thread_meta WHERE thread = ? AND ended_at IS NOT NULL").get(threadId))
|
|
50
|
+
return false;
|
|
51
|
+
const by = { name: owner, generation: Number(session["account_generation"]) };
|
|
52
|
+
if (!signInForInteractiveStands(store, input.session))
|
|
53
|
+
return false;
|
|
54
|
+
const approved = flexibleDelegationAtUse(store, { repo: String(thread["repo"]), starter: by, digest: String(session["terms_digest"]), level: "full", freshProof: false });
|
|
55
|
+
if (!approved.ok || approved.termsId !== session["terms_id"] || !interactiveLaunchRoom(store, threadId, String(thread["repo"]), approved.terms.caps.liveThreads))
|
|
56
|
+
return false;
|
|
57
|
+
const level = store.handle.prepare("SELECT level FROM flexible_thread_level WHERE thread = ?").get(threadId);
|
|
58
|
+
if (level !== undefined && level["level"] !== "full")
|
|
59
|
+
return false;
|
|
60
|
+
const made = flexibleStartCard(store, { repo: String(thread["repo"]), by, runtime: "interactive", model: String(session["model"]),
|
|
61
|
+
helperModels: JSON.parse(String(session["helper_models"])), message: String(session["message"]) });
|
|
62
|
+
if (!made.ok || made.card.summary.key !== session["start_key"] || made.card.network !== session["network_digest"])
|
|
63
|
+
return false;
|
|
64
|
+
const why = reserveLaunchOpen(store, { launch: launch.id, thread: threadId, turn: null, clock: () => input.now, check: input.authorizeLaunch });
|
|
65
|
+
if (why !== null)
|
|
66
|
+
return false;
|
|
67
|
+
return Number(store.handle.prepare("UPDATE flexible_interactive_session SET state = 'active', activated_at = ? WHERE id = ? AND state = 'prepared'")
|
|
68
|
+
.run(input.now.toISOString(), input.session).changes) === 1;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export function endInteractiveSession(store, input) {
|
|
72
|
+
return store.transact(() => {
|
|
73
|
+
const session = interactiveSession(store, input.session);
|
|
74
|
+
if (session === null || session["state"] === "ended")
|
|
75
|
+
return false;
|
|
76
|
+
store.handle.prepare("UPDATE flexible_interactive_session SET state = 'ended', ended_at = ?, end_reason = ? WHERE id = ? AND state <> 'ended'")
|
|
77
|
+
.run(input.now.toISOString(), input.reason, input.session);
|
|
78
|
+
store.handle.prepare("INSERT INTO flexible_stop_request (launch, thread, reason, requested_at) VALUES (?, ?, ?, ?) ON CONFLICT (launch) DO NOTHING")
|
|
79
|
+
.run(session["launch"], session["thread"], input.reason, input.now.toISOString());
|
|
80
|
+
return true;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function interactiveLaunchRoom(store, thread, repo, projectLimit) {
|
|
84
|
+
if (!threadLevelAllowed(store.orgPolicy(), "claude", "full").ok)
|
|
85
|
+
return false;
|
|
86
|
+
const working = store.handle.prepare(`SELECT DISTINCT t.id, t.repo FROM flexible_thread t WHERE t.id <> ? AND (
|
|
87
|
+
EXISTS (SELECT 1 FROM flexible_thread_launch l WHERE l.thread = t.id AND l.state <> 'exited') OR
|
|
88
|
+
EXISTS (SELECT 1 FROM thread_turn x WHERE x.thread = t.id AND x.status IN ('admitted', 'running')))`)
|
|
89
|
+
.all(thread);
|
|
90
|
+
if (working.filter(one => one["repo"] === repo).length >= projectLimit)
|
|
91
|
+
return false;
|
|
92
|
+
const installation = store.handle.prepare("SELECT live_threads FROM flexible_installation_caps WHERE id = 1").get()?.["live_threads"];
|
|
93
|
+
return installation === null || installation === undefined || working.length < Number(installation);
|
|
94
|
+
}
|
package/dist/flexible-session.js
CHANGED
|
@@ -1142,6 +1142,11 @@ function endWordsOf(store, turn, status) {
|
|
|
1142
1142
|
if (status !== "interrupted" && status !== "unknown" && status !== "withdrawn")
|
|
1143
1143
|
return {};
|
|
1144
1144
|
const detail = store.handle.prepare("SELECT end_detail FROM thread_turn WHERE id = ?").get(turn)?.["end_detail"];
|
|
1145
|
+
if (status === "unknown" && (detail === null || detail === undefined || detail === "The agent stopped with an error.")) {
|
|
1146
|
+
const connection = relayFailureWords(store, turn);
|
|
1147
|
+
if (connection !== null)
|
|
1148
|
+
return { endWords: connection };
|
|
1149
|
+
}
|
|
1145
1150
|
if (typeof detail !== "string" || detail.trim() === "")
|
|
1146
1151
|
return {};
|
|
1147
1152
|
const words = cleanLiveText(detail).trim().slice(0, 500);
|
|
@@ -1153,12 +1158,31 @@ function withoutRefusedLines(store, turn, records) {
|
|
|
1153
1158
|
if (turn === null || !records.some(one => one.k === "say" && one.t.some(line => AGENT_API_ERROR.test(line))))
|
|
1154
1159
|
return records;
|
|
1155
1160
|
const row = flexibleTurn(store, turn);
|
|
1156
|
-
if (row
|
|
1161
|
+
if (row === null)
|
|
1162
|
+
return records;
|
|
1163
|
+
const words = row.status === "interrupted" ? endWordsOf(store, turn, row.status).endWords : relayFailureWords(store, turn) ?? undefined;
|
|
1164
|
+
if (row.status !== "interrupted" && words === undefined)
|
|
1157
1165
|
return records;
|
|
1158
|
-
const words = endWordsOf(store, turn, row.status).endWords;
|
|
1159
1166
|
const explained = words === undefined ? FLEXIBLE_REFUSED_LINE_WORDS : `Toolroll: ${words}`;
|
|
1160
1167
|
return records.map(one => one.k !== "say" || !one.t.some(line => AGENT_API_ERROR.test(line)) ? one : { ...one, t: [explained] });
|
|
1161
1168
|
}
|
|
1169
|
+
function relayFailureWords(store, turn) {
|
|
1170
|
+
const call = store.handle.prepare("SELECT status, http_status FROM thread_relay_call WHERE turn = ? AND route = 'messages' ORDER BY id DESC LIMIT 1").get(turn);
|
|
1171
|
+
if (call === undefined)
|
|
1172
|
+
return null;
|
|
1173
|
+
const next = "Review changes, then reply to retry.";
|
|
1174
|
+
if (call["status"] === "incomplete")
|
|
1175
|
+
return `Model connection lost. ${next}`;
|
|
1176
|
+
if (call["status"] !== "upstream-error")
|
|
1177
|
+
return null;
|
|
1178
|
+
if (call["http_status"] === null)
|
|
1179
|
+
return `Can't reach the model. ${next}`;
|
|
1180
|
+
if (call["http_status"] === 429)
|
|
1181
|
+
return "Too many model requests. Review changes, then reply later.";
|
|
1182
|
+
if (Number(call["http_status"]) >= 500)
|
|
1183
|
+
return `The model service failed. ${next}`;
|
|
1184
|
+
return null;
|
|
1185
|
+
}
|
|
1162
1186
|
function recordedTitle(store, thread) {
|
|
1163
1187
|
const title = store.handle.prepare("SELECT title FROM flexible_thread_meta WHERE thread = ?").get(thread)?.["title"];
|
|
1164
1188
|
return typeof title === "string" && title !== "" ? title : null;
|
package/dist/flexible-sign-in.js
CHANGED
|
@@ -473,3 +473,13 @@ export function signInEpochOf(store, person) {
|
|
|
473
473
|
function raiseSignInEpoch(store, person) {
|
|
474
474
|
store.handle.prepare("INSERT INTO flexible_sign_in_epoch (person, epoch) VALUES (?, 1) ON CONFLICT (person) DO UPDATE SET epoch = epoch + 1").run(person);
|
|
475
475
|
}
|
|
476
|
+
export function signInForInteractiveStands(store, sessionId) {
|
|
477
|
+
const session = store.handle.prepare("SELECT * FROM flexible_interactive_session WHERE id = ? AND state IN ('prepared', 'active')").get(sessionId);
|
|
478
|
+
if (session === undefined || session["provider"] !== "claude" || session["billing"] !== "subscription")
|
|
479
|
+
return false;
|
|
480
|
+
const thread = store.handle.prepare("SELECT created_by FROM flexible_thread WHERE id = ?").get(session["thread"]);
|
|
481
|
+
if (thread === undefined || thread["created_by"] !== session["owner"] || signInEpochOf(store, String(session["owner"])) !== session["sign_in_epoch"])
|
|
482
|
+
return false;
|
|
483
|
+
const billing = flexibleSignInBilling(store, { name: String(session["owner"]), generation: Number(session["account_generation"]) });
|
|
484
|
+
return billing.ok && billing.billing === "subscription";
|
|
485
|
+
}
|
package/dist/flexible-start.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { flexibleAvailable } from "./flexible-available.js";
|
|
3
3
|
import { FLEXIBLE_LAPSE_WORDS, FLEXIBLE_LEVEL_WORDS, FLEXIBLE_UNAVAILABLE, flexibleStanding, FULL_ACCESS_WORDS, OPEN_NETWORK_WORDS } from "./flexible.js";
|
|
4
4
|
import { flexibleNetworkDigest, flexibleThreadNetwork } from "./flexible-launcher.js";
|
|
5
|
+
import { FLEXIBLE_RELAY_UPSTREAMS } from "./flexible-relay-upstreams.js";
|
|
5
6
|
import { flexibleSignInBilling, flexibleSignInStatus } from "./flexible-sign-in.js";
|
|
6
7
|
import { networkWords } from "./egress.js";
|
|
7
8
|
import { agentModelName } from "./model-names.js";
|
|
@@ -26,6 +27,12 @@ export const FLEXIBLE_UNKNOWN_COST_WORDS = "If Toolroll can't measure what a tur
|
|
|
26
27
|
export function flexibleStartCard(store, input) {
|
|
27
28
|
if (!flexibleAvailable(store))
|
|
28
29
|
return refuse("not-available");
|
|
30
|
+
const helperModels = [...new Set(input.helperModels ?? [])].sort();
|
|
31
|
+
if (helperModels.some(model => !FLEXIBLE_RELAY_UPSTREAMS.claude.helperModels.test(model)))
|
|
32
|
+
return refuse("invalid-request");
|
|
33
|
+
const runtime = input.runtime ?? "stream-json";
|
|
34
|
+
if (runtime !== "stream-json" && runtime !== "interactive")
|
|
35
|
+
return refuse("invalid-request");
|
|
29
36
|
const model = input.model === null || input.model === "" ? FLEXIBLE_DEFAULT_MODEL : input.model;
|
|
30
37
|
if (typeof input.repo !== "string" || input.repo === "" || typeof model !== "string" || !RELAY_MODEL.test(model) || typeof input.message !== "string"
|
|
31
38
|
|| typeof input.by?.name !== "string" || !Number.isSafeInteger(input.by.generation))
|
|
@@ -47,6 +54,8 @@ export function flexibleStartCard(store, input) {
|
|
|
47
54
|
if (!credential.ok)
|
|
48
55
|
return refuse(credential.reason);
|
|
49
56
|
const billing = credential.billing;
|
|
57
|
+
if (runtime === "interactive" && billing !== "subscription")
|
|
58
|
+
return refuse("invalid-request");
|
|
50
59
|
const signedIn = flexibleSignInStatus(store, input.by.name);
|
|
51
60
|
const savedOn = signedIn.state === "none" ? null : signedIn.savedAt.slice(0, 10);
|
|
52
61
|
const open = network.mode === "open";
|
|
@@ -69,6 +78,12 @@ export function flexibleStartCard(store, input) {
|
|
|
69
78
|
{ label: "Ship", words: FLEXIBLE_SHIP_WORDS, fields: ["flexible.ship"] },
|
|
70
79
|
{ label: "Terms", words: `this project's Flexible terms, turned on by ${terms.signer}`, lines: [`They last until someone turns them off or lowers them, or ${terms.signer}'s account or access changes.`], fields: ["flexible.terms"] },
|
|
71
80
|
];
|
|
81
|
+
if (runtime === "interactive") {
|
|
82
|
+
decisions.splice(decisions.findIndex(row => row.label === "Limits"), 1);
|
|
83
|
+
decisions.push({ label: "Concurrent agents", words: `${plural(caps.liveThreads, "thread")} at once in this project`, fields: ["flexible.caps"] });
|
|
84
|
+
decisions.push({ label: "Runtime", words: "Interactive Claude, using your subscription; no turn or cost limits", lines: helperModels.length === 0 ? [] : [`Permitted helper models: ${helperModels.join(", ")}`], fields: ["flexible.agent"] });
|
|
85
|
+
decisions.find(row => row.label === "Agent").lines = ["Your Claude subscription powers this interactive session. Your sign-in stays with Toolroll."];
|
|
86
|
+
}
|
|
72
87
|
const warnings = [
|
|
73
88
|
{ words: "The agent can read this repository's whole history, not just the commit it starts from.", fields: ["flexible.repository"] },
|
|
74
89
|
{ words: "Anything it reads can end up in what it writes: its messages and its commits. Toolroll checks for secrets before Ship, but that isn't a guarantee.", fields: ["flexible.network"] },
|
|
@@ -76,10 +91,10 @@ export function flexibleStartCard(store, input) {
|
|
|
76
91
|
];
|
|
77
92
|
const digestOfMessage = createHash("sha256").update(input.message, "utf8").digest("hex");
|
|
78
93
|
const networkDigest = flexibleNetworkDigest(network);
|
|
79
|
-
const key = createHash("sha256").update(JSON.stringify({ v: 1, kind: "standing-orders:flexible-start", digest: standing.digest, repo: input.repo, by: input.by, model, level: "full", billing,
|
|
94
|
+
const key = createHash("sha256").update(JSON.stringify({ v: 1, kind: "standing-orders:flexible-start", termsId: standing.id, digest: standing.digest, repo: input.repo, by: input.by, runtime, helperModels, model, level: "full", billing,
|
|
80
95
|
network: networkDigest, message: digestOfMessage, decisions, warnings }), "utf8").digest("hex").slice(0, 32);
|
|
81
96
|
const summary = { revision: null, revisionNotes: [], revisionChanges: [], decisions, why: null, differs: [], warnings, usual: [], usualLabel: "Other settings", usualSummary: "", key };
|
|
82
|
-
return { ok: true, card: { summary, digest: standing.digest, network: networkDigest, model, level: "full", billing, terms } };
|
|
97
|
+
return { ok: true, card: { summary, termsId: standing.id, digest: standing.digest, network: networkDigest, model, level: "full", billing, runtime, helperModels, terms } };
|
|
83
98
|
}
|
|
84
99
|
export const FLEXIBLE_NEXT_WORDS = Object.freeze({
|
|
85
100
|
"turn-on": "Threads are off. Turn them on in Settings → General, or with `toolroll config set flexible on`. Nothing was started.",
|
package/dist/flexible.js
CHANGED
|
@@ -364,3 +364,16 @@ export function flexibleSettingsView(store, repo, viewer) {
|
|
|
364
364
|
return { repo, standing, canChange: viewer.canChange,
|
|
365
365
|
proposal: proposed.ok ? { terms: proposed.terms, digest: proposed.digest } : { problem: proposed.message.replace(/ Nothing changed\.$/, "") } };
|
|
366
366
|
}
|
|
367
|
+
export function flexibleRuntime(store, thread) {
|
|
368
|
+
const row = store.handle.prepare("SELECT runtime FROM flexible_thread_runtime WHERE thread = ?").get(thread);
|
|
369
|
+
if (row === undefined)
|
|
370
|
+
return "stream-json";
|
|
371
|
+
if (row["runtime"] !== "stream-json" && row["runtime"] !== "interactive")
|
|
372
|
+
throw new Error("unreadable thread runtime");
|
|
373
|
+
return row["runtime"];
|
|
374
|
+
}
|
|
375
|
+
export function recordFlexibleRuntime(store, thread, runtime) {
|
|
376
|
+
const changed = store.handle.prepare("UPDATE flexible_thread_runtime SET runtime = ?, chosen = 1 WHERE thread = ?").run(runtime, thread);
|
|
377
|
+
if (Number(changed.changes) !== 1)
|
|
378
|
+
throw new Error("missing thread runtime");
|
|
379
|
+
}
|
package/dist/lead-tools.js
CHANGED
|
@@ -1235,6 +1235,7 @@ const LEAD_TOOL_HANDLERS = {
|
|
|
1235
1235
|
return { ok: true, body: {
|
|
1236
1236
|
subagents: mates.map(mate => ({
|
|
1237
1237
|
subagent: mate.id, name: nameOf(mate), label: labelOf(mate), handle: mate.handle, project: repoIdOf(ctx.who, mate.repo), working: mate.state === "active",
|
|
1238
|
+
codexBackup: { enabled: mate.codexBackupModel !== null, model: mate.codexBackupModel, settings: `/settings/lead/subagents/${mate.id}#backup`, change: "Enable or change with your password in Settings; Claude stays primary." },
|
|
1238
1239
|
reportsTo: whoIs(mate.manager), soul: args["subagent"] === undefined ? mate.soul.slice(0, 600) : mate.soul, version: mate.version,
|
|
1239
1240
|
worksOn: zonesOf(ctx.store, mate).map(one => ({ flow: one.flow, flowName: one.flowName, zone: one.title, how: one.kind })),
|
|
1240
1241
|
today: summaryOf(ctx.store, mate, today.toISOString()).said,
|
package/dist/server/console.css
CHANGED
|
@@ -860,7 +860,7 @@
|
|
|
860
860
|
background: var(--primary); color: var(--primary-foreground);
|
|
861
861
|
border: 1px solid var(--primary);
|
|
862
862
|
border-radius: calc(var(--radius) - 3px); padding: .525rem; margin: .75rem 0 .125rem;
|
|
863
|
-
box-shadow:
|
|
863
|
+
box-shadow: none;
|
|
864
864
|
}
|
|
865
865
|
@media (hover: hover) and (pointer: fine) { .side .new-task:hover { background: color-mix(in srgb, var(--primary) 85%, var(--background)); } }
|
|
866
866
|
/* The same action link outside the sidebar reads as a real button. */
|
|
@@ -947,7 +947,7 @@
|
|
|
947
947
|
@media (hover: hover) and (pointer: fine) { .demo-chat .demo-suggestions button:hover { color: var(--so-ink); border-color: var(--so-input-line); background: var(--so-soft); } }
|
|
948
948
|
/* The composer: one card docked at the bottom, a borderless box that grows, the hint and a round send inside. */
|
|
949
949
|
.demo-composer { position: sticky; bottom: 0; margin: 0; padding: .75rem 0 1rem; border: 0; border-radius: 0; box-shadow: none; background: linear-gradient(to bottom, transparent, var(--so-paper) 1.25rem); }
|
|
950
|
-
.demo-composer-card { display: flex; flex-direction: column; gap: .35rem; padding: .7rem .7rem .55rem .9rem; border: 1px solid var(--so-input-line); border-radius: 1rem; background: var(--so-paper); box-shadow:
|
|
950
|
+
.demo-composer-card { display: flex; flex-direction: column; gap: .35rem; padding: .7rem .7rem .55rem .9rem; border: 1px solid var(--so-input-line); border-radius: 1rem; background: var(--so-paper); box-shadow: var(--so-pill-shadow); transition: border-color .12s var(--so-ease-out), box-shadow .12s var(--so-ease-out); }
|
|
951
951
|
.demo-composer-card:focus-within { border-color: var(--so-muted); box-shadow: 0 0 0 3px var(--so-soft); }
|
|
952
952
|
.demo-chat .demo-composer textarea { width: 100%; min-height: 1.6rem; max-height: 12rem; field-sizing: content; padding: .15rem 0; border: 0; border-radius: 0; background: none; box-shadow: none; resize: none; font-size: .9375rem; line-height: 1.55; }
|
|
953
953
|
.demo-chat .demo-composer textarea:focus-visible { outline: 0; }
|
|
@@ -998,7 +998,7 @@
|
|
|
998
998
|
font-size: .72rem; font-weight: 550; text-align: center; text-decoration: none;
|
|
999
999
|
}
|
|
1000
1000
|
@media (hover: hover) and (pointer: fine) { .task-view-switch a:hover { color: var(--foreground); background: color-mix(in srgb, var(--muted) 70%, transparent); } }
|
|
1001
|
-
.task-view-switch a.active { color: var(--foreground); background: var(--glass-strong); box-shadow:
|
|
1001
|
+
.task-view-switch a.active { color: var(--foreground); background: var(--glass-strong); box-shadow: var(--so-pill-shadow); }
|
|
1002
1002
|
.acts-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .75rem 0 .25rem; }
|
|
1003
1003
|
.acts-bar form.inline { margin: 0; display: inline-flex; align-items: center; gap: .375rem; }
|
|
1004
1004
|
.acts-bar form.inline button { width: auto; }
|
|
@@ -2126,7 +2126,7 @@
|
|
|
2126
2126
|
}
|
|
2127
2127
|
@media (hover: hover) and (pointer: fine) { .chat-project-card:hover {
|
|
2128
2128
|
border-color: var(--glass-border); background: color-mix(in srgb, var(--muted) 82%, transparent);
|
|
2129
|
-
box-shadow:
|
|
2129
|
+
box-shadow: none;
|
|
2130
2130
|
} }
|
|
2131
2131
|
.chat-project-name { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .45rem; }
|
|
2132
2132
|
.chat-project-name strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8125rem; }
|
|
@@ -2151,7 +2151,7 @@
|
|
|
2151
2151
|
align-self: flex-end; max-width: min(82%, 40rem); padding: .75rem 1rem;
|
|
2152
2152
|
border: 1px solid var(--glass-border); border-radius: 1.2rem 1.2rem .35rem 1.2rem;
|
|
2153
2153
|
background: var(--user-message); color: var(--so-ink);
|
|
2154
|
-
box-shadow:
|
|
2154
|
+
box-shadow: none;
|
|
2155
2155
|
}
|
|
2156
2156
|
.thread .msg.mate {
|
|
2157
2157
|
position: relative; align-self: stretch; padding: .75rem .5rem .75rem 3.45rem;
|
|
@@ -2278,7 +2278,7 @@
|
|
|
2278
2278
|
@media (hover: hover) and (pointer: fine) { .composer textarea:hover { border: 0; box-shadow: none; } }
|
|
2279
2279
|
.composer button {
|
|
2280
2280
|
flex: 0 0 2.75rem; width: 2.75rem; min-height: 2.75rem; padding: 0; border-radius: 999px;
|
|
2281
|
-
font-size: 0; box-shadow:
|
|
2281
|
+
font-size: 0; box-shadow: none;
|
|
2282
2282
|
}
|
|
2283
2283
|
.composer button::after { content: "↑"; font: 600 1.15rem/1 var(--font-sans); }
|
|
2284
2284
|
.chat-main > details { margin-top: 1rem; background: color-mix(in srgb, var(--glass) 70%, transparent); }
|
|
@@ -2299,7 +2299,7 @@
|
|
|
2299
2299
|
.chat-main { max-width: none; }
|
|
2300
2300
|
.chat-projects { display: none; }
|
|
2301
2301
|
.chat-workspace.projects-open::before {
|
|
2302
|
-
content: ""; position: fixed; inset: 0 0 0 232px; z-index: 23; background:
|
|
2302
|
+
content: ""; position: fixed; inset: 0 0 0 232px; z-index: 23; background: var(--so-scrim);
|
|
2303
2303
|
}
|
|
2304
2304
|
.chat-workspace.projects-open .chat-projects {
|
|
2305
2305
|
display: block; position: fixed; top: 4rem; left: calc(232px + 1.25rem); z-index: 25;
|
|
@@ -2321,7 +2321,7 @@
|
|
|
2321
2321
|
.chat-workspace.projects-hidden .chat-projects, .chat-projects { display: none; }
|
|
2322
2322
|
.chat-project-toggle { display: inline-flex; min-height: 2.75rem; }
|
|
2323
2323
|
.chat-project-close { display: grid; place-items: center; min-height: 2.75rem; min-width: 2.75rem; }
|
|
2324
|
-
.chat-workspace.projects-open::before { content: ""; position: fixed; inset: 0; z-index: 30; background:
|
|
2324
|
+
.chat-workspace.projects-open::before { content: ""; position: fixed; inset: 0; z-index: 30; background: var(--so-scrim); }
|
|
2325
2325
|
.chat-workspace.projects-open .chat-projects { display: block; position: fixed; top: 5rem; left: 1rem; right: 1rem; width: auto; max-height: calc(100dvh - 10rem); overflow-y: auto; overscroll-behavior: contain; z-index: 31; background: var(--card); }
|
|
2326
2326
|
.chat-project-list { display: grid; gap: 0; padding: 0; }
|
|
2327
2327
|
.chat-project-card {
|
|
@@ -2738,7 +2738,7 @@ html.so-nav-shallower::view-transition-new(so-page) { animation: so-page-shallow
|
|
|
2738
2738
|
/* Board cards are panels in a frame: a hover fills them raised, never a shadow. */
|
|
2739
2739
|
.decide-card:hover, .menu-row:hover {
|
|
2740
2740
|
|
|
2741
|
-
box-shadow:
|
|
2741
|
+
box-shadow: none;
|
|
2742
2742
|
}
|
|
2743
2743
|
}
|
|
2744
2744
|
}
|
package/dist/server/flows.js
CHANGED
|
@@ -208,7 +208,7 @@ export function createFlowsHandlers(runtime) {
|
|
|
208
208
|
if (mate === null)
|
|
209
209
|
return refuse(response, who, 404, "No such subagent in your projects.", "/settings/lead/subagents");
|
|
210
210
|
const approvers = store.listApprovers().map(one => one.name).filter(name => store.accountCanAccess(name, mate.repo));
|
|
211
|
-
return sendScreen(response, 200, screen(labelOf(mate), html `<p><a href="/settings/lead">Lead</a></p><h1>${labelOf(mate)}</h1>${(subagentPageHtml(store, mate, who.name, projectName, who.via === "cookie" && who.role === "approver", approvers, { said: url.searchParams.get("said"), problem: url.searchParams.get("problem"), query: url.searchParams.get("q") }))}`, { chrome: chromeFor(mate.repo, "settings") }));
|
|
211
|
+
return sendScreen(response, 200, screen(labelOf(mate), html `<p><a href="/settings/lead">Lead</a></p><h1>${labelOf(mate)}</h1>${(subagentPageHtml(store, mate, who.name, projectName, who.via === "cookie" && who.role === "approver", approvers, { said: url.searchParams.get("said"), problem: url.searchParams.get("problem"), backupDraft: url.searchParams.get("backupDraft"), query: url.searchParams.get("q") }))}`, { chrome: chromeFor(mate.repo, "settings") }));
|
|
212
212
|
}
|
|
213
213
|
async function subagentSoulFile(ctx) {
|
|
214
214
|
const { url, who, response } = ctx;
|
|
@@ -419,11 +419,12 @@ export function createFlowsHandlers(runtime) {
|
|
|
419
419
|
}
|
|
420
420
|
const done = part === "state" ? setSubagentState(store, mate, body.get("state") === "removed" ? "removed" : body.get("state") === "paused" ? "paused" : "active", who.name, now)
|
|
421
421
|
: part === "note" ? tellSubagent(store, mate, body.get("note") ?? "", who.name, now)
|
|
422
|
-
: part === "settings" ? subagentSettings(store, mate, { model: body.get("model") ?? "default", dailyTurns: Number(body.get("dailyTurns")), manager: body.get("manager") ?? mate.manager
|
|
422
|
+
: part === "settings" ? subagentSettings(store, mate, { model: body.get("model") ?? "default", dailyTurns: Number(body.get("dailyTurns")), manager: body.get("manager") ?? mate.manager,
|
|
423
|
+
...(body.get("backupPresent") === "1" ? { codexBackupModel: (body.get("codexBackupModel") ?? "").trim() || null } : {}) }, who.name, now, { proveBackup: () => authenticateApprover(who, body.get("password") ?? "", mate.repo).ok })
|
|
423
424
|
: sendSubagentSummaries(store, mate.repo, now, mate.id) > 0 ? { ok: true, said: `Sent today's summary to ${mate.manager}.` } : { ok: false, said: "The summary couldn't be sent." };
|
|
424
425
|
if (part === "state" && body.get("state") === "removed" && done.ok)
|
|
425
426
|
return redirect(response, `/settings/lead/subagents?said=${encodeURIComponent(done.said)}`);
|
|
426
|
-
return redirect(response, `${back}?${done.ok ? "said" : "problem"}=${encodeURIComponent(done.said)}${part === "note" ? "#memory" : ""}`);
|
|
427
|
+
return redirect(response, `${back}?${done.ok ? "said" : "problem"}=${encodeURIComponent(done.said)}${part === "settings" && !done.ok && body.get("backupPresent") === "1" ? `&backupDraft=${encodeURIComponent(body.get("codexBackupModel") ?? "")}` : ""}${part === "note" ? "#memory" : part === "settings" ? "#backup" : ""}`);
|
|
427
428
|
};
|
|
428
429
|
async function createFromGallery(ctx) {
|
|
429
430
|
const { url, who, response, posted } = ctx;
|
package/dist/spend-report.js
CHANGED
|
@@ -109,11 +109,11 @@ export function spendRows(db, from, to) {
|
|
|
109
109
|
rows.push({ ref: `mate_turn:${id}`, at: turn.at, source: "lead", role: "lead", project: turn.project, person: turn.person, subagent: null, taskId: null, runId: null,
|
|
110
110
|
provider: turn.provider ?? "lead", modelChosen: turn.model, modelReported: null, billing: "api-key", amount, charge: { microusd: held, basis: "estimated" } });
|
|
111
111
|
}
|
|
112
|
-
for (const row of db.prepare(`SELECT t.id, t.at, t.subagent, t.model, t.cost_usd, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
|
|
112
|
+
for (const row of db.prepare(`SELECT t.id, t.at, t.subagent, t.model, t.provider, t.model_reported, t.cost_usd, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
|
|
113
113
|
WHERE t.at >= ? AND t.at < ? ORDER BY t.id`).all(from, to)) {
|
|
114
114
|
const amount = { kind: "unknown" };
|
|
115
115
|
rows.push({ ref: `subagent_turn:${Number(row["id"])}`, at: String(row["at"]), source: "subagent", role: "subagent", project: text(row["repo"]), person: null,
|
|
116
|
-
subagent: Number(row["subagent"]), taskId: null, runId: null, provider: "
|
|
116
|
+
subagent: Number(row["subagent"]), taskId: null, runId: null, provider: String(row["provider"]), modelChosen: text(row["model"]), modelReported: text(row["model_reported"]), billing: "unproved",
|
|
117
117
|
amount, charge: chargeOf(amount, usdMicro(row["cost_usd"]), "estimated") });
|
|
118
118
|
}
|
|
119
119
|
for (const row of db.prepare("SELECT id, at, repo, provider, model, cost_usd FROM side_spend WHERE at >= ? AND at < ? ORDER BY id").all(from, to)) {
|
package/dist/spend.js
CHANGED
|
@@ -221,12 +221,12 @@ export function spendItems(db, from, to, readMode = provider => billingOf(provid
|
|
|
221
221
|
taskId: String(row["task"]), runId: Number(row["id"]), authMode: billing,
|
|
222
222
|
};
|
|
223
223
|
});
|
|
224
|
-
for (const row of !any("subagent") ? [] : db.prepare(`SELECT t.at, t.subagent, t.model, t.cost_usd, t.tokens_in, t.tokens_out, t.billing, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
|
|
224
|
+
for (const row of !any("subagent") ? [] : db.prepare(`SELECT t.at, t.subagent, t.model, t.provider, t.cost_usd, t.tokens_in, t.tokens_out, t.billing, m.repo FROM subagent_turn t JOIN subagent m ON m.id = t.subagent
|
|
225
225
|
WHERE t.at >= ? AND t.at < ? ORDER BY t.id`).all(from, to)) {
|
|
226
226
|
const billing = row["billing"] === "api-key" ? "api-key" : "subscription";
|
|
227
|
-
const priced = priceWork(db, { provider: "
|
|
227
|
+
const priced = priceWork(db, { provider: String(row["provider"]), model: text(row["model"]), costUsd: count(row["cost_usd"]), tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), billing }, lookup);
|
|
228
228
|
items.push({ at: String(row["at"]), kind: "subagent", microusd: priced.microusd, source: priced.source, project: String(row["repo"]), person: null,
|
|
229
|
-
subagent: Number(row["subagent"]), provider: "
|
|
229
|
+
subagent: Number(row["subagent"]), provider: String(row["provider"]), model: text(row["model"]),
|
|
230
230
|
tokensIn: count(row["tokens_in"]), tokensOut: count(row["tokens_out"]), taskId: null, runId: null, authMode: billing });
|
|
231
231
|
}
|
|
232
232
|
for (const row of !any("chat") ? [] : db.prepare(`SELECT created_at AS at, approver, provider, model, settled_microusd, tokens_in, tokens_out, NULL AS project
|