loopctl-mcp-server 3.46.0 → 3.47.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
@@ -83,6 +83,21 @@ import {
83
83
  webhookTest,
84
84
  webhookUpdate,
85
85
  } from "./lib/webhooks.js";
86
+ import {
87
+ skillCostPerformance,
88
+ skillCreate,
89
+ skillDelete,
90
+ skillGet,
91
+ skillImport,
92
+ skillList,
93
+ skillResultReport,
94
+ skillStats,
95
+ skillUpdate,
96
+ skillVersionCreate,
97
+ skillVersionGet,
98
+ skillVersionResults,
99
+ skillVersions,
100
+ } from "./lib/skills.js";
86
101
  import {
87
102
  tokenBudgetDelete,
88
103
  tokenBudgetGet,
@@ -130,6 +145,28 @@ import {
130
145
  } from "./lib/generated-tools.js";
131
146
  import { exactKeyMissingMessage, orchestratorKeyArgs } from "./lib/custody-key.js";
132
147
  import { readPayloadFile } from "./lib/payload-path.js";
148
+ import {
149
+ entityCreate,
150
+ entityDelete,
151
+ entityGet,
152
+ entityList,
153
+ entityUpdate,
154
+ } from "./lib/entities.js";
155
+ import {
156
+ uiTestAddFinding,
157
+ uiTestComplete,
158
+ uiTestGet,
159
+ uiTestList,
160
+ uiTestStart,
161
+ } from "./lib/ui-tests.js";
162
+ import { projectExport } from "./lib/project-export.js";
163
+ import { corpusGet } from "./lib/corpus-get.js";
164
+ import {
165
+ knowledgeExport as downloadKnowledgeExport,
166
+ knowledgePipeline,
167
+ knowledgeProjectUsage,
168
+ } from "./lib/knowledge-admin.js";
169
+ import { knowledgeLinkCreate, knowledgeLinkDelete, knowledgeLinks } from "./lib/article-links.js";
133
170
  import { enrollRunner, listRunners, revokeRunner, runnerPool } from "./lib/runners.js";
134
171
  import { replyDraftList } from "./lib/reply-drafts.js";
135
172
  import {
@@ -411,7 +448,7 @@ async function sendRequest(
411
448
  path,
412
449
  body,
413
450
  keyOverride,
414
- { exactKey = false, timeoutMs, keyHint } = {},
451
+ { exactKey = false, timeoutMs, keyHint, saveBody } = {},
415
452
  ) {
416
453
  const url = `${getBaseUrl()}${path}`;
417
454
  // `exactKey` sends `keyOverride` VERBATIM instead of consulting `resolveKey`
@@ -505,6 +542,13 @@ async function sendRequest(
505
542
  return { ok: true };
506
543
  }
507
544
 
545
+ // A binary answer (knowledge_export's .tar.gz) cannot be decoded as text without being
546
+ // corrupted, so a caller that asks for the body hands over the Response on success and
547
+ // writes it where it belongs (lib/knowledge-admin.js). A refusal is still parsed below.
548
+ if (saveBody && response.ok) {
549
+ return saveBody(response);
550
+ }
551
+
508
552
  let responseBody;
509
553
  const contentType = response.headers.get("content-type") || "";
510
554
  if (contentType.includes("application/json")) {
@@ -1191,13 +1235,15 @@ async function getStory({ story_id }) {
1191
1235
  // set the default selection (`resolveKey`) applies. Unlike the unconditional user-key family
1192
1236
  // described above `apiCall`, these fall back rather than refuse: their gates use the role
1193
1237
  // hierarchy (`role:`, never `exact_role:`), so a sufficient global key passes.
1238
+ // `opts` carries request options that are not about the key (`timeoutMs`, `saveBody`); the key
1239
+ // options are this function's to set.
1194
1240
  function pinnedApiCall(hint) {
1195
- return (method, path, body) => {
1241
+ return (method, path, body, opts = {}) => {
1196
1242
  const keyHint = hint();
1197
1243
 
1198
1244
  return keyHint
1199
- ? apiCall(method, path, body, process.env[keyHint], { exactKey: true, keyHint })
1200
- : apiCall(method, path, body);
1245
+ ? apiCall(method, path, body, process.env[keyHint], { ...opts, exactKey: true, keyHint })
1246
+ : apiCall(method, path, body, undefined, opts);
1201
1247
  };
1202
1248
  }
1203
1249
 
@@ -1431,6 +1477,69 @@ async function webhookDeliveriesTool(args) {
1431
1477
  return toContent(await webhookDeliveries(args, { apiCall: userKeyApiCall }));
1432
1478
  }
1433
1479
 
1480
+ // loopctl #872, batch 4. The skill writes (create, update, delete, new version, import) and the
1481
+ // cost-performance read are `role: :user` (`userKeyApiCall`); the other skill reads are
1482
+ // `role: :agent` (the session's own key). The skill result is `exact_role: [:orchestrator,
1483
+ // :superadmin]`, so it selects its key through `orchestratorKeyArgs` as bulk_verify does.
1484
+
1485
+ async function skillCreateTool(args) {
1486
+ return toContent(await skillCreate(args, { apiCall: userKeyApiCall }));
1487
+ }
1488
+
1489
+ async function skillListTool(args) {
1490
+ return toContent(await skillList(args, { apiCall: ownKeyApiCall }));
1491
+ }
1492
+
1493
+ async function skillGetTool(args) {
1494
+ return toContent(await skillGet(args, { apiCall: ownKeyApiCall }));
1495
+ }
1496
+
1497
+ async function skillUpdateTool(args) {
1498
+ return toContent(await skillUpdate(args, { apiCall: userKeyApiCall }));
1499
+ }
1500
+
1501
+ async function skillDeleteTool(args) {
1502
+ return toContent(await skillDelete(args, { apiCall: userKeyApiCall }));
1503
+ }
1504
+
1505
+ async function skillImportTool(args) {
1506
+ return toContent(await skillImport(args, { apiCall: userKeyApiCall }));
1507
+ }
1508
+
1509
+ async function skillVersionCreateTool(args) {
1510
+ return toContent(await skillVersionCreate(args, { apiCall: userKeyApiCall }));
1511
+ }
1512
+
1513
+ async function skillVersionsTool(args) {
1514
+ return toContent(await skillVersions(args, { apiCall: ownKeyApiCall }));
1515
+ }
1516
+
1517
+ async function skillVersionGetTool(args) {
1518
+ return toContent(await skillVersionGet(args, { apiCall: ownKeyApiCall }));
1519
+ }
1520
+
1521
+ async function skillStatsTool(args) {
1522
+ return toContent(await skillStats(args, { apiCall: ownKeyApiCall }));
1523
+ }
1524
+
1525
+ async function skillVersionResultsTool(args) {
1526
+ return toContent(await skillVersionResults(args, { apiCall: ownKeyApiCall }));
1527
+ }
1528
+
1529
+ async function skillCostPerformanceTool(args) {
1530
+ return toContent(await skillCostPerformance(args, { apiCall: userKeyApiCall }));
1531
+ }
1532
+
1533
+ async function skillResultReportTool(args) {
1534
+ const orch = orchestratorKeyArgs();
1535
+
1536
+ return toContent(
1537
+ await skillResultReport(args, {
1538
+ apiCall: (method, path, body) => apiCall(method, path, body, orch.override, orch.options),
1539
+ }),
1540
+ );
1541
+ }
1542
+
1434
1543
  async function tokenBudgetListTool(args) {
1435
1544
  return toContent(await tokenBudgetList(args, { apiCall: ownKeyApiCall }));
1436
1545
  }
@@ -2183,8 +2292,10 @@ async function knowledgeList({
2183
2292
  include_body,
2184
2293
  suppressed,
2185
2294
  }) {
2295
+ // A project goes in the path (GET /api/v1/projects/:project_id/articles), the route
2296
+ // ArticleController.index serves for exactly this filter; the action reads it as the same
2297
+ // `project_id` param a query string would carry (loopctl #872).
2186
2298
  const params = new URLSearchParams();
2187
- if (project_id) params.set("project_id", project_id);
2188
2299
  if (category) params.set("category", category);
2189
2300
  if (status) params.set("status", status);
2190
2301
  if (tags) params.set("tags", tags);
@@ -2205,7 +2316,9 @@ async function knowledgeList({
2205
2316
 
2206
2317
  const result = await apiCall(
2207
2318
  "GET",
2208
- `/api/v1/articles?${params}`,
2319
+ project_id
2320
+ ? `/api/v1/projects/${encodeURIComponent(project_id)}/articles?${params}`
2321
+ : `/api/v1/articles?${params}`,
2209
2322
  null,
2210
2323
  agentKey(),
2211
2324
  );
@@ -2282,10 +2395,12 @@ async function knowledgeCreate({
2282
2395
  idempotency_key,
2283
2396
  metadata,
2284
2397
  }) {
2398
+ // A project goes in the path (POST /api/v1/projects/:project_id/articles), the route
2399
+ // ArticleController.create serves for a project-scoped article; the action merges it into
2400
+ // the attrs as the same `project_id` a body would carry (loopctl #872).
2285
2401
  const payload = { title, body };
2286
2402
  if (category) payload.category = category;
2287
2403
  if (tags) payload.tags = tags;
2288
- if (project_id) payload.project_id = project_id;
2289
2404
  if (source_type) payload.source_type = source_type;
2290
2405
  if (source_id) payload.source_id = source_id;
2291
2406
  if (idempotency_key) payload.idempotency_key = idempotency_key;
@@ -2305,7 +2420,9 @@ async function knowledgeCreate({
2305
2420
 
2306
2421
  const result = await apiCall(
2307
2422
  "POST",
2308
- "/api/v1/articles",
2423
+ project_id
2424
+ ? `/api/v1/projects/${encodeURIComponent(project_id)}/articles`
2425
+ : "/api/v1/articles",
2309
2426
  payload,
2310
2427
  agentKey(),
2311
2428
  );
@@ -2793,6 +2910,88 @@ async function knowledgeLint({ project_id, stale_days, min_coverage, max_per_cat
2793
2910
  return toContent(result);
2794
2911
  }
2795
2912
 
2913
+ // loopctl #872, batch 4. Entity definitions are a security root: create, update and delete are
2914
+ // `role: :user` + human-anchored (`userKeyApiCall`), list and show `role: :agent`
2915
+ // (`ownKeyApiCall`). Every ui-test action, project_export, corpus_get and knowledge_links are
2916
+ // `role: :agent` (`ownKeyApiCall`). knowledge_project_usage and knowledge_pipeline are
2917
+ // `role: :orchestrator` (`orchestratorPinnedApiCall`). knowledge_export and
2918
+ // knowledge_link_delete are `role: :user` (`userKeyApiCall`); knowledge_link_create is
2919
+ // `role: :agent` except a `supersedes` link, which the action holds to `role: :user`.
2920
+
2921
+ async function entityListTool(args) {
2922
+ return toContent(await entityList(args, { apiCall: ownKeyApiCall }));
2923
+ }
2924
+
2925
+ async function entityGetTool(args) {
2926
+ return toContent(await entityGet(args, { apiCall: ownKeyApiCall }));
2927
+ }
2928
+
2929
+ async function entityCreateTool(args) {
2930
+ return toContent(await entityCreate(args, { apiCall: userKeyApiCall }));
2931
+ }
2932
+
2933
+ async function entityUpdateTool(args) {
2934
+ return toContent(await entityUpdate(args, { apiCall: userKeyApiCall }));
2935
+ }
2936
+
2937
+ async function entityDeleteTool(args) {
2938
+ return toContent(await entityDelete(args, { apiCall: userKeyApiCall }));
2939
+ }
2940
+
2941
+ async function uiTestStartTool(args) {
2942
+ return toContent(await uiTestStart(args, { apiCall: ownKeyApiCall }));
2943
+ }
2944
+
2945
+ async function uiTestListTool(args) {
2946
+ return toContent(await uiTestList(args, { apiCall: ownKeyApiCall }));
2947
+ }
2948
+
2949
+ async function uiTestGetTool(args) {
2950
+ return toContent(await uiTestGet(args, { apiCall: ownKeyApiCall }));
2951
+ }
2952
+
2953
+ async function uiTestAddFindingTool(args) {
2954
+ return toContent(await uiTestAddFinding(args, { apiCall: ownKeyApiCall }));
2955
+ }
2956
+
2957
+ async function uiTestCompleteTool(args) {
2958
+ return toContent(await uiTestComplete(args, { apiCall: ownKeyApiCall }));
2959
+ }
2960
+
2961
+ async function projectExportTool(args) {
2962
+ return toContent(await projectExport(args, { apiCall: ownKeyApiCall }));
2963
+ }
2964
+
2965
+ async function corpusGetTool(args) {
2966
+ return toContent(await corpusGet(args, { apiCall: ownKeyApiCall }));
2967
+ }
2968
+
2969
+ async function knowledgeProjectUsageTool(args) {
2970
+ return toContent(await knowledgeProjectUsage(args, { apiCall: orchestratorPinnedApiCall }));
2971
+ }
2972
+
2973
+ async function knowledgePipelineTool(args) {
2974
+ return toContent(await knowledgePipeline(args, { apiCall: orchestratorPinnedApiCall }));
2975
+ }
2976
+
2977
+ async function knowledgeExportTool(args) {
2978
+ return toContent(await downloadKnowledgeExport(args, { apiCall: userKeyApiCall }));
2979
+ }
2980
+
2981
+ async function knowledgeLinkCreateTool(args) {
2982
+ return toContent(
2983
+ await knowledgeLinkCreate(args, { apiCall: ownKeyApiCall, userApiCall: userKeyApiCall }),
2984
+ );
2985
+ }
2986
+
2987
+ async function knowledgeLinkDeleteTool(args) {
2988
+ return toContent(await knowledgeLinkDelete(args, { apiCall: userKeyApiCall }));
2989
+ }
2990
+
2991
+ async function knowledgeLinksTool(args) {
2992
+ return toContent(await knowledgeLinks(args, { apiCall: ownKeyApiCall }));
2993
+ }
2994
+
2796
2995
  async function knowledgeConsolidation({ day, class: klass, limit, offset } = {}) {
2797
2996
  const params = new URLSearchParams();
2798
2997
  if (day) params.set("day", String(day));
@@ -3207,30 +3406,6 @@ async function knowledgeUnusedArticles({ days_unused, limit, offset } = {}) {
3207
3406
  return toContent(result);
3208
3407
  }
3209
3408
 
3210
- async function knowledgeExport({ project_id }) {
3211
- const basePath = project_id
3212
- ? `/api/v1/projects/${project_id}/knowledge/export`
3213
- : "/api/v1/knowledge/export";
3214
- const baseUrl = getBaseUrl();
3215
- // The export endpoint is role:user — use LOOPCTL_USER_KEY. (LOOPCTL_ORCH_KEY is
3216
- // orchestrator role, which is BELOW user in the hierarchy and would 403.) The
3217
- // endpoint streams a gzipped tar (`application/gzip`), so save it as `.tar.gz`.
3218
- const downloadCmd = `curl -H "Authorization: Bearer $LOOPCTL_USER_KEY" "${baseUrl}${basePath}" -o knowledge-export.tar.gz`;
3219
- return {
3220
- content: [{
3221
- type: "text",
3222
- text: JSON.stringify({
3223
- message:
3224
- "Knowledge export streams a bounded-memory gzipped tar (.tar.gz). Use the curl " +
3225
- "command below to download it directly. Requires a user-role key " +
3226
- "(LOOPCTL_USER_KEY); extract with `tar -xzf knowledge-export.tar.gz`.",
3227
- command: downloadCmd,
3228
- endpoint: `${baseUrl}${basePath}`,
3229
- }, null, 2),
3230
- }],
3231
- };
3232
- }
3233
-
3234
3409
  // --- OKF (Open Knowledge Format) interchange ---
3235
3410
 
3236
3411
  // Guard a user-supplied absolute filesystem path against pseudo-filesystems.
@@ -7818,6 +7993,367 @@ const TOOLS = [
7818
7993
  required: [],
7819
7994
  },
7820
7995
  },
7996
+ {
7997
+ name: "entity_list",
7998
+ description:
7999
+ "LIST THE TENANT'S CONTEXT RETRIEVER ENTITY DEFINITIONS (GET /api/v1/entities, Epic 30), " +
8000
+ "ordered by name: each with `id`, `name`, `backing_source` (projects, stories or epics) " +
8001
+ "and `fields` (the declared columns with `type`, `filterable`, `searchable`). Each " +
8002
+ "definition is what a generated `cr_filter_*` / `cr_search_*` tool queries. Any key of " +
8003
+ "the tenant (`role: :agent`); travels on this session's own key. A superadmin key with " +
8004
+ "no impersonation target is 422 impersonation_tenant_required.",
8005
+ inputSchema: { type: "object", properties: {}, required: [] },
8006
+ },
8007
+ {
8008
+ name: "entity_get",
8009
+ description:
8010
+ "READ ONE CONTEXT RETRIEVER ENTITY DEFINITION (GET /api/v1/entities/:id). Any key of the " +
8011
+ "tenant (`role: :agent`), on this session's own key. 404 for a definition that is not " +
8012
+ "this tenant's. A non-UUID `entity_id` is refused by the tool, sending nothing.",
8013
+ inputSchema: {
8014
+ type: "object",
8015
+ properties: {
8016
+ entity_id: { type: "string", description: "The definition's UUID." },
8017
+ },
8018
+ required: ["entity_id"],
8019
+ },
8020
+ },
8021
+ {
8022
+ name: "entity_create",
8023
+ description:
8024
+ "DEFINE A CONTEXT RETRIEVER ENTITY (POST /api/v1/entities): `name` (lowercase " +
8025
+ "snake_case, at most 100 characters), `backing_source` (projects, stories or epics) and " +
8026
+ "`fields`, a non-empty list of `{name, type, filterable, searchable}` where `type` is " +
8027
+ "string, integer, boolean, float or datetime. The definition is a SECURITY ROOT: its " +
8028
+ "fields are the executor's allowlist and the tenant's cr_* tools are generated from it, " +
8029
+ "and loopctl accepts only the columns its own per-source allowlist names (never " +
8030
+ "tenant_id, metadata or a custody column). Needs a USER-role key (`role: :user` with " +
8031
+ "the hierarchy) on a human-anchored tenant, sent on LOOPCTL_USER_KEY verbatim when set, " +
8032
+ "else the default key: an agent or orchestrator key is 403 insufficient_role, an " +
8033
+ "agent-rooted tenant 403 custody_tier_required. 422 for a column the source does not " +
8034
+ "allowlist, a bad name or type, more than 50 fields, or the per-tenant limit " +
8035
+ "(entity_limit). Refused by the tool, " +
8036
+ "sending nothing: a blank name, an unknown backing_source and an empty or non-object " +
8037
+ "fields list.",
8038
+ inputSchema: {
8039
+ type: "object",
8040
+ properties: {
8041
+ name: { type: "string", description: "The entity name, lowercase snake_case." },
8042
+ backing_source: {
8043
+ type: "string",
8044
+ enum: ["projects", "stories", "epics"],
8045
+ description: "The table the entity reads.",
8046
+ },
8047
+ fields: {
8048
+ type: "array",
8049
+ items: {
8050
+ type: "object",
8051
+ properties: {
8052
+ name: { type: "string" },
8053
+ type: { type: "string", enum: ["string", "integer", "boolean", "float", "datetime"] },
8054
+ filterable: { type: "boolean" },
8055
+ searchable: { type: "boolean" },
8056
+ },
8057
+ },
8058
+ description: "The declared columns, each an allowlisted column of the backing source.",
8059
+ },
8060
+ },
8061
+ required: ["name", "backing_source", "fields"],
8062
+ },
8063
+ },
8064
+ {
8065
+ name: "entity_update",
8066
+ description:
8067
+ "EDIT A CONTEXT RETRIEVER ENTITY DEFINITION (PATCH /api/v1/entities/:id): any of " +
8068
+ "`name`, `backing_source` and `fields` (the full new list; it replaces the old one). An " +
8069
+ "omitted field keeps its value, and the result is re-validated against loopctl's column " +
8070
+ "allowlist, so an update can never widen it. Keyed and gated as entity_create: a " +
8071
+ "USER-role key on a human-anchored tenant; an agent or orchestrator key is 403 " +
8072
+ "insufficient_role, an agent-rooted tenant 403 custody_tier_required. 404 for a " +
8073
+ "definition that is not this tenant's; 422 as entity_create. Refused by the tool, " +
8074
+ "sending nothing: a non-UUID `entity_id`, a call naming no field (loopctl would answer " +
8075
+ "200 unchanged), and the malformed values entity_create refuses.",
8076
+ inputSchema: {
8077
+ type: "object",
8078
+ properties: {
8079
+ entity_id: { type: "string", description: "The definition's UUID." },
8080
+ name: { type: "string", description: "Optional: the new name." },
8081
+ backing_source: {
8082
+ type: "string",
8083
+ enum: ["projects", "stories", "epics"],
8084
+ description: "Optional: the new backing source.",
8085
+ },
8086
+ fields: {
8087
+ type: "array",
8088
+ items: { type: "object" },
8089
+ description: "Optional: the full new field list, as entity_create takes it.",
8090
+ },
8091
+ },
8092
+ required: ["entity_id"],
8093
+ },
8094
+ },
8095
+ {
8096
+ name: "entity_delete",
8097
+ description:
8098
+ "DELETE A CONTEXT RETRIEVER ENTITY DEFINITION (DELETE /api/v1/entities/:id); its cr_* " +
8099
+ "tools stop being generated. Audited; answers the deleted definition. Keyed and gated " +
8100
+ "as entity_create: a USER-role key on a human-anchored tenant; an agent or orchestrator " +
8101
+ "key is 403 insufficient_role, an agent-rooted tenant 403 custody_tier_required. 404 for " +
8102
+ "a definition that is not this tenant's. A non-UUID `entity_id` is refused by the tool, " +
8103
+ "sending nothing.",
8104
+ inputSchema: {
8105
+ type: "object",
8106
+ properties: {
8107
+ entity_id: { type: "string", description: "The definition's UUID." },
8108
+ },
8109
+ required: ["entity_id"],
8110
+ },
8111
+ },
8112
+ {
8113
+ name: "ui_test_start",
8114
+ description:
8115
+ "START A UI TEST RUN for a project (POST /api/v1/projects/:project_id/ui-tests): " +
8116
+ "`guide_reference` names the test guide the run follows (1..1000 characters). Answers " +
8117
+ "201 with `ui_test_run` (status in_progress, empty findings), started by this key's " +
8118
+ "agent. `role: :agent`, on this session's own key. 422 kb_project_no_work for a " +
8119
+ "knowledge-only (kind: kb) project, 422 for a project_id that is not a UUID and names " +
8120
+ "no project, or a guide_reference out of range. Refused by the tool, sending nothing: a blank " +
8121
+ "project_id or guide_reference. Record findings with ui_test_add_finding, then close " +
8122
+ "the run with ui_test_complete.",
8123
+ inputSchema: {
8124
+ type: "object",
8125
+ properties: {
8126
+ project_id: { type: "string", description: "The project's UUID, slug or repo name." },
8127
+ guide_reference: { type: "string", description: "The test guide this run follows." },
8128
+ },
8129
+ required: ["project_id", "guide_reference"],
8130
+ },
8131
+ },
8132
+ {
8133
+ name: "ui_test_list",
8134
+ description:
8135
+ "LIST A PROJECT'S UI TEST RUNS (GET /api/v1/projects/:project_id/ui-tests), newest " +
8136
+ "first, with `meta` total, limit and offset. Optional `status` (in_progress, passed, " +
8137
+ "failed or cancelled), `limit` (default 20) and `offset`. `role: :agent`, on this " +
8138
+ "session's own key. 422 for a project_id that is not a UUID and names no project. Refused by the " +
8139
+ "tool, sending nothing: a blank project_id, an unknown status, a limit below 1 and a " +
8140
+ "negative offset, which loopctl would not refuse cleanly.",
8141
+ inputSchema: {
8142
+ type: "object",
8143
+ properties: {
8144
+ project_id: { type: "string", description: "The project's UUID, slug or repo name." },
8145
+ status: {
8146
+ type: "string",
8147
+ enum: ["in_progress", "passed", "failed", "cancelled"],
8148
+ description: "Optional: only runs in this status.",
8149
+ },
8150
+ limit: { type: "integer", description: "Optional: runs per page (default 20)." },
8151
+ offset: { type: "integer", description: "Optional: runs to skip (default 0)." },
8152
+ },
8153
+ required: ["project_id"],
8154
+ },
8155
+ },
8156
+ {
8157
+ name: "ui_test_get",
8158
+ description:
8159
+ "READ ONE UI TEST RUN with all its findings (GET /api/v1/projects/:project_id/ui-tests/" +
8160
+ ":id). The run is found by its id within the tenant. `role: :agent`, on this session's " +
8161
+ "own key. 404 for a run that is not this tenant's. Refused by the tool, sending " +
8162
+ "nothing: a blank project_id and a non-UUID `run_id`.",
8163
+ inputSchema: {
8164
+ type: "object",
8165
+ properties: {
8166
+ project_id: { type: "string", description: "The project's UUID, slug or repo name." },
8167
+ run_id: { type: "string", description: "The run's UUID." },
8168
+ },
8169
+ required: ["project_id", "run_id"],
8170
+ },
8171
+ },
8172
+ {
8173
+ name: "ui_test_add_finding",
8174
+ description:
8175
+ "RECORD A FINDING on an in-progress UI test run (POST /api/v1/projects/:project_id/" +
8176
+ "ui-tests/:id/findings): any of `step`, `severity` (critical, high, medium or low; " +
8177
+ "critical and high are counted on the run), `type`, `description`, `screenshot_path` " +
8178
+ "(counted as a screenshot) and `console_errors`. Answers the updated run. `role: " +
8179
+ ":agent`, on this session's own key. 404 for a run that is not this tenant's, 422 when " +
8180
+ "the run is no longer in progress, 422 kb_project_no_work for a knowledge-only project. " +
8181
+ "Refused by the tool, sending nothing: a blank project_id, a non-UUID `run_id`, an " +
8182
+ "unknown severity (loopctl would store it uncounted) and a finding naming no field.",
8183
+ inputSchema: {
8184
+ type: "object",
8185
+ properties: {
8186
+ project_id: { type: "string", description: "The project's UUID, slug or repo name." },
8187
+ run_id: { type: "string", description: "The run's UUID." },
8188
+ step: { type: "string", description: "Optional: the guide step where it was found." },
8189
+ severity: {
8190
+ type: "string",
8191
+ enum: ["critical", "high", "medium", "low"],
8192
+ description: "Optional: the finding's severity.",
8193
+ },
8194
+ type: { type: "string", description: "Optional: the kind of finding (e.g. bug, ux)." },
8195
+ description: { type: "string", description: "Optional: what was observed." },
8196
+ screenshot_path: { type: "string", description: "Optional: where the screenshot is." },
8197
+ console_errors: {
8198
+ type: "array",
8199
+ items: { type: "string" },
8200
+ description: "Optional: browser console errors seen at this step.",
8201
+ },
8202
+ },
8203
+ required: ["project_id", "run_id"],
8204
+ },
8205
+ },
8206
+ {
8207
+ name: "ui_test_complete",
8208
+ description:
8209
+ "CLOSE A UI TEST RUN (POST /api/v1/projects/:project_id/ui-tests/:id/complete) with " +
8210
+ "`status` passed or failed and a `summary`; stamps completed_at; audited. `role: " +
8211
+ ":agent`, on this session's own key. 404 for a run that is not this tenant's, 422 when " +
8212
+ "the run is already completed, when status is anything but passed or failed, or when " +
8213
+ "summary is missing; 422 kb_project_no_work for a knowledge-only project. Refused by " +
8214
+ "the tool, sending nothing: a blank project_id and a non-UUID `run_id`.",
8215
+ inputSchema: {
8216
+ type: "object",
8217
+ properties: {
8218
+ project_id: { type: "string", description: "The project's UUID, slug or repo name." },
8219
+ run_id: { type: "string", description: "The run's UUID." },
8220
+ status: { type: "string", enum: ["passed", "failed"], description: "The verdict." },
8221
+ summary: { type: "string", description: "What the run found." },
8222
+ },
8223
+ required: ["project_id", "run_id", "status", "summary"],
8224
+ },
8225
+ },
8226
+ {
8227
+ name: "project_export",
8228
+ description:
8229
+ "EXPORT A PROJECT'S WORK BREAKDOWN as JSON (GET /api/v1/projects/:id/export): " +
8230
+ "`export_metadata`, `project`, `epics` with their stories, `story_dependencies` and " +
8231
+ "`epic_dependencies`, the shape import_stories takes back (payload_path). Optional " +
8232
+ "`out_file` (an absolute path that must not exist yet, created 0600) writes the export " +
8233
+ "there and returns its counts instead of the whole document. `role: :agent`, on this " +
8234
+ "session's own key; not human-anchored. 404 for a project that is not this tenant's. " +
8235
+ "Refused by the tool, sending nothing: a `project_id` that is not a UUID (this route " +
8236
+ "does not resolve a slug or repo name and would answer 404; use resolve_project first) " +
8237
+ "and an out_file that is not absolute, exists already or sits in a missing directory.",
8238
+ inputSchema: {
8239
+ type: "object",
8240
+ properties: {
8241
+ project_id: { type: "string", description: "The project's UUID." },
8242
+ out_file: {
8243
+ type: "string",
8244
+ description: "Optional: absolute path, which must not exist yet, to write the export to.",
8245
+ },
8246
+ },
8247
+ required: ["project_id"],
8248
+ },
8249
+ },
8250
+ {
8251
+ name: "corpus_get",
8252
+ description:
8253
+ "READ ONE CORPUS (GET /api/v1/corpora/:id): its `mode`, `dim`, slug and project, plus " +
8254
+ "`status.has_sources`, whether anything is indexed in it yet. Per-source chunk counts " +
8255
+ "and hashes are corpus_status. Takes the corpus id or slug. `role: :agent`, on this " +
8256
+ "session's own key. 404 for a corpus that is not this tenant's. A blank `corpus_id` is " +
8257
+ "refused by the tool, sending nothing.",
8258
+ inputSchema: {
8259
+ type: "object",
8260
+ properties: {
8261
+ corpus_id: { type: "string", description: "The corpus id or slug." },
8262
+ },
8263
+ required: ["corpus_id"],
8264
+ },
8265
+ },
8266
+ {
8267
+ name: "knowledge_project_usage",
8268
+ description:
8269
+ "READ ONE PROJECT'S KNOWLEDGE-WIKI USAGE (GET /api/v1/knowledge/analytics/projects/:id/" +
8270
+ "usage): total reads, unique articles, unique callers, the access-type breakdown, the " +
8271
+ "top articles and a zero-filled daily read series. Optional `since_days` (1..365, " +
8272
+ "default 7) and `limit` on top articles (1..100, default 20). Needs an ORCHESTRATOR-role " +
8273
+ "key or above (`role: :orchestrator`), sent on LOOPCTL_ORCH_KEY (else LOOPCTL_USER_KEY) " +
8274
+ "verbatim when set, else the default key; an agent key is 403 insufficient_role. 404 " +
8275
+ "for a project that is not this tenant's. Refused by the tool, sending nothing: a " +
8276
+ "`project_id` that is not a UUID (this route does not resolve a slug and would answer " +
8277
+ "404), and a since_days or limit out of range (loopctl would clamp it silently).",
8278
+ inputSchema: {
8279
+ type: "object",
8280
+ properties: {
8281
+ project_id: { type: "string", description: "The project's UUID." },
8282
+ since_days: { type: "integer", description: "Optional: look-back window, 1..365 days." },
8283
+ limit: { type: "integer", description: "Optional: top articles to return, 1..100." },
8284
+ },
8285
+ required: ["project_id"],
8286
+ },
8287
+ },
8288
+ {
8289
+ name: "knowledge_pipeline",
8290
+ description:
8291
+ "READ THE SELF-LEARNING KNOWLEDGE PIPELINE STATUS (GET /api/v1/knowledge/pipeline): " +
8292
+ "pending extractions, the 20 most recent drafts from review findings, the publish rate " +
8293
+ "of review_finding articles, recent extraction errors, and whether automatic " +
8294
+ "extraction is enabled. Takes no parameter. Needs an ORCHESTRATOR-role key or above, " +
8295
+ "keyed as knowledge_project_usage; an agent key is 403 insufficient_role.",
8296
+ inputSchema: { type: "object", properties: {}, required: [] },
8297
+ },
8298
+ {
8299
+ name: "knowledge_link_create",
8300
+ description:
8301
+ "LINK TWO ARTICLES (POST /api/v1/article_links): `source_article_id`, " +
8302
+ "`target_article_id`, `relationship_type` (relates_to, derived_from, contradicts or " +
8303
+ "supersedes) and optional `metadata`. A supersedes link RETIRES its target (published " +
8304
+ "-> superseded, gone from every default published read), so it needs a USER-role key " +
8305
+ "and travels on LOOPCTL_USER_KEY verbatim when set (403 for an agent or orchestrator " +
8306
+ "key); every other type is `role: :agent` on this session's own key. potential_conflict " +
8307
+ "is system-generated only and is 422 here; to dispute a pair use " +
8308
+ "knowledge_assert_conflict. 404 for a target the key cannot see; 422 for a self-link or " +
8309
+ "a link that exists already. Refused by the tool, sending nothing: a non-UUID article " +
8310
+ "id, an unknown relationship_type and a metadata that is not an object.",
8311
+ inputSchema: {
8312
+ type: "object",
8313
+ properties: {
8314
+ source_article_id: { type: "string", description: "The linking article's UUID." },
8315
+ target_article_id: { type: "string", description: "The linked article's UUID." },
8316
+ relationship_type: {
8317
+ type: "string",
8318
+ enum: ["relates_to", "derived_from", "contradicts", "supersedes"],
8319
+ description: "How the source relates to the target.",
8320
+ },
8321
+ metadata: { type: "object", description: "Optional: free-form link metadata." },
8322
+ },
8323
+ required: ["source_article_id", "target_article_id", "relationship_type"],
8324
+ },
8325
+ },
8326
+ {
8327
+ name: "knowledge_link_delete",
8328
+ description:
8329
+ "DELETE AN ARTICLE LINK (DELETE /api/v1/article_links/:id); audited; answers 204. Needs " +
8330
+ "a USER-role key (`role: :user` with the hierarchy), sent on LOOPCTL_USER_KEY verbatim " +
8331
+ "when set, else the default key; an agent or orchestrator key is 403 insufficient_role. " +
8332
+ "404 for a link that is not this tenant's. Read link ids with knowledge_links. A " +
8333
+ "non-UUID `link_id` is refused by the tool, sending nothing.",
8334
+ inputSchema: {
8335
+ type: "object",
8336
+ properties: {
8337
+ link_id: { type: "string", description: "The link's UUID." },
8338
+ },
8339
+ required: ["link_id"],
8340
+ },
8341
+ },
8342
+ {
8343
+ name: "knowledge_links",
8344
+ description:
8345
+ "LIST AN ARTICLE'S LINKS (GET /api/v1/articles/:article_id/links): outgoing and " +
8346
+ "incoming, each with its id, relationship_type and the linked article, scoped to what " +
8347
+ "this key may see. `role: :agent`, on this session's own key. A non-UUID `article_id` " +
8348
+ "is refused by the tool, sending nothing.",
8349
+ inputSchema: {
8350
+ type: "object",
8351
+ properties: {
8352
+ article_id: { type: "string", description: "The article's UUID." },
8353
+ },
8354
+ required: ["article_id"],
8355
+ },
8356
+ },
7821
8357
  {
7822
8358
  name: "knowledge_consolidation",
7823
8359
  description:
@@ -7888,23 +8424,36 @@ const TOOLS = [
7888
8424
  {
7889
8425
  name: "knowledge_export",
7890
8426
  description:
7891
- "Export all knowledge articles as an OKF v0.1 bundle — gzipped tar archive, unbounded, bounded-memory streaming, " +
7892
- "fail-closed (no partial bundles). Because binary cannot be returned as MCP content, this tool returns a curl command. " +
7893
- "Optional: ?format=json for buffered in-memory JSON (capped at export_max_buffered_export_articles, 413 over cap).",
8427
+ "DOWNLOAD THE PUBLISHED KNOWLEDGE WIKI as an Obsidian-layout gzipped tar " +
8428
+ "(GET /api/v1/knowledge/export, or GET /api/v1/projects/:project_id/knowledge/export " +
8429
+ "with `project_id`, which adds that project's articles to the tenant-wide ones): one " +
8430
+ "`{category}/{slug}-{short_id}.md` per article with YAML frontmatter and [[wikilinks]], " +
8431
+ "plus a root `_index.md`. No article-count cap. The archive is binary, so it is written " +
8432
+ "to `out_file` (an absolute path that must not exist yet, created 0600 before the " +
8433
+ "request) and the result names it with its uncompressed size; extract with tar -xzf. " +
8434
+ "FAIL-CLOSED: loopctl ends a failed export without the gzip trailer and tar " +
8435
+ "end-of-archive, so the tool decompresses the saved file to the end and DELETES it, " +
8436
+ "reporting truncation, when either is missing or the download breaks off. For the OKF " +
8437
+ "interchange bundle use knowledge_okf_export. Needs a USER-role key (`role: :user` " +
8438
+ "with the hierarchy), sent on LOOPCTL_USER_KEY verbatim when set, else the default " +
8439
+ "key; an agent or orchestrator key is 403 insufficient_role. 422 for a project_id that " +
8440
+ "names no project; 429 over the concurrent-export cap. Refused by the tool, sending " +
8441
+ "nothing: a blank project_id and an out_file that is not absolute, exists already or " +
8442
+ "sits in a missing directory.",
7894
8443
  inputSchema: {
7895
8444
  type: "object",
7896
8445
  properties: {
7897
8446
  project_id: {
7898
8447
  type: "string",
7899
- description: "Optional: scope export to a specific project UUID.",
8448
+ description: "Optional: the project (UUID, slug or repo name) whose articles to add.",
7900
8449
  },
7901
- format: {
8450
+ out_file: {
7902
8451
  type: "string",
7903
- enum: ["tar.gz", "json"],
7904
- description: "Optional: tar.gz (default, unbounded streaming) or json (buffered, capped).",
8452
+ description:
8453
+ "REQUIRED. Absolute path, which must not exist yet, the .tar.gz is written to.",
7905
8454
  },
7906
8455
  },
7907
- required: [],
8456
+ required: ["out_file"],
7908
8457
  },
7909
8458
  },
7910
8459
  {
@@ -10556,6 +11105,287 @@ const TOOLS = [
10556
11105
  required: ["webhook_id"],
10557
11106
  },
10558
11107
  },
11108
+ {
11109
+ name: "skill_create",
11110
+ description:
11111
+ "CREATE A VERSIONED SKILL (POST /api/v1/skills): `name` (unique per tenant and project, " +
11112
+ "1..255 characters) and `prompt_text` (the text of version 1), optional `description`, " +
11113
+ "`project_id` (UUID, slug or repo name; omitted = tenant-wide) and `metadata`. Answers " +
11114
+ "the skill and its version 1. Needs a USER-role key (`role: :user` with the hierarchy), " +
11115
+ "sent on LOOPCTL_USER_KEY verbatim when set, else the default key; an agent or " +
11116
+ "orchestrator key is 403 insufficient_role, and an agent-rooted tenant is 403 " +
11117
+ "custody_tier_required. 422 for a name already taken, a blank prompt or a project_id that " +
11118
+ "resolves to no project; 500 audit_write_failed when the audit entry is refused (nothing is written). " +
11119
+ "Refused by the tool, sending nothing: a blank name or prompt_text, a non-string " +
11120
+ "description, a blank project_id and non-object metadata.",
11121
+ inputSchema: {
11122
+ type: "object",
11123
+ properties: {
11124
+ name: { type: "string", description: "The skill's name, e.g. \"loopctl:review\"." },
11125
+ prompt_text: { type: "string", description: "The prompt text of version 1." },
11126
+ description: { type: "string", description: "Optional: what the skill does." },
11127
+ project_id: {
11128
+ type: "string",
11129
+ description: "Optional: the project (UUID, slug or repo name); omitted = tenant-wide.",
11130
+ },
11131
+ metadata: { type: "object", description: "Optional: free-form metadata." },
11132
+ },
11133
+ required: ["name", "prompt_text"],
11134
+ },
11135
+ },
11136
+ {
11137
+ name: "skill_list",
11138
+ description:
11139
+ "LIST THE TENANT'S SKILLS (GET /api/v1/skills), ordered by name then id, with `meta` " +
11140
+ "paging. Filters `project_id` (UUID, slug or repo name), `status` (active, archived; " +
11141
+ "archived skills are listed unless filtered out) and `name` (case-insensitive " +
11142
+ "substring); `page` and `page_size` (1..100, default 20). Any key: `role: :agent`, sent " +
11143
+ "as the session's own. 422 for a project naming none. Refused by the tool, sending " +
11144
+ "nothing: a bad page or page_size (loopctl would clamp or drop it), an unknown status, " +
11145
+ "and a blank project_id or name.",
11146
+ inputSchema: {
11147
+ type: "object",
11148
+ properties: {
11149
+ project_id: { type: "string", description: "Optional project filter." },
11150
+ status: {
11151
+ type: "string",
11152
+ enum: ["active", "archived"],
11153
+ description: "Optional status filter.",
11154
+ },
11155
+ name: { type: "string", description: "Optional case-insensitive name substring." },
11156
+ page: { type: "integer", description: "Optional page number (default 1)." },
11157
+ page_size: { type: "integer", description: "Optional page size, 1..100 (default 20)." },
11158
+ },
11159
+ required: [],
11160
+ },
11161
+ },
11162
+ {
11163
+ name: "skill_get",
11164
+ description:
11165
+ "READ ONE SKILL (GET /api/v1/skills/:id) with `current_prompt`, the prompt text of its " +
11166
+ "current version. Any key: `role: :agent`, sent as the session's own. 404 for a skill " +
11167
+ "that is not this tenant's. A non-UUID `skill_id` is refused by the tool, sending " +
11168
+ "nothing.",
11169
+ inputSchema: {
11170
+ type: "object",
11171
+ properties: {
11172
+ skill_id: { type: "string", description: "The UUID of the skill." },
11173
+ },
11174
+ required: ["skill_id"],
11175
+ },
11176
+ },
11177
+ {
11178
+ name: "skill_update",
11179
+ description:
11180
+ "EDIT A SKILL'S METADATA (PATCH /api/v1/skills/:id): any of `description`, `status` " +
11181
+ "(active, archived; active un-archives) and `metadata` (replaces the map). The prompt " +
11182
+ "is NOT editable here: skill_version_create adds a version. Audited. Needs a USER-role " +
11183
+ "key, keyed as skill_create; an agent or orchestrator key is 403 insufficient_role, and " +
11184
+ "an agent-rooted tenant is 403 custody_tier_required. 404 for a skill that is not this " +
11185
+ "tenant's; 422 for an invalid status; 500 audit_write_failed when the audit entry is " +
11186
+ "refused (the update is rolled back). Refused by the tool, sending nothing: a non-UUID " +
11187
+ "`skill_id`, a call naming no field or a null field (loopctl drops nulls and would " +
11188
+ "answer 200 unchanged), an unknown status, a non-string description and non-object " +
11189
+ "metadata.",
11190
+ inputSchema: {
11191
+ type: "object",
11192
+ properties: {
11193
+ skill_id: { type: "string", description: "The UUID of the skill." },
11194
+ description: { type: "string", description: "Optional: the new description." },
11195
+ status: {
11196
+ type: "string",
11197
+ enum: ["active", "archived"],
11198
+ description: "Optional: active or archived.",
11199
+ },
11200
+ metadata: { type: "object", description: "Optional: the new metadata map." },
11201
+ },
11202
+ required: ["skill_id"],
11203
+ },
11204
+ },
11205
+ {
11206
+ name: "skill_delete",
11207
+ description:
11208
+ "ARCHIVE A SKILL (DELETE /api/v1/skills/:id): a soft delete that sets its status to " +
11209
+ "archived and answers the skill; its versions and results stay, and skill_update " +
11210
+ "with status active restores it. Audited. Needs a USER-role key, keyed as " +
11211
+ "skill_create; an agent or orchestrator key is 403 insufficient_role, and an " +
11212
+ "agent-rooted tenant is 403 custody_tier_required. 404 for a skill that is not this " +
11213
+ "tenant's; 500 audit_write_failed when the audit entry is refused. A non-UUID " +
11214
+ "`skill_id` is refused by the tool, sending nothing.",
11215
+ inputSchema: {
11216
+ type: "object",
11217
+ properties: {
11218
+ skill_id: { type: "string", description: "The UUID of the skill." },
11219
+ },
11220
+ required: ["skill_id"],
11221
+ },
11222
+ },
11223
+ {
11224
+ name: "skill_import",
11225
+ description:
11226
+ "BULK IMPORT SKILLS (POST /api/v1/skills/import): `skills`, a list of `{name, " +
11227
+ "prompt_text, description?, project_id?}`. A new name creates the skill at version 1; " +
11228
+ "an existing name gets a new version when its prompt differs (trimmed) and is left " +
11229
+ "unchanged when it does not. Answers `{total, created, updated, unchanged}`. ALL OR " +
11230
+ "NOTHING: one bad item rolls the whole import back. Each item's project_id must be a " +
11231
+ "UUID (no slug resolution here): 422 naming `skills[i]` otherwise. Needs a USER-role " +
11232
+ "key, keyed as skill_create; an agent or orchestrator key is 403 insufficient_role, and " +
11233
+ "an agent-rooted tenant is 403 custody_tier_required. 422 for a blank name or prompt; " +
11234
+ "500 audit_write_failed when the audit entry is refused. Refused by the tool, sending " +
11235
+ "nothing: an empty or non-list `skills` and an item that is not an object.",
11236
+ inputSchema: {
11237
+ type: "object",
11238
+ properties: {
11239
+ skills: {
11240
+ type: "array",
11241
+ items: { type: "object" },
11242
+ description: "The skills: each {name, prompt_text, description?, project_id? (UUID)}.",
11243
+ },
11244
+ },
11245
+ required: ["skills"],
11246
+ },
11247
+ },
11248
+ {
11249
+ name: "skill_version_create",
11250
+ description:
11251
+ "ADD A VERSION TO A SKILL (POST /api/v1/skills/:id/versions): `prompt_text` (the full " +
11252
+ "new text), optional `changelog` and `created_by` (a free-text label; defaults to the " +
11253
+ "key's actor label). The version number is the next one and becomes the skill's " +
11254
+ "current_version. Audited. Needs a USER-role key, keyed as skill_create; an agent or " +
11255
+ "orchestrator key is 403 insufficient_role, and an agent-rooted tenant is 403 " +
11256
+ "custody_tier_required. 404 for a skill that is not this tenant's; 422 for a blank " +
11257
+ "prompt; 500 audit_write_failed when the audit entry is refused. Refused by the tool, " +
11258
+ "sending nothing: a non-UUID `skill_id`, a blank prompt_text and a non-string changelog " +
11259
+ "or created_by.",
11260
+ inputSchema: {
11261
+ type: "object",
11262
+ properties: {
11263
+ skill_id: { type: "string", description: "The UUID of the skill." },
11264
+ prompt_text: { type: "string", description: "The full prompt text of the new version." },
11265
+ changelog: { type: "string", description: "Optional: what changed." },
11266
+ created_by: { type: "string", description: "Optional: who wrote it (a label)." },
11267
+ },
11268
+ required: ["skill_id", "prompt_text"],
11269
+ },
11270
+ },
11271
+ {
11272
+ name: "skill_versions",
11273
+ description:
11274
+ "LIST A SKILL'S VERSIONS (GET /api/v1/skills/:id/versions), oldest first: each with " +
11275
+ "`version`, `changelog`, `created_by` and `inserted_at` (no prompt text; " +
11276
+ "skill_version_get has it). Any key: `role: :agent`, sent as the session's own. 404 " +
11277
+ "for a skill that is not this tenant's. A non-UUID `skill_id` is refused by the tool, " +
11278
+ "sending nothing.",
11279
+ inputSchema: {
11280
+ type: "object",
11281
+ properties: {
11282
+ skill_id: { type: "string", description: "The UUID of the skill." },
11283
+ },
11284
+ required: ["skill_id"],
11285
+ },
11286
+ },
11287
+ {
11288
+ name: "skill_version_get",
11289
+ description:
11290
+ "READ ONE SKILL VERSION (GET /api/v1/skills/:id/versions/:version): its prompt text, " +
11291
+ "changelog and metadata, plus a `cost_summary` of the token usage reported against it. " +
11292
+ "Any key: `role: :agent`, sent as the session's own. 404 for a skill or version that is " +
11293
+ "not this tenant's. Refused by the tool, sending nothing: a non-UUID `skill_id` and a " +
11294
+ "`version` that is not a positive integer (loopctl parses it leniently, so \"2abc\" " +
11295
+ "would read as 2).",
11296
+ inputSchema: {
11297
+ type: "object",
11298
+ properties: {
11299
+ skill_id: { type: "string", description: "The UUID of the skill." },
11300
+ version: { type: "integer", description: "The version number (1 or more)." },
11301
+ },
11302
+ required: ["skill_id", "version"],
11303
+ },
11304
+ },
11305
+ {
11306
+ name: "skill_stats",
11307
+ description:
11308
+ "READ A SKILL'S PERFORMANCE BY VERSION (GET /api/v1/skills/:id/stats): per version, " +
11309
+ "the results recorded (skill_result_report) with pass, fail and partial counts of " +
11310
+ "their verification results, stories reviewed, and averages of the metrics " +
11311
+ "findings_count, false_positive_count and iteration. Any key: `role: :agent`, sent as " +
11312
+ "the session's own. 404 for a skill that is not this tenant's. A non-UUID `skill_id` " +
11313
+ "is refused by the tool, sending nothing.",
11314
+ inputSchema: {
11315
+ type: "object",
11316
+ properties: {
11317
+ skill_id: { type: "string", description: "The UUID of the skill." },
11318
+ },
11319
+ required: ["skill_id"],
11320
+ },
11321
+ },
11322
+ {
11323
+ name: "skill_version_results",
11324
+ description:
11325
+ "LIST THE RESULTS RECORDED FOR ONE SKILL VERSION " +
11326
+ "(GET /api/v1/skills/:id/versions/:version/results), newest first: each with " +
11327
+ "`verification_result_id`, `story_id` and `metrics`. Any key: `role: :agent`, sent as " +
11328
+ "the session's own. 404 for a skill or version that is not this tenant's. Refused by " +
11329
+ "the tool, sending nothing: a non-UUID `skill_id` and a `version` that is not a " +
11330
+ "positive integer.",
11331
+ inputSchema: {
11332
+ type: "object",
11333
+ properties: {
11334
+ skill_id: { type: "string", description: "The UUID of the skill." },
11335
+ version: { type: "integer", description: "The version number (1 or more)." },
11336
+ },
11337
+ required: ["skill_id", "version"],
11338
+ },
11339
+ },
11340
+ {
11341
+ name: "skill_cost_performance",
11342
+ description:
11343
+ "READ A SKILL'S COST PER VERSION (GET /api/v1/skills/:id/cost-performance): per " +
11344
+ "version with token usage reported against it, invocations, total and average cost " +
11345
+ "per story (millicents), verification rate, cost change against the previous version " +
11346
+ "and a `cost_regression` flag. Needs a USER-role key (`role: :user` with the " +
11347
+ "hierarchy; not human-anchored), keyed as skill_create; an agent or orchestrator key " +
11348
+ "is 403 insufficient_role. 404 for a skill that is not this tenant's. A non-UUID " +
11349
+ "`skill_id` is refused by the tool, sending nothing.",
11350
+ inputSchema: {
11351
+ type: "object",
11352
+ properties: {
11353
+ skill_id: { type: "string", description: "The UUID of the skill." },
11354
+ },
11355
+ required: ["skill_id"],
11356
+ },
11357
+ },
11358
+ {
11359
+ name: "skill_result_report",
11360
+ description:
11361
+ "RECORD A SKILL RESULT (POST /api/v1/skill_results): links a verification result to the " +
11362
+ "skill version that produced it, for skill_stats and skill_version_results. " +
11363
+ "`skill_version_id`, `verification_result_id` and `story_id` (all UUIDs, all required: " +
11364
+ "loopctl refuses a result without a verification) and optional `metrics` (an object; " +
11365
+ "skill_stats averages findings_count, false_positive_count and iteration). Audited. " +
11366
+ "Needs an ORCHESTRATOR key: `exact_role: [:orchestrator, :superadmin]`, so a user key " +
11367
+ "is 403 insufficient_role like an agent key. Sent on LOOPCTL_ORCH_KEY verbatim when " +
11368
+ "set, else LOOPCTL_API_KEY. 403 custody_tier_required on an agent-rooted tenant; 422 " +
11369
+ "for an id naming no row (a foreign-key refusal); 500 audit_write_failed when the audit entry is " +
11370
+ "refused. Refused by the tool, sending nothing: a missing or non-UUID id and " +
11371
+ "non-object metrics.",
11372
+ inputSchema: {
11373
+ type: "object",
11374
+ properties: {
11375
+ skill_version_id: { type: "string", description: "The UUID of the skill version." },
11376
+ verification_result_id: {
11377
+ type: "string",
11378
+ description: "The UUID of the verification result.",
11379
+ },
11380
+ story_id: { type: "string", description: "The UUID of the story." },
11381
+ metrics: {
11382
+ type: "object",
11383
+ description: "Optional: e.g. {findings_count, false_positive_count, iteration}.",
11384
+ },
11385
+ },
11386
+ required: ["skill_version_id", "verification_result_id", "story_id"],
11387
+ },
11388
+ },
10559
11389
  {
10560
11390
  name: "token_budget_list",
10561
11391
  description:
@@ -13876,11 +14706,62 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
13876
14706
  case "knowledge_lint":
13877
14707
  return await knowledgeLint(args);
13878
14708
 
14709
+ case "entity_list":
14710
+ return await entityListTool(args);
14711
+
14712
+ case "entity_get":
14713
+ return await entityGetTool(args);
14714
+
14715
+ case "entity_create":
14716
+ return await entityCreateTool(args);
14717
+
14718
+ case "entity_update":
14719
+ return await entityUpdateTool(args);
14720
+
14721
+ case "entity_delete":
14722
+ return await entityDeleteTool(args);
14723
+
14724
+ case "ui_test_start":
14725
+ return await uiTestStartTool(args);
14726
+
14727
+ case "ui_test_list":
14728
+ return await uiTestListTool(args);
14729
+
14730
+ case "ui_test_get":
14731
+ return await uiTestGetTool(args);
14732
+
14733
+ case "ui_test_add_finding":
14734
+ return await uiTestAddFindingTool(args);
14735
+
14736
+ case "ui_test_complete":
14737
+ return await uiTestCompleteTool(args);
14738
+
14739
+ case "project_export":
14740
+ return await projectExportTool(args);
14741
+
14742
+ case "corpus_get":
14743
+ return await corpusGetTool(args);
14744
+
14745
+ case "knowledge_project_usage":
14746
+ return await knowledgeProjectUsageTool(args);
14747
+
14748
+ case "knowledge_pipeline":
14749
+ return await knowledgePipelineTool(args);
14750
+
14751
+ case "knowledge_link_create":
14752
+ return await knowledgeLinkCreateTool(args);
14753
+
14754
+ case "knowledge_link_delete":
14755
+ return await knowledgeLinkDeleteTool(args);
14756
+
14757
+ case "knowledge_links":
14758
+ return await knowledgeLinksTool(args);
14759
+
13879
14760
  case "knowledge_consolidation":
13880
14761
  return await knowledgeConsolidation(args);
13881
14762
 
13882
14763
  case "knowledge_export":
13883
- return await knowledgeExport(args);
14764
+ return await knowledgeExportTool(args);
13884
14765
 
13885
14766
  case "knowledge_okf_export":
13886
14767
  return await knowledgeOkfExport(args);
@@ -14106,6 +14987,32 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
14106
14987
  return await webhookTestTool(args);
14107
14988
  case "webhook_deliveries":
14108
14989
  return await webhookDeliveriesTool(args);
14990
+ case "skill_create":
14991
+ return await skillCreateTool(args);
14992
+ case "skill_list":
14993
+ return await skillListTool(args);
14994
+ case "skill_get":
14995
+ return await skillGetTool(args);
14996
+ case "skill_update":
14997
+ return await skillUpdateTool(args);
14998
+ case "skill_delete":
14999
+ return await skillDeleteTool(args);
15000
+ case "skill_import":
15001
+ return await skillImportTool(args);
15002
+ case "skill_version_create":
15003
+ return await skillVersionCreateTool(args);
15004
+ case "skill_versions":
15005
+ return await skillVersionsTool(args);
15006
+ case "skill_version_get":
15007
+ return await skillVersionGetTool(args);
15008
+ case "skill_stats":
15009
+ return await skillStatsTool(args);
15010
+ case "skill_version_results":
15011
+ return await skillVersionResultsTool(args);
15012
+ case "skill_cost_performance":
15013
+ return await skillCostPerformanceTool(args);
15014
+ case "skill_result_report":
15015
+ return await skillResultReportTool(args);
14109
15016
  case "token_budget_list":
14110
15017
  return await tokenBudgetListTool(args);
14111
15018
  case "token_budget_get":