@inflexa-ai/harness 0.19.2 → 0.21.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 (139) hide show
  1. package/dist/agents/conversation-agent.d.ts +26 -14
  2. package/dist/agents/conversation-agent.js +12 -23
  3. package/dist/agents/report-session-agent.d.ts +31 -5
  4. package/dist/agents/report-session-agent.js +31 -6
  5. package/dist/app/chat-turn.js +3 -1
  6. package/dist/app/message-assembly.d.ts +15 -1
  7. package/dist/app/message-assembly.js +22 -8
  8. package/dist/app/report-session-runtime.d.ts +21 -4
  9. package/dist/app/report-session-runtime.js +53 -6
  10. package/dist/app/spawn-report-session.d.ts +174 -17
  11. package/dist/app/spawn-report-session.js +233 -21
  12. package/dist/contracts/chat-events.d.ts +7 -2
  13. package/dist/contracts/message.d.ts +10 -0
  14. package/dist/contracts/report-blocks.d.ts +743 -19
  15. package/dist/contracts/report-blocks.js +186 -11
  16. package/dist/contracts/report-reference.d.ts +88 -0
  17. package/dist/contracts/report-reference.js +48 -0
  18. package/dist/index.d.ts +9 -0
  19. package/dist/index.js +20 -0
  20. package/dist/lib/chrome.d.ts +26 -6
  21. package/dist/lib/chrome.js +99 -32
  22. package/dist/lib/eyes.d.ts +57 -0
  23. package/dist/lib/eyes.js +45 -0
  24. package/dist/lib/page-capture.d.ts +14 -0
  25. package/dist/lib/page-capture.js +56 -2
  26. package/dist/literature/sources/pubmed.js +2 -1
  27. package/dist/loop/run-agent.js +58 -23
  28. package/dist/loop/tool-detail.d.ts +19 -2
  29. package/dist/loop/tool-detail.js +35 -2
  30. package/dist/memory/content-to-cortex.d.ts +3 -2
  31. package/dist/memory/content-to-cortex.js +21 -12
  32. package/dist/memory/conversation-display-replay.js +14 -7
  33. package/dist/memory/thread-history.d.ts +60 -3
  34. package/dist/memory/thread-history.js +55 -16
  35. package/dist/memory/thread-store.d.ts +11 -1
  36. package/dist/memory/thread-store.js +12 -2
  37. package/dist/prompts/conversation.d.ts +1 -1
  38. package/dist/prompts/conversation.js +23 -6
  39. package/dist/prompts/report-session.d.ts +1 -1
  40. package/dist/prompts/report-session.js +183 -9
  41. package/dist/report-model/authoring-grammar.d.ts +463 -0
  42. package/dist/report-model/authoring-grammar.js +77 -0
  43. package/dist/report-model/block-walk.d.ts +57 -14
  44. package/dist/report-model/block-walk.js +116 -11
  45. package/dist/report-model/draft-finish.d.ts +22 -4
  46. package/dist/report-model/draft-finish.js +39 -7
  47. package/dist/report-model/draft-operations.d.ts +3 -0
  48. package/dist/report-model/draft-operations.js +19 -5
  49. package/dist/report-model/draft-read.d.ts +8 -5
  50. package/dist/report-model/draft-read.js +21 -5
  51. package/dist/report-model/fixture-resolver.js +15 -4
  52. package/dist/report-model/pin-snapshot.d.ts +24 -6
  53. package/dist/report-model/pin-snapshot.js +204 -6
  54. package/dist/report-model/production-resolver.js +15 -4
  55. package/dist/report-model/reference-resolver.d.ts +50 -1
  56. package/dist/report-model/reference-resolver.js +94 -1
  57. package/dist/report-model/reference-stamp.d.ts +45 -0
  58. package/dist/report-model/reference-stamp.js +173 -0
  59. package/dist/report-model/structural-validation.d.ts +4 -1
  60. package/dist/report-model/structural-validation.js +48 -3
  61. package/dist/report-model/validate.d.ts +1 -1
  62. package/dist/report-model/validate.js +1 -1
  63. package/dist/report-render/asset-lookup.d.ts +19 -0
  64. package/dist/report-render/asset-lookup.js +37 -0
  65. package/dist/report-render/assets.d.ts +45 -1
  66. package/dist/report-render/assets.js +65 -6
  67. package/dist/report-render/chart-presets.d.ts +102 -0
  68. package/dist/report-render/chart-presets.js +205 -0
  69. package/dist/report-render/chart.d.ts +112 -10
  70. package/dist/report-render/chart.js +1164 -41
  71. package/dist/report-render/design.d.ts +99 -0
  72. package/dist/report-render/design.js +289 -107
  73. package/dist/report-render/number-format.d.ts +117 -0
  74. package/dist/report-render/number-format.js +479 -0
  75. package/dist/report-render/page.d.ts +121 -5
  76. package/dist/report-render/page.js +689 -7
  77. package/dist/report-render/references.d.ts +70 -16
  78. package/dist/report-render/references.js +54 -22
  79. package/dist/report-render/render.d.ts +23 -5
  80. package/dist/report-render/render.js +81 -22
  81. package/dist/report-render/table-data.d.ts +92 -0
  82. package/dist/report-render/table-data.js +129 -0
  83. package/dist/report-render/types.d.ts +15 -0
  84. package/dist/report-render/value-bridge.js +6 -2
  85. package/dist/report-render/views/chart-view.d.ts +12 -5
  86. package/dist/report-render/views/chart-view.js +14 -8
  87. package/dist/report-render/views/page-view.d.ts +36 -15
  88. package/dist/report-render/views/page-view.js +45 -23
  89. package/dist/report-render/views/prose.d.ts +12 -2
  90. package/dist/report-render/views/prose.js +29 -7
  91. package/dist/report-render/views/references-view.d.ts +22 -8
  92. package/dist/report-render/views/references-view.js +101 -13
  93. package/dist/report-render/views/values.d.ts +128 -13
  94. package/dist/report-render/views/values.js +199 -18
  95. package/dist/runtime/assemble.d.ts +39 -5
  96. package/dist/runtime/assemble.js +47 -6
  97. package/dist/sandbox/client.d.ts +10 -1
  98. package/dist/sandbox/create-sandbox.d.ts +9 -4
  99. package/dist/sandbox/create-sandbox.js +22 -16
  100. package/dist/sandbox/docker-client.js +10 -7
  101. package/dist/sandbox/k8s-client.js +11 -18
  102. package/dist/sandbox/mount-plan.d.ts +45 -7
  103. package/dist/sandbox/mount-plan.js +43 -5
  104. package/dist/sandbox/types.d.ts +10 -6
  105. package/dist/state/init.js +38 -9
  106. package/dist/state/report-session-state.d.ts +42 -1
  107. package/dist/state/report-session-state.js +70 -2
  108. package/dist/state/report-versions.d.ts +22 -17
  109. package/dist/state/report-versions.js +48 -35
  110. package/dist/state/snapshot-parse.js +16 -1
  111. package/dist/tasks/data-profile.d.ts +7 -4
  112. package/dist/tasks/data-profile.js +9 -9
  113. package/dist/tools/define-tool.d.ts +32 -0
  114. package/dist/tools/define-tool.js +4 -0
  115. package/dist/tools/detail-resolver.d.ts +7 -2
  116. package/dist/tools/detail-resolver.js +7 -2
  117. package/dist/tools/iterate-report.d.ts +1 -1
  118. package/dist/tools/report/preview-snapshot.js +1 -0
  119. package/dist/tools/report-authoring/authoring-tools.d.ts +15 -6
  120. package/dist/tools/report-authoring/authoring-tools.js +99 -18
  121. package/dist/tools/report-session/derive-table.d.ts +162 -0
  122. package/dist/tools/report-session/derive-table.js +459 -0
  123. package/dist/tools/report-session/examine-page.d.ts +48 -18
  124. package/dist/tools/report-session/examine-page.js +204 -24
  125. package/dist/tools/report-session/index.d.ts +2 -0
  126. package/dist/tools/report-session/index.js +2 -0
  127. package/dist/tools/report-session/list-artifacts.d.ts +97 -0
  128. package/dist/tools/report-session/list-artifacts.js +197 -0
  129. package/dist/tools/report-session/preview-report.d.ts +6 -0
  130. package/dist/tools/report-session/preview-report.js +180 -28
  131. package/dist/tools/report-session/record-version.d.ts +22 -10
  132. package/dist/tools/report-session/record-version.js +99 -14
  133. package/dist/tools/start-report-session.d.ts +115 -0
  134. package/dist/tools/start-report-session.js +179 -0
  135. package/dist/workflows/sandbox-step.d.ts +7 -4
  136. package/dist/workflows/sandbox-step.js +10 -12
  137. package/dist/workspace/paths.d.ts +50 -0
  138. package/dist/workspace/paths.js +63 -0
  139. package/package.json +2 -1
@@ -0,0 +1,463 @@
1
+ /**
2
+ * The block grammar that an agent writes and reads.
3
+ *
4
+ * The pinned snapshot owns the hash of each artifact reference. Thus an agent names the path alone, and the
5
+ * land path stamps the hash from the snapshot entry at that path. This grammar is the contract grammar with
6
+ * that one field dropped. The published input schema of a tool shows no hash, and a read of a block gives
7
+ * none back. Thus an agent never sees a hash, and it never mistypes one.
8
+ *
9
+ * The grammar composes from the contract schemas, and it does not copy them. Each block keeps its own
10
+ * fields, and only the reference-bearing field of a kind changes. Thus a new field of a block reaches this
11
+ * grammar the moment that the contract declares it.
12
+ *
13
+ * The stored form stays the contract form. The stamp fills the hash before the draft grammar parses the
14
+ * payload, thus the grounding and the resolution read the same pin as before.
15
+ */
16
+ import { z } from "zod";
17
+ /**
18
+ * The seven atoms of the authoring surface.
19
+ *
20
+ * A text block and a citation block bind no artifact, thus each one is the contract schema itself. The five
21
+ * others replace the one field that carries a pin.
22
+ */
23
+ declare const AUTHORING_ATOM_SCHEMAS: readonly [z.ZodObject<{
24
+ kind: z.ZodLiteral<"text">;
25
+ id: z.ZodString;
26
+ content: z.ZodObject<{
27
+ prose: z.ZodString;
28
+ list: z.ZodOptional<z.ZodObject<{
29
+ ordered: z.ZodBoolean;
30
+ items: z.ZodArray<z.ZodString>;
31
+ }, z.core.$strict>>;
32
+ }, z.core.$strict>;
33
+ }, z.core.$strict>, z.ZodObject<{
34
+ kind: z.ZodLiteral<"claim">;
35
+ id: z.ZodString;
36
+ content: z.ZodObject<{
37
+ prose: z.ZodString;
38
+ }, z.core.$strict>;
39
+ bindings: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
40
+ format: z.ZodOptional<z.ZodString>;
41
+ kind: z.ZodLiteral<"artifact-value">;
42
+ path: z.ZodString;
43
+ unit: z.ZodOptional<z.ZodString>;
44
+ locator: z.ZodObject<{
45
+ column: z.ZodString;
46
+ rowFilter: z.ZodOptional<z.ZodObject<{
47
+ column: z.ZodString;
48
+ op: z.ZodLiteral<"eq">;
49
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
50
+ }, z.core.$strict>>;
51
+ row: z.ZodOptional<z.ZodNumber>;
52
+ }, z.core.$strict>;
53
+ assert: z.ZodOptional<z.ZodObject<{
54
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
55
+ tolerance: z.ZodOptional<z.ZodNumber>;
56
+ }, z.core.$strict>>;
57
+ run: z.ZodOptional<z.ZodString>;
58
+ snapshot: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strict>, z.ZodObject<{
60
+ format: z.ZodOptional<z.ZodString>;
61
+ kind: z.ZodLiteral<"artifact-table">;
62
+ path: z.ZodString;
63
+ unit: z.ZodOptional<z.ZodString>;
64
+ rowBound: z.ZodOptional<z.ZodObject<{
65
+ column: z.ZodString;
66
+ count: z.ZodNumber;
67
+ order: z.ZodOptional<z.ZodEnum<{
68
+ desc: "desc";
69
+ asc: "asc";
70
+ }>>;
71
+ }, z.core.$strict>>;
72
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
+ columnMeanings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
74
+ count: "count";
75
+ identifier: "identifier";
76
+ category: "category";
77
+ "p-value": "p-value";
78
+ effect: "effect";
79
+ }>>>;
80
+ columnLabels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
81
+ run: z.ZodOptional<z.ZodString>;
82
+ snapshot: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strict>, z.ZodObject<{
84
+ format: z.ZodOptional<z.ZodString>;
85
+ kind: z.ZodLiteral<"artifact-file">;
86
+ path: z.ZodString;
87
+ unit: z.ZodOptional<z.ZodString>;
88
+ run: z.ZodOptional<z.ZodString>;
89
+ snapshot: z.ZodOptional<z.ZodString>;
90
+ }, z.core.$strict>, z.ZodObject<{
91
+ unit: z.ZodOptional<z.ZodString>;
92
+ format: z.ZodOptional<z.ZodString>;
93
+ kind: z.ZodLiteral<"derivation">;
94
+ op: z.ZodEnum<{
95
+ ratio: "ratio";
96
+ delta: "delta";
97
+ pctChange: "pctChange";
98
+ }>;
99
+ assert: z.ZodOptional<z.ZodObject<{
100
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
101
+ tolerance: z.ZodOptional<z.ZodNumber>;
102
+ }, z.core.$strict>>;
103
+ inputs: z.ZodArray<z.ZodObject<{
104
+ format: z.ZodOptional<z.ZodString>;
105
+ kind: z.ZodLiteral<"artifact-value">;
106
+ path: z.ZodString;
107
+ unit: z.ZodOptional<z.ZodString>;
108
+ locator: z.ZodObject<{
109
+ column: z.ZodString;
110
+ rowFilter: z.ZodOptional<z.ZodObject<{
111
+ column: z.ZodString;
112
+ op: z.ZodLiteral<"eq">;
113
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
114
+ }, z.core.$strict>>;
115
+ row: z.ZodOptional<z.ZodNumber>;
116
+ }, z.core.$strict>;
117
+ assert: z.ZodOptional<z.ZodObject<{
118
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
119
+ tolerance: z.ZodOptional<z.ZodNumber>;
120
+ }, z.core.$strict>>;
121
+ run: z.ZodOptional<z.ZodString>;
122
+ snapshot: z.ZodOptional<z.ZodString>;
123
+ }, z.core.$strict>>;
124
+ }, z.core.$strict>, z.ZodObject<{
125
+ unit: z.ZodOptional<z.ZodString>;
126
+ format: z.ZodOptional<z.ZodString>;
127
+ kind: z.ZodLiteral<"citation">;
128
+ idKind: z.ZodEnum<{
129
+ doi: "doi";
130
+ pmid: "pmid";
131
+ arxiv: "arxiv";
132
+ }>;
133
+ id: z.ZodString;
134
+ raw: z.ZodString;
135
+ assert: z.ZodOptional<z.ZodObject<{
136
+ value: z.ZodString;
137
+ }, z.core.$strict>>;
138
+ }, z.core.$strict>], "kind">>;
139
+ }, z.core.$strict>, z.ZodObject<{
140
+ kind: z.ZodLiteral<"metric">;
141
+ id: z.ZodString;
142
+ label: z.ZodString;
143
+ value: z.ZodDiscriminatedUnion<[z.ZodObject<{
144
+ format: z.ZodOptional<z.ZodString>;
145
+ kind: z.ZodLiteral<"artifact-value">;
146
+ path: z.ZodString;
147
+ unit: z.ZodOptional<z.ZodString>;
148
+ locator: z.ZodObject<{
149
+ column: z.ZodString;
150
+ rowFilter: z.ZodOptional<z.ZodObject<{
151
+ column: z.ZodString;
152
+ op: z.ZodLiteral<"eq">;
153
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
154
+ }, z.core.$strict>>;
155
+ row: z.ZodOptional<z.ZodNumber>;
156
+ }, z.core.$strict>;
157
+ assert: z.ZodOptional<z.ZodObject<{
158
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
159
+ tolerance: z.ZodOptional<z.ZodNumber>;
160
+ }, z.core.$strict>>;
161
+ run: z.ZodOptional<z.ZodString>;
162
+ snapshot: z.ZodOptional<z.ZodString>;
163
+ }, z.core.$strict>, z.ZodObject<{
164
+ unit: z.ZodOptional<z.ZodString>;
165
+ format: z.ZodOptional<z.ZodString>;
166
+ kind: z.ZodLiteral<"derivation">;
167
+ op: z.ZodEnum<{
168
+ ratio: "ratio";
169
+ delta: "delta";
170
+ pctChange: "pctChange";
171
+ }>;
172
+ assert: z.ZodOptional<z.ZodObject<{
173
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
174
+ tolerance: z.ZodOptional<z.ZodNumber>;
175
+ }, z.core.$strict>>;
176
+ inputs: z.ZodArray<z.ZodObject<{
177
+ format: z.ZodOptional<z.ZodString>;
178
+ kind: z.ZodLiteral<"artifact-value">;
179
+ path: z.ZodString;
180
+ unit: z.ZodOptional<z.ZodString>;
181
+ locator: z.ZodObject<{
182
+ column: z.ZodString;
183
+ rowFilter: z.ZodOptional<z.ZodObject<{
184
+ column: z.ZodString;
185
+ op: z.ZodLiteral<"eq">;
186
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
187
+ }, z.core.$strict>>;
188
+ row: z.ZodOptional<z.ZodNumber>;
189
+ }, z.core.$strict>;
190
+ assert: z.ZodOptional<z.ZodObject<{
191
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
192
+ tolerance: z.ZodOptional<z.ZodNumber>;
193
+ }, z.core.$strict>>;
194
+ run: z.ZodOptional<z.ZodString>;
195
+ snapshot: z.ZodOptional<z.ZodString>;
196
+ }, z.core.$strict>>;
197
+ }, z.core.$strict>], "kind">;
198
+ }, z.core.$strict>, z.ZodObject<{
199
+ kind: z.ZodLiteral<"table">;
200
+ id: z.ZodString;
201
+ title: z.ZodOptional<z.ZodString>;
202
+ caption: z.ZodOptional<z.ZodString>;
203
+ binding: z.ZodObject<{
204
+ format: z.ZodOptional<z.ZodString>;
205
+ kind: z.ZodLiteral<"artifact-table">;
206
+ path: z.ZodString;
207
+ unit: z.ZodOptional<z.ZodString>;
208
+ rowBound: z.ZodOptional<z.ZodObject<{
209
+ column: z.ZodString;
210
+ count: z.ZodNumber;
211
+ order: z.ZodOptional<z.ZodEnum<{
212
+ desc: "desc";
213
+ asc: "asc";
214
+ }>>;
215
+ }, z.core.$strict>>;
216
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
217
+ columnMeanings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
218
+ count: "count";
219
+ identifier: "identifier";
220
+ category: "category";
221
+ "p-value": "p-value";
222
+ effect: "effect";
223
+ }>>>;
224
+ columnLabels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
225
+ run: z.ZodOptional<z.ZodString>;
226
+ snapshot: z.ZodOptional<z.ZodString>;
227
+ }, z.core.$strict>;
228
+ }, z.core.$strict>, z.ZodObject<{
229
+ binding: z.ZodObject<{
230
+ format: z.ZodOptional<z.ZodString>;
231
+ kind: z.ZodLiteral<"artifact-table">;
232
+ path: z.ZodString;
233
+ unit: z.ZodOptional<z.ZodString>;
234
+ rowBound: z.ZodOptional<z.ZodObject<{
235
+ column: z.ZodString;
236
+ count: z.ZodNumber;
237
+ order: z.ZodOptional<z.ZodEnum<{
238
+ desc: "desc";
239
+ asc: "asc";
240
+ }>>;
241
+ }, z.core.$strict>>;
242
+ columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
243
+ columnMeanings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
244
+ count: "count";
245
+ identifier: "identifier";
246
+ category: "category";
247
+ "p-value": "p-value";
248
+ effect: "effect";
249
+ }>>>;
250
+ columnLabels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
251
+ run: z.ZodOptional<z.ZodString>;
252
+ snapshot: z.ZodOptional<z.ZodString>;
253
+ }, z.core.$strict>;
254
+ kind: z.ZodLiteral<"chart">;
255
+ id: z.ZodString;
256
+ title: z.ZodOptional<z.ZodString>;
257
+ chartType: z.ZodOptional<z.ZodEnum<{
258
+ bar: "bar";
259
+ line: "line";
260
+ scatter: "scatter";
261
+ histogram: "histogram";
262
+ box: "box";
263
+ heatmap: "heatmap";
264
+ pie: "pie";
265
+ volcano: "volcano";
266
+ manhattan: "manhattan";
267
+ ma: "ma";
268
+ km: "km";
269
+ }>>;
270
+ encoding: z.ZodOptional<z.ZodObject<{
271
+ x: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
272
+ column: z.ZodString;
273
+ transform: z.ZodEnum<{
274
+ log10: "log10";
275
+ neg_log10: "neg_log10";
276
+ abs: "abs";
277
+ rank: "rank";
278
+ }>;
279
+ }, z.core.$strict>]>>;
280
+ y: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
281
+ column: z.ZodString;
282
+ transform: z.ZodEnum<{
283
+ log10: "log10";
284
+ neg_log10: "neg_log10";
285
+ abs: "abs";
286
+ rank: "rank";
287
+ }>;
288
+ }, z.core.$strict>]>>;
289
+ group: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
290
+ column: z.ZodString;
291
+ transform: z.ZodEnum<{
292
+ log10: "log10";
293
+ neg_log10: "neg_log10";
294
+ abs: "abs";
295
+ rank: "rank";
296
+ }>;
297
+ }, z.core.$strict>]>>;
298
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
299
+ column: z.ZodString;
300
+ transform: z.ZodEnum<{
301
+ log10: "log10";
302
+ neg_log10: "neg_log10";
303
+ abs: "abs";
304
+ rank: "rank";
305
+ }>;
306
+ }, z.core.$strict>]>>;
307
+ label: z.ZodOptional<z.ZodString>;
308
+ }, z.core.$strict>>;
309
+ orientation: z.ZodOptional<z.ZodEnum<{
310
+ vertical: "vertical";
311
+ horizontal: "horizontal";
312
+ }>>;
313
+ thresholds: z.ZodOptional<z.ZodObject<{
314
+ significance: z.ZodNumber;
315
+ effect: z.ZodNumber;
316
+ }, z.core.$strict>>;
317
+ composition: z.ZodOptional<z.ZodObject<{
318
+ series: z.ZodArray<z.ZodObject<{
319
+ form: z.ZodEnum<{
320
+ step: "step";
321
+ bar: "bar";
322
+ line: "line";
323
+ scatter: "scatter";
324
+ area: "area";
325
+ }>;
326
+ encoding: z.ZodObject<{
327
+ x: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
328
+ column: z.ZodString;
329
+ transform: z.ZodEnum<{
330
+ log10: "log10";
331
+ neg_log10: "neg_log10";
332
+ abs: "abs";
333
+ rank: "rank";
334
+ }>;
335
+ }, z.core.$strict>]>;
336
+ y: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
337
+ column: z.ZodString;
338
+ transform: z.ZodEnum<{
339
+ log10: "log10";
340
+ neg_log10: "neg_log10";
341
+ abs: "abs";
342
+ rank: "rank";
343
+ }>;
344
+ }, z.core.$strict>]>;
345
+ y0: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
346
+ column: z.ZodString;
347
+ transform: z.ZodEnum<{
348
+ log10: "log10";
349
+ neg_log10: "neg_log10";
350
+ abs: "abs";
351
+ rank: "rank";
352
+ }>;
353
+ }, z.core.$strict>]>>;
354
+ group: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
355
+ column: z.ZodString;
356
+ transform: z.ZodEnum<{
357
+ log10: "log10";
358
+ neg_log10: "neg_log10";
359
+ abs: "abs";
360
+ rank: "rank";
361
+ }>;
362
+ }, z.core.$strict>]>>;
363
+ label: z.ZodOptional<z.ZodString>;
364
+ }, z.core.$strict>;
365
+ name: z.ZodOptional<z.ZodString>;
366
+ orientation: z.ZodOptional<z.ZodEnum<{
367
+ vertical: "vertical";
368
+ horizontal: "horizontal";
369
+ }>>;
370
+ }, z.core.$strict>>;
371
+ annotations: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
372
+ kind: z.ZodLiteral<"reference-line">;
373
+ axis: z.ZodEnum<{
374
+ x: "x";
375
+ y: "y";
376
+ }>;
377
+ value: z.ZodNumber;
378
+ label: z.ZodOptional<z.ZodString>;
379
+ }, z.core.$strict>, z.ZodObject<{
380
+ kind: z.ZodLiteral<"reference-band">;
381
+ axis: z.ZodEnum<{
382
+ x: "x";
383
+ y: "y";
384
+ }>;
385
+ from: z.ZodNumber;
386
+ to: z.ZodNumber;
387
+ label: z.ZodOptional<z.ZodString>;
388
+ }, z.core.$strict>, z.ZodObject<{
389
+ kind: z.ZodLiteral<"point-labels">;
390
+ column: z.ZodString;
391
+ order: z.ZodEnum<{
392
+ desc: "desc";
393
+ asc: "asc";
394
+ }>;
395
+ n: z.ZodNumber;
396
+ }, z.core.$strict>], "kind">>>;
397
+ axes: z.ZodOptional<z.ZodObject<{
398
+ x: z.ZodOptional<z.ZodObject<{
399
+ title: z.ZodOptional<z.ZodString>;
400
+ scale: z.ZodOptional<z.ZodEnum<{
401
+ log: "log";
402
+ linear: "linear";
403
+ }>>;
404
+ }, z.core.$strict>>;
405
+ y: z.ZodOptional<z.ZodObject<{
406
+ title: z.ZodOptional<z.ZodString>;
407
+ scale: z.ZodOptional<z.ZodEnum<{
408
+ log: "log";
409
+ linear: "linear";
410
+ }>>;
411
+ }, z.core.$strict>>;
412
+ }, z.core.$strict>>;
413
+ }, z.core.$strict>>;
414
+ caption: z.ZodOptional<z.ZodString>;
415
+ }, z.core.$strict>, z.ZodObject<{
416
+ kind: z.ZodLiteral<"figure">;
417
+ id: z.ZodString;
418
+ caption: z.ZodOptional<z.ZodString>;
419
+ binding: z.ZodObject<{
420
+ format: z.ZodOptional<z.ZodString>;
421
+ kind: z.ZodLiteral<"artifact-file">;
422
+ path: z.ZodString;
423
+ unit: z.ZodOptional<z.ZodString>;
424
+ run: z.ZodOptional<z.ZodString>;
425
+ snapshot: z.ZodOptional<z.ZodString>;
426
+ }, z.core.$strict>;
427
+ }, z.core.$strict>, z.ZodObject<{
428
+ kind: z.ZodLiteral<"citation">;
429
+ id: z.ZodString;
430
+ binding: z.ZodObject<{
431
+ unit: z.ZodOptional<z.ZodString>;
432
+ format: z.ZodOptional<z.ZodString>;
433
+ kind: z.ZodLiteral<"citation">;
434
+ idKind: z.ZodEnum<{
435
+ doi: "doi";
436
+ pmid: "pmid";
437
+ arxiv: "arxiv";
438
+ }>;
439
+ id: z.ZodString;
440
+ raw: z.ZodString;
441
+ assert: z.ZodOptional<z.ZodObject<{
442
+ value: z.ZodString;
443
+ }, z.core.$strict>>;
444
+ }, z.core.$strict>;
445
+ note: z.ZodOptional<z.ZodString>;
446
+ }, z.core.$strict>];
447
+ /**
448
+ * The section shape as a plain type. TypeScript cannot infer the block tree through the union cycle, thus
449
+ * the recursive members carry an explicit type.
450
+ */
451
+ export interface AuthoringSectionBlock {
452
+ kind: "section";
453
+ id: string;
454
+ title: string;
455
+ blocks: AuthoringBlock[];
456
+ }
457
+ /** One block of any kind except a section, as an agent writes it and reads it. */
458
+ export type AuthoringAtomBlock = z.infer<(typeof AUTHORING_ATOM_SCHEMAS)[number]>;
459
+ /** One block of any of the eight kinds, as an agent writes it and reads it. */
460
+ export type AuthoringBlock = AuthoringAtomBlock | AuthoringSectionBlock;
461
+ /** The block union of the authoring surface. The annotation gives the recursive members a stable type. */
462
+ export declare const AuthoringBlockSchema: z.ZodType<AuthoringBlock>;
463
+ export {};
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The block grammar that an agent writes and reads.
3
+ *
4
+ * The pinned snapshot owns the hash of each artifact reference. Thus an agent names the path alone, and the
5
+ * land path stamps the hash from the snapshot entry at that path. This grammar is the contract grammar with
6
+ * that one field dropped. The published input schema of a tool shows no hash, and a read of a block gives
7
+ * none back. Thus an agent never sees a hash, and it never mistypes one.
8
+ *
9
+ * The grammar composes from the contract schemas, and it does not copy them. Each block keeps its own
10
+ * fields, and only the reference-bearing field of a kind changes. Thus a new field of a block reaches this
11
+ * grammar the moment that the contract declares it.
12
+ *
13
+ * The stored form stays the contract form. The stamp fills the hash before the draft grammar parses the
14
+ * payload, thus the grounding and the resolution read the same pin as before.
15
+ */
16
+ import { z } from "zod";
17
+ import { ChartBlockSchema, CitationBlockSchema, ClaimBlockSchema, FigureBlockSchema, MetricBlockSchema, TableBlockSchema, TextBlockSchema, } from "../contracts/report-blocks.js";
18
+ import { ArtifactFileReferenceSchema, ArtifactTableReferenceSchema, ArtifactValueReferenceSchema, CitationReferenceSchema, DerivationReferenceSchema, } from "../contracts/report-reference.js";
19
+ /** A reference to one scalar value inside an artifact, by the path of the artifact and a locator. */
20
+ const AuthoringValueReferenceSchema = ArtifactValueReferenceSchema.omit({ hash: true });
21
+ /** A reference to a whole table artifact, by the path of the artifact. */
22
+ const AuthoringTableReferenceSchema = ArtifactTableReferenceSchema.omit({ hash: true });
23
+ /** A reference to a whole artifact file, by the path of the artifact. */
24
+ const AuthoringFileReferenceSchema = ArtifactFileReferenceSchema.omit({ hash: true });
25
+ /** A reference to a value computed from two scalar references. Each input names a path and no hash. */
26
+ const AuthoringDerivationReferenceSchema = DerivationReferenceSchema.extend({
27
+ inputs: z
28
+ .array(AuthoringValueReferenceSchema)
29
+ .length(2)
30
+ .describe("The two input references. Each operation takes exactly two, and each one must resolve to a scalar."),
31
+ });
32
+ /** The full reference union of the authoring surface. A citation names an external id, thus it pins no artifact. */
33
+ const AuthoringReferenceSchema = z.discriminatedUnion("kind", [
34
+ AuthoringValueReferenceSchema,
35
+ AuthoringTableReferenceSchema,
36
+ AuthoringFileReferenceSchema,
37
+ AuthoringDerivationReferenceSchema,
38
+ CitationReferenceSchema,
39
+ ]);
40
+ /** The references of the authoring surface that resolve to one scalar value. */
41
+ const AuthoringScalarReferenceSchema = z.discriminatedUnion("kind", [AuthoringValueReferenceSchema, AuthoringDerivationReferenceSchema]);
42
+ /**
43
+ * The chart block of the authoring surface.
44
+ *
45
+ * A chart carries a rule over its own fields, and a schema with a rule refuses a replacement of one field.
46
+ * Thus this schema spreads the fields of the contract chart, and it replaces the binding. The rule itself
47
+ * stays out: the core parses each payload with the draft grammar, and that grammar carries the rule. This
48
+ * schema publishes the shape, and it types the read.
49
+ */
50
+ const AuthoringChartBlockSchema = z.strictObject({
51
+ ...ChartBlockSchema.shape,
52
+ binding: AuthoringTableReferenceSchema.describe("The whole-table artifact to plot."),
53
+ });
54
+ /**
55
+ * The seven atoms of the authoring surface.
56
+ *
57
+ * A text block and a citation block bind no artifact, thus each one is the contract schema itself. The five
58
+ * others replace the one field that carries a pin.
59
+ */
60
+ const AUTHORING_ATOM_SCHEMAS = [
61
+ TextBlockSchema,
62
+ ClaimBlockSchema.extend({ bindings: z.array(AuthoringReferenceSchema).min(1).describe("The evidence that justifies the claim.") }),
63
+ MetricBlockSchema.extend({ value: AuthoringScalarReferenceSchema.describe("The one scalar reference that gives the metric value.") }),
64
+ TableBlockSchema.extend({ binding: AuthoringTableReferenceSchema.describe("The whole-table artifact to render.") }),
65
+ AuthoringChartBlockSchema,
66
+ FigureBlockSchema.extend({ binding: AuthoringFileReferenceSchema.describe("The image artifact. It pins the whole file, and the path names it.") }),
67
+ CitationBlockSchema,
68
+ ];
69
+ /** A section of the authoring surface permits zero child blocks, exactly as a draft section does. */
70
+ const AuthoringSectionBlockSchema = z.strictObject({
71
+ kind: z.literal("section"),
72
+ id: z.string().min(1),
73
+ title: z.string(),
74
+ blocks: z.lazy(() => z.array(AuthoringBlockSchema)),
75
+ });
76
+ /** The block union of the authoring surface. The annotation gives the recursive members a stable type. */
77
+ export const AuthoringBlockSchema = z.discriminatedUnion("kind", [AuthoringSectionBlockSchema, ...AUTHORING_ATOM_SCHEMAS]);
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * The one walk over a block tree.
3
3
  *
4
- * A block kind decides where a reference sits, which prose carries a free numeral, and whether the block
5
- * holds children. Three consumers need that same knowledge: the mechanical validator, the draft finish,
6
- * and the draft operations. A switch for each consumer is a switch that a ninth block kind can miss in
7
- * silence, because each arm returns and none of them fails to build. Thus the walk lives here one time.
4
+ * A block kind decides where a reference sits, which text carries a free numeral or a drifted exponent
5
+ * form, and whether the block holds children. Three consumers need that same knowledge: the mechanical
6
+ * validator, the draft finish, and the draft operations. A switch for each consumer is a switch that a
7
+ * ninth block kind can miss in silence, because each arm returns and none of them fails to build. Thus the
8
+ * walk lives here one time.
8
9
  *
9
10
  * The walk reads a finished `Block` tree and a relaxed `DraftBlock` tree alike. The two differ only in the
10
11
  * section rules, and the section arm reads the children of either one.
@@ -12,7 +13,7 @@
12
13
  * The walk resolves nothing and it opens no file. It reports what the tree holds, and a caller decides
13
14
  * which part it needs.
14
15
  */
15
- import type { Block } from "../contracts/report-blocks.js";
16
+ import { type Block } from "../contracts/report-blocks.js";
16
17
  import type { Reference } from "../contracts/report-reference.js";
17
18
  import type { DraftBlock } from "./draft.js";
18
19
  /** A block of a finished report, or a block of a draft. The atoms are the same shape in both. */
@@ -20,33 +21,65 @@ export type AnyBlock = Block | DraftBlock;
20
21
  /**
21
22
  * One reference that the walk met, tied to the block that carries it.
22
23
  *
23
- * `encodingColumns` is present for a `chart` only. A chart names its axes as free strings, thus the names
24
- * must be matched against the table that the binding resolves to. Nothing else can catch a chart that
25
- * plots a column which does not exist. The match needs the resolved rows, thus only a value-tier consumer
26
- * reads this field.
24
+ * `encodingColumns` is present for a `chart` only. A chart names its columns as free strings, thus the
25
+ * names must be matched against the table that the binding resolves to. Nothing else can catch a chart
26
+ * that plots a column which does not exist. The field carries every column that the chart grammar names,
27
+ * thus the structural tier and the value tier match the same set.
27
28
  */
28
29
  export interface CollectedReference {
29
30
  blockId: string;
30
31
  reference: Reference;
31
32
  encodingColumns?: string[];
32
33
  }
33
- /** An advisory warning about the content of one block. A warning never makes a report invalid. */
34
- export interface ReportWarning {
34
+ /** An advisory warning about the prose of one block. The detail is the numeral that the prose carries. */
35
+ export interface FreeNumeralWarning {
35
36
  blockId: string;
36
37
  kind: "free-numeral";
37
38
  detail: string;
38
39
  }
40
+ /**
41
+ * An advisory warning about one exponent form that the prose of a block carries and the page never prints.
42
+ * The detail is the written form.
43
+ */
44
+ export interface ExponentFormWarning {
45
+ blockId: string;
46
+ kind: "exponent-form";
47
+ detail: string;
48
+ }
49
+ /** One advisory warning about the prose of a block. */
50
+ export type ProseWarning = FreeNumeralWarning | ExponentFormWarning;
51
+ /**
52
+ * An advisory warning about one derivation that no binding of the document names. The detail is the output
53
+ * path of the record. The record stays, and the bytes are reproducible from the script and the sources.
54
+ */
55
+ export interface UnusedDerivationWarning {
56
+ kind: "unused-derivation";
57
+ detail: string;
58
+ }
59
+ /** One advisory warning about a report. A warning never makes a report invalid. */
60
+ export type ReportWarning = ProseWarning | UnusedDerivationWarning;
39
61
  /** What one walk over a block tree found. */
40
62
  export interface BlockWalk {
41
63
  /** Each reference, in document order, tied to the block that carries it. */
42
64
  references: CollectedReference[];
43
65
  /** Each id that more than one block holds, named one time, in sorted order. */
44
66
  repeatedIds: string[];
45
- /** Each free numeral that prose carries. */
46
- warnings: ReportWarning[];
67
+ /** Each free numeral and each drifted exponent form that prose carries. */
68
+ warnings: ProseWarning[];
47
69
  }
48
70
  /** Warn for each free-standing numeral that the prose of one block carries. */
49
- export declare function numeralWarnings(blockId: string, prose: string): ReportWarning[];
71
+ export declare function numeralWarnings(blockId: string, prose: string): FreeNumeralWarning[];
72
+ /**
73
+ * Warn for each exponent form of one block that the page never prints.
74
+ *
75
+ * The page owns the notation of a value. Thus a sentence that writes a second notation of the same number
76
+ * disagrees with the card beside it. The renderer answers which forms it prints, thus this scan states no
77
+ * rule of its own.
78
+ *
79
+ * The check is advisory, exactly as the numeral scan is. A prose exponent can be a quoted threshold that no
80
+ * cell carries, thus a hit warns and it never fails the report.
81
+ */
82
+ export declare function exponentWarnings(blockId: string, prose: string): ExponentFormWarning[];
50
83
  /**
51
84
  * Walk a block tree, and report each reference, each repeated id, and each free numeral.
52
85
  *
@@ -54,3 +87,13 @@ export declare function numeralWarnings(blockId: string, prose: string): ReportW
54
87
  * to one block. The walk is pre-order, thus the references follow the document order.
55
88
  */
56
89
  export declare function walkBlocks(blocks: readonly AnyBlock[]): BlockWalk;
90
+ /**
91
+ * Each artifact path that a set of collected references names.
92
+ *
93
+ * An artifact binding names one path. A derivation reference computes over two inputs, thus it names the
94
+ * path of each input and a table that feeds a derived scalar counts as named. A citation names no path.
95
+ *
96
+ * The set answers one question: which files does this document use. The finish reads it against the
97
+ * derivations of the session, and the record reads it again over the recorded document.
98
+ */
99
+ export declare function referencedPaths(references: readonly CollectedReference[]): Set<string>;