@promptbook/wizard 0.112.0-13 → 0.112.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 +384 -364
- package/esm/index.es.js.map +1 -1
- package/esm/src/cli/cli-commands/coder/{find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags.d.ts} +1 -1
- package/esm/src/cli/cli-commands/coder.d.ts +1 -1
- package/esm/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +1 -1
- package/esm/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/esm/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +1 -2
- package/esm/src/scrapers/document/DocumentScraper.d.ts +1 -2
- package/esm/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -2
- package/esm/src/scripting/javascript/postprocessing-functions.d.ts +1 -1
- package/esm/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +1 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +586 -566
- package/umd/index.umd.js.map +1 -1
- package/umd/src/cli/cli-commands/coder/{find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags.d.ts} +1 -1
- package/umd/src/cli/cli-commands/coder.d.ts +1 -1
- package/umd/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +1 -1
- package/umd/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/umd/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/umd/src/llm-providers/google/google-models.d.ts +1 -1
- package/umd/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/umd/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +1 -2
- package/umd/src/scrapers/document/DocumentScraper.d.ts +1 -2
- package/umd/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -2
- package/umd/src/scripting/javascript/postprocessing-functions.d.ts +1 -1
- package/umd/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +1 -2
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { io } from 'socket.io-client';
|
|
2
|
-
import
|
|
2
|
+
import _spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
3
3
|
import Anthropic from '@anthropic-ai/sdk';
|
|
4
4
|
import Bottleneck from 'bottleneck';
|
|
5
5
|
import colors from 'colors';
|
|
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
38
38
|
* @generated
|
|
39
39
|
* @see https://github.com/webgptorg/promptbook
|
|
40
40
|
*/
|
|
41
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
41
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-16';
|
|
42
42
|
/**
|
|
43
43
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
44
44
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1306,7 +1306,7 @@ function $deepFreeze(objectValue) {
|
|
|
1306
1306
|
function getErrorReportUrl(error) {
|
|
1307
1307
|
const report = {
|
|
1308
1308
|
title: `🐜 Error report from ${NAME}`,
|
|
1309
|
-
body: spaceTrim$
|
|
1309
|
+
body: spaceTrim$1((block) => `
|
|
1310
1310
|
|
|
1311
1311
|
|
|
1312
1312
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1464,7 +1464,7 @@ function checkSerializableAsJson(options) {
|
|
|
1464
1464
|
}
|
|
1465
1465
|
else if (typeof value === 'object') {
|
|
1466
1466
|
if (value instanceof Date) {
|
|
1467
|
-
throw new UnexpectedError(spaceTrim$
|
|
1467
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1468
1468
|
\`${name}\` is Date
|
|
1469
1469
|
|
|
1470
1470
|
Use \`string_date_iso8601\` instead
|
|
@@ -1483,7 +1483,7 @@ function checkSerializableAsJson(options) {
|
|
|
1483
1483
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
1484
1484
|
}
|
|
1485
1485
|
else if (value instanceof Error) {
|
|
1486
|
-
throw new UnexpectedError(spaceTrim$
|
|
1486
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1487
1487
|
\`${name}\` is unserialized Error
|
|
1488
1488
|
|
|
1489
1489
|
Use function \`serializeError\`
|
|
@@ -1506,7 +1506,7 @@ function checkSerializableAsJson(options) {
|
|
|
1506
1506
|
}
|
|
1507
1507
|
catch (error) {
|
|
1508
1508
|
assertsError(error);
|
|
1509
|
-
throw new UnexpectedError(spaceTrim$
|
|
1509
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1510
1510
|
\`${name}\` is not serializable
|
|
1511
1511
|
|
|
1512
1512
|
${block(error.stack || error.message)}
|
|
@@ -1538,7 +1538,7 @@ function checkSerializableAsJson(options) {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
1540
|
else {
|
|
1541
|
-
throw new UnexpectedError(spaceTrim$
|
|
1541
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1542
1542
|
\`${name}\` is unknown type
|
|
1543
1543
|
|
|
1544
1544
|
Additional message for \`${name}\`:
|
|
@@ -2328,7 +2328,7 @@ function deserializeError(error, isStackAddedToMessage = true) {
|
|
|
2328
2328
|
message = `${name}: ${message}`;
|
|
2329
2329
|
}
|
|
2330
2330
|
if (isStackAddedToMessage && stack !== undefined && stack !== '') {
|
|
2331
|
-
message = spaceTrim$
|
|
2331
|
+
message = spaceTrim$1((block) => `
|
|
2332
2332
|
${block(message)}
|
|
2333
2333
|
|
|
2334
2334
|
Original stack trace:
|
|
@@ -2386,7 +2386,7 @@ async function createRemoteClient(options) {
|
|
|
2386
2386
|
const remoteServerUrlParsed = new URL(remoteServerUrl);
|
|
2387
2387
|
if (remoteServerUrlParsed.pathname !== '/' && remoteServerUrlParsed.pathname !== '') {
|
|
2388
2388
|
remoteServerUrlParsed.pathname = '/';
|
|
2389
|
-
throw new Error(spaceTrim$
|
|
2389
|
+
throw new Error(spaceTrim$1((block) => `
|
|
2390
2390
|
Remote server requires root url \`/\`
|
|
2391
2391
|
|
|
2392
2392
|
You have provided \`remoteServerUrl\`:
|
|
@@ -2823,7 +2823,7 @@ function pricing(value) {
|
|
|
2823
2823
|
/**
|
|
2824
2824
|
* List of available Anthropic Claude models with pricing
|
|
2825
2825
|
*
|
|
2826
|
-
* Note: Synced with official API docs at
|
|
2826
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
2827
2827
|
*
|
|
2828
2828
|
* @see https://docs.anthropic.com/en/docs/models-overview
|
|
2829
2829
|
* @public exported from `@promptbook/anthropic-claude`
|
|
@@ -2831,6 +2831,26 @@ function pricing(value) {
|
|
|
2831
2831
|
const ANTHROPIC_CLAUDE_MODELS = exportJson({
|
|
2832
2832
|
name: 'ANTHROPIC_CLAUDE_MODELS',
|
|
2833
2833
|
value: [
|
|
2834
|
+
{
|
|
2835
|
+
modelVariant: 'CHAT',
|
|
2836
|
+
modelTitle: 'Claude Opus 4.6',
|
|
2837
|
+
modelName: 'claude-opus-4-6',
|
|
2838
|
+
modelDescription: "Anthropic's most capable model for advanced coding, complex reasoning, and agentic workflows with 1M token context window.",
|
|
2839
|
+
pricing: {
|
|
2840
|
+
prompt: pricing(`$5.00 / 1M tokens`),
|
|
2841
|
+
output: pricing(`$25.00 / 1M tokens`),
|
|
2842
|
+
},
|
|
2843
|
+
},
|
|
2844
|
+
{
|
|
2845
|
+
modelVariant: 'CHAT',
|
|
2846
|
+
modelTitle: 'Claude Sonnet 4.6',
|
|
2847
|
+
modelName: 'claude-sonnet-4-6',
|
|
2848
|
+
modelDescription: 'Best speed and intelligence balance for production-ready workloads with 1M token context window. Ideal for high-performance, lower-latency applications.',
|
|
2849
|
+
pricing: {
|
|
2850
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
2851
|
+
output: pricing(`$15.00 / 1M tokens`),
|
|
2852
|
+
},
|
|
2853
|
+
},
|
|
2834
2854
|
{
|
|
2835
2855
|
modelVariant: 'CHAT',
|
|
2836
2856
|
modelTitle: 'Claude Sonnet 4.5',
|
|
@@ -3619,7 +3639,7 @@ class AnthropicClaudeExecutionTools {
|
|
|
3619
3639
|
getDefaultModel(defaultModelName) {
|
|
3620
3640
|
const model = ANTHROPIC_CLAUDE_MODELS.find(({ modelName }) => modelName.startsWith(defaultModelName));
|
|
3621
3641
|
if (model === undefined) {
|
|
3622
|
-
throw new UnexpectedError(spaceTrim$
|
|
3642
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
3623
3643
|
Cannot find model in Anthropic Claude models with name "${defaultModelName}" which should be used as default.
|
|
3624
3644
|
|
|
3625
3645
|
Available models:
|
|
@@ -3776,7 +3796,7 @@ const _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
3776
3796
|
/**
|
|
3777
3797
|
* List of available OpenAI models with pricing
|
|
3778
3798
|
*
|
|
3779
|
-
* Note: Synced with official API docs at
|
|
3799
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
3780
3800
|
*
|
|
3781
3801
|
* @see https://platform.openai.com/docs/models/
|
|
3782
3802
|
* @see https://openai.com/api/pricing/
|
|
@@ -3898,8 +3918,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
3898
3918
|
modelName: 'gpt-4.1',
|
|
3899
3919
|
modelDescription: 'Smartest non-reasoning model with 128K context window. Enhanced version of GPT-4 with improved instruction following, better factual accuracy, and reduced hallucinations. Features advanced function calling capabilities and superior performance on coding tasks. Ideal for applications requiring high intelligence without reasoning overhead.',
|
|
3900
3920
|
pricing: {
|
|
3901
|
-
prompt: pricing(`$
|
|
3902
|
-
output: pricing(`$
|
|
3921
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
3922
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
3903
3923
|
},
|
|
3904
3924
|
},
|
|
3905
3925
|
/**/
|
|
@@ -3910,8 +3930,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
3910
3930
|
modelName: 'gpt-4.1-mini',
|
|
3911
3931
|
modelDescription: 'Smaller, faster version of GPT-4.1 with 128K context window. Balances intelligence and efficiency with 3x faster inference than base GPT-4.1. Maintains strong capabilities across text generation, reasoning, and coding while offering better cost-performance ratio for most applications.',
|
|
3912
3932
|
pricing: {
|
|
3913
|
-
prompt: pricing(`$0.
|
|
3914
|
-
output: pricing(`$
|
|
3933
|
+
prompt: pricing(`$0.40 / 1M tokens`),
|
|
3934
|
+
output: pricing(`$1.60 / 1M tokens`),
|
|
3915
3935
|
},
|
|
3916
3936
|
},
|
|
3917
3937
|
/**/
|
|
@@ -3922,8 +3942,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
3922
3942
|
modelName: 'gpt-4.1-nano',
|
|
3923
3943
|
modelDescription: 'Fastest, most cost-efficient version of GPT-4.1 with 128K context window. Optimized for high-throughput applications requiring good quality at minimal cost. Features 5x faster inference than GPT-4.1 while maintaining adequate performance for most general-purpose tasks.',
|
|
3924
3944
|
pricing: {
|
|
3925
|
-
prompt: pricing(`$0.
|
|
3926
|
-
output: pricing(`$0.
|
|
3945
|
+
prompt: pricing(`$0.10 / 1M tokens`),
|
|
3946
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
3927
3947
|
},
|
|
3928
3948
|
},
|
|
3929
3949
|
/**/
|
|
@@ -3934,8 +3954,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
3934
3954
|
modelName: 'o3',
|
|
3935
3955
|
modelDescription: 'Advanced reasoning model with 128K context window specializing in complex logical, mathematical, and analytical tasks. Successor to o1 with enhanced step-by-step problem-solving capabilities and superior performance on STEM-focused problems. Ideal for professional applications requiring deep analytical thinking and precise reasoning.',
|
|
3936
3956
|
pricing: {
|
|
3937
|
-
prompt: pricing(`$
|
|
3938
|
-
output: pricing(`$
|
|
3957
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
3958
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
3939
3959
|
},
|
|
3940
3960
|
},
|
|
3941
3961
|
/**/
|
|
@@ -3946,8 +3966,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
3946
3966
|
modelName: 'o3-pro',
|
|
3947
3967
|
modelDescription: 'Enhanced version of o3 with more compute allocated for better responses on the most challenging problems. Features extended reasoning time and improved accuracy on complex analytical tasks. Designed for applications where maximum reasoning quality is more important than response speed.',
|
|
3948
3968
|
pricing: {
|
|
3949
|
-
prompt: pricing(`$
|
|
3950
|
-
output: pricing(`$
|
|
3969
|
+
prompt: pricing(`$20.00 / 1M tokens`),
|
|
3970
|
+
output: pricing(`$80.00 / 1M tokens`),
|
|
3951
3971
|
},
|
|
3952
3972
|
},
|
|
3953
3973
|
/**/
|
|
@@ -3958,8 +3978,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
3958
3978
|
modelName: 'o4-mini',
|
|
3959
3979
|
modelDescription: 'Fast, cost-efficient reasoning model with 128K context window. Successor to o1-mini with improved analytical capabilities while maintaining speed advantages. Features enhanced mathematical reasoning and logical problem-solving at significantly lower cost than full reasoning models.',
|
|
3960
3980
|
pricing: {
|
|
3961
|
-
prompt: pricing(`$
|
|
3962
|
-
output: pricing(`$
|
|
3981
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
3982
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
3963
3983
|
},
|
|
3964
3984
|
},
|
|
3965
3985
|
/**/
|
|
@@ -4317,8 +4337,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
4317
4337
|
modelName: 'gpt-4o-2024-05-13',
|
|
4318
4338
|
modelDescription: 'May 2024 version of GPT-4o with 128K context window. Features enhanced multimodal capabilities including superior image understanding (up to 20MP), audio processing, and improved reasoning. Optimized for 2x lower latency than GPT-4 Turbo while maintaining high performance. Includes knowledge up to October 2023. Ideal for production applications requiring reliable multimodal capabilities.',
|
|
4319
4339
|
pricing: {
|
|
4320
|
-
prompt: pricing(`$
|
|
4321
|
-
output: pricing(`$
|
|
4340
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
4341
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
4322
4342
|
},
|
|
4323
4343
|
},
|
|
4324
4344
|
/**/
|
|
@@ -4329,8 +4349,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
4329
4349
|
modelName: 'gpt-4o',
|
|
4330
4350
|
modelDescription: "OpenAI's most advanced general-purpose multimodal model with 128K context window. Optimized for balanced performance, speed, and cost with 2x faster responses than GPT-4 Turbo. Features excellent vision processing, audio understanding, reasoning, and text generation quality. Represents optimal balance of capability and efficiency for most advanced applications.",
|
|
4331
4351
|
pricing: {
|
|
4332
|
-
prompt: pricing(`$
|
|
4333
|
-
output: pricing(`$
|
|
4352
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
4353
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
4334
4354
|
},
|
|
4335
4355
|
},
|
|
4336
4356
|
/**/
|
|
@@ -4401,8 +4421,8 @@ const OPENAI_MODELS = exportJson({
|
|
|
4401
4421
|
modelName: 'o3-mini',
|
|
4402
4422
|
modelDescription: 'Cost-effective reasoning model with 128K context window optimized for academic and scientific problem-solving. Features efficient performance on STEM tasks with specialized capabilities in mathematics, physics, chemistry, and computer science. Offers 80% of O1 performance on technical domains at significantly lower cost. Ideal for educational applications and research support.',
|
|
4403
4423
|
pricing: {
|
|
4404
|
-
prompt: pricing(`$
|
|
4405
|
-
output: pricing(`$
|
|
4424
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
4425
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
4406
4426
|
},
|
|
4407
4427
|
},
|
|
4408
4428
|
/**/
|
|
@@ -4937,7 +4957,7 @@ function createExecutionToolsFromVercelProvider(options) {
|
|
|
4937
4957
|
const modelName = modelRequirements.modelName ||
|
|
4938
4958
|
((_a = availableModels.find(({ modelVariant }) => modelVariant === 'CHAT')) === null || _a === void 0 ? void 0 : _a.modelName);
|
|
4939
4959
|
if (!modelName) {
|
|
4940
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
4960
|
+
throw new PipelineExecutionError(spaceTrim$1(`
|
|
4941
4961
|
Can not determine which model to use.
|
|
4942
4962
|
|
|
4943
4963
|
You need to provide at least one of:
|
|
@@ -5052,7 +5072,7 @@ function createExecutionToolsFromVercelProvider(options) {
|
|
|
5052
5072
|
/**
|
|
5053
5073
|
* List of available Deepseek models with descriptions
|
|
5054
5074
|
*
|
|
5055
|
-
* Note: Synced with official API docs at
|
|
5075
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
5056
5076
|
*
|
|
5057
5077
|
* @see https://www.deepseek.com/models
|
|
5058
5078
|
* @public exported from `@promptbook/deepseek`
|
|
@@ -5066,8 +5086,8 @@ const DEEPSEEK_MODELS = exportJson({
|
|
|
5066
5086
|
modelName: 'deepseek-chat',
|
|
5067
5087
|
modelDescription: 'Latest flagship general-purpose model with 128K context window. Features exceptional reasoning capabilities, advanced code generation, and strong performance across diverse domains. Offers competitive performance with leading models while maintaining cost efficiency. Ideal for complex reasoning, coding, and knowledge-intensive tasks.',
|
|
5068
5088
|
pricing: {
|
|
5069
|
-
prompt: pricing(`$0.
|
|
5070
|
-
output: pricing(`$0.
|
|
5089
|
+
prompt: pricing(`$0.28 / 1M tokens`),
|
|
5090
|
+
output: pricing(`$0.42 / 1M tokens`),
|
|
5071
5091
|
},
|
|
5072
5092
|
},
|
|
5073
5093
|
{
|
|
@@ -5333,7 +5353,7 @@ const _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
5333
5353
|
/**
|
|
5334
5354
|
* List of available Google models with descriptions
|
|
5335
5355
|
*
|
|
5336
|
-
* Note: Synced with official API docs at
|
|
5356
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
5337
5357
|
*
|
|
5338
5358
|
* @see https://ai.google.dev/models/gemini
|
|
5339
5359
|
* @public exported from `@promptbook/google`
|
|
@@ -5354,8 +5374,8 @@ const GOOGLE_MODELS = exportJson({
|
|
|
5354
5374
|
modelName: 'gemini-2.5-pro',
|
|
5355
5375
|
modelDescription: 'State-of-the-art thinking model with 1M token context window capable of reasoning over complex problems in code, math, and STEM. Features enhanced thinking capabilities, advanced multimodal understanding, and superior performance on analytical tasks. Ideal for complex enterprise applications requiring maximum intelligence and reasoning.',
|
|
5356
5376
|
pricing: {
|
|
5357
|
-
prompt: pricing(`$
|
|
5358
|
-
output: pricing(`$
|
|
5377
|
+
prompt: pricing(`$1.25 / 1M tokens`),
|
|
5378
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
5359
5379
|
},
|
|
5360
5380
|
},
|
|
5361
5381
|
{
|
|
@@ -5364,8 +5384,8 @@ const GOOGLE_MODELS = exportJson({
|
|
|
5364
5384
|
modelName: 'gemini-2.5-flash',
|
|
5365
5385
|
modelDescription: 'Best model in terms of price-performance with 1M token context window offering well-rounded capabilities. Features adaptive thinking, cost efficiency, and enhanced reasoning for large-scale processing. Ideal for low-latency, high-volume tasks that require thinking and agentic use cases.',
|
|
5366
5386
|
pricing: {
|
|
5367
|
-
prompt: pricing(`$0.
|
|
5368
|
-
output: pricing(`$
|
|
5387
|
+
prompt: pricing(`$0.30 / 1M tokens`),
|
|
5388
|
+
output: pricing(`$2.50 / 1M tokens`),
|
|
5369
5389
|
},
|
|
5370
5390
|
},
|
|
5371
5391
|
{
|
|
@@ -5374,8 +5394,8 @@ const GOOGLE_MODELS = exportJson({
|
|
|
5374
5394
|
modelName: 'gemini-2.5-flash-lite',
|
|
5375
5395
|
modelDescription: 'Cost-efficient Gemini 2.5 Flash model optimized for high throughput with 1M token context window. Features thinking capabilities while maintaining the most cost-efficient pricing. Perfect for real-time, low-latency use cases requiring good quality at scale.',
|
|
5376
5396
|
pricing: {
|
|
5377
|
-
prompt: pricing(`$0.
|
|
5378
|
-
output: pricing(`$0.
|
|
5397
|
+
prompt: pricing(`$0.10 / 1M tokens`),
|
|
5398
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
5379
5399
|
},
|
|
5380
5400
|
},
|
|
5381
5401
|
{
|
|
@@ -5895,159 +5915,6 @@ resultContent, rawResponse, duration = ZERO_VALUE) {
|
|
|
5895
5915
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
5896
5916
|
*/
|
|
5897
5917
|
|
|
5898
|
-
/**
|
|
5899
|
-
* Prompt parameter key used to pass hidden runtime context to tool execution.
|
|
5900
|
-
*
|
|
5901
|
-
* @private internal runtime wiring for commitment tools
|
|
5902
|
-
*/
|
|
5903
|
-
const TOOL_RUNTIME_CONTEXT_PARAMETER = 'promptbookToolRuntimeContext';
|
|
5904
|
-
/**
|
|
5905
|
-
* Hidden argument key used to pass runtime context into individual tool calls.
|
|
5906
|
-
*
|
|
5907
|
-
* @private internal runtime wiring for commitment tools
|
|
5908
|
-
*/
|
|
5909
|
-
const TOOL_RUNTIME_CONTEXT_ARGUMENT = '__promptbookToolRuntimeContext';
|
|
5910
|
-
/**
|
|
5911
|
-
* Prompt parameter key used to pass a hidden tool-progress listener token into script execution.
|
|
5912
|
-
*
|
|
5913
|
-
* @private internal runtime wiring for commitment tools
|
|
5914
|
-
*/
|
|
5915
|
-
const TOOL_PROGRESS_TOKEN_PARAMETER = 'promptbookToolProgressToken';
|
|
5916
|
-
/**
|
|
5917
|
-
* Hidden argument key used to pass a tool-progress listener token into individual tool calls.
|
|
5918
|
-
*
|
|
5919
|
-
* @private internal runtime wiring for commitment tools
|
|
5920
|
-
*/
|
|
5921
|
-
const TOOL_PROGRESS_TOKEN_ARGUMENT = '__promptbookToolProgressToken';
|
|
5922
|
-
/**
|
|
5923
|
-
* Monotonic counter used for hidden progress-listener tokens.
|
|
5924
|
-
*
|
|
5925
|
-
* @private internal runtime wiring for commitment tools
|
|
5926
|
-
*/
|
|
5927
|
-
let toolCallProgressListenerCounter = 0;
|
|
5928
|
-
/**
|
|
5929
|
-
* Active tool-progress listeners keyed by hidden execution token.
|
|
5930
|
-
*
|
|
5931
|
-
* @private internal runtime wiring for commitment tools
|
|
5932
|
-
*/
|
|
5933
|
-
const toolCallProgressListeners = new Map();
|
|
5934
|
-
/**
|
|
5935
|
-
* Parses unknown runtime context payload into a normalized object.
|
|
5936
|
-
*
|
|
5937
|
-
* @private internal runtime wiring for commitment tools
|
|
5938
|
-
*/
|
|
5939
|
-
function parseToolRuntimeContext(rawValue) {
|
|
5940
|
-
if (!rawValue) {
|
|
5941
|
-
return null;
|
|
5942
|
-
}
|
|
5943
|
-
let parsed = rawValue;
|
|
5944
|
-
if (typeof rawValue === 'string') {
|
|
5945
|
-
try {
|
|
5946
|
-
parsed = JSON.parse(rawValue);
|
|
5947
|
-
}
|
|
5948
|
-
catch (_a) {
|
|
5949
|
-
return null;
|
|
5950
|
-
}
|
|
5951
|
-
}
|
|
5952
|
-
if (!parsed || typeof parsed !== 'object') {
|
|
5953
|
-
return null;
|
|
5954
|
-
}
|
|
5955
|
-
return parsed;
|
|
5956
|
-
}
|
|
5957
|
-
/**
|
|
5958
|
-
* Reads runtime context attached to tool call arguments.
|
|
5959
|
-
*
|
|
5960
|
-
* @private internal runtime wiring for commitment tools
|
|
5961
|
-
*/
|
|
5962
|
-
function readToolRuntimeContextFromToolArgs(args) {
|
|
5963
|
-
return parseToolRuntimeContext(args[TOOL_RUNTIME_CONTEXT_ARGUMENT]);
|
|
5964
|
-
}
|
|
5965
|
-
/**
|
|
5966
|
-
* Serializes runtime context for prompt parameters.
|
|
5967
|
-
*
|
|
5968
|
-
* @private internal runtime wiring for commitment tools
|
|
5969
|
-
*/
|
|
5970
|
-
function serializeToolRuntimeContext(context) {
|
|
5971
|
-
return JSON.stringify(context);
|
|
5972
|
-
}
|
|
5973
|
-
/**
|
|
5974
|
-
* Registers one in-memory listener that receives progress updates emitted by a running tool.
|
|
5975
|
-
*
|
|
5976
|
-
* The returned token is passed into script execution as a hidden argument so tool implementations
|
|
5977
|
-
* can stream progress without exposing extra parameters to the model.
|
|
5978
|
-
*
|
|
5979
|
-
* @param listener - Listener notified about tool progress.
|
|
5980
|
-
* @returns Hidden token used to route progress updates.
|
|
5981
|
-
* @private internal runtime wiring for commitment tools
|
|
5982
|
-
*/
|
|
5983
|
-
function registerToolCallProgressListener(listener) {
|
|
5984
|
-
toolCallProgressListenerCounter += 1;
|
|
5985
|
-
const token = `tool-progress:${Date.now()}:${toolCallProgressListenerCounter}`;
|
|
5986
|
-
toolCallProgressListeners.set(token, listener);
|
|
5987
|
-
return token;
|
|
5988
|
-
}
|
|
5989
|
-
/**
|
|
5990
|
-
* Unregisters one in-memory progress listener.
|
|
5991
|
-
*
|
|
5992
|
-
* @param token - Token previously created by `registerToolCallProgressListener`.
|
|
5993
|
-
* @private internal runtime wiring for commitment tools
|
|
5994
|
-
*/
|
|
5995
|
-
function unregisterToolCallProgressListener(token) {
|
|
5996
|
-
toolCallProgressListeners.delete(token);
|
|
5997
|
-
}
|
|
5998
|
-
/**
|
|
5999
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
6000
|
-
*/
|
|
6001
|
-
|
|
6002
|
-
/**
|
|
6003
|
-
* Marker property stored inside serialized tool-execution envelopes.
|
|
6004
|
-
*
|
|
6005
|
-
* @private internal tool-execution transport
|
|
6006
|
-
*/
|
|
6007
|
-
const TOOL_EXECUTION_ENVELOPE_MARKER = '__promptbookToolExecutionEnvelope';
|
|
6008
|
-
/**
|
|
6009
|
-
* Creates one serialized tool-execution envelope.
|
|
6010
|
-
*
|
|
6011
|
-
* @private internal tool-execution transport
|
|
6012
|
-
*/
|
|
6013
|
-
function createToolExecutionEnvelope(options) {
|
|
6014
|
-
const envelope = {
|
|
6015
|
-
[TOOL_EXECUTION_ENVELOPE_MARKER]: true,
|
|
6016
|
-
assistantMessage: options.assistantMessage,
|
|
6017
|
-
toolResult: options.toolResult,
|
|
6018
|
-
};
|
|
6019
|
-
return JSON.stringify(envelope);
|
|
6020
|
-
}
|
|
6021
|
-
/**
|
|
6022
|
-
* Parses one serialized tool-execution envelope when present.
|
|
6023
|
-
*
|
|
6024
|
-
* @private internal tool-execution transport
|
|
6025
|
-
*/
|
|
6026
|
-
function parseToolExecutionEnvelope(rawValue) {
|
|
6027
|
-
if (typeof rawValue !== 'string') {
|
|
6028
|
-
return null;
|
|
6029
|
-
}
|
|
6030
|
-
try {
|
|
6031
|
-
const parsedValue = JSON.parse(rawValue);
|
|
6032
|
-
if (!parsedValue ||
|
|
6033
|
-
typeof parsedValue !== 'object' ||
|
|
6034
|
-
parsedValue[TOOL_EXECUTION_ENVELOPE_MARKER] !== true ||
|
|
6035
|
-
typeof parsedValue.assistantMessage !== 'string') {
|
|
6036
|
-
return null;
|
|
6037
|
-
}
|
|
6038
|
-
return {
|
|
6039
|
-
assistantMessage: parsedValue.assistantMessage,
|
|
6040
|
-
toolResult: parsedValue.toolResult,
|
|
6041
|
-
};
|
|
6042
|
-
}
|
|
6043
|
-
catch (_a) {
|
|
6044
|
-
return null;
|
|
6045
|
-
}
|
|
6046
|
-
}
|
|
6047
|
-
/**
|
|
6048
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
6049
|
-
*/
|
|
6050
|
-
|
|
6051
5918
|
/**
|
|
6052
5919
|
* Normalizes a given text to camelCase format.
|
|
6053
5920
|
*
|
|
@@ -6264,7 +6131,7 @@ function serializeError(error) {
|
|
|
6264
6131
|
const { name, message, stack } = error;
|
|
6265
6132
|
const { id } = error;
|
|
6266
6133
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
6267
|
-
console.error(spaceTrim$
|
|
6134
|
+
console.error(spaceTrim$1((block) => `
|
|
6268
6135
|
|
|
6269
6136
|
Cannot serialize error with name "${name}"
|
|
6270
6137
|
|
|
@@ -6370,7 +6237,7 @@ function jsonParse(value) {
|
|
|
6370
6237
|
}
|
|
6371
6238
|
else if (typeof value !== 'string') {
|
|
6372
6239
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
6373
|
-
throw new Error(spaceTrim$
|
|
6240
|
+
throw new Error(spaceTrim$1(`
|
|
6374
6241
|
Can not parse JSON from non-string value.
|
|
6375
6242
|
|
|
6376
6243
|
The value type: ${typeof value}
|
|
@@ -6384,7 +6251,7 @@ function jsonParse(value) {
|
|
|
6384
6251
|
if (!(error instanceof Error)) {
|
|
6385
6252
|
throw error;
|
|
6386
6253
|
}
|
|
6387
|
-
throw new Error(spaceTrim$
|
|
6254
|
+
throw new Error(spaceTrim$1((block) => `
|
|
6388
6255
|
${block(error.message)}
|
|
6389
6256
|
|
|
6390
6257
|
The expected JSON text:
|
|
@@ -6673,7 +6540,7 @@ function buildParametersSection(items) {
|
|
|
6673
6540
|
const entries = items
|
|
6674
6541
|
.flatMap((item) => formatParameterListItem(item).split(/\r?\n/))
|
|
6675
6542
|
.filter((line) => line !== '');
|
|
6676
|
-
return spaceTrim$
|
|
6543
|
+
return spaceTrim$1((block) => `
|
|
6677
6544
|
**Parameters:**
|
|
6678
6545
|
${block(entries.join('\n'))}
|
|
6679
6546
|
|
|
@@ -6746,7 +6613,7 @@ function isPromptString(value) {
|
|
|
6746
6613
|
*/
|
|
6747
6614
|
function prompt(strings, ...values) {
|
|
6748
6615
|
if (values.length === 0) {
|
|
6749
|
-
return new PromptString(spaceTrim$
|
|
6616
|
+
return new PromptString(spaceTrim$1(strings.join('')));
|
|
6750
6617
|
}
|
|
6751
6618
|
const stringsWithHiddenParameters = strings.map((stringsItem) => ParameterEscaping.hideBrackets(stringsItem));
|
|
6752
6619
|
const parameterMetadata = values.map((value) => {
|
|
@@ -6787,7 +6654,7 @@ function prompt(strings, ...values) {
|
|
|
6787
6654
|
? `${result}${stringsItem}`
|
|
6788
6655
|
: `${result}${stringsItem}${ParameterSection.formatParameterPlaceholder(parameterName)}`;
|
|
6789
6656
|
}, '');
|
|
6790
|
-
pipelineString = spaceTrim$
|
|
6657
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
6791
6658
|
try {
|
|
6792
6659
|
pipelineString = templateParameters(pipelineString, parameters);
|
|
6793
6660
|
}
|
|
@@ -6796,7 +6663,7 @@ function prompt(strings, ...values) {
|
|
|
6796
6663
|
throw error;
|
|
6797
6664
|
}
|
|
6798
6665
|
console.error({ pipelineString, parameters, parameterNames: parameterNamesOrdered, error });
|
|
6799
|
-
throw new UnexpectedError(spaceTrim$
|
|
6666
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6800
6667
|
Internal error in prompt template literal
|
|
6801
6668
|
|
|
6802
6669
|
${block(JSON.stringify({ strings, values }, null, 4))}}
|
|
@@ -6914,7 +6781,7 @@ const CountUtils = {
|
|
|
6914
6781
|
* @public exported from `@promptbook/utils`
|
|
6915
6782
|
*/
|
|
6916
6783
|
function computeHash(value) {
|
|
6917
|
-
return SHA256(hexEncoder.parse(spaceTrim$
|
|
6784
|
+
return SHA256(hexEncoder.parse(spaceTrim$1(valueToString(value)))).toString( /* hex */);
|
|
6918
6785
|
}
|
|
6919
6786
|
/**
|
|
6920
6787
|
* TODO: [🥬][🥬] Use this ACRY
|
|
@@ -8969,6 +8836,159 @@ function isValidPipelineUrl(url) {
|
|
|
8969
8836
|
* TODO: [🐠] Maybe more info why the URL is invalid
|
|
8970
8837
|
*/
|
|
8971
8838
|
|
|
8839
|
+
/**
|
|
8840
|
+
* Marker property stored inside serialized tool-execution envelopes.
|
|
8841
|
+
*
|
|
8842
|
+
* @private internal tool-execution transport
|
|
8843
|
+
*/
|
|
8844
|
+
const TOOL_EXECUTION_ENVELOPE_MARKER = '__promptbookToolExecutionEnvelope';
|
|
8845
|
+
/**
|
|
8846
|
+
* Creates one serialized tool-execution envelope.
|
|
8847
|
+
*
|
|
8848
|
+
* @private internal tool-execution transport
|
|
8849
|
+
*/
|
|
8850
|
+
function createToolExecutionEnvelope(options) {
|
|
8851
|
+
const envelope = {
|
|
8852
|
+
[TOOL_EXECUTION_ENVELOPE_MARKER]: true,
|
|
8853
|
+
assistantMessage: options.assistantMessage,
|
|
8854
|
+
toolResult: options.toolResult,
|
|
8855
|
+
};
|
|
8856
|
+
return JSON.stringify(envelope);
|
|
8857
|
+
}
|
|
8858
|
+
/**
|
|
8859
|
+
* Parses one serialized tool-execution envelope when present.
|
|
8860
|
+
*
|
|
8861
|
+
* @private internal tool-execution transport
|
|
8862
|
+
*/
|
|
8863
|
+
function parseToolExecutionEnvelope(rawValue) {
|
|
8864
|
+
if (typeof rawValue !== 'string') {
|
|
8865
|
+
return null;
|
|
8866
|
+
}
|
|
8867
|
+
try {
|
|
8868
|
+
const parsedValue = JSON.parse(rawValue);
|
|
8869
|
+
if (!parsedValue ||
|
|
8870
|
+
typeof parsedValue !== 'object' ||
|
|
8871
|
+
parsedValue[TOOL_EXECUTION_ENVELOPE_MARKER] !== true ||
|
|
8872
|
+
typeof parsedValue.assistantMessage !== 'string') {
|
|
8873
|
+
return null;
|
|
8874
|
+
}
|
|
8875
|
+
return {
|
|
8876
|
+
assistantMessage: parsedValue.assistantMessage,
|
|
8877
|
+
toolResult: parsedValue.toolResult,
|
|
8878
|
+
};
|
|
8879
|
+
}
|
|
8880
|
+
catch (_a) {
|
|
8881
|
+
return null;
|
|
8882
|
+
}
|
|
8883
|
+
}
|
|
8884
|
+
/**
|
|
8885
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
8886
|
+
*/
|
|
8887
|
+
|
|
8888
|
+
/**
|
|
8889
|
+
* Prompt parameter key used to pass hidden runtime context to tool execution.
|
|
8890
|
+
*
|
|
8891
|
+
* @private internal runtime wiring for commitment tools
|
|
8892
|
+
*/
|
|
8893
|
+
const TOOL_RUNTIME_CONTEXT_PARAMETER = 'promptbookToolRuntimeContext';
|
|
8894
|
+
/**
|
|
8895
|
+
* Hidden argument key used to pass runtime context into individual tool calls.
|
|
8896
|
+
*
|
|
8897
|
+
* @private internal runtime wiring for commitment tools
|
|
8898
|
+
*/
|
|
8899
|
+
const TOOL_RUNTIME_CONTEXT_ARGUMENT = '__promptbookToolRuntimeContext';
|
|
8900
|
+
/**
|
|
8901
|
+
* Prompt parameter key used to pass a hidden tool-progress listener token into script execution.
|
|
8902
|
+
*
|
|
8903
|
+
* @private internal runtime wiring for commitment tools
|
|
8904
|
+
*/
|
|
8905
|
+
const TOOL_PROGRESS_TOKEN_PARAMETER = 'promptbookToolProgressToken';
|
|
8906
|
+
/**
|
|
8907
|
+
* Hidden argument key used to pass a tool-progress listener token into individual tool calls.
|
|
8908
|
+
*
|
|
8909
|
+
* @private internal runtime wiring for commitment tools
|
|
8910
|
+
*/
|
|
8911
|
+
const TOOL_PROGRESS_TOKEN_ARGUMENT = '__promptbookToolProgressToken';
|
|
8912
|
+
/**
|
|
8913
|
+
* Monotonic counter used for hidden progress-listener tokens.
|
|
8914
|
+
*
|
|
8915
|
+
* @private internal runtime wiring for commitment tools
|
|
8916
|
+
*/
|
|
8917
|
+
let toolCallProgressListenerCounter = 0;
|
|
8918
|
+
/**
|
|
8919
|
+
* Active tool-progress listeners keyed by hidden execution token.
|
|
8920
|
+
*
|
|
8921
|
+
* @private internal runtime wiring for commitment tools
|
|
8922
|
+
*/
|
|
8923
|
+
const toolCallProgressListeners = new Map();
|
|
8924
|
+
/**
|
|
8925
|
+
* Parses unknown runtime context payload into a normalized object.
|
|
8926
|
+
*
|
|
8927
|
+
* @private internal runtime wiring for commitment tools
|
|
8928
|
+
*/
|
|
8929
|
+
function parseToolRuntimeContext(rawValue) {
|
|
8930
|
+
if (!rawValue) {
|
|
8931
|
+
return null;
|
|
8932
|
+
}
|
|
8933
|
+
let parsed = rawValue;
|
|
8934
|
+
if (typeof rawValue === 'string') {
|
|
8935
|
+
try {
|
|
8936
|
+
parsed = JSON.parse(rawValue);
|
|
8937
|
+
}
|
|
8938
|
+
catch (_a) {
|
|
8939
|
+
return null;
|
|
8940
|
+
}
|
|
8941
|
+
}
|
|
8942
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
8943
|
+
return null;
|
|
8944
|
+
}
|
|
8945
|
+
return parsed;
|
|
8946
|
+
}
|
|
8947
|
+
/**
|
|
8948
|
+
* Reads runtime context attached to tool call arguments.
|
|
8949
|
+
*
|
|
8950
|
+
* @private internal runtime wiring for commitment tools
|
|
8951
|
+
*/
|
|
8952
|
+
function readToolRuntimeContextFromToolArgs(args) {
|
|
8953
|
+
return parseToolRuntimeContext(args[TOOL_RUNTIME_CONTEXT_ARGUMENT]);
|
|
8954
|
+
}
|
|
8955
|
+
/**
|
|
8956
|
+
* Serializes runtime context for prompt parameters.
|
|
8957
|
+
*
|
|
8958
|
+
* @private internal runtime wiring for commitment tools
|
|
8959
|
+
*/
|
|
8960
|
+
function serializeToolRuntimeContext(context) {
|
|
8961
|
+
return JSON.stringify(context);
|
|
8962
|
+
}
|
|
8963
|
+
/**
|
|
8964
|
+
* Registers one in-memory listener that receives progress updates emitted by a running tool.
|
|
8965
|
+
*
|
|
8966
|
+
* The returned token is passed into script execution as a hidden argument so tool implementations
|
|
8967
|
+
* can stream progress without exposing extra parameters to the model.
|
|
8968
|
+
*
|
|
8969
|
+
* @param listener - Listener notified about tool progress.
|
|
8970
|
+
* @returns Hidden token used to route progress updates.
|
|
8971
|
+
* @private internal runtime wiring for commitment tools
|
|
8972
|
+
*/
|
|
8973
|
+
function registerToolCallProgressListener(listener) {
|
|
8974
|
+
toolCallProgressListenerCounter += 1;
|
|
8975
|
+
const token = `tool-progress:${Date.now()}:${toolCallProgressListenerCounter}`;
|
|
8976
|
+
toolCallProgressListeners.set(token, listener);
|
|
8977
|
+
return token;
|
|
8978
|
+
}
|
|
8979
|
+
/**
|
|
8980
|
+
* Unregisters one in-memory progress listener.
|
|
8981
|
+
*
|
|
8982
|
+
* @param token - Token previously created by `registerToolCallProgressListener`.
|
|
8983
|
+
* @private internal runtime wiring for commitment tools
|
|
8984
|
+
*/
|
|
8985
|
+
function unregisterToolCallProgressListener(token) {
|
|
8986
|
+
toolCallProgressListeners.delete(token);
|
|
8987
|
+
}
|
|
8988
|
+
/**
|
|
8989
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
8990
|
+
*/
|
|
8991
|
+
|
|
8972
8992
|
/**
|
|
8973
8993
|
* Function `addUsage` will add multiple usages into one
|
|
8974
8994
|
*
|
|
@@ -9023,53 +9043,6 @@ function addUsage(...usageItems) {
|
|
|
9023
9043
|
}, deepClone(ZERO_USAGE));
|
|
9024
9044
|
}
|
|
9025
9045
|
|
|
9026
|
-
/**
|
|
9027
|
-
* Maps Promptbook tools to OpenAI tools.
|
|
9028
|
-
*
|
|
9029
|
-
* @private
|
|
9030
|
-
*/
|
|
9031
|
-
function mapToolsToOpenAi(tools) {
|
|
9032
|
-
return tools.map((tool) => ({
|
|
9033
|
-
type: 'function',
|
|
9034
|
-
function: {
|
|
9035
|
-
name: tool.name,
|
|
9036
|
-
description: tool.description,
|
|
9037
|
-
parameters: tool.parameters,
|
|
9038
|
-
},
|
|
9039
|
-
}));
|
|
9040
|
-
}
|
|
9041
|
-
|
|
9042
|
-
/**
|
|
9043
|
-
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
9044
|
-
*
|
|
9045
|
-
* @private utility of OpenAI tool execution wrappers
|
|
9046
|
-
*/
|
|
9047
|
-
function buildToolInvocationScript(options) {
|
|
9048
|
-
const { functionName, functionArgsExpression } = options;
|
|
9049
|
-
return `
|
|
9050
|
-
const args = ${functionArgsExpression};
|
|
9051
|
-
const runtimeContextRaw =
|
|
9052
|
-
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
9053
|
-
? undefined
|
|
9054
|
-
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
9055
|
-
|
|
9056
|
-
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
9057
|
-
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
9058
|
-
}
|
|
9059
|
-
|
|
9060
|
-
const toolProgressTokenRaw =
|
|
9061
|
-
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
9062
|
-
? undefined
|
|
9063
|
-
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
9064
|
-
|
|
9065
|
-
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
9066
|
-
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
9067
|
-
}
|
|
9068
|
-
|
|
9069
|
-
return await ${functionName}(args);
|
|
9070
|
-
`;
|
|
9071
|
-
}
|
|
9072
|
-
|
|
9073
9046
|
/**
|
|
9074
9047
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
9075
9048
|
*
|
|
@@ -9126,6 +9099,53 @@ function isUnsupportedParameterError(error) {
|
|
|
9126
9099
|
errorMessage.includes('does not support'));
|
|
9127
9100
|
}
|
|
9128
9101
|
|
|
9102
|
+
/**
|
|
9103
|
+
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
9104
|
+
*
|
|
9105
|
+
* @private utility of OpenAI tool execution wrappers
|
|
9106
|
+
*/
|
|
9107
|
+
function buildToolInvocationScript(options) {
|
|
9108
|
+
const { functionName, functionArgsExpression } = options;
|
|
9109
|
+
return `
|
|
9110
|
+
const args = ${functionArgsExpression};
|
|
9111
|
+
const runtimeContextRaw =
|
|
9112
|
+
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
9113
|
+
? undefined
|
|
9114
|
+
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
9115
|
+
|
|
9116
|
+
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
9117
|
+
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
9118
|
+
}
|
|
9119
|
+
|
|
9120
|
+
const toolProgressTokenRaw =
|
|
9121
|
+
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
9122
|
+
? undefined
|
|
9123
|
+
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
9124
|
+
|
|
9125
|
+
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
9126
|
+
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
9127
|
+
}
|
|
9128
|
+
|
|
9129
|
+
return await ${functionName}(args);
|
|
9130
|
+
`;
|
|
9131
|
+
}
|
|
9132
|
+
|
|
9133
|
+
/**
|
|
9134
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
9135
|
+
*
|
|
9136
|
+
* @private
|
|
9137
|
+
*/
|
|
9138
|
+
function mapToolsToOpenAi(tools) {
|
|
9139
|
+
return tools.map((tool) => ({
|
|
9140
|
+
type: 'function',
|
|
9141
|
+
function: {
|
|
9142
|
+
name: tool.name,
|
|
9143
|
+
description: tool.description,
|
|
9144
|
+
parameters: tool.parameters,
|
|
9145
|
+
},
|
|
9146
|
+
}));
|
|
9147
|
+
}
|
|
9148
|
+
|
|
9129
9149
|
/**
|
|
9130
9150
|
* Provides access to the structured clone implementation when available.
|
|
9131
9151
|
*/
|
|
@@ -10092,7 +10112,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
10092
10112
|
// Note: Match exact or prefix for model families
|
|
10093
10113
|
const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
|
|
10094
10114
|
if (model === undefined) {
|
|
10095
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
10115
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
10096
10116
|
Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
|
|
10097
10117
|
|
|
10098
10118
|
Available models:
|
|
@@ -11967,7 +11987,7 @@ class OpenAiAssistantExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
11967
11987
|
assertsError(error);
|
|
11968
11988
|
const serializedError = serializeError(error);
|
|
11969
11989
|
errors = [serializedError];
|
|
11970
|
-
functionResponse = spaceTrim$
|
|
11990
|
+
functionResponse = spaceTrim$1((block) => `
|
|
11971
11991
|
|
|
11972
11992
|
The invoked tool \`${functionName}\` failed with error:
|
|
11973
11993
|
|
|
@@ -13056,7 +13076,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
13056
13076
|
pipelineString += '\n\n';
|
|
13057
13077
|
pipelineString += '```' + contentLanguage;
|
|
13058
13078
|
pipelineString += '\n';
|
|
13059
|
-
pipelineString += spaceTrim$
|
|
13079
|
+
pipelineString += spaceTrim$1(content);
|
|
13060
13080
|
// <- TODO: [main] !!3 Escape
|
|
13061
13081
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
13062
13082
|
pipelineString += '\n';
|
|
@@ -13956,14 +13976,14 @@ class MultipleLlmExecutionTools {
|
|
|
13956
13976
|
if (description === undefined) {
|
|
13957
13977
|
return headLine;
|
|
13958
13978
|
}
|
|
13959
|
-
return spaceTrim$
|
|
13979
|
+
return spaceTrim$1((block) => `
|
|
13960
13980
|
${headLine}
|
|
13961
13981
|
|
|
13962
13982
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
13963
13983
|
`);
|
|
13964
13984
|
})
|
|
13965
13985
|
.join('\n\n');
|
|
13966
|
-
return spaceTrim$
|
|
13986
|
+
return spaceTrim$1((block) => `
|
|
13967
13987
|
Multiple LLM Providers:
|
|
13968
13988
|
|
|
13969
13989
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -14065,7 +14085,7 @@ class MultipleLlmExecutionTools {
|
|
|
14065
14085
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
14066
14086
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
14067
14087
|
// 3) ...
|
|
14068
|
-
spaceTrim$
|
|
14088
|
+
spaceTrim$1((block) => `
|
|
14069
14089
|
All execution tools of ${this.title} failed:
|
|
14070
14090
|
|
|
14071
14091
|
${block(errors
|
|
@@ -14078,7 +14098,7 @@ class MultipleLlmExecutionTools {
|
|
|
14078
14098
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
14079
14099
|
}
|
|
14080
14100
|
else {
|
|
14081
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
14101
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
14082
14102
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
14083
14103
|
|
|
14084
14104
|
Available \`LlmExecutionTools\`:
|
|
@@ -14115,7 +14135,7 @@ class MultipleLlmExecutionTools {
|
|
|
14115
14135
|
*/
|
|
14116
14136
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
14117
14137
|
if (llmExecutionTools.length === 0) {
|
|
14118
|
-
const warningMessage = spaceTrim$
|
|
14138
|
+
const warningMessage = spaceTrim$1(`
|
|
14119
14139
|
You have not provided any \`LlmExecutionTools\`
|
|
14120
14140
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
14121
14141
|
|
|
@@ -14287,14 +14307,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
14287
14307
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
14288
14308
|
});
|
|
14289
14309
|
if (metadata.length === 0) {
|
|
14290
|
-
return spaceTrim$
|
|
14310
|
+
return spaceTrim$1(`
|
|
14291
14311
|
**No scrapers are available**
|
|
14292
14312
|
|
|
14293
14313
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
14294
14314
|
At least there should be available the metadata of the scrapers
|
|
14295
14315
|
`);
|
|
14296
14316
|
}
|
|
14297
|
-
return spaceTrim$
|
|
14317
|
+
return spaceTrim$1((block) => `
|
|
14298
14318
|
Available scrapers are:
|
|
14299
14319
|
${block(metadata
|
|
14300
14320
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -14395,7 +14415,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
14395
14415
|
else if (urlOrRequest instanceof Request) {
|
|
14396
14416
|
url = urlOrRequest.url;
|
|
14397
14417
|
}
|
|
14398
|
-
throw new PromptbookFetchError(spaceTrim$
|
|
14418
|
+
throw new PromptbookFetchError(spaceTrim$1((block) => `
|
|
14399
14419
|
Can not fetch "${url}"
|
|
14400
14420
|
|
|
14401
14421
|
Fetch error:
|
|
@@ -14555,7 +14575,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
14555
14575
|
const fileExtension = getFileExtension(filename);
|
|
14556
14576
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
14557
14577
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
14558
|
-
throw new NotFoundError(spaceTrim$
|
|
14578
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
14559
14579
|
Can not make source handler for file which does not exist:
|
|
14560
14580
|
|
|
14561
14581
|
File:
|
|
@@ -14648,7 +14668,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
14648
14668
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
14649
14669
|
break;
|
|
14650
14670
|
}
|
|
14651
|
-
console.warn(spaceTrim$
|
|
14671
|
+
console.warn(spaceTrim$1((block) => `
|
|
14652
14672
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
14653
14673
|
|
|
14654
14674
|
The source:
|
|
@@ -14664,7 +14684,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
14664
14684
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
14665
14685
|
}
|
|
14666
14686
|
if (partialPieces === null) {
|
|
14667
|
-
throw new KnowledgeScrapeError(spaceTrim$
|
|
14687
|
+
throw new KnowledgeScrapeError(spaceTrim$1((block) => `
|
|
14668
14688
|
Cannot scrape knowledge
|
|
14669
14689
|
|
|
14670
14690
|
The source:
|
|
@@ -15101,7 +15121,7 @@ const CsvFormatParser = {
|
|
|
15101
15121
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
15102
15122
|
const csv = csvParse(value, settings);
|
|
15103
15123
|
if (csv.errors.length !== 0) {
|
|
15104
|
-
throw new CsvFormatError(spaceTrim$
|
|
15124
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
15105
15125
|
CSV parsing error
|
|
15106
15126
|
|
|
15107
15127
|
Error(s) from CSV parsing:
|
|
@@ -15146,7 +15166,7 @@ const CsvFormatParser = {
|
|
|
15146
15166
|
const { value, settings, mapCallback, onProgress } = options;
|
|
15147
15167
|
const csv = csvParse(value, settings);
|
|
15148
15168
|
if (csv.errors.length !== 0) {
|
|
15149
|
-
throw new CsvFormatError(spaceTrim$
|
|
15169
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
15150
15170
|
CSV parsing error
|
|
15151
15171
|
|
|
15152
15172
|
Error(s) from CSV parsing:
|
|
@@ -15332,7 +15352,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
15332
15352
|
}
|
|
15333
15353
|
// Phase 2️⃣: Non-matching mapping
|
|
15334
15354
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
15335
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
15355
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
15336
15356
|
Can not map available parameters to expected parameters
|
|
15337
15357
|
|
|
15338
15358
|
Mapped parameters:
|
|
@@ -15905,7 +15925,7 @@ async function executeFormatSubvalues(options) {
|
|
|
15905
15925
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
15906
15926
|
}
|
|
15907
15927
|
if (jokerParameterNames.length !== 0) {
|
|
15908
|
-
throw new UnexpectedError(spaceTrim$
|
|
15928
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
15909
15929
|
JOKER parameters are not supported together with FOREACH command
|
|
15910
15930
|
|
|
15911
15931
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -15918,7 +15938,7 @@ async function executeFormatSubvalues(options) {
|
|
|
15918
15938
|
if (formatDefinition === undefined) {
|
|
15919
15939
|
throw new UnexpectedError(
|
|
15920
15940
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
15921
|
-
spaceTrim$
|
|
15941
|
+
spaceTrim$1((block) => `
|
|
15922
15942
|
Unsupported format "${task.foreach.formatName}"
|
|
15923
15943
|
|
|
15924
15944
|
Available formats:
|
|
@@ -15935,7 +15955,7 @@ async function executeFormatSubvalues(options) {
|
|
|
15935
15955
|
if (subvalueParser === undefined) {
|
|
15936
15956
|
throw new UnexpectedError(
|
|
15937
15957
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
15938
|
-
spaceTrim$
|
|
15958
|
+
spaceTrim$1((block) => `
|
|
15939
15959
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
15940
15960
|
|
|
15941
15961
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -15975,7 +15995,7 @@ async function executeFormatSubvalues(options) {
|
|
|
15975
15995
|
if (!(error instanceof PipelineExecutionError)) {
|
|
15976
15996
|
throw error;
|
|
15977
15997
|
}
|
|
15978
|
-
const highLevelError = new PipelineExecutionError(spaceTrim$
|
|
15998
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
|
|
15979
15999
|
${error.message}
|
|
15980
16000
|
|
|
15981
16001
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -15999,7 +16019,7 @@ async function executeFormatSubvalues(options) {
|
|
|
15999
16019
|
...options,
|
|
16000
16020
|
priority: priority + index,
|
|
16001
16021
|
parameters: allSubparameters,
|
|
16002
|
-
pipelineIdentification: spaceTrim$
|
|
16022
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
16003
16023
|
${block(pipelineIdentification)}
|
|
16004
16024
|
Subparameter index: ${index}
|
|
16005
16025
|
`),
|
|
@@ -16008,7 +16028,7 @@ async function executeFormatSubvalues(options) {
|
|
|
16008
16028
|
}
|
|
16009
16029
|
catch (error) {
|
|
16010
16030
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
16011
|
-
console.error(spaceTrim$
|
|
16031
|
+
console.error(spaceTrim$1((block) => `
|
|
16012
16032
|
${error.message}
|
|
16013
16033
|
|
|
16014
16034
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -16880,8 +16900,8 @@ class MarkdownScraper {
|
|
|
16880
16900
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
16881
16901
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
16882
16902
|
let name = `piece-${i}`;
|
|
16883
|
-
let title = spaceTrim$
|
|
16884
|
-
const knowledgePieceContent = spaceTrim$
|
|
16903
|
+
let title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
|
|
16904
|
+
const knowledgePieceContent = spaceTrim$1(knowledgeTextPiece);
|
|
16885
16905
|
let keywords = [];
|
|
16886
16906
|
const index = [];
|
|
16887
16907
|
/*
|
|
@@ -16894,7 +16914,7 @@ class MarkdownScraper {
|
|
|
16894
16914
|
isCrashedOnError: true,
|
|
16895
16915
|
});
|
|
16896
16916
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
16897
|
-
title = spaceTrim$
|
|
16917
|
+
title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
16898
16918
|
name = titleToName(title);
|
|
16899
16919
|
// --- Keywords
|
|
16900
16920
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
@@ -17049,7 +17069,7 @@ class BoilerplateScraper {
|
|
|
17049
17069
|
await $execCommand(command);
|
|
17050
17070
|
// Note: [0]
|
|
17051
17071
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
17052
|
-
throw new UnexpectedError(spaceTrim$
|
|
17072
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
17053
17073
|
File that was supposed to be created by Pandoc does not exist for unknown reason
|
|
17054
17074
|
|
|
17055
17075
|
Expected file:
|
|
@@ -17213,7 +17233,7 @@ class DocumentScraper {
|
|
|
17213
17233
|
await $execCommand(command);
|
|
17214
17234
|
// Note: [0]
|
|
17215
17235
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
17216
|
-
throw new UnexpectedError(spaceTrim$
|
|
17236
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
17217
17237
|
File that was supposed to be created by Pandoc does not exist for unknown reason
|
|
17218
17238
|
|
|
17219
17239
|
Expected file:
|
|
@@ -17364,7 +17384,7 @@ class LegacyDocumentScraper {
|
|
|
17364
17384
|
await $execCommand(command);
|
|
17365
17385
|
const files = await readdir(documentSourceOutdirPathForLibreOffice);
|
|
17366
17386
|
if (files.length !== 1) {
|
|
17367
|
-
throw new UnexpectedError(spaceTrim$
|
|
17387
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
17368
17388
|
Expected exactly 1 file in the LibreOffice output directory, got ${files.length}
|
|
17369
17389
|
|
|
17370
17390
|
The temporary folder:
|
|
@@ -17378,7 +17398,7 @@ class LegacyDocumentScraper {
|
|
|
17378
17398
|
await rename(join(documentSourceOutdirPathForLibreOffice, file), cacheFilehandler.filename);
|
|
17379
17399
|
await rmdir(documentSourceOutdirPathForLibreOffice);
|
|
17380
17400
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
17381
|
-
throw new UnexpectedError(spaceTrim$
|
|
17401
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
17382
17402
|
File that was supposed to be created by LibreOffice does not exist for unknown reason
|
|
17383
17403
|
|
|
17384
17404
|
Expected file:
|
|
@@ -29255,7 +29275,7 @@ function computeAgentHash(agentSource) {
|
|
|
29255
29275
|
* @public exported from `@promptbook/core`
|
|
29256
29276
|
*/
|
|
29257
29277
|
function normalizeAgentName(rawAgentName) {
|
|
29258
|
-
return titleToName(spaceTrim$
|
|
29278
|
+
return titleToName(spaceTrim$1(rawAgentName));
|
|
29259
29279
|
}
|
|
29260
29280
|
|
|
29261
29281
|
/**
|
|
@@ -29430,7 +29450,7 @@ function parseAgentSource(agentSource) {
|
|
|
29430
29450
|
continue;
|
|
29431
29451
|
}
|
|
29432
29452
|
if (commitment.type === 'FROM') {
|
|
29433
|
-
const content = spaceTrim$
|
|
29453
|
+
const content = spaceTrim$1(commitment.content).split(/\r?\n/)[0] || '';
|
|
29434
29454
|
if (content === 'Adam' || content === '' /* <- Note: Adam is implicit */) {
|
|
29435
29455
|
continue;
|
|
29436
29456
|
}
|
|
@@ -29453,7 +29473,7 @@ function parseAgentSource(agentSource) {
|
|
|
29453
29473
|
continue;
|
|
29454
29474
|
}
|
|
29455
29475
|
if (commitment.type === 'IMPORT') {
|
|
29456
|
-
const content = spaceTrim$
|
|
29476
|
+
const content = spaceTrim$1(commitment.content).split(/\r?\n/)[0] || '';
|
|
29457
29477
|
let label = content;
|
|
29458
29478
|
let iconName = 'ExternalLink'; // Import remote
|
|
29459
29479
|
try {
|
|
@@ -29491,7 +29511,7 @@ function parseAgentSource(agentSource) {
|
|
|
29491
29511
|
continue;
|
|
29492
29512
|
}
|
|
29493
29513
|
if (commitment.type === 'KNOWLEDGE') {
|
|
29494
|
-
const content = spaceTrim$
|
|
29514
|
+
const content = spaceTrim$1(commitment.content);
|
|
29495
29515
|
const extractedUrls = extractUrlsFromText(content);
|
|
29496
29516
|
let label = content;
|
|
29497
29517
|
let iconName = 'Book';
|
|
@@ -29550,7 +29570,7 @@ function parseAgentSource(agentSource) {
|
|
|
29550
29570
|
continue;
|
|
29551
29571
|
}
|
|
29552
29572
|
if (commitment.type === 'META LINK') {
|
|
29553
|
-
const linkValue = spaceTrim$
|
|
29573
|
+
const linkValue = spaceTrim$1(commitment.content);
|
|
29554
29574
|
links.push(linkValue);
|
|
29555
29575
|
meta.link = linkValue;
|
|
29556
29576
|
continue;
|
|
@@ -29560,11 +29580,11 @@ function parseAgentSource(agentSource) {
|
|
|
29560
29580
|
continue;
|
|
29561
29581
|
}
|
|
29562
29582
|
if (commitment.type === 'META IMAGE') {
|
|
29563
|
-
meta.image = spaceTrim$
|
|
29583
|
+
meta.image = spaceTrim$1(commitment.content);
|
|
29564
29584
|
continue;
|
|
29565
29585
|
}
|
|
29566
29586
|
if (commitment.type === 'META DESCRIPTION') {
|
|
29567
|
-
meta.description = spaceTrim$
|
|
29587
|
+
meta.description = spaceTrim$1(commitment.content);
|
|
29568
29588
|
continue;
|
|
29569
29589
|
}
|
|
29570
29590
|
if (commitment.type === 'META DISCLAIMER') {
|
|
@@ -29572,7 +29592,7 @@ function parseAgentSource(agentSource) {
|
|
|
29572
29592
|
continue;
|
|
29573
29593
|
}
|
|
29574
29594
|
if (commitment.type === 'META INPUT PLACEHOLDER') {
|
|
29575
|
-
meta.inputPlaceholder = spaceTrim$
|
|
29595
|
+
meta.inputPlaceholder = spaceTrim$1(commitment.content);
|
|
29576
29596
|
continue;
|
|
29577
29597
|
}
|
|
29578
29598
|
if (commitment.type === 'MESSAGE SUFFIX') {
|
|
@@ -29588,7 +29608,7 @@ function parseAgentSource(agentSource) {
|
|
|
29588
29608
|
continue;
|
|
29589
29609
|
}
|
|
29590
29610
|
if (commitment.type === 'META VOICE') {
|
|
29591
|
-
meta.voice = spaceTrim$
|
|
29611
|
+
meta.voice = spaceTrim$1(commitment.content);
|
|
29592
29612
|
continue;
|
|
29593
29613
|
}
|
|
29594
29614
|
if (commitment.type !== 'META') {
|
|
@@ -29597,10 +29617,10 @@ function parseAgentSource(agentSource) {
|
|
|
29597
29617
|
// Parse META commitments - format is "META TYPE content"
|
|
29598
29618
|
const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
|
|
29599
29619
|
if (metaTypeRaw === 'LINK') {
|
|
29600
|
-
links.push(spaceTrim$
|
|
29620
|
+
links.push(spaceTrim$1(commitment.content.substring(metaTypeRaw.length)));
|
|
29601
29621
|
}
|
|
29602
29622
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
29603
|
-
meta[metaType] = spaceTrim$
|
|
29623
|
+
meta[metaType] = spaceTrim$1(commitment.content.substring(metaTypeRaw.length));
|
|
29604
29624
|
}
|
|
29605
29625
|
// Generate fullname fallback if no meta fullname specified
|
|
29606
29626
|
if (!meta.fullname) {
|
|
@@ -29631,7 +29651,7 @@ function parseAgentSource(agentSource) {
|
|
|
29631
29651
|
* @returns The content with normalized separators
|
|
29632
29652
|
*/
|
|
29633
29653
|
function normalizeSeparator(content) {
|
|
29634
|
-
const trimmed = spaceTrim$
|
|
29654
|
+
const trimmed = spaceTrim$1(content);
|
|
29635
29655
|
if (trimmed.includes(',')) {
|
|
29636
29656
|
return trimmed;
|
|
29637
29657
|
}
|
|
@@ -29644,7 +29664,7 @@ function normalizeSeparator(content) {
|
|
|
29644
29664
|
* @returns Normalized domain or a trimmed fallback.
|
|
29645
29665
|
*/
|
|
29646
29666
|
function normalizeMetaDomain(content) {
|
|
29647
|
-
const trimmed = spaceTrim$
|
|
29667
|
+
const trimmed = spaceTrim$1(content);
|
|
29648
29668
|
return normalizeDomainForMatching(trimmed) || trimmed.toLowerCase();
|
|
29649
29669
|
}
|
|
29650
29670
|
/**
|
|
@@ -29792,7 +29812,7 @@ const OpenAiSdkTranspiler = {
|
|
|
29792
29812
|
}
|
|
29793
29813
|
const KNOWLEDGE_THRESHOLD = 1000;
|
|
29794
29814
|
if (directKnowledge.join('\n').length > KNOWLEDGE_THRESHOLD || knowledgeSources.length > 0) {
|
|
29795
|
-
return spaceTrim$
|
|
29815
|
+
return spaceTrim$1((block) => `
|
|
29796
29816
|
#!/usr/bin/env node
|
|
29797
29817
|
|
|
29798
29818
|
import * as dotenv from 'dotenv';
|
|
@@ -29867,7 +29887,7 @@ const OpenAiSdkTranspiler = {
|
|
|
29867
29887
|
|
|
29868
29888
|
if (context) {
|
|
29869
29889
|
question = spaceTrim(\`
|
|
29870
|
-
${block(spaceTrim$
|
|
29890
|
+
${block(spaceTrim$1(`
|
|
29871
29891
|
Here is some additional context to help you answer the question:
|
|
29872
29892
|
\${context}
|
|
29873
29893
|
|
|
@@ -29948,7 +29968,7 @@ const OpenAiSdkTranspiler = {
|
|
|
29948
29968
|
})();
|
|
29949
29969
|
`);
|
|
29950
29970
|
}
|
|
29951
|
-
const source = spaceTrim$
|
|
29971
|
+
const source = spaceTrim$1((block) => `
|
|
29952
29972
|
|
|
29953
29973
|
#!/usr/bin/env node
|
|
29954
29974
|
|
|
@@ -30787,13 +30807,13 @@ function $registeredLlmToolsMessage() {
|
|
|
30787
30807
|
});
|
|
30788
30808
|
const usedEnvMessage = $usedEnvFilename === null ? `Unknown \`.env\` file` : `Used \`.env\` file:\n${$usedEnvFilename}`;
|
|
30789
30809
|
if (metadata.length === 0) {
|
|
30790
|
-
return spaceTrim$
|
|
30810
|
+
return spaceTrim$1((block) => `
|
|
30791
30811
|
No LLM providers are available.
|
|
30792
30812
|
|
|
30793
30813
|
${block(usedEnvMessage)}
|
|
30794
30814
|
`);
|
|
30795
30815
|
}
|
|
30796
|
-
return spaceTrim$
|
|
30816
|
+
return spaceTrim$1((block) => `
|
|
30797
30817
|
|
|
30798
30818
|
${block(usedEnvMessage)}
|
|
30799
30819
|
|
|
@@ -30839,7 +30859,7 @@ function $registeredLlmToolsMessage() {
|
|
|
30839
30859
|
morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
|
|
30840
30860
|
}
|
|
30841
30861
|
}
|
|
30842
|
-
let providerMessage = spaceTrim$
|
|
30862
|
+
let providerMessage = spaceTrim$1(`
|
|
30843
30863
|
${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
|
|
30844
30864
|
${morePieces.join('; ')}
|
|
30845
30865
|
`);
|
|
@@ -30973,7 +30993,7 @@ class $EnvStorage {
|
|
|
30973
30993
|
.filter((line) => !line.startsWith(`# ${GENERATOR_WARNING_IN_ENV}`)) // Remove GENERATOR_WARNING_IN_ENV
|
|
30974
30994
|
.filter((line) => !line.startsWith(`${transformedKey}=`)) // Remove existing key if present
|
|
30975
30995
|
.join('\n');
|
|
30976
|
-
const newEnvContent = spaceTrim$
|
|
30996
|
+
const newEnvContent = spaceTrim$1((block) => `
|
|
30977
30997
|
${block(updatedEnvContent)}
|
|
30978
30998
|
|
|
30979
30999
|
# ${GENERATOR_WARNING_IN_ENV}
|
|
@@ -31002,7 +31022,7 @@ class $EnvStorage {
|
|
|
31002
31022
|
*/
|
|
31003
31023
|
function stringifyPipelineJson(pipeline) {
|
|
31004
31024
|
if (!isSerializableAsJson(pipeline)) {
|
|
31005
|
-
throw new UnexpectedError(spaceTrim$
|
|
31025
|
+
throw new UnexpectedError(spaceTrim$1(`
|
|
31006
31026
|
Cannot stringify the pipeline, because it is not serializable as JSON
|
|
31007
31027
|
|
|
31008
31028
|
There can be multiple reasons:
|
|
@@ -31185,7 +31205,7 @@ function cacheLlmTools(llmTools, options = {}) {
|
|
|
31185
31205
|
let normalizedContent = content;
|
|
31186
31206
|
normalizedContent = normalizedContent.replace(/\s+/g, ' ');
|
|
31187
31207
|
normalizedContent = normalizedContent.split('\r\n').join('\n');
|
|
31188
|
-
normalizedContent = spaceTrim$
|
|
31208
|
+
normalizedContent = spaceTrim$1(normalizedContent);
|
|
31189
31209
|
// Note: Do not need to save everything in the cache, just the relevant parameters
|
|
31190
31210
|
const relevantParameterNames = extractParameterNames(content);
|
|
31191
31211
|
const relevantParameters = Object.fromEntries(Object.entries(parameters).filter(([key]) => relevantParameterNames.has(key)));
|
|
@@ -31421,7 +31441,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
|
|
|
31421
31441
|
.find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
|
|
31422
31442
|
if (registeredItem === undefined) {
|
|
31423
31443
|
// console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
|
|
31424
|
-
throw new Error(spaceTrim$
|
|
31444
|
+
throw new Error(spaceTrim$1((block) => `
|
|
31425
31445
|
There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
|
|
31426
31446
|
Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
|
|
31427
31447
|
|
|
@@ -31489,14 +31509,14 @@ async function $provideLlmToolsFromEnv(options = {}) {
|
|
|
31489
31509
|
const configuration = await $provideLlmToolsConfigurationFromEnv();
|
|
31490
31510
|
if (configuration.length === 0) {
|
|
31491
31511
|
if ($llmToolsMetadataRegister.list().length === 0) {
|
|
31492
|
-
throw new UnexpectedError(spaceTrim$
|
|
31512
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
31493
31513
|
No LLM tools registered, this is probably a bug in the Promptbook library
|
|
31494
31514
|
|
|
31495
31515
|
${block($registeredLlmToolsMessage())}}
|
|
31496
31516
|
`));
|
|
31497
31517
|
}
|
|
31498
31518
|
// TODO: [🥃]
|
|
31499
|
-
throw new Error(spaceTrim$
|
|
31519
|
+
throw new Error(spaceTrim$1((block) => `
|
|
31500
31520
|
No LLM tools found in the environment
|
|
31501
31521
|
|
|
31502
31522
|
${block($registeredLlmToolsMessage())}}
|
|
@@ -31635,7 +31655,7 @@ async function $provideScrapersForNode(tools, options) {
|
|
|
31635
31655
|
function extractOneBlockFromMarkdown(markdown) {
|
|
31636
31656
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
31637
31657
|
if (codeBlocks.length !== 1) {
|
|
31638
|
-
throw new ParseError(spaceTrim$
|
|
31658
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
31639
31659
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
31640
31660
|
|
|
31641
31661
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -31744,7 +31764,7 @@ class JavascriptEvalExecutionTools {
|
|
|
31744
31764
|
}
|
|
31745
31765
|
// Note: [💎]
|
|
31746
31766
|
// Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
|
|
31747
|
-
const spaceTrim = (_) =>
|
|
31767
|
+
const spaceTrim = (_) => _spaceTrim(_);
|
|
31748
31768
|
$preserve(spaceTrim);
|
|
31749
31769
|
const removeQuotes$1 = removeQuotes;
|
|
31750
31770
|
$preserve(removeQuotes$1);
|
|
@@ -31835,7 +31855,7 @@ class JavascriptEvalExecutionTools {
|
|
|
31835
31855
|
.join('\n');
|
|
31836
31856
|
// script = templateParameters(script, parameters);
|
|
31837
31857
|
// <- TODO: [🧠][🥳] Should be this is one of two variants how to use parameters in script
|
|
31838
|
-
const statementToEvaluate =
|
|
31858
|
+
const statementToEvaluate = _spaceTrim((block) => `
|
|
31839
31859
|
|
|
31840
31860
|
// Build-in functions:
|
|
31841
31861
|
${block(buildinFunctionsStatement)}
|
|
@@ -31850,7 +31870,7 @@ class JavascriptEvalExecutionTools {
|
|
|
31850
31870
|
(async ()=>{ ${script} })()
|
|
31851
31871
|
`);
|
|
31852
31872
|
if (this.options.isVerbose) {
|
|
31853
|
-
console.info(
|
|
31873
|
+
console.info(_spaceTrim((block) => `
|
|
31854
31874
|
🚀 Evaluating ${scriptLanguage} script:
|
|
31855
31875
|
|
|
31856
31876
|
${block(statementToEvaluate)}`));
|
|
@@ -31859,7 +31879,7 @@ class JavascriptEvalExecutionTools {
|
|
|
31859
31879
|
try {
|
|
31860
31880
|
result = await eval(statementToEvaluate);
|
|
31861
31881
|
if (this.options.isVerbose) {
|
|
31862
|
-
console.info(
|
|
31882
|
+
console.info(_spaceTrim((block) => `
|
|
31863
31883
|
🚀 Script evaluated successfully, result:
|
|
31864
31884
|
${block(valueToString(result))}
|
|
31865
31885
|
`));
|
|
@@ -31878,7 +31898,7 @@ class JavascriptEvalExecutionTools {
|
|
|
31878
31898
|
To: [PipelineExecutionError: Parameter `{thing}` is not defined],
|
|
31879
31899
|
*/
|
|
31880
31900
|
if (!statementToEvaluate.includes(undefinedName + '(')) {
|
|
31881
|
-
throw new PipelineExecutionError(
|
|
31901
|
+
throw new PipelineExecutionError(_spaceTrim((block) => `
|
|
31882
31902
|
|
|
31883
31903
|
Parameter \`{${undefinedName}}\` is not defined
|
|
31884
31904
|
|
|
@@ -31900,7 +31920,7 @@ class JavascriptEvalExecutionTools {
|
|
|
31900
31920
|
`));
|
|
31901
31921
|
}
|
|
31902
31922
|
else {
|
|
31903
|
-
throw new PipelineExecutionError(
|
|
31923
|
+
throw new PipelineExecutionError(_spaceTrim((block) => `
|
|
31904
31924
|
Function ${undefinedName}() is not defined
|
|
31905
31925
|
|
|
31906
31926
|
- Make sure that the function is one of built-in functions
|
|
@@ -32039,7 +32059,7 @@ const knowledgeCommandParser = {
|
|
|
32039
32059
|
*/
|
|
32040
32060
|
parse(input) {
|
|
32041
32061
|
const { args } = input;
|
|
32042
|
-
const knowledgeSourceContent = spaceTrim$
|
|
32062
|
+
const knowledgeSourceContent = spaceTrim$1(args[0] || '');
|
|
32043
32063
|
if (knowledgeSourceContent === '') {
|
|
32044
32064
|
throw new ParseError(`Source is not defined`);
|
|
32045
32065
|
}
|
|
@@ -32183,7 +32203,7 @@ const sectionCommandParser = {
|
|
|
32183
32203
|
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
32184
32204
|
const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
|
|
32185
32205
|
if (taskTypes.length !== 1) {
|
|
32186
|
-
throw new ParseError(spaceTrim$
|
|
32206
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
32187
32207
|
Unknown section type "${normalized}"
|
|
32188
32208
|
|
|
32189
32209
|
Supported section types are:
|
|
@@ -32203,7 +32223,7 @@ const sectionCommandParser = {
|
|
|
32203
32223
|
*/
|
|
32204
32224
|
$applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
32205
32225
|
if ($taskJson.isSectionTypeSet === true) {
|
|
32206
|
-
throw new ParseError(spaceTrim$
|
|
32226
|
+
throw new ParseError(spaceTrim$1(`
|
|
32207
32227
|
Section type is already defined in the section.
|
|
32208
32228
|
It can be defined only once.
|
|
32209
32229
|
`));
|
|
@@ -32483,7 +32503,7 @@ const expectCommandParser = {
|
|
|
32483
32503
|
/**
|
|
32484
32504
|
* Description of the FORMAT command
|
|
32485
32505
|
*/
|
|
32486
|
-
description: spaceTrim$
|
|
32506
|
+
description: spaceTrim$1(`
|
|
32487
32507
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
32488
32508
|
It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
32489
32509
|
`),
|
|
@@ -32557,7 +32577,7 @@ const expectCommandParser = {
|
|
|
32557
32577
|
}
|
|
32558
32578
|
catch (error) {
|
|
32559
32579
|
assertsError(error);
|
|
32560
|
-
throw new ParseError(spaceTrim$
|
|
32580
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
32561
32581
|
Invalid FORMAT command
|
|
32562
32582
|
${block(error.message)}:
|
|
32563
32583
|
`));
|
|
@@ -32669,7 +32689,7 @@ function validateParameterName(parameterName) {
|
|
|
32669
32689
|
if (!(error instanceof ParseError)) {
|
|
32670
32690
|
throw error;
|
|
32671
32691
|
}
|
|
32672
|
-
throw new ParseError(spaceTrim$
|
|
32692
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
32673
32693
|
${block(error.message)}
|
|
32674
32694
|
|
|
32675
32695
|
Tried to validate parameter name:
|
|
@@ -32728,7 +32748,7 @@ const foreachCommandParser = {
|
|
|
32728
32748
|
const assignSign = args[3];
|
|
32729
32749
|
const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
|
|
32730
32750
|
if (formatDefinition === undefined) {
|
|
32731
|
-
throw new ParseError(spaceTrim$
|
|
32751
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
32732
32752
|
Unsupported format "${formatName}"
|
|
32733
32753
|
|
|
32734
32754
|
Available formats:
|
|
@@ -32740,7 +32760,7 @@ const foreachCommandParser = {
|
|
|
32740
32760
|
}
|
|
32741
32761
|
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
32742
32762
|
if (subvalueParser === undefined) {
|
|
32743
|
-
throw new ParseError(spaceTrim$
|
|
32763
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
32744
32764
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
32745
32765
|
|
|
32746
32766
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -32788,7 +32808,7 @@ const foreachCommandParser = {
|
|
|
32788
32808
|
outputSubparameterName = 'newLine';
|
|
32789
32809
|
}
|
|
32790
32810
|
else {
|
|
32791
|
-
throw new ParseError(spaceTrim$
|
|
32811
|
+
throw new ParseError(spaceTrim$1(`
|
|
32792
32812
|
FOREACH ${formatName} ${subformatName} must specify output subparameter
|
|
32793
32813
|
|
|
32794
32814
|
Correct example:
|
|
@@ -32864,7 +32884,7 @@ const formatCommandParser = {
|
|
|
32864
32884
|
/**
|
|
32865
32885
|
* Description of the FORMAT command
|
|
32866
32886
|
*/
|
|
32867
|
-
description: spaceTrim$
|
|
32887
|
+
description: spaceTrim$1(`
|
|
32868
32888
|
Format command describes the desired output of the task (after post-processing)
|
|
32869
32889
|
It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
32870
32890
|
`),
|
|
@@ -33236,7 +33256,7 @@ const formfactorCommandParser = {
|
|
|
33236
33256
|
const formfactorNameCandidate = args[0].toUpperCase();
|
|
33237
33257
|
const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
|
|
33238
33258
|
if (formfactor === undefined) {
|
|
33239
|
-
throw new ParseError(spaceTrim$
|
|
33259
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
33240
33260
|
Unknown formfactor name "${formfactorNameCandidate}"
|
|
33241
33261
|
|
|
33242
33262
|
Available formfactors:
|
|
@@ -33255,7 +33275,7 @@ const formfactorCommandParser = {
|
|
|
33255
33275
|
*/
|
|
33256
33276
|
$applyToPipelineJson(command, $pipelineJson) {
|
|
33257
33277
|
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
33258
|
-
throw new ParseError(spaceTrim$
|
|
33278
|
+
throw new ParseError(spaceTrim$1(`
|
|
33259
33279
|
Redefinition of \`FORMFACTOR\` in the pipeline head
|
|
33260
33280
|
|
|
33261
33281
|
You have used:
|
|
@@ -33403,7 +33423,7 @@ const modelCommandParser = {
|
|
|
33403
33423
|
*/
|
|
33404
33424
|
parse(input) {
|
|
33405
33425
|
const { args, normalized } = input;
|
|
33406
|
-
const availableVariantsMessage = spaceTrim$
|
|
33426
|
+
const availableVariantsMessage = spaceTrim$1((block) => `
|
|
33407
33427
|
Available variants are:
|
|
33408
33428
|
${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
|
|
33409
33429
|
`);
|
|
@@ -33425,14 +33445,14 @@ const modelCommandParser = {
|
|
|
33425
33445
|
// <- Note: [🤖]
|
|
33426
33446
|
}
|
|
33427
33447
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
33428
|
-
spaceTrim$
|
|
33448
|
+
spaceTrim$1((block) => `
|
|
33429
33449
|
Embedding model can not be used in pipeline
|
|
33430
33450
|
|
|
33431
33451
|
${block(availableVariantsMessage)}
|
|
33432
33452
|
`);
|
|
33433
33453
|
}
|
|
33434
33454
|
else {
|
|
33435
|
-
throw new ParseError(spaceTrim$
|
|
33455
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
33436
33456
|
Unknown model variant in command:
|
|
33437
33457
|
|
|
33438
33458
|
${block(availableVariantsMessage)}
|
|
@@ -33447,7 +33467,7 @@ const modelCommandParser = {
|
|
|
33447
33467
|
};
|
|
33448
33468
|
}
|
|
33449
33469
|
else {
|
|
33450
|
-
throw new ParseError(spaceTrim$
|
|
33470
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
33451
33471
|
Unknown model key in command.
|
|
33452
33472
|
|
|
33453
33473
|
Supported model keys are:
|
|
@@ -33474,7 +33494,7 @@ const modelCommandParser = {
|
|
|
33474
33494
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
33475
33495
|
}
|
|
33476
33496
|
else {
|
|
33477
|
-
throw new ParseError(spaceTrim$
|
|
33497
|
+
throw new ParseError(spaceTrim$1(`
|
|
33478
33498
|
Redefinition of \`MODEL ${command.key}\` in the pipeline head
|
|
33479
33499
|
|
|
33480
33500
|
You have used:
|
|
@@ -33502,7 +33522,7 @@ const modelCommandParser = {
|
|
|
33502
33522
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
33503
33523
|
}
|
|
33504
33524
|
else {
|
|
33505
|
-
throw new ParseError(spaceTrim$
|
|
33525
|
+
throw new ParseError(spaceTrim$1(`
|
|
33506
33526
|
Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
|
|
33507
33527
|
|
|
33508
33528
|
You have used:
|
|
@@ -33512,7 +33532,7 @@ const modelCommandParser = {
|
|
|
33512
33532
|
}
|
|
33513
33533
|
}
|
|
33514
33534
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
33515
|
-
console.log(spaceTrim$
|
|
33535
|
+
console.log(spaceTrim$1(`
|
|
33516
33536
|
Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
|
|
33517
33537
|
|
|
33518
33538
|
In pipeline head:
|
|
@@ -33595,7 +33615,7 @@ const parameterCommandParser = {
|
|
|
33595
33615
|
// <- TODO: When [🥶] fixed, change to:
|
|
33596
33616
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
33597
33617
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
33598
|
-
throw new ParseError(spaceTrim$
|
|
33618
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
33599
33619
|
Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
|
|
33600
33620
|
|
|
33601
33621
|
The description:
|
|
@@ -33777,7 +33797,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
33777
33797
|
persona.description = personaDescription;
|
|
33778
33798
|
return;
|
|
33779
33799
|
}
|
|
33780
|
-
console.warn(spaceTrim$
|
|
33800
|
+
console.warn(spaceTrim$1(`
|
|
33781
33801
|
|
|
33782
33802
|
Persona "${personaName}" is defined multiple times with different description:
|
|
33783
33803
|
|
|
@@ -33788,7 +33808,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
33788
33808
|
${personaDescription}
|
|
33789
33809
|
|
|
33790
33810
|
`));
|
|
33791
|
-
persona.description += spaceTrim$
|
|
33811
|
+
persona.description += spaceTrim$1('\n\n' + personaDescription);
|
|
33792
33812
|
}
|
|
33793
33813
|
|
|
33794
33814
|
/**
|
|
@@ -34629,7 +34649,7 @@ function removeMarkdownComments(content) {
|
|
|
34629
34649
|
*/
|
|
34630
34650
|
function isFlatPipeline(pipelineString) {
|
|
34631
34651
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
34632
|
-
pipelineString = spaceTrim$
|
|
34652
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
34633
34653
|
const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
34634
34654
|
//const isLastLineReturnStatement = pipelineString.split(/\r?\n/).pop()!.split('`').join('').startsWith('->');
|
|
34635
34655
|
const isBacktickBlockUsed = pipelineString.includes('```');
|
|
@@ -34655,7 +34675,7 @@ function deflatePipeline(pipelineString) {
|
|
|
34655
34675
|
if (!isFlatPipeline(pipelineString)) {
|
|
34656
34676
|
return pipelineString;
|
|
34657
34677
|
}
|
|
34658
|
-
pipelineString = spaceTrim$
|
|
34678
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
34659
34679
|
const pipelineStringLines = pipelineString.split(/\r?\n/);
|
|
34660
34680
|
const potentialReturnStatement = pipelineStringLines.pop();
|
|
34661
34681
|
let returnStatement;
|
|
@@ -34668,19 +34688,19 @@ function deflatePipeline(pipelineString) {
|
|
|
34668
34688
|
returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
|
|
34669
34689
|
pipelineStringLines.push(potentialReturnStatement);
|
|
34670
34690
|
}
|
|
34671
|
-
const prompt = spaceTrim$
|
|
34691
|
+
const prompt = spaceTrim$1(pipelineStringLines.join('\n'));
|
|
34672
34692
|
let quotedPrompt;
|
|
34673
34693
|
if (prompt.split(/\r?\n/).length <= 1) {
|
|
34674
34694
|
quotedPrompt = `> ${prompt}`;
|
|
34675
34695
|
}
|
|
34676
34696
|
else {
|
|
34677
|
-
quotedPrompt = spaceTrim$
|
|
34697
|
+
quotedPrompt = spaceTrim$1((block) => `
|
|
34678
34698
|
\`\`\`
|
|
34679
34699
|
${block(prompt.split('`').join('\\`'))}
|
|
34680
34700
|
\`\`\`
|
|
34681
34701
|
`);
|
|
34682
34702
|
}
|
|
34683
|
-
pipelineString = validatePipelineString(spaceTrim$
|
|
34703
|
+
pipelineString = validatePipelineString(spaceTrim$1((block) => `
|
|
34684
34704
|
# ${DEFAULT_BOOK_TITLE}
|
|
34685
34705
|
|
|
34686
34706
|
## Prompt
|
|
@@ -34738,7 +34758,7 @@ function parseMarkdownSection(value) {
|
|
|
34738
34758
|
}
|
|
34739
34759
|
const title = lines[0].replace(/^#+\s*/, '');
|
|
34740
34760
|
const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
34741
|
-
const content = spaceTrim$
|
|
34761
|
+
const content = spaceTrim$1(lines.slice(1).join('\n'));
|
|
34742
34762
|
if (level < 1 || level > 6) {
|
|
34743
34763
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
34744
34764
|
}
|
|
@@ -34766,7 +34786,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
34766
34786
|
if (buffer.length === 0) {
|
|
34767
34787
|
return;
|
|
34768
34788
|
}
|
|
34769
|
-
let section = spaceTrim$
|
|
34789
|
+
let section = spaceTrim$1(buffer.join('\n'));
|
|
34770
34790
|
if (section === '') {
|
|
34771
34791
|
return;
|
|
34772
34792
|
}
|
|
@@ -34841,7 +34861,7 @@ function flattenMarkdown(markdown) {
|
|
|
34841
34861
|
flattenedMarkdown += `## ${title}` + `\n\n`;
|
|
34842
34862
|
flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
|
|
34843
34863
|
}
|
|
34844
|
-
return spaceTrim$
|
|
34864
|
+
return spaceTrim$1(flattenedMarkdown);
|
|
34845
34865
|
}
|
|
34846
34866
|
/**
|
|
34847
34867
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -35548,7 +35568,7 @@ async function createPipelineCollectionFromDirectory(rootPath, tools, options) {
|
|
|
35548
35568
|
catch (error) {
|
|
35549
35569
|
assertsError(error);
|
|
35550
35570
|
// TODO: [7] DRY
|
|
35551
|
-
const wrappedErrorMessage = spaceTrim$
|
|
35571
|
+
const wrappedErrorMessage = spaceTrim$1((block) => `
|
|
35552
35572
|
${error.name} in pipeline ${fileName.split('\\').join('/')}:
|
|
35553
35573
|
|
|
35554
35574
|
Original error message:
|
|
@@ -35583,7 +35603,7 @@ async function createPipelineCollectionFromDirectory(rootPath, tools, options) {
|
|
|
35583
35603
|
pipeline = { ...pipeline, pipelineUrl };
|
|
35584
35604
|
}
|
|
35585
35605
|
else if (!pipeline.pipelineUrl.startsWith(rootUrl)) {
|
|
35586
|
-
throw new PipelineUrlError(spaceTrim$
|
|
35606
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
35587
35607
|
Pipeline with URL ${pipeline.pipelineUrl} is not a child of the root URL ${rootUrl} 🍏
|
|
35588
35608
|
|
|
35589
35609
|
File:
|
|
@@ -35621,7 +35641,7 @@ async function createPipelineCollectionFromDirectory(rootPath, tools, options) {
|
|
|
35621
35641
|
}
|
|
35622
35642
|
else {
|
|
35623
35643
|
const existing = collection.get(pipeline.pipelineUrl);
|
|
35624
|
-
throw new PipelineUrlError(spaceTrim$
|
|
35644
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
35625
35645
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍏
|
|
35626
35646
|
|
|
35627
35647
|
Conflicting files:
|
|
@@ -35639,7 +35659,7 @@ async function createPipelineCollectionFromDirectory(rootPath, tools, options) {
|
|
|
35639
35659
|
catch (error) {
|
|
35640
35660
|
assertsError(error);
|
|
35641
35661
|
// TODO: [7] DRY
|
|
35642
|
-
const wrappedErrorMessage = spaceTrim$
|
|
35662
|
+
const wrappedErrorMessage = spaceTrim$1((block) => `
|
|
35643
35663
|
${error.name} in pipeline ${fileName.split('\\').join('/')}:
|
|
35644
35664
|
|
|
35645
35665
|
Original error message:
|
|
@@ -35815,7 +35835,7 @@ async function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
35815
35835
|
// console.log(`Strategy 3️⃣`);
|
|
35816
35836
|
const response = await fetch(pipelineSource);
|
|
35817
35837
|
if (response.status >= 300) {
|
|
35818
|
-
throw new NotFoundError(spaceTrim$
|
|
35838
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
35819
35839
|
Book not found on URL:
|
|
35820
35840
|
${block(pipelineSource)}
|
|
35821
35841
|
|
|
@@ -35825,7 +35845,7 @@ async function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
35825
35845
|
const pipelineString = await response.text();
|
|
35826
35846
|
// console.log({ pipelineString });
|
|
35827
35847
|
if (!isValidPipelineString(pipelineString)) {
|
|
35828
|
-
throw new NotFoundError(spaceTrim$
|
|
35848
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
35829
35849
|
Book not found on URL:
|
|
35830
35850
|
${block(pipelineSource)}
|
|
35831
35851
|
|
|
@@ -35847,7 +35867,7 @@ async function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
35847
35867
|
});
|
|
35848
35868
|
return pipelineJson;
|
|
35849
35869
|
} /* not else */
|
|
35850
|
-
throw new NotFoundError(spaceTrim$
|
|
35870
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
35851
35871
|
Book not found:
|
|
35852
35872
|
${block(pipelineSource)}
|
|
35853
35873
|
|
|
@@ -36029,7 +36049,7 @@ function validateBook(source) {
|
|
|
36029
36049
|
* @deprecated Use `$generateBookBoilerplate` instead
|
|
36030
36050
|
* @public exported from `@promptbook/core`
|
|
36031
36051
|
*/
|
|
36032
|
-
padBook(validateBook(spaceTrim$
|
|
36052
|
+
padBook(validateBook(spaceTrim$1(`
|
|
36033
36053
|
AI Avatar
|
|
36034
36054
|
|
|
36035
36055
|
PERSONA A friendly AI assistant that helps you with your tasks
|
|
@@ -36056,7 +36076,7 @@ function book(strings, ...values) {
|
|
|
36056
36076
|
const bookString = prompt(strings, ...values).toString();
|
|
36057
36077
|
if (!isValidPipelineString(bookString)) {
|
|
36058
36078
|
// TODO: Make the CustomError for this
|
|
36059
|
-
throw new Error(spaceTrim$
|
|
36079
|
+
throw new Error(spaceTrim$1(`
|
|
36060
36080
|
The string is not a valid pipeline string
|
|
36061
36081
|
|
|
36062
36082
|
book\`
|
|
@@ -36066,7 +36086,7 @@ function book(strings, ...values) {
|
|
|
36066
36086
|
}
|
|
36067
36087
|
if (!isValidBook(bookString)) {
|
|
36068
36088
|
// TODO: Make the CustomError for this
|
|
36069
|
-
throw new Error(spaceTrim$
|
|
36089
|
+
throw new Error(spaceTrim$1(`
|
|
36070
36090
|
The string is not a valid book
|
|
36071
36091
|
|
|
36072
36092
|
book\`
|
|
@@ -36992,7 +37012,7 @@ function promptbookifyAiText(text) {
|
|
|
36992
37012
|
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
36993
37013
|
*/
|
|
36994
37014
|
|
|
36995
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5-
|
|
37015
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
|
|
36996
37016
|
/**
|
|
36997
37017
|
* Creates one structured log entry for streamed tool-call updates.
|
|
36998
37018
|
*
|
|
@@ -37487,7 +37507,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
37487
37507
|
}),
|
|
37488
37508
|
],
|
|
37489
37509
|
};
|
|
37490
|
-
const errorMessage = spaceTrim$
|
|
37510
|
+
const errorMessage = spaceTrim$1((block) => `
|
|
37491
37511
|
|
|
37492
37512
|
The invoked tool \`${functionName}\` failed with error:
|
|
37493
37513
|
|
|
@@ -38437,7 +38457,7 @@ class SelfLearningManager {
|
|
|
38437
38457
|
if (isJsonSchemaResponseFormat(responseFormat)) {
|
|
38438
38458
|
const jsonSchema = responseFormat.json_schema;
|
|
38439
38459
|
const schemaJson = JSON.stringify(jsonSchema, null, 4);
|
|
38440
|
-
userMessageContent = spaceTrim$
|
|
38460
|
+
userMessageContent = spaceTrim$1((block) => `
|
|
38441
38461
|
${block(prompt.content)}
|
|
38442
38462
|
|
|
38443
38463
|
NOTE Request was made through OpenAI Compatible API with \`response_format\` of type \`json_schema\` with the following schema:
|
|
@@ -38468,12 +38488,12 @@ class SelfLearningManager {
|
|
|
38468
38488
|
const formattedAgentMessage = formatAgentMessageForJsonMode(result.content, usesJsonSchemaMode);
|
|
38469
38489
|
const teacherInstructions = extractOpenTeacherInstructions(agentSource);
|
|
38470
38490
|
const teacherInstructionsSection = teacherInstructions
|
|
38471
|
-
? spaceTrim$
|
|
38491
|
+
? spaceTrim$1((block) => `
|
|
38472
38492
|
**Teacher instructions:**
|
|
38473
38493
|
${block(teacherInstructions)}
|
|
38474
38494
|
`)
|
|
38475
38495
|
: '';
|
|
38476
|
-
const teacherPromptContent = spaceTrim$
|
|
38496
|
+
const teacherPromptContent = spaceTrim$1((block) => `
|
|
38477
38497
|
|
|
38478
38498
|
You are a teacher agent helping another agent to learn from its interactions.
|
|
38479
38499
|
|
|
@@ -38506,7 +38526,7 @@ class SelfLearningManager {
|
|
|
38506
38526
|
? '- This interaction used JSON mode, so the agent answer should stay as a formatted JSON code block.'
|
|
38507
38527
|
: ''}
|
|
38508
38528
|
${block(isInitialMessageMissing
|
|
38509
|
-
? spaceTrim$
|
|
38529
|
+
? spaceTrim$1(`
|
|
38510
38530
|
- The agent source does not have an INITIAL MESSAGE defined, generate one.
|
|
38511
38531
|
- The INITIAL MESSAGE should be welcoming, informative about the agent capabilities and also should give some quick options to start the conversation with the agent.
|
|
38512
38532
|
- The quick option looks like \`[👋 Hello](?message=Hello, how are you?)\`
|
|
@@ -38549,7 +38569,7 @@ class SelfLearningManager {
|
|
|
38549
38569
|
*/
|
|
38550
38570
|
appendToAgentSource(section) {
|
|
38551
38571
|
const currentSource = this.options.getAgentSource();
|
|
38552
|
-
const newSource = padBook(validateBook(spaceTrim$
|
|
38572
|
+
const newSource = padBook(validateBook(spaceTrim$1(currentSource) + section));
|
|
38553
38573
|
this.options.updateAgentSource(newSource);
|
|
38554
38574
|
}
|
|
38555
38575
|
}
|
|
@@ -38577,13 +38597,13 @@ function formatAgentMessageForJsonMode(content, isJsonMode) {
|
|
|
38577
38597
|
}
|
|
38578
38598
|
const parsedJson = tryParseJson(content);
|
|
38579
38599
|
if (parsedJson === null) {
|
|
38580
|
-
return spaceTrim$
|
|
38600
|
+
return spaceTrim$1((block) => `
|
|
38581
38601
|
\`\`\`json
|
|
38582
38602
|
${block(content)}
|
|
38583
38603
|
\`\`\`
|
|
38584
38604
|
`);
|
|
38585
38605
|
}
|
|
38586
|
-
return spaceTrim$
|
|
38606
|
+
return spaceTrim$1((block) => `
|
|
38587
38607
|
\`\`\`json
|
|
38588
38608
|
${block(JSON.stringify(parsedJson, null, 4))}
|
|
38589
38609
|
\`\`\`
|
|
@@ -38615,7 +38635,7 @@ function formatSelfLearningSample(options) {
|
|
|
38615
38635
|
const internalMessagesSection = options.internalMessages
|
|
38616
38636
|
.map((internalMessage) => formatInternalLearningMessage(internalMessage))
|
|
38617
38637
|
.join('\n\n');
|
|
38618
|
-
return spaceTrim$
|
|
38638
|
+
return spaceTrim$1((block) => `
|
|
38619
38639
|
|
|
38620
38640
|
USER MESSAGE
|
|
38621
38641
|
${block(options.userMessageContent)}
|
|
@@ -38633,7 +38653,7 @@ function formatSelfLearningSample(options) {
|
|
|
38633
38653
|
* @private function of Agent
|
|
38634
38654
|
*/
|
|
38635
38655
|
function formatInternalLearningMessage(internalMessage) {
|
|
38636
|
-
return spaceTrim$
|
|
38656
|
+
return spaceTrim$1((block) => `
|
|
38637
38657
|
INTERNAL MESSAGE
|
|
38638
38658
|
${block(stringifyInternalLearningPayload(internalMessage))}
|
|
38639
38659
|
`);
|
|
@@ -39099,7 +39119,7 @@ function buildRemoteAgentSource(profile, meta) {
|
|
|
39099
39119
|
.filter((line) => Boolean(line))
|
|
39100
39120
|
.join('\n');
|
|
39101
39121
|
const personaBlock = profile.personaDescription
|
|
39102
|
-
? spaceTrim$
|
|
39122
|
+
? spaceTrim$1((block) => `
|
|
39103
39123
|
PERSONA
|
|
39104
39124
|
${block(profile.personaDescription || '')}
|
|
39105
39125
|
`)
|
|
@@ -39135,7 +39155,7 @@ class RemoteAgent extends Agent {
|
|
|
39135
39155
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
39136
39156
|
// <- TODO: [🐱🚀] Maybe use promptbookFetch
|
|
39137
39157
|
if (!profileResponse.ok) {
|
|
39138
|
-
throw new Error(spaceTrim$
|
|
39158
|
+
throw new Error(spaceTrim$1((block) => `
|
|
39139
39159
|
Failed to fetch remote agent profile:
|
|
39140
39160
|
|
|
39141
39161
|
Agent URL:
|