spur-board 0.24.0 → 0.26.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/cli.mjs +5 -4
- package/dist/{client-B1u-1YVS.mjs → client-DEwzucXx.mjs} +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{config-BuftCWGz.mjs → config-B8ZBFd_9.mjs} +2 -2
- package/dist/daemon.mjs +413 -199
- package/dist/mcp.mjs +4 -4
- package/dist/{src-lQGgnLLD.mjs → src-7fzumMWU.mjs} +31 -4
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as SLACK_BOT_SCOPES, P as ERRORS, U as configSchema, W as requiredSecretKeys, l as roleCanUseOperation, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-
|
|
2
|
-
import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-
|
|
1
|
+
import { G as SLACK_BOT_SCOPES, P as ERRORS, U as configSchema, W as requiredSecretKeys, l as roleCanUseOperation, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-7fzumMWU.mjs";
|
|
2
|
+
import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-DEwzucXx.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-B8ZBFd_9.mjs";
|
|
4
4
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
5
5
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
6
6
|
import { homedir, hostname, userInfo } from "node:os";
|
|
@@ -308,7 +308,8 @@ const remoteBaseIds = [
|
|
|
308
308
|
"link.rules",
|
|
309
309
|
"spur.api",
|
|
310
310
|
"spur.send",
|
|
311
|
-
"operator.path"
|
|
311
|
+
"operator.path",
|
|
312
|
+
"curator.sessions"
|
|
312
313
|
];
|
|
313
314
|
const remoteSlackIds = [
|
|
314
315
|
"slack.auth",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as errorContextSchema, I as errorEnvelopeSchema, L as successEnvelopeSchema, P as ERRORS, f as renderJsonError } from "./src-
|
|
1
|
+
import { F as errorContextSchema, I as errorEnvelopeSchema, L as successEnvelopeSchema, P as ERRORS, f as renderJsonError } from "./src-7fzumMWU.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { n as requestOperation, r as requestTokenEnrollment, t as fetchCatalogVersion } from "./client-DEwzucXx.mjs";
|
|
2
2
|
export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U as configSchema, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-
|
|
2
|
-
import { i as CliError, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { U as configSchema, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-7fzumMWU.mjs";
|
|
2
|
+
import { i as CliError, t as fetchCatalogVersion } from "./client-DEwzucXx.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";
|
package/dist/daemon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as errorCodeOf, C as SESSION_STATUSES, D as ticketFactsSchema, E as sessionFactsSchema, G as SLACK_BOT_SCOPES, H as RESERVED_PROJECT, L as successEnvelopeSchema, M as parseRef$1, N as taskKeySchema, O as actorIdSchema, P as ERRORS, S as SESSION_HEALTH_STATES, T as prRefSchema, U as configSchema, V as DEFAULT_SLACK_COMMAND, W as requiredSecretKeys, _ as interactionRefSchema, a as batchSchema, b as EVENT_KINDS, c as buildCatalogSnapshot, d as renderHttpProblem, g as inboundEventSchema, h as conversationRefSchema, i as AdapterError, j as parseActorId, k as encodeActorId, l as roleCanUseOperation, m as SPACE_IDS, n as BOARD_TICK_MS, o as entityRefSchema, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as messageRefSchema, w as prFactsSchema, x as eventPayloadSchemas, y as userIdSchema, z as DEFAULT_LINK } from "./src-
|
|
1
|
+
import { A as errorCodeOf, C as SESSION_STATUSES, D as ticketFactsSchema, E as sessionFactsSchema, G as SLACK_BOT_SCOPES, H as RESERVED_PROJECT, L as successEnvelopeSchema, M as parseRef$1, N as taskKeySchema, O as actorIdSchema, P as ERRORS, S as SESSION_HEALTH_STATES, T as prRefSchema, U as configSchema, V as DEFAULT_SLACK_COMMAND, W as requiredSecretKeys, _ as interactionRefSchema, a as batchSchema, b as EVENT_KINDS, c as buildCatalogSnapshot, d as renderHttpProblem, g as inboundEventSchema, h as conversationRefSchema, i as AdapterError, j as parseActorId, k as encodeActorId, l as roleCanUseOperation, m as SPACE_IDS, n as BOARD_TICK_MS, o as entityRefSchema, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as messageRefSchema, w as prFactsSchema, x as eventPayloadSchemas, y as userIdSchema, z as DEFAULT_LINK } from "./src-7fzumMWU.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, existsSync, fstatSync, fsyncSync, ftruncateSync, linkSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeSync } from "node:fs";
|
|
@@ -8382,15 +8382,17 @@ function renderBody(key, text) {
|
|
|
8382
8382
|
}
|
|
8383
8383
|
/**
|
|
8384
8384
|
* A distinct semantic ring. Transport retries reuse this row and its text. A restarted series
|
|
8385
|
-
* (`series` > 0)
|
|
8386
|
-
*
|
|
8385
|
+
* (`series` > 0), a ring after the task was archived (`archives` > 0) and a ring after a move
|
|
8386
|
+
* killed an earlier one (`moves` > 0) get their own keys, so a cancelled ring does not block its
|
|
8387
|
+
* replacement; unsuffixed keys stay as before.
|
|
8387
8388
|
*/
|
|
8388
8389
|
async function enqueueDoorbell(trx, input) {
|
|
8389
8390
|
const series = input.series ?? 0;
|
|
8390
8391
|
const archives = input.archives ?? 0;
|
|
8392
|
+
const moves = input.moves ?? 0;
|
|
8391
8393
|
const row = await insertOutbox(trx, {
|
|
8392
8394
|
kind: "doorbell",
|
|
8393
|
-
dedupeKey: `doorbell:${String(input.notificationId)}:${input.session}:${String(input.ring)}${series > 0 ? `:s${String(series)}` : ""}${archives > 0 ? `:a${String(archives)}` : ""}`,
|
|
8395
|
+
dedupeKey: `doorbell:${String(input.notificationId)}:${input.session}:${String(input.ring)}${series > 0 ? `:s${String(series)}` : ""}${archives > 0 ? `:a${String(archives)}` : ""}${moves > 0 ? `:m${String(moves)}` : ""}`,
|
|
8394
8396
|
payload: {
|
|
8395
8397
|
notificationId: input.notificationId,
|
|
8396
8398
|
ring: input.ring,
|
|
@@ -8684,18 +8686,6 @@ async function enqueueConversationClose(trx, input) {
|
|
|
8684
8686
|
closed_at: input.at.toISOString()
|
|
8685
8687
|
}).where("block_id", "=", input.blockId).where("state", "=", "open").execute();
|
|
8686
8688
|
}
|
|
8687
|
-
async function enqueueInboundDoorbell(trx, input) {
|
|
8688
|
-
await insertOutbox(trx, {
|
|
8689
|
-
kind: "doorbell",
|
|
8690
|
-
dedupeKey: input.key,
|
|
8691
|
-
payload: {
|
|
8692
|
-
session: input.session,
|
|
8693
|
-
text: input.text
|
|
8694
|
-
},
|
|
8695
|
-
parent: null,
|
|
8696
|
-
at: input.at
|
|
8697
|
-
});
|
|
8698
|
-
}
|
|
8699
8689
|
//#endregion
|
|
8700
8690
|
//#region ../core/src/app/feed.ts
|
|
8701
8691
|
/** The struck summary is capped so the edit stays one message part. */
|
|
@@ -8945,9 +8935,11 @@ const tokenRevokeMutation = {
|
|
|
8945
8935
|
//#endregion
|
|
8946
8936
|
//#region ../core/src/api/identity.ts
|
|
8947
8937
|
function sessionActor(project, session, config) {
|
|
8948
|
-
if (config.projects.filter((entry) => entry.spurProjects.some((spur) => spur.name === project)).length !== 1) throw new CommandError("forbidden", "Unknown session project.");
|
|
8949
8938
|
const actor = actorIdSchema.safeParse(`agent:${project}/${session}`);
|
|
8950
8939
|
if (!actor.success) throw new CommandError("forbidden", "Invalid session identity.");
|
|
8940
|
+
const matches = config.projects.filter((entry) => entry.spurProjects.some((spur) => spur.name === project));
|
|
8941
|
+
if (matches.length === 0) throw new CommandError("forbidden", `Spur project "${project}" is not listed in any spurProjects in the Board's config.yaml (not Spur's spur.yaml), and inside a Spur session a token is not used. Ask the operator to add it under projects[].spurProjects there and restart the Board daemon, or run the command outside a Spur session.`);
|
|
8942
|
+
if (matches.length > 1) throw new CommandError("forbidden", `Spur project "${project}" is listed under several Board projects: ${matches.map((entry) => entry.id).join(", ")}. Ask the operator to keep it under one of them in the Board's config.yaml (not Spur's spur.yaml) and restart the Board daemon.`);
|
|
8951
8943
|
return actor.data;
|
|
8952
8944
|
}
|
|
8953
8945
|
/** Resolve the caller at the HTTP boundary; a session header always outranks a token. */
|
|
@@ -9150,21 +9142,121 @@ function listenApiServer(app, port) {
|
|
|
9150
9142
|
});
|
|
9151
9143
|
}
|
|
9152
9144
|
//#endregion
|
|
9145
|
+
//#region ../core/src/app/block-thread.ts
|
|
9146
|
+
function orchestrator(config, task) {
|
|
9147
|
+
const name = config.projects.find((project) => project.id === task.project)?.columns.find((column) => column.id === task.column)?.orchestrator;
|
|
9148
|
+
return name === void 0 || name === "none" ? null : name;
|
|
9149
|
+
}
|
|
9150
|
+
function authorRole(config, task, actor) {
|
|
9151
|
+
if (actor === "operator") return "operator";
|
|
9152
|
+
const parsed = parseActorId(actor);
|
|
9153
|
+
if (parsed?.actor === "agent" && config.projects.some((project) => project.spurProjects.some((spur) => spur.name === parsed.actorRef.project && spur.role === "operator"))) return "operator";
|
|
9154
|
+
if (parsed?.actor !== "agent") return "worker";
|
|
9155
|
+
if (parsed.actorRef.project === orchestrator(config, task)) return `orchestrator:${task.column}`;
|
|
9156
|
+
return parsed.actorRef.project === curatorProject(config, task.project) ? "curator" : "worker";
|
|
9157
|
+
}
|
|
9158
|
+
function personaRole(role) {
|
|
9159
|
+
const addressee = parseAddressee(role);
|
|
9160
|
+
switch (addressee.kind) {
|
|
9161
|
+
case "operator": return "board";
|
|
9162
|
+
case "worker": return "worker";
|
|
9163
|
+
case "curator":
|
|
9164
|
+
case "orchestrator": return "orchestrator";
|
|
9165
|
+
default: return assertNever(addressee);
|
|
9166
|
+
}
|
|
9167
|
+
}
|
|
9168
|
+
function personaFor(config, task, actor) {
|
|
9169
|
+
if (actor === "system") return {
|
|
9170
|
+
name: "board",
|
|
9171
|
+
role: "board"
|
|
9172
|
+
};
|
|
9173
|
+
if (actor === "operator") return {
|
|
9174
|
+
name: "operator",
|
|
9175
|
+
role: "board"
|
|
9176
|
+
};
|
|
9177
|
+
const parsed = parseActorId(actor);
|
|
9178
|
+
if (parsed?.actor !== "agent") throw new Error("Invalid actor");
|
|
9179
|
+
return {
|
|
9180
|
+
name: parsed.actorRef.project,
|
|
9181
|
+
role: personaRole(authorRole(config, task, actor))
|
|
9182
|
+
};
|
|
9183
|
+
}
|
|
9184
|
+
async function queueBlockOpen(trx, task, block, ctx, config) {
|
|
9185
|
+
if (authorRole(config, task, block.author) === "operator") return;
|
|
9186
|
+
const comments = await trx.selectFrom("comment").select(["id", "author"]).where("block_id", "=", block.id).orderBy("id").execute();
|
|
9187
|
+
if (await enqueueConversationOpen(trx, {
|
|
9188
|
+
blockId: block.id,
|
|
9189
|
+
commentId: comments[0]?.id ?? null,
|
|
9190
|
+
persona: personaFor(config, task, comments[0]?.author ?? block.author),
|
|
9191
|
+
at: new Date(ctx.at)
|
|
9192
|
+
}) === null) return;
|
|
9193
|
+
for (const comment of comments.slice(1)) await enqueueConversationReply(trx, {
|
|
9194
|
+
commentId: comment.id,
|
|
9195
|
+
persona: personaFor(config, task, comment.author),
|
|
9196
|
+
at: new Date(ctx.at)
|
|
9197
|
+
});
|
|
9198
|
+
}
|
|
9199
|
+
//#endregion
|
|
9153
9200
|
//#region ../core/src/app/doorbells.ts
|
|
9201
|
+
const UNANSWERED = "unanswered";
|
|
9154
9202
|
async function journal$2(trx, notification, kind, payload, at) {
|
|
9155
9203
|
await emit(trx, kind, (await trx.selectFrom("task").select("project").where("id", "=", notification.task_id).executeTakeFirstOrThrow()).project, notification.task_id, at.toISOString(), payload);
|
|
9156
9204
|
}
|
|
9157
|
-
/**
|
|
9205
|
+
/**
|
|
9206
|
+
* The one rule for who a board event rings. A doorbell means someone is waiting for your action,
|
|
9207
|
+
* so a party that caused the event, or that the Slack thread already reaches, gets no row.
|
|
9208
|
+
*/
|
|
9209
|
+
async function applyDoorbellPolicy(trx, event, at) {
|
|
9210
|
+
switch (event.kind) {
|
|
9211
|
+
case "block_opened":
|
|
9212
|
+
if (!(parseActorId(event.block.author)?.actor === "agent" && event.block.addressee_role === event.authorRole)) await registerBlockNotification(trx, event.block, at);
|
|
9213
|
+
return;
|
|
9214
|
+
case "block_escalated":
|
|
9215
|
+
await closeBlockNotification(trx, event.block.id, at);
|
|
9216
|
+
await registerBlockNotification(trx, event.block, at);
|
|
9217
|
+
return;
|
|
9218
|
+
case "answer":
|
|
9219
|
+
await registerAnswerNotification(trx, event, at);
|
|
9220
|
+
return;
|
|
9221
|
+
case "block_removed":
|
|
9222
|
+
await registerRemovedNotification(trx, event.block, at);
|
|
9223
|
+
return;
|
|
9224
|
+
case "block_closed_by_addressee":
|
|
9225
|
+
case "task_comment": return;
|
|
9226
|
+
default: assertNever(event);
|
|
9227
|
+
}
|
|
9228
|
+
}
|
|
9229
|
+
/** Register a block for its agent addressee; the Slack thread carries an operator's. */
|
|
9158
9230
|
async function registerBlockNotification(trx, block, at) {
|
|
9159
|
-
if (block.addressee_role
|
|
9231
|
+
if (block.addressee_role === "operator") return;
|
|
9160
9232
|
await trx.insertInto("notification").values({
|
|
9161
|
-
source_key: `block:${String(block.id)}
|
|
9233
|
+
source_key: `block:${String(block.id)}:${block.addressee_role}`,
|
|
9162
9234
|
kind: "block",
|
|
9163
9235
|
task_id: block.task_id,
|
|
9164
9236
|
block_id: block.id,
|
|
9165
9237
|
comment_id: null,
|
|
9166
9238
|
revision: null,
|
|
9167
|
-
role:
|
|
9239
|
+
role: block.addressee_role,
|
|
9240
|
+
author_session: null,
|
|
9241
|
+
recipient_session: null,
|
|
9242
|
+
next_at: at.toISOString(),
|
|
9243
|
+
last_outbox_id: null,
|
|
9244
|
+
acked_at: null,
|
|
9245
|
+
exhausted_at: null,
|
|
9246
|
+
created_at: at.toISOString()
|
|
9247
|
+
}).onConflict((oc) => oc.column("source_key").doNothing()).execute();
|
|
9248
|
+
}
|
|
9249
|
+
/** Register a one-ring notice that a block its addressee held was closed by someone else. */
|
|
9250
|
+
async function registerRemovedNotification(trx, block, at) {
|
|
9251
|
+
if (block.addressee_role === "operator") return;
|
|
9252
|
+
await trx.insertInto("notification").values({
|
|
9253
|
+
source_key: `removed:${String(block.id)}`,
|
|
9254
|
+
kind: "removed",
|
|
9255
|
+
task_id: block.task_id,
|
|
9256
|
+
block_id: block.id,
|
|
9257
|
+
comment_id: null,
|
|
9258
|
+
revision: null,
|
|
9259
|
+
role: block.addressee_role,
|
|
9168
9260
|
author_session: null,
|
|
9169
9261
|
recipient_session: null,
|
|
9170
9262
|
next_at: at.toISOString(),
|
|
@@ -9174,11 +9266,12 @@ async function registerBlockNotification(trx, block, at) {
|
|
|
9174
9266
|
created_at: at.toISOString()
|
|
9175
9267
|
}).onConflict((oc) => oc.column("source_key").doNothing()).execute();
|
|
9176
9268
|
}
|
|
9177
|
-
/** Register an answer or clarification for the
|
|
9178
|
-
async function registerAnswerNotification(trx, input) {
|
|
9179
|
-
if (input.authorRole !== "worker") return;
|
|
9269
|
+
/** Register an answer or clarification for the question's author, unless the author wrote it. */
|
|
9270
|
+
async function registerAnswerNotification(trx, input, at) {
|
|
9180
9271
|
const parsed = parseActorId(input.block.author);
|
|
9181
|
-
if (parsed?.actor !== "agent") return;
|
|
9272
|
+
if (parsed?.actor !== "agent" || input.actor === input.block.author) return;
|
|
9273
|
+
const actor = parseActorId(input.actor);
|
|
9274
|
+
if (resolvedByProject(input.authorRole) && actor?.actor === "agent" && actor.actorRef.project === parsed.actorRef.project) return;
|
|
9182
9275
|
await trx.insertInto("notification").values({
|
|
9183
9276
|
source_key: `comment:${String(input.commentId)}:${String(input.revision)}`,
|
|
9184
9277
|
kind: "answer",
|
|
@@ -9186,46 +9279,126 @@ async function registerAnswerNotification(trx, input) {
|
|
|
9186
9279
|
block_id: input.block.id,
|
|
9187
9280
|
comment_id: input.commentId,
|
|
9188
9281
|
revision: input.revision,
|
|
9189
|
-
role:
|
|
9282
|
+
role: input.authorRole,
|
|
9190
9283
|
author_session: parsed.actorRef.session,
|
|
9191
9284
|
recipient_session: null,
|
|
9192
|
-
next_at:
|
|
9285
|
+
next_at: at.toISOString(),
|
|
9193
9286
|
last_outbox_id: null,
|
|
9194
9287
|
acked_at: null,
|
|
9195
9288
|
exhausted_at: null,
|
|
9196
|
-
created_at:
|
|
9289
|
+
created_at: at.toISOString()
|
|
9197
9290
|
}).onConflict((oc) => oc.column("source_key").doNothing()).execute();
|
|
9198
9291
|
}
|
|
9292
|
+
/**
|
|
9293
|
+
* Moves a block to a new addressee, for `block.escalate` and for a ring series that ended: the
|
|
9294
|
+
* journal row, the old notification's end, the new one and the Slack thread, in the caller's
|
|
9295
|
+
* transaction.
|
|
9296
|
+
*/
|
|
9297
|
+
async function moveBlockToAddressee(trx, input) {
|
|
9298
|
+
const { task, block, to, reason, ctx, config } = input;
|
|
9299
|
+
const updated = await trx.updateTable("block").set({ addressee_role: to }).where("id", "=", block.id).returningAll().executeTakeFirstOrThrow();
|
|
9300
|
+
await emit(trx, "block_escalated", task.project, task.id, ctx.at, {
|
|
9301
|
+
block: `B${String(block.id)}`,
|
|
9302
|
+
from: block.addressee_role,
|
|
9303
|
+
to,
|
|
9304
|
+
...reason === void 0 ? {} : { reason }
|
|
9305
|
+
}, ctx.actor);
|
|
9306
|
+
await applyDoorbellPolicy(trx, {
|
|
9307
|
+
kind: "block_escalated",
|
|
9308
|
+
block: updated
|
|
9309
|
+
}, new Date(ctx.at));
|
|
9310
|
+
await queueBlockOpen(trx, task, updated, ctx, config);
|
|
9311
|
+
return updated;
|
|
9312
|
+
}
|
|
9313
|
+
async function sessionById(trx, id) {
|
|
9314
|
+
return trx.selectFrom("session_snapshot").selectAll().where("id", "=", id).executeTakeFirst();
|
|
9315
|
+
}
|
|
9199
9316
|
async function liveSession(trx, id) {
|
|
9200
|
-
const row = await trx
|
|
9317
|
+
const row = await sessionById(trx, id);
|
|
9201
9318
|
return row?.ended_at === null && row.state !== "killed" && row.state !== "stopped" ? row : void 0;
|
|
9202
9319
|
}
|
|
9203
|
-
/**
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9320
|
+
/** Spur lifecycle states of a session that can no longer read a ring. */
|
|
9321
|
+
const FINISHED_STATES = [
|
|
9322
|
+
"killed",
|
|
9323
|
+
"stopped",
|
|
9324
|
+
"errored",
|
|
9325
|
+
"completed"
|
|
9326
|
+
];
|
|
9327
|
+
/** Stricter than `liveSession`: a role resolved by Spur project must also be in Spur's list. */
|
|
9328
|
+
function liveInProject(session) {
|
|
9329
|
+
return session.ended_at === null && session.absent_since === null && !FINISHED_STATES.includes(session.state);
|
|
9213
9330
|
}
|
|
9214
|
-
/**
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9331
|
+
/** Roles whose recipient is any session of a configured Spur project, not one linked session. */
|
|
9332
|
+
function resolvedByProject(role) {
|
|
9333
|
+
const { kind } = parseAddressee(role);
|
|
9334
|
+
return kind === "curator" || kind === "orchestrator";
|
|
9335
|
+
}
|
|
9336
|
+
/**
|
|
9337
|
+
* Milliseconds of a stored time, or null for a missing or unreadable one. `Date.parse`, not text
|
|
9338
|
+
* order: ISO values with different fractions do not sort as text.
|
|
9339
|
+
*/
|
|
9340
|
+
function instant(value) {
|
|
9341
|
+
if (typeof value !== "string") return null;
|
|
9342
|
+
const ms = Date.parse(value);
|
|
9343
|
+
return Number.isNaN(ms) ? null : ms;
|
|
9344
|
+
}
|
|
9345
|
+
/** Orders later times first and missing times last. Compared, never subtracted. */
|
|
9346
|
+
function laterFirst(left, right) {
|
|
9347
|
+
const a = left ?? -Infinity;
|
|
9348
|
+
const b = right ?? -Infinity;
|
|
9349
|
+
return a > b ? -1 : a < b ? 1 : 0;
|
|
9350
|
+
}
|
|
9351
|
+
/**
|
|
9352
|
+
* The newest live session of a Spur project, then the most recently active, then by id. A row
|
|
9353
|
+
* with an unreadable time or detail stays eligible and sorts last on that time.
|
|
9354
|
+
*/
|
|
9355
|
+
async function bestProjectSession(trx, project) {
|
|
9356
|
+
if (project === null) return void 0;
|
|
9357
|
+
return (await trx.selectFrom("session_snapshot").selectAll().select(sql`CASE WHEN json_valid(detail) THEN json_extract(detail, '$.lastActivityAt') END`.as("last_activity")).where("spur_project", "=", project).where("ended_at", "is", null).where("absent_since", "is", null).where("state", "not in", FINISHED_STATES).execute()).sort((left, right) => laterFirst(instant(left.first_seen), instant(right.first_seen)) || laterFirst(instant(left.last_activity), instant(right.last_activity)) || (left.id < right.id ? -1 : 1))[0];
|
|
9358
|
+
}
|
|
9359
|
+
/**
|
|
9360
|
+
* The live session that a curator block on a board project rings, or undefined when the project
|
|
9361
|
+
* has no curator or the curator has no live session. `board doctor` reports the same choice.
|
|
9362
|
+
*/
|
|
9363
|
+
async function curatorSession(trx, config, projectId) {
|
|
9364
|
+
return bestProjectSession(trx, curatorProject(config, projectId));
|
|
9365
|
+
}
|
|
9366
|
+
/** The newest live session linked to a task in a role. */
|
|
9367
|
+
async function linkedSession(trx, taskId, role) {
|
|
9368
|
+
const links = await trx.selectFrom("link").select("session_id").where("task_id", "=", taskId).where("entity", "=", "session").where("role", "=", role).where("banned", "=", 0).orderBy("created_at", "desc").execute();
|
|
9223
9369
|
for (const link of links) {
|
|
9224
9370
|
if (link.session_id === null) continue;
|
|
9225
9371
|
const session = await liveSession(trx, link.session_id);
|
|
9226
9372
|
if (session !== void 0) return session;
|
|
9227
9373
|
}
|
|
9228
9374
|
}
|
|
9375
|
+
async function taskProject(trx, taskId) {
|
|
9376
|
+
return (await trx.selectFrom("task").select("project").where("id", "=", taskId).executeTakeFirstOrThrow()).project;
|
|
9377
|
+
}
|
|
9378
|
+
/** The Spur project orchestrating a column; null when no agent project does. */
|
|
9379
|
+
function columnOrchestratorProject(config, projectId, column) {
|
|
9380
|
+
const name = config.projects.find((project) => project.id === projectId)?.columns.find((entry) => entry.id === column)?.orchestrator;
|
|
9381
|
+
return name === void 0 || name === "none" || name === "operator" ? null : name;
|
|
9382
|
+
}
|
|
9383
|
+
/** Select the current live recipient for a semantic notification. */
|
|
9384
|
+
async function selectNotificationRecipient(trx, n, config) {
|
|
9385
|
+
const addressee = parseAddressee(n.role);
|
|
9386
|
+
switch (addressee.kind) {
|
|
9387
|
+
case "curator": return curatorSession(trx, config, await taskProject(trx, n.task_id));
|
|
9388
|
+
case "orchestrator": {
|
|
9389
|
+
const author = n.author_session === null ? void 0 : await sessionById(trx, n.author_session);
|
|
9390
|
+
if (author !== void 0 && liveInProject(author)) return author;
|
|
9391
|
+
return await linkedSession(trx, n.task_id, "orchestrator") ?? bestProjectSession(trx, columnOrchestratorProject(config, await taskProject(trx, n.task_id), addressee.column));
|
|
9392
|
+
}
|
|
9393
|
+
case "worker":
|
|
9394
|
+
case "operator": {
|
|
9395
|
+
const author = n.author_session === null ? void 0 : await liveSession(trx, n.author_session);
|
|
9396
|
+
if (author !== void 0 || addressee.kind === "operator") return author;
|
|
9397
|
+
return linkedSession(trx, n.task_id, "worker");
|
|
9398
|
+
}
|
|
9399
|
+
default: return assertNever(addressee);
|
|
9400
|
+
}
|
|
9401
|
+
}
|
|
9229
9402
|
/** The operator item kind raised when a notification's rings are exhausted. */
|
|
9230
9403
|
function exhaustedItemKind(n) {
|
|
9231
9404
|
return n.kind === "answer" ? "answer_undelivered" : "worker_not_reading";
|
|
@@ -9246,11 +9419,49 @@ async function restartNotification(trx, sourceKey, at) {
|
|
|
9246
9419
|
}).where("source_key", "=", sourceKey).where("acked_at", "is", null).where("exhausted_at", "is not", null).returning("id").executeTakeFirst() === void 0) throw new CommandError("retry_not_applicable", "The doorbell was read or is still ringing; close the item instead.");
|
|
9247
9420
|
}
|
|
9248
9421
|
/**
|
|
9249
|
-
* Ends a ring
|
|
9250
|
-
*
|
|
9251
|
-
*
|
|
9252
|
-
|
|
9253
|
-
|
|
9422
|
+
* Ends a notification's ring series. A curator block moves to the operator; a removal or a ring
|
|
9423
|
+
* with no session to name ends alone; anything else raises the operator item, whose Retry restarts
|
|
9424
|
+
* the series (`restartNotification`). Every end journals `doorbell_undelivered`.
|
|
9425
|
+
*/
|
|
9426
|
+
async function endNotification(trx, n, task, end) {
|
|
9427
|
+
const { session, reason, at, config } = end;
|
|
9428
|
+
await trx.updateTable("notification").set({ exhausted_at: at.toISOString() }).where("id", "=", n.id).execute();
|
|
9429
|
+
const addressee = parseAddressee(n.role);
|
|
9430
|
+
if (n.kind === "block" && addressee.kind === "curator") await moveBlockToAddressee(trx, {
|
|
9431
|
+
task,
|
|
9432
|
+
block: await trx.selectFrom("block").selectAll().where("id", "=", n.block_id).executeTakeFirstOrThrow(),
|
|
9433
|
+
to: "operator",
|
|
9434
|
+
reason,
|
|
9435
|
+
ctx: {
|
|
9436
|
+
actor: "system",
|
|
9437
|
+
at: at.toISOString()
|
|
9438
|
+
},
|
|
9439
|
+
config
|
|
9440
|
+
});
|
|
9441
|
+
else if (n.kind !== "removed" && session !== null) {
|
|
9442
|
+
const blockRef = `block B${String(n.block_id)} on ${task.key}`;
|
|
9443
|
+
const answer = `Answer to ${blockRef} was not`;
|
|
9444
|
+
const holder = `${addressee.kind} ${session}`;
|
|
9445
|
+
await raiseItem(trx, {
|
|
9446
|
+
itemKey: exhaustedItemKey(n),
|
|
9447
|
+
kind: exhaustedItemKind(n),
|
|
9448
|
+
text: reason === UNANSWERED ? n.kind === "answer" ? `${answer} read` : `${holder} is not reading ${blockRef}` : n.kind === "answer" ? `${answer} delivered: ${reason}` : `${holder} did not get ${blockRef}: ${reason}`,
|
|
9449
|
+
url: taskUrl(task, config),
|
|
9450
|
+
taskId: task.id,
|
|
9451
|
+
blockId: n.block_id,
|
|
9452
|
+
at
|
|
9453
|
+
});
|
|
9454
|
+
}
|
|
9455
|
+
await journal$2(trx, n, "doorbell_undelivered", {
|
|
9456
|
+
doorbell: `N${String(n.id)}`,
|
|
9457
|
+
reason
|
|
9458
|
+
}, at);
|
|
9459
|
+
}
|
|
9460
|
+
/**
|
|
9461
|
+
* Ends a ring Spur will not take (a permanent rejection, or no answer for the retry window). A
|
|
9462
|
+
* ring that is no longer its notification's last row (the recipient changed while it was in
|
|
9463
|
+
* flight) ends alone. An inbound author ring has no notification: it ends like an author found
|
|
9464
|
+
* unavailable at enqueue.
|
|
9254
9465
|
*/
|
|
9255
9466
|
async function ringUndelivered(trx, input) {
|
|
9256
9467
|
const { at, reason } = input;
|
|
@@ -9274,21 +9485,24 @@ async function ringUndelivered(trx, input) {
|
|
|
9274
9485
|
}
|
|
9275
9486
|
const n = await trx.selectFrom("notification").selectAll().where("id", "=", input.notificationId).executeTakeFirst();
|
|
9276
9487
|
if (n === void 0 || n.acked_at !== null || n.exhausted_at !== null || n.last_outbox_id !== input.outboxId) return;
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
text: n.kind === "answer" ? `Answer to block B${String(n.block_id)} on ${task.key} was not delivered: ${reason}` : `worker ${input.session} did not get block B${String(n.block_id)} on ${task.key}: ${reason}`,
|
|
9283
|
-
url: taskUrl(task, input.config),
|
|
9284
|
-
taskId: task.id,
|
|
9285
|
-
blockId: n.block_id,
|
|
9286
|
-
at
|
|
9488
|
+
await endNotification(trx, n, await trx.selectFrom("task").selectAll().where("id", "=", n.task_id).executeTakeFirstOrThrow(), {
|
|
9489
|
+
session: input.session,
|
|
9490
|
+
reason,
|
|
9491
|
+
at,
|
|
9492
|
+
config: input.config
|
|
9287
9493
|
});
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9494
|
+
}
|
|
9495
|
+
/** Why a notification with no recipient ends now, or null when it stays due for a next session. */
|
|
9496
|
+
function noRecipientEnd(n) {
|
|
9497
|
+
if (n.kind === "removed" || n.kind === "answer" && n.role === "operator") return "no live addressee";
|
|
9498
|
+
return n.kind === "block" && n.role === "curator" ? "no live curator session" : null;
|
|
9499
|
+
}
|
|
9500
|
+
/** A ring never carries comment or reason text: only where to look. */
|
|
9501
|
+
async function ringText(trx, n, task, ring) {
|
|
9502
|
+
const suffix = `(N${String(n.id)}-${String(ring)})`;
|
|
9503
|
+
if (n.kind !== "removed") return `${task.key} block B${String(n.block_id)}: check board inbox ${suffix}`;
|
|
9504
|
+
const block = await trx.selectFrom("block").select("unblocked_by").where("id", "=", n.block_id).executeTakeFirstOrThrow();
|
|
9505
|
+
return `${task.key} block B${String(n.block_id)} was removed by ${block.unblocked_by ?? "system"}; see board task ${task.key} ${suffix}`;
|
|
9292
9506
|
}
|
|
9293
9507
|
/** Notifications reconcile looks at: unacked, not exhausted, due, on a task not archived. */
|
|
9294
9508
|
function dueNotifications(db, at) {
|
|
@@ -9306,11 +9520,19 @@ async function reconcileDueDoorbells(store, config, at) {
|
|
|
9306
9520
|
async function reconcileDoorbells(trx, at, config) {
|
|
9307
9521
|
const due = await dueNotifications(trx, at).selectAll("notification").orderBy("notification.id").execute();
|
|
9308
9522
|
for (const n of due) {
|
|
9309
|
-
const session = await selectNotificationRecipient(trx, n);
|
|
9523
|
+
const session = await selectNotificationRecipient(trx, n, config);
|
|
9524
|
+
const keepsRings = resolvedByProject(n.role);
|
|
9310
9525
|
if (session === void 0) {
|
|
9311
|
-
|
|
9526
|
+
const reason = noRecipientEnd(n);
|
|
9527
|
+
if (reason !== null) await endNotification(trx, n, await trx.selectFrom("task").selectAll().where("id", "=", n.task_id).executeTakeFirstOrThrow(), {
|
|
9528
|
+
session: null,
|
|
9529
|
+
reason,
|
|
9530
|
+
at,
|
|
9531
|
+
config
|
|
9532
|
+
});
|
|
9533
|
+
else if (n.recipient_session !== null) await trx.updateTable("notification").set({
|
|
9312
9534
|
recipient_session: null,
|
|
9313
|
-
rings: 0,
|
|
9535
|
+
rings: keepsRings ? n.rings : 0,
|
|
9314
9536
|
last_outbox_id: null
|
|
9315
9537
|
}).where("id", "=", n.id).execute();
|
|
9316
9538
|
continue;
|
|
@@ -9323,11 +9545,11 @@ async function reconcileDoorbells(trx, at, config) {
|
|
|
9323
9545
|
state: "dead",
|
|
9324
9546
|
last_error: "recipient changed"
|
|
9325
9547
|
}).where("id", "=", lastOutbox).where("state", "=", "pending").execute();
|
|
9326
|
-
rings = 0;
|
|
9548
|
+
if (!keepsRings) rings = 0;
|
|
9327
9549
|
lastOutbox = null;
|
|
9328
9550
|
await trx.updateTable("notification").set({
|
|
9329
9551
|
recipient_session: session.id,
|
|
9330
|
-
rings
|
|
9552
|
+
rings,
|
|
9331
9553
|
last_outbox_id: null
|
|
9332
9554
|
}).where("id", "=", n.id).execute();
|
|
9333
9555
|
}
|
|
@@ -9336,28 +9558,20 @@ async function reconcileDoorbells(trx, at, config) {
|
|
|
9336
9558
|
if (row?.state === "pending" || row?.state === "in_flight") continue;
|
|
9337
9559
|
}
|
|
9338
9560
|
const task = await trx.selectFrom("task").selectAll().where("id", "=", n.task_id).executeTakeFirstOrThrow();
|
|
9339
|
-
const itemKey = exhaustedItemKey(n);
|
|
9340
9561
|
if (rings >= 3) {
|
|
9341
|
-
await
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
taskId: task.id,
|
|
9347
|
-
blockId: n.block_id,
|
|
9348
|
-
at
|
|
9562
|
+
await endNotification(trx, n, task, {
|
|
9563
|
+
session: session.id,
|
|
9564
|
+
reason: UNANSWERED,
|
|
9565
|
+
at,
|
|
9566
|
+
config
|
|
9349
9567
|
});
|
|
9350
|
-
await trx.updateTable("notification").set({ exhausted_at: at.toISOString() }).where("id", "=", n.id).execute();
|
|
9351
|
-
await journal$2(trx, n, "doorbell_undelivered", {
|
|
9352
|
-
doorbell: `N${String(n.id)}`,
|
|
9353
|
-
reason: "unanswered"
|
|
9354
|
-
}, at);
|
|
9355
9568
|
continue;
|
|
9356
9569
|
}
|
|
9357
|
-
const raised = await trx.selectFrom("operator_item").select((eb) => eb.fn.max("raise_no").as("series")).where("item_key", "=",
|
|
9570
|
+
const raised = await trx.selectFrom("operator_item").select((eb) => eb.fn.max("raise_no").as("series")).where("item_key", "=", exhaustedItemKey(n)).executeTakeFirst();
|
|
9358
9571
|
const archived = await trx.selectFrom("event").select((eb) => eb.fn.countAll().as("count")).where("task_id", "=", n.task_id).where("kind", "=", "task_archived").executeTakeFirst();
|
|
9572
|
+
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;
|
|
9359
9573
|
const ring = rings + 1;
|
|
9360
|
-
const text =
|
|
9574
|
+
const text = await ringText(trx, n, task, ring);
|
|
9361
9575
|
const outboxId = await enqueueDoorbell(trx, {
|
|
9362
9576
|
notificationId: n.id,
|
|
9363
9577
|
ring,
|
|
@@ -9365,7 +9579,8 @@ async function reconcileDoorbells(trx, at, config) {
|
|
|
9365
9579
|
text,
|
|
9366
9580
|
at,
|
|
9367
9581
|
series: raised?.series ?? 0,
|
|
9368
|
-
archives: archived?.count ?? 0
|
|
9582
|
+
archives: archived?.count ?? 0,
|
|
9583
|
+
moves: killed?.count ?? 0
|
|
9369
9584
|
});
|
|
9370
9585
|
await trx.updateTable("notification").set({ last_outbox_id: outboxId }).where("id", "=", n.id).execute();
|
|
9371
9586
|
}
|
|
@@ -9381,7 +9596,8 @@ async function recordRingDelivery(trx, notificationId, ring, session, at, config
|
|
|
9381
9596
|
];
|
|
9382
9597
|
await trx.updateTable("notification").set({
|
|
9383
9598
|
rings: ring,
|
|
9384
|
-
next_at: new Date(at.getTime() + (pauses[ring - 1] ?? 0)).toISOString()
|
|
9599
|
+
next_at: new Date(at.getTime() + (pauses[ring - 1] ?? 0)).toISOString(),
|
|
9600
|
+
...n.kind === "removed" ? { acked_at: at.toISOString() } : {}
|
|
9385
9601
|
}).where("id", "=", notificationId).execute();
|
|
9386
9602
|
await journal$2(trx, n, "doorbell_rung", {
|
|
9387
9603
|
doorbell: `N${String(n.id)}`,
|
|
@@ -9390,10 +9606,10 @@ async function recordRingDelivery(trx, notificationId, ring, session, at, config
|
|
|
9390
9606
|
}, at);
|
|
9391
9607
|
}
|
|
9392
9608
|
/** Confirm that a queued ring still belongs to a live, idle, unread recipient. */
|
|
9393
|
-
async function ringStillCurrent(trx, notificationId, sessionId) {
|
|
9609
|
+
async function ringStillCurrent(trx, notificationId, sessionId, config) {
|
|
9394
9610
|
const n = await trx.selectFrom("notification").selectAll().where("id", "=", notificationId).executeTakeFirst();
|
|
9395
9611
|
if (n === void 0 || n.acked_at !== null || n.exhausted_at !== null || n.recipient_session !== sessionId) return "dead";
|
|
9396
|
-
const session = await selectNotificationRecipient(trx, n);
|
|
9612
|
+
const session = await selectNotificationRecipient(trx, n, config);
|
|
9397
9613
|
if (session?.id !== sessionId) return "dead";
|
|
9398
9614
|
return session.state === "working" ? "defer" : "send";
|
|
9399
9615
|
}
|
|
@@ -9417,7 +9633,7 @@ async function acknowledgeNotification(trx, input) {
|
|
|
9417
9633
|
const notices = await query.orderBy("id", "desc").execute();
|
|
9418
9634
|
const n = notices[0];
|
|
9419
9635
|
if (n === void 0) return false;
|
|
9420
|
-
if (!await notificationAddressedTo(trx, n, input.actor)) throw new CommandError("forbidden", "Only the addressed task role can acknowledge.");
|
|
9636
|
+
if (!await notificationAddressedTo(trx, n, input.actor, input.config)) throw new CommandError("forbidden", "Only the addressed task role can acknowledge.");
|
|
9421
9637
|
for (const notice of notices) {
|
|
9422
9638
|
await trx.updateTable("notification").set({ acked_at: input.at.toISOString() }).where("id", "=", notice.id).execute();
|
|
9423
9639
|
await journal$2(trx, notice, "doorbell_read", { doorbell: `N${String(notice.id)}` }, input.at);
|
|
@@ -9426,13 +9642,30 @@ async function acknowledgeNotification(trx, input) {
|
|
|
9426
9642
|
}
|
|
9427
9643
|
return true;
|
|
9428
9644
|
}
|
|
9429
|
-
/**
|
|
9430
|
-
async function notificationAddressedTo(trx, n, actor) {
|
|
9645
|
+
/** Decides who may list and acknowledge an inbox notice, by the role it is addressed to. */
|
|
9646
|
+
async function notificationAddressedTo(trx, n, actor, config) {
|
|
9431
9647
|
const parsed = parseActorId(actor);
|
|
9432
9648
|
if (parsed?.actor !== "agent") return false;
|
|
9433
|
-
const
|
|
9434
|
-
const
|
|
9435
|
-
|
|
9649
|
+
const { project, session } = parsed.actorRef;
|
|
9650
|
+
const addressee = parseAddressee(n.role);
|
|
9651
|
+
switch (addressee.kind) {
|
|
9652
|
+
case "curator": return project === curatorProject(config, await taskProject(trx, n.task_id));
|
|
9653
|
+
case "orchestrator": return project === columnOrchestratorProject(config, await taskProject(trx, n.task_id), addressee.column) || await hasLiveLink(trx, n.task_id, "orchestrator", session);
|
|
9654
|
+
case "operator": return session === n.author_session;
|
|
9655
|
+
case "worker": return workerNotificationAddressedTo(trx, n, session, config);
|
|
9656
|
+
default: return assertNever(addressee);
|
|
9657
|
+
}
|
|
9658
|
+
}
|
|
9659
|
+
async function sessionLink(trx, taskId, role, session) {
|
|
9660
|
+
return trx.selectFrom("link").select("id").where("task_id", "=", taskId).where("entity", "=", "session").where("role", "=", role).where("banned", "=", 0).where("session_id", "=", session).executeTakeFirst();
|
|
9661
|
+
}
|
|
9662
|
+
async function hasLiveLink(trx, taskId, role, session) {
|
|
9663
|
+
return await sessionLink(trx, taskId, role, session) !== void 0 && await liveSession(trx, session) !== void 0;
|
|
9664
|
+
}
|
|
9665
|
+
/** The selected worker while it lives; before the first ring, the author or a linked worker. */
|
|
9666
|
+
async function workerNotificationAddressedTo(trx, n, session, config) {
|
|
9667
|
+
if (n.recipient_session === null) return session === n.author_session || await sessionLink(trx, n.task_id, "worker", session) !== void 0;
|
|
9668
|
+
return await liveSession(trx, n.recipient_session) !== void 0 ? session === n.recipient_session : (await selectNotificationRecipient(trx, n, config))?.id === session;
|
|
9436
9669
|
}
|
|
9437
9670
|
async function closeBlockNotification(trx, blockId, at) {
|
|
9438
9671
|
const closed = await trx.updateTable("notification").set({ acked_at: at.toISOString() }).where("block_id", "=", blockId).where("kind", "=", "block").where("acked_at", "is", null).returning(["kind", "source_key"]).execute();
|
|
@@ -9553,59 +9786,6 @@ function commentView(comment, task) {
|
|
|
9553
9786
|
async function journal$1(trx, task, ctx, kind, payload) {
|
|
9554
9787
|
await emit(trx, kind, task.project, task.id, ctx.at, payload, ctx.actor);
|
|
9555
9788
|
}
|
|
9556
|
-
function orchestrator(config, task) {
|
|
9557
|
-
const name = config.projects.find((project) => project.id === task.project)?.columns.find((column) => column.id === task.column)?.orchestrator;
|
|
9558
|
-
return name === void 0 || name === "none" ? null : name;
|
|
9559
|
-
}
|
|
9560
|
-
function authorRole(config, task, actor) {
|
|
9561
|
-
if (actor === "operator") return "operator";
|
|
9562
|
-
const parsed = parseActorId(actor);
|
|
9563
|
-
if (parsed?.actor === "agent" && config.projects.some((project) => project.spurProjects.some((spur) => spur.name === parsed.actorRef.project && spur.role === "operator"))) return "operator";
|
|
9564
|
-
if (parsed?.actor !== "agent") return "worker";
|
|
9565
|
-
if (parsed.actorRef.project === orchestrator(config, task)) return `orchestrator:${task.column}`;
|
|
9566
|
-
return parsed.actorRef.project === curatorProject(config, task.project) ? "curator" : "worker";
|
|
9567
|
-
}
|
|
9568
|
-
function personaRole(role) {
|
|
9569
|
-
const addressee = parseAddressee(role);
|
|
9570
|
-
switch (addressee.kind) {
|
|
9571
|
-
case "operator": return "board";
|
|
9572
|
-
case "worker": return "worker";
|
|
9573
|
-
case "curator":
|
|
9574
|
-
case "orchestrator": return "orchestrator";
|
|
9575
|
-
default: return assertNever(addressee);
|
|
9576
|
-
}
|
|
9577
|
-
}
|
|
9578
|
-
function personaFor(config, task, actor) {
|
|
9579
|
-
if (actor === "system") return {
|
|
9580
|
-
name: "board",
|
|
9581
|
-
role: "board"
|
|
9582
|
-
};
|
|
9583
|
-
if (actor === "operator") return {
|
|
9584
|
-
name: "operator",
|
|
9585
|
-
role: "board"
|
|
9586
|
-
};
|
|
9587
|
-
const parsed = parseActorId(actor);
|
|
9588
|
-
if (parsed?.actor !== "agent") throw new Error("Invalid actor");
|
|
9589
|
-
return {
|
|
9590
|
-
name: parsed.actorRef.project,
|
|
9591
|
-
role: personaRole(authorRole(config, task, actor))
|
|
9592
|
-
};
|
|
9593
|
-
}
|
|
9594
|
-
async function queueBlockOpen(trx, task, block, ctx, config) {
|
|
9595
|
-
if (authorRole(config, task, block.author) === "operator") return;
|
|
9596
|
-
const comments = await trx.selectFrom("comment").select(["id", "author"]).where("block_id", "=", block.id).orderBy("id").execute();
|
|
9597
|
-
if (await enqueueConversationOpen(trx, {
|
|
9598
|
-
blockId: block.id,
|
|
9599
|
-
commentId: comments[0]?.id ?? null,
|
|
9600
|
-
persona: personaFor(config, task, comments[0]?.author ?? block.author),
|
|
9601
|
-
at: new Date(ctx.at)
|
|
9602
|
-
}) === null) return;
|
|
9603
|
-
for (const comment of comments.slice(1)) await enqueueConversationReply(trx, {
|
|
9604
|
-
commentId: comment.id,
|
|
9605
|
-
persona: personaFor(config, task, comment.author),
|
|
9606
|
-
at: new Date(ctx.at)
|
|
9607
|
-
});
|
|
9608
|
-
}
|
|
9609
9789
|
async function hasWorker(trx, task) {
|
|
9610
9790
|
return await trx.selectFrom("link").select("id").where("task_id", "=", task.id).where("entity", "=", "session").where("role", "=", "worker").where("banned", "=", 0).executeTakeFirst() !== void 0;
|
|
9611
9791
|
}
|
|
@@ -9644,13 +9824,14 @@ async function addComment(trx, task, block, text, ctx, addressee, config, source
|
|
|
9644
9824
|
comment: commentId(row.id),
|
|
9645
9825
|
addressee
|
|
9646
9826
|
});
|
|
9647
|
-
|
|
9827
|
+
await applyDoorbellPolicy(trx, block === void 0 ? { kind: "task_comment" } : {
|
|
9828
|
+
kind: "answer",
|
|
9648
9829
|
block,
|
|
9649
9830
|
commentId: row.id,
|
|
9650
9831
|
revision: row.revision,
|
|
9651
9832
|
authorRole: authorRole(config, task, block.author),
|
|
9652
|
-
|
|
9653
|
-
});
|
|
9833
|
+
actor: ctx.actor
|
|
9834
|
+
}, new Date(ctx.at));
|
|
9654
9835
|
if (block !== void 0 && source === void 0) await enqueueConversationReply(trx, {
|
|
9655
9836
|
commentId: row.id,
|
|
9656
9837
|
persona: personaFor(config, task, ctx.actor),
|
|
@@ -9683,7 +9864,11 @@ async function openBlock(trx, task, type, reason, ctx, config) {
|
|
|
9683
9864
|
type,
|
|
9684
9865
|
addressee
|
|
9685
9866
|
});
|
|
9686
|
-
await
|
|
9867
|
+
await applyDoorbellPolicy(trx, {
|
|
9868
|
+
kind: "block_opened",
|
|
9869
|
+
block: row,
|
|
9870
|
+
authorRole: authorRole(config, task, ctx.actor)
|
|
9871
|
+
}, new Date(ctx.at));
|
|
9687
9872
|
return row;
|
|
9688
9873
|
}
|
|
9689
9874
|
/** Unblocks one block with its journal entry, thread close, doorbell close and item clears. */
|
|
@@ -9734,7 +9919,7 @@ async function recordInboundBlockMessage(trx, input) {
|
|
|
9734
9919
|
block: answered ? await closeOpenBlock(trx, task, block, ctx, "done", null) : block,
|
|
9735
9920
|
task,
|
|
9736
9921
|
answered,
|
|
9737
|
-
|
|
9922
|
+
authorRole: authorRole(input.config, task, block.author)
|
|
9738
9923
|
};
|
|
9739
9924
|
}
|
|
9740
9925
|
/** Uses the same revision and acknowledgment rule as the catalog comment.edit mutation. */
|
|
@@ -9757,13 +9942,14 @@ async function editInboundComment(trx, input) {
|
|
|
9757
9942
|
});
|
|
9758
9943
|
if (next.clarification && updated.block_id !== null) {
|
|
9759
9944
|
const block = await trx.selectFrom("block").selectAll().where("id", "=", updated.block_id).executeTakeFirstOrThrow();
|
|
9760
|
-
|
|
9945
|
+
await applyDoorbellPolicy(trx, {
|
|
9946
|
+
kind: "answer",
|
|
9761
9947
|
block,
|
|
9762
9948
|
commentId: updated.id,
|
|
9763
9949
|
revision: updated.revision,
|
|
9764
9950
|
authorRole: authorRole(input.config, task, block.author),
|
|
9765
|
-
|
|
9766
|
-
});
|
|
9951
|
+
actor: input.actor
|
|
9952
|
+
}, new Date(input.at));
|
|
9767
9953
|
}
|
|
9768
9954
|
return updated;
|
|
9769
9955
|
}
|
|
@@ -9827,16 +10013,13 @@ function createBlockMutations(config) {
|
|
|
9827
10013
|
if (!next.changed) return { block: blockView(block, task) };
|
|
9828
10014
|
const target = await authorizationTarget(trx, task, block);
|
|
9829
10015
|
if (!holdsBlock(config, ctx.actor, target)) return { block: blockView(block, task) };
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
block
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
await queueBlockOpen(trx, task, updated, ctx, config);
|
|
9838
|
-
await registerBlockNotification(trx, updated, new Date(ctx.at));
|
|
9839
|
-
return { block: blockView(updated, task) };
|
|
10016
|
+
return { block: blockView(await moveBlockToAddressee(trx, {
|
|
10017
|
+
task,
|
|
10018
|
+
block,
|
|
10019
|
+
to: next.addressee,
|
|
10020
|
+
ctx,
|
|
10021
|
+
config
|
|
10022
|
+
}), task) };
|
|
9840
10023
|
}
|
|
9841
10024
|
},
|
|
9842
10025
|
answer: {
|
|
@@ -9874,7 +10057,12 @@ function createBlockMutations(config) {
|
|
|
9874
10057
|
actor: ctx.actor
|
|
9875
10058
|
}));
|
|
9876
10059
|
if (input.mode === "withdraw") await addComment(trx, task, block, input.answer, ctx, block.addressee_role, config);
|
|
9877
|
-
|
|
10060
|
+
const updated = await closeOpenBlock(trx, task, block, ctx, decision.outcome, decision.outcomeReason);
|
|
10061
|
+
await applyDoorbellPolicy(trx, input.mode === "done" || holdsBlock(config, ctx.actor, await authorizationTarget(trx, task, block)) ? { kind: "block_closed_by_addressee" } : {
|
|
10062
|
+
kind: "block_removed",
|
|
10063
|
+
block: updated
|
|
10064
|
+
}, new Date(ctx.at));
|
|
10065
|
+
return { block: blockView(updated, task) };
|
|
9878
10066
|
}
|
|
9879
10067
|
},
|
|
9880
10068
|
add: {
|
|
@@ -9930,7 +10118,8 @@ function createBlockMutations(config) {
|
|
|
9930
10118
|
if (!await acknowledgeNotification(trx, {
|
|
9931
10119
|
blockId: found(await blockById(trx, entry.id)).id,
|
|
9932
10120
|
actor: ctx.actor,
|
|
9933
|
-
at: new Date(ctx.at)
|
|
10121
|
+
at: new Date(ctx.at),
|
|
10122
|
+
config
|
|
9934
10123
|
})) throw new CommandError("not_found", "No unread block notification.");
|
|
9935
10124
|
continue;
|
|
9936
10125
|
}
|
|
@@ -9941,7 +10130,8 @@ function createBlockMutations(config) {
|
|
|
9941
10130
|
commentId: comment.id,
|
|
9942
10131
|
revision,
|
|
9943
10132
|
actor: ctx.actor,
|
|
9944
|
-
at: new Date(ctx.at)
|
|
10133
|
+
at: new Date(ctx.at),
|
|
10134
|
+
config
|
|
9945
10135
|
});
|
|
9946
10136
|
await trx.updateTable("comment").set({ acked_revision: revision }).where("id", "=", comment.id).execute();
|
|
9947
10137
|
await journal$1(trx, task, ctx, "comment_acked", {
|
|
@@ -10459,7 +10649,7 @@ function createSender(options) {
|
|
|
10459
10649
|
};
|
|
10460
10650
|
}
|
|
10461
10651
|
if (c.body.kind === "doorbell" && c.body.payload.notificationId !== void 0) {
|
|
10462
|
-
const status = await ringStillCurrent(trx, c.body.payload.notificationId, c.body.payload.session);
|
|
10652
|
+
const status = await ringStillCurrent(trx, c.body.payload.notificationId, c.body.payload.session, options.config);
|
|
10463
10653
|
if (status === "dead") {
|
|
10464
10654
|
await kill(trx, [c.id], "notification no longer current");
|
|
10465
10655
|
return {
|
|
@@ -11418,7 +11608,7 @@ function createTaskQueries(config) {
|
|
|
11418
11608
|
const task = await trx.selectFrom("task").selectAll().where("id", "=", notice.task_id).executeTakeFirst();
|
|
11419
11609
|
if (task === void 0 || !projects.has(task.project)) continue;
|
|
11420
11610
|
seen.add(notice.comment_id);
|
|
11421
|
-
if (!await notificationAddressedTo(trx, notice, actor)) continue;
|
|
11611
|
+
if (!await notificationAddressedTo(trx, notice, actor, config)) continue;
|
|
11422
11612
|
const comment = await trx.selectFrom("comment").selectAll().where("id", "=", notice.comment_id).executeTakeFirst();
|
|
11423
11613
|
if (comment === void 0 || comment.acked_revision === comment.revision) continue;
|
|
11424
11614
|
comments.push(commentView(comment, task));
|
|
@@ -11560,6 +11750,20 @@ async function firstPollDone(db, config, completeSince) {
|
|
|
11560
11750
|
return [...doctorSources(config)].every((source) => blind.has(source) || completeSince.has(source));
|
|
11561
11751
|
}
|
|
11562
11752
|
/**
|
|
11753
|
+
* The curator of each board project and the live session its curator blocks ring, in config
|
|
11754
|
+
* order. It asks the doorbells for their choice rather than keeping a copy, so the doctor cannot
|
|
11755
|
+
* name one session while the rings go to another.
|
|
11756
|
+
*/
|
|
11757
|
+
async function curatorSessions(db, config) {
|
|
11758
|
+
const entries = [];
|
|
11759
|
+
for (const project of config.projects) entries.push({
|
|
11760
|
+
project: project.id,
|
|
11761
|
+
curator: curatorProject(config, project.id),
|
|
11762
|
+
session: (await curatorSession(db, config, project.id))?.id ?? null
|
|
11763
|
+
});
|
|
11764
|
+
return entries;
|
|
11765
|
+
}
|
|
11766
|
+
/**
|
|
11563
11767
|
* Called from an accepted observation's transaction after board and item reconciliation.
|
|
11564
11768
|
* The version marker and feed row share that transaction with the source-state update.
|
|
11565
11769
|
*/
|
|
@@ -12356,6 +12560,14 @@ function createObservationCore(deps) {
|
|
|
12356
12560
|
kind: "session",
|
|
12357
12561
|
id: link.session_id
|
|
12358
12562
|
}]) : [];
|
|
12563
|
+
const curators = config.projects.flatMap((project) => project.spurProjects.filter((spur) => spur.role === "curator").map((spur) => spur.name));
|
|
12564
|
+
if (source === "spur" && curators.length > 0) {
|
|
12565
|
+
const rows = await store.db.selectFrom("session_snapshot").select("id").where("spur_project", "in", curators).where("ended_at", "is", null).execute();
|
|
12566
|
+
sessions.push(...rows.map((row) => ({
|
|
12567
|
+
kind: "session",
|
|
12568
|
+
id: row.id
|
|
12569
|
+
})));
|
|
12570
|
+
}
|
|
12359
12571
|
const misses = await store.db.selectFrom("source_miss").selectAll().where("source", "=", source).execute();
|
|
12360
12572
|
return {
|
|
12361
12573
|
observe: {
|
|
@@ -12799,34 +13011,16 @@ async function skip(trx, input) {
|
|
|
12799
13011
|
async function linkedComment(trx, event) {
|
|
12800
13012
|
return trx.selectFrom("comment").selectAll().where("conversation_ref", "=", event.conversation).where("message_ref", "=", event.message).executeTakeFirst();
|
|
12801
13013
|
}
|
|
13014
|
+
/** The answer's notification is already registered; this raises the item when nobody can read it. */
|
|
12802
13015
|
async function ringAuthor(trx, input) {
|
|
12803
13016
|
const key = `doorbell:comment:${String(input.comment.id)}:revision:${String(input.comment.revision)}`;
|
|
12804
13017
|
const parsed = parseActorId(input.block.author);
|
|
12805
|
-
if (parsed?.actor === "agent")
|
|
12806
|
-
|
|
13018
|
+
if (parsed?.actor === "agent") {
|
|
13019
|
+
if (await selectNotificationRecipient(trx, {
|
|
12807
13020
|
task_id: input.task.id,
|
|
12808
|
-
role:
|
|
13021
|
+
role: input.authorRole,
|
|
12809
13022
|
author_session: parsed.actorRef.session
|
|
12810
|
-
});
|
|
12811
|
-
await registerAnswerNotification(trx, {
|
|
12812
|
-
block: input.block,
|
|
12813
|
-
commentId: input.comment.id,
|
|
12814
|
-
revision: input.comment.revision,
|
|
12815
|
-
authorRole: "worker",
|
|
12816
|
-
at: new Date(input.at)
|
|
12817
|
-
});
|
|
12818
|
-
if (recipient !== void 0) return;
|
|
12819
|
-
} else {
|
|
12820
|
-
const session = await trx.selectFrom("session_snapshot").select(["id", "ended_at"]).where("id", "=", parsed.actorRef.session).executeTakeFirst();
|
|
12821
|
-
if (session !== void 0 && session.ended_at === null) {
|
|
12822
|
-
await enqueueInboundDoorbell(trx, {
|
|
12823
|
-
key,
|
|
12824
|
-
session: session.id,
|
|
12825
|
-
text: `Answer for ${input.task.key} block B${String(input.block.id)}; read board task ${input.task.key}`,
|
|
12826
|
-
at: new Date(input.at)
|
|
12827
|
-
});
|
|
12828
|
-
return;
|
|
12829
|
-
}
|
|
13023
|
+
}, input.config) !== void 0) return;
|
|
12830
13024
|
}
|
|
12831
13025
|
await journal(trx, {
|
|
12832
13026
|
kind: "doorbell_undelivered",
|
|
@@ -12898,8 +13092,9 @@ function createInbound(input) {
|
|
|
12898
13092
|
block: recorded.block,
|
|
12899
13093
|
task: recorded.task,
|
|
12900
13094
|
comment: recorded.comment,
|
|
12901
|
-
|
|
12902
|
-
at
|
|
13095
|
+
authorRole: recorded.authorRole,
|
|
13096
|
+
at,
|
|
13097
|
+
config
|
|
12903
13098
|
});
|
|
12904
13099
|
return { status: "applied" };
|
|
12905
13100
|
}
|
|
@@ -17140,6 +17335,24 @@ function linkRulesCheck(outcomes) {
|
|
|
17140
17335
|
};
|
|
17141
17336
|
return warning(id, fitFix(problems, problems.some((segment) => segment.unmatched) ? ` ${LINK_RULES_TAIL}` : "", `link rules miss recent PRs in ${String(problems.length)} projects; change projects[].link to the repo's branch and PR title rules.`));
|
|
17142
17337
|
}
|
|
17338
|
+
const CURATOR_TAIL = "Start a Spur session of each curator with no live session.";
|
|
17339
|
+
function curatorSessionsCheck(entries) {
|
|
17340
|
+
const id = "curator.sessions";
|
|
17341
|
+
const segment = (text, problem) => ({
|
|
17342
|
+
problem,
|
|
17343
|
+
unmatched: false,
|
|
17344
|
+
text: () => text
|
|
17345
|
+
});
|
|
17346
|
+
const segments = entries.map(({ project, curator, session }) => curator === null ? segment(`${project}: no curator configured`, false) : session === null ? segment(`${project}: curator ${curator}, no live session`, true) : segment(`${project}: curator ${curator}, session ${session}`, false));
|
|
17347
|
+
const missing = segments.filter((entry) => entry.problem).length;
|
|
17348
|
+
if (missing === 0) return {
|
|
17349
|
+
id,
|
|
17350
|
+
status: "pass",
|
|
17351
|
+
blocking: false,
|
|
17352
|
+
fix: fitFix(segments, "", `Every configured curator has a live session in ${String(segments.length)} projects.`)
|
|
17353
|
+
};
|
|
17354
|
+
return warning(id, fitFix([...segments.filter((entry) => entry.problem), ...segments.filter((entry) => !entry.problem)], ` ${CURATOR_TAIL}`, `${String(missing)} curators have no live session. Start a Spur session of each.`));
|
|
17355
|
+
}
|
|
17143
17356
|
function check(id, ok, fix) {
|
|
17144
17357
|
return {
|
|
17145
17358
|
id,
|
|
@@ -17284,6 +17497,7 @@ async function runDaemonDoctor(ctx, productVersion, fetcher = fetch, { deadlineM
|
|
|
17284
17497
|
const operatorProject = config.projects.some((project) => project.spurProjects.some((spurProject) => spurProject.role === "operator"));
|
|
17285
17498
|
const token = operatorProject ? void 0 : await ctx.store.db.selectFrom("operator_token").select("id").where("status", "=", "approved").executeTakeFirst();
|
|
17286
17499
|
checks.push(check("operator.path", operatorProject || token !== void 0, "Configure a Spur project with the operator role or approve a named operator token."));
|
|
17500
|
+
checks.push(curatorSessionsCheck(await curatorSessions(ctx.store.db, config)));
|
|
17287
17501
|
return {
|
|
17288
17502
|
version: productVersion,
|
|
17289
17503
|
checks
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ERRORS, p as renderMcpError, u as OPERATIONS } from "./src-
|
|
2
|
-
import { i as CliError, n as requestOperation } from "./client-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-
|
|
1
|
+
import { P as ERRORS, p as renderMcpError, u as OPERATIONS } from "./src-7fzumMWU.mjs";
|
|
2
|
+
import { i as CliError, n as requestOperation } from "./client-DEwzucXx.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-B8ZBFd_9.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -159,7 +159,7 @@ function createMcpServer(env = process.env, loadConfig = loadClientConfig) {
|
|
|
159
159
|
...error.context,
|
|
160
160
|
...key && ERRORS[error.code].exit === 5 ? { idempotencyKey: key } : {}
|
|
161
161
|
} } : {}
|
|
162
|
-
});
|
|
162
|
+
}, error.code === "forbidden" ? error.hint : void 0);
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
return server;
|
|
@@ -205,7 +205,7 @@ const githubIssuesTracker = z.strictObject({
|
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
207
|
const spurProject = z.strictObject({
|
|
208
|
-
name: nonEmpty,
|
|
208
|
+
name: nonEmpty.describe("The name of the project in Spur. A Spur project can be listed under only one board project."),
|
|
209
209
|
role: z.enum([
|
|
210
210
|
"worker",
|
|
211
211
|
"operator",
|
|
@@ -318,10 +318,31 @@ function isTimeZone(tz) {
|
|
|
318
318
|
return false;
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
+
/** A session belongs to one board project, so a Spur project can be listed under only one. */
|
|
322
|
+
function rejectSharedSpurProjects(items, ctx) {
|
|
323
|
+
const owners = /* @__PURE__ */ new Map();
|
|
324
|
+
items.forEach((project, i) => {
|
|
325
|
+
project.spurProjects.forEach(({ name }, j) => {
|
|
326
|
+
const owner = owners.get(name);
|
|
327
|
+
if (owner === void 0) owners.set(name, project.id);
|
|
328
|
+
else if (owner !== project.id) ctx.addIssue({
|
|
329
|
+
code: "custom",
|
|
330
|
+
path: [
|
|
331
|
+
i,
|
|
332
|
+
"spurProjects",
|
|
333
|
+
j,
|
|
334
|
+
"name"
|
|
335
|
+
],
|
|
336
|
+
message: `Spur project ${JSON.stringify(name)} is listed under board projects ${JSON.stringify(owner)} and ${JSON.stringify(project.id)}: list it under only one`
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
}
|
|
321
341
|
/** The board config file. Every object rejects unknown keys; no key holds a secret. */
|
|
322
342
|
const configSchema = z.strictObject({
|
|
323
343
|
projects: z.array(projectSchema).min(1).superRefine((items, ctx) => {
|
|
324
344
|
rejectDuplicates(items, "id", "project id", ctx);
|
|
345
|
+
rejectSharedSpurProjects(items, ctx);
|
|
325
346
|
}),
|
|
326
347
|
operator: z.strictObject({ slack: nonEmpty }),
|
|
327
348
|
slack: z.strictObject({
|
|
@@ -1134,7 +1155,8 @@ const eventPayloadSchemas = {
|
|
|
1134
1155
|
block_escalated: z.looseObject({
|
|
1135
1156
|
block: S,
|
|
1136
1157
|
from: role,
|
|
1137
|
-
to: role
|
|
1158
|
+
to: role,
|
|
1159
|
+
reason: S.optional()
|
|
1138
1160
|
}),
|
|
1139
1161
|
block_unblocked: z.looseObject({
|
|
1140
1162
|
block: S,
|
|
@@ -1414,8 +1436,13 @@ function renderHttpProblem(input) {
|
|
|
1414
1436
|
}
|
|
1415
1437
|
};
|
|
1416
1438
|
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1439
|
+
/** `hint` replaces the catalog hint for one call; `errorInputSchema` stays hint-free. */
|
|
1440
|
+
function renderMcpError(input, hint) {
|
|
1441
|
+
const rendered = fields(input, "mcp");
|
|
1442
|
+
const content = hint === void 0 ? rendered : {
|
|
1443
|
+
...rendered,
|
|
1444
|
+
hint
|
|
1445
|
+
};
|
|
1419
1446
|
return {
|
|
1420
1447
|
isError: true,
|
|
1421
1448
|
content: [{
|