@rcrsr/rill 0.17.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 (83) hide show
  1. package/dist/ast-nodes.d.ts +14 -4
  2. package/dist/ast-unions.d.ts +1 -1
  3. package/dist/constants.d.ts +1 -1
  4. package/dist/constants.js +1 -0
  5. package/dist/error-registry.js +228 -0
  6. package/dist/ext/crypto/index.js +5 -5
  7. package/dist/ext/exec/index.js +3 -3
  8. package/dist/ext/fetch/index.js +4 -4
  9. package/dist/ext/fetch/request.js +1 -1
  10. package/dist/ext/fs/index.js +101 -114
  11. package/dist/ext/fs/sandbox.d.ts +18 -0
  12. package/dist/ext/fs/sandbox.js +33 -0
  13. package/dist/ext/kv/index.js +12 -12
  14. package/dist/ext/kv/store.d.ts +1 -1
  15. package/dist/ext/kv/store.js +1 -1
  16. package/dist/generated/version-data.d.ts +1 -1
  17. package/dist/generated/version-data.js +2 -2
  18. package/dist/highlight-map.js +1 -0
  19. package/dist/index.d.ts +1 -15
  20. package/dist/index.js +1 -14
  21. package/dist/lexer/operators.js +1 -0
  22. package/dist/parser/helpers.js +1 -0
  23. package/dist/parser/parser-expr.js +44 -5
  24. package/dist/parser/parser-literals.js +111 -4
  25. package/dist/parser/parser-shape.js +2 -2
  26. package/dist/parser/parser-use.js +19 -2
  27. package/dist/parser/parser.d.ts +2 -0
  28. package/dist/parser/parser.js +2 -0
  29. package/dist/runtime/core/callable.d.ts +5 -6
  30. package/dist/runtime/core/callable.js +10 -17
  31. package/dist/runtime/core/context.d.ts +2 -2
  32. package/dist/runtime/core/context.js +8 -8
  33. package/dist/runtime/core/eval/base.d.ts +2 -2
  34. package/dist/runtime/core/eval/base.js +2 -0
  35. package/dist/runtime/core/eval/evaluator.d.ts +1 -1
  36. package/dist/runtime/core/eval/index.d.ts +2 -2
  37. package/dist/runtime/core/eval/mixins/closures.js +367 -27
  38. package/dist/runtime/core/eval/mixins/collections.js +81 -6
  39. package/dist/runtime/core/eval/mixins/control-flow.js +1 -1
  40. package/dist/runtime/core/eval/mixins/conversion.js +17 -12
  41. package/dist/runtime/core/eval/mixins/core.js +15 -2
  42. package/dist/runtime/core/eval/mixins/expressions.js +3 -2
  43. package/dist/runtime/core/eval/mixins/extraction.js +2 -3
  44. package/dist/runtime/core/eval/mixins/list-dispatch.js +1 -1
  45. package/dist/runtime/core/eval/mixins/literals.js +14 -3
  46. package/dist/runtime/core/eval/mixins/types.js +30 -1
  47. package/dist/runtime/core/eval/mixins/variables.js +3 -1
  48. package/dist/runtime/core/execute.d.ts +1 -1
  49. package/dist/runtime/core/field-descriptor.d.ts +1 -1
  50. package/dist/runtime/core/introspection.d.ts +2 -2
  51. package/dist/runtime/core/introspection.js +2 -1
  52. package/dist/runtime/core/resolvers.d.ts +1 -1
  53. package/dist/runtime/core/signals.d.ts +6 -1
  54. package/dist/runtime/core/signals.js +9 -0
  55. package/dist/runtime/core/types/constructors.d.ts +54 -0
  56. package/dist/runtime/core/types/constructors.js +201 -0
  57. package/dist/runtime/core/types/guards.d.ts +42 -0
  58. package/dist/runtime/core/types/guards.js +88 -0
  59. package/dist/runtime/core/types/index.d.ts +18 -0
  60. package/dist/runtime/core/types/index.js +19 -0
  61. package/dist/runtime/core/types/operations.d.ts +98 -0
  62. package/dist/runtime/core/types/operations.js +804 -0
  63. package/dist/runtime/core/{type-registrations.d.ts → types/registrations.d.ts} +12 -22
  64. package/dist/runtime/core/{type-registrations.js → types/registrations.js} +94 -92
  65. package/dist/runtime/core/{types.d.ts → types/runtime.d.ts} +8 -8
  66. package/dist/runtime/core/{type-structures.d.ts → types/structures.d.ts} +21 -3
  67. package/dist/runtime/core/values.d.ts +13 -102
  68. package/dist/runtime/core/values.js +26 -722
  69. package/dist/runtime/ext/builtins.js +9 -8
  70. package/dist/runtime/ext/extensions.d.ts +2 -2
  71. package/dist/runtime/ext/extensions.js +2 -1
  72. package/dist/runtime/ext/test-context.d.ts +2 -2
  73. package/dist/runtime/ext/test-context.js +3 -2
  74. package/dist/runtime/index.d.ts +8 -22
  75. package/dist/runtime/index.js +10 -16
  76. package/dist/signature-parser.d.ts +1 -1
  77. package/dist/token-types.d.ts +1 -0
  78. package/dist/token-types.js +1 -0
  79. package/package.json +1 -1
  80. /package/dist/runtime/core/{markers.d.ts → types/markers.d.ts} +0 -0
  81. /package/dist/runtime/core/{markers.js → types/markers.js} +0 -0
  82. /package/dist/runtime/core/{types.js → types/runtime.js} +0 -0
  83. /package/dist/runtime/core/{type-structures.js → types/structures.js} +0 -0
@@ -9,9 +9,11 @@
9
9
  import { callable, isCallable, isDict } from '../core/callable.js';
10
10
  import { RuntimeError } from '../../types.js';
11
11
  import { parseSignatureRegistration } from '../../signature-parser.js';
12
- import { anyTypeValue, deepEquals, formatValue, inferType, isEmpty, isRillIterator, isVector, rillTypeToTypeValue, serializeValue, } from '../core/values.js';
12
+ import { deepEquals, formatValue, inferType, serializeValue, } from '../core/types/registrations.js';
13
+ import { isIterator, isVector } from '../core/types/guards.js';
14
+ import { anyTypeValue, isEmpty, structureToTypeValue } from '../core/values.js';
13
15
  import { invokeCallable } from '../core/eval/index.js';
14
- import { populateBuiltinMethods } from '../core/type-registrations.js';
16
+ import { populateBuiltinMethods } from '../core/types/registrations.js';
15
17
  // ============================================================
16
18
  // ITERATOR HELPERS
17
19
  // ============================================================
@@ -109,7 +111,7 @@ export const BUILTIN_FUNCTIONS = {
109
111
  annotations: {},
110
112
  },
111
113
  ],
112
- returnType: rillTypeToTypeValue({ kind: 'string' }),
114
+ returnType: structureToTypeValue({ kind: 'string' }),
113
115
  fn: (args, _ctx, location) => {
114
116
  const value = args['value'] ?? null;
115
117
  try {
@@ -117,8 +119,7 @@ export const BUILTIN_FUNCTIONS = {
117
119
  return JSON.stringify(jsonValue);
118
120
  }
119
121
  catch (err) {
120
- if (err instanceof RuntimeError)
121
- throw err;
122
+ // Wrap serialization errors (RILL-R067 from protocol) as RILL-R004
122
123
  if (err instanceof Error) {
123
124
  throw new RuntimeError('RILL-R004', err.message, location);
124
125
  }
@@ -143,7 +144,7 @@ export const BUILTIN_FUNCTIONS = {
143
144
  annotations: {},
144
145
  },
145
146
  ],
146
- returnType: rillTypeToTypeValue({ kind: 'list' }),
147
+ returnType: structureToTypeValue({ kind: 'list' }),
147
148
  fn: (args) => {
148
149
  const input = args['items'] ?? null;
149
150
  if (Array.isArray(input)) {
@@ -350,7 +351,7 @@ function buildMethodEntry(name, signature, method, skipReceiverValidation) {
350
351
  ? { description: parsed.description }
351
352
  : {},
352
353
  returnType: parsed.returnType !== undefined
353
- ? rillTypeToTypeValue(parsed.returnType)
354
+ ? structureToTypeValue(parsed.returnType)
354
355
  : anyTypeValue,
355
356
  ...(skipReceiverValidation ? { skipReceiverValidation: true } : {}),
356
357
  };
@@ -415,7 +416,7 @@ const mTail = (receiver, _args, _ctx, location) => {
415
416
  };
416
417
  /** Get iterator at first position for any collection */
417
418
  const mFirst = (receiver, _args, _ctx, location) => {
418
- if (isRillIterator(receiver))
419
+ if (isIterator(receiver))
419
420
  return receiver;
420
421
  if (Array.isArray(receiver))
421
422
  return makeListIterator(receiver, 0);
@@ -1,6 +1,6 @@
1
1
  import type { ApplicationCallable } from '../core/callable.js';
2
- import type { ExtensionEvent, RuntimeCallbacks } from '../core/types.js';
3
- import type { RillValue } from '../core/values.js';
2
+ import type { ExtensionEvent, RuntimeCallbacks } from '../core/types/runtime.js';
3
+ import type { RillValue } from '../core/types/structures.js';
4
4
  /**
5
5
  * Minimal interface for extension event emission.
6
6
  * Allows emitExtensionEvent to accept any context with callbacks.
@@ -1,3 +1,4 @@
1
+ import { RuntimeError } from '../../types.js';
1
2
  /**
2
3
  * Emit an extension event with auto-generated timestamp.
3
4
  * Adds ISO timestamp if event.timestamp is undefined, then calls onLogEvent callback.
@@ -26,7 +27,7 @@ export function emitExtensionEvent(ctx, event) {
26
27
  if (!event['event'] ||
27
28
  typeof event['event'] !== 'string' ||
28
29
  event['event'].trim() === '') {
29
- throw new Error('Event must include non-empty event field');
30
+ throw new RuntimeError('RILL-R075', 'Event must include non-empty event field');
30
31
  }
31
32
  // IC-2: Guard for callbacks property (graceful degradation)
32
33
  if ('callbacks' in ctx && ctx.callbacks) {
@@ -4,8 +4,8 @@
4
4
  * Creates a pre-wired RuntimeContext from extension value maps.
5
5
  * Designed for testing and lightweight embedding without rill-config.
6
6
  */
7
- import type { RuntimeContext } from '../core/types.js';
8
- import { type RillValue } from '../core/values.js';
7
+ import type { RuntimeContext } from '../core/types/runtime.js';
8
+ import type { RillValue } from '../core/types/structures.js';
9
9
  /**
10
10
  * Error thrown when extension binding generation fails.
11
11
  * Mirrors the ExtensionBindingError in rill-config for core-only usage.
@@ -8,7 +8,8 @@ import { parseSource } from '../../ext-parse-bridge.js';
8
8
  import { createRuntimeContext } from '../core/context.js';
9
9
  import { extResolver } from '../core/resolvers.js';
10
10
  import { isCallable } from '../core/callable.js';
11
- import { formatStructure } from '../core/values.js';
11
+ import { formatStructure } from '../core/types/operations.js';
12
+ import { RuntimeError } from '../../types.js';
12
13
  // ============================================================
13
14
  // ERROR CLASS
14
15
  // ============================================================
@@ -109,7 +110,7 @@ function createExtModuleResolver(bindingSource) {
109
110
  if (resource === 'ext') {
110
111
  return { kind: 'source', text: bindingSource, sourceId: 'module:ext' };
111
112
  }
112
- throw new Error(`Unknown module '${resource}'`);
113
+ throw new RuntimeError('RILL-R076', `Unknown module '${resource}'`);
113
114
  };
114
115
  }
115
116
  // ============================================================
@@ -16,29 +16,14 @@
16
16
  * - ext/: Self-contained extensions
17
17
  * - builtins.ts: Built-in functions and methods
18
18
  */
19
- export type { CaptureEvent, ErrorEvent, ExecutionResult, ExecutionStepper, HostCallEvent, FunctionReturnEvent, ObservabilityCallbacks, ResolverResult, RuntimeCallbacks, RuntimeContext, RuntimeOptions, SchemeResolver, StepEndEvent, StepResult, StepStartEvent, } from './core/types.js';
20
- export type { ApplicationCallable, CallableFn, RillCallable, RillFunction, RillParam, RuntimeCallable, ScriptCallable, } from './core/callable.js';
21
- export { callable, isApplicationCallable, isCallable, isDict, isRuntimeCallable, isScriptCallable, toCallable, } from './core/callable.js';
22
- export type { NativeArray, NativePlainObject, NativeResult, NativeValue, RillFieldDef, RillIterator, RillTuple, RillTypeValue, RillValue, RillVector, TypeStructure, } from './core/values.js';
23
- /** @deprecated Use TypeStructure instead. Will be removed in the next major version. */
24
- export type { RillType } from './core/values.js';
25
- export type { TypeDefinition, TypeProtocol, } from './core/type-registrations.js';
26
- export { anyTypeValue, commonType, createTuple, createVector, formatStructure, inferElementType, inferStructure, inferType, isIterator, isTuple, isTypeValue, isVector, isReservedMethod, paramToFieldDef, structureToTypeValue, RESERVED_DICT_METHODS, structureEquals, structureMatches, toNative, } from './core/values.js';
27
- /** @deprecated Use formatStructure instead. */
28
- export { formatStructuralType } from './core/values.js';
29
- /** @deprecated Use inferStructure instead. */
30
- export { inferStructuralType } from './core/values.js';
31
- /** @deprecated Use isIterator instead. */
32
- export { isRillIterator } from './core/values.js';
33
- /** @deprecated Use structureToTypeValue instead. */
34
- export { rillTypeToTypeValue } from './core/values.js';
35
- /** @deprecated Use structureEquals instead. */
36
- export { structuralTypeEquals } from './core/values.js';
37
- /** @deprecated Use structureMatches instead. */
38
- export { structuralTypeMatches } from './core/values.js';
19
+ export type { CaptureEvent, ErrorEvent, ExecutionResult, ExecutionStepper, ExtensionEvent, FieldComparisonCallbacks, FunctionReturnEvent, HostCallEvent, NativeArray, NativePlainObject, NativeValue, ObservabilityCallbacks, ResolverResult, RillFieldDef, RillIterator, RillStream, RillTuple, RillTypeValue, RillValue, RillVector, RuntimeCallbacks, RuntimeContext, RuntimeOptions, SchemeResolver, StepEndEvent, StepResult, StepStartEvent, TypeDefinition, TypeProtocol, TypeStructure, } from './core/types/index.js';
20
+ export type { ApplicationCallable, CallableFn, MarshalOptions, RillCallable, RillFunction, RillParam, RuntimeCallable, ScriptCallable, } from './core/callable.js';
21
+ export { callable, hydrateFieldDefaults, isApplicationCallable, isCallable, isDict, isRuntimeCallable, isScriptCallable, marshalArgs, toCallable, } from './core/callable.js';
22
+ export type { NativeResult } from './core/values.js';
23
+ export { BUILT_IN_TYPES, commonType, compareStructuredFields, copyValue, createOrdered, createRillStream, createTuple, createVector, deepEquals, deserializeValue, formatRillLiteral, formatStructure, formatValue, inferElementType, inferStructure, inferType, isIterator, isRillStream, isStream, isTuple, isTypeValue, isVector, paramToFieldDef, serializeValue, structureEquals, structureMatches, } from './core/types/index.js';
24
+ export { anyTypeValue, isEmpty, isReservedMethod, isTruthy, RESERVED_DICT_METHODS, structureToTypeValue, toNative, } from './core/values.js';
39
25
  export { buildFieldDescriptor } from './core/field-descriptor.js';
40
- export { BreakSignal, ReturnSignal } from './core/signals.js';
41
- export type { ExtensionEvent } from './core/types.js';
26
+ export { BreakSignal, ReturnSignal, YieldSignal } from './core/signals.js';
42
27
  export type { ConfigFieldDescriptor, ExtensionConfigSchema, ExtensionFactory, ExtensionFactoryResult, ExtensionManifest, FsExtensionContract, KvExtensionContract, } from './ext/extensions.js';
43
28
  export type { SchemaEntry } from '../ext/kv/index.js';
44
29
  export { emitExtensionEvent } from './ext/extensions.js';
@@ -49,6 +34,7 @@ export type { CallFrame } from '../types.js';
49
34
  export { getCallStack, pushCallFrame, popCallFrame } from './core/context.js';
50
35
  export { createStepper, execute } from './core/execute.js';
51
36
  export { invokeCallable } from './core/eval/index.js';
37
+ export { BUILTIN_METHODS } from './ext/builtins.js';
52
38
  export type { DocumentationCoverageResult, FunctionMetadata, ParamMetadata, } from './core/introspection.js';
53
39
  export { generateManifest, getDocumentationCoverage, getFunctions, getLanguageReference, } from './core/introspection.js';
54
40
  export type { VersionInfo } from '../generated/version-data.js';
@@ -16,26 +16,16 @@
16
16
  * - ext/: Self-contained extensions
17
17
  * - builtins.ts: Built-in functions and methods
18
18
  */
19
- export { callable, isApplicationCallable, isCallable, isDict, isRuntimeCallable, isScriptCallable, toCallable, } from './core/callable.js';
20
- export { anyTypeValue, commonType, createTuple, createVector, formatStructure, inferElementType, inferStructure, inferType, isIterator, isTuple, isTypeValue, isVector, isReservedMethod, paramToFieldDef, structureToTypeValue, RESERVED_DICT_METHODS, structureEquals, structureMatches, toNative, } from './core/values.js';
21
- // Deprecated aliases old names kept for one release
22
- /** @deprecated Use formatStructure instead. */
23
- export { formatStructuralType } from './core/values.js';
24
- /** @deprecated Use inferStructure instead. */
25
- export { inferStructuralType } from './core/values.js';
26
- /** @deprecated Use isIterator instead. */
27
- export { isRillIterator } from './core/values.js';
28
- /** @deprecated Use structureToTypeValue instead. */
29
- export { rillTypeToTypeValue } from './core/values.js';
30
- /** @deprecated Use structureEquals instead. */
31
- export { structuralTypeEquals } from './core/values.js';
32
- /** @deprecated Use structureMatches instead. */
33
- export { structuralTypeMatches } from './core/values.js';
19
+ export { callable, hydrateFieldDefaults, isApplicationCallable, isCallable, isDict, isRuntimeCallable, isScriptCallable, marshalArgs, toCallable, } from './core/callable.js';
20
+ // Extracted to types/ sub-modules (via barrel)
21
+ export { BUILT_IN_TYPES, commonType, compareStructuredFields, copyValue, createOrdered, createRillStream, createTuple, createVector, deepEquals, deserializeValue, formatRillLiteral, formatStructure, formatValue, inferElementType, inferStructure, inferType, isIterator, isRillStream, isStream, isTuple, isTypeValue, isVector, paramToFieldDef, serializeValue, structureEquals, structureMatches, } from './core/types/index.js';
22
+ // Remain in values.ts
23
+ export { anyTypeValue, isEmpty, isReservedMethod, isTruthy, RESERVED_DICT_METHODS, structureToTypeValue, toNative, } from './core/values.js';
34
24
  export { buildFieldDescriptor } from './core/field-descriptor.js';
35
25
  // ============================================================
36
26
  // CONTROL FLOW SIGNALS
37
27
  // ============================================================
38
- export { BreakSignal, ReturnSignal } from './core/signals.js';
28
+ export { BreakSignal, ReturnSignal, YieldSignal } from './core/signals.js';
39
29
  export { emitExtensionEvent } from './ext/extensions.js';
40
30
  // ============================================================
41
31
  // BUILT-IN RESOLVERS
@@ -55,5 +45,9 @@ export { createStepper, execute } from './core/execute.js';
55
45
  // CALLABLE INVOCATION
56
46
  // ============================================================
57
47
  export { invokeCallable } from './core/eval/index.js';
48
+ // ============================================================
49
+ // BUILT-IN METHODS
50
+ // ============================================================
51
+ export { BUILTIN_METHODS } from './ext/builtins.js';
58
52
  export { generateManifest, getDocumentationCoverage, getFunctions, getLanguageReference, } from './core/introspection.js';
59
53
  export { VERSION, VERSION_INFO } from '../generated/version-data.js';
@@ -12,7 +12,7 @@
12
12
  * which is NOT in parser/* or lexer/* — boundary preserved.
13
13
  */
14
14
  import type { RillParam } from './runtime/core/callable.js';
15
- import type { TypeStructure } from './runtime/core/values.js';
15
+ import type { TypeStructure } from './runtime/core/types/structures.js';
16
16
  /**
17
17
  * Result of parsing a signature string at registration time.
18
18
  */
@@ -53,6 +53,7 @@ export declare const TOKEN_TYPES: {
53
53
  readonly CONVERT: "CONVERT";
54
54
  readonly BREAK: "BREAK";
55
55
  readonly RETURN: "RETURN";
56
+ readonly YIELD: "YIELD";
56
57
  readonly PASS: "PASS";
57
58
  readonly ASSERT: "ASSERT";
58
59
  readonly ERROR: "ERROR";
@@ -70,6 +70,7 @@ export const TOKEN_TYPES = {
70
70
  // Keywords
71
71
  BREAK: 'BREAK',
72
72
  RETURN: 'RETURN',
73
+ YIELD: 'YIELD',
73
74
  PASS: 'PASS',
74
75
  ASSERT: 'ASSERT',
75
76
  ERROR: 'ERROR',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcrsr/rill",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Scripting designed for machine-generated code",
5
5
  "license": "MIT",
6
6
  "author": "Andre Bremer",