@rcrsr/rill 0.16.0 → 0.18.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 (97) hide show
  1. package/README.md +37 -21
  2. package/dist/ast-nodes.d.ts +14 -4
  3. package/dist/ast-unions.d.ts +1 -1
  4. package/dist/constants.d.ts +1 -1
  5. package/dist/constants.js +1 -0
  6. package/dist/error-registry.js +228 -0
  7. package/dist/ext/crypto/index.d.ts +3 -3
  8. package/dist/ext/crypto/index.js +62 -59
  9. package/dist/ext/exec/index.d.ts +3 -3
  10. package/dist/ext/exec/index.js +15 -9
  11. package/dist/ext/fetch/index.d.ts +3 -3
  12. package/dist/ext/fetch/index.js +17 -12
  13. package/dist/ext/fetch/request.js +1 -1
  14. package/dist/ext/fs/index.d.ts +3 -3
  15. package/dist/ext/fs/index.js +256 -266
  16. package/dist/ext/fs/sandbox.d.ts +18 -0
  17. package/dist/ext/fs/sandbox.js +33 -0
  18. package/dist/ext/kv/index.d.ts +3 -3
  19. package/dist/ext/kv/index.js +198 -196
  20. package/dist/ext/kv/store.d.ts +1 -1
  21. package/dist/ext/kv/store.js +2 -1
  22. package/dist/ext-parse-bridge.d.ts +10 -0
  23. package/dist/ext-parse-bridge.js +10 -0
  24. package/dist/generated/introspection-data.d.ts +1 -1
  25. package/dist/generated/introspection-data.js +385 -296
  26. package/dist/generated/version-data.d.ts +1 -1
  27. package/dist/generated/version-data.js +2 -2
  28. package/dist/highlight-map.js +1 -0
  29. package/dist/index.d.ts +1 -4
  30. package/dist/index.js +1 -5
  31. package/dist/lexer/operators.js +1 -0
  32. package/dist/parser/helpers.js +1 -0
  33. package/dist/parser/parser-expr.js +44 -5
  34. package/dist/parser/parser-literals.js +111 -4
  35. package/dist/parser/parser-shape.js +2 -2
  36. package/dist/parser/parser-types.js +12 -0
  37. package/dist/parser/parser-use.js +26 -3
  38. package/dist/parser/parser.d.ts +2 -0
  39. package/dist/parser/parser.js +2 -0
  40. package/dist/runtime/core/callable.d.ts +24 -13
  41. package/dist/runtime/core/callable.js +71 -38
  42. package/dist/runtime/core/context.d.ts +2 -13
  43. package/dist/runtime/core/context.js +80 -79
  44. package/dist/runtime/core/eval/base.d.ts +2 -2
  45. package/dist/runtime/core/eval/base.js +2 -0
  46. package/dist/runtime/core/eval/evaluator.d.ts +1 -1
  47. package/dist/runtime/core/eval/index.d.ts +3 -3
  48. package/dist/runtime/core/eval/index.js +11 -0
  49. package/dist/runtime/core/eval/mixins/closures.js +381 -41
  50. package/dist/runtime/core/eval/mixins/collections.js +81 -6
  51. package/dist/runtime/core/eval/mixins/control-flow.js +1 -1
  52. package/dist/runtime/core/eval/mixins/conversion.js +61 -115
  53. package/dist/runtime/core/eval/mixins/core.js +17 -4
  54. package/dist/runtime/core/eval/mixins/expressions.js +36 -27
  55. package/dist/runtime/core/eval/mixins/extraction.js +2 -3
  56. package/dist/runtime/core/eval/mixins/list-dispatch.js +1 -1
  57. package/dist/runtime/core/eval/mixins/literals.js +17 -6
  58. package/dist/runtime/core/eval/mixins/types.js +73 -54
  59. package/dist/runtime/core/eval/mixins/variables.js +12 -8
  60. package/dist/runtime/core/execute.d.ts +1 -1
  61. package/dist/runtime/core/field-descriptor.d.ts +3 -3
  62. package/dist/runtime/core/field-descriptor.js +2 -1
  63. package/dist/runtime/core/introspection.d.ts +2 -2
  64. package/dist/runtime/core/introspection.js +7 -6
  65. package/dist/runtime/core/resolvers.d.ts +1 -1
  66. package/dist/runtime/core/signals.d.ts +6 -1
  67. package/dist/runtime/core/signals.js +9 -0
  68. package/dist/runtime/core/types/constructors.d.ts +54 -0
  69. package/dist/runtime/core/types/constructors.js +201 -0
  70. package/dist/runtime/core/types/guards.d.ts +42 -0
  71. package/dist/runtime/core/types/guards.js +88 -0
  72. package/dist/runtime/core/types/index.d.ts +18 -0
  73. package/dist/runtime/core/types/index.js +19 -0
  74. package/dist/runtime/core/types/markers.d.ts +12 -0
  75. package/dist/runtime/core/types/markers.js +7 -0
  76. package/dist/runtime/core/types/operations.d.ts +98 -0
  77. package/dist/runtime/core/types/operations.js +804 -0
  78. package/dist/runtime/core/types/registrations.d.ts +126 -0
  79. package/dist/runtime/core/types/registrations.js +751 -0
  80. package/dist/runtime/core/{types.d.ts → types/runtime.d.ts} +22 -10
  81. package/dist/runtime/core/types/structures.d.ts +146 -0
  82. package/dist/runtime/core/types/structures.js +12 -0
  83. package/dist/runtime/core/values.d.ts +29 -209
  84. package/dist/runtime/core/values.js +56 -968
  85. package/dist/runtime/ext/builtins.js +88 -68
  86. package/dist/runtime/ext/extensions.d.ts +31 -125
  87. package/dist/runtime/ext/extensions.js +2 -94
  88. package/dist/runtime/ext/test-context.d.ts +28 -0
  89. package/dist/runtime/ext/test-context.js +155 -0
  90. package/dist/runtime/index.d.ts +12 -12
  91. package/dist/runtime/index.js +13 -5
  92. package/dist/signature-parser.d.ts +2 -2
  93. package/dist/signature-parser.js +14 -14
  94. package/dist/token-types.d.ts +1 -0
  95. package/dist/token-types.js +1 -0
  96. package/package.json +1 -1
  97. /package/dist/runtime/core/{types.js → types/runtime.js} +0 -0
@@ -4,10 +4,10 @@
4
4
  * Public types for runtime configuration and execution results.
5
5
  * These types are the primary interface for host applications.
6
6
  */
7
- import type { RillTypeName } from '../../types.js';
8
- import type { CallableFn, RillFunction } from './callable.js';
9
- import type { RillType, RillValue } from './values.js';
10
- export type { NativeArray, NativePlainObject, NativeValue } from './values.js';
7
+ import type { RillTypeName } from '../../../types.js';
8
+ import type { CallableFn, RillFunction } from '../callable.js';
9
+ import type { TypeStructure, RillValue } from './structures.js';
10
+ export type { NativeArray, NativePlainObject, NativeValue } from '../values.js';
11
11
  /** I/O callbacks for runtime operations */
12
12
  export interface RuntimeCallbacks {
13
13
  /** Called when .log is invoked */
@@ -119,9 +119,9 @@ 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
- readonly functions: Map<string, CallableFn | import('./callable.js').ApplicationCallable>;
124
+ readonly functions: Map<string, CallableFn | import('../callable.js').ApplicationCallable>;
125
125
  /** I/O callbacks */
126
126
  readonly callbacks: RuntimeCallbacks;
127
127
  /** Observability callbacks */
@@ -152,15 +152,27 @@ export interface RuntimeContext {
152
152
  * Call stack for error context.
153
153
  * Managed by evaluator; pushed on function entry, popped on exit.
154
154
  */
155
- readonly callStack: import('../../types.js').CallFrame[];
155
+ readonly callStack: import('../../../types.js').CallFrame[];
156
156
  /** Arbitrary string metadata passed from the host (e.g. request IDs, user IDs) */
157
157
  readonly metadata?: Record<string, string> | undefined;
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) */
@@ -172,7 +184,7 @@ export interface RuntimeContext {
172
184
  * Must be provided when `kind: 'source'` resolver results are expected.
173
185
  * Omit if only `kind: 'value'` resolvers are used.
174
186
  */
175
- readonly parseSource?: ((text: string) => import('../../types.js').ScriptNode) | undefined;
187
+ readonly parseSource?: ((text: string) => import('../../../types.js').ScriptNode) | undefined;
176
188
  /** Identifies the current source file for cross-module error reporting */
177
189
  readonly sourceId?: string | undefined;
178
190
  /** Source text of the current file for cross-module error snippets */
@@ -212,7 +224,7 @@ export interface RuntimeOptions {
212
224
  * Parser function for executing resolver source results.
213
225
  * Required when resolvers may return `kind: 'source'` results.
214
226
  */
215
- parseSource?: (text: string) => import('../../types.js').ScriptNode;
227
+ parseSource?: (text: string) => import('../../../types.js').ScriptNode;
216
228
  }
217
229
  /** Result of script execution */
218
230
  export interface ExecutionResult {
@@ -0,0 +1,146 @@
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 13 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: 'stream';
71
+ chunk?: TypeStructure;
72
+ ret?: TypeStructure;
73
+ } | {
74
+ kind: string;
75
+ data?: unknown;
76
+ };
77
+ /**
78
+ * Tuple type - represents positional unpacked arguments for closure invocation.
79
+ * Created by the * (spread) operator from lists.
80
+ * Entries are positional only.
81
+ *
82
+ * Note: In Rill, "tuple" refers to fixed-size argument packing (like function signatures),
83
+ * while "list" refers to dynamic ordered collections ([1, 2, 3]).
84
+ */
85
+ export interface RillTuple {
86
+ readonly __rill_tuple: true;
87
+ readonly entries: RillValue[];
88
+ }
89
+ /**
90
+ * Ordered type - represents named key-value pairs with preserved insertion order.
91
+ * Created by the * (spread) operator from dicts.
92
+ * Entries may carry an optional third element (default value) when representing
93
+ * closure parameter reflection via `.^input`.
94
+ */
95
+ export interface RillOrdered {
96
+ readonly __rill_ordered: true;
97
+ readonly entries: [string, RillValue, RillValue?][];
98
+ }
99
+ /**
100
+ * Vector type - represents dense numeric embeddings.
101
+ * Immutable Float32Array with associated model name.
102
+ */
103
+ export interface RillVector {
104
+ readonly __rill_vector: true;
105
+ readonly data: Float32Array;
106
+ readonly model: string;
107
+ }
108
+ /**
109
+ * Type value - represents a first-class type name at runtime.
110
+ * Created when a type name expression (e.g. `string`, `number`) is evaluated.
111
+ */
112
+ export interface RillTypeValue {
113
+ readonly __rill_type: true;
114
+ readonly typeName: RillTypeName;
115
+ readonly structure: TypeStructure;
116
+ }
117
+ /**
118
+ * Iterator type - represents a lazy sequence.
119
+ * An iterator is a dict with:
120
+ * - done: boolean - whether iteration is complete
121
+ * - next: callable - function to get next iterator
122
+ * - value?: any - current value (absent when done)
123
+ */
124
+ export interface RillIterator extends Record<string, RillValue> {
125
+ readonly done: boolean;
126
+ readonly next: CallableMarker;
127
+ readonly value?: RillValue;
128
+ }
129
+ /**
130
+ * Stream type - represents an async lazy sequence with resolution.
131
+ * A stream is a dict with:
132
+ * - __rill_stream: true - discriminator for stream detection
133
+ * - done: boolean - whether all chunks have been consumed
134
+ * - next: callable - function to advance to the next stream step
135
+ * - value?: any - current chunk value (present when done is false)
136
+ */
137
+ export interface RillStream extends Record<string, RillValue> {
138
+ readonly __rill_stream: true;
139
+ readonly done: boolean;
140
+ readonly next: CallableMarker;
141
+ readonly value?: RillValue;
142
+ }
143
+ /** Any value that can flow through Rill */
144
+ export type RillValue = string | number | boolean | null | RillValue[] | {
145
+ [key: string]: RillValue;
146
+ } | CallableMarker | RillTuple | RillOrdered | RillVector | FieldDescriptorMarker | RillTypeValue | RillStream;
@@ -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 {};
@@ -3,166 +3,27 @@
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
- * Entries may carry an optional third element (default value) when representing
30
- * closure parameter reflection via `.^input`.
31
- */
32
- export interface RillOrdered {
33
- readonly __rill_ordered: true;
34
- readonly entries: [string, RillValue, RillValue?][];
35
- }
36
- /**
37
- * Vector type - represents dense numeric embeddings.
38
- * Immutable Float32Array with associated model name.
39
- */
40
- export interface RillVector {
41
- readonly __rill_vector: true;
42
- readonly data: Float32Array;
43
- readonly model: string;
44
- }
45
- /**
46
- * Field definition - describes a single field in a structural type.
47
- * Used by dict, tuple, ordered, and closure type descriptors.
48
- * Default detection: `field.defaultValue !== undefined`.
49
- */
50
- export interface RillFieldDef {
51
- name?: string;
52
- type: RillType;
53
- defaultValue?: RillValue;
54
- }
55
- /**
56
- * Structural type descriptor - describes the shape of a value in the type system.
57
- * Used by RillTypeValue to carry type structure information at runtime.
58
- */
59
- export type RillType = {
60
- type: 'number';
61
- } | {
62
- type: 'string';
63
- } | {
64
- type: 'bool';
65
- } | {
66
- type: 'vector';
67
- } | {
68
- type: 'type';
69
- } | {
70
- type: 'any';
71
- } | {
72
- type: 'dict';
73
- fields?: Record<string, RillFieldDef>;
74
- valueType?: RillType;
75
- } | {
76
- type: 'list';
77
- element?: RillType;
78
- } | {
79
- type: 'closure';
80
- params?: RillFieldDef[];
81
- ret?: RillType;
82
- } | {
83
- type: 'tuple';
84
- elements?: RillFieldDef[];
85
- valueType?: RillType;
86
- } | {
87
- type: 'ordered';
88
- fields?: RillFieldDef[];
89
- valueType?: RillType;
90
- } | {
91
- type: 'union';
92
- members: RillType[];
93
- };
94
- /**
95
- * @deprecated Use RillType instead. Will be removed in the next major version.
96
- */
97
- export type RillStructuralType = RillType;
98
- /**
99
- * Type value - represents a first-class type name at runtime.
100
- * Created when a type name expression (e.g. `string`, `number`) is evaluated.
101
- */
102
- export interface RillTypeValue {
103
- readonly __rill_type: true;
104
- readonly typeName: RillTypeName;
105
- readonly structure: RillType;
106
- }
107
- /** Any value that can flow through Rill */
108
- export type RillValue = string | number | boolean | null | RillValue[] | {
109
- [key: string]: RillValue;
110
- } | CallableMarker | RillTuple | RillOrdered | RillVector | FieldDescriptorMarker | RillTypeValue;
111
- /** Type guard for RillTuple (spread args) */
112
- export declare function isTuple(value: RillValue): value is RillTuple;
113
- /** Type guard for RillVector */
114
- export declare function isVector(value: RillValue): value is RillVector;
115
- /** Type guard for RillOrdered (named spread args) */
116
- export declare function isOrdered(value: RillValue): value is RillOrdered;
117
- /** Type guard for RillTypeValue */
118
- export declare function isTypeValue(value: RillValue): value is RillTypeValue;
119
- /**
120
- * Create ordered from entries array (named, preserves insertion order).
121
- * Entries may be 2-element [name, value] or 3-element [name, value, default]
122
- * tuples; the third element carries a default value for `.^input` reflection.
123
- */
124
- export declare function createOrdered(entries: [string, RillValue, RillValue?][]): RillOrdered;
125
- /** Create tuple from entries array (positional, preserves order) */
126
- export declare function createTuple(entries: RillValue[]): RillTuple;
127
- /**
128
- * Create vector from Float32Array with model name.
129
- * @throws {Error} if data.length is 0 (zero-dimension vectors not allowed)
130
- */
131
- export declare function createVector(data: Float32Array, model: string): RillVector;
132
- /** Infer the Rill type from a runtime value */
133
- export declare function inferType(value: RillValue): RillTypeName;
134
- /**
135
- * Infer the element type for a homogeneous list.
136
- * Empty arrays return { type: 'any' }.
137
- * Mixed types throw RILL-R002.
138
- */
139
- export declare function inferElementType(elements: RillValue[]): RillType;
140
- /**
141
- * Return the most specific shared type for two RillType values.
142
- * Returns null when types are incompatible at the top level.
7
+ * Structural operations (structureEquals, structureMatches, formatStructure,
8
+ * inferStructure, commonType) live in types/operations.ts and are re-exported.
143
9
  *
144
- * Cascade priority:
145
- * 1. Any-narrowing: if either side is `any`, return the other
146
- * 2. Structural match: delegate to structuralTypeEquals; on true, return a
147
- * 3. Recursive list: merge inner element types
148
- * 3b. Uniform valueType: merge dict/tuple/ordered value types
149
- * 4. Bare type fallback: same compound type but structural mismatch
150
- * 5. Incompatible: different top-level types return null
151
- */
152
- export declare function commonType(a: RillType, b: RillType): RillType | null;
153
- /** Compare two structural types for equality. */
154
- export declare function structuralTypeEquals(a: RillType, b: RillType): boolean;
155
- /** Infer the structural type descriptor for any Rill value. */
156
- export declare function inferStructuralType(value: RillValue): RillType;
157
- /**
158
- * Check if a value matches a structural type descriptor.
159
- * Used for runtime type checking (`:?` operator).
10
+ * Dispatch functions (inferType, formatValue, deepEquals, serializeValue,
11
+ * copyValue) re-export from type-registrations.ts protocol implementations.
160
12
  */
161
- export declare function structuralTypeMatches(value: RillValue, type: RillType): boolean;
162
- /** Build a closure param field definition from name, type, and optional default. */
163
- export declare function paramToFieldDef(name: string, type: RillType, defaultValue: RillValue | undefined): RillFieldDef;
164
- /** Format a structural type descriptor as a human-readable string. */
165
- export declare function formatStructuralType(type: RillType): string;
13
+ import type { RillTypeName } from '../../types.js';
14
+ import type { RillCallable } from './callable.js';
15
+ import { isDict, isIterator, isOrdered, isStream, isTuple, isTypeValue, isVector } from './types/guards.js';
16
+ /** isCallable guard widened to narrow to full RillCallable (not just CallableMarker) */
17
+ declare const isCallable: (value: RillValue) => value is RillCallable;
18
+ import type { RillFieldDef, RillIterator, RillOrdered, RillTuple, RillTypeValue, RillValue, RillVector, TypeStructure } from './types/structures.js';
19
+ export type { RillFieldDef, RillIterator, RillOrdered, RillTuple, RillTypeValue, RillValue, RillVector, TypeStructure, };
20
+ export type { DictStructure, TupleStructure, OrderedStructure, } from './types/operations.js';
21
+ export { isCallable, isDict, isIterator, isOrdered, isStream, isTuple, isTypeValue, isVector, };
22
+ export { copyValue, createOrdered, createTuple, createVector, emptyForType, } from './types/constructors.js';
23
+ export { commonType, compareStructuredFields, formatStructure, inferElementType, inferStructure, paramToFieldDef, structureEquals, structureMatches, } from './types/operations.js';
24
+ export type { FieldComparisonCallbacks } from './types/operations.js';
25
+ /** Infer the Rill type from a runtime value. Delegates to type-registrations. */
26
+ export declare const inferType: (value: RillValue) => string;
166
27
  /**
167
28
  * Check if a value is of the expected type.
168
29
  * Returns true if the value matches the expected type, false otherwise.
@@ -172,8 +33,8 @@ export declare function checkType(value: RillValue, expected: RillTypeName): boo
172
33
  export declare function isTruthy(value: RillValue): boolean;
173
34
  /** Check if a value is empty (inverse of truthy) */
174
35
  export declare function isEmpty(value: RillValue): boolean;
175
- /** Format a value for display */
176
- export declare function formatValue(value: RillValue): string;
36
+ /** Format a value for display. Delegates to type-registrations. */
37
+ export declare const formatValue: (value: RillValue) => string;
177
38
  /**
178
39
  * Recursive native (host-side) value type.
179
40
  * Represents values that can cross the host/script boundary.
@@ -187,31 +48,23 @@ export type NativePlainObject = {
187
48
  };
188
49
  /** Structured result from toNative conversion */
189
50
  export interface NativeResult {
190
- /** Rill type name matches RillTypeName, or 'iterator' for lazy sequences */
51
+ /** Rill type name -- matches RillTypeName, or 'iterator' for lazy sequences */
191
52
  rillTypeName: string;
192
53
  /** Human-readable type signature, e.g. "string", "list(number)", "|x: number| :string" */
193
54
  rillTypeSignature: string;
194
55
  /** Native JS representation. Non-native types produce descriptor objects. */
195
56
  value: NativeValue;
196
57
  }
197
- /**
198
- * Convert a RillValue to a JSON-serializable value.
199
- * @throws {Error} plain Error (not RuntimeError) for non-serializable types
200
- */
201
- export declare function valueToJSON(value: RillValue): unknown;
58
+ /** Serialize a Rill value for JSON transport. Delegates to type-registrations. */
59
+ export declare const serializeValue: (value: RillValue) => unknown;
202
60
  /**
203
61
  * Convert a RillValue to a NativeResult for host consumption.
204
62
  * Non-representable types (closures, vectors, type values, iterators) produce descriptor objects.
205
63
  * Tuples convert to native arrays. Ordered values convert to plain objects.
206
64
  */
207
65
  export declare function toNative(value: RillValue): NativeResult;
208
- /**
209
- * Deep structural equality for all Rill values.
210
- * - Primitives: value equality
211
- * - Tuples: length + recursive element equality
212
- * - Dicts: same keys + recursive value equality (order-independent)
213
- */
214
- export declare function deepEquals(a: RillValue, b: RillValue): boolean;
66
+ /** Deep structural equality for all Rill values. Delegates to type-registrations. */
67
+ export declare const deepEquals: (a: RillValue, b: RillValue) => boolean;
215
68
  /** Reserved dict method names that cannot be overridden */
216
69
  export declare const RESERVED_DICT_METHODS: readonly ["keys", "values", "entries"];
217
70
  /**
@@ -220,49 +73,16 @@ export declare const RESERVED_DICT_METHODS: readonly ["keys", "values", "entries
220
73
  */
221
74
  export declare const anyTypeValue: RillTypeValue;
222
75
  /**
223
- * Convert a RillType structural descriptor to a RillTypeValue.
224
- * Uses the RillType's `type` field as the `typeName`.
76
+ * Convert a TypeStructure descriptor to a RillTypeValue.
77
+ * Uses the TypeStructure's `kind` field as the `typeName`.
225
78
  * Falls back to 'any' for compound types that lack a direct RillTypeName mapping.
226
79
  */
227
- export declare function rillTypeToTypeValue(type: RillType): RillTypeValue;
80
+ export declare function structureToTypeValue(type: TypeStructure): RillTypeValue;
228
81
  /**
229
82
  * Check if a type is a collection (dict, ordered, tuple) with defined
230
83
  * fields or elements. Used to decide if an empty collection can be
231
84
  * synthesized and hydrated.
232
85
  */
233
- export declare function hasCollectionFields(type: RillType): boolean;
234
- /**
235
- * Create an empty collection value matching the given RillType.
236
- * Assumes the type is dict, ordered, or tuple.
237
- */
238
- export declare function emptyForType(type: RillType): RillValue;
86
+ export declare function hasCollectionFields(type: TypeStructure): boolean;
239
87
  /** Check if a key name is reserved */
240
88
  export declare function isReservedMethod(name: string): boolean;
241
- /**
242
- * Iterator type - represents a lazy sequence.
243
- * An iterator is a dict with:
244
- * - done: boolean - whether iteration is complete
245
- * - next: callable - function to get next iterator
246
- * - value: any (only required when not done) - current element
247
- */
248
- export interface RillIterator extends Record<string, RillValue> {
249
- readonly done: boolean;
250
- readonly next: CallableMarker;
251
- readonly value?: RillValue;
252
- }
253
- /**
254
- * Type guard for Rill iterator (lazy sequence).
255
- * An iterator is a dict with:
256
- * - done: boolean - whether iteration is complete
257
- * - next: callable - function to get next iterator
258
- * - value: any (only required when not done) - current element
259
- */
260
- export declare function isRillIterator(value: RillValue): value is RillIterator;
261
- /**
262
- * Deep copy a RillValue, producing a new independent value.
263
- * Handles primitives, arrays, plain dicts, and null.
264
- * Special markers (closures, tuples, ordered, vectors, type values) are returned
265
- * as-is since they are immutable by contract.
266
- */
267
- export declare function deepCopyRillValue(value: RillValue): RillValue;
268
- export {};