@promptbook/cli 0.81.0-13 → 0.81.0-15
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/esm/index.es.js +309 -195
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -2
- package/esm/typings/src/formfactors/image-generator/ImageGeneratorFormfactorDefinition.d.ts +24 -0
- package/esm/typings/src/formfactors/index.d.ts +22 -5
- package/esm/typings/src/high-level-abstractions/index.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
- package/esm/typings/src/other/templates/getBookTemplates.d.ts +1 -0
- package/esm/typings/src/utils/validators/filePath/{isPathRoot.d.ts → isRootPath.d.ts} +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +309 -195
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/utils/validators/filePath/{isPathRoot.test.d.ts → isRootPath.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -39,7 +39,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
39
39
|
* @generated
|
|
40
40
|
* @see https://github.com/webgptorg/promptbook
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
42
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-14';
|
|
43
43
|
/**
|
|
44
44
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
45
45
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2070,6 +2070,25 @@ var $llmToolsMetadataRegister = new $Register('llm_tools_metadata');
|
|
|
2070
2070
|
* TODO: [®] DRY Register logic
|
|
2071
2071
|
*/
|
|
2072
2072
|
|
|
2073
|
+
/**
|
|
2074
|
+
* Determines if the given path is a root path.
|
|
2075
|
+
*
|
|
2076
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
2077
|
+
* @public exported from `@promptbook/utils`
|
|
2078
|
+
*/
|
|
2079
|
+
function isRootPath(value) {
|
|
2080
|
+
if (value === '/') {
|
|
2081
|
+
return true;
|
|
2082
|
+
}
|
|
2083
|
+
if (/^[A-Z]:\\$/i.test(value)) {
|
|
2084
|
+
return true;
|
|
2085
|
+
}
|
|
2086
|
+
return false;
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* TODO: [🍏] Make for MacOS paths
|
|
2090
|
+
*/
|
|
2091
|
+
|
|
2073
2092
|
/**
|
|
2074
2093
|
* @@@
|
|
2075
2094
|
*
|
|
@@ -2084,17 +2103,46 @@ var $llmToolsMetadataRegister = new $Register('llm_tools_metadata');
|
|
|
2084
2103
|
* @public exported from `@promptbook/node`
|
|
2085
2104
|
*/
|
|
2086
2105
|
function $provideLlmToolsConfigurationFromEnv() {
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2107
|
+
var rootDirname, i, envFilename, llmToolsConfiguration;
|
|
2108
|
+
return __generator(this, function (_a) {
|
|
2109
|
+
switch (_a.label) {
|
|
2110
|
+
case 0:
|
|
2111
|
+
if (!$isRunningInNode()) {
|
|
2112
|
+
throw new EnvironmentMismatchError('Function `$provideLlmToolsFromEnv` works only in Node.js environment');
|
|
2113
|
+
}
|
|
2114
|
+
rootDirname = process.cwd();
|
|
2115
|
+
i = 0;
|
|
2116
|
+
_a.label = 1;
|
|
2117
|
+
case 1:
|
|
2118
|
+
if (!(i < LOOP_LIMIT)) return [3 /*break*/, 4];
|
|
2119
|
+
envFilename = join(rootDirname, '.env' /* <- TODO: [🕝] Make here more candidates */);
|
|
2120
|
+
console.log({ rootDirname: rootDirname, envFilename: envFilename });
|
|
2121
|
+
return [4 /*yield*/, isFileExisting(envFilename, $provideFilesystemForNode())];
|
|
2122
|
+
case 2:
|
|
2123
|
+
// <- TODO: !!!!!!! Remove
|
|
2124
|
+
if (_a.sent()) {
|
|
2125
|
+
dotenv.config({ path: envFilename });
|
|
2126
|
+
return [3 /*break*/, 4];
|
|
2127
|
+
}
|
|
2128
|
+
if (isRootPath(rootDirname)) {
|
|
2129
|
+
return [3 /*break*/, 4];
|
|
2130
|
+
}
|
|
2131
|
+
// Note: If the directory does not exist, try the parent directory
|
|
2132
|
+
rootDirname = join(rootDirname, '..');
|
|
2133
|
+
_a.label = 3;
|
|
2134
|
+
case 3:
|
|
2135
|
+
i++;
|
|
2136
|
+
return [3 /*break*/, 1];
|
|
2137
|
+
case 4:
|
|
2138
|
+
llmToolsConfiguration = $llmToolsMetadataRegister
|
|
2139
|
+
.list()
|
|
2140
|
+
.map(function (metadata) { return metadata.createConfigurationFromEnv(process.env); })
|
|
2141
|
+
.filter(function (configuration) { return configuration !== null; });
|
|
2142
|
+
return [2 /*return*/, llmToolsConfiguration];
|
|
2143
|
+
}
|
|
2144
|
+
});
|
|
2145
|
+
});
|
|
2098
2146
|
}
|
|
2099
2147
|
/**
|
|
2100
2148
|
* TODO: [🧠][🪁] Maybe do allow to do auto-install if package not registered and not found
|
|
@@ -2609,18 +2657,28 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
2609
2657
|
*/
|
|
2610
2658
|
function $provideLlmToolsFromEnv(options) {
|
|
2611
2659
|
if (options === void 0) { options = {}; }
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2660
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2661
|
+
var configuration;
|
|
2662
|
+
return __generator(this, function (_a) {
|
|
2663
|
+
switch (_a.label) {
|
|
2664
|
+
case 0:
|
|
2665
|
+
if (!$isRunningInNode()) {
|
|
2666
|
+
throw new EnvironmentMismatchError('Function `$provideLlmToolsFromEnv` works only in Node.js environment');
|
|
2667
|
+
}
|
|
2668
|
+
return [4 /*yield*/, $provideLlmToolsConfigurationFromEnv()];
|
|
2669
|
+
case 1:
|
|
2670
|
+
configuration = _a.sent();
|
|
2671
|
+
if (configuration.length === 0) {
|
|
2672
|
+
if ($llmToolsMetadataRegister.list().length === 0) {
|
|
2673
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n No LLM tools registered, this is probably a bug in the Promptbook library\n\n ".concat(block($registeredLlmToolsMessage()), "}\n "); }));
|
|
2674
|
+
}
|
|
2675
|
+
// TODO: [🥃]
|
|
2676
|
+
throw new Error(spaceTrim(function (block) { return "\n No LLM tools found in the environment\n\n ".concat(block($registeredLlmToolsMessage()), "}\n "); }));
|
|
2677
|
+
}
|
|
2678
|
+
return [2 /*return*/, createLlmToolsFromConfiguration(configuration, options)];
|
|
2679
|
+
}
|
|
2680
|
+
});
|
|
2681
|
+
});
|
|
2624
2682
|
}
|
|
2625
2683
|
/**
|
|
2626
2684
|
* TODO: @@@ write `$provideLlmToolsFromEnv` vs `$provideLlmToolsConfigurationFromEnv` vs `createLlmToolsFromConfiguration`
|
|
@@ -2638,17 +2696,30 @@ function $provideLlmToolsFromEnv(options) {
|
|
|
2638
2696
|
* @private within the repository - for CLI utils
|
|
2639
2697
|
*/
|
|
2640
2698
|
function $provideLlmToolsForWizzardOrCli(options) {
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2699
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2700
|
+
var isCacheReloaded, _a, _b;
|
|
2701
|
+
return __generator(this, function (_c) {
|
|
2702
|
+
switch (_c.label) {
|
|
2703
|
+
case 0:
|
|
2704
|
+
if (!$isRunningInNode()) {
|
|
2705
|
+
throw new EnvironmentMismatchError('Function `$provideLlmToolsForWizzardOrCli` works only in Node.js environment');
|
|
2706
|
+
}
|
|
2707
|
+
isCacheReloaded = (options !== null && options !== void 0 ? options : {}).isCacheReloaded;
|
|
2708
|
+
_a = cacheLlmTools;
|
|
2709
|
+
_b = countTotalUsage;
|
|
2710
|
+
// <- Note: for example here we don`t want the [🌯]
|
|
2711
|
+
return [4 /*yield*/, $provideLlmToolsFromEnv()];
|
|
2712
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [_b.apply(void 0, [
|
|
2713
|
+
// <- Note: for example here we don`t want the [🌯]
|
|
2714
|
+
_c.sent()]),
|
|
2715
|
+
{
|
|
2716
|
+
storage: new FileCacheStorage({ fs: $provideFilesystemForNode() }, {
|
|
2717
|
+
rootFolderPath: join(process.cwd(), DEFAULT_EXECUTIONS_CACHE_DIRNAME),
|
|
2718
|
+
}),
|
|
2719
|
+
isCacheReloaded: isCacheReloaded,
|
|
2720
|
+
}])];
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2652
2723
|
});
|
|
2653
2724
|
}
|
|
2654
2725
|
/**
|
|
@@ -2670,10 +2741,14 @@ function initializeListModelsCommand(program) {
|
|
|
2670
2741
|
listModelsCommand.description(spaceTrim("\n List all available and configured LLM models\n "));
|
|
2671
2742
|
listModelsCommand.action(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2672
2743
|
return __generator(this, function (_a) {
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2744
|
+
switch (_a.label) {
|
|
2745
|
+
case 0: return [4 /*yield*/, $provideLlmToolsForWizzardOrCli({})];
|
|
2746
|
+
case 1:
|
|
2747
|
+
_a.sent();
|
|
2748
|
+
// <- Note: Providing LLM tools will make a side effect of registering all available LLM tools to show the message
|
|
2749
|
+
console.info($registeredLlmToolsMessage());
|
|
2750
|
+
return [2 /*return*/, process.exit(0)];
|
|
2751
|
+
}
|
|
2677
2752
|
});
|
|
2678
2753
|
}); });
|
|
2679
2754
|
}
|
|
@@ -7962,6 +8037,35 @@ var GenericFormfactorDefinition = {
|
|
|
7962
8037
|
pipelineInterface: GENERIC_PIPELINE_INTERFACE,
|
|
7963
8038
|
};
|
|
7964
8039
|
|
|
8040
|
+
/**
|
|
8041
|
+
* Image generator is form of app that generates image from input message
|
|
8042
|
+
*
|
|
8043
|
+
* @public exported from `@promptbook/core`
|
|
8044
|
+
*/
|
|
8045
|
+
var ImageGeneratorFormfactorDefinition = {
|
|
8046
|
+
name: 'IMAGE_GENERATOR',
|
|
8047
|
+
description: "@@@",
|
|
8048
|
+
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
|
|
8049
|
+
pipelineInterface: {
|
|
8050
|
+
inputParameters: [
|
|
8051
|
+
{
|
|
8052
|
+
name: 'inputMessage',
|
|
8053
|
+
description: "Input message to be image made from",
|
|
8054
|
+
isInput: true,
|
|
8055
|
+
isOutput: false,
|
|
8056
|
+
},
|
|
8057
|
+
],
|
|
8058
|
+
outputParameters: [
|
|
8059
|
+
{
|
|
8060
|
+
name: 'prompt',
|
|
8061
|
+
description: "Prompt to be used for image generation",
|
|
8062
|
+
isInput: false,
|
|
8063
|
+
isOutput: true,
|
|
8064
|
+
},
|
|
8065
|
+
],
|
|
8066
|
+
},
|
|
8067
|
+
};
|
|
8068
|
+
|
|
7965
8069
|
/**
|
|
7966
8070
|
* Matcher is form of app that @@@
|
|
7967
8071
|
*
|
|
@@ -8060,6 +8164,7 @@ var FORMFACTOR_DEFINITIONS = [
|
|
|
8060
8164
|
SheetsFormfactorDefinition,
|
|
8061
8165
|
MatcherFormfactorDefinition,
|
|
8062
8166
|
GeneratorFormfactorDefinition,
|
|
8167
|
+
ImageGeneratorFormfactorDefinition,
|
|
8063
8168
|
];
|
|
8064
8169
|
/**
|
|
8065
8170
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -10814,25 +10919,6 @@ function unwrapResult(text, options) {
|
|
|
10814
10919
|
* TODO: [🧠] Should this also unwrap the (parenthesis)
|
|
10815
10920
|
*/
|
|
10816
10921
|
|
|
10817
|
-
/**
|
|
10818
|
-
* Determines if the given path is a root path.
|
|
10819
|
-
*
|
|
10820
|
-
* Note: This does not check if the file exists only if the path is valid
|
|
10821
|
-
* @public exported from `@promptbook/utils`
|
|
10822
|
-
*/
|
|
10823
|
-
function isPathRoot(value) {
|
|
10824
|
-
if (value === '/') {
|
|
10825
|
-
return true;
|
|
10826
|
-
}
|
|
10827
|
-
if (/^[A-Z]:\\$/i.test(value)) {
|
|
10828
|
-
return true;
|
|
10829
|
-
}
|
|
10830
|
-
return false;
|
|
10831
|
-
}
|
|
10832
|
-
/**
|
|
10833
|
-
* TODO: [🍏] Make for MacOS paths
|
|
10834
|
-
*/
|
|
10835
|
-
|
|
10836
10922
|
/**
|
|
10837
10923
|
* Extracts code block from markdown.
|
|
10838
10924
|
*
|
|
@@ -11086,9 +11172,11 @@ function $provideExecutionToolsForNode(options) {
|
|
|
11086
11172
|
throw new EnvironmentMismatchError('Function `$getExecutionToolsForNode` works only in Node.js environment');
|
|
11087
11173
|
}
|
|
11088
11174
|
fs = $provideFilesystemForNode();
|
|
11089
|
-
|
|
11090
|
-
return [4 /*yield*/, $provideExecutablesForNode(options)];
|
|
11175
|
+
return [4 /*yield*/, $provideLlmToolsFromEnv(options)];
|
|
11091
11176
|
case 1:
|
|
11177
|
+
llm = _b.sent();
|
|
11178
|
+
return [4 /*yield*/, $provideExecutablesForNode(options)];
|
|
11179
|
+
case 2:
|
|
11092
11180
|
executables = _b.sent();
|
|
11093
11181
|
_a = {
|
|
11094
11182
|
llm: llm,
|
|
@@ -11096,7 +11184,7 @@ function $provideExecutionToolsForNode(options) {
|
|
|
11096
11184
|
executables: executables
|
|
11097
11185
|
};
|
|
11098
11186
|
return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, options)];
|
|
11099
|
-
case
|
|
11187
|
+
case 3:
|
|
11100
11188
|
tools = (_a.scrapers = _b.sent(),
|
|
11101
11189
|
_a.script = [new JavascriptExecutionTools(options)],
|
|
11102
11190
|
_a);
|
|
@@ -11623,16 +11711,18 @@ function initializeMakeCommand(program) {
|
|
|
11623
11711
|
isCacheReloaded: isCacheReloaded,
|
|
11624
11712
|
};
|
|
11625
11713
|
fs = $provideFilesystemForNode(prepareAndScrapeOptions);
|
|
11626
|
-
|
|
11627
|
-
return [4 /*yield*/, $provideExecutablesForNode(prepareAndScrapeOptions)];
|
|
11714
|
+
return [4 /*yield*/, $provideLlmToolsForWizzardOrCli(prepareAndScrapeOptions)];
|
|
11628
11715
|
case 1:
|
|
11716
|
+
llm = _e.sent();
|
|
11717
|
+
return [4 /*yield*/, $provideExecutablesForNode(prepareAndScrapeOptions)];
|
|
11718
|
+
case 2:
|
|
11629
11719
|
executables = _e.sent();
|
|
11630
11720
|
_b = {
|
|
11631
11721
|
llm: llm,
|
|
11632
11722
|
fs: fs
|
|
11633
11723
|
};
|
|
11634
11724
|
return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, prepareAndScrapeOptions)];
|
|
11635
|
-
case
|
|
11725
|
+
case 3:
|
|
11636
11726
|
tools = (_b.scrapers = _e.sent(),
|
|
11637
11727
|
_b.script = [
|
|
11638
11728
|
/*new JavascriptExecutionTools(options)*/
|
|
@@ -11643,33 +11733,33 @@ function initializeMakeCommand(program) {
|
|
|
11643
11733
|
isRecursive: true,
|
|
11644
11734
|
// <- TODO: [🍖] Add `intermediateFilesStrategy`
|
|
11645
11735
|
})];
|
|
11646
|
-
case
|
|
11736
|
+
case 4:
|
|
11647
11737
|
collection = _e.sent();
|
|
11648
11738
|
return [4 /*yield*/, collection.listPipelines()];
|
|
11649
|
-
case
|
|
11739
|
+
case 5:
|
|
11650
11740
|
pipelinesUrls = _e.sent();
|
|
11651
11741
|
if (pipelinesUrls.length === 0) {
|
|
11652
11742
|
console.error(colors.red("No books found in \"".concat(path, "\"")));
|
|
11653
11743
|
return [2 /*return*/, process.exit(1)];
|
|
11654
11744
|
}
|
|
11655
|
-
_e.label = 5;
|
|
11656
|
-
case 5:
|
|
11657
|
-
_e.trys.push([5, 16, 17, 18]);
|
|
11658
|
-
validations_1 = __values(validations), validations_1_1 = validations_1.next();
|
|
11659
11745
|
_e.label = 6;
|
|
11660
11746
|
case 6:
|
|
11661
|
-
|
|
11662
|
-
|
|
11747
|
+
_e.trys.push([6, 17, 18, 19]);
|
|
11748
|
+
validations_1 = __values(validations), validations_1_1 = validations_1.next();
|
|
11663
11749
|
_e.label = 7;
|
|
11664
11750
|
case 7:
|
|
11665
|
-
|
|
11666
|
-
|
|
11751
|
+
if (!!validations_1_1.done) return [3 /*break*/, 16];
|
|
11752
|
+
validation_1 = validations_1_1.value;
|
|
11667
11753
|
_e.label = 8;
|
|
11668
11754
|
case 8:
|
|
11669
|
-
|
|
11755
|
+
_e.trys.push([8, 13, 14, 15]);
|
|
11756
|
+
pipelinesUrls_1 = (e_1 = void 0, __values(pipelinesUrls)), pipelinesUrls_1_1 = pipelinesUrls_1.next();
|
|
11757
|
+
_e.label = 9;
|
|
11758
|
+
case 9:
|
|
11759
|
+
if (!!pipelinesUrls_1_1.done) return [3 /*break*/, 12];
|
|
11670
11760
|
pipelineUrl = pipelinesUrls_1_1.value;
|
|
11671
11761
|
return [4 /*yield*/, collection.getPipelineByUrl(pipelineUrl)];
|
|
11672
|
-
case
|
|
11762
|
+
case 10:
|
|
11673
11763
|
pipeline = _e.sent();
|
|
11674
11764
|
if (validation_1 === 'logic') {
|
|
11675
11765
|
validatePipeline(pipeline);
|
|
@@ -11677,37 +11767,37 @@ function initializeMakeCommand(program) {
|
|
|
11677
11767
|
console.info(colors.cyan("Validated logic of ".concat(pipeline.pipelineUrl)));
|
|
11678
11768
|
}
|
|
11679
11769
|
}
|
|
11680
|
-
_e.label =
|
|
11681
|
-
case
|
|
11770
|
+
_e.label = 11;
|
|
11771
|
+
case 11:
|
|
11682
11772
|
pipelinesUrls_1_1 = pipelinesUrls_1.next();
|
|
11683
|
-
return [3 /*break*/,
|
|
11684
|
-
case
|
|
11685
|
-
case
|
|
11773
|
+
return [3 /*break*/, 9];
|
|
11774
|
+
case 12: return [3 /*break*/, 15];
|
|
11775
|
+
case 13:
|
|
11686
11776
|
e_1_1 = _e.sent();
|
|
11687
11777
|
e_1 = { error: e_1_1 };
|
|
11688
|
-
return [3 /*break*/,
|
|
11689
|
-
case
|
|
11778
|
+
return [3 /*break*/, 15];
|
|
11779
|
+
case 14:
|
|
11690
11780
|
try {
|
|
11691
11781
|
if (pipelinesUrls_1_1 && !pipelinesUrls_1_1.done && (_d = pipelinesUrls_1.return)) _d.call(pipelinesUrls_1);
|
|
11692
11782
|
}
|
|
11693
11783
|
finally { if (e_1) throw e_1.error; }
|
|
11694
11784
|
return [7 /*endfinally*/];
|
|
11695
|
-
case
|
|
11785
|
+
case 15:
|
|
11696
11786
|
validations_1_1 = validations_1.next();
|
|
11697
|
-
return [3 /*break*/,
|
|
11698
|
-
case
|
|
11699
|
-
case
|
|
11787
|
+
return [3 /*break*/, 7];
|
|
11788
|
+
case 16: return [3 /*break*/, 19];
|
|
11789
|
+
case 17:
|
|
11700
11790
|
e_2_1 = _e.sent();
|
|
11701
11791
|
e_2 = { error: e_2_1 };
|
|
11702
|
-
return [3 /*break*/,
|
|
11703
|
-
case
|
|
11792
|
+
return [3 /*break*/, 19];
|
|
11793
|
+
case 18:
|
|
11704
11794
|
try {
|
|
11705
11795
|
if (validations_1_1 && !validations_1_1.done && (_c = validations_1.return)) _c.call(validations_1);
|
|
11706
11796
|
}
|
|
11707
11797
|
finally { if (e_2) throw e_2.error; }
|
|
11708
11798
|
return [7 /*endfinally*/];
|
|
11709
|
-
case
|
|
11710
|
-
case
|
|
11799
|
+
case 19: return [4 /*yield*/, collectionToJson(collection)];
|
|
11800
|
+
case 20:
|
|
11711
11801
|
collectionJson = _e.sent();
|
|
11712
11802
|
collectionJsonString = stringifyPipelineJson(collectionJson).trim();
|
|
11713
11803
|
collectionJsonItems = (function () {
|
|
@@ -11744,27 +11834,27 @@ function initializeMakeCommand(program) {
|
|
|
11744
11834
|
}
|
|
11745
11835
|
});
|
|
11746
11836
|
}); };
|
|
11747
|
-
if (!formats.includes('json')) return [3 /*break*/,
|
|
11837
|
+
if (!formats.includes('json')) return [3 /*break*/, 22];
|
|
11748
11838
|
formats = formats.filter(function (format) { return format !== 'json'; });
|
|
11749
11839
|
return [4 /*yield*/, saveFile('json', collectionJsonString)];
|
|
11750
|
-
case 20:
|
|
11751
|
-
_e.sent();
|
|
11752
|
-
_e.label = 21;
|
|
11753
11840
|
case 21:
|
|
11754
|
-
|
|
11841
|
+
_e.sent();
|
|
11842
|
+
_e.label = 22;
|
|
11843
|
+
case 22:
|
|
11844
|
+
if (!(formats.includes('javascript') || formats.includes('js'))) return [3 /*break*/, 24];
|
|
11755
11845
|
formats = formats.filter(function (format) { return format !== 'javascript' && format !== 'js'; });
|
|
11756
11846
|
return [4 /*yield*/, saveFile('js', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @private internal cache for `").concat(functionName, "`\n */\n let pipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(){\n if(pipelineCollection===null){\n pipelineCollection = createCollectionFromJson(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }))];
|
|
11757
|
-
case 22:
|
|
11758
|
-
(_e.sent()) + '\n';
|
|
11759
|
-
_e.label = 23;
|
|
11760
11847
|
case 23:
|
|
11761
|
-
|
|
11848
|
+
(_e.sent()) + '\n';
|
|
11849
|
+
_e.label = 24;
|
|
11850
|
+
case 24:
|
|
11851
|
+
if (!(formats.includes('typescript') || formats.includes('ts'))) return [3 /*break*/, 26];
|
|
11762
11852
|
formats = formats.filter(function (format) { return format !== 'typescript' && format !== 'ts'; });
|
|
11763
11853
|
return [4 /*yield*/, saveFile('ts', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n import type { PipelineCollection } from '@promptbook/types';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @private internal cache for `").concat(functionName, "`\n * @generated\n */\n let pipelineCollection: null | PipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(): PipelineCollection{\n if(pipelineCollection===null){\n\n // TODO: !!!!!! Use book string literal notation\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n pipelineCollection = (createCollectionFromJson as (..._: any) => PipelineCollection)(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }) + '\n')];
|
|
11764
|
-
case 24:
|
|
11765
|
-
_e.sent();
|
|
11766
|
-
_e.label = 25;
|
|
11767
11854
|
case 25:
|
|
11855
|
+
_e.sent();
|
|
11856
|
+
_e.label = 26;
|
|
11857
|
+
case 26:
|
|
11768
11858
|
if (formats.length > 0) {
|
|
11769
11859
|
console.warn(colors.yellow("Format ".concat(formats.join(' and '), " is not supported")));
|
|
11770
11860
|
}
|
|
@@ -12263,7 +12353,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
12263
12353
|
*/
|
|
12264
12354
|
function $getCompiledBook(tools, pipelineSource, options) {
|
|
12265
12355
|
return __awaiter(this, void 0, void 0, function () {
|
|
12266
|
-
var fs, fetch, filePathRaw, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, pipelineString, pipelineJson, e_1_1,
|
|
12356
|
+
var fs, fetch, filePathRaw, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, pipelineString, pipelineJson, e_1_1, rootDirname, _loop_1, i, state_1, response_1, pipelineString, pipelineJson;
|
|
12267
12357
|
var e_1, _a;
|
|
12268
12358
|
var _this = this;
|
|
12269
12359
|
return __generator(this, function (_b) {
|
|
@@ -12271,6 +12361,7 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12271
12361
|
case 0:
|
|
12272
12362
|
fs = tools.fs, fetch = tools.fetch;
|
|
12273
12363
|
if (!isValidFilePath(pipelineSource)) return [3 /*break*/, 10];
|
|
12364
|
+
console.log("Strategy 1\uFE0F\u20E3");
|
|
12274
12365
|
filePathRaw = pipelineSource;
|
|
12275
12366
|
filePath = null;
|
|
12276
12367
|
filePathCandidates = [filePathRaw, "".concat(filePathRaw, ".md"), "".concat(filePathRaw, ".book.md"), "".concat(filePathRaw, ".book.md")];
|
|
@@ -12312,23 +12403,33 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12312
12403
|
return [7 /*endfinally*/];
|
|
12313
12404
|
case 10:
|
|
12314
12405
|
if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 14];
|
|
12315
|
-
|
|
12406
|
+
console.log("Strategy 2\uFE0F\u20E3");
|
|
12407
|
+
rootDirname = process.cwd();
|
|
12316
12408
|
_loop_1 = function (i) {
|
|
12317
|
-
var
|
|
12318
|
-
return __generator(this, function (
|
|
12319
|
-
switch (
|
|
12409
|
+
var booksDirname, collection_1, _c, _d, _e, pipeline;
|
|
12410
|
+
return __generator(this, function (_f) {
|
|
12411
|
+
switch (_f.label) {
|
|
12320
12412
|
case 0:
|
|
12321
|
-
|
|
12322
|
-
|
|
12413
|
+
booksDirname = join(rootDirname, DEFAULT_BOOKS_DIRNAME /* <- TODO: [🕝] Make here more candidates */);
|
|
12414
|
+
console.log({ rootDirname: rootDirname, booksDirname: booksDirname });
|
|
12415
|
+
return [4 /*yield*/, isDirectoryExisting(booksDirname, fs)];
|
|
12323
12416
|
case 1:
|
|
12324
|
-
|
|
12417
|
+
if (!_f.sent()) return [3 /*break*/, 5];
|
|
12418
|
+
return [4 /*yield*/, createCollectionFromDirectory(booksDirname, tools, __assign({ isRecursive: true, rootDirname: booksDirname }, options))];
|
|
12419
|
+
case 2:
|
|
12420
|
+
collection_1 = _f.sent();
|
|
12421
|
+
_d = (_c = console).log;
|
|
12422
|
+
_e = ['listPipelines'];
|
|
12423
|
+
return [4 /*yield*/, collection_1.listPipelines()];
|
|
12424
|
+
case 3:
|
|
12425
|
+
_d.apply(_c, _e.concat([_f.sent()]));
|
|
12325
12426
|
return [4 /*yield*/, (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
12326
12427
|
var error_1;
|
|
12327
12428
|
return __generator(this, function (_a) {
|
|
12328
12429
|
switch (_a.label) {
|
|
12329
12430
|
case 0:
|
|
12330
12431
|
_a.trys.push([0, 2, , 3]);
|
|
12331
|
-
return [4 /*yield*/,
|
|
12432
|
+
return [4 /*yield*/, collection_1.getPipelineByUrl(pipelineSource)];
|
|
12332
12433
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12333
12434
|
case 2:
|
|
12334
12435
|
error_1 = _a.sent();
|
|
@@ -12341,16 +12442,20 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12341
12442
|
}
|
|
12342
12443
|
});
|
|
12343
12444
|
}); })()];
|
|
12344
|
-
case
|
|
12345
|
-
pipeline =
|
|
12445
|
+
case 4:
|
|
12446
|
+
pipeline = _f.sent();
|
|
12447
|
+
console.log({ pipeline: pipeline });
|
|
12448
|
+
// <- TODO: !!!!!!! Remove
|
|
12346
12449
|
if (pipeline !== null) {
|
|
12347
12450
|
return [2 /*return*/, { value: pipeline }];
|
|
12348
12451
|
}
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
|
|
12452
|
+
_f.label = 5;
|
|
12453
|
+
case 5:
|
|
12454
|
+
if (isRootPath(rootDirname)) {
|
|
12455
|
+
return [2 /*return*/, "break-up_to_root"];
|
|
12352
12456
|
}
|
|
12353
|
-
|
|
12457
|
+
// Note: If the directory does not exist, try the parent directory
|
|
12458
|
+
rootDirname = join(rootDirname, '..');
|
|
12354
12459
|
return [2 /*return*/];
|
|
12355
12460
|
}
|
|
12356
12461
|
});
|
|
@@ -12364,23 +12469,26 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12364
12469
|
state_1 = _b.sent();
|
|
12365
12470
|
if (typeof state_1 === "object")
|
|
12366
12471
|
return [2 /*return*/, state_1.value];
|
|
12367
|
-
|
|
12368
|
-
return [3 /*break*/, 14];
|
|
12472
|
+
switch (state_1) {
|
|
12473
|
+
case "break-up_to_root": return [3 /*break*/, 14];
|
|
12474
|
+
}
|
|
12369
12475
|
_b.label = 13;
|
|
12370
12476
|
case 13:
|
|
12371
12477
|
i++;
|
|
12372
12478
|
return [3 /*break*/, 11];
|
|
12373
12479
|
case 14:
|
|
12374
12480
|
if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 18];
|
|
12481
|
+
console.log("Strategy 3\uFE0F\u20E3");
|
|
12375
12482
|
return [4 /*yield*/, fetch(pipelineSource)];
|
|
12376
12483
|
case 15:
|
|
12377
12484
|
response_1 = _b.sent();
|
|
12378
12485
|
if (response_1.status >= 300) {
|
|
12379
|
-
throw new NotFoundError(spaceTrim(function (block) { return "\n
|
|
12486
|
+
throw new NotFoundError(spaceTrim(function (block) { return "\n Book not found on URL:\n ".concat(block(pipelineSource), "\n\n Request failed with status ").concat(block(response_1.status.toString()), " ").concat(block(response_1.statusText), "\n "); }));
|
|
12380
12487
|
}
|
|
12381
12488
|
return [4 /*yield*/, response_1.text()];
|
|
12382
12489
|
case 16:
|
|
12383
12490
|
pipelineString = _b.sent();
|
|
12491
|
+
console.log({ pipelineString: pipelineString });
|
|
12384
12492
|
return [4 /*yield*/, compilePipeline(pipelineString /* <- TODO: !!!!!! Remove */, tools, __assign({ rootDirname: null }, options))];
|
|
12385
12493
|
case 17:
|
|
12386
12494
|
pipelineJson = _b.sent();
|
|
@@ -12390,7 +12498,7 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12390
12498
|
if (just(false) /* <- TODO: !!!!!! Implement, use and export `isValidPipelineString` */) {
|
|
12391
12499
|
throw new NotYetImplementedError('Strategy 4️⃣: If the pipelineSource is a PipelineString - try to parse it');
|
|
12392
12500
|
} /* not else */
|
|
12393
|
-
throw new NotFoundError(spaceTrim(function (block) { return "\n
|
|
12501
|
+
throw new NotFoundError(spaceTrim(function (block) { return "\n Book not found:\n ".concat(block(pipelineSource), "\n\n Pipelines can be loaded from:\n 1) As a file ./books/write-cv.book.md\n 2) As a URL https://promptbook.studio/hejny/write-cv.book.md found in ./books folder recursively\n 2) As a URL https://promptbook.studio/hejny/write-cv.book.md fetched from the internet\n 3) As a string\n\n\n "); }));
|
|
12394
12502
|
}
|
|
12395
12503
|
});
|
|
12396
12504
|
});
|
|
@@ -12536,7 +12644,7 @@ function initializeRunCommand(program) {
|
|
|
12536
12644
|
runCommand.option('-j, --json <json>', "Pass all or some input parameters as JSON record, if used the output is also returned as JSON");
|
|
12537
12645
|
runCommand.option('-s, --save-report <path>', "Save report to file");
|
|
12538
12646
|
runCommand.action(function (pipelineSource, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
12539
|
-
var isCacheReloaded, isInteractive, isFormfactorUsed, json, isVerbose, saveReport, inputParameters, prepareAndScrapeOptions, fs, llm, executables, tools, pipeline,
|
|
12647
|
+
var isCacheReloaded, isInteractive, isFormfactorUsed, json, isVerbose, saveReport, inputParameters, prepareAndScrapeOptions, fs, llm, error_1, executables, tools, pipeline, error_2, pipelineExecutor, questions, response, result, isSuccessful, errors, warnings, outputParameters, executionReport, executionReportString, _a, _b, error, _c, _d, warning, _e, _f, key, value, separator;
|
|
12540
12648
|
var _g, e_1, _h, e_2, _j, e_3, _k;
|
|
12541
12649
|
return __generator(this, function (_l) {
|
|
12542
12650
|
switch (_l.label) {
|
|
@@ -12559,27 +12667,31 @@ function initializeRunCommand(program) {
|
|
|
12559
12667
|
console.info(colors.gray('--- Preparing tools ---'));
|
|
12560
12668
|
}
|
|
12561
12669
|
fs = $provideFilesystemForNode(prepareAndScrapeOptions);
|
|
12562
|
-
|
|
12563
|
-
|
|
12670
|
+
_l.label = 1;
|
|
12671
|
+
case 1:
|
|
12672
|
+
_l.trys.push([1, 3, , 4]);
|
|
12673
|
+
return [4 /*yield*/, $provideLlmToolsForWizzardOrCli(prepareAndScrapeOptions)];
|
|
12674
|
+
case 2:
|
|
12675
|
+
llm = _l.sent();
|
|
12676
|
+
return [3 /*break*/, 4];
|
|
12677
|
+
case 3:
|
|
12678
|
+
error_1 = _l.sent();
|
|
12679
|
+
if (!(error_1 instanceof Error)) {
|
|
12680
|
+
throw error_1;
|
|
12564
12681
|
}
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
|
-
throw error;
|
|
12568
|
-
}
|
|
12569
|
-
if (!error.message.includes('No LLM tools')) {
|
|
12570
|
-
throw error;
|
|
12571
|
-
}
|
|
12572
|
-
console.error(colors.red(spaceTrim(function (block) { return "\n You need to configure LLM tools first\n\n 1) Create .env file at the root of your project\n 2) Configure API keys for LLM tools\n\n For example:\n ".concat(block($llmToolsMetadataRegister
|
|
12573
|
-
.list()
|
|
12574
|
-
.map(function (_a) {
|
|
12575
|
-
var title = _a.title, envVariables = _a.envVariables;
|
|
12576
|
-
return "- ".concat((envVariables || []).join(' + '), " (").concat(title, ")");
|
|
12577
|
-
})
|
|
12578
|
-
.join('\n')), "\n\n ").concat(block($registeredLlmToolsMessage()), "\n "); })));
|
|
12579
|
-
return [2 /*return*/, process.exit(1)];
|
|
12682
|
+
if (!error_1.message.includes('No LLM tools')) {
|
|
12683
|
+
throw error_1;
|
|
12580
12684
|
}
|
|
12581
|
-
return
|
|
12582
|
-
|
|
12685
|
+
console.error(colors.red(spaceTrim(function (block) { return "\n You need to configure LLM tools first\n\n 1) Create .env file at the root of your project\n 2) Configure API keys for LLM tools\n\n For example:\n ".concat(block($llmToolsMetadataRegister
|
|
12686
|
+
.list()
|
|
12687
|
+
.map(function (_a) {
|
|
12688
|
+
var title = _a.title, envVariables = _a.envVariables;
|
|
12689
|
+
return "- ".concat((envVariables || []).join(' + '), " (").concat(title, ")");
|
|
12690
|
+
})
|
|
12691
|
+
.join('\n')), "\n\n ").concat(block($registeredLlmToolsMessage()), "\n "); })));
|
|
12692
|
+
return [2 /*return*/, process.exit(1)];
|
|
12693
|
+
case 4: return [4 /*yield*/, $provideExecutablesForNode(prepareAndScrapeOptions)];
|
|
12694
|
+
case 5:
|
|
12583
12695
|
executables = _l.sent();
|
|
12584
12696
|
_g = {
|
|
12585
12697
|
llm: llm,
|
|
@@ -12587,7 +12699,7 @@ function initializeRunCommand(program) {
|
|
|
12587
12699
|
fetch: scraperFetch
|
|
12588
12700
|
};
|
|
12589
12701
|
return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, prepareAndScrapeOptions)];
|
|
12590
|
-
case
|
|
12702
|
+
case 6:
|
|
12591
12703
|
tools = (_g.scrapers = _l.sent(),
|
|
12592
12704
|
_g.script = [
|
|
12593
12705
|
/*new JavascriptExecutionTools(options)*/
|
|
@@ -12599,21 +12711,21 @@ function initializeRunCommand(program) {
|
|
|
12599
12711
|
if (isVerbose) {
|
|
12600
12712
|
console.info(colors.gray('--- Preparing pipeline ---'));
|
|
12601
12713
|
}
|
|
12602
|
-
_l.label =
|
|
12603
|
-
case
|
|
12604
|
-
_l.trys.push([
|
|
12714
|
+
_l.label = 7;
|
|
12715
|
+
case 7:
|
|
12716
|
+
_l.trys.push([7, 9, , 10]);
|
|
12605
12717
|
return [4 /*yield*/, $getCompiledBook(tools, pipelineSource, prepareAndScrapeOptions)];
|
|
12606
|
-
case
|
|
12718
|
+
case 8:
|
|
12607
12719
|
pipeline = _l.sent();
|
|
12608
|
-
return [3 /*break*/,
|
|
12609
|
-
case
|
|
12610
|
-
|
|
12611
|
-
if (!(
|
|
12612
|
-
throw
|
|
12720
|
+
return [3 /*break*/, 10];
|
|
12721
|
+
case 9:
|
|
12722
|
+
error_2 = _l.sent();
|
|
12723
|
+
if (!(error_2 instanceof ParseError)) {
|
|
12724
|
+
throw error_2;
|
|
12613
12725
|
}
|
|
12614
|
-
console.error(colors.red(spaceTrim(function (block) { return "\n ".concat(block(
|
|
12726
|
+
console.error(colors.red(spaceTrim(function (block) { return "\n ".concat(block(error_2.message), "\n\n in ").concat(pipelineSource, "\n "); })));
|
|
12615
12727
|
return [2 /*return*/, process.exit(1)];
|
|
12616
|
-
case
|
|
12728
|
+
case 10:
|
|
12617
12729
|
if (isVerbose) {
|
|
12618
12730
|
console.info(colors.gray('--- Validating pipeline ---'));
|
|
12619
12731
|
}
|
|
@@ -12699,7 +12811,7 @@ function initializeRunCommand(program) {
|
|
|
12699
12811
|
return [2 /*return*/, process.exit(1)];
|
|
12700
12812
|
}
|
|
12701
12813
|
return [4 /*yield*/, prompts(questions)];
|
|
12702
|
-
case
|
|
12814
|
+
case 11:
|
|
12703
12815
|
response = _l.sent();
|
|
12704
12816
|
// <- TODO: [🧠][🍼] Change behavior according to the formfactor
|
|
12705
12817
|
inputParameters = __assign(__assign({}, inputParameters), response);
|
|
@@ -12713,26 +12825,26 @@ function initializeRunCommand(program) {
|
|
|
12713
12825
|
console.info(taskProgress);
|
|
12714
12826
|
}
|
|
12715
12827
|
})];
|
|
12716
|
-
case
|
|
12828
|
+
case 12:
|
|
12717
12829
|
result = _l.sent();
|
|
12718
12830
|
isSuccessful = result.isSuccessful, errors = result.errors, warnings = result.warnings, outputParameters = result.outputParameters, executionReport = result.executionReport;
|
|
12719
12831
|
if (isVerbose) {
|
|
12720
12832
|
console.info(colors.gray('--- Detailed Result ---'));
|
|
12721
12833
|
console.info({ isSuccessful: isSuccessful, errors: errors, warnings: warnings, outputParameters: outputParameters, executionReport: executionReport });
|
|
12722
12834
|
}
|
|
12723
|
-
if (!(saveReport && saveReport.endsWith('.json'))) return [3 /*break*/,
|
|
12835
|
+
if (!(saveReport && saveReport.endsWith('.json'))) return [3 /*break*/, 14];
|
|
12724
12836
|
return [4 /*yield*/, writeFile(saveReport, JSON.stringify(executionReport, null, 4) + '\n', 'utf-8')];
|
|
12725
|
-
case
|
|
12837
|
+
case 13:
|
|
12726
12838
|
_l.sent();
|
|
12727
|
-
return [3 /*break*/,
|
|
12728
|
-
case
|
|
12729
|
-
if (!(saveReport && saveReport.endsWith('.md'))) return [3 /*break*/,
|
|
12839
|
+
return [3 /*break*/, 16];
|
|
12840
|
+
case 14:
|
|
12841
|
+
if (!(saveReport && saveReport.endsWith('.md'))) return [3 /*break*/, 16];
|
|
12730
12842
|
executionReportString = executionReportJsonToString(executionReport);
|
|
12731
12843
|
return [4 /*yield*/, writeFile(saveReport, executionReportString, 'utf-8')];
|
|
12732
|
-
case
|
|
12844
|
+
case 15:
|
|
12733
12845
|
_l.sent();
|
|
12734
|
-
_l.label =
|
|
12735
|
-
case
|
|
12846
|
+
_l.label = 16;
|
|
12847
|
+
case 16:
|
|
12736
12848
|
if (saveReport && isVerbose) {
|
|
12737
12849
|
console.info(colors.green("Report saved to ".concat(saveReport)));
|
|
12738
12850
|
}
|
|
@@ -12832,64 +12944,66 @@ function initializeTestCommand(program) {
|
|
|
12832
12944
|
isCacheReloaded: isCacheReloaded,
|
|
12833
12945
|
};
|
|
12834
12946
|
fs = $provideFilesystemForNode(prepareAndScrapeOptions);
|
|
12835
|
-
|
|
12836
|
-
return [4 /*yield*/, $provideExecutablesForNode(prepareAndScrapeOptions)];
|
|
12947
|
+
return [4 /*yield*/, $provideLlmToolsForWizzardOrCli(prepareAndScrapeOptions)];
|
|
12837
12948
|
case 1:
|
|
12949
|
+
llm = _f.sent();
|
|
12950
|
+
return [4 /*yield*/, $provideExecutablesForNode(prepareAndScrapeOptions)];
|
|
12951
|
+
case 2:
|
|
12838
12952
|
executables = _f.sent();
|
|
12839
12953
|
_d = {
|
|
12840
12954
|
llm: llm,
|
|
12841
12955
|
fs: fs
|
|
12842
12956
|
};
|
|
12843
12957
|
return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, prepareAndScrapeOptions)];
|
|
12844
|
-
case
|
|
12958
|
+
case 3:
|
|
12845
12959
|
tools = (_d.scrapers = _f.sent(),
|
|
12846
12960
|
_d.script = [
|
|
12847
12961
|
/*new JavascriptExecutionTools(options)*/
|
|
12848
12962
|
],
|
|
12849
12963
|
_d);
|
|
12850
12964
|
return [4 /*yield*/, glob(filesGlob, { ignore: ignore })];
|
|
12851
|
-
case 3:
|
|
12852
|
-
filenames = _f.sent();
|
|
12853
|
-
_f.label = 4;
|
|
12854
12965
|
case 4:
|
|
12855
|
-
_f.
|
|
12856
|
-
filenames_1 = __values(filenames), filenames_1_1 = filenames_1.next();
|
|
12966
|
+
filenames = _f.sent();
|
|
12857
12967
|
_f.label = 5;
|
|
12858
12968
|
case 5:
|
|
12859
|
-
|
|
12860
|
-
|
|
12969
|
+
_f.trys.push([5, 17, 18, 19]);
|
|
12970
|
+
filenames_1 = __values(filenames), filenames_1_1 = filenames_1.next();
|
|
12861
12971
|
_f.label = 6;
|
|
12862
12972
|
case 6:
|
|
12863
|
-
|
|
12973
|
+
if (!!filenames_1_1.done) return [3 /*break*/, 16];
|
|
12974
|
+
filename = filenames_1_1.value;
|
|
12975
|
+
_f.label = 7;
|
|
12976
|
+
case 7:
|
|
12977
|
+
_f.trys.push([7, 14, , 15]);
|
|
12864
12978
|
pipeline = void 0;
|
|
12865
|
-
if (!filename.endsWith('.book.md')) return [3 /*break*/,
|
|
12979
|
+
if (!filename.endsWith('.book.md')) return [3 /*break*/, 10];
|
|
12866
12980
|
return [4 /*yield*/, readFile(filename, 'utf-8')];
|
|
12867
|
-
case
|
|
12981
|
+
case 8:
|
|
12868
12982
|
pipelineMarkdown = (_f.sent());
|
|
12869
12983
|
return [4 /*yield*/, compilePipeline(pipelineMarkdown, tools)];
|
|
12870
|
-
case
|
|
12984
|
+
case 9:
|
|
12871
12985
|
pipeline = _f.sent();
|
|
12872
12986
|
if (isVerbose) {
|
|
12873
12987
|
console.info(colors.green("Parsed ".concat(filename)));
|
|
12874
12988
|
}
|
|
12875
|
-
_f.label =
|
|
12876
|
-
case
|
|
12877
|
-
if (!filename.endsWith('.book.json')) return [3 /*break*/,
|
|
12989
|
+
_f.label = 10;
|
|
12990
|
+
case 10:
|
|
12991
|
+
if (!filename.endsWith('.book.json')) return [3 /*break*/, 12];
|
|
12878
12992
|
_c = (_b = JSON).parse;
|
|
12879
12993
|
return [4 /*yield*/, readFile(filename, 'utf-8')];
|
|
12880
|
-
case 10:
|
|
12881
|
-
pipeline = _c.apply(_b, [_f.sent()]);
|
|
12882
|
-
return [3 /*break*/, 12];
|
|
12883
12994
|
case 11:
|
|
12995
|
+
pipeline = _c.apply(_b, [_f.sent()]);
|
|
12996
|
+
return [3 /*break*/, 13];
|
|
12997
|
+
case 12:
|
|
12884
12998
|
if (isVerbose) {
|
|
12885
12999
|
console.info(colors.gray("Skipping ".concat(filename)));
|
|
12886
13000
|
}
|
|
12887
|
-
return [3 /*break*/,
|
|
12888
|
-
case
|
|
13001
|
+
return [3 /*break*/, 15];
|
|
13002
|
+
case 13:
|
|
12889
13003
|
validatePipeline(pipeline);
|
|
12890
13004
|
console.info(colors.green("Validated ".concat(filename)));
|
|
12891
|
-
return [3 /*break*/,
|
|
12892
|
-
case
|
|
13005
|
+
return [3 /*break*/, 15];
|
|
13006
|
+
case 14:
|
|
12893
13007
|
error_1 = _f.sent();
|
|
12894
13008
|
if (!(error_1 instanceof Error)) {
|
|
12895
13009
|
throw error_1;
|
|
@@ -12898,21 +13012,21 @@ function initializeTestCommand(program) {
|
|
|
12898
13012
|
console.error(colors.bgRed(error_1.name /* <- 11:11 */));
|
|
12899
13013
|
console.error(colors.red(error_1.stack || error_1.message));
|
|
12900
13014
|
return [2 /*return*/, process.exit(1)];
|
|
12901
|
-
case
|
|
13015
|
+
case 15:
|
|
12902
13016
|
filenames_1_1 = filenames_1.next();
|
|
12903
|
-
return [3 /*break*/,
|
|
12904
|
-
case
|
|
12905
|
-
case
|
|
13017
|
+
return [3 /*break*/, 6];
|
|
13018
|
+
case 16: return [3 /*break*/, 19];
|
|
13019
|
+
case 17:
|
|
12906
13020
|
e_1_1 = _f.sent();
|
|
12907
13021
|
e_1 = { error: e_1_1 };
|
|
12908
|
-
return [3 /*break*/,
|
|
12909
|
-
case
|
|
13022
|
+
return [3 /*break*/, 19];
|
|
13023
|
+
case 18:
|
|
12910
13024
|
try {
|
|
12911
13025
|
if (filenames_1_1 && !filenames_1_1.done && (_e = filenames_1.return)) _e.call(filenames_1);
|
|
12912
13026
|
}
|
|
12913
13027
|
finally { if (e_1) throw e_1.error; }
|
|
12914
13028
|
return [7 /*endfinally*/];
|
|
12915
|
-
case
|
|
13029
|
+
case 19:
|
|
12916
13030
|
console.info(colors.green("All pipelines are valid"));
|
|
12917
13031
|
return [2 /*return*/, process.exit(0)];
|
|
12918
13032
|
}
|