@promptbook/wizard 0.103.0-54 → 0.103.0-56

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/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('spacetrim'), require('crypto'), require('socket.io-client'), require('@anthropic-ai/sdk'), require('bottleneck'), require('colors'), require('@azure/openai'), require('openai'), require('fs/promises'), require('child_process'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('rxjs'), require('crypto-js/sha256'), require('mime-types'), require('papaparse'), require('@mozilla/readability'), require('jsdom'), require('showdown'), require('dotenv'), require('jszip')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'socket.io-client', '@anthropic-ai/sdk', 'bottleneck', 'colors', '@azure/openai', 'openai', 'fs/promises', 'child_process', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'path', 'rxjs', 'crypto-js/sha256', 'mime-types', 'papaparse', '@mozilla/readability', 'jsdom', 'showdown', 'dotenv', 'jszip'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-wizard"] = {}, global.spaceTrim, global.crypto, global.socket_ioClient, global.Anthropic, global.Bottleneck, global.colors, global.openai, global.OpenAI, global.promises, global.child_process, global.waitasecond, global.cryptoJs, global.hexEncoder, global.path, global.rxjs, global.sha256, global.mimeTypes, global.papaparse, global.readability, global.jsdom, global.showdown, global.dotenv, global.JSZip));
5
- })(this, (function (exports, spaceTrim, crypto, socket_ioClient, Anthropic, Bottleneck, colors, openai, OpenAI, promises, child_process, waitasecond, cryptoJs, hexEncoder, path, rxjs, sha256, mimeTypes, papaparse, readability, jsdom, showdown, dotenv, JSZip) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-wizard"] = {}, global.spaceTrim$1, global.crypto, global.socket_ioClient, global.Anthropic, global.Bottleneck, global.colors, global.openai, global.OpenAI, global.promises, global.child_process, global.waitasecond, global.cryptoJs, global.hexEncoder, global.path, global.rxjs, global.sha256, global.mimeTypes, global.papaparse, global.readability, global.jsdom, global.showdown, global.dotenv, global.JSZip));
5
+ })(this, (function (exports, spaceTrim$1, crypto, socket_ioClient, Anthropic, Bottleneck, colors, openai, OpenAI, promises, child_process, waitasecond, cryptoJs, hexEncoder, path, rxjs, sha256, mimeTypes, papaparse, readability, jsdom, showdown, dotenv, JSZip) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -24,7 +24,7 @@
24
24
  return Object.freeze(n);
25
25
  }
26
26
 
27
- var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
27
+ var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
28
28
  var Anthropic__default = /*#__PURE__*/_interopDefaultLegacy(Anthropic);
29
29
  var Bottleneck__default = /*#__PURE__*/_interopDefaultLegacy(Bottleneck);
30
30
  var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-54';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -102,6 +102,17 @@
102
102
  * Note: [💞] Ignore a discrepancy between file name and entity name
103
103
  */
104
104
 
105
+ /**
106
+ * Trims string from all 4 sides
107
+ *
108
+ * Note: This is a re-exported function from the `spacetrim` package which is
109
+ * Developed by same author @hejny as this package
110
+ *
111
+ * @public exported from `@promptbook/utils`
112
+ * @see https://github.com/hejny/spacetrim#usage
113
+ */
114
+ const spaceTrim = spaceTrim$1.spaceTrim;
115
+
105
116
  /**
106
117
  * Just marks a place of place where should be something implemented
107
118
  * No side effects.
@@ -163,6 +174,7 @@
163
174
  * @public exported from `@promptbook/color`
164
175
  */
165
176
  const CSS_COLORS = {
177
+ promptbook: '#79EAFD',
166
178
  transparent: 'rgba(0,0,0,0)',
167
179
  aliceblue: '#f0f8ff',
168
180
  antiquewhite: '#faebd7',
@@ -378,6 +390,28 @@
378
390
  throw new Error(`Can not create color from given object`);
379
391
  }
380
392
  }
393
+ /**
394
+ * Creates a new Color instance from miscellaneous formats
395
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
396
+ *
397
+ * @param color
398
+ * @returns Color object
399
+ */
400
+ static fromSafe(color) {
401
+ try {
402
+ return Color.from(color);
403
+ }
404
+ catch (error) {
405
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
406
+ console.warn(spaceTrim((block) => `
407
+ Color.fromSafe error:
408
+ ${block(error.message)}
409
+
410
+ Returning default PROMPTBOOK_COLOR.
411
+ `));
412
+ return Color.fromString('promptbook');
413
+ }
414
+ }
381
415
  /**
382
416
  * Creates a new Color instance from miscellaneous string formats
383
417
  *
@@ -987,7 +1021,7 @@
987
1021
  *
988
1022
  * @public exported from `@promptbook/core`
989
1023
  */
990
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1024
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
991
1025
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
992
1026
  /**
993
1027
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1346,7 +1380,7 @@
1346
1380
  */
1347
1381
  class UnexpectedError extends Error {
1348
1382
  constructor(message) {
1349
- super(spaceTrim.spaceTrim((block) => `
1383
+ super(spaceTrim$1.spaceTrim((block) => `
1350
1384
  ${block(message)}
1351
1385
 
1352
1386
  Note: This error should not happen.
@@ -1372,7 +1406,7 @@
1372
1406
  constructor(whatWasThrown) {
1373
1407
  const tag = `[🤮]`;
1374
1408
  console.error(tag, whatWasThrown);
1375
- super(spaceTrim.spaceTrim(`
1409
+ super(spaceTrim$1.spaceTrim(`
1376
1410
  Non-Error object was thrown
1377
1411
 
1378
1412
  Note: Look for ${tag} in the console for more details
@@ -1706,7 +1740,7 @@
1706
1740
  */
1707
1741
  class NotYetImplementedError extends Error {
1708
1742
  constructor(message) {
1709
- super(spaceTrim.spaceTrim((block) => `
1743
+ super(spaceTrim$1.spaceTrim((block) => `
1710
1744
  ${block(message)}
1711
1745
 
1712
1746
  Note: This feature is not implemented yet but it will be soon.
@@ -2060,7 +2094,7 @@
2060
2094
  */
2061
2095
  class MissingToolsError extends Error {
2062
2096
  constructor(message) {
2063
- super(spaceTrim.spaceTrim((block) => `
2097
+ super(spaceTrim$1.spaceTrim((block) => `
2064
2098
  ${block(message)}
2065
2099
 
2066
2100
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -6912,18 +6946,26 @@
6912
6946
  modelName: 'assistant',
6913
6947
  // <- [🧠] What is the best value here
6914
6948
  });
6949
+ // Build thread messages: include previous thread messages + current user message
6950
+ const threadMessages = [];
6951
+ // TODO: [🈹] Maybe this should not be here but in other place, look at commit 39d705e75e5bcf7a818c3af36bc13e1c8475c30c
6952
+ // Add previous messages from thread (if any)
6953
+ if ('thread' in prompt &&
6954
+ Array.isArray(prompt.thread)) {
6955
+ const previousMessages = prompt.thread.map((msg) => ({
6956
+ role: (msg.role === 'assistant' ? 'assistant' : 'user'),
6957
+ content: msg.content,
6958
+ }));
6959
+ threadMessages.push(...previousMessages);
6960
+ }
6961
+ // Always add the current user message
6962
+ threadMessages.push({ role: 'user', content: rawPromptContent });
6915
6963
  const rawRequest = {
6916
6964
  // TODO: [👨‍👨‍👧‍👧] ...modelSettings,
6917
6965
  // TODO: [👨‍👨‍👧‍👧][🧠] What about system message for assistants, does it make sense - combination of OpenAI assistants with Promptbook Personas
6918
6966
  assistant_id: this.assistantId,
6919
6967
  thread: {
6920
- messages: 'thread' in prompt &&
6921
- Array.isArray(prompt.thread)
6922
- ? prompt.thread.map((msg) => ({
6923
- role: msg.role === 'assistant' ? 'assistant' : 'user',
6924
- content: msg.content,
6925
- }))
6926
- : [{ role: 'user', content: rawPromptContent }],
6968
+ messages: threadMessages,
6927
6969
  },
6928
6970
  // <- TODO: Add user identification here> user: this.options.user,
6929
6971
  };
@@ -6943,7 +6985,7 @@
6943
6985
  console.info('textDelta', textDelta.value);
6944
6986
  }
6945
6987
  const chunk = {
6946
- content: textDelta.value || '',
6988
+ content: snapshot.value,
6947
6989
  modelName: 'assistant',
6948
6990
  timing: {
6949
6991
  start,
@@ -7607,11 +7649,11 @@
7607
7649
  console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
7608
7650
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
7609
7651
  }
7610
- resolve(spaceTrim.spaceTrim(output.join('\n')));
7652
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
7611
7653
  }
7612
7654
  }
7613
7655
  else {
7614
- resolve(spaceTrim.spaceTrim(output.join('\n')));
7656
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
7615
7657
  }
7616
7658
  };
7617
7659
  commandProcess.on('close', finishWithCode);
@@ -7629,7 +7671,7 @@
7629
7671
  console.warn(error);
7630
7672
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
7631
7673
  }
7632
- resolve(spaceTrim.spaceTrim(output.join('\n')));
7674
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
7633
7675
  }
7634
7676
  });
7635
7677
  }
@@ -8247,7 +8289,7 @@
8247
8289
  if (!(error instanceof PipelineLogicError)) {
8248
8290
  throw error;
8249
8291
  }
8250
- console.error(spaceTrim.spaceTrim((block) => `
8292
+ console.error(spaceTrim$1.spaceTrim((block) => `
8251
8293
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
8252
8294
 
8253
8295
  ${block(error.message)}
@@ -8274,7 +8316,7 @@
8274
8316
  })();
8275
8317
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
8276
8318
  // <- Note: [🚲]
8277
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8319
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8278
8320
  Invalid promptbook URL "${pipeline.pipelineUrl}"
8279
8321
 
8280
8322
  ${block(pipelineIdentification)}
@@ -8282,7 +8324,7 @@
8282
8324
  }
8283
8325
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
8284
8326
  // <- Note: [🚲]
8285
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8327
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8286
8328
  Invalid Promptbook Version "${pipeline.bookVersion}"
8287
8329
 
8288
8330
  ${block(pipelineIdentification)}
@@ -8291,7 +8333,7 @@
8291
8333
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
8292
8334
  if (!Array.isArray(pipeline.parameters)) {
8293
8335
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
8294
- throw new ParseError(spaceTrim.spaceTrim((block) => `
8336
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
8295
8337
  Pipeline is valid JSON but with wrong structure
8296
8338
 
8297
8339
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -8302,7 +8344,7 @@
8302
8344
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
8303
8345
  if (!Array.isArray(pipeline.tasks)) {
8304
8346
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
8305
- throw new ParseError(spaceTrim.spaceTrim((block) => `
8347
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
8306
8348
  Pipeline is valid JSON but with wrong structure
8307
8349
 
8308
8350
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -8328,7 +8370,7 @@
8328
8370
  // Note: Check each parameter individually
8329
8371
  for (const parameter of pipeline.parameters) {
8330
8372
  if (parameter.isInput && parameter.isOutput) {
8331
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8373
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8332
8374
 
8333
8375
  Parameter \`{${parameter.name}}\` can not be both input and output
8334
8376
 
@@ -8339,7 +8381,7 @@
8339
8381
  if (!parameter.isInput &&
8340
8382
  !parameter.isOutput &&
8341
8383
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
8342
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8384
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8343
8385
  Parameter \`{${parameter.name}}\` is created but not used
8344
8386
 
8345
8387
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -8351,7 +8393,7 @@
8351
8393
  }
8352
8394
  // Note: Testing that parameter is either input or result of some task
8353
8395
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
8354
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8396
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8355
8397
  Parameter \`{${parameter.name}}\` is declared but not defined
8356
8398
 
8357
8399
  You can do one of these:
@@ -8367,14 +8409,14 @@
8367
8409
  // Note: Checking each task individually
8368
8410
  for (const task of pipeline.tasks) {
8369
8411
  if (definedParameters.has(task.resultingParameterName)) {
8370
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8412
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8371
8413
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
8372
8414
 
8373
8415
  ${block(pipelineIdentification)}
8374
8416
  `));
8375
8417
  }
8376
8418
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
8377
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8419
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8378
8420
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
8379
8421
 
8380
8422
  ${block(pipelineIdentification)}
@@ -8384,7 +8426,7 @@
8384
8426
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
8385
8427
  if (!task.format &&
8386
8428
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
8387
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8429
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8388
8430
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
8389
8431
 
8390
8432
  ${block(pipelineIdentification)}
@@ -8392,7 +8434,7 @@
8392
8434
  }
8393
8435
  for (const joker of task.jokerParameterNames) {
8394
8436
  if (!task.dependentParameterNames.includes(joker)) {
8395
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8437
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8396
8438
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
8397
8439
 
8398
8440
  ${block(pipelineIdentification)}
@@ -8403,21 +8445,21 @@
8403
8445
  if (task.expectations) {
8404
8446
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
8405
8447
  if (min !== undefined && max !== undefined && min > max) {
8406
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8448
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8407
8449
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
8408
8450
 
8409
8451
  ${block(pipelineIdentification)}
8410
8452
  `));
8411
8453
  }
8412
8454
  if (min !== undefined && min < 0) {
8413
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8455
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8414
8456
  Min expectation of ${unit} must be zero or positive
8415
8457
 
8416
8458
  ${block(pipelineIdentification)}
8417
8459
  `));
8418
8460
  }
8419
8461
  if (max !== undefined && max <= 0) {
8420
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
8462
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
8421
8463
  Max expectation of ${unit} must be positive
8422
8464
 
8423
8465
  ${block(pipelineIdentification)}
@@ -8439,7 +8481,7 @@
8439
8481
  while (unresovedTasks.length > 0) {
8440
8482
  if (loopLimit-- < 0) {
8441
8483
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
8442
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
8484
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
8443
8485
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
8444
8486
 
8445
8487
  ${block(pipelineIdentification)}
@@ -8449,7 +8491,7 @@
8449
8491
  if (currentlyResovedTasks.length === 0) {
8450
8492
  throw new PipelineLogicError(
8451
8493
  // TODO: [🐎] DRY
8452
- spaceTrim.spaceTrim((block) => `
8494
+ spaceTrim$1.spaceTrim((block) => `
8453
8495
 
8454
8496
  Can not resolve some parameters:
8455
8497
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -8587,7 +8629,7 @@
8587
8629
  for (const pipeline of pipelines) {
8588
8630
  // TODO: [👠] DRY
8589
8631
  if (pipeline.pipelineUrl === undefined) {
8590
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
8632
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
8591
8633
  Pipeline with name "${pipeline.title}" does not have defined URL
8592
8634
 
8593
8635
  File:
@@ -8609,7 +8651,7 @@
8609
8651
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
8610
8652
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
8611
8653
  const existing = this.collection.get(pipeline.pipelineUrl);
8612
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
8654
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
8613
8655
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
8614
8656
 
8615
8657
  Conflicting files:
@@ -8641,13 +8683,13 @@
8641
8683
  const pipeline = this.collection.get(url);
8642
8684
  if (!pipeline) {
8643
8685
  if (this.listPipelines().length === 0) {
8644
- throw new NotFoundError(spaceTrim.spaceTrim(`
8686
+ throw new NotFoundError(spaceTrim$1.spaceTrim(`
8645
8687
  Pipeline with url "${url}" not found
8646
8688
 
8647
8689
  No pipelines available
8648
8690
  `));
8649
8691
  }
8650
- throw new NotFoundError(spaceTrim.spaceTrim((block) => `
8692
+ throw new NotFoundError(spaceTrim$1.spaceTrim((block) => `
8651
8693
  Pipeline with url "${url}" not found
8652
8694
 
8653
8695
  Available pipelines:
@@ -8841,11 +8883,11 @@
8841
8883
  throw deserializeError(errors[0]);
8842
8884
  }
8843
8885
  else {
8844
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
8886
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
8845
8887
  Multiple errors occurred during Promptbook execution
8846
8888
 
8847
8889
  ${block(errors
8848
- .map(({ name, stack, message }, index) => spaceTrim.spaceTrim((block) => `
8890
+ .map(({ name, stack, message }, index) => spaceTrim$1.spaceTrim((block) => `
8849
8891
  ${name} ${index + 1}:
8850
8892
  ${block(stack || message)}
8851
8893
  `))
@@ -10021,7 +10063,7 @@
10021
10063
  if (task.taskType === 'PROMPT_TASK' &&
10022
10064
  knowledgePiecesCount > 0 &&
10023
10065
  !dependentParameterNames.includes('knowledge')) {
10024
- preparedContent = spaceTrim.spaceTrim(`
10066
+ preparedContent = spaceTrim$1.spaceTrim(`
10025
10067
  {content}
10026
10068
 
10027
10069
  ## Knowledge
@@ -10253,7 +10295,7 @@
10253
10295
  }
10254
10296
  catch (error) {
10255
10297
  assertsError(error);
10256
- throw new ParseError(spaceTrim.spaceTrim((block) => `
10298
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
10257
10299
  Can not extract variables from the script
10258
10300
  ${block(error.stack || error.message)}
10259
10301
 
@@ -10895,7 +10937,7 @@
10895
10937
  }
10896
10938
  catch (error) {
10897
10939
  keepUnused(error);
10898
- throw new ExpectError(spaceTrim.spaceTrim((block) => `
10940
+ throw new ExpectError(spaceTrim$1.spaceTrim((block) => `
10899
10941
  Expected valid JSON string
10900
10942
 
10901
10943
  The expected JSON text:
@@ -10958,7 +11000,7 @@
10958
11000
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
10959
11001
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
10960
11002
  if (isJokerAttempt && !jokerParameterName) {
10961
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
11003
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
10962
11004
  Joker not found in attempt ${attemptIndex}
10963
11005
 
10964
11006
  ${block(pipelineIdentification)}
@@ -10969,7 +11011,7 @@
10969
11011
  $ongoingTaskResult.$expectError = null;
10970
11012
  if (isJokerAttempt) {
10971
11013
  if (parameters[jokerParameterName] === undefined) {
10972
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11014
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
10973
11015
  Joker parameter {${jokerParameterName}} not defined
10974
11016
 
10975
11017
  ${block(pipelineIdentification)}
@@ -11027,7 +11069,7 @@
11027
11069
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
11028
11070
  break variant;
11029
11071
  case 'EMBEDDING':
11030
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11072
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11031
11073
  Embedding model can not be used in pipeline
11032
11074
 
11033
11075
  This should be catched during parsing
@@ -11038,7 +11080,7 @@
11038
11080
  break variant;
11039
11081
  // <- case [🤖]:
11040
11082
  default:
11041
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11083
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11042
11084
  Unknown model variant "${task.modelRequirements.modelVariant}"
11043
11085
 
11044
11086
  ${block(pipelineIdentification)}
@@ -11049,14 +11091,14 @@
11049
11091
  break;
11050
11092
  case 'SCRIPT_TASK':
11051
11093
  if (arrayableToArray(tools.script).length === 0) {
11052
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11094
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11053
11095
  No script execution tools are available
11054
11096
 
11055
11097
  ${block(pipelineIdentification)}
11056
11098
  `));
11057
11099
  }
11058
11100
  if (!task.contentLanguage) {
11059
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11101
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11060
11102
  Script language is not defined for SCRIPT TASK "${task.name}"
11061
11103
 
11062
11104
  ${block(pipelineIdentification)}
@@ -11087,7 +11129,7 @@
11087
11129
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
11088
11130
  }
11089
11131
  else {
11090
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11132
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11091
11133
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
11092
11134
 
11093
11135
  ${block(pipelineIdentification)}
@@ -11101,7 +11143,7 @@
11101
11143
  break taskType;
11102
11144
  case 'DIALOG_TASK':
11103
11145
  if (tools.userInterface === undefined) {
11104
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11146
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11105
11147
  User interface tools are not available
11106
11148
 
11107
11149
  ${block(pipelineIdentification)}
@@ -11119,7 +11161,7 @@
11119
11161
  break taskType;
11120
11162
  // <- case: [🅱]
11121
11163
  default:
11122
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11164
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11123
11165
  Unknown execution type "${task.taskType}"
11124
11166
 
11125
11167
  ${block(pipelineIdentification)}
@@ -11217,7 +11259,7 @@
11217
11259
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
11218
11260
  // Note: Create a summary of all failures
11219
11261
  const failuresSummary = $ongoingTaskResult.$failedResults
11220
- .map((failure) => spaceTrim.spaceTrim((block) => {
11262
+ .map((failure) => spaceTrim$1.spaceTrim((block) => {
11221
11263
  var _a, _b;
11222
11264
  return `
11223
11265
  Attempt ${failure.attemptIndex + 1}:
@@ -11227,14 +11269,14 @@
11227
11269
  Result:
11228
11270
  ${block(failure.result === null
11229
11271
  ? 'null'
11230
- : spaceTrim.spaceTrim(failure.result)
11272
+ : spaceTrim$1.spaceTrim(failure.result)
11231
11273
  .split('\n')
11232
11274
  .map((line) => `> ${line}`)
11233
11275
  .join('\n'))}
11234
11276
  `;
11235
11277
  }))
11236
11278
  .join('\n\n---\n\n');
11237
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
11279
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => {
11238
11280
  var _a;
11239
11281
  return `
11240
11282
  LLM execution failed ${maxExecutionAttempts}x
@@ -11254,7 +11296,7 @@
11254
11296
  }
11255
11297
  }
11256
11298
  if ($ongoingTaskResult.$resultString === null) {
11257
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
11299
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
11258
11300
  Something went wrong and prompt result is null
11259
11301
 
11260
11302
  ${block(pipelineIdentification)}
@@ -11560,7 +11602,7 @@
11560
11602
  // Note: Doublecheck that ALL reserved parameters are defined:
11561
11603
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
11562
11604
  if (reservedParameters[parameterName] === undefined) {
11563
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
11605
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
11564
11606
  Reserved parameter {${parameterName}} is not defined
11565
11607
 
11566
11608
  ${block(pipelineIdentification)}
@@ -11586,7 +11628,7 @@
11586
11628
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
11587
11629
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
11588
11630
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
11589
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
11631
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
11590
11632
  Dependent parameters are not consistent with used parameters:
11591
11633
 
11592
11634
  Dependent parameters:
@@ -11630,7 +11672,7 @@
11630
11672
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
11631
11673
  // Houston, we have a problem
11632
11674
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
11633
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
11675
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
11634
11676
  Parameter \`{${parameterName}}\` is NOT defined
11635
11677
  BUT used in task "${currentTask.title || currentTask.name}"
11636
11678
 
@@ -11699,7 +11741,7 @@
11699
11741
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
11700
11742
  if (parametersToPass[parameter.name] === undefined) {
11701
11743
  // [4]
11702
- $warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11744
+ $warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11703
11745
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
11704
11746
 
11705
11747
  Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
@@ -11807,7 +11849,7 @@
11807
11849
  for (const parameterName of Object.keys(inputParameters)) {
11808
11850
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
11809
11851
  if (parameter === undefined) {
11810
- warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11852
+ warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11811
11853
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
11812
11854
 
11813
11855
  ${block(pipelineIdentification)}
@@ -11822,7 +11864,7 @@
11822
11864
  // TODO: [🧠] This should be also non-critical error
11823
11865
  return exportJson({
11824
11866
  name: 'pipelineExecutorResult',
11825
- message: spaceTrim.spaceTrim((block) => `
11867
+ message: spaceTrim$1.spaceTrim((block) => `
11826
11868
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
11827
11869
 
11828
11870
  ${block(pipelineIdentification)}
@@ -11831,7 +11873,7 @@
11831
11873
  value: {
11832
11874
  isSuccessful: false,
11833
11875
  errors: [
11834
- new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11876
+ new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11835
11877
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
11836
11878
 
11837
11879
  ${block(pipelineIdentification)}
@@ -11858,7 +11900,7 @@
11858
11900
  while (unresovedTasks.length > 0) {
11859
11901
  if (loopLimit-- < 0) {
11860
11902
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
11861
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
11903
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
11862
11904
  Loop limit reached during resolving parameters pipeline execution
11863
11905
 
11864
11906
  ${block(pipelineIdentification)}
@@ -11868,7 +11910,7 @@
11868
11910
  if (!currentTask && resolving.length === 0) {
11869
11911
  throw new UnexpectedError(
11870
11912
  // TODO: [🐎] DRY
11871
- spaceTrim.spaceTrim((block) => `
11913
+ spaceTrim$1.spaceTrim((block) => `
11872
11914
  Can not resolve some parameters:
11873
11915
 
11874
11916
  ${block(pipelineIdentification)}
@@ -11908,7 +11950,7 @@
11908
11950
  tools,
11909
11951
  onProgress(newOngoingResult) {
11910
11952
  if (isReturned) {
11911
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
11953
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
11912
11954
  Can not call \`onProgress\` after pipeline execution is finished
11913
11955
 
11914
11956
  ${block(pipelineIdentification)}
@@ -11925,7 +11967,7 @@
11925
11967
  },
11926
11968
  logLlmCall,
11927
11969
  $executionReport: executionReport,
11928
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
11970
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
11929
11971
  ${block(pipelineIdentification)}
11930
11972
  Task name: ${currentTask.name}
11931
11973
  Task title: ${currentTask.title}
@@ -12034,7 +12076,7 @@
12034
12076
  preparedPipeline = pipeline;
12035
12077
  }
12036
12078
  else if (isNotPreparedWarningSuppressed !== true) {
12037
- console.warn(spaceTrim.spaceTrim((block) => `
12079
+ console.warn(spaceTrim$1.spaceTrim((block) => `
12038
12080
  Pipeline is not prepared
12039
12081
 
12040
12082
  ${block(pipelineIdentification)}
@@ -12059,7 +12101,7 @@
12059
12101
  tools,
12060
12102
  onProgress,
12061
12103
  logLlmCall,
12062
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
12104
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
12063
12105
  ${block(pipelineIdentification)}
12064
12106
  ${runCount === 1 ? '' : `Run #${runCount}`}
12065
12107
  `),
@@ -13580,7 +13622,7 @@
13580
13622
  * Markdown documentation for ACTION commitment.
13581
13623
  */
13582
13624
  get documentation() {
13583
- return spaceTrim.spaceTrim(`
13625
+ return spaceTrim$1.spaceTrim(`
13584
13626
  # ${this.type}
13585
13627
 
13586
13628
  Defines specific actions or capabilities that the agent can perform.
@@ -13627,6 +13669,133 @@
13627
13669
  * Note: [💞] Ignore a discrepancy between file name and entity name
13628
13670
  */
13629
13671
 
13672
+ /**
13673
+ * CLOSED commitment definition
13674
+ *
13675
+ * The CLOSED commitment specifies that the agent CANNOT be modified by conversation.
13676
+ * It prevents the agent from learning from interactions and updating its source code.
13677
+ *
13678
+ * Example usage in agent source:
13679
+ *
13680
+ * ```book
13681
+ * CLOSED
13682
+ * ```
13683
+ *
13684
+ * @private [🪔] Maybe export the commitments through some package
13685
+ */
13686
+ class ClosedCommitmentDefinition extends BaseCommitmentDefinition {
13687
+ constructor() {
13688
+ super('CLOSED');
13689
+ }
13690
+ /**
13691
+ * Short one-line description of CLOSED.
13692
+ */
13693
+ get description() {
13694
+ return 'Prevent the agent from being modified by conversation.';
13695
+ }
13696
+ /**
13697
+ * Icon for this commitment.
13698
+ */
13699
+ get icon() {
13700
+ return '🔒';
13701
+ }
13702
+ /**
13703
+ * Markdown documentation for CLOSED commitment.
13704
+ */
13705
+ get documentation() {
13706
+ return spaceTrim$1.spaceTrim(`
13707
+ # CLOSED
13708
+
13709
+ Specifies that the agent **cannot** be modified by conversation with it.
13710
+ This means the agent will **not** learn from interactions and its source code will remain static during conversation.
13711
+
13712
+ By default (if not specified), agents are \`OPEN\` to modification.
13713
+
13714
+ > See also [OPEN](/docs/OPEN)
13715
+
13716
+ ## Example
13717
+
13718
+ \`\`\`book
13719
+ CLOSED
13720
+ \`\`\`
13721
+ `);
13722
+ }
13723
+ applyToAgentModelRequirements(requirements, _content) {
13724
+ const updatedMetadata = {
13725
+ ...requirements.metadata,
13726
+ isClosed: true,
13727
+ };
13728
+ return {
13729
+ ...requirements,
13730
+ metadata: updatedMetadata,
13731
+ };
13732
+ }
13733
+ }
13734
+ /**
13735
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13736
+ */
13737
+
13738
+ /**
13739
+ * COMPONENT commitment definition
13740
+ *
13741
+ * The COMPONENT commitment defines a UI component that the agent can render in the chat.
13742
+ *
13743
+ * @private [🪔] Maybe export the commitments through some package
13744
+ */
13745
+ class ComponentCommitmentDefinition extends BaseCommitmentDefinition {
13746
+ constructor() {
13747
+ super('COMPONENT');
13748
+ }
13749
+ /**
13750
+ * Short one-line description of COMPONENT.
13751
+ */
13752
+ get description() {
13753
+ return 'Define a UI component that the agent can render in the chat.';
13754
+ }
13755
+ /**
13756
+ * Icon for this commitment.
13757
+ */
13758
+ get icon() {
13759
+ return '🧩';
13760
+ }
13761
+ /**
13762
+ * Markdown documentation for COMPONENT commitment.
13763
+ */
13764
+ get documentation() {
13765
+ return spaceTrim$1.spaceTrim(`
13766
+ # COMPONENT
13767
+
13768
+ Defines a UI component that the agent can render in the chat.
13769
+
13770
+ ## Key aspects
13771
+
13772
+ - Tells the agent that a specific component is available.
13773
+ - Provides syntax for using the component.
13774
+
13775
+ ## Example
13776
+
13777
+ \`\`\`book
13778
+ COMPONENT Arrow
13779
+ The agent should render an arrow component in the chat UI.
13780
+ Syntax:
13781
+ <Arrow direction="up" color="red" />
13782
+ \`\`\`
13783
+ `);
13784
+ }
13785
+ applyToAgentModelRequirements(requirements, content) {
13786
+ const trimmedContent = content.trim();
13787
+ if (!trimmedContent) {
13788
+ return requirements;
13789
+ }
13790
+ // Add component capability to the system message
13791
+ const componentSection = `Component: ${trimmedContent}`;
13792
+ return this.appendToSystemMessage(requirements, componentSection, '\n\n');
13793
+ }
13794
+ }
13795
+ /**
13796
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13797
+ */
13798
+
13630
13799
  /**
13631
13800
  * DELETE commitment definition
13632
13801
  *
@@ -13665,7 +13834,7 @@
13665
13834
  * Markdown documentation for DELETE commitment.
13666
13835
  */
13667
13836
  get documentation() {
13668
- return spaceTrim.spaceTrim(`
13837
+ return spaceTrim$1.spaceTrim(`
13669
13838
  # DELETE (CANCEL, DISCARD, REMOVE)
13670
13839
 
13671
13840
  A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
@@ -13787,7 +13956,7 @@
13787
13956
  * Markdown documentation for FORMAT commitment.
13788
13957
  */
13789
13958
  get documentation() {
13790
- return spaceTrim.spaceTrim(`
13959
+ return spaceTrim$1.spaceTrim(`
13791
13960
  # ${this.type}
13792
13961
 
13793
13962
  Defines the specific output structure and formatting for responses (data formats, templates, structure).
@@ -13832,6 +14001,79 @@
13832
14001
  * Note: [💞] Ignore a discrepancy between file name and entity name
13833
14002
  */
13834
14003
 
14004
+ /**
14005
+ * FROM commitment definition
14006
+ *
14007
+ * The FROM commitment tells the agent that its `agentSource` is inherited from another agent.
14008
+ *
14009
+ * Example usage in agent source:
14010
+ *
14011
+ * ```book
14012
+ * FROM https://s6.ptbk.io/benjamin-white
14013
+ * ```
14014
+ *
14015
+ * @private [🪔] Maybe export the commitments through some package
14016
+ */
14017
+ class FromCommitmentDefinition extends BaseCommitmentDefinition {
14018
+ constructor(type = 'FROM') {
14019
+ super(type);
14020
+ }
14021
+ /**
14022
+ * Short one-line description of FROM.
14023
+ */
14024
+ get description() {
14025
+ return 'Inherit agent source from another agent.';
14026
+ }
14027
+ /**
14028
+ * Icon for this commitment.
14029
+ */
14030
+ get icon() {
14031
+ return '🧬';
14032
+ }
14033
+ /**
14034
+ * Markdown documentation for FROM commitment.
14035
+ */
14036
+ get documentation() {
14037
+ return spaceTrim$1.spaceTrim(`
14038
+ # ${this.type}
14039
+
14040
+ Inherits agent source from another agent.
14041
+
14042
+ ## Examples
14043
+
14044
+ \`\`\`book
14045
+ My AI Agent
14046
+
14047
+ FROM https://s6.ptbk.io/benjamin-white
14048
+ RULE Speak only in English.
14049
+ \`\`\`
14050
+ `);
14051
+ }
14052
+ applyToAgentModelRequirements(requirements, content) {
14053
+ const trimmedContent = content.trim();
14054
+ if (!trimmedContent) {
14055
+ return requirements;
14056
+ }
14057
+ // Validate URL
14058
+ try {
14059
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
14060
+ const url = new URL(trimmedContent);
14061
+ // TODO: Add more validation if needed (e.g. check for valid protocol)
14062
+ }
14063
+ catch (error) {
14064
+ console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
14065
+ return requirements;
14066
+ }
14067
+ return {
14068
+ ...requirements,
14069
+ parentAgentUrl: trimmedContent,
14070
+ };
14071
+ }
14072
+ }
14073
+ /**
14074
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14075
+ */
14076
+
13835
14077
  /**
13836
14078
  * GOAL commitment definition
13837
14079
  *
@@ -13868,7 +14110,7 @@
13868
14110
  * Markdown documentation for GOAL commitment.
13869
14111
  */
13870
14112
  get documentation() {
13871
- return spaceTrim.spaceTrim(`
14113
+ return spaceTrim$1.spaceTrim(`
13872
14114
  # ${this.type}
13873
14115
 
13874
14116
  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.
@@ -13970,7 +14212,7 @@
13970
14212
  * Markdown documentation for KNOWLEDGE commitment.
13971
14213
  */
13972
14214
  get documentation() {
13973
- return spaceTrim.spaceTrim(`
14215
+ return spaceTrim$1.spaceTrim(`
13974
14216
  # ${this.type}
13975
14217
 
13976
14218
  Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
@@ -14040,6 +14282,77 @@
14040
14282
  * Note: [💞] Ignore a discrepancy between file name and entity name
14041
14283
  */
14042
14284
 
14285
+ /**
14286
+ * LANGUAGE commitment definition
14287
+ *
14288
+ * The LANGUAGE/LANGUAGES commitment specifies the language(s) the agent should use in its responses.
14289
+ *
14290
+ * Example usage in agent source:
14291
+ *
14292
+ * ```book
14293
+ * LANGUAGE English
14294
+ * LANGUAGE French, English and Czech
14295
+ * ```
14296
+ *
14297
+ * @private [🪔] Maybe export the commitments through some package
14298
+ */
14299
+ class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
14300
+ constructor(type = 'LANGUAGE') {
14301
+ super(type);
14302
+ }
14303
+ /**
14304
+ * Short one-line description of LANGUAGE/LANGUAGES.
14305
+ */
14306
+ get description() {
14307
+ return 'Specifies the language(s) the agent should use.';
14308
+ }
14309
+ /**
14310
+ * Icon for this commitment.
14311
+ */
14312
+ get icon() {
14313
+ return '🌐';
14314
+ }
14315
+ /**
14316
+ * Markdown documentation for LANGUAGE/LANGUAGES commitment.
14317
+ */
14318
+ get documentation() {
14319
+ return spaceTrim$1.spaceTrim(`
14320
+ # ${this.type}
14321
+
14322
+ Specifies the language(s) the agent should use in its responses.
14323
+ This is a specialized variation of the RULE commitment focused on language constraints.
14324
+
14325
+ ## Examples
14326
+
14327
+ \`\`\`book
14328
+ Paul Smith & Associés
14329
+
14330
+ PERSONA You are a company lawyer.
14331
+ LANGUAGE French, English and Czech
14332
+ \`\`\`
14333
+
14334
+ \`\`\`book
14335
+ Customer Support
14336
+
14337
+ PERSONA You are a customer support agent.
14338
+ LANGUAGE English
14339
+ \`\`\`
14340
+ `);
14341
+ }
14342
+ applyToAgentModelRequirements(requirements, content) {
14343
+ const trimmedContent = content.trim();
14344
+ if (!trimmedContent) {
14345
+ return requirements;
14346
+ }
14347
+ // Add language rule to the system message
14348
+ const languageSection = `Language: ${trimmedContent}`;
14349
+ return this.appendToSystemMessage(requirements, languageSection, '\n\n');
14350
+ }
14351
+ }
14352
+ /**
14353
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14354
+ */
14355
+
14043
14356
  /**
14044
14357
  * MEMORY commitment definition
14045
14358
  *
@@ -14077,7 +14390,7 @@
14077
14390
  * Markdown documentation for MEMORY commitment.
14078
14391
  */
14079
14392
  get documentation() {
14080
- return spaceTrim.spaceTrim(`
14393
+ return spaceTrim$1.spaceTrim(`
14081
14394
  # ${this.type}
14082
14395
 
14083
14396
  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.
@@ -14181,7 +14494,7 @@
14181
14494
  * Markdown documentation for AGENT MESSAGE commitment.
14182
14495
  */
14183
14496
  get documentation() {
14184
- return spaceTrim.spaceTrim(`
14497
+ return spaceTrim$1.spaceTrim(`
14185
14498
  # ${this.type}
14186
14499
 
14187
14500
  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.
@@ -14258,7 +14571,7 @@
14258
14571
  * Markdown documentation for INITIAL MESSAGE commitment.
14259
14572
  */
14260
14573
  get documentation() {
14261
- return spaceTrim.spaceTrim(`
14574
+ return spaceTrim$1.spaceTrim(`
14262
14575
  # ${this.type}
14263
14576
 
14264
14577
  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).
@@ -14322,7 +14635,7 @@
14322
14635
  * Markdown documentation for MESSAGE commitment.
14323
14636
  */
14324
14637
  get documentation() {
14325
- return spaceTrim.spaceTrim(`
14638
+ return spaceTrim$1.spaceTrim(`
14326
14639
  # ${this.type}
14327
14640
 
14328
14641
  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.
@@ -14434,7 +14747,7 @@
14434
14747
  * Markdown documentation for USER MESSAGE commitment.
14435
14748
  */
14436
14749
  get documentation() {
14437
- return spaceTrim.spaceTrim(`
14750
+ return spaceTrim$1.spaceTrim(`
14438
14751
  # ${this.type}
14439
14752
 
14440
14753
  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.
@@ -14513,7 +14826,7 @@
14513
14826
  * Markdown documentation for META commitment.
14514
14827
  */
14515
14828
  get documentation() {
14516
- return spaceTrim.spaceTrim(`
14829
+ return spaceTrim$1.spaceTrim(`
14517
14830
  # META
14518
14831
 
14519
14832
  Sets meta-information about the agent that is used for display and attribution purposes.
@@ -14624,6 +14937,12 @@
14624
14937
  * META COLOR #00ff00
14625
14938
  * ```
14626
14939
  *
14940
+ * You can also specify multiple colors separated by comma:
14941
+ *
14942
+ * ```book
14943
+ * META COLOR #ff0000, #00ff00, #0000ff
14944
+ * ```
14945
+ *
14627
14946
  * @private [🪔] Maybe export the commitments through some package
14628
14947
  */
14629
14948
  class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
@@ -14634,7 +14953,7 @@
14634
14953
  * Short one-line description of META COLOR.
14635
14954
  */
14636
14955
  get description() {
14637
- return "Set the agent's accent color.";
14956
+ return "Set the agent's accent color or gradient.";
14638
14957
  }
14639
14958
  /**
14640
14959
  * Icon for this commitment.
@@ -14646,10 +14965,10 @@
14646
14965
  * Markdown documentation for META COLOR commitment.
14647
14966
  */
14648
14967
  get documentation() {
14649
- return spaceTrim.spaceTrim(`
14968
+ return spaceTrim$1.spaceTrim(`
14650
14969
  # META COLOR
14651
14970
 
14652
- Sets the agent's accent color.
14971
+ Sets the agent's accent color or gradient.
14653
14972
 
14654
14973
  ## Key aspects
14655
14974
 
@@ -14657,6 +14976,7 @@
14657
14976
  - Only one \`META COLOR\` should be used per agent.
14658
14977
  - If multiple are specified, the last one takes precedence.
14659
14978
  - Used for visual representation in user interfaces.
14979
+ - Can specify multiple colors separated by comma to create a gradient.
14660
14980
 
14661
14981
  ## Examples
14662
14982
 
@@ -14673,6 +14993,13 @@
14673
14993
  META COLOR #e74c3c
14674
14994
  PERSONA You are a creative and inspiring assistant
14675
14995
  \`\`\`
14996
+
14997
+ \`\`\`book
14998
+ Gradient Agent
14999
+
15000
+ META COLOR #ff0000, #00ff00, #0000ff
15001
+ PERSONA You are a colorful agent
15002
+ \`\`\`
14676
15003
  `);
14677
15004
  }
14678
15005
  applyToAgentModelRequirements(requirements, content) {
@@ -14695,84 +15022,82 @@
14695
15022
  */
14696
15023
 
14697
15024
  /**
14698
- * META IMAGE commitment definition
15025
+ * META FONT commitment definition
14699
15026
  *
14700
- * The META IMAGE commitment sets the agent's avatar/profile image URL.
15027
+ * The META FONT commitment sets the agent's font.
14701
15028
  * This commitment is special because it doesn't affect the system message,
14702
15029
  * but is handled separately in the parsing logic.
14703
15030
  *
14704
15031
  * Example usage in agent source:
14705
15032
  *
14706
15033
  * ```book
14707
- * META IMAGE https://example.com/avatar.jpg
14708
- * META IMAGE /assets/agent-avatar.png
15034
+ * META FONT Poppins, Arial, sans-serif
15035
+ * META FONT Roboto
14709
15036
  * ```
14710
15037
  *
14711
15038
  * @private [🪔] Maybe export the commitments through some package
14712
15039
  */
14713
- class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
15040
+ class MetaFontCommitmentDefinition extends BaseCommitmentDefinition {
14714
15041
  constructor() {
14715
- super('META IMAGE', ['IMAGE']);
15042
+ super('META FONT', ['FONT']);
14716
15043
  }
14717
15044
  /**
14718
- * Short one-line description of META IMAGE.
15045
+ * Short one-line description of META FONT.
14719
15046
  */
14720
15047
  get description() {
14721
- return "Set the agent's profile image URL.";
15048
+ return "Set the agent's font.";
14722
15049
  }
14723
15050
  /**
14724
15051
  * Icon for this commitment.
14725
15052
  */
14726
15053
  get icon() {
14727
- return '🖼️';
15054
+ return '🔤';
14728
15055
  }
14729
15056
  /**
14730
- * Markdown documentation for META IMAGE commitment.
15057
+ * Markdown documentation for META FONT commitment.
14731
15058
  */
14732
15059
  get documentation() {
14733
- return spaceTrim.spaceTrim(`
14734
- # META IMAGE
15060
+ return spaceTrim$1.spaceTrim(`
15061
+ # META FONT
14735
15062
 
14736
- Sets the agent's avatar/profile image URL.
15063
+ Sets the agent's font.
14737
15064
 
14738
15065
  ## Key aspects
14739
15066
 
14740
15067
  - Does not modify the agent's behavior or responses.
14741
- - Only one \`META IMAGE\` should be used per agent.
15068
+ - Only one \`META FONT\` should be used per agent.
14742
15069
  - If multiple are specified, the last one takes precedence.
14743
15070
  - Used for visual representation in user interfaces.
15071
+ - Supports Google Fonts.
14744
15072
 
14745
15073
  ## Examples
14746
15074
 
14747
15075
  \`\`\`book
14748
- Professional Assistant
15076
+ Modern Assistant
14749
15077
 
14750
- META IMAGE https://example.com/professional-avatar.jpg
14751
- PERSONA You are a professional business assistant
14752
- STYLE Maintain a formal and courteous tone
15078
+ META FONT Poppins, Arial, sans-serif
15079
+ PERSONA You are a modern assistant
14753
15080
  \`\`\`
14754
15081
 
14755
15082
  \`\`\`book
14756
- Creative Helper
15083
+ Classic Helper
14757
15084
 
14758
- META IMAGE /assets/creative-bot-avatar.png
14759
- PERSONA You are a creative and inspiring assistant
14760
- STYLE Be enthusiastic and encouraging
14761
- ACTION Can help with brainstorming and ideation
15085
+ META FONT Times New Roman
15086
+ PERSONA You are a classic helper
14762
15087
  \`\`\`
14763
15088
  `);
14764
15089
  }
14765
15090
  applyToAgentModelRequirements(requirements, content) {
14766
- // META IMAGE doesn't modify the system message or model requirements
14767
- // It's handled separately in the parsing logic for profile image extraction
15091
+ // META FONT doesn't modify the system message or model requirements
15092
+ // It's handled separately in the parsing logic
14768
15093
  // This method exists for consistency with the CommitmentDefinition interface
14769
15094
  return requirements;
14770
15095
  }
14771
15096
  /**
14772
- * Extracts the profile image URL from the content
15097
+ * Extracts the font from the content
14773
15098
  * This is used by the parsing logic
14774
15099
  */
14775
- extractProfileImageUrl(content) {
15100
+ extractProfileFont(content) {
14776
15101
  const trimmedContent = content.trim();
14777
15102
  return trimmedContent || null;
14778
15103
  }
@@ -14782,16 +15107,212 @@
14782
15107
  */
14783
15108
 
14784
15109
  /**
14785
- * MODEL commitment definition
15110
+ * META IMAGE commitment definition
14786
15111
  *
14787
- * The MODEL commitment specifies which AI model to use and can also set
14788
- * model-specific parameters like temperature, topP, topK, and maxTokens.
15112
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
15113
+ * This commitment is special because it doesn't affect the system message,
15114
+ * but is handled separately in the parsing logic.
14789
15115
  *
14790
- * Supports multiple syntax variations:
15116
+ * Example usage in agent source:
14791
15117
  *
14792
- * Single-line format:
14793
15118
  * ```book
14794
- * MODEL gpt-4
15119
+ * META IMAGE https://example.com/avatar.jpg
15120
+ * META IMAGE /assets/agent-avatar.png
15121
+ * ```
15122
+ *
15123
+ * @private [🪔] Maybe export the commitments through some package
15124
+ */
15125
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
15126
+ constructor() {
15127
+ super('META IMAGE', ['IMAGE']);
15128
+ }
15129
+ /**
15130
+ * Short one-line description of META IMAGE.
15131
+ */
15132
+ get description() {
15133
+ return "Set the agent's profile image URL.";
15134
+ }
15135
+ /**
15136
+ * Icon for this commitment.
15137
+ */
15138
+ get icon() {
15139
+ return '🖼️';
15140
+ }
15141
+ /**
15142
+ * Markdown documentation for META IMAGE commitment.
15143
+ */
15144
+ get documentation() {
15145
+ return spaceTrim$1.spaceTrim(`
15146
+ # META IMAGE
15147
+
15148
+ Sets the agent's avatar/profile image URL.
15149
+
15150
+ ## Key aspects
15151
+
15152
+ - Does not modify the agent's behavior or responses.
15153
+ - Only one \`META IMAGE\` should be used per agent.
15154
+ - If multiple are specified, the last one takes precedence.
15155
+ - Used for visual representation in user interfaces.
15156
+
15157
+ ## Examples
15158
+
15159
+ \`\`\`book
15160
+ Professional Assistant
15161
+
15162
+ META IMAGE https://example.com/professional-avatar.jpg
15163
+ PERSONA You are a professional business assistant
15164
+ STYLE Maintain a formal and courteous tone
15165
+ \`\`\`
15166
+
15167
+ \`\`\`book
15168
+ Creative Helper
15169
+
15170
+ META IMAGE /assets/creative-bot-avatar.png
15171
+ PERSONA You are a creative and inspiring assistant
15172
+ STYLE Be enthusiastic and encouraging
15173
+ ACTION Can help with brainstorming and ideation
15174
+ \`\`\`
15175
+ `);
15176
+ }
15177
+ applyToAgentModelRequirements(requirements, content) {
15178
+ // META IMAGE doesn't modify the system message or model requirements
15179
+ // It's handled separately in the parsing logic for profile image extraction
15180
+ // This method exists for consistency with the CommitmentDefinition interface
15181
+ return requirements;
15182
+ }
15183
+ /**
15184
+ * Extracts the profile image URL from the content
15185
+ * This is used by the parsing logic
15186
+ */
15187
+ extractProfileImageUrl(content) {
15188
+ const trimmedContent = content.trim();
15189
+ return trimmedContent || null;
15190
+ }
15191
+ }
15192
+ /**
15193
+ * Note: [💞] Ignore a discrepancy between file name and entity name
15194
+ */
15195
+
15196
+ /**
15197
+ * META LINK commitment definition
15198
+ *
15199
+ * The `META LINK` commitment represents the link to the person from whom the agent is created.
15200
+ * This commitment is special because it doesn't affect the system message,
15201
+ * but is handled separately in the parsing logic for profile display.
15202
+ *
15203
+ * Example usage in agent source:
15204
+ *
15205
+ * ```
15206
+ * META LINK https://twitter.com/username
15207
+ * META LINK https://linkedin.com/in/profile
15208
+ * META LINK https://github.com/username
15209
+ * ```
15210
+ *
15211
+ * Multiple `META LINK` commitments can be used when there are multiple sources:
15212
+ *
15213
+ * ```book
15214
+ * META LINK https://twitter.com/username
15215
+ * META LINK https://linkedin.com/in/profile
15216
+ * ```
15217
+ *
15218
+ * @private [🪔] Maybe export the commitments through some package
15219
+ */
15220
+ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
15221
+ constructor() {
15222
+ super('META LINK');
15223
+ }
15224
+ /**
15225
+ * Short one-line description of META LINK.
15226
+ */
15227
+ get description() {
15228
+ return 'Provide profile/source links for the person the agent models.';
15229
+ }
15230
+ /**
15231
+ * Icon for this commitment.
15232
+ */
15233
+ get icon() {
15234
+ return '🔗';
15235
+ }
15236
+ /**
15237
+ * Markdown documentation for META LINK commitment.
15238
+ */
15239
+ get documentation() {
15240
+ return spaceTrim$1.spaceTrim(`
15241
+ # META LINK
15242
+
15243
+ Represents a profile or source link for the person the agent is modeled after.
15244
+
15245
+ ## Key aspects
15246
+
15247
+ - Does not modify the agent's behavior or responses.
15248
+ - Multiple \`META LINK\` commitments can be used for different social profiles.
15249
+ - Used for attribution and crediting the original person.
15250
+ - Displayed in user interfaces for transparency.
15251
+
15252
+ ## Examples
15253
+
15254
+ \`\`\`book
15255
+ Expert Consultant
15256
+
15257
+ META LINK https://twitter.com/expertname
15258
+ META LINK https://linkedin.com/in/expertprofile
15259
+ PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
15260
+ KNOWLEDGE Extensive background in machine learning and neural networks
15261
+ \`\`\`
15262
+
15263
+ \`\`\`book
15264
+ Open Source Developer
15265
+
15266
+ META LINK https://github.com/developer
15267
+ META LINK https://twitter.com/devhandle
15268
+ PERSONA You are an experienced open source developer
15269
+ ACTION Can help with code reviews and architecture decisions
15270
+ STYLE Be direct and technical in explanations
15271
+ \`\`\`
15272
+ `);
15273
+ }
15274
+ applyToAgentModelRequirements(requirements, content) {
15275
+ // META LINK doesn't modify the system message or model requirements
15276
+ // It's handled separately in the parsing logic for profile link extraction
15277
+ // This method exists for consistency with the CommitmentDefinition interface
15278
+ return requirements;
15279
+ }
15280
+ /**
15281
+ * Extracts the profile link URL from the content
15282
+ * This is used by the parsing logic
15283
+ */
15284
+ extractProfileLinkUrl(content) {
15285
+ const trimmedContent = content.trim();
15286
+ return trimmedContent || null;
15287
+ }
15288
+ /**
15289
+ * Validates if the provided content is a valid URL
15290
+ */
15291
+ isValidUrl(content) {
15292
+ try {
15293
+ new URL(content.trim());
15294
+ return true;
15295
+ }
15296
+ catch (_a) {
15297
+ return false;
15298
+ }
15299
+ }
15300
+ }
15301
+ /**
15302
+ * Note: [💞] Ignore a discrepancy between file name and entity name
15303
+ */
15304
+
15305
+ /**
15306
+ * MODEL commitment definition
15307
+ *
15308
+ * The MODEL commitment specifies which AI model to use and can also set
15309
+ * model-specific parameters like temperature, topP, topK, and maxTokens.
15310
+ *
15311
+ * Supports multiple syntax variations:
15312
+ *
15313
+ * Single-line format:
15314
+ * ```book
15315
+ * MODEL gpt-4
14795
15316
  * MODEL claude-3-opus temperature=0.3
14796
15317
  * MODEL gpt-3.5-turbo temperature=0.8 topP=0.9
14797
15318
  * ```
@@ -14826,7 +15347,7 @@
14826
15347
  * Markdown documentation for MODEL commitment.
14827
15348
  */
14828
15349
  get documentation() {
14829
- return spaceTrim.spaceTrim(`
15350
+ return spaceTrim$1.spaceTrim(`
14830
15351
  # ${this.type}
14831
15352
 
14832
15353
  Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
@@ -15067,7 +15588,7 @@
15067
15588
  * Markdown documentation for NOTE commitment.
15068
15589
  */
15069
15590
  get documentation() {
15070
- return spaceTrim.spaceTrim(`
15591
+ return spaceTrim$1.spaceTrim(`
15071
15592
  # ${this.type}
15072
15593
 
15073
15594
  Adds comments for documentation without changing agent behavior.
@@ -15132,6 +15653,74 @@
15132
15653
  * [💞] Ignore a discrepancy between file name and entity name
15133
15654
  */
15134
15655
 
15656
+ /**
15657
+ * OPEN commitment definition
15658
+ *
15659
+ * The OPEN commitment specifies that the agent can be modified by conversation.
15660
+ * This is the default behavior.
15661
+ *
15662
+ * Example usage in agent source:
15663
+ *
15664
+ * ```book
15665
+ * OPEN
15666
+ * ```
15667
+ *
15668
+ * @private [🪔] Maybe export the commitments through some package
15669
+ */
15670
+ class OpenCommitmentDefinition extends BaseCommitmentDefinition {
15671
+ constructor() {
15672
+ super('OPEN');
15673
+ }
15674
+ /**
15675
+ * Short one-line description of OPEN.
15676
+ */
15677
+ get description() {
15678
+ return 'Allow the agent to be modified by conversation (default).';
15679
+ }
15680
+ /**
15681
+ * Icon for this commitment.
15682
+ */
15683
+ get icon() {
15684
+ return '🔓';
15685
+ }
15686
+ /**
15687
+ * Markdown documentation for OPEN commitment.
15688
+ */
15689
+ get documentation() {
15690
+ return spaceTrim$1.spaceTrim(`
15691
+ # OPEN
15692
+
15693
+ Specifies that the agent can be modified by conversation with it.
15694
+ This means the agent will learn from interactions and update its source code.
15695
+
15696
+ This is the default behavior if neither \`OPEN\` nor \`CLOSED\` is specified.
15697
+
15698
+ > See also [CLOSED](/docs/CLOSED)
15699
+
15700
+ ## Example
15701
+
15702
+ \`\`\`book
15703
+ OPEN
15704
+ \`\`\`
15705
+ `);
15706
+ }
15707
+ applyToAgentModelRequirements(requirements, _content) {
15708
+ // Since OPEN is default, we can just ensure isClosed is false
15709
+ // But to be explicit we can set it
15710
+ const updatedMetadata = {
15711
+ ...requirements.metadata,
15712
+ isClosed: false,
15713
+ };
15714
+ return {
15715
+ ...requirements,
15716
+ metadata: updatedMetadata,
15717
+ };
15718
+ }
15719
+ }
15720
+ /**
15721
+ * Note: [💞] Ignore a discrepancy between file name and entity name
15722
+ */
15723
+
15135
15724
  /**
15136
15725
  * PERSONA commitment definition
15137
15726
  *
@@ -15175,7 +15764,7 @@
15175
15764
  * Markdown documentation for PERSONA commitment.
15176
15765
  */
15177
15766
  get documentation() {
15178
- return spaceTrim.spaceTrim(`
15767
+ return spaceTrim$1.spaceTrim(`
15179
15768
  # ${this.type}
15180
15769
 
15181
15770
  Defines who the agent is, their background, expertise, and personality traits.
@@ -15308,7 +15897,7 @@
15308
15897
  * Markdown documentation for RULE/RULES commitment.
15309
15898
  */
15310
15899
  get documentation() {
15311
- return spaceTrim.spaceTrim(`
15900
+ return spaceTrim$1.spaceTrim(`
15312
15901
  # ${this.type}
15313
15902
 
15314
15903
  Adds behavioral constraints and guidelines that the agent must follow.
@@ -15390,7 +15979,7 @@
15390
15979
  * Markdown documentation for SAMPLE/EXAMPLE commitment.
15391
15980
  */
15392
15981
  get documentation() {
15393
- return spaceTrim.spaceTrim(`
15982
+ return spaceTrim$1.spaceTrim(`
15394
15983
  # ${this.type}
15395
15984
 
15396
15985
  Provides examples of how the agent should respond or behave in certain situations.
@@ -15473,7 +16062,7 @@
15473
16062
  * Markdown documentation for SCENARIO commitment.
15474
16063
  */
15475
16064
  get documentation() {
15476
- return spaceTrim.spaceTrim(`
16065
+ return spaceTrim$1.spaceTrim(`
15477
16066
  # ${this.type}
15478
16067
 
15479
16068
  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.
@@ -15595,7 +16184,7 @@
15595
16184
  * Markdown documentation for STYLE commitment.
15596
16185
  */
15597
16186
  get documentation() {
15598
- return spaceTrim.spaceTrim(`
16187
+ return spaceTrim$1.spaceTrim(`
15599
16188
  # ${this.type}
15600
16189
 
15601
16190
  Defines how the agent should format and present its responses (tone, writing style, formatting).
@@ -15642,6 +16231,389 @@
15642
16231
  * [💞] Ignore a discrepancy between file name and entity name
15643
16232
  */
15644
16233
 
16234
+ /**
16235
+ * USE commitment definition
16236
+ *
16237
+ * The USE commitment indicates that the agent should utilize specific tools or capabilities
16238
+ * to access and interact with external systems when necessary.
16239
+ *
16240
+ * Supported USE types:
16241
+ * - USE BROWSER: Enables the agent to use a web browser tool
16242
+ * - USE SEARCH ENGINE (future): Enables search engine access
16243
+ * - USE FILE SYSTEM (future): Enables file system operations
16244
+ * - USE MCP (future): Enables MCP server connections
16245
+ *
16246
+ * The content following the USE commitment is ignored (similar to NOTE).
16247
+ *
16248
+ * Example usage in agent source:
16249
+ *
16250
+ * ```book
16251
+ * USE BROWSER
16252
+ * USE SEARCH ENGINE
16253
+ * ```
16254
+ *
16255
+ * @private [🪔] Maybe export the commitments through some package
16256
+ */
16257
+ class UseCommitmentDefinition extends BaseCommitmentDefinition {
16258
+ constructor() {
16259
+ super('USE');
16260
+ }
16261
+ /**
16262
+ * Short one-line description of USE commitments.
16263
+ */
16264
+ get description() {
16265
+ return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
16266
+ }
16267
+ /**
16268
+ * Icon for this commitment.
16269
+ */
16270
+ get icon() {
16271
+ return '🔧';
16272
+ }
16273
+ /**
16274
+ * Markdown documentation for USE commitment.
16275
+ */
16276
+ get documentation() {
16277
+ return spaceTrim$1.spaceTrim(`
16278
+ # USE
16279
+
16280
+ Enables the agent to use specific tools or capabilities for interacting with external systems.
16281
+
16282
+ ## Supported USE types
16283
+
16284
+ - **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
16285
+ - **USE SEARCH ENGINE** (future) - Enables search engine access
16286
+ - **USE FILE SYSTEM** (future) - Enables file system operations
16287
+ - **USE MCP** (future) - Enables MCP server connections
16288
+
16289
+ ## Key aspects
16290
+
16291
+ - The content following the USE commitment is ignored (similar to NOTE)
16292
+ - Multiple USE commitments can be specified to enable multiple capabilities
16293
+ - The actual tool usage is handled by the agent runtime
16294
+
16295
+ ## Examples
16296
+
16297
+ ### Basic browser usage
16298
+
16299
+ \`\`\`book
16300
+ Research Assistant
16301
+
16302
+ PERSONA You are a helpful research assistant
16303
+ USE BROWSER
16304
+ KNOWLEDGE Can search the web for up-to-date information
16305
+ \`\`\`
16306
+
16307
+ ### Multiple tools
16308
+
16309
+ \`\`\`book
16310
+ Data Analyst
16311
+
16312
+ PERSONA You are a data analyst assistant
16313
+ USE BROWSER
16314
+ USE FILE SYSTEM
16315
+ ACTION Can analyze data from various sources
16316
+ \`\`\`
16317
+ `);
16318
+ }
16319
+ applyToAgentModelRequirements(requirements, content) {
16320
+ // USE commitments don't modify the system message or model requirements directly
16321
+ // They are handled separately in the parsing logic for capability extraction
16322
+ // This method exists for consistency with the CommitmentDefinition interface
16323
+ return requirements;
16324
+ }
16325
+ /**
16326
+ * Extracts the tool type from the USE commitment
16327
+ * This is used by the parsing logic
16328
+ */
16329
+ extractToolType(content) {
16330
+ var _a, _b;
16331
+ const trimmedContent = content.trim();
16332
+ // The tool type is the first word after USE (already stripped)
16333
+ const match = trimmedContent.match(/^(\w+)/);
16334
+ 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;
16335
+ }
16336
+ /**
16337
+ * Checks if this is a known USE type
16338
+ */
16339
+ isKnownUseType(useType) {
16340
+ const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
16341
+ return knownTypes.includes(useType.toUpperCase());
16342
+ }
16343
+ }
16344
+ /**
16345
+ * Note: [💞] Ignore a discrepancy between file name and entity name
16346
+ */
16347
+
16348
+ /**
16349
+ * USE BROWSER commitment definition
16350
+ *
16351
+ * The `USE BROWSER` commitment indicates that the agent should utilize a web browser tool
16352
+ * to access and retrieve up-to-date information from the internet when necessary.
16353
+ *
16354
+ * The content following `USE BROWSER` is ignored (similar to NOTE).
16355
+ *
16356
+ * Example usage in agent source:
16357
+ *
16358
+ * ```book
16359
+ * USE BROWSER
16360
+ * USE BROWSER This will be ignored
16361
+ * ```
16362
+ *
16363
+ * @private [🪔] Maybe export the commitments through some package
16364
+ */
16365
+ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
16366
+ constructor() {
16367
+ super('USE BROWSER', ['BROWSER']);
16368
+ }
16369
+ /**
16370
+ * Short one-line description of USE BROWSER.
16371
+ */
16372
+ get description() {
16373
+ return 'Enable the agent to use a web browser tool for accessing internet information.';
16374
+ }
16375
+ /**
16376
+ * Icon for this commitment.
16377
+ */
16378
+ get icon() {
16379
+ return '🌐';
16380
+ }
16381
+ /**
16382
+ * Markdown documentation for USE BROWSER commitment.
16383
+ */
16384
+ get documentation() {
16385
+ return spaceTrim$1.spaceTrim(`
16386
+ # USE BROWSER
16387
+
16388
+ Enables the agent to use a web browser tool to access and retrieve up-to-date information from the internet.
16389
+
16390
+ ## Key aspects
16391
+
16392
+ - The content following \`USE BROWSER\` is ignored (similar to NOTE)
16393
+ - The actual browser tool usage is handled by the agent runtime
16394
+ - Allows the agent to fetch current information from websites
16395
+ - Useful for research tasks, fact-checking, and accessing dynamic content
16396
+
16397
+ ## Examples
16398
+
16399
+ \`\`\`book
16400
+ Research Assistant
16401
+
16402
+ PERSONA You are a helpful research assistant specialized in finding current information
16403
+ USE BROWSER
16404
+ RULE Always cite your sources when providing information from the web
16405
+ \`\`\`
16406
+
16407
+ \`\`\`book
16408
+ News Analyst
16409
+
16410
+ PERSONA You are a news analyst who stays up-to-date with current events
16411
+ USE BROWSER
16412
+ STYLE Present news in a balanced and objective manner
16413
+ ACTION Can search for and summarize news articles
16414
+ \`\`\`
16415
+
16416
+ \`\`\`book
16417
+ Company Lawyer
16418
+
16419
+ PERSONA You are a company lawyer providing legal advice
16420
+ USE BROWSER
16421
+ KNOWLEDGE Corporate law and legal procedures
16422
+ RULE Always recommend consulting with a licensed attorney for specific legal matters
16423
+ \`\`\`
16424
+ `);
16425
+ }
16426
+ applyToAgentModelRequirements(requirements, content) {
16427
+ // We simply mark that browser capability is enabled in metadata
16428
+ // Get existing metadata
16429
+ const existingMetadata = requirements.metadata || {};
16430
+ // Get existing tools array or create new one
16431
+ const existingTools = existingMetadata.tools || [];
16432
+ // Add 'browser' to tools if not already present
16433
+ const updatedTools = existingTools.includes('browser') ? existingTools : [...existingTools, 'browser'];
16434
+ // Return requirements with updated metadata
16435
+ return {
16436
+ ...requirements,
16437
+ metadata: {
16438
+ ...existingMetadata,
16439
+ tools: updatedTools,
16440
+ useBrowser: true,
16441
+ },
16442
+ };
16443
+ }
16444
+ }
16445
+ /**
16446
+ * Note: [💞] Ignore a discrepancy between file name and entity name
16447
+ */
16448
+
16449
+ /**
16450
+ * USE MCP commitment definition
16451
+ *
16452
+ * The `USE MCP` commitment allows to specify an MCP server URL which the agent will connect to
16453
+ * for retrieving additional instructions and actions.
16454
+ *
16455
+ * The content following `USE MCP` is the URL of the MCP server.
16456
+ *
16457
+ * Example usage in agent source:
16458
+ *
16459
+ * ```book
16460
+ * USE MCP http://mcp-server-url.com
16461
+ * ```
16462
+ *
16463
+ * @private [🪔] Maybe export the commitments through some package
16464
+ */
16465
+ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
16466
+ constructor() {
16467
+ super('USE MCP', ['MCP']);
16468
+ }
16469
+ /**
16470
+ * Short one-line description of USE MCP.
16471
+ */
16472
+ get description() {
16473
+ return 'Connects the agent to an external MCP server for additional capabilities.';
16474
+ }
16475
+ /**
16476
+ * Icon for this commitment.
16477
+ */
16478
+ get icon() {
16479
+ return '🔌';
16480
+ }
16481
+ /**
16482
+ * Markdown documentation for USE MCP commitment.
16483
+ */
16484
+ get documentation() {
16485
+ return spaceTrim$1.spaceTrim(`
16486
+ # USE MCP
16487
+
16488
+ Connects the agent to an external Model Context Protocol (MCP) server.
16489
+
16490
+ ## Key aspects
16491
+
16492
+ - The content following \`USE MCP\` must be a valid URL
16493
+ - Multiple MCP servers can be connected by using multiple \`USE MCP\` commitments
16494
+ - The agent will have access to tools and resources provided by the MCP server
16495
+
16496
+ ## Example
16497
+
16498
+ \`\`\`book
16499
+ Company Lawyer
16500
+
16501
+ PERSONA You are a company lawyer.
16502
+ USE MCP http://legal-db.example.com
16503
+ \`\`\`
16504
+ `);
16505
+ }
16506
+ applyToAgentModelRequirements(requirements, content) {
16507
+ const mcpServerUrl = content.trim();
16508
+ if (!mcpServerUrl) {
16509
+ return requirements;
16510
+ }
16511
+ const existingMcpServers = requirements.mcpServers || [];
16512
+ // Avoid duplicates
16513
+ if (existingMcpServers.includes(mcpServerUrl)) {
16514
+ return requirements;
16515
+ }
16516
+ return {
16517
+ ...requirements,
16518
+ mcpServers: [...existingMcpServers, mcpServerUrl],
16519
+ };
16520
+ }
16521
+ }
16522
+ /**
16523
+ * Note: [💞] Ignore a discrepancy between file name and entity name
16524
+ */
16525
+
16526
+ /**
16527
+ * USE SEARCH ENGINE commitment definition
16528
+ *
16529
+ * The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
16530
+ * to access and retrieve up-to-date information from the internet when necessary.
16531
+ *
16532
+ * The content following `USE SEARCH ENGINE` is ignored (similar to NOTE).
16533
+ *
16534
+ * Example usage in agent source:
16535
+ *
16536
+ * ```book
16537
+ * USE SEARCH ENGINE
16538
+ * USE SEARCH ENGINE This will be ignored
16539
+ * ```
16540
+ *
16541
+ * @private [🪔] Maybe export the commitments through some package
16542
+ */
16543
+ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
16544
+ constructor() {
16545
+ super('USE SEARCH ENGINE', ['SEARCH ENGINE', 'SEARCH']);
16546
+ }
16547
+ /**
16548
+ * Short one-line description of USE SEARCH ENGINE.
16549
+ */
16550
+ get description() {
16551
+ return 'Enable the agent to use a search engine tool for accessing internet information.';
16552
+ }
16553
+ /**
16554
+ * Icon for this commitment.
16555
+ */
16556
+ get icon() {
16557
+ return '🔍';
16558
+ }
16559
+ /**
16560
+ * Markdown documentation for USE SEARCH ENGINE commitment.
16561
+ */
16562
+ get documentation() {
16563
+ return spaceTrim$1.spaceTrim(`
16564
+ # USE SEARCH ENGINE
16565
+
16566
+ Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
16567
+
16568
+ ## Key aspects
16569
+
16570
+ - The content following \`USE SEARCH ENGINE\` is ignored (similar to NOTE)
16571
+ - The actual search engine tool usage is handled by the agent runtime
16572
+ - Allows the agent to search for current information from the web
16573
+ - Useful for research tasks, finding facts, and accessing dynamic content
16574
+
16575
+ ## Examples
16576
+
16577
+ \`\`\`book
16578
+ Research Assistant
16579
+
16580
+ PERSONA You are a helpful research assistant specialized in finding current information
16581
+ USE SEARCH ENGINE
16582
+ RULE Always cite your sources when providing information from the web
16583
+ \`\`\`
16584
+
16585
+ \`\`\`book
16586
+ Fact Checker
16587
+
16588
+ PERSONA You are a fact checker
16589
+ USE SEARCH ENGINE
16590
+ ACTION Search for claims and verify them against reliable sources
16591
+ \`\`\`
16592
+ `);
16593
+ }
16594
+ applyToAgentModelRequirements(requirements, content) {
16595
+ // We simply mark that search engine capability is enabled in metadata
16596
+ // Get existing metadata
16597
+ const existingMetadata = requirements.metadata || {};
16598
+ // Get existing tools array or create new one
16599
+ const existingTools = existingMetadata.tools || [];
16600
+ // Add 'search-engine' to tools if not already present
16601
+ const updatedTools = existingTools.includes('search-engine') ? existingTools : [...existingTools, 'search-engine'];
16602
+ // Return requirements with updated metadata
16603
+ return {
16604
+ ...requirements,
16605
+ metadata: {
16606
+ ...existingMetadata,
16607
+ tools: updatedTools,
16608
+ useSearchEngine: true,
16609
+ },
16610
+ };
16611
+ }
16612
+ }
16613
+ /**
16614
+ * Note: [💞] Ignore a discrepancy between file name and entity name
16615
+ */
16616
+
15645
16617
  /**
15646
16618
  * Placeholder commitment definition for commitments that are not yet implemented
15647
16619
  *
@@ -15670,7 +16642,7 @@
15670
16642
  * Markdown documentation available at runtime.
15671
16643
  */
15672
16644
  get documentation() {
15673
- return spaceTrim.spaceTrim(`
16645
+ return spaceTrim$1.spaceTrim(`
15674
16646
  # ${this.type}
15675
16647
 
15676
16648
  This commitment is not yet fully implemented.
@@ -15728,16 +16700,22 @@
15728
16700
  new StyleCommitmentDefinition('STYLES'),
15729
16701
  new RuleCommitmentDefinition('RULE'),
15730
16702
  new RuleCommitmentDefinition('RULES'),
16703
+ new LanguageCommitmentDefinition('LANGUAGE'),
16704
+ new LanguageCommitmentDefinition('LANGUAGES'),
15731
16705
  new SampleCommitmentDefinition('SAMPLE'),
15732
16706
  new SampleCommitmentDefinition('EXAMPLE'),
15733
16707
  new FormatCommitmentDefinition('FORMAT'),
15734
16708
  new FormatCommitmentDefinition('FORMATS'),
16709
+ new FromCommitmentDefinition('FROM'),
15735
16710
  new ModelCommitmentDefinition('MODEL'),
15736
16711
  new ModelCommitmentDefinition('MODELS'),
15737
16712
  new ActionCommitmentDefinition('ACTION'),
15738
16713
  new ActionCommitmentDefinition('ACTIONS'),
16714
+ new ComponentCommitmentDefinition(),
15739
16715
  new MetaImageCommitmentDefinition(),
15740
16716
  new MetaColorCommitmentDefinition(),
16717
+ new MetaFontCommitmentDefinition(),
16718
+ new MetaLinkCommitmentDefinition(),
15741
16719
  new MetaCommitmentDefinition(),
15742
16720
  new NoteCommitmentDefinition('NOTE'),
15743
16721
  new NoteCommitmentDefinition('NOTES'),
@@ -15756,6 +16734,12 @@
15756
16734
  new DeleteCommitmentDefinition('CANCEL'),
15757
16735
  new DeleteCommitmentDefinition('DISCARD'),
15758
16736
  new DeleteCommitmentDefinition('REMOVE'),
16737
+ new OpenCommitmentDefinition(),
16738
+ new ClosedCommitmentDefinition(),
16739
+ new UseBrowserCommitmentDefinition(),
16740
+ new UseSearchEngineCommitmentDefinition(),
16741
+ new UseMcpCommitmentDefinition(),
16742
+ new UseCommitmentDefinition(),
15759
16743
  // Not yet implemented commitments (using placeholder)
15760
16744
  new NotYetImplementedCommitmentDefinition('EXPECT'),
15761
16745
  new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
@@ -15813,6 +16797,11 @@
15813
16797
  * TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
15814
16798
  */
15815
16799
 
16800
+ /**
16801
+ * Regex pattern to match horizontal lines (markdown thematic breaks)
16802
+ * Matches 3 or more hyphens, underscores, or asterisks (with optional spaces between)
16803
+ */
16804
+ const HORIZONTAL_LINE_PATTERN = /^[\s]*[-_*][\s]*[-_*][\s]*[-_*][\s]*[-_*]*[\s]*$/;
15816
16805
  /**
15817
16806
  * Parses agent source using the new commitment system with multiline support
15818
16807
  * This function replaces the hardcoded commitment parsing in the original parseAgentSource
@@ -15855,7 +16844,7 @@
15855
16844
  const fullContent = currentCommitment.contentLines.join('\n');
15856
16845
  commitments.push({
15857
16846
  type: currentCommitment.type,
15858
- content: spaceTrim.spaceTrim(fullContent),
16847
+ content: spaceTrim$1.spaceTrim(fullContent),
15859
16848
  originalLine: currentCommitment.originalStartLine,
15860
16849
  lineNumber: currentCommitment.startLineNumber,
15861
16850
  });
@@ -15875,6 +16864,24 @@
15875
16864
  break;
15876
16865
  }
15877
16866
  }
16867
+ // Check if this is a horizontal line (ends any current commitment)
16868
+ const isHorizontalLine = HORIZONTAL_LINE_PATTERN.test(line);
16869
+ if (isHorizontalLine) {
16870
+ // Save the current commitment if it exists
16871
+ if (currentCommitment) {
16872
+ const fullContent = currentCommitment.contentLines.join('\n');
16873
+ commitments.push({
16874
+ type: currentCommitment.type,
16875
+ content: spaceTrim$1.spaceTrim(fullContent),
16876
+ originalLine: currentCommitment.originalStartLine,
16877
+ lineNumber: currentCommitment.startLineNumber,
16878
+ });
16879
+ currentCommitment = null;
16880
+ }
16881
+ // Add horizontal line to non-commitment lines
16882
+ nonCommitmentLines.push(line);
16883
+ continue;
16884
+ }
15878
16885
  if (!foundNewCommitment) {
15879
16886
  if (currentCommitment) {
15880
16887
  // This line belongs to the current commitment
@@ -15891,7 +16898,7 @@
15891
16898
  const fullContent = currentCommitment.contentLines.join('\n');
15892
16899
  commitments.push({
15893
16900
  type: currentCommitment.type,
15894
- content: spaceTrim.spaceTrim(fullContent),
16901
+ content: spaceTrim$1.spaceTrim(fullContent),
15895
16902
  originalLine: currentCommitment.originalStartLine,
15896
16903
  lineNumber: currentCommitment.startLineNumber,
15897
16904
  });
@@ -16390,7 +17397,7 @@
16390
17397
  let trimmedText = text;
16391
17398
  // Remove leading and trailing spaces and newlines
16392
17399
  if (isTrimmed) {
16393
- trimmedText = spaceTrim.spaceTrim(trimmedText);
17400
+ trimmedText = spaceTrim$1.spaceTrim(trimmedText);
16394
17401
  }
16395
17402
  let processedText = trimmedText;
16396
17403
  if (isIntroduceSentenceRemoved) {
@@ -16399,7 +17406,7 @@
16399
17406
  // Remove the introduce sentence and quotes by replacing it with an empty string
16400
17407
  processedText = processedText.replace(introduceSentenceRegex, '');
16401
17408
  }
16402
- processedText = spaceTrim.spaceTrim(processedText);
17409
+ processedText = spaceTrim$1.spaceTrim(processedText);
16403
17410
  }
16404
17411
  if (processedText.length < 3) {
16405
17412
  return trimmedText;
@@ -16570,7 +17577,9 @@
16570
17577
  const links = [];
16571
17578
  for (const commitment of parseResult.commitments) {
16572
17579
  if (commitment.type === 'META LINK') {
16573
- links.push(spaceTrim__default["default"](commitment.content));
17580
+ const linkValue = spaceTrim__default["default"](commitment.content);
17581
+ links.push(linkValue);
17582
+ meta.link = linkValue;
16574
17583
  continue;
16575
17584
  }
16576
17585
  if (commitment.type === 'META IMAGE') {
@@ -16581,6 +17590,10 @@
16581
17590
  meta.color = spaceTrim__default["default"](commitment.content);
16582
17591
  continue;
16583
17592
  }
17593
+ if (commitment.type === 'META FONT') {
17594
+ meta.font = spaceTrim__default["default"](commitment.content);
17595
+ continue;
17596
+ }
16584
17597
  if (commitment.type !== 'META') {
16585
17598
  continue;
16586
17599
  }
@@ -18121,13 +19134,13 @@
18121
19134
  * @public exported from `@promptbook/markdown-utils`
18122
19135
  */
18123
19136
  function trimCodeBlock(value) {
18124
- value = spaceTrim.spaceTrim(value);
19137
+ value = spaceTrim$1.spaceTrim(value);
18125
19138
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
18126
19139
  return value;
18127
19140
  }
18128
19141
  value = value.replace(/^```[a-z]*/i, '');
18129
19142
  value = value.replace(/```$/i, '');
18130
- value = spaceTrim.spaceTrim(value);
19143
+ value = spaceTrim$1.spaceTrim(value);
18131
19144
  return value;
18132
19145
  }
18133
19146
 
@@ -18140,9 +19153,9 @@
18140
19153
  * @public exported from `@promptbook/markdown-utils`
18141
19154
  */
18142
19155
  function trimEndOfCodeBlock(value) {
18143
- value = spaceTrim.spaceTrim(value);
19156
+ value = spaceTrim$1.spaceTrim(value);
18144
19157
  value = value.replace(/```$/g, '');
18145
- value = spaceTrim.spaceTrim(value);
19158
+ value = spaceTrim$1.spaceTrim(value);
18146
19159
  return value;
18147
19160
  }
18148
19161
 
@@ -20577,7 +21590,7 @@
20577
21590
  function getParserForCommand(command) {
20578
21591
  const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
20579
21592
  if (commandParser === undefined) {
20580
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
21593
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
20581
21594
  Command ${command.type} parser is not found
20582
21595
 
20583
21596
  ${block(JSON.stringify(command, null, 4)
@@ -20653,7 +21666,7 @@
20653
21666
  .map(removeMarkdownFormatting)
20654
21667
  .map((item) => item.trim());
20655
21668
  if (items.length === 0 || items[0] === '') {
20656
- throw new ParseError(spaceTrim.spaceTrim((block) => `
21669
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
20657
21670
  Malformed command:
20658
21671
  - ${raw}
20659
21672
 
@@ -20689,7 +21702,7 @@
20689
21702
  return command;
20690
21703
  }
20691
21704
  }
20692
- throw new ParseError(spaceTrim.spaceTrim((block) => `
21705
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
20693
21706
  Malformed or unknown command:
20694
21707
  - ${raw}
20695
21708
 
@@ -20740,7 +21753,7 @@
20740
21753
  if (!(error instanceof ParseError)) {
20741
21754
  throw error;
20742
21755
  }
20743
- throw new ParseError(spaceTrim.spaceTrim((block) => `
21756
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
20744
21757
  Invalid ${commandName} command:
20745
21758
 
20746
21759
  Your command:
@@ -21056,7 +22069,7 @@
21056
22069
  * @public exported from `@promptbook/markdown-utils`
21057
22070
  */
21058
22071
  function removeMarkdownComments(content) {
21059
- return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
22072
+ return spaceTrim$1.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
21060
22073
  }
21061
22074
 
21062
22075
  /**
@@ -21341,7 +22354,7 @@
21341
22354
  if (pipelineString.startsWith('#!')) {
21342
22355
  const [shebangLine, ...restLines] = pipelineString.split('\n');
21343
22356
  if (!(shebangLine || '').includes('ptbk')) {
21344
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22357
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21345
22358
  It seems that you try to parse a book file which has non-standard shebang line for book files:
21346
22359
  Shebang line must contain 'ptbk'
21347
22360
 
@@ -21357,7 +22370,7 @@
21357
22370
  pipelineString = validatePipelineString(restLines.join('\n'));
21358
22371
  }
21359
22372
  pipelineString = removeMarkdownComments(pipelineString);
21360
- pipelineString = spaceTrim.spaceTrim(pipelineString);
22373
+ pipelineString = spaceTrim$1.spaceTrim(pipelineString);
21361
22374
  // <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
21362
22375
  pipelineString = deflatePipeline(pipelineString);
21363
22376
  // ==============
@@ -21369,7 +22382,7 @@
21369
22382
  // ==============
21370
22383
  // Note: 1️⃣◽4️⃣ Check markdown structure
21371
22384
  if (pipelineHead === undefined) {
21372
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
22385
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
21373
22386
  Pipeline head is not defined
21374
22387
 
21375
22388
  ${block(getPipelineIdentification())}
@@ -21378,7 +22391,7 @@
21378
22391
  `));
21379
22392
  }
21380
22393
  if (pipelineHead.level !== 1) {
21381
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
22394
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
21382
22395
  Pipeline head is not h1
21383
22396
 
21384
22397
  ${block(getPipelineIdentification())}
@@ -21387,7 +22400,7 @@
21387
22400
  `));
21388
22401
  }
21389
22402
  if (!pipelineSections.every((section) => section.level === 2)) {
21390
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
22403
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
21391
22404
  Not every pipeline section is h2
21392
22405
 
21393
22406
  ${block(getPipelineIdentification())}
@@ -21400,7 +22413,7 @@
21400
22413
  const defineParam = (parameterCommand) => {
21401
22414
  const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
21402
22415
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
21403
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22416
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21404
22417
  Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
21405
22418
 
21406
22419
  ${block(getPipelineIdentification())}
@@ -21411,7 +22424,7 @@
21411
22424
  existingParameter.description &&
21412
22425
  existingParameter.description !== parameterDescription &&
21413
22426
  parameterDescription) {
21414
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22427
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21415
22428
  Parameter \`{${parameterName}}\` is defined multiple times with different description:
21416
22429
 
21417
22430
  ${block(getPipelineIdentification())}
@@ -21449,7 +22462,7 @@
21449
22462
  description = description.split(/^>.*$/gm).join('');
21450
22463
  //Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
21451
22464
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
21452
- description = spaceTrim.spaceTrim(description);
22465
+ description = spaceTrim$1.spaceTrim(description);
21453
22466
  if (description === '') {
21454
22467
  description = undefined;
21455
22468
  }
@@ -21460,7 +22473,7 @@
21460
22473
  const command = parseCommand(listItem, 'PIPELINE_HEAD');
21461
22474
  const commandParser = getParserForCommand(command);
21462
22475
  if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
21463
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22476
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21464
22477
  Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
21465
22478
 
21466
22479
  ${block(getPipelineIdentification())}
@@ -21474,7 +22487,7 @@
21474
22487
  if (!(error instanceof ParseError)) {
21475
22488
  throw error;
21476
22489
  }
21477
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22490
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21478
22491
  Command ${command.type} failed to apply to the pipeline
21479
22492
 
21480
22493
  The error:
@@ -21527,7 +22540,7 @@
21527
22540
  description = description.split(/^>.*$/gm).join('');
21528
22541
  //Note: Remove lists and return statement - TODO: [🎾]
21529
22542
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
21530
- description = spaceTrim.spaceTrim(description);
22543
+ description = spaceTrim$1.spaceTrim(description);
21531
22544
  if (description === '') {
21532
22545
  description = undefined;
21533
22546
  }
@@ -21561,7 +22574,7 @@
21561
22574
  for (const { listItem, command } of commands) {
21562
22575
  const commandParser = getParserForCommand(command);
21563
22576
  if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
21564
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22577
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21565
22578
  Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
21566
22579
 
21567
22580
  ${block(getPipelineIdentification())}
@@ -21576,7 +22589,7 @@
21576
22589
  if (!(error instanceof ParseError)) {
21577
22590
  throw error;
21578
22591
  }
21579
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22592
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21580
22593
  Command \`${command.type}\` failed to apply to the task
21581
22594
 
21582
22595
  The error:
@@ -21607,14 +22620,14 @@
21607
22620
  // TODO: [🍧] Should be done in SECTION command
21608
22621
  if ($taskJson.taskType === 'SCRIPT_TASK') {
21609
22622
  if (!language) {
21610
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22623
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21611
22624
  You must specify the language of the script in the \`SCRIPT\` task
21612
22625
 
21613
22626
  ${block(getPipelineIdentification())}
21614
22627
  `));
21615
22628
  }
21616
22629
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
21617
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22630
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21618
22631
  Script language ${language} is not supported.
21619
22632
 
21620
22633
  Supported languages are: