@uwmd/core 1.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 (214) hide show
  1. package/README.md +79 -0
  2. package/dist/agents/bancroft.d.ts +32 -0
  3. package/dist/agents/bancroft.d.ts.map +1 -0
  4. package/dist/agents/bancroft.js +292 -0
  5. package/dist/agents/bancroft.js.map +1 -0
  6. package/dist/agents/schemas.d.ts +13 -0
  7. package/dist/agents/schemas.d.ts.map +1 -0
  8. package/dist/agents/schemas.js +74 -0
  9. package/dist/agents/schemas.js.map +1 -0
  10. package/dist/bindings.d.ts +85 -0
  11. package/dist/bindings.d.ts.map +1 -0
  12. package/dist/bindings.js +293 -0
  13. package/dist/bindings.js.map +1 -0
  14. package/dist/browser.d.ts +66 -0
  15. package/dist/browser.d.ts.map +1 -0
  16. package/dist/browser.js +53 -0
  17. package/dist/browser.js.map +1 -0
  18. package/dist/calc/builtins.d.ts +4 -0
  19. package/dist/calc/builtins.d.ts.map +1 -0
  20. package/dist/calc/builtins.js +329 -0
  21. package/dist/calc/builtins.js.map +1 -0
  22. package/dist/calc/dependencies.d.ts +34 -0
  23. package/dist/calc/dependencies.d.ts.map +1 -0
  24. package/dist/calc/dependencies.js +101 -0
  25. package/dist/calc/dependencies.js.map +1 -0
  26. package/dist/calc/errors.d.ts +8 -0
  27. package/dist/calc/errors.d.ts.map +1 -0
  28. package/dist/calc/errors.js +18 -0
  29. package/dist/calc/errors.js.map +1 -0
  30. package/dist/calc/evaluator.d.ts +5 -0
  31. package/dist/calc/evaluator.d.ts.map +1 -0
  32. package/dist/calc/evaluator.js +184 -0
  33. package/dist/calc/evaluator.js.map +1 -0
  34. package/dist/calc/index.d.ts +14 -0
  35. package/dist/calc/index.d.ts.map +1 -0
  36. package/dist/calc/index.js +56 -0
  37. package/dist/calc/index.js.map +1 -0
  38. package/dist/calc/parser.d.ts +32 -0
  39. package/dist/calc/parser.d.ts.map +1 -0
  40. package/dist/calc/parser.js +361 -0
  41. package/dist/calc/parser.js.map +1 -0
  42. package/dist/cascade.d.ts +85 -0
  43. package/dist/cascade.d.ts.map +1 -0
  44. package/dist/cascade.js +172 -0
  45. package/dist/cascade.js.map +1 -0
  46. package/dist/cli.d.ts +3 -0
  47. package/dist/cli.d.ts.map +1 -0
  48. package/dist/cli.js +843 -0
  49. package/dist/cli.js.map +1 -0
  50. package/dist/codec.d.ts +25 -0
  51. package/dist/codec.d.ts.map +1 -0
  52. package/dist/codec.js +62 -0
  53. package/dist/codec.js.map +1 -0
  54. package/dist/codecs.d.ts +6 -0
  55. package/dist/codecs.d.ts.map +1 -0
  56. package/dist/codecs.js +12 -0
  57. package/dist/codecs.js.map +1 -0
  58. package/dist/compactor.d.ts +11 -0
  59. package/dist/compactor.d.ts.map +1 -0
  60. package/dist/compactor.js +84 -0
  61. package/dist/compactor.js.map +1 -0
  62. package/dist/context-profiles.d.ts +30 -0
  63. package/dist/context-profiles.d.ts.map +1 -0
  64. package/dist/context-profiles.js +225 -0
  65. package/dist/context-profiles.js.map +1 -0
  66. package/dist/context.d.ts +55 -0
  67. package/dist/context.d.ts.map +1 -0
  68. package/dist/context.js +288 -0
  69. package/dist/context.js.map +1 -0
  70. package/dist/dcf.d.ts +9 -0
  71. package/dist/dcf.d.ts.map +1 -0
  72. package/dist/dcf.js +75 -0
  73. package/dist/dcf.js.map +1 -0
  74. package/dist/debt.d.ts +11 -0
  75. package/dist/debt.d.ts.map +1 -0
  76. package/dist/debt.js +85 -0
  77. package/dist/debt.js.map +1 -0
  78. package/dist/defaults.d.ts +104 -0
  79. package/dist/defaults.d.ts.map +1 -0
  80. package/dist/defaults.js +622 -0
  81. package/dist/defaults.js.map +1 -0
  82. package/dist/derived.d.ts +17 -0
  83. package/dist/derived.d.ts.map +1 -0
  84. package/dist/derived.js +29 -0
  85. package/dist/derived.js.map +1 -0
  86. package/dist/editor.d.ts +76 -0
  87. package/dist/editor.d.ts.map +1 -0
  88. package/dist/editor.js +502 -0
  89. package/dist/editor.js.map +1 -0
  90. package/dist/envelope.d.ts +51 -0
  91. package/dist/envelope.d.ts.map +1 -0
  92. package/dist/envelope.js +213 -0
  93. package/dist/envelope.js.map +1 -0
  94. package/dist/format.d.ts +60 -0
  95. package/dist/format.d.ts.map +1 -0
  96. package/dist/format.js +115 -0
  97. package/dist/format.js.map +1 -0
  98. package/dist/gaps.d.ts +62 -0
  99. package/dist/gaps.d.ts.map +1 -0
  100. package/dist/gaps.js +272 -0
  101. package/dist/gaps.js.map +1 -0
  102. package/dist/index.d.ts +75 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +47 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/init.d.ts +15 -0
  107. package/dist/init.d.ts.map +1 -0
  108. package/dist/init.js +169 -0
  109. package/dist/init.js.map +1 -0
  110. package/dist/integrity-canonical.d.ts +17 -0
  111. package/dist/integrity-canonical.d.ts.map +1 -0
  112. package/dist/integrity-canonical.js +124 -0
  113. package/dist/integrity-canonical.js.map +1 -0
  114. package/dist/integrity.d.ts +54 -0
  115. package/dist/integrity.d.ts.map +1 -0
  116. package/dist/integrity.js +244 -0
  117. package/dist/integrity.js.map +1 -0
  118. package/dist/modules.d.ts +24 -0
  119. package/dist/modules.d.ts.map +1 -0
  120. package/dist/modules.js +322 -0
  121. package/dist/modules.js.map +1 -0
  122. package/dist/negotiation.d.ts +19 -0
  123. package/dist/negotiation.d.ts.map +1 -0
  124. package/dist/negotiation.js +70 -0
  125. package/dist/negotiation.js.map +1 -0
  126. package/dist/opstatement.d.ts +9 -0
  127. package/dist/opstatement.d.ts.map +1 -0
  128. package/dist/opstatement.js +80 -0
  129. package/dist/opstatement.js.map +1 -0
  130. package/dist/packs/excel-emit.d.ts +21 -0
  131. package/dist/packs/excel-emit.d.ts.map +1 -0
  132. package/dist/packs/excel-emit.js +135 -0
  133. package/dist/packs/excel-emit.js.map +1 -0
  134. package/dist/packs/index.d.ts +13 -0
  135. package/dist/packs/index.d.ts.map +1 -0
  136. package/dist/packs/index.js +37 -0
  137. package/dist/packs/index.js.map +1 -0
  138. package/dist/packs/industrial.d.ts +3 -0
  139. package/dist/packs/industrial.d.ts.map +1 -0
  140. package/dist/packs/industrial.js +115 -0
  141. package/dist/packs/industrial.js.map +1 -0
  142. package/dist/packs/multifamily.d.ts +3 -0
  143. package/dist/packs/multifamily.d.ts.map +1 -0
  144. package/dist/packs/multifamily.js +82 -0
  145. package/dist/packs/multifamily.js.map +1 -0
  146. package/dist/packs/office.d.ts +3 -0
  147. package/dist/packs/office.d.ts.map +1 -0
  148. package/dist/packs/office.js +108 -0
  149. package/dist/packs/office.js.map +1 -0
  150. package/dist/packs/retail.d.ts +3 -0
  151. package/dist/packs/retail.d.ts.map +1 -0
  152. package/dist/packs/retail.js +115 -0
  153. package/dist/packs/retail.js.map +1 -0
  154. package/dist/packs/self-storage.d.ts +3 -0
  155. package/dist/packs/self-storage.d.ts.map +1 -0
  156. package/dist/packs/self-storage.js +105 -0
  157. package/dist/packs/self-storage.js.map +1 -0
  158. package/dist/parser.d.ts +15 -0
  159. package/dist/parser.d.ts.map +1 -0
  160. package/dist/parser.js +430 -0
  161. package/dist/parser.js.map +1 -0
  162. package/dist/protocol.d.ts +389 -0
  163. package/dist/protocol.d.ts.map +1 -0
  164. package/dist/protocol.js +714 -0
  165. package/dist/protocol.js.map +1 -0
  166. package/dist/refinement.d.ts +63 -0
  167. package/dist/refinement.d.ts.map +1 -0
  168. package/dist/refinement.js +242 -0
  169. package/dist/refinement.js.map +1 -0
  170. package/dist/renderer.d.ts +22 -0
  171. package/dist/renderer.d.ts.map +1 -0
  172. package/dist/renderer.js +478 -0
  173. package/dist/renderer.js.map +1 -0
  174. package/dist/rentroll.d.ts +21 -0
  175. package/dist/rentroll.d.ts.map +1 -0
  176. package/dist/rentroll.js +256 -0
  177. package/dist/rentroll.js.map +1 -0
  178. package/dist/report.d.ts +29 -0
  179. package/dist/report.d.ts.map +1 -0
  180. package/dist/report.js +924 -0
  181. package/dist/report.js.map +1 -0
  182. package/dist/runner.d.ts +43 -0
  183. package/dist/runner.d.ts.map +1 -0
  184. package/dist/runner.js +288 -0
  185. package/dist/runner.js.map +1 -0
  186. package/dist/sourcesuses.d.ts +14 -0
  187. package/dist/sourcesuses.d.ts.map +1 -0
  188. package/dist/sourcesuses.js +63 -0
  189. package/dist/sourcesuses.js.map +1 -0
  190. package/dist/types.d.ts +248 -0
  191. package/dist/types.d.ts.map +1 -0
  192. package/dist/types.js +15 -0
  193. package/dist/types.js.map +1 -0
  194. package/dist/uwcsv.d.ts +23 -0
  195. package/dist/uwcsv.d.ts.map +1 -0
  196. package/dist/uwcsv.js +877 -0
  197. package/dist/uwcsv.js.map +1 -0
  198. package/dist/uwjson.d.ts +19 -0
  199. package/dist/uwjson.d.ts.map +1 -0
  200. package/dist/uwjson.js +61 -0
  201. package/dist/uwjson.js.map +1 -0
  202. package/dist/uwxml.d.ts +18 -0
  203. package/dist/uwxml.d.ts.map +1 -0
  204. package/dist/uwxml.js +297 -0
  205. package/dist/uwxml.js.map +1 -0
  206. package/dist/validator.d.ts +35 -0
  207. package/dist/validator.d.ts.map +1 -0
  208. package/dist/validator.js +553 -0
  209. package/dist/validator.js.map +1 -0
  210. package/dist/valuation.d.ts +9 -0
  211. package/dist/valuation.d.ts.map +1 -0
  212. package/dist/valuation.js +34 -0
  213. package/dist/valuation.js.map +1 -0
  214. package/package.json +58 -0
@@ -0,0 +1,389 @@
1
+ import type { AssetClass, ConfidenceLevel, DealStage, FinancialThresholds, ParsedUWFile, PipelineStatus, UWBlock, UWMeta, ValidationMessage, ValidationSeverity } from './types.js';
2
+ /** Semver of this protocol. Bumped independently of @uwmd/core's npm version. */
3
+ export declare const PROTOCOL_VERSION: "1.2.0";
4
+ /** Format spec version this protocol pairs with. */
5
+ export declare const FORMAT_VERSION: "1.1";
6
+ /** The four conformance tiers defined in UW_PROTOCOL_v1.md Part II. */
7
+ export type ViewerTier = 'tier-1-reader' | 'tier-2-editor' | 'tier-3-calc-host' | 'tier-4-agent-host';
8
+ /** What kind of actor the implementation serves. Informational. */
9
+ export type ViewerRole = 'web' | 'cli' | 'desktop' | 'ide-extension' | 'library' | 'service';
10
+ /**
11
+ * Granular capability flags. Tiers are coarse; capabilities let an
12
+ * implementer signal partial conformance (e.g. read-only viewer that
13
+ * also supports editing one specific section).
14
+ */
15
+ export type ViewerCapability = 'parse' | 'validate' | 'render-json' | 'render-csv' | 'render-summary' | 'render-chat' | 'render-pdf' | 'render-docx' | 'edit-replace' | 'edit-supersede' | 'edit-frontmatter' | 'calc-evaluate' | 'calc-deterministic' | 'agent-host' | 'module-load';
16
+ export type RepresentationFidelity = 'source' | 'model' | 'view';
17
+ export type RepresentationDirection = 'read' | 'write';
18
+ /** Discoverable support for one source, model, or view representation. */
19
+ export interface RepresentationCapability {
20
+ id: string;
21
+ media_types: string[];
22
+ file_extensions: string[];
23
+ directions: RepresentationDirection[];
24
+ fidelity: RepresentationFidelity;
25
+ representation_version: string;
26
+ /** Required for view-fidelity representations. */
27
+ view?: string;
28
+ streaming?: boolean;
29
+ max_bytes?: number;
30
+ }
31
+ /**
32
+ * What a conforming implementation declares about itself. A reader of a
33
+ * `.uw.md` file should be able to discover whether a given tool will be
34
+ * able to handle the file by inspecting this manifest.
35
+ */
36
+ export interface ImplementationManifest {
37
+ /** Stable identifier (e.g. "io.uwmd.web-viewer"). */
38
+ id: string;
39
+ /** Human-readable name. */
40
+ name: string;
41
+ /** Semver of the implementation. */
42
+ version: string;
43
+ /** Protocol semver this implementation targets. */
44
+ protocol_version: string;
45
+ /** Format semver this implementation can read. */
46
+ format_version: string;
47
+ /** Tier the implementation self-certifies to. */
48
+ tier: ViewerTier;
49
+ /** Optional finer-grained capability list. */
50
+ capabilities?: ViewerCapability[];
51
+ /** Machine-readable representation discovery (Protocol 1.2+). */
52
+ representations?: RepresentationCapability[];
53
+ /** Asset classes the implementation specifically supports (omit = all). */
54
+ asset_classes?: AssetClass[];
55
+ /** Role / form factor of the implementation. */
56
+ role?: ViewerRole;
57
+ /** Public homepage / docs URL. */
58
+ homepage?: string;
59
+ }
60
+ /** Frozen to 'en-US' in v1; field reserved for v2 i18n work. */
61
+ export type SupportedLocale = 'en-US';
62
+ export interface NumberFormatRules {
63
+ locale: SupportedLocale;
64
+ currency: {
65
+ decimals: number;
66
+ symbol: string;
67
+ };
68
+ percent: {
69
+ decimals: number;
70
+ multiplier: number;
71
+ suffix: string;
72
+ };
73
+ ratio: {
74
+ decimals: number;
75
+ suffix: string;
76
+ };
77
+ count: {
78
+ thousands_separator: boolean;
79
+ };
80
+ null_display: string;
81
+ }
82
+ export interface DateFormatRules {
83
+ locale: SupportedLocale;
84
+ /** 'iso' = passthrough of the source ISO-8601 string. */
85
+ default_style: 'iso' | 'short' | 'medium' | 'long';
86
+ }
87
+ /** Default number-formatting table referenced by Part III §3.1. */
88
+ export declare const DEFAULT_NUMBER_FORMAT: NumberFormatRules;
89
+ export declare const DEFAULT_DATE_FORMAT: DateFormatRules;
90
+ export type ConfidenceBadgeStyle = 'pill' | 'icon' | 'text';
91
+ /** Compressed display hint for the source field on a UWMeta. */
92
+ export interface SourceBadge {
93
+ source: string;
94
+ display_label: string;
95
+ authority: EditAuthority;
96
+ }
97
+ export type FlagSeverity = 'info' | 'warning' | 'blocking';
98
+ /** A single field-level rendering hint inside a SectionViewModel. */
99
+ export interface FieldViewHint {
100
+ /** Dot-path within the section's content, resolved via parser.deepGet. */
101
+ path: string;
102
+ /** Display label. */
103
+ label: string;
104
+ /** Formatting kind. Drives which formatter in `./format.ts` applies. */
105
+ kind: 'currency' | 'percent' | 'ratio' | 'count' | 'date' | 'string' | 'enum' | 'list';
106
+ /** True if this field should be highlighted as a primary metric. */
107
+ primary?: boolean;
108
+ /** Human-readable units for ratios/counts/strings (e.g. "yrs", "units"). */
109
+ unit?: string;
110
+ /** Decimals override (otherwise DEFAULT_NUMBER_FORMAT applies). */
111
+ decimals?: number;
112
+ /** For 'enum' kind: allowed values for badge coloring. */
113
+ enum?: readonly string[];
114
+ }
115
+ /**
116
+ * Layout description for a single section. Renderers walk this to produce
117
+ * any presentation (web cards, terminal output, PDF, etc.) without
118
+ * hard-coding section-specific knowledge.
119
+ */
120
+ export interface SectionViewModel {
121
+ section_id: string;
122
+ display_name: string;
123
+ /** Order in the standard section list (0..20 for the 21 standard sections). */
124
+ display_order: number;
125
+ /** Brief one-line description of what this section captures. */
126
+ description: string;
127
+ /** Fields to surface on the section's primary card / one-line summary. */
128
+ primary_fields: FieldViewHint[];
129
+ /** Fields shown on expand. */
130
+ detail_fields?: FieldViewHint[];
131
+ /** True if the section may have multiple variants (stress tests, scenarios). */
132
+ multi_variant?: boolean;
133
+ }
134
+ export type ViewModelRegistry = Readonly<Record<string, SectionViewModel>>;
135
+ /**
136
+ * Ordered cascade steps used to resolve a value that has no explicit
137
+ * user input or document extraction. A producer MUST stamp
138
+ * `_meta.source` with the cascade step that produced the value, and
139
+ * MUST NOT reorder this cascade. See protocol §IX.
140
+ *
141
+ * Step 0 (`user_override`) and step 1 (`user_input`) are detected by
142
+ * walking the parsed file for an existing block at the field path
143
+ * whose `_meta.source` matches; the remaining steps are looked up in
144
+ * external tables (investor profile, market data) or built-in tables
145
+ * (asset class, global, system).
146
+ */
147
+ export type CascadeStep = 'user_override' | 'user_input' | 'investor_profile' | 'market_data' | 'asset_class_default' | 'global_default' | 'system_default';
148
+ /** Ordered cascade as a runtime value (frozen). Index === precedence. */
149
+ export declare const CASCADE_ORDER: readonly CascadeStep[];
150
+ /**
151
+ * The full set of canonical short-form source tags producers stamp into
152
+ * `_meta.source`. The first seven values match `CascadeStep` 1:1; the
153
+ * remaining four are non-cascade tags retained from v1.0 for back-compat
154
+ * (`manual`, `ai_extracted`, `agent_computed`, `scenario_default`).
155
+ *
156
+ * `scenario_default` is retained but its meaning is sharpened to mean
157
+ * "value derived from a named scenario in the file or institution
158
+ * config." Producers needing a generic fallback SHOULD use
159
+ * `system_default` instead.
160
+ *
161
+ * Long-form patterns (e.g. `agent/L6-01`, `document/rent_roll`,
162
+ * `import:filename.pdf`) remain valid; this constant enumerates the
163
+ * canonical short forms only.
164
+ */
165
+ export declare const SOURCE_TAGS: readonly ["user_input", "user_override", "manual", "investor_profile", "market_data", "ai_extracted", "agent_computed", "asset_class_default", "scenario_default", "global_default", "system_default"];
166
+ export type CanonicalSourceTag = (typeof SOURCE_TAGS)[number];
167
+ /**
168
+ * What a producer should do when an incomplete-data condition (missing or
169
+ * provisional value) is encountered for a `(section, field, stage)` tuple.
170
+ *
171
+ * - `halt` — refuse to advance; surface as DQ-02 error.
172
+ * - `degrade` — continue, but mark the affected output as conditional.
173
+ * - `substitute` — fill from the cascade step named by `fallback_source`.
174
+ * - `defer` — continue and surface the gap; treat the deficiency as
175
+ * acceptable at this stage.
176
+ */
177
+ export type GapAction = {
178
+ kind: 'halt';
179
+ } | {
180
+ kind: 'degrade';
181
+ } | {
182
+ kind: 'substitute';
183
+ fallback_source: CascadeStep;
184
+ } | {
185
+ kind: 'defer';
186
+ };
187
+ export interface IncompleteDataPolicy {
188
+ /** Section the policy applies to. Required. */
189
+ section: string;
190
+ /** Optional dot-path within the section. When omitted, the policy applies
191
+ * to the whole section. */
192
+ field_path?: string;
193
+ /** Optional pipeline stage. When omitted, the policy applies at every stage. */
194
+ stage?: import('./types.js').DealStage;
195
+ action: GapAction;
196
+ /** Human-readable explanation of why this policy exists. */
197
+ rationale?: string;
198
+ }
199
+ /**
200
+ * Curated default policies covering high-impact (section, stage) pairs in the
201
+ * multifamily workflow. Adopters MAY extend this set; lookups consult adopter
202
+ * policies first, then these defaults.
203
+ *
204
+ * Policies stack: more-specific (with field_path) wins over less-specific;
205
+ * within the same specificity, more-specific stage wins over wildcard.
206
+ */
207
+ export declare const BUILTIN_INCOMPLETE_DATA_POLICIES: readonly IncompleteDataPolicy[];
208
+ /**
209
+ * Look up the most-specific applicable policy for `(section, field_path, stage)`.
210
+ *
211
+ * Specificity order (highest to lowest):
212
+ * 1. matching section + matching field_path + matching stage
213
+ * 2. matching section + matching field_path (any stage)
214
+ * 3. matching section + matching stage (any field)
215
+ * 4. matching section (any field, any stage)
216
+ *
217
+ * Returns null when no policy matches.
218
+ */
219
+ export declare function lookupIncompleteDataPolicy(section: string, field_path: string | undefined, stage: import('./types.js').DealStage, policies?: readonly IncompleteDataPolicy[]): IncompleteDataPolicy | null;
220
+ /** Who is permitted to overwrite a block, derived from `_meta.source`. */
221
+ export type EditAuthority = 'agent_only' | 'human_only' | 'either' | 'system_only';
222
+ export interface EditPolicy {
223
+ /** Glob-style pattern matching `_meta.source` (e.g. "agent/*", "manual"). */
224
+ source_pattern: string;
225
+ authority: EditAuthority;
226
+ /** If true, edits MUST go through supersede (append a new block); else replace. */
227
+ supersede_on_edit: boolean;
228
+ }
229
+ /**
230
+ * A discrete edit operation against a parsed file. Tier-2 implementers
231
+ * accept these and produce a new `.uw.md` with byte-stable formatting
232
+ * for unrelated regions (round-trip preservation).
233
+ */
234
+ export type EditOperation = {
235
+ kind: 'frontmatter_set';
236
+ path: string;
237
+ value: unknown;
238
+ } | {
239
+ kind: 'section_replace';
240
+ section_id: string;
241
+ variant?: string;
242
+ content: Record<string, unknown>;
243
+ meta: Partial<UWMeta>;
244
+ } | {
245
+ kind: 'section_supersede';
246
+ section_id: string;
247
+ variant?: string;
248
+ content: Record<string, unknown>;
249
+ meta: Partial<UWMeta>;
250
+ } | {
251
+ kind: 'pipeline_log_append';
252
+ entry: Record<string, unknown>;
253
+ };
254
+ export interface IssueRemediation {
255
+ /** Validation code (e.g. "CC-01"). */
256
+ code: string;
257
+ /** Default severity emitted by validator.ts. */
258
+ severity: ValidationSeverity;
259
+ /** Short title shown in the issue list. */
260
+ title: string;
261
+ /** Plain-language description of what is wrong. */
262
+ description: string;
263
+ /** Imperative remediation copy ("Recompute LTV from current loan_amount / purchase_price."). */
264
+ remediation: string;
265
+ /** Spec section anchor for deep-linking. */
266
+ spec_ref?: string;
267
+ }
268
+ /**
269
+ * Variables made available to a custom_calculation expression. The host
270
+ * resolves `parsed` paths via parser.deepGet semantics.
271
+ */
272
+ export interface CalcEvaluationContext {
273
+ parsed: ParsedUWFile;
274
+ /** Result map of previously-evaluated calculations in the same batch. */
275
+ prior_results: Readonly<Record<string, number | string | boolean | null>>;
276
+ /** Locale for number parsing. v1: must be 'en-US'. */
277
+ locale: SupportedLocale;
278
+ }
279
+ export interface CalcResult {
280
+ calc_id: string;
281
+ ok: boolean;
282
+ value: number | string | boolean | null;
283
+ /** Unit string from the calc declaration (e.g. "%", "$", "x"). */
284
+ unit?: string;
285
+ /** Formatted display string per DEFAULT_NUMBER_FORMAT. */
286
+ display?: string;
287
+ error?: ProtocolError;
288
+ }
289
+ export interface AgentHostCapability {
290
+ /** Layer ID this host can run (e.g. "L6"). Maps to BANCROFT_LAYERS. */
291
+ layer_id: string;
292
+ /** Whether the host runs the layer with a real LLM (vs. dry-run replay). */
293
+ live: boolean;
294
+ /** Tool schemas the agent is allowed to call. */
295
+ tools: ('write_uw_section' | 'write_multiple_sections')[];
296
+ }
297
+ /**
298
+ * A loaded module declaration. Mirrors the JSON Schema in
299
+ * spec/schemas/module-manifest.schema.json — keep in lockstep.
300
+ */
301
+ export interface ModuleManifest {
302
+ manifest_version: '1';
303
+ id: string;
304
+ name: string;
305
+ version: string;
306
+ description: string;
307
+ authors: string[];
308
+ license: string;
309
+ requires_protocol: string;
310
+ requires_format: string;
311
+ requires_tier: ViewerTier;
312
+ asset_classes?: AssetClass[];
313
+ deal_stages?: DealStage[];
314
+ sections?: ModuleSectionDecl[];
315
+ calculations?: ModuleCalcDecl[];
316
+ validations?: ModuleValidationDecl[];
317
+ thresholds?: Partial<FinancialThresholds>;
318
+ view_models?: SectionViewModel[];
319
+ ui?: Record<string, unknown>;
320
+ agent_layers?: ModuleAgentLayerDecl[];
321
+ depends_on?: {
322
+ id: string;
323
+ version: string;
324
+ }[];
325
+ }
326
+ export interface ModuleSectionDecl {
327
+ id: string;
328
+ display_name: string;
329
+ schema: Record<string, unknown>;
330
+ required?: boolean;
331
+ }
332
+ export interface ModuleCalcDecl {
333
+ id: string;
334
+ label: string;
335
+ formula: string;
336
+ unit?: string;
337
+ /** True if the formula has no side effects and same inputs → same output. */
338
+ deterministic: boolean;
339
+ }
340
+ export interface ModuleValidationDecl {
341
+ code: string;
342
+ severity: ValidationSeverity;
343
+ message: string;
344
+ rule: string;
345
+ }
346
+ export interface ModuleAgentLayerDecl {
347
+ id: string;
348
+ reads: string[];
349
+ writes: string[];
350
+ prompt_template: string;
351
+ }
352
+ export interface ModuleLoadResult {
353
+ ok: boolean;
354
+ manifest?: ModuleManifest;
355
+ errors: ProtocolError[];
356
+ }
357
+ export type ProtocolErrorCategory = 'parse' | 'validate' | 'render' | 'edit' | 'calc' | 'agent' | 'module' | 'version';
358
+ export interface ProtocolError {
359
+ category: ProtocolErrorCategory;
360
+ code: string;
361
+ message: string;
362
+ /** Path into the file (section.field or frontmatter.path). */
363
+ pointer?: string;
364
+ /** Suggested remediation text. */
365
+ remediation?: string;
366
+ /** Underlying error message if wrapping a thrown exception. */
367
+ cause?: string;
368
+ }
369
+ /**
370
+ * View models for the 21 standard sections defined in UW_FORMAT_SPEC_v1.md §4.
371
+ * Implementers SHOULD use these as the default rendering layout. Modules MAY
372
+ * override per-section by declaring their own `view_models` entry.
373
+ */
374
+ export declare const BUILTIN_VIEW_MODELS: ViewModelRegistry;
375
+ /**
376
+ * Default edit policies derived from canonical `_meta.source` patterns.
377
+ * Implementers consult this table to decide whether a write is a replace
378
+ * or a supersede, and whether the actor is permitted to write at all.
379
+ */
380
+ export declare const BUILTIN_EDIT_POLICIES: readonly EditPolicy[];
381
+ /**
382
+ * Remediation copy for the cross-cutting consistency checks CC-01..CC-10
383
+ * (see UW_FORMAT_SPEC_v1.md §5.3). Renderers SHOULD surface these strings
384
+ * verbatim in any validation issue list — the goal is uniform UX across
385
+ * every conforming implementation.
386
+ */
387
+ export declare const BUILTIN_REMEDIATIONS: readonly IssueRemediation[];
388
+ export type { AssetClass, ConfidenceLevel, DealStage, FinancialThresholds, ParsedUWFile, PipelineStatus, UWBlock, UWMeta, ValidationMessage, ValidationSeverity, };
389
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAIpB,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,EAAG,OAAgB,CAAC;AAEjD,oDAAoD;AACpD,eAAO,MAAM,cAAc,EAAG,KAAc,CAAC;AAI7C,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAClB,eAAe,GACf,eAAe,GACf,kBAAkB,GAClB,mBAAmB,CAAC;AAExB,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7F;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,UAAU,GACV,aAAa,GACb,YAAY,GACZ,gBAAgB,GAChB,aAAa,GACb,YAAY,GACZ,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,eAAe,GACf,oBAAoB,GACpB,YAAY,GACZ,aAAa,CAAC;AAElB,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AACjE,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvD,0EAA0E;AAC1E,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,EAAE,uBAAuB,EA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