@rcrsr/rill 0.15.0 → 0.17.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 (316) hide show
  1. package/README.md +37 -21
  2. package/dist/ast-nodes.d.ts +2 -13
  3. package/dist/ast-nodes.js +0 -1
  4. package/dist/ast-unions.d.ts +0 -1
  5. package/dist/ast-unions.js +0 -1
  6. package/dist/constants.d.ts +0 -1
  7. package/dist/constants.js +0 -1
  8. package/dist/error-classes.d.ts +0 -1
  9. package/dist/error-classes.js +0 -1
  10. package/dist/error-formatter.d.ts +0 -1
  11. package/dist/error-formatter.js +0 -1
  12. package/dist/error-registry.d.ts +0 -1
  13. package/dist/error-registry.js +32 -1
  14. package/dist/ext/crypto/index.d.ts +3 -4
  15. package/dist/ext/crypto/index.js +66 -64
  16. package/dist/ext/exec/index.d.ts +3 -4
  17. package/dist/ext/exec/index.js +17 -12
  18. package/dist/ext/exec/runner.d.ts +0 -1
  19. package/dist/ext/exec/runner.js +0 -1
  20. package/dist/ext/fetch/index.d.ts +3 -4
  21. package/dist/ext/fetch/index.js +23 -49
  22. package/dist/ext/fetch/request.d.ts +0 -1
  23. package/dist/ext/fetch/request.js +0 -1
  24. package/dist/ext/fs/index.d.ts +3 -4
  25. package/dist/ext/fs/index.js +268 -266
  26. package/dist/ext/fs/sandbox.d.ts +0 -1
  27. package/dist/ext/fs/sandbox.js +0 -1
  28. package/dist/ext/kv/index.d.ts +3 -4
  29. package/dist/ext/kv/index.js +216 -215
  30. package/dist/ext/kv/store.d.ts +0 -1
  31. package/dist/ext/kv/store.js +2 -2
  32. package/dist/ext-parse-bridge.d.ts +10 -0
  33. package/dist/ext-parse-bridge.js +10 -0
  34. package/dist/generated/introspection-data.d.ts +1 -2
  35. package/dist/generated/introspection-data.js +385 -297
  36. package/dist/generated/version-data.d.ts +1 -2
  37. package/dist/generated/version-data.js +2 -3
  38. package/dist/highlight-map.d.ts +0 -1
  39. package/dist/highlight-map.js +0 -1
  40. package/dist/index.d.ts +15 -5
  41. package/dist/index.js +14 -6
  42. package/dist/lexer/errors.d.ts +0 -1
  43. package/dist/lexer/errors.js +0 -1
  44. package/dist/lexer/helpers.d.ts +0 -1
  45. package/dist/lexer/helpers.js +0 -1
  46. package/dist/lexer/index.d.ts +0 -1
  47. package/dist/lexer/index.js +0 -1
  48. package/dist/lexer/operators.d.ts +0 -1
  49. package/dist/lexer/operators.js +0 -1
  50. package/dist/lexer/readers.d.ts +0 -1
  51. package/dist/lexer/readers.js +0 -1
  52. package/dist/lexer/state.d.ts +0 -1
  53. package/dist/lexer/state.js +0 -1
  54. package/dist/lexer/tokenizer.d.ts +0 -1
  55. package/dist/lexer/tokenizer.js +0 -1
  56. package/dist/parser/helpers.d.ts +0 -1
  57. package/dist/parser/helpers.js +0 -1
  58. package/dist/parser/index.d.ts +0 -1
  59. package/dist/parser/index.js +0 -1
  60. package/dist/parser/parser-collect.d.ts +0 -1
  61. package/dist/parser/parser-collect.js +0 -1
  62. package/dist/parser/parser-control.d.ts +0 -1
  63. package/dist/parser/parser-control.js +0 -1
  64. package/dist/parser/parser-expr.d.ts +0 -1
  65. package/dist/parser/parser-expr.js +0 -1
  66. package/dist/parser/parser-extract.d.ts +0 -1
  67. package/dist/parser/parser-extract.js +0 -1
  68. package/dist/parser/parser-functions.d.ts +0 -1
  69. package/dist/parser/parser-functions.js +0 -1
  70. package/dist/parser/parser-literals.d.ts +0 -1
  71. package/dist/parser/parser-literals.js +4 -2
  72. package/dist/parser/parser-script.d.ts +0 -1
  73. package/dist/parser/parser-script.js +0 -1
  74. package/dist/parser/parser-shape.d.ts +2 -3
  75. package/dist/parser/parser-shape.js +8 -52
  76. package/dist/parser/parser-types.d.ts +28 -2
  77. package/dist/parser/parser-types.js +76 -13
  78. package/dist/parser/parser-use.d.ts +0 -1
  79. package/dist/parser/parser-use.js +7 -2
  80. package/dist/parser/parser-variables.d.ts +0 -1
  81. package/dist/parser/parser-variables.js +0 -1
  82. package/dist/parser/parser.d.ts +0 -1
  83. package/dist/parser/parser.js +0 -1
  84. package/dist/parser/state.d.ts +0 -1
  85. package/dist/parser/state.js +0 -1
  86. package/dist/runtime/core/callable.d.ts +59 -20
  87. package/dist/runtime/core/callable.js +188 -39
  88. package/dist/runtime/core/context.d.ts +0 -12
  89. package/dist/runtime/core/context.js +77 -77
  90. package/dist/runtime/core/equals.d.ts +0 -1
  91. package/dist/runtime/core/equals.js +35 -3
  92. package/dist/runtime/core/eval/base.d.ts +0 -1
  93. package/dist/runtime/core/eval/base.js +0 -1
  94. package/dist/runtime/core/eval/evaluator.d.ts +0 -1
  95. package/dist/runtime/core/eval/evaluator.js +0 -1
  96. package/dist/runtime/core/eval/index.d.ts +2 -3
  97. package/dist/runtime/core/eval/index.js +11 -1
  98. package/dist/runtime/core/eval/mixins/annotations.d.ts +0 -1
  99. package/dist/runtime/core/eval/mixins/annotations.js +0 -1
  100. package/dist/runtime/core/eval/mixins/closures.d.ts +0 -1
  101. package/dist/runtime/core/eval/mixins/closures.js +92 -70
  102. package/dist/runtime/core/eval/mixins/collections.d.ts +0 -1
  103. package/dist/runtime/core/eval/mixins/collections.js +9 -4
  104. package/dist/runtime/core/eval/mixins/control-flow.d.ts +0 -1
  105. package/dist/runtime/core/eval/mixins/control-flow.js +0 -1
  106. package/dist/runtime/core/eval/mixins/conversion.d.ts +0 -1
  107. package/dist/runtime/core/eval/mixins/conversion.js +196 -188
  108. package/dist/runtime/core/eval/mixins/core.d.ts +0 -1
  109. package/dist/runtime/core/eval/mixins/core.js +2 -3
  110. package/dist/runtime/core/eval/mixins/expressions.d.ts +0 -1
  111. package/dist/runtime/core/eval/mixins/expressions.js +35 -28
  112. package/dist/runtime/core/eval/mixins/extraction.d.ts +0 -1
  113. package/dist/runtime/core/eval/mixins/extraction.js +8 -9
  114. package/dist/runtime/core/eval/mixins/list-dispatch.d.ts +0 -1
  115. package/dist/runtime/core/eval/mixins/list-dispatch.js +0 -1
  116. package/dist/runtime/core/eval/mixins/literals.d.ts +0 -1
  117. package/dist/runtime/core/eval/mixins/literals.js +6 -10
  118. package/dist/runtime/core/eval/mixins/types.d.ts +2 -1
  119. package/dist/runtime/core/eval/mixins/types.js +231 -261
  120. package/dist/runtime/core/eval/mixins/use.d.ts +0 -1
  121. package/dist/runtime/core/eval/mixins/use.js +0 -1
  122. package/dist/runtime/core/eval/mixins/variables.d.ts +0 -1
  123. package/dist/runtime/core/eval/mixins/variables.js +16 -15
  124. package/dist/runtime/core/eval/types.d.ts +0 -1
  125. package/dist/runtime/core/eval/types.js +0 -1
  126. package/dist/runtime/core/execute.d.ts +0 -1
  127. package/dist/runtime/core/execute.js +0 -1
  128. package/dist/runtime/core/field-descriptor.d.ts +4 -5
  129. package/dist/runtime/core/field-descriptor.js +2 -2
  130. package/dist/runtime/core/introspection.d.ts +0 -1
  131. package/dist/runtime/core/introspection.js +6 -7
  132. package/dist/runtime/core/markers.d.ts +12 -0
  133. package/dist/runtime/core/markers.js +7 -0
  134. package/dist/runtime/core/resolvers.d.ts +0 -1
  135. package/dist/runtime/core/resolvers.js +0 -1
  136. package/dist/runtime/core/signals.d.ts +0 -1
  137. package/dist/runtime/core/signals.js +0 -1
  138. package/dist/runtime/core/type-registrations.d.ts +136 -0
  139. package/dist/runtime/core/type-registrations.js +749 -0
  140. package/dist/runtime/core/type-structures.d.ts +128 -0
  141. package/dist/runtime/core/type-structures.js +12 -0
  142. package/dist/runtime/core/types.d.ts +15 -4
  143. package/dist/runtime/core/types.js +0 -1
  144. package/dist/runtime/core/values.d.ts +88 -146
  145. package/dist/runtime/core/values.js +466 -470
  146. package/dist/runtime/ext/builtins.d.ts +0 -1
  147. package/dist/runtime/ext/builtins.js +125 -80
  148. package/dist/runtime/ext/extensions.d.ts +30 -125
  149. package/dist/runtime/ext/extensions.js +0 -94
  150. package/dist/runtime/ext/test-context.d.ts +28 -0
  151. package/dist/runtime/ext/test-context.js +154 -0
  152. package/dist/runtime/index.d.ts +22 -9
  153. package/dist/runtime/index.js +18 -5
  154. package/dist/signature-parser.d.ts +2 -3
  155. package/dist/signature-parser.js +19 -17
  156. package/dist/source-location.d.ts +0 -1
  157. package/dist/source-location.js +0 -1
  158. package/dist/token-types.d.ts +0 -1
  159. package/dist/token-types.js +0 -1
  160. package/dist/types.d.ts +0 -1
  161. package/dist/types.js +0 -1
  162. package/dist/value-types.d.ts +15 -12
  163. package/dist/value-types.js +0 -1
  164. package/package.json +2 -1
  165. package/dist/ast-nodes.d.ts.map +0 -1
  166. package/dist/ast-nodes.js.map +0 -1
  167. package/dist/ast-unions.d.ts.map +0 -1
  168. package/dist/ast-unions.js.map +0 -1
  169. package/dist/constants.d.ts.map +0 -1
  170. package/dist/constants.js.map +0 -1
  171. package/dist/error-classes.d.ts.map +0 -1
  172. package/dist/error-classes.js.map +0 -1
  173. package/dist/error-formatter.d.ts.map +0 -1
  174. package/dist/error-formatter.js.map +0 -1
  175. package/dist/error-registry.d.ts.map +0 -1
  176. package/dist/error-registry.js.map +0 -1
  177. package/dist/ext/crypto/index.d.ts.map +0 -1
  178. package/dist/ext/crypto/index.js.map +0 -1
  179. package/dist/ext/exec/index.d.ts.map +0 -1
  180. package/dist/ext/exec/index.js.map +0 -1
  181. package/dist/ext/exec/runner.d.ts.map +0 -1
  182. package/dist/ext/exec/runner.js.map +0 -1
  183. package/dist/ext/fetch/index.d.ts.map +0 -1
  184. package/dist/ext/fetch/index.js.map +0 -1
  185. package/dist/ext/fetch/request.d.ts.map +0 -1
  186. package/dist/ext/fetch/request.js.map +0 -1
  187. package/dist/ext/fs/index.d.ts.map +0 -1
  188. package/dist/ext/fs/index.js.map +0 -1
  189. package/dist/ext/fs/sandbox.d.ts.map +0 -1
  190. package/dist/ext/fs/sandbox.js.map +0 -1
  191. package/dist/ext/kv/index.d.ts.map +0 -1
  192. package/dist/ext/kv/index.js.map +0 -1
  193. package/dist/ext/kv/store.d.ts.map +0 -1
  194. package/dist/ext/kv/store.js.map +0 -1
  195. package/dist/generated/introspection-data.d.ts.map +0 -1
  196. package/dist/generated/introspection-data.js.map +0 -1
  197. package/dist/generated/version-data.d.ts.map +0 -1
  198. package/dist/generated/version-data.js.map +0 -1
  199. package/dist/highlight-map.d.ts.map +0 -1
  200. package/dist/highlight-map.js.map +0 -1
  201. package/dist/index.d.ts.map +0 -1
  202. package/dist/index.js.map +0 -1
  203. package/dist/lexer/errors.d.ts.map +0 -1
  204. package/dist/lexer/errors.js.map +0 -1
  205. package/dist/lexer/helpers.d.ts.map +0 -1
  206. package/dist/lexer/helpers.js.map +0 -1
  207. package/dist/lexer/index.d.ts.map +0 -1
  208. package/dist/lexer/index.js.map +0 -1
  209. package/dist/lexer/operators.d.ts.map +0 -1
  210. package/dist/lexer/operators.js.map +0 -1
  211. package/dist/lexer/readers.d.ts.map +0 -1
  212. package/dist/lexer/readers.js.map +0 -1
  213. package/dist/lexer/state.d.ts.map +0 -1
  214. package/dist/lexer/state.js.map +0 -1
  215. package/dist/lexer/tokenizer.d.ts.map +0 -1
  216. package/dist/lexer/tokenizer.js.map +0 -1
  217. package/dist/parser/helpers.d.ts.map +0 -1
  218. package/dist/parser/helpers.js.map +0 -1
  219. package/dist/parser/index.d.ts.map +0 -1
  220. package/dist/parser/index.js.map +0 -1
  221. package/dist/parser/parser-collect.d.ts.map +0 -1
  222. package/dist/parser/parser-collect.js.map +0 -1
  223. package/dist/parser/parser-control.d.ts.map +0 -1
  224. package/dist/parser/parser-control.js.map +0 -1
  225. package/dist/parser/parser-expr.d.ts.map +0 -1
  226. package/dist/parser/parser-expr.js.map +0 -1
  227. package/dist/parser/parser-extract.d.ts.map +0 -1
  228. package/dist/parser/parser-extract.js.map +0 -1
  229. package/dist/parser/parser-functions.d.ts.map +0 -1
  230. package/dist/parser/parser-functions.js.map +0 -1
  231. package/dist/parser/parser-literals.d.ts.map +0 -1
  232. package/dist/parser/parser-literals.js.map +0 -1
  233. package/dist/parser/parser-script.d.ts.map +0 -1
  234. package/dist/parser/parser-script.js.map +0 -1
  235. package/dist/parser/parser-shape.d.ts.map +0 -1
  236. package/dist/parser/parser-shape.js.map +0 -1
  237. package/dist/parser/parser-types.d.ts.map +0 -1
  238. package/dist/parser/parser-types.js.map +0 -1
  239. package/dist/parser/parser-use.d.ts.map +0 -1
  240. package/dist/parser/parser-use.js.map +0 -1
  241. package/dist/parser/parser-variables.d.ts.map +0 -1
  242. package/dist/parser/parser-variables.js.map +0 -1
  243. package/dist/parser/parser.d.ts.map +0 -1
  244. package/dist/parser/parser.js.map +0 -1
  245. package/dist/parser/state.d.ts.map +0 -1
  246. package/dist/parser/state.js.map +0 -1
  247. package/dist/runtime/core/callable.d.ts.map +0 -1
  248. package/dist/runtime/core/callable.js.map +0 -1
  249. package/dist/runtime/core/context.d.ts.map +0 -1
  250. package/dist/runtime/core/context.js.map +0 -1
  251. package/dist/runtime/core/equals.d.ts.map +0 -1
  252. package/dist/runtime/core/equals.js.map +0 -1
  253. package/dist/runtime/core/eval/base.d.ts.map +0 -1
  254. package/dist/runtime/core/eval/base.js.map +0 -1
  255. package/dist/runtime/core/eval/evaluator.d.ts.map +0 -1
  256. package/dist/runtime/core/eval/evaluator.js.map +0 -1
  257. package/dist/runtime/core/eval/index.d.ts.map +0 -1
  258. package/dist/runtime/core/eval/index.js.map +0 -1
  259. package/dist/runtime/core/eval/mixins/annotations.d.ts.map +0 -1
  260. package/dist/runtime/core/eval/mixins/annotations.js.map +0 -1
  261. package/dist/runtime/core/eval/mixins/closures.d.ts.map +0 -1
  262. package/dist/runtime/core/eval/mixins/closures.js.map +0 -1
  263. package/dist/runtime/core/eval/mixins/collections.d.ts.map +0 -1
  264. package/dist/runtime/core/eval/mixins/collections.js.map +0 -1
  265. package/dist/runtime/core/eval/mixins/control-flow.d.ts.map +0 -1
  266. package/dist/runtime/core/eval/mixins/control-flow.js.map +0 -1
  267. package/dist/runtime/core/eval/mixins/conversion.d.ts.map +0 -1
  268. package/dist/runtime/core/eval/mixins/conversion.js.map +0 -1
  269. package/dist/runtime/core/eval/mixins/core.d.ts.map +0 -1
  270. package/dist/runtime/core/eval/mixins/core.js.map +0 -1
  271. package/dist/runtime/core/eval/mixins/expressions.d.ts.map +0 -1
  272. package/dist/runtime/core/eval/mixins/expressions.js.map +0 -1
  273. package/dist/runtime/core/eval/mixins/extraction.d.ts.map +0 -1
  274. package/dist/runtime/core/eval/mixins/extraction.js.map +0 -1
  275. package/dist/runtime/core/eval/mixins/list-dispatch.d.ts.map +0 -1
  276. package/dist/runtime/core/eval/mixins/list-dispatch.js.map +0 -1
  277. package/dist/runtime/core/eval/mixins/literals.d.ts.map +0 -1
  278. package/dist/runtime/core/eval/mixins/literals.js.map +0 -1
  279. package/dist/runtime/core/eval/mixins/types.d.ts.map +0 -1
  280. package/dist/runtime/core/eval/mixins/types.js.map +0 -1
  281. package/dist/runtime/core/eval/mixins/use.d.ts.map +0 -1
  282. package/dist/runtime/core/eval/mixins/use.js.map +0 -1
  283. package/dist/runtime/core/eval/mixins/variables.d.ts.map +0 -1
  284. package/dist/runtime/core/eval/mixins/variables.js.map +0 -1
  285. package/dist/runtime/core/eval/types.d.ts.map +0 -1
  286. package/dist/runtime/core/eval/types.js.map +0 -1
  287. package/dist/runtime/core/execute.d.ts.map +0 -1
  288. package/dist/runtime/core/execute.js.map +0 -1
  289. package/dist/runtime/core/field-descriptor.d.ts.map +0 -1
  290. package/dist/runtime/core/field-descriptor.js.map +0 -1
  291. package/dist/runtime/core/introspection.d.ts.map +0 -1
  292. package/dist/runtime/core/introspection.js.map +0 -1
  293. package/dist/runtime/core/resolvers.d.ts.map +0 -1
  294. package/dist/runtime/core/resolvers.js.map +0 -1
  295. package/dist/runtime/core/signals.d.ts.map +0 -1
  296. package/dist/runtime/core/signals.js.map +0 -1
  297. package/dist/runtime/core/types.d.ts.map +0 -1
  298. package/dist/runtime/core/types.js.map +0 -1
  299. package/dist/runtime/core/values.d.ts.map +0 -1
  300. package/dist/runtime/core/values.js.map +0 -1
  301. package/dist/runtime/ext/builtins.d.ts.map +0 -1
  302. package/dist/runtime/ext/builtins.js.map +0 -1
  303. package/dist/runtime/ext/extensions.d.ts.map +0 -1
  304. package/dist/runtime/ext/extensions.js.map +0 -1
  305. package/dist/runtime/index.d.ts.map +0 -1
  306. package/dist/runtime/index.js.map +0 -1
  307. package/dist/signature-parser.d.ts.map +0 -1
  308. package/dist/signature-parser.js.map +0 -1
  309. package/dist/source-location.d.ts.map +0 -1
  310. package/dist/source-location.js.map +0 -1
  311. package/dist/token-types.d.ts.map +0 -1
  312. package/dist/token-types.js.map +0 -1
  313. package/dist/types.d.ts.map +0 -1
  314. package/dist/types.js.map +0 -1
  315. package/dist/value-types.d.ts.map +0 -1
  316. package/dist/value-types.js.map +0 -1
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Type Structure Definitions
3
+ *
4
+ * Defines the TypeStructure union (discriminated by `.kind`) and
5
+ * associated value interfaces. These types form the foundation for
6
+ * the type registration and dispatch system.
7
+ *
8
+ * The TypeStructure union mirrors the existing RillType union but uses
9
+ * `.kind` as its discriminator instead of `.type`, enabling future
10
+ * coexistence during migration.
11
+ */
12
+ import type { RillTypeName } from '../../types.js';
13
+ import type { CallableMarker, FieldDescriptorMarker } from './markers.js';
14
+ /**
15
+ * Field definition - describes a single field in a structural type.
16
+ * Used by dict, tuple, ordered, and closure type descriptors.
17
+ * Default detection: `field.defaultValue !== undefined`.
18
+ *
19
+ * Uses TypeStructure (not RillType) for the field's type descriptor.
20
+ */
21
+ export interface RillFieldDef {
22
+ name?: string | undefined;
23
+ type: TypeStructure;
24
+ defaultValue?: RillValue | undefined;
25
+ }
26
+ /**
27
+ * Structural type descriptor - describes the shape of a value in the type system.
28
+ * Discriminated by `.kind` (not `.type`).
29
+ *
30
+ * Includes all 12 built-in variants plus a catch-all for types without
31
+ * parameterized structure (e.g. iterator).
32
+ */
33
+ export type TypeStructure = {
34
+ kind: 'number';
35
+ } | {
36
+ kind: 'string';
37
+ } | {
38
+ kind: 'bool';
39
+ } | {
40
+ kind: 'vector';
41
+ } | {
42
+ kind: 'type';
43
+ } | {
44
+ kind: 'any';
45
+ } | {
46
+ kind: 'dict';
47
+ fields?: Record<string, RillFieldDef> | undefined;
48
+ valueType?: TypeStructure | undefined;
49
+ } | {
50
+ kind: 'list';
51
+ element?: TypeStructure | undefined;
52
+ } | {
53
+ kind: 'closure';
54
+ params?: RillFieldDef[] | undefined;
55
+ ret?: TypeStructure | undefined;
56
+ } | {
57
+ kind: 'tuple';
58
+ elements?: RillFieldDef[] | undefined;
59
+ valueType?: TypeStructure | undefined;
60
+ } | {
61
+ kind: 'ordered';
62
+ fields?: RillFieldDef[] | undefined;
63
+ valueType?: TypeStructure | undefined;
64
+ } | {
65
+ kind: 'union';
66
+ members: TypeStructure[];
67
+ } | {
68
+ kind: 'iterator';
69
+ } | {
70
+ kind: string;
71
+ data?: unknown;
72
+ };
73
+ /**
74
+ * Tuple type - represents positional unpacked arguments for closure invocation.
75
+ * Created by the * (spread) operator from lists.
76
+ * Entries are positional only.
77
+ *
78
+ * Note: In Rill, "tuple" refers to fixed-size argument packing (like function signatures),
79
+ * while "list" refers to dynamic ordered collections ([1, 2, 3]).
80
+ */
81
+ export interface RillTuple {
82
+ readonly __rill_tuple: true;
83
+ readonly entries: RillValue[];
84
+ }
85
+ /**
86
+ * Ordered type - represents named key-value pairs with preserved insertion order.
87
+ * Created by the * (spread) operator from dicts.
88
+ * Entries may carry an optional third element (default value) when representing
89
+ * closure parameter reflection via `.^input`.
90
+ */
91
+ export interface RillOrdered {
92
+ readonly __rill_ordered: true;
93
+ readonly entries: [string, RillValue, RillValue?][];
94
+ }
95
+ /**
96
+ * Vector type - represents dense numeric embeddings.
97
+ * Immutable Float32Array with associated model name.
98
+ */
99
+ export interface RillVector {
100
+ readonly __rill_vector: true;
101
+ readonly data: Float32Array;
102
+ readonly model: string;
103
+ }
104
+ /**
105
+ * Type value - represents a first-class type name at runtime.
106
+ * Created when a type name expression (e.g. `string`, `number`) is evaluated.
107
+ */
108
+ export interface RillTypeValue {
109
+ readonly __rill_type: true;
110
+ readonly typeName: RillTypeName;
111
+ readonly structure: TypeStructure;
112
+ }
113
+ /**
114
+ * Iterator type - represents a lazy sequence.
115
+ * An iterator is a dict with:
116
+ * - done: boolean - whether iteration is complete
117
+ * - next: callable - function to get next iterator
118
+ * - value?: any - current value (absent when done)
119
+ */
120
+ export interface RillIterator extends Record<string, RillValue> {
121
+ readonly done: boolean;
122
+ readonly next: CallableMarker;
123
+ readonly value?: RillValue;
124
+ }
125
+ /** Any value that can flow through Rill */
126
+ export type RillValue = string | number | boolean | null | RillValue[] | {
127
+ [key: string]: RillValue;
128
+ } | CallableMarker | RillTuple | RillOrdered | RillVector | FieldDescriptorMarker | RillTypeValue;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Type Structure Definitions
3
+ *
4
+ * Defines the TypeStructure union (discriminated by `.kind`) and
5
+ * associated value interfaces. These types form the foundation for
6
+ * the type registration and dispatch system.
7
+ *
8
+ * The TypeStructure union mirrors the existing RillType union but uses
9
+ * `.kind` as its discriminator instead of `.type`, enabling future
10
+ * coexistence during migration.
11
+ */
12
+ export {};
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import type { RillTypeName } from '../../types.js';
8
8
  import type { CallableFn, RillFunction } from './callable.js';
9
- import type { RillType, RillValue } from './values.js';
9
+ import type { TypeStructure, RillValue } from './values.js';
10
10
  export type { NativeArray, NativePlainObject, NativeValue } from './values.js';
11
11
  /** I/O callbacks for runtime operations */
12
12
  export interface RuntimeCallbacks {
@@ -119,7 +119,7 @@ export interface RuntimeContext {
119
119
  /** Named variables ($varname) - local to this scope */
120
120
  readonly variables: Map<string, RillValue>;
121
121
  /** Variable types - locked after first assignment (local to this scope) */
122
- readonly variableTypes: Map<string, RillTypeName | RillType>;
122
+ readonly variableTypes: Map<string, RillTypeName | TypeStructure>;
123
123
  /** Built-in and user-defined functions (CallableFn for untyped, ApplicationCallable for typed) */
124
124
  readonly functions: Map<string, CallableFn | import('./callable.js').ApplicationCallable>;
125
125
  /** I/O callbacks */
@@ -158,9 +158,21 @@ export interface RuntimeContext {
158
158
  /**
159
159
  * Per-type method dictionaries: maps type name to a frozen dict of ApplicationCallable values.
160
160
  * Keys: "string", "list", "dict", "number", "bool", "vector".
161
- * Populated at context creation from BUILTIN_METHODS; propagated to child contexts.
161
+ * Populated at context creation from type registrations; propagated to child contexts.
162
162
  */
163
163
  readonly typeMethodDicts: ReadonlyMap<string, Readonly<Record<string, RillValue>>>;
164
+ /**
165
+ * Type names that reject type arguments in type constructors.
166
+ * Derived from BUILT_IN_TYPES registrations where isLeaf === true, plus 'any'.
167
+ * Used by type assertion/check evaluation to reject e.g. string(number).
168
+ */
169
+ readonly leafTypes: ReadonlySet<string>;
170
+ /**
171
+ * Method names that handle their own receiver type checking with specific
172
+ * error messages. Generic RILL-R003 must not fire before the method body runs.
173
+ * Derived from registration method dicts at context creation.
174
+ */
175
+ readonly unvalidatedMethodReceivers: ReadonlySet<string>;
164
176
  /** Scheme-to-resolver map, populated from RuntimeOptions.resolvers (empty Map when absent) */
165
177
  readonly resolvers: ReadonlyMap<string, SchemeResolver>;
166
178
  /** Per-scheme config data, populated from RuntimeOptions.configurations.resolvers (empty Map when absent) */
@@ -255,4 +267,3 @@ export interface ExecutionStepper {
255
267
  * This sets boundDict on each callable so they can access their container.
256
268
  */
257
269
  export declare function bindDictCallables(value: RillValue): RillValue;
258
- //# sourceMappingURL=types.d.ts.map
@@ -47,4 +47,3 @@ export function bindDictCallables(value) {
47
47
  }
48
48
  return result;
49
49
  }
50
- //# sourceMappingURL=types.js.map
@@ -3,112 +3,30 @@
3
3
  *
4
4
  * Core value types that flow through Rill programs.
5
5
  * Public API for host applications.
6
- */
7
- import type { RillTypeName } from '../../types.js';
8
- interface CallableMarker {
9
- readonly __type: 'callable';
10
- }
11
- interface FieldDescriptorMarker {
12
- readonly __rill_field_descriptor: true;
13
- }
14
- /**
15
- * Tuple type - represents positional unpacked arguments for closure invocation.
16
- * Created by the * (spread) operator from lists.
17
- * Entries are positional only.
18
6
  *
19
- * Note: In Rill, "tuple" refers to fixed-size argument packing (like function signatures),
20
- * while "list" refers to dynamic ordered collections ([1, 2, 3]).
21
- */
22
- export interface RillTuple {
23
- readonly __rill_tuple: true;
24
- readonly entries: RillValue[];
25
- }
26
- /**
27
- * Ordered type - represents named key-value pairs with preserved insertion order.
28
- * Created by the * (spread) operator from dicts.
29
- */
30
- export interface RillOrdered {
31
- readonly __rill_ordered: true;
32
- readonly entries: [string, RillValue][];
33
- }
34
- /**
35
- * Vector type - represents dense numeric embeddings.
36
- * Immutable Float32Array with associated model name.
7
+ * Dispatch functions (inferType, formatValue, deepEquals, serializeValue,
8
+ * copyValue) re-export from type-registrations.ts protocol implementations.
37
9
  */
38
- export interface RillVector {
39
- readonly __rill_vector: true;
40
- readonly data: Float32Array;
41
- readonly model: string;
42
- }
43
- /**
44
- * Structural type descriptor - describes the shape of a value in the type system.
45
- * Used by RillTypeValue to carry type structure information at runtime.
46
- */
47
- export type RillType = {
48
- type: 'number';
49
- } | {
50
- type: 'string';
51
- } | {
52
- type: 'bool';
53
- } | {
54
- type: 'vector';
55
- } | {
56
- type: 'type';
57
- } | {
58
- type: 'any';
59
- } | {
60
- type: 'dict';
61
- fields?: Record<string, RillFieldType>;
62
- } | {
63
- type: 'list';
64
- element?: RillType;
65
- } | {
66
- type: 'closure';
67
- params?: [string, RillType, RillValue?][];
68
- ret?: RillType;
69
- } | {
70
- type: 'tuple';
71
- elements?: [RillType, RillValue?][];
72
- } | {
73
- type: 'ordered';
74
- fields?: [string, RillType, RillValue?][];
75
- } | {
76
- type: 'union';
77
- members: RillType[];
10
+ import type { RillTypeName } from '../../types.js';
11
+ import type { RillFieldDef, RillIterator, RillOrdered, RillTuple, RillTypeValue, RillValue, RillVector, TypeStructure } from './type-structures.js';
12
+ export type { RillFieldDef, RillIterator, RillOrdered, RillTuple, RillTypeValue, RillValue, RillVector, TypeStructure, };
13
+ export type DictStructure = {
14
+ kind: 'dict';
15
+ fields?: Record<string, RillFieldDef>;
16
+ valueType?: TypeStructure;
78
17
  };
79
- /**
80
- * Dict field type - either a plain RillType or a RillType paired with a default value.
81
- * Used in dict structural types to carry optional default values per field.
82
- */
83
- export type RillFieldType = RillType | {
84
- type: RillType;
85
- defaultValue: RillValue;
18
+ export type TupleStructure = {
19
+ kind: 'tuple';
20
+ elements?: RillFieldDef[];
21
+ valueType?: TypeStructure;
86
22
  };
87
- /**
88
- * Type guard to distinguish the `{ type, defaultValue }` form of RillFieldType
89
- * from a plain RillType.
90
- */
91
- export declare function isFieldTypeWithDefault(fieldType: RillFieldType): fieldType is {
92
- type: RillType;
93
- defaultValue: RillValue;
23
+ export type OrderedStructure = {
24
+ kind: 'ordered';
25
+ fields?: RillFieldDef[];
26
+ valueType?: TypeStructure;
94
27
  };
95
- /**
96
- * @deprecated Use RillType instead. Will be removed in the next major version.
97
- */
98
- export type RillStructuralType = RillType;
99
- /**
100
- * Type value - represents a first-class type name at runtime.
101
- * Created when a type name expression (e.g. `string`, `number`) is evaluated.
102
- */
103
- export interface RillTypeValue {
104
- readonly __rill_type: true;
105
- readonly typeName: RillTypeName;
106
- readonly structure: RillType;
107
- }
108
- /** Any value that can flow through Rill */
109
- export type RillValue = string | number | boolean | null | RillValue[] | {
110
- [key: string]: RillValue;
111
- } | CallableMarker | RillTuple | RillOrdered | RillVector | FieldDescriptorMarker | RillTypeValue;
28
+ /** @deprecated Use TypeStructure instead. */
29
+ export type RillType = TypeStructure;
112
30
  /** Type guard for RillTuple (spread args) */
113
31
  export declare function isTuple(value: RillValue): value is RillTuple;
114
32
  /** Type guard for RillVector */
@@ -117,8 +35,12 @@ export declare function isVector(value: RillValue): value is RillVector;
117
35
  export declare function isOrdered(value: RillValue): value is RillOrdered;
118
36
  /** Type guard for RillTypeValue */
119
37
  export declare function isTypeValue(value: RillValue): value is RillTypeValue;
120
- /** Create ordered from entries array (named, preserves insertion order) */
121
- export declare function createOrdered(entries: [string, RillValue][]): RillOrdered;
38
+ /**
39
+ * Create ordered from entries array (named, preserves insertion order).
40
+ * Entries may be 2-element [name, value] or 3-element [name, value, default]
41
+ * tuples; the third element carries a default value for `.^input` reflection.
42
+ */
43
+ export declare function createOrdered(entries: [string, RillValue, RillValue?][]): RillOrdered;
122
44
  /** Create tuple from entries array (positional, preserves order) */
123
45
  export declare function createTuple(entries: RillValue[]): RillTuple;
124
46
  /**
@@ -126,27 +48,48 @@ export declare function createTuple(entries: RillValue[]): RillTuple;
126
48
  * @throws {Error} if data.length is 0 (zero-dimension vectors not allowed)
127
49
  */
128
50
  export declare function createVector(data: Float32Array, model: string): RillVector;
129
- /** Infer the Rill type from a runtime value */
130
- export declare function inferType(value: RillValue): RillTypeName;
51
+ /** Infer the Rill type from a runtime value. Delegates to type-registrations. */
52
+ export declare const inferType: (value: RillValue) => string;
131
53
  /**
132
54
  * Infer the element type for a homogeneous list.
133
- * Empty arrays return { type: 'any' }.
55
+ * Empty arrays return { kind: 'any' }.
134
56
  * Mixed types throw RILL-R002.
135
57
  */
136
- export declare function inferElementType(elements: RillValue[]): RillType;
58
+ export declare function inferElementType(elements: RillValue[]): TypeStructure;
59
+ /**
60
+ * Return the most specific shared type for two TypeStructure values.
61
+ * Returns null when types are incompatible at the top level.
62
+ *
63
+ * Cascade priority:
64
+ * 1. Any-narrowing: if either side is `any`, return the other
65
+ * 2. Structural match: delegate to structureEquals; on true, return a
66
+ * 3. Recursive list: merge inner element types
67
+ * 3b. Uniform valueType: merge dict/tuple/ordered value types
68
+ * 4. Bare type fallback: same compound type but structural mismatch
69
+ * 5. Incompatible: different top-level types return null
70
+ */
71
+ export declare function commonType(a: TypeStructure, b: TypeStructure): TypeStructure | null;
137
72
  /** Compare two structural types for equality. */
138
- export declare function structuralTypeEquals(a: RillType, b: RillType): boolean;
73
+ export declare function structureEquals(a: TypeStructure, b: TypeStructure): boolean;
74
+ /** @deprecated Use structureEquals instead. */
75
+ export declare const structuralTypeEquals: typeof structureEquals;
139
76
  /** Infer the structural type descriptor for any Rill value. */
140
- export declare function inferStructuralType(value: RillValue): RillType;
77
+ export declare function inferStructure(value: RillValue): TypeStructure;
78
+ /** @deprecated Use inferStructure instead. */
79
+ export declare const inferStructuralType: typeof inferStructure;
141
80
  /**
142
81
  * Check if a value matches a structural type descriptor.
143
82
  * Used for runtime type checking (`:?` operator).
144
83
  */
145
- export declare function structuralTypeMatches(value: RillValue, type: RillType): boolean;
146
- /** Build a closure param tuple, omitting the optional third element when no default. */
147
- export declare function paramToTypeTuple(name: string, type: RillType, defaultValue: RillValue | undefined): [string, RillType, RillValue?];
84
+ export declare function structureMatches(value: RillValue, type: TypeStructure): boolean;
85
+ /** @deprecated Use structureMatches instead. */
86
+ export declare const structuralTypeMatches: typeof structureMatches;
87
+ /** Build a closure param field definition from name, type, and optional default. */
88
+ export declare function paramToFieldDef(name: string, type: TypeStructure, defaultValue: RillValue | undefined): RillFieldDef;
148
89
  /** Format a structural type descriptor as a human-readable string. */
149
- export declare function formatStructuralType(type: RillType): string;
90
+ export declare function formatStructure(type: TypeStructure): string;
91
+ /** @deprecated Use formatStructure instead. */
92
+ export declare const formatStructuralType: typeof formatStructure;
150
93
  /**
151
94
  * Check if a value is of the expected type.
152
95
  * Returns true if the value matches the expected type, false otherwise.
@@ -156,8 +99,8 @@ export declare function checkType(value: RillValue, expected: RillTypeName): boo
156
99
  export declare function isTruthy(value: RillValue): boolean;
157
100
  /** Check if a value is empty (inverse of truthy) */
158
101
  export declare function isEmpty(value: RillValue): boolean;
159
- /** Format a value for display */
160
- export declare function formatValue(value: RillValue): string;
102
+ /** Format a value for display. Delegates to type-registrations. */
103
+ export declare const formatValue: (value: RillValue) => string;
161
104
  /**
162
105
  * Recursive native (host-side) value type.
163
106
  * Represents values that can cross the host/script boundary.
@@ -171,31 +114,25 @@ export type NativePlainObject = {
171
114
  };
172
115
  /** Structured result from toNative conversion */
173
116
  export interface NativeResult {
174
- /** Rill type name matches RillTypeName, or 'iterator' for lazy sequences */
117
+ /** Rill type name -- matches RillTypeName, or 'iterator' for lazy sequences */
175
118
  rillTypeName: string;
176
119
  /** Human-readable type signature, e.g. "string", "list(number)", "|x: number| :string" */
177
120
  rillTypeSignature: string;
178
121
  /** Native JS representation. Non-native types produce descriptor objects. */
179
122
  value: NativeValue;
180
123
  }
181
- /**
182
- * Convert a RillValue to a JSON-serializable value.
183
- * @throws {Error} plain Error (not RuntimeError) for non-serializable types
184
- */
185
- export declare function valueToJSON(value: RillValue): unknown;
124
+ /** Serialize a Rill value for JSON transport. Delegates to type-registrations. */
125
+ export declare const serializeValue: (value: RillValue) => unknown;
126
+ /** @deprecated Use serializeValue instead. */
127
+ export declare const valueToJSON: (value: RillValue) => unknown;
186
128
  /**
187
129
  * Convert a RillValue to a NativeResult for host consumption.
188
130
  * Non-representable types (closures, vectors, type values, iterators) produce descriptor objects.
189
131
  * Tuples convert to native arrays. Ordered values convert to plain objects.
190
132
  */
191
133
  export declare function toNative(value: RillValue): NativeResult;
192
- /**
193
- * Deep structural equality for all Rill values.
194
- * - Primitives: value equality
195
- * - Tuples: length + recursive element equality
196
- * - Dicts: same keys + recursive value equality (order-independent)
197
- */
198
- export declare function deepEquals(a: RillValue, b: RillValue): boolean;
134
+ /** Deep structural equality for all Rill values. Delegates to type-registrations. */
135
+ export declare const deepEquals: (a: RillValue, b: RillValue) => boolean;
199
136
  /** Reserved dict method names that cannot be overridden */
200
137
  export declare const RESERVED_DICT_METHODS: readonly ["keys", "values", "entries"];
201
138
  /**
@@ -204,25 +141,26 @@ export declare const RESERVED_DICT_METHODS: readonly ["keys", "values", "entries
204
141
  */
205
142
  export declare const anyTypeValue: RillTypeValue;
206
143
  /**
207
- * Convert a RillType structural descriptor to a RillTypeValue.
208
- * Uses the RillType's `type` field as the `typeName`.
144
+ * Convert a TypeStructure descriptor to a RillTypeValue.
145
+ * Uses the TypeStructure's `kind` field as the `typeName`.
209
146
  * Falls back to 'any' for compound types that lack a direct RillTypeName mapping.
210
147
  */
211
- export declare function rillTypeToTypeValue(type: RillType): RillTypeValue;
212
- /** Check if a key name is reserved */
213
- export declare function isReservedMethod(name: string): boolean;
148
+ export declare function structureToTypeValue(type: TypeStructure): RillTypeValue;
149
+ /** @deprecated Use structureToTypeValue instead. */
150
+ export declare const rillTypeToTypeValue: typeof structureToTypeValue;
214
151
  /**
215
- * Iterator type - represents a lazy sequence.
216
- * An iterator is a dict with:
217
- * - done: boolean - whether iteration is complete
218
- * - next: callable - function to get next iterator
219
- * - value: any (only required when not done) - current element
152
+ * Check if a type is a collection (dict, ordered, tuple) with defined
153
+ * fields or elements. Used to decide if an empty collection can be
154
+ * synthesized and hydrated.
220
155
  */
221
- export interface RillIterator extends Record<string, RillValue> {
222
- readonly done: boolean;
223
- readonly next: CallableMarker;
224
- readonly value?: RillValue;
225
- }
156
+ export declare function hasCollectionFields(type: TypeStructure): boolean;
157
+ /**
158
+ * Create an empty collection value matching the given TypeStructure.
159
+ * Assumes the type is dict, ordered, or tuple.
160
+ */
161
+ export declare function emptyForType(type: TypeStructure): RillValue;
162
+ /** Check if a key name is reserved */
163
+ export declare function isReservedMethod(name: string): boolean;
226
164
  /**
227
165
  * Type guard for Rill iterator (lazy sequence).
228
166
  * An iterator is a dict with:
@@ -230,6 +168,10 @@ export interface RillIterator extends Record<string, RillValue> {
230
168
  * - next: callable - function to get next iterator
231
169
  * - value: any (only required when not done) - current element
232
170
  */
233
- export declare function isRillIterator(value: RillValue): value is RillIterator;
234
- export {};
235
- //# sourceMappingURL=values.d.ts.map
171
+ export declare function isIterator(value: RillValue): value is RillIterator;
172
+ /** @deprecated Use isIterator instead. */
173
+ export declare const isRillIterator: typeof isIterator;
174
+ /** Copy a RillValue. Delegates to type-registrations. */
175
+ export declare const copyValue: (value: RillValue) => RillValue;
176
+ /** @deprecated Use copyValue instead. */
177
+ export declare const deepCopyRillValue: (value: RillValue) => RillValue;