spur-board 0.54.1 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-Dd1yi1dh.mjs → chunk-3DiqeT6s.mjs} +1 -1
- package/dist/{chunk-CaWf-PGm.mjs → chunk-COsEkoTY.mjs} +2 -2
- package/dist/{chunk-C0avjvF7.mjs → chunk-DdX2rQDT.mjs} +1 -0
- package/dist/cli.mjs +3 -3
- package/dist/client.mjs +1 -1
- package/dist/daemon.mjs +116 -23
- package/dist/mcp.mjs +3 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as errorEnvelopeSchema, Q as errorContextSchema, S as renderJsonError, X as ERRORS, c as tokenRequestStatusSchema, o as tokenRequestResultSchema, tt as successEnvelopeSchema } from "./chunk-
|
|
1
|
+
import { $ as errorEnvelopeSchema, Q as errorContextSchema, S as renderJsonError, X as ERRORS, c as tokenRequestStatusSchema, o as tokenRequestResultSchema, tt as successEnvelopeSchema } from "./chunk-DdX2rQDT.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as buildCatalogSnapshot, ct as plainHttpAllowed, st as configSchema, y as OPERATIONS } from "./chunk-
|
|
2
|
-
import { o as CliError, t as fetchCatalogVersion } from "./chunk-
|
|
1
|
+
import { _ as buildCatalogSnapshot, ct as plainHttpAllowed, st as configSchema, y as OPERATIONS } from "./chunk-DdX2rQDT.mjs";
|
|
2
|
+
import { o as CliError, t as fetchCatalogVersion } from "./chunk-3DiqeT6s.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
|
@@ -1943,6 +1943,7 @@ const taskWhySchema = z.strictObject({
|
|
|
1943
1943
|
column: z.enum(COLUMN_IDS).describe("Column the dispatcher works from: the shadow column in shadow mode."),
|
|
1944
1944
|
dispatcher: z.enum(DISPATCHER_MODES).nullable().describe("The project's dispatcher mode; null when the project is not configured."),
|
|
1945
1945
|
holds: z.array(z.enum(TASK_HOLDS)).describe("What holds the dispatcher from acting on the task; empty when nothing does."),
|
|
1946
|
+
heldBy: z.array(blockIdSchema).min(1).optional().describe("Blocks of the open cycle-limit or course-check items holding the task; absent when none does."),
|
|
1946
1947
|
gates: z.array(z.strictObject({
|
|
1947
1948
|
column: z.enum(COLUMN_IDS).describe("Board column."),
|
|
1948
1949
|
enabled: z.boolean().describe("Whether the column is enabled in the project."),
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { W as actorIdSchema, X as ERRORS, a as requestHashOf, ft as SLACK_BOT_SCOPES, lt as requiredSecretKeys, r as remoteDoctorReportSchema, st as configSchema, tt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS, v as roleCanUseOperation, y as OPERATIONS } from "./chunk-
|
|
1
|
+
import { W as actorIdSchema, X as ERRORS, a as requestHashOf, ft as SLACK_BOT_SCOPES, lt as requiredSecretKeys, r as remoteDoctorReportSchema, st as configSchema, tt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS, v as roleCanUseOperation, y as OPERATIONS } from "./chunk-DdX2rQDT.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
|
|
3
|
-
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-
|
|
4
|
-
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-
|
|
3
|
+
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-3DiqeT6s.mjs";
|
|
4
|
+
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-COsEkoTY.mjs";
|
|
5
5
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
6
6
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
7
7
|
import { homedir, hostname, userInfo } from "node:os";
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-
|
|
1
|
+
import { a as requestTokenEnrollment, i as requestSkillReload, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./chunk-3DiqeT6s.mjs";
|
|
2
2
|
export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestSkillReload, requestTokenEnrollment };
|
package/dist/daemon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as EVENT_KINDS, B as sessionFactsSchema, D as interactionRefSchema, E as inboundEventSchema, F as isExternalAuthor, G as encodeActorId, H as JIRA_PROJECT_KEY, I as parseRingMarker, J as parseRef$1, K as errorCodeOf, L as prFactsSchema, M as REVIEW_STATES, N as SESSION_HEALTH_STATES, O as messageRefSchema, P as SESSION_STATUSES, R as prRefSchema, T as conversationRefSchema, U as REF_NUMBER, V as ticketFactsSchema, W as actorIdSchema, X as ERRORS, Y as taskKeySchema, Z as err, _ as buildCatalogSnapshot, a as requestHashOf, at as DEFAULT_SLACK_COMMAND, b as turnHandedSchema, c as tokenRequestStatusSchema, ct as plainHttpAllowed, d as AdapterError, dt as DISPATCHER_MODES, et as ok, f as batchSchema, ft as SLACK_BOT_SCOPES, g as trackerSourceId, h as sourceCursorSchema, i as TOKEN_REQUEST_LIMITS, j as eventPayloadSchemas, k as userIdSchema, l as BOARD_TICK_MS, lt as requiredSecretKeys, m as prSourceId, n as doctorReportSchema, o as tokenRequestResultSchema, ot as RESERVED_PROJECT, p as entityRefSchema, q as parseActorId, rt as DEFAULT_LINK, s as tokenRequestSchema, st as configSchema, t as assertNever, tt as successEnvelopeSchema, ut as COLUMN_IDS, v as roleCanUseOperation, w as SPACE_IDS, x as renderHttpProblem, y as OPERATIONS, z as ringMarker } from "./chunk-
|
|
1
|
+
import { A as EVENT_KINDS, B as sessionFactsSchema, D as interactionRefSchema, E as inboundEventSchema, F as isExternalAuthor, G as encodeActorId, H as JIRA_PROJECT_KEY, I as parseRingMarker, J as parseRef$1, K as errorCodeOf, L as prFactsSchema, M as REVIEW_STATES, N as SESSION_HEALTH_STATES, O as messageRefSchema, P as SESSION_STATUSES, R as prRefSchema, T as conversationRefSchema, U as REF_NUMBER, V as ticketFactsSchema, W as actorIdSchema, X as ERRORS, Y as taskKeySchema, Z as err, _ as buildCatalogSnapshot, a as requestHashOf, at as DEFAULT_SLACK_COMMAND, b as turnHandedSchema, c as tokenRequestStatusSchema, ct as plainHttpAllowed, d as AdapterError, dt as DISPATCHER_MODES, et as ok, f as batchSchema, ft as SLACK_BOT_SCOPES, g as trackerSourceId, h as sourceCursorSchema, i as TOKEN_REQUEST_LIMITS, j as eventPayloadSchemas, k as userIdSchema, l as BOARD_TICK_MS, lt as requiredSecretKeys, m as prSourceId, n as doctorReportSchema, o as tokenRequestResultSchema, ot as RESERVED_PROJECT, p as entityRefSchema, q as parseActorId, rt as DEFAULT_LINK, s as tokenRequestSchema, st as configSchema, t as assertNever, tt as successEnvelopeSchema, ut as COLUMN_IDS, v as roleCanUseOperation, w as SPACE_IDS, x as renderHttpProblem, y as OPERATIONS, z as ringMarker } from "./chunk-DdX2rQDT.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-DAMwWWmT.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -8902,17 +8902,23 @@ function exchangeBody(payload) {
|
|
|
8902
8902
|
}
|
|
8903
8903
|
/**
|
|
8904
8904
|
* A distinct semantic ring. Transport retries reuse this row and its text. A restarted series
|
|
8905
|
-
* (`series` > 0)
|
|
8906
|
-
*
|
|
8907
|
-
*
|
|
8905
|
+
* (`series` > 0) and a ring after the task was archived (`archives` > 0) get their own keys.
|
|
8906
|
+
* Every ring of a key whose earlier rows all finished (a move or archive killed them, or a
|
|
8907
|
+
* handover reset the series after they were delivered) takes the next handover generation
|
|
8908
|
+
* `:h<n>`, `n` being how many rows the key has, so a finished ring never blocks its successor.
|
|
8909
|
+
* A row of the key still waiting in the outbox is returned instead. Unsuffixed keys stay as
|
|
8910
|
+
* before.
|
|
8908
8911
|
*/
|
|
8909
8912
|
async function enqueueDoorbell(trx, input) {
|
|
8910
8913
|
const series = input.series ?? 0;
|
|
8911
8914
|
const archives = input.archives ?? 0;
|
|
8912
|
-
const
|
|
8915
|
+
const base = `doorbell:${String(input.notificationId)}:${input.session}:${String(input.ring)}${series > 0 ? `:s${String(series)}` : ""}${archives > 0 ? `:a${String(archives)}` : ""}`;
|
|
8916
|
+
const rows = await trx.selectFrom("outbox").select(["id", "state"]).where((eb) => eb.or([eb("dedupe_key", "=", base), eb.and([eb("dedupe_key", ">", `${base}:h`), eb("dedupe_key", "<", `${base}:i`)])])).execute();
|
|
8917
|
+
const waiting = rows.find((row) => row.state === "pending" || row.state === "in_flight");
|
|
8918
|
+
if (waiting !== void 0) return waiting.id;
|
|
8913
8919
|
const row = await insertOutbox(trx, {
|
|
8914
8920
|
kind: "doorbell",
|
|
8915
|
-
dedupeKey:
|
|
8921
|
+
dedupeKey: rows.length > 0 ? `${base}:h${String(rows.length)}` : base,
|
|
8916
8922
|
payload: {
|
|
8917
8923
|
notificationId: input.notificationId,
|
|
8918
8924
|
ring: input.ring,
|
|
@@ -8925,6 +8931,16 @@ async function enqueueDoorbell(trx, input) {
|
|
|
8925
8931
|
if (row.id === null) throw new Error("Doorbell cannot be blocked by gateway scan");
|
|
8926
8932
|
return row.id;
|
|
8927
8933
|
}
|
|
8934
|
+
/**
|
|
8935
|
+
* Moves the doorbell rows of the worker's notifications on task `taskId`, other than `exceptId`,
|
|
8936
|
+
* that wait in the outbox to the front, in outbox id order, ahead of rings reconcile enqueues
|
|
8937
|
+
* next. A row in retry backoff (`attempts > 0`) keeps its wait.
|
|
8938
|
+
*/
|
|
8939
|
+
async function promoteWorkerDoorbells(trx, taskId, at, exceptId) {
|
|
8940
|
+
let others = trx.selectFrom("notification").select("id").where("task_id", "=", taskId).where("role", "=", "worker");
|
|
8941
|
+
if (exceptId !== void 0) others = others.where("id", "!=", exceptId);
|
|
8942
|
+
await trx.updateTable("outbox").set({ next_at: at.toISOString() }).where("kind", "=", "doorbell").where("state", "=", "pending").where("attempts", "=", 0).where(sql`json_extract(payload, '$.notificationId')`, "in", others).execute();
|
|
8943
|
+
}
|
|
8928
8944
|
/** The key holds no install time, so a session gets at most one reload message per version. */
|
|
8929
8945
|
function skillReloadKey(version, session) {
|
|
8930
8946
|
return `doorbell:skill-reload:${version}:${session}`;
|
|
@@ -9395,7 +9411,17 @@ async function raiseItem(trx, input) {
|
|
|
9395
9411
|
return raiseItemWith(trx, input, enqueueFeedLine);
|
|
9396
9412
|
}
|
|
9397
9413
|
/**
|
|
9414
|
+
* Whether the course check `item` forwarded a note: a worker `answer` notification on its block.
|
|
9415
|
+
* The note's first ring then releases the held rings (`releaseAfterCourseNote`).
|
|
9416
|
+
*/
|
|
9417
|
+
async function courseNoted(trx, item) {
|
|
9418
|
+
if (item.block_id === null) return false;
|
|
9419
|
+
return await trx.selectFrom("notification").select("id").where("block_id", "=", item.block_id).where("role", "=", "worker").where("kind", "=", "answer").executeTakeFirst() !== void 0;
|
|
9420
|
+
}
|
|
9421
|
+
/**
|
|
9398
9422
|
* Clear an item once; the edit waits for its line and is cancelled with a stale pending line.
|
|
9423
|
+
* A course check cleared without a note moves the worker's held rings on its task that wait in
|
|
9424
|
+
* the outbox to the front, so they keep their order.
|
|
9399
9425
|
* The journal names `actor`, `system` unless an actor's action cleared it. `writeEdit`, when
|
|
9400
9426
|
* given, writes the line's edit instead of the resolved one.
|
|
9401
9427
|
*/
|
|
@@ -9403,6 +9429,7 @@ async function clearItem(trx, itemId, at, actor = "system", writeEdit) {
|
|
|
9403
9429
|
if ((await trx.selectFrom("operator_item").selectAll().where("id", "=", itemId).executeTakeFirstOrThrow()).cleared_at !== null) return;
|
|
9404
9430
|
const item = await trx.updateTable("operator_item").set({ cleared_at: at.toISOString() }).where("id", "=", itemId).returningAll().executeTakeFirstOrThrow();
|
|
9405
9431
|
await journal$3(trx, item, "from_you_cleared", at, void 0, actor);
|
|
9432
|
+
if (item.kind === "course_check" && item.task_id !== null && !await courseNoted(trx, item)) await promoteWorkerDoorbells(trx, item.task_id, at);
|
|
9406
9433
|
if (item.line_outbox_id === null) return;
|
|
9407
9434
|
if (writeEdit !== void 0) {
|
|
9408
9435
|
await writeEdit(item, item.line_outbox_id);
|
|
@@ -9591,6 +9618,9 @@ async function applyDoorbellPolicy(trx, event, at) {
|
|
|
9591
9618
|
case "block_removed":
|
|
9592
9619
|
await registerRemovedNotification(trx, event.block, at);
|
|
9593
9620
|
return;
|
|
9621
|
+
case "course_note":
|
|
9622
|
+
await registerCourseNoteNotification(trx, event, at);
|
|
9623
|
+
return;
|
|
9594
9624
|
case "block_closed_by_addressee":
|
|
9595
9625
|
case "task_comment": return;
|
|
9596
9626
|
default: assertNever(event);
|
|
@@ -9750,6 +9780,40 @@ async function registerAnswerNotification(trx, input, at) {
|
|
|
9750
9780
|
}).onConflict((oc) => oc.column("source_key").doNothing()).execute();
|
|
9751
9781
|
}
|
|
9752
9782
|
/**
|
|
9783
|
+
* Register the worker's ring for a course note: the curator's answer to a course check, copied to
|
|
9784
|
+
* the task. It names the course block, and until its first ring is delivered the worker's other
|
|
9785
|
+
* rings on the task stay held (`courseHold`), so the worker reads the decision first.
|
|
9786
|
+
*/
|
|
9787
|
+
async function registerCourseNoteNotification(trx, input, at) {
|
|
9788
|
+
await trx.insertInto("notification").values({
|
|
9789
|
+
source_key: `course-note:${String(input.comment.id)}`,
|
|
9790
|
+
kind: "answer",
|
|
9791
|
+
task_id: input.block.task_id,
|
|
9792
|
+
block_id: input.block.id,
|
|
9793
|
+
comment_id: input.comment.id,
|
|
9794
|
+
revision: input.comment.revision,
|
|
9795
|
+
role: "worker",
|
|
9796
|
+
author_session: null,
|
|
9797
|
+
recipient_session: null,
|
|
9798
|
+
next_at: at.toISOString(),
|
|
9799
|
+
last_outbox_id: null,
|
|
9800
|
+
acked_at: null,
|
|
9801
|
+
exhausted_at: null,
|
|
9802
|
+
created_at: at.toISOString()
|
|
9803
|
+
}).onConflict((oc) => oc.column("source_key").doNothing()).execute();
|
|
9804
|
+
}
|
|
9805
|
+
/** Course-check items of any state, as subquery rows of their block ids. */
|
|
9806
|
+
const courseBlocks = (eb) => eb.selectFrom("operator_item").select("operator_item.block_id").where("operator_item.kind", "=", "course_check").where("operator_item.block_id", "is not", null);
|
|
9807
|
+
/**
|
|
9808
|
+
* Whether a worker notification is held by a course check on its task. Two holds apply: while a
|
|
9809
|
+
* `course_check` item is active, and, once it clears with a note, until the note's first ring is
|
|
9810
|
+
* delivered to any session, so the note rings first. A course note is a worker `answer`
|
|
9811
|
+
* notification on a course check's block. Other roles and `cycle_limit` items hold no ring.
|
|
9812
|
+
*/
|
|
9813
|
+
function courseHold(eb) {
|
|
9814
|
+
return eb.and([eb("notification.role", "=", "worker"), eb.or([eb.exists(eb.selectFrom("operator_item").select("operator_item.id").where("operator_item.kind", "=", "course_check").whereRef("operator_item.task_id", "=", "notification.task_id").where("operator_item.cleared_at", "is", null)), eb.and([eb.not(eb.and([eb("notification.kind", "=", "answer"), eb("notification.block_id", "in", courseBlocks(eb))])), eb.exists(eb.selectFrom("notification as note").select("note.id").whereRef("note.task_id", "=", "notification.task_id").where("note.role", "=", "worker").where("note.kind", "=", "answer").where("note.block_id", "in", courseBlocks(eb)).where("note.rings", "=", 0).where("note.acked_at", "is", null).where("note.exhausted_at", "is", null).where((inner) => inner.not(inner.exists(inner.selectFrom("outbox").select("outbox.id").where(sql`+outbox.state`, "=", "done").where("outbox.dedupe_key", ">", sql`'doorbell:' || ${sql.ref("note.id")} || ':'`).where("outbox.dedupe_key", "<", sql`'doorbell:' || ${sql.ref("note.id")} || ';'`)))))])])]);
|
|
9815
|
+
}
|
|
9816
|
+
/**
|
|
9753
9817
|
* Moves a block to a new addressee, for `block.escalate` and for a ring series that ended: the
|
|
9754
9818
|
* journal row, the old notification's end, the new one and the Slack thread, in the caller's
|
|
9755
9819
|
* transaction.
|
|
@@ -9890,6 +9954,7 @@ async function restartNotification(trx, sourceKey, at) {
|
|
|
9890
9954
|
async function endNotification(trx, n, task, end) {
|
|
9891
9955
|
const { session, reason, at, config } = end;
|
|
9892
9956
|
await trx.updateTable("notification").set({ exhausted_at: at.toISOString() }).where("id", "=", n.id).execute();
|
|
9957
|
+
if (n.rings === 0) await releaseAfterCourseNote(trx, n, at);
|
|
9893
9958
|
const addressee = parseAddressee(n.role);
|
|
9894
9959
|
if (n.kind === "block" && addressee.kind === "curator") await moveBlockToAddressee(trx, {
|
|
9895
9960
|
task,
|
|
@@ -9971,9 +10036,12 @@ async function ringText(trx, n, task, ring) {
|
|
|
9971
10036
|
const block = await trx.selectFrom("block").select("unblocked_by").where("id", "=", blockId).executeTakeFirstOrThrow();
|
|
9972
10037
|
return `${task.key} block B${String(blockId)} was removed by ${block.unblocked_by ?? "system"}; see board task ${task.key} ${suffix}`;
|
|
9973
10038
|
}
|
|
9974
|
-
/**
|
|
10039
|
+
/**
|
|
10040
|
+
* Notifications reconcile looks at: unacked, not exhausted, due, on a task not archived, and not
|
|
10041
|
+
* held by a course check (`courseHold`).
|
|
10042
|
+
*/
|
|
9975
10043
|
function dueNotifications(db, at) {
|
|
9976
|
-
return db.selectFrom("notification").innerJoin("task", "task.id", "notification.task_id").where("task.membership", "!=", "archived").where("notification.acked_at", "is", null).where("notification.exhausted_at", "is", null).where("notification.next_at", "<=", at.toISOString());
|
|
10044
|
+
return db.selectFrom("notification").innerJoin("task", "task.id", "notification.task_id").where("task.membership", "!=", "archived").where("notification.acked_at", "is", null).where("notification.exhausted_at", "is", null).where("notification.next_at", "<=", at.toISOString()).where((eb) => eb.not(courseHold(eb)));
|
|
9977
10045
|
}
|
|
9978
10046
|
/**
|
|
9979
10047
|
* Reconciles due notifications in their own transaction. With none due it opens no transaction;
|
|
@@ -10048,7 +10116,6 @@ async function reconcileDoorbells(trx, at, config) {
|
|
|
10048
10116
|
}
|
|
10049
10117
|
const raised = await trx.selectFrom("operator_item").select((eb) => eb.fn.max("raise_no").as("series")).where("item_key", "=", exhaustedItemKey(n)).executeTakeFirst();
|
|
10050
10118
|
const archived = await trx.selectFrom("event").select((eb) => eb.fn.countAll().as("count")).where("task_id", "=", n.task_id).where("kind", "=", "task_archived").executeTakeFirst();
|
|
10051
|
-
const killed = keepsRings ? await trx.selectFrom("outbox").select((eb) => eb.fn.countAll().as("count")).where("kind", "=", "doorbell").where("state", "=", "dead").where(sql`json_extract(payload, '$.notificationId')`, "=", n.id).executeTakeFirst() : void 0;
|
|
10052
10119
|
const ring = rings + 1;
|
|
10053
10120
|
const text = await ringText(trx, n, task, ring);
|
|
10054
10121
|
const outboxId = await enqueueDoorbell(trx, {
|
|
@@ -10058,8 +10125,7 @@ async function reconcileDoorbells(trx, at, config) {
|
|
|
10058
10125
|
text,
|
|
10059
10126
|
at,
|
|
10060
10127
|
series: raised?.series ?? 0,
|
|
10061
|
-
archives: archived?.count ?? 0
|
|
10062
|
-
moves: killed?.count ?? 0
|
|
10128
|
+
archives: archived?.count ?? 0
|
|
10063
10129
|
});
|
|
10064
10130
|
await trx.updateTable("notification").set({ last_outbox_id: outboxId }).where("id", "=", n.id).execute();
|
|
10065
10131
|
}
|
|
@@ -10107,12 +10173,23 @@ async function recordRingDelivery(trx, notificationId, ring, session, at, config
|
|
|
10107
10173
|
next_at: new Date(at.getTime() + (pauses[ring - 1] ?? 0)).toISOString(),
|
|
10108
10174
|
...n.kind === "removed" || n.kind === "turn_reminder" ? { acked_at: at.toISOString() } : {}
|
|
10109
10175
|
}).where("id", "=", notificationId).execute();
|
|
10176
|
+
if (ring === 1) await releaseAfterCourseNote(trx, n, at);
|
|
10110
10177
|
await journal$2(trx, n, "doorbell_rung", {
|
|
10111
10178
|
doorbell: `N${String(n.id)}`,
|
|
10112
10179
|
addressee: n.role,
|
|
10113
10180
|
attempt: ring
|
|
10114
10181
|
}, at);
|
|
10115
10182
|
}
|
|
10183
|
+
/**
|
|
10184
|
+
* Once a course note no longer holds (`courseHold`): its first ring delivered, or read or ended
|
|
10185
|
+
* before it rang. Moves the worker's other rings on the task that waited in the outbox to the
|
|
10186
|
+
* front (`promoteWorkerDoorbells`); `clearItem` does the same for a course check that clears
|
|
10187
|
+
* without a note.
|
|
10188
|
+
*/
|
|
10189
|
+
async function releaseAfterCourseNote(trx, n, at) {
|
|
10190
|
+
if (await trx.selectFrom("notification").select("id").where("id", "=", n.id).where("role", "=", "worker").where("kind", "=", "answer").where((eb) => eb("block_id", "in", courseBlocks(eb))).executeTakeFirst() === void 0) return;
|
|
10191
|
+
await promoteWorkerDoorbells(trx, n.task_id, at, n.id);
|
|
10192
|
+
}
|
|
10116
10193
|
/** True while the Spur source is blind: its stored session facts may no longer hold. */
|
|
10117
10194
|
async function spurBlind$1(trx) {
|
|
10118
10195
|
const state = await trx.selectFrom("source_state").select("blind_reason").where("source", "=", "spur").executeTakeFirst();
|
|
@@ -10124,6 +10201,7 @@ async function ringStillCurrent(trx, notificationId, sessionId, config) {
|
|
|
10124
10201
|
if (n === void 0 || n.acked_at !== null || n.exhausted_at !== null || n.recipient_session !== sessionId) return "dead";
|
|
10125
10202
|
const session = await selectNotificationRecipient(trx, n, config);
|
|
10126
10203
|
if (session?.id !== sessionId) return "dead";
|
|
10204
|
+
if (await trx.selectFrom("notification").select("id").where("id", "=", n.id).where(courseHold).executeTakeFirst() !== void 0) return "defer";
|
|
10127
10205
|
return recipientBusy(session) && !await spurBlind$1(trx) ? "defer" : "send";
|
|
10128
10206
|
}
|
|
10129
10207
|
/**
|
|
@@ -10150,6 +10228,7 @@ async function acknowledgeNotification(trx, input) {
|
|
|
10150
10228
|
if (!await notificationAddressedTo(trx, n, input.actor, input.config)) throw new CommandError("forbidden", "Only the addressed task role can acknowledge.");
|
|
10151
10229
|
for (const notice of notices) {
|
|
10152
10230
|
await trx.updateTable("notification").set({ acked_at: input.at.toISOString() }).where("id", "=", notice.id).execute();
|
|
10231
|
+
if (notice.rings === 0) await releaseAfterCourseNote(trx, notice, input.at);
|
|
10153
10232
|
await journal$2(trx, notice, "doorbell_read", { doorbell: `N${String(notice.id)}` }, input.at);
|
|
10154
10233
|
const item = await trx.selectFrom("operator_item").select("id").where("item_key", "=", exhaustedItemKey(notice)).where("cleared_at", "is", null).executeTakeFirst();
|
|
10155
10234
|
if (item !== void 0) await clearItem(trx, item.id, input.at);
|
|
@@ -11405,16 +11484,20 @@ async function openSystemBlock(trx, input) {
|
|
|
11405
11484
|
* Copies the answer to a course check to the task as a comment without a block, so the worker
|
|
11406
11485
|
* reads it in its inbox: the close reason, else `answer`, else the closing actor's newest comment
|
|
11407
11486
|
* on the block. A copied comment is named in the copy's `comment_added`, so its edits reach the
|
|
11408
|
-
* copy.
|
|
11487
|
+
* copy. The copy rings the worker, ahead of its other rings on the task (`course_note`). Returns
|
|
11488
|
+
* the copy, or undefined when there is no answer to copy.
|
|
11409
11489
|
*/
|
|
11410
11490
|
async function forwardCourseNote(trx, task, block, ctx, reason, given) {
|
|
11411
|
-
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11491
|
+
const answer = reason !== null ? void 0 : given ?? await trx.selectFrom("comment").select(["id", "text"]).where("block_id", "=", block.id).where("author", "=", ctx.actor).orderBy("id", "desc").executeTakeFirst();
|
|
11492
|
+
const text = reason ?? answer?.text;
|
|
11493
|
+
if (text === void 0) return void 0;
|
|
11494
|
+
const copy = await insertComment(trx, task, null, text, ctx, "worker", void 0, answer?.id);
|
|
11495
|
+
await applyDoorbellPolicy(trx, {
|
|
11496
|
+
kind: "course_note",
|
|
11497
|
+
block,
|
|
11498
|
+
comment: copy
|
|
11499
|
+
}, new Date(ctx.at));
|
|
11500
|
+
return copy;
|
|
11418
11501
|
}
|
|
11419
11502
|
/** The comments `forwardCourseNote` copied from comment `id`. */
|
|
11420
11503
|
async function forwardedCopies(trx, id) {
|
|
@@ -11446,8 +11529,9 @@ async function reviseComment(trx, task, comment, text, ctx) {
|
|
|
11446
11529
|
* Unblocks one block with its journal entry, thread close, doorbell close and item clears. An
|
|
11447
11530
|
* operator or agent close of a reconciled ledger block dismisses its item, so the condition
|
|
11448
11531
|
* raises again only once it changes; a `system` or archive close only clears it. An answer or a
|
|
11449
|
-
* close with a reason to a course check also goes to the worker as a task comment
|
|
11450
|
-
* the answer when the closing actor also
|
|
11532
|
+
* close with a reason to a course check also goes to the worker as a task comment that rings it
|
|
11533
|
+
* first, before the rings the check held; `answer` names the answer when the closing actor also
|
|
11534
|
+
* left a note after it.
|
|
11451
11535
|
*/
|
|
11452
11536
|
async function closeOpenBlock(trx, task, block, ctx, outcome, outcomeReason, answer) {
|
|
11453
11537
|
const updated = await trx.updateTable("block").set({
|
|
@@ -15023,14 +15107,21 @@ function createTaskQueries(deps) {
|
|
|
15023
15107
|
checksWaivedBy: null
|
|
15024
15108
|
};
|
|
15025
15109
|
const { gates, checksWaivedBy } = explainGates(read.input.facts, read.input.project);
|
|
15110
|
+
const holds = dispatchHolds(read.input);
|
|
15111
|
+
const heldBy = holds.includes("cycle_limit") ? await holdBlocks(trx, task.id) : [];
|
|
15026
15112
|
return {
|
|
15027
15113
|
...shared,
|
|
15028
15114
|
dispatcher: mode,
|
|
15029
|
-
holds
|
|
15115
|
+
holds,
|
|
15116
|
+
...heldBy.length === 0 ? {} : { heldBy },
|
|
15030
15117
|
gates,
|
|
15031
15118
|
checksWaivedBy
|
|
15032
15119
|
};
|
|
15033
15120
|
}
|
|
15121
|
+
/** The blocks of the active cycle-limit and course-check items that hold the task's turn. */
|
|
15122
|
+
async function holdBlocks(trx, taskId) {
|
|
15123
|
+
return (await trx.selectFrom("operator_item").select("block_id").where((eb) => eb.or([eb("item_key", "like", `${cycleKeyPrefix(taskId)}%`), eb("item_key", "like", `${courseKeyPrefix(taskId)}%`)])).where("cleared_at", "is", null).where("block_id", "is not", null).orderBy("id").execute()).flatMap((item) => item.block_id === null ? [] : [`B${String(item.block_id)}`]);
|
|
15124
|
+
}
|
|
15034
15125
|
const get = {
|
|
15035
15126
|
id: "task.get",
|
|
15036
15127
|
resolveTargets: (trx, input) => taskTarget(trx, taskKey(input.task)),
|
|
@@ -15103,6 +15194,7 @@ function createTaskQueries(deps) {
|
|
|
15103
15194
|
const notices = await trx.selectFrom("notification").selectAll().where("kind", "=", "answer").where("acked_at", "is", null).orderBy("id", "desc").execute();
|
|
15104
15195
|
const comments = [];
|
|
15105
15196
|
const seen = /* @__PURE__ */ new Set();
|
|
15197
|
+
const listed = /* @__PURE__ */ new Set();
|
|
15106
15198
|
for (const notice of notices) {
|
|
15107
15199
|
if (notice.comment_id === null || seen.has(notice.comment_id)) continue;
|
|
15108
15200
|
const task = await trx.selectFrom("task").selectAll().where("id", "=", notice.task_id).executeTakeFirst();
|
|
@@ -15111,6 +15203,7 @@ function createTaskQueries(deps) {
|
|
|
15111
15203
|
if (!await notificationAddressedTo(trx, notice, actor, config)) continue;
|
|
15112
15204
|
const comment = await trx.selectFrom("comment").selectAll().where("id", "=", notice.comment_id).executeTakeFirst();
|
|
15113
15205
|
if (comment === void 0 || comment.acked_revision === comment.revision) continue;
|
|
15206
|
+
listed.add(comment.id);
|
|
15114
15207
|
comments.push(commentView(comment, task));
|
|
15115
15208
|
}
|
|
15116
15209
|
const parsedActor = parseActorId(actor);
|
|
@@ -15121,7 +15214,7 @@ function createTaskQueries(deps) {
|
|
|
15121
15214
|
const taskComments = await trx.selectFrom("comment").selectAll().where("task_id", "in", [...tasksById.keys()]).where("block_id", "is", null).orderBy("id").execute();
|
|
15122
15215
|
for (const comment of taskComments) {
|
|
15123
15216
|
const task = tasksById.get(comment.task_id);
|
|
15124
|
-
if (task === void 0 || comment.author === actor || comment.acked_revision === comment.revision) continue;
|
|
15217
|
+
if (task === void 0 || listed.has(comment.id) || comment.author === actor || comment.acked_revision === comment.revision) continue;
|
|
15125
15218
|
comments.push(commentView(comment, task));
|
|
15126
15219
|
}
|
|
15127
15220
|
}
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as renderMcpError, X as ERRORS, y as OPERATIONS } from "./chunk-
|
|
2
|
-
import { o as CliError, r as requestOperation } from "./chunk-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-
|
|
1
|
+
import { C as renderMcpError, X as ERRORS, y as OPERATIONS } from "./chunk-DdX2rQDT.mjs";
|
|
2
|
+
import { o as CliError, r as requestOperation } from "./chunk-3DiqeT6s.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-COsEkoTY.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|