rhachet 1.1.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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/dist/__nonpublished_modules__/file-fns/src/getFile.d.ts +6 -0
  3. package/dist/__nonpublished_modules__/file-fns/src/getFile.js +14 -0
  4. package/dist/__nonpublished_modules__/file-fns/src/getFile.js.map +1 -0
  5. package/dist/__test_assets__/directory.d.ts +1 -0
  6. package/dist/__test_assets__/directory.js +5 -0
  7. package/dist/__test_assets__/directory.js.map +1 -0
  8. package/dist/__test_assets__/genContextLogTrail.d.ts +2 -0
  9. package/dist/__test_assets__/genContextLogTrail.js +12 -0
  10. package/dist/__test_assets__/genContextLogTrail.js.map +1 -0
  11. package/dist/__test_assets__/genContextStitchTrail.d.ts +2 -0
  12. package/dist/__test_assets__/genContextStitchTrail.js +8 -0
  13. package/dist/__test_assets__/genContextStitchTrail.js.map +1 -0
  14. package/dist/__test_assets__/getContextOpenAI.d.ts +2 -0
  15. package/dist/__test_assets__/getContextOpenAI.js +18 -0
  16. package/dist/__test_assets__/getContextOpenAI.js.map +1 -0
  17. package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.d.ts +14 -0
  18. package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.js +23 -0
  19. package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.js.map +1 -0
  20. package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.d.ts +16 -0
  21. package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.js +29 -0
  22. package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.js.map +1 -0
  23. package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.d.ts +15 -0
  24. package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.js +97 -0
  25. package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.js.map +1 -0
  26. package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.d.ts +13 -0
  27. package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.js +33 -0
  28. package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.js.map +1 -0
  29. package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.d.ts +13 -0
  30. package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.js +45 -0
  31. package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.js.map +1 -0
  32. package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.d.ts +29 -0
  33. package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.js +76 -0
  34. package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.js.map +1 -0
  35. package/dist/__test_assets__/threads/codeArtist.d.ts +6 -0
  36. package/dist/__test_assets__/threads/codeArtist.js +26 -0
  37. package/dist/__test_assets__/threads/codeArtist.js.map +1 -0
  38. package/dist/__test_assets__/threads/codeCritic.d.ts +6 -0
  39. package/dist/__test_assets__/threads/codeCritic.js +21 -0
  40. package/dist/__test_assets__/threads/codeCritic.js.map +1 -0
  41. package/dist/__test_assets__/threads/director.d.ts +6 -0
  42. package/dist/__test_assets__/threads/director.js +14 -0
  43. package/dist/__test_assets__/threads/director.js.map +1 -0
  44. package/dist/contract/sdk.d.ts +8 -0
  45. package/dist/contract/sdk.js +33 -0
  46. package/dist/contract/sdk.js.map +1 -0
  47. package/dist/domain/objects/Stitch.d.ts +42 -0
  48. package/dist/domain/objects/Stitch.js +9 -0
  49. package/dist/domain/objects/Stitch.js.map +1 -0
  50. package/dist/domain/objects/StitchChoice.d.ts +30 -0
  51. package/dist/domain/objects/StitchChoice.js +8 -0
  52. package/dist/domain/objects/StitchChoice.js.map +1 -0
  53. package/dist/domain/objects/StitchCycle.d.ts +44 -0
  54. package/dist/domain/objects/StitchCycle.js +8 -0
  55. package/dist/domain/objects/StitchCycle.js.map +1 -0
  56. package/dist/domain/objects/StitchFanout.d.ts +35 -0
  57. package/dist/domain/objects/StitchFanout.js +8 -0
  58. package/dist/domain/objects/StitchFanout.js.map +1 -0
  59. package/dist/domain/objects/StitchRoute.d.ts +22 -0
  60. package/dist/domain/objects/StitchRoute.js +8 -0
  61. package/dist/domain/objects/StitchRoute.js.map +1 -0
  62. package/dist/domain/objects/StitchSetEvent.d.ts +23 -0
  63. package/dist/domain/objects/StitchSetEvent.js +8 -0
  64. package/dist/domain/objects/StitchSetEvent.js.map +1 -0
  65. package/dist/domain/objects/StitchStep.d.ts +55 -0
  66. package/dist/domain/objects/StitchStep.js +11 -0
  67. package/dist/domain/objects/StitchStep.js.map +1 -0
  68. package/dist/domain/objects/StitchTrail.d.ts +26 -0
  69. package/dist/domain/objects/StitchTrail.js +19 -0
  70. package/dist/domain/objects/StitchTrail.js.map +1 -0
  71. package/dist/domain/objects/Stitcher.d.ts +105 -0
  72. package/dist/domain/objects/Stitcher.js +49 -0
  73. package/dist/domain/objects/Stitcher.js.map +1 -0
  74. package/dist/domain/objects/Stitcher.test.d.ts +1 -0
  75. package/dist/domain/objects/Stitcher.test.js +78 -0
  76. package/dist/domain/objects/Stitcher.test.js.map +1 -0
  77. package/dist/domain/objects/Thread.d.ts +31 -0
  78. package/dist/domain/objects/Thread.js +11 -0
  79. package/dist/domain/objects/Thread.js.map +1 -0
  80. package/dist/domain/objects/Threads.d.ts +56 -0
  81. package/dist/domain/objects/Threads.js +26 -0
  82. package/dist/domain/objects/Threads.js.map +1 -0
  83. package/dist/domain/objects/Weave.d.ts +0 -0
  84. package/dist/domain/objects/Weave.js +2 -0
  85. package/dist/domain/objects/Weave.js.map +1 -0
  86. package/dist/domain/objects/Weaver.d.ts +5 -0
  87. package/dist/domain/objects/Weaver.js +7 -0
  88. package/dist/domain/objects/Weaver.js.map +1 -0
  89. package/dist/domain/objects/index.d.ts +11 -0
  90. package/dist/domain/objects/index.js +30 -0
  91. package/dist/domain/objects/index.js.map +1 -0
  92. package/dist/index.d.ts +1 -0
  93. package/dist/index.js +18 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/logic/stitch/adapters/imagineViaOpenAI.d.ts +13 -0
  96. package/dist/logic/stitch/adapters/imagineViaOpenAI.js +36 -0
  97. package/dist/logic/stitch/adapters/imagineViaOpenAI.js.map +1 -0
  98. package/dist/logic/stitch/enstitch.d.ts +27 -0
  99. package/dist/logic/stitch/enstitch.js +97 -0
  100. package/dist/logic/stitch/enstitch.js.map +1 -0
  101. package/dist/logic/stitch/enstitch.test.d.ts +1 -0
  102. package/dist/logic/stitch/enstitch.test.js +87 -0
  103. package/dist/logic/stitch/enstitch.test.js.map +1 -0
  104. package/dist/logic/stitch/invokeImagineStitcher.d.ts +10 -0
  105. package/dist/logic/stitch/invokeImagineStitcher.integration.test.d.ts +1 -0
  106. package/dist/logic/stitch/invokeImagineStitcher.integration.test.js +193 -0
  107. package/dist/logic/stitch/invokeImagineStitcher.integration.test.js.map +1 -0
  108. package/dist/logic/stitch/invokeImagineStitcher.js +23 -0
  109. package/dist/logic/stitch/invokeImagineStitcher.js.map +1 -0
  110. package/dist/logic/stitch/withStitchTrail.d.ts +16 -0
  111. package/dist/logic/stitch/withStitchTrail.js +40 -0
  112. package/dist/logic/stitch/withStitchTrail.js.map +1 -0
  113. package/dist/logic/thread/enroleThread.d.ts +4 -0
  114. package/dist/logic/thread/enroleThread.js +6 -0
  115. package/dist/logic/thread/enroleThread.js.map +1 -0
  116. package/dist/logic/thread/genThread.d.ts +7 -0
  117. package/dist/logic/thread/genThread.js +10 -0
  118. package/dist/logic/thread/genThread.js.map +1 -0
  119. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.d.ts +17 -0
  120. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.js +3 -0
  121. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.js.map +1 -0
  122. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.d.ts +1 -0
  123. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js +67 -0
  124. package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js.map +1 -0
  125. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.d.ts +18 -0
  126. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.js +3 -0
  127. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.js.map +1 -0
  128. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.d.ts +1 -0
  129. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js +132 -0
  130. package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js.map +1 -0
  131. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.d.ts +23 -0
  132. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.js +3 -0
  133. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.js.map +1 -0
  134. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.d.ts +1 -0
  135. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js +74 -0
  136. package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js.map +1 -0
  137. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.d.ts +24 -0
  138. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.js +3 -0
  139. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.js.map +1 -0
  140. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.d.ts +1 -0
  141. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js +190 -0
  142. package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js.map +1 -0
  143. package/dist/logic/weave/compose/ProcedureContextMerged.generic.d.ts +36 -0
  144. package/dist/logic/weave/compose/ProcedureContextMerged.generic.js +3 -0
  145. package/dist/logic/weave/compose/ProcedureContextMerged.generic.js.map +1 -0
  146. package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.d.ts +1 -0
  147. package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js +29 -0
  148. package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js.map +1 -0
  149. package/dist/logic/weave/compose/ThreadsMerged.generic.d.ts +65 -0
  150. package/dist/logic/weave/compose/ThreadsMerged.generic.js +3 -0
  151. package/dist/logic/weave/compose/ThreadsMerged.generic.js.map +1 -0
  152. package/dist/logic/weave/compose/ThreadsMerged.generic.test.d.ts +1 -0
  153. package/dist/logic/weave/compose/ThreadsMerged.generic.test.js +420 -0
  154. package/dist/logic/weave/compose/ThreadsMerged.generic.test.js.map +1 -0
  155. package/dist/logic/weave/compose/asStitcher.d.ts +12 -0
  156. package/dist/logic/weave/compose/asStitcher.js +15 -0
  157. package/dist/logic/weave/compose/asStitcher.js.map +1 -0
  158. package/dist/logic/weave/compose/asStitcher.test.d.ts +1 -0
  159. package/dist/logic/weave/compose/asStitcher.test.js +95 -0
  160. package/dist/logic/weave/compose/asStitcher.test.js.map +1 -0
  161. package/dist/logic/weave/compose/asStitcherFlat.d.ts +10 -0
  162. package/dist/logic/weave/compose/asStitcherFlat.js +13 -0
  163. package/dist/logic/weave/compose/asStitcherFlat.js.map +1 -0
  164. package/dist/logic/weave/compose/asStitcherFlat.test.d.ts +1 -0
  165. package/dist/logic/weave/compose/asStitcherFlat.test.js +96 -0
  166. package/dist/logic/weave/compose/asStitcherFlat.test.js.map +1 -0
  167. package/dist/logic/weave/compose/genStitchChoice.d.ts +22 -0
  168. package/dist/logic/weave/compose/genStitchChoice.js +23 -0
  169. package/dist/logic/weave/compose/genStitchChoice.js.map +1 -0
  170. package/dist/logic/weave/compose/genStitchChoice.test.d.ts +1 -0
  171. package/dist/logic/weave/compose/genStitchChoice.test.js +200 -0
  172. package/dist/logic/weave/compose/genStitchChoice.test.js.map +1 -0
  173. package/dist/logic/weave/compose/genStitchCycle.d.ts +28 -0
  174. package/dist/logic/weave/compose/genStitchCycle.js +30 -0
  175. package/dist/logic/weave/compose/genStitchCycle.js.map +1 -0
  176. package/dist/logic/weave/compose/genStitchCycle.test.d.ts +1 -0
  177. package/dist/logic/weave/compose/genStitchCycle.test.js +152 -0
  178. package/dist/logic/weave/compose/genStitchCycle.test.js.map +1 -0
  179. package/dist/logic/weave/compose/genStitchFanout.d.ts +17 -0
  180. package/dist/logic/weave/compose/genStitchFanout.js +21 -0
  181. package/dist/logic/weave/compose/genStitchFanout.js.map +1 -0
  182. package/dist/logic/weave/compose/genStitchFanout.test.d.ts +1 -0
  183. package/dist/logic/weave/compose/genStitchFanout.test.js +79 -0
  184. package/dist/logic/weave/compose/genStitchFanout.test.js.map +1 -0
  185. package/dist/logic/weave/compose/genStitchRoute.d.ts +15 -0
  186. package/dist/logic/weave/compose/genStitchRoute.js +20 -0
  187. package/dist/logic/weave/compose/genStitchRoute.js.map +1 -0
  188. package/dist/logic/weave/compose/genStitchRoute.test.d.ts +1 -0
  189. package/dist/logic/weave/compose/genStitchRoute.test.js +120 -0
  190. package/dist/logic/weave/compose/genStitchRoute.test.js.map +1 -0
  191. package/dist/logic/weave/enweave.d.ts +0 -0
  192. package/dist/logic/weave/enweave.js +2 -0
  193. package/dist/logic/weave/enweave.js.map +1 -0
  194. package/dist/logic/weave/enweaveAllStitchers.d.ts +0 -0
  195. package/dist/logic/weave/enweaveAllStitchers.js +2 -0
  196. package/dist/logic/weave/enweaveAllStitchers.js.map +1 -0
  197. package/dist/logic/weave/enweaveOneChoice.d.ts +14 -0
  198. package/dist/logic/weave/enweaveOneChoice.js +48 -0
  199. package/dist/logic/weave/enweaveOneChoice.js.map +1 -0
  200. package/dist/logic/weave/enweaveOneChoice.test.d.ts +1 -0
  201. package/dist/logic/weave/enweaveOneChoice.test.js +181 -0
  202. package/dist/logic/weave/enweaveOneChoice.test.js.map +1 -0
  203. package/dist/logic/weave/enweaveOneCycle.d.ts +19 -0
  204. package/dist/logic/weave/enweaveOneCycle.js +98 -0
  205. package/dist/logic/weave/enweaveOneCycle.js.map +1 -0
  206. package/dist/logic/weave/enweaveOneCycle.test.d.ts +1 -0
  207. package/dist/logic/weave/enweaveOneCycle.test.js +180 -0
  208. package/dist/logic/weave/enweaveOneCycle.test.js.map +1 -0
  209. package/dist/logic/weave/enweaveOneFanout.d.ts +12 -0
  210. package/dist/logic/weave/enweaveOneFanout.integration.test.d.ts +1 -0
  211. package/dist/logic/weave/enweaveOneFanout.integration.test.js +166 -0
  212. package/dist/logic/weave/enweaveOneFanout.integration.test.js.map +1 -0
  213. package/dist/logic/weave/enweaveOneFanout.js +37 -0
  214. package/dist/logic/weave/enweaveOneFanout.js.map +1 -0
  215. package/dist/logic/weave/enweaveOneRoute.d.ts +12 -0
  216. package/dist/logic/weave/enweaveOneRoute.integration.test.d.ts +1 -0
  217. package/dist/logic/weave/enweaveOneRoute.integration.test.js +159 -0
  218. package/dist/logic/weave/enweaveOneRoute.integration.test.js.map +1 -0
  219. package/dist/logic/weave/enweaveOneRoute.js +33 -0
  220. package/dist/logic/weave/enweaveOneRoute.js.map +1 -0
  221. package/dist/logic/weave/enweaveOneStitcher.d.ts +11 -0
  222. package/dist/logic/weave/enweaveOneStitcher.integration.test.d.ts +2 -0
  223. package/dist/logic/weave/enweaveOneStitcher.integration.test.js +258 -0
  224. package/dist/logic/weave/enweaveOneStitcher.integration.test.js.map +1 -0
  225. package/dist/logic/weave/enweaveOneStitcher.js +42 -0
  226. package/dist/logic/weave/enweaveOneStitcher.js.map +1 -0
  227. package/package.json +88 -0
  228. package/readme.md +61 -0
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const test_fns_1 = require("test-fns");
4
+ const genContextLogTrail_1 = require("../../__test_assets__/genContextLogTrail");
5
+ const genContextStitchTrail_1 = require("../../__test_assets__/genContextStitchTrail");
6
+ const StitchStep_1 = require("../../domain/objects/StitchStep");
7
+ const Thread_1 = require("../../domain/objects/Thread");
8
+ const enstitch_1 = require("./enstitch");
9
+ describe('enstitch', () => {
10
+ const context = { ...(0, genContextStitchTrail_1.genContextStitchTrail)(), ...(0, genContextLogTrail_1.genContextLogTrail)() };
11
+ (0, test_fns_1.given)('a compute stitcher with a single thread', () => {
12
+ const threadMain = new Thread_1.Thread({
13
+ context: { role: 'main' },
14
+ stitches: [],
15
+ });
16
+ const stitcher = new StitchStep_1.StitchStepCompute({
17
+ slug: 'mock-step',
18
+ readme: null,
19
+ form: 'COMPUTE',
20
+ stitchee: 'main',
21
+ invoke: () => ({ input: 'in', output: 'out' }),
22
+ });
23
+ (0, test_fns_1.when)('enstitch is called', () => {
24
+ (0, test_fns_1.then)('it should append the stitch to the thread', async () => {
25
+ const result = await (0, enstitch_1.enstitch)({ stitcher, threads: { main: threadMain } }, context);
26
+ expect(result.stitch.output).toEqual('out');
27
+ expect(result.threads.main.stitches.length).toBe(1);
28
+ expect(result.threads.main.stitches[0].output).toEqual('out');
29
+ });
30
+ });
31
+ });
32
+ (0, test_fns_1.given)('a compute stitcher with a multiple thread (seed + peers)', () => {
33
+ const seed = new Thread_1.Thread({
34
+ context: { role: 'main' },
35
+ stitches: [],
36
+ });
37
+ const peer = new Thread_1.Thread({
38
+ context: { role: 'main' },
39
+ stitches: [],
40
+ });
41
+ const threadBundle = { seed, peers: [peer, peer, peer] };
42
+ const stitcher = new StitchStep_1.StitchStepCompute({
43
+ slug: 'mock-step',
44
+ readme: null,
45
+ form: 'COMPUTE',
46
+ stitchee: 'main',
47
+ invoke: ({ threads }) => ({
48
+ input: 'in',
49
+ output: { peers: threads.main.peers.length },
50
+ }),
51
+ });
52
+ (0, test_fns_1.when)('enstitch is called with multiple thread shape', () => {
53
+ (0, test_fns_1.then)('it should update the seed thread with the stitch', async () => {
54
+ const result = await (0, enstitch_1.enstitch)({ stitcher, threads: { main: threadBundle } }, context);
55
+ expect(result.stitch.output).toEqual({
56
+ peers: 3,
57
+ });
58
+ expect(result.threads.main.stitches.length).toBe(1);
59
+ expect(result.threads.main.stitches[0].output).toEqual({
60
+ peers: 3,
61
+ });
62
+ });
63
+ });
64
+ });
65
+ (0, test_fns_1.given)('a compute stitcher that returns a constant literal output "A"', () => {
66
+ const threadMain = new Thread_1.Thread({
67
+ context: { role: 'main' },
68
+ stitches: [],
69
+ });
70
+ const stitcher = new StitchStep_1.StitchStepCompute({
71
+ slug: 'repeatee',
72
+ readme: 'Repeat logic',
73
+ form: 'COMPUTE',
74
+ stitchee: 'main',
75
+ invoke: () => ({ input: null, output: 'A' }),
76
+ });
77
+ (0, test_fns_1.when)('enstitch is called with a repeatee-style stitcher', () => {
78
+ (0, test_fns_1.then)('it should append a stitch with output "A"', async () => {
79
+ const result = await (0, enstitch_1.enstitch)({ stitcher, threads: { main: threadMain } }, context);
80
+ expect(result.stitch.output).toBe('A');
81
+ expect(result.threads.main.stitches.length).toBe(1);
82
+ expect(result.threads.main.stitches[0].output).toBe('A');
83
+ });
84
+ });
85
+ });
86
+ });
87
+ //# sourceMappingURL=enstitch.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enstitch.test.js","sourceRoot":"","sources":["../../../src/logic/stitch/enstitch.test.ts"],"names":[],"mappings":";;AAAA,uCAA6C;AAG7C,iFAA8E;AAC9E,uFAAoF;AAEpF,gEAAoE;AAEpE,wDAAqD;AAErD,yCAAsC;AAEtC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,MAAM,OAAO,GAAG,EAAE,GAAG,IAAA,6CAAqB,GAAE,EAAE,GAAG,IAAA,uCAAkB,GAAE,EAAE,CAAC;IAExE,IAAA,gBAAK,EAAC,yCAAyC,EAAE,GAAG,EAAE;QACpD,MAAM,UAAU,GAAG,IAAI,eAAM,CAAC;YAC5B,OAAO,EAAE,EAAE,IAAI,EAAE,MAAe,EAAE;YAClC,QAAQ,EAAE,EAAE;SACb,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,IAAI,8BAAiB,CAEpC;YACA,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAA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M,EAAE,cAAc;YACtB,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;SAC7C,CAAC,CAAC;QAEH,IAAA,eAAI,EAAC,mDAAmD,EAAE,GAAG,EAAE;YAC7D,IAAA,eAAI,EAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;gBAC3D,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAC3B,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAC3C,OAAO,CACR,CAAC;gBAEF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACvC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACpD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Stitch } from '../../domain/objects/Stitch';
2
+ import { StitchStepImagine } from '../../domain/objects/StitchStep';
3
+ import { GStitcher } from '../../domain/objects/Stitcher';
4
+ /**
5
+ * .what = invokes the imagine stitcher by invocation of stitcher mechanisms
6
+ */
7
+ export declare const invokeImagineStitcher: <TStitcher extends GStitcher>(input: {
8
+ stitcher: StitchStepImagine<TStitcher>;
9
+ threads: TStitcher['threads'];
10
+ }, context: TStitcher['context']) => Promise<Pick<Stitch<TStitcher['output']>, 'input' | 'output'>>;
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const test_fns_1 = require("test-fns");
4
+ const genContextLogTrail_1 = require("../../__test_assets__/genContextLogTrail");
5
+ const genContextStitchTrail_1 = require("../../__test_assets__/genContextStitchTrail");
6
+ const getContextOpenAI_1 = require("../../__test_assets__/getContextOpenAI");
7
+ const StitchStep_1 = require("../../domain/objects/StitchStep");
8
+ const Thread_1 = require("../../domain/objects/Thread");
9
+ const imagineViaOpenAI_1 = require("./adapters/imagineViaOpenAI");
10
+ const enstitch_1 = require("./enstitch");
11
+ describe('invokeImagineStitcher', () => {
12
+ test_fns_1.given.runIf(!process.env.CI)('a representative imagine stitcher', () => {
13
+ const context = {
14
+ ...(0, genContextLogTrail_1.genContextLogTrail)(),
15
+ ...(0, genContextStitchTrail_1.genContextStitchTrail)(),
16
+ ...(0, getContextOpenAI_1.getContextOpenAI)(),
17
+ };
18
+ const stitcher = new StitchStep_1.StitchStepImagine({
19
+ form: 'IMAGINE',
20
+ slug: 'fillout-stub',
21
+ readme: 'intent(fills out a stub of code); note(good example for impact of context)',
22
+ stitchee: 'author',
23
+ enprompt: ({ threads }) => [
24
+ 'fillout the code of the given stubout',
25
+ 'context.factset = ',
26
+ threads.author.context.factset.join('\n - '),
27
+ '',
28
+ 'here is the stubout',
29
+ threads.author.stitches.slice(-1)[0]?.output,
30
+ '',
31
+ 'fillout the code of the given stubout',
32
+ ].join('\n'),
33
+ imagine: imagineViaOpenAI_1.imagineViaOpenAI,
34
+ deprompt: ({ promptOut, promptIn }) => ({
35
+ output: promptOut,
36
+ input: promptIn,
37
+ }),
38
+ });
39
+ const stubout = `
40
+ /**
41
+ * .what = calls the open-meteo weather api
42
+ * .how =
43
+ * - uses procedural pattern
44
+ * - fails fast
45
+ */
46
+ export const sdkOpenMeteo = {
47
+ getWeather: (input: {...}, context: VisualogicContext & AuthContextOpenMeteo) => {
48
+ ...
49
+ }
50
+ }
51
+ `.trim();
52
+ (0, test_fns_1.when)('thread has blank context', () => {
53
+ const thread = new Thread_1.Thread({
54
+ context: { role: 'author', factset: [] },
55
+ stitches: [{ output: stubout, input: null }],
56
+ });
57
+ (0, test_fns_1.then)('it should be able to stitch', async () => {
58
+ const { stitch, threads } = await (0, enstitch_1.enstitch)({ stitcher, threads: { author: thread } }, context);
59
+ console.log(stitch.input);
60
+ console.log(stitch.output);
61
+ // stitch should look right
62
+ expect(stitch.output).toContain('sdkOpenMeteo');
63
+ // stitchee should be updated, too
64
+ expect(threads.author.stitches.length).toEqual(thread.stitches.length + 1);
65
+ });
66
+ });
67
+ (0, test_fns_1.when)('thread has context', () => {
68
+ const thread = new Thread_1.Thread({
69
+ context: {
70
+ role: 'author',
71
+ factset: [
72
+ `example of usage of open-meteo
73
+
74
+ \`\`\`ts
75
+ import { fetchWeatherApi } from 'openmeteo';
76
+
77
+ const params = {
78
+ latitude: [52.54],
79
+ longitude: [13.41],
80
+ current: 'temperature_2m,weather_code,wind_speed_10m,wind_direction_10m',
81
+ hourly: 'temperature_2m,precipitation',
82
+ daily: 'weather_code,temperature_2m_max,temperature_2m_min'
83
+ };
84
+ const url = 'https://api.open-meteo.com/v1/forecast';
85
+ const responses = await fetchWeatherApi(url, params);
86
+
87
+ // Helper function to form time ranges
88
+ const range = (start: number, stop: number, step: number) =>
89
+ Array.from({ length: (stop - start) / step }, (_, i) => start + i * step);
90
+
91
+ // Process first location. Add a for-loop for multiple locations or weather models
92
+ const response = responses[0];
93
+
94
+ // Attributes for timezone and location
95
+ const utcOffsetSeconds = response.utcOffsetSeconds();
96
+ const timezone = response.timezone();
97
+ const timezoneAbbreviation = response.timezoneAbbreviation();
98
+ const latitude = response.latitude();
99
+ const longitude = response.longitude();
100
+
101
+ const current = response.current()!;
102
+ const hourly = response.hourly()!;
103
+ const daily = response.daily()!;
104
+
105
+ // Note: The order of weather variables in the URL query and the indices below need to match!
106
+ const weatherData = {
107
+ current: {
108
+ time: new Date((Number(current.time()) + utcOffsetSeconds) * 1000),
109
+ temperature: current.variables(0)!.value(), // Current is only 1 value, therefore \`.value()\`
110
+ weatherCode: current.variables(1)!.value(),
111
+ windSpeed: current.variables(2)!.value(),
112
+ windDirection: current.variables(3)!.value()
113
+ },
114
+ hourly: {
115
+ time: range(Number(hourly.time()), Number(hourly.timeEnd()), hourly.interval()).map(
116
+ (t) => new Date((t + utcOffsetSeconds) * 1000)
117
+ ),
118
+ temperature: hourly.variables(0)!.valuesArray()!, // \`.valuesArray()\` get an array of floats
119
+ precipitation: hourly.variables(1)!.valuesArray()!,
120
+ },
121
+ daily: {
122
+ time: range(Number(daily.time()), Number(daily.timeEnd()), daily.interval()).map(
123
+ (t) => new Date((t + utcOffsetSeconds) * 1000)
124
+ ),
125
+ weatherCode: daily.variables(0)!.valuesArray()!,
126
+ temperatureMax: daily.variables(1)!.valuesArray()!,
127
+ temperatureMin: daily.variables(2)!.valuesArray()!,
128
+ }
129
+ };
130
+
131
+ // \`weatherData\` now contains a simple structure with arrays for datetime and weather data
132
+ for (let i = 0; i < weatherData.daily.time.length; i++) {
133
+ console.log(
134
+ weatherData.daily.time[i].toISOString(),
135
+ weatherData.daily.weatherCode[i],
136
+ weatherData.daily.temperatureMax[i],
137
+ weatherData.daily.temperatureMin[i]
138
+ );
139
+ }
140
+
141
+ \`\`\`
142
+ `.trim(),
143
+ `open-meteo forecast response shape
144
+
145
+ On success a JSON object will be returned.
146
+
147
+ {
148
+ "latitude": 52.52,
149
+ "longitude": 13.419,
150
+ "elevation": 44.812,
151
+ "generationtime_ms": 2.2119,
152
+ "utc_offset_seconds": 0,
153
+ "timezone": "Europe/Berlin",
154
+ "timezone_abbreviation": "CEST",
155
+ "hourly": {
156
+ "time": ["2022-07-01T00:00", "2022-07-01T01:00", "2022-07-01T02:00", ...],
157
+ "temperature_2m": [13, 12.7, 12.7, 12.5, 12.5, 12.8, 13, 12.9, 13.3, ...]
158
+ },
159
+ "hourly_units": {
160
+ "temperature_2m": "°C"
161
+ }
162
+ }
163
+ Parameter Format Description
164
+ latitude, longitude Floating point WGS84 of the center of the weather grid-cell which was used to generate this forecast. This coordinate might be a few kilometers away from the requested coordinate.
165
+ elevation Floating point The elevation from a 90 meter digital elevation model. This effects which grid-cell is selected (see parameter cell_selection). Statistical downscaling is used to adapt weather conditions for this elevation. This elevation can also be controlled with the query parameter elevation. If &elevation=nan is specified, all downscaling is disabled and the averge grid-cell elevation is used.
166
+ generationtime_ms Floating point Generation time of the weather forecast in milliseconds. This is mainly used for performance monitoring and improvements.
167
+ utc_offset_seconds Integer Applied timezone offset from the &timezone= parameter.
168
+ timezone
169
+ timezone_abbreviation String Timezone identifier (e.g. Europe/Berlin) and abbreviation (e.g. CEST)
170
+ hourly Object For each selected weather variable, data will be returned as a floating point array. Additionally a time array will be returned with ISO8601 timestamps.
171
+ hourly_units Object For each selected weather variable, the unit will be listed here.
172
+ daily Object For each selected daily weather variable, data will be returned as a floating point array. Additionally a time array will be returned with ISO8601 timestamps.
173
+ daily_units Object For each selected daily weather variable, the unit will be listed here.
174
+ `,
175
+ 'we want to declare an explicit output type with a simplified name pattern. for example, Weather { label: "sunny" | ..., temp: { high, low }, rain, etc }',
176
+ ],
177
+ },
178
+ stitches: [{ output: stubout, input: null }],
179
+ });
180
+ (0, test_fns_1.then)('it should leverage the knowledge of the context', async () => {
181
+ const { stitch, threads } = await (0, enstitch_1.enstitch)({ stitcher, threads: { author: thread } }, context);
182
+ console.log(stitch.input);
183
+ console.log(stitch.output);
184
+ // stitch should look right
185
+ expect(stitch.output).toContain('sdkOpenMeteo');
186
+ expect(stitch.output).toContain('temperature_2m');
187
+ // stitchee should be updated, too
188
+ expect(threads.author.stitches.length).toEqual(thread.stitches.length + 1);
189
+ });
190
+ });
191
+ });
192
+ });
193
+ //# sourceMappingURL=invokeImagineStitcher.integration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invokeImagineStitcher.integration.test.js","sourceRoot":"","sources":["../../../src/logic/stitch/invokeImagineStitcher.integration.test.ts"],"names":[],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D,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAiB,CAAC;aAC5D,CAAC,CAAC;YACH,IAAA,eAAI,EAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;gBACjE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,mBAAQ,EACxC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EACzC,OAAO,CACR,CAAC;gBACF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAE3B,2BAA2B;gBAC3B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;gBAChD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;gBAElD,kCAAkC;gBAClC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAC3B,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.invokeImagineStitcher = void 0;
4
+ /**
5
+ * .what = invokes the imagine stitcher by invocation of stitcher mechanisms
6
+ */
7
+ const invokeImagineStitcher = async (input, context) => {
8
+ const { stitcher, threads } = input;
9
+ // enprompt the thread
10
+ const prompt = stitcher.enprompt({ threads });
11
+ // invoke the imagination
12
+ const imagined = await stitcher.imagine(prompt, context);
13
+ // deprompt back into a stitch
14
+ const stitch = stitcher.deprompt({
15
+ threads,
16
+ promptIn: prompt,
17
+ promptOut: imagined,
18
+ });
19
+ // expose the stitch
20
+ return stitch;
21
+ };
22
+ exports.invokeImagineStitcher = invokeImagineStitcher;
23
+ //# sourceMappingURL=invokeImagineStitcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invokeImagineStitcher.js","sourceRoot":"","sources":["../../../src/logic/stitch/invokeImagineStitcher.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACI,MAAM,qBAAqB,GAAG,KAAK,EACxC,KAGC,EACD,OAA6B,EACmC,EAAE;IAClE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAEpC,sBAAsB;IACtB,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE9C,yBAAyB;IACzB,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzD,8BAA8B;IAC9B,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAC/B,OAAO;QACP,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,QAAQ;KACpB,CAAC,CAAC;IAEH,oBAAoB;IACpB,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAxBW,QAAA,qBAAqB,yBAwBhC"}
@@ -0,0 +1,16 @@
1
+ import { Procedure } from 'as-procedure';
2
+ import { StitchTrail } from '../../domain/objects/StitchTrail';
3
+ import { Stitcher } from '../../domain/objects/Stitcher';
4
+ export interface ContextStitchTrail {
5
+ stitch: {
6
+ trail: StitchTrail;
7
+ };
8
+ }
9
+ export declare const isStitcher: import("type-fns").AssessWithAssure<any, Stitcher>;
10
+ /**
11
+ * .what = adds stitch trail to enstitcher
12
+ * .why =
13
+ * - enables traces of why a stitch was created
14
+ * - enables you to see the different trails taken across the domain's treestruct of questions
15
+ */
16
+ export declare const withStitchTrail: <TLogic extends Procedure>(logic: TLogic) => TLogic;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withStitchTrail = exports.isStitcher = void 0;
4
+ const type_fns_1 = require("type-fns");
5
+ const uuid_fns_1 = require("uuid-fns");
6
+ const StitchTrail_1 = require("../../domain/objects/StitchTrail");
7
+ const Stitcher_1 = require("../../domain/objects/Stitcher");
8
+ exports.isStitcher = (0, type_fns_1.withAssure)((input) => !!input &&
9
+ 'form' in input &&
10
+ 'slug' in input &&
11
+ (0, Stitcher_1.isOfStitcherForm)(input.form));
12
+ /**
13
+ * .what = adds stitch trail to enstitcher
14
+ * .why =
15
+ * - enables traces of why a stitch was created
16
+ * - enables you to see the different trails taken across the domain's treestruct of questions
17
+ */
18
+ const withStitchTrail = (logic) => {
19
+ return (async (input, context) => {
20
+ // assure that stitcher was part of the input, if withStitchTrail was used
21
+ const stitcher = exports.isStitcher.assure(input.stitcher);
22
+ // establish a new trail marker and add it to the context
23
+ const stitchTrailMarker = StitchTrail_1.StitchTrailMarker.build({
24
+ stitcherSlug: stitcher.slug,
25
+ stitchUuid: (0, uuid_fns_1.getUuid)(), // new stitcher invocation -> new trail marker
26
+ });
27
+ const stitchTrailContextNow = {
28
+ stitch: {
29
+ trail: [...(context.stitch.trail ?? []), stitchTrailMarker],
30
+ },
31
+ };
32
+ // invoke the logic with this trail marker now added to its context
33
+ return await logic(input, {
34
+ ...context,
35
+ ...stitchTrailContextNow,
36
+ });
37
+ });
38
+ };
39
+ exports.withStitchTrail = withStitchTrail;
40
+ //# sourceMappingURL=withStitchTrail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withStitchTrail.js","sourceRoot":"","sources":["../../../src/logic/stitch/withStitchTrail.ts"],"names":[],"mappings":";;;AAMA,uCAAsC;AACtC,uCAAmC;AAEnC,kEAG0C;AAC1C,4DAA2E;AAQ9D,QAAA,UAAU,GAAG,IAAA,qBAAU,EAClC,CAAC,KAAU,EAAqB,EAAE,CAChC,CAAC,CAAC,KAAK;IACP,MAAM,IAAI,KAAK;IACf,MAAM,IAAI,KAAK;IACf,IAAA,2BAAgB,EAAC,KAAK,CAAC,IAAI,CAAC,CAC/B,CAAC;AAEF;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAC7B,KAAa,EACC,EAAE;IAChB,OAAO,CAAC,KAAK,EACX,KAAmC,EACnC,OAAuC,EACC,EAAE;QAC1C,0EAA0E;QAC1E,MAAM,QAAQ,GAAG,kBAAU,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEnD,yDAAyD;QACzD,MAAM,iBAAiB,GAAG,+BAAiB,CAAC,KAAK,CAAC;YAChD,YAAY,EAAE,QAAQ,CAAC,IAAI;YAC3B,UAAU,EAAE,IAAA,kBAAO,GAAE,EAAE,8CAA8C;SACtE,CAAC,CAAC;QACH,MAAM,qBAAqB,GAAuB;YAChD,MAAM,EAAE;gBACN,KAAK,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,iBAAiB,CAAC;aAC5D;SACF,CAAC;QAEF,mEAAmE;QACnE,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE;YACxB,GAAG,OAAO;YACV,GAAG,qBAAqB;SACzB,CAAC,CAAC;IACL,CAAC,CAAiB,CAAC;AACrB,CAAC,CAAC;AA3BW,QAAA,eAAe,mBA2B1B"}
@@ -0,0 +1,4 @@
1
+ import { Thread } from '../../domain/objects/Thread';
2
+ export declare const enrollThread: <TThread extends Thread<any>>(input: {
3
+ thread: TThread;
4
+ }) => void;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enrollThread = void 0;
4
+ const enrollThread = (input) => { };
5
+ exports.enrollThread = enrollThread;
6
+ //# sourceMappingURL=enroleThread.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enroleThread.js","sourceRoot":"","sources":["../../../src/logic/thread/enroleThread.ts"],"names":[],"mappings":";;;AAEO,MAAM,YAAY,GAAG,CAA8B,KAEzD,EAAE,EAAE,GAAE,CAAC,CAAC;AAFI,QAAA,YAAY,gBAEhB"}
@@ -0,0 +1,7 @@
1
+ import { Thread } from '../../domain/objects/Thread';
2
+ /**
3
+ * .what = generates a new thread
4
+ */
5
+ export declare const genThread: <C extends {
6
+ role: string;
7
+ }>(context: C) => Thread<C>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.genThread = void 0;
4
+ const Thread_1 = require("../../domain/objects/Thread");
5
+ /**
6
+ * .what = generates a new thread
7
+ */
8
+ const genThread = (context) => new Thread_1.Thread({ context, stitches: [] });
9
+ exports.genThread = genThread;
10
+ //# sourceMappingURL=genThread.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genThread.js","sourceRoot":"","sources":["../../../src/logic/thread/genThread.ts"],"names":[],"mappings":";;;AAAA,wDAAqD;AAErD;;GAEG;AACI,MAAM,SAAS,GAAG,CAA6B,OAAU,EAAa,EAAE,CAC7E,IAAI,eAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;AAD3B,QAAA,SAAS,aACkB"}
@@ -0,0 +1,17 @@
1
+ import { GStitcher, Stitcher } from '../../../domain/objects/Stitcher';
2
+ import { ProcedureContextMerged, ProcedureContextSpread } from './ProcedureContextMerged.generic';
3
+ import { ThreadsMerged, ThreadsSpread } from './ThreadsMerged.generic';
4
+ /**
5
+ * .what = infers a composite GStitcher from a StitchChoice config
6
+ * .how =
7
+ * - threads: merged from options + decider
8
+ * - context: merged from options + decider
9
+ * - output: union of option outputs
10
+ */
11
+ export type GStitcherInferredFromChoice<TOptions extends readonly [Stitcher<GStitcher>, ...Stitcher<GStitcher>[]], TDecider extends Stitcher<GStitcher>> = GStitcher<ThreadsMerged<[
12
+ TDecider extends Stitcher<infer G> ? G['threads'] : never,
13
+ ...ThreadsSpread<TOptions>
14
+ ]>, ProcedureContextMerged<[
15
+ TDecider extends Stitcher<infer G> ? G['context'] : never,
16
+ ...ProcedureContextSpread<TOptions>
17
+ ]> & GStitcher['context'], TOptions[number] extends Stitcher<infer G> ? G['output'] : never>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=GStitcherInferredFromChoice.generic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GStitcherInferredFromChoice.generic.js","sourceRoot":"","sources":["../../../../src/logic/weave/compose/GStitcherInferredFromChoice.generic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const test_fns_1 = require("test-fns");
4
+ const genContextLogTrail_1 = require("../../../__test_assets__/genContextLogTrail");
5
+ const genContextStitchTrail_1 = require("../../../__test_assets__/genContextStitchTrail");
6
+ const StitchStep_1 = require("../../../domain/objects/StitchStep");
7
+ const genThread_1 = require("../../thread/genThread");
8
+ const stitcherReturn42 = new StitchStep_1.StitchStepCompute({
9
+ slug: `return-42`,
10
+ form: 'COMPUTE',
11
+ readme: null,
12
+ stitchee: 'main',
13
+ invoke: () => ({ input: null, output: 42 }),
14
+ });
15
+ const stitcherReturnHello = new StitchStep_1.StitchStepCompute({
16
+ slug: `return-hello`,
17
+ form: 'COMPUTE',
18
+ readme: null,
19
+ stitchee: 'main',
20
+ invoke: () => ({ input: null, output: 'hello' }),
21
+ });
22
+ const stitcherChooseReturn = new StitchStep_1.StitchStepCompute({
23
+ slug: 'choose-return',
24
+ form: 'COMPUTE',
25
+ readme: null,
26
+ stitchee: 'main',
27
+ invoke: () => ({ input: null, output: { choice: { slug: 'return-42' } } }),
28
+ });
29
+ describe('GStitcherInferredFromChoice', () => {
30
+ (0, test_fns_1.given)('a decider and two options with different output types', () => {
31
+ const options = [stitcherReturn42, stitcherReturnHello];
32
+ const decider = stitcherChooseReturn;
33
+ (0, test_fns_1.then)('it should merge threads and context, and infer a union output', () => {
34
+ const threads = {
35
+ main: (0, genThread_1.genThread)({ role: 'main' }),
36
+ };
37
+ expect(threads);
38
+ const context = {
39
+ ...(0, genContextLogTrail_1.genContextLogTrail)(),
40
+ ...(0, genContextStitchTrail_1.genContextStitchTrail)(),
41
+ };
42
+ expect(context);
43
+ const output1 = 42;
44
+ const output2 = 'hello';
45
+ expect(typeof output1 === 'number' || typeof output1 === 'string').toBe(true);
46
+ expect(typeof output2 === 'number' || typeof output2 === 'string').toBe(true);
47
+ });
48
+ (0, test_fns_1.then)('it should error if threads has unknown keys', () => {
49
+ const badThreads = {
50
+ // @ts-expect-error extra thread "foo"
51
+ foo: (0, genThread_1.genThread)({ role: 'foo' }),
52
+ };
53
+ expect(badThreads);
54
+ });
55
+ (0, test_fns_1.then)('it should error if context is missing required fields', () => {
56
+ // @ts-expect-error missing context
57
+ const badContext = {};
58
+ expect(badContext);
59
+ });
60
+ (0, test_fns_1.then)('it should error if output is not string or number', () => {
61
+ // @ts-expect-error boolean not allowed
62
+ const badOutput = true;
63
+ expect(badOutput);
64
+ });
65
+ });
66
+ });
67
+ //# sourceMappingURL=GStitcherInferredFromChoice.generic.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GStitcherInferredFromChoice.generic.test.js","sourceRoot":"","sources":["../../../../src/logic/weave/compose/GStitcherInferredFromChoice.generic.test.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAGvC,oFAAiF;AACjF,0FAAuF;AAEvF,mEAAuE;AAGvE,sDAAmD;AAGnD,MAAM,gBAAgB,GAAG,IAAI,8BAAiB,CAE5C;IACA,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;CAC5C,CAAC,CAAC;AAEH,MAAM,m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AAO,OAAO,KAAK,QAAQ,CAAC,CAAC,IAAI,CACrE,IAAI,CACL,CAAC;YACF,MAAM,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,IAAI,CACrE,IAAI,CACL,CAAC;QACJ,CAAC,CACF,CAAC;QAEF,IAAA,eAAI,EAAC,6CAA6C,EAAE,GAAG,EAAE;YACvD,MAAM,UAAU,GAAwB;gBACtC,sCAAsC;gBACtC,GAAG,EAAE,IAAA,qBAAS,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;aAChC,CAAC;YACF,MAAM,CAAC,UAAU,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,IAAA,eAAI,EAAC,uDAAuD,EAAE,GAAG,EAAE;YACjE,mCAAmC;YACnC,MAAM,UAAU,GAAwB,EAAE,CAAC;YAC3C,MAAM,CAAC,UAAU,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,IAAA,eAAI,EAAC,mDAAmD,EAAE,GAAG,EAAE;YAC7D,uCAAuC;YACvC,MAAM,SAAS,GAAuB,IAAI,CAAC;YAC3C,MAAM,CAAC,SAAS,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { GStitcher, GStitcherOf, Stitcher } from '../../../domain/objects/Stitcher';
2
+ import { Threads } from '../../../domain/objects/Threads';
3
+ import { ProcedureContextMerged } from './ProcedureContextMerged.generic';
4
+ import { ThreadsMerged } from './ThreadsMerged.generic';
5
+ /**
6
+ * .what = infers a composite GStitcher from a StitchCycle config
7
+ * .how =
8
+ * - threads: merged from repeatee + decider
9
+ * - context: merged from repeatee + decider
10
+ * - output: same as repeatee (since it loops and returns its output type)
11
+ */
12
+ export type GStitcherInferredFromCycle<TRepeatee extends Stitcher<GStitcher<Threads<any, 'single'>, any, any>>, TDecider extends Stitcher<GStitcher<Threads<any, 'single'>, any, any>>> = GStitcher<ThreadsMerged<[
13
+ GStitcherOf<TRepeatee>['threads'],
14
+ GStitcherOf<TDecider>['threads']
15
+ ]>, ProcedureContextMerged<[
16
+ GStitcherOf<TRepeatee>['context'],
17
+ GStitcherOf<TDecider>['context']
18
+ ]> & GStitcher['context'], GStitcherOf<TRepeatee>['output']>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=GStitcherInferredFromCycle.generic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GStitcherInferredFromCycle.generic.js","sourceRoot":"","sources":["../../../../src/logic/weave/compose/GStitcherInferredFromCycle.generic.ts"],"names":[],"mappings":""}