@promptbook/wizard 0.103.0-55 → 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-55';
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.
@@ -13661,7 +13703,7 @@
13661
13703
  * Markdown documentation for CLOSED commitment.
13662
13704
  */
13663
13705
  get documentation() {
13664
- return spaceTrim.spaceTrim(`
13706
+ return spaceTrim$1.spaceTrim(`
13665
13707
  # CLOSED
13666
13708
 
13667
13709
  Specifies that the agent **cannot** be modified by conversation with it.
@@ -13720,7 +13762,7 @@
13720
13762
  * Markdown documentation for COMPONENT commitment.
13721
13763
  */
13722
13764
  get documentation() {
13723
- return spaceTrim.spaceTrim(`
13765
+ return spaceTrim$1.spaceTrim(`
13724
13766
  # COMPONENT
13725
13767
 
13726
13768
  Defines a UI component that the agent can render in the chat.
@@ -13792,7 +13834,7 @@
13792
13834
  * Markdown documentation for DELETE commitment.
13793
13835
  */
13794
13836
  get documentation() {
13795
- return spaceTrim.spaceTrim(`
13837
+ return spaceTrim$1.spaceTrim(`
13796
13838
  # DELETE (CANCEL, DISCARD, REMOVE)
13797
13839
 
13798
13840
  A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
@@ -13914,7 +13956,7 @@
13914
13956
  * Markdown documentation for FORMAT commitment.
13915
13957
  */
13916
13958
  get documentation() {
13917
- return spaceTrim.spaceTrim(`
13959
+ return spaceTrim$1.spaceTrim(`
13918
13960
  # ${this.type}
13919
13961
 
13920
13962
  Defines the specific output structure and formatting for responses (data formats, templates, structure).
@@ -13992,7 +14034,7 @@
13992
14034
  * Markdown documentation for FROM commitment.
13993
14035
  */
13994
14036
  get documentation() {
13995
- return spaceTrim.spaceTrim(`
14037
+ return spaceTrim$1.spaceTrim(`
13996
14038
  # ${this.type}
13997
14039
 
13998
14040
  Inherits agent source from another agent.
@@ -14068,7 +14110,7 @@
14068
14110
  * Markdown documentation for GOAL commitment.
14069
14111
  */
14070
14112
  get documentation() {
14071
- return spaceTrim.spaceTrim(`
14113
+ return spaceTrim$1.spaceTrim(`
14072
14114
  # ${this.type}
14073
14115
 
14074
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.
@@ -14132,227 +14174,6 @@
14132
14174
  * Note: [💞] Ignore a discrepancy between file name and entity name
14133
14175
  */
14134
14176
 
14135
- /**
14136
- * Placeholder commitment definition for commitments that are not yet implemented
14137
- *
14138
- * This commitment simply adds its content 1:1 into the system message,
14139
- * preserving the original behavior until proper implementation is added.
14140
- *
14141
- * @public exported from `@promptbook/core`
14142
- */
14143
- class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
14144
- constructor(type) {
14145
- super(type);
14146
- }
14147
- /**
14148
- * Short one-line description of a placeholder commitment.
14149
- */
14150
- get description() {
14151
- return 'Placeholder commitment that appends content verbatim to the system message.';
14152
- }
14153
- /**
14154
- * Icon for this commitment.
14155
- */
14156
- get icon() {
14157
- return '🚧';
14158
- }
14159
- /**
14160
- * Markdown documentation available at runtime.
14161
- */
14162
- get documentation() {
14163
- return spaceTrim.spaceTrim(`
14164
- # ${this.type}
14165
-
14166
- This commitment is not yet fully implemented.
14167
-
14168
- ## Key aspects
14169
-
14170
- - Content is appended directly to the system message.
14171
- - No special processing or validation is performed.
14172
- - Behavior preserved until proper implementation is added.
14173
-
14174
- ## Status
14175
-
14176
- - **Status:** Placeholder implementation
14177
- - **Effect:** Appends content prefixed by commitment type
14178
- - **Future:** Will be replaced with specialized logic
14179
-
14180
- ## Examples
14181
-
14182
- \`\`\`book
14183
- Example Agent
14184
-
14185
- PERSONA You are a helpful assistant
14186
- ${this.type} Your content here
14187
- RULE Always be helpful
14188
- \`\`\`
14189
- `);
14190
- }
14191
- applyToAgentModelRequirements(requirements, content) {
14192
- const trimmedContent = content.trim();
14193
- if (!trimmedContent) {
14194
- return requirements;
14195
- }
14196
- // Add the commitment content 1:1 to the system message
14197
- const commitmentLine = `${this.type} ${trimmedContent}`;
14198
- return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
14199
- }
14200
- }
14201
-
14202
- /**
14203
- * Registry of all available commitment definitions
14204
- * This array contains instances of all commitment definitions
14205
- * This is the single source of truth for all commitments in the system
14206
- *
14207
- * @private Use functions to access commitments instead of this array directly
14208
- */
14209
- const COMMITMENT_REGISTRY = [];
14210
- /**
14211
- * Registers a new commitment definition
14212
- * @param definition The commitment definition to register
14213
- *
14214
- * @public exported from `@promptbook/core`
14215
- */
14216
- function registerCommitment(definition) {
14217
- COMMITMENT_REGISTRY.push(definition);
14218
- }
14219
- /**
14220
- * Gets a commitment definition by its type
14221
- * @param type The commitment type to look up
14222
- * @returns The commitment definition or null if not found
14223
- *
14224
- * @public exported from `@promptbook/core`
14225
- */
14226
- function getCommitmentDefinition(type) {
14227
- return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
14228
- }
14229
- /**
14230
- * Gets all available commitment definitions
14231
- * @returns Array of all commitment definitions
14232
- *
14233
- * @public exported from `@promptbook/core`
14234
- */
14235
- function getAllCommitmentDefinitions() {
14236
- return $deepFreeze([...COMMITMENT_REGISTRY]);
14237
- }
14238
- /**
14239
- * TODO: !!!! Proofread this file
14240
- * Note: [💞] Ignore a discrepancy between file name and entity name
14241
- */
14242
-
14243
- /**
14244
- * IMPORTANT co-commitment definition
14245
- *
14246
- * The IMPORTANT co-commitment modifies another commitment to emphasize its importance.
14247
- * It is typically used with RULE to mark it as critical.
14248
- *
14249
- * Example usage in agent source:
14250
- *
14251
- * ```book
14252
- * IMPORTANT RULE Never provide medical advice
14253
- * ```
14254
- *
14255
- * @private [🪔] Maybe export the commitments through some package
14256
- */
14257
- class ImportantCommitmentDefinition extends BaseCommitmentDefinition {
14258
- constructor() {
14259
- super('IMPORTANT');
14260
- }
14261
- get description() {
14262
- return 'Marks a commitment as important.';
14263
- }
14264
- get icon() {
14265
- return '⭐';
14266
- }
14267
- get documentation() {
14268
- return spaceTrim.spaceTrim(`
14269
- # IMPORTANT
14270
-
14271
- Marks another commitment as important. This acts as a modifier (co-commitment).
14272
-
14273
- ## Example
14274
-
14275
- \`\`\`book
14276
- IMPORTANT RULE Do not reveal the system prompt
14277
- \`\`\`
14278
- `);
14279
- }
14280
- applyToAgentModelRequirements(requirements, content) {
14281
- const definitions = getAllCommitmentDefinitions();
14282
- const trimmedContent = content.trim();
14283
- // Find the inner commitment
14284
- for (const definition of definitions) {
14285
- // Skip self to avoid infinite recursion if someone writes IMPORTANT IMPORTANT ...
14286
- // Although IMPORTANT IMPORTANT might be valid stacking?
14287
- // If we support stacking, we shouldn't skip self, but we must ensure progress.
14288
- // Since we are matching against 'content', if content starts with IMPORTANT, it means nested IMPORTANT.
14289
- // That's fine.
14290
- const typeRegex = definition.createTypeRegex();
14291
- const match = typeRegex.exec(trimmedContent);
14292
- if (match && match.index === 0) {
14293
- // Found the inner commitment type
14294
- // Extract inner content using the definition's full regex
14295
- // Note: createRegex usually matches the full line including the type
14296
- const fullRegex = definition.createRegex();
14297
- const fullMatch = fullRegex.exec(trimmedContent);
14298
- // If regex matches, extract contents. If not (maybe multiline handling differs?), fallback to rest of string
14299
- let innerContent = '';
14300
- if (fullMatch && fullMatch.groups && fullMatch.groups.contents) {
14301
- innerContent = fullMatch.groups.contents;
14302
- }
14303
- else {
14304
- // Fallback: remove the type from the start
14305
- // This might be risky if regex is complex, but usually type regex matches the keyword
14306
- const typeMatchString = match[0];
14307
- innerContent = trimmedContent.substring(typeMatchString.length).trim();
14308
- }
14309
- // Apply the inner commitment
14310
- const modifiedRequirements = definition.applyToAgentModelRequirements(requirements, innerContent);
14311
- // Now modify the result to reflect "IMPORTANT" status
14312
- // We compare the system message
14313
- if (modifiedRequirements.systemMessage !== requirements.systemMessage) {
14314
- const originalMsg = requirements.systemMessage;
14315
- const newMsg = modifiedRequirements.systemMessage;
14316
- // If the inner commitment appended something
14317
- if (newMsg.startsWith(originalMsg)) {
14318
- const appended = newMsg.substring(originalMsg.length);
14319
- // Add "IMPORTANT: " prefix to the appended part
14320
- // We need to be careful about newlines
14321
- // Heuristic: If appended starts with separator (newlines), preserve them
14322
- const matchSep = appended.match(/^(\s*)(.*)/s);
14323
- if (matchSep) {
14324
- const [, separator, text] = matchSep;
14325
- // Check if it already has "Rule:" prefix or similar
14326
- // We want "IMPORTANT Rule: ..."
14327
- // Let's just prepend IMPORTANT to the text
14328
- // But formatted nicely
14329
- // If it's a rule: "\n\nRule: content"
14330
- // We want "\n\nIMPORTANT Rule: content"
14331
- const importantText = `IMPORTANT ${text}`;
14332
- return {
14333
- ...modifiedRequirements,
14334
- systemMessage: originalMsg + separator + importantText
14335
- };
14336
- }
14337
- }
14338
- }
14339
- // If no system message change or we couldn't detect how to modify it, just return the modified requirements
14340
- // Maybe the inner commitment modified metadata?
14341
- return modifiedRequirements;
14342
- }
14343
- }
14344
- // If no inner commitment found, treat as a standalone note?
14345
- // Or warn?
14346
- // For now, treat as no-op or maybe just append as text?
14347
- // Let's treat as Note if fallback? No, explicit is better.
14348
- console.warn(`IMPORTANT commitment used without a valid inner commitment: ${content}`);
14349
- return requirements;
14350
- }
14351
- }
14352
- /**
14353
- * Note: [💞] Ignore a discrepancy between file name and entity name
14354
- */
14355
-
14356
14177
  /**
14357
14178
  * KNOWLEDGE commitment definition
14358
14179
  *
@@ -14391,7 +14212,7 @@
14391
14212
  * Markdown documentation for KNOWLEDGE commitment.
14392
14213
  */
14393
14214
  get documentation() {
14394
- return spaceTrim.spaceTrim(`
14215
+ return spaceTrim$1.spaceTrim(`
14395
14216
  # ${this.type}
14396
14217
 
14397
14218
  Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
@@ -14495,7 +14316,7 @@
14495
14316
  * Markdown documentation for LANGUAGE/LANGUAGES commitment.
14496
14317
  */
14497
14318
  get documentation() {
14498
- return spaceTrim.spaceTrim(`
14319
+ return spaceTrim$1.spaceTrim(`
14499
14320
  # ${this.type}
14500
14321
 
14501
14322
  Specifies the language(s) the agent should use in its responses.
@@ -14569,7 +14390,7 @@
14569
14390
  * Markdown documentation for MEMORY commitment.
14570
14391
  */
14571
14392
  get documentation() {
14572
- return spaceTrim.spaceTrim(`
14393
+ return spaceTrim$1.spaceTrim(`
14573
14394
  # ${this.type}
14574
14395
 
14575
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.
@@ -14673,7 +14494,7 @@
14673
14494
  * Markdown documentation for AGENT MESSAGE commitment.
14674
14495
  */
14675
14496
  get documentation() {
14676
- return spaceTrim.spaceTrim(`
14497
+ return spaceTrim$1.spaceTrim(`
14677
14498
  # ${this.type}
14678
14499
 
14679
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.
@@ -14750,7 +14571,7 @@
14750
14571
  * Markdown documentation for INITIAL MESSAGE commitment.
14751
14572
  */
14752
14573
  get documentation() {
14753
- return spaceTrim.spaceTrim(`
14574
+ return spaceTrim$1.spaceTrim(`
14754
14575
  # ${this.type}
14755
14576
 
14756
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).
@@ -14814,7 +14635,7 @@
14814
14635
  * Markdown documentation for MESSAGE commitment.
14815
14636
  */
14816
14637
  get documentation() {
14817
- return spaceTrim.spaceTrim(`
14638
+ return spaceTrim$1.spaceTrim(`
14818
14639
  # ${this.type}
14819
14640
 
14820
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.
@@ -14926,7 +14747,7 @@
14926
14747
  * Markdown documentation for USER MESSAGE commitment.
14927
14748
  */
14928
14749
  get documentation() {
14929
- return spaceTrim.spaceTrim(`
14750
+ return spaceTrim$1.spaceTrim(`
14930
14751
  # ${this.type}
14931
14752
 
14932
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.
@@ -15005,7 +14826,7 @@
15005
14826
  * Markdown documentation for META commitment.
15006
14827
  */
15007
14828
  get documentation() {
15008
- return spaceTrim.spaceTrim(`
14829
+ return spaceTrim$1.spaceTrim(`
15009
14830
  # META
15010
14831
 
15011
14832
  Sets meta-information about the agent that is used for display and attribution purposes.
@@ -15116,6 +14937,12 @@
15116
14937
  * META COLOR #00ff00
15117
14938
  * ```
15118
14939
  *
14940
+ * You can also specify multiple colors separated by comma:
14941
+ *
14942
+ * ```book
14943
+ * META COLOR #ff0000, #00ff00, #0000ff
14944
+ * ```
14945
+ *
15119
14946
  * @private [🪔] Maybe export the commitments through some package
15120
14947
  */
15121
14948
  class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
@@ -15126,7 +14953,7 @@
15126
14953
  * Short one-line description of META COLOR.
15127
14954
  */
15128
14955
  get description() {
15129
- return "Set the agent's accent color.";
14956
+ return "Set the agent's accent color or gradient.";
15130
14957
  }
15131
14958
  /**
15132
14959
  * Icon for this commitment.
@@ -15138,10 +14965,10 @@
15138
14965
  * Markdown documentation for META COLOR commitment.
15139
14966
  */
15140
14967
  get documentation() {
15141
- return spaceTrim.spaceTrim(`
14968
+ return spaceTrim$1.spaceTrim(`
15142
14969
  # META COLOR
15143
14970
 
15144
- Sets the agent's accent color.
14971
+ Sets the agent's accent color or gradient.
15145
14972
 
15146
14973
  ## Key aspects
15147
14974
 
@@ -15149,6 +14976,7 @@
15149
14976
  - Only one \`META COLOR\` should be used per agent.
15150
14977
  - If multiple are specified, the last one takes precedence.
15151
14978
  - Used for visual representation in user interfaces.
14979
+ - Can specify multiple colors separated by comma to create a gradient.
15152
14980
 
15153
14981
  ## Examples
15154
14982
 
@@ -15165,6 +14993,13 @@
15165
14993
  META COLOR #e74c3c
15166
14994
  PERSONA You are a creative and inspiring assistant
15167
14995
  \`\`\`
14996
+
14997
+ \`\`\`book
14998
+ Gradient Agent
14999
+
15000
+ META COLOR #ff0000, #00ff00, #0000ff
15001
+ PERSONA You are a colorful agent
15002
+ \`\`\`
15168
15003
  `);
15169
15004
  }
15170
15005
  applyToAgentModelRequirements(requirements, content) {
@@ -15186,6 +15021,91 @@
15186
15021
  * Note: [💞] Ignore a discrepancy between file name and entity name
15187
15022
  */
15188
15023
 
15024
+ /**
15025
+ * META FONT commitment definition
15026
+ *
15027
+ * The META FONT commitment sets the agent's font.
15028
+ * This commitment is special because it doesn't affect the system message,
15029
+ * but is handled separately in the parsing logic.
15030
+ *
15031
+ * Example usage in agent source:
15032
+ *
15033
+ * ```book
15034
+ * META FONT Poppins, Arial, sans-serif
15035
+ * META FONT Roboto
15036
+ * ```
15037
+ *
15038
+ * @private [🪔] Maybe export the commitments through some package
15039
+ */
15040
+ class MetaFontCommitmentDefinition extends BaseCommitmentDefinition {
15041
+ constructor() {
15042
+ super('META FONT', ['FONT']);
15043
+ }
15044
+ /**
15045
+ * Short one-line description of META FONT.
15046
+ */
15047
+ get description() {
15048
+ return "Set the agent's font.";
15049
+ }
15050
+ /**
15051
+ * Icon for this commitment.
15052
+ */
15053
+ get icon() {
15054
+ return '🔤';
15055
+ }
15056
+ /**
15057
+ * Markdown documentation for META FONT commitment.
15058
+ */
15059
+ get documentation() {
15060
+ return spaceTrim$1.spaceTrim(`
15061
+ # META FONT
15062
+
15063
+ Sets the agent's font.
15064
+
15065
+ ## Key aspects
15066
+
15067
+ - Does not modify the agent's behavior or responses.
15068
+ - Only one \`META FONT\` should be used per agent.
15069
+ - If multiple are specified, the last one takes precedence.
15070
+ - Used for visual representation in user interfaces.
15071
+ - Supports Google Fonts.
15072
+
15073
+ ## Examples
15074
+
15075
+ \`\`\`book
15076
+ Modern Assistant
15077
+
15078
+ META FONT Poppins, Arial, sans-serif
15079
+ PERSONA You are a modern assistant
15080
+ \`\`\`
15081
+
15082
+ \`\`\`book
15083
+ Classic Helper
15084
+
15085
+ META FONT Times New Roman
15086
+ PERSONA You are a classic helper
15087
+ \`\`\`
15088
+ `);
15089
+ }
15090
+ applyToAgentModelRequirements(requirements, content) {
15091
+ // META FONT doesn't modify the system message or model requirements
15092
+ // It's handled separately in the parsing logic
15093
+ // This method exists for consistency with the CommitmentDefinition interface
15094
+ return requirements;
15095
+ }
15096
+ /**
15097
+ * Extracts the font from the content
15098
+ * This is used by the parsing logic
15099
+ */
15100
+ extractProfileFont(content) {
15101
+ const trimmedContent = content.trim();
15102
+ return trimmedContent || null;
15103
+ }
15104
+ }
15105
+ /**
15106
+ * Note: [💞] Ignore a discrepancy between file name and entity name
15107
+ */
15108
+
15189
15109
  /**
15190
15110
  * META IMAGE commitment definition
15191
15111
  *
@@ -15222,7 +15142,7 @@
15222
15142
  * Markdown documentation for META IMAGE commitment.
15223
15143
  */
15224
15144
  get documentation() {
15225
- return spaceTrim.spaceTrim(`
15145
+ return spaceTrim$1.spaceTrim(`
15226
15146
  # META IMAGE
15227
15147
 
15228
15148
  Sets the agent's avatar/profile image URL.
@@ -15317,7 +15237,7 @@
15317
15237
  * Markdown documentation for META LINK commitment.
15318
15238
  */
15319
15239
  get documentation() {
15320
- return spaceTrim.spaceTrim(`
15240
+ return spaceTrim$1.spaceTrim(`
15321
15241
  # META LINK
15322
15242
 
15323
15243
  Represents a profile or source link for the person the agent is modeled after.
@@ -15427,7 +15347,7 @@
15427
15347
  * Markdown documentation for MODEL commitment.
15428
15348
  */
15429
15349
  get documentation() {
15430
- return spaceTrim.spaceTrim(`
15350
+ return spaceTrim$1.spaceTrim(`
15431
15351
  # ${this.type}
15432
15352
 
15433
15353
  Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
@@ -15668,7 +15588,7 @@
15668
15588
  * Markdown documentation for NOTE commitment.
15669
15589
  */
15670
15590
  get documentation() {
15671
- return spaceTrim.spaceTrim(`
15591
+ return spaceTrim$1.spaceTrim(`
15672
15592
  # ${this.type}
15673
15593
 
15674
15594
  Adds comments for documentation without changing agent behavior.
@@ -15767,7 +15687,7 @@
15767
15687
  * Markdown documentation for OPEN commitment.
15768
15688
  */
15769
15689
  get documentation() {
15770
- return spaceTrim.spaceTrim(`
15690
+ return spaceTrim$1.spaceTrim(`
15771
15691
  # OPEN
15772
15692
 
15773
15693
  Specifies that the agent can be modified by conversation with it.
@@ -15844,7 +15764,7 @@
15844
15764
  * Markdown documentation for PERSONA commitment.
15845
15765
  */
15846
15766
  get documentation() {
15847
- return spaceTrim.spaceTrim(`
15767
+ return spaceTrim$1.spaceTrim(`
15848
15768
  # ${this.type}
15849
15769
 
15850
15770
  Defines who the agent is, their background, expertise, and personality traits.
@@ -15977,7 +15897,7 @@
15977
15897
  * Markdown documentation for RULE/RULES commitment.
15978
15898
  */
15979
15899
  get documentation() {
15980
- return spaceTrim.spaceTrim(`
15900
+ return spaceTrim$1.spaceTrim(`
15981
15901
  # ${this.type}
15982
15902
 
15983
15903
  Adds behavioral constraints and guidelines that the agent must follow.
@@ -16059,7 +15979,7 @@
16059
15979
  * Markdown documentation for SAMPLE/EXAMPLE commitment.
16060
15980
  */
16061
15981
  get documentation() {
16062
- return spaceTrim.spaceTrim(`
15982
+ return spaceTrim$1.spaceTrim(`
16063
15983
  # ${this.type}
16064
15984
 
16065
15985
  Provides examples of how the agent should respond or behave in certain situations.
@@ -16142,7 +16062,7 @@
16142
16062
  * Markdown documentation for SCENARIO commitment.
16143
16063
  */
16144
16064
  get documentation() {
16145
- return spaceTrim.spaceTrim(`
16065
+ return spaceTrim$1.spaceTrim(`
16146
16066
  # ${this.type}
16147
16067
 
16148
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.
@@ -16264,7 +16184,7 @@
16264
16184
  * Markdown documentation for STYLE commitment.
16265
16185
  */
16266
16186
  get documentation() {
16267
- return spaceTrim.spaceTrim(`
16187
+ return spaceTrim$1.spaceTrim(`
16268
16188
  # ${this.type}
16269
16189
 
16270
16190
  Defines how the agent should format and present its responses (tone, writing style, formatting).
@@ -16311,86 +16231,563 @@
16311
16231
  * [💞] Ignore a discrepancy between file name and entity name
16312
16232
  */
16313
16233
 
16314
- // Import all commitment definition classes
16315
- // Register fully implemented commitments
16316
- registerCommitment(new PersonaCommitmentDefinition('PERSONA'));
16317
- registerCommitment(new PersonaCommitmentDefinition('PERSONAE'));
16318
- registerCommitment(new KnowledgeCommitmentDefinition());
16319
- registerCommitment(new MemoryCommitmentDefinition('MEMORY'));
16320
- registerCommitment(new MemoryCommitmentDefinition('MEMORIES'));
16321
- registerCommitment(new StyleCommitmentDefinition('STYLE'));
16322
- registerCommitment(new StyleCommitmentDefinition('STYLES'));
16323
- registerCommitment(new RuleCommitmentDefinition('RULE'));
16324
- registerCommitment(new RuleCommitmentDefinition('RULES'));
16325
- registerCommitment(new LanguageCommitmentDefinition('LANGUAGE'));
16326
- registerCommitment(new LanguageCommitmentDefinition('LANGUAGES'));
16327
- registerCommitment(new SampleCommitmentDefinition('SAMPLE'));
16328
- registerCommitment(new SampleCommitmentDefinition('EXAMPLE'));
16329
- registerCommitment(new FormatCommitmentDefinition('FORMAT'));
16330
- registerCommitment(new FormatCommitmentDefinition('FORMATS'));
16331
- registerCommitment(new FromCommitmentDefinition('FROM'));
16332
- registerCommitment(new ModelCommitmentDefinition('MODEL'));
16333
- registerCommitment(new ModelCommitmentDefinition('MODELS'));
16334
- registerCommitment(new ActionCommitmentDefinition('ACTION'));
16335
- registerCommitment(new ActionCommitmentDefinition('ACTIONS'));
16336
- registerCommitment(new ComponentCommitmentDefinition());
16337
- registerCommitment(new MetaImageCommitmentDefinition());
16338
- registerCommitment(new MetaColorCommitmentDefinition());
16339
- registerCommitment(new MetaLinkCommitmentDefinition());
16340
- registerCommitment(new MetaCommitmentDefinition());
16341
- registerCommitment(new NoteCommitmentDefinition('NOTE'));
16342
- registerCommitment(new NoteCommitmentDefinition('NOTES'));
16343
- registerCommitment(new NoteCommitmentDefinition('COMMENT'));
16344
- registerCommitment(new NoteCommitmentDefinition('NONCE'));
16345
- registerCommitment(new GoalCommitmentDefinition('GOAL'));
16346
- registerCommitment(new GoalCommitmentDefinition('GOALS'));
16347
- registerCommitment(new ImportantCommitmentDefinition());
16348
- registerCommitment(new InitialMessageCommitmentDefinition());
16349
- registerCommitment(new UserMessageCommitmentDefinition());
16350
- registerCommitment(new AgentMessageCommitmentDefinition());
16351
- registerCommitment(new MessageCommitmentDefinition('MESSAGE'));
16352
- registerCommitment(new MessageCommitmentDefinition('MESSAGES'));
16353
- registerCommitment(new ScenarioCommitmentDefinition('SCENARIO'));
16354
- registerCommitment(new ScenarioCommitmentDefinition('SCENARIOS'));
16355
- registerCommitment(new DeleteCommitmentDefinition('DELETE'));
16356
- registerCommitment(new DeleteCommitmentDefinition('CANCEL'));
16357
- registerCommitment(new DeleteCommitmentDefinition('DISCARD'));
16358
- registerCommitment(new DeleteCommitmentDefinition('REMOVE'));
16359
- registerCommitment(new OpenCommitmentDefinition());
16360
- registerCommitment(new ClosedCommitmentDefinition());
16361
- // Register not yet implemented commitments
16362
- registerCommitment(new NotYetImplementedCommitmentDefinition('EXPECT'));
16363
- registerCommitment(new NotYetImplementedCommitmentDefinition('BEHAVIOUR'));
16364
- registerCommitment(new NotYetImplementedCommitmentDefinition('BEHAVIOURS'));
16365
- registerCommitment(new NotYetImplementedCommitmentDefinition('AVOID'));
16366
- registerCommitment(new NotYetImplementedCommitmentDefinition('AVOIDANCE'));
16367
- registerCommitment(new NotYetImplementedCommitmentDefinition('CONTEXT'));
16368
-
16369
16234
  /**
16370
- * Creates an empty/basic agent model requirements object
16371
- * This serves as the starting point for the reduce-like pattern
16372
- * where each commitment applies its changes to build the final requirements
16235
+ * USE commitment definition
16373
16236
  *
16374
- * @public exported from `@promptbook/core`
16375
- */
16376
- function createEmptyAgentModelRequirements() {
16377
- return {
16378
- systemMessage: '',
16379
- // modelName: 'gpt-5',
16380
- modelName: 'gemini-2.5-flash-lite',
16381
- temperature: 0.7,
16382
- topP: 0.9,
16383
- topK: 50,
16384
- };
16385
- }
16386
- /**
16387
- * Creates a basic agent model requirements with just the agent name
16388
- * This is used when we have an agent name but no commitments
16237
+ * The USE commitment indicates that the agent should utilize specific tools or capabilities
16238
+ * to access and interact with external systems when necessary.
16389
16239
  *
16390
- * @public exported from `@promptbook/core`
16391
- */
16392
- function createBasicAgentModelRequirements(agentName) {
16393
- const empty = createEmptyAgentModelRequirements();
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
+
16617
+ /**
16618
+ * Placeholder commitment definition for commitments that are not yet implemented
16619
+ *
16620
+ * This commitment simply adds its content 1:1 into the system message,
16621
+ * preserving the original behavior until proper implementation is added.
16622
+ *
16623
+ * @public exported from `@promptbook/core`
16624
+ */
16625
+ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
16626
+ constructor(type) {
16627
+ super(type);
16628
+ }
16629
+ /**
16630
+ * Short one-line description of a placeholder commitment.
16631
+ */
16632
+ get description() {
16633
+ return 'Placeholder commitment that appends content verbatim to the system message.';
16634
+ }
16635
+ /**
16636
+ * Icon for this commitment.
16637
+ */
16638
+ get icon() {
16639
+ return '🚧';
16640
+ }
16641
+ /**
16642
+ * Markdown documentation available at runtime.
16643
+ */
16644
+ get documentation() {
16645
+ return spaceTrim$1.spaceTrim(`
16646
+ # ${this.type}
16647
+
16648
+ This commitment is not yet fully implemented.
16649
+
16650
+ ## Key aspects
16651
+
16652
+ - Content is appended directly to the system message.
16653
+ - No special processing or validation is performed.
16654
+ - Behavior preserved until proper implementation is added.
16655
+
16656
+ ## Status
16657
+
16658
+ - **Status:** Placeholder implementation
16659
+ - **Effect:** Appends content prefixed by commitment type
16660
+ - **Future:** Will be replaced with specialized logic
16661
+
16662
+ ## Examples
16663
+
16664
+ \`\`\`book
16665
+ Example Agent
16666
+
16667
+ PERSONA You are a helpful assistant
16668
+ ${this.type} Your content here
16669
+ RULE Always be helpful
16670
+ \`\`\`
16671
+ `);
16672
+ }
16673
+ applyToAgentModelRequirements(requirements, content) {
16674
+ const trimmedContent = content.trim();
16675
+ if (!trimmedContent) {
16676
+ return requirements;
16677
+ }
16678
+ // Add the commitment content 1:1 to the system message
16679
+ const commitmentLine = `${this.type} ${trimmedContent}`;
16680
+ return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
16681
+ }
16682
+ }
16683
+
16684
+ // Import all commitment definition classes
16685
+ /**
16686
+ * Registry of all available commitment definitions
16687
+ * This array contains instances of all commitment definitions
16688
+ * This is the single source of truth for all commitments in the system
16689
+ *
16690
+ * @private Use functions to access commitments instead of this array directly
16691
+ */
16692
+ const COMMITMENT_REGISTRY = [
16693
+ // Fully implemented commitments
16694
+ new PersonaCommitmentDefinition('PERSONA'),
16695
+ new PersonaCommitmentDefinition('PERSONAE'),
16696
+ new KnowledgeCommitmentDefinition(),
16697
+ new MemoryCommitmentDefinition('MEMORY'),
16698
+ new MemoryCommitmentDefinition('MEMORIES'),
16699
+ new StyleCommitmentDefinition('STYLE'),
16700
+ new StyleCommitmentDefinition('STYLES'),
16701
+ new RuleCommitmentDefinition('RULE'),
16702
+ new RuleCommitmentDefinition('RULES'),
16703
+ new LanguageCommitmentDefinition('LANGUAGE'),
16704
+ new LanguageCommitmentDefinition('LANGUAGES'),
16705
+ new SampleCommitmentDefinition('SAMPLE'),
16706
+ new SampleCommitmentDefinition('EXAMPLE'),
16707
+ new FormatCommitmentDefinition('FORMAT'),
16708
+ new FormatCommitmentDefinition('FORMATS'),
16709
+ new FromCommitmentDefinition('FROM'),
16710
+ new ModelCommitmentDefinition('MODEL'),
16711
+ new ModelCommitmentDefinition('MODELS'),
16712
+ new ActionCommitmentDefinition('ACTION'),
16713
+ new ActionCommitmentDefinition('ACTIONS'),
16714
+ new ComponentCommitmentDefinition(),
16715
+ new MetaImageCommitmentDefinition(),
16716
+ new MetaColorCommitmentDefinition(),
16717
+ new MetaFontCommitmentDefinition(),
16718
+ new MetaLinkCommitmentDefinition(),
16719
+ new MetaCommitmentDefinition(),
16720
+ new NoteCommitmentDefinition('NOTE'),
16721
+ new NoteCommitmentDefinition('NOTES'),
16722
+ new NoteCommitmentDefinition('COMMENT'),
16723
+ new NoteCommitmentDefinition('NONCE'),
16724
+ new GoalCommitmentDefinition('GOAL'),
16725
+ new GoalCommitmentDefinition('GOALS'),
16726
+ new InitialMessageCommitmentDefinition(),
16727
+ new UserMessageCommitmentDefinition(),
16728
+ new AgentMessageCommitmentDefinition(),
16729
+ new MessageCommitmentDefinition('MESSAGE'),
16730
+ new MessageCommitmentDefinition('MESSAGES'),
16731
+ new ScenarioCommitmentDefinition('SCENARIO'),
16732
+ new ScenarioCommitmentDefinition('SCENARIOS'),
16733
+ new DeleteCommitmentDefinition('DELETE'),
16734
+ new DeleteCommitmentDefinition('CANCEL'),
16735
+ new DeleteCommitmentDefinition('DISCARD'),
16736
+ new DeleteCommitmentDefinition('REMOVE'),
16737
+ new OpenCommitmentDefinition(),
16738
+ new ClosedCommitmentDefinition(),
16739
+ new UseBrowserCommitmentDefinition(),
16740
+ new UseSearchEngineCommitmentDefinition(),
16741
+ new UseMcpCommitmentDefinition(),
16742
+ new UseCommitmentDefinition(),
16743
+ // Not yet implemented commitments (using placeholder)
16744
+ new NotYetImplementedCommitmentDefinition('EXPECT'),
16745
+ new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
16746
+ new NotYetImplementedCommitmentDefinition('BEHAVIOURS'),
16747
+ new NotYetImplementedCommitmentDefinition('AVOID'),
16748
+ new NotYetImplementedCommitmentDefinition('AVOIDANCE'),
16749
+ new NotYetImplementedCommitmentDefinition('CONTEXT'),
16750
+ ];
16751
+ /**
16752
+ * Gets a commitment definition by its type
16753
+ * @param type The commitment type to look up
16754
+ * @returns The commitment definition or null if not found
16755
+ *
16756
+ * @public exported from `@promptbook/core`
16757
+ */
16758
+ function getCommitmentDefinition(type) {
16759
+ return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
16760
+ }
16761
+ /**
16762
+ * TODO: [🧠] Maybe create through standardized $register
16763
+ * Note: [💞] Ignore a discrepancy between file name and entity name
16764
+ */
16765
+
16766
+ /**
16767
+ * Creates an empty/basic agent model requirements object
16768
+ * This serves as the starting point for the reduce-like pattern
16769
+ * where each commitment applies its changes to build the final requirements
16770
+ *
16771
+ * @public exported from `@promptbook/core`
16772
+ */
16773
+ function createEmptyAgentModelRequirements() {
16774
+ return {
16775
+ systemMessage: '',
16776
+ // modelName: 'gpt-5',
16777
+ modelName: 'gemini-2.5-flash-lite',
16778
+ temperature: 0.7,
16779
+ topP: 0.9,
16780
+ topK: 50,
16781
+ };
16782
+ }
16783
+ /**
16784
+ * Creates a basic agent model requirements with just the agent name
16785
+ * This is used when we have an agent name but no commitments
16786
+ *
16787
+ * @public exported from `@promptbook/core`
16788
+ */
16789
+ function createBasicAgentModelRequirements(agentName) {
16790
+ const empty = createEmptyAgentModelRequirements();
16394
16791
  return {
16395
16792
  ...empty,
16396
16793
  systemMessage: `You are ${agentName || 'AI Agent'}`,
@@ -16400,6 +16797,11 @@
16400
16797
  * TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
16401
16798
  */
16402
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]*$/;
16403
16805
  /**
16404
16806
  * Parses agent source using the new commitment system with multiline support
16405
16807
  * This function replaces the hardcoded commitment parsing in the original parseAgentSource
@@ -16442,7 +16844,7 @@
16442
16844
  const fullContent = currentCommitment.contentLines.join('\n');
16443
16845
  commitments.push({
16444
16846
  type: currentCommitment.type,
16445
- content: spaceTrim.spaceTrim(fullContent),
16847
+ content: spaceTrim$1.spaceTrim(fullContent),
16446
16848
  originalLine: currentCommitment.originalStartLine,
16447
16849
  lineNumber: currentCommitment.startLineNumber,
16448
16850
  });
@@ -16462,6 +16864,24 @@
16462
16864
  break;
16463
16865
  }
16464
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
+ }
16465
16885
  if (!foundNewCommitment) {
16466
16886
  if (currentCommitment) {
16467
16887
  // This line belongs to the current commitment
@@ -16478,7 +16898,7 @@
16478
16898
  const fullContent = currentCommitment.contentLines.join('\n');
16479
16899
  commitments.push({
16480
16900
  type: currentCommitment.type,
16481
- content: spaceTrim.spaceTrim(fullContent),
16901
+ content: spaceTrim$1.spaceTrim(fullContent),
16482
16902
  originalLine: currentCommitment.originalStartLine,
16483
16903
  lineNumber: currentCommitment.startLineNumber,
16484
16904
  });
@@ -16977,7 +17397,7 @@
16977
17397
  let trimmedText = text;
16978
17398
  // Remove leading and trailing spaces and newlines
16979
17399
  if (isTrimmed) {
16980
- trimmedText = spaceTrim.spaceTrim(trimmedText);
17400
+ trimmedText = spaceTrim$1.spaceTrim(trimmedText);
16981
17401
  }
16982
17402
  let processedText = trimmedText;
16983
17403
  if (isIntroduceSentenceRemoved) {
@@ -16986,7 +17406,7 @@
16986
17406
  // Remove the introduce sentence and quotes by replacing it with an empty string
16987
17407
  processedText = processedText.replace(introduceSentenceRegex, '');
16988
17408
  }
16989
- processedText = spaceTrim.spaceTrim(processedText);
17409
+ processedText = spaceTrim$1.spaceTrim(processedText);
16990
17410
  }
16991
17411
  if (processedText.length < 3) {
16992
17412
  return trimmedText;
@@ -17170,6 +17590,10 @@
17170
17590
  meta.color = spaceTrim__default["default"](commitment.content);
17171
17591
  continue;
17172
17592
  }
17593
+ if (commitment.type === 'META FONT') {
17594
+ meta.font = spaceTrim__default["default"](commitment.content);
17595
+ continue;
17596
+ }
17173
17597
  if (commitment.type !== 'META') {
17174
17598
  continue;
17175
17599
  }
@@ -18710,13 +19134,13 @@
18710
19134
  * @public exported from `@promptbook/markdown-utils`
18711
19135
  */
18712
19136
  function trimCodeBlock(value) {
18713
- value = spaceTrim.spaceTrim(value);
19137
+ value = spaceTrim$1.spaceTrim(value);
18714
19138
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
18715
19139
  return value;
18716
19140
  }
18717
19141
  value = value.replace(/^```[a-z]*/i, '');
18718
19142
  value = value.replace(/```$/i, '');
18719
- value = spaceTrim.spaceTrim(value);
19143
+ value = spaceTrim$1.spaceTrim(value);
18720
19144
  return value;
18721
19145
  }
18722
19146
 
@@ -18729,9 +19153,9 @@
18729
19153
  * @public exported from `@promptbook/markdown-utils`
18730
19154
  */
18731
19155
  function trimEndOfCodeBlock(value) {
18732
- value = spaceTrim.spaceTrim(value);
19156
+ value = spaceTrim$1.spaceTrim(value);
18733
19157
  value = value.replace(/```$/g, '');
18734
- value = spaceTrim.spaceTrim(value);
19158
+ value = spaceTrim$1.spaceTrim(value);
18735
19159
  return value;
18736
19160
  }
18737
19161
 
@@ -21166,7 +21590,7 @@
21166
21590
  function getParserForCommand(command) {
21167
21591
  const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
21168
21592
  if (commandParser === undefined) {
21169
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
21593
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
21170
21594
  Command ${command.type} parser is not found
21171
21595
 
21172
21596
  ${block(JSON.stringify(command, null, 4)
@@ -21242,7 +21666,7 @@
21242
21666
  .map(removeMarkdownFormatting)
21243
21667
  .map((item) => item.trim());
21244
21668
  if (items.length === 0 || items[0] === '') {
21245
- throw new ParseError(spaceTrim.spaceTrim((block) => `
21669
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21246
21670
  Malformed command:
21247
21671
  - ${raw}
21248
21672
 
@@ -21278,7 +21702,7 @@
21278
21702
  return command;
21279
21703
  }
21280
21704
  }
21281
- throw new ParseError(spaceTrim.spaceTrim((block) => `
21705
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21282
21706
  Malformed or unknown command:
21283
21707
  - ${raw}
21284
21708
 
@@ -21329,7 +21753,7 @@
21329
21753
  if (!(error instanceof ParseError)) {
21330
21754
  throw error;
21331
21755
  }
21332
- throw new ParseError(spaceTrim.spaceTrim((block) => `
21756
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21333
21757
  Invalid ${commandName} command:
21334
21758
 
21335
21759
  Your command:
@@ -21645,7 +22069,7 @@
21645
22069
  * @public exported from `@promptbook/markdown-utils`
21646
22070
  */
21647
22071
  function removeMarkdownComments(content) {
21648
- return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
22072
+ return spaceTrim$1.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
21649
22073
  }
21650
22074
 
21651
22075
  /**
@@ -21930,7 +22354,7 @@
21930
22354
  if (pipelineString.startsWith('#!')) {
21931
22355
  const [shebangLine, ...restLines] = pipelineString.split('\n');
21932
22356
  if (!(shebangLine || '').includes('ptbk')) {
21933
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22357
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21934
22358
  It seems that you try to parse a book file which has non-standard shebang line for book files:
21935
22359
  Shebang line must contain 'ptbk'
21936
22360
 
@@ -21946,7 +22370,7 @@
21946
22370
  pipelineString = validatePipelineString(restLines.join('\n'));
21947
22371
  }
21948
22372
  pipelineString = removeMarkdownComments(pipelineString);
21949
- pipelineString = spaceTrim.spaceTrim(pipelineString);
22373
+ pipelineString = spaceTrim$1.spaceTrim(pipelineString);
21950
22374
  // <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
21951
22375
  pipelineString = deflatePipeline(pipelineString);
21952
22376
  // ==============
@@ -21958,7 +22382,7 @@
21958
22382
  // ==============
21959
22383
  // Note: 1️⃣◽4️⃣ Check markdown structure
21960
22384
  if (pipelineHead === undefined) {
21961
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
22385
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
21962
22386
  Pipeline head is not defined
21963
22387
 
21964
22388
  ${block(getPipelineIdentification())}
@@ -21967,7 +22391,7 @@
21967
22391
  `));
21968
22392
  }
21969
22393
  if (pipelineHead.level !== 1) {
21970
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
22394
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
21971
22395
  Pipeline head is not h1
21972
22396
 
21973
22397
  ${block(getPipelineIdentification())}
@@ -21976,7 +22400,7 @@
21976
22400
  `));
21977
22401
  }
21978
22402
  if (!pipelineSections.every((section) => section.level === 2)) {
21979
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
22403
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
21980
22404
  Not every pipeline section is h2
21981
22405
 
21982
22406
  ${block(getPipelineIdentification())}
@@ -21989,7 +22413,7 @@
21989
22413
  const defineParam = (parameterCommand) => {
21990
22414
  const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
21991
22415
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
21992
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22416
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
21993
22417
  Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
21994
22418
 
21995
22419
  ${block(getPipelineIdentification())}
@@ -22000,7 +22424,7 @@
22000
22424
  existingParameter.description &&
22001
22425
  existingParameter.description !== parameterDescription &&
22002
22426
  parameterDescription) {
22003
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22427
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
22004
22428
  Parameter \`{${parameterName}}\` is defined multiple times with different description:
22005
22429
 
22006
22430
  ${block(getPipelineIdentification())}
@@ -22038,7 +22462,7 @@
22038
22462
  description = description.split(/^>.*$/gm).join('');
22039
22463
  //Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
22040
22464
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
22041
- description = spaceTrim.spaceTrim(description);
22465
+ description = spaceTrim$1.spaceTrim(description);
22042
22466
  if (description === '') {
22043
22467
  description = undefined;
22044
22468
  }
@@ -22049,7 +22473,7 @@
22049
22473
  const command = parseCommand(listItem, 'PIPELINE_HEAD');
22050
22474
  const commandParser = getParserForCommand(command);
22051
22475
  if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
22052
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22476
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
22053
22477
  Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
22054
22478
 
22055
22479
  ${block(getPipelineIdentification())}
@@ -22063,7 +22487,7 @@
22063
22487
  if (!(error instanceof ParseError)) {
22064
22488
  throw error;
22065
22489
  }
22066
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22490
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
22067
22491
  Command ${command.type} failed to apply to the pipeline
22068
22492
 
22069
22493
  The error:
@@ -22116,7 +22540,7 @@
22116
22540
  description = description.split(/^>.*$/gm).join('');
22117
22541
  //Note: Remove lists and return statement - TODO: [🎾]
22118
22542
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
22119
- description = spaceTrim.spaceTrim(description);
22543
+ description = spaceTrim$1.spaceTrim(description);
22120
22544
  if (description === '') {
22121
22545
  description = undefined;
22122
22546
  }
@@ -22150,7 +22574,7 @@
22150
22574
  for (const { listItem, command } of commands) {
22151
22575
  const commandParser = getParserForCommand(command);
22152
22576
  if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
22153
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22577
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
22154
22578
  Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
22155
22579
 
22156
22580
  ${block(getPipelineIdentification())}
@@ -22165,7 +22589,7 @@
22165
22589
  if (!(error instanceof ParseError)) {
22166
22590
  throw error;
22167
22591
  }
22168
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22592
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
22169
22593
  Command \`${command.type}\` failed to apply to the task
22170
22594
 
22171
22595
  The error:
@@ -22196,14 +22620,14 @@
22196
22620
  // TODO: [🍧] Should be done in SECTION command
22197
22621
  if ($taskJson.taskType === 'SCRIPT_TASK') {
22198
22622
  if (!language) {
22199
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22623
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
22200
22624
  You must specify the language of the script in the \`SCRIPT\` task
22201
22625
 
22202
22626
  ${block(getPipelineIdentification())}
22203
22627
  `));
22204
22628
  }
22205
22629
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
22206
- throw new ParseError(spaceTrim.spaceTrim((block) => `
22630
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
22207
22631
  Script language ${language} is not supported.
22208
22632
 
22209
22633
  Supported languages are: