@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.
- package/README.md +37 -21
- package/dist/ast-nodes.d.ts +14 -4
- package/dist/ast-unions.d.ts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -0
- package/dist/error-registry.js +228 -0
- package/dist/ext/crypto/index.d.ts +3 -3
- package/dist/ext/crypto/index.js +62 -59
- package/dist/ext/exec/index.d.ts +3 -3
- package/dist/ext/exec/index.js +15 -9
- package/dist/ext/fetch/index.d.ts +3 -3
- package/dist/ext/fetch/index.js +17 -12
- package/dist/ext/fetch/request.js +1 -1
- package/dist/ext/fs/index.d.ts +3 -3
- package/dist/ext/fs/index.js +256 -266
- package/dist/ext/fs/sandbox.d.ts +18 -0
- package/dist/ext/fs/sandbox.js +33 -0
- package/dist/ext/kv/index.d.ts +3 -3
- package/dist/ext/kv/index.js +198 -196
- package/dist/ext/kv/store.d.ts +1 -1
- package/dist/ext/kv/store.js +2 -1
- package/dist/ext-parse-bridge.d.ts +10 -0
- package/dist/ext-parse-bridge.js +10 -0
- package/dist/generated/introspection-data.d.ts +1 -1
- package/dist/generated/introspection-data.js +385 -296
- package/dist/generated/version-data.d.ts +1 -1
- package/dist/generated/version-data.js +2 -2
- package/dist/highlight-map.js +1 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -5
- package/dist/lexer/operators.js +1 -0
- package/dist/parser/helpers.js +1 -0
- package/dist/parser/parser-expr.js +44 -5
- package/dist/parser/parser-literals.js +111 -4
- package/dist/parser/parser-shape.js +2 -2
- package/dist/parser/parser-types.js +12 -0
- package/dist/parser/parser-use.js +26 -3
- package/dist/parser/parser.d.ts +2 -0
- package/dist/parser/parser.js +2 -0
- package/dist/runtime/core/callable.d.ts +24 -13
- package/dist/runtime/core/callable.js +71 -38
- package/dist/runtime/core/context.d.ts +2 -13
- package/dist/runtime/core/context.js +80 -79
- package/dist/runtime/core/eval/base.d.ts +2 -2
- package/dist/runtime/core/eval/base.js +2 -0
- package/dist/runtime/core/eval/evaluator.d.ts +1 -1
- package/dist/runtime/core/eval/index.d.ts +3 -3
- package/dist/runtime/core/eval/index.js +11 -0
- package/dist/runtime/core/eval/mixins/closures.js +381 -41
- package/dist/runtime/core/eval/mixins/collections.js +81 -6
- package/dist/runtime/core/eval/mixins/control-flow.js +1 -1
- package/dist/runtime/core/eval/mixins/conversion.js +61 -115
- package/dist/runtime/core/eval/mixins/core.js +17 -4
- package/dist/runtime/core/eval/mixins/expressions.js +36 -27
- package/dist/runtime/core/eval/mixins/extraction.js +2 -3
- package/dist/runtime/core/eval/mixins/list-dispatch.js +1 -1
- package/dist/runtime/core/eval/mixins/literals.js +17 -6
- package/dist/runtime/core/eval/mixins/types.js +73 -54
- package/dist/runtime/core/eval/mixins/variables.js +12 -8
- package/dist/runtime/core/execute.d.ts +1 -1
- package/dist/runtime/core/field-descriptor.d.ts +3 -3
- package/dist/runtime/core/field-descriptor.js +2 -1
- package/dist/runtime/core/introspection.d.ts +2 -2
- package/dist/runtime/core/introspection.js +7 -6
- package/dist/runtime/core/resolvers.d.ts +1 -1
- package/dist/runtime/core/signals.d.ts +6 -1
- package/dist/runtime/core/signals.js +9 -0
- package/dist/runtime/core/types/constructors.d.ts +54 -0
- package/dist/runtime/core/types/constructors.js +201 -0
- package/dist/runtime/core/types/guards.d.ts +42 -0
- package/dist/runtime/core/types/guards.js +88 -0
- package/dist/runtime/core/types/index.d.ts +18 -0
- package/dist/runtime/core/types/index.js +19 -0
- package/dist/runtime/core/types/markers.d.ts +12 -0
- package/dist/runtime/core/types/markers.js +7 -0
- package/dist/runtime/core/types/operations.d.ts +98 -0
- package/dist/runtime/core/types/operations.js +804 -0
- package/dist/runtime/core/types/registrations.d.ts +126 -0
- package/dist/runtime/core/types/registrations.js +751 -0
- package/dist/runtime/core/{types.d.ts → types/runtime.d.ts} +22 -10
- package/dist/runtime/core/types/structures.d.ts +146 -0
- package/dist/runtime/core/types/structures.js +12 -0
- package/dist/runtime/core/values.d.ts +29 -209
- package/dist/runtime/core/values.js +56 -968
- package/dist/runtime/ext/builtins.js +88 -68
- package/dist/runtime/ext/extensions.d.ts +31 -125
- package/dist/runtime/ext/extensions.js +2 -94
- package/dist/runtime/ext/test-context.d.ts +28 -0
- package/dist/runtime/ext/test-context.js +155 -0
- package/dist/runtime/index.d.ts +12 -12
- package/dist/runtime/index.js +13 -5
- package/dist/signature-parser.d.ts +2 -2
- package/dist/signature-parser.js +14 -14
- package/dist/token-types.d.ts +1 -0
- package/dist/token-types.js +1 -0
- package/package.json +1 -1
- /package/dist/runtime/core/{types.js → types/runtime.js} +0 -0
package/dist/ext/fs/index.js
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
import fs from 'node:fs/promises';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { RuntimeError } from '../../error-classes.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { toCallable } from '../../runtime/core/callable.js';
|
|
11
|
+
import { structureToTypeValue } from '../../runtime/core/values.js';
|
|
12
|
+
import { resolvePath, matchesGlob, initializeMount, parseMountPath, } from './sandbox.js';
|
|
12
13
|
export const configSchema = {
|
|
13
14
|
mounts: { type: 'string', required: true },
|
|
14
15
|
};
|
|
@@ -22,7 +23,7 @@ export const configSchema = {
|
|
|
22
23
|
* Returns 12 functions: read, write, append, list, find, exists, remove, stat, mkdir, copy, move, mounts.
|
|
23
24
|
*
|
|
24
25
|
* @param config - Mount configuration and defaults
|
|
25
|
-
* @returns
|
|
26
|
+
* @returns ExtensionFactoryResult with 12 filesystem functions
|
|
26
27
|
* @throws RuntimeError if mount initialization fails
|
|
27
28
|
*
|
|
28
29
|
* @example
|
|
@@ -75,8 +76,7 @@ export function createFsExtension(config) {
|
|
|
75
76
|
// ctx and location not used but required by CallableFn signature
|
|
76
77
|
) => {
|
|
77
78
|
await ensureInitialized();
|
|
78
|
-
const mountName = args['
|
|
79
|
-
const filePath = args['path'];
|
|
79
|
+
const { mountName, relativePath: filePath } = parseMountPath(args['path'], mounts);
|
|
80
80
|
// EC-5: Catch file not found from resolvePath
|
|
81
81
|
let resolvedPath;
|
|
82
82
|
try {
|
|
@@ -101,8 +101,7 @@ export function createFsExtension(config) {
|
|
|
101
101
|
*/
|
|
102
102
|
const write = async (args) => {
|
|
103
103
|
await ensureInitialized();
|
|
104
|
-
const mountName = args['
|
|
105
|
-
const filePath = args['path'];
|
|
104
|
+
const { mountName, relativePath: filePath } = parseMountPath(args['path'], mounts);
|
|
106
105
|
const content = args['content'];
|
|
107
106
|
const resolvedPath = await resolvePath(mountName, filePath, mounts, 'write', true // createMode: resolve parent directory
|
|
108
107
|
);
|
|
@@ -120,8 +119,7 @@ export function createFsExtension(config) {
|
|
|
120
119
|
*/
|
|
121
120
|
const append = async (args) => {
|
|
122
121
|
await ensureInitialized();
|
|
123
|
-
const mountName = args['
|
|
124
|
-
const filePath = args['path'];
|
|
122
|
+
const { mountName, relativePath: filePath } = parseMountPath(args['path'], mounts);
|
|
125
123
|
const content = args['content'];
|
|
126
124
|
const resolvedPath = await resolvePath(mountName, filePath, mounts, 'write', true // createMode: allow new files
|
|
127
125
|
);
|
|
@@ -157,8 +155,7 @@ export function createFsExtension(config) {
|
|
|
157
155
|
*/
|
|
158
156
|
const list = async (args) => {
|
|
159
157
|
await ensureInitialized();
|
|
160
|
-
const mountName = args['
|
|
161
|
-
const dirPath = args['path'] ?? '';
|
|
158
|
+
const { mountName, relativePath: dirPath } = parseMountPath(args['path'], mounts);
|
|
162
159
|
const resolvedPath = await resolvePath(mountName, dirPath, mounts, 'read');
|
|
163
160
|
const entries = await fs.readdir(resolvedPath, { withFileTypes: true });
|
|
164
161
|
const result = [];
|
|
@@ -179,13 +176,20 @@ export function createFsExtension(config) {
|
|
|
179
176
|
*/
|
|
180
177
|
const find = async (args) => {
|
|
181
178
|
await ensureInitialized();
|
|
182
|
-
const mountName = args['
|
|
179
|
+
const { mountName, relativePath: searchBase } = parseMountPath(args['path'], mounts);
|
|
183
180
|
const pattern = args['pattern'] ?? '*';
|
|
184
181
|
const mount = mounts[mountName];
|
|
185
182
|
if (!mount || !mount.resolvedPath) {
|
|
186
183
|
throw new RuntimeError('RILL-R004', `mount "${mountName}" not configured`, undefined, { mountName });
|
|
187
184
|
}
|
|
188
|
-
|
|
185
|
+
let basePath;
|
|
186
|
+
if (searchBase) {
|
|
187
|
+
// Validate searchBase through sandbox resolver to prevent path traversal
|
|
188
|
+
basePath = await resolvePath(mountName, searchBase, mounts, 'read');
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
basePath = mount.resolvedPath;
|
|
192
|
+
}
|
|
189
193
|
const results = [];
|
|
190
194
|
// Recursive directory traversal
|
|
191
195
|
const traverse = async (currentPath) => {
|
|
@@ -197,7 +201,7 @@ export function createFsExtension(config) {
|
|
|
197
201
|
}
|
|
198
202
|
else if (matchesGlob(entry.name, pattern)) {
|
|
199
203
|
// Return path relative to mount base
|
|
200
|
-
const relativePath = path.relative(
|
|
204
|
+
const relativePath = path.relative(mount.resolvedPath, fullPath);
|
|
201
205
|
results.push(relativePath);
|
|
202
206
|
}
|
|
203
207
|
}
|
|
@@ -211,8 +215,7 @@ export function createFsExtension(config) {
|
|
|
211
215
|
*/
|
|
212
216
|
const exists = async (args) => {
|
|
213
217
|
await ensureInitialized();
|
|
214
|
-
const mountName = args['
|
|
215
|
-
const filePath = args['path'];
|
|
218
|
+
const { mountName, relativePath: filePath } = parseMountPath(args['path'], mounts);
|
|
216
219
|
try {
|
|
217
220
|
await resolvePath(mountName, filePath, mounts, 'read');
|
|
218
221
|
return true;
|
|
@@ -231,8 +234,7 @@ export function createFsExtension(config) {
|
|
|
231
234
|
*/
|
|
232
235
|
const remove = async (args) => {
|
|
233
236
|
await ensureInitialized();
|
|
234
|
-
const mountName = args['
|
|
235
|
-
const filePath = args['path'];
|
|
237
|
+
const { mountName, relativePath: filePath } = parseMountPath(args['path'], mounts);
|
|
236
238
|
// Catch file not found from resolvePath
|
|
237
239
|
let resolvedPath;
|
|
238
240
|
try {
|
|
@@ -264,8 +266,7 @@ export function createFsExtension(config) {
|
|
|
264
266
|
*/
|
|
265
267
|
const stat = async (args) => {
|
|
266
268
|
await ensureInitialized();
|
|
267
|
-
const mountName = args['
|
|
268
|
-
const filePath = args['path'];
|
|
269
|
+
const { mountName, relativePath: filePath } = parseMountPath(args['path'], mounts);
|
|
269
270
|
// Catch file not found from resolvePath
|
|
270
271
|
let resolvedPath;
|
|
271
272
|
try {
|
|
@@ -294,8 +295,7 @@ export function createFsExtension(config) {
|
|
|
294
295
|
*/
|
|
295
296
|
const mkdir = async (args) => {
|
|
296
297
|
await ensureInitialized();
|
|
297
|
-
const mountName = args['
|
|
298
|
-
const dirPath = args['path'];
|
|
298
|
+
const { mountName, relativePath: dirPath } = parseMountPath(args['path'], mounts);
|
|
299
299
|
const mount = mounts[mountName];
|
|
300
300
|
if (!mount || !mount.resolvedPath) {
|
|
301
301
|
throw new RuntimeError('RILL-R004', `mount "${mountName}" not configured`, undefined, { mountName });
|
|
@@ -344,9 +344,13 @@ export function createFsExtension(config) {
|
|
|
344
344
|
*/
|
|
345
345
|
const copy = async (args) => {
|
|
346
346
|
await ensureInitialized();
|
|
347
|
-
const mountName = args['
|
|
348
|
-
const
|
|
349
|
-
const
|
|
347
|
+
const { mountName: srcMountName, relativePath: srcPath } = parseMountPath(args['src'], mounts);
|
|
348
|
+
const { mountName: destMountName, relativePath: destPath } = parseMountPath(args['dest'], mounts);
|
|
349
|
+
const mountName = srcMountName;
|
|
350
|
+
// Verify same mount
|
|
351
|
+
if (srcMountName !== destMountName) {
|
|
352
|
+
throw new RuntimeError('RILL-R004', `copy requires same mount for src and dest`, undefined, { src: args['src'], dest: args['dest'] });
|
|
353
|
+
}
|
|
350
354
|
const resolvedSrc = await resolvePath(mountName, srcPath, mounts, 'read');
|
|
351
355
|
const resolvedDest = await resolvePath(mountName, destPath, mounts, 'write', true // createMode
|
|
352
356
|
);
|
|
@@ -373,9 +377,13 @@ export function createFsExtension(config) {
|
|
|
373
377
|
*/
|
|
374
378
|
const move = async (args) => {
|
|
375
379
|
await ensureInitialized();
|
|
376
|
-
const mountName = args['
|
|
377
|
-
const
|
|
378
|
-
const
|
|
380
|
+
const { mountName: srcMountName, relativePath: srcPath } = parseMountPath(args['src'], mounts);
|
|
381
|
+
const { mountName: destMountName, relativePath: destPath } = parseMountPath(args['dest'], mounts);
|
|
382
|
+
const mountName = srcMountName;
|
|
383
|
+
// Verify same mount
|
|
384
|
+
if (srcMountName !== destMountName) {
|
|
385
|
+
throw new RuntimeError('RILL-R004', `move requires same mount for src and dest`, undefined, { src: args['src'], dest: args['dest'] });
|
|
386
|
+
}
|
|
379
387
|
const resolvedSrc = await resolvePath(mountName, srcPath, mounts, 'read');
|
|
380
388
|
const resolvedDest = await resolvePath(mountName, destPath, mounts, 'write', true // createMode
|
|
381
389
|
);
|
|
@@ -412,244 +420,226 @@ export function createFsExtension(config) {
|
|
|
412
420
|
// EXTENSION RESULT
|
|
413
421
|
// ============================================================
|
|
414
422
|
return {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
},
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
{
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
},
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
},
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
{
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
annotations: { description: 'Source file path' },
|
|
636
|
-
},
|
|
637
|
-
{
|
|
638
|
-
name: 'dest',
|
|
639
|
-
type: { type: 'string' },
|
|
640
|
-
defaultValue: undefined,
|
|
641
|
-
annotations: { description: 'Destination file path' },
|
|
642
|
-
},
|
|
643
|
-
],
|
|
644
|
-
fn: move,
|
|
645
|
-
annotations: { description: 'Move file within mount' },
|
|
646
|
-
returnType: rillTypeToTypeValue({ type: 'bool' }),
|
|
647
|
-
},
|
|
648
|
-
mounts: {
|
|
649
|
-
params: [],
|
|
650
|
-
fn: mountsList,
|
|
651
|
-
annotations: { description: 'List configured mounts' },
|
|
652
|
-
returnType: rillTypeToTypeValue({ type: 'list' }),
|
|
423
|
+
value: {
|
|
424
|
+
read: toCallable({
|
|
425
|
+
params: [
|
|
426
|
+
{
|
|
427
|
+
name: 'path',
|
|
428
|
+
type: { kind: 'string' },
|
|
429
|
+
defaultValue: undefined,
|
|
430
|
+
annotations: {
|
|
431
|
+
description: 'Mount-prefixed file path (e.g. "/mount/file.txt")',
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
],
|
|
435
|
+
fn: read,
|
|
436
|
+
annotations: { description: 'Read file contents' },
|
|
437
|
+
returnType: structureToTypeValue({ kind: 'string' }),
|
|
438
|
+
}),
|
|
439
|
+
write: toCallable({
|
|
440
|
+
params: [
|
|
441
|
+
{
|
|
442
|
+
name: 'path',
|
|
443
|
+
type: { kind: 'string' },
|
|
444
|
+
defaultValue: undefined,
|
|
445
|
+
annotations: {
|
|
446
|
+
description: 'Mount-prefixed file path (e.g. "/mount/file.txt")',
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
name: 'content',
|
|
451
|
+
type: { kind: 'string' },
|
|
452
|
+
defaultValue: undefined,
|
|
453
|
+
annotations: { description: 'Content to write' },
|
|
454
|
+
},
|
|
455
|
+
],
|
|
456
|
+
fn: write,
|
|
457
|
+
annotations: { description: 'Write file, replacing if exists' },
|
|
458
|
+
returnType: structureToTypeValue({ kind: 'string' }),
|
|
459
|
+
}),
|
|
460
|
+
append: toCallable({
|
|
461
|
+
params: [
|
|
462
|
+
{
|
|
463
|
+
name: 'path',
|
|
464
|
+
type: { kind: 'string' },
|
|
465
|
+
defaultValue: undefined,
|
|
466
|
+
annotations: {
|
|
467
|
+
description: 'Mount-prefixed file path (e.g. "/mount/file.txt")',
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
name: 'content',
|
|
472
|
+
type: { kind: 'string' },
|
|
473
|
+
defaultValue: undefined,
|
|
474
|
+
annotations: { description: 'Content to append' },
|
|
475
|
+
},
|
|
476
|
+
],
|
|
477
|
+
fn: append,
|
|
478
|
+
annotations: { description: 'Append content to file' },
|
|
479
|
+
returnType: structureToTypeValue({ kind: 'string' }),
|
|
480
|
+
}),
|
|
481
|
+
list: toCallable({
|
|
482
|
+
params: [
|
|
483
|
+
{
|
|
484
|
+
name: 'path',
|
|
485
|
+
type: { kind: 'string' },
|
|
486
|
+
defaultValue: undefined,
|
|
487
|
+
annotations: {
|
|
488
|
+
description: 'Mount-prefixed directory path (e.g. "/mount/subdir")',
|
|
489
|
+
},
|
|
490
|
+
},
|
|
491
|
+
],
|
|
492
|
+
fn: list,
|
|
493
|
+
annotations: { description: 'List directory contents' },
|
|
494
|
+
returnType: structureToTypeValue({
|
|
495
|
+
kind: 'list',
|
|
496
|
+
element: {
|
|
497
|
+
kind: 'dict',
|
|
498
|
+
fields: {
|
|
499
|
+
name: { type: { kind: 'string' } },
|
|
500
|
+
type: { type: { kind: 'string' } },
|
|
501
|
+
size: { type: { kind: 'number' } },
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
}),
|
|
505
|
+
}),
|
|
506
|
+
find: toCallable({
|
|
507
|
+
params: [
|
|
508
|
+
{
|
|
509
|
+
name: 'path',
|
|
510
|
+
type: { kind: 'string' },
|
|
511
|
+
defaultValue: undefined,
|
|
512
|
+
annotations: {
|
|
513
|
+
description: 'Mount-prefixed base path (e.g. "/mount" or "/mount/subdir")',
|
|
514
|
+
},
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
name: 'pattern',
|
|
518
|
+
type: { kind: 'string' },
|
|
519
|
+
defaultValue: '*',
|
|
520
|
+
annotations: { description: 'Glob pattern for filtering' },
|
|
521
|
+
},
|
|
522
|
+
],
|
|
523
|
+
fn: find,
|
|
524
|
+
annotations: { description: 'Recursive file search' },
|
|
525
|
+
returnType: structureToTypeValue({
|
|
526
|
+
kind: 'list',
|
|
527
|
+
element: { kind: 'string' },
|
|
528
|
+
}),
|
|
529
|
+
}),
|
|
530
|
+
exists: toCallable({
|
|
531
|
+
params: [
|
|
532
|
+
{
|
|
533
|
+
name: 'path',
|
|
534
|
+
type: { kind: 'string' },
|
|
535
|
+
defaultValue: undefined,
|
|
536
|
+
annotations: {
|
|
537
|
+
description: 'Mount-prefixed file path (e.g. "/mount/file.txt")',
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
],
|
|
541
|
+
fn: exists,
|
|
542
|
+
annotations: { description: 'Check file existence' },
|
|
543
|
+
returnType: structureToTypeValue({ kind: 'bool' }),
|
|
544
|
+
}),
|
|
545
|
+
remove: toCallable({
|
|
546
|
+
params: [
|
|
547
|
+
{
|
|
548
|
+
name: 'path',
|
|
549
|
+
type: { kind: 'string' },
|
|
550
|
+
defaultValue: undefined,
|
|
551
|
+
annotations: {
|
|
552
|
+
description: 'Mount-prefixed file path (e.g. "/mount/file.txt")',
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
],
|
|
556
|
+
fn: remove,
|
|
557
|
+
annotations: { description: 'Delete file' },
|
|
558
|
+
returnType: structureToTypeValue({ kind: 'bool' }),
|
|
559
|
+
}),
|
|
560
|
+
stat: toCallable({
|
|
561
|
+
params: [
|
|
562
|
+
{
|
|
563
|
+
name: 'path',
|
|
564
|
+
type: { kind: 'string' },
|
|
565
|
+
defaultValue: undefined,
|
|
566
|
+
annotations: {
|
|
567
|
+
description: 'Mount-prefixed file path (e.g. "/mount/file.txt")',
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
],
|
|
571
|
+
fn: stat,
|
|
572
|
+
annotations: { description: 'Get file metadata' },
|
|
573
|
+
returnType: structureToTypeValue({
|
|
574
|
+
kind: 'dict',
|
|
575
|
+
fields: {
|
|
576
|
+
name: { type: { kind: 'string' } },
|
|
577
|
+
type: { type: { kind: 'string' } },
|
|
578
|
+
size: { type: { kind: 'number' } },
|
|
579
|
+
created: { type: { kind: 'string' } },
|
|
580
|
+
modified: { type: { kind: 'string' } },
|
|
581
|
+
},
|
|
582
|
+
}),
|
|
583
|
+
}),
|
|
584
|
+
mkdir: toCallable({
|
|
585
|
+
params: [
|
|
586
|
+
{
|
|
587
|
+
name: 'path',
|
|
588
|
+
type: { kind: 'string' },
|
|
589
|
+
defaultValue: undefined,
|
|
590
|
+
annotations: {
|
|
591
|
+
description: 'Mount-prefixed directory path (e.g. "/mount/subdir")',
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
],
|
|
595
|
+
fn: mkdir,
|
|
596
|
+
annotations: { description: 'Create directory' },
|
|
597
|
+
returnType: structureToTypeValue({ kind: 'bool' }),
|
|
598
|
+
}),
|
|
599
|
+
copy: toCallable({
|
|
600
|
+
params: [
|
|
601
|
+
{
|
|
602
|
+
name: 'src',
|
|
603
|
+
type: { kind: 'string' },
|
|
604
|
+
defaultValue: undefined,
|
|
605
|
+
annotations: { description: 'Mount-prefixed source path' },
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: 'dest',
|
|
609
|
+
type: { kind: 'string' },
|
|
610
|
+
defaultValue: undefined,
|
|
611
|
+
annotations: { description: 'Mount-prefixed destination path' },
|
|
612
|
+
},
|
|
613
|
+
],
|
|
614
|
+
fn: copy,
|
|
615
|
+
annotations: { description: 'Copy file within mount' },
|
|
616
|
+
returnType: structureToTypeValue({ kind: 'bool' }),
|
|
617
|
+
}),
|
|
618
|
+
move: toCallable({
|
|
619
|
+
params: [
|
|
620
|
+
{
|
|
621
|
+
name: 'src',
|
|
622
|
+
type: { kind: 'string' },
|
|
623
|
+
defaultValue: undefined,
|
|
624
|
+
annotations: { description: 'Mount-prefixed source path' },
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
name: 'dest',
|
|
628
|
+
type: { kind: 'string' },
|
|
629
|
+
defaultValue: undefined,
|
|
630
|
+
annotations: { description: 'Mount-prefixed destination path' },
|
|
631
|
+
},
|
|
632
|
+
],
|
|
633
|
+
fn: move,
|
|
634
|
+
annotations: { description: 'Move file within mount' },
|
|
635
|
+
returnType: structureToTypeValue({ kind: 'bool' }),
|
|
636
|
+
}),
|
|
637
|
+
mounts: toCallable({
|
|
638
|
+
params: [],
|
|
639
|
+
fn: mountsList,
|
|
640
|
+
annotations: { description: 'List configured mounts' },
|
|
641
|
+
returnType: structureToTypeValue({ kind: 'list' }),
|
|
642
|
+
}),
|
|
653
643
|
},
|
|
654
644
|
};
|
|
655
645
|
}
|