@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
package/README.md CHANGED
@@ -13,24 +13,34 @@ npm install @rcrsr/rill
13
13
  ## Quick Start
14
14
 
15
15
  ```typescript
16
- import { parse, execute, createRuntimeContext } from '@rcrsr/rill';
16
+ import { parse, execute, createRuntimeContext, toCallable } from '@rcrsr/rill';
17
+ import type { ExtensionFactoryResult } from '@rcrsr/rill';
18
+
19
+ function createMyExtension(): ExtensionFactoryResult {
20
+ return {
21
+ value: {
22
+ prompt: toCallable({
23
+ params: [{ name: 'message', type: { kind: 'string' } }],
24
+ fn: async (args) => await callYourLLM(args.message),
25
+ annotations: { description: 'Call your LLM' },
26
+ returnType: { kind: 'string' },
27
+ }),
28
+ },
29
+ };
30
+ }
31
+
32
+ const ext = createMyExtension();
33
+ const ctx = createRuntimeContext({
34
+ variables: { app: ext.value },
35
+ });
17
36
 
18
37
  const script = `
19
- prompt("Analyze this code for issues")
38
+ app.prompt("Analyze this code for issues")
20
39
  -> .contains("ERROR") ? error($) ! "Analysis complete"
21
40
  `;
22
41
 
23
- const ctx = createRuntimeContext({
24
- functions: {
25
- prompt: {
26
- params: [{ name: 'message', type: 'string' }],
27
- fn: async (args) => await callYourLLM(args[0]),
28
- },
29
- },
30
- });
31
-
32
42
  const result = await execute(parse(script), ctx);
33
- console.log(result.value);
43
+ console.log(result.result);
34
44
  ```
35
45
 
36
46
  ## API
@@ -47,25 +57,31 @@ Source Text → parse() → AST → execute() → Result
47
57
  | `execute(ast, ctx)` | Execute an AST with a runtime context |
48
58
  | `createRuntimeContext(opts)` | Create a configured runtime context |
49
59
  | `callable(fn, isProperty?)` | Wrap a function as a rill-callable value |
50
- | `prefixFunctions(prefix, fns)` | Namespace host functions (e.g., `app::`) |
60
+ | `toCallable(def)` | Convert a `RillFunction` to an `ApplicationCallable` |
61
+ | `createTestContext(extensions)` | Wire extensions for testing without config infrastructure |
51
62
 
52
63
  ### Runtime Options
53
64
 
54
65
  ```typescript
66
+ const ext = createMyExtension();
67
+
55
68
  const ctx = createRuntimeContext({
56
- // Host functions available to scripts
69
+ // Extension values injected as variables (recommended)
70
+ variables: {
71
+ app: ext.value,
72
+ config: { greeting: 'hello' },
73
+ },
74
+
75
+ // Legacy: direct function registration (still supported)
57
76
  functions: {
58
77
  prompt: {
59
- params: [{ name: 'text', type: 'string' }],
78
+ params: [{ name: 'text', type: { kind: 'string' } }],
60
79
  fn: async (args, ctx, location) => { /* ... */ },
80
+ annotations: {},
81
+ returnType: { kind: 'string' },
61
82
  },
62
83
  },
63
84
 
64
- // Variables injected into script scope
65
- variables: {
66
- config: { greeting: 'hello' },
67
- },
68
-
69
85
  // Callbacks
70
86
  callbacks: {
71
87
  onLog: (value) => console.log(value),
@@ -159,7 +175,7 @@ import { createCryptoExtension } from '@rcrsr/rill/ext/crypto';
159
175
  | `@rcrsr/rill/ext/kv` | `createKvExtension(config)` | Key-value store with JSON persistence and schema validation |
160
176
  | `@rcrsr/rill/ext/crypto` | `createCryptoExtension(config)` | Cryptographic functions (hash, hmac, uuid, random) |
161
177
 
162
- Each factory returns an `ExtensionResult` with host function definitions ready to integrate into your runtime context.
178
+ Each factory returns an `ExtensionFactoryResult` with a `value` dict of host functions and optional lifecycle hooks (`dispose`, `suspend`, `restore`) ready to integrate into your runtime context.
163
179
 
164
180
  > **Note:** These extensions require Node.js APIs and are not compatible with browser environments.
165
181
 
@@ -1,5 +1,5 @@
1
1
  import type { SourceSpan } from './source-location.js';
2
- import type { RillTypeName, TypeRef } from './value-types.js';
2
+ import type { FieldArg, RillTypeName, TypeRef } from './value-types.js';
3
3
  interface BaseNode {
4
4
  readonly span: SourceSpan;
5
5
  }
@@ -245,18 +245,8 @@ export interface DictEntryNode extends BaseNode {
245
245
  export interface TypeConstructorNode extends BaseNode {
246
246
  readonly type: 'TypeConstructor';
247
247
  readonly constructorName: 'list' | 'dict' | 'tuple' | 'ordered';
248
- readonly args: TypeConstructorArg[];
248
+ readonly args: FieldArg[];
249
249
  }
250
- export type TypeConstructorArg = {
251
- kind: 'positional';
252
- value: ExpressionNode;
253
- defaultValue?: LiteralNode;
254
- } | {
255
- kind: 'named';
256
- name: string;
257
- value: ExpressionNode;
258
- defaultValue?: LiteralNode;
259
- };
260
250
  /**
261
251
  * Closure signature literal: |param: type, ...| :returnType
262
252
  * Represents a closure type signature as a first-class value.
@@ -812,4 +802,3 @@ export interface UseExprNode extends BaseNode {
812
802
  export type SimplePrimaryNode = LiteralNode | VariableNode | HostCallNode | MethodCallNode | BlockNode | BinaryExprNode | UnaryExprNode | GroupedExprNode | PostfixExprNode | TypeAssertionNode | TypeCheckNode;
813
803
  export type ASTNode = ScriptNode | FrontmatterNode | ClosureNode | ClosureParamNode | StatementNode | CaptureNode | BreakNode | ReturnNode | PassNode | AssertNode | PipeChainNode | PostfixExprNode | MethodCallNode | InvokeNode | AnnotationAccessNode | HostCallNode | HostRefNode | ClosureCallNode | PipeInvokeNode | VariableNode | ConditionalNode | WhileLoopNode | DoWhileLoopNode | BlockNode | StringLiteralNode | InterpolationNode | NumberLiteralNode | BoolLiteralNode | ListSpreadNode | DictNode | DictEntryNode | BinaryExprNode | UnaryExprNode | GroupedExprNode | DestructureNode | DestructPatternNode | SliceNode | TypeAssertionNode | TypeCheckNode | TypeConstructorNode | ClosureSigLiteralNode | AnnotatedStatementNode | AnnotatedExprNode | NamedArgNode | SpreadArgNode | EachExprNode | MapExprNode | FoldExprNode | FilterExprNode | RecoveryErrorNode | ErrorNode | TypeNameExprNode | ListLiteralNode | DictLiteralNode | TupleLiteralNode | OrderedLiteralNode | DestructNode | ConvertNode | UseExprNode;
814
804
  export {};
815
- //# sourceMappingURL=ast-nodes.d.ts.map
package/dist/ast-nodes.js CHANGED
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=ast-nodes.js.map
@@ -3,4 +3,3 @@
3
3
  * String union of all AST node type literals.
4
4
  */
5
5
  export type NodeType = 'Script' | 'Frontmatter' | 'Closure' | 'ClosureParam' | 'Statement' | 'PipeChain' | 'PostfixExpr' | 'MethodCall' | 'Invoke' | 'AnnotationAccess' | 'HostCall' | 'HostRef' | 'ClosureCall' | 'PipeInvoke' | 'Variable' | 'Capture' | 'Conditional' | 'WhileLoop' | 'DoWhileLoop' | 'Block' | 'StringLiteral' | 'Interpolation' | 'NumberLiteral' | 'BoolLiteral' | 'ListSpread' | 'Dict' | 'DictEntry' | 'Break' | 'Return' | 'Pass' | 'Assert' | 'BinaryExpr' | 'UnaryExpr' | 'GroupedExpr' | 'Destructure' | 'DestructPattern' | 'Slice' | 'TypeAssertion' | 'TypeCheck' | 'AnnotatedStatement' | 'AnnotatedExpr' | 'NamedArg' | 'SpreadArg' | 'EachExpr' | 'MapExpr' | 'FoldExpr' | 'FilterExpr' | 'RecoveryError' | 'Error' | 'TypeNameExpr' | 'TypeConstructor' | 'ClosureSigLiteral' | 'ListLiteral' | 'DictLiteral' | 'TupleLiteral' | 'OrderedLiteral' | 'Destruct' | 'Convert' | 'UseExpr';
6
- //# sourceMappingURL=ast-unions.d.ts.map
@@ -3,4 +3,3 @@
3
3
  * String union of all AST node type literals.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=ast-unions.js.map
@@ -11,4 +11,3 @@
11
11
  * - Runtime: Set-based O(1) membership lookup
12
12
  */
13
13
  export declare const VALID_TYPE_NAMES: readonly ["string", "number", "bool", "closure", "list", "dict", "tuple", "ordered", "vector", "any", "type", "iterator"];
14
- //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -27,4 +27,3 @@ export const VALID_TYPE_NAMES = [
27
27
  'type',
28
28
  'iterator',
29
29
  ];
30
- //# sourceMappingURL=constants.js.map
@@ -94,4 +94,3 @@ export declare class AutoExceptionError extends RuntimeError {
94
94
  export declare class AbortError extends RuntimeError {
95
95
  constructor(location?: SourceLocation);
96
96
  }
97
- //# sourceMappingURL=error-classes.d.ts.map
@@ -191,4 +191,3 @@ export class AbortError extends RuntimeError {
191
191
  this.name = 'AbortError';
192
192
  }
193
193
  }
194
- //# sourceMappingURL=error-classes.js.map
@@ -53,4 +53,3 @@ export interface FormatErrorJsonOptions {
53
53
  * and callStack (when frames are present).
54
54
  */
55
55
  export declare function formatRillErrorJson(error: RillError, options?: FormatErrorJsonOptions): string;
56
- //# sourceMappingURL=error-formatter.d.ts.map
@@ -274,4 +274,3 @@ function appendCallStack(parts, data, visibleFrames, sources, filePath) {
274
274
  }
275
275
  }
276
276
  }
277
- //# sourceMappingURL=error-formatter.js.map
@@ -90,4 +90,3 @@ export declare function renderMessage(template: string, context: Record<string,
90
90
  * // Returns: ""
91
91
  */
92
92
  export declare function getHelpUrl(errorId: string, version: string): string;
93
- //# sourceMappingURL=error-registry.d.ts.map
@@ -336,6 +336,24 @@ const ERROR_DEFINITIONS = [
336
336
  },
337
337
  ],
338
338
  },
339
+ {
340
+ errorId: 'RILL-P014',
341
+ category: 'parse',
342
+ description: 'Malformed type argument list',
343
+ messageTemplate: '{details}',
344
+ cause: 'A type argument list has a syntax error: missing comma, closing paren, or invalid argument.',
345
+ resolution: 'Check the type argument list for missing commas or closing parentheses.',
346
+ examples: [
347
+ {
348
+ description: 'Missing comma between type arguments',
349
+ code: 'list(string number) # Error: expected , or )',
350
+ },
351
+ {
352
+ description: 'Missing closing paren',
353
+ code: 'dict(key: string # Error: expected )',
354
+ },
355
+ ],
356
+ },
339
357
  {
340
358
  errorId: 'RILL-P020',
341
359
  category: 'parse',
@@ -1093,6 +1111,20 @@ const ERROR_DEFINITIONS = [
1093
1111
  },
1094
1112
  ],
1095
1113
  },
1114
+ {
1115
+ errorId: 'RILL-R045',
1116
+ category: 'runtime',
1117
+ description: 'Too many arguments passed to callable',
1118
+ messageTemplate: 'Expected {expected} args, got {actual}',
1119
+ cause: 'The number of arguments passed to a callable exceeds the number of declared parameters.',
1120
+ resolution: 'Remove the excess arguments or add more parameters to the callable definition.',
1121
+ examples: [
1122
+ {
1123
+ description: 'Too many arguments to a two-param closure',
1124
+ code: '|x: number, y: number| { x + y } -> app::call(1, 2, 3) # 3 args, 2 params',
1125
+ },
1126
+ ],
1127
+ },
1096
1128
  // Resolver errors (RILL-R050–RILL-R059)
1097
1129
  {
1098
1130
  errorId: 'RILL-R050',
@@ -1472,4 +1504,3 @@ export function getHelpUrl(errorId, version) {
1472
1504
  const anchor = errorId.toLowerCase();
1473
1505
  return `https://github.com/rcrsr/rill/blob/v${version}/docs/ref-errors.md#${anchor}`;
1474
1506
  }
1475
- //# sourceMappingURL=error-registry.js.map
@@ -4,7 +4,7 @@
4
4
  * Provides cryptographic functions via thin wrapper around node:crypto.
5
5
  * Functions: hash, hmac, uuid, random
6
6
  */
7
- import type { ExtensionResult, ExtensionConfigSchema, ExtensionManifest } from '../../runtime/ext/extensions.js';
7
+ import type { ExtensionFactoryResult, ExtensionConfigSchema, ExtensionManifest } from '../../runtime/ext/extensions.js';
8
8
  export declare const configSchema: ExtensionConfigSchema;
9
9
  /** Crypto extension configuration */
10
10
  export interface CryptoConfig {
@@ -19,7 +19,7 @@ export interface CryptoConfig {
19
19
  * Returns 4 functions: hash, hmac, uuid, random.
20
20
  *
21
21
  * @param config - Crypto configuration
22
- * @returns ExtensionResult with 4 crypto functions
22
+ * @returns ExtensionFactoryResult with 4 crypto functions
23
23
  *
24
24
  * @example
25
25
  * ```typescript
@@ -29,6 +29,5 @@ export interface CryptoConfig {
29
29
  * });
30
30
  * ```
31
31
  */
32
- export declare function createCryptoExtension(config?: CryptoConfig): ExtensionResult;
32
+ export declare function createCryptoExtension(config?: CryptoConfig): ExtensionFactoryResult;
33
33
  export declare const extensionManifest: ExtensionManifest;
34
- //# sourceMappingURL=index.d.ts.map
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import crypto from 'node:crypto';
8
8
  import { RuntimeError } from '../../error-classes.js';
9
+ import { toCallable } from '../../runtime/core/callable.js';
9
10
  import { rillTypeToTypeValue, } from '../../runtime/core/values.js';
10
11
  // ============================================================
11
12
  // TYPES
@@ -23,7 +24,7 @@ export const configSchema = {
23
24
  * Returns 4 functions: hash, hmac, uuid, random.
24
25
  *
25
26
  * @param config - Crypto configuration
26
- * @returns ExtensionResult with 4 crypto functions
27
+ * @returns ExtensionFactoryResult with 4 crypto functions
27
28
  *
28
29
  * @example
29
30
  * ```typescript
@@ -56,8 +57,8 @@ export function createCryptoExtension(config = {}) {
56
57
  * IR-23
57
58
  */
58
59
  const hash = async (args) => {
59
- const input = args[0];
60
- const algorithm = args[1] ?? defaultAlgorithm;
60
+ const input = args['input'];
61
+ const algorithm = args['algorithm'] ?? defaultAlgorithm;
61
62
  // EC-27: Invalid algorithm
62
63
  validateAlgorithm(algorithm);
63
64
  const hashObject = crypto.createHash(algorithm);
@@ -73,8 +74,8 @@ export function createCryptoExtension(config = {}) {
73
74
  if (!hmacKey) {
74
75
  throw new RuntimeError('RILL-R004', 'hmacKey required for hmac() — set in config', undefined, {});
75
76
  }
76
- const input = args[0];
77
- const algorithm = args[1] ?? defaultAlgorithm;
77
+ const input = args['input'];
78
+ const algorithm = args['algorithm'] ?? defaultAlgorithm;
78
79
  // EC-27: Invalid algorithm
79
80
  validateAlgorithm(algorithm);
80
81
  const hmacObject = crypto.createHmac(algorithm, hmacKey);
@@ -93,71 +94,73 @@ export function createCryptoExtension(config = {}) {
93
94
  * IR-26
94
95
  */
95
96
  const random = async (args) => {
96
- const bytes = args[0];
97
+ const bytes = args['bytes'];
97
98
  return crypto.randomBytes(bytes).toString('hex');
98
99
  };
99
100
  // ============================================================
100
101
  // EXTENSION RESULT
101
102
  // ============================================================
102
103
  return {
103
- hash: {
104
- params: [
105
- {
106
- name: 'input',
107
- type: { type: 'string' },
108
- defaultValue: undefined,
109
- annotations: { description: 'Content to hash' },
104
+ value: {
105
+ hash: toCallable({
106
+ params: [
107
+ {
108
+ name: 'input',
109
+ type: { kind: 'string' },
110
+ defaultValue: undefined,
111
+ annotations: { description: 'Content to hash' },
112
+ },
113
+ {
114
+ name: 'algorithm',
115
+ type: { kind: 'string' },
116
+ defaultValue: defaultAlgorithm,
117
+ annotations: { description: 'Hash algorithm' },
118
+ },
119
+ ],
120
+ fn: hash,
121
+ annotations: { description: 'Hash content, returns hex output' },
122
+ returnType: rillTypeToTypeValue({ kind: 'string' }),
123
+ }),
124
+ hmac: toCallable({
125
+ params: [
126
+ {
127
+ name: 'input',
128
+ type: { kind: 'string' },
129
+ defaultValue: undefined,
130
+ annotations: { description: 'Content to authenticate' },
131
+ },
132
+ {
133
+ name: 'algorithm',
134
+ type: { kind: 'string' },
135
+ defaultValue: defaultAlgorithm,
136
+ annotations: { description: 'Hash algorithm' },
137
+ },
138
+ ],
139
+ fn: hmac,
140
+ annotations: {
141
+ description: 'Generate HMAC signature, returns hex output',
110
142
  },
111
- {
112
- name: 'algorithm',
113
- type: { type: 'string' },
114
- defaultValue: defaultAlgorithm,
115
- annotations: { description: 'Hash algorithm' },
116
- },
117
- ],
118
- fn: hash,
119
- annotations: { description: 'Hash content, returns hex output' },
120
- returnType: rillTypeToTypeValue({ type: 'string' }),
121
- },
122
- hmac: {
123
- params: [
124
- {
125
- name: 'input',
126
- type: { type: 'string' },
127
- defaultValue: undefined,
128
- annotations: { description: 'Content to authenticate' },
129
- },
130
- {
131
- name: 'algorithm',
132
- type: { type: 'string' },
133
- defaultValue: defaultAlgorithm,
134
- annotations: { description: 'Hash algorithm' },
135
- },
136
- ],
137
- fn: hmac,
138
- annotations: {
139
- description: 'Generate HMAC signature, returns hex output',
140
- },
141
- returnType: rillTypeToTypeValue({ type: 'string' }),
142
- },
143
- uuid: {
144
- params: [],
145
- fn: uuid,
146
- annotations: { description: 'Generate random UUID v4' },
147
- returnType: rillTypeToTypeValue({ type: 'string' }),
148
- },
149
- random: {
150
- params: [
151
- {
152
- name: 'bytes',
153
- type: { type: 'number' },
154
- defaultValue: undefined,
155
- annotations: { description: 'Number of bytes' },
156
- },
157
- ],
158
- fn: random,
159
- annotations: { description: 'Generate random bytes as hex string' },
160
- returnType: rillTypeToTypeValue({ type: 'string' }),
143
+ returnType: rillTypeToTypeValue({ kind: 'string' }),
144
+ }),
145
+ uuid: toCallable({
146
+ params: [],
147
+ fn: uuid,
148
+ annotations: { description: 'Generate random UUID v4' },
149
+ returnType: rillTypeToTypeValue({ kind: 'string' }),
150
+ }),
151
+ random: toCallable({
152
+ params: [
153
+ {
154
+ name: 'bytes',
155
+ type: { kind: 'number' },
156
+ defaultValue: undefined,
157
+ annotations: { description: 'Number of bytes' },
158
+ },
159
+ ],
160
+ fn: random,
161
+ annotations: { description: 'Generate random bytes as hex string' },
162
+ returnType: rillTypeToTypeValue({ kind: 'string' }),
163
+ }),
161
164
  },
162
165
  };
163
166
  }
@@ -168,4 +171,3 @@ export const extensionManifest = {
168
171
  factory: createCryptoExtension,
169
172
  configSchema,
170
173
  };
171
- //# sourceMappingURL=index.js.map
@@ -4,7 +4,7 @@
4
4
  * Provides sandboxed command execution via allowlist/blocklist security controls.
5
5
  * Each declared command becomes a function with argument validation and process isolation.
6
6
  */
7
- import type { ExtensionResult, ExtensionConfigSchema, ExtensionManifest } from '../../runtime/ext/extensions.js';
7
+ import type { ExtensionFactoryResult, ExtensionConfigSchema, ExtensionManifest } from '../../runtime/ext/extensions.js';
8
8
  import { type CommandConfig } from './runner.js';
9
9
  export declare const configSchema: ExtensionConfigSchema;
10
10
  /** exec extension configuration */
@@ -27,7 +27,7 @@ export type { CommandConfig };
27
27
  * Returns dispose() function to abort in-flight processes.
28
28
  *
29
29
  * @param config - Command definitions and defaults
30
- * @returns ExtensionResult with command functions and dispose
30
+ * @returns ExtensionFactoryResult with command functions and dispose
31
31
  *
32
32
  * @example
33
33
  * ```typescript
@@ -42,6 +42,5 @@ export type { CommandConfig };
42
42
  * });
43
43
  * ```
44
44
  */
45
- export declare function createExecExtension(config: ExecConfig): ExtensionResult;
45
+ export declare function createExecExtension(config: ExecConfig): ExtensionFactoryResult;
46
46
  export declare const extensionManifest: ExtensionManifest;
47
- //# sourceMappingURL=index.d.ts.map
@@ -4,6 +4,7 @@
4
4
  * Provides sandboxed command execution via allowlist/blocklist security controls.
5
5
  * Each declared command becomes a function with argument validation and process isolation.
6
6
  */
7
+ import { toCallable } from '../../runtime/core/callable.js';
7
8
  import { rillTypeToTypeValue, } from '../../runtime/core/values.js';
8
9
  import { runCommand, } from './runner.js';
9
10
  // ============================================================
@@ -23,7 +24,7 @@ export const configSchema = {
23
24
  * Returns dispose() function to abort in-flight processes.
24
25
  *
25
26
  * @param config - Command definitions and defaults
26
- * @returns ExtensionResult with command functions and dispose
27
+ * @returns ExtensionFactoryResult with command functions and dispose
27
28
  *
28
29
  * @example
29
30
  * ```typescript
@@ -80,9 +81,9 @@ export function createExecExtension(config) {
80
81
  for (const [commandName, commandConfig] of Object.entries(config.commands)) {
81
82
  // Create function for this command
82
83
  const commandFn = async (args) => {
83
- // Extract args and stdin from RillValue array
84
- const argsParam = args[0] ?? [];
85
- const stdinParam = args[1];
84
+ // Extract args and stdin from named arg map
85
+ const argsParam = args['args'] ?? [];
86
+ const stdinParam = args['stdin'];
86
87
  // Convert args to string array
87
88
  const stringArgs = argsParam.map((arg) => String(arg));
88
89
  // Create abort controller for this execution
@@ -118,13 +119,13 @@ export function createExecExtension(config) {
118
119
  params: [
119
120
  {
120
121
  name: 'args',
121
- type: { type: 'list' },
122
+ type: { kind: 'list' },
122
123
  defaultValue: [],
123
124
  annotations: { description: 'Command arguments' },
124
125
  },
125
126
  {
126
127
  name: 'stdin',
127
- type: { type: 'string' },
128
+ type: { kind: 'string' },
128
129
  defaultValue: '',
129
130
  annotations: { description: 'Standard input data' },
130
131
  },
@@ -133,7 +134,7 @@ export function createExecExtension(config) {
133
134
  annotations: {
134
135
  description: commandConfig.description ?? `Execute ${commandName} command`,
135
136
  },
136
- returnType: rillTypeToTypeValue({ type: 'dict' }),
137
+ returnType: rillTypeToTypeValue({ kind: 'dict' }),
137
138
  };
138
139
  }
139
140
  // ============================================================
@@ -153,7 +154,7 @@ export function createExecExtension(config) {
153
154
  params: [],
154
155
  fn: commands,
155
156
  annotations: { description: 'List all configured commands' },
156
- returnType: rillTypeToTypeValue({ type: 'list' }),
157
+ returnType: rillTypeToTypeValue({ kind: 'list' }),
157
158
  };
158
159
  // ============================================================
159
160
  // DISPOSE FUNCTION
@@ -169,9 +170,14 @@ export function createExecExtension(config) {
169
170
  // ============================================================
170
171
  // EXTENSION RESULT
171
172
  // ============================================================
172
- const result = functions;
173
- result.dispose = dispose;
174
- return result;
173
+ const callableDict = {};
174
+ for (const [name, def] of Object.entries(functions)) {
175
+ callableDict[name] = toCallable(def);
176
+ }
177
+ return {
178
+ value: callableDict,
179
+ dispose,
180
+ };
175
181
  }
176
182
  // ============================================================
177
183
  // MANIFEST
@@ -180,4 +186,3 @@ export const extensionManifest = {
180
186
  factory: createExecExtension,
181
187
  configSchema,
182
188
  };
183
- //# sourceMappingURL=index.js.map
@@ -59,4 +59,3 @@ export interface CommandResult {
59
59
  * ```
60
60
  */
61
61
  export declare function runCommand(commandName: string, config: CommandConfig, args: readonly string[], stdinData?: string | undefined, signal?: AbortSignal | undefined): Promise<CommandResult>;
62
- //# sourceMappingURL=runner.d.ts.map
@@ -165,4 +165,3 @@ export async function runCommand(commandName, config, args, stdinData, signal) {
165
165
  throw err;
166
166
  }
167
167
  }
168
- //# sourceMappingURL=runner.js.map
@@ -5,7 +5,7 @@
5
5
  * Scripts call endpoints with positional args or single dict argument.
6
6
  * All URLs are constructed from config - scripts cannot specify arbitrary URLs.
7
7
  */
8
- import type { ExtensionResult, ExtensionConfigSchema, ExtensionManifest } from '../../runtime/ext/extensions.js';
8
+ import type { ExtensionFactoryResult, ExtensionConfigSchema, ExtensionManifest } from '../../runtime/ext/extensions.js';
9
9
  export declare const configSchema: ExtensionConfigSchema;
10
10
  /** Parameter definition for endpoint */
11
11
  export interface EndpointParam {
@@ -46,7 +46,7 @@ export interface FetchConfig {
46
46
  * All URLs constructed from config - scripts cannot create arbitrary URLs.
47
47
  *
48
48
  * @param config - Fetch configuration with endpoints
49
- * @returns ExtensionResult with endpoint functions and introspection
49
+ * @returns ExtensionFactoryResult with endpoint functions and introspection
50
50
  * @throws Error on invalid configuration
51
51
  *
52
52
  * @example
@@ -65,6 +65,5 @@ export interface FetchConfig {
65
65
  * });
66
66
  * ```
67
67
  */
68
- export declare function createFetchExtension(config: FetchConfig): ExtensionResult;
68
+ export declare function createFetchExtension(config: FetchConfig): ExtensionFactoryResult;
69
69
  export declare const extensionManifest: ExtensionManifest;
70
- //# sourceMappingURL=index.d.ts.map