spur-board 0.32.1 → 0.34.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 +4 -4
- package/dist/{client-DtDNMMO-.mjs → client-dHOLiNKd.mjs} +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{config-D3ltZ-MU.mjs → config-BsZv50VN.mjs} +2 -2
- package/dist/daemon.mjs +242 -56
- package/dist/mcp.mjs +3 -3
- package/dist/migrations/0012_turn.sql +66 -0
- package/dist/{src-B63VaSzU.mjs → src-B2L79Nf9.mjs} +97 -26
- package/package.json +1 -1
- package/skills/spur-board/references/commands.md +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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 { F as ERRORS, J as SLACK_BOT_SCOPES, K as configSchema, l as roleCanUseOperation, q as requiredSecretKeys, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-B2L79Nf9.mjs";
|
|
2
|
+
import { a as errorExitCode, i as CliError, n as requestOperation, o as renderCliError, r as requestTokenEnrollment, s as escapeTerminalControls } from "./client-dHOLiNKd.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-BsZv50VN.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";
|
|
@@ -1940,7 +1940,7 @@ function positionalInput(op, field, value) {
|
|
|
1940
1940
|
if (!revisionEntryArray(fieldSchema(op, field)) || !Array.isArray(value)) return value;
|
|
1941
1941
|
return value.map((item) => {
|
|
1942
1942
|
if (typeof item !== "string") return item;
|
|
1943
|
-
if (
|
|
1943
|
+
if (!item.includes("@")) return { id: item };
|
|
1944
1944
|
const match = /^([^@]+)@([1-9][0-9]*)$/.exec(item);
|
|
1945
1945
|
const id = match?.[1];
|
|
1946
1946
|
const rawRevision = match?.[2];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as successEnvelopeSchema, F as ERRORS, L as errorContextSchema, R as errorEnvelopeSchema, p as renderJsonError } from "./src-B2L79Nf9.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-dHOLiNKd.mjs";
|
|
2
2
|
export { fetchCatalogVersion, requestOperation, requestTokenEnrollment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as CliError, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { K as configSchema, c as buildCatalogSnapshot, u as OPERATIONS } from "./src-B2L79Nf9.mjs";
|
|
2
|
+
import { i as CliError, t as fetchCatalogVersion } from "./client-dHOLiNKd.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
|
|
1
|
+
import { A as encodeActorId, B as successEnvelopeSchema, C as SESSION_HEALTH_STATES, D as sessionFactsSchema, E as prRefSchema, F as ERRORS, G as RESERVED_PROJECT, H as DEFAULT_LINK, I as err, J as SLACK_BOT_SCOPES, K as configSchema, M as parseActorId, N as parseRef$1, O as ticketFactsSchema, P as taskKeySchema, S as eventPayloadSchemas, T as prFactsSchema, W as DEFAULT_SLACK_COMMAND, _ as inboundEventSchema, a as batchSchema, b as userIdSchema, c as buildCatalogSnapshot, d as turnHandedSchema, f as renderHttpProblem, g as conversationRefSchema, h as SPACE_IDS, i as AdapterError, j as errorCodeOf, k as actorIdSchema, l as roleCanUseOperation, n as BOARD_TICK_MS, o as entityRefSchema, q as requiredSecretKeys, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as interactionRefSchema, w as SESSION_STATUSES, x as EVENT_KINDS, y as messageRefSchema, z as ok } from "./src-B2L79Nf9.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";
|
|
@@ -8210,7 +8210,8 @@ const ITEM_KINDS = [
|
|
|
8210
8210
|
"inbound_failure",
|
|
8211
8211
|
"inbound_gap",
|
|
8212
8212
|
"board_observation",
|
|
8213
|
-
"worker_ended"
|
|
8213
|
+
"worker_ended",
|
|
8214
|
+
"turn"
|
|
8214
8215
|
];
|
|
8215
8216
|
const ITEM_POLICY = {
|
|
8216
8217
|
token_request: {
|
|
@@ -8289,6 +8290,14 @@ const ITEM_POLICY = {
|
|
|
8289
8290
|
priority: 4,
|
|
8290
8291
|
buttons: "item",
|
|
8291
8292
|
reconciled: true
|
|
8293
|
+
},
|
|
8294
|
+
/** A turn whose executor is the operator; `closeTurns` clears it. */
|
|
8295
|
+
turn: {
|
|
8296
|
+
retry: "none",
|
|
8297
|
+
feed: true,
|
|
8298
|
+
priority: 4,
|
|
8299
|
+
buttons: "item",
|
|
8300
|
+
reconciled: false
|
|
8292
8301
|
}
|
|
8293
8302
|
};
|
|
8294
8303
|
/** Guards a stored kind: the column is free text and old or hand-written rows may hold others. */
|
|
@@ -9406,6 +9415,15 @@ async function registerBlockNotification(trx, block, at) {
|
|
|
9406
9415
|
created_at: at.toISOString()
|
|
9407
9416
|
}).onConflict((oc) => oc.column("source_key").doNothing()).execute();
|
|
9408
9417
|
}
|
|
9418
|
+
/** The block of a block-owned notification; the store CHECK gives every non-turn kind one. */
|
|
9419
|
+
function noticeBlockId(n) {
|
|
9420
|
+
if (n.block_id === null) throw new Error(`notification of kind ${n.kind} has no block`);
|
|
9421
|
+
return n.block_id;
|
|
9422
|
+
}
|
|
9423
|
+
/** What a notification is about, as the operator item names it. */
|
|
9424
|
+
function noticeRef(n, task) {
|
|
9425
|
+
return n.kind === "turn" ? `turn T${String(n.turn_id)} on ${task.key}` : `block B${String(noticeBlockId(n))} on ${task.key}`;
|
|
9426
|
+
}
|
|
9409
9427
|
/** Register a one-ring notice that a block its addressee held was closed by someone else. */
|
|
9410
9428
|
async function registerRemovedNotification(trx, block, at) {
|
|
9411
9429
|
if (block.addressee_role === "operator") return;
|
|
@@ -9589,7 +9607,7 @@ async function endNotification(trx, n, task, end) {
|
|
|
9589
9607
|
const addressee = parseAddressee(n.role);
|
|
9590
9608
|
if (n.kind === "block" && addressee.kind === "curator") await moveBlockToAddressee(trx, {
|
|
9591
9609
|
task,
|
|
9592
|
-
block: await trx.selectFrom("block").selectAll().where("id", "=", n
|
|
9610
|
+
block: await trx.selectFrom("block").selectAll().where("id", "=", noticeBlockId(n)).executeTakeFirstOrThrow(),
|
|
9593
9611
|
to: "operator",
|
|
9594
9612
|
reason,
|
|
9595
9613
|
ctx: {
|
|
@@ -9599,7 +9617,7 @@ async function endNotification(trx, n, task, end) {
|
|
|
9599
9617
|
config
|
|
9600
9618
|
});
|
|
9601
9619
|
else if (n.kind !== "removed" && session !== null) {
|
|
9602
|
-
const blockRef =
|
|
9620
|
+
const blockRef = noticeRef(n, task);
|
|
9603
9621
|
const answer = `Answer to ${blockRef} was not`;
|
|
9604
9622
|
const holder = `${addressee.kind} ${session}`;
|
|
9605
9623
|
await raiseItem(trx, {
|
|
@@ -9660,9 +9678,11 @@ function noRecipientEnd(n) {
|
|
|
9660
9678
|
/** A ring never carries comment or reason text: only where to look. */
|
|
9661
9679
|
async function ringText(trx, n, task, ring) {
|
|
9662
9680
|
const suffix = `(N${String(n.id)}-${String(ring)})`;
|
|
9663
|
-
if (n.kind
|
|
9664
|
-
const
|
|
9665
|
-
return `${task.key} block B${String(
|
|
9681
|
+
if (n.kind === "turn") return `${task.key} turn T${String(n.turn_id)}: check board inbox ${suffix}`;
|
|
9682
|
+
const blockId = noticeBlockId(n);
|
|
9683
|
+
if (n.kind !== "removed") return `${task.key} block B${String(blockId)}: check board inbox ${suffix}`;
|
|
9684
|
+
const block = await trx.selectFrom("block").select("unblocked_by").where("id", "=", blockId).executeTakeFirstOrThrow();
|
|
9685
|
+
return `${task.key} block B${String(blockId)} was removed by ${block.unblocked_by ?? "system"}; see board task ${task.key} ${suffix}`;
|
|
9666
9686
|
}
|
|
9667
9687
|
/** Notifications reconcile looks at: unacked, not exhausted, due, on a task not archived. */
|
|
9668
9688
|
function dueNotifications(db, at) {
|
|
@@ -9789,6 +9809,7 @@ async function acknowledgeNotification(trx, input) {
|
|
|
9789
9809
|
let query = trx.selectFrom("notification").selectAll().where("acked_at", "is", null);
|
|
9790
9810
|
if (input.blockId !== void 0) query = query.where("block_id", "=", input.blockId).where("kind", "=", "block");
|
|
9791
9811
|
else if (input.commentId !== void 0) query = query.where("comment_id", "=", input.commentId).where("kind", "=", "answer");
|
|
9812
|
+
else if (input.turnId !== void 0) query = query.where("turn_id", "=", input.turnId).where("kind", "=", "turn");
|
|
9792
9813
|
else return false;
|
|
9793
9814
|
const notices = await query.orderBy("id", "desc").execute();
|
|
9794
9815
|
const n = notices[0];
|
|
@@ -9828,13 +9849,111 @@ async function workerNotificationAddressedTo(trx, n, session, config) {
|
|
|
9828
9849
|
return await liveSession(trx, n.recipient_session) !== void 0 ? session === n.recipient_session : (await selectNotificationRecipient(trx, n, config))?.id === session;
|
|
9829
9850
|
}
|
|
9830
9851
|
async function closeBlockNotification(trx, blockId, at) {
|
|
9831
|
-
|
|
9852
|
+
await closeOwnedNotifications(trx, "block", blockId, at);
|
|
9853
|
+
}
|
|
9854
|
+
/** Ends a turn's ring series for good: acked, and its exhaustion item cleared by the system. */
|
|
9855
|
+
async function closeTurnNotification(trx, turnId, at) {
|
|
9856
|
+
await closeOwnedNotifications(trx, "turn", turnId, at);
|
|
9857
|
+
}
|
|
9858
|
+
async function closeOwnedNotifications(trx, kind, ownerId, at) {
|
|
9859
|
+
const closed = await trx.updateTable("notification").set({ acked_at: at.toISOString() }).where(kind === "block" ? "block_id" : "turn_id", "=", ownerId).where("kind", "=", kind).where("acked_at", "is", null).returning(["kind", "source_key"]).execute();
|
|
9832
9860
|
for (const row of closed) {
|
|
9833
9861
|
const item = await trx.selectFrom("operator_item").select("id").where("item_key", "=", exhaustedItemKey(row)).where("cleared_at", "is", null).executeTakeFirst();
|
|
9834
9862
|
if (item !== void 0) await clearItem(trx, item.id, at);
|
|
9835
9863
|
}
|
|
9836
9864
|
}
|
|
9837
9865
|
//#endregion
|
|
9866
|
+
//#region ../core/src/app/turns.ts
|
|
9867
|
+
const handedSchema = z.array(turnHandedSchema);
|
|
9868
|
+
const turnItemKey = (turnId) => `turn:${String(turnId)}`;
|
|
9869
|
+
/** The feedback a stored turn handed over. */
|
|
9870
|
+
function turnHanded(turn) {
|
|
9871
|
+
return parseJson(handedSchema, turn.handed);
|
|
9872
|
+
}
|
|
9873
|
+
/** The newest notification of a turn; an operator turn has none. */
|
|
9874
|
+
async function turnNotification(trx, turnId) {
|
|
9875
|
+
return trx.selectFrom("notification").selectAll().where("turn_id", "=", turnId).where("kind", "=", "turn").orderBy("id", "desc").executeTakeFirst();
|
|
9876
|
+
}
|
|
9877
|
+
/**
|
|
9878
|
+
* Takes a turn for `actor`. False for a missing, closed, operator or taken worker turn. An
|
|
9879
|
+
* untaken turn needs its unread notification addressed to the actor; a taken orchestrator turn
|
|
9880
|
+
* may be taken over by whoever its notification is now addressed to. Others get `forbidden`.
|
|
9881
|
+
*/
|
|
9882
|
+
async function takeTurn(trx, input) {
|
|
9883
|
+
const { turnId, actor, at, config } = input;
|
|
9884
|
+
const turn = await trx.selectFrom("turn").selectAll().where("id", "=", turnId).executeTakeFirst();
|
|
9885
|
+
if (turn === void 0 || turn.closed_at !== null || turn.role === "operator") return false;
|
|
9886
|
+
if (turn.acked_at === null) {
|
|
9887
|
+
if (!await acknowledgeNotification(trx, {
|
|
9888
|
+
turnId,
|
|
9889
|
+
actor,
|
|
9890
|
+
at,
|
|
9891
|
+
config
|
|
9892
|
+
})) return false;
|
|
9893
|
+
} else {
|
|
9894
|
+
if (parseAddressee(turn.role).kind !== "orchestrator") return false;
|
|
9895
|
+
const notice = await turnNotification(trx, turnId);
|
|
9896
|
+
if (notice === void 0 || !await notificationAddressedTo(trx, notice, actor, config)) throw new CommandError("forbidden", "Only the addressed task role can take this turn.");
|
|
9897
|
+
}
|
|
9898
|
+
await trx.updateTable("turn").set({
|
|
9899
|
+
acked_by: actor,
|
|
9900
|
+
acked_at: at.toISOString()
|
|
9901
|
+
}).where("id", "=", turnId).execute();
|
|
9902
|
+
return true;
|
|
9903
|
+
}
|
|
9904
|
+
/**
|
|
9905
|
+
* Closes every unclosed turn of a task: its rings stop and its items end as "condition ended".
|
|
9906
|
+
* A ring already queued is dropped by the sender (`ringStillCurrent`).
|
|
9907
|
+
*/
|
|
9908
|
+
async function closeTurns(trx, input) {
|
|
9909
|
+
const { taskId, reason, at } = input;
|
|
9910
|
+
const closed = await trx.updateTable("turn").set({
|
|
9911
|
+
closed_at: at.toISOString(),
|
|
9912
|
+
closed_reason: reason
|
|
9913
|
+
}).where("task_id", "=", taskId).where("closed_at", "is", null).returning("id").execute();
|
|
9914
|
+
for (const { id } of closed) {
|
|
9915
|
+
await closeTurnNotification(trx, id, at);
|
|
9916
|
+
const item = await trx.selectFrom("operator_item").select("id").where("item_key", "=", turnItemKey(id)).where("cleared_at", "is", null).executeTakeFirst();
|
|
9917
|
+
if (item !== void 0) await clearItem(trx, item.id, at);
|
|
9918
|
+
}
|
|
9919
|
+
}
|
|
9920
|
+
/** Whether `left` is newer than `right` by `postedAt` instant, then by id. Compared, not subtracted. */
|
|
9921
|
+
function isNewer(left, right) {
|
|
9922
|
+
const a = Date.parse(left.postedAt);
|
|
9923
|
+
const b = Date.parse(right.postedAt);
|
|
9924
|
+
return a !== b ? a > b : left.id > right.id;
|
|
9925
|
+
}
|
|
9926
|
+
/**
|
|
9927
|
+
* Per requested PR, the newest feedback any turn of its linked tasks handed over, acked or not,
|
|
9928
|
+
* closed or not, so the cursor never moves back. A PR with none gets no entry.
|
|
9929
|
+
*/
|
|
9930
|
+
async function turnFeedbackCursors(db, prs) {
|
|
9931
|
+
if (prs.length === 0) return [];
|
|
9932
|
+
const rows = await db.selectFrom("turn").innerJoin("link", "link.task_id", "turn.task_id").select([
|
|
9933
|
+
"link.repo",
|
|
9934
|
+
"link.number",
|
|
9935
|
+
"turn.handed"
|
|
9936
|
+
]).where("link.entity", "=", "pr").where("link.banned", "=", 0).where(sql`lower(link.repo)`, "in", prs.map((pr) => pr.repo.toLowerCase())).execute();
|
|
9937
|
+
const cursors = [];
|
|
9938
|
+
for (const ref of prs) {
|
|
9939
|
+
const repo = ref.repo.toLowerCase();
|
|
9940
|
+
let best;
|
|
9941
|
+
for (const row of rows) {
|
|
9942
|
+
if (row.repo?.toLowerCase() !== repo || row.number !== ref.number) continue;
|
|
9943
|
+
for (const entry of turnHanded(row)) {
|
|
9944
|
+
if (entry.repo.toLowerCase() !== repo || entry.number !== ref.number) continue;
|
|
9945
|
+
if (best === void 0 || isNewer(entry, best)) best = entry;
|
|
9946
|
+
}
|
|
9947
|
+
}
|
|
9948
|
+
if (best !== void 0) cursors.push({
|
|
9949
|
+
ref,
|
|
9950
|
+
id: best.id,
|
|
9951
|
+
postedAt: best.postedAt
|
|
9952
|
+
});
|
|
9953
|
+
}
|
|
9954
|
+
return cursors;
|
|
9955
|
+
}
|
|
9956
|
+
//#endregion
|
|
9838
9957
|
//#region ../core/src/app/blocks.ts
|
|
9839
9958
|
const idNumber = (id) => Number(id.slice(1));
|
|
9840
9959
|
const blockId$1 = (id) => `B${String(id)}`;
|
|
@@ -9897,6 +10016,17 @@ async function blockTarget(trx, id) {
|
|
|
9897
10016
|
const block = await blockById(trx, id);
|
|
9898
10017
|
return [await authorizationTarget(trx, block === void 0 ? void 0 : await taskById(trx, block.task_id), block)];
|
|
9899
10018
|
}
|
|
10019
|
+
async function turnTarget(trx, id) {
|
|
10020
|
+
const turn = await trx.selectFrom("turn").select("task_id").where("id", "=", idNumber(id)).executeTakeFirst();
|
|
10021
|
+
if (turn === void 0) return {
|
|
10022
|
+
kind: "missing",
|
|
10023
|
+
id
|
|
10024
|
+
};
|
|
10025
|
+
return {
|
|
10026
|
+
...await authorizationTarget(trx, await taskById(trx, turn.task_id)),
|
|
10027
|
+
id
|
|
10028
|
+
};
|
|
10029
|
+
}
|
|
9900
10030
|
async function commentTarget(trx, id) {
|
|
9901
10031
|
const comment = await commentById(trx, id);
|
|
9902
10032
|
return {
|
|
@@ -10301,6 +10431,7 @@ function createBlockMutations(config) {
|
|
|
10301
10431
|
async resolveTargets(trx, input) {
|
|
10302
10432
|
return Promise.all(input.entries.map(async ({ id }) => {
|
|
10303
10433
|
if (id.startsWith("C")) return commentTarget(trx, id);
|
|
10434
|
+
if (id.startsWith("T")) return turnTarget(trx, id);
|
|
10304
10435
|
const target = (await blockTarget(trx, id))[0];
|
|
10305
10436
|
return target === void 0 ? {
|
|
10306
10437
|
kind: "missing",
|
|
@@ -10313,6 +10444,15 @@ function createBlockMutations(config) {
|
|
|
10313
10444
|
},
|
|
10314
10445
|
async run(trx, input, ctx) {
|
|
10315
10446
|
for (const entry of input.entries) {
|
|
10447
|
+
if (entry.id.startsWith("T")) {
|
|
10448
|
+
if (!await takeTurn(trx, {
|
|
10449
|
+
turnId: idNumber(entry.id),
|
|
10450
|
+
actor: ctx.actor,
|
|
10451
|
+
at: new Date(ctx.at),
|
|
10452
|
+
config
|
|
10453
|
+
})) throw new CommandError("not_found", "No open turn to take for this ID.");
|
|
10454
|
+
continue;
|
|
10455
|
+
}
|
|
10316
10456
|
if (!("revision" in entry)) {
|
|
10317
10457
|
if (!await acknowledgeNotification(trx, {
|
|
10318
10458
|
blockId: found(await blockById(trx, entry.id)).id,
|
|
@@ -10347,8 +10487,8 @@ function createBlockMutations(config) {
|
|
|
10347
10487
|
//#region ../core/src/app/archive.ts
|
|
10348
10488
|
/**
|
|
10349
10489
|
* Takes a task off the board in the caller's transaction: closes its open blocks with outcome
|
|
10350
|
-
* `archived
|
|
10351
|
-
* `task_archived`. Callers set their own extra columns (manual flags, the Done slot).
|
|
10490
|
+
* `archived` and its unclosed turns, clears its board-derived items, cancels its unsent doorbells
|
|
10491
|
+
* and journals `task_archived`. Callers set their own extra columns (manual flags, the Done slot).
|
|
10352
10492
|
*/
|
|
10353
10493
|
async function archiveTask(trx, input) {
|
|
10354
10494
|
const { task, reason, actor, at } = input;
|
|
@@ -10358,6 +10498,11 @@ async function archiveTask(trx, input) {
|
|
|
10358
10498
|
};
|
|
10359
10499
|
const blocks = await trx.selectFrom("block").selectAll().where("task_id", "=", task.id).where("state", "=", "open").orderBy("id").execute();
|
|
10360
10500
|
for (const block of blocks) await closeOpenBlock(trx, task, block, ctx, "archived", null);
|
|
10501
|
+
await closeTurns(trx, {
|
|
10502
|
+
taskId: task.id,
|
|
10503
|
+
reason: "archived",
|
|
10504
|
+
at: new Date(at)
|
|
10505
|
+
});
|
|
10361
10506
|
const items = await trx.selectFrom("operator_item").select("id").where("kind", "in", RECONCILED_KINDS).where("task_id", "=", task.id).where("cleared_at", "is", null).orderBy("id").execute();
|
|
10362
10507
|
for (const item of items) await clearItem(trx, item.id, new Date(at), actor);
|
|
10363
10508
|
const comments = await trx.selectFrom("comment").select("id").where("task_id", "=", task.id).execute();
|
|
@@ -11732,50 +11877,82 @@ function createTaskQueries(config) {
|
|
|
11732
11877
|
const parsed = parseRef$1(key, "task");
|
|
11733
11878
|
return parsed.ok && parsed.value.kind === "task" && parsed.value.form === "github-short" ? canonicalKey(config, key).key : key;
|
|
11734
11879
|
};
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
const
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
|
|
11766
|
-
actor:
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11880
|
+
const get = {
|
|
11881
|
+
id: "task.get",
|
|
11882
|
+
resolveTargets: (trx, input) => taskTarget(trx, taskKey(input.task)),
|
|
11883
|
+
async run(trx, input) {
|
|
11884
|
+
const task = await taskByKey(trx, taskKey(input.task));
|
|
11885
|
+
const [blocks, comments, links] = await Promise.all([
|
|
11886
|
+
trx.selectFrom("block").selectAll().where("task_id", "=", task.id).orderBy("id").execute(),
|
|
11887
|
+
trx.selectFrom("comment").selectAll().where("task_id", "=", task.id).orderBy("id").execute(),
|
|
11888
|
+
trx.selectFrom("link").selectAll().where("task_id", "=", task.id).where("banned", "=", 0).orderBy("id").execute()
|
|
11889
|
+
]);
|
|
11890
|
+
return {
|
|
11891
|
+
task: taskView(task),
|
|
11892
|
+
links: links.map(linkView),
|
|
11893
|
+
blocks: blocks.map((block) => blockView(block, task)),
|
|
11894
|
+
comments: comments.map((comment) => commentView(comment, task))
|
|
11895
|
+
};
|
|
11896
|
+
}
|
|
11897
|
+
};
|
|
11898
|
+
const history = {
|
|
11899
|
+
id: "task.history",
|
|
11900
|
+
resolveTargets: (trx, input) => taskTarget(trx, taskKey(input.task)),
|
|
11901
|
+
async run(trx, input) {
|
|
11902
|
+
const task = await taskByKey(trx, taskKey(input.task));
|
|
11903
|
+
const events = (await trx.selectFrom("event").selectAll().where("task_id", "=", task.id).orderBy("id").execute()).flatMap((row) => {
|
|
11904
|
+
const kind = EVENT_KINDS.find((candidate) => candidate === row.kind);
|
|
11905
|
+
if (kind === void 0) return [];
|
|
11906
|
+
const actorRef = row.actor_ref === null ? void 0 : parseJson(actorRefSchema, row.actor_ref);
|
|
11907
|
+
return [{
|
|
11908
|
+
at: row.at,
|
|
11909
|
+
kind,
|
|
11910
|
+
actor: encodeActorId({
|
|
11911
|
+
actor: row.actor,
|
|
11912
|
+
actorRef
|
|
11913
|
+
}),
|
|
11914
|
+
summary: linkSummary(kind, row.payload) ?? EVENT_SUMMARIES[kind]
|
|
11915
|
+
}];
|
|
11916
|
+
});
|
|
11917
|
+
return {
|
|
11918
|
+
task: taskView(task),
|
|
11919
|
+
events
|
|
11920
|
+
};
|
|
11921
|
+
}
|
|
11922
|
+
};
|
|
11923
|
+
/**
|
|
11924
|
+
* Unclosed agent turns the caller may take or has taken: an untaken one addressed to it, one it
|
|
11925
|
+
* took, and a taken orchestrator turn it may take over. At most one per task.
|
|
11926
|
+
*/
|
|
11927
|
+
async function inboxTurns(trx, projects, actor) {
|
|
11928
|
+
if (parseActorId(actor)?.actor !== "agent" || projects.size === 0) return [];
|
|
11929
|
+
const rows = await trx.selectFrom("turn").innerJoin("task", "task.id", "turn.task_id").selectAll("turn").select("task.key").where("task.project", "in", [...projects]).where("turn.closed_at", "is", null).where("turn.role", "!=", "operator").orderBy("turn.id").execute();
|
|
11930
|
+
const turns = [];
|
|
11931
|
+
for (const turn of rows) {
|
|
11932
|
+
if (turn.acked_by !== actor) {
|
|
11933
|
+
const notice = await turnNotification(trx, turn.id);
|
|
11934
|
+
const mayTake = turn.acked_at === null ? notice?.acked_at === null : turn.role.startsWith("orchestrator:");
|
|
11935
|
+
if (notice === void 0 || !mayTake || !await notificationAddressedTo(trx, notice, actor, config)) continue;
|
|
11777
11936
|
}
|
|
11778
|
-
|
|
11937
|
+
turns.push({
|
|
11938
|
+
id: `T${String(turn.id)}`,
|
|
11939
|
+
task: turn.key,
|
|
11940
|
+
column: turn.column,
|
|
11941
|
+
addressee: turn.role,
|
|
11942
|
+
reason: turn.reason,
|
|
11943
|
+
handed: turnHanded(turn),
|
|
11944
|
+
at: turn.created_at,
|
|
11945
|
+
taken: turn.acked_by === null || turn.acked_at === null ? null : {
|
|
11946
|
+
by: turn.acked_by,
|
|
11947
|
+
at: turn.acked_at
|
|
11948
|
+
}
|
|
11949
|
+
});
|
|
11950
|
+
}
|
|
11951
|
+
return turns;
|
|
11952
|
+
}
|
|
11953
|
+
return {
|
|
11954
|
+
get,
|
|
11955
|
+
history,
|
|
11779
11956
|
inbox: {
|
|
11780
11957
|
id: "inbox.get",
|
|
11781
11958
|
resolveTargets(_trx, input, actor) {
|
|
@@ -11823,7 +12000,8 @@ function createTaskQueries(config) {
|
|
|
11823
12000
|
}
|
|
11824
12001
|
return {
|
|
11825
12002
|
comments,
|
|
11826
|
-
blocks
|
|
12003
|
+
blocks,
|
|
12004
|
+
turns: await inboxTurns(trx, projects, actor)
|
|
11827
12005
|
};
|
|
11828
12006
|
}
|
|
11829
12007
|
}
|
|
@@ -12392,6 +12570,11 @@ async function ticket(trx, config, fact, at, source) {
|
|
|
12392
12570
|
archive_reason: "manual"
|
|
12393
12571
|
}).where("id", "=", pending.id).execute();
|
|
12394
12572
|
await emit(trx, "task_archived", pending.project, pending.id, at, { reason: "manual" });
|
|
12573
|
+
await closeTurns(trx, {
|
|
12574
|
+
taskId: pending.id,
|
|
12575
|
+
reason: "archived",
|
|
12576
|
+
at: new Date(at)
|
|
12577
|
+
});
|
|
12395
12578
|
await moveOpenWork(trx, pending.id, task.id);
|
|
12396
12579
|
await trx.updateTable("task").set({
|
|
12397
12580
|
key: fact.key,
|
|
@@ -12750,9 +12933,11 @@ function createObservationCore(deps) {
|
|
|
12750
12933
|
})));
|
|
12751
12934
|
}
|
|
12752
12935
|
const misses = await store.db.selectFrom("source_miss").selectAll().where("source", "=", source).execute();
|
|
12936
|
+
const requested = [...new Map(prs.map((ref) => [refKey(ref), ref])).values()];
|
|
12937
|
+
const feedbackCursors = await turnFeedbackCursors(store.db, requested);
|
|
12753
12938
|
return {
|
|
12754
12939
|
observe: {
|
|
12755
|
-
prs:
|
|
12940
|
+
prs: requested,
|
|
12756
12941
|
tickets,
|
|
12757
12942
|
sessions: [...new Map(sessions.map((ref) => [refKey(ref), ref])).values()]
|
|
12758
12943
|
},
|
|
@@ -12763,7 +12948,8 @@ function createObservationCore(deps) {
|
|
|
12763
12948
|
ref,
|
|
12764
12949
|
count: row.misses
|
|
12765
12950
|
}];
|
|
12766
|
-
})
|
|
12951
|
+
}),
|
|
12952
|
+
...feedbackCursors.length === 0 ? {} : { feedbackCursors }
|
|
12767
12953
|
};
|
|
12768
12954
|
},
|
|
12769
12955
|
async observe(source, observation) {
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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 { F as ERRORS, m as renderMcpError, u as OPERATIONS } from "./src-B2L79Nf9.mjs";
|
|
2
|
+
import { i as CliError, n as requestOperation } from "./client-dHOLiNKd.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-BsZv50VN.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
-- A turn hands a task's current column visit to its executor. `seq` counts the turns of one
|
|
2
|
+
-- visit; a task has at most one unclosed turn. `handed` is JSON checked by zod.
|
|
3
|
+
CREATE TABLE turn (
|
|
4
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
5
|
+
task_id INTEGER NOT NULL REFERENCES task (id),
|
|
6
|
+
"column" TEXT NOT NULL,
|
|
7
|
+
epoch INTEGER NOT NULL,
|
|
8
|
+
seq INTEGER NOT NULL,
|
|
9
|
+
role TEXT NOT NULL,
|
|
10
|
+
reason TEXT NOT NULL,
|
|
11
|
+
handed TEXT NOT NULL,
|
|
12
|
+
acked_by TEXT,
|
|
13
|
+
acked_at TEXT,
|
|
14
|
+
closed_at TEXT,
|
|
15
|
+
closed_reason TEXT,
|
|
16
|
+
created_at TEXT NOT NULL,
|
|
17
|
+
UNIQUE (task_id, "column", epoch, seq),
|
|
18
|
+
CHECK ((acked_at IS NULL) = (acked_by IS NULL)),
|
|
19
|
+
CHECK ((closed_at IS NULL) = (closed_reason IS NULL))
|
|
20
|
+
) STRICT;
|
|
21
|
+
|
|
22
|
+
CREATE UNIQUE INDEX turn_one_unclosed ON turn (task_id) WHERE closed_at IS NULL;
|
|
23
|
+
|
|
24
|
+
-- A notification belongs to a block or, for kind `turn`, to a turn. Keep every id, and keep the
|
|
25
|
+
-- sequence: outbox payloads name notification ids above the largest one still stored.
|
|
26
|
+
CREATE TABLE notification_new (
|
|
27
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
28
|
+
source_key TEXT NOT NULL UNIQUE,
|
|
29
|
+
kind TEXT NOT NULL,
|
|
30
|
+
task_id INTEGER NOT NULL REFERENCES task (id),
|
|
31
|
+
block_id INTEGER REFERENCES block (id),
|
|
32
|
+
comment_id INTEGER REFERENCES comment (id),
|
|
33
|
+
revision INTEGER,
|
|
34
|
+
role TEXT NOT NULL,
|
|
35
|
+
author_session TEXT,
|
|
36
|
+
recipient_session TEXT,
|
|
37
|
+
rings INTEGER NOT NULL DEFAULT 0,
|
|
38
|
+
next_at TEXT NOT NULL,
|
|
39
|
+
last_outbox_id INTEGER REFERENCES outbox (id),
|
|
40
|
+
acked_at TEXT,
|
|
41
|
+
created_at TEXT NOT NULL,
|
|
42
|
+
exhausted_at TEXT,
|
|
43
|
+
turn_id INTEGER REFERENCES turn (id),
|
|
44
|
+
CHECK (kind <> 'turn' OR (turn_id IS NOT NULL AND block_id IS NULL)),
|
|
45
|
+
CHECK (kind = 'turn' OR (block_id IS NOT NULL AND turn_id IS NULL))
|
|
46
|
+
) STRICT;
|
|
47
|
+
|
|
48
|
+
INSERT INTO notification_new (id, source_key, kind, task_id, block_id, comment_id, revision, role,
|
|
49
|
+
author_session, recipient_session, rings, next_at, last_outbox_id, acked_at, created_at,
|
|
50
|
+
exhausted_at, turn_id)
|
|
51
|
+
SELECT id, source_key, kind, task_id, block_id, comment_id, revision, role, author_session,
|
|
52
|
+
recipient_session, rings, next_at, last_outbox_id, acked_at, created_at, exhausted_at, NULL
|
|
53
|
+
FROM notification;
|
|
54
|
+
|
|
55
|
+
INSERT INTO sqlite_sequence (name, seq)
|
|
56
|
+
SELECT 'notification_new', 0
|
|
57
|
+
WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = 'notification_new');
|
|
58
|
+
UPDATE sqlite_sequence
|
|
59
|
+
SET seq = max(seq, coalesce((SELECT seq FROM sqlite_sequence WHERE name = 'notification'), 0))
|
|
60
|
+
WHERE name = 'notification_new';
|
|
61
|
+
|
|
62
|
+
DROP TABLE notification;
|
|
63
|
+
ALTER TABLE notification_new RENAME TO notification;
|
|
64
|
+
CREATE INDEX notification_due ON notification (acked_at, next_at);
|
|
65
|
+
CREATE INDEX notification_block ON notification (block_id, id);
|
|
66
|
+
CREATE INDEX notification_turn ON notification (turn_id, id);
|
|
@@ -263,6 +263,7 @@ const projectSchema = z.strictObject({
|
|
|
263
263
|
}).regex(/^[a-z][a-z0-9-]*$/, "Expected lowercase letters, digits and dashes"),
|
|
264
264
|
tracker: z.discriminatedUnion("type", [jiraTracker, githubIssuesTracker]),
|
|
265
265
|
repos: z.array(repoSlugSchema).min(1),
|
|
266
|
+
reposWithoutCi: z.array(repoSlugSchema).default([]).describe("Repos from repos that run no CI checks, in any letter case. In a listed repo, a PR whose check list on head is empty passes the Dev gate check condition instead of waiting in Dev. A list of only skipped checks still waits, and red or pending checks still count. A listed repo whose branch protection requires checks that have not reported yet also passes, so list only repos that run no checks. Without this key, a PR with no checks waits in Dev."),
|
|
266
267
|
link: z.strictObject({
|
|
267
268
|
sources: z.array(z.enum(LINK_SOURCES)).min(1).superRefine((sources, ctx) => {
|
|
268
269
|
sources.forEach((source, i) => {
|
|
@@ -297,6 +298,15 @@ const projectSchema = z.strictObject({
|
|
|
297
298
|
cycleLimit: DEFAULT_CYCLE_LIMIT
|
|
298
299
|
})))
|
|
299
300
|
}).superRefine((project, ctx) => {
|
|
301
|
+
const repos = new Set(project.repos.map((repo) => repo.toLowerCase()));
|
|
302
|
+
project.reposWithoutCi.forEach((repo, j) => {
|
|
303
|
+
if (repos.has(repo.toLowerCase())) return;
|
|
304
|
+
ctx.addIssue({
|
|
305
|
+
code: "custom",
|
|
306
|
+
path: ["reposWithoutCi", j],
|
|
307
|
+
message: `Repository ${JSON.stringify(repo)} is not in repos`
|
|
308
|
+
});
|
|
309
|
+
});
|
|
300
310
|
const spurNames = new Set(project.spurProjects.map((p) => p.name));
|
|
301
311
|
project.columns.forEach(({ orchestrator }, j) => {
|
|
302
312
|
if (orchestrator === "none" || orchestrator === "operator" || spurNames.has(orchestrator)) return;
|
|
@@ -769,12 +779,14 @@ const PATTERNS = {
|
|
|
769
779
|
block: `^B${N$1}$`,
|
|
770
780
|
comment: `^C${N$1}$`,
|
|
771
781
|
item: `^I${N$1}$`,
|
|
782
|
+
turn: `^T${N$1}$`,
|
|
772
783
|
task: `^(?:${TASK_FORMS.map((t) => t.source).join("|")})$`
|
|
773
784
|
};
|
|
774
785
|
const NUMBERED_KINDS = [
|
|
775
786
|
"block",
|
|
776
787
|
"comment",
|
|
777
|
-
"item"
|
|
788
|
+
"item",
|
|
789
|
+
"turn"
|
|
778
790
|
];
|
|
779
791
|
function matchRef(text) {
|
|
780
792
|
for (const kind of NUMBERED_KINDS) if (new RegExp(PATTERNS[kind]).test(text)) return {
|
|
@@ -790,9 +802,9 @@ function matchRef(text) {
|
|
|
790
802
|
return null;
|
|
791
803
|
}
|
|
792
804
|
/**
|
|
793
|
-
* Parses a block, comment or
|
|
794
|
-
*
|
|
795
|
-
*
|
|
805
|
+
* Parses a block, comment, item or turn ID or a task key. Numbered IDs are tried first, so
|
|
806
|
+
* `B12` is a block and `B-12` a Jira key. A valid ID of another kind than `expected` is
|
|
807
|
+
* `wrong_id_kind`; anything else that does not parse is `usage`.
|
|
796
808
|
*/
|
|
797
809
|
function parseRef(text, expected) {
|
|
798
810
|
const ref = matchRef(text);
|
|
@@ -804,6 +816,7 @@ const EXAMPLES = {
|
|
|
804
816
|
block: "B12",
|
|
805
817
|
comment: "C3",
|
|
806
818
|
item: "I7",
|
|
819
|
+
turn: "T4",
|
|
807
820
|
task: "PROJ-123, owner/repo#42 or repo#42"
|
|
808
821
|
};
|
|
809
822
|
function refSchema(kind, description) {
|
|
@@ -820,6 +833,7 @@ function refSchema(kind, description) {
|
|
|
820
833
|
const blockIdSchema = refSchema("block", "Block ID: B followed by a number, e.g. B12.");
|
|
821
834
|
const commentIdSchema = refSchema("comment", "Comment ID: C followed by a number, e.g. C3.");
|
|
822
835
|
const itemIdSchema = refSchema("item", "Item ID: I followed by a number, e.g. I7.");
|
|
836
|
+
const turnIdSchema = refSchema("turn", "Turn ID: T followed by a number, e.g. T4.");
|
|
823
837
|
const taskKeySchema = refSchema("task", "Task key: a Jira key (PROJ-123) or a GitHub issue (owner/repo#42, or repo#42).");
|
|
824
838
|
/** The error code for a failed parse: `wrong_id_kind` when an ID of another kind was given. */
|
|
825
839
|
function errorCodeOf(error) {
|
|
@@ -1608,6 +1622,26 @@ const blockViewSchema = z.strictObject({
|
|
|
1608
1622
|
unblockedBy: actorIdSchema.nullable().describe("Actor that unblocked the block; null while open."),
|
|
1609
1623
|
unblockedAt: z.iso.datetime().nullable().describe("When the block was unblocked; null while open.")
|
|
1610
1624
|
}).describe("A block on a task.");
|
|
1625
|
+
/** One pull request comment or review a turn handed to its executor. */
|
|
1626
|
+
const turnHandedSchema = z.strictObject({
|
|
1627
|
+
...prRefSchema.shape,
|
|
1628
|
+
kind: z.enum(FEEDBACK_KINDS).describe("Whether this is a comment or a submitted review."),
|
|
1629
|
+
id: z.string().min(1).describe("Stable id of the comment or review in the source."),
|
|
1630
|
+
postedAt: z.iso.datetime().describe("When the comment was posted or the review submitted, ISO 8601 UTC.")
|
|
1631
|
+
}).describe("Pull request feedback handed over with a turn.");
|
|
1632
|
+
const turnViewSchema = z.strictObject({
|
|
1633
|
+
id: turnIdSchema,
|
|
1634
|
+
task: taskKeySchema,
|
|
1635
|
+
column: z.enum(COLUMN_IDS).describe("Board column the turn belongs to."),
|
|
1636
|
+
addressee: z.enum(ADDRESSEE_ROLES).describe("Who executes the turn."),
|
|
1637
|
+
reason: z.string().describe("Why the turn was handed to the executor."),
|
|
1638
|
+
handed: z.array(turnHandedSchema).describe("Pull request feedback handed over with the turn."),
|
|
1639
|
+
at: z.iso.datetime().describe("When the turn was opened, ISO 8601 UTC."),
|
|
1640
|
+
taken: z.strictObject({
|
|
1641
|
+
by: actorIdSchema,
|
|
1642
|
+
at: z.iso.datetime().describe("When the turn was taken, ISO 8601 UTC.")
|
|
1643
|
+
}).nullable().describe("Who took the turn and when; null until it is taken.")
|
|
1644
|
+
}).describe("A turn: the executor of a column is asked to act on a task.");
|
|
1611
1645
|
const itemViewSchema = z.strictObject({
|
|
1612
1646
|
id: itemIdSchema,
|
|
1613
1647
|
task: taskKeySchema.nullable().describe("Task the item is about; null for a board-wide item."),
|
|
@@ -1801,6 +1835,22 @@ const comment = {
|
|
|
1801
1835
|
ackedRevision: null,
|
|
1802
1836
|
untrusted: true
|
|
1803
1837
|
};
|
|
1838
|
+
const reviewTurn = {
|
|
1839
|
+
id: "T4",
|
|
1840
|
+
task: "PROJ-123",
|
|
1841
|
+
column: "review",
|
|
1842
|
+
addressee: "orchestrator:review",
|
|
1843
|
+
reason: "The pull request is ready for review.",
|
|
1844
|
+
at,
|
|
1845
|
+
taken: null
|
|
1846
|
+
};
|
|
1847
|
+
const handedReview = {
|
|
1848
|
+
repo: "acme/web",
|
|
1849
|
+
number: 42,
|
|
1850
|
+
kind: "review",
|
|
1851
|
+
id: "PRR_kwDOA1",
|
|
1852
|
+
postedAt: at
|
|
1853
|
+
};
|
|
1804
1854
|
const item = {
|
|
1805
1855
|
id: "I7",
|
|
1806
1856
|
task: "PROJ-123",
|
|
@@ -2056,7 +2106,7 @@ const OPERATIONS = [
|
|
|
2056
2106
|
defineOperation({
|
|
2057
2107
|
id: "inbox.get",
|
|
2058
2108
|
kind: "query",
|
|
2059
|
-
description: "List the comments and
|
|
2109
|
+
description: "List the comments, blocks and turns addressed to the caller and not yet handled.",
|
|
2060
2110
|
mcp: {
|
|
2061
2111
|
whenToUse: "Read items awaiting the caller.",
|
|
2062
2112
|
whenNotToUse: "Use inbox_ack to mark them read."
|
|
@@ -2064,7 +2114,8 @@ const OPERATIONS = [
|
|
|
2064
2114
|
input: z.strictObject({ project }),
|
|
2065
2115
|
output: z.strictObject({
|
|
2066
2116
|
comments: z.array(commentSchema).describe("Comments not yet acknowledged."),
|
|
2067
|
-
blocks: z.array(blockViewSchema).describe("Open blocks addressed to the caller.")
|
|
2117
|
+
blocks: z.array(blockViewSchema).describe("Open blocks addressed to the caller."),
|
|
2118
|
+
turns: z.array(turnViewSchema).describe("Unclosed turns the caller may take or has taken; at most one per task.")
|
|
2068
2119
|
}),
|
|
2069
2120
|
grants: [{ grant: "project-agent" }, { grant: "operator" }],
|
|
2070
2121
|
errors: ["not_found"],
|
|
@@ -2078,23 +2129,35 @@ const OPERATIONS = [
|
|
|
2078
2129
|
input: {},
|
|
2079
2130
|
output: {
|
|
2080
2131
|
comments: [comment],
|
|
2081
|
-
blocks: [codeBlock]
|
|
2132
|
+
blocks: [codeBlock],
|
|
2133
|
+
turns: [{
|
|
2134
|
+
...reviewTurn,
|
|
2135
|
+
handed: [handedReview]
|
|
2136
|
+
}]
|
|
2082
2137
|
}
|
|
2083
2138
|
}]
|
|
2084
2139
|
}),
|
|
2085
2140
|
defineOperation({
|
|
2086
2141
|
id: "inbox.ack",
|
|
2087
2142
|
kind: "mutation",
|
|
2088
|
-
description: "Mark comments
|
|
2143
|
+
description: "Mark comments, agent-addressed blocks or turns as read; acking a turn makes the caller its taker.",
|
|
2089
2144
|
mcp: {
|
|
2090
2145
|
whenToUse: "Mark handled inbox items read.",
|
|
2091
2146
|
whenNotToUse: "Use inbox_get to inspect them first."
|
|
2092
2147
|
},
|
|
2093
|
-
input: z.strictObject({ entries: z.array(z.union([
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2148
|
+
input: z.strictObject({ entries: z.array(z.union([
|
|
2149
|
+
z.strictObject({
|
|
2150
|
+
id: commentIdSchema,
|
|
2151
|
+
revision: z.int().positive().describe("Revision the caller read.")
|
|
2152
|
+
}),
|
|
2153
|
+
z.strictObject({ id: blockIdSchema }),
|
|
2154
|
+
z.strictObject({ id: turnIdSchema })
|
|
2155
|
+
])).min(1).describe("Comment revisions, blocks and turns to acknowledge.") }),
|
|
2156
|
+
output: z.strictObject({ acked: z.array(z.union([
|
|
2157
|
+
commentIdSchema,
|
|
2158
|
+
blockIdSchema,
|
|
2159
|
+
turnIdSchema
|
|
2160
|
+
])).describe("Entries now acknowledged.") }),
|
|
2098
2161
|
grants: [{ grant: "project-agent" }],
|
|
2099
2162
|
errors: [
|
|
2100
2163
|
"wrong_id_kind",
|
|
@@ -2106,18 +2169,26 @@ const OPERATIONS = [
|
|
|
2106
2169
|
args: ["entries"]
|
|
2107
2170
|
},
|
|
2108
2171
|
slack: null,
|
|
2109
|
-
examples: [
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2172
|
+
examples: [
|
|
2173
|
+
{
|
|
2174
|
+
summary: "Acknowledge a comment revision",
|
|
2175
|
+
input: { entries: [{
|
|
2176
|
+
id: "C3",
|
|
2177
|
+
revision: 1
|
|
2178
|
+
}] },
|
|
2179
|
+
output: { acked: ["C3"] }
|
|
2180
|
+
},
|
|
2181
|
+
{
|
|
2182
|
+
summary: "Acknowledge an agent-addressed block",
|
|
2183
|
+
input: { entries: [{ id: "B13" }] },
|
|
2184
|
+
output: { acked: ["B13"] }
|
|
2185
|
+
},
|
|
2186
|
+
{
|
|
2187
|
+
summary: "Take a turn",
|
|
2188
|
+
input: { entries: [{ id: "T4" }] },
|
|
2189
|
+
output: { acked: ["T4"] }
|
|
2190
|
+
}
|
|
2191
|
+
]
|
|
2121
2192
|
}),
|
|
2122
2193
|
defineOperation({
|
|
2123
2194
|
id: "token.list",
|
|
@@ -2984,4 +3055,4 @@ function assertNever(value) {
|
|
|
2984
3055
|
throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
|
|
2985
3056
|
}
|
|
2986
3057
|
//#endregion
|
|
2987
|
-
export {
|
|
3058
|
+
export { encodeActorId as A, successEnvelopeSchema as B, SESSION_HEALTH_STATES as C, sessionFactsSchema as D, prRefSchema as E, ERRORS as F, RESERVED_PROJECT as G, DEFAULT_LINK as H, err as I, SLACK_BOT_SCOPES as J, configSchema as K, errorContextSchema as L, parseActorId as M, parseRef as N, ticketFactsSchema as O, taskKeySchema as P, errorEnvelopeSchema as R, eventPayloadSchemas as S, prFactsSchema as T, DEFAULT_SLACK_APP_NAME as U, DEFAULT_HTTP_PORT as V, DEFAULT_SLACK_COMMAND as W, inboundEventSchema as _, batchSchema as a, userIdSchema as b, buildCatalogSnapshot as c, turnHandedSchema as d, renderHttpProblem as f, conversationRefSchema as g, SPACE_IDS as h, AdapterError as i, errorCodeOf as j, actorIdSchema as k, roleCanUseOperation as l, renderMcpError as m, BOARD_TICK_MS as n, entityRefSchema as o, renderJsonError as p, requiredSecretKeys as q, SYSTEMD_SERVICE_SETTINGS as r, sourceCursorSchema as s, assertNever as t, OPERATIONS as u, interactionRefSchema as v, SESSION_STATUSES as w, EVENT_KINDS as x, messageRefSchema as y, ok as z };
|
package/package.json
CHANGED
|
@@ -63,7 +63,7 @@ Other errors: none.
|
|
|
63
63
|
|
|
64
64
|
### `board inbox`
|
|
65
65
|
|
|
66
|
-
Purpose: List the comments and
|
|
66
|
+
Purpose: List the comments, blocks and turns addressed to the caller and not yet handled.
|
|
67
67
|
Arguments: none.
|
|
68
68
|
Flags: `--project <value>`, `--json`.
|
|
69
69
|
Use when: Read items awaiting the caller.
|
|
@@ -73,7 +73,7 @@ Other errors: `not_found`.
|
|
|
73
73
|
|
|
74
74
|
### `board inbox ack`
|
|
75
75
|
|
|
76
|
-
Purpose: Mark comments
|
|
76
|
+
Purpose: Mark comments, agent-addressed blocks or turns as read; acking a turn makes the caller its taker.
|
|
77
77
|
Arguments: `<entries>`.
|
|
78
78
|
Flags: `--key <key>`, `--json`.
|
|
79
79
|
Use when: Mark handled inbox items read.
|