@runeya/runeya 2.0.158 → 2.0.159

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 (148) hide show
  1. package/agent/index.js +318 -231
  2. package/agent/index.js.map +1 -1
  3. package/agent-manager-NR24TCUQ.js +13 -0
  4. package/chat-MRS24DL3.js +28 -0
  5. package/{chunk-SVKR7CYU.js → chunk-C3KBWZ24.js} +4 -4
  6. package/{chunk-TMX3NXMQ.js → chunk-GJ5KN2LL.js} +6 -6
  7. package/{chunk-DVECWRFG.js → chunk-GPSTFDKW.js} +18 -18
  8. package/{chunk-L3BEQ75K.js → chunk-JJTSWJXV.js} +5 -5
  9. package/{chunk-N4ZP7T6L.js → chunk-KNWWJND3.js} +4 -4
  10. package/{chunk-NV7MBTNW.js → chunk-KWKSPNGO.js} +5 -5
  11. package/{chunk-EZ35ISYR.js → chunk-LY4HARY5.js} +172 -67
  12. package/chunk-LY4HARY5.js.map +1 -0
  13. package/{chunk-ETPXJSVC.js → chunk-UYOJZ34Z.js} +2 -2
  14. package/{chunk-4HN2AGBV.js → chunk-V7BOVXZI.js} +11 -11
  15. package/{chunk-N5LP5TPS.js → chunk-YEFYRGSP.js} +2 -2
  16. package/{chunk-JAMAGUGN.js → chunk-YEZOV6GP.js} +2 -2
  17. package/{chunk-V7WTXGEJ.js → chunk-ZW4GRZRF.js} +6 -6
  18. package/{chunk-SGFGQ2EL.js → chunk-ZZZQMQWF.js} +2 -2
  19. package/{companion-KVAOV52T.js → companion-CGBD5O6Y.js} +9 -9
  20. package/{desktop-installer-page-DCS2FLA5.js → desktop-installer-page-54PKY3L3.js} +3 -3
  21. package/{desktop-launcher-ER3J7KAW.js → desktop-launcher-2DWKSS6V.js} +3 -3
  22. package/{environment-resolver-HT6GTSLA.js → environment-resolver-E7JDNTRO.js} +6 -6
  23. package/{external-3QTRN4YV.js → external-5I5BUT44.js} +3 -3
  24. package/index.js +12 -12
  25. package/{install-gate-WZR3XSN6.js → install-gate-W5D4ZOZK.js} +2 -2
  26. package/mcp-server/external.js +145 -60
  27. package/mcp-server/external.js.map +1 -1
  28. package/mcp-server/index.js +145 -60
  29. package/mcp-server/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/{project-store-6TFAYAWK.js → project-store-67M34SNQ.js} +7 -7
  32. package/settings-manager-M5RS5WRM.js +10 -0
  33. package/{src-DBSSIQC7.js → src-FTYC7P2P.js} +36 -2
  34. package/{src-F5SK2AL3.js → src-UZX6XOIK.js} +1095 -897
  35. package/src-UZX6XOIK.js.map +1 -0
  36. package/{vault-resolver-G3G5YPNG.js → vault-resolver-5Q25S6NI.js} +3 -3
  37. package/web/assets/{AgentScalarChatInterface.vue-DgXKqqWC.js → AgentScalarChatInterface.vue-DLtiWyFa.js} +1 -1
  38. package/web/assets/{AgentTerminalPage-B_cExmB6.js → AgentTerminalPage-Ds4QAs67.js} +1 -1
  39. package/web/assets/{AiChatModals-CNyUOq-o.js → AiChatModals-Ccx5-MPb.js} +1 -1
  40. package/web/assets/AppLayout--wQ4AU4i.js +1 -0
  41. package/web/assets/AppLayout-Pi8OZrHN.css +1 -0
  42. package/web/assets/{AuditPage-C8f1gRUr.js → AuditPage-TlsfnK1U.js} +1 -1
  43. package/web/assets/{CloudAccountPage-BC45p4uK.js → CloudAccountPage-BuFn-iaB.js} +1 -1
  44. package/web/assets/{CloudMessagingPage-BCEZdgoe.js → CloudMessagingPage-BcOTKWP1.js} +1 -1
  45. package/web/assets/{DashboardPage-CGtK_iBU.js → DashboardPage-BLw_tc_p.js} +1 -1
  46. package/web/assets/{DirectoryPickerDialog-Ciy6QiOl.js → DirectoryPickerDialog-X6P-Gl27.js} +1 -1
  47. package/web/assets/{EditorIcon-Cx11i-sC.js → EditorIcon-DYGui0zm.js} +1 -1
  48. package/web/assets/{EnvironmentForm-Dm5RBLw3.js → EnvironmentForm-CNxgYejU.js} +1 -1
  49. package/web/assets/{EnvironmentFormPage-tEpeq4it.js → EnvironmentFormPage-Cu9tmfeS.js} +1 -1
  50. package/web/assets/{EnvironmentListPage-D8ppIAWE.js → EnvironmentListPage-RJc8Noj0.js} +1 -1
  51. package/web/assets/{FlagChip-UumVjPY9.js → FlagChip-DBj0fpJC.js} +1 -1
  52. package/web/assets/{KanbanBoardPage-CamUcYCQ.js → KanbanBoardPage-CfeFN-sn.js} +3 -3
  53. package/web/assets/{KanbanListPage-C_DZwAKD.js → KanbanListPage-Bvf_6sKr.js} +1 -1
  54. package/web/assets/{KnowledgeListPage-BBhzvW-h.js → KnowledgeListPage-8asAbOWR.js} +1 -1
  55. package/web/assets/{KnowledgePagePage-Bnnhyxfi.js → KnowledgePagePage-CH8ErT7E.js} +1 -1
  56. package/web/assets/{LaunchProjectPage-BHbOO-qr.js → LaunchProjectPage-Cj4zIh-L.js} +1 -1
  57. package/web/assets/{LaunchServicesPage-CrKG4CUc.js → LaunchServicesPage-C5yBRgjj.js} +1 -1
  58. package/web/assets/{LaunchShell-BHgU9IFB.js → LaunchShell-BHRT0Iyo.js} +1 -1
  59. package/web/assets/{LogViewer-DeTRyWSh.js → LogViewer-B-iEIEx5.js} +1 -1
  60. package/web/assets/{OrgKeyPrompt-CmHBAJRR.js → OrgKeyPrompt-U4dh8VYn.js} +1 -1
  61. package/web/assets/{ProcessControls-Bs5rpuyG.js → ProcessControls-DR2mGg4A.js} +1 -1
  62. package/web/assets/{ProcessDetailPage-BouE6rnn.js → ProcessDetailPage-UdlOtobk.js} +1 -1
  63. package/web/assets/{ProcessMetrics-DisQYLu6.js → ProcessMetrics-CAiB2nbb.js} +1 -1
  64. package/web/assets/{ProjectCreateDialog-CK-RH0wb.js → ProjectCreateDialog-JJ_UgVSV.js} +1 -1
  65. package/web/assets/{ProjectLocationGate-j_EaQ37h.js → ProjectLocationGate-RpWuVQOx.js} +1 -1
  66. package/web/assets/{ProjectPublishDialog-D7lTBCu_.js → ProjectPublishDialog-DXBAZVgF.js} +1 -1
  67. package/web/assets/{RandomJobTestPage-D11UxER3.js → RandomJobTestPage-BTyZOdQT.js} +1 -1
  68. package/web/assets/{ScenarioEditorPage-D0ZyVUSQ.js → ScenarioEditorPage-DO5s-Rb3.js} +1 -1
  69. package/web/assets/{SendToChatDialog-j61mBTkW.js → SendToChatDialog-jghvXDZk.js} +1 -1
  70. package/web/assets/{ServiceControlsBar-C2E_SEkD.js → ServiceControlsBar-Bjv9tyyt.js} +1 -1
  71. package/web/assets/{ServiceDetailPage-m_oJmvYC.js → ServiceDetailPage-DHYpDCfp.js} +1 -1
  72. package/web/assets/{ServiceFormPage-DyxF-esJ.js → ServiceFormPage-CCXaIoow.js} +1 -1
  73. package/web/assets/{SettingsPage-BLaufENl.js → SettingsPage-s-668z6W.js} +38 -38
  74. package/web/assets/{SettingsPage-Dsuzjo8r.css → SettingsPage-x-Rev6ea.css} +1 -1
  75. package/web/assets/{UnlockPage-BmKWcShW.js → UnlockPage-BNdzhO5C.js} +1 -1
  76. package/web/assets/{VaultMigrationPage-CScIzmKv.js → VaultMigrationPage-RWmGEMLC.js} +1 -1
  77. package/web/assets/{VersionBadge-yfgoumwX.js → VersionBadge-Crpf2R7o.js} +1 -1
  78. package/web/assets/{WikiPage-WQBT7wLD.js → WikiPage-BlemtaAo.js} +1 -1
  79. package/web/assets/{WikiView-CXXW1EZ1.js → WikiView-Du6Adpd-.js} +1 -1
  80. package/web/assets/{add-scalar-classes-C4A2C4Db.js → add-scalar-classes-B5tjvEi-.js} +1 -1
  81. package/web/assets/{agent.store-n7zoFDoU.js → agent.store-5ggNQfb3.js} +1 -1
  82. package/web/assets/{auth-Bh28S0O0.js → auth-ArDkSMsT.js} +2 -2
  83. package/web/assets/{cloud-chat.store-C4WdXFzT.js → cloud-chat.store-XJxdooyL.js} +1 -1
  84. package/web/assets/cloud-client-CMfTrHgZ.js +2 -0
  85. package/web/assets/{cloud-session-sF4HS72U.js → cloud-session-CHtF1SMt.js} +2 -2
  86. package/web/assets/dist-CjS_rxe9.js +1 -0
  87. package/web/assets/{i18n-B8hHo8g2.js → i18n-f_6x1GJ8.js} +2 -2
  88. package/web/assets/{index-DozDRY7J.css → index-DiXnhxxp.css} +1 -1
  89. package/web/assets/{index-Ccvk-qRh.js → index-Z4n9BqGD.js} +5 -5
  90. package/web/assets/{knowledge-host-97o7-gG1.js → knowledge-host-DeJwAH8b.js} +3 -3
  91. package/web/assets/{modal-BE_ZgM3t.js → modal-Bomcd8xq.js} +1 -1
  92. package/web/assets/{notification.store-BCON_qHz.js → notification.store-C8qNYGB5.js} +1 -1
  93. package/web/assets/{project-launch.store-Cd0LhFqV.js → project-launch.store-DBuxvZJr.js} +1 -1
  94. package/web/assets/{project.store-Doqh_upd.js → project.store-CXP-Oq1W.js} +1 -1
  95. package/web/assets/{scenario.store-Bttan_98.js → scenario.store-B6TiJlpU.js} +1 -1
  96. package/web/assets/{service.store-BtPdRbHy.js → service.store-oNOqRX_s.js} +1 -1
  97. package/web/assets/{settings-scope-BB3H0WrY.js → settings-scope-EYddCMQs.js} +1 -1
  98. package/web/assets/{settings.store-B51AlAcp.js → settings.store-Dbe4N-TD.js} +1 -1
  99. package/web/assets/{src-CcVk2-Gw.js → src-B1nAsOcw.js} +1 -1
  100. package/web/assets/{src-55L4GktS.js → src-BMnPg9V0.js} +1 -1
  101. package/web/assets/src-BR35jQnn.css +1 -0
  102. package/web/assets/src-BY3QUJ9Z.css +1 -0
  103. package/web/assets/src-Cpewe6v-.js +1 -0
  104. package/web/assets/{trpc-CcVyWYH-.js → trpc-CFd5DIpB.js} +3 -3
  105. package/web/assets/{useCloudOrg-43CkkppL.js → useCloudOrg-_oj_ijeT.js} +1 -1
  106. package/web/assets/{useEnvVarAutocomplete-DGB9ZE4S.js → useEnvVarAutocomplete-IIpGvDLc.js} +1 -1
  107. package/web/assets/{useProjectCatalog-BiDVlcdO.js → useProjectCatalog-DT8MiHr7.js} +1 -1
  108. package/web/assets/{useProjectCloudOrg-CjDX0EaT.js → useProjectCloudOrg-BgBNXoL1.js} +1 -1
  109. package/web/assets/{useServiceUrlHost-CVjTMrmw.js → useServiceUrlHost-CzDrWXfO.js} +1 -1
  110. package/web/assets/uuid-D2uso58z.js +1 -0
  111. package/web/index.html +19 -19
  112. package/agent-manager-KDL4JWZN.js +0 -13
  113. package/chat-H5KZT3O6.js +0 -28
  114. package/chunk-EZ35ISYR.js.map +0 -1
  115. package/settings-manager-OTVXDUJS.js +0 -10
  116. package/src-F5SK2AL3.js.map +0 -1
  117. package/web/assets/AppLayout-B1-D2-jx.css +0 -1
  118. package/web/assets/AppLayout-DPNVmCyo.js +0 -1
  119. package/web/assets/cloud-client-D7GDcRGa.js +0 -2
  120. package/web/assets/dist-Cx_klvkk.js +0 -1
  121. package/web/assets/src-16-vEwhK.css +0 -1
  122. package/web/assets/src-DOziuDw8.css +0 -1
  123. package/web/assets/src-IxogYJKL.js +0 -1
  124. package/web/assets/uuid-DfCowYZy.js +0 -1
  125. /package/{agent-manager-KDL4JWZN.js.map → agent-manager-NR24TCUQ.js.map} +0 -0
  126. /package/{chat-H5KZT3O6.js.map → chat-MRS24DL3.js.map} +0 -0
  127. /package/{chunk-SVKR7CYU.js.map → chunk-C3KBWZ24.js.map} +0 -0
  128. /package/{chunk-TMX3NXMQ.js.map → chunk-GJ5KN2LL.js.map} +0 -0
  129. /package/{chunk-DVECWRFG.js.map → chunk-GPSTFDKW.js.map} +0 -0
  130. /package/{chunk-L3BEQ75K.js.map → chunk-JJTSWJXV.js.map} +0 -0
  131. /package/{chunk-N4ZP7T6L.js.map → chunk-KNWWJND3.js.map} +0 -0
  132. /package/{chunk-NV7MBTNW.js.map → chunk-KWKSPNGO.js.map} +0 -0
  133. /package/{chunk-ETPXJSVC.js.map → chunk-UYOJZ34Z.js.map} +0 -0
  134. /package/{chunk-4HN2AGBV.js.map → chunk-V7BOVXZI.js.map} +0 -0
  135. /package/{chunk-N5LP5TPS.js.map → chunk-YEFYRGSP.js.map} +0 -0
  136. /package/{chunk-JAMAGUGN.js.map → chunk-YEZOV6GP.js.map} +0 -0
  137. /package/{chunk-V7WTXGEJ.js.map → chunk-ZW4GRZRF.js.map} +0 -0
  138. /package/{chunk-SGFGQ2EL.js.map → chunk-ZZZQMQWF.js.map} +0 -0
  139. /package/{companion-KVAOV52T.js.map → companion-CGBD5O6Y.js.map} +0 -0
  140. /package/{desktop-installer-page-DCS2FLA5.js.map → desktop-installer-page-54PKY3L3.js.map} +0 -0
  141. /package/{desktop-launcher-ER3J7KAW.js.map → desktop-launcher-2DWKSS6V.js.map} +0 -0
  142. /package/{environment-resolver-HT6GTSLA.js.map → environment-resolver-E7JDNTRO.js.map} +0 -0
  143. /package/{external-3QTRN4YV.js.map → external-5I5BUT44.js.map} +0 -0
  144. /package/{install-gate-WZR3XSN6.js.map → install-gate-W5D4ZOZK.js.map} +0 -0
  145. /package/{project-store-6TFAYAWK.js.map → project-store-67M34SNQ.js.map} +0 -0
  146. /package/{settings-manager-OTVXDUJS.js.map → settings-manager-M5RS5WRM.js.map} +0 -0
  147. /package/{src-DBSSIQC7.js.map → src-FTYC7P2P.js.map} +0 -0
  148. /package/{vault-resolver-G3G5YPNG.js.map → vault-resolver-5Q25S6NI.js.map} +0 -0
@@ -67,16 +67,16 @@ import {
67
67
  soleAccountScope,
68
68
  startCliSession,
69
69
  vaultOfProject
70
- } from "./chunk-DVECWRFG.js";
71
- import "./chunk-SGFGQ2EL.js";
70
+ } from "./chunk-GPSTFDKW.js";
71
+ import "./chunk-ZZZQMQWF.js";
72
72
  import {
73
73
  environmentOverridesStore,
74
74
  environmentResolver,
75
75
  filterEnvForAi
76
- } from "./chunk-L3BEQ75K.js";
76
+ } from "./chunk-JJTSWJXV.js";
77
77
  import {
78
78
  settingsManager
79
- } from "./chunk-SVKR7CYU.js";
79
+ } from "./chunk-C3KBWZ24.js";
80
80
  import {
81
81
  CONVERSATIONS_DIRNAME,
82
82
  activeSessionRegistry,
@@ -97,14 +97,14 @@ import {
97
97
  stopClaudeTranscriptWatcher,
98
98
  stopCodexTranscriptWatcher,
99
99
  verifyJwt
100
- } from "./chunk-4HN2AGBV.js";
100
+ } from "./chunk-V7BOVXZI.js";
101
101
  import {
102
102
  LocalProjectRefusedError,
103
103
  ensureDataGitignore,
104
104
  holdsRuneyaProject,
105
105
  projectPathStore,
106
106
  projectStore
107
- } from "./chunk-V7WTXGEJ.js";
107
+ } from "./chunk-ZW4GRZRF.js";
108
108
  import {
109
109
  agentManager,
110
110
  agentSpawner,
@@ -116,10 +116,10 @@ import {
116
116
  scheduleSelfRestart,
117
117
  traefikManager,
118
118
  unregisterInstance
119
- } from "./chunk-TMX3NXMQ.js";
119
+ } from "./chunk-GJ5KN2LL.js";
120
120
  import {
121
121
  serviceStore
122
- } from "./chunk-NV7MBTNW.js";
122
+ } from "./chunk-KWKSPNGO.js";
123
123
  import {
124
124
  clearDetached,
125
125
  clearEncryptionKey,
@@ -147,7 +147,7 @@ import {
147
147
  setEncryptionKeyInMemory,
148
148
  setPendingLegacyKey,
149
149
  stableEncryptValue
150
- } from "./chunk-N4ZP7T6L.js";
150
+ } from "./chunk-KNWWJND3.js";
151
151
  import {
152
152
  decryptValueWith,
153
153
  encryptValueWith,
@@ -156,11 +156,13 @@ import {
156
156
  whichCommand
157
157
  } from "./chunk-OZBSOSAS.js";
158
158
  import {
159
+ atomicWriteJsonSecure,
159
160
  atomicWriteSecure,
161
+ readJsonFileSafe,
160
162
  renameWithRetry,
161
163
  resolveConversationRunDir,
162
164
  sweepStaleTempFiles
163
- } from "./chunk-JAMAGUGN.js";
165
+ } from "./chunk-YEZOV6GP.js";
164
166
  import "./chunk-MD3VW4HQ.js";
165
167
  import {
166
168
  allVaultRoots,
@@ -188,7 +190,7 @@ import {
188
190
  rememberOrgName,
189
191
  stampOrgCloud,
190
192
  vaultFor
191
- } from "./chunk-ETPXJSVC.js";
193
+ } from "./chunk-UYOJZ34Z.js";
192
194
  import {
193
195
  AGENT_LONG_FETCH_TIMEOUT,
194
196
  AGENT_STOP_FETCH_TIMEOUT,
@@ -216,10 +218,16 @@ import {
216
218
  MissingVariableReasonSchema,
217
219
  NotificationPreferencesSchema,
218
220
  SUPPORTED_EDITORS,
221
+ SUPPORT_THREAD_FULL,
219
222
  ScenarioGroupSchema,
220
223
  ScenarioNodeSchema,
221
224
  ServiceShortcutSchema,
222
225
  SettingsSchema,
226
+ SupportCreateInputSchema,
227
+ SupportCreatedSchema,
228
+ SupportReplyInputSchema,
229
+ SupportTicketSummarySchema,
230
+ SupportTicketViewSchema,
223
231
  TraefikConfigSchema,
224
232
  UpdateEnvironmentSchema,
225
233
  VariableOverrideSchema,
@@ -237,13 +245,13 @@ import {
237
245
  serviceSlug,
238
246
  suggestBuiltinReferences,
239
247
  writeEntity
240
- } from "./chunk-EZ35ISYR.js";
248
+ } from "./chunk-LY4HARY5.js";
241
249
 
242
250
  // ../server/src/create-server.ts
243
251
  import express from "express";
244
252
  import cors from "cors";
245
253
  import { createServer } from "http";
246
- import { join as join18, resolve as resolve4 } from "path";
254
+ import { join as join19, resolve as resolve4 } from "path";
247
255
  import { WebSocketServer } from "ws";
248
256
  import { createExpressMiddleware } from "@trpc/server/adapters/express";
249
257
  import { applyWSSHandler } from "@trpc/server/adapters/ws";
@@ -653,10 +661,138 @@ var changelogRouter = router({
653
661
  })
654
662
  });
655
663
 
656
- // ../server/src/trpc/routers/project.ts
664
+ // ../server/src/trpc/routers/support.ts
665
+ import { join as join2 } from "path";
657
666
  import { z as z5 } from "zod";
658
- import { dirname as dirname2, isAbsolute as isAbsolute2 } from "path";
659
667
  import { TRPCError as TRPCError3 } from "@trpc/server";
668
+ var TOKEN_HEADER = "x-support-token";
669
+ var tokensFile = () => join2(machineRoot(), "support-tickets.json");
670
+ async function readTokens() {
671
+ const raw = await readJsonFileSafe(tokensFile());
672
+ return Array.isArray(raw?.tickets) ? raw.tickets : [];
673
+ }
674
+ async function rememberToken(entry) {
675
+ const current2 = await readTokens();
676
+ await atomicWriteJsonSecure(tokensFile(), { tickets: [...current2, entry] });
677
+ }
678
+ function cloudBase() {
679
+ return getCloudApiUrl().replace(/\/+$/, "");
680
+ }
681
+ async function anonymousFetch(path, body, token) {
682
+ return fetch(`${cloudBase()}${path}`, {
683
+ method: "POST",
684
+ headers: {
685
+ "Content-Type": "application/json",
686
+ [APP_VERSION_HEADER]: appVersion,
687
+ ...token ? { [TOKEN_HEADER]: token } : {}
688
+ },
689
+ body: JSON.stringify(body),
690
+ signal: AbortSignal.timeout(15e3)
691
+ });
692
+ }
693
+ async function readJson(res) {
694
+ if (res.status === 404) throw new TRPCError3({ code: "NOT_FOUND", message: "Ticket not found." });
695
+ if (res.status === 429) throw new TRPCError3({ code: "TOO_MANY_REQUESTS", message: "Too many requests, try again later." });
696
+ if (res.status === 400) {
697
+ const body = await res.json().catch(() => null);
698
+ if (body?.code === SUPPORT_THREAD_FULL) throw new TRPCError3({ code: "PRECONDITION_FAILED", message: SUPPORT_THREAD_FULL });
699
+ }
700
+ if (!res.ok) throw new TRPCError3({ code: "BAD_GATEWAY", message: `Support: HTTP ${res.status}` });
701
+ return res.json();
702
+ }
703
+ async function tokenFor(ticketId) {
704
+ const base = cloudBase();
705
+ return (await readTokens()).find((t) => t.ticketId === ticketId && t.cloudUrl === base)?.token;
706
+ }
707
+ async function listTickets(opts = {}) {
708
+ const results = [];
709
+ const accounts = await cloudSessionStore.list();
710
+ const Parsed = z5.object({ tickets: z5.array(SupportTicketSummarySchema) });
711
+ for (const account of accounts) {
712
+ try {
713
+ const res = await cloudFetch("/api/auth/support/ticket/list", { accountId: account.id });
714
+ for (const t of Parsed.parse(await readJson(res)).tickets) results.push({ ...t, accountId: account.id });
715
+ } catch (err) {
716
+ const absent = err instanceof TRPCError3 && err.code === "NOT_FOUND";
717
+ if (opts.strict && !absent) throw err;
718
+ if (!absent) console.warn("[support] list failed for an account:", err instanceof Error ? err.message : err);
719
+ }
720
+ }
721
+ const base = cloudBase();
722
+ const tokens = (await readTokens()).filter((t) => t.cloudUrl === base).map((t) => t.token);
723
+ for (let i = 0; i < tokens.length; i += 50) {
724
+ const res = await anonymousFetch("/api/auth/support/ticket/list-by-token", { tokens: tokens.slice(i, i + 50) });
725
+ for (const t of Parsed.parse(await readJson(res)).tickets) results.push({ ...t, accountId: null });
726
+ }
727
+ const seen = /* @__PURE__ */ new Set();
728
+ return results.filter((t) => seen.has(t.id) ? false : (seen.add(t.id), true)).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
729
+ }
730
+ async function anonymousTicketsStamp() {
731
+ const base = cloudBase();
732
+ const tokens = (await readTokens()).filter((t) => t.cloudUrl === base).map((t) => t.token);
733
+ const Parsed = z5.object({ tickets: z5.array(SupportTicketSummarySchema) });
734
+ const parts = [];
735
+ for (let i = 0; i < tokens.length; i += 50) {
736
+ const res = await anonymousFetch("/api/auth/support/ticket/list-by-token", { tokens: tokens.slice(i, i + 50) });
737
+ for (const t of Parsed.parse(await readJson(res)).tickets) parts.push(`${t.id}@${t.updatedAt}`);
738
+ }
739
+ return parts.sort().join("|");
740
+ }
741
+ var AccountRef = z5.object({ accountId: z5.string().max(512).optional() });
742
+ var TicketRef = AccountRef.extend({ id: z5.string().uuid() });
743
+ var supportRouter = router({
744
+ /** Les comptes cloud du poste, pour choisir sous quel nom écrire. */
745
+ accounts: protectedProcedure.query(async () => {
746
+ const accounts = await cloudSessionStore.list();
747
+ return accounts.map((a) => ({ id: a.id, email: a.email, name: a.name }));
748
+ }),
749
+ create: protectedProcedure.input(SupportCreateInputSchema.omit({ source: true }).merge(AccountRef)).mutation(async ({ input }) => {
750
+ const { accountId, ...fields } = input;
751
+ const body = { ...fields, source: "app" };
752
+ if (accountId) {
753
+ const res = await cloudFetch("/api/auth/support/ticket/create", { method: "POST", body, accountId });
754
+ return SupportCreatedSchema.parse(await readJson(res)).ticket;
755
+ }
756
+ if ((await cloudSessionStore.list()).length) {
757
+ throw new TRPCError3({ code: "BAD_REQUEST", message: "A cloud account is linked: send the request with it." });
758
+ }
759
+ if (!fields.email) throw new TRPCError3({ code: "BAD_REQUEST", message: "An email is required without an account." });
760
+ const created = SupportCreatedSchema.parse(await readJson(await anonymousFetch("/api/auth/support/ticket/create", body)));
761
+ if (created.accessToken) {
762
+ await rememberToken({ cloudUrl: cloudBase(), ticketId: created.ticket.id, token: created.accessToken });
763
+ }
764
+ return created.ticket;
765
+ }),
766
+ /** Les demandes de ce poste : celles des comptes liés, et celles envoyées sans compte. */
767
+ list: protectedProcedure.query(() => listTickets()),
768
+ /** Le nombre de demandes avec une réponse non lue : la pastille de la barre du bas. */
769
+ unreadCount: protectedProcedure.query(async () => {
770
+ try {
771
+ return (await listTickets({ strict: true })).filter((t) => t.unread).length;
772
+ } catch (err) {
773
+ console.warn("[support] unreadCount failed:", err instanceof Error ? err.message : err);
774
+ throw err;
775
+ }
776
+ }),
777
+ /** `peek` : consulter sans marquer comme lu (relecture sur signal, onglet caché). */
778
+ get: protectedProcedure.input(TicketRef.extend({ peek: z5.boolean().optional() })).query(async ({ input }) => {
779
+ const token = await tokenFor(input.id);
780
+ const body = { id: input.id, ...input.peek ? { peek: true } : {} };
781
+ const res = token || !input.accountId ? await anonymousFetch("/api/auth/support/ticket/get", body, token) : await cloudFetch("/api/auth/support/ticket/get", { method: "POST", body, accountId: input.accountId });
782
+ return z5.object({ ticket: SupportTicketViewSchema }).parse(await readJson(res)).ticket;
783
+ }),
784
+ reply: protectedProcedure.input(TicketRef.merge(SupportReplyInputSchema)).mutation(async ({ input }) => {
785
+ const token = await tokenFor(input.id);
786
+ const body = { id: input.id, body: input.body };
787
+ const res = token || !input.accountId ? await anonymousFetch("/api/auth/support/ticket/reply", body, token) : await cloudFetch("/api/auth/support/ticket/reply", { method: "POST", body, accountId: input.accountId });
788
+ return z5.object({ ticket: SupportTicketViewSchema }).parse(await readJson(res)).ticket;
789
+ })
790
+ });
791
+
792
+ // ../server/src/trpc/routers/project.ts
793
+ import { z as z6 } from "zod";
794
+ import { dirname as dirname2, isAbsolute as isAbsolute2 } from "path";
795
+ import { TRPCError as TRPCError4 } from "@trpc/server";
660
796
 
661
797
  // ../server/src/services/current-project.ts
662
798
  var current = null;
@@ -702,7 +838,7 @@ import { mkdir } from "fs/promises";
702
838
  // ../server/src/services/master-password.ts
703
839
  import { randomBytes, createCipheriv, createDecipheriv } from "crypto";
704
840
  import { readFile, writeFile, chmod, stat } from "fs/promises";
705
- import { join as join2 } from "path";
841
+ import { join as join3 } from "path";
706
842
  import { Entry } from "@napi-rs/keyring";
707
843
  import { hashRaw as argon2HashRaw } from "@node-rs/argon2";
708
844
  var KEYRING_SERVICE = "runeya";
@@ -735,7 +871,7 @@ function aesDecrypt(key, data) {
735
871
  }
736
872
  async function getPepperFromFile(dataDir) {
737
873
  try {
738
- const raw = await readKeyFile(join2(dataDir, PEPPER_FILENAME));
874
+ const raw = await readKeyFile(join3(dataDir, PEPPER_FILENAME));
739
875
  const hex = raw.toString("utf-8").trim();
740
876
  if (/^[0-9a-f]{64}$/i.test(hex)) return Buffer.from(hex, "hex");
741
877
  } catch {
@@ -743,7 +879,7 @@ async function getPepperFromFile(dataDir) {
743
879
  return null;
744
880
  }
745
881
  async function writePepperToFile(dataDir, pepper) {
746
- const filePath = join2(dataDir, PEPPER_FILENAME);
882
+ const filePath = join3(dataDir, PEPPER_FILENAME);
747
883
  const tmpPath = filePath + ".tmp";
748
884
  await writeFile(tmpPath, pepper.toString("hex"), "utf-8");
749
885
  await chmod(tmpPath, 384);
@@ -794,14 +930,14 @@ async function writeEncryptedKey(dataDir, masterPassword, encryptionKey, pepperD
794
930
  const payload = aesEncrypt(derivedKey, encryptionKey);
795
931
  const fileContent = Buffer.concat([salt, payload]);
796
932
  const encoded = fileContent.toString("base64");
797
- const filePath = join2(dataDir, ENCRYPTED_KEY_FILENAME);
933
+ const filePath = join3(dataDir, ENCRYPTED_KEY_FILENAME);
798
934
  const tmpPath = filePath + ".tmp";
799
935
  await writeFile(tmpPath, encoded, "utf-8");
800
936
  await chmod(tmpPath, 384);
801
937
  await renameWithRetry(tmpPath, filePath);
802
938
  }
803
939
  async function readEncryptedKey(dataDir, masterPassword, pepperDir = dataDir) {
804
- const filePath = join2(dataDir, ENCRYPTED_KEY_FILENAME);
940
+ const filePath = join3(dataDir, ENCRYPTED_KEY_FILENAME);
805
941
  const raw = await readKeyFile(filePath);
806
942
  const fileContent = Buffer.from(raw.toString("utf-8").trim(), "base64");
807
943
  const salt = fileContent.subarray(0, 16);
@@ -821,13 +957,13 @@ async function getPepperFromKeychain(dataDir) {
821
957
  }
822
958
  async function writeVerifyFile(dataDir, encryptionKey) {
823
959
  const payload = aesEncrypt(encryptionKey, Buffer.from(CANARY_PLAINTEXT, "utf-8"));
824
- const filePath = join2(dataDir, VERIFY_FILENAME);
960
+ const filePath = join3(dataDir, VERIFY_FILENAME);
825
961
  const tmpPath = filePath + ".tmp";
826
962
  await writeFile(tmpPath, payload.toString("base64"), "utf-8");
827
963
  await renameWithRetry(tmpPath, filePath);
828
964
  }
829
965
  async function verifyEncryptionKey(dataDir, encryptionKey) {
830
- const filePath = join2(dataDir, VERIFY_FILENAME);
966
+ const filePath = join3(dataDir, VERIFY_FILENAME);
831
967
  const raw = await readKeyFile(filePath);
832
968
  if (!matchesCanary(raw.toString("utf-8"), encryptionKey)) {
833
969
  throw new Error("Cl\xE9 d'encryption incorrecte");
@@ -843,14 +979,14 @@ function matchesCanary(canaryBase64, encryptionKey) {
843
979
  }
844
980
  async function readVerifyFile(dataDir) {
845
981
  try {
846
- return (await readKeyFile(join2(dataDir, VERIFY_FILENAME))).toString("utf-8").trim();
982
+ return (await readKeyFile(join3(dataDir, VERIFY_FILENAME))).toString("utf-8").trim();
847
983
  } catch {
848
984
  return null;
849
985
  }
850
986
  }
851
987
  async function hasVerifyFile(dataDir) {
852
988
  try {
853
- await stat(join2(dataDir, VERIFY_FILENAME));
989
+ await stat(join3(dataDir, VERIFY_FILENAME));
854
990
  return true;
855
991
  } catch {
856
992
  return false;
@@ -858,7 +994,7 @@ async function hasVerifyFile(dataDir) {
858
994
  }
859
995
  async function hasEncryptedKeyFile(dataDir) {
860
996
  try {
861
- await stat(join2(dataDir, ENCRYPTED_KEY_FILENAME));
997
+ await stat(join3(dataDir, ENCRYPTED_KEY_FILENAME));
862
998
  return true;
863
999
  } catch {
864
1000
  return false;
@@ -999,7 +1135,7 @@ async function assertReadable(orgId) {
999
1135
  await assertOrgVaultReadable(orgId);
1000
1136
  } catch (err) {
1001
1137
  if (err instanceof OrgVaultUnreadableError) {
1002
- throw new TRPCError3({ code: "FORBIDDEN", message: err.message });
1138
+ throw new TRPCError4({ code: "FORBIDDEN", message: err.message });
1003
1139
  }
1004
1140
  throw err;
1005
1141
  }
@@ -1019,10 +1155,10 @@ var projectRouter = router({
1019
1155
  * `orgId` names which project — the same id can exist in several
1020
1156
  * organizations. Left out, the id must answer for exactly one project.
1021
1157
  */
1022
- get: protectedProcedure.input(z5.object({ id: z5.string().max(128), orgId: z5.string().max(128).nullable().optional() })).query(async ({ input }) => {
1158
+ get: protectedProcedure.input(z6.object({ id: z6.string().max(128), orgId: z6.string().max(128).nullable().optional() })).query(async ({ input }) => {
1023
1159
  const project = await projectStore.get(input);
1024
1160
  if (!project) {
1025
- throw new TRPCError3({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1161
+ throw new TRPCError4({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1026
1162
  }
1027
1163
  await assertReadable(project.orgId);
1028
1164
  return project;
@@ -1033,23 +1169,23 @@ var projectRouter = router({
1033
1169
  * Environments are intentionally excluded — they carry secret values that
1034
1170
  * stay local.
1035
1171
  */
1036
- export: protectedProcedure.input(z5.object({ id: z5.string().max(128), orgId: z5.string().max(128).nullable().optional() })).query(async ({ input }) => {
1172
+ export: protectedProcedure.input(z6.object({ id: z6.string().max(128), orgId: z6.string().max(128).nullable().optional() })).query(async ({ input }) => {
1037
1173
  const project = await projectStore.get(input);
1038
1174
  if (!project) {
1039
- throw new TRPCError3({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1175
+ throw new TRPCError4({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1040
1176
  }
1041
1177
  await assertReadable(project.orgId);
1042
1178
  const services = (await Promise.all(project.serviceIds.map((sid) => serviceStore.getSanitized(sid)))).filter((s) => s !== null);
1043
1179
  return { project, services };
1044
1180
  }),
1045
1181
  create: protectedProcedure.input(
1046
- z5.object({
1047
- name: z5.string().min(1).max(200),
1048
- description: z5.string().max(1e4).optional(),
1049
- orgId: z5.string().max(128).nullable().optional(),
1050
- serviceIds: z5.array(z5.string().max(128)).max(1e4).optional(),
1182
+ z6.object({
1183
+ name: z6.string().min(1).max(200),
1184
+ description: z6.string().max(1e4).optional(),
1185
+ orgId: z6.string().max(128).nullable().optional(),
1186
+ serviceIds: z6.array(z6.string().max(128)).max(1e4).optional(),
1051
1187
  /** Le dossier d'un projet local. Omis : le dossier de lancement. */
1052
- localPath: z5.string().min(1).max(4096).refine(isAbsolute2, "Chemin absolu attendu").optional()
1188
+ localPath: z6.string().min(1).max(4096).refine(isAbsolute2, "Chemin absolu attendu").optional()
1053
1189
  })
1054
1190
  ).mutation(async ({ input }) => {
1055
1191
  const { localPath, ...fields } = input;
@@ -1063,9 +1199,9 @@ var projectRouter = router({
1063
1199
  }, fields.orgId ? void 0 : localPath);
1064
1200
  } catch (err) {
1065
1201
  if (err instanceof LocalProjectRefusedError) {
1066
- throw new TRPCError3({ code: "CONFLICT", message: err.code, cause: err });
1202
+ throw new TRPCError4({ code: "CONFLICT", message: err.code, cause: err });
1067
1203
  }
1068
- throw new TRPCError3({ code: "CONFLICT", message: err.message });
1204
+ throw new TRPCError4({ code: "CONFLICT", message: err.message });
1069
1205
  }
1070
1206
  const localEnv = await environmentStore.create({
1071
1207
  projectId: project.id,
@@ -1084,38 +1220,38 @@ var projectRouter = router({
1084
1220
  return result;
1085
1221
  }),
1086
1222
  update: protectedProcedure.input(
1087
- z5.object({
1088
- id: z5.string().max(128),
1089
- name: z5.string().min(1).max(200).optional(),
1090
- description: z5.string().max(1e4).optional(),
1091
- orgId: z5.string().max(128).nullable().optional(),
1092
- serviceIds: z5.array(z5.string().max(128)).max(1e4).optional(),
1093
- groupOrder: z5.array(z5.string().max(200)).max(100).optional()
1223
+ z6.object({
1224
+ id: z6.string().max(128),
1225
+ name: z6.string().min(1).max(200).optional(),
1226
+ description: z6.string().max(1e4).optional(),
1227
+ orgId: z6.string().max(128).nullable().optional(),
1228
+ serviceIds: z6.array(z6.string().max(128)).max(1e4).optional(),
1229
+ groupOrder: z6.array(z6.string().max(200)).max(100).optional()
1094
1230
  })
1095
1231
  ).mutation(async ({ input }) => {
1096
1232
  const project = await projectStore.update(input);
1097
1233
  if (!project) {
1098
- throw new TRPCError3({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1234
+ throw new TRPCError4({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1099
1235
  }
1100
1236
  await auditService.log({ userId: "local", action: "update", entityType: "project", entityId: input.id });
1101
1237
  return project;
1102
1238
  }),
1103
- delete: protectedProcedure.input(z5.object({ id: z5.string().max(128), orgId: z5.string().max(128).nullable().optional() })).mutation(async ({ input }) => {
1239
+ delete: protectedProcedure.input(z6.object({ id: z6.string().max(128), orgId: z6.string().max(128).nullable().optional() })).mutation(async ({ input }) => {
1104
1240
  const deleted = await projectStore.delete(input);
1105
1241
  if (!deleted) {
1106
- throw new TRPCError3({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1242
+ throw new TRPCError4({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1107
1243
  }
1108
1244
  await auditService.log({ userId: "local", action: "delete", entityType: "project", entityId: input.id });
1109
1245
  return { success: true };
1110
1246
  }),
1111
- addService: protectedProcedure.input(z5.object({
1112
- projectId: z5.string().max(128),
1113
- orgId: z5.string().max(128).nullable().optional(),
1114
- serviceId: z5.string().max(128)
1247
+ addService: protectedProcedure.input(z6.object({
1248
+ projectId: z6.string().max(128),
1249
+ orgId: z6.string().max(128).nullable().optional(),
1250
+ serviceId: z6.string().max(128)
1115
1251
  })).mutation(async ({ input }) => {
1116
1252
  const project = await attachServiceToProject({ id: input.projectId, orgId: input.orgId }, input.serviceId);
1117
1253
  if (!project) {
1118
- throw new TRPCError3({ code: "NOT_FOUND", message: `Project ${input.projectId} not found` });
1254
+ throw new TRPCError4({ code: "NOT_FOUND", message: `Project ${input.projectId} not found` });
1119
1255
  }
1120
1256
  await auditService.log({
1121
1257
  userId: "local",
@@ -1126,17 +1262,17 @@ var projectRouter = router({
1126
1262
  });
1127
1263
  return project;
1128
1264
  }),
1129
- removeService: protectedProcedure.input(z5.object({
1130
- projectId: z5.string().max(128),
1131
- orgId: z5.string().max(128).nullable().optional(),
1132
- serviceId: z5.string().max(128)
1265
+ removeService: protectedProcedure.input(z6.object({
1266
+ projectId: z6.string().max(128),
1267
+ orgId: z6.string().max(128).nullable().optional(),
1268
+ serviceId: z6.string().max(128)
1133
1269
  })).mutation(async ({ input }) => {
1134
1270
  const project = await projectStore.removeService(
1135
1271
  { id: input.projectId, orgId: input.orgId },
1136
1272
  input.serviceId
1137
1273
  );
1138
1274
  if (!project) {
1139
- throw new TRPCError3({ code: "NOT_FOUND", message: `Project ${input.projectId} not found` });
1275
+ throw new TRPCError4({ code: "NOT_FOUND", message: `Project ${input.projectId} not found` });
1140
1276
  }
1141
1277
  await auditService.log({
1142
1278
  userId: "local",
@@ -1147,21 +1283,21 @@ var projectRouter = router({
1147
1283
  });
1148
1284
  return project;
1149
1285
  }),
1150
- setActiveEnvironment: protectedProcedure.input(z5.object({
1151
- projectId: z5.string().max(128),
1152
- orgId: z5.string().max(128).nullable().optional(),
1153
- environmentId: z5.string().max(128)
1286
+ setActiveEnvironment: protectedProcedure.input(z6.object({
1287
+ projectId: z6.string().max(128),
1288
+ orgId: z6.string().max(128).nullable().optional(),
1289
+ environmentId: z6.string().max(128)
1154
1290
  })).mutation(async ({ input }) => {
1155
1291
  const project = await projectStore.get({ id: input.projectId, orgId: input.orgId });
1156
1292
  if (!project) {
1157
- throw new TRPCError3({ code: "NOT_FOUND", message: `Project ${input.projectId} not found` });
1293
+ throw new TRPCError4({ code: "NOT_FOUND", message: `Project ${input.projectId} not found` });
1158
1294
  }
1159
1295
  const environment = await environmentStore.get(input.environmentId);
1160
1296
  if (!environment) {
1161
- throw new TRPCError3({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
1297
+ throw new TRPCError4({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
1162
1298
  }
1163
1299
  if (environment.projectId !== input.projectId) {
1164
- throw new TRPCError3({ code: "FORBIDDEN", message: "Environment does not belong to this project" });
1300
+ throw new TRPCError4({ code: "FORBIDDEN", message: "Environment does not belong to this project" });
1165
1301
  }
1166
1302
  const runningServices = [];
1167
1303
  for (const serviceId of project.serviceIds) {
@@ -1186,7 +1322,7 @@ var projectRouter = router({
1186
1322
  input.environmentId
1187
1323
  );
1188
1324
  if (!updated) {
1189
- throw new TRPCError3({ code: "INTERNAL_SERVER_ERROR", message: "Failed to set active environment" });
1325
+ throw new TRPCError4({ code: "INTERNAL_SERVER_ERROR", message: "Failed to set active environment" });
1190
1326
  }
1191
1327
  for (const serviceId of project.serviceIds) {
1192
1328
  const service2 = await serviceStore.get(serviceId);
@@ -1235,7 +1371,7 @@ var projectRouter = router({
1235
1371
  * système s'en sert, pour montrer les services du projet ouvert plutôt que
1236
1372
  * ceux de toute la machine.
1237
1373
  */
1238
- setCurrent: protectedProcedure.input(z5.object({ id: z5.string().max(128), orgId: z5.string().max(128).nullable().default(null) }).nullable()).mutation(({ input }) => {
1374
+ setCurrent: protectedProcedure.input(z6.object({ id: z6.string().max(128), orgId: z6.string().max(128).nullable().default(null) }).nullable()).mutation(({ input }) => {
1239
1375
  setCurrentProject(input ? { id: input.id, orgId: input.orgId } : null);
1240
1376
  return { ok: true };
1241
1377
  }),
@@ -1251,13 +1387,13 @@ var projectRouter = router({
1251
1387
  * des secrets déchiffrés : elles servent à détecter la référence, et
1252
1388
  * s'arrêtent là.
1253
1389
  */
1254
- graph: protectedProcedure.input(z5.object({
1255
- id: z5.string().min(1).max(128),
1256
- orgId: z5.string().max(128).nullable().optional()
1390
+ graph: protectedProcedure.input(z6.object({
1391
+ id: z6.string().min(1).max(128),
1392
+ orgId: z6.string().max(128).nullable().optional()
1257
1393
  })).query(async ({ ctx, input }) => {
1258
1394
  const project = await projectStore.get(input);
1259
1395
  if (!project) {
1260
- throw new TRPCError3({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1396
+ throw new TRPCError4({ code: "NOT_FOUND", message: `Project ${input.id} not found` });
1261
1397
  }
1262
1398
  await assertReadable(project.orgId);
1263
1399
  const allowed = getAllowedServiceIds(ctx);
@@ -1298,14 +1434,14 @@ var projectRouter = router({
1298
1434
  * un outil IA lancé hors de Runeya (`runeya mcp`), qui sait seulement dans
1299
1435
  * quel dossier il tourne.
1300
1436
  */
1301
- containing: protectedProcedure.input(z5.object({ path: z5.string().min(1).max(4096) })).query(async ({ input }) => {
1437
+ containing: protectedProcedure.input(z6.object({ path: z6.string().min(1).max(4096) })).query(async ({ input }) => {
1302
1438
  const ref = projectContaining(await localProjectPaths(), input.path);
1303
1439
  const project = ref ? await projectStore.get(ref).catch(() => null) : null;
1304
1440
  return project ? { projectId: project.id, orgId: project.orgId ?? null, name: project.name } : null;
1305
1441
  }),
1306
- getLocalPath: protectedProcedure.input(z5.object({
1307
- id: z5.string().min(1).max(128),
1308
- orgId: z5.string().max(128).nullable().optional()
1442
+ getLocalPath: protectedProcedure.input(z6.object({
1443
+ id: z6.string().min(1).max(128),
1444
+ orgId: z6.string().max(128).nullable().optional()
1309
1445
  })).query(async ({ input }) => {
1310
1446
  return { path: await projectPathStore.get(input) };
1311
1447
  }),
@@ -1317,34 +1453,34 @@ var projectRouter = router({
1317
1453
  * makes services run against the wrong code.
1318
1454
  */
1319
1455
  /** Ajouter à la liste le projet local déjà présent dans un dossier. */
1320
- importLocal: protectedProcedure.input(z5.object({ path: z5.string().min(1).max(4096).refine(isAbsolute2, "Chemin absolu attendu") })).mutation(async ({ input }) => {
1456
+ importLocal: protectedProcedure.input(z6.object({ path: z6.string().min(1).max(4096).refine(isAbsolute2, "Chemin absolu attendu") })).mutation(async ({ input }) => {
1321
1457
  try {
1322
1458
  const project = await projectStore.importLocal(input.path);
1323
1459
  await auditService.log({ userId: "local", action: "update", entityType: "project", entityId: project.id, metadata: { importedFrom: input.path } });
1324
1460
  return project;
1325
1461
  } catch (err) {
1326
1462
  if (err instanceof LocalProjectRefusedError) {
1327
- throw new TRPCError3({ code: "CONFLICT", message: err.code, cause: err });
1463
+ throw new TRPCError4({ code: "CONFLICT", message: err.code, cause: err });
1328
1464
  }
1329
1465
  throw err;
1330
1466
  }
1331
1467
  }),
1332
- setLocalPath: protectedProcedure.input(z5.object({
1333
- id: z5.string().min(1).max(128),
1334
- orgId: z5.string().max(128).nullable().optional(),
1335
- path: z5.string().min(1).max(4096)
1468
+ setLocalPath: protectedProcedure.input(z6.object({
1469
+ id: z6.string().min(1).max(128),
1470
+ orgId: z6.string().max(128).nullable().optional(),
1471
+ path: z6.string().min(1).max(4096)
1336
1472
  })).mutation(async ({ input }) => {
1337
1473
  const project = await projectStore.get(input);
1338
- if (!project) throw new TRPCError3({ code: "NOT_FOUND", message: "Projet introuvable" });
1474
+ if (!project) throw new TRPCError4({ code: "NOT_FOUND", message: "Projet introuvable" });
1339
1475
  if (await holdsRuneyaProject(input.path)) {
1340
- throw new TRPCError3({
1476
+ throw new TRPCError4({
1341
1477
  code: "CONFLICT",
1342
1478
  message: "Ce r\xE9pertoire contient d\xE9j\xE0 un projet Runeya"
1343
1479
  });
1344
1480
  }
1345
1481
  const taken = await projectStore.projectAtPath(input.path, project);
1346
1482
  if (taken) {
1347
- throw new TRPCError3({
1483
+ throw new TRPCError4({
1348
1484
  code: "CONFLICT",
1349
1485
  message: "Un autre projet est d\xE9j\xE0 rattach\xE9 \xE0 ce r\xE9pertoire"
1350
1486
  });
@@ -1413,8 +1549,8 @@ var projectRouter = router({
1413
1549
  });
1414
1550
 
1415
1551
  // ../server/src/trpc/routers/agent.ts
1416
- import { z as z6 } from "zod";
1417
- import { TRPCError as TRPCError4 } from "@trpc/server";
1552
+ import { z as z7 } from "zod";
1553
+ import { TRPCError as TRPCError5 } from "@trpc/server";
1418
1554
  var SUBSCRIPTION_QUEUE_MAX = LOG_BUFFER_SIZE;
1419
1555
  var agentRouter = router({
1420
1556
  /** List all registered agents with their connection status */
@@ -1422,10 +1558,10 @@ var agentRouter = router({
1422
1558
  return agentManager.listAgents();
1423
1559
  }),
1424
1560
  /** Get a single agent's config and status */
1425
- get: protectedProcedure.input(z6.object({ id: z6.string().max(128) })).query(({ input }) => {
1561
+ get: protectedProcedure.input(z7.object({ id: z7.string().max(128) })).query(({ input }) => {
1426
1562
  const agent = agentManager.getAgent(input.id);
1427
1563
  if (!agent) {
1428
- throw new TRPCError4({ code: "NOT_FOUND", message: `Agent ${input.id} not found` });
1564
+ throw new TRPCError5({ code: "NOT_FOUND", message: `Agent ${input.id} not found` });
1429
1565
  }
1430
1566
  return {
1431
1567
  config: { ...agent.config, passphrase: "***" },
@@ -1434,10 +1570,10 @@ var agentRouter = router({
1434
1570
  }),
1435
1571
  /** Test connectivity to an agent given url + passphrase */
1436
1572
  testConnection: protectedProcedure.input(
1437
- z6.object({
1438
- url: z6.string().url().max(2048),
1439
- passphrase: z6.string().min(1).max(1024).optional(),
1440
- agentId: z6.string().max(128).optional()
1573
+ z7.object({
1574
+ url: z7.string().url().max(2048),
1575
+ passphrase: z7.string().min(1).max(1024).optional(),
1576
+ agentId: z7.string().max(128).optional()
1441
1577
  })
1442
1578
  ).mutation(async ({ input }) => {
1443
1579
  let passphrase = input.passphrase;
@@ -1445,13 +1581,13 @@ var agentRouter = router({
1445
1581
  if (!passphrase && input.agentId) {
1446
1582
  const agent = agentManager.getAgentConfig(input.agentId);
1447
1583
  if (!agent) {
1448
- throw new TRPCError4({ code: "NOT_FOUND", message: "Agent not found" });
1584
+ throw new TRPCError5({ code: "NOT_FOUND", message: "Agent not found" });
1449
1585
  }
1450
1586
  passphrase = agent.passphrase;
1451
1587
  targetUrl = agent.url;
1452
1588
  }
1453
1589
  if (!passphrase) {
1454
- throw new TRPCError4({ code: "BAD_REQUEST", message: "Passphrase is required" });
1590
+ throw new TRPCError5({ code: "BAD_REQUEST", message: "Passphrase is required" });
1455
1591
  }
1456
1592
  const url = new URL("/api/trpc/health.check", targetUrl);
1457
1593
  try {
@@ -1474,13 +1610,13 @@ var agentRouter = router({
1474
1610
  }),
1475
1611
  /** Register a new agent */
1476
1612
  register: protectedProcedure.input(
1477
- z6.object({
1478
- name: z6.string().min(1).max(100),
1479
- url: z6.string().url().max(2048),
1480
- passphrase: z6.string().min(1).max(1024),
1613
+ z7.object({
1614
+ name: z7.string().min(1).max(100),
1615
+ url: z7.string().url().max(2048),
1616
+ passphrase: z7.string().min(1).max(1024),
1481
1617
  // À quelle organisation rattacher l'agent. Absent = la machine, ce que
1482
1618
  // font l'agent local et tout client antérieur à ce champ.
1483
- orgId: z6.string().min(1).max(128).nullable().optional()
1619
+ orgId: z7.string().min(1).max(128).nullable().optional()
1484
1620
  })
1485
1621
  ).mutation(async ({ input }) => {
1486
1622
  const config = await agentManager.register(
@@ -1493,13 +1629,13 @@ var agentRouter = router({
1493
1629
  }),
1494
1630
  /** Update an existing agent */
1495
1631
  update: protectedProcedure.input(
1496
- z6.object({
1497
- id: z6.string().max(128),
1498
- name: z6.string().min(1).max(100).optional(),
1499
- url: z6.string().url().max(2048).optional(),
1500
- passphrase: z6.string().min(1).max(1024).optional(),
1501
- passthroughEnv: z6.array(
1502
- z6.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(256)
1632
+ z7.object({
1633
+ id: z7.string().max(128),
1634
+ name: z7.string().min(1).max(100).optional(),
1635
+ url: z7.string().url().max(2048).optional(),
1636
+ passphrase: z7.string().min(1).max(1024).optional(),
1637
+ passthroughEnv: z7.array(
1638
+ z7.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).max(256)
1503
1639
  ).max(100).optional()
1504
1640
  })
1505
1641
  ).mutation(async ({ input }) => {
@@ -1510,17 +1646,17 @@ var agentRouter = router({
1510
1646
  } catch (err) {
1511
1647
  if (err instanceof Error) {
1512
1648
  if (err.message.includes("not found")) {
1513
- throw new TRPCError4({ code: "NOT_FOUND", message: err.message });
1649
+ throw new TRPCError5({ code: "NOT_FOUND", message: err.message });
1514
1650
  }
1515
1651
  if (err.message.includes("Cannot modify")) {
1516
- throw new TRPCError4({ code: "FORBIDDEN", message: err.message });
1652
+ throw new TRPCError5({ code: "FORBIDDEN", message: err.message });
1517
1653
  }
1518
1654
  }
1519
1655
  throw err;
1520
1656
  }
1521
1657
  }),
1522
1658
  /** Get resolved passthrough env values from an agent */
1523
- getPassthroughEnv: protectedProcedure.input(z6.object({ id: z6.string().max(128) })).query(async ({ input }) => {
1659
+ getPassthroughEnv: protectedProcedure.input(z7.object({ id: z7.string().max(128) })).query(async ({ input }) => {
1524
1660
  try {
1525
1661
  return await agentManager.agentQuery(input.id, "config.getPassthroughEnv");
1526
1662
  } catch {
@@ -1528,16 +1664,16 @@ var agentRouter = router({
1528
1664
  }
1529
1665
  }),
1530
1666
  /** Remove a registered agent */
1531
- remove: protectedProcedure.input(z6.object({ id: z6.string().max(128) })).mutation(async ({ input }) => {
1667
+ remove: protectedProcedure.input(z7.object({ id: z7.string().max(128) })).mutation(async ({ input }) => {
1532
1668
  try {
1533
1669
  const removed = await agentManager.remove(input.id);
1534
1670
  if (!removed) {
1535
- throw new TRPCError4({ code: "NOT_FOUND", message: `Agent ${input.id} not found` });
1671
+ throw new TRPCError5({ code: "NOT_FOUND", message: `Agent ${input.id} not found` });
1536
1672
  }
1537
1673
  return { success: true };
1538
1674
  } catch (err) {
1539
1675
  if (err instanceof Error && err.message === "Cannot remove the local agent") {
1540
- throw new TRPCError4({ code: "FORBIDDEN", message: err.message });
1676
+ throw new TRPCError5({ code: "FORBIDDEN", message: err.message });
1541
1677
  }
1542
1678
  throw err;
1543
1679
  }
@@ -1575,16 +1711,16 @@ var agentRouter = router({
1575
1711
  });
1576
1712
 
1577
1713
  // ../server/src/trpc/routers/process.ts
1578
- import { z as z7 } from "zod";
1579
- import { TRPCError as TRPCError6 } from "@trpc/server";
1714
+ import { z as z8 } from "zod";
1715
+ import { TRPCError as TRPCError7 } from "@trpc/server";
1580
1716
 
1581
1717
  // ../server/src/services/process-control.ts
1582
- import { TRPCError as TRPCError5 } from "@trpc/server";
1718
+ import { TRPCError as TRPCError6 } from "@trpc/server";
1583
1719
  async function resolveTarget(processId, fallbackAgentId) {
1584
1720
  const service2 = await serviceStore.get(processId) ?? null;
1585
1721
  const agentId = (service2 ? await resolveEffectiveAgentId(service2) : null) ?? fallbackAgentId ?? null;
1586
1722
  if (!agentId) {
1587
- throw new TRPCError5({ code: "BAD_REQUEST", message: "NO_AGENT_FOR_SERVICE" });
1723
+ throw new TRPCError6({ code: "BAD_REQUEST", message: "NO_AGENT_FOR_SERVICE" });
1588
1724
  }
1589
1725
  return { agentId, service: service2 };
1590
1726
  }
@@ -1599,7 +1735,7 @@ async function callAgent(fn, fallbackMessage) {
1599
1735
  try {
1600
1736
  return await fn();
1601
1737
  } catch (err) {
1602
- throw new TRPCError5({
1738
+ throw new TRPCError6({
1603
1739
  code: "INTERNAL_SERVER_ERROR",
1604
1740
  message: isAgentUnreachable(err) ? "AGENT_UNREACHABLE" : err?.message ?? fallbackMessage
1605
1741
  });
@@ -1614,7 +1750,7 @@ async function assertEnvironmentComplete(service2) {
1614
1750
  activeEnvironmentId: project.activeEnvironmentId
1615
1751
  });
1616
1752
  if (missing.length === 0) return;
1617
- throw new TRPCError5({
1753
+ throw new TRPCError6({
1618
1754
  code: "PRECONDITION_FAILED",
1619
1755
  message: `Missing environment variables: ${missing.map((m) => m.key).join(", ")}`,
1620
1756
  cause: { missingVariables: missing, environmentId: project.activeEnvironmentId }
@@ -1749,13 +1885,13 @@ async function* forwardLogBatches(agentId, processId) {
1749
1885
  }
1750
1886
  var processRouter = router({
1751
1887
  /** List all processes across all connected agents */
1752
- list: protectedProcedure.meta({ openapi: { method: "GET", path: "/processes", tags: ["processes"], summary: "List all processes", protect: true } }).output(z7.any()).query(() => listAllProcesses()),
1888
+ list: protectedProcedure.meta({ openapi: { method: "GET", path: "/processes", tags: ["processes"], summary: "List all processes", protect: true } }).output(z8.any()).query(() => listAllProcesses()),
1753
1889
  /** Get a single process from a specific agent */
1754
- get: protectedProcedure.meta({ openapi: { method: "GET", path: "/processes/{agentId}/{id}", tags: ["processes"], summary: "Get a process by agent and ID", protect: true } }).input(z7.object({ agentId: z7.string().max(128), id: z7.string().max(128) })).output(z7.any()).query(async ({ input, ctx }) => {
1890
+ get: protectedProcedure.meta({ openapi: { method: "GET", path: "/processes/{agentId}/{id}", tags: ["processes"], summary: "Get a process by agent and ID", protect: true } }).input(z8.object({ agentId: z8.string().max(128), id: z8.string().max(128) })).output(z8.any()).query(async ({ input, ctx }) => {
1755
1891
  requireServiceAction(ctx, input.id, "service:read");
1756
1892
  const status = agentManager.getStatus(input.agentId);
1757
1893
  if (!status) {
1758
- throw new TRPCError6({ code: "NOT_FOUND", message: `Agent ${input.agentId} not found` });
1894
+ throw new TRPCError7({ code: "NOT_FOUND", message: `Agent ${input.agentId} not found` });
1759
1895
  }
1760
1896
  const proc = await agentManager.agentQuery(input.agentId, "process.get", { id: input.id });
1761
1897
  return { ...proc, agentId: input.agentId };
@@ -1765,37 +1901,37 @@ var processRouter = router({
1765
1901
  * (or restarted). This avoids pushing configs for every service at agent boot,
1766
1902
  * which would be wasteful when many services are never started.
1767
1903
  * The deploy call is idempotent — creates the process if missing, updates config if it exists. */
1768
- start: protectedProcedure.meta({ openapi: { method: "POST", path: "/processes/{agentId}/{processId}/start", tags: ["processes"], summary: "Start a process", protect: true } }).input(z7.object({ agentId: z7.string().max(128).optional(), processId: z7.string().max(128) })).output(z7.any()).mutation(async ({ input, ctx }) => {
1904
+ start: protectedProcedure.meta({ openapi: { method: "POST", path: "/processes/{agentId}/{processId}/start", tags: ["processes"], summary: "Start a process", protect: true } }).input(z8.object({ agentId: z8.string().max(128).optional(), processId: z8.string().max(128) })).output(z8.any()).mutation(async ({ input, ctx }) => {
1769
1905
  requireServiceAction(ctx, input.processId, "service:start");
1770
1906
  return startProcess(input.processId, input.agentId);
1771
1907
  }),
1772
1908
  /** Stop a process on an agent */
1773
- stop: protectedProcedure.meta({ openapi: { method: "POST", path: "/processes/{agentId}/{processId}/stop", tags: ["processes"], summary: "Stop a process", protect: true } }).input(z7.object({ agentId: z7.string().max(128), processId: z7.string().max(128) })).output(z7.any()).mutation(async ({ input, ctx }) => {
1909
+ stop: protectedProcedure.meta({ openapi: { method: "POST", path: "/processes/{agentId}/{processId}/stop", tags: ["processes"], summary: "Stop a process", protect: true } }).input(z8.object({ agentId: z8.string().max(128), processId: z8.string().max(128) })).output(z8.any()).mutation(async ({ input, ctx }) => {
1774
1910
  requireServiceAction(ctx, input.processId, "service:stop");
1775
1911
  return stopProcess(input.processId, input.agentId);
1776
1912
  }),
1777
1913
  /** Restart a process on an agent.
1778
1914
  * Sends stop → deploy (latest resolved config) → start so that
1779
1915
  * config/variable changes take effect. Same lazy deploy pattern as start. */
1780
- restart: protectedProcedure.meta({ openapi: { method: "POST", path: "/processes/{agentId}/{processId}/restart", tags: ["processes"], summary: "Restart a process", protect: true } }).input(z7.object({ agentId: z7.string().max(128).optional(), processId: z7.string().max(128) })).output(z7.any()).mutation(async ({ input, ctx }) => {
1916
+ restart: protectedProcedure.meta({ openapi: { method: "POST", path: "/processes/{agentId}/{processId}/restart", tags: ["processes"], summary: "Restart a process", protect: true } }).input(z8.object({ agentId: z8.string().max(128).optional(), processId: z8.string().max(128) })).output(z8.any()).mutation(async ({ input, ctx }) => {
1781
1917
  requireServiceAction(ctx, input.processId, "service:restart");
1782
1918
  return restartProcess(input.processId, input.agentId);
1783
1919
  }),
1784
1920
  /** Get buffered logs for a process from an agent */
1785
- logs: protectedProcedure.meta({ openapi: { method: "GET", path: "/processes/{agentId}/{processId}/logs", tags: ["processes"], summary: "Get buffered logs for a process", protect: true } }).input(z7.object({ agentId: z7.string().max(128), processId: z7.string().max(128) })).output(z7.any()).query(async ({ input, ctx }) => {
1921
+ logs: protectedProcedure.meta({ openapi: { method: "GET", path: "/processes/{agentId}/{processId}/logs", tags: ["processes"], summary: "Get buffered logs for a process", protect: true } }).input(z8.object({ agentId: z8.string().max(128), processId: z8.string().max(128) })).output(z8.any()).query(async ({ input, ctx }) => {
1786
1922
  requireServiceAction(ctx, input.processId, "logs:read");
1787
1923
  return agentManager.agentQuery(input.agentId, "process.logs", { id: input.processId });
1788
1924
  }),
1789
1925
  /** Clear buffered logs for a process on an agent */
1790
- clearLogBuffer: protectedProcedure.input(z7.object({ agentId: z7.string().max(128), processId: z7.string().max(128) })).mutation(async ({ input }) => {
1926
+ clearLogBuffer: protectedProcedure.input(z8.object({ agentId: z8.string().max(128), processId: z8.string().max(128) })).mutation(async ({ input }) => {
1791
1927
  await agentManager.agentMutation(input.agentId, "process.clearLogBuffer", { id: input.processId });
1792
1928
  await auditService.log({ userId: "local", action: "clearLogBuffer", entityType: "process", entityId: input.processId, metadata: { agentId: input.agentId } });
1793
1929
  return { success: true };
1794
1930
  }),
1795
1931
  /** Execute a shortcut command on an agent, streaming output into the process log */
1796
- executeShortcut: protectedProcedure.input(z7.object({
1797
- agentId: z7.string().max(128),
1798
- processId: z7.string().max(128),
1932
+ executeShortcut: protectedProcedure.input(z8.object({
1933
+ agentId: z8.string().max(128),
1934
+ processId: z8.string().max(128),
1799
1935
  shortcut: ServiceShortcutSchema
1800
1936
  })).mutation(async ({ input }) => {
1801
1937
  const service2 = await serviceStore.get(input.processId);
@@ -1823,12 +1959,12 @@ var processRouter = router({
1823
1959
  return result;
1824
1960
  }),
1825
1961
  /** Execute an ad-hoc command on an agent, streaming output into the process log */
1826
- executeAdHocCommand: protectedProcedure.input(z7.object({
1827
- agentId: z7.string().max(128),
1828
- processId: z7.string().max(128),
1829
- command: z7.string().min(1).max(4096),
1830
- cwd: z7.string().max(4096).optional(),
1831
- commandId: z7.string().max(128).optional()
1962
+ executeAdHocCommand: protectedProcedure.input(z8.object({
1963
+ agentId: z8.string().max(128),
1964
+ processId: z8.string().max(128),
1965
+ command: z8.string().min(1).max(4096),
1966
+ cwd: z8.string().max(4096).optional(),
1967
+ commandId: z8.string().max(128).optional()
1832
1968
  })).mutation(async ({ input }) => {
1833
1969
  const service2 = await serviceStore.get(input.processId);
1834
1970
  if (service2) {
@@ -1862,25 +1998,25 @@ var processRouter = router({
1862
1998
  return result;
1863
1999
  }),
1864
2000
  /** Cancel a running shortcut command on an agent */
1865
- cancelShortcut: protectedProcedure.input(z7.object({
1866
- agentId: z7.string().max(128),
1867
- processId: z7.string().max(128),
1868
- shortcutId: z7.string().max(128)
2001
+ cancelShortcut: protectedProcedure.input(z8.object({
2002
+ agentId: z8.string().max(128),
2003
+ processId: z8.string().max(128),
2004
+ shortcutId: z8.string().max(128)
1869
2005
  })).mutation(async ({ input }) => {
1870
2006
  await agentManager.agentMutation(input.agentId, "process.cancelShortcut", { id: input.processId, shortcutId: input.shortcutId });
1871
2007
  return { success: true };
1872
2008
  }),
1873
2009
  /** Cancel a running ad-hoc command on an agent */
1874
- cancelAdHocCommand: protectedProcedure.input(z7.object({
1875
- agentId: z7.string().max(128),
1876
- processId: z7.string().max(128),
1877
- commandId: z7.string().max(128).optional()
2010
+ cancelAdHocCommand: protectedProcedure.input(z8.object({
2011
+ agentId: z8.string().max(128),
2012
+ processId: z8.string().max(128),
2013
+ commandId: z8.string().max(128).optional()
1878
2014
  })).mutation(async ({ input }) => {
1879
2015
  await agentManager.agentMutation(input.agentId, "process.cancelAdHocCommand", { id: input.processId, commandId: input.commandId });
1880
2016
  return { success: true };
1881
2017
  }),
1882
2018
  /** Get current metrics for a process from an agent */
1883
- metrics: protectedProcedure.input(z7.object({ agentId: z7.string().max(128), processId: z7.string().max(128) })).query(async ({ input }) => {
2019
+ metrics: protectedProcedure.input(z8.object({ agentId: z8.string().max(128), processId: z8.string().max(128) })).query(async ({ input }) => {
1884
2020
  return agentManager.agentQuery(input.agentId, "process.metrics", { id: input.processId });
1885
2021
  }),
1886
2022
  /**
@@ -1888,7 +2024,7 @@ var processRouter = router({
1888
2024
  * Forwards batched events from the AgentWSBridge in real-time.
1889
2025
  * Historical logs are fetched separately via process.logs query.
1890
2026
  */
1891
- onLog: protectedProcedure.input(z7.object({ agentId: z7.string().max(128), processId: z7.string().max(128) })).subscription(async function* ({ input, ctx }) {
2027
+ onLog: protectedProcedure.input(z8.object({ agentId: z8.string().max(128), processId: z8.string().max(128) })).subscription(async function* ({ input, ctx }) {
1892
2028
  requireServiceAction(ctx, input.processId, "logs:read");
1893
2029
  yield* forwardLogBatches(input.agentId, input.processId);
1894
2030
  }),
@@ -1897,9 +2033,9 @@ var processRouter = router({
1897
2033
  * Input is optional — omit agentId/processId for global monitoring (dashboard).
1898
2034
  * Forwards events from the AgentWSBridge in real-time.
1899
2035
  */
1900
- onStatus: protectedProcedure.input(z7.object({
1901
- agentId: z7.string().max(128).optional(),
1902
- processId: z7.string().max(128).optional()
2036
+ onStatus: protectedProcedure.input(z8.object({
2037
+ agentId: z8.string().max(128).optional(),
2038
+ processId: z8.string().max(128).optional()
1903
2039
  }).optional()).subscription(async function* ({ input, ctx }) {
1904
2040
  const allowedIds = getAllowedServiceIds(ctx);
1905
2041
  if (input?.processId) requireServiceAction(ctx, input.processId, "service:status");
@@ -1927,9 +2063,9 @@ var processRouter = router({
1927
2063
  });
1928
2064
  }),
1929
2065
  /** Subscribe to real-time metrics for a process. */
1930
- onMetrics: protectedProcedure.input(z7.object({
1931
- agentId: z7.string().max(128).optional(),
1932
- processId: z7.string().max(128).optional()
2066
+ onMetrics: protectedProcedure.input(z8.object({
2067
+ agentId: z8.string().max(128).optional(),
2068
+ processId: z8.string().max(128).optional()
1933
2069
  }).optional()).subscription(async function* ({ input, ctx }) {
1934
2070
  const allowedIds = getAllowedServiceIds(ctx);
1935
2071
  if (input?.processId) requireServiceAction(ctx, input.processId, "service:status");
@@ -1941,9 +2077,9 @@ var processRouter = router({
1941
2077
  });
1942
2078
  }),
1943
2079
  /** Subscribe to real-time health status changes. */
1944
- onHealth: protectedProcedure.input(z7.object({
1945
- agentId: z7.string().max(128).optional(),
1946
- processId: z7.string().max(128).optional()
2080
+ onHealth: protectedProcedure.input(z8.object({
2081
+ agentId: z8.string().max(128).optional(),
2082
+ processId: z8.string().max(128).optional()
1947
2083
  }).optional()).subscription(async function* ({ input, ctx }) {
1948
2084
  const allowedIds = getAllowedServiceIds(ctx);
1949
2085
  if (input?.processId) requireServiceAction(ctx, input.processId, "service:healthcheck");
@@ -1957,21 +2093,21 @@ var processRouter = router({
1957
2093
  });
1958
2094
 
1959
2095
  // ../server/src/trpc/routers/audit.ts
1960
- import { z as z8 } from "zod";
2096
+ import { z as z9 } from "zod";
1961
2097
  var auditRouter = router({
1962
- list: protectedProcedure.input(z8.object({
1963
- action: z8.string().max(50).optional(),
1964
- entityType: z8.string().max(50).optional(),
1965
- entityId: z8.string().max(100).optional(),
1966
- limit: z8.number().int().positive().max(100).default(50),
1967
- offset: z8.number().int().nonnegative().default(0)
2098
+ list: protectedProcedure.input(z9.object({
2099
+ action: z9.string().max(50).optional(),
2100
+ entityType: z9.string().max(50).optional(),
2101
+ entityId: z9.string().max(100).optional(),
2102
+ limit: z9.number().int().positive().max(100).default(50),
2103
+ offset: z9.number().int().nonnegative().default(0)
1968
2104
  }).optional()).query(async ({ input }) => {
1969
2105
  return auditService.list(input ?? {});
1970
2106
  })
1971
2107
  });
1972
2108
 
1973
2109
  // ../server/src/trpc/routers/setup.ts
1974
- import { z as z9 } from "zod";
2110
+ import { z as z10 } from "zod";
1975
2111
  var setupRouter = router({
1976
2112
  /**
1977
2113
  * Check if encryption key is required (project initialized but no key).
@@ -2068,9 +2204,9 @@ var setupRouter = router({
2068
2204
  * une validation de la clé à adopter rendait le parcours impossible : vert
2069
2205
  * quand le geste est inutile, rouge sinon.
2070
2206
  */
2071
- checkOrgKeyLocal: protectedProcedure.input(z9.object({
2072
- orgId: z9.string().min(1).max(128),
2073
- keyHex: z9.string().length(64).regex(/^[0-9a-f]+$/i, "Invalid hex format")
2207
+ checkOrgKeyLocal: protectedProcedure.input(z10.object({
2208
+ orgId: z10.string().min(1).max(128),
2209
+ keyHex: z10.string().length(64).regex(/^[0-9a-f]+$/i, "Invalid hex format")
2074
2210
  })).query(async ({ input }) => {
2075
2211
  const canary = await readVerifyFile(orgVaultRoot(input.orgId));
2076
2212
  const locked = isVaultLocked(input.orgId);
@@ -2087,8 +2223,8 @@ var setupRouter = router({
2087
2223
  * Spawns the local agent if in local-simple mode.
2088
2224
  */
2089
2225
  submitEncryptionKey: publicProcedure.input(
2090
- z9.object({
2091
- keyHex: z9.string().length(64).regex(/^[0-9a-f]+$/i, "Invalid hex format")
2226
+ z10.object({
2227
+ keyHex: z10.string().length(64).regex(/^[0-9a-f]+$/i, "Invalid hex format")
2092
2228
  })
2093
2229
  ).mutation(async ({ input }) => {
2094
2230
  try {
@@ -2106,8 +2242,8 @@ var setupRouter = router({
2106
2242
 
2107
2243
  // ../server/src/trpc/routers/environment.ts
2108
2244
  import { randomUUID } from "crypto";
2109
- import { z as z10 } from "zod";
2110
- import { TRPCError as TRPCError7 } from "@trpc/server";
2245
+ import { z as z11 } from "zod";
2246
+ import { TRPCError as TRPCError8 } from "@trpc/server";
2111
2247
 
2112
2248
  // ../server/src/services/ai-variable-write.ts
2113
2249
  var AiVariableWriteError = class extends Error {
@@ -2186,29 +2322,29 @@ async function builtinsForEnvironment(environment) {
2186
2322
  return own ? values : Object.fromEntries(Object.entries(values).filter(([name]) => name.startsWith("services.")));
2187
2323
  }
2188
2324
  var environmentRouter = router({
2189
- list: protectedProcedure.input(z10.object({
2190
- projectId: z10.string().max(128),
2191
- orgId: z10.string().max(128).nullable().optional()
2325
+ list: protectedProcedure.input(z11.object({
2326
+ projectId: z11.string().max(128),
2327
+ orgId: z11.string().max(128).nullable().optional()
2192
2328
  })).query(async ({ input }) => {
2193
2329
  return await environmentStore.list(input.projectId, input.orgId);
2194
2330
  }),
2195
- get: protectedProcedure.input(z10.object({ id: z10.string().max(128) })).query(async ({ input }) => {
2331
+ get: protectedProcedure.input(z11.object({ id: z11.string().max(128) })).query(async ({ input }) => {
2196
2332
  const env2 = await environmentStore.get(input.id);
2197
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.id} not found` });
2333
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.id} not found` });
2198
2334
  return env2;
2199
2335
  }),
2200
- listByScope: protectedProcedure.input(z10.object({
2201
- projectId: z10.string().max(128),
2202
- orgId: z10.string().max(128).nullable().optional(),
2203
- scope: z10.enum(["global", "service"])
2336
+ listByScope: protectedProcedure.input(z11.object({
2337
+ projectId: z11.string().max(128),
2338
+ orgId: z11.string().max(128).nullable().optional(),
2339
+ scope: z11.enum(["global", "service"])
2204
2340
  })).query(async ({ input }) => {
2205
2341
  return await environmentStore.listByScope(input.projectId, input.scope, input.orgId);
2206
2342
  }),
2207
- findServiceEnvironment: protectedProcedure.input(z10.object({ serviceId: z10.string().max(128), globalEnvId: z10.string().max(128) })).query(async ({ input }) => {
2343
+ findServiceEnvironment: protectedProcedure.input(z11.object({ serviceId: z11.string().max(128), globalEnvId: z11.string().max(128) })).query(async ({ input }) => {
2208
2344
  return await environmentStore.findServiceEnvironment(input.serviceId, input.globalEnvId);
2209
2345
  }),
2210
2346
  create: protectedProcedure.input(CreateEnvironmentSchema.extend({
2211
- orgId: z10.string().max(128).nullable().optional()
2347
+ orgId: z11.string().max(128).nullable().optional()
2212
2348
  })).mutation(async ({ input }) => {
2213
2349
  const { orgId, ...environment } = input;
2214
2350
  const target = { id: input.projectId, orgId };
@@ -2244,9 +2380,9 @@ var environmentRouter = router({
2244
2380
  }),
2245
2381
  update: protectedProcedure.input(UpdateEnvironmentSchema).mutation(async ({ input }) => {
2246
2382
  const existing = await environmentStore.get(input.id);
2247
- if (!existing) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.id} not found` });
2383
+ if (!existing) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.id} not found` });
2248
2384
  const env2 = await environmentStore.update(input);
2249
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.id} not found` });
2385
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.id} not found` });
2250
2386
  if (env2.scope === "global" && input.name && input.name !== existing.name) {
2251
2387
  const project = await projectStore.get(environmentStore.projectRefOf(env2) ?? env2.projectId);
2252
2388
  if (project) {
@@ -2260,24 +2396,24 @@ var environmentRouter = router({
2260
2396
  }
2261
2397
  return env2;
2262
2398
  }),
2263
- delete: protectedProcedure.input(z10.object({ id: z10.string().max(128) })).mutation(async ({ input }) => {
2399
+ delete: protectedProcedure.input(z11.object({ id: z11.string().max(128) })).mutation(async ({ input }) => {
2264
2400
  const env2 = await environmentStore.get(input.id);
2265
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.id} not found` });
2401
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.id} not found` });
2266
2402
  if (env2.immutable) {
2267
- throw new TRPCError7({ code: "FORBIDDEN", message: "Cannot delete immutable environment" });
2403
+ throw new TRPCError8({ code: "FORBIDDEN", message: "Cannot delete immutable environment" });
2268
2404
  }
2269
2405
  if (env2.scope === "global") {
2270
2406
  await environmentStore.deleteByActivateOn(input.id);
2271
2407
  }
2272
2408
  const deleted = await environmentStore.delete(input.id);
2273
- if (!deleted) throw new TRPCError7({ code: "INTERNAL_SERVER_ERROR", message: "Failed to delete environment" });
2409
+ if (!deleted) throw new TRPCError8({ code: "INTERNAL_SERVER_ERROR", message: "Failed to delete environment" });
2274
2410
  await projectStore.removeEnvironment(environmentStore.projectRefOf(env2) ?? env2.projectId, input.id);
2275
2411
  return { success: true };
2276
2412
  }),
2277
- resolve: protectedProcedure.input(z10.object({ environmentId: z10.string().max(128) })).query(async ({ input, ctx }) => {
2413
+ resolve: protectedProcedure.input(z11.object({ environmentId: z11.string().max(128) })).query(async ({ input, ctx }) => {
2278
2414
  const { includeSecrets } = requireEnvAction(ctx, input.environmentId, "env:read");
2279
2415
  const env2 = await environmentStore.get(input.environmentId);
2280
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2416
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2281
2417
  const resolved = await environmentResolver.resolveEnvironmentWithSources(input.environmentId);
2282
2418
  if (!includeSecrets) {
2283
2419
  const sanitized = { ...resolved };
@@ -2293,10 +2429,10 @@ var environmentRouter = router({
2293
2429
  }
2294
2430
  return resolved;
2295
2431
  }),
2296
- resolveFlat: protectedProcedure.meta({ openapi: { method: "GET", path: "/environments/{environmentId}/resolve-flat", tags: ["environments"], summary: "Resolve environment variables as a flat key-value map", protect: true } }).input(z10.object({ environmentId: z10.string().max(128) })).output(z10.record(z10.string(), z10.string())).query(async ({ input, ctx }) => {
2432
+ resolveFlat: protectedProcedure.meta({ openapi: { method: "GET", path: "/environments/{environmentId}/resolve-flat", tags: ["environments"], summary: "Resolve environment variables as a flat key-value map", protect: true } }).input(z11.object({ environmentId: z11.string().max(128) })).output(z11.record(z11.string(), z11.string())).query(async ({ input, ctx }) => {
2297
2433
  const { includeSecrets } = requireEnvAction(ctx, input.environmentId, "env:read");
2298
2434
  const env2 = await environmentStore.get(input.environmentId);
2299
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2435
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2300
2436
  const { env: resolved, envSecrets } = await environmentResolver.resolveEnvironment(input.environmentId);
2301
2437
  const result = {};
2302
2438
  for (const [key, value] of Object.entries(resolved)) {
@@ -2318,10 +2454,10 @@ var environmentRouter = router({
2318
2454
  * motif. C'est ce que l'assistant de complétion affiche, et il n'a pas
2319
2455
  * besoin de connaître ce qui est déjà rempli ailleurs.
2320
2456
  */
2321
- missingVariables: protectedProcedure.input(z10.object({ environmentId: z10.string().max(128) })).query(async ({ input, ctx }) => {
2457
+ missingVariables: protectedProcedure.input(z11.object({ environmentId: z11.string().max(128) })).query(async ({ input, ctx }) => {
2322
2458
  requireEnvAction(ctx, input.environmentId, "env:read");
2323
2459
  const env2 = await environmentStore.get(input.environmentId);
2324
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2460
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2325
2461
  const missing = await environmentResolver.findMissingForActiveEnvironment(input.environmentId);
2326
2462
  return missing.filter((item) => canEnvAction(ctx, item.environmentId, "env:read"));
2327
2463
  }),
@@ -2340,17 +2476,17 @@ var environmentRouter = router({
2340
2476
  * poste, en recopiant depuis la définition la forme (`pre`, `post`) et le
2341
2477
  * caractère secret que la surcharge ne porte pas d'elle-même.
2342
2478
  */
2343
- fillVariable: protectedProcedure.input(z10.object({
2344
- environmentId: z10.string().max(128),
2345
- variableId: z10.string().max(128),
2346
- value: z10.string().max(8192),
2479
+ fillVariable: protectedProcedure.input(z11.object({
2480
+ environmentId: z11.string().max(128),
2481
+ variableId: z11.string().max(128),
2482
+ value: z11.string().max(8192),
2347
2483
  reason: MissingVariableReasonSchema
2348
2484
  })).mutation(async ({ input, ctx }) => {
2349
2485
  requireEnvAction(ctx, input.environmentId, "env:write");
2350
2486
  const env2 = await environmentStore.get(input.environmentId);
2351
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2487
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2352
2488
  const variable = env2.variables[input.variableId];
2353
- if (!variable) throw new TRPCError7({ code: "NOT_FOUND", message: `Variable ${input.variableId} not found` });
2489
+ if (!variable) throw new TRPCError8({ code: "NOT_FOUND", message: `Variable ${input.variableId} not found` });
2354
2490
  const slot = variable.value;
2355
2491
  if (input.reason === "overrideOnly") {
2356
2492
  await environmentOverridesStore.setOverride(input.variableId, {
@@ -2362,11 +2498,11 @@ var environmentRouter = router({
2362
2498
  ...variable,
2363
2499
  value: { ...slot, value: input.value }
2364
2500
  });
2365
- if (!result) throw new TRPCError7({ code: "INTERNAL_SERVER_ERROR", message: "Failed to fill variable" });
2501
+ if (!result) throw new TRPCError8({ code: "INTERNAL_SERVER_ERROR", message: "Failed to fill variable" });
2366
2502
  return { success: true };
2367
2503
  }),
2368
- setOverride: protectedProcedure.input(z10.object({
2369
- variableId: z10.string().max(128),
2504
+ setOverride: protectedProcedure.input(z11.object({
2505
+ variableId: z11.string().max(128),
2370
2506
  // Only the value slot: the env var name comes from the variable
2371
2507
  // definition (a `key` sent by an older client is stripped here).
2372
2508
  variable: VariableOverrideSchema
@@ -2374,8 +2510,8 @@ var environmentRouter = router({
2374
2510
  await environmentOverridesStore.setOverride(input.variableId, input.variable);
2375
2511
  return { success: true };
2376
2512
  }),
2377
- removeOverride: protectedProcedure.input(z10.object({
2378
- variableId: z10.string().max(128)
2513
+ removeOverride: protectedProcedure.input(z11.object({
2514
+ variableId: z11.string().max(128)
2379
2515
  })).mutation(async ({ input }) => {
2380
2516
  await environmentOverridesStore.removeOverride(input.variableId);
2381
2517
  return { success: true };
@@ -2383,16 +2519,16 @@ var environmentRouter = router({
2383
2519
  getOverrides: protectedProcedure.query(async () => {
2384
2520
  return await environmentOverridesStore.getAll();
2385
2521
  }),
2386
- upsertVariable: protectedProcedure.meta({ openapi: { method: "PUT", path: "/environments/{environmentId}/variables/{variableId}", tags: ["environments"], summary: "Upsert a variable in an environment", protect: true } }).output(z10.any()).input(z10.object({
2387
- environmentId: z10.string().max(128),
2388
- variableId: z10.string().max(128),
2522
+ upsertVariable: protectedProcedure.meta({ openapi: { method: "PUT", path: "/environments/{environmentId}/variables/{variableId}", tags: ["environments"], summary: "Upsert a variable in an environment", protect: true } }).output(z11.any()).input(z11.object({
2523
+ environmentId: z11.string().max(128),
2524
+ variableId: z11.string().max(128),
2389
2525
  variable: VariableSchema
2390
2526
  })).mutation(async ({ input, ctx }) => {
2391
2527
  requireEnvAction(ctx, input.environmentId, "env:write");
2392
2528
  const env2 = await environmentStore.get(input.environmentId);
2393
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2529
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2394
2530
  const result = await environmentStore.upsertVariable(input.environmentId, input.variableId, input.variable);
2395
- if (!result) throw new TRPCError7({ code: "INTERNAL_SERVER_ERROR", message: "Failed to update variable" });
2531
+ if (!result) throw new TRPCError8({ code: "INTERNAL_SERVER_ERROR", message: "Failed to update variable" });
2396
2532
  return result;
2397
2533
  }),
2398
2534
  /**
@@ -2400,15 +2536,15 @@ var environmentRouter = router({
2400
2536
  * hérite de qui, lequel est actif — sans aucune valeur (`describeEnvironmentsForAi`).
2401
2537
  * Une clé d'API n'y voit que les environnements qu'elle peut lire.
2402
2538
  */
2403
- listForAi: protectedProcedure.input(z10.object({
2404
- projectId: z10.string().max(128),
2405
- orgId: z10.string().max(128).nullable().optional()
2539
+ listForAi: protectedProcedure.input(z11.object({
2540
+ projectId: z11.string().max(128),
2541
+ orgId: z11.string().max(128).nullable().optional()
2406
2542
  })).query(async ({ input, ctx }) => {
2407
2543
  const project = await projectStore.get({
2408
2544
  id: input.projectId,
2409
2545
  ...input.orgId !== void 0 ? { orgId: input.orgId } : {}
2410
2546
  });
2411
- if (!project) throw new TRPCError7({ code: "NOT_FOUND", message: `Project ${input.projectId} not found` });
2547
+ if (!project) throw new TRPCError8({ code: "NOT_FOUND", message: `Project ${input.projectId} not found` });
2412
2548
  const environments = (await environmentStore.list(input.projectId, input.orgId)).filter((env2) => canEnvAction(ctx, env2.id, "env:read"));
2413
2549
  const serviceNames = {};
2414
2550
  for (const serviceId of project.serviceIds) {
@@ -2424,10 +2560,10 @@ var environmentRouter = router({
2424
2560
  * remplies — elles dépendent du service qui les reçoit — mais une référence
2425
2561
  * qui ne correspond à rien est nommée.
2426
2562
  */
2427
- resolveForAi: protectedProcedure.input(z10.object({ environmentId: z10.string().max(128) })).query(async ({ input, ctx }) => {
2563
+ resolveForAi: protectedProcedure.input(z11.object({ environmentId: z11.string().max(128) })).query(async ({ input, ctx }) => {
2428
2564
  requireEnvAction(ctx, input.environmentId, "env:read");
2429
2565
  const env2 = await environmentStore.get(input.environmentId);
2430
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2566
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2431
2567
  const [resolved, shared] = await Promise.all([
2432
2568
  environmentResolver.resolveEnvironment(input.environmentId),
2433
2569
  environmentResolver.resolveAiSharedKeys(input.environmentId)
@@ -2449,29 +2585,29 @@ var environmentRouter = router({
2449
2585
  * pas un secret public et ne le partage jamais avec les IA. La réponse ne
2450
2586
  * porte aucune valeur : ce qui vient d'être écrit peut être un secret.
2451
2587
  */
2452
- setVariableBlind: protectedProcedure.input(z10.object({
2453
- environmentId: z10.string().max(128),
2454
- key: z10.string().min(1).max(256),
2455
- value: z10.string().max(8192).optional(),
2456
- pre: z10.string().max(8192).optional(),
2457
- post: z10.string().max(8192).optional(),
2458
- isSecret: z10.boolean().optional(),
2459
- description: z10.string().max(2e3).optional()
2588
+ setVariableBlind: protectedProcedure.input(z11.object({
2589
+ environmentId: z11.string().max(128),
2590
+ key: z11.string().min(1).max(256),
2591
+ value: z11.string().max(8192).optional(),
2592
+ pre: z11.string().max(8192).optional(),
2593
+ post: z11.string().max(8192).optional(),
2594
+ isSecret: z11.boolean().optional(),
2595
+ description: z11.string().max(2e3).optional()
2460
2596
  })).mutation(async ({ input, ctx }) => {
2461
2597
  requireEnvAction(ctx, input.environmentId, "env:write");
2462
2598
  const env2 = await environmentStore.get(input.environmentId);
2463
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2599
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2464
2600
  const found = Object.entries(env2.variables).find(([, v]) => v.key === input.key);
2465
2601
  const variableId = found?.[0] ?? randomUUID();
2466
2602
  let variable;
2467
2603
  try {
2468
2604
  variable = planAiVariableWrite(found?.[1], input);
2469
2605
  } catch (err) {
2470
- if (err instanceof AiVariableWriteError) throw new TRPCError7({ code: "FORBIDDEN", message: err.message });
2606
+ if (err instanceof AiVariableWriteError) throw new TRPCError8({ code: "FORBIDDEN", message: err.message });
2471
2607
  throw err;
2472
2608
  }
2473
2609
  const result = await environmentStore.upsertVariable(input.environmentId, variableId, variable);
2474
- if (!result) throw new TRPCError7({ code: "INTERNAL_SERVER_ERROR", message: "Failed to write variable" });
2610
+ if (!result) throw new TRPCError8({ code: "INTERNAL_SERVER_ERROR", message: "Failed to write variable" });
2475
2611
  const written = `${variable.value.pre}${variable.value.value}${variable.value.post}`;
2476
2612
  let suggestions = [];
2477
2613
  if (!variable.value.isSecret) {
@@ -2497,26 +2633,26 @@ var environmentRouter = router({
2497
2633
  * une route dédiée parce que `update` rend l'environnement entier, valeurs
2498
2634
  * comprises.
2499
2635
  */
2500
- setInheritanceBlind: protectedProcedure.input(z10.object({ environmentId: z10.string().max(128), inherit: z10.boolean() })).mutation(async ({ input, ctx }) => {
2636
+ setInheritanceBlind: protectedProcedure.input(z11.object({ environmentId: z11.string().max(128), inherit: z11.boolean() })).mutation(async ({ input, ctx }) => {
2501
2637
  requireEnvAction(ctx, input.environmentId, "env:write");
2502
2638
  const env2 = await environmentStore.get(input.environmentId);
2503
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2639
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2504
2640
  if (env2.scope !== "service" || !env2.activateOn) {
2505
- throw new TRPCError7({ code: "BAD_REQUEST", message: `Environment ${input.environmentId} is not a service environment: only those inherit from, or are isolated from, the global environment that activates them` });
2641
+ throw new TRPCError8({ code: "BAD_REQUEST", message: `Environment ${input.environmentId} is not a service environment: only those inherit from, or are isolated from, the global environment that activates them` });
2506
2642
  }
2507
2643
  const updated = await environmentStore.update({ id: env2.id, parentIds: input.inherit ? [env2.activateOn] : [] });
2508
- if (!updated) throw new TRPCError7({ code: "INTERNAL_SERVER_ERROR", message: "Failed to update inheritance" });
2644
+ if (!updated) throw new TRPCError8({ code: "INTERNAL_SERVER_ERROR", message: "Failed to update inheritance" });
2509
2645
  return { environmentId: env2.id, isolated: !input.inherit };
2510
2646
  }),
2511
2647
  /** Retirer une variable par son nom, pour le compte d'une IA : la réponse ne porte aucune valeur. */
2512
- removeVariableBlind: protectedProcedure.input(z10.object({ environmentId: z10.string().max(128), key: z10.string().min(1).max(256) })).mutation(async ({ input, ctx }) => {
2648
+ removeVariableBlind: protectedProcedure.input(z11.object({ environmentId: z11.string().max(128), key: z11.string().min(1).max(256) })).mutation(async ({ input, ctx }) => {
2513
2649
  requireEnvAction(ctx, input.environmentId, "env:write");
2514
2650
  const env2 = await environmentStore.get(input.environmentId);
2515
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2651
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2516
2652
  const found = Object.entries(env2.variables).find(([, v]) => v.key === input.key);
2517
- if (!found) throw new TRPCError7({ code: "NOT_FOUND", message: `Variable ${input.key} not found in environment ${input.environmentId}` });
2653
+ if (!found) throw new TRPCError8({ code: "NOT_FOUND", message: `Variable ${input.key} not found in environment ${input.environmentId}` });
2518
2654
  const result = await environmentStore.removeVariable(input.environmentId, found[0]);
2519
- if (!result) throw new TRPCError7({ code: "INTERNAL_SERVER_ERROR", message: "Failed to remove variable" });
2655
+ if (!result) throw new TRPCError8({ code: "INTERNAL_SERVER_ERROR", message: "Failed to remove variable" });
2520
2656
  return { environmentId: input.environmentId, key: input.key, removed: true };
2521
2657
  }),
2522
2658
  /**
@@ -2524,12 +2660,12 @@ var environmentRouter = router({
2524
2660
  * define it, and variables that reference it through {{environment.KEY}}.
2525
2661
  * Used by the UI to warn before editing a shared variable from a resolved view.
2526
2662
  */
2527
- keyUsages: protectedProcedure.input(z10.object({
2528
- projectId: z10.string().max(128),
2529
- orgId: z10.string().max(128).nullable().optional(),
2530
- key: z10.string().min(1).max(256),
2663
+ keyUsages: protectedProcedure.input(z11.object({
2664
+ projectId: z11.string().max(128),
2665
+ orgId: z11.string().max(128).nullable().optional(),
2666
+ key: z11.string().min(1).max(256),
2531
2667
  /** Environment holding the variable about to be edited — enables inherited-impact detection */
2532
- environmentId: z10.string().max(128).optional()
2668
+ environmentId: z11.string().max(128).optional()
2533
2669
  })).query(async ({ input }) => {
2534
2670
  const environments = await environmentStore.list(input.projectId, input.orgId);
2535
2671
  const services = await serviceStore.list();
@@ -2586,24 +2722,24 @@ var environmentRouter = router({
2586
2722
  }
2587
2723
  return { definedIn, referencedBy, inheritedBy };
2588
2724
  }),
2589
- removeVariable: protectedProcedure.input(z10.object({
2590
- environmentId: z10.string().max(128),
2591
- variableId: z10.string().max(128)
2725
+ removeVariable: protectedProcedure.input(z11.object({
2726
+ environmentId: z11.string().max(128),
2727
+ variableId: z11.string().max(128)
2592
2728
  })).mutation(async ({ input }) => {
2593
2729
  const env2 = await environmentStore.get(input.environmentId);
2594
- if (!env2) throw new TRPCError7({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2730
+ if (!env2) throw new TRPCError8({ code: "NOT_FOUND", message: `Environment ${input.environmentId} not found` });
2595
2731
  const result = await environmentStore.removeVariable(input.environmentId, input.variableId);
2596
- if (!result) throw new TRPCError7({ code: "INTERNAL_SERVER_ERROR", message: "Failed to remove variable" });
2732
+ if (!result) throw new TRPCError8({ code: "INTERNAL_SERVER_ERROR", message: "Failed to remove variable" });
2597
2733
  return result;
2598
2734
  })
2599
2735
  });
2600
2736
 
2601
2737
  // ../server/src/trpc/routers/settings.ts
2602
2738
  import { promises as dns } from "dns";
2603
- import { z as z11 } from "zod";
2604
- import { TRPCError as TRPCError8 } from "@trpc/server";
2739
+ import { z as z12 } from "zod";
2740
+ import { TRPCError as TRPCError9 } from "@trpc/server";
2605
2741
  var notificationPreferencesShape = NotificationPreferencesSchema.shape;
2606
- var NotificationPreferencesPatchSchema = z11.object(
2742
+ var NotificationPreferencesPatchSchema = z12.object(
2607
2743
  Object.fromEntries(
2608
2744
  Object.entries(notificationPreferencesShape).map(([key, field]) => [key, field.unwrap().optional()])
2609
2745
  )
@@ -2619,8 +2755,8 @@ function maskApiKey2(plaintext) {
2619
2755
  return plaintext.slice(0, 4) + "****" + plaintext.slice(-4);
2620
2756
  }
2621
2757
  var ScopeShape = {
2622
- orgId: z11.string().max(128).nullable().optional(),
2623
- projectId: z11.string().max(128).optional()
2758
+ orgId: z12.string().max(128).nullable().optional(),
2759
+ projectId: z12.string().max(128).optional()
2624
2760
  };
2625
2761
  async function scopeOf(input) {
2626
2762
  return input?.orgId ?? await vaultOfProject(input?.projectId);
@@ -2667,11 +2803,11 @@ var settingsRouter = router({
2667
2803
  * celle de l'onglet qui bascule, ne sont pas coupées. Le choix est mémorisé
2668
2804
  * dans les réglages, donc conservé au prochain démarrage.
2669
2805
  */
2670
- setLanMode: protectedProcedure.input(z11.object({ enabled: z11.boolean() })).mutation(async ({ input }) => {
2806
+ setLanMode: protectedProcedure.input(z12.object({ enabled: z12.boolean() })).mutation(async ({ input }) => {
2671
2807
  try {
2672
2808
  return await setLanMode(input.enabled);
2673
2809
  } catch (err) {
2674
- throw new TRPCError8({
2810
+ throw new TRPCError9({
2675
2811
  code: "INTERNAL_SERVER_ERROR",
2676
2812
  message: `Impossible de changer l'adresse d'\xE9coute : ${err.message}`
2677
2813
  });
@@ -2692,7 +2828,7 @@ var settingsRouter = router({
2692
2828
  /**
2693
2829
  * Get notification preferences
2694
2830
  */
2695
- getNotificationPreferences: protectedProcedure.input(z11.object(ScopeShape).optional()).query(async ({ input }) => {
2831
+ getNotificationPreferences: protectedProcedure.input(z12.object(ScopeShape).optional()).query(async ({ input }) => {
2696
2832
  const priv = await settingsManager.getPrivateSettings(await scopeOf(input));
2697
2833
  return NotificationPreferencesSchema.parse(priv.notifications ?? {});
2698
2834
  }),
@@ -2721,7 +2857,7 @@ var settingsRouter = router({
2721
2857
  * parseur d'organisation se modifie pour toute l'équipe, et l'interface doit
2722
2858
  * pouvoir le dire avant que quelqu'un le change sans le savoir.
2723
2859
  */
2724
- listParsers: protectedProcedure.input(z11.object(ScopeShape).optional()).query(async ({ input }) => {
2860
+ listParsers: protectedProcedure.input(z12.object(ScopeShape).optional()).query(async ({ input }) => {
2725
2861
  const vault = await scopeOf(input);
2726
2862
  return listWithOrigin(await logParserStore.list(vault), vault);
2727
2863
  }),
@@ -2733,7 +2869,7 @@ var settingsRouter = router({
2733
2869
  * retard — affichant une liste dans laquelle le parseur qu'un service vient
2734
2870
  * de référencer n'existe pas encore.
2735
2871
  */
2736
- onParsersChanged: protectedProcedure.input(z11.object(ScopeShape).optional()).subscription(async function* ({ input, signal }) {
2872
+ onParsersChanged: protectedProcedure.input(z12.object(ScopeShape).optional()).subscription(async function* ({ input, signal }) {
2737
2873
  const vault = await scopeOf(input);
2738
2874
  let pending = true;
2739
2875
  let wake = null;
@@ -2771,10 +2907,10 @@ var settingsRouter = router({
2771
2907
  /**
2772
2908
  * Get single parser by ID
2773
2909
  */
2774
- getParser: protectedProcedure.input(z11.object({ id: z11.string().max(128), ...ScopeShape })).query(async ({ input }) => {
2910
+ getParser: protectedProcedure.input(z12.object({ id: z12.string().max(128), ...ScopeShape })).query(async ({ input }) => {
2775
2911
  const parser = await logParserStore.get(input.id, await scopeOf(input));
2776
2912
  if (!parser) {
2777
- throw new TRPCError8({ code: "NOT_FOUND", message: `Parser not found: ${input.id}` });
2913
+ throw new TRPCError9({ code: "NOT_FOUND", message: `Parser not found: ${input.id}` });
2778
2914
  }
2779
2915
  return parser;
2780
2916
  }),
@@ -2790,7 +2926,7 @@ var settingsRouter = router({
2790
2926
  ).mutation(async ({ input }) => {
2791
2927
  const { orgId, projectId, ...fields } = input;
2792
2928
  if (!fields.code.trim()) {
2793
- throw new TRPCError8({ code: "BAD_REQUEST", message: "Parser code cannot be empty" });
2929
+ throw new TRPCError9({ code: "BAD_REQUEST", message: "Parser code cannot be empty" });
2794
2930
  }
2795
2931
  return logParserStore.create(fields, await scopeOf({ orgId, projectId }));
2796
2932
  }),
@@ -2805,27 +2941,27 @@ var settingsRouter = router({
2805
2941
  ).mutation(async ({ input }) => {
2806
2942
  const { id, orgId, projectId, ...patch } = input;
2807
2943
  if (id.startsWith("native:")) {
2808
- throw new TRPCError8({ code: "FORBIDDEN", message: "Cannot modify built-in parsers" });
2944
+ throw new TRPCError9({ code: "FORBIDDEN", message: "Cannot modify built-in parsers" });
2809
2945
  }
2810
2946
  if (patch.code !== void 0 && !patch.code.trim()) {
2811
- throw new TRPCError8({ code: "BAD_REQUEST", message: "Parser code cannot be empty" });
2947
+ throw new TRPCError9({ code: "BAD_REQUEST", message: "Parser code cannot be empty" });
2812
2948
  }
2813
2949
  const updated = await logParserStore.update(id, patch, await scopeOf({ orgId, projectId }));
2814
2950
  if (!updated) {
2815
- throw new TRPCError8({ code: "NOT_FOUND", message: `Parser not found: ${id}` });
2951
+ throw new TRPCError9({ code: "NOT_FOUND", message: `Parser not found: ${id}` });
2816
2952
  }
2817
2953
  return updated;
2818
2954
  }),
2819
2955
  /**
2820
2956
  * Delete parser by ID
2821
2957
  */
2822
- deleteParser: protectedProcedure.input(z11.object({ id: z11.string().max(128), ...ScopeShape })).mutation(async ({ input }) => {
2958
+ deleteParser: protectedProcedure.input(z12.object({ id: z12.string().max(128), ...ScopeShape })).mutation(async ({ input }) => {
2823
2959
  if (input.id.startsWith("native:")) {
2824
- throw new TRPCError8({ code: "FORBIDDEN", message: "Cannot delete built-in parsers" });
2960
+ throw new TRPCError9({ code: "FORBIDDEN", message: "Cannot delete built-in parsers" });
2825
2961
  }
2826
2962
  const deleted = await logParserStore.delete(input.id, await scopeOf(input));
2827
2963
  if (!deleted) {
2828
- throw new TRPCError8({ code: "NOT_FOUND", message: `Parser not found: ${input.id}` });
2964
+ throw new TRPCError9({ code: "NOT_FOUND", message: `Parser not found: ${input.id}` });
2829
2965
  }
2830
2966
  return { deleted: true };
2831
2967
  }),
@@ -2861,15 +2997,15 @@ var settingsRouter = router({
2861
2997
  defaultPrompt: companionDefaultPrompt()
2862
2998
  };
2863
2999
  }),
2864
- setCompanionSettings: protectedProcedure.input(z11.object({
2865
- enabledByDefault: z11.boolean().optional(),
3000
+ setCompanionSettings: protectedProcedure.input(z12.object({
3001
+ enabledByDefault: z12.boolean().optional(),
2866
3002
  // Rejeté au-delà, jamais tronqué : un prompt coupé produirait des
2867
3003
  // relectures incohérentes sans rien signaler.
2868
- prompt: z11.string().max(2e4).optional(),
3004
+ prompt: z12.string().max(2e4).optional(),
2869
3005
  /** Chaîne vide = retirer le défaut. */
2870
- runner: z11.enum(["claude-code", "codex", ""]).optional(),
2871
- model: z11.string().max(200).optional(),
2872
- effort: z11.enum(["low", "normal", "high", ""]).optional()
3006
+ runner: z12.enum(["claude-code", "codex", ""]).optional(),
3007
+ model: z12.string().max(200).optional(),
3008
+ effort: z12.enum(["low", "normal", "high", ""]).optional()
2873
3009
  })).mutation(async ({ input }) => {
2874
3010
  const settings = await settingsManager.getSettings();
2875
3011
  const current2 = settings.companion ?? { enabledByDefault: false };
@@ -2891,7 +3027,7 @@ var settingsRouter = router({
2891
3027
  /**
2892
3028
  * List AI providers (API keys are masked)
2893
3029
  */
2894
- listAIProviders: protectedProcedure.input(z11.object(ScopeShape).optional()).query(async ({ input }) => {
3030
+ listAIProviders: protectedProcedure.input(z12.object(ScopeShape).optional()).query(async ({ input }) => {
2895
3031
  const vault = await scopeOf(input);
2896
3032
  const priv = await settingsManager.getPrivateSettings(vault);
2897
3033
  return (priv.aiProviders ?? []).map((p) => {
@@ -2909,16 +3045,16 @@ var settingsRouter = router({
2909
3045
  /**
2910
3046
  * Create AI provider
2911
3047
  */
2912
- createAIProvider: protectedProcedure.input(z11.object({
2913
- name: z11.string().min(1).max(200),
3048
+ createAIProvider: protectedProcedure.input(z12.object({
3049
+ name: z12.string().min(1).max(200),
2914
3050
  provider: AIProviderSchema.shape.provider,
2915
- apiKey: z11.string().max(500).optional(),
3051
+ apiKey: z12.string().max(500).optional(),
2916
3052
  // optional for providers like Ollama
2917
- model: z11.string().max(200).optional(),
3053
+ model: z12.string().max(200).optional(),
2918
3054
  ...ScopeShape
2919
3055
  })).mutation(async ({ input }) => {
2920
3056
  if (input.provider !== "ollama" && !input.apiKey?.trim()) {
2921
- throw new TRPCError8({ code: "BAD_REQUEST", message: "Une cl\xE9 API est requise pour ce provider." });
3057
+ throw new TRPCError9({ code: "BAD_REQUEST", message: "Une cl\xE9 API est requise pour ce provider." });
2922
3058
  }
2923
3059
  const vault = await scopeOf(input);
2924
3060
  const priv = await settingsManager.getPrivateSettings(vault);
@@ -2947,19 +3083,19 @@ var settingsRouter = router({
2947
3083
  /**
2948
3084
  * Update AI provider (apiKey optional — omit to keep existing)
2949
3085
  */
2950
- updateAIProvider: protectedProcedure.input(z11.object({
2951
- id: z11.string().min(1).max(128),
2952
- name: z11.string().min(1).max(200).optional(),
3086
+ updateAIProvider: protectedProcedure.input(z12.object({
3087
+ id: z12.string().min(1).max(128),
3088
+ name: z12.string().min(1).max(200).optional(),
2953
3089
  provider: AIProviderSchema.shape.provider.optional(),
2954
- apiKey: z11.string().min(1).max(500).optional(),
2955
- model: z11.string().max(200).optional(),
3090
+ apiKey: z12.string().min(1).max(500).optional(),
3091
+ model: z12.string().max(200).optional(),
2956
3092
  ...ScopeShape
2957
3093
  })).mutation(async ({ input }) => {
2958
3094
  const vault = await scopeOf(input);
2959
3095
  const priv = await settingsManager.getPrivateSettings(vault);
2960
3096
  const providers = priv.aiProviders ?? [];
2961
3097
  const idx = providers.findIndex((p) => p.id === input.id);
2962
- if (idx === -1) throw new TRPCError8({ code: "NOT_FOUND", message: `AI provider not found: ${input.id}` });
3098
+ if (idx === -1) throw new TRPCError9({ code: "NOT_FOUND", message: `AI provider not found: ${input.id}` });
2963
3099
  const existing = providers[idx];
2964
3100
  const encryptedApiKey = input.apiKey ? stableEncryptValue(input.apiKey, existing.encryptedApiKey, vault) : existing.encryptedApiKey;
2965
3101
  const updated = {
@@ -2985,12 +3121,12 @@ var settingsRouter = router({
2985
3121
  /**
2986
3122
  * Delete AI provider
2987
3123
  */
2988
- deleteAIProvider: protectedProcedure.input(z11.object({ id: z11.string().min(1).max(128), ...ScopeShape })).mutation(async ({ input }) => {
3124
+ deleteAIProvider: protectedProcedure.input(z12.object({ id: z12.string().min(1).max(128), ...ScopeShape })).mutation(async ({ input }) => {
2989
3125
  const vault = await scopeOf(input);
2990
3126
  const priv = await settingsManager.getPrivateSettings(vault);
2991
3127
  const providers = priv.aiProviders ?? [];
2992
3128
  const filtered = providers.filter((p) => p.id !== input.id);
2993
- if (filtered.length === providers.length) throw new TRPCError8({ code: "NOT_FOUND", message: `AI provider not found: ${input.id}` });
3129
+ if (filtered.length === providers.length) throw new TRPCError9({ code: "NOT_FOUND", message: `AI provider not found: ${input.id}` });
2994
3130
  const deletedWasActive = providers.find((p) => p.id === input.id)?.active ?? false;
2995
3131
  if (deletedWasActive && filtered.length > 0) filtered[0].active = true;
2996
3132
  await settingsManager.savePrivateSettings({ ...priv, aiProviders: filtered }, vault);
@@ -2999,12 +3135,12 @@ var settingsRouter = router({
2999
3135
  /**
3000
3136
  * Set one provider as active (clears active flag on all others)
3001
3137
  */
3002
- setActiveAIProvider: protectedProcedure.input(z11.object({ id: z11.string().min(1).max(128), ...ScopeShape })).mutation(async ({ input }) => {
3138
+ setActiveAIProvider: protectedProcedure.input(z12.object({ id: z12.string().min(1).max(128), ...ScopeShape })).mutation(async ({ input }) => {
3003
3139
  const vault = await scopeOf(input);
3004
3140
  const priv = await settingsManager.getPrivateSettings(vault);
3005
3141
  const providers = priv.aiProviders ?? [];
3006
3142
  const idx = providers.findIndex((p) => p.id === input.id);
3007
- if (idx === -1) throw new TRPCError8({ code: "NOT_FOUND", message: `AI provider not found: ${input.id}` });
3143
+ if (idx === -1) throw new TRPCError9({ code: "NOT_FOUND", message: `AI provider not found: ${input.id}` });
3008
3144
  const updated = providers.map((p) => ({ ...p, active: p.id === input.id }));
3009
3145
  await settingsManager.savePrivateSettings({ ...priv, aiProviders: updated }, vault);
3010
3146
  return { id: input.id, active: true };
@@ -3015,7 +3151,7 @@ var settingsRouter = router({
3015
3151
  /**
3016
3152
  * Get Traefik config for a specific agent (never returns credentials or cert key in plain text)
3017
3153
  */
3018
- getAgentTraefikConfig: protectedProcedure.input(z11.object({ agentId: z11.string().max(128) })).query(async ({ input }) => {
3154
+ getAgentTraefikConfig: protectedProcedure.input(z12.object({ agentId: z12.string().max(128) })).query(async ({ input }) => {
3019
3155
  const raw = agentStore.getTraefikConfig(input.agentId);
3020
3156
  const parsed = raw ? TraefikConfigSchema.safeParse(raw) : null;
3021
3157
  const config = parsed?.success ? parsed.data : null;
@@ -3035,16 +3171,16 @@ var settingsRouter = router({
3035
3171
  /**
3036
3172
  * Update Traefik config for a specific agent (credentials are encrypted before saving)
3037
3173
  */
3038
- updateAgentTraefikConfig: protectedProcedure.input(z11.object({
3039
- agentId: z11.string().max(128),
3040
- enabled: z11.boolean().optional(),
3041
- acmeEmail: z11.string().email().max(256).optional(),
3042
- wildcardDomain: z11.string().max(253).optional(),
3043
- httpPort: z11.number().int().min(1).max(65535).optional(),
3044
- httpsPort: z11.number().int().min(1).max(65535).optional(),
3045
- dnsProvider: z11.string().max(64).optional(),
3046
- dnsCredentials: z11.record(z11.string().max(64), z11.string().max(2048)).optional(),
3047
- acmeStaging: z11.boolean().optional()
3174
+ updateAgentTraefikConfig: protectedProcedure.input(z12.object({
3175
+ agentId: z12.string().max(128),
3176
+ enabled: z12.boolean().optional(),
3177
+ acmeEmail: z12.string().email().max(256).optional(),
3178
+ wildcardDomain: z12.string().max(253).optional(),
3179
+ httpPort: z12.number().int().min(1).max(65535).optional(),
3180
+ httpsPort: z12.number().int().min(1).max(65535).optional(),
3181
+ dnsProvider: z12.string().max(64).optional(),
3182
+ dnsCredentials: z12.record(z12.string().max(64), z12.string().max(2048)).optional(),
3183
+ acmeStaging: z12.boolean().optional()
3048
3184
  })).mutation(async ({ input }) => {
3049
3185
  const { agentId, ...fields } = input;
3050
3186
  const raw = agentStore.getTraefikConfig(agentId);
@@ -3073,13 +3209,13 @@ var settingsRouter = router({
3073
3209
  /**
3074
3210
  * Get Traefik config files content for a specific agent
3075
3211
  */
3076
- getAgentTraefikConfigFiles: protectedProcedure.input(z11.object({ agentId: z11.string().max(128) })).query(async ({ input }) => {
3212
+ getAgentTraefikConfigFiles: protectedProcedure.input(z12.object({ agentId: z12.string().max(128) })).query(async ({ input }) => {
3077
3213
  return agentManager.agentQuery(
3078
3214
  input.agentId,
3079
3215
  "config.getTraefikConfigFiles"
3080
3216
  );
3081
3217
  }),
3082
- getAgentTraefikFileTree: protectedProcedure.input(z11.object({ agentId: z11.string().max(128) })).query(async ({ input }) => {
3218
+ getAgentTraefikFileTree: protectedProcedure.input(z12.object({ agentId: z12.string().max(128) })).query(async ({ input }) => {
3083
3219
  return agentManager.agentQuery(
3084
3220
  input.agentId,
3085
3221
  "config.getTraefikFileTree"
@@ -3088,7 +3224,7 @@ var settingsRouter = router({
3088
3224
  /**
3089
3225
  * Get Traefik container logs for a specific agent (snapshot)
3090
3226
  */
3091
- getAgentTraefikLogs: protectedProcedure.input(z11.object({ agentId: z11.string().max(128), lines: z11.number().int().min(1).max(500).default(100) })).query(async ({ input }) => {
3227
+ getAgentTraefikLogs: protectedProcedure.input(z12.object({ agentId: z12.string().max(128), lines: z12.number().int().min(1).max(500).default(100) })).query(async ({ input }) => {
3092
3228
  const result = await agentManager.agentQuery(
3093
3229
  input.agentId,
3094
3230
  "config.getTraefikLogs",
@@ -3099,7 +3235,7 @@ var settingsRouter = router({
3099
3235
  /**
3100
3236
  * Stream Traefik logs in real-time (subscription, yields new lines every 500ms)
3101
3237
  */
3102
- streamAgentTraefikLogs: protectedProcedure.input(z11.object({ agentId: z11.string().max(128) })).subscription(async function* ({ input, signal }) {
3238
+ streamAgentTraefikLogs: protectedProcedure.input(z12.object({ agentId: z12.string().max(128) })).subscription(async function* ({ input, signal }) {
3103
3239
  let seen = 0;
3104
3240
  while (!signal?.aborted) {
3105
3241
  try {
@@ -3122,11 +3258,11 @@ var settingsRouter = router({
3122
3258
  /**
3123
3259
  * Restart Traefik container on a specific agent (re-pushes config first to handle agent restarts)
3124
3260
  */
3125
- restartAgentTraefik: protectedProcedure.input(z11.object({ agentId: z11.string().max(128) })).mutation(async ({ input }) => {
3261
+ restartAgentTraefik: protectedProcedure.input(z12.object({ agentId: z12.string().max(128) })).mutation(async ({ input }) => {
3126
3262
  const raw = agentStore.getTraefikConfig(input.agentId);
3127
3263
  const parsed = raw ? TraefikConfigSchema.safeParse(raw) : null;
3128
3264
  const config = parsed?.success ? parsed.data : null;
3129
- if (!config?.enabled) throw new TRPCError8({ code: "BAD_REQUEST", message: "Traefik non activ\xE9 sur cet agent" });
3265
+ if (!config?.enabled) throw new TRPCError9({ code: "BAD_REQUEST", message: "Traefik non activ\xE9 sur cet agent" });
3130
3266
  const decrypted = { ...config, dnsCredentials: traefikManager.decryptDnsCredentials(config.dnsCredentials ?? {}) };
3131
3267
  await agentManager.agentMutation(input.agentId, "config.initTraefikConfig", decrypted, 5e3);
3132
3268
  await agentManager.agentMutation(input.agentId, "config.restartTraefik", void 0, 3e4);
@@ -3135,11 +3271,11 @@ var settingsRouter = router({
3135
3271
  /**
3136
3272
  * Force certificate renewal for a specific agent (wipes acme.json + restarts container)
3137
3273
  */
3138
- renewAgentTraefikCert: protectedProcedure.input(z11.object({ agentId: z11.string().max(128) })).mutation(async ({ input }) => {
3274
+ renewAgentTraefikCert: protectedProcedure.input(z12.object({ agentId: z12.string().max(128) })).mutation(async ({ input }) => {
3139
3275
  const raw = agentStore.getTraefikConfig(input.agentId);
3140
3276
  const parsed = raw ? TraefikConfigSchema.safeParse(raw) : null;
3141
3277
  const config = parsed?.success ? parsed.data : null;
3142
- if (!config?.enabled) throw new TRPCError8({ code: "BAD_REQUEST", message: "Traefik non activ\xE9 sur cet agent" });
3278
+ if (!config?.enabled) throw new TRPCError9({ code: "BAD_REQUEST", message: "Traefik non activ\xE9 sur cet agent" });
3143
3279
  const decrypted = { ...config, dnsCredentials: traefikManager.decryptDnsCredentials(config.dnsCredentials ?? {}) };
3144
3280
  await agentManager.agentMutation(input.agentId, "config.initTraefikConfig", decrypted, 5e3);
3145
3281
  await agentManager.agentMutation(input.agentId, "config.renewTraefikCert", void 0, 3e4);
@@ -3148,7 +3284,7 @@ var settingsRouter = router({
3148
3284
  /**
3149
3285
  * Validate Traefik configuration for a specific agent
3150
3286
  */
3151
- validateAgentTraefikConfig: protectedProcedure.input(z11.object({ agentId: z11.string().max(128) })).query(async ({ input }) => {
3287
+ validateAgentTraefikConfig: protectedProcedure.input(z12.object({ agentId: z12.string().max(128) })).query(async ({ input }) => {
3152
3288
  const raw = agentStore.getTraefikConfig(input.agentId);
3153
3289
  const parsed = raw ? TraefikConfigSchema.safeParse(raw) : null;
3154
3290
  const config = parsed?.success ? parsed.data : null;
@@ -3250,12 +3386,12 @@ var settingsRouter = router({
3250
3386
  * Test parser code: compile and run it against sample logs, return per-line results
3251
3387
  */
3252
3388
  testParser: protectedProcedure.input(
3253
- z11.object({
3254
- code: z11.string().max(5e4),
3255
- sampleLogs: z11.array(
3256
- z11.object({
3257
- raw: z11.string().max(16384),
3258
- stream: z11.enum(["stdout", "stderr"])
3389
+ z12.object({
3390
+ code: z12.string().max(5e4),
3391
+ sampleLogs: z12.array(
3392
+ z12.object({
3393
+ raw: z12.string().max(16384),
3394
+ stream: z12.enum(["stdout", "stderr"])
3259
3395
  })
3260
3396
  ).max(100).default([])
3261
3397
  })
@@ -3271,7 +3407,7 @@ var settingsRouter = router({
3271
3407
  updatedAt: /* @__PURE__ */ new Date()
3272
3408
  }]);
3273
3409
  } catch (err) {
3274
- throw new TRPCError8({
3410
+ throw new TRPCError9({
3275
3411
  code: "BAD_REQUEST",
3276
3412
  message: err instanceof Error ? err.message : String(err)
3277
3413
  });
@@ -3299,30 +3435,30 @@ var settingsRouter = router({
3299
3435
  });
3300
3436
 
3301
3437
  // ../server/src/trpc/routers/editor.ts
3302
- import { z as z13 } from "zod";
3303
- import { TRPCError as TRPCError9 } from "@trpc/server";
3438
+ import { z as z14 } from "zod";
3439
+ import { TRPCError as TRPCError10 } from "@trpc/server";
3304
3440
  import { execFile as execFile3, spawn as spawn2 } from "child_process";
3305
3441
  import { stat as stat2 } from "fs/promises";
3306
- import { resolve as resolve2, join as join4 } from "path";
3442
+ import { resolve as resolve2, join as join5 } from "path";
3307
3443
  import { homedir as homedir2 } from "os";
3308
3444
 
3309
3445
  // ../server/src/services/user-config-manager.ts
3310
3446
  import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
3311
- import { join as join3 } from "path";
3447
+ import { join as join4 } from "path";
3312
3448
  import { homedir } from "os";
3313
- import { z as z12 } from "zod";
3314
- var CONFIG_DIR = join3(homedir(), ".runeya");
3449
+ import { z as z13 } from "zod";
3450
+ var CONFIG_DIR = join4(homedir(), ".runeya");
3315
3451
  var CONFIG_FILE = "runeya.conf";
3316
- var EditorPreferencesSchema = z12.object({
3317
- default: z12.string().max(64).optional()
3318
- }).catchall(z12.string().max(64)).refine((obj) => Object.keys(obj).length <= 500, "Too many editor preferences");
3319
- var ProjectSettingsSchema = z12.object({
3320
- settings: z12.object({
3452
+ var EditorPreferencesSchema = z13.object({
3453
+ default: z13.string().max(64).optional()
3454
+ }).catchall(z13.string().max(64)).refine((obj) => Object.keys(obj).length <= 500, "Too many editor preferences");
3455
+ var ProjectSettingsSchema = z13.object({
3456
+ settings: z13.object({
3321
3457
  editors: EditorPreferencesSchema.optional()
3322
3458
  }).optional()
3323
3459
  });
3324
- var UserConfigSchema = z12.record(
3325
- z12.string().max(128),
3460
+ var UserConfigSchema = z13.record(
3461
+ z13.string().max(128),
3326
3462
  ProjectSettingsSchema
3327
3463
  ).refine((obj) => Object.keys(obj).length <= 100, "Too many projects in config");
3328
3464
  function configKey(ref) {
@@ -3335,7 +3471,7 @@ var UserConfigManager = class {
3335
3471
  }
3336
3472
  async atomicWrite(data) {
3337
3473
  await this.ensureDir();
3338
- const filePath = join3(CONFIG_DIR, CONFIG_FILE);
3474
+ const filePath = join4(CONFIG_DIR, CONFIG_FILE);
3339
3475
  const tmpPath = filePath + ".tmp";
3340
3476
  await writeFile2(tmpPath, JSON.stringify(data, null, 2), "utf-8");
3341
3477
  await renameWithRetry(tmpPath, filePath);
@@ -3344,7 +3480,7 @@ var UserConfigManager = class {
3344
3480
  async getConfig() {
3345
3481
  if (!this.config) {
3346
3482
  try {
3347
- const raw = await readFile2(join3(CONFIG_DIR, CONFIG_FILE), "utf-8");
3483
+ const raw = await readFile2(join4(CONFIG_DIR, CONFIG_FILE), "utf-8");
3348
3484
  const parsed = UserConfigSchema.safeParse(JSON.parse(raw));
3349
3485
  this.config = parsed.success ? parsed.data : {};
3350
3486
  } catch {
@@ -3393,7 +3529,7 @@ async function getServiceCwd(serviceId) {
3393
3529
  const services = await serviceStore.list();
3394
3530
  const service2 = services.find((s) => s.id === serviceId);
3395
3531
  if (!service2) {
3396
- throw new TRPCError9({ code: "NOT_FOUND", message: "Service not found" });
3532
+ throw new TRPCError10({ code: "NOT_FOUND", message: "Service not found" });
3397
3533
  }
3398
3534
  return resolveCwd(await resolveWorkspaceCwd({ serviceId }));
3399
3535
  }
@@ -3414,19 +3550,19 @@ var editorRouter = router({
3414
3550
  );
3415
3551
  return results;
3416
3552
  }),
3417
- getPreferences: protectedProcedure.input(z13.object({
3418
- projectId: z13.string().max(128),
3419
- orgId: z13.string().max(128).nullable().optional()
3553
+ getPreferences: protectedProcedure.input(z14.object({
3554
+ projectId: z14.string().max(128),
3555
+ orgId: z14.string().max(128).nullable().optional()
3420
3556
  })).query(async ({ input }) => {
3421
3557
  return userConfigManager.getEditorPreferences({ id: input.projectId, orgId: input.orgId });
3422
3558
  }),
3423
- setDefault: protectedProcedure.input(z13.object({
3424
- projectId: z13.string().max(128),
3425
- orgId: z13.string().max(128).nullable().optional(),
3426
- editorKey: z13.string().max(64)
3559
+ setDefault: protectedProcedure.input(z14.object({
3560
+ projectId: z14.string().max(128),
3561
+ orgId: z14.string().max(128).nullable().optional(),
3562
+ editorKey: z14.string().max(64)
3427
3563
  })).mutation(async ({ input }) => {
3428
3564
  if (!EDITOR_BY_KEY.has(input.editorKey)) {
3429
- throw new TRPCError9({ code: "BAD_REQUEST", message: `Unknown editor: ${input.editorKey}` });
3565
+ throw new TRPCError10({ code: "BAD_REQUEST", message: `Unknown editor: ${input.editorKey}` });
3430
3566
  }
3431
3567
  await userConfigManager.setEditorPreference(
3432
3568
  { id: input.projectId, orgId: input.orgId },
@@ -3435,14 +3571,14 @@ var editorRouter = router({
3435
3571
  );
3436
3572
  return { success: true };
3437
3573
  }),
3438
- setServiceEditor: protectedProcedure.input(z13.object({
3439
- projectId: z13.string().max(128),
3440
- orgId: z13.string().max(128).nullable().optional(),
3441
- serviceId: z13.string().max(128),
3442
- editorKey: z13.string().max(64)
3574
+ setServiceEditor: protectedProcedure.input(z14.object({
3575
+ projectId: z14.string().max(128),
3576
+ orgId: z14.string().max(128).nullable().optional(),
3577
+ serviceId: z14.string().max(128),
3578
+ editorKey: z14.string().max(64)
3443
3579
  })).mutation(async ({ input }) => {
3444
3580
  if (!EDITOR_BY_KEY.has(input.editorKey)) {
3445
- throw new TRPCError9({ code: "BAD_REQUEST", message: `Unknown editor: ${input.editorKey}` });
3581
+ throw new TRPCError10({ code: "BAD_REQUEST", message: `Unknown editor: ${input.editorKey}` });
3446
3582
  }
3447
3583
  await userConfigManager.setEditorPreference(
3448
3584
  { id: input.projectId, orgId: input.orgId },
@@ -3451,10 +3587,10 @@ var editorRouter = router({
3451
3587
  );
3452
3588
  return { success: true };
3453
3589
  }),
3454
- removeServiceEditor: protectedProcedure.input(z13.object({
3455
- projectId: z13.string().max(128),
3456
- orgId: z13.string().max(128).nullable().optional(),
3457
- serviceId: z13.string().max(128)
3590
+ removeServiceEditor: protectedProcedure.input(z14.object({
3591
+ projectId: z14.string().max(128),
3592
+ orgId: z14.string().max(128).nullable().optional(),
3593
+ serviceId: z14.string().max(128)
3458
3594
  })).mutation(async ({ input }) => {
3459
3595
  await userConfigManager.removeEditorPreference(
3460
3596
  { id: input.projectId, orgId: input.orgId },
@@ -3462,21 +3598,21 @@ var editorRouter = router({
3462
3598
  );
3463
3599
  return { success: true };
3464
3600
  }),
3465
- open: protectedProcedure.input(z13.object({
3466
- editorKey: z13.string().max(64),
3467
- path: z13.string().max(4096)
3601
+ open: protectedProcedure.input(z14.object({
3602
+ editorKey: z14.string().max(64),
3603
+ path: z14.string().max(4096)
3468
3604
  })).mutation(async ({ input }) => {
3469
3605
  const editor = EDITOR_BY_KEY.get(input.editorKey);
3470
3606
  if (!editor) {
3471
- throw new TRPCError9({ code: "BAD_REQUEST", message: `Unknown editor: ${input.editorKey}` });
3607
+ throw new TRPCError10({ code: "BAD_REQUEST", message: `Unknown editor: ${input.editorKey}` });
3472
3608
  }
3473
3609
  const expanded = input.path.replace(/^~(\/|$)/, `${process.env["HOME"] ?? "/tmp"}$1`).replace(/\$\{(\w+)\}|\$(\w+)/g, (_, a, b) => process.env[a || b] ?? "");
3474
3610
  const resolvedPath = resolve2(expanded || ".");
3475
3611
  try {
3476
3612
  await stat2(resolvedPath);
3477
3613
  } catch (err) {
3478
- if (err instanceof TRPCError9) throw err;
3479
- throw new TRPCError9({ code: "BAD_REQUEST", message: `Path does not exist: ${resolvedPath}` });
3614
+ if (err instanceof TRPCError10) throw err;
3615
+ throw new TRPCError10({ code: "BAD_REQUEST", message: `Path does not exist: ${resolvedPath}` });
3480
3616
  }
3481
3617
  const invocation = resolveCliInvocation(editor.command, [resolvedPath]);
3482
3618
  const child = spawn2(invocation.command, invocation.args, {
@@ -3488,24 +3624,24 @@ var editorRouter = router({
3488
3624
  child.unref();
3489
3625
  return { success: true };
3490
3626
  }),
3491
- openFile: protectedProcedure.input(z13.object({
3492
- editorKey: z13.string().max(64),
3493
- serviceId: z13.string().max(128),
3494
- relativePath: z13.string().max(4096)
3627
+ openFile: protectedProcedure.input(z14.object({
3628
+ editorKey: z14.string().max(64),
3629
+ serviceId: z14.string().max(128),
3630
+ relativePath: z14.string().max(4096)
3495
3631
  })).mutation(async ({ input }) => {
3496
3632
  const editor = EDITOR_BY_KEY.get(input.editorKey);
3497
3633
  if (!editor) {
3498
- throw new TRPCError9({ code: "BAD_REQUEST", message: `Unknown editor: ${input.editorKey}` });
3634
+ throw new TRPCError10({ code: "BAD_REQUEST", message: `Unknown editor: ${input.editorKey}` });
3499
3635
  }
3500
3636
  const cwd = await getServiceCwd(input.serviceId);
3501
- const filePath = join4(cwd, input.relativePath);
3637
+ const filePath = join5(cwd, input.relativePath);
3502
3638
  if (!filePath.startsWith(cwd)) {
3503
- throw new TRPCError9({ code: "BAD_REQUEST", message: "Path traversal not allowed" });
3639
+ throw new TRPCError10({ code: "BAD_REQUEST", message: "Path traversal not allowed" });
3504
3640
  }
3505
3641
  try {
3506
3642
  await stat2(filePath);
3507
3643
  } catch {
3508
- throw new TRPCError9({ code: "BAD_REQUEST", message: `File does not exist: ${filePath}` });
3644
+ throw new TRPCError10({ code: "BAD_REQUEST", message: `File does not exist: ${filePath}` });
3509
3645
  }
3510
3646
  const invocation = resolveCliInvocation(editor.command, [filePath]);
3511
3647
  const child = spawn2(invocation.command, invocation.args, {
@@ -3520,57 +3656,57 @@ var editorRouter = router({
3520
3656
  });
3521
3657
 
3522
3658
  // ../server/src/trpc/routers/api-keys.ts
3523
- import { z as z14 } from "zod";
3524
- import { TRPCError as TRPCError10 } from "@trpc/server";
3659
+ import { z as z15 } from "zod";
3660
+ import { TRPCError as TRPCError11 } from "@trpc/server";
3525
3661
  import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
3526
- import { join as join5, dirname as dirname3 } from "path";
3662
+ import { join as join6, dirname as dirname3 } from "path";
3527
3663
  var ALLOWED_SKILL_PATHS = /* @__PURE__ */ new Set([
3528
3664
  ".claude/skills/runeya/SKILL.md",
3529
3665
  ".cursor/rules/runeya.mdc",
3530
3666
  ".windsurf/rules/runeya.md"
3531
3667
  ]);
3532
- var KeyInputSchema = z14.object({
3533
- name: z14.string().min(1).max(200),
3668
+ var KeyInputSchema = z15.object({
3669
+ name: z15.string().min(1).max(200),
3534
3670
  scopes: ApiKeyScopeSchema,
3535
- isPublic: z14.boolean().default(false)
3671
+ isPublic: z15.boolean().default(false)
3536
3672
  });
3537
3673
  var apiKeysRouter = router({
3538
3674
  list: protectedProcedure.query(() => apiKeyStore.list()),
3539
- create: protectedProcedure.input(KeyInputSchema.extend({ orgId: z14.string().min(1).max(128).nullable().optional() })).mutation(
3675
+ create: protectedProcedure.input(KeyInputSchema.extend({ orgId: z15.string().min(1).max(128).nullable().optional() })).mutation(
3540
3676
  ({ input }) => apiKeyStore.create(input.name, input.scopes, input.isPublic, input.orgId ?? null)
3541
3677
  ),
3542
3678
  /**
3543
3679
  * Renvoie le secret d'une seule clé, sur demande explicite. `list` ne le
3544
3680
  * contient pas : une clé ne doit jamais être re-servie en masse.
3545
3681
  */
3546
- reveal: protectedProcedure.input(z14.object({ id: z14.string().max(128) })).query(async ({ input }) => {
3682
+ reveal: protectedProcedure.input(z15.object({ id: z15.string().max(128) })).query(async ({ input }) => {
3547
3683
  const key = await apiKeyStore.reveal(input.id);
3548
- if (!key) throw new TRPCError10({ code: "NOT_FOUND", message: "API key not found" });
3684
+ if (!key) throw new TRPCError11({ code: "NOT_FOUND", message: "API key not found" });
3549
3685
  return { key };
3550
3686
  }),
3551
- update: protectedProcedure.input(KeyInputSchema.extend({ id: z14.string().max(128) })).mutation(async ({ input }) => {
3687
+ update: protectedProcedure.input(KeyInputSchema.extend({ id: z15.string().max(128) })).mutation(async ({ input }) => {
3552
3688
  const updated = await apiKeyStore.update(input.id, input.name, input.scopes, input.isPublic);
3553
- if (!updated) throw new TRPCError10({ code: "NOT_FOUND", message: "API key not found" });
3689
+ if (!updated) throw new TRPCError11({ code: "NOT_FOUND", message: "API key not found" });
3554
3690
  return maskApiKey(updated);
3555
3691
  }),
3556
- remove: protectedProcedure.input(z14.object({ id: z14.string().max(128) })).mutation(async ({ input }) => {
3692
+ remove: protectedProcedure.input(z15.object({ id: z15.string().max(128) })).mutation(async ({ input }) => {
3557
3693
  const removed = await apiKeyStore.remove(input.id);
3558
- if (!removed) throw new TRPCError10({ code: "NOT_FOUND", message: "API key not found" });
3694
+ if (!removed) throw new TRPCError11({ code: "NOT_FOUND", message: "API key not found" });
3559
3695
  return { success: true };
3560
3696
  }),
3561
- renewKey: protectedProcedure.input(z14.object({ id: z14.string().max(128) })).mutation(async ({ input }) => {
3697
+ renewKey: protectedProcedure.input(z15.object({ id: z15.string().max(128) })).mutation(async ({ input }) => {
3562
3698
  const renewed = await apiKeyStore.renewKey(input.id);
3563
- if (!renewed) throw new TRPCError10({ code: "NOT_FOUND", message: "API key not found" });
3699
+ if (!renewed) throw new TRPCError11({ code: "NOT_FOUND", message: "API key not found" });
3564
3700
  return renewed;
3565
3701
  }),
3566
- writeSkillFile: protectedProcedure.input(z14.object({
3567
- relativePath: z14.string().max(256),
3568
- content: z14.string().max(32768)
3702
+ writeSkillFile: protectedProcedure.input(z15.object({
3703
+ relativePath: z15.string().max(256),
3704
+ content: z15.string().max(32768)
3569
3705
  })).mutation(async ({ input }) => {
3570
3706
  if (!ALLOWED_SKILL_PATHS.has(input.relativePath)) {
3571
- throw new TRPCError10({ code: "BAD_REQUEST", message: "Chemin non autoris\xE9" });
3707
+ throw new TRPCError11({ code: "BAD_REQUEST", message: "Chemin non autoris\xE9" });
3572
3708
  }
3573
- const abs = join5(await resolveWorkspaceCwd({}), input.relativePath);
3709
+ const abs = join6(await resolveWorkspaceCwd({}), input.relativePath);
3574
3710
  await mkdir3(dirname3(abs), { recursive: true });
3575
3711
  await writeFile3(abs, input.content, { encoding: "utf-8", mode: 420 });
3576
3712
  return { path: input.relativePath };
@@ -3578,133 +3714,133 @@ var apiKeysRouter = router({
3578
3714
  });
3579
3715
 
3580
3716
  // ../server/src/trpc/routers/git.ts
3581
- import { z as z15 } from "zod";
3582
- import { TRPCError as TRPCError11 } from "@trpc/server";
3717
+ import { z as z16 } from "zod";
3718
+ import { TRPCError as TRPCError12 } from "@trpc/server";
3583
3719
  import Anthropic from "@anthropic-ai/sdk";
3584
3720
  import OpenAI from "openai";
3585
- var SERVICE_ID_SCHEMA = z15.string().max(128);
3586
- var SAFE_PATH_SCHEMA = z15.string().min(1).max(4096).refine((p) => !p.startsWith("/") && !p.includes("../"), {
3721
+ var SERVICE_ID_SCHEMA = z16.string().max(128);
3722
+ var SAFE_PATH_SCHEMA = z16.string().min(1).max(4096).refine((p) => !p.startsWith("/") && !p.includes("../"), {
3587
3723
  message: "Path must be relative and not traverse up"
3588
3724
  });
3589
- var REMOTE_SCHEMA = z15.string().min(1).max(128).regex(/^[a-zA-Z0-9_\-.]+$/);
3590
- var BRANCH_SCHEMA = z15.string().min(1).max(256).regex(/^[a-zA-Z0-9._\-/]+$/);
3725
+ var REMOTE_SCHEMA = z16.string().min(1).max(128).regex(/^[a-zA-Z0-9_\-.]+$/);
3726
+ var BRANCH_SCHEMA = z16.string().min(1).max(256).regex(/^[a-zA-Z0-9._\-/]+$/);
3591
3727
  async function resolveServiceContext(serviceId) {
3592
3728
  const service2 = await serviceStore.get(serviceId);
3593
3729
  if (!service2) {
3594
- throw new TRPCError11({ code: "NOT_FOUND", message: "Service not found" });
3730
+ throw new TRPCError12({ code: "NOT_FOUND", message: "Service not found" });
3595
3731
  }
3596
3732
  const agentId = await resolveEffectiveAgentId(service2);
3597
3733
  if (!agentId) {
3598
- throw new TRPCError11({ code: "BAD_REQUEST", message: "No agent configured for this service" });
3734
+ throw new TRPCError12({ code: "BAD_REQUEST", message: "No agent configured for this service" });
3599
3735
  }
3600
3736
  return { agentId, cwd: await resolveWorkspaceCwd({ serviceId }) };
3601
3737
  }
3602
3738
  var gitTargetShape = {
3603
3739
  serviceId: SERVICE_ID_SCHEMA.optional(),
3604
- agentId: z15.string().max(128).optional(),
3740
+ agentId: z16.string().max(128).optional(),
3605
3741
  /** Anchors on a project when no service is targeted (e.g. from the AI chat). */
3606
- projectId: z15.string().max(128).optional(),
3742
+ projectId: z16.string().max(128).optional(),
3607
3743
  /** Son organisation : un id de projet seul peut en nommer un par organisation. */
3608
- orgId: z15.string().max(128).nullable().optional()
3744
+ orgId: z16.string().max(128).nullable().optional()
3609
3745
  };
3610
3746
  async function resolveGitContext(input) {
3611
3747
  if (input.serviceId) return resolveServiceContext(input.serviceId);
3612
3748
  const agentId = input.agentId ?? agentManager.getDefaultAgentId();
3613
3749
  if (!agentId) {
3614
- throw new TRPCError11({ code: "BAD_REQUEST", message: "No agent available" });
3750
+ throw new TRPCError12({ code: "BAD_REQUEST", message: "No agent available" });
3615
3751
  }
3616
3752
  const cwd = await resolveAgentCwd({ projectId: input.projectId, orgId: input.orgId }) ?? ".";
3617
3753
  return { agentId, cwd };
3618
3754
  }
3619
3755
  var gitRouter = router({
3620
3756
  /** Get full git status */
3621
- status: protectedProcedure.input(z15.object({ ...gitTargetShape })).query(async ({ input }) => {
3757
+ status: protectedProcedure.input(z16.object({ ...gitTargetShape })).query(async ({ input }) => {
3622
3758
  const { agentId, cwd } = await resolveGitContext(input);
3623
3759
  return agentManager.agentQuery(agentId, "git.status", { cwd });
3624
3760
  }),
3625
3761
  /** Get commit log */
3626
- log: protectedProcedure.input(z15.object({ ...gitTargetShape, limit: z15.number().int().min(1).max(200).default(50) })).query(async ({ input }) => {
3762
+ log: protectedProcedure.input(z16.object({ ...gitTargetShape, limit: z16.number().int().min(1).max(200).default(50) })).query(async ({ input }) => {
3627
3763
  const { agentId, cwd } = await resolveGitContext(input);
3628
3764
  return agentManager.agentQuery(agentId, "git.log", { cwd, limit: input.limit });
3629
3765
  }),
3630
3766
  /** List local and remote branches */
3631
- branches: protectedProcedure.input(z15.object({ ...gitTargetShape })).query(async ({ input }) => {
3767
+ branches: protectedProcedure.input(z16.object({ ...gitTargetShape })).query(async ({ input }) => {
3632
3768
  const { agentId, cwd } = await resolveGitContext(input);
3633
3769
  return agentManager.agentQuery(agentId, "git.branches", { cwd });
3634
3770
  }),
3635
3771
  /** Checkout a branch */
3636
- checkout: protectedProcedure.input(z15.object({ ...gitTargetShape, branch: BRANCH_SCHEMA, create: z15.boolean().default(false) })).mutation(async ({ input }) => {
3772
+ checkout: protectedProcedure.input(z16.object({ ...gitTargetShape, branch: BRANCH_SCHEMA, create: z16.boolean().default(false) })).mutation(async ({ input }) => {
3637
3773
  const { agentId, cwd } = await resolveGitContext(input);
3638
3774
  return agentManager.agentMutation(agentId, "git.checkout", { cwd, branch: input.branch, create: input.create });
3639
3775
  }),
3640
3776
  /** Stage files */
3641
- stage: protectedProcedure.input(z15.object({ ...gitTargetShape, paths: z15.array(SAFE_PATH_SCHEMA).min(1).max(500) })).mutation(async ({ input }) => {
3777
+ stage: protectedProcedure.input(z16.object({ ...gitTargetShape, paths: z16.array(SAFE_PATH_SCHEMA).min(1).max(500) })).mutation(async ({ input }) => {
3642
3778
  const { agentId, cwd } = await resolveGitContext(input);
3643
3779
  return agentManager.agentMutation(agentId, "git.stage", { cwd, paths: input.paths });
3644
3780
  }),
3645
3781
  /** Stage all files */
3646
- stageAll: protectedProcedure.input(z15.object({ ...gitTargetShape })).mutation(async ({ input }) => {
3782
+ stageAll: protectedProcedure.input(z16.object({ ...gitTargetShape })).mutation(async ({ input }) => {
3647
3783
  const { agentId, cwd } = await resolveGitContext(input);
3648
3784
  return agentManager.agentMutation(agentId, "git.stageAll", { cwd });
3649
3785
  }),
3650
3786
  /** Unstage files */
3651
- unstage: protectedProcedure.input(z15.object({ ...gitTargetShape, paths: z15.array(SAFE_PATH_SCHEMA).min(1).max(500) })).mutation(async ({ input }) => {
3787
+ unstage: protectedProcedure.input(z16.object({ ...gitTargetShape, paths: z16.array(SAFE_PATH_SCHEMA).min(1).max(500) })).mutation(async ({ input }) => {
3652
3788
  const { agentId, cwd } = await resolveGitContext(input);
3653
3789
  return agentManager.agentMutation(agentId, "git.unstage", { cwd, paths: input.paths });
3654
3790
  }),
3655
3791
  /** Unstage all files */
3656
- unstageAll: protectedProcedure.input(z15.object({ ...gitTargetShape })).mutation(async ({ input }) => {
3792
+ unstageAll: protectedProcedure.input(z16.object({ ...gitTargetShape })).mutation(async ({ input }) => {
3657
3793
  const { agentId, cwd } = await resolveGitContext(input);
3658
3794
  return agentManager.agentMutation(agentId, "git.unstageAll", { cwd });
3659
3795
  }),
3660
3796
  /** Commit staged changes */
3661
- commit: protectedProcedure.input(z15.object({ ...gitTargetShape, message: z15.string().min(1).max(4096) })).mutation(async ({ input }) => {
3797
+ commit: protectedProcedure.input(z16.object({ ...gitTargetShape, message: z16.string().min(1).max(4096) })).mutation(async ({ input }) => {
3662
3798
  const { agentId, cwd } = await resolveGitContext(input);
3663
3799
  return agentManager.agentMutation(agentId, "git.commit", { cwd, message: input.message });
3664
3800
  }),
3665
3801
  /** Push to remote */
3666
- push: protectedProcedure.input(z15.object({ ...gitTargetShape, remote: REMOTE_SCHEMA.default("origin"), setUpstream: z15.boolean().default(false) })).mutation(async ({ input }) => {
3802
+ push: protectedProcedure.input(z16.object({ ...gitTargetShape, remote: REMOTE_SCHEMA.default("origin"), setUpstream: z16.boolean().default(false) })).mutation(async ({ input }) => {
3667
3803
  const { agentId, cwd } = await resolveGitContext(input);
3668
3804
  return agentManager.agentMutation(agentId, "git.push", { cwd, remote: input.remote, setUpstream: input.setUpstream });
3669
3805
  }),
3670
3806
  /** Pull from remote */
3671
- pull: protectedProcedure.input(z15.object({ ...gitTargetShape, remote: REMOTE_SCHEMA.default("origin") })).mutation(async ({ input }) => {
3807
+ pull: protectedProcedure.input(z16.object({ ...gitTargetShape, remote: REMOTE_SCHEMA.default("origin") })).mutation(async ({ input }) => {
3672
3808
  const { agentId, cwd } = await resolveGitContext(input);
3673
3809
  return agentManager.agentMutation(agentId, "git.pull", { cwd, remote: input.remote });
3674
3810
  }),
3675
3811
  /** Fetch from remote */
3676
- fetch: protectedProcedure.input(z15.object({ ...gitTargetShape, remote: REMOTE_SCHEMA.default("origin") })).mutation(async ({ input }) => {
3812
+ fetch: protectedProcedure.input(z16.object({ ...gitTargetShape, remote: REMOTE_SCHEMA.default("origin") })).mutation(async ({ input }) => {
3677
3813
  const { agentId, cwd } = await resolveGitContext(input);
3678
3814
  return agentManager.agentMutation(agentId, "git.fetch", { cwd, remote: input.remote });
3679
3815
  }),
3680
3816
  /** Get diff for a file or the whole index */
3681
- diff: protectedProcedure.input(z15.object({
3817
+ diff: protectedProcedure.input(z16.object({
3682
3818
  ...gitTargetShape,
3683
- path: z15.string().max(4096).optional(),
3684
- staged: z15.boolean().default(false),
3685
- untracked: z15.boolean().default(false)
3819
+ path: z16.string().max(4096).optional(),
3820
+ staged: z16.boolean().default(false),
3821
+ untracked: z16.boolean().default(false)
3686
3822
  })).query(async ({ input }) => {
3687
3823
  const { agentId, cwd } = await resolveGitContext(input);
3688
3824
  return agentManager.agentQuery(agentId, "git.diff", { cwd, path: input.path, staged: input.staged, untracked: input.untracked });
3689
3825
  }),
3690
3826
  /** Discard changes to working tree files */
3691
- discard: protectedProcedure.input(z15.object({ ...gitTargetShape, paths: z15.array(SAFE_PATH_SCHEMA).min(1).max(500) })).mutation(async ({ input }) => {
3827
+ discard: protectedProcedure.input(z16.object({ ...gitTargetShape, paths: z16.array(SAFE_PATH_SCHEMA).min(1).max(500) })).mutation(async ({ input }) => {
3692
3828
  const { agentId, cwd } = await resolveGitContext(input);
3693
3829
  return agentManager.agentMutation(agentId, "git.discard", { cwd, paths: input.paths });
3694
3830
  }),
3695
3831
  /** Generate a commit message from staged diffs using AI (diff fetched from agent, AI runs on server) */
3696
- generateCommitMessage: protectedProcedure.input(z15.object({ ...gitTargetShape, providerId: OptionalProviderIdSchema, model: z15.string().max(200).optional() })).mutation(async ({ input }) => {
3832
+ generateCommitMessage: protectedProcedure.input(z16.object({ ...gitTargetShape, providerId: OptionalProviderIdSchema, model: z16.string().max(200).optional() })).mutation(async ({ input }) => {
3697
3833
  const { agentId, cwd } = await resolveGitContext(input);
3698
3834
  const { diff } = await agentManager.agentQuery(agentId, "git.stagedDiff", { cwd });
3699
3835
  if (!diff.trim()) {
3700
- throw new TRPCError11({ code: "BAD_REQUEST", message: "No staged changes to generate a commit message from" });
3836
+ throw new TRPCError12({ code: "BAD_REQUEST", message: "No staged changes to generate a commit message from" });
3701
3837
  }
3702
3838
  const active = await getActiveProvider(
3703
3839
  input.providerId,
3704
3840
  input.orgId ?? await vaultOfProject(input.projectId)
3705
3841
  );
3706
3842
  if (!active) {
3707
- throw new TRPCError11({ code: "BAD_REQUEST", message: "No AI provider configured" });
3843
+ throw new TRPCError12({ code: "BAD_REQUEST", message: "No AI provider configured" });
3708
3844
  }
3709
3845
  const systemPrompt = `You are a git commit message generator. Given a git diff, write a concise and meaningful conventional commit message (e.g. feat:, fix:, refactor:, chore:, docs:, style:, test:).
3710
3846
  Rules:
@@ -3737,45 +3873,45 @@ Rules:
3737
3873
  });
3738
3874
  return { message: res.choices[0]?.message?.content?.trim() ?? "" };
3739
3875
  }
3740
- throw new TRPCError11({ code: "BAD_REQUEST", message: "Unsupported AI provider" });
3876
+ throw new TRPCError12({ code: "BAD_REQUEST", message: "Unsupported AI provider" });
3741
3877
  }),
3742
3878
  /** Merge a branch into the current branch */
3743
- merge: protectedProcedure.input(z15.object({ ...gitTargetShape, branch: BRANCH_SCHEMA, noFf: z15.boolean().default(false) })).mutation(async ({ input }) => {
3879
+ merge: protectedProcedure.input(z16.object({ ...gitTargetShape, branch: BRANCH_SCHEMA, noFf: z16.boolean().default(false) })).mutation(async ({ input }) => {
3744
3880
  const { agentId, cwd } = await resolveGitContext(input);
3745
3881
  return agentManager.agentMutation(agentId, "git.merge", { cwd, branch: input.branch, noFf: input.noFf });
3746
3882
  }),
3747
3883
  /** Rebase current branch onto another branch */
3748
- rebase: protectedProcedure.input(z15.object({ ...gitTargetShape, branch: BRANCH_SCHEMA })).mutation(async ({ input }) => {
3884
+ rebase: protectedProcedure.input(z16.object({ ...gitTargetShape, branch: BRANCH_SCHEMA })).mutation(async ({ input }) => {
3749
3885
  const { agentId, cwd } = await resolveGitContext(input);
3750
3886
  return agentManager.agentMutation(agentId, "git.rebase", { cwd, branch: input.branch });
3751
3887
  }),
3752
3888
  /** List stash entries */
3753
- stashList: protectedProcedure.input(z15.object({ ...gitTargetShape })).query(async ({ input }) => {
3889
+ stashList: protectedProcedure.input(z16.object({ ...gitTargetShape })).query(async ({ input }) => {
3754
3890
  const { agentId, cwd } = await resolveGitContext(input);
3755
3891
  return agentManager.agentQuery(agentId, "git.stashList", { cwd });
3756
3892
  }),
3757
3893
  /** Stash current changes */
3758
- stashPush: protectedProcedure.input(z15.object({ ...gitTargetShape, message: z15.string().max(4096).optional(), includeUntracked: z15.boolean().default(true) })).mutation(async ({ input }) => {
3894
+ stashPush: protectedProcedure.input(z16.object({ ...gitTargetShape, message: z16.string().max(4096).optional(), includeUntracked: z16.boolean().default(true) })).mutation(async ({ input }) => {
3759
3895
  const { agentId, cwd } = await resolveGitContext(input);
3760
3896
  return agentManager.agentMutation(agentId, "git.stashPush", { cwd, message: input.message, includeUntracked: input.includeUntracked });
3761
3897
  }),
3762
3898
  /** Pop a stash entry */
3763
- stashPop: protectedProcedure.input(z15.object({ ...gitTargetShape, index: z15.number().int().min(0).max(1e3).default(0) })).mutation(async ({ input }) => {
3899
+ stashPop: protectedProcedure.input(z16.object({ ...gitTargetShape, index: z16.number().int().min(0).max(1e3).default(0) })).mutation(async ({ input }) => {
3764
3900
  const { agentId, cwd } = await resolveGitContext(input);
3765
3901
  return agentManager.agentMutation(agentId, "git.stashPop", { cwd, index: input.index });
3766
3902
  }),
3767
3903
  /** Apply a stash entry without dropping it */
3768
- stashApply: protectedProcedure.input(z15.object({ ...gitTargetShape, index: z15.number().int().min(0).max(1e3).default(0) })).mutation(async ({ input }) => {
3904
+ stashApply: protectedProcedure.input(z16.object({ ...gitTargetShape, index: z16.number().int().min(0).max(1e3).default(0) })).mutation(async ({ input }) => {
3769
3905
  const { agentId, cwd } = await resolveGitContext(input);
3770
3906
  return agentManager.agentMutation(agentId, "git.stashApply", { cwd, index: input.index });
3771
3907
  }),
3772
3908
  /** Drop a stash entry */
3773
- stashDrop: protectedProcedure.input(z15.object({ ...gitTargetShape, index: z15.number().int().min(0).max(1e3).default(0) })).mutation(async ({ input }) => {
3909
+ stashDrop: protectedProcedure.input(z16.object({ ...gitTargetShape, index: z16.number().int().min(0).max(1e3).default(0) })).mutation(async ({ input }) => {
3774
3910
  const { agentId, cwd } = await resolveGitContext(input);
3775
3911
  return agentManager.agentMutation(agentId, "git.stashDrop", { cwd, index: input.index });
3776
3912
  }),
3777
3913
  /** Watch .git/ for changes and stream updated status */
3778
- onStatusChange: protectedProcedure.input(z15.object({ ...gitTargetShape })).subscription(async function* ({ input }) {
3914
+ onStatusChange: protectedProcedure.input(z16.object({ ...gitTargetShape })).subscription(async function* ({ input }) {
3779
3915
  const { agentId, cwd } = await resolveGitContext(input);
3780
3916
  const queue = [];
3781
3917
  let resolve5 = null;
@@ -3802,7 +3938,7 @@ Rules:
3802
3938
  }
3803
3939
  );
3804
3940
  } catch (err) {
3805
- throw new TRPCError11({
3941
+ throw new TRPCError12({
3806
3942
  code: "BAD_REQUEST",
3807
3943
  message: `Cannot subscribe to git status: ${err.message}`
3808
3944
  });
@@ -3822,7 +3958,7 @@ Rules:
3822
3958
  }
3823
3959
  }),
3824
3960
  /** List remotes */
3825
- remotes: protectedProcedure.input(z15.object({ ...gitTargetShape })).query(async ({ input }) => {
3961
+ remotes: protectedProcedure.input(z16.object({ ...gitTargetShape })).query(async ({ input }) => {
3826
3962
  const { agentId, cwd } = await resolveGitContext(input);
3827
3963
  return agentManager.agentQuery(agentId, "git.remotes", { cwd });
3828
3964
  })
@@ -3830,41 +3966,41 @@ Rules:
3830
3966
 
3831
3967
  // ../server/src/trpc/routers/scenario.ts
3832
3968
  import { randomUUID as randomUUID3 } from "crypto";
3833
- import { TRPCError as TRPCError14 } from "@trpc/server";
3834
- import { z as z16 } from "zod";
3969
+ import { TRPCError as TRPCError15 } from "@trpc/server";
3970
+ import { z as z17 } from "zod";
3835
3971
 
3836
3972
  // ../server/src/trpc/crud-procedure-utils.ts
3837
- import { TRPCError as TRPCError12 } from "@trpc/server";
3973
+ import { TRPCError as TRPCError13 } from "@trpc/server";
3838
3974
  async function getOrNotFound(getter, notFoundMessage) {
3839
3975
  const entity = await getter();
3840
- if (!entity) throw new TRPCError12({ code: "NOT_FOUND", message: notFoundMessage });
3976
+ if (!entity) throw new TRPCError13({ code: "NOT_FOUND", message: notFoundMessage });
3841
3977
  return entity;
3842
3978
  }
3843
3979
  async function createOrBadRequest(creator) {
3844
3980
  try {
3845
3981
  return await creator();
3846
3982
  } catch (err) {
3847
- throw new TRPCError12({ code: "BAD_REQUEST", message: err.message });
3983
+ throw new TRPCError13({ code: "BAD_REQUEST", message: err.message });
3848
3984
  }
3849
3985
  }
3850
3986
  async function updateOrThrow(updater, notFoundMessage) {
3851
3987
  try {
3852
3988
  const entity = await updater();
3853
- if (!entity) throw new TRPCError12({ code: "NOT_FOUND", message: notFoundMessage });
3989
+ if (!entity) throw new TRPCError13({ code: "NOT_FOUND", message: notFoundMessage });
3854
3990
  return entity;
3855
3991
  } catch (err) {
3856
- if (err instanceof TRPCError12) throw err;
3857
- throw new TRPCError12({ code: "BAD_REQUEST", message: err.message });
3992
+ if (err instanceof TRPCError13) throw err;
3993
+ throw new TRPCError13({ code: "BAD_REQUEST", message: err.message });
3858
3994
  }
3859
3995
  }
3860
3996
  async function deleteOrNotFound(deleter, notFoundMessage) {
3861
3997
  const deleted = await deleter();
3862
- if (!deleted) throw new TRPCError12({ code: "NOT_FOUND", message: notFoundMessage });
3998
+ if (!deleted) throw new TRPCError13({ code: "NOT_FOUND", message: notFoundMessage });
3863
3999
  return { ok: true };
3864
4000
  }
3865
4001
 
3866
4002
  // ../server/src/trpc/ai-generation-procedure-utils.ts
3867
- import { TRPCError as TRPCError13 } from "@trpc/server";
4003
+ import { TRPCError as TRPCError14 } from "@trpc/server";
3868
4004
 
3869
4005
  // ../server/src/services/ai-generation.ts
3870
4006
  import Anthropic2 from "@anthropic-ai/sdk";
@@ -3920,7 +4056,7 @@ async function* streamProviderText(input) {
3920
4056
  // ../server/src/trpc/ai-generation-procedure-utils.ts
3921
4057
  async function* streamWithActiveProvider(opts) {
3922
4058
  const active = await getActiveProvider(opts.providerId, opts.vault);
3923
- if (!active) throw new TRPCError13({ code: "BAD_REQUEST", message: "Aucun fournisseur IA configur\xE9" });
4059
+ if (!active) throw new TRPCError14({ code: "BAD_REQUEST", message: "Aucun fournisseur IA configur\xE9" });
3924
4060
  const { provider, plaintextKey } = active;
3925
4061
  const model = opts.model || provider.model || DEFAULT_MODELS[provider.provider] || "";
3926
4062
  try {
@@ -3938,7 +4074,7 @@ async function* streamWithActiveProvider(opts) {
3938
4074
  yield { type: "done", text: "" };
3939
4075
  } catch (err) {
3940
4076
  if (String(err?.message ?? "").startsWith("Unsupported provider:")) {
3941
- throw new TRPCError13({ code: "BAD_REQUEST", message: `Fournisseur non support\xE9: ${provider.provider}` });
4077
+ throw new TRPCError14({ code: "BAD_REQUEST", message: `Fournisseur non support\xE9: ${provider.provider}` });
3942
4078
  }
3943
4079
  throw err;
3944
4080
  }
@@ -3947,7 +4083,7 @@ async function* streamWithActiveProvider(opts) {
3947
4083
  // ../server/src/services/scenario-runner.ts
3948
4084
  import { mkdir as mkdir4 } from "fs/promises";
3949
4085
  import { randomUUID as randomUUID2 } from "crypto";
3950
- import { join as join6 } from "path";
4086
+ import { join as join7 } from "path";
3951
4087
 
3952
4088
  // ../server/src/services/scenario-presets-fr.ts
3953
4089
  var lines = (...l) => l.join("\n");
@@ -5666,8 +5802,8 @@ async function nodeRuneyaAccess(conversationId) {
5666
5802
  let injectedEnv;
5667
5803
  if (ref?.id) {
5668
5804
  try {
5669
- const { projectStore: projectStore2 } = await import("./project-store-6TFAYAWK.js");
5670
- const { environmentResolver: environmentResolver2 } = await import("./environment-resolver-HT6GTSLA.js");
5805
+ const { projectStore: projectStore2 } = await import("./project-store-67M34SNQ.js");
5806
+ const { environmentResolver: environmentResolver2 } = await import("./environment-resolver-E7JDNTRO.js");
5671
5807
  const project = await projectStore2.get(ref.orgId ? { id: ref.id, orgId: ref.orgId } : ref.id);
5672
5808
  if (project?.activeEnvironmentId) {
5673
5809
  const injected = await environmentResolver2.resolveAiInjectedEnv(project.activeEnvironmentId);
@@ -5806,7 +5942,7 @@ async function appendNodeOutput(conversationId, node, output) {
5806
5942
  if (!dir) return;
5807
5943
  const slug = node.label.toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, 60) || "member";
5808
5944
  const safeId = node.id.replace(/[^a-z0-9_-]/gi, "-").slice(0, 80);
5809
- const filePath = join6(dir, `${slug}_${safeId}.md`);
5945
+ const filePath = join7(dir, `${slug}_${safeId}.md`);
5810
5946
  const content = `## Output
5811
5947
 
5812
5948
  ${output}
@@ -5821,7 +5957,7 @@ async function appendToReadme(conversationId, bus, text) {
5821
5957
  try {
5822
5958
  await mkdir4(dir, { recursive: true });
5823
5959
  const { appendFile } = await import("fs/promises");
5824
- await appendFile(join6(dir, "README.md"), line, "utf-8");
5960
+ await appendFile(join7(dir, "README.md"), line, "utf-8");
5825
5961
  } catch {
5826
5962
  }
5827
5963
  publishToBus(bus, { type: "readme_append", text: line });
@@ -5841,7 +5977,7 @@ async function writeFinalMd(conversationId, bus, userRequest, content) {
5841
5977
 
5842
5978
  ${content}
5843
5979
  `;
5844
- const filePath = join6(dir, "FINAL.md");
5980
+ const filePath = join7(dir, "FINAL.md");
5845
5981
  await atomicWriteSecure(filePath, fullContent);
5846
5982
  await appendToReadme(
5847
5983
  conversationId,
@@ -6521,29 +6657,29 @@ Modify the scenario. Keep existing ids when possible.`;
6521
6657
  return `Generate an scenario org-chart based on: ${userPrompt}`;
6522
6658
  }
6523
6659
  var ScopeShape2 = {
6524
- orgId: z16.string().max(128).nullable().optional(),
6660
+ orgId: z17.string().max(128).nullable().optional(),
6525
6661
  projectId: Id128Schema.optional()
6526
6662
  };
6527
6663
  async function scopeOf2(input) {
6528
6664
  return input?.orgId ?? await vaultOfProject(input?.projectId);
6529
6665
  }
6530
6666
  var scenarioRouter = router({
6531
- list: protectedProcedure.input(z16.object(ScopeShape2).optional()).query(async ({ input }) => scenarioStore.list(await scopeOf2(input))),
6532
- get: protectedProcedure.input(z16.object({ id: Id128Schema, ...ScopeShape2 })).query(async ({ input }) => getOrNotFound(
6667
+ list: protectedProcedure.input(z17.object(ScopeShape2).optional()).query(async ({ input }) => scenarioStore.list(await scopeOf2(input))),
6668
+ get: protectedProcedure.input(z17.object({ id: Id128Schema, ...ScopeShape2 })).query(async ({ input }) => getOrNotFound(
6533
6669
  async () => scenarioStore.get(input.id, await scopeOf2(input)),
6534
6670
  "Scenario not found"
6535
6671
  )),
6536
- create: protectedProcedure.input(z16.object({
6672
+ create: protectedProcedure.input(z17.object({
6537
6673
  name: NameSchema,
6538
- icon: z16.string().max(64).optional(),
6674
+ icon: z17.string().max(64).optional(),
6539
6675
  description: DescriptionSchema.optional(),
6540
6676
  leaderId: Id128Schema,
6541
- groups: z16.array(ScenarioGroupSchema).max(100).optional(),
6542
- nodes: z16.array(ScenarioNodeSchema).min(1).max(500),
6543
- traversalMode: z16.enum(["hierarchical", "topological"]).optional(),
6544
- presetId: z16.string().max(128).optional(),
6545
- locale: z16.string().max(16).optional(),
6546
- isPublished: z16.boolean().optional(),
6677
+ groups: z17.array(ScenarioGroupSchema).max(100).optional(),
6678
+ nodes: z17.array(ScenarioNodeSchema).min(1).max(500),
6679
+ traversalMode: z17.enum(["hierarchical", "topological"]).optional(),
6680
+ presetId: z17.string().max(128).optional(),
6681
+ locale: z17.string().max(16).optional(),
6682
+ isPublished: z17.boolean().optional(),
6547
6683
  ...ScopeShape2
6548
6684
  })).mutation(({ input }) => {
6549
6685
  const now = Date.now();
@@ -6563,18 +6699,18 @@ var scenarioRouter = router({
6563
6699
  updatedAt: now
6564
6700
  }, await scopeOf2(input)));
6565
6701
  }),
6566
- update: protectedProcedure.input(z16.object({
6702
+ update: protectedProcedure.input(z17.object({
6567
6703
  id: Id128Schema,
6568
6704
  name: NameSchema.optional(),
6569
- icon: z16.string().max(64).optional(),
6705
+ icon: z17.string().max(64).optional(),
6570
6706
  description: DescriptionSchema.optional(),
6571
6707
  leaderId: Id128Schema.optional(),
6572
- groups: z16.array(ScenarioGroupSchema).max(100).optional(),
6573
- nodes: z16.array(ScenarioNodeSchema).min(1).max(500).optional(),
6574
- traversalMode: z16.enum(["hierarchical", "topological"]).optional(),
6575
- presetId: z16.string().max(128).optional(),
6576
- locale: z16.string().max(16).optional(),
6577
- isPublished: z16.boolean().optional(),
6708
+ groups: z17.array(ScenarioGroupSchema).max(100).optional(),
6709
+ nodes: z17.array(ScenarioNodeSchema).min(1).max(500).optional(),
6710
+ traversalMode: z17.enum(["hierarchical", "topological"]).optional(),
6711
+ presetId: z17.string().max(128).optional(),
6712
+ locale: z17.string().max(16).optional(),
6713
+ isPublished: z17.boolean().optional(),
6578
6714
  ...ScopeShape2
6579
6715
  })).mutation(({ input }) => updateOrThrow(
6580
6716
  async () => scenarioStore.update(input.id, {
@@ -6592,26 +6728,26 @@ var scenarioRouter = router({
6592
6728
  }, await scopeOf2(input)),
6593
6729
  "Scenario not found"
6594
6730
  )),
6595
- delete: protectedProcedure.input(z16.object({ id: Id128Schema, ...ScopeShape2 })).mutation(({ input }) => deleteOrNotFound(
6731
+ delete: protectedProcedure.input(z17.object({ id: Id128Schema, ...ScopeShape2 })).mutation(({ input }) => deleteOrNotFound(
6596
6732
  async () => scenarioStore.delete(input.id, await scopeOf2(input)),
6597
6733
  "Scenario not found"
6598
6734
  )),
6599
- run: protectedProcedure.input(z16.object({
6735
+ run: protectedProcedure.input(z17.object({
6600
6736
  conversationId: ConversationIdSchema,
6601
6737
  scenarioId: Id128Schema,
6602
- userRequest: z16.string().max(1e5),
6603
- runnerOverride: z16.enum(["claude-code", "codex"]).optional(),
6738
+ userRequest: z17.string().max(1e5),
6739
+ runnerOverride: z17.enum(["claude-code", "codex"]).optional(),
6604
6740
  modelOverride: Id128Schema.optional(),
6605
6741
  agentId: Id128Schema.optional(),
6606
6742
  /** Anchors the run's working directory on the project it belongs to. */
6607
6743
  projectId: Id128Schema.optional(),
6608
6744
  /** Son organisation : sans elle, un id partagé désignerait un projet au hasard. */
6609
- orgId: z16.string().max(128).nullable().optional(),
6610
- resume: z16.boolean().optional()
6745
+ orgId: z17.string().max(128).nullable().optional(),
6746
+ resume: z17.boolean().optional()
6611
6747
  })).subscription(async function* ({ input, signal }) {
6612
6748
  const vault = await scopeOf2(input);
6613
6749
  const scenario = await scenarioStore.get(input.scenarioId, vault);
6614
- if (!scenario) throw new TRPCError14({ code: "NOT_FOUND", message: "Scenario not found" });
6750
+ if (!scenario) throw new TRPCError15({ code: "NOT_FOUND", message: "Scenario not found" });
6615
6751
  const canStart = input.userRequest.trim().length > 0 || !!input.resume;
6616
6752
  if (!isScenarioRunning(input.conversationId) && canStart) {
6617
6753
  let userRequest = input.userRequest;
@@ -6628,41 +6764,41 @@ var scenarioRouter = router({
6628
6764
  }
6629
6765
  yield* tapBus(input.conversationId, signal ?? new AbortController().signal);
6630
6766
  }),
6631
- stop: protectedProcedure.input(z16.object({ conversationId: ConversationIdSchema })).mutation(({ input }) => {
6767
+ stop: protectedProcedure.input(z17.object({ conversationId: ConversationIdSchema })).mutation(({ input }) => {
6632
6768
  abortScenario(input.conversationId);
6633
6769
  return { ok: true };
6634
6770
  }),
6635
- sendNodeInput: protectedProcedure.input(z16.object({
6771
+ sendNodeInput: protectedProcedure.input(z17.object({
6636
6772
  conversationId: ConversationIdSchema,
6637
6773
  nodeId: Id128Schema,
6638
- text: z16.string().min(1).max(1e5)
6774
+ text: z17.string().min(1).max(1e5)
6639
6775
  })).mutation(({ input }) => {
6640
6776
  const resolved = resolveNodeInput(input.conversationId, input.nodeId, input.text);
6641
- if (!resolved) throw new TRPCError14({ code: "NOT_FOUND", message: "No pending input request for this node" });
6777
+ if (!resolved) throw new TRPCError15({ code: "NOT_FOUND", message: "No pending input request for this node" });
6642
6778
  return { ok: true };
6643
6779
  }),
6644
- isRunning: protectedProcedure.input(z16.object({ conversationId: ConversationIdSchema })).query(({ input }) => ({ running: isScenarioRunning(input.conversationId) })),
6645
- runState: protectedProcedure.input(z16.object({ conversationId: ConversationIdSchema })).query(({ input }) => {
6780
+ isRunning: protectedProcedure.input(z17.object({ conversationId: ConversationIdSchema })).query(({ input }) => ({ running: isScenarioRunning(input.conversationId) })),
6781
+ runState: protectedProcedure.input(z17.object({ conversationId: ConversationIdSchema })).query(({ input }) => {
6646
6782
  const runState = scenarioRunStore.getRunState(input.conversationId);
6647
6783
  return runState ?? { nodeStates: {}, nodeOutputs: {}, activeNodeId: void 0 };
6648
6784
  }),
6649
- getPersistedRunState: protectedProcedure.input(z16.object({ conversationId: ConversationIdSchema })).query(async ({ input }) => {
6785
+ getPersistedRunState: protectedProcedure.input(z17.object({ conversationId: ConversationIdSchema })).query(async ({ input }) => {
6650
6786
  return await scenarioRunStore.loadPersistedRunState(input.conversationId);
6651
6787
  }),
6652
- getReadme: protectedProcedure.input(z16.object({ conversationId: ConversationIdSchema })).query(async ({ input }) => {
6788
+ getReadme: protectedProcedure.input(z17.object({ conversationId: ConversationIdSchema })).query(async ({ input }) => {
6653
6789
  return await scenarioRunStore.readReadme(input.conversationId);
6654
6790
  }),
6655
- getSnapshot: protectedProcedure.input(z16.object({ conversationId: ConversationIdSchema })).query(async ({ input }) => {
6791
+ getSnapshot: protectedProcedure.input(z17.object({ conversationId: ConversationIdSchema })).query(async ({ input }) => {
6656
6792
  return await scenarioRunStore.loadScenarioSnapshot(input.conversationId);
6657
6793
  }),
6658
- streamGenerateWithAI: protectedProcedure.input(z16.object({
6659
- prompt: z16.string().min(1).max(1e4),
6794
+ streamGenerateWithAI: protectedProcedure.input(z17.object({
6795
+ prompt: z17.string().min(1).max(1e4),
6660
6796
  providerId: OptionalProviderIdSchema,
6661
- model: z16.string().max(200).optional(),
6662
- current: z16.object({
6797
+ model: z17.string().max(200).optional(),
6798
+ current: z17.object({
6663
6799
  leaderId: Id128Schema,
6664
- groups: z16.array(ScenarioGroupSchema).max(100),
6665
- nodes: z16.array(ScenarioNodeSchema).max(500)
6800
+ groups: z17.array(ScenarioGroupSchema).max(100),
6801
+ nodes: z17.array(ScenarioNodeSchema).max(500)
6666
6802
  }).optional()
6667
6803
  })).subscription(async function* ({ input, signal }) {
6668
6804
  const userMessage = buildScenarioUserMessage(input.prompt, input.current);
@@ -6675,7 +6811,7 @@ var scenarioRouter = router({
6675
6811
  signal: signal ?? void 0
6676
6812
  });
6677
6813
  }),
6678
- streamRunEvents: protectedProcedure.input(z16.object({ conversationId: ConversationIdSchema })).subscription(async function* ({ input }) {
6814
+ streamRunEvents: protectedProcedure.input(z17.object({ conversationId: ConversationIdSchema })).subscription(async function* ({ input }) {
6679
6815
  const convId = input.conversationId;
6680
6816
  const runState = scenarioRunStore.getRunState(convId);
6681
6817
  if (runState) {
@@ -6689,24 +6825,24 @@ var scenarioRouter = router({
6689
6825
  * open a debug PTY with `claude --resume <sessionId>` on the right agent.
6690
6826
  * Falls back to the persisted run-state for past nodes.
6691
6827
  */
6692
- getNodeSession: protectedProcedure.input(z16.object({
6828
+ getNodeSession: protectedProcedure.input(z17.object({
6693
6829
  conversationId: ConversationIdSchema,
6694
6830
  nodeId: Id128Schema
6695
6831
  })).query(async ({ input }) => {
6696
6832
  return await scenarioRunStore.getNodeSessionPersistent(input.conversationId, input.nodeId);
6697
6833
  }),
6698
6834
  listPresets: protectedProcedure.query(() => listPresets()),
6699
- getPreset: protectedProcedure.input(z16.object({ id: Id128Schema })).query(({ input }) => {
6835
+ getPreset: protectedProcedure.input(z17.object({ id: Id128Schema })).query(({ input }) => {
6700
6836
  const preset = getPreset(input.id);
6701
- if (!preset) throw new TRPCError14({ code: "NOT_FOUND", message: "Preset not found" });
6837
+ if (!preset) throw new TRPCError15({ code: "NOT_FOUND", message: "Preset not found" });
6702
6838
  return preset;
6703
6839
  })
6704
6840
  });
6705
6841
 
6706
6842
  // ../server/src/trpc/routers/debug.ts
6707
6843
  import { randomUUID as randomUUID4 } from "crypto";
6708
- import { TRPCError as TRPCError15 } from "@trpc/server";
6709
- import { z as z17 } from "zod";
6844
+ import { TRPCError as TRPCError16 } from "@trpc/server";
6845
+ import { z as z18 } from "zod";
6710
6846
  var MAX_BUFFER2 = 300;
6711
6847
  var jobs = /* @__PURE__ */ new Map();
6712
6848
  function publish(job, event) {
@@ -6763,9 +6899,9 @@ async function* tapJob(job, signal) {
6763
6899
  }
6764
6900
  }
6765
6901
  var debugRouter = router({
6766
- startRandomJob: protectedProcedure.input(z17.object({
6767
- intervalMs: z17.number().int().min(100).max(5e3).optional(),
6768
- maxTicks: z17.number().int().min(1).max(1e4).optional()
6902
+ startRandomJob: protectedProcedure.input(z18.object({
6903
+ intervalMs: z18.number().int().min(100).max(5e3).optional(),
6904
+ maxTicks: z18.number().int().min(1).max(1e4).optional()
6769
6905
  }).optional()).mutation(({ input }) => {
6770
6906
  const jobId = randomUUID4();
6771
6907
  const intervalMs = input?.intervalMs ?? 400;
@@ -6799,15 +6935,15 @@ var debugRouter = router({
6799
6935
  jobs.set(jobId, job);
6800
6936
  return { jobId, intervalMs, maxTicks, startedAt: job.startedAt };
6801
6937
  }),
6802
- streamRandomJob: protectedProcedure.input(z17.object({ jobId: z17.string().max(128) })).subscription(async function* ({ input, signal }) {
6938
+ streamRandomJob: protectedProcedure.input(z18.object({ jobId: z18.string().max(128) })).subscription(async function* ({ input, signal }) {
6803
6939
  const job = jobs.get(input.jobId);
6804
6940
  if (!job) {
6805
- throw new TRPCError15({ code: "NOT_FOUND", message: "Random job not found" });
6941
+ throw new TRPCError16({ code: "NOT_FOUND", message: "Random job not found" });
6806
6942
  }
6807
6943
  yield* tapJob(job, signal ?? new AbortController().signal);
6808
6944
  }),
6809
- stopRandomJob: protectedProcedure.input(z17.object({ jobId: z17.string().max(128) })).mutation(({ input }) => ({ ok: stopJob(input.jobId, "stopped") })),
6810
- randomJobStatus: protectedProcedure.input(z17.object({ jobId: z17.string().max(128) })).query(({ input }) => {
6945
+ stopRandomJob: protectedProcedure.input(z18.object({ jobId: z18.string().max(128) })).mutation(({ input }) => ({ ok: stopJob(input.jobId, "stopped") })),
6946
+ randomJobStatus: protectedProcedure.input(z18.object({ jobId: z18.string().max(128) })).query(({ input }) => {
6811
6947
  const job = jobs.get(input.jobId);
6812
6948
  return {
6813
6949
  running: !!job && !job.done,
@@ -6817,8 +6953,8 @@ var debugRouter = router({
6817
6953
  });
6818
6954
 
6819
6955
  // ../server/src/trpc/routers/diagnostics.ts
6820
- import { z as z18 } from "zod";
6821
- import { TRPCError as TRPCError16 } from "@trpc/server";
6956
+ import { z as z19 } from "zod";
6957
+ import { TRPCError as TRPCError17 } from "@trpc/server";
6822
6958
 
6823
6959
  // ../server/src/services/log-buffer.ts
6824
6960
  import { EventEmitter } from "events";
@@ -6889,7 +7025,7 @@ function onEntry(listener) {
6889
7025
  // ../server/src/trpc/routers/diagnostics.ts
6890
7026
  var diagnosticsRouter = router({
6891
7027
  /** Backlog for a client that just opened the panel. */
6892
- recentLogs: protectedProcedure.input(z18.object({ limit: z18.number().int().min(1).max(2e3).default(500) }).optional()).query(({ input }) => recentEntries(input?.limit ?? 500)),
7028
+ recentLogs: protectedProcedure.input(z19.object({ limit: z19.number().int().min(1).max(2e3).default(500) }).optional()).query(({ input }) => recentEntries(input?.limit ?? 500)),
6893
7029
  /**
6894
7030
  * Live log stream.
6895
7031
  *
@@ -6898,7 +7034,7 @@ var diagnosticsRouter = router({
6898
7034
  * silently loses lines, which is precisely what someone watching a boot
6899
7035
  * failure cannot afford.
6900
7036
  */
6901
- streamLogs: protectedProcedure.input(z18.object({ afterSeq: z18.number().int().nonnegative().default(0) }).optional()).subscription(async function* ({ input, signal }) {
7037
+ streamLogs: protectedProcedure.input(z19.object({ afterSeq: z19.number().int().nonnegative().default(0) }).optional()).subscription(async function* ({ input, signal }) {
6902
7038
  for (const entry of entriesSince(input?.afterSeq ?? 0)) yield entry;
6903
7039
  const queue = [];
6904
7040
  let wake = null;
@@ -6932,18 +7068,18 @@ var diagnosticsRouter = router({
6932
7068
  * refused. That is what keeps this from being a way to signal arbitrary
6933
7069
  * processes with the server's privileges.
6934
7070
  */
6935
- killInstance: protectedProcedure.input(z18.object({ pid: z18.number().int().positive() })).mutation(async ({ input }) => {
7071
+ killInstance: protectedProcedure.input(z19.object({ pid: z19.number().int().positive() })).mutation(async ({ input }) => {
6936
7072
  try {
6937
7073
  return await killInstance(input.pid);
6938
7074
  } catch (err) {
6939
7075
  const reason = err.message;
6940
7076
  if (reason === "instance-not-found") {
6941
- throw new TRPCError16({ code: "NOT_FOUND", message: "No live Runeya instance with this pid." });
7077
+ throw new TRPCError17({ code: "NOT_FOUND", message: "No live Runeya instance with this pid." });
6942
7078
  }
6943
7079
  if (reason === "instance-is-current") {
6944
- throw new TRPCError16({ code: "BAD_REQUEST", message: "This instance cannot stop itself." });
7080
+ throw new TRPCError17({ code: "BAD_REQUEST", message: "This instance cannot stop itself." });
6945
7081
  }
6946
- throw new TRPCError16({ code: "INTERNAL_SERVER_ERROR", message: reason });
7082
+ throw new TRPCError17({ code: "INTERNAL_SERVER_ERROR", message: reason });
6947
7083
  }
6948
7084
  }),
6949
7085
  /**
@@ -6960,7 +7096,7 @@ var diagnosticsRouter = router({
6960
7096
  * reproductible : instance trop ancienne pour avoir publié sa ligne de
6961
7097
  * commande, ou lancée avec un secret que le registre ne conserve pas.
6962
7098
  */
6963
- restartInstance: protectedProcedure.input(z18.object({ pid: z18.number().int().positive() })).mutation(async ({ input }) => {
7099
+ restartInstance: protectedProcedure.input(z19.object({ pid: z19.number().int().positive() })).mutation(async ({ input }) => {
6964
7100
  try {
6965
7101
  if (input.pid === process.pid) {
6966
7102
  const { relauncherPid, port } = await scheduleSelfRestart();
@@ -6970,39 +7106,39 @@ var diagnosticsRouter = router({
6970
7106
  } catch (err) {
6971
7107
  const reason = err.message;
6972
7108
  if (reason === "instance-not-found") {
6973
- throw new TRPCError16({ code: "NOT_FOUND", message: "No live Runeya instance with this pid." });
7109
+ throw new TRPCError17({ code: "NOT_FOUND", message: "No live Runeya instance with this pid." });
6974
7110
  }
6975
7111
  if (reason.startsWith("instance-not-restartable:")) {
6976
- throw new TRPCError16({
7112
+ throw new TRPCError17({
6977
7113
  code: "BAD_REQUEST",
6978
7114
  message: `This instance cannot be restarted (${reason.split(":")[1]}).`
6979
7115
  });
6980
7116
  }
6981
- throw new TRPCError16({ code: "INTERNAL_SERVER_ERROR", message: reason });
7117
+ throw new TRPCError17({ code: "INTERNAL_SERVER_ERROR", message: reason });
6982
7118
  }
6983
7119
  })
6984
7120
  });
6985
7121
 
6986
7122
  // ../server/src/trpc/routers/mcp-pairing.ts
6987
- import { z as z20 } from "zod";
6988
- import { TRPCError as TRPCError17 } from "@trpc/server";
7123
+ import { z as z21 } from "zod";
7124
+ import { TRPCError as TRPCError18 } from "@trpc/server";
6989
7125
 
6990
7126
  // ../server/src/services/mcp-pairing.ts
6991
7127
  import { createHash, randomBytes as randomBytes2, randomInt, randomUUID as randomUUID5, timingSafeEqual } from "crypto";
6992
7128
  import { readFile as readFile3 } from "fs/promises";
6993
- import { z as z19 } from "zod";
7129
+ import { z as z20 } from "zod";
6994
7130
  var REQUEST_TTL_MS = 2 * 60 * 1e3;
6995
7131
  var MCP_TOKEN_TTL = "15m";
6996
7132
  var FILE = "mcp-clients.json";
6997
- var McpClientSchema = z19.object({
6998
- id: z19.string().uuid(),
6999
- name: z19.string().min(1).max(100),
7000
- cwd: z19.string().max(4096),
7133
+ var McpClientSchema = z20.object({
7134
+ id: z20.string().uuid(),
7135
+ name: z20.string().min(1).max(100),
7136
+ cwd: z20.string().max(4096),
7001
7137
  /** SHA-256 du secret, en hexadécimal. */
7002
- secretHash: z19.string().regex(/^[0-9a-f]{64}$/),
7003
- createdAt: z19.string().max(64)
7138
+ secretHash: z20.string().regex(/^[0-9a-f]{64}$/),
7139
+ createdAt: z20.string().max(64)
7004
7140
  });
7005
- var McpClientsFileSchema = z19.object({ clients: z19.array(McpClientSchema).max(500) });
7141
+ var McpClientsFileSchema = z20.object({ clients: z20.array(McpClientSchema).max(500) });
7006
7142
  function hashSecret(secret) {
7007
7143
  return createHash("sha256").update(secret).digest("hex");
7008
7144
  }
@@ -7132,35 +7268,35 @@ var mcpPairing = new McpPairing(() => keyedFilePath(FILE));
7132
7268
  // ../server/src/trpc/routers/mcp-pairing.ts
7133
7269
  function asBadRequest(fn) {
7134
7270
  return Promise.resolve().then(fn).catch((err) => {
7135
- throw new TRPCError17({ code: "BAD_REQUEST", message: err.message });
7271
+ throw new TRPCError18({ code: "BAD_REQUEST", message: err.message });
7136
7272
  });
7137
7273
  }
7138
7274
  var mcpPairingRouter = router({
7139
- request: publicProcedure.input(z20.object({ name: z20.string().min(1).max(100), cwd: z20.string().max(4096) })).mutation(({ ctx, input }) => {
7275
+ request: publicProcedure.input(z21.object({ name: z21.string().min(1).max(100), cwd: z21.string().max(4096) })).mutation(({ ctx, input }) => {
7140
7276
  requireLoopback(ctx);
7141
7277
  if (isCiMode()) {
7142
- throw new TRPCError17({
7278
+ throw new TRPCError18({
7143
7279
  code: "PRECONDITION_FAILED",
7144
7280
  message: "Runeya tourne en mode CI : l'appairage y est d\xE9sactiv\xE9. Passe une cl\xE9 d'API dans RUNEYA_API_TOKEN."
7145
7281
  });
7146
7282
  }
7147
7283
  return asBadRequest(() => mcpPairing.request(input.name, input.cwd));
7148
7284
  }),
7149
- status: publicProcedure.input(z20.object({ requestId: z20.string().uuid() })).query(({ ctx, input }) => {
7285
+ status: publicProcedure.input(z21.object({ requestId: z21.string().uuid() })).query(({ ctx, input }) => {
7150
7286
  requireLoopback(ctx);
7151
7287
  return mcpPairing.status(input.requestId);
7152
7288
  }),
7153
- exchange: publicProcedure.input(z20.object({ secret: z20.string().min(1).max(200) })).mutation(({ ctx, input }) => {
7289
+ exchange: publicProcedure.input(z21.object({ secret: z21.string().min(1).max(200) })).mutation(({ ctx, input }) => {
7154
7290
  requireLoopback(ctx);
7155
7291
  return mcpPairing.exchange(input.secret).then((token) => ({ token })).catch(() => {
7156
- throw new TRPCError17({ code: "UNAUTHORIZED", message: "Unknown or revoked MCP pairing." });
7292
+ throw new TRPCError18({ code: "UNAUTHORIZED", message: "Unknown or revoked MCP pairing." });
7157
7293
  });
7158
7294
  }),
7159
7295
  pending: protectedProcedure.query(({ ctx }) => {
7160
7296
  requireHuman(ctx);
7161
7297
  return mcpPairing.pending();
7162
7298
  }),
7163
- decide: protectedProcedure.input(z20.object({ requestId: z20.string().uuid(), approve: z20.boolean() })).mutation(({ ctx, input }) => {
7299
+ decide: protectedProcedure.input(z21.object({ requestId: z21.string().uuid(), approve: z21.boolean() })).mutation(({ ctx, input }) => {
7164
7300
  requireHuman(ctx);
7165
7301
  return asBadRequest(() => mcpPairing.decide(input.requestId, input.approve));
7166
7302
  }),
@@ -7168,22 +7304,22 @@ var mcpPairingRouter = router({
7168
7304
  requireHuman(ctx);
7169
7305
  return mcpPairing.list();
7170
7306
  }),
7171
- revoke: protectedProcedure.input(z20.object({ id: z20.string().uuid() })).mutation(({ ctx, input }) => {
7307
+ revoke: protectedProcedure.input(z21.object({ id: z21.string().uuid() })).mutation(({ ctx, input }) => {
7172
7308
  requireHuman(ctx);
7173
7309
  return mcpPairing.revoke(input.id);
7174
7310
  })
7175
7311
  });
7176
7312
 
7177
7313
  // ../server/src/trpc/routers/ai-clients.ts
7178
- import { z as z21 } from "zod";
7179
- import { TRPCError as TRPCError18 } from "@trpc/server";
7314
+ import { z as z22 } from "zod";
7315
+ import { TRPCError as TRPCError19 } from "@trpc/server";
7180
7316
 
7181
7317
  // ../server/src/services/ai-client-mcp.ts
7182
7318
  import { execFile as execFile4 } from "child_process";
7183
7319
  import { existsSync as existsSync2, readdirSync } from "fs";
7184
7320
  import { mkdir as mkdir5, readFile as readFile4, realpath } from "fs/promises";
7185
7321
  import { homedir as homedir3 } from "os";
7186
- import { dirname as dirname4, join as join7 } from "path";
7322
+ import { dirname as dirname4, join as join8 } from "path";
7187
7323
  var SERVER_NAME = "runeya";
7188
7324
  function mcpEntry(override = env.MCP_COMMAND ?? null, home = env.HOME_DIR, platform = process.platform) {
7189
7325
  const [command, ...args] = override ? override.split(/\s+/) : ["runeya"];
@@ -7197,9 +7333,9 @@ function envFlags(flag, entry) {
7197
7333
  return Object.entries(entry.env ?? {}).flatMap(([k, v]) => [flag, `${k}=${v}`]);
7198
7334
  }
7199
7335
  function vscodeUserDir(home) {
7200
- if (process.platform === "darwin") return join7(home, "Library", "Application Support", "Code", "User");
7201
- if (process.platform === "win32") return join7(process.env["APPDATA"] ?? join7(home, "AppData", "Roaming"), "Code", "User");
7202
- return join7(home, ".config", "Code", "User");
7336
+ if (process.platform === "darwin") return join8(home, "Library", "Application Support", "Code", "User");
7337
+ if (process.platform === "win32") return join8(process.env["APPDATA"] ?? join8(home, "AppData", "Roaming"), "Code", "User");
7338
+ return join8(home, ".config", "Code", "User");
7203
7339
  }
7204
7340
  function listDir(dir) {
7205
7341
  try {
@@ -7209,14 +7345,14 @@ function listDir(dir) {
7209
7345
  }
7210
7346
  }
7211
7347
  function claudeDesktopDir(home, platform = process.platform, vars = process.env, exists4 = existsSync2, list = listDir) {
7212
- if (platform === "darwin") return join7(home, "Library", "Application Support", "Claude");
7348
+ if (platform === "darwin") return join8(home, "Library", "Application Support", "Claude");
7213
7349
  if (platform === "win32") {
7214
- const packages = join7(vars["LOCALAPPDATA"] ?? join7(home, "AppData", "Local"), "Packages");
7215
- const store = list(packages).filter((name) => name.startsWith("Claude_")).map((name) => join7(packages, name, "LocalCache", "Roaming", "Claude")).find(exists4);
7350
+ const packages = join8(vars["LOCALAPPDATA"] ?? join8(home, "AppData", "Local"), "Packages");
7351
+ const store = list(packages).filter((name) => name.startsWith("Claude_")).map((name) => join8(packages, name, "LocalCache", "Roaming", "Claude")).find(exists4);
7216
7352
  if (store) return store;
7217
- return join7(vars["APPDATA"] ?? join7(home, "AppData", "Roaming"), "Claude");
7353
+ return join8(vars["APPDATA"] ?? join8(home, "AppData", "Roaming"), "Claude");
7218
7354
  }
7219
- return join7(home, ".config", "Claude");
7355
+ return join8(home, ".config", "Claude");
7220
7356
  }
7221
7357
  var AI_CLIENTS = [
7222
7358
  {
@@ -7224,7 +7360,7 @@ var AI_CLIENTS = [
7224
7360
  label: "Claude Code",
7225
7361
  kind: "cli",
7226
7362
  binary: "claude",
7227
- configFile: (home) => join7(home, ".claude.json"),
7363
+ configFile: (home) => join8(home, ".claude.json"),
7228
7364
  isInstalled: (content) => {
7229
7365
  try {
7230
7366
  const servers2 = JSON.parse(content).mcpServers;
@@ -7242,33 +7378,33 @@ var AI_CLIENTS = [
7242
7378
  label: "Codex",
7243
7379
  kind: "cli",
7244
7380
  binary: "codex",
7245
- configFile: (home) => join7(home, ".codex", "config.toml"),
7381
+ configFile: (home) => join8(home, ".codex", "config.toml"),
7246
7382
  isInstalled: (content) => new RegExp(`^\\s*\\[mcp_servers\\.${SERVER_NAME}\\]`, "m").test(content),
7247
7383
  addArgs: (e) => ["mcp", "add", ...envFlags("--env", e), SERVER_NAME, "--", e.command, ...e.args],
7248
7384
  removeArgs: ["mcp", "remove", SERVER_NAME]
7249
7385
  },
7250
- { id: "cursor", label: "Cursor", kind: "json", detectDir: (h) => join7(h, ".cursor"), configFile: (h) => join7(h, ".cursor", "mcp.json") },
7251
- { id: "gemini", label: "Gemini CLI", kind: "json", detectDir: (h) => join7(h, ".gemini"), configFile: (h) => join7(h, ".gemini", "settings.json") },
7386
+ { id: "cursor", label: "Cursor", kind: "json", detectDir: (h) => join8(h, ".cursor"), configFile: (h) => join8(h, ".cursor", "mcp.json") },
7387
+ { id: "gemini", label: "Gemini CLI", kind: "json", detectDir: (h) => join8(h, ".gemini"), configFile: (h) => join8(h, ".gemini", "settings.json") },
7252
7388
  {
7253
7389
  id: "windsurf",
7254
7390
  label: "Windsurf",
7255
7391
  kind: "json",
7256
- detectDir: (h) => join7(h, ".codeium", "windsurf"),
7257
- configFile: (h) => join7(h, ".codeium", "windsurf", "mcp_config.json")
7392
+ detectDir: (h) => join8(h, ".codeium", "windsurf"),
7393
+ configFile: (h) => join8(h, ".codeium", "windsurf", "mcp_config.json")
7258
7394
  },
7259
7395
  {
7260
7396
  id: "claude-desktop",
7261
7397
  label: "Claude Desktop",
7262
7398
  kind: "json",
7263
7399
  detectDir: claudeDesktopDir,
7264
- configFile: (h) => join7(claudeDesktopDir(h), "claude_desktop_config.json")
7400
+ configFile: (h) => join8(claudeDesktopDir(h), "claude_desktop_config.json")
7265
7401
  },
7266
7402
  {
7267
7403
  id: "vscode",
7268
7404
  label: "VS Code",
7269
7405
  kind: "json",
7270
7406
  detectDir: vscodeUserDir,
7271
- configFile: (h) => join7(vscodeUserDir(h), "mcp.json"),
7407
+ configFile: (h) => join8(vscodeUserDir(h), "mcp.json"),
7272
7408
  serversKey: "servers",
7273
7409
  entryFields: { type: "stdio" }
7274
7410
  }
@@ -7362,25 +7498,25 @@ async function setAiClientMcp(id, present, home = homedir3()) {
7362
7498
  }
7363
7499
 
7364
7500
  // ../server/src/trpc/routers/ai-clients.ts
7365
- var AiClientIdSchema = z21.enum(["claude-code", "codex", "cursor", "gemini", "windsurf", "claude-desktop", "vscode"]);
7501
+ var AiClientIdSchema = z22.enum(["claude-code", "codex", "cursor", "gemini", "windsurf", "claude-desktop", "vscode"]);
7366
7502
  var aiClientsRouter = router({
7367
7503
  list: protectedProcedure.query(({ ctx }) => {
7368
7504
  requireHuman(ctx);
7369
7505
  return listAiClients();
7370
7506
  }),
7371
- setInstalled: protectedProcedure.input(z21.object({ id: AiClientIdSchema, installed: z21.boolean() })).mutation(async ({ ctx, input }) => {
7507
+ setInstalled: protectedProcedure.input(z22.object({ id: AiClientIdSchema, installed: z22.boolean() })).mutation(async ({ ctx, input }) => {
7372
7508
  requireHuman(ctx);
7373
7509
  try {
7374
7510
  await setAiClientMcp(input.id, input.installed);
7375
7511
  } catch (err) {
7376
- throw new TRPCError18({ code: "BAD_REQUEST", message: err.message });
7512
+ throw new TRPCError19({ code: "BAD_REQUEST", message: err.message });
7377
7513
  }
7378
7514
  return listAiClients();
7379
7515
  })
7380
7516
  });
7381
7517
 
7382
7518
  // ../server/src/trpc/routers/kanban-queue.ts
7383
- import { z as z22 } from "zod";
7519
+ import { z as z23 } from "zod";
7384
7520
 
7385
7521
  // ../server/src/services/kanban-queue.ts
7386
7522
  import { randomUUID as randomUUID6 } from "crypto";
@@ -7572,38 +7708,38 @@ var kanbanQueue = new KanbanQueueService();
7572
7708
  // ../server/src/trpc/routers/kanban-queue.ts
7573
7709
  var kanbanQueueRouter = router({
7574
7710
  getState: protectedProcedure.query(() => kanbanQueue.getState()),
7575
- add: protectedProcedure.input(z22.object({
7576
- boardId: z22.string().max(128),
7577
- cardId: z22.string().max(128),
7578
- runner: z22.enum(["claude-code", "codex"]).optional(),
7579
- model: z22.string().max(128).optional(),
7580
- scenarioId: z22.string().max(128).optional(),
7711
+ add: protectedProcedure.input(z23.object({
7712
+ boardId: z23.string().max(128),
7713
+ cardId: z23.string().max(128),
7714
+ runner: z23.enum(["claude-code", "codex"]).optional(),
7715
+ model: z23.string().max(128).optional(),
7716
+ scenarioId: z23.string().max(128).optional(),
7581
7717
  // Le projet ouvert quand la carte a été mise en file : la conversation
7582
7718
  // qui en naîtra lui appartient, plutôt que de rester orpheline et de
7583
7719
  // s'afficher dans tous les projets.
7584
- projectId: z22.string().max(128).optional(),
7585
- orgId: z22.string().max(128).nullable().optional()
7720
+ projectId: z23.string().max(128).optional(),
7721
+ orgId: z23.string().max(128).nullable().optional()
7586
7722
  })).mutation(({ input }) => kanbanQueue.add(input)),
7587
- addColumn: protectedProcedure.input(z22.object({
7588
- boardId: z22.string().max(128),
7589
- columnId: z22.string().max(128),
7723
+ addColumn: protectedProcedure.input(z23.object({
7724
+ boardId: z23.string().max(128),
7725
+ columnId: z23.string().max(128),
7590
7726
  // Les cartes visibles côté écran : une colonne filtrée n'envoie qu'elles.
7591
- cardIds: z22.array(z22.string().max(128)).max(5e3).optional(),
7592
- runner: z22.enum(["claude-code", "codex"]).optional(),
7593
- model: z22.string().max(128).optional(),
7594
- scenarioId: z22.string().max(128).optional(),
7595
- projectId: z22.string().max(128).optional(),
7596
- orgId: z22.string().max(128).nullable().optional()
7727
+ cardIds: z23.array(z23.string().max(128)).max(5e3).optional(),
7728
+ runner: z23.enum(["claude-code", "codex"]).optional(),
7729
+ model: z23.string().max(128).optional(),
7730
+ scenarioId: z23.string().max(128).optional(),
7731
+ projectId: z23.string().max(128).optional(),
7732
+ orgId: z23.string().max(128).nullable().optional()
7597
7733
  })).mutation(async ({ input }) => {
7598
7734
  const { boardId, columnId, ...options } = input;
7599
7735
  return kanbanQueue.addColumn(boardId, columnId, options);
7600
7736
  }),
7601
- remove: protectedProcedure.input(z22.object({ itemId: z22.string().max(128) })).mutation(({ input }) => ({ removed: kanbanQueue.remove(input.itemId) })),
7737
+ remove: protectedProcedure.input(z23.object({ itemId: z23.string().max(128) })).mutation(({ input }) => ({ removed: kanbanQueue.remove(input.itemId) })),
7602
7738
  stopAll: protectedProcedure.mutation(() => {
7603
7739
  kanbanQueue.stopAll();
7604
7740
  return { ok: true };
7605
7741
  }),
7606
- setMaxConcurrent: protectedProcedure.input(z22.object({ max: z22.number().int().min(1).max(20) })).mutation(({ input }) => {
7742
+ setMaxConcurrent: protectedProcedure.input(z23.object({ max: z23.number().int().min(1).max(20) })).mutation(({ input }) => {
7607
7743
  kanbanQueue.setMaxConcurrent(input.max);
7608
7744
  return kanbanQueue.getState();
7609
7745
  }),
@@ -7640,13 +7776,13 @@ var kanbanQueueRouter = router({
7640
7776
  import { mkdir as mkdir6, readdir, rm, stat as stat3, writeFile as writeFile4 } from "fs/promises";
7641
7777
  import { createHash as createHash2 } from "crypto";
7642
7778
  import { tmpdir } from "os";
7643
- import { join as join8 } from "path";
7644
- import { z as z23 } from "zod";
7645
- import { TRPCError as TRPCError19 } from "@trpc/server";
7779
+ import { join as join9 } from "path";
7780
+ import { z as z24 } from "zod";
7781
+ import { TRPCError as TRPCError20 } from "@trpc/server";
7646
7782
  var protectedProcedure2 = protectedProcedure.use(async ({ next }) => {
7647
7783
  const result = await next();
7648
7784
  if (!result.ok && result.error.cause instanceof KanbanUnavailableError) {
7649
- throw new TRPCError19({
7785
+ throw new TRPCError20({
7650
7786
  code: "PRECONDITION_FAILED",
7651
7787
  message: result.error.message,
7652
7788
  cause: result.error.cause
@@ -7694,14 +7830,14 @@ function safeDecode(value) {
7694
7830
  }
7695
7831
  var MAX_ATTACHMENT_BYTES = 55 * 1024 * 1024;
7696
7832
  function attachmentCacheDir() {
7697
- return join8(tmpdir(), "runeya-kanban-attachments");
7833
+ return join9(tmpdir(), "runeya-kanban-attachments");
7698
7834
  }
7699
7835
  var ATTACHMENT_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
7700
7836
  async function purgeStaleAttachments(dir, ttlMs = ATTACHMENT_CACHE_TTL_MS) {
7701
7837
  try {
7702
7838
  const cutoff = Date.now() - ttlMs;
7703
7839
  for (const name of await readdir(dir)) {
7704
- const path = join8(dir, name);
7840
+ const path = join9(dir, name);
7705
7841
  const info = await stat3(path).catch(() => null);
7706
7842
  if (info && info.mtimeMs < cutoff) await rm(path, { force: true });
7707
7843
  }
@@ -7709,14 +7845,14 @@ async function purgeStaleAttachments(dir, ttlMs = ATTACHMENT_CACHE_TTL_MS) {
7709
7845
  }
7710
7846
  }
7711
7847
  function attachmentCacheDirs() {
7712
- return [attachmentCacheDir(), join8(machineRoot(), "kanban-attachments")];
7848
+ return [attachmentCacheDir(), join9(machineRoot(), "kanban-attachments")];
7713
7849
  }
7714
7850
  async function storeAttachment(id, name, body, dirs = attachmentCacheDirs()) {
7715
7851
  const refusals = [];
7716
7852
  for (const dir of dirs) {
7717
7853
  try {
7718
7854
  await mkdir6(dir, { recursive: true });
7719
- const path = join8(dir, safeLocalName(id, name));
7855
+ const path = join9(dir, safeLocalName(id, name));
7720
7856
  await writeFile4(path, body);
7721
7857
  void purgeStaleAttachments(dir);
7722
7858
  return path;
@@ -7724,7 +7860,7 @@ async function storeAttachment(id, name, body, dirs = attachmentCacheDirs()) {
7724
7860
  refusals.push(`${dir} (${err instanceof Error ? err.message : String(err)})`);
7725
7861
  }
7726
7862
  }
7727
- throw new TRPCError19({
7863
+ throw new TRPCError20({
7728
7864
  code: "INTERNAL_SERVER_ERROR",
7729
7865
  message: `Impossible d'\xE9crire la pi\xE8ce jointe sur cette machine. Emplacements essay\xE9s : ${refusals.join(" ; ")}. V\xE9rifiez les droits d'\xE9criture, ou l'espace disque.`
7730
7866
  });
@@ -7745,9 +7881,9 @@ var kanbanRouter = router({
7745
7881
  * card graph, so listing them in full would be megabytes to answer "which
7746
7882
  * boards exist?". Use `getBoard` for the cards of one.
7747
7883
  */
7748
- listBoards: protectedProcedure2.input(z23.object({
7749
- includeArchived: z23.boolean().optional(),
7750
- organizationId: z23.string().max(128).optional()
7884
+ listBoards: protectedProcedure2.input(z24.object({
7885
+ includeArchived: z24.boolean().optional(),
7886
+ organizationId: z24.string().max(128).optional()
7751
7887
  }).optional()).query(async ({ input }) => {
7752
7888
  const { organizationId, boards } = await kanbanStore.list(
7753
7889
  input?.includeArchived ?? false,
@@ -7773,7 +7909,7 @@ var kanbanRouter = router({
7773
7909
  };
7774
7910
  }),
7775
7911
  /** One board: its columns, and the cards in each. */
7776
- getBoard: protectedProcedure2.input(z23.object({ boardId: z23.string().max(128) })).query(async ({ input }) => {
7912
+ getBoard: protectedProcedure2.input(z24.object({ boardId: z24.string().max(128) })).query(async ({ input }) => {
7777
7913
  const board = await kanbanStore.get(input.boardId);
7778
7914
  if (!board) return { board: null };
7779
7915
  const { links } = await kanbanStore.cardLinks(input.boardId);
@@ -7812,12 +7948,12 @@ var kanbanRouter = router({
7812
7948
  * organization — or one board when `boardId` is given. Archived boards are
7813
7949
  * left out: they are what the team decided to stop looking at.
7814
7950
  */
7815
- searchCards: protectedProcedure2.input(z23.object({
7816
- query: z23.string().max(256).optional(),
7817
- createdBy: z23.string().min(1).max(200).optional(),
7818
- boardId: z23.string().max(128).optional(),
7819
- limit: z23.number().int().min(1).max(100).optional(),
7820
- organizationId: z23.string().max(128).optional()
7951
+ searchCards: protectedProcedure2.input(z24.object({
7952
+ query: z24.string().max(256).optional(),
7953
+ createdBy: z24.string().min(1).max(200).optional(),
7954
+ boardId: z24.string().max(128).optional(),
7955
+ limit: z24.number().int().min(1).max(100).optional(),
7956
+ organizationId: z24.string().max(128).optional()
7821
7957
  }).refine((i) => !!i.query?.trim() || !!i.createdBy?.trim(), { message: "query or createdBy is required." })).query(async ({ input }) => {
7822
7958
  return kanbanStore.searchCards(input);
7823
7959
  }),
@@ -7825,10 +7961,10 @@ var kanbanRouter = router({
7825
7961
  * Les conversations de support liées à une carte, avec leur fil — ce que
7826
7962
  * le client a écrit à l'équipe, séparé des commentaires de la carte.
7827
7963
  */
7828
- getCardConversations: protectedProcedure2.input(z23.object({
7829
- boardId: z23.string().max(128),
7830
- cardId: z23.string().max(128),
7831
- limit: z23.number().int().min(1).max(500).optional()
7964
+ getCardConversations: protectedProcedure2.input(z24.object({
7965
+ boardId: z24.string().max(128),
7966
+ cardId: z24.string().max(128),
7967
+ limit: z24.number().int().min(1).max(500).optional()
7832
7968
  })).query(async ({ input }) => {
7833
7969
  const conversations = await kanbanStore.cardConversations(input.boardId, input.cardId);
7834
7970
  const limit = input.limit ?? 100;
@@ -7841,13 +7977,13 @@ var kanbanRouter = router({
7841
7977
  };
7842
7978
  }),
7843
7979
  /** Chercher une conversation chez les fournisseurs de l'organisation (lecture seule côté fournisseur). */
7844
- searchConversations: protectedProcedure2.input(z23.object({ boardId: z23.string().max(128), query: z23.string().trim().min(1).max(500) })).query(async ({ input }) => ({ results: await kanbanStore.searchConversations(input.boardId, input.query) })),
7980
+ searchConversations: protectedProcedure2.input(z24.object({ boardId: z24.string().max(128), query: z24.string().trim().min(1).max(500) })).query(async ({ input }) => ({ results: await kanbanStore.searchConversations(input.boardId, input.query) })),
7845
7981
  /** Lier une conversation trouvée à une carte. N'écrit rien chez le fournisseur. */
7846
- linkConversation: protectedProcedure2.input(z23.object({
7847
- boardId: z23.string().max(128),
7848
- cardId: z23.string().max(128),
7849
- connectionId: z23.string().max(128),
7850
- externalId: z23.string().max(128)
7982
+ linkConversation: protectedProcedure2.input(z24.object({
7983
+ boardId: z24.string().max(128),
7984
+ cardId: z24.string().max(128),
7985
+ connectionId: z24.string().max(128),
7986
+ externalId: z24.string().max(128)
7851
7987
  })).mutation(async ({ input }) => ({ conversations: await kanbanStore.linkConversation(input) })),
7852
7988
  /**
7853
7989
  * Le fil de commentaires d'une carte, relu à la demande.
@@ -7858,10 +7994,10 @@ var kanbanRouter = router({
7858
7994
  * qu'un `commentCount`, et rien n'en donnait le texte. Cette route est la
7859
7995
  * relecture, pour une seule carte : c'est le journal qui pèse, pas le reste.
7860
7996
  */
7861
- getCardComments: protectedProcedure2.input(z23.object({
7862
- boardId: z23.string().max(128),
7863
- cardId: z23.string().max(128),
7864
- limit: z23.number().int().min(1).max(200).optional()
7997
+ getCardComments: protectedProcedure2.input(z24.object({
7998
+ boardId: z24.string().max(128),
7999
+ cardId: z24.string().max(128),
8000
+ limit: z24.number().int().min(1).max(200).optional()
7865
8001
  })).query(async ({ input }) => {
7866
8002
  const history = await kanbanStore.cardHistory(input.boardId, input.cardId);
7867
8003
  const comments = history.filter((e) => e.type === "comment");
@@ -7890,18 +8026,18 @@ var kanbanRouter = router({
7890
8026
  * `getBoard` en donne déjà l'essentiel carte par carte ; cette route sert
7891
8027
  * quand c'est l'arbre lui-même qu'on veut, dates et auteurs compris.
7892
8028
  */
7893
- getCardLinks: protectedProcedure2.input(z23.object({ boardId: z23.string().max(128) })).query(async ({ input }) => kanbanStore.cardLinks(input.boardId)),
8029
+ getCardLinks: protectedProcedure2.input(z24.object({ boardId: z24.string().max(128) })).query(async ({ input }) => kanbanStore.cardLinks(input.boardId)),
7894
8030
  /**
7895
8031
  * Rattacher une carte à une carte parente, ou l'en détacher.
7896
8032
  *
7897
8033
  * Sans `parentCardId`, le lien est retiré. Le parent peut vivre sur un autre
7898
8034
  * tableau : `parentBoardId` le désigne alors, sinon c'est celui de la carte.
7899
8035
  */
7900
- setCardParent: protectedProcedure2.input(z23.object({
7901
- boardId: z23.string().max(128),
7902
- cardId: z23.string().max(128),
7903
- parentCardId: z23.string().max(128).optional(),
7904
- parentBoardId: z23.string().max(128).optional()
8036
+ setCardParent: protectedProcedure2.input(z24.object({
8037
+ boardId: z24.string().max(128),
8038
+ cardId: z24.string().max(128),
8039
+ parentCardId: z24.string().max(128).optional(),
8040
+ parentBoardId: z24.string().max(128).optional()
7905
8041
  })).mutation(async ({ input }) => {
7906
8042
  const ok = await kanbanStore.setCardParent(
7907
8043
  input.boardId,
@@ -7909,7 +8045,7 @@ var kanbanRouter = router({
7909
8045
  input.parentCardId ? { boardId: input.parentBoardId ?? input.boardId, cardId: input.parentCardId } : null
7910
8046
  );
7911
8047
  if (!ok) {
7912
- throw new TRPCError19({ code: "BAD_REQUEST", message: "The cloud refused the link (unknown card, or a cycle)." });
8048
+ throw new TRPCError20({ code: "BAD_REQUEST", message: "The cloud refused the link (unknown card, or a cycle)." });
7913
8049
  }
7914
8050
  return { ok: true };
7915
8051
  }),
@@ -7918,48 +8054,48 @@ var kanbanRouter = router({
7918
8054
  * `boardId` est le tableau où on la pose (ou d'où on la retire) ; la carte
7919
8055
  * reste sur son tableau d'origine.
7920
8056
  */
7921
- getCardPlacements: protectedProcedure2.input(z23.object({ boardId: z23.string().max(128), cardId: z23.string().max(128) })).query(async ({ input }) => ({ placements: await kanbanStore.cardPlacements(input.boardId, input.cardId) })),
7922
- placeCard: protectedProcedure2.input(z23.object({ boardId: z23.string().max(128), cardId: z23.string().max(128), column: z23.string().min(1).max(200) })).mutation(async ({ input }) => {
8057
+ getCardPlacements: protectedProcedure2.input(z24.object({ boardId: z24.string().max(128), cardId: z24.string().max(128) })).query(async ({ input }) => ({ placements: await kanbanStore.cardPlacements(input.boardId, input.cardId) })),
8058
+ placeCard: protectedProcedure2.input(z24.object({ boardId: z24.string().max(128), cardId: z24.string().max(128), column: z24.string().min(1).max(200) })).mutation(async ({ input }) => {
7923
8059
  const res = await kanbanStore.placeCard(input.boardId, input.cardId, input.column);
7924
8060
  if (!res.ok) {
7925
- throw new TRPCError19({
8061
+ throw new TRPCError20({
7926
8062
  code: "BAD_REQUEST",
7927
8063
  message: res.reason ?? "The cloud refused the placement (unknown card or column, archived card, or already on this board)."
7928
8064
  });
7929
8065
  }
7930
8066
  return { ok: true };
7931
8067
  }),
7932
- unplaceCard: protectedProcedure2.input(z23.object({ boardId: z23.string().max(128), cardId: z23.string().max(128) })).mutation(async ({ input }) => {
8068
+ unplaceCard: protectedProcedure2.input(z24.object({ boardId: z24.string().max(128), cardId: z24.string().max(128) })).mutation(async ({ input }) => {
7933
8069
  if (!await kanbanStore.unplaceCard(input.boardId, input.cardId)) {
7934
- throw new TRPCError19({ code: "NOT_FOUND", message: "This card is not placed on this board." });
8070
+ throw new TRPCError20({ code: "NOT_FOUND", message: "This card is not placed on this board." });
7935
8071
  }
7936
8072
  return { ok: true };
7937
8073
  }),
7938
- moveCard: protectedProcedure2.input(z23.object({
7939
- boardId: z23.string().max(128),
7940
- cardId: z23.string().max(128),
7941
- targetColumn: z23.string().max(256)
8074
+ moveCard: protectedProcedure2.input(z24.object({
8075
+ boardId: z24.string().max(128),
8076
+ cardId: z24.string().max(128),
8077
+ targetColumn: z24.string().max(256)
7942
8078
  })).mutation(async ({ input }) => {
7943
8079
  await executeKanbanCommands(input.boardId, input.cardId, [
7944
8080
  { type: "move_card", columnTitle: input.targetColumn }
7945
8081
  ]);
7946
8082
  return { ok: true };
7947
8083
  }),
7948
- addComment: protectedProcedure2.input(z23.object({
7949
- boardId: z23.string().max(128),
7950
- cardId: z23.string().max(128),
7951
- comment: z23.string().max(1e5)
8084
+ addComment: protectedProcedure2.input(z24.object({
8085
+ boardId: z24.string().max(128),
8086
+ cardId: z24.string().max(128),
8087
+ comment: z24.string().max(1e5)
7952
8088
  })).mutation(async ({ input }) => {
7953
8089
  await executeKanbanCommands(input.boardId, input.cardId, [
7954
8090
  { type: "add_comment", comment: input.comment }
7955
8091
  ]);
7956
8092
  return { ok: true };
7957
8093
  }),
7958
- addCard: protectedProcedure2.input(z23.object({
7959
- boardId: z23.string().max(128),
7960
- column: z23.string().max(256),
7961
- title: z23.string().max(512),
7962
- content: z23.string().max(2e4).optional()
8094
+ addCard: protectedProcedure2.input(z24.object({
8095
+ boardId: z24.string().max(128),
8096
+ column: z24.string().max(256),
8097
+ title: z24.string().max(512),
8098
+ content: z24.string().max(2e4).optional()
7963
8099
  })).mutation(async ({ input }) => {
7964
8100
  await executeKanbanBoardCommands(input.boardId, [
7965
8101
  { type: "add_card", columnTitle: input.column, cardTitle: input.title, cardContent: input.content }
@@ -7972,7 +8108,7 @@ var kanbanRouter = router({
7972
8108
  * `getBoard` rapatrie le tableau entier pour n'en regarder qu'une ; et il ne
7973
8109
  * porte pas les cartes rangées. Une carte s'adresse par son identifiant.
7974
8110
  */
7975
- getCard: protectedProcedure2.input(z23.object({ boardId: z23.string().max(128), cardId: z23.string().max(128) })).query(async ({ input }) => {
8111
+ getCard: protectedProcedure2.input(z24.object({ boardId: z24.string().max(128), cardId: z24.string().max(128) })).query(async ({ input }) => {
7976
8112
  const found = await kanbanStore.card(input.boardId, input.cardId);
7977
8113
  if (!found) throw new Error(`Carte ${input.cardId} introuvable sur le tableau ${input.boardId}.`);
7978
8114
  return { ...summarizeCard(found.card, input.boardId, ""), columnId: found.columnId };
@@ -7983,16 +8119,16 @@ var kanbanRouter = router({
7983
8119
  * endroit (`buildKanbanCardPrompt`). L'outil le reçoit comme un message, pas
7984
8120
  * comme une consigne système : il guide le travail sans en avoir la force.
7985
8121
  */
7986
- cardContext: protectedProcedure2.input(z23.object({
7987
- boardId: z23.string().max(128),
7988
- cardId: z23.string().max(128),
7989
- projectId: z23.string().max(128).optional(),
7990
- orgId: z23.string().max(128).optional()
8122
+ cardContext: protectedProcedure2.input(z24.object({
8123
+ boardId: z24.string().max(128),
8124
+ cardId: z24.string().max(128),
8125
+ projectId: z24.string().max(128).optional(),
8126
+ orgId: z24.string().max(128).optional()
7991
8127
  })).query(async ({ input }) => {
7992
8128
  const board = await kanbanStore.get(input.boardId);
7993
- if (!board) throw new TRPCError19({ code: "NOT_FOUND", message: `Tableau ${input.boardId} introuvable.` });
8129
+ if (!board) throw new TRPCError20({ code: "NOT_FOUND", message: `Tableau ${input.boardId} introuvable.` });
7994
8130
  if (!board.columns.some((col) => col.cards.some((c) => c.id === input.cardId))) {
7995
- throw new TRPCError19({ code: "NOT_FOUND", message: `Carte ${input.cardId} introuvable sur le tableau ${input.boardId}.` });
8131
+ throw new TRPCError20({ code: "NOT_FOUND", message: `Carte ${input.cardId} introuvable sur le tableau ${input.boardId}.` });
7996
8132
  }
7997
8133
  const scope = {
7998
8134
  ...input.projectId ? { projectId: input.projectId } : {},
@@ -8009,16 +8145,16 @@ var kanbanRouter = router({
8009
8145
  * Un champ absent n'est pas touché ; `null` l'efface. La distinction compte —
8010
8146
  * changer un titre ne doit pas vider une couleur.
8011
8147
  */
8012
- updateCard: protectedProcedure2.input(z23.object({
8013
- boardId: z23.string().max(128),
8014
- cardId: z23.string().max(128),
8015
- title: z23.string().min(1).max(512).optional(),
8016
- content: z23.string().max(1e5).optional(),
8017
- priority: z23.number().int().min(1).max(10).nullable().optional(),
8018
- color: z23.string().max(32).nullable().optional(),
8019
- groups: z23.array(z23.string().min(1).max(60)).max(30).optional(),
8020
- deadline: z23.string().regex(/^\d{4}-\d{2}-\d{2}$/).nullable().optional(),
8021
- assignees: z23.array(z23.string().max(128)).max(50).optional()
8148
+ updateCard: protectedProcedure2.input(z24.object({
8149
+ boardId: z24.string().max(128),
8150
+ cardId: z24.string().max(128),
8151
+ title: z24.string().min(1).max(512).optional(),
8152
+ content: z24.string().max(1e5).optional(),
8153
+ priority: z24.number().int().min(1).max(10).nullable().optional(),
8154
+ color: z24.string().max(32).nullable().optional(),
8155
+ groups: z24.array(z24.string().min(1).max(60)).max(30).optional(),
8156
+ deadline: z24.string().regex(/^\d{4}-\d{2}-\d{2}$/).nullable().optional(),
8157
+ assignees: z24.array(z24.string().max(128)).max(50).optional()
8022
8158
  })).mutation(async ({ input }) => {
8023
8159
  const { boardId, cardId, content, ...rest } = input;
8024
8160
  const patch = { ...rest };
@@ -8029,10 +8165,10 @@ var kanbanRouter = router({
8029
8165
  return summarizeCard(card, boardId, "");
8030
8166
  }),
8031
8167
  /** Ranger une carte, ou la reprendre. */
8032
- setCardArchived: protectedProcedure2.input(z23.object({
8033
- boardId: z23.string().max(128),
8034
- cardId: z23.string().max(128),
8035
- archived: z23.boolean()
8168
+ setCardArchived: protectedProcedure2.input(z24.object({
8169
+ boardId: z24.string().max(128),
8170
+ cardId: z24.string().max(128),
8171
+ archived: z24.boolean()
8036
8172
  })).mutation(async ({ input }) => {
8037
8173
  const ok = await kanbanStore.setCardArchived(input.boardId, input.cardId, input.archived);
8038
8174
  if (!ok) throw new Error(`La carte ${input.cardId} n'a pas pu \xEAtre ${input.archived ? "archiv\xE9e" : "reprise"}.`);
@@ -8044,48 +8180,48 @@ var kanbanRouter = router({
8044
8180
  * Sans cette liste, assigner revient à deviner un identifiant — et l'agent
8045
8181
  * n'a aucun moyen de le trouver.
8046
8182
  */
8047
- listMembers: protectedProcedure2.input(z23.object({ organizationId: z23.string().max(128).optional() })).query(async ({ input }) => ({ members: await kanbanStore.members(input.organizationId) })),
8183
+ listMembers: protectedProcedure2.input(z24.object({ organizationId: z24.string().max(128).optional() })).query(async ({ input }) => ({ members: await kanbanStore.members(input.organizationId) })),
8048
8184
  /**
8049
8185
  * Fetch one card attachment from the cloud and drop it on this machine, so an
8050
8186
  * agent can open it with its own file tools. The bytes never go through the
8051
8187
  * prompt: the card context lists the attachments, this returns a path.
8052
8188
  */
8053
- downloadAttachment: protectedProcedure2.input(z23.object({
8054
- attachmentId: z23.string().max(128),
8189
+ downloadAttachment: protectedProcedure2.input(z24.object({
8190
+ attachmentId: z24.string().max(128),
8055
8191
  // La pièce jointe appartient à une organisation : la nommer dit sous quel
8056
8192
  // compte la demander.
8057
- orgId: z23.string().max(128).optional(),
8193
+ orgId: z24.string().max(128).optional(),
8058
8194
  // À défaut, le tableau d'où vient la carte suffit : il désigne un compte
8059
8195
  // comme le fait n'importe quel autre appel du kanban. Sans lui, la route
8060
8196
  // retombait sur le compte unique du poste et refusait de servir dès qu'il
8061
8197
  // y en avait plusieurs — alors que l'agent, qui n'a qu'un identifiant de
8062
8198
  // fichier, n'avait aucun moyen de nommer l'organisation.
8063
- boardId: z23.string().max(128).optional()
8199
+ boardId: z24.string().max(128).optional()
8064
8200
  })).mutation(async ({ input }) => {
8065
8201
  const id = input.attachmentId;
8066
8202
  if (!ATTACHMENT_ID_REGEX.test(id)) {
8067
- throw new TRPCError19({ code: "BAD_REQUEST", message: "Invalid attachment id" });
8203
+ throw new TRPCError20({ code: "BAD_REQUEST", message: "Invalid attachment id" });
8068
8204
  }
8069
8205
  const res = await cloudFetch2(`/api/kanban/file/${id}`, {
8070
8206
  timeoutMs: 12e4,
8071
8207
  accountId: await attachmentScope(input)
8072
8208
  });
8073
8209
  if (res.status === 404) {
8074
- throw new TRPCError19({ code: "NOT_FOUND", message: `Attachment ${id} not found` });
8210
+ throw new TRPCError20({ code: "NOT_FOUND", message: `Attachment ${id} not found` });
8075
8211
  }
8076
8212
  if (!res.ok) {
8077
- throw new TRPCError19({
8213
+ throw new TRPCError20({
8078
8214
  code: res.status === 403 ? "FORBIDDEN" : "INTERNAL_SERVER_ERROR",
8079
8215
  message: `Cloud refused the attachment (HTTP ${res.status})`
8080
8216
  });
8081
8217
  }
8082
8218
  const declared = Number(res.headers.get("content-length") ?? 0);
8083
8219
  if (declared > MAX_ATTACHMENT_BYTES) {
8084
- throw new TRPCError19({ code: "PAYLOAD_TOO_LARGE", message: "Attachment too large to download" });
8220
+ throw new TRPCError20({ code: "PAYLOAD_TOO_LARGE", message: "Attachment too large to download" });
8085
8221
  }
8086
8222
  const body = Buffer.from(await res.arrayBuffer());
8087
8223
  if (body.length > MAX_ATTACHMENT_BYTES) {
8088
- throw new TRPCError19({ code: "PAYLOAD_TOO_LARGE", message: "Attachment too large to download" });
8224
+ throw new TRPCError20({ code: "PAYLOAD_TOO_LARGE", message: "Attachment too large to download" });
8089
8225
  }
8090
8226
  const contentType = res.headers.get("content-type") ?? "application/octet-stream";
8091
8227
  const disposition = res.headers.get("content-disposition") ?? "";
@@ -8097,10 +8233,10 @@ var kanbanRouter = router({
8097
8233
  });
8098
8234
 
8099
8235
  // ../server/src/trpc/routers/knowledge.ts
8100
- import { z as z24 } from "zod";
8101
- import { TRPCError as TRPCError20 } from "@trpc/server";
8236
+ import { z as z25 } from "zod";
8237
+ import { TRPCError as TRPCError21 } from "@trpc/server";
8102
8238
  var protectedProcedure3 = protectedProcedure.use(({ ctx, next }) => {
8103
- if (ctx.callerType === "api") throw new TRPCError20({ code: "FORBIDDEN", message: "An API key cannot use the knowledge base." });
8239
+ if (ctx.callerType === "api") throw new TRPCError21({ code: "FORBIDDEN", message: "An API key cannot use the knowledge base." });
8104
8240
  return next();
8105
8241
  });
8106
8242
  var accountOfObject = /* @__PURE__ */ new Map();
@@ -8118,7 +8254,7 @@ async function orgScope(explicit) {
8118
8254
  const organizationId = await resolveOrganizationId(explicit);
8119
8255
  return { organizationId, accountId: await accountForOrgScope(organizationId) };
8120
8256
  } catch (err) {
8121
- if (err instanceof KanbanUnavailableError) throw new TRPCError20({ code: "PRECONDITION_FAILED", message: err.message });
8257
+ if (err instanceof KanbanUnavailableError) throw new TRPCError21({ code: "PRECONDITION_FAILED", message: err.message });
8122
8258
  throw err;
8123
8259
  }
8124
8260
  }
@@ -8134,7 +8270,7 @@ async function call(path, accountId, init = {}) {
8134
8270
  const res = await cloudFetch2(`/api/auth${path}`, { ...init, accountId });
8135
8271
  if (!res.ok) {
8136
8272
  const body = await res.json().catch(() => null);
8137
- throw new TRPCError20({
8273
+ throw new TRPCError21({
8138
8274
  code: STATUS[res.status] ?? "PRECONDITION_FAILED",
8139
8275
  message: body?.message ?? `Le cloud a r\xE9pondu HTTP ${res.status} sur ${path}.`
8140
8276
  });
@@ -8157,7 +8293,7 @@ async function accountOf(id, probe) {
8157
8293
  return res?.ok ? a.id : null;
8158
8294
  }));
8159
8295
  const owner = owners.find((o) => !!o);
8160
- if (!owner) throw new TRPCError20({ code: "NOT_FOUND", message: `Aucun compte li\xE9 \xE0 ce poste ne conna\xEEt ${id}.` });
8296
+ if (!owner) throw new TRPCError21({ code: "NOT_FOUND", message: `Aucun compte li\xE9 \xE0 ce poste ne conna\xEEt ${id}.` });
8161
8297
  rememberAccount(id, owner);
8162
8298
  return owner;
8163
8299
  }
@@ -8165,7 +8301,7 @@ var pageAccount = (pageId) => accountOf(pageId, (id) => `/knowledge/page?pageId=
8165
8301
  async function spaceAccount(spaceId) {
8166
8302
  const { accountId } = await knownAccount(spaceId);
8167
8303
  if (accountId) return accountId;
8168
- throw new TRPCError20({ code: "BAD_REQUEST", message: `Espace ${spaceId} inconnu de ce poste : appelez knowledge_list_spaces avec son organizationId d'abord.` });
8304
+ throw new TRPCError21({ code: "BAD_REQUEST", message: `Espace ${spaceId} inconnu de ce poste : appelez knowledge_list_spaces avec son organizationId d'abord.` });
8169
8305
  }
8170
8306
  function remember(ids, accountId) {
8171
8307
  for (const id of ids) rememberAccount(id, accountId);
@@ -8175,13 +8311,13 @@ var qs = (params) => new URLSearchParams(Object.entries(params).flatMap(([k, v])
8175
8311
  return [[k, Array.isArray(v) ? v.join(",") : String(v)]];
8176
8312
  })).toString();
8177
8313
  var knowledgeRouter = router({
8178
- listSpaces: protectedProcedure3.input(z24.object({ organizationId: z24.string().max(128).optional() })).query(async ({ input }) => {
8314
+ listSpaces: protectedProcedure3.input(z25.object({ organizationId: z25.string().max(128).optional() })).query(async ({ input }) => {
8179
8315
  const { organizationId, accountId } = await orgScope(input.organizationId);
8180
8316
  const res = await call(`/knowledge/space/list?${qs({ organizationId })}`, accountId);
8181
8317
  remember(res.spaces.map((s) => s.id), accountId);
8182
8318
  return { organizationId, cloud: await cloudOf(accountId), ...res };
8183
8319
  }),
8184
- search: protectedProcedure3.input(KnowledgeSearchInputSchema.extend({ organizationId: z24.string().max(128).optional() })).query(async ({ input }) => {
8320
+ search: protectedProcedure3.input(KnowledgeSearchInputSchema.extend({ organizationId: z25.string().max(128).optional() })).query(async ({ input }) => {
8185
8321
  const { organizationId, accountId } = await orgScope(input.organizationId);
8186
8322
  const res = await call(`/knowledge/search?${qs({
8187
8323
  organizationId,
@@ -8198,36 +8334,36 @@ var knowledgeRouter = router({
8198
8334
  remember(res.hits.map((h) => h.id), accountId);
8199
8335
  return { organizationId, cloud: await cloudOf(accountId), ...res };
8200
8336
  }),
8201
- listThemes: protectedProcedure3.input(z24.object({ organizationId: z24.string().max(128).optional(), spaceId: KnowledgeIdSchema.optional() })).query(async ({ input }) => {
8337
+ listThemes: protectedProcedure3.input(z25.object({ organizationId: z25.string().max(128).optional(), spaceId: KnowledgeIdSchema.optional() })).query(async ({ input }) => {
8202
8338
  const { organizationId, accountId } = await orgScope(input.organizationId);
8203
8339
  const res = await call(`/knowledge/themes?${qs({ organizationId, spaceId: input.spaceId })}`, accountId);
8204
8340
  remember(res.themes.map((t) => t.id), accountId);
8205
8341
  return res;
8206
8342
  }),
8207
- getPage: protectedProcedure3.input(z24.object({ pageId: KnowledgeIdSchema })).query(async ({ input }) => call(`/knowledge/page?${qs({ pageId: input.pageId })}`, await pageAccount(input.pageId))),
8208
- getNeighbors: protectedProcedure3.input(z24.object({
8343
+ getPage: protectedProcedure3.input(z25.object({ pageId: KnowledgeIdSchema })).query(async ({ input }) => call(`/knowledge/page?${qs({ pageId: input.pageId })}`, await pageAccount(input.pageId))),
8344
+ getNeighbors: protectedProcedure3.input(z25.object({
8209
8345
  pageId: KnowledgeIdSchema,
8210
- depth: z24.number().int().min(1).max(KNOWLEDGE_LIMITS.neighborsDepth).optional(),
8211
- kinds: z24.array(KnowledgeEdgeKindSchema).optional(),
8212
- includeObsolete: z24.boolean().optional()
8346
+ depth: z25.number().int().min(1).max(KNOWLEDGE_LIMITS.neighborsDepth).optional(),
8347
+ kinds: z25.array(KnowledgeEdgeKindSchema).optional(),
8348
+ includeObsolete: z25.boolean().optional()
8213
8349
  })).query(async ({ input }) => {
8214
8350
  const accountId = await pageAccount(input.pageId);
8215
8351
  const res = await call(`/knowledge/page/neighbors?${qs(input)}`, accountId);
8216
8352
  remember(res.nodes.map((n) => n.id), accountId);
8217
8353
  return res;
8218
8354
  }),
8219
- getRelated: protectedProcedure3.input(z24.object({
8220
- pageIds: z24.array(KnowledgeIdSchema).min(1).max(10),
8221
- limit: z24.number().int().min(1).max(KNOWLEDGE_LIMITS.relatedPages).optional(),
8222
- includeObsolete: z24.boolean().optional()
8355
+ getRelated: protectedProcedure3.input(z25.object({
8356
+ pageIds: z25.array(KnowledgeIdSchema).min(1).max(10),
8357
+ limit: z25.number().int().min(1).max(KNOWLEDGE_LIMITS.relatedPages).optional(),
8358
+ includeObsolete: z25.boolean().optional()
8223
8359
  })).query(async ({ input }) => {
8224
8360
  const accountId = await pageAccount(input.pageIds[0]);
8225
8361
  const res = await call(`/knowledge/related?${qs(input)}`, accountId);
8226
8362
  remember(res.pages.map((p) => p.id), accountId);
8227
8363
  return res;
8228
8364
  }),
8229
- getHistory: protectedProcedure3.input(z24.object({ pageId: KnowledgeIdSchema })).query(async ({ input }) => call(`/knowledge/page/history?${qs(input)}`, await pageAccount(input.pageId))),
8230
- getVersion: protectedProcedure3.input(z24.object({ pageId: KnowledgeIdSchema, at: z24.iso.datetime(), compare: z24.boolean().optional() })).query(async ({ input }) => call(`/knowledge/page/version?${qs(input)}`, await pageAccount(input.pageId))),
8365
+ getHistory: protectedProcedure3.input(z25.object({ pageId: KnowledgeIdSchema })).query(async ({ input }) => call(`/knowledge/page/history?${qs(input)}`, await pageAccount(input.pageId))),
8366
+ getVersion: protectedProcedure3.input(z25.object({ pageId: KnowledgeIdSchema, at: z25.iso.datetime(), compare: z25.boolean().optional() })).query(async ({ input }) => call(`/knowledge/page/version?${qs(input)}`, await pageAccount(input.pageId))),
8231
8367
  createPage: protectedProcedure3.input(KnowledgeCreatePageInputSchema).mutation(async ({ input }) => {
8232
8368
  const accountId = await spaceAccount(input.spaceId);
8233
8369
  const res = await call("/knowledge/page/create", accountId, { method: "POST", body: input });
@@ -8242,21 +8378,21 @@ var knowledgeRouter = router({
8242
8378
  });
8243
8379
 
8244
8380
  // ../server/src/trpc/routers/terminal.ts
8245
- import { z as z25 } from "zod";
8246
- import { TRPCError as TRPCError21 } from "@trpc/server";
8381
+ import { z as z26 } from "zod";
8382
+ import { TRPCError as TRPCError22 } from "@trpc/server";
8247
8383
  var terminalRouter = router({
8248
8384
  /** Create a PTY shell session on the target agent */
8249
- create: protectedProcedure.input(z25.object({
8250
- agentId: z25.string().max(128),
8251
- cwd: z25.string().max(512).optional(),
8385
+ create: protectedProcedure.input(z26.object({
8386
+ agentId: z26.string().max(128),
8387
+ cwd: z26.string().max(512).optional(),
8252
8388
  /** Anchors the terminal when no explicit cwd is given. */
8253
- serviceId: z25.string().max(128).optional(),
8254
- projectId: z25.string().max(128).optional(),
8389
+ serviceId: z26.string().max(128).optional(),
8390
+ projectId: z26.string().max(128).optional(),
8255
8391
  /** L'organisation du projet : un id seul peut en nommer un par organisation. */
8256
- orgId: z25.string().max(128).nullable().optional(),
8257
- cols: z25.number().int().min(1).max(512).optional(),
8258
- rows: z25.number().int().min(1).max(256).optional(),
8259
- title: z25.string().max(128).optional()
8392
+ orgId: z26.string().max(128).nullable().optional(),
8393
+ cols: z26.number().int().min(1).max(512).optional(),
8394
+ rows: z26.number().int().min(1).max(256).optional(),
8395
+ title: z26.string().max(128).optional()
8260
8396
  })).mutation(async ({ input }) => {
8261
8397
  const result = await agentManager.agentMutation(
8262
8398
  input.agentId,
@@ -8277,17 +8413,17 @@ var terminalRouter = router({
8277
8413
  return result;
8278
8414
  }),
8279
8415
  /** Les sessions PTY encore vivantes sur l'agent (onglets à retrouver) */
8280
- list: protectedProcedure.input(z25.object({ agentId: z25.string().max(128) })).query(async ({ input }) => {
8416
+ list: protectedProcedure.input(z26.object({ agentId: z26.string().max(128) })).query(async ({ input }) => {
8281
8417
  return agentManager.agentQuery(
8282
8418
  input.agentId,
8283
8419
  "terminal.list"
8284
8420
  );
8285
8421
  }),
8286
8422
  /** Renommer un onglet */
8287
- rename: protectedProcedure.input(z25.object({
8288
- agentId: z25.string().max(128),
8289
- sessionId: z25.string().max(128),
8290
- title: z25.string().max(128)
8423
+ rename: protectedProcedure.input(z26.object({
8424
+ agentId: z26.string().max(128),
8425
+ sessionId: z26.string().max(128),
8426
+ title: z26.string().max(128)
8291
8427
  })).mutation(async ({ input }) => {
8292
8428
  await agentManager.agentMutation(
8293
8429
  input.agentId,
@@ -8297,10 +8433,10 @@ var terminalRouter = router({
8297
8433
  return { ok: true };
8298
8434
  }),
8299
8435
  /** Send keystrokes / data to a PTY session */
8300
- write: protectedProcedure.input(z25.object({
8301
- agentId: z25.string().max(128),
8302
- sessionId: z25.string().max(128),
8303
- data: z25.string().max(65536)
8436
+ write: protectedProcedure.input(z26.object({
8437
+ agentId: z26.string().max(128),
8438
+ sessionId: z26.string().max(128),
8439
+ data: z26.string().max(65536)
8304
8440
  })).mutation(async ({ input }) => {
8305
8441
  await agentManager.agentMutation(
8306
8442
  input.agentId,
@@ -8310,11 +8446,11 @@ var terminalRouter = router({
8310
8446
  return { ok: true };
8311
8447
  }),
8312
8448
  /** Resize the PTY */
8313
- resize: protectedProcedure.input(z25.object({
8314
- agentId: z25.string().max(128),
8315
- sessionId: z25.string().max(128),
8316
- cols: z25.number().int().min(1).max(512),
8317
- rows: z25.number().int().min(1).max(256)
8449
+ resize: protectedProcedure.input(z26.object({
8450
+ agentId: z26.string().max(128),
8451
+ sessionId: z26.string().max(128),
8452
+ cols: z26.number().int().min(1).max(512),
8453
+ rows: z26.number().int().min(1).max(256)
8318
8454
  })).mutation(async ({ input }) => {
8319
8455
  await agentManager.agentMutation(
8320
8456
  input.agentId,
@@ -8324,9 +8460,9 @@ var terminalRouter = router({
8324
8460
  return { ok: true };
8325
8461
  }),
8326
8462
  /** Destroy a PTY session */
8327
- destroy: protectedProcedure.input(z25.object({
8328
- agentId: z25.string().max(128),
8329
- sessionId: z25.string().max(128)
8463
+ destroy: protectedProcedure.input(z26.object({
8464
+ agentId: z26.string().max(128),
8465
+ sessionId: z26.string().max(128)
8330
8466
  })).mutation(async ({ input }) => {
8331
8467
  await agentManager.agentMutation(
8332
8468
  input.agentId,
@@ -8336,11 +8472,11 @@ var terminalRouter = router({
8336
8472
  return { ok: true };
8337
8473
  }),
8338
8474
  /** Stream PTY output — proxied via AgentWSBridge dynamic subscription */
8339
- onData: protectedProcedure.input(z25.object({
8340
- agentId: z25.string().max(128),
8341
- sessionId: z25.string().max(128),
8475
+ onData: protectedProcedure.input(z26.object({
8476
+ agentId: z26.string().max(128),
8477
+ sessionId: z26.string().max(128),
8342
8478
  /** Rejouer l'historique de la session avant le flux temps réel. */
8343
- replay: z25.boolean().optional()
8479
+ replay: z26.boolean().optional()
8344
8480
  })).subscription(async function* ({ input }) {
8345
8481
  const queue = [];
8346
8482
  let resolve5 = null;
@@ -8367,7 +8503,7 @@ var terminalRouter = router({
8367
8503
  }
8368
8504
  );
8369
8505
  } catch (err) {
8370
- throw new TRPCError21({
8506
+ throw new TRPCError22({
8371
8507
  code: "BAD_REQUEST",
8372
8508
  message: `Cannot subscribe to terminal: ${err.message}`
8373
8509
  });
@@ -8389,11 +8525,11 @@ var terminalRouter = router({
8389
8525
  });
8390
8526
 
8391
8527
  // ../server/src/trpc/routers/utility.ts
8392
- import { z as z26 } from "zod";
8528
+ import { z as z27 } from "zod";
8393
8529
  var MAX_WAIT_MS = 5 * 60 * 1e3;
8394
8530
  var utilityRouter = router({
8395
- wait: protectedProcedure.input(z26.object({
8396
- ms: z26.number().int().min(0).max(MAX_WAIT_MS)
8531
+ wait: protectedProcedure.input(z27.object({
8532
+ ms: z27.number().int().min(0).max(MAX_WAIT_MS)
8397
8533
  })).mutation(async ({ input }) => {
8398
8534
  await new Promise((resolve5) => setTimeout(resolve5, input.ms));
8399
8535
  return { waited: input.ms };
@@ -8401,15 +8537,15 @@ var utilityRouter = router({
8401
8537
  });
8402
8538
 
8403
8539
  // ../server/src/trpc/routers/wiki.ts
8404
- import { z as z27 } from "zod";
8405
- import { TRPCError as TRPCError22 } from "@trpc/server";
8540
+ import { z as z28 } from "zod";
8541
+ import { TRPCError as TRPCError23 } from "@trpc/server";
8406
8542
  import { readFile as readFile5, readdir as readdir2, stat as stat4, realpath as realpath2, writeFile as writeFile5, mkdir as mkdir7, rename, rm as rm2 } from "fs/promises";
8407
- import { resolve as resolvePath, join as join9, relative as relative2, sep, dirname as dirname5 } from "path";
8408
- var SCOPE_SCHEMA = z27.union([
8409
- z27.literal("global"),
8410
- z27.string().regex(/^service:[A-Za-z0-9_-]{1,128}$/, "Invalid service scope")
8543
+ import { resolve as resolvePath, join as join10, relative as relative2, sep, dirname as dirname5 } from "path";
8544
+ var SCOPE_SCHEMA = z28.union([
8545
+ z28.literal("global"),
8546
+ z28.string().regex(/^service:[A-Za-z0-9_-]{1,128}$/, "Invalid service scope")
8411
8547
  ]);
8412
- var REL_PATH_SCHEMA = z27.string().min(1).max(512).regex(/^[A-Za-z0-9_./-]+$/).refine((p) => !p.includes("..") && !p.startsWith("/"), {
8548
+ var REL_PATH_SCHEMA = z28.string().min(1).max(512).regex(/^[A-Za-z0-9_./-]+$/).refine((p) => !p.includes("..") && !p.startsWith("/"), {
8413
8549
  message: "Path must be a relative path without traversal"
8414
8550
  });
8415
8551
  var MAX_FILES = 500;
@@ -8429,36 +8565,36 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
8429
8565
  "target",
8430
8566
  "out"
8431
8567
  ]);
8432
- var DocsEntrySchema = z27.lazy(() => z27.union([
8433
- z27.object({ type: z27.literal("file"), name: z27.string(), path: z27.string() }),
8434
- z27.object({ type: z27.literal("dir"), name: z27.string(), path: z27.string(), children: z27.array(DocsEntrySchema) })
8568
+ var DocsEntrySchema = z28.lazy(() => z28.union([
8569
+ z28.object({ type: z28.literal("file"), name: z28.string(), path: z28.string() }),
8570
+ z28.object({ type: z28.literal("dir"), name: z28.string(), path: z28.string(), children: z28.array(DocsEntrySchema) })
8435
8571
  ]));
8436
8572
  async function resolveScope(scope) {
8437
8573
  if (scope === "global") {
8438
8574
  const settings = await settingsManager.getSettings();
8439
8575
  const sub = (settings.globalDocsPath?.trim() || "wiki").replace(/^[\\/]+|[\\/]+$/g, "");
8440
8576
  if (sub.includes("..") || sub.includes("\0")) {
8441
- throw new TRPCError22({ code: "BAD_REQUEST", message: "Sous-chemin invalide" });
8577
+ throw new TRPCError23({ code: "BAD_REQUEST", message: "Sous-chemin invalide" });
8442
8578
  }
8443
8579
  const dataDirAbs = resolvePath(env.DATA_DIR);
8444
8580
  await mkdir7(dataDirAbs, { recursive: true });
8445
8581
  const base = dirname5(await realpath2(dataDirAbs));
8446
8582
  const target = resolvePath(base, sub);
8447
8583
  if (target !== base && !(target + sep).startsWith(base + sep)) {
8448
- throw new TRPCError22({ code: "FORBIDDEN", message: "Hors du dossier de donn\xE9es du serveur" });
8584
+ throw new TRPCError23({ code: "FORBIDDEN", message: "Hors du dossier de donn\xE9es du serveur" });
8449
8585
  }
8450
8586
  await mkdir7(target, { recursive: true });
8451
8587
  const root = await realpath2(target);
8452
8588
  if (root !== base && !(root + sep).startsWith(base + sep)) {
8453
- throw new TRPCError22({ code: "FORBIDDEN", message: "Le dossier wiki r\xE9sout hors du dossier de donn\xE9es" });
8589
+ throw new TRPCError23({ code: "FORBIDDEN", message: "Le dossier wiki r\xE9sout hors du dossier de donn\xE9es" });
8454
8590
  }
8455
8591
  return { mode: "local", root };
8456
8592
  }
8457
8593
  const serviceId = scope.slice("service:".length);
8458
8594
  const service2 = await serviceStore.get(serviceId);
8459
- if (!service2) throw new TRPCError22({ code: "NOT_FOUND", message: "Service introuvable" });
8595
+ if (!service2) throw new TRPCError23({ code: "NOT_FOUND", message: "Service introuvable" });
8460
8596
  const agentId = await resolveEffectiveAgentId(service2);
8461
- if (!agentId) throw new TRPCError22({ code: "BAD_REQUEST", message: "Aucun agent configur\xE9 pour ce service" });
8597
+ if (!agentId) throw new TRPCError23({ code: "BAD_REQUEST", message: "Aucun agent configur\xE9 pour ce service" });
8462
8598
  const cwd = await resolveWorkspaceCwd({ serviceId, override: service2.docsPath?.trim() || void 0 });
8463
8599
  return { mode: "agent", agentId, cwd };
8464
8600
  }
@@ -8474,7 +8610,7 @@ async function walkLocal(root, dir, depth, counter) {
8474
8610
  for (const e of entries2) {
8475
8611
  if (counter.n >= MAX_FILES) break;
8476
8612
  if (e.name.startsWith(".") && e.name !== ".") continue;
8477
- const abs = join9(dir, e.name);
8613
+ const abs = join10(dir, e.name);
8478
8614
  const rel = relative2(root, abs).split(sep).join("/");
8479
8615
  if (e.isDirectory()) {
8480
8616
  if (IGNORED_DIRS.has(e.name)) continue;
@@ -8493,7 +8629,7 @@ async function walkLocal(root, dir, depth, counter) {
8493
8629
  }
8494
8630
  async function resolveSafeLocal(root, relPath, requireExist) {
8495
8631
  if (relPath.includes("..") || relPath.startsWith("/")) {
8496
- throw new TRPCError22({ code: "BAD_REQUEST", message: "Chemin invalide" });
8632
+ throw new TRPCError23({ code: "BAD_REQUEST", message: "Chemin invalide" });
8497
8633
  }
8498
8634
  const target = resolvePath(root, relPath);
8499
8635
  if (requireExist) {
@@ -8501,10 +8637,10 @@ async function resolveSafeLocal(root, relPath, requireExist) {
8501
8637
  try {
8502
8638
  real = await realpath2(target);
8503
8639
  } catch {
8504
- throw new TRPCError22({ code: "NOT_FOUND", message: "Chemin introuvable" });
8640
+ throw new TRPCError23({ code: "NOT_FOUND", message: "Chemin introuvable" });
8505
8641
  }
8506
8642
  if (real !== root && !(real + sep).startsWith(root + sep)) {
8507
- throw new TRPCError22({ code: "FORBIDDEN", message: "Hors du dossier autoris\xE9" });
8643
+ throw new TRPCError23({ code: "FORBIDDEN", message: "Hors du dossier autoris\xE9" });
8508
8644
  }
8509
8645
  return real;
8510
8646
  }
@@ -8516,12 +8652,12 @@ async function resolveSafeLocal(root, relPath, requireExist) {
8516
8652
  realParent = parent;
8517
8653
  }
8518
8654
  if (realParent !== root && !(realParent + sep).startsWith(root + sep)) {
8519
- throw new TRPCError22({ code: "FORBIDDEN", message: "Hors du dossier autoris\xE9" });
8655
+ throw new TRPCError23({ code: "FORBIDDEN", message: "Hors du dossier autoris\xE9" });
8520
8656
  }
8521
8657
  return resolvePath(realParent, target.slice(parent.length).replace(/^[\\/]+/, ""));
8522
8658
  }
8523
8659
  var wikiRouter = router({
8524
- list: protectedProcedure.input(z27.object({ scope: SCOPE_SCHEMA })).output(z27.object({ root: z27.string(), entries: z27.array(DocsEntrySchema), truncated: z27.boolean() })).query(async ({ input }) => {
8660
+ list: protectedProcedure.input(z28.object({ scope: SCOPE_SCHEMA })).output(z28.object({ root: z28.string(), entries: z28.array(DocsEntrySchema), truncated: z28.boolean() })).query(async ({ input }) => {
8525
8661
  const target = await resolveScope(input.scope);
8526
8662
  if (target.mode === "agent") {
8527
8663
  return agentManager.agentQuery(target.agentId, "wiki.listRepoMarkdown", { cwd: target.cwd });
@@ -8530,9 +8666,9 @@ var wikiRouter = router({
8530
8666
  const entries2 = await walkLocal(target.root, target.root, 0, counter);
8531
8667
  return { root: target.root, entries: entries2, truncated: counter.n >= MAX_FILES };
8532
8668
  }),
8533
- read: protectedProcedure.input(z27.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA })).output(z27.object({ path: z27.string(), content: z27.string() })).query(async ({ input }) => {
8669
+ read: protectedProcedure.input(z28.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA })).output(z28.object({ path: z28.string(), content: z28.string() })).query(async ({ input }) => {
8534
8670
  if (!/\.(md|markdown)$/i.test(input.path)) {
8535
- throw new TRPCError22({ code: "BAD_REQUEST", message: "Seuls les .md/.markdown sont autoris\xE9s" });
8671
+ throw new TRPCError23({ code: "BAD_REQUEST", message: "Seuls les .md/.markdown sont autoris\xE9s" });
8536
8672
  }
8537
8673
  const target = await resolveScope(input.scope);
8538
8674
  if (target.mode === "agent") {
@@ -8540,14 +8676,14 @@ var wikiRouter = router({
8540
8676
  }
8541
8677
  const file = await resolveSafeLocal(target.root, input.path, true);
8542
8678
  const s = await stat4(file);
8543
- if (!s.isFile()) throw new TRPCError22({ code: "BAD_REQUEST", message: "Pas un fichier" });
8544
- if (s.size > MAX_FILE_BYTES) throw new TRPCError22({ code: "PAYLOAD_TOO_LARGE", message: "Fichier trop volumineux" });
8679
+ if (!s.isFile()) throw new TRPCError23({ code: "BAD_REQUEST", message: "Pas un fichier" });
8680
+ if (s.size > MAX_FILE_BYTES) throw new TRPCError23({ code: "PAYLOAD_TOO_LARGE", message: "Fichier trop volumineux" });
8545
8681
  const content = await readFile5(file, "utf-8");
8546
8682
  return { path: input.path, content };
8547
8683
  }),
8548
- write: protectedProcedure.input(z27.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA, content: z27.string().max(5e6) })).mutation(async ({ input }) => {
8684
+ write: protectedProcedure.input(z28.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA, content: z28.string().max(5e6) })).mutation(async ({ input }) => {
8549
8685
  if (!/\.(md|markdown)$/i.test(input.path)) {
8550
- throw new TRPCError22({ code: "BAD_REQUEST", message: "Seuls les .md/.markdown sont autoris\xE9s" });
8686
+ throw new TRPCError23({ code: "BAD_REQUEST", message: "Seuls les .md/.markdown sont autoris\xE9s" });
8551
8687
  }
8552
8688
  const target = await resolveScope(input.scope);
8553
8689
  if (target.mode === "agent") {
@@ -8558,9 +8694,9 @@ var wikiRouter = router({
8558
8694
  await writeFile5(file, input.content, "utf-8");
8559
8695
  return { path: input.path, ok: true };
8560
8696
  }),
8561
- createFile: protectedProcedure.input(z27.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA })).mutation(async ({ input }) => {
8697
+ createFile: protectedProcedure.input(z28.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA })).mutation(async ({ input }) => {
8562
8698
  if (!/\.(md|markdown)$/i.test(input.path)) {
8563
- throw new TRPCError22({ code: "BAD_REQUEST", message: "Seuls les .md/.markdown sont autoris\xE9s" });
8699
+ throw new TRPCError23({ code: "BAD_REQUEST", message: "Seuls les .md/.markdown sont autoris\xE9s" });
8564
8700
  }
8565
8701
  const target = await resolveScope(input.scope);
8566
8702
  if (target.mode === "agent") {
@@ -8569,15 +8705,15 @@ var wikiRouter = router({
8569
8705
  const file = await resolveSafeLocal(target.root, input.path, false);
8570
8706
  try {
8571
8707
  await stat4(file);
8572
- throw new TRPCError22({ code: "CONFLICT", message: "Fichier d\xE9j\xE0 existant" });
8708
+ throw new TRPCError23({ code: "CONFLICT", message: "Fichier d\xE9j\xE0 existant" });
8573
8709
  } catch (err) {
8574
- if (err instanceof TRPCError22) throw err;
8710
+ if (err instanceof TRPCError23) throw err;
8575
8711
  }
8576
8712
  await mkdir7(dirname5(file), { recursive: true });
8577
8713
  await writeFile5(file, "", "utf-8");
8578
8714
  return { path: input.path, ok: true };
8579
8715
  }),
8580
- createDir: protectedProcedure.input(z27.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA })).mutation(async ({ input }) => {
8716
+ createDir: protectedProcedure.input(z28.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA })).mutation(async ({ input }) => {
8581
8717
  const target = await resolveScope(input.scope);
8582
8718
  if (target.mode === "agent") {
8583
8719
  return agentManager.agentMutation(target.agentId, "wiki.createDir", { cwd: target.cwd, path: input.path });
@@ -8586,7 +8722,7 @@ var wikiRouter = router({
8586
8722
  await mkdir7(dir, { recursive: true });
8587
8723
  return { path: input.path, ok: true };
8588
8724
  }),
8589
- rename: protectedProcedure.input(z27.object({ scope: SCOPE_SCHEMA, fromPath: REL_PATH_SCHEMA, toPath: REL_PATH_SCHEMA })).mutation(async ({ input }) => {
8725
+ rename: protectedProcedure.input(z28.object({ scope: SCOPE_SCHEMA, fromPath: REL_PATH_SCHEMA, toPath: REL_PATH_SCHEMA })).mutation(async ({ input }) => {
8590
8726
  const target = await resolveScope(input.scope);
8591
8727
  if (target.mode === "agent") {
8592
8728
  return agentManager.agentMutation(target.agentId, "wiki.renamePath", { cwd: target.cwd, fromPath: input.fromPath, toPath: input.toPath });
@@ -8595,34 +8731,34 @@ var wikiRouter = router({
8595
8731
  const to = await resolveSafeLocal(target.root, input.toPath, false);
8596
8732
  try {
8597
8733
  await stat4(to);
8598
- throw new TRPCError22({ code: "CONFLICT", message: "La cible existe d\xE9j\xE0" });
8734
+ throw new TRPCError23({ code: "CONFLICT", message: "La cible existe d\xE9j\xE0" });
8599
8735
  } catch (err) {
8600
- if (err instanceof TRPCError22) throw err;
8736
+ if (err instanceof TRPCError23) throw err;
8601
8737
  }
8602
8738
  await mkdir7(dirname5(to), { recursive: true });
8603
8739
  await rename(from, to);
8604
8740
  return { fromPath: input.fromPath, toPath: input.toPath, ok: true };
8605
8741
  }),
8606
- ensureRoot: protectedProcedure.input(z27.object({ scope: SCOPE_SCHEMA })).mutation(async ({ input }) => {
8742
+ ensureRoot: protectedProcedure.input(z28.object({ scope: SCOPE_SCHEMA })).mutation(async ({ input }) => {
8607
8743
  if (input.scope === "global") {
8608
8744
  await resolveScope("global");
8609
8745
  return { ok: true };
8610
8746
  }
8611
8747
  const serviceId = input.scope.slice("service:".length);
8612
8748
  const service2 = await serviceStore.get(serviceId);
8613
- if (!service2) throw new TRPCError22({ code: "NOT_FOUND", message: "Service introuvable" });
8749
+ if (!service2) throw new TRPCError23({ code: "NOT_FOUND", message: "Service introuvable" });
8614
8750
  const agentId = await resolveEffectiveAgentId(service2);
8615
- if (!agentId) throw new TRPCError22({ code: "BAD_REQUEST", message: "Aucun agent configur\xE9" });
8751
+ if (!agentId) throw new TRPCError23({ code: "BAD_REQUEST", message: "Aucun agent configur\xE9" });
8616
8752
  const cwd = await resolveWorkspaceCwd({ serviceId, override: service2.docsPath?.trim() || void 0 });
8617
8753
  return agentManager.agentMutation(agentId, "wiki.ensureRoot", { cwd });
8618
8754
  }),
8619
- delete: protectedProcedure.input(z27.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA })).mutation(async ({ input }) => {
8755
+ delete: protectedProcedure.input(z28.object({ scope: SCOPE_SCHEMA, path: REL_PATH_SCHEMA })).mutation(async ({ input }) => {
8620
8756
  const target = await resolveScope(input.scope);
8621
8757
  if (target.mode === "agent") {
8622
8758
  return agentManager.agentMutation(target.agentId, "wiki.deletePath", { cwd: target.cwd, path: input.path });
8623
8759
  }
8624
8760
  const fp = await resolveSafeLocal(target.root, input.path, true);
8625
- if (fp === target.root) throw new TRPCError22({ code: "FORBIDDEN", message: "Impossible de supprimer la racine" });
8761
+ if (fp === target.root) throw new TRPCError23({ code: "FORBIDDEN", message: "Impossible de supprimer la racine" });
8626
8762
  await rm2(fp, { recursive: true, force: true });
8627
8763
  return { path: input.path, ok: true };
8628
8764
  })
@@ -8644,14 +8780,14 @@ var configRouter = router({
8644
8780
  });
8645
8781
 
8646
8782
  // ../server/src/trpc/routers/cloud-sync.ts
8647
- import { z as z28 } from "zod";
8648
- import { TRPCError as TRPCError23 } from "@trpc/server";
8783
+ import { z as z29 } from "zod";
8784
+ import { TRPCError as TRPCError24 } from "@trpc/server";
8649
8785
 
8650
8786
  // ../server/src/services/org-sync-scope.ts
8651
8787
  import { access } from "fs/promises";
8652
- import { join as join10 } from "path";
8788
+ import { join as join11 } from "path";
8653
8789
  async function isMaterialized(root) {
8654
- return access(join10(root, "project.json")).then(() => true, () => false);
8790
+ return access(join11(root, "project.json")).then(() => true, () => false);
8655
8791
  }
8656
8792
  async function orgsToSync() {
8657
8793
  const [stamps, stampedAccounts, accounts] = await Promise.all([
@@ -8733,12 +8869,12 @@ import * as Y2 from "yjs";
8733
8869
  // ../server/src/services/sync-doc-cache.ts
8734
8870
  import { readFileSync as readFileSync2, renameSync, rmSync, writeFileSync, mkdirSync } from "fs";
8735
8871
  import { readFile as readFile6 } from "fs/promises";
8736
- import { dirname as dirname6, join as join11 } from "path";
8872
+ import { dirname as dirname6, join as join12 } from "path";
8737
8873
  import { randomUUID as randomUUID7 } from "crypto";
8738
8874
  import * as Y from "yjs";
8739
8875
  var FILE2 = "sync-doc.bin";
8740
8876
  function cachePath(orgId) {
8741
- return join11(orgVaultRoot(orgId), FILE2);
8877
+ return join12(orgVaultRoot(orgId), FILE2);
8742
8878
  }
8743
8879
  async function readSyncDoc(orgId) {
8744
8880
  try {
@@ -9750,7 +9886,7 @@ var cloudSyncBridge = new CloudSyncBridge();
9750
9886
 
9751
9887
  // ../server/src/services/key-adoption.ts
9752
9888
  import { readdir as readdir3, readFile as readFile7, writeFile as writeFile6, mkdir as mkdir9, copyFile, rename as rename2, stat as stat5 } from "fs/promises";
9753
- import { dirname as dirname7, join as join12 } from "path";
9889
+ import { dirname as dirname7, join as join13 } from "path";
9754
9890
  import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes3 } from "crypto";
9755
9891
  var ALGORITHM = "aes-256-gcm";
9756
9892
  function isAgentTriplet(value) {
@@ -9817,7 +9953,7 @@ async function jsonNamesIn(dir) {
9817
9953
  async function jsonFilesIn(root) {
9818
9954
  const names = await jsonNamesIn(root);
9819
9955
  for (const sub of ENCRYPTED_SUBDIRS) {
9820
- names.push(...(await jsonNamesIn(join12(root, sub))).map((n) => join12(sub, n)));
9956
+ names.push(...(await jsonNamesIn(join13(root, sub))).map((n) => join13(sub, n)));
9821
9957
  }
9822
9958
  return names;
9823
9959
  }
@@ -9855,7 +9991,7 @@ async function adoptOrgKey(orgId, newKey, masterPassword, now) {
9855
9991
  const touchedRoots = /* @__PURE__ */ new Set();
9856
9992
  for (const vaultRoot of await rootsOfOrg(orgId)) {
9857
9993
  for (const name of await jsonFilesIn(vaultRoot)) {
9858
- const path = join12(vaultRoot, name);
9994
+ const path = join13(vaultRoot, name);
9859
9995
  let parsed;
9860
9996
  try {
9861
9997
  parsed = JSON.parse(await readFile7(path, "utf-8"));
@@ -9872,15 +10008,15 @@ async function adoptOrgKey(orgId, newKey, masterPassword, now) {
9872
10008
  const stamp = now.toISOString().replace(/[:.]/g, "-").substring(0, 19);
9873
10009
  const backups = [];
9874
10010
  for (const vaultRoot of touchedRoots) {
9875
- const backupDir = join12(vaultRoot, `backup-key-${stamp}`);
10011
+ const backupDir = join13(vaultRoot, `backup-key-${stamp}`);
9876
10012
  await mkdir9(backupDir, { recursive: true });
9877
10013
  for (const name of await jsonFilesIn(vaultRoot)) {
9878
- await mkdir9(dirname7(join12(backupDir, name)), { recursive: true });
9879
- await copyFile(join12(vaultRoot, name), join12(backupDir, name));
10014
+ await mkdir9(dirname7(join13(backupDir, name)), { recursive: true });
10015
+ await copyFile(join13(vaultRoot, name), join13(backupDir, name));
9880
10016
  }
9881
10017
  for (const name of [".encryption.key.enc", ".runeya-verify"]) {
9882
- if (await exists(join12(vaultRoot, name))) {
9883
- await copyFile(join12(vaultRoot, name), join12(backupDir, name));
10018
+ if (await exists(join13(vaultRoot, name))) {
10019
+ await copyFile(join13(vaultRoot, name), join13(backupDir, name));
9884
10020
  }
9885
10021
  }
9886
10022
  backups.push(backupDir);
@@ -9935,7 +10071,7 @@ async function assertOrgReadable(orgId) {
9935
10071
  await assertOrgVaultReadable(orgId);
9936
10072
  } catch (err) {
9937
10073
  if (err instanceof OrgVaultUnreadableError) {
9938
- throw new TRPCError23({ code: "FORBIDDEN", message: err.message });
10074
+ throw new TRPCError24({ code: "FORBIDDEN", message: err.message });
9939
10075
  }
9940
10076
  throw err;
9941
10077
  }
@@ -9945,10 +10081,10 @@ async function assertOrgKey(orgId) {
9945
10081
  await reconcileOrgCanary(orgId);
9946
10082
  } catch (err) {
9947
10083
  if (err instanceof OrgKeyMismatchError) {
9948
- throw new TRPCError23({ code: "FORBIDDEN", message: err.message });
10084
+ throw new TRPCError24({ code: "FORBIDDEN", message: err.message });
9949
10085
  }
9950
10086
  if (err instanceof CanaryUnavailableError) {
9951
- throw new TRPCError23({ code: "PRECONDITION_FAILED", message: err.message });
10087
+ throw new TRPCError24({ code: "PRECONDITION_FAILED", message: err.message });
9952
10088
  }
9953
10089
  throw err;
9954
10090
  }
@@ -9965,14 +10101,14 @@ var cloudSyncRouter = router({
9965
10101
  * "open this project" is the whole gesture.
9966
10102
  */
9967
10103
  trackProject: protectedProcedure.input(
9968
- z28.object({
9969
- orgId: z28.string().min(1).max(128),
9970
- cloudUrl: z28.string().url().max(2048),
9971
- projectId: z28.string().min(1).max(128),
10104
+ z29.object({
10105
+ orgId: z29.string().min(1).max(128),
10106
+ cloudUrl: z29.string().url().max(2048),
10107
+ projectId: z29.string().min(1).max(128),
9972
10108
  // Le compte sous lequel cette organisation a été listée. Tamponné avec
9973
10109
  // elle : c'est ce qui permettra à tout appel ultérieur de retrouver le
9974
10110
  // bon token sans qu'on ait à le lui redire.
9975
- accountId: z28.string().max(64).optional()
10111
+ accountId: z29.string().max(64).optional()
9976
10112
  })
9977
10113
  ).mutation(async ({ input }) => {
9978
10114
  await assertOrgReadable(input.orgId);
@@ -9994,7 +10130,7 @@ var cloudSyncRouter = router({
9994
10130
  return { pulled, state: syncState(input.orgId) };
9995
10131
  } catch (err) {
9996
10132
  if (err instanceof ProjectHeldElsewhereError) {
9997
- throw new TRPCError23({ code: "CONFLICT", message: err.code, cause: err });
10133
+ throw new TRPCError24({ code: "CONFLICT", message: err.code, cause: err });
9998
10134
  }
9999
10135
  throw err;
10000
10136
  }
@@ -10013,22 +10149,22 @@ var cloudSyncRouter = router({
10013
10149
  * fusionné.
10014
10150
  */
10015
10151
  publishProject: protectedProcedure.input(
10016
- z28.object({
10017
- orgId: z28.string().min(1).max(128),
10018
- cloudUrl: z28.string().url().max(2048),
10019
- projectId: z28.string().min(1).max(128),
10152
+ z29.object({
10153
+ orgId: z29.string().min(1).max(128),
10154
+ cloudUrl: z29.string().url().max(2048),
10155
+ projectId: z29.string().min(1).max(128),
10020
10156
  // Le compte sous lequel cette organisation a été listée. Tamponné avec
10021
10157
  // elle : c'est ce qui permettra à tout appel ultérieur de retrouver le
10022
10158
  // bon token sans qu'on ait à le lui redire.
10023
- accountId: z28.string().max(64).optional()
10159
+ accountId: z29.string().max(64).optional()
10024
10160
  })
10025
10161
  ).mutation(async ({ input }) => {
10026
10162
  const local = await projectStore.get({ id: input.projectId, orgId: null });
10027
10163
  if (!local) {
10028
- throw new TRPCError23({ code: "NOT_FOUND", message: "PROJECT_NOT_LOCAL" });
10164
+ throw new TRPCError24({ code: "NOT_FOUND", message: "PROJECT_NOT_LOCAL" });
10029
10165
  }
10030
10166
  if (await projectStore.get({ id: input.projectId, orgId: input.orgId })) {
10031
- throw new TRPCError23({ code: "CONFLICT", message: "PROJECT_ALREADY_IN_ORG" });
10167
+ throw new TRPCError24({ code: "CONFLICT", message: "PROJECT_ALREADY_IN_ORG" });
10032
10168
  }
10033
10169
  await assertOrgReadable(input.orgId);
10034
10170
  const connected = cloudSyncBridge.states().some((s) => s.orgId === input.orgId);
@@ -10053,7 +10189,7 @@ var cloudSyncRouter = router({
10053
10189
  await cloudSyncBridge.followProject(input.orgId, input.projectId);
10054
10190
  } catch (err) {
10055
10191
  if (err instanceof ProjectHeldElsewhereError) {
10056
- throw new TRPCError23({ code: "CONFLICT", message: err.code, cause: err });
10192
+ throw new TRPCError24({ code: "CONFLICT", message: err.code, cause: err });
10057
10193
  }
10058
10194
  throw err;
10059
10195
  }
@@ -10067,16 +10203,16 @@ var cloudSyncRouter = router({
10067
10203
  * publié. Le cloud, lui, ne peut pas répondre — il n'a que du chiffré sous
10068
10204
  * les yeux — donc le canari est rapatrié et jugé ici.
10069
10205
  */
10070
- checkOrgKey: protectedProcedure.input(z28.object({
10071
- orgId: z28.string().min(1).max(128),
10072
- keyHex: z28.string().length(64).regex(/^[0-9a-f]+$/i)
10206
+ checkOrgKey: protectedProcedure.input(z29.object({
10207
+ orgId: z29.string().min(1).max(128),
10208
+ keyHex: z29.string().length(64).regex(/^[0-9a-f]+$/i)
10073
10209
  })).query(async ({ input }) => {
10074
10210
  const res = await cloudFetch2(
10075
10211
  `/api/auth/organization/canary?organizationId=${encodeURIComponent(input.orgId)}`,
10076
10212
  { method: "GET", accountId: await accountForOrgScope(input.orgId) }
10077
10213
  );
10078
10214
  if (!res.ok) {
10079
- throw new TRPCError23({ code: "BAD_GATEWAY", message: await cloudMessage(res) || `CANARY_READ_FAILED (${res.status})` });
10215
+ throw new TRPCError24({ code: "BAD_GATEWAY", message: await cloudMessage(res) || `CANARY_READ_FAILED (${res.status})` });
10080
10216
  }
10081
10217
  const { canary } = await res.json();
10082
10218
  if (typeof canary !== "string") return { matches: false, published: false };
@@ -10091,7 +10227,7 @@ var cloudSyncRouter = router({
10091
10227
  * que l'interface puisse proposer ni l'adoption ni la remise à zéro — le seul
10092
10228
  * chemin qui la répare. Rien n'est écrit ici, ni sur le disque ni sur le cloud.
10093
10229
  */
10094
- orgKeyStatus: protectedProcedure.input(z28.object({ orgId: z28.string().min(1).max(128) })).query(async ({ input }) => {
10230
+ orgKeyStatus: protectedProcedure.input(z29.object({ orgId: z29.string().min(1).max(128) })).query(async ({ input }) => {
10095
10231
  const key = getEncryptionKey(input.orgId);
10096
10232
  if (!key) return { status: "unknown" };
10097
10233
  const res = await cloudFetch2(
@@ -10114,10 +10250,10 @@ var cloudSyncRouter = router({
10114
10250
  * Bornée au coffre de l'organisation et à ceux de ses projets : les autres
10115
10251
  * organisations et la machine gardent leur clé.
10116
10252
  */
10117
- adoptOrgKey: protectedProcedure.input(z28.object({
10118
- orgId: z28.string().min(1).max(128),
10119
- keyHex: z28.string().length(64).regex(/^[0-9a-f]+$/i),
10120
- masterPassword: z28.string().min(1).max(1024)
10253
+ adoptOrgKey: protectedProcedure.input(z29.object({
10254
+ orgId: z29.string().min(1).max(128),
10255
+ keyHex: z29.string().length(64).regex(/^[0-9a-f]+$/i),
10256
+ masterPassword: z29.string().min(1).max(1024)
10121
10257
  })).mutation(async ({ input }) => {
10122
10258
  const report = await adoptOrgKey(
10123
10259
  input.orgId,
@@ -10147,14 +10283,14 @@ var cloudSyncRouter = router({
10147
10283
  * Ce qui a déjà été synchronisé sous l'ancienne clé de référence reste
10148
10284
  * illisible : aucune clé d'ici ne l'ouvre. L'interface le dit avant.
10149
10285
  */
10150
- resetOrgKey: protectedProcedure.input(z28.object({
10151
- orgId: z28.string().min(1).max(128),
10152
- masterPassword: z28.string().min(1).max(1024)
10286
+ resetOrgKey: protectedProcedure.input(z29.object({
10287
+ orgId: z29.string().min(1).max(128),
10288
+ masterPassword: z29.string().min(1).max(1024)
10153
10289
  })).mutation(async ({ input }) => {
10154
10290
  const { keyHex } = await resetOrgKeyToFresh(input.orgId, input.masterPassword, /* @__PURE__ */ new Date());
10155
10291
  const canary = await readVerifyFile(orgVaultRoot(input.orgId));
10156
10292
  if (!canary) {
10157
- throw new TRPCError23({
10293
+ throw new TRPCError24({
10158
10294
  code: "PRECONDITION_FAILED",
10159
10295
  message: "Le coffre de cette organisation n'a pas re\xE7u sa cl\xE9."
10160
10296
  });
@@ -10166,7 +10302,7 @@ var cloudSyncRouter = router({
10166
10302
  });
10167
10303
  if (!res.ok) {
10168
10304
  const detail = await cloudMessage(res);
10169
- throw new TRPCError23({
10305
+ throw new TRPCError24({
10170
10306
  code: res.status === 403 ? "FORBIDDEN" : "BAD_GATEWAY",
10171
10307
  message: detail || `ORG_KEY_RESET_FAILED (${res.status})`
10172
10308
  });
@@ -10182,9 +10318,9 @@ var cloudSyncRouter = router({
10182
10318
  * every other member and for this one on another machine.
10183
10319
  */
10184
10320
  untrackProject: protectedProcedure.input(
10185
- z28.object({
10186
- orgId: z28.string().min(1).max(128),
10187
- projectId: z28.string().min(1).max(128)
10321
+ z29.object({
10322
+ orgId: z29.string().min(1).max(128),
10323
+ projectId: z29.string().min(1).max(128)
10188
10324
  })
10189
10325
  ).mutation(async ({ input }) => {
10190
10326
  await cloudSyncBridge.unfollowProject(input.orgId, input.projectId);
@@ -10200,9 +10336,9 @@ var cloudSyncRouter = router({
10200
10336
  * membre, ce qui évite d'effacer les fichiers si le cloud a refusé l'ordre.
10201
10337
  */
10202
10338
  deleteProjectFromOrg: protectedProcedure.input(
10203
- z28.object({
10204
- orgId: z28.string().min(1).max(128),
10205
- projectId: z28.string().min(1).max(128)
10339
+ z29.object({
10340
+ orgId: z29.string().min(1).max(128),
10341
+ projectId: z29.string().min(1).max(128)
10206
10342
  })
10207
10343
  ).mutation(async ({ input }) => {
10208
10344
  let res;
@@ -10215,8 +10351,8 @@ var cloudSyncRouter = router({
10215
10351
  accountId: await accountForOrgScope(input.orgId)
10216
10352
  });
10217
10353
  } catch (err) {
10218
- if (err instanceof TRPCError23 && err.code === "PRECONDITION_FAILED") {
10219
- throw new TRPCError23({ code: "PRECONDITION_FAILED", message: "CLOUD_NOT_LINKED" });
10354
+ if (err instanceof TRPCError24 && err.code === "PRECONDITION_FAILED") {
10355
+ throw new TRPCError24({ code: "PRECONDITION_FAILED", message: "CLOUD_NOT_LINKED" });
10220
10356
  }
10221
10357
  throw err;
10222
10358
  }
@@ -10224,12 +10360,12 @@ var cloudSyncRouter = router({
10224
10360
  const detail = await cloudMessage(res);
10225
10361
  if (res.status === 403) {
10226
10362
  const code = /not a member/i.test(detail) ? "PROJECT_NOT_MEMBER" : "PROJECT_DELETE_FORBIDDEN";
10227
- throw new TRPCError23({ code: "FORBIDDEN", message: code, cause: new Error(detail) });
10363
+ throw new TRPCError24({ code: "FORBIDDEN", message: code, cause: new Error(detail) });
10228
10364
  }
10229
10365
  if (res.status === 404) {
10230
- throw new TRPCError23({ code: "NOT_FOUND", message: "PROJECT_NOT_IN_ORG", cause: new Error(detail) });
10366
+ throw new TRPCError24({ code: "NOT_FOUND", message: "PROJECT_NOT_IN_ORG", cause: new Error(detail) });
10231
10367
  }
10232
- throw new TRPCError23({
10368
+ throw new TRPCError24({
10233
10369
  code: "BAD_GATEWAY",
10234
10370
  message: detail || `PROJECT_DELETE_FAILED (${res.status})`
10235
10371
  });
@@ -10258,10 +10394,10 @@ var cloudSyncRouter = router({
10258
10394
  * d'un autre. Même forme que `rememberOrgNames`, et pour la même raison :
10259
10395
  * ce que seul le cloud sait, on le recopie quand il le dit.
10260
10396
  */
10261
- rememberOrgAccounts: protectedProcedure.input(z28.object({
10262
- orgs: z28.array(z28.object({
10263
- orgId: z28.string().min(1).max(128),
10264
- accountId: z28.string().min(1).max(64)
10397
+ rememberOrgAccounts: protectedProcedure.input(z29.object({
10398
+ orgs: z29.array(z29.object({
10399
+ orgId: z29.string().min(1).max(128),
10400
+ accountId: z29.string().min(1).max(64)
10265
10401
  })).max(200)
10266
10402
  })).mutation(async ({ input }) => {
10267
10403
  const candidates = /* @__PURE__ */ new Map();
@@ -10288,10 +10424,10 @@ var cloudSyncRouter = router({
10288
10424
  }
10289
10425
  return { remembered };
10290
10426
  }),
10291
- rememberOrgNames: protectedProcedure.input(z28.object({
10292
- orgs: z28.array(z28.object({
10293
- orgId: z28.string().min(1).max(128),
10294
- name: z28.string().min(1).max(100)
10427
+ rememberOrgNames: protectedProcedure.input(z29.object({
10428
+ orgs: z29.array(z29.object({
10429
+ orgId: z29.string().min(1).max(128),
10430
+ name: z29.string().min(1).max(100)
10295
10431
  })).max(200)
10296
10432
  })).mutation(async ({ input }) => {
10297
10433
  for (const { orgId, name } of input.orgs) await rememberOrgName(orgId, name);
@@ -10321,7 +10457,7 @@ var cloudSyncRouter = router({
10321
10457
  * Un 404 efface le logo retenu — l'organisation en a retiré un — tandis qu'un
10322
10458
  * réseau muet laisse en place ce qui est déjà là : hors ligne, on garde.
10323
10459
  */
10324
- cacheOrgLogos: protectedProcedure.input(z28.object({ orgIds: z28.array(z28.string().min(1).max(128)).max(200) })).mutation(async ({ input }) => {
10460
+ cacheOrgLogos: protectedProcedure.input(z29.object({ orgIds: z29.array(z29.string().min(1).max(128)).max(200) })).mutation(async ({ input }) => {
10325
10461
  let cached = 0;
10326
10462
  for (const orgId of input.orgIds) {
10327
10463
  const base = await orgCloudUrl(orgId);
@@ -10379,13 +10515,13 @@ var cloudSyncRouter = router({
10379
10515
  // ../server/src/trpc/routers/filesystem.ts
10380
10516
  import { readdir as readdir4, stat as stat6 } from "fs/promises";
10381
10517
  import { homedir as homedir4 } from "os";
10382
- import { isAbsolute as isAbsolute3, join as join13, resolve as resolve3, dirname as dirname8, basename } from "path";
10383
- import { z as z29 } from "zod";
10518
+ import { isAbsolute as isAbsolute3, join as join14, resolve as resolve3, dirname as dirname8, basename } from "path";
10519
+ import { z as z30 } from "zod";
10384
10520
  var MAX_ENTRIES2 = 500;
10385
- var PATH_SCHEMA = z29.string().min(1).max(4096);
10521
+ var PATH_SCHEMA = z30.string().min(1).max(4096);
10386
10522
  function safeResolve(input) {
10387
10523
  if (input.includes("\0")) throw new Error("Chemin invalide");
10388
- const expanded = input.startsWith("~") ? join13(homedir4(), input.slice(1)) : input;
10524
+ const expanded = input.startsWith("~") ? join14(homedir4(), input.slice(1)) : input;
10389
10525
  if (!isAbsolute3(expanded)) throw new Error("Le chemin doit \xEAtre absolu");
10390
10526
  return resolve3(expanded);
10391
10527
  }
@@ -10406,7 +10542,7 @@ var filesystemRouter = router({
10406
10542
  * Hidden entries are skipped: they are noise for choosing a workspace, and
10407
10543
  * `.runeya` itself would invite placing a project inside another's data.
10408
10544
  */
10409
- listDirectories: protectedProcedure.input(z29.object({ path: PATH_SCHEMA })).query(async ({ input }) => {
10545
+ listDirectories: protectedProcedure.input(z30.object({ path: PATH_SCHEMA })).query(async ({ input }) => {
10410
10546
  const dir = safeResolve(input.path);
10411
10547
  const info = await stat6(dir).catch(() => null);
10412
10548
  if (!info?.isDirectory()) {
@@ -10421,7 +10557,7 @@ var filesystemRouter = router({
10421
10557
  const truncated = names.length > MAX_ENTRIES2;
10422
10558
  const entries2 = [];
10423
10559
  for (const name of names.slice(0, MAX_ENTRIES2)) {
10424
- const path = join13(dir, name);
10560
+ const path = join14(dir, name);
10425
10561
  entries2.push({ name, path, hasRuneyaProject: await holdsRuneyaProject(path) });
10426
10562
  }
10427
10563
  return {
@@ -10439,7 +10575,7 @@ var filesystemRouter = router({
10439
10575
  * qui s'y trouve, ou rien (déjà dans la liste, lié à un projet d'organisation,
10440
10576
  * racine machine).
10441
10577
  */
10442
- checkLocalProjectTarget: protectedProcedure.input(z29.object({ path: PATH_SCHEMA })).query(async ({ input }) => {
10578
+ checkLocalProjectTarget: protectedProcedure.input(z30.object({ path: PATH_SCHEMA })).query(async ({ input }) => {
10443
10579
  const dir = safeResolve(input.path);
10444
10580
  const info = await stat6(dir).catch(() => null);
10445
10581
  if (!info?.isDirectory()) return { path: dir, status: "missing", projectName: null };
@@ -10451,10 +10587,10 @@ var filesystemRouter = router({
10451
10587
  * Two projects in one directory is what makes services run against the wrong
10452
10588
  * code, so a directory that already holds one is refused outright.
10453
10589
  */
10454
- checkProjectTarget: protectedProcedure.input(z29.object({
10590
+ checkProjectTarget: protectedProcedure.input(z30.object({
10455
10591
  path: PATH_SCHEMA,
10456
- projectId: z29.string().min(1).max(128),
10457
- orgId: z29.string().max(128).nullable().optional()
10592
+ projectId: z30.string().min(1).max(128),
10593
+ orgId: z30.string().max(128).nullable().optional()
10458
10594
  })).query(async ({ input }) => {
10459
10595
  const dir = safeResolve(input.path);
10460
10596
  const info = await stat6(dir).catch(() => null);
@@ -10473,9 +10609,9 @@ var filesystemRouter = router({
10473
10609
  });
10474
10610
 
10475
10611
  // ../server/src/trpc/routers/desktop.ts
10476
- import { z as z30 } from "zod";
10612
+ import { z as z31 } from "zod";
10477
10613
  import { isAbsolute as isAbsolute5 } from "path";
10478
- import { TRPCError as TRPCError24 } from "@trpc/server";
10614
+ import { TRPCError as TRPCError25 } from "@trpc/server";
10479
10615
 
10480
10616
  // ../server/src/services/desktop-launcher.ts
10481
10617
  import { execFile as execFile5 } from "child_process";
@@ -10559,53 +10695,53 @@ var desktopRouter = router({
10559
10695
  * dessinée par le serveur. Sans cette annonce elle garderait la teinte figée
10560
10696
  * du fichier livré avec le CLI. Rien n'est persisté — voir `tray-accent.ts`.
10561
10697
  */
10562
- setTrayAccent: protectedProcedure.input(z30.object({
10698
+ setTrayAccent: protectedProcedure.input(z31.object({
10563
10699
  // `#rgb` ou `#rrggbb` : la forme est vérifiée ici, pas rabotée plus loin.
10564
- color: z30.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/).nullable()
10700
+ color: z31.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/).nullable()
10565
10701
  })).mutation(({ input }) => {
10566
10702
  setTrayAccent(input.color);
10567
10703
  return { ok: true };
10568
10704
  }),
10569
- installLauncher: protectedProcedure.input(z30.object({
10570
- name: z30.string().trim().min(1).max(120),
10705
+ installLauncher: protectedProcedure.input(z31.object({
10706
+ name: z31.string().trim().min(1).max(120),
10571
10707
  /**
10572
10708
  * `null` : raccourci global, sans dossier épinglé. Sinon un chemin
10573
10709
  * absolu, refusé autrement : le dossier devient un argument positionnel
10574
10710
  * du CLI, où une valeur commençant par un tiret passerait pour un drapeau.
10575
10711
  */
10576
- workingDir: z30.string().max(4096).refine(isAbsolute5, {
10712
+ workingDir: z31.string().max(4096).refine(isAbsolute5, {
10577
10713
  message: "Le dossier de travail doit \xEAtre un chemin absolu."
10578
10714
  }).nullable(),
10579
- port: z30.number().int().min(1).max(65535),
10580
- agentPort: z30.number().int().min(1).max(65535),
10715
+ port: z31.number().int().min(1).max(65535),
10716
+ agentPort: z31.number().int().min(1).max(65535),
10581
10717
  /** Projet ouvert directement par le raccourci (`--project`). Absent : liste des projets. */
10582
- projectId: z30.string().max(128).regex(LAUNCHER_PROJECT_ID_PATTERN).nullable().optional()
10718
+ projectId: z31.string().max(128).regex(LAUNCHER_PROJECT_ID_PATTERN).nullable().optional()
10583
10719
  })).mutation(async ({ input }) => {
10584
10720
  try {
10585
10721
  return await installLauncher(input);
10586
10722
  } catch (err) {
10587
10723
  const message = err.message;
10588
10724
  if (message === "launcher-working-dir-not-absolute") {
10589
- throw new TRPCError24({
10725
+ throw new TRPCError25({
10590
10726
  code: "BAD_REQUEST",
10591
10727
  message: "Le dossier de travail doit \xEAtre un chemin absolu."
10592
10728
  });
10593
10729
  }
10594
10730
  if (message === "launcher-unavailable") {
10595
- throw new TRPCError24({
10731
+ throw new TRPCError25({
10596
10732
  code: "PRECONDITION_FAILED",
10597
10733
  message: "Cette Runeya ne sait pas o\xF9 trouver son CLI : cr\xE9ez le raccourci avec `runeya install-desktop`."
10598
10734
  });
10599
10735
  }
10600
- throw new TRPCError24({ code: "INTERNAL_SERVER_ERROR", message });
10736
+ throw new TRPCError25({ code: "INTERNAL_SERVER_ERROR", message });
10601
10737
  }
10602
10738
  })
10603
10739
  });
10604
10740
 
10605
10741
  // ../server/src/trpc/routers/mcp-ready.ts
10606
- import { z as z31 } from "zod";
10742
+ import { z as z32 } from "zod";
10607
10743
  var mcpReadyRouter = router({
10608
- signal: protectedProcedure.input(z31.object({ id: z31.string().min(1).max(128) })).mutation(({ input }) => {
10744
+ signal: protectedProcedure.input(z32.object({ id: z32.string().min(1).max(128) })).mutation(({ input }) => {
10609
10745
  signalMcpReady(input.id);
10610
10746
  return { ok: true };
10611
10747
  })
@@ -10617,6 +10753,7 @@ var appRouter = router({
10617
10753
  session: sessionRouter,
10618
10754
  appUpdate: appUpdateRouter,
10619
10755
  changelog: changelogRouter,
10756
+ support: supportRouter,
10620
10757
  diagnostics: diagnosticsRouter,
10621
10758
  mcpPairing: mcpPairingRouter,
10622
10759
  mcpReady: mcpReadyRouter,
@@ -10711,7 +10848,7 @@ async function ensureFilePermissions() {
10711
10848
 
10712
10849
  // ../server/src/services/vault-migration.ts
10713
10850
  import { readdir as readdir5, readFile as readFile8, writeFile as writeFile7, mkdir as mkdir10, copyFile as copyFile2, unlink, rename as rename3, stat as stat8 } from "fs/promises";
10714
- import { join as join14 } from "path";
10851
+ import { join as join15 } from "path";
10715
10852
  var KEY_FILES = [".encryption.key.enc", ".runeya-verify"];
10716
10853
  var MACHINE_FILES = [
10717
10854
  "agents.json",
@@ -10741,17 +10878,17 @@ async function openLegacyVault(legacyRoot, masterPassword) {
10741
10878
  }
10742
10879
  async function migrateLegacyVault(legacyRoot, machineRootDir, legacyKey, machineKey, now) {
10743
10880
  const stamp = now.toISOString().replace(/[:.]/g, "-").substring(0, 19);
10744
- const backupDir = join14(legacyRoot, `backup-${stamp}`);
10881
+ const backupDir = join15(legacyRoot, `backup-${stamp}`);
10745
10882
  await mkdir10(backupDir, { recursive: true });
10746
10883
  const jsonFiles = await vaultJsonFiles(legacyRoot);
10747
10884
  for (const name of [...jsonFiles, ...KEY_FILES]) {
10748
- if (await exists2(join14(legacyRoot, name))) {
10749
- await copyFile2(join14(legacyRoot, name), join14(backupDir, name));
10885
+ if (await exists2(join15(legacyRoot, name))) {
10886
+ await copyFile2(join15(legacyRoot, name), join15(backupDir, name));
10750
10887
  }
10751
10888
  }
10752
10889
  const rekeyed = [];
10753
10890
  for (const name of jsonFiles) {
10754
- const raw = await readFile8(join14(legacyRoot, name), "utf-8");
10891
+ const raw = await readFile8(join15(legacyRoot, name), "utf-8");
10755
10892
  let parsed;
10756
10893
  try {
10757
10894
  parsed = JSON.parse(raw);
@@ -10761,13 +10898,13 @@ async function migrateLegacyVault(legacyRoot, machineRootDir, legacyKey, machine
10761
10898
  const counter = { n: 0 };
10762
10899
  const converted = rekeyValue(parsed, legacyKey, machineKey, counter);
10763
10900
  if (counter.n === 0) continue;
10764
- const tmp = join14(legacyRoot, `${name}.tmp`);
10901
+ const tmp = join15(legacyRoot, `${name}.tmp`);
10765
10902
  await writeFile7(tmp, JSON.stringify(converted, null, 2), "utf-8");
10766
- await rename3(tmp, join14(legacyRoot, name));
10903
+ await rename3(tmp, join15(legacyRoot, name));
10767
10904
  rekeyed.push({ file: name, values: counter.n });
10768
10905
  }
10769
10906
  for (const { file, values } of rekeyed) {
10770
- const parsed = JSON.parse(await readFile8(join14(legacyRoot, file), "utf-8"));
10907
+ const parsed = JSON.parse(await readFile8(join15(legacyRoot, file), "utf-8"));
10771
10908
  const check = { n: 0 };
10772
10909
  rekeyValue(parsed, machineKey, machineKey, check);
10773
10910
  if (check.n !== values) {
@@ -10780,9 +10917,9 @@ async function migrateLegacyVault(legacyRoot, machineRootDir, legacyKey, machine
10780
10917
  const moved = [];
10781
10918
  const skipped = [];
10782
10919
  for (const name of MACHINE_FILES) {
10783
- const from = join14(legacyRoot, name);
10920
+ const from = join15(legacyRoot, name);
10784
10921
  if (!await exists2(from)) continue;
10785
- const to = join14(machineRootDir, name);
10922
+ const to = join15(machineRootDir, name);
10786
10923
  if (await exists2(to)) {
10787
10924
  skipped.push(name);
10788
10925
  continue;
@@ -10792,7 +10929,7 @@ async function migrateLegacyVault(legacyRoot, machineRootDir, legacyKey, machine
10792
10929
  moved.push(name);
10793
10930
  }
10794
10931
  for (const name of KEY_FILES) {
10795
- const path = join14(legacyRoot, name);
10932
+ const path = join15(legacyRoot, name);
10796
10933
  if (await exists2(path)) await unlink(path);
10797
10934
  }
10798
10935
  return { backupDir, rekeyed, moved, skipped };
@@ -10800,7 +10937,7 @@ async function migrateLegacyVault(legacyRoot, machineRootDir, legacyKey, machine
10800
10937
 
10801
10938
  // ../server/src/services/settings-migration.ts
10802
10939
  import { readFile as readFile9, writeFile as writeFile8, rename as rename4, unlink as unlink2, mkdir as mkdir11, chmod as chmod4, stat as stat9 } from "fs/promises";
10803
- import { join as join15 } from "path";
10940
+ import { join as join16 } from "path";
10804
10941
  var SETTINGS_FILE = "settings.json";
10805
10942
  var SETTINGS_PRIVATE_FILE = "settings.private.json";
10806
10943
  async function exists3(path) {
@@ -10814,7 +10951,7 @@ async function legacySource(filename) {
10814
10951
  }
10815
10952
  async function moveInto(root, filename, from) {
10816
10953
  await mkdir11(root, { recursive: true });
10817
- const to = join15(root, filename);
10954
+ const to = join16(root, filename);
10818
10955
  const contents = await readFile9(from, "utf-8");
10819
10956
  const tmp = to + ".tmp";
10820
10957
  await writeFile8(tmp, contents, "utf-8");
@@ -10839,7 +10976,7 @@ async function migrateSettingsIntoVaults() {
10839
10976
  const orgId = orgs[0];
10840
10977
  const root = orgVaultRoot(orgId);
10841
10978
  for (const { filename, from } of sources) {
10842
- if (await exists3(join15(root, filename))) continue;
10979
+ if (await exists3(join16(root, filename))) continue;
10843
10980
  await moveInto(root, filename, from);
10844
10981
  report.files.push(filename);
10845
10982
  }
@@ -10862,7 +10999,7 @@ import {
10862
10999
  access as access2,
10863
11000
  readdir as readdir6
10864
11001
  } from "fs/promises";
10865
- import { join as join16, dirname as dirname9 } from "path";
11002
+ import { join as join17, dirname as dirname9 } from "path";
10866
11003
  var _require = createRequire(import.meta.url);
10867
11004
  var PARSER_ID_MAP = {
10868
11005
  "stack-monitor-parser-jsons": "native:json",
@@ -11004,7 +11141,7 @@ async function atomicWrite(path, data) {
11004
11141
  }
11005
11142
  async function runLegacyMigration(dataDir) {
11006
11143
  const legacyRoot = env.DATA_DIR;
11007
- const legacyKeyPath = join16(legacyRoot, "dbs", "encryption-key.json");
11144
+ const legacyKeyPath = join17(legacyRoot, "dbs", "encryption-key.json");
11008
11145
  try {
11009
11146
  await access2(legacyKeyPath);
11010
11147
  } catch {
@@ -11015,17 +11152,17 @@ async function runLegacyMigration(dataDir) {
11015
11152
  const legacyTmp = `${legacyRoot}-tmp`;
11016
11153
  await rename5(legacyRoot, legacyTmp);
11017
11154
  await mkdir12(dataDir, { recursive: true });
11018
- const legacyOld = join16(dataDir, `backup-${timestamp}`);
11155
+ const legacyOld = join17(dataDir, `backup-${timestamp}`);
11019
11156
  await rename5(legacyTmp, legacyOld);
11020
11157
  console.log(`[legacy-migration] Legacy data backed up to ${legacyOld}`);
11021
- const keyJson = JSON.parse(await readFile10(join16(legacyOld, "dbs", "encryption-key.json"), "utf-8"));
11158
+ const keyJson = JSON.parse(await readFile10(join17(legacyOld, "dbs", "encryption-key.json"), "utf-8"));
11022
11159
  const sodium = await getSodium();
11023
11160
  const sodiumKey = sodium.from_base64(keyJson.encryptionKey);
11024
11161
  const keyBuffer = Buffer.from(sodiumKey);
11025
11162
  const runyeaKeyHex = keyBuffer.toString("hex");
11026
11163
  await setEncryptionKey(runyeaKeyHex);
11027
11164
  console.log("[legacy-migration] Encryption key loaded in memory (temporary)");
11028
- const dbsDir = join16(legacyOld, "dbs");
11165
+ const dbsDir = join17(legacyOld, "dbs");
11029
11166
  async function readEncrypted(filePath) {
11030
11167
  try {
11031
11168
  return await decryptLegacyFile(filePath, sodiumKey, sodium);
@@ -11034,29 +11171,29 @@ async function runLegacyMigration(dataDir) {
11034
11171
  return null;
11035
11172
  }
11036
11173
  }
11037
- const envsDir = join16(dbsDir, "envs");
11174
+ const envsDir = join17(dbsDir, "envs");
11038
11175
  const envFiles = (await readdir6(envsDir).catch(() => [])).filter((f) => f.endsWith(".encrypted.json"));
11039
11176
  const legacyEnvs = {};
11040
11177
  for (const file of envFiles) {
11041
11178
  const name = file.replace(".encrypted.json", "");
11042
- legacyEnvs[name] = await readEncrypted(join16(envsDir, file));
11179
+ legacyEnvs[name] = await readEncrypted(join17(envsDir, file));
11043
11180
  }
11044
- const servicesDir = join16(dbsDir, "services");
11181
+ const servicesDir = join17(dbsDir, "services");
11045
11182
  const serviceFiles = (await readdir6(servicesDir).catch(() => [])).filter((f) => f.endsWith(".encrypted.json"));
11046
11183
  const legacyServices = {};
11047
11184
  for (const file of serviceFiles) {
11048
11185
  const name = file.replace(".encrypted.json", "");
11049
11186
  if (!name) continue;
11050
- const data = await readEncrypted(join16(servicesDir, file));
11187
+ const data = await readEncrypted(join17(servicesDir, file));
11051
11188
  if (data?.label) legacyServices[name] = data;
11052
11189
  }
11053
- const overridesDir = join16(dbsDir, "overrides");
11190
+ const overridesDir = join17(dbsDir, "overrides");
11054
11191
  const overrideFiles = (await readdir6(overridesDir).catch(() => [])).filter((f) => f.endsWith(".encrypted.json"));
11055
11192
  const legacyServiceOverrides = {};
11056
11193
  const legacyEnvOverrides = {};
11057
11194
  for (const file of overrideFiles) {
11058
11195
  const baseName = file.replace(".encrypted.json", "");
11059
- const data = await readEncrypted(join16(overridesDir, file));
11196
+ const data = await readEncrypted(join17(overridesDir, file));
11060
11197
  if (!data) continue;
11061
11198
  if (baseName.endsWith("-envs")) {
11062
11199
  legacyServiceOverrides[baseName.slice(0, -5)] = data;
@@ -11064,11 +11201,11 @@ async function runLegacyMigration(dataDir) {
11064
11201
  legacyEnvOverrides[baseName.slice(0, -12)] = data;
11065
11202
  }
11066
11203
  }
11067
- const parsersDir = join16(dbsDir, "parsers");
11204
+ const parsersDir = join17(dbsDir, "parsers");
11068
11205
  const parserFiles = (await readdir6(parsersDir).catch(() => [])).filter((f) => f.endsWith(".encrypted.json"));
11069
11206
  const legacyParsers = [];
11070
11207
  for (const file of parserFiles) {
11071
- const data = await readEncrypted(join16(parsersDir, file));
11208
+ const data = await readEncrypted(join17(parsersDir, file));
11072
11209
  if (data?.id) legacyParsers.push(data);
11073
11210
  }
11074
11211
  const projectMonoId = randomUUID9();
@@ -11409,7 +11546,7 @@ async function runLegacyMigration(dataDir) {
11409
11546
  }
11410
11547
  let existingSettings = {};
11411
11548
  try {
11412
- existingSettings = JSON.parse(await readFile10(join16(dataDir, "settings.json"), "utf-8"));
11549
+ existingSettings = JSON.parse(await readFile10(join17(dataDir, "settings.json"), "utf-8"));
11413
11550
  } catch {
11414
11551
  }
11415
11552
  const migratedParsers = legacyParsers.map((p) => ({
@@ -11430,11 +11567,11 @@ ${p.transform ?? ""}`,
11430
11567
  ...migratedParsers
11431
11568
  ]
11432
11569
  };
11433
- await atomicWrite(join16(dataDir, "projects.json"), runeProjects);
11434
- await atomicWrite(join16(dataDir, "services.json"), runeServices);
11435
- await atomicWrite(join16(dataDir, "environments.json"), runeEnvs);
11436
- await atomicWrite(join16(dataDir, "environment-overrides.json"), flatOverrides);
11437
- await atomicWrite(join16(dataDir, "settings.json"), newSettings);
11570
+ await atomicWrite(join17(dataDir, "projects.json"), runeProjects);
11571
+ await atomicWrite(join17(dataDir, "services.json"), runeServices);
11572
+ await atomicWrite(join17(dataDir, "environments.json"), runeEnvs);
11573
+ await atomicWrite(join17(dataDir, "environment-overrides.json"), flatOverrides);
11574
+ await atomicWrite(join17(dataDir, "settings.json"), newSettings);
11438
11575
  const svcEnvCount = runeEnvs.filter((e) => e.scope === "service").length;
11439
11576
  console.log(`[legacy-migration] Written: ${runeProjects.length} projects, ${runeServices.length} services, ${runeEnvs.length} environments (${svcEnvCount} service-scoped)`);
11440
11577
  console.log(`[legacy-migration] Overrides: ${Object.keys(flatOverrides).length}, custom parsers: ${migratedParsers.length} (all disabled \u2014 rewrite required)`);
@@ -11448,7 +11585,7 @@ async function findLegacyKeyInBackup(dataDir) {
11448
11585
  const entries2 = await readdir6(dataDir);
11449
11586
  const backupDirs = entries2.filter((e) => e.startsWith("backup-")).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).reverse();
11450
11587
  for (const dir of backupDirs) {
11451
- const keyJsonPath = join16(dataDir, dir, "dbs", "encryption-key.json");
11588
+ const keyJsonPath = join17(dataDir, dir, "dbs", "encryption-key.json");
11452
11589
  try {
11453
11590
  const raw = await readFile10(keyJsonPath, "utf-8");
11454
11591
  const parsed = JSON.parse(raw);
@@ -11471,8 +11608,8 @@ async function runOverrideOnlyMigration(dataDir) {
11471
11608
  const { resolve: resolve5 } = await import("path");
11472
11609
  const abDataDir = resolve5(dataDir);
11473
11610
  const candidateDirs = [
11474
- join16(dirname9(env.DATA_DIR), ".runeya", "dbs", "overrides"),
11475
- join16(abDataDir, "dbs", "overrides")
11611
+ join17(dirname9(env.DATA_DIR), ".runeya", "dbs", "overrides"),
11612
+ join17(abDataDir, "dbs", "overrides")
11476
11613
  ];
11477
11614
  let overridesDir = null;
11478
11615
  let overrideFiles = [];
@@ -11488,7 +11625,7 @@ async function runOverrideOnlyMigration(dataDir) {
11488
11625
  }
11489
11626
  }
11490
11627
  if (!overridesDir || overrideFiles.length === 0) return false;
11491
- const legacyKeyPath = join16(overridesDir, "..", "encryption-key.json");
11628
+ const legacyKeyPath = join17(overridesDir, "..", "encryption-key.json");
11492
11629
  try {
11493
11630
  await access2(legacyKeyPath);
11494
11631
  return false;
@@ -11506,7 +11643,7 @@ async function runOverrideOnlyMigration(dataDir) {
11506
11643
  const envNameToId = {};
11507
11644
  let envsRaw;
11508
11645
  try {
11509
- envsRaw = JSON.parse(await readFile10(join16(abDataDir, "environments.json"), "utf-8"));
11646
+ envsRaw = JSON.parse(await readFile10(join17(abDataDir, "environments.json"), "utf-8"));
11510
11647
  for (const _env of envsRaw) {
11511
11648
  const env2 = _env;
11512
11649
  if (env2["name"] && env2["id"]) {
@@ -11525,7 +11662,7 @@ async function runOverrideOnlyMigration(dataDir) {
11525
11662
  let servicesRaw = [];
11526
11663
  const serviceNameToId = {};
11527
11664
  try {
11528
- servicesRaw = JSON.parse(await readFile10(join16(abDataDir, "services.json"), "utf-8"));
11665
+ servicesRaw = JSON.parse(await readFile10(join17(abDataDir, "services.json"), "utf-8"));
11529
11666
  for (const _svc of servicesRaw) {
11530
11667
  const svc = _svc;
11531
11668
  if (svc["name"] && svc["id"]) serviceNameToId[svc["name"]] = svc["id"];
@@ -11542,7 +11679,7 @@ async function runOverrideOnlyMigration(dataDir) {
11542
11679
  const envName = baseName.slice(0, -"-environment".length);
11543
11680
  let data;
11544
11681
  try {
11545
- data = await decryptLegacyFile(join16(overridesDir, file), sodiumKey, sodium);
11682
+ data = await decryptLegacyFile(join17(overridesDir, file), sodiumKey, sodium);
11546
11683
  } catch (err) {
11547
11684
  console.warn(`[override-migration] Failed to decrypt ${file}: ${err.message}`);
11548
11685
  continue;
@@ -11569,7 +11706,7 @@ async function runOverrideOnlyMigration(dataDir) {
11569
11706
  }
11570
11707
  }
11571
11708
  if (Object.keys(flatOverrides).length > 0) {
11572
- await atomicWrite(join16(abDataDir, "environment-overrides.json"), flatOverrides);
11709
+ await atomicWrite(join17(abDataDir, "environment-overrides.json"), flatOverrides);
11573
11710
  console.log(`[override-migration] Written ${Object.keys(flatOverrides).length} override(s) to environment-overrides.json`);
11574
11711
  }
11575
11712
  let envsModified = false;
@@ -11579,7 +11716,7 @@ async function runOverrideOnlyMigration(dataDir) {
11579
11716
  const serviceName = baseName.slice(0, -"-envs".length);
11580
11717
  let data;
11581
11718
  try {
11582
- data = await decryptLegacyFile(join16(overridesDir, file), sodiumKey, sodium);
11719
+ data = await decryptLegacyFile(join17(overridesDir, file), sodiumKey, sodium);
11583
11720
  } catch (err) {
11584
11721
  console.warn(`[override-migration] Failed to decrypt ${file}: ${err.message}`);
11585
11722
  continue;
@@ -11638,7 +11775,7 @@ async function runOverrideOnlyMigration(dataDir) {
11638
11775
  }
11639
11776
  }
11640
11777
  if (envsModified) {
11641
- await atomicWrite(join16(abDataDir, "environments.json"), envsRaw);
11778
+ await atomicWrite(join17(abDataDir, "environments.json"), envsRaw);
11642
11779
  console.log("[override-migration] Merged service overrides into environments.json");
11643
11780
  }
11644
11781
  const migratedDir = overridesDir.replace(/overrides$/, "overrides-migrated");
@@ -11653,7 +11790,7 @@ async function runOverrideOnlyMigration(dataDir) {
11653
11790
  }
11654
11791
 
11655
11792
  // ../server/src/services/server-state.ts
11656
- import { join as join17 } from "path";
11793
+ import { join as join18 } from "path";
11657
11794
  import { stat as stat10 } from "fs/promises";
11658
11795
  var ENCRYPTED_KEY_FILENAME2 = ".encryption.key.enc";
11659
11796
  var VERIFY_FILENAME2 = ".runeya-verify";
@@ -11663,22 +11800,22 @@ async function getServerState() {
11663
11800
  let hasVerify = false;
11664
11801
  let hasData = false;
11665
11802
  try {
11666
- await stat10(join17(dataDir, ENCRYPTED_KEY_FILENAME2));
11803
+ await stat10(join18(dataDir, ENCRYPTED_KEY_FILENAME2));
11667
11804
  hasEncFile = true;
11668
11805
  } catch {
11669
11806
  }
11670
11807
  try {
11671
- await stat10(join17(dataDir, VERIFY_FILENAME2));
11808
+ await stat10(join18(dataDir, VERIFY_FILENAME2));
11672
11809
  hasVerify = true;
11673
11810
  } catch {
11674
11811
  }
11675
11812
  try {
11676
- await stat10(join17(dataDir, "projects.json"));
11813
+ await stat10(join18(dataDir, "projects.json"));
11677
11814
  hasData = true;
11678
11815
  } catch {
11679
11816
  }
11680
11817
  try {
11681
- await stat10(join17(dataDir, "project.json"));
11818
+ await stat10(join18(dataDir, "project.json"));
11682
11819
  hasData = true;
11683
11820
  } catch {
11684
11821
  }
@@ -12191,7 +12328,7 @@ async function createLocalServer() {
12191
12328
  machineRoot(),
12192
12329
  ...orgRoots,
12193
12330
  ...vaultRoots,
12194
- ...[machineRoot(), ...vaultRoots].map((root) => join18(root, CONVERSATIONS_DIRNAME))
12331
+ ...[machineRoot(), ...vaultRoots].map((root) => join19(root, CONVERSATIONS_DIRNAME))
12195
12332
  ]);
12196
12333
  if (removed > 0) console.log(`[server] ${removed} fichier(s) temporaire(s) orphelin(s) retir\xE9(s)`);
12197
12334
  })().catch((err) => console.warn("[server] Temp file sweep failed:", err));
@@ -12446,6 +12583,67 @@ async function createLocalServer() {
12446
12583
  });
12447
12584
  proxyCloudStream("/api/cloud/chat/stream", "/api/chat/stream");
12448
12585
  proxyCloudStream("/api/cloud/kanban/stream", "/api/kanban/stream");
12586
+ app.get("/api/cloud/support/stream", async (req, res) => {
12587
+ const jwt = typeof req.query["token"] === "string" ? req.query["token"] : "";
12588
+ try {
12589
+ await verifyJwt(jwt);
12590
+ } catch {
12591
+ res.status(401).end();
12592
+ return;
12593
+ }
12594
+ if (req.destroyed || res.closed) return;
12595
+ const stop = new AbortController();
12596
+ res.writeHead(200, { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", Connection: "keep-alive", "X-Accel-Buffering": "no" });
12597
+ res.write(": connected\n\n");
12598
+ const signal = () => {
12599
+ if (!res.writableEnded) res.write("data: changed\n\n");
12600
+ };
12601
+ const followAccount = async (accountId) => {
12602
+ while (!stop.signal.aborted) {
12603
+ try {
12604
+ const token = await cloudSessionStore.getToken(accountId);
12605
+ if (!token) return;
12606
+ const base = (await cloudSessionStore.getCloudUrl(accountId) ?? getCloudApiUrl()).replace(/\/+$/, "");
12607
+ const upstream = await fetch(`${base}/api/support/stream`, {
12608
+ headers: { Authorization: `Bearer ${token}`, [APP_VERSION_HEADER]: appVersion, Accept: "text/event-stream" },
12609
+ signal: stop.signal
12610
+ });
12611
+ if (upstream.status === 404) return;
12612
+ if (!upstream.ok || !upstream.body) throw new Error(`support stream: HTTP ${upstream.status}`);
12613
+ const reader = upstream.body.getReader();
12614
+ const decoder = new TextDecoder();
12615
+ for (; ; ) {
12616
+ const { done, value } = await reader.read();
12617
+ if (done) break;
12618
+ if (decoder.decode(value, { stream: true }).includes("data:")) signal();
12619
+ }
12620
+ } catch (err) {
12621
+ if (!stop.signal.aborted) console.warn("[support] stream: upstream failed, retrying in 5 s:", err instanceof Error ? err.message : err);
12622
+ }
12623
+ if (!stop.signal.aborted) await new Promise((r) => setTimeout(r, 5e3));
12624
+ }
12625
+ };
12626
+ for (const account of await cloudSessionStore.list()) void followAccount(account.id);
12627
+ let lastStamp = null;
12628
+ const pollAnonymous = async () => {
12629
+ try {
12630
+ const stamp = await anonymousTicketsStamp();
12631
+ if (lastStamp !== null && stamp !== lastStamp) signal();
12632
+ lastStamp = stamp;
12633
+ } catch {
12634
+ }
12635
+ };
12636
+ void pollAnonymous();
12637
+ const anonymousTimer = setInterval(() => void pollAnonymous(), 2e4);
12638
+ const ping = setInterval(() => {
12639
+ if (!res.writableEnded) res.write(": ping\n\n");
12640
+ }, 25e3);
12641
+ req.on("close", () => {
12642
+ stop.abort();
12643
+ clearInterval(anonymousTimer);
12644
+ clearInterval(ping);
12645
+ });
12646
+ });
12449
12647
  app.get("/api/cloud/knowledge/page/:pageId/stream", async (req, res) => {
12450
12648
  if (!KnowledgeIdSchema.safeParse(req.params.pageId).success) {
12451
12649
  res.status(400).end();
@@ -12899,7 +13097,7 @@ async function createLocalServer() {
12899
13097
  ]);
12900
13098
  console.log("[server] Shutdown complete");
12901
13099
  };
12902
- const { initCompanion } = await import("./companion-KVAOV52T.js");
13100
+ const { initCompanion } = await import("./companion-CGBD5O6Y.js");
12903
13101
  initCompanion();
12904
13102
  return { app, server, wss, shutdown };
12905
13103
  }
@@ -13030,7 +13228,7 @@ function onTrayServicesChanged(listener) {
13030
13228
 
13031
13229
  // ../server/src/services/tray-icon.ts
13032
13230
  import { mkdir as mkdir13, writeFile as writeFile10, rename as rename6 } from "fs/promises";
13033
- import { join as join19 } from "path";
13231
+ import { join as join20 } from "path";
13034
13232
 
13035
13233
  // ../server/src/services/png-to-ico.ts
13036
13234
  function isPng(bytes) {
@@ -13190,7 +13388,7 @@ var FETCH_TIMEOUT_MS = 3e3;
13190
13388
  var CACHE_TTL_MS = 10 * 6e4;
13191
13389
  var cache2 = /* @__PURE__ */ new Map();
13192
13390
  function trayIconDir() {
13193
- return join19(machineRoot(), "tray-icons");
13391
+ return join20(machineRoot(), "tray-icons");
13194
13392
  }
13195
13393
  async function resolveTrayIcon(platform = process.platform) {
13196
13394
  const orgId = getCurrentProject()?.orgId;
@@ -13219,7 +13417,7 @@ async function renderThemedIcon(platform) {
13219
13417
  async function writeTrayIcon(stem, png, platform) {
13220
13418
  const dir = trayIconDir();
13221
13419
  await mkdir13(dir, { recursive: true });
13222
- const path = join19(dir, stem);
13420
+ const path = join20(dir, stem);
13223
13421
  if (platform === "win32") {
13224
13422
  const ico = pngToIco(png);
13225
13423
  return ico ? writeAtomic(`${path}.ico`, ico) : null;
@@ -13354,4 +13552,4 @@ export {
13354
13552
  stopProcess,
13355
13553
  userPrefix
13356
13554
  };
13357
- //# sourceMappingURL=src-F5SK2AL3.js.map
13555
+ //# sourceMappingURL=src-UZX6XOIK.js.map