@mostra/cli 0.0.0-placeholder → 0.1.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 (195) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +17 -1
  3. package/dist/bin.d.ts +1 -0
  4. package/dist/bin.js +79 -0
  5. package/dist/bin.js.map +1 -0
  6. package/dist/bootstrap-DfEe_yPr.js +113 -0
  7. package/dist/bootstrap-DfEe_yPr.js.map +1 -0
  8. package/dist/exit-CBIf8nAU.js +79 -0
  9. package/dist/exit-CBIf8nAU.js.map +1 -0
  10. package/dist/flush-BCuWs0Zh.js +718 -0
  11. package/dist/flush-BCuWs0Zh.js.map +1 -0
  12. package/dist/index.d.ts +230 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +3 -0
  15. package/dist/reference/cli.md +977 -0
  16. package/dist/reference/diagnostics.json +1255 -0
  17. package/dist/reference/errors/MOSTRA_A11Y_MINOR.md +23 -0
  18. package/dist/reference/errors/MOSTRA_A11Y_SERIOUS.md +23 -0
  19. package/dist/reference/errors/MOSTRA_ACTION_CANCELLED.md +23 -0
  20. package/dist/reference/errors/MOSTRA_ACTION_EVENT_INVALID.md +23 -0
  21. package/dist/reference/errors/MOSTRA_ACTION_EXPORT_INVALID.md +23 -0
  22. package/dist/reference/errors/MOSTRA_ACTION_INTERRUPTED.md +23 -0
  23. package/dist/reference/errors/MOSTRA_ACTION_RUN_NOT_FOUND.md +23 -0
  24. package/dist/reference/errors/MOSTRA_ACTION_THREW.md +23 -0
  25. package/dist/reference/errors/MOSTRA_ACTION_TOO_LARGE.md +23 -0
  26. package/dist/reference/errors/MOSTRA_ACTION_UNKNOWN_FUNCTION.md +23 -0
  27. package/dist/reference/errors/MOSTRA_ACTION_UNSERIALIZABLE.md +23 -0
  28. package/dist/reference/errors/MOSTRA_ARTIFACT_DIR_NOT_EMPTY.md +23 -0
  29. package/dist/reference/errors/MOSTRA_ARTIFACT_ENTRY_AMBIGUOUS.md +23 -0
  30. package/dist/reference/errors/MOSTRA_ARTIFACT_NOT_FOUND.md +23 -0
  31. package/dist/reference/errors/MOSTRA_ARTIFACT_NO_ENTRY.md +23 -0
  32. package/dist/reference/errors/MOSTRA_ARTIFACT_NO_PAGE.md +23 -0
  33. package/dist/reference/errors/MOSTRA_ARTIFACT_SOURCE_MISSING.md +23 -0
  34. package/dist/reference/errors/MOSTRA_ARTIFACT_SOURCE_UNREADABLE.md +23 -0
  35. package/dist/reference/errors/MOSTRA_ARTIFACT_TEMPLATE_UNKNOWN.md +23 -0
  36. package/dist/reference/errors/MOSTRA_ARTIFACT_VERSION_COLLECTED.md +23 -0
  37. package/dist/reference/errors/MOSTRA_ARTIFACT_VERSION_NOT_FOUND.md +23 -0
  38. package/dist/reference/errors/MOSTRA_BUILD_CRASHED.md +23 -0
  39. package/dist/reference/errors/MOSTRA_BUILD_FAILED.md +23 -0
  40. package/dist/reference/errors/MOSTRA_BUILD_TIMEOUT.md +23 -0
  41. package/dist/reference/errors/MOSTRA_BUILD_UNRESOLVED.md +23 -0
  42. package/dist/reference/errors/MOSTRA_CLI_CONFIG_UNWRITABLE.md +23 -0
  43. package/dist/reference/errors/MOSTRA_CLI_UNKNOWN_COMMAND.md +23 -0
  44. package/dist/reference/errors/MOSTRA_CLI_USAGE.md +23 -0
  45. package/dist/reference/errors/MOSTRA_CONSOLE_ERROR.md +23 -0
  46. package/dist/reference/errors/MOSTRA_CONSOLE_WARNING.md +23 -0
  47. package/dist/reference/errors/MOSTRA_DEP_INSTALL_FAILED.md +23 -0
  48. package/dist/reference/errors/MOSTRA_DEP_MISSING.md +23 -0
  49. package/dist/reference/errors/MOSTRA_DEP_NOT_FOUND.md +23 -0
  50. package/dist/reference/errors/MOSTRA_DEP_OFFLINE.md +23 -0
  51. package/dist/reference/errors/MOSTRA_DEP_SPEC_INVALID.md +23 -0
  52. package/dist/reference/errors/MOSTRA_DEP_TIMEOUT.md +23 -0
  53. package/dist/reference/errors/MOSTRA_DEP_WARM_CONFLICT.md +23 -0
  54. package/dist/reference/errors/MOSTRA_ENV_BIND_FAILED.md +23 -0
  55. package/dist/reference/errors/MOSTRA_ENV_BROWSER_MISSING.md +23 -0
  56. package/dist/reference/errors/MOSTRA_ENV_BUNDLE_DOWNLOAD_FAILED.md +23 -0
  57. package/dist/reference/errors/MOSTRA_ENV_BUNDLE_INVALID.md +23 -0
  58. package/dist/reference/errors/MOSTRA_ENV_BUNDLE_UNAVAILABLE.md +23 -0
  59. package/dist/reference/errors/MOSTRA_ENV_NODE_UNSUPPORTED.md +23 -0
  60. package/dist/reference/errors/MOSTRA_ENV_PORT_TAKEN.md +23 -0
  61. package/dist/reference/errors/MOSTRA_ENV_RUNTIME_MISSING.md +23 -0
  62. package/dist/reference/errors/MOSTRA_ENV_SERVICE_FAILED.md +23 -0
  63. package/dist/reference/errors/MOSTRA_ENV_SHELL_MISSING.md +23 -0
  64. package/dist/reference/errors/MOSTRA_ENV_WARM_MISSING.md +23 -0
  65. package/dist/reference/errors/MOSTRA_FIELD_CONFLICT.md +23 -0
  66. package/dist/reference/errors/MOSTRA_FIELD_DUPLICATE_ID.md +23 -0
  67. package/dist/reference/errors/MOSTRA_FIELD_ID_INVALID.md +23 -0
  68. package/dist/reference/errors/MOSTRA_FIELD_ID_UNSTABLE.md +23 -0
  69. package/dist/reference/errors/MOSTRA_FIELD_MUTATION_ID_REUSED.md +23 -0
  70. package/dist/reference/errors/MOSTRA_FIELD_SHARED.md +23 -0
  71. package/dist/reference/errors/MOSTRA_FIELD_TOO_LARGE.md +23 -0
  72. package/dist/reference/errors/MOSTRA_FIELD_UNBOUND.md +23 -0
  73. package/dist/reference/errors/MOSTRA_HOME_DISK_FULL.md +23 -0
  74. package/dist/reference/errors/MOSTRA_HOME_GC_INCOMPLETE.md +23 -0
  75. package/dist/reference/errors/MOSTRA_HOME_GONE.md +23 -0
  76. package/dist/reference/errors/MOSTRA_HOME_INTEGRITY.md +23 -0
  77. package/dist/reference/errors/MOSTRA_HOME_LEDGER_UNREADABLE.md +23 -0
  78. package/dist/reference/errors/MOSTRA_HOME_LOCKED.md +23 -0
  79. package/dist/reference/errors/MOSTRA_HOME_MISMATCH.md +23 -0
  80. package/dist/reference/errors/MOSTRA_HOME_NOT_ALWAYS_ON.md +23 -0
  81. package/dist/reference/errors/MOSTRA_HOME_NOT_OWNED.md +23 -0
  82. package/dist/reference/errors/MOSTRA_HOME_SOCKET_TOO_LONG.md +23 -0
  83. package/dist/reference/errors/MOSTRA_HOME_TOO_NEW.md +23 -0
  84. package/dist/reference/errors/MOSTRA_HOST_CONNECTION_CLOSED.md +23 -0
  85. package/dist/reference/errors/MOSTRA_HOST_CURSOR_COMPACTED.md +23 -0
  86. package/dist/reference/errors/MOSTRA_HOST_INITIALIZE_ORDER.md +23 -0
  87. package/dist/reference/errors/MOSTRA_HOST_INTERNAL_ERROR.md +23 -0
  88. package/dist/reference/errors/MOSTRA_HOST_INVALID_PARAMS.md +23 -0
  89. package/dist/reference/errors/MOSTRA_HOST_MALFORMED.md +23 -0
  90. package/dist/reference/errors/MOSTRA_HOST_MESSAGE_TOO_LARGE.md +23 -0
  91. package/dist/reference/errors/MOSTRA_HOST_METHOD_UNKNOWN.md +23 -0
  92. package/dist/reference/errors/MOSTRA_HOST_NOTIFICATION_UNSUPPORTED.md +23 -0
  93. package/dist/reference/errors/MOSTRA_HOST_PORT_UNSUPPORTED.md +23 -0
  94. package/dist/reference/errors/MOSTRA_HOST_REQUEST_ID_REUSED.md +23 -0
  95. package/dist/reference/errors/MOSTRA_HOST_REVISION_UNSUPPORTED.md +23 -0
  96. package/dist/reference/errors/MOSTRA_HOST_SHUTDOWN_REFUSED.md +23 -0
  97. package/dist/reference/errors/MOSTRA_HOST_SUBSCRIPTION_UNKNOWN.md +23 -0
  98. package/dist/reference/errors/MOSTRA_HOST_TIMEOUT.md +23 -0
  99. package/dist/reference/errors/MOSTRA_HYGIENE_CONTENT_TYPE.md +23 -0
  100. package/dist/reference/errors/MOSTRA_HYGIENE_CSRF_MISSING.md +23 -0
  101. package/dist/reference/errors/MOSTRA_HYGIENE_HEADERS_TOO_LARGE.md +23 -0
  102. package/dist/reference/errors/MOSTRA_HYGIENE_HOST_REFUSED.md +23 -0
  103. package/dist/reference/errors/MOSTRA_HYGIENE_NOT_SERVED.md +23 -0
  104. package/dist/reference/errors/MOSTRA_HYGIENE_ORIGIN_REFUSED.md +23 -0
  105. package/dist/reference/errors/MOSTRA_HYGIENE_RATE_LIMITED.md +23 -0
  106. package/dist/reference/errors/MOSTRA_HYGIENE_REQUEST_MALFORMED.md +23 -0
  107. package/dist/reference/errors/MOSTRA_HYGIENE_SCOPE_DENIED.md +23 -0
  108. package/dist/reference/errors/MOSTRA_HYGIENE_SESSION_CONFLICT.md +23 -0
  109. package/dist/reference/errors/MOSTRA_HYGIENE_SESSION_MISSING.md +23 -0
  110. package/dist/reference/errors/MOSTRA_HYGIENE_TOKEN_INVALID.md +23 -0
  111. package/dist/reference/errors/MOSTRA_HYGIENE_TOKEN_REVOKED.md +23 -0
  112. package/dist/reference/errors/MOSTRA_LIVE_SOURCE_FAILED.md +23 -0
  113. package/dist/reference/errors/MOSTRA_LIVE_TOO_LARGE.md +23 -0
  114. package/dist/reference/errors/MOSTRA_MANIFEST_INVALID.md +23 -0
  115. package/dist/reference/errors/MOSTRA_MANIFEST_NOT_LITERAL.md +23 -0
  116. package/dist/reference/errors/MOSTRA_MANIFEST_UNKNOWN_KEY.md +23 -0
  117. package/dist/reference/errors/MOSTRA_NETWORK_EXTERNAL_FAILED.md +23 -0
  118. package/dist/reference/errors/MOSTRA_NETWORK_REQUEST_FAILED.md +23 -0
  119. package/dist/reference/errors/MOSTRA_PLATFORM_UNSUPPORTED.md +23 -0
  120. package/dist/reference/errors/MOSTRA_PUBLISH_ID_CONFLICT.md +23 -0
  121. package/dist/reference/errors/MOSTRA_PUBLISH_SOURCE_CHANGED.md +23 -0
  122. package/dist/reference/errors/MOSTRA_PUBLISH_VERIFY_FAILED.md +23 -0
  123. package/dist/reference/errors/MOSTRA_REGRESSION_ACTION_REMOVED.md +23 -0
  124. package/dist/reference/errors/MOSTRA_REGRESSION_ARIA.md +23 -0
  125. package/dist/reference/errors/MOSTRA_REGRESSION_FIELD_REMOVED.md +23 -0
  126. package/dist/reference/errors/MOSTRA_REGRESSION_LIVE_REMOVED.md +23 -0
  127. package/dist/reference/errors/MOSTRA_REGRESSION_PAGE_REMOVED.md +23 -0
  128. package/dist/reference/errors/MOSTRA_REGRESSION_PIXELS.md +23 -0
  129. package/dist/reference/errors/MOSTRA_RUNTIME_BLANK.md +23 -0
  130. package/dist/reference/errors/MOSTRA_RUNTIME_NOT_READY.md +23 -0
  131. package/dist/reference/errors/MOSTRA_RUNTIME_PAGE_ERROR.md +23 -0
  132. package/dist/reference/errors/MOSTRA_RUNTIME_WORKER_CRASHED.md +23 -0
  133. package/dist/reference/errors/MOSTRA_RUNTIME_WORKER_PARKED.md +23 -0
  134. package/dist/reference/errors/MOSTRA_SECRET_MISSING.md +23 -0
  135. package/dist/reference/errors/MOSTRA_SMOKE_BUDGET.md +23 -0
  136. package/dist/reference/errors/MOSTRA_SMOKE_NO_EFFECT.md +23 -0
  137. package/dist/reference/errors/MOSTRA_SUBMIT_ALREADY.md +23 -0
  138. package/dist/reference/errors/MOSTRA_SUBMIT_BLOCKED.md +23 -0
  139. package/dist/reference/errors/MOSTRA_SUBMIT_CHANNEL_DENIED.md +23 -0
  140. package/dist/reference/errors/MOSTRA_SUBMIT_NOT_FOUND.md +23 -0
  141. package/dist/reference/errors/MOSTRA_SUBMIT_POLICY_NONE.md +23 -0
  142. package/dist/reference/errors/MOSTRA_SUBMIT_REVISION_MOVED.md +23 -0
  143. package/dist/reference/errors/MOSTRA_SUBMIT_SIGNAL_INVALID.md +23 -0
  144. package/dist/reference/errors/MOSTRA_SUBMIT_VIEW_INVALID.md +23 -0
  145. package/dist/reference/errors/MOSTRA_TARGET_UNAVAILABLE.md +23 -0
  146. package/dist/reference/errors/MOSTRA_TYPE_ERROR.md +23 -0
  147. package/dist/reference/errors/MOSTRA_TYPE_UNTYPED_PACKAGE.md +23 -0
  148. package/dist/reference/errors/MOSTRA_VERIFY_ACTION_SKIPPED.md +23 -0
  149. package/dist/reference/errors/MOSTRA_VERIFY_BASELINE_MISSING.md +23 -0
  150. package/dist/reference/errors/MOSTRA_VERIFY_CRASHED.md +23 -0
  151. package/dist/reference/errors/MOSTRA_VERIFY_LIVE_FAILED.md +23 -0
  152. package/dist/reference/errors/MOSTRA_VERIFY_NO_BASELINE.md +23 -0
  153. package/dist/reference/errors/MOSTRA_VERIFY_SECRET_MISSING.md +23 -0
  154. package/dist/reference/errors/MOSTRA_VERIFY_SKIP_CONSEQUENCE.md +23 -0
  155. package/dist/reference/errors/MOSTRA_VERIFY_TIMEOUT.md +23 -0
  156. package/dist/reference/telemetry.md +82 -0
  157. package/dist/run-D1gRM6Bm.js +2 -0
  158. package/dist/run-Du266XjI.js +3824 -0
  159. package/dist/run-Du266XjI.js.map +1 -0
  160. package/dist/telemetry/flush-main.d.ts +1 -0
  161. package/dist/telemetry/flush-main.js +14 -0
  162. package/dist/telemetry/flush-main.js.map +1 -0
  163. package/package.json +62 -4
  164. package/src/bin.ts +70 -0
  165. package/src/bootstrap.ts +156 -0
  166. package/src/browser.ts +186 -0
  167. package/src/client.ts +313 -0
  168. package/src/command.ts +147 -0
  169. package/src/commands/admin.ts +791 -0
  170. package/src/commands/authoring.ts +244 -0
  171. package/src/commands/dev.ts +106 -0
  172. package/src/commands/index.ts +71 -0
  173. package/src/commands/interaction.ts +288 -0
  174. package/src/commands/shared.ts +71 -0
  175. package/src/commands/viewing.ts +153 -0
  176. package/src/docs.ts +111 -0
  177. package/src/exit.ts +89 -0
  178. package/src/help.ts +170 -0
  179. package/src/home.ts +111 -0
  180. package/src/index.ts +23 -0
  181. package/src/node-gate.ts +15 -0
  182. package/src/parse.ts +246 -0
  183. package/src/run.ts +387 -0
  184. package/src/telemetry/decision.ts +101 -0
  185. package/src/telemetry/events.ts +147 -0
  186. package/src/telemetry/flush-main.ts +13 -0
  187. package/src/telemetry/flush.ts +143 -0
  188. package/src/telemetry/harness.ts +39 -0
  189. package/src/telemetry/index.ts +318 -0
  190. package/src/telemetry/store.ts +379 -0
  191. package/src/telemetry/timezone.ts +72 -0
  192. package/src/telemetry/words.ts +87 -0
  193. package/src/telemetry/zone-sets.ts +182 -0
  194. package/src/telemetry/zones.generated.ts +720 -0
  195. package/src/version.ts +43 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,19 @@
1
1
  # @mostra/cli
2
2
 
3
- A placeholder: the first Mostra release replaces it. https://github.com/mostra-dev/mostra
3
+ The `mostra` command: create, verify, publish and share agent artifacts, wait for people's answers
4
+ and read them, from a terminal or an agent's shell.
5
+
6
+ ```sh
7
+ mostra new ./sidebar-review --title "Sidebar review"
8
+ mostra verify ./sidebar-review
9
+ mostra publish ./sidebar-review
10
+ mostra wait ./sidebar-review --until submitted --timeout 30m
11
+ mostra results ./sidebar-review
12
+ ```
13
+
14
+ Every command takes `--json`. `mostra --help` lists the commands, `mostra <command> --help`
15
+ describes one, and `mostra docs` prints the reference, including every diagnostic code's page.
16
+ The standalone CLI can send anonymous usage data; `mostra docs telemetry` says what and when, and
17
+ `mostra telemetry off` turns it off.
18
+
19
+ Apache-2.0.
package/dist/bin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/bin.js ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+ //#region src/node-gate.ts
3
+ /**
4
+ * The first thing `mostra` does (RT-01, D142): a copy installed from npm starts on the machine's
5
+ * Node.js, which must be 22.19 or later to find and start the runtime bundle (the SDK's download
6
+ * and extraction need it). An older one fails closed with `MOSTRA_ENV_NODE_UNSUPPORTED` before
7
+ * anything else loads, so nothing breaks half-way on an API it lacks. This module imports nothing.
8
+ */
9
+ /** The oldest Node.js `mostra` starts on, as `[major, minor]`. */
10
+ const MINIMUM_NODE = [22, 19];
11
+ /** Whether `version` (`process.versions.node`, `22.18.0`) is older than {@link MINIMUM_NODE}. */
12
+ function nodeTooOld(version) {
13
+ const [major = 0, minor = 0] = version.split(".").map((part) => Number.parseInt(part, 10));
14
+ return major < MINIMUM_NODE[0] || major === MINIMUM_NODE[0] && minor < MINIMUM_NODE[1];
15
+ }
16
+ //#endregion
17
+ //#region src/bin.ts
18
+ /**
19
+ * `mostra`, the CLI's binary (D60, INTERFACES §9). A copy installed from npm first moves into the
20
+ * runtime bundle its release pins (`bootstrap.ts`, RT-01); otherwise it runs one command and exits
21
+ * with its code, after stdout has drained, so a reader never loses the end of the envelope.
22
+ */
23
+ process.stdout.on("error", () => {});
24
+ process.stderr.on("error", () => {});
25
+ /** Refuses a Node.js too old to start Mostra, before anything that needs a newer one loads. */
26
+ async function refuseOldNode() {
27
+ const message = `Node.js ${MINIMUM_NODE.join(".")} or later is needed to start Mostra; this is ${process.versions.node}.`;
28
+ const json = process.argv.includes("--json");
29
+ try {
30
+ const { createDiagnostic } = await import("@mostra/protocol");
31
+ const diagnostic = createDiagnostic("MOSTRA_ENV_NODE_UNSUPPORTED", { message });
32
+ process.stderr.write(`mostra: ${diagnostic.message}\nmostra: ${diagnostic.hint ?? ""}\n`);
33
+ if (json) process.stdout.write(`${JSON.stringify({
34
+ ok: false,
35
+ error: diagnostic,
36
+ warnings: []
37
+ })}\n`);
38
+ } catch {
39
+ process.stderr.write(`mostra: ${message} (MOSTRA_ENV_NODE_UNSUPPORTED)\n`);
40
+ }
41
+ return 3;
42
+ }
43
+ const code = nodeTooOld(process.versions.node) ? await refuseOldNode() : await start();
44
+ async function start() {
45
+ const { bootstrap } = await import("./bootstrap-DfEe_yPr.js");
46
+ return await bootstrap({
47
+ argv: process.argv.slice(2),
48
+ env: process.env,
49
+ stdout: (text) => {
50
+ process.stdout.write(text);
51
+ },
52
+ stderr: (text) => {
53
+ process.stderr.write(text);
54
+ },
55
+ stderrTty: process.stderr.isTTY === true,
56
+ terminal: process.stdin.isTTY === true || process.stdout.isTTY === true || process.stderr.isTTY === true
57
+ }) ?? await (await import("./run-D1gRM6Bm.js")).run({
58
+ argv: process.argv.slice(2),
59
+ env: process.env,
60
+ cwd: process.cwd(),
61
+ stdout: (text) => {
62
+ process.stdout.write(text);
63
+ },
64
+ stderr: (text) => {
65
+ process.stderr.write(text);
66
+ },
67
+ stdin: process.stdin,
68
+ tty: {
69
+ stdin: process.stdin.isTTY === true,
70
+ stdout: process.stdout.isTTY === true,
71
+ stderr: process.stderr.isTTY === true
72
+ }
73
+ });
74
+ }
75
+ process.stdout.write("", () => process.exit(code));
76
+ //#endregion
77
+ export {};
78
+
79
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","names":[],"sources":["../src/node-gate.ts","../src/bin.ts"],"sourcesContent":["/**\n * The first thing `mostra` does (RT-01, D142): a copy installed from npm starts on the machine's\n * Node.js, which must be 22.19 or later to find and start the runtime bundle (the SDK's download\n * and extraction need it). An older one fails closed with `MOSTRA_ENV_NODE_UNSUPPORTED` before\n * anything else loads, so nothing breaks half-way on an API it lacks. This module imports nothing.\n */\n\n/** The oldest Node.js `mostra` starts on, as `[major, minor]`. */\nexport const MINIMUM_NODE: readonly [number, number] = [22, 19];\n\n/** Whether `version` (`process.versions.node`, `22.18.0`) is older than {@link MINIMUM_NODE}. */\nexport function nodeTooOld(version: string): boolean {\n const [major = 0, minor = 0] = version.split(\".\").map((part) => Number.parseInt(part, 10));\n return major < MINIMUM_NODE[0] || (major === MINIMUM_NODE[0] && minor < MINIMUM_NODE[1]);\n}\n","#!/usr/bin/env node\n/**\n * `mostra`, the CLI's binary (D60, INTERFACES §9). A copy installed from npm first moves into the\n * runtime bundle its release pins (`bootstrap.ts`, RT-01); otherwise it runs one command and exits\n * with its code, after stdout has drained, so a reader never loses the end of the envelope.\n */\nimport { MINIMUM_NODE, nodeTooOld } from \"./node-gate.ts\";\n\nprocess.stdout.on(\"error\", () => {});\nprocess.stderr.on(\"error\", () => {});\n\n/** Refuses a Node.js too old to start Mostra, before anything that needs a newer one loads. */\nasync function refuseOldNode(): Promise<number> {\n const message = `Node.js ${MINIMUM_NODE.join(\".\")} or later is needed to start Mostra; this is ${process.versions.node}.`;\n const json = process.argv.includes(\"--json\");\n try {\n const { createDiagnostic } = await import(\"@mostra/protocol\");\n const diagnostic = createDiagnostic(\"MOSTRA_ENV_NODE_UNSUPPORTED\", { message });\n process.stderr.write(`mostra: ${diagnostic.message}\\nmostra: ${diagnostic.hint ?? \"\"}\\n`);\n if (json)\n process.stdout.write(`${JSON.stringify({ ok: false, error: diagnostic, warnings: [] })}\\n`);\n } catch {\n process.stderr.write(`mostra: ${message} (MOSTRA_ENV_NODE_UNSUPPORTED)\\n`);\n }\n return 3;\n}\n\nconst code = nodeTooOld(process.versions.node) ? await refuseOldNode() : await start();\n\nasync function start(): Promise<number> {\n const { bootstrap } = await import(\"./bootstrap.ts\");\n const booted = await bootstrap({\n argv: process.argv.slice(2),\n env: process.env,\n stdout: (text) => {\n process.stdout.write(text);\n },\n stderr: (text) => {\n process.stderr.write(text);\n },\n stderrTty: process.stderr.isTTY === true,\n terminal:\n process.stdin.isTTY === true ||\n process.stdout.isTTY === true ||\n process.stderr.isTTY === true,\n });\n return (\n booted ??\n (await (\n await import(\"./run.ts\")\n ).run({\n argv: process.argv.slice(2),\n env: process.env,\n cwd: process.cwd(),\n stdout: (text) => {\n process.stdout.write(text);\n },\n stderr: (text) => {\n process.stderr.write(text);\n },\n stdin: process.stdin,\n tty: {\n stdin: process.stdin.isTTY === true,\n stdout: process.stdout.isTTY === true,\n stderr: process.stderr.isTTY === true,\n },\n }))\n );\n}\nprocess.stdout.write(\"\", () => process.exit(code));\n"],"mappings":";;;;;;;;;AAQA,MAAa,eAA0C,CAAC,IAAI,EAAE;;AAG9D,SAAgB,WAAW,SAA0B;CACnD,MAAM,CAAC,QAAQ,GAAG,QAAQ,KAAK,QAAQ,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS,OAAO,SAAS,MAAM,EAAE,CAAC;CACzF,OAAO,QAAQ,aAAa,MAAO,UAAU,aAAa,MAAM,QAAQ,aAAa;AACvF;;;;;;;;ACNA,QAAQ,OAAO,GAAG,eAAe,CAAC,CAAC;AACnC,QAAQ,OAAO,GAAG,eAAe,CAAC,CAAC;;AAGnC,eAAe,gBAAiC;CAC9C,MAAM,UAAU,WAAW,aAAa,KAAK,GAAG,EAAE,+CAA+C,QAAQ,SAAS,KAAK;CACvH,MAAM,OAAO,QAAQ,KAAK,SAAS,QAAQ;CAC3C,IAAI;EACF,MAAM,EAAE,qBAAqB,MAAM,OAAO;EAC1C,MAAM,aAAa,iBAAiB,+BAA+B,EAAE,QAAQ,CAAC;EAC9E,QAAQ,OAAO,MAAM,WAAW,WAAW,QAAQ,YAAY,WAAW,QAAQ,GAAG,GAAG;EACxF,IAAI,MACF,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU;GAAE,IAAI;GAAO,OAAO;GAAY,UAAU,CAAC;EAAE,CAAC,EAAE,GAAG;CAC9F,QAAQ;EACN,QAAQ,OAAO,MAAM,WAAW,QAAQ,iCAAiC;CAC3E;CACA,OAAO;AACT;AAEA,MAAM,OAAO,WAAW,QAAQ,SAAS,IAAI,IAAI,MAAM,cAAc,IAAI,MAAM,MAAM;AAErF,eAAe,QAAyB;CACtC,MAAM,EAAE,cAAc,MAAM,OAAO;CAgBnC,OACE,MAhBmB,UAAU;EAC7B,MAAM,QAAQ,KAAK,MAAM,CAAC;EAC1B,KAAK,QAAQ;EACb,SAAS,SAAS;GAChB,QAAQ,OAAO,MAAM,IAAI;EAC3B;EACA,SAAS,SAAS;GAChB,QAAQ,OAAO,MAAM,IAAI;EAC3B;EACA,WAAW,QAAQ,OAAO,UAAU;EACpC,UACE,QAAQ,MAAM,UAAU,QACxB,QAAQ,OAAO,UAAU,QACzB,QAAQ,OAAO,UAAU;CAC7B,CAAC,KAGE,OACC,MAAM,OAAO,qBAAA,CACb,IAAI;EACJ,MAAM,QAAQ,KAAK,MAAM,CAAC;EAC1B,KAAK,QAAQ;EACb,KAAK,QAAQ,IAAI;EACjB,SAAS,SAAS;GAChB,QAAQ,OAAO,MAAM,IAAI;EAC3B;EACA,SAAS,SAAS;GAChB,QAAQ,OAAO,MAAM,IAAI;EAC3B;EACA,OAAO,QAAQ;EACf,KAAK;GACH,OAAO,QAAQ,MAAM,UAAU;GAC/B,QAAQ,QAAQ,OAAO,UAAU;GACjC,QAAQ,QAAQ,OAAO,UAAU;EACnC;CACF,CAAC;AAEL;AACA,QAAQ,OAAO,MAAM,UAAU,QAAQ,KAAK,IAAI,CAAC"}
@@ -0,0 +1,113 @@
1
+ import { n as exitCodeFor } from "./exit-CBIf8nAU.js";
2
+ import { spawn } from "node:child_process";
3
+ import { RpcError, createDiagnostic } from "@mostra/protocol";
4
+ import { enclosingBundle, readPins, resolveRuntime } from "@mostra/sdk";
5
+ import { constants } from "node:os";
6
+ //#region src/bootstrap.ts
7
+ /**
8
+ * The npm bootstrap (RT-01, D142): a `mostra` installed from npm runs on whatever Node.js the
9
+ * system has, so before anything else it finds the runtime bundle its release pins (from the
10
+ * cache, or downloaded once, with progress on stderr) and runs the bundle's own `mostra` with the
11
+ * same arguments on the bundle's private Node.js. Every command, telemetry included, then runs in
12
+ * the bundle, and this process only waits and passes the exit code on.
13
+ *
14
+ * Inside a bundle, in a development checkout, or with `MOSTRA_BUNDLE`/`MOSTRA_RUNTIME_BIN` set,
15
+ * there is nothing to bootstrap and the CLI runs in this process.
16
+ *
17
+ * This module runs on the system's Node.js, so it uses nothing newer than Node.js 22.19 and loads
18
+ * none of the CLI's commands.
19
+ */
20
+ /** Whether this CLI should move into its pinned bundle before running a command. */
21
+ function needsBootstrap(env) {
22
+ if (env["MOSTRA_BUNDLE"] || env["MOSTRA_RUNTIME_BIN"]) return false;
23
+ if (enclosingBundle() !== void 0) return false;
24
+ return readPins(env) !== void 0;
25
+ }
26
+ /** Progress lines for a person waiting on the first download. */
27
+ function progressReporter(io) {
28
+ let lastPercent = -1;
29
+ let lastStep = "";
30
+ return (progress) => {
31
+ if (progress.step === "download") {
32
+ const percent = Math.floor(progress.received / progress.total * 100);
33
+ const mb = (bytes) => `${Math.round(bytes / 1e6)} MB`;
34
+ if (io.stderrTty) {
35
+ if (percent !== lastPercent) io.stderr(`\rmostra: downloading the Mostra runtime, ${mb(progress.received)} of ${mb(progress.total)} (${percent}%)`);
36
+ } else if (lastStep !== "download" || Math.floor(percent / 25) > Math.floor(lastPercent / 25)) io.stderr(`mostra: downloading the Mostra runtime (${mb(progress.total)}): ${percent}%\n`);
37
+ lastPercent = percent;
38
+ lastStep = "download";
39
+ return;
40
+ }
41
+ if (progress.step === lastStep) return;
42
+ if (lastStep === "download" && io.stderrTty) io.stderr("\n");
43
+ lastStep = progress.step;
44
+ const said = {
45
+ files: "checking the runtime's files",
46
+ browser: "fetching the browser verify uses"
47
+ }[progress.step];
48
+ if (said !== void 0) io.stderr(`mostra: ${said}…\n`);
49
+ };
50
+ }
51
+ /** The envelope `--json` promises, for a bootstrap that fails before any command runs. */
52
+ function failed(io, diagnostic) {
53
+ io.stderr(`mostra: ${diagnostic.message}\n`);
54
+ if (diagnostic.hint) io.stderr(`mostra: ${diagnostic.hint}\n`);
55
+ if (io.argv.includes("--json")) io.stdout(`${JSON.stringify({
56
+ ok: false,
57
+ error: diagnostic,
58
+ warnings: []
59
+ })}\n`);
60
+ return exitCodeFor(diagnostic.code);
61
+ }
62
+ /**
63
+ * When this copy needs the bundle its release pins (`needsBootstrap`), runs the bundle's
64
+ * `mostra` with `io.argv` and resolves with its exit code; otherwise resolves `undefined`, and the
65
+ * caller runs the command itself. Any failure, deciding included, is a diagnostic (one envelope
66
+ * with `--json`) and its exit code. Signals this process gets are passed on to the child.
67
+ */
68
+ async function bootstrap(io) {
69
+ try {
70
+ if (!needsBootstrap(io.env)) return void 0;
71
+ return await runInBundle(io);
72
+ } catch (error) {
73
+ if (error instanceof RpcError) return failed(io, error.diagnostic);
74
+ return failed(io, createDiagnostic("MOSTRA_HOST_INTERNAL_ERROR", { message: `The npm bootstrap failed: ${error instanceof Error ? error.message : String(error)}` }));
75
+ }
76
+ }
77
+ async function runInBundle(io) {
78
+ const runtime = await resolveRuntime({
79
+ env: io.env,
80
+ onProgress: progressReporter(io)
81
+ });
82
+ if (runtime.cliEntry === void 0) throw new RpcError(createDiagnostic("MOSTRA_ENV_RUNTIME_MISSING", { message: "The runtime the bootstrap found has no CLI entry." }));
83
+ const cli = runtime.cliEntry;
84
+ return new Promise((resolve) => {
85
+ const child = spawn(runtime.node, [cli, ...io.argv], {
86
+ stdio: "inherit",
87
+ env: io.env
88
+ });
89
+ const forward = (signal) => {
90
+ if (signal === "SIGINT" && io.terminal) return;
91
+ child.kill(signal);
92
+ };
93
+ const signals = [
94
+ "SIGINT",
95
+ "SIGTERM",
96
+ "SIGHUP"
97
+ ];
98
+ for (const signal of signals) process.on(signal, forward);
99
+ let settled = false;
100
+ const settle = (code) => {
101
+ if (settled) return;
102
+ settled = true;
103
+ for (const signal of signals) process.off(signal, forward);
104
+ resolve(code);
105
+ };
106
+ child.on("error", (error) => settle(failed(io, createDiagnostic("MOSTRA_ENV_RUNTIME_MISSING", { message: `The runtime bundle's CLI couldn't be started (${runtime.node}): ${error.message}` }))));
107
+ child.on("exit", (code, signal) => settle(code ?? 128 + (signal ? constants.signals[signal] ?? 0 : 0)));
108
+ });
109
+ }
110
+ //#endregion
111
+ export { bootstrap };
112
+
113
+ //# sourceMappingURL=bootstrap-DfEe_yPr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-DfEe_yPr.js","names":[],"sources":["../src/bootstrap.ts"],"sourcesContent":["/**\n * The npm bootstrap (RT-01, D142): a `mostra` installed from npm runs on whatever Node.js the\n * system has, so before anything else it finds the runtime bundle its release pins (from the\n * cache, or downloaded once, with progress on stderr) and runs the bundle's own `mostra` with the\n * same arguments on the bundle's private Node.js. Every command, telemetry included, then runs in\n * the bundle, and this process only waits and passes the exit code on.\n *\n * Inside a bundle, in a development checkout, or with `MOSTRA_BUNDLE`/`MOSTRA_RUNTIME_BIN` set,\n * there is nothing to bootstrap and the CLI runs in this process.\n *\n * This module runs on the system's Node.js, so it uses nothing newer than Node.js 22.19 and loads\n * none of the CLI's commands.\n */\nimport { spawn } from \"node:child_process\";\nimport { constants } from \"node:os\";\nimport { createDiagnostic, type Diagnostic, RpcError } from \"@mostra/protocol\";\nimport { enclosingBundle, type InstallProgress, readPins, resolveRuntime } from \"@mostra/sdk\";\nimport { exitCodeFor } from \"./exit.ts\";\nimport type { Environment } from \"./home.ts\";\n\n/** How the bootstrap talks to the terminal. */\nexport interface BootstrapIo {\n readonly argv: readonly string[];\n readonly env: Environment;\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n /** Whether stderr is a terminal: progress then rewrites one line. */\n readonly stderrTty: boolean;\n /**\n * Whether a terminal is attached (stdin, stdout or stderr is one). Ctrl-C there signals the\n * whole foreground process group, the bundle's `mostra` included, so SIGINT isn't forwarded:\n * a second one would cut short a command that stops gracefully on the first (`mostra dev`).\n */\n readonly terminal: boolean;\n}\n\n/** Whether this CLI should move into its pinned bundle before running a command. */\nexport function needsBootstrap(env: Environment): boolean {\n if (env[\"MOSTRA_BUNDLE\"] || env[\"MOSTRA_RUNTIME_BIN\"]) return false;\n if (enclosingBundle() !== undefined) return false;\n return readPins(env) !== undefined;\n}\n\n/** Progress lines for a person waiting on the first download. */\nfunction progressReporter(io: BootstrapIo): (progress: InstallProgress) => void {\n let lastPercent = -1;\n let lastStep = \"\";\n return (progress) => {\n if (progress.step === \"download\") {\n const percent = Math.floor((progress.received / progress.total) * 100);\n const mb = (bytes: number): string => `${Math.round(bytes / 1e6)} MB`;\n if (io.stderrTty) {\n if (percent !== lastPercent)\n io.stderr(\n `\\rmostra: downloading the Mostra runtime, ${mb(progress.received)} of ${mb(progress.total)} (${percent}%)`,\n );\n } else if (\n lastStep !== \"download\" ||\n Math.floor(percent / 25) > Math.floor(lastPercent / 25)\n ) {\n io.stderr(`mostra: downloading the Mostra runtime (${mb(progress.total)}): ${percent}%\\n`);\n }\n lastPercent = percent;\n lastStep = \"download\";\n return;\n }\n if (progress.step === lastStep) return;\n if (lastStep === \"download\" && io.stderrTty) io.stderr(\"\\n\");\n lastStep = progress.step;\n const words: Partial<Record<InstallProgress[\"step\"], string>> = {\n files: \"checking the runtime's files\",\n browser: \"fetching the browser verify uses\",\n };\n const said = words[progress.step];\n if (said !== undefined) io.stderr(`mostra: ${said}…\\n`);\n };\n}\n\n/** The envelope `--json` promises, for a bootstrap that fails before any command runs. */\nfunction failed(io: BootstrapIo, diagnostic: Diagnostic): number {\n io.stderr(`mostra: ${diagnostic.message}\\n`);\n if (diagnostic.hint) io.stderr(`mostra: ${diagnostic.hint}\\n`);\n if (io.argv.includes(\"--json\")) {\n io.stdout(`${JSON.stringify({ ok: false, error: diagnostic, warnings: [] })}\\n`);\n }\n return exitCodeFor(diagnostic.code);\n}\n\n/**\n * When this copy needs the bundle its release pins (`needsBootstrap`), runs the bundle's\n * `mostra` with `io.argv` and resolves with its exit code; otherwise resolves `undefined`, and the\n * caller runs the command itself. Any failure, deciding included, is a diagnostic (one envelope\n * with `--json`) and its exit code. Signals this process gets are passed on to the child.\n */\nexport async function bootstrap(io: BootstrapIo): Promise<number | undefined> {\n try {\n // Deciding is inside the boundary too: pins that can't be read are a diagnostic, never a\n // stack trace (GPT review finding 3).\n if (!needsBootstrap(io.env)) return undefined;\n return await runInBundle(io);\n } catch (error) {\n // Whatever goes wrong, `--json` still gets exactly one envelope (D140 item 16).\n if (error instanceof RpcError) return failed(io, error.diagnostic);\n return failed(\n io,\n createDiagnostic(\"MOSTRA_HOST_INTERNAL_ERROR\", {\n message: `The npm bootstrap failed: ${error instanceof Error ? error.message : String(error)}`,\n }),\n );\n }\n}\n\nasync function runInBundle(io: BootstrapIo): Promise<number> {\n const runtime = await resolveRuntime({ env: io.env, onProgress: progressReporter(io) });\n if (runtime.cliEntry === undefined) {\n throw new RpcError(\n createDiagnostic(\"MOSTRA_ENV_RUNTIME_MISSING\", {\n message: \"The runtime the bootstrap found has no CLI entry.\",\n }),\n );\n }\n const cli = runtime.cliEntry;\n return new Promise((resolve) => {\n const child = spawn(runtime.node, [cli, ...io.argv], {\n stdio: \"inherit\",\n env: io.env as NodeJS.ProcessEnv,\n });\n const forward = (signal: NodeJS.Signals): void => {\n if (signal === \"SIGINT\" && io.terminal) return; // the child got the terminal's own\n child.kill(signal);\n };\n const signals: NodeJS.Signals[] = [\"SIGINT\", \"SIGTERM\", \"SIGHUP\"];\n for (const signal of signals) process.on(signal, forward);\n let settled = false;\n const settle = (code: number): void => {\n if (settled) return;\n settled = true;\n for (const signal of signals) process.off(signal, forward);\n resolve(code);\n };\n child.on(\"error\", (error) =>\n settle(\n failed(\n io,\n createDiagnostic(\"MOSTRA_ENV_RUNTIME_MISSING\", {\n message: `The runtime bundle's CLI couldn't be started (${runtime.node}): ${error.message}`,\n }),\n ),\n ),\n );\n // A child ended by a signal exits as a shell reports it: 128 plus the signal's number.\n child.on(\"exit\", (code, signal) =>\n settle(code ?? 128 + (signal ? (constants.signals[signal] ?? 0) : 0)),\n );\n });\n}\n"],"mappings":"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"}
@@ -0,0 +1,79 @@
1
+ //#region src/exit.ts
2
+ /** The exit codes of INTERFACES §9. */
3
+ const EXIT = {
4
+ /** Success, or `verify` passed. */
5
+ ok: 0,
6
+ /** Artifact failure: verify failed, publish refused, a request the artifact's state refused. */
7
+ failure: 1,
8
+ /** Usage error. */
9
+ usage: 2,
10
+ /** Environment error: no runtime, browser or socket; the home; an unsupported platform. */
11
+ environment: 3,
12
+ /** Timeout: `--timeout` passed before the instance answered. */
13
+ timeout: 4,
14
+ /** `wait` ended `still_waiting`: not an error, the status is in the result. */
15
+ stillWaiting: 5,
16
+ /** Conflict: `once` already submitted, a compare-and-set mismatch, a reused request ID. */
17
+ conflict: 6
18
+ };
19
+ /** Each area's exit code. Every area is here: a new one fails the type check until it is. */
20
+ const BY_AREA = {
21
+ MANIFEST: EXIT.failure,
22
+ BUILD: EXIT.failure,
23
+ TYPE: EXIT.failure,
24
+ LINT: EXIT.failure,
25
+ DEP: EXIT.failure,
26
+ KIT: EXIT.failure,
27
+ FIELD: EXIT.failure,
28
+ ACTION: EXIT.failure,
29
+ LIVE: EXIT.failure,
30
+ RUNTIME: EXIT.failure,
31
+ CONSOLE: EXIT.failure,
32
+ NETWORK: EXIT.failure,
33
+ A11Y: EXIT.failure,
34
+ VISUAL: EXIT.failure,
35
+ SMOKE: EXIT.failure,
36
+ REGRESSION: EXIT.failure,
37
+ TERM: EXIT.failure,
38
+ PUBLISH: EXIT.failure,
39
+ SUBMIT: EXIT.failure,
40
+ HOST: EXIT.environment,
41
+ HOME: EXIT.environment,
42
+ HYGIENE: EXIT.failure,
43
+ SECRET: EXIT.failure,
44
+ SHARE: EXIT.environment,
45
+ VERIFY: EXIT.failure,
46
+ TARGET: EXIT.failure,
47
+ ENV: EXIT.environment,
48
+ PLATFORM: EXIT.environment,
49
+ ARTIFACT: EXIT.failure,
50
+ CLI: EXIT.usage
51
+ };
52
+ /** Codes whose exit code isn't their area's. */
53
+ const BY_CODE = {
54
+ MOSTRA_HOST_TIMEOUT: EXIT.timeout,
55
+ MOSTRA_CLI_CONFIG_UNWRITABLE: EXIT.environment,
56
+ MOSTRA_HOST_INVALID_PARAMS: EXIT.usage,
57
+ MOSTRA_HOST_REQUEST_ID_REUSED: EXIT.conflict,
58
+ MOSTRA_HOST_CURSOR_COMPACTED: EXIT.failure,
59
+ MOSTRA_HOST_SUBSCRIPTION_UNKNOWN: EXIT.usage,
60
+ MOSTRA_SUBMIT_ALREADY: EXIT.conflict,
61
+ MOSTRA_SUBMIT_REVISION_MOVED: EXIT.conflict,
62
+ MOSTRA_FIELD_CONFLICT: EXIT.conflict,
63
+ MOSTRA_FIELD_MUTATION_ID_REUSED: EXIT.conflict,
64
+ MOSTRA_PUBLISH_ID_CONFLICT: EXIT.failure,
65
+ MOSTRA_HOME_INTEGRITY: EXIT.failure,
66
+ MOSTRA_HOME_NOT_ALWAYS_ON: EXIT.ok,
67
+ MOSTRA_VERIFY_CRASHED: EXIT.environment
68
+ };
69
+ /** The exit code a diagnostic ends a command with. An unknown area is an environment error. */
70
+ function exitCodeFor(code) {
71
+ const exact = BY_CODE[code];
72
+ if (exact !== void 0) return exact;
73
+ const area = /^MOSTRA_([A-Z0-9]+)_/.exec(code)?.[1];
74
+ return (area !== void 0 ? BY_AREA[area] : void 0) ?? EXIT.environment;
75
+ }
76
+ //#endregion
77
+ export { exitCodeFor as n, EXIT as t };
78
+
79
+ //# sourceMappingURL=exit-CBIf8nAU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit-CBIf8nAU.js","names":[],"sources":["../src/exit.ts"],"sourcesContent":["/**\n * The exit codes (INTERFACES §9, D140 item 16): one table keyed by diagnostic code, so every\n * command ends the same way for the same failure. Each area has a code, and a few codes differ\n * from their area; the table is total over the catalog by construction, and a test checks every\n * catalog code against it.\n */\nimport type { DiagnosticArea } from \"@mostra/protocol\";\n\n/** The exit codes of INTERFACES §9. */\nexport const EXIT = {\n /** Success, or `verify` passed. */\n ok: 0,\n /** Artifact failure: verify failed, publish refused, a request the artifact's state refused. */\n failure: 1,\n /** Usage error. */\n usage: 2,\n /** Environment error: no runtime, browser or socket; the home; an unsupported platform. */\n environment: 3,\n /** Timeout: `--timeout` passed before the instance answered. */\n timeout: 4,\n /** `wait` ended `still_waiting`: not an error, the status is in the result. */\n stillWaiting: 5,\n /** Conflict: `once` already submitted, a compare-and-set mismatch, a reused request ID. */\n conflict: 6,\n} as const;\n\n/** One of {@link EXIT}'s codes. */\nexport type ExitCode = (typeof EXIT)[keyof typeof EXIT];\n\n/** Each area's exit code. Every area is here: a new one fails the type check until it is. */\nconst BY_AREA: Readonly<Record<DiagnosticArea, ExitCode>> = {\n MANIFEST: EXIT.failure,\n BUILD: EXIT.failure,\n TYPE: EXIT.failure,\n LINT: EXIT.failure,\n DEP: EXIT.failure,\n KIT: EXIT.failure,\n FIELD: EXIT.failure,\n ACTION: EXIT.failure,\n LIVE: EXIT.failure,\n RUNTIME: EXIT.failure,\n CONSOLE: EXIT.failure,\n NETWORK: EXIT.failure,\n A11Y: EXIT.failure,\n VISUAL: EXIT.failure,\n SMOKE: EXIT.failure,\n REGRESSION: EXIT.failure,\n TERM: EXIT.failure,\n PUBLISH: EXIT.failure,\n SUBMIT: EXIT.failure,\n HOST: EXIT.environment,\n HOME: EXIT.environment,\n HYGIENE: EXIT.failure,\n SECRET: EXIT.failure,\n SHARE: EXIT.environment,\n VERIFY: EXIT.failure,\n TARGET: EXIT.failure,\n ENV: EXIT.environment,\n PLATFORM: EXIT.environment,\n ARTIFACT: EXIT.failure,\n CLI: EXIT.usage,\n};\n\n/** Codes whose exit code isn't their area's. */\nconst BY_CODE: Readonly<Record<string, ExitCode>> = {\n MOSTRA_HOST_TIMEOUT: EXIT.timeout,\n // The CLI can't record a choice: its environment, not its command line.\n MOSTRA_CLI_CONFIG_UNWRITABLE: EXIT.environment,\n MOSTRA_HOST_INVALID_PARAMS: EXIT.usage,\n MOSTRA_HOST_REQUEST_ID_REUSED: EXIT.conflict,\n MOSTRA_HOST_CURSOR_COMPACTED: EXIT.failure,\n MOSTRA_HOST_SUBSCRIPTION_UNKNOWN: EXIT.usage,\n MOSTRA_SUBMIT_ALREADY: EXIT.conflict,\n MOSTRA_SUBMIT_REVISION_MOVED: EXIT.conflict,\n MOSTRA_FIELD_CONFLICT: EXIT.conflict,\n MOSTRA_FIELD_MUTATION_ID_REUSED: EXIT.conflict,\n MOSTRA_PUBLISH_ID_CONFLICT: EXIT.failure,\n MOSTRA_HOME_INTEGRITY: EXIT.failure,\n MOSTRA_HOME_NOT_ALWAYS_ON: EXIT.ok,\n MOSTRA_VERIFY_CRASHED: EXIT.environment,\n};\n\n/** The exit code a diagnostic ends a command with. An unknown area is an environment error. */\nexport function exitCodeFor(code: string): ExitCode {\n const exact = BY_CODE[code];\n if (exact !== undefined) return exact;\n const area = /^MOSTRA_([A-Z0-9]+)_/.exec(code)?.[1];\n return (area !== undefined ? BY_AREA[area as DiagnosticArea] : undefined) ?? EXIT.environment;\n}\n"],"mappings":";;AASA,MAAa,OAAO;;CAElB,IAAI;;CAEJ,SAAS;;CAET,OAAO;;CAEP,aAAa;;CAEb,SAAS;;CAET,cAAc;;CAEd,UAAU;AACZ;;AAMA,MAAM,UAAsD;CAC1D,UAAU,KAAK;CACf,OAAO,KAAK;CACZ,MAAM,KAAK;CACX,MAAM,KAAK;CACX,KAAK,KAAK;CACV,KAAK,KAAK;CACV,OAAO,KAAK;CACZ,QAAQ,KAAK;CACb,MAAM,KAAK;CACX,SAAS,KAAK;CACd,SAAS,KAAK;CACd,SAAS,KAAK;CACd,MAAM,KAAK;CACX,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,YAAY,KAAK;CACjB,MAAM,KAAK;CACX,SAAS,KAAK;CACd,QAAQ,KAAK;CACb,MAAM,KAAK;CACX,MAAM,KAAK;CACX,SAAS,KAAK;CACd,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,QAAQ,KAAK;CACb,QAAQ,KAAK;CACb,KAAK,KAAK;CACV,UAAU,KAAK;CACf,UAAU,KAAK;CACf,KAAK,KAAK;AACZ;;AAGA,MAAM,UAA8C;CAClD,qBAAqB,KAAK;CAE1B,8BAA8B,KAAK;CACnC,4BAA4B,KAAK;CACjC,+BAA+B,KAAK;CACpC,8BAA8B,KAAK;CACnC,kCAAkC,KAAK;CACvC,uBAAuB,KAAK;CAC5B,8BAA8B,KAAK;CACnC,uBAAuB,KAAK;CAC5B,iCAAiC,KAAK;CACtC,4BAA4B,KAAK;CACjC,uBAAuB,KAAK;CAC5B,2BAA2B,KAAK;CAChC,uBAAuB,KAAK;AAC9B;;AAGA,SAAgB,YAAY,MAAwB;CAClD,MAAM,QAAQ,QAAQ;CACtB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,OAAO,uBAAuB,KAAK,IAAI,CAAC,GAAG;CACjD,QAAQ,SAAS,KAAA,IAAY,QAAQ,QAA0B,KAAA,MAAc,KAAK;AACpF"}