@qodeca/xezar 0.13.0 → 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 +72 -39
  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 +25 -2
  160. package/dist/runs/retention.js +63 -2
  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 +599 -79
  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-CdS8r8E2.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-BYlnf4qf.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-C2On8SlI.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-6aopqAmV.js → task-changes-CH-E81-_.js} +1 -1
  226. package/web/dist/assets/{task-commits-u-dwaCyw.js → task-commits-DqfkMFxp.js} +1 -1
  227. package/web/dist/assets/{task-files-IMOZnIUK.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-fLDKEJoB.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-BY3KTkFw.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-CqGK62Lw.js +0 -1
  244. package/web/dist/assets/index-3nxVmdn5.css +0 -2
  245. package/web/dist/assets/index-qX7n11FX.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-Bj-uG_Hz.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,200 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Durable operation identity for MCP mutations (issue #101, decision D-06 —
4
+ * `docs/features/mcp-server/mcp-d06-versioning-idempotency-audit-decision.md`).
5
+ *
6
+ * Every mutating MCP tool takes a client-generated `operationId`. The server keys a receipt on
7
+ * `<projectId>/<operationId>` — the project half comes from the trusted connection binding, never
8
+ * from a tool argument — and verifies the stored `action` and payload digest on every retry. The
9
+ * JSON-RPC request id is deliberately NOT this identity: it correlates one request with one
10
+ * response and does not survive a reconnect (D-06 § 5.1).
11
+ *
12
+ * These are wire shapes only. How a receipt is stored lives in the service
13
+ * (`packages/xezar/src/mcp/operation-receipts.ts`); nothing here is persisted as-is.
14
+ */
15
+ /**
16
+ * The operation id a client supplies (D-06 § 5.2). Opaque: a UUIDv4 is the expected shape, but the
17
+ * server neither requires nor parses one. 8–128 characters from a closed alphabet — the bounds are
18
+ * shape bounds only (a technical proposal in D-06 § 1.1), and the alphabet keeps `/` out so the
19
+ * stored `<projectId>/<operationId>` key splits unambiguously.
20
+ */
21
+ export declare const operationIdSchema: z.ZodString;
22
+ export type OperationId = z.infer<typeof operationIdSchema>;
23
+ /**
24
+ * A stored, settled outcome (D-06 § 9.2). `in-progress` is deliberately absent: it is derived from
25
+ * liveness at lookup time and is never written down.
26
+ *
27
+ * - `ok` — the effect happened and the result is recorded.
28
+ * - `rejected` — refused before any effect (validation, `stale_version`, permission).
29
+ * - `not-applied` — reconciliation ESTABLISHED that the effect did not happen.
30
+ * - `unverified` — the effect may have happened; nothing has established which. Never retried.
31
+ */
32
+ export declare const operationOutcomeSchema: z.ZodEnum<{
33
+ "not-applied": "not-applied";
34
+ ok: "ok";
35
+ rejected: "rejected";
36
+ unverified: "unverified";
37
+ }>;
38
+ export type OperationOutcome = z.infer<typeof operationOutcomeSchema>;
39
+ /** What a settled `ok` operation produced — a reference, never content (D-06 § 7.1, § 10.3). */
40
+ export declare const operationResultRefSchema: z.ZodObject<{
41
+ kind: z.ZodString;
42
+ id: z.ZodString;
43
+ }, z.core.$strip>;
44
+ export type OperationResultRef = z.infer<typeof operationResultRefSchema>;
45
+ /**
46
+ * A short machine-readable reason or error code. Never a raw error body: output from `gh` or `git`
47
+ * can carry a token or a path (D-06 § 9.3, § 10.3), so the alphabet admits no `/`, `=` or quote
48
+ * and the length is capped.
49
+ */
50
+ export declare const operationReasonSchema: z.ZodString;
51
+ export type OperationReason = z.infer<typeof operationReasonSchema>;
52
+ /**
53
+ * The read a reconciler performs to answer "did this effect happen?" (D-06 § 9.3). Recorded in the
54
+ * `intent` line BEFORE the effect, because after a crash nothing else can rebuild it.
55
+ */
56
+ export declare const reconcilePredicateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
57
+ kind: z.ZodLiteral<"run-by-key">;
58
+ predictedRunId: z.ZodUUID;
59
+ }, z.core.$strip>, z.ZodObject<{
60
+ kind: z.ZodLiteral<"forge-search">;
61
+ repository: z.ZodString;
62
+ headBranch: z.ZodString;
63
+ }, z.core.$strip>, z.ZodObject<{
64
+ kind: z.ZodLiteral<"git-state">;
65
+ ref: z.ZodString;
66
+ sha: z.ZodString;
67
+ }, z.core.$strip>, z.ZodObject<{
68
+ kind: z.ZodLiteral<"none">;
69
+ }, z.core.$strip>], "kind">;
70
+ export type ReconcilePredicate = z.infer<typeof reconcilePredicateSchema>;
71
+ export type ReconcileKind = ReconcilePredicate['kind'];
72
+ /** Guidance a client gets with every `unverified` answer (D-06 § 9.3 rule 5). */
73
+ export declare const UNVERIFIED_GUIDANCE: 'read current state; a new operationId is a new action';
74
+ /** A settled operation — a first attempt that finished, or a retry replaying the stored outcome. */
75
+ export declare const operationSettledResultSchema: z.ZodObject<{
76
+ status: z.ZodEnum<{
77
+ "not-applied": "not-applied";
78
+ ok: "ok";
79
+ rejected: "rejected";
80
+ }>;
81
+ operationId: z.ZodString;
82
+ action: z.ZodString;
83
+ replayed: z.ZodBoolean;
84
+ resultRef: z.ZodOptional<z.ZodObject<{
85
+ kind: z.ZodString;
86
+ id: z.ZodString;
87
+ }, z.core.$strip>>;
88
+ errorCode: z.ZodOptional<z.ZodString>;
89
+ }, z.core.$strip>;
90
+ export type OperationSettledResult = z.infer<typeof operationSettledResultSchema>;
91
+ /**
92
+ * A duplicate that arrived while the first attempt is still live in this process (D-06 § 6). Not
93
+ * uncertain: the server knows the operation is running and will settle it.
94
+ */
95
+ export declare const operationInProgressResultSchema: z.ZodObject<{
96
+ status: z.ZodLiteral<"in-progress">;
97
+ operationId: z.ZodString;
98
+ action: z.ZodString;
99
+ startedAt: z.ZodString;
100
+ }, z.core.$strip>;
101
+ export type OperationInProgressResult = z.infer<typeof operationInProgressResultSchema>;
102
+ /**
103
+ * The effect may have happened and nothing has established which (D-06 § 9.3). No effect ran for
104
+ * this call, and none will run for any retry of the same `operationId`.
105
+ */
106
+ export declare const operationUnverifiedResultSchema: z.ZodObject<{
107
+ status: z.ZodLiteral<"unverified">;
108
+ operationId: z.ZodString;
109
+ action: z.ZodString;
110
+ startedAt: z.ZodString;
111
+ reconcile: z.ZodObject<{
112
+ kind: z.ZodEnum<{
113
+ "forge-search": "forge-search";
114
+ "git-state": "git-state";
115
+ none: "none";
116
+ "run-by-key": "run-by-key";
117
+ }>;
118
+ attemptedAt: z.ZodOptional<z.ZodString>;
119
+ reason: z.ZodString;
120
+ }, z.core.$strip>;
121
+ guidance: z.ZodLiteral<"read current state; a new operationId is a new action">;
122
+ }, z.core.$strip>;
123
+ export type OperationUnverifiedResult = z.infer<typeof operationUnverifiedResultSchema>;
124
+ /**
125
+ * The same `operationId` arrived with a different action or payload (D-06 § 6). No effect ran, and
126
+ * the stored operation's result is deliberately NOT returned — handing back another intention's
127
+ * result would be wrong and a small information leak. `mismatch` says which half disagreed.
128
+ */
129
+ export declare const operationKeyConflictSchema: z.ZodObject<{
130
+ error: z.ZodLiteral<"operation_key_conflict">;
131
+ operationId: z.ZodString;
132
+ storedAction: z.ZodString;
133
+ storedAt: z.ZodString;
134
+ mismatch: z.ZodEnum<{
135
+ action: "action";
136
+ payload: "payload";
137
+ }>;
138
+ }, z.core.$strip>;
139
+ export type OperationKeyConflict = z.infer<typeof operationKeyConflictSchema>;
140
+ /**
141
+ * The receipt journal cannot be written (read-only repository, full disk), so the operation cannot
142
+ * be made idempotent and is refused BEFORE its effect (D-06 § 7.5).
143
+ */
144
+ export declare const operationReceiptUnavailableSchema: z.ZodObject<{
145
+ error: z.ZodLiteral<"operation_receipt_unavailable">;
146
+ operationId: z.ZodString;
147
+ reason: z.ZodLiteral<"journal_unwritable">;
148
+ }, z.core.$strip>;
149
+ export type OperationReceiptUnavailable = z.infer<typeof operationReceiptUnavailableSchema>;
150
+ /** Every answer the operation-receipt layer gives a mutating MCP tool. */
151
+ export declare const operationAnswerSchema: z.ZodUnion<readonly [z.ZodObject<{
152
+ status: z.ZodEnum<{
153
+ "not-applied": "not-applied";
154
+ ok: "ok";
155
+ rejected: "rejected";
156
+ }>;
157
+ operationId: z.ZodString;
158
+ action: z.ZodString;
159
+ replayed: z.ZodBoolean;
160
+ resultRef: z.ZodOptional<z.ZodObject<{
161
+ kind: z.ZodString;
162
+ id: z.ZodString;
163
+ }, z.core.$strip>>;
164
+ errorCode: z.ZodOptional<z.ZodString>;
165
+ }, z.core.$strip>, z.ZodObject<{
166
+ status: z.ZodLiteral<"in-progress">;
167
+ operationId: z.ZodString;
168
+ action: z.ZodString;
169
+ startedAt: z.ZodString;
170
+ }, z.core.$strip>, z.ZodObject<{
171
+ status: z.ZodLiteral<"unverified">;
172
+ operationId: z.ZodString;
173
+ action: z.ZodString;
174
+ startedAt: z.ZodString;
175
+ reconcile: z.ZodObject<{
176
+ kind: z.ZodEnum<{
177
+ "forge-search": "forge-search";
178
+ "git-state": "git-state";
179
+ none: "none";
180
+ "run-by-key": "run-by-key";
181
+ }>;
182
+ attemptedAt: z.ZodOptional<z.ZodString>;
183
+ reason: z.ZodString;
184
+ }, z.core.$strip>;
185
+ guidance: z.ZodLiteral<"read current state; a new operationId is a new action">;
186
+ }, z.core.$strip>, z.ZodObject<{
187
+ error: z.ZodLiteral<"operation_key_conflict">;
188
+ operationId: z.ZodString;
189
+ storedAction: z.ZodString;
190
+ storedAt: z.ZodString;
191
+ mismatch: z.ZodEnum<{
192
+ action: "action";
193
+ payload: "payload";
194
+ }>;
195
+ }, z.core.$strip>, z.ZodObject<{
196
+ error: z.ZodLiteral<"operation_receipt_unavailable">;
197
+ operationId: z.ZodString;
198
+ reason: z.ZodLiteral<"journal_unwritable">;
199
+ }, z.core.$strip>]>;
200
+ export type OperationAnswer = z.infer<typeof operationAnswerSchema>;
@@ -0,0 +1,268 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The per-project MCP event journal (#103) — the wire half. The writer, the retention and the
4
+ * cursor arithmetic live in `packages/xezar/src/mcp/event-journal.ts`.
5
+ *
6
+ * Every shape here was decided elsewhere, and each comment names where:
7
+ * - D-05 (`docs/features/mcp-server/mcp-d05-async-event-contract-decision.md`) § 6.1–6.3 fixes
8
+ * the row envelope, the per-project gapless `journalSeq`, and `eventId = "<projectId>:<seq>"`;
9
+ * § 6.5 fixes the opaque cursor, replay strictly after it, the rejected malformed cursor and the
10
+ * explicit `cursor_too_old` answer.
11
+ * - D-09 (`mcp-d09-limits-retention-packaging-decision.md`) § 3 fixes every number: B-01 (page
12
+ * bytes), B-02/B-20 (page rows), B-04 (cursor bytes), B-19 (retention).
13
+ *
14
+ * This is NOT the per-run transcript: `runEventSchema` (`events.ts`) is one run's NDJSON, ordered by
15
+ * a per-run `seq` that is allowed gaps. A journal row is ordered by the PROJECT's `journalSeq`,
16
+ * which never has one, and it carries a summary — never a payload (D-05 § 6.3).
17
+ */
18
+ /** B-19: the newest rows a project keeps, whatever their age. */
19
+ export declare const MCP_JOURNAL_RETAINED_ROWS = 10000;
20
+ /** B-19: a row younger than this is never evicted, however many rows there are. */
21
+ export declare const MCP_JOURNAL_MIN_RETENTION_DAYS = 14;
22
+ /** B-02 / B-20: rows per replay page — the transcript page size, reused, not a second one. */
23
+ export declare const MCP_JOURNAL_PAGE_ROWS = 100;
24
+ /** B-01: serialized UTF-8 bytes of the rows on one page. Whichever of this and the row count is
25
+ * reached first ends the page; a page always carries at least one row when one is outstanding. */
26
+ export declare const MCP_JOURNAL_PAGE_BYTES = 40000;
27
+ /** B-04: the size ceiling of every MCP cursor, the same as the transcript history cursor. */
28
+ export declare const MCP_JOURNAL_CURSOR_MAX_BYTES = 2048;
29
+ /**
30
+ * Shape bound on `summary`, not a behavioural limit: it keeps the largest possible row far inside
31
+ * one B-01 page, so a single row can never need B-03's chunking. D-05 measured the whole envelope
32
+ * at 399 bytes; a summary is one line of prose, never a transcript, diff or file content.
33
+ */
34
+ export declare const MCP_JOURNAL_SUMMARY_MAX_CHARS = 500;
35
+ /** The agreed significant-event catalog (requirements § 6). Closed: D-05 § 6.3. */
36
+ export declare const mcpJournalCategorySchema: z.ZodEnum<{
37
+ "E-01": "E-01";
38
+ "E-02": "E-02";
39
+ "E-03": "E-03";
40
+ "E-04": "E-04";
41
+ "E-05": "E-05";
42
+ "E-06": "E-06";
43
+ }>;
44
+ export type McpJournalCategory = z.infer<typeof mcpJournalCategorySchema>;
45
+ /**
46
+ * Who caused the row (D-05 § 6.3). Server-derived, never taken from a tool argument. Together with
47
+ * `causedBy` this is the F-13 echo-loop guard: an adapter drops a row whose `origin` is `leader` AND
48
+ * whose `causedBy` is its own outstanding operation — never merely because it recognises the run.
49
+ */
50
+ export declare const mcpJournalOriginSchema: z.ZodEnum<{
51
+ human: "human";
52
+ leader: "leader";
53
+ system: "system";
54
+ }>;
55
+ export type McpJournalOrigin = z.infer<typeof mcpJournalOriginSchema>;
56
+ /** A leader operation id, as D-06 § 5.2 shapes every `operationId`. Opaque; never parsed. */
57
+ export declare const mcpJournalOperationIdSchema: z.ZodString;
58
+ /** The registry slug (`PROJECT_ID_RE` in `packages/xezar/src/workspace/config.ts`). */
59
+ export declare const mcpJournalProjectIdSchema: z.ZodString;
60
+ /**
61
+ * The affected resource. `version` is the D-06 token of the resource as it was when the row was
62
+ * written, carried through replay unchanged (D-05 § 6.3). It is always PRESENT: `null` is the
63
+ * explicit "this subject has no version" (an executor, say), never a missing key.
64
+ */
65
+ export declare const mcpJournalSubjectSchema: z.ZodObject<{
66
+ type: z.ZodString;
67
+ id: z.ZodString;
68
+ version: z.ZodNullable<z.ZodString>;
69
+ }, z.core.$strip>;
70
+ export type McpJournalSubject = z.infer<typeof mcpJournalSubjectSchema>;
71
+ /** Provenance back to one run transcript line. Never identity, never order (D-05 § 6.1). */
72
+ export declare const mcpJournalSourceSchema: z.ZodObject<{
73
+ runId: z.ZodString;
74
+ runSeq: z.ZodNumber;
75
+ }, z.core.$strip>;
76
+ /** `kind` is the finer machine label under a category; open for additive growth (D-05 § 6.3). */
77
+ export declare const mcpJournalKindSchema: z.ZodString;
78
+ /**
79
+ * What an emitter hands the journal. The journal assigns `journalSeq`, `ts`, `projectId` and
80
+ * `eventId` itself — a caller cannot choose its own position or its own project.
81
+ */
82
+ export declare const mcpJournalAppendInputSchema: z.ZodObject<{
83
+ category: z.ZodEnum<{
84
+ "E-01": "E-01";
85
+ "E-02": "E-02";
86
+ "E-03": "E-03";
87
+ "E-04": "E-04";
88
+ "E-05": "E-05";
89
+ "E-06": "E-06";
90
+ }>;
91
+ kind: z.ZodString;
92
+ subject: z.ZodObject<{
93
+ type: z.ZodString;
94
+ id: z.ZodString;
95
+ version: z.ZodNullable<z.ZodString>;
96
+ }, z.core.$strip>;
97
+ origin: z.ZodEnum<{
98
+ human: "human";
99
+ leader: "leader";
100
+ system: "system";
101
+ }>;
102
+ causedBy: z.ZodNullable<z.ZodString>;
103
+ summary: z.ZodString;
104
+ source: z.ZodOptional<z.ZodObject<{
105
+ runId: z.ZodString;
106
+ runSeq: z.ZodNumber;
107
+ }, z.core.$strip>>;
108
+ }, z.core.$strip>;
109
+ export type McpJournalAppendInput = z.input<typeof mcpJournalAppendInputSchema>;
110
+ /** One journal row, exactly as it is stored and exactly as it is replayed (D-05 § 6.3). */
111
+ export declare const mcpJournalRowSchema: z.ZodObject<{
112
+ category: z.ZodEnum<{
113
+ "E-01": "E-01";
114
+ "E-02": "E-02";
115
+ "E-03": "E-03";
116
+ "E-04": "E-04";
117
+ "E-05": "E-05";
118
+ "E-06": "E-06";
119
+ }>;
120
+ kind: z.ZodString;
121
+ subject: z.ZodObject<{
122
+ type: z.ZodString;
123
+ id: z.ZodString;
124
+ version: z.ZodNullable<z.ZodString>;
125
+ }, z.core.$strip>;
126
+ origin: z.ZodEnum<{
127
+ human: "human";
128
+ leader: "leader";
129
+ system: "system";
130
+ }>;
131
+ causedBy: z.ZodNullable<z.ZodString>;
132
+ summary: z.ZodString;
133
+ source: z.ZodOptional<z.ZodObject<{
134
+ runId: z.ZodString;
135
+ runSeq: z.ZodNumber;
136
+ }, z.core.$strip>>;
137
+ eventId: z.ZodString;
138
+ journalSeq: z.ZodNumber;
139
+ ts: z.ZodString;
140
+ projectId: z.ZodString;
141
+ }, z.core.$strip>;
142
+ export type McpJournalRow = z.infer<typeof mcpJournalRowSchema>;
143
+ /** Opaque to the client. It encodes project, epoch and position; a client never builds one. */
144
+ export declare const mcpJournalCursorSchema: z.ZodString;
145
+ export type McpJournalCursor = z.infer<typeof mcpJournalCursorSchema>;
146
+ /** A replay read: everything strictly after `cursor`, or from the oldest retained row without one. */
147
+ export declare const mcpJournalReadInputSchema: z.ZodObject<{
148
+ cursor: z.ZodOptional<z.ZodString>;
149
+ limit: z.ZodOptional<z.ZodNumber>;
150
+ }, z.core.$strip>;
151
+ export type McpJournalReadInput = z.infer<typeof mcpJournalReadInputSchema>;
152
+ export declare const mcpJournalPageSchema: z.ZodObject<{
153
+ status: z.ZodLiteral<"ok">;
154
+ events: z.ZodArray<z.ZodObject<{
155
+ category: z.ZodEnum<{
156
+ "E-01": "E-01";
157
+ "E-02": "E-02";
158
+ "E-03": "E-03";
159
+ "E-04": "E-04";
160
+ "E-05": "E-05";
161
+ "E-06": "E-06";
162
+ }>;
163
+ kind: z.ZodString;
164
+ subject: z.ZodObject<{
165
+ type: z.ZodString;
166
+ id: z.ZodString;
167
+ version: z.ZodNullable<z.ZodString>;
168
+ }, z.core.$strip>;
169
+ origin: z.ZodEnum<{
170
+ human: "human";
171
+ leader: "leader";
172
+ system: "system";
173
+ }>;
174
+ causedBy: z.ZodNullable<z.ZodString>;
175
+ summary: z.ZodString;
176
+ source: z.ZodOptional<z.ZodObject<{
177
+ runId: z.ZodString;
178
+ runSeq: z.ZodNumber;
179
+ }, z.core.$strip>>;
180
+ eventId: z.ZodString;
181
+ journalSeq: z.ZodNumber;
182
+ ts: z.ZodString;
183
+ projectId: z.ZodString;
184
+ }, z.core.$strip>>;
185
+ nextCursor: z.ZodString;
186
+ hasMore: z.ZodBoolean;
187
+ oldestSeq: z.ZodNullable<z.ZodNumber>;
188
+ latestSeq: z.ZodNumber;
189
+ }, z.core.$strip>;
190
+ export type McpJournalPage = z.infer<typeof mcpJournalPageSchema>;
191
+ /**
192
+ * The explicit gap (D-05 § 6.5, adopted by D-09 B-19). Rows the cursor still needed are gone —
193
+ * evicted by retention, or the journal was recreated — so NOTHING is replayed: a partial replay
194
+ * would read as "nothing happened" in between. The caller reads current state first, then continues
195
+ * from `resumeCursor`, which sits just before the oldest row still retained.
196
+ */
197
+ export declare const mcpJournalCursorTooOldSchema: z.ZodObject<{
198
+ status: z.ZodLiteral<"cursor_too_old">;
199
+ oldestSeq: z.ZodNullable<z.ZodNumber>;
200
+ latestSeq: z.ZodNumber;
201
+ resumeCursor: z.ZodString;
202
+ recovery: z.ZodObject<{
203
+ required: z.ZodLiteral<"current-state">;
204
+ message: z.ZodString;
205
+ }, z.core.$strip>;
206
+ }, z.core.$strip>;
207
+ export type McpJournalCursorTooOld = z.infer<typeof mcpJournalCursorTooOldSchema>;
208
+ export declare const mcpJournalReadResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
209
+ status: z.ZodLiteral<"ok">;
210
+ events: z.ZodArray<z.ZodObject<{
211
+ category: z.ZodEnum<{
212
+ "E-01": "E-01";
213
+ "E-02": "E-02";
214
+ "E-03": "E-03";
215
+ "E-04": "E-04";
216
+ "E-05": "E-05";
217
+ "E-06": "E-06";
218
+ }>;
219
+ kind: z.ZodString;
220
+ subject: z.ZodObject<{
221
+ type: z.ZodString;
222
+ id: z.ZodString;
223
+ version: z.ZodNullable<z.ZodString>;
224
+ }, z.core.$strip>;
225
+ origin: z.ZodEnum<{
226
+ human: "human";
227
+ leader: "leader";
228
+ system: "system";
229
+ }>;
230
+ causedBy: z.ZodNullable<z.ZodString>;
231
+ summary: z.ZodString;
232
+ source: z.ZodOptional<z.ZodObject<{
233
+ runId: z.ZodString;
234
+ runSeq: z.ZodNumber;
235
+ }, z.core.$strip>>;
236
+ eventId: z.ZodString;
237
+ journalSeq: z.ZodNumber;
238
+ ts: z.ZodString;
239
+ projectId: z.ZodString;
240
+ }, z.core.$strip>>;
241
+ nextCursor: z.ZodString;
242
+ hasMore: z.ZodBoolean;
243
+ oldestSeq: z.ZodNullable<z.ZodNumber>;
244
+ latestSeq: z.ZodNumber;
245
+ }, z.core.$strip>, z.ZodObject<{
246
+ status: z.ZodLiteral<"cursor_too_old">;
247
+ oldestSeq: z.ZodNullable<z.ZodNumber>;
248
+ latestSeq: z.ZodNumber;
249
+ resumeCursor: z.ZodString;
250
+ recovery: z.ZodObject<{
251
+ required: z.ZodLiteral<"current-state">;
252
+ message: z.ZodString;
253
+ }, z.core.$strip>;
254
+ }, z.core.$strip>], "status">;
255
+ export type McpJournalReadResult = z.infer<typeof mcpJournalReadResultSchema>;
256
+ /**
257
+ * A cursor the journal refuses outright. Never "start from zero" — that would replay the whole
258
+ * retention window into a model turn (D-05 § 6.5). `cursor_project_mismatch` names neither project:
259
+ * the bound session already knows its own, and the other one is not its business (N-01).
260
+ */
261
+ export declare const mcpJournalCursorRejectionSchema: z.ZodObject<{
262
+ error: z.ZodEnum<{
263
+ cursor_project_mismatch: "cursor_project_mismatch";
264
+ invalid_cursor: "invalid_cursor";
265
+ }>;
266
+ message: z.ZodString;
267
+ }, z.core.$strip>;
268
+ export type McpJournalCursorRejection = z.infer<typeof mcpJournalCursorRejectionSchema>;
@@ -0,0 +1,88 @@
1
+ import { z } from 'zod';
2
+ export declare const mcpLeaderActionInputSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ action: z.ZodLiteral<"attach">;
4
+ client: z.ZodLiteral<"opencode">;
5
+ baseUrl: z.ZodURL;
6
+ sessionId: z.ZodString;
7
+ }, z.core.$strict>, z.ZodObject<{
8
+ action: z.ZodLiteral<"attach">;
9
+ client: z.ZodLiteral<"pi">;
10
+ }, z.core.$strict>], "client">, z.ZodObject<{
11
+ action: z.ZodLiteral<"stop">;
12
+ }, z.core.$strict>]>;
13
+ export type McpLeaderActionInput = z.infer<typeof mcpLeaderActionInputSchema>;
14
+ /** The leader session attached to the project, if any. */
15
+ export declare const mcpLeaderSessionSchema: z.ZodObject<{
16
+ client: z.ZodEnum<{
17
+ opencode: "opencode";
18
+ pi: "pi";
19
+ }>;
20
+ state: z.ZodLiteral<"attached">;
21
+ }, z.core.$strip>;
22
+ export type McpLeaderSession = z.infer<typeof mcpLeaderSessionSchema>;
23
+ /**
24
+ * The event controller of the MCP session that owns the project, when one is open. The three
25
+ * cursors are D-05 § 6.6's, stay apart, and each reports only what HAPPENED — never where pushing
26
+ * happened to start (QA on #311):
27
+ * - `deliveredSeq`: the newest row really handed to the attached leader, in this journal. A row
28
+ * the leader caused itself (its own echo) is never handed to it and never counted, so this can stay
29
+ * below `latestSeq` with nothing wrong — and it says nothing about those rows;
30
+ * - `ackedSeq`: the newest row the leader acknowledged with an explicit tool call — the same record
31
+ * `leader_events` keeps, so the two never disagree; 0 until it acknowledges;
32
+ * - `reactedSeq`: the newest row a model turn was really seen to carry; 0 until one is.
33
+ */
34
+ export declare const mcpLeaderDeliverySchema: z.ZodObject<{
35
+ state: z.ZodEnum<{
36
+ disconnected: "disconnected";
37
+ dispatching: "dispatching";
38
+ ended: "ended";
39
+ idle: "idle";
40
+ inert: "inert";
41
+ recovering: "recovering";
42
+ }>;
43
+ deliveredSeq: z.ZodNumber;
44
+ ackedSeq: z.ZodNumber;
45
+ reactedSeq: z.ZodNumber;
46
+ latestSeq: z.ZodNumber;
47
+ }, z.core.$strip>;
48
+ export type McpLeaderDelivery = z.infer<typeof mcpLeaderDeliverySchema>;
49
+ /** Why events are kept rather than delivered right now. Always recoverable: nothing is lost. */
50
+ export declare const mcpLeaderBlockerSchema: z.ZodObject<{
51
+ code: z.ZodString;
52
+ message: z.ZodString;
53
+ fix: z.ZodString;
54
+ }, z.core.$strip>;
55
+ export type McpLeaderBlocker = z.infer<typeof mcpLeaderBlockerSchema>;
56
+ export declare const mcpLeaderStatusSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
57
+ available: z.ZodLiteral<false>;
58
+ reason: z.ZodString;
59
+ }, z.core.$strip>, z.ZodObject<{
60
+ available: z.ZodLiteral<true>;
61
+ leader: z.ZodNullable<z.ZodObject<{
62
+ client: z.ZodEnum<{
63
+ opencode: "opencode";
64
+ pi: "pi";
65
+ }>;
66
+ state: z.ZodLiteral<"attached">;
67
+ }, z.core.$strip>>;
68
+ delivery: z.ZodNullable<z.ZodObject<{
69
+ state: z.ZodEnum<{
70
+ disconnected: "disconnected";
71
+ dispatching: "dispatching";
72
+ ended: "ended";
73
+ idle: "idle";
74
+ inert: "inert";
75
+ recovering: "recovering";
76
+ }>;
77
+ deliveredSeq: z.ZodNumber;
78
+ ackedSeq: z.ZodNumber;
79
+ reactedSeq: z.ZodNumber;
80
+ latestSeq: z.ZodNumber;
81
+ }, z.core.$strip>>;
82
+ blocker: z.ZodNullable<z.ZodObject<{
83
+ code: z.ZodString;
84
+ message: z.ZodString;
85
+ fix: z.ZodString;
86
+ }, z.core.$strip>>;
87
+ }, z.core.$strip>], "available">;
88
+ export type McpLeaderStatus = z.infer<typeof mcpLeaderStatusSchema>;
@@ -0,0 +1,78 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Per-project MCP ownership (#99, decision D-02 in
4
+ * `docs/features/mcp-server/mcp-d02-session-binding-decision.md` § 4).
5
+ *
6
+ * Exactly one logical MCP session owns a project. A second one is refused with the
7
+ * *project-occupied* error, and an owner whose lease was lost or fenced is refused with the
8
+ * *session-expired* error on every later call.
9
+ *
10
+ * Neither error is standard MCP. The MCP specification publishes no error registry and no
11
+ * "project busy" code in the pages D-02 examined; both numbers are xezar's own, chosen inside the
12
+ * JSON-RPC 2.0 range reserved for implementation-defined server errors (`-32000` to `-32099`) and
13
+ * clear of every code the TypeScript SDK already claims. A future SDK release could still claim
14
+ * them, which is why **`data.reason` is the authoritative discriminator, not `code`**.
15
+ */
16
+ /** JSON-RPC `code` of the project-occupied error. Implementation-defined, not standard. */
17
+ export declare const MCP_PROJECT_OCCUPIED_CODE = -32080;
18
+ /** JSON-RPC `code` of the session-expired error. Implementation-defined, not standard. */
19
+ export declare const MCP_SESSION_EXPIRED_CODE = -32081;
20
+ /** The namespaced discriminators. A consumer branches on these, never on the number. */
21
+ export declare const MCP_PROJECT_OCCUPIED_REASON = "com.qodeca.xezar/project-occupied";
22
+ export declare const MCP_SESSION_EXPIRED_REASON = "com.qodeca.xezar/session-expired";
23
+ /**
24
+ * The JSON-RPC `error` object a second logical client receives from `initialize` while the
25
+ * project has a live owner. On Streamable HTTP it travels in a 200 response; on stdio it is the
26
+ * ordinary JSON-RPC error response.
27
+ *
28
+ * `.strict()` at both levels is the N-01 guarantee made structural: the refusal carries the
29
+ * project's own id, a human sentence and `retryable`, and NOTHING about the competing owner — no
30
+ * session id, fencing token, pid, client name or version, and no "occupied since" timestamp. A
31
+ * field added here is a field that can fingerprint another client, so adding one is a review
32
+ * question, not a convenience.
33
+ */
34
+ export declare const mcpProjectOccupiedErrorSchema: z.ZodObject<{
35
+ code: z.ZodLiteral<-32080>;
36
+ message: z.ZodString;
37
+ data: z.ZodObject<{
38
+ reason: z.ZodLiteral<"com.qodeca.xezar/project-occupied">;
39
+ projectId: z.ZodString;
40
+ retryable: z.ZodLiteral<true>;
41
+ }, z.core.$strict>;
42
+ }, z.core.$strict>;
43
+ export type McpProjectOccupiedError = z.infer<typeof mcpProjectOccupiedErrorSchema>;
44
+ /**
45
+ * The JSON-RPC `error` object a fenced or expired owner receives on any later call. On Streamable
46
+ * HTTP the transport answers 404 for that `MCP-Session-Id` instead, which every conforming client
47
+ * already treats as "start a new session"; on stdio this error is sent and the server then closes
48
+ * its output stream. Either way the exit is an automatic reconnect by the bridge — never the model
49
+ * and never a person.
50
+ */
51
+ export declare const mcpSessionExpiredErrorSchema: z.ZodObject<{
52
+ code: z.ZodLiteral<-32081>;
53
+ message: z.ZodString;
54
+ data: z.ZodObject<{
55
+ reason: z.ZodLiteral<"com.qodeca.xezar/session-expired">;
56
+ projectId: z.ZodString;
57
+ retryable: z.ZodLiteral<true>;
58
+ }, z.core.$strict>;
59
+ }, z.core.$strict>;
60
+ export type McpSessionExpiredError = z.infer<typeof mcpSessionExpiredErrorSchema>;
61
+ /**
62
+ * A project's occupancy as the cockpit renders it. Derived at READ time by the same classifier
63
+ * acquisition runs — never a stored flag, because a dead owner's claim can sit on disk until the
64
+ * next acquirer reaps it, and a stored flag would render "occupied" for a project nobody owns.
65
+ *
66
+ * - `unowned` — no claim, or none that is live. The resting state; nothing is blocked.
67
+ * - `owned` — one live owner. A second client would be refused.
68
+ * - `expired` — an owner's claim outlived its lease or its process. The next acquirer reclaims it.
69
+ *
70
+ * Deliberately no owner detail: the cockpit offers no control that changes this state (F-18 — no
71
+ * manual disconnect, no forced takeover), so it needs nothing to act on.
72
+ */
73
+ export declare const projectOwnerStateSchema: z.ZodEnum<{
74
+ expired: "expired";
75
+ owned: "owned";
76
+ unowned: "unowned";
77
+ }>;
78
+ export type ProjectOwnerState = z.infer<typeof projectOwnerStateSchema>;