functionalscript 0.38.0 → 0.40.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 (137) hide show
  1. package/README.md +1 -1
  2. package/fjs/bnf/descent/module.f.d.ts +43 -2
  3. package/fjs/bnf/descent/module.f.js +37 -12
  4. package/fjs/bnf/descent/proof.f.d.ts +1 -0
  5. package/fjs/bnf/descent/proof.f.js +73 -32
  6. package/fjs/bnf/ll1/module.f.js +2 -2
  7. package/fjs/bnf/token_symbol/module.f.d.ts +38 -0
  8. package/fjs/bnf/token_symbol/module.f.js +48 -0
  9. package/fjs/bnf/token_symbol/proof.f.d.ts +10 -0
  10. package/fjs/bnf/token_symbol/proof.f.js +37 -0
  11. package/fjs/cas/cli/module.f.js +6 -9
  12. package/fjs/cas/evo/module.f.d.ts +77 -13
  13. package/fjs/cas/evo/module.f.js +130 -18
  14. package/fjs/cas/evo/proof.f.d.ts +7 -0
  15. package/fjs/cas/evo/proof.f.js +120 -1
  16. package/fjs/cas/module.f.js +64 -37
  17. package/fjs/cas/proof.f.d.ts +3 -9
  18. package/fjs/cas/proof.f.js +94 -74
  19. package/fjs/ci/bun/module.f.js +3 -3
  20. package/fjs/ci/common/module.f.d.ts +1 -2
  21. package/fjs/ci/common/module.f.js +1 -5
  22. package/fjs/ci/config/module.f.d.ts +11 -8
  23. package/fjs/ci/config/module.f.js +24 -9
  24. package/fjs/ci/deno/module.f.js +3 -3
  25. package/fjs/ci/module.f.js +13 -7
  26. package/fjs/ci/nix/module.f.d.ts +61 -0
  27. package/fjs/ci/nix/module.f.js +92 -0
  28. package/fjs/ci/nix/proof.f.d.ts +23 -0
  29. package/fjs/ci/nix/proof.f.js +109 -0
  30. package/fjs/ci/node/module.f.d.ts +23 -1
  31. package/fjs/ci/node/module.f.js +58 -12
  32. package/fjs/ci/proof.f.d.ts +2 -0
  33. package/fjs/ci/proof.f.js +49 -9
  34. package/fjs/cli/module.f.js +2 -2
  35. package/fjs/common/monoid/module.f.d.ts +46 -2
  36. package/fjs/common/monoid/module.f.js +44 -0
  37. package/fjs/common/monoid/proof.f.d.ts +5 -0
  38. package/fjs/common/monoid/proof.f.js +27 -1
  39. package/fjs/dev/module.f.d.ts +1 -0
  40. package/fjs/dev/module.f.js +38 -27
  41. package/fjs/dev/update/module.f.d.ts +11 -0
  42. package/fjs/dev/update/module.f.js +20 -0
  43. package/fjs/dev/update/proof.f.d.ts +7 -0
  44. package/fjs/dev/update/proof.f.js +35 -0
  45. package/fjs/djs/ast/module.f.d.ts +47 -0
  46. package/fjs/djs/ast/module.f.js +9 -0
  47. package/fjs/djs/module.f.js +5 -8
  48. package/fjs/djs/parser/module.f.d.ts +3 -0
  49. package/fjs/djs/parser/module.f.js +17 -0
  50. package/fjs/djs/tokenizer/module.f.js +2 -2
  51. package/fjs/djs/tokenizer/proof.f.d.ts +1 -0
  52. package/fjs/djs/tokenizer/proof.f.js +70 -16
  53. package/fjs/djs/transpiler/module.f.js +6 -6
  54. package/fjs/effects/eff/module.f.d.ts +72 -0
  55. package/fjs/effects/eff/module.f.js +46 -0
  56. package/fjs/effects/eff/proof.f.d.ts +11 -0
  57. package/fjs/effects/eff/proof.f.js +58 -0
  58. package/fjs/effects/list/module.f.d.ts +11 -5
  59. package/fjs/effects/list/module.f.js +2 -1
  60. package/fjs/effects/memory/proof.f.js +7 -8
  61. package/fjs/effects/module.f.d.ts +334 -52
  62. package/fjs/effects/module.f.js +253 -45
  63. package/fjs/effects/node/memory/proof.js +3 -2
  64. package/fjs/effects/node/module.d.ts +3 -3
  65. package/fjs/effects/node/module.f.d.ts +18 -8
  66. package/fjs/effects/node/module.f.js +31 -11
  67. package/fjs/effects/node/module.js +12 -12
  68. package/fjs/effects/node/proof.f.d.ts +1 -0
  69. package/fjs/effects/node/proof.f.js +32 -11
  70. package/fjs/effects/node/virtual/module.f.js +1 -1
  71. package/fjs/effects/proof.f.d.ts +32 -6
  72. package/fjs/effects/proof.f.js +131 -39
  73. package/fjs/emergent_testing/all.test.js +2 -1
  74. package/fjs/emergent_testing/module.f.d.ts +3 -3
  75. package/fjs/emergent_testing/module.f.js +63 -49
  76. package/fjs/emergent_testing/proof.f.d.ts +4 -0
  77. package/fjs/emergent_testing/proof.f.js +54 -21
  78. package/fjs/emergent_testing/scenarios/thenable.pass.js +1 -1
  79. package/fjs/fsc/module.f.js +4 -4
  80. package/fjs/fsm/module.f.js +1 -1
  81. package/fjs/js/tokenizer/module.f.d.ts +1 -0
  82. package/fjs/js/tokenizer/module.f.js +13 -6
  83. package/fjs/{cas/mcp → mcp/cas}/module.f.d.ts +3 -25
  84. package/fjs/{cas/mcp → mcp/cas}/module.f.js +26 -64
  85. package/fjs/mcp/evo/module.f.d.ts +27 -0
  86. package/fjs/mcp/evo/module.f.js +94 -0
  87. package/fjs/{cas/evo/mcp → mcp/evo}/proof.f.d.ts +2 -0
  88. package/fjs/{cas/evo/mcp → mcp/evo}/proof.f.js +40 -9
  89. package/fjs/mcp/module.f.d.ts +54 -237
  90. package/fjs/mcp/module.f.js +55 -258
  91. package/fjs/mcp/proof.f.d.ts +43 -32
  92. package/fjs/mcp/proof.f.js +509 -200
  93. package/fjs/media/nix/module.f.d.ts +30 -0
  94. package/fjs/media/nix/module.f.js +166 -0
  95. package/fjs/media/nix/proof.f.d.ts +32 -0
  96. package/fjs/media/nix/proof.f.js +127 -0
  97. package/fjs/media/type/module.f.js +2 -2
  98. package/fjs/media/type/proof.f.js +7 -10
  99. package/fjs/module.f.js +5 -9
  100. package/fjs/protocol/json_rpc/module.f.d.ts +114 -0
  101. package/fjs/{media/json/rpc → protocol/json_rpc}/module.f.js +3 -3
  102. package/fjs/{media/json/rpc → protocol/json_rpc}/proof.f.js +3 -3
  103. package/fjs/protocol/mcp/module.f.d.ts +239 -0
  104. package/fjs/protocol/mcp/module.f.js +272 -0
  105. package/fjs/protocol/mcp/proof.f.d.ts +34 -0
  106. package/fjs/protocol/mcp/proof.f.js +208 -0
  107. package/fjs/{mcp → protocol/mcp}/stdio/module.f.d.ts +7 -7
  108. package/fjs/{mcp → protocol/mcp}/stdio/module.f.js +22 -22
  109. package/fjs/{mcp → protocol/mcp}/stdio/proof.f.js +9 -9
  110. package/fjs/types/bigint/module.f.js +4 -3
  111. package/fjs/types/bit_vec/module.f.js +5 -15
  112. package/fjs/types/btree/remove/module.f.d.ts +5 -0
  113. package/fjs/types/btree/remove/module.f.js +12 -0
  114. package/fjs/types/list/module.f.d.ts +21 -0
  115. package/fjs/types/list/module.f.js +17 -0
  116. package/fjs/types/list/proof.f.d.ts +1 -0
  117. package/fjs/types/list/proof.f.js +24 -1
  118. package/fjs/types/number/module.f.js +2 -1
  119. package/fjs/types/range_map/module.f.d.ts +14 -13
  120. package/fjs/types/range_map/module.f.js +18 -13
  121. package/fjs/types/range_map/proof.f.js +26 -39
  122. package/fjs/types/range_set/module.f.d.ts +5 -0
  123. package/fjs/types/range_set/module.f.js +16 -0
  124. package/fjs/types/range_set/proof.f.d.ts +1 -0
  125. package/fjs/types/range_set/proof.f.js +19 -0
  126. package/fjs/types/string/module.f.js +10 -2
  127. package/fjs/website/module.f.js +2 -3
  128. package/package.json +5 -5
  129. package/fjs/cas/evo/mcp/module.f.d.ts +0 -19
  130. package/fjs/cas/evo/mcp/module.f.js +0 -56
  131. package/fjs/cas/mcp/proof.f.d.ts +0 -45
  132. package/fjs/cas/mcp/proof.f.js +0 -545
  133. package/fjs/ci/playwright/module.f.d.ts +0 -2
  134. package/fjs/ci/playwright/module.f.js +0 -25
  135. package/fjs/media/json/rpc/module.f.d.ts +0 -114
  136. /package/fjs/{media/json/rpc → protocol/json_rpc}/proof.f.d.ts +0 -0
  137. /package/fjs/{mcp → protocol/mcp}/stdio/proof.f.d.ts +0 -0
@@ -13,25 +13,26 @@
13
13
  * })
14
14
  *
15
15
  * // Create range maps
16
- * const range1 = rmOps.fromRange([0, 10])(2)
17
- * const range2 = rmOps.fromRange([5, 15])(5)
16
+ * const range1 = rmOps.fromRange(2)([0, 10])
17
+ * const range2 = rmOps.fromRange(5)([5, 15])
18
18
  *
19
19
  * // Merge range maps
20
20
  * const merged = toArray(rmOps.merge(range1)(range2))
21
21
  *
22
22
  * // Retrieve values from the merged range map
23
+ * const get = rmOps.get(merged)
23
24
  * //
24
- * if (rmOps.get(-1)(merged) !== 0) { throw 'error' }
25
+ * if (get(-1) !== 0) { throw 'error' }
25
26
  * //
26
- * if (rmOps.get(0)(merged) !== 2) { throw 'error' }
27
- * if (rmOps.get(2)(merged) !== 2) { throw 'error' }
27
+ * if (get(0) !== 2) { throw 'error' }
28
+ * if (get(2) !== 2) { throw 'error' }
28
29
  * // overlapped: 2 | 5 = 7
29
- * if (rmOps.get(7)(merged) !== 7) { throw 'error' }
30
+ * if (get(7) !== 7) { throw 'error' }
30
31
  * //
31
- * if (rmOps.get(12)(merged) !== 5) { throw 'error' }
32
- * if (rmOps.get(15)(merged) !== 5) { throw 'error' }
32
+ * if (get(12) !== 5) { throw 'error' }
33
+ * if (get(15) !== 5) { throw 'error' }
33
34
  * //
34
- * if (rmOps.get(16)(merged) !== 0) { throw 'error' }
35
+ * if (get(16) !== 0) { throw 'error' }
35
36
  * ```
36
37
  */
37
38
  import { genericMerge } from '../sorted_list/module.f.js';
@@ -59,11 +60,15 @@ const tailReduce = equal => state => tail => {
59
60
  return { first: state, tail: tailResult };
60
61
  };
61
62
  export const merge = op => genericMerge({ reduceOp: reduceOp(op), tailReduce: tailReduce(op.equal) })(null);
62
- export const get = def => value => rm => {
63
- const pos = bsearch(rm.length)(mid => value <= rm[mid][1] ? -1 : 1);
64
- return pos < rm.length ? rm[pos][0] : def;
63
+ export const get = def => rm => {
64
+ const length = rm.length;
65
+ const search = bsearch(length);
66
+ return value => {
67
+ const pos = search(mid => value <= rm[mid][1] ? -1 : 1);
68
+ return pos < length ? rm[pos][0] : def;
69
+ };
65
70
  };
66
- export const fromRange = def => ([a, b]) => v => [[def, a - 1], [v, b]];
71
+ export const fromRange = def => v => ([a, b]) => [[def, a - 1], [v, b]];
67
72
  /**
68
73
  * Creates a set of operations for managing range maps using the specified properties.
69
74
  *
@@ -20,23 +20,24 @@ export const proof = {
20
20
  def: 0,
21
21
  });
22
22
  // Create range maps
23
- const range1 = rmOps.fromRange([0, 10])(2);
24
- const range2 = rmOps.fromRange([5, 15])(5);
23
+ const range1 = rmOps.fromRange(2)([0, 10]);
24
+ const range2 = rmOps.fromRange(5)([5, 15]);
25
25
  // Merge range maps
26
26
  const merged = toArray(rmOps.merge(range1)(range2));
27
27
  // Retrieve values from the merged range map
28
28
  //
29
- assertEq(rmOps.get(-1)(merged), 0, 'error');
29
+ const get = rmOps.get(merged);
30
+ assertEq(get(-1), 0, 'error');
30
31
  //
31
- assertEq(rmOps.get(0)(merged), 2, 'error');
32
- assertEq(rmOps.get(2)(merged), 2, 'error');
32
+ assertEq(get(0), 2, 'error');
33
+ assertEq(get(2), 2, 'error');
33
34
  // 2 | 5 = 7
34
- assertEq(rmOps.get(7)(merged), 7, 'error');
35
+ assertEq(get(7), 7, 'error');
35
36
  //
36
- assertEq(rmOps.get(12)(merged), 5, 'error');
37
- assertEq(rmOps.get(15)(merged), 5, 'error');
37
+ assertEq(get(12), 5, 'error');
38
+ assertEq(get(15), 5, 'error');
38
39
  //
39
- assertEq(rmOps.get(16)(merged), 0, 'error');
40
+ assertEq(get(16), 0, 'error');
40
41
  },
41
42
  merge: [
42
43
  () => {
@@ -95,70 +96,56 @@ export const proof = {
95
96
  return [
96
97
  () => {
97
98
  const rm = [[['a'], 10], [['b'], 20], [['c'], 30]];
98
- const result = str(at(5)(rm));
99
+ const result = str(at(rm)(5));
99
100
  assertEq(result, '["a"]');
100
101
  },
101
102
  () => {
102
103
  const rm = [[['a'], 10], [['b'], 20], [['c'], 30]];
103
- const result = str(at(10)(rm));
104
+ const result = str(at(rm)(10));
104
105
  assertEq(result, '["a"]');
105
106
  },
106
107
  () => {
107
108
  const rm = [[['a'], 10], [['b'], 20], [['c'], 30]];
108
- const result = str(at(15)(rm));
109
+ const result = str(at(rm)(15));
109
110
  assertEq(result, '["b"]');
110
111
  },
111
112
  () => {
112
113
  const rm = [[['a'], 10], [['b'], 20], [['c'], 30]];
113
- const result = str(at(20)(rm));
114
+ const result = str(at(rm)(20));
114
115
  assertEq(result, '["b"]');
115
116
  },
116
117
  () => {
117
118
  const rm = [[['a'], 10], [['b'], 20], [['c'], 30]];
118
- const result = str(at(25)(rm));
119
+ const result = str(at(rm)(25));
119
120
  assertEq(result, '["c"]');
120
121
  },
121
122
  () => {
122
123
  const rm = [[['a'], 10], [['b'], 20], [['c'], 30]];
123
- const result = str(at(30)(rm));
124
+ const result = str(at(rm)(30));
124
125
  assertEq(result, '["c"]');
125
126
  },
126
127
  () => {
127
128
  const rm = [[['a'], 10], [['b'], 20], [['c'], 30]];
128
- const result = str(at(35)(rm));
129
+ const result = str(at(rm)(35));
129
130
  assertEq(result, '[]');
130
131
  },
131
132
  () => {
132
133
  const rm = [];
133
- const result = str(at(10)(rm));
134
+ const result = str(at(rm)(10));
134
135
  assertEq(result, '[]');
135
136
  }
136
137
  ];
137
138
  },
138
139
  fromRange: () => {
139
140
  const def = -1;
140
- const rm = fromRange(def)([1, 7])(42);
141
+ const rm = fromRange(def)(42)([1, 7]);
142
+ const g = get(def)(rm);
141
143
  return [
142
- () => {
143
- const result = get(def)(0)(rm);
144
- assertEq(result, -1);
145
- },
146
- () => {
147
- const result = get(def)(1)(rm);
148
- assertEq(result, 42);
149
- },
150
- () => {
151
- const result = get(def)(3)(rm);
152
- assertEq(result, 42);
153
- },
154
- () => {
155
- const result = get(def)(7)(rm);
156
- assertEq(result, 42);
157
- },
158
- () => {
159
- const result = get(def)(9)(rm);
160
- assertEq(result, -1);
161
- },
144
+ () => assertEq(g(0), -1),
145
+ () => assertEq(g(1), 42),
146
+ () => assertEq(g(3), 42),
147
+ () => assertEq(g(7), 42),
148
+ () => assertEq(g(9), -1),
162
149
  ];
163
- }
150
+ },
164
151
  };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Constructs a range set containing a single numeric range.
3
+ */
4
+ export declare const fromRange: (r: import("../range/module.f.ts").Range) => import("../range_map/module.f.ts").RangeMapArray<boolean>;
5
+ export declare const merge: import("../range_map/module.f.ts").RangeMerge<boolean>, get: (rm: import("../range_map/module.f.ts").RangeMapArray<boolean>) => (value: number) => boolean;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A set of numeric ranges, represented as a `range_map` of `boolean`.
3
+ *
4
+ * @module
5
+ */
6
+ import { rangeMap } from '../range_map/module.f.js';
7
+ const map = rangeMap({
8
+ union: a => b => a || b,
9
+ equal: a => b => a === b,
10
+ def: false,
11
+ });
12
+ /**
13
+ * Constructs a range set containing a single numeric range.
14
+ */
15
+ export const fromRange = map.fromRange(true);
16
+ export const { merge, get } = map;
@@ -0,0 +1 @@
1
+ export declare const proof: () => void;
@@ -0,0 +1,19 @@
1
+ import { assert } from "../../asserts/module.f.js";
2
+ import { toArray } from "../list/module.f.js";
3
+ import { fromRange, merge, get } from "./module.f.js";
4
+ import {} from '../range/module.f.js';
5
+ const c = (a) => a.charCodeAt(0);
6
+ const range = ([a, b]) => [c(a), c(b)];
7
+ export const proof = () => {
8
+ const digit = fromRange(range('09'));
9
+ const initial = toArray(merge(fromRange(range('AZ')))(fromRange(range('az'))));
10
+ const isInitial = get(initial);
11
+ assert(!isInitial(0));
12
+ assert(isInitial(c('a')));
13
+ assert(!isInitial(c('1')));
14
+ assert(isInitial(c('Z')));
15
+ const isNext = get(toArray(merge(initial)(digit)));
16
+ assert(isNext(c('0')));
17
+ assert(isNext(c('A')));
18
+ assert(!isNext(c('@')));
19
+ };
@@ -18,10 +18,18 @@
18
18
  import { reduce as listReduce, repeat as listRepeat } from '../list/module.f.js';
19
19
  import { compose } from '../function/module.f.js';
20
20
  import { cmp as uCmp } from '../function/compare/module.f.js';
21
- import { join as joinOp, concat as concatOp } from '../function/operator/module.f.js';
21
+ import { join as joinOp } from '../function/operator/module.f.js';
22
+ import { fold } from '../../common/monoid/module.f.js';
23
+ // `join`'s per-separator reduction is seeded at `''` but is *not* a monoid fold:
24
+ // `joinOp(sep)` has no identity (`joinOp(sep)('')(x)` prepends a separator), so
25
+ // it stays a hand-seeded `reduce` rather than going through `monoid.fold`.
22
26
  const reduce = o => listReduce(o)('');
23
27
  export const join = compose(joinOp)(reduce);
24
- export const concat = reduce(concatOp);
28
+ // String concatenation with identity `''` is a lawful monoid, so `concat` is a
29
+ // monoid fold. The operation is accumulator-first (`a` on the left), matching
30
+ // `monoid.fold`'s convention — unlike the element-first `concat` in
31
+ // `function/operator`, which is written for `list.reduce`.
32
+ export const concat = fold({ identity: '', operation: a => b => a + b });
25
33
  export const repeat = v => compose(listRepeat(v))(concat);
26
34
  export const cmp = uCmp;
27
35
  export const splitAt = (p) => (v) => [v.substring(0, p), v.substring(p)];
@@ -5,11 +5,10 @@
5
5
  */
6
6
  import { htmlUtf8 } from '../media/html/module.f.js';
7
7
  import { writeFile } from '../effects/node/module.f.js';
8
- import { pure } from '../effects/module.f.js';
8
+ import { pure, step } from '../effects/module.f.js';
9
9
  const html = htmlUtf8()(['a',
10
10
  { href: 'https://github.com/functionalscript/functionalscript' },
11
11
  'GitHub Repository'
12
12
  ]);
13
- const program = writeFile('index.html', html)
14
- .step(() => pure(0));
13
+ const program = step(writeFile('index.html', html), () => pure(0));
15
14
  export const main = () => program;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.38.0",
3
+ "version": "0.40.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "**/*.js",
@@ -13,7 +13,8 @@
13
13
  "cov": "node --test --experimental-test-coverage --test-coverage-include=**/module.f.ts",
14
14
  "start": "node ./fjs/module.ts",
15
15
  "ci-update": "node ./fjs/module.ts ci",
16
- "update": "npx npm-check-updates -u && npm install && deno install && bun install && npm run ci-update",
16
+ "dev-update": "node ./fjs/module.ts r ./fjs/dev/update/module.f.ts",
17
+ "update": "npm run ci-update && npm install && deno install && bun install",
17
18
  "index-html": "node ./fjs/module.ts r ./fjs/website/module.f.ts",
18
19
  "website": "npm run prepack && npm run index-html"
19
20
  },
@@ -43,8 +44,7 @@
43
44
  },
44
45
  "homepage": "https://github.com/functionalscript/functionalscript#readme",
45
46
  "devDependencies": {
46
- "@playwright/test": "1.61.1",
47
- "@types/node": "26.1.1",
48
- "typescript": "7.0.2"
47
+ "@types/node": "=26.0.0",
48
+ "typescript": "=7.0.2"
49
49
  }
50
50
  }
@@ -1,19 +0,0 @@
1
- import { type Operation } from '../../../effects/module.f.ts';
2
- import { type MemOp } from '../../../effects/memory/module.f.ts';
3
- import { type ToolEntry } from '../../../mcp/module.f.ts';
4
- import { type Evo } from '../module.f.ts';
5
- /** Arguments for `evo_list`: none. */
6
- export declare const evoListArgs: {};
7
- /** Arguments for `evo_head`: the subject whose current heads are requested. */
8
- export declare const evoHeadArgs: {
9
- readonly subject: import("../../../types/rtti/module.f.ts").String;
10
- };
11
- /** Arguments for `evo_add`: a new revision, per `fjs/cas/evo`'s `AddRevision`. */
12
- export declare const evoAddArgs: {
13
- readonly parents: import("../../../types/rtti/module.f.ts").Type1<"array", import("../../../types/rtti/module.f.ts").String>;
14
- readonly snapshot: import("../../../types/rtti/module.f.ts").Or<readonly [import("../../../types/rtti/module.f.ts").String, undefined]>;
15
- readonly subject: import("../../../types/rtti/module.f.ts").Or<readonly [import("../../../types/rtti/module.f.ts").String, undefined]>;
16
- readonly archived: import("../../../types/rtti/module.f.ts").Or<readonly [true, undefined]>;
17
- };
18
- /** Registry of all Evo tools, bound to an `Evo<O>`. */
19
- export declare const evoToolRegistry: <O extends Operation>(e: Evo<O>) => readonly ToolEntry<O | MemOp>[];
@@ -1,56 +0,0 @@
1
- /**
2
- * MCP tool definitions for the Evo API (`fjs/cas/evo/module.f.ts`): subjects
3
- * and revision heads over the content-addressable store, backed by the
4
- * in-memory cache the core module maintains.
5
- *
6
- * ## Tools
7
- *
8
- * | Tool | args | action | result |
9
- * |-------------|-------------------------------------------|---------------|---------------------------|
10
- * | `evo_list` | `{}` | `e.list()` | subjects, as a JSON array of strings |
11
- * | `evo_head` | `{ subject }` | `e.head(...)` | head hashes, one per line |
12
- * | `evo_add` | `{ parents, snapshot?, subject?, archived? }` | `e.add(...)` | hash (cBase32) |
13
- *
14
- * These tools are not served by their own process: `fjs/cas/mcp` (the same
15
- * server as `cas_add`/`cas_get`/`cas_list`) builds one `Evo<O>` from its own
16
- * `Cas<O>` and cache slot, concatenates `evoToolRegistry` onto its own
17
- * registry, and serves everything from that single process — one `~/.cas/`
18
- * store, one Evo cache, one server.
19
- *
20
- * @module
21
- */
22
- import { string, option, array } from '../../../types/rtti/module.f.js';
23
- import { pure } from '../../../effects/module.f.js';
24
- import {} from '../../../effects/memory/module.f.js';
25
- import { toolEntry, errorResult, okResult, } from '../../../mcp/module.f.js';
26
- import { stringify } from '../../../media/json/module.f.js';
27
- import { identity } from '../../../types/function/module.f.js';
28
- import {} from '../module.f.js';
29
- // ── Argument schemas (declared once, used for both inputSchema and validate) ─────
30
- /** Arguments for `evo_list`: none. */
31
- export const evoListArgs = {};
32
- /** Arguments for `evo_head`: the subject whose current heads are requested. */
33
- export const evoHeadArgs = {
34
- subject: string,
35
- };
36
- /** Arguments for `evo_add`: a new revision, per `fjs/cas/evo`'s `AddRevision`. */
37
- export const evoAddArgs = {
38
- parents: array(string),
39
- snapshot: option(string),
40
- subject: option(string),
41
- archived: option(true),
42
- };
43
- // ── Tool registry ────────────────────────────────────────────────────────────────
44
- /** Canonical JSON encoder for `evo_list`'s result. */
45
- const toJson = stringify(identity);
46
- /** Registry of all Evo tools, bound to an `Evo<O>`. */
47
- export const evoToolRegistry = (e) => [
48
- toolEntry('evo_list', 'List all subjects with at least one stored revision, as a JSON array of strings.', evoListArgs,
49
- // Subjects are arbitrary caller-supplied strings (unlike hashes, not
50
- // constrained to a newline-free alphabet), so a `join('\n')` line
51
- // format could not represent an empty subject or one containing a
52
- // newline without ambiguity — JSON encoding can.
53
- () => e.list().step(subjects => pure(okResult(toJson(subjects))))),
54
- toolEntry('evo_head', 'List the current head hashes (cBase32) of a subject, one per line. Empty when the subject is unknown.', evoHeadArgs, ({ subject }) => e.head(subject).step(heads => pure(okResult(heads.join('\n'))))),
55
- toolEntry('evo_add', 'Add a new revision (a `vnd.fjs.revision` blob) and return its hash (cBase32). `subject` is required unless there is exactly one parent, from which it is inherited. `snapshot`, when omitted, is resolved from the parents (zero parents → `subject`, one parent → the parent\'s snapshot; a merge requires an explicit `snapshot`) and written explicitly. `generation` is computed by the server.', evoAddArgs, (input) => e.add(input).step(result => pure(result[0] === 'error' ? errorResult(result[1]) : okResult(result[1])))),
56
- ];
@@ -1,45 +0,0 @@
1
- export declare const proof: {
2
- getMetaLargeMultiChunkBlobNoError: () => void;
3
- getMetaLargeMultiChunkUtf8Symbols: () => void;
4
- getMetaLargeMultiChunkTextThenBinary: () => void;
5
- getContentLargeBlobTooLargeError: () => void;
6
- getContentMissingHashIsError: () => void;
7
- getContentBase64InflationOverflowWritesInternalError: () => void;
8
- getContentBase64NearBoundarySucceeds: () => void;
9
- getContentDoubleEscapedOverflowWritesInternalError: () => void;
10
- toolsListAdvertisesSixTools: () => void;
11
- evoAddListHeadRoundTripsThroughCasServer: () => void;
12
- evoAddDomainErrorIsErrorThroughCasServer: () => void;
13
- casAddSyncsEvoCacheForRevisionContent: () => void;
14
- addReturnsHash: () => void;
15
- textAddGetMetaRoundTrips: () => void;
16
- textAddGetContentRoundTrips: () => void;
17
- binaryAddGetMetaRoundTrips: () => void;
18
- binaryAddGetContentRoundTrips: () => void;
19
- addGetRoundTrips: () => void;
20
- getUntypedReturnsText: () => void;
21
- getTypedReturnsBinaryJson: () => void;
22
- getMetaRecognizesRevisionDialect: () => void;
23
- getContentRecognizesRevisionDialect: () => void;
24
- listEnumeratesStoredHashes: () => void;
25
- addInvalidContentIsError: () => void;
26
- addBadLengthContentIsError: () => void;
27
- addBase64OverLimitIsError: () => void;
28
- addTextOverLimitIsError: () => void;
29
- addTextAtLimitSucceeds: () => void;
30
- addBase64AtLimitSucceeds: () => void;
31
- getUnterminatedHashIsError: () => void;
32
- addMissingContentIsError: () => void;
33
- getMissingHashArgumentIsError: () => void;
34
- getInvalidHashIsError: () => void;
35
- getMissingHashIsError: () => void;
36
- unknownToolIsError: () => void;
37
- toolErrorIsNotJsonRpcError: () => void;
38
- getMetaReturnsLengthAndMimeType: () => void;
39
- getMetaBinaryBlob: () => void;
40
- getMetaOctetStreamForUnknownBinary: () => void;
41
- getMetaOctetStreamForNulBlob: () => void;
42
- getMetaMissingHashIsError: () => void;
43
- getMetaInvalidHashIsError: () => void;
44
- getOctetStreamWithContentIncludesBase64: () => void;
45
- };