loopctl-mcp-server 3.49.0 → 3.50.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/README.md +1 -0
- package/index.js +41 -1
- package/lib/checkpoints.js +27 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -661,6 +661,7 @@ Key distribution for the dispatch pattern (Epic 26): per-dispatch ephemeral keys
|
|
|
661
661
|
| `work_item_note` | **Write a note on a work item** (`POST /api/v1/stories/:id/notes`, US-52.17): `section` (plan, progress, decision, question) and `body`, appended and never edited, plus a `note_written` event on the story log in the same transaction. Sends this session's own key (its holder credential). Only the story's current holder writes one: `409 held_by_other_holder` when another session holds it, `409 not_holder` when nobody does, `404` for another tenant's story, `422` for an unknown section, an empty body, a body over 16384 bytes or a credential-shaped body. A writer repeating its own `idempotency_key` gets its first note back; a key another writer's note already carries is `409 idempotency_key_reused`. Every note carries a client UUIDv7 `event_id` (US-52.62); when loopctl does not answer (network error, timeout, 502/503/504) the note is journaled (`LOOPCTL_JOURNAL_DIR`) and answered `{queued: true, event_id}`, then replayed in order through `holder_replay`; while the journal holds entries a new note queues behind them. The journal entry needs the `claim_epoch` (optional argument; else the one the session last saw, else read from the story once). |
|
|
662
662
|
| `work_item_notes` | **Read a work item's notes** (`GET /api/v1/stories/:id/notes`), oldest first; the first page carries `current`, the newest note of each section. Optional `section`, `limit` (default 50, max 200) and `after` (a page's `next_cursor`). `404` for another tenant's story, `422` for an unknown section or a cursor it did not return. |
|
|
663
663
|
| `work_item_checkpoint` | **Checkpoint a work item** (`POST /api/v1/stories/:id/checkpoints`, US-52.41): computes from `worktree` the branch, the commit its work applies to (the pushed head, else the merge-base with origin's default branch) and `git diff --binary` on top of it with untracked files, without writing to the worktree, and records them with one progress note from `done` and `next` and a `checkpointed` event. Sends this session's own key (its holder credential): only the current holder at the story's `claim_epoch` (read from the story when omitted) with a live lease. `409 not_holder` (names the holder), `409 stale_claim_epoch`, `409 claim_lease_expired`, `409 checkpoint_id_conflict`, `403 holder_credential_required`, `404` for another tenant's story; `413 diff_over_bound` over 4 MiB (push a `wip/...` branch and pass `wip_branch` instead); `422 secret_in_diff` (names the files), `422 diff_and_wip_branch`, `422 invalid_wip_branch`. A repeated `checkpoint_id` with the same content returns the stored checkpoint (`replayed: true`). A checkpoint from a claim that has ended (the epoch you held, after the item moved on) is stored fenced and answered `202` (`fenced: true`, `current_holder_id`), with no note and no change to the item, for the current holder to resolve (US-52.42). Past 5 unresolved fenced checkpoints from you on one item, or 10 on the item from all late holders, a late checkpoint is `409 fenced_checkpoint_limit` (`limit_scope`, `max_unresolved_fenced`) and nothing is stored: push a `wip/...` branch instead. The checkpoint id is a client UUIDv7 unless given (US-52.62); one that gets no answer from loopctl is journaled under the epoch the session last saw and answered `{queued: true, event_id}`, unless it is too large for one replay body (about 1.5 MB encoded): then push a `wip/...` branch. |
|
|
664
|
+
| `work_item_checkpoints_fenced` | **List the tenant's unresolved fenced checkpoints** (`GET /api/v1/checkpoints?fenced=unresolved`, #1298): every fenced checkpoint a late holder left on any work item that nobody has applied or ignored yet, oldest first, each with `checkpoint_id`, `story_id`, `project_id`, `title`, `holder_id` and `host` of the late holder, `head_sha`, `wip_branch`, `diff_bytes`, `summary` (`summary_untrusted: true`) and `inserted_at`. Never the diff; `work_item_checkpoints` with a `checkpoint_id` reads it. Paged: pass `next_cursor` back as `cursor`; `limit` 1..200, default 50. Read-only on any key of the tenant. `400` for a bad `limit` or a cursor not issued to this tenant. |
|
|
664
665
|
| `work_item_checkpoints` | **Read a work item's checkpoints**: the newest 20, newest first, without diffs (`GET /api/v1/stories/:id/checkpoints`), with `fenced: "unresolved"` the fenced ones nobody resolved yet, oldest first, or with `checkpoint_id` one checkpoint with its diff base64 (`GET .../checkpoints/:checkpoint_id`), which `git apply` takes on a checkout of its `head_sha`. Any key of the tenant. `404` for another tenant's story or checkpoint. |
|
|
665
666
|
| `work_item_checkpoint_resolve` | **Apply or ignore a fenced checkpoint** (`POST /api/v1/stories/:id/checkpoints/:checkpoint_id/resolve`, US-52.42): `resolution` (`applied` or `ignored`) and a `reason`, on this session's own key; only the story's current holder with a live lease. The same resolution again is `200` and writes nothing. `409 not_holder` (names `holder_id`), `409 already_resolved`, `422 not_fenced`, `403 holder_credential_required`, `404` for a checkpoint not on this tenant's story. |
|
|
666
667
|
| `work_item_move` | **Move a work item** to a host, a holder, the cloud or the loop (`POST /api/v1/stories/:id/move`, US-52.43), on this session's own key; the server picks the path from who calls. The holder (live lease) names its own `checkpoint_id` at the current epoch and the claim is released at once over the uncounted `:moved` edge: `200 released`. Anyone else REQUESTS it: the holder is told on the item's thread and has `MOVE_RELEASE_SECONDS` to answer with the same `move_id`, after which the deadline worker releases it: `202 requested`. An unheld item is released at once: `200`. While reserved only the target claims it (`409 reserved_for_move`); a move to a host, holder or the cloud unpulled after `MOVE_PULL_SECONDS` expires to the loop, and a move to the loop never expires: implement@1 places it with the move's checkpoint as `resume`, on a runner of contract 1.40.0 or later (US-52.46). An item an interactive session released is reserved for any interactive session until someone moves it on. A move to a host whose runner joined on contract 1.40.0 or later is placed there and resumes from the move's checkpoint (US-52.44); a runner session holding the item is asked over its runner's socket. The same `move_id` and target answers the first result. `400 move_id_required`/`reason_required`/`invalid_reason`, `404` (incl. `unknown_story_stage`), `409 holder_ended`/`item_closed`/`item_escalated`/`move_pending`/`item_changed`, `422 invalid_target`/`unknown_host`/`unknown_holder`/`holder_cannot_pull` (a runner_session holder claims nothing after its own placement: move to its host)/`target_unavailable`/`already_held_by_target`/`checkpoint_not_current`, `403 boundary_move_needs_mark` only when ANOTHER session holds the item on a live lease, the move crosses the interactive boundary (that holder or the target holder is an interactive session), and the caller is not Mark's own user key (fleet_dash; US-52.45): a holder moves its own item anywhere, the loop included, and an item nobody is working is anyone's to move on; a key with no holder omits `checkpoint_id`; and `403` without the human anchor. |
|
package/index.js
CHANGED
|
@@ -63,7 +63,12 @@ import {
|
|
|
63
63
|
renameAuthenticator,
|
|
64
64
|
updateTenant,
|
|
65
65
|
} from "./lib/tenant-admin.js";
|
|
66
|
-
import {
|
|
66
|
+
import {
|
|
67
|
+
readCheckpoints,
|
|
68
|
+
readFencedCheckpoints,
|
|
69
|
+
recordCheckpoint,
|
|
70
|
+
resolveCheckpoint,
|
|
71
|
+
} from "./lib/checkpoints.js";
|
|
67
72
|
import { moveWorkItem } from "./lib/work-item-move.js";
|
|
68
73
|
import { pullWorkItem } from "./lib/work-item-pull.js";
|
|
69
74
|
import {
|
|
@@ -3714,6 +3719,15 @@ async function workItemCheckpointsTool(args) {
|
|
|
3714
3719
|
);
|
|
3715
3720
|
}
|
|
3716
3721
|
|
|
3722
|
+
// #1298: the tenant's unresolved fenced checkpoints, read on the session's own key.
|
|
3723
|
+
async function workItemCheckpointsFencedTool(args) {
|
|
3724
|
+
return toContent(
|
|
3725
|
+
await readFencedCheckpoints(args, {
|
|
3726
|
+
apiCall: (method, path, body) => apiCall(method, path, body, agentKey()),
|
|
3727
|
+
}),
|
|
3728
|
+
);
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3717
3731
|
// US-52.42: resolving a fenced checkpoint is the current holder's act, on its own key.
|
|
3718
3732
|
async function workItemCheckpointResolveTool(args) {
|
|
3719
3733
|
return toContent(
|
|
@@ -9989,6 +10003,30 @@ const TOOLS = [
|
|
|
9989
10003
|
},
|
|
9990
10004
|
},
|
|
9991
10005
|
|
|
10006
|
+
{
|
|
10007
|
+
name: "work_item_checkpoints_fenced",
|
|
10008
|
+
description:
|
|
10009
|
+
"LIST THE TENANT'S UNRESOLVED FENCED CHECKPOINTS (GET /api/v1/checkpoints?fenced=" +
|
|
10010
|
+
"unresolved): every fenced checkpoint a late holder left on any work item that nobody " +
|
|
10011
|
+
"has applied or ignored yet, oldest first, each with checkpoint_id, story_id, " +
|
|
10012
|
+
"project_id, title, holder_id and host of the late holder, head_sha, wip_branch, " +
|
|
10013
|
+
"diff_bytes, summary (summary_untrusted: true, the late holder's own text) and " +
|
|
10014
|
+
"inserted_at. Never the diff: read one with work_item_checkpoints {story_id, " +
|
|
10015
|
+
"checkpoint_id}. Paged: pass next_cursor back as cursor; limit 1..200, default 50. " +
|
|
10016
|
+
"READ-ONLY on any key of the tenant. 400 for a bad limit or a cursor this endpoint did " +
|
|
10017
|
+
"not issue to this tenant.",
|
|
10018
|
+
inputSchema: {
|
|
10019
|
+
type: "object",
|
|
10020
|
+
properties: {
|
|
10021
|
+
cursor: {
|
|
10022
|
+
type: "string",
|
|
10023
|
+
description: "Optional: a previous page's next_cursor, verbatim.",
|
|
10024
|
+
},
|
|
10025
|
+
limit: { type: "integer", description: "Optional: rows, 1..200 (default 50)." },
|
|
10026
|
+
},
|
|
10027
|
+
},
|
|
10028
|
+
},
|
|
10029
|
+
|
|
9992
10030
|
{
|
|
9993
10031
|
name: "work_item_checkpoint_resolve",
|
|
9994
10032
|
description:
|
|
@@ -14954,6 +14992,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
14954
14992
|
|
|
14955
14993
|
case "work_item_checkpoints":
|
|
14956
14994
|
return await workItemCheckpointsTool(args);
|
|
14995
|
+
case "work_item_checkpoints_fenced":
|
|
14996
|
+
return await workItemCheckpointsFencedTool(args);
|
|
14957
14997
|
|
|
14958
14998
|
case "work_item_checkpoint_resolve":
|
|
14959
14999
|
return await workItemCheckpointResolveTool(args);
|
package/lib/checkpoints.js
CHANGED
|
@@ -138,6 +138,33 @@ export async function readCheckpoints({ story_id, checkpoint_id, fenced } = {},
|
|
|
138
138
|
return apiCall("GET", `${checkpointsPath(story_id)}/${encodeURIComponent(checkpoint_id)}`, null);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* `work_item_checkpoints_fenced` (loopctl #1298): `GET /api/v1/checkpoints?fenced=unresolved`,
|
|
143
|
+
* the tenant's unresolved fenced checkpoints across every work item, oldest first, without
|
|
144
|
+
* diffs. `cursor` is a previous page's `next_cursor`, verbatim; `limit` is 1..200.
|
|
145
|
+
*/
|
|
146
|
+
export const FENCED_LIMIT_MAX = 200;
|
|
147
|
+
|
|
148
|
+
export async function readFencedCheckpoints({ cursor, limit } = {}, { apiCall } = {}) {
|
|
149
|
+
if (cursor !== undefined && cursor !== null && typeof cursor !== "string") {
|
|
150
|
+
return refuse("`cursor` must be the string a previous page returned as next_cursor.");
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (
|
|
154
|
+
limit !== undefined &&
|
|
155
|
+
limit !== null &&
|
|
156
|
+
!(Number.isInteger(limit) && limit >= 1 && limit <= FENCED_LIMIT_MAX)
|
|
157
|
+
) {
|
|
158
|
+
return refuse(`\`limit\` must be an integer from 1 to ${FENCED_LIMIT_MAX}.`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const params = new URLSearchParams({ fenced: "unresolved" });
|
|
162
|
+
if (cursor) params.set("cursor", cursor);
|
|
163
|
+
if (Number.isInteger(limit)) params.set("limit", String(limit));
|
|
164
|
+
|
|
165
|
+
return apiCall("GET", `/api/v1/checkpoints?${params.toString()}`, null);
|
|
166
|
+
}
|
|
167
|
+
|
|
141
168
|
const RESOLUTIONS = ["applied", "ignored"];
|
|
142
169
|
|
|
143
170
|
/** `POST .../checkpoints/:checkpoint_id/resolve`: the current holder applies or ignores one. */
|