@promptbook/node 0.112.0-13 → 0.112.0-15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +185 -185
- package/esm/index.es.js.map +1 -1
- package/esm/src/cli/cli-commands/coder/{find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags.d.ts} +1 -1
- package/esm/src/cli/cli-commands/coder.d.ts +1 -1
- package/esm/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +1 -1
- package/esm/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/esm/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +1 -2
- package/esm/src/scrapers/document/DocumentScraper.d.ts +1 -2
- package/esm/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -2
- package/esm/src/scripting/javascript/postprocessing-functions.d.ts +1 -1
- package/esm/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +1 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +387 -387
- package/umd/index.umd.js.map +1 -1
- package/umd/src/cli/cli-commands/coder/{find-fresh-emoji-tag.d.ts → find-fresh-emoji-tags.d.ts} +1 -1
- package/umd/src/cli/cli-commands/coder.d.ts +1 -1
- package/umd/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +1 -1
- package/umd/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/umd/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/umd/src/llm-providers/google/google-models.d.ts +1 -1
- package/umd/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/umd/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +1 -2
- package/umd/src/scrapers/document/DocumentScraper.d.ts +1 -2
- package/umd/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -2
- package/umd/src/scripting/javascript/postprocessing-functions.d.ts +1 -1
- package/umd/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +1 -2
- package/umd/src/version.d.ts +1 -1
package/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('fs/promises'), require('path'), require('spacetrim'), require('jszip'), require('crypto'), require('crypto-js'), require('crypto-js/enc-hex'), require('@mozilla/readability'), require('jsdom'), require('showdown'), require('child_process'), require('waitasecond'), require('dotenv'), require('crypto-js/sha256'), require('rxjs'), require('mime-types'), require('moment'), require('papaparse'), require('@openai/agents'), require('bottleneck'), require('openai')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'fs/promises', 'path', 'spacetrim', 'jszip', 'crypto', 'crypto-js', 'crypto-js/enc-hex', '@mozilla/readability', 'jsdom', 'showdown', 'child_process', 'waitasecond', 'dotenv', 'crypto-js/sha256', 'rxjs', 'mime-types', 'moment', 'papaparse', '@openai/agents', 'bottleneck', 'openai'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.colors, global.promises, global.path, global.
|
|
5
|
-
})(this, (function (exports, colors, promises, path,
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.colors, global.promises, global.path, global._spaceTrim, global.JSZip, global.crypto, global.cryptoJs, global.hexEncoder, global.readability, global.jsdom, global.showdown, global.child_process, global.waitasecond, global.dotenv, global.sha256, global.rxjs, global.mimeTypes, global.moment, global.papaparse, global.agents, global.Bottleneck, global.OpenAI));
|
|
5
|
+
})(this, (function (exports, colors, promises, path, _spaceTrim, JSZip, crypto, cryptoJs, hexEncoder, readability, jsdom, showdown, child_process, waitasecond, dotenv, sha256, rxjs, mimeTypes, moment, papaparse, agents, Bottleneck, OpenAI) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
28
|
-
var
|
|
28
|
+
var _spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(_spaceTrim);
|
|
29
29
|
var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
|
|
30
30
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
31
31
|
var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* @generated
|
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
|
50
50
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-15';
|
|
52
52
|
/**
|
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
54
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
* @public exported from `@promptbook/utils`
|
|
64
64
|
* @see https://github.com/hejny/spacetrim#usage
|
|
65
65
|
*/
|
|
66
|
-
const spaceTrim =
|
|
66
|
+
const spaceTrim = _spaceTrim.spaceTrim;
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* @private util of `@promptbook/color`
|
|
@@ -1226,7 +1226,7 @@
|
|
|
1226
1226
|
function getErrorReportUrl(error) {
|
|
1227
1227
|
const report = {
|
|
1228
1228
|
title: `🐜 Error report from ${NAME}`,
|
|
1229
|
-
body:
|
|
1229
|
+
body: _spaceTrim.spaceTrim((block) => `
|
|
1230
1230
|
|
|
1231
1231
|
|
|
1232
1232
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1269,7 +1269,7 @@
|
|
|
1269
1269
|
*/
|
|
1270
1270
|
class UnexpectedError extends Error {
|
|
1271
1271
|
constructor(message) {
|
|
1272
|
-
super(
|
|
1272
|
+
super(_spaceTrim.spaceTrim((block) => `
|
|
1273
1273
|
${block(message)}
|
|
1274
1274
|
|
|
1275
1275
|
Note: This error should not happen.
|
|
@@ -1299,7 +1299,7 @@
|
|
|
1299
1299
|
}
|
|
1300
1300
|
else if (typeof value !== 'string') {
|
|
1301
1301
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
1302
|
-
throw new Error(
|
|
1302
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
1303
1303
|
Can not parse JSON from non-string value.
|
|
1304
1304
|
|
|
1305
1305
|
The value type: ${typeof value}
|
|
@@ -1313,7 +1313,7 @@
|
|
|
1313
1313
|
if (!(error instanceof Error)) {
|
|
1314
1314
|
throw error;
|
|
1315
1315
|
}
|
|
1316
|
-
throw new Error(
|
|
1316
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
1317
1317
|
${block(error.message)}
|
|
1318
1318
|
|
|
1319
1319
|
The expected JSON text:
|
|
@@ -1373,7 +1373,7 @@
|
|
|
1373
1373
|
constructor(whatWasThrown) {
|
|
1374
1374
|
const tag = `[🤮]`;
|
|
1375
1375
|
console.error(tag, whatWasThrown);
|
|
1376
|
-
super(
|
|
1376
|
+
super(_spaceTrim.spaceTrim(`
|
|
1377
1377
|
Non-Error object was thrown
|
|
1378
1378
|
|
|
1379
1379
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1462,7 +1462,7 @@
|
|
|
1462
1462
|
}
|
|
1463
1463
|
else if (typeof value === 'object') {
|
|
1464
1464
|
if (value instanceof Date) {
|
|
1465
|
-
throw new UnexpectedError(
|
|
1465
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
1466
1466
|
\`${name}\` is Date
|
|
1467
1467
|
|
|
1468
1468
|
Use \`string_date_iso8601\` instead
|
|
@@ -1481,7 +1481,7 @@
|
|
|
1481
1481
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
1482
1482
|
}
|
|
1483
1483
|
else if (value instanceof Error) {
|
|
1484
|
-
throw new UnexpectedError(
|
|
1484
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
1485
1485
|
\`${name}\` is unserialized Error
|
|
1486
1486
|
|
|
1487
1487
|
Use function \`serializeError\`
|
|
@@ -1504,7 +1504,7 @@
|
|
|
1504
1504
|
}
|
|
1505
1505
|
catch (error) {
|
|
1506
1506
|
assertsError(error);
|
|
1507
|
-
throw new UnexpectedError(
|
|
1507
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
1508
1508
|
\`${name}\` is not serializable
|
|
1509
1509
|
|
|
1510
1510
|
${block(error.stack || error.message)}
|
|
@@ -1536,7 +1536,7 @@
|
|
|
1536
1536
|
}
|
|
1537
1537
|
}
|
|
1538
1538
|
else {
|
|
1539
|
-
throw new UnexpectedError(
|
|
1539
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
1540
1540
|
\`${name}\` is unknown type
|
|
1541
1541
|
|
|
1542
1542
|
Additional message for \`${name}\`:
|
|
@@ -1889,7 +1889,7 @@
|
|
|
1889
1889
|
if (!(error instanceof PipelineLogicError)) {
|
|
1890
1890
|
throw error;
|
|
1891
1891
|
}
|
|
1892
|
-
console.error(
|
|
1892
|
+
console.error(_spaceTrim.spaceTrim((block) => `
|
|
1893
1893
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
1894
1894
|
|
|
1895
1895
|
${block(error.message)}
|
|
@@ -1916,7 +1916,7 @@
|
|
|
1916
1916
|
})();
|
|
1917
1917
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
1918
1918
|
// <- Note: [🚲]
|
|
1919
|
-
throw new PipelineLogicError(
|
|
1919
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
1920
1920
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
1921
1921
|
|
|
1922
1922
|
${block(pipelineIdentification)}
|
|
@@ -1924,7 +1924,7 @@
|
|
|
1924
1924
|
}
|
|
1925
1925
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
1926
1926
|
// <- Note: [🚲]
|
|
1927
|
-
throw new PipelineLogicError(
|
|
1927
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
1928
1928
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
1929
1929
|
|
|
1930
1930
|
${block(pipelineIdentification)}
|
|
@@ -1933,7 +1933,7 @@
|
|
|
1933
1933
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
1934
1934
|
if (!Array.isArray(pipeline.parameters)) {
|
|
1935
1935
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
1936
|
-
throw new ParseError(
|
|
1936
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
1937
1937
|
Pipeline is valid JSON but with wrong structure
|
|
1938
1938
|
|
|
1939
1939
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -1944,7 +1944,7 @@
|
|
|
1944
1944
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
1945
1945
|
if (!Array.isArray(pipeline.tasks)) {
|
|
1946
1946
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
1947
|
-
throw new ParseError(
|
|
1947
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
1948
1948
|
Pipeline is valid JSON but with wrong structure
|
|
1949
1949
|
|
|
1950
1950
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -1970,7 +1970,7 @@
|
|
|
1970
1970
|
// Note: Check each parameter individually
|
|
1971
1971
|
for (const parameter of pipeline.parameters) {
|
|
1972
1972
|
if (parameter.isInput && parameter.isOutput) {
|
|
1973
|
-
throw new PipelineLogicError(
|
|
1973
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
1974
1974
|
|
|
1975
1975
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
1976
1976
|
|
|
@@ -1981,7 +1981,7 @@
|
|
|
1981
1981
|
if (!parameter.isInput &&
|
|
1982
1982
|
!parameter.isOutput &&
|
|
1983
1983
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
1984
|
-
throw new PipelineLogicError(
|
|
1984
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
1985
1985
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
1986
1986
|
|
|
1987
1987
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -1993,7 +1993,7 @@
|
|
|
1993
1993
|
}
|
|
1994
1994
|
// Note: Testing that parameter is either input or result of some task
|
|
1995
1995
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
1996
|
-
throw new PipelineLogicError(
|
|
1996
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
1997
1997
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
1998
1998
|
|
|
1999
1999
|
You can do one of these:
|
|
@@ -2009,14 +2009,14 @@
|
|
|
2009
2009
|
// Note: Checking each task individually
|
|
2010
2010
|
for (const task of pipeline.tasks) {
|
|
2011
2011
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
2012
|
-
throw new PipelineLogicError(
|
|
2012
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
2013
2013
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
2014
2014
|
|
|
2015
2015
|
${block(pipelineIdentification)}
|
|
2016
2016
|
`));
|
|
2017
2017
|
}
|
|
2018
2018
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
2019
|
-
throw new PipelineLogicError(
|
|
2019
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
2020
2020
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
2021
2021
|
|
|
2022
2022
|
${block(pipelineIdentification)}
|
|
@@ -2026,7 +2026,7 @@
|
|
|
2026
2026
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
2027
2027
|
if (!task.format &&
|
|
2028
2028
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
2029
|
-
throw new PipelineLogicError(
|
|
2029
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
2030
2030
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
2031
2031
|
|
|
2032
2032
|
${block(pipelineIdentification)}
|
|
@@ -2034,7 +2034,7 @@
|
|
|
2034
2034
|
}
|
|
2035
2035
|
for (const joker of task.jokerParameterNames) {
|
|
2036
2036
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
2037
|
-
throw new PipelineLogicError(
|
|
2037
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
2038
2038
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
2039
2039
|
|
|
2040
2040
|
${block(pipelineIdentification)}
|
|
@@ -2045,21 +2045,21 @@
|
|
|
2045
2045
|
if (task.expectations) {
|
|
2046
2046
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
2047
2047
|
if (min !== undefined && max !== undefined && min > max) {
|
|
2048
|
-
throw new PipelineLogicError(
|
|
2048
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
2049
2049
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
2050
2050
|
|
|
2051
2051
|
${block(pipelineIdentification)}
|
|
2052
2052
|
`));
|
|
2053
2053
|
}
|
|
2054
2054
|
if (min !== undefined && min < 0) {
|
|
2055
|
-
throw new PipelineLogicError(
|
|
2055
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
2056
2056
|
Min expectation of ${unit} must be zero or positive
|
|
2057
2057
|
|
|
2058
2058
|
${block(pipelineIdentification)}
|
|
2059
2059
|
`));
|
|
2060
2060
|
}
|
|
2061
2061
|
if (max !== undefined && max <= 0) {
|
|
2062
|
-
throw new PipelineLogicError(
|
|
2062
|
+
throw new PipelineLogicError(_spaceTrim.spaceTrim((block) => `
|
|
2063
2063
|
Max expectation of ${unit} must be positive
|
|
2064
2064
|
|
|
2065
2065
|
${block(pipelineIdentification)}
|
|
@@ -2081,7 +2081,7 @@
|
|
|
2081
2081
|
while (unresovedTasks.length > 0) {
|
|
2082
2082
|
if (loopLimit-- < 0) {
|
|
2083
2083
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
2084
|
-
throw new UnexpectedError(
|
|
2084
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
2085
2085
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
2086
2086
|
|
|
2087
2087
|
${block(pipelineIdentification)}
|
|
@@ -2091,7 +2091,7 @@
|
|
|
2091
2091
|
if (currentlyResovedTasks.length === 0) {
|
|
2092
2092
|
throw new PipelineLogicError(
|
|
2093
2093
|
// TODO: [🐎] DRY
|
|
2094
|
-
|
|
2094
|
+
_spaceTrim.spaceTrim((block) => `
|
|
2095
2095
|
|
|
2096
2096
|
Can not resolve some parameters:
|
|
2097
2097
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -2442,7 +2442,7 @@
|
|
|
2442
2442
|
pipelineString += '\n\n';
|
|
2443
2443
|
pipelineString += '```' + contentLanguage;
|
|
2444
2444
|
pipelineString += '\n';
|
|
2445
|
-
pipelineString +=
|
|
2445
|
+
pipelineString += _spaceTrim.spaceTrim(content);
|
|
2446
2446
|
// <- TODO: [main] !!3 Escape
|
|
2447
2447
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
2448
2448
|
pipelineString += '\n';
|
|
@@ -2573,7 +2573,7 @@
|
|
|
2573
2573
|
for (const pipeline of pipelines) {
|
|
2574
2574
|
// TODO: [👠] DRY
|
|
2575
2575
|
if (pipeline.pipelineUrl === undefined) {
|
|
2576
|
-
throw new PipelineUrlError(
|
|
2576
|
+
throw new PipelineUrlError(_spaceTrim.spaceTrim(`
|
|
2577
2577
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
2578
2578
|
|
|
2579
2579
|
File:
|
|
@@ -2595,7 +2595,7 @@
|
|
|
2595
2595
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
2596
2596
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
2597
2597
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
2598
|
-
throw new PipelineUrlError(
|
|
2598
|
+
throw new PipelineUrlError(_spaceTrim.spaceTrim(`
|
|
2599
2599
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
2600
2600
|
|
|
2601
2601
|
Conflicting files:
|
|
@@ -2627,13 +2627,13 @@
|
|
|
2627
2627
|
const pipeline = this.collection.get(url);
|
|
2628
2628
|
if (!pipeline) {
|
|
2629
2629
|
if (this.listPipelines().length === 0) {
|
|
2630
|
-
throw new NotFoundError(
|
|
2630
|
+
throw new NotFoundError(_spaceTrim.spaceTrim(`
|
|
2631
2631
|
Pipeline with url "${url}" not found
|
|
2632
2632
|
|
|
2633
2633
|
No pipelines available
|
|
2634
2634
|
`));
|
|
2635
2635
|
}
|
|
2636
|
-
throw new NotFoundError(
|
|
2636
|
+
throw new NotFoundError(_spaceTrim.spaceTrim((block) => `
|
|
2637
2637
|
Pipeline with url "${url}" not found
|
|
2638
2638
|
|
|
2639
2639
|
Available pipelines:
|
|
@@ -2674,7 +2674,7 @@
|
|
|
2674
2674
|
*/
|
|
2675
2675
|
class MissingToolsError extends Error {
|
|
2676
2676
|
constructor(message) {
|
|
2677
|
-
super(
|
|
2677
|
+
super(_spaceTrim.spaceTrim((block) => `
|
|
2678
2678
|
${block(message)}
|
|
2679
2679
|
|
|
2680
2680
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -2885,7 +2885,7 @@
|
|
|
2885
2885
|
*/
|
|
2886
2886
|
class NotYetImplementedError extends Error {
|
|
2887
2887
|
constructor(message) {
|
|
2888
|
-
super(
|
|
2888
|
+
super(_spaceTrim.spaceTrim((block) => `
|
|
2889
2889
|
${block(message)}
|
|
2890
2890
|
|
|
2891
2891
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -3024,7 +3024,7 @@
|
|
|
3024
3024
|
const { name, message, stack } = error;
|
|
3025
3025
|
const { id } = error;
|
|
3026
3026
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3027
|
-
console.error(
|
|
3027
|
+
console.error(_spaceTrim.spaceTrim((block) => `
|
|
3028
3028
|
|
|
3029
3029
|
Cannot serialize error with name "${name}"
|
|
3030
3030
|
|
|
@@ -3088,7 +3088,7 @@
|
|
|
3088
3088
|
message = `${name}: ${message}`;
|
|
3089
3089
|
}
|
|
3090
3090
|
if (isStackAddedToMessage && stack !== undefined && stack !== '') {
|
|
3091
|
-
message =
|
|
3091
|
+
message = _spaceTrim.spaceTrim((block) => `
|
|
3092
3092
|
${block(message)}
|
|
3093
3093
|
|
|
3094
3094
|
Original stack trace:
|
|
@@ -3125,11 +3125,11 @@
|
|
|
3125
3125
|
throw deserializeError(errors[0]);
|
|
3126
3126
|
}
|
|
3127
3127
|
else {
|
|
3128
|
-
throw new PipelineExecutionError(
|
|
3128
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
3129
3129
|
Multiple errors occurred during Promptbook execution
|
|
3130
3130
|
|
|
3131
3131
|
${block(errors
|
|
3132
|
-
.map(({ name, stack, message }, index) =>
|
|
3132
|
+
.map(({ name, stack, message }, index) => _spaceTrim.spaceTrim((block) => `
|
|
3133
3133
|
${name} ${index + 1}:
|
|
3134
3134
|
${block(stack || message)}
|
|
3135
3135
|
`))
|
|
@@ -3592,7 +3592,7 @@
|
|
|
3592
3592
|
}
|
|
3593
3593
|
catch (error) {
|
|
3594
3594
|
assertsError(error);
|
|
3595
|
-
throw new ParseError(
|
|
3595
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
3596
3596
|
Can not extract variables from the script
|
|
3597
3597
|
${block(error.stack || error.message)}
|
|
3598
3598
|
|
|
@@ -3775,7 +3775,7 @@
|
|
|
3775
3775
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
3776
3776
|
const csv = csvParse(value, settings);
|
|
3777
3777
|
if (csv.errors.length !== 0) {
|
|
3778
|
-
throw new CsvFormatError(
|
|
3778
|
+
throw new CsvFormatError(_spaceTrim.spaceTrim((block) => `
|
|
3779
3779
|
CSV parsing error
|
|
3780
3780
|
|
|
3781
3781
|
Error(s) from CSV parsing:
|
|
@@ -3820,7 +3820,7 @@
|
|
|
3820
3820
|
const { value, settings, mapCallback, onProgress } = options;
|
|
3821
3821
|
const csv = csvParse(value, settings);
|
|
3822
3822
|
if (csv.errors.length !== 0) {
|
|
3823
|
-
throw new CsvFormatError(
|
|
3823
|
+
throw new CsvFormatError(_spaceTrim.spaceTrim((block) => `
|
|
3824
3824
|
CSV parsing error
|
|
3825
3825
|
|
|
3826
3826
|
Error(s) from CSV parsing:
|
|
@@ -4030,7 +4030,7 @@
|
|
|
4030
4030
|
}
|
|
4031
4031
|
// Phase 2️⃣: Non-matching mapping
|
|
4032
4032
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
4033
|
-
throw new PipelineExecutionError(
|
|
4033
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
4034
4034
|
Can not map available parameters to expected parameters
|
|
4035
4035
|
|
|
4036
4036
|
Mapped parameters:
|
|
@@ -4108,14 +4108,14 @@
|
|
|
4108
4108
|
if (description === undefined) {
|
|
4109
4109
|
return headLine;
|
|
4110
4110
|
}
|
|
4111
|
-
return
|
|
4111
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
4112
4112
|
${headLine}
|
|
4113
4113
|
|
|
4114
4114
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
4115
4115
|
`);
|
|
4116
4116
|
})
|
|
4117
4117
|
.join('\n\n');
|
|
4118
|
-
return
|
|
4118
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
4119
4119
|
Multiple LLM Providers:
|
|
4120
4120
|
|
|
4121
4121
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -4217,7 +4217,7 @@
|
|
|
4217
4217
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4218
4218
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4219
4219
|
// 3) ...
|
|
4220
|
-
|
|
4220
|
+
_spaceTrim.spaceTrim((block) => `
|
|
4221
4221
|
All execution tools of ${this.title} failed:
|
|
4222
4222
|
|
|
4223
4223
|
${block(errors
|
|
@@ -4230,7 +4230,7 @@
|
|
|
4230
4230
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
4231
4231
|
}
|
|
4232
4232
|
else {
|
|
4233
|
-
throw new PipelineExecutionError(
|
|
4233
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
4234
4234
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
4235
4235
|
|
|
4236
4236
|
Available \`LlmExecutionTools\`:
|
|
@@ -4267,7 +4267,7 @@
|
|
|
4267
4267
|
*/
|
|
4268
4268
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
4269
4269
|
if (llmExecutionTools.length === 0) {
|
|
4270
|
-
const warningMessage =
|
|
4270
|
+
const warningMessage = _spaceTrim.spaceTrim(`
|
|
4271
4271
|
You have not provided any \`LlmExecutionTools\`
|
|
4272
4272
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
4273
4273
|
|
|
@@ -4970,7 +4970,7 @@
|
|
|
4970
4970
|
}
|
|
4971
4971
|
catch (error) {
|
|
4972
4972
|
keepUnused(error);
|
|
4973
|
-
throw new ExpectError(
|
|
4973
|
+
throw new ExpectError(_spaceTrim.spaceTrim((block) => `
|
|
4974
4974
|
Expected valid JSON string
|
|
4975
4975
|
|
|
4976
4976
|
The expected JSON text:
|
|
@@ -5033,7 +5033,7 @@
|
|
|
5033
5033
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
5034
5034
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
5035
5035
|
if (isJokerAttempt && !jokerParameterName) {
|
|
5036
|
-
throw new UnexpectedError(
|
|
5036
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
5037
5037
|
Joker not found in attempt ${attemptIndex}
|
|
5038
5038
|
|
|
5039
5039
|
${block(pipelineIdentification)}
|
|
@@ -5044,7 +5044,7 @@
|
|
|
5044
5044
|
$ongoingTaskResult.$expectError = null;
|
|
5045
5045
|
if (isJokerAttempt) {
|
|
5046
5046
|
if (parameters[jokerParameterName] === undefined) {
|
|
5047
|
-
throw new PipelineExecutionError(
|
|
5047
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5048
5048
|
Joker parameter {${jokerParameterName}} not defined
|
|
5049
5049
|
|
|
5050
5050
|
${block(pipelineIdentification)}
|
|
@@ -5103,7 +5103,7 @@
|
|
|
5103
5103
|
break variant;
|
|
5104
5104
|
case 'EMBEDDING':
|
|
5105
5105
|
case 'IMAGE_GENERATION':
|
|
5106
|
-
throw new PipelineExecutionError(
|
|
5106
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5107
5107
|
${modelRequirements.modelVariant} model can not be used in pipeline
|
|
5108
5108
|
|
|
5109
5109
|
This should be catched during parsing
|
|
@@ -5114,7 +5114,7 @@
|
|
|
5114
5114
|
break variant;
|
|
5115
5115
|
// <- case [🤖]:
|
|
5116
5116
|
default:
|
|
5117
|
-
throw new PipelineExecutionError(
|
|
5117
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5118
5118
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
5119
5119
|
|
|
5120
5120
|
${block(pipelineIdentification)}
|
|
@@ -5125,14 +5125,14 @@
|
|
|
5125
5125
|
break;
|
|
5126
5126
|
case 'SCRIPT_TASK':
|
|
5127
5127
|
if (arrayableToArray(tools.script).length === 0) {
|
|
5128
|
-
throw new PipelineExecutionError(
|
|
5128
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5129
5129
|
No script execution tools are available
|
|
5130
5130
|
|
|
5131
5131
|
${block(pipelineIdentification)}
|
|
5132
5132
|
`));
|
|
5133
5133
|
}
|
|
5134
5134
|
if (!task.contentLanguage) {
|
|
5135
|
-
throw new PipelineExecutionError(
|
|
5135
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5136
5136
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
5137
5137
|
|
|
5138
5138
|
${block(pipelineIdentification)}
|
|
@@ -5163,7 +5163,7 @@
|
|
|
5163
5163
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
5164
5164
|
}
|
|
5165
5165
|
else {
|
|
5166
|
-
throw new PipelineExecutionError(
|
|
5166
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5167
5167
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
5168
5168
|
|
|
5169
5169
|
${block(pipelineIdentification)}
|
|
@@ -5177,7 +5177,7 @@
|
|
|
5177
5177
|
break taskType;
|
|
5178
5178
|
case 'DIALOG_TASK':
|
|
5179
5179
|
if (tools.userInterface === undefined) {
|
|
5180
|
-
throw new PipelineExecutionError(
|
|
5180
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5181
5181
|
User interface tools are not available
|
|
5182
5182
|
|
|
5183
5183
|
${block(pipelineIdentification)}
|
|
@@ -5195,7 +5195,7 @@
|
|
|
5195
5195
|
break taskType;
|
|
5196
5196
|
// <- case: [🅱]
|
|
5197
5197
|
default:
|
|
5198
|
-
throw new PipelineExecutionError(
|
|
5198
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5199
5199
|
Unknown execution type "${task.taskType}"
|
|
5200
5200
|
|
|
5201
5201
|
${block(pipelineIdentification)}
|
|
@@ -5293,7 +5293,7 @@
|
|
|
5293
5293
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
5294
5294
|
// Note: Create a summary of all failures
|
|
5295
5295
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
5296
|
-
.map((failure) =>
|
|
5296
|
+
.map((failure) => _spaceTrim.spaceTrim((block) => {
|
|
5297
5297
|
var _a, _b;
|
|
5298
5298
|
return `
|
|
5299
5299
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -5303,14 +5303,14 @@
|
|
|
5303
5303
|
Result:
|
|
5304
5304
|
${block(failure.result === null
|
|
5305
5305
|
? 'null'
|
|
5306
|
-
:
|
|
5306
|
+
: _spaceTrim.spaceTrim(failure.result)
|
|
5307
5307
|
.split(/\r?\n/)
|
|
5308
5308
|
.map((line) => `> ${line}`)
|
|
5309
5309
|
.join('\n'))}
|
|
5310
5310
|
`;
|
|
5311
5311
|
}))
|
|
5312
5312
|
.join('\n\n---\n\n');
|
|
5313
|
-
throw new PipelineExecutionError(
|
|
5313
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => {
|
|
5314
5314
|
var _a;
|
|
5315
5315
|
return `
|
|
5316
5316
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -5330,7 +5330,7 @@
|
|
|
5330
5330
|
}
|
|
5331
5331
|
}
|
|
5332
5332
|
if ($ongoingTaskResult.$resultString === null) {
|
|
5333
|
-
throw new UnexpectedError(
|
|
5333
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
5334
5334
|
Something went wrong and prompt result is null
|
|
5335
5335
|
|
|
5336
5336
|
${block(pipelineIdentification)}
|
|
@@ -5357,7 +5357,7 @@
|
|
|
5357
5357
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
5358
5358
|
}
|
|
5359
5359
|
if (jokerParameterNames.length !== 0) {
|
|
5360
|
-
throw new UnexpectedError(
|
|
5360
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
5361
5361
|
JOKER parameters are not supported together with FOREACH command
|
|
5362
5362
|
|
|
5363
5363
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -5370,7 +5370,7 @@
|
|
|
5370
5370
|
if (formatDefinition === undefined) {
|
|
5371
5371
|
throw new UnexpectedError(
|
|
5372
5372
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
5373
|
-
|
|
5373
|
+
_spaceTrim.spaceTrim((block) => `
|
|
5374
5374
|
Unsupported format "${task.foreach.formatName}"
|
|
5375
5375
|
|
|
5376
5376
|
Available formats:
|
|
@@ -5387,7 +5387,7 @@
|
|
|
5387
5387
|
if (subvalueParser === undefined) {
|
|
5388
5388
|
throw new UnexpectedError(
|
|
5389
5389
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
5390
|
-
|
|
5390
|
+
_spaceTrim.spaceTrim((block) => `
|
|
5391
5391
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
5392
5392
|
|
|
5393
5393
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -5427,7 +5427,7 @@
|
|
|
5427
5427
|
if (!(error instanceof PipelineExecutionError)) {
|
|
5428
5428
|
throw error;
|
|
5429
5429
|
}
|
|
5430
|
-
const highLevelError = new PipelineExecutionError(
|
|
5430
|
+
const highLevelError = new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5431
5431
|
${error.message}
|
|
5432
5432
|
|
|
5433
5433
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -5451,7 +5451,7 @@
|
|
|
5451
5451
|
...options,
|
|
5452
5452
|
priority: priority + index,
|
|
5453
5453
|
parameters: allSubparameters,
|
|
5454
|
-
pipelineIdentification:
|
|
5454
|
+
pipelineIdentification: _spaceTrim.spaceTrim((block) => `
|
|
5455
5455
|
${block(pipelineIdentification)}
|
|
5456
5456
|
Subparameter index: ${index}
|
|
5457
5457
|
`),
|
|
@@ -5460,7 +5460,7 @@
|
|
|
5460
5460
|
}
|
|
5461
5461
|
catch (error) {
|
|
5462
5462
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
5463
|
-
console.error(
|
|
5463
|
+
console.error(_spaceTrim.spaceTrim((block) => `
|
|
5464
5464
|
${error.message}
|
|
5465
5465
|
|
|
5466
5466
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -5636,7 +5636,7 @@
|
|
|
5636
5636
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
5637
5637
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
5638
5638
|
if (reservedParameters[parameterName] === undefined) {
|
|
5639
|
-
throw new UnexpectedError(
|
|
5639
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
5640
5640
|
Reserved parameter {${parameterName}} is not defined
|
|
5641
5641
|
|
|
5642
5642
|
${block(pipelineIdentification)}
|
|
@@ -5662,7 +5662,7 @@
|
|
|
5662
5662
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
5663
5663
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
5664
5664
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
5665
|
-
throw new UnexpectedError(
|
|
5665
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
5666
5666
|
Dependent parameters are not consistent with used parameters:
|
|
5667
5667
|
|
|
5668
5668
|
Dependent parameters:
|
|
@@ -5706,7 +5706,7 @@
|
|
|
5706
5706
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
5707
5707
|
// Houston, we have a problem
|
|
5708
5708
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
5709
|
-
throw new UnexpectedError(
|
|
5709
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
5710
5710
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
5711
5711
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
5712
5712
|
|
|
@@ -5775,7 +5775,7 @@
|
|
|
5775
5775
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
5776
5776
|
if (parametersToPass[parameter.name] === undefined) {
|
|
5777
5777
|
// [4]
|
|
5778
|
-
$warnings.push(new PipelineExecutionError(
|
|
5778
|
+
$warnings.push(new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5779
5779
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
5780
5780
|
|
|
5781
5781
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -5883,7 +5883,7 @@
|
|
|
5883
5883
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
5884
5884
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
5885
5885
|
if (parameter === undefined) {
|
|
5886
|
-
warnings.push(new PipelineExecutionError(
|
|
5886
|
+
warnings.push(new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5887
5887
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
5888
5888
|
|
|
5889
5889
|
${block(pipelineIdentification)}
|
|
@@ -5898,7 +5898,7 @@
|
|
|
5898
5898
|
// TODO: [🧠] This should be also non-critical error
|
|
5899
5899
|
return exportJson({
|
|
5900
5900
|
name: 'pipelineExecutorResult',
|
|
5901
|
-
message:
|
|
5901
|
+
message: _spaceTrim.spaceTrim((block) => `
|
|
5902
5902
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
5903
5903
|
|
|
5904
5904
|
${block(pipelineIdentification)}
|
|
@@ -5907,7 +5907,7 @@
|
|
|
5907
5907
|
value: {
|
|
5908
5908
|
isSuccessful: false,
|
|
5909
5909
|
errors: [
|
|
5910
|
-
new PipelineExecutionError(
|
|
5910
|
+
new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
5911
5911
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
5912
5912
|
|
|
5913
5913
|
${block(pipelineIdentification)}
|
|
@@ -5934,7 +5934,7 @@
|
|
|
5934
5934
|
while (unresovedTasks.length > 0) {
|
|
5935
5935
|
if (loopLimit-- < 0) {
|
|
5936
5936
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
5937
|
-
throw new UnexpectedError(
|
|
5937
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
5938
5938
|
Loop limit reached during resolving parameters pipeline execution
|
|
5939
5939
|
|
|
5940
5940
|
${block(pipelineIdentification)}
|
|
@@ -5944,7 +5944,7 @@
|
|
|
5944
5944
|
if (!currentTask && resolving.length === 0) {
|
|
5945
5945
|
throw new UnexpectedError(
|
|
5946
5946
|
// TODO: [🐎] DRY
|
|
5947
|
-
|
|
5947
|
+
_spaceTrim.spaceTrim((block) => `
|
|
5948
5948
|
Can not resolve some parameters:
|
|
5949
5949
|
|
|
5950
5950
|
${block(pipelineIdentification)}
|
|
@@ -5984,7 +5984,7 @@
|
|
|
5984
5984
|
tools,
|
|
5985
5985
|
onProgress(newOngoingResult) {
|
|
5986
5986
|
if (isReturned) {
|
|
5987
|
-
throw new UnexpectedError(
|
|
5987
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
5988
5988
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
5989
5989
|
|
|
5990
5990
|
${block(pipelineIdentification)}
|
|
@@ -6001,7 +6001,7 @@
|
|
|
6001
6001
|
},
|
|
6002
6002
|
logLlmCall,
|
|
6003
6003
|
$executionReport: executionReport,
|
|
6004
|
-
pipelineIdentification:
|
|
6004
|
+
pipelineIdentification: _spaceTrim.spaceTrim((block) => `
|
|
6005
6005
|
${block(pipelineIdentification)}
|
|
6006
6006
|
Task name: ${currentTask.name}
|
|
6007
6007
|
Task title: ${currentTask.title}
|
|
@@ -6110,7 +6110,7 @@
|
|
|
6110
6110
|
preparedPipeline = pipeline;
|
|
6111
6111
|
}
|
|
6112
6112
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
6113
|
-
console.warn(
|
|
6113
|
+
console.warn(_spaceTrim.spaceTrim((block) => `
|
|
6114
6114
|
Pipeline is not prepared
|
|
6115
6115
|
|
|
6116
6116
|
${block(pipelineIdentification)}
|
|
@@ -6135,7 +6135,7 @@
|
|
|
6135
6135
|
tools,
|
|
6136
6136
|
onProgress,
|
|
6137
6137
|
logLlmCall,
|
|
6138
|
-
pipelineIdentification:
|
|
6138
|
+
pipelineIdentification: _spaceTrim.spaceTrim((block) => `
|
|
6139
6139
|
${block(pipelineIdentification)}
|
|
6140
6140
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
6141
6141
|
`),
|
|
@@ -6632,14 +6632,14 @@
|
|
|
6632
6632
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
6633
6633
|
});
|
|
6634
6634
|
if (metadata.length === 0) {
|
|
6635
|
-
return
|
|
6635
|
+
return _spaceTrim.spaceTrim(`
|
|
6636
6636
|
**No scrapers are available**
|
|
6637
6637
|
|
|
6638
6638
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
6639
6639
|
At least there should be available the metadata of the scrapers
|
|
6640
6640
|
`);
|
|
6641
6641
|
}
|
|
6642
|
-
return
|
|
6642
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
6643
6643
|
Available scrapers are:
|
|
6644
6644
|
${block(metadata
|
|
6645
6645
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -6882,7 +6882,7 @@
|
|
|
6882
6882
|
else if (urlOrRequest instanceof Request) {
|
|
6883
6883
|
url = urlOrRequest.url;
|
|
6884
6884
|
}
|
|
6885
|
-
throw new PromptbookFetchError(
|
|
6885
|
+
throw new PromptbookFetchError(_spaceTrim.spaceTrim((block) => `
|
|
6886
6886
|
Can not fetch "${url}"
|
|
6887
6887
|
|
|
6888
6888
|
Fetch error:
|
|
@@ -7042,7 +7042,7 @@
|
|
|
7042
7042
|
const fileExtension = getFileExtension(filename);
|
|
7043
7043
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
7044
7044
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
7045
|
-
throw new NotFoundError(
|
|
7045
|
+
throw new NotFoundError(_spaceTrim.spaceTrim((block) => `
|
|
7046
7046
|
Can not make source handler for file which does not exist:
|
|
7047
7047
|
|
|
7048
7048
|
File:
|
|
@@ -7135,7 +7135,7 @@
|
|
|
7135
7135
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
7136
7136
|
break;
|
|
7137
7137
|
}
|
|
7138
|
-
console.warn(
|
|
7138
|
+
console.warn(_spaceTrim.spaceTrim((block) => `
|
|
7139
7139
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
7140
7140
|
|
|
7141
7141
|
The source:
|
|
@@ -7151,7 +7151,7 @@
|
|
|
7151
7151
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7152
7152
|
}
|
|
7153
7153
|
if (partialPieces === null) {
|
|
7154
|
-
throw new KnowledgeScrapeError(
|
|
7154
|
+
throw new KnowledgeScrapeError(_spaceTrim.spaceTrim((block) => `
|
|
7155
7155
|
Cannot scrape knowledge
|
|
7156
7156
|
|
|
7157
7157
|
The source:
|
|
@@ -7230,7 +7230,7 @@
|
|
|
7230
7230
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
7231
7231
|
knowledgePiecesCount > 0 &&
|
|
7232
7232
|
!dependentParameterNames.includes('knowledge')) {
|
|
7233
|
-
preparedContent =
|
|
7233
|
+
preparedContent = _spaceTrim.spaceTrim(`
|
|
7234
7234
|
{content}
|
|
7235
7235
|
|
|
7236
7236
|
## Knowledge
|
|
@@ -7487,7 +7487,7 @@
|
|
|
7487
7487
|
*/
|
|
7488
7488
|
parse(input) {
|
|
7489
7489
|
const { args } = input;
|
|
7490
|
-
const knowledgeSourceContent =
|
|
7490
|
+
const knowledgeSourceContent = _spaceTrim.spaceTrim(args[0] || '');
|
|
7491
7491
|
if (knowledgeSourceContent === '') {
|
|
7492
7492
|
throw new ParseError(`Source is not defined`);
|
|
7493
7493
|
}
|
|
@@ -7631,7 +7631,7 @@
|
|
|
7631
7631
|
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
7632
7632
|
const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
|
|
7633
7633
|
if (taskTypes.length !== 1) {
|
|
7634
|
-
throw new ParseError(
|
|
7634
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
7635
7635
|
Unknown section type "${normalized}"
|
|
7636
7636
|
|
|
7637
7637
|
Supported section types are:
|
|
@@ -7651,7 +7651,7 @@
|
|
|
7651
7651
|
*/
|
|
7652
7652
|
$applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
7653
7653
|
if ($taskJson.isSectionTypeSet === true) {
|
|
7654
|
-
throw new ParseError(
|
|
7654
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
7655
7655
|
Section type is already defined in the section.
|
|
7656
7656
|
It can be defined only once.
|
|
7657
7657
|
`));
|
|
@@ -8003,7 +8003,7 @@
|
|
|
8003
8003
|
/**
|
|
8004
8004
|
* Description of the FORMAT command
|
|
8005
8005
|
*/
|
|
8006
|
-
description:
|
|
8006
|
+
description: _spaceTrim.spaceTrim(`
|
|
8007
8007
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
8008
8008
|
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.
|
|
8009
8009
|
`),
|
|
@@ -8077,7 +8077,7 @@
|
|
|
8077
8077
|
}
|
|
8078
8078
|
catch (error) {
|
|
8079
8079
|
assertsError(error);
|
|
8080
|
-
throw new ParseError(
|
|
8080
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
8081
8081
|
Invalid FORMAT command
|
|
8082
8082
|
${block(error.message)}:
|
|
8083
8083
|
`));
|
|
@@ -8267,7 +8267,7 @@
|
|
|
8267
8267
|
if (!(error instanceof ParseError)) {
|
|
8268
8268
|
throw error;
|
|
8269
8269
|
}
|
|
8270
|
-
throw new ParseError(
|
|
8270
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
8271
8271
|
${block(error.message)}
|
|
8272
8272
|
|
|
8273
8273
|
Tried to validate parameter name:
|
|
@@ -8326,7 +8326,7 @@
|
|
|
8326
8326
|
const assignSign = args[3];
|
|
8327
8327
|
const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
|
|
8328
8328
|
if (formatDefinition === undefined) {
|
|
8329
|
-
throw new ParseError(
|
|
8329
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
8330
8330
|
Unsupported format "${formatName}"
|
|
8331
8331
|
|
|
8332
8332
|
Available formats:
|
|
@@ -8338,7 +8338,7 @@
|
|
|
8338
8338
|
}
|
|
8339
8339
|
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
8340
8340
|
if (subvalueParser === undefined) {
|
|
8341
|
-
throw new ParseError(
|
|
8341
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
8342
8342
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
8343
8343
|
|
|
8344
8344
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -8386,7 +8386,7 @@
|
|
|
8386
8386
|
outputSubparameterName = 'newLine';
|
|
8387
8387
|
}
|
|
8388
8388
|
else {
|
|
8389
|
-
throw new ParseError(
|
|
8389
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
8390
8390
|
FOREACH ${formatName} ${subformatName} must specify output subparameter
|
|
8391
8391
|
|
|
8392
8392
|
Correct example:
|
|
@@ -8462,7 +8462,7 @@
|
|
|
8462
8462
|
/**
|
|
8463
8463
|
* Description of the FORMAT command
|
|
8464
8464
|
*/
|
|
8465
|
-
description:
|
|
8465
|
+
description: _spaceTrim.spaceTrim(`
|
|
8466
8466
|
Format command describes the desired output of the task (after post-processing)
|
|
8467
8467
|
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.
|
|
8468
8468
|
`),
|
|
@@ -8834,7 +8834,7 @@
|
|
|
8834
8834
|
const formfactorNameCandidate = args[0].toUpperCase();
|
|
8835
8835
|
const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
|
|
8836
8836
|
if (formfactor === undefined) {
|
|
8837
|
-
throw new ParseError(
|
|
8837
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
8838
8838
|
Unknown formfactor name "${formfactorNameCandidate}"
|
|
8839
8839
|
|
|
8840
8840
|
Available formfactors:
|
|
@@ -8853,7 +8853,7 @@
|
|
|
8853
8853
|
*/
|
|
8854
8854
|
$applyToPipelineJson(command, $pipelineJson) {
|
|
8855
8855
|
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
8856
|
-
throw new ParseError(
|
|
8856
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
8857
8857
|
Redefinition of \`FORMFACTOR\` in the pipeline head
|
|
8858
8858
|
|
|
8859
8859
|
You have used:
|
|
@@ -9001,7 +9001,7 @@
|
|
|
9001
9001
|
*/
|
|
9002
9002
|
parse(input) {
|
|
9003
9003
|
const { args, normalized } = input;
|
|
9004
|
-
const availableVariantsMessage =
|
|
9004
|
+
const availableVariantsMessage = _spaceTrim.spaceTrim((block) => `
|
|
9005
9005
|
Available variants are:
|
|
9006
9006
|
${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
|
|
9007
9007
|
`);
|
|
@@ -9023,14 +9023,14 @@
|
|
|
9023
9023
|
// <- Note: [🤖]
|
|
9024
9024
|
}
|
|
9025
9025
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
9026
|
-
|
|
9026
|
+
_spaceTrim.spaceTrim((block) => `
|
|
9027
9027
|
Embedding model can not be used in pipeline
|
|
9028
9028
|
|
|
9029
9029
|
${block(availableVariantsMessage)}
|
|
9030
9030
|
`);
|
|
9031
9031
|
}
|
|
9032
9032
|
else {
|
|
9033
|
-
throw new ParseError(
|
|
9033
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
9034
9034
|
Unknown model variant in command:
|
|
9035
9035
|
|
|
9036
9036
|
${block(availableVariantsMessage)}
|
|
@@ -9045,7 +9045,7 @@
|
|
|
9045
9045
|
};
|
|
9046
9046
|
}
|
|
9047
9047
|
else {
|
|
9048
|
-
throw new ParseError(
|
|
9048
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
9049
9049
|
Unknown model key in command.
|
|
9050
9050
|
|
|
9051
9051
|
Supported model keys are:
|
|
@@ -9072,7 +9072,7 @@
|
|
|
9072
9072
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9073
9073
|
}
|
|
9074
9074
|
else {
|
|
9075
|
-
throw new ParseError(
|
|
9075
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
9076
9076
|
Redefinition of \`MODEL ${command.key}\` in the pipeline head
|
|
9077
9077
|
|
|
9078
9078
|
You have used:
|
|
@@ -9100,7 +9100,7 @@
|
|
|
9100
9100
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
9101
9101
|
}
|
|
9102
9102
|
else {
|
|
9103
|
-
throw new ParseError(
|
|
9103
|
+
throw new ParseError(_spaceTrim.spaceTrim(`
|
|
9104
9104
|
Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
|
|
9105
9105
|
|
|
9106
9106
|
You have used:
|
|
@@ -9110,7 +9110,7 @@
|
|
|
9110
9110
|
}
|
|
9111
9111
|
}
|
|
9112
9112
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
9113
|
-
console.log(
|
|
9113
|
+
console.log(_spaceTrim.spaceTrim(`
|
|
9114
9114
|
Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
|
|
9115
9115
|
|
|
9116
9116
|
In pipeline head:
|
|
@@ -9193,7 +9193,7 @@
|
|
|
9193
9193
|
// <- TODO: When [🥶] fixed, change to:
|
|
9194
9194
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
9195
9195
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
9196
|
-
throw new ParseError(
|
|
9196
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
9197
9197
|
Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
|
|
9198
9198
|
|
|
9199
9199
|
The description:
|
|
@@ -9375,7 +9375,7 @@
|
|
|
9375
9375
|
persona.description = personaDescription;
|
|
9376
9376
|
return;
|
|
9377
9377
|
}
|
|
9378
|
-
console.warn(
|
|
9378
|
+
console.warn(_spaceTrim.spaceTrim(`
|
|
9379
9379
|
|
|
9380
9380
|
Persona "${personaName}" is defined multiple times with different description:
|
|
9381
9381
|
|
|
@@ -9386,7 +9386,7 @@
|
|
|
9386
9386
|
${personaDescription}
|
|
9387
9387
|
|
|
9388
9388
|
`));
|
|
9389
|
-
persona.description +=
|
|
9389
|
+
persona.description += _spaceTrim.spaceTrim('\n\n' + personaDescription);
|
|
9390
9390
|
}
|
|
9391
9391
|
|
|
9392
9392
|
/**
|
|
@@ -9751,7 +9751,7 @@
|
|
|
9751
9751
|
function getParserForCommand(command) {
|
|
9752
9752
|
const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
|
|
9753
9753
|
if (commandParser === undefined) {
|
|
9754
|
-
throw new UnexpectedError(
|
|
9754
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
9755
9755
|
Command ${command.type} parser is not found
|
|
9756
9756
|
|
|
9757
9757
|
${block(JSON.stringify(command, null, 4)
|
|
@@ -9827,7 +9827,7 @@
|
|
|
9827
9827
|
.map(removeMarkdownFormatting)
|
|
9828
9828
|
.map((item) => item.trim());
|
|
9829
9829
|
if (items.length === 0 || items[0] === '') {
|
|
9830
|
-
throw new ParseError(
|
|
9830
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
9831
9831
|
Malformed command:
|
|
9832
9832
|
- ${raw}
|
|
9833
9833
|
|
|
@@ -9863,7 +9863,7 @@
|
|
|
9863
9863
|
return command;
|
|
9864
9864
|
}
|
|
9865
9865
|
}
|
|
9866
|
-
throw new ParseError(
|
|
9866
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
9867
9867
|
Malformed or unknown command:
|
|
9868
9868
|
- ${raw}
|
|
9869
9869
|
|
|
@@ -9914,7 +9914,7 @@
|
|
|
9914
9914
|
if (!(error instanceof ParseError)) {
|
|
9915
9915
|
throw error;
|
|
9916
9916
|
}
|
|
9917
|
-
throw new ParseError(
|
|
9917
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
9918
9918
|
Invalid ${commandName} command:
|
|
9919
9919
|
|
|
9920
9920
|
Your command:
|
|
@@ -10230,7 +10230,7 @@
|
|
|
10230
10230
|
* @public exported from `@promptbook/markdown-utils`
|
|
10231
10231
|
*/
|
|
10232
10232
|
function removeMarkdownComments(content) {
|
|
10233
|
-
return
|
|
10233
|
+
return _spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
10234
10234
|
}
|
|
10235
10235
|
|
|
10236
10236
|
/**
|
|
@@ -10241,7 +10241,7 @@
|
|
|
10241
10241
|
*/
|
|
10242
10242
|
function isFlatPipeline(pipelineString) {
|
|
10243
10243
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
10244
|
-
pipelineString =
|
|
10244
|
+
pipelineString = _spaceTrim.spaceTrim(pipelineString);
|
|
10245
10245
|
const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
10246
10246
|
//const isLastLineReturnStatement = pipelineString.split(/\r?\n/).pop()!.split('`').join('').startsWith('->');
|
|
10247
10247
|
const isBacktickBlockUsed = pipelineString.includes('```');
|
|
@@ -10267,7 +10267,7 @@
|
|
|
10267
10267
|
if (!isFlatPipeline(pipelineString)) {
|
|
10268
10268
|
return pipelineString;
|
|
10269
10269
|
}
|
|
10270
|
-
pipelineString =
|
|
10270
|
+
pipelineString = _spaceTrim.spaceTrim(pipelineString);
|
|
10271
10271
|
const pipelineStringLines = pipelineString.split(/\r?\n/);
|
|
10272
10272
|
const potentialReturnStatement = pipelineStringLines.pop();
|
|
10273
10273
|
let returnStatement;
|
|
@@ -10280,19 +10280,19 @@
|
|
|
10280
10280
|
returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
|
|
10281
10281
|
pipelineStringLines.push(potentialReturnStatement);
|
|
10282
10282
|
}
|
|
10283
|
-
const prompt =
|
|
10283
|
+
const prompt = _spaceTrim.spaceTrim(pipelineStringLines.join('\n'));
|
|
10284
10284
|
let quotedPrompt;
|
|
10285
10285
|
if (prompt.split(/\r?\n/).length <= 1) {
|
|
10286
10286
|
quotedPrompt = `> ${prompt}`;
|
|
10287
10287
|
}
|
|
10288
10288
|
else {
|
|
10289
|
-
quotedPrompt =
|
|
10289
|
+
quotedPrompt = _spaceTrim.spaceTrim((block) => `
|
|
10290
10290
|
\`\`\`
|
|
10291
10291
|
${block(prompt.split('`').join('\\`'))}
|
|
10292
10292
|
\`\`\`
|
|
10293
10293
|
`);
|
|
10294
10294
|
}
|
|
10295
|
-
pipelineString = validatePipelineString(
|
|
10295
|
+
pipelineString = validatePipelineString(_spaceTrim.spaceTrim((block) => `
|
|
10296
10296
|
# ${DEFAULT_BOOK_TITLE}
|
|
10297
10297
|
|
|
10298
10298
|
## Prompt
|
|
@@ -10356,7 +10356,7 @@
|
|
|
10356
10356
|
function extractOneBlockFromMarkdown(markdown) {
|
|
10357
10357
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
10358
10358
|
if (codeBlocks.length !== 1) {
|
|
10359
|
-
throw new ParseError(
|
|
10359
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10360
10360
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
10361
10361
|
|
|
10362
10362
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -10381,7 +10381,7 @@
|
|
|
10381
10381
|
}
|
|
10382
10382
|
const title = lines[0].replace(/^#+\s*/, '');
|
|
10383
10383
|
const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
10384
|
-
const content =
|
|
10384
|
+
const content = _spaceTrim.spaceTrim(lines.slice(1).join('\n'));
|
|
10385
10385
|
if (level < 1 || level > 6) {
|
|
10386
10386
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
10387
10387
|
}
|
|
@@ -10409,7 +10409,7 @@
|
|
|
10409
10409
|
if (buffer.length === 0) {
|
|
10410
10410
|
return;
|
|
10411
10411
|
}
|
|
10412
|
-
let section =
|
|
10412
|
+
let section = _spaceTrim.spaceTrim(buffer.join('\n'));
|
|
10413
10413
|
if (section === '') {
|
|
10414
10414
|
return;
|
|
10415
10415
|
}
|
|
@@ -10484,7 +10484,7 @@
|
|
|
10484
10484
|
flattenedMarkdown += `## ${title}` + `\n\n`;
|
|
10485
10485
|
flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
|
|
10486
10486
|
}
|
|
10487
|
-
return
|
|
10487
|
+
return _spaceTrim.spaceTrim(flattenedMarkdown);
|
|
10488
10488
|
}
|
|
10489
10489
|
/**
|
|
10490
10490
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -10546,7 +10546,7 @@
|
|
|
10546
10546
|
if (pipelineString.startsWith('#!')) {
|
|
10547
10547
|
const [shebangLine, ...restLines] = pipelineString.split(/\r?\n/);
|
|
10548
10548
|
if (!(shebangLine || '').includes('ptbk')) {
|
|
10549
|
-
throw new ParseError(
|
|
10549
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10550
10550
|
It seems that you try to parse a book file which has non-standard shebang line for book files:
|
|
10551
10551
|
Shebang line must contain 'ptbk'
|
|
10552
10552
|
|
|
@@ -10562,7 +10562,7 @@
|
|
|
10562
10562
|
pipelineString = validatePipelineString(restLines.join('\n'));
|
|
10563
10563
|
}
|
|
10564
10564
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
10565
|
-
pipelineString =
|
|
10565
|
+
pipelineString = _spaceTrim.spaceTrim(pipelineString);
|
|
10566
10566
|
// <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
|
|
10567
10567
|
pipelineString = deflatePipeline(pipelineString);
|
|
10568
10568
|
// ==============
|
|
@@ -10574,7 +10574,7 @@
|
|
|
10574
10574
|
// ==============
|
|
10575
10575
|
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
10576
10576
|
if (pipelineHead === undefined) {
|
|
10577
|
-
throw new UnexpectedError(
|
|
10577
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
10578
10578
|
Pipeline head is not defined
|
|
10579
10579
|
|
|
10580
10580
|
${block(getPipelineIdentification())}
|
|
@@ -10583,7 +10583,7 @@
|
|
|
10583
10583
|
`));
|
|
10584
10584
|
}
|
|
10585
10585
|
if (pipelineHead.level !== 1) {
|
|
10586
|
-
throw new UnexpectedError(
|
|
10586
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
10587
10587
|
Pipeline head is not h1
|
|
10588
10588
|
|
|
10589
10589
|
${block(getPipelineIdentification())}
|
|
@@ -10592,7 +10592,7 @@
|
|
|
10592
10592
|
`));
|
|
10593
10593
|
}
|
|
10594
10594
|
if (!pipelineSections.every((section) => section.level === 2)) {
|
|
10595
|
-
throw new UnexpectedError(
|
|
10595
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
10596
10596
|
Not every pipeline section is h2
|
|
10597
10597
|
|
|
10598
10598
|
${block(getPipelineIdentification())}
|
|
@@ -10605,7 +10605,7 @@
|
|
|
10605
10605
|
const defineParam = (parameterCommand) => {
|
|
10606
10606
|
const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
|
|
10607
10607
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
10608
|
-
throw new ParseError(
|
|
10608
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10609
10609
|
Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
|
|
10610
10610
|
|
|
10611
10611
|
${block(getPipelineIdentification())}
|
|
@@ -10616,7 +10616,7 @@
|
|
|
10616
10616
|
existingParameter.description &&
|
|
10617
10617
|
existingParameter.description !== parameterDescription &&
|
|
10618
10618
|
parameterDescription) {
|
|
10619
|
-
throw new ParseError(
|
|
10619
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10620
10620
|
Parameter \`{${parameterName}}\` is defined multiple times with different description:
|
|
10621
10621
|
|
|
10622
10622
|
${block(getPipelineIdentification())}
|
|
@@ -10654,7 +10654,7 @@
|
|
|
10654
10654
|
description = description.split(/^>.*$/gm).join('');
|
|
10655
10655
|
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
10656
10656
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
10657
|
-
description =
|
|
10657
|
+
description = _spaceTrim.spaceTrim(description);
|
|
10658
10658
|
if (description === '') {
|
|
10659
10659
|
description = undefined;
|
|
10660
10660
|
}
|
|
@@ -10665,7 +10665,7 @@
|
|
|
10665
10665
|
const command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
10666
10666
|
const commandParser = getParserForCommand(command);
|
|
10667
10667
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
10668
|
-
throw new ParseError(
|
|
10668
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10669
10669
|
Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
|
|
10670
10670
|
|
|
10671
10671
|
${block(getPipelineIdentification())}
|
|
@@ -10679,7 +10679,7 @@
|
|
|
10679
10679
|
if (!(error instanceof ParseError)) {
|
|
10680
10680
|
throw error;
|
|
10681
10681
|
}
|
|
10682
|
-
throw new ParseError(
|
|
10682
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10683
10683
|
Command ${command.type} failed to apply to the pipeline
|
|
10684
10684
|
|
|
10685
10685
|
The error:
|
|
@@ -10732,7 +10732,7 @@
|
|
|
10732
10732
|
description = description.split(/^>.*$/gm).join('');
|
|
10733
10733
|
//Note: Remove lists and return statement - TODO: [🎾]
|
|
10734
10734
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
10735
|
-
description =
|
|
10735
|
+
description = _spaceTrim.spaceTrim(description);
|
|
10736
10736
|
if (description === '') {
|
|
10737
10737
|
description = undefined;
|
|
10738
10738
|
}
|
|
@@ -10766,7 +10766,7 @@
|
|
|
10766
10766
|
for (const { listItem, command } of commands) {
|
|
10767
10767
|
const commandParser = getParserForCommand(command);
|
|
10768
10768
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
10769
|
-
throw new ParseError(
|
|
10769
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10770
10770
|
Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
|
|
10771
10771
|
|
|
10772
10772
|
${block(getPipelineIdentification())}
|
|
@@ -10781,7 +10781,7 @@
|
|
|
10781
10781
|
if (!(error instanceof ParseError)) {
|
|
10782
10782
|
throw error;
|
|
10783
10783
|
}
|
|
10784
|
-
throw new ParseError(
|
|
10784
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10785
10785
|
Command \`${command.type}\` failed to apply to the task
|
|
10786
10786
|
|
|
10787
10787
|
The error:
|
|
@@ -10812,14 +10812,14 @@
|
|
|
10812
10812
|
// TODO: [🍧] Should be done in SECTION command
|
|
10813
10813
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
10814
10814
|
if (!language) {
|
|
10815
|
-
throw new ParseError(
|
|
10815
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10816
10816
|
You must specify the language of the script in the \`SCRIPT\` task
|
|
10817
10817
|
|
|
10818
10818
|
${block(getPipelineIdentification())}
|
|
10819
10819
|
`));
|
|
10820
10820
|
}
|
|
10821
10821
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
10822
|
-
throw new ParseError(
|
|
10822
|
+
throw new ParseError(_spaceTrim.spaceTrim((block) => `
|
|
10823
10823
|
Script language ${language} is not supported.
|
|
10824
10824
|
|
|
10825
10825
|
Supported languages are:
|
|
@@ -11227,7 +11227,7 @@
|
|
|
11227
11227
|
const entries = items
|
|
11228
11228
|
.flatMap((item) => formatParameterListItem(item).split(/\r?\n/))
|
|
11229
11229
|
.filter((line) => line !== '');
|
|
11230
|
-
return
|
|
11230
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
11231
11231
|
**Parameters:**
|
|
11232
11232
|
${block(entries.join('\n'))}
|
|
11233
11233
|
|
|
@@ -11300,7 +11300,7 @@
|
|
|
11300
11300
|
*/
|
|
11301
11301
|
function prompt(strings, ...values) {
|
|
11302
11302
|
if (values.length === 0) {
|
|
11303
|
-
return new PromptString(
|
|
11303
|
+
return new PromptString(_spaceTrim.spaceTrim(strings.join('')));
|
|
11304
11304
|
}
|
|
11305
11305
|
const stringsWithHiddenParameters = strings.map((stringsItem) => ParameterEscaping.hideBrackets(stringsItem));
|
|
11306
11306
|
const parameterMetadata = values.map((value) => {
|
|
@@ -11341,7 +11341,7 @@
|
|
|
11341
11341
|
? `${result}${stringsItem}`
|
|
11342
11342
|
: `${result}${stringsItem}${ParameterSection.formatParameterPlaceholder(parameterName)}`;
|
|
11343
11343
|
}, '');
|
|
11344
|
-
pipelineString =
|
|
11344
|
+
pipelineString = _spaceTrim.spaceTrim(pipelineString);
|
|
11345
11345
|
try {
|
|
11346
11346
|
pipelineString = templateParameters(pipelineString, parameters);
|
|
11347
11347
|
}
|
|
@@ -11350,7 +11350,7 @@
|
|
|
11350
11350
|
throw error;
|
|
11351
11351
|
}
|
|
11352
11352
|
console.error({ pipelineString, parameters, parameterNames: parameterNamesOrdered, error });
|
|
11353
|
-
throw new UnexpectedError(
|
|
11353
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
11354
11354
|
Internal error in prompt template literal
|
|
11355
11355
|
|
|
11356
11356
|
${block(JSON.stringify({ strings, values }, null, 4))}}
|
|
@@ -11491,7 +11491,7 @@
|
|
|
11491
11491
|
* @public exported from `@promptbook/utils`
|
|
11492
11492
|
*/
|
|
11493
11493
|
function computeHash(value) {
|
|
11494
|
-
return cryptoJs.SHA256(hexEncoder__default["default"].parse(
|
|
11494
|
+
return cryptoJs.SHA256(hexEncoder__default["default"].parse(_spaceTrim.spaceTrim(valueToString(value)))).toString( /* hex */);
|
|
11495
11495
|
}
|
|
11496
11496
|
/**
|
|
11497
11497
|
* TODO: [🥬][🥬] Use this ACRY
|
|
@@ -13008,7 +13008,7 @@
|
|
|
13008
13008
|
* @public exported from `@promptbook/utils`
|
|
13009
13009
|
*/
|
|
13010
13010
|
function normalizeMessageText(text) {
|
|
13011
|
-
return
|
|
13011
|
+
return _spaceTrim.spaceTrim(text);
|
|
13012
13012
|
}
|
|
13013
13013
|
|
|
13014
13014
|
/**
|
|
@@ -13055,7 +13055,7 @@
|
|
|
13055
13055
|
let trimmedText = text;
|
|
13056
13056
|
// Remove leading and trailing spaces and newlines
|
|
13057
13057
|
if (isTrimmed) {
|
|
13058
|
-
trimmedText =
|
|
13058
|
+
trimmedText = _spaceTrim.spaceTrim(trimmedText);
|
|
13059
13059
|
}
|
|
13060
13060
|
let processedText = trimmedText;
|
|
13061
13061
|
// Check for markdown code block
|
|
@@ -13074,7 +13074,7 @@
|
|
|
13074
13074
|
// Remove the introduce sentence and quotes by replacing it with an empty string
|
|
13075
13075
|
processedText = processedText.replace(introduceSentenceRegex, '');
|
|
13076
13076
|
}
|
|
13077
|
-
processedText =
|
|
13077
|
+
processedText = _spaceTrim.spaceTrim(processedText);
|
|
13078
13078
|
// Check again for code block after removing introduce sentence
|
|
13079
13079
|
const codeBlockMatch2 = processedText.match(codeBlockRegex);
|
|
13080
13080
|
if (codeBlockMatch2 && codeBlockMatch2[1] !== undefined) {
|
|
@@ -13455,8 +13455,8 @@
|
|
|
13455
13455
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
13456
13456
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
13457
13457
|
let name = `piece-${i}`;
|
|
13458
|
-
let title =
|
|
13459
|
-
const knowledgePieceContent =
|
|
13458
|
+
let title = _spaceTrim.spaceTrim(knowledgeTextPiece.substring(0, 100));
|
|
13459
|
+
const knowledgePieceContent = _spaceTrim.spaceTrim(knowledgeTextPiece);
|
|
13460
13460
|
let keywords = [];
|
|
13461
13461
|
const index = [];
|
|
13462
13462
|
/*
|
|
@@ -13469,7 +13469,7 @@
|
|
|
13469
13469
|
isCrashedOnError: true,
|
|
13470
13470
|
});
|
|
13471
13471
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
13472
|
-
title =
|
|
13472
|
+
title = _spaceTrim.spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
13473
13473
|
name = titleToName(title);
|
|
13474
13474
|
// --- Keywords
|
|
13475
13475
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
@@ -13739,7 +13739,7 @@
|
|
|
13739
13739
|
if (mimeType === 'application/pdf' || url.toLowerCase().endsWith('.pdf')) {
|
|
13740
13740
|
// TODO: [🔰] Implement PDF scraping using PdfScraper
|
|
13741
13741
|
// For now, return a message indicating PDF support is coming
|
|
13742
|
-
return
|
|
13742
|
+
return _spaceTrim.spaceTrim(`
|
|
13743
13743
|
# PDF Document: ${parsedUrl.pathname.split('/').pop()}
|
|
13744
13744
|
|
|
13745
13745
|
**Note:** PDF scraping is not yet fully implemented.
|
|
@@ -13779,7 +13779,7 @@
|
|
|
13779
13779
|
// Clean up intermediate files
|
|
13780
13780
|
await intermediateSource.destroy();
|
|
13781
13781
|
// Add URL header to the content
|
|
13782
|
-
return
|
|
13782
|
+
return _spaceTrim.spaceTrim(`
|
|
13783
13783
|
# Content from: ${url}
|
|
13784
13784
|
|
|
13785
13785
|
${markdown}
|
|
@@ -13790,7 +13790,7 @@
|
|
|
13790
13790
|
`);
|
|
13791
13791
|
}
|
|
13792
13792
|
// For other content types, return the raw content with a note
|
|
13793
|
-
return
|
|
13793
|
+
return _spaceTrim.spaceTrim(`
|
|
13794
13794
|
# Content from: ${url}
|
|
13795
13795
|
|
|
13796
13796
|
**Content Type:** ${contentType}
|
|
@@ -13805,7 +13805,7 @@
|
|
|
13805
13805
|
catch (error) {
|
|
13806
13806
|
// Handle errors gracefully
|
|
13807
13807
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
13808
|
-
return
|
|
13808
|
+
return _spaceTrim.spaceTrim(`
|
|
13809
13809
|
# Error fetching content from URL
|
|
13810
13810
|
|
|
13811
13811
|
**URL:** ${url}
|
|
@@ -13877,7 +13877,7 @@
|
|
|
13877
13877
|
}
|
|
13878
13878
|
catch (error) {
|
|
13879
13879
|
assertsError(error);
|
|
13880
|
-
throw new EnvironmentMismatchError(
|
|
13880
|
+
throw new EnvironmentMismatchError(_spaceTrim.spaceTrim((block) => `
|
|
13881
13881
|
\`run_browser\` tool is not available in this environment.
|
|
13882
13882
|
This commitment requires the Agents Server browser runtime with Playwright CLI.
|
|
13883
13883
|
|
|
@@ -13911,7 +13911,7 @@
|
|
|
13911
13911
|
? error
|
|
13912
13912
|
: new Error(typeof error === 'string' ? error : JSON.stringify(error !== null && error !== void 0 ? error : 'Unknown error'));
|
|
13913
13913
|
return async () => {
|
|
13914
|
-
throw new EnvironmentMismatchError(
|
|
13914
|
+
throw new EnvironmentMismatchError(_spaceTrim.spaceTrim((block) => `
|
|
13915
13915
|
\`send_email\` tool is not available in this environment.
|
|
13916
13916
|
This commitment requires Agents Server runtime with wallet-backed SMTP sending.
|
|
13917
13917
|
|
|
@@ -13943,7 +13943,7 @@
|
|
|
13943
13943
|
? error
|
|
13944
13944
|
: new Error(typeof error === 'string' ? error : JSON.stringify(error !== null && error !== void 0 ? error : 'Unknown error'));
|
|
13945
13945
|
return async () => {
|
|
13946
|
-
throw new EnvironmentMismatchError(
|
|
13946
|
+
throw new EnvironmentMismatchError(_spaceTrim.spaceTrim((block) => `
|
|
13947
13947
|
\`spawn_agent\` tool is not available in this environment.
|
|
13948
13948
|
This commitment requires Agents Server runtime with agent persistence enabled.
|
|
13949
13949
|
|
|
@@ -14163,7 +14163,7 @@
|
|
|
14163
14163
|
* Markdown documentation for ACTION commitment.
|
|
14164
14164
|
*/
|
|
14165
14165
|
get documentation() {
|
|
14166
|
-
return
|
|
14166
|
+
return _spaceTrim.spaceTrim(`
|
|
14167
14167
|
# ${this.type}
|
|
14168
14168
|
|
|
14169
14169
|
Defines specific actions or capabilities that the agent can perform.
|
|
@@ -14250,7 +14250,7 @@
|
|
|
14250
14250
|
* Markdown documentation for CLOSED commitment.
|
|
14251
14251
|
*/
|
|
14252
14252
|
get documentation() {
|
|
14253
|
-
return
|
|
14253
|
+
return _spaceTrim.spaceTrim(`
|
|
14254
14254
|
# CLOSED
|
|
14255
14255
|
|
|
14256
14256
|
Specifies that the agent **cannot** be modified by conversation with it.
|
|
@@ -14305,7 +14305,7 @@
|
|
|
14305
14305
|
* Markdown documentation for COMPONENT commitment.
|
|
14306
14306
|
*/
|
|
14307
14307
|
get documentation() {
|
|
14308
|
-
return
|
|
14308
|
+
return _spaceTrim.spaceTrim(`
|
|
14309
14309
|
# COMPONENT
|
|
14310
14310
|
|
|
14311
14311
|
Defines a UI component that the agent can render in the chat.
|
|
@@ -14377,7 +14377,7 @@
|
|
|
14377
14377
|
* Markdown documentation for DELETE commitment.
|
|
14378
14378
|
*/
|
|
14379
14379
|
get documentation() {
|
|
14380
|
-
return
|
|
14380
|
+
return _spaceTrim.spaceTrim(`
|
|
14381
14381
|
# DELETE (CANCEL, DISCARD, REMOVE)
|
|
14382
14382
|
|
|
14383
14383
|
A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
|
|
@@ -14508,7 +14508,7 @@
|
|
|
14508
14508
|
* Markdown documentation for DICTIONARY commitment.
|
|
14509
14509
|
*/
|
|
14510
14510
|
get documentation() {
|
|
14511
|
-
return
|
|
14511
|
+
return _spaceTrim.spaceTrim(`
|
|
14512
14512
|
# DICTIONARY
|
|
14513
14513
|
|
|
14514
14514
|
Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
|
|
@@ -14605,7 +14605,7 @@
|
|
|
14605
14605
|
* Markdown documentation for FORMAT commitment.
|
|
14606
14606
|
*/
|
|
14607
14607
|
get documentation() {
|
|
14608
|
-
return
|
|
14608
|
+
return _spaceTrim.spaceTrim(`
|
|
14609
14609
|
# ${this.type}
|
|
14610
14610
|
|
|
14611
14611
|
Defines the specific output structure and formatting for responses (data formats, templates, structure).
|
|
@@ -14901,7 +14901,7 @@
|
|
|
14901
14901
|
* Markdown documentation for FROM commitment.
|
|
14902
14902
|
*/
|
|
14903
14903
|
get documentation() {
|
|
14904
|
-
return
|
|
14904
|
+
return _spaceTrim.spaceTrim(`
|
|
14905
14905
|
# ${this.type}
|
|
14906
14906
|
|
|
14907
14907
|
Inherits agent source from another agent.
|
|
@@ -14928,7 +14928,7 @@
|
|
|
14928
14928
|
};
|
|
14929
14929
|
}
|
|
14930
14930
|
if (!isValidAgentUrl(trimmedContent)) {
|
|
14931
|
-
throw new Error(
|
|
14931
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
14932
14932
|
Invalid agent URL in FROM commitment: "${trimmedContent}"
|
|
14933
14933
|
|
|
14934
14934
|
\`\`\`book
|
|
@@ -14985,7 +14985,7 @@
|
|
|
14985
14985
|
* Markdown documentation for GOAL commitment.
|
|
14986
14986
|
*/
|
|
14987
14987
|
get documentation() {
|
|
14988
|
-
return
|
|
14988
|
+
return _spaceTrim.spaceTrim(`
|
|
14989
14989
|
# ${this.type}
|
|
14990
14990
|
|
|
14991
14991
|
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.
|
|
@@ -15082,7 +15082,7 @@
|
|
|
15082
15082
|
* Markdown documentation for IMPORT commitment.
|
|
15083
15083
|
*/
|
|
15084
15084
|
get documentation() {
|
|
15085
|
-
return
|
|
15085
|
+
return _spaceTrim.spaceTrim(`
|
|
15086
15086
|
# ${this.type}
|
|
15087
15087
|
|
|
15088
15088
|
Imports content from another agent or a generic text file at the location of the commitment.
|
|
@@ -15117,7 +15117,7 @@
|
|
|
15117
15117
|
importedFileUrls: [...(requirements.importedFileUrls || []), trimmedContent],
|
|
15118
15118
|
};
|
|
15119
15119
|
}
|
|
15120
|
-
throw new Error(
|
|
15120
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
15121
15121
|
Invalid agent URL or file path in IMPORT commitment: "${trimmedContent}"
|
|
15122
15122
|
|
|
15123
15123
|
\`\`\`book
|
|
@@ -15371,7 +15371,7 @@
|
|
|
15371
15371
|
* Markdown documentation for KNOWLEDGE commitment.
|
|
15372
15372
|
*/
|
|
15373
15373
|
get documentation() {
|
|
15374
|
-
return
|
|
15374
|
+
return _spaceTrim.spaceTrim(`
|
|
15375
15375
|
# ${this.type}
|
|
15376
15376
|
|
|
15377
15377
|
Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
|
|
@@ -15499,7 +15499,7 @@
|
|
|
15499
15499
|
* Markdown documentation for LANGUAGE/LANGUAGES commitment.
|
|
15500
15500
|
*/
|
|
15501
15501
|
get documentation() {
|
|
15502
|
-
return
|
|
15502
|
+
return _spaceTrim.spaceTrim(`
|
|
15503
15503
|
# ${this.type}
|
|
15504
15504
|
|
|
15505
15505
|
Specifies the language(s) the agent should use in its responses.
|
|
@@ -15528,7 +15528,7 @@
|
|
|
15528
15528
|
return requirements;
|
|
15529
15529
|
}
|
|
15530
15530
|
// Add language rule to the system message
|
|
15531
|
-
const languageSection = this.createSystemMessageSection('Language:',
|
|
15531
|
+
const languageSection = this.createSystemMessageSection('Language:', _spaceTrim.spaceTrim((block) => `
|
|
15532
15532
|
${block(trimmedContent)}
|
|
15533
15533
|
<- You are speaking these languages in your responses to the user.
|
|
15534
15534
|
`));
|
|
@@ -15545,11 +15545,11 @@
|
|
|
15545
15545
|
* @private utility for commitments
|
|
15546
15546
|
*/
|
|
15547
15547
|
function formatOptionalInstructionBlock(label, content) {
|
|
15548
|
-
const trimmedContent =
|
|
15548
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
15549
15549
|
if (!trimmedContent) {
|
|
15550
15550
|
return '';
|
|
15551
15551
|
}
|
|
15552
|
-
return
|
|
15552
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
15553
15553
|
- ${label}:
|
|
15554
15554
|
${block(trimmedContent
|
|
15555
15555
|
.split(/\r?\n/)
|
|
@@ -15576,7 +15576,7 @@
|
|
|
15576
15576
|
* @private function of MemoryCommitmentDefinition
|
|
15577
15577
|
*/
|
|
15578
15578
|
function createMemorySystemMessage(extraInstructions) {
|
|
15579
|
-
return
|
|
15579
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
15580
15580
|
Memory:
|
|
15581
15581
|
- Prefer storing agent-scoped memories; only make them global when the fact should apply across all your agents.
|
|
15582
15582
|
- You can use persistent user memory tools.
|
|
@@ -15966,7 +15966,7 @@
|
|
|
15966
15966
|
if (!tools.some((tool) => tool.name === MemoryToolNames.retrieve)) {
|
|
15967
15967
|
tools.push({
|
|
15968
15968
|
name: MemoryToolNames.retrieve,
|
|
15969
|
-
description:
|
|
15969
|
+
description: _spaceTrim.spaceTrim(`
|
|
15970
15970
|
Retrieve previously stored user memories relevant to the current conversation.
|
|
15971
15971
|
Use this before responding when user context can improve the answer.
|
|
15972
15972
|
`),
|
|
@@ -15988,7 +15988,7 @@
|
|
|
15988
15988
|
if (!tools.some((tool) => tool.name === MemoryToolNames.store)) {
|
|
15989
15989
|
tools.push({
|
|
15990
15990
|
name: MemoryToolNames.store,
|
|
15991
|
-
description:
|
|
15991
|
+
description: _spaceTrim.spaceTrim(`
|
|
15992
15992
|
Store a durable user memory that should be remembered in future conversations.
|
|
15993
15993
|
Store only stable and useful user-specific facts or preferences.
|
|
15994
15994
|
`),
|
|
@@ -16011,7 +16011,7 @@
|
|
|
16011
16011
|
if (!tools.some((tool) => tool.name === MemoryToolNames.update)) {
|
|
16012
16012
|
tools.push({
|
|
16013
16013
|
name: MemoryToolNames.update,
|
|
16014
|
-
description:
|
|
16014
|
+
description: _spaceTrim.spaceTrim(`
|
|
16015
16015
|
Update an existing user memory after retrieving it, so the stored fact stays accurate.
|
|
16016
16016
|
Always pass the memory id you retrieved along with the new content.
|
|
16017
16017
|
`),
|
|
@@ -16038,7 +16038,7 @@
|
|
|
16038
16038
|
if (!tools.some((tool) => tool.name === MemoryToolNames.delete)) {
|
|
16039
16039
|
tools.push({
|
|
16040
16040
|
name: MemoryToolNames.delete,
|
|
16041
|
-
description:
|
|
16041
|
+
description: _spaceTrim.spaceTrim(`
|
|
16042
16042
|
Delete a user memory that is no longer relevant. Deletions are soft so the record is hidden from future queries.
|
|
16043
16043
|
`),
|
|
16044
16044
|
parameters: {
|
|
@@ -16062,7 +16062,7 @@
|
|
|
16062
16062
|
* @private function of MemoryCommitmentDefinition
|
|
16063
16063
|
*/
|
|
16064
16064
|
function getMemoryCommitmentDocumentation(type) {
|
|
16065
|
-
return
|
|
16065
|
+
return _spaceTrim.spaceTrim(`
|
|
16066
16066
|
# ${type}
|
|
16067
16067
|
|
|
16068
16068
|
Enables persistent user memory for the current agent. The memory is stored by the runtime and can be retrieved in future conversations.
|
|
@@ -16221,7 +16221,7 @@
|
|
|
16221
16221
|
* Markdown documentation for AGENT MESSAGE commitment.
|
|
16222
16222
|
*/
|
|
16223
16223
|
get documentation() {
|
|
16224
|
-
return
|
|
16224
|
+
return _spaceTrim.spaceTrim(`
|
|
16225
16225
|
# ${this.type}
|
|
16226
16226
|
|
|
16227
16227
|
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.
|
|
@@ -16298,7 +16298,7 @@
|
|
|
16298
16298
|
* Markdown documentation for INITIAL MESSAGE commitment.
|
|
16299
16299
|
*/
|
|
16300
16300
|
get documentation() {
|
|
16301
|
-
return
|
|
16301
|
+
return _spaceTrim.spaceTrim(`
|
|
16302
16302
|
# ${this.type}
|
|
16303
16303
|
|
|
16304
16304
|
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).
|
|
@@ -16365,7 +16365,7 @@
|
|
|
16365
16365
|
* Markdown documentation for INTERNAL MESSAGE commitment.
|
|
16366
16366
|
*/
|
|
16367
16367
|
get documentation() {
|
|
16368
|
-
return
|
|
16368
|
+
return _spaceTrim.spaceTrim(`
|
|
16369
16369
|
# ${this.type}
|
|
16370
16370
|
|
|
16371
16371
|
Defines an internal trace message related to one interaction. This is intended mainly for self-learning analytics and future training datasets.
|
|
@@ -16441,7 +16441,7 @@
|
|
|
16441
16441
|
* Markdown documentation for MESSAGE commitment.
|
|
16442
16442
|
*/
|
|
16443
16443
|
get documentation() {
|
|
16444
|
-
return
|
|
16444
|
+
return _spaceTrim.spaceTrim(`
|
|
16445
16445
|
# ${this.type}
|
|
16446
16446
|
|
|
16447
16447
|
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.
|
|
@@ -16553,7 +16553,7 @@
|
|
|
16553
16553
|
* Markdown documentation for USER MESSAGE commitment.
|
|
16554
16554
|
*/
|
|
16555
16555
|
get documentation() {
|
|
16556
|
-
return
|
|
16556
|
+
return _spaceTrim.spaceTrim(`
|
|
16557
16557
|
# ${this.type}
|
|
16558
16558
|
|
|
16559
16559
|
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.
|
|
@@ -16620,7 +16620,7 @@
|
|
|
16620
16620
|
* Markdown documentation for MESSAGE SUFFIX commitment.
|
|
16621
16621
|
*/
|
|
16622
16622
|
get documentation() {
|
|
16623
|
-
return
|
|
16623
|
+
return _spaceTrim.spaceTrim(`
|
|
16624
16624
|
# MESSAGE SUFFIX
|
|
16625
16625
|
|
|
16626
16626
|
Defines a hardcoded message appended to every assistant response.
|
|
@@ -16702,7 +16702,7 @@
|
|
|
16702
16702
|
* Markdown documentation for META commitment.
|
|
16703
16703
|
*/
|
|
16704
16704
|
get documentation() {
|
|
16705
|
-
return
|
|
16705
|
+
return _spaceTrim.spaceTrim(`
|
|
16706
16706
|
# META
|
|
16707
16707
|
|
|
16708
16708
|
Sets meta-information about the agent that is used for display and attribution purposes.
|
|
@@ -16843,7 +16843,7 @@
|
|
|
16843
16843
|
* Markdown documentation for META COLOR commitment.
|
|
16844
16844
|
*/
|
|
16845
16845
|
get documentation() {
|
|
16846
|
-
return
|
|
16846
|
+
return _spaceTrim.spaceTrim(`
|
|
16847
16847
|
# META COLOR
|
|
16848
16848
|
|
|
16849
16849
|
Sets the agent's accent color or gradient.
|
|
@@ -16927,7 +16927,7 @@
|
|
|
16927
16927
|
* Markdown documentation for META DOMAIN commitment.
|
|
16928
16928
|
*/
|
|
16929
16929
|
get documentation() {
|
|
16930
|
-
return
|
|
16930
|
+
return _spaceTrim.spaceTrim(`
|
|
16931
16931
|
# META DOMAIN
|
|
16932
16932
|
|
|
16933
16933
|
Sets the canonical domain (host) of the agent, for example a custom domain that should open this agent directly.
|
|
@@ -17002,7 +17002,7 @@
|
|
|
17002
17002
|
* Markdown documentation for META DISCLAIMER commitment.
|
|
17003
17003
|
*/
|
|
17004
17004
|
get documentation() {
|
|
17005
|
-
return
|
|
17005
|
+
return _spaceTrim.spaceTrim(`
|
|
17006
17006
|
# META DISCLAIMER
|
|
17007
17007
|
|
|
17008
17008
|
Defines a markdown disclaimer shown to users before they can start chatting with the agent.
|
|
@@ -17072,7 +17072,7 @@
|
|
|
17072
17072
|
* Markdown documentation for META FONT commitment.
|
|
17073
17073
|
*/
|
|
17074
17074
|
get documentation() {
|
|
17075
|
-
return
|
|
17075
|
+
return _spaceTrim.spaceTrim(`
|
|
17076
17076
|
# META FONT
|
|
17077
17077
|
|
|
17078
17078
|
Sets the agent's font.
|
|
@@ -17157,7 +17157,7 @@
|
|
|
17157
17157
|
* Markdown documentation for META IMAGE commitment.
|
|
17158
17158
|
*/
|
|
17159
17159
|
get documentation() {
|
|
17160
|
-
return
|
|
17160
|
+
return _spaceTrim.spaceTrim(`
|
|
17161
17161
|
# META IMAGE
|
|
17162
17162
|
|
|
17163
17163
|
Sets the agent's avatar/profile image URL.
|
|
@@ -17236,7 +17236,7 @@
|
|
|
17236
17236
|
* Markdown documentation for META INPUT PLACEHOLDER commitment.
|
|
17237
17237
|
*/
|
|
17238
17238
|
get documentation() {
|
|
17239
|
-
return
|
|
17239
|
+
return _spaceTrim.spaceTrim(`
|
|
17240
17240
|
# META INPUT PLACEHOLDER
|
|
17241
17241
|
|
|
17242
17242
|
Sets custom placeholder text for the chat input field.
|
|
@@ -17317,7 +17317,7 @@
|
|
|
17317
17317
|
* Markdown documentation for META LINK commitment.
|
|
17318
17318
|
*/
|
|
17319
17319
|
get documentation() {
|
|
17320
|
-
return
|
|
17320
|
+
return _spaceTrim.spaceTrim(`
|
|
17321
17321
|
# META LINK
|
|
17322
17322
|
|
|
17323
17323
|
Represents a profile or source link for the person the agent is modeled after.
|
|
@@ -17416,7 +17416,7 @@
|
|
|
17416
17416
|
* Markdown documentation for META VOICE commitment.
|
|
17417
17417
|
*/
|
|
17418
17418
|
get documentation() {
|
|
17419
|
-
return
|
|
17419
|
+
return _spaceTrim.spaceTrim(`
|
|
17420
17420
|
# META VOICE
|
|
17421
17421
|
|
|
17422
17422
|
Instructs the UI to use a specific ElevenLabs voice when reading this agent's replies aloud.
|
|
@@ -17498,7 +17498,7 @@
|
|
|
17498
17498
|
* Markdown documentation for MODEL commitment.
|
|
17499
17499
|
*/
|
|
17500
17500
|
get documentation() {
|
|
17501
|
-
return
|
|
17501
|
+
return _spaceTrim.spaceTrim(`
|
|
17502
17502
|
# ${this.type}
|
|
17503
17503
|
|
|
17504
17504
|
Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
|
|
@@ -17739,7 +17739,7 @@
|
|
|
17739
17739
|
* Markdown documentation for NOTE commitment.
|
|
17740
17740
|
*/
|
|
17741
17741
|
get documentation() {
|
|
17742
|
-
return
|
|
17742
|
+
return _spaceTrim.spaceTrim(`
|
|
17743
17743
|
# ${this.type}
|
|
17744
17744
|
|
|
17745
17745
|
Adds comments for documentation without changing agent behavior.
|
|
@@ -17778,7 +17778,7 @@
|
|
|
17778
17778
|
applyToAgentModelRequirements(requirements, content) {
|
|
17779
17779
|
// The NOTE commitment makes no changes to the system message or model requirements
|
|
17780
17780
|
// It only stores the note content in metadata for documentation purposes
|
|
17781
|
-
const trimmedContent =
|
|
17781
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
17782
17782
|
if (trimmedContent === '') {
|
|
17783
17783
|
return requirements;
|
|
17784
17784
|
}
|
|
@@ -17823,7 +17823,7 @@
|
|
|
17823
17823
|
* Markdown documentation for OPEN commitment.
|
|
17824
17824
|
*/
|
|
17825
17825
|
get documentation() {
|
|
17826
|
-
return
|
|
17826
|
+
return _spaceTrim.spaceTrim(`
|
|
17827
17827
|
# OPEN
|
|
17828
17828
|
|
|
17829
17829
|
Specifies that the agent can be modified by conversation with it.
|
|
@@ -17900,7 +17900,7 @@
|
|
|
17900
17900
|
* Markdown documentation for PERSONA commitment.
|
|
17901
17901
|
*/
|
|
17902
17902
|
get documentation() {
|
|
17903
|
-
return
|
|
17903
|
+
return _spaceTrim.spaceTrim(`
|
|
17904
17904
|
# ${this.type}
|
|
17905
17905
|
|
|
17906
17906
|
Defines who the agent is, their background, expertise, and personality traits.
|
|
@@ -18033,7 +18033,7 @@
|
|
|
18033
18033
|
* Markdown documentation for RULE/RULES commitment.
|
|
18034
18034
|
*/
|
|
18035
18035
|
get documentation() {
|
|
18036
|
-
return
|
|
18036
|
+
return _spaceTrim.spaceTrim(`
|
|
18037
18037
|
# ${this.type}
|
|
18038
18038
|
|
|
18039
18039
|
Adds behavioral constraints and guidelines that the agent must follow.
|
|
@@ -18097,7 +18097,7 @@
|
|
|
18097
18097
|
* @private internal utility of writing commitments
|
|
18098
18098
|
*/
|
|
18099
18099
|
function createWritingSampleSection(content) {
|
|
18100
|
-
return
|
|
18100
|
+
return _spaceTrim.spaceTrim(`
|
|
18101
18101
|
Use this as a 1:1 voice exemplar for how your replies should sound.
|
|
18102
18102
|
Treat it as sample-only guidance for voice, cadence, phrasing, and emotional texture, not as task-solving instructions.
|
|
18103
18103
|
If multiple writing samples exist, newer samples have higher weight than older ones.
|
|
@@ -18114,7 +18114,7 @@
|
|
|
18114
18114
|
* @private internal utility of writing commitments
|
|
18115
18115
|
*/
|
|
18116
18116
|
function createWritingRulesSection(content) {
|
|
18117
|
-
return
|
|
18117
|
+
return _spaceTrim.spaceTrim(`
|
|
18118
18118
|
These instructions apply only to how you write: tone, formatting, length, emoji usage, punctuation, and similar presentation choices.
|
|
18119
18119
|
They do not change your task-solving behavior, business logic, or factual decision-making rules.
|
|
18120
18120
|
If multiple writing-rules blocks conflict, prefer the newer writing-rules blocks.
|
|
@@ -18164,7 +18164,7 @@
|
|
|
18164
18164
|
* Markdown documentation for `SAMPLE` / `EXAMPLE`.
|
|
18165
18165
|
*/
|
|
18166
18166
|
get documentation() {
|
|
18167
|
-
return
|
|
18167
|
+
return _spaceTrim.spaceTrim(`
|
|
18168
18168
|
# ${this.type}
|
|
18169
18169
|
|
|
18170
18170
|
Deprecated legacy alias for \`WRITING SAMPLE\`.
|
|
@@ -18245,7 +18245,7 @@
|
|
|
18245
18245
|
* Markdown documentation for SCENARIO commitment.
|
|
18246
18246
|
*/
|
|
18247
18247
|
get documentation() {
|
|
18248
|
-
return
|
|
18248
|
+
return _spaceTrim.spaceTrim(`
|
|
18249
18249
|
# ${this.type}
|
|
18250
18250
|
|
|
18251
18251
|
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.
|
|
@@ -18367,7 +18367,7 @@
|
|
|
18367
18367
|
* Markdown documentation for STYLE commitment.
|
|
18368
18368
|
*/
|
|
18369
18369
|
get documentation() {
|
|
18370
|
-
return
|
|
18370
|
+
return _spaceTrim.spaceTrim(`
|
|
18371
18371
|
# ${this.type}
|
|
18372
18372
|
|
|
18373
18373
|
Defines how the agent should format and present its responses (tone, writing style, formatting).
|
|
@@ -18640,7 +18640,7 @@
|
|
|
18640
18640
|
* Markdown documentation for TEAM commitment.
|
|
18641
18641
|
*/
|
|
18642
18642
|
get documentation() {
|
|
18643
|
-
return
|
|
18643
|
+
return _spaceTrim.spaceTrim(`
|
|
18644
18644
|
# TEAM
|
|
18645
18645
|
|
|
18646
18646
|
Registers teammate agents that the current agent can consult via tools.
|
|
@@ -19006,7 +19006,7 @@
|
|
|
19006
19006
|
* Markdown documentation for TEMPLATE commitment.
|
|
19007
19007
|
*/
|
|
19008
19008
|
get documentation() {
|
|
19009
|
-
return
|
|
19009
|
+
return _spaceTrim.spaceTrim(`
|
|
19010
19010
|
# ${this.type}
|
|
19011
19011
|
|
|
19012
19012
|
Enforces a specific response structure or template that the agent must follow when generating responses.
|
|
@@ -19062,7 +19062,7 @@
|
|
|
19062
19062
|
templateMode: true,
|
|
19063
19063
|
};
|
|
19064
19064
|
// Add a general instruction about using structured templates
|
|
19065
|
-
const templateModeInstruction =
|
|
19065
|
+
const templateModeInstruction = _spaceTrim.spaceTrim(`
|
|
19066
19066
|
Use a clear, structured template format for your responses.
|
|
19067
19067
|
Maintain consistency in how you organize and present information.
|
|
19068
19068
|
`);
|
|
@@ -19133,7 +19133,7 @@
|
|
|
19133
19133
|
* Markdown documentation for USE commitment.
|
|
19134
19134
|
*/
|
|
19135
19135
|
get documentation() {
|
|
19136
|
-
return
|
|
19136
|
+
return _spaceTrim.spaceTrim(`
|
|
19137
19137
|
# USE
|
|
19138
19138
|
|
|
19139
19139
|
Enables the agent to use specific tools or capabilities for interacting with external systems.
|
|
@@ -19291,7 +19291,7 @@
|
|
|
19291
19291
|
* Markdown documentation for USE BROWSER commitment.
|
|
19292
19292
|
*/
|
|
19293
19293
|
get documentation() {
|
|
19294
|
-
return
|
|
19294
|
+
return _spaceTrim.spaceTrim(`
|
|
19295
19295
|
# USE BROWSER
|
|
19296
19296
|
|
|
19297
19297
|
Enables the agent to use browser tools to access and retrieve up-to-date information from the internet.
|
|
@@ -19354,7 +19354,7 @@
|
|
|
19354
19354
|
if (!existingTools.some((tool) => tool.name === 'fetch_url_content')) {
|
|
19355
19355
|
toolsToAdd.push({
|
|
19356
19356
|
name: 'fetch_url_content',
|
|
19357
|
-
description:
|
|
19357
|
+
description: _spaceTrim.spaceTrim(`
|
|
19358
19358
|
Fetches and scrapes the content from a URL (webpage or document).
|
|
19359
19359
|
This tool retrieves the content of the specified URL and converts it to markdown format.
|
|
19360
19360
|
Use this when you need to access information from a specific website or document.
|
|
@@ -19376,7 +19376,7 @@
|
|
|
19376
19376
|
if (!existingTools.some((tool) => tool.name === 'run_browser')) {
|
|
19377
19377
|
toolsToAdd.push({
|
|
19378
19378
|
name: 'run_browser',
|
|
19379
|
-
description:
|
|
19379
|
+
description: _spaceTrim.spaceTrim(`
|
|
19380
19380
|
Launches a browser session for complex interactions.
|
|
19381
19381
|
This tool is for advanced browser automation tasks like scrolling, clicking, form filling, etc.
|
|
19382
19382
|
Use this when simple one-shot URL fetching is not enough.
|
|
@@ -19423,7 +19423,7 @@
|
|
|
19423
19423
|
...requirements._metadata,
|
|
19424
19424
|
useBrowser: true,
|
|
19425
19425
|
},
|
|
19426
|
-
},
|
|
19426
|
+
}, _spaceTrim.spaceTrim(`
|
|
19427
19427
|
You have access to browser tools to fetch and access content from the internet.
|
|
19428
19428
|
- Use "fetch_url_content" to retrieve content from specific URLs (webpages or documents) using scrapers.
|
|
19429
19429
|
- Use "run_browser" for real interactive browser automation (navigation, clicks, typing, waiting, scrolling).
|
|
@@ -19455,7 +19455,7 @@
|
|
|
19455
19455
|
async run_browser(args) {
|
|
19456
19456
|
console.log('!!!! [Tool] run_browser called', { args });
|
|
19457
19457
|
const { url } = args;
|
|
19458
|
-
return
|
|
19458
|
+
return _spaceTrim.spaceTrim(`
|
|
19459
19459
|
# Running browser
|
|
19460
19460
|
|
|
19461
19461
|
The running browser tool is not available in this runtime.
|
|
@@ -19508,7 +19508,7 @@
|
|
|
19508
19508
|
return null;
|
|
19509
19509
|
}
|
|
19510
19510
|
if (!response.ok) {
|
|
19511
|
-
throw new Error(
|
|
19511
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
19512
19512
|
Google Calendar API request failed (${response.status} ${response.statusText}):
|
|
19513
19513
|
${extractGoogleCalendarApiErrorMessage(parsedPayload, textPayload)}
|
|
19514
19514
|
`));
|
|
@@ -19617,7 +19617,7 @@
|
|
|
19617
19617
|
* @private internal utility of USE CALENDAR commitment
|
|
19618
19618
|
*/
|
|
19619
19619
|
function parseUseCalendarCommitmentContent(content) {
|
|
19620
|
-
const trimmedContent =
|
|
19620
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
19621
19621
|
if (!trimmedContent) {
|
|
19622
19622
|
return {
|
|
19623
19623
|
calendar: null,
|
|
@@ -20597,7 +20597,7 @@
|
|
|
20597
20597
|
* Markdown documentation for USE CALENDAR commitment.
|
|
20598
20598
|
*/
|
|
20599
20599
|
get documentation() {
|
|
20600
|
-
return
|
|
20600
|
+
return _spaceTrim.spaceTrim(`
|
|
20601
20601
|
# USE CALENDAR
|
|
20602
20602
|
|
|
20603
20603
|
Enables the agent to access and manage one Google Calendar.
|
|
@@ -20654,7 +20654,7 @@
|
|
|
20654
20654
|
useCalendar: true,
|
|
20655
20655
|
useCalendars: existingConfiguredCalendars,
|
|
20656
20656
|
},
|
|
20657
|
-
},
|
|
20657
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
20658
20658
|
Calendar tools:
|
|
20659
20659
|
- You can inspect and manage events in configured calendars.
|
|
20660
20660
|
- Supported operations include read, create, update, delete, invite guests, and reminders.
|
|
@@ -20716,7 +20716,7 @@
|
|
|
20716
20716
|
* @private internal utility of USE EMAIL commitment
|
|
20717
20717
|
*/
|
|
20718
20718
|
function parseUseEmailCommitmentContent(content) {
|
|
20719
|
-
const trimmedContent =
|
|
20719
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
20720
20720
|
if (!trimmedContent) {
|
|
20721
20721
|
return {
|
|
20722
20722
|
senderEmail: null,
|
|
@@ -20845,7 +20845,7 @@
|
|
|
20845
20845
|
* Markdown documentation for USE EMAIL commitment.
|
|
20846
20846
|
*/
|
|
20847
20847
|
get documentation() {
|
|
20848
|
-
return
|
|
20848
|
+
return _spaceTrim.spaceTrim(`
|
|
20849
20849
|
# USE EMAIL
|
|
20850
20850
|
|
|
20851
20851
|
Enables the agent to send outbound emails through SMTP.
|
|
@@ -20887,7 +20887,7 @@
|
|
|
20887
20887
|
useEmail: true,
|
|
20888
20888
|
...(parsedCommitment.senderEmail ? { useEmailSender: parsedCommitment.senderEmail } : {}),
|
|
20889
20889
|
},
|
|
20890
|
-
},
|
|
20890
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
20891
20891
|
Email tool:
|
|
20892
20892
|
- Use "${SEND_EMAIL_TOOL_NAME}" to send outbound emails.
|
|
20893
20893
|
- Prefer \`message\` argument compatible with Promptbook \`Message\` type.
|
|
@@ -21005,7 +21005,7 @@
|
|
|
21005
21005
|
* Markdown documentation for USE IMAGE GENERATOR commitment.
|
|
21006
21006
|
*/
|
|
21007
21007
|
get documentation() {
|
|
21008
|
-
return
|
|
21008
|
+
return _spaceTrim.spaceTrim(`
|
|
21009
21009
|
# USE IMAGE GENERATOR
|
|
21010
21010
|
|
|
21011
21011
|
Enables the agent to output markdown image placeholders that trigger image generation in the user interface.
|
|
@@ -21044,7 +21044,7 @@
|
|
|
21044
21044
|
...requirements._metadata,
|
|
21045
21045
|
useImageGenerator: content || true,
|
|
21046
21046
|
},
|
|
21047
|
-
},
|
|
21047
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
21048
21048
|
Image generation:
|
|
21049
21049
|
- You do not generate images directly and you do not call any image tool.
|
|
21050
21050
|
- When the user asks for an image, include markdown notation in your message:
|
|
@@ -21096,7 +21096,7 @@
|
|
|
21096
21096
|
* Markdown documentation for USE MCP commitment.
|
|
21097
21097
|
*/
|
|
21098
21098
|
get documentation() {
|
|
21099
|
-
return
|
|
21099
|
+
return _spaceTrim.spaceTrim(`
|
|
21100
21100
|
# USE MCP
|
|
21101
21101
|
|
|
21102
21102
|
Connects the agent to an external Model Context Protocol (MCP) server.
|
|
@@ -21177,7 +21177,7 @@
|
|
|
21177
21177
|
* Markdown documentation for USE POPUP commitment.
|
|
21178
21178
|
*/
|
|
21179
21179
|
get documentation() {
|
|
21180
|
-
return
|
|
21180
|
+
return _spaceTrim.spaceTrim(`
|
|
21181
21181
|
# USE POPUP
|
|
21182
21182
|
|
|
21183
21183
|
Enables the agent to open a popup window with a specific website.
|
|
@@ -21209,7 +21209,7 @@
|
|
|
21209
21209
|
...existingTools,
|
|
21210
21210
|
{
|
|
21211
21211
|
name: 'open_popup',
|
|
21212
|
-
description:
|
|
21212
|
+
description: _spaceTrim.spaceTrim(`
|
|
21213
21213
|
Opens a popup window with a specific URL.
|
|
21214
21214
|
Use this when you want to show a specific website to the user in a new window.
|
|
21215
21215
|
${!content ? '' : `Constraints / instructions: ${content}`}
|
|
@@ -21234,7 +21234,7 @@
|
|
|
21234
21234
|
...requirements._metadata,
|
|
21235
21235
|
usePopup: content || true,
|
|
21236
21236
|
},
|
|
21237
|
-
},
|
|
21237
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
21238
21238
|
Tool:
|
|
21239
21239
|
- You can open a popup window with a specific URL using the tool "open_popup".
|
|
21240
21240
|
- Use this when you want the user to see or interact with a specific website.
|
|
@@ -21261,7 +21261,7 @@
|
|
|
21261
21261
|
window.open(url, '_blank');
|
|
21262
21262
|
return `Popup window with URL "${url}" was opened.`;
|
|
21263
21263
|
}
|
|
21264
|
-
return
|
|
21264
|
+
return _spaceTrim.spaceTrim(`
|
|
21265
21265
|
Popup window with URL "${url}" was requested.
|
|
21266
21266
|
|
|
21267
21267
|
Note: The agent is currently running on the server, so the popup cannot be opened automatically.
|
|
@@ -21355,7 +21355,7 @@
|
|
|
21355
21355
|
* Markdown documentation for USE PRIVACY commitment.
|
|
21356
21356
|
*/
|
|
21357
21357
|
get documentation() {
|
|
21358
|
-
return
|
|
21358
|
+
return _spaceTrim.spaceTrim(`
|
|
21359
21359
|
# USE PRIVACY
|
|
21360
21360
|
|
|
21361
21361
|
Enables the agent to request turning on private mode in chat.
|
|
@@ -21395,7 +21395,7 @@
|
|
|
21395
21395
|
...existingTools,
|
|
21396
21396
|
{
|
|
21397
21397
|
name: TURN_PRIVACY_ON_TOOL_NAME,
|
|
21398
|
-
description:
|
|
21398
|
+
description: _spaceTrim.spaceTrim(`
|
|
21399
21399
|
Requests turning private mode on in the chat UI.
|
|
21400
21400
|
The user must explicitly confirm the action in a dialog before private mode is enabled.
|
|
21401
21401
|
Use this for sensitive topics or when the user asks not to store conversation data.
|
|
@@ -21414,7 +21414,7 @@
|
|
|
21414
21414
|
...requirements._metadata,
|
|
21415
21415
|
usePrivacy: content || true,
|
|
21416
21416
|
},
|
|
21417
|
-
},
|
|
21417
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
21418
21418
|
Privacy mode:
|
|
21419
21419
|
- Use "${TURN_PRIVACY_ON_TOOL_NAME}" when the user asks for a private/sensitive conversation.
|
|
21420
21420
|
- This tool requests a UI confirmation dialog. Private mode is enabled only after user confirms.
|
|
@@ -21985,7 +21985,7 @@
|
|
|
21985
21985
|
return null;
|
|
21986
21986
|
}
|
|
21987
21987
|
if (!response.ok) {
|
|
21988
|
-
throw new Error(
|
|
21988
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
21989
21989
|
GitHub API request failed (${response.status} ${response.statusText}):
|
|
21990
21990
|
${extractGitHubApiErrorMessage(parsedPayload, textPayload)}
|
|
21991
21991
|
`));
|
|
@@ -22116,7 +22116,7 @@
|
|
|
22116
22116
|
* @private internal utility of USE PROJECT commitment
|
|
22117
22117
|
*/
|
|
22118
22118
|
function parseUseProjectCommitmentContent(content) {
|
|
22119
|
-
const trimmedContent =
|
|
22119
|
+
const trimmedContent = _spaceTrim.spaceTrim(content);
|
|
22120
22120
|
if (!trimmedContent) {
|
|
22121
22121
|
return {
|
|
22122
22122
|
repository: null,
|
|
@@ -23017,7 +23017,7 @@
|
|
|
23017
23017
|
* Markdown documentation for USE PROJECT commitment.
|
|
23018
23018
|
*/
|
|
23019
23019
|
get documentation() {
|
|
23020
|
-
return
|
|
23020
|
+
return _spaceTrim.spaceTrim(`
|
|
23021
23021
|
# USE PROJECT
|
|
23022
23022
|
|
|
23023
23023
|
Enables the agent to work with files in a GitHub repository and create pull requests.
|
|
@@ -23057,7 +23057,7 @@
|
|
|
23057
23057
|
useProject: true,
|
|
23058
23058
|
useProjects: existingConfiguredProjects,
|
|
23059
23059
|
},
|
|
23060
|
-
},
|
|
23060
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
23061
23061
|
Project tools:
|
|
23062
23062
|
- You can inspect and edit configured GitHub repositories using project tools.
|
|
23063
23063
|
- Configured repositories:
|
|
@@ -23183,7 +23183,7 @@
|
|
|
23183
23183
|
* Markdown documentation for USE SEARCH ENGINE commitment.
|
|
23184
23184
|
*/
|
|
23185
23185
|
get documentation() {
|
|
23186
|
-
return
|
|
23186
|
+
return _spaceTrim.spaceTrim(`
|
|
23187
23187
|
# USE SEARCH ENGINE
|
|
23188
23188
|
|
|
23189
23189
|
Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
|
|
@@ -23225,7 +23225,7 @@
|
|
|
23225
23225
|
...existingTools,
|
|
23226
23226
|
{
|
|
23227
23227
|
name: 'web_search',
|
|
23228
|
-
description:
|
|
23228
|
+
description: _spaceTrim.spaceTrim(`
|
|
23229
23229
|
Search the internet for information.
|
|
23230
23230
|
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
23231
23231
|
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
@@ -23274,7 +23274,7 @@
|
|
|
23274
23274
|
...requirements._metadata,
|
|
23275
23275
|
useSearchEngine: content || true,
|
|
23276
23276
|
},
|
|
23277
|
-
},
|
|
23277
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
23278
23278
|
Tool:
|
|
23279
23279
|
- You have access to the web search engine via the tool "web_search".
|
|
23280
23280
|
- Use it to find up-to-date information or facts that you don't know.
|
|
@@ -23305,11 +23305,11 @@
|
|
|
23305
23305
|
}
|
|
23306
23306
|
const searchEngine = new SerpSearchEngine();
|
|
23307
23307
|
const results = await searchEngine.search(query, options);
|
|
23308
|
-
return
|
|
23308
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
23309
23309
|
Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
|
|
23310
23310
|
|
|
23311
23311
|
${block(results
|
|
23312
|
-
.map((result) =>
|
|
23312
|
+
.map((result) => _spaceTrim.spaceTrim(`
|
|
23313
23313
|
- **${result.title}**
|
|
23314
23314
|
${result.url}
|
|
23315
23315
|
${result.snippet}
|
|
@@ -23437,7 +23437,7 @@
|
|
|
23437
23437
|
* Markdown documentation for USE SPAWN commitment.
|
|
23438
23438
|
*/
|
|
23439
23439
|
get documentation() {
|
|
23440
|
-
return
|
|
23440
|
+
return _spaceTrim.spaceTrim(`
|
|
23441
23441
|
# USE SPAWN
|
|
23442
23442
|
|
|
23443
23443
|
Enables the agent to create a new persistent child agent using the \`spawn_agent\` tool.
|
|
@@ -23474,7 +23474,7 @@
|
|
|
23474
23474
|
...existingTools,
|
|
23475
23475
|
{
|
|
23476
23476
|
name: SPAWN_AGENT_TOOL_NAME,
|
|
23477
|
-
description:
|
|
23477
|
+
description: _spaceTrim.spaceTrim(`
|
|
23478
23478
|
Creates one new persistent child agent in Agents Server.
|
|
23479
23479
|
Use this when the user asks to create a new dedicated agent profile.
|
|
23480
23480
|
The tool returns JSON with \`status\`, \`agentId\`, and created \`agent\` or \`error\`.
|
|
@@ -23489,7 +23489,7 @@
|
|
|
23489
23489
|
...requirements._metadata,
|
|
23490
23490
|
useSpawn: content || true,
|
|
23491
23491
|
},
|
|
23492
|
-
},
|
|
23492
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
23493
23493
|
Spawning agents:
|
|
23494
23494
|
- Use "${SPAWN_AGENT_TOOL_NAME}" only when user asks to create a persistent new agent.
|
|
23495
23495
|
- Pass full agent source in \`source\`.
|
|
@@ -23529,7 +23529,7 @@
|
|
|
23529
23529
|
* @private internal utility of USE TIMEOUT
|
|
23530
23530
|
*/
|
|
23531
23531
|
function createTimeoutSystemMessage(extraInstructions) {
|
|
23532
|
-
return
|
|
23532
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
23533
23533
|
Timeout scheduling:
|
|
23534
23534
|
- Use "set_timeout" to wake this same chat thread in the future.
|
|
23535
23535
|
- Use "list_timeouts" to review timeouts across all chats for the same user+agent scope.
|
|
@@ -23645,7 +23645,7 @@
|
|
|
23645
23645
|
set(args) {
|
|
23646
23646
|
const parsedMilliseconds = Number(args.milliseconds);
|
|
23647
23647
|
if (!Number.isFinite(parsedMilliseconds) || parsedMilliseconds <= 0) {
|
|
23648
|
-
throw new PipelineExecutionError(
|
|
23648
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
23649
23649
|
Timeout \`milliseconds\` must be a positive number.
|
|
23650
23650
|
`));
|
|
23651
23651
|
}
|
|
@@ -23661,7 +23661,7 @@
|
|
|
23661
23661
|
cancel(args) {
|
|
23662
23662
|
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
23663
23663
|
if (!timeoutId) {
|
|
23664
|
-
throw new PipelineExecutionError(
|
|
23664
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
23665
23665
|
Timeout \`timeoutId\` is required.
|
|
23666
23666
|
`));
|
|
23667
23667
|
}
|
|
@@ -23672,18 +23672,18 @@
|
|
|
23672
23672
|
*/
|
|
23673
23673
|
list(args) {
|
|
23674
23674
|
if (args.includeFinished !== undefined && typeof args.includeFinished !== 'boolean') {
|
|
23675
|
-
throw new PipelineExecutionError(
|
|
23675
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
23676
23676
|
Timeout \`includeFinished\` must be a boolean when provided.
|
|
23677
23677
|
`));
|
|
23678
23678
|
}
|
|
23679
23679
|
const parsedLimit = args.limit === undefined ? DEFAULT_LIST_TIMEOUTS_LIMIT : Math.floor(Number(args.limit));
|
|
23680
23680
|
if (!Number.isFinite(parsedLimit) || parsedLimit <= 0) {
|
|
23681
|
-
throw new PipelineExecutionError(
|
|
23681
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
23682
23682
|
Timeout \`limit\` must be a positive number.
|
|
23683
23683
|
`));
|
|
23684
23684
|
}
|
|
23685
23685
|
if (parsedLimit > MAX_LIST_TIMEOUTS_LIMIT) {
|
|
23686
|
-
throw new PipelineExecutionError(
|
|
23686
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim(`
|
|
23687
23687
|
Timeout \`limit\` must be at most \`${MAX_LIST_TIMEOUTS_LIMIT}\`.
|
|
23688
23688
|
`));
|
|
23689
23689
|
}
|
|
@@ -23929,7 +23929,7 @@
|
|
|
23929
23929
|
* Markdown documentation for `USE TIMEOUT`.
|
|
23930
23930
|
*/
|
|
23931
23931
|
get documentation() {
|
|
23932
|
-
return
|
|
23932
|
+
return _spaceTrim.spaceTrim(`
|
|
23933
23933
|
# USE TIMEOUT
|
|
23934
23934
|
|
|
23935
23935
|
Enables timeout wake-ups and timeout management for the same user+agent scope.
|
|
@@ -24020,7 +24020,7 @@
|
|
|
24020
24020
|
* Markdown documentation for USE TIME commitment.
|
|
24021
24021
|
*/
|
|
24022
24022
|
get documentation() {
|
|
24023
|
-
return
|
|
24023
|
+
return _spaceTrim.spaceTrim(`
|
|
24024
24024
|
# USE TIME
|
|
24025
24025
|
|
|
24026
24026
|
Enables the agent to determine the current date and time.
|
|
@@ -24081,7 +24081,7 @@
|
|
|
24081
24081
|
_metadata: {
|
|
24082
24082
|
...requirements._metadata,
|
|
24083
24083
|
},
|
|
24084
|
-
},
|
|
24084
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
24085
24085
|
Time and date context:
|
|
24086
24086
|
- It is ${moment__default["default"]().format('MMMM YYYY')} now.
|
|
24087
24087
|
- If you need more precise current time information, use the tool "get_current_time".
|
|
@@ -24249,7 +24249,7 @@
|
|
|
24249
24249
|
* Markdown documentation for USE USER LOCATION commitment.
|
|
24250
24250
|
*/
|
|
24251
24251
|
get documentation() {
|
|
24252
|
-
return
|
|
24252
|
+
return _spaceTrim.spaceTrim(`
|
|
24253
24253
|
# USE USER LOCATION
|
|
24254
24254
|
|
|
24255
24255
|
Enables the agent to retrieve the user's location from runtime context.
|
|
@@ -24287,7 +24287,7 @@
|
|
|
24287
24287
|
...existingTools,
|
|
24288
24288
|
{
|
|
24289
24289
|
name: GET_USER_LOCATION_TOOL_NAME,
|
|
24290
|
-
description:
|
|
24290
|
+
description: _spaceTrim.spaceTrim(`
|
|
24291
24291
|
Retrieves user location shared by browser runtime (if permission is granted).
|
|
24292
24292
|
Returns JSON status with coordinates and metadata when available.
|
|
24293
24293
|
`),
|
|
@@ -24305,7 +24305,7 @@
|
|
|
24305
24305
|
...requirements._metadata,
|
|
24306
24306
|
useUserLocation: content || true,
|
|
24307
24307
|
},
|
|
24308
|
-
},
|
|
24308
|
+
}, _spaceTrim.spaceTrim((block) => `
|
|
24309
24309
|
User location:
|
|
24310
24310
|
- Use "${GET_USER_LOCATION_TOOL_NAME}" only when location is needed for a better answer.
|
|
24311
24311
|
- If the tool returns "unavailable" or "permission-denied", ask user to share location or provide city manually.
|
|
@@ -24382,7 +24382,7 @@
|
|
|
24382
24382
|
* Markdown documentation for `WRITING RULES`.
|
|
24383
24383
|
*/
|
|
24384
24384
|
get documentation() {
|
|
24385
|
-
return
|
|
24385
|
+
return _spaceTrim.spaceTrim(`
|
|
24386
24386
|
# ${this.type}
|
|
24387
24387
|
|
|
24388
24388
|
Adds instructions that apply strictly to how the agent writes.
|
|
@@ -24460,7 +24460,7 @@
|
|
|
24460
24460
|
* Markdown documentation for `WRITING SAMPLE`.
|
|
24461
24461
|
*/
|
|
24462
24462
|
get documentation() {
|
|
24463
|
-
return
|
|
24463
|
+
return _spaceTrim.spaceTrim(`
|
|
24464
24464
|
# ${this.type}
|
|
24465
24465
|
|
|
24466
24466
|
Provides explicit 1:1 sample text that demonstrates how the agent should sound.
|
|
@@ -24532,7 +24532,7 @@
|
|
|
24532
24532
|
* Markdown documentation available at runtime.
|
|
24533
24533
|
*/
|
|
24534
24534
|
get documentation() {
|
|
24535
|
-
return
|
|
24535
|
+
return _spaceTrim.spaceTrim(`
|
|
24536
24536
|
# ${this.type}
|
|
24537
24537
|
|
|
24538
24538
|
This commitment is not yet fully implemented.
|
|
@@ -24937,11 +24937,11 @@
|
|
|
24937
24937
|
console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
|
|
24938
24938
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
24939
24939
|
}
|
|
24940
|
-
resolve(
|
|
24940
|
+
resolve(_spaceTrim.spaceTrim(output.join('\n')));
|
|
24941
24941
|
}
|
|
24942
24942
|
}
|
|
24943
24943
|
else {
|
|
24944
|
-
resolve(
|
|
24944
|
+
resolve(_spaceTrim.spaceTrim(output.join('\n')));
|
|
24945
24945
|
}
|
|
24946
24946
|
};
|
|
24947
24947
|
commandProcess.on('close', finishWithCode);
|
|
@@ -24959,7 +24959,7 @@
|
|
|
24959
24959
|
console.warn(error);
|
|
24960
24960
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
24961
24961
|
}
|
|
24962
|
-
resolve(
|
|
24962
|
+
resolve(_spaceTrim.spaceTrim(output.join('\n')));
|
|
24963
24963
|
}
|
|
24964
24964
|
});
|
|
24965
24965
|
}
|
|
@@ -25268,13 +25268,13 @@
|
|
|
25268
25268
|
});
|
|
25269
25269
|
const usedEnvMessage = $usedEnvFilename === null ? `Unknown \`.env\` file` : `Used \`.env\` file:\n${$usedEnvFilename}`;
|
|
25270
25270
|
if (metadata.length === 0) {
|
|
25271
|
-
return
|
|
25271
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
25272
25272
|
No LLM providers are available.
|
|
25273
25273
|
|
|
25274
25274
|
${block(usedEnvMessage)}
|
|
25275
25275
|
`);
|
|
25276
25276
|
}
|
|
25277
|
-
return
|
|
25277
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
25278
25278
|
|
|
25279
25279
|
${block(usedEnvMessage)}
|
|
25280
25280
|
|
|
@@ -25320,7 +25320,7 @@
|
|
|
25320
25320
|
morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
|
|
25321
25321
|
}
|
|
25322
25322
|
}
|
|
25323
|
-
let providerMessage =
|
|
25323
|
+
let providerMessage = _spaceTrim.spaceTrim(`
|
|
25324
25324
|
${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
|
|
25325
25325
|
${morePieces.join('; ')}
|
|
25326
25326
|
`);
|
|
@@ -25442,7 +25442,7 @@
|
|
|
25442
25442
|
.find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
|
|
25443
25443
|
if (registeredItem === undefined) {
|
|
25444
25444
|
// console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
|
|
25445
|
-
throw new Error(
|
|
25445
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
25446
25446
|
There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
|
|
25447
25447
|
Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
|
|
25448
25448
|
|
|
@@ -25510,14 +25510,14 @@
|
|
|
25510
25510
|
const configuration = await $provideLlmToolsConfigurationFromEnv();
|
|
25511
25511
|
if (configuration.length === 0) {
|
|
25512
25512
|
if ($llmToolsMetadataRegister.list().length === 0) {
|
|
25513
|
-
throw new UnexpectedError(
|
|
25513
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim((block) => `
|
|
25514
25514
|
No LLM tools registered, this is probably a bug in the Promptbook library
|
|
25515
25515
|
|
|
25516
25516
|
${block($registeredLlmToolsMessage())}}
|
|
25517
25517
|
`));
|
|
25518
25518
|
}
|
|
25519
25519
|
// TODO: [🥃]
|
|
25520
|
-
throw new Error(
|
|
25520
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
25521
25521
|
No LLM tools found in the environment
|
|
25522
25522
|
|
|
25523
25523
|
${block($registeredLlmToolsMessage())}}
|
|
@@ -25601,13 +25601,13 @@
|
|
|
25601
25601
|
* @public exported from `@promptbook/markdown-utils`
|
|
25602
25602
|
*/
|
|
25603
25603
|
function trimCodeBlock(value) {
|
|
25604
|
-
value =
|
|
25604
|
+
value = _spaceTrim.spaceTrim(value);
|
|
25605
25605
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
25606
25606
|
return value;
|
|
25607
25607
|
}
|
|
25608
25608
|
value = value.replace(/^```[a-z]*/i, '');
|
|
25609
25609
|
value = value.replace(/```$/i, '');
|
|
25610
|
-
value =
|
|
25610
|
+
value = _spaceTrim.spaceTrim(value);
|
|
25611
25611
|
return value;
|
|
25612
25612
|
}
|
|
25613
25613
|
|
|
@@ -25620,9 +25620,9 @@
|
|
|
25620
25620
|
* @public exported from `@promptbook/markdown-utils`
|
|
25621
25621
|
*/
|
|
25622
25622
|
function trimEndOfCodeBlock(value) {
|
|
25623
|
-
value =
|
|
25623
|
+
value = _spaceTrim.spaceTrim(value);
|
|
25624
25624
|
value = value.replace(/```$/g, '');
|
|
25625
|
-
value =
|
|
25625
|
+
value = _spaceTrim.spaceTrim(value);
|
|
25626
25626
|
return value;
|
|
25627
25627
|
}
|
|
25628
25628
|
|
|
@@ -25669,7 +25669,7 @@
|
|
|
25669
25669
|
}
|
|
25670
25670
|
// Note: [💎]
|
|
25671
25671
|
// Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
|
|
25672
|
-
const spaceTrim = (_) =>
|
|
25672
|
+
const spaceTrim = (_) => _spaceTrim__default["default"](_);
|
|
25673
25673
|
$preserve(spaceTrim);
|
|
25674
25674
|
const removeQuotes$1 = removeQuotes;
|
|
25675
25675
|
$preserve(removeQuotes$1);
|
|
@@ -25760,7 +25760,7 @@
|
|
|
25760
25760
|
.join('\n');
|
|
25761
25761
|
// script = templateParameters(script, parameters);
|
|
25762
25762
|
// <- TODO: [🧠][🥳] Should be this is one of two variants how to use parameters in script
|
|
25763
|
-
const statementToEvaluate =
|
|
25763
|
+
const statementToEvaluate = _spaceTrim__default["default"]((block) => `
|
|
25764
25764
|
|
|
25765
25765
|
// Build-in functions:
|
|
25766
25766
|
${block(buildinFunctionsStatement)}
|
|
@@ -25775,7 +25775,7 @@
|
|
|
25775
25775
|
(async ()=>{ ${script} })()
|
|
25776
25776
|
`);
|
|
25777
25777
|
if (this.options.isVerbose) {
|
|
25778
|
-
console.info(
|
|
25778
|
+
console.info(_spaceTrim__default["default"]((block) => `
|
|
25779
25779
|
🚀 Evaluating ${scriptLanguage} script:
|
|
25780
25780
|
|
|
25781
25781
|
${block(statementToEvaluate)}`));
|
|
@@ -25784,7 +25784,7 @@
|
|
|
25784
25784
|
try {
|
|
25785
25785
|
result = await eval(statementToEvaluate);
|
|
25786
25786
|
if (this.options.isVerbose) {
|
|
25787
|
-
console.info(
|
|
25787
|
+
console.info(_spaceTrim__default["default"]((block) => `
|
|
25788
25788
|
🚀 Script evaluated successfully, result:
|
|
25789
25789
|
${block(valueToString(result))}
|
|
25790
25790
|
`));
|
|
@@ -25803,7 +25803,7 @@
|
|
|
25803
25803
|
To: [PipelineExecutionError: Parameter `{thing}` is not defined],
|
|
25804
25804
|
*/
|
|
25805
25805
|
if (!statementToEvaluate.includes(undefinedName + '(')) {
|
|
25806
|
-
throw new PipelineExecutionError(
|
|
25806
|
+
throw new PipelineExecutionError(_spaceTrim__default["default"]((block) => `
|
|
25807
25807
|
|
|
25808
25808
|
Parameter \`{${undefinedName}}\` is not defined
|
|
25809
25809
|
|
|
@@ -25825,7 +25825,7 @@
|
|
|
25825
25825
|
`));
|
|
25826
25826
|
}
|
|
25827
25827
|
else {
|
|
25828
|
-
throw new PipelineExecutionError(
|
|
25828
|
+
throw new PipelineExecutionError(_spaceTrim__default["default"]((block) => `
|
|
25829
25829
|
Function ${undefinedName}() is not defined
|
|
25830
25830
|
|
|
25831
25831
|
- Make sure that the function is one of built-in functions
|
|
@@ -26078,7 +26078,7 @@
|
|
|
26078
26078
|
catch (error) {
|
|
26079
26079
|
assertsError(error);
|
|
26080
26080
|
// TODO: [7] DRY
|
|
26081
|
-
const wrappedErrorMessage =
|
|
26081
|
+
const wrappedErrorMessage = _spaceTrim.spaceTrim((block) => `
|
|
26082
26082
|
${error.name} in pipeline ${fileName.split('\\').join('/')}:
|
|
26083
26083
|
|
|
26084
26084
|
Original error message:
|
|
@@ -26113,7 +26113,7 @@
|
|
|
26113
26113
|
pipeline = { ...pipeline, pipelineUrl };
|
|
26114
26114
|
}
|
|
26115
26115
|
else if (!pipeline.pipelineUrl.startsWith(rootUrl)) {
|
|
26116
|
-
throw new PipelineUrlError(
|
|
26116
|
+
throw new PipelineUrlError(_spaceTrim.spaceTrim(`
|
|
26117
26117
|
Pipeline with URL ${pipeline.pipelineUrl} is not a child of the root URL ${rootUrl} 🍏
|
|
26118
26118
|
|
|
26119
26119
|
File:
|
|
@@ -26151,7 +26151,7 @@
|
|
|
26151
26151
|
}
|
|
26152
26152
|
else {
|
|
26153
26153
|
const existing = collection.get(pipeline.pipelineUrl);
|
|
26154
|
-
throw new PipelineUrlError(
|
|
26154
|
+
throw new PipelineUrlError(_spaceTrim.spaceTrim(`
|
|
26155
26155
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍏
|
|
26156
26156
|
|
|
26157
26157
|
Conflicting files:
|
|
@@ -26169,7 +26169,7 @@
|
|
|
26169
26169
|
catch (error) {
|
|
26170
26170
|
assertsError(error);
|
|
26171
26171
|
// TODO: [7] DRY
|
|
26172
|
-
const wrappedErrorMessage =
|
|
26172
|
+
const wrappedErrorMessage = _spaceTrim.spaceTrim((block) => `
|
|
26173
26173
|
${error.name} in pipeline ${fileName.split('\\').join('/')}:
|
|
26174
26174
|
|
|
26175
26175
|
Original error message:
|
|
@@ -26227,7 +26227,7 @@
|
|
|
26227
26227
|
*/
|
|
26228
26228
|
function stringifyPipelineJson(pipeline) {
|
|
26229
26229
|
if (!isSerializableAsJson(pipeline)) {
|
|
26230
|
-
throw new UnexpectedError(
|
|
26230
|
+
throw new UnexpectedError(_spaceTrim.spaceTrim(`
|
|
26231
26231
|
Cannot stringify the pipeline, because it is not serializable as JSON
|
|
26232
26232
|
|
|
26233
26233
|
There can be multiple reasons:
|
|
@@ -26406,7 +26406,7 @@
|
|
|
26406
26406
|
* @deprecated Use `$generateBookBoilerplate` instead
|
|
26407
26407
|
* @public exported from `@promptbook/core`
|
|
26408
26408
|
*/
|
|
26409
|
-
padBook(validateBook(
|
|
26409
|
+
padBook(validateBook(_spaceTrim.spaceTrim(`
|
|
26410
26410
|
AI Avatar
|
|
26411
26411
|
|
|
26412
26412
|
PERSONA A friendly AI assistant that helps you with your tasks
|
|
@@ -26455,7 +26455,7 @@
|
|
|
26455
26455
|
const bookString = prompt(strings, ...values).toString();
|
|
26456
26456
|
if (!isValidPipelineString(bookString)) {
|
|
26457
26457
|
// TODO: Make the CustomError for this
|
|
26458
|
-
throw new Error(
|
|
26458
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
26459
26459
|
The string is not a valid pipeline string
|
|
26460
26460
|
|
|
26461
26461
|
book\`
|
|
@@ -26465,7 +26465,7 @@
|
|
|
26465
26465
|
}
|
|
26466
26466
|
if (!isValidBook(bookString)) {
|
|
26467
26467
|
// TODO: Make the CustomError for this
|
|
26468
|
-
throw new Error(
|
|
26468
|
+
throw new Error(_spaceTrim.spaceTrim(`
|
|
26469
26469
|
The string is not a valid book
|
|
26470
26470
|
|
|
26471
26471
|
book\`
|
|
@@ -26749,7 +26749,7 @@
|
|
|
26749
26749
|
* @public exported from `@promptbook/core`
|
|
26750
26750
|
*/
|
|
26751
26751
|
function normalizeAgentName(rawAgentName) {
|
|
26752
|
-
return titleToName(
|
|
26752
|
+
return titleToName(_spaceTrim.spaceTrim(rawAgentName));
|
|
26753
26753
|
}
|
|
26754
26754
|
|
|
26755
26755
|
/**
|
|
@@ -26906,7 +26906,7 @@
|
|
|
26906
26906
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
26907
26907
|
commitments.push({
|
|
26908
26908
|
type: currentCommitment.type,
|
|
26909
|
-
content:
|
|
26909
|
+
content: _spaceTrim.spaceTrim(fullContent),
|
|
26910
26910
|
originalLine: currentCommitment.originalStartLine,
|
|
26911
26911
|
lineNumber: currentCommitment.startLineNumber,
|
|
26912
26912
|
});
|
|
@@ -26934,7 +26934,7 @@
|
|
|
26934
26934
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
26935
26935
|
commitments.push({
|
|
26936
26936
|
type: currentCommitment.type,
|
|
26937
|
-
content:
|
|
26937
|
+
content: _spaceTrim.spaceTrim(fullContent),
|
|
26938
26938
|
originalLine: currentCommitment.originalStartLine,
|
|
26939
26939
|
lineNumber: currentCommitment.startLineNumber,
|
|
26940
26940
|
});
|
|
@@ -26960,7 +26960,7 @@
|
|
|
26960
26960
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
26961
26961
|
commitments.push({
|
|
26962
26962
|
type: currentCommitment.type,
|
|
26963
|
-
content:
|
|
26963
|
+
content: _spaceTrim.spaceTrim(fullContent),
|
|
26964
26964
|
originalLine: currentCommitment.originalStartLine,
|
|
26965
26965
|
lineNumber: currentCommitment.startLineNumber,
|
|
26966
26966
|
});
|
|
@@ -27193,7 +27193,7 @@
|
|
|
27193
27193
|
continue;
|
|
27194
27194
|
}
|
|
27195
27195
|
if (commitment.type === 'FROM') {
|
|
27196
|
-
const content =
|
|
27196
|
+
const content = _spaceTrim.spaceTrim(commitment.content).split(/\r?\n/)[0] || '';
|
|
27197
27197
|
if (content === 'Adam' || content === '' /* <- Note: Adam is implicit */) {
|
|
27198
27198
|
continue;
|
|
27199
27199
|
}
|
|
@@ -27216,7 +27216,7 @@
|
|
|
27216
27216
|
continue;
|
|
27217
27217
|
}
|
|
27218
27218
|
if (commitment.type === 'IMPORT') {
|
|
27219
|
-
const content =
|
|
27219
|
+
const content = _spaceTrim.spaceTrim(commitment.content).split(/\r?\n/)[0] || '';
|
|
27220
27220
|
let label = content;
|
|
27221
27221
|
let iconName = 'ExternalLink'; // Import remote
|
|
27222
27222
|
try {
|
|
@@ -27254,7 +27254,7 @@
|
|
|
27254
27254
|
continue;
|
|
27255
27255
|
}
|
|
27256
27256
|
if (commitment.type === 'KNOWLEDGE') {
|
|
27257
|
-
const content =
|
|
27257
|
+
const content = _spaceTrim.spaceTrim(commitment.content);
|
|
27258
27258
|
const extractedUrls = extractUrlsFromText(content);
|
|
27259
27259
|
let label = content;
|
|
27260
27260
|
let iconName = 'Book';
|
|
@@ -27313,7 +27313,7 @@
|
|
|
27313
27313
|
continue;
|
|
27314
27314
|
}
|
|
27315
27315
|
if (commitment.type === 'META LINK') {
|
|
27316
|
-
const linkValue =
|
|
27316
|
+
const linkValue = _spaceTrim.spaceTrim(commitment.content);
|
|
27317
27317
|
links.push(linkValue);
|
|
27318
27318
|
meta.link = linkValue;
|
|
27319
27319
|
continue;
|
|
@@ -27323,11 +27323,11 @@
|
|
|
27323
27323
|
continue;
|
|
27324
27324
|
}
|
|
27325
27325
|
if (commitment.type === 'META IMAGE') {
|
|
27326
|
-
meta.image =
|
|
27326
|
+
meta.image = _spaceTrim.spaceTrim(commitment.content);
|
|
27327
27327
|
continue;
|
|
27328
27328
|
}
|
|
27329
27329
|
if (commitment.type === 'META DESCRIPTION') {
|
|
27330
|
-
meta.description =
|
|
27330
|
+
meta.description = _spaceTrim.spaceTrim(commitment.content);
|
|
27331
27331
|
continue;
|
|
27332
27332
|
}
|
|
27333
27333
|
if (commitment.type === 'META DISCLAIMER') {
|
|
@@ -27335,7 +27335,7 @@
|
|
|
27335
27335
|
continue;
|
|
27336
27336
|
}
|
|
27337
27337
|
if (commitment.type === 'META INPUT PLACEHOLDER') {
|
|
27338
|
-
meta.inputPlaceholder =
|
|
27338
|
+
meta.inputPlaceholder = _spaceTrim.spaceTrim(commitment.content);
|
|
27339
27339
|
continue;
|
|
27340
27340
|
}
|
|
27341
27341
|
if (commitment.type === 'MESSAGE SUFFIX') {
|
|
@@ -27351,7 +27351,7 @@
|
|
|
27351
27351
|
continue;
|
|
27352
27352
|
}
|
|
27353
27353
|
if (commitment.type === 'META VOICE') {
|
|
27354
|
-
meta.voice =
|
|
27354
|
+
meta.voice = _spaceTrim.spaceTrim(commitment.content);
|
|
27355
27355
|
continue;
|
|
27356
27356
|
}
|
|
27357
27357
|
if (commitment.type !== 'META') {
|
|
@@ -27360,10 +27360,10 @@
|
|
|
27360
27360
|
// Parse META commitments - format is "META TYPE content"
|
|
27361
27361
|
const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
|
|
27362
27362
|
if (metaTypeRaw === 'LINK') {
|
|
27363
|
-
links.push(
|
|
27363
|
+
links.push(_spaceTrim.spaceTrim(commitment.content.substring(metaTypeRaw.length)));
|
|
27364
27364
|
}
|
|
27365
27365
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
27366
|
-
meta[metaType] =
|
|
27366
|
+
meta[metaType] = _spaceTrim.spaceTrim(commitment.content.substring(metaTypeRaw.length));
|
|
27367
27367
|
}
|
|
27368
27368
|
// Generate fullname fallback if no meta fullname specified
|
|
27369
27369
|
if (!meta.fullname) {
|
|
@@ -27394,7 +27394,7 @@
|
|
|
27394
27394
|
* @returns The content with normalized separators
|
|
27395
27395
|
*/
|
|
27396
27396
|
function normalizeSeparator(content) {
|
|
27397
|
-
const trimmed =
|
|
27397
|
+
const trimmed = _spaceTrim.spaceTrim(content);
|
|
27398
27398
|
if (trimmed.includes(',')) {
|
|
27399
27399
|
return trimmed;
|
|
27400
27400
|
}
|
|
@@ -27407,7 +27407,7 @@
|
|
|
27407
27407
|
* @returns Normalized domain or a trimmed fallback.
|
|
27408
27408
|
*/
|
|
27409
27409
|
function normalizeMetaDomain(content) {
|
|
27410
|
-
const trimmed =
|
|
27410
|
+
const trimmed = _spaceTrim.spaceTrim(content);
|
|
27411
27411
|
return normalizeDomainForMatching(trimmed) || trimmed.toLowerCase();
|
|
27412
27412
|
}
|
|
27413
27413
|
/**
|
|
@@ -27540,7 +27540,7 @@
|
|
|
27540
27540
|
.filter((c) => ['PERSONA', 'RULE', 'KNOWLEDGE'].includes(c.type))
|
|
27541
27541
|
.map((c) => `${c.type} ${c.content}`)
|
|
27542
27542
|
.join('\n\n');
|
|
27543
|
-
return
|
|
27543
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
27544
27544
|
${block(relevantCommitments)}
|
|
27545
27545
|
|
|
27546
27546
|
${block(corpus)}
|
|
@@ -28667,7 +28667,7 @@
|
|
|
28667
28667
|
/**
|
|
28668
28668
|
* List of available OpenAI models with pricing
|
|
28669
28669
|
*
|
|
28670
|
-
* Note: Synced with official API docs at
|
|
28670
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
28671
28671
|
*
|
|
28672
28672
|
* @see https://platform.openai.com/docs/models/
|
|
28673
28673
|
* @see https://openai.com/api/pricing/
|
|
@@ -28789,8 +28789,8 @@
|
|
|
28789
28789
|
modelName: 'gpt-4.1',
|
|
28790
28790
|
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.',
|
|
28791
28791
|
pricing: {
|
|
28792
|
-
prompt: pricing(`$
|
|
28793
|
-
output: pricing(`$
|
|
28792
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
28793
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
28794
28794
|
},
|
|
28795
28795
|
},
|
|
28796
28796
|
/**/
|
|
@@ -28801,8 +28801,8 @@
|
|
|
28801
28801
|
modelName: 'gpt-4.1-mini',
|
|
28802
28802
|
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.',
|
|
28803
28803
|
pricing: {
|
|
28804
|
-
prompt: pricing(`$0.
|
|
28805
|
-
output: pricing(`$
|
|
28804
|
+
prompt: pricing(`$0.40 / 1M tokens`),
|
|
28805
|
+
output: pricing(`$1.60 / 1M tokens`),
|
|
28806
28806
|
},
|
|
28807
28807
|
},
|
|
28808
28808
|
/**/
|
|
@@ -28813,8 +28813,8 @@
|
|
|
28813
28813
|
modelName: 'gpt-4.1-nano',
|
|
28814
28814
|
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.',
|
|
28815
28815
|
pricing: {
|
|
28816
|
-
prompt: pricing(`$0.
|
|
28817
|
-
output: pricing(`$0.
|
|
28816
|
+
prompt: pricing(`$0.10 / 1M tokens`),
|
|
28817
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
28818
28818
|
},
|
|
28819
28819
|
},
|
|
28820
28820
|
/**/
|
|
@@ -28825,8 +28825,8 @@
|
|
|
28825
28825
|
modelName: 'o3',
|
|
28826
28826
|
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.',
|
|
28827
28827
|
pricing: {
|
|
28828
|
-
prompt: pricing(`$
|
|
28829
|
-
output: pricing(`$
|
|
28828
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
28829
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
28830
28830
|
},
|
|
28831
28831
|
},
|
|
28832
28832
|
/**/
|
|
@@ -28837,8 +28837,8 @@
|
|
|
28837
28837
|
modelName: 'o3-pro',
|
|
28838
28838
|
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.',
|
|
28839
28839
|
pricing: {
|
|
28840
|
-
prompt: pricing(`$
|
|
28841
|
-
output: pricing(`$
|
|
28840
|
+
prompt: pricing(`$20.00 / 1M tokens`),
|
|
28841
|
+
output: pricing(`$80.00 / 1M tokens`),
|
|
28842
28842
|
},
|
|
28843
28843
|
},
|
|
28844
28844
|
/**/
|
|
@@ -28849,8 +28849,8 @@
|
|
|
28849
28849
|
modelName: 'o4-mini',
|
|
28850
28850
|
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.',
|
|
28851
28851
|
pricing: {
|
|
28852
|
-
prompt: pricing(`$
|
|
28853
|
-
output: pricing(`$
|
|
28852
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
28853
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
28854
28854
|
},
|
|
28855
28855
|
},
|
|
28856
28856
|
/**/
|
|
@@ -29208,8 +29208,8 @@
|
|
|
29208
29208
|
modelName: 'gpt-4o-2024-05-13',
|
|
29209
29209
|
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.',
|
|
29210
29210
|
pricing: {
|
|
29211
|
-
prompt: pricing(`$
|
|
29212
|
-
output: pricing(`$
|
|
29211
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
29212
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
29213
29213
|
},
|
|
29214
29214
|
},
|
|
29215
29215
|
/**/
|
|
@@ -29220,8 +29220,8 @@
|
|
|
29220
29220
|
modelName: 'gpt-4o',
|
|
29221
29221
|
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.",
|
|
29222
29222
|
pricing: {
|
|
29223
|
-
prompt: pricing(`$
|
|
29224
|
-
output: pricing(`$
|
|
29223
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
29224
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
29225
29225
|
},
|
|
29226
29226
|
},
|
|
29227
29227
|
/**/
|
|
@@ -29292,8 +29292,8 @@
|
|
|
29292
29292
|
modelName: 'o3-mini',
|
|
29293
29293
|
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.',
|
|
29294
29294
|
pricing: {
|
|
29295
|
-
prompt: pricing(`$
|
|
29296
|
-
output: pricing(`$
|
|
29295
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
29296
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
29297
29297
|
},
|
|
29298
29298
|
},
|
|
29299
29299
|
/**/
|
|
@@ -29393,53 +29393,6 @@
|
|
|
29393
29393
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
29394
29394
|
*/
|
|
29395
29395
|
|
|
29396
|
-
/**
|
|
29397
|
-
* Maps Promptbook tools to OpenAI tools.
|
|
29398
|
-
*
|
|
29399
|
-
* @private
|
|
29400
|
-
*/
|
|
29401
|
-
function mapToolsToOpenAi(tools) {
|
|
29402
|
-
return tools.map((tool) => ({
|
|
29403
|
-
type: 'function',
|
|
29404
|
-
function: {
|
|
29405
|
-
name: tool.name,
|
|
29406
|
-
description: tool.description,
|
|
29407
|
-
parameters: tool.parameters,
|
|
29408
|
-
},
|
|
29409
|
-
}));
|
|
29410
|
-
}
|
|
29411
|
-
|
|
29412
|
-
/**
|
|
29413
|
-
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
29414
|
-
*
|
|
29415
|
-
* @private utility of OpenAI tool execution wrappers
|
|
29416
|
-
*/
|
|
29417
|
-
function buildToolInvocationScript(options) {
|
|
29418
|
-
const { functionName, functionArgsExpression } = options;
|
|
29419
|
-
return `
|
|
29420
|
-
const args = ${functionArgsExpression};
|
|
29421
|
-
const runtimeContextRaw =
|
|
29422
|
-
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
29423
|
-
? undefined
|
|
29424
|
-
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
29425
|
-
|
|
29426
|
-
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
29427
|
-
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
29428
|
-
}
|
|
29429
|
-
|
|
29430
|
-
const toolProgressTokenRaw =
|
|
29431
|
-
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
29432
|
-
? undefined
|
|
29433
|
-
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
29434
|
-
|
|
29435
|
-
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
29436
|
-
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
29437
|
-
}
|
|
29438
|
-
|
|
29439
|
-
return await ${functionName}(args);
|
|
29440
|
-
`;
|
|
29441
|
-
}
|
|
29442
|
-
|
|
29443
29396
|
/**
|
|
29444
29397
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
29445
29398
|
*
|
|
@@ -29496,6 +29449,53 @@
|
|
|
29496
29449
|
errorMessage.includes('does not support'));
|
|
29497
29450
|
}
|
|
29498
29451
|
|
|
29452
|
+
/**
|
|
29453
|
+
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
29454
|
+
*
|
|
29455
|
+
* @private utility of OpenAI tool execution wrappers
|
|
29456
|
+
*/
|
|
29457
|
+
function buildToolInvocationScript(options) {
|
|
29458
|
+
const { functionName, functionArgsExpression } = options;
|
|
29459
|
+
return `
|
|
29460
|
+
const args = ${functionArgsExpression};
|
|
29461
|
+
const runtimeContextRaw =
|
|
29462
|
+
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
29463
|
+
? undefined
|
|
29464
|
+
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
29465
|
+
|
|
29466
|
+
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
29467
|
+
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
29468
|
+
}
|
|
29469
|
+
|
|
29470
|
+
const toolProgressTokenRaw =
|
|
29471
|
+
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
29472
|
+
? undefined
|
|
29473
|
+
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
29474
|
+
|
|
29475
|
+
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
29476
|
+
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
29477
|
+
}
|
|
29478
|
+
|
|
29479
|
+
return await ${functionName}(args);
|
|
29480
|
+
`;
|
|
29481
|
+
}
|
|
29482
|
+
|
|
29483
|
+
/**
|
|
29484
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
29485
|
+
*
|
|
29486
|
+
* @private
|
|
29487
|
+
*/
|
|
29488
|
+
function mapToolsToOpenAi(tools) {
|
|
29489
|
+
return tools.map((tool) => ({
|
|
29490
|
+
type: 'function',
|
|
29491
|
+
function: {
|
|
29492
|
+
name: tool.name,
|
|
29493
|
+
description: tool.description,
|
|
29494
|
+
parameters: tool.parameters,
|
|
29495
|
+
},
|
|
29496
|
+
}));
|
|
29497
|
+
}
|
|
29498
|
+
|
|
29499
29499
|
/**
|
|
29500
29500
|
* Provides access to the structured clone implementation when available.
|
|
29501
29501
|
*/
|
|
@@ -30462,7 +30462,7 @@
|
|
|
30462
30462
|
// Note: Match exact or prefix for model families
|
|
30463
30463
|
const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
|
|
30464
30464
|
if (model === undefined) {
|
|
30465
|
-
throw new PipelineExecutionError(
|
|
30465
|
+
throw new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
30466
30466
|
Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
|
|
30467
30467
|
|
|
30468
30468
|
Available models:
|
|
@@ -31388,7 +31388,7 @@
|
|
|
31388
31388
|
}
|
|
31389
31389
|
}
|
|
31390
31390
|
|
|
31391
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5-
|
|
31391
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
|
|
31392
31392
|
/**
|
|
31393
31393
|
* Creates one structured log entry for streamed tool-call updates.
|
|
31394
31394
|
*
|
|
@@ -31883,7 +31883,7 @@
|
|
|
31883
31883
|
}),
|
|
31884
31884
|
],
|
|
31885
31885
|
};
|
|
31886
|
-
const errorMessage =
|
|
31886
|
+
const errorMessage = _spaceTrim.spaceTrim((block) => `
|
|
31887
31887
|
|
|
31888
31888
|
The invoked tool \`${functionName}\` failed with error:
|
|
31889
31889
|
|
|
@@ -32601,7 +32601,7 @@
|
|
|
32601
32601
|
assertsError(error);
|
|
32602
32602
|
const serializedError = serializeError(error);
|
|
32603
32603
|
errors = [serializedError];
|
|
32604
|
-
functionResponse =
|
|
32604
|
+
functionResponse = _spaceTrim.spaceTrim((block) => `
|
|
32605
32605
|
|
|
32606
32606
|
The invoked tool \`${functionName}\` failed with error:
|
|
32607
32607
|
|
|
@@ -33540,7 +33540,7 @@
|
|
|
33540
33540
|
if (commitment.type !== 'OPEN') {
|
|
33541
33541
|
continue;
|
|
33542
33542
|
}
|
|
33543
|
-
const trimmed =
|
|
33543
|
+
const trimmed = _spaceTrim.spaceTrim(commitment.content);
|
|
33544
33544
|
return trimmed || null;
|
|
33545
33545
|
}
|
|
33546
33546
|
return null;
|
|
@@ -33609,7 +33609,7 @@
|
|
|
33609
33609
|
if (isJsonSchemaResponseFormat(responseFormat)) {
|
|
33610
33610
|
const jsonSchema = responseFormat.json_schema;
|
|
33611
33611
|
const schemaJson = JSON.stringify(jsonSchema, null, 4);
|
|
33612
|
-
userMessageContent =
|
|
33612
|
+
userMessageContent = _spaceTrim.spaceTrim((block) => `
|
|
33613
33613
|
${block(prompt.content)}
|
|
33614
33614
|
|
|
33615
33615
|
NOTE Request was made through OpenAI Compatible API with \`response_format\` of type \`json_schema\` with the following schema:
|
|
@@ -33640,12 +33640,12 @@
|
|
|
33640
33640
|
const formattedAgentMessage = formatAgentMessageForJsonMode(result.content, usesJsonSchemaMode);
|
|
33641
33641
|
const teacherInstructions = extractOpenTeacherInstructions(agentSource);
|
|
33642
33642
|
const teacherInstructionsSection = teacherInstructions
|
|
33643
|
-
?
|
|
33643
|
+
? _spaceTrim.spaceTrim((block) => `
|
|
33644
33644
|
**Teacher instructions:**
|
|
33645
33645
|
${block(teacherInstructions)}
|
|
33646
33646
|
`)
|
|
33647
33647
|
: '';
|
|
33648
|
-
const teacherPromptContent =
|
|
33648
|
+
const teacherPromptContent = _spaceTrim.spaceTrim((block) => `
|
|
33649
33649
|
|
|
33650
33650
|
You are a teacher agent helping another agent to learn from its interactions.
|
|
33651
33651
|
|
|
@@ -33678,7 +33678,7 @@
|
|
|
33678
33678
|
? '- This interaction used JSON mode, so the agent answer should stay as a formatted JSON code block.'
|
|
33679
33679
|
: ''}
|
|
33680
33680
|
${block(isInitialMessageMissing
|
|
33681
|
-
?
|
|
33681
|
+
? _spaceTrim.spaceTrim(`
|
|
33682
33682
|
- The agent source does not have an INITIAL MESSAGE defined, generate one.
|
|
33683
33683
|
- 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.
|
|
33684
33684
|
- The quick option looks like \`[👋 Hello](?message=Hello, how are you?)\`
|
|
@@ -33721,7 +33721,7 @@
|
|
|
33721
33721
|
*/
|
|
33722
33722
|
appendToAgentSource(section) {
|
|
33723
33723
|
const currentSource = this.options.getAgentSource();
|
|
33724
|
-
const newSource = padBook(validateBook(
|
|
33724
|
+
const newSource = padBook(validateBook(_spaceTrim.spaceTrim(currentSource) + section));
|
|
33725
33725
|
this.options.updateAgentSource(newSource);
|
|
33726
33726
|
}
|
|
33727
33727
|
}
|
|
@@ -33749,13 +33749,13 @@
|
|
|
33749
33749
|
}
|
|
33750
33750
|
const parsedJson = tryParseJson(content);
|
|
33751
33751
|
if (parsedJson === null) {
|
|
33752
|
-
return
|
|
33752
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
33753
33753
|
\`\`\`json
|
|
33754
33754
|
${block(content)}
|
|
33755
33755
|
\`\`\`
|
|
33756
33756
|
`);
|
|
33757
33757
|
}
|
|
33758
|
-
return
|
|
33758
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
33759
33759
|
\`\`\`json
|
|
33760
33760
|
${block(JSON.stringify(parsedJson, null, 4))}
|
|
33761
33761
|
\`\`\`
|
|
@@ -33787,7 +33787,7 @@
|
|
|
33787
33787
|
const internalMessagesSection = options.internalMessages
|
|
33788
33788
|
.map((internalMessage) => formatInternalLearningMessage(internalMessage))
|
|
33789
33789
|
.join('\n\n');
|
|
33790
|
-
return
|
|
33790
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
33791
33791
|
|
|
33792
33792
|
USER MESSAGE
|
|
33793
33793
|
${block(options.userMessageContent)}
|
|
@@ -33805,7 +33805,7 @@
|
|
|
33805
33805
|
* @private function of Agent
|
|
33806
33806
|
*/
|
|
33807
33807
|
function formatInternalLearningMessage(internalMessage) {
|
|
33808
|
-
return
|
|
33808
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
33809
33809
|
INTERNAL MESSAGE
|
|
33810
33810
|
${block(stringifyInternalLearningPayload(internalMessage))}
|
|
33811
33811
|
`);
|
|
@@ -34271,7 +34271,7 @@
|
|
|
34271
34271
|
.filter((line) => Boolean(line))
|
|
34272
34272
|
.join('\n');
|
|
34273
34273
|
const personaBlock = profile.personaDescription
|
|
34274
|
-
?
|
|
34274
|
+
? _spaceTrim.spaceTrim((block) => `
|
|
34275
34275
|
PERSONA
|
|
34276
34276
|
${block(profile.personaDescription || '')}
|
|
34277
34277
|
`)
|
|
@@ -34307,7 +34307,7 @@
|
|
|
34307
34307
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
34308
34308
|
// <- TODO: [🐱🚀] Maybe use promptbookFetch
|
|
34309
34309
|
if (!profileResponse.ok) {
|
|
34310
|
-
throw new Error(
|
|
34310
|
+
throw new Error(_spaceTrim.spaceTrim((block) => `
|
|
34311
34311
|
Failed to fetch remote agent profile:
|
|
34312
34312
|
|
|
34313
34313
|
Agent URL:
|