@promptbook/cli 0.81.0-14 → 0.81.0-16
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 +304 -197
- 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/utils/validators/filePath/{isPathRoot.d.ts → isRootPath.d.ts} +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +304 -197
- 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-15';
|
|
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,28 +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
|
-
if (!
|
|
12325
|
-
|
|
12326
|
-
}
|
|
12327
|
-
return [4 /*yield*/, createCollectionFromDirectory(rootDirname, tools, __assign({ isRecursive: true, rootDirname: rootDirname }, options))];
|
|
12417
|
+
if (!_f.sent()) return [3 /*break*/, 5];
|
|
12418
|
+
return [4 /*yield*/, createCollectionFromDirectory(booksDirname, tools, __assign({ isRecursive: true, rootDirname: booksDirname }, options))];
|
|
12328
12419
|
case 2:
|
|
12329
|
-
|
|
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()]));
|
|
12330
12426
|
return [4 /*yield*/, (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
12331
12427
|
var error_1;
|
|
12332
12428
|
return __generator(this, function (_a) {
|
|
12333
12429
|
switch (_a.label) {
|
|
12334
12430
|
case 0:
|
|
12335
12431
|
_a.trys.push([0, 2, , 3]);
|
|
12336
|
-
return [4 /*yield*/,
|
|
12432
|
+
return [4 /*yield*/, collection_1.getPipelineByUrl(pipelineSource)];
|
|
12337
12433
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12338
12434
|
case 2:
|
|
12339
12435
|
error_1 = _a.sent();
|
|
@@ -12346,16 +12442,20 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12346
12442
|
}
|
|
12347
12443
|
});
|
|
12348
12444
|
}); })()];
|
|
12349
|
-
case
|
|
12350
|
-
pipeline =
|
|
12445
|
+
case 4:
|
|
12446
|
+
pipeline = _f.sent();
|
|
12447
|
+
console.log({ pipeline: pipeline });
|
|
12448
|
+
// <- TODO: !!!!!!! Remove
|
|
12351
12449
|
if (pipeline !== null) {
|
|
12352
12450
|
return [2 /*return*/, { value: pipeline }];
|
|
12353
12451
|
}
|
|
12354
|
-
|
|
12355
|
-
|
|
12452
|
+
_f.label = 5;
|
|
12453
|
+
case 5:
|
|
12454
|
+
if (isRootPath(rootDirname)) {
|
|
12356
12455
|
return [2 /*return*/, "break-up_to_root"];
|
|
12357
12456
|
}
|
|
12358
|
-
|
|
12457
|
+
// Note: If the directory does not exist, try the parent directory
|
|
12458
|
+
rootDirname = join(rootDirname, '..');
|
|
12359
12459
|
return [2 /*return*/];
|
|
12360
12460
|
}
|
|
12361
12461
|
});
|
|
@@ -12371,7 +12471,6 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12371
12471
|
return [2 /*return*/, state_1.value];
|
|
12372
12472
|
switch (state_1) {
|
|
12373
12473
|
case "break-up_to_root": return [3 /*break*/, 14];
|
|
12374
|
-
case "continue-up_to_root": return [3 /*break*/, 13];
|
|
12375
12474
|
}
|
|
12376
12475
|
_b.label = 13;
|
|
12377
12476
|
case 13:
|
|
@@ -12379,15 +12478,17 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12379
12478
|
return [3 /*break*/, 11];
|
|
12380
12479
|
case 14:
|
|
12381
12480
|
if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 18];
|
|
12481
|
+
console.log("Strategy 3\uFE0F\u20E3");
|
|
12382
12482
|
return [4 /*yield*/, fetch(pipelineSource)];
|
|
12383
12483
|
case 15:
|
|
12384
12484
|
response_1 = _b.sent();
|
|
12385
12485
|
if (response_1.status >= 300) {
|
|
12386
|
-
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 "); }));
|
|
12387
12487
|
}
|
|
12388
12488
|
return [4 /*yield*/, response_1.text()];
|
|
12389
12489
|
case 16:
|
|
12390
12490
|
pipelineString = _b.sent();
|
|
12491
|
+
console.log({ pipelineString: pipelineString });
|
|
12391
12492
|
return [4 /*yield*/, compilePipeline(pipelineString /* <- TODO: !!!!!! Remove */, tools, __assign({ rootDirname: null }, options))];
|
|
12392
12493
|
case 17:
|
|
12393
12494
|
pipelineJson = _b.sent();
|
|
@@ -12397,7 +12498,7 @@ function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
12397
12498
|
if (just(false) /* <- TODO: !!!!!! Implement, use and export `isValidPipelineString` */) {
|
|
12398
12499
|
throw new NotYetImplementedError('Strategy 4️⃣: If the pipelineSource is a PipelineString - try to parse it');
|
|
12399
12500
|
} /* not else */
|
|
12400
|
-
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 "); }));
|
|
12401
12502
|
}
|
|
12402
12503
|
});
|
|
12403
12504
|
});
|
|
@@ -12543,7 +12644,7 @@ function initializeRunCommand(program) {
|
|
|
12543
12644
|
runCommand.option('-j, --json <json>', "Pass all or some input parameters as JSON record, if used the output is also returned as JSON");
|
|
12544
12645
|
runCommand.option('-s, --save-report <path>', "Save report to file");
|
|
12545
12646
|
runCommand.action(function (pipelineSource, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
12546
|
-
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;
|
|
12547
12648
|
var _g, e_1, _h, e_2, _j, e_3, _k;
|
|
12548
12649
|
return __generator(this, function (_l) {
|
|
12549
12650
|
switch (_l.label) {
|
|
@@ -12566,27 +12667,31 @@ function initializeRunCommand(program) {
|
|
|
12566
12667
|
console.info(colors.gray('--- Preparing tools ---'));
|
|
12567
12668
|
}
|
|
12568
12669
|
fs = $provideFilesystemForNode(prepareAndScrapeOptions);
|
|
12569
|
-
|
|
12570
|
-
|
|
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;
|
|
12571
12681
|
}
|
|
12572
|
-
|
|
12573
|
-
|
|
12574
|
-
throw error;
|
|
12575
|
-
}
|
|
12576
|
-
if (!error.message.includes('No LLM tools')) {
|
|
12577
|
-
throw error;
|
|
12578
|
-
}
|
|
12579
|
-
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
|
|
12580
|
-
.list()
|
|
12581
|
-
.map(function (_a) {
|
|
12582
|
-
var title = _a.title, envVariables = _a.envVariables;
|
|
12583
|
-
return "- ".concat((envVariables || []).join(' + '), " (").concat(title, ")");
|
|
12584
|
-
})
|
|
12585
|
-
.join('\n')), "\n\n ").concat(block($registeredLlmToolsMessage()), "\n "); })));
|
|
12586
|
-
return [2 /*return*/, process.exit(1)];
|
|
12682
|
+
if (!error_1.message.includes('No LLM tools')) {
|
|
12683
|
+
throw error_1;
|
|
12587
12684
|
}
|
|
12588
|
-
return
|
|
12589
|
-
|
|
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:
|
|
12590
12695
|
executables = _l.sent();
|
|
12591
12696
|
_g = {
|
|
12592
12697
|
llm: llm,
|
|
@@ -12594,7 +12699,7 @@ function initializeRunCommand(program) {
|
|
|
12594
12699
|
fetch: scraperFetch
|
|
12595
12700
|
};
|
|
12596
12701
|
return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, prepareAndScrapeOptions)];
|
|
12597
|
-
case
|
|
12702
|
+
case 6:
|
|
12598
12703
|
tools = (_g.scrapers = _l.sent(),
|
|
12599
12704
|
_g.script = [
|
|
12600
12705
|
/*new JavascriptExecutionTools(options)*/
|
|
@@ -12606,21 +12711,21 @@ function initializeRunCommand(program) {
|
|
|
12606
12711
|
if (isVerbose) {
|
|
12607
12712
|
console.info(colors.gray('--- Preparing pipeline ---'));
|
|
12608
12713
|
}
|
|
12609
|
-
_l.label =
|
|
12610
|
-
case
|
|
12611
|
-
_l.trys.push([
|
|
12714
|
+
_l.label = 7;
|
|
12715
|
+
case 7:
|
|
12716
|
+
_l.trys.push([7, 9, , 10]);
|
|
12612
12717
|
return [4 /*yield*/, $getCompiledBook(tools, pipelineSource, prepareAndScrapeOptions)];
|
|
12613
|
-
case
|
|
12718
|
+
case 8:
|
|
12614
12719
|
pipeline = _l.sent();
|
|
12615
|
-
return [3 /*break*/,
|
|
12616
|
-
case
|
|
12617
|
-
|
|
12618
|
-
if (!(
|
|
12619
|
-
throw
|
|
12720
|
+
return [3 /*break*/, 10];
|
|
12721
|
+
case 9:
|
|
12722
|
+
error_2 = _l.sent();
|
|
12723
|
+
if (!(error_2 instanceof ParseError)) {
|
|
12724
|
+
throw error_2;
|
|
12620
12725
|
}
|
|
12621
|
-
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 "); })));
|
|
12622
12727
|
return [2 /*return*/, process.exit(1)];
|
|
12623
|
-
case
|
|
12728
|
+
case 10:
|
|
12624
12729
|
if (isVerbose) {
|
|
12625
12730
|
console.info(colors.gray('--- Validating pipeline ---'));
|
|
12626
12731
|
}
|
|
@@ -12706,7 +12811,7 @@ function initializeRunCommand(program) {
|
|
|
12706
12811
|
return [2 /*return*/, process.exit(1)];
|
|
12707
12812
|
}
|
|
12708
12813
|
return [4 /*yield*/, prompts(questions)];
|
|
12709
|
-
case
|
|
12814
|
+
case 11:
|
|
12710
12815
|
response = _l.sent();
|
|
12711
12816
|
// <- TODO: [🧠][🍼] Change behavior according to the formfactor
|
|
12712
12817
|
inputParameters = __assign(__assign({}, inputParameters), response);
|
|
@@ -12720,26 +12825,26 @@ function initializeRunCommand(program) {
|
|
|
12720
12825
|
console.info(taskProgress);
|
|
12721
12826
|
}
|
|
12722
12827
|
})];
|
|
12723
|
-
case
|
|
12828
|
+
case 12:
|
|
12724
12829
|
result = _l.sent();
|
|
12725
12830
|
isSuccessful = result.isSuccessful, errors = result.errors, warnings = result.warnings, outputParameters = result.outputParameters, executionReport = result.executionReport;
|
|
12726
12831
|
if (isVerbose) {
|
|
12727
12832
|
console.info(colors.gray('--- Detailed Result ---'));
|
|
12728
12833
|
console.info({ isSuccessful: isSuccessful, errors: errors, warnings: warnings, outputParameters: outputParameters, executionReport: executionReport });
|
|
12729
12834
|
}
|
|
12730
|
-
if (!(saveReport && saveReport.endsWith('.json'))) return [3 /*break*/,
|
|
12835
|
+
if (!(saveReport && saveReport.endsWith('.json'))) return [3 /*break*/, 14];
|
|
12731
12836
|
return [4 /*yield*/, writeFile(saveReport, JSON.stringify(executionReport, null, 4) + '\n', 'utf-8')];
|
|
12732
|
-
case
|
|
12837
|
+
case 13:
|
|
12733
12838
|
_l.sent();
|
|
12734
|
-
return [3 /*break*/,
|
|
12735
|
-
case
|
|
12736
|
-
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];
|
|
12737
12842
|
executionReportString = executionReportJsonToString(executionReport);
|
|
12738
12843
|
return [4 /*yield*/, writeFile(saveReport, executionReportString, 'utf-8')];
|
|
12739
|
-
case
|
|
12844
|
+
case 15:
|
|
12740
12845
|
_l.sent();
|
|
12741
|
-
_l.label =
|
|
12742
|
-
case
|
|
12846
|
+
_l.label = 16;
|
|
12847
|
+
case 16:
|
|
12743
12848
|
if (saveReport && isVerbose) {
|
|
12744
12849
|
console.info(colors.green("Report saved to ".concat(saveReport)));
|
|
12745
12850
|
}
|
|
@@ -12839,64 +12944,66 @@ function initializeTestCommand(program) {
|
|
|
12839
12944
|
isCacheReloaded: isCacheReloaded,
|
|
12840
12945
|
};
|
|
12841
12946
|
fs = $provideFilesystemForNode(prepareAndScrapeOptions);
|
|
12842
|
-
|
|
12843
|
-
return [4 /*yield*/, $provideExecutablesForNode(prepareAndScrapeOptions)];
|
|
12947
|
+
return [4 /*yield*/, $provideLlmToolsForWizzardOrCli(prepareAndScrapeOptions)];
|
|
12844
12948
|
case 1:
|
|
12949
|
+
llm = _f.sent();
|
|
12950
|
+
return [4 /*yield*/, $provideExecutablesForNode(prepareAndScrapeOptions)];
|
|
12951
|
+
case 2:
|
|
12845
12952
|
executables = _f.sent();
|
|
12846
12953
|
_d = {
|
|
12847
12954
|
llm: llm,
|
|
12848
12955
|
fs: fs
|
|
12849
12956
|
};
|
|
12850
12957
|
return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, prepareAndScrapeOptions)];
|
|
12851
|
-
case
|
|
12958
|
+
case 3:
|
|
12852
12959
|
tools = (_d.scrapers = _f.sent(),
|
|
12853
12960
|
_d.script = [
|
|
12854
12961
|
/*new JavascriptExecutionTools(options)*/
|
|
12855
12962
|
],
|
|
12856
12963
|
_d);
|
|
12857
12964
|
return [4 /*yield*/, glob(filesGlob, { ignore: ignore })];
|
|
12858
|
-
case 3:
|
|
12859
|
-
filenames = _f.sent();
|
|
12860
|
-
_f.label = 4;
|
|
12861
12965
|
case 4:
|
|
12862
|
-
_f.
|
|
12863
|
-
filenames_1 = __values(filenames), filenames_1_1 = filenames_1.next();
|
|
12966
|
+
filenames = _f.sent();
|
|
12864
12967
|
_f.label = 5;
|
|
12865
12968
|
case 5:
|
|
12866
|
-
|
|
12867
|
-
|
|
12969
|
+
_f.trys.push([5, 17, 18, 19]);
|
|
12970
|
+
filenames_1 = __values(filenames), filenames_1_1 = filenames_1.next();
|
|
12868
12971
|
_f.label = 6;
|
|
12869
12972
|
case 6:
|
|
12870
|
-
|
|
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]);
|
|
12871
12978
|
pipeline = void 0;
|
|
12872
|
-
if (!filename.endsWith('.book.md')) return [3 /*break*/,
|
|
12979
|
+
if (!filename.endsWith('.book.md')) return [3 /*break*/, 10];
|
|
12873
12980
|
return [4 /*yield*/, readFile(filename, 'utf-8')];
|
|
12874
|
-
case
|
|
12981
|
+
case 8:
|
|
12875
12982
|
pipelineMarkdown = (_f.sent());
|
|
12876
12983
|
return [4 /*yield*/, compilePipeline(pipelineMarkdown, tools)];
|
|
12877
|
-
case
|
|
12984
|
+
case 9:
|
|
12878
12985
|
pipeline = _f.sent();
|
|
12879
12986
|
if (isVerbose) {
|
|
12880
12987
|
console.info(colors.green("Parsed ".concat(filename)));
|
|
12881
12988
|
}
|
|
12882
|
-
_f.label =
|
|
12883
|
-
case
|
|
12884
|
-
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];
|
|
12885
12992
|
_c = (_b = JSON).parse;
|
|
12886
12993
|
return [4 /*yield*/, readFile(filename, 'utf-8')];
|
|
12887
|
-
case 10:
|
|
12888
|
-
pipeline = _c.apply(_b, [_f.sent()]);
|
|
12889
|
-
return [3 /*break*/, 12];
|
|
12890
12994
|
case 11:
|
|
12995
|
+
pipeline = _c.apply(_b, [_f.sent()]);
|
|
12996
|
+
return [3 /*break*/, 13];
|
|
12997
|
+
case 12:
|
|
12891
12998
|
if (isVerbose) {
|
|
12892
12999
|
console.info(colors.gray("Skipping ".concat(filename)));
|
|
12893
13000
|
}
|
|
12894
|
-
return [3 /*break*/,
|
|
12895
|
-
case
|
|
13001
|
+
return [3 /*break*/, 15];
|
|
13002
|
+
case 13:
|
|
12896
13003
|
validatePipeline(pipeline);
|
|
12897
13004
|
console.info(colors.green("Validated ".concat(filename)));
|
|
12898
|
-
return [3 /*break*/,
|
|
12899
|
-
case
|
|
13005
|
+
return [3 /*break*/, 15];
|
|
13006
|
+
case 14:
|
|
12900
13007
|
error_1 = _f.sent();
|
|
12901
13008
|
if (!(error_1 instanceof Error)) {
|
|
12902
13009
|
throw error_1;
|
|
@@ -12905,21 +13012,21 @@ function initializeTestCommand(program) {
|
|
|
12905
13012
|
console.error(colors.bgRed(error_1.name /* <- 11:11 */));
|
|
12906
13013
|
console.error(colors.red(error_1.stack || error_1.message));
|
|
12907
13014
|
return [2 /*return*/, process.exit(1)];
|
|
12908
|
-
case
|
|
13015
|
+
case 15:
|
|
12909
13016
|
filenames_1_1 = filenames_1.next();
|
|
12910
|
-
return [3 /*break*/,
|
|
12911
|
-
case
|
|
12912
|
-
case
|
|
13017
|
+
return [3 /*break*/, 6];
|
|
13018
|
+
case 16: return [3 /*break*/, 19];
|
|
13019
|
+
case 17:
|
|
12913
13020
|
e_1_1 = _f.sent();
|
|
12914
13021
|
e_1 = { error: e_1_1 };
|
|
12915
|
-
return [3 /*break*/,
|
|
12916
|
-
case
|
|
13022
|
+
return [3 /*break*/, 19];
|
|
13023
|
+
case 18:
|
|
12917
13024
|
try {
|
|
12918
13025
|
if (filenames_1_1 && !filenames_1_1.done && (_e = filenames_1.return)) _e.call(filenames_1);
|
|
12919
13026
|
}
|
|
12920
13027
|
finally { if (e_1) throw e_1.error; }
|
|
12921
13028
|
return [7 /*endfinally*/];
|
|
12922
|
-
case
|
|
13029
|
+
case 19:
|
|
12923
13030
|
console.info(colors.green("All pipelines are valid"));
|
|
12924
13031
|
return [2 /*return*/, process.exit(0)];
|
|
12925
13032
|
}
|