simfile 0.0.1

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 (249) hide show
  1. package/README.md +143 -0
  2. package/dist/cli/index.d.ts +3 -0
  3. package/dist/cli/index.d.ts.map +1 -0
  4. package/dist/cli/index.js +348 -0
  5. package/dist/coverage/index.d.ts +2 -0
  6. package/dist/coverage/index.d.ts.map +1 -0
  7. package/dist/coverage/index.js +1 -0
  8. package/dist/coverage/matrix.d.ts +21 -0
  9. package/dist/coverage/matrix.d.ts.map +1 -0
  10. package/dist/coverage/matrix.js +173 -0
  11. package/dist/coverage/render.d.ts +3 -0
  12. package/dist/coverage/render.d.ts.map +1 -0
  13. package/dist/coverage/render.js +26 -0
  14. package/dist/index.d.ts +8 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +7 -0
  17. package/dist/kernel/duration.d.ts +9 -0
  18. package/dist/kernel/duration.d.ts.map +1 -0
  19. package/dist/kernel/duration.js +44 -0
  20. package/dist/kernel/index.d.ts +4 -0
  21. package/dist/kernel/index.d.ts.map +1 -0
  22. package/dist/kernel/index.js +3 -0
  23. package/dist/kernel/range.d.ts +6 -0
  24. package/dist/kernel/range.d.ts.map +1 -0
  25. package/dist/kernel/range.js +16 -0
  26. package/dist/kernel/stochastic.d.ts +10 -0
  27. package/dist/kernel/stochastic.d.ts.map +1 -0
  28. package/dist/kernel/stochastic.js +25 -0
  29. package/dist/ledger/index.d.ts +4 -0
  30. package/dist/ledger/index.d.ts.map +1 -0
  31. package/dist/ledger/index.js +3 -0
  32. package/dist/ledger/markers.d.ts +46 -0
  33. package/dist/ledger/markers.d.ts.map +1 -0
  34. package/dist/ledger/markers.js +108 -0
  35. package/dist/ledger/stable.d.ts +65 -0
  36. package/dist/ledger/stable.d.ts.map +1 -0
  37. package/dist/ledger/stable.js +78 -0
  38. package/dist/ledger/validation.d.ts +16 -0
  39. package/dist/ledger/validation.d.ts.map +1 -0
  40. package/dist/ledger/validation.js +127 -0
  41. package/dist/moltnet/index.d.ts +3 -0
  42. package/dist/moltnet/index.d.ts.map +1 -0
  43. package/dist/moltnet/index.js +2 -0
  44. package/dist/moltnet/transcript-export.d.ts +34 -0
  45. package/dist/moltnet/transcript-export.d.ts.map +1 -0
  46. package/dist/moltnet/transcript-export.js +68 -0
  47. package/dist/moltnet/world-participant.d.ts +77 -0
  48. package/dist/moltnet/world-participant.d.ts.map +1 -0
  49. package/dist/moltnet/world-participant.js +221 -0
  50. package/dist/observe/artifacts.d.ts +16 -0
  51. package/dist/observe/artifacts.d.ts.map +1 -0
  52. package/dist/observe/artifacts.js +31 -0
  53. package/dist/observe/causalStreams.d.ts +19 -0
  54. package/dist/observe/causalStreams.d.ts.map +1 -0
  55. package/dist/observe/causalStreams.js +38 -0
  56. package/dist/observe/compute.d.ts +17 -0
  57. package/dist/observe/compute.d.ts.map +1 -0
  58. package/dist/observe/compute.js +97 -0
  59. package/dist/observe/index.d.ts +11 -0
  60. package/dist/observe/index.d.ts.map +1 -0
  61. package/dist/observe/index.js +10 -0
  62. package/dist/observe/manifest.d.ts +79 -0
  63. package/dist/observe/manifest.d.ts.map +1 -0
  64. package/dist/observe/manifest.js +87 -0
  65. package/dist/observe/memoryBanks.d.ts +38 -0
  66. package/dist/observe/memoryBanks.d.ts.map +1 -0
  67. package/dist/observe/memoryBanks.js +86 -0
  68. package/dist/observe/observe.d.ts +32 -0
  69. package/dist/observe/observe.d.ts.map +1 -0
  70. package/dist/observe/observe.js +73 -0
  71. package/dist/observe/report.d.ts +165 -0
  72. package/dist/observe/report.d.ts.map +1 -0
  73. package/dist/observe/report.js +138 -0
  74. package/dist/observe/seedSpread.d.ts +49 -0
  75. package/dist/observe/seedSpread.d.ts.map +1 -0
  76. package/dist/observe/seedSpread.js +262 -0
  77. package/dist/observe/seedSpreadArtifacts.d.ts +49 -0
  78. package/dist/observe/seedSpreadArtifacts.d.ts.map +1 -0
  79. package/dist/observe/seedSpreadArtifacts.js +118 -0
  80. package/dist/observe/spreadMatcher.d.ts +45 -0
  81. package/dist/observe/spreadMatcher.d.ts.map +1 -0
  82. package/dist/observe/spreadMatcher.js +124 -0
  83. package/dist/report/index.d.ts +4 -0
  84. package/dist/report/index.d.ts.map +1 -0
  85. package/dist/report/index.js +3 -0
  86. package/dist/report/probeArtifact.d.ts +26 -0
  87. package/dist/report/probeArtifact.d.ts.map +1 -0
  88. package/dist/report/probeArtifact.js +119 -0
  89. package/dist/report/probes.d.ts +52 -0
  90. package/dist/report/probes.d.ts.map +1 -0
  91. package/dist/report/probes.js +164 -0
  92. package/dist/report/score.d.ts +27 -0
  93. package/dist/report/score.d.ts.map +1 -0
  94. package/dist/report/score.js +14 -0
  95. package/dist/report/transcripts.d.ts +12 -0
  96. package/dist/report/transcripts.d.ts.map +1 -0
  97. package/dist/report/transcripts.js +17 -0
  98. package/dist/runtime/causal-fixture.d.ts +26 -0
  99. package/dist/runtime/causal-fixture.d.ts.map +1 -0
  100. package/dist/runtime/causal-fixture.js +36 -0
  101. package/dist/runtime/clock.d.ts +25 -0
  102. package/dist/runtime/clock.d.ts.map +1 -0
  103. package/dist/runtime/clock.js +63 -0
  104. package/dist/runtime/condition.d.ts +55 -0
  105. package/dist/runtime/condition.d.ts.map +1 -0
  106. package/dist/runtime/condition.js +122 -0
  107. package/dist/runtime/emit-causal-fixture.d.ts +2 -0
  108. package/dist/runtime/emit-causal-fixture.d.ts.map +1 -0
  109. package/dist/runtime/emit-causal-fixture.js +45 -0
  110. package/dist/runtime/expression.d.ts +11 -0
  111. package/dist/runtime/expression.d.ts.map +1 -0
  112. package/dist/runtime/expression.js +305 -0
  113. package/dist/runtime/numeric.d.ts +7 -0
  114. package/dist/runtime/numeric.d.ts.map +1 -0
  115. package/dist/runtime/numeric.js +11 -0
  116. package/dist/runtime/rule-actions.d.ts +5 -0
  117. package/dist/runtime/rule-actions.d.ts.map +1 -0
  118. package/dist/runtime/rule-actions.js +82 -0
  119. package/dist/runtime/run-record.d.ts +73 -0
  120. package/dist/runtime/run-record.d.ts.map +1 -0
  121. package/dist/runtime/run-record.js +179 -0
  122. package/dist/runtime/step-tick.d.ts +43 -0
  123. package/dist/runtime/step-tick.d.ts.map +1 -0
  124. package/dist/runtime/step-tick.js +177 -0
  125. package/dist/runtime/trace-compile.d.ts +66 -0
  126. package/dist/runtime/trace-compile.d.ts.map +1 -0
  127. package/dist/runtime/trace-compile.js +157 -0
  128. package/dist/runtime/trace-export.d.ts +5 -0
  129. package/dist/runtime/trace-export.d.ts.map +1 -0
  130. package/dist/runtime/trace-export.js +4 -0
  131. package/dist/runtime/trace-run.d.ts +15 -0
  132. package/dist/runtime/trace-run.d.ts.map +1 -0
  133. package/dist/runtime/trace-run.js +92 -0
  134. package/dist/runtime/trace.d.ts +10 -0
  135. package/dist/runtime/trace.d.ts.map +1 -0
  136. package/dist/runtime/trace.js +9 -0
  137. package/dist/runtime/types.d.ts +61 -0
  138. package/dist/runtime/types.d.ts.map +1 -0
  139. package/dist/runtime/types.js +1 -0
  140. package/dist/runtime/viewer-trace.d.ts +64 -0
  141. package/dist/runtime/viewer-trace.d.ts.map +1 -0
  142. package/dist/runtime/viewer-trace.js +164 -0
  143. package/dist/runtime/world-act.d.ts +55 -0
  144. package/dist/runtime/world-act.d.ts.map +1 -0
  145. package/dist/runtime/world-act.js +156 -0
  146. package/dist/schema/binding.d.ts +23 -0
  147. package/dist/schema/binding.d.ts.map +1 -0
  148. package/dist/schema/binding.js +249 -0
  149. package/dist/schema/index.d.ts +5 -0
  150. package/dist/schema/index.d.ts.map +1 -0
  151. package/dist/schema/index.js +4 -0
  152. package/dist/schema/model.d.ts +244 -0
  153. package/dist/schema/model.d.ts.map +1 -0
  154. package/dist/schema/model.js +222 -0
  155. package/dist/schema/parse.d.ts +10 -0
  156. package/dist/schema/parse.d.ts.map +1 -0
  157. package/dist/schema/parse.js +15 -0
  158. package/dist/schema/semantic.d.ts +3 -0
  159. package/dist/schema/semantic.d.ts.map +1 -0
  160. package/dist/schema/semantic.js +135 -0
  161. package/dist/sims/composeRunManifest.d.ts +54 -0
  162. package/dist/sims/composeRunManifest.d.ts.map +1 -0
  163. package/dist/sims/composeRunManifest.js +40 -0
  164. package/dist/sims/composedJungianSimDriver.d.ts +50 -0
  165. package/dist/sims/composedJungianSimDriver.d.ts.map +1 -0
  166. package/dist/sims/composedJungianSimDriver.js +199 -0
  167. package/dist/sims/composedOfficeSimDriver.d.ts +53 -0
  168. package/dist/sims/composedOfficeSimDriver.d.ts.map +1 -0
  169. package/dist/sims/composedOfficeSimDriver.js +162 -0
  170. package/dist/sims/exchangeWait.d.ts +56 -0
  171. package/dist/sims/exchangeWait.d.ts.map +1 -0
  172. package/dist/sims/exchangeWait.js +66 -0
  173. package/dist/sims/index.d.ts +14 -0
  174. package/dist/sims/index.d.ts.map +1 -0
  175. package/dist/sims/index.js +13 -0
  176. package/dist/sims/moltnetRoomClient.d.ts +47 -0
  177. package/dist/sims/moltnetRoomClient.d.ts.map +1 -0
  178. package/dist/sims/moltnetRoomClient.js +41 -0
  179. package/dist/sims/poll.d.ts +19 -0
  180. package/dist/sims/poll.d.ts.map +1 -0
  181. package/dist/sims/poll.js +23 -0
  182. package/dist/sims/spawnfileCli.d.ts +49 -0
  183. package/dist/sims/spawnfileCli.d.ts.map +1 -0
  184. package/dist/sims/spawnfileCli.js +90 -0
  185. package/dist/sims/spawnfileReceipts.d.ts +76 -0
  186. package/dist/sims/spawnfileReceipts.d.ts.map +1 -0
  187. package/dist/sims/spawnfileReceipts.js +107 -0
  188. package/dist/sims/worldDrivenOfficeSimDriver.d.ts +59 -0
  189. package/dist/sims/worldDrivenOfficeSimDriver.d.ts.map +1 -0
  190. package/dist/sims/worldDrivenOfficeSimDriver.js +182 -0
  191. package/dist/sims/worldLedgerWriter.d.ts +32 -0
  192. package/dist/sims/worldLedgerWriter.d.ts.map +1 -0
  193. package/dist/sims/worldLedgerWriter.js +39 -0
  194. package/dist/sims/worldSeedLint.d.ts +42 -0
  195. package/dist/sims/worldSeedLint.d.ts.map +1 -0
  196. package/dist/sims/worldSeedLint.js +73 -0
  197. package/dist/sims/worldTickIngest.d.ts +27 -0
  198. package/dist/sims/worldTickIngest.d.ts.map +1 -0
  199. package/dist/sims/worldTickIngest.js +35 -0
  200. package/dist/sims/worldTickLoop.d.ts +64 -0
  201. package/dist/sims/worldTickLoop.d.ts.map +1 -0
  202. package/dist/sims/worldTickLoop.js +122 -0
  203. package/dist/view/engineProvenance.d.ts +46 -0
  204. package/dist/view/engineProvenance.d.ts.map +1 -0
  205. package/dist/view/engineProvenance.js +76 -0
  206. package/dist/view/index.d.ts +14 -0
  207. package/dist/view/index.d.ts.map +1 -0
  208. package/dist/view/index.js +107 -0
  209. package/dist/view/membranes.d.ts +14 -0
  210. package/dist/view/membranes.d.ts.map +1 -0
  211. package/dist/view/membranes.js +127 -0
  212. package/dist/view/runDetect.d.ts +2 -0
  213. package/dist/view/runDetect.d.ts.map +1 -0
  214. package/dist/view/runDetect.js +47 -0
  215. package/dist/view/runRawArtifacts.d.ts +48 -0
  216. package/dist/view/runRawArtifacts.d.ts.map +1 -0
  217. package/dist/view/runRawArtifacts.js +143 -0
  218. package/dist/view/runTimeline.d.ts +24 -0
  219. package/dist/view/runTimeline.d.ts.map +1 -0
  220. package/dist/view/runTimeline.js +204 -0
  221. package/dist/view/runTimelineRecords.d.ts +42 -0
  222. package/dist/view/runTimelineRecords.d.ts.map +1 -0
  223. package/dist/view/runTimelineRecords.js +244 -0
  224. package/dist/view/runTimelineRefs.d.ts +27 -0
  225. package/dist/view/runTimelineRefs.d.ts.map +1 -0
  226. package/dist/view/runTimelineRefs.js +31 -0
  227. package/dist/view/runTimelineTypes.d.ts +99 -0
  228. package/dist/view/runTimelineTypes.d.ts.map +1 -0
  229. package/dist/view/runTimelineTypes.js +1 -0
  230. package/dist/view/runViewModel.d.ts +21 -0
  231. package/dist/view/runViewModel.d.ts.map +1 -0
  232. package/dist/view/runViewModel.js +66 -0
  233. package/dist/view/runViewModelCompute.d.ts +24 -0
  234. package/dist/view/runViewModelCompute.d.ts.map +1 -0
  235. package/dist/view/runViewModelCompute.js +157 -0
  236. package/dist/view/runViewModelTypes.d.ts +177 -0
  237. package/dist/view/runViewModelTypes.d.ts.map +1 -0
  238. package/dist/view/runViewModelTypes.js +1 -0
  239. package/dist/view/runWorldTrace.d.ts +97 -0
  240. package/dist/view/runWorldTrace.d.ts.map +1 -0
  241. package/dist/view/runWorldTrace.js +88 -0
  242. package/dist/view/server.d.ts +12 -0
  243. package/dist/view/server.d.ts.map +1 -0
  244. package/dist/view/server.js +306 -0
  245. package/package.json +65 -0
  246. package/web/dist/assets/index-CJHLjfsG.js +49 -0
  247. package/web/dist/assets/index-DJOsPsU8.css +1 -0
  248. package/web/dist/index.html +13 -0
  249. package/web/dist/models/AnimatedMushnub.glb +0 -0
@@ -0,0 +1,249 @@
1
+ import { readFile } from "node:fs/promises";
2
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
+ const addIfDefined = (target, value) => {
4
+ if (typeof value === "string" && value.trim()) {
5
+ target.add(value);
6
+ }
7
+ };
8
+ const parseRoomScope = (value) => {
9
+ if (!value.startsWith("room:")) {
10
+ return undefined;
11
+ }
12
+ const rest = value.slice("room:".length);
13
+ const separatorIndex = rest.indexOf(":");
14
+ if (separatorIndex < 0 || separatorIndex === rest.length - 1) {
15
+ return undefined;
16
+ }
17
+ return `room:${rest.slice(0, separatorIndex)}:${rest.slice(separatorIndex + 1)}`;
18
+ };
19
+ const parseAgentScope = (value) => {
20
+ if (!value.startsWith("agent:")) {
21
+ return undefined;
22
+ }
23
+ const agentId = value.slice("agent:".length);
24
+ return agentId ? `agent:${agentId}` : undefined;
25
+ };
26
+ const parseTeamScope = (value) => {
27
+ if (!value.startsWith("team:")) {
28
+ return undefined;
29
+ }
30
+ const teamId = value.slice("team:".length);
31
+ return teamId ? `team:${teamId}` : undefined;
32
+ };
33
+ const createEmptyScopeIndex = () => ({
34
+ agents: new Set(),
35
+ rooms: new Set(),
36
+ teams: new Set()
37
+ });
38
+ const addTeamAndAgentScopes = (index, node) => {
39
+ if (typeof node.id !== "string") {
40
+ return;
41
+ }
42
+ const [kind, id] = node.id.split(":");
43
+ if (kind === "agent") {
44
+ addIfDefined(index.agents, id);
45
+ }
46
+ if (kind === "team") {
47
+ addIfDefined(index.teams, id);
48
+ }
49
+ };
50
+ const collectRoomScopes = (index, activeEnvironments) => {
51
+ if (!isRecord(activeEnvironments)) {
52
+ return;
53
+ }
54
+ const moltnet = activeEnvironments.moltnet;
55
+ if (!isRecord(moltnet)) {
56
+ return;
57
+ }
58
+ for (const [networkId, networkBinding] of Object.entries(moltnet)) {
59
+ if (!isRecord(networkBinding) || typeof networkId !== "string" || !networkId.trim()) {
60
+ continue;
61
+ }
62
+ const rooms = networkBinding.rooms;
63
+ if (!isRecord(rooms)) {
64
+ continue;
65
+ }
66
+ for (const roomId of Object.keys(rooms)) {
67
+ if (!roomId.trim()) {
68
+ continue;
69
+ }
70
+ index.rooms.add(`room:${networkId}:${roomId}`);
71
+ }
72
+ }
73
+ };
74
+ export const createReportScopeIndex = (report) => {
75
+ const index = createEmptyScopeIndex();
76
+ if (!isRecord(report) || !Array.isArray(report.nodes)) {
77
+ return index;
78
+ }
79
+ for (const nodeValue of report.nodes) {
80
+ if (!isRecord(nodeValue)) {
81
+ continue;
82
+ }
83
+ const node = nodeValue;
84
+ addTeamAndAgentScopes(index, node);
85
+ collectRoomScopes(index, node.active_environments);
86
+ }
87
+ return index;
88
+ };
89
+ const addMissingAgentDiagnostic = (agentScope, location, index, diagnostics) => {
90
+ if (!index.agents.has(agentScope.slice("agent:".length))) {
91
+ diagnostics.push({
92
+ level: "error",
93
+ message: `${location} references unknown agent ${agentScope}`
94
+ });
95
+ }
96
+ };
97
+ const addMissingTeamDiagnostic = (teamScope, location, index, diagnostics) => {
98
+ if (!index.teams.has(teamScope.slice("team:".length))) {
99
+ diagnostics.push({
100
+ level: "error",
101
+ message: `${location} references unknown team ${teamScope}`
102
+ });
103
+ }
104
+ };
105
+ const addMissingRoomDiagnostic = (roomScope, location, index, diagnostics) => {
106
+ if (!index.rooms.has(roomScope)) {
107
+ diagnostics.push({
108
+ level: "error",
109
+ message: `${location} references unknown room ${roomScope}`
110
+ });
111
+ }
112
+ };
113
+ const addDiagnosticsForScope = (scope, location, index, diagnostics) => {
114
+ const room = parseRoomScope(scope);
115
+ if (room) {
116
+ addMissingRoomDiagnostic(room, location, index, diagnostics);
117
+ return;
118
+ }
119
+ const agent = parseAgentScope(scope);
120
+ if (agent) {
121
+ addMissingAgentDiagnostic(agent, location, index, diagnostics);
122
+ return;
123
+ }
124
+ const team = parseTeamScope(scope);
125
+ if (team) {
126
+ addMissingTeamDiagnostic(team, location, index, diagnostics);
127
+ return;
128
+ }
129
+ };
130
+ const isEventNode = (value) => isRecord(value) && "event" in value;
131
+ const validateConditionScopes = (location, value, index, diagnostics) => {
132
+ if (!isRecord(value)) {
133
+ return;
134
+ }
135
+ if ("all" in value) {
136
+ const children = value.all;
137
+ if (!Array.isArray(children)) {
138
+ return;
139
+ }
140
+ children.forEach((child) => {
141
+ validateConditionScopes(location, child, index, diagnostics);
142
+ });
143
+ return;
144
+ }
145
+ if ("any" in value) {
146
+ const children = value.any;
147
+ if (!Array.isArray(children)) {
148
+ return;
149
+ }
150
+ children.forEach((child) => {
151
+ validateConditionScopes(location, child, index, diagnostics);
152
+ });
153
+ return;
154
+ }
155
+ if ("not" in value) {
156
+ validateConditionScopes(location, value.not, index, diagnostics);
157
+ return;
158
+ }
159
+ if (isEventNode(value)) {
160
+ if (typeof value.target === "string") {
161
+ addDiagnosticsForScope(value.target, `${location} event target`, index, diagnostics);
162
+ }
163
+ if (typeof value.actor === "string") {
164
+ addDiagnosticsForScope(value.actor, `${location} event actor`, index, diagnostics);
165
+ }
166
+ if (typeof value.scope === "string" && value.scope !== "global") {
167
+ addDiagnosticsForScope(value.scope, `${location} event scope`, index, diagnostics);
168
+ }
169
+ }
170
+ };
171
+ const validateVariableScopes = (variableId, variable, index, diagnostics) => {
172
+ if (variable.scope !== "global") {
173
+ addDiagnosticsForScope(variable.scope, `variable "${variableId}" scope`, index, diagnostics);
174
+ }
175
+ };
176
+ const validateRuleAction = (ruleId, action, index, diagnostics) => {
177
+ if ("to" in action) {
178
+ addDiagnosticsForScope(action.to, `rule "${ruleId}" action ${action.action} target`, index, diagnostics);
179
+ }
180
+ };
181
+ const validateMarkerScopes = (markerId, markerScopes, index, diagnostics) => {
182
+ for (const scope of markerScopes ?? []) {
183
+ if (scope !== "global") {
184
+ addDiagnosticsForScope(scope, `marker "${markerId}" scope`, index, diagnostics);
185
+ }
186
+ }
187
+ };
188
+ const validateRule = (ruleId, rule, index, diagnostics) => {
189
+ validateConditionScopes(`rule "${ruleId}"`, rule.when, index, diagnostics);
190
+ rule.do.forEach((action) => {
191
+ validateRuleAction(ruleId, action, index, diagnostics);
192
+ });
193
+ };
194
+ const validateProbe = (probeId, probe, index, diagnostics) => {
195
+ validateConditionScopes(`probe "${probeId}"`, probe.when, index, diagnostics);
196
+ if (probe.after) {
197
+ validateConditionScopes(`probe "${probeId}" after`, probe.after, index, diagnostics);
198
+ }
199
+ };
200
+ export const createBindingDiagnostics = (simfile, report) => {
201
+ const diagnostics = [];
202
+ if (!report) {
203
+ return diagnostics;
204
+ }
205
+ const index = createReportScopeIndex(report);
206
+ for (const [variableId, variable] of Object.entries(simfile.variables)) {
207
+ validateVariableScopes(variableId, variable, index, diagnostics);
208
+ }
209
+ for (const [markerId, marker] of Object.entries(simfile.markers)) {
210
+ validateMarkerScopes(markerId, marker.scopes, index, diagnostics);
211
+ }
212
+ for (const [ruleId, rule] of Object.entries(simfile.rules)) {
213
+ validateRule(ruleId, rule, index, diagnostics);
214
+ }
215
+ for (const [probeId, probe] of Object.entries(simfile.probes)) {
216
+ validateProbe(probeId, probe, index, diagnostics);
217
+ }
218
+ return diagnostics;
219
+ };
220
+ export const parseSpawnfileReportJson = (reportJson) => {
221
+ let report;
222
+ try {
223
+ report = JSON.parse(reportJson);
224
+ }
225
+ catch (error) {
226
+ throw new Error(`Invalid Spawnfile report JSON: ${error instanceof Error ? error.message : String(error)}`);
227
+ }
228
+ if (!isRecord(report) && !Array.isArray(report)) {
229
+ throw new Error("Spawnfile report must be a JSON object");
230
+ }
231
+ return report;
232
+ };
233
+ export const loadSpawnfileReport = async (pathOrJson) => {
234
+ try {
235
+ return parseSpawnfileReportJson(pathOrJson);
236
+ }
237
+ catch (parseError) {
238
+ const reportText = await readFile(pathOrJson, "utf8");
239
+ try {
240
+ return parseSpawnfileReportJson(reportText);
241
+ }
242
+ catch (fileError) {
243
+ if (parseError instanceof Error) {
244
+ throw parseError;
245
+ }
246
+ throw fileError;
247
+ }
248
+ }
249
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./model.js";
2
+ export * from "./parse.js";
3
+ export * from "./semantic.js";
4
+ export * from "./binding.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./model.js";
2
+ export * from "./parse.js";
3
+ export * from "./semantic.js";
4
+ export * from "./binding.js";
@@ -0,0 +1,244 @@
1
+ import { z } from "zod";
2
+ export declare const simfileIdentifierSchema: z.ZodString;
3
+ export declare const simfileRangeSchema: z.ZodString;
4
+ export declare const simfileEventKinds: readonly ["clock.sync", "rule.fired", "world.message", "world.dm", "world.act", "wake.recommended", "marker.seen"];
5
+ export declare const simfileWhenSchema: z.ZodTypeAny;
6
+ export declare const simfileClockSchema: z.ZodObject<{
7
+ seed: z.ZodString;
8
+ tick: z.ZodString;
9
+ sim_per_tick: z.ZodOptional<z.ZodString>;
10
+ phases: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
11
+ }, z.core.$strict>;
12
+ declare const simfileVariableSchema: z.ZodObject<{
13
+ scope: z.ZodString;
14
+ initial: z.ZodOptional<z.ZodNumber>;
15
+ range: z.ZodString;
16
+ measure: z.ZodOptional<z.ZodObject<{
17
+ kind: z.ZodEnum<{
18
+ messages_in: "messages_in";
19
+ token_mentions: "token_mentions";
20
+ marker_violations: "marker_violations";
21
+ distinct_speakers: "distinct_speakers";
22
+ mentions_of: "mentions_of";
23
+ ticks_since_last_message: "ticks_since_last_message";
24
+ }>;
25
+ scope: z.ZodOptional<z.ZodString>;
26
+ window: z.ZodString;
27
+ }, z.core.$strict>>;
28
+ derive: z.ZodOptional<z.ZodObject<{
29
+ eq: z.ZodString;
30
+ }, z.core.$strict>>;
31
+ fed_by: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strict>;
33
+ export declare const simfileGeneratorSchema: z.ZodUnion<readonly [z.ZodObject<{
34
+ kind: z.ZodLiteral<"deterministic">;
35
+ when: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
36
+ variable: z.ZodString;
37
+ delta: z.ZodOptional<z.ZodNumber>;
38
+ delta_eq: z.ZodOptional<z.ZodString>;
39
+ set_eq: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strict>, z.ZodObject<{
41
+ kind: z.ZodLiteral<"stochastic">;
42
+ when: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
43
+ variable: z.ZodString;
44
+ uniform: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
45
+ }, z.core.$strict>]>;
46
+ export declare const simfileRuleActionSchema: z.ZodUnion<readonly [z.ZodObject<{
47
+ action: z.ZodLiteral<"moltnet:message">;
48
+ to: z.ZodString;
49
+ content: z.ZodString;
50
+ }, z.core.$strict>, z.ZodObject<{
51
+ action: z.ZodLiteral<"moltnet:dm">;
52
+ to: z.ZodString;
53
+ content: z.ZodString;
54
+ }, z.core.$strict>, z.ZodObject<{
55
+ action: z.ZodLiteral<"wake:recommend">;
56
+ to: z.ZodString;
57
+ }, z.core.$strict>, z.ZodObject<{
58
+ action: z.ZodLiteral<"variable:set">;
59
+ variable: z.ZodString;
60
+ value: z.ZodNumber;
61
+ }, z.core.$strict>, z.ZodObject<{
62
+ action: z.ZodLiteral<"variable:delta">;
63
+ variable: z.ZodString;
64
+ value: z.ZodNumber;
65
+ }, z.core.$strict>]>;
66
+ export declare const simfileRuleSchema: z.ZodObject<{
67
+ fire: z.ZodDefault<z.ZodEnum<{
68
+ once: "once";
69
+ per_crossing: "per_crossing";
70
+ }>>;
71
+ when: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
72
+ do: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
73
+ action: z.ZodLiteral<"moltnet:message">;
74
+ to: z.ZodString;
75
+ content: z.ZodString;
76
+ }, z.core.$strict>, z.ZodObject<{
77
+ action: z.ZodLiteral<"moltnet:dm">;
78
+ to: z.ZodString;
79
+ content: z.ZodString;
80
+ }, z.core.$strict>, z.ZodObject<{
81
+ action: z.ZodLiteral<"wake:recommend">;
82
+ to: z.ZodString;
83
+ }, z.core.$strict>, z.ZodObject<{
84
+ action: z.ZodLiteral<"variable:set">;
85
+ variable: z.ZodString;
86
+ value: z.ZodNumber;
87
+ }, z.core.$strict>, z.ZodObject<{
88
+ action: z.ZodLiteral<"variable:delta">;
89
+ variable: z.ZodString;
90
+ value: z.ZodNumber;
91
+ }, z.core.$strict>]>>;
92
+ }, z.core.$strict>;
93
+ export declare const simfileLedgerSchema: z.ZodObject<{
94
+ store: z.ZodObject<{
95
+ kind: z.ZodDefault<z.ZodEnum<{
96
+ jsonl: "jsonl";
97
+ sqlite: "sqlite";
98
+ postgres: "postgres";
99
+ }>>;
100
+ path: z.ZodOptional<z.ZodString>;
101
+ }, z.core.$strict>;
102
+ }, z.core.$strict>;
103
+ export declare const simfileTelemetrySchema: z.ZodObject<{
104
+ snapshot_every: z.ZodOptional<z.ZodNumber>;
105
+ }, z.core.$strict>;
106
+ export declare const simfileMarkerSchema: z.ZodObject<{
107
+ text: z.ZodOptional<z.ZodArray<z.ZodString>>;
108
+ mode: z.ZodEnum<{
109
+ containment: "containment";
110
+ propagation: "propagation";
111
+ }>;
112
+ scopes: z.ZodArray<z.ZodString>;
113
+ }, z.core.$strict>;
114
+ export declare const simfileProbeSchema: z.ZodObject<{
115
+ when: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
116
+ expect: z.ZodUnion<readonly [z.ZodObject<{
117
+ at_least: z.ZodNumber;
118
+ }, z.core.$strict>, z.ZodObject<{
119
+ at_most: z.ZodNumber;
120
+ }, z.core.$strict>, z.ZodObject<{
121
+ always: z.ZodLiteral<true>;
122
+ }, z.core.$strict>, z.ZodObject<{
123
+ at_end: z.ZodLiteral<true>;
124
+ }, z.core.$strict>]>;
125
+ after: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
126
+ within: z.ZodOptional<z.ZodString>;
127
+ }, z.core.$strict>;
128
+ export declare const simfileSchema: z.ZodObject<{
129
+ simfile_version: z.ZodLiteral<"0.1">;
130
+ name: z.ZodString;
131
+ spawnfile: z.ZodOptional<z.ZodString>;
132
+ clock: z.ZodObject<{
133
+ seed: z.ZodString;
134
+ tick: z.ZodString;
135
+ sim_per_tick: z.ZodOptional<z.ZodString>;
136
+ phases: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
137
+ }, z.core.$strict>;
138
+ variables: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
139
+ scope: z.ZodString;
140
+ initial: z.ZodOptional<z.ZodNumber>;
141
+ range: z.ZodString;
142
+ measure: z.ZodOptional<z.ZodObject<{
143
+ kind: z.ZodEnum<{
144
+ messages_in: "messages_in";
145
+ token_mentions: "token_mentions";
146
+ marker_violations: "marker_violations";
147
+ distinct_speakers: "distinct_speakers";
148
+ mentions_of: "mentions_of";
149
+ ticks_since_last_message: "ticks_since_last_message";
150
+ }>;
151
+ scope: z.ZodOptional<z.ZodString>;
152
+ window: z.ZodString;
153
+ }, z.core.$strict>>;
154
+ derive: z.ZodOptional<z.ZodObject<{
155
+ eq: z.ZodString;
156
+ }, z.core.$strict>>;
157
+ fed_by: z.ZodOptional<z.ZodString>;
158
+ }, z.core.$strict>>>;
159
+ generators: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
160
+ kind: z.ZodLiteral<"deterministic">;
161
+ when: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
162
+ variable: z.ZodString;
163
+ delta: z.ZodOptional<z.ZodNumber>;
164
+ delta_eq: z.ZodOptional<z.ZodString>;
165
+ set_eq: z.ZodOptional<z.ZodString>;
166
+ }, z.core.$strict>, z.ZodObject<{
167
+ kind: z.ZodLiteral<"stochastic">;
168
+ when: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
169
+ variable: z.ZodString;
170
+ uniform: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
171
+ }, z.core.$strict>]>>>;
172
+ rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
173
+ fire: z.ZodDefault<z.ZodEnum<{
174
+ once: "once";
175
+ per_crossing: "per_crossing";
176
+ }>>;
177
+ when: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
178
+ do: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
179
+ action: z.ZodLiteral<"moltnet:message">;
180
+ to: z.ZodString;
181
+ content: z.ZodString;
182
+ }, z.core.$strict>, z.ZodObject<{
183
+ action: z.ZodLiteral<"moltnet:dm">;
184
+ to: z.ZodString;
185
+ content: z.ZodString;
186
+ }, z.core.$strict>, z.ZodObject<{
187
+ action: z.ZodLiteral<"wake:recommend">;
188
+ to: z.ZodString;
189
+ }, z.core.$strict>, z.ZodObject<{
190
+ action: z.ZodLiteral<"variable:set">;
191
+ variable: z.ZodString;
192
+ value: z.ZodNumber;
193
+ }, z.core.$strict>, z.ZodObject<{
194
+ action: z.ZodLiteral<"variable:delta">;
195
+ variable: z.ZodString;
196
+ value: z.ZodNumber;
197
+ }, z.core.$strict>]>>;
198
+ }, z.core.$strict>>>;
199
+ ledger: z.ZodOptional<z.ZodObject<{
200
+ store: z.ZodObject<{
201
+ kind: z.ZodDefault<z.ZodEnum<{
202
+ jsonl: "jsonl";
203
+ sqlite: "sqlite";
204
+ postgres: "postgres";
205
+ }>>;
206
+ path: z.ZodOptional<z.ZodString>;
207
+ }, z.core.$strict>;
208
+ }, z.core.$strict>>;
209
+ telemetry: z.ZodOptional<z.ZodObject<{
210
+ snapshot_every: z.ZodOptional<z.ZodNumber>;
211
+ }, z.core.$strict>>;
212
+ markers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
213
+ text: z.ZodOptional<z.ZodArray<z.ZodString>>;
214
+ mode: z.ZodEnum<{
215
+ containment: "containment";
216
+ propagation: "propagation";
217
+ }>;
218
+ scopes: z.ZodArray<z.ZodString>;
219
+ }, z.core.$strict>>>;
220
+ probes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
221
+ when: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
222
+ expect: z.ZodUnion<readonly [z.ZodObject<{
223
+ at_least: z.ZodNumber;
224
+ }, z.core.$strict>, z.ZodObject<{
225
+ at_most: z.ZodNumber;
226
+ }, z.core.$strict>, z.ZodObject<{
227
+ always: z.ZodLiteral<true>;
228
+ }, z.core.$strict>, z.ZodObject<{
229
+ at_end: z.ZodLiteral<true>;
230
+ }, z.core.$strict>]>;
231
+ after: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
232
+ within: z.ZodOptional<z.ZodString>;
233
+ }, z.core.$strict>>>;
234
+ }, z.core.$strict>;
235
+ export type Simfile = z.infer<typeof simfileSchema>;
236
+ export type SimfileClock = z.infer<typeof simfileClockSchema>;
237
+ export type SimfileGenerator = z.infer<typeof simfileGeneratorSchema>;
238
+ export type SimfileRule = z.infer<typeof simfileRuleSchema>;
239
+ export type SimfileLedger = z.infer<typeof simfileLedgerSchema>;
240
+ export type SimfileProbe = z.infer<typeof simfileProbeSchema>;
241
+ export type SimfileRuleAction = z.infer<typeof simfileRuleActionSchema>;
242
+ export type SimfileVariable = z.infer<typeof simfileVariableSchema>;
243
+ export {};
244
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/schema/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,uBAAuB,aAElC,CAAC;AAMH,eAAO,MAAM,kBAAkB,aAY7B,CAAC;AAuBH,eAAO,MAAM,iBAAiB,oHAQpB,CAAC;AAwBX,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,UAW/B,CAAC;AAEJ,eAAO,MAAM,kBAAkB;;;;;kBAKpB,CAAC;AAYZ,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;kBAYhB,CAAC;AAuBZ,eAAO,MAAM,sBAAsB;;;;;;;;;;;;oBAGjC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;oBAyBlC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;kBAInB,CAAC;AAEZ,eAAO,MAAM,mBAAmB;;;;;;;;;kBAKrB,CAAC;AAEZ,eAAO,MAAM,sBAAsB;;kBAExB,CAAC;AAEZ,eAAO,MAAM,mBAAmB;;;;;;;kBAIrB,CAAC;AAkBZ,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;kBAoBpB,CAAC;AAEZ,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAYf,CAAC;AAEZ,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}