@promptbook/components 0.112.0-12 → 0.112.0-15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +289 -207
- 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/commitments/USE_BROWSER/resolveRunBrowserToolForNode.d.ts +1 -1
- package/esm/src/commitments/USE_TIMEOUT/TimeoutToolNames.d.ts +1 -0
- package/esm/src/commitments/USE_TIMEOUT/TimeoutToolRuntimeAdapter.d.ts +51 -2
- package/esm/src/commitments/USE_TIMEOUT/USE_TIMEOUT.d.ts +2 -2
- package/esm/src/commitments/USE_TIMEOUT/getTimeoutToolRuntimeAdapterOrDisabledResult.d.ts +2 -2
- package/esm/src/commitments/USE_TIMEOUT/parseTimeoutToolArgs.d.ts +14 -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 +456 -375
- 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/commitments/USE_BROWSER/resolveRunBrowserToolForNode.d.ts +1 -1
- package/umd/src/commitments/USE_TIMEOUT/TimeoutToolNames.d.ts +1 -0
- package/umd/src/commitments/USE_TIMEOUT/TimeoutToolRuntimeAdapter.d.ts +51 -2
- package/umd/src/commitments/USE_TIMEOUT/USE_TIMEOUT.d.ts +2 -2
- package/umd/src/commitments/USE_TIMEOUT/getTimeoutToolRuntimeAdapterOrDisabledResult.d.ts +2 -2
- package/umd/src/commitments/USE_TIMEOUT/parseTimeoutToolArgs.d.ts +14 -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-15';
|
|
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,12 +15530,12 @@
|
|
|
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.
|
|
15537
|
+
- "cancel_timeout" accepts a timeout id from any chat in this same user+agent scope.
|
|
15538
15538
|
- When one timeout elapses, you will receive a new user-like message that explicitly says it is a timeout wake-up and includes the \`timeoutId\`.
|
|
15539
|
-
- Use "cancel_timeout" when a previously scheduled timeout is no longer relevant.
|
|
15540
15539
|
- Do not claim a timer was set or cancelled unless the tool confirms it.
|
|
15541
15540
|
${block(extraInstructions)}
|
|
15542
15541
|
`);
|
|
@@ -15597,13 +15596,6 @@
|
|
|
15597
15596
|
* @private internal utility of USE TIMEOUT
|
|
15598
15597
|
*/
|
|
15599
15598
|
function createDisabledTimeoutResult(action, message) {
|
|
15600
|
-
if (action === 'set') {
|
|
15601
|
-
return {
|
|
15602
|
-
action,
|
|
15603
|
-
status: 'disabled',
|
|
15604
|
-
message,
|
|
15605
|
-
};
|
|
15606
|
-
}
|
|
15607
15599
|
return {
|
|
15608
15600
|
action,
|
|
15609
15601
|
status: 'disabled',
|
|
@@ -15630,6 +15622,18 @@
|
|
|
15630
15622
|
}
|
|
15631
15623
|
}
|
|
15632
15624
|
|
|
15625
|
+
/**
|
|
15626
|
+
* Default number of rows returned by `list_timeouts`.
|
|
15627
|
+
*
|
|
15628
|
+
* @private internal USE TIMEOUT constant
|
|
15629
|
+
*/
|
|
15630
|
+
const DEFAULT_LIST_TIMEOUTS_LIMIT = 20;
|
|
15631
|
+
/**
|
|
15632
|
+
* Hard cap for `list_timeouts` page size.
|
|
15633
|
+
*
|
|
15634
|
+
* @private internal USE TIMEOUT constant
|
|
15635
|
+
*/
|
|
15636
|
+
const MAX_LIST_TIMEOUTS_LIMIT = 100;
|
|
15633
15637
|
/**
|
|
15634
15638
|
* Parses and validates `USE TIMEOUT` tool arguments.
|
|
15635
15639
|
*
|
|
@@ -15642,7 +15646,7 @@
|
|
|
15642
15646
|
set(args) {
|
|
15643
15647
|
const parsedMilliseconds = Number(args.milliseconds);
|
|
15644
15648
|
if (!Number.isFinite(parsedMilliseconds) || parsedMilliseconds <= 0) {
|
|
15645
|
-
throw new PipelineExecutionError(
|
|
15649
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15646
15650
|
Timeout \`milliseconds\` must be a positive number.
|
|
15647
15651
|
`));
|
|
15648
15652
|
}
|
|
@@ -15658,12 +15662,37 @@
|
|
|
15658
15662
|
cancel(args) {
|
|
15659
15663
|
const timeoutId = typeof args.timeoutId === 'string' ? args.timeoutId.trim() : '';
|
|
15660
15664
|
if (!timeoutId) {
|
|
15661
|
-
throw new PipelineExecutionError(
|
|
15665
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15662
15666
|
Timeout \`timeoutId\` is required.
|
|
15663
15667
|
`));
|
|
15664
15668
|
}
|
|
15665
15669
|
return { timeoutId };
|
|
15666
15670
|
},
|
|
15671
|
+
/**
|
|
15672
|
+
* Parses `list_timeouts` input.
|
|
15673
|
+
*/
|
|
15674
|
+
list(args) {
|
|
15675
|
+
if (args.includeFinished !== undefined && typeof args.includeFinished !== 'boolean') {
|
|
15676
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15677
|
+
Timeout \`includeFinished\` must be a boolean when provided.
|
|
15678
|
+
`));
|
|
15679
|
+
}
|
|
15680
|
+
const parsedLimit = args.limit === undefined ? DEFAULT_LIST_TIMEOUTS_LIMIT : Math.floor(Number(args.limit));
|
|
15681
|
+
if (!Number.isFinite(parsedLimit) || parsedLimit <= 0) {
|
|
15682
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15683
|
+
Timeout \`limit\` must be a positive number.
|
|
15684
|
+
`));
|
|
15685
|
+
}
|
|
15686
|
+
if (parsedLimit > MAX_LIST_TIMEOUTS_LIMIT) {
|
|
15687
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim(`
|
|
15688
|
+
Timeout \`limit\` must be at most \`${MAX_LIST_TIMEOUTS_LIMIT}\`.
|
|
15689
|
+
`));
|
|
15690
|
+
}
|
|
15691
|
+
return {
|
|
15692
|
+
includeFinished: args.includeFinished === true,
|
|
15693
|
+
limit: parsedLimit,
|
|
15694
|
+
};
|
|
15695
|
+
},
|
|
15667
15696
|
};
|
|
15668
15697
|
|
|
15669
15698
|
/**
|
|
@@ -15674,6 +15703,7 @@
|
|
|
15674
15703
|
const TimeoutToolNames = {
|
|
15675
15704
|
set: 'set_timeout',
|
|
15676
15705
|
cancel: 'cancel_timeout',
|
|
15706
|
+
list: 'list_timeouts',
|
|
15677
15707
|
};
|
|
15678
15708
|
|
|
15679
15709
|
/**
|
|
@@ -15773,6 +15803,35 @@
|
|
|
15773
15803
|
return JSON.stringify(result);
|
|
15774
15804
|
}
|
|
15775
15805
|
},
|
|
15806
|
+
async [TimeoutToolNames.list](args) {
|
|
15807
|
+
const runtimeContext = resolveTimeoutRuntimeContext(args);
|
|
15808
|
+
const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('list', runtimeContext);
|
|
15809
|
+
if (!adapter || disabledResult) {
|
|
15810
|
+
return JSON.stringify(disabledResult);
|
|
15811
|
+
}
|
|
15812
|
+
try {
|
|
15813
|
+
const parsedArgs = parseTimeoutToolArgs.list(args);
|
|
15814
|
+
const listedTimeouts = await adapter.listTimeouts(parsedArgs, runtimeContext);
|
|
15815
|
+
const result = {
|
|
15816
|
+
action: 'list',
|
|
15817
|
+
status: 'listed',
|
|
15818
|
+
items: listedTimeouts.items,
|
|
15819
|
+
total: listedTimeouts.total,
|
|
15820
|
+
};
|
|
15821
|
+
return createToolExecutionEnvelope({
|
|
15822
|
+
assistantMessage: listedTimeouts.total === 1 ? 'Found 1 timeout.' : `Found ${listedTimeouts.total} timeouts.`,
|
|
15823
|
+
toolResult: result,
|
|
15824
|
+
});
|
|
15825
|
+
}
|
|
15826
|
+
catch (error) {
|
|
15827
|
+
const result = {
|
|
15828
|
+
action: 'list',
|
|
15829
|
+
status: 'error',
|
|
15830
|
+
message: error instanceof Error ? error.message : String(error),
|
|
15831
|
+
};
|
|
15832
|
+
return JSON.stringify(result);
|
|
15833
|
+
}
|
|
15834
|
+
},
|
|
15776
15835
|
};
|
|
15777
15836
|
}
|
|
15778
15837
|
|
|
@@ -15806,26 +15865,45 @@
|
|
|
15806
15865
|
if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
|
|
15807
15866
|
tools.push({
|
|
15808
15867
|
name: TimeoutToolNames.cancel,
|
|
15809
|
-
description: 'Cancel one previously scheduled timeout
|
|
15868
|
+
description: 'Cancel one previously scheduled timeout within the same user+agent scope, even if it was set in another chat.',
|
|
15810
15869
|
parameters: {
|
|
15811
15870
|
type: 'object',
|
|
15812
15871
|
properties: {
|
|
15813
15872
|
timeoutId: {
|
|
15814
15873
|
type: 'string',
|
|
15815
|
-
description: 'Identifier returned earlier by `set_timeout`.',
|
|
15874
|
+
description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
|
|
15816
15875
|
},
|
|
15817
15876
|
},
|
|
15818
15877
|
required: ['timeoutId'],
|
|
15819
15878
|
},
|
|
15820
15879
|
});
|
|
15821
15880
|
}
|
|
15881
|
+
if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
|
|
15882
|
+
tools.push({
|
|
15883
|
+
name: TimeoutToolNames.list,
|
|
15884
|
+
description: 'List scheduled timeouts across all chats for this same user+agent scope so they can be reviewed or cancelled.',
|
|
15885
|
+
parameters: {
|
|
15886
|
+
type: 'object',
|
|
15887
|
+
properties: {
|
|
15888
|
+
includeFinished: {
|
|
15889
|
+
type: 'boolean',
|
|
15890
|
+
description: 'When true, include completed, failed, and cancelled rows in addition to active timeouts.',
|
|
15891
|
+
},
|
|
15892
|
+
limit: {
|
|
15893
|
+
type: 'number',
|
|
15894
|
+
description: 'Maximum number of rows to return (default 20, max 100).',
|
|
15895
|
+
},
|
|
15896
|
+
},
|
|
15897
|
+
},
|
|
15898
|
+
});
|
|
15899
|
+
}
|
|
15822
15900
|
return tools;
|
|
15823
15901
|
}
|
|
15824
15902
|
|
|
15825
15903
|
/**
|
|
15826
15904
|
* `USE TIMEOUT` commitment definition.
|
|
15827
15905
|
*
|
|
15828
|
-
* The `USE TIMEOUT` commitment enables
|
|
15906
|
+
* The `USE TIMEOUT` commitment enables timeout wake-ups and scoped timeout management.
|
|
15829
15907
|
*
|
|
15830
15908
|
* @private [🪔] Maybe export the commitments through some package
|
|
15831
15909
|
*/
|
|
@@ -15840,7 +15918,7 @@
|
|
|
15840
15918
|
* Short one-line description of `USE TIMEOUT`.
|
|
15841
15919
|
*/
|
|
15842
15920
|
get description() {
|
|
15843
|
-
return 'Enable
|
|
15921
|
+
return 'Enable timeout wake-ups plus scoped timeout listing/cancellation across chats.';
|
|
15844
15922
|
}
|
|
15845
15923
|
/**
|
|
15846
15924
|
* Icon for this commitment.
|
|
@@ -15852,17 +15930,18 @@
|
|
|
15852
15930
|
* Markdown documentation for `USE TIMEOUT`.
|
|
15853
15931
|
*/
|
|
15854
15932
|
get documentation() {
|
|
15855
|
-
return
|
|
15933
|
+
return spacetrim.spaceTrim(`
|
|
15856
15934
|
# USE TIMEOUT
|
|
15857
15935
|
|
|
15858
|
-
Enables
|
|
15936
|
+
Enables timeout wake-ups and timeout management for the same user+agent scope.
|
|
15859
15937
|
|
|
15860
15938
|
## Key aspects
|
|
15861
15939
|
|
|
15862
15940
|
- The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
|
|
15863
15941
|
- The tool returns immediately while the timeout is stored and executed by the runtime later.
|
|
15864
15942
|
- The wake-up arrives as a new user-like timeout message in the same conversation.
|
|
15865
|
-
- The agent can
|
|
15943
|
+
- The agent can inspect known timeouts via \`list_timeouts\`.
|
|
15944
|
+
- The agent can cancel an existing timeout by \`timeoutId\` via \`cancel_timeout\`, including timeouts created in another chat.
|
|
15866
15945
|
- Commitment content is treated as optional timeout policy instructions.
|
|
15867
15946
|
|
|
15868
15947
|
## Examples
|
|
@@ -15891,6 +15970,7 @@
|
|
|
15891
15970
|
return {
|
|
15892
15971
|
[TimeoutToolNames.set]: 'Set timer',
|
|
15893
15972
|
[TimeoutToolNames.cancel]: 'Cancel timer',
|
|
15973
|
+
[TimeoutToolNames.list]: 'List timers',
|
|
15894
15974
|
};
|
|
15895
15975
|
}
|
|
15896
15976
|
/**
|
|
@@ -15941,7 +16021,7 @@
|
|
|
15941
16021
|
* Markdown documentation for USE TIME commitment.
|
|
15942
16022
|
*/
|
|
15943
16023
|
get documentation() {
|
|
15944
|
-
return
|
|
16024
|
+
return spacetrim.spaceTrim(`
|
|
15945
16025
|
# USE TIME
|
|
15946
16026
|
|
|
15947
16027
|
Enables the agent to determine the current date and time.
|
|
@@ -16002,7 +16082,7 @@
|
|
|
16002
16082
|
_metadata: {
|
|
16003
16083
|
...requirements._metadata,
|
|
16004
16084
|
},
|
|
16005
|
-
},
|
|
16085
|
+
}, spacetrim.spaceTrim((block) => `
|
|
16006
16086
|
Time and date context:
|
|
16007
16087
|
- It is ${moment__default["default"]().format('MMMM YYYY')} now.
|
|
16008
16088
|
- If you need more precise current time information, use the tool "get_current_time".
|
|
@@ -16170,7 +16250,7 @@
|
|
|
16170
16250
|
* Markdown documentation for USE USER LOCATION commitment.
|
|
16171
16251
|
*/
|
|
16172
16252
|
get documentation() {
|
|
16173
|
-
return
|
|
16253
|
+
return spacetrim.spaceTrim(`
|
|
16174
16254
|
# USE USER LOCATION
|
|
16175
16255
|
|
|
16176
16256
|
Enables the agent to retrieve the user's location from runtime context.
|
|
@@ -16208,7 +16288,7 @@
|
|
|
16208
16288
|
...existingTools,
|
|
16209
16289
|
{
|
|
16210
16290
|
name: GET_USER_LOCATION_TOOL_NAME,
|
|
16211
|
-
description:
|
|
16291
|
+
description: spacetrim.spaceTrim(`
|
|
16212
16292
|
Retrieves user location shared by browser runtime (if permission is granted).
|
|
16213
16293
|
Returns JSON status with coordinates and metadata when available.
|
|
16214
16294
|
`),
|
|
@@ -16226,7 +16306,7 @@
|
|
|
16226
16306
|
...requirements._metadata,
|
|
16227
16307
|
useUserLocation: content || true,
|
|
16228
16308
|
},
|
|
16229
|
-
},
|
|
16309
|
+
}, spacetrim.spaceTrim((block) => `
|
|
16230
16310
|
User location:
|
|
16231
16311
|
- Use "${GET_USER_LOCATION_TOOL_NAME}" only when location is needed for a better answer.
|
|
16232
16312
|
- If the tool returns "unavailable" or "permission-denied", ask user to share location or provide city manually.
|
|
@@ -16303,7 +16383,7 @@
|
|
|
16303
16383
|
* Markdown documentation for `WRITING RULES`.
|
|
16304
16384
|
*/
|
|
16305
16385
|
get documentation() {
|
|
16306
|
-
return
|
|
16386
|
+
return spacetrim.spaceTrim(`
|
|
16307
16387
|
# ${this.type}
|
|
16308
16388
|
|
|
16309
16389
|
Adds instructions that apply strictly to how the agent writes.
|
|
@@ -16381,7 +16461,7 @@
|
|
|
16381
16461
|
* Markdown documentation for `WRITING SAMPLE`.
|
|
16382
16462
|
*/
|
|
16383
16463
|
get documentation() {
|
|
16384
|
-
return
|
|
16464
|
+
return spacetrim.spaceTrim(`
|
|
16385
16465
|
# ${this.type}
|
|
16386
16466
|
|
|
16387
16467
|
Provides explicit 1:1 sample text that demonstrates how the agent should sound.
|
|
@@ -16453,7 +16533,7 @@
|
|
|
16453
16533
|
* Markdown documentation available at runtime.
|
|
16454
16534
|
*/
|
|
16455
16535
|
get documentation() {
|
|
16456
|
-
return
|
|
16536
|
+
return spacetrim.spaceTrim(`
|
|
16457
16537
|
# ${this.type}
|
|
16458
16538
|
|
|
16459
16539
|
This commitment is not yet fully implemented.
|
|
@@ -16698,7 +16778,7 @@
|
|
|
16698
16778
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
16699
16779
|
commitments.push({
|
|
16700
16780
|
type: currentCommitment.type,
|
|
16701
|
-
content:
|
|
16781
|
+
content: spacetrim.spaceTrim(fullContent),
|
|
16702
16782
|
originalLine: currentCommitment.originalStartLine,
|
|
16703
16783
|
lineNumber: currentCommitment.startLineNumber,
|
|
16704
16784
|
});
|
|
@@ -16726,7 +16806,7 @@
|
|
|
16726
16806
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
16727
16807
|
commitments.push({
|
|
16728
16808
|
type: currentCommitment.type,
|
|
16729
|
-
content:
|
|
16809
|
+
content: spacetrim.spaceTrim(fullContent),
|
|
16730
16810
|
originalLine: currentCommitment.originalStartLine,
|
|
16731
16811
|
lineNumber: currentCommitment.startLineNumber,
|
|
16732
16812
|
});
|
|
@@ -16752,7 +16832,7 @@
|
|
|
16752
16832
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
16753
16833
|
commitments.push({
|
|
16754
16834
|
type: currentCommitment.type,
|
|
16755
|
-
content:
|
|
16835
|
+
content: spacetrim.spaceTrim(fullContent),
|
|
16756
16836
|
originalLine: currentCommitment.originalStartLine,
|
|
16757
16837
|
lineNumber: currentCommitment.startLineNumber,
|
|
16758
16838
|
});
|
|
@@ -16985,7 +17065,7 @@
|
|
|
16985
17065
|
continue;
|
|
16986
17066
|
}
|
|
16987
17067
|
if (commitment.type === 'FROM') {
|
|
16988
|
-
const content =
|
|
17068
|
+
const content = spacetrim.spaceTrim(commitment.content).split(/\r?\n/)[0] || '';
|
|
16989
17069
|
if (content === 'Adam' || content === '' /* <- Note: Adam is implicit */) {
|
|
16990
17070
|
continue;
|
|
16991
17071
|
}
|
|
@@ -17008,7 +17088,7 @@
|
|
|
17008
17088
|
continue;
|
|
17009
17089
|
}
|
|
17010
17090
|
if (commitment.type === 'IMPORT') {
|
|
17011
|
-
const content =
|
|
17091
|
+
const content = spacetrim.spaceTrim(commitment.content).split(/\r?\n/)[0] || '';
|
|
17012
17092
|
let label = content;
|
|
17013
17093
|
let iconName = 'ExternalLink'; // Import remote
|
|
17014
17094
|
try {
|
|
@@ -17046,7 +17126,7 @@
|
|
|
17046
17126
|
continue;
|
|
17047
17127
|
}
|
|
17048
17128
|
if (commitment.type === 'KNOWLEDGE') {
|
|
17049
|
-
const content =
|
|
17129
|
+
const content = spacetrim.spaceTrim(commitment.content);
|
|
17050
17130
|
const extractedUrls = extractUrlsFromText(content);
|
|
17051
17131
|
let label = content;
|
|
17052
17132
|
let iconName = 'Book';
|
|
@@ -17105,7 +17185,7 @@
|
|
|
17105
17185
|
continue;
|
|
17106
17186
|
}
|
|
17107
17187
|
if (commitment.type === 'META LINK') {
|
|
17108
|
-
const linkValue =
|
|
17188
|
+
const linkValue = spacetrim.spaceTrim(commitment.content);
|
|
17109
17189
|
links.push(linkValue);
|
|
17110
17190
|
meta.link = linkValue;
|
|
17111
17191
|
continue;
|
|
@@ -17115,11 +17195,11 @@
|
|
|
17115
17195
|
continue;
|
|
17116
17196
|
}
|
|
17117
17197
|
if (commitment.type === 'META IMAGE') {
|
|
17118
|
-
meta.image =
|
|
17198
|
+
meta.image = spacetrim.spaceTrim(commitment.content);
|
|
17119
17199
|
continue;
|
|
17120
17200
|
}
|
|
17121
17201
|
if (commitment.type === 'META DESCRIPTION') {
|
|
17122
|
-
meta.description =
|
|
17202
|
+
meta.description = spacetrim.spaceTrim(commitment.content);
|
|
17123
17203
|
continue;
|
|
17124
17204
|
}
|
|
17125
17205
|
if (commitment.type === 'META DISCLAIMER') {
|
|
@@ -17127,7 +17207,7 @@
|
|
|
17127
17207
|
continue;
|
|
17128
17208
|
}
|
|
17129
17209
|
if (commitment.type === 'META INPUT PLACEHOLDER') {
|
|
17130
|
-
meta.inputPlaceholder =
|
|
17210
|
+
meta.inputPlaceholder = spacetrim.spaceTrim(commitment.content);
|
|
17131
17211
|
continue;
|
|
17132
17212
|
}
|
|
17133
17213
|
if (commitment.type === 'MESSAGE SUFFIX') {
|
|
@@ -17143,7 +17223,7 @@
|
|
|
17143
17223
|
continue;
|
|
17144
17224
|
}
|
|
17145
17225
|
if (commitment.type === 'META VOICE') {
|
|
17146
|
-
meta.voice =
|
|
17226
|
+
meta.voice = spacetrim.spaceTrim(commitment.content);
|
|
17147
17227
|
continue;
|
|
17148
17228
|
}
|
|
17149
17229
|
if (commitment.type !== 'META') {
|
|
@@ -17152,10 +17232,10 @@
|
|
|
17152
17232
|
// Parse META commitments - format is "META TYPE content"
|
|
17153
17233
|
const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
|
|
17154
17234
|
if (metaTypeRaw === 'LINK') {
|
|
17155
|
-
links.push(
|
|
17235
|
+
links.push(spacetrim.spaceTrim(commitment.content.substring(metaTypeRaw.length)));
|
|
17156
17236
|
}
|
|
17157
17237
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
17158
|
-
meta[metaType] =
|
|
17238
|
+
meta[metaType] = spacetrim.spaceTrim(commitment.content.substring(metaTypeRaw.length));
|
|
17159
17239
|
}
|
|
17160
17240
|
// Generate fullname fallback if no meta fullname specified
|
|
17161
17241
|
if (!meta.fullname) {
|
|
@@ -17186,7 +17266,7 @@
|
|
|
17186
17266
|
* @returns The content with normalized separators
|
|
17187
17267
|
*/
|
|
17188
17268
|
function normalizeSeparator(content) {
|
|
17189
|
-
const trimmed =
|
|
17269
|
+
const trimmed = spacetrim.spaceTrim(content);
|
|
17190
17270
|
if (trimmed.includes(',')) {
|
|
17191
17271
|
return trimmed;
|
|
17192
17272
|
}
|
|
@@ -17199,7 +17279,7 @@
|
|
|
17199
17279
|
* @returns Normalized domain or a trimmed fallback.
|
|
17200
17280
|
*/
|
|
17201
17281
|
function normalizeMetaDomain(content) {
|
|
17202
|
-
const trimmed =
|
|
17282
|
+
const trimmed = spacetrim.spaceTrim(content);
|
|
17203
17283
|
return normalizeDomainForMatching(trimmed) || trimmed.toLowerCase();
|
|
17204
17284
|
}
|
|
17205
17285
|
/**
|
|
@@ -17340,7 +17420,7 @@
|
|
|
17340
17420
|
* @deprecated Use `$generateBookBoilerplate` instead
|
|
17341
17421
|
* @public exported from `@promptbook/core`
|
|
17342
17422
|
*/
|
|
17343
|
-
const DEFAULT_BOOK = padBook(validateBook(
|
|
17423
|
+
const DEFAULT_BOOK = padBook(validateBook(spacetrim.spaceTrim(`
|
|
17344
17424
|
AI Avatar
|
|
17345
17425
|
|
|
17346
17426
|
PERSONA A friendly AI assistant that helps you with your tasks
|
|
@@ -18135,7 +18215,7 @@
|
|
|
18135
18215
|
function aboutPromptbookInformation(options) {
|
|
18136
18216
|
const { isServersInfoIncluded = true, isRuntimeEnvironmentInfoIncluded = true } = options || {};
|
|
18137
18217
|
const fullInfoPieces = [];
|
|
18138
|
-
const basicInfo =
|
|
18218
|
+
const basicInfo = spacetrim.spaceTrim(`
|
|
18139
18219
|
|
|
18140
18220
|
# ${NAME}
|
|
18141
18221
|
|
|
@@ -18147,7 +18227,7 @@
|
|
|
18147
18227
|
`);
|
|
18148
18228
|
fullInfoPieces.push(basicInfo);
|
|
18149
18229
|
if (isServersInfoIncluded) {
|
|
18150
|
-
const serversInfo =
|
|
18230
|
+
const serversInfo = spacetrim.spaceTrim((block) => `
|
|
18151
18231
|
|
|
18152
18232
|
## Servers
|
|
18153
18233
|
|
|
@@ -18161,7 +18241,7 @@
|
|
|
18161
18241
|
...runtimeEnvironment,
|
|
18162
18242
|
isCostPrevented: IS_COST_PREVENTED,
|
|
18163
18243
|
};
|
|
18164
|
-
const environmentInfo =
|
|
18244
|
+
const environmentInfo = spacetrim.spaceTrim((block) => `
|
|
18165
18245
|
|
|
18166
18246
|
## Environment
|
|
18167
18247
|
|
|
@@ -18171,7 +18251,7 @@
|
|
|
18171
18251
|
`);
|
|
18172
18252
|
fullInfoPieces.push(environmentInfo);
|
|
18173
18253
|
}
|
|
18174
|
-
const fullInfo =
|
|
18254
|
+
const fullInfo = spacetrim.spaceTrim(fullInfoPieces.join('\n\n'));
|
|
18175
18255
|
return fullInfo;
|
|
18176
18256
|
}
|
|
18177
18257
|
/**
|
|
@@ -21454,7 +21534,7 @@
|
|
|
21454
21534
|
const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
21455
21535
|
return luminance > 186 ? '#0f172a' : '#f8fafc';
|
|
21456
21536
|
}
|
|
21457
|
-
const HERO_ILLUSTRATION_SVG =
|
|
21537
|
+
const HERO_ILLUSTRATION_SVG = spacetrim.spaceTrim(() => `
|
|
21458
21538
|
<svg width="320" height="220" viewBox="0 0 320 220" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
21459
21539
|
<defs>
|
|
21460
21540
|
<linearGradient id="heroGradient" x1="0" y1="0" x2="320" y2="220">
|
|
@@ -21472,7 +21552,7 @@
|
|
|
21472
21552
|
<rect x="62" y="130" width="196" height="20" rx="10" fill="rgba(255,255,255,0.15)" />
|
|
21473
21553
|
</svg>
|
|
21474
21554
|
`);
|
|
21475
|
-
const BRAND_MARK_SVG =
|
|
21555
|
+
const BRAND_MARK_SVG = spacetrim.spaceTrim(() => `
|
|
21476
21556
|
<svg width="92" height="92" viewBox="0 0 92 92" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
21477
21557
|
<defs>
|
|
21478
21558
|
<linearGradient id="badgeGradient" x1="0" y1="0" x2="92" y2="92">
|
|
@@ -21622,7 +21702,7 @@
|
|
|
21622
21702
|
const href = hasUrl ? ` href="${escapeHtml$1((_a = attachment.url) !== null && _a !== void 0 ? _a : '#')}" target="_blank" rel="noopener"` : '';
|
|
21623
21703
|
const name = escapeHtml$1(attachment.name || 'Attachment');
|
|
21624
21704
|
const meta = escapeHtml$1(attachment.type || 'file');
|
|
21625
|
-
return
|
|
21705
|
+
return spacetrim.spaceTrim(`
|
|
21626
21706
|
<${tag} class="attachment-chip"${href}>
|
|
21627
21707
|
<span class="attachment-icon">📎</span>
|
|
21628
21708
|
<span class="attachment-name">${name}</span>
|
|
@@ -21647,7 +21727,7 @@
|
|
|
21647
21727
|
const urlLink = citation.url
|
|
21648
21728
|
? `<a class="citation-link" href="${escapeHtml$1(citation.url)}" target="_blank" rel="noopener">Open source</a>`
|
|
21649
21729
|
: '';
|
|
21650
|
-
return
|
|
21730
|
+
return spacetrim.spaceTrim(`
|
|
21651
21731
|
<article class="citation-chip">
|
|
21652
21732
|
<div class="citation-header">
|
|
21653
21733
|
<span class="citation-badge">${escapeHtml$1(citation.id)}</span>
|
|
@@ -21679,7 +21759,7 @@
|
|
|
21679
21759
|
const avatarMarkup = visuals.avatarSrc
|
|
21680
21760
|
? `<img class="message-avatar-img" src="${escapeHtml$1(visuals.avatarSrc)}" alt="${escapeHtml$1(visuals.displayName)}" />`
|
|
21681
21761
|
: `<span class="message-avatar-fallback" style="background:${visuals.accentColor};color:${bubbleTextColor};">${escapeHtml$1(visuals.avatarLabel)}</span>`;
|
|
21682
|
-
return
|
|
21762
|
+
return spacetrim.spaceTrim(`
|
|
21683
21763
|
<article class="message-block ${alignmentClass}">
|
|
21684
21764
|
<div class="message-avatar">${avatarMarkup}</div>
|
|
21685
21765
|
<div class="message-card" style="--bubble-color:${visuals.accentColor};--bubble-text:${bubbleTextColor};">
|
|
@@ -21730,7 +21810,7 @@
|
|
|
21730
21810
|
const messageMarkup = messages.length > 0
|
|
21731
21811
|
? messages.map((message) => renderMessageBlock(message, participantLookup)).join('')
|
|
21732
21812
|
: '<div class="empty-state">No messages yet. Send a note to capture this chat.</div>';
|
|
21733
|
-
return
|
|
21813
|
+
return spacetrim.spaceTrim(`
|
|
21734
21814
|
<!DOCTYPE html>
|
|
21735
21815
|
<html lang="en">
|
|
21736
21816
|
<head>
|
|
@@ -22135,7 +22215,7 @@
|
|
|
22135
22215
|
<p class="hero-subtitle">${escapeHtml$1(heroSubtitle)}</p>
|
|
22136
22216
|
<div class="stat-grid">
|
|
22137
22217
|
${statCards
|
|
22138
|
-
.map((stat) =>
|
|
22218
|
+
.map((stat) => spacetrim.spaceTrim(`
|
|
22139
22219
|
<div class="stat-card">
|
|
22140
22220
|
<span class="stat-value">${escapeHtml$1(stat.value)}</span>
|
|
22141
22221
|
<span class="stat-label">${escapeHtml$1(stat.label)}</span>
|
|
@@ -22209,9 +22289,9 @@
|
|
|
22209
22289
|
const mdSaveFormatDefinition = {
|
|
22210
22290
|
formatName: 'md',
|
|
22211
22291
|
label: 'Markdown',
|
|
22212
|
-
getContent: ({ messages }) =>
|
|
22292
|
+
getContent: ({ messages }) => spacetrim.spaceTrim(`
|
|
22213
22293
|
${messages
|
|
22214
|
-
.map((message) =>
|
|
22294
|
+
.map((message) => spacetrim.spaceTrim(`
|
|
22215
22295
|
**${message.sender}:**
|
|
22216
22296
|
|
|
22217
22297
|
> ${message.content.replace(/\n/g, '\n> ')}
|
|
@@ -22390,7 +22470,7 @@
|
|
|
22390
22470
|
const { imports: participantsImports, value: participantsValue } = serializeToPromptbookJavascript(participants);
|
|
22391
22471
|
const { imports: messagesImports, value: messagesValue } = serializeToPromptbookJavascript(messages);
|
|
22392
22472
|
const uniqueImports = Array.from(new Set([`import { Chat } from '@promptbook/components';`, ...participantsImports, ...messagesImports])).filter((imp) => !!imp && imp.trim().length > 0);
|
|
22393
|
-
return
|
|
22473
|
+
return spacetrim.spaceTrim((block) => `
|
|
22394
22474
|
"use client";
|
|
22395
22475
|
|
|
22396
22476
|
${block(uniqueImports.join('\n'))}
|
|
@@ -23886,7 +23966,7 @@
|
|
|
23886
23966
|
type: uploadedFile.file.type,
|
|
23887
23967
|
url: uploadedFile.content,
|
|
23888
23968
|
}));
|
|
23889
|
-
if (
|
|
23969
|
+
if (spacetrim.spaceTrim(messageContent) === '' && attachments.length === 0) {
|
|
23890
23970
|
throw new Error(`You need to write some text or upload a file`);
|
|
23891
23971
|
}
|
|
23892
23972
|
if (soundSystem) {
|
|
@@ -23948,7 +24028,7 @@
|
|
|
23948
24028
|
}
|
|
23949
24029
|
const resolvedAction = resolveChatEnterAction(resolvedBehavior, false);
|
|
23950
24030
|
if (resolvedAction === 'SEND') {
|
|
23951
|
-
const hasTextToSend =
|
|
24031
|
+
const hasTextToSend = spacetrim.spaceTrim(snapshot.value) !== '' || snapshot.attachmentIds.length > 0;
|
|
23952
24032
|
if (!hasTextToSend) {
|
|
23953
24033
|
return;
|
|
23954
24034
|
}
|
|
@@ -24225,7 +24305,7 @@
|
|
|
24225
24305
|
pipelineString += '\n\n';
|
|
24226
24306
|
pipelineString += '```' + contentLanguage;
|
|
24227
24307
|
pipelineString += '\n';
|
|
24228
|
-
pipelineString +=
|
|
24308
|
+
pipelineString += spacetrim.spaceTrim(content);
|
|
24229
24309
|
// <- TODO: [main] !!3 Escape
|
|
24230
24310
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
24231
24311
|
pipelineString += '\n';
|
|
@@ -24283,7 +24363,7 @@
|
|
|
24283
24363
|
if (!(error instanceof PipelineLogicError)) {
|
|
24284
24364
|
throw error;
|
|
24285
24365
|
}
|
|
24286
|
-
console.error(
|
|
24366
|
+
console.error(spacetrim.spaceTrim((block) => `
|
|
24287
24367
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
24288
24368
|
|
|
24289
24369
|
${block(error.message)}
|
|
@@ -24310,7 +24390,7 @@
|
|
|
24310
24390
|
})();
|
|
24311
24391
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
24312
24392
|
// <- Note: [🚲]
|
|
24313
|
-
throw new PipelineLogicError(
|
|
24393
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24314
24394
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
24315
24395
|
|
|
24316
24396
|
${block(pipelineIdentification)}
|
|
@@ -24318,7 +24398,7 @@
|
|
|
24318
24398
|
}
|
|
24319
24399
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
24320
24400
|
// <- Note: [🚲]
|
|
24321
|
-
throw new PipelineLogicError(
|
|
24401
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24322
24402
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
24323
24403
|
|
|
24324
24404
|
${block(pipelineIdentification)}
|
|
@@ -24327,7 +24407,7 @@
|
|
|
24327
24407
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
24328
24408
|
if (!Array.isArray(pipeline.parameters)) {
|
|
24329
24409
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
24330
|
-
throw new ParseError(
|
|
24410
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
24331
24411
|
Pipeline is valid JSON but with wrong structure
|
|
24332
24412
|
|
|
24333
24413
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -24338,7 +24418,7 @@
|
|
|
24338
24418
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
24339
24419
|
if (!Array.isArray(pipeline.tasks)) {
|
|
24340
24420
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
24341
|
-
throw new ParseError(
|
|
24421
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
24342
24422
|
Pipeline is valid JSON but with wrong structure
|
|
24343
24423
|
|
|
24344
24424
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -24364,7 +24444,7 @@
|
|
|
24364
24444
|
// Note: Check each parameter individually
|
|
24365
24445
|
for (const parameter of pipeline.parameters) {
|
|
24366
24446
|
if (parameter.isInput && parameter.isOutput) {
|
|
24367
|
-
throw new PipelineLogicError(
|
|
24447
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24368
24448
|
|
|
24369
24449
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
24370
24450
|
|
|
@@ -24375,7 +24455,7 @@
|
|
|
24375
24455
|
if (!parameter.isInput &&
|
|
24376
24456
|
!parameter.isOutput &&
|
|
24377
24457
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
24378
|
-
throw new PipelineLogicError(
|
|
24458
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24379
24459
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
24380
24460
|
|
|
24381
24461
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -24387,7 +24467,7 @@
|
|
|
24387
24467
|
}
|
|
24388
24468
|
// Note: Testing that parameter is either input or result of some task
|
|
24389
24469
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
24390
|
-
throw new PipelineLogicError(
|
|
24470
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24391
24471
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
24392
24472
|
|
|
24393
24473
|
You can do one of these:
|
|
@@ -24403,14 +24483,14 @@
|
|
|
24403
24483
|
// Note: Checking each task individually
|
|
24404
24484
|
for (const task of pipeline.tasks) {
|
|
24405
24485
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
24406
|
-
throw new PipelineLogicError(
|
|
24486
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24407
24487
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
24408
24488
|
|
|
24409
24489
|
${block(pipelineIdentification)}
|
|
24410
24490
|
`));
|
|
24411
24491
|
}
|
|
24412
24492
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
24413
|
-
throw new PipelineLogicError(
|
|
24493
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24414
24494
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
24415
24495
|
|
|
24416
24496
|
${block(pipelineIdentification)}
|
|
@@ -24420,7 +24500,7 @@
|
|
|
24420
24500
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
24421
24501
|
if (!task.format &&
|
|
24422
24502
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
24423
|
-
throw new PipelineLogicError(
|
|
24503
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24424
24504
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
24425
24505
|
|
|
24426
24506
|
${block(pipelineIdentification)}
|
|
@@ -24428,7 +24508,7 @@
|
|
|
24428
24508
|
}
|
|
24429
24509
|
for (const joker of task.jokerParameterNames) {
|
|
24430
24510
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
24431
|
-
throw new PipelineLogicError(
|
|
24511
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24432
24512
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
24433
24513
|
|
|
24434
24514
|
${block(pipelineIdentification)}
|
|
@@ -24439,21 +24519,21 @@
|
|
|
24439
24519
|
if (task.expectations) {
|
|
24440
24520
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
24441
24521
|
if (min !== undefined && max !== undefined && min > max) {
|
|
24442
|
-
throw new PipelineLogicError(
|
|
24522
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24443
24523
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
24444
24524
|
|
|
24445
24525
|
${block(pipelineIdentification)}
|
|
24446
24526
|
`));
|
|
24447
24527
|
}
|
|
24448
24528
|
if (min !== undefined && min < 0) {
|
|
24449
|
-
throw new PipelineLogicError(
|
|
24529
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24450
24530
|
Min expectation of ${unit} must be zero or positive
|
|
24451
24531
|
|
|
24452
24532
|
${block(pipelineIdentification)}
|
|
24453
24533
|
`));
|
|
24454
24534
|
}
|
|
24455
24535
|
if (max !== undefined && max <= 0) {
|
|
24456
|
-
throw new PipelineLogicError(
|
|
24536
|
+
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
24457
24537
|
Max expectation of ${unit} must be positive
|
|
24458
24538
|
|
|
24459
24539
|
${block(pipelineIdentification)}
|
|
@@ -24475,7 +24555,7 @@
|
|
|
24475
24555
|
while (unresovedTasks.length > 0) {
|
|
24476
24556
|
if (loopLimit-- < 0) {
|
|
24477
24557
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
24478
|
-
throw new UnexpectedError(
|
|
24558
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
24479
24559
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
24480
24560
|
|
|
24481
24561
|
${block(pipelineIdentification)}
|
|
@@ -24485,7 +24565,7 @@
|
|
|
24485
24565
|
if (currentlyResovedTasks.length === 0) {
|
|
24486
24566
|
throw new PipelineLogicError(
|
|
24487
24567
|
// TODO: [🐎] DRY
|
|
24488
|
-
|
|
24568
|
+
spacetrim.spaceTrim((block) => `
|
|
24489
24569
|
|
|
24490
24570
|
Can not resolve some parameters:
|
|
24491
24571
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -24606,7 +24686,7 @@
|
|
|
24606
24686
|
for (const pipeline of pipelines) {
|
|
24607
24687
|
// TODO: [👠] DRY
|
|
24608
24688
|
if (pipeline.pipelineUrl === undefined) {
|
|
24609
|
-
throw new PipelineUrlError(
|
|
24689
|
+
throw new PipelineUrlError(spacetrim.spaceTrim(`
|
|
24610
24690
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
24611
24691
|
|
|
24612
24692
|
File:
|
|
@@ -24628,7 +24708,7 @@
|
|
|
24628
24708
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
24629
24709
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
24630
24710
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
24631
|
-
throw new PipelineUrlError(
|
|
24711
|
+
throw new PipelineUrlError(spacetrim.spaceTrim(`
|
|
24632
24712
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
24633
24713
|
|
|
24634
24714
|
Conflicting files:
|
|
@@ -24660,13 +24740,13 @@
|
|
|
24660
24740
|
const pipeline = this.collection.get(url);
|
|
24661
24741
|
if (!pipeline) {
|
|
24662
24742
|
if (this.listPipelines().length === 0) {
|
|
24663
|
-
throw new NotFoundError(
|
|
24743
|
+
throw new NotFoundError(spacetrim.spaceTrim(`
|
|
24664
24744
|
Pipeline with url "${url}" not found
|
|
24665
24745
|
|
|
24666
24746
|
No pipelines available
|
|
24667
24747
|
`));
|
|
24668
24748
|
}
|
|
24669
|
-
throw new NotFoundError(
|
|
24749
|
+
throw new NotFoundError(spacetrim.spaceTrim((block) => `
|
|
24670
24750
|
Pipeline with url "${url}" not found
|
|
24671
24751
|
|
|
24672
24752
|
Available pipelines:
|
|
@@ -24765,11 +24845,11 @@
|
|
|
24765
24845
|
throw deserializeError(errors[0]);
|
|
24766
24846
|
}
|
|
24767
24847
|
else {
|
|
24768
|
-
throw new PipelineExecutionError(
|
|
24848
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
24769
24849
|
Multiple errors occurred during Promptbook execution
|
|
24770
24850
|
|
|
24771
24851
|
${block(errors
|
|
24772
|
-
.map(({ name, stack, message }, index) =>
|
|
24852
|
+
.map(({ name, stack, message }, index) => spacetrim.spaceTrim((block) => `
|
|
24773
24853
|
${name} ${index + 1}:
|
|
24774
24854
|
${block(stack || message)}
|
|
24775
24855
|
`))
|
|
@@ -25249,14 +25329,14 @@
|
|
|
25249
25329
|
if (description === undefined) {
|
|
25250
25330
|
return headLine;
|
|
25251
25331
|
}
|
|
25252
|
-
return
|
|
25332
|
+
return spacetrim.spaceTrim((block) => `
|
|
25253
25333
|
${headLine}
|
|
25254
25334
|
|
|
25255
25335
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
25256
25336
|
`);
|
|
25257
25337
|
})
|
|
25258
25338
|
.join('\n\n');
|
|
25259
|
-
return
|
|
25339
|
+
return spacetrim.spaceTrim((block) => `
|
|
25260
25340
|
Multiple LLM Providers:
|
|
25261
25341
|
|
|
25262
25342
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -25358,7 +25438,7 @@
|
|
|
25358
25438
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
25359
25439
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
25360
25440
|
// 3) ...
|
|
25361
|
-
|
|
25441
|
+
spacetrim.spaceTrim((block) => `
|
|
25362
25442
|
All execution tools of ${this.title} failed:
|
|
25363
25443
|
|
|
25364
25444
|
${block(errors
|
|
@@ -25371,7 +25451,7 @@
|
|
|
25371
25451
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
25372
25452
|
}
|
|
25373
25453
|
else {
|
|
25374
|
-
throw new PipelineExecutionError(
|
|
25454
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
25375
25455
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
25376
25456
|
|
|
25377
25457
|
Available \`LlmExecutionTools\`:
|
|
@@ -25408,7 +25488,7 @@
|
|
|
25408
25488
|
*/
|
|
25409
25489
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
25410
25490
|
if (llmExecutionTools.length === 0) {
|
|
25411
|
-
const warningMessage =
|
|
25491
|
+
const warningMessage = spacetrim.spaceTrim(`
|
|
25412
25492
|
You have not provided any \`LlmExecutionTools\`
|
|
25413
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.
|
|
25414
25494
|
|
|
@@ -25585,14 +25665,14 @@
|
|
|
25585
25665
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
25586
25666
|
});
|
|
25587
25667
|
if (metadata.length === 0) {
|
|
25588
|
-
return
|
|
25668
|
+
return spacetrim.spaceTrim(`
|
|
25589
25669
|
**No scrapers are available**
|
|
25590
25670
|
|
|
25591
25671
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
25592
25672
|
At least there should be available the metadata of the scrapers
|
|
25593
25673
|
`);
|
|
25594
25674
|
}
|
|
25595
|
-
return
|
|
25675
|
+
return spacetrim.spaceTrim((block) => `
|
|
25596
25676
|
Available scrapers are:
|
|
25597
25677
|
${block(metadata
|
|
25598
25678
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -25719,7 +25799,7 @@
|
|
|
25719
25799
|
else if (urlOrRequest instanceof Request) {
|
|
25720
25800
|
url = urlOrRequest.url;
|
|
25721
25801
|
}
|
|
25722
|
-
throw new PromptbookFetchError(
|
|
25802
|
+
throw new PromptbookFetchError(spacetrim.spaceTrim((block) => `
|
|
25723
25803
|
Can not fetch "${url}"
|
|
25724
25804
|
|
|
25725
25805
|
Fetch error:
|
|
@@ -25879,7 +25959,7 @@
|
|
|
25879
25959
|
const fileExtension = getFileExtension(filename);
|
|
25880
25960
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
25881
25961
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
25882
|
-
throw new NotFoundError(
|
|
25962
|
+
throw new NotFoundError(spacetrim.spaceTrim((block) => `
|
|
25883
25963
|
Can not make source handler for file which does not exist:
|
|
25884
25964
|
|
|
25885
25965
|
File:
|
|
@@ -25972,7 +26052,7 @@
|
|
|
25972
26052
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
25973
26053
|
break;
|
|
25974
26054
|
}
|
|
25975
|
-
console.warn(
|
|
26055
|
+
console.warn(spacetrim.spaceTrim((block) => `
|
|
25976
26056
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
25977
26057
|
|
|
25978
26058
|
The source:
|
|
@@ -25988,7 +26068,7 @@
|
|
|
25988
26068
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
25989
26069
|
}
|
|
25990
26070
|
if (partialPieces === null) {
|
|
25991
|
-
throw new KnowledgeScrapeError(
|
|
26071
|
+
throw new KnowledgeScrapeError(spacetrim.spaceTrim((block) => `
|
|
25992
26072
|
Cannot scrape knowledge
|
|
25993
26073
|
|
|
25994
26074
|
The source:
|
|
@@ -26067,7 +26147,7 @@
|
|
|
26067
26147
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
26068
26148
|
knowledgePiecesCount > 0 &&
|
|
26069
26149
|
!dependentParameterNames.includes('knowledge')) {
|
|
26070
|
-
preparedContent =
|
|
26150
|
+
preparedContent = spacetrim.spaceTrim(`
|
|
26071
26151
|
{content}
|
|
26072
26152
|
|
|
26073
26153
|
## Knowledge
|
|
@@ -26299,7 +26379,7 @@
|
|
|
26299
26379
|
}
|
|
26300
26380
|
catch (error) {
|
|
26301
26381
|
assertsError(error);
|
|
26302
|
-
throw new ParseError(
|
|
26382
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
26303
26383
|
Can not extract variables from the script
|
|
26304
26384
|
${block(error.stack || error.message)}
|
|
26305
26385
|
|
|
@@ -26425,7 +26505,7 @@
|
|
|
26425
26505
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
26426
26506
|
const csv = csvParse(value, settings);
|
|
26427
26507
|
if (csv.errors.length !== 0) {
|
|
26428
|
-
throw new CsvFormatError(
|
|
26508
|
+
throw new CsvFormatError(spacetrim.spaceTrim((block) => `
|
|
26429
26509
|
CSV parsing error
|
|
26430
26510
|
|
|
26431
26511
|
Error(s) from CSV parsing:
|
|
@@ -26470,7 +26550,7 @@
|
|
|
26470
26550
|
const { value, settings, mapCallback, onProgress } = options;
|
|
26471
26551
|
const csv = csvParse(value, settings);
|
|
26472
26552
|
if (csv.errors.length !== 0) {
|
|
26473
|
-
throw new CsvFormatError(
|
|
26553
|
+
throw new CsvFormatError(spacetrim.spaceTrim((block) => `
|
|
26474
26554
|
CSV parsing error
|
|
26475
26555
|
|
|
26476
26556
|
Error(s) from CSV parsing:
|
|
@@ -26656,7 +26736,7 @@
|
|
|
26656
26736
|
}
|
|
26657
26737
|
// Phase 2️⃣: Non-matching mapping
|
|
26658
26738
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
26659
|
-
throw new PipelineExecutionError(
|
|
26739
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
26660
26740
|
Can not map available parameters to expected parameters
|
|
26661
26741
|
|
|
26662
26742
|
Mapped parameters:
|
|
@@ -26842,7 +26922,7 @@
|
|
|
26842
26922
|
}
|
|
26843
26923
|
catch (error) {
|
|
26844
26924
|
keepUnused(error);
|
|
26845
|
-
throw new ExpectError(
|
|
26925
|
+
throw new ExpectError(spacetrim.spaceTrim((block) => `
|
|
26846
26926
|
Expected valid JSON string
|
|
26847
26927
|
|
|
26848
26928
|
The expected JSON text:
|
|
@@ -26905,7 +26985,7 @@
|
|
|
26905
26985
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
26906
26986
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
26907
26987
|
if (isJokerAttempt && !jokerParameterName) {
|
|
26908
|
-
throw new UnexpectedError(
|
|
26988
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
26909
26989
|
Joker not found in attempt ${attemptIndex}
|
|
26910
26990
|
|
|
26911
26991
|
${block(pipelineIdentification)}
|
|
@@ -26916,7 +26996,7 @@
|
|
|
26916
26996
|
$ongoingTaskResult.$expectError = null;
|
|
26917
26997
|
if (isJokerAttempt) {
|
|
26918
26998
|
if (parameters[jokerParameterName] === undefined) {
|
|
26919
|
-
throw new PipelineExecutionError(
|
|
26999
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
26920
27000
|
Joker parameter {${jokerParameterName}} not defined
|
|
26921
27001
|
|
|
26922
27002
|
${block(pipelineIdentification)}
|
|
@@ -26975,7 +27055,7 @@
|
|
|
26975
27055
|
break variant;
|
|
26976
27056
|
case 'EMBEDDING':
|
|
26977
27057
|
case 'IMAGE_GENERATION':
|
|
26978
|
-
throw new PipelineExecutionError(
|
|
27058
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
26979
27059
|
${modelRequirements.modelVariant} model can not be used in pipeline
|
|
26980
27060
|
|
|
26981
27061
|
This should be catched during parsing
|
|
@@ -26986,7 +27066,7 @@
|
|
|
26986
27066
|
break variant;
|
|
26987
27067
|
// <- case [🤖]:
|
|
26988
27068
|
default:
|
|
26989
|
-
throw new PipelineExecutionError(
|
|
27069
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
26990
27070
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
26991
27071
|
|
|
26992
27072
|
${block(pipelineIdentification)}
|
|
@@ -26997,14 +27077,14 @@
|
|
|
26997
27077
|
break;
|
|
26998
27078
|
case 'SCRIPT_TASK':
|
|
26999
27079
|
if (arrayableToArray(tools.script).length === 0) {
|
|
27000
|
-
throw new PipelineExecutionError(
|
|
27080
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27001
27081
|
No script execution tools are available
|
|
27002
27082
|
|
|
27003
27083
|
${block(pipelineIdentification)}
|
|
27004
27084
|
`));
|
|
27005
27085
|
}
|
|
27006
27086
|
if (!task.contentLanguage) {
|
|
27007
|
-
throw new PipelineExecutionError(
|
|
27087
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27008
27088
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
27009
27089
|
|
|
27010
27090
|
${block(pipelineIdentification)}
|
|
@@ -27035,7 +27115,7 @@
|
|
|
27035
27115
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
27036
27116
|
}
|
|
27037
27117
|
else {
|
|
27038
|
-
throw new PipelineExecutionError(
|
|
27118
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27039
27119
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
27040
27120
|
|
|
27041
27121
|
${block(pipelineIdentification)}
|
|
@@ -27049,7 +27129,7 @@
|
|
|
27049
27129
|
break taskType;
|
|
27050
27130
|
case 'DIALOG_TASK':
|
|
27051
27131
|
if (tools.userInterface === undefined) {
|
|
27052
|
-
throw new PipelineExecutionError(
|
|
27132
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27053
27133
|
User interface tools are not available
|
|
27054
27134
|
|
|
27055
27135
|
${block(pipelineIdentification)}
|
|
@@ -27067,7 +27147,7 @@
|
|
|
27067
27147
|
break taskType;
|
|
27068
27148
|
// <- case: [🅱]
|
|
27069
27149
|
default:
|
|
27070
|
-
throw new PipelineExecutionError(
|
|
27150
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27071
27151
|
Unknown execution type "${task.taskType}"
|
|
27072
27152
|
|
|
27073
27153
|
${block(pipelineIdentification)}
|
|
@@ -27165,7 +27245,7 @@
|
|
|
27165
27245
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
27166
27246
|
// Note: Create a summary of all failures
|
|
27167
27247
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
27168
|
-
.map((failure) =>
|
|
27248
|
+
.map((failure) => spacetrim.spaceTrim((block) => {
|
|
27169
27249
|
var _a, _b;
|
|
27170
27250
|
return `
|
|
27171
27251
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -27175,14 +27255,14 @@
|
|
|
27175
27255
|
Result:
|
|
27176
27256
|
${block(failure.result === null
|
|
27177
27257
|
? 'null'
|
|
27178
|
-
:
|
|
27258
|
+
: spacetrim.spaceTrim(failure.result)
|
|
27179
27259
|
.split(/\r?\n/)
|
|
27180
27260
|
.map((line) => `> ${line}`)
|
|
27181
27261
|
.join('\n'))}
|
|
27182
27262
|
`;
|
|
27183
27263
|
}))
|
|
27184
27264
|
.join('\n\n---\n\n');
|
|
27185
|
-
throw new PipelineExecutionError(
|
|
27265
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => {
|
|
27186
27266
|
var _a;
|
|
27187
27267
|
return `
|
|
27188
27268
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -27202,7 +27282,7 @@
|
|
|
27202
27282
|
}
|
|
27203
27283
|
}
|
|
27204
27284
|
if ($ongoingTaskResult.$resultString === null) {
|
|
27205
|
-
throw new UnexpectedError(
|
|
27285
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27206
27286
|
Something went wrong and prompt result is null
|
|
27207
27287
|
|
|
27208
27288
|
${block(pipelineIdentification)}
|
|
@@ -27229,7 +27309,7 @@
|
|
|
27229
27309
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
27230
27310
|
}
|
|
27231
27311
|
if (jokerParameterNames.length !== 0) {
|
|
27232
|
-
throw new UnexpectedError(
|
|
27312
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27233
27313
|
JOKER parameters are not supported together with FOREACH command
|
|
27234
27314
|
|
|
27235
27315
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -27242,7 +27322,7 @@
|
|
|
27242
27322
|
if (formatDefinition === undefined) {
|
|
27243
27323
|
throw new UnexpectedError(
|
|
27244
27324
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
27245
|
-
|
|
27325
|
+
spacetrim.spaceTrim((block) => `
|
|
27246
27326
|
Unsupported format "${task.foreach.formatName}"
|
|
27247
27327
|
|
|
27248
27328
|
Available formats:
|
|
@@ -27259,7 +27339,7 @@
|
|
|
27259
27339
|
if (subvalueParser === undefined) {
|
|
27260
27340
|
throw new UnexpectedError(
|
|
27261
27341
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
27262
|
-
|
|
27342
|
+
spacetrim.spaceTrim((block) => `
|
|
27263
27343
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
27264
27344
|
|
|
27265
27345
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -27299,7 +27379,7 @@
|
|
|
27299
27379
|
if (!(error instanceof PipelineExecutionError)) {
|
|
27300
27380
|
throw error;
|
|
27301
27381
|
}
|
|
27302
|
-
const highLevelError = new PipelineExecutionError(
|
|
27382
|
+
const highLevelError = new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27303
27383
|
${error.message}
|
|
27304
27384
|
|
|
27305
27385
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -27323,7 +27403,7 @@
|
|
|
27323
27403
|
...options,
|
|
27324
27404
|
priority: priority + index,
|
|
27325
27405
|
parameters: allSubparameters,
|
|
27326
|
-
pipelineIdentification:
|
|
27406
|
+
pipelineIdentification: spacetrim.spaceTrim((block) => `
|
|
27327
27407
|
${block(pipelineIdentification)}
|
|
27328
27408
|
Subparameter index: ${index}
|
|
27329
27409
|
`),
|
|
@@ -27332,7 +27412,7 @@
|
|
|
27332
27412
|
}
|
|
27333
27413
|
catch (error) {
|
|
27334
27414
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
27335
|
-
console.error(
|
|
27415
|
+
console.error(spacetrim.spaceTrim((block) => `
|
|
27336
27416
|
${error.message}
|
|
27337
27417
|
|
|
27338
27418
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -27508,7 +27588,7 @@
|
|
|
27508
27588
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
27509
27589
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
27510
27590
|
if (reservedParameters[parameterName] === undefined) {
|
|
27511
|
-
throw new UnexpectedError(
|
|
27591
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27512
27592
|
Reserved parameter {${parameterName}} is not defined
|
|
27513
27593
|
|
|
27514
27594
|
${block(pipelineIdentification)}
|
|
@@ -27534,7 +27614,7 @@
|
|
|
27534
27614
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
27535
27615
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
27536
27616
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
27537
|
-
throw new UnexpectedError(
|
|
27617
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27538
27618
|
Dependent parameters are not consistent with used parameters:
|
|
27539
27619
|
|
|
27540
27620
|
Dependent parameters:
|
|
@@ -27578,7 +27658,7 @@
|
|
|
27578
27658
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
27579
27659
|
// Houston, we have a problem
|
|
27580
27660
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
27581
|
-
throw new UnexpectedError(
|
|
27661
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27582
27662
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
27583
27663
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
27584
27664
|
|
|
@@ -27647,7 +27727,7 @@
|
|
|
27647
27727
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
27648
27728
|
if (parametersToPass[parameter.name] === undefined) {
|
|
27649
27729
|
// [4]
|
|
27650
|
-
$warnings.push(new PipelineExecutionError(
|
|
27730
|
+
$warnings.push(new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27651
27731
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
27652
27732
|
|
|
27653
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
|
|
@@ -27755,7 +27835,7 @@
|
|
|
27755
27835
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
27756
27836
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
27757
27837
|
if (parameter === undefined) {
|
|
27758
|
-
warnings.push(new PipelineExecutionError(
|
|
27838
|
+
warnings.push(new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27759
27839
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
27760
27840
|
|
|
27761
27841
|
${block(pipelineIdentification)}
|
|
@@ -27770,7 +27850,7 @@
|
|
|
27770
27850
|
// TODO: [🧠] This should be also non-critical error
|
|
27771
27851
|
return exportJson({
|
|
27772
27852
|
name: 'pipelineExecutorResult',
|
|
27773
|
-
message:
|
|
27853
|
+
message: spacetrim.spaceTrim((block) => `
|
|
27774
27854
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
27775
27855
|
|
|
27776
27856
|
${block(pipelineIdentification)}
|
|
@@ -27779,7 +27859,7 @@
|
|
|
27779
27859
|
value: {
|
|
27780
27860
|
isSuccessful: false,
|
|
27781
27861
|
errors: [
|
|
27782
|
-
new PipelineExecutionError(
|
|
27862
|
+
new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
27783
27863
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
27784
27864
|
|
|
27785
27865
|
${block(pipelineIdentification)}
|
|
@@ -27806,7 +27886,7 @@
|
|
|
27806
27886
|
while (unresovedTasks.length > 0) {
|
|
27807
27887
|
if (loopLimit-- < 0) {
|
|
27808
27888
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
27809
|
-
throw new UnexpectedError(
|
|
27889
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27810
27890
|
Loop limit reached during resolving parameters pipeline execution
|
|
27811
27891
|
|
|
27812
27892
|
${block(pipelineIdentification)}
|
|
@@ -27816,7 +27896,7 @@
|
|
|
27816
27896
|
if (!currentTask && resolving.length === 0) {
|
|
27817
27897
|
throw new UnexpectedError(
|
|
27818
27898
|
// TODO: [🐎] DRY
|
|
27819
|
-
|
|
27899
|
+
spacetrim.spaceTrim((block) => `
|
|
27820
27900
|
Can not resolve some parameters:
|
|
27821
27901
|
|
|
27822
27902
|
${block(pipelineIdentification)}
|
|
@@ -27856,7 +27936,7 @@
|
|
|
27856
27936
|
tools,
|
|
27857
27937
|
onProgress(newOngoingResult) {
|
|
27858
27938
|
if (isReturned) {
|
|
27859
|
-
throw new UnexpectedError(
|
|
27939
|
+
throw new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
27860
27940
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
27861
27941
|
|
|
27862
27942
|
${block(pipelineIdentification)}
|
|
@@ -27873,7 +27953,7 @@
|
|
|
27873
27953
|
},
|
|
27874
27954
|
logLlmCall,
|
|
27875
27955
|
$executionReport: executionReport,
|
|
27876
|
-
pipelineIdentification:
|
|
27956
|
+
pipelineIdentification: spacetrim.spaceTrim((block) => `
|
|
27877
27957
|
${block(pipelineIdentification)}
|
|
27878
27958
|
Task name: ${currentTask.name}
|
|
27879
27959
|
Task title: ${currentTask.title}
|
|
@@ -27982,7 +28062,7 @@
|
|
|
27982
28062
|
preparedPipeline = pipeline;
|
|
27983
28063
|
}
|
|
27984
28064
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
27985
|
-
console.warn(
|
|
28065
|
+
console.warn(spacetrim.spaceTrim((block) => `
|
|
27986
28066
|
Pipeline is not prepared
|
|
27987
28067
|
|
|
27988
28068
|
${block(pipelineIdentification)}
|
|
@@ -28007,7 +28087,7 @@
|
|
|
28007
28087
|
tools,
|
|
28008
28088
|
onProgress,
|
|
28009
28089
|
logLlmCall,
|
|
28010
|
-
pipelineIdentification:
|
|
28090
|
+
pipelineIdentification: spacetrim.spaceTrim((block) => `
|
|
28011
28091
|
${block(pipelineIdentification)}
|
|
28012
28092
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
28013
28093
|
`),
|
|
@@ -28241,7 +28321,7 @@
|
|
|
28241
28321
|
.filter((c) => ['PERSONA', 'RULE', 'KNOWLEDGE'].includes(c.type))
|
|
28242
28322
|
.map((c) => `${c.type} ${c.content}`)
|
|
28243
28323
|
.join('\n\n');
|
|
28244
|
-
return
|
|
28324
|
+
return spacetrim.spaceTrim((block) => `
|
|
28245
28325
|
${block(relevantCommitments)}
|
|
28246
28326
|
|
|
28247
28327
|
${block(corpus)}
|
|
@@ -28763,7 +28843,7 @@
|
|
|
28763
28843
|
/**
|
|
28764
28844
|
* Description of the FORMAT command
|
|
28765
28845
|
*/
|
|
28766
|
-
description:
|
|
28846
|
+
description: spacetrim.spaceTrim(`
|
|
28767
28847
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
28768
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.
|
|
28769
28849
|
`),
|
|
@@ -28837,7 +28917,7 @@
|
|
|
28837
28917
|
}
|
|
28838
28918
|
catch (error) {
|
|
28839
28919
|
assertsError(error);
|
|
28840
|
-
throw new ParseError(
|
|
28920
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
28841
28921
|
Invalid FORMAT command
|
|
28842
28922
|
${block(error.message)}:
|
|
28843
28923
|
`));
|
|
@@ -28903,7 +28983,7 @@
|
|
|
28903
28983
|
/**
|
|
28904
28984
|
* Description of the FORMAT command
|
|
28905
28985
|
*/
|
|
28906
|
-
description:
|
|
28986
|
+
description: spacetrim.spaceTrim(`
|
|
28907
28987
|
Format command describes the desired output of the task (after post-processing)
|
|
28908
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.
|
|
28909
28989
|
`),
|
|
@@ -29493,7 +29573,7 @@
|
|
|
29493
29573
|
/**
|
|
29494
29574
|
* List of available OpenAI models with pricing
|
|
29495
29575
|
*
|
|
29496
|
-
* Note: Synced with official API docs at
|
|
29576
|
+
* Note: Synced with official API docs at 2026-03-22
|
|
29497
29577
|
*
|
|
29498
29578
|
* @see https://platform.openai.com/docs/models/
|
|
29499
29579
|
* @see https://openai.com/api/pricing/
|
|
@@ -29615,8 +29695,8 @@
|
|
|
29615
29695
|
modelName: 'gpt-4.1',
|
|
29616
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.',
|
|
29617
29697
|
pricing: {
|
|
29618
|
-
prompt: pricing(`$
|
|
29619
|
-
output: pricing(`$
|
|
29698
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
29699
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
29620
29700
|
},
|
|
29621
29701
|
},
|
|
29622
29702
|
/**/
|
|
@@ -29627,8 +29707,8 @@
|
|
|
29627
29707
|
modelName: 'gpt-4.1-mini',
|
|
29628
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.',
|
|
29629
29709
|
pricing: {
|
|
29630
|
-
prompt: pricing(`$0.
|
|
29631
|
-
output: pricing(`$
|
|
29710
|
+
prompt: pricing(`$0.40 / 1M tokens`),
|
|
29711
|
+
output: pricing(`$1.60 / 1M tokens`),
|
|
29632
29712
|
},
|
|
29633
29713
|
},
|
|
29634
29714
|
/**/
|
|
@@ -29639,8 +29719,8 @@
|
|
|
29639
29719
|
modelName: 'gpt-4.1-nano',
|
|
29640
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.',
|
|
29641
29721
|
pricing: {
|
|
29642
|
-
prompt: pricing(`$0.
|
|
29643
|
-
output: pricing(`$0.
|
|
29722
|
+
prompt: pricing(`$0.10 / 1M tokens`),
|
|
29723
|
+
output: pricing(`$0.40 / 1M tokens`),
|
|
29644
29724
|
},
|
|
29645
29725
|
},
|
|
29646
29726
|
/**/
|
|
@@ -29651,8 +29731,8 @@
|
|
|
29651
29731
|
modelName: 'o3',
|
|
29652
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.',
|
|
29653
29733
|
pricing: {
|
|
29654
|
-
prompt: pricing(`$
|
|
29655
|
-
output: pricing(`$
|
|
29734
|
+
prompt: pricing(`$2.00 / 1M tokens`),
|
|
29735
|
+
output: pricing(`$8.00 / 1M tokens`),
|
|
29656
29736
|
},
|
|
29657
29737
|
},
|
|
29658
29738
|
/**/
|
|
@@ -29663,8 +29743,8 @@
|
|
|
29663
29743
|
modelName: 'o3-pro',
|
|
29664
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.',
|
|
29665
29745
|
pricing: {
|
|
29666
|
-
prompt: pricing(`$
|
|
29667
|
-
output: pricing(`$
|
|
29746
|
+
prompt: pricing(`$20.00 / 1M tokens`),
|
|
29747
|
+
output: pricing(`$80.00 / 1M tokens`),
|
|
29668
29748
|
},
|
|
29669
29749
|
},
|
|
29670
29750
|
/**/
|
|
@@ -29675,8 +29755,8 @@
|
|
|
29675
29755
|
modelName: 'o4-mini',
|
|
29676
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.',
|
|
29677
29757
|
pricing: {
|
|
29678
|
-
prompt: pricing(`$
|
|
29679
|
-
output: pricing(`$
|
|
29758
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
29759
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
29680
29760
|
},
|
|
29681
29761
|
},
|
|
29682
29762
|
/**/
|
|
@@ -30034,8 +30114,8 @@
|
|
|
30034
30114
|
modelName: 'gpt-4o-2024-05-13',
|
|
30035
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.',
|
|
30036
30116
|
pricing: {
|
|
30037
|
-
prompt: pricing(`$
|
|
30038
|
-
output: pricing(`$
|
|
30117
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
30118
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
30039
30119
|
},
|
|
30040
30120
|
},
|
|
30041
30121
|
/**/
|
|
@@ -30046,8 +30126,8 @@
|
|
|
30046
30126
|
modelName: 'gpt-4o',
|
|
30047
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.",
|
|
30048
30128
|
pricing: {
|
|
30049
|
-
prompt: pricing(`$
|
|
30050
|
-
output: pricing(`$
|
|
30129
|
+
prompt: pricing(`$2.50 / 1M tokens`),
|
|
30130
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
30051
30131
|
},
|
|
30052
30132
|
},
|
|
30053
30133
|
/**/
|
|
@@ -30118,8 +30198,8 @@
|
|
|
30118
30198
|
modelName: 'o3-mini',
|
|
30119
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.',
|
|
30120
30200
|
pricing: {
|
|
30121
|
-
prompt: pricing(`$
|
|
30122
|
-
output: pricing(`$
|
|
30201
|
+
prompt: pricing(`$1.10 / 1M tokens`),
|
|
30202
|
+
output: pricing(`$4.40 / 1M tokens`),
|
|
30123
30203
|
},
|
|
30124
30204
|
},
|
|
30125
30205
|
/**/
|
|
@@ -30219,53 +30299,6 @@
|
|
|
30219
30299
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
30220
30300
|
*/
|
|
30221
30301
|
|
|
30222
|
-
/**
|
|
30223
|
-
* Maps Promptbook tools to OpenAI tools.
|
|
30224
|
-
*
|
|
30225
|
-
* @private
|
|
30226
|
-
*/
|
|
30227
|
-
function mapToolsToOpenAi(tools) {
|
|
30228
|
-
return tools.map((tool) => ({
|
|
30229
|
-
type: 'function',
|
|
30230
|
-
function: {
|
|
30231
|
-
name: tool.name,
|
|
30232
|
-
description: tool.description,
|
|
30233
|
-
parameters: tool.parameters,
|
|
30234
|
-
},
|
|
30235
|
-
}));
|
|
30236
|
-
}
|
|
30237
|
-
|
|
30238
|
-
/**
|
|
30239
|
-
* Builds a tool invocation script that injects hidden runtime context into tool args.
|
|
30240
|
-
*
|
|
30241
|
-
* @private utility of OpenAI tool execution wrappers
|
|
30242
|
-
*/
|
|
30243
|
-
function buildToolInvocationScript(options) {
|
|
30244
|
-
const { functionName, functionArgsExpression } = options;
|
|
30245
|
-
return `
|
|
30246
|
-
const args = ${functionArgsExpression};
|
|
30247
|
-
const runtimeContextRaw =
|
|
30248
|
-
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
30249
|
-
? undefined
|
|
30250
|
-
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
30251
|
-
|
|
30252
|
-
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
30253
|
-
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
30254
|
-
}
|
|
30255
|
-
|
|
30256
|
-
const toolProgressTokenRaw =
|
|
30257
|
-
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
30258
|
-
? undefined
|
|
30259
|
-
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
30260
|
-
|
|
30261
|
-
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
30262
|
-
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
30263
|
-
}
|
|
30264
|
-
|
|
30265
|
-
return await ${functionName}(args);
|
|
30266
|
-
`;
|
|
30267
|
-
}
|
|
30268
|
-
|
|
30269
30302
|
/**
|
|
30270
30303
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
30271
30304
|
*
|
|
@@ -30322,6 +30355,53 @@
|
|
|
30322
30355
|
errorMessage.includes('does not support'));
|
|
30323
30356
|
}
|
|
30324
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
|
+
|
|
30325
30405
|
/**
|
|
30326
30406
|
* Provides access to the structured clone implementation when available.
|
|
30327
30407
|
*/
|
|
@@ -31288,7 +31368,7 @@
|
|
|
31288
31368
|
// Note: Match exact or prefix for model families
|
|
31289
31369
|
const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
|
|
31290
31370
|
if (model === undefined) {
|
|
31291
|
-
throw new PipelineExecutionError(
|
|
31371
|
+
throw new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
31292
31372
|
Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
|
|
31293
31373
|
|
|
31294
31374
|
Available models:
|
|
@@ -32214,7 +32294,7 @@
|
|
|
32214
32294
|
}
|
|
32215
32295
|
}
|
|
32216
32296
|
|
|
32217
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5-
|
|
32297
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
|
|
32218
32298
|
/**
|
|
32219
32299
|
* Creates one structured log entry for streamed tool-call updates.
|
|
32220
32300
|
*
|
|
@@ -32709,7 +32789,7 @@
|
|
|
32709
32789
|
}),
|
|
32710
32790
|
],
|
|
32711
32791
|
};
|
|
32712
|
-
const errorMessage =
|
|
32792
|
+
const errorMessage = spacetrim.spaceTrim((block) => `
|
|
32713
32793
|
|
|
32714
32794
|
The invoked tool \`${functionName}\` failed with error:
|
|
32715
32795
|
|
|
@@ -33427,7 +33507,7 @@
|
|
|
33427
33507
|
assertsError(error);
|
|
33428
33508
|
const serializedError = serializeError(error);
|
|
33429
33509
|
errors = [serializedError];
|
|
33430
|
-
functionResponse =
|
|
33510
|
+
functionResponse = spacetrim.spaceTrim((block) => `
|
|
33431
33511
|
|
|
33432
33512
|
The invoked tool \`${functionName}\` failed with error:
|
|
33433
33513
|
|
|
@@ -34366,7 +34446,7 @@
|
|
|
34366
34446
|
if (commitment.type !== 'OPEN') {
|
|
34367
34447
|
continue;
|
|
34368
34448
|
}
|
|
34369
|
-
const trimmed =
|
|
34449
|
+
const trimmed = spacetrim.spaceTrim(commitment.content);
|
|
34370
34450
|
return trimmed || null;
|
|
34371
34451
|
}
|
|
34372
34452
|
return null;
|
|
@@ -34435,7 +34515,7 @@
|
|
|
34435
34515
|
if (isJsonSchemaResponseFormat(responseFormat)) {
|
|
34436
34516
|
const jsonSchema = responseFormat.json_schema;
|
|
34437
34517
|
const schemaJson = JSON.stringify(jsonSchema, null, 4);
|
|
34438
|
-
userMessageContent =
|
|
34518
|
+
userMessageContent = spacetrim.spaceTrim((block) => `
|
|
34439
34519
|
${block(prompt.content)}
|
|
34440
34520
|
|
|
34441
34521
|
NOTE Request was made through OpenAI Compatible API with \`response_format\` of type \`json_schema\` with the following schema:
|
|
@@ -34466,12 +34546,12 @@
|
|
|
34466
34546
|
const formattedAgentMessage = formatAgentMessageForJsonMode(result.content, usesJsonSchemaMode);
|
|
34467
34547
|
const teacherInstructions = extractOpenTeacherInstructions(agentSource);
|
|
34468
34548
|
const teacherInstructionsSection = teacherInstructions
|
|
34469
|
-
?
|
|
34549
|
+
? spacetrim.spaceTrim((block) => `
|
|
34470
34550
|
**Teacher instructions:**
|
|
34471
34551
|
${block(teacherInstructions)}
|
|
34472
34552
|
`)
|
|
34473
34553
|
: '';
|
|
34474
|
-
const teacherPromptContent =
|
|
34554
|
+
const teacherPromptContent = spacetrim.spaceTrim((block) => `
|
|
34475
34555
|
|
|
34476
34556
|
You are a teacher agent helping another agent to learn from its interactions.
|
|
34477
34557
|
|
|
@@ -34504,7 +34584,7 @@
|
|
|
34504
34584
|
? '- This interaction used JSON mode, so the agent answer should stay as a formatted JSON code block.'
|
|
34505
34585
|
: ''}
|
|
34506
34586
|
${block(isInitialMessageMissing
|
|
34507
|
-
?
|
|
34587
|
+
? spacetrim.spaceTrim(`
|
|
34508
34588
|
- The agent source does not have an INITIAL MESSAGE defined, generate one.
|
|
34509
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.
|
|
34510
34590
|
- The quick option looks like \`[👋 Hello](?message=Hello, how are you?)\`
|
|
@@ -34547,7 +34627,7 @@
|
|
|
34547
34627
|
*/
|
|
34548
34628
|
appendToAgentSource(section) {
|
|
34549
34629
|
const currentSource = this.options.getAgentSource();
|
|
34550
|
-
const newSource = padBook(validateBook(
|
|
34630
|
+
const newSource = padBook(validateBook(spacetrim.spaceTrim(currentSource) + section));
|
|
34551
34631
|
this.options.updateAgentSource(newSource);
|
|
34552
34632
|
}
|
|
34553
34633
|
}
|
|
@@ -34575,13 +34655,13 @@
|
|
|
34575
34655
|
}
|
|
34576
34656
|
const parsedJson = tryParseJson(content);
|
|
34577
34657
|
if (parsedJson === null) {
|
|
34578
|
-
return
|
|
34658
|
+
return spacetrim.spaceTrim((block) => `
|
|
34579
34659
|
\`\`\`json
|
|
34580
34660
|
${block(content)}
|
|
34581
34661
|
\`\`\`
|
|
34582
34662
|
`);
|
|
34583
34663
|
}
|
|
34584
|
-
return
|
|
34664
|
+
return spacetrim.spaceTrim((block) => `
|
|
34585
34665
|
\`\`\`json
|
|
34586
34666
|
${block(JSON.stringify(parsedJson, null, 4))}
|
|
34587
34667
|
\`\`\`
|
|
@@ -34613,7 +34693,7 @@
|
|
|
34613
34693
|
const internalMessagesSection = options.internalMessages
|
|
34614
34694
|
.map((internalMessage) => formatInternalLearningMessage(internalMessage))
|
|
34615
34695
|
.join('\n\n');
|
|
34616
|
-
return
|
|
34696
|
+
return spacetrim.spaceTrim((block) => `
|
|
34617
34697
|
|
|
34618
34698
|
USER MESSAGE
|
|
34619
34699
|
${block(options.userMessageContent)}
|
|
@@ -34631,7 +34711,7 @@
|
|
|
34631
34711
|
* @private function of Agent
|
|
34632
34712
|
*/
|
|
34633
34713
|
function formatInternalLearningMessage(internalMessage) {
|
|
34634
|
-
return
|
|
34714
|
+
return spacetrim.spaceTrim((block) => `
|
|
34635
34715
|
INTERNAL MESSAGE
|
|
34636
34716
|
${block(stringifyInternalLearningPayload(internalMessage))}
|
|
34637
34717
|
`);
|
|
@@ -35135,7 +35215,7 @@
|
|
|
35135
35215
|
const bookString = prompt(strings, ...values).toString();
|
|
35136
35216
|
if (!isValidPipelineString(bookString)) {
|
|
35137
35217
|
// TODO: Make the CustomError for this
|
|
35138
|
-
throw new Error(
|
|
35218
|
+
throw new Error(spacetrim.spaceTrim(`
|
|
35139
35219
|
The string is not a valid pipeline string
|
|
35140
35220
|
|
|
35141
35221
|
book\`
|
|
@@ -35145,7 +35225,7 @@
|
|
|
35145
35225
|
}
|
|
35146
35226
|
if (!isValidBook(bookString)) {
|
|
35147
35227
|
// TODO: Make the CustomError for this
|
|
35148
|
-
throw new Error(
|
|
35228
|
+
throw new Error(spacetrim.spaceTrim(`
|
|
35149
35229
|
The string is not a valid book
|
|
35150
35230
|
|
|
35151
35231
|
book\`
|
|
@@ -35414,7 +35494,7 @@
|
|
|
35414
35494
|
.filter((line) => Boolean(line))
|
|
35415
35495
|
.join('\n');
|
|
35416
35496
|
const personaBlock = profile.personaDescription
|
|
35417
|
-
?
|
|
35497
|
+
? spacetrim.spaceTrim((block) => `
|
|
35418
35498
|
PERSONA
|
|
35419
35499
|
${block(profile.personaDescription || '')}
|
|
35420
35500
|
`)
|
|
@@ -35450,7 +35530,7 @@
|
|
|
35450
35530
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
35451
35531
|
// <- TODO: [🐱🚀] Maybe use promptbookFetch
|
|
35452
35532
|
if (!profileResponse.ok) {
|
|
35453
|
-
throw new Error(
|
|
35533
|
+
throw new Error(spacetrim.spaceTrim((block) => `
|
|
35454
35534
|
Failed to fetch remote agent profile:
|
|
35455
35535
|
|
|
35456
35536
|
Agent URL:
|
|
@@ -38132,6 +38212,7 @@
|
|
|
38132
38212
|
useTime: { title: 'Checking time', emoji: '🕒' },
|
|
38133
38213
|
set_timeout: { title: 'Setting timer', emoji: '⏱️' },
|
|
38134
38214
|
cancel_timeout: { title: 'Cancelling timer', emoji: '⏱️' },
|
|
38215
|
+
list_timeouts: { title: 'Listing timers', emoji: '⏱️' },
|
|
38135
38216
|
get_user_location: { title: 'Checking location', emoji: '📍' },
|
|
38136
38217
|
send_email: { title: 'Sending email', emoji: '📧' },
|
|
38137
38218
|
useEmail: { title: 'Sending email', emoji: '📧' },
|
|
@@ -38496,11 +38577,11 @@
|
|
|
38496
38577
|
});
|
|
38497
38578
|
}
|
|
38498
38579
|
const decodedPrompt = decodePrompt(rawPrompt);
|
|
38499
|
-
const prompt =
|
|
38580
|
+
const prompt = spacetrim.spaceTrim(decodedPrompt) || decodedPrompt || 'Generated image';
|
|
38500
38581
|
const decodedAlt = decodePrompt(alt);
|
|
38501
38582
|
segments.push({
|
|
38502
38583
|
type: 'image',
|
|
38503
|
-
alt:
|
|
38584
|
+
alt: spacetrim.spaceTrim(decodedAlt) || 'Generated image',
|
|
38504
38585
|
prompt,
|
|
38505
38586
|
});
|
|
38506
38587
|
lastIndex = start + fullMatch.length;
|
|
@@ -39136,7 +39217,7 @@
|
|
|
39136
39217
|
*/
|
|
39137
39218
|
function constructImageFilename(params) {
|
|
39138
39219
|
const { prompt, model, size, quality, style, attachments } = params;
|
|
39139
|
-
const promptTrimmed =
|
|
39220
|
+
const promptTrimmed = spacetrim.spaceTrim(prompt);
|
|
39140
39221
|
return (promptTrimmed
|
|
39141
39222
|
.toLowerCase()
|
|
39142
39223
|
.replace(/[^a-z0-9]+/g, '-')
|
|
@@ -39200,7 +39281,7 @@
|
|
|
39200
39281
|
* @private internal component of `<ChatMessageItem/>`
|
|
39201
39282
|
*/
|
|
39202
39283
|
function ImagePromptRenderer({ alt, prompt }) {
|
|
39203
|
-
const trimmedPrompt = react.useMemo(() =>
|
|
39284
|
+
const trimmedPrompt = react.useMemo(() => spacetrim.spaceTrim(prompt), [prompt]);
|
|
39204
39285
|
const filename = react.useMemo(() => constructImageFilename({
|
|
39205
39286
|
prompt: trimmedPrompt,
|
|
39206
39287
|
}), [trimmedPrompt]);
|
|
@@ -42862,7 +42943,7 @@
|
|
|
42862
42943
|
id: AGENT_CHAT_INITIAL_MESSAGE_ID,
|
|
42863
42944
|
sender: 'AGENT',
|
|
42864
42945
|
content: agent.initialMessage ||
|
|
42865
|
-
|
|
42946
|
+
spacetrim.spaceTrim(`
|
|
42866
42947
|
|
|
42867
42948
|
Hello! I am ${agent.meta.fullname || agent.agentName || 'an AI Agent'}.
|
|
42868
42949
|
|