toolroll 0.9.55 → 0.9.57
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 +18 -0
- package/README.md +24 -8
- package/dist/action-ledger.d.ts +2 -4
- package/dist/action-ledger.js +2 -10
- package/dist/approval-policy.d.ts +5 -5
- package/dist/approval-policy.js +4 -4
- package/dist/approval-rules-ui.js +2 -2
- package/dist/assignment-adapters.d.ts +5 -0
- package/dist/assignment.d.ts +24 -3
- package/dist/assignment.js +36 -10
- package/dist/browser/workspace.js +5 -5
- package/dist/browser-workspace.d.ts +12 -12
- package/dist/browser-workspace.js +1 -1
- package/dist/budget-alerts.js +3 -3
- package/dist/chat-actions.d.ts +23 -18
- package/dist/chat-actions.js +110 -88
- package/dist/chat-ask.d.ts +2 -2
- package/dist/chat-ask.js +5 -5
- package/dist/chat-channel.d.ts +15 -15
- package/dist/chat-channel.js +20 -20
- package/dist/chat-controls.d.ts +0 -4
- package/dist/chat-controls.js +0 -1
- package/dist/chat-core.js +1 -1
- package/dist/chat-delivery-state.js +2 -2
- package/dist/chat-delivery.d.ts +2 -2
- package/dist/chat-delivery.js +30 -37
- package/dist/chat-flow.js +3 -3
- package/dist/chat-messages.d.ts +1 -1
- package/dist/chat-messages.js +4 -4
- package/dist/chat-migration.d.ts +1 -1
- package/dist/chat-migration.js +11 -11
- package/dist/chat-rooms.js +3 -3
- package/dist/chat-voice.js +1 -1
- package/dist/chat-warmth.d.ts +2 -2
- package/dist/check-levels.d.ts +3 -0
- package/dist/check-levels.js +5 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +6 -7
- package/dist/contracts/chat-actions.d.ts +32 -27
- package/dist/contracts/chat-actions.js +29 -11
- package/dist/contracts/chat-content.d.ts +1 -1
- package/dist/contracts/chat-content.js +1 -1
- package/dist/contracts/chat-tables.js +4 -4
- package/dist/contracts/console-api.d.ts +6 -6
- package/dist/contracts/console-api.js +7 -7
- package/dist/contracts/flow-propose.d.ts +3 -3
- package/dist/contracts/flow.d.ts +132 -125
- package/dist/contracts/flow.js +27 -12
- package/dist/contracts/lead-context.d.ts +1 -1
- package/dist/contracts/lead-context.js +2 -2
- package/dist/contracts/lead-tools.d.ts +20 -18
- package/dist/contracts/lead-tools.js +15 -15
- package/dist/contracts/stage-output.d.ts +1 -1
- package/dist/contracts/stage-output.js +1 -1
- package/dist/contracts/store-json.d.ts +23 -22
- package/dist/contracts/store-json.js +17 -17
- package/dist/contracts/{teammate-turn.d.ts → subagent-turn.d.ts} +5 -5
- package/dist/contracts/{teammate-turn.js → subagent-turn.js} +7 -7
- package/dist/converse.d.ts +23 -23
- package/dist/converse.js +28 -28
- package/dist/coordinator-proposals.d.ts +2 -2
- package/dist/coordinator-proposals.js +1 -1
- package/dist/coordinator.js +1 -1
- package/dist/deprecations.d.ts +12 -0
- package/dist/deprecations.js +20 -0
- package/dist/desktop-update-gate.js +8 -4
- package/dist/desktop-update.js +6 -1
- package/dist/discord-chat.js +6 -6
- package/dist/dispatch.d.ts +1 -1
- package/dist/dispatch.js +1 -1
- package/dist/dispose.js +0 -5
- package/dist/envelope.js +0 -1
- package/dist/export-ui.js +1 -1
- package/dist/export.js +7 -7
- package/dist/flow-engine.d.ts +2 -2
- package/dist/flow-engine.js +21 -21
- package/dist/flow-insights.d.ts +1 -1
- package/dist/flow-share.js +13 -8
- package/dist/flow-steps.d.ts +5 -5
- package/dist/flow-steps.js +19 -19
- package/dist/flow-triggers.d.ts +1 -1
- package/dist/flow-triggers.js +1 -1
- package/dist/flows-cli.js +1 -1
- package/dist/flows-ui.js +20 -20
- package/dist/flows.js +19 -19
- package/dist/guides.js +4 -3
- package/dist/invoke.js +1 -1
- package/dist/kits-ui.js +5 -5
- package/dist/kits.d.ts +12 -12
- package/dist/kits.js +31 -31
- package/dist/{mate-cli.d.ts → lead-cli.d.ts} +11 -11
- package/dist/{mate-cli.js → lead-cli.js} +38 -38
- package/dist/lead-commitments.js +4 -4
- package/dist/lead-context.d.ts +2 -2
- package/dist/lead-context.js +9 -9
- package/dist/{mate-contract.d.ts → lead-contract.d.ts} +3 -3
- package/dist/{mate-contract.js → lead-contract.js} +7 -6
- package/dist/{mate-doors.d.ts → lead-doors.d.ts} +6 -6
- package/dist/{mate-doors.js → lead-doors.js} +24 -24
- package/dist/lead-follow.d.ts +5 -5
- package/dist/lead-follow.js +9 -9
- package/dist/lead-people.d.ts +5 -5
- package/dist/lead-people.js +14 -14
- package/dist/{mate-progress.d.ts → lead-progress.d.ts} +9 -9
- package/dist/{mate-progress.js → lead-progress.js} +3 -3
- package/dist/lead-status.d.ts +1 -1
- package/dist/lead-status.js +2 -2
- package/dist/{mate-tools.d.ts → lead-tools.d.ts} +19 -19
- package/dist/{mate-tools.js → lead-tools.js} +109 -101
- package/dist/{mate.d.ts → lead.d.ts} +27 -27
- package/dist/{mate.js → lead.js} +102 -102
- package/dist/limits-ui.d.ts +1 -1
- package/dist/limits-ui.js +1 -1
- package/dist/mcp-connect.d.ts +1 -1
- package/dist/mcp-connect.js +3 -3
- package/dist/mcp-core.js +1 -1
- package/dist/memory-pass.d.ts +2 -2
- package/dist/memory-pass.js +7 -7
- package/dist/notification-rows.d.ts +2 -2
- package/dist/operate.d.ts +3 -3
- package/dist/operate.js +52 -42
- package/dist/policy.d.ts +1 -1
- package/dist/principal.d.ts +1 -1
- package/dist/principal.js +2 -2
- package/dist/project-delete-ui.js +1 -1
- package/dist/project-delete.d.ts +1 -1
- package/dist/project-delete.js +26 -26
- package/dist/project-memory.js +1 -1
- package/dist/project-tools.d.ts +1 -1
- package/dist/project-tools.js +1 -1
- package/dist/proof.d.ts +9 -0
- package/dist/proof.js +12 -0
- package/dist/recipe-ui.js +1 -1
- package/dist/release-coverage.d.ts +16 -0
- package/dist/release-coverage.js +92 -0
- package/dist/retention.js +4 -4
- package/dist/scope.d.ts +2 -2
- package/dist/scout-report.d.ts +1 -1
- package/dist/scout-report.js +1 -1
- package/dist/serve.js +40 -45
- package/dist/server/chat.d.ts +4 -4
- package/dist/server/chat.js +105 -103
- package/dist/server/chrome.js +3 -3
- package/dist/server/flows.js +69 -62
- package/dist/server/guards.js +3 -3
- package/dist/server/http.d.ts +3 -3
- package/dist/server/http.js +1 -1
- package/dist/server/live.js +6 -6
- package/dist/server/people-tokens.js +1 -1
- package/dist/server/remote.js +12 -10
- package/dist/server/render-chat.d.ts +30 -30
- package/dist/server/render-chat.js +33 -33
- package/dist/server/render-pages.js +2 -2
- package/dist/server/render-results.d.ts +4 -1
- package/dist/server/render-results.js +23 -9
- package/dist/server/render-settings.d.ts +7 -0
- package/dist/server/render-settings.js +3 -0
- package/dist/server/route-table.js +9 -7
- package/dist/server/runtime.d.ts +13 -13
- package/dist/server/settings.js +14 -13
- package/dist/server/tasks.js +34 -30
- package/dist/setup-guide.d.ts +2 -2
- package/dist/slack-chat.d.ts +2 -2
- package/dist/slack-chat.js +6 -6
- package/dist/spend-ui.d.ts +3 -3
- package/dist/spend-ui.js +9 -9
- package/dist/spend.d.ts +14 -14
- package/dist/spend.js +31 -31
- package/dist/store-baseline.d.ts +19 -0
- package/dist/store-baseline.js +2873 -0
- package/dist/store.d.ts +200 -254
- package/dist/store.js +830 -3152
- package/dist/subagent-admin.d.ts +53 -0
- package/dist/{teammate-admin.js → subagent-admin.js} +37 -37
- package/dist/{teammate-desk.d.ts → subagent-desk.d.ts} +22 -23
- package/dist/{teammate-desk.js → subagent-desk.js} +26 -35
- package/dist/{teammate-memory.d.ts → subagent-memory.d.ts} +17 -17
- package/dist/{teammate-memory.js → subagent-memory.js} +41 -41
- package/dist/{teammate-question.d.ts → subagent-question.d.ts} +6 -6
- package/dist/{teammate-question.js → subagent-question.js} +17 -17
- package/dist/{teammate-tools.d.ts → subagent-tools.d.ts} +18 -18
- package/dist/{teammate-tools.js → subagent-tools.js} +36 -36
- package/dist/{teammate-week.d.ts → subagent-week.d.ts} +10 -10
- package/dist/{teammate-week.js → subagent-week.js} +23 -23
- package/dist/{teammate-work.d.ts → subagent-work.d.ts} +21 -21
- package/dist/{teammate-work.js → subagent-work.js} +50 -50
- package/dist/subagents-ui.d.ts +22 -0
- package/dist/{teammates-ui.js → subagents-ui.js} +45 -45
- package/dist/{teammates.d.ts → subagents.d.ts} +11 -11
- package/dist/{teammates.js → subagents.js} +21 -21
- package/dist/subscription-chat.d.ts +13 -13
- package/dist/subscription-chat.js +19 -19
- package/dist/surface.d.ts +19 -2
- package/dist/surface.js +7 -31
- package/dist/task-outcome-cli.js +3 -1
- package/dist/task-status.d.ts +59 -7
- package/dist/task-status.js +132 -16
- package/dist/team-cli.d.ts +1 -0
- package/dist/team-cli.js +14 -2
- package/dist/team-leads.js +13 -13
- package/dist/team-runtime.d.ts +2 -2
- package/dist/team-runtime.js +9 -9
- package/dist/teams-chat.js +6 -6
- package/dist/telegram-flow.d.ts +3 -3
- package/dist/telegram-flow.js +3 -3
- package/dist/{telegram-mate.d.ts → telegram-lead.d.ts} +5 -5
- package/dist/{telegram-mate.js → telegram-lead.js} +27 -27
- package/dist/telegram-status.d.ts +11 -4
- package/dist/telegram-status.js +18 -11
- package/dist/telegram-team.d.ts +1 -1
- package/dist/telegram-team.js +5 -5
- package/dist/telegram.d.ts +1 -1
- package/dist/telegram.js +13 -34
- package/dist/text-limits.d.ts +18 -18
- package/dist/text-limits.js +18 -18
- package/dist/toolroll-update.d.ts +8 -0
- package/dist/toolroll-update.js +45 -8
- package/dist/work-index.d.ts +6 -1
- package/dist/work-index.js +50 -8
- package/dist/workspace-ui.js +2 -1
- package/package.json +1 -2
- package/dist/teammate-admin.d.ts +0 -53
- package/dist/teammates-ui.d.ts +0 -21
package/dist/telegram-status.js
CHANGED
|
@@ -4,7 +4,8 @@ import { manualReviewOnly } from "./proof.js";
|
|
|
4
4
|
* No provider calls, repository access, new workflow state, or inferred success. */
|
|
5
5
|
import { diagnoseTaskDispatch, withDispatchDiagnoses } from "./dispatch.js";
|
|
6
6
|
import { familyCompleted } from "./result-completion.js";
|
|
7
|
-
import { plainReasonOf, stageOfDispatch, taskStatusOf } from "./task-status.js";
|
|
7
|
+
import { assignmentStatusFacts, plainReasonOf, stageOfDispatch, taskStatusOf } from "./task-status.js";
|
|
8
|
+
import { assignmentOf } from "./assignment.js";
|
|
8
9
|
import { CHAT_CONTROLS, chatControlHref, chatResultHref } from "./chat-controls.js";
|
|
9
10
|
export function phoneCommand(text) {
|
|
10
11
|
// Slash forms everywhere; the bare words too, because Slack and Discord
|
|
@@ -39,7 +40,7 @@ export const PHONE_HELP = [
|
|
|
39
40
|
"/task <name or number> — the same, by a word from its name",
|
|
40
41
|
"/lead — back to talking about everything",
|
|
41
42
|
"/status — what's happening across your projects",
|
|
42
|
-
|
|
43
|
+
// D5: /team (the central team service's conversations) is deprecated: it still answers this release, unlisted.
|
|
43
44
|
"/help — this message",
|
|
44
45
|
"",
|
|
45
46
|
"To answer an agent's question, tap its buttons; reply to the question to add a note. Approvals that need your password, cancelling and publishing finish in the Toolroll console, and a console button only takes you there. The computer must be awake and connected to reply.",
|
|
@@ -53,10 +54,16 @@ export function projectLabel(repo) {
|
|
|
53
54
|
return plain(repo.split(/[\\/]/).filter(Boolean).pop() ?? "project", 48);
|
|
54
55
|
}
|
|
55
56
|
/** The shared headline (task-status.ts) for a dispatch diagnosis on the phone. */
|
|
56
|
-
function headlineFor(store, id, d) {
|
|
57
|
+
function headlineFor(store, id, d, read_ = {}) {
|
|
57
58
|
// Any version of a completed family reads Complete, as taskWaitSnapshot says.
|
|
58
59
|
const completed = d.code === "complete" && familyCompleted(store, id);
|
|
59
60
|
const read = stageOfDispatch(d, { completed });
|
|
61
|
+
// A finished result reads the console's own facts: its requirements, checks Off at release, and what holds it back.
|
|
62
|
+
if (read.stage === "finished" && read_.root !== undefined && read_.now !== undefined && read_.repos !== undefined) {
|
|
63
|
+
const assignment = assignmentOf(store, id, read_.now, { principal: "operator", repos: read_.repos }, read_.root);
|
|
64
|
+
if (assignment !== null && assignment.state === "ready-to-check")
|
|
65
|
+
return taskStatusOf(assignmentStatusFacts(assignment));
|
|
66
|
+
}
|
|
60
67
|
const finished = read.stage === "finished" || read.stage === "complete" || read.stage === "failed";
|
|
61
68
|
return taskStatusOf({ stage: read.stage, ...(read.need === undefined ? {} : { need: read.need }), reason: finished ? null : plainReasonOf(read.stage, d.code, d.detail),
|
|
62
69
|
checks: read.stage === "failed" && d.code === "proof-refuted" ? { status: "failed", exitCode: null, head: null } : null });
|
|
@@ -95,7 +102,7 @@ function nextStep(d) {
|
|
|
95
102
|
}
|
|
96
103
|
/** repos is the transport's explicit enrollment ceiling, never opened-project
|
|
97
104
|
* history. This snapshot is intentionally bounded and advertises that bound. */
|
|
98
|
-
export function phoneStatus(store, repos, now, focused = null) {
|
|
105
|
+
export function phoneStatus(store, repos, now, focused = null, root) {
|
|
99
106
|
if (repos.length === 0)
|
|
100
107
|
return "No connected projects are available to this bridge. Add a project in Toolroll, then send /status again.";
|
|
101
108
|
return store.transact(() => {
|
|
@@ -111,7 +118,7 @@ export function phoneStatus(store, repos, now, focused = null) {
|
|
|
111
118
|
continue;
|
|
112
119
|
lines.push(`${group} · ${rows.length}${snapshot.tasksSaturated ? " in this snapshot" : ""}`);
|
|
113
120
|
for (const task of rows.slice(0, 2)) {
|
|
114
|
-
lines.push(`${plain(task.id, 64)} · ${projectLabel(repos[task.repoIndex])}`, ` ${plain(task.title, 64)} — ${headlineFor(store, task.id, task.dispatch).headline}`);
|
|
121
|
+
lines.push(`${plain(task.id, 64)} · ${projectLabel(repos[task.repoIndex])}`, ` ${plain(task.title, 64)} — ${headlineFor(store, task.id, task.dispatch, { root, now, repos }).headline}`);
|
|
115
122
|
}
|
|
116
123
|
if (rows.length > 2)
|
|
117
124
|
lines.push(` +${rows.length - 2} more in the console`);
|
|
@@ -126,7 +133,7 @@ const PICK_GROUPS = ["Needs attention", "Working", "Waiting / next up", "Finishe
|
|
|
126
133
|
* then work in progress, waiting work and recent results; one entry per
|
|
127
134
|
* task (its revisions share it), optionally narrowed by words in the id or
|
|
128
135
|
* title. Bounded, within the chat's own project ceiling. */
|
|
129
|
-
export function phoneTaskChoices(store, repos, now, query = null, limit = 8) {
|
|
136
|
+
export function phoneTaskChoices(store, repos, now, query = null, limit = 8, root) {
|
|
130
137
|
if (repos.length === 0)
|
|
131
138
|
return [];
|
|
132
139
|
return store.transact(() => {
|
|
@@ -142,7 +149,7 @@ export function phoneTaskChoices(store, repos, now, query = null, limit = 8) {
|
|
|
142
149
|
if (seen.has(id) || !words.every(word => `${id} ${row.title}`.toLowerCase().includes(word)))
|
|
143
150
|
continue;
|
|
144
151
|
seen.add(id);
|
|
145
|
-
choices.push({ id, title: plain(row.title, 64), label: headlineFor(store, row.id, row.dispatch).headline, group: groupOf(row.dispatch) });
|
|
152
|
+
choices.push({ id, title: plain(row.title, 64), label: headlineFor(store, row.id, row.dispatch, { root, now, repos }).headline, group: groupOf(row.dispatch) });
|
|
146
153
|
if (choices.length >= limit)
|
|
147
154
|
break;
|
|
148
155
|
}
|
|
@@ -210,12 +217,12 @@ function taskLinkFor(id, d, result) {
|
|
|
210
217
|
default: return control("task");
|
|
211
218
|
}
|
|
212
219
|
}
|
|
213
|
-
export function phoneTask(store, repos, id, now) {
|
|
214
|
-
return phoneTaskView(store, repos, id, now).text;
|
|
220
|
+
export function phoneTask(store, repos, id, now, root) {
|
|
221
|
+
return phoneTaskView(store, repos, id, now, root).text;
|
|
215
222
|
}
|
|
216
223
|
/** One task's status for a chat app: the words, its one console link, and
|
|
217
224
|
* the saved result it shows (a reply to it is about that result). */
|
|
218
|
-
export function phoneTaskView(store, repos, id, now) {
|
|
225
|
+
export function phoneTaskView(store, repos, id, now, root) {
|
|
219
226
|
return store.transact(() => {
|
|
220
227
|
const ref = store.lookupRef(id);
|
|
221
228
|
// Check admission before reading a title, run, proof, or diagnosis.
|
|
@@ -225,7 +232,7 @@ export function phoneTaskView(store, repos, id, now) {
|
|
|
225
232
|
const d = diagnoseTaskDispatch(store, id, now);
|
|
226
233
|
if (d === null)
|
|
227
234
|
return { text: "This task's status is unavailable. Open it in the console before retrying.", link: null, run: null };
|
|
228
|
-
const shared = headlineFor(store, id, d);
|
|
235
|
+
const shared = headlineFor(store, id, d, { root, now, repos });
|
|
229
236
|
const lines = [plain(task.title, 140), `${plain(id, 64)} · ${projectLabel(ref.repo)}`, `As of ${now.toISOString().replace("T", " ").slice(0, 19)} UTC`, "", shared.headline];
|
|
230
237
|
const blocker = d.blockerTaskId === null ? null : store.lookupRef(d.blockerTaskId);
|
|
231
238
|
const hiddenDependency = blocker !== null && (blocker.repo === null || !repos.includes(blocker.repo));
|
package/dist/telegram-team.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* per-chat cursor read on every bridge cycle. No model runs here.
|
|
8
8
|
*/
|
|
9
9
|
import type { Store } from "./store.js";
|
|
10
|
-
import { type InlineButton } from "./telegram-
|
|
10
|
+
import { type InlineButton } from "./telegram-lead.js";
|
|
11
11
|
import type { TelegramTransport } from "./telegram.js";
|
|
12
12
|
import type { TelegramMessage } from "./contracts/telegram-callback.js";
|
|
13
13
|
export type TeamCommand = {
|
package/dist/telegram-team.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { renderReply, shapeReplyParts } from "./reply-shape.js";
|
|
2
2
|
import { TeamLeads } from "./team-leads.js";
|
|
3
3
|
import { proposalPreview, tooLongText } from "./chat-channel.js";
|
|
4
|
-
import { PART_CAP, mintCardTokens, phoneLinkButton, splitParts } from "./telegram-
|
|
5
|
-
import {
|
|
4
|
+
import { PART_CAP, mintCardTokens, phoneLinkButton, splitParts } from "./telegram-lead.js";
|
|
5
|
+
import { LEAD_MESSAGE_MAX_CHARS } from "./lead.js";
|
|
6
6
|
import { phoneText } from "./telegram-status.js";
|
|
7
7
|
/** `/team` lists, `/team <n>` chooses, `/team off` (or `private`) leaves. Any other slash text is not ours. */
|
|
8
8
|
export function teamCommand(text) {
|
|
@@ -172,7 +172,7 @@ export function applyTeamInbound(input) {
|
|
|
172
172
|
report.ignored++;
|
|
173
173
|
return true;
|
|
174
174
|
}
|
|
175
|
-
if (trimmed.length >
|
|
175
|
+
if (trimmed.length > LEAD_MESSAGE_MAX_CHARS) {
|
|
176
176
|
say(chatId, tooLongText(trimmed.length));
|
|
177
177
|
report.chatRefused = (report.chatRefused ?? 0) + 1;
|
|
178
178
|
return true;
|
|
@@ -255,7 +255,7 @@ export async function deliverTeamChats(store, botId, transport, clock, report, p
|
|
|
255
255
|
const row = conversationRow(store, chat.conversation);
|
|
256
256
|
if (row === null)
|
|
257
257
|
continue;
|
|
258
|
-
const pending = store.handle.prepare(`SELECT m.id, m.role, m.text, m.turn, q.author, q.request_id, q.status FROM
|
|
258
|
+
const pending = store.handle.prepare(`SELECT m.id, m.role, m.text, m.turn, q.author, q.request_id, q.status FROM lead_message m
|
|
259
259
|
LEFT JOIN team_message q ON q.message = m.id WHERE m.thread = ? AND m.id > ? ORDER BY m.id LIMIT 20`).all(row.thread, chat.cursor);
|
|
260
260
|
for (const message of pending) {
|
|
261
261
|
const id = Number(message["id"]);
|
|
@@ -279,7 +279,7 @@ export async function deliverTeamChats(store, botId, transport, clock, report, p
|
|
|
279
279
|
if (role === "assistant" && message["turn"] !== null) {
|
|
280
280
|
const turn = Number(message["turn"]);
|
|
281
281
|
const cardBinding = cardBindingFor(store, botId, chat, turn);
|
|
282
|
-
for (const proposal of store.
|
|
282
|
+
for (const proposal of store.listLeadProposals(row.thread, ["pending"]).filter(one => one.turn === turn)) {
|
|
283
283
|
const enrolled = await access();
|
|
284
284
|
if (enrolled === null) {
|
|
285
285
|
complete = false;
|
package/dist/telegram.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* are one command.
|
|
20
20
|
*/
|
|
21
21
|
import { type Store, type Notification } from "./store.js";
|
|
22
|
-
import { type TelegramConversationOptions } from "./telegram-
|
|
22
|
+
import { type TelegramConversationOptions } from "./telegram-lead.js";
|
|
23
23
|
/** Read the enrolled project list on demand. No callback means no task data,
|
|
24
24
|
* never an implicit all-database ceiling. Shared by pass and embedded follower. */
|
|
25
25
|
export type TelegramReadProjects = () => Promise<readonly string[]>;
|
package/dist/telegram.js
CHANGED
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
* BotFather token plus `bridge telegram unpair` is the recovery, and both
|
|
19
19
|
* are one command.
|
|
20
20
|
*/
|
|
21
|
-
import { applyTelegramQuestionReply, applyTelegramQuestionTap, openQuestionOf, telegramQuestionButtons } from "./
|
|
22
|
-
import { messageTeammate } from "./teammate-desk.js";
|
|
21
|
+
import { applyTelegramQuestionReply, applyTelegramQuestionTap, openQuestionOf, telegramQuestionButtons } from "./subagent-question.js";
|
|
23
22
|
import { acceptanceEvidenceText } from "./chat-acceptance.js";
|
|
24
23
|
import { verifyApproverStanding } from "./principal.js";
|
|
25
24
|
import { resultImageFileName, resultTaskLabel, verifyResultImage } from "./chat-evidence.js";
|
|
@@ -43,9 +42,9 @@ import { focusContextFor, taskInCeiling } from "./chat-channel.js";
|
|
|
43
42
|
import { answersPrompt, applyDecideFeedback, applyDecideTap, decideFallbackLink, dropDecideTokens, hasLiveDecideTokens, linksFor, placeDecidePrompt, decideOffer, decideTargetOf, isDecideToken, mergedText, mintDecideButtons, offerFingerprint, openPromptFor, placeDecideTokens, recordChatMerge, retireDecideTokens } from "./chat-decide.js";
|
|
44
43
|
import { mergePullRequest } from "./pull-request-flow.js";
|
|
45
44
|
import { phoneCommand, phoneStatus, phoneTaskView, PHONE_CONSOLE_FOOTER, PHONE_HELP, notificationIdentity, phoneTaskChoices, resolvePhoneTask, phoneFocusText, phoneTaskListText, phoneText, PHONE_NO_MATCH, PHONE_BACK_TO_LEAD } from "./telegram-status.js";
|
|
46
|
-
import {
|
|
45
|
+
import { LEAD_MESSAGE_MAX_CHARS } from "./lead.js";
|
|
47
46
|
import { envValue } from "./names.js";
|
|
48
|
-
import { applyProposalTap, processTelegramConversations, phoneLinkButton, replyContextFor, telegramConversationRepos, telegramRequestId, tooLongText, whichTaskText, } from "./telegram-
|
|
47
|
+
import { applyProposalTap, processTelegramConversations, phoneLinkButton, replyContextFor, telegramConversationRepos, telegramRequestId, tooLongText, whichTaskText, } from "./telegram-lead.js";
|
|
49
48
|
import { askOf, parseTelegramUpdate, pickOf, readTelegramButtonData, readTelegramUpdate, telegramButton } from "./contracts/telegram-callback.js";
|
|
50
49
|
/** The environment name — and therefore the name the builder strips from agents (both names; see names.ts). */
|
|
51
50
|
export { TELEGRAM_TOKEN_ENV as TOKEN_ENV, TELEGRAM_TOKEN_ENVS as TOKEN_ENVS } from "./names.js";
|
|
@@ -1246,7 +1245,7 @@ async function deliverOne(store, botId, binding, sender, notification, clock, ph
|
|
|
1246
1245
|
parts = voiced.map(one => one.text);
|
|
1247
1246
|
entities = voiced.map(one => one.entities);
|
|
1248
1247
|
}
|
|
1249
|
-
// A
|
|
1248
|
+
// A subagent's question (v93): its options and "Answer in words", for the person it asks.
|
|
1250
1249
|
const asked = flowKeys === null && choiceKeys === null ? openQuestionOf(store, notification.dedupeKey) : null;
|
|
1251
1250
|
const questionKeys = asked === null ? null : telegramQuestionButtons(store, binding, asked, clock());
|
|
1252
1251
|
const keys = flowKeys ?? choiceKeys ?? questionKeys;
|
|
@@ -1649,7 +1648,7 @@ function applyMessage(context, update, effects) {
|
|
|
1649
1648
|
// assistant when a conversation is configured; otherwise silence.
|
|
1650
1649
|
const binding = store.liveTelegramBindingFor(botId, String(from.id));
|
|
1651
1650
|
// A reply to an Edit or Send back prompt (v86): the new draft, or the note it goes back with.
|
|
1652
|
-
// A reply to a
|
|
1651
|
+
// A reply to a subagent's "Answer in words" prompt (v93): the answer.
|
|
1653
1652
|
const questionPrompt = binding !== null && message.reply_to_message !== undefined && String(chat.id) === binding.chatId
|
|
1654
1653
|
? store.telegramQuestionPrompt(binding.chatId, String(message.reply_to_message.message_id), clock()) : null;
|
|
1655
1654
|
if (binding !== null && questionPrompt !== null) {
|
|
@@ -1694,27 +1693,7 @@ function applyMessage(context, update, effects) {
|
|
|
1694
1693
|
});
|
|
1695
1694
|
return;
|
|
1696
1695
|
}
|
|
1697
|
-
//
|
|
1698
|
-
if (binding !== null && message.reply_to_message === undefined && message.chat?.type === "private" && String(chat.id) === binding.chatId && store.accountOf(binding.approver)?.role === "approver") {
|
|
1699
|
-
const repos = context.projects === null ? store.knownRepos().filter(repo => store.accountCanAccess(binding.approver, repo)) : telegramConversationRepos(store, binding.approver, context.projects);
|
|
1700
|
-
const handed = messageTeammate(store, { who: binding.approver, repos, via: "Telegram" }, message.text ?? "", clock());
|
|
1701
|
-
if (handed !== null) {
|
|
1702
|
-
effects.push(async () => {
|
|
1703
|
-
let button = null;
|
|
1704
|
-
if (handed.link !== undefined) {
|
|
1705
|
-
try {
|
|
1706
|
-
button = phoneLinkButton(context.conversation?.phoneOrigin?.() ?? null, handed.link);
|
|
1707
|
-
}
|
|
1708
|
-
catch {
|
|
1709
|
-
button = null;
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
await transport("sendMessage", { chat_id: binding.chatId, text: handed.said, link_preview_options: { is_disabled: true }, reply_parameters: { message_id: message.message_id },
|
|
1713
|
-
...(button === null ? {} : { reply_markup: { inline_keyboard: [button] } }) });
|
|
1714
|
-
});
|
|
1715
|
-
return;
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1696
|
+
// D5: a message naming a subagent ("@rosa …") goes to the lead like any other, which asks the subagent with a card.
|
|
1718
1697
|
const repliedDecision = binding !== null && message.reply_to_message !== undefined
|
|
1719
1698
|
? store.decisionForTelegramMessage(binding.id, binding.chatId, String(message.reply_to_message.message_id))
|
|
1720
1699
|
: null;
|
|
@@ -1799,7 +1778,7 @@ function applyConversation(context, update, effects) {
|
|
|
1799
1778
|
report.ignored++;
|
|
1800
1779
|
return;
|
|
1801
1780
|
}
|
|
1802
|
-
if (text.length >
|
|
1781
|
+
if (text.length > LEAD_MESSAGE_MAX_CHARS) {
|
|
1803
1782
|
say(tooLongText(text.length));
|
|
1804
1783
|
report.chatRefused = (report.chatRefused ?? 0) + 1;
|
|
1805
1784
|
return;
|
|
@@ -1905,9 +1884,9 @@ function applyPhoneRead(context, update, effects) {
|
|
|
1905
1884
|
const repos = telegramConversationRepos(store, binding.approver, registry);
|
|
1906
1885
|
const focused = focusedTitle(store, binding);
|
|
1907
1886
|
if (command.kind === "status")
|
|
1908
|
-
response = phoneStatus(store, repos, clock(), focused?.title ?? null);
|
|
1887
|
+
response = phoneStatus(store, repos, clock(), focused?.title ?? null, context.conversation?.evidenceRoot);
|
|
1909
1888
|
else if (command.kind === "tasks") {
|
|
1910
|
-
const choices = phoneTaskChoices(store, repos, clock());
|
|
1889
|
+
const choices = phoneTaskChoices(store, repos, clock(), null, 8, context.conversation?.evidenceRoot);
|
|
1911
1890
|
response = choices.length === 0 ? phoneTaskListText([], null) : `${focused === null ? "" : `Talking about: ${focused.title}\n\n`}Pick a task to talk about:`;
|
|
1912
1891
|
if (choices.length > 0)
|
|
1913
1892
|
keyboard = pickKeyboard(store, choices, focused !== null);
|
|
@@ -1922,7 +1901,7 @@ function applyPhoneRead(context, update, effects) {
|
|
|
1922
1901
|
response = PHONE_NO_MATCH;
|
|
1923
1902
|
else {
|
|
1924
1903
|
store.setChatFocus("telegram", binding.id, pick.id, clock());
|
|
1925
|
-
const view = phoneTaskView(store, repos, pick.view, clock());
|
|
1904
|
+
const view = phoneTaskView(store, repos, pick.view, clock(), context.conversation?.evidenceRoot);
|
|
1926
1905
|
shown = { task: pick.view, run: view.run };
|
|
1927
1906
|
button = phoneLinkButton(context.conversation?.phoneOrigin?.() ?? null, view.link);
|
|
1928
1907
|
// A destination with no trusted origin to carry it: the words say where instead.
|
|
@@ -2145,12 +2124,12 @@ function applyCallback(context, update, effects) {
|
|
|
2145
2124
|
store.setChatFocus("telegram", binding.id, id, clock());
|
|
2146
2125
|
ack(`Talking about: ${title}`.slice(0, 190));
|
|
2147
2126
|
const current = store.taskFamilyOf(taskId, repos, false)?.current.id ?? id;
|
|
2148
|
-
const view = phoneTaskView(store, repos, current, clock());
|
|
2127
|
+
const view = phoneTaskView(store, repos, current, clock(), context.conversation?.evidenceRoot);
|
|
2149
2128
|
store.recordTelegramTaskMessage(binding, String(message.message_id), current, view.run, clock());
|
|
2150
2129
|
editText(phoneFocusText(view.text), [[telegramButton("Back to the lead", "pick:lead")]]);
|
|
2151
2130
|
return;
|
|
2152
2131
|
}
|
|
2153
|
-
// A
|
|
2132
|
+
// A subagent's question (v93): an option answers it; "Answer in words" asks for a reply.
|
|
2154
2133
|
const questionAction = store.getTelegramQuestionAction(token);
|
|
2155
2134
|
if (questionAction !== null) {
|
|
2156
2135
|
if (questionAction.binding !== binding.id || questionAction.chatId !== tapChat || (questionAction.messageId !== null && questionAction.messageId !== String(message.message_id))) {
|
|
@@ -2247,7 +2226,7 @@ function applyCallback(context, update, effects) {
|
|
|
2247
2226
|
return;
|
|
2248
2227
|
}
|
|
2249
2228
|
const turn = askTap.turn;
|
|
2250
|
-
const found = store.
|
|
2229
|
+
const found = store.getLeadTurn(turn)?.approver === binding.approver ? store.leadAskState(turn, clock()) : { state: "expired" };
|
|
2251
2230
|
if (found.state !== "open") {
|
|
2252
2231
|
const line = found.state === "answered" ? "That question was already answered." : "That question expired. Send your answer as a message.";
|
|
2253
2232
|
ack(line);
|
package/dist/text-limits.d.ts
CHANGED
|
@@ -22,12 +22,12 @@ export declare const TEXT_LIMITS: {
|
|
|
22
22
|
readonly flowRef: 60;
|
|
23
23
|
/** A Message zone's message, or the comment an Update zone leaves. */
|
|
24
24
|
readonly flowMessage: 1000;
|
|
25
|
-
/** Who decides a "Person decides" zone (a sign-in name), and the
|
|
25
|
+
/** Who decides a "Person decides" zone (a sign-in name), and the subagent who works a zone, as written. */
|
|
26
26
|
readonly flowDecider: 64;
|
|
27
|
-
readonly
|
|
27
|
+
readonly flowSubagent: 40;
|
|
28
28
|
/** A Build zone's other project: its path. */
|
|
29
29
|
readonly flowRepo: 1000;
|
|
30
|
-
/** A script's or
|
|
30
|
+
/** A script's or subagent's answer, a choice's button, a Sort zone's answer and what it means, its question, and a score's level. */
|
|
31
31
|
readonly flowAnswer: 40;
|
|
32
32
|
readonly flowChoice: 40;
|
|
33
33
|
readonly flowSortMeans: 200;
|
|
@@ -136,11 +136,11 @@ export declare const TEXT_LIMITS: {
|
|
|
136
136
|
readonly decisionLabel: 120;
|
|
137
137
|
readonly decisionConsequence: 500;
|
|
138
138
|
readonly decisionAssignee: 120;
|
|
139
|
-
/** A
|
|
140
|
-
readonly
|
|
141
|
-
readonly
|
|
142
|
-
readonly
|
|
143
|
-
readonly
|
|
139
|
+
/** A subagent's turn (src/contracts/subagent-turn.ts): the answer it picks (and each option it offers), its question, its reason and what it remembers. */
|
|
140
|
+
readonly subagentAnswer: 60;
|
|
141
|
+
readonly subagentQuestion: 600;
|
|
142
|
+
readonly subagentReason: 400;
|
|
143
|
+
readonly subagentRemember: 300;
|
|
144
144
|
/** The lead's tools and the MCP gateway (src/contracts/lead-tools.ts, gateway-tools.ts): a task's id as a tool names
|
|
145
145
|
* it, a task's title and one path it touches, and a project's path as the gateway names it (an assignment brief or
|
|
146
146
|
* project context, and the rest of the gateway). */
|
|
@@ -175,17 +175,17 @@ export declare const TEXT_LIMITS: {
|
|
|
175
175
|
readonly actionUrl: 500;
|
|
176
176
|
readonly actionSecret: 64;
|
|
177
177
|
readonly actionAbout: 240;
|
|
178
|
-
/** A
|
|
178
|
+
/** A subagent change (propose_subagent): a soul section's title, a routine's schedule, a tool, an action, a limit's
|
|
179
179
|
* field, a name, a soul file, a note, a choice and text. */
|
|
180
|
-
readonly
|
|
181
|
-
readonly
|
|
182
|
-
readonly
|
|
183
|
-
readonly
|
|
184
|
-
readonly
|
|
185
|
-
readonly
|
|
186
|
-
readonly
|
|
187
|
-
readonly
|
|
188
|
-
readonly
|
|
180
|
+
readonly subagentSection: 60;
|
|
181
|
+
readonly subagentSchedule: 80;
|
|
182
|
+
readonly subagentTool: 40;
|
|
183
|
+
readonly subagentAction: 64;
|
|
184
|
+
readonly subagentName: 40;
|
|
185
|
+
readonly subagentSoul: 12000;
|
|
186
|
+
readonly subagentNote: 300;
|
|
187
|
+
readonly subagentChoice: 60;
|
|
188
|
+
readonly subagentText: 2000;
|
|
189
189
|
/** A project knowledge reference id, a promise and why it is released, what the lead remembers (its text, a
|
|
190
190
|
* decision's reason and source), a person's name, and a question to the owner with its options. */
|
|
191
191
|
readonly knowledgeReference: 20;
|
package/dist/text-limits.js
CHANGED
|
@@ -22,12 +22,12 @@ export const TEXT_LIMITS = {
|
|
|
22
22
|
flowRef: 60,
|
|
23
23
|
/** A Message zone's message, or the comment an Update zone leaves. */
|
|
24
24
|
flowMessage: 1_000,
|
|
25
|
-
/** Who decides a "Person decides" zone (a sign-in name), and the
|
|
25
|
+
/** Who decides a "Person decides" zone (a sign-in name), and the subagent who works a zone, as written. */
|
|
26
26
|
flowDecider: 64,
|
|
27
|
-
|
|
27
|
+
flowSubagent: 40,
|
|
28
28
|
/** A Build zone's other project: its path. */
|
|
29
29
|
flowRepo: 1_000,
|
|
30
|
-
/** A script's or
|
|
30
|
+
/** A script's or subagent's answer, a choice's button, a Sort zone's answer and what it means, its question, and a score's level. */
|
|
31
31
|
flowAnswer: 40,
|
|
32
32
|
flowChoice: 40,
|
|
33
33
|
flowSortMeans: 200,
|
|
@@ -136,11 +136,11 @@ export const TEXT_LIMITS = {
|
|
|
136
136
|
decisionLabel: 120,
|
|
137
137
|
decisionConsequence: 500,
|
|
138
138
|
decisionAssignee: 120,
|
|
139
|
-
/** A
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
/** A subagent's turn (src/contracts/subagent-turn.ts): the answer it picks (and each option it offers), its question, its reason and what it remembers. */
|
|
140
|
+
subagentAnswer: 60,
|
|
141
|
+
subagentQuestion: 600,
|
|
142
|
+
subagentReason: 400,
|
|
143
|
+
subagentRemember: 300,
|
|
144
144
|
/** The lead's tools and the MCP gateway (src/contracts/lead-tools.ts, gateway-tools.ts): a task's id as a tool names
|
|
145
145
|
* it, a task's title and one path it touches, and a project's path as the gateway names it (an assignment brief or
|
|
146
146
|
* project context, and the rest of the gateway). */
|
|
@@ -175,17 +175,17 @@ export const TEXT_LIMITS = {
|
|
|
175
175
|
actionUrl: 500,
|
|
176
176
|
actionSecret: 64,
|
|
177
177
|
actionAbout: 240,
|
|
178
|
-
/** A
|
|
178
|
+
/** A subagent change (propose_subagent): a soul section's title, a routine's schedule, a tool, an action, a limit's
|
|
179
179
|
* field, a name, a soul file, a note, a choice and text. */
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
180
|
+
subagentSection: 60,
|
|
181
|
+
subagentSchedule: 80,
|
|
182
|
+
subagentTool: 40,
|
|
183
|
+
subagentAction: 64,
|
|
184
|
+
subagentName: 40,
|
|
185
|
+
subagentSoul: 12_000,
|
|
186
|
+
subagentNote: 300,
|
|
187
|
+
subagentChoice: 60,
|
|
188
|
+
subagentText: 2_000,
|
|
189
189
|
/** A project knowledge reference id, a promise and why it is released, what the lead remembers (its text, a
|
|
190
190
|
* decision's reason and source), a person's name, and a question to the owner with its options. */
|
|
191
191
|
knowledgeReference: 20,
|
|
@@ -137,6 +137,14 @@ export type TableDigest = {
|
|
|
137
137
|
rows: number;
|
|
138
138
|
found: number;
|
|
139
139
|
};
|
|
140
|
+
compactedRuns?: {
|
|
141
|
+
run: number;
|
|
142
|
+
count: number;
|
|
143
|
+
}[];
|
|
144
|
+
summaries?: {
|
|
145
|
+
run: number;
|
|
146
|
+
hash: string;
|
|
147
|
+
}[];
|
|
140
148
|
};
|
|
141
149
|
/** Each saved table's columns, row count and last rowid; the append-only ones hashed (deploy-browser's rehearsal check).
|
|
142
150
|
* Bounded: only the ledger and small tables are read row by row. */
|
package/dist/toolroll-update.js
CHANGED
|
@@ -35,7 +35,7 @@ import { processMayBeAlive } from "./process-liveness.js";
|
|
|
35
35
|
import { assertCodingUpdateStopped, backupCodingCatalog, codingCatalogExists, releaseStaleCodingOwner, removeCodingUpdateGate } from "./coding-update.js";
|
|
36
36
|
import { installLaunchdService, launchdPlist, stopLaunchdService, writeFileDurably } from "./daemon.js";
|
|
37
37
|
import { NAME } from "./names.js";
|
|
38
|
-
import { updateSafeSchema } from "./store.js";
|
|
38
|
+
import { orphanKey, updateSafeSchema, V117_RENAMED_COLUMNS, V117_RENAMED_TABLES } from "./store.js";
|
|
39
39
|
import { isNewer, REGISTRY } from "./releases.js";
|
|
40
40
|
import { markNeverIndex } from "./never-index.js";
|
|
41
41
|
import { readRuntimeUpdateJournal, RUNTIME_PHASES, RUNTIME_UPDATE_STEPS, stagedStartedAt, updaterStartingOf } from "./contracts/update-journal.js";
|
|
@@ -322,7 +322,8 @@ export function durableRename(temp, target) {
|
|
|
322
322
|
* only when every saved value is null, or, with `carried`, when the receiving table gained exactly one receipt under
|
|
323
323
|
* that destination per row holding a value, and as many non-null values per column as the dropped columns held.
|
|
324
324
|
* `receives`: the only rows the table may gain are those receipts. `compacted`: rows may go only into summary rows,
|
|
325
|
-
* whose `sum` grows by exactly as many. `
|
|
325
|
+
* whose `sum` grows by exactly as many. `summarizes`: old summaries stay identical by run key; new ones account for
|
|
326
|
+
* that run's compacted witnesses, even below the previous maximum key. `retired`: a removed feature's table, which may go whole. `fromRoutines`: rows
|
|
326
327
|
* kept as they were, and the only rows the table may gain are one per saved routine, moved into a scheduled flow (its
|
|
327
328
|
* flow, or its schedule trigger naming that routine) — on only when the routine was approved and running. `moved`:
|
|
328
329
|
* the table may go only when every row it had (or the ones `rows` counts) arrived in `into`: the rows there that
|
|
@@ -366,7 +367,7 @@ const HISTORY_RULES = {
|
|
|
366
367
|
...Object.fromEntries(Object.entries(CHAT_MOVES).map(([table, moved]) => [table, { moved }])),
|
|
367
368
|
action_ledger: { appendOnly: true }, ledger_seal: { appendOnly: true }, ledger_checkpoint: { appendOnly: true },
|
|
368
369
|
// v114: a finished run whose process witnesses have all exited keeps one summary row in place of them.
|
|
369
|
-
run_process: { compacted: { into: "run_process_summary", sum: "witnesses" } }, run_process_summary: {
|
|
370
|
+
run_process: { compacted: { into: "run_process_summary", sum: "witnesses" } }, run_process_summary: { summarizes: "run_process" },
|
|
370
371
|
// v114: single-destination delivery columns may be dropped only once their values are legacy receipts.
|
|
371
372
|
notification: { dropped: ["attempts", "last_attempt_at", "last_error", "delivered_at", "receipt", "claim_owner", "claim_expires_at"], carried: { into: "notification_delivery", destination: LEGACY_DESTINATION } },
|
|
372
373
|
notification_delivery: { receives: LEGACY_DESTINATION },
|
|
@@ -377,11 +378,36 @@ const HISTORY_RULES = {
|
|
|
377
378
|
fallback_config: { retired: true }, fallback_cycle: { retired: true }, fallback_transition: { retired: true },
|
|
378
379
|
// v115: each routine becomes one scheduled flow and its schedule trigger.
|
|
379
380
|
flow: { fromRoutines: "flow" }, flow_trigger: { fromRoutines: "trigger" },
|
|
381
|
+
// v117 (D5): the lead's and the subagents' tables keep every row under their new names (mate_* → lead_*, teammate* →
|
|
382
|
+
// subagent*); a column renamed in a table that keeps its name keeps its values under the new one.
|
|
383
|
+
...Object.fromEntries(Object.entries(V117_RENAMED_TABLES).map(([old, now]) => [old, { moved: { into: now, where: "1" } }])),
|
|
384
|
+
...Object.fromEntries(V117_RENAMED_COLUMNS.filter(([table]) => !Object.values(V117_RENAMED_TABLES).includes(table)).map(([table, from, to]) => [table, { renamed: { [from]: to } }])),
|
|
380
385
|
};
|
|
381
386
|
/** The tables a migration may remove whole (v115's removed features). */
|
|
382
387
|
export const RETIRED_TABLES = Object.freeze(Object.keys(HISTORY_RULES).filter(name => HISTORY_RULES[name].retired));
|
|
383
388
|
const tableColumns = (db, name) => db.prepare("PRAGMA table_info(" + quote(name) + ")").all().map(r => String(r["name"]));
|
|
384
389
|
const plainValue = (_, v) => v instanceof Uint8Array ? Buffer.from(v).toString("hex") : typeof v === "bigint" ? String(v) : v;
|
|
390
|
+
const rowHash = (row) => createHash("sha256").update(JSON.stringify(Object.values(row), plainValue)).digest("hex");
|
|
391
|
+
const summaryRows = (db, name, columns) => db.prepare("SELECT " + columns.map(quote).join(",") + " FROM " + quote(name) + " ORDER BY run").iterate();
|
|
392
|
+
/** Keep every saved summary byte-identical. A new key must replace all witnesses saved for that same run. */
|
|
393
|
+
function keptSummaries(db, name, before, source) {
|
|
394
|
+
const saved = new Map(before?.summaries?.map(row => [row.run, row.hash]));
|
|
395
|
+
const witnesses = new Map(source?.compactedRuns?.map(row => [row.run, row.count]));
|
|
396
|
+
const from = HISTORY_RULES[name].summarizes, sum = HISTORY_RULES[from].compacted.sum;
|
|
397
|
+
const remaining = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(from)
|
|
398
|
+
? db.prepare("SELECT 1 FROM " + quote(from) + " WHERE run = ? LIMIT 1") : undefined;
|
|
399
|
+
for (const row of summaryRows(db, name, before?.columns ?? tableColumns(db, name))) {
|
|
400
|
+
const run = Number(row["run"]), hash = saved.get(run);
|
|
401
|
+
if (hash !== undefined) {
|
|
402
|
+
if (rowHash(row) !== hash)
|
|
403
|
+
return false;
|
|
404
|
+
saved.delete(run);
|
|
405
|
+
}
|
|
406
|
+
else if (!witnesses.has(run) || Number(row[sum]) !== witnesses.get(run) || !remaining || remaining.get(run))
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
return saved.size === 0;
|
|
410
|
+
}
|
|
385
411
|
/** Rows streamed into a sha256, never held together: through a rowid in rowid order, or a WITHOUT ROWID table whole. */
|
|
386
412
|
function rowsHash(db, name, columns, through) {
|
|
387
413
|
const select = "SELECT " + (through === undefined ? "" : 'rowid AS "rowid:", ') + columns.map(quote).join(",") + " FROM " + quote(name);
|
|
@@ -423,8 +449,13 @@ export function historySnapshot(db) {
|
|
|
423
449
|
t.received = receipts(db, name, rule.receives, columns.filter(column => column !== "notification" && column !== "destination"));
|
|
424
450
|
if (rule?.appendOnly || rule?.fromRoutines)
|
|
425
451
|
t.hash = rowsHash(db, name, columns, t.last).hash;
|
|
426
|
-
if (rule?.compacted)
|
|
452
|
+
if (rule?.compacted) {
|
|
427
453
|
t.summed = summed(db, rule.compacted);
|
|
454
|
+
t.compactedRuns = db.prepare("SELECT run, count(*) AS n FROM " + quote(name) + " GROUP BY run ORDER BY run").all()
|
|
455
|
+
.map(r => ({ run: Number(r["run"]), count: Number(r["n"]) }));
|
|
456
|
+
}
|
|
457
|
+
if (rule?.summarizes)
|
|
458
|
+
t.summaries = [...summaryRows(db, name, columns)].map(row => ({ run: Number(row["run"]), hash: rowHash(row) }));
|
|
428
459
|
if (rule?.fromRoutines)
|
|
429
460
|
t.routines = savedRoutines(db);
|
|
430
461
|
if (rule?.moved)
|
|
@@ -500,7 +531,8 @@ export function changedHistory(db, before) {
|
|
|
500
531
|
return move === undefined || t.moved === undefined || arrived(db, move) - t.moved.found !== t.moved.rows;
|
|
501
532
|
}
|
|
502
533
|
const rule = HISTORY_RULES[t.name], present = new Set(tableColumns(db, t.name));
|
|
503
|
-
|
|
534
|
+
const kept = (c) => present.has(c) || (rule?.renamed?.[c] !== undefined && present.has(rule.renamed[c]));
|
|
535
|
+
if (t.columns.some(c => !kept(c) && (!rule?.dropped?.includes(c) || (t.nonNull?.[c] !== 0 && !accounted(rule, t)))))
|
|
504
536
|
return true;
|
|
505
537
|
const columns = t.columns.filter(c => present.has(c));
|
|
506
538
|
if (!t.rowid) {
|
|
@@ -515,9 +547,13 @@ export function changedHistory(db, before) {
|
|
|
515
547
|
const after = rowsHash(db, t.name, columns, t.last);
|
|
516
548
|
return after.count !== t.count || after.hash !== t.hash;
|
|
517
549
|
}
|
|
550
|
+
if (rule?.summarizes)
|
|
551
|
+
return !keptSummaries(db, t.name, t, before.find(one => one.name === rule.summarizes));
|
|
518
552
|
const r = db.prepare("SELECT count(*) AS n, coalesce(max(rowid),0) AS last FROM " + quote(t.name)).get(), count = Number(r["n"]), last = Number(r["last"]);
|
|
519
553
|
if (rule?.compacted)
|
|
520
|
-
return count > t.count || last > t.last || t.count - count !== summed(db, rule.compacted) - (t.summed ?? 0)
|
|
554
|
+
return count > t.count || last > t.last || t.count - count !== summed(db, rule.compacted) - (t.summed ?? 0)
|
|
555
|
+
// A newly created summary table has no digest of its own; check its keys here too.
|
|
556
|
+
|| (!before.some(one => one.name === rule.compacted.into) && tables.has(rule.compacted.into) && !keptSummaries(db, rule.compacted.into, undefined, t));
|
|
521
557
|
if (rule?.receives) {
|
|
522
558
|
const added = gained.get(t.name)?.count ?? 0;
|
|
523
559
|
return count - t.count !== added || (added > 0 && added !== owed.get(t.name)?.count) || last < t.last;
|
|
@@ -531,8 +567,9 @@ async function rehearse(j, system, source) {
|
|
|
531
567
|
chmodSync(copy, 0o600);
|
|
532
568
|
try {
|
|
533
569
|
let db = new (sqlite().DatabaseSync)(copy, { readOnly: true });
|
|
534
|
-
// Rows already pointing nowhere before the update are the install's own; only ones the migration makes refuse.
|
|
535
|
-
|
|
570
|
+
// Rows already pointing nowhere before the update are the install's own; only ones the migration makes refuse. (By
|
|
571
|
+
// today's table names: a renamed table's old orphan is the same row under its new name, orphanKey.)
|
|
572
|
+
const orphans = () => new Set([...db.prepare("PRAGMA foreign_key_check").iterate()].map(row => orphanKey(row)));
|
|
536
573
|
const before = historySnapshot(db), orphaned = orphans();
|
|
537
574
|
db.close();
|
|
538
575
|
await system.rehearse(j.to.dist, copy);
|
package/dist/work-index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Store, type TaskState } from './store.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type AssignmentSnapshot } from './assignment.js';
|
|
3
3
|
import type { WorkAction, WorkSummaryAccess } from './work-summary.js';
|
|
4
4
|
import type { WorkStatus, WorkView } from './workspace-ui.js';
|
|
5
5
|
import { type Ask, type AskChip } from './needs-you.js';
|
|
@@ -37,6 +37,7 @@ export type WorkIndexItem = {
|
|
|
37
37
|
/** The viewer's own lead took it on (lead-voice.ts): "<name> is on it.", by the name they gave it, read now. */
|
|
38
38
|
lead?: string;
|
|
39
39
|
};
|
|
40
|
+
/** `root`: the evidence root, so a result whose checks were Off can read the release check that covers it. */
|
|
40
41
|
export type WorkIndexOptions = {
|
|
41
42
|
view?: WorkView;
|
|
42
43
|
limit?: number;
|
|
@@ -44,6 +45,7 @@ export type WorkIndexOptions = {
|
|
|
44
45
|
project?: string | null;
|
|
45
46
|
state?: TaskState;
|
|
46
47
|
leadId?: string;
|
|
48
|
+
root?: string;
|
|
47
49
|
};
|
|
48
50
|
/** How the list is grouped: the Needs you rows by their ask, then building, then the rest. */
|
|
49
51
|
export type WorkIndexGroup = Ask | 'building' | 'rest';
|
|
@@ -78,6 +80,9 @@ export declare class WorkIndexCursorError extends Error {
|
|
|
78
80
|
* Project counters share the page's admitted project/state filter.
|
|
79
81
|
* Cursors bind the admitted scope, project and view, never broaden access. */
|
|
80
82
|
export declare function workIndexPage(store: Store, now: Date, access: WorkSummaryAccess, options?: WorkIndexOptions): WorkIndexPage;
|
|
83
|
+
/** An exact family lookup through the list's saved-fact projection. It remains
|
|
84
|
+
* permission-bound and bypasses pagination, never action-time verification. */
|
|
85
|
+
export declare function workIndexTask(store: Store, taskId: string, now: Date, access: WorkSummaryAccess, root?: string): WorkIndexItem | null;
|
|
81
86
|
export declare function workCountsByProject(store: Store, now: Date, access: WorkSummaryAccess): WorkProjectCounts[];
|
|
82
87
|
/** Families whose headline is Ready for review, newest first: the Tasks
|
|
83
88
|
* list's own rows, so a completed family (root or any revision), a failed
|