@promptbook/cli 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 +300 -268
- package/esm/index.es.js.map +1 -1
- package/{umd/src/cli/cli-commands/coder/find-fresh-emoji-tag.d.ts → esm/src/cli/cli-commands/coder/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 +1 -1
- package/umd/index.umd.js +516 -484
- package/umd/index.umd.js.map +1 -1
- package/{esm/src/cli/cli-commands/coder/find-fresh-emoji-tag.d.ts → umd/src/cli/cli-commands/coder/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/scripts/{find-fresh-emoji-tag/find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags/find-fresh-emoji-tags.d.ts} +0 -0
- /package/esm/scripts/{find-fresh-emoji-tag → find-fresh-emoji-tags}/utils/$shuffleItems.d.ts +0 -0
- /package/esm/scripts/{find-fresh-emoji-tag → find-fresh-emoji-tags}/utils/emojis.d.ts +0 -0
- /package/umd/scripts/{find-fresh-emoji-tag/find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags/find-fresh-emoji-tags.d.ts} +0 -0
- /package/umd/scripts/{find-fresh-emoji-tag → find-fresh-emoji-tags}/utils/$shuffleItems.d.ts +0 -0
- /package/umd/scripts/{find-fresh-emoji-tag → find-fresh-emoji-tags}/utils/emojis.d.ts +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('fs'), require('path'), require('waitasecond'), require('prompts'), require('fs/promises'), require('dotenv'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('socket.io-client'), require('crypto-js'), require('jszip'), require('crypto'), require('@mozilla/readability'), require('jsdom'), require('showdown'), require('glob-promise'), require('moment'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('swagger-ui-express'), require('react'), require('react-dom/server'), require('@anthropic-ai/sdk'), require('bottleneck'), require('@azure/openai'), require('typescript'), require('readline'), require('child_process'), require('pg'), require('@supabase/supabase-js'), require('path/posix'), require('rxjs'), require('mime-types'), require('papaparse'), require('@openai/agents'), require('openai')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'fs', 'path', 'waitasecond', 'prompts', 'fs/promises', 'dotenv', 'crypto-js/enc-hex', 'crypto-js/sha256', 'socket.io-client', 'crypto-js', 'jszip', 'crypto', '@mozilla/readability', 'jsdom', 'showdown', 'glob-promise', 'moment', 'express', 'express-openapi-validator', 'http', 'socket.io', 'swagger-ui-express', 'react', 'react-dom/server', '@anthropic-ai/sdk', 'bottleneck', '@azure/openai', 'typescript', 'readline', 'child_process', 'pg', '@supabase/supabase-js', 'path/posix', 'rxjs', 'mime-types', 'papaparse', '@openai/agents', 'openai'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.
|
|
5
|
-
})(this, (function (exports, colors, commander,
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global._spaceTrim, global.fs, global.path, global.waitasecond, global.prompts, global.promises, global.dotenv, global.hexEncoder, global.sha256, global.socket_ioClient, global.cryptoJs, global.JSZip, global.crypto, global.readability, global.jsdom, global.showdown, global.glob, global.moment, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.react, global.server, global.Anthropic, global.Bottleneck, global.openai, global.ts, global.readline, global.child_process, global.pg, null, global.posix, global.rxjs, global.mimeTypes, global.papaparse, global.agents, global.OpenAI));
|
|
5
|
+
})(this, (function (exports, colors, commander, _spaceTrim, fs, path, waitasecond, prompts, promises, dotenv, hexEncoder, sha256, socket_ioClient, cryptoJs, JSZip, crypto, readability, jsdom, showdown, glob, moment, express, OpenApiValidator, http, socket_io, swaggerUi, react, server, Anthropic, Bottleneck, openai, ts, readline, child_process, pg, supabaseJs, posix, rxjs, mimeTypes, papaparse, agents, OpenAI) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
28
28
|
var commander__default = /*#__PURE__*/_interopDefaultLegacy(commander);
|
|
29
|
-
var
|
|
29
|
+
var _spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(_spaceTrim);
|
|
30
30
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
31
31
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
32
32
|
var prompts__default = /*#__PURE__*/_interopDefaultLegacy(prompts);
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
* @generated
|
|
61
61
|
* @see https://github.com/webgptorg/promptbook
|
|
62
62
|
*/
|
|
63
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
63
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-16';
|
|
64
64
|
/**
|
|
65
65
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
66
66
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
* @public exported from `@promptbook/utils`
|
|
76
76
|
* @see https://github.com/hejny/spacetrim#usage
|
|
77
77
|
*/
|
|
78
|
-
const spaceTrim =
|
|
78
|
+
const spaceTrim = _spaceTrim.spaceTrim;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Just marks a place of place where should be something implemented
|
|
@@ -1428,7 +1428,7 @@
|
|
|
1428
1428
|
function getErrorReportUrl(error) {
|
|
1429
1429
|
const report = {
|
|
1430
1430
|
title: `🐜 Error report from ${NAME}`,
|
|
1431
|
-
body:
|
|
1431
|
+
body: _spaceTrim.spaceTrim((block) => `
|
|
1432
1432
|
|
|
1433
1433
|
|
|
1434
1434
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1471,7 +1471,7 @@
|
|
|
1471
1471
|
*/
|
|
1472
1472
|
class UnexpectedError extends Error {
|
|
1473
1473
|
constructor(message) {
|
|
1474
|
-
super(
|
|
1474
|
+
super(_spaceTrim.spaceTrim((block) => `
|
|
1475
1475
|
${block(message)}
|
|
1476
1476
|
|
|
1477
1477
|
Note: This error should not happen.
|
|
@@ -1497,7 +1497,7 @@
|
|
|
1497
1497
|
constructor(whatWasThrown) {
|
|
1498
1498
|
const tag = `[🤮]`;
|
|
1499
1499
|
console.error(tag, whatWasThrown);
|
|
1500
|
-
super(
|
|
1500
|
+
super(_spaceTrim.spaceTrim(`
|
|
1501
1501
|
Non-Error object was thrown
|
|
1502
1502
|
|
|
1503
1503
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1567,7 +1567,7 @@
|
|
|
1567
1567
|
*/
|
|
1568
1568
|
function $initializeAboutCommand(program) {
|
|
1569
1569
|
const makeCommand = program.command('about');
|
|
1570
|
-
makeCommand.description(
|
|
1570
|
+
makeCommand.description(_spaceTrim.spaceTrim(`
|
|
1571
1571
|
Tells about Promptbook CLI and its abilities
|
|
1572
1572
|
`));
|
|
1573
1573
|
makeCommand.action(handleActionErrors(async () => {
|
|
@@ -1607,15 +1607,15 @@
|
|
|
1607
1607
|
*/
|
|
1608
1608
|
|
|
1609
1609
|
/**
|
|
1610
|
-
* Initializes `coder find-fresh-emoji-
|
|
1610
|
+
* Initializes `coder find-fresh-emoji-tags` command for Promptbook CLI utilities
|
|
1611
1611
|
*
|
|
1612
1612
|
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI
|
|
1613
1613
|
*
|
|
1614
1614
|
* @private internal function of `promptbookCli`
|
|
1615
1615
|
*/
|
|
1616
1616
|
function $initializeCoderFindFreshEmojiTagCommand(program) {
|
|
1617
|
-
const command = program.command('find-fresh-emoji-
|
|
1618
|
-
command.description(
|
|
1617
|
+
const command = program.command('find-fresh-emoji-tags');
|
|
1618
|
+
command.description(_spaceTrim__default["default"](`
|
|
1619
1619
|
Find unused emoji tags in the codebase
|
|
1620
1620
|
|
|
1621
1621
|
Scans entire codebase for emoji tags already in use (format: [emoji])
|
|
@@ -1624,7 +1624,7 @@
|
|
|
1624
1624
|
`));
|
|
1625
1625
|
command.action(handleActionErrors(async () => {
|
|
1626
1626
|
// Note: Import the function dynamically to avoid loading heavy dependencies until needed
|
|
1627
|
-
const { findFreshEmojiTag } = await Promise.resolve().then(function () { return
|
|
1627
|
+
const { findFreshEmojiTag } = await Promise.resolve().then(function () { return findFreshEmojiTags; });
|
|
1628
1628
|
try {
|
|
1629
1629
|
await findFreshEmojiTag();
|
|
1630
1630
|
}
|
|
@@ -1649,7 +1649,7 @@
|
|
|
1649
1649
|
*/
|
|
1650
1650
|
function $initializeCoderFindRefactorCandidatesCommand(program) {
|
|
1651
1651
|
const command = program.command('find-refactor-candidates');
|
|
1652
|
-
command.description(
|
|
1652
|
+
command.description(_spaceTrim.spaceTrim(`
|
|
1653
1653
|
Scan source files to identify refactoring candidates
|
|
1654
1654
|
|
|
1655
1655
|
Flags files that exceed:
|
|
@@ -1687,7 +1687,7 @@
|
|
|
1687
1687
|
*/
|
|
1688
1688
|
function $initializeCoderGenerateBoilerplatesCommand(program) {
|
|
1689
1689
|
const command = program.command('generate-boilerplates');
|
|
1690
|
-
command.description(
|
|
1690
|
+
command.description(_spaceTrim.spaceTrim(`
|
|
1691
1691
|
Generate prompt boilerplate files with unique emoji tags
|
|
1692
1692
|
`));
|
|
1693
1693
|
command.option('--count <count>', `Number of prompt boilerplate files to generate`, '5');
|
|
@@ -1736,7 +1736,7 @@
|
|
|
1736
1736
|
const filename = buildPromptFilename(promptNumbering.datePrefix, number, buildPromptSlug$1(template, title));
|
|
1737
1737
|
const filepath = path.join('prompts', filename);
|
|
1738
1738
|
const emojiTag = formatPromptEmojiTag(emoji);
|
|
1739
|
-
const one =
|
|
1739
|
+
const one = _spaceTrim.spaceTrim((block) => `
|
|
1740
1740
|
|
|
1741
1741
|
[-]
|
|
1742
1742
|
|
|
@@ -1744,7 +1744,7 @@
|
|
|
1744
1744
|
|
|
1745
1745
|
${block(promptTemplateContent)}
|
|
1746
1746
|
`);
|
|
1747
|
-
const content =
|
|
1747
|
+
const content = _spaceTrim.spaceTrim((block) => `
|
|
1748
1748
|
|
|
1749
1749
|
${block(one)}
|
|
1750
1750
|
|
|
@@ -1839,7 +1839,7 @@
|
|
|
1839
1839
|
*/
|
|
1840
1840
|
function $initializeCoderRunCommand(program) {
|
|
1841
1841
|
const command = program.command('run');
|
|
1842
|
-
command.description(
|
|
1842
|
+
command.description(_spaceTrim.spaceTrim(`
|
|
1843
1843
|
Execute coding prompts through selected AI agent
|
|
1844
1844
|
|
|
1845
1845
|
Runners:
|
|
@@ -1857,7 +1857,7 @@
|
|
|
1857
1857
|
`));
|
|
1858
1858
|
command.option('--dry-run', 'Print unwritten prompts without executing', false);
|
|
1859
1859
|
command.option('--agent <agent-name>', 'Select runner: openai-codex, cline, claude-code, opencode, gemini (required for non-dry-run)');
|
|
1860
|
-
command.option('--model <model>',
|
|
1860
|
+
command.option('--model <model>', _spaceTrim.spaceTrim(`
|
|
1861
1861
|
Model to use (required for openai-codex and gemini)
|
|
1862
1862
|
|
|
1863
1863
|
OpenAI examples: gpt-5.2-codex, default
|
|
@@ -1945,7 +1945,7 @@
|
|
|
1945
1945
|
*/
|
|
1946
1946
|
function $initializeCoderVerifyCommand(program) {
|
|
1947
1947
|
const command = program.command('verify');
|
|
1948
|
-
command.description(
|
|
1948
|
+
command.description(_spaceTrim.spaceTrim(`
|
|
1949
1949
|
Interactive verification helper for completed prompts
|
|
1950
1950
|
|
|
1951
1951
|
Features:
|
|
@@ -1983,7 +1983,7 @@
|
|
|
1983
1983
|
* - find-refactor-candidates: Find files that need refactoring
|
|
1984
1984
|
* - run: Run coding prompts with AI agents
|
|
1985
1985
|
* - verify: Verify completed prompts
|
|
1986
|
-
* - find-fresh-emoji-
|
|
1986
|
+
* - find-fresh-emoji-tags: Find unused emoji tags
|
|
1987
1987
|
*
|
|
1988
1988
|
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI
|
|
1989
1989
|
*
|
|
@@ -1991,7 +1991,7 @@
|
|
|
1991
1991
|
*/
|
|
1992
1992
|
function $initializeCoderCommand(program) {
|
|
1993
1993
|
const coderCommand = program.command('coder');
|
|
1994
|
-
coderCommand.description(
|
|
1994
|
+
coderCommand.description(_spaceTrim.spaceTrim(`
|
|
1995
1995
|
Coding utilities for automated development workflows
|
|
1996
1996
|
|
|
1997
1997
|
Subcommands:
|
|
@@ -1999,7 +1999,7 @@
|
|
|
1999
1999
|
- find-refactor-candidates: Find files that need refactoring
|
|
2000
2000
|
- run: Run coding prompts with AI agents
|
|
2001
2001
|
- verify: Verify completed prompts
|
|
2002
|
-
- find-fresh-emoji-
|
|
2002
|
+
- find-fresh-emoji-tags: Find unused emoji tags
|
|
2003
2003
|
`));
|
|
2004
2004
|
// Register all subcommands
|
|
2005
2005
|
$initializeCoderGenerateBoilerplatesCommand(coderCommand);
|
|
@@ -2028,7 +2028,7 @@
|
|
|
2028
2028
|
*/
|
|
2029
2029
|
function $initializeHelloCommand(program) {
|
|
2030
2030
|
const helloCommand = program.command('hello');
|
|
2031
|
-
helloCommand.description(
|
|
2031
|
+
helloCommand.description(_spaceTrim.spaceTrim(`
|
|
2032
2032
|
Just command for testing
|
|
2033
2033
|
`));
|
|
2034
2034
|
helloCommand.alias('hi');
|
|
@@ -2055,7 +2055,7 @@
|
|
|
2055
2055
|
*/
|
|
2056
2056
|
class NotYetImplementedError extends Error {
|
|
2057
2057
|
constructor(message) {
|
|
2058
|
-
super(
|
|
2058
|
+
super(_spaceTrim.spaceTrim((block) => `
|
|
2059
2059
|
${block(message)}
|
|
2060
2060
|
|
|
2061
2061
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -2290,13 +2290,13 @@
|
|
|
2290
2290
|
});
|
|
2291
2291
|
const usedEnvMessage = $usedEnvFilename === null ? `Unknown \`.env\` file` : `Used \`.env\` file:\n${$usedEnvFilename}`;
|
|
2292
2292
|
if (metadata.length === 0) {
|
|
2293
|
-
return
|
|
2293
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
2294
2294
|
No LLM providers are available.
|
|
2295
2295
|
|
|
2296
2296
|
${block(usedEnvMessage)}
|
|
2297
2297
|
`);
|
|
2298
2298
|
}
|
|
2299
|
-
return
|
|
2299
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
2300
2300
|
|
|
2301
2301
|
${block(usedEnvMessage)}
|
|
2302
2302
|
|
|
@@ -2342,7 +2342,7 @@
|
|
|
2342
2342
|
morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
|
|
2343
2343
|
}
|
|
2344
2344
|
}
|
|
2345
|
-
let providerMessage =
|
|
2345
|
+
let providerMessage = _spaceTrim.spaceTrim(`
|
|
2346
2346
|
${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
|
|
2347
2347
|
${morePieces.join('; ')}
|
|
2348
2348
|
`);
|
|
@@ -2408,7 +2408,7 @@
|
|
|
2408
2408
|
}
|
|
2409
2409
|
else if (typeof value !== 'string') {
|
|
2410
2410
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
2411
|
-
throw new Error(
|
|
2411
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
2412
2412
|
Can not parse JSON from non-string value.
|
|
2413
2413
|
|
|
2414
2414
|
The value type: ${typeof value}
|
|
@@ -2422,7 +2422,7 @@
|
|
|
2422
2422
|
if (!(error instanceof Error)) {
|
|
2423
2423
|
throw error;
|
|
2424
2424
|
}
|
|
2425
|
-
throw new Error(
|
|
2425
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
2426
2426
|
${block(error.message)}
|
|
2427
2427
|
|
|
2428
2428
|
The expected JSON text:
|
|
@@ -2644,7 +2644,7 @@
|
|
|
2644
2644
|
.filter((line) => !line.startsWith(`# ${GENERATOR_WARNING_IN_ENV}`)) // Remove GENERATOR_WARNING_IN_ENV
|
|
2645
2645
|
.filter((line) => !line.startsWith(`${transformedKey}=`)) // Remove existing key if present
|
|
2646
2646
|
.join('\n');
|
|
2647
|
-
const newEnvContent =
|
|
2647
|
+
const newEnvContent = _spaceTrim.spaceTrim((block) => `
|
|
2648
2648
|
${block(updatedEnvContent)}
|
|
2649
2649
|
|
|
2650
2650
|
# ${GENERATOR_WARNING_IN_ENV}
|
|
@@ -2755,7 +2755,7 @@
|
|
|
2755
2755
|
}
|
|
2756
2756
|
else if (typeof value === 'object') {
|
|
2757
2757
|
if (value instanceof Date) {
|
|
2758
|
-
throw new UnexpectedError(
|
|
2758
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
2759
2759
|
\`${name}\` is Date
|
|
2760
2760
|
|
|
2761
2761
|
Use \`string_date_iso8601\` instead
|
|
@@ -2774,7 +2774,7 @@
|
|
|
2774
2774
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2775
2775
|
}
|
|
2776
2776
|
else if (value instanceof Error) {
|
|
2777
|
-
throw new UnexpectedError(
|
|
2777
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
2778
2778
|
\`${name}\` is unserialized Error
|
|
2779
2779
|
|
|
2780
2780
|
Use function \`serializeError\`
|
|
@@ -2797,7 +2797,7 @@
|
|
|
2797
2797
|
}
|
|
2798
2798
|
catch (error) {
|
|
2799
2799
|
assertsError(error);
|
|
2800
|
-
throw new UnexpectedError(
|
|
2800
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
2801
2801
|
\`${name}\` is not serializable
|
|
2802
2802
|
|
|
2803
2803
|
${block(error.stack || error.message)}
|
|
@@ -2829,7 +2829,7 @@
|
|
|
2829
2829
|
}
|
|
2830
2830
|
}
|
|
2831
2831
|
else {
|
|
2832
|
-
throw new UnexpectedError(
|
|
2832
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
2833
2833
|
\`${name}\` is unknown type
|
|
2834
2834
|
|
|
2835
2835
|
Additional message for \`${name}\`:
|
|
@@ -3093,7 +3093,7 @@
|
|
|
3093
3093
|
*/
|
|
3094
3094
|
function stringifyPipelineJson(pipeline) {
|
|
3095
3095
|
if (!isSerializableAsJson(pipeline)) {
|
|
3096
|
-
throw new UnexpectedError(
|
|
3096
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim(`
|
|
3097
3097
|
Cannot stringify the pipeline, because it is not serializable as JSON
|
|
3098
3098
|
|
|
3099
3099
|
There can be multiple reasons:
|
|
@@ -3800,7 +3800,7 @@
|
|
|
3800
3800
|
*/
|
|
3801
3801
|
class MissingToolsError extends Error {
|
|
3802
3802
|
constructor(message) {
|
|
3803
|
-
super(
|
|
3803
|
+
super(_spaceTrim.spaceTrim((block) => `
|
|
3804
3804
|
${block(message)}
|
|
3805
3805
|
|
|
3806
3806
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -4007,7 +4007,7 @@
|
|
|
4007
4007
|
message = `${name}: ${message}`;
|
|
4008
4008
|
}
|
|
4009
4009
|
if (isStackAddedToMessage && stack !== undefined && stack !== '') {
|
|
4010
|
-
message =
|
|
4010
|
+
message = _spaceTrim.spaceTrim((block) => `
|
|
4011
4011
|
${block(message)}
|
|
4012
4012
|
|
|
4013
4013
|
Original stack trace:
|
|
@@ -4034,7 +4034,7 @@
|
|
|
4034
4034
|
const remoteServerUrlParsed = new URL(remoteServerUrl);
|
|
4035
4035
|
if (remoteServerUrlParsed.pathname !== '/' && remoteServerUrlParsed.pathname !== '') {
|
|
4036
4036
|
remoteServerUrlParsed.pathname = '/';
|
|
4037
|
-
throw new Error(
|
|
4037
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
4038
4038
|
Remote server requires root url \`/\`
|
|
4039
4039
|
|
|
4040
4040
|
You have provided \`remoteServerUrl\`:
|
|
@@ -4309,7 +4309,7 @@
|
|
|
4309
4309
|
.filter(([MERMAID_NAME]) => (inputAndIntermediateParametersMermaid + outputParametersMermaid).includes(MERMAID_NAME))
|
|
4310
4310
|
.map(([MERMAID_NAME, title]) => `${MERMAID_NAME}((${title})):::${MERMAID_NAME}`)
|
|
4311
4311
|
.join('\n');
|
|
4312
|
-
const promptbookMermaid =
|
|
4312
|
+
const promptbookMermaid = _spaceTrim.spaceTrim((block) => `
|
|
4313
4313
|
|
|
4314
4314
|
%% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
|
|
4315
4315
|
|
|
@@ -4360,7 +4360,7 @@
|
|
|
4360
4360
|
const { name, message, stack } = error;
|
|
4361
4361
|
const { id } = error;
|
|
4362
4362
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
4363
|
-
console.error(
|
|
4363
|
+
console.error(_spaceTrim.spaceTrim((block) => `
|
|
4364
4364
|
|
|
4365
4365
|
Cannot serialize error with name "${name}"
|
|
4366
4366
|
|
|
@@ -4885,7 +4885,7 @@
|
|
|
4885
4885
|
const entries = items
|
|
4886
4886
|
.flatMap((item) => formatParameterListItem(item).split(/\r?\n/))
|
|
4887
4887
|
.filter((line) => line !== '');
|
|
4888
|
-
return
|
|
4888
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
4889
4889
|
**Parameters:**
|
|
4890
4890
|
${block(entries.join('\n'))}
|
|
4891
4891
|
|
|
@@ -4958,7 +4958,7 @@
|
|
|
4958
4958
|
*/
|
|
4959
4959
|
function prompt(strings, ...values) {
|
|
4960
4960
|
if (values.length === 0) {
|
|
4961
|
-
return new PromptString(
|
|
4961
|
+
return new PromptString(_spaceTrim.spaceTrim(strings.join('')));
|
|
4962
4962
|
}
|
|
4963
4963
|
const stringsWithHiddenParameters = strings.map((stringsItem) => ParameterEscaping.hideBrackets(stringsItem));
|
|
4964
4964
|
const parameterMetadata = values.map((value) => {
|
|
@@ -4999,7 +4999,7 @@
|
|
|
4999
4999
|
? `${result}${stringsItem}`
|
|
5000
5000
|
: `${result}${stringsItem}${ParameterSection.formatParameterPlaceholder(parameterName)}`;
|
|
5001
5001
|
}, '');
|
|
5002
|
-
pipelineString =
|
|
5002
|
+
pipelineString = _spaceTrim.spaceTrim(pipelineString);
|
|
5003
5003
|
try {
|
|
5004
5004
|
pipelineString = templateParameters(pipelineString, parameters);
|
|
5005
5005
|
}
|
|
@@ -5008,7 +5008,7 @@
|
|
|
5008
5008
|
throw error;
|
|
5009
5009
|
}
|
|
5010
5010
|
console.error({ pipelineString, parameters, parameterNames: parameterNamesOrdered, error });
|
|
5011
|
-
throw new UnexpectedError(
|
|
5011
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
5012
5012
|
Internal error in prompt template literal
|
|
5013
5013
|
|
|
5014
5014
|
${block(JSON.stringify({ strings, values }, null, 4))}}
|
|
@@ -5231,7 +5231,7 @@
|
|
|
5231
5231
|
* @public exported from `@promptbook/utils`
|
|
5232
5232
|
*/
|
|
5233
5233
|
function computeHash(value) {
|
|
5234
|
-
return cryptoJs.SHA256(hexEncoder__default["default"].parse(
|
|
5234
|
+
return cryptoJs.SHA256(hexEncoder__default["default"].parse(_spaceTrim.spaceTrim(valueToString(value)))).toString( /* hex */);
|
|
5235
5235
|
}
|
|
5236
5236
|
/**
|
|
5237
5237
|
* TODO: [🥬][🥬] Use this ACRY
|
|
@@ -6831,7 +6831,7 @@
|
|
|
6831
6831
|
* @public exported from `@promptbook/utils`
|
|
6832
6832
|
*/
|
|
6833
6833
|
function normalizeMessageText(text) {
|
|
6834
|
-
return
|
|
6834
|
+
return _spaceTrim.spaceTrim(text);
|
|
6835
6835
|
}
|
|
6836
6836
|
|
|
6837
6837
|
/**
|
|
@@ -6913,7 +6913,7 @@
|
|
|
6913
6913
|
let trimmedText = text;
|
|
6914
6914
|
// Remove leading and trailing spaces and newlines
|
|
6915
6915
|
if (isTrimmed) {
|
|
6916
|
-
trimmedText =
|
|
6916
|
+
trimmedText = _spaceTrim.spaceTrim(trimmedText);
|
|
6917
6917
|
}
|
|
6918
6918
|
let processedText = trimmedText;
|
|
6919
6919
|
// Check for markdown code block
|
|
@@ -6932,7 +6932,7 @@
|
|
|
6932
6932
|
// Remove the introduce sentence and quotes by replacing it with an empty string
|
|
6933
6933
|
processedText = processedText.replace(introduceSentenceRegex, '');
|
|
6934
6934
|
}
|
|
6935
|
-
processedText =
|
|
6935
|
+
processedText = _spaceTrim.spaceTrim(processedText);
|
|
6936
6936
|
// Check again for code block after removing introduce sentence
|
|
6937
6937
|
const codeBlockMatch2 = processedText.match(codeBlockRegex);
|
|
6938
6938
|
if (codeBlockMatch2 && codeBlockMatch2[1] !== undefined) {
|
|
@@ -7412,7 +7412,7 @@
|
|
|
7412
7412
|
}
|
|
7413
7413
|
catch (error) {
|
|
7414
7414
|
keepUnused(error);
|
|
7415
|
-
throw new ExpectError(
|
|
7415
|
+
throw new ExpectError(_spaceTrim.spaceTrim((block) => `
|
|
7416
7416
|
Expected valid JSON string
|
|
7417
7417
|
|
|
7418
7418
|
The expected JSON text:
|
|
@@ -7517,7 +7517,7 @@
|
|
|
7517
7517
|
let normalizedContent = content;
|
|
7518
7518
|
normalizedContent = normalizedContent.replace(/\s+/g, ' ');
|
|
7519
7519
|
normalizedContent = normalizedContent.split('\r\n').join('\n');
|
|
7520
|
-
normalizedContent =
|
|
7520
|
+
normalizedContent = _spaceTrim.spaceTrim(normalizedContent);
|
|
7521
7521
|
// Note: Do not need to save everything in the cache, just the relevant parameters
|
|
7522
7522
|
const relevantParameterNames = extractParameterNames(content);
|
|
7523
7523
|
const relevantParameters = Object.fromEntries(Object.entries(parameters).filter(([key]) => relevantParameterNames.has(key)));
|
|
@@ -7987,14 +7987,14 @@
|
|
|
7987
7987
|
if (description === undefined) {
|
|
7988
7988
|
return headLine;
|
|
7989
7989
|
}
|
|
7990
|
-
return
|
|
7990
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
7991
7991
|
${headLine}
|
|
7992
7992
|
|
|
7993
7993
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
7994
7994
|
`);
|
|
7995
7995
|
})
|
|
7996
7996
|
.join('\n\n');
|
|
7997
|
-
return
|
|
7997
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
7998
7998
|
Multiple LLM Providers:
|
|
7999
7999
|
|
|
8000
8000
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -8096,7 +8096,7 @@
|
|
|
8096
8096
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
8097
8097
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
8098
8098
|
// 3) ...
|
|
8099
|
-
|
|
8099
|
+
_spaceTrim.spaceTrim((block) => `
|
|
8100
8100
|
All execution tools of ${this.title} failed:
|
|
8101
8101
|
|
|
8102
8102
|
${block(errors
|
|
@@ -8109,7 +8109,7 @@
|
|
|
8109
8109
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
8110
8110
|
}
|
|
8111
8111
|
else {
|
|
8112
|
-
throw new PipelineExecutionError(
|
|
8112
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
8113
8113
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
8114
8114
|
|
|
8115
8115
|
Available \`LlmExecutionTools\`:
|
|
@@ -8146,7 +8146,7 @@
|
|
|
8146
8146
|
*/
|
|
8147
8147
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
8148
8148
|
if (llmExecutionTools.length === 0) {
|
|
8149
|
-
const warningMessage =
|
|
8149
|
+
const warningMessage = _spaceTrim.spaceTrim(`
|
|
8150
8150
|
You have not provided any \`LlmExecutionTools\`
|
|
8151
8151
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
8152
8152
|
|
|
@@ -8204,7 +8204,7 @@
|
|
|
8204
8204
|
.find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
|
|
8205
8205
|
if (registeredItem === undefined) {
|
|
8206
8206
|
// console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
|
|
8207
|
-
throw new Error(
|
|
8207
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
8208
8208
|
There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
|
|
8209
8209
|
Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
|
|
8210
8210
|
|
|
@@ -8272,14 +8272,14 @@
|
|
|
8272
8272
|
const configuration = await $provideLlmToolsConfigurationFromEnv();
|
|
8273
8273
|
if (configuration.length === 0) {
|
|
8274
8274
|
if ($llmToolsMetadataRegister.list().length === 0) {
|
|
8275
|
-
throw new UnexpectedError(
|
|
8275
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
8276
8276
|
No LLM tools registered, this is probably a bug in the Promptbook library
|
|
8277
8277
|
|
|
8278
8278
|
${block($registeredLlmToolsMessage())}}
|
|
8279
8279
|
`));
|
|
8280
8280
|
}
|
|
8281
8281
|
// TODO: [🥃]
|
|
8282
|
-
throw new Error(
|
|
8282
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
8283
8283
|
No LLM tools found in the environment
|
|
8284
8284
|
|
|
8285
8285
|
${block($registeredLlmToolsMessage())}}
|
|
@@ -8389,7 +8389,7 @@
|
|
|
8389
8389
|
else if (urlOrRequest instanceof Request) {
|
|
8390
8390
|
url = urlOrRequest.url;
|
|
8391
8391
|
}
|
|
8392
|
-
throw new PromptbookFetchError(
|
|
8392
|
+
throw new PromptbookFetchError(_spaceTrim.spaceTrim((block) => `
|
|
8393
8393
|
Can not fetch "${url}"
|
|
8394
8394
|
|
|
8395
8395
|
Fetch error:
|
|
@@ -8443,7 +8443,7 @@
|
|
|
8443
8443
|
console.log(colors__default["default"].red(`You can not login to remote server in non-interactive mode`));
|
|
8444
8444
|
process.exit(1);
|
|
8445
8445
|
}
|
|
8446
|
-
console.info(colors__default["default"].cyan(
|
|
8446
|
+
console.info(colors__default["default"].cyan(_spaceTrim.spaceTrim(`
|
|
8447
8447
|
You will be logged in to ${remoteServerUrl}
|
|
8448
8448
|
If you don't have an account, it will be created automatically.
|
|
8449
8449
|
`)));
|
|
@@ -8517,7 +8517,7 @@
|
|
|
8517
8517
|
*/
|
|
8518
8518
|
function $initializeListModelsCommand(program) {
|
|
8519
8519
|
const listModelsCommand = program.command('list-models');
|
|
8520
|
-
listModelsCommand.description(
|
|
8520
|
+
listModelsCommand.description(_spaceTrim.spaceTrim(`
|
|
8521
8521
|
List all available and configured LLM models
|
|
8522
8522
|
`));
|
|
8523
8523
|
listModelsCommand.alias('models');
|
|
@@ -8671,11 +8671,11 @@
|
|
|
8671
8671
|
console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
|
|
8672
8672
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
8673
8673
|
}
|
|
8674
|
-
resolve(
|
|
8674
|
+
resolve(_spaceTrim.spaceTrim(output.join('\n')));
|
|
8675
8675
|
}
|
|
8676
8676
|
}
|
|
8677
8677
|
else {
|
|
8678
|
-
resolve(
|
|
8678
|
+
resolve(_spaceTrim.spaceTrim(output.join('\n')));
|
|
8679
8679
|
}
|
|
8680
8680
|
};
|
|
8681
8681
|
commandProcess.on('close', finishWithCode);
|
|
@@ -8693,7 +8693,7 @@
|
|
|
8693
8693
|
console.warn(error);
|
|
8694
8694
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
8695
8695
|
}
|
|
8696
|
-
resolve(
|
|
8696
|
+
resolve(_spaceTrim.spaceTrim(output.join('\n')));
|
|
8697
8697
|
}
|
|
8698
8698
|
});
|
|
8699
8699
|
}
|
|
@@ -9006,14 +9006,14 @@
|
|
|
9006
9006
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
9007
9007
|
});
|
|
9008
9008
|
if (metadata.length === 0) {
|
|
9009
|
-
return
|
|
9009
|
+
return _spaceTrim.spaceTrim(`
|
|
9010
9010
|
**No scrapers are available**
|
|
9011
9011
|
|
|
9012
9012
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
9013
9013
|
At least there should be available the metadata of the scrapers
|
|
9014
9014
|
`);
|
|
9015
9015
|
}
|
|
9016
|
-
return
|
|
9016
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
9017
9017
|
Available scrapers are:
|
|
9018
9018
|
${block(metadata
|
|
9019
9019
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -9064,7 +9064,7 @@
|
|
|
9064
9064
|
*/
|
|
9065
9065
|
function $initializeListScrapersCommand(program) {
|
|
9066
9066
|
const listModelsCommand = program.command('list-scrapers');
|
|
9067
|
-
listModelsCommand.description(
|
|
9067
|
+
listModelsCommand.description(_spaceTrim.spaceTrim(`
|
|
9068
9068
|
List all available and configured scrapers and executables
|
|
9069
9069
|
`));
|
|
9070
9070
|
listModelsCommand.alias('scrapers');
|
|
@@ -9072,7 +9072,7 @@
|
|
|
9072
9072
|
// TODO: [🌞] Do not allow on REMOTE_SERVER strategy
|
|
9073
9073
|
const scrapers = await $provideScrapersForNode({});
|
|
9074
9074
|
const executables = await $provideExecutablesForNode();
|
|
9075
|
-
console.info(
|
|
9075
|
+
console.info(_spaceTrim.spaceTrim((block) => `
|
|
9076
9076
|
${block($registeredScrapersMessage(scrapers))}
|
|
9077
9077
|
|
|
9078
9078
|
All mime-types which can be scraped:
|
|
@@ -9102,7 +9102,7 @@
|
|
|
9102
9102
|
*/
|
|
9103
9103
|
function $initializeLoginCommand(program) {
|
|
9104
9104
|
const loginCommand = program.command('login');
|
|
9105
|
-
loginCommand.description(
|
|
9105
|
+
loginCommand.description(_spaceTrim.spaceTrim(`
|
|
9106
9106
|
Login to the remote Promptbook server
|
|
9107
9107
|
`));
|
|
9108
9108
|
loginCommand.action(handleActionErrors(async (cliOptions) => {
|
|
@@ -9153,7 +9153,7 @@
|
|
|
9153
9153
|
if (!(error instanceof PipelineLogicError)) {
|
|
9154
9154
|
throw error;
|
|
9155
9155
|
}
|
|
9156
|
-
console.error(
|
|
9156
|
+
console.error(_spaceTrim.spaceTrim((block) => `
|
|
9157
9157
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
9158
9158
|
|
|
9159
9159
|
${block(error.message)}
|
|
@@ -9180,7 +9180,7 @@
|
|
|
9180
9180
|
})();
|
|
9181
9181
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
9182
9182
|
// <- Note: [🚲]
|
|
9183
|
-
throw new PipelineLogicError(
|
|
9183
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9184
9184
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
9185
9185
|
|
|
9186
9186
|
${block(pipelineIdentification)}
|
|
@@ -9188,7 +9188,7 @@
|
|
|
9188
9188
|
}
|
|
9189
9189
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
9190
9190
|
// <- Note: [🚲]
|
|
9191
|
-
throw new PipelineLogicError(
|
|
9191
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9192
9192
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
9193
9193
|
|
|
9194
9194
|
${block(pipelineIdentification)}
|
|
@@ -9197,7 +9197,7 @@
|
|
|
9197
9197
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
9198
9198
|
if (!Array.isArray(pipeline.parameters)) {
|
|
9199
9199
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
9200
|
-
throw new ParseError(
|
|
9200
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
9201
9201
|
Pipeline is valid JSON but with wrong structure
|
|
9202
9202
|
|
|
9203
9203
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -9208,7 +9208,7 @@
|
|
|
9208
9208
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
9209
9209
|
if (!Array.isArray(pipeline.tasks)) {
|
|
9210
9210
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
9211
|
-
throw new ParseError(
|
|
9211
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
9212
9212
|
Pipeline is valid JSON but with wrong structure
|
|
9213
9213
|
|
|
9214
9214
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -9234,7 +9234,7 @@
|
|
|
9234
9234
|
// Note: Check each parameter individually
|
|
9235
9235
|
for (const parameter of pipeline.parameters) {
|
|
9236
9236
|
if (parameter.isInput && parameter.isOutput) {
|
|
9237
|
-
throw new PipelineLogicError(
|
|
9237
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9238
9238
|
|
|
9239
9239
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
9240
9240
|
|
|
@@ -9245,7 +9245,7 @@
|
|
|
9245
9245
|
if (!parameter.isInput &&
|
|
9246
9246
|
!parameter.isOutput &&
|
|
9247
9247
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
9248
|
-
throw new PipelineLogicError(
|
|
9248
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9249
9249
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
9250
9250
|
|
|
9251
9251
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -9257,7 +9257,7 @@
|
|
|
9257
9257
|
}
|
|
9258
9258
|
// Note: Testing that parameter is either input or result of some task
|
|
9259
9259
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
9260
|
-
throw new PipelineLogicError(
|
|
9260
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9261
9261
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
9262
9262
|
|
|
9263
9263
|
You can do one of these:
|
|
@@ -9273,14 +9273,14 @@
|
|
|
9273
9273
|
// Note: Checking each task individually
|
|
9274
9274
|
for (const task of pipeline.tasks) {
|
|
9275
9275
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
9276
|
-
throw new PipelineLogicError(
|
|
9276
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9277
9277
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
9278
9278
|
|
|
9279
9279
|
${block(pipelineIdentification)}
|
|
9280
9280
|
`));
|
|
9281
9281
|
}
|
|
9282
9282
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
9283
|
-
throw new PipelineLogicError(
|
|
9283
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9284
9284
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
9285
9285
|
|
|
9286
9286
|
${block(pipelineIdentification)}
|
|
@@ -9290,7 +9290,7 @@
|
|
|
9290
9290
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
9291
9291
|
if (!task.format &&
|
|
9292
9292
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
9293
|
-
throw new PipelineLogicError(
|
|
9293
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9294
9294
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
9295
9295
|
|
|
9296
9296
|
${block(pipelineIdentification)}
|
|
@@ -9298,7 +9298,7 @@
|
|
|
9298
9298
|
}
|
|
9299
9299
|
for (const joker of task.jokerParameterNames) {
|
|
9300
9300
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
9301
|
-
throw new PipelineLogicError(
|
|
9301
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9302
9302
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
9303
9303
|
|
|
9304
9304
|
${block(pipelineIdentification)}
|
|
@@ -9309,21 +9309,21 @@
|
|
|
9309
9309
|
if (task.expectations) {
|
|
9310
9310
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
9311
9311
|
if (min !== undefined && max !== undefined && min > max) {
|
|
9312
|
-
throw new PipelineLogicError(
|
|
9312
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9313
9313
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
9314
9314
|
|
|
9315
9315
|
${block(pipelineIdentification)}
|
|
9316
9316
|
`));
|
|
9317
9317
|
}
|
|
9318
9318
|
if (min !== undefined && min < 0) {
|
|
9319
|
-
throw new PipelineLogicError(
|
|
9319
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9320
9320
|
Min expectation of ${unit} must be zero or positive
|
|
9321
9321
|
|
|
9322
9322
|
${block(pipelineIdentification)}
|
|
9323
9323
|
`));
|
|
9324
9324
|
}
|
|
9325
9325
|
if (max !== undefined && max <= 0) {
|
|
9326
|
-
throw new PipelineLogicError(
|
|
9326
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
9327
9327
|
Max expectation of ${unit} must be positive
|
|
9328
9328
|
|
|
9329
9329
|
${block(pipelineIdentification)}
|
|
@@ -9345,7 +9345,7 @@
|
|
|
9345
9345
|
while (unresovedTasks.length > 0) {
|
|
9346
9346
|
if (loopLimit-- < 0) {
|
|
9347
9347
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
9348
|
-
throw new UnexpectedError(
|
|
9348
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
9349
9349
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
9350
9350
|
|
|
9351
9351
|
${block(pipelineIdentification)}
|
|
@@ -9355,7 +9355,7 @@
|
|
|
9355
9355
|
if (currentlyResovedTasks.length === 0) {
|
|
9356
9356
|
throw new PipelineLogicError(
|
|
9357
9357
|
// TODO: [🐎] DRY
|
|
9358
|
-
|
|
9358
|
+
_spaceTrim.spaceTrim((block) => `
|
|
9359
9359
|
|
|
9360
9360
|
Can not resolve some parameters:
|
|
9361
9361
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -9602,7 +9602,7 @@
|
|
|
9602
9602
|
pipelineString += '\n\n';
|
|
9603
9603
|
pipelineString += '```' + contentLanguage;
|
|
9604
9604
|
pipelineString += '\n';
|
|
9605
|
-
pipelineString +=
|
|
9605
|
+
pipelineString += _spaceTrim.spaceTrim(content);
|
|
9606
9606
|
// <- TODO: [main] !!3 Escape
|
|
9607
9607
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
9608
9608
|
pipelineString += '\n';
|
|
@@ -9690,7 +9690,7 @@
|
|
|
9690
9690
|
for (const pipeline of pipelines) {
|
|
9691
9691
|
// TODO: [👠] DRY
|
|
9692
9692
|
if (pipeline.pipelineUrl === undefined) {
|
|
9693
|
-
throw new PipelineUrlError(
|
|
9693
|
+
throw new PipelineUrlError(_spaceTrim.spaceTrim(`
|
|
9694
9694
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
9695
9695
|
|
|
9696
9696
|
File:
|
|
@@ -9712,7 +9712,7 @@
|
|
|
9712
9712
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
9713
9713
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
9714
9714
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
9715
|
-
throw new PipelineUrlError(
|
|
9715
|
+
throw new PipelineUrlError(_spaceTrim.spaceTrim(`
|
|
9716
9716
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
9717
9717
|
|
|
9718
9718
|
Conflicting files:
|
|
@@ -9744,13 +9744,13 @@
|
|
|
9744
9744
|
const pipeline = this.collection.get(url);
|
|
9745
9745
|
if (!pipeline) {
|
|
9746
9746
|
if (this.listPipelines().length === 0) {
|
|
9747
|
-
throw new NotFoundError(
|
|
9747
|
+
throw new NotFoundError(_spaceTrim.spaceTrim(`
|
|
9748
9748
|
Pipeline with url "${url}" not found
|
|
9749
9749
|
|
|
9750
9750
|
No pipelines available
|
|
9751
9751
|
`));
|
|
9752
9752
|
}
|
|
9753
|
-
throw new NotFoundError(
|
|
9753
|
+
throw new NotFoundError(_spaceTrim.spaceTrim((block) => `
|
|
9754
9754
|
Pipeline with url "${url}" not found
|
|
9755
9755
|
|
|
9756
9756
|
Available pipelines:
|
|
@@ -9849,11 +9849,11 @@
|
|
|
9849
9849
|
throw deserializeError(errors[0]);
|
|
9850
9850
|
}
|
|
9851
9851
|
else {
|
|
9852
|
-
throw new PipelineExecutionError(
|
|
9852
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
9853
9853
|
Multiple errors occurred during Promptbook execution
|
|
9854
9854
|
|
|
9855
9855
|
${block(errors
|
|
9856
|
-
.map(({ name, stack, message }, index) =>
|
|
9856
|
+
.map(({ name, stack, message }, index) => _spaceTrim.spaceTrim((block) => `
|
|
9857
9857
|
${name} ${index + 1}:
|
|
9858
9858
|
${block(stack || message)}
|
|
9859
9859
|
`))
|
|
@@ -10111,7 +10111,7 @@
|
|
|
10111
10111
|
}
|
|
10112
10112
|
catch (error) {
|
|
10113
10113
|
assertsError(error);
|
|
10114
|
-
throw new ParseError(
|
|
10114
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10115
10115
|
Can not extract variables from the script
|
|
10116
10116
|
${block(error.stack || error.message)}
|
|
10117
10117
|
|
|
@@ -10237,7 +10237,7 @@
|
|
|
10237
10237
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
10238
10238
|
const csv = csvParse(value, settings);
|
|
10239
10239
|
if (csv.errors.length !== 0) {
|
|
10240
|
-
throw new CsvFormatError(
|
|
10240
|
+
throw new CsvFormatError(_spaceTrim.spaceTrim((block) => `
|
|
10241
10241
|
CSV parsing error
|
|
10242
10242
|
|
|
10243
10243
|
Error(s) from CSV parsing:
|
|
@@ -10282,7 +10282,7 @@
|
|
|
10282
10282
|
const { value, settings, mapCallback, onProgress } = options;
|
|
10283
10283
|
const csv = csvParse(value, settings);
|
|
10284
10284
|
if (csv.errors.length !== 0) {
|
|
10285
|
-
throw new CsvFormatError(
|
|
10285
|
+
throw new CsvFormatError(_spaceTrim.spaceTrim((block) => `
|
|
10286
10286
|
CSV parsing error
|
|
10287
10287
|
|
|
10288
10288
|
Error(s) from CSV parsing:
|
|
@@ -10468,7 +10468,7 @@
|
|
|
10468
10468
|
}
|
|
10469
10469
|
// Phase 2️⃣: Non-matching mapping
|
|
10470
10470
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
10471
|
-
throw new PipelineExecutionError(
|
|
10471
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10472
10472
|
Can not map available parameters to expected parameters
|
|
10473
10473
|
|
|
10474
10474
|
Mapped parameters:
|
|
@@ -10559,7 +10559,7 @@
|
|
|
10559
10559
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
10560
10560
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
10561
10561
|
if (isJokerAttempt && !jokerParameterName) {
|
|
10562
|
-
throw new UnexpectedError(
|
|
10562
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
10563
10563
|
Joker not found in attempt ${attemptIndex}
|
|
10564
10564
|
|
|
10565
10565
|
${block(pipelineIdentification)}
|
|
@@ -10570,7 +10570,7 @@
|
|
|
10570
10570
|
$ongoingTaskResult.$expectError = null;
|
|
10571
10571
|
if (isJokerAttempt) {
|
|
10572
10572
|
if (parameters[jokerParameterName] === undefined) {
|
|
10573
|
-
throw new PipelineExecutionError(
|
|
10573
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10574
10574
|
Joker parameter {${jokerParameterName}} not defined
|
|
10575
10575
|
|
|
10576
10576
|
${block(pipelineIdentification)}
|
|
@@ -10629,7 +10629,7 @@
|
|
|
10629
10629
|
break variant;
|
|
10630
10630
|
case 'EMBEDDING':
|
|
10631
10631
|
case 'IMAGE_GENERATION':
|
|
10632
|
-
throw new PipelineExecutionError(
|
|
10632
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10633
10633
|
${modelRequirements.modelVariant} model can not be used in pipeline
|
|
10634
10634
|
|
|
10635
10635
|
This should be catched during parsing
|
|
@@ -10640,7 +10640,7 @@
|
|
|
10640
10640
|
break variant;
|
|
10641
10641
|
// <- case [🤖]:
|
|
10642
10642
|
default:
|
|
10643
|
-
throw new PipelineExecutionError(
|
|
10643
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10644
10644
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
10645
10645
|
|
|
10646
10646
|
${block(pipelineIdentification)}
|
|
@@ -10651,14 +10651,14 @@
|
|
|
10651
10651
|
break;
|
|
10652
10652
|
case 'SCRIPT_TASK':
|
|
10653
10653
|
if (arrayableToArray(tools.script).length === 0) {
|
|
10654
|
-
throw new PipelineExecutionError(
|
|
10654
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10655
10655
|
No script execution tools are available
|
|
10656
10656
|
|
|
10657
10657
|
${block(pipelineIdentification)}
|
|
10658
10658
|
`));
|
|
10659
10659
|
}
|
|
10660
10660
|
if (!task.contentLanguage) {
|
|
10661
|
-
throw new PipelineExecutionError(
|
|
10661
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10662
10662
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
10663
10663
|
|
|
10664
10664
|
${block(pipelineIdentification)}
|
|
@@ -10689,7 +10689,7 @@
|
|
|
10689
10689
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
10690
10690
|
}
|
|
10691
10691
|
else {
|
|
10692
|
-
throw new PipelineExecutionError(
|
|
10692
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10693
10693
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
10694
10694
|
|
|
10695
10695
|
${block(pipelineIdentification)}
|
|
@@ -10703,7 +10703,7 @@
|
|
|
10703
10703
|
break taskType;
|
|
10704
10704
|
case 'DIALOG_TASK':
|
|
10705
10705
|
if (tools.userInterface === undefined) {
|
|
10706
|
-
throw new PipelineExecutionError(
|
|
10706
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10707
10707
|
User interface tools are not available
|
|
10708
10708
|
|
|
10709
10709
|
${block(pipelineIdentification)}
|
|
@@ -10721,7 +10721,7 @@
|
|
|
10721
10721
|
break taskType;
|
|
10722
10722
|
// <- case: [🅱]
|
|
10723
10723
|
default:
|
|
10724
|
-
throw new PipelineExecutionError(
|
|
10724
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10725
10725
|
Unknown execution type "${task.taskType}"
|
|
10726
10726
|
|
|
10727
10727
|
${block(pipelineIdentification)}
|
|
@@ -10819,7 +10819,7 @@
|
|
|
10819
10819
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
10820
10820
|
// Note: Create a summary of all failures
|
|
10821
10821
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
10822
|
-
.map((failure) =>
|
|
10822
|
+
.map((failure) => _spaceTrim.spaceTrim((block) => {
|
|
10823
10823
|
var _a, _b;
|
|
10824
10824
|
return `
|
|
10825
10825
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -10829,14 +10829,14 @@
|
|
|
10829
10829
|
Result:
|
|
10830
10830
|
${block(failure.result === null
|
|
10831
10831
|
? 'null'
|
|
10832
|
-
:
|
|
10832
|
+
: _spaceTrim.spaceTrim(failure.result)
|
|
10833
10833
|
.split(/\r?\n/)
|
|
10834
10834
|
.map((line) => `> ${line}`)
|
|
10835
10835
|
.join('\n'))}
|
|
10836
10836
|
`;
|
|
10837
10837
|
}))
|
|
10838
10838
|
.join('\n\n---\n\n');
|
|
10839
|
-
throw new PipelineExecutionError(
|
|
10839
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => {
|
|
10840
10840
|
var _a;
|
|
10841
10841
|
return `
|
|
10842
10842
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -10856,7 +10856,7 @@
|
|
|
10856
10856
|
}
|
|
10857
10857
|
}
|
|
10858
10858
|
if ($ongoingTaskResult.$resultString === null) {
|
|
10859
|
-
throw new UnexpectedError(
|
|
10859
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
10860
10860
|
Something went wrong and prompt result is null
|
|
10861
10861
|
|
|
10862
10862
|
${block(pipelineIdentification)}
|
|
@@ -10883,7 +10883,7 @@
|
|
|
10883
10883
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
10884
10884
|
}
|
|
10885
10885
|
if (jokerParameterNames.length !== 0) {
|
|
10886
|
-
throw new UnexpectedError(
|
|
10886
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
10887
10887
|
JOKER parameters are not supported together with FOREACH command
|
|
10888
10888
|
|
|
10889
10889
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -10896,7 +10896,7 @@
|
|
|
10896
10896
|
if (formatDefinition === undefined) {
|
|
10897
10897
|
throw new UnexpectedError(
|
|
10898
10898
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
10899
|
-
|
|
10899
|
+
_spaceTrim.spaceTrim((block) => `
|
|
10900
10900
|
Unsupported format "${task.foreach.formatName}"
|
|
10901
10901
|
|
|
10902
10902
|
Available formats:
|
|
@@ -10913,7 +10913,7 @@
|
|
|
10913
10913
|
if (subvalueParser === undefined) {
|
|
10914
10914
|
throw new UnexpectedError(
|
|
10915
10915
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
10916
|
-
|
|
10916
|
+
_spaceTrim.spaceTrim((block) => `
|
|
10917
10917
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
10918
10918
|
|
|
10919
10919
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -10953,7 +10953,7 @@
|
|
|
10953
10953
|
if (!(error instanceof PipelineExecutionError)) {
|
|
10954
10954
|
throw error;
|
|
10955
10955
|
}
|
|
10956
|
-
const highLevelError = new PipelineExecutionError(
|
|
10956
|
+
const highLevelError = new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
10957
10957
|
${error.message}
|
|
10958
10958
|
|
|
10959
10959
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -10977,7 +10977,7 @@
|
|
|
10977
10977
|
...options,
|
|
10978
10978
|
priority: priority + index,
|
|
10979
10979
|
parameters: allSubparameters,
|
|
10980
|
-
pipelineIdentification:
|
|
10980
|
+
pipelineIdentification: _spaceTrim.spaceTrim((block) => `
|
|
10981
10981
|
${block(pipelineIdentification)}
|
|
10982
10982
|
Subparameter index: ${index}
|
|
10983
10983
|
`),
|
|
@@ -10986,7 +10986,7 @@
|
|
|
10986
10986
|
}
|
|
10987
10987
|
catch (error) {
|
|
10988
10988
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
10989
|
-
console.error(
|
|
10989
|
+
console.error(_spaceTrim.spaceTrim((block) => `
|
|
10990
10990
|
${error.message}
|
|
10991
10991
|
|
|
10992
10992
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -11162,7 +11162,7 @@
|
|
|
11162
11162
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
11163
11163
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
11164
11164
|
if (reservedParameters[parameterName] === undefined) {
|
|
11165
|
-
throw new UnexpectedError(
|
|
11165
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
11166
11166
|
Reserved parameter {${parameterName}} is not defined
|
|
11167
11167
|
|
|
11168
11168
|
${block(pipelineIdentification)}
|
|
@@ -11188,7 +11188,7 @@
|
|
|
11188
11188
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
11189
11189
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
11190
11190
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
11191
|
-
throw new UnexpectedError(
|
|
11191
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
11192
11192
|
Dependent parameters are not consistent with used parameters:
|
|
11193
11193
|
|
|
11194
11194
|
Dependent parameters:
|
|
@@ -11232,7 +11232,7 @@
|
|
|
11232
11232
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
11233
11233
|
// Houston, we have a problem
|
|
11234
11234
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
11235
|
-
throw new UnexpectedError(
|
|
11235
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
11236
11236
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
11237
11237
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
11238
11238
|
|
|
@@ -11301,7 +11301,7 @@
|
|
|
11301
11301
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
11302
11302
|
if (parametersToPass[parameter.name] === undefined) {
|
|
11303
11303
|
// [4]
|
|
11304
|
-
$warnings.push(new PipelineExecutionError(
|
|
11304
|
+
$warnings.push(new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
11305
11305
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
11306
11306
|
|
|
11307
11307
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -11409,7 +11409,7 @@
|
|
|
11409
11409
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
11410
11410
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
11411
11411
|
if (parameter === undefined) {
|
|
11412
|
-
warnings.push(new PipelineExecutionError(
|
|
11412
|
+
warnings.push(new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
11413
11413
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
11414
11414
|
|
|
11415
11415
|
${block(pipelineIdentification)}
|
|
@@ -11424,7 +11424,7 @@
|
|
|
11424
11424
|
// TODO: [🧠] This should be also non-critical error
|
|
11425
11425
|
return exportJson({
|
|
11426
11426
|
name: 'pipelineExecutorResult',
|
|
11427
|
-
message:
|
|
11427
|
+
message: _spaceTrim.spaceTrim((block) => `
|
|
11428
11428
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
11429
11429
|
|
|
11430
11430
|
${block(pipelineIdentification)}
|
|
@@ -11433,7 +11433,7 @@
|
|
|
11433
11433
|
value: {
|
|
11434
11434
|
isSuccessful: false,
|
|
11435
11435
|
errors: [
|
|
11436
|
-
new PipelineExecutionError(
|
|
11436
|
+
new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
11437
11437
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
11438
11438
|
|
|
11439
11439
|
${block(pipelineIdentification)}
|
|
@@ -11460,7 +11460,7 @@
|
|
|
11460
11460
|
while (unresovedTasks.length > 0) {
|
|
11461
11461
|
if (loopLimit-- < 0) {
|
|
11462
11462
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
11463
|
-
throw new UnexpectedError(
|
|
11463
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
11464
11464
|
Loop limit reached during resolving parameters pipeline execution
|
|
11465
11465
|
|
|
11466
11466
|
${block(pipelineIdentification)}
|
|
@@ -11470,7 +11470,7 @@
|
|
|
11470
11470
|
if (!currentTask && resolving.length === 0) {
|
|
11471
11471
|
throw new UnexpectedError(
|
|
11472
11472
|
// TODO: [🐎] DRY
|
|
11473
|
-
|
|
11473
|
+
_spaceTrim.spaceTrim((block) => `
|
|
11474
11474
|
Can not resolve some parameters:
|
|
11475
11475
|
|
|
11476
11476
|
${block(pipelineIdentification)}
|
|
@@ -11510,7 +11510,7 @@
|
|
|
11510
11510
|
tools,
|
|
11511
11511
|
onProgress(newOngoingResult) {
|
|
11512
11512
|
if (isReturned) {
|
|
11513
|
-
throw new UnexpectedError(
|
|
11513
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
11514
11514
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
11515
11515
|
|
|
11516
11516
|
${block(pipelineIdentification)}
|
|
@@ -11527,7 +11527,7 @@
|
|
|
11527
11527
|
},
|
|
11528
11528
|
logLlmCall,
|
|
11529
11529
|
$executionReport: executionReport,
|
|
11530
|
-
pipelineIdentification:
|
|
11530
|
+
pipelineIdentification: _spaceTrim.spaceTrim((block) => `
|
|
11531
11531
|
${block(pipelineIdentification)}
|
|
11532
11532
|
Task name: ${currentTask.name}
|
|
11533
11533
|
Task title: ${currentTask.title}
|
|
@@ -11636,7 +11636,7 @@
|
|
|
11636
11636
|
preparedPipeline = pipeline;
|
|
11637
11637
|
}
|
|
11638
11638
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
11639
|
-
console.warn(
|
|
11639
|
+
console.warn(_spaceTrim.spaceTrim((block) => `
|
|
11640
11640
|
Pipeline is not prepared
|
|
11641
11641
|
|
|
11642
11642
|
${block(pipelineIdentification)}
|
|
@@ -11661,7 +11661,7 @@
|
|
|
11661
11661
|
tools,
|
|
11662
11662
|
onProgress,
|
|
11663
11663
|
logLlmCall,
|
|
11664
|
-
pipelineIdentification:
|
|
11664
|
+
pipelineIdentification: _spaceTrim.spaceTrim((block) => `
|
|
11665
11665
|
${block(pipelineIdentification)}
|
|
11666
11666
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
11667
11667
|
`),
|
|
@@ -12030,7 +12030,7 @@
|
|
|
12030
12030
|
const fileExtension = getFileExtension(filename);
|
|
12031
12031
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
12032
12032
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
12033
|
-
throw new NotFoundError(
|
|
12033
|
+
throw new NotFoundError(_spaceTrim.spaceTrim((block) => `
|
|
12034
12034
|
Can not make source handler for file which does not exist:
|
|
12035
12035
|
|
|
12036
12036
|
File:
|
|
@@ -12123,7 +12123,7 @@
|
|
|
12123
12123
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
12124
12124
|
break;
|
|
12125
12125
|
}
|
|
12126
|
-
console.warn(
|
|
12126
|
+
console.warn(_spaceTrim.spaceTrim((block) => `
|
|
12127
12127
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
12128
12128
|
|
|
12129
12129
|
The source:
|
|
@@ -12139,7 +12139,7 @@
|
|
|
12139
12139
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
12140
12140
|
}
|
|
12141
12141
|
if (partialPieces === null) {
|
|
12142
|
-
throw new KnowledgeScrapeError(
|
|
12142
|
+
throw new KnowledgeScrapeError(_spaceTrim.spaceTrim((block) => `
|
|
12143
12143
|
Cannot scrape knowledge
|
|
12144
12144
|
|
|
12145
12145
|
The source:
|
|
@@ -12218,7 +12218,7 @@
|
|
|
12218
12218
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
12219
12219
|
knowledgePiecesCount > 0 &&
|
|
12220
12220
|
!dependentParameterNames.includes('knowledge')) {
|
|
12221
|
-
preparedContent =
|
|
12221
|
+
preparedContent = _spaceTrim.spaceTrim(`
|
|
12222
12222
|
{content}
|
|
12223
12223
|
|
|
12224
12224
|
## Knowledge
|
|
@@ -12475,7 +12475,7 @@
|
|
|
12475
12475
|
*/
|
|
12476
12476
|
parse(input) {
|
|
12477
12477
|
const { args } = input;
|
|
12478
|
-
const knowledgeSourceContent =
|
|
12478
|
+
const knowledgeSourceContent = _spaceTrim.spaceTrim(args[0] || '');
|
|
12479
12479
|
if (knowledgeSourceContent === '') {
|
|
12480
12480
|
throw new ParseError(`Source is not defined`);
|
|
12481
12481
|
}
|
|
@@ -12619,7 +12619,7 @@
|
|
|
12619
12619
|
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
12620
12620
|
const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
|
|
12621
12621
|
if (taskTypes.length !== 1) {
|
|
12622
|
-
throw new ParseError(
|
|
12622
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
12623
12623
|
Unknown section type "${normalized}"
|
|
12624
12624
|
|
|
12625
12625
|
Supported section types are:
|
|
@@ -12639,7 +12639,7 @@
|
|
|
12639
12639
|
*/
|
|
12640
12640
|
$applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
12641
12641
|
if ($taskJson.isSectionTypeSet === true) {
|
|
12642
|
-
throw new ParseError(
|
|
12642
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
12643
12643
|
Section type is already defined in the section.
|
|
12644
12644
|
It can be defined only once.
|
|
12645
12645
|
`));
|
|
@@ -12919,7 +12919,7 @@
|
|
|
12919
12919
|
/**
|
|
12920
12920
|
* Description of the FORMAT command
|
|
12921
12921
|
*/
|
|
12922
|
-
description:
|
|
12922
|
+
description: _spaceTrim.spaceTrim(`
|
|
12923
12923
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
12924
12924
|
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.
|
|
12925
12925
|
`),
|
|
@@ -12993,7 +12993,7 @@
|
|
|
12993
12993
|
}
|
|
12994
12994
|
catch (error) {
|
|
12995
12995
|
assertsError(error);
|
|
12996
|
-
throw new ParseError(
|
|
12996
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
12997
12997
|
Invalid FORMAT command
|
|
12998
12998
|
${block(error.message)}:
|
|
12999
12999
|
`));
|
|
@@ -13105,7 +13105,7 @@
|
|
|
13105
13105
|
if (!(error instanceof ParseError)) {
|
|
13106
13106
|
throw error;
|
|
13107
13107
|
}
|
|
13108
|
-
throw new ParseError(
|
|
13108
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
13109
13109
|
${block(error.message)}
|
|
13110
13110
|
|
|
13111
13111
|
Tried to validate parameter name:
|
|
@@ -13164,7 +13164,7 @@
|
|
|
13164
13164
|
const assignSign = args[3];
|
|
13165
13165
|
const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
|
|
13166
13166
|
if (formatDefinition === undefined) {
|
|
13167
|
-
throw new ParseError(
|
|
13167
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
13168
13168
|
Unsupported format "${formatName}"
|
|
13169
13169
|
|
|
13170
13170
|
Available formats:
|
|
@@ -13176,7 +13176,7 @@
|
|
|
13176
13176
|
}
|
|
13177
13177
|
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
13178
13178
|
if (subvalueParser === undefined) {
|
|
13179
|
-
throw new ParseError(
|
|
13179
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
13180
13180
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
13181
13181
|
|
|
13182
13182
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -13224,7 +13224,7 @@
|
|
|
13224
13224
|
outputSubparameterName = 'newLine';
|
|
13225
13225
|
}
|
|
13226
13226
|
else {
|
|
13227
|
-
throw new ParseError(
|
|
13227
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
13228
13228
|
FOREACH ${formatName} ${subformatName} must specify output subparameter
|
|
13229
13229
|
|
|
13230
13230
|
Correct example:
|
|
@@ -13300,7 +13300,7 @@
|
|
|
13300
13300
|
/**
|
|
13301
13301
|
* Description of the FORMAT command
|
|
13302
13302
|
*/
|
|
13303
|
-
description:
|
|
13303
|
+
description: _spaceTrim.spaceTrim(`
|
|
13304
13304
|
Format command describes the desired output of the task (after post-processing)
|
|
13305
13305
|
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.
|
|
13306
13306
|
`),
|
|
@@ -13672,7 +13672,7 @@
|
|
|
13672
13672
|
const formfactorNameCandidate = args[0].toUpperCase();
|
|
13673
13673
|
const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
|
|
13674
13674
|
if (formfactor === undefined) {
|
|
13675
|
-
throw new ParseError(
|
|
13675
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
13676
13676
|
Unknown formfactor name "${formfactorNameCandidate}"
|
|
13677
13677
|
|
|
13678
13678
|
Available formfactors:
|
|
@@ -13691,7 +13691,7 @@
|
|
|
13691
13691
|
*/
|
|
13692
13692
|
$applyToPipelineJson(command, $pipelineJson) {
|
|
13693
13693
|
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
13694
|
-
throw new ParseError(
|
|
13694
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
13695
13695
|
Redefinition of \`FORMFACTOR\` in the pipeline head
|
|
13696
13696
|
|
|
13697
13697
|
You have used:
|
|
@@ -13839,7 +13839,7 @@
|
|
|
13839
13839
|
*/
|
|
13840
13840
|
parse(input) {
|
|
13841
13841
|
const { args, normalized } = input;
|
|
13842
|
-
const availableVariantsMessage =
|
|
13842
|
+
const availableVariantsMessage = _spaceTrim.spaceTrim((block) => `
|
|
13843
13843
|
Available variants are:
|
|
13844
13844
|
${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
|
|
13845
13845
|
`);
|
|
@@ -13861,14 +13861,14 @@
|
|
|
13861
13861
|
// <- Note: [🤖]
|
|
13862
13862
|
}
|
|
13863
13863
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
13864
|
-
|
|
13864
|
+
_spaceTrim.spaceTrim((block) => `
|
|
13865
13865
|
Embedding model can not be used in pipeline
|
|
13866
13866
|
|
|
13867
13867
|
${block(availableVariantsMessage)}
|
|
13868
13868
|
`);
|
|
13869
13869
|
}
|
|
13870
13870
|
else {
|
|
13871
|
-
throw new ParseError(
|
|
13871
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
13872
13872
|
Unknown model variant in command:
|
|
13873
13873
|
|
|
13874
13874
|
${block(availableVariantsMessage)}
|
|
@@ -13883,7 +13883,7 @@
|
|
|
13883
13883
|
};
|
|
13884
13884
|
}
|
|
13885
13885
|
else {
|
|
13886
|
-
throw new ParseError(
|
|
13886
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
13887
13887
|
Unknown model key in command.
|
|
13888
13888
|
|
|
13889
13889
|
Supported model keys are:
|
|
@@ -13910,7 +13910,7 @@
|
|
|
13910
13910
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
13911
13911
|
}
|
|
13912
13912
|
else {
|
|
13913
|
-
throw new ParseError(
|
|
13913
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
13914
13914
|
Redefinition of \`MODEL ${command.key}\` in the pipeline head
|
|
13915
13915
|
|
|
13916
13916
|
You have used:
|
|
@@ -13938,7 +13938,7 @@
|
|
|
13938
13938
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
13939
13939
|
}
|
|
13940
13940
|
else {
|
|
13941
|
-
throw new ParseError(
|
|
13941
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
13942
13942
|
Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
|
|
13943
13943
|
|
|
13944
13944
|
You have used:
|
|
@@ -13948,7 +13948,7 @@
|
|
|
13948
13948
|
}
|
|
13949
13949
|
}
|
|
13950
13950
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
13951
|
-
console.log(
|
|
13951
|
+
console.log(_spaceTrim.spaceTrim(`
|
|
13952
13952
|
Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
|
|
13953
13953
|
|
|
13954
13954
|
In pipeline head:
|
|
@@ -14031,7 +14031,7 @@
|
|
|
14031
14031
|
// <- TODO: When [🥶] fixed, change to:
|
|
14032
14032
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
14033
14033
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
14034
|
-
throw new ParseError(
|
|
14034
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
14035
14035
|
Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
|
|
14036
14036
|
|
|
14037
14037
|
The description:
|
|
@@ -14213,7 +14213,7 @@
|
|
|
14213
14213
|
persona.description = personaDescription;
|
|
14214
14214
|
return;
|
|
14215
14215
|
}
|
|
14216
|
-
console.warn(
|
|
14216
|
+
console.warn(_spaceTrim.spaceTrim(`
|
|
14217
14217
|
|
|
14218
14218
|
Persona "${personaName}" is defined multiple times with different description:
|
|
14219
14219
|
|
|
@@ -14224,7 +14224,7 @@
|
|
|
14224
14224
|
${personaDescription}
|
|
14225
14225
|
|
|
14226
14226
|
`));
|
|
14227
|
-
persona.description +=
|
|
14227
|
+
persona.description += _spaceTrim.spaceTrim('\n\n' + personaDescription);
|
|
14228
14228
|
}
|
|
14229
14229
|
|
|
14230
14230
|
/**
|
|
@@ -14575,7 +14575,7 @@
|
|
|
14575
14575
|
function getParserForCommand(command) {
|
|
14576
14576
|
const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
|
|
14577
14577
|
if (commandParser === undefined) {
|
|
14578
|
-
throw new UnexpectedError(
|
|
14578
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
14579
14579
|
Command ${command.type} parser is not found
|
|
14580
14580
|
|
|
14581
14581
|
${block(JSON.stringify(command, null, 4)
|
|
@@ -14651,7 +14651,7 @@
|
|
|
14651
14651
|
.map(removeMarkdownFormatting)
|
|
14652
14652
|
.map((item) => item.trim());
|
|
14653
14653
|
if (items.length === 0 || items[0] === '') {
|
|
14654
|
-
throw new ParseError(
|
|
14654
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
14655
14655
|
Malformed command:
|
|
14656
14656
|
- ${raw}
|
|
14657
14657
|
|
|
@@ -14687,7 +14687,7 @@
|
|
|
14687
14687
|
return command;
|
|
14688
14688
|
}
|
|
14689
14689
|
}
|
|
14690
|
-
throw new ParseError(
|
|
14690
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
14691
14691
|
Malformed or unknown command:
|
|
14692
14692
|
- ${raw}
|
|
14693
14693
|
|
|
@@ -14738,7 +14738,7 @@
|
|
|
14738
14738
|
if (!(error instanceof ParseError)) {
|
|
14739
14739
|
throw error;
|
|
14740
14740
|
}
|
|
14741
|
-
throw new ParseError(
|
|
14741
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
14742
14742
|
Invalid ${commandName} command:
|
|
14743
14743
|
|
|
14744
14744
|
Your command:
|
|
@@ -15054,7 +15054,7 @@
|
|
|
15054
15054
|
* @public exported from `@promptbook/markdown-utils`
|
|
15055
15055
|
*/
|
|
15056
15056
|
function removeMarkdownComments(content) {
|
|
15057
|
-
return
|
|
15057
|
+
return _spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
15058
15058
|
}
|
|
15059
15059
|
|
|
15060
15060
|
/**
|
|
@@ -15065,7 +15065,7 @@
|
|
|
15065
15065
|
*/
|
|
15066
15066
|
function isFlatPipeline(pipelineString) {
|
|
15067
15067
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
15068
|
-
pipelineString =
|
|
15068
|
+
pipelineString = _spaceTrim.spaceTrim(pipelineString);
|
|
15069
15069
|
const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
15070
15070
|
//const isLastLineReturnStatement = pipelineString.split(/\r?\n/).pop()!.split('`').join('').startsWith('->');
|
|
15071
15071
|
const isBacktickBlockUsed = pipelineString.includes('```');
|
|
@@ -15091,7 +15091,7 @@
|
|
|
15091
15091
|
if (!isFlatPipeline(pipelineString)) {
|
|
15092
15092
|
return pipelineString;
|
|
15093
15093
|
}
|
|
15094
|
-
pipelineString =
|
|
15094
|
+
pipelineString = _spaceTrim.spaceTrim(pipelineString);
|
|
15095
15095
|
const pipelineStringLines = pipelineString.split(/\r?\n/);
|
|
15096
15096
|
const potentialReturnStatement = pipelineStringLines.pop();
|
|
15097
15097
|
let returnStatement;
|
|
@@ -15104,19 +15104,19 @@
|
|
|
15104
15104
|
returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
|
|
15105
15105
|
pipelineStringLines.push(potentialReturnStatement);
|
|
15106
15106
|
}
|
|
15107
|
-
const prompt =
|
|
15107
|
+
const prompt = _spaceTrim.spaceTrim(pipelineStringLines.join('\n'));
|
|
15108
15108
|
let quotedPrompt;
|
|
15109
15109
|
if (prompt.split(/\r?\n/).length <= 1) {
|
|
15110
15110
|
quotedPrompt = `> ${prompt}`;
|
|
15111
15111
|
}
|
|
15112
15112
|
else {
|
|
15113
|
-
quotedPrompt =
|
|
15113
|
+
quotedPrompt = _spaceTrim.spaceTrim((block) => `
|
|
15114
15114
|
\`\`\`
|
|
15115
15115
|
${block(prompt.split('`').join('\\`'))}
|
|
15116
15116
|
\`\`\`
|
|
15117
15117
|
`);
|
|
15118
15118
|
}
|
|
15119
|
-
pipelineString = validatePipelineString(
|
|
15119
|
+
pipelineString = validatePipelineString(_spaceTrim.spaceTrim((block) => `
|
|
15120
15120
|
# ${DEFAULT_BOOK_TITLE}
|
|
15121
15121
|
|
|
15122
15122
|
## Prompt
|
|
@@ -15180,7 +15180,7 @@
|
|
|
15180
15180
|
function extractOneBlockFromMarkdown(markdown) {
|
|
15181
15181
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
15182
15182
|
if (codeBlocks.length !== 1) {
|
|
15183
|
-
throw new ParseError(
|
|
15183
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15184
15184
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
15185
15185
|
|
|
15186
15186
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -15205,7 +15205,7 @@
|
|
|
15205
15205
|
}
|
|
15206
15206
|
const title = lines[0].replace(/^#+\s*/, '');
|
|
15207
15207
|
const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
15208
|
-
const content =
|
|
15208
|
+
const content = _spaceTrim.spaceTrim(lines.slice(1).join('\n'));
|
|
15209
15209
|
if (level < 1 || level > 6) {
|
|
15210
15210
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
15211
15211
|
}
|
|
@@ -15233,7 +15233,7 @@
|
|
|
15233
15233
|
if (buffer.length === 0) {
|
|
15234
15234
|
return;
|
|
15235
15235
|
}
|
|
15236
|
-
let section =
|
|
15236
|
+
let section = _spaceTrim.spaceTrim(buffer.join('\n'));
|
|
15237
15237
|
if (section === '') {
|
|
15238
15238
|
return;
|
|
15239
15239
|
}
|
|
@@ -15308,7 +15308,7 @@
|
|
|
15308
15308
|
flattenedMarkdown += `## ${title}` + `\n\n`;
|
|
15309
15309
|
flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
|
|
15310
15310
|
}
|
|
15311
|
-
return
|
|
15311
|
+
return _spaceTrim.spaceTrim(flattenedMarkdown);
|
|
15312
15312
|
}
|
|
15313
15313
|
/**
|
|
15314
15314
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -15370,7 +15370,7 @@
|
|
|
15370
15370
|
if (pipelineString.startsWith('#!')) {
|
|
15371
15371
|
const [shebangLine, ...restLines] = pipelineString.split(/\r?\n/);
|
|
15372
15372
|
if (!(shebangLine || '').includes('ptbk')) {
|
|
15373
|
-
throw new ParseError(
|
|
15373
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15374
15374
|
It seems that you try to parse a book file which has non-standard shebang line for book files:
|
|
15375
15375
|
Shebang line must contain 'ptbk'
|
|
15376
15376
|
|
|
@@ -15386,7 +15386,7 @@
|
|
|
15386
15386
|
pipelineString = validatePipelineString(restLines.join('\n'));
|
|
15387
15387
|
}
|
|
15388
15388
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
15389
|
-
pipelineString =
|
|
15389
|
+
pipelineString = _spaceTrim.spaceTrim(pipelineString);
|
|
15390
15390
|
// <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
|
|
15391
15391
|
pipelineString = deflatePipeline(pipelineString);
|
|
15392
15392
|
// ==============
|
|
@@ -15398,7 +15398,7 @@
|
|
|
15398
15398
|
// ==============
|
|
15399
15399
|
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
15400
15400
|
if (pipelineHead === undefined) {
|
|
15401
|
-
throw new UnexpectedError(
|
|
15401
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
15402
15402
|
Pipeline head is not defined
|
|
15403
15403
|
|
|
15404
15404
|
${block(getPipelineIdentification())}
|
|
@@ -15407,7 +15407,7 @@
|
|
|
15407
15407
|
`));
|
|
15408
15408
|
}
|
|
15409
15409
|
if (pipelineHead.level !== 1) {
|
|
15410
|
-
throw new UnexpectedError(
|
|
15410
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
15411
15411
|
Pipeline head is not h1
|
|
15412
15412
|
|
|
15413
15413
|
${block(getPipelineIdentification())}
|
|
@@ -15416,7 +15416,7 @@
|
|
|
15416
15416
|
`));
|
|
15417
15417
|
}
|
|
15418
15418
|
if (!pipelineSections.every((section) => section.level === 2)) {
|
|
15419
|
-
throw new UnexpectedError(
|
|
15419
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
15420
15420
|
Not every pipeline section is h2
|
|
15421
15421
|
|
|
15422
15422
|
${block(getPipelineIdentification())}
|
|
@@ -15429,7 +15429,7 @@
|
|
|
15429
15429
|
const defineParam = (parameterCommand) => {
|
|
15430
15430
|
const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
|
|
15431
15431
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
15432
|
-
throw new ParseError(
|
|
15432
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15433
15433
|
Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
|
|
15434
15434
|
|
|
15435
15435
|
${block(getPipelineIdentification())}
|
|
@@ -15440,7 +15440,7 @@
|
|
|
15440
15440
|
existingParameter.description &&
|
|
15441
15441
|
existingParameter.description !== parameterDescription &&
|
|
15442
15442
|
parameterDescription) {
|
|
15443
|
-
throw new ParseError(
|
|
15443
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15444
15444
|
Parameter \`{${parameterName}}\` is defined multiple times with different description:
|
|
15445
15445
|
|
|
15446
15446
|
${block(getPipelineIdentification())}
|
|
@@ -15478,7 +15478,7 @@
|
|
|
15478
15478
|
description = description.split(/^>.*$/gm).join('');
|
|
15479
15479
|
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
15480
15480
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
15481
|
-
description =
|
|
15481
|
+
description = _spaceTrim.spaceTrim(description);
|
|
15482
15482
|
if (description === '') {
|
|
15483
15483
|
description = undefined;
|
|
15484
15484
|
}
|
|
@@ -15489,7 +15489,7 @@
|
|
|
15489
15489
|
const command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
15490
15490
|
const commandParser = getParserForCommand(command);
|
|
15491
15491
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
15492
|
-
throw new ParseError(
|
|
15492
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15493
15493
|
Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
|
|
15494
15494
|
|
|
15495
15495
|
${block(getPipelineIdentification())}
|
|
@@ -15503,7 +15503,7 @@
|
|
|
15503
15503
|
if (!(error instanceof ParseError)) {
|
|
15504
15504
|
throw error;
|
|
15505
15505
|
}
|
|
15506
|
-
throw new ParseError(
|
|
15506
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15507
15507
|
Command ${command.type} failed to apply to the pipeline
|
|
15508
15508
|
|
|
15509
15509
|
The error:
|
|
@@ -15556,7 +15556,7 @@
|
|
|
15556
15556
|
description = description.split(/^>.*$/gm).join('');
|
|
15557
15557
|
//Note: Remove lists and return statement - TODO: [🎾]
|
|
15558
15558
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
15559
|
-
description =
|
|
15559
|
+
description = _spaceTrim.spaceTrim(description);
|
|
15560
15560
|
if (description === '') {
|
|
15561
15561
|
description = undefined;
|
|
15562
15562
|
}
|
|
@@ -15590,7 +15590,7 @@
|
|
|
15590
15590
|
for (const { listItem, command } of commands) {
|
|
15591
15591
|
const commandParser = getParserForCommand(command);
|
|
15592
15592
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
15593
|
-
throw new ParseError(
|
|
15593
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15594
15594
|
Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
|
|
15595
15595
|
|
|
15596
15596
|
${block(getPipelineIdentification())}
|
|
@@ -15605,7 +15605,7 @@
|
|
|
15605
15605
|
if (!(error instanceof ParseError)) {
|
|
15606
15606
|
throw error;
|
|
15607
15607
|
}
|
|
15608
|
-
throw new ParseError(
|
|
15608
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15609
15609
|
Command \`${command.type}\` failed to apply to the task
|
|
15610
15610
|
|
|
15611
15611
|
The error:
|
|
@@ -15636,14 +15636,14 @@
|
|
|
15636
15636
|
// TODO: [🍧] Should be done in SECTION command
|
|
15637
15637
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
15638
15638
|
if (!language) {
|
|
15639
|
-
throw new ParseError(
|
|
15639
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15640
15640
|
You must specify the language of the script in the \`SCRIPT\` task
|
|
15641
15641
|
|
|
15642
15642
|
${block(getPipelineIdentification())}
|
|
15643
15643
|
`));
|
|
15644
15644
|
}
|
|
15645
15645
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
15646
|
-
throw new ParseError(
|
|
15646
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
15647
15647
|
Script language ${language} is not supported.
|
|
15648
15648
|
|
|
15649
15649
|
Supported languages are:
|
|
@@ -15959,8 +15959,8 @@
|
|
|
15959
15959
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
15960
15960
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
15961
15961
|
let name = `piece-${i}`;
|
|
15962
|
-
let title =
|
|
15963
|
-
const knowledgePieceContent =
|
|
15962
|
+
let title = _spaceTrim.spaceTrim(knowledgeTextPiece.substring(0, 100));
|
|
15963
|
+
const knowledgePieceContent = _spaceTrim.spaceTrim(knowledgeTextPiece);
|
|
15964
15964
|
let keywords = [];
|
|
15965
15965
|
const index = [];
|
|
15966
15966
|
/*
|
|
@@ -15973,7 +15973,7 @@
|
|
|
15973
15973
|
isCrashedOnError: true,
|
|
15974
15974
|
});
|
|
15975
15975
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
15976
|
-
title =
|
|
15976
|
+
title = _spaceTrim.spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
15977
15977
|
name = titleToName(title);
|
|
15978
15978
|
// --- Keywords
|
|
15979
15979
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
@@ -16243,7 +16243,7 @@
|
|
|
16243
16243
|
if (mimeType === 'application/pdf' || url.toLowerCase().endsWith('.pdf')) {
|
|
16244
16244
|
// TODO: [🔰] Implement PDF scraping using PdfScraper
|
|
16245
16245
|
// For now, return a message indicating PDF support is coming
|
|
16246
|
-
return
|
|
16246
|
+
return _spaceTrim.spaceTrim(`
|
|
16247
16247
|
# PDF Document: ${parsedUrl.pathname.split('/').pop()}
|
|
16248
16248
|
|
|
16249
16249
|
**Note:** PDF scraping is not yet fully implemented.
|
|
@@ -16283,7 +16283,7 @@
|
|
|
16283
16283
|
// Clean up intermediate files
|
|
16284
16284
|
await intermediateSource.destroy();
|
|
16285
16285
|
// Add URL header to the content
|
|
16286
|
-
return
|
|
16286
|
+
return _spaceTrim.spaceTrim(`
|
|
16287
16287
|
# Content from: ${url}
|
|
16288
16288
|
|
|
16289
16289
|
${markdown}
|
|
@@ -16294,7 +16294,7 @@
|
|
|
16294
16294
|
`);
|
|
16295
16295
|
}
|
|
16296
16296
|
// For other content types, return the raw content with a note
|
|
16297
|
-
return
|
|
16297
|
+
return _spaceTrim.spaceTrim(`
|
|
16298
16298
|
# Content from: ${url}
|
|
16299
16299
|
|
|
16300
16300
|
**Content Type:** ${contentType}
|
|
@@ -16309,7 +16309,7 @@
|
|
|
16309
16309
|
catch (error) {
|
|
16310
16310
|
// Handle errors gracefully
|
|
16311
16311
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
16312
|
-
return
|
|
16312
|
+
return _spaceTrim.spaceTrim(`
|
|
16313
16313
|
# Error fetching content from URL
|
|
16314
16314
|
|
|
16315
16315
|
**URL:** ${url}
|
|
@@ -16381,7 +16381,7 @@
|
|
|
16381
16381
|
}
|
|
16382
16382
|
catch (error) {
|
|
16383
16383
|
assertsError(error);
|
|
16384
|
-
throw new EnvironmentMismatchError(
|
|
16384
|
+
throw new EnvironmentMismatchError(_spaceTrim.spaceTrim((block) => `
|
|
16385
16385
|
\`run_browser\` tool is not available in this environment.
|
|
16386
16386
|
This commitment requires the Agents Server browser runtime with Playwright CLI.
|
|
16387
16387
|
|
|
@@ -16415,7 +16415,7 @@
|
|
|
16415
16415
|
? error
|
|
16416
16416
|
: new Error(typeof error === 'string' ? error : JSON.stringify(error !== null && error !== void 0 ? error : 'Unknown error'));
|
|
16417
16417
|
return async () => {
|
|
16418
|
-
throw new EnvironmentMismatchError(
|
|
16418
|
+
throw new EnvironmentMismatchError(_spaceTrim.spaceTrim((block) => `
|
|
16419
16419
|
\`send_email\` tool is not available in this environment.
|
|
16420
16420
|
This commitment requires Agents Server runtime with wallet-backed SMTP sending.
|
|
16421
16421
|
|
|
@@ -16447,7 +16447,7 @@
|
|
|
16447
16447
|
? error
|
|
16448
16448
|
: new Error(typeof error === 'string' ? error : JSON.stringify(error !== null && error !== void 0 ? error : 'Unknown error'));
|
|
16449
16449
|
return async () => {
|
|
16450
|
-
throw new EnvironmentMismatchError(
|
|
16450
|
+
throw new EnvironmentMismatchError(_spaceTrim.spaceTrim((block) => `
|
|
16451
16451
|
\`spawn_agent\` tool is not available in this environment.
|
|
16452
16452
|
This commitment requires Agents Server runtime with agent persistence enabled.
|
|
16453
16453
|
|
|
@@ -16667,7 +16667,7 @@
|
|
|
16667
16667
|
* Markdown documentation for ACTION commitment.
|
|
16668
16668
|
*/
|
|
16669
16669
|
get documentation() {
|
|
16670
|
-
return
|
|
16670
|
+
return _spaceTrim.spaceTrim(`
|
|
16671
16671
|
# ${this.type}
|
|
16672
16672
|
|
|
16673
16673
|
Defines specific actions or capabilities that the agent can perform.
|
|
@@ -16754,7 +16754,7 @@
|
|
|
16754
16754
|
* Markdown documentation for CLOSED commitment.
|
|
16755
16755
|
*/
|
|
16756
16756
|
get documentation() {
|
|
16757
|
-
return
|
|
16757
|
+
return _spaceTrim.spaceTrim(`
|
|
16758
16758
|
# CLOSED
|
|
16759
16759
|
|
|
16760
16760
|
Specifies that the agent **cannot** be modified by conversation with it.
|
|
@@ -16809,7 +16809,7 @@
|
|
|
16809
16809
|
* Markdown documentation for COMPONENT commitment.
|
|
16810
16810
|
*/
|
|
16811
16811
|
get documentation() {
|
|
16812
|
-
return
|
|
16812
|
+
return _spaceTrim.spaceTrim(`
|
|
16813
16813
|
# COMPONENT
|
|
16814
16814
|
|
|
16815
16815
|
Defines a UI component that the agent can render in the chat.
|
|
@@ -16881,7 +16881,7 @@
|
|
|
16881
16881
|
* Markdown documentation for DELETE commitment.
|
|
16882
16882
|
*/
|
|
16883
16883
|
get documentation() {
|
|
16884
|
-
return
|
|
16884
|
+
return _spaceTrim.spaceTrim(`
|
|
16885
16885
|
# DELETE (CANCEL, DISCARD, REMOVE)
|
|
16886
16886
|
|
|
16887
16887
|
A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
|
|
@@ -17012,7 +17012,7 @@
|
|
|
17012
17012
|
* Markdown documentation for DICTIONARY commitment.
|
|
17013
17013
|
*/
|
|
17014
17014
|
get documentation() {
|
|
17015
|
-
return
|
|
17015
|
+
return _spaceTrim.spaceTrim(`
|
|
17016
17016
|
# DICTIONARY
|
|
17017
17017
|
|
|
17018
17018
|
Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
|
|
@@ -17109,7 +17109,7 @@
|
|
|
17109
17109
|
* Markdown documentation for FORMAT commitment.
|
|
17110
17110
|
*/
|
|
17111
17111
|
get documentation() {
|
|
17112
|
-
return
|
|
17112
|
+
return _spaceTrim.spaceTrim(`
|
|
17113
17113
|
# ${this.type}
|
|
17114
17114
|
|
|
17115
17115
|
Defines the specific output structure and formatting for responses (data formats, templates, structure).
|
|
@@ -17405,7 +17405,7 @@
|
|
|
17405
17405
|
* Markdown documentation for FROM commitment.
|
|
17406
17406
|
*/
|
|
17407
17407
|
get documentation() {
|
|
17408
|
-
return
|
|
17408
|
+
return _spaceTrim.spaceTrim(`
|
|
17409
17409
|
# ${this.type}
|
|
17410
17410
|
|
|
17411
17411
|
Inherits agent source from another agent.
|
|
@@ -17432,7 +17432,7 @@
|
|
|
17432
17432
|
};
|
|
17433
17433
|
}
|
|
17434
17434
|
if (!isValidAgentUrl(trimmedContent)) {
|
|
17435
|
-
throw new Error(
|
|
17435
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
17436
17436
|
Invalid agent URL in FROM commitment: "${trimmedContent}"
|
|
17437
17437
|
|
|
17438
17438
|
\`\`\`book
|
|
@@ -17489,7 +17489,7 @@
|
|
|
17489
17489
|
* Markdown documentation for GOAL commitment.
|
|
17490
17490
|
*/
|
|
17491
17491
|
get documentation() {
|
|
17492
|
-
return
|
|
17492
|
+
return _spaceTrim.spaceTrim(`
|
|
17493
17493
|
# ${this.type}
|
|
17494
17494
|
|
|
17495
17495
|
Defines the main goal which should be achieved by the AI assistant. There can be multiple goals, and later goals are more important than earlier goals.
|
|
@@ -17586,7 +17586,7 @@
|
|
|
17586
17586
|
* Markdown documentation for IMPORT commitment.
|
|
17587
17587
|
*/
|
|
17588
17588
|
get documentation() {
|
|
17589
|
-
return
|
|
17589
|
+
return _spaceTrim.spaceTrim(`
|
|
17590
17590
|
# ${this.type}
|
|
17591
17591
|
|
|
17592
17592
|
Imports content from another agent or a generic text file at the location of the commitment.
|
|
@@ -17621,7 +17621,7 @@
|
|
|
17621
17621
|
importedFileUrls: [...(requirements.importedFileUrls || []), trimmedContent],
|
|
17622
17622
|
};
|
|
17623
17623
|
}
|
|
17624
|
-
throw new Error(
|
|
17624
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
17625
17625
|
Invalid agent URL or file path in IMPORT commitment: "${trimmedContent}"
|
|
17626
17626
|
|
|
17627
17627
|
\`\`\`book
|
|
@@ -17875,7 +17875,7 @@
|
|
|
17875
17875
|
* Markdown documentation for KNOWLEDGE commitment.
|
|
17876
17876
|
*/
|
|
17877
17877
|
get documentation() {
|
|
17878
|
-
return
|
|
17878
|
+
return _spaceTrim.spaceTrim(`
|
|
17879
17879
|
# ${this.type}
|
|
17880
17880
|
|
|
17881
17881
|
Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
|
|
@@ -18003,7 +18003,7 @@
|
|
|
18003
18003
|
* Markdown documentation for LANGUAGE/LANGUAGES commitment.
|
|
18004
18004
|
*/
|
|
18005
18005
|
get documentation() {
|
|
18006
|
-
return
|
|
18006
|
+
return _spaceTrim.spaceTrim(`
|
|
18007
18007
|
# ${this.type}
|
|
18008
18008
|
|
|
18009
18009
|
Specifies the language(s) the agent should use in its responses.
|
|
@@ -18032,7 +18032,7 @@
|
|
|
18032
18032
|
return requirements;
|
|
18033
18033
|
}
|
|
18034
18034
|
// Add language rule to the system message
|
|
18035
|
-
const languageSection = this.createSystemMessageSection('Language:',
|
|
18035
|
+
const languageSection = this.createSystemMessageSection('Language:', _spaceTrim.spaceTrim((block) => `
|
|
18036
18036
|
${block(trimmedContent)}
|
|
18037
18037
|
<- You are speaking these languages in your responses to the user.
|
|
18038
18038
|
`));
|
|
@@ -18049,11 +18049,11 @@
|
|
|
18049
18049
|
* @private utility for commitments
|
|
18050
18050
|
*/
|
|
18051
18051
|
function formatOptionalInstructionBlock(label, content) {
|
|
18052
|
-
const trimmedContent =
|
|
18052
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
18053
18053
|
if (!trimmedContent) {
|
|
18054
18054
|
return '';
|
|
18055
18055
|
}
|
|
18056
|
-
return
|
|
18056
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
18057
18057
|
- ${label}:
|
|
18058
18058
|
${block(trimmedContent
|
|
18059
18059
|
.split(/\r?\n/)
|
|
@@ -18080,7 +18080,7 @@
|
|
|
18080
18080
|
* @private function of MemoryCommitmentDefinition
|
|
18081
18081
|
*/
|
|
18082
18082
|
function createMemorySystemMessage(extraInstructions) {
|
|
18083
|
-
return
|
|
18083
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
18084
18084
|
Memory:
|
|
18085
18085
|
- Prefer storing agent-scoped memories; only make them global when the fact should apply across all your agents.
|
|
18086
18086
|
- You can use persistent user memory tools.
|
|
@@ -18470,7 +18470,7 @@
|
|
|
18470
18470
|
if (!tools.some((tool) => tool.name === MemoryToolNames.retrieve)) {
|
|
18471
18471
|
tools.push({
|
|
18472
18472
|
name: MemoryToolNames.retrieve,
|
|
18473
|
-
description:
|
|
18473
|
+
description: _spaceTrim.spaceTrim(`
|
|
18474
18474
|
Retrieve previously stored user memories relevant to the current conversation.
|
|
18475
18475
|
Use this before responding when user context can improve the answer.
|
|
18476
18476
|
`),
|
|
@@ -18492,7 +18492,7 @@
|
|
|
18492
18492
|
if (!tools.some((tool) => tool.name === MemoryToolNames.store)) {
|
|
18493
18493
|
tools.push({
|
|
18494
18494
|
name: MemoryToolNames.store,
|
|
18495
|
-
description:
|
|
18495
|
+
description: _spaceTrim.spaceTrim(`
|
|
18496
18496
|
Store a durable user memory that should be remembered in future conversations.
|
|
18497
18497
|
Store only stable and useful user-specific facts or preferences.
|
|
18498
18498
|
`),
|
|
@@ -18515,7 +18515,7 @@
|
|
|
18515
18515
|
if (!tools.some((tool) => tool.name === MemoryToolNames.update)) {
|
|
18516
18516
|
tools.push({
|
|
18517
18517
|
name: MemoryToolNames.update,
|
|
18518
|
-
description:
|
|
18518
|
+
description: _spaceTrim.spaceTrim(`
|
|
18519
18519
|
Update an existing user memory after retrieving it, so the stored fact stays accurate.
|
|
18520
18520
|
Always pass the memory id you retrieved along with the new content.
|
|
18521
18521
|
`),
|
|
@@ -18542,7 +18542,7 @@
|
|
|
18542
18542
|
if (!tools.some((tool) => tool.name === MemoryToolNames.delete)) {
|
|
18543
18543
|
tools.push({
|
|
18544
18544
|
name: MemoryToolNames.delete,
|
|
18545
|
-
description:
|
|
18545
|
+
description: _spaceTrim.spaceTrim(`
|
|
18546
18546
|
Delete a user memory that is no longer relevant. Deletions are soft so the record is hidden from future queries.
|
|
18547
18547
|
`),
|
|
18548
18548
|
parameters: {
|
|
@@ -18566,7 +18566,7 @@
|
|
|
18566
18566
|
* @private function of MemoryCommitmentDefinition
|
|
18567
18567
|
*/
|
|
18568
18568
|
function getMemoryCommitmentDocumentation(type) {
|
|
18569
|
-
return
|
|
18569
|
+
return _spaceTrim.spaceTrim(`
|
|
18570
18570
|
# ${type}
|
|
18571
18571
|
|
|
18572
18572
|
Enables persistent user memory for the current agent. The memory is stored by the runtime and can be retrieved in future conversations.
|
|
@@ -18725,7 +18725,7 @@
|
|
|
18725
18725
|
* Markdown documentation for AGENT MESSAGE commitment.
|
|
18726
18726
|
*/
|
|
18727
18727
|
get documentation() {
|
|
18728
|
-
return
|
|
18728
|
+
return _spaceTrim.spaceTrim(`
|
|
18729
18729
|
# ${this.type}
|
|
18730
18730
|
|
|
18731
18731
|
Defines a message from the agent in the conversation history. This is used to pre-fill the chat with a conversation history or to provide few-shot examples.
|
|
@@ -18802,7 +18802,7 @@
|
|
|
18802
18802
|
* Markdown documentation for INITIAL MESSAGE commitment.
|
|
18803
18803
|
*/
|
|
18804
18804
|
get documentation() {
|
|
18805
|
-
return
|
|
18805
|
+
return _spaceTrim.spaceTrim(`
|
|
18806
18806
|
# ${this.type}
|
|
18807
18807
|
|
|
18808
18808
|
Defines the first message that the user sees when opening the chat. This message is purely for display purposes in the UI and does not inherently become part of the LLM's system prompt context (unless also included via other means).
|
|
@@ -18869,7 +18869,7 @@
|
|
|
18869
18869
|
* Markdown documentation for INTERNAL MESSAGE commitment.
|
|
18870
18870
|
*/
|
|
18871
18871
|
get documentation() {
|
|
18872
|
-
return
|
|
18872
|
+
return _spaceTrim.spaceTrim(`
|
|
18873
18873
|
# ${this.type}
|
|
18874
18874
|
|
|
18875
18875
|
Defines an internal trace message related to one interaction. This is intended mainly for self-learning analytics and future training datasets.
|
|
@@ -18945,7 +18945,7 @@
|
|
|
18945
18945
|
* Markdown documentation for MESSAGE commitment.
|
|
18946
18946
|
*/
|
|
18947
18947
|
get documentation() {
|
|
18948
|
-
return
|
|
18948
|
+
return _spaceTrim.spaceTrim(`
|
|
18949
18949
|
# ${this.type}
|
|
18950
18950
|
|
|
18951
18951
|
Contains 1:1 text of the message which AI assistant already sent during the conversation. Later messages are later in the conversation. It is similar to \`WRITING SAMPLE\`, but it is not a sample. It is the real message which the AI assistant already sent.
|
|
@@ -19057,7 +19057,7 @@
|
|
|
19057
19057
|
* Markdown documentation for USER MESSAGE commitment.
|
|
19058
19058
|
*/
|
|
19059
19059
|
get documentation() {
|
|
19060
|
-
return
|
|
19060
|
+
return _spaceTrim.spaceTrim(`
|
|
19061
19061
|
# ${this.type}
|
|
19062
19062
|
|
|
19063
19063
|
Defines a message from the user in the conversation history. This is used to pre-fill the chat with a conversation history or to provide few-shot examples.
|
|
@@ -19124,7 +19124,7 @@
|
|
|
19124
19124
|
* Markdown documentation for MESSAGE SUFFIX commitment.
|
|
19125
19125
|
*/
|
|
19126
19126
|
get documentation() {
|
|
19127
|
-
return
|
|
19127
|
+
return _spaceTrim.spaceTrim(`
|
|
19128
19128
|
# MESSAGE SUFFIX
|
|
19129
19129
|
|
|
19130
19130
|
Defines a hardcoded message appended to every assistant response.
|
|
@@ -19206,7 +19206,7 @@
|
|
|
19206
19206
|
* Markdown documentation for META commitment.
|
|
19207
19207
|
*/
|
|
19208
19208
|
get documentation() {
|
|
19209
|
-
return
|
|
19209
|
+
return _spaceTrim.spaceTrim(`
|
|
19210
19210
|
# META
|
|
19211
19211
|
|
|
19212
19212
|
Sets meta-information about the agent that is used for display and attribution purposes.
|
|
@@ -19347,7 +19347,7 @@
|
|
|
19347
19347
|
* Markdown documentation for META COLOR commitment.
|
|
19348
19348
|
*/
|
|
19349
19349
|
get documentation() {
|
|
19350
|
-
return
|
|
19350
|
+
return _spaceTrim.spaceTrim(`
|
|
19351
19351
|
# META COLOR
|
|
19352
19352
|
|
|
19353
19353
|
Sets the agent's accent color or gradient.
|
|
@@ -19431,7 +19431,7 @@
|
|
|
19431
19431
|
* Markdown documentation for META DOMAIN commitment.
|
|
19432
19432
|
*/
|
|
19433
19433
|
get documentation() {
|
|
19434
|
-
return
|
|
19434
|
+
return _spaceTrim.spaceTrim(`
|
|
19435
19435
|
# META DOMAIN
|
|
19436
19436
|
|
|
19437
19437
|
Sets the canonical domain (host) of the agent, for example a custom domain that should open this agent directly.
|
|
@@ -19506,7 +19506,7 @@
|
|
|
19506
19506
|
* Markdown documentation for META DISCLAIMER commitment.
|
|
19507
19507
|
*/
|
|
19508
19508
|
get documentation() {
|
|
19509
|
-
return
|
|
19509
|
+
return _spaceTrim.spaceTrim(`
|
|
19510
19510
|
# META DISCLAIMER
|
|
19511
19511
|
|
|
19512
19512
|
Defines a markdown disclaimer shown to users before they can start chatting with the agent.
|
|
@@ -19576,7 +19576,7 @@
|
|
|
19576
19576
|
* Markdown documentation for META FONT commitment.
|
|
19577
19577
|
*/
|
|
19578
19578
|
get documentation() {
|
|
19579
|
-
return
|
|
19579
|
+
return _spaceTrim.spaceTrim(`
|
|
19580
19580
|
# META FONT
|
|
19581
19581
|
|
|
19582
19582
|
Sets the agent's font.
|
|
@@ -19661,7 +19661,7 @@
|
|
|
19661
19661
|
* Markdown documentation for META IMAGE commitment.
|
|
19662
19662
|
*/
|
|
19663
19663
|
get documentation() {
|
|
19664
|
-
return
|
|
19664
|
+
return _spaceTrim.spaceTrim(`
|
|
19665
19665
|
# META IMAGE
|
|
19666
19666
|
|
|
19667
19667
|
Sets the agent's avatar/profile image URL.
|
|
@@ -19740,7 +19740,7 @@
|
|
|
19740
19740
|
* Markdown documentation for META INPUT PLACEHOLDER commitment.
|
|
19741
19741
|
*/
|
|
19742
19742
|
get documentation() {
|
|
19743
|
-
return
|
|
19743
|
+
return _spaceTrim.spaceTrim(`
|
|
19744
19744
|
# META INPUT PLACEHOLDER
|
|
19745
19745
|
|
|
19746
19746
|
Sets custom placeholder text for the chat input field.
|
|
@@ -19821,7 +19821,7 @@
|
|
|
19821
19821
|
* Markdown documentation for META LINK commitment.
|
|
19822
19822
|
*/
|
|
19823
19823
|
get documentation() {
|
|
19824
|
-
return
|
|
19824
|
+
return _spaceTrim.spaceTrim(`
|
|
19825
19825
|
# META LINK
|
|
19826
19826
|
|
|
19827
19827
|
Represents a profile or source link for the person the agent is modeled after.
|
|
@@ -19920,7 +19920,7 @@
|
|
|
19920
19920
|
* Markdown documentation for META VOICE commitment.
|
|
19921
19921
|
*/
|
|
19922
19922
|
get documentation() {
|
|
19923
|
-
return
|
|
19923
|
+
return _spaceTrim.spaceTrim(`
|
|
19924
19924
|
# META VOICE
|
|
19925
19925
|
|
|
19926
19926
|
Instructs the UI to use a specific ElevenLabs voice when reading this agent's replies aloud.
|
|
@@ -20002,7 +20002,7 @@
|
|
|
20002
20002
|
* Markdown documentation for MODEL commitment.
|
|
20003
20003
|
*/
|
|
20004
20004
|
get documentation() {
|
|
20005
|
-
return
|
|
20005
|
+
return _spaceTrim.spaceTrim(`
|
|
20006
20006
|
# ${this.type}
|
|
20007
20007
|
|
|
20008
20008
|
Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
|
|
@@ -20243,7 +20243,7 @@
|
|
|
20243
20243
|
* Markdown documentation for NOTE commitment.
|
|
20244
20244
|
*/
|
|
20245
20245
|
get documentation() {
|
|
20246
|
-
return
|
|
20246
|
+
return _spaceTrim.spaceTrim(`
|
|
20247
20247
|
# ${this.type}
|
|
20248
20248
|
|
|
20249
20249
|
Adds comments for documentation without changing agent behavior.
|
|
@@ -20282,7 +20282,7 @@
|
|
|
20282
20282
|
applyToAgentModelRequirements(requirements, content) {
|
|
20283
20283
|
// The NOTE commitment makes no changes to the system message or model requirements
|
|
20284
20284
|
// It only stores the note content in metadata for documentation purposes
|
|
20285
|
-
const trimmedContent =
|
|
20285
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
20286
20286
|
if (trimmedContent === '') {
|
|
20287
20287
|
return requirements;
|
|
20288
20288
|
}
|
|
@@ -20327,7 +20327,7 @@
|
|
|
20327
20327
|
* Markdown documentation for OPEN commitment.
|
|
20328
20328
|
*/
|
|
20329
20329
|
get documentation() {
|
|
20330
|
-
return
|
|
20330
|
+
return _spaceTrim.spaceTrim(`
|
|
20331
20331
|
# OPEN
|
|
20332
20332
|
|
|
20333
20333
|
Specifies that the agent can be modified by conversation with it.
|
|
@@ -20404,7 +20404,7 @@
|
|
|
20404
20404
|
* Markdown documentation for PERSONA commitment.
|
|
20405
20405
|
*/
|
|
20406
20406
|
get documentation() {
|
|
20407
|
-
return
|
|
20407
|
+
return _spaceTrim.spaceTrim(`
|
|
20408
20408
|
# ${this.type}
|
|
20409
20409
|
|
|
20410
20410
|
Defines who the agent is, their background, expertise, and personality traits.
|
|
@@ -20537,7 +20537,7 @@
|
|
|
20537
20537
|
* Markdown documentation for RULE/RULES commitment.
|
|
20538
20538
|
*/
|
|
20539
20539
|
get documentation() {
|
|
20540
|
-
return
|
|
20540
|
+
return _spaceTrim.spaceTrim(`
|
|
20541
20541
|
# ${this.type}
|
|
20542
20542
|
|
|
20543
20543
|
Adds behavioral constraints and guidelines that the agent must follow.
|
|
@@ -20601,7 +20601,7 @@
|
|
|
20601
20601
|
* @private internal utility of writing commitments
|
|
20602
20602
|
*/
|
|
20603
20603
|
function createWritingSampleSection(content) {
|
|
20604
|
-
return
|
|
20604
|
+
return _spaceTrim.spaceTrim(`
|
|
20605
20605
|
Use this as a 1:1 voice exemplar for how your replies should sound.
|
|
20606
20606
|
Treat it as sample-only guidance for voice, cadence, phrasing, and emotional texture, not as task-solving instructions.
|
|
20607
20607
|
If multiple writing samples exist, newer samples have higher weight than older ones.
|
|
@@ -20618,7 +20618,7 @@
|
|
|
20618
20618
|
* @private internal utility of writing commitments
|
|
20619
20619
|
*/
|
|
20620
20620
|
function createWritingRulesSection(content) {
|
|
20621
|
-
return
|
|
20621
|
+
return _spaceTrim.spaceTrim(`
|
|
20622
20622
|
These instructions apply only to how you write: tone, formatting, length, emoji usage, punctuation, and similar presentation choices.
|
|
20623
20623
|
They do not change your task-solving behavior, business logic, or factual decision-making rules.
|
|
20624
20624
|
If multiple writing-rules blocks conflict, prefer the newer writing-rules blocks.
|
|
@@ -20668,7 +20668,7 @@
|
|
|
20668
20668
|
* Markdown documentation for `SAMPLE` / `EXAMPLE`.
|
|
20669
20669
|
*/
|
|
20670
20670
|
get documentation() {
|
|
20671
|
-
return
|
|
20671
|
+
return _spaceTrim.spaceTrim(`
|
|
20672
20672
|
# ${this.type}
|
|
20673
20673
|
|
|
20674
20674
|
Deprecated legacy alias for \`WRITING SAMPLE\`.
|
|
@@ -20749,7 +20749,7 @@
|
|
|
20749
20749
|
* Markdown documentation for SCENARIO commitment.
|
|
20750
20750
|
*/
|
|
20751
20751
|
get documentation() {
|
|
20752
|
-
return
|
|
20752
|
+
return _spaceTrim.spaceTrim(`
|
|
20753
20753
|
# ${this.type}
|
|
20754
20754
|
|
|
20755
20755
|
Defines a specific situation or context in which the AI assistant should operate. It helps to set the scene for the AI's responses. Later scenarios are more important than earlier scenarios.
|
|
@@ -20871,7 +20871,7 @@
|
|
|
20871
20871
|
* Markdown documentation for STYLE commitment.
|
|
20872
20872
|
*/
|
|
20873
20873
|
get documentation() {
|
|
20874
|
-
return
|
|
20874
|
+
return _spaceTrim.spaceTrim(`
|
|
20875
20875
|
# ${this.type}
|
|
20876
20876
|
|
|
20877
20877
|
Defines how the agent should format and present its responses (tone, writing style, formatting).
|
|
@@ -21144,7 +21144,7 @@
|
|
|
21144
21144
|
* Markdown documentation for TEAM commitment.
|
|
21145
21145
|
*/
|
|
21146
21146
|
get documentation() {
|
|
21147
|
-
return
|
|
21147
|
+
return _spaceTrim.spaceTrim(`
|
|
21148
21148
|
# TEAM
|
|
21149
21149
|
|
|
21150
21150
|
Registers teammate agents that the current agent can consult via tools.
|
|
@@ -21510,7 +21510,7 @@
|
|
|
21510
21510
|
* Markdown documentation for TEMPLATE commitment.
|
|
21511
21511
|
*/
|
|
21512
21512
|
get documentation() {
|
|
21513
|
-
return
|
|
21513
|
+
return _spaceTrim.spaceTrim(`
|
|
21514
21514
|
# ${this.type}
|
|
21515
21515
|
|
|
21516
21516
|
Enforces a specific response structure or template that the agent must follow when generating responses.
|
|
@@ -21566,7 +21566,7 @@
|
|
|
21566
21566
|
templateMode: true,
|
|
21567
21567
|
};
|
|
21568
21568
|
// Add a general instruction about using structured templates
|
|
21569
|
-
const templateModeInstruction =
|
|
21569
|
+
const templateModeInstruction = _spaceTrim.spaceTrim(`
|
|
21570
21570
|
Use a clear, structured template format for your responses.
|
|
21571
21571
|
Maintain consistency in how you organize and present information.
|
|
21572
21572
|
`);
|
|
@@ -21637,7 +21637,7 @@
|
|
|
21637
21637
|
* Markdown documentation for USE commitment.
|
|
21638
21638
|
*/
|
|
21639
21639
|
get documentation() {
|
|
21640
|
-
return
|
|
21640
|
+
return _spaceTrim.spaceTrim(`
|
|
21641
21641
|
# USE
|
|
21642
21642
|
|
|
21643
21643
|
Enables the agent to use specific tools or capabilities for interacting with external systems.
|
|
@@ -21795,7 +21795,7 @@
|
|
|
21795
21795
|
* Markdown documentation for USE BROWSER commitment.
|
|
21796
21796
|
*/
|
|
21797
21797
|
get documentation() {
|
|
21798
|
-
return
|
|
21798
|
+
return _spaceTrim.spaceTrim(`
|
|
21799
21799
|
# USE BROWSER
|
|
21800
21800
|
|
|
21801
21801
|
Enables the agent to use browser tools to access and retrieve up-to-date information from the internet.
|
|
@@ -21858,7 +21858,7 @@
|
|
|
21858
21858
|
if (!existingTools.some((tool) => tool.name === 'fetch_url_content')) {
|
|
21859
21859
|
toolsToAdd.push({
|
|
21860
21860
|
name: 'fetch_url_content',
|
|
21861
|
-
description:
|
|
21861
|
+
description: _spaceTrim.spaceTrim(`
|
|
21862
21862
|
Fetches and scrapes the content from a URL (webpage or document).
|
|
21863
21863
|
This tool retrieves the content of the specified URL and converts it to markdown format.
|
|
21864
21864
|
Use this when you need to access information from a specific website or document.
|
|
@@ -21880,7 +21880,7 @@
|
|
|
21880
21880
|
if (!existingTools.some((tool) => tool.name === 'run_browser')) {
|
|
21881
21881
|
toolsToAdd.push({
|
|
21882
21882
|
name: 'run_browser',
|
|
21883
|
-
description:
|
|
21883
|
+
description: _spaceTrim.spaceTrim(`
|
|
21884
21884
|
Launches a browser session for complex interactions.
|
|
21885
21885
|
This tool is for advanced browser automation tasks like scrolling, clicking, form filling, etc.
|
|
21886
21886
|
Use this when simple one-shot URL fetching is not enough.
|
|
@@ -21927,7 +21927,7 @@
|
|
|
21927
21927
|
...requirements._metadata,
|
|
21928
21928
|
useBrowser: true,
|
|
21929
21929
|
},
|
|
21930
|
-
},
|
|
21930
|
+
}, _spaceTrim.spaceTrim(`
|
|
21931
21931
|
You have access to browser tools to fetch and access content from the internet.
|
|
21932
21932
|
- Use "fetch_url_content" to retrieve content from specific URLs (webpages or documents) using scrapers.
|
|
21933
21933
|
- Use "run_browser" for real interactive browser automation (navigation, clicks, typing, waiting, scrolling).
|
|
@@ -21959,7 +21959,7 @@
|
|
|
21959
21959
|
async run_browser(args) {
|
|
21960
21960
|
console.log('!!!! [Tool] run_browser called', { args });
|
|
21961
21961
|
const { url } = args;
|
|
21962
|
-
return
|
|
21962
|
+
return _spaceTrim.spaceTrim(`
|
|
21963
21963
|
# Running browser
|
|
21964
21964
|
|
|
21965
21965
|
The running browser tool is not available in this runtime.
|
|
@@ -22012,7 +22012,7 @@
|
|
|
22012
22012
|
return null;
|
|
22013
22013
|
}
|
|
22014
22014
|
if (!response.ok) {
|
|
22015
|
-
throw new Error(
|
|
22015
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
22016
22016
|
Google Calendar API request failed (${response.status} ${response.statusText}):
|
|
22017
22017
|
${extractGoogleCalendarApiErrorMessage(parsedPayload, textPayload)}
|
|
22018
22018
|
`));
|
|
@@ -22121,7 +22121,7 @@
|
|
|
22121
22121
|
* @private internal utility of USE CALENDAR commitment
|
|
22122
22122
|
*/
|
|
22123
22123
|
function parseUseCalendarCommitmentContent(content) {
|
|
22124
|
-
const trimmedContent =
|
|
22124
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
22125
22125
|
if (!trimmedContent) {
|
|
22126
22126
|
return {
|
|
22127
22127
|
calendar: null,
|
|
@@ -23101,7 +23101,7 @@
|
|
|
23101
23101
|
* Markdown documentation for USE CALENDAR commitment.
|
|
23102
23102
|
*/
|
|
23103
23103
|
get documentation() {
|
|
23104
|
-
return
|
|
23104
|
+
return _spaceTrim.spaceTrim(`
|
|
23105
23105
|
# USE CALENDAR
|
|
23106
23106
|
|
|
23107
23107
|
Enables the agent to access and manage one Google Calendar.
|
|
@@ -23158,7 +23158,7 @@
|
|
|
23158
23158
|
useCalendar: true,
|
|
23159
23159
|
useCalendars: existingConfiguredCalendars,
|
|
23160
23160
|
},
|
|
23161
|
-
},
|
|
23161
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
23162
23162
|
Calendar tools:
|
|
23163
23163
|
- You can inspect and manage events in configured calendars.
|
|
23164
23164
|
- Supported operations include read, create, update, delete, invite guests, and reminders.
|
|
@@ -23220,7 +23220,7 @@
|
|
|
23220
23220
|
* @private internal utility of USE EMAIL commitment
|
|
23221
23221
|
*/
|
|
23222
23222
|
function parseUseEmailCommitmentContent(content) {
|
|
23223
|
-
const trimmedContent =
|
|
23223
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
23224
23224
|
if (!trimmedContent) {
|
|
23225
23225
|
return {
|
|
23226
23226
|
senderEmail: null,
|
|
@@ -23349,7 +23349,7 @@
|
|
|
23349
23349
|
* Markdown documentation for USE EMAIL commitment.
|
|
23350
23350
|
*/
|
|
23351
23351
|
get documentation() {
|
|
23352
|
-
return
|
|
23352
|
+
return _spaceTrim.spaceTrim(`
|
|
23353
23353
|
# USE EMAIL
|
|
23354
23354
|
|
|
23355
23355
|
Enables the agent to send outbound emails through SMTP.
|
|
@@ -23391,7 +23391,7 @@
|
|
|
23391
23391
|
useEmail: true,
|
|
23392
23392
|
...(parsedCommitment.senderEmail ? { useEmailSender: parsedCommitment.senderEmail } : {}),
|
|
23393
23393
|
},
|
|
23394
|
-
},
|
|
23394
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
23395
23395
|
Email tool:
|
|
23396
23396
|
- Use "${SEND_EMAIL_TOOL_NAME}" to send outbound emails.
|
|
23397
23397
|
- Prefer \`message\` argument compatible with Promptbook \`Message\` type.
|
|
@@ -23509,7 +23509,7 @@
|
|
|
23509
23509
|
* Markdown documentation for USE IMAGE GENERATOR commitment.
|
|
23510
23510
|
*/
|
|
23511
23511
|
get documentation() {
|
|
23512
|
-
return
|
|
23512
|
+
return _spaceTrim.spaceTrim(`
|
|
23513
23513
|
# USE IMAGE GENERATOR
|
|
23514
23514
|
|
|
23515
23515
|
Enables the agent to output markdown image placeholders that trigger image generation in the user interface.
|
|
@@ -23548,7 +23548,7 @@
|
|
|
23548
23548
|
...requirements._metadata,
|
|
23549
23549
|
useImageGenerator: content || true,
|
|
23550
23550
|
},
|
|
23551
|
-
},
|
|
23551
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
23552
23552
|
Image generation:
|
|
23553
23553
|
- You do not generate images directly and you do not call any image tool.
|
|
23554
23554
|
- When the user asks for an image, include markdown notation in your message:
|
|
@@ -23600,7 +23600,7 @@
|
|
|
23600
23600
|
* Markdown documentation for USE MCP commitment.
|
|
23601
23601
|
*/
|
|
23602
23602
|
get documentation() {
|
|
23603
|
-
return
|
|
23603
|
+
return _spaceTrim.spaceTrim(`
|
|
23604
23604
|
# USE MCP
|
|
23605
23605
|
|
|
23606
23606
|
Connects the agent to an external Model Context Protocol (MCP) server.
|
|
@@ -23681,7 +23681,7 @@
|
|
|
23681
23681
|
* Markdown documentation for USE POPUP commitment.
|
|
23682
23682
|
*/
|
|
23683
23683
|
get documentation() {
|
|
23684
|
-
return
|
|
23684
|
+
return _spaceTrim.spaceTrim(`
|
|
23685
23685
|
# USE POPUP
|
|
23686
23686
|
|
|
23687
23687
|
Enables the agent to open a popup window with a specific website.
|
|
@@ -23713,7 +23713,7 @@
|
|
|
23713
23713
|
...existingTools,
|
|
23714
23714
|
{
|
|
23715
23715
|
name: 'open_popup',
|
|
23716
|
-
description:
|
|
23716
|
+
description: _spaceTrim.spaceTrim(`
|
|
23717
23717
|
Opens a popup window with a specific URL.
|
|
23718
23718
|
Use this when you want to show a specific website to the user in a new window.
|
|
23719
23719
|
${!content ? '' : `Constraints / instructions: ${content}`}
|
|
@@ -23738,7 +23738,7 @@
|
|
|
23738
23738
|
...requirements._metadata,
|
|
23739
23739
|
usePopup: content || true,
|
|
23740
23740
|
},
|
|
23741
|
-
},
|
|
23741
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
23742
23742
|
Tool:
|
|
23743
23743
|
- You can open a popup window with a specific URL using the tool "open_popup".
|
|
23744
23744
|
- Use this when you want the user to see or interact with a specific website.
|
|
@@ -23765,7 +23765,7 @@
|
|
|
23765
23765
|
window.open(url, '_blank');
|
|
23766
23766
|
return `Popup window with URL "${url}" was opened.`;
|
|
23767
23767
|
}
|
|
23768
|
-
return
|
|
23768
|
+
return _spaceTrim.spaceTrim(`
|
|
23769
23769
|
Popup window with URL "${url}" was requested.
|
|
23770
23770
|
|
|
23771
23771
|
Note: The agent is currently running on the server, so the popup cannot be opened automatically.
|
|
@@ -23859,7 +23859,7 @@
|
|
|
23859
23859
|
* Markdown documentation for USE PRIVACY commitment.
|
|
23860
23860
|
*/
|
|
23861
23861
|
get documentation() {
|
|
23862
|
-
return
|
|
23862
|
+
return _spaceTrim.spaceTrim(`
|
|
23863
23863
|
# USE PRIVACY
|
|
23864
23864
|
|
|
23865
23865
|
Enables the agent to request turning on private mode in chat.
|
|
@@ -23899,7 +23899,7 @@
|
|
|
23899
23899
|
...existingTools,
|
|
23900
23900
|
{
|
|
23901
23901
|
name: TURN_PRIVACY_ON_TOOL_NAME,
|
|
23902
|
-
description:
|
|
23902
|
+
description: _spaceTrim.spaceTrim(`
|
|
23903
23903
|
Requests turning private mode on in the chat UI.
|
|
23904
23904
|
The user must explicitly confirm the action in a dialog before private mode is enabled.
|
|
23905
23905
|
Use this for sensitive topics or when the user asks not to store conversation data.
|
|
@@ -23918,7 +23918,7 @@
|
|
|
23918
23918
|
...requirements._metadata,
|
|
23919
23919
|
usePrivacy: content || true,
|
|
23920
23920
|
},
|
|
23921
|
-
},
|
|
23921
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
23922
23922
|
Privacy mode:
|
|
23923
23923
|
- Use "${TURN_PRIVACY_ON_TOOL_NAME}" when the user asks for a private/sensitive conversation.
|
|
23924
23924
|
- This tool requests a UI confirmation dialog. Private mode is enabled only after user confirms.
|
|
@@ -24489,7 +24489,7 @@
|
|
|
24489
24489
|
return null;
|
|
24490
24490
|
}
|
|
24491
24491
|
if (!response.ok) {
|
|
24492
|
-
throw new Error(
|
|
24492
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
24493
24493
|
GitHub API request failed (${response.status} ${response.statusText}):
|
|
24494
24494
|
${extractGitHubApiErrorMessage(parsedPayload, textPayload)}
|
|
24495
24495
|
`));
|
|
@@ -24620,7 +24620,7 @@
|
|
|
24620
24620
|
* @private internal utility of USE PROJECT commitment
|
|
24621
24621
|
*/
|
|
24622
24622
|
function parseUseProjectCommitmentContent(content) {
|
|
24623
|
-
const trimmedContent =
|
|
24623
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
24624
24624
|
if (!trimmedContent) {
|
|
24625
24625
|
return {
|
|
24626
24626
|
repository: null,
|
|
@@ -25521,7 +25521,7 @@
|
|
|
25521
25521
|
* Markdown documentation for USE PROJECT commitment.
|
|
25522
25522
|
*/
|
|
25523
25523
|
get documentation() {
|
|
25524
|
-
return
|
|
25524
|
+
return _spaceTrim.spaceTrim(`
|
|
25525
25525
|
# USE PROJECT
|
|
25526
25526
|
|
|
25527
25527
|
Enables the agent to work with files in a GitHub repository and create pull requests.
|
|
@@ -25561,7 +25561,7 @@
|
|
|
25561
25561
|
useProject: true,
|
|
25562
25562
|
useProjects: existingConfiguredProjects,
|
|
25563
25563
|
},
|
|
25564
|
-
},
|
|
25564
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
25565
25565
|
Project tools:
|
|
25566
25566
|
- You can inspect and edit configured GitHub repositories using project tools.
|
|
25567
25567
|
- Configured repositories:
|
|
@@ -25687,7 +25687,7 @@
|
|
|
25687
25687
|
* Markdown documentation for USE SEARCH ENGINE commitment.
|
|
25688
25688
|
*/
|
|
25689
25689
|
get documentation() {
|
|
25690
|
-
return
|
|
25690
|
+
return _spaceTrim.spaceTrim(`
|
|
25691
25691
|
# USE SEARCH ENGINE
|
|
25692
25692
|
|
|
25693
25693
|
Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
|
|
@@ -25729,7 +25729,7 @@
|
|
|
25729
25729
|
...existingTools,
|
|
25730
25730
|
{
|
|
25731
25731
|
name: 'web_search',
|
|
25732
|
-
description:
|
|
25732
|
+
description: _spaceTrim.spaceTrim(`
|
|
25733
25733
|
Search the internet for information.
|
|
25734
25734
|
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
25735
25735
|
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
@@ -25778,7 +25778,7 @@
|
|
|
25778
25778
|
...requirements._metadata,
|
|
25779
25779
|
useSearchEngine: content || true,
|
|
25780
25780
|
},
|
|
25781
|
-
},
|
|
25781
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
25782
25782
|
Tool:
|
|
25783
25783
|
- You have access to the web search engine via the tool "web_search".
|
|
25784
25784
|
- Use it to find up-to-date information or facts that you don't know.
|
|
@@ -25809,11 +25809,11 @@
|
|
|
25809
25809
|
}
|
|
25810
25810
|
const searchEngine = new SerpSearchEngine();
|
|
25811
25811
|
const results = await searchEngine.search(query, options);
|
|
25812
|
-
return
|
|
25812
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
25813
25813
|
Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
|
|
25814
25814
|
|
|
25815
25815
|
${block(results
|
|
25816
|
-
.map((result) =>
|
|
25816
|
+
.map((result) => _spaceTrim.spaceTrim(`
|
|
25817
25817
|
- **${result.title}**
|
|
25818
25818
|
${result.url}
|
|
25819
25819
|
${result.snippet}
|
|
@@ -25941,7 +25941,7 @@
|
|
|
25941
25941
|
* Markdown documentation for USE SPAWN commitment.
|
|
25942
25942
|
*/
|
|
25943
25943
|
get documentation() {
|
|
25944
|
-
return
|
|
25944
|
+
return _spaceTrim.spaceTrim(`
|
|
25945
25945
|
# USE SPAWN
|
|
25946
25946
|
|
|
25947
25947
|
Enables the agent to create a new persistent child agent using the \`spawn_agent\` tool.
|
|
@@ -25978,7 +25978,7 @@
|
|
|
25978
25978
|
...existingTools,
|
|
25979
25979
|
{
|
|
25980
25980
|
name: SPAWN_AGENT_TOOL_NAME,
|
|
25981
|
-
description:
|
|
25981
|
+
description: _spaceTrim.spaceTrim(`
|
|
25982
25982
|
Creates one new persistent child agent in Agents Server.
|
|
25983
25983
|
Use this when the user asks to create a new dedicated agent profile.
|
|
25984
25984
|
The tool returns JSON with \`status\`, \`agentId\`, and created \`agent\` or \`error\`.
|
|
@@ -25993,7 +25993,7 @@
|
|
|
25993
25993
|
...requirements._metadata,
|
|
25994
25994
|
useSpawn: content || true,
|
|
25995
25995
|
},
|
|
25996
|
-
},
|
|
25996
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
25997
25997
|
Spawning agents:
|
|
25998
25998
|
- Use "${SPAWN_AGENT_TOOL_NAME}" only when user asks to create a persistent new agent.
|
|
25999
25999
|
- Pass full agent source in \`source\`.
|
|
@@ -26033,7 +26033,7 @@
|
|
|
26033
26033
|
* @private internal utility of USE TIMEOUT
|
|
26034
26034
|
*/
|
|
26035
26035
|
function createTimeoutSystemMessage(extraInstructions) {
|
|
26036
|
-
return
|
|
26036
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
26037
26037
|
Timeout scheduling:
|
|
26038
26038
|
- Use "set_timeout" to wake this same chat thread in the future.
|
|
26039
26039
|
- Use "list_timeouts" to review timeouts across all chats for the same user+agent scope.
|
|
@@ -26149,7 +26149,7 @@
|
|
|
26149
26149
|
set(args) {
|
|
26150
26150
|
const parsedMilliseconds = Number(args.milliseconds);
|
|
26151
26151
|
if (!Number.isFinite(parsedMilliseconds) || parsedMilliseconds <= 0) {
|
|
26152
|
-
throw new PipelineExecutionError(
|
|
26152
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
26153
26153
|
Timeout \`milliseconds\` must be a positive number.
|
|
26154
26154
|
`));
|
|
26155
26155
|
}
|
|
@@ -26165,7 +26165,7 @@
|
|
|
26165
26165
|
cancel(args) {
|
|
26166
26166
|
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
26167
26167
|
if (!timeoutId) {
|
|
26168
|
-
throw new PipelineExecutionError(
|
|
26168
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
26169
26169
|
Timeout \`timeoutId\` is required.
|
|
26170
26170
|
`));
|
|
26171
26171
|
}
|
|
@@ -26176,18 +26176,18 @@
|
|
|
26176
26176
|
*/
|
|
26177
26177
|
list(args) {
|
|
26178
26178
|
if (args.includeFinished !== undefined && typeof args.includeFinished !== 'boolean') {
|
|
26179
|
-
throw new PipelineExecutionError(
|
|
26179
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
26180
26180
|
Timeout \`includeFinished\` must be a boolean when provided.
|
|
26181
26181
|
`));
|
|
26182
26182
|
}
|
|
26183
26183
|
const parsedLimit = args.limit === undefined ? DEFAULT_LIST_TIMEOUTS_LIMIT : Math.floor(Number(args.limit));
|
|
26184
26184
|
if (!Number.isFinite(parsedLimit) || parsedLimit <= 0) {
|
|
26185
|
-
throw new PipelineExecutionError(
|
|
26185
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
26186
26186
|
Timeout \`limit\` must be a positive number.
|
|
26187
26187
|
`));
|
|
26188
26188
|
}
|
|
26189
26189
|
if (parsedLimit > MAX_LIST_TIMEOUTS_LIMIT) {
|
|
26190
|
-
throw new PipelineExecutionError(
|
|
26190
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
26191
26191
|
Timeout \`limit\` must be at most \`${MAX_LIST_TIMEOUTS_LIMIT}\`.
|
|
26192
26192
|
`));
|
|
26193
26193
|
}
|
|
@@ -26433,7 +26433,7 @@
|
|
|
26433
26433
|
* Markdown documentation for `USE TIMEOUT`.
|
|
26434
26434
|
*/
|
|
26435
26435
|
get documentation() {
|
|
26436
|
-
return
|
|
26436
|
+
return _spaceTrim.spaceTrim(`
|
|
26437
26437
|
# USE TIMEOUT
|
|
26438
26438
|
|
|
26439
26439
|
Enables timeout wake-ups and timeout management for the same user+agent scope.
|
|
@@ -26524,7 +26524,7 @@
|
|
|
26524
26524
|
* Markdown documentation for USE TIME commitment.
|
|
26525
26525
|
*/
|
|
26526
26526
|
get documentation() {
|
|
26527
|
-
return
|
|
26527
|
+
return _spaceTrim.spaceTrim(`
|
|
26528
26528
|
# USE TIME
|
|
26529
26529
|
|
|
26530
26530
|
Enables the agent to determine the current date and time.
|
|
@@ -26585,7 +26585,7 @@
|
|
|
26585
26585
|
_metadata: {
|
|
26586
26586
|
...requirements._metadata,
|
|
26587
26587
|
},
|
|
26588
|
-
},
|
|
26588
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
26589
26589
|
Time and date context:
|
|
26590
26590
|
- It is ${moment__default["default"]().format('MMMM YYYY')} now.
|
|
26591
26591
|
- If you need more precise current time information, use the tool "get_current_time".
|
|
@@ -26753,7 +26753,7 @@
|
|
|
26753
26753
|
* Markdown documentation for USE USER LOCATION commitment.
|
|
26754
26754
|
*/
|
|
26755
26755
|
get documentation() {
|
|
26756
|
-
return
|
|
26756
|
+
return _spaceTrim.spaceTrim(`
|
|
26757
26757
|
# USE USER LOCATION
|
|
26758
26758
|
|
|
26759
26759
|
Enables the agent to retrieve the user's location from runtime context.
|
|
@@ -26791,7 +26791,7 @@
|
|
|
26791
26791
|
...existingTools,
|
|
26792
26792
|
{
|
|
26793
26793
|
name: GET_USER_LOCATION_TOOL_NAME,
|
|
26794
|
-
description:
|
|
26794
|
+
description: _spaceTrim.spaceTrim(`
|
|
26795
26795
|
Retrieves user location shared by browser runtime (if permission is granted).
|
|
26796
26796
|
Returns JSON status with coordinates and metadata when available.
|
|
26797
26797
|
`),
|
|
@@ -26809,7 +26809,7 @@
|
|
|
26809
26809
|
...requirements._metadata,
|
|
26810
26810
|
useUserLocation: content || true,
|
|
26811
26811
|
},
|
|
26812
|
-
},
|
|
26812
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
26813
26813
|
User location:
|
|
26814
26814
|
- Use "${GET_USER_LOCATION_TOOL_NAME}" only when location is needed for a better answer.
|
|
26815
26815
|
- If the tool returns "unavailable" or "permission-denied", ask user to share location or provide city manually.
|
|
@@ -26886,7 +26886,7 @@
|
|
|
26886
26886
|
* Markdown documentation for `WRITING RULES`.
|
|
26887
26887
|
*/
|
|
26888
26888
|
get documentation() {
|
|
26889
|
-
return
|
|
26889
|
+
return _spaceTrim.spaceTrim(`
|
|
26890
26890
|
# ${this.type}
|
|
26891
26891
|
|
|
26892
26892
|
Adds instructions that apply strictly to how the agent writes.
|
|
@@ -26964,7 +26964,7 @@
|
|
|
26964
26964
|
* Markdown documentation for `WRITING SAMPLE`.
|
|
26965
26965
|
*/
|
|
26966
26966
|
get documentation() {
|
|
26967
|
-
return
|
|
26967
|
+
return _spaceTrim.spaceTrim(`
|
|
26968
26968
|
# ${this.type}
|
|
26969
26969
|
|
|
26970
26970
|
Provides explicit 1:1 sample text that demonstrates how the agent should sound.
|
|
@@ -27036,7 +27036,7 @@
|
|
|
27036
27036
|
* Markdown documentation available at runtime.
|
|
27037
27037
|
*/
|
|
27038
27038
|
get documentation() {
|
|
27039
|
-
return
|
|
27039
|
+
return _spaceTrim.spaceTrim(`
|
|
27040
27040
|
# ${this.type}
|
|
27041
27041
|
|
|
27042
27042
|
This commitment is not yet fully implemented.
|
|
@@ -27337,13 +27337,13 @@
|
|
|
27337
27337
|
* @public exported from `@promptbook/markdown-utils`
|
|
27338
27338
|
*/
|
|
27339
27339
|
function trimCodeBlock(value) {
|
|
27340
|
-
value =
|
|
27340
|
+
value = _spaceTrim.spaceTrim(value);
|
|
27341
27341
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
27342
27342
|
return value;
|
|
27343
27343
|
}
|
|
27344
27344
|
value = value.replace(/^```[a-z]*/i, '');
|
|
27345
27345
|
value = value.replace(/```$/i, '');
|
|
27346
|
-
value =
|
|
27346
|
+
value = _spaceTrim.spaceTrim(value);
|
|
27347
27347
|
return value;
|
|
27348
27348
|
}
|
|
27349
27349
|
|
|
@@ -27356,9 +27356,9 @@
|
|
|
27356
27356
|
* @public exported from `@promptbook/markdown-utils`
|
|
27357
27357
|
*/
|
|
27358
27358
|
function trimEndOfCodeBlock(value) {
|
|
27359
|
-
value =
|
|
27359
|
+
value = _spaceTrim.spaceTrim(value);
|
|
27360
27360
|
value = value.replace(/```$/g, '');
|
|
27361
|
-
value =
|
|
27361
|
+
value = _spaceTrim.spaceTrim(value);
|
|
27362
27362
|
return value;
|
|
27363
27363
|
}
|
|
27364
27364
|
|
|
@@ -27405,7 +27405,7 @@
|
|
|
27405
27405
|
}
|
|
27406
27406
|
// Note: [💎]
|
|
27407
27407
|
// Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
|
|
27408
|
-
const spaceTrim = (_) =>
|
|
27408
|
+
const spaceTrim = (_) => _spaceTrim__default["default"](_);
|
|
27409
27409
|
$preserve(spaceTrim);
|
|
27410
27410
|
const removeQuotes$1 = removeQuotes;
|
|
27411
27411
|
$preserve(removeQuotes$1);
|
|
@@ -27496,7 +27496,7 @@
|
|
|
27496
27496
|
.join('\n');
|
|
27497
27497
|
// script = templateParameters(script, parameters);
|
|
27498
27498
|
// <- TODO: [🧠][🥳] Should be this is one of two variants how to use parameters in script
|
|
27499
|
-
const statementToEvaluate =
|
|
27499
|
+
const statementToEvaluate = _spaceTrim__default["default"]((block) => `
|
|
27500
27500
|
|
|
27501
27501
|
// Build-in functions:
|
|
27502
27502
|
${block(buildinFunctionsStatement)}
|
|
@@ -27511,7 +27511,7 @@
|
|
|
27511
27511
|
(async ()=>{ ${script} })()
|
|
27512
27512
|
`);
|
|
27513
27513
|
if (this.options.isVerbose) {
|
|
27514
|
-
console.info(
|
|
27514
|
+
console.info(_spaceTrim__default["default"]((block) => `
|
|
27515
27515
|
🚀 Evaluating ${scriptLanguage} script:
|
|
27516
27516
|
|
|
27517
27517
|
${block(statementToEvaluate)}`));
|
|
@@ -27520,7 +27520,7 @@
|
|
|
27520
27520
|
try {
|
|
27521
27521
|
result = await eval(statementToEvaluate);
|
|
27522
27522
|
if (this.options.isVerbose) {
|
|
27523
|
-
console.info(
|
|
27523
|
+
console.info(_spaceTrim__default["default"]((block) => `
|
|
27524
27524
|
🚀 Script evaluated successfully, result:
|
|
27525
27525
|
${block(valueToString(result))}
|
|
27526
27526
|
`));
|
|
@@ -27539,7 +27539,7 @@
|
|
|
27539
27539
|
To: [PipelineExecutionError: Parameter `{thing}` is not defined],
|
|
27540
27540
|
*/
|
|
27541
27541
|
if (!statementToEvaluate.includes(undefinedName + '(')) {
|
|
27542
|
-
throw new PipelineExecutionError(
|
|
27542
|
+
throw new PipelineExecutionError(_spaceTrim__default["default"]((block) => `
|
|
27543
27543
|
|
|
27544
27544
|
Parameter \`{${undefinedName}}\` is not defined
|
|
27545
27545
|
|
|
@@ -27561,7 +27561,7 @@
|
|
|
27561
27561
|
`));
|
|
27562
27562
|
}
|
|
27563
27563
|
else {
|
|
27564
|
-
throw new PipelineExecutionError(
|
|
27564
|
+
throw new PipelineExecutionError(_spaceTrim__default["default"]((block) => `
|
|
27565
27565
|
Function ${undefinedName}() is not defined
|
|
27566
27566
|
|
|
27567
27567
|
- Make sure that the function is one of built-in functions
|
|
@@ -27814,7 +27814,7 @@
|
|
|
27814
27814
|
catch (error) {
|
|
27815
27815
|
assertsError(error);
|
|
27816
27816
|
// TODO: [7] DRY
|
|
27817
|
-
const wrappedErrorMessage =
|
|
27817
|
+
const wrappedErrorMessage = _spaceTrim.spaceTrim((block) => `
|
|
27818
27818
|
${error.name} in pipeline ${fileName.split('\\').join('/')}:
|
|
27819
27819
|
|
|
27820
27820
|
Original error message:
|
|
@@ -27849,7 +27849,7 @@
|
|
|
27849
27849
|
pipeline = { ...pipeline, pipelineUrl };
|
|
27850
27850
|
}
|
|
27851
27851
|
else if (!pipeline.pipelineUrl.startsWith(rootUrl)) {
|
|
27852
|
-
throw new PipelineUrlError(
|
|
27852
|
+
throw new PipelineUrlError(_spaceTrim.spaceTrim(`
|
|
27853
27853
|
Pipeline with URL ${pipeline.pipelineUrl} is not a child of the root URL ${rootUrl} 🍏
|
|
27854
27854
|
|
|
27855
27855
|
File:
|
|
@@ -27887,7 +27887,7 @@
|
|
|
27887
27887
|
}
|
|
27888
27888
|
else {
|
|
27889
27889
|
const existing = collection.get(pipeline.pipelineUrl);
|
|
27890
|
-
throw new PipelineUrlError(
|
|
27890
|
+
throw new PipelineUrlError(_spaceTrim.spaceTrim(`
|
|
27891
27891
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍏
|
|
27892
27892
|
|
|
27893
27893
|
Conflicting files:
|
|
@@ -27905,7 +27905,7 @@
|
|
|
27905
27905
|
catch (error) {
|
|
27906
27906
|
assertsError(error);
|
|
27907
27907
|
// TODO: [7] DRY
|
|
27908
|
-
const wrappedErrorMessage =
|
|
27908
|
+
const wrappedErrorMessage = _spaceTrim.spaceTrim((block) => `
|
|
27909
27909
|
${error.name} in pipeline ${fileName.split('\\').join('/')}:
|
|
27910
27910
|
|
|
27911
27911
|
Original error message:
|
|
@@ -28040,7 +28040,7 @@
|
|
|
28040
28040
|
// Note: For negligible usage, we report at least something
|
|
28041
28041
|
reportItems.push('Negligible');
|
|
28042
28042
|
}
|
|
28043
|
-
return
|
|
28043
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
28044
28044
|
Usage:
|
|
28045
28045
|
${block(reportItems.map((item) => `- ${item}`).join('\n'))}
|
|
28046
28046
|
`);
|
|
@@ -28080,7 +28080,7 @@
|
|
|
28080
28080
|
*/
|
|
28081
28081
|
function $initializeMakeCommand(program) {
|
|
28082
28082
|
const makeCommand = program.command('make');
|
|
28083
|
-
makeCommand.description(
|
|
28083
|
+
makeCommand.description(_spaceTrim.spaceTrim(`
|
|
28084
28084
|
Makes a new pipeline collection in given folder
|
|
28085
28085
|
`));
|
|
28086
28086
|
makeCommand.alias('compile');
|
|
@@ -28092,7 +28092,7 @@
|
|
|
28092
28092
|
'Path to promptbook collection directory', DEFAULT_BOOKS_DIRNAME);
|
|
28093
28093
|
makeCommand.option('--project-name', `Name of the project for whom collection is`, 'Untitled Promptbook project');
|
|
28094
28094
|
makeCommand.option('--root-url <url>', `Root URL of all pipelines to make`, undefined);
|
|
28095
|
-
makeCommand.option('-f, --format <format>',
|
|
28095
|
+
makeCommand.option('-f, --format <format>', _spaceTrim.spaceTrim(`
|
|
28096
28096
|
Output format of builded collection "bookc", "javascript", "typescript" or "json"
|
|
28097
28097
|
|
|
28098
28098
|
Note: You can use multiple formats separated by comma
|
|
@@ -28100,14 +28100,14 @@
|
|
|
28100
28100
|
makeCommand.option('--no-validation', `Do not validate logic of pipelines in collection`, true);
|
|
28101
28101
|
makeCommand.option('--validation', `Types of validations separated by comma (options "logic","imports")`, 'logic,imports');
|
|
28102
28102
|
makeCommand.option('-r, --reload', `Call LLM models even if same prompt with result is in the cache`, false);
|
|
28103
|
-
makeCommand.option('-o, --output <path>',
|
|
28103
|
+
makeCommand.option('-o, --output <path>', _spaceTrim.spaceTrim(`
|
|
28104
28104
|
Where to save the builded collection
|
|
28105
28105
|
|
|
28106
28106
|
Note: If you keep it "${DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME}" it will be saved in the root of the promptbook directory
|
|
28107
28107
|
If you set it to a path, it will be saved in that path
|
|
28108
28108
|
BUT you can use only one format and set correct extension
|
|
28109
28109
|
`), DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME);
|
|
28110
|
-
makeCommand.option('-fn, --function-name <functionName>',
|
|
28110
|
+
makeCommand.option('-fn, --function-name <functionName>', _spaceTrim.spaceTrim(`
|
|
28111
28111
|
Name of the function to get pipeline collection
|
|
28112
28112
|
|
|
28113
28113
|
Note: This can be used only with "javascript" or "typescript" format
|
|
@@ -28190,7 +28190,7 @@
|
|
|
28190
28190
|
if (lastChar !== ']') {
|
|
28191
28191
|
throw new UnexpectedError(`Last character of serialized collection should be "]" not "${lastChar}"`);
|
|
28192
28192
|
}
|
|
28193
|
-
return
|
|
28193
|
+
return _spaceTrim.spaceTrim(collectionJsonString.substring(1, collectionJsonString.length - 1));
|
|
28194
28194
|
})();
|
|
28195
28195
|
const saveFile = async (extension, content) => {
|
|
28196
28196
|
const filename = output !== DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME
|
|
@@ -28221,7 +28221,7 @@
|
|
|
28221
28221
|
}
|
|
28222
28222
|
if (formats.includes('javascript') || formats.includes('js')) {
|
|
28223
28223
|
formats = formats.filter((format) => format !== 'javascript' && format !== 'js');
|
|
28224
|
-
(await saveFile('js',
|
|
28224
|
+
(await saveFile('js', _spaceTrim.spaceTrim((block) => `
|
|
28225
28225
|
// ${block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI)}
|
|
28226
28226
|
|
|
28227
28227
|
import { createPipelineCollectionFromJson } from '@promptbook/core';
|
|
@@ -28258,7 +28258,7 @@
|
|
|
28258
28258
|
}
|
|
28259
28259
|
if (formats.includes('typescript') || formats.includes('ts')) {
|
|
28260
28260
|
formats = formats.filter((format) => format !== 'typescript' && format !== 'ts');
|
|
28261
|
-
await saveFile('ts',
|
|
28261
|
+
await saveFile('ts', _spaceTrim.spaceTrim((block) => `
|
|
28262
28262
|
// ${block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI)}
|
|
28263
28263
|
|
|
28264
28264
|
import { createPipelineCollectionFromJson } from '@promptbook/core';
|
|
@@ -28326,7 +28326,7 @@
|
|
|
28326
28326
|
const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
|
|
28327
28327
|
const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
|
|
28328
28328
|
const sectionMatch = content.match(sectionRegex);
|
|
28329
|
-
const contentToInsert =
|
|
28329
|
+
const contentToInsert = _spaceTrim.spaceTrim((block) => `
|
|
28330
28330
|
<!--${sectionName}-->
|
|
28331
28331
|
${block(warningLine)}
|
|
28332
28332
|
${block(sectionContent)}
|
|
@@ -28339,7 +28339,7 @@
|
|
|
28339
28339
|
const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
|
|
28340
28340
|
if (placeForSection !== null) {
|
|
28341
28341
|
const [heading] = placeForSection;
|
|
28342
|
-
return content.replace(heading,
|
|
28342
|
+
return content.replace(heading, _spaceTrim.spaceTrim((block) => `
|
|
28343
28343
|
${block(contentToInsert)}
|
|
28344
28344
|
|
|
28345
28345
|
${block(heading)}
|
|
@@ -28348,7 +28348,7 @@
|
|
|
28348
28348
|
console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
|
|
28349
28349
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
28350
28350
|
// <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
|
|
28351
|
-
return
|
|
28351
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
28352
28352
|
${block(content)}
|
|
28353
28353
|
|
|
28354
28354
|
${block(contentToInsert)}
|
|
@@ -28372,7 +28372,7 @@
|
|
|
28372
28372
|
return { href: `#${task.name}`, title: task.title };
|
|
28373
28373
|
},
|
|
28374
28374
|
});
|
|
28375
|
-
const promptbookMermaidBlock =
|
|
28375
|
+
const promptbookMermaidBlock = _spaceTrim.spaceTrim((block) => `
|
|
28376
28376
|
\`\`\`mermaid
|
|
28377
28377
|
${block(promptbookMermaid)}
|
|
28378
28378
|
\`\`\`
|
|
@@ -28403,7 +28403,7 @@
|
|
|
28403
28403
|
*/
|
|
28404
28404
|
function $initializePrettifyCommand(program) {
|
|
28405
28405
|
const prettifyCommand = program.command('prettify');
|
|
28406
|
-
prettifyCommand.description(
|
|
28406
|
+
prettifyCommand.description(_spaceTrim.spaceTrim(`
|
|
28407
28407
|
Iterates over \`.book.md\` files and does multiple enhancing operations on them:
|
|
28408
28408
|
|
|
28409
28409
|
1) Adds Mermaid graph
|
|
@@ -28569,7 +28569,7 @@
|
|
|
28569
28569
|
function executionReportJsonToString(executionReportJson, options) {
|
|
28570
28570
|
var _a, _b, _c, _d, _e, _f;
|
|
28571
28571
|
const { taxRate, chartsWidth } = { ...ExecutionReportStringOptionsDefaults, ...(options || {}) };
|
|
28572
|
-
let executionReportString =
|
|
28572
|
+
let executionReportString = _spaceTrim.spaceTrim((block) => `
|
|
28573
28573
|
# ${executionReportJson.title || 'Execution report'}
|
|
28574
28574
|
|
|
28575
28575
|
${block(executionReportJson.description || '')}
|
|
@@ -28691,7 +28691,7 @@
|
|
|
28691
28691
|
if (just(true)) {
|
|
28692
28692
|
executionReportString +=
|
|
28693
28693
|
'\n\n\n\n' +
|
|
28694
|
-
|
|
28694
|
+
_spaceTrim.spaceTrim((block) => {
|
|
28695
28695
|
var _a;
|
|
28696
28696
|
return `
|
|
28697
28697
|
|
|
@@ -28710,7 +28710,7 @@
|
|
|
28710
28710
|
executionReportString += '*No result*';
|
|
28711
28711
|
}
|
|
28712
28712
|
else if (typeof promptExecution.result.content === 'string') {
|
|
28713
|
-
executionReportString +=
|
|
28713
|
+
executionReportString += _spaceTrim.spaceTrim((block) => `
|
|
28714
28714
|
\`\`\`
|
|
28715
28715
|
${block(escapeMarkdownBlock(promptExecution.result.content))}
|
|
28716
28716
|
\`\`\`
|
|
@@ -28723,7 +28723,7 @@
|
|
|
28723
28723
|
if (promptExecution.error && promptExecution.error.message) {
|
|
28724
28724
|
executionReportString +=
|
|
28725
28725
|
'\n\n\n\n' +
|
|
28726
|
-
|
|
28726
|
+
_spaceTrim.spaceTrim((block) => `
|
|
28727
28727
|
|
|
28728
28728
|
### Error
|
|
28729
28729
|
|
|
@@ -28859,7 +28859,7 @@
|
|
|
28859
28859
|
// console.log(`Strategy 3️⃣`);
|
|
28860
28860
|
const response = await fetch(pipelineSource);
|
|
28861
28861
|
if (response.status >= 300) {
|
|
28862
|
-
throw new NotFoundError(
|
|
28862
|
+
throw new NotFoundError(_spaceTrim.spaceTrim((block) => `
|
|
28863
28863
|
Book not found on URL:
|
|
28864
28864
|
${block(pipelineSource)}
|
|
28865
28865
|
|
|
@@ -28869,7 +28869,7 @@
|
|
|
28869
28869
|
const pipelineString = await response.text();
|
|
28870
28870
|
// console.log({ pipelineString });
|
|
28871
28871
|
if (!isValidPipelineString(pipelineString)) {
|
|
28872
|
-
throw new NotFoundError(
|
|
28872
|
+
throw new NotFoundError(_spaceTrim.spaceTrim((block) => `
|
|
28873
28873
|
Book not found on URL:
|
|
28874
28874
|
${block(pipelineSource)}
|
|
28875
28875
|
|
|
@@ -28891,7 +28891,7 @@
|
|
|
28891
28891
|
});
|
|
28892
28892
|
return pipelineJson;
|
|
28893
28893
|
} /* not else */
|
|
28894
|
-
throw new NotFoundError(
|
|
28894
|
+
throw new NotFoundError(_spaceTrim.spaceTrim((block) => `
|
|
28895
28895
|
Book not found:
|
|
28896
28896
|
${block(pipelineSource)}
|
|
28897
28897
|
|
|
@@ -28938,7 +28938,7 @@
|
|
|
28938
28938
|
const initialMessage = (((_a = pipeline.parameters.find(({ name }) => name === 'chatbotResponse')) === null || _a === void 0 ? void 0 : _a.exampleValues) || [])[0];
|
|
28939
28939
|
if (initialMessage) {
|
|
28940
28940
|
console.info(`\n`);
|
|
28941
|
-
console.info(
|
|
28941
|
+
console.info(_spaceTrim.spaceTrim((block) => `
|
|
28942
28942
|
|
|
28943
28943
|
${colors__default["default"].bold(colors__default["default"].green('Chatbot:'))}
|
|
28944
28944
|
${block(colors__default["default"].green(initialMessage))}
|
|
@@ -28961,7 +28961,7 @@
|
|
|
28961
28961
|
type: 'text',
|
|
28962
28962
|
name: 'userMessage',
|
|
28963
28963
|
message: 'User message',
|
|
28964
|
-
hint:
|
|
28964
|
+
hint: _spaceTrim.spaceTrim((block) => `
|
|
28965
28965
|
Type "exit" to exit,
|
|
28966
28966
|
|
|
28967
28967
|
previousTitle
|
|
@@ -28977,7 +28977,7 @@
|
|
|
28977
28977
|
return process.exit(0);
|
|
28978
28978
|
}
|
|
28979
28979
|
console.info(`\n`);
|
|
28980
|
-
console.info(
|
|
28980
|
+
console.info(_spaceTrim.spaceTrim((block) => `
|
|
28981
28981
|
|
|
28982
28982
|
${colors__default["default"].bold(colors__default["default"].blue('User:'))}
|
|
28983
28983
|
${block(colors__default["default"].blue(userMessage))}
|
|
@@ -28990,7 +28990,7 @@
|
|
|
28990
28990
|
};
|
|
28991
28991
|
const result = await pipelineExecutor(inputParameters).asPromise({ isCrashedOnError: true });
|
|
28992
28992
|
console.info(`\n`);
|
|
28993
|
-
console.info(
|
|
28993
|
+
console.info(_spaceTrim.spaceTrim((block) => `
|
|
28994
28994
|
|
|
28995
28995
|
${colors__default["default"].bold(colors__default["default"].green('Chatbot:'))}
|
|
28996
28996
|
${block(colors__default["default"].green(result.outputParameters.chatbotResponse))}
|
|
@@ -29021,7 +29021,7 @@
|
|
|
29021
29021
|
*/
|
|
29022
29022
|
function $initializeRunCommand(program) {
|
|
29023
29023
|
const runCommand = program.command('run', { isDefault: true });
|
|
29024
|
-
runCommand.description(
|
|
29024
|
+
runCommand.description(_spaceTrim.spaceTrim(`
|
|
29025
29025
|
Runs a pipeline
|
|
29026
29026
|
`));
|
|
29027
29027
|
runCommand.alias('execute');
|
|
@@ -29064,7 +29064,7 @@
|
|
|
29064
29064
|
if (!error.message.includes('No LLM tools')) {
|
|
29065
29065
|
throw error;
|
|
29066
29066
|
}
|
|
29067
|
-
console.error(colors__default["default"].red(
|
|
29067
|
+
console.error(colors__default["default"].red(_spaceTrim.spaceTrim((block) => `
|
|
29068
29068
|
You need to configure LLM tools first
|
|
29069
29069
|
|
|
29070
29070
|
1) Create .env file at the root of your project
|
|
@@ -29132,7 +29132,7 @@
|
|
|
29132
29132
|
if (!(error instanceof ParseError)) {
|
|
29133
29133
|
throw error;
|
|
29134
29134
|
}
|
|
29135
|
-
console.error(colors__default["default"].red(
|
|
29135
|
+
console.error(colors__default["default"].red(_spaceTrim.spaceTrim((block) => `
|
|
29136
29136
|
${block(error.message)}
|
|
29137
29137
|
|
|
29138
29138
|
in ${pipelineSource}
|
|
@@ -29184,7 +29184,7 @@
|
|
|
29184
29184
|
};
|
|
29185
29185
|
});
|
|
29186
29186
|
if (isInteractive === false && questions.length !== 0) {
|
|
29187
|
-
console.error(colors__default["default"].red(
|
|
29187
|
+
console.error(colors__default["default"].red(_spaceTrim.spaceTrim((block) => `
|
|
29188
29188
|
When using --no-interactive you need to pass all the input parameters through --json
|
|
29189
29189
|
|
|
29190
29190
|
You are missing:
|
|
@@ -29316,7 +29316,7 @@
|
|
|
29316
29316
|
'Path to agents directory', DEFAULT_AGENTS_DIRNAME);
|
|
29317
29317
|
startServerCommand.option('--port <port>', `Port to start the server on`, '4440');
|
|
29318
29318
|
startServerCommand.option('-r, --reload', `Call LLM models even if same prompt with result is in the cache`, false);
|
|
29319
|
-
startServerCommand.description(
|
|
29319
|
+
startServerCommand.description(_spaceTrim.spaceTrim(`
|
|
29320
29320
|
Starts a Promptbook agents server
|
|
29321
29321
|
`));
|
|
29322
29322
|
startServerCommand.alias('start');
|
|
@@ -30207,7 +30207,7 @@
|
|
|
30207
30207
|
response.type('text/html').send(renderServerIndexHtml(serverInfo));
|
|
30208
30208
|
}
|
|
30209
30209
|
else {
|
|
30210
|
-
response.type('text/markdown').send(await
|
|
30210
|
+
response.type('text/markdown').send(await _spaceTrim.spaceTrim(async (block) => `
|
|
30211
30211
|
# Promptbook
|
|
30212
30212
|
|
|
30213
30213
|
> ${block(CLAIM)}
|
|
@@ -30623,7 +30623,7 @@
|
|
|
30623
30623
|
// <- TODO: [🧟♂️] Unite path to promptbook collection argument
|
|
30624
30624
|
'Path to promptbook collection directory', DEFAULT_BOOKS_DIRNAME);
|
|
30625
30625
|
startServerCommand.option('--port <port>', `Port to start the server on`, '4460');
|
|
30626
|
-
startServerCommand.option('-u, --url <url>',
|
|
30626
|
+
startServerCommand.option('-u, --url <url>', _spaceTrim.spaceTrim(`
|
|
30627
30627
|
Public root url of the server
|
|
30628
30628
|
It is used for following purposes:
|
|
30629
30629
|
|
|
@@ -30633,7 +30633,7 @@
|
|
|
30633
30633
|
startServerCommand.option('--allow-anonymous', `Is anonymous mode allowed`, false);
|
|
30634
30634
|
startServerCommand.option('-r, --reload', `Call LLM models even if same prompt with result is in the cache`, false);
|
|
30635
30635
|
startServerCommand.option('--no-rich-ui', `Disable rich UI`, true);
|
|
30636
|
-
startServerCommand.description(
|
|
30636
|
+
startServerCommand.description(_spaceTrim.spaceTrim(`
|
|
30637
30637
|
Starts a remote server to execute books
|
|
30638
30638
|
|
|
30639
30639
|
Note: You want probably to use "ptbk start-agents-server" to start agents server instead of pipelines server
|
|
@@ -30724,7 +30724,7 @@
|
|
|
30724
30724
|
*/
|
|
30725
30725
|
function $initializeTestCommand(program) {
|
|
30726
30726
|
const testCommand = program.command('test');
|
|
30727
|
-
testCommand.description(
|
|
30727
|
+
testCommand.description(_spaceTrim.spaceTrim(`
|
|
30728
30728
|
Iterates over \`.book.md\` and \`.bookc\` and checks if they are parsable and logically valid
|
|
30729
30729
|
`));
|
|
30730
30730
|
testCommand.argument('<filesGlob>',
|
|
@@ -30826,7 +30826,7 @@
|
|
|
30826
30826
|
*/
|
|
30827
30827
|
async function promptbookCli() {
|
|
30828
30828
|
if (!$isRunningInNode()) {
|
|
30829
|
-
throw new EnvironmentMismatchError(
|
|
30829
|
+
throw new EnvironmentMismatchError(_spaceTrim.spaceTrim(`
|
|
30830
30830
|
Function promptbookCli is initiator of CLI script and should be run in Node.js environment.
|
|
30831
30831
|
|
|
30832
30832
|
- In browser use function exported from \`@promptbook/utils\` or \`@promptbook/core\` directly, for example \`prettifyPipelineString\`.
|
|
@@ -30964,7 +30964,7 @@
|
|
|
30964
30964
|
/**
|
|
30965
30965
|
* List of available Anthropic Claude models with pricing
|
|
30966
30966
|
*
|
|
30967
|
-
* Note: Synced with official API docs at
|
|
30967
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
30968
30968
|
*
|
|
30969
30969
|
* @see https://docs.anthropic.com/en/docs/models-overview
|
|
30970
30970
|
* @public exported from `@promptbook/anthropic-claude`
|
|
@@ -30972,6 +30972,26 @@
|
|
|
30972
30972
|
const ANTHROPIC_CLAUDE_MODELS = exportJson({
|
|
30973
30973
|
name: 'ANTHROPIC_CLAUDE_MODELS',
|
|
30974
30974
|
value: [
|
|
30975
|
+
{
|
|
30976
|
+
modelVariant: 'CHAT',
|
|
30977
|
+
modelTitle: 'Claude Opus 4.6',
|
|
30978
|
+
modelName: 'claude-opus-4-6',
|
|
30979
|
+
modelDescription: "Anthropic's most capable model for advanced coding, complex reasoning, and agentic workflows with 1M token context window.",
|
|
30980
|
+
pricing: {
|
|
30981
|
+
prompt: pricing(`$5.00 / 1M tokens`),
|
|
30982
|
+
output: pricing(`$25.00 / 1M tokens`),
|
|
30983
|
+
},
|
|
30984
|
+
},
|
|
30985
|
+
{
|
|
30986
|
+
modelVariant: 'CHAT',
|
|
30987
|
+
modelTitle: 'Claude Sonnet 4.6',
|
|
30988
|
+
modelName: 'claude-sonnet-4-6',
|
|
30989
|
+
modelDescription: 'Best speed and intelligence balance for production-ready workloads with 1M token context window. Ideal for high-performance, lower-latency applications.',
|
|
30990
|
+
pricing: {
|
|
30991
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
30992
|
+
output: pricing(`$15.00 / 1M tokens`),
|
|
30993
|
+
},
|
|
30994
|
+
},
|
|
30975
30995
|
{
|
|
30976
30996
|
modelVariant: 'CHAT',
|
|
30977
30997
|
modelTitle: 'Claude Sonnet 4.5',
|
|
@@ -31373,7 +31393,7 @@
|
|
|
31373
31393
|
getDefaultModel(defaultModelName) {
|
|
31374
31394
|
const model = ANTHROPIC_CLAUDE_MODELS.find(({ modelName }) => modelName.startsWith(defaultModelName));
|
|
31375
31395
|
if (model === undefined) {
|
|
31376
|
-
throw new UnexpectedError(
|
|
31396
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
31377
31397
|
Cannot find model in Anthropic Claude models with name "${defaultModelName}" which should be used as default.
|
|
31378
31398
|
|
|
31379
31399
|
Available models:
|
|
@@ -31530,7 +31550,7 @@
|
|
|
31530
31550
|
/**
|
|
31531
31551
|
* List of available OpenAI models with pricing
|
|
31532
31552
|
*
|
|
31533
|
-
* Note: Synced with official API docs at
|
|
31553
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
31534
31554
|
*
|
|
31535
31555
|
* @see https://platform.openai.com/docs/models/
|
|
31536
31556
|
* @see https://openai.com/api/pricing/
|
|
@@ -31652,8 +31672,8 @@
|
|
|
31652
31672
|
modelName: 'gpt-4.1',
|
|
31653
31673
|
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.',
|
|
31654
31674
|
pricing: {
|
|
31655
|
-
prompt: pricing(`$
|
|
31656
|
-
output: pricing(`$
|
|
31675
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
31676
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
31657
31677
|
},
|
|
31658
31678
|
},
|
|
31659
31679
|
/**/
|
|
@@ -31664,8 +31684,8 @@
|
|
|
31664
31684
|
modelName: 'gpt-4.1-mini',
|
|
31665
31685
|
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.',
|
|
31666
31686
|
pricing: {
|
|
31667
|
-
prompt: pricing(`$0.
|
|
31668
|
-
output: pricing(`$
|
|
31687
|
+
prompt: pricing(`$0.40 / 1M tokens`),
|
|
31688
|
+
output: pricing(`$1.60 / 1M tokens`),
|
|
31669
31689
|
},
|
|
31670
31690
|
},
|
|
31671
31691
|
/**/
|
|
@@ -31676,8 +31696,8 @@
|
|
|
31676
31696
|
modelName: 'gpt-4.1-nano',
|
|
31677
31697
|
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.',
|
|
31678
31698
|
pricing: {
|
|
31679
|
-
prompt: pricing(`$0.
|
|
31680
|
-
output: pricing(`$0.
|
|
31699
|
+
prompt: pricing(`$0.10 / 1M tokens`),
|
|
31700
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
31681
31701
|
},
|
|
31682
31702
|
},
|
|
31683
31703
|
/**/
|
|
@@ -31688,8 +31708,8 @@
|
|
|
31688
31708
|
modelName: 'o3',
|
|
31689
31709
|
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.',
|
|
31690
31710
|
pricing: {
|
|
31691
|
-
prompt: pricing(`$
|
|
31692
|
-
output: pricing(`$
|
|
31711
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
31712
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
31693
31713
|
},
|
|
31694
31714
|
},
|
|
31695
31715
|
/**/
|
|
@@ -31700,8 +31720,8 @@
|
|
|
31700
31720
|
modelName: 'o3-pro',
|
|
31701
31721
|
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.',
|
|
31702
31722
|
pricing: {
|
|
31703
|
-
prompt: pricing(`$
|
|
31704
|
-
output: pricing(`$
|
|
31723
|
+
prompt: pricing(`$20.00 / 1M tokens`),
|
|
31724
|
+
output: pricing(`$80.00 / 1M tokens`),
|
|
31705
31725
|
},
|
|
31706
31726
|
},
|
|
31707
31727
|
/**/
|
|
@@ -31712,8 +31732,8 @@
|
|
|
31712
31732
|
modelName: 'o4-mini',
|
|
31713
31733
|
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.',
|
|
31714
31734
|
pricing: {
|
|
31715
|
-
prompt: pricing(`$
|
|
31716
|
-
output: pricing(`$
|
|
31735
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
31736
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
31717
31737
|
},
|
|
31718
31738
|
},
|
|
31719
31739
|
/**/
|
|
@@ -32071,8 +32091,8 @@
|
|
|
32071
32091
|
modelName: 'gpt-4o-2024-05-13',
|
|
32072
32092
|
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.',
|
|
32073
32093
|
pricing: {
|
|
32074
|
-
prompt: pricing(`$
|
|
32075
|
-
output: pricing(`$
|
|
32094
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
32095
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
32076
32096
|
},
|
|
32077
32097
|
},
|
|
32078
32098
|
/**/
|
|
@@ -32083,8 +32103,8 @@
|
|
|
32083
32103
|
modelName: 'gpt-4o',
|
|
32084
32104
|
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.",
|
|
32085
32105
|
pricing: {
|
|
32086
|
-
prompt: pricing(`$
|
|
32087
|
-
output: pricing(`$
|
|
32106
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
32107
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
32088
32108
|
},
|
|
32089
32109
|
},
|
|
32090
32110
|
/**/
|
|
@@ -32155,8 +32175,8 @@
|
|
|
32155
32175
|
modelName: 'o3-mini',
|
|
32156
32176
|
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.',
|
|
32157
32177
|
pricing: {
|
|
32158
|
-
prompt: pricing(`$
|
|
32159
|
-
output: pricing(`$
|
|
32178
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
32179
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
32160
32180
|
},
|
|
32161
32181
|
},
|
|
32162
32182
|
/**/
|
|
@@ -32671,7 +32691,7 @@
|
|
|
32671
32691
|
const modelName = modelRequirements.modelName ||
|
|
32672
32692
|
((_a = availableModels.find(({ modelVariant }) => modelVariant === 'CHAT')) === null || _a === void 0 ? void 0 : _a.modelName);
|
|
32673
32693
|
if (!modelName) {
|
|
32674
|
-
throw new PipelineExecutionError(
|
|
32694
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
32675
32695
|
Can not determine which model to use.
|
|
32676
32696
|
|
|
32677
32697
|
You need to provide at least one of:
|
|
@@ -32786,7 +32806,7 @@
|
|
|
32786
32806
|
/**
|
|
32787
32807
|
* List of available Deepseek models with descriptions
|
|
32788
32808
|
*
|
|
32789
|
-
* Note: Synced with official API docs at
|
|
32809
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
32790
32810
|
*
|
|
32791
32811
|
* @see https://www.deepseek.com/models
|
|
32792
32812
|
* @public exported from `@promptbook/deepseek`
|
|
@@ -32800,8 +32820,8 @@
|
|
|
32800
32820
|
modelName: 'deepseek-chat',
|
|
32801
32821
|
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.',
|
|
32802
32822
|
pricing: {
|
|
32803
|
-
prompt: pricing(`$0.
|
|
32804
|
-
output: pricing(`$0.
|
|
32823
|
+
prompt: pricing(`$0.28 / 1M tokens`),
|
|
32824
|
+
output: pricing(`$0.42 / 1M tokens`),
|
|
32805
32825
|
},
|
|
32806
32826
|
},
|
|
32807
32827
|
{
|
|
@@ -33067,7 +33087,7 @@
|
|
|
33067
33087
|
/**
|
|
33068
33088
|
* List of available Google models with descriptions
|
|
33069
33089
|
*
|
|
33070
|
-
* Note: Synced with official API docs at
|
|
33090
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
33071
33091
|
*
|
|
33072
33092
|
* @see https://ai.google.dev/models/gemini
|
|
33073
33093
|
* @public exported from `@promptbook/google`
|
|
@@ -33088,8 +33108,8 @@
|
|
|
33088
33108
|
modelName: 'gemini-2.5-pro',
|
|
33089
33109
|
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.',
|
|
33090
33110
|
pricing: {
|
|
33091
|
-
prompt: pricing(`$
|
|
33092
|
-
output: pricing(`$
|
|
33111
|
+
prompt: pricing(`$1.25 / 1M tokens`),
|
|
33112
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
33093
33113
|
},
|
|
33094
33114
|
},
|
|
33095
33115
|
{
|
|
@@ -33098,8 +33118,8 @@
|
|
|
33098
33118
|
modelName: 'gemini-2.5-flash',
|
|
33099
33119
|
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.',
|
|
33100
33120
|
pricing: {
|
|
33101
|
-
prompt: pricing(`$0.
|
|
33102
|
-
output: pricing(`$
|
|
33121
|
+
prompt: pricing(`$0.30 / 1M tokens`),
|
|
33122
|
+
output: pricing(`$2.50 / 1M tokens`),
|
|
33103
33123
|
},
|
|
33104
33124
|
},
|
|
33105
33125
|
{
|
|
@@ -33108,8 +33128,8 @@
|
|
|
33108
33128
|
modelName: 'gemini-2.5-flash-lite',
|
|
33109
33129
|
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.',
|
|
33110
33130
|
pricing: {
|
|
33111
|
-
prompt: pricing(`$0.
|
|
33112
|
-
output: pricing(`$0.
|
|
33131
|
+
prompt: pricing(`$0.10 / 1M tokens`),
|
|
33132
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
33113
33133
|
},
|
|
33114
33134
|
},
|
|
33115
33135
|
{
|
|
@@ -33588,53 +33608,6 @@
|
|
|
33588
33608
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
33589
33609
|
*/
|
|
33590
33610
|
|
|
33591
|
-
/**
|
|
33592
|
-
* Maps Promptbook tools to OpenAI tools.
|
|
33593
|
-
*
|
|
33594
|
-
* @private
|
|
33595
|
-
*/
|
|
33596
|
-
function mapToolsToOpenAi(tools) {
|
|
33597
|
-
return tools.map((tool) => ({
|
|
33598
|
-
type: 'function',
|
|
33599
|
-
function: {
|
|
33600
|
-
name: tool.name,
|
|
33601
|
-
description: tool.description,
|
|
33602
|
-
parameters: tool.parameters,
|
|
33603
|
-
},
|
|
33604
|
-
}));
|
|
33605
|
-
}
|
|
33606
|
-
|
|
33607
|
-
/**
|
|
33608
|
-
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
33609
|
-
*
|
|
33610
|
-
* @private utility of OpenAI tool execution wrappers
|
|
33611
|
-
*/
|
|
33612
|
-
function buildToolInvocationScript(options) {
|
|
33613
|
-
const { functionName, functionArgsExpression } = options;
|
|
33614
|
-
return `
|
|
33615
|
-
const args = ${functionArgsExpression};
|
|
33616
|
-
const runtimeContextRaw =
|
|
33617
|
-
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
33618
|
-
? undefined
|
|
33619
|
-
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
33620
|
-
|
|
33621
|
-
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
33622
|
-
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
33623
|
-
}
|
|
33624
|
-
|
|
33625
|
-
const toolProgressTokenRaw =
|
|
33626
|
-
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
33627
|
-
? undefined
|
|
33628
|
-
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
33629
|
-
|
|
33630
|
-
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
33631
|
-
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
33632
|
-
}
|
|
33633
|
-
|
|
33634
|
-
return await ${functionName}(args);
|
|
33635
|
-
`;
|
|
33636
|
-
}
|
|
33637
|
-
|
|
33638
33611
|
/**
|
|
33639
33612
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
33640
33613
|
*
|
|
@@ -33691,6 +33664,53 @@
|
|
|
33691
33664
|
errorMessage.includes('does not support'));
|
|
33692
33665
|
}
|
|
33693
33666
|
|
|
33667
|
+
/**
|
|
33668
|
+
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
33669
|
+
*
|
|
33670
|
+
* @private utility of OpenAI tool execution wrappers
|
|
33671
|
+
*/
|
|
33672
|
+
function buildToolInvocationScript(options) {
|
|
33673
|
+
const { functionName, functionArgsExpression } = options;
|
|
33674
|
+
return `
|
|
33675
|
+
const args = ${functionArgsExpression};
|
|
33676
|
+
const runtimeContextRaw =
|
|
33677
|
+
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
33678
|
+
? undefined
|
|
33679
|
+
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
33680
|
+
|
|
33681
|
+
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
33682
|
+
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
33683
|
+
}
|
|
33684
|
+
|
|
33685
|
+
const toolProgressTokenRaw =
|
|
33686
|
+
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
33687
|
+
? undefined
|
|
33688
|
+
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
33689
|
+
|
|
33690
|
+
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
33691
|
+
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
33692
|
+
}
|
|
33693
|
+
|
|
33694
|
+
return await ${functionName}(args);
|
|
33695
|
+
`;
|
|
33696
|
+
}
|
|
33697
|
+
|
|
33698
|
+
/**
|
|
33699
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
33700
|
+
*
|
|
33701
|
+
* @private
|
|
33702
|
+
*/
|
|
33703
|
+
function mapToolsToOpenAi(tools) {
|
|
33704
|
+
return tools.map((tool) => ({
|
|
33705
|
+
type: 'function',
|
|
33706
|
+
function: {
|
|
33707
|
+
name: tool.name,
|
|
33708
|
+
description: tool.description,
|
|
33709
|
+
parameters: tool.parameters,
|
|
33710
|
+
},
|
|
33711
|
+
}));
|
|
33712
|
+
}
|
|
33713
|
+
|
|
33694
33714
|
/**
|
|
33695
33715
|
* Provides access to the structured clone implementation when available.
|
|
33696
33716
|
*/
|
|
@@ -34657,7 +34677,7 @@
|
|
|
34657
34677
|
// Note: Match exact or prefix for model families
|
|
34658
34678
|
const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
|
|
34659
34679
|
if (model === undefined) {
|
|
34660
|
-
throw new PipelineExecutionError(
|
|
34680
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
34661
34681
|
Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
|
|
34662
34682
|
|
|
34663
34683
|
Available models:
|
|
@@ -36414,7 +36434,7 @@
|
|
|
36414
36434
|
assertsError(error);
|
|
36415
36435
|
const serializedError = serializeError(error);
|
|
36416
36436
|
errors = [serializedError];
|
|
36417
|
-
functionResponse =
|
|
36437
|
+
functionResponse = _spaceTrim.spaceTrim((block) => `
|
|
36418
36438
|
|
|
36419
36439
|
The invoked tool \`${functionName}\` failed with error:
|
|
36420
36440
|
|
|
@@ -37143,7 +37163,7 @@
|
|
|
37143
37163
|
await $execCommand(command);
|
|
37144
37164
|
// Note: [0]
|
|
37145
37165
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
37146
|
-
throw new UnexpectedError(
|
|
37166
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
37147
37167
|
File that was supposed to be created by Pandoc does not exist for unknown reason
|
|
37148
37168
|
|
|
37149
37169
|
Expected file:
|
|
@@ -37307,7 +37327,7 @@
|
|
|
37307
37327
|
await $execCommand(command);
|
|
37308
37328
|
// Note: [0]
|
|
37309
37329
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
37310
|
-
throw new UnexpectedError(
|
|
37330
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
37311
37331
|
File that was supposed to be created by Pandoc does not exist for unknown reason
|
|
37312
37332
|
|
|
37313
37333
|
Expected file:
|
|
@@ -37458,7 +37478,7 @@
|
|
|
37458
37478
|
await $execCommand(command);
|
|
37459
37479
|
const files = await promises.readdir(documentSourceOutdirPathForLibreOffice);
|
|
37460
37480
|
if (files.length !== 1) {
|
|
37461
|
-
throw new UnexpectedError(
|
|
37481
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
37462
37482
|
Expected exactly 1 file in the LibreOffice output directory, got ${files.length}
|
|
37463
37483
|
|
|
37464
37484
|
The temporary folder:
|
|
@@ -37472,7 +37492,7 @@
|
|
|
37472
37492
|
await promises.rename(path.join(documentSourceOutdirPathForLibreOffice, file), cacheFilehandler.filename);
|
|
37473
37493
|
await promises.rmdir(documentSourceOutdirPathForLibreOffice);
|
|
37474
37494
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
37475
|
-
throw new UnexpectedError(
|
|
37495
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
37476
37496
|
File that was supposed to be created by LibreOffice does not exist for unknown reason
|
|
37477
37497
|
|
|
37478
37498
|
Expected file:
|
|
@@ -38145,7 +38165,7 @@
|
|
|
38145
38165
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
38146
38166
|
commitments.push({
|
|
38147
38167
|
type: currentCommitment.type,
|
|
38148
|
-
content:
|
|
38168
|
+
content: _spaceTrim.spaceTrim(fullContent),
|
|
38149
38169
|
originalLine: currentCommitment.originalStartLine,
|
|
38150
38170
|
lineNumber: currentCommitment.startLineNumber,
|
|
38151
38171
|
});
|
|
@@ -38173,7 +38193,7 @@
|
|
|
38173
38193
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
38174
38194
|
commitments.push({
|
|
38175
38195
|
type: currentCommitment.type,
|
|
38176
|
-
content:
|
|
38196
|
+
content: _spaceTrim.spaceTrim(fullContent),
|
|
38177
38197
|
originalLine: currentCommitment.originalStartLine,
|
|
38178
38198
|
lineNumber: currentCommitment.startLineNumber,
|
|
38179
38199
|
});
|
|
@@ -38199,7 +38219,7 @@
|
|
|
38199
38219
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
38200
38220
|
commitments.push({
|
|
38201
38221
|
type: currentCommitment.type,
|
|
38202
|
-
content:
|
|
38222
|
+
content: _spaceTrim.spaceTrim(fullContent),
|
|
38203
38223
|
originalLine: currentCommitment.originalStartLine,
|
|
38204
38224
|
lineNumber: currentCommitment.startLineNumber,
|
|
38205
38225
|
});
|
|
@@ -38238,7 +38258,7 @@
|
|
|
38238
38258
|
.filter((c) => ['PERSONA', 'RULE', 'KNOWLEDGE'].includes(c.type))
|
|
38239
38259
|
.map((c) => `${c.type} ${c.content}`)
|
|
38240
38260
|
.join('\n\n');
|
|
38241
|
-
return
|
|
38261
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
38242
38262
|
${block(relevantCommitments)}
|
|
38243
38263
|
|
|
38244
38264
|
${block(corpus)}
|
|
@@ -38739,7 +38759,7 @@
|
|
|
38739
38759
|
* @public exported from `@promptbook/core`
|
|
38740
38760
|
*/
|
|
38741
38761
|
function normalizeAgentName(rawAgentName) {
|
|
38742
|
-
return titleToName(
|
|
38762
|
+
return titleToName(_spaceTrim.spaceTrim(rawAgentName));
|
|
38743
38763
|
}
|
|
38744
38764
|
|
|
38745
38765
|
/**
|
|
@@ -38914,7 +38934,7 @@
|
|
|
38914
38934
|
continue;
|
|
38915
38935
|
}
|
|
38916
38936
|
if (commitment.type === 'FROM') {
|
|
38917
|
-
const content =
|
|
38937
|
+
const content = _spaceTrim.spaceTrim(commitment.content).split(/\r?\n/)[0] || '';
|
|
38918
38938
|
if (content === 'Adam' || content === '' /* <- Note: Adam is implicit */) {
|
|
38919
38939
|
continue;
|
|
38920
38940
|
}
|
|
@@ -38937,7 +38957,7 @@
|
|
|
38937
38957
|
continue;
|
|
38938
38958
|
}
|
|
38939
38959
|
if (commitment.type === 'IMPORT') {
|
|
38940
|
-
const content =
|
|
38960
|
+
const content = _spaceTrim.spaceTrim(commitment.content).split(/\r?\n/)[0] || '';
|
|
38941
38961
|
let label = content;
|
|
38942
38962
|
let iconName = 'ExternalLink'; // Import remote
|
|
38943
38963
|
try {
|
|
@@ -38975,7 +38995,7 @@
|
|
|
38975
38995
|
continue;
|
|
38976
38996
|
}
|
|
38977
38997
|
if (commitment.type === 'KNOWLEDGE') {
|
|
38978
|
-
const content =
|
|
38998
|
+
const content = _spaceTrim.spaceTrim(commitment.content);
|
|
38979
38999
|
const extractedUrls = extractUrlsFromText(content);
|
|
38980
39000
|
let label = content;
|
|
38981
39001
|
let iconName = 'Book';
|
|
@@ -39034,7 +39054,7 @@
|
|
|
39034
39054
|
continue;
|
|
39035
39055
|
}
|
|
39036
39056
|
if (commitment.type === 'META LINK') {
|
|
39037
|
-
const linkValue =
|
|
39057
|
+
const linkValue = _spaceTrim.spaceTrim(commitment.content);
|
|
39038
39058
|
links.push(linkValue);
|
|
39039
39059
|
meta.link = linkValue;
|
|
39040
39060
|
continue;
|
|
@@ -39044,11 +39064,11 @@
|
|
|
39044
39064
|
continue;
|
|
39045
39065
|
}
|
|
39046
39066
|
if (commitment.type === 'META IMAGE') {
|
|
39047
|
-
meta.image =
|
|
39067
|
+
meta.image = _spaceTrim.spaceTrim(commitment.content);
|
|
39048
39068
|
continue;
|
|
39049
39069
|
}
|
|
39050
39070
|
if (commitment.type === 'META DESCRIPTION') {
|
|
39051
|
-
meta.description =
|
|
39071
|
+
meta.description = _spaceTrim.spaceTrim(commitment.content);
|
|
39052
39072
|
continue;
|
|
39053
39073
|
}
|
|
39054
39074
|
if (commitment.type === 'META DISCLAIMER') {
|
|
@@ -39056,7 +39076,7 @@
|
|
|
39056
39076
|
continue;
|
|
39057
39077
|
}
|
|
39058
39078
|
if (commitment.type === 'META INPUT PLACEHOLDER') {
|
|
39059
|
-
meta.inputPlaceholder =
|
|
39079
|
+
meta.inputPlaceholder = _spaceTrim.spaceTrim(commitment.content);
|
|
39060
39080
|
continue;
|
|
39061
39081
|
}
|
|
39062
39082
|
if (commitment.type === 'MESSAGE SUFFIX') {
|
|
@@ -39072,7 +39092,7 @@
|
|
|
39072
39092
|
continue;
|
|
39073
39093
|
}
|
|
39074
39094
|
if (commitment.type === 'META VOICE') {
|
|
39075
|
-
meta.voice =
|
|
39095
|
+
meta.voice = _spaceTrim.spaceTrim(commitment.content);
|
|
39076
39096
|
continue;
|
|
39077
39097
|
}
|
|
39078
39098
|
if (commitment.type !== 'META') {
|
|
@@ -39081,10 +39101,10 @@
|
|
|
39081
39101
|
// Parse META commitments - format is "META TYPE content"
|
|
39082
39102
|
const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
|
|
39083
39103
|
if (metaTypeRaw === 'LINK') {
|
|
39084
|
-
links.push(
|
|
39104
|
+
links.push(_spaceTrim.spaceTrim(commitment.content.substring(metaTypeRaw.length)));
|
|
39085
39105
|
}
|
|
39086
39106
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
39087
|
-
meta[metaType] =
|
|
39107
|
+
meta[metaType] = _spaceTrim.spaceTrim(commitment.content.substring(metaTypeRaw.length));
|
|
39088
39108
|
}
|
|
39089
39109
|
// Generate fullname fallback if no meta fullname specified
|
|
39090
39110
|
if (!meta.fullname) {
|
|
@@ -39115,7 +39135,7 @@
|
|
|
39115
39135
|
* @returns The content with normalized separators
|
|
39116
39136
|
*/
|
|
39117
39137
|
function normalizeSeparator(content) {
|
|
39118
|
-
const trimmed =
|
|
39138
|
+
const trimmed = _spaceTrim.spaceTrim(content);
|
|
39119
39139
|
if (trimmed.includes(',')) {
|
|
39120
39140
|
return trimmed;
|
|
39121
39141
|
}
|
|
@@ -39128,7 +39148,7 @@
|
|
|
39128
39148
|
* @returns Normalized domain or a trimmed fallback.
|
|
39129
39149
|
*/
|
|
39130
39150
|
function normalizeMetaDomain(content) {
|
|
39131
|
-
const trimmed =
|
|
39151
|
+
const trimmed = _spaceTrim.spaceTrim(content);
|
|
39132
39152
|
return normalizeDomainForMatching(trimmed) || trimmed.toLowerCase();
|
|
39133
39153
|
}
|
|
39134
39154
|
/**
|
|
@@ -39266,7 +39286,7 @@
|
|
|
39266
39286
|
}
|
|
39267
39287
|
const KNOWLEDGE_THRESHOLD = 1000;
|
|
39268
39288
|
if (directKnowledge.join('\n').length > KNOWLEDGE_THRESHOLD || knowledgeSources.length > 0) {
|
|
39269
|
-
return
|
|
39289
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
39270
39290
|
#!/usr/bin/env node
|
|
39271
39291
|
|
|
39272
39292
|
import * as dotenv from 'dotenv';
|
|
@@ -39341,7 +39361,7 @@
|
|
|
39341
39361
|
|
|
39342
39362
|
if (context) {
|
|
39343
39363
|
question = spaceTrim(\`
|
|
39344
|
-
${block(
|
|
39364
|
+
${block(_spaceTrim.spaceTrim(`
|
|
39345
39365
|
Here is some additional context to help you answer the question:
|
|
39346
39366
|
\${context}
|
|
39347
39367
|
|
|
@@ -39422,7 +39442,7 @@
|
|
|
39422
39442
|
})();
|
|
39423
39443
|
`);
|
|
39424
39444
|
}
|
|
39425
|
-
const source =
|
|
39445
|
+
const source = _spaceTrim.spaceTrim((block) => `
|
|
39426
39446
|
|
|
39427
39447
|
#!/usr/bin/env node
|
|
39428
39448
|
|
|
@@ -39612,7 +39632,7 @@
|
|
|
39612
39632
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
39613
39633
|
*/
|
|
39614
39634
|
|
|
39615
|
-
// find-fresh-emoji-
|
|
39635
|
+
// find-fresh-emoji-tags.ts
|
|
39616
39636
|
// Note: When run as a standalone script, call the exported function
|
|
39617
39637
|
if (require.main === module) {
|
|
39618
39638
|
findFreshEmojiTag()
|
|
@@ -39633,7 +39653,13 @@
|
|
|
39633
39653
|
function initializeFindFreshEmojiTagRun() {
|
|
39634
39654
|
dotenv__namespace.config({ path: '.env' });
|
|
39635
39655
|
if (process.cwd() !== path.join(__dirname, '../..')) {
|
|
39636
|
-
console.error(colors__default["default"].red(`
|
|
39656
|
+
console.error(colors__default["default"].red(_spaceTrim.spaceTrim(`
|
|
39657
|
+
CWD must be root of the project
|
|
39658
|
+
|
|
39659
|
+
Script: find-fresh-emoji-tag.ts
|
|
39660
|
+
Current CWD: ${process.cwd()}
|
|
39661
|
+
Expected CWD: ${path.join(__dirname, '../..')}
|
|
39662
|
+
`)));
|
|
39637
39663
|
process.exit(1);
|
|
39638
39664
|
}
|
|
39639
39665
|
}
|
|
@@ -39683,7 +39709,7 @@
|
|
|
39683
39709
|
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
39684
39710
|
*/
|
|
39685
39711
|
|
|
39686
|
-
var
|
|
39712
|
+
var findFreshEmojiTags = /*#__PURE__*/Object.freeze({
|
|
39687
39713
|
__proto__: null,
|
|
39688
39714
|
findFreshEmojiTag: findFreshEmojiTag
|
|
39689
39715
|
});
|
|
@@ -39932,7 +39958,13 @@
|
|
|
39932
39958
|
function initializeFindRefactorCandidatesRun() {
|
|
39933
39959
|
dotenv__namespace.config({ path: '.env' });
|
|
39934
39960
|
if (process.cwd() !== path.join(__dirname, '../..')) {
|
|
39935
|
-
console.error(colors__default["default"].red(`
|
|
39961
|
+
console.error(colors__default["default"].red(_spaceTrim.spaceTrim(`
|
|
39962
|
+
CWD must be root of the project
|
|
39963
|
+
|
|
39964
|
+
Script: find-refactor-candidates.ts
|
|
39965
|
+
Current CWD: ${process.cwd()}
|
|
39966
|
+
Expected CWD: ${path.join(__dirname, '../..')}
|
|
39967
|
+
`)));
|
|
39936
39968
|
process.exit(1);
|
|
39937
39969
|
}
|
|
39938
39970
|
}
|
|
@@ -40032,7 +40064,7 @@
|
|
|
40032
40064
|
function buildPromptContent(candidate, emojiTag) {
|
|
40033
40065
|
const fileName = path.basename(candidate.relativePath);
|
|
40034
40066
|
const guidanceLines = buildPromptGuidance(candidate);
|
|
40035
|
-
return
|
|
40067
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
40036
40068
|
|
|
40037
40069
|
[ ]
|
|
40038
40070
|
|
|
@@ -40922,7 +40954,7 @@
|
|
|
40922
40954
|
}
|
|
40923
40955
|
const currentBranch = await readCurrentBranchName(agentEnv);
|
|
40924
40956
|
if (currentBranch === 'HEAD') {
|
|
40925
|
-
throw new GitPushFailedError(
|
|
40957
|
+
throw new GitPushFailedError(_spaceTrim.spaceTrim(`
|
|
40926
40958
|
Failed to push coding-agent commit because Git is in detached HEAD mode.
|
|
40927
40959
|
|
|
40928
40960
|
Actionable hint:
|
|
@@ -41002,7 +41034,7 @@
|
|
|
41002
41034
|
return remotes[0];
|
|
41003
41035
|
}
|
|
41004
41036
|
if (remotes.length > 1) {
|
|
41005
|
-
throw new GitPushFailedError(
|
|
41037
|
+
throw new GitPushFailedError(_spaceTrim.spaceTrim(`
|
|
41006
41038
|
Failed to push coding-agent commit because no default remote is configured.
|
|
41007
41039
|
|
|
41008
41040
|
Available remotes: ${remotes.join(', ')}
|
|
@@ -41011,7 +41043,7 @@
|
|
|
41011
41043
|
- Configure \`remote.pushDefault\` or \`branch.${currentBranch}.remote\`, then rerun the coding script.
|
|
41012
41044
|
`));
|
|
41013
41045
|
}
|
|
41014
|
-
throw new GitPushFailedError(
|
|
41046
|
+
throw new GitPushFailedError(_spaceTrim.spaceTrim(`
|
|
41015
41047
|
Failed to push coding-agent commit because no Git remote is configured.
|
|
41016
41048
|
|
|
41017
41049
|
Actionable hint:
|
|
@@ -41056,7 +41088,7 @@
|
|
|
41056
41088
|
const details = stringifyUnknownError(error).trim() || '(No Git output)';
|
|
41057
41089
|
const hints = buildPushFailureHints(details);
|
|
41058
41090
|
const hintsMarkdown = hints.map((hint) => `- ${hint}`).join('\n');
|
|
41059
|
-
return
|
|
41091
|
+
return _spaceTrim.spaceTrim(`
|
|
41060
41092
|
Failed to push coding-agent commit to the remote repository.
|
|
41061
41093
|
|
|
41062
41094
|
Command:
|
|
@@ -41154,7 +41186,7 @@
|
|
|
41154
41186
|
async function ensureWorkingTreeClean() {
|
|
41155
41187
|
const isClean = await isWorkingTreeClean(process.cwd());
|
|
41156
41188
|
if (!isClean) {
|
|
41157
|
-
throw new Error(
|
|
41189
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
41158
41190
|
Git working tree is not clean.
|
|
41159
41191
|
|
|
41160
41192
|
Please commit or stash your changes before running this script
|
|
@@ -41272,7 +41304,7 @@
|
|
|
41272
41304
|
function parseServerRecord(rawRow, label = 'row') {
|
|
41273
41305
|
const rawEnvironment = typeof rawRow.environment === 'string' ? rawRow.environment.trim().toUpperCase() : '';
|
|
41274
41306
|
if (!isServerEnvironment(rawEnvironment)) {
|
|
41275
|
-
throw new DatabaseError(
|
|
41307
|
+
throw new DatabaseError(_spaceTrim.spaceTrim(`
|
|
41276
41308
|
Invalid \`${SERVER_REGISTRY_TABLE_NAME}\` ${label}.
|
|
41277
41309
|
|
|
41278
41310
|
Field \`environment\` must be one of \`${SERVER_ENVIRONMENT.PRODUCTION}\`, \`${SERVER_ENVIRONMENT.PREVIEW}\`, \`${SERVER_ENVIRONMENT.LTS}\` or \`${SERVER_ENVIRONMENT.LIVE}\`.
|
|
@@ -41281,7 +41313,7 @@
|
|
|
41281
41313
|
const domain = typeof rawRow.domain === 'string' ? rawRow.domain.trim().toLowerCase() : '';
|
|
41282
41314
|
const normalizedDomain = normalizeServerDomain(domain);
|
|
41283
41315
|
if (!normalizedDomain) {
|
|
41284
|
-
throw new DatabaseError(
|
|
41316
|
+
throw new DatabaseError(_spaceTrim.spaceTrim(`
|
|
41285
41317
|
Invalid \`${SERVER_REGISTRY_TABLE_NAME}\` ${label}.
|
|
41286
41318
|
|
|
41287
41319
|
Field \`domain\` must contain a valid host or URL-like domain string.
|
|
@@ -41295,7 +41327,7 @@
|
|
|
41295
41327
|
const updatedAt = typeof rawRow.updatedAt === 'string' ? rawRow.updatedAt : '';
|
|
41296
41328
|
const id = typeof rawRow.id === 'number' ? rawRow.id : Number(rawRow.id);
|
|
41297
41329
|
if (!name || !hasTablePrefix /*|| !createdAt || !updatedAt ||*/ || !Number.isFinite(id)) {
|
|
41298
|
-
throw new DatabaseError(
|
|
41330
|
+
throw new DatabaseError(_spaceTrim.spaceTrim(`
|
|
41299
41331
|
Invalid \`${SERVER_REGISTRY_TABLE_NAME}\` ${label}.
|
|
41300
41332
|
|
|
41301
41333
|
Fields \`id\`, \`name\`, \`tablePrefix\`, \`createdAt\`, and \`updatedAt\` are required.
|
|
@@ -41415,7 +41447,7 @@
|
|
|
41415
41447
|
if (isMissingServerRegistryError(error)) {
|
|
41416
41448
|
return [];
|
|
41417
41449
|
}
|
|
41418
|
-
throw new DatabaseError(
|
|
41450
|
+
throw new DatabaseError(_spaceTrim.spaceTrim((block) => `
|
|
41419
41451
|
Failed to query global server registry table \`_Server\`.
|
|
41420
41452
|
|
|
41421
41453
|
${block(error instanceof Error ? error.message : String(error))}
|
|
@@ -41600,7 +41632,7 @@
|
|
|
41600
41632
|
invalidTargets.push(onlyTarget);
|
|
41601
41633
|
}
|
|
41602
41634
|
if (invalidTargets.length > 0) {
|
|
41603
|
-
throw new DatabaseError(
|
|
41635
|
+
throw new DatabaseError(_spaceTrim.spaceTrim(`
|
|
41604
41636
|
Invalid migration targets specified in \`--only\`: ${invalidTargets
|
|
41605
41637
|
.map((target) => `\`${target}\``)
|
|
41606
41638
|
.join(', ')}.
|
|
@@ -41708,7 +41740,7 @@
|
|
|
41708
41740
|
async function resolveDatabaseMigrationRuntimeConfiguration(logger = console) {
|
|
41709
41741
|
const connectionString = resolveDatabaseMigrationConnectionStringFromEnvironment();
|
|
41710
41742
|
if (!connectionString) {
|
|
41711
|
-
throw new DatabaseError(
|
|
41743
|
+
throw new DatabaseError(_spaceTrim.spaceTrim(`
|
|
41712
41744
|
${DATABASE_CONNECTION_ENV_NAMES.join(' or ')} is not defined.
|
|
41713
41745
|
`));
|
|
41714
41746
|
}
|
|
@@ -42070,7 +42102,7 @@
|
|
|
42070
42102
|
.map((match) => `${getReadableRuleName(match.rule)}: ${createSqlStatementPreview(match.statement)}`)
|
|
42071
42103
|
.join(' | ')})`)
|
|
42072
42104
|
.join('\n');
|
|
42073
|
-
return new DatabaseError(
|
|
42105
|
+
return new DatabaseError(_spaceTrim.spaceTrim((block) => `
|
|
42074
42106
|
Auto-migration blocked because pending testing-server migrations contain potentially destructive SQL.
|
|
42075
42107
|
|
|
42076
42108
|
Review these migration statements:
|
|
@@ -43834,7 +43866,7 @@
|
|
|
43834
43866
|
async function runCodexPrompts(providedOptions) {
|
|
43835
43867
|
const options = providedOptions !== null && providedOptions !== void 0 ? providedOptions : parseRunOptions(process.argv.slice(2));
|
|
43836
43868
|
if (options.allowDestructiveAutoMigrate && !options.autoMigrate) {
|
|
43837
|
-
throw new DatabaseError(
|
|
43869
|
+
throw new DatabaseError(_spaceTrim.spaceTrim(`
|
|
43838
43870
|
Flag \`--allow-destructive-auto-migrate\` requires \`--auto-migrate\`.
|
|
43839
43871
|
`));
|
|
43840
43872
|
}
|
|
@@ -44488,7 +44520,7 @@
|
|
|
44488
44520
|
* @deprecated Use `$generateBookBoilerplate` instead
|
|
44489
44521
|
* @public exported from `@promptbook/core`
|
|
44490
44522
|
*/
|
|
44491
|
-
padBook(validateBook(
|
|
44523
|
+
padBook(validateBook(_spaceTrim.spaceTrim(`
|
|
44492
44524
|
AI Avatar
|
|
44493
44525
|
|
|
44494
44526
|
PERSONA A friendly AI assistant that helps you with your tasks
|
|
@@ -44515,7 +44547,7 @@
|
|
|
44515
44547
|
const bookString = prompt(strings, ...values).toString();
|
|
44516
44548
|
if (!isValidPipelineString(bookString)) {
|
|
44517
44549
|
// TODO: Make the CustomError for this
|
|
44518
|
-
throw new Error(
|
|
44550
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
44519
44551
|
The string is not a valid pipeline string
|
|
44520
44552
|
|
|
44521
44553
|
book\`
|
|
@@ -44525,7 +44557,7 @@
|
|
|
44525
44557
|
}
|
|
44526
44558
|
if (!isValidBook(bookString)) {
|
|
44527
44559
|
// TODO: Make the CustomError for this
|
|
44528
|
-
throw new Error(
|
|
44560
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
44529
44561
|
The string is not a valid book
|
|
44530
44562
|
|
|
44531
44563
|
book\`
|
|
@@ -45451,7 +45483,7 @@
|
|
|
45451
45483
|
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
45452
45484
|
*/
|
|
45453
45485
|
|
|
45454
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5-
|
|
45486
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
|
|
45455
45487
|
/**
|
|
45456
45488
|
* Creates one structured log entry for streamed tool-call updates.
|
|
45457
45489
|
*
|
|
@@ -45946,7 +45978,7 @@
|
|
|
45946
45978
|
}),
|
|
45947
45979
|
],
|
|
45948
45980
|
};
|
|
45949
|
-
const errorMessage =
|
|
45981
|
+
const errorMessage = _spaceTrim.spaceTrim((block) => `
|
|
45950
45982
|
|
|
45951
45983
|
The invoked tool \`${functionName}\` failed with error:
|
|
45952
45984
|
|
|
@@ -46827,7 +46859,7 @@
|
|
|
46827
46859
|
if (commitment.type !== 'OPEN') {
|
|
46828
46860
|
continue;
|
|
46829
46861
|
}
|
|
46830
|
-
const trimmed =
|
|
46862
|
+
const trimmed = _spaceTrim.spaceTrim(commitment.content);
|
|
46831
46863
|
return trimmed || null;
|
|
46832
46864
|
}
|
|
46833
46865
|
return null;
|
|
@@ -46896,7 +46928,7 @@
|
|
|
46896
46928
|
if (isJsonSchemaResponseFormat(responseFormat)) {
|
|
46897
46929
|
const jsonSchema = responseFormat.json_schema;
|
|
46898
46930
|
const schemaJson = JSON.stringify(jsonSchema, null, 4);
|
|
46899
|
-
userMessageContent =
|
|
46931
|
+
userMessageContent = _spaceTrim.spaceTrim((block) => `
|
|
46900
46932
|
${block(prompt.content)}
|
|
46901
46933
|
|
|
46902
46934
|
NOTE Request was made through OpenAI Compatible API with \`response_format\` of type \`json_schema\` with the following schema:
|
|
@@ -46927,12 +46959,12 @@
|
|
|
46927
46959
|
const formattedAgentMessage = formatAgentMessageForJsonMode(result.content, usesJsonSchemaMode);
|
|
46928
46960
|
const teacherInstructions = extractOpenTeacherInstructions(agentSource);
|
|
46929
46961
|
const teacherInstructionsSection = teacherInstructions
|
|
46930
|
-
?
|
|
46962
|
+
? _spaceTrim.spaceTrim((block) => `
|
|
46931
46963
|
**Teacher instructions:**
|
|
46932
46964
|
${block(teacherInstructions)}
|
|
46933
46965
|
`)
|
|
46934
46966
|
: '';
|
|
46935
|
-
const teacherPromptContent =
|
|
46967
|
+
const teacherPromptContent = _spaceTrim.spaceTrim((block) => `
|
|
46936
46968
|
|
|
46937
46969
|
You are a teacher agent helping another agent to learn from its interactions.
|
|
46938
46970
|
|
|
@@ -46965,7 +46997,7 @@
|
|
|
46965
46997
|
? '- This interaction used JSON mode, so the agent answer should stay as a formatted JSON code block.'
|
|
46966
46998
|
: ''}
|
|
46967
46999
|
${block(isInitialMessageMissing
|
|
46968
|
-
?
|
|
47000
|
+
? _spaceTrim.spaceTrim(`
|
|
46969
47001
|
- The agent source does not have an INITIAL MESSAGE defined, generate one.
|
|
46970
47002
|
- 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.
|
|
46971
47003
|
- The quick option looks like \`[👋 Hello](?message=Hello, how are you?)\`
|
|
@@ -47008,7 +47040,7 @@
|
|
|
47008
47040
|
*/
|
|
47009
47041
|
appendToAgentSource(section) {
|
|
47010
47042
|
const currentSource = this.options.getAgentSource();
|
|
47011
|
-
const newSource = padBook(validateBook(
|
|
47043
|
+
const newSource = padBook(validateBook(_spaceTrim.spaceTrim(currentSource) + section));
|
|
47012
47044
|
this.options.updateAgentSource(newSource);
|
|
47013
47045
|
}
|
|
47014
47046
|
}
|
|
@@ -47036,13 +47068,13 @@
|
|
|
47036
47068
|
}
|
|
47037
47069
|
const parsedJson = tryParseJson(content);
|
|
47038
47070
|
if (parsedJson === null) {
|
|
47039
|
-
return
|
|
47071
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
47040
47072
|
\`\`\`json
|
|
47041
47073
|
${block(content)}
|
|
47042
47074
|
\`\`\`
|
|
47043
47075
|
`);
|
|
47044
47076
|
}
|
|
47045
|
-
return
|
|
47077
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
47046
47078
|
\`\`\`json
|
|
47047
47079
|
${block(JSON.stringify(parsedJson, null, 4))}
|
|
47048
47080
|
\`\`\`
|
|
@@ -47074,7 +47106,7 @@
|
|
|
47074
47106
|
const internalMessagesSection = options.internalMessages
|
|
47075
47107
|
.map((internalMessage) => formatInternalLearningMessage(internalMessage))
|
|
47076
47108
|
.join('\n\n');
|
|
47077
|
-
return
|
|
47109
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
47078
47110
|
|
|
47079
47111
|
USER MESSAGE
|
|
47080
47112
|
${block(options.userMessageContent)}
|
|
@@ -47092,7 +47124,7 @@
|
|
|
47092
47124
|
* @private function of Agent
|
|
47093
47125
|
*/
|
|
47094
47126
|
function formatInternalLearningMessage(internalMessage) {
|
|
47095
|
-
return
|
|
47127
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
47096
47128
|
INTERNAL MESSAGE
|
|
47097
47129
|
${block(stringifyInternalLearningPayload(internalMessage))}
|
|
47098
47130
|
`);
|
|
@@ -47558,7 +47590,7 @@
|
|
|
47558
47590
|
.filter((line) => Boolean(line))
|
|
47559
47591
|
.join('\n');
|
|
47560
47592
|
const personaBlock = profile.personaDescription
|
|
47561
|
-
?
|
|
47593
|
+
? _spaceTrim.spaceTrim((block) => `
|
|
47562
47594
|
PERSONA
|
|
47563
47595
|
${block(profile.personaDescription || '')}
|
|
47564
47596
|
`)
|
|
@@ -47594,7 +47626,7 @@
|
|
|
47594
47626
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
47595
47627
|
// <- TODO: [🐱🚀] Maybe use promptbookFetch
|
|
47596
47628
|
if (!profileResponse.ok) {
|
|
47597
|
-
throw new Error(
|
|
47629
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
47598
47630
|
Failed to fetch remote agent profile:
|
|
47599
47631
|
|
|
47600
47632
|
Agent URL:
|