@promptbook/cli 0.103.0-55 → 0.103.0-66
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/apps/agents-server/TODO.txt +5 -1
- package/apps/agents-server/package-lock.json +2336 -0
- package/apps/agents-server/package.json +9 -0
- package/apps/agents-server/src/app/actions.ts +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +282 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +91 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +44 -0
- package/apps/agents-server/src/app/agents/[agentName]/CloneAgentButton.tsx +4 -4
- package/apps/agents-server/src/app/agents/[agentName]/InstallPwaButton.tsx +2 -2
- package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +80 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +11 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/models/route.ts +93 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/models/route.ts +93 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +4 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +9 -2
- package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +7 -3
- package/apps/agents-server/src/app/agents/[agentName]/integration/SdkCodeTabs.tsx +31 -0
- package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +271 -30
- package/apps/agents-server/src/app/agents/[agentName]/layout.tsx +41 -0
- package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +61 -97
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +47 -157
- package/apps/agents-server/src/app/agents/[agentName]/website-integration/page.tsx +70 -0
- package/apps/agents-server/src/app/api/openai/v1/chat/completions/route.ts +6 -0
- package/apps/agents-server/src/app/api/openai/v1/models/route.ts +65 -0
- package/apps/agents-server/src/app/docs/[docId]/page.tsx +12 -32
- package/apps/agents-server/src/app/docs/page.tsx +42 -17
- package/apps/agents-server/src/app/embed/page.tsx +2 -2
- package/apps/agents-server/src/app/globals.css +129 -0
- package/apps/agents-server/src/app/layout.tsx +16 -26
- package/apps/agents-server/src/app/manifest.ts +9 -4
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +334 -0
- package/apps/agents-server/src/components/AgentProfile/AgentProfileFromSource.tsx +23 -0
- package/apps/agents-server/src/{app/agents/[agentName] → components/AgentProfile}/AgentQrCode.tsx +8 -1
- package/apps/agents-server/src/components/AgentProfile/QrCodeModal.tsx +90 -0
- package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +87 -0
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +7 -6
- package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +20 -0
- package/apps/agents-server/src/components/PrintButton/PrintButton.tsx +18 -0
- package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +18 -0
- package/apps/agents-server/src/database/metadataDefaults.ts +6 -0
- package/apps/agents-server/src/database/migrations/2025-12-0070-chat-history-source.sql +2 -0
- package/apps/agents-server/src/database/schema.ts +6 -0
- package/apps/agents-server/src/utils/handleChatCompletion.ts +186 -14
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +13 -6
- package/apps/agents-server/src/utils/validateApiKey.ts +128 -0
- package/apps/agents-server/tailwind.config.ts +1 -1
- package/esm/index.es.js +953 -474
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +2 -2
- package/esm/typings/src/_packages/core.index.d.ts +6 -8
- package/esm/typings/src/_packages/types.index.d.ts +7 -1
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +3 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +52 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +14 -0
- package/esm/typings/src/book-components/icons/SendIcon.d.ts +3 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +4 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -0
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +6 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +42 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/{IMPORTANT/IMPORTANT.d.ts → USE_MCP/USE_MCP.d.ts} +16 -5
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +6 -0
- package/esm/typings/src/commitments/index.d.ts +93 -1
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +3 -1
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/playground/playground.d.ts +3 -0
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/esm/typings/src/utils/color/Color.d.ts +9 -1
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +6 -0
- package/esm/typings/src/utils/random/CzechNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
- package/esm/typings/src/utils/random/getNamePool.d.ts +10 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +902 -423
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +0 -29
- package/esm/typings/src/commitments/registry.d.ts +0 -68
- package/esm/typings/src/playground/playground1.d.ts +0 -2
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('waitasecond'), require('prompts'), require('path'), require('fs/promises'), require('dotenv'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto'), require('socket.io-client'), require('rxjs'), require('child_process'), require('jszip'), require('papaparse'), require('crypto-js'), require('mime-types'), require('glob-promise'), require('moment'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('swagger-ui-express'), require('react'), require('react-dom/server'), require('@anthropic-ai/sdk'), require('bottleneck'), require('@azure/openai'), require('openai'), require('@mozilla/readability'), require('jsdom'), require('showdown')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'waitasecond', 'prompts', 'path', 'fs/promises', 'dotenv', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto', 'socket.io-client', 'rxjs', 'child_process', 'jszip', 'papaparse', 'crypto-js', 'mime-types', 'glob-promise', 'moment', 'express', 'express-openapi-validator', 'http', 'socket.io', 'swagger-ui-express', 'react', 'react-dom/server', '@anthropic-ai/sdk', 'bottleneck', '@azure/openai', 'openai', '@mozilla/readability', 'jsdom', 'showdown'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim, global.waitasecond, global.prompts, global.path, global.promises, global.dotenv, global.hexEncoder, global.sha256, global.crypto, global.socket_ioClient, global.rxjs, global.child_process, global.JSZip, global.papaparse, global.cryptoJs, global.mimeTypes, global.glob, global.moment, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.react, global.server, global.Anthropic, global.Bottleneck, global.openai, global.OpenAI, global.readability, global.jsdom, global.showdown));
|
|
5
|
-
})(this, (function (exports, colors, commander, spaceTrim, waitasecond, prompts, path, promises, dotenv, hexEncoder, sha256, crypto, socket_ioClient, rxjs, child_process, JSZip, papaparse, cryptoJs, mimeTypes, glob, moment, express, OpenApiValidator, http, socket_io, swaggerUi, react, server, Anthropic, Bottleneck, openai, OpenAI, readability, jsdom, showdown) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim$1, global.waitasecond, global.prompts, global.path, global.promises, global.dotenv, global.hexEncoder, global.sha256, global.crypto, global.socket_ioClient, global.rxjs, global.child_process, global.JSZip, global.papaparse, global.cryptoJs, global.mimeTypes, global.glob, global.moment, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.react, global.server, global.Anthropic, global.Bottleneck, global.openai, global.OpenAI, global.readability, global.jsdom, global.showdown));
|
|
5
|
+
})(this, (function (exports, colors, commander, spaceTrim$1, waitasecond, prompts, path, promises, dotenv, hexEncoder, sha256, crypto, socket_ioClient, rxjs, child_process, JSZip, papaparse, cryptoJs, mimeTypes, glob, moment, express, OpenApiValidator, http, socket_io, swaggerUi, react, server, Anthropic, Bottleneck, openai, OpenAI, readability, jsdom, showdown) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
28
28
|
var commander__default = /*#__PURE__*/_interopDefaultLegacy(commander);
|
|
29
|
-
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
29
|
+
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
|
|
30
30
|
var prompts__default = /*#__PURE__*/_interopDefaultLegacy(prompts);
|
|
31
31
|
var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
|
|
32
32
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
* @generated
|
|
57
57
|
* @see https://github.com/webgptorg/promptbook
|
|
58
58
|
*/
|
|
59
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
59
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-66';
|
|
60
60
|
/**
|
|
61
61
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
62
62
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -110,6 +110,17 @@
|
|
|
110
110
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
111
111
|
*/
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Trims string from all 4 sides
|
|
115
|
+
*
|
|
116
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
117
|
+
* Developed by same author @hejny as this package
|
|
118
|
+
*
|
|
119
|
+
* @public exported from `@promptbook/utils`
|
|
120
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
121
|
+
*/
|
|
122
|
+
const spaceTrim = spaceTrim$1.spaceTrim;
|
|
123
|
+
|
|
113
124
|
/**
|
|
114
125
|
* Just marks a place of place where should be something implemented
|
|
115
126
|
* No side effects.
|
|
@@ -171,6 +182,7 @@
|
|
|
171
182
|
* @public exported from `@promptbook/color`
|
|
172
183
|
*/
|
|
173
184
|
const CSS_COLORS = {
|
|
185
|
+
promptbook: '#79EAFD',
|
|
174
186
|
transparent: 'rgba(0,0,0,0)',
|
|
175
187
|
aliceblue: '#f0f8ff',
|
|
176
188
|
antiquewhite: '#faebd7',
|
|
@@ -371,21 +383,61 @@
|
|
|
371
383
|
* @param color
|
|
372
384
|
* @returns Color object
|
|
373
385
|
*/
|
|
374
|
-
static from(color) {
|
|
375
|
-
if (color
|
|
386
|
+
static from(color, _isSingleValue = false) {
|
|
387
|
+
if (color === '') {
|
|
388
|
+
throw new Error(`Can not create color from empty string`);
|
|
389
|
+
}
|
|
390
|
+
else if (color instanceof Color) {
|
|
376
391
|
return take(color);
|
|
377
392
|
}
|
|
378
393
|
else if (Color.isColor(color)) {
|
|
379
394
|
return take(color);
|
|
380
395
|
}
|
|
381
396
|
else if (typeof color === 'string') {
|
|
382
|
-
|
|
397
|
+
try {
|
|
398
|
+
return Color.fromString(color);
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
402
|
+
if (_isSingleValue) {
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
405
|
+
const parts = color.split(/[\s+,;|]/);
|
|
406
|
+
if (parts.length > 0) {
|
|
407
|
+
return Color.from(parts[0].trim(), true);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
throw new Error(`Can not create color from given string "${color}"`);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
383
413
|
}
|
|
384
414
|
else {
|
|
385
415
|
console.error({ color });
|
|
386
416
|
throw new Error(`Can not create color from given object`);
|
|
387
417
|
}
|
|
388
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Creates a new Color instance from miscellaneous formats
|
|
421
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
422
|
+
*
|
|
423
|
+
* @param color
|
|
424
|
+
* @returns Color object
|
|
425
|
+
*/
|
|
426
|
+
static fromSafe(color) {
|
|
427
|
+
try {
|
|
428
|
+
return Color.from(color);
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
432
|
+
console.warn(spaceTrim((block) => `
|
|
433
|
+
Color.fromSafe error:
|
|
434
|
+
${block(error.message)}
|
|
435
|
+
|
|
436
|
+
Returning default PROMPTBOOK_COLOR.
|
|
437
|
+
`));
|
|
438
|
+
return Color.fromString('promptbook');
|
|
439
|
+
}
|
|
440
|
+
}
|
|
389
441
|
/**
|
|
390
442
|
* Creates a new Color instance from miscellaneous string formats
|
|
391
443
|
*
|
|
@@ -1009,7 +1061,7 @@
|
|
|
1009
1061
|
*
|
|
1010
1062
|
* @public exported from `@promptbook/core`
|
|
1011
1063
|
*/
|
|
1012
|
-
const PROMPTBOOK_COLOR = Color.
|
|
1064
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
1013
1065
|
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1014
1066
|
/**
|
|
1015
1067
|
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
@@ -1450,7 +1502,7 @@
|
|
|
1450
1502
|
*/
|
|
1451
1503
|
class UnexpectedError extends Error {
|
|
1452
1504
|
constructor(message) {
|
|
1453
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
1505
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
1454
1506
|
${block(message)}
|
|
1455
1507
|
|
|
1456
1508
|
Note: This error should not happen.
|
|
@@ -1476,7 +1528,7 @@
|
|
|
1476
1528
|
constructor(whatWasThrown) {
|
|
1477
1529
|
const tag = `[🤮]`;
|
|
1478
1530
|
console.error(tag, whatWasThrown);
|
|
1479
|
-
super(spaceTrim.spaceTrim(`
|
|
1531
|
+
super(spaceTrim$1.spaceTrim(`
|
|
1480
1532
|
Non-Error object was thrown
|
|
1481
1533
|
|
|
1482
1534
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1621,7 +1673,7 @@
|
|
|
1621
1673
|
*/
|
|
1622
1674
|
class NotYetImplementedError extends Error {
|
|
1623
1675
|
constructor(message) {
|
|
1624
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
1676
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
1625
1677
|
${block(message)}
|
|
1626
1678
|
|
|
1627
1679
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -3295,7 +3347,7 @@
|
|
|
3295
3347
|
*/
|
|
3296
3348
|
class MissingToolsError extends Error {
|
|
3297
3349
|
constructor(message) {
|
|
3298
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
3350
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
3299
3351
|
${block(message)}
|
|
3300
3352
|
|
|
3301
3353
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -4013,7 +4065,7 @@
|
|
|
4013
4065
|
}
|
|
4014
4066
|
catch (error) {
|
|
4015
4067
|
keepUnused(error);
|
|
4016
|
-
throw new ExpectError(spaceTrim.spaceTrim((block) => `
|
|
4068
|
+
throw new ExpectError(spaceTrim$1.spaceTrim((block) => `
|
|
4017
4069
|
Expected valid JSON string
|
|
4018
4070
|
|
|
4019
4071
|
The expected JSON text:
|
|
@@ -5226,11 +5278,11 @@
|
|
|
5226
5278
|
console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
|
|
5227
5279
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
5228
5280
|
}
|
|
5229
|
-
resolve(spaceTrim.spaceTrim(output.join('\n')));
|
|
5281
|
+
resolve(spaceTrim$1.spaceTrim(output.join('\n')));
|
|
5230
5282
|
}
|
|
5231
5283
|
}
|
|
5232
5284
|
else {
|
|
5233
|
-
resolve(spaceTrim.spaceTrim(output.join('\n')));
|
|
5285
|
+
resolve(spaceTrim$1.spaceTrim(output.join('\n')));
|
|
5234
5286
|
}
|
|
5235
5287
|
};
|
|
5236
5288
|
commandProcess.on('close', finishWithCode);
|
|
@@ -5248,7 +5300,7 @@
|
|
|
5248
5300
|
console.warn(error);
|
|
5249
5301
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
5250
5302
|
}
|
|
5251
|
-
resolve(spaceTrim.spaceTrim(output.join('\n')));
|
|
5303
|
+
resolve(spaceTrim$1.spaceTrim(output.join('\n')));
|
|
5252
5304
|
}
|
|
5253
5305
|
});
|
|
5254
5306
|
}
|
|
@@ -5780,7 +5832,7 @@
|
|
|
5780
5832
|
if (!(error instanceof PipelineLogicError)) {
|
|
5781
5833
|
throw error;
|
|
5782
5834
|
}
|
|
5783
|
-
console.error(spaceTrim.spaceTrim((block) => `
|
|
5835
|
+
console.error(spaceTrim$1.spaceTrim((block) => `
|
|
5784
5836
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
5785
5837
|
|
|
5786
5838
|
${block(error.message)}
|
|
@@ -5807,7 +5859,7 @@
|
|
|
5807
5859
|
})();
|
|
5808
5860
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
5809
5861
|
// <- Note: [🚲]
|
|
5810
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5862
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5811
5863
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
5812
5864
|
|
|
5813
5865
|
${block(pipelineIdentification)}
|
|
@@ -5815,7 +5867,7 @@
|
|
|
5815
5867
|
}
|
|
5816
5868
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
5817
5869
|
// <- Note: [🚲]
|
|
5818
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5870
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5819
5871
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
5820
5872
|
|
|
5821
5873
|
${block(pipelineIdentification)}
|
|
@@ -5824,7 +5876,7 @@
|
|
|
5824
5876
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
5825
5877
|
if (!Array.isArray(pipeline.parameters)) {
|
|
5826
5878
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
5827
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
5879
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
5828
5880
|
Pipeline is valid JSON but with wrong structure
|
|
5829
5881
|
|
|
5830
5882
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -5835,7 +5887,7 @@
|
|
|
5835
5887
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
5836
5888
|
if (!Array.isArray(pipeline.tasks)) {
|
|
5837
5889
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
5838
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
5890
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
5839
5891
|
Pipeline is valid JSON but with wrong structure
|
|
5840
5892
|
|
|
5841
5893
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -5861,7 +5913,7 @@
|
|
|
5861
5913
|
// Note: Check each parameter individually
|
|
5862
5914
|
for (const parameter of pipeline.parameters) {
|
|
5863
5915
|
if (parameter.isInput && parameter.isOutput) {
|
|
5864
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5916
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5865
5917
|
|
|
5866
5918
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
5867
5919
|
|
|
@@ -5872,7 +5924,7 @@
|
|
|
5872
5924
|
if (!parameter.isInput &&
|
|
5873
5925
|
!parameter.isOutput &&
|
|
5874
5926
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
5875
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5927
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5876
5928
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
5877
5929
|
|
|
5878
5930
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -5884,7 +5936,7 @@
|
|
|
5884
5936
|
}
|
|
5885
5937
|
// Note: Testing that parameter is either input or result of some task
|
|
5886
5938
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
5887
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5939
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5888
5940
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
5889
5941
|
|
|
5890
5942
|
You can do one of these:
|
|
@@ -5900,14 +5952,14 @@
|
|
|
5900
5952
|
// Note: Checking each task individually
|
|
5901
5953
|
for (const task of pipeline.tasks) {
|
|
5902
5954
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
5903
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5955
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5904
5956
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
5905
5957
|
|
|
5906
5958
|
${block(pipelineIdentification)}
|
|
5907
5959
|
`));
|
|
5908
5960
|
}
|
|
5909
5961
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
5910
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5962
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5911
5963
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
5912
5964
|
|
|
5913
5965
|
${block(pipelineIdentification)}
|
|
@@ -5917,7 +5969,7 @@
|
|
|
5917
5969
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
5918
5970
|
if (!task.format &&
|
|
5919
5971
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
5920
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5972
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5921
5973
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
5922
5974
|
|
|
5923
5975
|
${block(pipelineIdentification)}
|
|
@@ -5925,7 +5977,7 @@
|
|
|
5925
5977
|
}
|
|
5926
5978
|
for (const joker of task.jokerParameterNames) {
|
|
5927
5979
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
5928
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5980
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5929
5981
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
5930
5982
|
|
|
5931
5983
|
${block(pipelineIdentification)}
|
|
@@ -5936,21 +5988,21 @@
|
|
|
5936
5988
|
if (task.expectations) {
|
|
5937
5989
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
5938
5990
|
if (min !== undefined && max !== undefined && min > max) {
|
|
5939
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5991
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5940
5992
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
5941
5993
|
|
|
5942
5994
|
${block(pipelineIdentification)}
|
|
5943
5995
|
`));
|
|
5944
5996
|
}
|
|
5945
5997
|
if (min !== undefined && min < 0) {
|
|
5946
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
5998
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5947
5999
|
Min expectation of ${unit} must be zero or positive
|
|
5948
6000
|
|
|
5949
6001
|
${block(pipelineIdentification)}
|
|
5950
6002
|
`));
|
|
5951
6003
|
}
|
|
5952
6004
|
if (max !== undefined && max <= 0) {
|
|
5953
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
6005
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
5954
6006
|
Max expectation of ${unit} must be positive
|
|
5955
6007
|
|
|
5956
6008
|
${block(pipelineIdentification)}
|
|
@@ -5972,7 +6024,7 @@
|
|
|
5972
6024
|
while (unresovedTasks.length > 0) {
|
|
5973
6025
|
if (loopLimit-- < 0) {
|
|
5974
6026
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
5975
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6027
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
5976
6028
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
5977
6029
|
|
|
5978
6030
|
${block(pipelineIdentification)}
|
|
@@ -5982,7 +6034,7 @@
|
|
|
5982
6034
|
if (currentlyResovedTasks.length === 0) {
|
|
5983
6035
|
throw new PipelineLogicError(
|
|
5984
6036
|
// TODO: [🐎] DRY
|
|
5985
|
-
spaceTrim.spaceTrim((block) => `
|
|
6037
|
+
spaceTrim$1.spaceTrim((block) => `
|
|
5986
6038
|
|
|
5987
6039
|
Can not resolve some parameters:
|
|
5988
6040
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -6317,7 +6369,7 @@
|
|
|
6317
6369
|
for (const pipeline of pipelines) {
|
|
6318
6370
|
// TODO: [👠] DRY
|
|
6319
6371
|
if (pipeline.pipelineUrl === undefined) {
|
|
6320
|
-
throw new PipelineUrlError(spaceTrim.spaceTrim(`
|
|
6372
|
+
throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
|
|
6321
6373
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
6322
6374
|
|
|
6323
6375
|
File:
|
|
@@ -6339,7 +6391,7 @@
|
|
|
6339
6391
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
6340
6392
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
6341
6393
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
6342
|
-
throw new PipelineUrlError(spaceTrim.spaceTrim(`
|
|
6394
|
+
throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
|
|
6343
6395
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
6344
6396
|
|
|
6345
6397
|
Conflicting files:
|
|
@@ -6371,13 +6423,13 @@
|
|
|
6371
6423
|
const pipeline = this.collection.get(url);
|
|
6372
6424
|
if (!pipeline) {
|
|
6373
6425
|
if (this.listPipelines().length === 0) {
|
|
6374
|
-
throw new NotFoundError(spaceTrim.spaceTrim(`
|
|
6426
|
+
throw new NotFoundError(spaceTrim$1.spaceTrim(`
|
|
6375
6427
|
Pipeline with url "${url}" not found
|
|
6376
6428
|
|
|
6377
6429
|
No pipelines available
|
|
6378
6430
|
`));
|
|
6379
6431
|
}
|
|
6380
|
-
throw new NotFoundError(spaceTrim.spaceTrim((block) => `
|
|
6432
|
+
throw new NotFoundError(spaceTrim$1.spaceTrim((block) => `
|
|
6381
6433
|
Pipeline with url "${url}" not found
|
|
6382
6434
|
|
|
6383
6435
|
Available pipelines:
|
|
@@ -6535,11 +6587,11 @@
|
|
|
6535
6587
|
throw deserializeError(errors[0]);
|
|
6536
6588
|
}
|
|
6537
6589
|
else {
|
|
6538
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
6590
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
6539
6591
|
Multiple errors occurred during Promptbook execution
|
|
6540
6592
|
|
|
6541
6593
|
${block(errors
|
|
6542
|
-
.map(({ name, stack, message }, index) => spaceTrim.spaceTrim((block) => `
|
|
6594
|
+
.map(({ name, stack, message }, index) => spaceTrim$1.spaceTrim((block) => `
|
|
6543
6595
|
${name} ${index + 1}:
|
|
6544
6596
|
${block(stack || message)}
|
|
6545
6597
|
`))
|
|
@@ -6878,7 +6930,7 @@
|
|
|
6878
6930
|
}
|
|
6879
6931
|
catch (error) {
|
|
6880
6932
|
assertsError(error);
|
|
6881
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6933
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6882
6934
|
Can not extract variables from the script
|
|
6883
6935
|
${block(error.stack || error.message)}
|
|
6884
6936
|
|
|
@@ -7478,7 +7530,7 @@
|
|
|
7478
7530
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
7479
7531
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
7480
7532
|
if (isJokerAttempt && !jokerParameterName) {
|
|
7481
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
7533
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
7482
7534
|
Joker not found in attempt ${attemptIndex}
|
|
7483
7535
|
|
|
7484
7536
|
${block(pipelineIdentification)}
|
|
@@ -7489,7 +7541,7 @@
|
|
|
7489
7541
|
$ongoingTaskResult.$expectError = null;
|
|
7490
7542
|
if (isJokerAttempt) {
|
|
7491
7543
|
if (parameters[jokerParameterName] === undefined) {
|
|
7492
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
7544
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
7493
7545
|
Joker parameter {${jokerParameterName}} not defined
|
|
7494
7546
|
|
|
7495
7547
|
${block(pipelineIdentification)}
|
|
@@ -7547,7 +7599,7 @@
|
|
|
7547
7599
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
7548
7600
|
break variant;
|
|
7549
7601
|
case 'EMBEDDING':
|
|
7550
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
7602
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
7551
7603
|
Embedding model can not be used in pipeline
|
|
7552
7604
|
|
|
7553
7605
|
This should be catched during parsing
|
|
@@ -7558,7 +7610,7 @@
|
|
|
7558
7610
|
break variant;
|
|
7559
7611
|
// <- case [🤖]:
|
|
7560
7612
|
default:
|
|
7561
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
7613
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
7562
7614
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
7563
7615
|
|
|
7564
7616
|
${block(pipelineIdentification)}
|
|
@@ -7569,14 +7621,14 @@
|
|
|
7569
7621
|
break;
|
|
7570
7622
|
case 'SCRIPT_TASK':
|
|
7571
7623
|
if (arrayableToArray(tools.script).length === 0) {
|
|
7572
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
7624
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
7573
7625
|
No script execution tools are available
|
|
7574
7626
|
|
|
7575
7627
|
${block(pipelineIdentification)}
|
|
7576
7628
|
`));
|
|
7577
7629
|
}
|
|
7578
7630
|
if (!task.contentLanguage) {
|
|
7579
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
7631
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
7580
7632
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
7581
7633
|
|
|
7582
7634
|
${block(pipelineIdentification)}
|
|
@@ -7607,7 +7659,7 @@
|
|
|
7607
7659
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
7608
7660
|
}
|
|
7609
7661
|
else {
|
|
7610
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
7662
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
7611
7663
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
7612
7664
|
|
|
7613
7665
|
${block(pipelineIdentification)}
|
|
@@ -7621,7 +7673,7 @@
|
|
|
7621
7673
|
break taskType;
|
|
7622
7674
|
case 'DIALOG_TASK':
|
|
7623
7675
|
if (tools.userInterface === undefined) {
|
|
7624
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
7676
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
7625
7677
|
User interface tools are not available
|
|
7626
7678
|
|
|
7627
7679
|
${block(pipelineIdentification)}
|
|
@@ -7639,7 +7691,7 @@
|
|
|
7639
7691
|
break taskType;
|
|
7640
7692
|
// <- case: [🅱]
|
|
7641
7693
|
default:
|
|
7642
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
7694
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
7643
7695
|
Unknown execution type "${task.taskType}"
|
|
7644
7696
|
|
|
7645
7697
|
${block(pipelineIdentification)}
|
|
@@ -7737,7 +7789,7 @@
|
|
|
7737
7789
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
7738
7790
|
// Note: Create a summary of all failures
|
|
7739
7791
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
7740
|
-
.map((failure) => spaceTrim.spaceTrim((block) => {
|
|
7792
|
+
.map((failure) => spaceTrim$1.spaceTrim((block) => {
|
|
7741
7793
|
var _a, _b;
|
|
7742
7794
|
return `
|
|
7743
7795
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -7747,14 +7799,14 @@
|
|
|
7747
7799
|
Result:
|
|
7748
7800
|
${block(failure.result === null
|
|
7749
7801
|
? 'null'
|
|
7750
|
-
: spaceTrim.spaceTrim(failure.result)
|
|
7802
|
+
: spaceTrim$1.spaceTrim(failure.result)
|
|
7751
7803
|
.split('\n')
|
|
7752
7804
|
.map((line) => `> ${line}`)
|
|
7753
7805
|
.join('\n'))}
|
|
7754
7806
|
`;
|
|
7755
7807
|
}))
|
|
7756
7808
|
.join('\n\n---\n\n');
|
|
7757
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
|
|
7809
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => {
|
|
7758
7810
|
var _a;
|
|
7759
7811
|
return `
|
|
7760
7812
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -7774,7 +7826,7 @@
|
|
|
7774
7826
|
}
|
|
7775
7827
|
}
|
|
7776
7828
|
if ($ongoingTaskResult.$resultString === null) {
|
|
7777
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
7829
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
7778
7830
|
Something went wrong and prompt result is null
|
|
7779
7831
|
|
|
7780
7832
|
${block(pipelineIdentification)}
|
|
@@ -8080,7 +8132,7 @@
|
|
|
8080
8132
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
8081
8133
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
8082
8134
|
if (reservedParameters[parameterName] === undefined) {
|
|
8083
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
8135
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
8084
8136
|
Reserved parameter {${parameterName}} is not defined
|
|
8085
8137
|
|
|
8086
8138
|
${block(pipelineIdentification)}
|
|
@@ -8106,7 +8158,7 @@
|
|
|
8106
8158
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
8107
8159
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
8108
8160
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
8109
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
8161
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
8110
8162
|
Dependent parameters are not consistent with used parameters:
|
|
8111
8163
|
|
|
8112
8164
|
Dependent parameters:
|
|
@@ -8150,7 +8202,7 @@
|
|
|
8150
8202
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
8151
8203
|
// Houston, we have a problem
|
|
8152
8204
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
8153
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
8205
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
8154
8206
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
8155
8207
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
8156
8208
|
|
|
@@ -8219,7 +8271,7 @@
|
|
|
8219
8271
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
8220
8272
|
if (parametersToPass[parameter.name] === undefined) {
|
|
8221
8273
|
// [4]
|
|
8222
|
-
$warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
8274
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
8223
8275
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
8224
8276
|
|
|
8225
8277
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -8327,7 +8379,7 @@
|
|
|
8327
8379
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
8328
8380
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
8329
8381
|
if (parameter === undefined) {
|
|
8330
|
-
warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
8382
|
+
warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
8331
8383
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
8332
8384
|
|
|
8333
8385
|
${block(pipelineIdentification)}
|
|
@@ -8342,7 +8394,7 @@
|
|
|
8342
8394
|
// TODO: [🧠] This should be also non-critical error
|
|
8343
8395
|
return exportJson({
|
|
8344
8396
|
name: 'pipelineExecutorResult',
|
|
8345
|
-
message: spaceTrim.spaceTrim((block) => `
|
|
8397
|
+
message: spaceTrim$1.spaceTrim((block) => `
|
|
8346
8398
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
8347
8399
|
|
|
8348
8400
|
${block(pipelineIdentification)}
|
|
@@ -8351,7 +8403,7 @@
|
|
|
8351
8403
|
value: {
|
|
8352
8404
|
isSuccessful: false,
|
|
8353
8405
|
errors: [
|
|
8354
|
-
new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
8406
|
+
new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
8355
8407
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
8356
8408
|
|
|
8357
8409
|
${block(pipelineIdentification)}
|
|
@@ -8378,7 +8430,7 @@
|
|
|
8378
8430
|
while (unresovedTasks.length > 0) {
|
|
8379
8431
|
if (loopLimit-- < 0) {
|
|
8380
8432
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
8381
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
8433
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
8382
8434
|
Loop limit reached during resolving parameters pipeline execution
|
|
8383
8435
|
|
|
8384
8436
|
${block(pipelineIdentification)}
|
|
@@ -8388,7 +8440,7 @@
|
|
|
8388
8440
|
if (!currentTask && resolving.length === 0) {
|
|
8389
8441
|
throw new UnexpectedError(
|
|
8390
8442
|
// TODO: [🐎] DRY
|
|
8391
|
-
spaceTrim.spaceTrim((block) => `
|
|
8443
|
+
spaceTrim$1.spaceTrim((block) => `
|
|
8392
8444
|
Can not resolve some parameters:
|
|
8393
8445
|
|
|
8394
8446
|
${block(pipelineIdentification)}
|
|
@@ -8428,7 +8480,7 @@
|
|
|
8428
8480
|
tools,
|
|
8429
8481
|
onProgress(newOngoingResult) {
|
|
8430
8482
|
if (isReturned) {
|
|
8431
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
8483
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
8432
8484
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
8433
8485
|
|
|
8434
8486
|
${block(pipelineIdentification)}
|
|
@@ -8445,7 +8497,7 @@
|
|
|
8445
8497
|
},
|
|
8446
8498
|
logLlmCall,
|
|
8447
8499
|
$executionReport: executionReport,
|
|
8448
|
-
pipelineIdentification: spaceTrim.spaceTrim((block) => `
|
|
8500
|
+
pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
|
|
8449
8501
|
${block(pipelineIdentification)}
|
|
8450
8502
|
Task name: ${currentTask.name}
|
|
8451
8503
|
Task title: ${currentTask.title}
|
|
@@ -8554,7 +8606,7 @@
|
|
|
8554
8606
|
preparedPipeline = pipeline;
|
|
8555
8607
|
}
|
|
8556
8608
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
8557
|
-
console.warn(spaceTrim.spaceTrim((block) => `
|
|
8609
|
+
console.warn(spaceTrim$1.spaceTrim((block) => `
|
|
8558
8610
|
Pipeline is not prepared
|
|
8559
8611
|
|
|
8560
8612
|
${block(pipelineIdentification)}
|
|
@@ -8579,7 +8631,7 @@
|
|
|
8579
8631
|
tools,
|
|
8580
8632
|
onProgress,
|
|
8581
8633
|
logLlmCall,
|
|
8582
|
-
pipelineIdentification: spaceTrim.spaceTrim((block) => `
|
|
8634
|
+
pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
|
|
8583
8635
|
${block(pipelineIdentification)}
|
|
8584
8636
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
8585
8637
|
`),
|
|
@@ -9166,7 +9218,7 @@
|
|
|
9166
9218
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
9167
9219
|
knowledgePiecesCount > 0 &&
|
|
9168
9220
|
!dependentParameterNames.includes('knowledge')) {
|
|
9169
|
-
preparedContent = spaceTrim.spaceTrim(`
|
|
9221
|
+
preparedContent = spaceTrim$1.spaceTrim(`
|
|
9170
9222
|
{content}
|
|
9171
9223
|
|
|
9172
9224
|
## Knowledge
|
|
@@ -11683,7 +11735,7 @@
|
|
|
11683
11735
|
function getParserForCommand(command) {
|
|
11684
11736
|
const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
|
|
11685
11737
|
if (commandParser === undefined) {
|
|
11686
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
11738
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
11687
11739
|
Command ${command.type} parser is not found
|
|
11688
11740
|
|
|
11689
11741
|
${block(JSON.stringify(command, null, 4)
|
|
@@ -11759,7 +11811,7 @@
|
|
|
11759
11811
|
.map(removeMarkdownFormatting)
|
|
11760
11812
|
.map((item) => item.trim());
|
|
11761
11813
|
if (items.length === 0 || items[0] === '') {
|
|
11762
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
11814
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
11763
11815
|
Malformed command:
|
|
11764
11816
|
- ${raw}
|
|
11765
11817
|
|
|
@@ -11795,7 +11847,7 @@
|
|
|
11795
11847
|
return command;
|
|
11796
11848
|
}
|
|
11797
11849
|
}
|
|
11798
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
11850
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
11799
11851
|
Malformed or unknown command:
|
|
11800
11852
|
- ${raw}
|
|
11801
11853
|
|
|
@@ -11846,7 +11898,7 @@
|
|
|
11846
11898
|
if (!(error instanceof ParseError)) {
|
|
11847
11899
|
throw error;
|
|
11848
11900
|
}
|
|
11849
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
11901
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
11850
11902
|
Invalid ${commandName} command:
|
|
11851
11903
|
|
|
11852
11904
|
Your command:
|
|
@@ -12162,7 +12214,7 @@
|
|
|
12162
12214
|
* @public exported from `@promptbook/markdown-utils`
|
|
12163
12215
|
*/
|
|
12164
12216
|
function removeMarkdownComments(content) {
|
|
12165
|
-
return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
12217
|
+
return spaceTrim$1.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
12166
12218
|
}
|
|
12167
12219
|
|
|
12168
12220
|
/**
|
|
@@ -12478,7 +12530,7 @@
|
|
|
12478
12530
|
if (pipelineString.startsWith('#!')) {
|
|
12479
12531
|
const [shebangLine, ...restLines] = pipelineString.split('\n');
|
|
12480
12532
|
if (!(shebangLine || '').includes('ptbk')) {
|
|
12481
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12533
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
12482
12534
|
It seems that you try to parse a book file which has non-standard shebang line for book files:
|
|
12483
12535
|
Shebang line must contain 'ptbk'
|
|
12484
12536
|
|
|
@@ -12494,7 +12546,7 @@
|
|
|
12494
12546
|
pipelineString = validatePipelineString(restLines.join('\n'));
|
|
12495
12547
|
}
|
|
12496
12548
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
12497
|
-
pipelineString = spaceTrim.spaceTrim(pipelineString);
|
|
12549
|
+
pipelineString = spaceTrim$1.spaceTrim(pipelineString);
|
|
12498
12550
|
// <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
|
|
12499
12551
|
pipelineString = deflatePipeline(pipelineString);
|
|
12500
12552
|
// ==============
|
|
@@ -12506,7 +12558,7 @@
|
|
|
12506
12558
|
// ==============
|
|
12507
12559
|
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
12508
12560
|
if (pipelineHead === undefined) {
|
|
12509
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
12561
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
12510
12562
|
Pipeline head is not defined
|
|
12511
12563
|
|
|
12512
12564
|
${block(getPipelineIdentification())}
|
|
@@ -12515,7 +12567,7 @@
|
|
|
12515
12567
|
`));
|
|
12516
12568
|
}
|
|
12517
12569
|
if (pipelineHead.level !== 1) {
|
|
12518
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
12570
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
12519
12571
|
Pipeline head is not h1
|
|
12520
12572
|
|
|
12521
12573
|
${block(getPipelineIdentification())}
|
|
@@ -12524,7 +12576,7 @@
|
|
|
12524
12576
|
`));
|
|
12525
12577
|
}
|
|
12526
12578
|
if (!pipelineSections.every((section) => section.level === 2)) {
|
|
12527
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
12579
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
12528
12580
|
Not every pipeline section is h2
|
|
12529
12581
|
|
|
12530
12582
|
${block(getPipelineIdentification())}
|
|
@@ -12537,7 +12589,7 @@
|
|
|
12537
12589
|
const defineParam = (parameterCommand) => {
|
|
12538
12590
|
const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
|
|
12539
12591
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
12540
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12592
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
12541
12593
|
Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
|
|
12542
12594
|
|
|
12543
12595
|
${block(getPipelineIdentification())}
|
|
@@ -12548,7 +12600,7 @@
|
|
|
12548
12600
|
existingParameter.description &&
|
|
12549
12601
|
existingParameter.description !== parameterDescription &&
|
|
12550
12602
|
parameterDescription) {
|
|
12551
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12603
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
12552
12604
|
Parameter \`{${parameterName}}\` is defined multiple times with different description:
|
|
12553
12605
|
|
|
12554
12606
|
${block(getPipelineIdentification())}
|
|
@@ -12586,7 +12638,7 @@
|
|
|
12586
12638
|
description = description.split(/^>.*$/gm).join('');
|
|
12587
12639
|
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
12588
12640
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
12589
|
-
description = spaceTrim.spaceTrim(description);
|
|
12641
|
+
description = spaceTrim$1.spaceTrim(description);
|
|
12590
12642
|
if (description === '') {
|
|
12591
12643
|
description = undefined;
|
|
12592
12644
|
}
|
|
@@ -12597,7 +12649,7 @@
|
|
|
12597
12649
|
const command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
12598
12650
|
const commandParser = getParserForCommand(command);
|
|
12599
12651
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
12600
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12652
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
12601
12653
|
Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
|
|
12602
12654
|
|
|
12603
12655
|
${block(getPipelineIdentification())}
|
|
@@ -12611,7 +12663,7 @@
|
|
|
12611
12663
|
if (!(error instanceof ParseError)) {
|
|
12612
12664
|
throw error;
|
|
12613
12665
|
}
|
|
12614
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12666
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
12615
12667
|
Command ${command.type} failed to apply to the pipeline
|
|
12616
12668
|
|
|
12617
12669
|
The error:
|
|
@@ -12664,7 +12716,7 @@
|
|
|
12664
12716
|
description = description.split(/^>.*$/gm).join('');
|
|
12665
12717
|
//Note: Remove lists and return statement - TODO: [🎾]
|
|
12666
12718
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
12667
|
-
description = spaceTrim.spaceTrim(description);
|
|
12719
|
+
description = spaceTrim$1.spaceTrim(description);
|
|
12668
12720
|
if (description === '') {
|
|
12669
12721
|
description = undefined;
|
|
12670
12722
|
}
|
|
@@ -12698,7 +12750,7 @@
|
|
|
12698
12750
|
for (const { listItem, command } of commands) {
|
|
12699
12751
|
const commandParser = getParserForCommand(command);
|
|
12700
12752
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
12701
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12753
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
12702
12754
|
Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
|
|
12703
12755
|
|
|
12704
12756
|
${block(getPipelineIdentification())}
|
|
@@ -12713,7 +12765,7 @@
|
|
|
12713
12765
|
if (!(error instanceof ParseError)) {
|
|
12714
12766
|
throw error;
|
|
12715
12767
|
}
|
|
12716
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12768
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
12717
12769
|
Command \`${command.type}\` failed to apply to the task
|
|
12718
12770
|
|
|
12719
12771
|
The error:
|
|
@@ -12744,14 +12796,14 @@
|
|
|
12744
12796
|
// TODO: [🍧] Should be done in SECTION command
|
|
12745
12797
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
12746
12798
|
if (!language) {
|
|
12747
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12799
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
12748
12800
|
You must specify the language of the script in the \`SCRIPT\` task
|
|
12749
12801
|
|
|
12750
12802
|
${block(getPipelineIdentification())}
|
|
12751
12803
|
`));
|
|
12752
12804
|
}
|
|
12753
12805
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
12754
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12806
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
12755
12807
|
Script language ${language} is not supported.
|
|
12756
12808
|
|
|
12757
12809
|
Supported languages are:
|
|
@@ -12969,7 +13021,7 @@
|
|
|
12969
13021
|
.filter(([MERMAID_NAME]) => (inputAndIntermediateParametersMermaid + outputParametersMermaid).includes(MERMAID_NAME))
|
|
12970
13022
|
.map(([MERMAID_NAME, title]) => `${MERMAID_NAME}((${title})):::${MERMAID_NAME}`)
|
|
12971
13023
|
.join('\n');
|
|
12972
|
-
const promptbookMermaid = spaceTrim.spaceTrim((block) => `
|
|
13024
|
+
const promptbookMermaid = spaceTrim$1.spaceTrim((block) => `
|
|
12973
13025
|
|
|
12974
13026
|
%% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
|
|
12975
13027
|
|
|
@@ -13136,7 +13188,7 @@
|
|
|
13136
13188
|
let trimmedText = text;
|
|
13137
13189
|
// Remove leading and trailing spaces and newlines
|
|
13138
13190
|
if (isTrimmed) {
|
|
13139
|
-
trimmedText = spaceTrim.spaceTrim(trimmedText);
|
|
13191
|
+
trimmedText = spaceTrim$1.spaceTrim(trimmedText);
|
|
13140
13192
|
}
|
|
13141
13193
|
let processedText = trimmedText;
|
|
13142
13194
|
if (isIntroduceSentenceRemoved) {
|
|
@@ -13145,7 +13197,7 @@
|
|
|
13145
13197
|
// Remove the introduce sentence and quotes by replacing it with an empty string
|
|
13146
13198
|
processedText = processedText.replace(introduceSentenceRegex, '');
|
|
13147
13199
|
}
|
|
13148
|
-
processedText = spaceTrim.spaceTrim(processedText);
|
|
13200
|
+
processedText = spaceTrim$1.spaceTrim(processedText);
|
|
13149
13201
|
}
|
|
13150
13202
|
if (processedText.length < 3) {
|
|
13151
13203
|
return trimmedText;
|
|
@@ -13218,13 +13270,13 @@
|
|
|
13218
13270
|
* @public exported from `@promptbook/markdown-utils`
|
|
13219
13271
|
*/
|
|
13220
13272
|
function trimCodeBlock(value) {
|
|
13221
|
-
value = spaceTrim.spaceTrim(value);
|
|
13273
|
+
value = spaceTrim$1.spaceTrim(value);
|
|
13222
13274
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
13223
13275
|
return value;
|
|
13224
13276
|
}
|
|
13225
13277
|
value = value.replace(/^```[a-z]*/i, '');
|
|
13226
13278
|
value = value.replace(/```$/i, '');
|
|
13227
|
-
value = spaceTrim.spaceTrim(value);
|
|
13279
|
+
value = spaceTrim$1.spaceTrim(value);
|
|
13228
13280
|
return value;
|
|
13229
13281
|
}
|
|
13230
13282
|
|
|
@@ -13237,9 +13289,9 @@
|
|
|
13237
13289
|
* @public exported from `@promptbook/markdown-utils`
|
|
13238
13290
|
*/
|
|
13239
13291
|
function trimEndOfCodeBlock(value) {
|
|
13240
|
-
value = spaceTrim.spaceTrim(value);
|
|
13292
|
+
value = spaceTrim$1.spaceTrim(value);
|
|
13241
13293
|
value = value.replace(/```$/g, '');
|
|
13242
|
-
value = spaceTrim.spaceTrim(value);
|
|
13294
|
+
value = spaceTrim$1.spaceTrim(value);
|
|
13243
13295
|
return value;
|
|
13244
13296
|
}
|
|
13245
13297
|
|
|
@@ -14191,7 +14243,7 @@
|
|
|
14191
14243
|
const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
|
|
14192
14244
|
const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
|
|
14193
14245
|
const sectionMatch = content.match(sectionRegex);
|
|
14194
|
-
const contentToInsert = spaceTrim.spaceTrim((block) => `
|
|
14246
|
+
const contentToInsert = spaceTrim$1.spaceTrim((block) => `
|
|
14195
14247
|
<!--${sectionName}-->
|
|
14196
14248
|
${block(warningLine)}
|
|
14197
14249
|
${block(sectionContent)}
|
|
@@ -14204,7 +14256,7 @@
|
|
|
14204
14256
|
const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
|
|
14205
14257
|
if (placeForSection !== null) {
|
|
14206
14258
|
const [heading] = placeForSection;
|
|
14207
|
-
return content.replace(heading, spaceTrim.spaceTrim((block) => `
|
|
14259
|
+
return content.replace(heading, spaceTrim$1.spaceTrim((block) => `
|
|
14208
14260
|
${block(contentToInsert)}
|
|
14209
14261
|
|
|
14210
14262
|
${block(heading)}
|
|
@@ -14213,7 +14265,7 @@
|
|
|
14213
14265
|
console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
|
|
14214
14266
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
14215
14267
|
// <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
|
|
14216
|
-
return spaceTrim.spaceTrim((block) => `
|
|
14268
|
+
return spaceTrim$1.spaceTrim((block) => `
|
|
14217
14269
|
${block(content)}
|
|
14218
14270
|
|
|
14219
14271
|
${block(contentToInsert)}
|
|
@@ -14237,7 +14289,7 @@
|
|
|
14237
14289
|
return { href: `#${task.name}`, title: task.title };
|
|
14238
14290
|
},
|
|
14239
14291
|
});
|
|
14240
|
-
const promptbookMermaidBlock = spaceTrim.spaceTrim((block) => `
|
|
14292
|
+
const promptbookMermaidBlock = spaceTrim$1.spaceTrim((block) => `
|
|
14241
14293
|
\`\`\`mermaid
|
|
14242
14294
|
${block(promptbookMermaid)}
|
|
14243
14295
|
\`\`\`
|
|
@@ -14434,7 +14486,7 @@
|
|
|
14434
14486
|
function executionReportJsonToString(executionReportJson, options) {
|
|
14435
14487
|
var _a, _b, _c, _d, _e, _f;
|
|
14436
14488
|
const { taxRate, chartsWidth } = { ...ExecutionReportStringOptionsDefaults, ...(options || {}) };
|
|
14437
|
-
let executionReportString = spaceTrim.spaceTrim((block) => `
|
|
14489
|
+
let executionReportString = spaceTrim$1.spaceTrim((block) => `
|
|
14438
14490
|
# ${executionReportJson.title || 'Execution report'}
|
|
14439
14491
|
|
|
14440
14492
|
${block(executionReportJson.description || '')}
|
|
@@ -14556,7 +14608,7 @@
|
|
|
14556
14608
|
if (just(true)) {
|
|
14557
14609
|
executionReportString +=
|
|
14558
14610
|
'\n\n\n\n' +
|
|
14559
|
-
spaceTrim.spaceTrim((block) => {
|
|
14611
|
+
spaceTrim$1.spaceTrim((block) => {
|
|
14560
14612
|
var _a;
|
|
14561
14613
|
return `
|
|
14562
14614
|
|
|
@@ -14575,7 +14627,7 @@
|
|
|
14575
14627
|
executionReportString += '*No result*';
|
|
14576
14628
|
}
|
|
14577
14629
|
else if (typeof promptExecution.result.content === 'string') {
|
|
14578
|
-
executionReportString += spaceTrim.spaceTrim((block) => `
|
|
14630
|
+
executionReportString += spaceTrim$1.spaceTrim((block) => `
|
|
14579
14631
|
\`\`\`
|
|
14580
14632
|
${block(escapeMarkdownBlock(promptExecution.result.content))}
|
|
14581
14633
|
\`\`\`
|
|
@@ -14588,7 +14640,7 @@
|
|
|
14588
14640
|
if (promptExecution.error && promptExecution.error.message) {
|
|
14589
14641
|
executionReportString +=
|
|
14590
14642
|
'\n\n\n\n' +
|
|
14591
|
-
spaceTrim.spaceTrim((block) => `
|
|
14643
|
+
spaceTrim$1.spaceTrim((block) => `
|
|
14592
14644
|
|
|
14593
14645
|
### Error
|
|
14594
14646
|
|
|
@@ -16067,7 +16119,7 @@
|
|
|
16067
16119
|
response.type('text/html').send(renderServerIndexHtml(serverInfo));
|
|
16068
16120
|
}
|
|
16069
16121
|
else {
|
|
16070
|
-
response.type('text/markdown').send(await spaceTrim.spaceTrim(async (block) => `
|
|
16122
|
+
response.type('text/markdown').send(await spaceTrim$1.spaceTrim(async (block) => `
|
|
16071
16123
|
# Promptbook
|
|
16072
16124
|
|
|
16073
16125
|
> ${block(CLAIM)}
|
|
@@ -16681,7 +16733,7 @@
|
|
|
16681
16733
|
*/
|
|
16682
16734
|
async function promptbookCli() {
|
|
16683
16735
|
if (!$isRunningInNode()) {
|
|
16684
|
-
throw new EnvironmentMismatchError(spaceTrim.spaceTrim(`
|
|
16736
|
+
throw new EnvironmentMismatchError(spaceTrim$1.spaceTrim(`
|
|
16685
16737
|
Function promptbookCli is initiator of CLI script and should be run in Node.js environment.
|
|
16686
16738
|
|
|
16687
16739
|
- In browser use function exported from \`@promptbook/utils\` or \`@promptbook/core\` directly, for example \`prettifyPipelineString\`.
|
|
@@ -20528,18 +20580,26 @@
|
|
|
20528
20580
|
modelName: 'assistant',
|
|
20529
20581
|
// <- [🧠] What is the best value here
|
|
20530
20582
|
});
|
|
20583
|
+
// Build thread messages: include previous thread messages + current user message
|
|
20584
|
+
const threadMessages = [];
|
|
20585
|
+
// TODO: [🈹] Maybe this should not be here but in other place, look at commit 39d705e75e5bcf7a818c3af36bc13e1c8475c30c
|
|
20586
|
+
// Add previous messages from thread (if any)
|
|
20587
|
+
if ('thread' in prompt &&
|
|
20588
|
+
Array.isArray(prompt.thread)) {
|
|
20589
|
+
const previousMessages = prompt.thread.map((msg) => ({
|
|
20590
|
+
role: (msg.role === 'assistant' ? 'assistant' : 'user'),
|
|
20591
|
+
content: msg.content,
|
|
20592
|
+
}));
|
|
20593
|
+
threadMessages.push(...previousMessages);
|
|
20594
|
+
}
|
|
20595
|
+
// Always add the current user message
|
|
20596
|
+
threadMessages.push({ role: 'user', content: rawPromptContent });
|
|
20531
20597
|
const rawRequest = {
|
|
20532
20598
|
// TODO: [👨👨👧👧] ...modelSettings,
|
|
20533
20599
|
// TODO: [👨👨👧👧][🧠] What about system message for assistants, does it make sense - combination of OpenAI assistants with Promptbook Personas
|
|
20534
20600
|
assistant_id: this.assistantId,
|
|
20535
20601
|
thread: {
|
|
20536
|
-
messages:
|
|
20537
|
-
Array.isArray(prompt.thread)
|
|
20538
|
-
? prompt.thread.map((msg) => ({
|
|
20539
|
-
role: msg.role === 'assistant' ? 'assistant' : 'user',
|
|
20540
|
-
content: msg.content,
|
|
20541
|
-
}))
|
|
20542
|
-
: [{ role: 'user', content: rawPromptContent }],
|
|
20602
|
+
messages: threadMessages,
|
|
20543
20603
|
},
|
|
20544
20604
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
20545
20605
|
};
|
|
@@ -20559,7 +20619,7 @@
|
|
|
20559
20619
|
console.info('textDelta', textDelta.value);
|
|
20560
20620
|
}
|
|
20561
20621
|
const chunk = {
|
|
20562
|
-
content:
|
|
20622
|
+
content: snapshot.value,
|
|
20563
20623
|
modelName: 'assistant',
|
|
20564
20624
|
timing: {
|
|
20565
20625
|
start,
|
|
@@ -22421,15 +22481,19 @@
|
|
|
22421
22481
|
*
|
|
22422
22482
|
* @private - TODO: [🧠] Maybe should be public?
|
|
22423
22483
|
*/
|
|
22424
|
-
function createCommitmentRegex(commitment, aliases = []) {
|
|
22484
|
+
function createCommitmentRegex(commitment, aliases = [], requiresContent = true) {
|
|
22425
22485
|
const allCommitments = [commitment, ...aliases];
|
|
22426
22486
|
const patterns = allCommitments.map((c) => {
|
|
22427
22487
|
const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
22428
22488
|
return escapedCommitment.split(/\s+/).join('\\s+');
|
|
22429
22489
|
});
|
|
22430
22490
|
const keywordPattern = patterns.join('|');
|
|
22431
|
-
|
|
22432
|
-
|
|
22491
|
+
if (requiresContent) {
|
|
22492
|
+
return new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
|
|
22493
|
+
}
|
|
22494
|
+
else {
|
|
22495
|
+
return new RegExp(`^\\s*(?<type>${keywordPattern})\\b(?:\\s+(?<contents>.+))?$`, 'gim');
|
|
22496
|
+
}
|
|
22433
22497
|
}
|
|
22434
22498
|
/**
|
|
22435
22499
|
* Generates a regex pattern to match a specific commitment type
|
|
@@ -22462,12 +22526,20 @@
|
|
|
22462
22526
|
this.type = type;
|
|
22463
22527
|
this.aliases = aliases;
|
|
22464
22528
|
}
|
|
22529
|
+
/**
|
|
22530
|
+
* Whether this commitment requires content.
|
|
22531
|
+
* If true, regex will match only if there is content after the commitment keyword.
|
|
22532
|
+
* If false, regex will match even if there is no content.
|
|
22533
|
+
*/
|
|
22534
|
+
get requiresContent() {
|
|
22535
|
+
return true;
|
|
22536
|
+
}
|
|
22465
22537
|
/**
|
|
22466
22538
|
* Creates a regex pattern to match this commitment in agent source
|
|
22467
22539
|
* Uses the existing createCommitmentRegex function as internal helper
|
|
22468
22540
|
*/
|
|
22469
22541
|
createRegex() {
|
|
22470
|
-
return createCommitmentRegex(this.type, this.aliases);
|
|
22542
|
+
return createCommitmentRegex(this.type, this.aliases, this.requiresContent);
|
|
22471
22543
|
}
|
|
22472
22544
|
/**
|
|
22473
22545
|
* Creates a regex pattern to match just the commitment type
|
|
@@ -22554,7 +22626,7 @@
|
|
|
22554
22626
|
* Markdown documentation for ACTION commitment.
|
|
22555
22627
|
*/
|
|
22556
22628
|
get documentation() {
|
|
22557
|
-
return spaceTrim.spaceTrim(`
|
|
22629
|
+
return spaceTrim$1.spaceTrim(`
|
|
22558
22630
|
# ${this.type}
|
|
22559
22631
|
|
|
22560
22632
|
Defines specific actions or capabilities that the agent can perform.
|
|
@@ -22619,6 +22691,12 @@
|
|
|
22619
22691
|
constructor() {
|
|
22620
22692
|
super('CLOSED');
|
|
22621
22693
|
}
|
|
22694
|
+
/**
|
|
22695
|
+
* The `CLOSED` commitment is standalone.
|
|
22696
|
+
*/
|
|
22697
|
+
get requiresContent() {
|
|
22698
|
+
return false;
|
|
22699
|
+
}
|
|
22622
22700
|
/**
|
|
22623
22701
|
* Short one-line description of CLOSED.
|
|
22624
22702
|
*/
|
|
@@ -22635,7 +22713,7 @@
|
|
|
22635
22713
|
* Markdown documentation for CLOSED commitment.
|
|
22636
22714
|
*/
|
|
22637
22715
|
get documentation() {
|
|
22638
|
-
return spaceTrim.spaceTrim(`
|
|
22716
|
+
return spaceTrim$1.spaceTrim(`
|
|
22639
22717
|
# CLOSED
|
|
22640
22718
|
|
|
22641
22719
|
Specifies that the agent **cannot** be modified by conversation with it.
|
|
@@ -22694,7 +22772,7 @@
|
|
|
22694
22772
|
* Markdown documentation for COMPONENT commitment.
|
|
22695
22773
|
*/
|
|
22696
22774
|
get documentation() {
|
|
22697
|
-
return spaceTrim.spaceTrim(`
|
|
22775
|
+
return spaceTrim$1.spaceTrim(`
|
|
22698
22776
|
# COMPONENT
|
|
22699
22777
|
|
|
22700
22778
|
Defines a UI component that the agent can render in the chat.
|
|
@@ -22766,7 +22844,7 @@
|
|
|
22766
22844
|
* Markdown documentation for DELETE commitment.
|
|
22767
22845
|
*/
|
|
22768
22846
|
get documentation() {
|
|
22769
|
-
return spaceTrim.spaceTrim(`
|
|
22847
|
+
return spaceTrim$1.spaceTrim(`
|
|
22770
22848
|
# DELETE (CANCEL, DISCARD, REMOVE)
|
|
22771
22849
|
|
|
22772
22850
|
A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
|
|
@@ -22888,7 +22966,7 @@
|
|
|
22888
22966
|
* Markdown documentation for FORMAT commitment.
|
|
22889
22967
|
*/
|
|
22890
22968
|
get documentation() {
|
|
22891
|
-
return spaceTrim.spaceTrim(`
|
|
22969
|
+
return spaceTrim$1.spaceTrim(`
|
|
22892
22970
|
# ${this.type}
|
|
22893
22971
|
|
|
22894
22972
|
Defines the specific output structure and formatting for responses (data formats, templates, structure).
|
|
@@ -22966,7 +23044,7 @@
|
|
|
22966
23044
|
* Markdown documentation for FROM commitment.
|
|
22967
23045
|
*/
|
|
22968
23046
|
get documentation() {
|
|
22969
|
-
return spaceTrim.spaceTrim(`
|
|
23047
|
+
return spaceTrim$1.spaceTrim(`
|
|
22970
23048
|
# ${this.type}
|
|
22971
23049
|
|
|
22972
23050
|
Inherits agent source from another agent.
|
|
@@ -23042,7 +23120,7 @@
|
|
|
23042
23120
|
* Markdown documentation for GOAL commitment.
|
|
23043
23121
|
*/
|
|
23044
23122
|
get documentation() {
|
|
23045
|
-
return spaceTrim.spaceTrim(`
|
|
23123
|
+
return spaceTrim$1.spaceTrim(`
|
|
23046
23124
|
# ${this.type}
|
|
23047
23125
|
|
|
23048
23126
|
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.
|
|
@@ -23106,227 +23184,6 @@
|
|
|
23106
23184
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23107
23185
|
*/
|
|
23108
23186
|
|
|
23109
|
-
/**
|
|
23110
|
-
* Placeholder commitment definition for commitments that are not yet implemented
|
|
23111
|
-
*
|
|
23112
|
-
* This commitment simply adds its content 1:1 into the system message,
|
|
23113
|
-
* preserving the original behavior until proper implementation is added.
|
|
23114
|
-
*
|
|
23115
|
-
* @public exported from `@promptbook/core`
|
|
23116
|
-
*/
|
|
23117
|
-
class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
23118
|
-
constructor(type) {
|
|
23119
|
-
super(type);
|
|
23120
|
-
}
|
|
23121
|
-
/**
|
|
23122
|
-
* Short one-line description of a placeholder commitment.
|
|
23123
|
-
*/
|
|
23124
|
-
get description() {
|
|
23125
|
-
return 'Placeholder commitment that appends content verbatim to the system message.';
|
|
23126
|
-
}
|
|
23127
|
-
/**
|
|
23128
|
-
* Icon for this commitment.
|
|
23129
|
-
*/
|
|
23130
|
-
get icon() {
|
|
23131
|
-
return '🚧';
|
|
23132
|
-
}
|
|
23133
|
-
/**
|
|
23134
|
-
* Markdown documentation available at runtime.
|
|
23135
|
-
*/
|
|
23136
|
-
get documentation() {
|
|
23137
|
-
return spaceTrim.spaceTrim(`
|
|
23138
|
-
# ${this.type}
|
|
23139
|
-
|
|
23140
|
-
This commitment is not yet fully implemented.
|
|
23141
|
-
|
|
23142
|
-
## Key aspects
|
|
23143
|
-
|
|
23144
|
-
- Content is appended directly to the system message.
|
|
23145
|
-
- No special processing or validation is performed.
|
|
23146
|
-
- Behavior preserved until proper implementation is added.
|
|
23147
|
-
|
|
23148
|
-
## Status
|
|
23149
|
-
|
|
23150
|
-
- **Status:** Placeholder implementation
|
|
23151
|
-
- **Effect:** Appends content prefixed by commitment type
|
|
23152
|
-
- **Future:** Will be replaced with specialized logic
|
|
23153
|
-
|
|
23154
|
-
## Examples
|
|
23155
|
-
|
|
23156
|
-
\`\`\`book
|
|
23157
|
-
Example Agent
|
|
23158
|
-
|
|
23159
|
-
PERSONA You are a helpful assistant
|
|
23160
|
-
${this.type} Your content here
|
|
23161
|
-
RULE Always be helpful
|
|
23162
|
-
\`\`\`
|
|
23163
|
-
`);
|
|
23164
|
-
}
|
|
23165
|
-
applyToAgentModelRequirements(requirements, content) {
|
|
23166
|
-
const trimmedContent = content.trim();
|
|
23167
|
-
if (!trimmedContent) {
|
|
23168
|
-
return requirements;
|
|
23169
|
-
}
|
|
23170
|
-
// Add the commitment content 1:1 to the system message
|
|
23171
|
-
const commitmentLine = `${this.type} ${trimmedContent}`;
|
|
23172
|
-
return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
|
|
23173
|
-
}
|
|
23174
|
-
}
|
|
23175
|
-
|
|
23176
|
-
/**
|
|
23177
|
-
* Registry of all available commitment definitions
|
|
23178
|
-
* This array contains instances of all commitment definitions
|
|
23179
|
-
* This is the single source of truth for all commitments in the system
|
|
23180
|
-
*
|
|
23181
|
-
* @private Use functions to access commitments instead of this array directly
|
|
23182
|
-
*/
|
|
23183
|
-
const COMMITMENT_REGISTRY = [];
|
|
23184
|
-
/**
|
|
23185
|
-
* Registers a new commitment definition
|
|
23186
|
-
* @param definition The commitment definition to register
|
|
23187
|
-
*
|
|
23188
|
-
* @public exported from `@promptbook/core`
|
|
23189
|
-
*/
|
|
23190
|
-
function registerCommitment(definition) {
|
|
23191
|
-
COMMITMENT_REGISTRY.push(definition);
|
|
23192
|
-
}
|
|
23193
|
-
/**
|
|
23194
|
-
* Gets a commitment definition by its type
|
|
23195
|
-
* @param type The commitment type to look up
|
|
23196
|
-
* @returns The commitment definition or null if not found
|
|
23197
|
-
*
|
|
23198
|
-
* @public exported from `@promptbook/core`
|
|
23199
|
-
*/
|
|
23200
|
-
function getCommitmentDefinition(type) {
|
|
23201
|
-
return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
|
|
23202
|
-
}
|
|
23203
|
-
/**
|
|
23204
|
-
* Gets all available commitment definitions
|
|
23205
|
-
* @returns Array of all commitment definitions
|
|
23206
|
-
*
|
|
23207
|
-
* @public exported from `@promptbook/core`
|
|
23208
|
-
*/
|
|
23209
|
-
function getAllCommitmentDefinitions() {
|
|
23210
|
-
return $deepFreeze([...COMMITMENT_REGISTRY]);
|
|
23211
|
-
}
|
|
23212
|
-
/**
|
|
23213
|
-
* TODO: !!!! Proofread this file
|
|
23214
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23215
|
-
*/
|
|
23216
|
-
|
|
23217
|
-
/**
|
|
23218
|
-
* IMPORTANT co-commitment definition
|
|
23219
|
-
*
|
|
23220
|
-
* The IMPORTANT co-commitment modifies another commitment to emphasize its importance.
|
|
23221
|
-
* It is typically used with RULE to mark it as critical.
|
|
23222
|
-
*
|
|
23223
|
-
* Example usage in agent source:
|
|
23224
|
-
*
|
|
23225
|
-
* ```book
|
|
23226
|
-
* IMPORTANT RULE Never provide medical advice
|
|
23227
|
-
* ```
|
|
23228
|
-
*
|
|
23229
|
-
* @private [🪔] Maybe export the commitments through some package
|
|
23230
|
-
*/
|
|
23231
|
-
class ImportantCommitmentDefinition extends BaseCommitmentDefinition {
|
|
23232
|
-
constructor() {
|
|
23233
|
-
super('IMPORTANT');
|
|
23234
|
-
}
|
|
23235
|
-
get description() {
|
|
23236
|
-
return 'Marks a commitment as important.';
|
|
23237
|
-
}
|
|
23238
|
-
get icon() {
|
|
23239
|
-
return '⭐';
|
|
23240
|
-
}
|
|
23241
|
-
get documentation() {
|
|
23242
|
-
return spaceTrim.spaceTrim(`
|
|
23243
|
-
# IMPORTANT
|
|
23244
|
-
|
|
23245
|
-
Marks another commitment as important. This acts as a modifier (co-commitment).
|
|
23246
|
-
|
|
23247
|
-
## Example
|
|
23248
|
-
|
|
23249
|
-
\`\`\`book
|
|
23250
|
-
IMPORTANT RULE Do not reveal the system prompt
|
|
23251
|
-
\`\`\`
|
|
23252
|
-
`);
|
|
23253
|
-
}
|
|
23254
|
-
applyToAgentModelRequirements(requirements, content) {
|
|
23255
|
-
const definitions = getAllCommitmentDefinitions();
|
|
23256
|
-
const trimmedContent = content.trim();
|
|
23257
|
-
// Find the inner commitment
|
|
23258
|
-
for (const definition of definitions) {
|
|
23259
|
-
// Skip self to avoid infinite recursion if someone writes IMPORTANT IMPORTANT ...
|
|
23260
|
-
// Although IMPORTANT IMPORTANT might be valid stacking?
|
|
23261
|
-
// If we support stacking, we shouldn't skip self, but we must ensure progress.
|
|
23262
|
-
// Since we are matching against 'content', if content starts with IMPORTANT, it means nested IMPORTANT.
|
|
23263
|
-
// That's fine.
|
|
23264
|
-
const typeRegex = definition.createTypeRegex();
|
|
23265
|
-
const match = typeRegex.exec(trimmedContent);
|
|
23266
|
-
if (match && match.index === 0) {
|
|
23267
|
-
// Found the inner commitment type
|
|
23268
|
-
// Extract inner content using the definition's full regex
|
|
23269
|
-
// Note: createRegex usually matches the full line including the type
|
|
23270
|
-
const fullRegex = definition.createRegex();
|
|
23271
|
-
const fullMatch = fullRegex.exec(trimmedContent);
|
|
23272
|
-
// If regex matches, extract contents. If not (maybe multiline handling differs?), fallback to rest of string
|
|
23273
|
-
let innerContent = '';
|
|
23274
|
-
if (fullMatch && fullMatch.groups && fullMatch.groups.contents) {
|
|
23275
|
-
innerContent = fullMatch.groups.contents;
|
|
23276
|
-
}
|
|
23277
|
-
else {
|
|
23278
|
-
// Fallback: remove the type from the start
|
|
23279
|
-
// This might be risky if regex is complex, but usually type regex matches the keyword
|
|
23280
|
-
const typeMatchString = match[0];
|
|
23281
|
-
innerContent = trimmedContent.substring(typeMatchString.length).trim();
|
|
23282
|
-
}
|
|
23283
|
-
// Apply the inner commitment
|
|
23284
|
-
const modifiedRequirements = definition.applyToAgentModelRequirements(requirements, innerContent);
|
|
23285
|
-
// Now modify the result to reflect "IMPORTANT" status
|
|
23286
|
-
// We compare the system message
|
|
23287
|
-
if (modifiedRequirements.systemMessage !== requirements.systemMessage) {
|
|
23288
|
-
const originalMsg = requirements.systemMessage;
|
|
23289
|
-
const newMsg = modifiedRequirements.systemMessage;
|
|
23290
|
-
// If the inner commitment appended something
|
|
23291
|
-
if (newMsg.startsWith(originalMsg)) {
|
|
23292
|
-
const appended = newMsg.substring(originalMsg.length);
|
|
23293
|
-
// Add "IMPORTANT: " prefix to the appended part
|
|
23294
|
-
// We need to be careful about newlines
|
|
23295
|
-
// Heuristic: If appended starts with separator (newlines), preserve them
|
|
23296
|
-
const matchSep = appended.match(/^(\s*)(.*)/s);
|
|
23297
|
-
if (matchSep) {
|
|
23298
|
-
const [, separator, text] = matchSep;
|
|
23299
|
-
// Check if it already has "Rule:" prefix or similar
|
|
23300
|
-
// We want "IMPORTANT Rule: ..."
|
|
23301
|
-
// Let's just prepend IMPORTANT to the text
|
|
23302
|
-
// But formatted nicely
|
|
23303
|
-
// If it's a rule: "\n\nRule: content"
|
|
23304
|
-
// We want "\n\nIMPORTANT Rule: content"
|
|
23305
|
-
const importantText = `IMPORTANT ${text}`;
|
|
23306
|
-
return {
|
|
23307
|
-
...modifiedRequirements,
|
|
23308
|
-
systemMessage: originalMsg + separator + importantText
|
|
23309
|
-
};
|
|
23310
|
-
}
|
|
23311
|
-
}
|
|
23312
|
-
}
|
|
23313
|
-
// If no system message change or we couldn't detect how to modify it, just return the modified requirements
|
|
23314
|
-
// Maybe the inner commitment modified metadata?
|
|
23315
|
-
return modifiedRequirements;
|
|
23316
|
-
}
|
|
23317
|
-
}
|
|
23318
|
-
// If no inner commitment found, treat as a standalone note?
|
|
23319
|
-
// Or warn?
|
|
23320
|
-
// For now, treat as no-op or maybe just append as text?
|
|
23321
|
-
// Let's treat as Note if fallback? No, explicit is better.
|
|
23322
|
-
console.warn(`IMPORTANT commitment used without a valid inner commitment: ${content}`);
|
|
23323
|
-
return requirements;
|
|
23324
|
-
}
|
|
23325
|
-
}
|
|
23326
|
-
/**
|
|
23327
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23328
|
-
*/
|
|
23329
|
-
|
|
23330
23187
|
/**
|
|
23331
23188
|
* KNOWLEDGE commitment definition
|
|
23332
23189
|
*
|
|
@@ -23365,7 +23222,7 @@
|
|
|
23365
23222
|
* Markdown documentation for KNOWLEDGE commitment.
|
|
23366
23223
|
*/
|
|
23367
23224
|
get documentation() {
|
|
23368
|
-
return spaceTrim.spaceTrim(`
|
|
23225
|
+
return spaceTrim$1.spaceTrim(`
|
|
23369
23226
|
# ${this.type}
|
|
23370
23227
|
|
|
23371
23228
|
Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
|
|
@@ -23469,7 +23326,7 @@
|
|
|
23469
23326
|
* Markdown documentation for LANGUAGE/LANGUAGES commitment.
|
|
23470
23327
|
*/
|
|
23471
23328
|
get documentation() {
|
|
23472
|
-
return spaceTrim.spaceTrim(`
|
|
23329
|
+
return spaceTrim$1.spaceTrim(`
|
|
23473
23330
|
# ${this.type}
|
|
23474
23331
|
|
|
23475
23332
|
Specifies the language(s) the agent should use in its responses.
|
|
@@ -23543,7 +23400,7 @@
|
|
|
23543
23400
|
* Markdown documentation for MEMORY commitment.
|
|
23544
23401
|
*/
|
|
23545
23402
|
get documentation() {
|
|
23546
|
-
return spaceTrim.spaceTrim(`
|
|
23403
|
+
return spaceTrim$1.spaceTrim(`
|
|
23547
23404
|
# ${this.type}
|
|
23548
23405
|
|
|
23549
23406
|
Similar to KNOWLEDGE but focuses on remembering past interactions and user preferences. This commitment helps the agent maintain context about the user's history, preferences, and previous conversations.
|
|
@@ -23647,7 +23504,7 @@
|
|
|
23647
23504
|
* Markdown documentation for AGENT MESSAGE commitment.
|
|
23648
23505
|
*/
|
|
23649
23506
|
get documentation() {
|
|
23650
|
-
return spaceTrim.spaceTrim(`
|
|
23507
|
+
return spaceTrim$1.spaceTrim(`
|
|
23651
23508
|
# ${this.type}
|
|
23652
23509
|
|
|
23653
23510
|
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.
|
|
@@ -23724,7 +23581,7 @@
|
|
|
23724
23581
|
* Markdown documentation for INITIAL MESSAGE commitment.
|
|
23725
23582
|
*/
|
|
23726
23583
|
get documentation() {
|
|
23727
|
-
return spaceTrim.spaceTrim(`
|
|
23584
|
+
return spaceTrim$1.spaceTrim(`
|
|
23728
23585
|
# ${this.type}
|
|
23729
23586
|
|
|
23730
23587
|
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).
|
|
@@ -23788,7 +23645,7 @@
|
|
|
23788
23645
|
* Markdown documentation for MESSAGE commitment.
|
|
23789
23646
|
*/
|
|
23790
23647
|
get documentation() {
|
|
23791
|
-
return spaceTrim.spaceTrim(`
|
|
23648
|
+
return spaceTrim$1.spaceTrim(`
|
|
23792
23649
|
# ${this.type}
|
|
23793
23650
|
|
|
23794
23651
|
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 EXAMPLE but it is not example, it is the real message which AI assistant already sent.
|
|
@@ -23900,7 +23757,7 @@
|
|
|
23900
23757
|
* Markdown documentation for USER MESSAGE commitment.
|
|
23901
23758
|
*/
|
|
23902
23759
|
get documentation() {
|
|
23903
|
-
return spaceTrim.spaceTrim(`
|
|
23760
|
+
return spaceTrim$1.spaceTrim(`
|
|
23904
23761
|
# ${this.type}
|
|
23905
23762
|
|
|
23906
23763
|
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.
|
|
@@ -23979,7 +23836,7 @@
|
|
|
23979
23836
|
* Markdown documentation for META commitment.
|
|
23980
23837
|
*/
|
|
23981
23838
|
get documentation() {
|
|
23982
|
-
return spaceTrim.spaceTrim(`
|
|
23839
|
+
return spaceTrim$1.spaceTrim(`
|
|
23983
23840
|
# META
|
|
23984
23841
|
|
|
23985
23842
|
Sets meta-information about the agent that is used for display and attribution purposes.
|
|
@@ -24090,6 +23947,12 @@
|
|
|
24090
23947
|
* META COLOR #00ff00
|
|
24091
23948
|
* ```
|
|
24092
23949
|
*
|
|
23950
|
+
* You can also specify multiple colors separated by comma:
|
|
23951
|
+
*
|
|
23952
|
+
* ```book
|
|
23953
|
+
* META COLOR #ff0000, #00ff00, #0000ff
|
|
23954
|
+
* ```
|
|
23955
|
+
*
|
|
24093
23956
|
* @private [🪔] Maybe export the commitments through some package
|
|
24094
23957
|
*/
|
|
24095
23958
|
class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
@@ -24100,7 +23963,7 @@
|
|
|
24100
23963
|
* Short one-line description of META COLOR.
|
|
24101
23964
|
*/
|
|
24102
23965
|
get description() {
|
|
24103
|
-
return "Set the agent's accent color.";
|
|
23966
|
+
return "Set the agent's accent color or gradient.";
|
|
24104
23967
|
}
|
|
24105
23968
|
/**
|
|
24106
23969
|
* Icon for this commitment.
|
|
@@ -24112,10 +23975,10 @@
|
|
|
24112
23975
|
* Markdown documentation for META COLOR commitment.
|
|
24113
23976
|
*/
|
|
24114
23977
|
get documentation() {
|
|
24115
|
-
return spaceTrim.spaceTrim(`
|
|
23978
|
+
return spaceTrim$1.spaceTrim(`
|
|
24116
23979
|
# META COLOR
|
|
24117
23980
|
|
|
24118
|
-
Sets the agent's accent color.
|
|
23981
|
+
Sets the agent's accent color or gradient.
|
|
24119
23982
|
|
|
24120
23983
|
## Key aspects
|
|
24121
23984
|
|
|
@@ -24123,6 +23986,7 @@
|
|
|
24123
23986
|
- Only one \`META COLOR\` should be used per agent.
|
|
24124
23987
|
- If multiple are specified, the last one takes precedence.
|
|
24125
23988
|
- Used for visual representation in user interfaces.
|
|
23989
|
+
- Can specify multiple colors separated by comma to create a gradient.
|
|
24126
23990
|
|
|
24127
23991
|
## Examples
|
|
24128
23992
|
|
|
@@ -24139,6 +24003,13 @@
|
|
|
24139
24003
|
META COLOR #e74c3c
|
|
24140
24004
|
PERSONA You are a creative and inspiring assistant
|
|
24141
24005
|
\`\`\`
|
|
24006
|
+
|
|
24007
|
+
\`\`\`book
|
|
24008
|
+
Gradient Agent
|
|
24009
|
+
|
|
24010
|
+
META COLOR #ff0000, #00ff00, #0000ff
|
|
24011
|
+
PERSONA You are a colorful agent
|
|
24012
|
+
\`\`\`
|
|
24142
24013
|
`);
|
|
24143
24014
|
}
|
|
24144
24015
|
applyToAgentModelRequirements(requirements, content) {
|
|
@@ -24160,6 +24031,91 @@
|
|
|
24160
24031
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24161
24032
|
*/
|
|
24162
24033
|
|
|
24034
|
+
/**
|
|
24035
|
+
* META FONT commitment definition
|
|
24036
|
+
*
|
|
24037
|
+
* The META FONT commitment sets the agent's font.
|
|
24038
|
+
* This commitment is special because it doesn't affect the system message,
|
|
24039
|
+
* but is handled separately in the parsing logic.
|
|
24040
|
+
*
|
|
24041
|
+
* Example usage in agent source:
|
|
24042
|
+
*
|
|
24043
|
+
* ```book
|
|
24044
|
+
* META FONT Poppins, Arial, sans-serif
|
|
24045
|
+
* META FONT Roboto
|
|
24046
|
+
* ```
|
|
24047
|
+
*
|
|
24048
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
24049
|
+
*/
|
|
24050
|
+
class MetaFontCommitmentDefinition extends BaseCommitmentDefinition {
|
|
24051
|
+
constructor() {
|
|
24052
|
+
super('META FONT', ['FONT']);
|
|
24053
|
+
}
|
|
24054
|
+
/**
|
|
24055
|
+
* Short one-line description of META FONT.
|
|
24056
|
+
*/
|
|
24057
|
+
get description() {
|
|
24058
|
+
return "Set the agent's font.";
|
|
24059
|
+
}
|
|
24060
|
+
/**
|
|
24061
|
+
* Icon for this commitment.
|
|
24062
|
+
*/
|
|
24063
|
+
get icon() {
|
|
24064
|
+
return '🔤';
|
|
24065
|
+
}
|
|
24066
|
+
/**
|
|
24067
|
+
* Markdown documentation for META FONT commitment.
|
|
24068
|
+
*/
|
|
24069
|
+
get documentation() {
|
|
24070
|
+
return spaceTrim$1.spaceTrim(`
|
|
24071
|
+
# META FONT
|
|
24072
|
+
|
|
24073
|
+
Sets the agent's font.
|
|
24074
|
+
|
|
24075
|
+
## Key aspects
|
|
24076
|
+
|
|
24077
|
+
- Does not modify the agent's behavior or responses.
|
|
24078
|
+
- Only one \`META FONT\` should be used per agent.
|
|
24079
|
+
- If multiple are specified, the last one takes precedence.
|
|
24080
|
+
- Used for visual representation in user interfaces.
|
|
24081
|
+
- Supports Google Fonts.
|
|
24082
|
+
|
|
24083
|
+
## Examples
|
|
24084
|
+
|
|
24085
|
+
\`\`\`book
|
|
24086
|
+
Modern Assistant
|
|
24087
|
+
|
|
24088
|
+
META FONT Poppins, Arial, sans-serif
|
|
24089
|
+
PERSONA You are a modern assistant
|
|
24090
|
+
\`\`\`
|
|
24091
|
+
|
|
24092
|
+
\`\`\`book
|
|
24093
|
+
Classic Helper
|
|
24094
|
+
|
|
24095
|
+
META FONT Times New Roman
|
|
24096
|
+
PERSONA You are a classic helper
|
|
24097
|
+
\`\`\`
|
|
24098
|
+
`);
|
|
24099
|
+
}
|
|
24100
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
24101
|
+
// META FONT doesn't modify the system message or model requirements
|
|
24102
|
+
// It's handled separately in the parsing logic
|
|
24103
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
24104
|
+
return requirements;
|
|
24105
|
+
}
|
|
24106
|
+
/**
|
|
24107
|
+
* Extracts the font from the content
|
|
24108
|
+
* This is used by the parsing logic
|
|
24109
|
+
*/
|
|
24110
|
+
extractProfileFont(content) {
|
|
24111
|
+
const trimmedContent = content.trim();
|
|
24112
|
+
return trimmedContent || null;
|
|
24113
|
+
}
|
|
24114
|
+
}
|
|
24115
|
+
/**
|
|
24116
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24117
|
+
*/
|
|
24118
|
+
|
|
24163
24119
|
/**
|
|
24164
24120
|
* META IMAGE commitment definition
|
|
24165
24121
|
*
|
|
@@ -24196,7 +24152,7 @@
|
|
|
24196
24152
|
* Markdown documentation for META IMAGE commitment.
|
|
24197
24153
|
*/
|
|
24198
24154
|
get documentation() {
|
|
24199
|
-
return spaceTrim.spaceTrim(`
|
|
24155
|
+
return spaceTrim$1.spaceTrim(`
|
|
24200
24156
|
# META IMAGE
|
|
24201
24157
|
|
|
24202
24158
|
Sets the agent's avatar/profile image URL.
|
|
@@ -24291,7 +24247,7 @@
|
|
|
24291
24247
|
* Markdown documentation for META LINK commitment.
|
|
24292
24248
|
*/
|
|
24293
24249
|
get documentation() {
|
|
24294
|
-
return spaceTrim.spaceTrim(`
|
|
24250
|
+
return spaceTrim$1.spaceTrim(`
|
|
24295
24251
|
# META LINK
|
|
24296
24252
|
|
|
24297
24253
|
Represents a profile or source link for the person the agent is modeled after.
|
|
@@ -24401,7 +24357,7 @@
|
|
|
24401
24357
|
* Markdown documentation for MODEL commitment.
|
|
24402
24358
|
*/
|
|
24403
24359
|
get documentation() {
|
|
24404
|
-
return spaceTrim.spaceTrim(`
|
|
24360
|
+
return spaceTrim$1.spaceTrim(`
|
|
24405
24361
|
# ${this.type}
|
|
24406
24362
|
|
|
24407
24363
|
Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
|
|
@@ -24642,7 +24598,7 @@
|
|
|
24642
24598
|
* Markdown documentation for NOTE commitment.
|
|
24643
24599
|
*/
|
|
24644
24600
|
get documentation() {
|
|
24645
|
-
return spaceTrim.spaceTrim(`
|
|
24601
|
+
return spaceTrim$1.spaceTrim(`
|
|
24646
24602
|
# ${this.type}
|
|
24647
24603
|
|
|
24648
24604
|
Adds comments for documentation without changing agent behavior.
|
|
@@ -24741,7 +24697,7 @@
|
|
|
24741
24697
|
* Markdown documentation for OPEN commitment.
|
|
24742
24698
|
*/
|
|
24743
24699
|
get documentation() {
|
|
24744
|
-
return spaceTrim.spaceTrim(`
|
|
24700
|
+
return spaceTrim$1.spaceTrim(`
|
|
24745
24701
|
# OPEN
|
|
24746
24702
|
|
|
24747
24703
|
Specifies that the agent can be modified by conversation with it.
|
|
@@ -24818,7 +24774,7 @@
|
|
|
24818
24774
|
* Markdown documentation for PERSONA commitment.
|
|
24819
24775
|
*/
|
|
24820
24776
|
get documentation() {
|
|
24821
|
-
return spaceTrim.spaceTrim(`
|
|
24777
|
+
return spaceTrim$1.spaceTrim(`
|
|
24822
24778
|
# ${this.type}
|
|
24823
24779
|
|
|
24824
24780
|
Defines who the agent is, their background, expertise, and personality traits.
|
|
@@ -24951,7 +24907,7 @@
|
|
|
24951
24907
|
* Markdown documentation for RULE/RULES commitment.
|
|
24952
24908
|
*/
|
|
24953
24909
|
get documentation() {
|
|
24954
|
-
return spaceTrim.spaceTrim(`
|
|
24910
|
+
return spaceTrim$1.spaceTrim(`
|
|
24955
24911
|
# ${this.type}
|
|
24956
24912
|
|
|
24957
24913
|
Adds behavioral constraints and guidelines that the agent must follow.
|
|
@@ -25033,7 +24989,7 @@
|
|
|
25033
24989
|
* Markdown documentation for SAMPLE/EXAMPLE commitment.
|
|
25034
24990
|
*/
|
|
25035
24991
|
get documentation() {
|
|
25036
|
-
return spaceTrim.spaceTrim(`
|
|
24992
|
+
return spaceTrim$1.spaceTrim(`
|
|
25037
24993
|
# ${this.type}
|
|
25038
24994
|
|
|
25039
24995
|
Provides examples of how the agent should respond or behave in certain situations.
|
|
@@ -25116,7 +25072,7 @@
|
|
|
25116
25072
|
* Markdown documentation for SCENARIO commitment.
|
|
25117
25073
|
*/
|
|
25118
25074
|
get documentation() {
|
|
25119
|
-
return spaceTrim.spaceTrim(`
|
|
25075
|
+
return spaceTrim$1.spaceTrim(`
|
|
25120
25076
|
# ${this.type}
|
|
25121
25077
|
|
|
25122
25078
|
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.
|
|
@@ -25238,7 +25194,7 @@
|
|
|
25238
25194
|
* Markdown documentation for STYLE commitment.
|
|
25239
25195
|
*/
|
|
25240
25196
|
get documentation() {
|
|
25241
|
-
return spaceTrim.spaceTrim(`
|
|
25197
|
+
return spaceTrim$1.spaceTrim(`
|
|
25242
25198
|
# ${this.type}
|
|
25243
25199
|
|
|
25244
25200
|
Defines how the agent should format and present its responses (tone, writing style, formatting).
|
|
@@ -25285,61 +25241,544 @@
|
|
|
25285
25241
|
* [💞] Ignore a discrepancy between file name and entity name
|
|
25286
25242
|
*/
|
|
25287
25243
|
|
|
25288
|
-
|
|
25289
|
-
|
|
25290
|
-
|
|
25291
|
-
|
|
25292
|
-
|
|
25293
|
-
|
|
25294
|
-
|
|
25295
|
-
|
|
25296
|
-
|
|
25297
|
-
|
|
25298
|
-
|
|
25299
|
-
|
|
25300
|
-
|
|
25301
|
-
|
|
25302
|
-
|
|
25303
|
-
|
|
25304
|
-
|
|
25305
|
-
|
|
25306
|
-
|
|
25307
|
-
|
|
25308
|
-
|
|
25309
|
-
|
|
25310
|
-
|
|
25311
|
-
|
|
25312
|
-
|
|
25313
|
-
|
|
25314
|
-
|
|
25315
|
-
|
|
25316
|
-
|
|
25317
|
-
|
|
25318
|
-
|
|
25319
|
-
|
|
25320
|
-
|
|
25321
|
-
|
|
25322
|
-
|
|
25323
|
-
|
|
25324
|
-
|
|
25325
|
-
|
|
25326
|
-
|
|
25327
|
-
|
|
25328
|
-
|
|
25329
|
-
|
|
25330
|
-
|
|
25331
|
-
|
|
25332
|
-
|
|
25333
|
-
|
|
25334
|
-
|
|
25335
|
-
|
|
25336
|
-
|
|
25337
|
-
|
|
25338
|
-
|
|
25339
|
-
|
|
25340
|
-
|
|
25341
|
-
|
|
25342
|
-
|
|
25244
|
+
/**
|
|
25245
|
+
* USE commitment definition
|
|
25246
|
+
*
|
|
25247
|
+
* The USE commitment indicates that the agent should utilize specific tools or capabilities
|
|
25248
|
+
* to access and interact with external systems when necessary.
|
|
25249
|
+
*
|
|
25250
|
+
* Supported USE types:
|
|
25251
|
+
* - USE BROWSER: Enables the agent to use a web browser tool
|
|
25252
|
+
* - USE SEARCH ENGINE (future): Enables search engine access
|
|
25253
|
+
* - USE FILE SYSTEM (future): Enables file system operations
|
|
25254
|
+
* - USE MCP (future): Enables MCP server connections
|
|
25255
|
+
*
|
|
25256
|
+
* The content following the USE commitment is ignored (similar to NOTE).
|
|
25257
|
+
*
|
|
25258
|
+
* Example usage in agent source:
|
|
25259
|
+
*
|
|
25260
|
+
* ```book
|
|
25261
|
+
* USE BROWSER
|
|
25262
|
+
* USE SEARCH ENGINE
|
|
25263
|
+
* ```
|
|
25264
|
+
*
|
|
25265
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
25266
|
+
*/
|
|
25267
|
+
class UseCommitmentDefinition extends BaseCommitmentDefinition {
|
|
25268
|
+
constructor() {
|
|
25269
|
+
super('USE');
|
|
25270
|
+
}
|
|
25271
|
+
/**
|
|
25272
|
+
* Short one-line description of USE commitments.
|
|
25273
|
+
*/
|
|
25274
|
+
get description() {
|
|
25275
|
+
return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
|
|
25276
|
+
}
|
|
25277
|
+
/**
|
|
25278
|
+
* Icon for this commitment.
|
|
25279
|
+
*/
|
|
25280
|
+
get icon() {
|
|
25281
|
+
return '🔧';
|
|
25282
|
+
}
|
|
25283
|
+
/**
|
|
25284
|
+
* Markdown documentation for USE commitment.
|
|
25285
|
+
*/
|
|
25286
|
+
get documentation() {
|
|
25287
|
+
return spaceTrim$1.spaceTrim(`
|
|
25288
|
+
# USE
|
|
25289
|
+
|
|
25290
|
+
Enables the agent to use specific tools or capabilities for interacting with external systems.
|
|
25291
|
+
|
|
25292
|
+
## Supported USE types
|
|
25293
|
+
|
|
25294
|
+
- **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
|
|
25295
|
+
- **USE SEARCH ENGINE** (future) - Enables search engine access
|
|
25296
|
+
- **USE FILE SYSTEM** (future) - Enables file system operations
|
|
25297
|
+
- **USE MCP** (future) - Enables MCP server connections
|
|
25298
|
+
|
|
25299
|
+
## Key aspects
|
|
25300
|
+
|
|
25301
|
+
- The content following the USE commitment is ignored (similar to NOTE)
|
|
25302
|
+
- Multiple USE commitments can be specified to enable multiple capabilities
|
|
25303
|
+
- The actual tool usage is handled by the agent runtime
|
|
25304
|
+
|
|
25305
|
+
## Examples
|
|
25306
|
+
|
|
25307
|
+
### Basic browser usage
|
|
25308
|
+
|
|
25309
|
+
\`\`\`book
|
|
25310
|
+
Research Assistant
|
|
25311
|
+
|
|
25312
|
+
PERSONA You are a helpful research assistant
|
|
25313
|
+
USE BROWSER
|
|
25314
|
+
KNOWLEDGE Can search the web for up-to-date information
|
|
25315
|
+
\`\`\`
|
|
25316
|
+
|
|
25317
|
+
### Multiple tools
|
|
25318
|
+
|
|
25319
|
+
\`\`\`book
|
|
25320
|
+
Data Analyst
|
|
25321
|
+
|
|
25322
|
+
PERSONA You are a data analyst assistant
|
|
25323
|
+
USE BROWSER
|
|
25324
|
+
USE FILE SYSTEM
|
|
25325
|
+
ACTION Can analyze data from various sources
|
|
25326
|
+
\`\`\`
|
|
25327
|
+
`);
|
|
25328
|
+
}
|
|
25329
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
25330
|
+
// USE commitments don't modify the system message or model requirements directly
|
|
25331
|
+
// They are handled separately in the parsing logic for capability extraction
|
|
25332
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
25333
|
+
return requirements;
|
|
25334
|
+
}
|
|
25335
|
+
/**
|
|
25336
|
+
* Extracts the tool type from the USE commitment
|
|
25337
|
+
* This is used by the parsing logic
|
|
25338
|
+
*/
|
|
25339
|
+
extractToolType(content) {
|
|
25340
|
+
var _a, _b;
|
|
25341
|
+
const trimmedContent = content.trim();
|
|
25342
|
+
// The tool type is the first word after USE (already stripped)
|
|
25343
|
+
const match = trimmedContent.match(/^(\w+)/);
|
|
25344
|
+
return (_b = (_a = match === null || match === void 0 ? void 0 : match[1]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : null;
|
|
25345
|
+
}
|
|
25346
|
+
/**
|
|
25347
|
+
* Checks if this is a known USE type
|
|
25348
|
+
*/
|
|
25349
|
+
isKnownUseType(useType) {
|
|
25350
|
+
const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
|
|
25351
|
+
return knownTypes.includes(useType.toUpperCase());
|
|
25352
|
+
}
|
|
25353
|
+
}
|
|
25354
|
+
/**
|
|
25355
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
25356
|
+
*/
|
|
25357
|
+
|
|
25358
|
+
/**
|
|
25359
|
+
* USE BROWSER commitment definition
|
|
25360
|
+
*
|
|
25361
|
+
* The `USE BROWSER` commitment indicates that the agent should utilize a web browser tool
|
|
25362
|
+
* to access and retrieve up-to-date information from the internet when necessary.
|
|
25363
|
+
*
|
|
25364
|
+
* The content following `USE BROWSER` is ignored (similar to NOTE).
|
|
25365
|
+
*
|
|
25366
|
+
* Example usage in agent source:
|
|
25367
|
+
*
|
|
25368
|
+
* ```book
|
|
25369
|
+
* USE BROWSER
|
|
25370
|
+
* USE BROWSER This will be ignored
|
|
25371
|
+
* ```
|
|
25372
|
+
*
|
|
25373
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
25374
|
+
*/
|
|
25375
|
+
class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
25376
|
+
constructor() {
|
|
25377
|
+
super('USE BROWSER', ['BROWSER']);
|
|
25378
|
+
}
|
|
25379
|
+
/**
|
|
25380
|
+
* The `USE BROWSER` commitment is standalone.
|
|
25381
|
+
*/
|
|
25382
|
+
get requiresContent() {
|
|
25383
|
+
return false;
|
|
25384
|
+
}
|
|
25385
|
+
/**
|
|
25386
|
+
* Short one-line description of USE BROWSER.
|
|
25387
|
+
*/
|
|
25388
|
+
get description() {
|
|
25389
|
+
return 'Enable the agent to use a web browser tool for accessing internet information.';
|
|
25390
|
+
}
|
|
25391
|
+
/**
|
|
25392
|
+
* Icon for this commitment.
|
|
25393
|
+
*/
|
|
25394
|
+
get icon() {
|
|
25395
|
+
return '🌐';
|
|
25396
|
+
}
|
|
25397
|
+
/**
|
|
25398
|
+
* Markdown documentation for USE BROWSER commitment.
|
|
25399
|
+
*/
|
|
25400
|
+
get documentation() {
|
|
25401
|
+
return spaceTrim$1.spaceTrim(`
|
|
25402
|
+
# USE BROWSER
|
|
25403
|
+
|
|
25404
|
+
Enables the agent to use a web browser tool to access and retrieve up-to-date information from the internet.
|
|
25405
|
+
|
|
25406
|
+
## Key aspects
|
|
25407
|
+
|
|
25408
|
+
- The content following \`USE BROWSER\` is ignored (similar to NOTE)
|
|
25409
|
+
- The actual browser tool usage is handled by the agent runtime
|
|
25410
|
+
- Allows the agent to fetch current information from websites
|
|
25411
|
+
- Useful for research tasks, fact-checking, and accessing dynamic content
|
|
25412
|
+
|
|
25413
|
+
## Examples
|
|
25414
|
+
|
|
25415
|
+
\`\`\`book
|
|
25416
|
+
Research Assistant
|
|
25417
|
+
|
|
25418
|
+
PERSONA You are a helpful research assistant specialized in finding current information
|
|
25419
|
+
USE BROWSER
|
|
25420
|
+
RULE Always cite your sources when providing information from the web
|
|
25421
|
+
\`\`\`
|
|
25422
|
+
|
|
25423
|
+
\`\`\`book
|
|
25424
|
+
News Analyst
|
|
25425
|
+
|
|
25426
|
+
PERSONA You are a news analyst who stays up-to-date with current events
|
|
25427
|
+
USE BROWSER
|
|
25428
|
+
STYLE Present news in a balanced and objective manner
|
|
25429
|
+
ACTION Can search for and summarize news articles
|
|
25430
|
+
\`\`\`
|
|
25431
|
+
|
|
25432
|
+
\`\`\`book
|
|
25433
|
+
Company Lawyer
|
|
25434
|
+
|
|
25435
|
+
PERSONA You are a company lawyer providing legal advice
|
|
25436
|
+
USE BROWSER
|
|
25437
|
+
KNOWLEDGE Corporate law and legal procedures
|
|
25438
|
+
RULE Always recommend consulting with a licensed attorney for specific legal matters
|
|
25439
|
+
\`\`\`
|
|
25440
|
+
`);
|
|
25441
|
+
}
|
|
25442
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
25443
|
+
// We simply mark that browser capability is enabled in metadata
|
|
25444
|
+
// Get existing metadata
|
|
25445
|
+
const existingMetadata = requirements.metadata || {};
|
|
25446
|
+
// Get existing tools array or create new one
|
|
25447
|
+
const existingTools = existingMetadata.tools || [];
|
|
25448
|
+
// Add 'browser' to tools if not already present
|
|
25449
|
+
const updatedTools = existingTools.includes('browser') ? existingTools : [...existingTools, 'browser'];
|
|
25450
|
+
// Return requirements with updated metadata
|
|
25451
|
+
return {
|
|
25452
|
+
...requirements,
|
|
25453
|
+
metadata: {
|
|
25454
|
+
...existingMetadata,
|
|
25455
|
+
tools: updatedTools,
|
|
25456
|
+
useBrowser: true,
|
|
25457
|
+
},
|
|
25458
|
+
};
|
|
25459
|
+
}
|
|
25460
|
+
}
|
|
25461
|
+
/**
|
|
25462
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
25463
|
+
*/
|
|
25464
|
+
|
|
25465
|
+
/**
|
|
25466
|
+
* USE MCP commitment definition
|
|
25467
|
+
*
|
|
25468
|
+
* The `USE MCP` commitment allows to specify an MCP server URL which the agent will connect to
|
|
25469
|
+
* for retrieving additional instructions and actions.
|
|
25470
|
+
*
|
|
25471
|
+
* The content following `USE MCP` is the URL of the MCP server.
|
|
25472
|
+
*
|
|
25473
|
+
* Example usage in agent source:
|
|
25474
|
+
*
|
|
25475
|
+
* ```book
|
|
25476
|
+
* USE MCP http://mcp-server-url.com
|
|
25477
|
+
* ```
|
|
25478
|
+
*
|
|
25479
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
25480
|
+
*/
|
|
25481
|
+
class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
25482
|
+
constructor() {
|
|
25483
|
+
super('USE MCP', ['MCP']);
|
|
25484
|
+
}
|
|
25485
|
+
/**
|
|
25486
|
+
* Short one-line description of USE MCP.
|
|
25487
|
+
*/
|
|
25488
|
+
get description() {
|
|
25489
|
+
return 'Connects the agent to an external MCP server for additional capabilities.';
|
|
25490
|
+
}
|
|
25491
|
+
/**
|
|
25492
|
+
* Icon for this commitment.
|
|
25493
|
+
*/
|
|
25494
|
+
get icon() {
|
|
25495
|
+
return '🔌';
|
|
25496
|
+
}
|
|
25497
|
+
/**
|
|
25498
|
+
* Markdown documentation for USE MCP commitment.
|
|
25499
|
+
*/
|
|
25500
|
+
get documentation() {
|
|
25501
|
+
return spaceTrim$1.spaceTrim(`
|
|
25502
|
+
# USE MCP
|
|
25503
|
+
|
|
25504
|
+
Connects the agent to an external Model Context Protocol (MCP) server.
|
|
25505
|
+
|
|
25506
|
+
## Key aspects
|
|
25507
|
+
|
|
25508
|
+
- The content following \`USE MCP\` must be a valid URL
|
|
25509
|
+
- Multiple MCP servers can be connected by using multiple \`USE MCP\` commitments
|
|
25510
|
+
- The agent will have access to tools and resources provided by the MCP server
|
|
25511
|
+
|
|
25512
|
+
## Example
|
|
25513
|
+
|
|
25514
|
+
\`\`\`book
|
|
25515
|
+
Company Lawyer
|
|
25516
|
+
|
|
25517
|
+
PERSONA You are a company lawyer.
|
|
25518
|
+
USE MCP http://legal-db.example.com
|
|
25519
|
+
\`\`\`
|
|
25520
|
+
`);
|
|
25521
|
+
}
|
|
25522
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
25523
|
+
const mcpServerUrl = content.trim();
|
|
25524
|
+
if (!mcpServerUrl) {
|
|
25525
|
+
return requirements;
|
|
25526
|
+
}
|
|
25527
|
+
const existingMcpServers = requirements.mcpServers || [];
|
|
25528
|
+
// Avoid duplicates
|
|
25529
|
+
if (existingMcpServers.includes(mcpServerUrl)) {
|
|
25530
|
+
return requirements;
|
|
25531
|
+
}
|
|
25532
|
+
return {
|
|
25533
|
+
...requirements,
|
|
25534
|
+
mcpServers: [...existingMcpServers, mcpServerUrl],
|
|
25535
|
+
};
|
|
25536
|
+
}
|
|
25537
|
+
}
|
|
25538
|
+
/**
|
|
25539
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
25540
|
+
*/
|
|
25541
|
+
|
|
25542
|
+
/**
|
|
25543
|
+
* USE SEARCH ENGINE commitment definition
|
|
25544
|
+
*
|
|
25545
|
+
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
25546
|
+
* to access and retrieve up-to-date information from the internet when necessary.
|
|
25547
|
+
*
|
|
25548
|
+
* The content following `USE SEARCH ENGINE` is ignored (similar to NOTE).
|
|
25549
|
+
*
|
|
25550
|
+
* Example usage in agent source:
|
|
25551
|
+
*
|
|
25552
|
+
* ```book
|
|
25553
|
+
* USE SEARCH ENGINE
|
|
25554
|
+
* USE SEARCH ENGINE This will be ignored
|
|
25555
|
+
* ```
|
|
25556
|
+
*
|
|
25557
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
25558
|
+
*/
|
|
25559
|
+
class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
25560
|
+
constructor() {
|
|
25561
|
+
super('USE SEARCH ENGINE', ['SEARCH ENGINE', 'SEARCH']);
|
|
25562
|
+
}
|
|
25563
|
+
/**
|
|
25564
|
+
* Short one-line description of USE SEARCH ENGINE.
|
|
25565
|
+
*/
|
|
25566
|
+
get description() {
|
|
25567
|
+
return 'Enable the agent to use a search engine tool for accessing internet information.';
|
|
25568
|
+
}
|
|
25569
|
+
/**
|
|
25570
|
+
* Icon for this commitment.
|
|
25571
|
+
*/
|
|
25572
|
+
get icon() {
|
|
25573
|
+
return '🔍';
|
|
25574
|
+
}
|
|
25575
|
+
/**
|
|
25576
|
+
* Markdown documentation for USE SEARCH ENGINE commitment.
|
|
25577
|
+
*/
|
|
25578
|
+
get documentation() {
|
|
25579
|
+
return spaceTrim$1.spaceTrim(`
|
|
25580
|
+
# USE SEARCH ENGINE
|
|
25581
|
+
|
|
25582
|
+
Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
|
|
25583
|
+
|
|
25584
|
+
## Key aspects
|
|
25585
|
+
|
|
25586
|
+
- The content following \`USE SEARCH ENGINE\` is ignored (similar to NOTE)
|
|
25587
|
+
- The actual search engine tool usage is handled by the agent runtime
|
|
25588
|
+
- Allows the agent to search for current information from the web
|
|
25589
|
+
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
25590
|
+
|
|
25591
|
+
## Examples
|
|
25592
|
+
|
|
25593
|
+
\`\`\`book
|
|
25594
|
+
Research Assistant
|
|
25595
|
+
|
|
25596
|
+
PERSONA You are a helpful research assistant specialized in finding current information
|
|
25597
|
+
USE SEARCH ENGINE
|
|
25598
|
+
RULE Always cite your sources when providing information from the web
|
|
25599
|
+
\`\`\`
|
|
25600
|
+
|
|
25601
|
+
\`\`\`book
|
|
25602
|
+
Fact Checker
|
|
25603
|
+
|
|
25604
|
+
PERSONA You are a fact checker
|
|
25605
|
+
USE SEARCH ENGINE
|
|
25606
|
+
ACTION Search for claims and verify them against reliable sources
|
|
25607
|
+
\`\`\`
|
|
25608
|
+
`);
|
|
25609
|
+
}
|
|
25610
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
25611
|
+
// We simply mark that search engine capability is enabled in metadata
|
|
25612
|
+
// Get existing metadata
|
|
25613
|
+
const existingMetadata = requirements.metadata || {};
|
|
25614
|
+
// Get existing tools array or create new one
|
|
25615
|
+
const existingTools = existingMetadata.tools || [];
|
|
25616
|
+
// Add 'search-engine' to tools if not already present
|
|
25617
|
+
const updatedTools = existingTools.includes('search-engine') ? existingTools : [...existingTools, 'search-engine'];
|
|
25618
|
+
// Return requirements with updated metadata
|
|
25619
|
+
return {
|
|
25620
|
+
...requirements,
|
|
25621
|
+
metadata: {
|
|
25622
|
+
...existingMetadata,
|
|
25623
|
+
tools: updatedTools,
|
|
25624
|
+
useSearchEngine: true,
|
|
25625
|
+
},
|
|
25626
|
+
};
|
|
25627
|
+
}
|
|
25628
|
+
}
|
|
25629
|
+
/**
|
|
25630
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
25631
|
+
*/
|
|
25632
|
+
|
|
25633
|
+
/**
|
|
25634
|
+
* Placeholder commitment definition for commitments that are not yet implemented
|
|
25635
|
+
*
|
|
25636
|
+
* This commitment simply adds its content 1:1 into the system message,
|
|
25637
|
+
* preserving the original behavior until proper implementation is added.
|
|
25638
|
+
*
|
|
25639
|
+
* @public exported from `@promptbook/core`
|
|
25640
|
+
*/
|
|
25641
|
+
class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
25642
|
+
constructor(type) {
|
|
25643
|
+
super(type);
|
|
25644
|
+
}
|
|
25645
|
+
/**
|
|
25646
|
+
* Short one-line description of a placeholder commitment.
|
|
25647
|
+
*/
|
|
25648
|
+
get description() {
|
|
25649
|
+
return 'Placeholder commitment that appends content verbatim to the system message.';
|
|
25650
|
+
}
|
|
25651
|
+
/**
|
|
25652
|
+
* Icon for this commitment.
|
|
25653
|
+
*/
|
|
25654
|
+
get icon() {
|
|
25655
|
+
return '🚧';
|
|
25656
|
+
}
|
|
25657
|
+
/**
|
|
25658
|
+
* Markdown documentation available at runtime.
|
|
25659
|
+
*/
|
|
25660
|
+
get documentation() {
|
|
25661
|
+
return spaceTrim$1.spaceTrim(`
|
|
25662
|
+
# ${this.type}
|
|
25663
|
+
|
|
25664
|
+
This commitment is not yet fully implemented.
|
|
25665
|
+
|
|
25666
|
+
## Key aspects
|
|
25667
|
+
|
|
25668
|
+
- Content is appended directly to the system message.
|
|
25669
|
+
- No special processing or validation is performed.
|
|
25670
|
+
- Behavior preserved until proper implementation is added.
|
|
25671
|
+
|
|
25672
|
+
## Status
|
|
25673
|
+
|
|
25674
|
+
- **Status:** Placeholder implementation
|
|
25675
|
+
- **Effect:** Appends content prefixed by commitment type
|
|
25676
|
+
- **Future:** Will be replaced with specialized logic
|
|
25677
|
+
|
|
25678
|
+
## Examples
|
|
25679
|
+
|
|
25680
|
+
\`\`\`book
|
|
25681
|
+
Example Agent
|
|
25682
|
+
|
|
25683
|
+
PERSONA You are a helpful assistant
|
|
25684
|
+
${this.type} Your content here
|
|
25685
|
+
RULE Always be helpful
|
|
25686
|
+
\`\`\`
|
|
25687
|
+
`);
|
|
25688
|
+
}
|
|
25689
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
25690
|
+
const trimmedContent = content.trim();
|
|
25691
|
+
if (!trimmedContent) {
|
|
25692
|
+
return requirements;
|
|
25693
|
+
}
|
|
25694
|
+
// Add the commitment content 1:1 to the system message
|
|
25695
|
+
const commitmentLine = `${this.type} ${trimmedContent}`;
|
|
25696
|
+
return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
|
|
25697
|
+
}
|
|
25698
|
+
}
|
|
25699
|
+
|
|
25700
|
+
// Import all commitment definition classes
|
|
25701
|
+
/**
|
|
25702
|
+
* Registry of all available commitment definitions
|
|
25703
|
+
* This array contains instances of all commitment definitions
|
|
25704
|
+
* This is the single source of truth for all commitments in the system
|
|
25705
|
+
*
|
|
25706
|
+
* @private Use functions to access commitments instead of this array directly
|
|
25707
|
+
*/
|
|
25708
|
+
const COMMITMENT_REGISTRY = [
|
|
25709
|
+
// Fully implemented commitments
|
|
25710
|
+
new PersonaCommitmentDefinition('PERSONA'),
|
|
25711
|
+
new PersonaCommitmentDefinition('PERSONAE'),
|
|
25712
|
+
new KnowledgeCommitmentDefinition(),
|
|
25713
|
+
new MemoryCommitmentDefinition('MEMORY'),
|
|
25714
|
+
new MemoryCommitmentDefinition('MEMORIES'),
|
|
25715
|
+
new StyleCommitmentDefinition('STYLE'),
|
|
25716
|
+
new StyleCommitmentDefinition('STYLES'),
|
|
25717
|
+
new RuleCommitmentDefinition('RULE'),
|
|
25718
|
+
new RuleCommitmentDefinition('RULES'),
|
|
25719
|
+
new LanguageCommitmentDefinition('LANGUAGE'),
|
|
25720
|
+
new LanguageCommitmentDefinition('LANGUAGES'),
|
|
25721
|
+
new SampleCommitmentDefinition('SAMPLE'),
|
|
25722
|
+
new SampleCommitmentDefinition('EXAMPLE'),
|
|
25723
|
+
new FormatCommitmentDefinition('FORMAT'),
|
|
25724
|
+
new FormatCommitmentDefinition('FORMATS'),
|
|
25725
|
+
new FromCommitmentDefinition('FROM'),
|
|
25726
|
+
new ModelCommitmentDefinition('MODEL'),
|
|
25727
|
+
new ModelCommitmentDefinition('MODELS'),
|
|
25728
|
+
new ActionCommitmentDefinition('ACTION'),
|
|
25729
|
+
new ActionCommitmentDefinition('ACTIONS'),
|
|
25730
|
+
new ComponentCommitmentDefinition(),
|
|
25731
|
+
new MetaImageCommitmentDefinition(),
|
|
25732
|
+
new MetaColorCommitmentDefinition(),
|
|
25733
|
+
new MetaFontCommitmentDefinition(),
|
|
25734
|
+
new MetaLinkCommitmentDefinition(),
|
|
25735
|
+
new MetaCommitmentDefinition(),
|
|
25736
|
+
new NoteCommitmentDefinition('NOTE'),
|
|
25737
|
+
new NoteCommitmentDefinition('NOTES'),
|
|
25738
|
+
new NoteCommitmentDefinition('COMMENT'),
|
|
25739
|
+
new NoteCommitmentDefinition('NONCE'),
|
|
25740
|
+
new GoalCommitmentDefinition('GOAL'),
|
|
25741
|
+
new GoalCommitmentDefinition('GOALS'),
|
|
25742
|
+
new InitialMessageCommitmentDefinition(),
|
|
25743
|
+
new UserMessageCommitmentDefinition(),
|
|
25744
|
+
new AgentMessageCommitmentDefinition(),
|
|
25745
|
+
new MessageCommitmentDefinition('MESSAGE'),
|
|
25746
|
+
new MessageCommitmentDefinition('MESSAGES'),
|
|
25747
|
+
new ScenarioCommitmentDefinition('SCENARIO'),
|
|
25748
|
+
new ScenarioCommitmentDefinition('SCENARIOS'),
|
|
25749
|
+
new DeleteCommitmentDefinition('DELETE'),
|
|
25750
|
+
new DeleteCommitmentDefinition('CANCEL'),
|
|
25751
|
+
new DeleteCommitmentDefinition('DISCARD'),
|
|
25752
|
+
new DeleteCommitmentDefinition('REMOVE'),
|
|
25753
|
+
new OpenCommitmentDefinition(),
|
|
25754
|
+
new ClosedCommitmentDefinition(),
|
|
25755
|
+
new UseBrowserCommitmentDefinition(),
|
|
25756
|
+
new UseSearchEngineCommitmentDefinition(),
|
|
25757
|
+
new UseMcpCommitmentDefinition(),
|
|
25758
|
+
new UseCommitmentDefinition(),
|
|
25759
|
+
// Not yet implemented commitments (using placeholder)
|
|
25760
|
+
new NotYetImplementedCommitmentDefinition('EXPECT'),
|
|
25761
|
+
new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
|
|
25762
|
+
new NotYetImplementedCommitmentDefinition('BEHAVIOURS'),
|
|
25763
|
+
new NotYetImplementedCommitmentDefinition('AVOID'),
|
|
25764
|
+
new NotYetImplementedCommitmentDefinition('AVOIDANCE'),
|
|
25765
|
+
new NotYetImplementedCommitmentDefinition('CONTEXT'),
|
|
25766
|
+
];
|
|
25767
|
+
/**
|
|
25768
|
+
* Gets a commitment definition by its type
|
|
25769
|
+
* @param type The commitment type to look up
|
|
25770
|
+
* @returns The commitment definition or null if not found
|
|
25771
|
+
*
|
|
25772
|
+
* @public exported from `@promptbook/core`
|
|
25773
|
+
*/
|
|
25774
|
+
function getCommitmentDefinition(type) {
|
|
25775
|
+
return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
|
|
25776
|
+
}
|
|
25777
|
+
/**
|
|
25778
|
+
* TODO: [🧠] Maybe create through standardized $register
|
|
25779
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
25780
|
+
*/
|
|
25781
|
+
|
|
25343
25782
|
/**
|
|
25344
25783
|
* Creates an empty/basic agent model requirements object
|
|
25345
25784
|
* This serves as the starting point for the reduce-like pattern
|
|
@@ -25374,6 +25813,11 @@
|
|
|
25374
25813
|
* TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
|
|
25375
25814
|
*/
|
|
25376
25815
|
|
|
25816
|
+
/**
|
|
25817
|
+
* Regex pattern to match horizontal lines (markdown thematic breaks)
|
|
25818
|
+
* Matches 3 or more hyphens, underscores, or asterisks (with optional spaces between)
|
|
25819
|
+
*/
|
|
25820
|
+
const HORIZONTAL_LINE_PATTERN = /^[\s]*[-_*][\s]*[-_*][\s]*[-_*][\s]*[-_*]*[\s]*$/;
|
|
25377
25821
|
/**
|
|
25378
25822
|
* Parses agent source using the new commitment system with multiline support
|
|
25379
25823
|
* This function replaces the hardcoded commitment parsing in the original parseAgentSource
|
|
@@ -25416,7 +25860,7 @@
|
|
|
25416
25860
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
25417
25861
|
commitments.push({
|
|
25418
25862
|
type: currentCommitment.type,
|
|
25419
|
-
content: spaceTrim.spaceTrim(fullContent),
|
|
25863
|
+
content: spaceTrim$1.spaceTrim(fullContent),
|
|
25420
25864
|
originalLine: currentCommitment.originalStartLine,
|
|
25421
25865
|
lineNumber: currentCommitment.startLineNumber,
|
|
25422
25866
|
});
|
|
@@ -25436,6 +25880,24 @@
|
|
|
25436
25880
|
break;
|
|
25437
25881
|
}
|
|
25438
25882
|
}
|
|
25883
|
+
// Check if this is a horizontal line (ends any current commitment)
|
|
25884
|
+
const isHorizontalLine = HORIZONTAL_LINE_PATTERN.test(line);
|
|
25885
|
+
if (isHorizontalLine) {
|
|
25886
|
+
// Save the current commitment if it exists
|
|
25887
|
+
if (currentCommitment) {
|
|
25888
|
+
const fullContent = currentCommitment.contentLines.join('\n');
|
|
25889
|
+
commitments.push({
|
|
25890
|
+
type: currentCommitment.type,
|
|
25891
|
+
content: spaceTrim$1.spaceTrim(fullContent),
|
|
25892
|
+
originalLine: currentCommitment.originalStartLine,
|
|
25893
|
+
lineNumber: currentCommitment.startLineNumber,
|
|
25894
|
+
});
|
|
25895
|
+
currentCommitment = null;
|
|
25896
|
+
}
|
|
25897
|
+
// Add horizontal line to non-commitment lines
|
|
25898
|
+
nonCommitmentLines.push(line);
|
|
25899
|
+
continue;
|
|
25900
|
+
}
|
|
25439
25901
|
if (!foundNewCommitment) {
|
|
25440
25902
|
if (currentCommitment) {
|
|
25441
25903
|
// This line belongs to the current commitment
|
|
@@ -25452,7 +25914,7 @@
|
|
|
25452
25914
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
25453
25915
|
commitments.push({
|
|
25454
25916
|
type: currentCommitment.type,
|
|
25455
|
-
content: spaceTrim.spaceTrim(fullContent),
|
|
25917
|
+
content: spaceTrim$1.spaceTrim(fullContent),
|
|
25456
25918
|
originalLine: currentCommitment.originalStartLine,
|
|
25457
25919
|
lineNumber: currentCommitment.startLineNumber,
|
|
25458
25920
|
});
|
|
@@ -25760,7 +26222,11 @@
|
|
|
25760
26222
|
continue;
|
|
25761
26223
|
}
|
|
25762
26224
|
if (commitment.type === 'META COLOR') {
|
|
25763
|
-
meta.color =
|
|
26225
|
+
meta.color = normalizeSeparator(commitment.content);
|
|
26226
|
+
continue;
|
|
26227
|
+
}
|
|
26228
|
+
if (commitment.type === 'META FONT') {
|
|
26229
|
+
meta.font = normalizeSeparator(commitment.content);
|
|
25764
26230
|
continue;
|
|
25765
26231
|
}
|
|
25766
26232
|
if (commitment.type !== 'META') {
|
|
@@ -25796,6 +26262,19 @@
|
|
|
25796
26262
|
parameters,
|
|
25797
26263
|
};
|
|
25798
26264
|
}
|
|
26265
|
+
/**
|
|
26266
|
+
* Normalizes the separator in the content
|
|
26267
|
+
*
|
|
26268
|
+
* @param content - The content to normalize
|
|
26269
|
+
* @returns The content with normalized separators
|
|
26270
|
+
*/
|
|
26271
|
+
function normalizeSeparator(content) {
|
|
26272
|
+
const trimmed = spaceTrim__default["default"](content);
|
|
26273
|
+
if (trimmed.includes(',')) {
|
|
26274
|
+
return trimmed;
|
|
26275
|
+
}
|
|
26276
|
+
return trimmed.split(/\s+/).join(', ');
|
|
26277
|
+
}
|
|
25799
26278
|
/**
|
|
25800
26279
|
* TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
|
|
25801
26280
|
*/
|