spur-board 0.151.1 → 0.153.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.
@@ -1,4 +1,4 @@
1
- import { _ as renderJsonError, c as tokenRequestStatusSchema, dt as errorContextSchema, ft as errorEnvelopeSchema, lt as ERRORS, mt as successEnvelopeSchema, o as tokenRequestResultSchema } from "./chunk-6hZvXPE0.mjs";
1
+ import { _ as renderJsonError, c as tokenRequestStatusSchema, dt as errorContextSchema, ft as errorEnvelopeSchema, lt as ERRORS, mt as successEnvelopeSchema, o as tokenRequestResultSchema } from "./chunk-H8DV9VuH.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
@@ -1,5 +1,5 @@
1
- import { Ot as plainHttpAllowed, Tt as configSchema, d as buildCatalogSnapshot, p as OPERATIONS } from "./chunk-6hZvXPE0.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-D8IOOBWp.mjs";
1
+ import { Ot as plainHttpAllowed, Tt as configSchema, d as buildCatalogSnapshot, p as OPERATIONS } from "./chunk-H8DV9VuH.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-DCth-W_y.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";
@@ -208,13 +208,14 @@ const TURN_OUTCOMES = [
208
208
  ];
209
209
  /**
210
210
  * How a turn wait ended: `woken` when its time ran out, `submitted` by the holder's submit,
211
- * `closed` by any other turn close, a take or the holder's end, `limit` when it ran out and the
212
- * turn's waits reached their count or total time.
211
+ * `closed` by any other turn close, a take or the holder's end, `ended` when the operator ended it
212
+ * early, `limit` when it ran out and the turn's waits reached their count or total time.
213
213
  */
214
214
  const TURN_WAIT_OUTCOMES = [
215
215
  "woken",
216
216
  "submitted",
217
217
  "closed",
218
+ "ended",
218
219
  "limit"
219
220
  ];
220
221
  /** The exit conditions of the column gates, as `board task --why` names them. */
@@ -1312,6 +1313,13 @@ const ERRORS = {
1312
1313
  hint: "Check which role may run the operation in `board schema`, or ask the operator.",
1313
1314
  recovery: noRetry("Use an allowed role or ask the operator for access.")
1314
1315
  }),
1316
+ not_operator: spec("not_operator", {
1317
+ status: 403,
1318
+ exit: EXIT_CODES.refused,
1319
+ message: "Only the operator may end a turn's wait early.",
1320
+ hint: "Ask the operator to end the wait; as its holder, submit or return the turn, or start a shorter wait.",
1321
+ recovery: noRetry("Ask the operator to end the wait.")
1322
+ }),
1315
1323
  not_found: spec("not_found", {
1316
1324
  status: 404,
1317
1325
  exit: EXIT_CODES.refused,
@@ -1375,6 +1383,13 @@ const ERRORS = {
1375
1383
  hint: "Submit or return the turn; the operator gets an inbox item once the wait ends.",
1376
1384
  recovery: noRetry("Submit or return the turn instead of waiting again.")
1377
1385
  }),
1386
+ no_active_wait: spec("no_active_wait", {
1387
+ status: 409,
1388
+ exit: EXIT_CODES.refused,
1389
+ message: "The turn has no active wait; it ended or never started.",
1390
+ hint: "Read the turn with `board task <KEY>`; there is no wait left to end.",
1391
+ recovery: noRetry("Read the turn before ending its wait again.")
1392
+ }),
1378
1393
  submit_basis_invalid: spec("submit_basis_invalid", {
1379
1394
  status: 409,
1380
1395
  exit: EXIT_CODES.refused,
@@ -3438,17 +3453,18 @@ const taskReturnOutputSchema = z.strictObject({
3438
3453
  block: blockViewSchema
3439
3454
  });
3440
3455
  const taskWaitInputSchema = z.strictObject({
3441
- turn: turnIdSchema.describe("Turn ID you took (T4)."),
3442
- for: z.int().min(1).max(120).describe("Whole minutes to wait, 1 to 120; the turn total cap may shorten it."),
3443
- reason: z.string().min(1).max(200).regex(/\S/).describe("What you wait for, up to 200 characters; the wake ring repeats it.")
3456
+ turn: turnIdSchema.describe("Turn ID you took (T4); with end, the turn whose wait you end as the operator."),
3457
+ for: z.int().min(1).max(120).optional().describe("Whole minutes to wait, 1 to 120; the turn total cap may shorten it. Required unless end."),
3458
+ reason: z.string().min(1).max(200).regex(/\S/).optional().describe("What you wait for, up to 200 characters; the wake ring repeats it. Required unless end. Wait only on a condition you cannot change and must re-check: a busy test stand, no free slot, high machine load, a deploy, an outside service. Not on your own work (review fixes, tests, checks, rebasing): work holding the turn, so a stall reaches the operator; a wait hides it."),
3459
+ end: z.boolean().optional().describe("Operator only: end the turn's active wait now instead of starting one; pass no for or reason.")
3444
3460
  });
3445
3461
  const taskWaitOutputSchema = z.strictObject({
3446
3462
  turn: turnIdSchema.describe("The waiting turn."),
3447
- wait: turnWaitSchema,
3448
- waits: z.int().min(1).describe("Waits the turn has started, this one included.")
3463
+ wait: turnWaitSchema.optional().describe("The wait just started; absent after end."),
3464
+ waits: z.int().min(1).describe("Waits the turn has started, this one or the ended one included.")
3449
3465
  });
3450
3466
  /**
3451
- * The three writes as `browserOperations` entries (`../browser.ts`), kept beside their schemas: the
3467
+ * The four writes as `browserOperations` entries (`../browser.ts`), kept beside their schemas: the
3452
3468
  * web Turn section calls them, and the catalog shares the same schema objects.
3453
3469
  */
3454
3470
  const turnWriteOperations = {
@@ -3469,6 +3485,12 @@ const turnWriteOperations = {
3469
3485
  kind: "mutation",
3470
3486
  input: taskReturnInputSchema,
3471
3487
  output: taskReturnOutputSchema
3488
+ },
3489
+ "task.wait": {
3490
+ id: "task.wait",
3491
+ kind: "mutation",
3492
+ input: taskWaitInputSchema,
3493
+ output: taskWaitOutputSchema
3472
3494
  }
3473
3495
  };
3474
3496
  // ../contracts/src/ops/config-view-schema.ts
@@ -5496,13 +5518,14 @@ const OPERATIONS = [
5496
5518
  defineOperation({
5497
5519
  id: "task.wait",
5498
5520
  kind: "mutation",
5499
- description: "Wait on a turn the caller took for an outside condition; the Board stays quiet, then rings the holder when the wait ends.",
5521
+ description: "Wait on a turn the caller took for an outside condition; the Board stays quiet, then rings the holder when the wait ends. The operator can end the active wait early.",
5500
5522
  mcp: {
5501
- whenToUse: "You hold a turn and must re-check an outside condition later, such as a busy test stand: wait for whole minutes with the reason instead of sitting quiet. The Board rings you with the reason when the wait ends; submit, return or a close ends it earlier. Waits per turn are capped by count and total time.",
5502
- whenNotToUse: "Use task_submit to hand in finished work, or task_return to send the task back to Dev."
5523
+ whenToUse: "You hold a turn. Wait only on a condition you cannot change and must re-check: a busy test stand, no free slot, high machine load, a deploy, an outside service. Give whole minutes and the reason; the Board rings you with the reason when the wait ends, and submit, return or a close ends it earlier. Waits per turn are capped by count and total time. As the operator, pass end to end a holder's active wait early; the holder is rung.",
5524
+ whenNotToUse: "Use task_submit to hand in finished work, or task_return to send the task back to Dev. Not on your own work (review fixes, tests, checks, rebasing): work holding the turn, so a stall reaches the operator; a wait hides it."
5503
5525
  },
5504
5526
  input: taskWaitInputSchema,
5505
5527
  output: taskWaitOutputSchema,
5528
+ web: true,
5506
5529
  grants: [
5507
5530
  { grant: "task-worker" },
5508
5531
  { grant: "column-orchestrator" },
@@ -5510,11 +5533,13 @@ const OPERATIONS = [
5510
5533
  ],
5511
5534
  errors: [
5512
5535
  "wrong_id_kind",
5536
+ "not_operator",
5513
5537
  "not_found",
5514
5538
  "task_archived",
5515
5539
  "turn_closed",
5516
5540
  "not_turn_taker",
5517
- "turn_wait_limit"
5541
+ "turn_wait_limit",
5542
+ "no_active_wait"
5518
5543
  ],
5519
5544
  cli: {
5520
5545
  command: "wait",
@@ -5537,6 +5562,16 @@ const OPERATIONS = [
5537
5562
  },
5538
5563
  waits: 1
5539
5564
  }
5565
+ }, {
5566
+ summary: "End a turn's wait early as the operator",
5567
+ input: {
5568
+ turn: "T4",
5569
+ end: true
5570
+ },
5571
+ output: {
5572
+ turn: "T4",
5573
+ waits: 1
5574
+ }
5540
5575
  }]
5541
5576
  }),
5542
5577
  defineOperation({
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { At as requiredSecretKeys, D as sortSkillFiles, Rt as SLACK_BOT_SCOPES, T as skillReloadFileSchema, Tt as configSchema, a as requestHashOf, f as roleCanUseOperation, it as actorIdSchema, jt as resolveWebOrigin, lt as ERRORS, mt as successEnvelopeSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, yt as DEFAULT_STAND_PORT_RANGE } from "./chunk-6hZvXPE0.mjs";
1
+ import { At as requiredSecretKeys, D as sortSkillFiles, Rt as SLACK_BOT_SCOPES, T as skillReloadFileSchema, Tt as configSchema, a as requestHashOf, f as roleCanUseOperation, it as actorIdSchema, jt as resolveWebOrigin, lt as ERRORS, mt as successEnvelopeSchema, p as OPERATIONS, r as remoteDoctorReportSchema, u as SYSTEMD_SERVICE_SETTINGS, yt as DEFAULT_STAND_PORT_RANGE } from "./chunk-H8DV9VuH.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-D8IOOBWp.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-DM0fcX7h.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-DCth-W_y.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-DI6p0nEK.mjs";
5
5
  import { createHash, randomBytes, randomUUID } from "node:crypto";
6
6
  import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
7
7
  import { homedir, hostname, tmpdir, 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-D8IOOBWp.mjs";
1
+ export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-DCth-W_y.mjs";
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as ringMarker, A as eventPayloadSchemas, At as requiredSecretKeys, B as sourceCursorSchema, Bt as TODO_GROUP_COLUMN_IDS, C as messageRefSchema, Ct as columnTurnTimings, D as sortSkillFiles, Dt as externalQuietAfterMs, E as skillReloadFilesSchema, Et as defaultAddressee, F as defaultBranchFactSchema, Ft as COLUMN_IDS, G as SESSION_HEALTH_STATES, H as PR_STATES, Ht as isTodoGroupColumn, I as entityRefSchema, It as DISPATCHER_MODES, J as parseRingMarker, K as SESSION_STATUSES, L as mirrorSourceId, Lt as ITEM_KINDS, M as MIRROR_FAILURES, Mt as BLOCK_TYPES, N as MIRROR_FAILURE_CODES, Nt as COLUMNS, O as EVENT_KINDS, Ot as plainHttpAllowed, P as batchSchema, Pt as COLUMN_GROUPS, Q as prReviewRuleSchema, R as prSourceId, Rt as SLACK_BOT_SCOPES, S as interactionRefSchema, St as boardWideSpurProject, Tt as configSchema, U as REVIEW_DECISIONS, V as trackerSourceId, Vt as VIAS, W as REVIEW_STATES, X as prFactsSchema, Y as prApprovalPairSchema, Z as prRefSchema, a as requestHashOf, at as encodeActorId, b as conversationRefSchema, bt as RESERVED_PROJECT, c as tokenRequestStatusSchema, ct as parseRef$1, d as buildCatalogSnapshot, et as sessionFactsSchema, f as roleCanUseOperation, g as renderHttpProblem, gt as DEFAULT_LINK, h as turnHandedSchema, i as TOKEN_REQUEST_LIMITS, it as actorIdSchema, j as AdapterError, jt as resolveWebOrigin, k as GATE_REASONS, kt as readyMirrorOf, l as BOARD_TICK_MS, lt as ERRORS, m as defaultBranchViewSchema, mt as successEnvelopeSchema, n as doctorReportSchema, nt as JIRA_PROJECT_KEY, o as tokenRequestResultSchema, ot as errorCodeOf, p as OPERATIONS, pt as ok, q as isExternalAuthor, rt as REF_NUMBER, s as tokenRequestSchema, st as parseActorId, t as assertNever, tt as ticketFactsSchema, ut as err, vt as DEFAULT_SLACK_COMMAND, w as userIdSchema, wt as configBindings, x as inboundEventSchema, xt as approvalRuleOf, y as SPACE_IDS, z as sessionTransitionSchema, zt as TASK_HOLDS } from "./chunk-6hZvXPE0.mjs";
1
+ import { $ as ringMarker, A as eventPayloadSchemas, At as requiredSecretKeys, B as sourceCursorSchema, Bt as TODO_GROUP_COLUMN_IDS, C as messageRefSchema, Ct as columnTurnTimings, D as sortSkillFiles, Dt as externalQuietAfterMs, E as skillReloadFilesSchema, Et as defaultAddressee, F as defaultBranchFactSchema, Ft as COLUMN_IDS, G as SESSION_HEALTH_STATES, H as PR_STATES, Ht as isTodoGroupColumn, I as entityRefSchema, It as DISPATCHER_MODES, J as parseRingMarker, K as SESSION_STATUSES, L as mirrorSourceId, Lt as ITEM_KINDS, M as MIRROR_FAILURES, Mt as BLOCK_TYPES, N as MIRROR_FAILURE_CODES, Nt as COLUMNS, O as EVENT_KINDS, Ot as plainHttpAllowed, P as batchSchema, Pt as COLUMN_GROUPS, Q as prReviewRuleSchema, R as prSourceId, Rt as SLACK_BOT_SCOPES, S as interactionRefSchema, St as boardWideSpurProject, Tt as configSchema, U as REVIEW_DECISIONS, V as trackerSourceId, Vt as VIAS, W as REVIEW_STATES, X as prFactsSchema, Y as prApprovalPairSchema, Z as prRefSchema, a as requestHashOf, at as encodeActorId, b as conversationRefSchema, bt as RESERVED_PROJECT, c as tokenRequestStatusSchema, ct as parseRef$1, d as buildCatalogSnapshot, et as sessionFactsSchema, f as roleCanUseOperation, g as renderHttpProblem, gt as DEFAULT_LINK, h as turnHandedSchema, i as TOKEN_REQUEST_LIMITS, it as actorIdSchema, j as AdapterError, jt as resolveWebOrigin, k as GATE_REASONS, kt as readyMirrorOf, l as BOARD_TICK_MS, lt as ERRORS, m as defaultBranchViewSchema, mt as successEnvelopeSchema, n as doctorReportSchema, nt as JIRA_PROJECT_KEY, o as tokenRequestResultSchema, ot as errorCodeOf, p as OPERATIONS, pt as ok, q as isExternalAuthor, rt as REF_NUMBER, s as tokenRequestSchema, st as parseActorId, t as assertNever, tt as ticketFactsSchema, ut as err, vt as DEFAULT_SLACK_COMMAND, w as userIdSchema, wt as configBindings, x as inboundEventSchema, xt as approvalRuleOf, y as SPACE_IDS, z as sessionTransitionSchema, zt as TASK_HOLDS } from "./chunk-H8DV9VuH.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";
@@ -50,6 +50,22 @@ const PERSONA_ROLES = [
50
50
  "worker",
51
51
  "board"
52
52
  ];
53
+ // ../contracts/src/host-usage.ts
54
+ /**
55
+ * Levels of host usage shared by the web meters, the status bar dot and the board's disk item:
56
+ * a reading is at a level when its used fraction is at or above it, as the Meter colours it.
57
+ */
58
+ const HOST_USAGE_LEVELS = {
59
+ warn: .8,
60
+ error: .9
61
+ };
62
+ /** The level of a reading given in percent used, 0-100. */
63
+ function hostUsageLevel(usedPercent) {
64
+ const used = usedPercent / 100;
65
+ if (used >= HOST_USAGE_LEVELS.error) return "error";
66
+ if (used >= HOST_USAGE_LEVELS.warn) return "warn";
67
+ return "ok";
68
+ }
53
69
  // ../core/src/store/copy.ts
54
70
  /**
55
71
  * Opens a database read-write with no PRAGMA, migration or version check: the connection only
@@ -10151,8 +10167,13 @@ const turnReminderKey = (turnId, session, takenAt) => `turn:${String(turnId)}:re
10151
10167
  * `turn_reminder` row too, so it rings once and drops with the turn's other reminders.
10152
10168
  */
10153
10169
  const turnWakeKey = (turnId, session, since) => `turn:${String(turnId)}:wake:${session}:${since}`;
10154
- /** Whether a `turn_reminder` row is the wake ring of a wait. */
10155
- const isTurnWakeKey = (key) => /^turn:\d+:wake:/.test(key);
10170
+ /**
10171
+ * The key of the ring that tells `session` the operator ended its wait on a turn, started at
10172
+ * `since`, early. Like the wake ring, a `turn_reminder` row that rings once.
10173
+ */
10174
+ const turnEndedKey = (turnId, session, since) => `turn:${String(turnId)}:ended:${session}:${since}`;
10175
+ /** Whether a `turn_reminder` row is the wake or end ring of a wait. */
10176
+ const isTurnWakeKey = (key) => /^turn:\d+:(wake|ended):/.test(key);
10156
10177
  const isTurnKind = (kind) => kind === "turn" || kind === "turn_reminder";
10157
10178
  /**
10158
10179
  * Whether a reminder was cancelled before it was ever sent, as a link removal does: it counts as
@@ -10182,7 +10203,7 @@ async function cancelledRingState(trx, n) {
10182
10203
  * its take, so each ownership episode gets its own reminder and no episode gets a second. A
10183
10204
  * reminder of the take cancelled unsent is replaced by a fresh one: its row gets a new id, so the
10184
10205
  * new ring does not reuse the outbox key of a ring the sender already killed. A wait's wake ring
10185
- * passes its own `wakeKey` (`turnWakeKey`).
10206
+ * passes its own `wakeKey` (`turnWakeKey`, or `turnEndedKey` for the operator's early end).
10186
10207
  */
10187
10208
  async function registerTurnReminder(trx, turn, session, at, wakeKey) {
10188
10209
  if (turn.acked_at === null) throw new Error(`turn ${String(turn.id)} is not taken`);
@@ -10581,14 +10602,15 @@ async function noRecipientEnd(trx, n) {
10581
10602
  }
10582
10603
  /**
10583
10604
  * A ring never carries comment or reason text, only where to look; the one exception is a wait's
10584
- * wake ring, which repeats the reason the holder gave itself, on one line.
10605
+ * wake or end ring, which repeats the reason the holder gave itself, on one line.
10585
10606
  */
10586
10607
  async function ringText(trx, n, { key }, ring) {
10587
10608
  const suffix = ringMarker(n.id, ring);
10588
10609
  if (n.kind === "turn") return `${key} turn T${String(n.turn_id)}: check board inbox ${suffix}`;
10589
10610
  if (n.kind === "turn_reminder" && n.turn_id !== null && isTurnWakeKey(n.source_key)) {
10590
10611
  const reason = ((await trx.selectFrom("turn").select("wait_reason").where("id", "=", n.turn_id).executeTakeFirst())?.wait_reason ?? "").replace(/\s+/g, " ").trim();
10591
- return `${key} turn T${String(n.turn_id)} wait ended: ${reason}; check board inbox ${suffix}`;
10612
+ const by = n.source_key.includes(":ended:") ? " by the operator" : "";
10613
+ return `${key} turn T${String(n.turn_id)} wait ended${by}: ${reason}; check board inbox ${suffix}`;
10592
10614
  }
10593
10615
  if (n.kind === "turn_reminder") return `${key} turn T${String(n.turn_id)} is still open: check board inbox ${suffix}`;
10594
10616
  const blockId = noticeBlockId(n);
@@ -12316,6 +12338,26 @@ async function endTaskTurnWaits(trx, input) {
12316
12338
  project: turn.project
12317
12339
  });
12318
12340
  }
12341
+ /**
12342
+ * The operator ends the active wait of `turn` early, as `ended`: its time counts toward the turn's
12343
+ * limits. An agent holder gets one ring saying so, unless it ended the wait itself, its session
12344
+ * ended, or it holds a worker turn whose session link the operator removed.
12345
+ */
12346
+ async function endWaitEarly(trx, input) {
12347
+ const { turn, project, at, actor } = input;
12348
+ await endTurnWait(trx, {
12349
+ turn,
12350
+ project,
12351
+ outcome: "ended",
12352
+ at,
12353
+ actor
12354
+ });
12355
+ const session = holderSession(turn);
12356
+ if (session === null || turn.wait_since === null || actor === turn.acked_by) return;
12357
+ if (await sessionEnded(trx, session)) return;
12358
+ if (workerUnlinked(await unlinkedSessions(trx), turn, session)) return;
12359
+ await registerTurnReminder(trx, turn, session, at, turnEndedKey(turn.id, session, turn.wait_since));
12360
+ }
12319
12361
  /** Whether the turn's waits reached the count or the total time limit. */
12320
12362
  function waitsUsed(config, turn) {
12321
12363
  const { maxWaits, maxTotalMs } = config.health.turnWait;
@@ -12382,9 +12424,9 @@ async function wakeWaitingTurns(trx, config, at) {
12382
12424
  /**
12383
12425
  * The `taskId:sessionId` pairs whose `worker_idle` stays off: the agent holder of an unclosed turn
12384
12426
  * while it waits, and for `health.idleInDevAfterMs` after a wait that ran out (`woken` or
12385
- * `limit`). Only those ends come after the take with the holder still live: a take ends the wait
12386
- * at its own time, and submit or close leave no unclosed turn. A holder whose session ended gets
12387
- * none.
12427
+ * `limit`) or that the operator ended (`ended`). Only those ends come after the take with the
12428
+ * holder still live: a take ends the wait at its own time, and submit or close leave no unclosed
12429
+ * turn. A holder whose session ended gets none.
12388
12430
  */
12389
12431
  async function restingHolders(trx, config, now) {
12390
12432
  const turns = await trx.selectFrom("turn").select([
@@ -15138,6 +15180,79 @@ async function externalQuietItems(trx, config, now, tasks, sourceById) {
15138
15180
  held
15139
15181
  };
15140
15182
  }
15183
+ // ../core/src/app/host-disk.ts
15184
+ const HOST_DISK_KEY = "host-disk:";
15185
+ const META_KEY = "host_disk";
15186
+ const GIB = 2 ** 30;
15187
+ /**
15188
+ * Per mount: the run of samples in a row at the error level, when the open episode began (null
15189
+ * when none is open) and the latest reading.
15190
+ */
15191
+ const stateSchema = z.record(z.string(), z.strictObject({
15192
+ streak: z.number().int().nonnegative(),
15193
+ since: z.iso.datetime().nullable(),
15194
+ usedPercent: z.number(),
15195
+ availableBytes: z.number(),
15196
+ sampledAt: z.iso.datetime()
15197
+ }));
15198
+ /** The stored state; a missing or malformed value reads as empty. */
15199
+ async function readState(trx) {
15200
+ const row = await trx.selectFrom("meta").select("value").where("key", "=", META_KEY).executeTakeFirst();
15201
+ if (row === void 0) return {};
15202
+ try {
15203
+ const parsed = stateSchema.safeParse(JSON.parse(row.value));
15204
+ return parsed.success ? parsed.data : {};
15205
+ } catch {
15206
+ return {};
15207
+ }
15208
+ }
15209
+ /**
15210
+ * Records one host sample's volumes. Two samples in a row at the error level open an episode; a
15211
+ * sample below the warn level ends it. A mount missing from the sample keeps its entry.
15212
+ */
15213
+ async function recordHostDisk(store, sample) {
15214
+ await store.transaction(async (trx) => {
15215
+ const state = await readState(trx);
15216
+ for (const volume of sample.volumes) {
15217
+ const level = hostUsageLevel(volume.usedPercent);
15218
+ const previous = state[volume.mount];
15219
+ const streak = level === "error" ? (previous?.streak ?? 0) + 1 : 0;
15220
+ let since = previous?.since ?? null;
15221
+ if (level === "ok") since = null;
15222
+ else if (streak >= 2 && since === null) since = sample.sampledAt;
15223
+ state[volume.mount] = {
15224
+ streak,
15225
+ since,
15226
+ usedPercent: volume.usedPercent,
15227
+ availableBytes: volume.availableBytes,
15228
+ sampledAt: sample.sampledAt
15229
+ };
15230
+ }
15231
+ const value = JSON.stringify(stateSchema.parse(state));
15232
+ await trx.insertInto("meta").values({
15233
+ key: META_KEY,
15234
+ value
15235
+ }).onConflict((oc) => oc.column("key").doUpdateSet({ value })).execute();
15236
+ });
15237
+ }
15238
+ /**
15239
+ * One item per volume with an open episode. The fingerprint hashes the mount and the episode
15240
+ * start, so the item and its feed line stay while the shown numbers follow the latest sample.
15241
+ */
15242
+ async function hostDiskItems(trx) {
15243
+ const state = await readState(trx);
15244
+ return Object.entries(state).flatMap(([mount, entry]) => entry.since === null ? [] : [{
15245
+ key: `${HOST_DISK_KEY}${mount}`,
15246
+ kind: "board_observation",
15247
+ taskId: null,
15248
+ summary: `host disk ${mount}: ${String(Math.floor(entry.usedPercent))}% used, ${(entry.availableBytes / GIB).toFixed(1)} GiB free`,
15249
+ hashedSummary: `host disk ${mount}`,
15250
+ factAt: entry.sampledAt,
15251
+ source: null,
15252
+ priority: 4,
15253
+ revision: entry.since
15254
+ }]);
15255
+ }
15141
15256
  // ../core/src/app/quiet-turns.ts
15142
15257
  /**
15143
15258
  * How long the holder of a taken turn may sit quiet before it is reminded, then flagged: the column
@@ -15236,7 +15351,7 @@ async function remindStuckTurns(trx, config, at) {
15236
15351
  * `remindStuckTurns` registers it by: its holder's current take is quiet for `stuckTurnAfterMs`.
15237
15352
  * Otherwise the sender defers it, so a question opened after it was queued holds it until the
15238
15353
  * question closes and a fresh quiet period passes, and blind Spur holds it until Spur reports again.
15239
- * A wait's wake ring is due unless Spur is blind. Every other ring is due.
15354
+ * A wait's wake or end ring is due unless Spur is blind. Every other ring is due.
15240
15355
  */
15241
15356
  async function ringDue(trx, notificationId, config, at) {
15242
15357
  const n = await trx.selectFrom("notification").select(["kind", "source_key"]).where("id", "=", notificationId).executeTakeFirst();
@@ -15905,6 +16020,7 @@ async function reconcileItems(trx, config, now, spurComplete, warnSkipped, spurC
15905
16020
  candidates.push(...quiet.candidates);
15906
16021
  heldKeys.push(...quiet.held);
15907
16022
  candidates.push(...await turnWaitItems(trx, config, taskById));
16023
+ candidates.push(...await hostDiskItems(trx));
15908
16024
  const ordered = orderItems(candidates);
15909
16025
  const seen = /* @__PURE__ */ new Set([...ordered.map((item) => item.key), ...heldKeys]);
15910
16026
  for (const flag of health.held) {
@@ -20337,13 +20453,21 @@ async function executesShadowColumn(db, task, actor, config) {
20337
20453
  function current(turn, task) {
20338
20454
  return turn.closed_at === null && turn.column === task.column && turn.epoch === task.column_epoch;
20339
20455
  }
20340
- /** The refusals both operations share, in order: archived, closed, not the taker. */
20341
- async function takenTurn(trx, id, ctx) {
20456
+ /** The refusals every turn write shares, in order: not found, archived, closed. */
20457
+ async function unclosedTurn(trx, id) {
20342
20458
  const turn = await turnById(trx, id);
20343
20459
  if (turn === void 0) throw new CommandError("not_found", "Check the turn ID.");
20344
20460
  const task = await taskById(trx, turn.task_id);
20345
20461
  if (task.membership === "archived") throw new CommandError("task_archived", "Add the task again before changing it.");
20346
20462
  if (!current(turn, task)) throw new CommandError("turn_closed", `Turn ${id} is closed; read your open turns with \`board inbox\`.`);
20463
+ return {
20464
+ turn,
20465
+ task
20466
+ };
20467
+ }
20468
+ /** The refusals the holder's writes share, in order: those of `unclosedTurn`, not the taker. */
20469
+ async function takenTurn(trx, id, ctx) {
20470
+ const { turn, task } = await unclosedTurn(trx, id);
20347
20471
  if (turn.acked_by === null || turn.acked_by !== ctx.actor) throw new CommandError("not_turn_taker", turn.acked_by === null ? `Take turn ${id} with \`board inbox ack ${id}\` first.` : `Turn ${id} was taken by another session; only that session can submit or return it.`);
20348
20472
  return {
20349
20473
  turn,
@@ -20622,14 +20746,32 @@ function createTurnMutations(deps) {
20622
20746
  * replaced: it ends `closed` and its time counts. Past the turn's count or total time limit the
20623
20747
  * call is refused; otherwise the wait lasts `for` minutes, cut to the time left of the total, and
20624
20748
  * the turn's unsent reminders are dropped, so the board stays quiet until the tick wakes it.
20749
+ * With `end`, the operator ends the turn's active wait instead (`endWaitEarly`).
20625
20750
  */
20626
20751
  function createTurnWaitMutation({ config }) {
20627
20752
  return {
20628
20753
  id: "task.wait",
20629
20754
  resolveTargets: (trx, input) => turnVisitTarget(trx, input.turn),
20630
20755
  async run(trx, input, ctx) {
20631
- const { turn, task } = await takenTurn(trx, input.turn, ctx);
20632
20756
  const at = new Date(ctx.at);
20757
+ if (input.end === true) {
20758
+ if (input.for !== void 0 || input.reason !== void 0) throw new CommandError("usage", "Pass end alone, without for or reason.");
20759
+ const { turn, task } = await unclosedTurn(trx, input.turn);
20760
+ if (!isOperator(ctx.actor, config, task.project)) throw new CommandError("not_operator", `Ask the operator to end the wait on ${input.turn}.`);
20761
+ if (turn.wait_until === null) throw new CommandError("no_active_wait", `Turn ${input.turn} is not waiting.`);
20762
+ await endWaitEarly(trx, {
20763
+ turn,
20764
+ project: task.project,
20765
+ at,
20766
+ actor: ctx.actor
20767
+ });
20768
+ return {
20769
+ turn: input.turn,
20770
+ waits: turn.wait_count
20771
+ };
20772
+ }
20773
+ if (input.for === void 0 || input.reason === void 0) throw new CommandError("usage", "Pass for and reason to wait, or end to end the wait.");
20774
+ const { turn, task } = await takenTurn(trx, input.turn, ctx);
20633
20775
  const waitedMs = await endTurnWait(trx, {
20634
20776
  turn,
20635
20777
  project: task.project,
@@ -23271,13 +23413,15 @@ function installEventStream(app, options) {
23271
23413
  }
23272
23414
  // ../core/src/api/web-server.ts
23273
23415
  /**
23274
- * The Turn section's writes take and close a turn; the operator caller would otherwise get a
23275
- * fresh key per request, so a keyless retry could take or close a turn again.
23416
+ * The task panel's turn writes take and close a turn or end its wait; the operator caller would
23417
+ * otherwise get a fresh key per request, so a keyless retry could take or close a turn again or
23418
+ * end a later wait.
23276
23419
  */
23277
23420
  const KEYED_WEB_WRITES = /* @__PURE__ */ new Set([
23278
23421
  "inbox.ack",
23279
23422
  "task.submit",
23280
- "task.return"
23423
+ "task.return",
23424
+ "task.wait"
23281
23425
  ]);
23282
23426
  const mime = {
23283
23427
  ".html": "text/html; charset=utf-8",
@@ -29108,10 +29252,12 @@ function untilAborted(promise, signal) {
29108
29252
  * `read` never samples. A metric whose read fails is null, with one warning per metric; a disk
29109
29253
  * path whose read fails is left out of `volumes`, with one warning per path. Volumes are deduped
29110
29254
  * by device and listed least free bytes first; `disk` is the first. Stop aborts pending disk
29111
- * reads instead of waiting for them, and that run writes nothing.
29255
+ * reads instead of waiting for them, and that run writes nothing. `onSample` gets each sample
29256
+ * once it is stored, so `read` already returns it; its failure is the run's error and leaves the
29257
+ * sample readable.
29112
29258
  */
29113
29259
  function createHostSampler(options) {
29114
- const { probe, clock, log, intervalMs = HOST_SAMPLE_MS } = options;
29260
+ const { probe, clock, log, intervalMs = HOST_SAMPLE_MS, onSample } = options;
29115
29261
  let last = null;
29116
29262
  let previousCpu;
29117
29263
  const warned = /* @__PURE__ */ new Set();
@@ -29164,7 +29310,7 @@ function createHostSampler(options) {
29164
29310
  });
29165
29311
  });
29166
29312
  volumes.sort((a, b) => a.availableBytes - b.availableBytes);
29167
- last = {
29313
+ const taken = {
29168
29314
  sampledAt,
29169
29315
  cpuPercent,
29170
29316
  memory: mem === null ? null : {
@@ -29175,6 +29321,8 @@ function createHostSampler(options) {
29175
29321
  disk: volumes[0] ?? null,
29176
29322
  volumes
29177
29323
  };
29324
+ last = taken;
29325
+ await onSample?.(taken);
29178
29326
  };
29179
29327
  const own = new AbortController();
29180
29328
  const job = createJob({
@@ -30339,7 +30487,8 @@ function createDaemonModules(ctxFor, ports = {}) {
30339
30487
  const host = createHostSampler({
30340
30488
  probe: ports.hostProbe ?? createHostProbe(ports.dataDir),
30341
30489
  clock: hostCtx.clock,
30342
- log: hostCtx.log
30490
+ log: hostCtx.log,
30491
+ onSample: (sample) => recordHostDisk(hostCtx.store, sample)
30343
30492
  });
30344
30493
  let webPort;
30345
30494
  let lastDispatchAt = null;
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { lt as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-6hZvXPE0.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-D8IOOBWp.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-DM0fcX7h.mjs";
1
+ import { lt as ERRORS, p as OPERATIONS, v as renderMcpError } from "./chunk-H8DV9VuH.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-DCth-W_y.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-DI6p0nEK.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";