@promptbook/components 0.112.0-13 → 0.112.0-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +192 -192
- 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 +1 -1
- package/umd/index.umd.js +362 -363
- 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,12 +1,11 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('crypto'), require('mime-types'), require('moment'), require('react-dom'), require('@monaco-editor/react'), require('destroyable'), require('katex'), require('react-dom/client'), require('showdown'), require('rxjs'), require('jspdf'), require('lucide-react'), require('waitasecond'), require('crypto-js/sha256'), require('papaparse'), require('colors'), require('@openai/agents'), require('bottleneck'), require('openai'), require('leaflet/dist/leaflet.css'), require('qrcode')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'crypto', 'mime-types', 'moment', 'react-dom', '@monaco-editor/react', 'destroyable', 'katex', 'react-dom/client', 'showdown', 'rxjs', 'jspdf', 'lucide-react', 'waitasecond', 'crypto-js/sha256', 'papaparse', 'colors', '@openai/agents', 'bottleneck', 'openai', 'leaflet/dist/leaflet.css', 'qrcode'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.react, global.
|
|
5
|
-
})(this, (function (exports, jsxRuntime, react,
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.react, global.spacetrim, global.cryptoJs, global.hexEncoder, global.path, global.crypto$1, global.mimeTypes, global.moment, global.reactDom, global.MonacoEditor, global.destroyable, global.katex, global.client, global.showdown, global.rxjs, global.jspdf, global.lucideReact, global.waitasecond, global.sha256, global.papaparse, global.colors, global.agents, global.Bottleneck, global.OpenAI, null, global.QRCode));
|
|
5
|
+
})(this, (function (exports, jsxRuntime, react, spacetrim, cryptoJs, hexEncoder, path, crypto$1, mimeTypes, moment, reactDom, MonacoEditor, destroyable, katex, client, showdown, rxjs, jspdf, lucideReact, waitasecond, sha256, papaparse, colors, agents, Bottleneck, OpenAI, leaflet_css, QRCode) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
|
|
10
9
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
11
10
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
12
11
|
var MonacoEditor__default = /*#__PURE__*/_interopDefaultLegacy(MonacoEditor);
|
|
@@ -31,7 +30,7 @@
|
|
|
31
30
|
* @generated
|
|
32
31
|
* @see https://github.com/webgptorg/promptbook
|
|
33
32
|
*/
|
|
34
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-16';
|
|
35
34
|
/**
|
|
36
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
37
36
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -260,7 +259,7 @@
|
|
|
260
259
|
* @private internal utility of USE PROJECT commitment
|
|
261
260
|
*/
|
|
262
261
|
function parseUseProjectCommitmentContent(content) {
|
|
263
|
-
const trimmedContent =
|
|
262
|
+
const trimmedContent = spacetrim.spaceTrim(content);
|
|
264
263
|
if (!trimmedContent) {
|
|
265
264
|
return {
|
|
266
265
|
repository: null,
|
|
@@ -437,42 +436,6 @@
|
|
|
437
436
|
* TODO: [🌺] Use some intermediate util splitWords
|
|
438
437
|
*/
|
|
439
438
|
|
|
440
|
-
/**
|
|
441
|
-
* Normalizes a domain-like string into a comparable hostname form.
|
|
442
|
-
*
|
|
443
|
-
* The returned value is lowercased and stripped to hostname only
|
|
444
|
-
* (protocol, path, query, hash, and port are removed).
|
|
445
|
-
*
|
|
446
|
-
* @param rawDomain - Raw domain value (for example `my-agent.com` or `https://my-agent.com/path`).
|
|
447
|
-
* @returns Normalized hostname or `null` when the value cannot be normalized.
|
|
448
|
-
* @private utility for host/domain matching
|
|
449
|
-
*/
|
|
450
|
-
function normalizeDomainForMatching(rawDomain) {
|
|
451
|
-
const trimmedDomain = rawDomain.trim();
|
|
452
|
-
if (!trimmedDomain) {
|
|
453
|
-
return null;
|
|
454
|
-
}
|
|
455
|
-
const candidateUrl = hasHttpProtocol(trimmedDomain) ? trimmedDomain : `https://${trimmedDomain}`;
|
|
456
|
-
try {
|
|
457
|
-
const parsedUrl = new URL(candidateUrl);
|
|
458
|
-
const normalizedHostname = parsedUrl.hostname.trim().toLowerCase();
|
|
459
|
-
return normalizedHostname || null;
|
|
460
|
-
}
|
|
461
|
-
catch (_a) {
|
|
462
|
-
return null;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Checks whether the value already includes an HTTP(S) protocol prefix.
|
|
467
|
-
*
|
|
468
|
-
* @param value - Raw value to inspect.
|
|
469
|
-
* @returns True when the value starts with `http://` or `https://`.
|
|
470
|
-
* @private utility for host/domain matching
|
|
471
|
-
*/
|
|
472
|
-
function hasHttpProtocol(value) {
|
|
473
|
-
return value.startsWith('http://') || value.startsWith('https://');
|
|
474
|
-
}
|
|
475
|
-
|
|
476
439
|
/**
|
|
477
440
|
* Tests if given string is valid URL.
|
|
478
441
|
*
|
|
@@ -589,6 +552,42 @@
|
|
|
589
552
|
return count;
|
|
590
553
|
}
|
|
591
554
|
|
|
555
|
+
/**
|
|
556
|
+
* Normalizes a domain-like string into a comparable hostname form.
|
|
557
|
+
*
|
|
558
|
+
* The returned value is lowercased and stripped to hostname only
|
|
559
|
+
* (protocol, path, query, hash, and port are removed).
|
|
560
|
+
*
|
|
561
|
+
* @param rawDomain - Raw domain value (for example `my-agent.com` or `https://my-agent.com/path`).
|
|
562
|
+
* @returns Normalized hostname or `null` when the value cannot be normalized.
|
|
563
|
+
* @private utility for host/domain matching
|
|
564
|
+
*/
|
|
565
|
+
function normalizeDomainForMatching(rawDomain) {
|
|
566
|
+
const trimmedDomain = rawDomain.trim();
|
|
567
|
+
if (!trimmedDomain) {
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
const candidateUrl = hasHttpProtocol(trimmedDomain) ? trimmedDomain : `https://${trimmedDomain}`;
|
|
571
|
+
try {
|
|
572
|
+
const parsedUrl = new URL(candidateUrl);
|
|
573
|
+
const normalizedHostname = parsedUrl.hostname.trim().toLowerCase();
|
|
574
|
+
return normalizedHostname || null;
|
|
575
|
+
}
|
|
576
|
+
catch (_a) {
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Checks whether the value already includes an HTTP(S) protocol prefix.
|
|
582
|
+
*
|
|
583
|
+
* @param value - Raw value to inspect.
|
|
584
|
+
* @returns True when the value starts with `http://` or `https://`.
|
|
585
|
+
* @private utility for host/domain matching
|
|
586
|
+
*/
|
|
587
|
+
function hasHttpProtocol(value) {
|
|
588
|
+
return value.startsWith('http://') || value.startsWith('https://');
|
|
589
|
+
}
|
|
590
|
+
|
|
592
591
|
/**
|
|
593
592
|
* Trims string from all 4 sides
|
|
594
593
|
*
|
|
@@ -598,7 +597,7 @@
|
|
|
598
597
|
* @public exported from `@promptbook/utils`
|
|
599
598
|
* @see https://github.com/hejny/spacetrim#usage
|
|
600
599
|
*/
|
|
601
|
-
const spaceTrim =
|
|
600
|
+
const spaceTrim = spacetrim.spaceTrim;
|
|
602
601
|
|
|
603
602
|
/**
|
|
604
603
|
* Just marks a place of place where should be something implemented
|
|
@@ -1787,7 +1786,7 @@
|
|
|
1787
1786
|
function getErrorReportUrl(error) {
|
|
1788
1787
|
const report = {
|
|
1789
1788
|
title: `🐜 Error report from ${NAME}`,
|
|
1790
|
-
body:
|
|
1789
|
+
body: spacetrim.spaceTrim((block) => `
|
|
1791
1790
|
|
|
1792
1791
|
|
|
1793
1792
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1830,7 +1829,7 @@
|
|
|
1830
1829
|
*/
|
|
1831
1830
|
class UnexpectedError extends Error {
|
|
1832
1831
|
constructor(message) {
|
|
1833
|
-
super(
|
|
1832
|
+
super(spacetrim.spaceTrim((block) => `
|
|
1834
1833
|
${block(message)}
|
|
1835
1834
|
|
|
1836
1835
|
Note: This error should not happen.
|
|
@@ -1856,7 +1855,7 @@
|
|
|
1856
1855
|
constructor(whatWasThrown) {
|
|
1857
1856
|
const tag = `[🤮]`;
|
|
1858
1857
|
console.error(tag, whatWasThrown);
|
|
1859
|
-
super(
|
|
1858
|
+
super(spacetrim.spaceTrim(`
|
|
1860
1859
|
Non-Error object was thrown
|
|
1861
1860
|
|
|
1862
1861
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1982,7 +1981,7 @@
|
|
|
1982
1981
|
* @public exported from `@promptbook/utils`
|
|
1983
1982
|
*/
|
|
1984
1983
|
function computeHash(value) {
|
|
1985
|
-
return cryptoJs.SHA256(hexEncoder__default["default"].parse(
|
|
1984
|
+
return cryptoJs.SHA256(hexEncoder__default["default"].parse(spacetrim.spaceTrim(valueToString(value)))).toString( /* hex */);
|
|
1986
1985
|
}
|
|
1987
1986
|
/**
|
|
1988
1987
|
* TODO: [🥬][🥬] Use this ACRY
|
|
@@ -2089,7 +2088,7 @@
|
|
|
2089
2088
|
}
|
|
2090
2089
|
else if (typeof value === 'object') {
|
|
2091
2090
|
if (value instanceof Date) {
|
|
2092
|
-
throw new UnexpectedError(
|
|
2091
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2093
2092
|
\`${name}\` is Date
|
|
2094
2093
|
|
|
2095
2094
|
Use \`string_date_iso8601\` instead
|
|
@@ -2108,7 +2107,7 @@
|
|
|
2108
2107
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2109
2108
|
}
|
|
2110
2109
|
else if (value instanceof Error) {
|
|
2111
|
-
throw new UnexpectedError(
|
|
2110
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2112
2111
|
\`${name}\` is unserialized Error
|
|
2113
2112
|
|
|
2114
2113
|
Use function \`serializeError\`
|
|
@@ -2131,7 +2130,7 @@
|
|
|
2131
2130
|
}
|
|
2132
2131
|
catch (error) {
|
|
2133
2132
|
assertsError(error);
|
|
2134
|
-
throw new UnexpectedError(
|
|
2133
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2135
2134
|
\`${name}\` is not serializable
|
|
2136
2135
|
|
|
2137
2136
|
${block(error.stack || error.message)}
|
|
@@ -2163,7 +2162,7 @@
|
|
|
2163
2162
|
}
|
|
2164
2163
|
}
|
|
2165
2164
|
else {
|
|
2166
|
-
throw new UnexpectedError(
|
|
2165
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2167
2166
|
\`${name}\` is unknown type
|
|
2168
2167
|
|
|
2169
2168
|
Additional message for \`${name}\`:
|
|
@@ -2935,7 +2934,7 @@
|
|
|
2935
2934
|
*/
|
|
2936
2935
|
class MissingToolsError extends Error {
|
|
2937
2936
|
constructor(message) {
|
|
2938
|
-
super(
|
|
2937
|
+
super(spacetrim.spaceTrim((block) => `
|
|
2939
2938
|
${block(message)}
|
|
2940
2939
|
|
|
2941
2940
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -2979,7 +2978,7 @@
|
|
|
2979
2978
|
*/
|
|
2980
2979
|
class NotYetImplementedError extends Error {
|
|
2981
2980
|
constructor(message) {
|
|
2982
|
-
super(
|
|
2981
|
+
super(spacetrim.spaceTrim((block) => `
|
|
2983
2982
|
${block(message)}
|
|
2984
2983
|
|
|
2985
2984
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -3165,7 +3164,7 @@
|
|
|
3165
3164
|
message = `${name}: ${message}`;
|
|
3166
3165
|
}
|
|
3167
3166
|
if (isStackAddedToMessage && stack !== undefined && stack !== '') {
|
|
3168
|
-
message =
|
|
3167
|
+
message = spacetrim.spaceTrim((block) => `
|
|
3169
3168
|
${block(message)}
|
|
3170
3169
|
|
|
3171
3170
|
Original stack trace:
|
|
@@ -3186,7 +3185,7 @@
|
|
|
3186
3185
|
const { name, message, stack } = error;
|
|
3187
3186
|
const { id } = error;
|
|
3188
3187
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3189
|
-
console.error(
|
|
3188
|
+
console.error(spacetrim.spaceTrim((block) => `
|
|
3190
3189
|
|
|
3191
3190
|
Cannot serialize error with name "${name}"
|
|
3192
3191
|
|
|
@@ -3292,7 +3291,7 @@
|
|
|
3292
3291
|
}
|
|
3293
3292
|
else if (typeof value !== 'string') {
|
|
3294
3293
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
3295
|
-
throw new Error(
|
|
3294
|
+
throw new Error(spacetrim.spaceTrim(`
|
|
3296
3295
|
Can not parse JSON from non-string value.
|
|
3297
3296
|
|
|
3298
3297
|
The value type: ${typeof value}
|
|
@@ -3306,7 +3305,7 @@
|
|
|
3306
3305
|
if (!(error instanceof Error)) {
|
|
3307
3306
|
throw error;
|
|
3308
3307
|
}
|
|
3309
|
-
throw new Error(
|
|
3308
|
+
throw new Error(spacetrim.spaceTrim((block) => `
|
|
3310
3309
|
${block(error.message)}
|
|
3311
3310
|
|
|
3312
3311
|
The expected JSON text:
|
|
@@ -3666,7 +3665,7 @@
|
|
|
3666
3665
|
const entries = items
|
|
3667
3666
|
.flatMap((item) => formatParameterListItem(item).split(/\r?\n/))
|
|
3668
3667
|
.filter((line) => line !== '');
|
|
3669
|
-
return
|
|
3668
|
+
return spacetrim.spaceTrim((block) => `
|
|
3670
3669
|
**Parameters:**
|
|
3671
3670
|
${block(entries.join('\n'))}
|
|
3672
3671
|
|
|
@@ -3739,7 +3738,7 @@
|
|
|
3739
3738
|
*/
|
|
3740
3739
|
function prompt(strings, ...values) {
|
|
3741
3740
|
if (values.length === 0) {
|
|
3742
|
-
return new PromptString(
|
|
3741
|
+
return new PromptString(spacetrim.spaceTrim(strings.join('')));
|
|
3743
3742
|
}
|
|
3744
3743
|
const stringsWithHiddenParameters = strings.map((stringsItem) => ParameterEscaping.hideBrackets(stringsItem));
|
|
3745
3744
|
const parameterMetadata = values.map((value) => {
|
|
@@ -3780,7 +3779,7 @@
|
|
|
3780
3779
|
? `${result}${stringsItem}`
|
|
3781
3780
|
: `${result}${stringsItem}${ParameterSection.formatParameterPlaceholder(parameterName)}`;
|
|
3782
3781
|
}, '');
|
|
3783
|
-
pipelineString =
|
|
3782
|
+
pipelineString = spacetrim.spaceTrim(pipelineString);
|
|
3784
3783
|
try {
|
|
3785
3784
|
pipelineString = templateParameters(pipelineString, parameters);
|
|
3786
3785
|
}
|
|
@@ -3789,7 +3788,7 @@
|
|
|
3789
3788
|
throw error;
|
|
3790
3789
|
}
|
|
3791
3790
|
console.error({ pipelineString, parameters, parameterNames: parameterNamesOrdered, error });
|
|
3792
|
-
throw new UnexpectedError(
|
|
3791
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
3793
3792
|
Internal error in prompt template literal
|
|
3794
3793
|
|
|
3795
3794
|
${block(JSON.stringify({ strings, values }, null, 4))}}
|
|
@@ -5698,7 +5697,7 @@
|
|
|
5698
5697
|
* @public exported from `@promptbook/utils`
|
|
5699
5698
|
*/
|
|
5700
5699
|
function normalizeMessageText(text) {
|
|
5701
|
-
return
|
|
5700
|
+
return spacetrim.spaceTrim(text);
|
|
5702
5701
|
}
|
|
5703
5702
|
|
|
5704
5703
|
/**
|
|
@@ -5760,7 +5759,7 @@
|
|
|
5760
5759
|
let trimmedText = text;
|
|
5761
5760
|
// Remove leading and trailing spaces and newlines
|
|
5762
5761
|
if (isTrimmed) {
|
|
5763
|
-
trimmedText =
|
|
5762
|
+
trimmedText = spacetrim.spaceTrim(trimmedText);
|
|
5764
5763
|
}
|
|
5765
5764
|
let processedText = trimmedText;
|
|
5766
5765
|
// Check for markdown code block
|
|
@@ -5779,7 +5778,7 @@
|
|
|
5779
5778
|
// Remove the introduce sentence and quotes by replacing it with an empty string
|
|
5780
5779
|
processedText = processedText.replace(introduceSentenceRegex, '');
|
|
5781
5780
|
}
|
|
5782
|
-
processedText =
|
|
5781
|
+
processedText = spacetrim.spaceTrim(processedText);
|
|
5783
5782
|
// Check again for code block after removing introduce sentence
|
|
5784
5783
|
const codeBlockMatch2 = processedText.match(codeBlockRegex);
|
|
5785
5784
|
if (codeBlockMatch2 && codeBlockMatch2[1] !== undefined) {
|
|
@@ -5902,7 +5901,7 @@
|
|
|
5902
5901
|
imports.push(`import { Color } from '@promptbook/color';`);
|
|
5903
5902
|
}
|
|
5904
5903
|
else if (typeof value === 'string') {
|
|
5905
|
-
const trimmed =
|
|
5904
|
+
const trimmed = spacetrim.spaceTrim(value);
|
|
5906
5905
|
if (trimmed.includes('\n')) {
|
|
5907
5906
|
// Multiline string -> use `spaceTrim`
|
|
5908
5907
|
serializedValue = `spaceTrim(\`\n${value.replace(/`/g, '\\`')}\n\`)`;
|
|
@@ -6159,7 +6158,7 @@
|
|
|
6159
6158
|
* @public exported from `@promptbook/core`
|
|
6160
6159
|
*/
|
|
6161
6160
|
function normalizeAgentName(rawAgentName) {
|
|
6162
|
-
return titleToName(
|
|
6161
|
+
return titleToName(spacetrim.spaceTrim(rawAgentName));
|
|
6163
6162
|
}
|
|
6164
6163
|
|
|
6165
6164
|
/**
|
|
@@ -6381,7 +6380,7 @@
|
|
|
6381
6380
|
* Markdown documentation for ACTION commitment.
|
|
6382
6381
|
*/
|
|
6383
6382
|
get documentation() {
|
|
6384
|
-
return
|
|
6383
|
+
return spacetrim.spaceTrim(`
|
|
6385
6384
|
# ${this.type}
|
|
6386
6385
|
|
|
6387
6386
|
Defines specific actions or capabilities that the agent can perform.
|
|
@@ -6485,7 +6484,7 @@
|
|
|
6485
6484
|
* Markdown documentation for CLOSED commitment.
|
|
6486
6485
|
*/
|
|
6487
6486
|
get documentation() {
|
|
6488
|
-
return
|
|
6487
|
+
return spacetrim.spaceTrim(`
|
|
6489
6488
|
# CLOSED
|
|
6490
6489
|
|
|
6491
6490
|
Specifies that the agent **cannot** be modified by conversation with it.
|
|
@@ -6540,7 +6539,7 @@
|
|
|
6540
6539
|
* Markdown documentation for COMPONENT commitment.
|
|
6541
6540
|
*/
|
|
6542
6541
|
get documentation() {
|
|
6543
|
-
return
|
|
6542
|
+
return spacetrim.spaceTrim(`
|
|
6544
6543
|
# COMPONENT
|
|
6545
6544
|
|
|
6546
6545
|
Defines a UI component that the agent can render in the chat.
|
|
@@ -6612,7 +6611,7 @@
|
|
|
6612
6611
|
* Markdown documentation for DELETE commitment.
|
|
6613
6612
|
*/
|
|
6614
6613
|
get documentation() {
|
|
6615
|
-
return
|
|
6614
|
+
return spacetrim.spaceTrim(`
|
|
6616
6615
|
# DELETE (CANCEL, DISCARD, REMOVE)
|
|
6617
6616
|
|
|
6618
6617
|
A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
|
|
@@ -6743,7 +6742,7 @@
|
|
|
6743
6742
|
* Markdown documentation for DICTIONARY commitment.
|
|
6744
6743
|
*/
|
|
6745
6744
|
get documentation() {
|
|
6746
|
-
return
|
|
6745
|
+
return spacetrim.spaceTrim(`
|
|
6747
6746
|
# DICTIONARY
|
|
6748
6747
|
|
|
6749
6748
|
Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
|
|
@@ -6840,7 +6839,7 @@
|
|
|
6840
6839
|
* Markdown documentation for FORMAT commitment.
|
|
6841
6840
|
*/
|
|
6842
6841
|
get documentation() {
|
|
6843
|
-
return
|
|
6842
|
+
return spacetrim.spaceTrim(`
|
|
6844
6843
|
# ${this.type}
|
|
6845
6844
|
|
|
6846
6845
|
Defines the specific output structure and formatting for responses (data formats, templates, structure).
|
|
@@ -7146,7 +7145,7 @@
|
|
|
7146
7145
|
* Markdown documentation for FROM commitment.
|
|
7147
7146
|
*/
|
|
7148
7147
|
get documentation() {
|
|
7149
|
-
return
|
|
7148
|
+
return spacetrim.spaceTrim(`
|
|
7150
7149
|
# ${this.type}
|
|
7151
7150
|
|
|
7152
7151
|
Inherits agent source from another agent.
|
|
@@ -7173,7 +7172,7 @@
|
|
|
7173
7172
|
};
|
|
7174
7173
|
}
|
|
7175
7174
|
if (!isValidAgentUrl(trimmedContent)) {
|
|
7176
|
-
throw new Error(
|
|
7175
|
+
throw new Error(spacetrim.spaceTrim((block) => `
|
|
7177
7176
|
Invalid agent URL in FROM commitment: "${trimmedContent}"
|
|
7178
7177
|
|
|
7179
7178
|
\`\`\`book
|
|
@@ -7230,7 +7229,7 @@
|
|
|
7230
7229
|
* Markdown documentation for GOAL commitment.
|
|
7231
7230
|
*/
|
|
7232
7231
|
get documentation() {
|
|
7233
|
-
return
|
|
7232
|
+
return spacetrim.spaceTrim(`
|
|
7234
7233
|
# ${this.type}
|
|
7235
7234
|
|
|
7236
7235
|
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.
|
|
@@ -7327,7 +7326,7 @@
|
|
|
7327
7326
|
* Markdown documentation for IMPORT commitment.
|
|
7328
7327
|
*/
|
|
7329
7328
|
get documentation() {
|
|
7330
|
-
return
|
|
7329
|
+
return spacetrim.spaceTrim(`
|
|
7331
7330
|
# ${this.type}
|
|
7332
7331
|
|
|
7333
7332
|
Imports content from another agent or a generic text file at the location of the commitment.
|
|
@@ -7362,7 +7361,7 @@
|
|
|
7362
7361
|
importedFileUrls: [...(requirements.importedFileUrls || []), trimmedContent],
|
|
7363
7362
|
};
|
|
7364
7363
|
}
|
|
7365
|
-
throw new Error(
|
|
7364
|
+
throw new Error(spacetrim.spaceTrim((block) => `
|
|
7366
7365
|
Invalid agent URL or file path in IMPORT commitment: "${trimmedContent}"
|
|
7367
7366
|
|
|
7368
7367
|
\`\`\`book
|
|
@@ -7531,7 +7530,7 @@
|
|
|
7531
7530
|
* Markdown documentation for KNOWLEDGE commitment.
|
|
7532
7531
|
*/
|
|
7533
7532
|
get documentation() {
|
|
7534
|
-
return
|
|
7533
|
+
return spacetrim.spaceTrim(`
|
|
7535
7534
|
# ${this.type}
|
|
7536
7535
|
|
|
7537
7536
|
Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
|
|
@@ -7659,7 +7658,7 @@
|
|
|
7659
7658
|
* Markdown documentation for LANGUAGE/LANGUAGES commitment.
|
|
7660
7659
|
*/
|
|
7661
7660
|
get documentation() {
|
|
7662
|
-
return
|
|
7661
|
+
return spacetrim.spaceTrim(`
|
|
7663
7662
|
# ${this.type}
|
|
7664
7663
|
|
|
7665
7664
|
Specifies the language(s) the agent should use in its responses.
|
|
@@ -7688,7 +7687,7 @@
|
|
|
7688
7687
|
return requirements;
|
|
7689
7688
|
}
|
|
7690
7689
|
// Add language rule to the system message
|
|
7691
|
-
const languageSection = this.createSystemMessageSection('Language:',
|
|
7690
|
+
const languageSection = this.createSystemMessageSection('Language:', spacetrim.spaceTrim((block) => `
|
|
7692
7691
|
${block(trimmedContent)}
|
|
7693
7692
|
<- You are speaking these languages in your responses to the user.
|
|
7694
7693
|
`));
|
|
@@ -7705,11 +7704,11 @@
|
|
|
7705
7704
|
* @private utility for commitments
|
|
7706
7705
|
*/
|
|
7707
7706
|
function formatOptionalInstructionBlock(label, content) {
|
|
7708
|
-
const trimmedContent =
|
|
7707
|
+
const trimmedContent = spacetrim.spaceTrim(content);
|
|
7709
7708
|
if (!trimmedContent) {
|
|
7710
7709
|
return '';
|
|
7711
7710
|
}
|
|
7712
|
-
return
|
|
7711
|
+
return spacetrim.spaceTrim((block) => `
|
|
7713
7712
|
- ${label}:
|
|
7714
7713
|
${block(trimmedContent
|
|
7715
7714
|
.split(/\r?\n/)
|
|
@@ -7736,7 +7735,7 @@
|
|
|
7736
7735
|
* @private function of MemoryCommitmentDefinition
|
|
7737
7736
|
*/
|
|
7738
7737
|
function createMemorySystemMessage(extraInstructions) {
|
|
7739
|
-
return
|
|
7738
|
+
return spacetrim.spaceTrim((block) => `
|
|
7740
7739
|
Memory:
|
|
7741
7740
|
- Prefer storing agent-scoped memories; only make them global when the fact should apply across all your agents.
|
|
7742
7741
|
- You can use persistent user memory tools.
|
|
@@ -8126,7 +8125,7 @@
|
|
|
8126
8125
|
if (!tools.some((tool) => tool.name === MemoryToolNames.retrieve)) {
|
|
8127
8126
|
tools.push({
|
|
8128
8127
|
name: MemoryToolNames.retrieve,
|
|
8129
|
-
description:
|
|
8128
|
+
description: spacetrim.spaceTrim(`
|
|
8130
8129
|
Retrieve previously stored user memories relevant to the current conversation.
|
|
8131
8130
|
Use this before responding when user context can improve the answer.
|
|
8132
8131
|
`),
|
|
@@ -8148,7 +8147,7 @@
|
|
|
8148
8147
|
if (!tools.some((tool) => tool.name === MemoryToolNames.store)) {
|
|
8149
8148
|
tools.push({
|
|
8150
8149
|
name: MemoryToolNames.store,
|
|
8151
|
-
description:
|
|
8150
|
+
description: spacetrim.spaceTrim(`
|
|
8152
8151
|
Store a durable user memory that should be remembered in future conversations.
|
|
8153
8152
|
Store only stable and useful user-specific facts or preferences.
|
|
8154
8153
|
`),
|
|
@@ -8171,7 +8170,7 @@
|
|
|
8171
8170
|
if (!tools.some((tool) => tool.name === MemoryToolNames.update)) {
|
|
8172
8171
|
tools.push({
|
|
8173
8172
|
name: MemoryToolNames.update,
|
|
8174
|
-
description:
|
|
8173
|
+
description: spacetrim.spaceTrim(`
|
|
8175
8174
|
Update an existing user memory after retrieving it, so the stored fact stays accurate.
|
|
8176
8175
|
Always pass the memory id you retrieved along with the new content.
|
|
8177
8176
|
`),
|
|
@@ -8198,7 +8197,7 @@
|
|
|
8198
8197
|
if (!tools.some((tool) => tool.name === MemoryToolNames.delete)) {
|
|
8199
8198
|
tools.push({
|
|
8200
8199
|
name: MemoryToolNames.delete,
|
|
8201
|
-
description:
|
|
8200
|
+
description: spacetrim.spaceTrim(`
|
|
8202
8201
|
Delete a user memory that is no longer relevant. Deletions are soft so the record is hidden from future queries.
|
|
8203
8202
|
`),
|
|
8204
8203
|
parameters: {
|
|
@@ -8222,7 +8221,7 @@
|
|
|
8222
8221
|
* @private function of MemoryCommitmentDefinition
|
|
8223
8222
|
*/
|
|
8224
8223
|
function getMemoryCommitmentDocumentation(type) {
|
|
8225
|
-
return
|
|
8224
|
+
return spacetrim.spaceTrim(`
|
|
8226
8225
|
# ${type}
|
|
8227
8226
|
|
|
8228
8227
|
Enables persistent user memory for the current agent. The memory is stored by the runtime and can be retrieved in future conversations.
|
|
@@ -8381,7 +8380,7 @@
|
|
|
8381
8380
|
* Markdown documentation for AGENT MESSAGE commitment.
|
|
8382
8381
|
*/
|
|
8383
8382
|
get documentation() {
|
|
8384
|
-
return
|
|
8383
|
+
return spacetrim.spaceTrim(`
|
|
8385
8384
|
# ${this.type}
|
|
8386
8385
|
|
|
8387
8386
|
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.
|
|
@@ -8458,7 +8457,7 @@
|
|
|
8458
8457
|
* Markdown documentation for INITIAL MESSAGE commitment.
|
|
8459
8458
|
*/
|
|
8460
8459
|
get documentation() {
|
|
8461
|
-
return
|
|
8460
|
+
return spacetrim.spaceTrim(`
|
|
8462
8461
|
# ${this.type}
|
|
8463
8462
|
|
|
8464
8463
|
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).
|
|
@@ -8525,7 +8524,7 @@
|
|
|
8525
8524
|
* Markdown documentation for INTERNAL MESSAGE commitment.
|
|
8526
8525
|
*/
|
|
8527
8526
|
get documentation() {
|
|
8528
|
-
return
|
|
8527
|
+
return spacetrim.spaceTrim(`
|
|
8529
8528
|
# ${this.type}
|
|
8530
8529
|
|
|
8531
8530
|
Defines an internal trace message related to one interaction. This is intended mainly for self-learning analytics and future training datasets.
|
|
@@ -8601,7 +8600,7 @@
|
|
|
8601
8600
|
* Markdown documentation for MESSAGE commitment.
|
|
8602
8601
|
*/
|
|
8603
8602
|
get documentation() {
|
|
8604
|
-
return
|
|
8603
|
+
return spacetrim.spaceTrim(`
|
|
8605
8604
|
# ${this.type}
|
|
8606
8605
|
|
|
8607
8606
|
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.
|
|
@@ -8713,7 +8712,7 @@
|
|
|
8713
8712
|
* Markdown documentation for USER MESSAGE commitment.
|
|
8714
8713
|
*/
|
|
8715
8714
|
get documentation() {
|
|
8716
|
-
return
|
|
8715
|
+
return spacetrim.spaceTrim(`
|
|
8717
8716
|
# ${this.type}
|
|
8718
8717
|
|
|
8719
8718
|
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.
|
|
@@ -8780,7 +8779,7 @@
|
|
|
8780
8779
|
* Markdown documentation for MESSAGE SUFFIX commitment.
|
|
8781
8780
|
*/
|
|
8782
8781
|
get documentation() {
|
|
8783
|
-
return
|
|
8782
|
+
return spacetrim.spaceTrim(`
|
|
8784
8783
|
# MESSAGE SUFFIX
|
|
8785
8784
|
|
|
8786
8785
|
Defines a hardcoded message appended to every assistant response.
|
|
@@ -8862,7 +8861,7 @@
|
|
|
8862
8861
|
* Markdown documentation for META commitment.
|
|
8863
8862
|
*/
|
|
8864
8863
|
get documentation() {
|
|
8865
|
-
return
|
|
8864
|
+
return spacetrim.spaceTrim(`
|
|
8866
8865
|
# META
|
|
8867
8866
|
|
|
8868
8867
|
Sets meta-information about the agent that is used for display and attribution purposes.
|
|
@@ -9003,7 +9002,7 @@
|
|
|
9003
9002
|
* Markdown documentation for META COLOR commitment.
|
|
9004
9003
|
*/
|
|
9005
9004
|
get documentation() {
|
|
9006
|
-
return
|
|
9005
|
+
return spacetrim.spaceTrim(`
|
|
9007
9006
|
# META COLOR
|
|
9008
9007
|
|
|
9009
9008
|
Sets the agent's accent color or gradient.
|
|
@@ -9087,7 +9086,7 @@
|
|
|
9087
9086
|
* Markdown documentation for META DOMAIN commitment.
|
|
9088
9087
|
*/
|
|
9089
9088
|
get documentation() {
|
|
9090
|
-
return
|
|
9089
|
+
return spacetrim.spaceTrim(`
|
|
9091
9090
|
# META DOMAIN
|
|
9092
9091
|
|
|
9093
9092
|
Sets the canonical domain (host) of the agent, for example a custom domain that should open this agent directly.
|
|
@@ -9162,7 +9161,7 @@
|
|
|
9162
9161
|
* Markdown documentation for META DISCLAIMER commitment.
|
|
9163
9162
|
*/
|
|
9164
9163
|
get documentation() {
|
|
9165
|
-
return
|
|
9164
|
+
return spacetrim.spaceTrim(`
|
|
9166
9165
|
# META DISCLAIMER
|
|
9167
9166
|
|
|
9168
9167
|
Defines a markdown disclaimer shown to users before they can start chatting with the agent.
|
|
@@ -9232,7 +9231,7 @@
|
|
|
9232
9231
|
* Markdown documentation for META FONT commitment.
|
|
9233
9232
|
*/
|
|
9234
9233
|
get documentation() {
|
|
9235
|
-
return
|
|
9234
|
+
return spacetrim.spaceTrim(`
|
|
9236
9235
|
# META FONT
|
|
9237
9236
|
|
|
9238
9237
|
Sets the agent's font.
|
|
@@ -9317,7 +9316,7 @@
|
|
|
9317
9316
|
* Markdown documentation for META IMAGE commitment.
|
|
9318
9317
|
*/
|
|
9319
9318
|
get documentation() {
|
|
9320
|
-
return
|
|
9319
|
+
return spacetrim.spaceTrim(`
|
|
9321
9320
|
# META IMAGE
|
|
9322
9321
|
|
|
9323
9322
|
Sets the agent's avatar/profile image URL.
|
|
@@ -9396,7 +9395,7 @@
|
|
|
9396
9395
|
* Markdown documentation for META INPUT PLACEHOLDER commitment.
|
|
9397
9396
|
*/
|
|
9398
9397
|
get documentation() {
|
|
9399
|
-
return
|
|
9398
|
+
return spacetrim.spaceTrim(`
|
|
9400
9399
|
# META INPUT PLACEHOLDER
|
|
9401
9400
|
|
|
9402
9401
|
Sets custom placeholder text for the chat input field.
|
|
@@ -9477,7 +9476,7 @@
|
|
|
9477
9476
|
* Markdown documentation for META LINK commitment.
|
|
9478
9477
|
*/
|
|
9479
9478
|
get documentation() {
|
|
9480
|
-
return
|
|
9479
|
+
return spacetrim.spaceTrim(`
|
|
9481
9480
|
# META LINK
|
|
9482
9481
|
|
|
9483
9482
|
Represents a profile or source link for the person the agent is modeled after.
|
|
@@ -9576,7 +9575,7 @@
|
|
|
9576
9575
|
* Markdown documentation for META VOICE commitment.
|
|
9577
9576
|
*/
|
|
9578
9577
|
get documentation() {
|
|
9579
|
-
return
|
|
9578
|
+
return spacetrim.spaceTrim(`
|
|
9580
9579
|
# META VOICE
|
|
9581
9580
|
|
|
9582
9581
|
Instructs the UI to use a specific ElevenLabs voice when reading this agent's replies aloud.
|
|
@@ -9658,7 +9657,7 @@
|
|
|
9658
9657
|
* Markdown documentation for MODEL commitment.
|
|
9659
9658
|
*/
|
|
9660
9659
|
get documentation() {
|
|
9661
|
-
return
|
|
9660
|
+
return spacetrim.spaceTrim(`
|
|
9662
9661
|
# ${this.type}
|
|
9663
9662
|
|
|
9664
9663
|
Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
|
|
@@ -9899,7 +9898,7 @@
|
|
|
9899
9898
|
* Markdown documentation for NOTE commitment.
|
|
9900
9899
|
*/
|
|
9901
9900
|
get documentation() {
|
|
9902
|
-
return
|
|
9901
|
+
return spacetrim.spaceTrim(`
|
|
9903
9902
|
# ${this.type}
|
|
9904
9903
|
|
|
9905
9904
|
Adds comments for documentation without changing agent behavior.
|
|
@@ -9938,7 +9937,7 @@
|
|
|
9938
9937
|
applyToAgentModelRequirements(requirements, content) {
|
|
9939
9938
|
// The NOTE commitment makes no changes to the system message or model requirements
|
|
9940
9939
|
// It only stores the note content in metadata for documentation purposes
|
|
9941
|
-
const trimmedContent =
|
|
9940
|
+
const trimmedContent = spacetrim.spaceTrim(content);
|
|
9942
9941
|
if (trimmedContent === '') {
|
|
9943
9942
|
return requirements;
|
|
9944
9943
|
}
|
|
@@ -9983,7 +9982,7 @@
|
|
|
9983
9982
|
* Markdown documentation for OPEN commitment.
|
|
9984
9983
|
*/
|
|
9985
9984
|
get documentation() {
|
|
9986
|
-
return
|
|
9985
|
+
return spacetrim.spaceTrim(`
|
|
9987
9986
|
# OPEN
|
|
9988
9987
|
|
|
9989
9988
|
Specifies that the agent can be modified by conversation with it.
|
|
@@ -10060,7 +10059,7 @@
|
|
|
10060
10059
|
* Markdown documentation for PERSONA commitment.
|
|
10061
10060
|
*/
|
|
10062
10061
|
get documentation() {
|
|
10063
|
-
return
|
|
10062
|
+
return spacetrim.spaceTrim(`
|
|
10064
10063
|
# ${this.type}
|
|
10065
10064
|
|
|
10066
10065
|
Defines who the agent is, their background, expertise, and personality traits.
|
|
@@ -10193,7 +10192,7 @@
|
|
|
10193
10192
|
* Markdown documentation for RULE/RULES commitment.
|
|
10194
10193
|
*/
|
|
10195
10194
|
get documentation() {
|
|
10196
|
-
return
|
|
10195
|
+
return spacetrim.spaceTrim(`
|
|
10197
10196
|
# ${this.type}
|
|
10198
10197
|
|
|
10199
10198
|
Adds behavioral constraints and guidelines that the agent must follow.
|
|
@@ -10257,7 +10256,7 @@
|
|
|
10257
10256
|
* @private internal utility of writing commitments
|
|
10258
10257
|
*/
|
|
10259
10258
|
function createWritingSampleSection(content) {
|
|
10260
|
-
return
|
|
10259
|
+
return spacetrim.spaceTrim(`
|
|
10261
10260
|
Use this as a 1:1 voice exemplar for how your replies should sound.
|
|
10262
10261
|
Treat it as sample-only guidance for voice, cadence, phrasing, and emotional texture, not as task-solving instructions.
|
|
10263
10262
|
If multiple writing samples exist, newer samples have higher weight than older ones.
|
|
@@ -10274,7 +10273,7 @@
|
|
|
10274
10273
|
* @private internal utility of writing commitments
|
|
10275
10274
|
*/
|
|
10276
10275
|
function createWritingRulesSection(content) {
|
|
10277
|
-
return
|
|
10276
|
+
return spacetrim.spaceTrim(`
|
|
10278
10277
|
These instructions apply only to how you write: tone, formatting, length, emoji usage, punctuation, and similar presentation choices.
|
|
10279
10278
|
They do not change your task-solving behavior, business logic, or factual decision-making rules.
|
|
10280
10279
|
If multiple writing-rules blocks conflict, prefer the newer writing-rules blocks.
|
|
@@ -10324,7 +10323,7 @@
|
|
|
10324
10323
|
* Markdown documentation for `SAMPLE` / `EXAMPLE`.
|
|
10325
10324
|
*/
|
|
10326
10325
|
get documentation() {
|
|
10327
|
-
return
|
|
10326
|
+
return spacetrim.spaceTrim(`
|
|
10328
10327
|
# ${this.type}
|
|
10329
10328
|
|
|
10330
10329
|
Deprecated legacy alias for \`WRITING SAMPLE\`.
|
|
@@ -10405,7 +10404,7 @@
|
|
|
10405
10404
|
* Markdown documentation for SCENARIO commitment.
|
|
10406
10405
|
*/
|
|
10407
10406
|
get documentation() {
|
|
10408
|
-
return
|
|
10407
|
+
return spacetrim.spaceTrim(`
|
|
10409
10408
|
# ${this.type}
|
|
10410
10409
|
|
|
10411
10410
|
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.
|
|
@@ -10527,7 +10526,7 @@
|
|
|
10527
10526
|
* Markdown documentation for STYLE commitment.
|
|
10528
10527
|
*/
|
|
10529
10528
|
get documentation() {
|
|
10530
|
-
return
|
|
10529
|
+
return spacetrim.spaceTrim(`
|
|
10531
10530
|
# ${this.type}
|
|
10532
10531
|
|
|
10533
10532
|
Defines how the agent should format and present its responses (tone, writing style, formatting).
|
|
@@ -10800,7 +10799,7 @@
|
|
|
10800
10799
|
* Markdown documentation for TEAM commitment.
|
|
10801
10800
|
*/
|
|
10802
10801
|
get documentation() {
|
|
10803
|
-
return
|
|
10802
|
+
return spacetrim.spaceTrim(`
|
|
10804
10803
|
# TEAM
|
|
10805
10804
|
|
|
10806
10805
|
Registers teammate agents that the current agent can consult via tools.
|
|
@@ -11166,7 +11165,7 @@
|
|
|
11166
11165
|
* Markdown documentation for TEMPLATE commitment.
|
|
11167
11166
|
*/
|
|
11168
11167
|
get documentation() {
|
|
11169
|
-
return
|
|
11168
|
+
return spacetrim.spaceTrim(`
|
|
11170
11169
|
# ${this.type}
|
|
11171
11170
|
|
|
11172
11171
|
Enforces a specific response structure or template that the agent must follow when generating responses.
|
|
@@ -11222,7 +11221,7 @@
|
|
|
11222
11221
|
templateMode: true,
|
|
11223
11222
|
};
|
|
11224
11223
|
// Add a general instruction about using structured templates
|
|
11225
|
-
const templateModeInstruction =
|
|
11224
|
+
const templateModeInstruction = spacetrim.spaceTrim(`
|
|
11226
11225
|
Use a clear, structured template format for your responses.
|
|
11227
11226
|
Maintain consistency in how you organize and present information.
|
|
11228
11227
|
`);
|
|
@@ -11293,7 +11292,7 @@
|
|
|
11293
11292
|
* Markdown documentation for USE commitment.
|
|
11294
11293
|
*/
|
|
11295
11294
|
get documentation() {
|
|
11296
|
-
return
|
|
11295
|
+
return spacetrim.spaceTrim(`
|
|
11297
11296
|
# USE
|
|
11298
11297
|
|
|
11299
11298
|
Enables the agent to use specific tools or capabilities for interacting with external systems.
|
|
@@ -11451,7 +11450,7 @@
|
|
|
11451
11450
|
* Markdown documentation for USE BROWSER commitment.
|
|
11452
11451
|
*/
|
|
11453
11452
|
get documentation() {
|
|
11454
|
-
return
|
|
11453
|
+
return spacetrim.spaceTrim(`
|
|
11455
11454
|
# USE BROWSER
|
|
11456
11455
|
|
|
11457
11456
|
Enables the agent to use browser tools to access and retrieve up-to-date information from the internet.
|
|
@@ -11514,7 +11513,7 @@
|
|
|
11514
11513
|
if (!existingTools.some((tool) => tool.name === 'fetch_url_content')) {
|
|
11515
11514
|
toolsToAdd.push({
|
|
11516
11515
|
name: 'fetch_url_content',
|
|
11517
|
-
description:
|
|
11516
|
+
description: spacetrim.spaceTrim(`
|
|
11518
11517
|
Fetches and scrapes the content from a URL (webpage or document).
|
|
11519
11518
|
This tool retrieves the content of the specified URL and converts it to markdown format.
|
|
11520
11519
|
Use this when you need to access information from a specific website or document.
|
|
@@ -11536,7 +11535,7 @@
|
|
|
11536
11535
|
if (!existingTools.some((tool) => tool.name === 'run_browser')) {
|
|
11537
11536
|
toolsToAdd.push({
|
|
11538
11537
|
name: 'run_browser',
|
|
11539
|
-
description:
|
|
11538
|
+
description: spacetrim.spaceTrim(`
|
|
11540
11539
|
Launches a browser session for complex interactions.
|
|
11541
11540
|
This tool is for advanced browser automation tasks like scrolling, clicking, form filling, etc.
|
|
11542
11541
|
Use this when simple one-shot URL fetching is not enough.
|
|
@@ -11583,7 +11582,7 @@
|
|
|
11583
11582
|
...requirements._metadata,
|
|
11584
11583
|
useBrowser: true,
|
|
11585
11584
|
},
|
|
11586
|
-
},
|
|
11585
|
+
}, spacetrim.spaceTrim(`
|
|
11587
11586
|
You have access to browser tools to fetch and access content from the internet.
|
|
11588
11587
|
- Use "fetch_url_content" to retrieve content from specific URLs (webpages or documents) using scrapers.
|
|
11589
11588
|
- Use "run_browser" for real interactive browser automation (navigation, clicks, typing, waiting, scrolling).
|
|
@@ -11615,7 +11614,7 @@
|
|
|
11615
11614
|
async run_browser(args) {
|
|
11616
11615
|
console.log('!!!! [Tool] run_browser called', { args });
|
|
11617
11616
|
const { url } = args;
|
|
11618
|
-
return
|
|
11617
|
+
return spacetrim.spaceTrim(`
|
|
11619
11618
|
# Running browser
|
|
11620
11619
|
|
|
11621
11620
|
The running browser tool is not available in this runtime.
|
|
@@ -11668,7 +11667,7 @@
|
|
|
11668
11667
|
return null;
|
|
11669
11668
|
}
|
|
11670
11669
|
if (!response.ok) {
|
|
11671
|
-
throw new Error(
|
|
11670
|
+
throw new Error(spacetrim.spaceTrim(`
|
|
11672
11671
|
Google Calendar API request failed (${response.status} ${response.statusText}):
|
|
11673
11672
|
${extractGoogleCalendarApiErrorMessage(parsedPayload, textPayload)}
|
|
11674
11673
|
`));
|
|
@@ -11777,7 +11776,7 @@
|
|
|
11777
11776
|
* @private internal utility of USE CALENDAR commitment
|
|
11778
11777
|
*/
|
|
11779
11778
|
function parseUseCalendarCommitmentContent(content) {
|
|
11780
|
-
const trimmedContent =
|
|
11779
|
+
const trimmedContent = spacetrim.spaceTrim(content);
|
|
11781
11780
|
if (!trimmedContent) {
|
|
11782
11781
|
return {
|
|
11783
11782
|
calendar: null,
|
|
@@ -12757,7 +12756,7 @@
|
|
|
12757
12756
|
* Markdown documentation for USE CALENDAR commitment.
|
|
12758
12757
|
*/
|
|
12759
12758
|
get documentation() {
|
|
12760
|
-
return
|
|
12759
|
+
return spacetrim.spaceTrim(`
|
|
12761
12760
|
# USE CALENDAR
|
|
12762
12761
|
|
|
12763
12762
|
Enables the agent to access and manage one Google Calendar.
|
|
@@ -12814,7 +12813,7 @@
|
|
|
12814
12813
|
useCalendar: true,
|
|
12815
12814
|
useCalendars: existingConfiguredCalendars,
|
|
12816
12815
|
},
|
|
12817
|
-
},
|
|
12816
|
+
}, spacetrim.spaceTrim((block) => `
|
|
12818
12817
|
Calendar tools:
|
|
12819
12818
|
- You can inspect and manage events in configured calendars.
|
|
12820
12819
|
- Supported operations include read, create, update, delete, invite guests, and reminders.
|
|
@@ -12876,7 +12875,7 @@
|
|
|
12876
12875
|
* @private internal utility of USE EMAIL commitment
|
|
12877
12876
|
*/
|
|
12878
12877
|
function parseUseEmailCommitmentContent(content) {
|
|
12879
|
-
const trimmedContent =
|
|
12878
|
+
const trimmedContent = spacetrim.spaceTrim(content);
|
|
12880
12879
|
if (!trimmedContent) {
|
|
12881
12880
|
return {
|
|
12882
12881
|
senderEmail: null,
|
|
@@ -13005,7 +13004,7 @@
|
|
|
13005
13004
|
* Markdown documentation for USE EMAIL commitment.
|
|
13006
13005
|
*/
|
|
13007
13006
|
get documentation() {
|
|
13008
|
-
return
|
|
13007
|
+
return spacetrim.spaceTrim(`
|
|
13009
13008
|
# USE EMAIL
|
|
13010
13009
|
|
|
13011
13010
|
Enables the agent to send outbound emails through SMTP.
|
|
@@ -13047,7 +13046,7 @@
|
|
|
13047
13046
|
useEmail: true,
|
|
13048
13047
|
...(parsedCommitment.senderEmail ? { useEmailSender: parsedCommitment.senderEmail } : {}),
|
|
13049
13048
|
},
|
|
13050
|
-
},
|
|
13049
|
+
}, spacetrim.spaceTrim((block) => `
|
|
13051
13050
|
Email tool:
|
|
13052
13051
|
- Use "${SEND_EMAIL_TOOL_NAME}" to send outbound emails.
|
|
13053
13052
|
- Prefer \`message\` argument compatible with Promptbook \`Message\` type.
|
|
@@ -13165,7 +13164,7 @@
|
|
|
13165
13164
|
* Markdown documentation for USE IMAGE GENERATOR commitment.
|
|
13166
13165
|
*/
|
|
13167
13166
|
get documentation() {
|
|
13168
|
-
return
|
|
13167
|
+
return spacetrim.spaceTrim(`
|
|
13169
13168
|
# USE IMAGE GENERATOR
|
|
13170
13169
|
|
|
13171
13170
|
Enables the agent to output markdown image placeholders that trigger image generation in the user interface.
|
|
@@ -13204,7 +13203,7 @@
|
|
|
13204
13203
|
...requirements._metadata,
|
|
13205
13204
|
useImageGenerator: content || true,
|
|
13206
13205
|
},
|
|
13207
|
-
},
|
|
13206
|
+
}, spacetrim.spaceTrim((block) => `
|
|
13208
13207
|
Image generation:
|
|
13209
13208
|
- You do not generate images directly and you do not call any image tool.
|
|
13210
13209
|
- When the user asks for an image, include markdown notation in your message:
|
|
@@ -13256,7 +13255,7 @@
|
|
|
13256
13255
|
* Markdown documentation for USE MCP commitment.
|
|
13257
13256
|
*/
|
|
13258
13257
|
get documentation() {
|
|
13259
|
-
return
|
|
13258
|
+
return spacetrim.spaceTrim(`
|
|
13260
13259
|
# USE MCP
|
|
13261
13260
|
|
|
13262
13261
|
Connects the agent to an external Model Context Protocol (MCP) server.
|
|
@@ -13337,7 +13336,7 @@
|
|
|
13337
13336
|
* Markdown documentation for USE POPUP commitment.
|
|
13338
13337
|
*/
|
|
13339
13338
|
get documentation() {
|
|
13340
|
-
return
|
|
13339
|
+
return spacetrim.spaceTrim(`
|
|
13341
13340
|
# USE POPUP
|
|
13342
13341
|
|
|
13343
13342
|
Enables the agent to open a popup window with a specific website.
|
|
@@ -13369,7 +13368,7 @@
|
|
|
13369
13368
|
...existingTools,
|
|
13370
13369
|
{
|
|
13371
13370
|
name: 'open_popup',
|
|
13372
|
-
description:
|
|
13371
|
+
description: spacetrim.spaceTrim(`
|
|
13373
13372
|
Opens a popup window with a specific URL.
|
|
13374
13373
|
Use this when you want to show a specific website to the user in a new window.
|
|
13375
13374
|
${!content ? '' : `Constraints / instructions: ${content}`}
|
|
@@ -13394,7 +13393,7 @@
|
|
|
13394
13393
|
...requirements._metadata,
|
|
13395
13394
|
usePopup: content || true,
|
|
13396
13395
|
},
|
|
13397
|
-
},
|
|
13396
|
+
}, spacetrim.spaceTrim((block) => `
|
|
13398
13397
|
Tool:
|
|
13399
13398
|
- You can open a popup window with a specific URL using the tool "open_popup".
|
|
13400
13399
|
- Use this when you want the user to see or interact with a specific website.
|
|
@@ -13421,7 +13420,7 @@
|
|
|
13421
13420
|
window.open(url, '_blank');
|
|
13422
13421
|
return `Popup window with URL "${url}" was opened.`;
|
|
13423
13422
|
}
|
|
13424
|
-
return
|
|
13423
|
+
return spacetrim.spaceTrim(`
|
|
13425
13424
|
Popup window with URL "${url}" was requested.
|
|
13426
13425
|
|
|
13427
13426
|
Note: The agent is currently running on the server, so the popup cannot be opened automatically.
|
|
@@ -13515,7 +13514,7 @@
|
|
|
13515
13514
|
* Markdown documentation for USE PRIVACY commitment.
|
|
13516
13515
|
*/
|
|
13517
13516
|
get documentation() {
|
|
13518
|
-
return
|
|
13517
|
+
return spacetrim.spaceTrim(`
|
|
13519
13518
|
# USE PRIVACY
|
|
13520
13519
|
|
|
13521
13520
|
Enables the agent to request turning on private mode in chat.
|
|
@@ -13555,7 +13554,7 @@
|
|
|
13555
13554
|
...existingTools,
|
|
13556
13555
|
{
|
|
13557
13556
|
name: TURN_PRIVACY_ON_TOOL_NAME,
|
|
13558
|
-
description:
|
|
13557
|
+
description: spacetrim.spaceTrim(`
|
|
13559
13558
|
Requests turning private mode on in the chat UI.
|
|
13560
13559
|
The user must explicitly confirm the action in a dialog before private mode is enabled.
|
|
13561
13560
|
Use this for sensitive topics or when the user asks not to store conversation data.
|
|
@@ -13574,7 +13573,7 @@
|
|
|
13574
13573
|
...requirements._metadata,
|
|
13575
13574
|
usePrivacy: content || true,
|
|
13576
13575
|
},
|
|
13577
|
-
},
|
|
13576
|
+
}, spacetrim.spaceTrim((block) => `
|
|
13578
13577
|
Privacy mode:
|
|
13579
13578
|
- Use "${TURN_PRIVACY_ON_TOOL_NAME}" when the user asks for a private/sensitive conversation.
|
|
13580
13579
|
- This tool requests a UI confirmation dialog. Private mode is enabled only after user confirms.
|
|
@@ -14164,7 +14163,7 @@
|
|
|
14164
14163
|
return null;
|
|
14165
14164
|
}
|
|
14166
14165
|
if (!response.ok) {
|
|
14167
|
-
throw new Error(
|
|
14166
|
+
throw new Error(spacetrim.spaceTrim(`
|
|
14168
14167
|
GitHub API request failed (${response.status} ${response.statusText}):
|
|
14169
14168
|
${extractGitHubApiErrorMessage(parsedPayload, textPayload)}
|
|
14170
14169
|
`));
|
|
@@ -15019,7 +15018,7 @@
|
|
|
15019
15018
|
* Markdown documentation for USE PROJECT commitment.
|
|
15020
15019
|
*/
|
|
15021
15020
|
get documentation() {
|
|
15022
|
-
return
|
|
15021
|
+
return spacetrim.spaceTrim(`
|
|
15023
15022
|
# USE PROJECT
|
|
15024
15023
|
|
|
15025
15024
|
Enables the agent to work with files in a GitHub repository and create pull requests.
|
|
@@ -15059,7 +15058,7 @@
|
|
|
15059
15058
|
useProject: true,
|
|
15060
15059
|
useProjects: existingConfiguredProjects,
|
|
15061
15060
|
},
|
|
15062
|
-
},
|
|
15061
|
+
}, spacetrim.spaceTrim((block) => `
|
|
15063
15062
|
Project tools:
|
|
15064
15063
|
- You can inspect and edit configured GitHub repositories using project tools.
|
|
15065
15064
|
- Configured repositories:
|
|
@@ -15185,7 +15184,7 @@
|
|
|
15185
15184
|
* Markdown documentation for USE SEARCH ENGINE commitment.
|
|
15186
15185
|
*/
|
|
15187
15186
|
get documentation() {
|
|
15188
|
-
return
|
|
15187
|
+
return spacetrim.spaceTrim(`
|
|
15189
15188
|
# USE SEARCH ENGINE
|
|
15190
15189
|
|
|
15191
15190
|
Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
|
|
@@ -15227,7 +15226,7 @@
|
|
|
15227
15226
|
...existingTools,
|
|
15228
15227
|
{
|
|
15229
15228
|
name: 'web_search',
|
|
15230
|
-
description:
|
|
15229
|
+
description: spacetrim.spaceTrim(`
|
|
15231
15230
|
Search the internet for information.
|
|
15232
15231
|
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
15233
15232
|
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
@@ -15276,7 +15275,7 @@
|
|
|
15276
15275
|
...requirements._metadata,
|
|
15277
15276
|
useSearchEngine: content || true,
|
|
15278
15277
|
},
|
|
15279
|
-
},
|
|
15278
|
+
}, spacetrim.spaceTrim((block) => `
|
|
15280
15279
|
Tool:
|
|
15281
15280
|
- You have access to the web search engine via the tool "web_search".
|
|
15282
15281
|
- Use it to find up-to-date information or facts that you don't know.
|
|
@@ -15307,11 +15306,11 @@
|
|
|
15307
15306
|
}
|
|
15308
15307
|
const searchEngine = new SerpSearchEngine();
|
|
15309
15308
|
const results = await searchEngine.search(query, options);
|
|
15310
|
-
return
|
|
15309
|
+
return spacetrim.spaceTrim((block) => `
|
|
15311
15310
|
Search results for "${query}"${Object.keys(options).length === 0 ? '' : ` with options ${JSON.stringify(options)}`}:
|
|
15312
15311
|
|
|
15313
15312
|
${block(results
|
|
15314
|
-
.map((result) =>
|
|
15313
|
+
.map((result) => spacetrim.spaceTrim(`
|
|
15315
15314
|
- **${result.title}**
|
|
15316
15315
|
${result.url}
|
|
15317
15316
|
${result.snippet}
|
|
@@ -15439,7 +15438,7 @@
|
|
|
15439
15438
|
* Markdown documentation for USE SPAWN commitment.
|
|
15440
15439
|
*/
|
|
15441
15440
|
get documentation() {
|
|
15442
|
-
return
|
|
15441
|
+
return spacetrim.spaceTrim(`
|
|
15443
15442
|
# USE SPAWN
|
|
15444
15443
|
|
|
15445
15444
|
Enables the agent to create a new persistent child agent using the \`spawn_agent\` tool.
|
|
@@ -15476,7 +15475,7 @@
|
|
|
15476
15475
|
...existingTools,
|
|
15477
15476
|
{
|
|
15478
15477
|
name: SPAWN_AGENT_TOOL_NAME,
|
|
15479
|
-
description:
|
|
15478
|
+
description: spacetrim.spaceTrim(`
|
|
15480
15479
|
Creates one new persistent child agent in Agents Server.
|
|
15481
15480
|
Use this when the user asks to create a new dedicated agent profile.
|
|
15482
15481
|
The tool returns JSON with \`status\`, \`agentId\`, and created \`agent\` or \`error\`.
|
|
@@ -15491,7 +15490,7 @@
|
|
|
15491
15490
|
...requirements._metadata,
|
|
15492
15491
|
useSpawn: content || true,
|
|
15493
15492
|
},
|
|
15494
|
-
},
|
|
15493
|
+
}, spacetrim.spaceTrim((block) => `
|
|
15495
15494
|
Spawning agents:
|
|
15496
15495
|
- Use "${SPAWN_AGENT_TOOL_NAME}" only when user asks to create a persistent new agent.
|
|
15497
15496
|
- Pass full agent source in \`source\`.
|
|
@@ -15531,7 +15530,7 @@
|
|
|
15531
15530
|
* @private internal utility of USE TIMEOUT
|
|
15532
15531
|
*/
|
|
15533
15532
|
function createTimeoutSystemMessage(extraInstructions) {
|
|
15534
|
-
return
|
|
15533
|
+
return spacetrim.spaceTrim((block) => `
|
|
15535
15534
|
Timeout scheduling:
|
|
15536
15535
|
- Use "set_timeout" to wake this same chat thread in the future.
|
|
15537
15536
|
- Use "list_timeouts" to review timeouts across all chats for the same user+agent scope.
|
|
@@ -15647,7 +15646,7 @@
|
|
|
15647
15646
|
set(args) {
|
|
15648
15647
|
const parsedMilliseconds = Number(args.milliseconds);
|
|
15649
15648
|
if (!Number.isFinite(parsedMilliseconds) || parsedMilliseconds <= 0) {
|
|
15650
|
-
throw new PipelineExecutionError(
|
|
15649
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15651
15650
|
Timeout \`milliseconds\` must be a positive number.
|
|
15652
15651
|
`));
|
|
15653
15652
|
}
|
|
@@ -15663,7 +15662,7 @@
|
|
|
15663
15662
|
cancel(args) {
|
|
15664
15663
|
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
15665
15664
|
if (!timeoutId) {
|
|
15666
|
-
throw new PipelineExecutionError(
|
|
15665
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15667
15666
|
Timeout \`timeoutId\` is required.
|
|
15668
15667
|
`));
|
|
15669
15668
|
}
|
|
@@ -15674,18 +15673,18 @@
|
|
|
15674
15673
|
*/
|
|
15675
15674
|
list(args) {
|
|
15676
15675
|
if (args.includeFinished !== undefined && typeof args.includeFinished !== 'boolean') {
|
|
15677
|
-
throw new PipelineExecutionError(
|
|
15676
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15678
15677
|
Timeout \`includeFinished\` must be a boolean when provided.
|
|
15679
15678
|
`));
|
|
15680
15679
|
}
|
|
15681
15680
|
const parsedLimit = args.limit === undefined ? DEFAULT_LIST_TIMEOUTS_LIMIT : Math.floor(Number(args.limit));
|
|
15682
15681
|
if (!Number.isFinite(parsedLimit) || parsedLimit <= 0) {
|
|
15683
|
-
throw new PipelineExecutionError(
|
|
15682
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15684
15683
|
Timeout \`limit\` must be a positive number.
|
|
15685
15684
|
`));
|
|
15686
15685
|
}
|
|
15687
15686
|
if (parsedLimit > MAX_LIST_TIMEOUTS_LIMIT) {
|
|
15688
|
-
throw new PipelineExecutionError(
|
|
15687
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15689
15688
|
Timeout \`limit\` must be at most \`${MAX_LIST_TIMEOUTS_LIMIT}\`.
|
|
15690
15689
|
`));
|
|
15691
15690
|
}
|
|
@@ -15931,7 +15930,7 @@
|
|
|
15931
15930
|
* Markdown documentation for `USE TIMEOUT`.
|
|
15932
15931
|
*/
|
|
15933
15932
|
get documentation() {
|
|
15934
|
-
return
|
|
15933
|
+
return spacetrim.spaceTrim(`
|
|
15935
15934
|
# USE TIMEOUT
|
|
15936
15935
|
|
|
15937
15936
|
Enables timeout wake-ups and timeout management for the same user+agent scope.
|
|
@@ -16022,7 +16021,7 @@
|
|
|
16022
16021
|
* Markdown documentation for USE TIME commitment.
|
|
16023
16022
|
*/
|
|
16024
16023
|
get documentation() {
|
|
16025
|
-
return
|
|
16024
|
+
return spacetrim.spaceTrim(`
|
|
16026
16025
|
# USE TIME
|
|
16027
16026
|
|
|
16028
16027
|
Enables the agent to determine the current date and time.
|
|
@@ -16083,7 +16082,7 @@
|
|
|
16083
16082
|
_metadata: {
|
|
16084
16083
|
...requirements._metadata,
|
|
16085
16084
|
},
|
|
16086
|
-
},
|
|
16085
|
+
}, spacetrim.spaceTrim((block) => `
|
|
16087
16086
|
Time and date context:
|
|
16088
16087
|
- It is ${moment__default["default"]().format('MMMM YYYY')} now.
|
|
16089
16088
|
- If you need more precise current time information, use the tool "get_current_time".
|
|
@@ -16251,7 +16250,7 @@
|
|
|
16251
16250
|
* Markdown documentation for USE USER LOCATION commitment.
|
|
16252
16251
|
*/
|
|
16253
16252
|
get documentation() {
|
|
16254
|
-
return
|
|
16253
|
+
return spacetrim.spaceTrim(`
|
|
16255
16254
|
# USE USER LOCATION
|
|
16256
16255
|
|
|
16257
16256
|
Enables the agent to retrieve the user's location from runtime context.
|
|
@@ -16289,7 +16288,7 @@
|
|
|
16289
16288
|
...existingTools,
|
|
16290
16289
|
{
|
|
16291
16290
|
name: GET_USER_LOCATION_TOOL_NAME,
|
|
16292
|
-
description:
|
|
16291
|
+
description: spacetrim.spaceTrim(`
|
|
16293
16292
|
Retrieves user location shared by browser runtime (if permission is granted).
|
|
16294
16293
|
Returns JSON status with coordinates and metadata when available.
|
|
16295
16294
|
`),
|
|
@@ -16307,7 +16306,7 @@
|
|
|
16307
16306
|
...requirements._metadata,
|
|
16308
16307
|
useUserLocation: content || true,
|
|
16309
16308
|
},
|
|
16310
|
-
},
|
|
16309
|
+
}, spacetrim.spaceTrim((block) => `
|
|
16311
16310
|
User location:
|
|
16312
16311
|
- Use "${GET_USER_LOCATION_TOOL_NAME}" only when location is needed for a better answer.
|
|
16313
16312
|
- If the tool returns "unavailable" or "permission-denied", ask user to share location or provide city manually.
|
|
@@ -16384,7 +16383,7 @@
|
|
|
16384
16383
|
* Markdown documentation for `WRITING RULES`.
|
|
16385
16384
|
*/
|
|
16386
16385
|
get documentation() {
|
|
16387
|
-
return
|
|
16386
|
+
return spacetrim.spaceTrim(`
|
|
16388
16387
|
# ${this.type}
|
|
16389
16388
|
|
|
16390
16389
|
Adds instructions that apply strictly to how the agent writes.
|
|
@@ -16462,7 +16461,7 @@
|
|
|
16462
16461
|
* Markdown documentation for `WRITING SAMPLE`.
|
|
16463
16462
|
*/
|
|
16464
16463
|
get documentation() {
|
|
16465
|
-
return
|
|
16464
|
+
return spacetrim.spaceTrim(`
|
|
16466
16465
|
# ${this.type}
|
|
16467
16466
|
|
|
16468
16467
|
Provides explicit 1:1 sample text that demonstrates how the agent should sound.
|
|
@@ -16534,7 +16533,7 @@
|
|
|
16534
16533
|
* Markdown documentation available at runtime.
|
|
16535
16534
|
*/
|
|
16536
16535
|
get documentation() {
|
|
16537
|
-
return
|
|
16536
|
+
return spacetrim.spaceTrim(`
|
|
16538
16537
|
# ${this.type}
|
|
16539
16538
|
|
|
16540
16539
|
This commitment is not yet fully implemented.
|
|
@@ -16779,7 +16778,7 @@
|
|
|
16779
16778
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
16780
16779
|
commitments.push({
|
|
16781
16780
|
type: currentCommitment.type,
|
|
16782
|
-
content:
|
|
16781
|
+
content: spacetrim.spaceTrim(fullContent),
|
|
16783
16782
|
originalLine: currentCommitment.originalStartLine,
|
|
16784
16783
|
lineNumber: currentCommitment.startLineNumber,
|
|
16785
16784
|
});
|
|
@@ -16807,7 +16806,7 @@
|
|
|
16807
16806
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
16808
16807
|
commitments.push({
|
|
16809
16808
|
type: currentCommitment.type,
|
|
16810
|
-
content:
|
|
16809
|
+
content: spacetrim.spaceTrim(fullContent),
|
|
16811
16810
|
originalLine: currentCommitment.originalStartLine,
|
|
16812
16811
|
lineNumber: currentCommitment.startLineNumber,
|
|
16813
16812
|
});
|
|
@@ -16833,7 +16832,7 @@
|
|
|
16833
16832
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
16834
16833
|
commitments.push({
|
|
16835
16834
|
type: currentCommitment.type,
|
|
16836
|
-
content:
|
|
16835
|
+
content: spacetrim.spaceTrim(fullContent),
|
|
16837
16836
|
originalLine: currentCommitment.originalStartLine,
|
|
16838
16837
|
lineNumber: currentCommitment.startLineNumber,
|
|
16839
16838
|
});
|
|
@@ -17066,7 +17065,7 @@
|
|
|
17066
17065
|
continue;
|
|
17067
17066
|
}
|
|
17068
17067
|
if (commitment.type === 'FROM') {
|
|
17069
|
-
const content =
|
|
17068
|
+
const content = spacetrim.spaceTrim(commitment.content).split(/\r?\n/)[0] || '';
|
|
17070
17069
|
if (content === 'Adam' || content === '' /* <- Note: Adam is implicit */) {
|
|
17071
17070
|
continue;
|
|
17072
17071
|
}
|
|
@@ -17089,7 +17088,7 @@
|
|
|
17089
17088
|
continue;
|
|
17090
17089
|
}
|
|
17091
17090
|
if (commitment.type === 'IMPORT') {
|
|
17092
|
-
const content =
|
|
17091
|
+
const content = spacetrim.spaceTrim(commitment.content).split(/\r?\n/)[0] || '';
|
|
17093
17092
|
let label = content;
|
|
17094
17093
|
let iconName = 'ExternalLink'; // Import remote
|
|
17095
17094
|
try {
|
|
@@ -17127,7 +17126,7 @@
|
|
|
17127
17126
|
continue;
|
|
17128
17127
|
}
|
|
17129
17128
|
if (commitment.type === 'KNOWLEDGE') {
|
|
17130
|
-
const content =
|
|
17129
|
+
const content = spacetrim.spaceTrim(commitment.content);
|
|
17131
17130
|
const extractedUrls = extractUrlsFromText(content);
|
|
17132
17131
|
let label = content;
|
|
17133
17132
|
let iconName = 'Book';
|
|
@@ -17186,7 +17185,7 @@
|
|
|
17186
17185
|
continue;
|
|
17187
17186
|
}
|
|
17188
17187
|
if (commitment.type === 'META LINK') {
|
|
17189
|
-
const linkValue =
|
|
17188
|
+
const linkValue = spacetrim.spaceTrim(commitment.content);
|
|
17190
17189
|
links.push(linkValue);
|
|
17191
17190
|
meta.link = linkValue;
|
|
17192
17191
|
continue;
|
|
@@ -17196,11 +17195,11 @@
|
|
|
17196
17195
|
continue;
|
|
17197
17196
|
}
|
|
17198
17197
|
if (commitment.type === 'META IMAGE') {
|
|
17199
|
-
meta.image =
|
|
17198
|
+
meta.image = spacetrim.spaceTrim(commitment.content);
|
|
17200
17199
|
continue;
|
|
17201
17200
|
}
|
|
17202
17201
|
if (commitment.type === 'META DESCRIPTION') {
|
|
17203
|
-
meta.description =
|
|
17202
|
+
meta.description = spacetrim.spaceTrim(commitment.content);
|
|
17204
17203
|
continue;
|
|
17205
17204
|
}
|
|
17206
17205
|
if (commitment.type === 'META DISCLAIMER') {
|
|
@@ -17208,7 +17207,7 @@
|
|
|
17208
17207
|
continue;
|
|
17209
17208
|
}
|
|
17210
17209
|
if (commitment.type === 'META INPUT PLACEHOLDER') {
|
|
17211
|
-
meta.inputPlaceholder =
|
|
17210
|
+
meta.inputPlaceholder = spacetrim.spaceTrim(commitment.content);
|
|
17212
17211
|
continue;
|
|
17213
17212
|
}
|
|
17214
17213
|
if (commitment.type === 'MESSAGE SUFFIX') {
|
|
@@ -17224,7 +17223,7 @@
|
|
|
17224
17223
|
continue;
|
|
17225
17224
|
}
|
|
17226
17225
|
if (commitment.type === 'META VOICE') {
|
|
17227
|
-
meta.voice =
|
|
17226
|
+
meta.voice = spacetrim.spaceTrim(commitment.content);
|
|
17228
17227
|
continue;
|
|
17229
17228
|
}
|
|
17230
17229
|
if (commitment.type !== 'META') {
|
|
@@ -17233,10 +17232,10 @@
|
|
|
17233
17232
|
// Parse META commitments - format is "META TYPE content"
|
|
17234
17233
|
const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
|
|
17235
17234
|
if (metaTypeRaw === 'LINK') {
|
|
17236
|
-
links.push(
|
|
17235
|
+
links.push(spacetrim.spaceTrim(commitment.content.substring(metaTypeRaw.length)));
|
|
17237
17236
|
}
|
|
17238
17237
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
17239
|
-
meta[metaType] =
|
|
17238
|
+
meta[metaType] = spacetrim.spaceTrim(commitment.content.substring(metaTypeRaw.length));
|
|
17240
17239
|
}
|
|
17241
17240
|
// Generate fullname fallback if no meta fullname specified
|
|
17242
17241
|
if (!meta.fullname) {
|
|
@@ -17267,7 +17266,7 @@
|
|
|
17267
17266
|
* @returns The content with normalized separators
|
|
17268
17267
|
*/
|
|
17269
17268
|
function normalizeSeparator(content) {
|
|
17270
|
-
const trimmed =
|
|
17269
|
+
const trimmed = spacetrim.spaceTrim(content);
|
|
17271
17270
|
if (trimmed.includes(',')) {
|
|
17272
17271
|
return trimmed;
|
|
17273
17272
|
}
|
|
@@ -17280,7 +17279,7 @@
|
|
|
17280
17279
|
* @returns Normalized domain or a trimmed fallback.
|
|
17281
17280
|
*/
|
|
17282
17281
|
function normalizeMetaDomain(content) {
|
|
17283
|
-
const trimmed =
|
|
17282
|
+
const trimmed = spacetrim.spaceTrim(content);
|
|
17284
17283
|
return normalizeDomainForMatching(trimmed) || trimmed.toLowerCase();
|
|
17285
17284
|
}
|
|
17286
17285
|
/**
|
|
@@ -17421,7 +17420,7 @@
|
|
|
17421
17420
|
* @deprecated Use `$generateBookBoilerplate` instead
|
|
17422
17421
|
* @public exported from `@promptbook/core`
|
|
17423
17422
|
*/
|
|
17424
|
-
const DEFAULT_BOOK = padBook(validateBook(
|
|
17423
|
+
const DEFAULT_BOOK = padBook(validateBook(spacetrim.spaceTrim(`
|
|
17425
17424
|
AI Avatar
|
|
17426
17425
|
|
|
17427
17426
|
PERSONA A friendly AI assistant that helps you with your tasks
|
|
@@ -18216,7 +18215,7 @@
|
|
|
18216
18215
|
function aboutPromptbookInformation(options) {
|
|
18217
18216
|
const { isServersInfoIncluded = true, isRuntimeEnvironmentInfoIncluded = true } = options || {};
|
|
18218
18217
|
const fullInfoPieces = [];
|
|
18219
|
-
const basicInfo =
|
|
18218
|
+
const basicInfo = spacetrim.spaceTrim(`
|
|
18220
18219
|
|
|
18221
18220
|
# ${NAME}
|
|
18222
18221
|
|
|
@@ -18228,7 +18227,7 @@
|
|
|
18228
18227
|
`);
|
|
18229
18228
|
fullInfoPieces.push(basicInfo);
|
|
18230
18229
|
if (isServersInfoIncluded) {
|
|
18231
|
-
const serversInfo =
|
|
18230
|
+
const serversInfo = spacetrim.spaceTrim((block) => `
|
|
18232
18231
|
|
|
18233
18232
|
## Servers
|
|
18234
18233
|
|
|
@@ -18242,7 +18241,7 @@
|
|
|
18242
18241
|
...runtimeEnvironment,
|
|
18243
18242
|
isCostPrevented: IS_COST_PREVENTED,
|
|
18244
18243
|
};
|
|
18245
|
-
const environmentInfo =
|
|
18244
|
+
const environmentInfo = spacetrim.spaceTrim((block) => `
|
|
18246
18245
|
|
|
18247
18246
|
## Environment
|
|
18248
18247
|
|
|
@@ -18252,7 +18251,7 @@
|
|
|
18252
18251
|
`);
|
|
18253
18252
|
fullInfoPieces.push(environmentInfo);
|
|
18254
18253
|
}
|
|
18255
|
-
const fullInfo =
|
|
18254
|
+
const fullInfo = spacetrim.spaceTrim(fullInfoPieces.join('\n\n'));
|
|
18256
18255
|
return fullInfo;
|
|
18257
18256
|
}
|
|
18258
18257
|
/**
|
|
@@ -21535,7 +21534,7 @@
|
|
|
21535
21534
|
const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
21536
21535
|
return luminance > 186 ? '#0f172a' : '#f8fafc';
|
|
21537
21536
|
}
|
|
21538
|
-
const HERO_ILLUSTRATION_SVG =
|
|
21537
|
+
const HERO_ILLUSTRATION_SVG = spacetrim.spaceTrim(() => `
|
|
21539
21538
|
<svg width="320" height="220" viewBox="0 0 320 220" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
21540
21539
|
<defs>
|
|
21541
21540
|
<linearGradient id="heroGradient" x1="0" y1="0" x2="320" y2="220">
|
|
@@ -21553,7 +21552,7 @@
|
|
|
21553
21552
|
<rect x="62" y="130" width="196" height="20" rx="10" fill="rgba(255,255,255,0.15)" />
|
|
21554
21553
|
</svg>
|
|
21555
21554
|
`);
|
|
21556
|
-
const BRAND_MARK_SVG =
|
|
21555
|
+
const BRAND_MARK_SVG = spacetrim.spaceTrim(() => `
|
|
21557
21556
|
<svg width="92" height="92" viewBox="0 0 92 92" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
21558
21557
|
<defs>
|
|
21559
21558
|
<linearGradient id="badgeGradient" x1="0" y1="0" x2="92" y2="92">
|
|
@@ -21703,7 +21702,7 @@
|
|
|
21703
21702
|
const href = hasUrl ? ` href="${escapeHtml$1((_a = attachment.url) !== null && _a !== void 0 ? _a : '#')}" target="_blank" rel="noopener"` : '';
|
|
21704
21703
|
const name = escapeHtml$1(attachment.name || 'Attachment');
|
|
21705
21704
|
const meta = escapeHtml$1(attachment.type || 'file');
|
|
21706
|
-
return
|
|
21705
|
+
return spacetrim.spaceTrim(`
|
|
21707
21706
|
<${tag} class="attachment-chip"${href}>
|
|
21708
21707
|
<span class="attachment-icon">📎</span>
|
|
21709
21708
|
<span class="attachment-name">${name}</span>
|
|
@@ -21728,7 +21727,7 @@
|
|
|
21728
21727
|
const urlLink = citation.url
|
|
21729
21728
|
? `<a class="citation-link" href="${escapeHtml$1(citation.url)}" target="_blank" rel="noopener">Open source</a>`
|
|
21730
21729
|
: '';
|
|
21731
|
-
return
|
|
21730
|
+
return spacetrim.spaceTrim(`
|
|
21732
21731
|
<article class="citation-chip">
|
|
21733
21732
|
<div class="citation-header">
|
|
21734
21733
|
<span class="citation-badge">${escapeHtml$1(citation.id)}</span>
|
|
@@ -21760,7 +21759,7 @@
|
|
|
21760
21759
|
const avatarMarkup = visuals.avatarSrc
|
|
21761
21760
|
? `<img class="message-avatar-img" src="${escapeHtml$1(visuals.avatarSrc)}" alt="${escapeHtml$1(visuals.displayName)}" />`
|
|
21762
21761
|
: `<span class="message-avatar-fallback" style="background:${visuals.accentColor};color:${bubbleTextColor};">${escapeHtml$1(visuals.avatarLabel)}</span>`;
|
|
21763
|
-
return
|
|
21762
|
+
return spacetrim.spaceTrim(`
|
|
21764
21763
|
<article class="message-block ${alignmentClass}">
|
|
21765
21764
|
<div class="message-avatar">${avatarMarkup}</div>
|
|
21766
21765
|
<div class="message-card" style="--bubble-color:${visuals.accentColor};--bubble-text:${bubbleTextColor};">
|
|
@@ -21811,7 +21810,7 @@
|
|
|
21811
21810
|
const messageMarkup = messages.length > 0
|
|
21812
21811
|
? messages.map((message) => renderMessageBlock(message, participantLookup)).join('')
|
|
21813
21812
|
: '<div class="empty-state">No messages yet. Send a note to capture this chat.</div>';
|
|
21814
|
-
return
|
|
21813
|
+
return spacetrim.spaceTrim(`
|
|
21815
21814
|
<!DOCTYPE html>
|
|
21816
21815
|
<html lang="en">
|
|
21817
21816
|
<head>
|
|
@@ -22216,7 +22215,7 @@
|
|
|
22216
22215
|
<p class="hero-subtitle">${escapeHtml$1(heroSubtitle)}</p>
|
|
22217
22216
|
<div class="stat-grid">
|
|
22218
22217
|
${statCards
|
|
22219
|
-
.map((stat) =>
|
|
22218
|
+
.map((stat) => spacetrim.spaceTrim(`
|
|
22220
22219
|
<div class="stat-card">
|
|
22221
22220
|
<span class="stat-value">${escapeHtml$1(stat.value)}</span>
|
|
22222
22221
|
<span class="stat-label">${escapeHtml$1(stat.label)}</span>
|
|
@@ -22290,9 +22289,9 @@
|
|
|
22290
22289
|
const mdSaveFormatDefinition = {
|
|
22291
22290
|
formatName: 'md',
|
|
22292
22291
|
label: 'Markdown',
|
|
22293
|
-
getContent: ({ messages }) =>
|
|
22292
|
+
getContent: ({ messages }) => spacetrim.spaceTrim(`
|
|
22294
22293
|
${messages
|
|
22295
|
-
.map((message) =>
|
|
22294
|
+
.map((message) => spacetrim.spaceTrim(`
|
|
22296
22295
|
**${message.sender}:**
|
|
22297
22296
|
|
|
22298
22297
|
> ${message.content.replace(/\n/g, '\n> ')}
|
|
@@ -22471,7 +22470,7 @@
|
|
|
22471
22470
|
const { imports: participantsImports, value: participantsValue } = serializeToPromptbookJavascript(participants);
|
|
22472
22471
|
const { imports: messagesImports, value: messagesValue } = serializeToPromptbookJavascript(messages);
|
|
22473
22472
|
const uniqueImports = Array.from(new Set([`import { Chat } from '@promptbook/components';`, ...participantsImports, ...messagesImports])).filter((imp) => !!imp && imp.trim().length > 0);
|
|
22474
|
-
return
|
|
22473
|
+
return spacetrim.spaceTrim((block) => `
|
|
22475
22474
|
"use client";
|
|
22476
22475
|
|
|
22477
22476
|
${block(uniqueImports.join('\n'))}
|
|
@@ -23967,7 +23966,7 @@
|
|
|
23967
23966
|
type: uploadedFile.file.type,
|
|
23968
23967
|
url: uploadedFile.content,
|
|
23969
23968
|
}));
|
|
23970
|
-
if (
|
|
23969
|
+
if (spacetrim.spaceTrim(messageContent) === '' && attachments.length === 0) {
|
|
23971
23970
|
throw new Error(`You need to write some text or upload a file`);
|
|
23972
23971
|
}
|
|
23973
23972
|
if (soundSystem) {
|
|
@@ -24029,7 +24028,7 @@
|
|
|
24029
24028
|
}
|
|
24030
24029
|
const resolvedAction = resolveChatEnterAction(resolvedBehavior, false);
|
|
24031
24030
|
if (resolvedAction === 'SEND') {
|
|
24032
|
-
const hasTextToSend =
|
|
24031
|
+
const hasTextToSend = spacetrim.spaceTrim(snapshot.value) !== '' || snapshot.attachmentIds.length > 0;
|
|
24033
24032
|
if (!hasTextToSend) {
|
|
24034
24033
|
return;
|
|
24035
24034
|
}
|
|
@@ -24306,7 +24305,7 @@
|
|
|
24306
24305
|
pipelineString += '\n\n';
|
|
24307
24306
|
pipelineString += '```' + contentLanguage;
|
|
24308
24307
|
pipelineString += '\n';
|
|
24309
|
-
pipelineString +=
|
|
24308
|
+
pipelineString += spacetrim.spaceTrim(content);
|
|
24310
24309
|
// <- TODO: [main] !!3 Escape
|
|
24311
24310
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
24312
24311
|
pipelineString += '\n';
|
|
@@ -24364,7 +24363,7 @@
|
|
|
24364
24363
|
if (!(error instanceof PipelineLogicError)) {
|
|
24365
24364
|
throw error;
|
|
24366
24365
|
}
|
|
24367
|
-
console.error(
|
|
24366
|
+
console.error(spacetrim.spaceTrim((block) => `
|
|
24368
24367
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
24369
24368
|
|
|
24370
24369
|
${block(error.message)}
|
|
@@ -24391,7 +24390,7 @@
|
|
|
24391
24390
|
})();
|
|
24392
24391
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
24393
24392
|
// <- Note: [🚲]
|
|
24394
|
-
throw new PipelineLogicError(
|
|
24393
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24395
24394
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
24396
24395
|
|
|
24397
24396
|
${block(pipelineIdentification)}
|
|
@@ -24399,7 +24398,7 @@
|
|
|
24399
24398
|
}
|
|
24400
24399
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
24401
24400
|
// <- Note: [🚲]
|
|
24402
|
-
throw new PipelineLogicError(
|
|
24401
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24403
24402
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
24404
24403
|
|
|
24405
24404
|
${block(pipelineIdentification)}
|
|
@@ -24408,7 +24407,7 @@
|
|
|
24408
24407
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
24409
24408
|
if (!Array.isArray(pipeline.parameters)) {
|
|
24410
24409
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
24411
|
-
throw new ParseError(
|
|
24410
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
24412
24411
|
Pipeline is valid JSON but with wrong structure
|
|
24413
24412
|
|
|
24414
24413
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -24419,7 +24418,7 @@
|
|
|
24419
24418
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
24420
24419
|
if (!Array.isArray(pipeline.tasks)) {
|
|
24421
24420
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
24422
|
-
throw new ParseError(
|
|
24421
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
24423
24422
|
Pipeline is valid JSON but with wrong structure
|
|
24424
24423
|
|
|
24425
24424
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -24445,7 +24444,7 @@
|
|
|
24445
24444
|
// Note: Check each parameter individually
|
|
24446
24445
|
for (const parameter of pipeline.parameters) {
|
|
24447
24446
|
if (parameter.isInput && parameter.isOutput) {
|
|
24448
|
-
throw new PipelineLogicError(
|
|
24447
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24449
24448
|
|
|
24450
24449
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
24451
24450
|
|
|
@@ -24456,7 +24455,7 @@
|
|
|
24456
24455
|
if (!parameter.isInput &&
|
|
24457
24456
|
!parameter.isOutput &&
|
|
24458
24457
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
24459
|
-
throw new PipelineLogicError(
|
|
24458
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24460
24459
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
24461
24460
|
|
|
24462
24461
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -24468,7 +24467,7 @@
|
|
|
24468
24467
|
}
|
|
24469
24468
|
// Note: Testing that parameter is either input or result of some task
|
|
24470
24469
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
24471
|
-
throw new PipelineLogicError(
|
|
24470
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24472
24471
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
24473
24472
|
|
|
24474
24473
|
You can do one of these:
|
|
@@ -24484,14 +24483,14 @@
|
|
|
24484
24483
|
// Note: Checking each task individually
|
|
24485
24484
|
for (const task of pipeline.tasks) {
|
|
24486
24485
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
24487
|
-
throw new PipelineLogicError(
|
|
24486
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24488
24487
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
24489
24488
|
|
|
24490
24489
|
${block(pipelineIdentification)}
|
|
24491
24490
|
`));
|
|
24492
24491
|
}
|
|
24493
24492
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
24494
|
-
throw new PipelineLogicError(
|
|
24493
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24495
24494
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
24496
24495
|
|
|
24497
24496
|
${block(pipelineIdentification)}
|
|
@@ -24501,7 +24500,7 @@
|
|
|
24501
24500
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
24502
24501
|
if (!task.format &&
|
|
24503
24502
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
24504
|
-
throw new PipelineLogicError(
|
|
24503
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24505
24504
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
24506
24505
|
|
|
24507
24506
|
${block(pipelineIdentification)}
|
|
@@ -24509,7 +24508,7 @@
|
|
|
24509
24508
|
}
|
|
24510
24509
|
for (const joker of task.jokerParameterNames) {
|
|
24511
24510
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
24512
|
-
throw new PipelineLogicError(
|
|
24511
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24513
24512
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
24514
24513
|
|
|
24515
24514
|
${block(pipelineIdentification)}
|
|
@@ -24520,21 +24519,21 @@
|
|
|
24520
24519
|
if (task.expectations) {
|
|
24521
24520
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
24522
24521
|
if (min !== undefined && max !== undefined && min > max) {
|
|
24523
|
-
throw new PipelineLogicError(
|
|
24522
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24524
24523
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
24525
24524
|
|
|
24526
24525
|
${block(pipelineIdentification)}
|
|
24527
24526
|
`));
|
|
24528
24527
|
}
|
|
24529
24528
|
if (min !== undefined && min < 0) {
|
|
24530
|
-
throw new PipelineLogicError(
|
|
24529
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24531
24530
|
Min expectation of ${unit} must be zero or positive
|
|
24532
24531
|
|
|
24533
24532
|
${block(pipelineIdentification)}
|
|
24534
24533
|
`));
|
|
24535
24534
|
}
|
|
24536
24535
|
if (max !== undefined && max <= 0) {
|
|
24537
|
-
throw new PipelineLogicError(
|
|
24536
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24538
24537
|
Max expectation of ${unit} must be positive
|
|
24539
24538
|
|
|
24540
24539
|
${block(pipelineIdentification)}
|
|
@@ -24556,7 +24555,7 @@
|
|
|
24556
24555
|
while (unresovedTasks.length > 0) {
|
|
24557
24556
|
if (loopLimit-- < 0) {
|
|
24558
24557
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
24559
|
-
throw new UnexpectedError(
|
|
24558
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
24560
24559
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
24561
24560
|
|
|
24562
24561
|
${block(pipelineIdentification)}
|
|
@@ -24566,7 +24565,7 @@
|
|
|
24566
24565
|
if (currentlyResovedTasks.length === 0) {
|
|
24567
24566
|
throw new PipelineLogicError(
|
|
24568
24567
|
// TODO: [🐎] DRY
|
|
24569
|
-
|
|
24568
|
+
spacetrim.spaceTrim((block) => `
|
|
24570
24569
|
|
|
24571
24570
|
Can not resolve some parameters:
|
|
24572
24571
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -24687,7 +24686,7 @@
|
|
|
24687
24686
|
for (const pipeline of pipelines) {
|
|
24688
24687
|
// TODO: [👠] DRY
|
|
24689
24688
|
if (pipeline.pipelineUrl === undefined) {
|
|
24690
|
-
throw new PipelineUrlError(
|
|
24689
|
+
throw new PipelineUrlError(spacetrim.spaceTrim(`
|
|
24691
24690
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
24692
24691
|
|
|
24693
24692
|
File:
|
|
@@ -24709,7 +24708,7 @@
|
|
|
24709
24708
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
24710
24709
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
24711
24710
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
24712
|
-
throw new PipelineUrlError(
|
|
24711
|
+
throw new PipelineUrlError(spacetrim.spaceTrim(`
|
|
24713
24712
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
24714
24713
|
|
|
24715
24714
|
Conflicting files:
|
|
@@ -24741,13 +24740,13 @@
|
|
|
24741
24740
|
const pipeline = this.collection.get(url);
|
|
24742
24741
|
if (!pipeline) {
|
|
24743
24742
|
if (this.listPipelines().length === 0) {
|
|
24744
|
-
throw new NotFoundError(
|
|
24743
|
+
throw new NotFoundError(spacetrim.spaceTrim(`
|
|
24745
24744
|
Pipeline with url "${url}" not found
|
|
24746
24745
|
|
|
24747
24746
|
No pipelines available
|
|
24748
24747
|
`));
|
|
24749
24748
|
}
|
|
24750
|
-
throw new NotFoundError(
|
|
24749
|
+
throw new NotFoundError(spacetrim.spaceTrim((block) => `
|
|
24751
24750
|
Pipeline with url "${url}" not found
|
|
24752
24751
|
|
|
24753
24752
|
Available pipelines:
|
|
@@ -24846,11 +24845,11 @@
|
|
|
24846
24845
|
throw deserializeError(errors[0]);
|
|
24847
24846
|
}
|
|
24848
24847
|
else {
|
|
24849
|
-
throw new PipelineExecutionError(
|
|
24848
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
24850
24849
|
Multiple errors occurred during Promptbook execution
|
|
24851
24850
|
|
|
24852
24851
|
${block(errors
|
|
24853
|
-
.map(({ name, stack, message }, index) =>
|
|
24852
|
+
.map(({ name, stack, message }, index) => spacetrim.spaceTrim((block) => `
|
|
24854
24853
|
${name} ${index + 1}:
|
|
24855
24854
|
${block(stack || message)}
|
|
24856
24855
|
`))
|
|
@@ -25330,14 +25329,14 @@
|
|
|
25330
25329
|
if (description === undefined) {
|
|
25331
25330
|
return headLine;
|
|
25332
25331
|
}
|
|
25333
|
-
return
|
|
25332
|
+
return spacetrim.spaceTrim((block) => `
|
|
25334
25333
|
${headLine}
|
|
25335
25334
|
|
|
25336
25335
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
25337
25336
|
`);
|
|
25338
25337
|
})
|
|
25339
25338
|
.join('\n\n');
|
|
25340
|
-
return
|
|
25339
|
+
return spacetrim.spaceTrim((block) => `
|
|
25341
25340
|
Multiple LLM Providers:
|
|
25342
25341
|
|
|
25343
25342
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -25439,7 +25438,7 @@
|
|
|
25439
25438
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
25440
25439
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
25441
25440
|
// 3) ...
|
|
25442
|
-
|
|
25441
|
+
spacetrim.spaceTrim((block) => `
|
|
25443
25442
|
All execution tools of ${this.title} failed:
|
|
25444
25443
|
|
|
25445
25444
|
${block(errors
|
|
@@ -25452,7 +25451,7 @@
|
|
|
25452
25451
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
25453
25452
|
}
|
|
25454
25453
|
else {
|
|
25455
|
-
throw new PipelineExecutionError(
|
|
25454
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
25456
25455
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
25457
25456
|
|
|
25458
25457
|
Available \`LlmExecutionTools\`:
|
|
@@ -25489,7 +25488,7 @@
|
|
|
25489
25488
|
*/
|
|
25490
25489
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
25491
25490
|
if (llmExecutionTools.length === 0) {
|
|
25492
|
-
const warningMessage =
|
|
25491
|
+
const warningMessage = spacetrim.spaceTrim(`
|
|
25493
25492
|
You have not provided any \`LlmExecutionTools\`
|
|
25494
25493
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
25495
25494
|
|
|
@@ -25666,14 +25665,14 @@
|
|
|
25666
25665
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
25667
25666
|
});
|
|
25668
25667
|
if (metadata.length === 0) {
|
|
25669
|
-
return
|
|
25668
|
+
return spacetrim.spaceTrim(`
|
|
25670
25669
|
**No scrapers are available**
|
|
25671
25670
|
|
|
25672
25671
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
25673
25672
|
At least there should be available the metadata of the scrapers
|
|
25674
25673
|
`);
|
|
25675
25674
|
}
|
|
25676
|
-
return
|
|
25675
|
+
return spacetrim.spaceTrim((block) => `
|
|
25677
25676
|
Available scrapers are:
|
|
25678
25677
|
${block(metadata
|
|
25679
25678
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -25800,7 +25799,7 @@
|
|
|
25800
25799
|
else if (urlOrRequest instanceof Request) {
|
|
25801
25800
|
url = urlOrRequest.url;
|
|
25802
25801
|
}
|
|
25803
|
-
throw new PromptbookFetchError(
|
|
25802
|
+
throw new PromptbookFetchError(spacetrim.spaceTrim((block) => `
|
|
25804
25803
|
Can not fetch "${url}"
|
|
25805
25804
|
|
|
25806
25805
|
Fetch error:
|
|
@@ -25960,7 +25959,7 @@
|
|
|
25960
25959
|
const fileExtension = getFileExtension(filename);
|
|
25961
25960
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
25962
25961
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
25963
|
-
throw new NotFoundError(
|
|
25962
|
+
throw new NotFoundError(spacetrim.spaceTrim((block) => `
|
|
25964
25963
|
Can not make source handler for file which does not exist:
|
|
25965
25964
|
|
|
25966
25965
|
File:
|
|
@@ -26053,7 +26052,7 @@
|
|
|
26053
26052
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
26054
26053
|
break;
|
|
26055
26054
|
}
|
|
26056
|
-
console.warn(
|
|
26055
|
+
console.warn(spacetrim.spaceTrim((block) => `
|
|
26057
26056
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
26058
26057
|
|
|
26059
26058
|
The source:
|
|
@@ -26069,7 +26068,7 @@
|
|
|
26069
26068
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
26070
26069
|
}
|
|
26071
26070
|
if (partialPieces === null) {
|
|
26072
|
-
throw new KnowledgeScrapeError(
|
|
26071
|
+
throw new KnowledgeScrapeError(spacetrim.spaceTrim((block) => `
|
|
26073
26072
|
Cannot scrape knowledge
|
|
26074
26073
|
|
|
26075
26074
|
The source:
|
|
@@ -26148,7 +26147,7 @@
|
|
|
26148
26147
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
26149
26148
|
knowledgePiecesCount > 0 &&
|
|
26150
26149
|
!dependentParameterNames.includes('knowledge')) {
|
|
26151
|
-
preparedContent =
|
|
26150
|
+
preparedContent = spacetrim.spaceTrim(`
|
|
26152
26151
|
{content}
|
|
26153
26152
|
|
|
26154
26153
|
## Knowledge
|
|
@@ -26380,7 +26379,7 @@
|
|
|
26380
26379
|
}
|
|
26381
26380
|
catch (error) {
|
|
26382
26381
|
assertsError(error);
|
|
26383
|
-
throw new ParseError(
|
|
26382
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
26384
26383
|
Can not extract variables from the script
|
|
26385
26384
|
${block(error.stack || error.message)}
|
|
26386
26385
|
|
|
@@ -26506,7 +26505,7 @@
|
|
|
26506
26505
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
26507
26506
|
const csv = csvParse(value, settings);
|
|
26508
26507
|
if (csv.errors.length !== 0) {
|
|
26509
|
-
throw new CsvFormatError(
|
|
26508
|
+
throw new CsvFormatError(spacetrim.spaceTrim((block) => `
|
|
26510
26509
|
CSV parsing error
|
|
26511
26510
|
|
|
26512
26511
|
Error(s) from CSV parsing:
|
|
@@ -26551,7 +26550,7 @@
|
|
|
26551
26550
|
const { value, settings, mapCallback, onProgress } = options;
|
|
26552
26551
|
const csv = csvParse(value, settings);
|
|
26553
26552
|
if (csv.errors.length !== 0) {
|
|
26554
|
-
throw new CsvFormatError(
|
|
26553
|
+
throw new CsvFormatError(spacetrim.spaceTrim((block) => `
|
|
26555
26554
|
CSV parsing error
|
|
26556
26555
|
|
|
26557
26556
|
Error(s) from CSV parsing:
|
|
@@ -26737,7 +26736,7 @@
|
|
|
26737
26736
|
}
|
|
26738
26737
|
// Phase 2️⃣: Non-matching mapping
|
|
26739
26738
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
26740
|
-
throw new PipelineExecutionError(
|
|
26739
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
26741
26740
|
Can not map available parameters to expected parameters
|
|
26742
26741
|
|
|
26743
26742
|
Mapped parameters:
|
|
@@ -26923,7 +26922,7 @@
|
|
|
26923
26922
|
}
|
|
26924
26923
|
catch (error) {
|
|
26925
26924
|
keepUnused(error);
|
|
26926
|
-
throw new ExpectError(
|
|
26925
|
+
throw new ExpectError(spacetrim.spaceTrim((block) => `
|
|
26927
26926
|
Expected valid JSON string
|
|
26928
26927
|
|
|
26929
26928
|
The expected JSON text:
|
|
@@ -26986,7 +26985,7 @@
|
|
|
26986
26985
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
26987
26986
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
26988
26987
|
if (isJokerAttempt && !jokerParameterName) {
|
|
26989
|
-
throw new UnexpectedError(
|
|
26988
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
26990
26989
|
Joker not found in attempt ${attemptIndex}
|
|
26991
26990
|
|
|
26992
26991
|
${block(pipelineIdentification)}
|
|
@@ -26997,7 +26996,7 @@
|
|
|
26997
26996
|
$ongoingTaskResult.$expectError = null;
|
|
26998
26997
|
if (isJokerAttempt) {
|
|
26999
26998
|
if (parameters[jokerParameterName] === undefined) {
|
|
27000
|
-
throw new PipelineExecutionError(
|
|
26999
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27001
27000
|
Joker parameter {${jokerParameterName}} not defined
|
|
27002
27001
|
|
|
27003
27002
|
${block(pipelineIdentification)}
|
|
@@ -27056,7 +27055,7 @@
|
|
|
27056
27055
|
break variant;
|
|
27057
27056
|
case 'EMBEDDING':
|
|
27058
27057
|
case 'IMAGE_GENERATION':
|
|
27059
|
-
throw new PipelineExecutionError(
|
|
27058
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27060
27059
|
${modelRequirements.modelVariant} model can not be used in pipeline
|
|
27061
27060
|
|
|
27062
27061
|
This should be catched during parsing
|
|
@@ -27067,7 +27066,7 @@
|
|
|
27067
27066
|
break variant;
|
|
27068
27067
|
// <- case [🤖]:
|
|
27069
27068
|
default:
|
|
27070
|
-
throw new PipelineExecutionError(
|
|
27069
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27071
27070
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
27072
27071
|
|
|
27073
27072
|
${block(pipelineIdentification)}
|
|
@@ -27078,14 +27077,14 @@
|
|
|
27078
27077
|
break;
|
|
27079
27078
|
case 'SCRIPT_TASK':
|
|
27080
27079
|
if (arrayableToArray(tools.script).length === 0) {
|
|
27081
|
-
throw new PipelineExecutionError(
|
|
27080
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27082
27081
|
No script execution tools are available
|
|
27083
27082
|
|
|
27084
27083
|
${block(pipelineIdentification)}
|
|
27085
27084
|
`));
|
|
27086
27085
|
}
|
|
27087
27086
|
if (!task.contentLanguage) {
|
|
27088
|
-
throw new PipelineExecutionError(
|
|
27087
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27089
27088
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
27090
27089
|
|
|
27091
27090
|
${block(pipelineIdentification)}
|
|
@@ -27116,7 +27115,7 @@
|
|
|
27116
27115
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
27117
27116
|
}
|
|
27118
27117
|
else {
|
|
27119
|
-
throw new PipelineExecutionError(
|
|
27118
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27120
27119
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
27121
27120
|
|
|
27122
27121
|
${block(pipelineIdentification)}
|
|
@@ -27130,7 +27129,7 @@
|
|
|
27130
27129
|
break taskType;
|
|
27131
27130
|
case 'DIALOG_TASK':
|
|
27132
27131
|
if (tools.userInterface === undefined) {
|
|
27133
|
-
throw new PipelineExecutionError(
|
|
27132
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27134
27133
|
User interface tools are not available
|
|
27135
27134
|
|
|
27136
27135
|
${block(pipelineIdentification)}
|
|
@@ -27148,7 +27147,7 @@
|
|
|
27148
27147
|
break taskType;
|
|
27149
27148
|
// <- case: [🅱]
|
|
27150
27149
|
default:
|
|
27151
|
-
throw new PipelineExecutionError(
|
|
27150
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27152
27151
|
Unknown execution type "${task.taskType}"
|
|
27153
27152
|
|
|
27154
27153
|
${block(pipelineIdentification)}
|
|
@@ -27246,7 +27245,7 @@
|
|
|
27246
27245
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
27247
27246
|
// Note: Create a summary of all failures
|
|
27248
27247
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
27249
|
-
.map((failure) =>
|
|
27248
|
+
.map((failure) => spacetrim.spaceTrim((block) => {
|
|
27250
27249
|
var _a, _b;
|
|
27251
27250
|
return `
|
|
27252
27251
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -27256,14 +27255,14 @@
|
|
|
27256
27255
|
Result:
|
|
27257
27256
|
${block(failure.result === null
|
|
27258
27257
|
? 'null'
|
|
27259
|
-
:
|
|
27258
|
+
: spacetrim.spaceTrim(failure.result)
|
|
27260
27259
|
.split(/\r?\n/)
|
|
27261
27260
|
.map((line) => `> ${line}`)
|
|
27262
27261
|
.join('\n'))}
|
|
27263
27262
|
`;
|
|
27264
27263
|
}))
|
|
27265
27264
|
.join('\n\n---\n\n');
|
|
27266
|
-
throw new PipelineExecutionError(
|
|
27265
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => {
|
|
27267
27266
|
var _a;
|
|
27268
27267
|
return `
|
|
27269
27268
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -27283,7 +27282,7 @@
|
|
|
27283
27282
|
}
|
|
27284
27283
|
}
|
|
27285
27284
|
if ($ongoingTaskResult.$resultString === null) {
|
|
27286
|
-
throw new UnexpectedError(
|
|
27285
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27287
27286
|
Something went wrong and prompt result is null
|
|
27288
27287
|
|
|
27289
27288
|
${block(pipelineIdentification)}
|
|
@@ -27310,7 +27309,7 @@
|
|
|
27310
27309
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
27311
27310
|
}
|
|
27312
27311
|
if (jokerParameterNames.length !== 0) {
|
|
27313
|
-
throw new UnexpectedError(
|
|
27312
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27314
27313
|
JOKER parameters are not supported together with FOREACH command
|
|
27315
27314
|
|
|
27316
27315
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -27323,7 +27322,7 @@
|
|
|
27323
27322
|
if (formatDefinition === undefined) {
|
|
27324
27323
|
throw new UnexpectedError(
|
|
27325
27324
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
27326
|
-
|
|
27325
|
+
spacetrim.spaceTrim((block) => `
|
|
27327
27326
|
Unsupported format "${task.foreach.formatName}"
|
|
27328
27327
|
|
|
27329
27328
|
Available formats:
|
|
@@ -27340,7 +27339,7 @@
|
|
|
27340
27339
|
if (subvalueParser === undefined) {
|
|
27341
27340
|
throw new UnexpectedError(
|
|
27342
27341
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
27343
|
-
|
|
27342
|
+
spacetrim.spaceTrim((block) => `
|
|
27344
27343
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
27345
27344
|
|
|
27346
27345
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -27380,7 +27379,7 @@
|
|
|
27380
27379
|
if (!(error instanceof PipelineExecutionError)) {
|
|
27381
27380
|
throw error;
|
|
27382
27381
|
}
|
|
27383
|
-
const highLevelError = new PipelineExecutionError(
|
|
27382
|
+
const highLevelError = new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27384
27383
|
${error.message}
|
|
27385
27384
|
|
|
27386
27385
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -27404,7 +27403,7 @@
|
|
|
27404
27403
|
...options,
|
|
27405
27404
|
priority: priority + index,
|
|
27406
27405
|
parameters: allSubparameters,
|
|
27407
|
-
pipelineIdentification:
|
|
27406
|
+
pipelineIdentification: spacetrim.spaceTrim((block) => `
|
|
27408
27407
|
${block(pipelineIdentification)}
|
|
27409
27408
|
Subparameter index: ${index}
|
|
27410
27409
|
`),
|
|
@@ -27413,7 +27412,7 @@
|
|
|
27413
27412
|
}
|
|
27414
27413
|
catch (error) {
|
|
27415
27414
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
27416
|
-
console.error(
|
|
27415
|
+
console.error(spacetrim.spaceTrim((block) => `
|
|
27417
27416
|
${error.message}
|
|
27418
27417
|
|
|
27419
27418
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -27589,7 +27588,7 @@
|
|
|
27589
27588
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
27590
27589
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
27591
27590
|
if (reservedParameters[parameterName] === undefined) {
|
|
27592
|
-
throw new UnexpectedError(
|
|
27591
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27593
27592
|
Reserved parameter {${parameterName}} is not defined
|
|
27594
27593
|
|
|
27595
27594
|
${block(pipelineIdentification)}
|
|
@@ -27615,7 +27614,7 @@
|
|
|
27615
27614
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
27616
27615
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
27617
27616
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
27618
|
-
throw new UnexpectedError(
|
|
27617
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27619
27618
|
Dependent parameters are not consistent with used parameters:
|
|
27620
27619
|
|
|
27621
27620
|
Dependent parameters:
|
|
@@ -27659,7 +27658,7 @@
|
|
|
27659
27658
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
27660
27659
|
// Houston, we have a problem
|
|
27661
27660
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
27662
|
-
throw new UnexpectedError(
|
|
27661
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27663
27662
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
27664
27663
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
27665
27664
|
|
|
@@ -27728,7 +27727,7 @@
|
|
|
27728
27727
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
27729
27728
|
if (parametersToPass[parameter.name] === undefined) {
|
|
27730
27729
|
// [4]
|
|
27731
|
-
$warnings.push(new PipelineExecutionError(
|
|
27730
|
+
$warnings.push(new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27732
27731
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
27733
27732
|
|
|
27734
27733
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -27836,7 +27835,7 @@
|
|
|
27836
27835
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
27837
27836
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
27838
27837
|
if (parameter === undefined) {
|
|
27839
|
-
warnings.push(new PipelineExecutionError(
|
|
27838
|
+
warnings.push(new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27840
27839
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
27841
27840
|
|
|
27842
27841
|
${block(pipelineIdentification)}
|
|
@@ -27851,7 +27850,7 @@
|
|
|
27851
27850
|
// TODO: [🧠] This should be also non-critical error
|
|
27852
27851
|
return exportJson({
|
|
27853
27852
|
name: 'pipelineExecutorResult',
|
|
27854
|
-
message:
|
|
27853
|
+
message: spacetrim.spaceTrim((block) => `
|
|
27855
27854
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
27856
27855
|
|
|
27857
27856
|
${block(pipelineIdentification)}
|
|
@@ -27860,7 +27859,7 @@
|
|
|
27860
27859
|
value: {
|
|
27861
27860
|
isSuccessful: false,
|
|
27862
27861
|
errors: [
|
|
27863
|
-
new PipelineExecutionError(
|
|
27862
|
+
new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27864
27863
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
27865
27864
|
|
|
27866
27865
|
${block(pipelineIdentification)}
|
|
@@ -27887,7 +27886,7 @@
|
|
|
27887
27886
|
while (unresovedTasks.length > 0) {
|
|
27888
27887
|
if (loopLimit-- < 0) {
|
|
27889
27888
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
27890
|
-
throw new UnexpectedError(
|
|
27889
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27891
27890
|
Loop limit reached during resolving parameters pipeline execution
|
|
27892
27891
|
|
|
27893
27892
|
${block(pipelineIdentification)}
|
|
@@ -27897,7 +27896,7 @@
|
|
|
27897
27896
|
if (!currentTask && resolving.length === 0) {
|
|
27898
27897
|
throw new UnexpectedError(
|
|
27899
27898
|
// TODO: [🐎] DRY
|
|
27900
|
-
|
|
27899
|
+
spacetrim.spaceTrim((block) => `
|
|
27901
27900
|
Can not resolve some parameters:
|
|
27902
27901
|
|
|
27903
27902
|
${block(pipelineIdentification)}
|
|
@@ -27937,7 +27936,7 @@
|
|
|
27937
27936
|
tools,
|
|
27938
27937
|
onProgress(newOngoingResult) {
|
|
27939
27938
|
if (isReturned) {
|
|
27940
|
-
throw new UnexpectedError(
|
|
27939
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27941
27940
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
27942
27941
|
|
|
27943
27942
|
${block(pipelineIdentification)}
|
|
@@ -27954,7 +27953,7 @@
|
|
|
27954
27953
|
},
|
|
27955
27954
|
logLlmCall,
|
|
27956
27955
|
$executionReport: executionReport,
|
|
27957
|
-
pipelineIdentification:
|
|
27956
|
+
pipelineIdentification: spacetrim.spaceTrim((block) => `
|
|
27958
27957
|
${block(pipelineIdentification)}
|
|
27959
27958
|
Task name: ${currentTask.name}
|
|
27960
27959
|
Task title: ${currentTask.title}
|
|
@@ -28063,7 +28062,7 @@
|
|
|
28063
28062
|
preparedPipeline = pipeline;
|
|
28064
28063
|
}
|
|
28065
28064
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
28066
|
-
console.warn(
|
|
28065
|
+
console.warn(spacetrim.spaceTrim((block) => `
|
|
28067
28066
|
Pipeline is not prepared
|
|
28068
28067
|
|
|
28069
28068
|
${block(pipelineIdentification)}
|
|
@@ -28088,7 +28087,7 @@
|
|
|
28088
28087
|
tools,
|
|
28089
28088
|
onProgress,
|
|
28090
28089
|
logLlmCall,
|
|
28091
|
-
pipelineIdentification:
|
|
28090
|
+
pipelineIdentification: spacetrim.spaceTrim((block) => `
|
|
28092
28091
|
${block(pipelineIdentification)}
|
|
28093
28092
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
28094
28093
|
`),
|
|
@@ -28322,7 +28321,7 @@
|
|
|
28322
28321
|
.filter((c) => ['PERSONA', 'RULE', 'KNOWLEDGE'].includes(c.type))
|
|
28323
28322
|
.map((c) => `${c.type} ${c.content}`)
|
|
28324
28323
|
.join('\n\n');
|
|
28325
|
-
return
|
|
28324
|
+
return spacetrim.spaceTrim((block) => `
|
|
28326
28325
|
${block(relevantCommitments)}
|
|
28327
28326
|
|
|
28328
28327
|
${block(corpus)}
|
|
@@ -28844,7 +28843,7 @@
|
|
|
28844
28843
|
/**
|
|
28845
28844
|
* Description of the FORMAT command
|
|
28846
28845
|
*/
|
|
28847
|
-
description:
|
|
28846
|
+
description: spacetrim.spaceTrim(`
|
|
28848
28847
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
28849
28848
|
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.
|
|
28850
28849
|
`),
|
|
@@ -28918,7 +28917,7 @@
|
|
|
28918
28917
|
}
|
|
28919
28918
|
catch (error) {
|
|
28920
28919
|
assertsError(error);
|
|
28921
|
-
throw new ParseError(
|
|
28920
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
28922
28921
|
Invalid FORMAT command
|
|
28923
28922
|
${block(error.message)}:
|
|
28924
28923
|
`));
|
|
@@ -28984,7 +28983,7 @@
|
|
|
28984
28983
|
/**
|
|
28985
28984
|
* Description of the FORMAT command
|
|
28986
28985
|
*/
|
|
28987
|
-
description:
|
|
28986
|
+
description: spacetrim.spaceTrim(`
|
|
28988
28987
|
Format command describes the desired output of the task (after post-processing)
|
|
28989
28988
|
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.
|
|
28990
28989
|
`),
|
|
@@ -29574,7 +29573,7 @@
|
|
|
29574
29573
|
/**
|
|
29575
29574
|
* List of available OpenAI models with pricing
|
|
29576
29575
|
*
|
|
29577
|
-
* Note: Synced with official API docs at
|
|
29576
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
29578
29577
|
*
|
|
29579
29578
|
* @see https://platform.openai.com/docs/models/
|
|
29580
29579
|
* @see https://openai.com/api/pricing/
|
|
@@ -29696,8 +29695,8 @@
|
|
|
29696
29695
|
modelName: 'gpt-4.1',
|
|
29697
29696
|
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.',
|
|
29698
29697
|
pricing: {
|
|
29699
|
-
prompt: pricing(`$
|
|
29700
|
-
output: pricing(`$
|
|
29698
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
29699
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
29701
29700
|
},
|
|
29702
29701
|
},
|
|
29703
29702
|
/**/
|
|
@@ -29708,8 +29707,8 @@
|
|
|
29708
29707
|
modelName: 'gpt-4.1-mini',
|
|
29709
29708
|
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.',
|
|
29710
29709
|
pricing: {
|
|
29711
|
-
prompt: pricing(`$0.
|
|
29712
|
-
output: pricing(`$
|
|
29710
|
+
prompt: pricing(`$0.40 / 1M tokens`),
|
|
29711
|
+
output: pricing(`$1.60 / 1M tokens`),
|
|
29713
29712
|
},
|
|
29714
29713
|
},
|
|
29715
29714
|
/**/
|
|
@@ -29720,8 +29719,8 @@
|
|
|
29720
29719
|
modelName: 'gpt-4.1-nano',
|
|
29721
29720
|
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.',
|
|
29722
29721
|
pricing: {
|
|
29723
|
-
prompt: pricing(`$0.
|
|
29724
|
-
output: pricing(`$0.
|
|
29722
|
+
prompt: pricing(`$0.10 / 1M tokens`),
|
|
29723
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
29725
29724
|
},
|
|
29726
29725
|
},
|
|
29727
29726
|
/**/
|
|
@@ -29732,8 +29731,8 @@
|
|
|
29732
29731
|
modelName: 'o3',
|
|
29733
29732
|
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.',
|
|
29734
29733
|
pricing: {
|
|
29735
|
-
prompt: pricing(`$
|
|
29736
|
-
output: pricing(`$
|
|
29734
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
29735
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
29737
29736
|
},
|
|
29738
29737
|
},
|
|
29739
29738
|
/**/
|
|
@@ -29744,8 +29743,8 @@
|
|
|
29744
29743
|
modelName: 'o3-pro',
|
|
29745
29744
|
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.',
|
|
29746
29745
|
pricing: {
|
|
29747
|
-
prompt: pricing(`$
|
|
29748
|
-
output: pricing(`$
|
|
29746
|
+
prompt: pricing(`$20.00 / 1M tokens`),
|
|
29747
|
+
output: pricing(`$80.00 / 1M tokens`),
|
|
29749
29748
|
},
|
|
29750
29749
|
},
|
|
29751
29750
|
/**/
|
|
@@ -29756,8 +29755,8 @@
|
|
|
29756
29755
|
modelName: 'o4-mini',
|
|
29757
29756
|
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.',
|
|
29758
29757
|
pricing: {
|
|
29759
|
-
prompt: pricing(`$
|
|
29760
|
-
output: pricing(`$
|
|
29758
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
29759
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
29761
29760
|
},
|
|
29762
29761
|
},
|
|
29763
29762
|
/**/
|
|
@@ -30115,8 +30114,8 @@
|
|
|
30115
30114
|
modelName: 'gpt-4o-2024-05-13',
|
|
30116
30115
|
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.',
|
|
30117
30116
|
pricing: {
|
|
30118
|
-
prompt: pricing(`$
|
|
30119
|
-
output: pricing(`$
|
|
30117
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
30118
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
30120
30119
|
},
|
|
30121
30120
|
},
|
|
30122
30121
|
/**/
|
|
@@ -30127,8 +30126,8 @@
|
|
|
30127
30126
|
modelName: 'gpt-4o',
|
|
30128
30127
|
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.",
|
|
30129
30128
|
pricing: {
|
|
30130
|
-
prompt: pricing(`$
|
|
30131
|
-
output: pricing(`$
|
|
30129
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
30130
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
30132
30131
|
},
|
|
30133
30132
|
},
|
|
30134
30133
|
/**/
|
|
@@ -30199,8 +30198,8 @@
|
|
|
30199
30198
|
modelName: 'o3-mini',
|
|
30200
30199
|
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.',
|
|
30201
30200
|
pricing: {
|
|
30202
|
-
prompt: pricing(`$
|
|
30203
|
-
output: pricing(`$
|
|
30201
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
30202
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
30204
30203
|
},
|
|
30205
30204
|
},
|
|
30206
30205
|
/**/
|
|
@@ -30300,53 +30299,6 @@
|
|
|
30300
30299
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
30301
30300
|
*/
|
|
30302
30301
|
|
|
30303
|
-
/**
|
|
30304
|
-
* Maps Promptbook tools to OpenAI tools.
|
|
30305
|
-
*
|
|
30306
|
-
* @private
|
|
30307
|
-
*/
|
|
30308
|
-
function mapToolsToOpenAi(tools) {
|
|
30309
|
-
return tools.map((tool) => ({
|
|
30310
|
-
type: 'function',
|
|
30311
|
-
function: {
|
|
30312
|
-
name: tool.name,
|
|
30313
|
-
description: tool.description,
|
|
30314
|
-
parameters: tool.parameters,
|
|
30315
|
-
},
|
|
30316
|
-
}));
|
|
30317
|
-
}
|
|
30318
|
-
|
|
30319
|
-
/**
|
|
30320
|
-
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
30321
|
-
*
|
|
30322
|
-
* @private utility of OpenAI tool execution wrappers
|
|
30323
|
-
*/
|
|
30324
|
-
function buildToolInvocationScript(options) {
|
|
30325
|
-
const { functionName, functionArgsExpression } = options;
|
|
30326
|
-
return `
|
|
30327
|
-
const args = ${functionArgsExpression};
|
|
30328
|
-
const runtimeContextRaw =
|
|
30329
|
-
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
30330
|
-
? undefined
|
|
30331
|
-
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
30332
|
-
|
|
30333
|
-
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
30334
|
-
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
30335
|
-
}
|
|
30336
|
-
|
|
30337
|
-
const toolProgressTokenRaw =
|
|
30338
|
-
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
30339
|
-
? undefined
|
|
30340
|
-
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
30341
|
-
|
|
30342
|
-
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
30343
|
-
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
30344
|
-
}
|
|
30345
|
-
|
|
30346
|
-
return await ${functionName}(args);
|
|
30347
|
-
`;
|
|
30348
|
-
}
|
|
30349
|
-
|
|
30350
30302
|
/**
|
|
30351
30303
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
30352
30304
|
*
|
|
@@ -30403,6 +30355,53 @@
|
|
|
30403
30355
|
errorMessage.includes('does not support'));
|
|
30404
30356
|
}
|
|
30405
30357
|
|
|
30358
|
+
/**
|
|
30359
|
+
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
30360
|
+
*
|
|
30361
|
+
* @private utility of OpenAI tool execution wrappers
|
|
30362
|
+
*/
|
|
30363
|
+
function buildToolInvocationScript(options) {
|
|
30364
|
+
const { functionName, functionArgsExpression } = options;
|
|
30365
|
+
return `
|
|
30366
|
+
const args = ${functionArgsExpression};
|
|
30367
|
+
const runtimeContextRaw =
|
|
30368
|
+
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
30369
|
+
? undefined
|
|
30370
|
+
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
30371
|
+
|
|
30372
|
+
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
30373
|
+
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
30374
|
+
}
|
|
30375
|
+
|
|
30376
|
+
const toolProgressTokenRaw =
|
|
30377
|
+
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
30378
|
+
? undefined
|
|
30379
|
+
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
30380
|
+
|
|
30381
|
+
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
30382
|
+
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
30383
|
+
}
|
|
30384
|
+
|
|
30385
|
+
return await ${functionName}(args);
|
|
30386
|
+
`;
|
|
30387
|
+
}
|
|
30388
|
+
|
|
30389
|
+
/**
|
|
30390
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
30391
|
+
*
|
|
30392
|
+
* @private
|
|
30393
|
+
*/
|
|
30394
|
+
function mapToolsToOpenAi(tools) {
|
|
30395
|
+
return tools.map((tool) => ({
|
|
30396
|
+
type: 'function',
|
|
30397
|
+
function: {
|
|
30398
|
+
name: tool.name,
|
|
30399
|
+
description: tool.description,
|
|
30400
|
+
parameters: tool.parameters,
|
|
30401
|
+
},
|
|
30402
|
+
}));
|
|
30403
|
+
}
|
|
30404
|
+
|
|
30406
30405
|
/**
|
|
30407
30406
|
* Provides access to the structured clone implementation when available.
|
|
30408
30407
|
*/
|
|
@@ -31369,7 +31368,7 @@
|
|
|
31369
31368
|
// Note: Match exact or prefix for model families
|
|
31370
31369
|
const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
|
|
31371
31370
|
if (model === undefined) {
|
|
31372
|
-
throw new PipelineExecutionError(
|
|
31371
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
31373
31372
|
Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
|
|
31374
31373
|
|
|
31375
31374
|
Available models:
|
|
@@ -32295,7 +32294,7 @@
|
|
|
32295
32294
|
}
|
|
32296
32295
|
}
|
|
32297
32296
|
|
|
32298
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5-
|
|
32297
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
|
|
32299
32298
|
/**
|
|
32300
32299
|
* Creates one structured log entry for streamed tool-call updates.
|
|
32301
32300
|
*
|
|
@@ -32790,7 +32789,7 @@
|
|
|
32790
32789
|
}),
|
|
32791
32790
|
],
|
|
32792
32791
|
};
|
|
32793
|
-
const errorMessage =
|
|
32792
|
+
const errorMessage = spacetrim.spaceTrim((block) => `
|
|
32794
32793
|
|
|
32795
32794
|
The invoked tool \`${functionName}\` failed with error:
|
|
32796
32795
|
|
|
@@ -33508,7 +33507,7 @@
|
|
|
33508
33507
|
assertsError(error);
|
|
33509
33508
|
const serializedError = serializeError(error);
|
|
33510
33509
|
errors = [serializedError];
|
|
33511
|
-
functionResponse =
|
|
33510
|
+
functionResponse = spacetrim.spaceTrim((block) => `
|
|
33512
33511
|
|
|
33513
33512
|
The invoked tool \`${functionName}\` failed with error:
|
|
33514
33513
|
|
|
@@ -34447,7 +34446,7 @@
|
|
|
34447
34446
|
if (commitment.type !== 'OPEN') {
|
|
34448
34447
|
continue;
|
|
34449
34448
|
}
|
|
34450
|
-
const trimmed =
|
|
34449
|
+
const trimmed = spacetrim.spaceTrim(commitment.content);
|
|
34451
34450
|
return trimmed || null;
|
|
34452
34451
|
}
|
|
34453
34452
|
return null;
|
|
@@ -34516,7 +34515,7 @@
|
|
|
34516
34515
|
if (isJsonSchemaResponseFormat(responseFormat)) {
|
|
34517
34516
|
const jsonSchema = responseFormat.json_schema;
|
|
34518
34517
|
const schemaJson = JSON.stringify(jsonSchema, null, 4);
|
|
34519
|
-
userMessageContent =
|
|
34518
|
+
userMessageContent = spacetrim.spaceTrim((block) => `
|
|
34520
34519
|
${block(prompt.content)}
|
|
34521
34520
|
|
|
34522
34521
|
NOTE Request was made through OpenAI Compatible API with \`response_format\` of type \`json_schema\` with the following schema:
|
|
@@ -34547,12 +34546,12 @@
|
|
|
34547
34546
|
const formattedAgentMessage = formatAgentMessageForJsonMode(result.content, usesJsonSchemaMode);
|
|
34548
34547
|
const teacherInstructions = extractOpenTeacherInstructions(agentSource);
|
|
34549
34548
|
const teacherInstructionsSection = teacherInstructions
|
|
34550
|
-
?
|
|
34549
|
+
? spacetrim.spaceTrim((block) => `
|
|
34551
34550
|
**Teacher instructions:**
|
|
34552
34551
|
${block(teacherInstructions)}
|
|
34553
34552
|
`)
|
|
34554
34553
|
: '';
|
|
34555
|
-
const teacherPromptContent =
|
|
34554
|
+
const teacherPromptContent = spacetrim.spaceTrim((block) => `
|
|
34556
34555
|
|
|
34557
34556
|
You are a teacher agent helping another agent to learn from its interactions.
|
|
34558
34557
|
|
|
@@ -34585,7 +34584,7 @@
|
|
|
34585
34584
|
? '- This interaction used JSON mode, so the agent answer should stay as a formatted JSON code block.'
|
|
34586
34585
|
: ''}
|
|
34587
34586
|
${block(isInitialMessageMissing
|
|
34588
|
-
?
|
|
34587
|
+
? spacetrim.spaceTrim(`
|
|
34589
34588
|
- The agent source does not have an INITIAL MESSAGE defined, generate one.
|
|
34590
34589
|
- 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.
|
|
34591
34590
|
- The quick option looks like \`[👋 Hello](?message=Hello, how are you?)\`
|
|
@@ -34628,7 +34627,7 @@
|
|
|
34628
34627
|
*/
|
|
34629
34628
|
appendToAgentSource(section) {
|
|
34630
34629
|
const currentSource = this.options.getAgentSource();
|
|
34631
|
-
const newSource = padBook(validateBook(
|
|
34630
|
+
const newSource = padBook(validateBook(spacetrim.spaceTrim(currentSource) + section));
|
|
34632
34631
|
this.options.updateAgentSource(newSource);
|
|
34633
34632
|
}
|
|
34634
34633
|
}
|
|
@@ -34656,13 +34655,13 @@
|
|
|
34656
34655
|
}
|
|
34657
34656
|
const parsedJson = tryParseJson(content);
|
|
34658
34657
|
if (parsedJson === null) {
|
|
34659
|
-
return
|
|
34658
|
+
return spacetrim.spaceTrim((block) => `
|
|
34660
34659
|
\`\`\`json
|
|
34661
34660
|
${block(content)}
|
|
34662
34661
|
\`\`\`
|
|
34663
34662
|
`);
|
|
34664
34663
|
}
|
|
34665
|
-
return
|
|
34664
|
+
return spacetrim.spaceTrim((block) => `
|
|
34666
34665
|
\`\`\`json
|
|
34667
34666
|
${block(JSON.stringify(parsedJson, null, 4))}
|
|
34668
34667
|
\`\`\`
|
|
@@ -34694,7 +34693,7 @@
|
|
|
34694
34693
|
const internalMessagesSection = options.internalMessages
|
|
34695
34694
|
.map((internalMessage) => formatInternalLearningMessage(internalMessage))
|
|
34696
34695
|
.join('\n\n');
|
|
34697
|
-
return
|
|
34696
|
+
return spacetrim.spaceTrim((block) => `
|
|
34698
34697
|
|
|
34699
34698
|
USER MESSAGE
|
|
34700
34699
|
${block(options.userMessageContent)}
|
|
@@ -34712,7 +34711,7 @@
|
|
|
34712
34711
|
* @private function of Agent
|
|
34713
34712
|
*/
|
|
34714
34713
|
function formatInternalLearningMessage(internalMessage) {
|
|
34715
|
-
return
|
|
34714
|
+
return spacetrim.spaceTrim((block) => `
|
|
34716
34715
|
INTERNAL MESSAGE
|
|
34717
34716
|
${block(stringifyInternalLearningPayload(internalMessage))}
|
|
34718
34717
|
`);
|
|
@@ -35216,7 +35215,7 @@
|
|
|
35216
35215
|
const bookString = prompt(strings, ...values).toString();
|
|
35217
35216
|
if (!isValidPipelineString(bookString)) {
|
|
35218
35217
|
// TODO: Make the CustomError for this
|
|
35219
|
-
throw new Error(
|
|
35218
|
+
throw new Error(spacetrim.spaceTrim(`
|
|
35220
35219
|
The string is not a valid pipeline string
|
|
35221
35220
|
|
|
35222
35221
|
book\`
|
|
@@ -35226,7 +35225,7 @@
|
|
|
35226
35225
|
}
|
|
35227
35226
|
if (!isValidBook(bookString)) {
|
|
35228
35227
|
// TODO: Make the CustomError for this
|
|
35229
|
-
throw new Error(
|
|
35228
|
+
throw new Error(spacetrim.spaceTrim(`
|
|
35230
35229
|
The string is not a valid book
|
|
35231
35230
|
|
|
35232
35231
|
book\`
|
|
@@ -35495,7 +35494,7 @@
|
|
|
35495
35494
|
.filter((line) => Boolean(line))
|
|
35496
35495
|
.join('\n');
|
|
35497
35496
|
const personaBlock = profile.personaDescription
|
|
35498
|
-
?
|
|
35497
|
+
? spacetrim.spaceTrim((block) => `
|
|
35499
35498
|
PERSONA
|
|
35500
35499
|
${block(profile.personaDescription || '')}
|
|
35501
35500
|
`)
|
|
@@ -35531,7 +35530,7 @@
|
|
|
35531
35530
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
35532
35531
|
// <- TODO: [🐱🚀] Maybe use promptbookFetch
|
|
35533
35532
|
if (!profileResponse.ok) {
|
|
35534
|
-
throw new Error(
|
|
35533
|
+
throw new Error(spacetrim.spaceTrim((block) => `
|
|
35535
35534
|
Failed to fetch remote agent profile:
|
|
35536
35535
|
|
|
35537
35536
|
Agent URL:
|
|
@@ -38578,11 +38577,11 @@
|
|
|
38578
38577
|
});
|
|
38579
38578
|
}
|
|
38580
38579
|
const decodedPrompt = decodePrompt(rawPrompt);
|
|
38581
|
-
const prompt =
|
|
38580
|
+
const prompt = spacetrim.spaceTrim(decodedPrompt) || decodedPrompt || 'Generated image';
|
|
38582
38581
|
const decodedAlt = decodePrompt(alt);
|
|
38583
38582
|
segments.push({
|
|
38584
38583
|
type: 'image',
|
|
38585
|
-
alt:
|
|
38584
|
+
alt: spacetrim.spaceTrim(decodedAlt) || 'Generated image',
|
|
38586
38585
|
prompt,
|
|
38587
38586
|
});
|
|
38588
38587
|
lastIndex = start + fullMatch.length;
|
|
@@ -39218,7 +39217,7 @@
|
|
|
39218
39217
|
*/
|
|
39219
39218
|
function constructImageFilename(params) {
|
|
39220
39219
|
const { prompt, model, size, quality, style, attachments } = params;
|
|
39221
|
-
const promptTrimmed =
|
|
39220
|
+
const promptTrimmed = spacetrim.spaceTrim(prompt);
|
|
39222
39221
|
return (promptTrimmed
|
|
39223
39222
|
.toLowerCase()
|
|
39224
39223
|
.replace(/[^a-z0-9]+/g, '-')
|
|
@@ -39282,7 +39281,7 @@
|
|
|
39282
39281
|
* @private internal component of `<ChatMessageItem/>`
|
|
39283
39282
|
*/
|
|
39284
39283
|
function ImagePromptRenderer({ alt, prompt }) {
|
|
39285
|
-
const trimmedPrompt = react.useMemo(() =>
|
|
39284
|
+
const trimmedPrompt = react.useMemo(() => spacetrim.spaceTrim(prompt), [prompt]);
|
|
39286
39285
|
const filename = react.useMemo(() => constructImageFilename({
|
|
39287
39286
|
prompt: trimmedPrompt,
|
|
39288
39287
|
}), [trimmedPrompt]);
|
|
@@ -42944,7 +42943,7 @@
|
|
|
42944
42943
|
id: AGENT_CHAT_INITIAL_MESSAGE_ID,
|
|
42945
42944
|
sender: 'AGENT',
|
|
42946
42945
|
content: agent.initialMessage ||
|
|
42947
|
-
|
|
42946
|
+
spacetrim.spaceTrim(`
|
|
42948
42947
|
|
|
42949
42948
|
Hello! I am ${agent.meta.fullname || agent.agentName || 'an AI Agent'}.
|
|
42950
42949
|
|