@runeya/runeya 2.0.154 → 2.0.156

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 (169) hide show
  1. package/agent/index.js +315 -166
  2. package/agent/index.js.map +1 -1
  3. package/agent-manager-KDL4JWZN.js +13 -0
  4. package/chat-7V3FN2PU.js +28 -0
  5. package/{chunk-MGKGIHT4.js → chunk-ETPXJSVC.js} +2 -2
  6. package/{chunk-RVZATF7R.js → chunk-EZ35ISYR.js} +249 -1
  7. package/chunk-EZ35ISYR.js.map +1 -0
  8. package/{chunk-3C3R5ZVX.js → chunk-JAMAGUGN.js} +2 -2
  9. package/{chunk-TBNCGMDM.js → chunk-L3BEQ75K.js} +5 -5
  10. package/{chunk-QD2OVLK4.js → chunk-LUFAT2NW.js} +463 -6
  11. package/chunk-LUFAT2NW.js.map +1 -0
  12. package/{chunk-3O54EIGT.js → chunk-N4ZP7T6L.js} +4 -4
  13. package/{chunk-26Q43CB2.js → chunk-N5LP5TPS.js} +2 -2
  14. package/{chunk-VKYSHTYT.js → chunk-NJDF4CDG.js} +39 -23
  15. package/chunk-NJDF4CDG.js.map +1 -0
  16. package/{chunk-DTRZ5ZN7.js → chunk-NV7MBTNW.js} +5 -5
  17. package/{chunk-OLHL5NFP.js → chunk-S5M6KX5K.js} +30 -12
  18. package/chunk-S5M6KX5K.js.map +1 -0
  19. package/{chunk-PU6REPMY.js → chunk-SVKR7CYU.js} +4 -4
  20. package/{chunk-R4SKU6AO.js → chunk-TMX3NXMQ.js} +6 -6
  21. package/{chunk-2DIW5EUT.js → chunk-V7WTXGEJ.js} +6 -6
  22. package/{companion-3MW23ONE.js → companion-AF7G2FNC.js} +9 -9
  23. package/{desktop-installer-page-TBKSXVFD.js → desktop-installer-page-DCS2FLA5.js} +3 -3
  24. package/{desktop-launcher-WBYP3KTF.js → desktop-launcher-ER3J7KAW.js} +3 -3
  25. package/{environment-resolver-R2GH6QOX.js → environment-resolver-HT6GTSLA.js} +6 -6
  26. package/{external-UJ46WKBL.js → external-DHD7PLKK.js} +3 -3
  27. package/index.js +12 -12
  28. package/{install-gate-3UVXPA57.js → install-gate-L27RKPNM.js} +2 -2
  29. package/mcp-server/external.js +672 -36
  30. package/mcp-server/external.js.map +1 -1
  31. package/mcp-server/index.js +672 -36
  32. package/mcp-server/index.js.map +1 -1
  33. package/package.json +1 -1
  34. package/{project-store-GBKM34QP.js → project-store-6TFAYAWK.js} +7 -7
  35. package/settings-manager-OTVXDUJS.js +10 -0
  36. package/{src-6WZKSNN7.js → src-DBSSIQC7.js} +72 -2
  37. package/{src-K4E6GUCZ.js → src-YFOQ4ZCE.js} +427 -219
  38. package/src-YFOQ4ZCE.js.map +1 -0
  39. package/{vault-resolver-GGHULMG6.js → vault-resolver-G3G5YPNG.js} +3 -3
  40. package/web/assets/{AgentScalarChatInterface.vue-BtA-f77q.js → AgentScalarChatInterface.vue-CtkvKRSd.js} +1 -1
  41. package/web/assets/AgentTerminalPage-Dt9S2kZX.js +1 -0
  42. package/web/assets/{AiChatModals-BV3vIIqN.js → AiChatModals-BEpSEXmp.js} +1 -1
  43. package/web/assets/AppLayout-B1-D2-jx.css +1 -0
  44. package/web/assets/AppLayout-DIAQvecQ.js +1 -0
  45. package/web/assets/{AuditPage-DoKHFRJ7.js → AuditPage-BEt0m-rM.js} +1 -1
  46. package/web/assets/{CloudAccountPage-CDQNalgx.js → CloudAccountPage-BGijgepw.js} +1 -1
  47. package/web/assets/CloudMessagingPage-C9uWAT8S.js +2 -0
  48. package/web/assets/CloudMessagingPage-grbGyoki.css +1 -0
  49. package/web/assets/{DashboardPage-ClJR5DiP.js → DashboardPage-DFiL6A-k.js} +1 -1
  50. package/web/assets/{DirectoryPickerDialog-CVVg3SzI.js → DirectoryPickerDialog-C8dwWIUa.js} +1 -1
  51. package/web/assets/{EditorIcon-DksI79ZN.js → EditorIcon-Cx11i-sC.js} +1 -1
  52. package/web/assets/{EnvironmentForm-eMpLFv_-.js → EnvironmentForm-DZgZitCy.js} +1 -1
  53. package/web/assets/{EnvironmentFormPage-DXH2lgk_.js → EnvironmentFormPage-ubP8cX3l.js} +1 -1
  54. package/web/assets/{EnvironmentListPage-D-g_8lQw.js → EnvironmentListPage-CPs1uuvs.js} +1 -1
  55. package/web/assets/{FlagChip-DjC14z4J.js → FlagChip-UumVjPY9.js} +1 -1
  56. package/web/assets/KanbanBoardPage-C9NqOqdD.js +4 -0
  57. package/web/assets/KanbanBoardPage-Cy1VPXZs.css +1 -0
  58. package/web/assets/{KanbanListPage-DnhCC5ET.js → KanbanListPage-D_ZpIbT2.js} +1 -1
  59. package/web/assets/KnowledgeListPage-BjfZa5Wu.css +1 -0
  60. package/web/assets/KnowledgeListPage-BoaV9hBg.js +1 -0
  61. package/web/assets/KnowledgePagePage-UGJGJY4d.js +1 -0
  62. package/web/assets/KnowledgePagePage-qnvlYhD5.css +1 -0
  63. package/web/assets/{LaunchProjectPage-DyNqhic1.js → LaunchProjectPage-B0Lg5Kr5.js} +1 -1
  64. package/web/assets/{LaunchServicesPage-bI7pVeU7.js → LaunchServicesPage-D_pqkdXt.js} +1 -1
  65. package/web/assets/{LaunchShell-CokT4E5l.js → LaunchShell-CJtXkSUp.js} +1 -1
  66. package/web/assets/LogViewer-DLxO4-gP.js +3 -0
  67. package/web/assets/{LogViewer-OHdSLleq.css → LogViewer-nXZtMJDA.css} +1 -1
  68. package/web/assets/{OrgKeyPrompt-DtgelhnI.js → OrgKeyPrompt-Cbx4cLL0.js} +1 -1
  69. package/web/assets/{ProcessControls-CxlDLGiO.js → ProcessControls-Cx-QzqxQ.js} +1 -1
  70. package/web/assets/{ProcessDetailPage-D93cKCHb.js → ProcessDetailPage-Bxwv0984.js} +1 -1
  71. package/web/assets/{ProcessMetrics-C_7_boMv.js → ProcessMetrics-DisQYLu6.js} +1 -1
  72. package/web/assets/{ProjectCreateDialog-Bko_A5wp.js → ProjectCreateDialog-HcYVX36i.js} +1 -1
  73. package/web/assets/{ProjectLocationGate-jsy8WetY.js → ProjectLocationGate-PR92Tdos.js} +1 -1
  74. package/web/assets/{ProjectPublishDialog-7kR1zZAo.js → ProjectPublishDialog-YvOeVDCP.js} +1 -1
  75. package/web/assets/{RandomJobTestPage-Dp9prwa7.js → RandomJobTestPage-Bp9qone4.js} +1 -1
  76. package/web/assets/ScenarioEditorPage-Cjkkz3JB.js +14 -0
  77. package/web/assets/{SendToChatDialog-BVSbXcbf.js → SendToChatDialog-CQbi2P_L.js} +1 -1
  78. package/web/assets/{ServiceControlsBar-DFECGWL8.js → ServiceControlsBar-9jsN3h0c.js} +1 -1
  79. package/web/assets/ServiceDetailPage-COHMUw51.js +2 -0
  80. package/web/assets/{ServiceFormPage-ChsRsoLt.js → ServiceFormPage-B4n8scwP.js} +1 -1
  81. package/web/assets/{SettingsPage-BXKsN9Py.js → SettingsPage-C3PnwdxZ.js} +6 -6
  82. package/web/assets/{UnlockPage-DhEN16uX.js → UnlockPage-BIB0NtWF.js} +1 -1
  83. package/web/assets/{VaultMigrationPage-BgRNUuTP.js → VaultMigrationPage-D27SeEVr.js} +1 -1
  84. package/web/assets/{VersionBadge-CXJ-2h5V.js → VersionBadge-FeuuTMz7.js} +1 -1
  85. package/web/assets/{WikiPage-BT5a9d5Q.js → WikiPage-A8C0dEDX.js} +1 -1
  86. package/web/assets/{WikiView-BNReLsq5.js → WikiView-D3c0r5q8.js} +1 -1
  87. package/web/assets/{add-scalar-classes-C_lKfiMa.js → add-scalar-classes-Ohd6-7G3.js} +2 -2
  88. package/web/assets/{agent.store-B6OM7edC.js → agent.store-BwUoohNu.js} +1 -1
  89. package/web/assets/auth-DdEdmJV5.js +2 -0
  90. package/web/assets/{cloud-chat.store-Di38xQRJ.js → cloud-chat.store-za5cBdZx.js} +1 -1
  91. package/web/assets/{cloud-client-CEVx-bg6.js → cloud-client-zXY8HZtj.js} +2 -2
  92. package/web/assets/{cloud-session-w6eNQX1X.js → cloud-session-DqfQKW5D.js} +2 -2
  93. package/web/assets/devtools-DCoWQoU_-D2vs4YXr.js +1 -0
  94. package/web/assets/dist-Cx_klvkk.js +1 -0
  95. package/web/assets/i18n-B8hHo8g2.js +17 -0
  96. package/web/assets/{index-mvpLwxNT.js → index-CYcPxjSC.js} +93 -105
  97. package/web/assets/index-DozDRY7J.css +1 -0
  98. package/web/assets/knowledge-host-ButMqDET.js +6 -0
  99. package/web/assets/knowledge-host-CfNnk0oz.css +1 -0
  100. package/web/assets/{modal-Bslt0NZi.js → modal-B9eahS9q.js} +1 -1
  101. package/web/assets/{notification.store-CAG1kWYq.js → notification.store-CWs6iQmx.js} +1 -1
  102. package/web/assets/{project-launch.store-Im5SMon9.js → project-launch.store-DkD7Q9jW.js} +1 -1
  103. package/web/assets/{project.store-CITAykC3.js → project.store-CnflI3la.js} +1 -1
  104. package/web/assets/scenario-run-overrides-BqTAaZZz.js +1 -0
  105. package/web/assets/{scenario.store-C9sSoRzb.js → scenario.store-DGt8nNt5.js} +1 -1
  106. package/web/assets/{service.store-CZJuuJiv.js → service.store-yECOKc1C.js} +1 -1
  107. package/web/assets/{settings-scope-vcJEMNnD.js → settings-scope-Ca1LjLG1.js} +1 -1
  108. package/web/assets/{settings.store-CydW_2jh.js → settings.store-Cyop63CA.js} +1 -1
  109. package/web/assets/{src-CIOvFTGI.js → src-8YjxNhhv.js} +23 -23
  110. package/web/assets/src-B-YFvUDL.css +1 -0
  111. package/web/assets/{src-COZZWm-m.js → src-BD3q9_go.js} +1 -1
  112. package/web/assets/{src-Ck_MutzB.js → src-CcVk2-Gw.js} +1 -1
  113. package/web/assets/{trpc-BQ0mLnfI.js → trpc-DlM4IpMe.js} +3 -3
  114. package/web/assets/{useCloudOrg-CQvEbrZv.js → useCloudOrg-Ck6Ef1iD.js} +1 -1
  115. package/web/assets/useEnvVarAutocomplete-B0fhZK-_.js +1 -0
  116. package/web/assets/{useProjectCatalog-CWHpf3Yj.js → useProjectCatalog-D1RgJoOm.js} +1 -1
  117. package/web/assets/{useProjectCloudOrg-B3rNPes5.js → useProjectCloudOrg-tnlpo5R1.js} +1 -1
  118. package/web/assets/{useServiceUrlHost-BFfie_6h.js → useServiceUrlHost-Xzj6EOft.js} +1 -1
  119. package/web/assets/uuid-B2pLMyOM.js +1 -0
  120. package/web/assets/uuid-DfCowYZy.js +1 -0
  121. package/web/assets/vue-router--yRg_Dd_.js +1 -0
  122. package/web/index.html +20 -19
  123. package/agent-manager-SF4CAJJC.js +0 -13
  124. package/chat-COP27XB3.js +0 -28
  125. package/chunk-OLHL5NFP.js.map +0 -1
  126. package/chunk-QD2OVLK4.js.map +0 -1
  127. package/chunk-RVZATF7R.js.map +0 -1
  128. package/chunk-VKYSHTYT.js.map +0 -1
  129. package/settings-manager-VSOC3XGI.js +0 -10
  130. package/src-K4E6GUCZ.js.map +0 -1
  131. package/web/assets/AgentTerminalPage-2Ky-vEkw.js +0 -1
  132. package/web/assets/AppLayout-BgPr-urw.css +0 -1
  133. package/web/assets/AppLayout-DsczwAFI.js +0 -1
  134. package/web/assets/CloudMessagingPage-Cn3JhJsY.css +0 -1
  135. package/web/assets/CloudMessagingPage-DduCz3KB.js +0 -2
  136. package/web/assets/KanbanBoardPage-BeSkCN6I.js +0 -4
  137. package/web/assets/KanbanBoardPage-BrFqn87r.css +0 -1
  138. package/web/assets/LogViewer-Cs3Y8vaZ.js +0 -3
  139. package/web/assets/ScenarioEditorPage-fv9yLH75.js +0 -14
  140. package/web/assets/ServiceDetailPage-BQA74240.js +0 -2
  141. package/web/assets/auth-5bsz5kSC.js +0 -2
  142. package/web/assets/dist-C9Qdh18x.js +0 -1
  143. package/web/assets/i18n-DbgjJIf8.js +0 -1
  144. package/web/assets/index-DB3-fmza.css +0 -1
  145. package/web/assets/src-DrVR8mhy.css +0 -1
  146. package/web/assets/useEnvVarAutocomplete-hy3rO3SN.js +0 -1
  147. package/web/assets/uuid-XipkJWQw.js +0 -1
  148. package/web/assets/vue-router-fin80h5W.js +0 -1
  149. /package/{agent-manager-SF4CAJJC.js.map → agent-manager-KDL4JWZN.js.map} +0 -0
  150. /package/{chat-COP27XB3.js.map → chat-7V3FN2PU.js.map} +0 -0
  151. /package/{chunk-MGKGIHT4.js.map → chunk-ETPXJSVC.js.map} +0 -0
  152. /package/{chunk-3C3R5ZVX.js.map → chunk-JAMAGUGN.js.map} +0 -0
  153. /package/{chunk-TBNCGMDM.js.map → chunk-L3BEQ75K.js.map} +0 -0
  154. /package/{chunk-3O54EIGT.js.map → chunk-N4ZP7T6L.js.map} +0 -0
  155. /package/{chunk-26Q43CB2.js.map → chunk-N5LP5TPS.js.map} +0 -0
  156. /package/{chunk-DTRZ5ZN7.js.map → chunk-NV7MBTNW.js.map} +0 -0
  157. /package/{chunk-PU6REPMY.js.map → chunk-SVKR7CYU.js.map} +0 -0
  158. /package/{chunk-R4SKU6AO.js.map → chunk-TMX3NXMQ.js.map} +0 -0
  159. /package/{chunk-2DIW5EUT.js.map → chunk-V7WTXGEJ.js.map} +0 -0
  160. /package/{companion-3MW23ONE.js.map → companion-AF7G2FNC.js.map} +0 -0
  161. /package/{desktop-installer-page-TBKSXVFD.js.map → desktop-installer-page-DCS2FLA5.js.map} +0 -0
  162. /package/{desktop-launcher-WBYP3KTF.js.map → desktop-launcher-ER3J7KAW.js.map} +0 -0
  163. /package/{environment-resolver-R2GH6QOX.js.map → environment-resolver-HT6GTSLA.js.map} +0 -0
  164. /package/{external-UJ46WKBL.js.map → external-DHD7PLKK.js.map} +0 -0
  165. /package/{install-gate-3UVXPA57.js.map → install-gate-L27RKPNM.js.map} +0 -0
  166. /package/{project-store-GBKM34QP.js.map → project-store-6TFAYAWK.js.map} +0 -0
  167. /package/{settings-manager-VSOC3XGI.js.map → settings-manager-OTVXDUJS.js.map} +0 -0
  168. /package/{src-6WZKSNN7.js.map → src-DBSSIQC7.js.map} +0 -0
  169. /package/{vault-resolver-GGHULMG6.js.map → vault-resolver-G3G5YPNG.js.map} +0 -0
@@ -6,21 +6,21 @@ import {
6
6
  environmentStore,
7
7
  extractEncryptedVariableSlots,
8
8
  getEncryptionKey
9
- } from "./chunk-3O54EIGT.js";
9
+ } from "./chunk-N4ZP7T6L.js";
10
10
  import {
11
11
  fingerprintFiles,
12
12
  renameWithRetry
13
- } from "./chunk-3C3R5ZVX.js";
13
+ } from "./chunk-JAMAGUGN.js";
14
14
  import {
15
15
  allVaultRoots,
16
16
  keyedFilePath,
17
17
  legacyMachineFilePath,
18
18
  vaultIdOfRoot
19
- } from "./chunk-MGKGIHT4.js";
19
+ } from "./chunk-ETPXJSVC.js";
20
20
  import {
21
21
  MASKED_VALUE,
22
22
  isSharedWithAi
23
- } from "./chunk-RVZATF7R.js";
23
+ } from "./chunk-EZ35ISYR.js";
24
24
 
25
25
  // ../server/src/services/environment-overrides-store.ts
26
26
  import { readFile, writeFile, mkdir, chmod } from "fs/promises";
@@ -860,4 +860,4 @@ export {
860
860
  describeVariables,
861
861
  environmentResolver
862
862
  };
863
- //# sourceMappingURL=chunk-TBNCGMDM.js.map
863
+ //# sourceMappingURL=chunk-L3BEQ75K.js.map
@@ -3,14 +3,40 @@ import {
3
3
  BootstrapCommandSchema,
4
4
  DockerConfigSchema,
5
5
  HealthCheckSchema,
6
+ KNOWLEDGE_LIMITS,
7
+ KNOWLEDGE_PAGE_TYPES,
8
+ KNOWLEDGE_RELATIONS,
9
+ KNOWLEDGE_TYPE_SPECS,
10
+ KnowledgeAliasesSchema,
11
+ KnowledgeEdgeKindSchema,
12
+ KnowledgeFieldsSchema,
13
+ KnowledgeIdSchema,
14
+ KnowledgeLinkSchema,
15
+ KnowledgeLocaleSchema,
16
+ KnowledgePageTypeSchema,
17
+ KnowledgeProjectIdsSchema,
18
+ KnowledgeRelationSchema,
19
+ KnowledgeSectionModeSchema,
20
+ KnowledgeSectionSchema,
21
+ KnowledgeSourcesSchema,
22
+ KnowledgeStatusSchema,
23
+ KnowledgeThemeIdsSchema,
6
24
  RestartStrategySchema,
7
25
  ServiceCommandSchema,
8
26
  ServiceConfigSchema,
9
27
  ServiceShortcutSchema,
28
+ foldText,
10
29
  maskLogSourceSecrets
11
- } from "./chunk-RVZATF7R.js";
30
+ } from "./chunk-EZ35ISYR.js";
12
31
 
13
32
  // ../../packages/ai-capabilities/src/trpc-caller.ts
33
+ function withoutStack(error) {
34
+ if (!error || typeof error !== "object") return error;
35
+ const { data, ...rest } = error;
36
+ if (!data || typeof data !== "object") return error;
37
+ const { stack: _stack, ...cleanData } = data;
38
+ return { ...rest, data: cleanData };
39
+ }
14
40
  async function callTrpc(baseUrl, route, method, input, authToken, fetchImpl = fetch) {
15
41
  const headers = {
16
42
  "Content-Type": "application/json",
@@ -24,13 +50,14 @@ async function callTrpc(baseUrl, route, method, input, authToken, fetchImpl = fe
24
50
  signal: AbortSignal.timeout(15e3)
25
51
  });
26
52
  const json = await res.json();
27
- if (json["error"]) throw new Error(JSON.stringify(json["error"]));
53
+ if (json["error"]) throw new Error(JSON.stringify(withoutStack(json["error"])));
28
54
  const result = json["result"];
29
55
  return result?.["data"] ?? result ?? json;
30
56
  }
31
57
  async function runCapability(cap, baseUrl, params, authToken, fetchImpl = fetch) {
32
- const result = await callTrpc(baseUrl, cap.route, cap.method, cap.buildInput(params), authToken, fetchImpl);
33
- return cap.transformOutput ? cap.transformOutput(result) : result;
58
+ const input = cap.buildInput(params);
59
+ const result = await callTrpc(baseUrl, cap.route, cap.method, input, authToken, fetchImpl);
60
+ return cap.transformOutput ? cap.transformOutput(result, input) : result;
34
61
  }
35
62
 
36
63
  // ../../packages/ai-capabilities/src/capabilities.ts
@@ -158,6 +185,435 @@ var refs = (scope) => BUILTIN_VARIABLES.filter((b) => b.scope === scope).map((b)
158
185
  var BUILTINS_HELP = `Built-in references Runeya fills itself \u2014 filled when the service is deployed, from the service that receives the variable: ${refs("server")}, the numbered {{service.PORT_2}} / {{service.URL_2}}\u2026 for its other ports, and {{services.<slug>.PORT}}, .URL, .BASE_URL, .NAME, .ID for a sibling service of the project (slug = its name in lowercase-dashes). Filled on the machine when the service starts: ${refs("agent")}.`;
159
186
  var CREATE_SERVICE_PARAMS = serviceParams(false);
160
187
  var UPDATE_SERVICE_PARAMS = serviceParams(true);
188
+ var KNOWLEDGE_TYPES_DOC = KNOWLEDGE_PAGE_TYPES.map((t) => {
189
+ const spec = KNOWLEDGE_TYPE_SPECS[t];
190
+ const fields = spec.fields.map((f) => `${f.key} (${f.description})`).join("; ");
191
+ return `${t}: ${spec.description}${fields ? ` Fields: ${fields}.` : ""}`;
192
+ }).join(" | ");
193
+ var KNOWLEDGE_RELATIONS_DOC = `${KNOWLEDGE_RELATIONS.join(", ")} (related and contradicts read both ways)`;
194
+ var kIds = z.array(KnowledgeIdSchema).max(50);
195
+ var kSearchLimit = z.number().int().min(1).max(KNOWLEDGE_LIMITS.searchResults);
196
+ var kSections = z.array(KnowledgeSectionSchema).max(KNOWLEDGE_LIMITS.sections);
197
+ var kThemeDepth = z.number().int().min(0).max(KNOWLEDGE_LIMITS.themeDepth);
198
+ var kDepth = z.number().int().min(1).max(KNOWLEDGE_LIMITS.neighborsDepth);
199
+ var kRelatedLimit = z.number().int().min(1).max(KNOWLEDGE_LIMITS.relatedPages);
200
+ var kNeighborLimit = z.number().int().min(1).max(KNOWLEDGE_LIMITS.neighborsNodes);
201
+ var kHistoryLimit = z.number().int().min(1).max(500);
202
+ var kSeedIds = z.array(KnowledgeIdSchema).min(1).max(10);
203
+ function knowledgePageFields(p) {
204
+ const out = {};
205
+ if (p.title !== void 0) out.title = p.title;
206
+ if (p.summary !== void 0) out.summary = p.summary;
207
+ if (p.type !== void 0) out.type = parseTyped("type", KnowledgePageTypeSchema, p.type);
208
+ if (p.aliases !== void 0) out.aliases = parseTyped("aliases", KnowledgeAliasesSchema, p.aliases);
209
+ if (p.fields !== void 0) out.fields = parseTyped("fields", KnowledgeFieldsSchema, p.fields);
210
+ if (p.themeIds !== void 0) out.themeIds = parseTyped("themeIds", KnowledgeThemeIdsSchema, p.themeIds);
211
+ if (p.projectIds !== void 0) out.projectIds = parseTyped("projectIds", KnowledgeProjectIdsSchema, p.projectIds);
212
+ if (p.sources !== void 0) out.sources = parseTyped("sources", KnowledgeSourcesSchema, p.sources);
213
+ return out;
214
+ }
215
+ function sectionNamed(sections, heading) {
216
+ const found = sections.filter((x) => foldText(String(x.heading)) === foldText(heading));
217
+ if (found.length) return found;
218
+ const names = sections.map((x) => `"${String(x.heading)}"`).join(", ") || "none";
219
+ throw new Error(`No section "${heading}" in this page. Sections: ${names}.`);
220
+ }
221
+ function withoutFullBody(result) {
222
+ if (!result || typeof result !== "object" || !("page" in result)) return result;
223
+ const page0 = result.page;
224
+ if (page0 && typeof page0 === "object") {
225
+ const { markdown: _markdown, ...page } = page0;
226
+ return { ...result, page };
227
+ }
228
+ return result;
229
+ }
230
+ function editedSectionOnly(result) {
231
+ const reduced = withoutFullBody(result);
232
+ if (!reduced || typeof reduced !== "object") return reduced;
233
+ const { changed, ...response } = reduced;
234
+ const page = response.page;
235
+ if (!page || typeof page !== "object") return reduced;
236
+ const { sections, id, title, status, lock, updatedAt, updatedBy } = page;
237
+ const edited = changed ?? [];
238
+ const touched = new Set(edited.map((c) => c.heading));
239
+ return {
240
+ ...response,
241
+ page: {
242
+ // Ce qui sert à vérifier l'écriture ; la fiche complète est dans knowledge_get_page.
243
+ id,
244
+ title,
245
+ status,
246
+ locked: Boolean(lock),
247
+ updatedAt,
248
+ updatedBy,
249
+ editedSections: edited,
250
+ otherSections: (sections ?? []).map((s) => s.heading).filter((h) => !touched.has(h))
251
+ }
252
+ };
253
+ }
254
+ var isRec = (v) => !!v && typeof v === "object" && !Array.isArray(v);
255
+ function slimThemes(item) {
256
+ if (!isRec(item) || !Array.isArray(item.themes)) return item;
257
+ return { ...item, themes: item.themes.map((t) => ({ id: t.id, title: t.title })) };
258
+ }
259
+ function pageSheet(page) {
260
+ return { id: page.id, title: page.title, status: page.status, locked: Boolean(page.lock ?? page.locked), updatedAt: page.updatedAt, updatedBy: page.updatedBy };
261
+ }
262
+ function mergedLinks(links) {
263
+ const byId = /* @__PURE__ */ new Map();
264
+ for (const l of Array.isArray(links) ? links : []) {
265
+ const id = String(l.id);
266
+ const seen = byId.get(id);
267
+ if (seen) seen.kinds.push(l.kind);
268
+ else byId.set(id, { id: l.id, title: l.title, type: l.type, status: l.status, kinds: [l.kind] });
269
+ }
270
+ return [...byId.values()];
271
+ }
272
+ function writeAnswer(pick) {
273
+ return (result, input) => {
274
+ const reduced = withoutFullBody(result);
275
+ if (!isRec(reduced) || !isRec(reduced.page)) return reduced;
276
+ return { ...reduced, page: { ...pageSheet(reduced.page), ...pick(reduced.page, isRec(input) ? input : {}) } };
277
+ };
278
+ }
279
+ var headingsOf = (page) => Array.isArray(page.sections) ? page.sections.map((x) => String(x.heading)) : [];
280
+ function readPageAnswer(result, input) {
281
+ const reduced = withoutFullBody(result);
282
+ if (!isRec(reduced) || !isRec(reduced.page)) return reduced;
283
+ const page = slimThemes(reduced.page);
284
+ const links = isRec(page.links) ? page.links : {};
285
+ const heading = isRec(input) && typeof input.heading === "string" ? input.heading : void 0;
286
+ const sections = Array.isArray(page.sections) ? page.sections : [];
287
+ const picked = heading === void 0 ? sections : sectionNamed(sections, heading);
288
+ return {
289
+ ...reduced,
290
+ page: {
291
+ ...page,
292
+ links: { outgoing: mergedLinks(links.outgoing), incoming: mergedLinks(links.incoming) },
293
+ sections: picked,
294
+ ...heading === void 0 ? {} : { otherSections: headingsOf(page).filter((h) => foldText(h) !== foldText(heading)) },
295
+ // Les sections encore vides : une page à compléter se voit sans relire le détail.
296
+ ...sections.some((x) => !String(x.markdown).trim()) ? { emptySections: sections.filter((x) => !String(x.markdown).trim()).map((x) => String(x.heading)) } : {}
297
+ }
298
+ };
299
+ }
300
+ var KNOWLEDGE_LOCK_NOTE = "A page locked by a person cannot be changed by you: the call is refused, tell the user what you would change instead.";
301
+ var KNOWLEDGE_CAPABILITIES = [
302
+ {
303
+ name: "knowledge_list_spaces",
304
+ description: "List the knowledge spaces of the organization (the team's long-term memory, kept in the cloud). Returns the organizationId actually queried and each space id, name, description and page count.",
305
+ route: "knowledge.listSpaces",
306
+ method: "GET",
307
+ params: [{ name: "organizationId", description: "The organization. Optional when the machine has one.", required: false }],
308
+ buildInput: (p) => p.organizationId ? { organizationId: p.organizationId } : {},
309
+ usageHint: `"qu'est-ce qu'on sait sur\u2026" / "cherche dans la m\xE9moire" \u2192 knowledge_search before answering from your own assumptions.`
310
+ },
311
+ {
312
+ name: "knowledge_search",
313
+ description: `Search the knowledge base: free text (accent and case insensitive, French stemming; each word may be partial and is looked for in titles, aliases, summaries, fields and bodies; every remaining word must match, stop words are ignored), filtered by type, space, project and themes. Each hit gives its summary, theme ids (their titles are listed once in themes) and the number of linked pages, so you can choose without opening pages. Cross themes with themeIds: only pages carrying ALL the given themes are returned, each theme counting its sub-themes down to themeDepth levels (0 = the theme alone, default 1). Obsolete pages are left out unless includeObsolete. Without a query, pages come by last update and the answer gives nextCursor: pass it as cursor to get the next ones, until it is absent. With a query, nextCursor gives the next results of the same ranking, frozen for 15 minutes (pass the same query with it): nothing is skipped or repeated even if pages change meanwhile. incomplete: true means more pages match than were examined: refine the query (more words, a type, a theme, a space) rather than trusting the list as complete. Page types: ${KNOWLEDGE_TYPES_DOC}`,
314
+ route: "knowledge.search",
315
+ method: "GET",
316
+ params: [
317
+ { name: "query", description: "Free text. Omit to list pages by last update.", required: false },
318
+ { name: "types", description: `Page types to keep: ${KNOWLEDGE_PAGE_TYPES.join(", ")}`, required: false, schema: z.array(KnowledgePageTypeSchema) },
319
+ { name: "themeIds", description: "Theme page ids the pages must ALL carry (from knowledge_list_themes)", required: false, schema: KnowledgeThemeIdsSchema },
320
+ { name: "themeDepth", description: `Levels of sub-themes counted with each theme, 0 to ${KNOWLEDGE_LIMITS.themeDepth}`, required: false, schema: kThemeDepth },
321
+ { name: "spaceIds", description: "Restrict to these spaces", required: false, schema: kIds },
322
+ // Pas `projectId` : ce nom est rempli d'office avec le projet de la
323
+ // conversation (project-anchor), ce qui filtrait toute recherche sur lui.
324
+ { name: "onlyProjectId", description: "Only pages attached to this Runeya project. Omit to search the whole organization.", required: false },
325
+ { name: "includeObsolete", description: "Also return obsolete pages", required: false, schema: z.boolean() },
326
+ { name: "limit", description: `At most this many hits (1-${KNOWLEDGE_LIMITS.searchResults}, default 20)`, required: false, schema: kSearchLimit },
327
+ { name: "organizationId", description: "The organization. Optional when the machine has one.", required: false },
328
+ { name: "cursor", description: "The nextCursor of the previous answer, to get the next pages (with a query, pass the same query)", required: false }
329
+ ],
330
+ buildInput: (p) => ({
331
+ ...p.organizationId ? { organizationId: p.organizationId } : {},
332
+ ...p.query ? { query: p.query } : {},
333
+ ...p.onlyProjectId ? { projectId: p.onlyProjectId } : {},
334
+ ...p.types !== void 0 ? { types: parseTyped("types", z.array(KnowledgePageTypeSchema), p.types) } : {},
335
+ ...p.themeIds !== void 0 ? { themeIds: parseTyped("themeIds", KnowledgeThemeIdsSchema, p.themeIds) } : {},
336
+ ...p.themeDepth !== void 0 ? { themeDepth: parseTyped("themeDepth", kThemeDepth, p.themeDepth) } : {},
337
+ ...p.spaceIds !== void 0 ? { spaceIds: parseTyped("spaceIds", kIds, p.spaceIds) } : {},
338
+ ...p.includeObsolete !== void 0 ? { includeObsolete: parseTyped("includeObsolete", z.boolean(), p.includeObsolete) } : {},
339
+ ...p.limit !== void 0 ? { limit: parseTyped("limit", kSearchLimit, p.limit) } : {},
340
+ ...p.cursor !== void 0 ? { cursor: p.cursor } : {}
341
+ }),
342
+ // Les thèmes une seule fois, en tête : chaque résultat ne porte que leurs ids.
343
+ transformOutput: (result) => {
344
+ if (!isRec(result) || !Array.isArray(result.hits)) return result;
345
+ const themes = {};
346
+ const hits = result.hits.map((h) => {
347
+ const ids = Array.isArray(h.themes) ? h.themes.map((t) => {
348
+ themes[String(t.id)] = t.title;
349
+ return t.id;
350
+ }) : [];
351
+ return { ...h, themes: ids };
352
+ });
353
+ return { ...result, themes, hits };
354
+ }
355
+ },
356
+ {
357
+ name: "knowledge_list_themes",
358
+ description: "List the theme pages: each theme id, title, its broader themes (parentIds) and how many pages carry it. Themes form a hierarchy from broad to precise; use their ids in knowledge_search themeIds to cross pages by subject. A theme with similarTo has an almost identical title to those themes: probably a duplicate, prefer the one with the most pages.",
359
+ route: "knowledge.listThemes",
360
+ method: "GET",
361
+ params: [
362
+ { name: "spaceId", description: "Only the themes of this space", required: false },
363
+ { name: "organizationId", description: "The organization. Optional when the machine has one.", required: false }
364
+ ],
365
+ buildInput: (p) => ({ ...p.organizationId ? { organizationId: p.organizationId } : {}, ...p.spaceId ? { spaceId: p.spaceId } : {} })
366
+ },
367
+ {
368
+ name: "knowledge_get_page",
369
+ description: "Read one knowledge page: type, fields, summary, aliases, themes, sources, its sections in Markdown, links in both directions (each linked page once, with all its link kinds), what replaces it, and whether it is locked. Links to other pages in the body are written [title](kb:<pageId>).",
370
+ route: "knowledge.getPage",
371
+ method: "GET",
372
+ params: [
373
+ { name: "pageId", description: "The page id", required: true },
374
+ { name: "heading", description: "Read only this section (heading, case and accents ignored); the others are listed by heading", required: false }
375
+ ],
376
+ buildInput: (p) => ({ pageId: p.pageId, ...p.heading !== void 0 ? { heading: p.heading } : {} }),
377
+ transformOutput: readPageAnswer
378
+ },
379
+ {
380
+ name: "knowledge_get_neighbors",
381
+ description: "Walk the graph around a page, both directions, 1 to 3 hops: the pages reached (nearest first, with their distance and summary) and the edges between them. Obsolete pages are left out unless includeObsolete. Edge kinds: explicit relations, theme (a page and its theme), mentions (a [title](kb:id) link in a body), superseded_by.",
382
+ route: "knowledge.getNeighbors",
383
+ method: "GET",
384
+ params: [
385
+ { name: "pageId", description: "The starting page", required: true },
386
+ { name: "depth", description: `Number of hops, 1 to ${KNOWLEDGE_LIMITS.neighborsDepth} (default 1)`, required: false, schema: kDepth },
387
+ { name: "kinds", description: "Only follow these edge kinds", required: false, schema: z.array(KnowledgeEdgeKindSchema) },
388
+ { name: "limit", description: "At most this many pages, nearest first (default all)", required: false, schema: kNeighborLimit },
389
+ { name: "includeObsolete", description: "Also return obsolete pages (left out by default)", required: false, schema: z.boolean() }
390
+ ],
391
+ buildInput: (p) => ({
392
+ pageId: p.pageId,
393
+ ...p.depth !== void 0 ? { depth: parseTyped("depth", kDepth, p.depth) } : {},
394
+ ...p.kinds !== void 0 ? { kinds: parseTyped("kinds", z.array(KnowledgeEdgeKindSchema), p.kinds) } : {},
395
+ ...p.limit !== void 0 ? { limit: parseTyped("limit", kNeighborLimit, p.limit) } : {},
396
+ ...p.includeObsolete !== void 0 ? { includeObsolete: parseTyped("includeObsolete", z.boolean(), p.includeObsolete) } : {}
397
+ }),
398
+ transformOutput: (result, input) => {
399
+ if (!isRec(result) || !Array.isArray(result.nodes)) return result;
400
+ const limit = isRec(input) && typeof input.limit === "number" ? input.limit : void 0;
401
+ const all = result.nodes.map(slimThemes);
402
+ const nodes = limit === void 0 ? all : all.slice(0, limit + 1);
403
+ const kept = new Set(nodes.map((n) => n.id));
404
+ const merged = /* @__PURE__ */ new Map();
405
+ for (const e of Array.isArray(result.edges) ? result.edges : []) {
406
+ if (!kept.has(e.from) || !kept.has(e.to)) continue;
407
+ const key = `${String(e.from)}>${String(e.to)}`;
408
+ const seen = merged.get(key);
409
+ if (seen) seen.kinds.push(e.kind);
410
+ else merged.set(key, { from: e.from, to: e.to, kinds: [e.kind] });
411
+ }
412
+ const edges = [...merged.values()];
413
+ return { ...result, nodes, edges, truncated: Boolean(result.truncated) || nodes.length < all.length, omitted: all.length - nodes.length };
414
+ }
415
+ },
416
+ {
417
+ name: "knowledge_get_related",
418
+ description: "Find the pages closest to one or several pages, even without a direct link: score = 3 \xD7 direct links + 2 \xD7 shared themes + 1 \xD7 shared neighbors. Obsolete pages are left out unless includeObsolete. Use it to gather everything on a subject before answering or writing.",
419
+ route: "knowledge.getRelated",
420
+ method: "GET",
421
+ params: [
422
+ { name: "pageIds", description: "One to ten page ids", required: true, schema: kSeedIds },
423
+ { name: "limit", description: "At most this many pages (default 10)", required: false, schema: kRelatedLimit },
424
+ { name: "includeObsolete", description: "Also return obsolete pages (left out by default)", required: false, schema: z.boolean() }
425
+ ],
426
+ buildInput: (p) => ({
427
+ pageIds: parseTyped("pageIds", kSeedIds, p.pageIds),
428
+ ...p.limit !== void 0 ? { limit: parseTyped("limit", kRelatedLimit, p.limit) } : {},
429
+ ...p.includeObsolete !== void 0 ? { includeObsolete: parseTyped("includeObsolete", z.boolean(), p.includeObsolete) } : {}
430
+ }),
431
+ transformOutput: (result) => isRec(result) && Array.isArray(result.pages) ? { ...result, pages: result.pages.map(slimThemes) } : result
432
+ },
433
+ {
434
+ name: "knowledge_get_history",
435
+ description: "Read the history of a page: its versions, newest first, each with its date (at), its author (a person or an AI) and the number of changes. Each AI write is its own version; close edits by one person are grouped. Read the content of a version with knowledge_get_version.",
436
+ route: "knowledge.getHistory",
437
+ method: "GET",
438
+ params: [
439
+ { name: "pageId", description: "The page id", required: true },
440
+ { name: "limit", description: "At most this many versions, newest first (default all)", required: false, schema: kHistoryLimit }
441
+ ],
442
+ buildInput: (p) => ({ pageId: p.pageId, ...p.limit !== void 0 ? { limit: parseTyped("limit", kHistoryLimit, p.limit) } : {} }),
443
+ transformOutput: (result, input) => {
444
+ if (!isRec(result) || !Array.isArray(result.versions)) return result;
445
+ const limit = isRec(input) && typeof input.limit === "number" ? input.limit : void 0;
446
+ const all = result.versions.map((v) => {
447
+ const { from, ...rest } = v;
448
+ return from === v.at ? rest : v;
449
+ });
450
+ const versions = limit === void 0 ? all : all.slice(0, limit);
451
+ return { ...result, versions, omitted: all.length - versions.length };
452
+ }
453
+ },
454
+ {
455
+ name: "knowledge_get_version",
456
+ description: "Read a page as it was at a past date: title, summary, status, fields and sections in Markdown. Take the date (at) from knowledge_get_history. With compare, the answer also gives what changed since that version (sinceThen): changed paragraphs per section (previous = the version, paragraphs = now) and the sheet fields that differ. Restoring a version is left to people, in the app.",
457
+ route: "knowledge.getVersion",
458
+ method: "GET",
459
+ params: [
460
+ { name: "pageId", description: "The page id", required: true },
461
+ { name: "at", description: "The date of the version, as given by knowledge_get_history (ISO 8601)", required: true, schema: z.iso.datetime() },
462
+ { name: "heading", description: "Read only this section of the version", required: false },
463
+ { name: "compare", description: "Also give what changed since this version (sinceThen)", required: false, schema: z.boolean() }
464
+ ],
465
+ buildInput: (p) => ({ pageId: p.pageId, at: parseTyped("at", z.iso.datetime(), p.at), ...p.heading !== void 0 ? { heading: p.heading } : {}, ...p.compare !== void 0 ? { compare: parseTyped("compare", z.boolean(), p.compare) } : {} }),
466
+ transformOutput: (result, input) => {
467
+ if (!isRec(result) || !isRec(result.snapshot)) return result;
468
+ const { markdown: _markdown, ...snapshot } = result.snapshot;
469
+ const extra = result.sinceThen === void 0 ? {} : { sinceThen: result.sinceThen };
470
+ const heading = isRec(input) && typeof input.heading === "string" ? input.heading : void 0;
471
+ if (heading === void 0) return { snapshot, ...extra };
472
+ const sections = Array.isArray(snapshot.sections) ? snapshot.sections : [];
473
+ return { snapshot: { ...snapshot, sections: sectionNamed(sections, heading) }, ...extra };
474
+ }
475
+ },
476
+ {
477
+ name: "knowledge_create_page",
478
+ description: `Create a knowledge page. Search first: update an existing page rather than creating a duplicate. The answer lists pages with an almost identical title (similar): if one is the same subject, mark the new page obsolete and complete the existing one. Give a precise title, a one or two sentence summary (it is what searches show), aliases (other names people use), themes and links. Sections default to those of the type; give your own as [{"heading","markdown"}]. Cite other pages in Markdown as [title](kb:<pageId>). Types: ${KNOWLEDGE_TYPES_DOC}`,
479
+ route: "knowledge.createPage",
480
+ method: "POST",
481
+ params: [
482
+ { name: "spaceId", description: "The space, from knowledge_list_spaces", required: true },
483
+ { name: "type", description: `One of ${KNOWLEDGE_PAGE_TYPES.join(", ")}`, required: true, schema: KnowledgePageTypeSchema },
484
+ { name: "title", description: "Page title", required: true },
485
+ { name: "summary", description: "One or two sentences", required: true },
486
+ { name: "aliases", description: "Other names for the subject", required: false, schema: KnowledgeAliasesSchema },
487
+ { name: "fields", description: "The fields of the type, as an object", required: false, schema: KnowledgeFieldsSchema },
488
+ { name: "themeIds", description: "Theme page ids", required: false, schema: KnowledgeThemeIdsSchema },
489
+ { name: "projectIds", description: "Runeya project ids the page is about", required: false, schema: KnowledgeProjectIdsSchema },
490
+ { name: "sources", description: 'Where the knowledge comes from: [{"label","url"?}]', required: false, schema: KnowledgeSourcesSchema },
491
+ { name: "sections", description: 'Body sections: [{"heading","markdown"}]', required: false, schema: kSections },
492
+ { name: "links", description: `Links to other pages: [{"to","relation"}], relation among ${KNOWLEDGE_RELATIONS_DOC}`, required: false, schema: z.array(KnowledgeLinkSchema).max(200) },
493
+ { name: "locale", description: "Language of default section titles: fr or en", required: false, schema: KnowledgeLocaleSchema }
494
+ ],
495
+ buildInput: (p) => ({
496
+ spaceId: p.spaceId,
497
+ ...knowledgePageFields(p),
498
+ ...p.sections !== void 0 ? { sections: parseTyped("sections", kSections, p.sections) } : {},
499
+ ...p.links !== void 0 ? { links: parseTyped("links", z.array(KnowledgeLinkSchema).max(200), p.links) } : {},
500
+ ...p.locale !== void 0 ? { locale: parseTyped("locale", KnowledgeLocaleSchema, p.locale) } : {}
501
+ }),
502
+ transformOutput: writeAnswer((page) => ({ themes: slimThemes(page).themes, sections: headingsOf(page) }))
503
+ },
504
+ {
505
+ name: "knowledge_update_page",
506
+ description: `Change the card of a page: title, summary, type, aliases, fields (merged; an empty value clears a field), themes, projects, sources (lists replace the current ones), status. To retire a page, set supersededBy to the page replacing it (it becomes obsolete) or status to obsolete: you cannot delete pages. ${KNOWLEDGE_LOCK_NOTE}`,
507
+ route: "knowledge.updatePage",
508
+ method: "POST",
509
+ params: [
510
+ { name: "pageId", description: "The page id", required: true },
511
+ { name: "title", description: "New title", required: false },
512
+ { name: "summary", description: "New summary", required: false },
513
+ { name: "type", description: "New type", required: false, schema: KnowledgePageTypeSchema },
514
+ { name: "aliases", description: "Replaces the aliases", required: false, schema: KnowledgeAliasesSchema },
515
+ { name: "fields", description: "Fields to set or clear", required: false, schema: KnowledgeFieldsSchema },
516
+ { name: "themeIds", description: "Replaces the themes", required: false, schema: KnowledgeThemeIdsSchema },
517
+ { name: "projectIds", description: "Replaces the projects", required: false, schema: KnowledgeProjectIdsSchema },
518
+ { name: "sources", description: "Replaces the sources", required: false, schema: KnowledgeSourcesSchema },
519
+ { name: "status", description: "active or obsolete", required: false, schema: KnowledgeStatusSchema },
520
+ { name: "supersededBy", description: "The page replacing this one; null removes it", required: false, schema: KnowledgeIdSchema.nullable() }
521
+ ],
522
+ buildInput: (p) => ({
523
+ pageId: p.pageId,
524
+ ...knowledgePageFields(p),
525
+ ...p.status !== void 0 ? { status: parseTyped("status", KnowledgeStatusSchema, p.status) } : {},
526
+ ...p.supersededBy !== void 0 ? { supersededBy: parseTyped("supersededBy", KnowledgeIdSchema.nullable(), p.supersededBy) } : {}
527
+ }),
528
+ // Les seuls champs de la fiche que l'appel a donnés, tels qu'enregistrés.
529
+ transformOutput: writeAnswer((page, input) => Object.fromEntries(Object.keys(input).flatMap((key) => {
530
+ if (key === "pageId") return [];
531
+ if (key === "themeIds") return [["themes", slimThemes(page).themes]];
532
+ return [[key, page[key]]];
533
+ })))
534
+ },
535
+ {
536
+ name: "knowledge_update_section",
537
+ description: `Write one section of a page body, named by its heading (case and accents ignored): replace its content, append to it, or remove it. A heading that does not exist is an error listing the sections (often a typo); set create to true to add it at the end. An empty heading is the text before the first section. Inside the markdown, use ### or deeper for subheadings: a # or ## line is refused. Other sections are left untouched, including what a person is typing in them. ${KNOWLEDGE_LOCK_NOTE}`,
538
+ route: "knowledge.editSection",
539
+ method: "POST",
540
+ params: [
541
+ { name: "pageId", description: "The page id", required: true },
542
+ { name: "heading", description: "The section heading", required: true },
543
+ { name: "markdown", description: "The content, in Markdown (required unless mode is remove)", required: false },
544
+ { name: "mode", description: "replace (default), append or remove", required: false, schema: KnowledgeSectionModeSchema },
545
+ { name: "create", description: "Create the section at the end if no section has this heading", required: false, schema: z.boolean() }
546
+ ],
547
+ buildInput: (p) => {
548
+ const started = typeof p.markdown === "string" ? [...p.markdown.matchAll(/^#{1,2}\s+(.+)$/gm)].map((m) => m[1].trim()) : [];
549
+ if (started.length) {
550
+ throw new Error(`The markdown would start new sections (${started.map((h) => `"${h}"`).join(", ")}). Use ### or deeper for subheadings inside a section, or write each section with its own call.`);
551
+ }
552
+ return {
553
+ pageId: p.pageId,
554
+ heading: p.heading ?? "",
555
+ ...p.markdown !== void 0 ? { markdown: p.markdown } : {},
556
+ ...p.mode !== void 0 ? { mode: parseTyped("mode", KnowledgeSectionModeSchema, p.mode) } : {},
557
+ ...p.create !== void 0 ? { create: parseTyped("create", z.boolean(), p.create) } : {}
558
+ };
559
+ },
560
+ transformOutput: writeAnswer((page, input) => {
561
+ const heading = typeof input.heading === "string" ? input.heading : "";
562
+ const sections = Array.isArray(page.sections) ? page.sections : [];
563
+ return {
564
+ section: sections.find((x) => foldText(String(x.heading)) === foldText(heading)) ?? null,
565
+ otherSections: headingsOf(page).filter((h) => foldText(h) !== foldText(heading))
566
+ };
567
+ })
568
+ },
569
+ {
570
+ name: "knowledge_edit_text",
571
+ description: `Replace an exact passage of a page body, like a text editor: send only the old text and the new one, not the whole section. The passage is matched against the Markdown returned by knowledge_get_page (so bold is **\u2026**, a page link is [title](kb:id)) and must appear exactly once, in the given section or in the whole body; otherwise nothing is written and the error says whether it is missing or ambiguous. The answer gives the page id, title, status, lock and last update and, for each edited section, only the paragraphs that are new or changed, their previous version and how many were deleted without replacement (editedSections); the other sections are listed by heading, and the rest of the sheet (themes, fields, links) is left out: read it with knowledge_get_page. Prefer it to knowledge_update_section for a change inside a long section. To insert text, anchor on the words around the insertion point: to complete "We chose Mongo." send find "We chose Mongo." and replace "We chose Mongo for its flexibility.". ${KNOWLEDGE_LOCK_NOTE}`,
572
+ route: "knowledge.editText",
573
+ method: "POST",
574
+ params: [
575
+ { name: "pageId", description: "The page id", required: true },
576
+ { name: "find", description: "The exact text to replace, as it appears in the page Markdown. Include enough surrounding words for it to be unique.", required: true },
577
+ { name: "replace", description: "The new text (empty to delete the passage)", required: true },
578
+ { name: "heading", description: "Look only in this section (heading, case and accents ignored; empty = text before the first section)", required: false },
579
+ { name: "all", description: "Replace every occurrence instead of requiring a unique one", required: false, schema: z.boolean() }
580
+ ],
581
+ buildInput: (p) => ({
582
+ pageId: p.pageId,
583
+ find: p.find,
584
+ replace: p.replace ?? "",
585
+ ...p.heading !== void 0 ? { heading: p.heading } : {},
586
+ ...p.all !== void 0 ? { all: parseTyped("all", z.boolean(), p.all) } : {}
587
+ }),
588
+ transformOutput: editedSectionOnly
589
+ },
590
+ {
591
+ name: "knowledge_link_pages",
592
+ description: `Declare a link from a page to another: ${KNOWLEDGE_RELATIONS_DOC}. The link belongs to the starting page, so you may link to a locked page. The answer says whether the link already existed (alreadyLinked). ${KNOWLEDGE_LOCK_NOTE}`,
593
+ route: "knowledge.link",
594
+ method: "POST",
595
+ params: [
596
+ { name: "pageId", description: "The starting page", required: true },
597
+ { name: "to", description: "The target page", required: true },
598
+ { name: "relation", description: KNOWLEDGE_RELATIONS.join(", "), required: true, schema: KnowledgeRelationSchema }
599
+ ],
600
+ buildInput: (p) => ({ pageId: p.pageId, to: p.to, relation: parseTyped("relation", KnowledgeRelationSchema, p.relation) }),
601
+ transformOutput: writeAnswer((page) => ({ outgoingLinks: mergedLinks(isRec(page.links) ? page.links.outgoing : []) }))
602
+ },
603
+ {
604
+ name: "knowledge_unlink_pages",
605
+ description: `Remove a link declared by a page; without relation, every declared link to the target. The answer says how many were removed (removed). A mentions link comes from a [title](kb:id) in the body: remove it by editing the text (knowledge_edit_text), not with this tool. ${KNOWLEDGE_LOCK_NOTE}`,
606
+ route: "knowledge.unlink",
607
+ method: "POST",
608
+ params: [
609
+ { name: "pageId", description: "The starting page", required: true },
610
+ { name: "to", description: "The target page", required: true },
611
+ { name: "relation", description: `${KNOWLEDGE_RELATIONS.join(", ")}. Omit it to remove every declared link to the target page.`, required: false, schema: KnowledgeRelationSchema }
612
+ ],
613
+ buildInput: (p) => ({ pageId: p.pageId, to: p.to, ...p.relation !== void 0 ? { relation: parseTyped("relation", KnowledgeRelationSchema, p.relation) } : {} }),
614
+ transformOutput: writeAnswer((page) => ({ outgoingLinks: mergedLinks(isRec(page.links) ? page.links.outgoing : []) }))
615
+ }
616
+ ];
161
617
  var RUNEYA_CAPABILITIES = [
162
618
  {
163
619
  name: "list_services",
@@ -950,7 +1406,8 @@ var RUNEYA_CAPABILITIES = [
950
1406
  method: "GET",
951
1407
  params: [],
952
1408
  buildInput: () => void 0
953
- }
1409
+ },
1410
+ ...KNOWLEDGE_CAPABILITIES
954
1411
  ];
955
1412
 
956
1413
  // ../../packages/ai-capabilities/src/adapters/json-schema.ts
@@ -1060,4 +1517,4 @@ export {
1060
1517
  runCapability,
1061
1518
  applyProjectAnchor
1062
1519
  };
1063
- //# sourceMappingURL=chunk-QD2OVLK4.js.map
1520
+ //# sourceMappingURL=chunk-LUFAT2NW.js.map