@qodeca/xezar 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/README.md +45 -15
  2. package/dist/agent-config/account-identity.d.ts +2 -8
  3. package/dist/agent-config/account-identity.js +54 -10
  4. package/dist/agent-config/account-identity.js.map +1 -1
  5. package/dist/agent-config/catalog.d.ts +49 -7
  6. package/dist/agent-config/catalog.js +107 -0
  7. package/dist/agent-config/catalog.js.map +1 -1
  8. package/dist/agent-config/model-settings/pi.d.ts +12 -6
  9. package/dist/agent-config/model-settings/pi.js +12 -6
  10. package/dist/agent-config/model-settings/pi.js.map +1 -1
  11. package/dist/agent-config/seed.js +10 -0
  12. package/dist/agent-config/seed.js.map +1 -1
  13. package/dist/contract/github.d.ts +15 -0
  14. package/dist/contract/index.d.ts +9 -0
  15. package/dist/contract/index.js +1527 -895
  16. package/dist/contract/mcp-api-reference.d.ts +174 -0
  17. package/dist/contract/mcp-audit.d.ts +103 -0
  18. package/dist/contract/mcp-discovery.d.ts +257 -0
  19. package/dist/contract/mcp-event-catalog.d.ts +121 -0
  20. package/dist/contract/mcp-event-catalog.test.d.ts +1 -0
  21. package/dist/contract/mcp-idempotency.d.ts +200 -0
  22. package/dist/contract/mcp-journal.d.ts +268 -0
  23. package/dist/contract/mcp-leader.d.ts +88 -0
  24. package/dist/contract/mcp-ownership.d.ts +78 -0
  25. package/dist/contract/mcp-versioning.d.ts +139 -0
  26. package/dist/contract/runs.d.ts +81 -0
  27. package/dist/core/agent-profiles.d.ts +15 -4
  28. package/dist/core/agent-profiles.js +22 -8
  29. package/dist/core/agent-profiles.js.map +1 -1
  30. package/dist/core/opencode-server-runner.js +71 -11
  31. package/dist/core/opencode-server-runner.js.map +1 -1
  32. package/dist/core/secret-redaction.d.ts +7 -1
  33. package/dist/core/secret-redaction.js +44 -10
  34. package/dist/core/secret-redaction.js.map +1 -1
  35. package/dist/index.js +138 -27
  36. package/dist/index.js.map +1 -1
  37. package/dist/machine-identity.d.ts +66 -0
  38. package/dist/machine-identity.js +96 -0
  39. package/dist/machine-identity.js.map +1 -0
  40. package/dist/mcp/adapters/claude-code.d.ts +41 -0
  41. package/dist/mcp/adapters/claude-code.js +40 -0
  42. package/dist/mcp/adapters/claude-code.js.map +1 -0
  43. package/dist/mcp/adapters/codex.d.ts +140 -0
  44. package/dist/mcp/adapters/codex.js +323 -0
  45. package/dist/mcp/adapters/codex.js.map +1 -0
  46. package/dist/mcp/adapters/opencode.d.ts +148 -0
  47. package/dist/mcp/adapters/opencode.js +528 -0
  48. package/dist/mcp/adapters/opencode.js.map +1 -0
  49. package/dist/mcp/adapters/pi-link.d.ts +102 -0
  50. package/dist/mcp/adapters/pi-link.js +235 -0
  51. package/dist/mcp/adapters/pi-link.js.map +1 -0
  52. package/dist/mcp/adapters/pi.d.ts +188 -0
  53. package/dist/mcp/adapters/pi.js +418 -0
  54. package/dist/mcp/adapters/pi.js.map +1 -0
  55. package/dist/mcp/api-reference.d.ts +26 -0
  56. package/dist/mcp/api-reference.js +133 -0
  57. package/dist/mcp/api-reference.js.map +1 -0
  58. package/dist/mcp/audit-trail.d.ts +162 -0
  59. package/dist/mcp/audit-trail.js +306 -0
  60. package/dist/mcp/audit-trail.js.map +1 -0
  61. package/dist/mcp/bridge.d.ts +81 -0
  62. package/dist/mcp/bridge.js +407 -0
  63. package/dist/mcp/bridge.js.map +1 -0
  64. package/dist/mcp/connection-file.d.ts +49 -0
  65. package/dist/mcp/connection-file.js +63 -0
  66. package/dist/mcp/connection-file.js.map +1 -0
  67. package/dist/mcp/echo-guard.d.ts +94 -0
  68. package/dist/mcp/echo-guard.js +160 -0
  69. package/dist/mcp/echo-guard.js.map +1 -0
  70. package/dist/mcp/event-catalog.d.ts +120 -0
  71. package/dist/mcp/event-catalog.js +306 -0
  72. package/dist/mcp/event-catalog.js.map +1 -0
  73. package/dist/mcp/event-controller.d.ts +230 -0
  74. package/dist/mcp/event-controller.js +596 -0
  75. package/dist/mcp/event-controller.js.map +1 -0
  76. package/dist/mcp/event-journal.d.ts +57 -0
  77. package/dist/mcp/event-journal.js +423 -0
  78. package/dist/mcp/event-journal.js.map +1 -0
  79. package/dist/mcp/index.d.ts +63 -0
  80. package/dist/mcp/index.js +386 -0
  81. package/dist/mcp/index.js.map +1 -0
  82. package/dist/mcp/ipc.d.ts +202 -0
  83. package/dist/mcp/ipc.js +206 -0
  84. package/dist/mcp/ipc.js.map +1 -0
  85. package/dist/mcp/leader-delivery.d.ts +119 -0
  86. package/dist/mcp/leader-delivery.js +450 -0
  87. package/dist/mcp/leader-delivery.js.map +1 -0
  88. package/dist/mcp/operation-receipts.d.ts +210 -0
  89. package/dist/mcp/operation-receipts.js +723 -0
  90. package/dist/mcp/operation-receipts.js.map +1 -0
  91. package/dist/mcp/project-catalogs.d.ts +23 -0
  92. package/dist/mcp/project-catalogs.js +25 -0
  93. package/dist/mcp/project-catalogs.js.map +1 -0
  94. package/dist/mcp/project-leaders.d.ts +26 -0
  95. package/dist/mcp/project-leaders.js +17 -0
  96. package/dist/mcp/project-leaders.js.map +1 -0
  97. package/dist/mcp/protocol.d.ts +50 -0
  98. package/dist/mcp/protocol.js +47 -0
  99. package/dist/mcp/protocol.js.map +1 -0
  100. package/dist/mcp/reconnect.d.ts +297 -0
  101. package/dist/mcp/reconnect.js +465 -0
  102. package/dist/mcp/reconnect.js.map +1 -0
  103. package/dist/mcp/resource-ownership.d.ts +228 -0
  104. package/dist/mcp/resource-ownership.js +390 -0
  105. package/dist/mcp/resource-ownership.js.map +1 -0
  106. package/dist/mcp/service-adapter.d.ts +16488 -0
  107. package/dist/mcp/service-adapter.js +148 -0
  108. package/dist/mcp/service-adapter.js.map +1 -0
  109. package/dist/mcp/service.d.ts +83 -0
  110. package/dist/mcp/service.js +233 -0
  111. package/dist/mcp/service.js.map +1 -0
  112. package/dist/mcp/session-binding.d.ts +105 -0
  113. package/dist/mcp/session-binding.js +163 -0
  114. package/dist/mcp/session-binding.js.map +1 -0
  115. package/dist/mcp/stale-write.d.ts +145 -0
  116. package/dist/mcp/stale-write.js +219 -0
  117. package/dist/mcp/stale-write.js.map +1 -0
  118. package/dist/mcp/tool.d.ts +48 -0
  119. package/dist/mcp/tool.js +24 -0
  120. package/dist/mcp/tool.js.map +1 -0
  121. package/dist/mcp/tools/discovery.d.ts +40 -0
  122. package/dist/mcp/tools/discovery.js +232 -0
  123. package/dist/mcp/tools/discovery.js.map +1 -0
  124. package/dist/mcp/tools/execution-control.d.ts +171 -0
  125. package/dist/mcp/tools/execution-control.js +513 -0
  126. package/dist/mcp/tools/execution-control.js.map +1 -0
  127. package/dist/mcp/tools/handoff-git.d.ts +26 -0
  128. package/dist/mcp/tools/handoff-git.js +544 -0
  129. package/dist/mcp/tools/handoff-git.js.map +1 -0
  130. package/dist/mcp/tools/index.d.ts +2 -0
  131. package/dist/mcp/tools/index.js +23 -0
  132. package/dist/mcp/tools/index.js.map +1 -0
  133. package/dist/mcp/tools/leader-events.d.ts +46 -0
  134. package/dist/mcp/tools/leader-events.js +126 -0
  135. package/dist/mcp/tools/leader-events.js.map +1 -0
  136. package/dist/mcp/tools/local-handoff.d.ts +102 -0
  137. package/dist/mcp/tools/local-handoff.js +306 -0
  138. package/dist/mcp/tools/local-handoff.js.map +1 -0
  139. package/dist/mcp/tools/project-config.d.ts +340 -0
  140. package/dist/mcp/tools/project-config.js +1075 -0
  141. package/dist/mcp/tools/project-config.js.map +1 -0
  142. package/dist/mcp/tools/results-evidence.d.ts +112 -0
  143. package/dist/mcp/tools/results-evidence.js +1045 -0
  144. package/dist/mcp/tools/results-evidence.js.map +1 -0
  145. package/dist/mcp/tools/task-create.d.ts +70 -0
  146. package/dist/mcp/tools/task-create.js +473 -0
  147. package/dist/mcp/tools/task-create.js.map +1 -0
  148. package/dist/mcp/tools/task-reads.d.ts +102 -0
  149. package/dist/mcp/tools/task-reads.js +689 -0
  150. package/dist/mcp/tools/task-reads.js.map +1 -0
  151. package/dist/mcp/tools/work-organisation.d.ts +2 -0
  152. package/dist/mcp/tools/work-organisation.js +502 -0
  153. package/dist/mcp/tools/work-organisation.js.map +1 -0
  154. package/dist/paths.d.ts +17 -7
  155. package/dist/paths.js +18 -8
  156. package/dist/paths.js.map +1 -1
  157. package/dist/runs/project-writer.js +76 -11
  158. package/dist/runs/project-writer.js.map +1 -1
  159. package/dist/runs/retention.d.ts +24 -1
  160. package/dist/runs/retention.js +62 -1
  161. package/dist/runs/retention.js.map +1 -1
  162. package/dist/server/forge/github.js +44 -0
  163. package/dist/server/forge/github.js.map +1 -1
  164. package/dist/server/forge/types.d.ts +16 -0
  165. package/dist/server/project-context.d.ts +81 -8
  166. package/dist/server/project-context.js +143 -35
  167. package/dist/server/project-context.js.map +1 -1
  168. package/dist/server/server.d.ts +1050 -53
  169. package/dist/server/server.js +326 -120
  170. package/dist/server/server.js.map +1 -1
  171. package/dist/server/validators.d.ts +26 -6
  172. package/dist/server/validators.js +17 -0
  173. package/dist/server/validators.js.map +1 -1
  174. package/dist/skills-remote.js +64 -6
  175. package/dist/skills-remote.js.map +1 -1
  176. package/dist/workflows/run.d.ts +277 -12
  177. package/dist/workflows/run.js +554 -59
  178. package/dist/workflows/run.js.map +1 -1
  179. package/dist/workspace/agent-profiles.d.ts +30 -3
  180. package/dist/workspace/agent-profiles.js +39 -4
  181. package/dist/workspace/agent-profiles.js.map +1 -1
  182. package/dist/workspace/config.js +25 -4
  183. package/dist/workspace/config.js.map +1 -1
  184. package/dist/workspace/project-owner.d.ts +210 -0
  185. package/dist/workspace/project-owner.js +518 -0
  186. package/dist/workspace/project-owner.js.map +1 -0
  187. package/package.json +5 -3
  188. package/scripts/pi-leader-extension.ts +420 -0
  189. package/scripts/sync-readme.mjs +83 -2
  190. package/web/dist/assets/{alert-dialog-BVsVcbFy.js → alert-dialog-D6rP6d39.js} +1 -1
  191. package/web/dist/assets/arrow-down-DMOfFIzW.js +1 -0
  192. package/web/dist/assets/arrow-left-C4Ec2BUg.js +1 -0
  193. package/web/dist/assets/{centered-state-Djgly6Ni.js → centered-state-B0ZqrPaa.js} +12 -12
  194. package/web/dist/assets/chevron-right-mHJ-crvn.js +1 -0
  195. package/web/dist/assets/{collapsible-DZ4D-DHG.js → collapsible-DchEHgUM.js} +1 -1
  196. package/web/dist/assets/{commit-list-B-z1JL9G.js → commit-list-BpMim1Rv.js} +1 -1
  197. package/web/dist/assets/{compare-variants-D62m4j3B.js → compare-variants-D5ItQbAq.js} +1 -1
  198. package/web/dist/assets/{diff-BKew9rQX.js → diff-HqqZ_WDR.js} +2 -2
  199. package/web/dist/assets/{diff-stat-D0mc5V6Z.js → diff-stat-NsU-3ecr.js} +1 -1
  200. package/web/dist/assets/{diff-view-xpIcuLIC.js → diff-view-B7c11Xux.js} +1 -1
  201. package/web/dist/assets/{dropdown-menu-CEQziH7X.js → dropdown-menu-CtTpnyod.js} +1 -1
  202. package/web/dist/assets/{editable-title-BCX3T2BY.js → editable-title-BXtuGQry.js} +1 -1
  203. package/web/dist/assets/{ellipsis-vertical-ByVdDc4z.js → ellipsis-vertical-MHtGZSH6.js} +1 -1
  204. package/web/dist/assets/{file-xBSB5hXO.js → file-DKLw5SOb.js} +1 -1
  205. package/web/dist/assets/{folder-CldgbZ5A.js → folder-Drw6-ufH.js} +1 -1
  206. package/web/dist/assets/{git-toolbar-DJANqg7Y.js → git-toolbar-BQH8bORV.js} +1 -1
  207. package/web/dist/assets/github-ynnpKFCJ.js +1 -0
  208. package/web/dist/assets/{image-preview-Cv5mZr0n.js → image-preview-DLhMN_R9.js} +1 -1
  209. package/web/dist/assets/index-BEsrNdXt.js +29 -0
  210. package/web/dist/assets/index-Da8DOBau.css +2 -0
  211. package/web/dist/assets/{markdown-CgEEE2ND.js → markdown-q365eN6Y.js} +1 -1
  212. package/web/dist/assets/{new-task-form-1r2bgsdD.js → new-task-form-CW-hNIWQ.js} +1 -1
  213. package/web/dist/assets/{pill-q-x22_ej.js → pill-B_TFulXa.js} +1 -1
  214. package/web/dist/assets/{project-router-VDN4jQM8.js → project-router-CLPc-ImZ.js} +1 -1
  215. package/web/dist/assets/{prompt-templates-BmZtCe-L.js → prompt-templates-CLc4RxyO.js} +1 -1
  216. package/web/dist/assets/{repo-git-btG0sdbO.js → repo-git-Is7R6-Tj.js} +1 -1
  217. package/web/dist/assets/{run-diff-vguEMJzh.js → run-diff-DHMvDlVo.js} +2 -2
  218. package/web/dist/assets/run-header-DvZJbQ8I.js +1 -0
  219. package/web/dist/assets/{search-x-QmhaAbg5.js → search-x-Ce2MMetu.js} +1 -1
  220. package/web/dist/assets/{skill-empty-hint-BrzUwByZ.js → skill-empty-hint-C_xCSvzB.js} +1 -1
  221. package/web/dist/assets/skills-CivqD4si.js +1 -0
  222. package/web/dist/assets/{sparkles-CP8QDOgX.js → sparkles-BCqPoj5g.js} +1 -1
  223. package/web/dist/assets/{square-terminal-CGypshSD.js → square-terminal-ikj5g-oK.js} +1 -1
  224. package/web/dist/assets/{tab-link-D4lFzzI1.js → tab-link-VsEjFV1Y.js} +1 -1
  225. package/web/dist/assets/{task-changes-BtZId14z.js → task-changes-CH-E81-_.js} +1 -1
  226. package/web/dist/assets/{task-commits-BoeyJXrv.js → task-commits-DqfkMFxp.js} +1 -1
  227. package/web/dist/assets/{task-files-DIy2oUnj.js → task-files-D_nkHZ_a.js} +2 -2
  228. package/web/dist/assets/task-thread-bxQompxJ.js +9 -0
  229. package/web/dist/assets/{textarea-CyBCyKIk.js → textarea-xajuW1L_.js} +1 -1
  230. package/web/dist/assets/{thread-loading-Cuq2jchC.js → thread-loading-C3JQZbIE.js} +1 -1
  231. package/web/dist/assets/{trash-2-B6Dp3ZNs.js → trash-2-hJrBhpUD.js} +1 -1
  232. package/web/dist/assets/{triangle-alert-xBya8FUp.js → triangle-alert-D1u82y1a.js} +1 -1
  233. package/web/dist/assets/{upload-D6MXEB9p.js → upload-Bn6FBZ59.js} +1 -1
  234. package/web/dist/assets/{use-desktop-CPBwzQ7M.js → use-desktop-DOIMfHfY.js} +1 -1
  235. package/web/dist/assets/{use-submit-shortcut-JTpNzU-u.js → use-submit-shortcut-Dj4DHTdE.js} +1 -1
  236. package/web/dist/assets/utils-YwBpOoRN.js +64 -0
  237. package/web/dist/assets/{workflows-DG115scU.js → workflows-CTaAKz2m.js} +3 -3
  238. package/web/dist/assets/{zoomable-image-GTYwLtkS.js → zoomable-image-C1-6P3tg.js} +1 -1
  239. package/web/dist/index.html +23 -23
  240. package/web/dist/assets/arrow-down-CYgAlZtW.js +0 -1
  241. package/web/dist/assets/arrow-left-BOqE0a3k.js +0 -1
  242. package/web/dist/assets/chevron-right-Cc9BWnbN.js +0 -1
  243. package/web/dist/assets/github-D6vK0jFn.js +0 -1
  244. package/web/dist/assets/index-CkmR6h7s.css +0 -2
  245. package/web/dist/assets/index-DVDqF4bM.js +0 -9
  246. package/web/dist/assets/refresh-cw-DcNCj2nu.js +0 -1
  247. package/web/dist/assets/run-header-DM7MiKj9.js +0 -1
  248. package/web/dist/assets/skills-DMfxQtrD.js +0 -1
  249. package/web/dist/assets/task-thread-CbMPmrWq.js +0 -9
  250. package/web/dist/assets/utils--z9hRtl3.js +0 -64
@@ -0,0 +1,386 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { realpath } from 'node:fs/promises';
3
+ import { basename, resolve } from 'node:path';
4
+ import { operationIdSchema, } from '../contract/index.js';
5
+ import { collectSecretValues } from '../core/secret-redaction.js';
6
+ import { projectDataDir } from '../project-data-paths.js';
7
+ import { loadWorkspaceConfig } from '../workspace/config.js';
8
+ import { ProjectOwnership } from '../workspace/project-owner.js';
9
+ import { AuditTrail } from './audit-trail.js';
10
+ import { runBridge } from './bridge.js';
11
+ import { writeMcpConnectionFile } from './connection-file.js';
12
+ import { EchoGuard } from './echo-guard.js';
13
+ import { EventCatalog, withEventOrigin } from './event-catalog.js';
14
+ import { EventJournal } from './event-journal.js';
15
+ import { mcpSocketLocation } from './ipc.js';
16
+ import { LeaderDelivery } from './leader-delivery.js';
17
+ import { OperationReceiptStore, runByKeyReconciler } from './operation-receipts.js';
18
+ import { registerProjectCatalog } from './project-catalogs.js';
19
+ import { registerProjectLeader } from './project-leaders.js';
20
+ import { LeaderCursors, runStateReader } from './reconnect.js';
21
+ import { listenMcpSocket } from './service.js';
22
+ import { staleRejectionIn } from './stale-write.js';
23
+ import { errorResult, textResult } from './tool.js';
24
+ import { tools } from './tools/index.js';
25
+ /**
26
+ * The MCP module's public surface (#86, D-01). `packages/xezar/src/index.ts` imports
27
+ * it LAZILY from both sides, so an ordinary `serve` that never meets an MCP client
28
+ * pays nothing for it and cannot be broken by it (N-07).
29
+ */
30
+ export { runBridge, HEALTH_TOOL } from './bridge.js';
31
+ export { listenMcpSocket } from './service.js';
32
+ export { mcpSocketLocation, IPC_PROTOCOL_VERSION } from './ipc.js';
33
+ export { SUPPORTED_PROTOCOL_VERSIONS, SERVER_CAPABILITIES, negotiateProtocolVersion } from './protocol.js';
34
+ export { defineTool, textResult, errorResult } from './tool.js';
35
+ /**
36
+ * Service side: compose the MCP service for a registered project and open its socket (#243).
37
+ * Throws a one-line error when the socket cannot open; the cockpit turns that into one warning
38
+ * and keeps booting (N-07). Everything composed here is released by the handle's `close()`, and
39
+ * by the throw itself when the socket fails — nothing outlives either.
40
+ *
41
+ * The composition lives HERE, once, because the stdio bridge (`runMcpCommand`) executes nothing:
42
+ * it forwards every call to this socket, so both doors get exactly this behaviour.
43
+ */
44
+ export async function startMcpService(opts) {
45
+ const project = (await loadWorkspaceConfig()).projects.find((p) => p.id === opts.projectId);
46
+ if (!project)
47
+ throw new Error(`project ${opts.projectId} is not in the workspace registry`);
48
+ const providerBaseline = await opts.providerBaseline?.().catch(() => undefined);
49
+ const dataDir = opts.store?.dataDir ?? projectDataDir(project.root);
50
+ const warn = opts.warn ?? ((message) => console.warn(message));
51
+ const parts = composeDoor({
52
+ projectId: project.id,
53
+ dataDir,
54
+ store: opts.store,
55
+ workspaceEvents: opts.workspaceEvents,
56
+ providerBaseline,
57
+ env: opts.env ?? process.env,
58
+ warn,
59
+ });
60
+ // Built here rather than by the socket, because push delivery reads it too (#309). It writes
61
+ // nothing until a session opens.
62
+ const ownership = opts.ownership ?? new ProjectOwnership({ dataDir, projectId: project.id });
63
+ // Push delivery (#309): every owner session gets an event controller, on by default. It needs the
64
+ // journal; without one there is nothing to deliver, and that was already one warning above.
65
+ const delivery = parts.journal
66
+ ? new LeaderDelivery({
67
+ projectId: project.id,
68
+ projectRoot: project.root,
69
+ journal: parts.journal,
70
+ ownership,
71
+ guard: parts.guard,
72
+ // One acknowledgement (#332): the leader's pull record is what push resumes by, filters by and reports.
73
+ ...(parts.cursors ? { leaderRecord: parts.cursors } : {}),
74
+ warn,
75
+ ...(opts.leader?.heartbeatMs === undefined ? {} : { heartbeatMs: opts.leader.heartbeatMs }),
76
+ })
77
+ : undefined;
78
+ const unregisterLeader = delivery ? registerProjectLeader(project.id, delivery) : undefined;
79
+ // Controllers and any leader first, while the journal they read is still open.
80
+ const closeDelivery = () => {
81
+ unregisterLeader?.();
82
+ delivery?.close();
83
+ };
84
+ try {
85
+ const socket = await listenMcpSocket({
86
+ project: { id: project.id, name: projectName(project), root: project.root },
87
+ version: opts.version,
88
+ tools,
89
+ ...(opts.env ? { env: opts.env } : {}),
90
+ ...(opts.platform ? { platform: opts.platform } : {}),
91
+ context: {
92
+ ...(opts.service ? { service: opts.service } : {}),
93
+ ...(parts.leaderEvents ? { leaderEvents: parts.leaderEvents } : {}),
94
+ },
95
+ door: parts.door,
96
+ // The owner claims live beside the store the cockpit writes (D-02.8).
97
+ dataDir,
98
+ ownership,
99
+ ...(delivery ? { sessions: { opened: (key) => delivery.sessionOpened(key), closed: (key) => delivery.sessionClosed(key) } } : {}),
100
+ });
101
+ // D-04: written once the socket it names really listens, so the file never points at nothing.
102
+ // A failure is one warning and an MCP the client can still reach by the registry (N-07).
103
+ try {
104
+ writeMcpConnectionFile({ project: { id: project.id, root: project.root }, dataDir, socket: socket.path });
105
+ }
106
+ catch (err) {
107
+ warn(`[xez] MCP connection file not written (${err instanceof Error ? err.message : String(err)}) — MCP tools keep working without it`);
108
+ }
109
+ return {
110
+ path: socket.path,
111
+ close() {
112
+ // The socket first: no call may start while its parts are going away.
113
+ socket.close();
114
+ closeDelivery();
115
+ parts.close();
116
+ },
117
+ };
118
+ }
119
+ catch (err) {
120
+ closeDelivery();
121
+ // The socket never opened, so nothing else will dispose the owner slot it would have enforced.
122
+ if (!opts.ownership)
123
+ ownership.dispose();
124
+ parts.close();
125
+ throw err;
126
+ }
127
+ }
128
+ /**
129
+ * The parts that act on every MCP call, and the door that applies them. Each part is optional in
130
+ * the zero-config sense: one that cannot open is ONE warning and a smaller MCP, never a failed
131
+ * start — the tools keep working, exactly as they did before any part existed.
132
+ *
133
+ * - the project's event journal (#103), opened with this host's real secret list (F-15);
134
+ * - the E-01–E-06 catalog (#104), deriving rows from the SAME store and workspace bus the cockpit
135
+ * drives (N-02); every MCP mutation runs inside `withEventOrigin`, so a change it causes is
136
+ * the leader's, with the operation that caused it;
137
+ * - operation receipts (#101) for every call that carries an `operationId`;
138
+ * - the echo guard (#106): the operation is recorded as this leader's own BEFORE it runs;
139
+ * - the audit trail (#102), stamped `mcp` because this is the MCP door (D-06 § 10.4 rule 1).
140
+ *
141
+ * Read-only tools pass straight through: a read has no effect to deduplicate, attribute or audit.
142
+ *
143
+ * Two more parts face outward rather than wrapping a call:
144
+ * - the catalog is registered as the project's E-05 reporter (#252), so the cockpit's own config,
145
+ * workflow and agent-config write routes can report a human change to it;
146
+ * - the leader's persisted cursors (#105) and the `leader_events` port over them (#251), handed to
147
+ * the tools as context — the leader's pull read of its journal on reconnect.
148
+ */
149
+ function composeDoor(input) {
150
+ const { projectId, dataDir, store, workspaceEvents, providerBaseline, warn } = input;
151
+ const closers = [];
152
+ const attempt = (what, open) => {
153
+ try {
154
+ return open();
155
+ }
156
+ catch (err) {
157
+ warn(`[xez] MCP ${what} unavailable (${err instanceof Error ? err.message : String(err)}) — MCP tools keep working without it`);
158
+ return undefined;
159
+ }
160
+ };
161
+ const secretValues = collectSecretValues(input.env);
162
+ const journal = attempt('event journal', () => EventJournal.open({ dataDir, projectId, secretValues, warn }));
163
+ if (journal)
164
+ closers.push(() => journal.close());
165
+ // Pushed after the journal, so it detaches first: no row can reach a closed journal.
166
+ const catalog = journal && store
167
+ ? attempt('event catalog', () => EventCatalog.attach({
168
+ journal,
169
+ store,
170
+ ...(workspaceEvents ? { workspaceEvents } : {}),
171
+ ...(providerBaseline ? { providerBaseline } : {}),
172
+ warn,
173
+ }))
174
+ : undefined;
175
+ if (catalog) {
176
+ closers.push(() => catalog.detach());
177
+ // Pushed after the catalog, so the routes stop reaching it before it detaches.
178
+ closers.push(registerProjectCatalog(projectId, catalog));
179
+ }
180
+ const cursors = journal && store ? attempt('leader cursors', () => LeaderCursors.open({ dataDir, projectId, journal, warn })) : undefined;
181
+ const leaderEvents = journal && store && cursors ? { journal, cursors, readState: runStateReader(store, journal), secretValues } : undefined;
182
+ const receipts = attempt('operation receipts', () => OperationReceiptStore.open(dataDir, {
183
+ ...(store
184
+ ? {
185
+ reconcilers: { 'run-by-key': runByKeyReconciler(store) },
186
+ isResultLive: (ref) => ref.kind === 'run' && store.getRun(ref.id) !== undefined,
187
+ }
188
+ : {}),
189
+ }));
190
+ if (receipts) {
191
+ // Background, never awaited (D-06 § 9.3 rule 1): until it settles a receipt reads `unverified`.
192
+ void receipts.reconcilePending().catch(() => undefined);
193
+ closers.push(() => receipts.close());
194
+ }
195
+ const guard = attempt('echo guard', () => new EchoGuard({ projectId }));
196
+ const audit = attempt('audit trail', () => new AuditTrail({ projectId, dataDir }, { warn }).channel('mcp'));
197
+ const door = async ({ tool, args }, invoke) => {
198
+ if (tool.annotations?.readOnlyHint === true)
199
+ return invoke();
200
+ const operationId = operationIdOf(args);
201
+ const action = actionId(tool.name, args.action);
202
+ const target = targetOf(args);
203
+ // The origin is the door's, never the client's (D-05 § 6.3): every mutation through here is the
204
+ // leader's. Since #264 every MUTATING action of every tool carries a client `operationId`
205
+ // (D-06 § 5.2), so the mint below is what covers the read actions a mutating tool also has
206
+ // (`organise_work list_queue`, `handoff_git repo`, `leader_events read`, the `project_config`
207
+ // reads and refusals): they still need an origin for the catalog and the echo guard, and they
208
+ // deliberately reach no receipt, because only a client key may create one.
209
+ const causedBy = operationId ?? `mcp-door.${randomUUID()}`;
210
+ const marked = () => withEventOrigin({ origin: 'leader', causedBy, ...(target ? { runId: target.id } : {}) }, invoke);
211
+ const issued = guard ? () => guard.issue(causedBy, marked) : marked;
212
+ const op = {
213
+ action,
214
+ payload: args,
215
+ ...(operationId === undefined ? {} : { operationId }),
216
+ ...(target ? { resource: target } : {}),
217
+ // The version the leader's decision was based on (#250); the trail keeps it only in `rev1` shape.
218
+ ...(typeof args.expectedVersion === 'string' ? { expectedVersion: args.expectedVersion } : {}),
219
+ };
220
+ let result;
221
+ try {
222
+ result =
223
+ operationId !== undefined && receipts
224
+ ? await idempotent(receipts, { projectId, operationId, action, args, toolName: tool.name, issued, warn })
225
+ : await issued();
226
+ }
227
+ catch (err) {
228
+ audit?.record(op, { outcome: 'unverified', errorCode: 'effect_failed' });
229
+ throw err;
230
+ }
231
+ // An error result may come from a refusal or from a failure after the effect started; the door
232
+ // cannot tell which, so it never claims `rejected` (nothing happened) on the tool's behalf. The
233
+ // one exception is the stale-version rejection (#250): the ROUTE refused it before any effect
234
+ // and says so (`applied: false`), so recording it as `ok` would put a write that never happened
235
+ // into the trail (D-06 § 4.4 rule 6).
236
+ const resource = resourceOf(result);
237
+ const stale = staleRejectionOf(result);
238
+ audit?.record(op, stale
239
+ ? { outcome: 'rejected', errorCode: 'stale_version', resource: stale.resource }
240
+ : result.isError
241
+ ? { outcome: 'unverified', errorCode: 'tool_error' }
242
+ : { outcome: 'ok', ...(resource ? { resource } : {}) });
243
+ return result;
244
+ };
245
+ let closed = false;
246
+ return {
247
+ door,
248
+ leaderEvents,
249
+ journal,
250
+ guard,
251
+ cursors,
252
+ close() {
253
+ if (closed)
254
+ return;
255
+ closed = true;
256
+ for (const close of closers.splice(0).reverse()) {
257
+ try {
258
+ close();
259
+ }
260
+ catch (err) {
261
+ warn(`[xez] MCP shutdown step failed: ${err instanceof Error ? err.message : String(err)}`);
262
+ }
263
+ }
264
+ },
265
+ };
266
+ }
267
+ /**
268
+ * Run one call under its operation key (D-06 § 6). The call that runs the tool answers with the
269
+ * tool's own result, unchanged; every other answer — a replay, a duplicate still in flight, an
270
+ * unverified crash leftover, a key reused for different work — is the receipt layer's own shape.
271
+ */
272
+ async function idempotent(receipts, call) {
273
+ let fresh;
274
+ const answer = await receipts.execute({
275
+ projectId: call.projectId,
276
+ operationId: call.operationId,
277
+ action: call.action,
278
+ payload: call.args,
279
+ reconcile: { kind: 'none' },
280
+ effect: async () => {
281
+ try {
282
+ fresh = await call.issued();
283
+ }
284
+ catch (err) {
285
+ // The receipt layer answers `unverified` and swallows the throw, so the log line the
286
+ // service would have written for it is written here (the text never reaches the client).
287
+ call.warn(`[xez] MCP tool ${call.toolName} failed: ${err instanceof Error ? err.message : String(err)}`);
288
+ throw err;
289
+ }
290
+ if (fresh.isError)
291
+ return { outcome: 'rejected', errorCode: 'tool refused' };
292
+ const ref = resourceOf(fresh);
293
+ return { outcome: 'ok', resultRef: ref ? { kind: ref.kind, id: ref.id } : { kind: 'operation', id: call.operationId } };
294
+ },
295
+ });
296
+ if (fresh !== undefined)
297
+ return fresh;
298
+ return answerResult(answer);
299
+ }
300
+ function answerResult(answer) {
301
+ const body = answer;
302
+ const refused = 'error' in answer || answer.status === 'rejected';
303
+ return refused ? errorResult(JSON.stringify(body), body) : textResult(JSON.stringify(body), body);
304
+ }
305
+ function operationIdOf(args) {
306
+ const parsed = operationIdSchema.safeParse(args.operationId);
307
+ return parsed.success ? parsed.data : undefined;
308
+ }
309
+ /** `task_create` + `start_from_inbox` → `taskCreate.startFromInbox`: the audit's dotted action id. */
310
+ function actionId(toolName, action) {
311
+ const camel = (name) => name.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
312
+ return `${camel(toolName)}.${typeof action === 'string' ? camel(action) : 'call'}`;
313
+ }
314
+ /** The task a call names, when it names one — the tools spell it `runId` or `taskId`. */
315
+ function targetOf(args) {
316
+ const id = typeof args.runId === 'string' ? args.runId : typeof args.taskId === 'string' ? args.taskId : undefined;
317
+ return id === undefined ? undefined : { kind: 'run', id };
318
+ }
319
+ /** The stale-version rejection a tool relayed, if that is what its (non-error) answer is. */
320
+ function staleRejectionOf(result) {
321
+ if (result.isError)
322
+ return undefined;
323
+ const block = result.content[0];
324
+ if (!block || block.type !== 'text')
325
+ return undefined;
326
+ try {
327
+ return staleRejectionIn(JSON.parse(block.text));
328
+ }
329
+ catch {
330
+ return undefined;
331
+ }
332
+ }
333
+ /** The resource a result names: a tool's `subject`, or a receipt's `resultRef`. */
334
+ function resourceOf(result) {
335
+ const content = result.structuredContent;
336
+ const subject = content?.subject;
337
+ if (typeof subject?.type === 'string' && typeof subject.id === 'string')
338
+ return { kind: subject.type, id: subject.id };
339
+ const ref = content?.resultRef;
340
+ if (typeof ref?.kind === 'string' && typeof ref.id === 'string')
341
+ return { kind: ref.kind, id: ref.id };
342
+ return undefined;
343
+ }
344
+ /**
345
+ * `xez mcp` — spawned by an MCP client with the session's project as its working
346
+ * directory (D-01 § 4). Serves MCP on stdio until the client closes stdin.
347
+ */
348
+ export async function runMcpCommand(opts) {
349
+ // stdout carries JSON-RPC and nothing else: one stray log line from any module
350
+ // would corrupt the client's stream. Diagnostics go to stderr, which clients log.
351
+ const toStderr = (...args) => console.error(...args);
352
+ console.log = toStderr;
353
+ console.info = toStderr;
354
+ console.debug = toStderr;
355
+ await runBridge({
356
+ input: process.stdin,
357
+ output: process.stdout,
358
+ version: opts.version,
359
+ tools,
360
+ resolveTarget: () => resolveMcpTarget(opts.repoRoot),
361
+ });
362
+ }
363
+ /**
364
+ * The cwd only FINDS the socket; it never becomes the authority (D-01 § 4). A read of
365
+ * the registry: the bridge registers nothing, so a directory xezar has never served
366
+ * finds no project and answers with how to fix that.
367
+ */
368
+ export async function resolveMcpTarget(repoRoot) {
369
+ const root = await realpath(repoRoot).catch(() => resolve(repoRoot));
370
+ const project = (await loadWorkspaceConfig()).projects.find((p) => p.root === root);
371
+ if (!project) {
372
+ return {
373
+ kind: 'unavailable',
374
+ status: 'not-registered',
375
+ message: 'This directory is not a xezar project yet. Start the cockpit here once with `xez` (or `npx @qodeca/xezar`) so it is registered, then call this tool again.',
376
+ };
377
+ }
378
+ const location = mcpSocketLocation(project);
379
+ if (location.kind === 'unavailable')
380
+ return { kind: 'unavailable', status: 'unsupported', message: location.reason };
381
+ return { kind: 'socket', path: location.path, project: { id: project.id, name: projectName(project) } };
382
+ }
383
+ function projectName(project) {
384
+ return project.name || basename(project.root);
385
+ }
386
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,iBAAiB,GAKlB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAqB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAsB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAA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,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;AAC1G,CAAC;AAED,SAAS,WAAW,CAAC,OAAuC;IAC1D,OAAO,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,202 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The IPC leg between `xez mcp` (the bridge) and the running xezar service — D-01
4
+ * (docs/features/mcp-server/mcp-d01-transport-decision.md) § 1.2–1.5.
5
+ *
6
+ * One Unix domain socket per registered project, owned by the service, at
7
+ * `<xezarHomeDir()>/ipc/<projectId>.sock` (dir 0700, socket 0600). Frames are
8
+ * newline-delimited JSON, the same framing as the stdio leg. The socket IS the
9
+ * project binding (§ 1.5): no frame carries a project field, and the service answers
10
+ * only for the project it opened the socket for.
11
+ *
12
+ * Both sides import this file, so the path rule and the frame shapes cannot drift.
13
+ * They may still come from different installed versions (`npx` vs a global
14
+ * install), which is what `IPC_PROTOCOL_VERSION` is for.
15
+ */
16
+ /**
17
+ * Bumped only when a frame shape changes incompatibly. Carried on every request.
18
+ *
19
+ * 2 (#302): a connection is a SESSION. The bridge keeps one connection for its whole life, opens
20
+ * the session on it with `session/open` (which acquires the project's owner slot, D-02), and every
21
+ * `health` / `tools/call` needs that live session. A version-1 bridge — one connection per call,
22
+ * no session — would be refused on every call anyway; the version check refuses it legibly first.
23
+ */
24
+ export declare const IPC_PROTOCOL_VERSION = 2;
25
+ /**
26
+ * Largest frame either leg accepts, in bytes: 32 MiB + 64 KiB. Taken from D-09 B-08
27
+ * (qodeca/xezar#206, not yet merged at the time of writing) so the bridge does not
28
+ * invent a second number. A larger frame is refused with an explicit error and
29
+ * closes nothing else.
30
+ */
31
+ export declare const MAX_FRAME_BYTES = 33619968;
32
+ /**
33
+ * How long the bridge waits for the service to answer one request — D-09 B-09
34
+ * (qodeca/xezar#206): 55 s. On expiry the bridge answers with a readable result;
35
+ * the service operation is not cancelled. There is no retry (D-01 § 5, D-09 B-16).
36
+ */
37
+ export declare const IPC_REQUEST_TIMEOUT_MS = 55000;
38
+ /**
39
+ * How long the bridge waits to connect and open its session. Acquisition itself is bounded far
40
+ * below this (D-02.2: 5 attempts, at most 375 ms of backoff), so only a hung service reaches it.
41
+ * It is short because `initialize` waits on it, and a client gives up on a server whose handshake
42
+ * is slow — Codex's documented default startup timeout is 10 s (not re-measured here). On expiry
43
+ * the handshake still succeeds with no session (N-07) and the next call tries again.
44
+ */
45
+ export declare const IPC_SESSION_OPEN_TIMEOUT_MS = 5000;
46
+ export type McpSocketLocation = {
47
+ readonly kind: 'socket';
48
+ readonly path: string;
49
+ } | {
50
+ readonly kind: 'unavailable';
51
+ readonly reason: string;
52
+ };
53
+ /**
54
+ * Where the service listens for `projectId`, and where the bridge connects. Pure:
55
+ * both sides compute it from the same registry entry, so they always agree.
56
+ *
57
+ * D-01 § 1.4: when `<home>/ipc/<projectId>.sock` is longer than the OS allows, the
58
+ * first 12 hex characters of SHA-256(project root) replace the id. When even that
59
+ * is too long (a very long `XEZ_HOME`), there is no socket — the caller degrades.
60
+ * Windows named pipes are untested and their naming is undecided (D-01 § 10.2), so
61
+ * Windows is reported as unavailable rather than guessed.
62
+ */
63
+ export declare function mcpSocketLocation(project: {
64
+ readonly id: string;
65
+ readonly root: string;
66
+ }, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): McpSocketLocation;
67
+ /** `<xezarHomeDir()>/ipc` — the only directory the service creates for MCP. */
68
+ export declare function mcpSocketDir(env?: NodeJS.ProcessEnv): string;
69
+ /** A tool result exactly as MCP carries it: the text block is authoritative. */
70
+ export declare const toolResultSchema: z.ZodObject<{
71
+ content: z.ZodArray<z.ZodObject<{
72
+ type: z.ZodLiteral<"text">;
73
+ text: z.ZodString;
74
+ }, z.core.$strip>>;
75
+ structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
76
+ isError: z.ZodOptional<z.ZodBoolean>;
77
+ }, z.core.$strip>;
78
+ export type McpToolResult = z.infer<typeof toolResultSchema>;
79
+ /** What `health` answers. No account identity and no path — F-12, N-01, F-15. */
80
+ export declare const healthResultSchema: z.ZodObject<{
81
+ ipcVersion: z.ZodNumber;
82
+ xezarVersion: z.ZodString;
83
+ project: z.ZodObject<{
84
+ id: z.ZodString;
85
+ name: z.ZodString;
86
+ }, z.core.$strip>;
87
+ }, z.core.$strip>;
88
+ export type HealthResult = z.infer<typeof healthResultSchema>;
89
+ export declare const toolCallParamsSchema: z.ZodObject<{
90
+ name: z.ZodString;
91
+ arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
92
+ }, z.core.$strip>;
93
+ /**
94
+ * Bridge → service. `v` is checked BEFORE the method is looked at, so a service
95
+ * can refuse a bridge from another protocol version legibly. `bridgeVersion` is the
96
+ * bridge's xezar version, for diagnostics only.
97
+ */
98
+ export declare const ipcRequestSchema: z.ZodObject<{
99
+ v: z.ZodNumber;
100
+ id: z.ZodNumber;
101
+ bridgeVersion: z.ZodOptional<z.ZodString>;
102
+ method: z.ZodString;
103
+ params: z.ZodOptional<z.ZodUnknown>;
104
+ }, z.core.$strip>;
105
+ export type IpcRequest = z.infer<typeof ipcRequestSchema>;
106
+ export declare const ipcErrorCodeSchema: z.ZodEnum<{
107
+ "bad-frame": "bad-frame";
108
+ internal: "internal";
109
+ "invalid-params": "invalid-params";
110
+ "project-occupied": "project-occupied";
111
+ "session-expired": "session-expired";
112
+ "unknown-method": "unknown-method";
113
+ "unknown-tool": "unknown-tool";
114
+ "version-mismatch": "version-mismatch";
115
+ }>;
116
+ /**
117
+ * The JSON-RPC error the bridge hands the client verbatim for the two ownership refusals. The
118
+ * contract's schemas are `.strict()`, so nothing about the competing owner can ride along (N-01).
119
+ */
120
+ export declare const ownershipRpcErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
121
+ code: z.ZodLiteral<-32080>;
122
+ message: z.ZodString;
123
+ data: z.ZodObject<{
124
+ reason: z.ZodLiteral<"com.qodeca.xezar/project-occupied">;
125
+ projectId: z.ZodString;
126
+ retryable: z.ZodLiteral<true>;
127
+ }, z.core.$strict>;
128
+ }, z.core.$strict>, z.ZodObject<{
129
+ code: z.ZodLiteral<-32081>;
130
+ message: z.ZodString;
131
+ data: z.ZodObject<{
132
+ reason: z.ZodLiteral<"com.qodeca.xezar/session-expired">;
133
+ projectId: z.ZodString;
134
+ retryable: z.ZodLiteral<true>;
135
+ }, z.core.$strict>;
136
+ }, z.core.$strict>]>;
137
+ /** What `session/open` answers: this connection's session now owns the project. */
138
+ export declare const sessionOpenResultSchema: z.ZodObject<{
139
+ owner: z.ZodLiteral<true>;
140
+ }, z.core.$strip>;
141
+ /** Service → bridge. */
142
+ export declare const ipcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
143
+ v: z.ZodNumber;
144
+ id: z.ZodNullable<z.ZodNumber>;
145
+ ok: z.ZodLiteral<true>;
146
+ result: z.ZodUnknown;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ v: z.ZodNumber;
149
+ id: z.ZodNullable<z.ZodNumber>;
150
+ ok: z.ZodLiteral<false>;
151
+ error: z.ZodObject<{
152
+ code: z.ZodEnum<{
153
+ "bad-frame": "bad-frame";
154
+ internal: "internal";
155
+ "invalid-params": "invalid-params";
156
+ "project-occupied": "project-occupied";
157
+ "session-expired": "session-expired";
158
+ "unknown-method": "unknown-method";
159
+ "unknown-tool": "unknown-tool";
160
+ "version-mismatch": "version-mismatch";
161
+ }>;
162
+ message: z.ZodString;
163
+ }, z.core.$strip>;
164
+ serviceVersion: z.ZodOptional<z.ZodString>;
165
+ rpcError: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
166
+ code: z.ZodLiteral<-32080>;
167
+ message: z.ZodString;
168
+ data: z.ZodObject<{
169
+ reason: z.ZodLiteral<"com.qodeca.xezar/project-occupied">;
170
+ projectId: z.ZodString;
171
+ retryable: z.ZodLiteral<true>;
172
+ }, z.core.$strict>;
173
+ }, z.core.$strict>, z.ZodObject<{
174
+ code: z.ZodLiteral<-32081>;
175
+ message: z.ZodString;
176
+ data: z.ZodObject<{
177
+ reason: z.ZodLiteral<"com.qodeca.xezar/session-expired">;
178
+ projectId: z.ZodString;
179
+ retryable: z.ZodLiteral<true>;
180
+ }, z.core.$strict>;
181
+ }, z.core.$strict>]>>;
182
+ }, z.core.$strip>], "ok">;
183
+ export type IpcResponse = z.infer<typeof ipcResponseSchema>;
184
+ /**
185
+ * Split a byte stream into newline-delimited frames. A frame over `maxBytes` is
186
+ * reported once through `onOversize` and skipped up to its newline; the stream
187
+ * keeps working (D-09 B-08: "closes nothing else").
188
+ */
189
+ export declare class LineFramer {
190
+ private readonly onFrame;
191
+ private readonly onOversize;
192
+ private readonly maxBytes;
193
+ private chunks;
194
+ private size;
195
+ private discarding;
196
+ constructor(onFrame: (line: string) => void, onOversize: () => void, maxBytes?: number);
197
+ push(chunk: Buffer): void;
198
+ private append;
199
+ private flushFrame;
200
+ }
201
+ /** One frame on the wire. `JSON.stringify` never emits a raw newline. */
202
+ export declare function encodeFrame(value: unknown): string;