@bevel-software/platform-core-backend 0.7.5 → 0.8.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.
Files changed (230) hide show
  1. package/LICENSE +202 -202
  2. package/THIRD-PARTY-NOTICES.md +428 -454
  3. package/dist/core/core-ports.d.ts +1 -1
  4. package/dist/core/create-core-server.d.ts.map +1 -1
  5. package/dist/core/create-core-server.js +51 -7
  6. package/dist/core/create-core-server.js.map +1 -1
  7. package/dist/core/create-core-services.d.ts +5 -3
  8. package/dist/core/create-core-services.d.ts.map +1 -1
  9. package/dist/core/create-core-services.js +30 -18
  10. package/dist/core/create-core-services.js.map +1 -1
  11. package/dist/modules/access/access-control.interface.d.ts +8 -7
  12. package/dist/modules/access/access-control.interface.d.ts.map +1 -1
  13. package/dist/modules/access/access-control.service.d.ts +1 -1
  14. package/dist/modules/access/access-control.service.d.ts.map +1 -1
  15. package/dist/modules/access/access-control.service.js +6 -6
  16. package/dist/modules/access/access-control.service.js.map +1 -1
  17. package/dist/modules/access/access-declarations.d.ts +5 -5
  18. package/dist/modules/access/access-declarations.js +3 -3
  19. package/dist/modules/access/access-mutation.service.d.ts +3 -3
  20. package/dist/modules/access/access-mutation.service.d.ts.map +1 -1
  21. package/dist/modules/access/access-mutation.service.js +3 -3
  22. package/dist/modules/access/access-mutation.service.js.map +1 -1
  23. package/dist/modules/access/access-splice.js +4 -4
  24. package/dist/modules/access/access-splice.js.map +1 -1
  25. package/dist/modules/access/access.routes.js +19 -19
  26. package/dist/modules/access/access.routes.js.map +1 -1
  27. package/dist/modules/access/creator-access.d.ts +2 -2
  28. package/dist/modules/access/creator-access.js +5 -5
  29. package/dist/modules/access/creator-access.js.map +1 -1
  30. package/dist/modules/access/roles-admin.service.d.ts +18 -4
  31. package/dist/modules/access/roles-admin.service.d.ts.map +1 -1
  32. package/dist/modules/access/roles-admin.service.js +14 -4
  33. package/dist/modules/access/roles-admin.service.js.map +1 -1
  34. package/dist/modules/code-mode/code-mode-names.d.ts +5 -13
  35. package/dist/modules/code-mode/code-mode-names.d.ts.map +1 -1
  36. package/dist/modules/code-mode/code-mode-names.js +5 -27
  37. package/dist/modules/code-mode/code-mode-names.js.map +1 -1
  38. package/dist/modules/code-mode/code-mode.tool.d.ts.map +1 -1
  39. package/dist/modules/code-mode/code-mode.tool.js +29 -7
  40. package/dist/modules/code-mode/code-mode.tool.js.map +1 -1
  41. package/dist/modules/mcp/mcp.service.d.ts +11 -52
  42. package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
  43. package/dist/modules/mcp/mcp.service.js +33 -395
  44. package/dist/modules/mcp/mcp.service.js.map +1 -1
  45. package/dist/modules/plugins/index.d.ts +7 -0
  46. package/dist/modules/plugins/index.d.ts.map +1 -0
  47. package/dist/modules/plugins/index.js +6 -0
  48. package/dist/modules/plugins/index.js.map +1 -0
  49. package/dist/modules/plugins/join-proposals.d.ts +53 -0
  50. package/dist/modules/plugins/join-proposals.d.ts.map +1 -0
  51. package/dist/modules/plugins/join-proposals.js +67 -0
  52. package/dist/modules/plugins/join-proposals.js.map +1 -0
  53. package/dist/modules/plugins/join-requests.service.d.ts +81 -0
  54. package/dist/modules/plugins/join-requests.service.d.ts.map +1 -0
  55. package/dist/modules/plugins/join-requests.service.js +135 -0
  56. package/dist/modules/plugins/join-requests.service.js.map +1 -0
  57. package/dist/modules/plugins/plugin-provision.service.d.ts +134 -0
  58. package/dist/modules/plugins/plugin-provision.service.d.ts.map +1 -0
  59. package/dist/modules/plugins/plugin-provision.service.js +344 -0
  60. package/dist/modules/plugins/plugin-provision.service.js.map +1 -0
  61. package/dist/modules/plugins/plugins.contract.d.ts +106 -0
  62. package/dist/modules/plugins/plugins.contract.d.ts.map +1 -0
  63. package/dist/modules/plugins/plugins.contract.js +36 -0
  64. package/dist/modules/plugins/plugins.contract.js.map +1 -0
  65. package/dist/modules/plugins/plugins.routes.d.ts +42 -0
  66. package/dist/modules/plugins/plugins.routes.d.ts.map +1 -0
  67. package/dist/modules/plugins/plugins.routes.js +379 -0
  68. package/dist/modules/plugins/plugins.routes.js.map +1 -0
  69. package/dist/modules/plugins/plugins.service.d.ts +60 -0
  70. package/dist/modules/plugins/plugins.service.d.ts.map +1 -0
  71. package/dist/modules/plugins/plugins.service.js +172 -0
  72. package/dist/modules/plugins/plugins.service.js.map +1 -0
  73. package/dist/modules/skills/pending-skills.service.d.ts +2 -2
  74. package/dist/modules/skills/pending-skills.service.js +7 -7
  75. package/dist/modules/skills/pending-skills.service.js.map +1 -1
  76. package/dist/modules/skills/skills.contract.d.ts +4 -4
  77. package/dist/modules/skills/skills.contract.d.ts.map +1 -1
  78. package/dist/modules/skills/skills.contract.js +1 -1
  79. package/dist/modules/skills/skills.service.js +5 -5
  80. package/dist/modules/skills/skills.service.js.map +1 -1
  81. package/dist/modules/tool-manuals/mcp-json-discovery.d.ts +65 -0
  82. package/dist/modules/tool-manuals/mcp-json-discovery.d.ts.map +1 -0
  83. package/dist/modules/tool-manuals/mcp-json-discovery.js +276 -0
  84. package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -0
  85. package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts +92 -0
  86. package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts.map +1 -0
  87. package/dist/modules/tool-manuals/mcp-server-edit.service.js +328 -0
  88. package/dist/modules/tool-manuals/mcp-server-edit.service.js.map +1 -0
  89. package/dist/modules/tool-manuals/tool-manuals.contract.d.ts +38 -12
  90. package/dist/modules/tool-manuals/tool-manuals.contract.d.ts.map +1 -1
  91. package/dist/modules/tool-manuals/tool-manuals.contract.js +1 -1
  92. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts +13 -2
  93. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts.map +1 -1
  94. package/dist/modules/tool-manuals/tool-manuals.routes.js +233 -2
  95. package/dist/modules/tool-manuals/tool-manuals.routes.js.map +1 -1
  96. package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
  97. package/dist/modules/tool-manuals/tool-manuals.service.js +74 -37
  98. package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
  99. package/dist/modules/tool-manuals/tool-manuals.tools.js +6 -3
  100. package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
  101. package/dist/modules/workflow/git/git.service.js +2 -2
  102. package/dist/modules/workflow/git/git.service.js.map +1 -1
  103. package/dist/modules/workspace/kb-seed.service.d.ts +2 -2
  104. package/dist/modules/workspace/kb-seed.service.d.ts.map +1 -1
  105. package/dist/modules/workspace/kb-seed.service.js +43 -10
  106. package/dist/modules/workspace/kb-seed.service.js.map +1 -1
  107. package/dist/modules/workspace/plugins-migration.d.ts +50 -0
  108. package/dist/modules/workspace/plugins-migration.d.ts.map +1 -0
  109. package/dist/modules/workspace/plugins-migration.js +379 -0
  110. package/dist/modules/workspace/plugins-migration.js.map +1 -0
  111. package/dist/modules/workspace/workspace.routes.js +3 -3
  112. package/dist/modules/workspace/workspace.routes.js.map +1 -1
  113. package/dist/modules/workspace/workspace.service.d.ts +26 -0
  114. package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
  115. package/dist/modules/workspace/workspace.service.js +83 -12
  116. package/dist/modules/workspace/workspace.service.js.map +1 -1
  117. package/dist/shared/kb-layout.test.js +3 -3
  118. package/dist/shared/kb-layout.test.js.map +1 -1
  119. package/dist/shared/utcp-namespace.d.ts +6 -27
  120. package/dist/shared/utcp-namespace.d.ts.map +1 -1
  121. package/dist/shared/utcp-namespace.js +6 -63
  122. package/dist/shared/utcp-namespace.js.map +1 -1
  123. package/dist/shared/variable-refs.d.ts +42 -0
  124. package/dist/shared/variable-refs.d.ts.map +1 -0
  125. package/dist/shared/variable-refs.js +60 -0
  126. package/dist/shared/variable-refs.js.map +1 -0
  127. package/kb-template/.bevelignore +1 -1
  128. package/kb-template/AGENTS.md +88 -35
  129. package/kb-template/KnowledgeBase/How to get started.md +10 -10
  130. package/kb-template/access.md +36 -36
  131. package/migrations/meta/0000_snapshot.json +1479 -1479
  132. package/package.json +5 -4
  133. package/src/assets.ts +25 -25
  134. package/src/core/core-ports.ts +106 -106
  135. package/src/core/create-core-server.ts +55 -9
  136. package/src/core/create-core-services.ts +40 -20
  137. package/src/index.ts +69 -69
  138. package/src/modules/access/__tests__/access-control.atref-batch.test.ts +98 -98
  139. package/src/modules/access/__tests__/access-declarations.test.ts +28 -28
  140. package/src/modules/access/__tests__/access-md-format.test.ts +18 -18
  141. package/src/modules/access/__tests__/access-mutation.service.test.ts +5 -5
  142. package/src/modules/access/__tests__/access-splice.test.ts +2 -2
  143. package/src/modules/access/__tests__/access.routes.overrides.test.ts +16 -16
  144. package/src/modules/access/__tests__/grant-sources.test.ts +12 -12
  145. package/src/modules/access/__tests__/roles-admin.service.test.ts +13 -1
  146. package/src/modules/access/access-control.interface.ts +8 -7
  147. package/src/modules/access/access-control.service.ts +7 -7
  148. package/src/modules/access/access-declarations.ts +5 -5
  149. package/src/modules/access/access-mutation.service.ts +3 -3
  150. package/src/modules/access/access-splice.ts +4 -4
  151. package/src/modules/access/access.routes.ts +20 -20
  152. package/src/modules/access/creator-access.ts +5 -5
  153. package/src/modules/access/roles-admin.service.ts +13 -2
  154. package/src/modules/admin/admin-access.routes.ts +29 -29
  155. package/src/modules/auth/__tests__/auth.routes.test.ts +91 -91
  156. package/src/modules/auth/__tests__/rate-limit.test.ts +36 -36
  157. package/src/modules/auth/rate-limit.ts +45 -45
  158. package/src/modules/code-mode/__tests__/code-mode.tool.test.ts +67 -0
  159. package/src/modules/code-mode/code-mode-names.ts +10 -36
  160. package/src/modules/code-mode/code-mode.tool.ts +27 -7
  161. package/src/modules/database/connection.ts +15 -15
  162. package/src/modules/database/schema.ts +11 -11
  163. package/src/modules/diff/__tests__/diff.routes.rejectPathsLocked.test.ts +150 -150
  164. package/src/modules/mcp/mcp.service.ts +57 -435
  165. package/src/modules/{groups → plugins}/__tests__/join-proposals.test.ts +1 -1
  166. package/src/modules/{groups → plugins}/__tests__/join-requests.service.test.ts +7 -7
  167. package/src/modules/{groups/__tests__/group-index.service.test.ts → plugins/__tests__/plugin-index.service.test.ts} +41 -41
  168. package/src/modules/plugins/__tests__/plugin-provision.service.test.ts +312 -0
  169. package/src/modules/{groups/__tests__/groups.routes.test.ts → plugins/__tests__/plugins.routes.test.ts} +100 -100
  170. package/src/modules/plugins/index.ts +17 -0
  171. package/src/modules/{groups → plugins}/join-proposals.ts +2 -2
  172. package/src/modules/{groups → plugins}/join-requests.service.ts +8 -8
  173. package/src/modules/{groups/group-provision.service.ts → plugins/plugin-provision.service.ts} +139 -69
  174. package/src/modules/{groups/groups.contract.ts → plugins/plugins.contract.ts} +26 -26
  175. package/src/modules/{groups/groups.routes.ts → plugins/plugins.routes.ts} +102 -102
  176. package/src/modules/{groups/groups.service.ts → plugins/plugins.service.ts} +43 -43
  177. package/src/modules/secrets-vault/__tests__/tool-owner-gate.route.test.ts +143 -143
  178. package/src/modules/skills/__tests__/pending-skills.service.test.ts +14 -14
  179. package/src/modules/skills/__tests__/skills.service.test.ts +13 -13
  180. package/src/modules/skills/pending-skills.service.ts +7 -7
  181. package/src/modules/skills/skills.contract.ts +4 -4
  182. package/src/modules/skills/skills.service.ts +5 -5
  183. package/src/modules/tool-auth/llm-usage-meter.ts +19 -19
  184. package/src/modules/tool-manuals/__tests__/mcp-json-discovery.test.ts +198 -0
  185. package/src/modules/tool-manuals/__tests__/mcp-server-edit.service.test.ts +346 -0
  186. package/src/modules/tool-manuals/__tests__/tool-manuals.archive.route.test.ts +101 -0
  187. package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +3 -3
  188. package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +2 -2
  189. package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +27 -27
  190. package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +3 -3
  191. package/src/modules/tool-manuals/mcp-json-discovery.ts +328 -0
  192. package/src/modules/tool-manuals/mcp-server-edit.service.ts +434 -0
  193. package/src/modules/tool-manuals/tool-manuals.contract.ts +35 -12
  194. package/src/modules/tool-manuals/tool-manuals.routes.ts +222 -1
  195. package/src/modules/tool-manuals/tool-manuals.service.ts +82 -42
  196. package/src/modules/tool-manuals/tool-manuals.tools.ts +6 -3
  197. package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +1 -1
  198. package/src/modules/workflow/git/__tests__/branch-name.test.ts +3 -3
  199. package/src/modules/workflow/git/__tests__/git.service.accessGating.test.ts +3 -3
  200. package/src/modules/workflow/git/__tests__/git.service.commitFile.test.ts +13 -8
  201. package/src/modules/workflow/git/__tests__/git.service.deleteBranch.test.ts +1 -1
  202. package/src/modules/workflow/git/__tests__/pull-request.service.test.ts +1 -1
  203. package/src/modules/workflow/git/git.service.ts +2 -2
  204. package/src/modules/workflow/review-workflow/__tests__/approval-states.test.ts +1 -1
  205. package/src/modules/workflow/review-workflow/__tests__/cancel-pr.test.ts +1 -1
  206. package/src/modules/workflow/workflow-hooks.ts +101 -101
  207. package/src/modules/workspace/__tests__/kb-seed.service.test.ts +81 -13
  208. package/src/modules/workspace/__tests__/plugins-migration.test.ts +427 -0
  209. package/src/modules/workspace/__tests__/session-ontology.gate.test.ts +237 -237
  210. package/src/modules/workspace/__tests__/workspace.routes.create-grant.test.ts +236 -236
  211. package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +179 -179
  212. package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +320 -320
  213. package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +337 -337
  214. package/src/modules/workspace/__tests__/workspace.service.test.ts +116 -0
  215. package/src/modules/workspace/bevel-ignore.ts +66 -66
  216. package/src/modules/workspace/kb-seed.service.ts +38 -9
  217. package/src/modules/workspace/plugins-migration.ts +479 -0
  218. package/src/modules/workspace/session-sink.ts +25 -25
  219. package/src/modules/workspace/workspace.routes.ts +3 -3
  220. package/src/modules/workspace/workspace.service.ts +85 -14
  221. package/src/modules/workspace/workspace.tools.ts +922 -922
  222. package/src/shared/__tests__/join-request.test.ts +13 -13
  223. package/src/shared/__tests__/kb-layout.plugin.test.ts +45 -0
  224. package/src/shared/kb-layout.test.ts +3 -3
  225. package/src/shared/utcp-namespace.ts +10 -68
  226. package/src/shared/variable-refs.ts +64 -0
  227. package/src/modules/groups/__tests__/group-provision.service.test.ts +0 -247
  228. package/src/modules/groups/index.ts +0 -17
  229. package/src/shared/__tests__/kb-layout.group.test.ts +0 -45
  230. /package/kb-template/{Groups → Plugins}/.gitkeep +0 -0
@@ -0,0 +1,92 @@
1
+ import { type AuthUser } from '@bevel-software/platform-shared';
2
+ import { type WorkspaceService } from '../workspace/workspace.service.js';
3
+ import type { IAccessControl } from '../access/access-control.interface.js';
4
+ import type { IToolManualService, ToolVariable } from './tool-manuals.contract.js';
5
+ /**
6
+ * Server-scoped editing of one MCP server — the form the tool page uses
7
+ * instead of dropping a writer into raw `mcp.json`.
8
+ *
9
+ * One server's truth spans TWO files (the spec's split, not ours): the
10
+ * portable half in `mcp.json` (transport, url, literal headers) and our half
11
+ * in `plugin.json`'s `extensions["software.bevel.hexis"].mcpServers[<name>]`
12
+ * (auth headers carrying `${VAR}` vault references, variable declarations,
13
+ * description, `local`). This service is the ONE writer that keeps the two in
14
+ * step: a save rewrites both entries and commits them together, because a
15
+ * server whose auth landed without its url — or the reverse — is a broken
16
+ * tool with no author to blame.
17
+ *
18
+ * RENAME IS DESTRUCTIVE BY DESIGN and the route says so: the `mcpServers` key
19
+ * is the namespace vault secrets bind to (`<name>_<VAR>`), so renaming a
20
+ * server orphans every configured secret and completed sign-in under the old
21
+ * key. The frontend counts what disconnects (it already holds per-variable
22
+ * status) and confirms; this service just refuses a rename onto a taken key.
23
+ */
24
+ export type McpTransport = 'streamable-http' | 'sse' | 'stdio';
25
+ export interface McpServerView {
26
+ name: string;
27
+ transport: McpTransport;
28
+ url?: string;
29
+ command?: string;
30
+ args?: string[];
31
+ cwd?: string;
32
+ env?: Record<string, string>;
33
+ /** Portable headers, stored in mcp.json. Never carry a `${VAR}`. */
34
+ literalHeaders: Record<string, string>;
35
+ /** Auth headers with vault references, stored in the extensions block. */
36
+ authHeaders: Record<string, string>;
37
+ variables: ToolVariable[];
38
+ description?: string;
39
+ local: boolean;
40
+ canWrite: boolean;
41
+ }
42
+ /**
43
+ * PATCH semantics, field by field: `undefined` means "the client did not
44
+ * surface this field" and the stored value survives; a present-but-empty
45
+ * value (`{}`, `[]`, `''`) is an explicit clear. A full-replace contract
46
+ * would make every client responsible for echoing back fields it does not
47
+ * edit — and the one that forgot would silently destroy the literal headers
48
+ * in mcp.json or the variable declarations behind `${VAR}` references.
49
+ */
50
+ export interface McpServerWrite {
51
+ newName?: string;
52
+ transport: McpTransport;
53
+ url?: string;
54
+ command?: string;
55
+ args?: string[];
56
+ cwd?: string;
57
+ env?: Record<string, string>;
58
+ literalHeaders?: Record<string, string>;
59
+ authHeaders?: Record<string, string>;
60
+ variables?: ToolVariable[];
61
+ description?: string;
62
+ local?: boolean;
63
+ }
64
+ export declare class McpServerEditError extends Error {
65
+ readonly status: number;
66
+ constructor(message: string, status: number);
67
+ }
68
+ interface CommitDriver {
69
+ runPendingCommit(workspaceId: string, branch: string, targetPath: string, user: AuthUser, opts?: {
70
+ systemAuthorized?: boolean;
71
+ }): Promise<void>;
72
+ }
73
+ export declare class McpServerEditService {
74
+ private readonly workspaceService;
75
+ private readonly commits;
76
+ private readonly accessControl;
77
+ private readonly toolManuals;
78
+ private readonly kbDirName;
79
+ constructor(workspaceService: WorkspaceService, commits: CommitDriver, accessControl: IAccessControl, toolManuals: IToolManualService, kbDirName: string);
80
+ /** The merged view of one server, or null when unknown/unreadable (indistinguishable, fail closed). */
81
+ getServer(userEmail: string, slug: string): Promise<McpServerView | null>;
82
+ /** Rewrite one server across both files, in one commit. Returns the (possibly new) name. */
83
+ putServer(user: AuthUser, slug: string, write: McpServerWrite): Promise<{
84
+ name: string;
85
+ }>;
86
+ /** Resolve a slug to an mcp.json-backed server the caller can READ; null otherwise. */
87
+ private locate;
88
+ private readFiles;
89
+ private extensionEntry;
90
+ }
91
+ export {};
92
+ //# sourceMappingURL=mcp-server-edit.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server-edit.service.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-manuals/mcp-server-edit.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAIhG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAEnF;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,KAAK,GAAG,OAAO,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,YAAY,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;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AAS,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IA6B/E,4FAA4F;IACtF,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAwN/F,uFAAuF;YACzE,MAAM;YAkBN,SAAS;IAoBvB,OAAO,CAAC,cAAc;CAMvB"}
@@ -0,0 +1,328 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { DEFAULT_BRANCH, HEXIS_EXTENSION_NS, PLUGINS_DIR, PLUGIN_MANIFEST_FILE, PLUGIN_MCP_FILE, } from '@bevel-software/platform-shared';
4
+ import { workspaceIdForBranch } from '../workspace/workspace.service.js';
5
+ import { validatedVariables } from './mcp-json-discovery.js';
6
+ import { assertSafeFetchUrl } from '../../shared/ssrf.js';
7
+ import { containsVariableReference, findReservedVariableRef } from '../../shared/variable-refs.js';
8
+ export class McpServerEditError extends Error {
9
+ status;
10
+ constructor(message, status) {
11
+ super(message);
12
+ this.status = status;
13
+ this.name = 'McpServerEditError';
14
+ }
15
+ }
16
+ /** Same shape the discovery accepts: the key is a namespace, not prose. */
17
+ const SERVER_NAME_RE = /^[a-z0-9][a-z0-9_-]*$/;
18
+ // The substitutor's own grammar (shared/variable-refs.ts) decides what is a
19
+ // reference: `${A-B}` is not (stays a literal header), `$5` is (digit-leading
20
+ // names are legal). The migration's header split applies the same predicate.
21
+ const hasVarRef = containsVariableReference;
22
+ function isRecord(v) {
23
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
24
+ }
25
+ /**
26
+ * The same reserved-reference policy discovery enforces, applied at SAVE: a
27
+ * `${…API_URL}`/`${…CONNECTION_KEY}` persisted here would make discovery drop
28
+ * the server on its next scan — an editor that can save self-invalidating
29
+ * config is worse than a 422 naming the reference. The same shared grammar
30
+ * both sides scan with is what makes "saveable" and "discoverable" agree.
31
+ */
32
+ const findReservedRef = findReservedVariableRef;
33
+ export class McpServerEditService {
34
+ workspaceService;
35
+ commits;
36
+ accessControl;
37
+ toolManuals;
38
+ kbDirName;
39
+ constructor(workspaceService, commits, accessControl, toolManuals, kbDirName) {
40
+ this.workspaceService = workspaceService;
41
+ this.commits = commits;
42
+ this.accessControl = accessControl;
43
+ this.toolManuals = toolManuals;
44
+ this.kbDirName = kbDirName;
45
+ }
46
+ /** The merged view of one server, or null when unknown/unreadable (indistinguishable, fail closed). */
47
+ async getServer(userEmail, slug) {
48
+ const located = await this.locate(userEmail, slug);
49
+ if (!located)
50
+ return null;
51
+ const { folder, name, wsId, mcpJsonPath } = located;
52
+ const { mcp, manifest } = await this.readFiles(folder);
53
+ const entry = mcp?.mcpServers?.[name];
54
+ if (!entry || typeof entry !== 'object')
55
+ return null;
56
+ const raw = entry;
57
+ const ext = this.extensionEntry(manifest, name);
58
+ return {
59
+ name,
60
+ transport: raw.type ?? 'streamable-http',
61
+ ...(typeof raw.url === 'string' ? { url: raw.url } : {}),
62
+ ...(typeof raw.command === 'string' ? { command: raw.command } : {}),
63
+ ...(Array.isArray(raw.args) ? { args: raw.args.map(String) } : {}),
64
+ ...(typeof raw.cwd === 'string' ? { cwd: raw.cwd } : {}),
65
+ ...(raw.env && typeof raw.env === 'object' ? { env: raw.env } : {}),
66
+ // Shape-checked, not merely null-coalesced: both files are hand-editable
67
+ // knowledge-base content, and a string where an object/array belongs
68
+ // would flow into the form's Object.entries/`.map` as nonsense.
69
+ literalHeaders: isRecord(raw.headers) ? raw.headers : {},
70
+ authHeaders: isRecord(ext.headers) ? ext.headers : {},
71
+ variables: Array.isArray(ext.variables) ? ext.variables : [],
72
+ ...(typeof ext.description === 'string' ? { description: ext.description } : {}),
73
+ local: ext.local === true || raw.type === 'stdio',
74
+ canWrite: await this.accessControl.canWrite(wsId, userEmail, mcpJsonPath),
75
+ };
76
+ }
77
+ /** Rewrite one server across both files, in one commit. Returns the (possibly new) name. */
78
+ async putServer(user, slug, write) {
79
+ const located = await this.locate(user.email, slug);
80
+ if (!located)
81
+ throw new McpServerEditError('No such tool.', 404);
82
+ const { folder, name, wsId, mcpJsonPath } = located;
83
+ if (!(await this.accessControl.canWrite(wsId, user.email, mcpJsonPath))) {
84
+ throw new McpServerEditError("You don't have permission to edit this plugin's servers.", 403);
85
+ }
86
+ const { mcp, manifest, mcpAbs, manifestAbs } = await this.readFiles(folder);
87
+ if (!mcp?.mcpServers || typeof mcp.mcpServers !== 'object') {
88
+ throw new McpServerEditError(`${PLUGIN_MCP_FILE} is missing or unparsable — fix the file first.`, 422);
89
+ }
90
+ const servers = mcp.mcpServers;
91
+ if (!(name in servers))
92
+ throw new McpServerEditError('No such server.', 404);
93
+ if (write.transport !== 'streamable-http' && write.transport !== 'sse' && write.transport !== 'stdio') {
94
+ // Persisting an unknown transport would save an entry discovery then
95
+ // refuses — an unusable server with no error at the moment it was made.
96
+ throw new McpServerEditError(`Unknown transport "${String(write.transport)}".`, 422);
97
+ }
98
+ // The EFFECTIVE value of every field, PATCH-over-stored (see
99
+ // McpServerWrite): `undefined` keeps what the files already say, a
100
+ // present value — empty included — replaces it.
101
+ const prior = isRecord(servers[name]) ? servers[name] : {};
102
+ const priorExt = this.extensionEntry(manifest, name);
103
+ const url = write.url ?? (typeof prior.url === 'string' ? prior.url : undefined);
104
+ const command = write.command ?? (typeof prior.command === 'string' ? prior.command : undefined);
105
+ const args = write.args ?? (Array.isArray(prior.args) ? prior.args.map(String) : undefined);
106
+ const env = write.env ?? (isRecord(prior.env) ? prior.env : undefined);
107
+ const cwd = write.cwd ?? (typeof prior.cwd === 'string' ? prior.cwd : undefined);
108
+ const literalIn = write.literalHeaders ?? (isRecord(prior.headers) ? prior.headers : {});
109
+ const authIn = write.authHeaders ?? (isRecord(priorExt.headers) ? priorExt.headers : {});
110
+ // RAW on the stored side, no shape fallback: coercing malformed stored
111
+ // declarations to [] here would let a save that never touched variables
112
+ // silently CLEAR them — the validator below owes that case a 422, same
113
+ // as any other malformed input.
114
+ const variablesIn = write.variables ?? priorExt.variables;
115
+ // Discovery's OWN validator, at save time (like the reserved-ref check
116
+ // below): a malformed declaration — bad name, duplicate, re-declared
117
+ // platform name, oauth on a shared scope or with a broken provider —
118
+ // persisted here would make discovery drop the whole server on its next
119
+ // scan. What comes back is the normalized form discovery would read, and
120
+ // that is what gets stored.
121
+ const variables = validatedVariables(variablesIn);
122
+ if (variables === null) {
123
+ throw new McpServerEditError('The `variables` declaration is malformed — each entry needs a unique, non-reserved ' +
124
+ 'alphanumeric/underscore name, a scope of `admin` or `user`, and any `oauth` block must sit ' +
125
+ 'on a `user`-scoped variable with valid https provider URLs and a client id.', 422);
126
+ }
127
+ const description = write.description ?? (typeof priorExt.description === 'string' ? priorExt.description : undefined);
128
+ const local = write.local ?? (priorExt.local === true);
129
+ // The WHOLE writable surface, mirroring what discovery scans — effective
130
+ // values, not just the incoming patch: a reserved ref smuggled through a
131
+ // stdio arg (`--url=${X_API_URL}`), env value, cwd or description would
132
+ // save with a 200 and then vanish from the catalog on the next scan —
133
+ // the exact self-invalidating state this 422 prevents.
134
+ const reservedRef = findReservedRef({
135
+ url,
136
+ command,
137
+ args,
138
+ env,
139
+ cwd,
140
+ description,
141
+ literalHeaders: literalIn,
142
+ authHeaders: authIn,
143
+ variables,
144
+ });
145
+ if (reservedRef !== null) {
146
+ throw new McpServerEditError(`"${reservedRef}" references a platform-seeded variable (API_URL / CONNECTION_KEY) — ` +
147
+ 'discovery refuses servers that name them, so this cannot be saved.', 422);
148
+ }
149
+ const target = write.newName?.trim() || name;
150
+ if (!SERVER_NAME_RE.test(target)) {
151
+ throw new McpServerEditError('A server name is its secret namespace: lowercase alphanumeric with `_`/`-`.', 422);
152
+ }
153
+ if (target !== name && target in servers) {
154
+ throw new McpServerEditError(`A server named "${target}" already exists here.`, 409);
155
+ }
156
+ // Defense in depth on the portable file: a `${VAR}` in mcp.json would be
157
+ // transmitted literally by a conformant client AND violate the spec's
158
+ // no-credentials rule — reroute it to the extensions block instead of
159
+ // trusting the frontend's split.
160
+ const literal = {};
161
+ const auth = { ...authIn };
162
+ for (const [k, v] of Object.entries(literalIn)) {
163
+ if (hasVarRef(v))
164
+ auth[k] = v;
165
+ else
166
+ literal[k] = v;
167
+ }
168
+ let entry;
169
+ if (write.transport === 'stdio') {
170
+ const cmd = command?.trim();
171
+ if (!cmd)
172
+ throw new McpServerEditError('A stdio server needs a command.', 422);
173
+ entry = {
174
+ type: 'stdio',
175
+ command: cmd,
176
+ ...(args && args.length > 0 ? { args } : {}),
177
+ ...(env && Object.keys(env).length > 0 ? { env } : {}),
178
+ ...(cwd ? { cwd } : {}),
179
+ };
180
+ }
181
+ else {
182
+ let parsed;
183
+ try {
184
+ parsed = new URL(url ?? '');
185
+ }
186
+ catch {
187
+ throw new McpServerEditError('The server needs a valid http(s) URL.', 422);
188
+ }
189
+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
190
+ throw new McpServerEditError('The server needs a valid http(s) URL.', 422);
191
+ }
192
+ // The same SSRF gate discovery applies on read: without it here, a save
193
+ // succeeds and the server then silently disappears from the catalog —
194
+ // an edit flow that eats its own output. Local-only servers are exempt;
195
+ // loopback is what local means.
196
+ if (local !== true) {
197
+ try {
198
+ assertSafeFetchUrl(url ?? '', { label: 'Server URL' });
199
+ }
200
+ catch (err) {
201
+ throw new McpServerEditError(`${err instanceof Error ? err.message : 'The URL is not reachable from the workspace'} — ` +
202
+ 'mark the server local-only if it is deliberately private.', 422);
203
+ }
204
+ }
205
+ entry = {
206
+ type: write.transport,
207
+ url,
208
+ ...(Object.keys(literal).length > 0 ? { headers: literal } : {}),
209
+ };
210
+ }
211
+ if (target !== name)
212
+ delete servers[name];
213
+ servers[target] = entry;
214
+ // The extensions half: rewrite our entry, drop the old key on rename.
215
+ // A missing/unparsable manifest refuses the save when there is auth to
216
+ // store — silently dropping a credential mapping is worse than an error.
217
+ const extEntry = {
218
+ ...(Object.keys(auth).length > 0 ? { headers: auth } : {}),
219
+ ...(variables.length > 0 ? { variables } : {}),
220
+ ...(description ? { description } : {}),
221
+ ...(local === true && write.transport !== 'stdio' ? { local: true } : {}),
222
+ };
223
+ if (manifest === null && Object.keys(extEntry).length > 0) {
224
+ throw new McpServerEditError(`${PLUGIN_MANIFEST_FILE} is missing or unparsable — fix the file first.`, 422);
225
+ }
226
+ if (manifest !== null) {
227
+ // A wrong-TYPED extensions chain (a string, an array) would throw a
228
+ // TypeError below and surface as a 500. It is also not ours to silently
229
+ // replace: an array `extensions` may be another tool's data, malformed
230
+ // or not, and a save aimed at one server should not discard it.
231
+ const badShape = (v) => v !== undefined && (typeof v !== 'object' || v === null || Array.isArray(v));
232
+ const ext = (manifest.extensions ??= {});
233
+ if (badShape(manifest.extensions)) {
234
+ throw new McpServerEditError(`${PLUGIN_MANIFEST_FILE} has a malformed \`extensions\` block — fix the file first.`, 422);
235
+ }
236
+ if (badShape(ext[HEXIS_EXTENSION_NS]) || badShape(ext[HEXIS_EXTENSION_NS]?.mcpServers)) {
237
+ throw new McpServerEditError(`${PLUGIN_MANIFEST_FILE} has a malformed \`extensions\` block — fix the file first.`, 422);
238
+ }
239
+ const ns = (ext[HEXIS_EXTENSION_NS] ??= {});
240
+ const extServers = (ns.mcpServers ??= {});
241
+ delete extServers[name];
242
+ if (Object.keys(extEntry).length > 0)
243
+ extServers[target] = extEntry;
244
+ }
245
+ // All-or-nothing for real: snapshot both files first, and on ANY failure
246
+ // past the first write put the originals back — the API reporting failure
247
+ // while the workspace keeps half the edit is the state this exists to
248
+ // prevent.
249
+ // Rollback scope is the WRITES only. A failed write restores both files
250
+ // (a half-written pair is the state this exists to prevent); a failed
251
+ // COMMIT must not — the pending-commit pipeline may already have created
252
+ // a local commit before the push refused, and rewriting the working tree
253
+ // to pre-edit bytes would leave it dirty AGAINST that commit, a state the
254
+ // workflow layer's own pull-rebase recovery then misreads. Commit-stage
255
+ // failures propagate as-is and the pipeline's recovery owns the cleanup.
256
+ const [mcpBefore, manifestBefore] = await Promise.all([
257
+ fs.readFile(mcpAbs, 'utf8').catch(() => null),
258
+ fs.readFile(manifestAbs, 'utf8').catch(() => null),
259
+ ]);
260
+ try {
261
+ await fs.writeFile(mcpAbs, `${JSON.stringify(mcp, null, 2)}\n`, 'utf8');
262
+ if (manifest !== null) {
263
+ await fs.writeFile(manifestAbs, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8');
264
+ }
265
+ }
266
+ catch (err) {
267
+ if (mcpBefore !== null)
268
+ await fs.writeFile(mcpAbs, mcpBefore, 'utf8').catch(() => { });
269
+ if (manifestBefore !== null)
270
+ await fs.writeFile(manifestAbs, manifestBefore, 'utf8').catch(() => { });
271
+ throw err;
272
+ }
273
+ // One folder-scoped commit, ungated beyond the caller's own write access —
274
+ // both files or neither. The catalog cache is stale the moment it lands.
275
+ await this.commits.runPendingCommit(workspaceIdForBranch(DEFAULT_BRANCH), DEFAULT_BRANCH, `${this.kbDirName}/${PLUGINS_DIR}/${folder}`, user);
276
+ this.toolManuals.invalidate();
277
+ return { name: target };
278
+ }
279
+ /** Resolve a slug to an mcp.json-backed server the caller can READ; null otherwise. */
280
+ async locate(userEmail, slug) {
281
+ const summaries = await this.toolManuals.listAccessible(userEmail);
282
+ const found = summaries.find((s) => s.slug === slug);
283
+ if (!found || found.type !== 'mcp' || !found.path.endsWith(`/${PLUGIN_MCP_FILE}`))
284
+ return null;
285
+ const segments = found.path.split('/');
286
+ const folder = segments[1];
287
+ if (!folder)
288
+ return null;
289
+ return {
290
+ folder,
291
+ name: found.name,
292
+ wsId: workspaceIdForBranch(DEFAULT_BRANCH),
293
+ mcpJsonPath: found.path,
294
+ };
295
+ }
296
+ async readFiles(folder) {
297
+ const wsId = workspaceIdForBranch(DEFAULT_BRANCH);
298
+ await this.workspaceService.getOrCreateForBranch(DEFAULT_BRANCH);
299
+ const wsDir = await this.workspaceService.getWorkspacePath(wsId);
300
+ const pluginDir = path.join(wsDir, this.kbDirName, PLUGINS_DIR, folder);
301
+ const mcpAbs = path.join(pluginDir, PLUGIN_MCP_FILE);
302
+ const manifestAbs = path.join(pluginDir, PLUGIN_MANIFEST_FILE);
303
+ return {
304
+ mcp: await readJson(mcpAbs),
305
+ manifest: await readJson(manifestAbs),
306
+ mcpAbs,
307
+ manifestAbs,
308
+ };
309
+ }
310
+ extensionEntry(manifest, name) {
311
+ const ns = manifest?.extensions?.[HEXIS_EXTENSION_NS];
312
+ const servers = ns?.mcpServers;
313
+ const entry = servers?.[name];
314
+ return entry && typeof entry === 'object' ? entry : {};
315
+ }
316
+ }
317
+ async function readJson(p) {
318
+ try {
319
+ const parsed = JSON.parse(await fs.readFile(p, 'utf-8'));
320
+ return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
321
+ ? parsed
322
+ : null;
323
+ }
324
+ catch {
325
+ return null;
326
+ }
327
+ }
328
+ //# sourceMappingURL=mcp-server-edit.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server-edit.service.js","sourceRoot":"","sources":["../../../src/modules/tool-manuals/mcp-server-edit.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,eAAe,GAEhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAyB,MAAM,mCAAmC,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAmEnG,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAGhC;IAFX,YACE,OAAe,EACN,MAAc;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAC;QAF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AK,UAAU,QAAQ,CAAC,CAAS;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QAClE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAC5E,CAAC,CAAE,MAAkC;YACrC,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { CallTemplate } from '@utcp/sdk';
2
2
  /**
3
- * Tool manuals — user-authored `*.tool` files under `Groups/` in the DEFAULT
3
+ * Tool manuals — user-authored `*.tool` files under `Plugins/` in the DEFAULT
4
4
  * branch KB. Each is a UTCP *manual* (a pointer to where tools come from), not a
5
5
  * flattened tool list. Access-controlled exactly like Skills (default-deny ACL
6
6
  * on the `.tool` file path). The MCP/UTCP endpoint serves every manual a user
@@ -77,8 +77,8 @@ export interface ToolManualSetup {
77
77
  /** Why auto-setup didn't complete — present for `oauth-manual`. */
78
78
  reason?: string;
79
79
  }
80
- /** A parsed `.tool` file (normalized). */
81
- export interface ToolManualDescriptor {
80
+ /** Fields common to every parsed manual — see {@link ToolManualDescriptor}. */
81
+ export interface ToolManualDescriptorBase {
82
82
  /** URL-safe id derived from the file name (route `:slug`), unique in the catalog. */
83
83
  slug: string;
84
84
  /**
@@ -87,7 +87,7 @@ export interface ToolManualDescriptor {
87
87
  * catalog; namespacing doubles underscores in vault keys (`utcpNamespacedKey`).
88
88
  */
89
89
  name: string;
90
- /** Repo-root-relative path of the `.tool` file (e.g. `Groups/Everyone/weather.tool`). */
90
+ /** Repo-root-relative path of the `.tool` file (e.g. `Plugins/Everyone/weather.tool`). */
91
91
  path: string;
92
92
  type: ToolManualType;
93
93
  /**
@@ -105,16 +105,42 @@ export interface ToolManualDescriptor {
105
105
  tools?: unknown[];
106
106
  /** Declared `${VAR}` scopes (see {@link ToolVariable}); empty when none declared. */
107
107
  variables?: ToolVariable[];
108
- /**
109
- * Whether this tool can run for a REMOTE consumer (Bevel's hosted MCP proxy).
110
- * Absent/`true` ⇒ available remotely; `false` ⇒ LOCAL-ONLY — the remote endpoint
111
- * skips it (it can't reach e.g. a `localhost` MCP server), and instead surfaces
112
- * its path via the `list_local_tools` tool so a local agent can self-configure it.
113
- */
114
- remote?: boolean;
115
108
  /** For `type: mcp`: the admin-facing setup requirement from auto-discovery. */
116
109
  setup?: ToolManualSetup;
117
110
  }
111
+ /** The spawn spec of a stdio-declared MCP server (a plugin `mcp.json` entry). */
112
+ export interface ToolManualStdioSpec {
113
+ command: string;
114
+ args: string[];
115
+ env?: Record<string, string>;
116
+ cwd?: string;
117
+ }
118
+ /**
119
+ * A parsed manual (a `.tool` file or a plugin `mcp.json` entry, normalized).
120
+ *
121
+ * `remote` — whether the tool can run for a REMOTE consumer (Bevel's hosted
122
+ * MCP proxy). Absent/`true` ⇒ available remotely; `false` ⇒ LOCAL-ONLY — the
123
+ * remote endpoint skips it (it can't reach e.g. a `localhost` MCP server),
124
+ * and instead surfaces its path via the `list_local_tools` tool so a local
125
+ * agent can self-configure it.
126
+ *
127
+ * `stdio` — for a `type: mcp` server declared with a stdio transport in a
128
+ * plugin's `mcp.json`: the spawn spec. A UNION, not two optional fields,
129
+ * because a stdio spec REQUIRES `remote: false` — the hosted proxy can never
130
+ * spawn a subprocess out of knowledge-base content, so stdio servers are
131
+ * served only to local consumers, which run them per the Agent Plugins
132
+ * runtime contract (PLUGIN_ROOT/PLUGIN_DATA, `./` containment) — and the
133
+ * type refusing `remote: true` beside a spawn spec is what keeps every
134
+ * producer honest about that.
135
+ */
136
+ export type ToolManualDescriptor = (ToolManualDescriptorBase & {
137
+ remote?: boolean;
138
+ stdio?: undefined;
139
+ }) | (ToolManualDescriptorBase & {
140
+ type: 'mcp';
141
+ remote: false;
142
+ stdio: ToolManualStdioSpec;
143
+ });
118
144
  /** A validated UTCP manual dict (`{ utcp_version, manual_version, tools }`). */
119
145
  export type UtcpManualDict = Record<string, unknown>;
120
146
  /** Result of validating a draft `.tool` for the renderer's preview. */
@@ -176,7 +202,7 @@ export interface IToolManualService {
176
202
  /**
177
203
  * Every manual in the catalog, UNFILTERED by access — the mirror of
178
204
  * `skillService.listSkills(undefined)`. For caller-INDEPENDENT counting only
179
- * (the group index's "N tools", which a non-member is allowed to see as a
205
+ * (the plugin index's "N tools", which a non-member is allowed to see as a
180
206
  * number). Never surface a name, path or description from this to someone
181
207
  * who cannot read the file; `listAccessible` is the surface for that.
182
208
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tool-manuals.contract.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-manuals/tool-manuals.contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AAEH,sFAAsF;AACtF,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAEvD,mDAAmD;AACnD,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,oDAAoD;IACpD,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C;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAC9F,CAAC;IACF,0EAA0E;IAC1E,UAAU,IAAI,IAAI,CAAC;CACpB"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tool manuals — user-authored `*.tool` files under `Groups/` in the DEFAULT
2
+ * Tool manuals — user-authored `*.tool` files under `Plugins/` in the DEFAULT
3
3
  * branch KB. Each is a UTCP *manual* (a pointer to where tools come from), not a
4
4
  * flattened tool list. Access-controlled exactly like Skills (default-deny ACL
5
5
  * on the `.tool` file path). The MCP/UTCP endpoint serves every manual a user
@@ -1,6 +1,10 @@
1
1
  import express, { type RequestHandler } from 'express';
2
+ import { type WorkspaceService } from '../workspace/workspace.service.js';
3
+ import type { IAccessControl } from '../access/access-control.interface.js';
2
4
  import '@utcp/http';
3
5
  import { type IToolManualService } from './tool-manuals.contract.js';
6
+ import { type McpServerEditService } from './mcp-server-edit.service.js';
7
+ import type { AuthUser } from '@bevel-software/platform-shared';
4
8
  import '../auth/auth.middleware.js';
5
9
  import '../tool-auth/tool-auth.middleware.js';
6
10
  /** Resolve a connection-key/internal-token user id to its email (per-caller ACL). */
@@ -14,7 +18,11 @@ export type ResolveUserEmail = (userId: string) => Promise<string | undefined>;
14
18
  * GET /tools/:slug/manual — an inline `.tool`'s embedded tools as a UTCP
15
19
  * manual (so inline needs no extra client plugin).
16
20
  */
17
- export declare function createToolManualsAgentRoutes(toolManualService: IToolManualService, manualAuth: RequestHandler, resolveUserEmail: ResolveUserEmail): express.Router;
21
+ export declare function createToolManualsAgentRoutes(toolManualService: IToolManualService, manualAuth: RequestHandler, resolveUserEmail: ResolveUserEmail, archiveDeps?: {
22
+ workspaceService: WorkspaceService;
23
+ accessControl: IAccessControl;
24
+ kbDirName: string;
25
+ }): express.Router;
18
26
  /**
19
27
  * Browser-facing tool-manual routes (mounted under the JWT auth middleware):
20
28
  * GET /tools — the caller's accessible `.tool` manuals (summaries).
@@ -24,5 +32,8 @@ export declare function createToolManualsAgentRoutes(toolManualService: IToolMan
24
32
  * literal sibling is shadowed by the param segment;
25
33
  * `preview` is POST-only, so it never collides.
26
34
  */
27
- export declare function createToolManualsBrowserRoutes(toolManualService: IToolManualService): express.Router;
35
+ export declare function createToolManualsBrowserRoutes(toolManualService: IToolManualService, serverEdit?: {
36
+ service: McpServerEditService;
37
+ getUser: (userId: string) => Promise<AuthUser | undefined>;
38
+ }): express.Router;
28
39
  //# sourceMappingURL=tool-manuals.routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-manuals.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-manuals/tool-manuals.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAgB,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,kBAAkB,EAA2B,MAAM,4BAA4B,CAAC;AAC9F,OAAO,4BAA4B,CAAC;AACpC,OAAO,sCAAsC,CAAC;AAE9C,qFAAqF;AACrF,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAgB/E;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,iBAAiB,EAAE,kBAAkB,EACrC,UAAU,EAAE,cAAc,EAC1B,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,MAAM,CA2ChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAuCpG"}
1
+ {"version":3,"file":"tool-manuals.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/tool-manuals/tool-manuals.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAgB,KAAK,cAAc,E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