spur-board 0.104.3 → 0.105.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-2UOGIWN_.mjs → chunk-D-1P5oeK.mjs} +1 -1
- package/dist/{chunk-DGsDK61k.mjs → chunk-IDeN7dOW.mjs} +5 -3
- package/dist/{chunk-BTkdnlO3.mjs → chunk-gi-XmApc.mjs} +2 -2
- package/dist/cli.mjs +3 -3
- package/dist/client.mjs +1 -1
- package/dist/daemon.mjs +98 -35
- package/dist/mcp.mjs +3 -3
- package/dist/web/assets/{index-B35CcJ4n.js → index-DpAnZoCX.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/skills/spur-board/references/how-board-works-blocks.md +30 -26
- package/skills/spur-board/references/how-board-works-turns.md +10 -0
- package/skills/spur-board/references/web-ui-board.md +4 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as renderJsonError, at as successEnvelopeSchema, c as tokenRequestStatusSchema, et as ERRORS, nt as errorContextSchema, o as tokenRequestResultSchema, rt as errorEnvelopeSchema } from "./chunk-
|
|
1
|
+
import { _ as renderJsonError, at as successEnvelopeSchema, c as tokenRequestStatusSchema, et as ERRORS, nt as errorContextSchema, o as tokenRequestResultSchema, rt as errorEnvelopeSchema } from "./chunk-IDeN7dOW.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
|
@@ -2921,6 +2921,7 @@ const inboxEntrySchema = z.strictObject({
|
|
|
2921
2921
|
kind: z.enum(INBOX_KINDS).describe("block for a block addressed to the operator, turn for a turn, else the item kind."),
|
|
2922
2922
|
severity: z.enum(INBOX_SEVERITIES).describe("failure: the board or a connection broke; attention: a decision, answer or other operator action is wanted."),
|
|
2923
2923
|
text: z.string().describe("What needs the operator, in one line."),
|
|
2924
|
+
url: z.url({ protocol: /^https?$/ }).and(z.string().regex(/^[hH][tT][tT][pP][sS]?:\/\//)).optional().describe("Meaningful external destination for this entry, when known; HTTP(S) only. Task navigation takes precedence in the web inbox."),
|
|
2924
2925
|
action: z.string().min(1).optional().describe("What the operator does about an item entry; the text ends with it. Absent on block and turn entries."),
|
|
2925
2926
|
at: z.iso.datetime().describe("When the entry was raised or opened, ISO 8601 UTC."),
|
|
2926
2927
|
task: taskKeySchema.nullable().describe("Task the entry is about; null when it has none."),
|
|
@@ -3753,10 +3754,11 @@ const OPERATIONS = [
|
|
|
3753
3754
|
{
|
|
3754
3755
|
id: "I9",
|
|
3755
3756
|
project: "_board",
|
|
3756
|
-
kind: "
|
|
3757
|
+
kind: "board_observation",
|
|
3757
3758
|
severity: "failure",
|
|
3758
|
-
text:
|
|
3759
|
-
action: "
|
|
3759
|
+
text: "example/web: main is red (build): open the failing run; fix or revert",
|
|
3760
|
+
action: "open the failing run; fix or revert",
|
|
3761
|
+
url: "https://github.com/example/web/actions/runs/42",
|
|
3760
3762
|
at,
|
|
3761
3763
|
task: null
|
|
3762
3764
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as buildCatalogSnapshot, gt as plainHttpAllowed, mt as configSchema, p as OPERATIONS } from "./chunk-
|
|
2
|
-
import { o as CliError, t as fetchCatalogVersion } from "./chunk-
|
|
1
|
+
import { d as buildCatalogSnapshot, gt as plainHttpAllowed, mt as configSchema, p as OPERATIONS } from "./chunk-IDeN7dOW.mjs";
|
|
2
|
+
import { o as CliError, t as fetchCatalogVersion } from "./chunk-D-1P5oeK.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/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { St as SLACK_BOT_SCOPES, Y as actorIdSchema, _t as requiredSecretKeys, a as requestHashOf, at as successEnvelopeSchema, et as ERRORS, f as roleCanUseOperation, mt as configSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, ut as DEFAULT_STAND_PORT_RANGE, vt as resolveWebOrigin } from "./chunk-
|
|
1
|
+
import { St as SLACK_BOT_SCOPES, Y as actorIdSchema, _t as requiredSecretKeys, a as requestHashOf, at as successEnvelopeSchema, et as ERRORS, f as roleCanUseOperation, mt as configSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, ut as DEFAULT_STAND_PORT_RANGE, vt as resolveWebOrigin } from "./chunk-IDeN7dOW.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
|
|
3
|
-
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-
|
|
4
|
-
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-
|
|
3
|
+
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-D-1P5oeK.mjs";
|
|
4
|
+
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-gi-XmApc.mjs";
|
|
5
5
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
6
6
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
7
7
|
import { homedir, hostname, userInfo } from "node:os";
|
package/dist/client.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-
|
|
1
|
+
export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-D-1P5oeK.mjs";
|
package/dist/daemon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as parseRef$1, A as defaultBranchFactSchema, B as isExternalAuthor, C as messageRefSchema, Ct as TASK_HOLDS, D as eventPayloadSchemas, E as GATE_REASONS, F as trackerSourceId, G as sessionFactsSchema, H as prFactsSchema, I as PR_STATES, J as REF_NUMBER, K as ticketFactsSchema, L as REVIEW_STATES, M as prSourceId, N as sessionTransitionSchema, O as AdapterError, P as sourceCursorSchema, Q as parseActorId, R as SESSION_HEALTH_STATES, S as interactionRefSchema, St as SLACK_BOT_SCOPES, T as EVENT_KINDS, U as prRefSchema, V as parseRingMarker, W as ringMarker, X as encodeActorId, Y as actorIdSchema, Z as errorCodeOf, _t as requiredSecretKeys, a as requestHashOf, at as successEnvelopeSchema, b as conversationRefSchema, bt as DISPATCHER_MODES, c as tokenRequestStatusSchema, d as buildCatalogSnapshot, dt as RESERVED_PROJECT, et as ERRORS, f as roleCanUseOperation, ft as boardWideSpurProject, g as renderHttpProblem, gt as plainHttpAllowed, h as turnHandedSchema, ht as defaultAddressee, i as TOKEN_REQUEST_LIMITS, it as ok, j as entityRefSchema, k as batchSchema, l as BOARD_TICK_MS, lt as DEFAULT_SLACK_COMMAND, m as defaultBranchViewSchema, mt as configSchema, n as doctorReportSchema, o as tokenRequestResultSchema, p as OPERATIONS, pt as configBindings, q as JIRA_PROJECT_KEY, s as tokenRequestSchema, st as DEFAULT_LINK, t as assertNever, tt as err, vt as resolveWebOrigin, w as userIdSchema, wt as VIAS, x as inboundEventSchema, xt as ITEM_KINDS, y as SPACE_IDS, yt as COLUMN_IDS, z as SESSION_STATUSES } from "./chunk-
|
|
1
|
+
import { $ as parseRef$1, A as defaultBranchFactSchema, B as isExternalAuthor, C as messageRefSchema, Ct as TASK_HOLDS, D as eventPayloadSchemas, E as GATE_REASONS, F as trackerSourceId, G as sessionFactsSchema, H as prFactsSchema, I as PR_STATES, J as REF_NUMBER, K as ticketFactsSchema, L as REVIEW_STATES, M as prSourceId, N as sessionTransitionSchema, O as AdapterError, P as sourceCursorSchema, Q as parseActorId, R as SESSION_HEALTH_STATES, S as interactionRefSchema, St as SLACK_BOT_SCOPES, T as EVENT_KINDS, U as prRefSchema, V as parseRingMarker, W as ringMarker, X as encodeActorId, Y as actorIdSchema, Z as errorCodeOf, _t as requiredSecretKeys, a as requestHashOf, at as successEnvelopeSchema, b as conversationRefSchema, bt as DISPATCHER_MODES, c as tokenRequestStatusSchema, d as buildCatalogSnapshot, dt as RESERVED_PROJECT, et as ERRORS, f as roleCanUseOperation, ft as boardWideSpurProject, g as renderHttpProblem, gt as plainHttpAllowed, h as turnHandedSchema, ht as defaultAddressee, i as TOKEN_REQUEST_LIMITS, it as ok, j as entityRefSchema, k as batchSchema, l as BOARD_TICK_MS, lt as DEFAULT_SLACK_COMMAND, m as defaultBranchViewSchema, mt as configSchema, n as doctorReportSchema, o as tokenRequestResultSchema, p as OPERATIONS, pt as configBindings, q as JIRA_PROJECT_KEY, s as tokenRequestSchema, st as DEFAULT_LINK, t as assertNever, tt as err, vt as resolveWebOrigin, w as userIdSchema, wt as VIAS, x as inboundEventSchema, xt as ITEM_KINDS, y as SPACE_IDS, yt as COLUMN_IDS, z as SESSION_STATUSES } from "./chunk-IDeN7dOW.mjs";
|
|
2
2
|
import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -13634,7 +13634,7 @@ const deliveryPayloadSchema = z.object({
|
|
|
13634
13634
|
notificationId: z.unknown().optional()
|
|
13635
13635
|
});
|
|
13636
13636
|
/** The outbox row of a `delivery:<outbox id>` item; the item itself has no task. */
|
|
13637
|
-
function deliveryId(item) {
|
|
13637
|
+
function deliveryId$1(item) {
|
|
13638
13638
|
return item.kind === "post_failed" && item.task_id === null ? Number(item.item_key.slice(9)) : void 0;
|
|
13639
13639
|
}
|
|
13640
13640
|
/**
|
|
@@ -13643,7 +13643,7 @@ function deliveryId(item) {
|
|
|
13643
13643
|
*/
|
|
13644
13644
|
async function deliveryOwners(trx, items) {
|
|
13645
13645
|
const owners = /* @__PURE__ */ new Map();
|
|
13646
|
-
const outboxIds = items.flatMap((item) => deliveryId(item) ?? []);
|
|
13646
|
+
const outboxIds = items.flatMap((item) => deliveryId$1(item) ?? []);
|
|
13647
13647
|
if (outboxIds.length === 0) return owners;
|
|
13648
13648
|
const rows = await trx.selectFrom("outbox").select([
|
|
13649
13649
|
"id",
|
|
@@ -13680,7 +13680,7 @@ async function deliveryOwners(trx, items) {
|
|
|
13680
13680
|
const tasks = await trx.selectFrom("task").selectAll().where("id", "in", [...new Set(taskIds.values())]).execute();
|
|
13681
13681
|
const taskById = new Map(tasks.map((task) => [task.id, task]));
|
|
13682
13682
|
for (const item of items) {
|
|
13683
|
-
const outboxId = deliveryId(item);
|
|
13683
|
+
const outboxId = deliveryId$1(item);
|
|
13684
13684
|
const taskId = outboxId === void 0 ? void 0 : taskIds.get(outboxId);
|
|
13685
13685
|
const task = taskId === void 0 ? void 0 : taskById.get(taskId);
|
|
13686
13686
|
if (task !== void 0) owners.set(item.id, task);
|
|
@@ -14098,6 +14098,52 @@ function serviceOf(source) {
|
|
|
14098
14098
|
if (source.startsWith("github:") || source.startsWith("github-issues:")) return "GitHub";
|
|
14099
14099
|
return source.startsWith("jira:") ? "Jira" : void 0;
|
|
14100
14100
|
}
|
|
14101
|
+
const externalUrlSchema = z.url({ protocol: /^https?$/ });
|
|
14102
|
+
/** Only structured destinations count; the task-less feed placeholder is never navigation. */
|
|
14103
|
+
function meaningfulUrl(value) {
|
|
14104
|
+
if (!externalUrlSchema.safeParse(value).success) return void 0;
|
|
14105
|
+
const url = new URL(value);
|
|
14106
|
+
if (url.origin === "https://github.com" && url.pathname === "/") return void 0;
|
|
14107
|
+
return url.href;
|
|
14108
|
+
}
|
|
14109
|
+
function deliveredUrl(value) {
|
|
14110
|
+
if (value === null) return void 0;
|
|
14111
|
+
let decoded;
|
|
14112
|
+
try {
|
|
14113
|
+
decoded = JSON.parse(value);
|
|
14114
|
+
} catch (error) {
|
|
14115
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
14116
|
+
return;
|
|
14117
|
+
}
|
|
14118
|
+
const ref = deliveredRefSchema.safeParse(decoded);
|
|
14119
|
+
return ref.success ? meaningfulUrl(ref.data.permalink) : void 0;
|
|
14120
|
+
}
|
|
14121
|
+
function deliveryId(item) {
|
|
14122
|
+
if (item.kind !== "post_failed" || !/^delivery:[1-9]\d*$/.test(item.item_key)) return void 0;
|
|
14123
|
+
const id = Number(item.item_key.slice(9));
|
|
14124
|
+
return Number.isSafeInteger(id) ? id : void 0;
|
|
14125
|
+
}
|
|
14126
|
+
/** One batched join, including only the immediate parent of each failed delivery. */
|
|
14127
|
+
async function deliveryUrls(trx, items) {
|
|
14128
|
+
const ids = items.flatMap((item) => deliveryId(item) ?? []);
|
|
14129
|
+
if (ids.length === 0) return /* @__PURE__ */ new Map();
|
|
14130
|
+
const rows = await trx.selectFrom("outbox").leftJoin("outbox as parent", "parent.id", "outbox.parent_outbox_id").select([
|
|
14131
|
+
"outbox.id",
|
|
14132
|
+
"outbox.external_ref",
|
|
14133
|
+
"parent.external_ref as parent_ref"
|
|
14134
|
+
]).where("outbox.id", "in", ids).execute();
|
|
14135
|
+
return new Map(rows.map((row) => [row.id, deliveredUrl(row.external_ref) ?? deliveredUrl(row.parent_ref)]));
|
|
14136
|
+
}
|
|
14137
|
+
function itemUrl(item, deliveries) {
|
|
14138
|
+
if (item.item_key.startsWith("source:")) {
|
|
14139
|
+
const service = serviceOf(item.item_key.slice(7));
|
|
14140
|
+
if (service === "GitHub") return "https://docs.github.com/en/rest/using-the-rest-api/troubleshooting-the-rest-api";
|
|
14141
|
+
if (service === "Jira") return "https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro";
|
|
14142
|
+
return;
|
|
14143
|
+
}
|
|
14144
|
+
const id = deliveryId(item);
|
|
14145
|
+
return id === void 0 ? meaningfulUrl(item.url) : deliveries.get(id);
|
|
14146
|
+
}
|
|
14101
14147
|
/**
|
|
14102
14148
|
* The text of a source item: built from the source's state while it is open and blind; a cleared
|
|
14103
14149
|
* or unknown one keeps its stored text, which names the failure it had.
|
|
@@ -14176,7 +14222,7 @@ function createOperatorInbox(deps) {
|
|
|
14176
14222
|
const items = [...openItems, ...lastCleared.values()];
|
|
14177
14223
|
const blockIds = [...new Set(items.flatMap((item) => itemBlockRef(item) ?? []))];
|
|
14178
14224
|
const sourceIds = items.flatMap((item) => item.item_key.startsWith("source:") ? [item.item_key.slice(7)] : []);
|
|
14179
|
-
const [referenced, owners, sources] = await Promise.all([
|
|
14225
|
+
const [referenced, owners, sources, deliveries] = await Promise.all([
|
|
14180
14226
|
blockIds.length === 0 ? Promise.resolve([]) : trx.selectFrom("block").leftJoin("task", "task.id", "block.task_id").select([
|
|
14181
14227
|
"block.id",
|
|
14182
14228
|
"block.addressee_role",
|
|
@@ -14189,7 +14235,8 @@ function createOperatorInbox(deps) {
|
|
|
14189
14235
|
"source",
|
|
14190
14236
|
"blind_reason",
|
|
14191
14237
|
"blind_message"
|
|
14192
|
-
]).where("source", "in", sourceIds).execute()
|
|
14238
|
+
]).where("source", "in", sourceIds).execute(),
|
|
14239
|
+
deliveryUrls(trx, items)
|
|
14193
14240
|
]);
|
|
14194
14241
|
const blockById = new Map(referenced.map((block) => [block.id, block]));
|
|
14195
14242
|
const sourceById = new Map(sources.map((state) => [state.source, state]));
|
|
@@ -14208,6 +14255,7 @@ function createOperatorInbox(deps) {
|
|
|
14208
14255
|
task
|
|
14209
14256
|
})
|
|
14210
14257
|
};
|
|
14258
|
+
const url = itemUrl(item, deliveries);
|
|
14211
14259
|
return {
|
|
14212
14260
|
id: `I${String(item.id)}`,
|
|
14213
14261
|
project: task?.project ?? (block === void 0 ? "_board" : blockProject(block.project)),
|
|
@@ -14217,6 +14265,7 @@ function createOperatorInbox(deps) {
|
|
|
14217
14265
|
action,
|
|
14218
14266
|
at: item.raised_at,
|
|
14219
14267
|
task: task?.key ?? null,
|
|
14268
|
+
...url === void 0 ? {} : { url },
|
|
14220
14269
|
...item.cleared_at === null ? {} : { handledAt: item.cleared_at }
|
|
14221
14270
|
};
|
|
14222
14271
|
};
|
|
@@ -15482,15 +15531,6 @@ function evaluateSessionHealth(input) {
|
|
|
15482
15531
|
seen.add(identity);
|
|
15483
15532
|
const task = tasks[session.taskId];
|
|
15484
15533
|
if (session.endedAt !== null) {
|
|
15485
|
-
if (session.role === "worker" && (session.endReason === "kill" || session.endReason === "vanished") && task?.turnSessions?.includes(session.id) === true && !liveWorkerTasks.has(session.taskId)) {
|
|
15486
|
-
const flag = {
|
|
15487
|
-
taskId: session.taskId,
|
|
15488
|
-
sessionId: session.id,
|
|
15489
|
-
kind: "worker_lost"
|
|
15490
|
-
};
|
|
15491
|
-
(spur.observationComplete ? flags : held).push(flag);
|
|
15492
|
-
continue;
|
|
15493
|
-
}
|
|
15494
15534
|
if (session.role === "worker" && (session.endReason === "complete" || session.endReason === "kill" || session.endReason === "vanished") && task !== void 0 && !task.hasOpenPr && !task.hasMergedPr && !liveWorkerTasks.has(session.taskId)) {
|
|
15495
15535
|
const flag = {
|
|
15496
15536
|
taskId: session.taskId,
|
|
@@ -15554,16 +15594,14 @@ const stallObservationSchema = z.object({
|
|
|
15554
15594
|
const ENDED_WORKER_LABELS = {
|
|
15555
15595
|
worker_completed: "worker ended (completed), no PR",
|
|
15556
15596
|
worker_killed: "worker ended (killed), no PR",
|
|
15557
|
-
worker_vanished: "worker vanished, no PR"
|
|
15558
|
-
worker_lost: "worker ended during its open turn"
|
|
15597
|
+
worker_vanished: "worker vanished, no PR"
|
|
15559
15598
|
};
|
|
15560
15599
|
/** Health flags only the operator can resolve; each opens an operator block. */
|
|
15561
15600
|
const ANOMALY_FLAGS = /* @__PURE__ */ new Set([
|
|
15562
15601
|
"stuck_worker",
|
|
15563
15602
|
"stuck_orchestrator",
|
|
15564
15603
|
"needs_input",
|
|
15565
|
-
"worker_completed"
|
|
15566
|
-
"worker_lost"
|
|
15604
|
+
"worker_completed"
|
|
15567
15605
|
]);
|
|
15568
15606
|
/**
|
|
15569
15607
|
* The item for an open operator conversation with a ring that waits for a live session of its
|
|
@@ -15627,6 +15665,7 @@ async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurC
|
|
|
15627
15665
|
}
|
|
15628
15666
|
const tasks = await trx.selectFrom("task").selectAll().where("membership", "!=", "archived").execute();
|
|
15629
15667
|
const taskById = new Map(tasks.map((task) => [task.id, task]));
|
|
15668
|
+
const endedHolders = await endedTurnItems(trx, taskById, candidates, new Date(now));
|
|
15630
15669
|
const misses = await trx.selectFrom("source_miss").selectAll().execute();
|
|
15631
15670
|
for (const miss of misses) {
|
|
15632
15671
|
if (miss.gone !== 1) continue;
|
|
@@ -15741,8 +15780,7 @@ async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurC
|
|
|
15741
15780
|
for (const task of tasks) taskPrs[String(task.id)] = {
|
|
15742
15781
|
hasOpenPr: false,
|
|
15743
15782
|
hasMergedPr: false,
|
|
15744
|
-
prCompleteAt: prCompleteAt(config.projects.find((entry) => entry.id === task.project), sourceById)
|
|
15745
|
-
turnSessions: []
|
|
15783
|
+
prCompleteAt: prCompleteAt(config.projects.find((entry) => entry.id === task.project), sourceById)
|
|
15746
15784
|
};
|
|
15747
15785
|
const tickets = await trx.selectFrom("ticket_snapshot").select([
|
|
15748
15786
|
"task_id",
|
|
@@ -15769,11 +15807,6 @@ async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurC
|
|
|
15769
15807
|
const project = config.projects.find((entry) => entry.id === task.project);
|
|
15770
15808
|
state.hasMergedPr = at === null || project === void 0 || mergedTicket(project, config, tickets.find((entry) => entry.task_id === taskId), task.manual_include === 1, at) !== "open";
|
|
15771
15809
|
}
|
|
15772
|
-
const workerTurns = await trx.selectFrom("turn").select(["task_id", "acked_by"]).where("role", "=", "worker").where("closed_at", "is", null).where("acked_at", "is not", null).execute();
|
|
15773
|
-
for (const turn of workerTurns) {
|
|
15774
|
-
const holder = turn.acked_by === null ? null : parseActorId(turn.acked_by);
|
|
15775
|
-
if (holder?.actor === "agent") taskPrs[String(turn.task_id)]?.turnSessions.push(holder.actorRef.session);
|
|
15776
|
-
}
|
|
15777
15810
|
const heldKeys = [];
|
|
15778
15811
|
for (const task of tasks) {
|
|
15779
15812
|
const state = taskPrs[String(task.id)];
|
|
@@ -15972,6 +16005,7 @@ async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurC
|
|
|
15972
16005
|
value: toJson(episodeSchema, health.episode)
|
|
15973
16006
|
}).onConflict((oc) => oc.column("key").doUpdateSet({ value: toJson(episodeSchema, health.episode) })).execute();
|
|
15974
16007
|
for (const flag of health.flags) {
|
|
16008
|
+
if (endedHolders.has(`${flag.taskId}:${flag.sessionId}`)) continue;
|
|
15975
16009
|
const task = taskById.get(Number(flag.taskId));
|
|
15976
16010
|
if (task === void 0) continue;
|
|
15977
16011
|
const fact = subjects.find((subject) => subject.taskId === flag.taskId && subject.id === flag.sessionId);
|
|
@@ -16001,11 +16035,11 @@ async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurC
|
|
|
16001
16035
|
const threshold = stuckTurnAfterMs(config);
|
|
16002
16036
|
for (const { turn, sessionId, ended, quietSince, reminder, delivered } of await quietTurns(trx)) {
|
|
16003
16037
|
const task = taskById.get(turn.task_id);
|
|
16004
|
-
if (task === void 0 || quietSince === null || flagged.has(sessionId)) continue;
|
|
16038
|
+
if (ended || task === void 0 || quietSince === null || flagged.has(sessionId)) continue;
|
|
16005
16039
|
const quiet = Date.parse(quietSince);
|
|
16006
16040
|
const reminded = reminder !== void 0 && delivered && reminder.acked_at !== null && now >= Math.max(Date.parse(reminder.acked_at), quiet) + threshold;
|
|
16007
16041
|
const unreached = reminder !== void 0 && reminder.exhausted_at !== null && now >= quiet + threshold;
|
|
16008
|
-
if (!reminded && !unreached
|
|
16042
|
+
if (!reminded && !unreached) continue;
|
|
16009
16043
|
candidates.push({
|
|
16010
16044
|
key: `stuck-turn:${String(turn.id)}`,
|
|
16011
16045
|
kind: "anomaly",
|
|
@@ -16021,6 +16055,7 @@ async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurC
|
|
|
16021
16055
|
const ordered = orderItems(candidates);
|
|
16022
16056
|
const seen = /* @__PURE__ */ new Set([...ordered.map((item) => item.key), ...heldKeys]);
|
|
16023
16057
|
for (const flag of health.held) {
|
|
16058
|
+
if (endedHolders.has(`${flag.taskId}:${flag.sessionId}`)) continue;
|
|
16024
16059
|
const task = taskById.get(Number(flag.taskId));
|
|
16025
16060
|
if (task !== void 0 && !stalled.has(`${flag.taskId}:${flag.sessionId}`)) seen.add(healthKey(task.id, flag));
|
|
16026
16061
|
}
|
|
@@ -16030,7 +16065,7 @@ async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurC
|
|
|
16030
16065
|
sessionId: subject.id,
|
|
16031
16066
|
kind: subject.role === "worker" ? "stuck_worker" : "stuck_orchestrator"
|
|
16032
16067
|
})));
|
|
16033
|
-
const spurHeld = spurBlind ? await blindHeldKeys(trx, subjects) : /* @__PURE__ */ new Set();
|
|
16068
|
+
const spurHeld = spurBlind ? await blindHeldKeys(trx, subjects.filter((subject) => !endedHolders.has(`${subject.taskId}:${subject.id}`))) : /* @__PURE__ */ new Set();
|
|
16034
16069
|
if (stallBlind) for (const key of stallHeld) spurHeld.add(key);
|
|
16035
16070
|
for (const item of existing) {
|
|
16036
16071
|
if (item.kind !== "anomaly") continue;
|
|
@@ -16142,16 +16177,44 @@ async function closeEndedDoneTurns(trx, at) {
|
|
|
16142
16177
|
reason: "moved",
|
|
16143
16178
|
at
|
|
16144
16179
|
});
|
|
16145
|
-
const keys = [`stuck-turn:${String(turn.id)}`,
|
|
16146
|
-
taskId: String(turn.task_id),
|
|
16147
|
-
sessionId,
|
|
16148
|
-
kind: "worker_lost"
|
|
16149
|
-
})];
|
|
16180
|
+
const keys = [`stuck-turn:${String(turn.id)}`, `health:${String(turn.task_id)}:${sessionId}:worker_lost`];
|
|
16150
16181
|
const items = await trx.selectFrom("operator_item").selectAll().where("item_key", "in", keys).where("cleared_at", "is", null).execute();
|
|
16151
16182
|
const reason = `turn T${String(turn.id)} closed: its holder ${sessionId} ended in Done`;
|
|
16152
16183
|
for (const item of items) await clearReconciled(trx, item, at, reason);
|
|
16153
16184
|
}
|
|
16154
16185
|
}
|
|
16186
|
+
/** Raise ended-holder attention from ownership, independent of links, PRs and source freshness. */
|
|
16187
|
+
async function endedTurnItems(trx, tasks, candidates, at) {
|
|
16188
|
+
const holders = /* @__PURE__ */ new Set();
|
|
16189
|
+
const turns = await trx.selectFrom("turn").selectAll().where("closed_at", "is", null).where("acked_at", "is not", null).execute();
|
|
16190
|
+
for (const turn of turns) {
|
|
16191
|
+
const holder = turn.acked_by === null ? null : parseActorId(turn.acked_by);
|
|
16192
|
+
if (holder?.actor !== "agent") continue;
|
|
16193
|
+
const sessionId = holder.actorRef.session;
|
|
16194
|
+
const session = await trx.selectFrom("session_snapshot").selectAll().where("id", "=", sessionId).executeTakeFirst();
|
|
16195
|
+
if (session === void 0 || session.ended_at === null) continue;
|
|
16196
|
+
const parsed = sessionFactsSchema.safeParse(JSON.parse(session.detail));
|
|
16197
|
+
if (!parsed.success || parsed.data.id !== sessionId || parsed.data.spurProject !== holder.actorRef.project || parsed.data.endedAt === null) continue;
|
|
16198
|
+
const keys = [`stuck-turn:${String(turn.id)}`, `health:${String(turn.task_id)}:${sessionId}:worker_lost`];
|
|
16199
|
+
const legacy = await trx.selectFrom("operator_item").selectAll().where("item_key", "in", keys).where("cleared_at", "is", null).execute();
|
|
16200
|
+
const reason = `turn T${String(turn.id)} holder ${sessionId} ended; start a replacement worker or archive the task`;
|
|
16201
|
+
for (const item of legacy) await clearReconciled(trx, item, at, reason);
|
|
16202
|
+
const task = tasks.get(turn.task_id);
|
|
16203
|
+
if (task === void 0 || task.column === "done" || turn.column !== task.column || turn.epoch !== task.column_epoch) continue;
|
|
16204
|
+
holders.add(`${String(task.id)}:${sessionId}`);
|
|
16205
|
+
candidates.push({
|
|
16206
|
+
key: `ended-turn:${String(turn.id)}:${sessionId}`,
|
|
16207
|
+
kind: "worker_ended",
|
|
16208
|
+
taskId: task.id,
|
|
16209
|
+
summary: `${task.key}: turn T${String(turn.id)} holder ${sessionId} ended`,
|
|
16210
|
+
factAt: session.ended_at,
|
|
16211
|
+
revision: session.ended_at,
|
|
16212
|
+
source: "spur",
|
|
16213
|
+
priority: 4
|
|
16214
|
+
});
|
|
16215
|
+
}
|
|
16216
|
+
return holders;
|
|
16217
|
+
}
|
|
16155
16218
|
/**
|
|
16156
16219
|
* Raises the cycle-limit block of a task's column, once while it is open. The operator's close
|
|
16157
16220
|
* of the block or its item is the reset: a later call opens a new block.
|
|
@@ -16178,7 +16241,7 @@ async function blindHeldKeys(trx, subjects) {
|
|
|
16178
16241
|
sessionId: subject.id,
|
|
16179
16242
|
kind
|
|
16180
16243
|
}));
|
|
16181
|
-
for (const { turn } of await quietTurns(trx)) held.add(`stuck-turn:${String(turn.id)}`);
|
|
16244
|
+
for (const { turn, ended } of await quietTurns(trx)) if (!ended) held.add(`stuck-turn:${String(turn.id)}`);
|
|
16182
16245
|
return held;
|
|
16183
16246
|
}
|
|
16184
16247
|
/** A producer's local healthSince can restart without a new current observed health state. */
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { et as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-
|
|
2
|
-
import { o as CliError, r as requestOperation } from "./chunk-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-
|
|
1
|
+
import { et as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-IDeN7dOW.mjs";
|
|
2
|
+
import { o as CliError, r as requestOperation } from "./chunk-D-1P5oeK.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-gi-XmApc.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|