@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,7 +4,8 @@
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 { rillTypeToTypeValue, } from '../../runtime/core/values.js';
7
+ import { toCallable } from '../../runtime/core/callable.js';
8
+ import { structureToTypeValue } from '../../runtime/core/values.js';
8
9
  import { runCommand, } from './runner.js';
9
10
  // ============================================================
10
11
  // TYPES
@@ -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
@@ -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: structureToTypeValue({ 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: structureToTypeValue({ 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
@@ -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,5 +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;
@@ -6,8 +6,8 @@
6
6
  * All URLs are constructed from config - scripts cannot specify arbitrary URLs.
7
7
  */
8
8
  import { RuntimeError } from '../../error-classes.js';
9
- import {} from '../../runtime/core/callable.js';
10
- import { rillTypeToTypeValue, } from '../../runtime/core/values.js';
9
+ import { toCallable } from '../../runtime/core/callable.js';
10
+ import { structureToTypeValue } from '../../runtime/core/values.js';
11
11
  import { buildRequest, executeRequest, createSemaphore, } from './request.js';
12
12
  // ============================================================
13
13
  // TYPE DEFINITIONS
@@ -96,7 +96,7 @@ function processArguments(args, params, functionName) {
96
96
  * All URLs constructed from config - scripts cannot create arbitrary URLs.
97
97
  *
98
98
  * @param config - Fetch configuration with endpoints
99
- * @returns ExtensionResult with endpoint functions and introspection
99
+ * @returns ExtensionFactoryResult with endpoint functions and introspection
100
100
  * @throws Error on invalid configuration
101
101
  *
102
102
  * @example
@@ -164,10 +164,10 @@ export function createFetchExtension(config) {
164
164
  };
165
165
  // Build parameter definitions for RillFunction
166
166
  const rillParams = params.map((param) => {
167
- // Map EndpointParam type string to RillType object
167
+ // Map EndpointParam type string to TypeStructure object
168
168
  const rillType = param.type !== 'dict'
169
- ? { type: param.type }
170
- : { type: 'dict' };
169
+ ? { kind: param.type }
170
+ : { kind: 'dict' };
171
171
  return {
172
172
  name: param.name,
173
173
  type: rillType,
@@ -176,8 +176,8 @@ export function createFetchExtension(config) {
176
176
  };
177
177
  });
178
178
  const returnTypeValue = (endpointConfig.responseShape ?? defaultResponseShape) === 'full'
179
- ? rillTypeToTypeValue({ type: 'dict' })
180
- : rillTypeToTypeValue({ type: 'any' });
179
+ ? structureToTypeValue({ kind: 'dict' })
180
+ : structureToTypeValue({ kind: 'any' });
181
181
  const hostFunctionDef = {
182
182
  params: rillParams,
183
183
  fn: endpointFn,
@@ -211,7 +211,7 @@ export function createFetchExtension(config) {
211
211
  params: [],
212
212
  fn: endpoints,
213
213
  annotations: { description: 'List configured endpoints' },
214
- returnType: rillTypeToTypeValue({ type: 'list' }),
214
+ returnType: structureToTypeValue({ kind: 'list' }),
215
215
  };
216
216
  // ============================================================
217
217
  // DISPOSAL
@@ -229,9 +229,14 @@ export function createFetchExtension(config) {
229
229
  // ============================================================
230
230
  // EXTENSION RESULT
231
231
  // ============================================================
232
- const result = functions;
233
- result.dispose = dispose;
234
- return result;
232
+ const callableDict = {};
233
+ for (const [name, def] of Object.entries(functions)) {
234
+ callableDict[name] = toCallable(def);
235
+ }
236
+ return {
237
+ value: callableDict,
238
+ dispose,
239
+ };
235
240
  }
236
241
  // ============================================================
237
242
  // MANIFEST
@@ -253,10 +253,10 @@ export async function executeRequest(url, options, config, namespace, responseSh
253
253
  const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
254
254
  try {
255
255
  // Execute fetch request
256
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
257
256
  const response = await fetch(url, {
258
257
  ...options,
259
258
  signal: controller.signal,
259
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
260
260
  });
261
261
  clearTimeout(timeoutId);
262
262
  // Handle HTTP errors
@@ -4,7 +4,7 @@
4
4
  * Provides sandboxed filesystem operations via mount-based access control.
5
5
  * All 12 functions implement path validation, permission checks, and glob filtering.
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 MountConfig } from './sandbox.js';
9
9
  /** Filesystem extension configuration */
10
10
  export interface FsConfig {
@@ -24,7 +24,7 @@ export declare const configSchema: ExtensionConfigSchema;
24
24
  * Returns 12 functions: read, write, append, list, find, exists, remove, stat, mkdir, copy, move, mounts.
25
25
  *
26
26
  * @param config - Mount configuration and defaults
27
- * @returns ExtensionResult with 12 filesystem functions
27
+ * @returns ExtensionFactoryResult with 12 filesystem functions
28
28
  * @throws RuntimeError if mount initialization fails
29
29
  *
30
30
  * @example
@@ -36,5 +36,5 @@ export declare const configSchema: ExtensionConfigSchema;
36
36
  * });
37
37
  * ```
38
38
  */
39
- export declare function createFsExtension(config: FsConfig): ExtensionResult;
39
+ export declare function createFsExtension(config: FsConfig): ExtensionFactoryResult;
40
40
  export declare const extensionManifest: ExtensionManifest;