loopctl-mcp-server 3.44.0 → 3.45.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/index.js CHANGED
@@ -52,6 +52,17 @@ import {
52
52
  removeEpicDependency,
53
53
  removeStoryDependency,
54
54
  } from "./lib/dependencies.js";
55
+ import { bulkClaimStories, unclaimStory } from "./lib/story-claims.js";
56
+ import { bulkRejectStories, bulkVerifyStories } from "./lib/bulk-verdicts.js";
57
+ import { getAgent, listAgents, registerAgent } from "./lib/agents.js";
58
+ import { listQuarantinedPosts, releaseQuarantinedPost } from "./lib/channel-quarantine.js";
59
+ import { auditInclusionProof } from "./lib/audit-inclusion.js";
60
+ import {
61
+ listAuthenticators,
62
+ listTrustedEndpoints,
63
+ renameAuthenticator,
64
+ updateTenant,
65
+ } from "./lib/tenant-admin.js";
55
66
  import { readCheckpoints, recordCheckpoint, resolveCheckpoint } from "./lib/checkpoints.js";
56
67
  import { moveWorkItem } from "./lib/work-item-move.js";
57
68
  import { pullWorkItem } from "./lib/work-item-pull.js";
@@ -63,7 +74,7 @@ import {
63
74
  } from "./lib/factory.js";
64
75
  import { readFactoryPolicy } from "./lib/factory-policy.js";
65
76
  import { snapshotUrls } from "./lib/snapshots.js";
66
- import { apiKeyCreate } from "./lib/api-keys.js";
77
+ import { apiKeyCreate, apiKeyList, apiKeyRotate } from "./lib/api-keys.js";
67
78
  import {
68
79
  openReviewRound,
69
80
  readReviewRoundStatus,
@@ -1284,6 +1295,91 @@ async function storyDependencyListTool(args) {
1284
1295
  return toContent(await listStoryDependencies(args, { apiCall: ownKeyApiCall }));
1285
1296
  }
1286
1297
 
1298
+ // loopctl #872, batch 2. bulk_claim, unclaim_story and register_agent are `exact_role: :agent`:
1299
+ // the session's own key, never the orchestrator or user key, which those gates refuse.
1300
+ // bulk_verify and bulk_reject are `exact_role: :orchestrator` custody verdicts, so they select
1301
+ // their key through `orchestratorKeyArgs` exactly as verify_story and bulk_mark_complete do.
1302
+ // list_agents and get_agent are `role: :orchestrator` reads (`orchestratorPinnedApiCall`).
1303
+ // The api-key, quarantine, authenticator and tenant-update routes are `role: :user`
1304
+ // (`userKeyApiCall`). The trusted-endpoint list has no role plug (the session's own key), and the
1305
+ // inclusion proof is a public route (`publicApiCall`, no key at all).
1306
+
1307
+ async function bulkClaimTool(args) {
1308
+ return toContent(await bulkClaimStories(args, { apiCall: ownKeyApiCall }));
1309
+ }
1310
+
1311
+ async function unclaimStoryTool(args) {
1312
+ return toContent(withUnreachableNotice(await unclaimStory(args, { apiCall: ownKeyApiCall })));
1313
+ }
1314
+
1315
+ async function bulkVerifyTool(args) {
1316
+ const orch = orchestratorKeyArgs();
1317
+
1318
+ return toContent(
1319
+ await bulkVerifyStories(args, {
1320
+ apiCall: (method, path, body) => apiCall(method, path, body, orch.override, orch.options),
1321
+ }),
1322
+ );
1323
+ }
1324
+
1325
+ async function bulkRejectTool(args) {
1326
+ const orch = orchestratorKeyArgs();
1327
+
1328
+ return toContent(
1329
+ await bulkRejectStories(args, {
1330
+ apiCall: (method, path, body) => apiCall(method, path, body, orch.override, orch.options),
1331
+ }),
1332
+ );
1333
+ }
1334
+
1335
+ async function registerAgentTool(args) {
1336
+ return toContent(await registerAgent(args, { apiCall: ownKeyApiCall }));
1337
+ }
1338
+
1339
+ async function listAgentsTool(args) {
1340
+ return toContent(await listAgents(args, { apiCall: orchestratorPinnedApiCall }));
1341
+ }
1342
+
1343
+ async function getAgentTool(args) {
1344
+ return toContent(await getAgent(args, { apiCall: orchestratorPinnedApiCall }));
1345
+ }
1346
+
1347
+ async function apiKeyListTool(args) {
1348
+ return toContent(await apiKeyList(args, { apiCall: userKeyApiCall }));
1349
+ }
1350
+
1351
+ async function apiKeyRotateTool(args) {
1352
+ return toContent(await apiKeyRotate(args, { apiCall: userKeyApiCall }));
1353
+ }
1354
+
1355
+ async function channelQuarantinedTool(args) {
1356
+ return toContent(await listQuarantinedPosts(args, { apiCall: userKeyApiCall }));
1357
+ }
1358
+
1359
+ async function channelReleaseTool(args) {
1360
+ return toContent(await releaseQuarantinedPost(args, { apiCall: userKeyApiCall }));
1361
+ }
1362
+
1363
+ async function auditInclusionProofTool(args) {
1364
+ return toContent(await auditInclusionProof(args, { apiCall: publicApiCall }));
1365
+ }
1366
+
1367
+ async function listTrustedEndpointsTool(args) {
1368
+ return toContent(await listTrustedEndpoints(args, { apiCall: ownKeyApiCall }));
1369
+ }
1370
+
1371
+ async function listAuthenticatorsTool(args) {
1372
+ return toContent(await listAuthenticators(args, { apiCall: userKeyApiCall }));
1373
+ }
1374
+
1375
+ async function renameAuthenticatorTool(args) {
1376
+ return toContent(await renameAuthenticator(args, { apiCall: userKeyApiCall }));
1377
+ }
1378
+
1379
+ async function updateTenantTool(args) {
1380
+ return toContent(await updateTenant(args, { apiCall: userKeyApiCall }));
1381
+ }
1382
+
1287
1383
  // --- Workflow Tools (agent key) ---
1288
1384
 
1289
1385
  async function contractStory({ story_id, story_title, ac_count }) {
@@ -3942,7 +4038,7 @@ async function escalationPlaybook(args) {
3942
4038
 
3943
4039
  // #846: force-unclaim is `exact_role: :orchestrator`
3944
4040
  // (`story_verification_controller.ex:30-31`), so this is the one delivery-loop verb that wants
3945
- // the ORCH key. Same selection as the other four custody verbs: when LOOPCTL_ORCH_KEY is set it
4041
+ // the ORCH key. Same selection as the other custody verbs: when LOOPCTL_ORCH_KEY is set it
3946
4042
  // is sent EXACTLY, because `resolveKey` (`index.js:132-138`) would otherwise discard it for a
3947
4043
  // global LOOPCTL_API_KEY on the one call it was set for; when it is not set, a global key still
3948
4044
  // goes, because an orchestrator-role LOOPCTL_API_KEY was a documented, working configuration
@@ -9771,6 +9867,455 @@ const TOOLS = [
9771
9867
  },
9772
9868
  },
9773
9869
 
9870
+ // loopctl #872, batch 2.
9871
+ {
9872
+ name: "bulk_claim",
9873
+ description:
9874
+ "CLAIM SEVERAL STORIES AT ONCE (POST /api/v1/stories/bulk/claim): each `contracted` " +
9875
+ "story in `story_ids` (1..50) is claimed for this session's agent and holder in one " +
9876
+ "transaction, with partial success: 200 with `results` when any story was claimed, 422 " +
9877
+ "with `results` when none was. Each result is `{story_id, status, reason}`; a story's " +
9878
+ "refusal (not in contracted, `story_held`, `dependencies_not_met`, `Story not found`) is " +
9879
+ "its `reason`. Unlike `claim_story` it mints NO start capability and returns no claim " +
9880
+ "epoch: `start_story` recovers the capability through recover-cap. Sent on this " +
9881
+ "session's own key. The gate is `exact_role: :agent` with NO hierarchy: an orchestrator, " +
9882
+ "user or superadmin key is 403 insufficient_role. Whole-batch refusals: 403 " +
9883
+ "custody_tier_required on an agent-rooted tenant, 409 chg_root_review_only for a key " +
9884
+ "descending from an intake source's chg root, 422 for an empty or oversized batch, 503 " +
9885
+ "tenant_halted under a custody halt. Refused by the tool, sending nothing: an empty or " +
9886
+ "oversized batch, an id that is not a UUID, and an id named twice.",
9887
+ inputSchema: {
9888
+ type: "object",
9889
+ properties: {
9890
+ story_ids: {
9891
+ type: "array",
9892
+ items: { type: "string" },
9893
+ description: "The UUIDs of the stories to claim, 1 to 50, each once.",
9894
+ },
9895
+ },
9896
+ required: ["story_ids"],
9897
+ },
9898
+ },
9899
+ {
9900
+ name: "unclaim_story",
9901
+ description:
9902
+ "GIVE BACK A STORY THIS SESSION CLAIMED (POST /api/v1/stories/:id/unclaim): the claim " +
9903
+ "is released and the story returns to pending. A DELIVERY story does not stay pending: " +
9904
+ "giving it back spent an attempt, so it is re-contracted below the retry ceiling and its " +
9905
+ "stage row escalated over `attempts_exhausted` at it; the answer is the story as the " +
9906
+ "release left it, with `next_actions`. Sent on this session's own key. The gate is " +
9907
+ "`exact_role: :agent` with NO hierarchy: an orchestrator, user or superadmin key is 403 " +
9908
+ "insufficient_role; to take back a story another agent holds, use `force_unclaim_story`. " +
9909
+ "403 when this key's agent is not the story's assignee, 403 custody_tier_required on an " +
9910
+ "agent-rooted tenant, 404 for a story that is not this tenant's, 409 for a story in no " +
9911
+ "state a claim can leave, 409 held_by_other_holder when another session holds it (even " +
9912
+ "one with this agent key), 422 when the release's write or audit entry was rejected, 500 " +
9913
+ "audit_chain_append_failed when the escalation's chain entry was refused (the whole " +
9914
+ "release rolled back, the story is unchanged), 503 tenant_halted under a custody halt. A " +
9915
+ "`story_id` that is not a UUID is refused by the tool, sending nothing.",
9916
+ inputSchema: {
9917
+ type: "object",
9918
+ properties: {
9919
+ story_id: { type: "string", description: "The UUID of the story to give back." },
9920
+ },
9921
+ required: ["story_id"],
9922
+ },
9923
+ },
9924
+ {
9925
+ name: "bulk_verify",
9926
+ description:
9927
+ "VERIFY SEVERAL REPORTED STORIES AT ONCE (POST /api/v1/stories/bulk/verify): each entry " +
9928
+ "of `stories` (1..50) is `{story_id, summary, review_type, findings}`, the last three " +
9929
+ "optional (defaults: `Verified via bulk operation`, `bulk_verify`, {}). Every story runs " +
9930
+ "the same gates `verify_story` runs, its custody lineage comparison included, in one " +
9931
+ "transaction with partial success: 200 with `results` when any story was verified, 422 " +
9932
+ "with `results` when none was; a story's refusal (`self_verify_blocked`, " +
9933
+ "`caller_lineage_required`, not reported_done, a missing review, a chg landed-review or " +
9934
+ "trunk-evidence refusal, ...) is its `reason`. Needs an ORCHESTRATOR-role key, chosen as " +
9935
+ "`verify_story` chooses it: LOOPCTL_ORCH_KEY sent exactly when set, else LOOPCTL_API_KEY. " +
9936
+ "The gate is `exact_role: :orchestrator` with NO hierarchy, so a user or superadmin key " +
9937
+ "is 403 insufficient_role like an agent key. Whole-batch refusals: 400 when the " +
9938
+ "orchestrator key is linked to no agent, 401 bulk_signature_unsupported (or 403 " +
9939
+ "agent_enrollment_required) for an enrolled caller under the LCP-1 signed profile, which " +
9940
+ "a set cannot satisfy, 403 custody_tier_required on an agent-rooted tenant, 409 " +
9941
+ "chg_root_cannot_verify for a chg-rooted key, 422 for an empty or oversized batch, 503 " +
9942
+ "tenant_halted under a custody halt. Refused by the tool, sending nothing: a bad batch, " +
9943
+ "a story_id that is not a UUID or is named twice (loopctl would keep only the last " +
9944
+ "entry's fields), and a non-string `summary`/`review_type` or non-object `findings` " +
9945
+ "(loopctl would verify the story and silently record no verification result).",
9946
+ inputSchema: {
9947
+ type: "object",
9948
+ properties: {
9949
+ stories: {
9950
+ type: "array",
9951
+ description: "The stories to verify, 1 to 50, each once.",
9952
+ items: {
9953
+ type: "object",
9954
+ properties: {
9955
+ story_id: { type: "string", description: "The UUID of the story." },
9956
+ summary: { type: "string", description: "Optional verification summary." },
9957
+ review_type: { type: "string", description: "Optional review type label." },
9958
+ findings: { type: "object", description: "Optional structured findings." },
9959
+ },
9960
+ required: ["story_id"],
9961
+ },
9962
+ },
9963
+ },
9964
+ required: ["stories"],
9965
+ },
9966
+ },
9967
+ {
9968
+ name: "bulk_reject",
9969
+ description:
9970
+ "REJECT SEVERAL REPORTED STORIES AT ONCE (POST /api/v1/stories/bulk/reject): each entry " +
9971
+ "of `stories` (1..50) is `{story_id, reason, review_type, findings}`, `reason` " +
9972
+ "required. Each story runs the same gates `reject_story` runs, in one transaction with " +
9973
+ "partial success: 200 with `results` when any story was rejected, 422 with `results` " +
9974
+ "when none was; a story's refusal (not reported_done, `self_verify_blocked`, " +
9975
+ "`caller_lineage_required` on a pull-request-route story for a key no dispatch minted, " +
9976
+ "...) is its `reason`. A rejected story's claim is released, and a delivery story is " +
9977
+ "re-contracted or escalated in the same transaction. Needs an ORCHESTRATOR-role key, " +
9978
+ "chosen as `reject_story` chooses it: LOOPCTL_ORCH_KEY sent exactly when set, else " +
9979
+ "LOOPCTL_API_KEY. The gate is `exact_role: :orchestrator` with NO hierarchy, so a user or " +
9980
+ "superadmin key is 403 insufficient_role like an agent key. Whole-batch refusals: 400 " +
9981
+ "when the orchestrator key is linked to no agent, 403 custody_tier_required on an " +
9982
+ "agent-rooted tenant, 409 chg_root_cannot_verify for a chg-rooted key, 422 for an empty " +
9983
+ "or oversized batch, 500 audit_chain_append_failed when a release's escalation could not " +
9984
+ "append its chain entry (the WHOLE batch rolled back), 503 tenant_halted under a custody " +
9985
+ "halt. Refused by the tool, sending nothing: a bad batch, a story_id that is not a UUID " +
9986
+ "or is named twice, a missing or blank `reason`, and a non-string `reason`/`review_type` " +
9987
+ "or non-object `findings` (loopctl would reject the story and silently record no result).",
9988
+ inputSchema: {
9989
+ type: "object",
9990
+ properties: {
9991
+ stories: {
9992
+ type: "array",
9993
+ description: "The stories to reject, 1 to 50, each once.",
9994
+ items: {
9995
+ type: "object",
9996
+ properties: {
9997
+ story_id: { type: "string", description: "The UUID of the story." },
9998
+ reason: { type: "string", description: "Required: why it is rejected." },
9999
+ review_type: { type: "string", description: "Optional review type label." },
10000
+ findings: { type: "object", description: "Optional structured findings." },
10001
+ },
10002
+ required: ["story_id", "reason"],
10003
+ },
10004
+ },
10005
+ },
10006
+ required: ["stories"],
10007
+ },
10008
+ },
10009
+ {
10010
+ name: "register_agent",
10011
+ description:
10012
+ "REGISTER THIS KEY'S AGENT (POST /api/v1/agents/register): creates an agent row named " +
10013
+ "`name` of type `agent_type` (orchestrator or implementer), with optional `metadata`, " +
10014
+ "and links the CALLING key to it; 201 with `agent`. Sent on this session's own key. The " +
10015
+ "gate is `exact_role: :agent` with NO hierarchy: an orchestrator, user or superadmin key " +
10016
+ "is 403 insufficient_role. 409 when the key already carries an agent (a holder " +
10017
+ "credential always does), 422 without `name` or `agent_type`, for a taken name, or for a " +
10018
+ "name starting `system:` (any case), which loopctl reserves for its own agents. Refused " +
10019
+ "by the tool, sending nothing: a blank `name`, an `agent_type` outside the enum, and a " +
10020
+ "`metadata` that is not an object.",
10021
+ inputSchema: {
10022
+ type: "object",
10023
+ properties: {
10024
+ name: { type: "string", description: "The agent's name." },
10025
+ agent_type: {
10026
+ type: "string",
10027
+ enum: ["orchestrator", "implementer"],
10028
+ description: "The agent's type.",
10029
+ },
10030
+ metadata: { type: "object", description: "Optional: any structured detail." },
10031
+ },
10032
+ required: ["name", "agent_type"],
10033
+ },
10034
+ },
10035
+ {
10036
+ name: "list_agents",
10037
+ description:
10038
+ "LIST THE TENANT'S AGENTS (GET /api/v1/agents): each with `id`, `name`, `agent_type`, " +
10039
+ "`status`, `last_seen_at` and `metadata`, plus `total`, `page` and `page_size`. Filters " +
10040
+ "`agent_type` (orchestrator, implementer) and `status` (active, idle, deactivated); " +
10041
+ "`sort_by` one of name, agent_type, status, last_seen_at, inserted_at (default name); " +
10042
+ "`page` and `page_size` (1..100, default 20). Needs an ORCHESTRATOR-role key or higher " +
10043
+ "(`role: :orchestrator` with the hierarchy), sent on LOOPCTL_ORCH_KEY verbatim, else " +
10044
+ "LOOPCTL_USER_KEY, else the default key; an agent key is 403 insufficient_role. Refused " +
10045
+ "by the tool, sending nothing: a filter or sort outside its enum and a bad page, because " +
10046
+ "loopctl DROPS an unknown filter or bad number and would answer every agent.",
10047
+ inputSchema: {
10048
+ type: "object",
10049
+ properties: {
10050
+ agent_type: {
10051
+ type: "string",
10052
+ enum: ["orchestrator", "implementer"],
10053
+ description: "Optional agent_type filter.",
10054
+ },
10055
+ status: {
10056
+ type: "string",
10057
+ enum: ["active", "idle", "deactivated"],
10058
+ description: "Optional status filter.",
10059
+ },
10060
+ sort_by: {
10061
+ type: "string",
10062
+ enum: ["name", "agent_type", "status", "last_seen_at", "inserted_at"],
10063
+ description: "Optional sort field (default name).",
10064
+ },
10065
+ page: { type: "integer", description: "Optional page number (default 1)." },
10066
+ page_size: { type: "integer", description: "Optional page size, 1..100 (default 20)." },
10067
+ },
10068
+ required: [],
10069
+ },
10070
+ },
10071
+ {
10072
+ name: "get_agent",
10073
+ description:
10074
+ "READ ONE AGENT (GET /api/v1/agents/:id): its `name`, `agent_type`, `status`, " +
10075
+ "`last_seen_at` and `metadata`. Needs an ORCHESTRATOR-role key or higher (`role: " +
10076
+ ":orchestrator` with the hierarchy), sent on LOOPCTL_ORCH_KEY verbatim, else " +
10077
+ "LOOPCTL_USER_KEY, else the default key; an agent key is 403 insufficient_role. 404 for " +
10078
+ "an agent that is not this tenant's. An `agent_id` that is not a UUID is refused by the " +
10079
+ "tool, sending nothing.",
10080
+ inputSchema: {
10081
+ type: "object",
10082
+ properties: {
10083
+ agent_id: { type: "string", description: "The UUID of the agent." },
10084
+ },
10085
+ required: ["agent_id"],
10086
+ },
10087
+ },
10088
+ {
10089
+ name: "api_key_list",
10090
+ description:
10091
+ "LIST THE TENANT'S API KEYS (GET /api/v1/api_keys): each with `id`, `name`, " +
10092
+ "`key_prefix`, `role`, `last_used_at`, `expires_at`, `revoked_at` and " +
10093
+ "`snapshot_project_id` — never a raw key or hash. Revoked keys are left out unless " +
10094
+ "`include_revoked` is true; an expired agent-linked agent or orchestrator key is revoked " +
10095
+ "by a sweep within minutes of expiring. Needs a USER-role key (`role: :user` with the " +
10096
+ "hierarchy), sent on LOOPCTL_USER_KEY verbatim when set, else the default key; an agent " +
10097
+ "or orchestrator key is 403 insufficient_role. A non-boolean `include_revoked` is " +
10098
+ "refused by the tool, sending nothing.",
10099
+ inputSchema: {
10100
+ type: "object",
10101
+ properties: {
10102
+ include_revoked: {
10103
+ type: "boolean",
10104
+ description: "Optional: true lists revoked keys too.",
10105
+ },
10106
+ },
10107
+ required: [],
10108
+ },
10109
+ },
10110
+ {
10111
+ name: "api_key_rotate",
10112
+ description:
10113
+ "ROTATE AN API KEY (POST /api/v1/api_keys/:id/rotate): mints a replacement with the old " +
10114
+ "key's name, role, agent and snapshot scope, and puts the old key on an expiry " +
10115
+ "`grace_period_hours` from now (default 24, from 1 to 168). " +
10116
+ "The new raw key is written to `key_file` (absolute, must not exist, created 0600 " +
10117
+ "before anything is sent) and is never in the result, which carries `new_key` (id, " +
10118
+ "prefix, role, name, expiry, scope) and `old_key_expires_at`. Needs a USER-role key that " +
10119
+ "no dispatch minted, sent on LOOPCTL_USER_KEY verbatim when set, else the default key: " +
10120
+ "an agent or orchestrator key is 403 insufficient_role, a dispatch-minted key 403 " +
10121
+ "api_key_mint_forbidden. 404 for a key that is not this tenant's, 422 `Cannot rotate a " +
10122
+ "revoked key`, 422 for a runner's key (revoke and re-enroll the runner). Rotating " +
10123
+ "LOOPCTL_USER_KEY itself is allowed: move the new key into place before the grace period " +
10124
+ "ends. Refused by the tool, sending nothing: an `api_key_id` that is not a UUID, a " +
10125
+ "`grace_period_hours` that is not an integer from 1 to 168 (loopctl would clamp a larger one " +
10126
+ "silently), and a `key_file` that is not absolute or already exists.",
10127
+ inputSchema: {
10128
+ type: "object",
10129
+ properties: {
10130
+ api_key_id: { type: "string", description: "The UUID of the key to rotate." },
10131
+ grace_period_hours: {
10132
+ type: "integer",
10133
+ description: "Optional: hours the old key keeps working, 1 to 168 (default 24); 0 or less is refused, because expiring the old key at once can lock out the caller.",
10134
+ },
10135
+ key_file: {
10136
+ type: "string",
10137
+ description: "Absolute path, not existing yet, where the new raw key is written.",
10138
+ },
10139
+ },
10140
+ required: ["api_key_id", "key_file"],
10141
+ },
10142
+ },
10143
+ {
10144
+ name: "channel_quarantine_list",
10145
+ description:
10146
+ "REVIEW QUARANTINED COORDINATION POSTS (GET /api/v1/channel/posts/quarantined): the " +
10147
+ "posts the secret rescan hid as suspected credentials, newest quarantine first, with " +
10148
+ "`meta` (`count`, `limit`). The FULL rows are written to `rows_file` (absolute, must not " +
10149
+ "exist, created 0600) and NOT returned: the result lists each post with its scanned " +
10150
+ "fields (body, key, session_id, host, to_host, to_capability, idempotency_key, refs) " +
10151
+ "removed, and `quarantine_reason` names the ones that tripped. Read the file, judge, " +
10152
+ "then `channel_delete` a real credential or `channel_quarantine_release` a false positive, and " +
10153
+ "delete the file. Optional `project_id` (an id, slug or repo name; one that names no " +
10154
+ "project answers an empty list) and `limit` (1..100, default 25). Needs a USER-role key " +
10155
+ "on a human-anchored tenant (`role: :user` with the hierarchy), sent on LOOPCTL_USER_KEY " +
10156
+ "verbatim when set, else the default key: an agent or orchestrator key is 403 " +
10157
+ "insufficient_role, an agent-rooted tenant 403 custody_tier_required. Refused by the " +
10158
+ "tool, sending nothing: a `limit` outside 1..100 (loopctl would silently clamp or default " +
10159
+ "it) and a `rows_file` that is not absolute or already exists.",
10160
+ inputSchema: {
10161
+ type: "object",
10162
+ properties: {
10163
+ project_id: {
10164
+ type: "string",
10165
+ description: "Optional: one project's channel (its id, slug or repo name).",
10166
+ },
10167
+ limit: { type: "integer", description: "Optional: at most this many, 1..100 (default 25)." },
10168
+ rows_file: {
10169
+ type: "string",
10170
+ description: "Absolute path, not existing yet, where the full rows are written.",
10171
+ },
10172
+ },
10173
+ required: ["rows_file"],
10174
+ },
10175
+ },
10176
+ {
10177
+ name: "channel_quarantine_release",
10178
+ description:
10179
+ "RELEASE A QUARANTINED COORDINATION POST (POST /api/v1/channel/posts/:id/release): the " +
10180
+ "false-positive exoneration, the counterpart to `channel_delete`. The post is readable " +
10181
+ "on its channel again and is exempt from the rescan for the current denylist revision; " +
10182
+ "the release is audited. Answers `released: true` and the post with its scanned fields " +
10183
+ "removed (read it with `channel_get`). Needs a USER-role key on a human-anchored tenant, " +
10184
+ "sent on LOOPCTL_USER_KEY verbatim when set, else the default key: an agent or " +
10185
+ "orchestrator key is 403 insufficient_role, an agent-rooted tenant 403 " +
10186
+ "custody_tier_required. 404, identical for each, when the post is missing, another " +
10187
+ "tenant's or not quarantined; 500 audit_write_failed when the audit entry could not be " +
10188
+ "written (nothing was released). A `post_id` that is not a UUID is refused by the tool, " +
10189
+ "sending nothing.",
10190
+ inputSchema: {
10191
+ type: "object",
10192
+ properties: {
10193
+ post_id: { type: "string", description: "The UUID of the quarantined post." },
10194
+ },
10195
+ required: ["post_id"],
10196
+ },
10197
+ },
10198
+ {
10199
+ name: "audit_inclusion_proof",
10200
+ description:
10201
+ "PROVE AN AUDIT ENTRY IS IN THE SIGNED LOG (GET " +
10202
+ "/api/v1/audit/sth/:tenant_id/inclusion/:position): the merkle audit path from the entry " +
10203
+ "at `position` up to the signed tree head that covers it, as `leaf_index`, `leaf_hash`, " +
10204
+ "`tree_size`, `audit_path` and `sth` (hashes URL-safe base64, no padding). Fold the leaf " +
10205
+ "up the path, compare with `sth.merkle_root`, and check `sth.signature` against the " +
10206
+ "tenant's public audit key. PUBLIC: sent with no key, so it works for any tenant and in " +
10207
+ "a session whose keys fail. 400 invalid_tenant_id, 404 for a position with no entry, 409 " +
10208
+ "not_yet_included when no signed tree head covers the entry yet (retry after the next " +
10209
+ "one), 429 past the per-IP proof budget (wait for the retry-after). Refused by the tool, " +
10210
+ "sending nothing: a `tenant_id` that is not a UUID and a `position` that is not a " +
10211
+ "non-negative integer (loopctl would answer the same 404 as a missing entry).",
10212
+ inputSchema: {
10213
+ type: "object",
10214
+ properties: {
10215
+ tenant_id: { type: "string", description: "The UUID of the tenant." },
10216
+ position: {
10217
+ type: "integer",
10218
+ description: "The entry's chain_position, as a custody claim or audit entry names it.",
10219
+ },
10220
+ },
10221
+ required: ["tenant_id", "position"],
10222
+ },
10223
+ },
10224
+ {
10225
+ name: "list_trusted_endpoints",
10226
+ description:
10227
+ "LIST THE TENANT'S DECLARED TRUSTED ENDPOINTS (GET /api/v1/egress/trusted-endpoints): " +
10228
+ "each host the tenant declared with its purposes, and `locality_label`. Every entry is " +
10229
+ "an UNVERIFIED tenant attestation, not network locality: loopctl does not prove the " +
10230
+ "tenant owns the host. Read-only, on this session's own key; the route has no role " +
10231
+ "plug, so any key of the tenant reads it. Declare with `declare_trusted_endpoint`, " +
10232
+ "revoke with `revoke_trusted_endpoint` (both need the user key).",
10233
+ inputSchema: { type: "object", properties: {}, required: [] },
10234
+ },
10235
+ {
10236
+ name: "list_authenticators",
10237
+ description:
10238
+ "LIST THE TENANT'S ENROLLED WEBAUTHN AUTHENTICATORS (GET " +
10239
+ "/api/v1/tenants/:id/authenticators): each one's `id` (what `rename_authenticator` and " +
10240
+ "`revoke_authenticator` take), `friendly_name`, `credential_fingerprint`, " +
10241
+ "`attestation_format`, `inserted_at` and `last_used_at`, never credential material. " +
10242
+ "Confirm a revoke against the FINGERPRINT: the label is rewritable by any user key. No " +
10243
+ "WebAuthn assertion is needed. Needs a USER-role key of THIS tenant, sent on " +
10244
+ "LOOPCTL_USER_KEY verbatim when set, else the default key: 403 insufficient_role below " +
10245
+ "user, 403 Forbidden when `tenant_id` is not the key's own tenant (`get_tenant` gives " +
10246
+ "it). A `tenant_id` that is not a UUID is refused by the tool, sending nothing; one in " +
10247
+ "upper case is sent lower case, since loopctl compares it as text.",
10248
+ inputSchema: {
10249
+ type: "object",
10250
+ properties: {
10251
+ tenant_id: { type: "string", description: "The UUID of your tenant." },
10252
+ },
10253
+ required: ["tenant_id"],
10254
+ },
10255
+ },
10256
+ {
10257
+ name: "rename_authenticator",
10258
+ description:
10259
+ "RELABEL AN ENROLLED AUTHENTICATOR (PATCH /api/v1/tenants/:id/authenticators/:auth_id): " +
10260
+ "only `friendly_name` changes (trimmed, not blank, at most 120 bytes); no credential " +
10261
+ "material, and no WebAuthn assertion is needed. The old and new label are recorded in " +
10262
+ "the audit chain against the calling key. Needs a USER-role key of THIS tenant, sent on " +
10263
+ "LOOPCTL_USER_KEY verbatim when set, else the default key: 403 insufficient_role below " +
10264
+ "user, 403 Forbidden for another tenant's id. 400 without a string `friendly_name`, 404 " +
10265
+ "for an unknown authenticator, 422 friendly_name_blank, friendly_name_invalid or " +
10266
+ "friendly_name_too_long, 429 past the tenant's rename budget (300 an hour), 500 when the " +
10267
+ "rename or its audit entry could not be written. Refused by the tool, sending nothing: a " +
10268
+ "non-UUID id and a blank or over-long `friendly_name`.",
10269
+ inputSchema: {
10270
+ type: "object",
10271
+ properties: {
10272
+ tenant_id: { type: "string", description: "The UUID of your tenant." },
10273
+ authenticator_id: {
10274
+ type: "string",
10275
+ description: "The authenticator's `id` from list_authenticators.",
10276
+ },
10277
+ friendly_name: { type: "string", description: "The new label, at most 120 bytes." },
10278
+ },
10279
+ required: ["tenant_id", "authenticator_id", "friendly_name"],
10280
+ },
10281
+ },
10282
+ {
10283
+ name: "update_tenant",
10284
+ description:
10285
+ "UPDATE THE TENANT'S OWN PROFILE (PATCH /api/v1/tenants/me): any of `name`, `email`, " +
10286
+ "`settings`, `default_story_budget_millicents` and `token_data_retention_days`; answers " +
10287
+ "the updated `tenant`. `settings` is MERGED into the stored map key by key (a key you " +
10288
+ "leave out keeps its value). Needs a USER-role key (`role: :user` with the hierarchy), " +
10289
+ "sent on LOOPCTL_USER_KEY verbatim when set, else the default key; an agent or " +
10290
+ "orchestrator key is 403 insufficient_role. 422 for a malformed or taken email, a " +
10291
+ "settings value loopctl types (knowledge_auto_extract, kb_curation_log) that is not a " +
10292
+ "boolean, a budget that is not above 0, or a retention that is not an integer of at " +
10293
+ "least 30 days (null turns retention off). The slug is immutable and is not a " +
10294
+ "parameter: loopctl would ignore one and answer 200 with it unchanged, so a call " +
10295
+ "carrying `slug`, or carrying no field at all, is refused by the tool, sending nothing. " +
10296
+ "Read the tenant with `get_tenant`.",
10297
+ inputSchema: {
10298
+ type: "object",
10299
+ properties: {
10300
+ name: { type: "string", description: "Optional: the tenant's display name." },
10301
+ email: { type: "string", description: "Optional: the tenant's contact email." },
10302
+ settings: {
10303
+ type: "object",
10304
+ description: "Optional: settings keys to merge into the stored settings.",
10305
+ },
10306
+ default_story_budget_millicents: {
10307
+ type: "integer",
10308
+ description: "Optional: the default per-story budget, above 0.",
10309
+ },
10310
+ token_data_retention_days: {
10311
+ type: ["integer", "null"],
10312
+ description: "Optional: days of token data kept, at least 30; null turns it off.",
10313
+ },
10314
+ },
10315
+ required: [],
10316
+ },
10317
+ },
10318
+
9774
10319
  {
9775
10320
  name: "factory_overview",
9776
10321
  description:
@@ -12997,6 +13542,38 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
12997
13542
  return await storyDependencyRemoveTool(args);
12998
13543
  case "story_dependency_list":
12999
13544
  return await storyDependencyListTool(args);
13545
+ case "bulk_claim":
13546
+ return await bulkClaimTool(args);
13547
+ case "unclaim_story":
13548
+ return await unclaimStoryTool(args);
13549
+ case "bulk_verify":
13550
+ return await bulkVerifyTool(args);
13551
+ case "bulk_reject":
13552
+ return await bulkRejectTool(args);
13553
+ case "register_agent":
13554
+ return await registerAgentTool(args);
13555
+ case "list_agents":
13556
+ return await listAgentsTool(args);
13557
+ case "get_agent":
13558
+ return await getAgentTool(args);
13559
+ case "api_key_list":
13560
+ return await apiKeyListTool(args);
13561
+ case "api_key_rotate":
13562
+ return await apiKeyRotateTool(args);
13563
+ case "channel_quarantine_list":
13564
+ return await channelQuarantinedTool(args);
13565
+ case "channel_quarantine_release":
13566
+ return await channelReleaseTool(args);
13567
+ case "audit_inclusion_proof":
13568
+ return await auditInclusionProofTool(args);
13569
+ case "list_trusted_endpoints":
13570
+ return await listTrustedEndpointsTool(args);
13571
+ case "list_authenticators":
13572
+ return await listAuthenticatorsTool(args);
13573
+ case "rename_authenticator":
13574
+ return await renameAuthenticatorTool(args);
13575
+ case "update_tenant":
13576
+ return await updateTenantTool(args);
13000
13577
  case "factory_overview":
13001
13578
  return await factoryOverviewTool(args);
13002
13579
  case "decisions":