@mostra/protocol 0.9.0 → 0.11.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 (241) hide show
  1. package/dist/actions.d.ts +30 -4
  2. package/dist/actions.d.ts.map +1 -1
  3. package/dist/actions.js +14 -4
  4. package/dist/actions.js.map +1 -1
  5. package/dist/artifact.d.ts +2 -1
  6. package/dist/artifact.d.ts.map +1 -1
  7. package/dist/artifact.js +2 -1
  8. package/dist/artifact.js.map +1 -1
  9. package/dist/browser.d.ts +47 -0
  10. package/dist/browser.d.ts.map +1 -1
  11. package/dist/browser.js +36 -3
  12. package/dist/browser.js.map +1 -1
  13. package/dist/capability.d.ts +0 -9
  14. package/dist/capability.d.ts.map +1 -1
  15. package/dist/capability.js +1 -17
  16. package/dist/capability.js.map +1 -1
  17. package/dist/diagnostics/codes/action.d.ts +1 -1
  18. package/dist/diagnostics/codes/action.d.ts.map +1 -1
  19. package/dist/diagnostics/codes/action.js +12 -1
  20. package/dist/diagnostics/codes/action.js.map +1 -1
  21. package/dist/diagnostics/codes/artifact.d.ts +1 -1
  22. package/dist/diagnostics/codes/artifact.d.ts.map +1 -1
  23. package/dist/diagnostics/codes/artifact.js +12 -1
  24. package/dist/diagnostics/codes/artifact.js.map +1 -1
  25. package/dist/diagnostics/codes/home.d.ts +1 -1
  26. package/dist/diagnostics/codes/home.d.ts.map +1 -1
  27. package/dist/diagnostics/codes/home.js +12 -1
  28. package/dist/diagnostics/codes/home.js.map +1 -1
  29. package/dist/diagnostics/codes/index.d.ts +3 -2
  30. package/dist/diagnostics/codes/index.d.ts.map +1 -1
  31. package/dist/diagnostics/codes/index.js +3 -1
  32. package/dist/diagnostics/codes/index.js.map +1 -1
  33. package/dist/diagnostics/codes/remote.d.ts +8 -0
  34. package/dist/diagnostics/codes/remote.d.ts.map +1 -0
  35. package/dist/diagnostics/codes/remote.js +176 -0
  36. package/dist/diagnostics/codes/remote.js.map +1 -0
  37. package/dist/diagnostics/codes/submit.d.ts +1 -1
  38. package/dist/diagnostics/codes/submit.d.ts.map +1 -1
  39. package/dist/diagnostics/codes/submit.js +12 -1
  40. package/dist/diagnostics/codes/submit.js.map +1 -1
  41. package/dist/diagnostics/diagnostic.d.ts +1 -1
  42. package/dist/diagnostics/diagnostic.d.ts.map +1 -1
  43. package/dist/diagnostics/diagnostic.js +2 -1
  44. package/dist/diagnostics/diagnostic.js.map +1 -1
  45. package/dist/duration.d.ts +13 -0
  46. package/dist/duration.d.ts.map +1 -0
  47. package/dist/duration.js +27 -0
  48. package/dist/duration.js.map +1 -0
  49. package/dist/ids.d.ts +17 -1
  50. package/dist/ids.d.ts.map +1 -1
  51. package/dist/ids.js +9 -1
  52. package/dist/ids.js.map +1 -1
  53. package/dist/index.d.ts +33 -8
  54. package/dist/index.js +33 -8
  55. package/dist/interaction.d.ts +33 -2
  56. package/dist/interaction.d.ts.map +1 -1
  57. package/dist/interaction.js +22 -6
  58. package/dist/interaction.js.map +1 -1
  59. package/dist/manifest.d.ts +59 -14
  60. package/dist/manifest.d.ts.map +1 -1
  61. package/dist/manifest.js +63 -15
  62. package/dist/manifest.js.map +1 -1
  63. package/dist/methods/artifact/export.d.ts +40 -0
  64. package/dist/methods/artifact/export.d.ts.map +1 -0
  65. package/dist/methods/artifact/export.js +36 -0
  66. package/dist/methods/artifact/export.js.map +1 -0
  67. package/dist/methods/artifact/import.d.ts +23 -0
  68. package/dist/methods/artifact/import.d.ts.map +1 -0
  69. package/dist/methods/artifact/import.js +25 -0
  70. package/dist/methods/artifact/import.js.map +1 -0
  71. package/dist/methods/artifact/pause.d.ts +33 -0
  72. package/dist/methods/artifact/pause.d.ts.map +1 -0
  73. package/dist/methods/artifact/pause.js +33 -0
  74. package/dist/methods/artifact/pause.js.map +1 -0
  75. package/dist/methods/artifact/publish.d.ts +2 -1
  76. package/dist/methods/artifact/publish.d.ts.map +1 -1
  77. package/dist/methods/artifact/publish.js +1 -1
  78. package/dist/methods/hosted/push.d.ts +76 -0
  79. package/dist/methods/hosted/push.d.ts.map +1 -0
  80. package/dist/methods/hosted/push.js +71 -0
  81. package/dist/methods/hosted/push.js.map +1 -0
  82. package/dist/methods/hosted/submission.d.ts +18 -0
  83. package/dist/methods/hosted/submission.d.ts.map +1 -0
  84. package/dist/methods/hosted/submission.js +23 -0
  85. package/dist/methods/hosted/submission.js.map +1 -0
  86. package/dist/methods/index.d.ts.map +1 -1
  87. package/dist/methods/index.js +44 -2
  88. package/dist/methods/index.js.map +1 -1
  89. package/dist/methods/instance/status.d.ts +3 -0
  90. package/dist/methods/instance/status.d.ts.map +1 -1
  91. package/dist/methods/instance/status.js +3 -1
  92. package/dist/methods/instance/status.js.map +1 -1
  93. package/dist/methods/mostra/initialize.d.ts +17 -3
  94. package/dist/methods/mostra/initialize.d.ts.map +1 -1
  95. package/dist/methods/mostra/initialize.js +11 -3
  96. package/dist/methods/mostra/initialize.js.map +1 -1
  97. package/dist/methods/port/relay-author.d.ts +28 -0
  98. package/dist/methods/port/relay-author.d.ts.map +1 -0
  99. package/dist/methods/port/relay-author.js +42 -0
  100. package/dist/methods/port/relay-author.js.map +1 -0
  101. package/dist/methods/port/relay-call.d.ts +33 -0
  102. package/dist/methods/port/relay-call.d.ts.map +1 -0
  103. package/dist/methods/port/relay-call.js +31 -0
  104. package/dist/methods/port/relay-call.js.map +1 -0
  105. package/dist/methods/port/relay-cancel.d.ts +16 -0
  106. package/dist/methods/port/relay-cancel.d.ts.map +1 -0
  107. package/dist/methods/port/relay-cancel.js +21 -0
  108. package/dist/methods/port/relay-cancel.js.map +1 -0
  109. package/dist/methods/port/relay-live.d.ts +25 -0
  110. package/dist/methods/port/relay-live.d.ts.map +1 -0
  111. package/dist/methods/port/relay-live.js +32 -0
  112. package/dist/methods/port/relay-live.js.map +1 -0
  113. package/dist/methods/port/relay-reconcile.d.ts +39 -0
  114. package/dist/methods/port/relay-reconcile.d.ts.map +1 -0
  115. package/dist/methods/port/relay-reconcile.js +35 -0
  116. package/dist/methods/port/relay-reconcile.js.map +1 -0
  117. package/dist/methods/port/relay-run.d.ts +47 -0
  118. package/dist/methods/port/relay-run.d.ts.map +1 -0
  119. package/dist/methods/port/relay-run.js +41 -0
  120. package/dist/methods/port/relay-run.js.map +1 -0
  121. package/dist/methods/port/submissions-deliver.d.ts +8 -0
  122. package/dist/methods/port/submissions-deliver.d.ts.map +1 -1
  123. package/dist/methods/port/submissions-deliver.js +4 -2
  124. package/dist/methods/port/submissions-deliver.js.map +1 -1
  125. package/dist/methods/relay/call-batch.d.ts +26 -0
  126. package/dist/methods/relay/call-batch.d.ts.map +1 -0
  127. package/dist/methods/relay/call-batch.js +30 -0
  128. package/dist/methods/relay/call-batch.js.map +1 -0
  129. package/dist/methods/relay/effect.d.ts +31 -0
  130. package/dist/methods/relay/effect.d.ts.map +1 -0
  131. package/dist/methods/relay/effect.js +30 -0
  132. package/dist/methods/relay/effect.js.map +1 -0
  133. package/dist/methods/relay/live-value.d.ts +33 -0
  134. package/dist/methods/relay/live-value.d.ts.map +1 -0
  135. package/dist/methods/relay/live-value.js +32 -0
  136. package/dist/methods/relay/live-value.js.map +1 -0
  137. package/dist/methods/relay/run-update.d.ts +46 -0
  138. package/dist/methods/relay/run-update.d.ts.map +1 -0
  139. package/dist/methods/relay/run-update.js +45 -0
  140. package/dist/methods/relay/run-update.js.map +1 -0
  141. package/dist/methods/remote/link.d.ts +40 -0
  142. package/dist/methods/remote/link.d.ts.map +1 -0
  143. package/dist/methods/remote/link.js +40 -0
  144. package/dist/methods/remote/link.js.map +1 -0
  145. package/dist/methods/remote/login-wait.d.ts +30 -0
  146. package/dist/methods/remote/login-wait.d.ts.map +1 -0
  147. package/dist/methods/remote/login-wait.js +36 -0
  148. package/dist/methods/remote/login-wait.js.map +1 -0
  149. package/dist/methods/remote/login.d.ts +41 -0
  150. package/dist/methods/remote/login.d.ts.map +1 -0
  151. package/dist/methods/remote/login.js +37 -0
  152. package/dist/methods/remote/login.js.map +1 -0
  153. package/dist/methods/remote/logout.d.ts +25 -0
  154. package/dist/methods/remote/logout.d.ts.map +1 -0
  155. package/dist/methods/remote/logout.js +28 -0
  156. package/dist/methods/remote/logout.js.map +1 -0
  157. package/dist/methods/remote/status.d.ts +14 -0
  158. package/dist/methods/remote/status.d.ts.map +1 -0
  159. package/dist/methods/remote/status.js +22 -0
  160. package/dist/methods/remote/status.js.map +1 -0
  161. package/dist/methods/remote/token.d.ts +19 -0
  162. package/dist/methods/remote/token.d.ts.map +1 -0
  163. package/dist/methods/remote/token.js +24 -0
  164. package/dist/methods/remote/token.js.map +1 -0
  165. package/dist/methods/share/start.d.ts +5 -2
  166. package/dist/methods/share/start.d.ts.map +1 -1
  167. package/dist/methods/share/start.js +6 -3
  168. package/dist/methods/share/start.js.map +1 -1
  169. package/dist/methods/state/patch.d.ts +7 -0
  170. package/dist/methods/state/patch.d.ts.map +1 -1
  171. package/dist/methods/state/patch.js +2 -1
  172. package/dist/methods/state/patch.js.map +1 -1
  173. package/dist/methods/view/url.d.ts +2 -1
  174. package/dist/methods/view/url.d.ts.map +1 -1
  175. package/dist/methods/view/url.js +2 -1
  176. package/dist/methods/view/url.js.map +1 -1
  177. package/dist/operator.d.ts +464 -0
  178. package/dist/operator.d.ts.map +1 -0
  179. package/dist/operator.js +134 -0
  180. package/dist/operator.js.map +1 -0
  181. package/dist/policy.d.ts +18 -0
  182. package/dist/policy.d.ts.map +1 -0
  183. package/dist/policy.js +23 -0
  184. package/dist/policy.js.map +1 -0
  185. package/dist/remote.d.ts +55 -0
  186. package/dist/remote.d.ts.map +1 -0
  187. package/dist/remote.js +52 -0
  188. package/dist/remote.js.map +1 -0
  189. package/dist/view.d.ts +1 -1
  190. package/dist/view.js +1 -1
  191. package/dist/view.js.map +1 -1
  192. package/package.json +12 -2
  193. package/schemas/protocol.draft-07.json +1839 -99
  194. package/schemas/protocol.schema.json +1787 -111
  195. package/src/actions.ts +45 -5
  196. package/src/browser.ts +70 -0
  197. package/src/capability.ts +0 -23
  198. package/src/diagnostics/codes/action.ts +12 -0
  199. package/src/diagnostics/codes/artifact.ts +12 -0
  200. package/src/diagnostics/codes/home.ts +12 -0
  201. package/src/diagnostics/codes/index.ts +6 -2
  202. package/src/diagnostics/codes/remote.ts +197 -0
  203. package/src/diagnostics/codes/submit.ts +12 -0
  204. package/src/diagnostics/diagnostic.ts +3 -1
  205. package/src/duration.ts +29 -0
  206. package/src/ids.ts +33 -1
  207. package/src/index.ts +143 -8
  208. package/src/interaction.ts +48 -2
  209. package/src/manifest.ts +115 -24
  210. package/src/methods/artifact/export.ts +68 -0
  211. package/src/methods/artifact/import.ts +39 -0
  212. package/src/methods/artifact/pause.ts +59 -0
  213. package/src/methods/hosted/push.ts +146 -0
  214. package/src/methods/hosted/submission.ts +34 -0
  215. package/src/methods/index.ts +42 -0
  216. package/src/methods/instance/status.ts +4 -0
  217. package/src/methods/mostra/initialize.ts +19 -3
  218. package/src/methods/port/relay-author.ts +57 -0
  219. package/src/methods/port/relay-call.ts +58 -0
  220. package/src/methods/port/relay-cancel.ts +33 -0
  221. package/src/methods/port/relay-live.ts +48 -0
  222. package/src/methods/port/relay-reconcile.ts +71 -0
  223. package/src/methods/port/relay-run.ts +80 -0
  224. package/src/methods/port/submissions-deliver.ts +13 -1
  225. package/src/methods/relay/call-batch.ts +52 -0
  226. package/src/methods/relay/effect.ts +55 -0
  227. package/src/methods/relay/live-value.ts +54 -0
  228. package/src/methods/relay/run-update.ts +81 -0
  229. package/src/methods/remote/link.ts +65 -0
  230. package/src/methods/remote/login-wait.ts +55 -0
  231. package/src/methods/remote/login.ts +72 -0
  232. package/src/methods/remote/logout.ts +42 -0
  233. package/src/methods/remote/status.ts +34 -0
  234. package/src/methods/remote/token.ts +39 -0
  235. package/src/methods/share/start.ts +12 -4
  236. package/src/methods/state/patch.ts +6 -0
  237. package/src/methods/view/url.ts +2 -1
  238. package/src/operator.ts +621 -0
  239. package/src/policy.ts +30 -0
  240. package/src/remote.ts +89 -0
  241. package/src/view.ts +1 -1
@@ -0,0 +1,176 @@
1
+ //#region src/diagnostics/codes/remote.ts
2
+ /** The codes of the REMOTE area, in the order they were added. */
3
+ const remoteDiagnosticCodes = [
4
+ "MOSTRA_REMOTE_CONFIG_INVALID",
5
+ "MOSTRA_REMOTE_LOGIN_FAILED",
6
+ "MOSTRA_REMOTE_UNREACHABLE",
7
+ "MOSTRA_REMOTE_OWNER_OFFLINE",
8
+ "MOSTRA_REMOTE_QUEUE_FULL",
9
+ "MOSTRA_REMOTE_NOT_OWNER_INSTANCE",
10
+ "MOSTRA_REMOTE_SIGN_IN_REQUIRED",
11
+ "MOSTRA_REMOTE_RATE_LIMITED",
12
+ "MOSTRA_REMOTE_PAUSED_BY_OPERATOR",
13
+ "MOSTRA_REMOTE_LIMIT_REACHED",
14
+ "MOSTRA_REMOTE_OPERATOR_UNAVAILABLE",
15
+ "MOSTRA_REMOTE_NO_INSTANCE",
16
+ "MOSTRA_REMOTE_UNDER_REVIEW",
17
+ "MOSTRA_REMOTE_HOME_SUSPENDED",
18
+ "MOSTRA_REMOTE_HOME_MOVING"
19
+ ];
20
+ /** The REMOTE area's catalog entries. */
21
+ const remoteDiagnostics = {
22
+ MOSTRA_REMOTE_CONFIG_INVALID: {
23
+ severity: "error",
24
+ phase: "host",
25
+ title: "Remote server configuration can't be used",
26
+ hint: "Fix the configuration key the message names, then start mostra-runtime server again.",
27
+ docs: {
28
+ explanation: "`mostra-runtime server` reads its configuration (the file `--config` names and `MOSTRA_SERVER_*` variables) before it serves anything, and stops when a key is missing, of the wrong type or out of range, naming the key. Nothing was served.",
29
+ fix: "Correct the key the message names: `apiOrigin` must be an `https:` origin (or `http:` on loopback), and `domains.active` a host name."
30
+ }
31
+ },
32
+ MOSTRA_REMOTE_LOGIN_FAILED: {
33
+ severity: "error",
34
+ phase: "host",
35
+ title: "Signing in to a remote server failed",
36
+ hint: "Run mostra login again, and approve the code on the server's page within ten minutes.",
37
+ docs: {
38
+ explanation: "Signing this home in to a remote server didn't finish: the code expired, the person refused it, the server refused the client, or the binding's access token was refused (revoked, expired, or for another server). Nothing of the home changed; artifacts it owns on that server stay its own.",
39
+ fix: "Sign in to the server again and approve the code on the page it names. A refusal you didn't expect means the sign-in was revoked on the server."
40
+ }
41
+ },
42
+ MOSTRA_REMOTE_UNREACHABLE: {
43
+ severity: "error",
44
+ phase: "host",
45
+ title: "The remote server can't be reached",
46
+ hint: "Check the network and the server's address, then try again; mostra status shows the link.",
47
+ docs: {
48
+ explanation: "The owner instance couldn't reach the remote server that holds this hosted artifact, so a write that must go there (its artifact state, a live value) was refused, never applied locally alone (D165 item 1). Nothing was lost: a page's edit stays in its journal and is sent again.",
49
+ fix: "Run `mostra status` to see each server's link. When the server is back the link reconnects by itself; then write again."
50
+ }
51
+ },
52
+ MOSTRA_REMOTE_OWNER_OFFLINE: {
53
+ severity: "error",
54
+ phase: "host",
55
+ title: "The artifact's owner instance is offline",
56
+ hint: "Start Mostra on the machine that shared the page, or try again once it is back.",
57
+ docs: {
58
+ explanation: "A hosted page called server code its owner instance runs, and the owner instance isn't connected. A plain call isn't kept, so it is refused at once; an action run waits or fails as the artifact's `hosted.offline` says.",
59
+ fix: "Start Mostra on the owner's machine (`mostra daemon start`, or `mostra daemon install` for always-on). An action that must work while the owner is away should be an action run with `hosted.offline.actions: \"queue\"`."
60
+ }
61
+ },
62
+ MOSTRA_REMOTE_QUEUE_FULL: {
63
+ severity: "error",
64
+ phase: "host",
65
+ title: "Too many runs wait for the owner",
66
+ hint: "Wait for the owner to come back and work through its queue, then press again.",
67
+ docs: {
68
+ explanation: "The artifact's owner instance is offline and as many runs as the server allows already wait for it, so this one was refused before anything was recorded. Runs already waiting keep their place.",
69
+ fix: "Bring the owner instance back online: waiting runs then go out in the order they were made. The cap is the server's `relay.waitingRunsPerArtifact` setting."
70
+ }
71
+ },
72
+ MOSTRA_REMOTE_NOT_OWNER_INSTANCE: {
73
+ severity: "error",
74
+ phase: "host",
75
+ title: "Another instance owns this hosted artifact",
76
+ hint: "Share or push this artifact from its owner instance, named in the message.",
77
+ docs: {
78
+ explanation: "A hosted artifact has one owner instance: the one that shared it. It alone receives the artifact's submissions, relayed runs and authoring, and only it pushes versions of it (D165 item 1b). Another instance of the same account reads and waits through the hosted home.",
79
+ fix: "Run the command on the instance the message names. Moving an artifact to another owner instance isn't part of this release."
80
+ }
81
+ },
82
+ MOSTRA_REMOTE_SIGN_IN_REQUIRED: {
83
+ severity: "error",
84
+ phase: "host",
85
+ title: "This action needs a signed-in viewer",
86
+ hint: "Sign in from the page's chrome, or have the owner allow this for anyone with the link.",
87
+ docs: {
88
+ explanation: "On a hosted link, an action that runs on the owner's machine, or a submission when the artifact asks for it, needs a viewer signed in (D159, D165 item 13). Nothing was recorded.",
89
+ fix: "Sign in with the page's Sign in. An owner who wants anyone with the link to run actions sets `hosted: { actions: \"link\" }` in the manifest (and `submissions: \"link\"` for answers)."
90
+ }
91
+ },
92
+ MOSTRA_REMOTE_RATE_LIMITED: {
93
+ severity: "error",
94
+ phase: "host",
95
+ title: "Too many requests on this link",
96
+ hint: "Try again after the time the answer's Retry-After gives.",
97
+ docs: {
98
+ explanation: "Too many requests of this kind came through one link or one address in a short time, past the server's `rateLimits`. Nothing was recorded, and a draft stays as it was.",
99
+ fix: "Wait for the `Retry-After` the answer carries and try again. The limits are the server's `rateLimits` settings."
100
+ }
101
+ },
102
+ MOSTRA_REMOTE_PAUSED_BY_OPERATOR: {
103
+ severity: "error",
104
+ phase: "host",
105
+ title: "Paused by the server's operator",
106
+ hint: "Contact the server's operator: only the operator resumes a pause it made.",
107
+ docs: {
108
+ explanation: "The server's operator paused this hosted artifact, and an owner can't undo an operator's pause (D165 item 14). Views keep working and the links stay valid.",
109
+ fix: "Ask the server's operator why it was paused and to resume it."
110
+ }
111
+ },
112
+ MOSTRA_REMOTE_LIMIT_REACHED: {
113
+ severity: "error",
114
+ phase: "host",
115
+ title: "The server's limit refused this",
116
+ hint: "Read the message for the server's limit, and try again once it allows the operation.",
117
+ docs: {
118
+ explanation: "The server's operator refused the operation for this account (its `limits` port): a share, a version push, a link, a view, a submission, an action or an MCP call. The message is the operator's own. A refused submission keeps its draft.",
119
+ fix: "Follow the operator's message; its `Retry-After`, when present, says when to try again."
120
+ }
121
+ },
122
+ MOSTRA_REMOTE_OPERATOR_UNAVAILABLE: {
123
+ severity: "error",
124
+ phase: "host",
125
+ title: "The server's operator didn't answer",
126
+ hint: "Try again in a moment; the server's operator didn't answer in time.",
127
+ docs: {
128
+ explanation: "The server's operator module didn't answer in time (2 s for limits, 5 s for sign-in), so an operation that creates something (a share, a push, a link, authoring, a sign-in) was refused rather than allowed blind. Views, drafts and submissions never wait for it, and existing sessions keep working.",
129
+ fix: "Try again; if it lasts, the server's operator has to fix its operator module."
130
+ }
131
+ },
132
+ MOSTRA_REMOTE_NO_INSTANCE: {
133
+ severity: "error",
134
+ phase: "host",
135
+ title: "No owner instance connected",
136
+ hint: "Start Mostra on the machine linked to this account (mostra daemon start), then try again.",
137
+ docs: {
138
+ explanation: "Creating, verifying and publishing from a chat host run on the account's default owner instance, through the relay (D165 item 5), and no default instance is connected to the server now. Reading tools (list, wait, results, state, docs, open) keep working.",
139
+ fix: "Start Mostra on the linked machine (`mostra daemon start`, or `mostra daemon install` to keep it running); link a machine first with `mostra login <server> --default`."
140
+ }
141
+ },
142
+ MOSTRA_REMOTE_UNDER_REVIEW: {
143
+ severity: "error",
144
+ phase: "host",
145
+ title: "This page is under review",
146
+ hint: "Nothing to do here: the server's operator is reviewing this page.",
147
+ docs: {
148
+ explanation: "The server's operator quarantined this hosted page, or this version of it, while it reviews it. Its data is kept; the page shows a neutral notice instead of its content until the operator releases it.",
149
+ fix: "The owner can ask the server's operator about the review."
150
+ }
151
+ },
152
+ MOSTRA_REMOTE_HOME_SUSPENDED: {
153
+ severity: "error",
154
+ phase: "host",
155
+ title: "This account's pages are suspended",
156
+ hint: "Contact the server's operator: this account's pages are suspended.",
157
+ docs: {
158
+ explanation: "The server's operator suspended this account's hosted home: its pages, its owner instances' bindings, pushes and links are refused until the operator resumes it. Nothing was deleted.",
159
+ fix: "Ask the server's operator to resume the account."
160
+ }
161
+ },
162
+ MOSTRA_REMOTE_HOME_MOVING: {
163
+ severity: "error",
164
+ phase: "host",
165
+ title: "This account's pages are moving",
166
+ hint: "Try again in a minute: this account's pages are moving between machines.",
167
+ docs: {
168
+ explanation: "The server's operator is moving this account's hosted home to another data directory (`drainHome`), so the home is closed here until it serves again. Clients retry; nothing is lost.",
169
+ fix: "Retry shortly; the move ends when the operator releases the home on its new machine."
170
+ }
171
+ }
172
+ };
173
+ //#endregion
174
+ export { remoteDiagnosticCodes, remoteDiagnostics };
175
+
176
+ //# sourceMappingURL=remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.js","names":[],"sources":["../../../src/diagnostics/codes/remote.ts"],"sourcesContent":["/**\n * Diagnostic codes of the REMOTE area.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the REMOTE area, in the order they were added. */\nexport const remoteDiagnosticCodes = [\n \"MOSTRA_REMOTE_CONFIG_INVALID\",\n \"MOSTRA_REMOTE_LOGIN_FAILED\",\n \"MOSTRA_REMOTE_UNREACHABLE\",\n \"MOSTRA_REMOTE_OWNER_OFFLINE\",\n \"MOSTRA_REMOTE_QUEUE_FULL\",\n \"MOSTRA_REMOTE_NOT_OWNER_INSTANCE\",\n \"MOSTRA_REMOTE_SIGN_IN_REQUIRED\",\n \"MOSTRA_REMOTE_RATE_LIMITED\",\n \"MOSTRA_REMOTE_PAUSED_BY_OPERATOR\",\n \"MOSTRA_REMOTE_LIMIT_REACHED\",\n \"MOSTRA_REMOTE_OPERATOR_UNAVAILABLE\",\n \"MOSTRA_REMOTE_NO_INSTANCE\",\n \"MOSTRA_REMOTE_UNDER_REVIEW\",\n \"MOSTRA_REMOTE_HOME_SUSPENDED\",\n \"MOSTRA_REMOTE_HOME_MOVING\",\n // gen:codes\n] as const;\n\n/** The codes of the REMOTE area. */\nexport type RemoteDiagnosticCode = (typeof remoteDiagnosticCodes)[number];\n\n/** The REMOTE area's catalog entries. */\nexport const remoteDiagnostics: AreaCatalog<RemoteDiagnosticCode> = {\n MOSTRA_REMOTE_CONFIG_INVALID: {\n severity: \"error\",\n phase: \"host\",\n title: \"Remote server configuration can't be used\",\n hint: \"Fix the configuration key the message names, then start mostra-runtime server again.\",\n docs: {\n explanation:\n \"`mostra-runtime server` reads its configuration (the file `--config` names and `MOSTRA_SERVER_*` variables) before it serves anything, and stops when a key is missing, of the wrong type or out of range, naming the key. Nothing was served.\",\n fix: \"Correct the key the message names: `apiOrigin` must be an `https:` origin (or `http:` on loopback), and `domains.active` a host name.\",\n },\n },\n MOSTRA_REMOTE_LOGIN_FAILED: {\n severity: \"error\",\n phase: \"host\",\n title: \"Signing in to a remote server failed\",\n hint: \"Run mostra login again, and approve the code on the server's page within ten minutes.\",\n docs: {\n explanation:\n \"Signing this home in to a remote server didn't finish: the code expired, the person refused it, the server refused the client, or the binding's access token was refused (revoked, expired, or for another server). Nothing of the home changed; artifacts it owns on that server stay its own.\",\n fix: \"Sign in to the server again and approve the code on the page it names. A refusal you didn't expect means the sign-in was revoked on the server.\",\n },\n },\n MOSTRA_REMOTE_UNREACHABLE: {\n severity: \"error\",\n phase: \"host\",\n title: \"The remote server can't be reached\",\n hint: \"Check the network and the server's address, then try again; mostra status shows the link.\",\n docs: {\n explanation:\n \"The owner instance couldn't reach the remote server that holds this hosted artifact, so a write that must go there (its artifact state, a live value) was refused, never applied locally alone (D165 item 1). Nothing was lost: a page's edit stays in its journal and is sent again.\",\n fix: \"Run `mostra status` to see each server's link. When the server is back the link reconnects by itself; then write again.\",\n },\n },\n MOSTRA_REMOTE_OWNER_OFFLINE: {\n severity: \"error\",\n phase: \"host\",\n title: \"The artifact's owner instance is offline\",\n hint: \"Start Mostra on the machine that shared the page, or try again once it is back.\",\n docs: {\n explanation:\n \"A hosted page called server code its owner instance runs, and the owner instance isn't connected. A plain call isn't kept, so it is refused at once; an action run waits or fails as the artifact's `hosted.offline` says.\",\n fix: 'Start Mostra on the owner\\'s machine (`mostra daemon start`, or `mostra daemon install` for always-on). An action that must work while the owner is away should be an action run with `hosted.offline.actions: \"queue\"`.',\n },\n },\n MOSTRA_REMOTE_QUEUE_FULL: {\n severity: \"error\",\n phase: \"host\",\n title: \"Too many runs wait for the owner\",\n hint: \"Wait for the owner to come back and work through its queue, then press again.\",\n docs: {\n explanation:\n \"The artifact's owner instance is offline and as many runs as the server allows already wait for it, so this one was refused before anything was recorded. Runs already waiting keep their place.\",\n fix: \"Bring the owner instance back online: waiting runs then go out in the order they were made. The cap is the server's `relay.waitingRunsPerArtifact` setting.\",\n },\n },\n MOSTRA_REMOTE_NOT_OWNER_INSTANCE: {\n severity: \"error\",\n phase: \"host\",\n title: \"Another instance owns this hosted artifact\",\n hint: \"Share or push this artifact from its owner instance, named in the message.\",\n docs: {\n explanation:\n \"A hosted artifact has one owner instance: the one that shared it. It alone receives the artifact's submissions, relayed runs and authoring, and only it pushes versions of it (D165 item 1b). Another instance of the same account reads and waits through the hosted home.\",\n fix: \"Run the command on the instance the message names. Moving an artifact to another owner instance isn't part of this release.\",\n },\n },\n MOSTRA_REMOTE_SIGN_IN_REQUIRED: {\n severity: \"error\",\n phase: \"host\",\n title: \"This action needs a signed-in viewer\",\n hint: \"Sign in from the page's chrome, or have the owner allow this for anyone with the link.\",\n docs: {\n explanation:\n \"On a hosted link, an action that runs on the owner's machine, or a submission when the artifact asks for it, needs a viewer signed in (D159, D165 item 13). Nothing was recorded.\",\n fix: 'Sign in with the page\\'s Sign in. An owner who wants anyone with the link to run actions sets `hosted: { actions: \"link\" }` in the manifest (and `submissions: \"link\"` for answers).',\n },\n },\n MOSTRA_REMOTE_RATE_LIMITED: {\n severity: \"error\",\n phase: \"host\",\n title: \"Too many requests on this link\",\n hint: \"Try again after the time the answer's Retry-After gives.\",\n docs: {\n explanation:\n \"Too many requests of this kind came through one link or one address in a short time, past the server's `rateLimits`. Nothing was recorded, and a draft stays as it was.\",\n fix: \"Wait for the `Retry-After` the answer carries and try again. The limits are the server's `rateLimits` settings.\",\n },\n },\n MOSTRA_REMOTE_PAUSED_BY_OPERATOR: {\n severity: \"error\",\n phase: \"host\",\n title: \"Paused by the server's operator\",\n hint: \"Contact the server's operator: only the operator resumes a pause it made.\",\n docs: {\n explanation:\n \"The server's operator paused this hosted artifact, and an owner can't undo an operator's pause (D165 item 14). Views keep working and the links stay valid.\",\n fix: \"Ask the server's operator why it was paused and to resume it.\",\n },\n },\n MOSTRA_REMOTE_LIMIT_REACHED: {\n severity: \"error\",\n phase: \"host\",\n title: \"The server's limit refused this\",\n hint: \"Read the message for the server's limit, and try again once it allows the operation.\",\n docs: {\n explanation:\n \"The server's operator refused the operation for this account (its `limits` port): a share, a version push, a link, a view, a submission, an action or an MCP call. The message is the operator's own. A refused submission keeps its draft.\",\n fix: \"Follow the operator's message; its `Retry-After`, when present, says when to try again.\",\n },\n },\n MOSTRA_REMOTE_OPERATOR_UNAVAILABLE: {\n severity: \"error\",\n phase: \"host\",\n title: \"The server's operator didn't answer\",\n hint: \"Try again in a moment; the server's operator didn't answer in time.\",\n docs: {\n explanation:\n \"The server's operator module didn't answer in time (2 s for limits, 5 s for sign-in), so an operation that creates something (a share, a push, a link, authoring, a sign-in) was refused rather than allowed blind. Views, drafts and submissions never wait for it, and existing sessions keep working.\",\n fix: \"Try again; if it lasts, the server's operator has to fix its operator module.\",\n },\n },\n MOSTRA_REMOTE_NO_INSTANCE: {\n severity: \"error\",\n phase: \"host\",\n title: \"No owner instance connected\",\n hint: \"Start Mostra on the machine linked to this account (mostra daemon start), then try again.\",\n docs: {\n explanation:\n \"Creating, verifying and publishing from a chat host run on the account's default owner instance, through the relay (D165 item 5), and no default instance is connected to the server now. Reading tools (list, wait, results, state, docs, open) keep working.\",\n fix: \"Start Mostra on the linked machine (`mostra daemon start`, or `mostra daemon install` to keep it running); link a machine first with `mostra login <server> --default`.\",\n },\n },\n MOSTRA_REMOTE_UNDER_REVIEW: {\n severity: \"error\",\n phase: \"host\",\n title: \"This page is under review\",\n hint: \"Nothing to do here: the server's operator is reviewing this page.\",\n docs: {\n explanation:\n \"The server's operator quarantined this hosted page, or this version of it, while it reviews it. Its data is kept; the page shows a neutral notice instead of its content until the operator releases it.\",\n fix: \"The owner can ask the server's operator about the review.\",\n },\n },\n MOSTRA_REMOTE_HOME_SUSPENDED: {\n severity: \"error\",\n phase: \"host\",\n title: \"This account's pages are suspended\",\n hint: \"Contact the server's operator: this account's pages are suspended.\",\n docs: {\n explanation:\n \"The server's operator suspended this account's hosted home: its pages, its owner instances' bindings, pushes and links are refused until the operator resumes it. Nothing was deleted.\",\n fix: \"Ask the server's operator to resume the account.\",\n },\n },\n MOSTRA_REMOTE_HOME_MOVING: {\n severity: \"error\",\n phase: \"host\",\n title: \"This account's pages are moving\",\n hint: \"Try again in a minute: this account's pages are moving between machines.\",\n docs: {\n explanation:\n \"The server's operator is moving this account's hosted home to another data directory (`drainHome`), so the home is closed here until it serves again. Clients retry; nothing is lost.\",\n fix: \"Retry shortly; the move ends when the operator releases the home on its new machine.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAMA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,oBAAuD;CAClE,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,4BAA4B;EAC1B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,6BAA6B;EAC3B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,0BAA0B;EACxB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,kCAAkC;EAChC,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,gCAAgC;EAC9B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,4BAA4B;EAC1B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,kCAAkC;EAChC,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,6BAA6B;EAC3B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,oCAAoC;EAClC,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,4BAA4B;EAC1B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;AAEF"}
@@ -1,7 +1,7 @@
1
1
  import "../spec.js";
2
2
  //#region src/diagnostics/codes/submit.d.ts
3
3
  /** The codes of the SUBMIT area, in the order they were added. */
4
- export declare const submitDiagnosticCodes: readonly ["MOSTRA_SUBMIT_ALREADY", "MOSTRA_SUBMIT_REVISION_MOVED", "MOSTRA_SUBMIT_POLICY_NONE", "MOSTRA_SUBMIT_NOT_FOUND", "MOSTRA_SUBMIT_VIEW_INVALID", "MOSTRA_SUBMIT_SIGNAL_INVALID", "MOSTRA_SUBMIT_CHANNEL_DENIED", "MOSTRA_SUBMIT_BLOCKED"];
4
+ export declare const submitDiagnosticCodes: readonly ["MOSTRA_SUBMIT_ALREADY", "MOSTRA_SUBMIT_REVISION_MOVED", "MOSTRA_SUBMIT_POLICY_NONE", "MOSTRA_SUBMIT_NOT_FOUND", "MOSTRA_SUBMIT_VIEW_INVALID", "MOSTRA_SUBMIT_SIGNAL_INVALID", "MOSTRA_SUBMIT_CHANNEL_DENIED", "MOSTRA_SUBMIT_BLOCKED", "MOSTRA_SUBMIT_PAUSED"];
5
5
  /** The codes of the SUBMIT area. */
6
6
  export type SubmitDiagnosticCode = (typeof submitDiagnosticCodes)[number];
7
7
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"submit.d.ts","names":[],"sources":["../../../src/diagnostics/codes/submit.ts"],"mappings":";;;qBAMa;;YAaD,+BAA+B"}
1
+ {"version":3,"file":"submit.d.ts","names":[],"sources":["../../../src/diagnostics/codes/submit.ts"],"mappings":";;;qBAMa;;YAcD,+BAA+B"}
@@ -8,7 +8,8 @@ const submitDiagnosticCodes = [
8
8
  "MOSTRA_SUBMIT_VIEW_INVALID",
9
9
  "MOSTRA_SUBMIT_SIGNAL_INVALID",
10
10
  "MOSTRA_SUBMIT_CHANNEL_DENIED",
11
- "MOSTRA_SUBMIT_BLOCKED"
11
+ "MOSTRA_SUBMIT_BLOCKED",
12
+ "MOSTRA_SUBMIT_PAUSED"
12
13
  ];
13
14
  /** The SUBMIT area's catalog entries. */
14
15
  const submitDiagnostics = {
@@ -91,6 +92,16 @@ const submitDiagnostics = {
91
92
  explanation: "Before a submit, the shell and the client runtime check every mounted field (D106): a `required` field without a value, a value its `validate` rejects, or a conflict the viewer hasn't resolved blocks the submit. The diagnostic lists the blockers with their field IDs and labels; `useSubmit().blockers` lists them before anyone submits. Nothing was submitted.",
92
93
  fix: "Show `useSubmit().blockers` next to your submit button, or let the shell list them by label. Answer the required fields, fix the invalid values, and keep or take the conflicting values, then submit again."
93
94
  }
95
+ },
96
+ MOSTRA_SUBMIT_PAUSED: {
97
+ severity: "error",
98
+ phase: "host",
99
+ title: "Artifact paused, no answers taken",
100
+ hint: "Wait until the page is resumed, then submit again; the draft is kept.",
101
+ docs: {
102
+ explanation: "The artifact is paused (`mostra pause`, or its server's operator paused it). A paused artifact stays viewable and its links stay valid, but it takes no submissions until it is resumed. Nothing was recorded, and the draft stays as it was.",
103
+ fix: "The owner resumes it with `mostra resume <artifact>`; a pause by the server's operator is resumed only by the operator."
104
+ }
94
105
  }
95
106
  };
96
107
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"submit.js","names":[],"sources":["../../../src/diagnostics/codes/submit.ts"],"sourcesContent":["/**\n * Diagnostic codes of the SUBMIT area.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the SUBMIT area, in the order they were added. */\nexport const submitDiagnosticCodes = [\n \"MOSTRA_SUBMIT_ALREADY\",\n \"MOSTRA_SUBMIT_REVISION_MOVED\",\n \"MOSTRA_SUBMIT_POLICY_NONE\",\n \"MOSTRA_SUBMIT_NOT_FOUND\",\n \"MOSTRA_SUBMIT_VIEW_INVALID\",\n \"MOSTRA_SUBMIT_SIGNAL_INVALID\",\n \"MOSTRA_SUBMIT_CHANNEL_DENIED\",\n \"MOSTRA_SUBMIT_BLOCKED\",\n // gen:codes\n] as const;\n\n/** The codes of the SUBMIT area. */\nexport type SubmitDiagnosticCode = (typeof submitDiagnosticCodes)[number];\n\n/** The SUBMIT area's catalog entries. */\nexport const submitDiagnostics: AreaCatalog<SubmitDiagnosticCode> = {\n MOSTRA_SUBMIT_ALREADY: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Already submitted\",\n hint: \"This artifact takes one submission, and it was made; read it with `mostra results`.\",\n docs: {\n explanation:\n \"The artifact's submission policy is `once`, and a submission already closed this draft: for scope `per-artifact` any viewer's submission closes every draft, for `per-viewer` the viewer's own. A submission is immutable and final, so Mostra refuses a second one and further edits to the closed draft. The refusal carries the existing submission. A repeated submit of the same view at the same draft revision is not refused: it returns the original submission.\",\n fix: 'Read the existing submission with `mostra results <artifact>`. When another round of answers is wanted, publish a new artifact linked to this one (`links: [{ rel: \"round-of\", artifact }]`), or have the host publish with the `epochs` policy.',\n },\n },\n MOSTRA_SUBMIT_REVISION_MOVED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Draft changed before submit\",\n hint: \"Reload the draft, check what changed, and submit again with its current revision.\",\n docs: {\n explanation:\n \"A submit names the draft revision the viewer saw (`expectedRevision`), and the draft has changed since: another tab, device or writer saved an edit. Mostra never makes a submission from content the viewer didn't see (FAILURE_MODEL §4), so it refuses. The message names the draft's current revision.\",\n fix: \"Let the page reload the draft so the viewer sees exactly what will be sent, then submit with the new revision. The shell and the client runtime flush pending saves before they submit, which makes this rare.\",\n },\n },\n MOSTRA_SUBMIT_POLICY_NONE: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Artifact takes no submissions\",\n hint: \"Exchange data through artifact state, actions and signals; this artifact has no submissions.\",\n docs: {\n explanation:\n \"The artifact's submission policy is `none` (D63): long-lived artifacts such as dashboards and task managers talk to agents through artifact state, actions, signals and events, and the shell shows no Submit control. Mostra refuses a submit, and a `wait --until submitted`, on such an artifact.\",\n fix: \"Wait for a signal (`--until signal:<name>`), a state change (`--until state:<field>`) or an event instead, and read state with `mostra state get`. To collect submissions, publish with policy `once` or `epochs`.\",\n },\n },\n MOSTRA_SUBMIT_NOT_FOUND: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"No such submission\",\n hint: \"Wait for a submission with `mostra wait <artifact> --until submitted`, or, when the message says the policy is none, read `mostra state get <artifact>` or wait for a signal with `--until signal:<name>`.\",\n docs: {\n explanation:\n \"The artifact has no submission yet, or none with the ID asked for. Submissions are durable once made, so this means none was made (or the ID belongs to another artifact or home). An artifact whose submission policy is `none` never has one, and the message says so: its viewers' work is in its shared state, its signals and its action runs.\",\n fix: \"Run `mostra wait <artifact> --until submitted` to block until the viewer submits, then read the results. List the artifact's submissions through `submission.created` events. Under policy `none`, read the shared state with `mostra state get <artifact>`, or wait for a signal the page raises with `mostra wait <artifact> --until signal:<name>`: its event carries the signal's payload.\",\n },\n },\n MOSTRA_SUBMIT_VIEW_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Unknown view\",\n hint: \"Send the view ID this page was opened with.\",\n docs: {\n explanation:\n \"Mutations and submits name the view they come from, the one the shell created when it opened this frame. The view named doesn't exist, belongs to another artifact, or belongs to another viewer. Mostra binds every submission to the exact version its view showed, so it refuses a view it can't place.\",\n fix: \"Use the `viewId` the shell handed this frame. A page opened outside Mostra's shell has no view and can't submit.\",\n },\n },\n MOSTRA_SUBMIT_SIGNAL_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Invalid signal\",\n hint: \"Name signals with letters, digits, `.`, `_` and `-`, and keep their payload under 64 KiB of JSON.\",\n docs: {\n explanation:\n \"A signal names something the artifact wants a host's attention for, such as `ping-agent`. Its name is 1 to 64 characters of letters, digits, `.`, `_` and `-`, starting with a letter or digit, and its payload is JSON of at most 64 KiB. This one broke one of those rules. The name `submit` is reserved for submissions.\",\n fix: \"Rename the signal or shrink its payload; put large data into a field or artifact state and send its ID in the payload.\",\n },\n },\n MOSTRA_SUBMIT_CHANNEL_DENIED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Submit channel not allowed\",\n hint: \"Let the viewer submit with the shell's trusted Submit; this host doesn't take submissions from artifact code.\",\n docs: {\n explanation:\n \"A submission comes through one of two channels (D40): the shell's trusted Submit (`shell`), which only a person can press, or the artifact's own code (`artifact`, `useSubmit().submit()` and `useChoice().choose()`). The host decides which it accepts (D108): through `HomeConfig.submitChannels` for the home, or its `trustedControls` port for each artifact. This view allows only the other channel, so Mostra refused the submit or the choice. `useSubmit().allowed` is `false` in such a view.\",\n fix: \"Ask the viewer to press the shell's Submit (relabel it with `useSubmitControl`), and use `useChoice(id, { candidates })` to have the shell render a trusted Choose. Check `allowed` before showing an in-page submit button.\",\n },\n },\n MOSTRA_SUBMIT_BLOCKED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Answers missing before submit\",\n hint: \"Fill in the fields this diagnostic lists, fix their errors or resolve their conflicts, then submit again.\",\n docs: {\n explanation:\n \"Before a submit, the shell and the client runtime check every mounted field (D106): a `required` field without a value, a value its `validate` rejects, or a conflict the viewer hasn't resolved blocks the submit. The diagnostic lists the blockers with their field IDs and labels; `useSubmit().blockers` lists them before anyone submits. Nothing was submitted.\",\n fix: \"Show `useSubmit().blockers` next to your submit button, or let the shell list them by label. Answer the required fields, fix the invalid values, and keep or take the conflicting values, then submit again.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAMA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,oBAAuD;CAClE,uBAAuB;EACrB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,yBAAyB;EACvB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,4BAA4B;EAC1B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,uBAAuB;EACrB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;AAEF"}
1
+ {"version":3,"file":"submit.js","names":[],"sources":["../../../src/diagnostics/codes/submit.ts"],"sourcesContent":["/**\n * Diagnostic codes of the SUBMIT area.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the SUBMIT area, in the order they were added. */\nexport const submitDiagnosticCodes = [\n \"MOSTRA_SUBMIT_ALREADY\",\n \"MOSTRA_SUBMIT_REVISION_MOVED\",\n \"MOSTRA_SUBMIT_POLICY_NONE\",\n \"MOSTRA_SUBMIT_NOT_FOUND\",\n \"MOSTRA_SUBMIT_VIEW_INVALID\",\n \"MOSTRA_SUBMIT_SIGNAL_INVALID\",\n \"MOSTRA_SUBMIT_CHANNEL_DENIED\",\n \"MOSTRA_SUBMIT_BLOCKED\",\n \"MOSTRA_SUBMIT_PAUSED\",\n // gen:codes\n] as const;\n\n/** The codes of the SUBMIT area. */\nexport type SubmitDiagnosticCode = (typeof submitDiagnosticCodes)[number];\n\n/** The SUBMIT area's catalog entries. */\nexport const submitDiagnostics: AreaCatalog<SubmitDiagnosticCode> = {\n MOSTRA_SUBMIT_ALREADY: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Already submitted\",\n hint: \"This artifact takes one submission, and it was made; read it with `mostra results`.\",\n docs: {\n explanation:\n \"The artifact's submission policy is `once`, and a submission already closed this draft: for scope `per-artifact` any viewer's submission closes every draft, for `per-viewer` the viewer's own. A submission is immutable and final, so Mostra refuses a second one and further edits to the closed draft. The refusal carries the existing submission. A repeated submit of the same view at the same draft revision is not refused: it returns the original submission.\",\n fix: 'Read the existing submission with `mostra results <artifact>`. When another round of answers is wanted, publish a new artifact linked to this one (`links: [{ rel: \"round-of\", artifact }]`), or have the host publish with the `epochs` policy.',\n },\n },\n MOSTRA_SUBMIT_REVISION_MOVED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Draft changed before submit\",\n hint: \"Reload the draft, check what changed, and submit again with its current revision.\",\n docs: {\n explanation:\n \"A submit names the draft revision the viewer saw (`expectedRevision`), and the draft has changed since: another tab, device or writer saved an edit. Mostra never makes a submission from content the viewer didn't see (FAILURE_MODEL §4), so it refuses. The message names the draft's current revision.\",\n fix: \"Let the page reload the draft so the viewer sees exactly what will be sent, then submit with the new revision. The shell and the client runtime flush pending saves before they submit, which makes this rare.\",\n },\n },\n MOSTRA_SUBMIT_POLICY_NONE: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Artifact takes no submissions\",\n hint: \"Exchange data through artifact state, actions and signals; this artifact has no submissions.\",\n docs: {\n explanation:\n \"The artifact's submission policy is `none` (D63): long-lived artifacts such as dashboards and task managers talk to agents through artifact state, actions, signals and events, and the shell shows no Submit control. Mostra refuses a submit, and a `wait --until submitted`, on such an artifact.\",\n fix: \"Wait for a signal (`--until signal:<name>`), a state change (`--until state:<field>`) or an event instead, and read state with `mostra state get`. To collect submissions, publish with policy `once` or `epochs`.\",\n },\n },\n MOSTRA_SUBMIT_NOT_FOUND: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"No such submission\",\n hint: \"Wait for a submission with `mostra wait <artifact> --until submitted`, or, when the message says the policy is none, read `mostra state get <artifact>` or wait for a signal with `--until signal:<name>`.\",\n docs: {\n explanation:\n \"The artifact has no submission yet, or none with the ID asked for. Submissions are durable once made, so this means none was made (or the ID belongs to another artifact or home). An artifact whose submission policy is `none` never has one, and the message says so: its viewers' work is in its shared state, its signals and its action runs.\",\n fix: \"Run `mostra wait <artifact> --until submitted` to block until the viewer submits, then read the results. List the artifact's submissions through `submission.created` events. Under policy `none`, read the shared state with `mostra state get <artifact>`, or wait for a signal the page raises with `mostra wait <artifact> --until signal:<name>`: its event carries the signal's payload.\",\n },\n },\n MOSTRA_SUBMIT_VIEW_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Unknown view\",\n hint: \"Send the view ID this page was opened with.\",\n docs: {\n explanation:\n \"Mutations and submits name the view they come from, the one the shell created when it opened this frame. The view named doesn't exist, belongs to another artifact, or belongs to another viewer. Mostra binds every submission to the exact version its view showed, so it refuses a view it can't place.\",\n fix: \"Use the `viewId` the shell handed this frame. A page opened outside Mostra's shell has no view and can't submit.\",\n },\n },\n MOSTRA_SUBMIT_SIGNAL_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Invalid signal\",\n hint: \"Name signals with letters, digits, `.`, `_` and `-`, and keep their payload under 64 KiB of JSON.\",\n docs: {\n explanation:\n \"A signal names something the artifact wants a host's attention for, such as `ping-agent`. Its name is 1 to 64 characters of letters, digits, `.`, `_` and `-`, starting with a letter or digit, and its payload is JSON of at most 64 KiB. This one broke one of those rules. The name `submit` is reserved for submissions.\",\n fix: \"Rename the signal or shrink its payload; put large data into a field or artifact state and send its ID in the payload.\",\n },\n },\n MOSTRA_SUBMIT_CHANNEL_DENIED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Submit channel not allowed\",\n hint: \"Let the viewer submit with the shell's trusted Submit; this host doesn't take submissions from artifact code.\",\n docs: {\n explanation:\n \"A submission comes through one of two channels (D40): the shell's trusted Submit (`shell`), which only a person can press, or the artifact's own code (`artifact`, `useSubmit().submit()` and `useChoice().choose()`). The host decides which it accepts (D108): through `HomeConfig.submitChannels` for the home, or its `trustedControls` port for each artifact. This view allows only the other channel, so Mostra refused the submit or the choice. `useSubmit().allowed` is `false` in such a view.\",\n fix: \"Ask the viewer to press the shell's Submit (relabel it with `useSubmitControl`), and use `useChoice(id, { candidates })` to have the shell render a trusted Choose. Check `allowed` before showing an in-page submit button.\",\n },\n },\n MOSTRA_SUBMIT_BLOCKED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Answers missing before submit\",\n hint: \"Fill in the fields this diagnostic lists, fix their errors or resolve their conflicts, then submit again.\",\n docs: {\n explanation:\n \"Before a submit, the shell and the client runtime check every mounted field (D106): a `required` field without a value, a value its `validate` rejects, or a conflict the viewer hasn't resolved blocks the submit. The diagnostic lists the blockers with their field IDs and labels; `useSubmit().blockers` lists them before anyone submits. Nothing was submitted.\",\n fix: \"Show `useSubmit().blockers` next to your submit button, or let the shell list them by label. Answer the required fields, fix the invalid values, and keep or take the conflicting values, then submit again.\",\n },\n },\n MOSTRA_SUBMIT_PAUSED: {\n severity: \"error\",\n phase: \"host\",\n title: \"Artifact paused, no answers taken\",\n hint: \"Wait until the page is resumed, then submit again; the draft is kept.\",\n docs: {\n explanation:\n \"The artifact is paused (`mostra pause`, or its server's operator paused it). A paused artifact stays viewable and its links stay valid, but it takes no submissions until it is resumed. Nothing was recorded, and the draft stays as it was.\",\n fix: \"The owner resumes it with `mostra resume <artifact>`; a pause by the server's operator is resumed only by the operator.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAMA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,oBAAuD;CAClE,uBAAuB;EACrB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,yBAAyB;EACvB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,4BAA4B;EAC1B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,uBAAuB;EACrB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,sBAAsB;EACpB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;AAEF"}
@@ -4,7 +4,7 @@ import * as z from "zod";
4
4
  * Diagnostic areas. A code is `MOSTRA_<AREA>_<NAME>`. INTERFACES §13 holds the authoritative list,
5
5
  * which only grows.
6
6
  */
7
- export type DiagnosticArea = "MANIFEST" | "BUILD" | "TYPE" | "LINT" | "DEP" | "KIT" | "FIELD" | "ACTION" | "LIVE" | "RUNTIME" | "CONSOLE" | "NETWORK" | "A11Y" | "VISUAL" | "SMOKE" | "REGRESSION" | "TERM" | "PUBLISH" | "SUBMIT" | "HOST" | "HOME" | "HYGIENE" | "SECRET" | "SHARE" | "VERIFY" | "TARGET" | "ENV" | "PLATFORM" | "ARTIFACT" | "CLI";
7
+ export type DiagnosticArea = "MANIFEST" | "BUILD" | "TYPE" | "LINT" | "DEP" | "KIT" | "FIELD" | "ACTION" | "LIVE" | "RUNTIME" | "CONSOLE" | "NETWORK" | "A11Y" | "VISUAL" | "SMOKE" | "REGRESSION" | "TERM" | "PUBLISH" | "SUBMIT" | "HOST" | "HOME" | "HYGIENE" | "SECRET" | "SHARE" | "VERIFY" | "TARGET" | "ENV" | "PLATFORM" | "ARTIFACT" | "CLI" | "REMOTE";
8
8
  /** Every diagnostic area, in INTERFACES §13 order. */
9
9
  export declare const DIAGNOSTIC_AREAS: readonly DiagnosticArea[];
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostic.d.ts","names":[],"sources":["../../src/diagnostics/diagnostic.ts"],"mappings":";;;;;;YAWY;;qBAiCC,2BAA2B;;;;;YAqC5B,2BAA2B;;;;;YAM3B;;YAGA;;;;;iBAqBK;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC;WACG;WAAuB;WAAuB;;WAC9C;WAA2B;;;iBAGzB;;WAEN,MAAM;;WAEN,UAAU;;WAEV;;WAEA;;WAEA,MAAM;;WAEN,WAAW;;WAEX,OAAO;;WAEP;;WAEA;;;qBAkBE,oBAAoB,EAAE,QAAQ;;qBAQ9B,iBAAiB,EAAE,QAAQ;;qBAwB3B,eAAe,EAAE,QAAQ;;qBAezB,oBAAoB,EAAE,QAAQ;;qBAW9B,YAAY,EAAE,QAAQ"}
1
+ {"version":3,"file":"diagnostic.d.ts","names":[],"sources":["../../src/diagnostics/diagnostic.ts"],"mappings":";;;;;;YAWY;;qBAkCC,2BAA2B;;;;;YAsC5B,2BAA2B;;;;;YAM3B;;YAGA;;;;;iBAqBK;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC;WACG;WAAuB;WAAuB;;WAC9C;WAA2B;;;iBAGzB;;WAEN,MAAM;;WAEN,UAAU;;WAEV;;WAEA;;WAEA,MAAM;;WAEN,WAAW;;WAEX,OAAO;;WAEP;;WAEA;;;qBAkBE,oBAAoB,EAAE,QAAQ;;qBAQ9B,iBAAiB,EAAE,QAAQ;;qBAwB3B,eAAe,EAAE,QAAQ;;qBAezB,oBAAoB,EAAE,QAAQ;;qBAW9B,YAAY,EAAE,QAAQ"}
@@ -36,7 +36,8 @@ const DIAGNOSTIC_AREAS = [
36
36
  "ENV",
37
37
  "PLATFORM",
38
38
  "ARTIFACT",
39
- "CLI"
39
+ "CLI",
40
+ "REMOTE"
40
41
  ];
41
42
  const positiveInt = z.int().min(1);
42
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostic.js","names":[],"sources":["../../src/diagnostics/diagnostic.ts"],"sourcesContent":["/**\n * The one diagnostic object every Mostra interface uses for errors, warnings and hints\n * (INTERFACES §1 and §13, AX-03).\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"../wire-registry.ts\";\n\n/**\n * Diagnostic areas. A code is `MOSTRA_<AREA>_<NAME>`. INTERFACES §13 holds the authoritative list,\n * which only grows.\n */\nexport type DiagnosticArea =\n | \"MANIFEST\"\n | \"BUILD\"\n | \"TYPE\"\n | \"LINT\"\n | \"DEP\"\n | \"KIT\"\n | \"FIELD\"\n | \"ACTION\"\n | \"LIVE\"\n | \"RUNTIME\"\n | \"CONSOLE\"\n | \"NETWORK\"\n | \"A11Y\"\n | \"VISUAL\"\n | \"SMOKE\"\n | \"REGRESSION\"\n | \"TERM\"\n | \"PUBLISH\"\n | \"SUBMIT\"\n | \"HOST\"\n | \"HOME\"\n | \"HYGIENE\"\n | \"SECRET\"\n | \"SHARE\"\n | \"VERIFY\"\n | \"TARGET\"\n | \"ENV\"\n | \"PLATFORM\"\n | \"ARTIFACT\"\n | \"CLI\";\n\n/** Every diagnostic area, in INTERFACES §13 order. */\nexport const DIAGNOSTIC_AREAS: readonly DiagnosticArea[] = [\n \"MANIFEST\",\n \"BUILD\",\n \"TYPE\",\n \"LINT\",\n \"DEP\",\n \"KIT\",\n \"FIELD\",\n \"ACTION\",\n \"LIVE\",\n \"RUNTIME\",\n \"CONSOLE\",\n \"NETWORK\",\n \"A11Y\",\n \"VISUAL\",\n \"SMOKE\",\n \"REGRESSION\",\n \"TERM\",\n \"PUBLISH\",\n \"SUBMIT\",\n \"HOST\",\n \"HOME\",\n \"HYGIENE\",\n \"SECRET\",\n \"SHARE\",\n \"VERIFY\",\n \"TARGET\",\n \"ENV\",\n \"PLATFORM\",\n \"ARTIFACT\",\n \"CLI\",\n];\n\n/**\n * A diagnostic code. Codes are semver surface: once released, a code keeps its meaning and is\n * never removed (AX-03).\n */\nexport type DiagnosticCode = `MOSTRA_${DiagnosticArea}_${string}`;\n\n/**\n * How bad it is. `error` is only for definite failures; observations that might be fine are\n * warnings (D72).\n */\nexport type DiagnosticSeverity = \"error\" | \"warning\" | \"hint\";\n\n/** The stage of work that produced the diagnostic. */\nexport type DiagnosticPhase =\n | \"manifest\"\n | \"compile\"\n | \"lint\"\n | \"runtime\"\n | \"console\"\n | \"network\"\n | \"a11y\"\n | \"visual\"\n | \"smoke\"\n | \"regression\"\n | \"contract\"\n | \"publish\"\n | \"host\"\n | \"hygiene\"\n | \"platform\";\n\n/**\n * A machine-applicable fix. `range` is `[startLine, startColumn, endLine, endColumn]`, 1-based,\n * with the end exclusive.\n */\nexport interface DiagnosticFix {\n /** Replace, insert or delete text in `file`, or run `command`. */\n readonly kind: \"replace\" | \"insert\" | \"delete\" | \"command\";\n /** The file to edit, relative to the artifact or project root. */\n readonly file?: string;\n /** The span to edit. */\n readonly range?: readonly [number, number, number, number];\n /** The replacement or inserted text. */\n readonly text?: string;\n /** The command to run, for `kind: \"command\"`. */\n readonly command?: string;\n}\n\n/** Where the problem is: a source position (1-based) or a place in a rendered viewport. */\nexport type DiagnosticLocation =\n | { readonly file: string; readonly line: number; readonly column: number }\n | { readonly viewport: string; readonly selector?: string };\n\n/** One diagnostic (INTERFACES §13). */\nexport interface Diagnostic {\n /** The stable code, `MOSTRA_<AREA>_<NAME>`. */\n readonly code: DiagnosticCode;\n /** How bad it is. */\n readonly severity: DiagnosticSeverity;\n /** What is wrong, for this occurrence. */\n readonly message: string;\n /** What to do: one imperative sentence. */\n readonly hint?: string;\n /** A machine-applicable fix, when one exists. */\n readonly fix?: DiagnosticFix;\n /** Where the problem is, when it has a place. */\n readonly location?: DiagnosticLocation;\n /** The stage of work that produced it. */\n readonly phase: DiagnosticPhase;\n /** The code's documentation page: `${docsBase}/errors/${code}` (D37). */\n readonly docs: string;\n /** How many identical occurrences this one stands for, when deduplicated. */\n readonly count?: number;\n}\n\nconst positiveInt = z.int().min(1);\n\n/**\n * Codes on the wire accept any area, so a client keeps working when a newer Mostra reports a code\n * from an area it doesn't know yet. Producers are typed against {@link DiagnosticArea}.\n */\nconst codeSchema = z\n .string()\n .regex(/^MOSTRA_[A-Z0-9]+_[A-Z0-9_]+$/)\n .register(wireRegistry, {\n id: \"DiagnosticCode\",\n description: \"Stable diagnostic code: MOSTRA_<AREA>_<NAME>.\",\n }) as unknown as z.ZodType<DiagnosticCode, string>;\n\n/** The Zod schema of the `DiagnosticSeverity` type. */\nexport const DiagnosticSeverity: z.ZodType<DiagnosticSeverity, string> = z\n .enum([\"error\", \"warning\", \"hint\"])\n .register(wireRegistry, {\n id: \"DiagnosticSeverity\",\n description: \"How bad it is: error only for definite failures.\",\n });\n\n/** The Zod schema of the `DiagnosticPhase` type. */\nexport const DiagnosticPhase: z.ZodType<DiagnosticPhase, string> = z\n .enum([\n \"manifest\",\n \"compile\",\n \"lint\",\n \"runtime\",\n \"console\",\n \"network\",\n \"a11y\",\n \"visual\",\n \"smoke\",\n \"regression\",\n \"contract\",\n \"publish\",\n \"host\",\n \"hygiene\",\n \"platform\",\n ])\n .register(wireRegistry, {\n id: \"DiagnosticPhase\",\n description: \"The stage of work that produced the diagnostic.\",\n });\n\n/** The Zod schema of the `DiagnosticFix` type. */\nexport const DiagnosticFix: z.ZodType<DiagnosticFix> = z\n .object({\n kind: z.enum([\"replace\", \"insert\", \"delete\", \"command\"]),\n file: z.string().exactOptional(),\n range: z.tuple([positiveInt, positiveInt, positiveInt, positiveInt]).readonly().exactOptional(),\n text: z.string().exactOptional(),\n command: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"DiagnosticFix\",\n description:\n \"A machine-applicable fix; range is [startLine, startColumn, endLine, endColumn], 1-based, end exclusive.\",\n });\n\n/** The Zod schema of the `DiagnosticLocation` type. */\nexport const DiagnosticLocation: z.ZodType<DiagnosticLocation> = z\n .union([\n z.object({ file: z.string(), line: positiveInt, column: positiveInt }),\n z.object({ viewport: z.string(), selector: z.string().exactOptional() }),\n ])\n .register(wireRegistry, {\n id: \"DiagnosticLocation\",\n description: \"A 1-based source position, or a place in a rendered viewport.\",\n });\n\n/** The Zod schema of the `Diagnostic` type. */\nexport const Diagnostic: z.ZodType<Diagnostic> = z\n .object({\n code: codeSchema,\n severity: DiagnosticSeverity,\n message: z.string(),\n hint: z.string().exactOptional(),\n fix: DiagnosticFix.exactOptional(),\n location: DiagnosticLocation.exactOptional(),\n phase: DiagnosticPhase,\n docs: z.url(),\n count: positiveInt.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Diagnostic\",\n description: \"One diagnostic: a stable code, severity, message, hint, fix and docs link.\",\n });\n"],"mappings":";;;;;;;;AA4CA,MAAa,mBAA8C;CACzD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AA4EA,MAAM,cAAc,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;;;;;AAMjC,MAAM,aAAa,EAChB,OAAO,CAAC,CACR,MAAM,+BAA+B,CAAC,CACtC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,qBAA4D,EACtE,KAAK;CAAC;CAAS;CAAW;AAAM,CAAC,CAAC,CAClC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,kBAAsD,EAChE,KAAK;CACJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,gBAA0C,EACpD,OAAO;CACN,MAAM,EAAE,KAAK;EAAC;EAAW;EAAU;EAAU;CAAS,CAAC;CACvD,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,OAAO,EAAE,MAAM;EAAC;EAAa;EAAa;EAAa;CAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CAC9F,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,SAAS,EAAE,OAAO,CAAC,CAAC,cAAc;AACpC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AAGH,MAAa,qBAAoD,EAC9D,MAAM,CACL,EAAE,OAAO;CAAE,MAAM,EAAE,OAAO;CAAG,MAAM;CAAa,QAAQ;AAAY,CAAC,GACrE,EAAE,OAAO;CAAE,UAAU,EAAE,OAAO;CAAG,UAAU,EAAE,OAAO,CAAC,CAAC,cAAc;AAAE,CAAC,CACzE,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,aAAoC,EAC9C,OAAO;CACN,MAAM;CACN,UAAU;CACV,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,KAAK,cAAc,cAAc;CACjC,UAAU,mBAAmB,cAAc;CAC3C,OAAO;CACP,MAAM,EAAE,IAAI;CACZ,OAAO,YAAY,cAAc;AACnC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC"}
1
+ {"version":3,"file":"diagnostic.js","names":[],"sources":["../../src/diagnostics/diagnostic.ts"],"sourcesContent":["/**\n * The one diagnostic object every Mostra interface uses for errors, warnings and hints\n * (INTERFACES §1 and §13, AX-03).\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"../wire-registry.ts\";\n\n/**\n * Diagnostic areas. A code is `MOSTRA_<AREA>_<NAME>`. INTERFACES §13 holds the authoritative list,\n * which only grows.\n */\nexport type DiagnosticArea =\n | \"MANIFEST\"\n | \"BUILD\"\n | \"TYPE\"\n | \"LINT\"\n | \"DEP\"\n | \"KIT\"\n | \"FIELD\"\n | \"ACTION\"\n | \"LIVE\"\n | \"RUNTIME\"\n | \"CONSOLE\"\n | \"NETWORK\"\n | \"A11Y\"\n | \"VISUAL\"\n | \"SMOKE\"\n | \"REGRESSION\"\n | \"TERM\"\n | \"PUBLISH\"\n | \"SUBMIT\"\n | \"HOST\"\n | \"HOME\"\n | \"HYGIENE\"\n | \"SECRET\"\n | \"SHARE\"\n | \"VERIFY\"\n | \"TARGET\"\n | \"ENV\"\n | \"PLATFORM\"\n | \"ARTIFACT\"\n | \"CLI\"\n | \"REMOTE\";\n\n/** Every diagnostic area, in INTERFACES §13 order. */\nexport const DIAGNOSTIC_AREAS: readonly DiagnosticArea[] = [\n \"MANIFEST\",\n \"BUILD\",\n \"TYPE\",\n \"LINT\",\n \"DEP\",\n \"KIT\",\n \"FIELD\",\n \"ACTION\",\n \"LIVE\",\n \"RUNTIME\",\n \"CONSOLE\",\n \"NETWORK\",\n \"A11Y\",\n \"VISUAL\",\n \"SMOKE\",\n \"REGRESSION\",\n \"TERM\",\n \"PUBLISH\",\n \"SUBMIT\",\n \"HOST\",\n \"HOME\",\n \"HYGIENE\",\n \"SECRET\",\n \"SHARE\",\n \"VERIFY\",\n \"TARGET\",\n \"ENV\",\n \"PLATFORM\",\n \"ARTIFACT\",\n \"CLI\",\n \"REMOTE\",\n];\n\n/**\n * A diagnostic code. Codes are semver surface: once released, a code keeps its meaning and is\n * never removed (AX-03).\n */\nexport type DiagnosticCode = `MOSTRA_${DiagnosticArea}_${string}`;\n\n/**\n * How bad it is. `error` is only for definite failures; observations that might be fine are\n * warnings (D72).\n */\nexport type DiagnosticSeverity = \"error\" | \"warning\" | \"hint\";\n\n/** The stage of work that produced the diagnostic. */\nexport type DiagnosticPhase =\n | \"manifest\"\n | \"compile\"\n | \"lint\"\n | \"runtime\"\n | \"console\"\n | \"network\"\n | \"a11y\"\n | \"visual\"\n | \"smoke\"\n | \"regression\"\n | \"contract\"\n | \"publish\"\n | \"host\"\n | \"hygiene\"\n | \"platform\";\n\n/**\n * A machine-applicable fix. `range` is `[startLine, startColumn, endLine, endColumn]`, 1-based,\n * with the end exclusive.\n */\nexport interface DiagnosticFix {\n /** Replace, insert or delete text in `file`, or run `command`. */\n readonly kind: \"replace\" | \"insert\" | \"delete\" | \"command\";\n /** The file to edit, relative to the artifact or project root. */\n readonly file?: string;\n /** The span to edit. */\n readonly range?: readonly [number, number, number, number];\n /** The replacement or inserted text. */\n readonly text?: string;\n /** The command to run, for `kind: \"command\"`. */\n readonly command?: string;\n}\n\n/** Where the problem is: a source position (1-based) or a place in a rendered viewport. */\nexport type DiagnosticLocation =\n | { readonly file: string; readonly line: number; readonly column: number }\n | { readonly viewport: string; readonly selector?: string };\n\n/** One diagnostic (INTERFACES §13). */\nexport interface Diagnostic {\n /** The stable code, `MOSTRA_<AREA>_<NAME>`. */\n readonly code: DiagnosticCode;\n /** How bad it is. */\n readonly severity: DiagnosticSeverity;\n /** What is wrong, for this occurrence. */\n readonly message: string;\n /** What to do: one imperative sentence. */\n readonly hint?: string;\n /** A machine-applicable fix, when one exists. */\n readonly fix?: DiagnosticFix;\n /** Where the problem is, when it has a place. */\n readonly location?: DiagnosticLocation;\n /** The stage of work that produced it. */\n readonly phase: DiagnosticPhase;\n /** The code's documentation page: `${docsBase}/errors/${code}` (D37). */\n readonly docs: string;\n /** How many identical occurrences this one stands for, when deduplicated. */\n readonly count?: number;\n}\n\nconst positiveInt = z.int().min(1);\n\n/**\n * Codes on the wire accept any area, so a client keeps working when a newer Mostra reports a code\n * from an area it doesn't know yet. Producers are typed against {@link DiagnosticArea}.\n */\nconst codeSchema = z\n .string()\n .regex(/^MOSTRA_[A-Z0-9]+_[A-Z0-9_]+$/)\n .register(wireRegistry, {\n id: \"DiagnosticCode\",\n description: \"Stable diagnostic code: MOSTRA_<AREA>_<NAME>.\",\n }) as unknown as z.ZodType<DiagnosticCode, string>;\n\n/** The Zod schema of the `DiagnosticSeverity` type. */\nexport const DiagnosticSeverity: z.ZodType<DiagnosticSeverity, string> = z\n .enum([\"error\", \"warning\", \"hint\"])\n .register(wireRegistry, {\n id: \"DiagnosticSeverity\",\n description: \"How bad it is: error only for definite failures.\",\n });\n\n/** The Zod schema of the `DiagnosticPhase` type. */\nexport const DiagnosticPhase: z.ZodType<DiagnosticPhase, string> = z\n .enum([\n \"manifest\",\n \"compile\",\n \"lint\",\n \"runtime\",\n \"console\",\n \"network\",\n \"a11y\",\n \"visual\",\n \"smoke\",\n \"regression\",\n \"contract\",\n \"publish\",\n \"host\",\n \"hygiene\",\n \"platform\",\n ])\n .register(wireRegistry, {\n id: \"DiagnosticPhase\",\n description: \"The stage of work that produced the diagnostic.\",\n });\n\n/** The Zod schema of the `DiagnosticFix` type. */\nexport const DiagnosticFix: z.ZodType<DiagnosticFix> = z\n .object({\n kind: z.enum([\"replace\", \"insert\", \"delete\", \"command\"]),\n file: z.string().exactOptional(),\n range: z.tuple([positiveInt, positiveInt, positiveInt, positiveInt]).readonly().exactOptional(),\n text: z.string().exactOptional(),\n command: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"DiagnosticFix\",\n description:\n \"A machine-applicable fix; range is [startLine, startColumn, endLine, endColumn], 1-based, end exclusive.\",\n });\n\n/** The Zod schema of the `DiagnosticLocation` type. */\nexport const DiagnosticLocation: z.ZodType<DiagnosticLocation> = z\n .union([\n z.object({ file: z.string(), line: positiveInt, column: positiveInt }),\n z.object({ viewport: z.string(), selector: z.string().exactOptional() }),\n ])\n .register(wireRegistry, {\n id: \"DiagnosticLocation\",\n description: \"A 1-based source position, or a place in a rendered viewport.\",\n });\n\n/** The Zod schema of the `Diagnostic` type. */\nexport const Diagnostic: z.ZodType<Diagnostic> = z\n .object({\n code: codeSchema,\n severity: DiagnosticSeverity,\n message: z.string(),\n hint: z.string().exactOptional(),\n fix: DiagnosticFix.exactOptional(),\n location: DiagnosticLocation.exactOptional(),\n phase: DiagnosticPhase,\n docs: z.url(),\n count: positiveInt.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Diagnostic\",\n description: \"One diagnostic: a stable code, severity, message, hint, fix and docs link.\",\n });\n"],"mappings":";;;;;;;;AA6CA,MAAa,mBAA8C;CACzD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AA4EA,MAAM,cAAc,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;;;;;AAMjC,MAAM,aAAa,EAChB,OAAO,CAAC,CACR,MAAM,+BAA+B,CAAC,CACtC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,qBAA4D,EACtE,KAAK;CAAC;CAAS;CAAW;AAAM,CAAC,CAAC,CAClC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,kBAAsD,EAChE,KAAK;CACJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,gBAA0C,EACpD,OAAO;CACN,MAAM,EAAE,KAAK;EAAC;EAAW;EAAU;EAAU;CAAS,CAAC;CACvD,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,OAAO,EAAE,MAAM;EAAC;EAAa;EAAa;EAAa;CAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CAC9F,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,SAAS,EAAE,OAAO,CAAC,CAAC,cAAc;AACpC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AAGH,MAAa,qBAAoD,EAC9D,MAAM,CACL,EAAE,OAAO;CAAE,MAAM,EAAE,OAAO;CAAG,MAAM;CAAa,QAAQ;AAAY,CAAC,GACrE,EAAE,OAAO;CAAE,UAAU,EAAE,OAAO;CAAG,UAAU,EAAE,OAAO,CAAC,CAAC,cAAc;AAAE,CAAC,CACzE,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,aAAoC,EAC9C,OAAO;CACN,MAAM;CACN,UAAU;CACV,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,KAAK,cAAc,cAAc;CACjC,UAAU,mBAAmB,cAAc;CAC3C,OAAO;CACP,MAAM,EAAE,IAAI;CACZ,OAAO,YAAY,cAAc;AACnC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC"}
@@ -0,0 +1,13 @@
1
+ import * as z from "zod";
2
+ //#region src/duration.d.ts
3
+ /**
4
+ * A duration: a positive whole number and a unit, `s`, `m`, `h` or `d` (`30m`, `24h`, `7d`), as
5
+ * INTERFACES §1 writes durations in flags and manifests.
6
+ */
7
+ export type Duration = `${number}${"s" | "m" | "h" | "d"}`;
8
+ /** The Zod schema of the `Duration` type. */
9
+ export declare const Duration: z.ZodType<Duration>;
10
+ /** The length of a `Duration` in milliseconds. */
11
+ export declare function durationMs(duration: Duration): number;
12
+ //#endregion
13
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","names":[],"sources":["../src/duration.ts"],"mappings":";;;;;;YAWY;;qBAGC,UAAU,EAAE,QAAQ;;wBAWjB,WAAW,UAAU"}
@@ -0,0 +1,27 @@
1
+ import { wireRegistry } from "./wire-registry.js";
2
+ import * as z from "zod";
3
+ //#region src/duration.ts
4
+ /**
5
+ * Durations as INTERFACES §1 writes them in flags and manifests: a module of its own, so the
6
+ * manifest and capability links share it without either pulling the other into a browser bundle.
7
+ */
8
+ /** The Zod schema of the `Duration` type. */
9
+ const Duration = z.string().regex(/^[1-9][0-9]{0,8}[smhd]$/).register(wireRegistry, {
10
+ id: "Duration",
11
+ description: "A duration: a positive whole number and s, m, h or d, such as 30m, 24h or 7d."
12
+ });
13
+ const UNIT_MS = {
14
+ s: 1e3,
15
+ m: 6e4,
16
+ h: 36e5,
17
+ d: 864e5
18
+ };
19
+ /** The length of a `Duration` in milliseconds. */
20
+ function durationMs(duration) {
21
+ const unit = duration.slice(-1);
22
+ return Number(duration.slice(0, -1)) * UNIT_MS[unit];
23
+ }
24
+ //#endregion
25
+ export { Duration, durationMs };
26
+
27
+ //# sourceMappingURL=duration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.js","names":[],"sources":["../src/duration.ts"],"sourcesContent":["/**\n * Durations as INTERFACES §1 writes them in flags and manifests: a module of its own, so the\n * manifest and capability links share it without either pulling the other into a browser bundle.\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/**\n * A duration: a positive whole number and a unit, `s`, `m`, `h` or `d` (`30m`, `24h`, `7d`), as\n * INTERFACES §1 writes durations in flags and manifests.\n */\nexport type Duration = `${number}${\"s\" | \"m\" | \"h\" | \"d\"}`;\n\n/** The Zod schema of the `Duration` type. */\nexport const Duration: z.ZodType<Duration> = z\n .string()\n .regex(/^[1-9][0-9]{0,8}[smhd]$/)\n .register(wireRegistry, {\n id: \"Duration\",\n description: \"A duration: a positive whole number and s, m, h or d, such as 30m, 24h or 7d.\",\n }) as z.ZodType<Duration>;\n\nconst UNIT_MS = { s: 1_000, m: 60_000, h: 3_600_000, d: 86_400_000 } as const;\n\n/** The length of a `Duration` in milliseconds. */\nexport function durationMs(duration: Duration): number {\n const unit = duration.slice(-1) as keyof typeof UNIT_MS;\n return Number(duration.slice(0, -1)) * UNIT_MS[unit];\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,WAAgC,EAC1C,OAAO,CAAC,CACR,MAAM,yBAAyB,CAAC,CAChC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;AAEH,MAAM,UAAU;CAAE,GAAG;CAAO,GAAG;CAAQ,GAAG;CAAW,GAAG;AAAW;;AAGnE,SAAgB,WAAW,UAA4B;CACrD,MAAM,OAAO,SAAS,MAAM,EAAE;CAC9B,OAAO,OAAO,SAAS,MAAM,GAAG,EAAE,CAAC,IAAI,QAAQ;AACjD"}
package/dist/ids.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as z from "zod";
2
2
  //#region src/ids.d.ts
3
3
  /** The prefixes INTERFACES §1 assigns, one per entity. */
4
- export type IdPrefix = "art" | "ver" | "vw" | "vwr" | "sub" | "dlv" | "run" | "thr" | "cmt" | "tok" | "mut" | "shr";
4
+ export type IdPrefix = "art" | "ver" | "vw" | "vwr" | "sub" | "dlv" | "run" | "thr" | "cmt" | "tok" | "mut" | "shr" | "acct" | "hom" | "lnk" | "rte";
5
5
  /**
6
6
  * A branded ID string. The brand exists only at the type level, so an `Id<"art">` is a plain
7
7
  * string at run time and on the wire.
@@ -101,6 +101,22 @@ export declare const MutationId: GeneratedIdKind<"mut">;
101
101
  export type ShareId = Id<"shr">;
102
102
  /** Share IDs. */
103
103
  export declare const ShareId: GeneratedIdKind<"shr">;
104
+ /** An account on a remote server (`acct_` + ULID, D165 item 8). */
105
+ export type AccountId = Id<"acct">;
106
+ /** Account IDs. */
107
+ export declare const AccountId: GeneratedIdKind<"acct">;
108
+ /** A hosted home on a remote server (`hom_` + ULID, D165 item 1). */
109
+ export type HomeId = Id<"hom">;
110
+ /** Hosted home IDs. */
111
+ export declare const HomeId: GeneratedIdKind<"hom">;
112
+ /** An instance linked to a remote server (`lnk_` + ULID, D165 item 2): its owner link. */
113
+ export type LinkId = Id<"lnk">;
114
+ /** Instance link IDs. */
115
+ export declare const LinkId: GeneratedIdKind<"lnk">;
116
+ /** A hosted route (`rte_` + ULID): one artifact on one hosted home (D165, after the Opus review). */
117
+ export type RouteId = Id<"rte">;
118
+ /** Hosted route IDs. */
119
+ export declare const RouteId: GeneratedIdKind<"rte">;
104
120
  /**
105
121
  * An event cursor: the decimal string of a home-wide event position (INTERFACES §1). Decimal
106
122
  * strings keep 64-bit positions exact in JavaScript.
package/dist/ids.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ids.d.ts","names":[],"sources":["../src/ids.ts"],"mappings":";;;YAmBY;;;;;YAkBA,GAAG,UAAU,eAAe;WAA2B,kBAAkB;;;YAGzE;;iBAGK,OAAO,UAAU;;WAEvB,QAAQ;;WAER;;WAEA,MAAM;;WAEN,SAAS;;WAET,QAAQ,EAAE,QAAQ,GAAG;;EAE9B,GAAG,iBAAiB,SAAS,GAAG;;;;;;;EAOhC,MAAM,gBAAgB,GAAG;;;iBAIV,gBAAgB,UAAU,kBAAkB,OAAO;;EAElE,UAAU,GAAG;;;YAkFH,aAAa;;qBAEZ,YAAY;;YAKb,YAAY;;iBAEP,sBAAsB;;;;;;;;;EASrC,WAAW,QAAQ,aAAa;;;qBAGrB,WAAW;;YAWZ,SAAS;;qBAER,QAAQ;;YAGT,WAAW;;qBAEV,UAAU;;YAKX,eAAe;;qBAEd,cAAc;;;;;YAQf,aAAa;;qBAEZ,YAAY;;YAKb,QAAQ;;qBAEP,OAAO;;YAKR,WAAW;;qBAEV,UAAU;;YAKX,YAAY;;qBAEX,WAAW;;YAKZ,UAAU;;qBAET,SAAS;;YAKV,aAAa;;qBAEZ,YAAY;;YAKb,UAAU;;qBAET,SAAS;;;;;YAQV;WAA6B;;;qBAG5B;;WAEF,SAAS;WACT,QAAQ,EAAE,QAAQ;EAC3B,GAAG,iBAAiB,SAAS;;EAE7B,MAAM,gBAAgB;;EAEtB,QAAQ,GAAG,QAAQ,GAAG"}
1
+ {"version":3,"file":"ids.d.ts","names":[],"sources":["../src/ids.ts"],"mappings":";;;YAmBY;;;;;YAsBA,GAAG,UAAU,eAAe;WAA2B,kBAAkB;;;YAGzE;;iBAGK,OAAO,UAAU;;WAEvB,QAAQ;;WAER;;WAEA,MAAM;;WAEN,SAAS;;WAET,QAAQ,EAAE,QAAQ,GAAG;;EAE9B,GAAG,iBAAiB,SAAS,GAAG;;;;;;;EAOhC,MAAM,gBAAgB,GAAG;;;iBAIV,gBAAgB,UAAU,kBAAkB,OAAO;;EAElE,UAAU,GAAG;;;YAkFH,aAAa;;qBAEZ,YAAY;;YAKb,YAAY;;iBAEP,sBAAsB;;;;;;;;;EASrC,WAAW,QAAQ,aAAa;;;qBAGrB,WAAW;;YAWZ,SAAS;;qBAER,QAAQ;;YAGT,WAAW;;qBAEV,UAAU;;YAKX,eAAe;;qBAEd,cAAc;;;;;YAQf,aAAa;;qBAEZ,YAAY;;YAKb,QAAQ;;qBAEP,OAAO;;YAKR,WAAW;;qBAEV,UAAU;;YAKX,YAAY;;qBAEX,WAAW;;YAKZ,UAAU;;qBAET,SAAS;;YAKV,aAAa;;qBAEZ,YAAY;;YAKb,UAAU;;qBAET,SAAS;;YAKV,YAAY;;qBAEX,WAAW;;YAKZ,SAAS;;qBAER,QAAQ;;YAKT,SAAS;;qBAER,QAAQ;;YAKT,UAAU;;qBAET,SAAS;;;;;YAQV;WAA6B;;;qBAG5B;;WAEF,SAAS;WACT,QAAQ,EAAE,QAAQ;EAC3B,GAAG,iBAAiB,SAAS;;EAE7B,MAAM,gBAAgB;;EAEtB,QAAQ,GAAG,QAAQ,GAAG"}
package/dist/ids.js CHANGED
@@ -111,6 +111,14 @@ const TokenId = generated(defineKind("tok", "capability token", "ulid", "TokenId
111
111
  const MutationId = generated(defineKind("mut", "mutation", "ulid", "MutationId"));
112
112
  /** Share IDs. */
113
113
  const ShareId = generated(defineKind("shr", "share", "ulid", "ShareId"));
114
+ /** Account IDs. */
115
+ const AccountId = generated(defineKind("acct", "account", "ulid", "AccountId"));
116
+ /** Hosted home IDs. */
117
+ const HomeId = generated(defineKind("hom", "hosted home", "ulid", "HomeId"));
118
+ /** Instance link IDs. */
119
+ const LinkId = generated(defineKind("lnk", "instance link", "ulid", "LinkId"));
120
+ /** Hosted route IDs. */
121
+ const RouteId = generated(defineKind("rte", "hosted route", "ulid", "RouteId"));
114
122
  /** Event cursors. */
115
123
  const Cursor = (() => {
116
124
  const pattern = /^(0|[1-9][0-9]{0,18})$/;
@@ -132,6 +140,6 @@ const Cursor = (() => {
132
140
  };
133
141
  })();
134
142
  //#endregion
135
- export { ArtifactId, CommentId, Cursor, DeliveryId, MutationId, RunId, ShareId, SubmissionId, ThreadId, TokenId, VersionId, ViewId, ViewerId };
143
+ export { AccountId, ArtifactId, CommentId, Cursor, DeliveryId, HomeId, LinkId, MutationId, RouteId, RunId, ShareId, SubmissionId, ThreadId, TokenId, VersionId, ViewId, ViewerId };
136
144
 
137
145
  //# sourceMappingURL=ids.js.map
package/dist/ids.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ids.js","names":[],"sources":["../src/ids.ts"],"sourcesContent":["/**\n * Prefixed, opaque identifiers (INTERFACES §1, DATA_MODEL §2).\n *\n * Every Mostra entity is named by a string of the form `<prefix>_<body>`. Callers treat IDs as\n * opaque: they validate the form at a boundary and never read meaning out of the body. Each ID\n * kind below is both a type and a value with the same name:\n *\n * ```ts\n * const artifact: ArtifactId = ArtifactId.parse(input);\n * const mutation: MutationId = MutationId.create();\n * const Params = z.object({ artifactId: ArtifactId.schema });\n * ```\n *\n * @packageDocumentation\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** The prefixes INTERFACES §1 assigns, one per entity. */\nexport type IdPrefix =\n | \"art\"\n | \"ver\"\n | \"vw\"\n | \"vwr\"\n | \"sub\"\n | \"dlv\"\n | \"run\"\n | \"thr\"\n | \"cmt\"\n | \"tok\"\n | \"mut\"\n | \"shr\";\n\n/**\n * A branded ID string. The brand exists only at the type level, so an `Id<\"art\">` is a plain\n * string at run time and on the wire.\n */\nexport type Id<P extends IdPrefix> = `${P}_${string}` & { readonly __mostraIdPrefix: P };\n\n/** How an ID kind's body is formed. */\nexport type IdBody = \"ulid\" | \"sha256-base32\";\n\n/** One ID kind: its prefix, validation and schema. */\nexport interface IdKind<P extends IdPrefix> {\n /** The prefix, without the underscore. */\n readonly prefix: P;\n /** The entity the ID names, in the PRODUCT vocabulary. */\n readonly entity: string;\n /** How the body is formed. */\n readonly body: IdBody;\n /** The exact form, anchored at both ends. */\n readonly pattern: RegExp;\n /** The Zod schema for this ID, registered for JSON Schema output under the kind's type name. */\n readonly schema: z.ZodType<Id<P>, string>;\n /** Whether `value` is an ID of this kind. */\n is(value: unknown): value is Id<P>;\n /**\n * Returns `value` as an ID of this kind.\n *\n * @throws TypeError when `value` is not of this kind's form. The message names the expected\n * form and never echoes the input.\n */\n parse(value: string): Id<P>;\n}\n\n/** An ID kind whose body is a ULID that the creator generates. */\nexport interface GeneratedIdKind<P extends IdPrefix> extends IdKind<P> {\n /** Generates a new ID from the current time and 80 bits of Web Crypto randomness. */\n create(): Id<P>;\n}\n\n/** Crockford's base32 alphabet, used by ULIDs and by content-addressed version IDs. */\nconst CROCKFORD = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\nconst BODY_LENGTH = 26;\n/** A ULID's first character encodes at most 3 bits (48-bit time in 26 × 5 = 130 bits). */\nconst ULID_BODY = \"[0-7][0-9A-HJKMNP-TV-Z]{25}\";\nconst BASE32_BODY = \"[0-9A-HJKMNP-TV-Z]{26}\";\n\nfunction defineKind<P extends IdPrefix>(\n prefix: P,\n entity: string,\n body: IdBody,\n typeName: string,\n): IdKind<P> {\n const pattern = new RegExp(`^${prefix}_${body === \"ulid\" ? ULID_BODY : BASE32_BODY}$`);\n const form = body === \"ulid\" ? \"a 26-character ULID\" : \"26 characters of Crockford base32\";\n const is = (value: unknown): value is Id<P> => typeof value === \"string\" && pattern.test(value);\n const schema = z\n .string()\n .regex(pattern)\n .register(wireRegistry, {\n id: typeName,\n description: `${entity[0]?.toUpperCase()}${entity.slice(1)} ID: \"${prefix}_\" followed by ${form}.`,\n }) as unknown as z.ZodType<Id<P>, string>;\n return {\n prefix,\n entity,\n body,\n pattern,\n schema,\n is,\n parse(value: string): Id<P> {\n if (is(value)) return value;\n throw new TypeError(`Expected ${entity} ID \"${prefix}_\" followed by ${form}.`);\n },\n };\n}\n\nfunction generated<P extends IdPrefix>(kind: IdKind<P>): GeneratedIdKind<P> {\n return { ...kind, create: () => kind.parse(`${kind.prefix}_${ulidBody(Date.now())}`) };\n}\n\n/**\n * Encodes a ULID body: 48 bits of milliseconds since the Unix epoch, then 80 random bits, as 26\n * Crockford base32 characters.\n */\nfunction ulidBody(now: number): string {\n if (!Number.isSafeInteger(now) || now < 0 || now > 0xffff_ffff_ffff) {\n throw new RangeError(\"ULID time must be a millisecond timestamp between 0 and 2^48 - 1.\");\n }\n let time = \"\";\n let rest = now;\n for (let i = 0; i < 10; i++) {\n time = CROCKFORD.charAt(rest % 32) + time;\n rest = Math.floor(rest / 32);\n }\n const random = new Uint8Array(10);\n globalThis.crypto.getRandomValues(random);\n return time + base32(random).slice(0, 16);\n}\n\n/** Encodes bytes as Crockford base32, most significant bit first, padding the last group with 0. */\nfunction base32(bytes: Uint8Array): string {\n let out = \"\";\n let buffer = 0;\n let bits = 0;\n for (const byte of bytes) {\n buffer = (buffer << 8) | byte;\n bits += 8;\n while (bits >= 5) {\n out += CROCKFORD.charAt((buffer >>> (bits - 5)) & 31);\n bits -= 5;\n }\n buffer &= (1 << bits) - 1;\n }\n if (bits > 0) out += CROCKFORD.charAt((buffer << (5 - bits)) & 31);\n return out;\n}\n\n/** An artifact ID (`art_` + ULID). */\nexport type ArtifactId = Id<\"art\">;\n/** Artifact IDs. */\nexport const ArtifactId: GeneratedIdKind<\"art\"> = generated(\n defineKind(\"art\", \"artifact\", \"ulid\", \"ArtifactId\"),\n);\n\n/** A version ID (`ver_` + 26 characters of base32 SHA-256): content-addressed, never generated. */\nexport type VersionId = Id<\"ver\">;\n/** The version ID kind, with the content-addressed constructor DATA_MODEL §2 defines. */\nexport interface VersionIdKind extends IdKind<\"ver\"> {\n /**\n * Returns the version ID for a SHA-256 digest: `ver_` plus the first 26 characters of the\n * digest in Crockford base32 (130 bits). The caller computes the digest of the artifact ID's\n * UTF-8 bytes, a `0x00` byte, and the 32-byte `sourceDigest` and `envDigest` (DATA_MODEL §2,\n * D89).\n *\n * @throws RangeError when `digest` is not 32 bytes long.\n */\n fromSha256(digest: Uint8Array): VersionId;\n}\n/** Version IDs. */\nexport const VersionId: VersionIdKind = {\n ...defineKind(\"ver\", \"version\", \"sha256-base32\", \"VersionId\"),\n fromSha256(digest: Uint8Array): VersionId {\n if (digest.length !== 32) {\n throw new RangeError(`A SHA-256 digest is 32 bytes, got ${digest.length}.`);\n }\n return VersionId.parse(`ver_${base32(digest).slice(0, BODY_LENGTH)}`);\n },\n};\n\n/** A view ID (`vw_` + ULID). */\nexport type ViewId = Id<\"vw\">;\n/** View IDs. */\nexport const ViewId: GeneratedIdKind<\"vw\"> = generated(defineKind(\"vw\", \"view\", \"ulid\", \"ViewId\"));\n\n/** A viewer ID (`vwr_` + ULID). */\nexport type ViewerId = Id<\"vwr\">;\n/** Viewer IDs. */\nexport const ViewerId: GeneratedIdKind<\"vwr\"> = generated(\n defineKind(\"vwr\", \"viewer\", \"ulid\", \"ViewerId\"),\n);\n\n/** A submission ID (`sub_` + ULID). */\nexport type SubmissionId = Id<\"sub\">;\n/** Submission IDs. */\nexport const SubmissionId: GeneratedIdKind<\"sub\"> = generated(\n defineKind(\"sub\", \"submission\", \"ulid\", \"SubmissionId\"),\n);\n\n/**\n * A delivery ID (`dlv_` + ULID): one submission's delivery to one host (D105). A redelivery after a\n * crash repeats it, so a host can treat deliveries idempotently.\n */\nexport type DeliveryId = Id<\"dlv\">;\n/** Delivery IDs. */\nexport const DeliveryId: GeneratedIdKind<\"dlv\"> = generated(\n defineKind(\"dlv\", \"delivery\", \"ulid\", \"DeliveryId\"),\n);\n\n/** An action run ID (`run_` + ULID). */\nexport type RunId = Id<\"run\">;\n/** Action run IDs. */\nexport const RunId: GeneratedIdKind<\"run\"> = generated(\n defineKind(\"run\", \"action run\", \"ulid\", \"RunId\"),\n);\n\n/** A review thread ID (`thr_` + ULID). */\nexport type ThreadId = Id<\"thr\">;\n/** Review thread IDs. */\nexport const ThreadId: GeneratedIdKind<\"thr\"> = generated(\n defineKind(\"thr\", \"thread\", \"ulid\", \"ThreadId\"),\n);\n\n/** A comment ID (`cmt_` + ULID). */\nexport type CommentId = Id<\"cmt\">;\n/** Comment IDs. */\nexport const CommentId: GeneratedIdKind<\"cmt\"> = generated(\n defineKind(\"cmt\", \"comment\", \"ulid\", \"CommentId\"),\n);\n\n/** A capability token ID (`tok_` + ULID). The token's secret is separate and never an ID. */\nexport type TokenId = Id<\"tok\">;\n/** Capability token IDs. */\nexport const TokenId: GeneratedIdKind<\"tok\"> = generated(\n defineKind(\"tok\", \"capability token\", \"ulid\", \"TokenId\"),\n);\n\n/** A mutation ID (`mut_` + ULID), generated by the client that sends the mutation. */\nexport type MutationId = Id<\"mut\">;\n/** Mutation IDs. */\nexport const MutationId: GeneratedIdKind<\"mut\"> = generated(\n defineKind(\"mut\", \"mutation\", \"ulid\", \"MutationId\"),\n);\n\n/** A share ID (`shr_` + ULID): one share of an artifact through a tunnel (D158). */\nexport type ShareId = Id<\"shr\">;\n/** Share IDs. */\nexport const ShareId: GeneratedIdKind<\"shr\"> = generated(\n defineKind(\"shr\", \"share\", \"ulid\", \"ShareId\"),\n);\n\n/**\n * An event cursor: the decimal string of a home-wide event position (INTERFACES §1). Decimal\n * strings keep 64-bit positions exact in JavaScript.\n */\nexport type Cursor = string & { readonly __mostraCursor: true };\n\n/** Event cursors. */\nexport const Cursor: {\n /** The exact form: a non-negative decimal integer without leading zeros, at most 19 digits. */\n readonly pattern: RegExp;\n readonly schema: z.ZodType<Cursor, string>;\n is(value: unknown): value is Cursor;\n /** @throws TypeError when `value` is not a cursor. */\n parse(value: string): Cursor;\n /** Orders two cursors: negative when `a` comes first, zero when equal, positive otherwise. */\n compare(a: Cursor, b: Cursor): number;\n} = (() => {\n const pattern = /^(0|[1-9][0-9]{0,18})$/;\n const is = (value: unknown): value is Cursor => typeof value === \"string\" && pattern.test(value);\n return {\n pattern,\n schema: z.string().regex(pattern).register(wireRegistry, {\n id: \"Cursor\",\n description: \"Event cursor: the decimal string of a home-wide event position.\",\n }) as unknown as z.ZodType<Cursor, string>,\n is,\n parse(value: string): Cursor {\n if (is(value)) return value;\n throw new TypeError(\"Expected an event cursor: a non-negative decimal integer string.\");\n },\n compare(a: Cursor, b: Cursor): number {\n return a.length === b.length ? (a < b ? -1 : a > b ? 1 : 0) : a.length - b.length;\n },\n };\n})();\n"],"mappings":"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"}
1
+ {"version":3,"file":"ids.js","names":[],"sources":["../src/ids.ts"],"sourcesContent":["/**\n * Prefixed, opaque identifiers (INTERFACES §1, DATA_MODEL §2).\n *\n * Every Mostra entity is named by a string of the form `<prefix>_<body>`. Callers treat IDs as\n * opaque: they validate the form at a boundary and never read meaning out of the body. Each ID\n * kind below is both a type and a value with the same name:\n *\n * ```ts\n * const artifact: ArtifactId = ArtifactId.parse(input);\n * const mutation: MutationId = MutationId.create();\n * const Params = z.object({ artifactId: ArtifactId.schema });\n * ```\n *\n * @packageDocumentation\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** The prefixes INTERFACES §1 assigns, one per entity. */\nexport type IdPrefix =\n | \"art\"\n | \"ver\"\n | \"vw\"\n | \"vwr\"\n | \"sub\"\n | \"dlv\"\n | \"run\"\n | \"thr\"\n | \"cmt\"\n | \"tok\"\n | \"mut\"\n | \"shr\"\n | \"acct\"\n | \"hom\"\n | \"lnk\"\n | \"rte\";\n\n/**\n * A branded ID string. The brand exists only at the type level, so an `Id<\"art\">` is a plain\n * string at run time and on the wire.\n */\nexport type Id<P extends IdPrefix> = `${P}_${string}` & { readonly __mostraIdPrefix: P };\n\n/** How an ID kind's body is formed. */\nexport type IdBody = \"ulid\" | \"sha256-base32\";\n\n/** One ID kind: its prefix, validation and schema. */\nexport interface IdKind<P extends IdPrefix> {\n /** The prefix, without the underscore. */\n readonly prefix: P;\n /** The entity the ID names, in the PRODUCT vocabulary. */\n readonly entity: string;\n /** How the body is formed. */\n readonly body: IdBody;\n /** The exact form, anchored at both ends. */\n readonly pattern: RegExp;\n /** The Zod schema for this ID, registered for JSON Schema output under the kind's type name. */\n readonly schema: z.ZodType<Id<P>, string>;\n /** Whether `value` is an ID of this kind. */\n is(value: unknown): value is Id<P>;\n /**\n * Returns `value` as an ID of this kind.\n *\n * @throws TypeError when `value` is not of this kind's form. The message names the expected\n * form and never echoes the input.\n */\n parse(value: string): Id<P>;\n}\n\n/** An ID kind whose body is a ULID that the creator generates. */\nexport interface GeneratedIdKind<P extends IdPrefix> extends IdKind<P> {\n /** Generates a new ID from the current time and 80 bits of Web Crypto randomness. */\n create(): Id<P>;\n}\n\n/** Crockford's base32 alphabet, used by ULIDs and by content-addressed version IDs. */\nconst CROCKFORD = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\nconst BODY_LENGTH = 26;\n/** A ULID's first character encodes at most 3 bits (48-bit time in 26 × 5 = 130 bits). */\nconst ULID_BODY = \"[0-7][0-9A-HJKMNP-TV-Z]{25}\";\nconst BASE32_BODY = \"[0-9A-HJKMNP-TV-Z]{26}\";\n\nfunction defineKind<P extends IdPrefix>(\n prefix: P,\n entity: string,\n body: IdBody,\n typeName: string,\n): IdKind<P> {\n const pattern = new RegExp(`^${prefix}_${body === \"ulid\" ? ULID_BODY : BASE32_BODY}$`);\n const form = body === \"ulid\" ? \"a 26-character ULID\" : \"26 characters of Crockford base32\";\n const is = (value: unknown): value is Id<P> => typeof value === \"string\" && pattern.test(value);\n const schema = z\n .string()\n .regex(pattern)\n .register(wireRegistry, {\n id: typeName,\n description: `${entity[0]?.toUpperCase()}${entity.slice(1)} ID: \"${prefix}_\" followed by ${form}.`,\n }) as unknown as z.ZodType<Id<P>, string>;\n return {\n prefix,\n entity,\n body,\n pattern,\n schema,\n is,\n parse(value: string): Id<P> {\n if (is(value)) return value;\n throw new TypeError(`Expected ${entity} ID \"${prefix}_\" followed by ${form}.`);\n },\n };\n}\n\nfunction generated<P extends IdPrefix>(kind: IdKind<P>): GeneratedIdKind<P> {\n return { ...kind, create: () => kind.parse(`${kind.prefix}_${ulidBody(Date.now())}`) };\n}\n\n/**\n * Encodes a ULID body: 48 bits of milliseconds since the Unix epoch, then 80 random bits, as 26\n * Crockford base32 characters.\n */\nfunction ulidBody(now: number): string {\n if (!Number.isSafeInteger(now) || now < 0 || now > 0xffff_ffff_ffff) {\n throw new RangeError(\"ULID time must be a millisecond timestamp between 0 and 2^48 - 1.\");\n }\n let time = \"\";\n let rest = now;\n for (let i = 0; i < 10; i++) {\n time = CROCKFORD.charAt(rest % 32) + time;\n rest = Math.floor(rest / 32);\n }\n const random = new Uint8Array(10);\n globalThis.crypto.getRandomValues(random);\n return time + base32(random).slice(0, 16);\n}\n\n/** Encodes bytes as Crockford base32, most significant bit first, padding the last group with 0. */\nfunction base32(bytes: Uint8Array): string {\n let out = \"\";\n let buffer = 0;\n let bits = 0;\n for (const byte of bytes) {\n buffer = (buffer << 8) | byte;\n bits += 8;\n while (bits >= 5) {\n out += CROCKFORD.charAt((buffer >>> (bits - 5)) & 31);\n bits -= 5;\n }\n buffer &= (1 << bits) - 1;\n }\n if (bits > 0) out += CROCKFORD.charAt((buffer << (5 - bits)) & 31);\n return out;\n}\n\n/** An artifact ID (`art_` + ULID). */\nexport type ArtifactId = Id<\"art\">;\n/** Artifact IDs. */\nexport const ArtifactId: GeneratedIdKind<\"art\"> = generated(\n defineKind(\"art\", \"artifact\", \"ulid\", \"ArtifactId\"),\n);\n\n/** A version ID (`ver_` + 26 characters of base32 SHA-256): content-addressed, never generated. */\nexport type VersionId = Id<\"ver\">;\n/** The version ID kind, with the content-addressed constructor DATA_MODEL §2 defines. */\nexport interface VersionIdKind extends IdKind<\"ver\"> {\n /**\n * Returns the version ID for a SHA-256 digest: `ver_` plus the first 26 characters of the\n * digest in Crockford base32 (130 bits). The caller computes the digest of the artifact ID's\n * UTF-8 bytes, a `0x00` byte, and the 32-byte `sourceDigest` and `envDigest` (DATA_MODEL §2,\n * D89).\n *\n * @throws RangeError when `digest` is not 32 bytes long.\n */\n fromSha256(digest: Uint8Array): VersionId;\n}\n/** Version IDs. */\nexport const VersionId: VersionIdKind = {\n ...defineKind(\"ver\", \"version\", \"sha256-base32\", \"VersionId\"),\n fromSha256(digest: Uint8Array): VersionId {\n if (digest.length !== 32) {\n throw new RangeError(`A SHA-256 digest is 32 bytes, got ${digest.length}.`);\n }\n return VersionId.parse(`ver_${base32(digest).slice(0, BODY_LENGTH)}`);\n },\n};\n\n/** A view ID (`vw_` + ULID). */\nexport type ViewId = Id<\"vw\">;\n/** View IDs. */\nexport const ViewId: GeneratedIdKind<\"vw\"> = generated(defineKind(\"vw\", \"view\", \"ulid\", \"ViewId\"));\n\n/** A viewer ID (`vwr_` + ULID). */\nexport type ViewerId = Id<\"vwr\">;\n/** Viewer IDs. */\nexport const ViewerId: GeneratedIdKind<\"vwr\"> = generated(\n defineKind(\"vwr\", \"viewer\", \"ulid\", \"ViewerId\"),\n);\n\n/** A submission ID (`sub_` + ULID). */\nexport type SubmissionId = Id<\"sub\">;\n/** Submission IDs. */\nexport const SubmissionId: GeneratedIdKind<\"sub\"> = generated(\n defineKind(\"sub\", \"submission\", \"ulid\", \"SubmissionId\"),\n);\n\n/**\n * A delivery ID (`dlv_` + ULID): one submission's delivery to one host (D105). A redelivery after a\n * crash repeats it, so a host can treat deliveries idempotently.\n */\nexport type DeliveryId = Id<\"dlv\">;\n/** Delivery IDs. */\nexport const DeliveryId: GeneratedIdKind<\"dlv\"> = generated(\n defineKind(\"dlv\", \"delivery\", \"ulid\", \"DeliveryId\"),\n);\n\n/** An action run ID (`run_` + ULID). */\nexport type RunId = Id<\"run\">;\n/** Action run IDs. */\nexport const RunId: GeneratedIdKind<\"run\"> = generated(\n defineKind(\"run\", \"action run\", \"ulid\", \"RunId\"),\n);\n\n/** A review thread ID (`thr_` + ULID). */\nexport type ThreadId = Id<\"thr\">;\n/** Review thread IDs. */\nexport const ThreadId: GeneratedIdKind<\"thr\"> = generated(\n defineKind(\"thr\", \"thread\", \"ulid\", \"ThreadId\"),\n);\n\n/** A comment ID (`cmt_` + ULID). */\nexport type CommentId = Id<\"cmt\">;\n/** Comment IDs. */\nexport const CommentId: GeneratedIdKind<\"cmt\"> = generated(\n defineKind(\"cmt\", \"comment\", \"ulid\", \"CommentId\"),\n);\n\n/** A capability token ID (`tok_` + ULID). The token's secret is separate and never an ID. */\nexport type TokenId = Id<\"tok\">;\n/** Capability token IDs. */\nexport const TokenId: GeneratedIdKind<\"tok\"> = generated(\n defineKind(\"tok\", \"capability token\", \"ulid\", \"TokenId\"),\n);\n\n/** A mutation ID (`mut_` + ULID), generated by the client that sends the mutation. */\nexport type MutationId = Id<\"mut\">;\n/** Mutation IDs. */\nexport const MutationId: GeneratedIdKind<\"mut\"> = generated(\n defineKind(\"mut\", \"mutation\", \"ulid\", \"MutationId\"),\n);\n\n/** A share ID (`shr_` + ULID): one share of an artifact through a tunnel (D158). */\nexport type ShareId = Id<\"shr\">;\n/** Share IDs. */\nexport const ShareId: GeneratedIdKind<\"shr\"> = generated(\n defineKind(\"shr\", \"share\", \"ulid\", \"ShareId\"),\n);\n\n/** An account on a remote server (`acct_` + ULID, D165 item 8). */\nexport type AccountId = Id<\"acct\">;\n/** Account IDs. */\nexport const AccountId: GeneratedIdKind<\"acct\"> = generated(\n defineKind(\"acct\", \"account\", \"ulid\", \"AccountId\"),\n);\n\n/** A hosted home on a remote server (`hom_` + ULID, D165 item 1). */\nexport type HomeId = Id<\"hom\">;\n/** Hosted home IDs. */\nexport const HomeId: GeneratedIdKind<\"hom\"> = generated(\n defineKind(\"hom\", \"hosted home\", \"ulid\", \"HomeId\"),\n);\n\n/** An instance linked to a remote server (`lnk_` + ULID, D165 item 2): its owner link. */\nexport type LinkId = Id<\"lnk\">;\n/** Instance link IDs. */\nexport const LinkId: GeneratedIdKind<\"lnk\"> = generated(\n defineKind(\"lnk\", \"instance link\", \"ulid\", \"LinkId\"),\n);\n\n/** A hosted route (`rte_` + ULID): one artifact on one hosted home (D165, after the Opus review). */\nexport type RouteId = Id<\"rte\">;\n/** Hosted route IDs. */\nexport const RouteId: GeneratedIdKind<\"rte\"> = generated(\n defineKind(\"rte\", \"hosted route\", \"ulid\", \"RouteId\"),\n);\n\n/**\n * An event cursor: the decimal string of a home-wide event position (INTERFACES §1). Decimal\n * strings keep 64-bit positions exact in JavaScript.\n */\nexport type Cursor = string & { readonly __mostraCursor: true };\n\n/** Event cursors. */\nexport const Cursor: {\n /** The exact form: a non-negative decimal integer without leading zeros, at most 19 digits. */\n readonly pattern: RegExp;\n readonly schema: z.ZodType<Cursor, string>;\n is(value: unknown): value is Cursor;\n /** @throws TypeError when `value` is not a cursor. */\n parse(value: string): Cursor;\n /** Orders two cursors: negative when `a` comes first, zero when equal, positive otherwise. */\n compare(a: Cursor, b: Cursor): number;\n} = (() => {\n const pattern = /^(0|[1-9][0-9]{0,18})$/;\n const is = (value: unknown): value is Cursor => typeof value === \"string\" && pattern.test(value);\n return {\n pattern,\n schema: z.string().regex(pattern).register(wireRegistry, {\n id: \"Cursor\",\n description: \"Event cursor: the decimal string of a home-wide event position.\",\n }) as unknown as z.ZodType<Cursor, string>,\n is,\n parse(value: string): Cursor {\n if (is(value)) return value;\n throw new TypeError(\"Expected an event cursor: a non-negative decimal integer string.\");\n },\n compare(a: Cursor, b: Cursor): number {\n return a.length === b.length ? (a < b ? -1 : a > b ? 1 : 0) : a.length - b.length;\n },\n };\n})();\n"],"mappings":"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"}