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.
- package/LICENSE +21 -0
- package/dist/__nonpublished_modules__/file-fns/src/getFile.d.ts +6 -0
- package/dist/__nonpublished_modules__/file-fns/src/getFile.js +14 -0
- package/dist/__nonpublished_modules__/file-fns/src/getFile.js.map +1 -0
- package/dist/__test_assets__/directory.d.ts +1 -0
- package/dist/__test_assets__/directory.js +5 -0
- package/dist/__test_assets__/directory.js.map +1 -0
- package/dist/__test_assets__/genContextLogTrail.d.ts +2 -0
- package/dist/__test_assets__/genContextLogTrail.js +12 -0
- package/dist/__test_assets__/genContextLogTrail.js.map +1 -0
- package/dist/__test_assets__/genContextStitchTrail.d.ts +2 -0
- package/dist/__test_assets__/genContextStitchTrail.js +8 -0
- package/dist/__test_assets__/genContextStitchTrail.js.map +1 -0
- package/dist/__test_assets__/getContextOpenAI.d.ts +2 -0
- package/dist/__test_assets__/getContextOpenAI.js +18 -0
- package/dist/__test_assets__/getContextOpenAI.js.map +1 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.d.ts +14 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.js +23 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileRead.js.map +1 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.d.ts +16 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.js +29 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeFileWrite.js.map +1 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.d.ts +15 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.js +97 -0
- package/dist/__test_assets__/stitchers/genStitcherCodeReviewImagine.js.map +1 -0
- package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.d.ts +13 -0
- package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.js +33 -0
- package/dist/__test_assets__/stitchers/stitcherCodeDiffImagine.js.map +1 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.d.ts +13 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.js +45 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutRandomSum.js.map +1 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.d.ts +29 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.js +76 -0
- package/dist/__test_assets__/stitchers/stitcherFanoutSubroutes.js.map +1 -0
- package/dist/__test_assets__/threads/codeArtist.d.ts +6 -0
- package/dist/__test_assets__/threads/codeArtist.js +26 -0
- package/dist/__test_assets__/threads/codeArtist.js.map +1 -0
- package/dist/__test_assets__/threads/codeCritic.d.ts +6 -0
- package/dist/__test_assets__/threads/codeCritic.js +21 -0
- package/dist/__test_assets__/threads/codeCritic.js.map +1 -0
- package/dist/__test_assets__/threads/director.d.ts +6 -0
- package/dist/__test_assets__/threads/director.js +14 -0
- package/dist/__test_assets__/threads/director.js.map +1 -0
- package/dist/contract/sdk.d.ts +8 -0
- package/dist/contract/sdk.js +33 -0
- package/dist/contract/sdk.js.map +1 -0
- package/dist/domain/objects/Stitch.d.ts +42 -0
- package/dist/domain/objects/Stitch.js +9 -0
- package/dist/domain/objects/Stitch.js.map +1 -0
- package/dist/domain/objects/StitchChoice.d.ts +30 -0
- package/dist/domain/objects/StitchChoice.js +8 -0
- package/dist/domain/objects/StitchChoice.js.map +1 -0
- package/dist/domain/objects/StitchCycle.d.ts +44 -0
- package/dist/domain/objects/StitchCycle.js +8 -0
- package/dist/domain/objects/StitchCycle.js.map +1 -0
- package/dist/domain/objects/StitchFanout.d.ts +35 -0
- package/dist/domain/objects/StitchFanout.js +8 -0
- package/dist/domain/objects/StitchFanout.js.map +1 -0
- package/dist/domain/objects/StitchRoute.d.ts +22 -0
- package/dist/domain/objects/StitchRoute.js +8 -0
- package/dist/domain/objects/StitchRoute.js.map +1 -0
- package/dist/domain/objects/StitchSetEvent.d.ts +23 -0
- package/dist/domain/objects/StitchSetEvent.js +8 -0
- package/dist/domain/objects/StitchSetEvent.js.map +1 -0
- package/dist/domain/objects/StitchStep.d.ts +55 -0
- package/dist/domain/objects/StitchStep.js +11 -0
- package/dist/domain/objects/StitchStep.js.map +1 -0
- package/dist/domain/objects/StitchTrail.d.ts +26 -0
- package/dist/domain/objects/StitchTrail.js +19 -0
- package/dist/domain/objects/StitchTrail.js.map +1 -0
- package/dist/domain/objects/Stitcher.d.ts +105 -0
- package/dist/domain/objects/Stitcher.js +49 -0
- package/dist/domain/objects/Stitcher.js.map +1 -0
- package/dist/domain/objects/Stitcher.test.d.ts +1 -0
- package/dist/domain/objects/Stitcher.test.js +78 -0
- package/dist/domain/objects/Stitcher.test.js.map +1 -0
- package/dist/domain/objects/Thread.d.ts +31 -0
- package/dist/domain/objects/Thread.js +11 -0
- package/dist/domain/objects/Thread.js.map +1 -0
- package/dist/domain/objects/Threads.d.ts +56 -0
- package/dist/domain/objects/Threads.js +26 -0
- package/dist/domain/objects/Threads.js.map +1 -0
- package/dist/domain/objects/Weave.d.ts +0 -0
- package/dist/domain/objects/Weave.js +2 -0
- package/dist/domain/objects/Weave.js.map +1 -0
- package/dist/domain/objects/Weaver.d.ts +5 -0
- package/dist/domain/objects/Weaver.js +7 -0
- package/dist/domain/objects/Weaver.js.map +1 -0
- package/dist/domain/objects/index.d.ts +11 -0
- package/dist/domain/objects/index.js +30 -0
- package/dist/domain/objects/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/logic/stitch/adapters/imagineViaOpenAI.d.ts +13 -0
- package/dist/logic/stitch/adapters/imagineViaOpenAI.js +36 -0
- package/dist/logic/stitch/adapters/imagineViaOpenAI.js.map +1 -0
- package/dist/logic/stitch/enstitch.d.ts +27 -0
- package/dist/logic/stitch/enstitch.js +97 -0
- package/dist/logic/stitch/enstitch.js.map +1 -0
- package/dist/logic/stitch/enstitch.test.d.ts +1 -0
- package/dist/logic/stitch/enstitch.test.js +87 -0
- package/dist/logic/stitch/enstitch.test.js.map +1 -0
- package/dist/logic/stitch/invokeImagineStitcher.d.ts +10 -0
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.d.ts +1 -0
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.js +193 -0
- package/dist/logic/stitch/invokeImagineStitcher.integration.test.js.map +1 -0
- package/dist/logic/stitch/invokeImagineStitcher.js +23 -0
- package/dist/logic/stitch/invokeImagineStitcher.js.map +1 -0
- package/dist/logic/stitch/withStitchTrail.d.ts +16 -0
- package/dist/logic/stitch/withStitchTrail.js +40 -0
- package/dist/logic/stitch/withStitchTrail.js.map +1 -0
- package/dist/logic/thread/enroleThread.d.ts +4 -0
- package/dist/logic/thread/enroleThread.js +6 -0
- package/dist/logic/thread/enroleThread.js.map +1 -0
- package/dist/logic/thread/genThread.d.ts +7 -0
- package/dist/logic/thread/genThread.js +10 -0
- package/dist/logic/thread/genThread.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.d.ts +17 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.js +3 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js +67 -0
- package/dist/logic/weave/compose/GStitcherInferredFromChoice.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.d.ts +18 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.js +3 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js +132 -0
- package/dist/logic/weave/compose/GStitcherInferredFromCycle.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.d.ts +23 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.js +3 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js +74 -0
- package/dist/logic/weave/compose/GStitcherInferredFromFanout.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.d.ts +24 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.js +3 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.js.map +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js +190 -0
- package/dist/logic/weave/compose/GStitcherInferredFromRoute.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.d.ts +36 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.js +3 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.js.map +1 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js +29 -0
- package/dist/logic/weave/compose/ProcedureContextMerged.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.d.ts +65 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.js +3 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.js.map +1 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.test.d.ts +1 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.test.js +420 -0
- package/dist/logic/weave/compose/ThreadsMerged.generic.test.js.map +1 -0
- package/dist/logic/weave/compose/asStitcher.d.ts +12 -0
- package/dist/logic/weave/compose/asStitcher.js +15 -0
- package/dist/logic/weave/compose/asStitcher.js.map +1 -0
- package/dist/logic/weave/compose/asStitcher.test.d.ts +1 -0
- package/dist/logic/weave/compose/asStitcher.test.js +95 -0
- package/dist/logic/weave/compose/asStitcher.test.js.map +1 -0
- package/dist/logic/weave/compose/asStitcherFlat.d.ts +10 -0
- package/dist/logic/weave/compose/asStitcherFlat.js +13 -0
- package/dist/logic/weave/compose/asStitcherFlat.js.map +1 -0
- package/dist/logic/weave/compose/asStitcherFlat.test.d.ts +1 -0
- package/dist/logic/weave/compose/asStitcherFlat.test.js +96 -0
- package/dist/logic/weave/compose/asStitcherFlat.test.js.map +1 -0
- package/dist/logic/weave/compose/genStitchChoice.d.ts +22 -0
- package/dist/logic/weave/compose/genStitchChoice.js +23 -0
- package/dist/logic/weave/compose/genStitchChoice.js.map +1 -0
- package/dist/logic/weave/compose/genStitchChoice.test.d.ts +1 -0
- package/dist/logic/weave/compose/genStitchChoice.test.js +200 -0
- package/dist/logic/weave/compose/genStitchChoice.test.js.map +1 -0
- package/dist/logic/weave/compose/genStitchCycle.d.ts +28 -0
- package/dist/logic/weave/compose/genStitchCycle.js +30 -0
- package/dist/logic/weave/compose/genStitchCycle.js.map +1 -0
- package/dist/logic/weave/compose/genStitchCycle.test.d.ts +1 -0
- package/dist/logic/weave/compose/genStitchCycle.test.js +152 -0
- package/dist/logic/weave/compose/genStitchCycle.test.js.map +1 -0
- package/dist/logic/weave/compose/genStitchFanout.d.ts +17 -0
- package/dist/logic/weave/compose/genStitchFanout.js +21 -0
- package/dist/logic/weave/compose/genStitchFanout.js.map +1 -0
- package/dist/logic/weave/compose/genStitchFanout.test.d.ts +1 -0
- package/dist/logic/weave/compose/genStitchFanout.test.js +79 -0
- package/dist/logic/weave/compose/genStitchFanout.test.js.map +1 -0
- package/dist/logic/weave/compose/genStitchRoute.d.ts +15 -0
- package/dist/logic/weave/compose/genStitchRoute.js +20 -0
- package/dist/logic/weave/compose/genStitchRoute.js.map +1 -0
- package/dist/logic/weave/compose/genStitchRoute.test.d.ts +1 -0
- package/dist/logic/weave/compose/genStitchRoute.test.js +120 -0
- package/dist/logic/weave/compose/genStitchRoute.test.js.map +1 -0
- package/dist/logic/weave/enweave.d.ts +0 -0
- package/dist/logic/weave/enweave.js +2 -0
- package/dist/logic/weave/enweave.js.map +1 -0
- package/dist/logic/weave/enweaveAllStitchers.d.ts +0 -0
- package/dist/logic/weave/enweaveAllStitchers.js +2 -0
- package/dist/logic/weave/enweaveAllStitchers.js.map +1 -0
- package/dist/logic/weave/enweaveOneChoice.d.ts +14 -0
- package/dist/logic/weave/enweaveOneChoice.js +48 -0
- package/dist/logic/weave/enweaveOneChoice.js.map +1 -0
- package/dist/logic/weave/enweaveOneChoice.test.d.ts +1 -0
- package/dist/logic/weave/enweaveOneChoice.test.js +181 -0
- package/dist/logic/weave/enweaveOneChoice.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneCycle.d.ts +19 -0
- package/dist/logic/weave/enweaveOneCycle.js +98 -0
- package/dist/logic/weave/enweaveOneCycle.js.map +1 -0
- package/dist/logic/weave/enweaveOneCycle.test.d.ts +1 -0
- package/dist/logic/weave/enweaveOneCycle.test.js +180 -0
- package/dist/logic/weave/enweaveOneCycle.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneFanout.d.ts +12 -0
- package/dist/logic/weave/enweaveOneFanout.integration.test.d.ts +1 -0
- package/dist/logic/weave/enweaveOneFanout.integration.test.js +166 -0
- package/dist/logic/weave/enweaveOneFanout.integration.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneFanout.js +37 -0
- package/dist/logic/weave/enweaveOneFanout.js.map +1 -0
- package/dist/logic/weave/enweaveOneRoute.d.ts +12 -0
- package/dist/logic/weave/enweaveOneRoute.integration.test.d.ts +1 -0
- package/dist/logic/weave/enweaveOneRoute.integration.test.js +159 -0
- package/dist/logic/weave/enweaveOneRoute.integration.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneRoute.js +33 -0
- package/dist/logic/weave/enweaveOneRoute.js.map +1 -0
- package/dist/logic/weave/enweaveOneStitcher.d.ts +11 -0
- package/dist/logic/weave/enweaveOneStitcher.integration.test.d.ts +2 -0
- package/dist/logic/weave/enweaveOneStitcher.integration.test.js +258 -0
- package/dist/logic/weave/enweaveOneStitcher.integration.test.js.map +1 -0
- package/dist/logic/weave/enweaveOneStitcher.js +42 -0
- package/dist/logic/weave/enweaveOneStitcher.js.map +1 -0
- package/package.json +88 -0
- package/readme.md +61 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asStitcherDesc = exports.isOfStitcherForm = exports.StitcherForm = void 0;
|
|
4
|
+
const type_fns_1 = require("type-fns");
|
|
5
|
+
/**
|
|
6
|
+
* .what = the canonical set of stitcher forms
|
|
7
|
+
*/
|
|
8
|
+
var StitcherForm;
|
|
9
|
+
(function (StitcherForm) {
|
|
10
|
+
/**
|
|
11
|
+
* .what = a stitch step executed via computation of procedural logic
|
|
12
|
+
*/
|
|
13
|
+
StitcherForm["COMPUTE"] = "COMPUTE";
|
|
14
|
+
/**
|
|
15
|
+
* .what = a stitch step executed via imagination of an llm
|
|
16
|
+
*/
|
|
17
|
+
StitcherForm["IMAGINE"] = "IMAGINE";
|
|
18
|
+
/**
|
|
19
|
+
* .what = a stitch combo via linear sequence
|
|
20
|
+
*/
|
|
21
|
+
StitcherForm["ROUTE"] = "ROUTE";
|
|
22
|
+
/**
|
|
23
|
+
* .what = a stitch combo via parallel fanout + fanin
|
|
24
|
+
*/
|
|
25
|
+
StitcherForm["FANOUT"] = "FANOUT";
|
|
26
|
+
/**
|
|
27
|
+
* .what = a stitch combo via conditional stitcher selection
|
|
28
|
+
*/
|
|
29
|
+
StitcherForm["CHOICE"] = "CHOICE";
|
|
30
|
+
/**
|
|
31
|
+
* .what = a stitch combo via repetition of stitchers
|
|
32
|
+
*/
|
|
33
|
+
StitcherForm["CYCLE"] = "CYCLE";
|
|
34
|
+
/**
|
|
35
|
+
* .what = a stitch combo which gracefully awaits some condition to be satisfied
|
|
36
|
+
*/
|
|
37
|
+
StitcherForm["AWAIT"] = "AWAIT";
|
|
38
|
+
})(StitcherForm || (exports.StitcherForm = StitcherForm = {}));
|
|
39
|
+
exports.isOfStitcherForm = (0, type_fns_1.createIsOfEnum)(StitcherForm);
|
|
40
|
+
/**
|
|
41
|
+
* .what = converts a full stitcher into a StitcherDesc
|
|
42
|
+
* .why = used for observability and trail markers
|
|
43
|
+
*/
|
|
44
|
+
const asStitcherDesc = (input) => {
|
|
45
|
+
const { slug, readme, form } = input.stitcher;
|
|
46
|
+
return { form, slug, readme };
|
|
47
|
+
};
|
|
48
|
+
exports.asStitcherDesc = asStitcherDesc;
|
|
49
|
+
//# sourceMappingURL=Stitcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stitcher.js","sourceRoot":"","sources":["../../../src/domain/objects/Stitcher.ts"],"names":[],"mappings":";;;AACA,uCAAsD;AAwBtD;;GAEG;AACH,IAAY,YAmCX;AAnCD,WAAY,YAAY;IACtB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,mCAAmB,CAAA;IAEnB;;OAEG;IACH,+BAAe,CAAA;IAEf;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,+BAAe,CAAA;IAEf;;OAEG;IACH,+BAAe,CAAA;AACjB,CAAC,EAnCW,YAAY,4BAAZ,YAAY,QAmCvB;AACY,QAAA,gBAAgB,GAAG,IAAA,yBAAc,EAAC,YAAY,CAAC,CAAC;AA8D7D;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAsC,KAEnE,EAAmC,EAAE;IACpC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC9C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAChC,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* example thread builder
|
|
5
|
+
*/
|
|
6
|
+
const genThread = (ctx) => ({
|
|
7
|
+
context: ctx,
|
|
8
|
+
stitches: [],
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Compile-time test suite using Jest
|
|
12
|
+
*/
|
|
13
|
+
describe('GStitcher', () => {
|
|
14
|
+
it('accepts single-threaded Threads', () => {
|
|
15
|
+
const stitcher = {
|
|
16
|
+
threads: {
|
|
17
|
+
artist: genThread({ role: 'artist', name: 'Zane' }),
|
|
18
|
+
},
|
|
19
|
+
context: {
|
|
20
|
+
stitch: { trail: [] },
|
|
21
|
+
log: console,
|
|
22
|
+
},
|
|
23
|
+
output: 'done',
|
|
24
|
+
};
|
|
25
|
+
expect(stitcher.output).toBe('done');
|
|
26
|
+
});
|
|
27
|
+
it('accepts multi-threaded Threads using Threads<..., "multiple">', () => {
|
|
28
|
+
const stitcher = {
|
|
29
|
+
threads: {
|
|
30
|
+
artist: {
|
|
31
|
+
seed: genThread({ role: 'artist', name: 'Zane' }),
|
|
32
|
+
peers: [genThread({ role: 'artist', name: 'Zane' })],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
context: {
|
|
36
|
+
stitch: { trail: [] },
|
|
37
|
+
log: console,
|
|
38
|
+
},
|
|
39
|
+
output: 'done',
|
|
40
|
+
};
|
|
41
|
+
expect(stitcher.threads.artist.peers[0]?.context.name).toBe('Zane');
|
|
42
|
+
});
|
|
43
|
+
it('rejects invalid thread shape', () => {
|
|
44
|
+
// @ts-expect-error - artist must be a Thread or Thread[]
|
|
45
|
+
const stitcher = {
|
|
46
|
+
threads: {
|
|
47
|
+
artist: 'not-a-thread',
|
|
48
|
+
},
|
|
49
|
+
context: {
|
|
50
|
+
stitch: { trail: [] },
|
|
51
|
+
log: console,
|
|
52
|
+
},
|
|
53
|
+
output: 'fail',
|
|
54
|
+
};
|
|
55
|
+
expect(stitcher);
|
|
56
|
+
});
|
|
57
|
+
describe('Stitcher<GStitcher>', () => {
|
|
58
|
+
// ✅ Positive, single
|
|
59
|
+
it('should allow Stitcher<GStitcher> with Threads<..., "single">', () => {
|
|
60
|
+
const assert = null;
|
|
61
|
+
expect(assert).toBeNull();
|
|
62
|
+
});
|
|
63
|
+
// ✅ Positive, multiple
|
|
64
|
+
it('only allow StitchStep<GStitcher> with Threads<..., "multiple">', () => {
|
|
65
|
+
const assert = null;
|
|
66
|
+
expect(assert).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
// ❌ Negative, single
|
|
69
|
+
it('should reject Stitcher<GStitcher> with non-Thread single shape', () => {
|
|
70
|
+
expect(true).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
// ❌ Negative, multiple
|
|
73
|
+
it('should reject Stitcher<GStitcher> with non-Thread[] multiple shape', () => {
|
|
74
|
+
expect(true).toBe(true);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=Stitcher.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stitcher.test.js","sourceRoot":"","sources":["../../../src/domain/objects/Stitcher.test.ts"],"names":[],"mappings":";;AAUA;;GAEG;AACH,MAAM,SAAS,GAAG,CAAI,GAAM,EAAa,EAAE,CAAC,CAAC;IAC3C,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAEH;;GAEG;AACH,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IAGzB,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QAGzC,MAAM,QAAQ,GAAkD;YAC9D,OAAO,EAAE;gBACP,MAAM,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,QAAiB,E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C,qBAAqB,EAAE,GAAG,EAAE;QACnC,qBAAqB;QACrB,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;YAMtE,MAAM,MAAM,GAAa,IAAI,CAAC;YAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,uBAAuB;QACvB,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;YAMxE,MAAM,MAAM,GAAa,IAAI,CAAC;YAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,qBAAqB;QACrB,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;YAQxE,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;QAEH,uBAAuB;QACvB,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;YAQ5E,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DomainLiteral } from 'domain-objects';
|
|
2
|
+
import { Stitch } from './Stitch';
|
|
3
|
+
import { StitchSetEvent } from './StitchSetEvent';
|
|
4
|
+
/**
|
|
5
|
+
* .what = a declaration of a thought thread
|
|
6
|
+
*/
|
|
7
|
+
export interface Thread<TThreadContext> {
|
|
8
|
+
/**
|
|
9
|
+
* the context accumulated for this thread so far
|
|
10
|
+
*/
|
|
11
|
+
context: TThreadContext;
|
|
12
|
+
/**
|
|
13
|
+
* .what = the stitches that were executed with this thread so far
|
|
14
|
+
*/
|
|
15
|
+
stitches: Stitch<any>[];
|
|
16
|
+
/**
|
|
17
|
+
* .what = the history that produced the state of this thread
|
|
18
|
+
* .note =
|
|
19
|
+
* - history should only be used for observability
|
|
20
|
+
* - should expect it to be optional, (e.g., only in prep environments, rarely in prod)
|
|
21
|
+
* - due to the size (lots of repeated data)
|
|
22
|
+
* - due to alt prod observability tools
|
|
23
|
+
* .todo
|
|
24
|
+
* - decide if still needed now that stitch was improved
|
|
25
|
+
*/
|
|
26
|
+
history?: StitchSetEvent<any, any>[];
|
|
27
|
+
}
|
|
28
|
+
export declare class Thread<TThreadContext> extends DomainLiteral<Thread<TThreadContext>> implements Thread<TThreadContext> {
|
|
29
|
+
}
|
|
30
|
+
export type ThreadOmitHistory<TThread extends Thread<any>> = Omit<TThread, 'history'>;
|
|
31
|
+
export declare const threadOmitHistory: <TThread extends Thread<any>>(thread: TThread) => ThreadOmitHistory<TThread>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.threadOmitHistory = exports.Thread = void 0;
|
|
4
|
+
const domain_objects_1 = require("domain-objects");
|
|
5
|
+
const type_fns_1 = require("type-fns");
|
|
6
|
+
class Thread extends domain_objects_1.DomainLiteral {
|
|
7
|
+
}
|
|
8
|
+
exports.Thread = Thread;
|
|
9
|
+
const threadOmitHistory = (thread) => (0, type_fns_1.omit)(thread, ['history']);
|
|
10
|
+
exports.threadOmitHistory = threadOmitHistory;
|
|
11
|
+
//# sourceMappingURL=Thread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Thread.js","sourceRoot":"","sources":["../../../src/domain/objects/Thread.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAC/C,uCAAgC;AA+BhC,MAAa,MACX,SAAQ,8BAAqC;CACT;AAFtC,wBAEsC;AAM/B,MAAM,iBAAiB,GAAG,CAC/B,MAAe,EACa,EAAE,CAAC,IAAA,eAAI,EAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AAF9C,QAAA,iBAAiB,qBAE6B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Empty } from 'type-fns';
|
|
2
|
+
import { Thread, ThreadOmitHistory } from './Thread';
|
|
3
|
+
/**
|
|
4
|
+
* .what = a slug that uniquely identifies a role a thread can have
|
|
5
|
+
*/
|
|
6
|
+
export type ThreadRole = string;
|
|
7
|
+
/**
|
|
8
|
+
* .what = a declaration of a role assigned to a thread
|
|
9
|
+
* .note =
|
|
10
|
+
* - a core goal of rhachet is to make it easy to leverage roles in thought branches
|
|
11
|
+
* - given that each thread of thought is heavily contextualized based on its "role", .role is a core primitive of a thought thread, in reality
|
|
12
|
+
*/
|
|
13
|
+
export type ThreadContextRole<TThreadRole extends ThreadRole> = {
|
|
14
|
+
role: TThreadRole;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* .what = a declaration of the available threads and their contexts
|
|
18
|
+
* .note
|
|
19
|
+
* - supports both single and multiple threads per role
|
|
20
|
+
* - enables lookup of a thread by .role
|
|
21
|
+
*/
|
|
22
|
+
export type Threads<TContextDict extends Record<string, object> = Record<never, never>, TMultiplicity extends 'single' | 'multiple' = 'single'> = {
|
|
23
|
+
[K in keyof TContextDict & string]: TMultiplicity extends 'multiple' ? {
|
|
24
|
+
/**
|
|
25
|
+
* .what = the seed thread from which the peers originated
|
|
26
|
+
* .why =
|
|
27
|
+
* - fanin operations need to know which thread to merge back into
|
|
28
|
+
*/
|
|
29
|
+
seed: Thread<TContextDict[K] extends Empty ? ThreadContextRole<K> : ThreadContextRole<K> & TContextDict[K]>;
|
|
30
|
+
/**
|
|
31
|
+
* .what = the peer threads which multiplied from the seed
|
|
32
|
+
* .why =
|
|
33
|
+
* - carries the thread history of the peer threads to the consumer (e.g., fanin)
|
|
34
|
+
*/
|
|
35
|
+
peers: Thread<TContextDict[K] extends Empty ? ThreadContextRole<K> : ThreadContextRole<K> & TContextDict[K]>[];
|
|
36
|
+
} : Thread<TContextDict[K] extends Empty ? ThreadContextRole<K> : ThreadContextRole<K> & TContextDict[K]>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* .what = assures that .history is undefined from threads
|
|
40
|
+
*/
|
|
41
|
+
type ThreadsOmitHistory<TThreads extends Threads<any, any>> = {
|
|
42
|
+
[K in keyof TThreads]: TThreads[K] extends {
|
|
43
|
+
seed: infer TSeed extends Thread<any>;
|
|
44
|
+
peers: Array<infer TPeer extends Thread<any>>;
|
|
45
|
+
} ? {
|
|
46
|
+
seed: ThreadOmitHistory<TSeed>;
|
|
47
|
+
peers: ThreadOmitHistory<TPeer>[];
|
|
48
|
+
} : TThreads[K] extends Thread<any> ? ThreadOmitHistory<TThreads[K]> : never;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* .what = assures that .history is undefined from threads
|
|
52
|
+
*/
|
|
53
|
+
export declare const threadsOmitHistory: <TThreads extends Threads<any, any>>(input: {
|
|
54
|
+
threads: TThreads;
|
|
55
|
+
}) => ThreadsOmitHistory<TThreads>;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.threadsOmitHistory = void 0;
|
|
4
|
+
const Thread_1 = require("./Thread");
|
|
5
|
+
/**
|
|
6
|
+
* .what = assures that .history is undefined from threads
|
|
7
|
+
*/
|
|
8
|
+
const threadsOmitHistory = (input) => {
|
|
9
|
+
const result = Object.fromEntries(Object.entries(input.threads).map(([role, value]) => {
|
|
10
|
+
if ('seed' in value && 'peers' in value) {
|
|
11
|
+
return [
|
|
12
|
+
role,
|
|
13
|
+
{
|
|
14
|
+
seed: (0, Thread_1.threadOmitHistory)(value.seed),
|
|
15
|
+
peers: value.peers.map(Thread_1.threadOmitHistory),
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return [role, (0, Thread_1.threadOmitHistory)(value)];
|
|
21
|
+
}
|
|
22
|
+
}));
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
exports.threadsOmitHistory = threadsOmitHistory;
|
|
26
|
+
//# sourceMappingURL=Threads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Threads.js","sourceRoot":"","sources":["../../../src/domain/objects/Threads.ts"],"names":[],"mappings":";;;AAEA,qCAAwE;AA2ExE;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAAqC,KAEtE,EAAgC,EAAE;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAC/B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QAClD,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;YACxC,OAAO;gBACL,IAAI;gBACJ;oBACE,IAAI,EAAE,IAAA,0BAAiB,EAAC,KAAK,CAAC,IAAI,CAAC;oBACnC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,0BAAiB,CAAC;iBAC1C;aACF,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,EAAE,IAAA,0BAAiB,EAAC,KAAoB,CAAC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,MAAsC,CAAC;AAChD,CAAC,CAAC;AApBW,QAAA,kBAAkB,sBAoB7B"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Weave.js","sourceRoot":"","sources":["../../../src/domain/objects/Weave.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Weaver.js","sourceRoot":"","sources":["../../../src/domain/objects/Weaver.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './Stitch';
|
|
2
|
+
export * from './StitchChoice';
|
|
3
|
+
export * from './StitchCycle';
|
|
4
|
+
export * from './Stitcher';
|
|
5
|
+
export * from './StitchFanout';
|
|
6
|
+
export * from './StitchRoute';
|
|
7
|
+
export * from './StitchSetEvent';
|
|
8
|
+
export * from './StitchStep';
|
|
9
|
+
export * from './StitchTrail';
|
|
10
|
+
export * from './Thread';
|
|
11
|
+
export * from './Threads';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Stitch"), exports);
|
|
18
|
+
__exportStar(require("./StitchChoice"), exports);
|
|
19
|
+
__exportStar(require("./StitchCycle"), exports);
|
|
20
|
+
__exportStar(require("./Stitcher"), exports);
|
|
21
|
+
__exportStar(require("./StitchFanout"), exports);
|
|
22
|
+
__exportStar(require("./StitchRoute"), exports);
|
|
23
|
+
__exportStar(require("./StitchSetEvent"), exports);
|
|
24
|
+
__exportStar(require("./StitchStep"), exports);
|
|
25
|
+
__exportStar(require("./StitchTrail"), exports);
|
|
26
|
+
__exportStar(require("./Thread"), exports);
|
|
27
|
+
__exportStar(require("./Threads"), exports);
|
|
28
|
+
// export * from './Weave';
|
|
29
|
+
// export * from './Weaver';
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/objects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,iDAA+B;AAC/B,gDAA8B;AAC9B,6CAA2B;AAC3B,iDAA+B;AAC/B,gDAA8B;AAC9B,mDAAiC;AACjC,+CAA6B;AAC7B,gDAA8B;AAC9B,2CAAyB;AACzB,4CAA0B;AAC1B,2BAA2B;AAC3B,4BAA4B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './contract/sdk';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./contract/sdk"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChatModel } from 'openai/resources/shared';
|
|
2
|
+
export interface ContextOpenAI {
|
|
3
|
+
openai: {
|
|
4
|
+
auth: {
|
|
5
|
+
key: string;
|
|
6
|
+
};
|
|
7
|
+
llm: {
|
|
8
|
+
model: ChatModel;
|
|
9
|
+
output: 'words' | 'json';
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare const imagineViaOpenAI: (input: string, context: ContextOpenAI) => Promise<string>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.imagineViaOpenAI = void 0;
|
|
7
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
8
|
+
const openai_1 = __importDefault(require("openai"));
|
|
9
|
+
const imagineViaOpenAI = async (input, context) => {
|
|
10
|
+
const openai = new openai_1.default({
|
|
11
|
+
apiKey: context.openai.auth.key,
|
|
12
|
+
});
|
|
13
|
+
const response = await openai.chat.completions.create({
|
|
14
|
+
response_format: context.openai.llm.output === 'json'
|
|
15
|
+
? { type: 'json_object' }
|
|
16
|
+
: undefined,
|
|
17
|
+
messages: [
|
|
18
|
+
{
|
|
19
|
+
role: 'user',
|
|
20
|
+
content: input,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
model: context.openai.llm.model,
|
|
24
|
+
});
|
|
25
|
+
if (!response.choices[0])
|
|
26
|
+
throw new helpful_errors_1.UnexpectedCodePathError('at least one response choice should be provided', { response });
|
|
27
|
+
if (response.choices.length > 1)
|
|
28
|
+
throw new helpful_errors_1.UnexpectedCodePathError('more than one response.choice provided', { response });
|
|
29
|
+
if (!response.choices[0].message.content)
|
|
30
|
+
throw new helpful_errors_1.UnexpectedCodePathError('no content provided in response', {
|
|
31
|
+
response,
|
|
32
|
+
});
|
|
33
|
+
return response.choices[0].message.content;
|
|
34
|
+
};
|
|
35
|
+
exports.imagineViaOpenAI = imagineViaOpenAI;
|
|
36
|
+
//# sourceMappingURL=imagineViaOpenAI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imagineViaOpenAI.js","sourceRoot":"","sources":["../../../../src/logic/stitch/adapters/imagineViaOpenAI.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAyD;AACzD,oDAA4B;AAerB,MAAM,gBAAgB,GAAG,KAAK,EACnC,KAAa,EACb,OAAsB,EACL,EAAE;IACnB,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC;QACxB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG;KAChC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QACpD,eAAe,EACb,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM;YAClC,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE;YACzB,CAAC,CAAC,SAAS;QACf,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,KAAK;aACf;SACF;QACD,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK;KAChC,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACtB,MAAM,IAAI,wCAAuB,CAC/B,iDAAiD,EACjD,EAAE,QAAQ,EAAE,CACb,CAAC;IACJ,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAC7B,MAAM,IAAI,wCAAuB,CAC/B,wCAAwC,EACxC,EAAE,QAAQ,EAAE,CACb,CAAC;IACJ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO;QACtC,MAAM,IAAI,wCAAuB,CAAC,iCAAiC,EAAE;YACnE,QAAQ;SACT,CAAC,CAAC;IACL,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;AAC7C,CAAC,CAAC;AAnCW,QAAA,gBAAgB,oBAmC3B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StitchSetEvent } from '../../domain/objects/StitchSetEvent';
|
|
2
|
+
import { StitchStep } from '../../domain/objects/StitchStep';
|
|
3
|
+
import { GStitcher } from '../../domain/objects/Stitcher';
|
|
4
|
+
import { Thread } from '../../domain/objects/Thread';
|
|
5
|
+
import { Threads } from '../../domain/objects/Threads';
|
|
6
|
+
/**
|
|
7
|
+
* .what = extracts the base thread to stitch into
|
|
8
|
+
* .why = handles both single and multiple thread formats
|
|
9
|
+
*/
|
|
10
|
+
export declare const getStitchee: <T>(thread: Thread<T> | {
|
|
11
|
+
seed: Thread<T>;
|
|
12
|
+
peers: Thread<T>[];
|
|
13
|
+
}) => Thread<T>;
|
|
14
|
+
/**
|
|
15
|
+
* .what = normalizes a threads object to the 'single' shape
|
|
16
|
+
* .why = simplifies downstream usage that expects Threads<any, 'single'>
|
|
17
|
+
*/
|
|
18
|
+
export declare const normThreadsToSingle: <TThreads extends Threads<any, any>>(input: TThreads) => ReqThreadsSingle<TThreads>;
|
|
19
|
+
type ReqThreadsSingle<T> = T extends Threads<infer TContextDict, any> ? Threads<TContextDict, 'single'> : never;
|
|
20
|
+
/**
|
|
21
|
+
* .what = enstitche a single stitch step to produce a stitch
|
|
22
|
+
*/
|
|
23
|
+
export declare const enstitch: <TStitcher extends GStitcher<Threads<any, any>, any, any>>(input: {
|
|
24
|
+
stitcher: StitchStep<TStitcher>;
|
|
25
|
+
threads: TStitcher['threads'];
|
|
26
|
+
}, context: TStitcher['context']) => Promise<StitchSetEvent<ReqThreadsSingle<TStitcher['threads']>, TStitcher['output']>>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enstitch = exports.normThreadsToSingle = exports.getStitchee = void 0;
|
|
4
|
+
const uni_time_1 = require("@ehmpathy/uni-time");
|
|
5
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
6
|
+
const uuid_fns_1 = require("uuid-fns");
|
|
7
|
+
const Stitch_1 = require("../../domain/objects/Stitch");
|
|
8
|
+
const StitchSetEvent_1 = require("../../domain/objects/StitchSetEvent");
|
|
9
|
+
const StitchTrail_1 = require("../../domain/objects/StitchTrail");
|
|
10
|
+
const Stitcher_1 = require("../../domain/objects/Stitcher");
|
|
11
|
+
const Thread_1 = require("../../domain/objects/Thread");
|
|
12
|
+
const invokeImagineStitcher_1 = require("./invokeImagineStitcher");
|
|
13
|
+
/**
|
|
14
|
+
* .what = extracts the base thread to stitch into
|
|
15
|
+
* .why = handles both single and multiple thread formats
|
|
16
|
+
*/
|
|
17
|
+
const getStitchee = (thread) => {
|
|
18
|
+
if ('seed' in thread && 'peers' in thread) {
|
|
19
|
+
return thread.seed;
|
|
20
|
+
}
|
|
21
|
+
return thread;
|
|
22
|
+
};
|
|
23
|
+
exports.getStitchee = getStitchee;
|
|
24
|
+
/**
|
|
25
|
+
* .what = normalizes a threads object to the 'single' shape
|
|
26
|
+
* .why = simplifies downstream usage that expects Threads<any, 'single'>
|
|
27
|
+
*/
|
|
28
|
+
const normThreadsToSingle = (input) => {
|
|
29
|
+
const result = {};
|
|
30
|
+
for (const key in input) {
|
|
31
|
+
const value = input[key];
|
|
32
|
+
result[key] =
|
|
33
|
+
'seed' in value && 'peers' in value
|
|
34
|
+
? value.seed // reduce multiple to seed
|
|
35
|
+
: value; // already single
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
exports.normThreadsToSingle = normThreadsToSingle;
|
|
40
|
+
/**
|
|
41
|
+
* .what = enstitche a single stitch step to produce a stitch
|
|
42
|
+
*/
|
|
43
|
+
const enstitch = async (input, context) => {
|
|
44
|
+
// enstitch the output
|
|
45
|
+
const result = await (() => {
|
|
46
|
+
// if the stitcher is of type "compute", then execute the computation; // todo: add observability on duration
|
|
47
|
+
if (input.stitcher.form === 'COMPUTE')
|
|
48
|
+
return input.stitcher.invoke({ threads: input.threads }, context);
|
|
49
|
+
// if the stitcher is of type "imagine", then execute the imagination // todo: add observability
|
|
50
|
+
if (input.stitcher.form === 'IMAGINE')
|
|
51
|
+
return (0, invokeImagineStitcher_1.invokeImagineStitcher)({ stitcher: input.stitcher, threads: input.threads }, context);
|
|
52
|
+
// otherwise, unsupported and unexpected; should have been compiletime prevented
|
|
53
|
+
throw new helpful_errors_1.UnexpectedCodePathError('why did we get an unsupported stitcher.form?', { stitcher: input.stitcher });
|
|
54
|
+
})();
|
|
55
|
+
const stitchUuid = (0, uuid_fns_1.getUuid)();
|
|
56
|
+
const stitch = Stitch_1.Stitch.build({
|
|
57
|
+
uuid: stitchUuid,
|
|
58
|
+
createdAt: (0, uni_time_1.asUniDateTime)(new Date()),
|
|
59
|
+
stitcher: (0, Stitcher_1.asStitcherDesc)({ stitcher: input.stitcher }),
|
|
60
|
+
trail: {
|
|
61
|
+
desc: (0, StitchTrail_1.asStitchTrailDesc)({
|
|
62
|
+
trail: [
|
|
63
|
+
...context.stitch.trail,
|
|
64
|
+
StitchTrail_1.StitchTrailMarker.build({
|
|
65
|
+
stitchUuid,
|
|
66
|
+
stitcherSlug: input.stitcher.slug,
|
|
67
|
+
}),
|
|
68
|
+
],
|
|
69
|
+
}),
|
|
70
|
+
// markers: context.stitch.trail, // todo: enable via context verbosity control
|
|
71
|
+
},
|
|
72
|
+
input: result.input,
|
|
73
|
+
output: result.output,
|
|
74
|
+
});
|
|
75
|
+
// mutate the input thread to attach the new stitch
|
|
76
|
+
const stitcheeKey = input.stitcher.stitchee;
|
|
77
|
+
const stitcheeBefore = Thread_1.Thread.build((0, exports.getStitchee)(input.threads[stitcheeKey] ??
|
|
78
|
+
helpful_errors_1.UnexpectedCodePathError.throw('could not find stitchee from input.threads')));
|
|
79
|
+
const stitcheeAfter = stitcheeBefore.clone({
|
|
80
|
+
stitches: [...stitcheeBefore.stitches, stitch], // append the latest stitch
|
|
81
|
+
});
|
|
82
|
+
// declare that this stitch has been set into "the fabric of reality"; energy => stitch
|
|
83
|
+
const event = StitchSetEvent_1.StitchSetEvent.build({
|
|
84
|
+
occurredAt: (0, uni_time_1.asUniDateTime)(new Date()),
|
|
85
|
+
stitch,
|
|
86
|
+
threads: (0, exports.normThreadsToSingle)({
|
|
87
|
+
...input.threads,
|
|
88
|
+
[stitcheeKey]: stitcheeAfter,
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
// emit the event
|
|
92
|
+
// todo: emit events via withStitchTrail
|
|
93
|
+
// and bubble it up
|
|
94
|
+
return event;
|
|
95
|
+
};
|
|
96
|
+
exports.enstitch = enstitch;
|
|
97
|
+
//# sourceMappingURL=enstitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enstitch.js","sourceRoot":"","sources":["../../../src/logic/stitch/enstitch.ts"],"names":[],"mappings":";;;AAAA,iDAAmD;AACnD,mDAAyD;AACzD,uCAAmC;AAEnC,wDAAqD;AACrD,wEAAqE;AAErE,kEAG0C;AAC1C,4DAA0E;AAC1E,wDAAqD;AAErD,mEAAgE;AAEhE;;;GAGG;AACI,MAAM,WAAW,GAAG,CACzB,MAA2D,EAChD,EAAE;IACb,IAAI,MAAM,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;QAC1C,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB;AAEF;;;GAGG;AACI,M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